doneitems

These are previous ToDo and Wishlist items that have been implemented.


InheritanceNonintuitive


One-line #def syntax

I'd like to be able to write:

#def title = 'a title of some sort'

Or even:

#def title = $htTitle

#attr provides this syntax, but is semantically different from #def.

-- IanBicking - 07 Nov 2001

#attr provides this already. If it doesn't suit your needs use #settings. #def is for defining methods, period.

-- TavisRudd - 07 Nov 2001

#def title = $htTitle is a method. You couldn't meaningfully do that with #attr. I'm not proposing that #def should create anything other than methods. But there's nothing (except the current syntax) stopping it from creating one-line methods.

Specifically, I find this awkward:

#def title
A title#slurp
#end def

When compared to this:

#def title = 'A title'

-- IanBicking - 07 Nov 2001

If the body is a constant, you don't lost anything with #attr because the $placeholder will be identical anyway thanks to autocalling. If the body contains $placeholders and/or #directives, I think it _should_ be multi-line to reinforce this fact, and it shouldn't be on the right side of an equal sign.

-- MikeOrr - 08 Nov 2001

Yes, you do lose something -- methods are semantically different from attributes. I expect to use these interfaces outside of Cheetah, where I don't have autocalling. I'd rather have everything be a #def, because that gives me a consistent interface. -- IanBicking - 09 Nov 2001

OK. I agree now. Let's add it before 1.0.

-- TavisRudd - 07 Dec 2001

It was added to Cheetah 0.9.9. The syntax and semantics are different: see the User's Guide. The separator is a colon (:), and the right side is Cheetah syntax (like in a multi-line #def), not an expression. The change was also implemented in #block.

-- MikeOrr - 16 Dec 2001