[Pharo-project] [squeak-dev] Compiler pedantic about ifNotNil: argument
siguctua at gmail.com
Sun Oct 10 18:57:13 EDT 2010
On 10 October 2010 23:25, Stéphane Ducasse <stephane.ducasse at inria.fr> wrote:
> On Oct 10, 2010, at 3:07 PM, Igor Stasenko wrote:
>> On 10 October 2010 15:39, Nicolas Cellier
>> <nicolas.cellier.aka.nice at gmail.com> wrote:
>>> The compiler uselessly insist on #ifNotNil: argument being a zero/one arg block.
>>> Thus we cannot write this xtream sentence
>>> process ifNotNil: #terminate.
>>> When the argument is not a block, Compiler should avoid inlining and
>>> just send a normal message.
>> i am also missing:
>> someThing ifTrue: 1 ifFalse: 0
> I hate this idea.
> Let the compiler doing optimizations and please do not mix implementation and language design.
> The ***semantics*** of iftrue: is to get a thunk (in scheme parlance) something whose evaluation is blocked.
> 1 is not that!
hmm.. what is wrong with sending real #ifTrue:ifFalse: message to boolean,
if compiler can't inline it?
or you think a following is a good way to write a code:
blockA := [self foo ].
blockB := [ self bar ].
self zork ifTrue: [ blockA value] ifFalse: [ blockB value ]
where you can just write:
self zork ifTrue: blockA ifFalse: blockB
In any way, passing anything else than block literal as argument should work.
This is smalltalk, not C with static types.
> Now the compiler could be smart and inline whatever.
> Pharo-project mailing list
> Pharo-project at lists.gforge.inria.fr
Igor Stasenko AKA sig.
More information about the Pharo-dev