There is type instability here, actually – the macro doesn't change
anything with regard to types.

coltype = get_vector_coltype_from_file(filename)::?
load_vector_from_hdf5_file(filename, vecname, coltype)::?

get_vector... is not type stable, which means that the entire block isn't –
there's no way to know the type of the result of this expression without
runtime values. This program would therefore be rejected by a type-safe
compiler.

The only ways around this are to (a) specify types by hand or (b) load
types from the file and generate specialised code at compile time. One is
inconvenient and the other is incomplete, which is why dynamic typing is
compelling.

On 3 January 2015 at 13:24, Ariel Keselman <[email protected]> wrote:

> it should still work if the file name is known only at runtime, consider
> the following script:
>
>
> filename = "myrandomfile"*string(rand(1:5))*".hdf"
> vecname = "myvec"
> @load_vector_from_hdf5_file(filename, vecname)
>
>
> w/o specifying types, w/o type instability, and file name decided at
> runtime.
>
> I have yet seen a convincing argumet for allowing type instabilities
> inside compiled functions.... and having this "feature" comes with a high
> cost
>

Reply via email to