Brackets

13 views
Skip to first unread message

portly....@googlemail.com

unread,
Aug 14, 2011, 5:08:09 PM8/14/11
to Magpie
Hi Bob

I've been thinking about what you were saying about the use of
brackets for arguments on the right of a method but not the left. So
you can have

foo bar (bang baz) zoop and understand what is being called. As I
said before I don't like the use of brackets for one side of the
arguments because it lacks symmetry.

This is a call for any thoughts on how you can make this more
symmetrical. My own initial idea was to use a semicolon to break up
method calls. So that the previous example would be

foo bar bank baz; zoop

For a method with no arguments e..g print() this would become print;

A newline or a "do" would count the same as a semicolon - so the
following code

For 1 to (10) do

would be rewritten

For 1 to 10 do

Not sure if I'm explaining this correctly (it is late, I've got a cold
and I'm tired) but hopefully someone will understand what I'm trying
to say :-).

cheers

Dave

Bob Nystrom

unread,
Aug 16, 2011, 1:46:54 AM8/16/11
to magpi...@googlegroups.com
On Sun, Aug 14, 2011 at 2:08 PM, portly....@googlemail.com
<portly....@googlemail.com> wrote:
>  foo bar (bang baz) zoop and understand what is being called. As I
> said before I don't like the use of brackets for one side of the
> arguments because it lacks symmetry.

I'm not crazy about it either, but it's worth noting that code itself
isn't symmetric. The parser reads it from left to right, as do our
eyes.

> This is a call for any thoughts on how you can make this more
> symmetrical. My own initial idea was to use a semicolon to break up
> method calls. So that the previous example would be
>
> foo bar bank baz; zoop

So right now in Magpie, this:

foo bar (bang baz) zoop

would look like this in Java or C++:

foo.bar(bang.baz).zoop

Are you saying your proposal of "foo bar bank baz; zoop" would mean
the same thing? How does it distinguish between:

foo.bar(bang.baz).zoop

and

foo.bar.bang(baz).zoop

> For a method  with no arguments e..g print() this would become print;
>
> A newline or a "do" would count the same as a semicolon - so the
> following code

Newlines are actually equivalent to semicolons in Magpie right now.
You can use either as expression separators in a block. A semicolon is
rarely (never?) used in practice, but it's available if you wanted to
cram a few expressions on one line for some reason.

We could free it up for some other use, but using for anything other
than a separator/terminator would likely be deeply confusing for
anyone coming from a C/C++/Java/JS/etc. background.

> For 1 to 10 do

It might still be possible to accomplish that with some other proposal.

> Not sure if I'm explaining this correctly (it is late, I've got a cold
> and I'm tired) but hopefully someone will understand what I'm trying
> to say :-).

I kinda followed it, but not totally. :)

- bob

Reply all
Reply to author
Forward
0 new messages