News for hackers. Stuff that matters.
Re:Strings and the CLR – A Special Relationship by Someone on Wednesday June 01, 2016 @03:36AM (#11812678)
So, are there high-level languages that make it easy to write classes that include length-varies-by-instance member(s) in their memory layout?

That could be a huge efficiency gain because of cache misses.

Re:Strings and the CLR – A Special Relationship by twic on Wednesday June 01, 2016 @03:59AM (#11812762)
Smalltalk has that:

https://www.gnu.org/software/smalltalk/manual-base/html_node...

https://www.gnu.org/software/smalltalk/manual/html_node/Insi...

Although see the footnote - "This is not always true for other Smalltalk implementations, who don't allow instance variables in variableByteSubclasses and variableWordSubclasses". So, in some implementations, you can have either normal fields or array slots, but not both. That said, i think if you have a base class with fields, you can always make a subclass with slots.

Re:Strings and the CLR – A Special Relationship by masklinn on Wednesday June 01, 2016 @07:34AM (#11813550)
Rust has unsized (aka dynamically-sized) types, trait objects and slices are probably the most commonly encountered DSTs.

There are two main limitations to them:

* by default most generic code can not operate over them, generics require the special `?Sized` bound to allow DSTs (essentially generics have a default Sized generic bound)

* Rust doesn't currently support dynamic stack allocation so DSTs can't be stack-allocated (https://github.com/rust-lang/rfcs/issues/618)

Re:Strings and the CLR – A Special Relationship by needusername on Wednesday June 01, 2016 @12:36PM (#11815826)
There is a proposal for Java http://objectlayout.org/
Re:Strings and the CLR – A Special Relationship by matthewwarren on Wednesday June 01, 2016 @11:44AM (#11815315)
Thanks for asking this, I didn't even think about other languages and if they made this possible or not
Re:Strings and the CLR – A Special Relationship by pjmlp on Wednesday June 01, 2016 @07:10AM (#11813469)
I imagine Eiffel, Modula-3 and Ada are possible candidates, but would need to research it.