You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Denis <ji...@respublica.fr> on 2002/05/02 11:42:58 UTC

Re: Userfriendly (WAS: RE: String concatenation Was: Give it a whirl. ..)

Simon,
On Thursday, May 2, 2002, at 10:07 AM, Simon Christian wrote:

> I agree wholeheartedly with this sentiment (though perhaps not with the 
> punctuation ;)

I think influential people here don't! Myself I have mixed feelings...
Christoph defines himself as a 'programmer', which is supposedly not the 
target audience of VTL. This discussion is not just nitpicking, there 
are real issues behind. Such as providing coherent syntax, making 
designers life simpler by limiting type errors in templates, etc.

My opinion is that we shouldn't try with string concatenation until 
there is an obvious answer. Geir already has a working parser that 
allows multilined strings, with embedded comments or newline escaping if 
you like, and Velocity admits all kind of things inside double 
quotes "". So the pressure for the string catenation operator is not too 
high.


Nevertheless, I will expose some new ideas as they occurred to me...
Why do we need a catenation operator? Part of the problem is that macros 
take parameters with no separator, just listed one after the other. On 
the other hand, the arithmetic + is not allowed for macro parameters.

So the idea is this:
For any construct but macros, you can build a string by just putting one 
after the other. E.g.

#set ( greetings = "Hello " $name )

In macros, either string catenation is not available or it is done with 
the + operator. E.g.

#title( "Hello " + $name )

So much for consistent syntax! But at least there would be no type 
conflicts. There would be no need to read the documentation to 
understand a template, which is a huge plus.
Try it on your templates, I think you will agree it looks quite good.

>
> Are nested braces interpreted at the moment?
>
> - simon
>
> Christoph Wilhelms wrote:
>
>> Hi all!
>> So, from my point of view as a programmer in different 
>> programming-languages
>> from Fortran to Java (via COBOL, C, C++, VB, VBA) I can say that the 
>> recent
>> discussion pretty much annoyed me!
>> For me it is OBVIOUS to take "+" like in Geirs-Proposal!
>> Reasons: Sting concat in Fortran, Cobol, C/C++ is PIA! I know many 
>> guys who
>> wrote their own function-libraries just for Strings and String
>> concatenation!

What does PIA mean?

-- Denis.


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Userfriendly (WAS: RE: String concatenation Was: Give it a whirl. ..)

Posted by Daniel Dekany <dd...@freemail.hu>.
Thursday, May 2, 2002, 11:42:58 AM, Denis wrote:

[snip]
> So the idea is this:
> For any construct but macros, you can build a string by just putting one 
> after the other. E.g.
>
> #set ( greetings = "Hello " $name )

I think this is a great idea, but only if we do an incompatible change
and make ',' as the obligatory macro parameter separator. And this
probably will not happen. /-: BTW who/why voted +1 on the current
macro call syntax??? Why is it good?

> In macros, either string catenation is not available or it is done with 
> the + operator. E.g.
>
> #title( "Hello " + $name )

S-: Oh no... this is complicated and disturbing. IMO we should allow
any expression as macro parameters (well, some performance problems
are here: macro parameters are evaluated again and again every time
when they occur in the macro body) and introduce ',' as parameter
separator.


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>