4 ms·
I had to write a scripting language for a personal project. Since I could create whatever syntax I wanted, I used this: 'if x==4' was written as 'x[4]' 'if x>
by lurquer 8y ago
I had to write a scripting language for a personal project. Since I could create whatever syntax I wanted, I used this:
'if x==4' was written as 'x[4]'
'if x>2 && x<4' was written as 'x(2,4)'
'if x>=2 && x<4' was written as 'x[2,4)'
Etc.
It was very easy to read and write... at least for me.
- gbear605 8y agoWhat if you wanted ‘if x>2 || x < -2’?
- thaumasiotes 8y agoThat's not exactly a challenge for the syntax... if-not x[-2,2] Just like you'd write x ∉ [-2,2] with pen and paper.
- function_seven 8y agoNot parent, but I would write x)-2,2( or x![-2,2]
- userbinator 8y agoI suppose the language has neither array subscripting nor function calls? Or did you decide to invent other creative syntax for those?
- lurquer 8y agoIt was a cell growth simulation. Morphogenesis. The goal was to start with a single cell and see if I could make it divide and grow into something neat. The constraint was that all the cells were identical, and 'knew' only a limited amount of things about their environment: how many neighbors were touching them, and the levels of an arbitrary number of 'chemicals' that would diffuse from one cell to the other. I made the scripting language as an easier way to program the 'rules' in the cell class. Dozens of little rules such as "if chemcial_0 is between 0.879 and .936 the increase chemical_1 by a smidgen," or "if chemical_23 equals 1.738 then undergo mitosis." The little shorthand syntax was far easier to read than the mess of conditionals in C++. It was pretty neat. Used Box2d for the physics part. Got up to making a worm kinda thing with legs. But then gave up. Trying to make identical cells differentiate into asymmetrical patterns is something that always intrigued me. Got interested after reading this: http://www.mvla.net/view/19352.pdf http://www.mvla.net/view/19352.pdf How's that for a long-winded answer...