Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pluto doesn't like adding constructors to structs #732

Closed
MasonProtter opened this issue Nov 28, 2020 · 5 comments
Closed

Pluto doesn't like adding constructors to structs #732

MasonProtter opened this issue Nov 28, 2020 · 5 comments
Labels
one day Closed because we won't work on it soon, will be opened again later.

Comments

@MasonProtter
Copy link

Compare

image

versus

image

Seems like a bug in the algorithm for detecting multiple incompatible definitions of something.

@fonsp
Copy link
Owner

fonsp commented Nov 29, 2020

This is on purpose, handling a mix of structs definitions and methods is very diffcult, because:

  1. pluto should be able to undo the scope effect from any cell. Pluto does support multiple methods across cells (👒 Include function signature in reactive edge - fix #177 #538), because it is relatively easy to delete methods defined in one cell, while keeping those defined in other cells. With structs, we also need to take the newly defined type into account.
  2. The outer constructor is a recursive call, see Cyclic references between methods in cells #178

@fonsp fonsp closed this as completed Nov 29, 2020
@MasonProtter
Copy link
Author

I get that it's difficult, but I feel this issue should stay open (whether or not anyone is actively working on it). This is certainly an issue other people will run into at some point so it'd be good for them to see that there's already an open issue.

If you want, you can even use the 'Won't Fix' label.

@SyxP
Copy link
Contributor

SyxP commented Nov 29, 2020

If you want a workaround somehow, the following works. (Not that I encourage the following style)

struct Temp
	x
end

Temp(4)

for i in [:Temp]
	@eval ($i)() = Temp(42)
end

Temp()

@MasonProtter
Copy link
Author

Yeah, one can also just do

@eval $(:Temp)() = Temp(42)

Still pretty unsightly, but a bit better.

@fonsp
Copy link
Owner

fonsp commented Nov 29, 2020

I don't recommend this to general users -- it will lead to lots of hidden issues later. Use a begin block.

@fonsp fonsp added the one day Closed because we won't work on it soon, will be opened again later. label Nov 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
one day Closed because we won't work on it soon, will be opened again later.
Projects
None yet
Development

No branches or pull requests

3 participants