Improving on commands/timelines

299 views
Skip to first unread message

iarwain

unread,
Sep 25, 2014, 5:05:13 PM9/25/14
to orx...@googlegroups.com
Hi all,

I've been using commands and timelines extensively in my last project and they turned to be invaluable for providing hooks between code and UI/gameplay.

However they can become pretty cumbersome, especially if one isn't used to stack-based evaluations.

I'd like to propose here a few improvements, lemme know what you think:

- Ability to pack a list of commands into a single blob/script:
    0 = Command1 # Command2 # ... # CommandN
  could be rewritten
    0 = "Command1
    Command2
    ...
    CommandN"
  However the formatting would be optionnal, people could write them on a single line or indent them as will without modifying their evaluation.

- Ability to use local variables that would disappear as soon as a blob/script is done:
    MyVar: Command1
    Command2 @MyVar
  What punctuation would you prefer for assignment ':' or '=' ? Same for the reference '@', '$', or something else?

- Ability to directly refer to config values (ie. global variables) as shortcuts to Config.SetValue & Config.GetValue:
    RunTime.Menu: Object.GetName ^
    Object.Delete $RunTime.Menu
  Again, which punctuation would you rather see for the reference ('$' ?) and the section/key separation '.', '|', '/', ...
  I'd also like to be able to compose a config variable name with the content of local variables:
    name: Object.GetName ^
    Object.Create $@name.Child
    RunTime.@name: ^

- Ability to chain commands directly, ie. use a command in-place as an argument for another one:
    Object.Delete Object.GetName ^
  This is equivalent to the current
    > Object.GetName ^ #
       Object.Delete <
  Or in the new system, it could also be written:
    name: Object.GetName ^
    Object.Delete @name


Taking a real world example from the original Commands and TimeLines post:

[CursorTrack]
0 = > Mouse.GetPosition                   #
    > Render.GetWorldPosition <           #
    > + < (0,0,0.01)                      #
      Object.SetPosition ^ <

Could either be rewritten as short as:

[CursorTrack]
0 = Object.SetPosition ^ + Render.GetWorldPosition Mouse.GetPosition (0,0,0.01)

Or with some fancy identation:

[CursorTrack]
0 = "Object.SetPosition ^
                        + Render.GetWorldPosition Mouse.GetPosition
                          (0,0,0.01)"

Or even, in a more traditional way:

[CursorTrack]
0 = "pos: Mouse.GetPosition
     pos: Render.GetWorldPosition @pos
     pos: + @pos (0,0,0.01)
     Object.SetPosition ^ @pos"

Any thoughts/comments?

Cheers,

Rom

Philippe Simons

unread,
Sep 26, 2014, 8:06:43 AM9/26/14
to orx...@googlegroups.com
On Thu, Sep 25, 2014 at 11:05 PM, iarwain <iar...@orx-project.org> wrote:
Hi all,

I've been using commands and timelines extensively in my last project and they turned to be invaluable for providing hooks between code and UI/gameplay.

However they can become pretty cumbersome, especially if one isn't used to stack-based evaluations.

I'd like to propose here a few improvements, lemme know what you think:

- Ability to pack a list of commands into a single blob/script:
    0 = Command1 # Command2 # ... # CommandN
  could be rewritten
    0 = "Command1
    Command2
    ...
    CommandN"
  However the formatting would be optionnal, people could write them on a single line or indent them as will without modifying their evaluation.

- Ability to use local variables that would disappear as soon as a blob/script is done:
    MyVar: Command1
    Command2 @MyVar
  What punctuation would you prefer for assignment ':' or '=' ? Same for the reference '@', '$', or something else?

I'll say '=' and '$'
 

- Ability to directly refer to config values (ie. global variables) as shortcuts to Config.SetValue & Config.GetValue:
    RunTime.Menu: Object.GetName ^
    Object.Delete $RunTime.Menu
  Again, which punctuation would you rather see for the reference ('$' ?) and the section/key separation '.', '|', '/', ...

'@' for reference and '.' for separation (same as config)
awesome !
 

Cheers,

Rom

--
You received this message because you are subscribed to the Google Groups "orx-dev" group.
To post to this group, send email to orx...@googlegroups.com.
Visit this group at http://groups.google.com/group/orx-dev.

orx-project

unread,
Sep 28, 2014, 3:20:42 AM9/28/14
to orx...@googlegroups.com
>> - Ability to use local variables that would disappear as soon as a
>> blob/script is done:
>> MyVar: Command1
>> Command2 @MyVar
>> What punctuation would you prefer for assignment ':' or '=' ? Same for
>> the reference '@', '$', or something else?
>
>
> I'll say '=' and '$'

I think I'd rather have something different than '=' as it's already
used for the key/value storing in config.
I like $.

>> - Ability to directly refer to config values (ie. global variables) as
>> shortcuts to Config.SetValue & Config.GetValue:
>> RunTime.Menu: Object.GetName ^
>> Object.Delete $RunTime.Menu
>> Again, which punctuation would you rather see for the reference ('$' ?)
>> and the section/key separation '.', '|', '/', ...
>
>
> '@' for reference and '.' for separation (same as config)

Makes sense.

Thanks! =)

Rom

iarwain

unread,
Sep 28, 2014, 3:35:28 AM9/28/14
to orx...@googlegroups.com
Ah, yes, I forgot to mention the one issue I can see right now: how to deal with optional parameters when evaluating chained calls.
How would you see it?

One way would be to tag optional parameters like putting them within [] or (). Example:

Object.GetPosition ^ [Config.SetValue RunTime MyBool true]

!=

Object.GetPosition ^ Config.SetValue RunTime MyBool true

Dans le premier cas, le résultat de Config.SetValue est envoyé en paramètre optionnel de Object.GetPosition, dans le second c'est une commande qui n'est pas liée à la première.

iarwain

unread,
Sep 28, 2014, 3:37:14 AM9/28/14
to orx...@googlegroups.com
Another option would be to specify the number of parameters sent to a command explicitly when needed:

Object.GetPosition/2 ^ Config.SetValue RunTime MyBool true

Any suggestion?

Philippe Simons

unread,
Sep 28, 2014, 5:04:10 PM9/28/14
to orx...@googlegroups.com
J'aime bien que tu passe de l'anglais au francais dans le même mail....

Anyway how hard would it be to uses parentheses .. like

Object.GetPosition(^, Config.SetValue(RunTime,MyBool,true))
Object.GetPosition(^) Config.SetValue(RunTime, MyBool, true)

or add a statement separator

Object.GetPosition ^ Config.SetValue RunTime MyBool true;
Object.GetPosition ^; Config.SetValue RunTime MyBool true

--

iarwain

unread,
Sep 28, 2014, 10:59:09 PM9/28/14
to orx...@googlegroups.com


Le dimanche 28 septembre 2014 17:04:10 UTC-4, Philippe Simons a écrit :
J'aime bien que tu passe de l'anglais au francais dans le même mail....

Heh, c'est ce qui arrive quand on écrit des emails à 4h du mat'. =)
 

Anyway how hard would it be to uses parentheses .. like

Object.GetPosition(^, Config.SetValue(RunTime,MyBool,true))
Object.GetPosition(^) Config.SetValue(RunTime, MyBool, true)


This is precisely what I'd like to avoid, not because of the difficulty but because I don't like the style: it adds control characters (parens, comas) everywhere when they would only be needed for the exception cases. I'd rather keep the syntax as light as possible in the tradition of languages such as Rebol, Forth or Tcl.
 
or add a statement separator

Object.GetPosition ^ Config.SetValue RunTime MyBool true;
Object.GetPosition ^; Config.SetValue RunTime MyBool true

I don't think that would be enough for all the situations. Let's take an example of 2 commands that accepts 3 optional parameters each: A & B, and two parameters C & D.

A B C; D => Does this mean that C is an optional argument of A or B?

Philippe Simons

unread,
Sep 29, 2014, 4:36:25 AM9/29/14
to orx...@googlegroups.com
Ok, I understand... was just thinking that commands syntax wasn't the most obvious to read, and theses changes (which are welcomed) won't make it any easier...

Go with the option to explicitly specify the number of parameters

iar...@orx-project.org

unread,
Sep 29, 2014, 1:21:48 PM9/29/14
to orx...@googlegroups.com
Well the thing is that chaining or putting statements on the same line is entirely optional, so you can choose to do it only if you're comfortable with it.

As a side note, I guess it's all a matter of tastes and habits: I personally do find something like (actual Rebol)

foreach file read %./data [write file replace/all read file "<placeholder>" "spam"]

more readable and easier to type than, let's say:

foreach (file : directory.read("./data")) do
{
  file.write(file.read().replace("<placeholder>", "spam", true));
Reply all
Reply to author
Forward
0 new messages