Damdoshi / LibLapin

Multimedia library for rookies and prototyping
http://hangedbunnystudio.com
Other
36 stars 9 forks source link

Executef/Getf are somewhat duplication of the same thing and underlying functions and address resolution are a mess #23

Open Damdoshi opened 3 months ago

Damdoshi commented 3 months ago

Using bunny_configuration for more advanced stuff in TAdventure have revealed some stuff:

As getf is able to execute expressions and functions if they do not take any parameter., it makes executef only relevant to functions/expresssions that takes parameters. Therefore, getf should be a specific case of executef with params set to NULL.

Currently, getf is the king of the hill, but trying to get a value from an expression or a function fail and log "syntax" errors : because parameters are not sent, prototype is not matched and parameters variable are not created. it is seens as "trying to access undeclared variables"... Not really what is precisely happenning, only a consequence of it.


Underlying functions are mostly there because of the previous attempt to have a nice "bunny configuration" API, so they are half public, half private, to avoid breaking compatibility with existing (Which I doubt they exist outside my own games)

The configuration.h header file should be rethinked and a lot of functions maybe should be removed. "get_X", "go_get_X", "vget_X", "vgo_getX", etc.


Address resolution is not satisfying mainly because it relies on a single context for symbol resolution. Meaning if you are in local context, using a variables from root, parameters or artificial context may not be possible because there is not way variables form these contexts to be fetch because go_get_schmolduc_node does not take them as parameters. Root may be explicitly provided by writing "[]" as first element of address, but not anything inside. For example, "LocalNode.SubLocalNode[RootValue][Parameter]" may not work.

It does not always go in the way, but it could and it is annoying.

Damdoshi commented 3 months ago

(I'm implementing quick and dirty executef flavors and macro for my needs in tadventure - later, those should be factorised elegantly, considering avaiable functions and current redundancy)

Damdoshi commented 3 months ago

I have hit the problem with a very simple code:

  [Go
    Command = "aller"
    Target = "porte", "salle"
    Condition(int c, node v) = c > 0 && v[0] in Target
    Failed(int c, node v) = [Function
      integer i

      For i = 0 to i < NbrCase([#Go].Target) Step i += 1
      "", Target[i] '<== Does not work. Target is from artificial context, i is from local context
      Next
    ]
  ]