Re: RAD vs. performance



Jon Harrop wrote:
Curtis W wrote:
Jon Harrop wrote:
Curtis W wrote:
Is 'a * 'b a "specific type"? It is more specific than 'a but is still
polymorphic.

I was referring to types like "int|float".

That is equivalent to something like:

<add: 'a -> 'a -> 'a; ..> as 'a

How would that routine look to be inferred in such a way?

Something like this:

# let sum h t = List.fold_left h#add h t;;
val sum : (< add : 'a -> 'b -> 'a; .. > as 'a) -> 'b list -> 'a = <fun>
What were we discussing again?

No, I wanted the specific type "expr".

"expr" is a general type, especially considering that it's a variant in
your example.

What exactly do you mean by that? It is not polymorphic.
I meant general in the sense that it isn't a single type, but rather a
variant. That would automatically be inferred in my language and while
OCaml can do it, it requires that you reimplement the standard library
and builtin types as objects in order to do so.

I'd be willing to bet that the
number of cases where you don't want to artificially constrict a type
is much higher than the number of cases where you do.

Quite the opposite in OCaml for union types.
Unlikely. Really the only reason to artificially constrain a type is
for performance reasons given that all compatible types would work,
which I've already shown to be 1) not an issue with a decent compiler
and 2) premature optimisation.

This can be most
apparent in library code, but can also be seen in normal application
code.

Yes. Polymorphic variants (inferred unions) are rarely used and ordinary
variants (declared) are commonly used. The opposite is probably true for
product types: tuples (inferred) are probably more common than records
(which must be declared in OCaml).
The fact that variants are used so much proves my point: in my language
the need to declare such things is completely gone. Add a new type?
That's fine, don't need to change a thing. Add a new function, that's
fine, too, don't need to change a thing.

the type was
general, not specific, in that it had multiple "subtypes," if you will.

What do you mean by subtypes? It is a union type (an expression is either a
number, a variable, an addition or a multiplication).
Subtypes as in the types in the union type: a number, a variable, an
addition or a multiplication.

At least, that's how I've interpreted how you've used the words before.

The declared "expr" type was monomorphic. It was recursive, perhaps that is
what you're referring to?
I was talking about your usage of the words "general" and "specific" in
terms of types.

That's exactly the same as the polymorphic variant example. Except, in
the absence of pattern matching, you'll require a lot more code.

No, it's not. If I were to put your routine in a library, for example,
and wanted to extend it with a new type I wouldn't be able to without
modifying it.

No. Read Jacques Garrigue's paper on code reuse using polymorphic variants.
Basically, they provide OO-style multiple inheritance with the brevity of
ordinary variants.
That paper describes solving the expression problem, which first of all
I'd already said:
Disregarding the expression problem,
In order to use any of the eval routines in another module without
having that module "know" about them is to pass them as arguments, at
which point you're reimplementing classes.

Disregarding the expression problem, the only way you'd
be able to simplify new types would be to have them pass in their
simplify function, at which point you're basically reimplementing a
class.

Exactly, yes. Although this is a cool feature for variants, it is typically
considered too costly in terms of weakening the static type system (too
much inference).
What do you mean by "cool feature for variants"? By the way, I might
add that in my language, classes are essentially an easy syntax for
automatically passing functions around with variables. Nothing more,
nothing less.

People spent many more years working with Fortran and they have enough
such errors to alter the language and make it taboo.

Odd, people have spent many years working with Python and I've never
seen a "strict" mode for it, nor have I seen anyone complain about it.

Two of the people that I work with were discussing the prospect of writing a
statically typed Python-compatible language. Programs written in this
subset could benefit from static typing without affecting interoperability
with dynamic code.
I suspect interoperability would be the hardest part.

How big is epsilon? The more calculations you do, the bigger the error,
the bigger epsilon needs to be. You end up needing to track errors, which
is what interval arithmetic does. However, that still can't give you an
eq/neq answer - it can only give you a fuzzy eq/maybe/neq.

You can always change the epsilon--after all, it could easily be a
member variable of floats, which can be optimised out if not used, of
course.

That's a little too ad hoc to be useful.
I fail to see your reasoning.

Really? My net connection costs about $30 per month.

Yeah, well! You don't have a monopoly on cable internet over their :-(

Pretty much. Telephony used to be nationalised and, now that it is
privatized, almost all companies that aren't BT are simply reselling BT
products rather than creating their own.
Meh. Either way, my country saved you guys during WWII. Either that, or
depending on what country you're from, we also kicked your buts.

.



Relevant Pages

  • Re: [all] Modern Development
    ... there is no API that will meet the needs of all variants. ... language. ... Fixed-size backpack is a subset of variable-size backpack. ...
    (rec.games.roguelike.angband)
  • Re: thought: C, dynamic types, and closures
    ... Adding closures, dynamic typing, and garbage collection to C _and_ ... these would exist before, but as compiler builtins, which would be renamed ... this leads to a generally simpler implementation (very likely, variants ... and have many of the same operations as my last script language, ...
    (comp.lang.misc)
  • thought: C, dynamic types, and closures
    ... these would exist before, but as compiler builtins, which would be renamed ... this leads to a generally simpler implementation (very likely, variants ... seperate dynamic-typed stack). ... and have many of the same operations as my last script language, ...
    (comp.lang.misc)
  • Re: RAD vs. performance
    ... I was referring to types like "int|float". ... How would that routine look to be inferred in such a way? ... Polymorphic variants are rarely used and ordinary ... general, not specific, in that it had multiple "subtypes," if you will. ...
    (comp.lang.misc)
  • Re: Arrays passed as parameters from VB ActiveX DLL
    ... > I need to call a VB function that passes out variants that are in fact ... > arrays. ... but don't know how to declare the array ... I have tried using a SAFEARRAY, ...
    (microsoft.public.vc.language)

Loading