Post Reply 
Bug or Feature? val.x:=3
01-11-2022, 11:03 PM
Post: #3
RE: Bug or Feature? val.x:=3
Okay. Playing around with this gave some interesting results.

First, setting up a container variable using "{[x,5],[y,3]}->v" allows use of "v.x" and "v.y". The former evaluates to 5, and the latter to 3. This is effectively an associative list of sorts. Note that while "{{x,5},{y,3}}->v" also works, it doesn't mesh well with the "v.x:=8" syntax. The assignment syntax creates a new entry in the list in a vector. UNION(v,v) will consider the list form "{x,8}" to be different from the vector form "[x,8]" and won't correctly remove duplicates.

Second, the issue of "v.x:=8" creating a new entry in the table can be addressed by UNION(v,v), or INTERSECT(v,v). Still looking for a better way to remove redundant entries.

Third, I haven't found a way to cleanly parameterize the expressions yet. The best I can currently do uses "CAS(eval("v."+x))" where "x" is the name of the variable. It also works with a string containing the item to look up.

Fourth, I don't think you can reference an unassigned member of "v" in formulae. For instance, "v.s=v.y+v.x" is an invalid command with the example.

Finally, I think this does open the door for limited object-oriented programming in PPL. It would be a pretty manual process, but here's an example of a "method" in this system:

Code:

m(this):=
BEGIN
 LOCAL p:=this;
 RETURN p.x+p.y;
END;

And this is an example of a property "set" method:

Code:

set_x(this,val):=
BEGIN
 LOCAL p:=this;
 p.x:=val;
 p:=UNION(p,p);
 RETURN p;
END;

// USAGE
v:=set_x(v,5);

The syntax is still cumbersome, so I'm still looking at how to clean it up, but it looks like it can be made to work as-is.

As always, any additional input would be greatly appreciated, especially if any HP guys run across this. If this is an unintentional thing, it'd be nice to know if it'll still be around in a few updates.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Bug or Feature? val.x:=3 - IHarwell - 01-08-2022, 09:35 PM
RE: Bug or Feature? val.x:=3 - Joe Horn - 01-09-2022, 01:46 AM
RE: Bug or Feature? val.x:=3 - IHarwell - 01-11-2022 11:03 PM



User(s) browsing this thread: 1 Guest(s)