in reply to Re: Re: Re: Code critique XS function for extracting a blessed regex's pattern.
in thread Code critique XS function for extracting a blessed regex's pattern.
Them's pretty strong words you are using there dude.
First off there are many "feature"s of perl that are not properly documented. This is probably natural given that the code changes much faster than the documentation. Nevertheless you have a point. I will request Hugo make a decision on this, and if it is determined that it is a feature then I will provide a patch for perlop so that it becomes a documented feature. (As I said this is not uncommon at all.)
Second off, it seems that you have been stuck by the "since I can't see a good reason to do this there must not be a good reason" bug. One of my hobbies is writing an improved Dumper. Being able to correctly dump an object that is in fact a blessed qr// is very useful. Both for data storage purposes, also for development use.
Personally I don't think that an improved dumper is ill-conceived, and the functionality is required if the dumper is going to be complete.
Now, keep that in mind as you reconsider the issue of whether Regexp thingies should maintain their magic after being reblessed into another class. It can lead to inconsistent behavior. For instance:
I fail to see why this behaviour is inconsistent. One item is a regex, the other item is not. Since they are different the fact that they behave different can hardly come to a suprise to anyone. The only aspect of this that makes it seem inconsistent is that under normal circumstances you cant tell whats different. Your argument seems to amount to saying that "Since you cant distinguish a blessed scalar ref from a blessed qr// you shouldnt implement a way to do so." Which hardly seems like a logical position to take.
(All of which begs the question of whether we should even rely on qr// returning a blessed reference in the first place.)
I believe that it is a feature. And one that is exploited too. I think it is extremely unlikely that this behaviour will change, and if it does it will change over several versions as it must be deprecated first, then eliminated. Either way, the decision of Hugo will resolve this.
The whole mess gets even stickier when you consider that strings can be used in much the same way that precompiled regexes are.
Precisely the problem I am trying to address. How do I tell a string from a regex? Consider I might have a search routine. If you pass in a string it finds all the elements that equal that string exactly. If you pass in a regex it finds all the elements that match the regex. Being able to distinguish the two seems to be of obvious utility.
That's not very nice behavior given that it isn't, AFAIK, documented that you shouldn't write a Regexp package of your own.
I dont get it. This is exactly the behaviour I would expect given that it is not documented that you shouldn't write a Regexp package of your own.
--- demerphq
my friends call me, usually because I'm late....
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: Re: Code critique XS function for extracting a blessed regex's pattern.
by sauoq (Abbot) on Feb 06, 2003 at 22:23 UTC | |
by demerphq (Chancellor) on Feb 08, 2003 at 14:08 UTC | |
by sauoq (Abbot) on Feb 09, 2003 at 04:51 UTC | |
by ysth (Canon) on Nov 20, 2003 at 00:09 UTC |