OT returning things. was: Re: [squeak-dev] Authorize upArrow in binary symbols

Tobias Pape Das.Linux at gmx.de
Wed Feb 26 22:36:20 UTC 2014


Hi,


I flag this OT, since I just fool around in the following.


On 26.02.2014, at 23:19, tim Rowledge <tim at rowledge.org> wrote:

> 
> On 26-02-2014, at 2:02 PM, Tobias Pape <Das.Linux at gmx.de> wrote:
> 
>> 
>> On 26.02.2014, at 21:39, tim Rowledge <tim at rowledge.org> wrote:
>> 
>>> 
>>> I had a whole lot of stuff typed but really it boils down to something simple. We need at least one symbol within the common character set that we can use as a syntactic element not related to a typical character - a return token.
>> 
>> Don’t get me wrong, but how do you come to the conclusion “We need [paraphrased: a distinct] return token”?
>> I mean, all other languages do without it, no?
> 
> C/Pascal/others use the return token ‘return’ spelled out. Those languages have a large complex syntax with ugly precedence rules so complex they need wall posters to list them all. In that context using a whole word seems a relatively minor crime. Smalltalk is simple. I like simple.
> 

As do I.

> 
>> I don’t want to say, we want to be like others,
>> but apparently, we (Smalltalk family, w/ Self etc.) are lonesome single-charcter return token users, aren’t we?
>> (Not that this would be wrong) So again, why do we need it explicitly?
> 
> Because that is how Smalltalk is. If we tried to use ‘return’, how would that read?
> 
> foo: aNumber
> |temp|
> temp := 4 + aNumber.
> return temp
> - that looks both ugly and annoying to parse.
> 
> foo: aNumber
> |temp|
> temp := 4 + aNumber.
> temp return
> - a little less ugly to read, and it even looks like a message send but implementation would be fairly nasty. Something like 
> return
>   thisContext sender returnValue: self
> 
> Yuck. How about we don’t break something that works nicely?

Ok, I got your line of thought :)
I don’t want a 'return' statement either, and retain ^ or ↑ as return character.

but as it stands, you just proved that it is not necessary de facto ;)

ATTENTION: NO proposal ahead, just thinking:

First, for normal methods, we can do without any return statement, just by saying:
	The last expression of a method constitutes its return value.
Fromt the example:

foo: aNumber
  |temp|
  temp := 4 + aNumber.
  temp

Second, for other returns as in:

burp: aNumber
 aNumber > 3 ifTrue: [^3].
 ^ 2.

, it is always possible to transform such “multi-path” methods (cyclomatic complexity > 1)
into methods with just one return. Granted: a number of them will look uglier than before :)

Methods returning nothing would then have to state self explicitly:

knorz
  self doSometingKnorzy.
  self. "or self yourself, for increased hilarity" 

The only actual _explicit_ return necessary is hence the non-local one as in:

nerf
  [self killRandomProccess] on: PermissionError do: [^ 'too bad']

But you just gave a solution for that one with the #returnValue trick.
I think the link Jecel provided is a good read for such foolery :)

Best and good night
	-Tobias

PS: I really like to write 2^31 - 1 and have it be valid Smalltalk…



-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 1625 bytes
Desc: Message signed with OpenPGP using GPGMail
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20140226/08005ec8/signature.pgp


More information about the Squeak-dev mailing list