[Novalug] Macro preprocessing
plarsen at famlarsen.homelinux.com
Tue Jun 29 11:41:10 EDT 2010
On Fri, 2010-06-25 at 21:53 -0400, James Ewing Cottrell 3rd wrote:
> On 6/25/2010 1:33 PM, Peter Larsen wrote:
> > On Fri, 2010-06-18 at 20:44 -0700, Jim Ide wrote:
First off - sorry for the very late reply to this one.
> >> XML and XSLT come the closest to what I want, except that the
> >> input text must be valid XML, and the XSLT template syntax
> >> is cluttered, clunky, frustrating, and gives me a headache.
> >> It also does not support parameter type checking.
> > I'll grab this one since it's sorta in the area I've been for about a
> > decade now. Quickly though, in regards to named parameters that's
> > solvable through overloading.
> Using overloading (and BTW, who does that besides C++ and Java?) to
> provide named parameters is Limited at Best and Insane at Worst.
Absolutely disagree. I think we have a small miscommunication here. Let
me try to clarify.
> Overloading only works when arguments differ by Type.
And the number of parameters. This is key.
> Thus, a date
> scanning that appeals to folks on both side of the Pond (e.g. we write
> Valentine's Day as 2/14 while Amy (note the cute Doctor Who reference)
> writes it as 14/2.
Depending on your platform, that really makes no difference. With both
Java, C++ and PL/SQL (that uses overloading) "Date" is a separate
object/type. It doesn't matter which timezone the date is in, or how
it's represented externally - it's the same object being used - it's one
object, no more, no less.
> Both are ints.
No. They're objects (and in Oracle's case they're full decimal numbers).
How the objects are represented doesn't matter. To the language Date,
Calendar, Person etc. are all different objects and hence no conflict
for the compiler to choose the right overloaded function/method. Even if
the objects would happen to have the exact same number/type of
attributes and methods, the objects are still not the same and
differentiable to the compiler.
> And unless you want to make one a
> double, or encode the month by biasing it by 100 or making it negative,
> well, the language won't help you there.
You're making the mistake of thinking primitive types. We rarely use
them with OOP languages. In particular when it comes to something as
complex as a date/time.
> Now it would be possible to appease both the Civilians (who write Feb
> 14) and the Military (who write 14 Feb) by providing two overloaded fns,
> scan_date(int, String) vs scan_date(String, int) because the two are of
> different types.
Sure it is. The user presentation of a date has no bearing on the
internal object representation. A date is a date is a date. Even Julian
vs. Gregorian dates are represented by the same object. They point to a
"point in time". That's it.
> Add a third argument, and you are up to 6 different signature. Add a
> fourth, and you are up to 24. And it is more or less at the 4th argument
> where people's memory starts to fail them.
It's still one argument. No more no less.
To clarify, what I was referring to was context. Methods are usually
called within context and by overloading, I simply specify the known
contexts. That way, I know when called what values SHOULD be there, and
if the context changes the way a method acts, it's easily shown and
validated by using overloading. This means, that if I have a method with
30 possible parameters, that I don't make 30! (factor 30) different
overloaded methods. I make only the number that makes sense from a
business sense. So for instance, if the method is adding a new employee,
I may make two overloaded methods, one for creating an employee through
the normal HR interface and one that deals with migrating from another
HR system. In one case, I have a reduced set of values and even special
validation rules, in the other I need to more or less take the data raw
and insert it - ie. even creating employees who are no longer with the
company. But it's still a matter of adding an employee. I hope that
clarifies what I meant.
> No, my friend, I don't believe that Function Overloading was ever
> intended to provide Named Arguments; none of the books I have read ever
> seem to make that case, altho you might find it in a book reviewed by
> Leonard Pinth-Garnell (google him if you need to).
Hopefully I made myself better understood above. You need to realize
that only Object oriented languages (to my knowledge) uses overloading.
And hence, talking primitive scalar types has no place here.
Wise words of the day:
The grand leap of the whale up the Fall of Niagara is esteemed, by all
who have seen it, as one of the finest spectacles in nature.
-- Benjamin Franklin.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 198 bytes
Desc: This is a digitally signed message part
Url : http://calypso.tux.org/pipermail/novalug/attachments/20100629/a3376632/attachment.bin
More information about the Novalug