RE: [racket-users] Racket-ese for Scheme `define-record-type' protocol?

2016-12-29 Thread Matthew Flatt
The `#:guard` option doesn't let you change the arity of the
constructor, so I don't think that's what Eric wants.

The separate `make-racr-specification` function is how I would write
it, including using `make-` as a prefix.

At Thu, 29 Dec 2016 10:53:49 +0100, "Jos Koot" wrote:
> Doesn't (struct ... #:guard guard-proc ...) not do what you want?
> See the doc on struct.
> Jos
> 
> -Original Message-
> From: racket-users@googlegroups.com [mailto:racket-users@googlegroups.com] On 
> Behalf Of Eric Eide
> Sent: jueves, 29 de diciembre de 2016 2:55
> To: Racket Users
> Subject: [racket-users] Racket-ese for Scheme `define-record-type' protocol?
> 
> Hi!  I'm translating a R6RS Scheme program to Racket, and I have a question
> about the best "Racket-ese" translation for Scheme's `define-record-type'.
> 
> Consider the following R6RS definition:
> 
> -
>  (define-record-type racr-specification
>(fields (mutable specification-phase) rules-table (mutable start-symbol))
>(opaque #t)(sealed #t)
>(protocol
> (lambda (new)
>   (lambda ()
> (new 1 (make-eq-hashtable 50) racr-nil)
> -
> 
> What is the Racket translation of the protocol specification?  Reading the
> online Racket docs, I don't see how to specify a different (and fresh per
> instance) value for every field within Racket's `struct` form.  (#:auto and
> #:auto-value are not what I want; I need different values, and fresh values,
> for every created instance.)
> 
> I guess I could "cheat" by defining the "expected" constructor myself:
> 
> -
> (define (make-racr-specification)
>   (racr-specification 1 (make-eq-hashtable 50) racr-nil))
> -
> 
> But this seems common enough that it would be built into `struct` in some way?
> Or maybe `struct` isn't what I want at all?
> 
> Thanks ---
> 
> Eric.
> (a Racket newbie)
> 
> -- 
> ---
> Eric Eide   . University of Utah School of 
> Computing
> http://www.cs.utah.edu/~eeide/ . +1 (801) 585-5512 voice, +1 (801) 581-5843 
> FAX

-- 
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.


RE: [racket-users] Racket-ese for Scheme `define-record-type' protocol?

2016-12-29 Thread Jos Koot
Doesn't (struct ... #:guard guard-proc ...) not do what you want?
See the doc on struct.
Jos

-Original Message-
From: racket-users@googlegroups.com [mailto:racket-users@googlegroups.com] On 
Behalf Of Eric Eide
Sent: jueves, 29 de diciembre de 2016 2:55
To: Racket Users
Subject: [racket-users] Racket-ese for Scheme `define-record-type' protocol?

Hi!  I'm translating a R6RS Scheme program to Racket, and I have a question
about the best "Racket-ese" translation for Scheme's `define-record-type'.

Consider the following R6RS definition:

-
 (define-record-type racr-specification
   (fields (mutable specification-phase) rules-table (mutable start-symbol))
   (opaque #t)(sealed #t)
   (protocol
(lambda (new)
  (lambda ()
(new 1 (make-eq-hashtable 50) racr-nil)
-

What is the Racket translation of the protocol specification?  Reading the
online Racket docs, I don't see how to specify a different (and fresh per
instance) value for every field within Racket's `struct` form.  (#:auto and
#:auto-value are not what I want; I need different values, and fresh values,
for every created instance.)

I guess I could "cheat" by defining the "expected" constructor myself:

-
(define (make-racr-specification)
  (racr-specification 1 (make-eq-hashtable 50) racr-nil))
-

But this seems common enough that it would be built into `struct` in some way?
Or maybe `struct` isn't what I want at all?

Thanks ---

Eric.
(a Racket newbie)

-- 
---
Eric Eide   . University of Utah School of Computing
http://www.cs.utah.edu/~eeide/ . +1 (801) 585-5512 voice, +1 (801) 581-5843 FAX

-- 
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.

-- 
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.