Inline::SLang::Types

Support for S-Lang types in Perl
Download

Inline::SLang::Types Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Douglas Burke
  • Publisher web site:
  • http://search.cpan.org/~djburke/Astro-Cosmology-0.90/Cosmology.pm

Inline::SLang::Types Tags


Inline::SLang::Types Description

Support for S-Lang types in Perl Inline::SLang::Types is a Perl module with support for S-Lang types.SYNOPSIS use Inline SLang => Config => BIND_SLFUNCS => ; use Inline SLang; use Math::Complex; # the S-Lang Complex_Type variable is automatically converted # to a Math::Complex object in Perl. # my $val = makecplx(); print "Perl has been sent $val "; # the multiplication is done using Math::Complex objects and # the result then converted to a S-Lang Complex_Type variable, # since vmessage is a S-Lang function . # vmessage( "S-Lang has been sent %S", $val * cplx(0,1) ); my $type = typecplx($val); print "And the S-Lang datatype is $type "; print " Perl object " . $type->typeof . " "; __END__ __SLang__ define makecplx() { return 3 + 4i; } define typecplx(cval) { return typeof(cval); }The output of this code - which can be found in the source-code distribution as examples/types.pl - is: Perl has been sent 3+4i S-Lang has been sent (-4 + 3i) And the S-Lang datatype is Complex_Type Perl object DataType_TypeThe aim of the type-handling in Inline::SLang is to allow a user to program "naturally" in Perl and S-Lang - i.e. to take advantage of the strengths of each language - and so native data types are used wherever possible. However, Perl objects (classes defined in this module) are used when necessary - for some poorly defined definition of necessary - to preserve type information.As an example, consider swapping a complex number between S-Lang and Perl. In S-Lang it would be represented as a Complex_Type and in Perl we choose to use a Math::Complex object. Something simple - such as an array reference containing two elements - could have been used, but then we would not be able to convert it back into a Complex_Type variable in S-Lang (well, not without telling the computer this is what we wanted). Requirements: · Perl


Inline::SLang::Types Related Software