That's an awesome trick, Marc. Thanks!

But still.. I don't see any difference:

> (define-type context
  id: a0000000-0000-0000-0000-000000000000
  constructor: macro-make-context
  macros:                                                                                                                                                                                         
  ;; opaque: WITHOUT OPAQUE
  unprintable:
  a)

(begin
  (##define-macro (macro-make-context p1) (##list '(let () (##declare (extended-bindings)) ##structure) ''#<type #19 context> p1))
  (##define-macro (make-constant-context p1) (##define-type-construct-constant 'make-constant-context '#<type #19 context> p1))
  (##define-macro (context? obj) `((let () (##declare (extended-bindings)) ##structure-direct-instance-of?) ,obj ,''##type-1-a0000000-0000-0000-0000-000000000000))
  (##define-macro (context-a obj) (##list '(let () (##declare (extended-bindings)) ##direct-structure-ref) obj 1 ''#<type #19 context> #f))
  (##define-macro (context-a-set! obj val) (##list '(let () (##declare (extended-bindings)) ##direct-structure-set!) obj val 1 ''#<type #19 context> #f)))

> (define-type context
  id: a0000000-0000-0000-0000-000000000000
  constructor: macro-make-context
  macros:
  opaque: ;; WITH OPAQUE
  unprintable:
  a)

(begin
  (##define-macro (macro-make-context p1) (##list '(let () (##declare (extended-bindings)) ##structure) ''#<type #20 context> p1))
  (##define-macro (make-constant-context p1) (##define-type-construct-constant 'make-constant-context '#<type #20 context> p1))
  (##define-macro (context? obj) `((let () (##declare (extended-bindings)) ##structure-direct-instance-of?) ,obj ,''##type-1-a0000000-0000-0000-0000-000000000000))
  (##define-macro (context-a obj) (##list '(let () (##declare (extended-bindings)) ##direct-structure-ref) obj 1 ''#<type #20 context> #f))
  (##define-macro (context-a-set! obj val) (##list '(let () (##declare (extended-bindings)) ##direct-structure-set!) obj val 1 ''#<type #20 context> #f)))


There is no difference!
I noticed that some attributes produce no difference in the output, but will somehow set some internal flag of Gambit. That's the case of :unprintable, which makes a difference when pretty-printing the object but produces no difference in the generated function/macros. If this is the case, what does opaque: actually do?


Thanks a lot!








        Álvaro Castro-Castilla
          Digital Experiences.   --   visit The Blog





On Tue, Apr 15, 2014 at 4:57 PM, Marc Feeley <feeley@iro.umontreal.ca> wrote:

On Apr 15, 2014, at 9:59 AM, Álvaro Castro-Castilla <alvaro.castro.castilla@gmail.com> wrote:

> Hi!
>
> I've been figuring out all the attributes available with define-type in Gambit. Testing and thanks to:
>
> https://mercure.iro.umontreal.ca/pipermail/gambit-list/attachments/20090226/af2ee44c/attachment-0001.txt
> https://mercure.iro.umontreal.ca/pipermail/gambit-list/2004-December/000043.html
>
> I could understand all but one: opaque. The ways to "learn" how things work with macros producing code is generally the trick (pp (lambda () (macro...)) 'asdf). But what about macros that produce macros? In that case you get an empty form with 'asdf, so no way to know what has been generated.
>
> That of course applies to define-type. There is no difference in generated code with opaque: keyword, so I assume that it only affects non-generative types. Can I see the generated code in such case?
>
> Reading Gambit's code in nonstd.scm doesn't clarify things either.
>
>
> Thank you!
>

Try:

(set! ##define-type-expansion-show? #t)

Marc