q-lang-users Mailing List for Q - Equational Programming Language (Page 61)
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: <mip...@ya...> - 2004-02-03 05:59:59
|
(OK, more agressive formatting.) Albert Graef wrote: > Julian Fondren wrote: > > ;; OpenBSD [...] > > > > Everything compiles fine expect for > > modules/clib/clib.c -- there I had to add an > > "#include <unistd.h>", since something > > apparently failed to define HAVE_UNISTD_H > > That's *really* strange. Could you please check the > generated config.h (in the toplevel directory of the > sources), to see if it defines HAVE_UNISTD_H? It does. With more investigation, the compilation only falls apart when the '#include <unistd.h>' comes *after* the '#define _XOPEN_SOURCE 500' in modules/clib/clib.c > Hmm, I tried to run your example, but somehow I > can't get it to work, the accept call in the server > always fails with EINVAL for me. Here's the call > sequence I used for initializing the server and the > client, I guess that's correct so far? Maybe I'm > missing something obvious? > > def S = server 5001 > def C = socket AF_INET SOCK_STREAM 0 > connect C ("localhost",5001) Huh, this seems to work with my current version. bwrite C (bytestr "Hello!\n") bstr (bread C 64) (though I used netcat to test it, for some reason) > Anyway, the problem with your code is that you don't > keep the handle for the echo_loop thread. You see, > the thread will be canceled automatically as soon as > the thread handle T is garbage collected. Here this > happens when server_loop FD tail-reduces to itself > (the local T variable is not used anymore and its > value is therefore thrown away). The solution is to > keep track of the thread handles, either in the > server_loop function or in echo_loop itself. The > latter solution would be something like the > following: Ah, OK. I'd actually thought of doing that, but didn't want to change my design until I understood why what I had failed. Thanks. [snip] > (As you'll notice I changed the second server_loop > rule to track down the cause of the mysterious > accept failures I encountered. Also note that you > don't have to explicitly cancel this_thread on exit > from echo_loop, in the second rule for echo_loop, as > the thread will be terminated anyway when the loop > ends.) > > Can you try whether this works for you? It did =) I ended up with a more nicely formatted version of the following: server P = thread (server_loop FD) where FD:Int = socket AF_INET SOCK_STREAM 0, () = bind FD ("localhost",P), () = listen FD 4; = perror "server" otherwise; server_loop FD = server_loop FD where (C:Int,(H,P)) = accept FD, _ = thread (echo_loop this_thread C H P), _ printf "Got connection from: %s:%d\n" (H,P); = server_loop FD otherwise where _ = perror "server(accept)"; echo_loop T FD H P = echo_loop T FD H P where MSG = recv FD 0 4096, () = echo FD MSG (bcmp MSG (bytestr "")); = closesocket FD otherwise where _ = printf "Lost connection from: %s:%d\n" (H,P); echo FD MSG 0 = error; echo FD MSG _ = () where _ = send FD 0 MSG; > Cheers, > Albert ________________________________________________________________________ BT Yahoo! Broadband - Free modem offer, sign up online today and save £80 http://btyahoo.yahoo.co.uk |
From: ww <wwa...@ea...> - 2004-02-02 23:54:10
|
Hi, I've been exploring Q recently and I've noticed that "and then" doesn't seem to run in constant space. From it's definition (in the docs), I was expecting that it could reuse the stack frame but that doesn't seem to be the case. Am I missing something? I'm running QPad version 5.0. Thanks, Walt My Example; randoml N:Int = randoml [] N; randoml L:List N:Int = randoml (push L random) (N-1) if N>0; = L otherwise; % C:\Documents and Settings\ww\My Documents\randoml.q ==> def A=randoml 10 ==> def B=randoml 100 ==> (A=A) true ==> stats 0 secs, 31 reductions, 41 cells ==> (B=B) true ==> stats 0 secs, 301 reductions, 401 cells ==> version "5.0" |
From: <Dr....@t-...> - 2004-02-02 16:47:34
|
Julian Fondren wrote: > ;; OpenBSD [...] > > Everything compiles fine expect for > modules/clib/clib.c > -- there I had to add an "#include <unistd.h>", since > something > apparently failed to define HAVE_UNISTD_H That's *really* strange. Could you please check the generated config.h (in the toplevel directory of the sources), to see if it defines HAVE_UNISTD_H? > (I also get many complaints about including malloc.h > instead of stdlib.h, > but nothing seems hurt by this.) Yes, I noticed this on older (4.x) FreeBSD systems, too. I actually think that it's OpenBSD's fault, and since it's harmless I probably won't do anything about it. > ;; threading > [original source snipped] > I've already uglified it a bit, trying to figure out > the problem. On my > machine I get the "Got connection from: ..." message > on a connection, > and on subsequent connections, but the (thread > (echo_loop C)) never seems > to happen. I know that everything but the threading > works, because I > had this server running in exactly this form before I > started trying to > make it multithreaded. Hmm, I tried to run your example, but somehow I can't get it to work, the accept call in the server always fails with EINVAL for me. Here's the call sequence I used for initializing the server and the client, I guess that's correct so far? Maybe I'm missing something obvious? def S = server 5001 def C = socket AF_INET SOCK_STREAM 0 connect C ("localhost",5001) Anyway, the problem with your code is that you don't keep the handle for the echo_loop thread. You see, the thread will be canceled automatically as soon as the thread handle T is garbage collected. Here this happens when server_loop FD tail-reduces to itself (the local T variable is not used anymore and its value is therefore thrown away). The solution is to keep track of the thread handles, either in the server_loop function or in echo_loop itself. The latter solution would be something like the following: server_loop FD = printf "Got connection from: %s:%d\n" (H,P) || server_loop FD where (C:Int,(H,P)) = accept FD, _ = thread (echo_loop this_thread C); = perror "server(accept)" || server_loop FD otherwise; echo_loop T FD = printf "(loop %d)\n" FD || echo_loop T FD where MSG = recv FD 0 4096, () = echo FD MSG (bcmp MSG (bytestr "")); = closesocket FD otherwise; (As you'll notice I changed the second server_loop rule to track down the cause of the mysterious accept failures I encountered. Also note that you don't have to explicitly cancel this_thread on exit from echo_loop, in the second rule for echo_loop, as the thread will be terminated anyway when the loop ends.) Can you try whether this works for you? Cheers, Albert -- Dr. Albert Gr"af Email: Dr....@t-..., ag...@mu... WWW: http://www.musikwissenschaft.uni-mainz.de/~ag |
From: <Dr....@t-...> - 2004-02-02 03:02:22
|
Hi, I just updated all the Q 5.0 packages on SourceForge, in order to fix a silly bug in clib::system which, unfortunately, I noticed only after the original release on Jan 31. So, if you experience crashes with the system function, you might wish to upgrade. (As usual, give the mirrors some time to catch up, the new files have just been released a few minutes ago.) Sorry for the inconvenience. -- Dr. Albert Gr"af Email: Dr....@t-..., ag...@mu... WWW: http://www.musikwissenschaft.uni-mainz.de/~ag |
From: <mip...@ya...> - 2004-02-02 02:14:35
|
(Sorry in advance for any bizarre formatting -- still not used to yahoo's email system.) ;; OpenBSD ./configure --with-x --with-gmp="-lgmp -L/usr/local/lib" \ --with-gmp-includes=-I/usr/local/include --with-rl --with-pthread \ --with-tk="-ltcl83 -ltk83 -L/usr/local/lib" \ --with-tk-includes=-I/usr/local/include/tcl8.3 \ -I/usr/local/include/tk8.3 Everything compiles fine expect for modules/clib/clib.c -- there I had to add an "#include <unistd.h>", since something apparently failed to define HAVE_UNISTD_H (I also get many complaints about including malloc.h instead of stdlib.h, but nothing seems hurt by this.) ;; threading I just started programming with Q last night, so perhaps I miss something obvious (I certainly don't understand all of Q's 'rewriting rules' semantics, though these fascinate me.) I've tried to implement a simple concurrency-oriented 'echo' server, with a thread per client, and have had a great of trouble with this. (With Q using OS-level POSIX threads, I know that this design won't work in the long run anyway -- I just wanted to see how it'd work, and the Q manual's UDP code inspired me.) My code: server P = thread (server_loop FD) where FD:Int = socket AF_INET SOCK_STREAM 0, () = bind FD ("localhost",P), () = listen FD 4; = perror "server" otherwise; server_loop FD = printf "Got connection from: %s:%d\n" (H,P) || server_loop FD where (C:Int,(H,P)) = accept FD, T = thread (echo_loop C); = writes "Loop.\n" || server_loop FD otherwise; echo_loop FD = printf "(loop %d)\n" FD || echo_loop FD where MSG = recv FD 0 4096, () = echo FD MSG (bcmp MSG (bytestr "")); = closesocket FD || cancel this_thread otherwise; echo FD MSG 0 = error; echo FD MSG _ = yield || send FD 0 MSG || (); I've already uglified it a bit, trying to figure out the problem. On my machine I get the "Got connection from: ..." message on a connection, and on subsequent connections, but the (thread (echo_loop C)) never seems to happen. I know that everything but the threading works, because I had this server running in exactly this form before I started trying to make it multithreaded. So what do I miss? ________________________________________________________________________ BT Yahoo! Broadband - Free modem offer, sign up online today and save £80 http://btyahoo.yahoo.co.uk |
From: <Dr....@t-...> - 2004-02-01 01:54:18
|
Hi, Q 5.0 has just been released, which features the C->Q interface, Apache module and Curl interface I talked about in a previous mail. There are also some improvements and bug fixes in the compiler and the debugger. If you upgrade to this version, please make sure to update the add-on modules to the latest versions as well (Q-Audio 1.3, Q-Midi 1.13, Q-Graph 1.3). You'll also have to recompile your own external modules, since the module API has changed. Enjoy! -- Dr. Albert Gr"af Email: Dr....@t-..., ag...@mu... WWW: http://www.musikwissenschaft.uni-mainz.de/~ag |
From: <Dr....@t-...> - 2004-01-18 19:07:07
|
Just a quick update: The C->Q interface (libqint) and a first application, the Q Apache module mod_q, are now in Q CVS. The Apache module currently requires Apache2 and the preworker MPM; Apache 1.3 support should follow soon. -- Dr. Albert Gr"af Email: Dr....@t-..., ag...@mu... WWW: http://www.musikwissenschaft.uni-mainz.de/~ag |
From: <Dr....@t-...> - 2004-01-10 14:23:27
|
First, I'd like to say hello to all newcomers on this list, and a happy new year to everyone! As you probably noticed, the holidays have been quite busy for me, but now that Q 4.6 is out of the door, along with Q-Audio 1.2 and Q-Midi 1.12, and the new website at sf.net is up, too, I can start working on the next Q release. In case anyone is wondering what I'm up to next, here's my current roadmap for the next release, which concentrates on the C<->Q interface and web programming facilities: - Add some stuff to libq (the Q->C interface) which is used in several modules, specifically: mkuint, isuint, mkbool, isbool. This is already in CVS. Unfortunately, this required a change of the binary API, so existing modules (including q-audio and q-midi) have to be recompiled if you use the latest CVS version. - Add a C->Q interface (libqint). This will allow the interpreter to be used as an embedded macro or programming language or as a rewriting engine in C/C++ applications, which is something several users have asked for. If you are interested in this, you can get a first impression of how the new interface will look like by checking out src/qint.h in Q cvs. - Once this is finished, I'll go about implementing a Q Apache module. This will allow Q to be used for server-side scripting of HTML content in the same way as, e.g., Perl, Python and PHP. Please see http://modules.apache.org/ for more information. - Add a libcurl module. This will facilitate the transferring of files with URL syntax using different protocols. See http://curl.haxx.se/. When all that is finished (hopefully in the next 2-3 months), after the release of Q 4.7, I think I'm going to focus again on the multimedia library. Specifically, I started making plans for a new Q-Video module which will allow access to different video file formats. As always, your comments are appreciated. :) Do you have anything to add to the above list? Any other items on your personal Q wishlist? Let me know! Cheers, Albert -- Dr. Albert Gr"af Email: Dr....@t-..., ag...@mu... WWW: http://www.musikwissenschaft.uni-mainz.de/~ag |
From: Albert G. <ag...@mu...> - 2004-01-07 15:09:31
|
Hi, Daniel, (I hope you don't mind that I'm cc'ing this to the new q-lang-users list, see http://lists.sourceforge.net/lists/listinfo/q-lang-users, as your questions might be relevant to other users.) > -does (or can) Q remember past evaluations to speed > up future evaluations. For instance, if I ask Q to rewrite ' f(a, b) ', > and then I ask Q to rewrite ' f(c, f(a, b)) ', will it remember that > it had already rewritten ' f(a, b) '? The interpreter doesn't do this automatically, but it's easy to implement it yourself. For an example, please take a look at the "hashed fib function" in the section on expression references in the Clib chapter of the manual. The 'hashed' function in that example is fairly generic and should be applicable to your problem, too. > -can Q be integrated into a C/C++ project. A large part > of my compiler would be writtin in C++. Can Q be linked > directly into a C++ program? Is there an C->Q API > (so I don't mean using C functions from Q, as documented > in appendix C of the Q programming manual, but rather using > Q functions from C). Not in a direct manner, at present. But it's one of the next things on my TODO list, as several ppl have already requested just that, and now I also need it myself, in order to implement a Q module for the Apache web server. > -would it be possible to write a Q -> C translator. So give > a set of .q files, 'compile' them into C? That's a big project. ;-) I've considered it, but it's hard to do this right. At the moment I'm just too busy with the Q library and other stuff to embark on this. So, if you really need a compiled functional language then I'm afraid I must direct you to the competition for now. ;-) Probably Ocaml would be your best bet (www.ocaml.org). Cheers, Albert -- Dr. Albert Gr"af Dept. of Music-Informatics Johannes Gutenberg-University Mainz, 55099 Mainz, Germany Phone: +49 6131 39-25142, Fax: -24717 Email: ag...@mu..., Dr....@t-... WWW: http://www.musikwissenschaft.uni-mainz.de/~ag |
From: <Dr....@t-...> - 2003-12-10 20:57:57
|
Welcome to the q-lang-users mailing list. This list is for discussing all issues related to using Q. Here you can post all your questions and comments concerning the Q interpreter, the standard library, the add-on modules, etc. If you have any problems using this list please contact me using one of the addresses given below. -- Dr. Albert Gr"af Email: Dr....@t-..., ag...@mu... WWW: http://www.musikwissenschaft.uni-mainz.de/~ag |