[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Proposal: conversion functions

This page is part of the web mail archives of SRFI 101 from before July 7th, 2015. The new archives for SRFI 101 contain all messages, not just those from before July 7th, 2015.

I agree with Taylor that the name list->list is confusing.  The
proposed specification of that function also strikes me as very poor,
for the reason that you have to know what you are putting in to know
what you are going to get out.  I would much rather see a function
named list->random-access-list (and another named list->standard-list
or list->linear-list) that accepts any kind of list and produces one
of the desired type.  That name already suggests that the function may
act as the identity operation on some inputs; in a system where all
lists were random-access, list->random-access-list would very well
always be the identity function.

While we're at it, it would be nice if

(a) All standard functions that expected lists already performed
list->standard-list on their inputs (or could at least be
automatically wrapped to do that); and

(b) There were some mechanism to conveniently additively extend
list->standard-list to handle other types of lists (after all, why
shouldn't it be able to perform vector->list on vectors, and
stream->list on streams, and the appropriate other thing on any other
kind of sequential data structure that might come along in the

While I am for considering list->random-access-list and
list->standard-list for inclusion in the next revision, I am not
seriously suggesting addressing points (a) and (b) in this document.
Rather, the conundrum we are currently having about the interoperation
of random-access lists with regular lists is an example of the fact
that Scheme has no standard mechanism for generic operations, and that
the core functions in the language are not generic---a defect that has
bothered me about Scheme for years.  Is the time ripe for SRFI 102:
Generic Operations?


On Fri, Sep 18, 2009 at 5:27 PM, David Van Horn
<dvanhorn@xxxxxxxxxxxxxxx> wrote:
> Taylor R Campbell wrote:
>>   Date: Fri, 18 Sep 2009 17:09:48 -0400
>>   From: David Van Horn <dvanhorn@xxxxxxxxxxxxxxx>
>>   Here is a proposal for converting between representation of pairs and
>> lists.
>> I think the names PAIR->PAIR and LIST->LIST are very confusing.  Also,
>> both directions are necessary.  How about using more descriptive, if
>> more verbose names, such as SEQUENTIAL-LIST->RANDOM-ACCESS-LIST or
>> LINEAR-LIST->RANDOM-ACCESS-LIST?  Also, are the pair-only operations
>> useful?
> As proposed, they do go both directions.  I suspect the pair only operation
> is not useful, but I'm not sure.  I will punt on that one for now.  As for
> names, I like list->list; it's suggestive of it potentially being an
> identity operation, but I'd like to hear what others think.
> David