at-el icon indicating copy to clipboard operation
at-el copied to clipboard

Recursive definition using @@ (def@@ @@ () body) is not working

Open sharad opened this issue 7 years ago • 1 comments

Recursive def@ with @@ not work properly, with super method cause infinite recursion.

defining recursively def@ with @@ a easy way to arrange related method of a objects with them.

(progn (setf @test-base (let ((drived-obj (@extend @ :name "test-base")))

      (with-@@ drived-obj

        (setf @:doc "test base")

        (def@ @@ :init ()
          (message "@test-base :init start")
          (@^:init)
          (message "@test-base :init finish"))

        (def@ @@ :dispatch ()
          (message "@test-base :dispatch start")
          (@:init)
          (message "@test-base :dispatch finish"))

        (@:dispatch))
      drived-obj))

(setf @test-base1 (let ((drived-obj (@extend @test-base :name "test base1"))) (with-@@ drived-obj

        (setf @:doc "test base1")

        (def@ @@ :init ()
          (message "@test-base1 :init start")
          (@^:init)
          (message "@test-base1 :init finish"))

        (def@ @@ :dispatch ()
          (message "@test-base1 :dispatch start")
          (@:init)
          (message "@test-base1 :dispatch finish"))

        (@:dispatch)) drived-obj)))

sharad avatar Jul 26 '18 11:07 sharad

Yeah, it's probably not expanding the body properly. I think it needs to force a macro expansion or something like that before recursing into the body. Using lexical-let here probably does something like this as a side effect.

However, that's kind of a hack, and I don't want to use lexical-let since that's been deprecated for years. I can't spot what exactly is wrong with @--walk as written, though.

skeeto avatar Jul 26 '18 20:07 skeeto