Skip to content

eval Proteus function apparently no longer works #3

@BruceDLong

Description

@BruceDLong

Some time ago I wrote a function in Proteus called eval or execute. It's called execute here.

execute takes a different Proteus function and a list as arguments. It executes the function with the arguments.

Here is my test case:

2
Two argument function defined with a tag then executed via execute command.
<% +{
    execute=#+{{{...} {...}} @\\[{...}]: \\[{...} {...}]}
    func=#+{{_, _} {\\\[_,_] \\\[_]} }
}    
%>

<% @execute: +{func +{9,4}}   %>
5
done
!

Place that in a file execFunc.pr (it's already in the repo I think) and type:

./ptest <execFunc.pr

It never ends or seg-faults.

Here is what the code does:

In the first section we define the tags 'execute' and 'func'
execute is the function that isn't working.

Remember, the first item in a function's defining list is the arguments and the last item is the return value. So the last item will usually map in some way to the first item, perhaps through interveneing items.

So the arguments for execute is {{...} {...}} -- a list containing two sub-lists of unknown contents.
The arguments for 'func' are {_, _} -- a list containing two integers of unknown value.

func would return the two ints in reverse order. So the call

func: +{9, 4}

would evaluate to {4, 9}

Therefore, the line:

@execute: +{func +{9,4}} 

should evaluate to
func:{9,4}

and then to

{4, 9}

IDEAS
This function worked before but I failed to place a regression test for it in test_build.py. Somewhere along the way the syntax and other things changed and it stopped working.

It's possible that I am defining it wrong or calling it wrong. If so the error is probably in the number of '' s somewhere. E.g., a '\' should be '' or '\'.

The other possibility is that the code has simply changed somehow and it no longer evaluates correctly. Most likely this would be a problem of evaluation order. For example, maybe it is evaluating the arguments to a function before they are filled in. E.g., it is evaluating '[,]' instead of 4, or '[_]' instead of 9.


This function is needed to take functions from a theme and execute them against "myStuff".

The basic idea will be:
for each item to display in myStuff,
execute(the_function_from_the_theme_for_this_type_of_item, args_about _position_etc)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions