From: Ali
Subject: Growing a data type?
Date: 
Message-ID: <ea699e19-00ba-4aa6-a976-395cbf4c97f2@n1g2000prb.googlegroups.com>
Hi,

Just watched Guy Steele's Growing a Language (http://video.google.com/
videoplay?docid=-8860158196198824415), very impressive.

Lisp got plus points for being able to abstract both abstract syntax
and function calls.

Here's a (hopefully) fun question: If Lisp didn't have a string data
type already, could you grow one which was indistinguishable from the
standard implementation, including double quote delimiters?

I don't expect this to be answered because I don't think I know any
language which can do this, but it would be nice to see how much of
string could be implemented in Lisp.

From: ······@gmail.com
Subject: Re: Growing a data type?
Date: 
Message-ID: <f84c78ec-3632-475b-91f2-04daf98ebd52@b38g2000prf.googlegroups.com>
On Oct 31, 12:08 pm, Ali <·············@gmail.com> wrote:
> Hi,
>
> Just watched Guy Steele's Growing a Language (http://video.google.com/
> videoplay?docid=-8860158196198824415), very impressive.
>
> Lisp got plus points for being able to abstract both abstract syntax
> and function calls.
>
> Here's a (hopefully) fun question: If Lisp didn't have a string data
> type already, could you grow one which was indistinguishable from the
> standard implementation, including double quote delimiters?
>
> I don't expect this to be answered because I don't think I know any
> language which can do this, but it would be nice to see how much of
> string could be implemented in Lisp.
string is vector with character as element-type so sure you can have
string class
also you can set reader to dispatch on " so you can have literal
strings
http://www.lispworks.com/documentation/HyperSpec/Body/02_add.htm

btw. in almost any language (known to me) string is specialized vector
(hmm, not in perl) ... but i dont know how you can solve literal
strings problem without messing with implementation
From: William James
Subject: Re: Growing a data type?
Date: 
Message-ID: <f31ed075-6123-4409-964d-13ea7ea02860@v16g2000prc.googlegroups.com>
On Oct 31, 6:08 am, Ali <·············@gmail.com> wrote:
> Hi,
>
> Just watched Guy Steele's Growing a Language (http://video.google.com/
> videoplay?docid=-8860158196198824415), very impressive.
>
> Lisp got plus points for being able to abstract both abstract syntax
> and function calls.
>
> Here's a (hopefully) fun question: If Lisp didn't have a string data
> type already, could you grow one which was indistinguishable from the
> standard implementation, including double quote delimiters?
>
> I don't expect this to be answered because I don't think I know any
> language which can do this

This is trivial in Forth.  The limitation is that the
opening double-quote mark must be followed by a space.

Instead of
  "foo-bar"
you would have
  " foo-bar"
From: Ali
Subject: Re: Growing a data type?
Date: 
Message-ID: <b6914677-912b-48bc-8578-3be5234122f0@s9g2000prm.googlegroups.com>
On Oct 31, 1:40 pm, William James <·········@yahoo.com> wrote:
> On Oct 31, 6:08 am, Ali <·············@gmail.com> wrote:
>
> > Hi,
>
> > Just watched Guy Steele's Growing a Language (http://video.google.com/
> > videoplay?docid=-8860158196198824415), very impressive.
>
> > Lisp got plus points for being able to abstract both abstract syntax
> > and function calls.
>
> > Here's a (hopefully) fun question: If Lisp didn't have a string data
> > type already, could you grow one which was indistinguishable from the
> > standard implementation, including double quote delimiters?
>
> > I don't expect this to be answered because I don't think I know any
> > language which can do this
>
> This is trivial in Forth.  The limitation is that the
> opening double-quote mark must be followed by a space.
>
> Instead of
>   "foo-bar"
> you would have
>   " foo-bar"

Nice one. Can you do it in Lisp? Does "  foo-bar" -> " foo-bar" ?
From: Grant Rettke
Subject: Re: Growing a data type?
Date: 
Message-ID: <a5a37832-0285-4c41-a6e1-9c3446ffef59@f37g2000pri.googlegroups.com>
On Oct 31, 6:08 am, Ali <·············@gmail.com> wrote:
> Here's a (hopefully) fun question: If Lisp didn't have a string data
> type already, could you grow one which was indistinguishable from the
> standard implementation, including double quote delimiters?

Changing how the reader works and pondering implementation of data
types is a fun question.

How about that Forth example, neath isn't it!
From: Pascal Costanza
Subject: Re: Growing a data type?
Date: 
Message-ID: <6n0bdhFip6jdU1@mid.individual.net>
Ali wrote:
> Hi,
> 
> Just watched Guy Steele's Growing a Language (http://video.google.com/
> videoplay?docid=-8860158196198824415), very impressive.
> 
> Lisp got plus points for being able to abstract both abstract syntax
> and function calls.
> 
> Here's a (hopefully) fun question: If Lisp didn't have a string data
> type already, could you grow one which was indistinguishable from the
> standard implementation, including double quote delimiters?
> 
> I don't expect this to be answered because I don't think I know any
> language which can do this, but it would be nice to see how much of
> string could be implemented in Lisp.

I think Guy Steele has more interesting things in mind than 
reimplementing strings.


Pascal

-- 
My website: http://p-cos.net
Common Lisp Document Repository: http://cdr.eurolisp.org
Closer to MOP & ContextL: http://common-lisp.net/project/closer/
From: Ali
Subject: Re: Growing a data type?
Date: 
Message-ID: <72454fbe-7aae-44cf-9b6e-2b5b3d902a35@f37g2000pri.googlegroups.com>
> I think Guy Steele has more interesting things in mind than
> reimplementing strings.

I'm not Guy Steele, I have boring things in mind such as seeing if
this theme can be extended across to the area of data types.

Why should I care? Its not interesting to you, but in case you've
missed the fact, I'll tell you:
Programs are pretty pointless without a concept of data. That is why I
find the question both interesting and important.

---

I may have misread your post, but I see it as both a) condescending,
and b) lacking anything interesting in itself.

Although I don't mind either of those properties on their own, when
combined, a magical process occurs in my brain where I start thinking
less of you, no matter how good a Lisp hacker you are.

And no, my question wasn't the best in the world, it was merely aimed
at producing some interesting conversation.
From: Tamas K Papp
Subject: Re: Growing a data type?
Date: 
Message-ID: <6n0oqqFj4f4fU1@mid.individual.net>
On Fri, 31 Oct 2008 08:36:12 -0700, Ali wrote:

>> I think Guy Steele has more interesting things in mind than
>> reimplementing strings.
> 
> I'm not Guy Steele, I have boring things in mind such as seeing if this
> theme can be extended across to the area of data types.
> 
> Why should I care? Its not interesting to you, but in case you've missed
> the fact, I'll tell you:
> Programs are pretty pointless without a concept of data. That is why I
> find the question both interesting and important.

Indeed.  But if you have basic data types (numbers, arrays, structs, 
lists) that all major languages possess nowadays, you can always 
implement new data types by combining them.  In this sense your question 
is trivial - if Lisp didn't have strings, there would be a zillion ways  
to implement them as sequences of characters, index->character has 
tables, or whatever (some of course make more sense than others).  The 
same applies to other general languages.

The other aspect is providing a read syntax, which is not that important 
anyhow for new data types, but milanj answered this questions for you.

> I may have misread your post, but I see it as both a) condescending, and
> b) lacking anything interesting in itself.
> 
> Although I don't mind either of those properties on their own, when
> combined, a magical process occurs in my brain where I start thinking
> less of you, no matter how good a Lisp hacker you are.
> 
> And no, my question wasn't the best in the world, it was merely aimed at
> producing some interesting conversation.

No, you were asking about something trivial that you could have found out 
for yourself easily.

Please understand that for some reason c.l.l attracts a whole bunch of 
clowns (I am not implying that you are one of them) who have no desire to 
program Lisp, just keep asking questions or emitting utterances they 
think are profound, so people reading this NG are a bit tired of things 
like that.

HTH,

Tamas
From: Pascal Costanza
Subject: Re: Growing a data type?
Date: 
Message-ID: <6n0vunFjcatlU1@mid.individual.net>
Ali wrote:
>> I think Guy Steele has more interesting things in mind than
>> reimplementing strings.
> 
> I'm not Guy Steele, I have boring things in mind such as seeing if
> this theme can be extended across to the area of data types.
> 
> Why should I care? Its not interesting to you, but in case you've
> missed the fact, I'll tell you:
> Programs are pretty pointless without a concept of data. That is why I
> find the question both interesting and important.
> 
> ---
> 
> I may have misread your post, but I see it as both a) condescending,
> and b) lacking anything interesting in itself.

"I don't expect this to be answered" is already condescending.

When I posted my answer, other posts already gave you the answer to the 
original question: That is, Common Lisp has all the rope you need to 
(re)implement strings yourself, including a read syntax for literal 
values. This is actually not so unusual to do this in Common Lisp for 
other kinds of data types.

> Although I don't mind either of those properties on their own, when
> combined, a magical process occurs in my brain where I start thinking
> less of you, no matter how good a Lisp hacker you are.

Yes, that's a problem with Lispers: They sometimes sound arrogant when 
they are actually just stating facts. ;)

> And no, my question wasn't the best in the world, it was merely aimed
> at producing some interesting conversation.

There is no real seed for an interesting discussion here: Common Lisp 
supports what you need to (re)implement such data types. (Although read 
macros could have more convenient support, but there are people actively 
working on this.)

Since Guy Steele was one of the main designers of Common Lisp, he 
certainly knows all this, so it's most certainly a given that he had 
something more interesting in mind. That's all I wanted to say, and 
that's actually all I said.


Pascal

-- 
My website: http://p-cos.net
Common Lisp Document Repository: http://cdr.eurolisp.org
Closer to MOP & ContextL: http://common-lisp.net/project/closer/
From: Barry Margolin
Subject: Re: Growing a data type?
Date: 
Message-ID: <barmar-154D09.16024631102008@mara100-84.onlink.net>
In article 
<····································@n1g2000prb.googlegroups.com>,
 Ali <·············@gmail.com> wrote:

> Hi,
> 
> Just watched Guy Steele's Growing a Language (http://video.google.com/
> videoplay?docid=-8860158196198824415), very impressive.
> 
> Lisp got plus points for being able to abstract both abstract syntax
> and function calls.
> 
> Here's a (hopefully) fun question: If Lisp didn't have a string data
> type already, could you grow one which was indistinguishable from the
> standard implementation, including double quote delimiters?

You could do it using CLOS.  You would define a STRING class that held 
the data, define a PRINT-OBJECT method that prints it using double quote 
syntax, and a read-macro on double-quote that constructs new strings.

-- 
Barry Margolin, ······@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
From: John Thingstad
Subject: Re: Growing a data type?
Date: 
Message-ID: <op.ujwdvozlut4oq5@pandora.alfanett.no>
P� Fri, 31 Oct 2008 12:08:03 +0100, skrev Ali <·············@gmail.com>:

> Hi,
>
> Just watched Guy Steele's Growing a Language (http://video.google.com/
> videoplay?docid=-8860158196198824415), very impressive.
>
> Lisp got plus points for being able to abstract both abstract syntax
> and function calls.
>
> Here's a (hopefully) fun question: If Lisp didn't have a string data
> type already, could you grow one which was indistinguishable from the
> standard implementation, including double quote delimiters?
>
> I don't expect this to be answered because I don't think I know any
> language which can do this, but it would be nice to see how much of
> string could be implemented in Lisp.

A string is just a array of characters. make-string is thus just a  
convenient shorthand for (make-array ... :element-type 'character) Much of  
the magic like utf16 encoding vs. uft8 vs. iso-lating-1 etc. happen at the  
character level. As for the "string" syntax, that is handled at the reader  
level. define-reader-macro and friends. All of this could be  
defined/redfined in Lisp if you want to. In fact most of Lisp is written  
in Lisp. Most Lisp implementations only use C to bootstrap Lisp and for  
the garbage collector. (Ok so there is a FFI and a few other things.)

--------------
John Thingstad
From: Ali
Subject: Re: Growing a data type?
Date: 
Message-ID: <a005ff5a-77f1-4274-bea2-6d12a83e8a29@i18g2000prf.googlegroups.com>
Okay, thanks for your patient replies of how to change the reader etc.

The answers all seem to resoundingly imply not only that string can be/
is efficiently implemented in terms of array, but it will be possible
to use it exactly as any other default data type.

Although there was also a minor unspoken curiosity as to whether a
certain set of axiomatic types could be/is used for implementing all
others, this is probably also silly because at the bottom line it
would be implementation dependant, and that no-one touched on that
would seem to agree that it is unimportant.

This was certainly a poor attempt at a good question, so sorry for
that.
From: Matthias Buelow
Subject: Re: Growing a data type?
Date: 
Message-ID: <6n15uqFj8v2qU1@mid.dfncis.de>
Ali wrote:

> Here's a (hopefully) fun question: If Lisp didn't have a string data
> type already, could you grow one which was indistinguishable from the
> standard implementation, including double quote delimiters?

Yes, set-macro-character to reprogram the reader, and for string storage
you could use plenty of things, including of course lists (would be a
bit slow but would work.)