cortoproject / corto

A hierarchical object store for connecting realtime machine data with web applications, historians & more
https://www.corto.io
MIT License
86 stars 14 forks source link

Implement by-value and by-reference semantics in corto_value API #680

Closed SanderMertens closed 6 years ago

SanderMertens commented 6 years ago

Currently the corto_value type allows describing any value in corto, but it does not describe how the value should be accessed. This is problematic when doing operations with values, like corto_value_binaryOp, as evaluation of a binary expression depends on how the operands should be evaluated.

A new field should be added to the corto_value type, which indicates how the value should be referenced. This field should be orthogonal to the existing corto_value type, in that specifying whether a value should be accessed by reference or by value does not affect how the value is stored inside the corto_value.

Currently the corto_value type supports two kinds for storing generic pointers (CORTO_VALUE and CORTO_MEM) where CORTO_VALUE means, look at the value type to determine how it should be referenced, and CORTO_MEM, which always references a pointer by value.

In the new design, these two kinds shall be replaced by CORTO_POINTER, and the new field shall determine whether the pointer should be referred to by value or by reference.

The new design shall support three reference kinds: BY_VALUE, BY_REFERENCE and BY_TYPE. The latter shall be used as default value, and uses the type to determine reference. This is equivalent to the old CORTO_VALUE kind.