View Single Post
Old 25 August 2015, 20:33   #335
Registered User

Megol's Avatar
Join Date: May 2014
Location: inside the emulator
Posts: 254
Originally Posted by Mrs Beanbag View Post
the advantage is that you can always tell there is a block there, basically "do...end" is equivalent to "{...}" but with friendlier symbols. Another idea that just occurred to me, is to use a colon for the long form and a comma for the short form. This is a bit like how we'd use punctuation in English:

if n=0, return 1
-- or
if n=0:
   return 1
Python uses a colon to start a block and IMHO that is a problem. I want the language to be readable in a plain editor on a high resolution screen without color coding and then a colon combined with other characters can be hard to see. Making a control statement the start of a block also reduces typing.

unusual if syntax, btw.. it appears to actually reverse the order in which the terms would be executed
I guess you mean the selection syntax? Guarded statements aren't that unusual and should be easy to understand - they do exactly what they spell out.

print "Hello world!" if user.state=available

if(user.state==available) print("Hello world!"); // C languages
The selection syntax is actually an accident and preliminary but I'm actually starting to like it. It is also easy to read and can reuse some parts of the guarded statement parser. IIRC the syntax used in Python too.

name:="BASIC" if user.level=beginner else "C++" 

name=(user.level==beginner)? "BASIC" : "C++"; // C languages
IMO it should be easier to read even for beginners. YMMV.
Megol is offline  
Page generated in 0.06703 seconds with 9 queries