It's called backward compatibility, which is also very important, perhaps
more so than consistency, at least for the Ant project. --DD

>From Project.java:
    /**
     * Adds a reference to the project.
     *
     * @param name The name of the reference.
     *        Must not be <code>null</code>.
     * @param value The value of the reference.
     *        Must not be <code>null</code>.
     */
    public void addReference(String name, Object value) {
        synchronized (references) {
            Object old = references.get(name);
            if (old == value) {
                // no warning, this is not changing anything
                return;
            }
// vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
            if (old != null && !(old instanceof UnknownElement)) {
                log("Overriding previous definition of reference to "
                    + name, MSG_WARN);
            }
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            String valueAsString = "";
            try {
                valueAsString = value.toString();
            } catch (Throwable t) {
                log("Caught exception (" + t.getClass().getName() +")"
                    + " while expanding " + name + ": " + t.getMessage(),
                    MSG_WARN);
            }
            log("Adding reference: " + name + " -> " + valueAsString,
                MSG_DEBUG);
            references.put(name, value);
        }
    }

-----Original Message-----
From: Steve Cohen [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, February 26, 2003 1:19 PM
To: Ant Users List
Subject: RE: <property refid=> question

So I could initially define it empty and then define it otherwise as
needed.  

So it works the opposite as properties.  With properties, you define it
as needed (or not) first, and then if you need a default value, attempt
to redefine.  If already defined, the redefine does not take place.

But with references the "default" must be defined first.

This sort of inconsistency is what sometimes drives me crazy.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to