On Thu, Nov 07, 2002 at 04:16:50PM -0500, Dan Sugalski wrote:

> Basically anything you can potentially find in a symbol table or 
> lexical scratchpad will potentially be able to have a property 
> attached to it. The only way that we'll be able to reasonably 
> restrict (and optimize) the use of low-level data types is to keep 
> them out of the symbol tables, which then makes using them in string 
> evals and suchlike things somewhat problematic. (And not allowing 
> properties on them will require us to throw runtime errors) It'll 
> also make passing them in as parameters interesting, as we'd then 
> need to construct temporary full variables that held them, which'd be 
> somewhat interesting to deal with.

But surely there should be no problem passing things as parameters - with a
bit of mundane magic even taking reference to a bit should work quite nicely.
After all, perl5 can already handle the idea of not autovivifying hash lookups
passed as subroutine parameters, and assigning to substrings and substring
references:

#!/usr/local/bin/perl -w

use strict;
use Devel::Peek;

sub rrrrrroll {
  Dump $_[0];
  $_[0] x= 6;
}

sub rrrroll {
  Dump $_[0];
  ${$_[0]} x= 4;
}

$a = "Mordor";

rrrrrroll (substr ($a, 2, 1));

print "'$a'\n";

rrrroll (\substr ($a, -1));

print "'$a'\n";

__END__

SV = PVLV(0x1138c0) at 0x1332e8
  REFCNT = 1
  FLAGS = (PADMY,GMG,SMG,pPOK)
  IV = 0
  NV = 0
  PV = 0x133d98 "r"\0
  CUR = 1
  LEN = 2
  MAGIC = 0x10e8f0
    MG_VIRTUAL = &PL_vtbl_substr
    MG_TYPE = PERL_MAGIC_substr(x)
  TYPE = x
  TARGOFF = 2
  TARGLEN = 1
  TARG = 0x132f10
SV = PV(0xf4580) at 0x132f10
  REFCNT = 2
  FLAGS = (POK,pPOK)
  PV = 0x10c398 "Mordor"\0
  CUR = 6
  LEN = 7
'Morrrrrrdor'
SV = RV(0x11dee8) at 0xf4284
  REFCNT = 1
  FLAGS = (ROK)
  RV = 0x13336c
  SV = PVLV(0x1138f0) at 0x13336c
    REFCNT = 2
    FLAGS = (PADMY,GMG,SMG,pPOK)
    IV = 0
    NV = 0
    PV = 0x1137e0 "r"\0
    CUR = 1
    LEN = 2
    MAGIC = 0x10e060
      MG_VIRTUAL = &PL_vtbl_substr
      MG_TYPE = PERL_MAGIC_substr(x)
    TYPE = x
    TARGOFF = 10
    TARGLEN = 1
    TARG = 0x132f10
  SV = PV(0xf4580) at 0x132f10
    REFCNT = 3
    FLAGS = (POK,pPOK)
    PV = 0x10c398 "Morrrrrrdor"\0
    CUR = 11
    LEN = 12
'Morrrrrrdorrrr'

Nicholas Clark
-- 
INTERCAL better than perl?      http://www.perl.org/advocacy/spoofathon/

Reply via email to