The following method compiles with Opal: but gives a syntax error with the old compilers parsercreateRedMorph ^ (self new color:Color red); yourself createRedMorph ^ (self new color:Color red)End of block expected -> ; yourself (for those who understand the ParseTreeSearcher syntax, how would a search expression look, for finding code like: "(some expression);yourself" nicolai |
Interesting.
I think that for a cascade you need more than one message send. > On 16 Sep 2015, at 10:56, Nicolai Hess <[hidden email]> wrote: > > 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 > |
In reply to this post by Nicolai Hess
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 <[hidden email]>:
|
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). DAPackageAnalyzerWindow class>>#onPackagesNamed: DAPackageCycleDetectionTreeModel class>>#onPackagesNamed: 2015-09-16 11:30 GMT+02:00 Thierry Goubier <[hidden email]>:
|
Arrg, sorry Yuri, this (too) isn't from QualityAssistance, but DependencyAnalyzer
2015-09-16 15:05 GMT+02:00 Nicolai Hess <[hidden email]>:
|
In reply to this post by Nicolai Hess
2015-09-16 15:05 GMT+02:00 Nicolai Hess <[hidden email]>:
But
|
Argh, sent too early:
self new color: Color red; yourself est bien une cascade, non? Thierry 2015-09-16 15:12 GMT+02:00 Thierry Goubier <[hidden email]>:
|
In reply to this post by Nicolai Hess
The PackageAnalyzer is now maintained by me (especially because it is so usefull for the bootstrap).
I just fixed that. Indeed, the code was wrong. Christophe Le 16 sept. 2015 à 15:05, Nicolai Hess a écrit :
smime.p7s (5K) Download Attachment |
In reply to this post by Nicolai Hess
On Wed, Sep 16, 2015 at 4:56 PM, Nicolai Hess <[hidden email]> wrote:
> 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 ? What is the result in other dialects? This is a potential incompatibility for little gain. Anyway I would guess Opal is wrong. cheers -ben |
On 9/16/2015 10:34 AM, Ben Coman wrote:
> On Wed, Sep 16, 2015 at 4:56 PM, Nicolai Hess <[hidden email]> wrote: >> 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 ? > > What is the result in other dialects? Dolphin lets you do "self ; yourself" as well as the example above. However, both VW & VA don't allow it. > This is a potential incompatibility for little gain. > Anyway I would guess Opal is wrong. I don't remember if we allowed this on purpose to be compatible with other Smalltalks or if it was a bug we missed. Anyway, a simple fix is to add " and: [node parentheses isEmpty]" to the RBParser>>parseCascadeMessage method: parseCascadeMessage | node receiver messages semicolons | node := self parseKeywordMessage. (currentToken isSpecial and: [currentToken value = $; and: [node isMessage and: [node parentheses isEmpty]]]) ifFalse: [^node]. ... John Brant |
2015-09-17 1:18 GMT+02:00 John Brant <[hidden email]>: On 9/16/2015 10:34 AM, Ben Coman wrote: Thanks for the info.
|
In reply to this post by Thierry Goubier
2015-09-16 15:14 GMT+02:00 Thierry Goubier <[hidden email]>:
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".
|
2015-09-17 9:10 GMT+02:00 Nicolai Hess <[hidden email]>:
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. 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
|
> On 17 Sep 2015, at 09:32, Thierry Goubier <[hidden email]> wrote: > > > > 2015-09-17 9:10 GMT+02:00 Nicolai Hess <[hidden email]>: > > > 2015-09-16 15:14 GMT+02:00 Thierry Goubier <[hidden email]>: > 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 <[hidden email]>: > > > 2015-09-16 15:05 GMT+02:00 Nicolai Hess <[hidden email]>: > 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 <[hidden email]>: > 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 <[hidden email]>: > 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 |
Free forum by Nabble | Edit this page |