Make-Tag

(make-tag symbol info ...) -> #f

Constructs a new tag, which are user-definable types that are disjoint from MOSVM's primitive types and each other. Used internally by define-record-type and define-class with cell to create new record types and encapsulate the vectors backing the record.

examples/point2.ms

;; This is a more primitive version of the <point> example from define-record.
(define <point> (make-tag 'point ))

(define (make-point x y) (cell <point> (cons x y)))
(define (point-x pt) (car (repr pt)))
(define (point-y pt) (cdr (repr pt)))

Using examples/point2.ms from the REPL:

>> (load "examples/point2.ms")
>> (define p (make-point 111 222))

>> (repr p)
:: (111 . 222)

>> (point-x p)
:: 111

>> (point-y p)
:: 222

>> (type p)
:: <pair>

See Also:

cell, repr, tag-info, tag, type