cperl icon indicating copy to clipboard operation
cperl copied to clipboard

new compile-time typeof operator

Open rurban opened this issue 9 years ago • 6 comments

returns the type(s) at compile-time. which is string or list of strings or a list of type expressions. currently the string comes from the stash name, but in the future a type can also be an object (as in perl6), not a stash. the return value of typeof must be parsable as valid type declaration. so it should honor list context to listify | alternations.

similar to ref, which returns one run-time string, the current type. (but even if the value contains multiple types, only one is returned with ref). but typeof gets the type from the OP*, not the attached SV*.

rurban avatar Mar 30 '16 13:03 rurban

can it be indexed again i.e. in a variable declaration?

vendethiel avatar Mar 30 '16 13:03 vendethiel

@vendethiel can you reformulate your question?

rurban avatar Mar 30 '16 14:03 rurban

can you use typeof as the type of a variable?

vendethiel avatar Mar 30 '16 14:03 vendethiel

Sure, that's the idea when using it with eval.

Note that you cannot do that with ref, but ref is only for introspection and was not really carefully planned

On Mar 30, 2016 16:39, "ven" [email protected] wrote:

can you use typeof as the type of a variable?

rurban avatar Mar 31 '16 09:03 rurban

this ticket was wrongly closed

vendethiel avatar Dec 03 '17 18:12 vendethiel

Oops, thanks. I really should add support for functions also.

rurban avatar Dec 03 '17 19:12 rurban