[plt-scheme] Typed-Scheme and structs

From: Paulo J. Matos (pocmatos at gmail.com)
Date: Sun Mar 22 10:00:54 EDT 2009

On Sun, Mar 22, 2009 at 1:48 PM, Sam TH <samth at ccs.neu.edu> wrote:
> Sure, I'll try to do that.  Can you submit a bug report with the
> feature request?  In general, I prefer to have these requests as bug
> reports to keep track of them more easily.
>
> Also, are you sure you really want auto fields?  Auto fields, as they
> exist right now, are only useful with mutation, and are fairly
> inconvenient to use.  What are you planning to use them for?
>

In my case, I use it for constant fields. For example:
I have a specification language whose expressions have an attached
type. So, untyped, the structure looks like:
#lang scheme

(define-struct Type-Integer
  ())

(define-struct Variable
  (name type))

(define-struct Integer-Literal
  (value
   (type #:auto))
  #:auto-value (make-Type-Integer))

If I try to type it, I end up not being able to assign a constant to
the Integer Literal. Anyway, that's not a big problem because I can
set it automatically when I create the structure or export a
make-Integer-Literal that sets it automatically.

Another issue is, I have several structures defining all the
expression types in my language and I have a function get type that
accesses the type field of each structure and returns it by converting
the structure to a vector and returning the last vector field. This
doesn't seem to work in typed-scheme. Should I file it as a bug?

The alternative it to use match on the structures and get the type
field but this intuitively seems a lot slower than converting to
vector and getting its last field.

Any alternative designs suggestions are welcome.

Cheers,

Paulo Matos

> sam th
>
> On Sun, Mar 22, 2009 at 1:33 PM, Paulo J. Matos <pocmatos at gmail.com> wrote:
>> Hi all,
>>
>> Can't I have auto fields in typed-scheme structures?
>>
>> Cheers,
>>
>> --
>> Paulo Jorge Matos - pocmatos at gmail.com
>> Webpage: http://www.personal.soton.ac.uk/pocm
>> _________________________________________________
>>  For list-related administrative tasks:
>>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>>
>
>
>
> --
> sam th
> samth at ccs.neu.edu
>



-- 
Paulo Jorge Matos - pocmatos at gmail.com
Webpage: http://www.personal.soton.ac.uk/pocm


Posted on the users mailing list.