Some additional comments about this subject.

A big difference is that in Chez Scheme the cons are mutable, and that
makes it almost impossible to make any optimization with the lists at the
Chez Scheme level.

With the current Racket implementation there are a few reductions at
compile time for the lists, for example

(car (list 1 2 3)) ; ==> 1

(when (list? l)
  (let ([x (cdr l)])
    (list? x)  ;==> #t
))

The optimizer "understands" lists, but it doesn't understand custom structs
that have are list like nesting.

Also, there was an attempt to implement the mcons using a struct instead of
a special construction, but some programs were too slow with the
modification, so it was never merged.
https://github.com/racket/racket/pull/1316

Gustavo





On Wed, Nov 28, 2018 at 3:26 PM Matthew Flatt <mfl...@cs.utah.edu> wrote:

> Right. An alternative would be to set decide eagerly, but `list?` tests
> are infrequent relative to pair constructions.
>
> Then again, a function like `list` can and does set the "is a list" bit
> eagerly and cheaply on newly allocated pairs.
>
> At Wed, 28 Nov 2018 18:16:31 +0100, Robby Findler wrote:
> > Also "don't know yet".
> >
> > Robby
> >
> > On Wed, Nov 28, 2018 at 6:15 PM Alexis King <lexi.lam...@gmail.com>
> wrote:
> >
> > > > On Nov 28, 2018, at 07:15, Matthew Flatt <mfl...@cs.utah.edu> wrote:
> > > >
> > > > Yes, that's special handling for pairs in the sense that the
> > > > traditional Racket implementation takes advantage of leftover bits
> in a
> > > > pair object, and it uses two of them for "is a list" and "not a
> list".
> > > >
> > > > Racket-on-Chez doesn't have the extra bits to work with, so "is a
> list"
> > > > and "not a list" information is recorded separately in an `eq?`-based
> > > > hash table.
> > >
> > > Why does keeping track of “is a list” and “not a list” require two
> bits?
> > > It seems like a pair either is or is not a list, so one bit of
> information
> > > would be sufficient. Are there situations where the system can neither
> be
> > > sure that something is or is not a list? Circular lists, or something
> like
> > > that?
> > >
> > > (This is not really important, of course, I’m just curious.)
> > >
> > > Alexis
> > >
> > > --
> > > 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.
>
> --
> 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.

Reply via email to