how can I compile a String to BlockContext?

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

how can I compile a String to BlockContext?

albertlee
aka  eval, in python:

>>> eval('3 + 5')
8


I guess there is some method can do this in smalltalk.
like this:

| s b|
s := '[:x | x + 5]'
b := SOME_WAY s
" b is a block now"
b value: 3
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: how can I compile a String to BlockContext?

Enrico Schwass-2
Hello

Not sure if it perfectly fits your needs, but check here

http://wiki.squeak.org/squeak/3602

bye
Enno


Am 27.02.2009 um 08:12 schrieb Albert Lee:

> aka  eval, in python:
>
>>>> eval('3 + 5')
> 8
>
>
> I guess there is some method can do this in smalltalk.
> like this:
>
> | s b|
> s := '[:x | x + 5]'
> b := SOME_WAY s
> " b is a block now"
> b value: 3
> _______________________________________________
> Beginners mailing list
> [hidden email]
> http://lists.squeakfoundation.org/mailman/listinfo/beginners

Enno Schwass
[hidden email]
http://web.mac.com/onkelenno/iWeb/Web-Site/Blog/Blog.html



_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: how can I compile a String to BlockContext?

albertlee
2009/2/27  <[hidden email]>:
> Hello
>
> Not sure if it perfectly fits your needs, but check here
>
> http://wiki.squeak.org/squeak/3602
>
> bye
> Enno
>

Yes, Thanks!

s := Compiler evaluate: '[:x :y | x + y]'.
s value: 3 value: 5
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: how can I compile a String to BlockContext?

Bert Freudenberg
In reply to this post by albertlee

On 27.02.2009, at 08:12, Albert Lee wrote:

> aka  eval, in python:
>
>>>> eval('3 + 5')
> 8


Compiler evaluate: '3 + 5'

- Bert -


_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: how can I compile a String to BlockContext?

hernanmd
In reply to this post by Enrico Schwass-2
Or http://www.squeaksource.com/evaluablestrings.html

2009/2/27  <[hidden email]>:

> Hello
>
> Not sure if it perfectly fits your needs, but check here
>
> http://wiki.squeak.org/squeak/3602
>
> bye
> Enno
>
>
> Am 27.02.2009 um 08:12 schrieb Albert Lee:
>
>> aka  eval, in python:
>>
>>>>> eval('3 + 5')
>>
>> 8
>>
>>
>> I guess there is some method can do this in smalltalk.
>> like this:
>>
>> | s b|
>> s := '[:x | x + 5]'
>> b := SOME_WAY s
>> " b is a block now"
>> b value: 3
>> _______________________________________________
>> Beginners mailing list
>> [hidden email]
>> http://lists.squeakfoundation.org/mailman/listinfo/beginners
>
> Enno Schwass
> [hidden email]
> http://web.mac.com/onkelenno/iWeb/Web-Site/Blog/Blog.html
>
>
>
> _______________________________________________
> Beginners mailing list
> [hidden email]
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
>
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners