[squeak-dev] Q: Value of just the period, in method body resp. block body

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

[squeak-dev] Q: Value of just the period, in method body resp. block body

Klaus D. Witzel
Quick, what does this method return:

MyClass>>myMethod.

and what does this method's block return:

MyClass>>myBlock

  ^[.]value

I'm writing compiler tests for CorruptVM/Moebius (tests that can then also  
be used with Squeak's compiler and NewCompiler) and want to include these  
two cases as well.

TIA.

/Klaus

--
"If at first, the idea is not absurd, then there is no hope for it".  
Albert Einstein


Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Q: Value of just the period, in method body resp. block body

jgfoster

On Nov 27, 2008, at 4:55 AM, Klaus D. Witzel wrote:

> Quick, what does this method return:
>
> MyClass>>myMethod.
In Squeak, this returns the receiver, an instance of MyClass.
>
>
> and what does this method's block return:
>
> MyClass>>myBlock
>
> ^[.]value
In Squeak, this returns nil.

>
>
> I'm writing compiler tests for CorruptVM/Moebius (tests that can  
> then also be used with Squeak's compiler and NewCompiler) and want  
> to include these two cases as well.
>
> TIA.
>
> /Klaus
>
> --
> "If at first, the idea is not absurd, then there is no hope for it".  
> Albert Einstein
>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Q: Value of just the period, in method body resp. block body

Igor Stasenko
In reply to this post by Klaus D. Witzel
2008/11/27 Klaus D. Witzel <[hidden email]>:

> Quick, what does this method return:
>
> MyClass>>myMethod.
>
> and what does this method's block return:
>
> MyClass>>myBlock
>
>  ^[.]value
>
> I'm writing compiler tests for CorruptVM/Moebius (tests that can then also
> be used with Squeak's compiler and NewCompiler) and want to include these
> two cases as well.
>

mmm.. i think this test case is not qualifying anything.
i'd rather test following:

^ [42] value
vs
^ [42 . ] value

A period is designating an end of expression , right?
For me its more interesting, why in ["empty"] blocks returns nil, but
[ 42. "empty" ] block returns 42.

> TIA.
>
> /Klaus
>
> --
> "If at first, the idea is not absurd, then there is no hope for it". Albert
> Einstein
>



--
Best regards,
Igor Stasenko AKA sig.

Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Q: Value of just the period, in method body resp. block body

Bert Freudenberg

On 27.11.2008, at 15:40, Igor Stasenko wrote:

> 2008/11/27 Klaus D. Witzel <[hidden email]>:
>> Quick, what does this method return:
>>
>> MyClass>>myMethod.
>>
>> and what does this method's block return:
>>
>> MyClass>>myBlock
>>
>> ^[.]value
>>
>> I'm writing compiler tests for CorruptVM/Moebius (tests that can  
>> then also
>> be used with Squeak's compiler and NewCompiler) and want to include  
>> these
>> two cases as well.
>>
>
> mmm.. i think this test case is not qualifying anything.
> i'd rather test following:
>
> ^ [42] value
> vs
> ^ [42 . ] value
>
> A period is designating an end of expression , right?
> For me its more interesting, why in ["empty"] blocks returns nil, but
> [ 42. "empty" ] block returns 42.


Because the . after the final statement in a block or method is  
optional.

- Bert -


Reply | Threaded
Open this post in threaded view
|

[squeak-dev] Re: Q: Value of just the period, in method body resp. block body

Klaus D. Witzel
On Thu, 27 Nov 2008 15:48:33 +0100, Bert Freudenberg wrote:

>
> On 27.11.2008, at 15:40, Igor Stasenko wrote:
>
>> 2008/11/27 Klaus D. Witzel :
>>> Quick, what does this method return:
>>>
>>> MyClass>>myMethod.
>>>
>>> and what does this method's block return:
>>>
>>> MyClass>>myBlock
>>>
>>> ^[.]value
>>>
>>> I'm writing compiler tests for CorruptVM/Moebius (tests that can then  
>>> also
>>> be used with Squeak's compiler and NewCompiler) and want to include  
>>> these
>>> two cases as well.
>>>
>>
>> mmm.. i think this test case is not qualifying anything.
>> i'd rather test following:
>>
>> ^ [42] value
>> vs
>> ^ [42 . ] value
>>
>> A period is designating an end of expression , right?
>> For me its more interesting, why in ["empty"] blocks returns nil, but
>> [ 42. "empty" ] block returns 42.
>
> Because the . after the final statement in a block or method is optional.

Thank you Bert, James and Igor :) Now it's clear what the test has to be  
about.

> - Bert -
>
>


Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Q: Value of just the period, in method body resp. block body

Igor Stasenko
In reply to this post by Bert Freudenberg
2008/11/27 Bert Freudenberg <[hidden email]>:

>
> On 27.11.2008, at 15:40, Igor Stasenko wrote:
>
>> 2008/11/27 Klaus D. Witzel <[hidden email]>:
>>>
>>> Quick, what does this method return:
>>>
>>> MyClass>>myMethod.
>>>
>>> and what does this method's block return:
>>>
>>> MyClass>>myBlock
>>>
>>> ^[.]value
>>>
>>> I'm writing compiler tests for CorruptVM/Moebius (tests that can then
>>> also
>>> be used with Squeak's compiler and NewCompiler) and want to include these
>>> two cases as well.
>>>
>>
>> mmm.. i think this test case is not qualifying anything.
>> i'd rather test following:
>>
>> ^ [42] value
>> vs
>> ^ [42 . ] value
>>
>> A period is designating an end of expression , right?
>> For me its more interesting, why in ["empty"] blocks returns nil, but
>> [ 42. "empty" ] block returns 42.
>
>
> Because the . after the final statement in a block or method is optional.
>

in squeak, they not just simply optional, you can, as TRUE writer
leave an ellipsises
[42 ...] value
to let readers feel the taste of your novel style  :)

> - Bert -
>


--
Best regards,
Igor Stasenko AKA sig.