Here's a list I made of various things to do that came up at the conference. It's not complete; especially it doesn't include the stuff that Martin Baehr kept track of on the whiteboards. Perhaps he can complete it with those things?
These items are both large and small. I've marked the ones I feel more personally responsible for, as well as those I think ought to be fixed before a 7.6 release.
Important enough to be finished before 7.6:
o Clean up the module make system.
o Document the module make system.
o Add local_install target to the module make system, to make it simple for users who download standalone modules to get them installed in their user account instead of in the system pike installation.
Other important things:
o Document the C API more. (mast, hopefully with help from others with the knowledge..)
o Describe memory handling in the manuals, i.e. refcounting vs gc:ing, various kinds of leaks and ways to combat them, etc. (mast)
o Transfer the pike-community.org contents to a Steam server c/o Martin Baehr.
Bug fixes:
o Fix the memory overwrite bug in the "uses" array in peep.c that David Gourdelier has discovered. (More info needed.)
o Fix the bug which caused a fatal in the gc for David Gourdelier. (More info needed.) (mast)
Not that important:
o Implement a variant of _locate_references that is more suited for normal pike programmers. For instance, it should return a data structure that describes the references to an object instead of dumping it all on stderr. (mast)
o Add a function or option to create_process that conveniently starts a pike interpreter with another pike script.
o Add a function to change the argv array of the pike process.
o Dump pike backtraces on SIGSEGV.
o Finish the implementation of the "variant" feature (i.e. runtime dispatch on function argument types).
o Fix odd indentation of the output from %O for e.g. arrays. (mast)
o Valgrind some more. (Apparently done by Nilsson now.)
o Fix LXR view of the pike source on the pike site.
o Implement this_function().
o Add local_install target to the module make system, to make it simple for users who download standalone modules to get them installed in their user account instead of in the system pike installation.
Perhaps a ~/.pikerc with some settings in it such as extra module paths would be nice too? Simple enough to fix at least.
o Dump pike backtraces on SIGSEGV.
How about dumping C backtraces also, when possible (probably limited to Linux?). I have code for this and it would be, especially combined with pike backtraces, quite useful in case you get sporadic crashes and can't always run with gdb. Example output:
Signal SIGQUIT received.
Stack dump: { ./hdb(print_backtrace+0x1d) [0x8063429] /lib/libpthread.so.0 [0x4fc3bfea] /lib/libc.so.6 [0x4f9f6288] ./hdb(main+0x30d) [0x809216d] /lib/libc.so.6(__libc_start_main+0xc7) [0x4f9e27a7] ./hdb(XMapRaised+0x39) [0x80624e1] }
Naturally the above happens at a stage where only main has been called so it's not so interesting. The addresses are easily used in gcc with `info line *ADDR' or with the addr2line command line tool (which doesn't handle dynamically loaded modules though).
/ David Hedbor
Previous text:
2003-10-02 17:06: Subject: Some tasks from the conference
Here's a list I made of various things to do that came up at the conference. It's not complete; especially it doesn't include the stuff that Martin Baehr kept track of on the whiteboards. Perhaps he can complete it with those things?
These items are both large and small. I've marked the ones I feel more personally responsible for, as well as those I think ought to be fixed before a 7.6 release.
Important enough to be finished before 7.6:
o Clean up the module make system.
o Document the module make system.
o Add local_install target to the module make system, to make it simple for users who download standalone modules to get them installed in their user account instead of in the system pike installation.
Other important things:
o Document the C API more. (mast, hopefully with help from others with the knowledge..)
o Describe memory handling in the manuals, i.e. refcounting vs gc:ing, various kinds of leaks and ways to combat them, etc. (mast)
o Transfer the pike-community.org contents to a Steam server c/o Martin Baehr.
Bug fixes:
o Fix the memory overwrite bug in the "uses" array in peep.c that David Gourdelier has discovered. (More info needed.)
o Fix the bug which caused a fatal in the gc for David Gourdelier. (More info needed.) (mast)
Not that important:
o Implement a variant of _locate_references that is more suited for normal pike programmers. For instance, it should return a data structure that describes the references to an object instead of dumping it all on stderr. (mast)
o Add a function or option to create_process that conveniently starts a pike interpreter with another pike script.
o Add a function to change the argv array of the pike process.
o Dump pike backtraces on SIGSEGV.
o Finish the implementation of the "variant" feature (i.e. runtime dispatch on function argument types).
o Fix odd indentation of the output from %O for e.g. arrays. (mast)
o Valgrind some more. (Apparently done by Nilsson now.)
o Fix LXR view of the pike source on the pike site.
o Implement this_function().
/ Martin Stjernholm, Roxen IS
I wouldn't mind a Pike module to debug C programs, if it's possible. Then it could be called to generate it's own backtraces... :)
/ Mirar
Previous text:
2003-10-02 17:18: Subject: Some tasks from the conference
o Add local_install target to the module make system, to make it simple for users who download standalone modules to get them installed in their user account instead of in the system pike installation.
Perhaps a ~/.pikerc with some settings in it such as extra module paths would be nice too? Simple enough to fix at least.
o Dump pike backtraces on SIGSEGV.
How about dumping C backtraces also, when possible (probably limited to Linux?). I have code for this and it would be, especially combined with pike backtraces, quite useful in case you get sporadic crashes and can't always run with gdb. Example output:
Signal SIGQUIT received.
Stack dump: { ./hdb(print_backtrace+0x1d) [0x8063429] /lib/libpthread.so.0 [0x4fc3bfea] /lib/libc.so.6 [0x4f9f6288] ./hdb(main+0x30d) [0x809216d] /lib/libc.so.6(__libc_start_main+0xc7) [0x4f9e27a7] ./hdb(XMapRaised+0x39) [0x80624e1] }
Naturally the above happens at a stage where only main has been called so it's not so interesting. The addresses are easily used in gcc with `info line *ADDR' or with the addr2line command line tool (which doesn't handle dynamically loaded modules though).
/ David Hedbor
Sure, the backtrace method could be called from Pike and return an array too. :) But of course, as I said, as far as I know this is Linux only (but other systems may have similar methods to do this).
/ David Hedbor
Previous text:
2003-10-02 17:24: Subject: Some tasks from the conference
I wouldn't mind a Pike module to debug C programs, if it's possible. Then it could be called to generate it's own backtraces... :)
/ Mirar
Yeah, so a Pike module might be nice. I mean, someday someone will implement it for other systems too (Windows?), or I might find another use for it. :)
/ Mirar
Previous text:
2003-10-02 17:39: Subject: Some tasks from the conference
Sure, the backtrace method could be called from Pike and return an array too. :) But of course, as I said, as far as I know this is Linux only (but other systems may have similar methods to do this).
/ David Hedbor
Of course, I doubt it's _highly_ useful to manually call, except to debug a locked up program (i.e the SIG<whatever> feature roxen has). Might be useful I suppose.
/ David Hedbor
Previous text:
2003-10-02 17:39: Subject: Some tasks from the conference
Sure, the backtrace method could be called from Pike and return an array too. :) But of course, as I said, as far as I know this is Linux only (but other systems may have similar methods to do this).
/ David Hedbor
How about dumping C backtraces also, when possible (probably limited to Linux?).
That'd be very welcome. I've missed it many times when trying to debug heavy production systems.
/ Martin Stjernholm, Roxen IS
Previous text:
2003-10-02 17:18: Subject: Some tasks from the conference
o Add local_install target to the module make system, to make it simple for users who download standalone modules to get them installed in their user account instead of in the system pike installation.
Perhaps a ~/.pikerc with some settings in it such as extra module paths would be nice too? Simple enough to fix at least.
o Dump pike backtraces on SIGSEGV.
How about dumping C backtraces also, when possible (probably limited to Linux?). I have code for this and it would be, especially combined with pike backtraces, quite useful in case you get sporadic crashes and can't always run with gdb. Example output:
Signal SIGQUIT received.
Stack dump: { ./hdb(print_backtrace+0x1d) [0x8063429] /lib/libpthread.so.0 [0x4fc3bfea] /lib/libc.so.6 [0x4f9f6288] ./hdb(main+0x30d) [0x809216d] /lib/libc.so.6(__libc_start_main+0xc7) [0x4f9e27a7] ./hdb(XMapRaised+0x39) [0x80624e1] }
Naturally the above happens at a stage where only main has been called so it's not so interesting. The addresses are easily used in gcc with `info line *ADDR' or with the addr2line command line tool (which doesn't handle dynamically loaded modules though).
/ David Hedbor
I can easily add it to 7.5 CVS. Currently my code breaks on the following signals:
signal(SIGILL, print_backtrace); signal(SIGQUIT, print_backtrace); signal(SIGABRT, print_backtrace); signal(SIGFPE, print_backtrace); signal(SIGSEGV, print_backtrace); signal(SIGBUS, print_backtrace); #ifdef SIGSYS signal(SIGSYS, print_backtrace); #endif
We want to remove SIGQUIT (which I use for debugging) since it's not strictly an error. Are the other ones ok to use as is? Note that it only, as far as I know, dumps the current thread.
/ David Hedbor
Previous text:
2003-10-02 17:31: Subject: Some tasks from the conference
How about dumping C backtraces also, when possible (probably limited to Linux?).
That'd be very welcome. I've missed it many times when trying to debug heavy production systems.
/ Martin Stjernholm, Roxen IS
SIGQUIT is fine, then I can use it to break a program (C-) and get a backtrace. :)
But please catch it in Hilfe too then, so the terminal doesn't go wacky just because I wanted a backtrace.
/ Mirar
Previous text:
2003-10-02 17:43: Subject: Some tasks from the conference
I can easily add it to 7.5 CVS. Currently my code breaks on the following signals:
signal(SIGILL, print_backtrace); signal(SIGQUIT, print_backtrace); signal(SIGABRT, print_backtrace); signal(SIGFPE, print_backtrace); signal(SIGSEGV, print_backtrace); signal(SIGBUS, print_backtrace); #ifdef SIGSYS signal(SIGSYS, print_backtrace); #endif
We want to remove SIGQUIT (which I use for debugging) since it's not strictly an error. Are the other ones ok to use as is? Note that it only, as far as I know, dumps the current thread.
/ David Hedbor
SIGQUIT is often used for application specific stuff. You'd have to turn it on explicitly if you want it.
/ Martin Stjernholm, Roxen IS
Previous text:
2003-10-02 17:44: Subject: Some tasks from the conference
SIGQUIT is fine, then I can use it to break a program (C-) and get a backtrace. :)
But please catch it in Hilfe too then, so the terminal doesn't go wacky just because I wanted a backtrace.
/ Mirar
If SIGQUIT is used for application stuff, it has it's own signal handler on that, and the backtrace code will not be called anyway?
/ Mirar
Previous text:
2003-10-02 17:54: Subject: Some tasks from the conference
SIGQUIT is often used for application specific stuff. You'd have to turn it on explicitly if you want it.
/ Martin Stjernholm, Roxen IS
You're right. Then it shouldn't be a problem.
/ Martin Stjernholm, Roxen IS
Previous text:
2003-10-02 17:56: Subject: Some tasks from the conference
If SIGQUIT is used for application stuff, it has it's own signal handler on that, and the backtrace code will not be called anyway?
/ Mirar
In the last episode (Oct 02), David Hedbor @ Pike developers forum said:
o Dump pike backtraces on SIGSEGV.
How about dumping C backtraces also, when possible (probably limited to Linux?). I have code for this and it would be, especially combined with pike backtraces, quite useful in case you get sporadic crashes and can't always run with gdb. Example output:
Solaris comes with a "pstack" program you can shell out and call on yourself, and there's a pstack port in the FreeBSD ports tree. Make sure that if you code it yourself, you are able to print stack traces for all threads.
For systems without pstack, you can always shell out and run a gdb/dbx/ladebug script to dump backtraces.
The problem with doing this is that the program MIGHT be at an unstable state in terms of memory allocation. Linux (newer ones at least) also optionally have the pstack program, so it's not unique per se.
/ David Hedbor
Previous text:
2003-10-02 17:54: Subject: Re: Some tasks from the conference
In the last episode (Oct 02), David Hedbor @ Pike developers forum said:
o Dump pike backtraces on SIGSEGV.
How about dumping C backtraces also, when possible (probably limited to Linux?). I have code for this and it would be, especially combined with pike backtraces, quite useful in case you get sporadic crashes and can't always run with gdb. Example output:
Solaris comes with a "pstack" program you can shell out and call on yourself, and there's a pstack port in the FreeBSD ports tree. Make sure that if you code it yourself, you are able to print stack traces for all threads.
For systems without pstack, you can always shell out and run a gdb/dbx/ladebug script to dump backtraces.
-- Dan Nelson dnelson@allantgroup.com
/ Brevbäraren
o Dump pike backtraces on SIGSEGV.
I would like an option to pike that dumps a pike backtrace on SIGINT as well. (Or as default behaviour.)
Can Pike backtraces be dumped on SIGSEGV? How wiill the security mechanism around that look like? Turn of catching SIGSEGV in the SIGSEGV handler?
(Speaking of which, maybe SIGQUIT should be trapped by Hilfe to reset the terminal?)
o Finish the implementation of the "variant" feature (i.e. runtime dispatch on function argument types).
Can someone elaborate on this?
o Fix LXR view of the pike source on the pike site.
LXR?
o Implement this_function().
Is this tricky?
/ Mirar
Previous text:
2003-10-02 17:06: Subject: Some tasks from the conference
Here's a list I made of various things to do that came up at the conference. It's not complete; especially it doesn't include the stuff that Martin Baehr kept track of on the whiteboards. Perhaps he can complete it with those things?
These items are both large and small. I've marked the ones I feel more personally responsible for, as well as those I think ought to be fixed before a 7.6 release.
Important enough to be finished before 7.6:
o Clean up the module make system.
o Document the module make system.
o Add local_install target to the module make system, to make it simple for users who download standalone modules to get them installed in their user account instead of in the system pike installation.
Other important things:
o Document the C API more. (mast, hopefully with help from others with the knowledge..)
o Describe memory handling in the manuals, i.e. refcounting vs gc:ing, various kinds of leaks and ways to combat them, etc. (mast)
o Transfer the pike-community.org contents to a Steam server c/o Martin Baehr.
Bug fixes:
o Fix the memory overwrite bug in the "uses" array in peep.c that David Gourdelier has discovered. (More info needed.)
o Fix the bug which caused a fatal in the gc for David Gourdelier. (More info needed.) (mast)
Not that important:
o Implement a variant of _locate_references that is more suited for normal pike programmers. For instance, it should return a data structure that describes the references to an object instead of dumping it all on stderr. (mast)
o Add a function or option to create_process that conveniently starts a pike interpreter with another pike script.
o Add a function to change the argv array of the pike process.
o Dump pike backtraces on SIGSEGV.
o Finish the implementation of the "variant" feature (i.e. runtime dispatch on function argument types).
o Fix odd indentation of the output from %O for e.g. arrays. (mast)
o Valgrind some more. (Apparently done by Nilsson now.)
o Fix LXR view of the pike source on the pike site.
o Implement this_function().
/ Martin Stjernholm, Roxen IS
o Finish the implementation of the "variant" feature (i.e. runtime dispatch on function argument types).
Can someone elaborate on this?
Overloading.
variant void my_exit(int bar) { exit(bar); }
variant void my_exit(string bar) { werror(bar); exit(17); }
A keyword is used to catch errorenous multiple definitions.
o Fix LXR view of the pike source on the pike site.
LXR?
Source code viwer with cross referencing support. Every sybol is a link to where it was defined.
/ Martin Nilsson (saturator)
Previous text:
2003-10-02 17:22: Subject: Some tasks from the conference
o Dump pike backtraces on SIGSEGV.
I would like an option to pike that dumps a pike backtrace on SIGINT as well. (Or as default behaviour.)
Can Pike backtraces be dumped on SIGSEGV? How wiill the security mechanism around that look like? Turn of catching SIGSEGV in the SIGSEGV handler?
(Speaking of which, maybe SIGQUIT should be trapped by Hilfe to reset the terminal?)
o Finish the implementation of the "variant" feature (i.e. runtime dispatch on function argument types).
Can someone elaborate on this?
o Fix LXR view of the pike source on the pike site.
LXR?
o Implement this_function().
Is this tricky?
/ Mirar
Source code viwer with cross referencing support. Every sybol is a link to where it was defined.
Nice. So far I've used etags for that, but it's buggy. :)
/ Mirar
Previous text:
2003-10-02 17:50: Subject: Some tasks from the conference
o Finish the implementation of the "variant" feature (i.e. runtime dispatch on function argument types).
Can someone elaborate on this?
Overloading.
variant void my_exit(int bar) { exit(bar); }
variant void my_exit(string bar) { werror(bar); exit(17); }
A keyword is used to catch errorenous multiple definitions.
o Fix LXR view of the pike source on the pike site.
LXR?
Source code viwer with cross referencing support. Every sybol is a link to where it was defined.
/ Martin Nilsson (saturator)
I would like an option to pike that dumps a pike backtrace on SIGINT as well. (Or as default behaviour.)
An option or environment setting to enable it for any signal would be nice, but I definitely don't think it should be the default for SIGINT.
Can Pike backtraces be dumped on SIGSEGV?
Yes, why not?
How will the security mechanism around that look like?
You mean wrt the pike security system, or security in general, e.g. concerns about a user segfaulting a process to get access to sensitive data on the stack? I think the last part should be solved by self-sensoring string objects, which were discussed a while back.
Turn of catching SIGSEGV in the SIGSEGV handler?
It's probably good to be able to disable it from inside pike.
o Implement this_function().
Is this tricky?
Not at all.
/ Martin Stjernholm, Roxen IS
Previous text:
2003-10-02 17:22: Subject: Some tasks from the conference
o Dump pike backtraces on SIGSEGV.
I would like an option to pike that dumps a pike backtrace on SIGINT as well. (Or as default behaviour.)
Can Pike backtraces be dumped on SIGSEGV? How wiill the security mechanism around that look like? Turn of catching SIGSEGV in the SIGSEGV handler?
(Speaking of which, maybe SIGQUIT should be trapped by Hilfe to reset the terminal?)
o Finish the implementation of the "variant" feature (i.e. runtime dispatch on function argument types).
Can someone elaborate on this?
o Fix LXR view of the pike source on the pike site.
LXR?
o Implement this_function().
Is this tricky?
/ Mirar
I would like an option to pike that dumps a pike backtrace on SIGINT as well. (Or as default behaviour.)
An option or environment setting to enable it for any signal would be nice, but I definitely don't think it should be the default for SIGINT.
Possibly not. Using SIGQUIT might be useful, though.
Can Pike backtraces be dumped on SIGSEGV?
Yes, why not?
Because the memory might be faulty. 99% of all my SIGSEGVs seems to be because the memory allocation info is broken, and thus all consequent calls to malloc or free SIGSEGVs...
You mean wrt the pike security system, or security in general, e.g. concerns about a user segfaulting a process to get access to sensitive data on the stack? I think the last part should be solved by self-sensoring string objects, which were discussed a while back.
I think I meant, what happens if the backtrace SIGSEGVs:
Turn of catching SIGSEGV in the SIGSEGV handler?
But an eye on the security features would be nice too. A sensitive-string-object should be implemented.
/ Mirar
Previous text:
2003-10-02 17:52: Subject: Some tasks from the conference
I would like an option to pike that dumps a pike backtrace on SIGINT as well. (Or as default behaviour.)
An option or environment setting to enable it for any signal would be nice, but I definitely don't think it should be the default for SIGINT.
Can Pike backtraces be dumped on SIGSEGV?
Yes, why not?
How will the security mechanism around that look like?
You mean wrt the pike security system, or security in general, e.g. concerns about a user segfaulting a process to get access to sensitive data on the stack? I think the last part should be solved by self-sensoring string objects, which were discussed a while back.
Turn of catching SIGSEGV in the SIGSEGV handler?
It's probably good to be able to disable it from inside pike.
o Implement this_function().
Is this tricky?
Not at all.
/ Martin Stjernholm, Roxen IS
I think I meant, what happens if the backtrace SIGSEGVs:
Well, it shouldn't do describe_backtrace(backtrace()). Rather it'd use gdb_backtraces() (see interpret.c) which is less fancy but much more robust. Still, it can segfault by following an invalid pointer so some care must be taken to handle that situation at least somewhat gracefully.
/ Martin Stjernholm, Roxen IS
Previous text:
2003-10-02 17:55: Subject: Some tasks from the conference
I would like an option to pike that dumps a pike backtrace on SIGINT as well. (Or as default behaviour.)
An option or environment setting to enable it for any signal would be nice, but I definitely don't think it should be the default for SIGINT.
Possibly not. Using SIGQUIT might be useful, though.
Can Pike backtraces be dumped on SIGSEGV?
Yes, why not?
Because the memory might be faulty. 99% of all my SIGSEGVs seems to be because the memory allocation info is broken, and thus all consequent calls to malloc or free SIGSEGVs...
You mean wrt the pike security system, or security in general, e.g. concerns about a user segfaulting a process to get access to sensitive data on the stack? I think the last part should be solved by self-sensoring string objects, which were discussed a while back.
I think I meant, what happens if the backtrace SIGSEGVs:
Turn of catching SIGSEGV in the SIGSEGV handler?
But an eye on the security features would be nice too. A sensitive-string-object should be implemented.
/ Mirar
On Thu, Oct 02, 2003 at 05:10:04PM +0200, Martin Stjernholm, Roxen IS @ Pike developers forum wrote:
o Transfer the pike-community.org contents to a Steam server c/o Martin Baehr.
i have received a huge mail (45 times by now ;-| and will start to disect that soon...
o Add a function or option to create_process that conveniently starts a pike interpreter with another pike script.
shouldn't this mean "with the same pike script" ?
o Add a function to change the argv array of the pike process.
is this the way it is done in c? i thought changing argv was just a convenience method in perl.
for pike i am guessing the better way is to have a function like System.set_process_name(string)
o Implement this_function().
to add to the discussion, (what i learned at the conference) this_function() is mostly usefull in hilfe-like situations, and it is also limited to simple recoursions. (doesn't help in situations where a() calls b() and b() calls a()...
greetings, martin.
o Add a function or option to create_process that conveniently starts a pike interpreter with another pike script.
shouldn't this mean "with the same pike script" ?
No, rather "with the same pike interpreter". To me it doesn't seem that useful to only be able to start the same script again.
for pike i am guessing the better way is to have a function like System.set_process_name(string)
That's exactly what I meant, with the addition that it could just as well change any argument in the array.
/ Martin Stjernholm, Roxen IS
Previous text:
2003-10-05 11:35: Subject: Re: Some tasks from the conference
On Thu, Oct 02, 2003 at 05:10:04PM +0200, Martin Stjernholm, Roxen IS @ Pike developers forum wrote:
o Transfer the pike-community.org contents to a Steam server c/o Martin Baehr.
i have received a huge mail (45 times by now ;-| and will start to disect that soon...
o Add a function or option to create_process that conveniently starts a pike interpreter with another pike script.
shouldn't this mean "with the same pike script" ?
o Add a function to change the argv array of the pike process.
is this the way it is done in c? i thought changing argv was just a convenience method in perl.
for pike i am guessing the better way is to have a function like System.set_process_name(string)
o Implement this_function().
to add to the discussion, (what i learned at the conference) this_function() is mostly usefull in hilfe-like situations, and it is also limited to simple recoursions. (doesn't help in situations where a() calls b() and b() calls a()...
greetings, martin.
/ Brevbäraren
On Sun, Oct 05, 2003 at 02:20:05PM +0200, Martin Stjernholm, Roxen IS @ Pike developers forum wrote:
rather "with the same pike interpreter"
err, right.
it doesn't seem that useful to only be able to start the same script again.
true, but that case should be particularely easy, probably by not needing to specify which script is to be started.
does the ability to fork without using fork() in order to send a process into the background fit in here, or is the suggested commandline option (like pike --detach) a better solution?
it could just as well change any argument in the array.
does it make sense to allow changing individual arguments? (except argv[0])
greetings, martin.
In the last episode (Oct 05), Martin Baehr said:
it could just as well change any argument in the array.
does it make sense to allow changing individual arguments? (except argv[0])
Depends on what you're trying to accomplish. If you are rewriting argc/argv to make it easier for later parts of a program to parse (a la getopt), then you can simply change argv directly. If you are trying to change what the ps command prints, each OS has a different method, since many kernels cache the argv string so ps doesn't have to swap processes into memory just to print the commandline. The BSDs have a setproctitle function that does the dirty work for you, and you can take a look at the sendmail source for all the other methods.
src/README describes the different SPT_TYPE values, and src/conf.c has the implementation.
of course i mean the latter, as the former is already possible. and there being different methods is exactly what made me wonder about changing individual elements in argv.
but i think we all mean the same anyways.
essentially there are these different usefull operations:
set the name only, leaving the args intact set the args only, leaving the name unchanged (eg. to hide sensitive info) set the whole string remove the pike executable out of the string. (reduce "/usr/bin/pike foo.pike" to "foo.pike")
the last is a special case of the first, but should be possible without having to find out the name of the script.
greetings, martin.
o Implement this_function().
to add to the discussion, (what i learned at the conference) this_function() is mostly usefull in hilfe-like situations,
I guess this is the computer science way of defining this_function:
function fac = Y (lambda (function this_function, int x)
{ return (x == 0) ? 1 : x * this_function(x - 1); });
Result: `()
fac(17);
Result: 355687428096000
All you need is to first define this general but strange-looking function:
function Y(function f)
{ return lambda(mixed y) { return (lambda(function x, mixed w) { return f(lambda(mixed z) { return x(x, z); }, w); }) (lambda(function x, mixed w) { return f(lambda(mixed z) { return x(x, z); }, w); }, y); }; }
It took me quite a while to try to remember what the function looks like, and then write it in pike ;-)
/ Niels Möller (igelkottsräddare)
Previous text:
2003-10-05 11:35: Subject: Re: Some tasks from the conference
On Thu, Oct 02, 2003 at 05:10:04PM +0200, Martin Stjernholm, Roxen IS @ Pike developers forum wrote:
o Transfer the pike-community.org contents to a Steam server c/o Martin Baehr.
i have received a huge mail (45 times by now ;-| and will start to disect that soon...
o Add a function or option to create_process that conveniently starts a pike interpreter with another pike script.
shouldn't this mean "with the same pike script" ?
o Add a function to change the argv array of the pike process.
is this the way it is done in c? i thought changing argv was just a convenience method in perl.
for pike i am guessing the better way is to have a function like System.set_process_name(string)
o Implement this_function().
to add to the discussion, (what i learned at the conference) this_function() is mostly usefull in hilfe-like situations, and it is also limited to simple recoursions. (doesn't help in situations where a() calls b() and b() calls a()...
greetings, martin.
/ Brevbäraren
Whoa, now that was a good entry for the next obfuscated Pike contest. :)
I take it that it's some kind of cheating to simply give a name to a lambda?
function Y (function f) { mixed g (mixed... args) { return f (g, @args); }; return g; }
/ Martin Stjernholm, Roxen IS
Previous text:
2003-10-06 09:25: Subject: Re: Some tasks from the conference
o Implement this_function().
to add to the discussion, (what i learned at the conference) this_function() is mostly usefull in hilfe-like situations,
I guess this is the computer science way of defining this_function:
function fac = Y (lambda (function this_function, int x)
{ return (x == 0) ? 1 : x * this_function(x - 1); });
Result: `()
fac(17);
Result: 355687428096000
All you need is to first define this general but strange-looking function:
function Y(function f)
{ return lambda(mixed y) { return (lambda(function x, mixed w) { return f(lambda(mixed z) { return x(x, z); }, w); }) (lambda(function x, mixed w) { return f(lambda(mixed z) { return x(x, z); }, w); }, y); }; }
It took me quite a while to try to remember what the function looks like, and then write it in pike ;-)
/ Niels Möller (igelkottsräddare)
No, it's the famous Y combinator. The point is that *no* naming is needed, the names "Y" and "fac" were used only for convenience.
Just try
(lambda (function f) { return lambda(mixed y) { return (lambda(function x, mixed w) { return f(lambda(mixed z) { return x(x, z); }, w); }) (lambda(function x, mixed w) { return f(lambda(mixed z) { return x(x, z); }, w); }, y); };}) (lambda (function this_function, int x) { return (x == 0) ? 1 : x * this_function(x - 1); }) (17);
Say you have a function f(function g, x), this can be viewed as a transformation from (x->g(x)) to (x->f(g,x))f. In this case it's
lambda (function this_function, int x) { return (x == 0) ? 1 : x * this_function(x - 1); }
Y constructs a kind of "fix point" to this function:
f(Y(f), x) = Y(f)(x).
It's quite a remarkable fact that such a fix point operator exists, and even more remarkable that it can be written as a fairly short lambda expression.
To see why, one can start with Y(f)(x), and do one round of argument substitution of into the first lambda call. After some rewriting out comes an expression that is equivalent to f(Y(f), x).
The usual definition is in a lambda language with curryfication of function arguments:
Y := (lambda (f) ((lambda (x) (f (lambda (z) ((x x) z)))) (lambda (x) (f (lambda (z) ((x x) z)))) ))
/ Niels Möller (igelkottsräddare)
Previous text:
2003-10-06 20:04: Subject: Re: Some tasks from the conference
Whoa, now that was a good entry for the next obfuscated Pike contest. :)
I take it that it's some kind of cheating to simply give a name to a lambda?
function Y (function f) { mixed g (mixed... args) { return f (g, @args); }; return g; }
/ Martin Stjernholm, Roxen IS
No, it's the famous Y combinator. The point is that *no* naming is needed, the names "Y" and "fac" were used only for convenience.
Local variables are named. I don't see a significant differance. Also, I think 'famous' might be a slight exaggeration. :)
/ Fredrik (Naranek) Hubinette (Real Build Master)
Previous text:
2003-10-06 21:20: Subject: Re: Some tasks from the conference
No, it's the famous Y combinator. The point is that *no* naming is needed, the names "Y" and "fac" were used only for convenience.
Just try
(lambda (function f) { return lambda(mixed y) { return (lambda(function x, mixed w) { return f(lambda(mixed z) { return x(x, z); }, w); }) (lambda(function x, mixed w) { return f(lambda(mixed z) { return x(x, z); }, w); }, y); };}) (lambda (function this_function, int x) { return (x == 0) ? 1 : x * this_function(x - 1); }) (17);
Say you have a function f(function g, x), this can be viewed as a transformation from (x->g(x)) to (x->f(g,x))f. In this case it's
lambda (function this_function, int x) { return (x == 0) ? 1 : x * this_function(x - 1); }
Y constructs a kind of "fix point" to this function:
f(Y(f), x) = Y(f)(x).
It's quite a remarkable fact that such a fix point operator exists, and even more remarkable that it can be written as a fairly short lambda expression.
To see why, one can start with Y(f)(x), and do one round of argument substitution of into the first lambda call. After some rewriting out comes an expression that is equivalent to f(Y(f), x).
The usual definition is in a lambda language with curryfication of function arguments:
Y := (lambda (f) ((lambda (x) (f (lambda (z) ((x x) z)))) (lambda (x) (f (lambda (z) ((x x) z)))) ))
/ Niels Möller (igelkottsräddare)
Well, the difference is that a local variable (by which I really mean a formal argument to a function) can not be defined recursively in terms of itself.
Local (function) definitions in pike are more powerful, just like ordinary recursive functions. It seems recursive definitions of variables won't work, though, like
array foo = ({ 1, foo });
That's unlike C, where you can at least do things like
struct foo { struct foo *p; } bar = { &bar };
/ Niels Möller (igelkottsräddare)
Previous text:
2003-10-06 23:35: Subject: Re: Some tasks from the conference
No, it's the famous Y combinator. The point is that *no* naming is needed, the names "Y" and "fac" were used only for convenience.
Local variables are named. I don't see a significant differance. Also, I think 'famous' might be a slight exaggeration. :)
/ Fredrik (Naranek) Hubinette (Real Build Master)
Well, the difference is that a local variable (by which I really mean a formal argument to a function) can not be defined recursively in terms of itself.
But in your case it is through aliasing. Since x ends up being the function itself after one step in the recursion, the function is in fact defined in terms of itself.
As far as I can tell, all that fancy stuff is just different way of doing naming.
/ Fredrik (Naranek) Hubinette (Real Build Master)
Previous text:
2003-10-07 00:12: Subject: Re: Some tasks from the conference
Well, the difference is that a local variable (by which I really mean a formal argument to a function) can not be defined recursively in terms of itself.
Local (function) definitions in pike are more powerful, just like ordinary recursive functions. It seems recursive definitions of variables won't work, though, like
array foo = ({ 1, foo });
That's unlike C, where you can at least do things like
struct foo { struct foo *p; } bar = { &bar };
/ Niels Möller (igelkottsräddare)
Perhaps you can see it that way. But it's possible to do away also with the local variables, and instead express Y in terms of the two functions
K(a, b) = b S(f, g, x) = f(x, g(x))
But we're quickly drifting off topic now. There are some old messages in the <möte 44: Kombinatorer och lambdakalkyl> conference, if anybody is interested.
/ Niels Möller (igelkottsräddare)
Previous text:
2003-10-07 00:33: Subject: Re: Some tasks from the conference
Well, the difference is that a local variable (by which I really mean a formal argument to a function) can not be defined recursively in terms of itself.
But in your case it is through aliasing. Since x ends up being the function itself after one step in the recursion, the function is in fact defined in terms of itself.
As far as I can tell, all that fancy stuff is just different way of doing naming.
/ Fredrik (Naranek) Hubinette (Real Build Master)
Then the references I've read are
David Turner, 1979, "A New Implementation Technique for Applicative Languages", Software Practice & Experience, 9.
Simon L, Peyton Jones "Implementation of Functional Programming Languages", ISBN 013-453333-X or ISBN 013-453325-9 (Paperback). One of the later chapters describes compilation to SK combinators. One of the earlier chapters defines the Y combinator.
/ Niels Möller (igelkottsräddare)
Previous text:
2003-10-07 01:52: Subject: Re: Some tasks from the conference
i fear they are in swedish :-(
greetings, martin.
/ Brevbäraren
All you need is to first define this general but strange-looking function:
function Y(function f)
{ return lambda(mixed y) { return (lambda(function x, mixed w) { return f(lambda(mixed z) { return x(x, z); }, w); }) (lambda(function x, mixed w) { return f(lambda(mixed z) { return x(x, z); }, w); }, y); }; }
It took me quite a while to try to remember what the function looks like, and then write it in pike ;-)
Wouldn't this be easier:
function Y(function f) { function Z(mixed ... y) { return f(Z, @y); }; return Z; }
/ Fredrik (Naranek) Hubinette (Real Build Master)
Previous text:
2003-10-06 09:25: Subject: Re: Some tasks from the conference
o Implement this_function().
to add to the discussion, (what i learned at the conference) this_function() is mostly usefull in hilfe-like situations,
I guess this is the computer science way of defining this_function:
function fac = Y (lambda (function this_function, int x)
{ return (x == 0) ? 1 : x * this_function(x - 1); });
Result: `()
fac(17);
Result: 355687428096000
All you need is to first define this general but strange-looking function:
function Y(function f)
{ return lambda(mixed y) { return (lambda(function x, mixed w) { return f(lambda(mixed z) { return x(x, z); }, w); }) (lambda(function x, mixed w) { return f(lambda(mixed z) { return x(x, z); }, w); }, y); }; }
It took me quite a while to try to remember what the function looks like, and then write it in pike ;-)
/ Niels Möller (igelkottsräddare)
That doesn't look as impressive.
/ Martin Nilsson (saturator)
Previous text:
2003-10-06 20:43: Subject: Re: Some tasks from the conference
All you need is to first define this general but strange-looking function:
function Y(function f)
{ return lambda(mixed y) { return (lambda(function x, mixed w) { return f(lambda(mixed z) { return x(x, z); }, w); }) (lambda(function x, mixed w) { return f(lambda(mixed z) { return x(x, z); }, w); }, y); }; }
It took me quite a while to try to remember what the function looks like, and then write it in pike ;-)
Wouldn't this be easier:
function Y(function f) { function Z(mixed ... y) { return f(Z, @y); }; return Z; }
/ Fredrik (Naranek) Hubinette (Real Build Master)
You use recursion to define Z. That's cheating. ;-)
/ Niels Möller (igelkottsräddare)
Previous text:
2003-10-06 20:43: Subject: Re: Some tasks from the conference
All you need is to first define this general but strange-looking function:
function Y(function f)
{ return lambda(mixed y) { return (lambda(function x, mixed w) { return f(lambda(mixed z) { return x(x, z); }, w); }) (lambda(function x, mixed w) { return f(lambda(mixed z) { return x(x, z); }, w); }, y); }; }
It took me quite a while to try to remember what the function looks like, and then write it in pike ;-)
Wouldn't this be easier:
function Y(function f) { function Z(mixed ... y) { return f(Z, @y); }; return Z; }
/ Fredrik (Naranek) Hubinette (Real Build Master)
pike-devel@lists.lysator.liu.se