Skip to content

Look at "structure" #82

@skx

Description

@skx

Hacker news had a link to Zuo recently:

That has support for "struct", which seems to do a bunch of things. Given the following code:

   (struct person name age)

Generates a bunch of things:

  • Generates a constructor
    • (set! person (fn* (name age))
  • Generates a type check
    • `(set! person? (fn* (x) ... is x an instance of person)"
  • Generates accessors for each field
    • (set! person-name (fn* (strct) (return strct.name)
    • (set! person-age (fn* (strct) (return strct.age)

More stuff wasn't immediately obvious, but I guess there are setters to match the getters. I guess the complication for implementation would be the creation of the methods, dynamically.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions