Record type: grouping objects

gd shared this idea 13 years ago
Under Consideration

This request makes sense together my scripting request.

I propose a new object type: records, which are a collection of objects (fields) with names. The two principal uses of records would be

  • to store objects together with custom properties (such as the weight of a mass point in a physics simulation),
  • and, more importantly, to group objects which belong together (and are typically created by a macro), so that if a macro or tool gets one of them as a parameter, it can access the others.

The definition of a record could be without a special syntax e. g.


Of course a special syntax like


would be nicer - this last syntax is possible if ":" is not allowed as an assignment operator in expressions.

Fields of a record could be accessed in the form Record.FieldName - this should work even like Element[listOfRecords,i].FieldName . Fields of records are full-fledged objects with properties (color and others). These field references would behave like objects: if Record is an object (and not an other expression, so that it can be assigned to), the Record.Field reference should behave like a normal object, in that it can be deleted or assigned to, or created by assigning a value to a new field.

The record which contains a field could be accessed with an Owner[Object] command which should work if the parameter is an "lvalue", an object which can be assigned to, such as an existing object parameter of macros.

Dependencies should be handled carefully so that they do not cause a "circular definition" error when unnecessary. With the respect of circular definitions, a definition containing Record.Field should be considered to depend only on Record.Field but not on the entire Record. Owner[param].Field2 (where "param" is an existing object parameter of a macro, in reality referring to Record.Field) should not be considered to depend on the whole Record, preferably not even on Record.Field, only on Record.Field2.

As usually some fields of a record are edited by the user, they should form a tree structure in the algebra window and in the Properties dialog, where the user can open a record and interact with its fields like with normal objects.

© 2022 International GeoGebra Institute