[stringtemplate-interest] "rest" and template recursion

Mark Wharton contact at moonbase.com.au
Sat May 31 02:24:08 PDT 2008


Hi Zen,

Actually there is a "Trunc" method in the ASTExpr class (ASTExpr.java) which looks - almost - like what you're asking for:

	/** Return all but the last element.  trunc(x)=null if x is single-valued. */
	public Object trunc(Object attribute) {
		return null; // not impl.
	}

Maybe it can be implemented while "rest" is worked out?

Cheers,

Mark

On Sat, 31 May 2008 16:30:39 +1000, "Zenaan Harkness" <zen at freedbms.net> said:
> On Fri, May 30, 2008 at 11:05:22PM -0700, Sasha Crosland wrote:
> > Thanks for the explanation, Terence.  A side-effect-free rest() does seem
> > more in the spirit of StringTemplate, doesn't it?  I vote yes, for what it's
> > worth.
> > 
> > But would you actually need to make a copy of the list data?  If lists are
> > immutable within a template, then couldn't you easily return a lightweight
> > view of the sublist that reads through to the original list, just like with
> > an iterator?
> 
> Vote thirded.
> 
> Recursion ought to Just Work (TM).
> 
> I additionally vote for an addition to first,last,rest to fill the gap,
> perhaps "front" (all but last).
> 
> Lightweight container wrapper is definitely the go here.
> ArrayList.clone(), or Collection.clone() should do what's needed.
> 
> zen
> 
> -- 
> Homepage: www.SoulSound.net -- Free Australia: www.UPMART.org
> Please respect the confidentiality of this email as sensibly warranted.
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org:8080/mailman/listinfo/stringtemplate-interest
Mark Wharton
+ 8190 9834 2559
contact at moonbase.com.au



More information about the stringtemplate-interest mailing list