I just checked in Dans patch for a new popen that returns a file object instead of a string under the name fpopen. Would you rather see that popen is incompatibly replaced? If not, make up a better name than fpopen.
How about File()->popen()? That would be consistent with current functionality such as File()->connect() and File()->pipe().
/ Marcus Comstedt (ACROSS) (Hail Ilpalazzo!)
Previous text:
2004-05-01 14:27: Subject: Poll
I just checked in Dans patch for a new popen that returns a file object instead of a string under the name fpopen. Would you rather see that popen is incompatibly replaced? If not, make up a better name than fpopen.
/ Martin Nilsson (räfsfiskal)
To me it feels like it is in the wrong module. Kind of like Stdio.File()->encode_gif(image_obj). The code in File will have to call spawn, so either Stdio has to depend on Process or we have to put an ugly master()->resolv in there.
/ Martin Nilsson (räfsfiskal)
Previous text:
2004-05-01 20:09: Subject: Poll
Why? I think it seems like a good idea.
/ Per Hedbor ()
Why is circular dependencies so bad?
/ Mirar
Previous text:
2004-05-02 02:28: Subject: Poll
To me it feels like it is in the wrong module. Kind of like Stdio.File()->encode_gif(image_obj). The code in File will have to call spawn, so either Stdio has to depend on Process or we have to put an ugly master()->resolv in there.
/ Martin Nilsson (räfsfiskal)
It's more the dependency than the circulariness I'm concerned about. Stdio is used by everything and should depend on as little as possible and be fast to load.
/ Martin Nilsson (räfsfiskal)
Previous text:
2004-05-03 08:50: Subject: Poll
Why is circular dependencies so bad?
/ Mirar
The resolv() hack seems appropriate then.
/ Johan Sundström (Achtung Liebe!)
Previous text:
2004-05-03 12:17: Subject: Poll
It's more the dependency than the circulariness I'm concerned about. Stdio is used by everything and should depend on as little as possible and be fast to load.
/ Martin Nilsson (räfsfiskal)
In the last episode (May 05), Martin Nilsson (rfsfiskal) @ Pike (-) developers forum said:
I just checked in Dans patch for a new popen that returns a file object instead of a string under the name fpopen. Would you rather see that popen is incompatibly replaced? If not, make up a better name than fpopen.
Apparently the lyskom gateway suddenly woke up and this entire thread arrived in my mailbox at once :)
I thought of a way to make it backwards-compatible: If you call popen("command") with no 2nd argument, default to "r", do the read() internally, and return the string.
object(Stdio.FILE)|string popen(string s, string|void mode) { int compat = 0; if (!mode) { mode = "r"; compat = 1; } object f = Stdio.FILE(); if (!f) error("Popen failed. (couldn't create file)\n");
object p = f->pipe(); if(!p) error("Popen failed. (couldn't create pipe)\n");
if (mode == "w") Process.spawn(s, p, 0, 0, destruct, f); else Process.spawn(s, 0, p, 0, destruct, f); p->close(); destruct(p);
if(compat) return f->read(); else return f; }
pike-devel@lists.lysator.liu.se