8.17.0.6

2 Common Run-Time Representations🔗ℹ

Rhombus and Racket share the same or related representations for many basic forms of data:

  • Booleans are the same.

  • Numbers are the same, including fixnums and flonums.

  • Characters, strings, and byte strings are the same. Beware, however, that Racket strings are mutable by default, which satisfies Rhombus’s ReadableString but not String.

  • Symbols and keywords. A keyword is written in shrubbery notation for Rhombus with a ~ prefix, and it is written in S-expression notation with a #: prefix, but the representation does not include that prefix.

    A Racket identifier with non-alphabetic characters can be written in Rhombus using #{} notation, as in #{finish-work}. A Racket keyword with non-alphabetic characters can be written in Rhombus using ~#{} notation, as in ~#{fast?}, or using #{} notation, as in #{#:fast?}, and the former is usually preferred.

  • Functions, including functions with keyword arguments are the same.

    The #{} and ~#{} notations can be useful for calling Racket functions with keyword arguments, as in #{finish-work}(~#{fast?}: #true).

  • Pairs are the same. Racket lists are Rhombus pair lists, Rhombus lists correspond to racket/treelist, and Rhombus mutable lists correspond to racket/mutable-treelist.

  • Racket vectors and Rhombus arrays are the same, and boxes are the same in both.

  • Racket hash tables and Rhombus maps are the same. Rhombus sets are unrelated to any Racket data structure, although the implementation internally uses Racket hash tables.

  • Racket sequences and Rhombus sequences are the same.

  • The void value and end-of-file object are the same.

  • Rhombus and Racket syntax objects are the same. A Rhombus syntax object encodes shrubbery structure within an S-expression syntax object as described in Parsed Representation.

In many other cases, the Rhombus representation of an entity is a wrapper on a Racket representation. For example, a Rhombus Thread object wraps a Racket thread object. In those case, a common convention within Rhombus is to provide access to the Racket representation through a handle property, and sometimes a from_handle function is provided to construct a Rhombus object wrapper for a suitable Racket value.

Rhombus wrappers enable a dynamic . operation to find methods and properties. Although dynamic . works on some kinds of Racket values without a wrapper, such as strings and lists, it relies on built-in support by the . operator. Rhombus has no safe and composable way to extend that built-in set.