On this page:
class
class_  clause
interface_  clause
veneer_  clause
class_  clause.macro
interface_  clause.macro
class_  and_  interface_  clause.macro
veneer_  clause.macro
class_  meta.describe
interface_  meta.describe
veneer_  meta.describe
class_  meta.Info
class_  meta.Info
interface_  meta.Info
interface_  meta.Info
veneer_  meta.Info
veneer_  meta.Info
8.14.0.1
7.13.6 Class, Interface, and Veneer Clause Macros🔗ℹ

space

class

The space for class, interface, and veneer names as bound by class, interface, and veneer.

The spaces for bindings of identifiers that implement class, interface, and veneer clauses, respectively.

definition

class_clause.macro 'defined_name pattern ...':

  option; ...

  body

  ...

 

definition

class_clause.macro

| 'defined_name pattern ...':

    option; ...

    body

    ...

| ...

 

option

 = 

~op_stx: id

 | 

~op_stx id

 | 

~all_stx: id

 | 

~all_stx id

 | 

~info: id

 | 

~info id

Like defn.macro, but defines a name in the class_clause space as a clause form for use within a class body.

The compile-time body block returns the expansion result. The result must be a sequence of groups to be spliced in place of the macro use, where each group can be either a another class clause, an expression, a defintion, or an export.

In addition to ~op_stx and ~all_stx options like defn.macro, the optional ~info body form binds an id to a class_meta.Info value. Use the class_meta.Info.lookup function to access information about the class declaration that appears before the use of the class-clause macro.

> class_clause.macro 'lazy_method $id(): $(body :: Block)':

    'private field result: #false

     method $id():

       result || (block:

                    def v $body

                    result := v

                    v)'

> class Person(name):

    lazy_method greeting():

      "Hello, " +& name

> def ming = Person("Ming")

> ming.greeting()

"Hello, Ming"

> ming.greeting() === ming.greeting()

#true

definition

interface_clause.macro 'defined_name pattern ...':

  option; ...

  body

  ...

 

definition

interface_clause.macro

| 'defined_name pattern ...':

    option; ...

    body

    ...

| ...

Like class_clause.macro, but for interface clauses and binding in the interface_clause space.

definition

class_and_interface_clause.macro 'defined_name

                                    pattern ...':

  option; ...

  body

  ...

 

definition

class_and_interface_clause.macro

| 'defined_name pattern ...':

    option; ...

    body

    ...

| ...

Like class_clause.macro, but defines for use both in class clauses and interface clauses by binding in both the the class_clause and interface_clause spaces.

definition

veneer_clause.macro 'defined_name pattern ...':

  option; ...

  body

  ...

 

definition

veneer_clause.macro

| 'defined_name pattern ...':

    option; ...

    body

    ...

| ...

Like class_clause.macro, but for veneer clauses and binding in the veneer_clause space.

Provided as meta.

Returns an object containing information about name, which must be bound as a class name or internal class name for class_meta.describe, as an interface name or internal interface name for interface_meta.describe, or as a veneer name for veneer_meta.describe. Use class_meta.Info.lookup, interface_meta.Info.lookup, or veneer_meta.Info.lookup to extract details from the information object.

annotation

class_meta.Info

 

function

fun class_meta.Info(

  info :: class_meta.Info,

  key :: Symbol

) :: Any

 

annotation

interface_meta.Info

 

function

fun interface_meta.Info(

  info :: interface_meta.Info,

  key :: Symbol

) :: Any

 

annotation

veneer_meta.Info

 

function

fun veneer_meta.Info(

  info :: veneer_meta.Info,

  key :: Symbol

) :: Any

Provided as meta.

A value satisfying class_meta.Info can be obtained from class_meta.describe or recieved by a class-clause macro through an ~info declaration. Similarly, a value satisfying interface_meta.Info or veneer_meta.Info can be obtained by interface_meta.describe or veneer_meta.describe, or received by an interface- or veneer-clause macro through an ~info declaration. In a macro declared with class_and_interface_clause.macro, a value received by ~info is an instance of either class_meta.Info or interface_meta.Info, which indicates the context where the macro is used.

The . operator can be used on a class information expression as equivalent to calling class_meta.Info functions:

info.lookup(key)

 is 

class_meta.Info. lookup(info, key)

The . operator can be used on a interface information expression as equivalent to calling interface_meta.Info functions:

info.lookup(key)

 is 

interface_meta.Info. lookup(info, key)

The . operator can be used on a veneer information expression as equivalent to calling veneer_meta.Info functions:

info.lookup(key)

 is 

veneer_meta.Info. lookup(info, key)

The class_meta.Info.lookup, interface_meta.Info.lookup, and veneer_meta.Info.lookup functions access information via a key symbol. The currently recognized keys are described below, but more may be added in the future.

When receieved within a class-, interface-, or veneer-clause macro, the information reported for a key covers only class, interface, or veneer clauses before the macro use, so a use of the same key in the same class but in a later clause may report different information. Furthermore, the information has not been fully checked; for example, the name of a class, interface, or veneer being extended is reported as it appears, and has not yet been checked to be a valid class, interface, or veneer name, and multiple names may be reported if a class contains multiple extends clauses. Similarly, field- or method-name lists may include duplicates.

When obtained via class_meta.describe, interface_meta.describe, or veneer_meta.describe, the information covers the whole body of the referenced class, interface, or veneer form. When a class or interface name is used, then information about private fields and methods is omitted from queries; using an internal name for a class or interface includes information about private fields and methods. A class- or inteface-clause macro, which directly receives only partial information, can expand to a use of an expression macro that uses class_meta.describe or interface_meta.describe to get more information based on a retained or newly declared internal name.

Reocgnized keys for classes:

Reocgnized keys for interfaces:

Reocgnized keys for veneers: