ELDERScript

Simulated dice for role playing games
Post Reply
gandreas
Immortal
Posts: 1464
Joined: Wed Feb 04, 2004 6:02 pm
Contact:

ELDERScript

Post by gandreas » Sat Nov 27, 2010 12:11 pm

After far too long referring to it as "The Dicenomicon Dice Expression Language" (or some variant of that), I've finally come up with a real name for the dice rolling expressions that you enter into The Dicenomicon:

"ELDERScript". I can't tell you what all the letters stand for (because that would cause certain "things" to happen, and getting blood and ichor stains out of carpeting is just too much work), but it does includes the words "Expression" (or maybe "Evaluation" or "Evoking"), "Language", "Dicenomicon" and either "Roll" or "Role-playing".

And more importantly, I've been working on enhancements for the next major (or maybe minor) version (there may well be a bug fix release before then - problems with tables not refreshing are quite annoying). The goal, of course, is to make sure that ELDERScript 2.0 doesn't break anything in ELDERScript 1.0. Besides a whole lot of internal rework (hopefully speeding things up as well), ELDERScript 2.0 will introduce mutable objects called "frames".

Currently, all values are immutable "atomic" values. So you can't replace an item in a list, you make a new list with that item replaced (this is why "@X[5] <- 3" doesn't actually change @X, but makes a new list with the fifth item replaced by 3, requiring you to write things like "@X <- (@X[5] <- 3)"). Frames are different - they are more like, say, dictionaries in Python, or their namesake, frames in NewtonScript (trust me on that one). They are "objects" with named slots, sort of like the way that strings can be records:

Code: Select all

@X <- "a=First Letter|b=Second Letter".
@X["a"]

Code: Select all

@X <- {a:"First Letter" | b:"Second Letter"}.
@X:a
Will both produce "First Letter". However:

Code: Select all

@X <- "a=First Letter|b=Second Letter".
@Y <- @X.
@X <- (@X["a"] <- "Alpha").
@X["a"], @Y["a"]
will produce "Alpha", "First Letter" (since @Y still has the original value), while:

Code: Select all

@X <- {a:"First Letter" | b:"Second Letter"}.
@Y <- @X.
@X:a <- "Alpha".
@X["a"], @Y["a"]
will produce "Alpha", "Alpha" (since @Y and @X refer to the same mutable frame).

Frames can also mimic lists:

Code: Select all

@X <- {("a","b","c")}.
@X[2]
will produce "b". This is equivalent to:

Code: Select all

@X <- {0:"a" | 1:"b" | 2:"c"}.
@X[2]
However frames are also nestable, and aren't "flattened" when combined with lists:

Code: Select all

@X <- {("a","b","c")}.
@Y <- {("d","e","f")}.
@Z <- {(@X,@Y)}.
@A <- (@X,@Y)
results in @Z being a frame with two numeric indices, while @A is a list with two frames. In neither case is there anything like ("a","b","c","d","e","f").

There's a bunch of subtle ramifications that need to be worked out (like what does "frame + frame" do? "frame + list"? "frame + value"? etc...), but that's a little hint of what's in the works...

gandreas
Immortal
Posts: 1464
Joined: Wed Feb 04, 2004 6:02 pm
Contact:

Re: ELDERScript

Post by gandreas » Wed Feb 09, 2011 10:14 am

I hoped that I wouldn't need to do this, but I'm probably going to have to make a few minor, but backward incompatible changes to ELDERScript to clean up a few problems that people keep running into (even me!).

The first problem is passing arrays to functions - currently, the following two things are identical:

Code: Select all

@FOO(1,2,3,4,5)

Code: Select all

@X ← (2,3,4).
@FOO(1,@X,5)
This makes it very difficult to write a function that takes a list as a parameter. So if you want to write a function that takes a list and coverts all values less than some value to add that value to them, writing a function:

Code: Select all

for @I in #1 do
if @I < #2 then
  @I + #2
else
  @I
end
end
won't work if you do:

Code: Select all

@X ← (2,3,4).
@FOO(@X,3)
(since #1 in the above function is (2,3,4,3) and #2 is not defined)

Instead you'd need to escape the list, and unescape it, which is error prone, and flat out ugly.

Note that with this change, you'll still be able to do:

Code: Select all

@X ← (2,3,4).
@FOO((1,@X,5))
and get the equivalent of:

Code: Select all

@FOO(1,2,3,4,5)

Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests