"Bill Page" <[EMAIL PROTECTED]> writes:

| On Thu, May 15, 2008 at 5:57 AM, Gabriel Dos Reis wrote:
| > Bill Page writes:
| > |
| > | So to summarize, the pattern is something like this:
| > |
| > |     if cond then
| > |         x := 1
| > |     else
| > |         x := 2.3
| > |     ...
| > |
| > | If this is allowed by the compiler, the question is what is the
| > | type of 'x' outside the scope of the 'then' and 'else' clauses?
| > ...
| > | If the scope of 'x' is intended to be global, then the type of
| > 'x' must be a Union.
| >
| > Union is one possiblity, another is a `real' overload.
| >
| 
| I agree with Waldek (in a different thread). I think the original
| developers of Axiom explicitly decided against variable name
| overloading. Do you know of any mainstream language where this is a
| common programming paradigm?

I mention the `real' overload solution to counter the assertion
*must be a Union*.  The `must' does not follow.

As for a language that has overload on variable, well have a look at
Perl.  It certainly is more mainstream than Spad.

Now, before you think I'm arguing for overload of variables, let me
stress again that I mention it to stress the fact that the `must' does
not follow.

On another tone, it appears odd to me tha one would argue for 
overloaded constants (which OpenAxiom supports, as well as other
Axioms in one form or another), and at the same time argue against
overload of variables?  What is the fundamental reason?

| One of the design goals of a static strongly typed language is to
| ensure type correctness by associating static types with variables.
| Allowing variable overloading by type seems to defeat this purpose -

How?  I mean, constants are overloaded, why isn't that also defating
the purpose -- assuming that is the case for variables?

| especially when it is combined with implicit typing rules.

How?  Please be more specific. 

| Overloading constants (including functions) however is obviously very
| convenient and supported in all flavors plus Aldor.

But, why isn't that also `defeating the purpose of static typing'?
Just because `it is claimed to be convenient'?  That cannot be the
reason. 

| > |
| > |     x:Union(Integer,Float)
| > |     if cond then
| > |         x := 1
| > |     else
| > |         x := 2.3
| > |
| > | I do not see anything wrong with this proposal. It is compatible
| > | with only a minor change to the existing library code
| >
| > I'm not sure the change is minor:  Union in Spad are different from
| > unions in C, in the sense that unions in Spad are tagged, which
| > means the the value representation of x is very different from that
| > of Integer or Float, and the compiler has to insert the right
| > coercions at the right places.  One would have to assess whether
| > codes are generated correctly (the `scary' part of the compiler).
| >
| 
| I have at least one example where the SPAD compiler does apparently do
| this correctly:
| 
| http://axiom-wiki.newsynthesis.org/SandBoxLexicalScope#bottom

Please read my follow up carefully to see how the compiler actually
works, and test the example I included. 

-- Gaby

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft 
Defy all challenges. Microsoft(R) Visual Studio 2008. 
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
open-axiom-devel mailing list
open-axiom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/open-axiom-devel

Reply via email to