[squeak-dev] [BUG] Parser does not detect syntax error with double colon

Marcel Taeumel marcel.taeumel at hpi.de
Wed Mar 4 15:35:41 UTC 2020


Hi, there.

> Perhaps I'm getting too old, but I see no reason to use these methods 
when you know the receiver is a stream.

That's right. :-) Both #any: and #take: are generic forms of #anyOne and #first: and similar for collections that are not necessarily sequenceable. The partial adaptation of the collection protocol for streams is still experimental. It is useful in scripting scenarios.

"stream take: 42" does not make any sense.
"streamOrCollection take: 42" can be quite useful. :-)

Best,
Marcel
Am 04.03.2020 14:04:27 schrieb Levente Uzonyi <leves at caesar.elte.hu>:
Hi All,

Answers inline. Rant alert!

On Wed, 4 Mar 2020, Thiede, Christoph wrote:

>
> Hi all,
>
>
> I took a look into the parser/scanner, let me ask you a few questions:
>
>
> Is it an important requirement that the compiler must be able to understand symbols such as #value::? Should these by valid symbols at all?

What are the consequences if you consider them not valid? What will break?
Why shouldn't they be valid? The most common "method names" are
#: #:: #::: #::::, etc (as in [ :x | ... ], [ :x :y | ... ], etc)

>
> If not, we could change the following line in Scanner >> #xLetter:
>
> tokenType := (type == #xColon and: [aheadChar ~~ $=] and: [aheadChar ~= $:])
>
> Otherwise, we could insert a validation of selector in #messagePart:repeat:. Something like:
>
>
> selector readStream in: [:stream |

What's wrong with temporaries?
I see #in: spreading like plague in methods. IMHO #in: is fine in scripts,
but I see no reason to use it as a replacement of temporaries in methods.

>   words do: [:word |
>   (stream take: word size - 1)

I had to look up what Stream >> #take: does. It's ^self any:
maxNumberOfElements. So, I had do look up what Stream >> #any: does.
Surprise, it's ^self next: numberOfElements.
Perhaps I'm getting too old, but I see no reason to use these methods
when you know the receiver is a stream.

Unfortunately neither methods have comments (#any: #take:), so one could
easily come to the conclusion that they are not very useful despite having
such generic names.

>   indexOf: $:
>   ifPresent: [:index | self notify: 'Argument expected' at: word start + index].

My image doesn't have #indexOf:ifPresent:.


Levente

>   stream skip: 1]].
>
>
> Looking forward to your thoughts!
>
>
> Best,
>
> Christoph
>
>
> _________________________________________________________________________________________________________________________________________________________________________________________________________________________________
> Von: Squeak-dev im Auftrag von Taeumel, Marcel
> Gesendet: Freitag, 28. Februar 2020 14:17:20
> An: John Pfersich via Squeak-dev
> Betreff: Re: [squeak-dev] [BUG] Parser does not detect syntax error with double colon  
> Hi Christoph.
> Thanks for pointing this out. This issue has been around for like forever. :-) In Squeak 3.8, however, the list of choices was bigger:
>
> [IMAGE]
>
> Let's improve this in 6.0alpha :-)
>
> Best,
> Marcel
>
> Am 28.02.2020 13:49:03 schrieb Thiede, Christoph :
>
> Steps to reproduce:
>
> Try doIt this (for example, in a workspace):
>
> 2 raisedTo:: 3.
>
>
> Expected behavior:
>
> 2 raisedTo:"Argument expected ->": 3.
>
>
> Actual behavior:
>
> [IMAGE]
>
> If you are thumb enough to choose #raisedTo:: (I was), you get a subsequent error:
>
> [IMAGE]
>
> Even worse: If you try to doIt the same code snippet again, no parser warning/error will be raised at all but you get a runtime error:
>
> MessageNotUnderstood: SmallInteger>>raisedTo::.
>
>
> Best,
>
> Christoph
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20200304/e2af9111/attachment.html>


More information about the Squeak-dev mailing list