Parser

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Parser

Chris Uppal-3
The following method (admittedly a bit odd) has its meaning changed by
reformat-and-save.

    method: aString

        ^ aString
            asLowercase;
            size + 2;
            yourself.

which (correctly, at least as compared with D4, and my understanding of
ANSI) answers the string.  Reformat re-writes it to:

        method: aString
            ^(aString
                asLowercase;
                size)
                + 2;
                yourself

which answer the length of the string.

(The reformat also throws away the terminating '.' which I don't like at
all -- I don't think reformatting should ever introduce or remove syntactic
elements -- but that's, presumably, a matter of finding out how to modulate
the RB's formatter, rather than a bug report for OA.)

    -- chris


Reply | Threaded
Open this post in threaded view
|

Re: Parser

Blair McGlashan
Chris

"Chris Uppal" <[hidden email]> wrote in message
news:[hidden email]...

> The following method (admittedly a bit odd) has its meaning changed by
> reformat-and-save.
>
>     method: aString
>
>         ^ aString
>             asLowercase;
>             size + 2;
>             yourself.
>
> which (correctly, at least as compared with D4, and my understanding of
> ANSI) answers the string.  Reformat re-writes it to:
>
>         method: aString
>             ^(aString
>                 asLowercase;
>                 size)
>                 + 2;
>                 yourself
>
> which answer the length of the string.

Actually I think the parser/formatter are probably correct. When we
originally implemented the Dolphin compiler (well before it was released to
the public) we got the interpretation of cascades completely wrong. When we
realised this we rewrote the parser to support what we thought was the
logically complete and correct way to parse them, but it is more "advanced"
than supported by traditional Smalltalk - VW won't even parse that method.
It may be that the ANSI spec. agrees with they way Dolphin parses cascades,
but I don't think that was deliberate (i.e. I expect the intent was to
standardise the behaviour of the major implementations at that time). I
didn't join the ANSI committee until very late on, and so wasn't involved
with discussions over syntax.

Regards

Blair


Reply | Threaded
Open this post in threaded view
|

Formatter

Ted Bracht-2
Hi Blair,

I came across a situation where the formatter added one tab too many. Not a
major issue.

from size > 0

    ifTrue:

        [from do:

                [:each |  "one tab too many"

                self model

                    addRate: (client

                                    send: 'getRate'  "maybe also one tab too
many? but nicely formatted under the receiver"

                                    with: each

                                    with: to) value

                    for: each.

                self refreshList]]