You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Bayarsaikhan VOLODYA <ba...@gmail.com> on 2005/08/22 13:34:29 UTC

syntax issue

Hi all,

which syntax is more suitable (or will not be deprecated) preferrable than 
the other one?

${name.firstName}
or 
$name.firstName
or
$name.getFirstName()

thanks in advance.

-- 
Bayarsaikhan VOLODYA

Re: Language Lawyer question (was: Re: syntax issue)

Posted by "Henning P. Schmiedehausen" <hp...@intermeta.de>.
Nathan Bubna <nb...@gmail.com> writes:

>sounds fine to me.   but if we change all the docs to favor $foo.bar
>over $foo.Bar, then i think we should tweak the uberspect to put that
>first in the search order.  because i believe $foo.Bar is technically
>the faster (though i don't think it matters with caching on) option.

+1.

	Regards
		Henning

-- 
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen          INTERMETA GmbH
hps@intermeta.de        +49 9131 50 654 0   http://www.intermeta.de/

RedHat Certified Engineer -- Jakarta Turbine Development  -- hero for hire
   Linux, Java, perl, Solaris -- Consulting, Training, Development

		      4 - 8 - 15 - 16 - 23 - 42

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Re: Language Lawyer question (was: Re: syntax issue)

Posted by Nathan Bubna <nb...@gmail.com>.
sounds fine to me.   but if we change all the docs to favor $foo.bar
over $foo.Bar, then i think we should tweak the uberspect to put that
first in the search order.  because i believe $foo.Bar is technically
the faster (though i don't think it matters with caching on) option.

On 8/25/05, Will Glass-Husain <wg...@forio.com> wrote:
> No, I disagree.  Velocity should be more accepting rather than less.  (I've
> previously argued we should make the entire language case-insensitive).
> Many template writers aren't programmers - let's keep things simple.
> 
> I'd be up for changing all the docs and examples to the lower case syntax
> though if someone wants to make a pass at it.
> 
> Best,
> WILL
> 
> 
> 
> 
> ----- Original Message -----
> From: "Henning P. Schmiedehausen" <hp...@intermeta.de>
> Newsgroups: hometree.jakarta.velocity.users
> To: <ve...@jakarta.apache.org>
> Sent: Thursday, August 25, 2005 9:25 AM
> Subject: Language Lawyer question (was: Re: syntax issue)
> 
> 
> > Nathan Bubna <nb...@gmail.com> writes:
> >
> >>barely) and specificity.  Shorthand notation ($bar.foo or $bar.Foo) is
> >
> > Personally, I'd like to get $bar.Foo deprecated in favour of $bar.foo
> >
> > Question for the velocity language lawyers ;-) :
> >
> > --- cut ---
> > public class TestBean {
> >    private String baz = null;
> >    private String foo = null;
> >
> >    public String getBAZ() {
> >        return baz;
> >    }
> >
> >    public void setBAZ(String baz) {
> >        this.baz = baz;
> >    }
> >
> >    public String getFoo() {
> >        return foo;
> >    }
> >
> >    public void setFoo(String foo) {
> >        this.foo = foo;
> >    }
> > }
> > --- cut ---
> >
> > $test is an instance of the test bean above.
> > --- cut ---
> > $test.setBAZ("ok")
> > $test.setFoo("ok")
> >
> > $test.getbaz()
> > $test.getBaz()
> > $test.getBAZ()
> > $test.getbAZ()
> >
> > $test.baz
> > $test.Baz
> > $test.BAZ
> > $test.bAZ
> >
> > $test.getfoo()
> > $test.getFoo()
> > $test.getFOO()
> > $test.getfoo()
> >
> > $test.foo
> > $test.Foo
> > $test.FOO
> > $test.foo
> > --- cut ---
> >
> > a: What is the outcome? (without trying it out or peeking below ... ;-) )
> > b: Did it surprise you?
> > c: Is this according to the Sun bean Specs?
> >
> > I'd love to see the Velocity introspector to move closer to the actual
> > bean spec (though it probably predates it...). Which means IMHO that
> > $foo.bar and $foo.getBar() are equivalent and behave the same.
> >
> > Regards
> > Henning
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > --- cut ---
> > $test.getbaz()
> > $test.getBaz()
> > ok
> > $test.getbAZ()
> >
> > $test.baz
> > $test.Baz
> > ok
> > ok
> >
> > $test.getfoo()
> > ok
> > $test.getFOO()
> > $test.getfOO()
> >
> > ok
> > ok
> > $test.FOO
> > $test.fOO
> > --- cut ---
> > --
> > Dipl.-Inf. (Univ.) Henning P. Schmiedehausen          INTERMETA GmbH
> > hps@intermeta.de        +49 9131 50 654 0   http://www.intermeta.de/
> >
> > RedHat Certified Engineer -- Jakarta Turbine Development  -- hero for hire
> >   Linux, Java, perl, Solaris -- Consulting, Training, Development
> >
> >       4 - 8 - 15 - 16 - 23 - 42
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Re: Language Lawyer question (was: Re: syntax issue)

Posted by Will Glass-Husain <wg...@forio.com>.
No, I disagree.  Velocity should be more accepting rather than less.  (I've 
previously argued we should make the entire language case-insensitive). 
Many template writers aren't programmers - let's keep things simple.

I'd be up for changing all the docs and examples to the lower case syntax 
though if someone wants to make a pass at it.

Best,
WILL




----- Original Message ----- 
From: "Henning P. Schmiedehausen" <hp...@intermeta.de>
Newsgroups: hometree.jakarta.velocity.users
To: <ve...@jakarta.apache.org>
Sent: Thursday, August 25, 2005 9:25 AM
Subject: Language Lawyer question (was: Re: syntax issue)


> Nathan Bubna <nb...@gmail.com> writes:
>
>>barely) and specificity.  Shorthand notation ($bar.foo or $bar.Foo) is
>
> Personally, I'd like to get $bar.Foo deprecated in favour of $bar.foo
>
> Question for the velocity language lawyers ;-) :
>
> --- cut --- 
> public class TestBean {
>    private String baz = null;
>    private String foo = null;
>
>    public String getBAZ() {
>        return baz;
>    }
>
>    public void setBAZ(String baz) {
>        this.baz = baz;
>    }
>
>    public String getFoo() {
>        return foo;
>    }
>
>    public void setFoo(String foo) {
>        this.foo = foo;
>    }
> }
> --- cut --- 
>
> $test is an instance of the test bean above.
> --- cut --- 
> $test.setBAZ("ok")
> $test.setFoo("ok")
>
> $test.getbaz()
> $test.getBaz()
> $test.getBAZ()
> $test.getbAZ()
>
> $test.baz
> $test.Baz
> $test.BAZ
> $test.bAZ
>
> $test.getfoo()
> $test.getFoo()
> $test.getFOO()
> $test.getfoo()
>
> $test.foo
> $test.Foo
> $test.FOO
> $test.foo
> --- cut --- 
>
> a: What is the outcome? (without trying it out or peeking below ... ;-) )
> b: Did it surprise you?
> c: Is this according to the Sun bean Specs?
>
> I'd love to see the Velocity introspector to move closer to the actual
> bean spec (though it probably predates it...). Which means IMHO that
> $foo.bar and $foo.getBar() are equivalent and behave the same.
>
> Regards
> Henning
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> --- cut ---
> $test.getbaz()
> $test.getBaz()
> ok
> $test.getbAZ()
>
> $test.baz
> $test.Baz
> ok
> ok
>
> $test.getfoo()
> ok
> $test.getFOO()
> $test.getfOO()
>
> ok
> ok
> $test.FOO
> $test.fOO
> --- cut ---
> -- 
> Dipl.-Inf. (Univ.) Henning P. Schmiedehausen          INTERMETA GmbH
> hps@intermeta.de        +49 9131 50 654 0   http://www.intermeta.de/
>
> RedHat Certified Engineer -- Jakarta Turbine Development  -- hero for hire
>   Linux, Java, perl, Solaris -- Consulting, Training, Development
>
>       4 - 8 - 15 - 16 - 23 - 42
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Re: Language Lawyer question (was: Re: syntax issue)

Posted by "Henning P. Schmiedehausen" <hp...@intermeta.de>.
Nathan Bubna <nb...@gmail.com> writes:

[...]
>> $test.foo
>> $test.Foo
>> $test.FOO
>> $test.foo
>> --- cut ---

Should've been $test.fOO, right.

[..]

>> b: Did it surprise you?

>umm.  i think *you* are wrong in your results.  there is no way that
>the last value ($test.foo) came out as $test.fOO!  :)  but assuming
>you were right and typed $test.fOO for the last input value (which is
>what i presume you meant, then the answer is "No, I wasn't at all
>surprised.  The rules for Velocity are quite simple.

You're correct. 

	Regards
		Henning

-- 
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen          INTERMETA GmbH
hps@intermeta.de        +49 9131 50 654 0   http://www.intermeta.de/

RedHat Certified Engineer -- Jakarta Turbine Development  -- hero for hire
   Linux, Java, perl, Solaris -- Consulting, Training, Development

		      4 - 8 - 15 - 16 - 23 - 42

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Re: Language Lawyer question (was: Re: syntax issue)

Posted by Nathan Bubna <nb...@gmail.com>.
On 8/25/05, Henning P. Schmiedehausen <hp...@intermeta.de> wrote:
> Nathan Bubna <nb...@gmail.com> writes:
> 
> >barely) and specificity.  Shorthand notation ($bar.foo or $bar.Foo) is
> 
> Personally, I'd like to get $bar.Foo deprecated in favour of $bar.foo
> 
> Question for the velocity language lawyers ;-) :
> 
> --- cut ---
> public class TestBean {
>     private String baz = null;
>     private String foo = null;
> 
>     public String getBAZ() {
>         return baz;
>     }
> 
>     public void setBAZ(String baz) {
>         this.baz = baz;
>     }
> 
>     public String getFoo() {
>         return foo;
>     }
> 
>     public void setFoo(String foo) {
>         this.foo = foo;
>     }
> }
> --- cut ---
> 
> $test is an instance of the test bean above.
> --- cut ---
> $test.setBAZ("ok")
> $test.setFoo("ok")
> 
> $test.getbaz()
> $test.getBaz()
> $test.getBAZ()
> $test.getbAZ()
> 
> $test.baz
> $test.Baz
> $test.BAZ
> $test.bAZ
> 
> $test.getfoo()
> $test.getFoo()
> $test.getFOO()
> $test.getfoo()
> 
> $test.foo
> $test.Foo
> $test.FOO
> $test.foo
> --- cut ---
> 
> a: What is the outcome? (without trying it out or peeking below ... ;-) )


--- cut ---
$test.setBAZ("ok")
$test.setFoo("ok")

$test.getbaz()
$test.getBaz()
ok
ok

$test.baz
$test.Baz
ok
ok

$test.getfoo()
ok
$test.getFOO()
$test.getfoo()

ok
ok
$test.FOO
ok
--- cut ---

> b: Did it surprise you?

umm.  i think *you* are wrong in your results.  there is no way that
the last value ($test.foo) came out as $test.fOO!  :)  but assuming
you were right and typed $test.fOO for the last input value (which is
what i presume you meant, then the answer is "No, I wasn't at all
surprised.  The rules for Velocity are quite simple.

> c: Is this according to the Sun bean Specs?

i neither know, nor care very much.

> I'd love to see the Velocity introspector to move closer to the actual
> bean spec (though it probably predates it...). Which means IMHO that
> $foo.bar and $foo.getBar() are equivalent and behave the same.

umm.  $foo.bar and $foo.getBar() *are* equivalent in Velocity.

>         Regards
>                 Henning
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> --- cut ---
> $test.getbaz()
> $test.getBaz()
> ok
> $test.getbAZ()
> 
> $test.baz
> $test.Baz
> ok
> ok
> 
> $test.getfoo()
> ok
> $test.getFOO()
> $test.getfOO()
> 
> ok
> ok
> $test.FOO
> $test.fOO
> --- cut ---
> --
> Dipl.-Inf. (Univ.) Henning P. Schmiedehausen          INTERMETA GmbH
> hps@intermeta.de        +49 9131 50 654 0   http://www.intermeta.de/
> 
> RedHat Certified Engineer -- Jakarta Turbine Development  -- hero for hire
>    Linux, Java, perl, Solaris -- Consulting, Training, Development
> 
>                       4 - 8 - 15 - 16 - 23 - 42
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Language Lawyer question (was: Re: syntax issue)

Posted by "Henning P. Schmiedehausen" <hp...@intermeta.de>.
Nathan Bubna <nb...@gmail.com> writes:

>barely) and specificity.  Shorthand notation ($bar.foo or $bar.Foo) is

Personally, I'd like to get $bar.Foo deprecated in favour of $bar.foo

Question for the velocity language lawyers ;-) :

--- cut --- 
public class TestBean {
    private String baz = null;
    private String foo = null;

    public String getBAZ() {
        return baz;
    }

    public void setBAZ(String baz) {
        this.baz = baz;
    }

    public String getFoo() {
        return foo;
    }

    public void setFoo(String foo) {
        this.foo = foo;
    }
}
--- cut --- 

$test is an instance of the test bean above.
--- cut --- 
$test.setBAZ("ok")
$test.setFoo("ok")

$test.getbaz()
$test.getBaz()
$test.getBAZ()
$test.getbAZ()

$test.baz
$test.Baz
$test.BAZ
$test.bAZ

$test.getfoo()
$test.getFoo()
$test.getFOO()
$test.getfoo()

$test.foo
$test.Foo
$test.FOO
$test.foo
--- cut --- 

a: What is the outcome? (without trying it out or peeking below ... ;-) )
b: Did it surprise you? 
c: Is this according to the Sun bean Specs?

I'd love to see the Velocity introspector to move closer to the actual
bean spec (though it probably predates it...). Which means IMHO that
$foo.bar and $foo.getBar() are equivalent and behave the same.

	Regards
		Henning















--- cut ---
$test.getbaz()
$test.getBaz()
ok
$test.getbAZ()

$test.baz
$test.Baz
ok
ok

$test.getfoo()
ok
$test.getFOO()
$test.getfOO()

ok
ok
$test.FOO
$test.fOO
--- cut ---
-- 
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen          INTERMETA GmbH
hps@intermeta.de        +49 9131 50 654 0   http://www.intermeta.de/

RedHat Certified Engineer -- Jakarta Turbine Development  -- hero for hire
   Linux, Java, perl, Solaris -- Consulting, Training, Development

		      4 - 8 - 15 - 16 - 23 - 42

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Re: syntax issue

Posted by Nathan Bubna <nb...@gmail.com>.
None of these will be deprecated and preference is a matter of both
taste and use.  Formal notation (${bar.foo} or ${bar.getFoo()}) is
good for separating your variables from the content next to them. 
Typing out the whole method ($bar.getFoo()) is good for speed (though
barely) and specificity.  Shorthand notation ($bar.foo or $bar.Foo) is
less keystrokes, more readable, and more flexible.  Choose them
depending on your needs and goals.

On 8/22/05, Bayarsaikhan VOLODYA <ba...@gmail.com> wrote:
> Hi all,
> 
> which syntax is more suitable (or will not be deprecated) preferrable than
> the other one?
> 
> ${name.firstName}
> or
> $name.firstName
> or
> $name.getFirstName()
> 
> thanks in advance.
> 
> --
> Bayarsaikhan VOLODYA
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Re: syntax issue

Posted by Will Glass-Husain <wg...@forio.com>.
Personally,

$name.firstName

has always seemed the most readable to me.  But do what seems right to you. 
The flexibility to access properties or methods is one of Velocity's 
strengths.

WILL

----- Original Message ----- 
From: "Bayarsaikhan VOLODYA" <ba...@gmail.com>
To: "Velocity Users List" <ve...@jakarta.apache.org>
Sent: Monday, August 22, 2005 4:34 AM
Subject: syntax issue


Hi all,

which syntax is more suitable (or will not be deprecated) preferrable than
the other one?

${name.firstName}
or
$name.firstName
or
$name.getFirstName()

thanks in advance.

-- 
Bayarsaikhan VOLODYA


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org