ainslec / adventuron-issue-tracker

Adventuron Issues Tracker
4 stars 0 forks source link

[RION] Create short form for collection accessors #461

Closed ainslec closed 2 years ago

ainslec commented 2 years ago

I've notices that non-trivial collection access is nightmarishly complex / messy.

Suggest a short form in Rion to help with this.

Currently:

: print (
    collection_get {
        collection -> ("a")
        index -> (
            collection_get {
                collection -> ("b")
                            index -> (c + d)
            }
        )
    }
);

Suggested replacement:

: print ( a[b[c+d] ] );

Type coersion, means that typing is more or less ok.

This needs to happen at the object notation level and be built into the tooling.

This syntax, like all the sugar scripting syntax forms is English-centric behind the scenes, but it makes no difference in the foreground.

ainslec commented 2 years ago

Fixed in beta 75d.

start_at  = loc1
locations / loc1;
collections {
   my_list : list {
      items  = [ chris, mark, terry ]
   }
}
on_startup {
   : iterate "my_list" / : print ("Item at index " + index() + " is " + my_list[index()] );   
   : press_any_key ;
}