Changeset 13768 in project

03/15/09 20:09:27 (11 years ago)
Kon Lovett

Update of rtd prop. Added %add1 & %sub1.

2 edited


  • chicken/trunk/chicken-primitive-object-inlines.scm

    r13756 r13768  
    979979(define-inline (%even? n) (##core#inline "C_i_evenp" n))
     981(define-inline (%+ x y) ((##core#primitive "C_plus") x y))
    981982(define-inline (%- x y) ((##core#primitive "C_minus") x y))
    982983(define-inline (%* x y) ((##core#primitive "C_times") x y))
    983984(define-inline (%/ x y) ((##core#primitive "C_divide") x y))
    984 (define-inline (%+ x y) ((##core#primitive "C_plus") x y))
     986(define-inline (%add1 x) (%+ x 1))
     987(define-inline (%sub1 x) (%- x 1))
    986989(define-inline (%quotient x y) ((##core#primitive "C_quotient") x y))
  • chicken/trunk/misc/Chicken Runtime Data Type Proposal

    r13709 r13768  
    260260structure-type object always has at least 1 element.
    262 For backwards compatibility, if needed, a structure-type with a symbol in slot
     262For backwards compatibility a structure-type with a symbol in slot
    2632630 can be given the current semantics. A synthetic rtd can be generated
    264264on-the-fly for such cases.
    372372-- Unresolved:
     374--- Generative vs. Nongenerative
     376(Shiro Kawai comp.lang.scheme Sun, 8 Mar 2009 01:14:37 -0800 (PST) Generative/nongenerative record types)
     377This is just a rough idea from top of my head.  Feedbacks are welcome.
     379I've been feeling very uncomfortable about "nongenerative" record type
     380creation feature in R6RS but couldn't point my finger to what made me
     381feel so.  I see why the feature like that is needed, but it doesn't
     383like Scheme-way as I perceive (what Scheme-way is may vary widely
     384among people, though).  I dug the discussion about it and so far got
     385an impression that (1) first, make-record-type is understood to be
     386generative, in order to guarantee to create distinct types, and then
     387(2) uid for nongenerative record type creation is introduced, mainly
     388to accomodate efficient local record definitions.
     390Record type descriptor is an immutable object, and I tend to think
     391equality of immutable objects should, ideally, defined by equality of
     392its components (as Henry Baker suggests in [1]).  Implementation may
     393take advantage of immutability to share the same storage for
     394equivalent object.  Anyway, it seems weird that two immutalbe objects
     395are not equivalent even though I cannot distinguish one from the other
     396any way except the system-provided equivalence predicate (e.g. eqv?).
     398The only reason I can think of that immutable record types with
     399exactly the same definitions need to be distinguished is the necessity
     400of distinct types.
     402Then, how about separate type identity from structure definitions?
     404The record type in R6RS are burdened by two roles; creating distinct
     405types, and creating aggregate types.  These two are not the same;
     406sometimes I merely need an aggregate type for code readability and do
     407not care if it is distinct from other types.  I've been happily using
     408a macro that expands aggregate type definition into bunch of
     409procedures that operate on vectors.
     413* make-record-type-descriptor (or equivalent) is *allowed* to return
     415  identical rtd if all the given arguments are equivalent.
     417* Record type equivalence is based on equivalence of rtd's components.
     418(If the implementation returns identical rtd for equivalent arguments,
     419the comparison is effectively eq?).
     421* If you need distinct types, give make-record-type-descriptor
     423different.  An easiest way may be to add "type-id" component to rtd,
     425use eqv? to compare that component to determine equivalence of rtds.
     426It is easy to create distinct rtd by giving (cons #f #f) as type-id.
     428* For the syntactic layer, I'm not sure whether the define-record-type
     429macro should create a distinct type or not.  But I feel it better to
     430have different macros for distinct type creation and mere aggregate
     431type creation.  Local aggregate structure for readability requires
     432latter, while the record type which is part of external API of some
     433module may require former.
     435On the surface, this idea just reverses the default perception of
     436generative/nongenerative behavior of make-record-type-descriptor;
     437R6RS's is generative unless unique uid is given.  This one is
     438nongenerative unless unique type-id is given.  But this one eliminates
     439explicit bookkeeping of uids, which is effectively creating another
     440namespace in R6RS.
    374444--- Conflicts between structure-type 'symbol' tags & 'rtd-object' names is an
    375445open issue.
Note: See TracChangeset for help on using the changeset viewer.