users@el-spec.java.net

[el-spec users] [jsr341-experts] Re: Identifiers with namespace

From: Mark Thomas <markt_at_apache.org>
Date: Tue, 14 Aug 2012 22:18:48 +0100

On 10/08/2012 23:13, Kin-man Chung wrote:
> There are some feedbacks from the public review. One of them is a
> request for adding namespaces to idendifiers.
>
> I know CDI has been using a.b.c.d as namespaced identifiers, but that
> creates ambiguities in both the syntax and semantics.
>
> Since we already have namespace for functions, its only logical to use
> the same syntax and notation for identifiers. For example,
>
> ns:obj.foo denotes the property foo of an object with a namespace ns.
>
> Obviously, namespaces are only allowed for top level objections.
>
> Note that there is an ambiguity with the ?: operator.
>
> What does a? b: d : e mean, a? (b:c): e or a? b: (c: d)?
>
> I think we already have similar problem with namespaced function in :?
> operators, so maybe we can reosslve this similarily. Let think about
> this more.

Could we just define a precedence order and require use of () to change it?

> How can we fit this into our ELResolver? When an
> ELResolver.getValue(Object base, Object property) is invoked, property
> is the identifier, as before, but instead of a null base, we can
> encapsulate the namespace in "base". So the code will be like
>
> Object getValue(ELContext context, Object base, Object property) {
> String namespace = null;
> if (base != null && base instance ELNameSpace)
> namespace = ((ELNameSpace)base).getNameSpace();
> }
> ...
>
> What do you think?

Seems like a bit of a hack but I don't have any better ideas right now.

Mark