Shinmera / parachute

An extensible and cross-compatible testing framework.
https://shinmera.github.io/parachute
zlib License
97 stars 9 forks source link

DEFINE-TEST expansion is unreadable #11

Closed phoe closed 1 year ago

phoe commented 4 years ago
(define-test foo
  (is = (+ 2 2) 4))

expands into

(LET ((*PACKAGE* #<PACKAGE "RIICHI-EVALUATOR.TEST">))
  (SETF (FIND-TEST 'FOO #<PACKAGE "RIICHI-EVALUATOR.TEST">)
          (PARACHUTE::ENSURE-TEST 'TEST :NAME 'FOO :HOME
                                  #<PACKAGE "RIICHI-EVALUATOR.TEST"> :TESTS
                                  (LIST (LAMBDA () (IS = (+ 2 2) 4))) :PARENT
                                  'NIL))
  'FOO)

The resulting macroexpansion contains unreadable package objecs, which prevents further processing by e.g. slime-macrostep. Consider not looking the packages up at macroexpansion time and instead inserting (find-package ...) forms that will perform package lookup at execution time.

Hexstream commented 4 years ago

Package objects with proper names are externalizable objects, though, so there should be no problem in having them in macroexpansions.

On Tue, Dec 24, 2019, 6:16 PM phoe notifications@github.com wrote:

(define-test foo (is = (+ 2 2) 4))

expands into

(LET ((PACKAGE #<PACKAGE "RIICHI-EVALUATOR.TEST">)) (SETF (FIND-TEST 'FOO #<PACKAGE "RIICHI-EVALUATOR.TEST">) (PARACHUTE::ENSURE-TEST 'TEST :NAME 'FOO :HOME

<PACKAGE "RIICHI-EVALUATOR.TEST"> :TESTS

                              (LIST (LAMBDA () (IS = (+ 2 2) 4))) :PARENT
                              'NIL))

'FOO)

The resulting macroexpansion contains unreadable package objecs, which prevents further processing by e.g. slime-macrostep. Consider not looking the packages up at macroexpansion time and instead inserting (find-package ...) forms that will perform package lookup at execution time.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Shinmera/parachute/issues/11?email_source=notifications&email_token=AAADFSFUYNCVVWH3GUXLA5TQ2KJ3LA5CNFSM4J7BFL5KYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4ICRT7MQ, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAADFSAHGIH7RVDFLCZH3A3Q2KJ3LANCNFSM4J7BFL5A .

phoe commented 4 years ago

That is correct - unless you would like to copy the macroexpansion into your source file and manipulate it as source, or if you would like to use slime-macrostep to expand a form that is non-expandable because it contains unreadable objects. That's two of my use cases that fail with unreadable objects in macroexpansions.

On 25.12.2019 00:24, Jean-Philippe Paradis wrote:

Package objects with proper names are externalizable objects, though, so there should be no problem in having them in macroexpansions.

On Tue, Dec 24, 2019, 6:16 PM phoe notifications@github.com wrote:

(define-test foo (is = (+ 2 2) 4))

expands into

(LET ((PACKAGE #<PACKAGE "RIICHI-EVALUATOR.TEST">)) (SETF (FIND-TEST 'FOO #<PACKAGE "RIICHI-EVALUATOR.TEST">) (PARACHUTE::ENSURE-TEST 'TEST :NAME 'FOO :HOME

<PACKAGE "RIICHI-EVALUATOR.TEST"> :TESTS

(LIST (LAMBDA () (IS = (+ 2 2) 4))) :PARENT 'NIL)) 'FOO)

The resulting macroexpansion contains unreadable package objecs, which prevents further processing by e.g. slime-macrostep. Consider not looking the packages up at macroexpansion time and instead inserting (find-package ...) forms that will perform package lookup at execution time.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub

https://github.com/Shinmera/parachute/issues/11?email_source=notifications&email_token=AAADFSFUYNCVVWH3GUXLA5TQ2KJ3LA5CNFSM4J7BFL5KYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4ICRT7MQ, or unsubscribe

https://github.com/notifications/unsubscribe-auth/AAADFSAHGIH7RVDFLCZH3A3Q2KJ3LANCNFSM4J7BFL5A .

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Shinmera/parachute/issues/11?email_source=notifications&email_token=ADSZHKXPPXHGK7XFEMAI65TQ2KKZTA5CNFSM4J7BFL5KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHTVXQA#issuecomment-568810432, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADSZHKQPH5P5KR7I5XUUEU3Q2KKZTANCNFSM4J7BFL5A.

Hexstream commented 4 years ago

unless you would like to copy the macroexpansion into your source file and manipulate it as source

I don't think I've ever done that, other than to show macroexpansions in documentation, in which case unreadable objects are not a problem. Macroexpansions are (almost?) never guaranteed to be "human-readable" anyway... (Do you have other use-cases for doing this?)

or if you would like to use slime-macrostep to expand a form that is non-expandable because it contains unreadable objects.

I'm not familiar with slime-macrostep, but shouldn't it be able to deal with unreadable objects in the general case anyway?

phoe commented 4 years ago

I'm not familiar with slime-macrostep, but shouldn't it be able to deal with unreadable objects in the general case anyway?

Not really. It macroexpands by grabbing what is available in the REPL buffer and reading it, which errors on the unreadable objects if I try to recursively expand the result of expanding DEFINE-TEST.

On 25.12.2019 19:07, Jean-Philippe Paradis wrote:

unless you would like to copy the macroexpansion into your source
file and manipulate it as source

I don't think I've ever done that, other than to show macroexpansions in documentation, in which case unreadable objects are not a problem. Macroexpansions are (almost?) never guaranteed to be "human-readable" anyway...

or if you would like to use slime-macrostep to expand a form that
is non-expandable because it
contains unreadable objects.

I'm not familiar with slime-macrostep, but shouldn't it be able to deal with unreadable objects in the general case anyway?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Shinmera/parachute/issues/11?email_source=notifications&email_token=ADSZHKRJE5PLX2OTHWHQJE3Q2OOOZA5CNFSM4J7BFL5KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHUQOSI#issuecomment-568919881, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADSZHKS65SPXK5CH5TEOIL3Q2OOOZANCNFSM4J7BFL5A.