Hi Tommi,
Thank you for the new version and for the explanation. I completely
missed the fact that a component can be called multiple times within
the same request. But now that you explained it I think that my
suggestion was not so good idea.
If a component is called multiple times with different parameters
within a single request, then the only reasonable behavior is to
initialize a variable, that has 'request' lifetime, on the first
invocation, and this is exactly how you do it in the new version.
------------------------------------------------
<html>
<head>
<title>Lifetime Test</title>
</head>
<body>
<& testid arg=97 >
<& testid arg=2 >
<& testid arg=3 >
</body>
</html>
<%def testid>
<%request>
int id(arg);
</%request>
<%args>
int arg;
</%args>
<div><$id$></div>
</%def>
------------------------------------------------
I am just afraid this will be a bit confusing. The situation is quite
similar to declaring a static variable within a C function and initializing
it with a function parameter:
------------------------------------------------
#include <stdio.h>
static foo(int i)
{
static int k = i; /* <-- Compilation error because the initializer is
not a constant */
printf("k = %d\n");
}
int main(int argc, char* argv[])
{
foo(1);
foo(2);
foo(3);
return 0;
}
------------------------------------------------
C compiler does not allow this kind of initialization, which is quite
reasonable. This is why I think the original design was more in-line
with existing languages. May be it would be better to leave things as
they were.
Thanks again for your help,
Yuri
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Register now and save $200. Hurry, offer ends at 11:59 p.m.,
Monday, April 7! Use priority code J8TLD2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Tntnet-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tntnet-general