[racket] struct constructors

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Tue May 27 03:34:05 EDT 2014

It is not what you need.

When you create a new structure, the constructor is the thing that
makes it... in your example that's "blah". The keyword you mentioned
lets you change that name to something like "mother-in-law", so

(struct blah (a b c v) #:constructor-name mother-in-law)

(mother-in-law 1 2 3 4)

is a valid program.

You may find this useful if you want to write your style struct
constructor but name it "blah".

Jay


On Tue, May 27, 2014 at 1:25 AM, Aidan Gauland <aidalgol at amuri.net> wrote:
> Hello fellow racketeers,
>
> What's the nearest equivalent for a struct to constructors for class
> instances?  Say I have a struct with a field that should be initialised
> to a three-element vector.  Right now, I'm just defining a wrapper
> make-blah.
>
> (struct blah (a b c v))
>
> (define (make-blah)
>   (blah 0 0 0 #(0 0 0))
>
> This seems fine, but I see that there's a keyword argument to the
> `struct' procedure #:constructor-name and I can't quite make sense of
> what that does.  Is it a low-level thing, or is it exactly what I want?
>
> Thanks,
> Aidan Gauland
>
>
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users



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

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

Posted on the users mailing list.