Nilsson, did you have any good way of inserting Regexp.PCRE?
I want to write the glue in lib/modules, but I'm getting fuzzed by the compilation orders (again). Is it supposed to work like this?
1) I moved Regexp (the c+pike glue) to Regexp.Builtin, using MODULE_INIT() location setting
2) I make Regexp.pmod/module.pmod inherit Regexp.Builtin, and then this happens:
| > Regexp("["); | Cannot call undefined lfun `(). | > indices(Regexp); | (1) Result: ({ /* 11 elements */ | "`()", ...and the rest that should be there... | "Builtin", | "module", | "___Builtin", | }) | > Regexp["`()"]("hej"); | (2) Result: Regexp.SimpleRegexp(hej)
There's nothing magical about the old Regexp module,
| SimpleRegexp `()(void|string regexp) { return SimpleRegexp(regexp); }
so what's going on? Why does `[] work but not `->?
| > Regexp.PCRE("(\1234.).*n")->split2("p\1235ke \1234s fun"); | (4) Result: ({ /* 2 elements */ | "\1234s fun", | "\1234s" | }) | > Regexp.PCRE.split2("(\1234.).*n","p\1235ke \1234s fun"); | (2) Result: ({ /* 2 elements */ | "\1234s fun", | "\1234s" | }) | > Regexp.PCRE.split("(\1234.).*n","p\1235ke \1234s fun"); | (3) Result: ({ /* 1 element */ | "\1234s" | }) | > Regexp.PCRE.Plain("(\1234.).*n")->split2("p\1235ke \1234s fun"); | Bad argument 1 to pcre->create(). Expected string (8bit) | :-)
So, to check this in I need to move away Regexp like in the commented text. Any ideas?
/ Mirar
Previous text:
2003-09-24 09:25: Subject: foo
Nilsson, did you have any good way of inserting Regexp.PCRE?
I want to write the glue in lib/modules, but I'm getting fuzzed by the compilation orders (again). Is it supposed to work like this?
- I moved Regexp (the c+pike glue) to Regexp.Builtin,
using MODULE_INIT() location setting
- I make Regexp.pmod/module.pmod inherit Regexp.Builtin,
and then this happens:
| > Regexp("["); | Cannot call undefined lfun `(). | > indices(Regexp); | (1) Result: ({ /* 11 elements */ | "`()", ...and the rest that should be there... | "Builtin", | "module", | "___Builtin", | }) | > Regexp["`()"]("hej"); | (2) Result: Regexp.SimpleRegexp(hej)
There's nothing magical about the old Regexp module,
| SimpleRegexp `()(void|string regexp) { return SimpleRegexp(regexp); }
so what's going on? Why does `[] work but not `->?
/ Mirar
Move manually in the repository.
/ Peter Bortas
Previous text:
2003-09-24 10:52: Subject: foo
| > Regexp.PCRE("(\1234.).*n")->split2("p\1235ke \1234s fun"); | (4) Result: ({ /* 2 elements */ | "\1234s fun", | "\1234s" | }) | > Regexp.PCRE.split2("(\1234.).*n","p\1235ke \1234s fun"); | (2) Result: ({ /* 2 elements */ | "\1234s fun", | "\1234s" | }) | > Regexp.PCRE.split("(\1234.).*n","p\1235ke \1234s fun"); | (3) Result: ({ /* 1 element */ | "\1234s" | }) | > Regexp.PCRE.Plain("(\1234.).*n")->split2("p\1235ke \1234s fun"); | Bad argument 1 to pcre->create(). Expected string (8bit) | :-)
So, to check this in I need to move away Regexp like in the commented text. Any ideas?
/ Mirar
This is even more interesting,
Regexp.pmod/Module.pmod: | class Foo | { | inherit Regexp.Builtin; | }
| > indices(Regexp.Foo); | (2) Result: ({ /* 1 element */ | "_SimpleRegexp" | }) | > indices(Regexp.Builtin); | (3) Result: ({ /* 6 elements */ | "replace", | "`()", | "split", | "SimpleRegexp", | "match", | "_SimpleRegexp" | })
Er... Okey?
/ Mirar
Previous text:
2003-09-24 11:30: Subject: foo
I already succeeded moving it to Regexp.Builtin, using PIKE_MODULE_INIT(Regexp.Builtin). But I can't make a compat Regexp module.pmod inheriting it...
/ Mirar
Regexp.Foo is a class, and Regexp.Builtin is an object.
/ Per Hedbor ()
Previous text:
2003-09-24 11:46: Subject: foo
This is even more interesting,
Regexp.pmod/Module.pmod: | class Foo | { | inherit Regexp.Builtin; | }
| > indices(Regexp.Foo); | (2) Result: ({ /* 1 element */ | "_SimpleRegexp" | }) | > indices(Regexp.Builtin); | (3) Result: ({ /* 6 elements */ | "replace", | "`()", | "split", | "SimpleRegexp", | "match", | "_SimpleRegexp" | })
Er... Okey?
/ Mirar
But the main problem seems to be that calling a function doesn't call `[] or `-> to dig out the `() lfun, it calls `() directly. Adding `() to the joinnode solves the problem; adding `-> didn't.
But adding `() to joinnode is ugly. Any better suggestion?
/ Mirar
Previous text:
2003-09-24 11:50: Subject: foo
Ah! Of course.
/ Mirar
Adding `() at all is ugly. We ought to fix support for .pike directories instead.
/ Martin Stjernholm, Roxen IS
Previous text:
2003-09-24 12:11: Subject: foo
But the main problem seems to be that calling a function doesn't call `[] or `-> to dig out the `() lfun, it calls `() directly. Adding `() to the joinnode solves the problem; adding `-> didn't.
But adding `() to joinnode is ugly. Any better suggestion?
/ Mirar
`() is here just for backwards compatibilty. *I* wont be sorry if we drop it, but someone else might.
I think from the beginning there were only Regexp, and it was a class - __module_value stuff.
How much will break if "Regexp(re)" disappears?
/ Mirar
Previous text:
2003-09-24 13:27: Subject: foo
Adding `() at all is ugly. We ought to fix support for .pike directories instead.
/ Martin Stjernholm, Roxen IS
A lot.
I'm starting to doubt if it's worth all this trickery to get a cleaner namespace. Clearly the module structure doesn't handle a name doubling as a class and a module. It's not only about the call API but also typechecking, inheritance etc. Why not use PCRE on the top level instead? It's not exactly likely that it'll conflict with anything else.
/ Martin Stjernholm, Roxen IS
Previous text:
2003-09-24 13:33: Subject: foo
`() is here just for backwards compatibilty. *I* wont be sorry if we drop it, but someone else might.
I think from the beginning there were only Regexp, and it was a class
- __module_value stuff.
How much will break if "Regexp(re)" disappears?
/ Mirar
I think it's a bug that joinnodes can't have the `() overloaded, though. So if that's fixed it solves the nice namespace too...
/ Mirar
Previous text:
2003-09-24 13:38: Subject: foo
A lot.
I'm starting to doubt if it's worth all this trickery to get a cleaner namespace. Clearly the module structure doesn't handle a name doubling as a class and a module. It's not only about the call API but also typechecking, inheritance etc. Why not use PCRE on the top level instead? It's not exactly likely that it'll conflict with anything else.
/ Martin Stjernholm, Roxen IS
No. It doesn't solve inherit and it doesn't solve typechecking (unless lots of horrible kludges are added to the module, like all the "optional" crap in the Thread module).
/ Martin Stjernholm, Roxen IS
Previous text:
2003-09-24 13:50: Subject: foo
I think it's a bug that joinnodes can't have the `() overloaded, though. So if that's fixed it solves the nice namespace too...
/ Mirar
inherit? You can't inherit modules anyway?
Although I agree on the typechecking. Why doesn't `() look up the lfun?
/ Mirar
Previous text:
2003-09-24 13:59: Subject: foo
No. It doesn't solve inherit and it doesn't solve typechecking (unless lots of horrible kludges are added to the module, like all the "optional" crap in the Thread module).
/ Martin Stjernholm, Roxen IS
Yes it's possible to inherit modules, provided that they aren't dirnodes or joinnodes. I've thought about solving the dirnode issue by essentially removing dirnodes altogether (especially the `[] and `-> lfuns in them). Joinnodes are harder to do away with. A solution for that case is probably to add a callback in the compilation handler that can extract a suitable class from the joinnode (or complain).
As for typechecking, it would be necessary that e.g. Regexp and Regexp.Regexp compare as equal, but only when Regexp is used as a class. It's not possible to solve well.
/ Martin Stjernholm, Roxen IS
Previous text:
2003-09-24 14:00: Subject: foo
inherit? You can't inherit modules anyway?
Although I agree on the typechecking. Why doesn't `() look up the lfun?
/ Mirar
What are dirnodes and joinnodes modules by the way ?
Martin Stjernholm, Roxen IS @ Pike developers forum wrote:
Yes it's possible to inherit modules, provided that they aren't dirnodes or joinnodes. I've thought about solving the dirnode issue by essentially removing dirnodes altogether (especially the `[] and `-> lfuns in them). Joinnodes are harder to do away with. A solution for that case is probably to add a callback in the compilation handler that can extract a suitable class from the joinnode (or complain).
As for typechecking, it would be necessary that e.g. Regexp and Regexp.Regexp compare as equal, but only when Regexp is used as a class. It's not possible to solve well.
/ Martin Stjernholm, Roxen IS
Previous text:
2003-09-24 14:00: Subject: foo
inherit? You can't inherit modules anyway?
Although I agree on the typechecking. Why doesn't `() look up the lfun?
/ Mirar
A dirnode is the object that represents a .pmod directory. It has `[] and `-> lfuns that looks for identifiers in the directory or in the special module.pmod file.
Joinnodes are used when several module directory trees contain the same module, e.g. if the module path contains /foo and /bar and there's a /foo/Gnu.pmod and a /bar/Gnu.pmod then you'll get a joinnode for Gnu which looks up every identifier in both.
/ Martin Stjernholm, Roxen IS
Previous text:
2003-09-24 16:49: Subject: Re: foo
What are dirnodes and joinnodes modules by the way ?
Martin Stjernholm, Roxen IS @ Pike developers forum wrote:
Yes it's possible to inherit modules, provided that they aren't dirnodes or joinnodes. I've thought about solving the dirnode issue by essentially removing dirnodes altogether (especially the `[] and `-> lfuns in them). Joinnodes are harder to do away with. A solution for that case is probably to add a callback in the compilation handler that can extract a suitable class from the joinnode (or complain).
As for typechecking, it would be necessary that e.g. Regexp and Regexp.Regexp compare as equal, but only when Regexp is used as a class. It's not possible to solve well.
/ Martin Stjernholm, Roxen IS
Previous text:
2003-09-24 14:00: Subject: foo
inherit? You can't inherit modules anyway?
Although I agree on the typechecking. Why doesn't `() look up the lfun?
/ Mirar
/ Brevbäraren
It has `[] and `-> lfuns that looks for identifiers in the directory or in the special module.pmod file.
No, it hasn't.
String;
(1) Result: master()->joinnode(({ /* 1 element */ master()->dirnode("/home/nilsson/Pike/7.5/lib/modules/String.pmod") }))
String["capitalize"];
(2) Result: String.capitalize
String->capitalize;
(3) Result: 0
This usually bites me when I write testsuite cases (cond(foo->bar)), but I have assumed that sometimes you might want to call things in the actual dirnode so I haven't fixed this.
/ Martin Nilsson (saturator)
Previous text:
2003-09-24 16:59: Subject: Re: foo
A dirnode is the object that represents a .pmod directory. It has `[] and `-> lfuns that looks for identifiers in the directory or in the special module.pmod file.
Joinnodes are used when several module directory trees contain the same module, e.g. if the module path contains /foo and /bar and there's a /foo/Gnu.pmod and a /bar/Gnu.pmod then you'll get a joinnode for Gnu which looks up every identifier in both.
/ Martin Stjernholm, Roxen IS
This usually bites me when I write testsuite cases (cond(foo->bar)), but I have assumed that sometimes you might want to call things in the actual dirnode so I haven't fixed this.
It's intentional. So there's nothing to "fix".
/ Henrik Grubbström (Lysator)
Previous text:
2003-09-24 17:04: Subject: Re: foo
It has `[] and `-> lfuns that looks for identifiers in the directory or in the special module.pmod file.
No, it hasn't.
String;
(1) Result: master()->joinnode(({ /* 1 element */ master()->dirnode("/home/nilsson/Pike/7.5/lib/modules/String.pmod") }))
String["capitalize"];
(2) Result: String.capitalize
String->capitalize;
(3) Result: 0
This usually bites me when I write testsuite cases (cond(foo->bar)), but I have assumed that sometimes you might want to call things in the actual dirnode so I haven't fixed this.
/ Martin Nilsson (saturator)
Lots.
/ Peter Bortas
Previous text:
2003-09-24 13:33: Subject: foo
`() is here just for backwards compatibilty. *I* wont be sorry if we drop it, but someone else might.
I think from the beginning there were only Regexp, and it was a class
- __module_value stuff.
How much will break if "Regexp(re)" disappears?
/ Mirar
Why is lib/modules so much better than module.pmod.in?
/ Martin Nilsson (saturator)
Previous text:
2003-09-24 09:25: Subject: foo
Nilsson, did you have any good way of inserting Regexp.PCRE?
I want to write the glue in lib/modules, but I'm getting fuzzed by the compilation orders (again). Is it supposed to work like this?
- I moved Regexp (the c+pike glue) to Regexp.Builtin,
using MODULE_INIT() location setting
- I make Regexp.pmod/module.pmod inherit Regexp.Builtin,
and then this happens:
| > Regexp("["); | Cannot call undefined lfun `(). | > indices(Regexp); | (1) Result: ({ /* 11 elements */ | "`()", ...and the rest that should be there... | "Builtin", | "module", | "___Builtin", | }) | > Regexp["`()"]("hej"); | (2) Result: Regexp.SimpleRegexp(hej)
There's nothing magical about the old Regexp module,
| SimpleRegexp `()(void|string regexp) { return SimpleRegexp(regexp); }
so what's going on? Why does `[] work but not `->?
/ Mirar
pike-devel@lists.lysator.liu.se