[Newbies] Re: error trap

2006-08-14 Thread Klaus D. Witzel

On Sun, 13 Aug 2006 18:31:23 +0200, Damien Cassou wrote:

Yes. And, into the other direction, even in good core methods one often  
finds things like

  ^ dict at: aKey ifAbsent: [nil]
 There seems to be a natural confusion between object value and  
block value.


What's the problem with that ?


The lack of understanding the expressive power of the software developer  
is the problem. Why always use a hammer? Because everything looks like  
nails?


Yes, 'nil value' answers nil but 'nil' is not a block and #at:ifAbsent:  
waits for a block (the parameter is called aBlock).


No, #at:ifAbsent: doesn't wait for an instance of BlockContext. Smalltalk  
is typeless and, if at all, only has *one* (the universal) type.



It is shorter to write 'nil' directly I agree.


And the compiler is not forced to emit code for a BlockContext and the VM  
is not forced to create a BlockContext only for throwing it away unused  
(unused in the sense that nil == [nil] value). It is like writing (x)  
versus (0+x) or (1*x).



What is more problematic in my point of view is code like this:

AbstractLauncherparameterAt: parName ifAbsent: aBlock
   Return the parameter named parName.
 Evaluate the block if parameter does not exist.
   ^self parameters
 at: parName asUppercase
 ifAbsent: [aBlock value]

It may be me (still a beginner), but it looks equivalent to

   ^self parameters
 at: parName asUppercase
 ifAbsent: aBlock


Yes, anObject == [anObject] value.


which is faster and clearer in my opinion.


Sure.

/Klaus

___
Beginners mailing list
Beginners@lists.squeakfoundation.org
http://lists.squeakfoundation.org/mailman/listinfo/beginners


[Newbies] Re: error trap

2006-08-14 Thread Klaus D. Witzel
On Mon, 14 Aug 2006 10:17:40 +0200, Damien Cassou  
[EMAIL PROTECTED] wrote:

Klaus D. Witzel wrote:

For an example try a printIt on
  ^ true ifTrue: #a ifFalse: [false ifTrue: #b ifFalse: #c]
 Again, a natural confusion between an object's value and a block's  
value.



  - argument of ifTrue: must be a block or variable -



In VW, there is no Objectvalue method. But #value is implemented in  
Boolean and UndefinedObject. Is this Smalltalk-standard to have #value  
on Object ?


Just scanned SmalltalkV2.sources and SqueakV1.sources: #value is not  
implemented by Object nor by UndefinedObject.


/Klaus

___
Beginners mailing list
Beginners@lists.squeakfoundation.org
http://lists.squeakfoundation.org/mailman/listinfo/beginners


[Newbies] Re: error trap

2006-08-11 Thread Klaus D. Witzel

On Fri, 11 Aug 2006 23:00:03 +0200, stéphane ducasse wrote:
Klaus wrote:

Yes. And, into the other direction, even in good core methods one often
finds things like

  ^ dict at: aKey ifAbsent: [nil]


this is much better.


Why do you call failures in understanding things like this better, Stef?  
Whoever writes such statements, has no idea about an object's value versus  
a block's value and especially no idea about when and why execution of a  
block of code can and should be delayed (not to speak about performance  
impact).



I would like to see caseOf:...removed from the system


And replace it by what? Why would you limit the expressive power of the  
software developer, Stef?


/Klaus


stef



___
Beginners mailing list
Beginners@lists.squeakfoundation.org
http://lists.squeakfoundation.org/mailman/listinfo/beginners


[Newbies] Re: error trap

2006-08-10 Thread Klaus D. Witzel

On Thu, 10 Aug 2006 17:27:09 +0200, Roel Wuyts wrote:

Note: no need for the endEntry when using show: it does it already (see  
TranscriptStream#show: )


Use a 'manual' endEntry when you would use nextPutAll: or print: etc. on  
the Transcript (which most people do not use anyway).


Right you are! But I'm writing on recycled web pages, those with  
notoriously small margin, therefore I tend to believe that people point to  
the methods mentioned (like #endEndtry) and curiously look for  
implementors and other good things in the same message category, the  
famous cmd-m followed by a cmd-b and/or cmd-m :p


/Klaus

___
Beginners mailing list
Beginners@lists.squeakfoundation.org
http://lists.squeakfoundation.org/mailman/listinfo/beginners


[Newbies] Re: error trap

2006-08-10 Thread Klaus D. Witzel

Hi Ron,

on Thu, 10 Aug 2006 17:02:11 +0200, you wrote:

From: Klaus D. Witzel
... You didn't inspectIt for verifying


No I didn't!  The { } just looked so wrong and like C!


Yes, same for me when I saw that for the first time in Squeak. Never saw  
that in Smalltalk/2.x (didn't look for it in VW).


But nowaday's I wonder how we have done it for so many decades without  
handsome {expression. 'constant'. [block]} select: [:everything |  
everything isAnObject].


/Klaus

___
Beginners mailing list
Beginners@lists.squeakfoundation.org
http://lists.squeakfoundation.org/mailman/listinfo/beginners


[Newbies] Re: error trap

2006-08-09 Thread Klaus D. Witzel

On Wed, 09 Aug 2006 19:59:41 +0200, Brian Murphy-Dye wrote:

Ron, another crazy possibility comes to mind when reading your
excellent description: making each line it's own block.

{[10/0].
  [2 raisedToInteger: 1/2].
  [-5 raisedTo: 1.5]
} do: [:each | [each value] on: Exception do: [:ex | Transcript show:
ex; cr]].


Excellent, Brian. Why do you still write in the beginners list ;-)
...
Ah, now I can see why: Transcript endEntry is missing from the above :)  
/joke


/Klaus


Brian.


___
Beginners mailing list
Beginners@lists.squeakfoundation.org
http://lists.squeakfoundation.org/mailman/listinfo/beginners