💾 Archived View for jb55.com › ward.asia.wiki.org › method-expressions captured on 2021-12-04 at 18:04:22. Gemini links have been rewritten to link to archived content

View Raw

More Information

-=-=-=-=-=-=-

Method Expressions

Method gets and sets variables with long wordy keys. Here we use the context of a single Method to interpret an expression where values can be named by a small but still unique fragment of already retrieved keys.

The existing middle-school math encourages step by step calculations that are hard to misinterpret. Mostly this is due to long and more precise names.

Say <b>CALC</b> to calculate a formula that appears on the remainder of the line.

The formula, without the word CALC, becomes the name of the result and can be used to recall it in later calcuations.

<h3>Example</h3>

Consider computing a paycheck with time and a half for overtime.

This could be more concisely expressed using a formula.

The challenge here is to define CALC to use the label field as a formula written in terms of numbers already defined in the Method. Values are more conveniently identified by single words. Here we will use a partial match on extant value names to give these words meaning.

The formula itself will become the name of the result. However, one might reasonably offer a more descriptive name in a subsequent line, perhaps a SHOW operation.

The formula works with the units present in other values and will return a result with appropriate units.

Hover over the results from this and the previous calculation to compare the difference that units makes.

<h3>Resources</h3>

Matthew Crumley evaluator adapted from Raphael Graf’s ActionScript.

Matthew Crumley

Douglas Crockford javascript evaluator using Pratt's top-down operator precedence.

Douglas Crockford

Jxck simple recursive-descent evaluator in a 90 line gist including tests.

Jxck

About Method Plugin for regular documentation.

About Method Plugin