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

make empty mutable structs non-singletons #17149

Closed
carnaval opened this issue Jun 27, 2016 · 9 comments
Closed

make empty mutable structs non-singletons #17149

carnaval opened this issue Jun 27, 2016 · 9 comments
Labels
compiler:codegen Generation of LLVM IR and native code
Milestone

Comments

@carnaval
Copy link
Contributor

note to self

@vtjnash
Copy link
Member

vtjnash commented Jun 27, 2016

:)

I think there may even be a few places already where we do so, but inconsistently. Alternatively, you could make mutable singletons unique values instead of being strangely almost equivalent to their immutable cousins.

@tkelman tkelman added the compiler:codegen Generation of LLVM IR and native code label Jun 27, 2016
@eschnett
Copy link
Contributor

Yes, having mutable singletons be unique would be cool. Currently I'm adding an unused Int field to a mutable type for this (is there a better way)?

@yuyichao
Copy link
Contributor

I thought this is only about codegen calling convention rather than object construction? "mutable" singletons should already be unique. What does adding a Int field accomplish?

@eschnett
Copy link
Contributor

@yuyichao

type N end
N()===N()
true

type N1 i::Int; N1()=new() end
N1()===N1()
false

Each call to N1() creates a new, unique object that can be used as abstract id. (An alternative would be using a global counter.) Calls to an empty type constructor such as N() don't; all objects of type N are identical, as if they were immutable.

@yuyichao
Copy link
Contributor

OK, you mean unique as each of them are different, not that it has a global unique value.....

@toivoh
Copy link
Contributor

toivoh commented Jun 28, 2016

@eschnett: You can use a field of eg type Void instead of an Int field, should save some space?

But I agree that it would be nice if there could be multiple instances of mutable types without fields. The current behavior was very handy before we had immutables, but now that we do, it just feels inconsistent.

@stevengj
Copy link
Member

stevengj commented Feb 1, 2018

This came up on discourse recently. I agree that having mutable singletons construct unique (not ===) objects makes sense nowadays.

@stevengj stevengj added the triage This should be discussed on a triage call label Feb 1, 2018
@stevengj
Copy link
Member

stevengj commented Feb 1, 2018

Marking as triage since it seems like this should really get decided before 1.0.

@Keno
Copy link
Member

Keno commented Feb 1, 2018

Triage says yes, let's make empty mutable structs give non-singleton.

@JeffBezanson JeffBezanson changed the title treat mutable singletons as ghost types in codegen make empty mutable structs non-singletons Feb 1, 2018
@StefanKarpinski StefanKarpinski removed the triage This should be discussed on a triage call label Feb 1, 2018
@StefanKarpinski StefanKarpinski added this to the 1.0 milestone Feb 1, 2018
Keno added a commit that referenced this issue Feb 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:codegen Generation of LLVM IR and native code
Projects
None yet
Development

No branches or pull requests

9 participants