AW: AW: [stringtemplate-interest] Problems with List and Hashesrevisited

Dreyer Ulf (CR/APA3) Ulf.Dreyer at de.bosch.com
Thu Jun 1 00:16:09 PDT 2006


Hi!
 
> > RecursiveOut(Daten) ::= << $Daten:RecursiveOut();separator=","$ >>
> > As both classes in my data-structure (AttributeHash and 
> AttributeList)
> > are IEnumerable it should strip away one layer at a time, 
> shouldn't  
> > it?
> 
> You are saying
> 
> f(x) { f(x); }
> 
> here.

Of course this does not have any output but 
I assumed because of attribute application and the fact
that Daten is always IEnumerable it would "shave off"
one layer per call. (as it is essentially 
a  foreach( foreach (foreach))) construct)

Assume List of Lists for simplicity:

[A,B,C]
A=[1,2,3]
1=[I,II,III]

I would assume, that I get
A
1
I II III
2
[...]

I suppose the last layer (of Strings) was the 
real problem as the above template does not differenciate
between enumerations and values.


Anyway current implementation works as inteded:

TreeOut(Daten) ::= <<
$if(Daten.Length)$
String: $Daten$
$else$
$Daten.DebugName$
    $Daten:TreeOut();separator="\n"$
$endif$
>>

Daten can be List, Hash or String
and as Kunle pointed out (Big thanks - I hadn't thought of that)
List and Hash have .Count
and String has .Length and therefore can be distinguished from
inside a template.
Mind you this dirty hack is not meant for real template programming
but for debugging purposes. ;)


I think it will take a while to really know all the finer points
of ST but I DO like it. (In spite of it doing what I code - not what
I WANT)  *G*


Ulf


More information about the stringtemplate-interest mailing list