1. Dot notation

If we adopt a syntax like this it might be a good idea to always have the parenthesis. In this case, for C plus plus programmers, dot notation is nice. I find it convincing that one should always use parenthesis whether we use dot notation or what I will call function= notation.

-- s = {1,2} 
s append=(3) 
-- s = {1,2,3} 

Dot notation is like C plus plus and looks more like pass by reference.

s.append(3) 

Forked from Re: Append

_tom said...
SDPringle said...

I have been thinking of adding a syntax extension that would work not only for builtins but also user created routines.

My first reaction was great! SDPringle can invent, and implement, new ideas.

Delayed reaction is: my head might explode. Euphoria does not take kindly to shortcuts and new syntax.

To show that you are working with a subroutine you need an argument list, possibly empty, shown by ( ) parenthesis.

s = append(s, pair ) 
s append= (pair) 
 
s = store(s, key, data ) 
s store=(key,data) 

Allowing () to "vanish" is a nice shortcut that adds another rule, an exception, that must be learned. Extra congnitive effort means not simple. The result is that

--either 
s append= pair     -- breaks a pattern, so it is a problem 
 
-- or 
s store=(key,data) -- adds a pattern, so it is a problem 

Will I get confused between a binary operator and a two argument function?

-- two argument function 
 
x = append(x,3) 
x append=(3) 
 
 
-- binary operator ... two arguments 
 
x = x + 2 
x += 2 
 
-- another kind of two argument function 
 
function add( atom a, atom b ) 
	return a+b 
	end function 
	 
x = add(2,3) 
x add=(2,3) 
	-- the previous pattern suggests that somehow "add" must be a three argument function 
	-- with the first argument being "x" 
	-- but, that is not what I have in add(2,3) 

My point is that I, thats one viewpoint, will make various typing errors in working with this syntax.

Then again, if you had dot notation, then the transition to your shortcut notation might be easy to visualize.

s = append(s, pair ) 
s = s.append( pair ) 
s append=(pair) 
 
s = store(s, key, data ) 
s = s.store( key, data ) 
s store=(key,data) 

In dot notation the "self" argument moves to a new location but does not vanish. In the shortcut notation the "self" argument vanishes. If something vanishes, then it is not Euphoric syntax.

_tom

new topic     » topic index » view message » categorize

2. Re: Dot notation

I think dot notation would be a nice touch to Euphoria. It will be great for when Euphoria has struct support added.

new topic     » goto parent     » topic index » view message » categorize

3. Re: Dot notation

Icy_Viking said...

I think dot notation would be a nice touch to Euphoria. It will be great for when Euphoria has struct support added.

I believe something like this will be introduced into Euphoria. It will be much more obvious and useful when object-oriented features start to become available.

new topic     » goto parent     » topic index » view message » categorize

4. Re: Dot notation

Speaking of nice touches, I've mentioned in this thread about Ham-script, the readme of which describes some of the notational approaches they are using and considering. Perhaps we can pick up some ideas there.

Bugmagnet

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu