# PDL::Types
π¦ stdpdl
## Synopsis
```none
use PDL::Types;
my $type = PDL::Type->new(6); # double
print $type->symbol, "\n"; # PDL_D
print $type->realctype, "\n"; # double
my $a = zeroes(double, 10);
```
Mirrors `PDL::Types.pm`: exports type-name subs (e.g. `byte`, `double`) that
return PDL type codes, plus uppercase aliases (`PDL_B`, `PDL_D`, etc.).
Type codes match `PdlDatatype` discriminant values exactly.
## Functions
### Other Functions
#### `type_stringify`
`PDL::Type` stringification: returns lowercase type name. `PDL::Type` is bless [`$enum`], Β»`PDL::Type`Β«.
#### `type_new`
`PDL::Type`->`new($code_or_name)` β constructor. Handles: `new($class, $code)`, `new($class, "double")`, `new($class, $existing_type)`. If the argument is already a `PDL::Type` blessed ref, pass it through.
#### `types_list`
PDL::Types::types() β return the list of all registered `PDL::Type` objects, ordered by numval. Mirrors `PDL::Types.pm`: my `@CACHED_TYPES` = map `bless([$_->{numval}, $_], 'PDL::Type')`, `@HASHES`; sub types { `@CACHED_TYPES` } Heavily used by `Test::PDL` (line 417) to iterate over available types when building per-type comparison subs; without it, every upstream test that `use`s `Test::PDL` fails at compile time.
#### `type_eq`
`PDL::Type` eq comparison β stringify both sides and compare
#### `type_ne`
`PDL::Type` ne comparison
#### `type_spaceship`
`PDL::Type` <=> numeric comparison by enum/numval. Mirrors upstream `PDL::Types.pm:578`: β<=>β => sub { `$_`[2] ? `$_`[1][0] <=> `$_`[0][0] : `$_`[0][0] <=> `$_`[1][0] }, where `$_[2]` is the swap flag.
#### `type_cmp`
`PDL::Type` cmp string comparison. Mirrors `Types.pm:575-577`.
#### `type_nomethod`
`PDL::Type` overload marker (nomethod)
#### `type_numify`
`PDL::Type` numification (0+) β returns the type code integer
#### `type_howbig`
`PDL::Type::howbig` β returns byte size of the type.
#### `type_enum`
`enum($type)` β numval, the slot-0 integer. `Types.pm:531`.
#### `type_badvalue`
`PDL::Type::badvalue` β get or set the bad value for the type.
#### `type_orig_badvalue`
`PDL::Type::orig_badvalue` β returns the ORIGINAL (hardcoded) bad value, ignoring any user-set override. Mirrors `Bad.pd`βs *default_badvalue_int (`pdl.h`βs PDL_BADVAL*\* constants). Note: this is NOT the same as xs_type_badvalue, which reflects mutations made via `byte->badvalue($v)`.
#### `type_codederef`
`PDL::Type` &{} overload β allows calling a `PDL::Type` as a code reference. `byte->()` returns Β»byteΒ« (the type name string).