To go further, if you wonder how to make this work for `match` and
inheriting, see this stackoverflow question:
https://stackoverflow.com/questions/55262818/how-to-override-a-struct-constructor-while-still-providing-the-struct-metadata-f

On Mon, Mar 18, 2019 at 3:08 PM Marc Kaufmann <marc.kaufman...@gmail.com>
wrote:

> While I did know that I could define my own, I was going to do it while
> providing-out another function make-fish and make-shark, but it's nice to
> know that this allows me to locally define make-fish, while it looks to the
> outside like (fish ...).
>
> Thanks to including sufficient numbers of mundane bugs in my code (all
> well-maintained in version control, for quick deployment on docker), I
> rarely get to worry about phases - it just isn't where the highest gains
> are. :-)
>
> On Mon, Mar 18, 2019 at 2:46 PM Jérôme Martin <jerome.martin....@gmail.com>
> wrote:
>
>> Once you discover that the default constructor for a struct is just a
>> simple procedure that was generated for you, it's not that big of deal to
>> just make your own and export it like this:
>>
>> (provide
>>   (except-out (struct-out fish) fish)
>>   (rename-out (make-fish fish)))
>>
>> All the code relying on it will still work.
>> Except I guess if you pass through different phase levels, it becomes a
>> bit more complicated because you have a syntax attached at compile-time to
>> the identifier. But that's another issue.
>> Correct me if I'm wrong.
>>
>> On Monday, March 18, 2019 at 2:11:46 PM UTC+1, Marc Kaufmann wrote:
>>>
>>> Yes, I saw that, the problem is that I want to be able to set a
>>> (potentially different) default value for the sub-type shark than for the
>>> sub-type guppy. So if I set the value to 'big for all `fish`, then I can't
>>> do that. Essentially, I'd need an #:auto for every sub-type, but the #:auto
>>> refers to a parent/super field.
>>>
>>> I'll just run with defining a custom constructor.
>>>
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "Racket Users" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/racket-users/TthsE0FZDB0/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> racket-users+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to