On 3 September 2014 19:25, Paul "LeoNerd" Evans <leonerd@leonerd.org.uk> wrote: > On Wed, 3 Sep 2014 12:42:19 -0400 > Jarkko Hietaniemi <jhi@iki.fi> wrote: > > > These just the top off my head and while typing to my phone. There > > is no reason why they need to be in an extension, except That Is The > > Way It Has Been. > > Hmm.. I'd argue the converse, at this stage. > > There's no reason /to/ add them as core operators when they can live in > Scalar-List-Utils' .xs file. Any nontrivially sized program these days > is likely to have ListUtils.so loaded anyway. > > I think there is a reason to move the to a different namespace: we could then fix the interface issues with some of them. For instance reftype() returns PL_sv_undef() when the item is not a ref. This means you have to guard usage of it somehow. If it returned PL_sv_no() instead, then we could safely write: if (reftype($foo) eq "HASH") { } instead of my $reftype= ref($foo); if (defined $reftype and $reftype eq "HASH") { } or one of the myriad of variants along that line. FWIW, years ago I posted a patch to do this, and the resulting controversy over which namespace to use resulted in it being reverted. See the "mauve" thread for details. Maintaining all of these as simple functions in the XS code is easier > IMHO than maintaining them as truely-core ops. > Who said they needed to be core ops? We can just put them in universal.c and register them into whatever namespace we wanted. OTOH, having reftype() and blessed() be fast IMO would be really nice. > What would you suggest as the alternative? > > use feature qw( weaken ); > > weaken( my $ref = $otherref ); > > perhaps? I don't see the difference that makes to the end-user. > > No "use feature" required. Just a simple: some_namespace::reftype() will work fine. We do this already for a variety of utility functions, such as utf8::downgrade(). IMO we would use something like "scalar" and "array" as the namespaces, and just put "everything related to scalars" in "scalar" and "everything related to arrays" in "array" and etc. maybe also use "list" as well as "array". /cue the arguing over whether it should be "scalar", "Scalar", "SCALAR", or whatever... Yves -- perl -Mre=debug -e "/just|another|perl|hacker/"Thread Previous | Thread Next