This is the mail archive of the guile@cygnus.com mailing list for the guile project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Recently I had cause to use the `expect' module. It is pretty convenient, but I noticed a couple things I don't like or don't understand. First, since it works on a per-character basis, it is very slow (I attribute this slowness to expect.scm and not Guile, but I admit I haven't run any tests). In my case, I know I want to operate only on entire lines. It would be nice if there were an `expect' option to enable this. Second, I don't understand the usage of `$' in regular expressions here. Or, rather, I think I understand it, but I don't like it. The manual implies that $ will match newlines. In reality it matches the end of any string -- rendering it useless for my purposes. The appended program demonstrates the problem: the regex is matched individually for each character of /etc/passwd. This behavior suprised me; I think it would be more natural if a `$' in an expect regex matched only a newline. (In this case it might be possible for expect-strings to automatically notice when line-by-line mode could be entered. (But an explicit flag is good enough for me.)) Tom (use-modules (ice-9 expect)) (with-input-from-file "/etc/passwd" (lambda () (while (char-ready?) (expect-strings ("^.*$" => (lambda all (display all) (newline)))))))