Properties, opIndex, and expression rewriting.

Chad J chadjoan at __spam.is.bad__gmail.com
Tue Aug 11 00:19:42 PDT 2009


http://www.igsoft.net/dpolls/poll/results.php?pollid=1
* 111 votes total.
* Keep things as they are now: 1 vote.
* And where did that vote come from?
Jeremie Pelletier pisze:
>
> Oops, I got the only one "keep things as they are now" vote haha.
> I meant to vote for the one with resolved +=.
>

So, Walter, how about some expression rewriting logic to solve some of
the problems with properties, opIndex, and related lvalueness stuff?

(I refer to the expression rewriting in the Wiki4D article on
properties:
http://prowiki.org/wiki4d/wiki.cgi?DocComments/Property#Semantic)

Syntax can be broached later.

I've also attached some D-like pseudocode of what I think such an
expression rewriting algorithm would look like (propertyrewrite.d).  The
other file is a potential test-case.  I used it to figure out what a
trace of the algorithm might look like, and designed it accordingly.  If
it can wait a few weeks, I might try to put it into dmd and write a
patch.  I'll only do it if there's interest though.

Other notes about attached pseudocode:
* The types in this psuedocode are expected to be defined as D classes
are; that is, they are reference types.
* It seems worthwhile to call this after operator overloads are turned
into calls.  This would make it more clear which things potentially have
side effects.  (Just imagine how << is overloaded in C++.  As much as
it's frowned upon, something similar could happen in the future of D.
Marking overloads like '<<', '+', '-' as pure could potentially remove
any pessimisation.)
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: propertyrewrite.d
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20090811/cd9f01ab/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: monstrosity.d
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20090811/cd9f01ab/attachment-0001.ksh>


More information about the Digitalmars-d mailing list