View Single Post
Old 25 August 2015, 12:04   #310
Mrs Beanbag
Glastonbridge Software
Mrs Beanbag's Avatar
Join Date: Jan 2012
Location: Edinburgh/Scotland
Posts: 2,202
Originally Posted by Megol View Post
Examples from my toy project:

if x=123
  ...          -- actually a valid statement :)

if x=123 then ... -- short version without block

for i=0..100 by 2

for i=0..100 by 2 do ... -- short version
I like how you use the same keyword for all the end statements. But i would swap round the syntax of the short and long versions, so that "do" is a universal block beginning. Then you can always see that there is a block even when confronted with an unfamiliar statement, which maybe also eases expansion of the language.

Originally Posted by Samurai_Crow View Post
The fact that tabs OR spaces but not both can be used with Python is a terrible annoyance, indeed.
Quite... but the width of a tab could be set to anything in the editor so it gets a bit awkward! I've pondered using some other character, maybe |, like so:

Start of a block:
|   inner statement
|   Start of a block
|   |   inner inner statements
|   inner statement
so you can trace down the lines and see where it lines up, which can actually be quite difficult with only whitespace indentation, if you have a very long function (more than a screen).

I still lean in favor of a graphical tree gadget though.
i was sceptical of this at first. i still am, in a way, but it's starting to make a sort of sense to me. the thing is, the "graphical tree" on the screen can only be a representation of a data structure in memory, which has to be serialisable, and if that serialisation is human readable, there's a text-based language right there. But it strikes me that that might actually be the best way to go about designing a language. It's tempting to start by thinking about what sort of syntax you'd prefer, and then work out how to compile it, but maybe that's backwards. Maybe we should start by writing the compiler--or rather, an abstract syntax tree--and then work backwards from that: think of the simplest way to serialise it, and then add syntactic sugar to taste.

Originally Posted by commodorejohn View Post
Also interesting:

Last edited by Mrs Beanbag; 25 August 2015 at 12:35.
Mrs Beanbag is offline  
Page generated in 0.05493 seconds with 9 queries