+All the callbacks are expected to return an integer, which is passed straight to the perl magic API.
+However, only the return value of the C<len> callback currently holds a meaning.
+
+=back
+
+ # A simple scalar tracer
+ my $wiz = wizard get => sub { print STDERR "got ${$_[0]}\n" },
+ set => sub { print STDERR "set to ${$_[0]}\n" },
+ free => sub { print STDERR "${$_[0]} was deleted\n" }
+
+Note that C<free> callbacks are I<never> called during global destruction, as there's no way to ensure that the wizard and the C<free> callback weren't destroyed before the variable.
+
+=cut
+
+sub wizard {
+ croak 'Wrong number of arguments for wizard()' if @_ % 2;
+ my %opts = @_;
+ my @keys = qw/data op_info get set len clear free/;
+ push @keys, 'copy' if MGf_COPY;
+ push @keys, 'dup' if MGf_DUP;
+ push @keys, 'local' if MGf_LOCAL;
+ push @keys, qw/fetch store exists delete copy_key/ if VMG_UVAR;
+ my $ret = eval { _wizard(map $opts{$_}, @keys) };
+ if (my $err = $@) {
+ $err =~ s/\sat\s+.*?\n//;
+ croak $err;
+ }
+ return $ret;
+}
+
+=head2 C<cast>
+
+ cast [$@%&*]var, $wiz, ...
+
+This function associates C<$wiz> magic to the variable supplied, without overwriting any other kind of magic.
+It returns true on success or when C<$wiz> magic is already present, and croaks on error.
+All extra arguments specified after C<$wiz> are passed to the private data constructor in C<@_[1 .. @_-1]>.
+If the variable isn't a hash, any C<uvar> callback of the wizard is safely ignored.
+
+ # Casts $wiz onto $x, and pass '1' to the data constructor.
+ my $x;
+ cast $x, $wiz, 1;
+
+The C<var> argument can be an array or hash value.
+Magic for those behaves like for any other scalar, except that it is dispelled when the entry is deleted from the container.
+For example, if you want to call C<POSIX::tzset> each time the C<'TZ'> environment variable is changed in C<%ENV>, you can use :
+
+ use POSIX;
+ cast $ENV{TZ}, wizard set => sub { POSIX::tzset(); () };