Gauche icon indicating copy to clipboard operation
Gauche copied to clipboard

Renamed field names in record type defintions

Open mnieper opened this issue 4 years ago • 5 comments

Gauche does not accept record names that arise through hygienic renaming:

(import (scheme base))

(define-syntax foo
  (syntax-rules ()
    ((foo k) (k field))))

(define-syntax bar
  (syntax-rules ()
    ((bar name)
     (define-record-type <rtd>
       (make-record name)
       record?
       (name record-name record-set-name!)))))

(foo bar)

This program gives the error:

*** ERROR: rtd-constructor: field-specs contains unrecognized field name: #<identifier r7rs.user#field.de1e36c0>

While loading "./g.scm" at line 15

Stack Trace:


0 (rtd-constructor #:.152 #(field)) [unknown location]

mnieper avatar Apr 09 '20 10:04 mnieper

PS: It seems that the field names have to be converted from identifiers to symbols, for example here: https://github.com/shirok/Gauche/blob/1a0933e094ae5f1a530a36b3c836afdb822c8647/libsrc/gauche/record.scm#L476

mnieper avatar Apr 09 '20 10:04 mnieper

might be related to #532

pclouds avatar Apr 09 '20 10:04 pclouds

I have tested with Gauche 0.9.6 that comes with Ubuntu 19.10.

mnieper avatar Apr 09 '20 10:04 mnieper

On master, it seems to work

gosh[r7rs.user]$ (foo bar)
#:record-set-name!.617

pclouds avatar Apr 09 '20 13:04 pclouds

Yes I think this particular example runs on 0.9.9. The other macro-defining-macro issue discussed in #532 is in unreleased master.

shirok avatar Apr 10 '20 03:04 shirok