Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
concatenating strings
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  Messages 1 - 25 of 35 - Collapse all  -  Translate all to Translated (View all originals)   Newer >
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
rif  
View profile  
 More options Nov 14 2002, 2:08 pm
Newsgroups: comp.lang.lisp
From: rif <r...@mit.edu>
Date: 14 Nov 2002 14:08:26 -0500
Local: Thurs, Nov 14 2002 2:08 pm
Subject: concatenating strings

I can concatenate strings using

(concatenate 'string "foo" (a-string-returning-function) "baz"))

I do this sort of thing a lot, and I'm tired of looking at concatenate
'string everywhere.  So I thought it'd be nice to have something with
a short name, like strcat (at least I didn't call it StrCat.  Would
str-cat be more Lispy?)  I want the name short, because that helps
keep the code small and avoid having to have excess carriage returns
everywhere

Anyways, it's easy to define as a macro:

(defmacro strcat (&rest args)
  `(concatenate 'string ,@args))

So my question is, is there a way to define this as a function rather
than a macro?

Cheers,

rif


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tim Daly, Jr.  
View profile  
 More options Nov 14 2002, 2:19 pm
Newsgroups: comp.lang.lisp
From: t...@tenkan.org (Tim Daly, Jr.)
Date: Thu, 14 Nov 2002 13:19:16 -0600
Local: Thurs, Nov 14 2002 2:19 pm
Subject: Re: concatenating strings
rif <r...@mit.edu> writes:

...

> Anyways, it's easy to define as a macro:

> (defmacro strcat (&rest args)
>   `(concatenate 'string ,@args))

> So my question is, is there a way to define this as a function rather
> than a macro?

(defun strcat (&rest args)
   (apply #'concatenate 'string args))

Looks good to me.  Or am I missing something?

-Tim      


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Richard Krush  
View profile  
 More options Nov 14 2002, 2:27 pm
Newsgroups: comp.lang.lisp
From: Richard Krush <rkr...@gmx.net>
Date: Thu, 14 Nov 2002 11:28:38 -0800
Local: Thurs, Nov 14 2002 2:28 pm
Subject: Re: concatenating strings

rif <r...@mit.edu> writes:
> I can concatenate strings using

> (concatenate 'string "foo" (a-string-returning-function) "baz"))

> I do this sort of thing a lot, and I'm tired of looking at concatenate
> 'string everywhere.  So I thought it'd be nice to have something with
> a short name, like strcat (at least I didn't call it StrCat.  Would
> str-cat be more Lispy?)  I want the name short, because that helps
> keep the code small and avoid having to have excess carriage returns
> everywhere

Personally I would name it STRING-CONCAT or some such, but that's only
me and I'm having a lot of trouble fitting my code into 80 columns. :)

> Anyways, it's easy to define as a macro:

> (defmacro strcat (&rest args)
>   `(concatenate 'string ,@args))

> So my question is, is there a way to define this as a function rather
> than a macro?

Yes there is! In fact, it will be even simpler than your macro:

  (defun strcat (&rest args)
    (apply #'concatenate 'string args))

If you are not familiar with APPLY, check out CLtL2 or CLHS, since
both do a far better at explaining its use than I am able to.

Hope that helps!

Richard.

P.S. Personally I would leave it as a macro, since you're not doing
anything but rewriting the way a function is called.

--
"I know not with what weapons World War III will be fought, but World War
IV will be fought with sticks and stones." -- Albert Einstein


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Barry Margolin  
View profile  
 More options Nov 14 2002, 2:48 pm
Newsgroups: comp.lang.lisp
From: Barry Margolin <bar...@genuity.net>
Date: Thu, 14 Nov 2002 19:22:39 GMT
Local: Thurs, Nov 14 2002 2:22 pm
Subject: Re: concatenating strings
In article <wj0znsc9dg5....@five-percent-nation.mit.edu>,

rif  <r...@mit.edu> wrote:

>I can concatenate strings using

>(concatenate 'string "foo" (a-string-returning-function) "baz"))

>I do this sort of thing a lot, and I'm tired of looking at concatenate
>'string everywhere.  So I thought it'd be nice to have something with
>a short name, like strcat (at least I didn't call it StrCat.  Would
>str-cat be more Lispy?)  I want the name short, because that helps
>keep the code small and avoid having to have excess carriage returns
>everywhere

Well, short names in general are not very Lispy.  Except for some of the
primitives that are used extremely frequently (DEFUN, CAR, CONS), most Lisp
functions are words spelled out in full.  In Zetalisp this function was
called STRING-APPEND.

>Anyways, it's easy to define as a macro:

>(defmacro strcat (&rest args)
>  `(concatenate 'string ,@args))

>So my question is, is there a way to define this as a function rather
>than a macro?

(defun strcat (&rest args)
  (apply #'concatenate 'string args))

--
Barry Margolin, bar...@genuity.net
Genuity, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Christopher C. Stacy  
View profile  
 More options Nov 14 2002, 2:57 pm
Newsgroups: comp.lang.lisp
From: cst...@dtpq.com (Christopher C. Stacy)
Date: Thu, 14 Nov 2002 19:57:26 GMT
Local: Thurs, Nov 14 2002 2:57 pm
Subject: Re: concatenating strings
In Symbolics Common Lisp, we called it STRING-APPEND.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Erik Naggum  
View profile  
 More options Nov 14 2002, 4:13 pm
Newsgroups: comp.lang.lisp
From: Erik Naggum <e...@naggum.no>
Date: 14 Nov 2002 21:13:13 +0000
Local: Thurs, Nov 14 2002 4:13 pm
Subject: Re: concatenating strings
* rif <r...@mit.edu>
| I can concatenate strings using
|
| (concatenate 'string "foo" (a-string-returning-function) "baz"))
|
| I do this sort of thing a lot,

  But that should have told you something.  You should perhaps look into
  Common Lisp's support for string-streams.

--
Erik Naggum, Oslo, Norway

Act from reason, and failure makes you rethink and study harder.
Act from faith, and failure makes you blame someone and push harder.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jochen Schmidt  
View profile  
 More options Nov 14 2002, 5:25 pm
Newsgroups: comp.lang.lisp
From: Jochen Schmidt <j...@dataheaven.de>
Date: Thu, 14 Nov 2002 23:24:08 +0100
Local: Thurs, Nov 14 2002 5:24 pm
Subject: Re: concatenating strings

Richard Krush wrote:
> P.S. Personally I would leave it as a macro, since you're not doing
> anything but rewriting the way a function is called.

Hm then I would declare it inline.

ciao,
Jochen

--
http://www.dataheaven.de


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thomas F. Burdick  
View profile  
 More options Nov 14 2002, 5:51 pm
Newsgroups: comp.lang.lisp
From: t...@apocalypse.OCF.Berkeley.EDU (Thomas F. Burdick)
Date: 14 Nov 2002 14:51:08 -0800
Local: Thurs, Nov 14 2002 5:51 pm
Subject: Re: concatenating strings

rif <r...@mit.edu> writes:
> I can concatenate strings using

> (concatenate 'string "foo" (a-string-returning-function) "baz"))

Yep, you can.  One thing you might consider is using the functional
programming utility "curry".  Here's a simple definition:

  (defun curry (fn &rest args)
    (if (null args)
        fn
        (let ((first (first args)))
          (curry #'(lambda (&rest args) (apply fn first args))
                 (rest args)))))

Now you can say:

  (let ((string-cat (curry #'concatenate 'string)))
    (funcall string-cat "foo" "bar" "baz"))

It's not the most efficient way of doing this, but...        

> I do this sort of thing a lot, and I'm tired of looking at concatenate
> 'string everywhere.

... you're obviously not concerned with efficiency.  That, or you have
yet to discover WITH-OUTPUT-TO-STRING.

> So I thought it'd be nice to have something with a short name, like
> strcat (at least I didn't call it StrCat.  Would str-cat be more
> Lispy?)  I want the name short, because that helps keep the code
> small and avoid having to have excess carriage returns everywhere

Using abbreviations in global names is generally considered a bad
thing.  Notice how few CL functions use them ... and those are only
the old ones, before the lesson was learned.

--
           /|_     .-----------------------.                        
         ,'  .\  / | No to Imperialist war |                        
     ,--'    _,'   | Wage class war!       |                        
    /       /      `-----------------------'                        
   (   -.  |                              
   |     ) |                              
  (`-.  '--.)                              
   `. )----'                              


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Barry Margolin  
View profile  
 More options Nov 14 2002, 6:03 pm
Newsgroups: comp.lang.lisp
From: Barry Margolin <bar...@genuity.net>
Date: Thu, 14 Nov 2002 23:03:12 GMT
Local: Thurs, Nov 14 2002 6:03 pm
Subject: Re: concatenating strings
In article <xcvd6p77okj....@apocalypse.OCF.Berkeley.EDU>,
Thomas F. Burdick <t...@apocalypse.OCF.Berkeley.EDU> wrote:

>rif <r...@mit.edu> writes:

>> I can concatenate strings using

>> (concatenate 'string "foo" (a-string-returning-function) "baz"))

>Yep, you can.  One thing you might consider is using the functional
>programming utility "curry".  Here's a simple definition:

>  (defun curry (fn &rest args)
>    (if (null args)
>        fn
>        (let ((first (first args)))
>          (curry #'(lambda (&rest args) (apply fn first args))
>                 (rest args)))))

Shouldn't it be (apply #'curry #'(lambda ...) (rest args))?

BTW, the way this definition reuses variable and function names reminds me
of the old PL/I joke:

IF IF = IF
THEN THEN = THEN;
ELSE ELSE = ELSE;

Let's hear it for languages without reserved words! :)

>Now you can say:

>  (let ((string-cat (curry #'concatenate 'string)))
>    (funcall string-cat "foo" "bar" "baz"))

>It's not the most efficient way of doing this, but...        

You could also do:

(defun string-cat (&rest strings)
  (reduce #'(lambda (s1 s2) (concatenate 'string s1 s2)) strings))

--
Barry Margolin, bar...@genuity.net
Genuity, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
rif  
View profile  
 More options Nov 14 2002, 6:22 pm
Newsgroups: comp.lang.lisp
From: rif <r...@mit.edu>
Date: 14 Nov 2002 18:22:13 -0500
Local: Thurs, Nov 14 2002 6:22 pm
Subject: Re: concatenating strings

> | I do this sort of thing a lot,
>   But that should have told you something.  You should perhaps look into
>   Common Lisp's support for string-streams.

Thanks.  I will check this out.

rif


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Nils Goesche  
View profile  
 More options Nov 14 2002, 6:25 pm
Newsgroups: comp.lang.lisp
From: Nils Goesche <n...@cartan.de>
Date: 15 Nov 2002 00:25:27 +0100
Local: Thurs, Nov 14 2002 6:25 pm
Subject: Re: concatenating strings
t...@apocalypse.OCF.Berkeley.EDU (Thomas F. Burdick) writes:

Indeed ;-) The only thing I miss since I turned my back to *ML
and came back to Lisp is currying; here is my version of CURRY:

(defmacro curry (f &rest curry-args)
  (let ((args (gensym "ARGS"))
        (fun (gensym "FUN"))
        (curries (mapcar (lambda (arg)
                           (declare (ignore arg))
                           (gensym))
                         curry-args)))
    `(let ((,fun ,f)
           ,@(mapcar #'list curries curry-args))
       (lambda (&rest ,args)
         (declare (dynamic-extent ,args))
         (apply ,fun ,@curries ,args)))))

CL-USER 143 > (map nil (curry #'format t "~&~D ~A")
                   '(1 2 3)
                   '(foo bar baz))
1 FOO
2 BAR
3 BAZ
NIL

Regards,
--
Nils Gösche
Ask not for whom the <CONTROL-G> tolls.

PGP key ID #xD26EF2A0


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Daniel Barlow  
View profile  
 More options Nov 14 2002, 7:19 pm
Newsgroups: comp.lang.lisp
From: Daniel Barlow <d...@telent.net>
Date: Fri, 15 Nov 2002 00:05:43 +0000
Local: Thurs, Nov 14 2002 7:05 pm
Subject: Re: concatenating strings
t...@apocalypse.OCF.Berkeley.EDU (Thomas F. Burdick) writes:

> Using abbreviations in global names is generally considered a bad
> thing.  Notice how few CL functions use them ... and those are only

But conversely, CL is a language which encourages you to create your
own domain-specific language on top of it, and perhaps it's reasonable
when creating a language that the shorter words should correspond to
the most often-used concepts.

After all, it seems on the whole, a bit pointless to create an
alternative to (concatenate 'string ...) on the grounds that it's
excessively long, unless the replacement is going to be significantly
shorter.

(That said, I agree with the other comments here that string-streams
are probably a better idea in this case anyway)

-dan

--

  http://ww.telent.net/cliki/ - Link farm for free CL-on-Unix resources


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
klw  
View profile  
 More options Nov 14 2002, 8:49 pm
Newsgroups: comp.lang.lisp
From: "klw" <nos...@for.me.please>
Date: Fri, 15 Nov 2002 01:48:34 GMT
Local: Thurs, Nov 14 2002 8:48 pm
Subject: Re: concatenating strings
What an interesting coincidence.  I was noticing how much (concatenate
'string ..., was repeating in my code.   I have been doing a lot of string
processing lately.  I wrote this very thing today, and wondered what the
community would think about it.  If it was considered bad style, etc ... my
macro was called s+

Thank you for posting this question rif!  And thank you everyone who offered
your thoughts and advice about this.

klw

"rif" <r...@mit.edu> wrote in message

news:wj0znsc9dg5.fsf@five-percent-nation.mit.edu...


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Matthew Danish  
View profile  
 More options Nov 14 2002, 10:47 pm
Newsgroups: comp.lang.lisp
From: Matthew Danish <mdan...@andrew.cmu.edu>
Date: Thu, 14 Nov 2002 22:50:39 -0500
Local: Thurs, Nov 14 2002 10:50 pm
Subject: Re: concatenating strings

On Thu, Nov 14, 2002 at 11:28:38AM -0800, Richard Krush wrote:
> Yes there is! In fact, it will be even simpler than your macro:

>   (defun strcat (&rest args)
>     (apply #'concatenate 'string args))

> If you are not familiar with APPLY, check out CLtL2 or CLHS, since
> both do a far better at explaining its use than I am able to.

> Hope that helps!

> Richard.

> P.S. Personally I would leave it as a macro, since you're not doing
> anything but rewriting the way a function is called.

It is better to use functions when you can, because functions are far
more flexible than macros: you can apply, funcall, reduce, map, and
generally pass them around.  If you want to avoid the overhead of the
function call, instead of using a macro use an inline function, as
Jochen points out.

--
; Matthew Danish <mdan...@andrew.cmu.edu>
; OpenPGP public key: C24B6010 on keyring.debian.org
; Signed or encrypted mail welcome.
; "There is no dark side of the moon really; matter of fact, it's all dark."


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Coby Beck  
View profile  
 More options Nov 14 2002, 11:35 pm
Newsgroups: comp.lang.lisp
From: "Coby Beck" <cb...@mercury.bc.ca>
Date: Fri, 15 Nov 2002 15:36:48 +1100
Local: Thurs, Nov 14 2002 11:36 pm
Subject: Re: concatenating strings

"Matthew Danish" <mdan...@andrew.cmu.edu> wrote in message

news:20021114225039.B19796@lain.cheme.cmu.edu...

I think a good general rule of thumb is if it is evaluating all its
arguments, it is not a macro.
ie
(defmacro strcat (@rest strings)
   `(concatenate 'string ,strings))

--
Coby Beck
(remove #\Space "coby 101 @ bigpond . com")


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thomas F. Burdick  
View profile  
 More options Nov 15 2002, 12:48 am
Newsgroups: comp.lang.lisp
From: t...@famine.OCF.Berkeley.EDU (Thomas F. Burdick)
Date: 14 Nov 2002 21:48:27 -0800
Local: Fri, Nov 15 2002 12:48 am
Subject: Re: concatenating strings

Oops, that's what I get for coding directly in my post.  The actual
CURRY-LEFT and CURRY-RIGHT functions (and accompanying compiler
macros) I use are a little less obvious, and I was just trying to get
the point across.

> BTW, the way this definition reuses variable and function names reminds me
> of the old PL/I joke:

> IF IF = IF
> THEN THEN = THEN;
> ELSE ELSE = ELSE;

> Let's hear it for languages without reserved words! :)

Between my working on compiler stuff, and the CL interpreter I
recently wrote (in debugging, but coming in a public and liberally
licenced form soon), I'm slightly worried that I'm more comfortable
with two namespaces and tight scoping than most people.  I noticed
that over the last year or two, I've been doing even more of this than
I used to.

> >Now you can say:

> >  (let ((string-cat (curry #'concatenate 'string)))
> >    (funcall string-cat "foo" "bar" "baz"))

> >It's not the most efficient way of doing this, but...        

> You could also do:

> (defun string-cat (&rest strings)
>   (reduce #'(lambda (s1 s2) (concatenate 'string s1 s2)) strings))

Wow, now that's cons-y :)

--
           /|_     .-----------------------.                        
         ,'  .\  / | No to Imperialist war |                        
     ,--'    _,'   | Wage class war!       |                        
    /       /      `-----------------------'                        
   (   -.  |                              
   |     ) |                              
  (`-.  '--.)                              
   `. )----'                              


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
rif  
View profile  
 More options Nov 15 2002, 7:49 am
Newsgroups: comp.lang.lisp
From: rif <r...@mit.edu>
Date: 15 Nov 2002 07:49:30 -0500
Local: Fri, Nov 15 2002 7:49 am
Subject: Re: concatenating strings

> (That said, I agree with the other comments here that string-streams
> are probably a better idea in this case anyway)

So I investigated a bit, and it seems to me (please correct me if I'm
wrong) that string-streams are the right solution if what I'm doing is
building up a single string using a large number of concatenate
operations.  In my situation, what's actually happening is that once
or twice per function (in many functions), I need to take a base file
name and add an extension to the filename (not always the same
extnsions(s)), so I don't thing that string-streams help here.

rif


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Espen Vestre  
View profile  
 More options Nov 15 2002, 8:16 am
Newsgroups: comp.lang.lisp
From: Espen Vestre <espen@*do-not-spam-me*.vestre.net>
Date: 15 Nov 2002 14:00:02 +0100
Local: Fri, Nov 15 2002 8:00 am
Subject: Re: concatenating strings

rif <r...@mit.edu> writes:
> In my situation, what's actually happening is that once
> or twice per function (in many functions), I need to take a base file
> name and add an extension to the filename (not always the same
> extnsions(s)), so I don't thing that string-streams help here.

Hmm - maybe you should start to think in terms of pathnames instead?
That will absolutely not make your code very compact to begin with,
but it might be more appropriate. Maybe you should really use
something like:

(defun add-file-type (basename type)
   (merge-pathnames (pathname basename) (make-pathname :type type)))        

instead of concatenate?
--
  (espen)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tim Bradshaw  
View profile  
 More options Nov 15 2002, 9:21 am
Newsgroups: comp.lang.lisp
From: Tim Bradshaw <t...@cley.com>
Date: 15 Nov 2002 14:12:22 +0000
Local: Fri, Nov 15 2002 9:12 am
Subject: Re: concatenating strings

* rif  wrote:
>> > So I investigated a bit, and it seems to me (please correct me if I'm
> wrong) that string-streams are the right solution if what I'm doing is
> building up a single string using a large number of concatenate
> operations.  In my situation, what's actually happening is that once
> or twice per function (in many functions), I need to take a base file
> name and add an extension to the filename (not always the same
> extnsions(s)), so I don't thing that string-streams help here.

If you're doing stuff with pathnames, then you should use pathnames,
not strings!

(defun typify-pathname (pathname type)
  (make-pathname :type type :defaults pathname))

--tim


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Erik Naggum  
View profile  
 More options Nov 15 2002, 3:12 pm
Newsgroups: comp.lang.lisp
From: Erik Naggum <e...@naggum.no>
Date: 15 Nov 2002 20:12:12 +0000
Local: Fri, Nov 15 2002 3:12 pm
Subject: Re: concatenating strings
* rif <r...@mit.edu>
| In my situation, what's actually happening is that once or twice per
| function (in many functions), I need to take a base file name and add an
| extension to the filename (not always the same extnsions(s)), so I don't
| thing that string-streams help here.

  Then your next exercise would be to investigate pathnames and their
  manipulation functions.  Sorry about the string-streams detour.

--
Erik Naggum, Oslo, Norway

Act from reason, and failure makes you rethink and study harder.
Act from faith, and failure makes you blame someone and push harder.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thomas A. Russ  
View profile  
 More options Nov 15 2002, 11:41 pm
Newsgroups: comp.lang.lisp
From: t...@sevak.isi.edu (Thomas A. Russ)
Date: 15 Nov 2002 17:55:22 -0800
Local: Fri, Nov 15 2002 8:55 pm
Subject: Re: concatenating strings
t...@apocalypse.OCF.Berkeley.EDU (Thomas F. Burdick) writes:

> ... you're obviously not concerned with efficiency.  That, or you have
> yet to discover WITH-OUTPUT-TO-STRING.

It has been our experience that the overhead to setup a string stream
for output can be quite high, at least in some implementations.  It
isn't clear that using such a form will be more efficient than doing
string concatentation.

The string output formalism is convenient, however, if you already have
print functions that do what you want, or if the parts of the code that
add parts to the final string are widely scattered, with a lot of
processing or decision making in between.

--
Thomas A. Russ,  USC/Information Sciences Institute          t...@isi.edu    


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Erik Naggum  
View profile  
 More options Nov 16 2002, 12:18 am
Newsgroups: comp.lang.lisp
From: Erik Naggum <e...@naggum.no>
Date: 16 Nov 2002 05:18:44 +0000
Local: Sat, Nov 16 2002 12:18 am
Subject: Re: concatenating strings
* Thomas A. Russ
| It has been our experience that the overhead to setup a string stream for
| output can be quite high, at least in some implementations.

  Please report this is as a performance-related deficiency to the vendor.
  Even more, /please/ do not discourage people from using features just
  because some vendors have not yet given priority to performance.  Doing
  so causes the language we can depend on to shrink as vendors ignore the
  parts of the standard they do not "like" and think people should not use.

--
Erik Naggum, Oslo, Norway

Act from reason, and failure makes you rethink and study harder.
Act from faith, and failure makes you blame someone and push harder.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thomas F. Burdick  
View profile  
 More options Nov 16 2002, 8:28 pm
Newsgroups: comp.lang.lisp
From: t...@apocalypse.OCF.Berkeley.EDU (Thomas F. Burdick)
Date: 16 Nov 2002 17:28:09 -0800
Local: Sat, Nov 16 2002 8:28 pm
Subject: Re: concatenating strings
t...@sevak.isi.edu (Thomas A. Russ) writes:

> t...@apocalypse.OCF.Berkeley.EDU (Thomas F. Burdick) writes:

> > ... you're obviously not concerned with efficiency.  That, or you have
> > yet to discover WITH-OUTPUT-TO-STRING.

> It has been our experience that the overhead to setup a string stream
> for output can be quite high, at least in some implementations.  It
> isn't clear that using such a form will be more efficient than doing
> string concatentation.

Hmm, I just checked with CMUCL, OpenMCL, and CLISP.  On the latter
two, using string streams is clearly faster.  CMUCL is slower, but, as
Erik noted, I consider that to be a bug (now that I noticed).  I would
argue that it *should* be more efficient, though, since you're giving
the compiler more information about what you're up to.

> The string output formalism is convenient, however, if you already have
> print functions that do what you want, or if the parts of the code that
> add parts to the final string are widely scattered, with a lot of
> processing or decision making in between.

It's definately an interface that encourages doing things the right
way, so even on CMUCL, I would reccommend using it unless you've
actually determined string-streams to be the source of a performance
problem.

--
           /|_     .-----------------------.                        
         ,'  .\  / | No to Imperialist war |                        
     ,--'    _,'   | Wage class war!       |                        
    /       /      `-----------------------'                        
   (   -.  |                              
   |     ) |                              
  (`-.  '--.)                              
   `. )----'                              


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Vijay L  
View profile  
 More options Nov 17 2002, 2:39 am
Newsgroups: comp.lang.lisp
From: vij...@lycos.com (Vijay L)
Date: 16 Nov 2002 23:39:51 -0800
Local: Sun, Nov 17 2002 2:39 am
Subject: Re: concatenating strings
t...@apocalypse.OCF.Berkeley.EDU (Thomas F. Burdick) wrote in message <news:xcvd6p77okj.fsf@apocalypse.OCF.Berkeley.EDU>...
> Using abbreviations in global names is generally considered a bad
> thing.  Notice how few CL functions use them ... and those are only
> the old ones, before the lesson was learned.

I take it that you're not very in with Paul Graham's macro: abbreviate

(defmacro abbreviate (short long)
  `(defmacro ,short (&rest args)
     `(,',long ,@args)))

which is used to, as the name suggests, abbreviate long named
functions and macros such as:

(abbreviate mvbind multiple-value-bind)

I find MVBIND far easier to use (except in indenting, but I use
editor:setup-indent, so even that problem is solved) than
MULTIPLE-VALUE-BIND

Thanks,

Vijay L


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Christopher C. Stacy  
View profile  
 More options Nov 18 2002, 12:04 am
Newsgroups: comp.lang.lisp
From: cst...@dtpq.com (Christopher C. Stacy)
Date: Mon, 18 Nov 2002 05:04:23 GMT
Local: Mon, Nov 18 2002 12:04 am
Subject: Re: concatenating strings

>>>>> On 16 Nov 2002 23:39:51 -0800, Vijay L ("Vijay") writes:

 Vijay> t...@apocalypse.OCF.Berkeley.EDU (Thomas F. Burdick) wrote in message <news:xcvd6p77okj.fsf@apocalypse.OCF.Berkeley.EDU>...
 >> Using abbreviations in global names is generally considered a bad
 >> thing.  Notice how few CL functions use them ... and those are only
 >> the old ones, before the lesson was learned.
 >>
 Vijay> I take it that you're not very in with Paul Graham's macro: abbreviate

 Vijay> (defmacro abbreviate (short long)
 Vijay>   `(defmacro ,short (&rest args)
 Vijay>      `(,',long ,@args)))

 Vijay> which is used to, as the name suggests, abbreviate long named
 Vijay> functions and macros such as:

 Vijay> (abbreviate mvbind multiple-value-bind)

 Vijay> I find MVBIND far easier to use (except in indenting, but I use
 Vijay> editor:setup-indent, so even that problem is solved) than
 Vijay> MULTIPLE-VALUE-BIND

If your problem is that you don't like to type long names,
why not use the abbreviation facility that is built into your editor?
For example, in Emacs, you can make the string "mvb" automatically
expand into "multiple-value-bind".  You don't have to type the long
string, but also nobody who comes along looking at your code later on
has to figure out what your random abbreviation means.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Messages 1 - 25 of 35   Newer >
« Back to Discussions « Newer topic     Older topic »