[squeak-dev] Shadowing "reserved" variables

JOHN SARKELA wiljo at mac.com
Wed Jul 17 12:35:54 UTC 2019


The ANSI Standard in section 3.4.2 Method Definition, states the following:

"It is erroneous if the same identifier is used for more than one <method argument> in an individual <method definition>. It is erroneous if any of the reserved identifiers ('nil', 'true', 'false', 'self', and 'super') is used as a <method argument>. It is erroneous if the same identifier is used as a <method argument> of a <method definition> and also appears in the method's <temporary variable list>. An identifier that is used as a <method argument> is called a method argument name." 

The sections which define the scopes for instances, classes, and pools also prohibit the used of the five reserved words.

By extension, we may infer that shadowing pseudo-variables such as thisContext should in all likelihood be disallowed as well.

John

> On Jul 17, 2019, at 6:51 AM, Levente Uzonyi <leves at caesar.elte.hu> wrote:
> 
> Hi All,
> 
> You can currently evaluate the following:
> 
> [ :self :thisContext |
> 	| nil super true false |
> 	nil := 1.
> 	super := 2.
> 	true := 3.
> 	false := 4.
> 	self + thisContext = (nil + super + true + false) ] value: 4 value: 6
> 
> Is this the expected behavior or should we disallow such oddities?
> 
> Levente
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20190717/dcac5f85/attachment.html>


More information about the Squeak-dev mailing list