Paste: Typed and nested sequences

Author: nomennescio
Mode: factor
Date: Tue, 31 Oct 2023 12:25:35
Plain Text |
! copyright 2023 nomennescio

! normal sequences are considered to have elements of type object, which carry almost no type information
! having uniform sequences with elements of the same type would be an opportunity to specialize for more performant code
! without disrupting the current hierarchies and code, one improvement would be to have such a uniform sequence for nested sequences, to allow for "deep" traversals, a common pattern in many generic words.

! error handling non-similar types (i.e. not base-class nor derived, where mixins are considered classes, and instances subclasses)

ERROR: similar-type element index sequence ;

! high-level skeleton, to be refined

MIXIN: nested-sequence
INSTANCE: nested-sequence sequence

TUPLE: nested-array < array
! additional fields, possible a type field
;

INSTANCE: nested-array nested-sequence

! more code
! setting an array to an element of a different type should fail

DEFER: }} ( -- * ) delimiter
SYNTAX: {{ \ }} [ >nested-array ] parse-literal ;

New Annotation

Summary:
Author:
Mode:
Body: