MiniD dsource project set up
Jarrett Billingsley
kb3ctd2 at yahoo.com
Tue Jun 27 07:53:43 PDT 2006
"James Dunne" <james.jdunne at gmail.com> wrote in message
news:e7qdqp$k3m$1 at digitaldaemon.com...
> Okay, I see now. I was thinking in terms of indexors as properties, like
> myobj.a[3] = 4; and a = myobj.b[6,7], etc.
I was originally toying with the idea of namespaces for properties which
would hold special functions like opSet and opGet, and then could also hold
things like opIndex[Assign] and opSlice[Assign]. That started getting a
little complex, but I suppose some special functions could be allowed in the
property blocks, such as
property int x
{
def int opIndex(int index)
{
return mArray[index];
}
def int opIndexAssign(int value, int index)
{
return mArray[index] = value;
}
}
...
def A a = new A;
a.x[5] = 4;
io.writefln(a.x[5]);
It could work. It's something that I always wanted in D - the ability to
easily wrap an array in a class, allowing access to the members but to
nothing else (so the user couldn't resize, sort, delete etc. the array).
> Yeah I also find myself avoiding chained assignments, but I don't know
> why. I guess I like to limit the horizontal span of my code. It's much
> easier to scroll vertically (go mouse-wheel!) than it is to scroll
> horizontally. :)
I always follow the mantra of one statement per line. That's partly why you
can't have multiple variable declarations on one line, and also why there's
no postfix ++ and -- (since IMO they cause nothing but confusion).
> Oh yeah, the globals - I always forget about the globals... They're local
> to the global scope, yes?
Mmmmmm..... maybe. ;)
> How about switching to a Pascal-inspired declaration syntax in combination
> with the 'function' keyword:
>
> function max(x,y : int) : int {
> return (x < y) ? y : x;
> }
>
> function hello(a, b : int) : function(c,d : int) : int {
> return max;
> }
>
> Reads nicely left-to-right.
Huuhh.. I've seen that kind of mix of C and Pascal before, and I'm not
entirely fond of it. It does certainly make parsing declarations much
easier.
> LOL - you don't get more disagreeable than that.
Yeah, templates scare me a bit. Especially something as complex as D's
templates. Perhaps very simple generics could work (basically just allow
templated classes / functions, with simple specialization), but that'd be
something for MiniD 2.0 ;)
> Overall, I like your idea! A D-looking script language that's easily
> embeddable in a D host program really makes it easy on the developer. Just
> don't put in too many 'gotchas' that would deviate far from the original
> D.
I'll try not to. Most of the things I'm changing are simply removing more
complex features, while trying to keep the rest as close as possible.
More information about the Digitalmars-d-announce
mailing list