Changeset 13768 in project


Ignore:
Timestamp:
03/15/09 20:09:27 (11 years ago)
Author:
Kon Lovett
Message:

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

Location:
chicken/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • chicken/trunk/chicken-primitive-object-inlines.scm

    r13756 r13768  
    979979(define-inline (%even? n) (##core#inline "C_i_evenp" n))
    980980
     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))
     985
     986(define-inline (%add1 x) (%+ x 1))
     987(define-inline (%sub1 x) (%- x 1))
    985988
    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.
    261261
    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:
    373373
     374--- Generative vs. Nongenerative
     375
     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.
     378
     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
     382look
     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.
     389
     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?).
     397
     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.
     401
     402Then, how about separate type identity from structure definitions?
     403
     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.
     410
     411Specifically,
     412
     413* make-record-type-descriptor (or equivalent) is *allowed* to return
     414the
     415  identical rtd if all the given arguments are equivalent.
     416
     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?).
     420
     421* If you need distinct types, give make-record-type-descriptor
     422something
     423different.  An easiest way may be to add "type-id" component to rtd,
     424and
     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.
     427
     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.
     434
     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.
     441
     442[1] http://home.pipeline.com/~hbaker1/ObjectIdentity.html
     443
    374444--- Conflicts between structure-type 'symbol' tags & 'rtd-object' names is an
    375445open issue.
Note: See TracChangeset for help on using the changeset viewer.