# Since no code is specified on the 'use Inline' line we look for # the __SLang__ block at the end of the file # use strict; use Inline 'SLang'; # regParse() in S-Lang returns a S-Lang variable with a type of Reg_Type. # This value is automatically converted into a Perl object of class Reg_Type. # my $reg = regParse("circle(100,200,50)"); print "S-Lang's regParse() returned [$reg]\n"; print "which is a " . ref($reg) . " object\n"; print "and whose area is " . regArea($reg) . "\n"; print " (pi * 50^2 is " . 4.0*atan2(1.0,1.0)*50*50 . ")\n"; does_slang_agree($reg); __END__ __SLang__ % Anything after the __SLang__ marker is S-Lang code % load in the region routines require("region"); % and define a somewhat pointless routine define does_slang_agree(in) { if ( typeof(in) != Region_Type ) verror( "Error!" ); vmessage( "S-Lang was sent a Region_Type variable with an area of %.11f", regArea(in) ); }