Michiel
unread,May 19, 2009, 5:37:17 PM5/19/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Mist: The Programming Language
So, for the first message on this group, let's dive straight into the
interesting stuff. There's this language-feature I've been thinking
about. It's about making a program in the language easier to read.
Before I explain, this is clearly a low priority. And if it's ever
implemented, it will be in the distant future. But it's interesting
nonetheless.
The idea is that the caller of this function may invoke it with
something more like a sentence than a single function-name followed by
a list of actual parameters. Imagine the following:
swap (a) with (b);
To accomplish this, I imagine the developer of this function would
write it something like this:
void swap (ref int a) with (ref int b) {
int t <- a;
a <- b;
b <- t;
}
For those unfamiliar with Mist syntax, <- is the assignment operator.
Now, I'm not saying this is a particularly exciting use-case, but I
can imagine programs may become easier to read. Also, I believe it may
tie in perfectly with other potential language features. To name a
few:
------------------------------
If we have a functional language (e.g. functions can be passed as
parameters and anonymous literal functions may be specified), I
imagine library writers may use this to design custom control flow
construct. Like a three-way-conditional:
three_way (x, y)
greater ({ do_something(); })
equal ({ do_something_else(); })
less ({do_something_else_entirely(); });
Now, all we need is the possibility to leave out the () parentheses at
the call and it will look like a genuine language construct.
------------------------------
------------------------------
Another interesting related feature is the possibility to merge
control-flow structures. Like, merge a for-loop and a while-loop:
for (i, 1..N) while (other_condition) {
foobar();
}
Looks a bit like a multi-section function-call, right? That's actually
one loop, with an iterating component (for) and a condition component
(while). It may look familiar. Algol already had something similar in
1968!
The drawback of this idea is that loops would always require {}
brackets when their body begins, or a nested loop will be
indistinguishable from a merged loop.
------------------------------
Still reading? I know I'm jumping all over the place here.
Comments and wild brain-storming are welcome. :-)