(Integer readFrom: 'abc' readStream) = 0

Zulq Alam me at zulq.net
Wed Jan 9 11:44:03 UTC 2008


Thanks Nicolas.

I hate to think how many times I've used #readFrom: without knowing this!

nicolas cellier wrote:
> Zulq Alam a écrit :
>> What's the reasoning behind this?
>>
> None.
> 
> Historically, readFrom: was mainly used from Parser (or Scanner) to read 
> literal Number and only triggered by the presence of a digit character, 
>  in this context, reading from 'abc' would never have happened.
> 
> Syntax error would have been handled by Smalltalk Compiler too (Parser), 
> so no care was ever taken at readFrom: level.
> 
> 
> That's all what is behind.
> Our expectations and usage of readFrom: has evolved.
> 
> However, I always preferred the power of Compiler evaluate: to its very 
> restricted avatar Number readFrom:
> 
> example of non smart readFrom:
>     Number readFrom: '1+1'.
>     Number readFrom: 'Float pi / 5 sin * 30'.
> 
> Of course, you gotta trust your users then, not very secure...
> 
> Nicolas
> 
> 
> 



More information about the Squeak-dev mailing list