[plt-dev] some Racket proposals & implementation

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Sat Apr 3 09:37:14 EDT 2010

On Sat, Apr 3, 2010 at 4:31 AM, Sam Tobin-Hochstadt <samth at ccs.neu.edu> wrote:
> On Sat, Apr 3, 2010 at 12:21 AM, Jay McCarthy <jay.mccarthy at gmail.com> wrote:
>> While grinding in FF13 tonight, I implemented most of this.
>
> Awesome!
>
>> I've attached three files. Put them in the same directory and you can
>> run sstruct-tests.ss
>>
>> I allow default value expressions, keyword constructors, overriding
>> names of accessors, mutators, constructors, and predicates. I support
>> parent structs and match expanders.
>>
>> There's a bunch of places where more stuff could be allowed that I
>> don't do yet. And I still have 8 test cases failing for those. Most of
>> these and additional features should be easy to support.
>>
>> A few annoyances:
>>
>> First, I have to specify the parent of a struct with struct:id rather
>> than 'id'. The problem is that I'd like 'id' to have three jobs:
>>
>> 1. match expander
>> 2. constructor
>> 3. struct type info
>>
>> Both 1 and 3 are static values so they'll conflict with each other.
>
> The solution here is for one or both of these to be a struct property,
> rather than a struct, so that one struct can be both.
>
> I think that it's struct type info that needs to be the property,
> since `match' depends on `define-struct', rather than the other way
> around.  But probably they both should be.
>
> Another possibility is that `match' could treat identifiers bound to
> static struct info as pattern constructors, even without them being
> match expanders.  This would probably be really easy to implement.

I need more than just the static struct info though to implement super
structs and my match expander does more craziness than 'struct'. So, I
just made my static description struct a sub-struct of match-expander.
Seems vaguely reasonable.

Now the problem I have is that

(define-sstruct a () #:constructor make-a)

requires sub-types to be created with

(define-sstruct (b make-a) ())

rather than

(define-sstruct (b a) ())

That doesn't seem right. Maybe #:constructor should require a
#:struct-info specialization too.

Jay

-- 
Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University
http://teammccarthy.org/jay

"The glory of God is Intelligence" - D&C 93


Posted on the dev mailing list.