keean / zenscript

A trait based language that compiles to JavaScript
MIT License
42 stars 7 forks source link

Proxy Iterators #45

Open keean opened 5 years ago

keean commented 5 years ago

@shelby3 Another C++ mess: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0022r0.html

We need to think about this carefully in light of wanting to use Pony style references. The immediate solution that occurs to be is that we need a special "bit-reference" type that encodes a bit-shift and mask, so you would effectively encode an address, and a start and stop bit range:

struct bitReference {
   *word address,
   int shift
}

where the dereference operation would be:

((*bitref.word) >> shift) & 1

The real reason I think C++ fails, is because it actually uses the concrete dereference '*' directly, instead of implementing Stepanov's Readable, Writeable, Mutable Concepts. With dereference becoming a type-class you can totally avoid proxy iterators. It is probably too big a change with all that code already out there for C++...

shelby3 commented 5 years ago

The real reason I think C++ fails, is because it actually uses the concrete dereference '*' directly, instead of implementing Stepanov's Readable, Writeable, Mutable Concepts. With dereference becoming a type-class you can totally avoid proxy iterators. It is probably too big a change with all that code already out there for C++...

Agreed.

The problem is the assumption that a reference type is an address in memory. Instead we need to have a typeclass for operations of reading from and writing to the object referenced.

Section 3 of the paper you linked to notes that abstraction of referencing is also necessary for example when the referenced objects exist across the network, which may very well be the case with Actors.