incubator-flex-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Left Right <>
Subject Re: [IDEAS] Collections and Generics
Date Fri, 24 Feb 2012 18:09:07 GMT
> In other words: haXe's generics are "compile-time" checks not runtime

Same as Java, Same as C++. Of course, that doesn't mean it is good... but
the runtime wasn't built having those things in mind, because you cannot
affect the runtime, that's the only thing you can do.

But, if to be honest, generics mean something entirely different. In an
interesting way, what Adobe posted as a roadmap for AS evolution speaks
about actual generics, but, I'm guessing it will take several years before
we hear about that.

Vector in AS3, strictly speaking, isn't a generic, it's a class created
from template. This is, in a plain talk "generic", but not so per exact
definition of the term. "Generic" is usually applicable in system with
multiple dispatch, when arguments combinations are considered. I.e.

(defgeneric combine (a b)
  (:documentation "Combines strings and integers"))

(defmethod combine ((a string) (b integer))
  (concatenate 'string a (write-to-string b)))

(defmethod combine ((a integer) (b string))
  (concatenate 'string (write-to-string a) b))

would be an illustration of what it actually means. I.e. you define a
generic method, and then you define specializations of the method. Or, in
some other languages the declaration of generic itself is implied, and it
is created as soon as any methods are found.

Or, if you consider a more modern language - HaXe, then any variable, or
function argument that you did not type explicitly is generic, because it
will accept any type, which is suitable in the context you provided.

As it happens with vectors, you can only use a particular method derived
from a generic template, but you don't do generic programming per se. That
part has been done for you by the template generator.

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message