On 17 Sep 2015, at 09:32, Thierry Goubier <thierry.goubier@gmail.com> wrote:
2015-09-17 9:10 GMT+02:00 Nicolai Hess <nicolaihess@web.de>:
2015-09-16 15:14 GMT+02:00 Thierry Goubier <thierry.goubier@gmail.com>: Argh, sent too early:
self new color: Color red; yourself
est bien une cascade, non?
Yes, but in
(self new color: Color red); yourself the expression in parenthesis looks like "this evalulates first, to 'anObject' ", so we send " ; yourself", a cascaded messages with only one message to "anObject".
Yes, agreed of course.
In a way, it looks like an error correction type of thing: the parser knows the parenthesis shouldn't be there or the ; shouldn't be there, so it chooses one interpretation out of the two: here it is the parenthesis are unnecessary.
Hmm, I don't agree. We as humans can infer that, from a language/compiler's standpoint it is not clear/possible. someObject message1; message2 is a pure cascade (someObject message1) message2 is not a cascade, message2 being sent to the result the last expression is totally equivalent to someObject message1 message2 However expression message expression ; message could be equivalent, like if it said expression yourself; message but the decision to drop the parenthesis cannot be made automatically, IMHO I would make the spurious ; an error, to avoid confusion
By the way, John found another issue with a fix you did in RBParser (RBPatternParser>>parseUnaryMessage) which fail some refactoring expressions. Can you have a look?
Thierry
Thierry
2015-09-16 15:12 GMT+02:00 Thierry Goubier <thierry.goubier@gmail.com>:
2015-09-16 15:05 GMT+02:00 Nicolai Hess <nicolaihess@web.de>: OK, I think Sven is right and a cascade needs at least one message send
"self ; yourself"
doesn't work too (both parser don't accept this).
But
There are currently two methods in Pharo 5.0 with this syntax:
DAPackageAnalyzerWindow class>>#onPackagesNamed: DAPackageCycleDetectionTreeModel class>>#onPackagesNamed:
@Yuri, can you change that.
And I think we should fix RBParser.
2015-09-16 11:30 GMT+02:00 Thierry Goubier <thierry.goubier@gmail.com>: Nicolai,
can you try with the RBParser directly? I believe Opal uses the RBParser.
RBParser parseMethod: 'createRedMorph ^ (self new color:Color red); yourself'
Oh, RBParser sees it as:
self new color: Color red; yourself
:)
Thierry
2015-09-16 10:56 GMT+02:00 Nicolai Hess <nicolaihess@web.de>: The following method compiles with Opal:
createRedMorph ^ (self new color:Color red); yourself
but gives a syntax error with the old compilers parser
createRedMorph ^ (self new color:Color red)End of block expected -> ; yourself
removing the parenthesis of course works for both. Who is right ?
(for those who understand the ParseTreeSearcher syntax, how would a search expression look, for finding code like:
"(some expression);yourself"
nicolai