Fun with symbol

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

Fun with symbol

Nicolas Cellier-3
About some discussion on Squeak-dev...
Ah, even mature VW is caught sometimes (at leat 7.3.1)

| str |
str := String new writeStream.
#'x:y:z' storeOn: str.
Kernel.Compiler evaluate: str contents readStream

Cheers



nicolas cellier a écrit :
 > That's what mature means I guess.
 >
 > The last is syntactically correct, and correctly parsed by Squeak.
 > However Squeak result is quite surprising, debug it to believe it.
 >
 > Nicolas
 >
 >
 >
 > PS: forgot this one:
 >     Compiler evaluate: '#$'.
 > Not to confuse:
 >     Compiler evaluate: '# $'.
 > And:
 >     Compiler evaluate: '#$ '.
 >
 > Boris Popov a écrit :
 >> If anyone cares, here's VisualWorks' treatment,
 >>
 >> Compiler evaluate: '#++'.
 >> #++
 >>
 >> Compiler evaluate: '##'.
 >> #word, binary, keyword, (, or [ expected ->#
 >>
 >> Compiler evaluate: '#'.
 >> #word, binary, keyword, (, or [ expected ->
 >>
 >> Compiler evaluate: '# "please" # "print" # "me"'.
 >> # "please" word, binary, keyword, (, or [ expected -># "print" # "me"
 >>
 >> Compiler evaluate: '##()'.
 >> #word, binary, keyword, (, or [ expected ->#()
 >>
 >> Compiler evaluate: '##)'.
 >> #word, binary, keyword, (, or [ expected ->#)
 >>
 >> Compiler evaluate: '##('.
 >> #word, binary, keyword, (, or [ expected ->#(
 >>
 >> Compiler evaluate: '##(##)'.
 >> #word, binary, keyword, (, or [ expected ->#(##)
 >>
 >> Compiler evaluate: '#1'.
 >> #word, binary, keyword, (, or [ expected ->1
 >>
 >> Compiler evaluate: '#-1'.
 >> #-Nothing more expected ->1
 >>
 >> Compiler evaluate: '#--1'.
 >> Unhandled exception: Message not understood: #-
 >>
 >> Cheers!
 >>
 >> -Boris
 >>
 >
 >
 >

Reply | Threaded
Open this post in threaded view
|

Re: Fun with symbol

Ladislav Lenart
nicolas cellier wrote:
> About some discussion on Squeak-dev...
> Ah, even mature VW is caught sometimes (at leat 7.3.1)
>
> | str |
> str := String new writeStream.
> #'x:y:z' storeOn: str.
> Kernel.Compiler evaluate: str contents readStream

Maybe I am missing the point here, but "Compiler class>>evaluate:"
expects aTextOrString and not aReadStream.

Ladislav Lenart


Reply | Threaded
Open this post in threaded view
|

Re: Fun with symbol

Nicolas Cellier-3
In reply to this post by Nicolas Cellier-3

From early ages up to at least 7.3.1 stream were accepted.
So the readStream is not necessary indeed. Maybe it were once, can't remember why i took such a habit...

The point is that #'x:y:z' is printed as #x:y:z which is further interpreted as the message send #x:y: z.
Type a method anywhere say
Object>>foo
    ^#'x:y:z'
If decompiled code is used and recompiled (via a fileOut/fileIn operation for example)
Then the code is not preserved.

This is a bug. A hardly ever seen and rather theoretical one, but a bug.

Nicolas

De : [hidden email]
Date : 23/05/07 09:31:41
A : [hidden email]
Cc : [hidden email]

Sujet : Re: Fun with symbol
nicolas cellier wrote:
> About some discussion on Squeak-dev...
> Ah, even mature VW is caught sometimes (at leat 7.3.1)
>
> | str |
> str := String new writeStream.
> #'x:y:z' storeOn: str.
> Kernel.Compiler evaluate: str contents readStream

Maybe I am missing the point here, but "Compiler class>>evaluate:"
expects aTextOrString and not aReadStream.

Ladislav Lenart


Reply | Threaded
Open this post in threaded view
|

Re: Fun with symbol

Dave Stevenson-2
In reply to this post by Nicolas Cellier-3
Works fine in current builds.

nicolas cellier wrote:

> About some discussion on Squeak-dev...
> Ah, even mature VW is caught sometimes (at leat 7.3.1)
>
> | str |
> str := String new writeStream.
> #'x:y:z' storeOn: str.
> Kernel.Compiler evaluate: str contents readStream
>
> Cheers
>
>
>
> nicolas cellier a écrit :
>  > That's what mature means I guess.
>  >
>  > The last is syntactically correct, and correctly parsed by Squeak.
>  > However Squeak result is quite surprising, debug it to believe it.
>  >
>  > Nicolas
>  >
>  >
>  >
>  > PS: forgot this one:
>  >     Compiler evaluate: '#$'.
>  > Not to confuse:
>  >     Compiler evaluate: '# $'.
>  > And:
>  >     Compiler evaluate: '#$ '.
>  >
>  > Boris Popov a écrit :
>  >> If anyone cares, here's VisualWorks' treatment,
>  >>
>  >> Compiler evaluate: '#++'.
>  >> #++
>  >>
>  >> Compiler evaluate: '##'.
>  >> #word, binary, keyword, (, or [ expected ->#
>  >>
>  >> Compiler evaluate: '#'.
>  >> #word, binary, keyword, (, or [ expected ->
>  >>
>  >> Compiler evaluate: '# "please" # "print" # "me"'.
>  >> # "please" word, binary, keyword, (, or [ expected -># "print" # "me"
>  >>
>  >> Compiler evaluate: '##()'.
>  >> #word, binary, keyword, (, or [ expected ->#()
>  >>
>  >> Compiler evaluate: '##)'.
>  >> #word, binary, keyword, (, or [ expected ->#)
>  >>
>  >> Compiler evaluate: '##('.
>  >> #word, binary, keyword, (, or [ expected ->#(
>  >>
>  >> Compiler evaluate: '##(##)'.
>  >> #word, binary, keyword, (, or [ expected ->#(##)
>  >>
>  >> Compiler evaluate: '#1'.
>  >> #word, binary, keyword, (, or [ expected ->1
>  >>
>  >> Compiler evaluate: '#-1'.
>  >> #-Nothing more expected ->1
>  >>
>  >> Compiler evaluate: '#--1'.
>  >> Unhandled exception: Message not understood: #-
>  >>
>  >> Cheers!
>  >>
>  >> -Boris
>  >>
>  >
>  >
>  >
>
>