q-lang-users Mailing List for Q - Equational Programming Language (Page 59)
Brought to you by:
agraef
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(3) |
Feb
(27) |
Mar
|
Apr
(4) |
May
(11) |
Jun
(5) |
Jul
(5) |
Aug
(6) |
Sep
(15) |
Oct
(28) |
Nov
(8) |
Dec
|
2005 |
Jan
(9) |
Feb
(5) |
Mar
(10) |
Apr
(43) |
May
(8) |
Jun
(31) |
Jul
(45) |
Aug
(17) |
Sep
(8) |
Oct
(30) |
Nov
(2) |
Dec
(6) |
2006 |
Jan
(4) |
Feb
(20) |
Mar
(1) |
Apr
|
May
(92) |
Jun
(179) |
Jul
(26) |
Aug
(65) |
Sep
(36) |
Oct
(38) |
Nov
(44) |
Dec
(68) |
2007 |
Jan
(11) |
Feb
(25) |
Mar
(37) |
Apr
(7) |
May
(83) |
Jun
(77) |
Jul
(44) |
Aug
(4) |
Sep
(28) |
Oct
(53) |
Nov
(12) |
Dec
(21) |
2008 |
Jan
(66) |
Feb
(45) |
Mar
(30) |
Apr
(50) |
May
(9) |
Jun
(18) |
Jul
(11) |
Aug
(6) |
Sep
(4) |
Oct
|
Nov
|
Dec
|
2009 |
Jan
|
Feb
|
Mar
|
Apr
(3) |
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(2) |
Oct
|
Nov
|
Dec
|
From: <Dr....@t-...> - 2004-08-30 21:05:04
|
Brian Beckman wrote: > Hi there -- I was trying to get the "help" command of QPad on windows > to work through "info" via CygWin. The error message I get in QPad is > "info -- qdoc not found". In other words, it looks like info is > running but simply can't find the qdocs. Any clues for me about how > to fix this, please & thanks? You'll need the qdoc.info* files from the source tarball (q-5.3.tar.gz). You'll find them in the doc subdirectory. Copy those files to some place where info finds them. BTW, what's wrong with the manual included in Qpad's html help? It's exactly the same material as in the info files. Albert -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikwissenschaft.uni-mainz.de/~ag |
From: <Dr....@t-...> - 2004-08-30 20:59:10
|
Hi, Tim! Tim Haynes wrote: > I'm trying to write a little utility to read & (manipulate &) write PNM > bitmap image files. Have you considered using Q's ImageMagick module for that purpose? > Reading is OK but I've had to declare that `ord ""=0' around my reader > function[1]; I'm having serious problems writing the ascii NUL byte out - > have tried declaring that `chr 0="\0"' and other variations on a theme, but > every time I try to fwritec the thing, the file truncates prematurely; > running hexdump shows that no byte in the output is set to 00. Yes, Q strings are 0-terminated, as in C, therefore you can't have a \0 in a string (if you do, the string will be truncated there). What you probably need are byte strings. These are especially useful for encoding arbitrary binary data. See Section 12.3 (Clib -> Byte Strings) of the manual. Also see the section on binary files for operations on how to read and write such binary data from/to a file. > Footnotes: > [1] I had to do this before, as in a `where' clause it had no effect... > this also felt untidy. Note that where clauses in Q are always *variable* definitions (similar to Haskell's pattern bindings), there is no such thing like a local function definition in Q. Thus a clause like ... where ord "" = 0; will be interpreted as: "match 0 against ord "" and assign all variables in ord "" (none in this case) to their corresponding values." Which fails, because the source term 0 doesn't match the target term ord "", causing the entire rule containing that where clause to fail. More info about where clauses in Q can be found in Section 7.4 (Equations and Expression Evaluation -> Local Variables) of the manual. NB: It's not just my laziness that there are no "local equations" in Q (we discussed this on the list a while ago). There are some deep semantic difficulties with this in a language based on general term rewriting. Incidentally, your example is one such "bad usage" of a local equation: If such a local equation would be possible, it would presumably mean that the normal form of ord "" should be 0 in the context of the hosting rule (which also raises the question, which context? Dynamic? Lexical?), but should remain to be ord "" itself outside of it. Hence the normal form of ord "" wouldn't be well-defined any more, wreaking havoc on equational semantics. :( Cheers, Albert -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikwissenschaft.uni-mainz.de/~ag |
From: Brian B. <bc....@gm...> - 2004-08-20 13:11:56
|
Hi there -- I was trying to get the "help" command of QPad on windows to work through "info" via CygWin. The error message I get in QPad is "info -- qdoc not found". In other words, it looks like info is running but simply can't find the qdocs. Any clues for me about how to fix this, please & thanks? |
From: Tim H. <q...@st...> - 2004-08-16 18:41:35
|
Hiya, I'm trying to write a little utility to read & (manipulate &) write PNM bitmap image files. Reading is OK but I've had to declare that `ord ""=0' around my reader function[1]; I'm having serious problems writing the ascii NUL byte out - have tried declaring that `chr 0="\0"' and other variations on a theme, but every time I try to fwritec the thing, the file truncates prematurely; running hexdump shows that no byte in the output is set to 00. I'm unhappy about the `ord ""=0' trick - I would not have expected NUL to be converted to an empty string, rather to "\0", of course. I've also found that trying to embed a NUL in the script source causes syntax errors etc, as presumably the interpreter is seeing that as EOF. Sources for perusal are at <http://spodzone.org.uk/temp/q-pnm.tgz>. Is there an official way to handle this? Cheers, ~Tim Footnotes: [1] I had to do this before, as in a `where' clause it had no effect... this also felt untidy. [2] this is last day before going on holiday; please excuse a delay to any responses... -- <http://spodzone.org.uk/> |
From: <Dr....@t-...> - 2004-07-04 22:08:50
|
Tim Haynes wrote: > Well, at some future date I would like to be able to read in arbitrary, > possibly large-ish, XML documents, have them parsed into an accessible > structure and then be able to perform xpath/xquery queries on them to > isolate node(s). Yes, I see. Well it should be possible to write a sablotron wrapper which gives access to the internal data structure so that you can carry out these queries. Or even map the internal structure into a Q term. > Oh, ordered dictionaries as well? That would be great. I think we're talking about different things here. Q's ordered dictionaries are just dictionaries for key values on which an order is defined (such as strings, lists or numbers). They are implemented as AVL trees. Hashed dictionaries do not require this order, as the key values are hashed to give an integer which is used as the actual key in the AVL tree, the associated values are buckets (lists) of table elements with the same key. Both structures can be nested, of course. > I was wondering, earlier, what the most appropriate data-structure would be > for storing such a set of XML nodes, facilitating rapid random access. I'll > have a look through those sections imminently. Well, if you need random access to the components of an xml tag, then nested dictionaries could work reasonably well. But if sablatron already has all the xpath indexing facilities that you need, then it would probably be easiest and most efficient to just expose the internal data structure which sablotron uses to represent xml, as an external type in Q, and provide the necessary access operations in a Q->C module. Albert -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikwissenschaft.uni-mainz.de/~ag |
From: Tim H. <q...@st...> - 2004-07-03 22:27:17
|
Dr....@t-... (Albert Graef) writes: > Tim Haynes wrote: >> Well, I'm not convinced I know that much about it either, but I'd be happy >> to pass on the scripts & sablotron glue I've got so far - where would you >> like them? > > Yes, I'd like to take a look at that! Just send me a tarball by email, if > you like. [for the list's benefit, a tarball has been mailed.] >> - the basic gist is that, given a database query result-set via >> ODBC, I convert this >> [(colname1,colname2), (row1col1, row1val1)...] >> into XML with a recursive function whose first parameter is a list of >> node-names for different depths (["xml","row","field"], typically). > > For simple XML this scheme seems to be perfectly adequate, so why make it > any more complicated? Well, at some future date I would like to be able to read in arbitrary, possibly large-ish, XML documents, have them parsed into an accessible structure and then be able to perform xpath/xquery queries on them to isolate node(s). >> However, this is not clever in the slightest - it's all done with >> strings when ideally it should be a type in its own right with an >> appropriate index - but my Q is not so advanced[0] that I'd know how to >> implement such a thing. [...] > > If all you need is a kind of indexed container, Q's standard library > already has both ordered and hashed dictionaries (sections 11.5.5/6 in > the manual). Oh, ordered dictionaries as well? That would be great. I was wondering, earlier, what the most appropriate data-structure would be for storing such a set of XML nodes, facilitating rapid random access. I'll have a look through those sections imminently. >> [0] I've only been using it on & off since I saw the 5.3 announcement on >> freshmeat - hi folks! > > Welcome to the list. :) Thanks :) ~Tim -- <http://spodzone.org.uk/> |
From: <Dr....@t-...> - 2004-07-03 10:20:00
|
Juan Minutti wrote: > Dear Q people: > I need to know how I can see a graph using the graph.q or grapher.q, my platform is Windows. Which Windows version? > I can use Q like a process calculator, but I haven´t idea how compile and see it run with another programs, like Active Tk/Tcl or ImageDisplay. First: Do you have both ActiveTcl and ImageMagick installed already? (You can find links for both in the Download section of the Q homepage at http://q-lang.sourceforge.net/#Download.) Next, besides that Qpad MSI you also need to have the Graph MSI installed. You should then see an icon for graphed. Double-click it. The graph editor should appear. If nothing happens, then we have to start troubleshooting. :) Albert -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikwissenschaft.uni-mainz.de/~ag |
From: <Dr....@t-...> - 2004-07-03 10:07:51
|
Tim Haynes wrote: > Well, I'm not convinced I know that much about it either, but I'd be happy > to pass on the scripts & sablotron glue I've got so far - where would you > like them? Yes, I'd like to take a look at that! Just send me a tarball by email, if you like. > - the basic gist is that, given a database query result-set via > ODBC, I convert this > [(colname1,colname2), (row1col1, row1val1)...] > into XML with a recursive function whose first parameter is a list of > node-names for different depths (["xml","row","field"], typically). For simple XML this scheme seems to be perfectly adequate, so why make it any more complicated? > However, this is not clever in the slightest - it's all done with strings > when ideally it should be a type in its own right with an appropriate index > - but my Q is not so advanced[0] that I'd know how to implement such a > thing. [...] If all you need is a kind of indexed container, Q's standard library already has both ordered and hashed dictionaries (sections 11.5.5/6 in the manual). Crafting your own data types is also pretty straightforward (chapter 8 of the manual). If you need more info on this, don't hesitate to ask! > [0] I've only been using it on & off since I saw the 5.3 announcement on > freshmeat - hi folks! Welcome to the list. :) Albert -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikwissenschaft.uni-mainz.de/~ag |
From: <jua...@ya...> - 2004-07-01 08:37:01
|
Dear Q people: I need to know how I can see a graph using the graph.q or grapher.q, my platform is Windows. I can use Q like a process calculator, but I haven´t idea how compile and see it run with another programs, like Active Tk/Tcl or ImageDisplay. Can somebody answer me? Please & Thank you. from: Juan Carlos Cota Minutti (México) --------------------------------- Do You Yahoo!? Yahoo! Net: La mejor conexión a internet y 25MB extra a tu correo por $100 al mes. |
From: Tim H. <q...@st...> - 2004-06-29 22:56:25
|
Dr....@t-... (Albert Graef) writes: > > The problem is, if I write something like this: [snip] > > then obviously my webpage comes out with `()' on the bottom. This > > invalidates the generated RSS stream or XHTML page. > > Solution: Either terminate your main function with something like `quit' > or `exit 0' (i.e., main ARGS =3D writes PAGE || quit;), or add this to the > -c line (e.g., #! -c main ARGS||quit). This causes the interpreter to > exit before it prints the result expression. > > Hope this helps! Most excellent. Hadn't thought of that. Works a treat. Scripts duly updated. Thanks :) > > I'm playing around with Q for use as web CGIs - scripts build up XML > > data and transform it with sablotron prior to printing it out. > > Interesting! I'm contemplating the idea to write an XML parser/unparser > module for Q, but as I don't know much about XML I could use some > assistance. Willing to help? Well, I'm not convinced I know that much about it either, but I'd be happy to pass on the scripts & sablotron glue I've got so far - where would you like them? - the basic gist is that, given a database query result-set via ODBC, I convert this [(colname1,colname2), (row1col1, row1val1)...] into XML with a recursive function whose first parameter is a list of node-names for different depths (["xml","row","field"], typically). However, this is not clever in the slightest - it's all done with strings when ideally it should be a type in its own right with an appropriate index =2D but my Q is not so advanced[0] that I'd know how to implement such a thing. Also, I've wimped-out and used a fixed-length buffer and a deprecated function in the sablotron API(!)... but these things are what v2.0 is for ;) [0] I've only been using it on & off since I saw the 5.3 announcement on freshmeat - hi folks! ~Tim =2D-=20 <http://spodzone.org.uk/> |
From: <Dr....@t-...> - 2004-06-29 22:15:54
|
> The problem is, if I write something like this: > > | #!/usr/local/bin/q > | #! -q > | #! -s > | #! -p .: [list of directories] > | #! -cmain ARGS > [snip much programming] > | def PAGE=strcat [MimeType, cookies, "\n", BODY]; > | main ARGS = writes PAGE ; > > then obviously my webpage comes out with `()' on the bottom. This > invalidates the generated RSS stream or XHTML page. Solution: Either terminate your main function with something like `quit' or `exit 0' (i.e., main ARGS = writes PAGE || quit;), or add this to the -c line (e.g., #! -c main ARGS||quit). This causes the interpreter to exit before it prints the result expression. Hope this helps! > I'm playing around with Q for use as web CGIs - scripts build up XML data > and transform it with sablotron prior to printing it out. Interesting! I'm contemplating the idea to write an XML parser/unparser module for Q, but as I don't know much about XML I could use some assistance. Willing to help? Cheers, Albert -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikwissenschaft.uni-mainz.de/~ag |
From: Tim H. <q...@st...> - 2004-06-29 08:53:20
|
Hi, Maybe this is a FAQ; if so, could someone point me at an appropriate bit of docs? I'm playing around with Q for use as web CGIs - scripts build up XML data and transform it with sablotron prior to printing it out. The problem is, if I write something like this: | #!/usr/local/bin/q | #! -q | #! -s | #! -p .: [list of directories] | #! -cmain ARGS [snip much programming] | def PAGE=3Dstrcat [MimeType, cookies, "\n", BODY]; | main ARGS =3D writes PAGE ; then obviously my webpage comes out with `()' on the bottom. This invalidates the generated RSS stream or XHTML page. I've worked around this by implementing a Content-Length header, but ideally don't want it to appear at all. I've looked for more options like `-q' but nothing says "don't print the final expression value". I can't readily think of an expression that doesn't return a visible/printable value. I've tried qcwrap-ing the script and compiling that, but where I've had that work, it's filled up /tmp with /tmp/file* files. Can anyone help? Do I have to bite the bullet and install mod_q?=20 I have: | zsh/scr7, potato 9:51AM public_html/ % q --version | Q interpreter version 5.3 (i686-pc-linux-gnu) | Copyright (c) 1991-2004 by Albert Graef All thoughts welcome :) TIA, ~Tim =2D-=20 <http://spodzone.org.uk/> |
From: <Dr....@t-...> - 2004-06-01 20:40:56
|
Mike Hall wrote: > Or, maybe just add another comment in the README file Ok, I have that on my TODO list now. -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikwissenschaft.uni-mainz.de/~ag |
From: Mike H. <m3...@rc...> - 2004-06-01 04:13:49
|
On Saturday, May 29, 2004, at 12:30 PM, Albert Graef wrote: > Mike Hall wrote: >> I don't know what happened the last time, but after a remove, >> re-unpack, and retry, and it built just fine. > > I'm glad to hear that. :) Hmm, unfortunately that workaround breaks > with newer autotool versions on my Linux system, so I'm afraid that I > cannot simply commit it to cvs. Maybe a conditional for OSX is needed. Or, maybe just add another comment in the README file (near the existing 'CFLAGS=-no-cpp-precomp' notes for OS X) to suggest that we flip around the comments on the two lines with the clib_la_LIBADD definitions if we have troubles. (I'm thinking I'll wait for 10.4 to upgrade...) |
From: <Dr....@t-...> - 2004-05-29 17:29:51
|
Mike Hall wrote: > I don't know what happened the last time, but after a remove, > re-unpack, and retry, and it built just fine. I'm glad to hear that. :) Hmm, unfortunately that workaround breaks with newer autotool versions on my Linux system, so I'm afraid that I cannot simply commit it to cvs. Maybe a conditional for OSX is needed. Unfortunately my own OSX system is an older version, too, so I cannot test whether the fix also works on Panther. Did anyone out there have success compiling Q on newer OSX systems (10.3.x), or are the compile probs the same as those reported by Mike? Albert -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikwissenschaft.uni-mainz.de/~ag |
From: Mike H. <m3...@rc...> - 2004-05-27 05:13:37
|
> > > please try the following: In modules/clib/Makefile.am, uncomment the > 1st > > LIBADD line (line 11) and comment out the second one (line 12). Then > run > > automake (or the autogen script). I don't know what happened the last time, but after a remove, re-unpack, and retry, and it built just fine. Thank you! (Both for the fix and for 'Q' itself!) |
From: Mike H. <m3...@rc...> - 2004-05-27 02:22:31
|
> please try the following: In modules/clib/Makefile.am, uncomment the 1st > LIBADD line (line 11) and comment out the second one (line 12). Then run > automake (or the autogen script). > You"ll also have to rerun configure, of course. Well, I performed the comment exchange in the Makefile ... I hope that's legitimate. (Seems to be OK, in this case.) ================ Making all in modules Making all in clib Making all in . /bin/sh ../../libtool --mode=link gcc -g -O2 -o clib.la -rpath /usr/local/lib/q -no-undefined -module -avoid-version clib.lo -L../../libq -lq -lgmp -lpthread -L../../glob -lglob -L../../regex -lregex -lm rm -fr .libs/clib.la .libs/clib.* .libs/clib.* gcc -dynamiclib -o .libs/clib.so clib.lo -L/usr/local/lib -L/Users/mgh/public/q/q-5.3/libq -L/Users/mgh/public/q/q-5.3/libq/.libs -lq -lgmp -lpthread -L/Users/mgh/public/q/q-5.3/glob /Users/mgh/public/q/q-5.3/glob/.libs/libglob.al -L/Users/mgh/public/q/q-5.3/regex /Users/mgh/public/q/q-5.3/regex/.libs/libregex.al -lm -lc -install_name /usr/local/lib/q/clib.so ld: Undefined symbols: _isuint _mkuint /usr/bin/libtool: internal link edit command failed ================ It sure looks like we're specifying the right libraries, and libq.dylib does exist in libq/.libs. Strange that it doesn't see those symbols. $ pwd /Users/mgh/public/q/q-5.3/libq $ ls -l .libs total 96 -rwxr-xr-x 1 mgh staff 17804 May 26 14:23 libq.5.0.0.dylib* lrwxr-xr-x 1 mgh staff 16 May 26 14:23 libq.5.dylib@ ->libq.5.0.0.dylib -rw-r--r-- 1 mgh staff 11188 May 26 14:23 libq.a lrwxr-xr-x 1 mgh staff 16 May 26 14:23 libq.dylib@ -> libq.5.0.0.dylib lrwxr-xr-x 1 mgh staff 10 May 26 14:23 libq.la@ -> ../libq.la -rw-r--r-- 1 mgh staff 717 May 26 14:23 libq.lai $ nm .libs/libq.dylib | grep uint ... 00001830 T _isuint 00001108 T _mkuint ================ On the "good news" front: I loaded Q-4.5 last night, and it compiled/installed just fine. For awhile, I was convinced that 'libtool' was acting up on Q 5.3, but it's the same between 4.5 and 5.3. Thank you for the tips and advice! I'll play with this alternate way of selecting the libraries. |
From: <Dr....@t-...> - 2004-05-26 16:13:49
|
> Then run automake (or the autogen script). You'll also have to rerun configure, of course. -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikwissenschaft.uni-mainz.de/~ag |
From: <Dr....@t-...> - 2004-05-26 07:31:15
|
Hi, please try the following: In modules/clib/Makefile.am, uncomment the 1st LIBADD line (line 11) and comment out the second one (line 12). Then run automake (or the autogen script). I'm still hoping for a libtool version which works on *both* Linux and OSX without major hassles. :( -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikwissenschaft.uni-mainz.de/~ag |
From: Mike H. <m3...@rc...> - 2004-05-26 00:36:31
|
Hello, all! Sorry to bother everyone with this. Is there another group where I can request help building Q 5.3 on Mac OS X 10.2.5 (ancient, I know). I not usually a newbie at building from source distributions, but this one has me stumped. 'Configure' ran OK. It didn't find many extensions, but that's OK for now. I'd be happy if I could get a basic 'Q' up and running. $ gcc --version gcc (GCC) 3.1 20020420 (prerelease) $ uname -a Darwin a.b.local. 6.5 Darwin Kernel Version 6.5: Mon Apr 7 17:05:38 PDT 2003; root:xnu/xnu-344.32.obj~1/RELEASE_PPC Power Macintosh powerpc $ make Making all in modules Making all in clib Making all in . /bin/sh ../../libtool --mode=link gcc -no-cpp-precomp -o clib.la -rpath /usr/local/lib/q -no-undefined -module -avoid-version clib.lo ../../libq/libq.la -lgmp -lpthread ../../glob/libglob.la ../../regex/libregex.la -lm rm -fr .libs/clib.la .libs/clib.* .libs/clib.* gcc -dynamiclib -o .libs/clib.so clib.lo -all_load ../../glob/.libs/libglob.al ../../regex/.libs/libregex.al -L../../libq/.libs -lq -L/usr/local/lib -lgmp -lpthread ../../glob/.libs/libglob.al ../../regex/.libs/libregex.al -lm -lc -install_name /usr/local/lib/q/clib.so ld: multiple definitions of symbol ___glob_pattern_p ../../glob/.libs/libglob.al(glob.lo) definition of ___glob_pattern_p in section (__TEXT,__text) ../../glob/.libs/libglob.al(glob.lo) definition of ___glob_pattern_p in section (__TEXT,__text) ld: multiple definitions of symbol _xxglob ld: multiple definitions of symbol _xxglobfree ... ld: multiple definitions of symbol _xxregfree /usr/bin/libtool: internal link edit command failed make[4]: *** [clib.la] Error 1 make[3]: *** [all-recursive] Error 1 make[2]: *** [all-recursive] Error 1 make[1]: *** [all-recursive] Error 1 make: *** [all] Error 2 Have tried the -no-cpp-precomp flag from the README; doesn't help until further along in the build process. Have tried -disable-shared; didn't help. Have tried pulling the regex + glob libs from the clib Makefile then the symbols aren't found, instead of being duplicated. I'd be happy to dig and find out more, if anyone has any pointers or suggestions. Thank you! -- Mike Hall users.rcn.com/m3ha11 |
From: <Dr....@t-...> - 2004-05-19 08:04:23
|
jc...@re... wrote: > AA handles this by treating if-then-else as syntactic sugar for its > local rules [...] But Q has conditional rules, not conditional expressions. I'm afraid that these cannot be handled in a similar manner. Nevertheless, I think that a combination of specificity and textual ordering might be useful. I put it on the TODO list and if I have the time, I'll implement it in an experimental version of the interpreter. > I would have no problems with disallowing local rules in special > forms altogether. I think that would also eliminate your problem with > implementation as well, although I am not sure I understand it. I dislike such a solution which introduces arbitrary restrictions on the form of the rules. :( Maybe I didn't explain the problem well enough. Surely there are some non-trivial implementation problems to be solved. But the main problem I see with local rules is that, unless you put severe restrictions on the form of the rules, the notion of a normal form is not well-defined any more. Maybe this is a better example: foo X = bar X where bar X = X+1; Now the question is, is `bar a' a normal form? You cannot answer this because it depends on the particular rewriting sequence. If you start out with bar a then the term is irreducible. If you start out with foo a, then it is not, because foo a => bar a => a+1. So even if you start out with a confluent and terminating rewriting system, you cannot decide equality using just rewriting any more. IMHO, this is a bad feature in a language based on term rewriting. OTOH, the local rules allowed in Aardappel are more restricted, namely rules of the form f ... = ... where f is a new function symbol. That's a fairly arbitrary restriction in a general term rewriting language. Of course it eliminates the semantic difficulties (and also most of the implementation difficulties I see) because the local function symbol cannot be used outside the rule where it is defined. In fact, Aardappel's construction for translating local rules to global ones (p. 65) is an idiom in Q. Whenever you need a local function, you introduce a (global) private function instead which takes the variables it needs from the other definition as extra arguments. I must admit that this is inconvenient. Kind of the same restriction you have in C (no nested functions). So it all boils down to the question whether syntactic sugar should be provided to support this idiom in Q. I tend to dislike it, because of the arbitrary restrictions on the form of the local rules. Also, I would probably have to break backwards compatibility once more. Any other opinions? Suggestions for the syntax? > But in general > I think they are the Right Thing from the viewpoint of encapsulation; > they allow you to simplify "deep and hairy" rules. That I agree to. :) > Also, unifying > local variables, conditionals, and functional arguments is aesthetically > attractive. See the thesis pp. 48-50. It's certainly nice to derive all of these from a more basic language feature. But I don't think that the way you deal with functional arguments in Aardappel is very straightforward. Curried function applications are much more convenient, and you get closures for free. Just compare the Aardappel definition of the scale function on p. 50 with the following equivalent Q code (where the scale function takes the list as its 2nd argument): scale N = map (*N); > The thesis pp. 13-21 and pp. 51-57 are more eloquent than I can be on > the virtues of Linda-style concurrency and its applicability to tree > rewriting. I haven't taken a deeper look at this yet, but from what I've read, it appears to me that it wouldn't be too difficult to write a little Q script which implements the basic Linda operations (minus the syntactic sugar that Aardappel offers) in terms of Q's POSIX thread operations. Have you tried that already? Cheers, Albert -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikwissenschaft.uni-mainz.de/~ag |
From: <jc...@re...> - 2004-05-18 21:37:37
|
Albert Graef scripsit: > thanks for the pointer to Wouter's PhD thesis, it's a very interesting > read. I'm still studying it, but maybe I can already comment on some of > your suggestions from the perspective on how they could be implemented > for Q, so that we can further discuss it. Thank you for the swift and hospitable response! > However, there's the problem with rules of equal specificity (in > particular, if the left-hand sides of rules are equal), which frequently > arise in sequences of conditional equations like: > > fac N = N*fac (N-1) if N>0; > = 1 otherwise; AA handles this by treating if-then-else as syntactic sugar for its local rules (where $foo is a notation for meta-level variables and _ is an anonymous variable as in Prolog): if $x then $y else $z <===> f($x) where f(true) = $y; f(_) = $z} end $x when $p = $e <===> f($e) where f($p) = $x; f(Y) = Y end > Now one could combine specificity and textual order, but I think that > might be confusing for the programmer, so I'd rather stick with a > single rule choice strategy. Actually, I don't think it would be all that confusing, especially if the parser provides helpful warnings. The implementation (as opposed to the definition) of AA falls back to document order; I think it ought to provide a warning when it does that. For specificity as the kind of polymorphism appropriate for tree rewriting, see the thesis pp. 44-48 (printed page numbers as always; add 3 for PDF page numbers). > For instance, let's assume for the moment that `where' is used to > introduce a local rule like: > > foo X = bar X where Y+Z = Y; > > Let's further assume that a+b is in normal form. We have that foo (a+b) > => bar (a+b) by invoking the above rule. Now the local rule dictates > that a+b => a, so the end result would be bar a, even though a+b was in > normal form outside this rule and the foo X rule doesn't rewrite the a+b > subterm itself. Or don't we reduce a+b because it comes from "outside"? AA does indeed reduce foo(a+b) to bar(a) in this case. > But what happens then if foo is a special form, and hence the argument > *is* evaluated in the context of the rule? I would have no problems with disallowing local rules in special forms altogether. I think that would also eliminate your problem with implementation as well, although I am not sure I understand it. The thesis is short on examples of local rules other than those that reduce to conditionals, which Q handles differently. But in general I think they are the Right Thing from the viewpoint of encapsulation; they allow you to simplify "deep and hairy" rules. Also, unifying local variables, conditionals, and functional arguments is aesthetically attractive. See the thesis pp. 48-50. > That sounds like a useful feature indeed. I'll have to take a closer > look at this in the thesis, though, before I can come up with a more > informed opinion. :) What are the main benefits of this approach when > compared to traditional multithreading? The problem with traditional threads is sharing, which ends up being done with low-level monitors or even lower-level semaphores. Functional programming languages can be as concurrent as you want, but they lack object identity. AA provides object identity for containers (tree spaces as WvO calls them), but the level of sharing is less than that of an imperative language (where anyone can in principle observe the current state -- local scope and objects make this better, but don't really solve the problem) and more than that of a pure functional language where there is no state to observe. The thesis pp. 13-21 and pp. 51-57 are more eloquent than I can be on the virtues of Linda-style concurrency and its applicability to tree rewriting. > >I'd be interested to hear comments on these ideas, and > >I'll be happy to provide more details. > > Maybe we can add some of these features to Q to make it better. Great! -- "[T]he Unicode Standard does not encode John Cowan idiosyncratic, personal, novel, or private http://www.ccil.org/~cowan use characters, nor does it encode logos http://www.reutershealth.com or graphics." jc...@re... |
From: <Dr....@t-...> - 2004-05-18 09:29:46
|
Hi, John, thanks for the pointer to Wouter's PhD thesis, it's a very interesting read. I'm still studying it, but maybe I can already comment on some of your suggestions from the perspective on how they could be implemented for Q, so that we can further discuss it. > 1) Specificity ordering. AA does not assign meaning to the source-code > order of equations; instead, a specificity meta-rule is used to order > them. Letting < stand for "is more specific than", the rule is > > variable < number < atom < bag < tree Yes, I agree that the specificity order is a nice way to resolve the problem with overlapping rules in different modules. Adding this to the Q bytecode compiler wouldn't be a big deal (just sort the rule lists attached to the final states in the matching automaton according to a different criterion). However, there's the problem with rules of equal specificity (in particular, if the left-hand sides of rules are equal), which frequently arise in sequences of conditional equations like: fac N = N*fac (N-1) if N>0; = 1 otherwise; In Q these are actually treated as two separate equations for the same left-hand side fac N, which would give an error with the specificity order. There are other, more complex examples like this where the textual order seems preferable to me, especially when backtracking using the fail construct is involved (which admittedly is a feature that goes beyond standard rewriting). Now one could combine specificity and textual order, but I think that might be confusing for the programmer, so I'd rather stick with a single rule choice strategy. > 2) Normal form declarations. AA allows a declaration that a particular > tree is in normal form and so not reducible. This is essentially > a left-hand side without a right-hand side. This is particularly > important in local definitions; it allows a form to be locally normal > without worrying about whether it's globally normal as well due to a > conflict between local and global names. I see a problem with this approach, namely that normal forms are not "well-defined" anymore. If normalization using term rewriting is at the core of your language semantics then this is a serious issue. Especially if the language allows terms to be evaluated in a lazy fashion, as is the case in Q. Then suddenly the value of a subterm will depend on what context it is evaluated in, wreaking havoc on referential transparency. It's precisely for this reason that Q does not allow local rules, but only local variable definitions. For instance, let's assume for the moment that `where' is used to introduce a local rule like: foo X = bar X where Y+Z = Y; Let's further assume that a+b is in normal form. We have that foo (a+b) => bar (a+b) by invoking the above rule. Now the local rule dictates that a+b => a, so the end result would be bar a, even though a+b was in normal form outside this rule and the foo X rule doesn't rewrite the a+b subterm itself. Or don't we reduce a+b because it comes from "outside"? But what happens then if foo is a special form, and hence the argument *is* evaluated in the context of the rule? There's also a Q-specific implementation issue: When foo is a special form, the interpreter has to decide whether the argument of foo needs evaluation. The interpreter currently does some optimizations to keep track of terms which it already knows to be in normal form, so that it doesn't do any (obviously) useless reevaluations. This would not be possible anymore, because there's no way to predict whether a+b will always be a normal form -- in some rules it is, in others (like the above) it isn't. So it would have to reevaluate all special arguments anyway. This has a *huge* impact on performance; actually it would make special forms, as Q provides them, impractical. As much as I'd like to have local rules in Q (I've given this feature some thought before), I always stumble on these semantic and implementation difficulties. These troubles don't arise in languages like Haskell because of the constructor discipline. So I think that local rules are a no-no in general rewriting. I'd really liked to be convinced otherwise, though. ;-) I'll have to take a closer look at Aardappel and see how it deals with this issue. > 3) Concurrent reduction. AA trees can be placed in unordered tree bags. > A tree bag is in normal form iff the trees in it are, and if any of them > are not, they are reduced concurrently. Every tree is deemed to be in a > bag called its container; the top-level tree is in a singleton container. That sounds like a useful feature indeed. I'll have to take a closer look at this in the thesis, though, before I can come up with a more informed opinion. :) What are the main benefits of this approach when compared to traditional multithreading? > I'd be interested to hear comments on these ideas, and > I'll be happy to provide more details. Thanks for bringing up these ideas, I really think that your points deserve further discussion. Maybe we can add some of these features to Q to make it better. Cheers, Albert -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikwissenschaft.uni-mainz.de/~ag |
From: <jc...@re...> - 2004-05-17 22:16:45
|
I've just discovered Q, and it looks extremely interesting. I came to eager tree rewrite languages via Wouter van Oortmessen's Aardappel (henceforth AA), which implements much the same model but puts a GUI face on it. Q is a much more industrial-strength system than AA, which is research software. However, there are a few interesting features of AA which I think it would be good to have in a future version of Q. 1) Specificity ordering. AA does not assign meaning to the source-code order of equations; instead, a specificity meta-rule is used to order them. Letting < stand for "is more specific than", the rule is variable < number < atom < bag < tree (I'll talk about bags later.) Trees are ordered according to the specificity of their first children; if that is the same, the second child is used, and so on. In cases where two equations are equally specific, an error is signaled. Using specificity ordering is a kind of analogue to the inclusion polymorphism of methods in OO languages: more specific rules are applied before more general ones. In this way we can place multiple equations in different modules without problems. 2) Normal form declarations. AA allows a declaration that a particular tree is in normal form and so not reducible. This is essentially a left-hand side without a right-hand side. This is particularly important in local definitions; it allows a form to be locally normal without worrying about whether it's globally normal as well due to a conflict between local and global names. 3) Concurrent reduction. AA trees can be placed in unordered tree bags. A tree bag is in normal form iff the trees in it are, and if any of them are not, they are reduced concurrently. Every tree is deemed to be in a bag called its container; the top-level tree is in a singleton container. Equations are extended to allow a bag of patterns on the left-hand side and a bag of results on the right-hand side. An equation cannot be applied (and is said to be blocked) until it is able to match and atomically remove normal-form trees from the container of the tree it is being applied to. This is equivalent to a Linda IN. After the equation is applied, the bag of results is instantiated and placed into the same container. This is equivalent to a Linda OUT. I'd be interested to hear comments on these ideas, and I'll be happy to provide more details. AA is documented at http://wouter.fov120.com/files/lang/aardappel/thesis.pdf , specifically pp. 7-17 (tree rewriting, Linda), pp. 28-38 (Aardappel), pp. 44-57 (design decisions), pp. 61-71 (formal semantics), pp. 85-89 (example). These page numbers are the hard-copy ones; add 3 for the PDF page numbers.) The 1992 Q paper is cited. -- A witness cannot give evidence of his John Cowan age unless he can remember being born. jc...@re... --Judge Blagden http://www.ccil.org/~cowan |
From: <Dr....@t-...> - 2004-05-16 15:28:40
|
Hi, as you may have noticed, Q-Midi 1.15 and Q-Synth 1.0 have been released. Q-Midi 1.15 includes a face-lifted Q-Midi player, a new Q-Midi "control center" (Linux only) and support for the new msAlsaSeq MidiShare/ALSA driver on Linux. Q-Synth 1.0 is the first release of the new OSC/SuperCollider interface which lets you control sound synthesis programs from Q, something all computer music buffs will enjoy. ;-) As a sidenote, the mailing list archive seems to lag behind several weeks now. Apparently that is due to SourceForge testing a new ML archiving system. I just hope that it will be fixed soon. Have a nice Sunday, Albert -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikwissenschaft.uni-mainz.de/~ag |