Post Reply 
newRPL - build 1255 released! [updated to 1299]
04-04-2018, 10:38 PM
Post: #183
RE: newRPL - build 1001 released! [update:build 1052]
(04-04-2018 07:38 PM)The Shadow Wrote:  Hmm. So this will be an automatic feature of all variables? I have mixed feelings about that, depending on how it works.

Like, say C is 'A+B', and I store 1 in A and 2 in B. If I put C on the stack, what do I get, 'A+B' or 3? If the former, how is that different from now? If the latter, how do I edit C to be 'A-B'?

Your example would be like this:
You store 1 in A and 2 in B
You store 'A+B' in the "definition" property of variable 'C'. Right now the syntax is ugly but I think it works well with the 50g keyboard:
Code:
'A+B' 'C...Defn' SPROP
The command SPROP will store the property 'Defn' of variable 'C', properties are separated by a triple dot so it doesn't happen accidentally.
Now variable 'C' will contain the value 3, automatically calculated by applying ->NUM to the 'Defn' property.
SPROP will also scan the formula 'A+B' (or a program, whatever you provide) and determine which global variables it depends on, in this case 'A' and 'B'. Then it will add 'C' to a property called 'Depn' (dependency) in 'A' and 'B'. This 'Depn' property will hold a list of all variables that depend on a given one, so if this variable change, all variables in the list will be recalculated.
A change to 'A' will check if the 'A...Depn' property exists, then go through the list running ->NUM in the 'Defn' propety of each variable. Each variable changed will also trigger other evaluations in the chain.

So the variable will hold the result, and the formula will go in a property, much like in a spreadsheet you have the result and the formula as 2 separate things.
For the units, I think the property 'Unit' will be a preferred display unit, when displaying in a Form it will attempt to convert to the preferred unit but the stored result will retain the unit in which it was calculated. But... I also included an attribute (did I mention now identifiers can have attributes? anyway...) that is simply a flag "force unit". If this attribute is set, the result will be hard-converted to the preferred unit after automatic evaluation of the formula.

You can also "tweak" intermediate values without removing the formula (this you cannot do in Excel, if you write a value, you lose the formula). On your example, if we add:

Code:
'C^2' 'D...Defn' SPROP

And then we do 5 'C' STO, we are tweaking the value of C, which is an intermediate value resulting from 'A+B' to the value 5, which would recalculate 'D'. This leaves the solution in an inconsistent state, since now 'C' is not 'A+B', but is quite useful when you know what you are doing.

All this means one thing: you don't have anything to worry about (un-mix your feelings and relax). If you don't define any 'Defn' properties, your variables will behave like good old 50g, and nothing automatic will ever happen.

Also, there will be a global system flag to disable automatic evaluation. And finally, I need to figure out a way to break out of infinite recursion in the evaluation (or this thing will loop ad-infinitum if you create a circular reference in your problem), but I'm close to a solution there.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: newRPL - build 1001 released! - pier4r - 12-16-2017, 08:03 AM
newRPL - on Hp 39gs - Martin Hepperle - 06-05-2019, 06:51 AM
RE: newRPL - build 1001 released! - pier4r - 12-23-2017, 10:16 AM
RE: newRPL - build 1001 released! - pier4r - 01-01-2018, 09:42 AM
t - Claudio L. - 01-01-2018, 03:06 PM
RE: newRPL - build 1001 released! - pier4r - 01-01-2018, 03:41 PM
RE: newRPL - build 1001 released! - pier4r - 01-02-2018, 04:54 PM
RE: newRPL - build 1001 released! - pier4r - 01-02-2018, 06:58 PM
RE: newRPL - build 1001 released! [update:build 1052] - Claudio L. - 04-04-2018 10:38 PM
newRPL - brickviking - 10-05-2018, 06:01 AM
How to participate? - erazor - 12-13-2019, 07:12 AM



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