Skip to content

Use lambda instead of evaling s-expressions #18

@Stebalien

Description

@Stebalien

Several types define expressions to be evaluated at runtime. E.g.:

  1. Switch statements where we have to eval the expression then find the matching case.
  2. List sizes.
  3. Struct sizes.

Instead, we should just use lambda expression so the byte-compiler can optimize them. We can likely provide some nice macros if lambdas become unwieldy. E.g., a switch could be written as:

(defclast ...
  (xcb:-struct)
  ((thing :initform
          (xcb:-switch (xcb:-fieldref 'class-id)
	        ((0) pitch duration led-mask led-values global-auto-repeat click percent pad~0 auto-repeats~)
	        ((1)
	         pad~1 accel-num accel-denom threshold)
	        ((2)
	         max-symbols num-keysyms keysyms~)
	        ((3)
	         resolution min-value max-value)
	        ((4)
	         led-mask* led-values*)
	        ((5)
	         percent* pad~2 pitch* duration*))))

Where xcb:-switch would compile the switch down to a lambda returning the correct case to use given some obj.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions