Skip to content

Instantly share code, notes, and snippets.

@metaleap
Created June 20, 2024 17:10
Show Gist options
  • Save metaleap/1909b8fc467b90e9376ee4ed7cb46f0b to your computer and use it in GitHub Desktop.
Save metaleap/1909b8fc467b90e9376ee4ed7cb46f0b to your computer and use it in GitHub Desktop.
(import :std/sugar
:std/text/json)
(defsyntax defcls
(syntax-rules ()
((defclas $typename ($fields ...) $ctor-name)
(begin
(defclass $type-name ($fields ...) constructor: $ctor-name)
(defmethod {$ctor-name $type-name}
(lambda (this msg)
(displayln "ctor sez" msg)))
))
))
(defcls MyClass (f1 f2 f3) :init!)
(def (main . args)
(def inst (make-MyClass "hallo"))
(set! (MyClass-f1 inst) "hola")
(displayln (MyClass-f1 inst)))
(main)
@metaleap
Copy link
Author

$ gxi < main.ss
Gerbil v0.18.1-122-g63f46f81 on Gambit v4.9.5-130-g09335d95
> > > > > *** ERROR IN main, (stdin)@19.14-19.26 -- Unbound variable: make-MyClass
--- continuation backtrace:
[0] ##primordial-exception-handler-hook                                                
[1] (interaction)                                                                      (stdin)@23:1-23:7                                                                       (main)
1> 
> 
*** EOF again to exit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment