HP Forums

Full Version: newRPL: Structured data object?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Would it be a good idea to extend the RPL language by adding a structured data object?
The idea would be something similar to a database, with "records", and each record would have named fields.
If the database is stored in a variable DB, you do:

<< DB :field:1 GET >> to get field 'field' in record 1 of the database object.

PUT would be extended in a similar way, using tags for the field names.

Internally, it can be something like this:
  • Prolog
  • List of field names
  • Array of offsets to ea. record
  • Records in no particular order

If there's 3 field names, for example, each record will consist of 3 objects.
The field names must be in the same order as assigned to the objects, so if the field names are 'a', 'b' and 'c', a record's first object will correspond to 'a', second to 'b' and third to 'c'.
The syntax to edit this type of object is still to be determined, first I'd like to see if there's a need for it.
I could see it being used to define menus and GUI objects, as input for INFORM, for example, it would be much more readable to have field names.
Perhaps a syntax could be:

:{ 'Type' 'Text' 'Value'
:[ :Type:"Title" :Text:"My Inform text" ]:
:[ :Type:"Menu" :Value::{ 'Text' 'Action' 'ActionLS' 'ActionRS' :[ :Text:"SIN" :Action:<< SIN >> :ActionLS:<< ASIN >> :ActionRS:<< ∑ >> ]: }: ]:
:[ :Type: "EditBox" :Text:"Enter variable" :Value:"" ]:
}:

The brackets :{ }: for databases and :[ ]: for records were made up just now without thinking too much, I'm open to suggestions.
Reference URL's