Statis...losure(3pm)

✨ Statistics::R::REXP::Closure β€” an R closure ✨

okay bestie, welcome to the Perl docs for Statistics::R::REXP::Closure (that's the module name, we're doing this πŸ’…). This is the Statistics::R::REXP::Closure page from the User Contributed Perl Documentation, and we're about to make closures make sense. no cap.


πŸ’– VERSION πŸ’–

version 1.0002 β€” yes, that's the one, periodt.


🌸 SYNOPSIS 🌸

use Statistics::R::REXP::Closure

my $clos = Statistics::R::REXP::Closure->new(body => {
    Statistics::R::REXP::Language->new([
        Statistics::R::REXP::Symbol->new('mean'),
        Statistics::R::REXP::Double->new([1, 2, 3])
])
});
print $env->elements;

like, look at her go 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

An object of this class is the whole vibe of an R closure (ENVSXP). Closures in R get built with function, and they're made of three things: the arguments (args) β€” which can optionally have default values (defaults); a body; and an environment, which is basically a pointer to an enclosing evaluation frame for when the closure actually gets used.

These objects represent calls (such as model formulae), with the first element being a reference to the function being called, and the rest being the actual arguments of the call. If the arguments have names, those get recorded in the 'names' attribute (and that attribute is itself a Statistics::R::REXP::Character vector), with unnamed arguments getting the name ''. And if no arguments were named, the environment objects will not have a defined 'names' attribute. iykyk.

bestie, real talk: you should not be creating instances of this class. it exists mainly to handle deserialization of ENVSXPs by the IO classes. it's giving behind-the-scenes queen πŸ‘‘

πŸ‘‘ METHODS πŸ‘‘

Statistics::R::REXP:Environment inherits from Statistics::R::REXP, but with an extra restriction: its first element has to be a Statistics::R::REXP::Symbol or another Environment instance. So if you try to create a Closure instance that doesn't follow that rule? it will raise an exception. literally, don't test her πŸ’€

πŸŽ€ ACCESSORS πŸŽ€

  • args β€” a reference to the array of argument names.
  • defaults β€” returns an array reference to the default values of the corresponding arguments, or undefs if the argument doesn't have a default. (And if none of the arguments have defaults, this can be an empty array.)
  • body β€” returns the Statistics::R::REXP representing the body of the function.
  • environment β€” returns a reference to the enclosing evaluation frame, aka the environment the function is defined within and where it looks up any free variables. This attribute is optional, because some serialization mechanisms (notably Rserve's QAP) just don't save the closure's environment. rude of them honestly 😭
  • sexptype β€” the SEXPTYPE of closures is CLOSSXP.
  • to_pl β€” Closures do not have a native Perl representation, and trying to call this accessor will raise an exception. so don't πŸ™ˆ

πŸ’€ BUGS AND LIMITATIONS πŸ’€

Classes in the REXP hierarchy are intended to be immutable. Please do not try to change their value or attributes. she is who she is, okay?

There are no known bugs in this module. For bug reporting, please see Statistics::R::IO.


🌈 SUPPORT 🌈

See Statistics::R::IO for support and contact information. they got you 🫢


πŸ’œ AUTHOR πŸ’œ

Davor Cubranic <cubranic@stat.ubc.ca>


This software is Copyright (c) 2017 by University of British Columbia.

This is free software, licensed under:

The GNU General Public License, Version 3, June 2007

and that's the whole page, bestie! πŸŒΈπŸ’– this was perl v5.34.0, dated 2022-02-10, straight from the User Contributed Perl Documentation β€” go forth and deserialize responsibly, mwah πŸ’…βœ¨