Re: [racket-users] How to discover a struct's interface without Dr Racket?

2021-10-31 Thread Brian Beckman
Thanks very much, Matt. This is helpful. I understand macros in a general way (I'm an old [very old] Scheme hand, plus I use Mathematica every day, and it's almost nothing but macros). However, the particulars of Racket's hygienic macro system are new to me, and I will read-up on all the refer

Re: [racket-users] How to discover a struct's interface without Dr Racket?

2021-10-31 Thread Matt Jadud
Hi Brian, In some ways, you did get a very good answer to your first question. You were able to see the properties of a *syntax object*. But syntax objects were, I think, only part of the picture you were looking for. The questions "what does the *struct* form in Racket do, what bindings does it

Re: [racket-users] How to discover a struct's interface without Dr Racket?

2021-10-31 Thread Brian Beckman
Hi, Matt ... I'll try your ideas in a little while. Regarding "why," I want the ability, from a module or a REPL, to quickly dump the attributes of an instance without having to look things up. The need arose when I was barnstorming and trying to explain syntax objects to someone, and he asked

Re: [racket-users] How to discover a struct's interface without Dr Racket?

2021-10-31 Thread Brian Beckman
works :) after 'raco install struct-plus-plus' tyvm On Sunday, October 31, 2021 at 7:03:14 AM UTC-7 david@gmail.com wrote: > The actual accessor functions are in there as well, not just the names. > > On Sun, Oct 31, 2021, 9:58 AM Jens Axel Søgaard > wrote: > >> A quick example: >> >> #lan

Re: [racket-users] How to discover a struct's interface without Dr Racket?

2021-10-31 Thread David Storrs
The actual accessor functions are in there as well, not just the names. On Sun, Oct 31, 2021, 9:58 AM Jens Axel Søgaard wrote: > A quick example: > > #lang racket > (require racket/require) > (require (filtered-in (λ (name) (regexp-replace #rx"struct[+][+]" name > "struct")) >

Re: [racket-users] How to discover a struct's interface without Dr Racket?

2021-10-31 Thread Jens Axel Søgaard
A quick example: #lang racket (require racket/require) (require (filtered-in (λ (name) (regexp-replace #rx"struct[+][+]" name "struct")) struct-plus-plus)) (struct horse (breed color legs)) (define beauty (horse 'arabian 'black 4)) (define info (force (struct-ref beauty)))

Re: [racket-users] How to discover a struct's interface without Dr Racket?

2021-10-31 Thread David Storrs
On Sun, Oct 31, 2021, 7:49 AM Jens Axel Søgaard wrote: > Hi Brian, > > A few random thoughts: > > > I would like, given only the symbol foo referring to the struct type > itself, > > to discover (at least) the list of procedures foo?, foo-a, foo-b, plus > > anything else the author of foo (the ty

Re: [racket-users] How to discover a struct's interface without Dr Racket?

2021-10-31 Thread Jens Axel Søgaard
Hi Brian, A few random thoughts: > I would like, given only the symbol foo referring to the struct type itself, > to discover (at least) the list of procedures foo?, foo-a, foo-b, plus > anything else the author of foo (the type) wants me to see. When you want to look this up, is it in the repl

Re: [racket-users] How to discover a struct's interface without Dr Racket?

2021-10-31 Thread Matt Jadud
Hi Brian, Does this help move you forward? It has been a while since I've stared at macros in Racket, so this might be easier... Also, make sure you're executing this code in a module. If you're working in a REPL, I suspect all bets are off. It is certainly the case that you could combine severa

Re: [racket-users] How to discover a struct's interface without Dr Racket?

2021-10-30 Thread Brian Beckman
Here are some of my latest (failed) experiments: #lang racket (require (for-syntax racket/struct-info)) (require racket/pretty) (struct foo (a b) #:transparent) (displayln `("a foo object is transparent: I can see inside: \n (struct->vector (foo 1 2)) ~~> " ,(struct->vector (foo

Re: [racket-users] How to discover a struct's interface without Dr Racket?

2021-10-29 Thread Siddhartha Kasivajhula
I was able to find this interface , but it doesn't quite provide the same information. E.g. (struct-type-info struct:foo) The ability to "introspect" values in a shell (or in the ap

Re: [racket-users] How to discover a struct's interface without Dr Racket?

2021-10-29 Thread Brian Beckman
Well, as I understand it, a struct (usually? always?), #:transparent or not, when declared, defines symbols that are meant to be visible in the current scope, so (struct foo (a b)) defines foo #|constructor|#, foo? #|instance-predicate|# foo-a and foo-b #|data accessors|# , that I can call on insta

Re: [racket-users] How to discover a struct's interface without Dr Racket?

2021-10-29 Thread 'John Clements' via Racket Users
In the text below, you refer to the “public” interface. Can I ask what you mean by “public” in this context? John > On Oct 29, 2021, at 11:16 AM, Brian Beckman wrote: > > I believe that run time will be the most plausible use case. I may write > macros that refer to struct-procedure names at