Constants, Macros, Variables and Stacks
Posted: Mon Jul 21, 2008 8:36 am
From my perusal of the wikipedia descriptions, I'm very confused about the whole grammar, language, and context thing. I'm pretty certain that at least the first two are suggestions are context-free, but I'm not sure about the second three.
#1: Numerical constants! Globally defined numerical constants would simplify and make more readable a lot of designs -- for example when you have a tree that uses 35 degrees in 10 places (and then when you want to try 25 instead).
#2: String Macros... Actually this could be the same thing as #1. But instead of the constant having to be a self-contained expression, you could have something like, so that you could just stick "shrink" inside other existing attribute strings, like to concatenate the contents.
#3: Variables! Global variables that could be used in expressions for attribute strings would be extremely powerful. For example, they would provide a number of solutions for what seems to be a very common concern, which is recursion-depth-sensitive behavior. If global variables violates "context-free"-ness, what about local variables within a rule? Not as powerful, but you could do a lot with a variable within a loop.
#4: IF statements! IF statements would let you make full use of variables, especially for recusion-depth-sensitive behavior, but even without them, one could probably simulate them by use of the variables within attribute expressions.
#5 A Stack! A stack, or equivalently(?), variables that can be passed to rules as parameters, would allow a more elegant and more powerful recursion-depth-sensitive behavior, and other cool things!.
ETA: #6: This is very minor, as it doesn't affect the actual capabilities, but it would seem cleaner if there were a default startshape rule name, like "start", so that instead of you could just do , or even better if the things that weren't rules, paths, etc, were just interpreted, so it could be just or
#1: Numerical constants! Globally defined numerical constants would simplify and make more readable a lot of designs -- for example when you have a tree that uses 35 degrees in 10 places (and then when you want to try 25 instead).
#2: String Macros... Actually this could be the same thing as #1. But instead of the constant having to be a self-contained expression, you could have something like
Code: Select all
const shrink size 0.9999 hue 20 a -10
Code: Select all
myshape {rotate -10 shrink}
#3: Variables! Global variables that could be used in expressions for attribute strings would be extremely powerful. For example, they would provide a number of solutions for what seems to be a very common concern, which is recursion-depth-sensitive behavior. If global variables violates "context-free"-ness, what about local variables within a rule? Not as powerful, but you could do a lot with a variable within a loop.
#4: IF statements! IF statements would let you make full use of variables, especially for recusion-depth-sensitive behavior, but even without them, one could probably simulate them by use of the variables within attribute expressions.
#5 A Stack! A stack, or equivalently(?), variables that can be passed to rules as parameters, would allow a more elegant and more powerful recursion-depth-sensitive behavior, and other cool things!.
ETA: #6: This is very minor, as it doesn't affect the actual capabilities, but it would seem cleaner if there were a default startshape rule name, like "start", so that instead of
Code: Select all
startshape start
rule start {CIRCLE{}}
Code: Select all
rule start {CIRCLE{}}
Code: Select all
CIRCLE{}
Code: Select all
myrule1{}
myrule2{}
rule myrule1{...
rule myrule2{...