That's a thought! Something like this:
/**
* Base level constructor for views.
*
* @access protected
* @constructarg public Boolean clip: If true, the resource and
children of this view
* are masked to its width and height
*/
function construct ( parent , args) {
[...]
}
Then we would reflect the @constructargs up into tag-land as "Tag
only" attributes.
Make sense?
On Dec 14, 2006, at 10:13 AM, P T Withington wrote:
The only way I can think of to reflect this in JS is to formalize
the args to LzNode.initialize to be 'keyword' arguments (a hash
table) and invent a way to document them.
Basically, `clip` is what Lisp would call an [init-keyword](http://
www.opendylan.org/books/dpg/db_54.html).
On 2006-12-14, at 12:45 EST, Jim Grandy wrote:
Thanks for the reply. I guess what I'm really trying to understand
is:
- the schema mentions an lzx attribute named 'clip' with a 'final'
modifier.
- the LFC only mentions a setter for 'clip', with no mention of a
JS field 'clip'
I'd like to understand how to model this in the refguide. The 3.x
refguide doesn't say that 'this.clip' will return undefined in JS,
but that's got to be the case in 4.x, based on code inspection. So
we presumably need a way of talking about a lzx attribute / js
virtual field that:
- can only be set at initialization time
- can not be read afterwards
Sounds like something like this should be modeled from an lzx pov
as an (optional) initializer.
It seems something like @clip doesn't really exist within the JS
language -- there's no way of formally expressing it.
The practical question is how to manage this within the refguide.
What I'm doing for now is looking for the "setters.foo = 'setFoo'"
pattern and generating a 'virtual' field that will be documented
as tag-only.
jim
On Dec 13, 2006, at 9:46 PM, P T Withington wrote:
On 2006-12-13, at 22:17 EST, Jim Grandy wrote:
I'm curious about the idiom of declaring a field by saying
setters.foo = 'onFoo';
I hope it would be:
setters.foo = 'setFoo';
This appears in many places in the LFC, and typically there is
no corresponding getter, cf
setters.clip = -1;
Setting the setter to -1 is additional Adam magic. I don't
recall off the top of my head what it means...
in LaszloView.lzs.
It's pretty straightforward to model this in the refguide --
look for an ASTPropertyIdentifierReference of the right form
inside a class declaration and output a field tag to suit -- but
I want to make sure I get the semantics right.
Is it right that this is a write-only field?
No. We don't have getters any more. There may be vestigial
getter support, but we don't use it. As I said to Ben a while
back, we used to pull values through getters, but now we push
them through setters. Reading being about 4-5x more prevalent,
it is more efficient this way.
We don't really have a way of making a read-only slot. We would
if we adopted the JS 2 getter/setter declarations, but this would
be a big language change as JS 2 does not allow you to have a
slot and a getter or setter with the same name. This is an area
of our language that needs clean-up.
In the case of @clip, there's no getClip() and no getters.clip =
'getClip', so I assume so. But the 3.x refguide doesn't say
this; it says:
name: clip
Usage: Tag only
Type (tag): boolean
Type (JS): Boolean
Default: false
Category: final
Does the tag compiler special case this sort of thing? If there
is no accessor in JS, how should we best handle this in the new
refguide?
Remember, some of the documentation for built-in LXC classes used
to come from the schema.
Is the existence of just a setter sufficient to suggest that
this is a Tag only field?
I think that information was all expressed in the schema.
I'm also confused that there is a setter declared in
LaszloView.lzs, but the attribute is documented as "final".
Those sound contradictory -- if it is final, why is there a
setter? Or maybe I have too strict a definition of 'final' -- I
thought it meant the value was set upon exit from the construct
method.
Essentially. What this is saying is that clip is an attribute
that you can only set on initialization.