On Wednesday 29 August 2007, Raymond Bosman wrote:
> On Wednesday 29 August 2007 17:08, Frederik Holljen wrote:
> > On Wednesday 29 August 2007, Raymond Bosman wrote:
> > > > > Personally, I compare each template with a function. The {use}
> > > > > variables are the function arguments. I think all the solutions we
> > > > > proposed are used in one or another way in a programming language.
> > > >
> > > > Yes, this is what I do as well. Can you give me examples of the
> > > > original three proposals in programming languages? The last two have
> > > > parallels to programming languages except you don't know in which
> > > > context your template will be called and so don't know which globals
> > > > will be available....
> > >
> > > Solution 1, 2, and 3 can be seen as a nested function definition.
> > >
> > > def template_p(a,b,c,d,e,f):
> > >
> > >     def template_q(a):
> > >         print a
> > >
> > >         def template_r():
> > >             print b
> > >             print c
> > >
> > >
> > > Function template_p is called from the user application; thus has all
> > > variables. template_p does an {include "template_q" send a}. That
> > > template includes template_r. All those sub-includes have access to the
> > > variables from the top function scope.
> >
> > This is not the same since the sub methods are created within the context
> > of each other., and the variables passed implicitly are set from this
> > context. Also, the methods are only available in the context in which
> > they were created. This is not the case with the template definitions,
> > they are just loose "function" definitions which can be called from
> > anywhere.
>
> Okay, it is not *exactly* the same. But think about the concept.  The next
> example comes closer?
>
> def user_application_send(a,b,c,d,e,f):
>      def template_q(a):
>          print a
>          template_r() # {include "r"}
>
>      def template_r():
>          print b
>          print c
It's a bit closer since you can call a sub-method slightly out of context. Can 
you actually do that in python? I'm not impressed... :D

It makes me think about another option though, and that is to actually add 
contexts to our templates. If you say which context the template belongs to 
then you can start doing stuff like the above. A context can be as advanced 
as you like it to be.. it can be a string.. to a full blown "template class" 
declaration with templates (functions..).

Freddy San


-- 
Components mailing list
Components@lists.ez.no
http://lists.ez.no/mailman/listinfo/components

Reply via email to