From masterofquestions Fri Feb 1 05:06:27 2008 From: masterofquestions (db) Date: Thu, 31 Jan 2008 23:06:27 -0500 Subject: [erlang-questions] Mnesia Erlang OTP Application sharing Schema/tables In-Reply-To: <479EFE8F.2090406@ericsson.com> References: <1218d6a50801282037j40fbfdees54232fa485300da8@mail.gmail.com> <479EFE8F.2090406@ericsson.com> Message-ID: <1218d6a50801312006l6f214661x5384b4f1b0ee499d@mail.gmail.com> Do I create another separate application that does mnesia schema/table initilization and have that mnesia initializing application start first on nd1 or nd2? If so, then the following steps would be: 1) start the mnesia initilization application on nd1 or nd2. 2) Then, I use the builder to create separate .rel and other files, and load app1 on ndA without regards to the condition of mnesia shema/tables? 3) Repeat the step 2, but with app1 with ndB. Am I right so far with this kind of thinking? Or is it better to have supervisor starting mnesia initialization first on either nd1 or nd2 and then app1 on ndA and app1 on ndB. No simple answer, this is getting complicated. Anyone have a sample make file that uses builder to create .app .rel .boot .script files? There seem to be link to the make in the old email archive: http://www.erlang.org/pipermail/erlang-questions/2004-May/012295.html. But the link for the make file doesn't seem to work. I ran the builder, very handy tool indeed. But, I didn't understand the BUILDER_OPTIONS file. Is there sample BUILDER_OPTIONS template file? russ On Jan 29, 2008 5:23 AM, Ulf Wiger (TN/EAB) wrote: > > My preference is to have an explicit 'install' phase, > where the schema and tables are created. > > The 'builder'(*) tool offers a simple way to do this, > in that it creates a start script with the start > commands removed for all apps except kernel and > stdlib (it then slaps a .load extension on it). > This way, you can get all the paths and environment > variables set correctly, and then create the schema > and tables safely. > > The main point is that the applications should be able > to expect that the tables have been created in advance, > and not engage in complex decision-making logic to > try to figure out why they're not there. > > BR, > Ulf W > > (*) This was a tool that I built long ago to test the > idea of incrementally building boot scripts for each > application, as the system grew. It's in jungerl. > > > > db skrev: > > Hello, > > > > My scenario is as follows: > > > > mnesia is distributed and table fragmented(on nd1, nd2). Now, when > > application started on ndA 1st and on ndB 2nd. App on ndA,ndB will > > access same mnesia schema/tables. I create the schema and table when > > application is started ndA. Now, I start same application on ndB and > > have it not create the schema/tables. > > > > App on ndA, ndB are not distributed but two of the same app running on > > both nodes (ndA, ndB). > > > > e.g similar to two web app instances, on two different machine, > > connecting to mysql cluster. > > > > if app on ndA or ndB crash and then restared, how do I make the > > Application so that it does not try to recreate the schema/tables. Is > > there a way to check if schema/tables are there, so you don't do any > > schema/table recreation? > > > > In erlang otp design, you start the 1st app on ndA which creates the > > schema and table, now you take this same code and run it on ndB. Now > > app on ndB will try to create the schema/table. How to stop this > nonsense? > > > > I don't want to cluster app on ndA and ndB together. app on each node > > reads a slightly different config file, but access the same > schema/tables. > > > > thanks, > > russ > > > > > > ------------------------------------------------------------------------ > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions > > http://www.erlang.org/mailman/listinfo/erlang-questions > -- rk -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080131/915734a3/attachment.html From andreas.hillqvist Fri Feb 1 08:13:23 2008 From: andreas.hillqvist (Andreas Hillqvist) Date: Fri, 1 Feb 2008 08:13:23 +0100 Subject: [erlang-questions] Newbie: Problem TCP connection erlang-python In-Reply-To: <200801311737.m0VHbhCq079947@pluto.hedeland.org> References: <8268eea30801310835q6af87136p2d4d52e906d6cc31@mail.gmail.com> <200801311737.m0VHbhCq079947@pluto.hedeland.org> Message-ID: <8268eea30801312313k7e7bd0c8m373faeec71697f1e@mail.gmail.com> Thank you for this information. I was wondering what the default value was. It was not clear to me when a read the documentation for inet and gen_tcp moduel. But i guess that is because that the default values can be changed? Regards Andreas Hillqvist 2008/1/31, Per Hedeland : > "Andreas Hillqvist" wrote: > > > >Just a small note: > >Both raw and 0 stand for that no packaging is done. > >So there should be no difference between: > >{packet, 0} or {packet, raw} > > And furthermore it's the default anyway (what else would it be?:-). > However, to Gerald, that type of code won't work in the general case - > you have no guarantee that a chunk of data you send down a TCP socket > comes out as one chunk at the other end => use one of the {packet, N} > (N /= 0) options (with the equivalent change at the Python side, of > course). > > --Per Hedeland > From ingela Fri Feb 1 09:14:43 2008 From: ingela (Ingela Anderton Andin) Date: Fri, 01 Feb 2008 09:14:43 +0100 Subject: [erlang-questions] Dealing with public/private keys stored in*.pem files In-Reply-To: References: Message-ID: <47A2D4F3.30308@erix.ericsson.se> erlang-questions-request wrote: >> 2008/1/31, Jakob Cederlund : >> >> Hi, >> there is not yet a public api for this in OTP. However, the undocumented, >> unsupported function ssl_pkix:decode_rsa_keyfile/2 does just this. It reads >> a .pem keyfile and returns a record with exponent and modulus, and other >> fields. It is unsupported, so it might be moved (or even removed) in future >> releases of OTP. >> /Jakob >> Well as Niclas pointed out ssl_pkix:decode_rsa_keyfile/2 is a new function in ssl-3.9 that was released in r12b. An as Jakob has pointed out it is not part of a public API (and will not be in the future either, probably even the documented functions in ssl_pkix will become deprecated) , so even if you use it to solve your immediate problem I would not recommend it as long term solution. I can however offer you a long term solution and that is to use the new library application public_key that we are working on right now. I can not make any promises on exactly when it will be released but it is coming in a near future so look out for it. Regards Ingela -OTP team From j.bhanot Fri Feb 1 09:23:23 2008 From: j.bhanot (J Bhanot) Date: Fri, 1 Feb 2008 13:53:23 +0530 Subject: [erlang-questions] Problems in erl_accept In-Reply-To: <14f0e3620801311031y7705ba76l81776d4803222f02@mail.gmail.com> Message-ID: thanks Gleb... I had to publish my C node and then it was being shown in Erlang node by executing this command: nodes(hidden). but now when i want it to accept connection - I have added following code.. memset((char *) &remote, 0, sizeof(remote)); if(erl_accept(sockfd, &remote) == ERL_ERROR) erl_err_sys("accept"); where remote is declared at the top as ErlConnect remote; and sockfd is the same socket which I have used in connecting to Erlang node, binding/listening and have made this port as non blocking as well but now when I execute code for C node.. I am getting following error: accept: Bad file descriptor Any ideas on that.. Regards, jb ____________________________________________ Gleber 02/01/2008 12:01 AM To "J Bhanot" , erlang-questions cc Subject Re: [erlang-questions] Erlang C Communication - process completes but nodes are not connected Hello. This is my first post to this list, so i'm sorry for any mistakes :) IIRC, C nodes are hidden nodes, hence net_adm:world() will not show them. Use nodes(hidden). to list hidden nodes. Regards, Gleb Peregud On 1/31/08, J Bhanot wrote: > Hi, > > I am using C node as client > [] > > #include > #include > #include > #include > #include > #include > #include > > #include "erl_interface.h" > #include "ei.h" > > #define PORT 6666 > > int sockfd, epmdfd; > > main() > { > > struct in_addr addr; > erl_init(NULL, 0); > > printf("Initializing ..."); > if(!erl_connect_init(69, "SFEWRG34AFDSGAFG35235", 0)) > { > printf("\nerror in initialisation"); > erl_err_sys("erl_connect_init"); > printf("\nafter error in init"); > } > printf(" done.\n"); > printf("node=%s, host=%s, alive=%s, creation=%d\n ", > erl_thisnodename(), erl_thishostname(), > erl_thisalivename(), erl_thiscreation()); > > > > > /*This is the short host name outgoing connect routine */ > printf("Connecting ..."); > usleep(5000); > getchar(); //for checking > if((sockfd = erl_connect("node1")) < 0) > > // if((sockfd = erl_connect("")) < 0) > { > printf("in error"); > erl_err_sys("erl_connect"); > } > printf("\nsock = %d\n", sockfd); > erl_err_sys("erl_connect"); > printf(" done.\n"); > > } > > [/code] > > and Erlang node as server 'node1' > > Steps to run Erlang node : > > > erl -setcookie SFEWRG34AFDSGAFG35235 -name node1 > Created a file named $HOME/.hosts.erlang having contents as > 'node1'. > 'c69'. > > > The output for c file upon execution is > > [root otp_src_R12B-0]# ./mytest > Initializing ... done. > node=c69, host=localhost, alive=c69, creation=0 > Connecting ... > sock = 3 > erl_connect: Success > > > but at erlang node when i execute the command : > (node1)8> net_adm:world(). > > i get the output as : > [] > > similalry > > (node1)9> nodes(). > [] > (node1)10> > > > That is no node is connected to it.... > > Now the point is C node has successfully connected .... > > Why Erlang node is not showing it as connected.... > > Do we need to register the C node with EPMD even when it is acting as a > client... > > Do we need to register Erlang node with EPMD as well and if yes the how do > we do that.. > > Note : I am using putty to connect to single linux server (FC8). > > Appreciate your help... > > Many Thanks, > > jb > > > > > > ____________________________________________ > =====-----=====-----===== > Notice: The information contained in this e-mail > message and/or attachments to it may contain > confidential or privileged information. If you are > not the intended recipient, any dissemination, use, > review, distribution, printing or copying of the > information contained in this e-mail message > and/or attachments to it are strictly prohibited. If > you have received this communication in error, > please notify us by reply e-mail or telephone and > immediately and permanently delete the message > and any attachments. Thank you > > > -- Gleb Peregud http://gleber.pl/ "Only two things are infinite, the universe and human stupidity, and I'm not sure about the former." -- Albert Einstein ForwardSourceID:NT0000E136 =====-----=====-----===== Notice: The information contained in this e-mail message and/or attachments to it may contain confidential or privileged information. If you are not the intended recipient, any dissemination, use, review, distribution, printing or copying of the information contained in this e-mail message and/or attachments to it are strictly prohibited. If you have received this communication in error, please notify us by reply e-mail or telephone and immediately and permanently delete the message and any attachments. Thank you -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080201/d16a25c0/attachment-0001.html From hakan Fri Feb 1 10:07:18 2008 From: hakan (Hakan Mattsson) Date: Fri, 1 Feb 2008 10:07:18 +0100 (CET) Subject: [erlang-questions] deleting records from a ram_copies table in mnesia In-Reply-To: <20080130194726.GE28231@vailsys.com> References: <653769.11660.qm@web53108.mail.re2.yahoo.com> <20080130194726.GE28231@vailsys.com> Message-ID: On Wed, 30 Jan 2008, Rick Pettit wrote: RP> > I would like to delete some records froma ram_copies RP> > table in mnesia, but the mnesia:delete({Tab,Key}) RP> > fails as the table doesn't exist on the disc...Is RP> > there any workaround to use the ram table in mnesia RP> > and delete the table or its records. RP> RP> RP> Are you sure the table exists on the node you are calling mnesia:delete/1 on? RP> RP> I suspect it doesn't exist on disc or in ram if you are getting a no_exists error. You get no_exists when the table is not accessible on that node. It may be several reasons for this: - The table does not exist (there is no such table in the local schema). - The table exists but is not yet readable at the local node. You should always invoke mnesia:wait_for_tables/2 in order to ensure that the table is accessible before you try to access it. Even if you do not have a local replica of the table you should use mnesia:wait_for_tables/2. /H?kan From chandrashekhar.mullaparthi Fri Feb 1 11:21:23 2008 From: chandrashekhar.mullaparthi (Chandru) Date: Fri, 1 Feb 2008 10:21:23 +0000 Subject: [erlang-questions] Mnesia Erlang OTP Application sharing Schema/tables In-Reply-To: <1218d6a50801312006l6f214661x5384b4f1b0ee499d@mail.gmail.com> References: <1218d6a50801282037j40fbfdees54232fa485300da8@mail.gmail.com> <479EFE8F.2090406@ericsson.com> <1218d6a50801312006l6f214661x5384b4f1b0ee499d@mail.gmail.com> Message-ID: On 01/02/2008, db wrote: > Do I create another separate application that does mnesia schema/table > initilization and have that mnesia initializing application start first on > nd1 or nd2? > One option is to do this. Installation phase ============== * Startup nd1 and nd2 by hand. i.e erl -sname nd1 erl -sname nd2 * Create the schema and the tables required * Shutdown the nodes Normal running phase ================== * Start up the full node. Applications assume that tables have been created. If not, they crash and burn. I used this strategy for a long time but got tierd of the two phase process. So I built a generic app which figures out if tables have already been created. If not it creates the required tables (or copies them from another node in the schema). Chandru From jakob Fri Feb 1 12:09:36 2008 From: jakob (Jakob Cederlund) Date: Fri, 01 Feb 2008 12:09:36 +0100 Subject: [erlang-questions] help: Erlang MIDI driver for MAC OS X In-Reply-To: <6a36e7290801210937n2d1849f8i8fce91a9018048a0@mail.gmail.com> References: <400A6F0E-01D7-4D1D-9D38-9CDAE51F4B11@gmail.com> <9b08084c0801210629g5185a512kdd1eb3d243c5a22f@mail.gmail.com> <6a36e7290801210937n2d1849f8i8fce91a9018048a0@mail.gmail.com> Message-ID: <47A2FDF0.1000801@erix.ericsson.se> Hi! I've written a simple coremidi-driver for erlang, but it's almost three years ago, and it's 100% uncommented, undocumented code. If anyone wants it, I can clean it up and send it over. Very simple stuff though: just sending and receiving timed Midi data. BTW, CoreAudio, while not really nice, is by far the nicest audio API I've used, and I've used several. (Try doing music on a Wintel machine, if you have strong nerves =). It's hard to program and even harder to setup.) Having a /dev/midi would be nice for playing around and testing simple stuff, and probably quite pointless for all other purposes. /Jakob PS I wrote the driver initially as an example for the OTP docs, but dropped it in favour of the postgres-driver, since the latter is cross-platform and simpler. I did use it though, to test some simple music-related things, like arpeggiators and quantizing of real-time midi-data. Erlang is nice for those kind of hacks, and midi:play is more rewarding than io:format. =) PPS Everything is not invented in UNIX... thank goodness! Bob Ippolito wrote: > On Jan 21, 2008 6:29 AM, Joe Armstrong wrote: > >> Thanks - I'd discovered this :-) >> >> I have actually made great progress after about 9 hours of searching >> and messing around suddenly things >> bust into life. >> >> I have now made a primitive OS-X midi driver - so now I can both send >> and receive real-time midi events >> and make horrible noises. >> >> The interesting thing is that this really does bring home to me how >> appallingly difficult it is to write even simple >> code today. >> > > Well, the reason Apple's CoreAudio APIs look like that are because > they're designed to have *very* precise timing, where you wouldn't be > able to do that properly over a file-like device. The APIs are a pain > in the ass and it sucks when you don't need that but that's why it's > designed that way. I think that the CoreAudio stuff lives in the > real-time parts of the kernel so when you get a callback it's at a > very high priority and you're not even supposed to allocate memory or > anything that might interrupt. > > -bob > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080201/9903bea8/attachment.html From j.bhanot Fri Feb 1 13:05:41 2008 From: j.bhanot (J Bhanot) Date: Fri, 1 Feb 2008 17:35:41 +0530 Subject: [erlang-questions] Problems in erl_accept In-Reply-To: <14f0e3620802010352t53073c7bx6d8ab9391b78b15@mail.gmail.com> Message-ID: thanks again Gleber... I have placed problem of accept at lower priority on my stack as of now... Now, I am trying to send the a simple "hello world" from my C node to Erlang node --- I have come across 2 ways to do that - erl send(fd, to, msg) where to is an Erlang term containing the Pid of the intended recipient of the message. Now the query here is is this to PID of my Erlang node (same PID which we get by doing ps aux | grep "erlangnode") or this is some other PID and if this is PID(int) which i get by grep then how do I convert into ETerm (think that should be simple, but owing to fact that I am a newbie in Erlang - finding it bit difficult at this moment :-() Second way to send message is: erl reg send(fd, to, msg) in which to is a string containing the registered name of the intended recipient of the message. Now question is do i need to regsiter my Erlang node... I have tried doing so by following commands: P1 = spawn(fun() -> receive _ -> ok end end). global:register_name(test, P1). global:registered_names(). [test] Now, I assume that test is regsitered name for the node... and have tried if(erl_reg_send(sockfd, "test", cmsg) == 0) but this thing is not working - - is there any other way of registering the Erlang node and whom with this node regsiter (EPMD???) Thanks and Regards, jb Gleber 02/01/2008 05:22 PM To "J Bhanot" cc Subject Re: Problems in erl_accept Sorry. I've never created any C node for erlang, though I don't know what is the source of the error... Hence You should wait for answers from more experienced erlangers from the mailing list :) But my intuition says, that problem is probably in sockfd, since it is the only socket file descriptor ought to be correct :) Good luckwith Erlang :) It is fascinating language! Regards, Gleb Peregud On 2/1/08, J Bhanot wrote: > thanks Gleb... > > I had to publish my C node and then it was being shown in Erlang node by > executing this command: > > nodes(hidden). > > but now when i want it to accept connection - I have added following > code.. > > memset((char *) &remote, 0, sizeof(remote)); > if(erl_accept(sockfd, &remote) == ERL_ERROR) > erl_err_sys("accept"); > > > where remote is declared at the top as > > ErlConnect remote; > > and sockfd is the same socket which I have used in connecting to Erlang > node, binding/listening and have made this port as non blocking as well > > but now when I execute code for C node.. > > I am getting following error: > > accept: Bad file descriptor > > Any ideas on that.. > > Regards, > jb > > ____________________________________________ > > > > Gleber > 02/01/2008 12:01 AM > > To > "J Bhanot" , erlang-questions > cc > > Subject > Re: [erlang-questions] Erlang C Communication - process completes but > nodes are not connected > > > > > > > Hello. > > This is my first post to this list, so i'm sorry for any mistakes :) > > IIRC, C nodes are hidden nodes, hence net_adm:world() will not show > them. Use nodes(hidden). to list hidden nodes. > > Regards, > Gleb Peregud > > On 1/31/08, J Bhanot wrote: > > Hi, > > > > I am using C node as client > > [] > > > > #include > > #include > > #include > > #include > > #include > > #include > > #include > > > > #include "erl_interface.h" > > #include "ei.h" > > > > #define PORT 6666 > > > > int sockfd, epmdfd; > > > > main() > > { > > > > struct in_addr addr; > > erl_init(NULL, 0); > > > > printf("Initializing ..."); > > if(!erl_connect_init(69, "SFEWRG34AFDSGAFG35235", 0)) > > { > > printf("\nerror in initialisation"); > > erl_err_sys("erl_connect_init"); > > printf("\nafter error in init"); > > } > > printf(" done.\n"); > > printf("node=%s, host=%s, alive=%s, creation=%d\n ", > > erl_thisnodename(), erl_thishostname(), > > erl_thisalivename(), erl_thiscreation()); > > > > > > > > > > /*This is the short host name outgoing connect routine */ > > printf("Connecting ..."); > > usleep(5000); > > getchar(); //for checking > > if((sockfd = erl_connect("node1")) < 0) > > > > // if((sockfd = erl_connect("")) < 0) > > { > > printf("in error"); > > erl_err_sys("erl_connect"); > > } > > printf("\nsock = %d\n", sockfd); > > erl_err_sys("erl_connect"); > > printf(" done.\n"); > > > > } > > > > [/code] > > > > and Erlang node as server 'node1' > > > > Steps to run Erlang node : > > > > > > erl -setcookie SFEWRG34AFDSGAFG35235 -name node1 > > Created a file named $HOME/.hosts.erlang having contents as > > 'node1'. > > 'c69'. > > > > > > The output for c file upon execution is > > > > [root otp_src_R12B-0]# ./mytest > > Initializing ... done. > > node=c69, host=localhost, alive=c69, creation=0 > > Connecting ... > > sock = 3 > > erl_connect: Success > > > > > > but at erlang node when i execute the command : > > (node1)8> net_adm:world(). > > > > i get the output as : > > [] > > > > similalry > > > > (node1)9> nodes(). > > [] > > (node1)10> > > > > > > That is no node is connected to it.... > > > > Now the point is C node has successfully connected .... > > > > Why Erlang node is not showing it as connected.... > > > > Do we need to register the C node with EPMD even when it is acting as a > > client... > > > > Do we need to register Erlang node with EPMD as well and if yes the how > do > > we do that.. > > > > Note : I am using putty to connect to single linux server (FC8). > > > > Appreciate your help... > > > > Many Thanks, > > > > jb > > > > > > > > > > > > ____________________________________________ > > =====-----=====-----===== > > Notice: The information contained in this e-mail > > message and/or attachments to it may contain > > confidential or privileged information. If you are > > not the intended recipient, any dissemination, use, > > review, distribution, printing or copying of the > > information contained in this e-mail message > > and/or attachments to it are strictly prohibited. If > > you have received this communication in error, > > please notify us by reply e-mail or telephone and > > immediately and permanently delete the message > > and any attachments. Thank you > > > > > > > > > -- > Gleb Peregud > http://gleber.pl/ > > "Only two things are infinite, the universe and human stupidity, and > I'm not sure about the former." > -- Albert Einstein > > ForwardSourceID:NT0000E136 > =====-----=====-----===== > Notice: The information contained in this e-mail > message and/or attachments to it may contain > confidential or privileged information. If you are > not the intended recipient, any dissemination, use, > review, distribution, printing or copying of the > information contained in this e-mail message > and/or attachments to it are strictly prohibited. If > you have received this communication in error, > please notify us by reply e-mail or telephone and > immediately and permanently delete the message > and any attachments. Thank you > > > -- Gleb Peregud http://gleber.pl/ "Only two things are infinite, the universe and human stupidity, and I'm not sure about the former." -- Albert Einstein ForwardSourceID:NT0000E186 =====-----=====-----===== Notice: The information contained in this e-mail message and/or attachments to it may contain confidential or privileged information. If you are not the intended recipient, any dissemination, use, review, distribution, printing or copying of the information contained in this e-mail message and/or attachments to it are strictly prohibited. If you have received this communication in error, please notify us by reply e-mail or telephone and immediately and permanently delete the message and any attachments. Thank you -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080201/f067e920/attachment-0001.html From sebastian.bello Fri Feb 1 13:50:52 2008 From: sebastian.bello (Sebastian Bello) Date: Fri, 01 Feb 2008 10:50:52 -0200 Subject: [erlang-questions] Passing parameters to a port driver In-Reply-To: <200801292140.m0TLeAd0025665@pluto.hedeland.org> References: <200801292140.m0TLeAd0025665@pluto.hedeland.org> Message-ID: <47A315AC.5000603@inswitch.us> Per, sorry but I didn't mention I was thinking about a linked-in driver; I read about extending the environment, but was wondering if it can be done by passing parameters; I guess the "char *buff" parameter on the C side must have that purpose. Sebastian- Per Hedeland escribi?: > Sebastian Bello wrote: > >> is there a way to pass parameters (maybe in the form of an Erlang term) >> to a port driver while creating it (open_port)? My understanding is that >> open_port launches the function >> static ErlDrvData driver_start(ErlDrvPort port, char *buff) >> >> on the port; what does "char *buff" contain? >> > > It's the complete Command string from open_port({spawn, Command}, ...) - > i.e. you can give that as "my_drv param1 param2" and the my_drv driver > will have its start() function invoked with that exact string as its > second argument (in C form of course:-). If you look at the > driver_entry(3) man page, the argument is called 'command', which > perhaps makes this a bit more obvious. > > --Per Hedeland > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > > __________ NOD32 2833 (20080129) Information __________ > > This message was checked by NOD32 antivirus system. > http://www.eset.com > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080201/5ca8aa14/attachment.html From alpar Fri Feb 1 13:58:13 2008 From: alpar (=?ISO-8859-1?Q?Alp=E1r_J=FCttner?=) Date: Fri, 01 Feb 2008 12:58:13 +0000 Subject: [erlang-questions] Newbie question: wait until an absolute time Message-ID: <1201870693.4624.61.camel@piko.site> Dear all, Is there any simple way in erlang to wait until a certain absolute time or to do something at a specific time in the future ? Namely, I'm looking for the absolute counterpart of the functions sleep(), send_after(), apply_after() and the 'after TimeOut ->'. Is it there anything like the opposite of now_to_universal_time(Now)? Anyway, is there any easy way to use a larger timeout than it is representable by a single integer? Thanks, Alpar From bengt.kleberg Fri Feb 1 14:22:31 2008 From: bengt.kleberg (Bengt Kleberg) Date: Fri, 01 Feb 2008 14:22:31 +0100 Subject: [erlang-questions] Newbie question: wait until an absolute time In-Reply-To: <1201870693.4624.61.camel@piko.site> References: <1201870693.4624.61.camel@piko.site> Message-ID: <1201872151.21702.10.camel@seasc0625.dyn.rnd.as.sw.ericsson.se> How large a timeout do you need? The maximum integer is Erlang is very large. bengt On Fri, 2008-02-01 at 12:58 +0000, Alp?r J?ttner wrote: > Dear all, > > Is there any simple way in erlang to wait until a certain absolute time > or to do something at a specific time in the future ? Namely, I'm > looking for the absolute counterpart of the functions sleep(), > send_after(), apply_after() and the 'after TimeOut ->'. > > Is it there anything like the opposite of now_to_universal_time(Now)? > > Anyway, is there any easy way to use a larger timeout than it is > representable by a single integer? > > Thanks, > Alpar > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions From kostis Fri Feb 1 14:26:01 2008 From: kostis (Kostis Sagonas) Date: Fri, 01 Feb 2008 15:26:01 +0200 Subject: [erlang-questions] Newbie question: wait until an absolute time In-Reply-To: <1201870693.4624.61.camel@piko.site> References: <1201870693.4624.61.camel@piko.site> Message-ID: <47A31DE9.5000000@cs.ntua.gr> Alp?r J?ttner wrote: > Dear all, > > ... > > Anyway, is there any easy way to use a larger timeout than it is > representable by a single integer? Yes. As timeout value you can also use the atom 'infinity' ;-) Seriously now, your question does not make much sense. Erlang has integers that can grow quite a bit: as much as the memory of your machine allows them to. In Erlang, integer values are not restricted to those that fit in 32 or 64 bits. So, you can pretty much use any integer you like. Kostis From mateuszb Fri Feb 1 14:29:13 2008 From: mateuszb (Mateusz Berezecki) Date: Fri, 1 Feb 2008 14:29:13 +0100 Subject: [erlang-questions] clarify: R12B0 weird gen_fsm behavior (is it a bug?) Message-ID: <66B14807-87B1-4C60-A989-FDE637F5C219@gmail.com> Hello list readers, I've encountered a weird gen_fsm behavior. This is an excerpt of a case clause which gets executed. The commented code is not compiled and not executed so having {next_state, 'JOINED', State1} goes into next state correctly. When I uncomment the code the FSM no longer goes into 'JOINED' state but remains in the current state. All of the functions in the commented code execute correctly and do not cause any abnormal termination of the process. Having commented out the code I was lucky enough to notice that the parent field in the #state{} record does not change to the new content as well !! What is happening? Am I doing something wrong or is it a bug? accepted -> % multicast_root(R, Children, Me), % update_siblings(R, Children), % ModState1 = Mod:parent_changed(Src, StateData, ModState), % ModState2 = case Root =:= R of % true -> ModState1; % false -> Mod:root_changed({Root, R}, StateData#state{root = R, parent = Src, % siblings = S, mod_state = ModState1}, ModState1) % end, State1 = StateData#state{root = R, parent = {Src,Socket}, siblings = S, mod_state = ModState}, {next_state, 'JOINED', State1#state{parent = {Src,Socket}}}; best regards, Mateusz Berezecki From alpar Fri Feb 1 14:45:11 2008 From: alpar (=?ISO-8859-1?Q?Alp=E1r_J=FCttner?=) Date: Fri, 01 Feb 2008 13:45:11 +0000 Subject: [erlang-questions] Newbie question: wait until an absolute time In-Reply-To: <18339.6737.681257.973144@antilipe.corelatus.se> References: <1201870693.4624.61.camel@piko.site> <18339.6737.681257.973144@antilipe.corelatus.se> Message-ID: <1201873511.4624.69.camel@piko.site> > Erlang integers don't have an upper limit. (underlying magic switches > to bignum representation). Thank you for the answer. This makes my life much easier! But then what is the reason why now() returns a tuple of three integers instead of just returning a single one? Regards, Alpar > > 1> 16#ffffFFFF + 1. > 4294967296 > 2> 16#fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff. > 2977131414714805823690030317109266572712515013375254774912983855843898524112477893944078543723575564536883288499266264815757728270805630975 > > Matt From chsu79 Fri Feb 1 14:52:08 2008 From: chsu79 (Christian S) Date: Fri, 1 Feb 2008 14:52:08 +0100 Subject: [erlang-questions] Newbie question: wait until an absolute time In-Reply-To: <47A31DE9.5000000@cs.ntua.gr> References: <1201870693.4624.61.camel@piko.site> <47A31DE9.5000000@cs.ntua.gr> Message-ID: On Feb 1, 2008 2:26 PM, Kostis Sagonas wrote: > Alp?r J?ttner wrote: > > Anyway, is there any easy way to use a larger timeout than it is > > representable by a single integer? > > Yes. As timeout value you can also use the atom 'infinity' ;-) > > Seriously now, your question does not make much sense. Erlang has > integers that can grow quite a bit: as much as the memory of your > machine allows them to. In Erlang, integer values are not restricted to > those that fit in 32 or 64 bits. So, you can pretty much use any integer > you like. I recall reading somewhere that the Timeout in receive ... after Timeout -> ... end. Has a 32/64bit maximum because of C-runtime-reasons. Maybe this was so once, or maybe my memory is faulty. If I knew that I would have to do something, such as turning on the VCR at 2009-12-24 19:00 for Karl Bertil Jonsons julafton on TV, I doubt I would just want to do "Timeout = VCRMillis - NowMillis, sleep(Timeout)" anyway. Instead I would limit my sleep to perhaps day-intervals, and close down to smaller intervals when I get closer to the absolute time. Such code would perhaps warrant a special function that does all that for me. From mateuszb Fri Feb 1 14:53:29 2008 From: mateuszb (Mateusz Berezecki) Date: Fri, 1 Feb 2008 14:53:29 +0100 Subject: [erlang-questions] clarify: R12B0 weird gen_fsm behavior (is it a bug?) In-Reply-To: <66B14807-87B1-4C60-A989-FDE637F5C219@gmail.com> References: <66B14807-87B1-4C60-A989-FDE637F5C219@gmail.com> Message-ID: <94DB21B8-A7C5-4054-BF18-C44318C158A7@gmail.com> On Feb 1, 2008, at 2:29 PM, Mateusz Berezecki wrote: > Hello list readers, > > I've encountered a weird gen_fsm behavior. > > This is an excerpt of a case clause which gets executed. > The commented code is not compiled and not executed so > having {next_state, 'JOINED', State1} goes into next state > correctly. When I uncomment the code the FSM no longer > goes into 'JOINED' state but remains in the current state. while trying to fix this behavior I came back to square one, where FSM does not change the states at all... so I have 2 states: - 'JOINING' - 'JOINED' I do the following at the end of the case mentioned in previous e-mail State1 = StateData#state{root = R, parent = {Src,Socket}, siblings = S, mod_state = ModState}, {next_state, 'some_random_state_XXXXX_AAAAA_1111111__222222_whatever', State1}; and this gets executed but FSM still does NOT change the state... It even does not complain about this non-existing state as it simply does not even attempts transitioning I am pretty puzzled with this one... The only thing I know is that the next event coming in in all cases is a {tcp, Socket, Data} one. Does it interfere with FSM in some way or something? can somebody please help me? Mateusz Berezecki From per Fri Feb 1 15:10:09 2008 From: per (Per Hedeland) Date: Fri, 1 Feb 2008 15:10:09 +0100 (CET) Subject: [erlang-questions] Passing parameters to a port driver In-Reply-To: <47A315AC.5000603@inswitch.us> Message-ID: <200802011410.m11EA9xe004844@pluto.hedeland.org> Sebastian Bello wrote: > >sorry but I didn't mention I was thinking about a linked-in driver; You said "driver" which was quite sufficient - that was the case that my answer described. (An external port program would (at least on *nix) get the Command in the argc/argv arguments to main()...) --Per From matthias Fri Feb 1 15:11:33 2008 From: matthias (Matthias Lang) Date: Fri, 1 Feb 2008 15:11:33 +0100 Subject: [erlang-questions] Newbie question: wait until an absolute time In-Reply-To: <1201873511.4624.69.camel@piko.site> References: <1201870693.4624.61.camel@piko.site> <18339.6737.681257.973144@antilipe.corelatus.se> <1201873511.4624.69.camel@piko.site> Message-ID: <18339.10389.514707.967045@antilipe.corelatus.se> Alp?r J?ttner writes: > But then what is the reason why now() returns a tuple of three integers > instead of just returning a single one? Maybe convenience. Possibly efficiency. Not impossible that it's just "because it seemed like a good idea at the time". Matthias From matthias Fri Feb 1 14:10:41 2008 From: matthias (Matthias Lang) Date: Fri, 1 Feb 2008 14:10:41 +0100 Subject: [erlang-questions] Newbie question: wait until an absolute time In-Reply-To: <1201870693.4624.61.camel@piko.site> References: <1201870693.4624.61.camel@piko.site> Message-ID: <18339.6737.681257.973144@antilipe.corelatus.se> Alp?r J?ttner writes: > Anyway, is there any easy way to use a larger timeout than it is > representable by a single integer? Erlang integers don't have an upper limit. (underlying magic switches to bignum representation). 1> 16#ffffFFFF + 1. 4294967296 2> 16#fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff. 2977131414714805823690030317109266572712515013375254774912983855843898524112477893944078543723575564536883288499266264815757728270805630975 Matt From dmitriid Fri Feb 1 15:15:25 2008 From: dmitriid (Dmitrii 'Mamut' Dimandt) Date: Fri, 01 Feb 2008 16:15:25 +0200 Subject: [erlang-questions] Newbie question: wait until an absolute time In-Reply-To: <1201873511.4624.69.camel@piko.site> References: <1201870693.4624.61.camel@piko.site> <18339.6737.681257.973144@antilipe.corelatus.se> <1201873511.4624.69.camel@piko.site> Message-ID: <47A3297D.70004@gmail.com> Alp?r J?ttner wrote: >> Erlang integers don't have an upper limit. (underlying magic switches >> to bignum representation). >> > > Thank you for the answer. This makes my life much easier! > But then what is the reason why now() returns a tuple of three integers > instead of just returning a single one? > > Because it's easier to match ;) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080201/69ebe7af/attachment.html From per Fri Feb 1 15:31:36 2008 From: per (Per Hedeland) Date: Fri, 1 Feb 2008 15:31:36 +0100 (CET) Subject: [erlang-questions] Newbie: Problem TCP connection erlang-python In-Reply-To: <8268eea30801312313k7e7bd0c8m373faeec71697f1e@mail.gmail.com> Message-ID: <200802011431.m11EVamY005301@pluto.hedeland.org> "Andreas Hillqvist" wrote: > >I was wondering what the default value was. >It was not clear to me when a read the documentation for inet and >gen_tcp moduel. I guess an explicit mention of "This is the default." after "No packaging is done." wouldn't hurt... >But i guess that is because that the default values can be changed? I think you should have seen enough of the OTP group's views on backwards compatibility to realize that a change that would break gazillions of applications for no good reason isn't all that likely to happen.:-) No, as I indicated, I think it isn't mentioned because it's "obvious" - what other "packaging" could possibly be default? Or with a slightly different view: If you don't give *any* 'packet' option, you will obviously not get any "packaging" - which is what 'raw' or 0 means. --Per From bekesa Fri Feb 1 14:54:03 2008 From: bekesa (Andras Georgy Bekes) Date: Fri, 01 Feb 2008 14:54:03 +0100 Subject: [erlang-questions] Newbie question: wait until an absolute time In-Reply-To: <47A31DE9.5000000@cs.ntua.gr> References: <1201870693.4624.61.camel@piko.site> <47A31DE9.5000000@cs.ntua.gr> Message-ID: <200802011454.03886.bekesa@sch.bme.hu> Hi, > > Anyway, is there any easy way to use a larger timeout than it is > > representable by a single integer? > In Erlang, integer values are not restricted > to those that fit in 32 or 64 bits. So, you can pretty much use any > integer you like. Unfortunately, this is not the case with timers. The doc (for the receive expression) states: "The highest allowed value is 16#ffffffff, that is, the value must fit in 32 bits." Well, on R11. I didn't check in R12. So, the question was wrong in some way. Georgy From mateuszb Fri Feb 1 15:31:21 2008 From: mateuszb (Mateusz Berezecki) Date: Fri, 1 Feb 2008 15:31:21 +0100 Subject: [erlang-questions] clarify: R12B0 weird gen_fsm behavior (is it a bug?) In-Reply-To: <94DB21B8-A7C5-4054-BF18-C44318C158A7@gmail.com> References: <66B14807-87B1-4C60-A989-FDE637F5C219@gmail.com> <94DB21B8-A7C5-4054-BF18-C44318C158A7@gmail.com> Message-ID: <42755CEB-7B15-4322-85C2-F76B44022F57@gmail.com> On Feb 1, 2008, at 2:53 PM, Mateusz Berezecki wrote: > problem solved. it was my bad not gen_fsm :) it helped to explain the problem to the list though :) M From chsu79 Fri Feb 1 15:31:37 2008 From: chsu79 (Christian S) Date: Fri, 1 Feb 2008 15:31:37 +0100 Subject: [erlang-questions] Newbie question: wait until an absolute time In-Reply-To: <18339.10299.623407.614330@antilipe.corelatus.se> References: <1201870693.4624.61.camel@piko.site> <47A31DE9.5000000@cs.ntua.gr> <18339.10299.623407.614330@antilipe.corelatus.se> Message-ID: On Feb 1, 2008 3:10 PM, Matthias Lang wrote: > > Instead I would limit my sleep to perhaps day-intervals, and close > > down to smaller intervals when I get closer to the absolute > > time. > > Realistically, that's a good idea, though day-intervals are rather > long if you ever want to load new code. That's a good point. If one has one very distant event, then one probably have more of them, and anything longer than a few hours should probably be stored in persistant storage and/or replicated or they will be forgotten when the power goes out and nobody checked that the diesel backup's start batteries were charged. That case alone makes this a larger project. Can crone.erl do this? From lenartlad Fri Feb 1 15:40:30 2008 From: lenartlad (Ladislav Lenart) Date: Fri, 01 Feb 2008 15:40:30 +0100 Subject: [erlang-questions] Newbie question: wait until an absolute time In-Reply-To: References: <1201870693.4624.61.camel@piko.site> <47A31DE9.5000000@cs.ntua.gr> Message-ID: <47A32F5E.2040006@volny.cz> Christian S wrote: > If I knew that I would have to do something, such as turning on the > VCR at 2009-12-24 19:00 for Karl Bertil Jonsons julafton on TV, I > doubt I would just want to do "Timeout = VCRMillis - NowMillis, > sleep(Timeout)" anyway. Instead I would limit my sleep to perhaps > day-intervals, and close down to smaller intervals when I get closer > to the absolute time. Such code would perhaps warrant a special > function that does all that for me. Hello, the reason behind your decision is to limit loss of precision, i.e. take potential time drifting into account? Ladislav Lenart From ulf.wiger Fri Feb 1 16:04:26 2008 From: ulf.wiger (Ulf Wiger (TN/EAB)) Date: Fri, 01 Feb 2008 16:04:26 +0100 Subject: [erlang-questions] Newbie question: wait until an absolute time In-Reply-To: <1201870693.4624.61.camel@piko.site> References: <1201870693.4624.61.camel@piko.site> Message-ID: <47A334FA.5050103@ericsson.com> Alp?r J?ttner skrev: > Dear all, > > Is there any simple way in erlang to wait until a certain absolute time > or to do something at a specific time in the future ? Namely, I'm > looking for the absolute counterpart of the functions sleep(), > send_after(), apply_after() and the 'after TimeOut ->'. > > Is it there anything like the opposite of now_to_universal_time(Now)? > > Anyway, is there any easy way to use a larger timeout than it is > representable by a single integer? As has been noted already, you cannot use timeout values that are larger than a smallint. A way to do it is to split the timeout into shorter waits, and then calculate the next timeout. Whether you want to wait in five-minute intervals or several hours at a time, is pretty much up to you. There are pros and cons with each. If the system idles a lot, you might not want to trigger activity unnecessarily; if it practically never idles, you might priorities readiness to handle things like unexpected jumps in the system time (when some operator changes the clock 8 hours back or forth in a running system...) A reasonably efficient diff between now() timestamps can look like this: diff({M,S,U}, {M,S1,U1}) -> ((S-S1) * 1000) + ((U-U1) div 1000); diff({M,S,U}, {M1,S1,U1}) -> ((M-M1)*1000000+(S-S1))*1000 + ((U-U1) div 1000). The main trick is to avoid creating bignums. At least this used to be quicker, when I benchmarked it years ago. That pesky erlang team tends to change things in ways that sometimes invalidates old assumptions, though. (: BR, Ulf W From per Fri Feb 1 16:07:04 2008 From: per (Per Hedeland) Date: Fri, 1 Feb 2008 16:07:04 +0100 (CET) Subject: [erlang-questions] Newbie question: wait until an absolute time In-Reply-To: <1201870693.4624.61.camel@piko.site> Message-ID: <200802011507.m11F74ug005997@pluto.hedeland.org> Alp?r J?ttner wrote: > >Is there any simple way in erlang to wait until a certain absolute time >or to do something at a specific time in the future ? Namely, I'm >looking for the absolute counterpart of the functions sleep(), >send_after(), apply_after() and the 'after TimeOut ->'. > >Is it there anything like the opposite of now_to_universal_time(Now)? > >Anyway, is there any easy way to use a larger timeout than it is >representable by a single integer? Others have already explained why you probably don't want to do it this way unless the future is "pretty near", but to answer the question without regard for that: 1> Now = calendar:local_time(). {{2008,2,1},{15,53,6}} 2> Future = {{2134,5,6},{17,42,0}}. {{2134,5,6},{17,42,0}} 3> Seconds = calendar:datetime_to_gregorian_seconds(Future) - calendar:datetime_to_gregorian_seconds(Now). 3984342534 4> timer:send_after(1000*Seconds, "Wake up!"). {ok,{5186220328800266,#Ref<0.0.0.40>}} (The timer module doesn't have the limit of 'receive after'.) --Per Hedeland From matthias Fri Feb 1 15:10:03 2008 From: matthias (Matthias Lang) Date: Fri, 1 Feb 2008 15:10:03 +0100 Subject: [erlang-questions] Newbie question: wait until an absolute time In-Reply-To: References: <1201870693.4624.61.camel@piko.site> <47A31DE9.5000000@cs.ntua.gr> Message-ID: <18339.10299.623407.614330@antilipe.corelatus.se> Christian S writes: > I recall reading somewhere that the Timeout in > > receive > ... > after Timeout -> > ... > end. > > Has a 32/64bit maximum because of C-runtime-reasons. Maybe this was so > once, or maybe my memory is faulty. You seem to be right. This is pretty ugly: Eshell V5.5.4 (abort with ^G) 1> receive after 16#ffffFFFF -> timeout end. timeout 2> receive after 16#ffffFFF -> timeout end. (hangs "forever", as it should) I didn't systematically check whether this also happens for compiled code too. timer:sleep/1 seems to do the right thing. > Instead I would limit my sleep to perhaps day-intervals, and close > down to smaller intervals when I get closer to the absolute > time. Realistically, that's a good idea, though day-intervals are rather long if you ever want to load new code. Matthias From chsu79 Fri Feb 1 16:19:51 2008 From: chsu79 (Christian S) Date: Fri, 1 Feb 2008 16:19:51 +0100 Subject: [erlang-questions] Newbie question: wait until an absolute time In-Reply-To: <47A32F5E.2040006@volny.cz> References: <1201870693.4624.61.camel@piko.site> <47A31DE9.5000000@cs.ntua.gr> <47A32F5E.2040006@volny.cz> Message-ID: > Hello, > > the reason behind your decision is to limit loss of precision, > i.e. take potential time drifting into account? > > Ladislav Lenart Yes. Another reason is that 2^32 seconds divided by 24h*3600*1000 milliseconds in a day is around 49 days. Matthias Lang also brought attention to code-upgrades which are much simpler if you dont have to involve system messages. Another good thing is that you can easily add to the receive clause (accepting messages) since you have already implemented your code to adjust the timeout to what is remaining before it goes to sleep. Say if you want to add "time remaining", "expire time" and such operations. From alpar Fri Feb 1 16:37:59 2008 From: alpar (=?ISO-8859-1?Q?Alp=E1r_J=FCttner?=) Date: Fri, 01 Feb 2008 15:37:59 +0000 Subject: [erlang-questions] Newbie question: wait until an absolute time In-Reply-To: <200802011507.m11F74ug005997@pluto.hedeland.org> References: <200802011507.m11F74ug005997@pluto.hedeland.org> Message-ID: <1201880279.4624.85.camel@piko.site> > timer:sleep/1 seems to do the right thing. and > (The timer module doesn't have the limit of 'receive after'.) Can I safely rely on this? Is it documented anywhere? Regards, Alpar From jilani Fri Feb 1 20:55:26 2008 From: jilani (Jilani Khaldi) Date: Fri, 01 Feb 2008 20:55:26 +0100 Subject: [erlang-questions] Erlang has handed in Italy Message-ID: <47A3792E.8020206@cheapnet.it> Hi all, on the issue 62 of Linux&C (the nr 1 magazine about Linux in Italy) there is an interview to Joe Armstrong (Hi Joe and sorry for the long delay) about Erlang. http://www.oltrelinux.com/home.php?num_riv=62 In the next issue (63) it will be a long article about the language. -- Jilani KHALDI From rvirding Fri Feb 1 23:52:49 2008 From: rvirding (Robert Virding) Date: Fri, 1 Feb 2008 23:52:49 +0100 Subject: [erlang-questions] Erlounge in San Francisco, 17-22 February In-Reply-To: <3dbc6d1c0801190827l11ac1050yae37415a0e565270@mail.gmail.com> References: <3dbc6d1c0801190827l11ac1050yae37415a0e565270@mail.gmail.com> Message-ID: <3dbc6d1c0802011452v20c7df1fu966a326e8ed87e8b@mail.gmail.com> Thank you for the good response, now we just have to work out a suitable day to meet. Looking at my schedule for the conference these are my preferences (from best to worst): Saturday 16/2 (but I will be tired after the trip) Sunday 17/2 Tuesday 19/2 Monday 18/2 Friday 22/2 Wednesday and Thursday are a no-no. Come with suggestions and we'll decide. Well met, Robert On 19/01/2008, Robert Virding wrote: > > I will be in San Francisco 17-22 of February (actually from the 16th) for > a conference* and if there are any other Erlangers there perhaps we could > meet over a beer and have a nice discussion. Let me know and we can arrange > something. > > Robert > > *Game Developers Conference which until recently has had very little to do > with Erlang, they're all C++ weenies. > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080201/ef144b30/attachment.html From csanto Sat Feb 2 00:44:24 2008 From: csanto (Corrado Santoro) Date: Sat, 02 Feb 2008 00:44:24 +0100 Subject: [erlang-questions] Erlang has handed in Italy In-Reply-To: <47A3792E.8020206@cheapnet.it> References: <47A3792E.8020206@cheapnet.it> Message-ID: <47A3AED8.6080607@diit.unict.it> Hi Jilani, Jilani Khaldi ha scritto: > Hi all, > on the issue 62 of Linux&C (the nr 1 magazine about Linux in Italy) > there is an interview to Joe Armstrong (Hi Joe and sorry for the long > delay) about Erlang. > http://www.oltrelinux.com/home.php?num_riv=62 WOW... I'll buy the magazine :-) > In the next issue (63) it will be a long article about the language. If you think it's worth, you may cite that at the University of Catania (Engineering Faculty) we have a small research community that uses Erlang for research purposes; many students working with us use Erlang for their BSc and MSc thesis and we also have lectures reserved to them. I don't know if this is the sole experience, in Italy, but it's probable. We hope, in the future, to officially introduce Erlang in a course of the Computer Engineering degree. All the best, --Corrado -- ================================================================== Eng. Corrado Santoro, Ph.D. University of Catania - ITALY - Engineering Faculty Tel: +39 095 7382380 VoIP: sip:7035 Personal Home Page: http://www.diit.unict.it/users/csanto NUXI Home Page: http://nuxi.diit.unict.it ================================================================== From avbalu Sat Feb 2 02:46:23 2008 From: avbalu (Balu Balasubramanian) Date: Sat, 2 Feb 2008 01:46:23 +0000 Subject: [erlang-questions] Question on Diagraph module In-Reply-To: <1201596775.12589.22.camel@seasc0625.dyn.rnd.as.sw.ericsson.se> References: <1201596775.12589.22.camel@seasc0625.dyn.rnd.as.sw.ericsson.se> Message-ID: Thanks, Bengt. Makes sense. Yes, the shell did crash and got recreated with new process id. But I see that the variable binding for G is still valid. That raises one more question (not really related to digraph) When the shell (and in general any process) crashes won't it automatically forget the variable bindings as well? ---------------------------------------- > From: bengt.kleberg > CC: erlang-questions > Date: Tue, 29 Jan 2008 09:52:55 +0100 > Subject: Re: [erlang-questions] Question on Diagraph module > > Greeteings, > > Presumably you are getting the error because G is gone. > > I have never used digraphs but the manual page > (http://erlang.org/doc/man/digraph.html) says: > > "The digraph will, however, be deleted if the process that created the > digraph terminates." > > Your shell process, that created G, has just crashed. > > > bengt > > On Tue, 2008-01-29 at 08:16 +0000, Balu Balasubramanian wrote: >> Hi, >> >> I am new to Erlang! >> >> Can some one explain why I am getting the last error message (badarith) that I get with digraph module in stdlib. >> >> Erlang (BEAM) emulator version 5.5.4 [source] [64-bit] [async-threads:0] [kernel -poll:false] >> >> Eshell V5.5.4 (abort with ^G) >> 1> G=digraph:new(). >> {graph,14,15,16,true} >> 2> digraph:info(G). >> [{cyclicity,cyclic},{memory,847},{protection,protected}] >> 3> digraph:info(). >> >> =ERROR REPORT==== 8-Jan-2008::22:02:06 === >> Error in process with exit value: {undef,[{digraph,info,[]},{erl_eval,d o_apply,5},{shell,exprs,6},{shell,eval_loop,3}]} >> >> ** exited: {undef,[{digraph,info,[]}, >> {erl_eval,do_apply,5}, >> {shell,exprs,6}, >> {shell,eval_loop,3}]} ** >> >> % the above error is obvious as digraph:info/0 is udnefined. But now, >> >> 4> digraph:info(G). >> >> =ERROR REPORT==== 8-Jan-2008::22:02:08 === >> Error in process with exit value: {badarith,[{digraph,info,1},{erl_eval ,do_apply,5},{shell,exprs,6},{shell,eval_loop,3}]} >> >> ** exited: {badarith,[{digraph,info,1}, >> {erl_eval,do_apply,5}, >> {shell,exprs,6}, >> {shell,eval_loop,3}]} ** >> >> % Can some one please explain the above badarith error? Are there known issues with the digraph module? >> >> 5> init:script_id(). >> {"OTP APN 181 01","R11B"} >> 6> >> >> >> Thanks >> Balu >> >> >> _________________________________________________________________ >> Connect and share in new ways with Windows Live. >> http://www.windowslive.com/share.html?ocid=TXT_TAGHM_Wave2_sharelife_012008 >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions >> http://www.erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions _________________________________________________________________ Need to know the score, the latest news, or you need your Hotmail?-get your "fix". http://www.msnmobilefix.com/Default.aspx From matthias Sat Feb 2 07:50:12 2008 From: matthias (Matthias Lang) Date: Sat, 2 Feb 2008 07:50:12 +0100 Subject: [erlang-questions] Question on Diagraph module In-Reply-To: References: <1201596775.12589.22.camel@seasc0625.dyn.rnd.as.sw.ericsson.se> Message-ID: <18340.4772.113978.734984@antilipe.corelatus.se> Balu Balasubramanian writes: > When the shell (and in general any process) crashes won't it > automatically forget the variable bindings as well? The shell is a bit tricky in that way, bindings are preserved from one shell process to the next: 1> self(). <0.31.0> 2> A = 3. 3 3> -x. ** exited: {badarith,[{erl_eval,eval_op,2},... 4> self(). <0.35.0> 5> A. 3 Matthias From icejmx Fri Feb 1 02:34:42 2008 From: icejmx (=?BIG5?B?usu6yw==?=) Date: Fri, 1 Feb 2008 09:34:42 +0800 Subject: [erlang-questions] why prim_inet undocument? Message-ID: HI! I want to use prim_inet.why prim_inet undocument,is old? erlang async socket is use the module? help! thanks every body! -- ?????? ??-??????Feed ?? ?? ?????? ?????Blog ??-http://www.ushared.com Demo Feed - http://www.ushared.com/qingfeng/1143981110.xml -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080201/a5bb700d/attachment.html From jilani Sat Feb 2 11:11:40 2008 From: jilani (Jilani Khaldi) Date: Sat, 02 Feb 2008 11:11:40 +0100 Subject: [erlang-questions] Erlang has handed in Italy In-Reply-To: <47A3AED8.6080607@diit.unict.it> References: <47A3792E.8020206@cheapnet.it> <47A3AED8.6080607@diit.unict.it> Message-ID: <47A441DC.9060808@cheapnet.it> > If you think it's worth, you may cite that at the University of Catania > (Engineering Faculty) we have a small research community that uses > Erlang for research purposes; many students working with us use Erlang > for their BSc and MSc thesis and we also have lectures reserved to them. > I don't know if this is the sole experience, in Italy, but it's probable. Where can I find information about all this? In your personal (english) site I can't find anything new about Erlang since 2004. In the italian site of the Engineering Faculty (Dipartimento di Ingegneria Informatica e delle Telecominicazioni) there is nothing mensioning Erlang or any other technologies. Secret italian (catanesi) weapons? Let us know, please. Ciao! -- Jilani KHALDI http://jkhaldi.oltrelinux.com From vychodil.hynek Sat Feb 2 11:57:35 2008 From: vychodil.hynek (Hynek Vychodil) Date: Sat, 2 Feb 2008 11:57:35 +0100 Subject: [erlang-questions] Question on Diagraph module In-Reply-To: References: <1201596775.12589.22.camel@seasc0625.dyn.rnd.as.sw.ericsson.se> Message-ID: <4d08db370802020257u51bc5cach47ce09a88c085b09@mail.gmail.com> On Feb 2, 2008 2:46 AM, Balu Balasubramanian wrote: > > Thanks, Bengt. > Makes sense. Yes, the shell did crash and got recreated with new process > id. But I see that the variable binding for G is still valid. > That raises one more question (not really related to digraph) > When the shell (and in general any process) crashes won't it automatically > forget the variable bindings as well? There is big difference between shell and any other process in normal working application. Shell itself is one process which keep variable binding different way than normal bindings in normal functions (and so variables are binded only inside functions, not for whole process). When you type some expression, expression is evaluated inside different subprocess and this subprocess is reused until crash. When evaluating subprocess crash, new one is created and used since that moment. Because bindings are kept inside shell main process, they can survive evaluating process crash. So behavior of shell is different from behavior of normal processes. For example digraph:new is called from evaluating shell process and digraph made they own ets tables with PID of evaluating process stored. Then result graph object is saved in shell main process and when evaluating process crash, graph disappear but graph record inside main shell process binding storage don't. Shell only emulate variable bindings inside one function this way. Shell can be made different way using try - catch but there is other caveats. For example you would be able break shell main process from evaluating expressions. (You can do it anyway in present implementation by code loading and storing code reference in shell bindings.) > > > ---------------------------------------- > > From: bengt.kleberg > > CC: erlang-questions > > Date: Tue, 29 Jan 2008 09:52:55 +0100 > > Subject: Re: [erlang-questions] Question on Diagraph module > > > > Greeteings, > > > > Presumably you are getting the error because G is gone. > > > > I have never used digraphs but the manual page > > (http://erlang.org/doc/man/digraph.html) says: > > > > "The digraph will, however, be deleted if the process that created the > > digraph terminates." > > > > Your shell process, that created G, has just crashed. > > > > > > bengt > > > > On Tue, 2008-01-29 at 08:16 +0000, Balu Balasubramanian wrote: > >> Hi, > >> > >> I am new to Erlang! > >> > >> Can some one explain why I am getting the last error message (badarith) > that I get with digraph module in stdlib. > >> > >> Erlang (BEAM) emulator version 5.5.4 [source] [64-bit] > [async-threads:0] [kernel -poll:false] > >> > >> Eshell V5.5.4 (abort with ^G) > >> 1> G=digraph:new(). > >> {graph,14,15,16,true} > >> 2> digraph:info(G). > >> [{cyclicity,cyclic},{memory,847},{protection,protected}] > >> 3> digraph:info(). > >> > >> =ERROR REPORT==== 8-Jan-2008::22:02:06 === > >> Error in process with exit value: > {undef,[{digraph,info,[]},{erl_eval,d > o_apply,5},{shell,exprs,6},{shell,eval_loop,3}]} > >> > >> ** exited: {undef,[{digraph,info,[]}, > >> {erl_eval,do_apply,5}, > >> {shell,exprs,6}, > >> {shell,eval_loop,3}]} ** > >> > >> % the above error is obvious as digraph:info/0 is udnefined. But now, > >> > >> 4> digraph:info(G). > >> > >> =ERROR REPORT==== 8-Jan-2008::22:02:08 === > >> Error in process with exit value: > {badarith,[{digraph,info,1},{erl_eval > ,do_apply,5},{shell,exprs,6},{shell,eval_loop,3}]} > >> > >> ** exited: {badarith,[{digraph,info,1}, > >> {erl_eval,do_apply,5}, > >> {shell,exprs,6}, > >> {shell,eval_loop,3}]} ** > >> > >> % Can some one please explain the above badarith error? Are there known > issues with the digraph module? > >> > >> 5> init:script_id(). > >> {"OTP APN 181 01","R11B"} > >> 6> > >> > >> > >> Thanks > >> Balu > >> > >> > >> _________________________________________________________________ > >> Connect and share in new ways with Windows Live. > >> > http://www.windowslive.com/share.html?ocid=TXT_TAGHM_Wave2_sharelife_012008 > >> _______________________________________________ > >> erlang-questions mailing list > >> erlang-questions > >> http://www.erlang.org/mailman/listinfo/erlang-questions > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions > > http://www.erlang.org/mailman/listinfo/erlang-questions > > _________________________________________________________________ > Need to know the score, the latest news, or you need your Hotmail(R)-get > your "fix". > http://www.msnmobilefix.com/Default.aspx > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > -- --Hynek (Pichi) Vychodil -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080202/d5e7f69e/attachment-0001.html From alpar Fri Feb 1 15:54:22 2008 From: alpar (=?ISO-8859-1?Q?Alp=E1r_J=FCttner?=) Date: Fri, 01 Feb 2008 14:54:22 +0000 Subject: [erlang-questions] Newbie question: wait until an absolute time In-Reply-To: <200802011454.03886.bekesa@sch.bme.hu> References: <1201870693.4624.61.camel@piko.site> <47A31DE9.5000000@cs.ntua.gr> <200802011454.03886.bekesa@sch.bme.hu> Message-ID: <1201877662.4624.74.camel@piko.site> Hi, > Hi, > > > > Anyway, is there any easy way to use a larger timeout than it is > > > representable by a single integer? > > In Erlang, integer values are not restricted > > to those that fit in 32 or 64 bits. So, you can pretty much use any > > integer you like. > Unfortunately, this is not the case with timers. > The doc (for the receive expression) states: "The highest allowed value > is 16#ffffffff, that is, the value must fit in 32 bits." Well, on R11. > I didn't check in R12. > > So, the question was wrong in some way. And so was the answer. :) Alpar From alpar Fri Feb 1 11:23:40 2008 From: alpar (=?ISO-8859-1?Q?Alp=E1r_J=FCttner?=) Date: Fri, 01 Feb 2008 10:23:40 +0000 Subject: [erlang-questions] Newbie question: wait until an absolute time Message-ID: <1201861420.4624.31.camel@piko.site> Dear all, Is there any simple way in erlang to wait until a certain absolute time or to do something at a specific time in the future ? Namely, I'm looking for the absolute counterpart of the functions sleep(), send_after(), apply_after() and the 'after TimeOut ->'. Is it there anything like the opposite of now_to_universal_time(Now)? Anyway, is there any easy way to use a larger timeout than it is representable by a single integer? Thanks, Alpar From erlang Sat Feb 2 15:27:20 2008 From: erlang (Joe Armstrong) Date: Sat, 2 Feb 2008 15:27:20 +0100 Subject: [erlang-questions] help: Erlang MIDI driver for MAC OS X In-Reply-To: <47A2FDF0.1000801@erix.ericsson.se> References: <400A6F0E-01D7-4D1D-9D38-9CDAE51F4B11@gmail.com> <9b08084c0801210629g5185a512kdd1eb3d243c5a22f@mail.gmail.com> <6a36e7290801210937n2d1849f8i8fce91a9018048a0@mail.gmail.com> <47A2FDF0.1000801@erix.ericsson.se> Message-ID: <9b08084c0802020627l3ed530d9g4bb298c0f77fce7c@mail.gmail.com> That sounds like fun - yes please send me a copy - don't bother to tidy it up. I'm amazed that you think the API is "nice" . On a good day, I would call it appallingly bad. The thing that it's better than must be true awful. I see absolutely no reason why a /dev/midi interface should no both be exceedingly simple and very powerful. Midi events (in the midi file spec) have infinite timing precision (play this note at exactly this time) - if I a want to play note N at time T I should only have to write a handful of bytes to a logical device not mess around with a load of totally irrelevant call back routines with obscure names and even more obscure arguments. Another grumble I have is that I was forced to read code to figure out how the routines worked - the so-called API "documentation" was not much help - I *hate* reading code to figure out what things do. All I get is one example of what the APIs do and not what they are *supposed* to do - sigh. Just because certain code has to be responsive and even fast doe not mean that the APIs have to be a mess. The job of turning complex requirements into fast code is the job of a compiler and not a programmer. I have (finally) also made a midi driver that can send and receive events from a keyboard and play things either via the keyboard or via an internal synt (Abletone live) - although the code works it's a mess - It would be nice to compare notes. Actually once you get Erlang to control midi streams the code starts fitting in with how I way to describe music. When you play a note you get sent a note. To play a note you send a message to the device. Synth ! {playNote, Pitch, Time, Vol} seems very natural. The arpeggiators sound fun - I'm trying to make rolling hash functions to recognise riffs and trigger samples ... /Joe On Feb 1, 2008 12:09 PM, Jakob Cederlund wrote: > > Hi! > I've written a simple coremidi-driver for erlang, but it's almost three > years ago, and it's 100% uncommented, undocumented code. If anyone wants it, > I can clean it up and send it over. Very simple stuff though: just sending > and receiving timed Midi data. > BTW, CoreAudio, while not really nice, is by far the nicest audio API I've > used, and I've used several. (Try doing music on a Wintel machine, if you > have strong nerves =). It's hard to program and even harder to setup.) > Having a /dev/midi would be nice for playing around and testing simple > stuff, and probably quite pointless for all other purposes. > /Jakob > > PS I wrote the driver initially as an example for the OTP docs, but dropped > it in favour of the postgres-driver, since the latter is cross-platform and > simpler. I did use it though, to test some simple music-related things, like > arpeggiators and quantizing of real-time midi-data. Erlang is nice for those > kind of hacks, and midi:play is more rewarding than io:format. =) > PPS Everything is not invented in UNIX... thank goodness! > > > Bob Ippolito wrote: > > On Jan 21, 2008 6:29 AM, Joe Armstrong wrote: > > > Thanks - I'd discovered this :-) > > I have actually made great progress after about 9 hours of searching > and messing around suddenly things > bust into life. > > I have now made a primitive OS-X midi driver - so now I can both send > and receive real-time midi events > and make horrible noises. > > The interesting thing is that this really does bring home to me how > appallingly difficult it is to write even simple > code today. > > Well, the reason Apple's CoreAudio APIs look like that are because > they're designed to have *very* precise timing, where you wouldn't be > able to do that properly over a file-like device. The APIs are a pain > in the ass and it sucks when you don't need that but that's why it's > designed that way. I think that the CoreAudio stuff lives in the > real-time parts of the kernel so when you get a callback it's at a > very high priority and you're not even supposed to allocate memory or > anything that might interrupt. > > -bob > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > From matthias Sat Feb 2 17:32:12 2008 From: matthias (Matthias Lang) Date: Sat, 2 Feb 2008 17:32:12 +0100 Subject: [erlang-questions] Newbie question: wait until an absolute time In-Reply-To: <1201861420.4624.31.camel@piko.site> References: <1201861420.4624.31.camel@piko.site> Message-ID: <18340.39692.88095.687058@antilipe.corelatus.se> Hi, > Is it there anything like the opposite of now_to_universal_time(Now)? The documentation for erlang:now() tells us that the now() epoch is 00:00 GMT, January 1, 1970. Putting that on a spoon: Seconds = calendar:datetime_to_gregorian_seconds(Datetime) - 62167219200, Now = {Seconds div 1000000, Seconds rem 1000000, 0}. > Anyway, is there any easy way to use a larger timeout than it is > representable by a single integer? If you mean "I don't like the limit 'receive' has and I want it to be higher", then, no, there is no easy way. If you mean "is there some way I can make a delay longer than the limit imposed by the timeout for 'receive'?", then the answer is sure, there are lots of ways. Remember what I said about not blocking code for extended periods? Here's one way to do it: sleep(Milliseconds) when Milliseconds =< 60000 -> receive after Milliseconds -> done end; sleep(Milliseconds) -> sleep(60000), my_timer:sleep(Milliseconds - 60000). Finally, an attempt to put this tedious thread out of its misery: %% Same as timer:send_after, except that the first argument is %% an absolute time in the format returned by calendar:now_to_universal_time send_on(Datetime, Pid, Message) -> End = calendar:datetime_to_gregorian_seconds(Datetime), Now = calendar:datetime_to_gregorian_seconds(calendar:universal_time()), Diff = (End - Now), timer:send_after(1000 * Diff, Pid, Message). Matthias From jim.menard Sat Feb 2 17:41:56 2008 From: jim.menard (Jim Menard) Date: Sat, 2 Feb 2008 11:41:56 -0500 Subject: [erlang-questions] help: Erlang MIDI driver for MAC OS X In-Reply-To: <9b08084c0801210629g5185a512kdd1eb3d243c5a22f@mail.gmail.com> References: <400A6F0E-01D7-4D1D-9D38-9CDAE51F4B11@gmail.com> <9b08084c0801210629g5185a512kdd1eb3d243c5a22f@mail.gmail.com> Message-ID: On Jan 21, 2008 9:29 AM, Joe Armstrong wrote: > Easy you might think: > > 1) open /dev/midi > 2) write three bytes > > A trivial exercise in any programming language - but NO - there is no > /dev/midi - instead there is an incredible > mess of API routines to open a midi first open a midi client - then > create a midi input and output port and > connect it to the client then get a midi device ref (for the correct > device) then setup a callback routine > for reading midi events - connect the sources the devices and > generally mess around. I feel your pain. Years ago, I wrote and used realtime MIDI performance software for the C64 and later the Atari ST and BeOS (http://www.io.com/~jimm/projects/keymaster/). It was pretty much as easy as you describe. The complexity you're fighting with is needed to overcome the 16-channel limitation of the MIDI spec. Programs need to talk to multiple MIDI devices through a MIDI interface with multiple MIDI I/O ports so that more than one synth can use all 16 MIDI channels separately, giving you hundreds of virtual channels. Apple has added complexity with virtual instruments, ports, and devices. It's kept me from writing any MIDI software for Mac OS X myself. > If anybody else is interested in real-time midi control and Erlang > programming please contact me. I'm definitely interested, but don't have time to contribute much. So I guess I'll shut up now, since I don't have anything worthwhile to add. Good luck with your project. It would be great if you decide to release your code. Jim -- Jim Menard, jimm, jim.menard http://www.io.com/~jimm/ From ulf.wiger Sat Feb 2 17:50:58 2008 From: ulf.wiger (Ulf Wiger (TN/EAB)) Date: Sat, 02 Feb 2008 17:50:58 +0100 Subject: [erlang-questions] help: Erlang MIDI driver for MAC OS X In-Reply-To: References: <400A6F0E-01D7-4D1D-9D38-9CDAE51F4B11@gmail.com> <9b08084c0801210629g5185a512kdd1eb3d243c5a22f@mail.gmail.com> Message-ID: <47A49F72.5020302@ericsson.com> Jim Menard skrev: > > The complexity you're fighting with is needed to overcome the > 16-channel limitation of the MIDI spec. Programs need to talk to > multiple MIDI devices through a MIDI interface with multiple MIDI I/O > ports so that more than one synth can use all 16 MIDI channels > separately, giving you hundreds of virtual channels. > > Apple has added complexity with virtual instruments, ports, and > devices. It's kept me from writing any MIDI software for Mac OS X > myself. Throwing myself into the deep end (I've not even looked at the MIDI interface, much less tried to write a MIDI program, but it's not obvious to me that the need for > 16 channels must force you into great complexity. Is this perhaps a case of accidental complexity, along the lines of what Joe described in http://www.erlang.se/workshop/2004/ex11.pdf ? Essentially, interfaces that are naturally message-based have a tendency to become extremely complex when you try to wrap them inside a traditional C API. BR, Ulf W From emmiller Sat Feb 2 22:40:01 2008 From: emmiller (Evan Miller) Date: Sat, 02 Feb 2008 13:40:01 -0800 Subject: [erlang-questions] Newbie: half-closing a port? Message-ID: After poring over the list archives for a while, I cannot find a way to do the following fairly simple operation: 1. Open a port 2. Send data to the port 3. Close the writing file descriptor 4. Read data from the port 5. Close the port My external program is a standard Unix utility that will not print data until it has read to the end of the input (i.e. the writer has closed its FD). If I close the port entirely, the external program gets a SIGPIPE when it attempts to flush its buffers. The following shell session demonstrates my problem: 22> Port = open_port({spawn, "sed 's/foo/bar/'"}, []). #Port<0.104> 23> Port ! {self(), {command, "foo\n"}}. {<0.56.0>,{command,"foo\n"}} 24> flush(). % still waiting for output... ok 25> Port ! {self(), close}. {<0.56.0>,close} 26> sed: couldn't flush stdout: Broken pipe 26> I would like to be able to do something like this just before closing: Port ! {self(), eof}. % read output... Is anything like this possible? Thanks, Evan Miller From ali.yakout Sun Feb 3 10:30:21 2008 From: ali.yakout (Ali Yakout) Date: Sun, 3 Feb 2008 10:30:21 +0100 Subject: [erlang-questions] How to include the Erlang runtime in my release? Message-ID: Hi, I'm using the erlware otp-base tool to build my release. I don't want to install the Erlang when installing my release on other machines with no Erlang. How do I include the Erlang runtime files in my release? My .app file look like this {release,{"ebank_rel","1.0"}, {erts,"5.5.5"}, [{kernel,"2.11.5"}, {stdlib,"1.14.5"}, {sasl,"2.1.5.1"}, {fslib,"5.1.0"}, {gas,"4.6.0"}, {ebank,"1.0"}]}. Thanks Regards, Ali Yakout From tony Sun Feb 3 11:56:03 2008 From: tony (Tony Rogvall) Date: Sun, 3 Feb 2008 11:56:03 +0100 Subject: [erlang-questions] Newbie: half-closing a port? In-Reply-To: References: Message-ID: <43661E95-4F26-4974-8B2B-77B194D0D599@rogvall.se> > > > I would like to be able to do something like this just before closing: > > Port ! {self(), eof}. > % read output... > I vote yes ! The simplest way would probably to implement a driver_control for the spawn driver (spawn_control) and add a library call somewhere to let the user close the output pipe side. I am not sure about windows but it looks (at least to me) as possible to implement. (while at it put in something for changing the read buffer size and acknowledge input get flow control ;-) What do you OTP people say ? /Tony From csanto Sun Feb 3 17:09:18 2008 From: csanto (Corrado Santoro) Date: Sun, 03 Feb 2008 17:09:18 +0100 Subject: [erlang-questions] Erlang has handed in Italy In-Reply-To: <47A441DC.9060808@cheapnet.it> References: <47A3792E.8020206@cheapnet.it> <47A3AED8.6080607@diit.unict.it> <47A441DC.9060808@cheapnet.it> Message-ID: <47A5E72E.2010600@diit.unict.it> Jilani Khaldi ha scritto: > Where can I find information about all this? In your personal (english) > site I can't find anything new about Erlang since 2004. In the italian > site of the Engineering Faculty (Dipartimento di Ingegneria Informatica > e delle Telecominicazioni) there is nothing mensioning Erlang or any > other technologies. Secret italian (catanesi) weapons? Let us know, please. Wel... no secret weapons at all! Only absence of proper advertising... UniCT is not so good in publishing research info :-) Anyway... here are some pointers, if you want to discuss some (or all) of them, please contact me privately. All the best, --Corrado 1. Robotics =========== Erlang has been used by our team to program a robot in two edition of the "Eurobot" competition (2006 and 2007). See http://eurobot.diit.unict.it. We'll repeat the experience this year. In 2006 and 2007, I made two presentations about such a project at Erlang Traning & Consulting, London (slides available on request). On such a topic, two papers have been presented at EUC'06 and Erlang Workshop 2007. 2. Robotics and 3D ================== Recently, we started a project for the realisation of a 3D robotic simlation engine. Check http://rosen.sourceforge.net/. 3. Hard real-time Erlang ======================== Enzo Nicosia, at Erlang Workshop 2007, presented a paper on how to excute hard-real-time computations using Erlang. 4. AI ===== The ERESYE tool, http://sourceforge.net/projects/eresye/, has been developed together with Francesca Gangemi; it allows programmers to design and implement inference systems in Erlang. A paper has been published at Erlang Workshop 2005. See also http://www.trapexit.org/Artificial_Intelligence_with_Erlang:_the_Domain_of_Relatives. 5. Multi-Agent Systems ====================== eXAT (http://www.diit.unict.it/users/csanto/exat) is a tool for the implementation of multi-agent systems in Erlang. It is FIPA compliant and integrates ERESYE for agent reasoning. Several papers have been published. 6. Grid Systems =============== Erlang has been used to develop a simulator of a P2P Grid system. The aim was to test a novel resource finding algorithm based on "potential field navigation". See: http://www3.interscience.wiley.com/search/allsearch?mode=viewselected&product=journal&ID=113392830&view_selected.x=107&view_selected.y=19&view_selected=view_selected 7. P2P Systems ============== Erlang has been recently used to develop a simulator of a novel algorithm to build locality-based overlay networks. Such a simulator is being used to generate overlay networks to test a QoS-aware MPEG transmission protocol. ---- END OF LIST ---- From rvirding Sun Feb 3 19:03:11 2008 From: rvirding (Robert Virding) Date: Sun, 3 Feb 2008 19:03:11 +0100 Subject: [erlang-questions] effect of destructive updates on GC implementation In-Reply-To: <31c6fe8f0801291402hec65c5cob670e39a845039a2@mail.gmail.com> References: <31c6fe8f0801291016p1aae6e36o5e7f040378d770bf@mail.gmail.com> <18335.39101.66579.372519@alkaid.it.uu.se> <31c6fe8f0801291402hec65c5cob670e39a845039a2@mail.gmail.com> Message-ID: <3dbc6d1c0802031003j4516697enb1c7b67c33fc56d3@mail.gmail.com> On 29/01/2008, Jonathan Amsterdam wrote: > > > The core Erlang developers are well aware of the techniques > > needed to support destructive updates in GC:d heaps. > > Apologies if my tone came across as patronizing. I just wanted to > explain my position without assuming anything. > > > 2. As soon as destructive updates are supported, people > > will use them. From what I've heard from Ericsson folks, > > the lack of destructive updates is actually a positive > > thing for them, presumably due to program reliability and > > programmer productivity. > > This is something I've wondered about. Are there any > production-quality, scalable programs that do not use mnesia, d/ets > tables or process dictionaries? That would be cool, but it seems to > me that when you're dealing with huge amounts of real-world data that > can change, the copying involved in purely functional data structures > would kill you. Of these three only process dictionaries come across as being fundamentally mutable data structures, and then only in a limited way. Mnesia is based on ets. While ets may seem like a mutable data structure (again in the limited way like process dictionaries) they can actually be modeled, and implemented, as processes. You don't actually create messages today and send them, by copying in the BEAM, but you do the copying bit. Ets tables also have a lot of the process semantics as well. If table ids were pids then you would be there. Think of being able to do operations directly on tables on other nodes. :-) As to whether the copying kills you there is only one way to find out and that is to measure. > 3. The combination of message passing and mutable data breaks > > the semantics of Erlang, or that of mutable data, and limits > > the choices the Erlang implementors can make. Suppose P1 > > sends a term T to P2. P2 inspects it. Later, P1 updates > > some part of T. Should P2 observe that change? > > - if yes, the semantics of Erlang is now fundamentally altered, > > - if no, the semantics of mutable data is severely restricted. > > Furthermore, each choice creates new hard constraints on how > > the runtime system may implement process heaps and message > > passing. > > > > This is the most compelling reason, for me. I think there would be great semantic problems in adding mutable data structures to a system which does not have them. If you allow the the mutating to reach between processes then you have added a "feature" which distinguishes between local and remote processes. There are very few such "features" today which I think is a VERY Good Thing. They cause problems in that programs which work suddenly don't work because someone moved a process to another node without knowing that somewhere deep inside there happened to be some sharing. We might as well add locks, mutexes and synchronisation primitives. I am still unclear as to what problem you are actually trying to solve. Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080203/3087e951/attachment.html From gerold Sun Feb 3 20:10:50 2008 From: gerold (gerold kathan) Date: Sun, 3 Feb 2008 20:10:50 +0100 Subject: [erlang-questions] [erl -name] crashes on vista Message-ID: <0a3701c86698$7dc67780$79536680$@at> Hej, i am running into problems when trying to register a an erlang node via 'erl -name myname' command * the problem only occurs under ms vista (I already run my shell with admin rights) * it works fine on another xp box * I tried with RB12 and R11B * error message I get looks like the following Th?nx and greetings from vienna, Cactus. C:\Windows\system32>erl -name h1 {error_logger,{{2008,2,3},{20,7,6}},"Protocol: ~p: register error: ~p~n",["inet_tcp",{{badmatch,{error,econnrefused}},[{inet_tcp_dist,listen,1} ,{net_k ernel,start_protos,4},{net_kernel,start_protos,3},{net_kernel,init_node,2},{ net_kernel,init,1},{gen_server,init_it,6},{proc_lib,init_p,5}]}]} {error_logger,{{2008,2,3},{20,7,6}},crash_report,[[{pid,<0.20.0>},{registere d_name,net_kernel},{error_info,{exit,{error,badarg},[{gen_server,init_it,6 },{proc_lib,init_p,5}]}},{initial_call,{gen,init_it,[gen_server,<0.17.0>,<0. 17.0>,{local,net_kernel},net_kernel,{h1,longnames,15000},[]]}},{ancestors, [net_sup,kernel_sup,<0.8.0>]},{messages,[]},{links,[#Port<0.7>,<0.17.0>]},{d ictionary,[{longnames,true}]},{trap_exit,true},{status,running},{heap_size ,377},{stack_size,23},{reductions,419}],[]]} {error_logger,{{2008,2,3},{20,7,6}},supervisor_report,[{supervisor,{local,ne t_sup}},{errorContext,start_error},{reason,{'EXIT',nodistribution}},{offen der,[{pid,undefined},{name,net_kernel},{mfa,{net_kernel,start_link,[[h1,long names]]}},{restart_type,permanent},{shutdown,2000},{child_type,worker}]}]} {error_logger,{{2008,2,3},{20,7,6}},supervisor_report,[{supervisor,{local,ke rnel_sup}},{errorContext,start_error},{reason,shutdown},{offender,[{pid,un defined},{name,net_sup},{mfa,{erl_distribution,start_link,[]}},{restart_type ,permanent},{shutdown,infinity},{child_type,supervisor}]}]} {error_logger,{{2008,2,3},{20,7,6}},crash_report,[[{pid,<0.7.0>},{registered _name,[]},{error_info,{exit,{shutdown,{kernel,start,[normal,[]]}},[{applic ation_master,init,4},{proc_lib,init_p,5}]}},{initial_call,{application_maste r,init,[<0.5.0>,<0.6.0>,{appl_data,kernel,[application_controller,erl_repl y,auth,boot_server,code_server,disk_log_server,disk_log_sup,erl_prim_loader, error_logger,file_server_2,fixtable_server,global_group,global_name_server ,heart,init,kernel_config,kernel_sup,net_kernel,net_sup,rex,user,os_server,d dll_server,erl_epmd,inet_db,pg2],undefined,{kernel,[]},[application,applic ation_controller,application_master,application_starter,auth,code,code_aux,p ackages,code_server,dist_util,erl_boot_server,erl_distribution,erl_prim_lo ader,erl_reply,erlang,error_handler,error_logger,file,file_server,file_io_se rver,prim_file,global,global_group,global_search,group,heart,hipe_unified_ loader,inet6_tcp,inet6_tcp_dist,inet6_udp,inet_config,inet_hosts,inet_gethos t_native,inet_tcp_dist,init,kernel,kernel_config,net,net_adm,net_kernel,os ,ram_file,rpc,user,user_drv,user_sup,disk_log,disk_log_1,disk_log_server,dis k_log_sup,dist_ac,erl_ddll,erl_epmd,erts_debug,gen_tcp,gen_udp,gen_sctp,pr im_inet,inet,inet_db,inet_dns,inet_parse,inet_res,inet_tcp,inet_udp,inet_sct p,pg2,seq_trace,wrap_log_reader,zlib,otp_ring0],[],infinity,infinity},norm al]}},{ancestors,[<0.6.0>]},{messages,[{'EXIT',<0.8.0>,normal}]},{links,[<0. 6.0>,<0.5.0>]},{dictionary,[]},{trap_exit,true},{status,running},{heap_siz e,987},{stack_size,23},{reductions,124}],[]]} {error_logger,{{2008,2,3},{20,7,6}},std_info,[{application,kernel},{exited,{ shutdown,{kernel,start,[normal,[]]}}},{type,permanent}]} {"Kernel pid terminated",application_controller,"{application_start_failure,kernel,{shutd own,{kernel,start,[normal,[]]}}}"} Crash dump was written to: erl_crash.dump Kernel pid terminated (application_controller) ({application_start_failure,kernel,{shutdown,{kernel,start,[normal,[]]}}}) From gerold Sun Feb 3 20:43:03 2008 From: gerold (cactus) Date: Sun, 3 Feb 2008 11:43:03 -0800 (PST) Subject: [erlang-questions] [erl -name] crashes on vista In-Reply-To: <0a3701c86698$7dc67780$79536680$@at> References: <0a3701c86698$7dc67780$79536680$@at> Message-ID: <8729c786-6fff-4d37-bd90-4aa3663ede67@k39g2000hsf.googlegroups.com> by the way i already tried C:\Windows\system32>erl Eshell V5.6 (abort with ^G) 1> gen_tcp:listen(0,[]). {ok,#Port<0.96>} 2> => this was mentioned in some ejabberd forum where someone had the same problem => in my case the response to gen_tcp looks like that it should work .... strange On Feb 3, 8:10?pm, "gerold kathan" wrote: > Hej, > i am running into problems when trying to register a an erlang node via 'erl > -name myname' command > * the problem only occurs under ms vista (I already run my shell with admin > rights) > * it works fine on another xp box > * I tried with RB12 and R11B > * error message I get looks like the following > > Th?nx and greetings from vienna, > Cactus. > > C:\Windows\system32>erl -name h1 > {error_logger,{{2008,2,3},{20,7,6}},"Protocol: ~p: register error: > ~p~n",["inet_tcp",{{badmatch,{error,econnrefused}},[{inet_tcp_dist,listen,1} > ,{net_k > ernel,start_protos,4},{net_kernel,start_protos,3},{net_kernel,init_node,2},{ > net_kernel,init,1},{gen_server,init_it,6},{proc_lib,init_p,5}]}]} > {error_logger,{{2008,2,3},{20,7,6}},crash_report,[[{pid,<0.20.0>},{registere > d_name,net_kernel},{error_info,{exit,{error,badarg},[{gen_server,init_it,6},{proc_lib,init_p,5}]}},{initial_call,{gen,init_it,[gen_server,<0.17.0>,<0. > > 17.0>,{local,net_kernel},net_kernel,{h1,longnames,15000},[]]}},{ancestors, > [net_sup,kernel_sup,<0.8.0>]},{messages,[]},{links,[#Port<0.7>,<0.17.0>]},{d > ictionary,[{longnames,true}]},{trap_exit,true},{status,running},{heap_size > ,377},{stack_size,23},{reductions,419}],[]]} > {error_logger,{{2008,2,3},{20,7,6}},supervisor_report,[{supervisor,{local,ne > t_sup}},{errorContext,start_error},{reason,{'EXIT',nodistribution}},{offen > der,[{pid,undefined},{name,net_kernel},{mfa,{net_kernel,start_link,[[h1,long > names]]}},{restart_type,permanent},{shutdown,2000},{child_type,worker}]}]} > > {error_logger,{{2008,2,3},{20,7,6}},supervisor_report,[{supervisor,{local,ke > rnel_sup}},{errorContext,start_error},{reason,shutdown},{offender,[{pid,un > defined},{name,net_sup},{mfa,{erl_distribution,start_link,[]}},{restart_type > ,permanent},{shutdown,infinity},{child_type,supervisor}]}]} > {error_logger,{{2008,2,3},{20,7,6}},crash_report,[[{pid,<0.7.0>},{registered > _name,[]},{error_info,{exit,{shutdown,{kernel,start,[normal,[]]}},[{applic > ation_master,init,4},{proc_lib,init_p,5}]}},{initial_call,{application_maste > r,init,[<0.5.0>,<0.6.0>,{appl_data,kernel,[application_controller,erl_repl > y,auth,boot_server,code_server,disk_log_server,disk_log_sup,erl_prim_loader, > error_logger,file_server_2,fixtable_server,global_group,global_name_server > ,heart,init,kernel_config,kernel_sup,net_kernel,net_sup,rex,user,os_server,d > dll_server,erl_epmd,inet_db,pg2],undefined,{kernel,[]},[application,applic > ation_controller,application_master,application_starter,auth,code,code_aux,p > ackages,code_server,dist_util,erl_boot_server,erl_distribution,erl_prim_lo > ader,erl_reply,erlang,error_handler,error_logger,file,file_server,file_io_se > rver,prim_file,global,global_group,global_search,group,heart,hipe_unified_ > loader,inet6_tcp,inet6_tcp_dist,inet6_udp,inet_config,inet_hosts,inet_gethos > t_native,inet_tcp_dist,init,kernel,kernel_config,net,net_adm,net_kernel,os > ,ram_file,rpc,user,user_drv,user_sup,disk_log,disk_log_1,disk_log_server,dis > k_log_sup,dist_ac,erl_ddll,erl_epmd,erts_debug,gen_tcp,gen_udp,gen_sctp,pr > im_inet,inet,inet_db,inet_dns,inet_parse,inet_res,inet_tcp,inet_udp,inet_sct > p,pg2,seq_trace,wrap_log_reader,zlib,otp_ring0],[],infinity,infinity},norm > al]}},{ancestors,[<0.6.0>]},{messages,[{'EXIT',<0.8.0>,normal}]},{links,[<0. > 6.0>,<0.5.0>]},{dictionary,[]},{trap_exit,true},{status,running},{heap_siz > e,987},{stack_size,23},{reductions,124}],[]]} > {error_logger,{{2008,2,3},{20,7,6}},std_info,[{application,kernel},{exited,{ > shutdown,{kernel,start,[normal,[]]}}},{type,permanent}]} > {"Kernel pid > terminated",application_controller,"{application_start_failure,kernel,{shutd > own,{kernel,start,[normal,[]]}}}"} > > Crash dump was written to: erl_crash.dump > Kernel pid terminated (application_controller) > ({application_start_failure,kernel,{shutdown,{kernel,start,[normal,[]]}}}) > > _______________________________________________ > erlang-questions mailing list > erlang-questi...://www.erlang.org/mailman/listinfo/erlang-questions From Lennart.Ohman Sun Feb 3 21:17:16 2008 From: Lennart.Ohman (=?iso-8859-1?Q?Lennart_=D6hman?=) Date: Sun, 3 Feb 2008 21:17:16 +0100 Subject: [erlang-questions] [erl -name] crashes on vista In-Reply-To: <0a3701c86698$7dc67780$79536680$@at> References: <0a3701c86698$7dc67780$79536680$@at> Message-ID: Hi Gerold, have you checked that you have an epmd running, or that you can get it running? (and that windows allows it to accept connections?) It looks like your problem is a connection problem. {badmatch,{error,econnrefused} I don't have a vista box but I can get the same problem if I deny the epmd to accept connections in my Zonealarm. Best Regards Lennart --------------------------------------------------------------------------- Lennart ?hman phone : +46-8-587 623 27 Sj?land & Thyselius Telecom AB cellular: +46-70-552 6735 H?lsingegatan 43, 10th floor fax : +46-8-667 8230 SE-113 31 STOCKHOLM, SWEDEN email : lennart.ohman -----Original Message----- From: erlang-questions-bounces [mailto:erlang-questions-bounces] On Behalf Of gerold kathan Sent: den 3 februari 2008 20:11 To: erlang-questions Subject: [erlang-questions] [erl -name] crashes on vista Hej, i am running into problems when trying to register a an erlang node via 'erl -name myname' command * the problem only occurs under ms vista (I already run my shell with admin rights) * it works fine on another xp box * I tried with RB12 and R11B * error message I get looks like the following Th?nx and greetings from vienna, Cactus. C:\Windows\system32>erl -name h1 {error_logger,{{2008,2,3},{20,7,6}},"Protocol: ~p: register error: ~p~n",["inet_tcp",{{badmatch,{error,econnrefused}},[{inet_tcp_dist,listen,1} ,{net_k ernel,start_protos,4},{net_kernel,start_protos,3},{net_kernel,init_node,2},{ net_kernel,init,1},{gen_server,init_it,6},{proc_lib,init_p,5}]}]} {error_logger,{{2008,2,3},{20,7,6}},crash_report,[[{pid,<0.20.0>},{registere d_name,net_kernel},{error_info,{exit,{error,badarg},[{gen_server,init_it,6 },{proc_lib,init_p,5}]}},{initial_call,{gen,init_it,[gen_server,<0.17.0>,<0. 17.0>,{local,net_kernel},net_kernel,{h1,longnames,15000},[]]}},{ancestors, [net_sup,kernel_sup,<0.8.0>]},{messages,[]},{links,[#Port<0.7>,<0.17.0>]},{d ictionary,[{longnames,true}]},{trap_exit,true},{status,running},{heap_size ,377},{stack_size,23},{reductions,419}],[]]} {error_logger,{{2008,2,3},{20,7,6}},supervisor_report,[{supervisor,{local,ne t_sup}},{errorContext,start_error},{reason,{'EXIT',nodistribution}},{offen der,[{pid,undefined},{name,net_kernel},{mfa,{net_kernel,start_link,[[h1,long names]]}},{restart_type,permanent},{shutdown,2000},{child_type,worker}]}]} {error_logger,{{2008,2,3},{20,7,6}},supervisor_report,[{supervisor,{local,ke rnel_sup}},{errorContext,start_error},{reason,shutdown},{offender,[{pid,un defined},{name,net_sup},{mfa,{erl_distribution,start_link,[]}},{restart_type ,permanent},{shutdown,infinity},{child_type,supervisor}]}]} {error_logger,{{2008,2,3},{20,7,6}},crash_report,[[{pid,<0.7.0>},{registered _name,[]},{error_info,{exit,{shutdown,{kernel,start,[normal,[]]}},[{applic ation_master,init,4},{proc_lib,init_p,5}]}},{initial_call,{application_maste r,init,[<0.5.0>,<0.6.0>,{appl_data,kernel,[application_controller,erl_repl y,auth,boot_server,code_server,disk_log_server,disk_log_sup,erl_prim_loader, error_logger,file_server_2,fixtable_server,global_group,global_name_server ,heart,init,kernel_config,kernel_sup,net_kernel,net_sup,rex,user,os_server,d dll_server,erl_epmd,inet_db,pg2],undefined,{kernel,[]},[application,applic ation_controller,application_master,application_starter,auth,code,code_aux,p ackages,code_server,dist_util,erl_boot_server,erl_distribution,erl_prim_lo ader,erl_reply,erlang,error_handler,error_logger,file,file_server,file_io_se rver,prim_file,global,global_group,global_search,group,heart,hipe_unified_ loader,inet6_tcp,inet6_tcp_dist,inet6_udp,inet_config,inet_hosts,inet_gethos t_native,inet_tcp_dist,init,kernel,kernel_config,net,net_adm,net_kernel,os ,ram_file,rpc,user,user_drv,user_sup,disk_log,disk_log_1,disk_log_server,dis k_log_sup,dist_ac,erl_ddll,erl_epmd,erts_debug,gen_tcp,gen_udp,gen_sctp,pr im_inet,inet,inet_db,inet_dns,inet_parse,inet_res,inet_tcp,inet_udp,inet_sct p,pg2,seq_trace,wrap_log_reader,zlib,otp_ring0],[],infinity,infinity},norm al]}},{ancestors,[<0.6.0>]},{messages,[{'EXIT',<0.8.0>,normal}]},{links,[<0. 6.0>,<0.5.0>]},{dictionary,[]},{trap_exit,true},{status,running},{heap_siz e,987},{stack_size,23},{reductions,124}],[]]} {error_logger,{{2008,2,3},{20,7,6}},std_info,[{application,kernel},{exited,{ shutdown,{kernel,start,[normal,[]]}}},{type,permanent}]} {"Kernel pid terminated",application_controller,"{application_start_failure,kernel,{shutd own,{kernel,start,[normal,[]]}}}"} Crash dump was written to: erl_crash.dump Kernel pid terminated (application_controller) ({application_start_failure,kernel,{shutdown,{kernel,start,[normal,[]]}}}) _______________________________________________ erlang-questions mailing list erlang-questions http://www.erlang.org/mailman/listinfo/erlang-questions From per Mon Feb 4 00:12:44 2008 From: per (Per Hedeland) Date: Mon, 4 Feb 2008 00:12:44 +0100 (CET) Subject: [erlang-questions] Newbie: half-closing a port? In-Reply-To: Message-ID: <200802032312.m13NCiNj075562@pluto.hedeland.org> Evan Miller wrote: > >I would like to be able to do something like this just before closing: > >Port ! {self(), eof}. >% read output... > >Is anything like this possible? As you can figure out from Tony's response, it isn't (and FWIW, I agree that it would be a good thing to add - it would fill a "functionality hole"). Assuming Unix and "text" input to the program, you can work around the problem with this hack though: 1> EOFwatcher = "sed -n -e /END-OF-FILE/q -e p | ". "sed -n -e /END-OF-FILE/q -e p | " 2> Port = open_port({spawn, EOFwatcher ++ "sed 's/foo/bar/'"}, []). #Port<0.88> 3> Port ! {self(), {command, "foo\n"}}. {<0.30.0>,{command,"foo\n"}} 4> Port ! {self(), {command, "END-OF-FILE\n"}}. {<0.30.0>,{command,"END-OF-FILE\n"}} 5> flush(). Shell got {#Port<0.88>,{data,"bar\n"}} ok --Per Hedeland From emmiller Mon Feb 4 02:54:19 2008 From: emmiller (Evan Miller) Date: Sun, 03 Feb 2008 17:54:19 -0800 Subject: [erlang-questions] Newbie: half-closing a port? In-Reply-To: <200802032312.m13NCiNj075562@pluto.hedeland.org> References: <200802032312.m13NCiNj075562@pluto.hedeland.org> Message-ID: Per Hedeland wrote: > Evan Miller wrote: >> I would like to be able to do something like this just before closing: >> >> Port ! {self(), eof}. >> % read output... >> >> Is anything like this possible? > > As you can figure out from Tony's response, it isn't (and FWIW, I agree > that it would be a good thing to add - it would fill a "functionality > hole"). Assuming Unix and "text" input to the program, you can work > around the problem with this hack though: > > 1> EOFwatcher = "sed -n -e /END-OF-FILE/q -e p | ". > "sed -n -e /END-OF-FILE/q -e p | " > 2> Port = open_port({spawn, EOFwatcher ++ "sed 's/foo/bar/'"}, []). > #Port<0.88> > 3> Port ! {self(), {command, "foo\n"}}. > {<0.30.0>,{command,"foo\n"}} > 4> Port ! {self(), {command, "END-OF-FILE\n"}}. > {<0.30.0>,{command,"END-OF-FILE\n"}} > 5> flush(). > Shell got {#Port<0.88>,{data,"bar\n"}} > ok Thanks for the hack, Per. While we're making a wish-list for the spawn driver, it would also be nice to be able to read stdout and stderr separately. Evan > > > --Per Hedeland From dustin.whitney Mon Feb 4 07:11:13 2008 From: dustin.whitney (Dustin Whitney) Date: Mon, 4 Feb 2008 01:11:13 -0500 Subject: [erlang-questions] UTF-8 problems Message-ID: <23def8000802032211y10013178veca9df5c56f5435a@mail.gmail.com> Hello, I want to make an HTTP GET request to a URL that returns an XML document, which I'd then like to run an XPath query against, but when I run it, all I get is a list of integers when I output the response body. I think this is due to the charset being in UTF-8. When I run the same program against http://slashdot.org, I get back the html content from slashdot in a readable form, and I think it's because slashdot uses iso-8859-1 as it's charset. How can I run XPath against what is returned when the page uses UTF-8? And how can I print UTF-8 to the console, so I can actually read it? Here is the small script I've written: -module(tmp). -export([get_url/0]). get_url() -> {_,{_, Header, Body}} = http:request(" http://dbpedia.org/sparql?default-graph-uri=http%3A%2F%2Fdbpedia.org&should-sponge=&query=PREFIX+xsd%3A+%3Chttp%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema%23%3E%0D%0APREFIX+rdfs%3A+%3Chttp%3A%2F%2Fwww.w3.org%2F2000%2F01%2Frdf-schema%23%3E%0D%0APREFIX+rdf%3A+%3Chttp%3A%2F%2Fwww.w3.org%2F1999%2F02%2F22-rdf-syntax-ns%23%3E%0D%0APREFIX+dbpedia2%3A+%3Chttp%3A%2F%2Fdbpedia.org%2Fproperty%2F%3E%0D%0A%0D%0ASELECT+*+WHERE+%7B%0D%0A%3Fsubject+rdf%3Atype+%3Chttp%3A%2F%2Fdbpedia.org%2Fclass%2Fyago%2FCity108524735%3E.%0D%0A%3Fsubject+rdfs%3Alabel+%3Flabel.%0D%0A%3Fsubject+dbpedia2%3Apopulation+%3Fpopulation.%0D%0AFILTER+%28lang%28%3Flabel%29+%3D+%22en%22+%26%26+xsd%3Ainteger%28%3Fpopulation%29+%3E+200000%29%0D%0A%7D&format=application%2Fsparql-results+xml&debug=on "), Body. I appreciate any help. Thanks, Dustin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080204/4f5dcc97/attachment.html From adam Mon Feb 4 09:02:45 2008 From: adam (Adam Lindberg) Date: Mon, 4 Feb 2008 09:02:45 +0100 Subject: [erlang-questions] How to include the Erlang runtime in my release? In-Reply-To: References: Message-ID: <6344005f0802040002q47f8a71apeae9d5193641c06c@mail.gmail.com> The Erlang runtime system is the {erts, "5.5.5"} entry in your release. You don't need to install Erlang on the target platform. Some info on how to start it can be found here: http://www.erlang.org/doc/design_principles/release_handling.html#11 Cheers, Adam On Feb 3, 2008 10:30 AM, Ali Yakout wrote: > Hi, > > I'm using the erlware otp-base tool to build my release. > I don't want to install the Erlang when installing my release on other > machines with no Erlang. > > How do I include the Erlang runtime files in my release? > > My .app file look like this > > {release,{"ebank_rel","1.0"}, > {erts,"5.5.5"}, > [{kernel,"2.11.5"}, > {stdlib,"1.14.5"}, > {sasl,"2.1.5.1"}, > {fslib,"5.1.0"}, > {gas,"4.6.0"}, > {ebank,"1.0"}]}. > > Thanks > > Regards, > Ali Yakout > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080204/c256b242/attachment.html From raimo+erlang-questions Mon Feb 4 11:50:51 2008 From: raimo+erlang-questions (Raimo Niskanen) Date: Mon, 4 Feb 2008 11:50:51 +0100 Subject: [erlang-questions] why prim_inet undocument? In-Reply-To: References: Message-ID: <20080204105051.GA8116@erix.ericsson.se> On Fri, Feb 01, 2008 at 09:34:42AM +0800, ???? wrote: > HI! > I want to use prim_inet.why prim_inet undocument,is old? > erlang async socket is use the module? > help! thanks every body! It is undocumented because it is an internal module that is not ment to be called from applications. Its interface may change without warning in even the smallest patch. If there is functionality you need that is not provided in gen_tcp, gen_udp, gen_sctp, inet etc... you just ask about it and there may either be another way to do it, or it may be added to the public interface where it should be. > > -- > ???????????? > ????-????????????Feed > ???? ???? ???????????? ??????????Blog > ????-http://www.ushared.com > Demo Feed - http://www.ushared.com/qingfeng/1143981110.xml > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From bbmaj7 Mon Feb 4 11:36:38 2008 From: bbmaj7 (Richard Andrews) Date: Mon, 4 Feb 2008 21:36:38 +1100 (EST) Subject: [erlang-questions] Newbie: half-closing a port? In-Reply-To: Message-ID: <479582.60422.qm@web52004.mail.re2.yahoo.com> --- Evan Miller wrote: > While we're making a wish-list for the spawn driver, it would also be > nice to be able to read stdout and stderr separately. I agree, it would be nice to have something like python's popen3(). As a desperate hack you could dup2 STDERR_FILENO to a TCP connection or some such to get the data back to erl. Get the name you always wanted with the new y7mail email address. www.yahoo7.com.au/y7mail From j.bhanot Mon Feb 4 14:10:06 2008 From: j.bhanot (J Bhanot) Date: Mon, 4 Feb 2008 18:40:06 +0530 Subject: [erlang-questions] Sending Message to Erlang node from C node Message-ID: Hi, I have succesfully connected to Erlang node from C node as when I execute following nodes(hidden). from Erlang node...i get the name of c node as c69 Now when I am trying to send the message from C node to Erlang node using : if(erl_reg_send(sockfd, "pong", cmsg) == 0) { printf("inside"); erl_err_sys("erl_reg_send"); } printf("outside"); I get neither inside nor outside... the prompt just comes to next line looks like process is dying while using erl_reg_send On the erlang side, I am using following pong script: -module(tut17). -export([start_ping/1, start_pong/0, ping/2, pong/0]). ping(0, Pong_Node) -> {pong, Pong_Node} ! finished, io:format("ping finished~n", []); ping(N, Pong_Node) -> {pong, Pong_Node} ! {ping, self()}, receive pong -> io:format("Ping received pong~n", []) end, ping(N - 1, Pong_Node). pong() -> receive finished -> io:format("Pong finished~n", []); {ping, Ping_PID} -> io:format("Pong received ping~n", []), Ping_PID ! pong, pong() end. start_pong() -> register(pong, spawn(tut17, pong, [])). start_ping(Pong_Node) -> spawn(tut17, ping, [3, Pong_Node]). and after the executing following in Erlang shell : tut17:start_pong(). I assume that my server process is registered and listening to messages - please correct me if ny understanding is not correct or anythingelse needs to be done..... Please note : I am able to connect but not able to send message from C node to Erlang node3 Appreciate your help.. Thanks and Regards, jb____________________________________________ =====-----=====-----===== Notice: The information contained in this e-mail message and/or attachments to it may contain confidential or privileged information. If you are not the intended recipient, any dissemination, use, review, distribution, printing or copying of the information contained in this e-mail message and/or attachments to it are strictly prohibited. If you have received this communication in error, please notify us by reply e-mail or telephone and immediately and permanently delete the message and any attachments. Thank you -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080204/62e3002b/attachment.html From vances Mon Feb 4 16:41:47 2008 From: vances (Vance Shipley) Date: Mon, 4 Feb 2008 10:41:47 -0500 Subject: [erlang-questions] Mnesia nested transactions Message-ID: <20080204154146.GH134@h216-235-12-173.host.egate.net> Am I correct in thinking that using nested transactions could help minimize the impact of deadlock? If a transaction performs a number of operations on tables and then executes a nested transaction and that transaction encounters deadlock is the nested transaction restarted inside the outer transaction? Or is the outer transaction restarted too? -Vance From ulf.wiger Mon Feb 4 17:00:18 2008 From: ulf.wiger (Ulf Wiger (TN/EAB)) Date: Mon, 04 Feb 2008 17:00:18 +0100 Subject: [erlang-questions] Mnesia nested transactions In-Reply-To: <20080204154146.GH134@h216-235-12-173.host.egate.net> References: <20080204154146.GH134@h216-235-12-173.host.egate.net> Message-ID: <47A73692.1020803@ericsson.com> Vance Shipley skrev: > Am I correct in thinking that using nested transactions > could help minimize the impact of deadlock? > > If a transaction performs a number of operations on tables > and then executes a nested transaction and that transaction > encounters deadlock is the nested transaction restarted > inside the outer transaction? Or is the outer transaction > restarted too? From mnesia_tm.erl (comment before restart/9): %% We can only restart toplevel transactions. %% If a deadlock situation occurs in a nested transaction %% The whole thing including all nested transactions need to be %% restarted. The stack is thus popped by a consequtive series of %% exit({aborted, #cyclic{}}) calls BR, Ulf W From dgud Mon Feb 4 17:04:23 2008 From: dgud (Dan Gudmundsson) Date: Mon, 04 Feb 2008 17:04:23 +0100 Subject: [erlang-questions] Mnesia nested transactions In-Reply-To: <20080204154146.GH134@h216-235-12-173.host.egate.net> References: <20080204154146.GH134@h216-235-12-173.host.egate.net> Message-ID: <47A73787.3050700@erix.ericsson.se> Everything is restarted, it has to if you think about it, the outer may have looks that causes the deadlock. /Dan Vance Shipley wrote: > Am I correct in thinking that using nested transactions > could help minimize the impact of deadlock? > > If a transaction performs a number of operations on tables > and then executes a nested transaction and that transaction > encounters deadlock is the nested transaction restarted > inside the outer transaction? Or is the outer transaction > restarted too? > > -Vance > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > From vances Mon Feb 4 18:20:01 2008 From: vances (Vance Shipley) Date: Mon, 4 Feb 2008 12:20:01 -0500 Subject: [erlang-questions] Mnesia nested transactions In-Reply-To: <47A73787.3050700@erix.ericsson.se> References: <20080204154146.GH134@h216-235-12-173.host.egate.net> <47A73787.3050700@erix.ericsson.se> Message-ID: <20080204172000.GM134@h216-235-12-173.host.egate.net> On Mon, Feb 04, 2008 at 05:04:23PM +0100, Dan Gudmundsson wrote: > Everything is restarted, it has to if you think about it, > the outer may have looks that causes the deadlock. I'm happy just to have a definitive answer, I'm coding not optimizing at this stage, however I don't follow your reasoning. If my outer transaction held locks that caused the deadlock doesn't it stand to reason the same locks would be there on the reattempt? -Vance From gerold Mon Feb 4 18:58:13 2008 From: gerold (cactus) Date: Mon, 4 Feb 2008 09:58:13 -0800 (PST) Subject: [erlang-questions] [erl -name] crashes on vista In-Reply-To: References: <0a3701c86698$7dc67780$79536680$@at> Message-ID: <65b64fcd-c89a-40f1-b59d-1c828898f9d0@s19g2000prg.googlegroups.com> hi - hmmmm on my windows xp box (where everything works fine) i did not have to run an epmd => by the way - what is the epmd for - sounds like some kind of unix style daemon ? => do i need to run an epmd ? if so - how ? => so for me it looks like that vista somehow blocks registering of erlang node => i already turned off all the firewalls ... has anyone any experience with erlang on vista ? th?nx and greetz from vienna cactus On Feb 3, 9:17?pm, Lennart ?hman wrote: > Hi Gerold, > have you checked that you have an epmd running, or that you can get it > running? (and that windows allows it to accept connections?) > > It looks like your problem is a connection problem. > > {badmatch,{error,econnrefused} > > I don't have a vista box but I can get the same problem if I deny the epmd > to accept connections in my Zonealarm. > > Best Regards > Lennart > > --------------------------------------------------------------------------- > Lennart ?hman ? ? ? ? ? ? ? ? ? phone ? : +46-8-587 623 27 > Sj?land & Thyselius Telecom AB ?cellular: +46-70-552 6735 > H?lsingegatan 43, 10th floor ? ?fax ? ? : +46-8-667 8230 > SE-113 31 STOCKHOLM, SWEDEN ? ? email ? : lennart.oh... > > -----Original Message----- > From: erlang-questions-boun... [mailto:erlang-questions-boun...] On Behalf Of gerold kathan > Sent: den 3 februari 2008 20:11 > To: erlang-questi... > Subject: [erlang-questions] [erl -name] crashes on vista > > Hej, > i am running into problems when trying to register a an erlang node via 'erl > -name myname' command > * the problem only occurs under ms vista (I already run my shell with admin > rights) > * it works fine on another xp box > * I tried with RB12 and R11B > * error message I get looks like the following > > Th?nx and greetings from vienna, > Cactus. > > C:\Windows\system32>erl -name h1 > {error_logger,{{2008,2,3},{20,7,6}},"Protocol: ~p: register error: > ~p~n",["inet_tcp",{{badmatch,{error,econnrefused}},[{inet_tcp_dist,listen,1} > ,{net_k > ernel,start_protos,4},{net_kernel,start_protos,3},{net_kernel,init_node,2},{ > net_kernel,init,1},{gen_server,init_it,6},{proc_lib,init_p,5}]}]} > {error_logger,{{2008,2,3},{20,7,6}},crash_report,[[{pid,<0.20.0>},{registere > d_name,net_kernel},{error_info,{exit,{error,badarg},[{gen_server,init_it,6 > },{proc_lib,init_p,5}]}},{initial_call,{gen,init_it,[gen_server,<0.17.0>,<0. > 17.0>,{local,net_kernel},net_kernel,{h1,longnames,15000},[]]}},{ancestors, > [net_sup,kernel_sup,<0.8.0>]},{messages,[]},{links,[#Port<0.7>,<0.17.0>]},{d > ictionary,[{longnames,true}]},{trap_exit,true},{status,running},{heap_size > ,377},{stack_size,23},{reductions,419}],[]]} > {error_logger,{{2008,2,3},{20,7,6}},supervisor_report,[{supervisor,{local,ne > t_sup}},{errorContext,start_error},{reason,{'EXIT',nodistribution}},{offen > der,[{pid,undefined},{name,net_kernel},{mfa,{net_kernel,start_link,[[h1,long > names]]}},{restart_type,permanent},{shutdown,2000},{child_type,worker}]}]} > > {error_logger,{{2008,2,3},{20,7,6}},supervisor_report,[{supervisor,{local,ke > rnel_sup}},{errorContext,start_error},{reason,shutdown},{offender,[{pid,un > defined},{name,net_sup},{mfa,{erl_distribution,start_link,[]}},{restart_type > ,permanent},{shutdown,infinity},{child_type,supervisor}]}]} > {error_logger,{{2008,2,3},{20,7,6}},crash_report,[[{pid,<0.7.0>},{registered > _name,[]},{error_info,{exit,{shutdown,{kernel,start,[normal,[]]}},[{applic > ation_master,init,4},{proc_lib,init_p,5}]}},{initial_call,{application_maste > r,init,[<0.5.0>,<0.6.0>,{appl_data,kernel,[application_controller,erl_repl > y,auth,boot_server,code_server,disk_log_server,disk_log_sup,erl_prim_loader, > error_logger,file_server_2,fixtable_server,global_group,global_name_server > ,heart,init,kernel_config,kernel_sup,net_kernel,net_sup,rex,user,os_server,d > dll_server,erl_epmd,inet_db,pg2],undefined,{kernel,[]},[application,applic > ation_controller,application_master,application_starter,auth,code,code_aux,p > ackages,code_server,dist_util,erl_boot_server,erl_distribution,erl_prim_lo > ader,erl_reply,erlang,error_handler,error_logger,file,file_server,file_io_se > rver,prim_file,global,global_group,global_search,group,heart,hipe_unified_ > loader,inet6_tcp,inet6_tcp_dist,inet6_udp,inet_config,inet_hosts,inet_gethos > t_native,inet_tcp_dist,init,kernel,kernel_config,net,net_adm,net_kernel,os > ,ram_file,rpc,user,user_drv,user_sup,disk_log,disk_log_1,disk_log_server,dis > k_log_sup,dist_ac,erl_ddll,erl_epmd,erts_debug,gen_tcp,gen_udp,gen_sctp,pr > im_inet,inet,inet_db,inet_dns,inet_parse,inet_res,inet_tcp,inet_udp,inet_sct > p,pg2,seq_trace,wrap_log_reader,zlib,otp_ring0],[],infinity,infinity},norm > al]}},{ancestors,[<0.6.0>]},{messages,[{'EXIT',<0.8.0>,normal}]},{links,[<0. > 6.0>,<0.5.0>]},{dictionary,[]},{trap_exit,true},{status,running},{heap_siz > e,987},{stack_size,23},{reductions,124}],[]]} > {error_logger,{{2008,2,3},{20,7,6}},std_info,[{application,kernel},{exited,{ > shutdown,{kernel,start,[normal,[]]}}},{type,permanent}]} > {"Kernel pid > terminated",application_controller,"{application_start_failure,kernel,{shutd > own,{kernel,start,[normal,[]]}}}"} > > Crash dump was written to: erl_crash.dump > Kernel pid terminated (application_controller) > ({application_start_failure,kernel,{shutdown,{kernel,start,[normal,[]]}}}) > > _______________________________________________ > erlang-questions mailing list > erlang-questi...://www.erlang.org/mailman/listinfo/erlang-questions > _______________________________________________ > erlang-questions mailing list > erlang-questi...://www.erlang.org/mailman/listinfo/erlang-questions > > From vlm Mon Feb 4 19:01:54 2008 From: vlm (Lev Walkin) Date: Mon, 04 Feb 2008 10:01:54 -0800 Subject: [erlang-questions] Mnesia nested transactions In-Reply-To: <20080204172000.GM134@h216-235-12-173.host.egate.net> References: <20080204154146.GH134@h216-235-12-173.host.egate.net> <47A73787.3050700@erix.ericsson.se> <20080204172000.GM134@h216-235-12-173.host.egate.net> Message-ID: <47A75312.1010008@lionet.info> Vance Shipley wrote: > On Mon, Feb 04, 2008 at 05:04:23PM +0100, Dan Gudmundsson wrote: >> Everything is restarted, it has to if you think about it, >> the outer may have looks that causes the deadlock. > > I'm happy just to have a definitive answer, I'm coding not > optimizing at this stage, however I don't follow your reasoning. > If my outer transaction held locks that caused the deadlock > doesn't it stand to reason the same locks would be there on the > reattempt? The outer transaction could hold locks (A) that prevent some other transaction from executing, while holding yet another set of locks (B). The inner transaction could start waiting on locks (B), hence the deadlock that can be fixed by restarting the outer transaction. -- Lev Walkin vlm From Lennart.Ohman Mon Feb 4 19:57:13 2008 From: Lennart.Ohman (=?iso-8859-1?Q?Lennart_=D6hman?=) Date: Mon, 4 Feb 2008 19:57:13 +0100 Subject: [erlang-questions] [erl -name] crashes on vista In-Reply-To: <65b64fcd-c89a-40f1-b59d-1c828898f9d0@s19g2000prg.googlegroups.com> References: <0a3701c86698$7dc67780$79536680$@at> <65b64fcd-c89a-40f1-b59d-1c828898f9d0@s19g2000prg.googlegroups.com> Message-ID: Hi, copy and paste from a dos window (on XP) /Lennart C:\Program Files\erl5.6\erts-5.6\bin>epmd -help usage: epmd [-d|-debug] [DbgExtra...] [-port No] [-daemon] [-d|-debug] [-port No] [-names|-kill] See the Erlang epmd manual page for info about the usage. The -port and DbgExtra options are -port No Let epmd listen to another port than default 4369 -d -debug Enable debugging. This will give a log to the standard error stream. It will shorten the number of saved used node names to 5. If you give more than one debug flag you may get more debugging information. -packet_timout Seconds Set the number of seconds a connection can be inactive before epmd times out and closes the connection (default 60). -delay_accept Seconds To simulate a busy server you can insert a delay between epmd gets notified about that a new connection is requested and when the connections gets accepted. -delay_write Seconds Also a simulation of a busy server. Inserts a delay before a reply is sent. C:\Program Files\erl5.6\erts-5.6\bin>epmd -names epmd: Cannot connect to local epmd THIS SINCE EPMD IS NOT RUNNING I START A DISTRIBUTED ERLANG NODE - USING THE RUN COMMAND AND -sname foo2 C:\Program Files\erl5.6\erts-5.6\bin>epmd -names epmd: up and running on port 4369 with data: name foo2 at port 1148 C:\Program Files\erl5.6\erts-5.6\bin> --------------------------------------------------------------------------- Lennart ?hman phone : +46-8-587 623 27 Sj?land & Thyselius Telecom AB cellular: +46-70-552 6735 H?lsingegatan 43, 10th floor fax : +46-8-667 8230 SE-113 31 STOCKHOLM, SWEDEN email : lennart.ohman -----Original Message----- From: erlang-questions-bounces [mailto:erlang-questions-bounces] On Behalf Of cactus Sent: den 4 februari 2008 18:58 To: erlang-questions Subject: Re: [erlang-questions] [erl -name] crashes on vista hi - hmmmm on my windows xp box (where everything works fine) i did not have to run an epmd => by the way - what is the epmd for - sounds like some kind of unix style daemon ? => do i need to run an epmd ? if so - how ? => so for me it looks like that vista somehow blocks registering of erlang node => i already turned off all the firewalls ... has anyone any experience with erlang on vista ? th?nx and greetz from vienna cactus On Feb 3, 9:17 pm, Lennart ?hman wrote: > Hi Gerold, > have you checked that you have an epmd running, or that you can get it > running? (and that windows allows it to accept connections?) > > It looks like your problem is a connection problem. > > {badmatch,{error,econnrefused} > > I don't have a vista box but I can get the same problem if I deny the epmd > to accept connections in my Zonealarm. > > Best Regards > Lennart > > --------------------------------------------------------------------------- > Lennart ?hman phone : +46-8-587 623 27 > Sj?land & Thyselius Telecom AB cellular: +46-70-552 6735 > H?lsingegatan 43, 10th floor fax : +46-8-667 8230 > SE-113 31 STOCKHOLM, SWEDEN email : lennart.oh... > > -----Original Message----- > From: erlang-questions-boun... [mailto:erlang-questions-boun...] On Behalf Of gerold kathan > Sent: den 3 februari 2008 20:11 > To: erlang-questi... > Subject: [erlang-questions] [erl -name] crashes on vista > > Hej, > i am running into problems when trying to register a an erlang node via 'erl > -name myname' command > * the problem only occurs under ms vista (I already run my shell with admin > rights) > * it works fine on another xp box > * I tried with RB12 and R11B > * error message I get looks like the following > > Th?nx and greetings from vienna, > Cactus. > > C:\Windows\system32>erl -name h1 > {error_logger,{{2008,2,3},{20,7,6}},"Protocol: ~p: register error: > ~p~n",["inet_tcp",{{badmatch,{error,econnrefused}},[{inet_tcp_dist,listen,1} > ,{net_k > ernel,start_protos,4},{net_kernel,start_protos,3},{net_kernel,init_node,2},{ > net_kernel,init,1},{gen_server,init_it,6},{proc_lib,init_p,5}]}]} > {error_logger,{{2008,2,3},{20,7,6}},crash_report,[[{pid,<0.20.0>},{registere > d_name,net_kernel},{error_info,{exit,{error,badarg},[{gen_server,init_it,6 > },{proc_lib,init_p,5}]}},{initial_call,{gen,init_it,[gen_server,<0.17.0>,<0. > 17.0>,{local,net_kernel},net_kernel,{h1,longnames,15000},[]]}},{ancestors, > [net_sup,kernel_sup,<0.8.0>]},{messages,[]},{links,[#Port<0.7>,<0.17.0>]},{d > ictionary,[{longnames,true}]},{trap_exit,true},{status,running},{heap_size > ,377},{stack_size,23},{reductions,419}],[]]} > {error_logger,{{2008,2,3},{20,7,6}},supervisor_report,[{supervisor,{local,ne > t_sup}},{errorContext,start_error},{reason,{'EXIT',nodistribution}},{offen > der,[{pid,undefined},{name,net_kernel},{mfa,{net_kernel,start_link,[[h1,long > names]]}},{restart_type,permanent},{shutdown,2000},{child_type,worker}]}]} > > {error_logger,{{2008,2,3},{20,7,6}},supervisor_report,[{supervisor,{local,ke > rnel_sup}},{errorContext,start_error},{reason,shutdown},{offender,[{pid,un > defined},{name,net_sup},{mfa,{erl_distribution,start_link,[]}},{restart_type > ,permanent},{shutdown,infinity},{child_type,supervisor}]}]} > {error_logger,{{2008,2,3},{20,7,6}},crash_report,[[{pid,<0.7.0>},{registered > _name,[]},{error_info,{exit,{shutdown,{kernel,start,[normal,[]]}},[{applic > ation_master,init,4},{proc_lib,init_p,5}]}},{initial_call,{application_maste > r,init,[<0.5.0>,<0.6.0>,{appl_data,kernel,[application_controller,erl_repl > y,auth,boot_server,code_server,disk_log_server,disk_log_sup,erl_prim_loader, > error_logger,file_server_2,fixtable_server,global_group,global_name_server > ,heart,init,kernel_config,kernel_sup,net_kernel,net_sup,rex,user,os_server,d > dll_server,erl_epmd,inet_db,pg2],undefined,{kernel,[]},[application,applic > ation_controller,application_master,application_starter,auth,code,code_aux,p > ackages,code_server,dist_util,erl_boot_server,erl_distribution,erl_prim_lo > ader,erl_reply,erlang,error_handler,error_logger,file,file_server,file_io_se > rver,prim_file,global,global_group,global_search,group,heart,hipe_unified_ > loader,inet6_tcp,inet6_tcp_dist,inet6_udp,inet_config,inet_hosts,inet_gethos > t_native,inet_tcp_dist,init,kernel,kernel_config,net,net_adm,net_kernel,os > ,ram_file,rpc,user,user_drv,user_sup,disk_log,disk_log_1,disk_log_server,dis > k_log_sup,dist_ac,erl_ddll,erl_epmd,erts_debug,gen_tcp,gen_udp,gen_sctp,pr > im_inet,inet,inet_db,inet_dns,inet_parse,inet_res,inet_tcp,inet_udp,inet_sct > p,pg2,seq_trace,wrap_log_reader,zlib,otp_ring0],[],infinity,infinity},norm > al]}},{ancestors,[<0.6.0>]},{messages,[{'EXIT',<0.8.0>,normal}]},{links,[<0. > 6.0>,<0.5.0>]},{dictionary,[]},{trap_exit,true},{status,running},{heap_siz > e,987},{stack_size,23},{reductions,124}],[]]} > {error_logger,{{2008,2,3},{20,7,6}},std_info,[{application,kernel},{exited,{ > shutdown,{kernel,start,[normal,[]]}}},{type,permanent}]} > {"Kernel pid > terminated",application_controller,"{application_start_failure,kernel,{shutd > own,{kernel,start,[normal,[]]}}}"} > > Crash dump was written to: erl_crash.dump > Kernel pid terminated (application_controller) > ({application_start_failure,kernel,{shutdown,{kernel,start,[normal,[]]}}}) > > _______________________________________________ > erlang-questions mailing list > erlang-questi...://www.erlang.org/mailman/listinfo/erlang-questions > _______________________________________________ > erlang-questions mailing list > erlang-questi...://www.erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ erlang-questions mailing list erlang-questions http://www.erlang.org/mailman/listinfo/erlang-questions From vladdu55 Mon Feb 4 20:00:44 2008 From: vladdu55 (Vlad Dumitrescu) Date: Mon, 4 Feb 2008 20:00:44 +0100 Subject: [erlang-questions] [erl -name] crashes on vista In-Reply-To: <65b64fcd-c89a-40f1-b59d-1c828898f9d0@s19g2000prg.googlegroups.com> References: <0a3701c86698$7dc67780$79536680$@at> <65b64fcd-c89a-40f1-b59d-1c828898f9d0@s19g2000prg.googlegroups.com> Message-ID: <95be1d3b0802041100t3a2eb6f7t661fbeb518e5b7d9@mail.gmail.com> Hi, On Feb 4, 2008 6:58 PM, cactus wrote: > hi - hmmmm on my windows xp box (where everything works fine) i did > not have to run an epmd When starting an Erlang node with "erl -sname" or "erl -name", epmd should get started automatically. You can check the process list to see if it's there. > => by the way - what is the epmd for - sounds like some kind of unix > style daemon ? yes, something like that. If you check http://www.erlang.org/doc/apps/erts/index.html, you will be able to find the documentation for it. > => so for me it looks like that vista somehow blocks registering of > erlang node > => i already turned off all the firewalls ... > has anyone any experience with erlang on vista ? It works for me without problems. Could you try "erl -sname h1"? For me it doesn't work to use -name without specifying a full host name (but there's a different error message). best regards, Vlad From gerold Mon Feb 4 21:05:34 2008 From: gerold (cactus) Date: Mon, 4 Feb 2008 12:05:34 -0800 (PST) Subject: [erlang-questions] [erl -name] crashes on vista In-Reply-To: <95be1d3b0802041100t3a2eb6f7t661fbeb518e5b7d9@mail.gmail.com> References: <0a3701c86698$7dc67780$79536680$@at> <65b64fcd-c89a-40f1-b59d-1c828898f9d0@s19g2000prg.googlegroups.com> <95be1d3b0802041100t3a2eb6f7t661fbeb518e5b7d9@mail.gmail.com> Message-ID: hej, so i tried to run the epmd directly: * on standard port 4369 it fails * on other port e.g. 4368 it works ----------------------------------------------------------------- C:\Program Files\erl5.6\erts-5.6\bin>epmd -port 4369 epmd: Mon Feb 04 20:58:49 2008: epmd running - daemon = 0 epmd: Mon Feb 04 20:58:49 2008: failed to bind socket: No error C:\Program Files\erl5.6\erts-5.6\bin>epmd -port 4368 epmd: Mon Feb 04 20:58:57 2008: epmd running - daemon = 0 ------------------------------------------------------------------ * the 'erl -sname' gives me the same error message than the 'erl - name' => can i specify when i start 'erl -name' that it should use other port than standard ? => i also will check again my firewall settings..... On Feb 4, 8:00?pm, "Vlad Dumitrescu" wrote: > Hi, > > On Feb 4, 2008 6:58 PM, cactus wrote: > > > hi - hmmmm on my windows xp box (where everything works fine) i did > > not have to run an epmd > > When starting an Erlang node with "erl -sname" or "erl -name", epmd > should get started automatically. You can check the process list to > see if it's there. > > > => by the way - what is the epmd for - sounds like some kind of unix > > style daemon ? > > yes, something like that. If you checkhttp://www.erlang.org/doc/apps/erts/index.html, you will be able to > find the documentation for it. > > > => so for me it looks like that vista somehow blocks registering of > > erlang node > > => i already turned off all the firewalls ... > > has anyone any experience with erlang on vista ? > > It works for me without problems. Could you try "erl -sname h1"? For > me it doesn't work to use -name without specifying a full host name > (but there's a different error message). > > best regards, > Vlad > _______________________________________________ > erlang-questions mailing list > erlang-questi...://www.erlang.org/mailman/listinfo/erlang-questions From vladdu55 Mon Feb 4 21:12:23 2008 From: vladdu55 (Vlad Dumitrescu) Date: Mon, 4 Feb 2008 21:12:23 +0100 Subject: [erlang-questions] [erl -name] crashes on vista In-Reply-To: References: <0a3701c86698$7dc67780$79536680$@at> <65b64fcd-c89a-40f1-b59d-1c828898f9d0@s19g2000prg.googlegroups.com> <95be1d3b0802041100t3a2eb6f7t661fbeb518e5b7d9@mail.gmail.com> Message-ID: <95be1d3b0802041212s5451271bxc1b564c89def852@mail.gmail.com> Hi, On Feb 4, 2008 9:05 PM, cactus wrote: > hej, > so i tried to run the epmd directly: > * on standard port 4369 it fails > * on other port e.g. 4368 it works > > ----------------------------------------------------------------- > C:\Program Files\erl5.6\erts-5.6\bin>epmd -port 4369 > epmd: Mon Feb 04 20:58:49 2008: epmd running - daemon = 0 > epmd: Mon Feb 04 20:58:49 2008: failed to bind socket: No error So, what is using your 4369 port? run 'netstat' to find out. regards, Vlad From matthew Mon Feb 4 21:31:49 2008 From: matthew (Matthew Dempsky) Date: Mon, 4 Feb 2008 12:31:49 -0800 Subject: [erlang-questions] Can we change the semantics of match expressions in comprehensions? Message-ID: I'd like to propose a change to the semantics of match expressions as filters in list and bit comprehensions. Currently, all filter expressions are evaluated and expected to return true or false or else an error is raised. I suggest special casing match expressions as filters. If a filter is of the form Pat = Expr, Expr is evaluated normally, and whether the result can be matched to Pat determines whether the comprehension continues down this path. E.g., this change would allow [B || {1,B} = A <- [{1,2},{2,3},{1,3}]] to be rewritten as [B || A <- [{1,2},{2,3},{1,3}], {1,B} = A]. It would also allow list comprehensions like [B || A <- List, {ok, B} = foo(A)]. I doubt this change will affect any existing code. Right now, filters like {1,B} = A would unconditionally raise bad_filter errors. The only match expression filter that would not result in bad_filter errors are "true = Expr", "false = Expr", and "Var = Expr"; and I find it highly unlikely that these expressions would be in use as comprehension filters. However, if there is concern about this change in semantics, erl_lint could be changed to emit warnings about code using those expressions for a few releases before the semantics are changed. Below is a proof-of-concept patch to implement this change for erl_eval, which allows you to play with the new semantics at the command-line. --- erl_eval.erl.orig 2008-02-04 11:53:07.000000000 -0800 +++ erl_eval.erl 2008-02-04 12:10:19.000000000 -0800 @@ -576,12 +576,21 @@ {value,false,_} -> Acc end; false -> - case expr(F, Bs0, Lf, Ef, none) of - {value,true,Bs1} -> CompFun(Bs1); - {value,false,_} -> Acc; - {value,V,_} -> - erlang:raise(error, {bad_filter,V}, stacktrace()) - end + case F of + {match,_,Lhs,Rhs0} -> + {value,Rhs,Bs1} = expr(Rhs0, Bs0, Lf, Ef, none), + case match(Lhs, Rhs, Bs1) of + {match,Bs2} -> CompFun(Bs2); + nomatch -> Acc + end; + _ -> + case expr(F, Bs0, Lf, Ef, none) of + {value,true,Bs1} -> CompFun(Bs1); + {value,false,_} -> Acc; + {value,V,_} -> + erlang:raise(error, {bad_filter,V}, stacktrace()) + end + end end. From gerold Mon Feb 4 21:33:43 2008 From: gerold (cactus) Date: Mon, 4 Feb 2008 12:33:43 -0800 (PST) Subject: [erlang-questions] [erl -name] crashes on vista In-Reply-To: <95be1d3b0802041212s5451271bxc1b564c89def852@mail.gmail.com> References: <0a3701c86698$7dc67780$79536680$@at> <65b64fcd-c89a-40f1-b59d-1c828898f9d0@s19g2000prg.googlegroups.com> <95be1d3b0802041100t3a2eb6f7t661fbeb518e5b7d9@mail.gmail.com> <95be1d3b0802041212s5451271bxc1b564c89def852@mail.gmail.com> Message-ID: <79eed1f2-9036-4936-82e3-a68e92dc8f2a@n20g2000hsh.googlegroups.com> it is really weird - due to my netstat - port 4369 is NOT in use - but still 'erl-sname' crashes - i will try tomorrow on a longhornserver RC..... i will keep you updated good night, cactus On Feb 4, 9:12?pm, "Vlad Dumitrescu" wrote: > Hi, > > On Feb 4, 2008 9:05 PM, cactus wrote: > > > hej, > > so i tried to run the epmd directly: > > * on standard port 4369 it fails > > * on other port e.g. 4368 it works > > > ----------------------------------------------------------------- > > C:\Program Files\erl5.6\erts-5.6\bin>epmd -port 4369 > > epmd: Mon Feb 04 20:58:49 2008: epmd running - daemon = 0 > > epmd: Mon Feb 04 20:58:49 2008: failed to bind socket: No error > > So, what is using your 4369 port? run 'netstat' to find out. > > regards, > Vlad > _______________________________________________ > erlang-questions mailing list > erlang-questi...://www.erlang.org/mailman/listinfo/erlang-questions From matthew Mon Feb 4 21:47:32 2008 From: matthew (Matthew Dempsky) Date: Mon, 4 Feb 2008 12:47:32 -0800 Subject: [erlang-questions] Can we change the semantics of match expressions in comprehensions? In-Reply-To: References: Message-ID: It occurs to me now that I can just rewrite "Pat = Expr" as "Pat <- [Expr]" without needing to change semantics at all. I think it might still be worth investigating changes along those I described, but I withdraw my advocacy for them for the time being. From psa Mon Feb 4 22:44:34 2008 From: psa (=?ISO-8859-1?Q?Paulo_S=E9rgio_Almeida?=) Date: Mon, 04 Feb 2008 21:44:34 +0000 Subject: [erlang-questions] Can we change the semantics of matchexpressions in comprehensions? In-Reply-To: References: Message-ID: <47A78742.3000102@di.uminho.pt> Matthew Dempsky wrote: > It occurs to me now that I can just rewrite "Pat = Expr" as "Pat <- > [Expr]" without needing to change semantics at all. I think it might > still be worth investigating changes along those I described, but I > withdraw my advocacy for them for the time being. I also happened to want such a feature and then discovered this work-around. However, even if it is not strictly needed, it would make the code clearer. I started using the hack quite frequently, and sometimes it is not pleasant reading the code. IndexEnv = [{Var, Val} || Var <- IndexVars, {value, {_, Val}} <- [lists:keysearch(Var, 1, Env)]], is not so bad, but it gets worse when Expr returns itself a list, e.g. PosVars = lists:umerge([lists:sort(Vars) || PVVL <- PVVLs, Vars <- [[Var || {Var, _} <- PVVL]]]), Regards, Paulo From babo.online Mon Feb 4 23:39:33 2008 From: babo.online (Attila Babo) Date: Tue, 5 Feb 2008 00:39:33 +0200 Subject: [erlang-questions] Auto generated functions Message-ID: <597c69660802041439p20d3a032mfbff16817f752fec@mail.gmail.com> I wrote a simple Y combinator to deal with tail-recursive anonymous functions. There are several showcase implementations for Erlang already, but for practical purposes you need to deal with arity. Here is my code with examples, I'm looking for a way to avoid this boilerplate code. For practical reasons it's OK to generate it up to a point by hand or use a single tuple as a parameter, but I'm looking for "nicer" solution. Any suggestions? Attila %% Y Combinator y(F) -> {arity, Arity} = erlang:fun_info(F(F), arity), G = case Arity of 0 -> fun(H) -> F(fun() -> (H(H))() end) end; 1 -> fun(H) -> F(fun(A) -> (H(H))(A) end) end; 2 -> fun(H) -> F(fun(A, B) -> (H(H))(A, B) end) end; 3 -> fun(H) -> F(fun(A, B, C) -> (H(H))(A, B, C) end) end; 4 -> fun(H) -> F(fun(A, B, C, D) -> (H(H))(A, B, C, D) end) end; 5 -> fun(H) -> F(fun(A, B, C, D, E) -> (H(H))(A, B, C, D, E) end) end end, G(G). %% Examples dots() -> (y:y(fun(F) -> fun() -> io:fwrite("."), F() end end))(). len(I) when is_list(I) -> (y(fun(F) -> fun(X, N) -> case X of [] -> N; [_|R] -> F(R, N+1) end end end))(I, 0). %% End of code http://www.erlang.org/ml-archive/erlang-questions/200301/msg00053.html http://bc.tech.coop/blog/070611.html From matthew Tue Feb 5 00:07:55 2008 From: matthew (Matthew Dempsky) Date: Mon, 4 Feb 2008 15:07:55 -0800 Subject: [erlang-questions] Can we change the semantics of match expressions in comprehensions? In-Reply-To: References: Message-ID: On 2/4/08, Matthew Dempsky wrote: > It occurs to me now that I can just rewrite "Pat = Expr" as "Pat <- > [Expr]" without needing to change semantics at all. Below is a patch for the Erlang compiler that better optimizes generator expressions like "Pat <- [Expr]" in list comprehensions. A similar patch could probably be built for binary comprehensions. (I doubt it's worth the added complexity to include, but I thought I'd share anyways.) --- v3_core.erl.orig 2008-02-04 14:44:19.000000000 -0800 +++ v3_core.erl 2008-02-04 14:50:09.000000000 -0800 @@ -732,6 +732,34 @@ %% code. %% More could be transformed before calling lc_tq. +lc_tq(Line, E, [{generate,Lg,P,{cons,_,X,{nil,_}}}|Qs0], More, St0) -> + %% Fast path for Pat <- [Expr] generators. + {Xc,Xps,St1} = novars(X, St0), + {Lc,Lps,St2} = lc_tq(Line, E, Qs0, More, St1), + {Mc,Mps,St3} = expr(More, St2), + {Else,St4} = new_var(St3), + LA = lineno_anno(Line, St4), + {Cs,St5} = try pattern(P, St4) of + P1 = #c_var{} -> + {[#iclause{anno=#a{anno=LA}, + pats=[P1],guard=[], + body=Lps ++ [Lc]}], + St4}; + P1 -> + {[#iclause{anno=#a{anno=LA}, + pats=[P1],guard=[], + body=Lps ++ [Lc]}, + #iclause{anno=#a{anno=LA}, + pats=[Else],guard=[], + body=Mps ++ [Mc]}], + St4} + catch + throw:Thrown -> + {[], add_warning(Line, Thrown, St4)} + end, + {Fpat,St6} = new_var(St5), + Fc = fail_clause([Fpat], #c_tuple{es=[#c_literal{val=badmatch},Fpat]}), + {#icase{anno=#a{anno=LA},args=[Xc],clauses=Cs,fc=Fc},Xps,St6}; lc_tq(Line, E, [{generate,Lg,P,G}|Qs0], More, St0) -> {Gs,Qs1} = splitwith(fun is_guard_test/1, Qs0), {Name,St1} = new_fun_name("lc", St0), From mukul.j Tue Feb 5 09:00:21 2008 From: mukul.j (Mukul J) Date: Tue, 5 Feb 2008 13:30:21 +0530 Subject: [erlang-questions] Running Megaco MGC and MG Message-ID: Hi All, A very good afternoon to all you. I am stuck somewhere in running Megaco (MGC & MG) over Erlang. I have configured two IP address like 192.168.1.100 (primary) and 192.168.1.101 (virtual) on a linux machine. Whenever i run the Megaco sample programs over erlang using the following command sequence, they works perfect. cd megaco/examples/simple erl -pa ../../../megaco/ebin -s megaco_filter -s megaco megaco_simple_mgc:start(). megaco_simple_mg:start(). This simply exchanges ServiceChange message between MGC and MG. This works fine with primary IP address. Now i want to do the same with virtual IP address. I am not able to find where i need to provide the IP address. I am not able to identify where i am lacking. Please forgive me if this is a silly question as i am new to erlang. An early help will resolve the issues. Appriciate your help. Thanks in advance. Regards, MJ =====-----=====-----===== Notice: The information contained in this e-mail message and/or attachments to it may contain confidential or privileged information. If you are not the intended recipient, any dissemination, use, review, distribution, printing or copying of the information contained in this e-mail message and/or attachments to it are strictly prohibited. If you have received this communication in error, please notify us by reply e-mail or telephone and immediately and permanently delete the message and any attachments. Thank you -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080205/67bc4071/attachment.html From yarivsadan Tue Feb 5 09:04:06 2008 From: yarivsadan (Yariv Sadan) Date: Tue, 5 Feb 2008 00:04:06 -0800 Subject: [erlang-questions] Erlounge in San Francisco, 17-22 February In-Reply-To: <3dbc6d1c0802011452v20c7df1fu966a326e8ed87e8b@mail.gmail.com> References: <3dbc6d1c0801190827l11ac1050yae37415a0e565270@mail.gmail.com> <3dbc6d1c0802011452v20c7df1fu966a326e8ed87e8b@mail.gmail.com> Message-ID: <17244f480802050004k255fd1e5vf952d2db9bc74bc8@mail.gmail.com> Monday the 18th or Tuesday the 19th, sometime after 7:30pm work best for me. Yariv 2008/2/1 Robert Virding : > Thank you for the good response, now we just have to work out a suitable day > to meet. Looking at my schedule for the conference these are my preferences > (from best to worst): > > Saturday 16/2 (but I will be tired after the trip) > Sunday 17/2 > Tuesday 19/2 > Monday 18/2 > Friday 22/2 > > Wednesday and Thursday are a no-no. Come with suggestions and we'll decide. > > Well met, > Robert > > > > On 19/01/2008, Robert Virding wrote: > > I will be in San Francisco 17-22 of February (actually from the 16th) for > a conference* and if there are any other Erlangers there perhaps we could > meet over a beer and have a nice discussion. Let me know and we can arrange > something. > > > > Robert > > > > *Game Developers Conference which until recently has had very little to do > with Erlang, they're all C++ weenies. > > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > From bjorn Tue Feb 5 09:05:12 2008 From: bjorn (Bjorn Gustavsson) Date: 05 Feb 2008 09:05:12 +0100 Subject: [erlang-questions] Can we change the semantics of match expressions in comprehensions? In-Reply-To: References: Message-ID: "Matthew Dempsky" writes: > Below is a patch for the Erlang compiler that better optimizes > generator expressions like "Pat <- [Expr]" in list comprehensions. A > similar patch could probably be built for binary comprehensions. > > (I doubt it's worth the added complexity to include, but I thought I'd > share anyways.) Thanks! I will have a look and might include it (or a similar optimization) in R12B-2. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From chsu79 Tue Feb 5 09:23:57 2008 From: chsu79 (Christian S) Date: Tue, 5 Feb 2008 09:23:57 +0100 Subject: [erlang-questions] Auto generated functions In-Reply-To: <597c69660802041439p20d3a032mfbff16817f752fec@mail.gmail.com> References: <597c69660802041439p20d3a032mfbff16817f752fec@mail.gmail.com> Message-ID: On Feb 4, 2008 11:39 PM, Attila Babo wrote: > I wrote a simple Y combinator to deal with tail-recursive anonymous > functions. There are several showcase implementations for Erlang > already, but for practical purposes you need to deal with arity. Here > is my code with examples, I'm looking for a way to avoid this > boilerplate code. For practical reasons it's OK to generate it up to a > point by hand or use a single tuple as a parameter, but I'm looking > for "nicer" solution. Any suggestions? That's the way its done. Only improvement would be to use the erlang:is_funciton/2 guard. But that is not likely what you were looking for. From zerthurd Tue Feb 5 09:43:16 2008 From: zerthurd (Maxim Treskin) Date: Tue, 5 Feb 2008 14:43:16 +0600 Subject: [erlang-questions] Running Megaco MGC and MG In-Reply-To: References: Message-ID: All files in *megaco/examples/ *is examples. You must write your own application using megaco stack. -- Maxim Treskin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080205/3bc472e2/attachment.html From mukul.j Tue Feb 5 10:27:37 2008 From: mukul.j (Mukul J) Date: Tue, 5 Feb 2008 14:57:37 +0530 Subject: [erlang-questions] Running Megaco MGC and MG In-Reply-To: Message-ID: Hi Maxim, Thats right. These all are sample applications. But i want to run the same over virtual IP address (as i have configured). As i am new to Erlang, i want to know whether can I execute the same example using virtual IP. Also where i need to do the modification for the same. Thanks in advance. Regards, MJ "Maxim Treskin" Sent by: erlang-questions-bounces 02/05/2008 02:13 PM To cc erlang-questions Subject Re: [erlang-questions] Running Megaco MGC and MG All files in megaco/examples/ is examples. You must write your own application using megaco stack. -- Maxim Treskin _______________________________________________ erlang-questions mailing list erlang-questions http://www.erlang.org/mailman/listinfo/erlang-questions ForwardSourceID:NT000187E2 =====-----=====-----===== Notice: The information contained in this e-mail message and/or attachments to it may contain confidential or privileged information. If you are not the intended recipient, any dissemination, use, review, distribution, printing or copying of the information contained in this e-mail message and/or attachments to it are strictly prohibited. If you have received this communication in error, please notify us by reply e-mail or telephone and immediately and permanently delete the message and any attachments. Thank you -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080205/83615d4a/attachment.html From zerthurd Tue Feb 5 10:47:03 2008 From: zerthurd (Maxim Treskin) Date: Tue, 5 Feb 2008 15:47:03 +0600 Subject: [erlang-questions] Running Megaco MGC and MG In-Reply-To: References: Message-ID: See function megaco_simple_mg:start/0: start() -> {ok, LocalHost} = inet:gethostname(), start(LocalHost, false, false). MG uses localhost by default. Read erl -man inet and redefine value of LocalHost. -- Maxim Treskin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080205/4a30fce3/attachment-0001.html From hakan Tue Feb 5 11:02:53 2008 From: hakan (Hakan Mattsson) Date: Tue, 5 Feb 2008 11:02:53 +0100 (CET) Subject: [erlang-questions] Running Megaco MGC and MG In-Reply-To: References: Message-ID: On Tue, 5 Feb 2008, Mukul J wrote: MJ> Thats right. These all are sample applications. But i want to run the same MJ> over virtual IP address (as i have configured). MJ> As i am new to Erlang, i want to know whether can I execute the same MJ> example using virtual IP. MJ> Also where i need to do the modification for the same. The example code is not prepared to allow the user to select which interface to use. But as a temporary solution you can hardcode the IP address in megaco_simple_mg.erl and megaco_simple_mgc.erl. Add {tcp_options, [{ip, IpAddr}]} to the Option list in start_tcp/2 and add {udp_options, [{ip, IpAddr}]} to the Option list in start_udp/2. Where IpAddr is {192,168,1,101}. /H?kan From daniel.kwiecinski Tue Feb 5 11:40:09 2008 From: daniel.kwiecinski (Daniel Kwiecinski) Date: Tue, 5 Feb 2008 10:40:09 +0000 Subject: [erlang-questions] Question about Patch: Add MD5 and SHA1 sign/verify functions Message-ID: I've applied the path from http://article.gmane.org/gmane.comp.lang.erlang.patches/151 and I did the following. Any help explaining cause of the error will be very appreciated. Do I correct use MPints? ************* CODE ************************************************************* encode(String) when is_list(String) -> {ok,{'RSAPrivateKey', 'two-prime', N , E, _, _, _, _, _, _, _}} = ssl_pkix:decode_rsa_keyfile("keys/private.pem", ""), io:format("N: ~p, E: ~p~n", [N, E]), LicEncoded = base64:encode(String), DataSize = size(StringEncoded), Data = list_to_binary([<>, StringEncoded]), Key = [crypto:mpint(N), crypto:mpint(E)], Signed = crypto:rsa_sha_sign(Data, Key). ************* OUTPUT ************************************************************ 1> N: 138445250593310927542773857214440421480303788023222788575718585027863611115049364971357691872676298545743250295800358402756549552994822827897856839673996350473620588754354369610803297438509920062322876055789528692164182842422276496510610413689066855989959284865235115518531216882699698497082235347230922628187, E: 65537 ERROR erlang code crashed: Reason: {badarg,[{erlang,port_control, [#Port<0.726>,37, [<<0,0,0,12,89,87,74,106,101,72,108,54,77,84,73,122>>, [<<0,0,0,129,0,197,39,15,141,167,6,5,108,161,36,156, 232,98,38,254,39,218,195,218,129,86,197,124,175, 154,216,158,194,246,96,166,139,158,183,81,58,162, 18,64,198,190,247,160,66,39,71,212,124,232,153, 25,254,239,65,183,202,58,151,88,229,174,59,162,4, 230,41,233,100,28,179,130,16,216,89,163,179,59, 223,210,251,174,78,108,157,165,251,234,86,60,198, 244,158,230,64,250,137,86,85,7,55,61,26,94,207, 27,171,40,181,95,236,192,7,33,219,39,233,110,211, 132,47,236,69,170,167,6,171,220,91>>, <<0,0,0,3,1,0,1>>]]]}, {crypto,control,2}, {crypto,rsa_sha_sign,2}, -- Kind Regards, Daniel Kwiecinski From goryachev Tue Feb 5 16:00:30 2008 From: goryachev (Igor Goryachev) Date: Tue, 05 Feb 2008 18:00:30 +0300 Subject: [erlang-questions] bug: Protocol: "inet_tcp": register/listen error: eaddrinuse while starting a node Message-ID: <8763x31m9d.fsf@yandex-team.ru> Hi, everyone! I have noticed some troubles while starting node with '-kernel inet_dist_listen_min 5290 inet_dist_listen_max 5290' options. And everything works fine when these options are omitted. The output is here: =========== {progress,preloaded} {progress,kernel_load_completed} {progress,modules_loaded} {start,heart} {start,error_logger} {start,application_controller} {progress,init_kernel_started} {apply,{application,load,[{application,stdlib,[{description,"ERTS CXC 138 10"},{vsn,"1.14.5"},{id,[]},{modules,[base64,beam_lib,c,calendar,dets,dets_server,dets_sup,dets_utils,dets_v8,dets_v9,dict,digraph,digraph_utils,edlin,edlin_expand,epp,eval_bits,erl_bits,erl_compile,erl_eval,erl_expand_records,erl_internal,erl_lint,erl_parse,erl_posix_msg,erl_pp,erl_scan,erl_tar,error_logger_file_h,error_logger_tty_h,escript,ets,file_sorter,filelib,filename,gb_trees,gb_sets,gen,gen_event,gen_fsm,gen_server,io,io_lib,io_lib_format,io_lib_fread,io_lib_pretty,lib,lists,log_mf_h,math,ms_transform,orddict,ordsets,otp_internal,pg,pool,proc_lib,proplists,qlc,qlc_pt,queue,random,regexp,sets,shell,shell_default,slave,sofs,string,supervisor,supervisor_bridge,sys,timer,win32reg,zip]},{registered,[timer_server,rsh_starter,take_over_monitor,pool_master,dets]},{applications,[kernel]},{included_applications,[]},{env,[]},{start_phases,undefined},{maxT,infinity},{maxP,infinity}]}]}} {progress,applications_loaded} {apply,{application,start_boot,[kernel,permanent]}} {error_logger,{{2008,2,5},{17,18,42}},"Protocol: ~p: register/listen error: ~p~n",["inet_tcp",eaddrinuse]} {error_logger,{{2008,2,5},{17,18,42}},crash_report,[[{pid,<0.21.0>},{registered_name,net_kernel},{error_info,{error,badarg}},{initial_call,{gen,init_it,[gen_server,<0.18.0>,<0.18.0>,{local,net_kernel},net_kernel,{'ejabberd',shortnames,15000},[]]}},{ancestors,[net_sup,kernel_sup,<0.8.0>]},{messages,[]},{links,[<0.18.0>]},{dictionary,[{longnames,false}]},{trap_exit,true},{status,running},{heap_size,377},{stack_size,21},{reductions,331}],[]]} {error_logger,{{2008,2,5},{17,18,42}},supervisor_report,[{supervisor,{local,net_sup}},{errorContext,start_error},{reason,{'EXIT',nodistribution}},{offender,[{pid,undefined},{name,net_kernel},{mfa,{net_kernel,start_link,[['ejabberd',shortnames]]}},{restart_type,permanent},{shutdown,2000},{child_type,worker}]}]} {error_logger,{{2008,2,5},{17,18,42}},supervisor_report,[{supervisor,{local,kernel_sup}},{errorContext,start_error},{reason,shutdown},{offender,[{pid,undefined},{name,net_sup},{mfa,{erl_distribution,start_link,[]}},{restart_type,permanent},{shutdown,infinity},{child_type,supervisor}]}]} {error_logger,{{2008,2,5},{17,18,42}},crash_report,[[{pid,<0.7.0>},{registered_name,[]},{error_info,{shutdown,{kernel,start,[normal,[]]}}},{initial_call,{application_master,init,[<0.5.0>,<0.6.0>,{appl_data,kernel,[application_controller,erl_reply,auth,boot_server,code_server,disk_log_server,disk_log_sup,erl_prim_loader,error_logger,file_server_2,fixtable_server,global_group,global_name_server,heart,init,kernel_config,kernel_sup,net_kernel,net_sup,rex,user,os_server,ddll_server,erl_epmd,inet_db,pg2],undefined,{kernel,[]},[application,application_controller,application_master,application_starter,auth,code,code_aux,packages,code_server,dist_util,erl_boot_server,erl_distribution,erl_prim_loader,erl_reply,erlang,error_handler,error_logger,file,file_server,file_io_server,prim_file,global,global_group,global_search,group,heart,hipe_unified_loader,inet6_tcp,inet6_tcp_dist,inet6_udp,inet_config,inet_hosts,inet_gethost_native,inet_tcp_dist,init,kernel,kernel_config,net,net_adm,net_kernel,os,ram_file,rpc,user,user_drv,user_sup,disk_log,disk_log_1,disk_log_server,disk_log_sup,dist_ac,erl_ddll,erl_epmd,erts_debug,gen_tcp,gen_udp,gen_sctp,prim_inet,inet,inet_db,inet_dns,inet_parse,inet_res,inet_tcp,inet_udp,inet_sctp,pg2,seq_trace,wrap_log_reader,zlib,otp_ring0],[],infinity,infinity},normal]}},{ancestors,[<0.6.0>]},{messages,[{'EXIT',<0.8.0>,normal}]},{links,[<0.6.0>,<0.5.0>]},{dictionary,[]},{trap_exit,true},{status,running},{heap_size,987},{stack_size,21},{reductions,2063}],[]]} {apply,{application,start_boot,[stdlib,permanent]}} {error_logger,{{2008,2,5},{17,18,42}},std_info,[{application,kernel},{exited,{shutdown,{kernel,start,[normal,[]]}}},{type,permanent}]} {"Kernel pid terminated",application_controller,"{application_start_failure,kernel,{shutdown,{kernel,start,[normal,[]]}}}"} Crash dump was written to: erl_crash.dump Kernel pid terminated (application_controller) ({application_start_failure,kernel,{shutdown,{kernel,start,[normal,[]]}}}) =========== After a little bit of investigation I've noticed, that there is no '{reuseaddr, true}' socket option in the lib/kernel/src/inet_tcp_dist.erl. If I add this option, recompile inet_tcp_dist.erl, put it into proper place, everything works fine like when mentioned above kernel options are omitted. The tiny patch is included. -- Igor Goryachev Yandex development team. -------------- next part -------------- A non-text attachment was scrubbed... Name: inet_tcp_dist.erl_add-reuseaddr.diff Type: text/x-diff Size: 461 bytes Desc: not available Url : http://www.erlang.org/pipermail/erlang-questions/attachments/20080205/cc525b86/attachment.bin From daniel.goertzen Tue Feb 5 20:46:34 2008 From: daniel.goertzen (Daniel Goertzen) Date: Tue, 5 Feb 2008 13:46:34 -0600 Subject: [erlang-questions] repeatable dets:insert() error Message-ID: dets:insert() unexpectedly fails upon inserting the 2,097,176th element in a stress test program. It happens on Windows with R11B, and linux with R12B. It only seems to happen when inserting the term {N,{entry,N}}; the term {N,{entry,another_entry,N} got past the 2.1M mark without error. Anybody know what's going on here? Consider this dets stress tester: go(make_dets) -> {ok,Mydets}=dets:open_file(mydets,[]), write_dets(Mydets), dets:close(Mydets). write_dets(Tab) -> write_dets(Tab,0). write_dets(Tab,N) -> case N rem 10000 of 0 -> io:format("inserting ~p~n",[N]); _ -> ok end, ok=dets:insert(Tab,{N,{entry,N}}), write_dets(Tab,N+1). With R11B on Windows I get: ... inserting 2070000 inserting 2080000 inserting 2090000 =ERROR REPORT==== 5-Feb-2008::09:54:40 === Error in process <0.30.0> with exit value: {badarg,[{dets,insert,[mydets,{209717 5,{entry,2097175}}]},{disk_log_test,write_dets,2},{disk_log_test,go,1},{erl_eval ,do_apply,5},{shell,exprs,6},{shell,eval_loop,3}]} ** exited: {badarg,[{dets,insert,[mydets,{2097175,{entry,2097175}}]}, {disk_log_test,write_dets,2}, {disk_log_test,go,1}, {erl_eval,do_apply,5}, {shell,exprs,6}, {shell,eval_loop,3}]} ** ...and on R12B on gentoo linux (amd64) I get: inserting 2070000 inserting 2080000 inserting 2090000 ** exception error: bad argument in function dets:insert/2 called as dets:insert(mydets,{2097175,{entry,2097175}}) in call from disk_log_test:write_dets/2 in call from disk_log_test:go/1 Thanks, Dan. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080205/aa3fd43e/attachment.html From dave.rafkind Wed Feb 6 05:22:31 2008 From: dave.rafkind (Dave Rafkind) Date: Tue, 5 Feb 2008 23:22:31 -0500 Subject: [erlang-questions] WASHDC erlounge? Message-ID: <2ae2b2da0802052022y37cd2ab9s206a1afdaa594e1e@mail.gmail.com> Say, anyone in the Washington DC metro area interested in some sort of erlang-related get-together? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080205/8259f52e/attachment-0001.html From jay Wed Feb 6 05:33:08 2008 From: jay (Jay Nelson) Date: Tue, 5 Feb 2008 20:33:08 -0800 Subject: [erlang-questions] Erlounge in San Francisco, 17-22 February Message-ID: <0E63161E-DFA2-4FEC-8199-598FB2775127@duomark.com> Monday evening would be perfect for me, since I am planning to drive back to LA during the day Tuesday. jay From mukul.j Wed Feb 6 12:18:56 2008 From: mukul.j (Mukul J) Date: Wed, 6 Feb 2008 16:48:56 +0530 Subject: [erlang-questions] Test Message-ID: thanks mj =====-----=====-----===== Notice: The information contained in this e-mail message and/or attachments to it may contain confidential or privileged information. If you are not the intended recipient, any dissemination, use, review, distribution, printing or copying of the information contained in this e-mail message and/or attachments to it are strictly prohibited. If you have received this communication in error, please notify us by reply e-mail or telephone and immediately and permanently delete the message and any attachments. Thank you -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080206/9df288e0/attachment-0001.html From zerthurd Wed Feb 6 12:38:33 2008 From: zerthurd (Maxim Treskin) Date: Wed, 6 Feb 2008 17:38:33 +0600 Subject: [erlang-questions] Wrong compilation warning Message-ID: Hello, During compilation of source file, which contains following code:

-record(ctx_ids, {
          used = [],
          free = []
         }).

-record(context, {
          ctx_id,
          term_ids
          }).

-record(core_state, {
          ctx_ids = [] :: [#ctx_ids{}],
          contexts = [] :: [#context{}]
         }).

I see a warning:
Warning: record context is unused
Record #context is unused in code, except in definition of record #core_state. May be is it compilation bug? Thank you. -- Maxim Treskin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080206/854f0eaa/attachment-0001.html From jwebb Wed Feb 6 12:58:09 2008 From: jwebb (John Webb) Date: Wed, 6 Feb 2008 20:58:09 +0900 Subject: [erlang-questions] Auto generated functions In-Reply-To: <597c69660802041439p20d3a032mfbff16817f752fec@mail.gmail.com> References: <597c69660802041439p20d3a032mfbff16817f752fec@mail.gmail.com> Message-ID: <66FFDE23-4AEE-4A49-A4A1-A277F6E95ABF@gol.com> Hi Attila, How about the following for fun? (sorry, bad pun)... %%%%%%%%%%%%%%%%%%%%%%%%%%% -module(y). -compile([export_all]). -import(lists,[map/2,seq/2,foldl/3,reverse/1,append/1]). y(F) when is_function(F) -> {arity,Arity} = erlang:fun_info(F(F),arity), Ps = mk_params(Arity), Func = append(["fun(H)->F(fun(",Ps,")->(H(H))(",Ps,")end)end."]), {ok,Tokens,_EndLine} = erl_scan:string(Func), {ok,[Expr]} = erl_parse:parse_exprs(Tokens), Bindings = erl_eval:add_binding('F',F,erl_eval:new_bindings()), {value,G,_NewBindings} = erl_eval:expr(Expr,Bindings), G(G); y(_) -> erlang:error(not_function). %% make a string of prameters "P1,P2...PN" mk_params(0) -> ""; mk_params(N) -> MkPs = fun(X) -> [$P|integer_to_list(X)] end, [P1|Ps] = map(MkPs, lists:seq(1,N)), append(reverse(foldl(fun(P,Acc) -> [P,","|Acc] end, [P1], Ps))). %% Examples dots() -> (y:y(fun(F) -> fun() -> io:format("."),F() end end))(). len(I) when is_list(I) -> (y:y(fun(F) -> fun([],N) -> N; ([_|R],N) -> F(R,N+1) end end))(I, 0). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% On Feb 5, 2008, at 7:39 AM, Attila Babo wrote: > I wrote a simple Y combinator to deal with tail-recursive anonymous > functions. There are several showcase implementations for Erlang > already, but for practical purposes you need to deal with arity. Here > is my code with examples, I'm looking for a way to avoid this > boilerplate code. For practical reasons it's OK to generate it up to a > point by hand or use a single tuple as a parameter, but I'm looking > for "nicer" solution. Any suggestions? > > Attila > > %% Y Combinator > > y(F) -> > {arity, Arity} = erlang:fun_info(F(F), arity), > G = case Arity of > 0 -> fun(H) -> F(fun() -> (H(H))() end) end; > 1 -> fun(H) -> F(fun(A) -> (H(H))(A) end) end; > 2 -> fun(H) -> F(fun(A, B) -> (H(H))(A, B) end) end; > 3 -> fun(H) -> F(fun(A, B, C) -> (H(H))(A, B, C) end) end; > 4 -> fun(H) -> F(fun(A, B, C, D) -> (H(H))(A, B, C, D) end) end; > 5 -> fun(H) -> F(fun(A, B, C, D, E) -> (H(H))(A, B, C, D, E) end) > end > end, > G(G). > > %% Examples > > dots() -> > (y:y(fun(F) -> fun() -> io:fwrite("."), F() end end))(). > > len(I) when is_list(I) -> > (y(fun(F) -> fun(X, N) -> case X of [] -> N; [_|R] -> F(R, N+1) end > end end))(I, 0). > > %% End of code > > http://www.erlang.org/ml-archive/erlang-questions/200301/msg00053.html > http://bc.tech.coop/blog/070611.html > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions From babo.online Wed Feb 6 13:50:37 2008 From: babo.online (Attila Babo) Date: Wed, 6 Feb 2008 14:50:37 +0200 Subject: [erlang-questions] Auto generated functions In-Reply-To: <66FFDE23-4AEE-4A49-A4A1-A277F6E95ABF@gol.com> References: <597c69660802041439p20d3a032mfbff16817f752fec@mail.gmail.com> <66FFDE23-4AEE-4A49-A4A1-A277F6E95ABF@gol.com> Message-ID: <597c69660802060450y49db9af8pec39887dc2d4ea57@mail.gmail.com> John, that's great, definitely an eye opener! Probably we pay dearly for it, but some memoization trick helps. Thanks, Attila From bjorn Wed Feb 6 15:07:54 2008 From: bjorn (Bjorn Gustavsson) Date: 06 Feb 2008 15:07:54 +0100 Subject: [erlang-questions] Erlang/OTP R12B-1 has been released Message-ID: Bug fix release : otp_src_R12B-1 Build date : 2008-02-06 This is bug fix release 1 for the R12B release. You can download the full source distribution from http://www.erlang.org/download/otp_src_R12B-1.tar.gz http://www.erlang.org/download/otp_src_R12B-1.readme Note: To unpack the TAR archive you need a GNU TAR compatible program. For installation instructions please read the README that is part of the distribution. The Windows binary distribution can be downloaded from http://www.erlang.org/download/otp_win32_R12B-1.exe On-line documentation can be found at http://www.erlang.org/doc/. You can also download the complete HTML documentation or the Unix manual files http://www.erlang.org/download/otp_doc_html_R12B-1.tar.gz http://www.erlang.org/download/otp_doc_man_R12B-1.tar.gz We also want to thank those that sent us patches, suggestions and bug reports, The OTP Team -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From holger Wed Feb 6 18:36:37 2008 From: holger (Holger Hoffstaette) Date: Wed, 06 Feb 2008 18:36:37 +0100 Subject: [erlang-questions] Erlang/OTP R12B-1 has been released References: Message-ID: On Wed, 06 Feb 2008 15:07:54 +0100, Bjorn Gustavsson wrote: > Bug fix release : otp_src_R12B-1 > Build date : 2008-02-06 > > This is bug fix release 1 for the R12B release. You can download the full > source distribution from ..please don't, at least not right away. The server is horribly slow (tested from the US and Germany); I am in the process of preparing torrents and will post them ASAP. Holger From holger Wed Feb 6 19:29:13 2008 From: holger (Holger Hoffstaette) Date: Wed, 06 Feb 2008 19:29:13 +0100 Subject: [erlang-questions] Erlang/OTP R12B-1 has been released References: Message-ID: for Windows: http://hoho.dyndns.org/~holger/dist/otp_win32_R12B-1.exe.torrent Please keep seeding until the poor erlang.org server is better :) Holger From holger Wed Feb 6 20:34:03 2008 From: holger (Holger Hoffstaette) Date: Wed, 06 Feb 2008 20:34:03 +0100 Subject: [erlang-questions] Erlang/OTP R12B-1 has been released References: Message-ID: Generic source: http://hoho.dyndns.org/~holger/dist/otp_src_R12B-1.tar.gz.torrent enjoy :) Holger From kostis Wed Feb 6 21:29:25 2008 From: kostis (Kostis Sagonas) Date: Wed, 06 Feb 2008 22:29:25 +0200 Subject: [erlang-questions] Wrong compilation warning In-Reply-To: References: Message-ID: <47AA18A5.8010100@cs.ntua.gr> Maxim Treskin wrote: >>... > -record(core_state, { > ctx_ids = [] :: [#ctx_ids{}], > contexts = [] :: [#context{}] > }). > > I see a warning: > Warning: record context is unused > > Record #context is unused in code, except in definition of record > #core_state. May be is it compilation bug? Well, a superfluous warning, even if bogus, is clearly not a compilation bug. In your code the culprit is the linter (erl_lint) that has not been adapted to take into account type annotations in record declarations. This might happen soon -- possibly even in the next R12 release. Best, Kostis From marcus Wed Feb 6 17:17:38 2008 From: marcus (Marcus Better) Date: Wed, 06 Feb 2008 17:17:38 +0100 Subject: [erlang-questions] [newbie] boot file binary compatibility Message-ID: Hi, I'm trying to launch erl with a boot file that was provided, but it crashes. I suspect it may require an older Erlang version. Two questions: 1. Are boot files platform (i.e. operating system) independent? 2. Can they be loaded by a newer Erlang runtime than the one they are intended for? I tried with Erlang R11B-5 and R12B-0 on Debian i386. This is what happens: ~$ erl -boot bootfile {"init terminating in do_boot",{'cannot load',error_handler,get_file}} Crash dump was written to: erl_crash.dump init terminating in do_boot () Regards, Marcus From kangas Wed Feb 6 22:40:11 2008 From: kangas (Matt Kangas) Date: Wed, 6 Feb 2008 16:40:11 -0500 Subject: [erlang-questions] WASHDC erlounge? In-Reply-To: <2ae2b2da0802052022y37cd2ab9s206a1afdaa594e1e@mail.gmail.com> References: <2ae2b2da0802052022y37cd2ab9s206a1afdaa594e1e@mail.gmail.com> Message-ID: <6899272A-2905-4764-B020-32C539BF6C81@bway.net> I'm in NYC, but DC is reasonably close by train. Count me in! BTW, I'm going to BarCampNYC3 on March 15 and will be demoing Erlang- oriented stuff. Anyone else want to help build an "Erlang Bloc" at this event? :) --Matt On Feb 5, 2008, at 11:22 PM, Dave Rafkind wrote: > Say, anyone in the Washington DC metro area interested in some sort > of erlang-related get-together? > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions -- Matt Kangas kangas ? www.p16blog.com From exta7 Wed Feb 6 23:03:11 2008 From: exta7 (Zvi) Date: Wed, 6 Feb 2008 14:03:11 -0800 (PST) Subject: [erlang-questions] Auto generated functions In-Reply-To: References: <597c69660802041439p20d3a032mfbff16817f752fec@mail.gmail.com> Message-ID: <15312902.post@talk.nabble.com> Y-combinator is cool, but I'm just currious why Erlang doesn't have some mechanism allowing fun to reference to itself (doesn't mutter if it's named or annonymous fun), same way as every process can get it's own PID using self(), i.e. (here I using this() to reference to function from inside): Len = fun([]) -> 0; ([_|T]) -> this()(T)+1 end. Is there something in BEAM instruction set, that preventing from implementing this? thanks, Zvi Christian S wrote: > > On Feb 4, 2008 11:39 PM, Attila Babo wrote: >> I wrote a simple Y combinator to deal with tail-recursive anonymous >> functions. There are several showcase implementations for Erlang >> already, but for practical purposes you need to deal with arity. Here >> is my code with examples, I'm looking for a way to avoid this >> boilerplate code. For practical reasons it's OK to generate it up to a >> point by hand or use a single tuple as a parameter, but I'm looking >> for "nicer" solution. Any suggestions? > > That's the way its done. Only improvement would be to use the > erlang:is_funciton/2 guard. But that is not likely what you were looking > for. > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > > -- View this message in context: http://www.nabble.com/Auto-generated-functions-tp15279499p15312902.html Sent from the Erlang Questions mailing list archive at Nabble.com. From matthias Wed Feb 6 22:30:43 2008 From: matthias (Matthias Lang) Date: Wed, 6 Feb 2008 22:30:43 +0100 Subject: [erlang-questions] Erlang/OTP R12B-1 has been released In-Reply-To: References: Message-ID: <18346.9987.466847.511122@antilipe.corelatus.se> Holger Hoffstaette writes: > Generic source: > http://hoho.dyndns.org/~holger/dist/otp_src_R12B-1.tar.gz.torrent As far as I can see, erlang.org doesn't post checksums of any sort. How can I know this isn't a trojan? (apart from downloading a copy from erlang.org and comparing, which would defeat the point) The erlang.org site has four mirrors, which are listed here: http://erlang.org/mirrors.html The mirrors can be trusted at least to the extent that the people running erlang.org trust them enough to list them as mirrors. I just checked that the high bandwidth Stockholm University mirror has the new source. It does, though I know it didn't earlier today when it was needed most. Seems Erlang's popularity is growing faster than the OTP group's outbound bandwidth. Matthias From kostis Thu Feb 7 00:23:36 2008 From: kostis (Kostis Sagonas) Date: Thu, 07 Feb 2008 01:23:36 +0200 Subject: [erlang-questions] Wrong compilation warning In-Reply-To: <3dbc6d1c0802061453u7918d749r37cf4815e866448d@mail.gmail.com> References: <47AA18A5.8010100@cs.ntua.gr> <3dbc6d1c0802061453u7918d749r37cf4815e866448d@mail.gmail.com> Message-ID: <47AA4178.7070602@cs.ntua.gr> Robert Virding wrote: > On 06/02/2008, *Kostis Sagonas* > wrote: > > Maxim Treskin wrote: > >>... > > -record(core_state, { > > ctx_ids = [] :: [#ctx_ids{}], > > contexts = [] :: [#context{}] > > }). > > > > I see a warning: > > Warning: record context is unused > > > > Record #context is unused in code, except in definition of record > > #core_state. May be is it compilation bug? > > Well, a superfluous warning, even if bogus, is clearly not a compilation > bug. In your code the culprit is the linter (erl_lint) that has not > been adapted to take into account type annotations in record > declarations. > This might happen soon -- possibly even in the next R12 release. > > > No, the warning is absolutely correct, the record context has not been > used. All the type declaration says is that a record of type context > *could* be used, but until you actually create a record of type context > then it hasn't been used. Sorry, I beg to differ. The warning is wrong. First of all, the warning should read: "the *declaration* of record context is unused". If it actually meant what you suggested above, then the compiler should also spit out a warning in the following code: ---------------------------------------- -record(context, ...). is_context{X) -> is_record(X, context). ---------------------------------------- as this code does not really create any context record. Anyway, my point is that the compiler should not warn when the declaration of a record is needed for some reason. In Maxim's code, the declaration of the context record is needed for the type declaration of fields of some other record. Without it, the file does not compile. The compiler cannot spit a warning for something that results in a compilation error if you fix the way the warning suggests. > I'm just waiting (NOT) for day we see a compiler error "missing type > declaration". :-) You'll never see such a compiler *error*, but the day you'll see such a warning might be sooner than you think... Cheers, Kostis PS. While playing with the compiler, I was somewhat surprised to discover that there is no error/warning when a module does not contain any export declaration. The compiler warns that all the module's functions are unused but other than that the module happily compiles & loads. I found that slightly weird... From rvirding Wed Feb 6 23:53:17 2008 From: rvirding (Robert Virding) Date: Wed, 6 Feb 2008 23:53:17 +0100 Subject: [erlang-questions] Wrong compilation warning In-Reply-To: <47AA18A5.8010100@cs.ntua.gr> References: <47AA18A5.8010100@cs.ntua.gr> Message-ID: <3dbc6d1c0802061453u7918d749r37cf4815e866448d@mail.gmail.com> On 06/02/2008, Kostis Sagonas wrote: > > Maxim Treskin wrote: > >>... > > -record(core_state, { > > ctx_ids = [] :: [#ctx_ids{}], > > contexts = [] :: [#context{}] > > }). > > > > I see a warning: > > Warning: record context is unused > > > > Record #context is unused in code, except in definition of record > > #core_state. May be is it compilation bug? > > Well, a superfluous warning, even if bogus, is clearly not a compilation > bug. In your code the culprit is the linter (erl_lint) that has not > been adapted to take into account type annotations in record declarations. > This might happen soon -- possibly even in the next R12 release. No, the warning is absolutely correct, the record context has not been used. All the type declaration says is that a record of type context *could* be used, but until you actually create a record of type context then it hasn't been used. Semantic "hair-splitting" it maybe, but still ... :-) I'm just waiting (NOT) for day we see a compiler error "missing type declaration". :-) Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080206/55d3ab88/attachment-0001.html From wglozer Thu Feb 7 00:09:02 2008 From: wglozer (Will) Date: Wed, 6 Feb 2008 15:09:02 -0800 Subject: [erlang-questions] Question about Patch: Add MD5 and SHA1 sign/verify functions In-Reply-To: References: Message-ID: Hi Daniel, In addition to the N and E parameters, you also need D, P, and Q, in that order. Regards, Will On Feb 5, 2008 2:40 AM, Daniel Kwiecinski wrote: > I've applied the path from > http://article.gmane.org/gmane.comp.lang.erlang.patches/151 and > I did the following. Any help explaining cause of the error will be > very appreciated. Do I correct use MPints? > > ************* CODE ************************************************************* > encode(String) when is_list(String) -> > {ok,{'RSAPrivateKey', 'two-prime', N , E, _, _, _, _, _, _, _}} = > ssl_pkix:decode_rsa_keyfile("keys/private.pem", ""), > io:format("N: ~p, E: ~p~n", [N, E]), > LicEncoded = base64:encode(String), > DataSize = size(StringEncoded), > Data = list_to_binary([<>, StringEncoded]), > Key = [crypto:mpint(N), crypto:mpint(E)], > Signed = crypto:rsa_sha_sign(Data, Key). > > > ************* OUTPUT > ************************************************************ > > 1> N: 138445250593310927542773857214440421480303788023222788575718585027863611115049364971357691872676298545743250295800358402756549552994822827897856839673996350473620588754354369610803297438509920062322876055789528692164182842422276496510610413689066855989959284865235115518531216882699698497082235347230922628187, > E: 65537 > > ERROR erlang code crashed: > Reason: {badarg,[{erlang,port_control, > [#Port<0.726>,37, > [<<0,0,0,12,89,87,74,106,101,72,108,54,77,84,73,122>>, > [<<0,0,0,129,0,197,39,15,141,167,6,5,108,161,36,156, > 232,98,38,254,39,218,195,218,129,86,197,124,175, > 154,216,158,194,246,96,166,139,158,183,81,58,162, > 18,64,198,190,247,160,66,39,71,212,124,232,153, > 25,254,239,65,183,202,58,151,88,229,174,59,162,4, > 230,41,233,100,28,179,130,16,216,89,163,179,59, > 223,210,251,174,78,108,157,165,251,234,86,60,198, > 244,158,230,64,250,137,86,85,7,55,61,26,94,207, > 27,171,40,181,95,236,192,7,33,219,39,233,110,211, > 132,47,236,69,170,167,6,171,220,91>>, > <<0,0,0,3,1,0,1>>]]]}, > {crypto,control,2}, > {crypto,rsa_sha_sign,2}, > > -- > Kind Regards, > Daniel Kwiecinski > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > From rvirding Thu Feb 7 02:01:15 2008 From: rvirding (Robert Virding) Date: Thu, 7 Feb 2008 02:01:15 +0100 Subject: [erlang-questions] Wrong compilation warning In-Reply-To: <47AA4178.7070602@cs.ntua.gr> References: <47AA18A5.8010100@cs.ntua.gr> <3dbc6d1c0802061453u7918d749r37cf4815e866448d@mail.gmail.com> <47AA4178.7070602@cs.ntua.gr> Message-ID: <3dbc6d1c0802061701h1d4e703eq73e0283ec676fa4@mail.gmail.com> On 07/02/2008, Kostis Sagonas wrote: > > > > PS. While playing with the compiler, I was somewhat surprised to > discover that there is no error/warning when a module does not > contain any export declaration. The compiler warns that all the > module's functions are unused but other than that the module happily > compiles & loads. I found that slightly weird... > Not really an error though is it, mightn't be very useful, but maybe. The compiler should do what you tell it too and if I don't want anyone using my module then it's my business. :-) Anyway you can still call module_info on it, so the module is not without interface. Seriously though I think the compiler should be very careful with what it classifies as errors. Seeing Erlang handles errors then errors may be a part of the application, for example used for detecting illegal behaviour. Warn perhaps, but allow almost anything you can generate code for. Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080207/f624bdb6/attachment.html From exta7 Thu Feb 7 02:21:32 2008 From: exta7 (Zvi) Date: Wed, 6 Feb 2008 17:21:32 -0800 (PST) Subject: [erlang-questions] erlsom and binary parsing output In-Reply-To: <407d9ef80801090800q67848043wbc49107b25c2719c@mail.gmail.com> References: <14588326.post@talk.nabble.com> <4781D817.8090203@ericsson.com> <14669389.post@talk.nabble.com> <14674437.post@talk.nabble.com> <407d9ef80801090800q67848043wbc49107b25c2719c@mail.gmail.com> Message-ID: <15325643.post@talk.nabble.com> Hi Willem, I using erlsom and it's much easier to use, than xmerl. The added benefit, that I do not need to patch my Erlang instalation with 'windows-1252' encoding support. My problem with erlsom is,that parsed strings are lists. Is there are any option in erlsom so xs:string will be mapped to the Erlang binary? Also in XML Data Binding product I was using with C++, you can specify mappings from XSD datatypes to the C++ datatypes and even create mappings for custom datatypes. In my schema I have integers and floats, besides strings, but they all mapped to strings (more exactly to Erlang lists of ASCII codes :). Some C++ XML Data Binding products even handle enums (which is much bigger problem in C++ than in Erlang - no atoms). For example I can map XSD datatype xs:date to my custom class CDate and just provide two methods: fromString and toString. If erlsom will map at least standard XSD datatypes to standard Erlang datatypes it will be also usefull. Thanks for the usefull tool. Zvi Willem de Jong-2 wrote: > > Hi, > > Similar to what Bertil suggested for Xmerl, you can achieve this in Erlsom > by adding a clause > > "windows-1252" -> 'iso-8859-1'; %% note: this is actually introducing a > bug > > %% in order to work around a problem! > > to the case statement in encoding_type() in erlsom_lib.erl. > > I would be interested to know why you think it will be necessary to > replace > it by a C++ port. It seems to me that it will be complicating things > considerably. What are the requirements that make this necessary? What > properties should an Erlang XML parser have? > > Regards, > Willem > > > On 1/7/08, Zvi wrote: >> >> >> XML generated by closed-source 3rd party Windows server (if it was >> generated >> by me, then it was encoded in utf-8). >> I asking here questions from Erlang domain, not the obvious & ugly common >> sence solutions, like reading the entire file into memory, changing the >> encoding string and only then feeding it into xmerl. (the problem only >> that >> this XML can be quite big, like 0.5 MB and more). >> Maybe xmerl has some option for forcing encoding, other than specified in >> the PI? >> Maybe there is some other XML parser like erlsom or expat driver, which >> supports windows-1252 encoding? >> Anyway I using xmerl just for prototyping, the long term solution will be >> to >> write C++ port, which will be doing all the XML processing and return >> Erlang >> terms in either text or binary form, which can be read either by >> file:consult or binary_to_term on the Erlang side. >> >> ZVi >> >> >> Christian S wrote: >> > >> > Why not ask yourself how to change your xml so it says iso-8859-1 as >> you >> > say >> > it should be doing? >> > >> > http://en.wikipedia.org/wiki/Garbage_In,_Garbage_Out >> > >> > On Jan 7, 2008 5:22 PM, Zvi wrote: >> >> >> >> Bertil, >> >> >> >> thanks for the reply. >> >> Actually the charcter set used is always latin-1, but for some reason >> 3rd >> >> party software call it windows-1252 . So if you can tell me, what I >> >> should >> >> change in xmerl, so it will threat windows-1252 as Latin-1 . >> > _______________________________________________ >> > erlang-questions mailing list >> > erlang-questions >> > http://www.erlang.org/mailman/listinfo/erlang-questions >> > >> > >> >> -- >> View this message in context: >> http://www.nabble.com/Exception-in-xmerl%2C-when-pasing-XML-with-non-UTF8-character-set-tp14588326p14674437.html >> Sent from the Erlang Questions mailing list archive at Nabble.com. >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > -- View this message in context: http://www.nabble.com/Exception-in-xmerl%2C-when-pasing-XML-with-non-UTF8-character-set-tp14588326p15325643.html Sent from the Erlang Questions mailing list archive at Nabble.com. From zerthurd Thu Feb 7 04:11:41 2008 From: zerthurd (Maxim Treskin) Date: Thu, 7 Feb 2008 09:11:41 +0600 Subject: [erlang-questions] [erlang-announce] Erlang/OTP R12B-1 has been released In-Reply-To: References: Message-ID: Hello Thank you for new release! Is it possible to provide OTP tarballs without compiled beams? It possible can decrease your server load. -- Maxim Treskin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080207/1d9315f4/attachment.html From wglozer Thu Feb 7 00:19:33 2008 From: wglozer (Will) Date: Wed, 6 Feb 2008 15:19:33 -0800 Subject: [erlang-questions] Erlounge in San Francisco, 17-22 February In-Reply-To: <3dbc6d1c0802011452v20c7df1fu966a326e8ed87e8b@mail.gmail.com> References: <3dbc6d1c0801190827l11ac1050yae37415a0e565270@mail.gmail.com> <3dbc6d1c0802011452v20c7df1fu966a326e8ed87e8b@mail.gmail.com> Message-ID: I'd prefer Monday the 18th as well. 2008/2/1 Robert Virding : > Thank you for the good response, now we just have to work out a suitable day > to meet. Looking at my schedule for the conference these are my preferences > (from best to worst): > > Saturday 16/2 (but I will be tired after the trip) > Sunday 17/2 > Tuesday 19/2 > Monday 18/2 > Friday 22/2 > > Wednesday and Thursday are a no-no. Come with suggestions and we'll decide. > > Well met, > Robert > > > On 19/01/2008, Robert Virding wrote: > > > > I will be in San Francisco 17-22 of February (actually from the 16th) for > a conference* and if there are any other Erlangers there perhaps we could > meet over a beer and have a nice discussion. Let me know and we can arrange > something. > > > > Robert > > > > *Game Developers Conference which until recently has had very little to do > with Erlang, they're all C++ weenies. > > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > From bjorn Thu Feb 7 09:17:23 2008 From: bjorn (Bjorn Gustavsson) Date: 07 Feb 2008 09:17:23 +0100 Subject: [erlang-questions] Erlang/OTP R12B-1 has been released In-Reply-To: <18346.9987.466847.511122@antilipe.corelatus.se> References: <18346.9987.466847.511122@antilipe.corelatus.se> Message-ID: Matthias Lang writes: > As far as I can see, erlang.org doesn't post checksums of any sort. > How can I know this isn't a trojan? (apart from downloading a copy from > erlang.org and comparing, which would defeat the point) http://www.erlang.org/download/MD5 (It is not easy to find, I know.) /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From nick Thu Feb 7 09:07:40 2008 From: nick (Nicholas Kereakas Gerakines) Date: Thu, 7 Feb 2008 00:07:40 -0800 Subject: [erlang-questions] Erlounge in San Francisco, 17-22 February In-Reply-To: References: <3dbc6d1c0801190827l11ac1050yae37415a0e565270@mail.gmail.com> <3dbc6d1c0802011452v20c7df1fu966a326e8ed87e8b@mail.gmail.com> Message-ID: <76F389D3-F029-4EC3-9037-3D24B9ED6D15@gerakines.net> Beer and good conversation sounds like fun. Monday the 18th works. # Nick Gerakines On Feb 6, 2008, at 3:19 PM, Will wrote: > I'd prefer Monday the 18th as well. > > 2008/2/1 Robert Virding : >> Thank you for the good response, now we just have to work out a >> suitable day >> to meet. Looking at my schedule for the conference these are my >> preferences >> (from best to worst): >> >> Saturday 16/2 (but I will be tired after the trip) >> Sunday 17/2 >> Tuesday 19/2 >> Monday 18/2 >> Friday 22/2 >> >> Wednesday and Thursday are a no-no. Come with suggestions and we'll >> decide. >> >> Well met, >> Robert >> >> >> On 19/01/2008, Robert Virding wrote: >>> >>> I will be in San Francisco 17-22 of February (actually from the >>> 16th) for >> a conference* and if there are any other Erlangers there perhaps we >> could >> meet over a beer and have a nice discussion. Let me know and we can >> arrange >> something. >>> >>> Robert >>> >>> *Game Developers Conference which until recently has had very >>> little to do >> with Erlang, they're all C++ weenies. >>> >>> >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions From frank Thu Feb 7 11:37:38 2008 From: frank (Frank Mueller) Date: Thu, 7 Feb 2008 11:37:38 +0100 (CET) Subject: [erlang-questions] Erlang/OTP R12B-1 has been released In-Reply-To: <18346.9987.466847.511122@antilipe.corelatus.se> References: <18346.9987.466847.511122@antilipe.corelatus.se> Message-ID: <40084.80.228.111.17.1202380658.squirrel@secure.mworld.biz> > Seems Erlang's popularity is growing faster than the OTP group's > outbound bandwidth. Hi Matthias, what's needed to provide a mirror? I've got free capacity which I could spend. Regards mue -- ** ** Frank Mueller / Oldenburg / Germany ** ** http://frank.mweb.de and http://mue.tideland.biz ** From thomasl_erlang Thu Feb 7 10:44:20 2008 From: thomasl_erlang (Thomas Lindgren) Date: Thu, 7 Feb 2008 01:44:20 -0800 (PST) Subject: [erlang-questions] Wrong compilation warning In-Reply-To: <3dbc6d1c0802061701h1d4e703eq73e0283ec676fa4@mail.gmail.com> Message-ID: <406928.63949.qm@web38812.mail.mud.yahoo.com> --- Robert Virding wrote: > On 07/02/2008, Kostis Sagonas > wrote: > > > > > > > > PS. While playing with the compiler, I was > somewhat surprised to > > discover that there is no error/warning when > a module does not > > contain any export declaration. The compiler > warns that all the > > module's functions are unused but other than > that the module happily > > compiles & loads. I found that slightly > weird... > > > > Not really an error though is it, mightn't be very > useful, but maybe. The > compiler should do what you tell it too and if I > don't want anyone using my > module then it's my business. :-) Anyway you can > still call module_info on > it, so the module is not without interface. I believe export_all is not counted as an export; at least that used to be the case. And it's useful not to have to declare an interface right away. (You still have to write the compiler attribute though. Personally, I wouldn't mind a module without exports being implicitly assumed to use export_all, perhaps with a warning.) Best, Thomas ____________________________________________________________________________________ Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping From vychodil.hynek Thu Feb 7 12:49:19 2008 From: vychodil.hynek (Hynek Vychodil) Date: Thu, 7 Feb 2008 12:49:19 +0100 Subject: [erlang-questions] Auto generated functions In-Reply-To: <15312902.post@talk.nabble.com> References: <597c69660802041439p20d3a032mfbff16817f752fec@mail.gmail.com> <15312902.post@talk.nabble.com> Message-ID: <4d08db370802070349p44536490g3656830ef5d17505@mail.gmail.com> Why if you can just use "half" of Y combinator: 3> LenGen = fun(_, []) -> 0; (This, [_|T]) -> This(This, T)+1 end, 3> Len = fun(L) -> LenGen(LenGen, L) end. #Fun 4> Len([a,b,c]). 3 5> Len([]). 0 6> Len(lists:seq(1,100)). 100 7> Len2 = begin G = fun(_, []) -> 0; (This, [_|T]) -> This(This, T)+1 end, fun(L) -> G(G, L) end end. #Fun 8> Len2([]). 0 9> Len2([a,b,c]). 3 10> Len2(lists:seq(1,100)). 100 this() is only syntactic sugar and object oriented approach (not functional). On Feb 6, 2008 11:03 PM, Zvi wrote: > > Y-combinator is cool, but I'm just currious why Erlang doesn't have some > mechanism allowing fun to reference to itself (doesn't mutter if it's > named > or annonymous fun), same way as every process can get it's own PID using > self(), i.e. (here I using this() to reference to function from inside): > > Len = fun([]) -> 0; > ([_|T]) -> this()(T)+1 end. > > Is there something in BEAM instruction set, that preventing from > implementing this? > > thanks, > Zvi > > > Christian S wrote: > > > > On Feb 4, 2008 11:39 PM, Attila Babo wrote: > >> I wrote a simple Y combinator to deal with tail-recursive anonymous > >> functions. There are several showcase implementations for Erlang > >> already, but for practical purposes you need to deal with arity. Here > >> is my code with examples, I'm looking for a way to avoid this > >> boilerplate code. For practical reasons it's OK to generate it up to a > >> point by hand or use a single tuple as a parameter, but I'm looking > >> for "nicer" solution. Any suggestions? > > > > That's the way its done. Only improvement would be to use the > > erlang:is_funciton/2 guard. But that is not likely what you were looking > > for. > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > > -- > View this message in context: > http://www.nabble.com/Auto-generated-functions-tp15279499p15312902.html > Sent from the Erlang Questions mailing list archive at Nabble.com. > > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > -- --Hynek (Pichi) Vychodil -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080207/1ac2f343/attachment.html From hans.bolinder Thu Feb 7 13:30:02 2008 From: hans.bolinder (Hans Bolinder) Date: Thu, 7 Feb 2008 13:30:02 +0100 Subject: [erlang-questions] repeatable dets:insert() error In-Reply-To: References: Message-ID: <18346.63946.843152.689199@gargle.gargle.HOWL> [Daniel Goertzen:] > dets:insert() unexpectedly fails upon inserting the 2,097,176th > element in a stress test program. Thanks for reporting this bug. Patches for R11B-5 and R12B-1 attached below. Best regards, Hans Bolinder, Erlang/OTP team *** /usr/local/otp/releases/otp_beam_solaris8_r11b_patched/lib/stdlib-1.14.5.5/src/dets_v9.erl Wed Jan 23 12:06:42 2008 --- dets_v9.erl Thu Feb 7 13:21:06 2008 *************** *** 1911,1916 **** --- 1911,1918 ---- {Head, ok}; grow(Head, Extra, undefined) -> grow(Head, Extra, seg_zero()); + grow(Head, _Extra, _SegZero) when Head#head.next >= Head#head.max_no_slots -> + {Head, ok}; grow(Head, Extra, SegZero) -> #head{n = N, next = Next, m = M} = Head, SegNum = Next div ?SEGSZP, *** /usr/local/otp/releases/otp_beam_solaris8_r12b_patched/lib/stdlib-1.15.1/src/dets_v9.erl Wed Feb 6 09:28:51 2008 --- dets_v9.erl Thu Feb 7 13:23:23 2008 *************** *** 1934,1939 **** --- 1934,1941 ---- {Head, ok}; grow(Head, Extra, undefined) -> grow(Head, Extra, seg_zero()); + grow(Head, _Extra, _SegZero) when Head#head.next >= Head#head.max_no_slots -> + {Head, ok}; grow(Head, Extra, SegZero) -> #head{n = N, next = Next, m = M} = Head, SegNum = Next div ?SEGSZP, From vychodil.hynek Thu Feb 7 13:30:14 2008 From: vychodil.hynek (Hynek Vychodil) Date: Thu, 7 Feb 2008 13:30:14 +0100 Subject: [erlang-questions] Auto generated functions In-Reply-To: <4d08db370802070349p44536490g3656830ef5d17505@mail.gmail.com> References: <597c69660802041439p20d3a032mfbff16817f752fec@mail.gmail.com> <15312902.post@talk.nabble.com> <4d08db370802070349p44536490g3656830ef5d17505@mail.gmail.com> Message-ID: <4d08db370802070430y204ccdb8of06f491172b3872c@mail.gmail.com> It is possible to add this() functionality by macro expansion without various number of parameters. But varios number of parameters can be done by some parse transformation. In this case I think this() is really only syntactic sugar. Just add letrec syntax element and you can forgot this(). -module(recurrent). -export([lenGen/0, duplicateGen/0]). -define(RC(P), (_This, P)). -define(This, _This). -define(Recur(F), begin _G = F, fun(_param) -> _G(_G,_param) end end). lenGen() -> ?Recur(fun?RC([]) -> 0; ?RC([_|T]) -> ?This?RC(T)+1 end). duplicateGen() -> ?Recur(fun?RC([_, 0]) -> []; ?RC([E, N]) -> [E|?This?RC([E, N-1])] end). On Feb 7, 2008 12:49 PM, Hynek Vychodil wrote: > Why if you can just use "half" of Y combinator: > > 3> LenGen = fun(_, []) -> 0; (This, [_|T]) -> This(This, T)+1 end, > 3> Len = fun(L) -> LenGen(LenGen, L) end. > #Fun > 4> Len([a,b,c]). > 3 > 5> Len([]). > 0 > 6> Len(lists:seq(1,100)). > 100 > 7> Len2 = begin G = fun(_, []) -> 0; (This, [_|T]) -> This(This, T)+1 end, > fun(L) -> G(G, L) end end. > #Fun > 8> Len2([]). > 0 > 9> Len2([a,b,c]). > 3 > 10> Len2(lists:seq(1,100)). > 100 > > this() is only syntactic sugar and object oriented approach (not > functional). > > > On Feb 6, 2008 11:03 PM, Zvi wrote: > > > > > Y-combinator is cool, but I'm just currious why Erlang doesn't have some > > mechanism allowing fun to reference to itself (doesn't mutter if it's > > named > > or annonymous fun), same way as every process can get it's own PID using > > self(), i.e. (here I using this() to reference to function from inside): > > > > Len = fun([]) -> 0; > > ([_|T]) -> this()(T)+1 end. > > > > Is there something in BEAM instruction set, that preventing from > > implementing this? > > > > thanks, > > Zvi > > > > > > Christian S wrote: > > > > > > On Feb 4, 2008 11:39 PM, Attila Babo wrote: > > >> I wrote a simple Y combinator to deal with tail-recursive anonymous > > >> functions. There are several showcase implementations for Erlang > > >> already, but for practical purposes you need to deal with arity. Here > > >> is my code with examples, I'm looking for a way to avoid this > > >> boilerplate code. For practical reasons it's OK to generate it up to > > a > > >> point by hand or use a single tuple as a parameter, but I'm looking > > >> for "nicer" solution. Any suggestions? > > > > > > That's the way its done. Only improvement would be to use the > > > erlang:is_funciton/2 guard. But that is not likely what you were > > looking > > > for. > > > _______________________________________________ > > > erlang-questions mailing list > > > erlang-questions > > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > > > > > > -- > > View this message in context: > > http://www.nabble.com/Auto-generated-functions-tp15279499p15312902.html > > Sent from the Erlang Questions mailing list archive at Nabble.com. > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > > -- > --Hynek (Pichi) Vychodil -- --Hynek (Pichi) Vychodil -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080207/26fefb19/attachment.html From daniel.goertzen Thu Feb 7 15:47:14 2008 From: daniel.goertzen (Daniel Goertzen) Date: Thu, 7 Feb 2008 08:47:14 -0600 Subject: [erlang-questions] Erlang/OTP R12B-1 has been released In-Reply-To: References: Message-ID: The torrent worked really well, I got the whole thing in about 60 seconds. (cable modem in Canada) Dan. On Feb 6, 2008 12:29 PM, Holger Hoffstaette wrote: > > for Windows: > http://hoho.dyndns.org/~holger/dist/otp_win32_R12B-1.exe.torrent > > Please keep seeding until the poor erlang.org server is better :) > > Holger > > > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080207/e337d4e0/attachment.html From bob Thu Feb 7 16:47:02 2008 From: bob (Bob Ippolito) Date: Thu, 7 Feb 2008 07:47:02 -0800 Subject: [erlang-questions] Erlang/OTP R12B-1 has been released In-Reply-To: <40084.80.228.111.17.1202380658.squirrel@secure.mworld.biz> References: <18346.9987.466847.511122@antilipe.corelatus.se> <40084.80.228.111.17.1202380658.squirrel@secure.mworld.biz> Message-ID: <6a36e7290802070747g3df0fd7ehc4c0369bd8a76161@mail.gmail.com> On Feb 7, 2008 2:37 AM, Frank Mueller wrote: > > Seems Erlang's popularity is growing faster than the OTP group's > > outbound bandwidth. > > what's needed to provide a mirror? I've got free capacity which I could spend. > There are instructions at the bottom of this page: http://erlang.org/mirrors.html Be prepared to wait, the rsync is sloooooow! -bob From matthew Thu Feb 7 08:00:54 2008 From: matthew (Matthew Dempsky) Date: Wed, 6 Feb 2008 23:00:54 -0800 Subject: [erlang-questions] Patrick Mahoney's SIGWINCH patch Message-ID: I noticed that Patrick Mahoney's SIGWINCH patch[1] was not included in R12B-1. Is it possible for it to be included in R12B-2? Are there any issues that need to be resolved for it to be acceptable for inclusion? [1] http://www.erlang.org/pipermail/erlang-patches/2007-December/000205.html From bob Thu Feb 7 17:18:46 2008 From: bob (Bob Ippolito) Date: Thu, 7 Feb 2008 08:18:46 -0800 Subject: [erlang-questions] Erlang/OTP R12B-1 has been released In-Reply-To: <6a36e7290802070747g3df0fd7ehc4c0369bd8a76161@mail.gmail.com> References: <18346.9987.466847.511122@antilipe.corelatus.se> <40084.80.228.111.17.1202380658.squirrel@secure.mworld.biz> <6a36e7290802070747g3df0fd7ehc4c0369bd8a76161@mail.gmail.com> Message-ID: <6a36e7290802070818ia470336lee81f6edd3af6abe@mail.gmail.com> On Feb 7, 2008 7:47 AM, Bob Ippolito wrote: > On Feb 7, 2008 2:37 AM, Frank Mueller wrote: > > > Seems Erlang's popularity is growing faster than the OTP group's > > > outbound bandwidth. > > > > what's needed to provide a mirror? I've got free capacity which I could spend. > > > > There are instructions at the bottom of this page: > http://erlang.org/mirrors.html > > Be prepared to wait, the rsync is sloooooow! > Oh, and we've got a US mirror here (in San Francisco, CA). Currently updating daily: http://erlang-mirror.mochimedia.net/ -bob From masterofquestions Thu Feb 7 17:59:23 2008 From: masterofquestions (db) Date: Thu, 7 Feb 2008 11:59:23 -0500 Subject: [erlang-questions] Erlang OTP .rel file start/supervise application remote node Message-ID: <1218d6a50802070859v645fc175vc41fdc1f25ed6fd8@mail.gmail.com> Does erlang otp and .rel files allow starting/supervising application on remote node? If so, how do you define it in .rel file? I have gone through all the documentations. Documentation mainly describes about how to start/supervise application on the same nodes. No mention of starting/supervise application on remote node. Does this mean otp does not support it or it's undocumented? thanks. -- rk -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080207/b5baa384/attachment.html From ratmapper Wed Feb 6 15:46:14 2008 From: ratmapper (Raimo Niskanen) Date: Wed, 6 Feb 2008 15:46:14 +0100 Subject: [erlang-questions] test Message-ID: We (erlang.org) are currently under heavy attack from spammers. This is a test mail. From kg9020 Thu Feb 7 18:38:58 2008 From: kg9020 (kg9) Date: Thu, 7 Feb 2008 09:38:58 -0800 (PST) Subject: [erlang-questions] Erlounge in San Francisco, Feb 10 - 16 Message-ID: <15339060.post@talk.nabble.com> Hello, I noticed the post for erlounge feb 17, I was wondering is there anything going on between Feb 10 - 16 thanks arthur -- View this message in context: http://www.nabble.com/Erlounge-in-San-Francisco%2C---Feb-10---16-tp15339060p15339060.html Sent from the Erlang Questions mailing list archive at Nabble.com. From ignatios Thu Feb 7 18:33:06 2008 From: ignatios (Ignatios Souvatzis) Date: Thu, 7 Feb 2008 18:33:06 +0100 Subject: [erlang-questions] inet_res: Message-ID: <20080207173306.GA26462@cs.uni-bonn.de> Hi, while browsing inet_res.erl (from R11B-5 and R12B-0), I found it still uses ip6.int; to be precise: gethostbyaddr_tm() calls res_gethostbyaddr(dn_ip6_int(...)) which in turn translates the address to the DNS key using dn_ip6_int(A,B,C,D,E,F,G,H) -> dnib(H) ++ dnib(G) ++ dnib(F) ++ dnib(E) ++ dnib(D) ++ dnib(C) ++ dnib(B) ++ dnib(A) ++ "IP6.INT". It should instead call a function (for niceness called dn_ip6_arpa) that adds "IP6.ARPA" at the end, although the safe coding method would be to not rename dn_ip6_int(), I guess. "IP6.INT" was deprecated with RFC3152 (BCP 49) in August 2001 and removed with RFC 3596 in October 2003. (This might explain why my quick inet_res tests in the shell weren't as successful as I wished - I didn't actually fix inet_res.erl yet and test the fix.) Regards, -is From dking Thu Feb 7 19:50:08 2008 From: dking (David King) Date: Thu, 7 Feb 2008 10:50:08 -0800 Subject: [erlang-questions] Erlounge in San Francisco, Feb 10 - 16 In-Reply-To: <15339060.post@talk.nabble.com> References: <15339060.post@talk.nabble.com> Message-ID: > I noticed the post for erlounge feb 17, I was wondering is there > anything > going on between Feb 10 - 16 Try bay-area-erlangers I'm trying to set one up in SoMa that week. Suggest a time on that list From dustin.whitney Thu Feb 7 05:57:39 2008 From: dustin.whitney (Dustin Whitney) Date: Wed, 6 Feb 2008 23:57:39 -0500 Subject: [erlang-questions] kick start a newb! Message-ID: <23def8000802062057x65888024g9cb1cc99cdd15c93@mail.gmail.com> I'd really like to get into Erlang, but I'm stumbling over some UTF 8 troubles. Could someone please explain to me why the code below results in a list of integers instead of the XML document I'm supposed to get (I think it has something to do with UTF8), I'd really appreciate it. The second listing of code works just fine, and I believe it works because slashdot encodes their data in iso-8859-1. How can I output UTF8 in a format that is readable? And, ultimately I want to run an XPath query against the XML document I get from the GET request... baby steps I suppose. Any help would be great, especially links to documentation! Thanks, Dustin Listing #1 -module(tmp). -export([get_url/0]). get_url() -> {_,{_, Header, Body}} = http:request(" http://dbpedia.org/sparql?default-graph-uri=http%3A%2F%2Fdbpedia.org&should-sponge=&query=PREFIX+xsd%3A+%3Chttp%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema%23%3E%0D%0APREFIX+rdfs%3A+%3Chttp%3A%2F%2Fwww.w3.org%2F2000%2F01%2Frdf-schema%23%3E%0D%0APREFIX+rdf%3A+%3Chttp%3A%2F%2Fwww.w3.org%2F1999%2F02%2F22-rdf-syntax-ns%23%3E%0D%0APREFIX+dbpedia2%3A+%3Chttp%3A%2F%2Fdbpedia.org%2Fproperty%2F%3E%0D%0A%0D%0ASELECT+*+WHERE+%7B%0D%0A%3Fsubject+rdf%3Atype+%3Chttp%3A%2F%2Fdbpedia.org%2Fclass%2Fyago%2FCity108524735%3E.%0D%0A%3Fsubject+rdfs%3Alabel+%3Flabel.%0D%0A%3Fsubject+dbpedia2%3Apopulation+%3Fpopulation.%0D%0AFILTER+%28lang%28%3Flabel%29+%3D+%22en%22+%26%26+xsd%3Ainteger%28%3Fpopulation%29+%3E+200000%29%0D%0A%7D&format=application%2Fsparql-results+xml&debug=on "), Body. Listing #2 -module(tmp). -export([get_url/0]). get_url() -> {_,{_, Header, Body}} = http:request("http://slashdot.org"), Body. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080206/e8cfff68/attachment.html From vlm Thu Feb 7 22:02:55 2008 From: vlm (Lev Walkin) Date: Thu, 07 Feb 2008 13:02:55 -0800 Subject: [erlang-questions] kick start a newb! In-Reply-To: <23def8000802062057x65888024g9cb1cc99cdd15c93@mail.gmail.com> References: <23def8000802062057x65888024g9cb1cc99cdd15c93@mail.gmail.com> Message-ID: <47AB71FF.50202@lionet.info> Try printing out [65, 65, 65], the rest should be obvious. Dustin Whitney wrote: > I'd really like to get into Erlang, but I'm stumbling over some UTF 8 > troubles. Could someone please explain to me why the code below results > in a list of integers instead of the XML document I'm supposed to get (I > think it has something to do with UTF8), I'd really appreciate it. The > second listing of code works just fine, and I believe it works because > slashdot encodes their data in iso-8859-1. How can I output UTF8 in a > format that is readable? And, ultimately I want to run an XPath query > against the XML document I get from the GET request... baby steps I > suppose. Any help would be great, especially links to documentation! > > Thanks, > Dustin > > Listing #1 > > -module(tmp). > -export([get_url/0]). > > get_url() -> > {_,{_, Header, Body}} = > http:request("http://dbpedia.org/sparql?default-graph-uri=http%3A%2F%2Fdbpedia.org&should-sponge=&query=PREFIX+xsd%3A+%3Chttp%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema%23%3E%0D%0APREFIX+rdfs%3A+%3Chttp%3A%2F%2Fwww.w3.org%2F2000%2F01%2Frdf-schema%23%3E%0D%0APREFIX+rdf%3A+%3Chttp%3A%2F%2Fwww.w3.org%2F1999%2F02%2F22-rdf-syntax-ns%23%3E%0D%0APREFIX+dbpedia2%3A+%3Chttp%3A%2F%2Fdbpedia.org%2Fproperty%2F%3E%0D%0A%0D%0ASELECT+*+WHERE+%7B%0D%0A%3Fsubject+rdf%3Atype+%3Chttp%3A%2F%2Fdbpedia.org%2Fclass%2Fyago%2FCity108524735%3E.%0D%0A%3Fsubject+rdfs%3Alabel+%3Flabel.%0D%0A%3Fsubject+dbpedia2%3Apopulation+%3Fpopulation.%0D%0AFILTER+%28lang%28%3Flabel%29+%3D+%22en%22+%26%26+xsd%3Ainteger%28%3Fpopulation%29+%3E+200000%29%0D%0A%7D&format=application%2Fsparql-results+xml&debug=on > "), > Body. > > > > Listing #2 > > -module(tmp). > -export([get_url/0]). > > get_url() -> > {_,{_, Header, Body}} = http:request("http://slashdot.org"), > Body. > > > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions From rvirding Thu Feb 7 22:53:44 2008 From: rvirding (Robert Virding) Date: Thu, 7 Feb 2008 22:53:44 +0100 Subject: [erlang-questions] Erlounge in San Francisco, 17-22 February In-Reply-To: <76F389D3-F029-4EC3-9037-3D24B9ED6D15@gerakines.net> References: <3dbc6d1c0801190827l11ac1050yae37415a0e565270@mail.gmail.com> <3dbc6d1c0802011452v20c7df1fu966a326e8ed87e8b@mail.gmail.com> <76F389D3-F029-4EC3-9037-3D24B9ED6D15@gerakines.net> Message-ID: <3dbc6d1c0802071353v2873419x88587f630da567ac@mail.gmail.com> OK, monday the 18th it is! At 7.30 pm. Name a good pub/bar and we'll meet. I'm staying down-town near the conference center, but I will have a car so I can get almost anywhere. Robert On 07/02/2008, Nicholas Kereakas Gerakines wrote: > > > Beer and good conversation sounds like fun. Monday the 18th works. > > # Nick Gerakines > > On Feb 6, 2008, at 3:19 PM, Will wrote: > > > I'd prefer Monday the 18th as well. > > > > 2008/2/1 Robert Virding : > >> Thank you for the good response, now we just have to work out a > >> suitable day > >> to meet. Looking at my schedule for the conference these are my > >> preferences > >> (from best to worst): > >> > >> Saturday 16/2 (but I will be tired after the trip) > >> Sunday 17/2 > >> Tuesday 19/2 > >> Monday 18/2 > >> Friday 22/2 > >> > >> Wednesday and Thursday are a no-no. Come with suggestions and we'll > >> decide. > >> > >> Well met, > >> Robert > >> > >> > >> On 19/01/2008, Robert Virding wrote: > >>> > >>> I will be in San Francisco 17-22 of February (actually from the > >>> 16th) for > >> a conference* and if there are any other Erlangers there perhaps we > >> could > >> meet over a beer and have a nice discussion. Let me know and we can > >> arrange > >> something. > >>> > >>> Robert > >>> > >>> *Game Developers Conference which until recently has had very > >>> little to do > >> with Erlang, they're all C++ weenies. > >>> > >>> > >> > >> > >> _______________________________________________ > >> erlang-questions mailing list > >> erlang-questions > >> http://www.erlang.org/mailman/listinfo/erlang-questions > >> > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions > > http://www.erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080207/fe7db39e/attachment-0001.html From samuel Thu Feb 7 23:42:30 2008 From: samuel (Samuel Tesla) Date: Thu, 7 Feb 2008 16:42:30 -0600 Subject: [erlang-questions] kick start a newb! In-Reply-To: <23def8000802062057x65888024g9cb1cc99cdd15c93@mail.gmail.com> References: <23def8000802062057x65888024g9cb1cc99cdd15c93@mail.gmail.com> Message-ID: <4bd555f70802071442y6af6a6d4gb22e91427f5d8f1a@mail.gmail.com> Dustin: Looking at the URL you included in your post, I'd agree it probably is UTF-8 related. As Lev was alluding to in his response, in Erlang strings are just a list of integers. At the top level, when you have a list of integers, if all of them are printable ASCII characters, it will display them as a string, hence [65,65,65] will be printed "AAA", whereas [1,2,3] will print [1,2,3]. Not all of the bytes in a UTF-8 encoded string are necessarily printable ASCII. So, it shows up as a list of integers. What you may want to do is look at xmerl (http://erlang.org/doc/apps/xmerl/index.html) to parse the XML. It will handle the character set conversions. If, for some reason, you want to do it on your own, I believe xmerl_ucs:from_utf8/1 may serve you well. But, that module is undocumented and thus not guaranteed to remain the same from release to release. I hope that helps! -- Samuel -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080207/80a6c672/attachment.html From dustin.whitney Thu Feb 7 23:57:12 2008 From: dustin.whitney (Dustin Whitney) Date: Thu, 7 Feb 2008 17:57:12 -0500 Subject: [erlang-questions] kick start a newb! In-Reply-To: <4bd555f70802071442y6af6a6d4gb22e91427f5d8f1a@mail.gmail.com> References: <23def8000802062057x65888024g9cb1cc99cdd15c93@mail.gmail.com> <4bd555f70802071442y6af6a6d4gb22e91427f5d8f1a@mail.gmail.com> Message-ID: <23def8000802071457nda6f016yc9dc76b734900059@mail.gmail.com> I modified the last line of my script to io:fwrite(Body). and that printed it out for me in a human readable format. I will check out xmerl_ucs:from_utf8/1 and see what it does. I want to run some XPath against the document anyway, so I'll be looking at that module anyway. I really appreciate the help. -Dustin On Feb 7, 2008 5:42 PM, Samuel Tesla wrote: > Dustin: > > Looking at the URL you included in your post, I'd agree it probably is > UTF-8 related. As Lev was alluding to in his response, in Erlang strings are > just a list of integers. At the top level, when you have a list of integers, > if all of them are printable ASCII characters, it will display them as a > string, hence [65,65,65] will be printed "AAA", whereas [1,2,3] will print > [1,2,3]. > > Not all of the bytes in a UTF-8 encoded string are necessarily printable > ASCII. So, it shows up as a list of integers. What you may want to do is > look at xmerl (http://erlang.org/doc/apps/xmerl/index.html) to parse the > XML. It will handle the character set conversions. If, for some reason, you > want to do it on your own, I believe xmerl_ucs:from_utf8/1 may serve you > well. But, that module is undocumented and thus not guaranteed to remain the > same from release to release. > > I hope that helps! > > -- Samuel > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080207/c90ad2a4/attachment.html From w.a.de.jong Fri Feb 8 00:10:14 2008 From: w.a.de.jong (Willem de Jong) Date: Fri, 8 Feb 2008 00:10:14 +0100 Subject: [erlang-questions] erlsom and binary parsing output In-Reply-To: <15325643.post@talk.nabble.com> References: <14588326.post@talk.nabble.com> <4781D817.8090203@ericsson.com> <14669389.post@talk.nabble.com> <14674437.post@talk.nabble.com> <407d9ef80801090800q67848043wbc49107b25c2719c@mail.gmail.com> <15325643.post@talk.nabble.com> Message-ID: <407d9ef80802071510m1071c996rafd688f24245d845@mail.gmail.com> Hi Zvi, I am pleased to hear that you like the tool :) At this moment there is no way to tell erlsom that it should map strings to binaries in stead of lists. Right now erlsom only maps integers, booleans and qnames (and only under certain conditions - it doesn't try to determine what the type is of an extended or restricted type). The sax parser that is part of erlsom already does the decoding of the binary input to a list of integers (unicode 'code points'). This means that the layer that deals with all the schema-stuff would have to re-encode it again, which wouldn't be very efficient. However, I am currently finalising a new version the sax-parser. This version will take advantage of the improved handling of binaries in R12B; it will work directly on binaries. In theory it could also return binaries, but I am not sure this would be a good idea. It depends on what you want to do with the output, I guess. Your request raises a couple of questions: - if erlsom would mp strings to binaries, then these binaries have to be encoded in some way (unless you want to accept only ASCII). What encoding should it use? My feeling is that UTF-8 would be the best choice. - if you want to have this kind of mapping, then you need a way to tell erlsom what to map, and how. What would be the way to do this? Would you prefer to add some special information to the xsd, or would you like to do it in another way? Anyway, currently I do not have any plans to do a lot of work on this - but I must say that I have also been thinking about the possibility to return binaries in stead of strings. It might be a possibility to introduce an option to have binaries (utf-8 encoded) in all the places where currently strings are used. Regards, Willem On Feb 7, 2008 2:21 AM, Zvi wrote: > > Hi Willem, > > I using erlsom and it's much easier to use, than xmerl. > The added benefit, that I do not need to patch my Erlang instalation with > 'windows-1252' encoding support. > My problem with erlsom is,that parsed strings are lists. Is there are any > option in erlsom so xs:string will be mapped to the Erlang binary? > Also in XML Data Binding product I was using with C++, you can specify > mappings from XSD datatypes to the C++ datatypes and even create mappings > for custom datatypes. > In my schema I have integers and floats, besides strings, but they all > mapped to strings (more exactly to Erlang lists of ASCII codes :). > Some C++ XML Data Binding products even handle enums (which is much bigger > problem in C++ than in Erlang - no atoms). For example I can map XSD > datatype xs:date to my custom class CDate and just provide two methods: > fromString and toString. > If erlsom will map at least standard XSD datatypes to standard Erlang > datatypes it will be also usefull. > > Thanks for the usefull tool. > Zvi > > > > Willem de Jong-2 wrote: > > > > Hi, > > > > Similar to what Bertil suggested for Xmerl, you can achieve this in > Erlsom > > by adding a clause > > > > "windows-1252" -> 'iso-8859-1'; %% note: this is actually introducing a > > bug > > > > %% in order to work around a problem! > > > > to the case statement in encoding_type() in erlsom_lib.erl. > > > > I would be interested to know why you think it will be necessary to > > replace > > it by a C++ port. It seems to me that it will be complicating things > > considerably. What are the requirements that make this necessary? What > > properties should an Erlang XML parser have? > > > > Regards, > > Willem > > > > > > On 1/7/08, Zvi wrote: > >> > >> > >> XML generated by closed-source 3rd party Windows server (if it was > >> generated > >> by me, then it was encoded in utf-8). > >> I asking here questions from Erlang domain, not the obvious & ugly > common > >> sence solutions, like reading the entire file into memory, changing the > >> encoding string and only then feeding it into xmerl. (the problem only > >> that > >> this XML can be quite big, like 0.5 MB and more). > >> Maybe xmerl has some option for forcing encoding, other than specified > in > >> the PI? > >> Maybe there is some other XML parser like erlsom or expat driver, which > >> supports windows-1252 encoding? > >> Anyway I using xmerl just for prototyping, the long term solution will > be > >> to > >> write C++ port, which will be doing all the XML processing and return > >> Erlang > >> terms in either text or binary form, which can be read either by > >> file:consult or binary_to_term on the Erlang side. > >> > >> ZVi > >> > >> > >> Christian S wrote: > >> > > >> > Why not ask yourself how to change your xml so it says iso-8859-1 as > >> you > >> > say > >> > it should be doing? > >> > > >> > http://en.wikipedia.org/wiki/Garbage_In,_Garbage_Out > >> > > >> > On Jan 7, 2008 5:22 PM, Zvi wrote: > >> >> > >> >> Bertil, > >> >> > >> >> thanks for the reply. > >> >> Actually the charcter set used is always latin-1, but for some > reason > >> 3rd > >> >> party software call it windows-1252 . So if you can tell me, what I > >> >> should > >> >> change in xmerl, so it will threat windows-1252 as Latin-1 . > >> > _______________________________________________ > >> > erlang-questions mailing list > >> > erlang-questions > >> > http://www.erlang.org/mailman/listinfo/erlang-questions > >> > > >> > > >> > >> -- > >> View this message in context: > >> > http://www.nabble.com/Exception-in-xmerl%2C-when-pasing-XML-with-non-UTF8-character-set-tp14588326p14674437.html > >> Sent from the Erlang Questions mailing list archive at Nabble.com > . > >> > >> _______________________________________________ > >> erlang-questions mailing list > >> erlang-questions > >> http://www.erlang.org/mailman/listinfo/erlang-questions > >> > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > -- > View this message in context: > http://www.nabble.com/Exception-in-xmerl%2C-when-pasing-XML-with-non-UTF8-character-set-tp14588326p15325643.html > Sent from the Erlang Questions mailing list archive at Nabble.com > . > > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080208/90794d7e/attachment.html From daveb Fri Feb 8 01:40:19 2008 From: daveb (Dave Bryson) Date: Thu, 7 Feb 2008 18:40:19 -0600 Subject: [erlang-questions] Selecting X number of items from Mnesia Message-ID: <3A3520F8-FF0B-448A-A669-F2D113952AA5@miceda.org> I apologize in advance for the newbie question! I'm trying to treat an mnesia table as a FIFO queue. What I'd like to be able to do is pull X number of items off the head of the list returned by a query. There's no conditional values to isolate the records - I just want the top X number of records. Is there an efficient way to do this with qlc? Thanks in advance! Dave From robi123 Fri Feb 8 02:17:02 2008 From: robi123 (Robin) Date: Thu, 7 Feb 2008 17:17:02 -0800 (PST) Subject: [erlang-questions] Jinterface - ping and send trouble Message-ID: <0ecb4460-4d8c-4ac5-ac3f-608dc9cf8732@l16g2000hsh.googlegroups.com> I have Jinterface successfully talking between Erlang and Java. >From Java, I can send a message to any named Erlang process on an Erlang node. >From Erlang, I can send a message direcly to a Jinterface PID: JAVA_PID ! foobar. % works, but getting the PID was round about >From Erlang, I could not send a message to a named Jinterface mailbox, nor ping: {named_mb, javanode} ! foobar. % does not work % then I noticed that ping does not succeed: (erlangnode)9> net_adm:ping(javanode). pang % ping fails, but net_adm can talk to and see the OtpNode (erlangnode)10> net_adm:names(). {ok,[{"erlangnode",52212},{"javanode",52236}]} (erlangnode)12> net_adm:names(rcb.local). {ok,[{"erlangnode",52212},{"javanode",52307}]} Since the communication was verified both ways, then it should be possible to send a message from Erlang to a named Jinterface mailbox, and also ping the Jinterface OtpNode, or are these operations expected not to work? thanks, Robin Jinterface 1.4, erlang R12B, java 1.5.0_13 on OSX From robi123 Fri Feb 8 05:29:14 2008 From: robi123 (Robin) Date: Thu, 7 Feb 2008 20:29:14 -0800 (PST) Subject: [erlang-questions] Jinterface - ping and send trouble In-Reply-To: <0ecb4460-4d8c-4ac5-ac3f-608dc9cf8732@l16g2000hsh.googlegroups.com> References: <0ecb4460-4d8c-4ac5-ac3f-608dc9cf8732@l16g2000hsh.googlegroups.com> Message-ID: <552c0a9b-c850-4803-841a-e5bdb0b67346@q77g2000hsh.googlegroups.com> I spoke too soon, ping and send work. After inspecting the JAVA_PID, the name of the java node is javanode not javanode (erlangnode)23> net_adm:ping(javanode). pong (erlangnode)24> {message, javanode } ! foobar. foobar The node name in the REPL shows erlangnode, but ping expects erlangnode Jinterface ping and send work well, thanks. Robin On Feb 7, 7:17 pm, Robin wrote: > I have Jinterface successfully talking between Erlang and Java. > > >From Java, I can send a message to any named Erlang process on an > > Erlang node. > > >From Erlang, I can send a message direcly to a Jinterface PID: > > JAVA_PID ! foobar. % works, but getting the PID was round about > > >From Erlang, I could not send a message to a named Jinterface mailbox, > > nor ping: > > {named_mb, javan...} ! foobar. % does not work > > % then I noticed that ping does not succeed: > (erlangn...)9> net_adm:ping(javan...). > pang > > % ping fails, but net_adm can talk to and see the OtpNode > (erlangn...)10> net_adm:names(). > {ok,[{"erlangnode",52212},{"javanode",52236}]} > (erlangn...)12> > net_adm:names(rcb.local). > {ok,[{"erlangnode",52212},{"javanode",52307}]} > > Since the communication was verified both ways, then it should be > possible to send a message from Erlang to a named Jinterface mailbox, > and also ping the Jinterface OtpNode, or are these operations expected > not to work? > > thanks, > > Robin > > Jinterface 1.4, erlang R12B, java 1.5.0_13 on OSX > _______________________________________________ > erlang-questions mailing list > erlang-questi...://www.erlang.org/mailman/listinfo/erlang-questions From chandrashekhar.mullaparthi Fri Feb 8 06:34:08 2008 From: chandrashekhar.mullaparthi (Chandru) Date: Fri, 8 Feb 2008 05:34:08 +0000 Subject: [erlang-questions] FW: A patch for ibrowse to extend save_response_to_file behavior In-Reply-To: References: <737EDF428EB6334ABD28B2EE98E0849B151424@HATMSG031.TMOUSERSUK.AD.T-MOBILE.CO.UK> Message-ID: Hi, In case anyone is using the save_response_to_file feature in ibrowse, an enhancement and bug fix has been made. The current version in sourceforge is 1.3.0. You can now specify the filename to save the response to. Thanks to Ram Krishnan for providing a patch. http://jungerl.cvs.sourceforge.net/jungerl/jungerl/lib/ibrowse/ Chandru ---------- Forwarded message ---------- From: Chandru Date: 7 Feb 2008 12:05 Subject: Re: FW: A patch for ibrowse to extend save_response_to_file behavior To: Ram Krishnan Hi Ram, Thanks a lot for the patch. I've been meaning to implement this feature for a long time now. While I was testing your patch, I found quite a few bugs in my original implementation of this feature so I've fixed the code to handle this properly. I've also updated the documentation and checked it all into CVS. I've attached the new modules for your convenience. Only ibrowse_http_client.erl has had a code change. ibrowse.erl only has changes to the comments. cheers Chandru > > -----Original Message----- > From: Ram Krishnan > Sent: 07 February 2008 04:22 > To: Chandrashekhar Mullaparthi > Subject: A patch for ibrowse to extend save_response_to_file behavior > > Hi, > > Firstly, thanks very much for the excellent ibrowse http client package that > you've contributed to Erlang. > > Secondly, I've attached a small patch (cvs diff -u8) which changes the > save_response_to_file option to accept a boolean or a file path as its > value. For example, > > ibrowse:send_req( > Url, > [], > get, > [], > [{save_response_to_file, "/tmp/foo.txt"}]) > > This makes it easy to have each ibrowse request store the response to > different locations when required; instead of a rename (or worse doing a > copy/delete across filesystems). > > Hopefully you will find this patch acceptable. I'm a Lisp programmer, and > recent Erlang convert so I would welcome any feedback you might have on the > changes. > > Thanks. > > -ram From masterofquestions Fri Feb 8 06:58:40 2008 From: masterofquestions (db) Date: Thu, 7 Feb 2008 21:58:40 -0800 (PST) Subject: [erlang-questions] erlang automake and autogenerate erlang otp files Message-ID: <5357e5f5-cad0-40a4-9cc5-ef5990d61eb6@v17g2000hsa.googlegroups.com> I am using autoconf and automake to handle erlang apps. Can someone tell me how I can autogenerate .app file? I have tried builder in jungerl in stand alone mode. Anyone knows how I can use builder within autoconf and automake to autogenerate .rel, .app, .boot, .start, .load, .script? In addition, I know that .app file goes into /ebin folder. Where do you place the other files that get autogenerated by builder? Automake installs my erlang application into /usr/local/lib/erlang/ lib. But I have my erlang lib folders in /usr/local/erlang/otp_r12b-0/ lib/erlang/lib. My erlang root is: /usr/local/erlang/otp_r12b-0 and automake does perform valid erlang lib check for mnesia. But it can not deduce the right erlang lib folders during install. Why is this discrepancy? From ulf Fri Feb 8 09:06:18 2008 From: ulf (Ulf Wiger) Date: Fri, 8 Feb 2008 09:06:18 +0100 Subject: [erlang-questions] Selecting X number of items from Mnesia In-Reply-To: <3A3520F8-FF0B-448A-A669-F2D113952AA5@miceda.org> References: <3A3520F8-FF0B-448A-A669-F2D113952AA5@miceda.org> Message-ID: <8209f740802080006g2ba2baa4xd19fa1daab56b9f5@mail.gmail.com> I'd have to check on how to do it with QLC, but using mnesia:select(Tab, MatchSpec, NObjs, Lock), you can quite easily pull the N first objects from an ordered_set table. BR, Ulf W 2008/2/8, Dave Bryson : > I apologize in advance for the newbie question! > > I'm trying to treat an mnesia table as a FIFO queue. What I'd like to > be able to do is pull X number of items off the head of the list > returned by a query. There's no conditional values to isolate the > records - I just want the top X number of records. Is there an > efficient way to do this with qlc? > > Thanks in advance! > > Dave > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > From vychodil.hynek Fri Feb 8 10:26:12 2008 From: vychodil.hynek (Hynek Vychodil) Date: Fri, 8 Feb 2008 10:26:12 +0100 Subject: [erlang-questions] Selecting X number of items from Mnesia In-Reply-To: <8209f740802080006g2ba2baa4xd19fa1daab56b9f5@mail.gmail.com> References: <3A3520F8-FF0B-448A-A669-F2D113952AA5@miceda.org> <8209f740802080006g2ba2baa4xd19fa1daab56b9f5@mail.gmail.com> Message-ID: <4d08db370802080126y261cc22dkde6369aa4a2231a7@mail.gmail.com> Just from qlc manual: To return just a few answers cursors can be used. The following code returns no more than five answers using an ETS table for storing the unique answers: C = qlc:cursor(qlc:q([X || X <- qlc:append(QH1, QH2)],{unique,true})), R = qlc:next_answers(C, 5), ok = qlc:delete_cursor(C), R. On Feb 8, 2008 9:06 AM, Ulf Wiger wrote: > I'd have to check on how to do it with QLC, but using > mnesia:select(Tab, MatchSpec, NObjs, Lock), you > can quite easily pull the N first objects from an > ordered_set table. > > BR, > Ulf W > > 2008/2/8, Dave Bryson : > > I apologize in advance for the newbie question! > > > > I'm trying to treat an mnesia table as a FIFO queue. What I'd like to > > be able to do is pull X number of items off the head of the list > > returned by a query. There's no conditional values to isolate the > > records - I just want the top X number of records. Is there an > > efficient way to do this with qlc? > > > > Thanks in advance! > > > > Dave > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > -- --Hynek (Pichi) Vychodil -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080208/43401c9e/attachment.html From raimo+erlang-questions Thu Feb 7 09:45:29 2008 From: raimo+erlang-questions (Raimo Niskanen) Date: Thu, 7 Feb 2008 09:45:29 +0100 Subject: [erlang-questions] Slow server www.erlang.org Message-ID: <20080207084529.GA3259@erix.ericsson.se> Many are experiencing slow server responses from www.erlang.org when downloading the R12B-1 release. This is mostly since we (erlang.org) are since tuesday afternoon local time under some kind of heavy spam attack. There are some 30000 mail servers all over the Internet that send mails to bogus addresses a'la John.Doe The network load went sky high, so no valid mails got through, and downloads sucked. I have made some tweaks, blocking more mail servers in the firewall. The question is if I have accidentally blocked valid mailservers in the process... The future will tell. Network load looks much better today. -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From ulf.wiger Fri Feb 8 11:08:32 2008 From: ulf.wiger (Ulf Wiger (TN/EAB)) Date: Fri, 08 Feb 2008 11:08:32 +0100 Subject: [erlang-questions] Selecting X number of items from Mnesia In-Reply-To: <4d08db370802080126y261cc22dkde6369aa4a2231a7@mail.gmail.com> References: <3A3520F8-FF0B-448A-A669-F2D113952AA5@miceda.org> <8209f740802080006g2ba2baa4xd19fa1daab56b9f5@mail.gmail.com> <4d08db370802080126y261cc22dkde6369aa4a2231a7@mail.gmail.com> Message-ID: <47AC2A20.2080008@ericsson.com> Hynek Vychodil skrev: > Just from qlc manual: > > To return just a few answers cursors can be used. The following code > returns no more than five answers using an ETS table for storing the > unique answers: > > C = qlc:cursor(qlc:q([X || X <- qlc:append(QH1, QH2)],{unique,true})), > R = qlc:next_answers(C, 5), > ok = qlc:delete_cursor(C), > R. Note, thought, that this will be much more costly than using select() with a limit on number of matching objects. The cursor support needs to create a temporary store, which in the case of QLC is solved using a separate process. This will involve quite some copying. BR, Ulf W > > On Feb 8, 2008 9:06 AM, Ulf Wiger > > wrote: > > I'd have to check on how to do it with QLC, but using > mnesia:select(Tab, MatchSpec, NObjs, Lock), you > can quite easily pull the N first objects from an > ordered_set table. > > BR, > Ulf W > > 2008/2/8, Dave Bryson >: > > I apologize in advance for the newbie question! > > > > I'm trying to treat an mnesia table as a FIFO queue. What I'd like to > > be able to do is pull X number of items off the head of the list > > returned by a query. There's no conditional values to isolate the > > records - I just want the top X number of records. Is there an > > efficient way to do this with qlc? > > > > Thanks in advance! > > > > Dave > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > -- > --Hynek (Pichi) Vychodil > > > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions From daveb Fri Feb 8 14:57:53 2008 From: daveb (Dave Bryson) Date: Fri, 8 Feb 2008 07:57:53 -0600 Subject: [erlang-questions] Selecting X number of items from Mnesia In-Reply-To: <47AC2A20.2080008@ericsson.com> References: <3A3520F8-FF0B-448A-A669-F2D113952AA5@miceda.org> <8209f740802080006g2ba2baa4xd19fa1daab56b9f5@mail.gmail.com> <4d08db370802080126y261cc22dkde6369aa4a2231a7@mail.gmail.com> <47AC2A20.2080008@ericsson.com> Message-ID: <8E8FA512-9790-4860-918C-83CE7029EF7E@miceda.org> Great! That's exactly what I needed. I was just confused a bit by the MatchSpec - the erts guide helped. MatchSpec looks very powerful. For any other newbies out there trying to do the same thing, here's how you can pull the first X number of rows from a table: % return the first 10 records mnesia:select(message,[{'$1',[],['$1']}],10,read) It's also easy to experiment and test your MatchSpec using: ets:test_ms/2 Thanks! Dave On Feb 8, 2008, at 4:08 AM, Ulf Wiger (TN/EAB) wrote: > Hynek Vychodil skrev: >> Just from qlc manual: >> >> To return just a few answers cursors can be used. The following code >> returns no more than five answers using an ETS table for storing the >> unique answers: >> >> C = qlc:cursor(qlc:q([X || X <- qlc:append(QH1, QH2)], >> {unique,true})), >> R = qlc:next_answers(C, 5), >> ok = qlc:delete_cursor(C), >> R. > > Note, thought, that this will be much more costly than using > select() with a limit on number of matching objects. > > The cursor support needs to create a temporary store, which in > the case of QLC is solved using a separate process. This will > involve quite some copying. > > BR, > Ulf W > > > >> >> On Feb 8, 2008 9:06 AM, Ulf Wiger > > >> wrote: >> >> I'd have to check on how to do it with QLC, but using >> mnesia:select(Tab, MatchSpec, NObjs, Lock), you >> can quite easily pull the N first objects from an >> ordered_set table. >> >> BR, >> Ulf W >> >> 2008/2/8, Dave Bryson > >: >>> I apologize in advance for the newbie question! >>> >>> I'm trying to treat an mnesia table as a FIFO queue. What I'd >>> like to >>> be able to do is pull X number of items off the head of the list >>> returned by a query. There's no conditional values to isolate the >>> records - I just want the top X number of records. Is there an >>> efficient way to do this with qlc? >>> >>> Thanks in advance! >>> >>> Dave >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions >>> http://www.erlang.org/mailman/listinfo/erlang-questions >>> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions >> http://www.erlang.org/mailman/listinfo/erlang-questions >> >> >> >> >> -- >> --Hynek (Pichi) Vychodil >> >> >> --------------------------------------------------------------------- >> --- >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions >> http://www.erlang.org/mailman/listinfo/erlang-questions > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions From ulf Fri Feb 8 15:21:57 2008 From: ulf (Ulf Wiger) Date: Fri, 8 Feb 2008 15:21:57 +0100 Subject: [erlang-questions] Selecting X number of items from Mnesia In-Reply-To: <8E8FA512-9790-4860-918C-83CE7029EF7E@miceda.org> References: <3A3520F8-FF0B-448A-A669-F2D113952AA5@miceda.org> <8209f740802080006g2ba2baa4xd19fa1daab56b9f5@mail.gmail.com> <4d08db370802080126y261cc22dkde6369aa4a2231a7@mail.gmail.com> <47AC2A20.2080008@ericsson.com> <8E8FA512-9790-4860-918C-83CE7029EF7E@miceda.org> Message-ID: <8209f740802080621l31e5cddfnb7a0623a94c5d109@mail.gmail.com> Note also the little performance tip that you should try to run select /before/ writing anything to the table from within the transaction. Otherwise, the select() operation must read the transaction store and traverse its contents, testing the match spec with test_ms/2, then merging any hits into the sorted result (if it's an ordered_set table). BR, Ulf W 2008/2/8, Dave Bryson : > Great! That's exactly what I needed. I was just confused a bit by > the MatchSpec - the erts guide helped. MatchSpec looks very powerful. > > For any other newbies out there trying to do the same thing, here's > how you can pull the first X number of rows from a table: > > % return the first 10 records > mnesia:select(message,[{'$1',[],['$1']}],10,read) > > It's also easy to experiment and test your MatchSpec using: > ets:test_ms/2 > > Thanks! > Dave > > > On Feb 8, 2008, at 4:08 AM, Ulf Wiger (TN/EAB) wrote: > > > Hynek Vychodil skrev: > >> Just from qlc manual: > >> > >> To return just a few answers cursors can be used. The following code > >> returns no more than five answers using an ETS table for storing the > >> unique answers: > >> > >> C = qlc:cursor(qlc:q([X || X <- qlc:append(QH1, QH2)], > >> {unique,true})), > >> R = qlc:next_answers(C, 5), > >> ok = qlc:delete_cursor(C), > >> R. > > > > Note, thought, that this will be much more costly than using > > select() with a limit on number of matching objects. > > > > The cursor support needs to create a temporary store, which in > > the case of QLC is solved using a separate process. This will > > involve quite some copying. > > > > BR, > > Ulf W > > > > > > > >> > >> On Feb 8, 2008 9:06 AM, Ulf Wiger >> > > >> wrote: > >> > >> I'd have to check on how to do it with QLC, but using > >> mnesia:select(Tab, MatchSpec, NObjs, Lock), you > >> can quite easily pull the N first objects from an > >> ordered_set table. > >> > >> BR, > >> Ulf W > >> > >> 2008/2/8, Dave Bryson >> >: > >>> I apologize in advance for the newbie question! > >>> > >>> I'm trying to treat an mnesia table as a FIFO queue. What I'd > >>> like to > >>> be able to do is pull X number of items off the head of the list > >>> returned by a query. There's no conditional values to isolate the > >>> records - I just want the top X number of records. Is there an > >>> efficient way to do this with qlc? > >>> > >>> Thanks in advance! > >>> > >>> Dave > >>> _______________________________________________ > >>> erlang-questions mailing list > >>> erlang-questions > >>> http://www.erlang.org/mailman/listinfo/erlang-questions > >>> > >> _______________________________________________ > >> erlang-questions mailing list > >> erlang-questions > >> http://www.erlang.org/mailman/listinfo/erlang-questions > >> > >> > >> > >> > >> -- > >> --Hynek (Pichi) Vychodil > >> > >> > >> --------------------------------------------------------------------- > >> --- > >> > >> _______________________________________________ > >> erlang-questions mailing list > >> erlang-questions > >> http://www.erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions > > http://www.erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > From kukhyun Fri Feb 8 18:57:00 2008 From: kukhyun (KukHyun Lee) Date: Sat, 9 Feb 2008 02:57:00 +0900 Subject: [erlang-questions] my erlang-shell mode has indent problem Message-ID: <1313a75c0802080957g40553ce7x1101b3023188eca6@mail.gmail.com> Hi. I'm newbie in Erlang. My erlang mode for emacs has some problem. Erlang (BEAM) emulator version 5.6 [source] [async-threads:0] [kernel-poll:false] Eshell V5.6 (abort with ^G) 1> [1,2,3]. [1, 2, 3] instead of 1> [1,2,3]. [1,2,3] why inserted newline? Erlang mode version 2.5.4. is this aquamacs bug or config problem? I want to [1,2,3] not [1, 2 3] :( Regards Lee -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080209/e9cfc640/attachment.html From tonyg Fri Feb 8 17:59:13 2008 From: tonyg (Tony Garnock-Jones) Date: Fri, 08 Feb 2008 16:59:13 +0000 Subject: [erlang-questions] Packet size parsing Message-ID: <47AC8A61.3090005@lshift.net> Hi all, How difficult might it be to support, in the C inet runtime, a new kind of {packet, N} option for sockets, {packet, N, Offset} where N - number of bytes of big-endian length indicator Offset - byte offset within the packet of the length indicator The length indicator would include its own bytes. The entire packet, including header, including length indicator, would be sent as a single binary to the process using the socket. This scheme is suitable for IP packets, AMQP frames, etc. that are embedded in a TCP stream, where (a) the length isn't first in the frame, and (b) the length includes the size of the header. For example, given {packet, 2, 2}, the C parsing code would wait for *four* bytes to arrive, would examine bytes 2 and 3, use the resulting big-endian 16-bit word as an indicator of how many bytes to expect (less, of course, the four bytes already read), and wait for the remainder: - read N + Offset bytes - let Len = the big-endian N-byte word at Offset - wait for Len - (N + Offset) more bytes - pass the entire Len-byte-long binary across to the application On the outbound leg, bytes N through N + Offset of the outbound binary would be replaced with the total length of the packet to be sent, during transmission. Note that {packet, N} is not quite equivalent to {packet, N, 0}, because the packet *including* header would be sent to the user with {packet,N,0}, and the packet *excluding* header would be sent with {packet,N}. Comments? Tony -- [][][] Tony Garnock-Jones | Mob: +44 (0)7905 974 211 [][] LShift Ltd | Tel: +44 (0)20 7729 7060 [] [] http://www.lshift.net/ | Email: tonyg From jilani Fri Feb 8 19:22:37 2008 From: jilani (Jilani Khaldi) Date: Fri, 08 Feb 2008 19:22:37 +0100 Subject: [erlang-questions] A good application written in Erlang Message-ID: <47AC9DED.1030303@cheapnet.it> Hi All, for a long term project, should a vBulletin (http://www.vbulletin.com/) application like written using Erlang/Mnesia/YAWS be a good project? And what about an e-learning system written using Erlang/Mnesia/YAWS? Thank you. -- Jilani KHALDI From tony Thu Feb 7 20:12:11 2008 From: tony (Tony Rogvall) Date: Thu, 7 Feb 2008 20:12:11 +0100 Subject: [erlang-questions] inet_res: In-Reply-To: <20080207173306.GA26462@cs.uni-bonn.de> References: <20080207173306.GA26462@cs.uni-bonn.de> Message-ID: <8636AE33-BCFB-4AE0-BF6D-615288204237@rogvall.se> > > "IP6.INT" was deprecated with RFC3152 (BCP 49) in August 2001 and > removed with RFC 3596 in October 2003. > 2003, things are really moving in the internet world ;-) /Tony > (This might explain why my quick inet_res tests in the shell weren't > as > successful as I wished - I didn't actually fix inet_res.erl yet and > test > the fix.) > > Regards, > -is > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions From jeffm Sat Feb 9 00:33:09 2008 From: jeffm (jm) Date: Sat, 09 Feb 2008 10:33:09 +1100 Subject: [erlang-questions] A good application written in Erlang In-Reply-To: <47AC9DED.1030303@cheapnet.it> References: <47AC9DED.1030303@cheapnet.it> Message-ID: <47ACE6B5.2090502@ghostgun.com> Jilani Khaldi wrote: > Hi All, > for a long term project, should a vBulletin (http://www.vbulletin.com/) > application like written using Erlang/Mnesia/YAWS be a good project? > And what about an e-learning system written using Erlang/Mnesia/YAWS? > Thank you. May I suggest elryweb ( http://erlyweb.org/ and see the developer's blog http://yarivsblog.com/ ) a MVC web frame work. The framework is more than usable to do real work, but would benefit from more developer's workinng on it and more development being done with it. In a light hearted attempt to hi-jack the LAMP term I've referred to this as the LYME stack: Linux, Yaws, Mysql, Erlang/Erlyweb - a new flavour of web development. Jeff. From chsu79 Sat Feb 9 12:02:17 2008 From: chsu79 (Christian S) Date: Sat, 9 Feb 2008 12:02:17 +0100 Subject: [erlang-questions] Packet size parsing In-Reply-To: <47AC8A61.3090005@lshift.net> References: <47AC8A61.3090005@lshift.net> Message-ID: A slightly more generalized way to handle protocols with a header+payload is to be able to tell the driver to collect B bytes before it sends a message. The postgresql protocol has a header with <> then followed by (Length-4) bytes of payload. So it would be nice to first tell it to send me a 5 byte header, not more and not less, then tell it to send me the payload size of data, still not more and not less. I get uneasy about so much protocol stuff being done in C code. That so easy to get wrong and get wrong so it is exploitable. Just asking C to collect a certain amount of bytes before it sends the process a message is not much code to get wrong. On Feb 8, 2008 5:59 PM, Tony Garnock-Jones wrote: > Hi all, > > > How difficult might it be to support, in the C inet runtime, a new kind > of {packet, N} option for sockets, > > {packet, N, Offset} > > where > N - number of bytes of big-endian length indicator > Offset - byte offset within the packet of the length indicator > From tonyg Sat Feb 9 12:35:03 2008 From: tonyg (Tony Garnock-Jones) Date: Sat, 09 Feb 2008 11:35:03 +0000 Subject: [erlang-questions] Packet size parsing In-Reply-To: References: <47AC8A61.3090005@lshift.net> Message-ID: <47AD8FE7.9030007@lshift.net> Hi Christian, That certainly works: in fact, we're currently simulating this in our AMQP server, using prim_inet:async_recv/3 to alternate between asking for headers and bodies. (rabbit_reader:switch_callback/3, for the interested reader.) The reason I asked about a specialised option is because having the packets effortlessly delivered to us is likely to be quite a bit faster than constantly chopping and changing, with several messages back-and-forth for each parsed packet, and inet_drv.c already has almost exactly the same (kind of) logic as we're duplicating down at the erlang level. I see, though, that to handle the PostgreSQL protocol as well, it would have to become {packet, N, Offset, Correction} e.g., - for AMQP 0-8, {packet, 4, 3, +1}, - for AMQP 0-10 (most recent draft), {packet, 2, 2, -12}, and - for PostgreSQL (as you described it), {packet, 4, 1, -4}. The revised general packet reader would be: - read N + Offset bytes - let Len = the big-endian N-byte word at Offset - wait for Len + Correction more bytes - pass a tuple of {<>, <>} to the application You're right, this is starting to look more complicated. I'd still like to hear how much pain might be involved in *doing* it, of course :-) Having looked at INET_LOPT_PACKET in prim_inet.erl and inet_drv.c I get the feeling the hardest part is going to be passing the three parameters over to C-land! Regards, Tony Christian S wrote: > A slightly more generalized way to handle protocols with a header+payload is > to be able to tell the driver to collect B bytes before it sends a message. > > The postgresql protocol has a header with > <> > then followed by (Length-4) bytes of payload. > > So it would be nice to first tell it to send me a 5 byte header, not > more and not less, > then tell it to send me the payload size of data, still not more and not less. > > I get uneasy about so much protocol stuff being done in C code. That > so easy to get > wrong and get wrong so it is exploitable. Just asking C to collect a > certain amount of > bytes before it sends the process a message is not much code to get wrong. > > On Feb 8, 2008 5:59 PM, Tony Garnock-Jones wrote: >> Hi all, >> >> >> How difficult might it be to support, in the C inet runtime, a new kind >> of {packet, N} option for sockets, >> >> {packet, N, Offset} >> >> where >> N - number of bytes of big-endian length indicator >> Offset - byte offset within the packet of the length indicator >> > From tonyg Sat Feb 9 18:20:13 2008 From: tonyg (Tony Garnock-Jones) Date: Sat, 09 Feb 2008 17:20:13 +0000 Subject: [erlang-questions] PATCH for genericised TCP-socket packet parsing In-Reply-To: <47AC8A61.3090005@lshift.net> References: <47AC8A61.3090005@lshift.net> Message-ID: <47ADE0CD.1050902@lshift.net> Hi all, Tony Garnock-Jones wrote: > How difficult might it be to support, in the C inet runtime, a new kind > of {packet, N} option for sockets, [...] The answer is: given a bit of digging, not too difficult. See attached patch, which is against R12B-0, and which implements a new TCP socket option {gen_packet, SizeLength, SizeOffset, SizeDelta} which only applies to inbound packets, just like the asn1, cdr, sunrm, tpkt types, and decodes packets by - requiring SizeLength + SizeOffset bytes to be available - reading the big-endian SizeLength-byte-long number at SizeOffset - adding SizeDelta to that value, and - considering the resulting value to be the expected length in bytes of the next packet to be returned, including its header For the examples I've collected so far, This protocol ... ... works with this option ---------------------------------------------------------- IPv4 (just an example!) {gen_packet, 2, 2, 0} AMQP 0-8 {gen_packet, 4, 3, 8} AMQP 0-10 (recent draft) {gen_packet, 2, 2, 0} PostgreSQL (from Christian) {gen_packet, 4, 1, 1} The existing TPKT/RFC1006 parser is the same as {gen_packet,2,2,0}, plus a check (on the receiver) of the value of the version byte. Problems with the patch: - I'm new to erlang internals. Have I missed anything? - The {packet_size, Integer} option works fine, but can be a bit tricky to reason about because of the effect the gen_packet parameters have on it. Note that this patch does nothing to outbound packets, requiring the user to ensure they're correctly formatted. This is just the same as the existing asn1, cdr, sunrm, tpkt etc. parsers. Tony -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: genpacket.patch Url: http://www.erlang.org/pipermail/erlang-questions/attachments/20080209/a970a5f7/attachment.ksh From tonyg Sat Feb 9 19:45:56 2008 From: tonyg (Tony Garnock-Jones) Date: Sat, 09 Feb 2008 18:45:56 +0000 Subject: [erlang-questions] PATCH for genericised TCP-socket packet parsing In-Reply-To: <47ADE0CD.1050902@lshift.net> References: <47AC8A61.3090005@lshift.net> <47ADE0CD.1050902@lshift.net> Message-ID: <47ADF4E4.50408@lshift.net> Patch updated to modify ssl_broker:is_tcp_gen_opt/1, as well. Tony Tony Garnock-Jones wrote: > The answer is: given a bit of digging, not too difficult. See attached > patch, which is against R12B-0, and which implements a new TCP socket > option > > {gen_packet, SizeLength, SizeOffset, SizeDelta} -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: genpacket.patch Url: http://www.erlang.org/pipermail/erlang-questions/attachments/20080209/30b16594/attachment-0001.ksh From kevin Sun Feb 10 06:49:45 2008 From: kevin (Kevin Scaldeferri) Date: Sat, 9 Feb 2008 21:49:45 -0800 Subject: [erlang-questions] using xmerl on web docs Message-ID: <0DABC91E-63AB-4E54-A561-AED32DB2E579@scaldeferri.com> Hi, I wanted to do something fairly basic (to me, at least) but ran into problems. Specifically, I would like to fetch some (X)HTML docs from the web and parse and validate them. So, I started optimistic. After fetching a doc with http:request, I tried to validate it: 6> {XML, Rest} = xmerl_scan:string(Body, [{validation, dtd}]). 3290- fatal: {error,{error_missing_element_declaration_in_DTD,html}} ** exception exit: {fatal, {{error, {error_missing_element_declaration_in_DTD, html}}, {file, file_name_unknown}, {line, 4}, {col, 1}}} in function xmerl_scan:fatal/2 in call from xmerl_scan:scan_document/2 in call from xmerl_scan:string/2 hmm... well I know this is really a valid XHTML doc, and I know the dtd does declare the element "html". As best I can tell, the problem is that xmerl doesn't actually fetch dtds from the web. This seems to be suggested by this bit in the source: %%% Always assume an external resource can be found locally! Thus %%% don't bother fetching with e.g. HTTP. Returns the path where the %%% resource is found. The path to the external resource is given by %%% URI directly or the option fetch_path (additional paths) or %%% directory (base path to external resource) fetch_URI(URI, S) -> ... So, I decided to give up on validating for the moment, and just parse the doc for the time being. Unfortunately, I didn't get any further; 8> {XML, Rest} = xmerl_scan:string(Body). 2692- fatal: {unknown_entity_ref,copy} 2602- fatal: error_scanning_entity_ref ** exception exit: {fatal, {error_scanning_entity_ref, {file, file_name_unknown}, {line, 33}, {col, 16}}} in function xmerl_scan:fatal/2 in call from xmerl_scan:scan_element/12 in call from xmerl_scan:scan_content/11 in call from xmerl_scan:scan_element/12 in call from xmerl_scan:scan_content/11 in call from xmerl_scan:scan_element/12 in call from xmerl_scan:scan_content/11 in call from xmerl_scan:scan_element/12 In this case, an © entity, perfectly valid according to the DTD, is rejected because we haven't parsed the DTD. It seems like I'm stuck in a chicken-and-egg problem. If I could parse without validating, I could extract the DTD location, fetch it and make a local copy that could be used for validation. But, it seems that I can't parse the document unless we already know the contents of the DTD (specifically, the entity declarations). Thus, I'm stuck. Is there something that I'm doing stupidly wrong here? Surely someone else has tried to parse documents off the web. Thanks, -kevin From saleyn Sun Feb 10 16:46:57 2008 From: saleyn (Serge Aleynikov) Date: Sun, 10 Feb 2008 10:46:57 -0500 Subject: [erlang-questions] Bug in snmp_generic.erl Message-ID: <47AF1C71.1070704@gmail.com> It appears to be present in all recent versions. Serge --- lib/snmp/src/agent/snmp_generic.erl.orig 2008-02-10 10:25:47.981319000 -0500 +++ lib/snmp/src/agent/snmp_generic.erl 2008-02-10 10:26:31.884368000 -0500 @@ -595,10 +595,10 @@ table_set_cols(NameDb, RowIndex, [{Col, Val} | Cols]) -> case catch table_set_element(NameDb, RowIndex, Col, Val) of true -> table_set_cols(NameDb, RowIndex, Cols); - _X -> + X -> user_err("snmp_generic:table_set_cols set ~w to" " ~w returned ~w", - [{NameDb, RowIndex}, {Col, Val}]), + [{NameDb, RowIndex}, {Col, Val}, X]), {undoFailed, Col} end. From ulf Sun Feb 10 19:03:56 2008 From: ulf (Ulf Wiger) Date: Sun, 10 Feb 2008 19:03:56 +0100 Subject: [erlang-questions] using xmerl on web docs In-Reply-To: <0DABC91E-63AB-4E54-A561-AED32DB2E579@scaldeferri.com> References: <0DABC91E-63AB-4E54-A561-AED32DB2E579@scaldeferri.com> Message-ID: <8209f740802101003s4e1493ci1fde044f1cc2ac98@mail.gmail.com> The fetch_URI function in xmerl_scan can be replaced by a user-defined function, {fetch_fun, F}. This is described in http://www.erlang.org/doc/apps/xmerl/xmerl_examples.html I've sometimes been a bit annoyed that even though the default mode is {validation, off}, xmerl will not accept not being able to find the DTD. BR, Ulf W 2008/2/10, Kevin Scaldeferri : > Hi, > > I wanted to do something fairly basic (to me, at least) but ran into > problems. Specifically, I would like to fetch some (X)HTML docs from > the web and parse and validate them. So, I started optimistic. After > fetching a doc with http:request, I tried to validate it: > > 6> {XML, Rest} = xmerl_scan:string(Body, [{validation, dtd}]). > 3290- fatal: {error,{error_missing_element_declaration_in_DTD,html}} > ** exception exit: {fatal, > {{error, > {error_missing_element_declaration_in_DTD, > html}}, > {file, > file_name_unknown}, > {line, > 4}, > {col, > 1}}} > in function xmerl_scan:fatal/2 > in call from xmerl_scan:scan_document/2 > in call from xmerl_scan:string/2 > > > hmm... well I know this is really a valid XHTML doc, and I know the > dtd does declare the element "html". As best I can tell, the problem > is that xmerl doesn't actually fetch dtds from the web. This seems to > be suggested by this bit in the source: > > %%% Always assume an external resource can be found locally! Thus > %%% don't bother fetching with e.g. HTTP. Returns the path where the > %%% resource is found. The path to the external resource is given by > %%% URI directly or the option fetch_path (additional paths) or > %%% directory (base path to external resource) > fetch_URI(URI, S) -> ... > > > So, I decided to give up on validating for the moment, and just parse > the doc for the time being. Unfortunately, I didn't get any further; > > 8> {XML, Rest} = xmerl_scan:string(Body). > 2692- fatal: {unknown_entity_ref,copy} > 2602- fatal: error_scanning_entity_ref > ** exception exit: {fatal, > {error_scanning_entity_ref, > {file, > file_name_unknown}, > {line, > 33}, > {col, > 16}}} > in function xmerl_scan:fatal/2 > in call from xmerl_scan:scan_element/12 > in call from xmerl_scan:scan_content/11 > in call from xmerl_scan:scan_element/12 > in call from xmerl_scan:scan_content/11 > in call from xmerl_scan:scan_element/12 > in call from xmerl_scan:scan_content/11 > in call from xmerl_scan:scan_element/12 > > > In this case, an © entity, perfectly valid according to the DTD, > is rejected because we haven't parsed the DTD. > > It seems like I'm stuck in a chicken-and-egg problem. If I could > parse without validating, I could extract the DTD location, fetch it > and make a local copy that could be used for validation. But, it > seems that I can't parse the document unless we already know the > contents of the DTD (specifically, the entity declarations). Thus, > I'm stuck. > > Is there something that I'm doing stupidly wrong here? Surely someone > else has tried to parse documents off the web. > > > Thanks, > > -kevin > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > From Martin.Logan Sun Feb 10 19:23:51 2008 From: Martin.Logan (Logan, Martin) Date: Sun, 10 Feb 2008 12:23:51 -0600 Subject: [erlang-questions] Chicgo Erllounge Message-ID: The date has not been confirmed yet but we are going to hold this during the time that Joe is giving his workshop here in Chicago. The best dates look to be Thursday Feb 14th or Friday Feb 15th. Let's have a vote on it here. Time is: 6:30 pm The location is: BLUE LINE CLUB CAR American 1548 N. DAMEN AVE. (773) 395-3700 This location is right of the blue line el and easily reachable from the Airpoirt. Cheers, Martin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080210/2732f529/attachment.html From Martin.Logan Sun Feb 10 22:09:54 2008 From: Martin.Logan (Logan, Martin) Date: Sun, 10 Feb 2008 15:09:54 -0600 Subject: [erlang-questions] Chicgo Erllounge Message-ID: As was just pointed out to me, Thursday, Valentines Day, is not a good choice for the Erllounge. My girlfriend has just confirmed it :-) We should shoot for Friday, or barring that Wednesday. ________________________________ From: Logan, Martin Sent: Sunday, February 10, 2008 12:24 PM To: erlang-questions Subject: Chicgo Erllounge The date has not been confirmed yet but we are going to hold this during the time that Joe is giving his workshop here in Chicago. The best dates look to be Thursday Feb 14th or Friday Feb 15th. Let's have a vote on it here. Time is: 6:30 pm The location is: BLUE LINE CLUB CAR American 1548 N. DAMEN AVE. (773) 395-3700 This location is right of the blue line el and easily reachable from the Airpoirt. Cheers, Martin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080210/f51f364e/attachment.html From kevin Mon Feb 11 00:19:51 2008 From: kevin (Kevin Scaldeferri) Date: Sun, 10 Feb 2008 15:19:51 -0800 Subject: [erlang-questions] using xmerl on web docs In-Reply-To: <8209f740802101003s4e1493ci1fde044f1cc2ac98@mail.gmail.com> References: <0DABC91E-63AB-4E54-A561-AED32DB2E579@scaldeferri.com> <8209f740802101003s4e1493ci1fde044f1cc2ac98@mail.gmail.com> Message-ID: <615BA18C-2FF1-422C-87DD-5C38C460B144@scaldeferri.com> Hmm... do you happen to know a well debugged implementation? I'm starting with something fairly naive, and the next problem I hit is: fetching http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd fetching xhtml-lat1.ent ** exception error: no match of right hand side value {error, no_scheme} Which I sort of expected, having had exactly the same problem in other languages with immature XML libs :-) I guess I will use the GlobalState to store the last fetched URI and then use it to resolve the relative reference, but really I'd love not to have to reinvent all this myself. So, if there's a good implementation someone has to share, I'd love to just use it. Thanks, -kevin On Feb 10, 2008, at 10:03 AM, Ulf Wiger wrote: > The fetch_URI function in xmerl_scan can be replaced by > a user-defined function, {fetch_fun, F}. > > This is described in http://www.erlang.org/doc/apps/xmerl/xmerl_examples.html > > I've sometimes been a bit annoyed that even though the default mode is > {validation, off}, xmerl will not accept not being able to find the > DTD. > > > BR, > Ulf W > > 2008/2/10, Kevin Scaldeferri : >> Hi, >> >> I wanted to do something fairly basic (to me, at least) but ran into >> problems. Specifically, I would like to fetch some (X)HTML docs from >> the web and parse and validate them. So, I started optimistic. >> After >> fetching a doc with http:request, I tried to validate it: >> >> 6> {XML, Rest} = xmerl_scan:string(Body, [{validation, dtd}]). >> 3290- fatal: {error,{error_missing_element_declaration_in_DTD,html}} >> ** exception exit: {fatal, >> {{error, >> {error_missing_element_declaration_in_DTD, >> html}}, >> {file, >> file_name_unknown}, >> {line, >> 4}, >> {col, >> 1}}} >> in function xmerl_scan:fatal/2 >> in call from xmerl_scan:scan_document/2 >> in call from xmerl_scan:string/2 >> >> >> hmm... well I know this is really a valid XHTML doc, and I know the >> dtd does declare the element "html". As best I can tell, the problem >> is that xmerl doesn't actually fetch dtds from the web. This seems >> to >> be suggested by this bit in the source: >> >> %%% Always assume an external resource can be found locally! Thus >> %%% don't bother fetching with e.g. HTTP. Returns the path where the >> %%% resource is found. The path to the external resource is given by >> %%% URI directly or the option fetch_path (additional paths) or >> %%% directory (base path to external resource) >> fetch_URI(URI, S) -> ... >> >> >> So, I decided to give up on validating for the moment, and just parse >> the doc for the time being. Unfortunately, I didn't get any further; >> >> 8> {XML, Rest} = xmerl_scan:string(Body). >> 2692- fatal: {unknown_entity_ref,copy} >> 2602- fatal: error_scanning_entity_ref >> ** exception exit: {fatal, >> {error_scanning_entity_ref, >> {file, >> file_name_unknown}, >> {line, >> 33}, >> {col, >> 16}}} >> in function xmerl_scan:fatal/2 >> in call from xmerl_scan:scan_element/12 >> in call from xmerl_scan:scan_content/11 >> in call from xmerl_scan:scan_element/12 >> in call from xmerl_scan:scan_content/11 >> in call from xmerl_scan:scan_element/12 >> in call from xmerl_scan:scan_content/11 >> in call from xmerl_scan:scan_element/12 >> >> >> In this case, an © entity, perfectly valid according to the DTD, >> is rejected because we haven't parsed the DTD. >> >> It seems like I'm stuck in a chicken-and-egg problem. If I could >> parse without validating, I could extract the DTD location, fetch it >> and make a local copy that could be used for validation. But, it >> seems that I can't parse the document unless we already know the >> contents of the DTD (specifically, the entity declarations). Thus, >> I'm stuck. >> >> Is there something that I'm doing stupidly wrong here? Surely >> someone >> else has tried to parse documents off the web. >> >> >> Thanks, >> >> -kevin >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions >> http://www.erlang.org/mailman/listinfo/erlang-questions >> From tom Mon Feb 11 03:16:29 2008 From: tom (Tom Samplonius) Date: Sun, 10 Feb 2008 18:16:29 -0800 (PST) Subject: [erlang-questions] UTF-8 problems In-Reply-To: <23def8000802032211y10013178veca9df5c56f5435a@mail.gmail.com> Message-ID: <28055199.5871202696189755.JavaMail.root@ly.sdf.com> ----- "Dustin Whitney" wrote: > (A really long URL ...) Strings are listed of integers in Erlang though, so this is expected. It depends on the output mechanism you are using to display the results. You could use binaries though, though I don't know whether Xmerl can process bins. Probably. Tom From adam.boz Mon Feb 11 04:09:47 2008 From: adam.boz (Adam Bozanich) Date: Sun, 10 Feb 2008 19:09:47 -0800 Subject: [erlang-questions] qlc expression help. Message-ID: Hi all, I'm having trouble creating a qlc expression which does what I want. I'm basically trying to create a filter for QH1 with a predicate that depends on QH2. In the example below, test2/0 gives me the result I'm looking for, but it requires the second QH to be eval'd. I'd like the expression to look like what's in the test1/0 function. Any suggestions? Thanks, -Adam session: 8> test_qlc:test2(). [{1,6,7},{2,8,9}] 9> test_qlc:test1(). [{1,4,5}, {1,2,3}, {1,6,7}, {1,6,7}, {2,4,5}, {2,2,3}, {2,8,9}, {2,8,9}, {3,4,5}, {3,2,3}] code: -module(test_qlc). -include_lib("stdlib/include/qlc.hrl"). -export([test1/0,test2/0,handroll/0]). -define(DB,[ {1,4,5},{1,2,3},{1,6,7}, {2,4,5},{2,2,3},{2,8,9}, {3,4,5},{3,2,3} ]). -define(OBJ,[{2,3},{4,5}]). test1() -> qlc:eval(qlc:q([ {O1,C1,V1} || {O1,C1,V1} <- ?DB, {C2,V2} <- ?OBJ, C1 /= C2, V1 /= V2])). test2() -> qlc:eval(qlc:q([ {O1,C1,V1} || {O1,C1,V1} <- ?DB, lists:member({C1,V1},?OBJ) == false ])). handroll() -> S = mkset(?DB), O = mkobj(?OBJ), to_table(difference(O,related(O,S))). related(S1,D) -> dict:filter(fun(_,S2) -> sets:is_subset(S1,S2) end,D). difference(S1,D) -> dict:filter(fun(_,S2) -> sets:size(S2) > 0 end, dict:map(fun(_,S2) -> sets:subtract(S2,S1) end,D)). to_table(D) -> lists:flatmap(fun({K,V}) -> lists:map(fun({X,Y}) -> {K,X,Y} end, sets:to_list(V)) end, dict:to_list(D)). mkset(DB) -> dict:map(fun(_,V) -> sets:from_list(V) end, lists:foldl(fun({O,C,V},Acc) -> dict:append(O,{C,V},Acc) end, dict:new(),DB)). mkobj(OBJ) -> sets:from_list(OBJ). -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080210/74455c9d/attachment.html From paul-trapexit Mon Feb 11 05:15:13 2008 From: paul-trapexit (Paul Mineiro) Date: Sun, 10 Feb 2008 20:15:13 -0800 (PST) Subject: [erlang-questions] beginner: mnesia dynamic fragment distribution balancing In-Reply-To: References: Message-ID: i didn't find any implementations of this idea so i went ahead and did one. it's been working although i wouldn't say it's gotten "heavy" use because we're just a start-up. hopefully there are no lurking pitfalls. i just got around to open-sourcing this weekend if anybody's interested. http://code.google.com/p/fragmentron -- p On Sat, 3 Nov 2007, Paul Mineiro wrote: > hi. > > i want to set up a fragmented table across a set of nodes with dynamic > membership, and basically maintain a balanced use of resources while > respecting the creation parameters (e.g. n_disc_copies). it appears > mnesia initially balances the fragments across the set of nodes at create > time but then you are "on your own" as the node pool changes. > > i can see how to do this manually by inspecting the table (and each > fragment) with mnesia:table_info/2, and then taking ownership of a replica > with mnesia:add_table_copy/3 and mnesia:del_table_copy/2 as necessary to > achieve balance. > > two questions: > > 1) has somebody done this already? i don't want to reinvent the wheel. > > 2) if not, i want to handle the case where multiple nodes are joining > and/or leaving at the same time. can i serialize this activity using > transaction constructs or should i create a (global) process to > synchronize all this activity through? > > thanks, > > -- p > > Optimism is an essential ingredient of innovation. How else can the > individual favor change over security? > > -- Robert Noyce > Optimism is an essential ingredient of innovation. How else can the individual favor change over security? -- Robert Noyce From j.bhanot Mon Feb 11 05:56:39 2008 From: j.bhanot (J Bhanot) Date: Mon, 11 Feb 2008 10:26:39 +0530 Subject: [erlang-questions] MG->MGC->C Node Message-ID: Hi All, I have been able to create client server comm between C node and Erlang node... Now i want to send the simple Service Change request which i get from sample MG (megaco_simple_mg.erl) in sample MGC (megaco_simple_mgc).... now when i recieve the message in MGC...i want to send the same message to C node for parsing.... now the question is at what point i should write the code in sample MGC to send the message.. Thanking in anticipation.. Regards, jb ____________________________________________ =====-----=====-----===== Notice: The information contained in this e-mail message and/or attachments to it may contain confidential or privileged information. If you are not the intended recipient, any dissemination, use, review, distribution, printing or copying of the information contained in this e-mail message and/or attachments to it are strictly prohibited. If you have received this communication in error, please notify us by reply e-mail or telephone and immediately and permanently delete the message and any attachments. Thank you -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080211/b405bfe0/attachment.html From j.bhanot Mon Feb 11 07:09:42 2008 From: j.bhanot (J Bhanot) Date: Mon, 11 Feb 2008 11:39:42 +0530 Subject: [erlang-questions] RecHandle#megaco_receive_handle Message-ID: Hi, Apologies for asking basic questions - what does RecHandle#megaco_receive_handle means...tried to go through various docs but could not find it.. thanks, jb ____________________________________________ =====-----=====-----===== Notice: The information contained in this e-mail message and/or attachments to it may contain confidential or privileged information. If you are not the intended recipient, any dissemination, use, review, distribution, printing or copying of the information contained in this e-mail message and/or attachments to it are strictly prohibited. If you have received this communication in error, please notify us by reply e-mail or telephone and immediately and permanently delete the message and any attachments. Thank you -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080211/91adc243/attachment.html From zerthurd Mon Feb 11 07:26:19 2008 From: zerthurd (Maxim Treskin) Date: Mon, 11 Feb 2008 12:26:19 +0600 Subject: [erlang-questions] RecHandle#megaco_receive_handle In-Reply-To: References: Message-ID: See Programming Examples in OTP documentation -- Maxim Treskin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080211/cf3d2be3/attachment.html From prabhuram.k Mon Feb 11 09:16:21 2008 From: prabhuram.k (Prabhuram K) Date: Mon, 11 Feb 2008 13:46:21 +0530 Subject: [erlang-questions] Find if a substring is present or not Message-ID: <3052a6dc0802110016r326431fbpcebb9cb2747a64a9@mail.gmail.com> Hi All, I am a newbie and I would like to find if a substring is present in a given string. Any Help would be highly appriciated. Thanks, ram -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080211/0cb1f771/attachment.html From bengt.kleberg Mon Feb 11 09:31:21 2008 From: bengt.kleberg (Bengt Kleberg) Date: Mon, 11 Feb 2008 09:31:21 +0100 Subject: [erlang-questions] Find if a substring is present or not In-Reply-To: <3052a6dc0802110016r326431fbpcebb9cb2747a64a9@mail.gmail.com> References: <3052a6dc0802110016r326431fbpcebb9cb2747a64a9@mail.gmail.com> Message-ID: <1202718681.14629.5.camel@seasc0625.dyn.rnd.as.sw.ericsson.se> Greetings, >From the documentation on the string module found at http://erlang.org/doc/man/string.html str(String, SubString) -> Index rstr(String, SubString) -> Index Types: String = SubString = string() Index = integer() Returns the position where the first/last occurrence of SubString begins in String. 0 is returned if SubString does not exist in String. bengt On Mon, 2008-02-11 at 13:46 +0530, Prabhuram K wrote: > Hi All, > I am a newbie and I would like to find if a substring is present in a > given string. Any Help would be highly appriciated. > > Thanks, > ram > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions From anthony.hw.kong Mon Feb 11 10:20:45 2008 From: anthony.hw.kong (Anthony Kong) Date: Mon, 11 Feb 2008 20:20:45 +1100 Subject: [erlang-questions] erlang sites availability Message-ID: Hi, all, Just wondering if you have experienced the same problem right now: - access http://www.planeterlang.org/ and get "Access forbidden!" error - access http://www.erlang-projects.org/ and get "Bad Gateway" error Cheers, Anthony -- /*--*/ Don't EVER make the mistake that you can design something better than what you get from ruthless massively parallel trial-and-error with a feedback cycle. That's giving your intelligence _much_ too much credit. - Linus Torvalds From thomasl_erlang Mon Feb 11 09:43:54 2008 From: thomasl_erlang (Thomas Lindgren) Date: Mon, 11 Feb 2008 00:43:54 -0800 (PST) Subject: [erlang-questions] PATCH for genericised TCP-socket packet parsing In-Reply-To: <47ADE0CD.1050902@lshift.net> Message-ID: <23559.86666.qm@web38804.mail.mud.yahoo.com> --- Tony Garnock-Jones wrote: > Hi all, > > Tony Garnock-Jones wrote: > > How difficult might it be to support, in the C > inet runtime, a new kind > > of {packet, N} option for sockets, [...] > > The answer is: given a bit of digging, not too > difficult. See attached > patch, which is against R12B-0, and which implements > a new TCP socket option > > {gen_packet, SizeLength, SizeOffset, SizeDelta} I haven't tried it yet, but I like the idea. Best, Thomas ____________________________________________________________________________________ Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping From hakan Mon Feb 11 10:54:35 2008 From: hakan (Hakan Mattsson) Date: Mon, 11 Feb 2008 10:54:35 +0100 (CET) Subject: [erlang-questions] MG->MGC->C Node In-Reply-To: References: Message-ID: On Mon, 11 Feb 2008, J Bhanot wrote: JB> I have been able to create client server comm between C node and Erlang JB> node... JB> JB> Now i want to send the simple Service Change request which i get from JB> sample MG (megaco_simple_mg.erl) in sample MGC (megaco_simple_mgc).... JB> JB> now when i recieve the message in MGC...i want to send the same message to JB> C node for parsing.... JB> JB> now the question is at what point i should write the code in sample MGC to JB> send the message.. Take a look at the architecture for the Megaco Session application. It provides a complete foreign language interface for the Erlang Megaco/H.248 protocol stack. The implementation is however rather old (based on R7B and requiring an old version of the Megaco/H.248 protocol). The Megaco Session application is not maintained, but it should not be too much work for you to get it working again. But a first step is to get a grasp of the architectural ideas from the code and the (brief) documentation. Megaco Session can be downloaded from http://www.erlang.org/project/megaco. Good luck! /H?kan From ft Mon Feb 11 10:06:26 2008 From: ft (Fredrik Thulin) Date: Mon, 11 Feb 2008 10:06:26 +0100 Subject: [erlang-questions] Erlang/OTP R12B-1 has been released In-Reply-To: <18346.9987.466847.511122@antilipe.corelatus.se> References: <18346.9987.466847.511122@antilipe.corelatus.se> Message-ID: <47B01012.4050405@it.su.se> Matthias Lang wrote: ... > I just checked that the high bandwidth Stockholm University mirror has > the new source. It does, though I know it didn't earlier today when it > was needed most. We rsync once every hour. If the source site was too heavily loaded I guess it's possible that rsync failed one or more times... /Fredrik From Dmitri.Girenko Mon Feb 11 10:17:31 2008 From: Dmitri.Girenko (Dmitri Girenko) Date: Mon, 11 Feb 2008 11:17:31 +0200 Subject: [erlang-questions] qlc expression help. In-Reply-To: References: Message-ID: <697074A35ED91748882E3850BDCE295EE09298@leenu.akumiitti.net> It looks similar to the problem that I had - the code worked only when subresult was evaluated. http://www.erlang.org/pipermail/erlang-questions/2008-January/032389.htm l maybe the patch here helps? http://www.erlang.org/pipermail/erlang-questions/2008-January/032410.htm l ________________________________ From: erlang-questions-bounces [mailto:erlang-questions-bounces] On Behalf Of Adam Bozanich Sent: 11. helmikuuta 2008 5:10 To: erlang-questions Subject: [erlang-questions] qlc expression help. Hi all, I'm having trouble creating a qlc expression which does what I want. I'm basically trying to create a filter for QH1 with a predicate that depends on QH2. In the example below, test2/0 gives me the result I'm looking for, but it requires the second QH to be eval'd. I'd like the expression to look like what's in the test1/0 function. Any suggestions? Thanks, -Adam session: 8> test_qlc:test2(). [{1,6,7},{2,8,9}] 9> test_qlc:test1(). [{1,4,5}, {1,2,3}, {1,6,7}, {1,6,7}, {2,4,5}, {2,2,3}, {2,8,9}, {2,8,9}, {3,4,5}, {3,2,3}] code: -module(test_qlc). -include_lib("stdlib/include/qlc.hrl"). -export([test1/0,test2/0,handroll/0]). -define(DB,[ {1,4,5},{1,2,3},{1,6,7}, {2,4,5},{2,2,3},{2,8,9}, {3,4,5},{3,2,3} ]). -define(OBJ,[{2,3},{4,5}]). test1() -> qlc:eval(qlc:q([ {O1,C1,V1} || {O1,C1,V1} <- ?DB, {C2,V2} <- ?OBJ, C1 /= C2, V1 /= V2])). test2() -> qlc:eval(qlc:q([ {O1,C1,V1} || {O1,C1,V1} <- ?DB, lists:member({C1,V1},?OBJ) == false ])). handroll() -> S = mkset(?DB), O = mkobj(?OBJ), to_table(difference(O,related(O,S))). related(S1,D) -> dict:filter(fun(_,S2) -> sets:is_subset(S1,S2) end,D). difference(S1,D) -> dict:filter(fun(_,S2) -> sets:size(S2) > 0 end, dict:map(fun(_,S2) -> sets:subtract(S2,S1) end,D)). to_table(D) -> lists:flatmap(fun({K,V}) -> lists:map(fun({X,Y}) -> {K,X,Y} end, sets:to_list(V)) end, dict:to_list(D)). mkset(DB) -> dict:map(fun(_,V) -> sets:from_list(V) end, lists:foldl(fun({O,C,V},Acc) -> dict:append(O,{C,V},Acc) end, dict:new(),DB)). mkobj(OBJ) -> sets:from_list(OBJ). -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080211/e83083c8/attachment.html From icejmx Mon Feb 11 12:26:10 2008 From: icejmx (=?UTF-8?B?556E556E?=) Date: Mon, 11 Feb 2008 19:26:10 +0800 Subject: [erlang-questions] erlang sites availability In-Reply-To: References: Message-ID: <47B030D2.80202@gmail.com> Anthony Kong ??: > Hi, all, > > Just wondering if you have experienced the same problem right now: > > - access http://www.planeterlang.org/ and get "Access forbidden!" error > > - access http://www.erlang-projects.org/ and get "Bad Gateway" error > > > Cheers, Anthony > > hi! the same to you.why? -- ??:erlang,python,java,php -------------------------------- ?????http://blog.80s.net.cn From kukhyun Mon Feb 11 12:34:58 2008 From: kukhyun (KukHyun Lee) Date: Mon, 11 Feb 2008 20:34:58 +0900 Subject: [erlang-questions] erlang sites availability In-Reply-To: References: Message-ID: <1313a75c0802110334k4ba19393s22c895fdfb66461a@mail.gmail.com> I have same problem!! is it network problem? 2008/2/11, Anthony Kong : > > Hi, all, > > Just wondering if you have experienced the same problem right now: > > - access http://www.planeterlang.org/ and get "Access forbidden!" error > > - access http://www.erlang-projects.org/ and get "Bad Gateway" error > > > Cheers, Anthony > > -- > /*--*/ > Don't EVER make the mistake that you can design something better than > what you get from ruthless massively parallel trial-and-error with a > feedback cycle. That's giving your intelligence _much_ too much > credit. > > - Linus Torvalds > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080211/00974560/attachment.html From tuncer.ayaz Mon Feb 11 14:37:23 2008 From: tuncer.ayaz (Tuncer Ayaz) Date: Mon, 11 Feb 2008 14:37:23 +0100 Subject: [erlang-questions] erlang sites availability In-Reply-To: References: Message-ID: <4ac8254d0802110537g477bec91q679a4955beddb6d5@mail.gmail.com> On Feb 11, 2008 10:20 AM, Anthony Kong wrote: > Hi, all, > > Just wondering if you have experienced the same problem right now: > > - access http://www.planeterlang.org/ and get "Access forbidden!" error works here from .de > - access http://www.erlang-projects.org/ and get "Bad Gateway" error same here in .de From tty.erlang Mon Feb 11 15:01:26 2008 From: tty.erlang (t ty) Date: Mon, 11 Feb 2008 09:01:26 -0500 Subject: [erlang-questions] erlang sites availability In-Reply-To: <4ac8254d0802110537g477bec91q679a4955beddb6d5@mail.gmail.com> References: <4ac8254d0802110537g477bec91q679a4955beddb6d5@mail.gmail.com> Message-ID: <290b3ba10802110601s18ed1037tfe0ac0aec2b53fe4@mail.gmail.com> On Feb 11, 2008 8:37 AM, Tuncer Ayaz wrote: > On Feb 11, 2008 10:20 AM, Anthony Kong wrote: > > Hi, all, > > > > Just wondering if you have experienced the same problem right now: > > > > - access http://www.planeterlang.org/ and get "Access forbidden!" error > > works here from .de works here from .ca > > > - access http://www.erlang-projects.org/ and get "Bad Gateway" error > > same here in .de 502 "Bad Gateway" from .ca From vychodil.hynek Mon Feb 11 15:25:55 2008 From: vychodil.hynek (Hynek Vychodil) Date: Mon, 11 Feb 2008 15:25:55 +0100 Subject: [erlang-questions] erlang sites availability In-Reply-To: <4ac8254d0802110537g477bec91q679a4955beddb6d5@mail.gmail.com> References: <4ac8254d0802110537g477bec91q679a4955beddb6d5@mail.gmail.com> Message-ID: <4d08db370802110625ue057865o3d9536c38495f213@mail.gmail.com> On Feb 11, 2008 2:37 PM, Tuncer Ayaz wrote: > On Feb 11, 2008 10:20 AM, Anthony Kong wrote: > > Hi, all, > > > > Just wondering if you have experienced the same problem right now: > > > > - access http://www.planeterlang.org/ and get "Access forbidden!" error > > works here from .de works from .cz > > > - access http://www.erlang-projects.org/ and get "Bad Gateway" error > > same here in .de Bad Gateway from .cz > > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > -- --Hynek (Pichi) Vychodil -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080211/0b89881c/attachment.html From gebi Mon Feb 11 15:45:57 2008 From: gebi (Michael Gebetsroither) Date: Mon, 11 Feb 2008 15:45:57 +0100 Subject: [erlang-questions] erlang sites availability References: Message-ID: * Anthony Kong wrote: > - access http://www.planeterlang.org/ and get "Access forbidden!" error works from .at > - access http://www.erlang-projects.org/ and get "Bad Gateway" error bad gateway from .at cu, michael -- It's already too late! From saleyn Mon Feb 11 14:31:56 2008 From: saleyn (Serge Aleynikov) Date: Mon, 11 Feb 2008 08:31:56 -0500 Subject: [erlang-questions] string:join([], Str) fails Message-ID: <47B04E4C.10605@gmail.com> I noticed that strings:join([], Str) is not handled in the implementation: 1> string:join([], ","). ** exception error: no function clause matching string:join([],",") This looks like an oversight, as it's not symmetric to string:tokens/2: 2> string:tokens([], ","). [] Serge From luke Mon Feb 11 16:36:11 2008 From: luke (LUKE) Date: Mon, 11 Feb 2008 23:36:11 +0800 Subject: [erlang-questions] erlang sites availability References: Message-ID: <16C8AE9AA980410CBF069267F70C7B59@lukeserver> > - access http://www.planeterlang.org/ and get "Access forbidden!" error "Access forbidden" from .tw > - access http://www.erlang-projects.org/ and get "Bad Gateway" error "Bad Gateway" from .tw ----- Original Message ----- From: "Anthony Kong" To: "EQ" Sent: Monday, February 11, 2008 5:20 PM Subject: [erlang-questions] erlang sites availability > Hi, all, > > Just wondering if you have experienced the same problem right now: > > - access http://www.planeterlang.org/ and get "Access forbidden!" error > > - access http://www.erlang-projects.org/ and get "Bad Gateway" error > > > Cheers, Anthony > > -- > /*--*/ > Don't EVER make the mistake that you can design something better than > what you get from ruthless massively parallel trial-and-error with a > feedback cycle. That's giving your intelligence _much_ too much > credit. > > - Linus Torvalds > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > > __________ NOD32 2862 (20080210) Information __________ > > This message was checked by NOD32 antivirus system. > http://www.nod32.com.hk > > From anthony.hw.kong Mon Feb 11 17:25:02 2008 From: anthony.hw.kong (Anthony Kong) Date: Tue, 12 Feb 2008 03:25:02 +1100 Subject: [erlang-questions] erlang sites availability In-Reply-To: <16C8AE9AA980410CBF069267F70C7B59@lukeserver> References: <16C8AE9AA980410CBF069267F70C7B59@lukeserver> Message-ID: Me from Sydney, au. Still same error messages. I start to have an idea. I used to be able to access these sites. Last time I checked probably a month ago. Maybe due to earlier spam attacks (on erlang.org, but these sites are related as well), somehow IP based blocking are turned on? Cheers, Anthony On Feb 12, 2008 2:36 AM, LUKE wrote: > > - access http://www.planeterlang.org/ and get "Access forbidden!" error > > "Access forbidden" from .tw > > > - access http://www.erlang-projects.org/ and get "Bad Gateway" error > "Bad Gateway" from .tw > > From alexander.lamb Mon Feb 11 18:58:36 2008 From: alexander.lamb (Alexander Lamb) Date: Mon, 11 Feb 2008 18:58:36 +0100 Subject: [erlang-questions] erlang sites availability In-Reply-To: References: Message-ID: <6F08377D-86C6-451E-84CE-D3893352AC4B@rodanotech.ch> Le 11 f?vr. 08 ? 15:45, Michael Gebetsroither a ?crit : > * Anthony Kong wrote: > >> - access http://www.planeterlang.org/ and get "Access forbidden!" >> error > Works from .fr > > >> - access http://www.erlang-projects.org/ and get "Bad Gateway" error > > bad gateway from .fr From kangas Mon Feb 11 21:11:05 2008 From: kangas (Matt Kangas) Date: Mon, 11 Feb 2008 15:11:05 -0500 Subject: [erlang-questions] Documentation build process: creating DocBook XML? Message-ID: <8EDCB178-4069-4F2B-A5BF-385C1D5D0565@bway.net> Dear Erlang team, and erlang-questions readers, I have some questions about the Erlang *documentation* build process. I'll list my questions first, then explain my reasons for asking... Questions: 1) What makefile targets are used to build the HTML documentation from source? Given an Erlang source tarball, can I build all of http://www.erlang.org/doc/ myself? 2) Which tools are used to generate which parts of the documentation? I've discovered "docbuilder" and "edoc" so far. What else gets called by make to crank out the doc tree? 3) What module(s) would I have to hack in order to add another output format to the documentation generator? Any advice on how to start? :-) Motivation: I'd like to see if put together an "improved" version of the current docs: same content, better presentation. Specifically, I'd like to try putting the Erlang docs inside the PHP documentation framework, as outlined here: http://www.p16blog.com/p16/2008/02/user-added-comm.html DocBook XML is the format I'd need to generate. It's a popular doc- source format for open-source projects, so even if PHP's framework proves unsuitable, several other doc frameworks should be directly usable. If I make any progress, I'll gladly contribute all code back to the community. :-) Thanks in advance, --Matt Kangas -- Matt Kangas kangas ? www.p16blog.com From Martin.Logan Mon Feb 11 21:18:17 2008 From: Martin.Logan (Logan, Martin) Date: Mon, 11 Feb 2008 14:18:17 -0600 Subject: [erlang-questions] Chicago Erllounge - Last Call For Final Date Vote Message-ID: >From all the response I have been getting it looks like most people want to meet for the Chicago Erllounge on Wednesday the 13th. I am still open to Friday if we get more responses on that side. If I don't get enough votes that way I am going to reserve our spot at the Blue Line Club Car for Wed the 13th. Please respond today, or tomorrow at latest, to this email or send email to martinjlogan with what day works for you. Cheers, Martin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080211/17b90999/attachment-0001.html From mike.hales Mon Feb 11 20:40:00 2008 From: mike.hales (Mike Hales) Date: Mon, 11 Feb 2008 12:40:00 -0700 Subject: [erlang-questions] erlang sites availability In-Reply-To: References: Message-ID: <0841E3E3-8D92-4378-906B-AD08554ACDD1@kscape.com> > > > - access http://www.planeterlang.org/ and get "Access forbidden!" > error Works from US. > > > - access http://www.erlang-projects.org/ and get "Bad Gateway" error > Bad gateway error from US. From christophe.romain Mon Feb 11 23:20:26 2008 From: christophe.romain (Christophe Romain) Date: Mon, 11 Feb 2008 23:20:26 +0100 Subject: [erlang-questions] erlang sites availability In-Reply-To: References: Message-ID: <330B8380-8EBC-45CE-87EA-1CAFE3938C69@process-one.net> Hi erlang-projects no longer exists, its content was very old and not maintained by the way. planeterlang.org filters some IP from china due to massive spamming. From KONGA Mon Feb 11 23:56:33 2008 From: KONGA (Anthony Kong) Date: Tue, 12 Feb 2008 09:56:33 +1100 Subject: [erlang-questions] erlang sites availability In-Reply-To: <330B8380-8EBC-45CE-87EA-1CAFE3938C69@process-one.net> References: <330B8380-8EBC-45CE-87EA-1CAFE3938C69@process-one.net> Message-ID: <47B16D4E.664A.00DD.0@stgeorge.com.au> Hi, Chris, Thanks for the info. I tried to access erlang-projects because I wanted to download a package called ejson, which as the name suggests it is JSON for erlang. It comes up first if you search for "erlang json". I probably should search the mailing list for an answer. Thanks all. Cheers, Anthony >>> Christophe Romain 12/02/2008 9:20 am >>> Hi erlang-projects no longer exists, its content was very old and not maintained by the way. planeterlang.org filters some IP from china due to massive spamming. ********************************************************************** ***** IMPORTANT INFORMATION ***** This document should be read only by those persons to whom it is addressed and its content is not intended for use by any other persons. If you have received this message in error, please notify us immediately. Please also destroy and delete the message from your computer. Any unauthorised form of reproduction of this message is strictly prohibited. St George Bank Limited AFSL 240997, Advance Asset Management Limited AFSL 240902, St George Life Limited AFSL 240900, ASGARD Capital Management Limited AFSL 240695 and Securitor Financial Group Limited AFSL 240687 is not liable for the proper and complete transmission of the information contained in this communication, nor for any delay in its receipt. ********************************************************************** -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080212/a1044013/attachment.html From kenneth.lundin Tue Feb 12 00:08:31 2008 From: kenneth.lundin (Kenneth Lundin) Date: Tue, 12 Feb 2008 00:08:31 +0100 Subject: [erlang-questions] Documentation build process: creating DocBook XML? In-Reply-To: <8EDCB178-4069-4F2B-A5BF-385C1D5D0565@bway.net> References: <8EDCB178-4069-4F2B-A5BF-385C1D5D0565@bway.net> Message-ID: On 2/11/08, Matt Kangas wrote: > Dear Erlang team, and erlang-questions readers, > > I have some questions about the Erlang *documentation* build process. > I'll list my questions first, then explain my reasons for asking... > > Questions: > > 1) What makefile targets are used to build the HTML documentation from > source? The makefiles for building the documentation is not part of the source tar ball. > Given an Erlang source tarball, can I build all of http://www.erlang.org/doc/ > myself? No, since the sources for the documentation is not included. As said earlier we are preparing for making the doc sources (in XML) available. It will happen soon (most probably before summer). > > 2) Which tools are used to generate which parts of the documentation? > I've discovered "docbuilder" and "edoc" so far. What else gets called > by make to crank out the doc tree? docbuilder is used to build all html except the top page and some index files which are built with specific Erlang programs currently not part of the distribution. Some applications are documented with edoc which is then translated to xml, fed into docbuilder to get the same format for everything. > > 3) What module(s) would I have to hack in order to add another output > format to the documentation generator? Any advice on how to start? :-) docbuilder and the generated html is undergoing stepwise improvements right now. There is a lot of history in docbuilder since the documentation source was in SGML. Much of this history makes docbuilder more complicated than it need to be and we will improve that stepwise. Docbuilder is the only code you need to hack to add another output format. It would be relatively easy to add a new output format in parallell with xhtml which is the current format. There are currently 3 backends for docbuilder: html, man, pdf (via latex) Only the html backend is included in the distribution. The man-backend is not released since we don't think it is so important. Only the reference manuals for modules and cprograms can be translated to man. The pdf backend is not released since it is dependent on a number of external tools. If we could handle all the conversion to pdf in Erlang we would distribute that backend as well. The generated html can be used as passive files , there is no need for a web-server which can deliver active content, this has been a principle from the beginning and it is still relevant. > > > Motivation: > > I'd like to see if put together an "improved" version of the current > docs: same content, better presentation. Specifically, I'd like to try > putting the Erlang docs inside the PHP documentation framework, as > outlined here: > > http://www.p16blog.com/p16/2008/02/user-added-comm.html > > DocBook XML is the format I'd need to generate. It's a popular doc- > source format for open-source projects, so even if PHP's framework > proves unsuitable, several other doc frameworks should be directly > usable. I am well aware of DocBook it is a huge DTD. The possibility to use existing backends for docbook to generate html and pdf could be interesting. But when I searched around for such backends a year or two ago I did not find anything that was attractive enough. I followed the link above to the PHP doc and I was not impressed by the format. The idea with notes from readers is nice but would't a type of Wiki be nicer? What else is so much better in the php doc's format? The notes from readers would be interesting to implement, but it would require some active logic on the server side, which we don't need today. But it would be relatively easy to implement even from scratch without use of the PHP framework. Have to read the PHP doc how to. > > If I make any progress, I'll gladly contribute all code back to the > community. :-) If there is a specific output format we can agree on I am interested in making a backend for it. Until then I will continue the improvements on the docbuilder html backend, considering the suggestions regarding google friendly etc. /Kenneth Erlang/OTP team at Ericsson > > Thanks in advance, > --Matt Kangas > > -- > Matt Kangas > kangas ? www.p16blog.com > > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > From bruce Tue Feb 12 01:00:25 2008 From: bruce (Bruce Fitzsimons) Date: Tue, 12 Feb 2008 13:00:25 +1300 Subject: [erlang-questions] erlang sites availability In-Reply-To: <330B8380-8EBC-45CE-87EA-1CAFE3938C69@process-one.net> References: <330B8380-8EBC-45CE-87EA-1CAFE3938C69@process-one.net> Message-ID: <47B0E199.7000306@fitzsimons.org> Christophe Romain wrote: > Hi > > erlang-projects no longer exists, its content was very old and not > maintained by the way. > planeterlang.org filters some IP from china due to massive spamming. > Also down from .nz space, the responses to date would suggest that your filtering is a little coarse. Cheers, Bruce From kangas Tue Feb 12 02:39:19 2008 From: kangas (Matt Kangas) Date: Mon, 11 Feb 2008 20:39:19 -0500 Subject: [erlang-questions] Documentation build process: creating DocBook XML? In-Reply-To: References: <8EDCB178-4069-4F2B-A5BF-385C1D5D0565@bway.net> Message-ID: <0E4164A2-0124-4091-9C89-08AA9DC2D6C5@bway.net> Kenneth, Thank you for the prompt and very detailed response! I apologize if my questions seemed to come out of nowhere. I'm a new user of Erlang, just getting used to what tools & resources are available. (Longer response sent direct - will bring discussion back to the list if anyone's interested) Thanks, --Matt On Feb 11, 2008, at 6:08 PM, Kenneth Lundin wrote: > On 2/11/08, Matt Kangas wrote: >> Dear Erlang team, and erlang-questions readers, >> >> I have some questions about the Erlang *documentation* build process. >> I'll list my questions first, then explain my reasons for asking... >> >> Questions: >> >> 1) What makefile targets are used to build the HTML documentation >> from >> source? > The makefiles for building the documentation is not part of the > source tar ball. > >> Given an Erlang source tarball, can I build all of http://www.erlang.org/doc/ >> myself? > No, since the sources for the documentation is not included. > As said earlier we are preparing for making the doc sources (in XML) > available. > It will happen soon (most probably before summer). >> >> 2) Which tools are used to generate which parts of the documentation? >> I've discovered "docbuilder" and "edoc" so far. What else gets called >> by make to crank out the doc tree? > docbuilder is used to build all html except the top page and some > index files which are built with specific Erlang programs currently > not part of the distribution. > > Some applications are documented with edoc which is then translated to > xml, fed into docbuilder to get the same format for everything. > >> >> 3) What module(s) would I have to hack in order to add another output >> format to the documentation generator? Any advice on how to >> start? :-) > docbuilder and the generated html is undergoing stepwise > improvements right now. > There is a lot of history in docbuilder since the documentation source > was in SGML. Much of this history makes docbuilder more complicated > than it need to be and we will improve that stepwise. > Docbuilder is the only code you need to hack to add another output > format. > It would be relatively easy to add a new output format in parallell > with xhtml which > is the current format. > > There are currently 3 backends for docbuilder: html, man, pdf (via > latex) > Only the html backend is included in the distribution. > The man-backend is not released since we don't think it is so > important. Only the reference manuals for modules and cprograms can be > translated to man. > The pdf backend is not released since it is dependent on a number of > external tools. If we could handle all the conversion to pdf in Erlang > we would distribute that backend as well. > > The generated html can be used as passive files , there is no need for > a web-server > which can deliver active content, this has been a principle from the > beginning and it is still relevant. > >> >> >> Motivation: >> >> I'd like to see if put together an "improved" version of the current >> docs: same content, better presentation. Specifically, I'd like to >> try >> putting the Erlang docs inside the PHP documentation framework, as >> outlined here: >> >> http://www.p16blog.com/p16/2008/02/user-added-comm.html >> >> DocBook XML is the format I'd need to generate. It's a popular doc- >> source format for open-source projects, so even if PHP's framework >> proves unsuitable, several other doc frameworks should be directly >> usable. > I am well aware of DocBook it is a huge DTD. The possibility to use > existing backends for docbook to generate html and pdf could be > interesting. > But when I searched around for such backends a year or two ago I did > not find > anything that was attractive enough. > > I followed the link above to the PHP doc and I was not impressed by > the format. The idea with > notes from readers is nice but would't a type of Wiki be nicer? > What else is so much better in the php doc's format? > > The notes from readers would be interesting to implement, but it would > require some active logic on the server side, which we don't need > today. > But it would be relatively easy to implement even from scratch without > use of the > PHP framework. Have to read the PHP doc how to. >> >> If I make any progress, I'll gladly contribute all code back to the >> community. :-) > > If there is a specific output format we can agree on I am interested > in making a backend for it. > Until then I will continue the improvements on the docbuilder html > backend, considering the suggestions regarding google friendly etc. > > /Kenneth Erlang/OTP team at Ericsson -- Matt Kangas kangas ? www.p16blog.com From dustin.whitney Tue Feb 12 05:53:55 2008 From: dustin.whitney (Dustin Whitney) Date: Mon, 11 Feb 2008 23:53:55 -0500 Subject: [erlang-questions] UTF8 Message-ID: <23def8000802112053i70dec636kadb9ec56b13772f0@mail.gmail.com> All, I am performing some XPath against a UTF8 encoded XML document that has some characters outside of the ASCII range. How do I serialize them to a file in human readable format? For example one of the words is "?ta, Gunma" which corresponds to [332,116,97,44,32,71,117,110,109,97]. How can I write [332,116,97,44,32,71,117,110,109,97] to a file so that when I open it up it looks like "?ta, Gunma"? Ultimately I want to know this because I need to make REST calls with these words, and lists of integers aren't cutting it. Thanks, Dustin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080211/1f9f4391/attachment.html From hasan.veldstra Tue Feb 12 08:59:04 2008 From: hasan.veldstra (Hasan Veldstra) Date: Tue, 12 Feb 2008 07:59:04 +0000 Subject: [erlang-questions] UTF8 In-Reply-To: <23def8000802112053i70dec636kadb9ec56b13772f0@mail.gmail.com> References: <23def8000802112053i70dec636kadb9ec56b13772f0@mail.gmail.com> Message-ID: > How can I write [332,116,97,44,32,71,117,110,109,97] to a file so > that when I open it up it looks like "?ta, Gunma"? -module(ftest). -export([run/0]). run() -> Data = [197,140,116,97,44,32,71,117,110,109,97], file:write_file("ftest.txt", list_to_binary(Data)). Text is just numbers when stored to disk. By the way, the list of numbers you originally posted is "?ta, Gunma" encoded in UTF-32, not UTF-8. It's in UTF-8 in my example. Hope this helps. From ttmrichter Tue Feb 12 13:07:01 2008 From: ttmrichter (Michael T. Richter) Date: Tue, 12 Feb 2008 20:07:01 +0800 Subject: [erlang-questions] erlang sites availability In-Reply-To: <330B8380-8EBC-45CE-87EA-1CAFE3938C69@process-one.net> References: <330B8380-8EBC-45CE-87EA-1CAFE3938C69@process-one.net> Message-ID: <1202818022.2915.20.camel@isolde> On Mon, 2008-02-11 at 23:20 +0100, Christophe Romain wrote: > planeterlang.org filters some IP from china due to massive spamming. Well that kind of sucks doubly for those of us stuck behind the Bamboo Curtain. One the one side we have a paternalistic government run by frightened old men blocking us from sites that are supposedly bad for us and on the other we have people blocking us from visiting their sites because they can't use spam filters. -- Michael T. Richter (GoogleTalk: ttmrichter) A well-designed and humane interface does not need to be split into beginner and expert subsystems. (Jef Raskin) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080212/6d601686/attachment.html -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part Url : http://www.erlang.org/pipermail/erlang-questions/attachments/20080212/6d601686/attachment.bin From Martin.Logan Tue Feb 12 16:41:27 2008 From: Martin.Logan (Logan, Martin) Date: Tue, 12 Feb 2008 09:41:27 -0600 Subject: [erlang-questions] Chicago Erllounge Date Confirmed Message-ID: The date is officially tomorrow, Wednesday the 13th. Time is: 6:30 pm The location is: BLUE LINE CLUB CAR American on 1548 N. DAMEN AVE. (773) 395-3700 This location is right off the blue line el and easily reachable from the O'hare. Basically just hop on the el and get off at Damen, the bar is underneath the stop. See you all there. Cheers, Martin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080212/5eb75f45/attachment.html From mickael.remond Tue Feb 12 16:30:14 2008 From: mickael.remond (=?UTF-8?Q?Micka=C3=ABl_R=C3=A9mond?=) Date: Tue, 12 Feb 2008 16:30:14 +0100 Subject: [erlang-questions] erlang sites availability In-Reply-To: <1202818022.2915.20.camel@isolde> References: <330B8380-8EBC-45CE-87EA-1CAFE3938C69@process-one.net> <1202818022.2915.20.camel@isolde> Message-ID: <480CB024-8F38-4E62-B493-098B104500D6@process-one.net> Hello, Le 12 f?vr. 08 ? 13:07, Michael T. Richter a ?crit : > > On Mon, 2008-02-11 at 23:20 +0100, Christophe Romain wrote: >> >> planeterlang.org filters some IP from china due to massive spamming. > > Well that kind of sucks doubly for those of us stuck behind the > Bamboo Curtain. One the one side we have a paternalistic government > run by frightened old men blocking us from sites that are supposedly > bad for us and on the other we have people blocking us from visiting > their sites because they can't use spam filters. We can use spam filter, trust me. We have changed the site code to use Akismet. This was however not enough. -- Micka?l R?mond http://www.process-one.net/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080212/24f64aaa/attachment.html From tsuraan Tue Feb 12 17:19:15 2008 From: tsuraan (tsuraan) Date: Tue, 12 Feb 2008 10:19:15 -0600 Subject: [erlang-questions] Strings as Lists Message-ID: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> Why does erlang internally represent strings as lists? In every language I've used other than Java, a string is a sequence of octets, just like Erlang's binary type. I know that you can represent a string efficiently by using <<"string">> rather than just "string", but why doesn't erlang do this by default? Is it just because pre-12B binary handling wasn't as efficient as list handling, or is Erlang intended to support UTF-32? Thanks for any input! -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080212/852d1da6/attachment.html From dustin.whitney Tue Feb 12 17:21:07 2008 From: dustin.whitney (Dustin Whitney) Date: Tue, 12 Feb 2008 11:21:07 -0500 Subject: [erlang-questions] UTF8 In-Reply-To: References: <23def8000802112053i70dec636kadb9ec56b13772f0@mail.gmail.com> Message-ID: <23def8000802120821u79dd458vbe0d9689f281697a@mail.gmail.com> Yeah, that worked thanks! I had tried what you did, but it did not work with the UTF-32 data. Do you know why? And how do you suppose my data was turned into UTF-32. I got the data originally from an HTTP GET request that returned a UTF-8 encoded XML file. The file its self says it's UTF-8, and the header tuple said the document was using the UTF-8 charset. Does Erlang convert the data automatically? Thanks! -Dustin On Feb 12, 2008 2:59 AM, Hasan Veldstra wrote: > > > How can I write [332,116,97,44,32,71,117,110,109,97] to a file so > > that when I open it up it looks like "?ta, Gunma"? > > > -module(ftest). > -export([run/0]). > > run() -> > Data = [197,140,116,97,44,32,71,117,110,109,97], > file:write_file("ftest.txt", list_to_binary(Data)). > > > Text is just numbers when stored to disk. > > By the way, the list of numbers you originally posted is "?ta, Gunma" > encoded in UTF-32, not UTF-8. It's in UTF-8 in my example. > > Hope this helps. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080212/7d8dc452/attachment.html From masklinn Tue Feb 12 17:45:07 2008 From: masklinn (Masklinn) Date: Tue, 12 Feb 2008 17:45:07 +0100 Subject: [erlang-questions] Strings as Lists In-Reply-To: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> Message-ID: <2F5E96D5-CF7A-42AC-B04E-CB8183F7AB7D@masklinn.net> On 12 Feb 2008, at 17:19 , tsuraan wrote: > Why does erlang internally represent strings as lists? In every > language > I've used other than Java, a string is a sequence of octets, just like > Erlang's binary type. I know that you can represent a string > efficiently by > using <<"string">> rather than just "string", but why doesn't erlang > do this > by default? Is it just because pre-12B binary handling wasn't as > efficient > as list handling, or is Erlang intended to support UTF-32? > A lot of functional languages represent strings as lists rather than arrays (Haskell also does that, and only recently got bytestrings) because lists are their basic collection datatype (due to being a recursive structure and everything), and this allows the use of all the list-related functions on strings. Representing strings as arrays of bytes or character (which is pretty much also what Java does, by the way) is an attribute of imperative languages whose basic collection datatype is the array. My guess is that's the reason why: a lot of string operations were already implemented on lists (reduces code duplication) and string efficiency wasn't really of importance in the erlang world until fairly recently, so strings being represented as lists of integers wasn't much of a problem. From pablo.polvorin Tue Feb 12 18:34:19 2008 From: pablo.polvorin (Pablo Polvorin) Date: Tue, 12 Feb 2008 14:34:19 -0300 Subject: [erlang-questions] asn1 and the new ssl module Message-ID: <1ffe809c0802120934r5c580eeas2cb811a7e5c0b170@mail.gmail.com> Hi all, I'm using the new ssl module to "upgrade" a gen_tcp socket to ssl. But I couldn't find a way to easily receiving asn1 packets from it. My question is, it's possible to use the {packet,asn1} option when using the new ssl module?. ssl_connection.erl seems to not have any reference to that option. Finally I implemented the buffering and packet delimiting code in my application, but I wonder if there is an easy and early way to accomplish the same. regards, -- Pablo Polvorin From chsu79 Tue Feb 12 19:21:45 2008 From: chsu79 (Christian S) Date: Tue, 12 Feb 2008 19:21:45 +0100 Subject: [erlang-questions] Strings as Lists In-Reply-To: <2F5E96D5-CF7A-42AC-B04E-CB8183F7AB7D@masklinn.net> References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> <2F5E96D5-CF7A-42AC-B04E-CB8183F7AB7D@masklinn.net> Message-ID: On Feb 12, 2008 5:45 PM, Masklinn wrote: > My guess is that's the reason why: a lot of string operations were > already implemented on lists (reduces code duplication) and string > efficiency wasn't really of importance in the erlang world until > fairly recently, so strings being represented as lists of integers > wasn't much of a problem. That is the reason. Hysterical Raisins. There was a time when Erlang didn't have binaries. Someone thought it would be a good idea to make "ABC" a way to write [65,66,67]. If you look at the old "eddie" web load balancer project you see the dns protocol being decoded using lists. The "" syntax for lists is a pragmatic solution to make code more readable when you need ascii sequences in your lists. I would not ask "Why does erlang internally represent strings as lists?". Erlang does not have strings. It has a shorthand syntax for creating lists. If you still consider "ABC" to be a string, then the list is certainly not an "internal representation". Go ahead and treat it as a list. I would ask "Why do some programmers store their large text-masses as lists?" Of course, I know the answer already; because there is a 'string' module that operates on lists as strings. Lazy buggers. Alternative ways to handle larger text-masses: - binaries (features representation that is 1:1 with the character encoding itself, now also (R12B) with efficient scanning and tail-construction) - iolists (features cheap concatenation of large texts) - list of words and a word-dictionary (features quicker scanning of ...words, efficient storage too) It all comes down to what you really are doing with your large texts. PS. For the scanning of protocols, I have been looking at Ragel as a tool to create C-code FSMs as a loadable driver that recognizes tokens and sends these tokens to the port owner process. The port owner in turn feeds the port binary chunks, since incremental parsing isnt much of a problem for state machines. Of course, I have only reached so far as to teach myself Ragel and realizing that it is still easy to make mistakes. It would be nice with a Ragel that produces erlang code. Have anyone else experimented with Ragel? I know that angry-ruby-guy used it for Mongrel, that is how I found out about it. From rvirding Tue Feb 12 23:13:02 2008 From: rvirding (Robert Virding) Date: Tue, 12 Feb 2008 23:13:02 +0100 Subject: [erlang-questions] Strings as Lists In-Reply-To: <2F5E96D5-CF7A-42AC-B04E-CB8183F7AB7D@masklinn.net> References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> <2F5E96D5-CF7A-42AC-B04E-CB8183F7AB7D@masklinn.net> Message-ID: <3dbc6d1c0802121413o7480d2abtc913801ceae67e8e@mail.gmail.com> I think it all boils down to what you are going to *do* with these strings. If you are just going to store them somewhere for later then converting them to a binary definitely save space. If, however, you are going to *work* with them then having them as lists is definitely much better. It is so much easier than having fixed sequence of octets. Also most, if not all declarative languages functional and logic, have very optimised list handling because lists are so practical to work with. As mentioned in the next mail you can also keep them as iolists while processing to make it efficient to send the strinigs into the big wide world. This is sort best of both worlds. Also having them as lists means you get UTF-16 and 32 for free, and most of your libraries still work straight out of the bag. This, UTF-16/32, I think will become much more important in the future when the number of internet users who don't have a latin charset as their base increases. Think of the influence of a few hundred million indians and chinese who want 32 bit charsets. :-) Robert On 12/02/2008, Masklinn wrote: > > > On 12 Feb 2008, at 17:19 , tsuraan wrote: > > > Why does erlang internally represent strings as lists? In every > > language > > I've used other than Java, a string is a sequence of octets, just like > > Erlang's binary type. I know that you can represent a string > > efficiently by > > using <<"string">> rather than just "string", but why doesn't erlang > > do this > > by default? Is it just because pre-12B binary handling wasn't as > > efficient > > as list handling, or is Erlang intended to support UTF-32? > > > > A lot of functional languages represent strings as lists rather than > arrays (Haskell also does that, and only recently got bytestrings) > because lists are their basic collection datatype (due to being a > recursive structure and everything), and this allows the use of all > the list-related functions on strings. > > Representing strings as arrays of bytes or character (which is pretty > much also what Java does, by the way) is an attribute of imperative > languages whose basic collection datatype is the array. > > My guess is that's the reason why: a lot of string operations were > already implemented on lists (reduces code duplication) and string > efficiency wasn't really of importance in the erlang world until > fairly recently, so strings being represented as lists of integers > wasn't much of a problem. > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080212/0c8c0392/attachment.html From rvirding Tue Feb 12 23:13:51 2008 From: rvirding (Robert Virding) Date: Tue, 12 Feb 2008 23:13:51 +0100 Subject: [erlang-questions] Erlounge in San Francisco, 17-22 February In-Reply-To: <3dbc6d1c0802071353v2873419x88587f630da567ac@mail.gmail.com> References: <3dbc6d1c0801190827l11ac1050yae37415a0e565270@mail.gmail.com> <3dbc6d1c0802011452v20c7df1fu966a326e8ed87e8b@mail.gmail.com> <76F389D3-F029-4EC3-9037-3D24B9ED6D15@gerakines.net> <3dbc6d1c0802071353v2873419x88587f630da567ac@mail.gmail.com> Message-ID: <3dbc6d1c0802121413o206a516ej1a9d328b3bf79d16@mail.gmail.com> Ok, now we just need some place to meet. Suggestions please. Robert On 07/02/2008, Robert Virding wrote: > > OK, monday the 18th it is! At 7.30 pm. Name a good pub/bar and we'll meet. > I'm staying down-town near the conference center, but I will have a car so I > can get almost anywhere. > > Robert > > On 07/02/2008, Nicholas Kereakas Gerakines wrote: > > > > > > Beer and good conversation sounds like fun. Monday the 18th works. > > > > # Nick Gerakines > > > > On Feb 6, 2008, at 3:19 PM, Will wrote: > > > > > I'd prefer Monday the 18th as well. > > > > > > 2008/2/1 Robert Virding : > > >> Thank you for the good response, now we just have to work out a > > >> suitable day > > >> to meet. Looking at my schedule for the conference these are my > > >> preferences > > >> (from best to worst): > > >> > > >> Saturday 16/2 (but I will be tired after the trip) > > >> Sunday 17/2 > > >> Tuesday 19/2 > > >> Monday 18/2 > > >> Friday 22/2 > > >> > > >> Wednesday and Thursday are a no-no. Come with suggestions and we'll > > >> decide. > > >> > > >> Well met, > > >> Robert > > >> > > >> > > >> On 19/01/2008, Robert Virding wrote: > > >>> > > >>> I will be in San Francisco 17-22 of February (actually from the > > >>> 16th) for > > >> a conference* and if there are any other Erlangers there perhaps we > > >> could > > >> meet over a beer and have a nice discussion. Let me know and we can > > >> arrange > > >> something. > > >>> > > >>> Robert > > >>> > > >>> *Game Developers Conference which until recently has had very > > >>> little to do > > >> with Erlang, they're all C++ weenies. > > >>> > > >>> > > >> > > >> > > >> _______________________________________________ > > >> erlang-questions mailing list > > >> erlang-questions > > >> http://www.erlang.org/mailman/listinfo/erlang-questions > > >> > > > _______________________________________________ > > > erlang-questions mailing list > > > erlang-questions > > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080212/8d4f0e26/attachment.html From kevin Wed Feb 13 00:41:24 2008 From: kevin (Kevin Scaldeferri) Date: Tue, 12 Feb 2008 15:41:24 -0800 Subject: [erlang-questions] Strings as Lists In-Reply-To: <3dbc6d1c0802121413o7480d2abtc913801ceae67e8e@mail.gmail.com> References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> <2F5E96D5-CF7A-42AC-B04E-CB8183F7AB7D@masklinn.net> <3dbc6d1c0802121413o7480d2abtc913801ceae67e8e@mail.gmail.com> Message-ID: <14EEE3D7-56F1-470A-BCE5-C5B534A6EF88@scaldeferri.com> On Feb 12, 2008, at 2:13 PM, Robert Virding wrote: > I think it all boils down to what you are going to *do* with these > strings. If you are just going to store them somewhere for later > then converting them to a binary definitely save space. If, however, > you are going to *work* with them then having them as lists is > definitely much better. It is so much easier than having fixed > sequence of octets. Also most, if not all declarative languages > functional and logic, have very optimised list handling because > lists are so practical to work with. Hold on... lists aren't really a particular convenient or efficient data structure for working with strings. First off, I append to strings a lot more than I prepend to them. Yeah, I could work with reversed strings, but that's a hack to deal with using the wrong data type. Plus, I probably prefix match more often than suffix matching (although this is less lopsided than append vs. prepend). Of course, I also like to do substring matching and regular expressions quite a bit, and Boyer-Moore is definitely more efficient with arrays than lists. It's probably worth noting that none of the languages which are considered _good_ for working with strings (AFAIK) use a list representation. -kevin From vlm Wed Feb 13 02:32:44 2008 From: vlm (Lev Walkin) Date: Tue, 12 Feb 2008 17:32:44 -0800 Subject: [erlang-questions] Strings as Lists In-Reply-To: <3dbc6d1c0802121413o7480d2abtc913801ceae67e8e@mail.gmail.com> References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> <2F5E96D5-CF7A-42AC-B04E-CB8183F7AB7D@masklinn.net> <3dbc6d1c0802121413o7480d2abtc913801ceae67e8e@mail.gmail.com> Message-ID: <47B248BC.10306@lionet.info> Robert Virding wrote: > I think it all boils down to what you are going to *do* with these > strings. If you are just going to store them somewhere for later then > converting them to a binary definitely save space. If, however, you are > going to *work* with them then having them as lists is definitely much > better. It is so much easier than having fixed sequence of octets. Also > most, if not all declarative languages functional and logic, have very > optimised list handling because lists are so practical to work with. > > As mentioned in the next mail you can also keep them as iolists while > processing to make it efficient to send the strinigs into the big wide > world. This is sort best of both worlds. > > Also having them as lists means you get UTF-16 and 32 for free, and most > of your libraries still work straight out of the bag. This, UTF-16/32, I > think will become much more important in the future when the number of > internet users who don't have a latin charset as their base increases. > Think of the influence of a few hundred million indians and chinese who > want 32 bit charsets. :-) Small correction: UTF-16 and UTF-32 are practically dead, you certainly need to think in terms of UTF-8 nowadays. > Robert > > On 12/02/2008, *Masklinn* > wrote: > > > On 12 Feb 2008, at 17:19 , tsuraan wrote: > > > Why does erlang internally represent strings as lists? In every > > language > > I've used other than Java, a string is a sequence of octets, just > like > > Erlang's binary type. I know that you can represent a string > > efficiently by > > using <<"string">> rather than just "string", but why doesn't erlang > > do this > > by default? Is it just because pre-12B binary handling wasn't as > > efficient > > as list handling, or is Erlang intended to support UTF-32? > > > > A lot of functional languages represent strings as lists rather than > arrays (Haskell also does that, and only recently got bytestrings) > because lists are their basic collection datatype (due to being a > recursive structure and everything), and this allows the use of all > the list-related functions on strings. > > Representing strings as arrays of bytes or character (which is pretty > much also what Java does, by the way) is an attribute of imperative > languages whose basic collection datatype is the array. > > My guess is that's the reason why: a lot of string operations were > already implemented on lists (reduces code duplication) and string > efficiency wasn't really of importance in the erlang world until > fairly recently, so strings being represented as lists of integers > wasn't much of a problem. > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions From dking Wed Feb 13 03:36:46 2008 From: dking (David King) Date: Tue, 12 Feb 2008 18:36:46 -0800 Subject: [erlang-questions] Erlounge in San Francisco, 17-22 February In-Reply-To: <3dbc6d1c0802121413o206a516ej1a9d328b3bf79d16@mail.gmail.com> References: <3dbc6d1c0801190827l11ac1050yae37415a0e565270@mail.gmail.com> <3dbc6d1c0802011452v20c7df1fu966a326e8ed87e8b@mail.gmail.com> <76F389D3-F029-4EC3-9037-3D24B9ED6D15@gerakines.net> <3dbc6d1c0802071353v2873419x88587f630da567ac@mail.gmail.com> <3dbc6d1c0802121413o206a516ej1a9d328b3bf79d16@mail.gmail.com> Message-ID: <2FAE4954-2162-4B22-A1D4-CD6D88F736F0@ketralnis.com> > Ok, now we just need some place to meet. Suggestions please. Reddit is willing to use their office in SoMa near Moscone for an Erlang meetup > > > Robert > > On 07/02/2008, Robert Virding wrote: OK, monday > the 18th it is! At 7.30 pm. Name a good pub/bar and we'll meet. I'm > staying down-town near the conference center, but I will have a car > so I can get almost anywhere. > > Robert > > > On 07/02/2008, Nicholas Kereakas Gerakines wrote: > Beer and good conversation sounds like fun. Monday the 18th works. > > # Nick Gerakines > > On Feb 6, 2008, at 3:19 PM, Will wrote: > > > I'd prefer Monday the 18th as well. > > > > 2008/2/1 Robert Virding : > >> Thank you for the good response, now we just have to work out a > >> suitable day > >> to meet. Looking at my schedule for the conference these are my > >> preferences > >> (from best to worst): > >> > >> Saturday 16/2 (but I will be tired after the trip) > >> Sunday 17/2 > >> Tuesday 19/2 > >> Monday 18/2 > >> Friday 22/2 > >> > >> Wednesday and Thursday are a no-no. Come with suggestions and we'll > >> decide. > >> > >> Well met, > >> Robert > >> > >> > >> On 19/01/2008, Robert Virding wrote: > >>> > >>> I will be in San Francisco 17-22 of February (actually from the > >>> 16th) for > >> a conference* and if there are any other Erlangers there perhaps we > >> could > >> meet over a beer and have a nice discussion. Let me know and we can > >> arrange > >> something. > >>> > >>> Robert > >>> > >>> *Game Developers Conference which until recently has had very > >>> little to do > >> with Erlang, they're all C++ weenies. > >>> > >>> > >> > >> > >> _______________________________________________ > >> erlang-questions mailing list > >> erlang-questions > >> http://www.erlang.org/mailman/listinfo/erlang-questions > >> > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions > > http://www.erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions From exta7 Wed Feb 13 05:00:16 2008 From: exta7 (Zvi) Date: Tue, 12 Feb 2008 20:00:16 -0800 (PST) Subject: [erlang-questions] Strings as Lists In-Reply-To: References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> <2F5E96D5-CF7A-42AC-B04E-CB8183F7AB7D@masklinn.net> Message-ID: <15448906.post@talk.nabble.com> Hi Christian, Christian S wrote: > > I would ask "Why do some programmers store their large text-masses as > lists?" > > Of course, I know the answer already; because there is a 'string' > module that operates on lists as strings. Lazy buggers. > Still there is a need for standard string datatype, which will be good for 90% of uses and it should be accepted by all standard libs. I reperesent strings as binaries, and my code become much more verbose (almost unreadable), i.e using: * <<"ABC">>, instead of "ABC" * <> instead of S1++S2 * using file:delete(binary_to_list(Filename)) instead of file:delete(Filename) * xmerl and erlsom parse into lists and not binaries (I heard about expat port, which can parse binary XML, but I don't know how to extract it's code out of ejabberd). etc. Christian S wrote: > > - list of words and a word-dictionary (features quicker scanning of > ...words, efficient storage too) > I want to implement something like this, but using atoms for words. Is this a good idea? There is a limit to number of atoms in VM (I think ~1M). I can preload lists of atoms-per-word and then use only list_to_existing_atom ... I'll have around 100000 words/atoms. Do you think that it's much better to use ets with integer word IDs mapped to binaries? Christian S wrote: > > For the scanning of protocols, I have been looking at Ragel as a tool > to create C-code FSMs as a loadable driver that recognizes tokens and > sends these tokens to the port owner process. The port owner in turn > feeds the port binary chunks, since incremental parsing isnt much of a > problem for state machines. > How Ragel is better, than other lexical analysers? Do you use it primarily because it's parsing binary input, why Erlang leexer working with lists? BR, Zvi -- View this message in context: http://www.nabble.com/Strings-as-Lists-tp15436835p15448906.html Sent from the Erlang Questions mailing list archive at Nabble.com. From dustin.whitney Wed Feb 13 05:29:02 2008 From: dustin.whitney (Dustin Whitney) Date: Tue, 12 Feb 2008 23:29:02 -0500 Subject: [erlang-questions] Strings as Lists In-Reply-To: <15448906.post@talk.nabble.com> References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> <2F5E96D5-CF7A-42AC-B04E-CB8183F7AB7D@masklinn.net> <15448906.post@talk.nabble.com> Message-ID: <23def8000802122029oc951482x6948cbe9824771da@mail.gmail.com> > Still there is a need for standard string datatype, which will be good for > 90% of uses and it should be accepted by all standard libs. > I reperesent strings as binaries, and my code become much more verbose > (almost unreadable), i.e using: > * <<"ABC">>, instead of "ABC" > * <> instead of S1++S2 > * using file:delete(binary_to_list(Filename)) instead of > file:delete(Filename) > * xmerl and erlsom parse into lists and not binaries (I heard about expat > port, which can parse binary XML, but I don't know how to extract it's > code > out of ejabberd). > etc. > > I agree. A standard string datatype would be a great addition, and it would make picking up erlang twice as easy. I am playing around with erlang right now, and strings have been the biggest hurdle for me. -Dustin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080212/7fe42acc/attachment.html From wglozer Wed Feb 13 06:45:08 2008 From: wglozer (Will) Date: Tue, 12 Feb 2008 21:45:08 -0800 Subject: [erlang-questions] Erlounge in San Francisco, 17-22 February In-Reply-To: <3dbc6d1c0802121413o206a516ej1a9d328b3bf79d16@mail.gmail.com> References: <3dbc6d1c0801190827l11ac1050yae37415a0e565270@mail.gmail.com> <3dbc6d1c0802011452v20c7df1fu966a326e8ed87e8b@mail.gmail.com> <76F389D3-F029-4EC3-9037-3D24B9ED6D15@gerakines.net> <3dbc6d1c0802071353v2873419x88587f630da567ac@mail.gmail.com> <3dbc6d1c0802121413o206a516ej1a9d328b3bf79d16@mail.gmail.com> Message-ID: Hmm, I'm fairly new to SF so can't make a lot of recommendations... I think 21st Amendment Brewery (2nd St near Brannan) has some larger tables, or there are always the hotel bars nearby (Westin, W, Four Seasons, Marriott, etc). On Feb 12, 2008 2:13 PM, Robert Virding wrote: > Ok, now we just need some place to meet. Suggestions please. > > Robert > > > > On 07/02/2008, Robert Virding wrote: > > OK, monday the 18th it is! At 7.30 pm. Name a good pub/bar and we'll meet. > I'm staying down-town near the conference center, but I will have a car so I > can get almost anywhere. > > > > Robert > > > > > > > > On 07/02/2008, Nicholas Kereakas Gerakines wrote: > > > > > > Beer and good conversation sounds like fun. Monday the 18th works. > > > > > > # Nick Gerakines > > > > > > On Feb 6, 2008, at 3:19 PM, Will wrote: > > > > > > > I'd prefer Monday the 18th as well. > > > > > > > > 2008/2/1 Robert Virding : > > > >> Thank you for the good response, now we just have to work out a > > > >> suitable day > > > >> to meet. Looking at my schedule for the conference these are my > > > >> preferences > > > >> (from best to worst): > > > >> > > > >> Saturday 16/2 (but I will be tired after the trip) > > > >> Sunday 17/2 > > > >> Tuesday 19/2 > > > >> Monday 18/2 > > > >> Friday 22/2 > > > >> > > > >> Wednesday and Thursday are a no-no. Come with suggestions and we'll > > > >> decide. > > > >> > > > >> Well met, > > > >> Robert > > > >> > > > >> > > > >> On 19/01/2008, Robert Virding wrote: > > > >>> > > > >>> I will be in San Francisco 17-22 of February (actually from the > > > >>> 16th) for > > > >> a conference* and if there are any other Erlangers there perhaps we > > > >> could > > > >> meet over a beer and have a nice discussion. Let me know and we can > > > >> arrange > > > >> something. > > > >>> > > > >>> Robert > > > >>> > > > >>> *Game Developers Conference which until recently has had very > > > >>> little to do > > > >> with Erlang, they're all C++ weenies. > > > >>> > > > >>> > > > >> > > > >> > > > >> _______________________________________________ > > > >> erlang-questions mailing list > > > >> erlang-questions > > > >> http://www.erlang.org/mailman/listinfo/erlang-questions > > > >> > > > > _______________________________________________ > > > > erlang-questions mailing list > > > > erlang-questions > > > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > > _______________________________________________ > > > erlang-questions mailing list > > > erlang-questions > > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > > > > > From j.bhanot Wed Feb 13 07:24:22 2008 From: j.bhanot (J Bhanot) Date: Wed, 13 Feb 2008 11:54:22 +0530 Subject: [erlang-questions] Service Change request in C node Message-ID: Hi, I have been able to send Service Change request from {MG->MGC} both running as erlang nodes and also SCR from MGC to cnode... Now the problem I have since SCR sent to C node is ETerm ... I would need to convert that to some recognisable format in C node... Is there any erl API to convert SCR in ETerm to String in C.. Thanks, jb ___________________________________________ =====-----=====-----===== Notice: The information contained in this e-mail message and/or attachments to it may contain confidential or privileged information. If you are not the intended recipient, any dissemination, use, review, distribution, printing or copying of the information contained in this e-mail message and/or attachments to it are strictly prohibited. If you have received this communication in error, please notify us by reply e-mail or telephone and immediately and permanently delete the message and any attachments. Thank you -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080213/b50704c6/attachment.html From vychodil.hynek Wed Feb 13 07:36:16 2008 From: vychodil.hynek (Hynek Vychodil) Date: Wed, 13 Feb 2008 07:36:16 +0100 Subject: [erlang-questions] Strings as Lists In-Reply-To: <15448906.post@talk.nabble.com> References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> <2F5E96D5-CF7A-42AC-B04E-CB8183F7AB7D@masklinn.net> <15448906.post@talk.nabble.com> Message-ID: <4d08db370802122236r66e1add9j54440b547987f959@mail.gmail.com> On Feb 13, 2008 5:00 AM, Zvi wrote: > Still there is a need for standard string datatype, which will be good for > 90% of uses and it should be accepted by all standard libs. > I reperesent strings as binaries, and my code become much more verbose > (almost unreadable), i.e using: > * <<"ABC">>, instead of "ABC" You can do it only because ISO-8859-1 is enough for you. Your code will be crap for me, because I would not use it! One char not equal to one byte, remeber it! List is best solution for all non english world, because one list element equals to one char. If you want make onelingual programs, continue in your practise. God save you. -- --Hynek (Pichi) Vychodil -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080213/e0f3850b/attachment.html From j.bhanot Wed Feb 13 07:37:15 2008 From: j.bhanot (J Bhanot) Date: Wed, 13 Feb 2008 12:07:15 +0530 Subject: [erlang-questions] Service Change request in C node In-Reply-To: Message-ID: Hi, A related question to this post only - How does Erlang treat a message or a service change request - Is it a list in Erlang... and if it is a list then how do i convert that in C recognisable format. Thanks, jb =====-----=====-----===== Notice: The information contained in this e-mail message and/or attachments to it may contain confidential or privileged information. If you are not the intended recipient, any dissemination, use, review, distribution, printing or copying of the information contained in this e-mail message and/or attachments to it are strictly prohibited. If you have received this communication in error, please notify us by reply e-mail or telephone and immediately and permanently delete the message and any attachments. Thank you -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080213/85a4552e/attachment.html From bjorn Wed Feb 13 07:39:45 2008 From: bjorn (Bjorn Gustavsson) Date: 13 Feb 2008 07:39:45 +0100 Subject: [erlang-questions] Strings as Lists In-Reply-To: <47B248BC.10306@lionet.info> References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> <2F5E96D5-CF7A-42AC-B04E-CB8183F7AB7D@masklinn.net> <3dbc6d1c0802121413o7480d2abtc913801ceae67e8e@mail.gmail.com> <47B248BC.10306@lionet.info> Message-ID: Lev Walkin writes: > > Small correction: UTF-16 and UTF-32 are practically dead, you certainly > need to think in terms of UTF-8 nowadays. Only for input and output. Internally, it is much easier to have a list with one element per Unicode character. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From zerthurd Wed Feb 13 07:46:05 2008 From: zerthurd (Maxim Treskin) Date: Wed, 13 Feb 2008 12:46:05 +0600 Subject: [erlang-questions] Service Change request in C node In-Reply-To: References: Message-ID: You can find related funtions in manual for ei: erl -man ei -- Maxim Treskin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080213/869391c8/attachment.html From bjorn Wed Feb 13 07:58:51 2008 From: bjorn (Bjorn Gustavsson) Date: 13 Feb 2008 07:58:51 +0100 Subject: [erlang-questions] Strings as Lists In-Reply-To: <14EEE3D7-56F1-470A-BCE5-C5B534A6EF88@scaldeferri.com> References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> <2F5E96D5-CF7A-42AC-B04E-CB8183F7AB7D@masklinn.net> <3dbc6d1c0802121413o7480d2abtc913801ceae67e8e@mail.gmail.com> <14EEE3D7-56F1-470A-BCE5-C5B534A6EF88@scaldeferri.com> Message-ID: Kevin Scaldeferri writes: > On Feb 12, 2008, at 2:13 PM, Robert Virding wrote: > > Hold on... lists aren't really a particular convenient or efficient > data structure for working with strings. First off, I append to > strings a lot more than I prepend to them. You can append by building a deep list and only flatten it at the end. NewString = [AListOfChars|AnotherListOfChars] or NewString = [AListOfChars,ACharacter] Or you can simply do a recursion (not tail-recursion) and use the '++' operator. That will be efficient, because the recursion will ensure that the '++' operators are executed in a right-to-left order. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From masklinn Wed Feb 13 08:11:43 2008 From: masklinn (Masklinn) Date: Wed, 13 Feb 2008 08:11:43 +0100 Subject: [erlang-questions] Strings as Lists In-Reply-To: <47B248BC.10306@lionet.info> References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> <2F5E96D5-CF7A-42AC-B04E-CB8183F7AB7D@masklinn.net> <3dbc6d1c0802121413o7480d2abtc913801ceae67e8e@mail.gmail.com> <47B248BC.10306@lionet.info> Message-ID: On 13 Feb 2008, at 02:32 , Lev Walkin wrote: > Robert Virding wrote: >> I think it all boils down to what you are going to *do* with these >> strings. If you are just going to store them somewhere for later >> then converting them to a binary definitely save space. If, >> however, you are going to *work* with them then having them as >> lists is definitely much better. It is so much easier than having >> fixed sequence of octets. Also most, if not all declarative >> languages functional and logic, have very optimised list handling >> because lists are so practical to work with. >> As mentioned in the next mail you can also keep them as iolists >> while processing to make it efficient to send the strinigs into the >> big wide world. This is sort best of both worlds. >> Also having them as lists means you get UTF-16 and 32 for free, and >> most of your libraries still work straight out of the bag. This, >> UTF-16/32, I think will become much more important in the future >> when the number of internet users who don't have a latin charset as >> their base increases. Think of the influence of a few hundred >> million indians and chinese who want 32 bit charsets. :-) > > Small correction: UTF-16 and UTF-32 are practically dead, you > certainly > need to think in terms of UTF-8 nowadays. > I need to think in terms of none of these. They're all transformation formats, in other words exchange formats. Inner representation of characters on 32 bits means we should get raw unicode codepoints and be done with it, the codepoints are the universal theoretical "values" for each character and there is *no reason* to use an UTF or an UCS format as the internal representation of characters. From j.bhanot Wed Feb 13 08:57:20 2008 From: j.bhanot (J Bhanot) Date: Wed, 13 Feb 2008 13:27:20 +0530 Subject: [erlang-questions] Service Change request in C node In-Reply-To: Message-ID: Hi Maxim, I am sending following message from MGC to C node - {'ServiceChangeRequest',[{megaco_term_id,false,[[114,111,111,116]]}],{'ServiceChangeParm',restart,asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE,[[57,48,49]],asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE}} I am using this in C node : tuplep = erl_element(3, emsg.msg); // above msg is the 3rd element that I pass from Erlang fnp1 = erl_element(1, tuplep); // I try to get the first element from that i.e. ServiceChangeRequest\ tuplesize = ERL_TUPLE_SIZE(tuplep); // gives me 3 mymessage1= ERL_ATOM_PTR(fnp1); // corerctly get ServiceChangeRequest when I print mymessage1 mymessage2 = ERL_ATOM_PTR(fnp2); // this gives junk as 2 element is not an atom Unfortunately, I have not been able to find any API that converts the whole list or tuple in String. Is there any API that can do so. Many thanks for your help. Regards, jb =====-----=====-----===== Notice: The information contained in this e-mail message and/or attachments to it may contain confidential or privileged information. If you are not the intended recipient, any dissemination, use, review, distribution, printing or copying of the information contained in this e-mail message and/or attachments to it are strictly prohibited. If you have received this communication in error, please notify us by reply e-mail or telephone and immediately and permanently delete the message and any attachments. Thank you -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080213/b54f8619/attachment.html From alex.arnon Wed Feb 13 09:53:12 2008 From: alex.arnon (Alex Arnon) Date: Wed, 13 Feb 2008 10:53:12 +0200 Subject: [erlang-questions] UTF8 In-Reply-To: <23def8000802120821u79dd458vbe0d9689f281697a@mail.gmail.com> References: <23def8000802112053i70dec636kadb9ec56b13772f0@mail.gmail.com> <23def8000802120821u79dd458vbe0d9689f281697a@mail.gmail.com> Message-ID: <944da41d0802130053s67119d5ewc75de9bff40ccfa0@mail.gmail.com> My guess would be that 332 is not a valid value for a byte :) 2008/2/12 Dustin Whitney : > Yeah, that worked thanks! I had tried what you did, but it did not work > with the UTF-32 data. Do you know why? And how do you suppose my data was > turned into UTF-32. I got the data originally from an HTTP GET request that > returned a UTF-8 encoded XML file. The file its self says it's UTF-8, and > the header tuple said the document was using the UTF-8 charset. Does Erlang > convert the data automatically? > Thanks! > -Dustin > > > On Feb 12, 2008 2:59 AM, Hasan Veldstra wrote: > > > > > > How can I write [332,116,97,44,32,71,117,110,109,97] to a file so > > > that when I open it up it looks like "?ta, Gunma"? > > > > > > -module(ftest). > > -export([run/0]). > > > > run() -> > > Data = [197,140,116,97,44,32,71,117,110,109,97], > > file:write_file("ftest.txt", list_to_binary(Data)). > > > > > > Text is just numbers when stored to disk. > > > > By the way, the list of numbers you originally posted is "?ta, Gunma" > > encoded in UTF-32, not UTF-8. It's in UTF-8 in my example. > > > > Hope this helps. > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080213/23c46f9c/attachment.html From j.bhanot Wed Feb 13 10:10:13 2008 From: j.bhanot (J Bhanot) Date: Wed, 13 Feb 2008 14:40:13 +0530 Subject: [erlang-questions] MG MGC comm Message-ID: Hi, My MG is an external entity which can send messages on a particular port.. Now i want my MGC application(based upon OTP stack) to listen to these messages and forward these to C node which will give the response back to MGC based upon a config file and thereon MGC will send the same response on a particular port(on which MG is listening)...... Question for this approach is: 1. Can I make MGC listen on a particular port and then recieve messages from MG(external entity) . another way of doing it is...... MG sends the messages to C node and C node directly communicates with Stack using erl_interface...based upon that plays with messages and send the response back to MG.... Is it possible first of all........ Thanking in anticipation... Regards, jb____________________________________________ =====-----=====-----===== Notice: The information contained in this e-mail message and/or attachments to it may contain confidential or privileged information. If you are not the intended recipient, any dissemination, use, review, distribution, printing or copying of the information contained in this e-mail message and/or attachments to it are strictly prohibited. If you have received this communication in error, please notify us by reply e-mail or telephone and immediately and permanently delete the message and any attachments. Thank you -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080213/b0bc7bc8/attachment.html From j.bhanot Wed Feb 13 10:29:24 2008 From: j.bhanot (J Bhanot) Date: Wed, 13 Feb 2008 14:59:24 +0530 Subject: [erlang-questions] Service Change request in C node In-Reply-To: Message-ID: Hi, I have tried using erl_iolist_to_string(list) but returns null and also it expects an IO list but i guess I have a simple list ...thats why it is returning NULL.. Regards, jb =====-----=====-----===== Notice: The information contained in this e-mail message and/or attachments to it may contain confidential or privileged information. If you are not the intended recipient, any dissemination, use, review, distribution, printing or copying of the information contained in this e-mail message and/or attachments to it are strictly prohibited. If you have received this communication in error, please notify us by reply e-mail or telephone and immediately and permanently delete the message and any attachments. Thank you -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080213/1a1eed10/attachment.html From chsu79 Wed Feb 13 14:57:03 2008 From: chsu79 (Christian S) Date: Wed, 13 Feb 2008 14:57:03 +0100 Subject: [erlang-questions] Strings as Lists In-Reply-To: <15448906.post@talk.nabble.com> References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> <2F5E96D5-CF7A-42AC-B04E-CB8183F7AB7D@masklinn.net> <15448906.post@talk.nabble.com> Message-ID: On Feb 13, 2008 5:00 AM, Zvi wrote: > Still there is a need for standard string datatype, which will be good for > 90% of uses and it should be accepted by all standard libs. If you ask me, that is string(). It is good for the majority of uses. > * <<"ABC">>, instead of "ABC" Yes, this is a bit annoying to type. I'm not the biggest fan of the syntactical appearance of binary comprehensions either. I have been pondering the use of LEFT and RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK in latin1 as shorthand for <<"">>. Of course, I realize that ~99,8% (everyone but me :) of all erlang users dont want non-ascii characters in the syntax, even though Erlang source code is specified to be in latin1. > * <> instead of S1++S2 [S1,S2] and then do iolist_to_binary/1 if you need it flat. > * using file:delete(binary_to_list(Filename)) instead of > file:delete(Filename) Why handle filenames as binaries? > > - list of words and a word-dictionary (features quicker scanning of > > ...words, efficient storage too) > I want to implement something like this, but using atoms for words. Is this > a good idea? [snip] Go with your own dictionary and word ids. Erlang handles small integers as fixnums so they're as efficient to compare as atoms. If you have an a-priori known dictionary then you can of course map to atoms. > How Ragel is better, than other lexical analysers? Do you use it primarily > because it's parsing binary input, why Erlang leexer working with lists? Leex is very cool and I have been playing with it some. It generates erlang code which is good. I mostly see it as the solution for parsing files. I want non-greedy matching, and also some push down automata support. Ragel can do this. With it you can parse quoted strings as a single token, and still have incremental parsing (i.e. in chunks). The fact that you generate C code from Ragel can also be beneficial in speed but of course risky. The higher-level programming of using Ragel can hopefully decrease risk of security problems. I'm really just experimenting with Ragel as a tool. I still suck at it after having spent ~6 hours or so with it. From chsu79 Wed Feb 13 15:05:03 2008 From: chsu79 (Christian S) Date: Wed, 13 Feb 2008 15:05:03 +0100 Subject: [erlang-questions] Strings as Lists In-Reply-To: <4d08db370802122236r66e1add9j54440b547987f959@mail.gmail.com> References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> <2F5E96D5-CF7A-42AC-B04E-CB8183F7AB7D@masklinn.net> <15448906.post@talk.nabble.com> <4d08db370802122236r66e1add9j54440b547987f959@mail.gmail.com> Message-ID: 2008/2/13 Hynek Vychodil : > You can do it only because ISO-8859-1 is enough for you. Your code will be > crap for me, because I would not use it! One char not equal to one byte, > remeber it! List is best solution for all non english world, because one > list element equals to one char. If you want make onelingual programs, > continue in your practise. God save you. Well you really should take strings out of source code if you need i18n. The litterals one can keep in source code are those for protocol framing... say the "HTTP 200 OK" reply in http or "EHLO fqdn" in smtp. Nobody would love lots of case Lang of en -> <<"Hello">>; sv -> <<"Hej">>; es -> <<"Hola">> end in the code. Once you go i18n(hello) you can treat everything as utf8 encoded binaries and just piece it together. From masterofquestions Wed Feb 13 16:50:32 2008 From: masterofquestions (db) Date: Wed, 13 Feb 2008 10:50:32 -0500 Subject: [erlang-questions] erlang automake vpath build ebin folder Message-ID: <1218d6a50802130750o1d4d1e02qedb07b3218c81c8@mail.gmail.com> When I do vpath build in automake_test/tmp/build, what I get is that beam file is placed into tmp/build/src/ folder, not into tmp/build/ebin/. What I like to see is to have ebin folder in vpath build directory and have the automake_test.beam file in ebin, like so tmp/build/ebin/automake_test.beam. When I also do build(src build) in main root directory "automake_test", what I get is that beam file placed into the automake_test/src/automake_test.beam rather than into automake_test/ebin/automake_test.beam. With the configure.ac, Makefile.am, src/Makefile.am, I was able to install of erlang app into /usr/local/erlang/otp_r12b-0/lib/erlang/lib, check for prerequisite erlang libraries (mnesia, etc) and have automake_test.beam file installed into /usr/local/erlang/otp_r12b-0/lib/erlang/lib/automake_test/ebin folder. I would like have ebin folder populated with compiled beam files when performaing regular build on the same source directory or when on separate build directory (VPATH builds). Anyone knows how to do this? My simple app folder structure: automake_test ->ebin/ ->src/ ->automake_test.erl ->Makefile.am ->tmp/ ->build/ ->Makefile.am ->configure.ac ================ automake_test/configure.ac: AC_INIT(Some test application, 0.1, address, someapp) dnl Require autoconf version >=2.59c. AC_PREREQ(2.59c) AC_COPYRIGHT(Copyright (C) 2006 tester) AC_REVISION($Id$) dnl Require automake version >=1.9.5. AM_INIT_AUTOMAKE(1.9.5) AC_ERLANG_NEED_ERLC AC_ERLANG_SUBST_ROOT_DIR AC_ERLANG_SUBST_LIB_DIR dnl Check for standard Erlang/OTP libraries. AC_ERLANG_CHECK_LIB([edoc]) AC_ERLANG_CHECK_LIB([os_mon]) AC_ERLANG_CHECK_LIB([mnesia]) dnl Determine directories for installation. AC_ERLANG_SUBST_INSTALL_LIB_DIR AC_ERLANG_SUBST_INSTALL_LIB_SUBDIR(automake_test, 0.1) dnl Specify the files to instantiate. AC_CONFIG_FILES([ \ Makefile \ src/Makefile \ ]) AC_OUTPUT ================== automake_test/Makefile.am: SUBDIRS = src ================== automake_test/src/Makefile.am: erlsrcdir = $(ERLANG_INSTALL_LIB_DIR_automake_test)/src erlsrc_DATA = automake_test.erl EXTRA_DIST = $(erlsrc_DATA) erlbeamdir = $(ERLANG_INSTALL_LIB_DIR_automake_test)/ebin erlbeam_DATA = automake_test.beam CLEANFILES = $(erlbeam_DATA) SUFFIXES = .erl .beam .erl.beam: $(ERLC) $(ERLCFLAGS) -b beam $< ================= -- rk -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080213/667a45f0/attachment.html From theczintheroc2007 Wed Feb 13 17:22:26 2008 From: theczintheroc2007 (Colin Z) Date: Wed, 13 Feb 2008 11:22:26 -0500 Subject: [erlang-questions] SMP Scheduler Implementation Message-ID: Are there any resources out there that explain how the SMP scheduling system works? In the simplest case, I'm curious about how the runtime manages two schedulers running on two cores/CPUs. Imagine we have three processes running in two schedulers such that process A and B are in Scheduler1 and process C is in Scheduler2 and each scheduler is running on a separate core. What happens if B and C send messages to A simultaneously? Is traditional synchronization of A's mailbox being done under the hood, or is cross-scheduler message passing simply not allowed? Another similar case would be when A is in a receive block processing the contents of its mailbox when C sends it a new message at the same time. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080213/dd69bbf8/attachment.html From masterofquestions Wed Feb 13 18:48:53 2008 From: masterofquestions (db) Date: Wed, 13 Feb 2008 09:48:53 -0800 (PST) Subject: [erlang-questions] erlang automake and autogenerate erlang otp files In-Reply-To: <5357e5f5-cad0-40a4-9cc5-ef5990d61eb6@v17g2000hsa.googlegroups.com> References: <5357e5f5-cad0-40a4-9cc5-ef5990d61eb6@v17g2000hsa.googlegroups.com> Message-ID: I will answer my own questions: > In addition, I know that .app file goes into /ebin folder. Where do > you place the other files that get autogenerated by builder? Builder generates these files and places them into priv folder. priv folder is created if it is not present. You can also pass the path to folder where you want to put .boot, .load, .rel, .script files if you don't like the default priv folder. .app file is automatically placed into ebin folder by builder. Builder is run from the root folder of the application and it determines the version number from the root folder. > Automake installs my erlang application into /usr/local/lib/erlang/ > lib. But I have my erlang lib folders in /usr/local/erlang/otp_r12b-0/ > lib/erlang/lib. My erlang root is: /usr/local/erlang/otp_r12b-0 and > automake does perform valid erlang lib check for mnesia. But it can > not deduce the right erlang lib folders during install. Why is this > discrepancy? Automake default install location is /usr/local. You need to add -- prefix=_your_path. From tsuraan Wed Feb 13 20:18:10 2008 From: tsuraan (tsuraan) Date: Wed, 13 Feb 2008 13:18:10 -0600 Subject: [erlang-questions] Strings as Lists In-Reply-To: <4d08db370802122236r66e1add9j54440b547987f959@mail.gmail.com> References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> <2F5E96D5-CF7A-42AC-B04E-CB8183F7AB7D@masklinn.net> <15448906.post@talk.nabble.com> <4d08db370802122236r66e1add9j54440b547987f959@mail.gmail.com> Message-ID: <84fb38e30802131118u11a5f76crd42621a5f6e1c32e@mail.gmail.com> Still there is a need for standard string datatype, which will be good for 90% of uses and it should be accepted by all standard libs. I reperesent strings as binaries, and my code become much more verbose (almost unreadable), i.e using: * <<"ABC">>, instead of "ABC" > > > You can do it only because ISO-8859-1 is enough for you. Your code will be > crap for me, because I would not use it! One char not equal to one byte, > remeber it! List is best solution for all non english world, because one > list element equals to one char. If you want make onelingual programs, > continue in your practise. God save you. > So in erlang, if you type a string literal that is (e.g .) japanese, does it create a list of the utf-32 codepoints of the string you wrote? I'd try it, but I don't trust my computer's i18n support enough to trust the results of any test I could do. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080213/48ec9dce/attachment.html From chsu79 Wed Feb 13 20:54:49 2008 From: chsu79 (Christian S) Date: Wed, 13 Feb 2008 20:54:49 +0100 Subject: [erlang-questions] Strings as Lists In-Reply-To: <84fb38e30802131118u11a5f76crd42621a5f6e1c32e@mail.gmail.com> References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> <2F5E96D5-CF7A-42AC-B04E-CB8183F7AB7D@masklinn.net> <15448906.post@talk.nabble.com> <4d08db370802122236r66e1add9j54440b547987f959@mail.gmail.com> <84fb38e30802131118u11a5f76crd42621a5f6e1c32e@mail.gmail.com> Message-ID: 2008/2/13 tsuraan : > So in erlang, if you type a string literal that is (e.g.) japanese, does it > create a list of the utf-32 codepoints of the string you wrote? I'd try it, > but I don't trust my computer's i18n support enough to trust the results of > any test I could do. The tokenizer expects latin1 input: http://erlang.org/doc/reference_manual/introduction.html#1.6 Of course, if you put utf8 encoded data into your strings it will happily create interpret your latin "?" as [$?, $?] or whatever sequence the ? utf8-encoded looks like as when viewed as latin1. The list [195,132] is what shows up if i enter it using my utf8 xterm. Didn't the list have a long thread about io character encodings a couple years ago? Or am I mixing it up with the with character encoding issues in common lisp's io system? There is some issues that show up if you write an alternative lexer that decodes utf8 into Unicode character points in lists, such as list_to_binary() expecting a string() type and choking if there is an integer above 255. This must be what the list had a thread about. The need for unicode_list_to_utf8_binary/1 and a dozen others target encodings. From vances Wed Feb 13 21:05:14 2008 From: vances (Vance Shipley) Date: Wed, 13 Feb 2008 15:05:14 -0500 Subject: [erlang-questions] Strings as Lists In-Reply-To: References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> <2F5E96D5-CF7A-42AC-B04E-CB8183F7AB7D@masklinn.net> <15448906.post@talk.nabble.com> <4d08db370802122236r66e1add9j54440b547987f959@mail.gmail.com> <84fb38e30802131118u11a5f76crd42621a5f6e1c32e@mail.gmail.com> Message-ID: <20080213200513.GE571@h216-235-12-173.host.egate.net> On Wed, Feb 13, 2008 at 08:54:49PM +0100, Christian S wrote: } The tokenizer expects latin1 input: And yet we see so few programs written in Swedish. :) -vVnce From rvirding Wed Feb 13 23:44:21 2008 From: rvirding (Robert Virding) Date: Wed, 13 Feb 2008 23:44:21 +0100 Subject: [erlang-questions] UTF8 In-Reply-To: <944da41d0802130053s67119d5ewc75de9bff40ccfa0@mail.gmail.com> References: <23def8000802112053i70dec636kadb9ec56b13772f0@mail.gmail.com> <23def8000802120821u79dd458vbe0d9689f281697a@mail.gmail.com> <944da41d0802130053s67119d5ewc75de9bff40ccfa0@mail.gmail.com> Message-ID: <3dbc6d1c0802131444u2816a661oac7e1c4520b86e59@mail.gmail.com> It is if they had kept of the old 9-bit bytes (characters) from DEC-10 days. In those days you also had a real ctrl-key which set the 9th bit. :-) Robert On 13/02/2008, Alex Arnon wrote: > > My guess would be that 332 is not a valid value for a byte :) > > 2008/2/12 Dustin Whitney : > > > Yeah, that worked thanks! I had tried what you did, but it did not work > > with the UTF-32 data. Do you know why? And how do you suppose my data was > > turned into UTF-32. I got the data originally from an HTTP GET request that > > returned a UTF-8 encoded XML file. The file its self says it's UTF-8, and > > the header tuple said the document was using the UTF-8 charset. Does Erlang > > convert the data automatically? > > Thanks! > > -Dustin > > > > > > On Feb 12, 2008 2:59 AM, Hasan Veldstra > > wrote: > > > > > > > > > How can I write [332,116,97,44,32,71,117,110,109,97] to a file so > > > > that when I open it up it looks like "?ta, Gunma"? > > > > > > > > > -module(ftest). > > > -export([run/0]). > > > > > > run() -> > > > Data = [197,140,116,97,44,32,71,117,110,109,97], > > > file:write_file("ftest.txt", list_to_binary(Data)). > > > > > > > > > Text is just numbers when stored to disk. > > > > > > By the way, the list of numbers you originally posted is "?ta, Gunma" > > > encoded in UTF-32, not UTF-8. It's in UTF-8 in my example. > > > > > > Hope this helps. > > > > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080213/37a2ecb2/attachment.html From rvirding Thu Feb 14 00:25:42 2008 From: rvirding (Robert Virding) Date: Thu, 14 Feb 2008 00:25:42 +0100 Subject: [erlang-questions] Strings as Lists In-Reply-To: References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> <2F5E96D5-CF7A-42AC-B04E-CB8183F7AB7D@masklinn.net> <15448906.post@talk.nabble.com> Message-ID: <3dbc6d1c0802131525v28afff23rb78e3673cd9a994@mail.gmail.com> On 13/02/2008, Christian S wrote: > > On Feb 13, 2008 5:00 AM, Zvi wrote: > > How Ragel is better, than other lexical analysers? Do you use it > primarily > > because it's parsing binary input, why Erlang leexer working with lists? > > Leex is very cool and I have been playing with it some. It generates > erlang code which is good. I mostly see it as the solution for parsing > files. Leex works anything, it assumes the input is a list of integers. However when building the DFA for generating the scanner it assumes 8 bit input. :-( This, however, is not critical and I have code which would work on *any* input characters. :-) It would then be able to handle any characters in the leex .xrl file if you could write the (32-bit) characters and read them in as a list of integers. Once you get the file into a list you could probably get it into the Erlang scanner without to much trouble. Just as long you were a little careful. As I said lists *are* wonderful for representing strings. As an aside I can mention that a new regexp package I have does work directly on binaries. But, much more fun, it also works on lists of anything, not just integers. So you can define regexps that work on lists of atoms or tuples or whatever. Do that with UTF-8! :-) Robert I want non-greedy matching, and also some push down automata support. > Ragel can do this. With it you can parse quoted strings as a single > token, and still have incremental parsing (i.e. in chunks). The fact > that you generate C code from Ragel can also be beneficial in speed > but of course risky. The higher-level programming of using Ragel can > hopefully decrease risk of security problems. Non-greedy is a bit difficult to do if you compile down to pure code like leex (or lex) but if you do it by interpreting a datastructure then it is not hard. I'm really just experimenting with Ragel as a tool. I still suck at it > after having spent ~6 hours or so with it. Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080214/4d9d2d49/attachment.html From rvirding Thu Feb 14 00:42:29 2008 From: rvirding (Robert Virding) Date: Thu, 14 Feb 2008 00:42:29 +0100 Subject: [erlang-questions] Erlounge in San Francisco, 17-22 February In-Reply-To: <2FAE4954-2162-4B22-A1D4-CD6D88F736F0@ketralnis.com> References: <3dbc6d1c0801190827l11ac1050yae37415a0e565270@mail.gmail.com> <3dbc6d1c0802011452v20c7df1fu966a326e8ed87e8b@mail.gmail.com> <76F389D3-F029-4EC3-9037-3D24B9ED6D15@gerakines.net> <3dbc6d1c0802071353v2873419x88587f630da567ac@mail.gmail.com> <3dbc6d1c0802121413o206a516ej1a9d328b3bf79d16@mail.gmail.com> <2FAE4954-2162-4B22-A1D4-CD6D88F736F0@ketralnis.com> Message-ID: <3dbc6d1c0802131542p4537805erca28764d804c9f0e@mail.gmail.com> Reddit offices on 3rd St?* That suits me fine. We could meet there and maybe go on for beer, for example to the 21st Amendment Brewery which is close. 7.30 pm suit everyone? Robert *Google Earth is wonderful. Actually there is no end of fantastic things you can do with it. On 13/02/2008, David King wrote: > > > Ok, now we just need some place to meet. Suggestions please. > > Reddit is willing to use their office in SoMa near Moscone for an > Erlang meetup > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080214/5b6003ce/attachment.html From chsu79 Thu Feb 14 01:09:39 2008 From: chsu79 (Christian S) Date: Thu, 14 Feb 2008 01:09:39 +0100 Subject: [erlang-questions] Strings as Lists In-Reply-To: <3dbc6d1c0802131525v28afff23rb78e3673cd9a994@mail.gmail.com> References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> <2F5E96D5-CF7A-42AC-B04E-CB8183F7AB7D@masklinn.net> <15448906.post@talk.nabble.com> <3dbc6d1c0802131525v28afff23rb78e3673cd9a994@mail.gmail.com> Message-ID: > > Leex is very cool and I have been playing with it some. It generates > > erlang code which is good. I mostly see it as the solution for parsing > > files. > > Leex works anything, it assumes the input is a list of integers. Oh sure, but with a state-stack one can suddenly parse more than regular grammars. Parsing a quoted string as a token from leex is difficult if you know that the end-quote might not be included in the chunk you just fed into leex, but the next chunk read from the tcp stream. With fully recursive grammars I can see how one wants to let yecc handle it, but a quoted string is not really recursive: You cant have a quoted string inside a quoted string the same way you can have, say, an if-expression inside an if-expression inside an if-expression etc in a programming language. Leex is a tool I would use for when I know I have some file of finite length and I could do a two-pass parsing with yecc as the second stage, I would not use it for tokenizing SMTP/IRC/NNTP... I'm looking for a better tool (as in quicker and easier code to maintain/extend) than writing protocol parsing "by hand". PS. I reserve the right to be completly mistaken about everything. From ok Thu Feb 14 02:28:38 2008 From: ok (Richard A. O'Keefe) Date: Thu, 14 Feb 2008 14:28:38 +1300 Subject: [erlang-questions] Strings as Lists In-Reply-To: References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> <2F5E96D5-CF7A-42AC-B04E-CB8183F7AB7D@masklinn.net> Message-ID: <89759538-180F-44E6-BD70-70EA32EF6DDA@cs.otago.ac.nz> On 13 Feb 2008, at 7:21 am, Christian S wrote: > That is the reason. Hysterical Raisins. > > There was a time when Erlang didn't have binaries. There was a time when Erlang didn't have _anything_, but that's almost surely not the reason. > Someone thought it > would be a good idea to make "ABC" a way to write [65,66,67]. Don't forget, Erlang was heavily influenced by Prolog and Strand84. If memory serves me correctly, the original prototype implementation was done in Prolog, and the Prolog reader has read "ABC" as [65,66,67] since the late 1970s at least. It's not Hysterical Raisins at all: it is simplicity (the preferred sequence type in Erlang is lists, and strings are just sequences of characters), power (because any time someone defines a function on lists you get to use it on strings, and there are *lots* of useful list functions), and processing efficiency (because working down one character at a time doesn't require allocating *any* new storage, not even for slices). ByteStrings were added to Haskell (actually in two flavours) to support high volume I/O. One of the reasons they've seen a lot of acceptance is that various people have gone to a lot of trouble to make them LOOK as much like lists as possible. Thanks to Haskell's typeclass machinery, that can be "very much indeed" (see the ListLike package, the use of which means that you can continue to write code that works on lists *or* strings). The one thing that bytestrings aren't much good for these days, of course, is holding *decoded* characters. It's important to realise that in ANY programming language there is more than one way to represent strings. For example, even for character=byte there are three different representations supported in C89, and C89 programs often had to deal with a fourth. You don't *have* to stick with the one that the compiler translates "ABC" to. From ok Thu Feb 14 02:14:56 2008 From: ok (Richard A. O'Keefe) Date: Thu, 14 Feb 2008 14:14:56 +1300 Subject: [erlang-questions] Strings as Lists In-Reply-To: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> Message-ID: <0EA68804-E7BB-477A-9351-677188540F48@cs.otago.ac.nz> On 13 Feb 2008, at 5:19 am, tsuraan wrote: > Why does erlang internally represent strings as lists? In every > language I've used other than Java, a string is a sequence of > octets, just like Erlang's binary type. Recall the programming proverb: it is better to have one data type with 100 functions than 10 data types with 10 functions each. It is actually quite commonplace in declarative languages (Prolog, Mercury, Haskell, some others) to implement strings as lists of characters because that way you get a vast number of functions you can usefully apply to strings. Not only that, you can process strings *incrementally* if they are lists. I never tire of telling this story: I was on the team that ported Quintus Prolog from the "UNIX" world to the Xerox Lisp machines (the 1108, 1109, 1185, and 1186, aka Dandelion, Dandetiger, Daybreak, and something else I forget). These machines compiled Interlisp to bytecode which was then executed by microcode, and gave very respectable performance for Lisp, in their day. The existing microcode supported Interlisp strings, which were byte vectors as you describe. There wasn't much microcode space left to support Quintus Prolog, so we had a microcoded WAM with plain old 2 word list cells and strings represented by 1 list cell per character. A series of benchmarks I did showed string processing going FIVE TIMES FASTER in Prolog using lists than in Lisp using byte vectors, largely because we could represent "the rest of a string" using NO new allocations whatever. The Java string representation is (slice of (array of uint16_t)) which means that "the rest of a string" costs only O(1) time and space, but O(1) extra space isn't O(0) extra space. I would expect most Javascript implementations to use something similar to this. The guiding rule is - if you just want to hold onto a string for a while, use a binary - if you want to build or process a string, use a list (possibly in Erlang a deep list). - if you want to represent something that has structure, and you want your program to be aware of that structure, turn it into a structured data value and work with it in that form. Basically, most languages get strings embarassingly wrong. Another story I like to tell is how I was able to do in 10 pages of C what a friend of mine needed 150 pages of PL/I to accomplish, largely because PL/I *does* have a "real" string data type and C doesn't, so I could accomplish what I needed very simply, while he had to fight the language every step of the way. From ok Thu Feb 14 04:49:44 2008 From: ok (Richard A. O'Keefe) Date: Thu, 14 Feb 2008 16:49:44 +1300 Subject: [erlang-questions] Strings as Lists In-Reply-To: <14EEE3D7-56F1-470A-BCE5-C5B534A6EF88@scaldeferri.com> References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> <2F5E96D5-CF7A-42AC-B04E-CB8183F7AB7D@masklinn.net> <3dbc6d1c0802121413o7480d2abtc913801ceae67e8e@mail.gmail.com> <14EEE3D7-56F1-470A-BCE5-C5B534A6EF88@scaldeferri.com> Message-ID: <972E01DC-2A4D-4EB8-B483-CFD98AB6E87F@cs.otago.ac.nz> On 13 Feb 2008, at 12:41 pm, Kevin Scaldeferri wrote: > Hold on... lists aren't really a particular convenient or efficient > data structure for working with strings. For some people they are. > First off, I append to > strings a lot more than I prepend to them. I take this to mean that you do stuff like S0 = ~0~, S1 = S0 ++ ~1~, ... Sn = Sn_1 ++ ~n~ perhaps in a loop. Right, this is not efficient. But it is spectacularly inefficient in programming languages with more conventional representations. It is O(n**2). For example, x = "" for (i = 1; i <= 100000; i++) x = x "a" just took 30.5 seconds in awk on my machine, 62.2 seconds in Perl, and a massive 631 seconds in Java. That was using gcj; I lost patience with the Sun SDK and killed it. (AWK faster than Java? Yes, it often is.) Building the same string in Erlang using loop(100000, "") where loop(0, S) -> lists:reverse(S); loop(N, S) -> loop(N-1, "a"++S). takes 0.15 second on the same machine. > Yeah, I could work with > reversed strings, but that's a hack to deal with using the wrong data > type. No, it has to do with the fact that appending on the right is O(n) whether one uses lists or arrays. Arguably, you should be using the right data type THE RIGHT WAY. Can you provide an example of your code? Alternatively, maybe iolists would suit you better: loop(0, S) -> lists:flatten(S); loop(N, S) -> loop(N-1, [S|"a"]). also takes 0.15 second, and is appending on the right. It's quite a general principle that the data structure or traversal that is convenient for building something up isn't necessarily the same as the data structure or traversal that is convenient for processing it afterwards; > Plus, I probably prefix match more often than suffix matching > (although this is less lopsided than append vs. prepend). Of course, > I also like to do substring matching and regular expressions quite a > bit, and Boyer-Moore is definitely more efficient with arrays than > lists. The Boyer-Moore algorithm requires space proportional to the alphabet size. The Unicode alphabet size is enormous (last time I looked there were nearly 100 000 characters defined). Unicode substring matching is definitely nasty, given that, for example, you would like (e,floating acute) to match ?, and the Boyer-Moore algorithm assumes a unique encoding of any given string, which Unicode does not even begin to have. Then there are fun things like U+0028 is the code for the "(" character, but if I see a "(" and go looking for it, I might have to look for a U+0029 instead, and there really doesn't seem to be any way of dealing with that without processing a bunch of control characters. (I know I am talking about appearance here, not semantics, but sometimes one wants to search based on appearance.) > > It's probably worth noting that none of the languages which are > considered _good_ for working with strings (AFAIK) use a list > representation. Not really. Perl is normally "considered _good_ for working with strings", but it is pretty much hopeless at building strings by concatenation. (Yes, I know about StringBuffer and StringBuilder, but they are DIFFERENT from String. The only language I know that's really good at it is Smalltalk, where you can do result := String writeStream: [:s | "any code you want, writing to the character stream s"]. and the internal representation of the intermediate result is none of your business. From ok Thu Feb 14 05:02:30 2008 From: ok (Richard A.O'Keefe) Date: Thu, 14 Feb 2008 17:02:30 +1300 Subject: [erlang-questions] Strings as Lists In-Reply-To: <14EEE3D7-56F1-470A-BCE5-C5B534A6EF88@scaldeferri.com> References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> <2F5E96D5-CF7A-42AC-B04E-CB8183F7AB7D@masklinn.net> <3dbc6d1c0802121413o7480d2abtc913801ceae67e8e@mail.gmail.com> <14EEE3D7-56F1-470A-BCE5-C5B534A6EF88@scaldeferri.com> Message-ID: <924E1C4E-0029-4EF7-92CD-54AD78B6345B@cs.otago.ac.nz> On 13 Feb 2008, at 12:41 pm, Kevin Scaldeferri wrote: > Hold on... lists aren't really a particular convenient or efficient > data structure for working with strings. For some people they are. > First off, I append to > strings a lot more than I prepend to them. I take this to mean that you do stuff like S0 = ~0~, S1 = S0 ++ ~1~, ... Sn = Sn_1 ++ ~n~ perhaps in a loop. Right, this is not efficient. But it is spectacularly inefficient in programming languages with more conventional representations. It is O(n**2). For example, x = "" for (i = 1; i <= 100000; i++) x = x "a" just took 30.5 seconds in awk on my machine, 62.2 seconds in Perl, and a massive 631 seconds in Java. That was using gcj; I lost patience with the Sun SDK and killed it. (AWK faster than Java? Yes, it often is.) Building the same string in Erlang using loop(100000, "") where loop(0, S) -> lists:reverse(S); loop(N, S) -> loop(N-1, "a"++S). takes 0.15 second on the same machine. > Yeah, I could work with > reversed strings, but that's a hack to deal with using the wrong data > type. No, it has to do with the fact that appending on the right is O(n) whether one uses lists or arrays. Arguably, you should be using the right data type THE RIGHT WAY. Can you provide an example of your code? Alternatively, maybe iolists would suit you better: loop(0, S) -> lists:flatten(S); loop(N, S) -> loop(N-1, [S|"a"]). also takes 0.15 second, and is appending on the right. It's quite a general principle that the data structure or traversal that is convenient for building something up isn't necessarily the same as the data structure or traversal that is convenient for processing it afterwards; > Plus, I probably prefix match more often than suffix matching > (although this is less lopsided than append vs. prepend). Of course, > I also like to do substring matching and regular expressions quite a > bit, and Boyer-Moore is definitely more efficient with arrays than > lists. The Boyer-Moore algorithm requires space proportional to the alphabet size. The Unicode alphabet size is enormous (last time I looked there were nearly 100 000 characters defined). Unicode substring matching is definitely nasty, given that, for example, you would like (e,floating acute) to match ?, and the Boyer-Moore algorithm assumes a unique encoding of any given string, which Unicode does not even begin to have. Then there are fun things like U+0028 is the code for the "(" character, but if I see a "(" and go looking for it, I might have to look for a U+0029 instead, and there really doesn't seem to be any way of dealing with that without processing a bunch of control characters. (I know I am talking about appearance here, not semantics, but sometimes one wants to search based on appearance.) > > It's probably worth noting that none of the languages which are > considered _good_ for working with strings (AFAIK) use a list > representation. Not really. Perl is normally "considered _good_ for working with strings", but it is pretty much hopeless at building strings by concatenation. The only language I know that's really good at it is Smalltalk, where you can do result := String writeStream: [:s | "any code you want, writing to the character stream s"]. and the internal representation of the intermediate result is none of your business. There are also libraries from the functional programming world that give you efficient incremental update of large strings, but they are fairly heavyweight. From exta7 Thu Feb 14 07:07:52 2008 From: exta7 (Zvi) Date: Wed, 13 Feb 2008 22:07:52 -0800 (PST) Subject: [erlang-questions] Strings as Lists In-Reply-To: <0EA68804-E7BB-477A-9351-677188540F48@cs.otago.ac.nz> References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> <0EA68804-E7BB-477A-9351-677188540F48@cs.otago.ac.nz> Message-ID: <15474643.post@talk.nabble.com> Richard, I think you confusing datatype with it's implementation/representation. My biggest problem with Erlang standard string representation is that in 64bit mode, each character taking 16 bytes. So typical message of 10KB after converted to XML become 20KB and after parsed by 64bit Erlang VM become 320KB. I talking about server-side code, so I need 320KB-per-client. Using binary, even if I copy this XML 3 times in memory, I still can handle 5-6 times more clients. Also, you forget that what was good for LISP Machines is not good for current machine architectures. Binary strings can be handled very efficiently using vectorized SIMD code and they use modern caches much more effectively, than lists. Deep lists and io-lists are essentially analog of Java's StringBuffer or C++ STL's ostringstream. io-lists can also be more efficient fo IO, if underlying OS has gather-write system call. So in general I want immutable String ADT. The ADT implementation should be smart enough, to switch to the best representation, according to usage. Similar to some languages, which implement associative arrays ADT using various datastructures, i.e. property lists for small arrays and hashtables for large. Or I can give hints which implementation of String ADT I want to use (using for example parametrized modules), i.e. string(deepList):concat(S1,S2) or string(binarySlice):substr(S,1,3). BTW: most sophisticated string implementation I know about was in SNOBOL. I think it was list of unique substrings. Zvi Richard A. O'Keefe wrote: > > On 13 Feb 2008, at 5:19 am, tsuraan wrote: > >> Why does erlang internally represent strings as lists? In every >> language I've used other than Java, a string is a sequence of >> octets, just like Erlang's binary type. > > Recall the programming proverb: > it is better to have one data type with 100 functions > than 10 data types with 10 functions each. > > It is actually quite commonplace in declarative languages (Prolog, > Mercury, > Haskell, some others) to implement strings as lists of characters > because > that way you get a vast number of functions you can usefully apply to > strings. > Not only that, you can process strings *incrementally* if they are > lists. > > I never tire of telling this story: > I was on the team that ported Quintus Prolog from the "UNIX" world > to the Xerox Lisp machines (the 1108, 1109, 1185, and 1186, aka > Dandelion, Dandetiger, Daybreak, and something else I forget). > These machines compiled Interlisp to bytecode which was then > executed by microcode, and gave very respectable performance for > Lisp, in their day. The existing microcode supported Interlisp > strings, which were byte vectors as you describe. > > There wasn't much microcode space left to support Quintus Prolog, > so we had a microcoded WAM with plain old 2 word list cells and > strings represented by 1 list cell per character. > > A series of benchmarks I did showed string processing going > FIVE TIMES FASTER in Prolog using lists than in Lisp using byte > vectors, largely because we could represent "the rest of a string" > using NO new allocations whatever. > > The Java string representation is (slice of (array of uint16_t)) > which means > that "the rest of a string" costs only O(1) time and space, but O(1) > extra > space isn't O(0) extra space. I would expect most Javascript > implementations > to use something similar to this. > > The guiding rule is > - if you just want to hold onto a string for a while, use a binary > - if you want to build or process a string, use a list (possibly in > Erlang a deep list). > - if you want to represent something that has structure, and you want > your program to be aware of that structure, turn it into a > structured > data value and work with it in that form. > > Basically, most languages get strings embarassingly wrong. Another > story > I like to tell is how I was able to do in 10 pages of C what a friend of > mine needed 150 pages of PL/I to accomplish, largely because PL/I *does* > have a "real" string data type and C doesn't, so I could accomplish what > I needed very simply, while he had to fight the language every step > of the > way. > > > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > > -- View this message in context: http://www.nabble.com/Strings-as-Lists-tp15436835p15474643.html Sent from the Erlang Questions mailing list archive at Nabble.com. From qrilka Thu Feb 14 08:01:18 2008 From: qrilka (Kirill Zaborski) Date: Thu, 14 Feb 2008 10:01:18 +0300 Subject: [erlang-questions] Strings as Lists In-Reply-To: <89759538-180F-44E6-BD70-70EA32EF6DDA@cs.otago.ac.nz> References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> <2F5E96D5-CF7A-42AC-B04E-CB8183F7AB7D@masklinn.net> <89759538-180F-44E6-BD70-70EA32EF6DDA@cs.otago.ac.nz> Message-ID: <337538cb0802132301k5b2d502fy36c19c6895c0dd4c@mail.gmail.com> Richard, is there any information available about Strand84? Search returns no meaningful answers. I presume it is some programming language (from year 1984? or some connection to Orwell's book? :) ). Am I right? Best regards, Kirill On Thu, Feb 14, 2008 at 4:28 AM, Richard A. O'Keefe wrote: > > On 13 Feb 2008, at 7:21 am, Christian S wrote: > > That is the reason. Hysterical Raisins. > > > > There was a time when Erlang didn't have binaries. > > There was a time when Erlang didn't have _anything_, > but that's almost surely not the reason. > > > Someone thought it > > would be a good idea to make "ABC" a way to write [65,66,67]. > > Don't forget, Erlang was heavily influenced by Prolog and Strand84. > If memory serves me correctly, the original prototype implementation > was done in Prolog, and the Prolog reader has read "ABC" as [65,66,67] > since the late 1970s at least. > > It's not Hysterical Raisins at all: it is simplicity (the preferred > sequence type in Erlang is lists, and strings are just sequences of > characters), power (because any time someone defines a function on > lists you get to use it on strings, and there are *lots* of useful > list functions), and processing efficiency (because working down > one character at a time doesn't require allocating *any* new storage, > not even for slices). > > ByteStrings were added to Haskell (actually in two flavours) to support > high volume I/O. One of the reasons they've seen a lot of acceptance is > that various people have gone to a lot of trouble to make them LOOK as > much like lists as possible. Thanks to Haskell's typeclass machinery, > that can be "very much indeed" (see the ListLike package, the use of > which > means that you can continue to write code that works on lists *or* > strings). > The one thing that bytestrings aren't much good for these days, of > course, > is holding *decoded* characters. > > > It's important to realise that in ANY programming language there is > more than > one way to represent strings. For example, even for character=byte > there are > three different representations supported in C89, and C89 programs > often had > to deal with a fourth. You don't *have* to stick with the one that the > compiler translates "ABC" to. > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > From alpar Thu Feb 14 08:37:38 2008 From: alpar (=?ISO-8859-1?Q?Alp=E1r_J=FCttner?=) Date: Thu, 14 Feb 2008 07:37:38 +0000 Subject: [erlang-questions] Strings as Lists In-Reply-To: <972E01DC-2A4D-4EB8-B483-CFD98AB6E87F@cs.otago.ac.nz> References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> <2F5E96D5-CF7A-42AC-B04E-CB8183F7AB7D@masklinn.net> <3dbc6d1c0802121413o7480d2abtc913801ceae67e8e@mail.gmail.com> <14EEE3D7-56F1-470A-BCE5-C5B534A6EF88@scaldeferri.com> <972E01DC-2A4D-4EB8-B483-CFD98AB6E87F@cs.otago.ac.nz> Message-ID: <1202974658.4369.24.camel@piko.site> > > Yeah, I could work with > > reversed strings, but that's a hack to deal with using the wrong data > > type. > > No, it has to do with the fact that appending on the right is O(n) > whether one uses lists or arrays. A minor correction: appending at the end of an array (std::vector<>) is O(1) operation in C++. The trick is that it allocates a bit more space that it is actually required. If it gets full, it allocates a two times bigger block and copies the array into that block. In this way, the average number of copying of the elements is at most 2. Of course it requires 1.5 times more memory on the average. perhaps in a loop. Right, this is not efficient. But it is > For example, > x = "" > for (i = 1; i <= 100000; i++) x = x "a" > just took 30.5 seconds in awk on my machine, 62.2 seconds in Perl, > and a massive > 631 seconds in Java. All of these C++ counterparts requires unmeasurably low time ( < 4ms) on my laptop: std::vector x; for (int i = 1; i <= 100000; i++) x.push_back('a'); std::string x; for (int i = 1; i <= 100000; i++) x.push_back('a'); std::string x; for (int i = 1; i <= 100000; i++) x+='a'; std::string x; for (int i = 1; i <= 100000; i++) x+="a"; Regards, Alpar From masklinn Thu Feb 14 09:37:09 2008 From: masklinn (Masklinn) Date: Thu, 14 Feb 2008 09:37:09 +0100 Subject: [erlang-questions] Strings as Lists In-Reply-To: <924E1C4E-0029-4EF7-92CD-54AD78B6345B@cs.otago.ac.nz> References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> <2F5E96D5-CF7A-42AC-B04E-CB8183F7AB7D@masklinn.net> <3dbc6d1c0802121413o7480d2abtc913801ceae67e8e@mail.gmail.com> <14EEE3D7-56F1-470A-BCE5-C5B534A6EF88@scaldeferri.com> <924E1C4E-0029-4EF7-92CD-54AD78B6345B@cs.otago.ac.nz> Message-ID: On 14 Feb 2008, at 05:02 , Richard A.O'Keefe wrote: >> First off, I append to >> strings a lot more than I prepend to them. > > I take this to mean that you do stuff like > > S0 = ~0~, > S1 = S0 ++ ~1~, > ... > Sn = Sn_1 ++ ~n~ > > perhaps in a loop. Right, this is not efficient. But it is > spectacularly > inefficient in programming languages with more conventional > representations. > It is O(n**2). For example, > x = "" > for (i = 1; i <= 100000; i++) x = x "a" > just took 30.5 seconds in awk on my machine, 62.2 seconds in Perl, > and a massive > 631 seconds in Java. That was using gcj; I lost patience with the > Sun SDK and > killed it. (AWK faster than Java? Yes, it often is.) Yep, that's a widely known fact, so it's not surprising and it's why people usually suggest using the equivalent to IOLists in imperative languages with immutable array-based strings. In the case of Java, a StringBuilder or StringBuffer (I just did the test on my macbook 2GHz, timing with `time`, using a StringBuilder for that loop yields 0.314s, using regular strings... 243s). From hasan.veldstra Thu Feb 14 10:37:28 2008 From: hasan.veldstra (Hasan Veldstra) Date: Thu, 14 Feb 2008 09:37:28 +0000 Subject: [erlang-questions] Strings as Lists In-Reply-To: <337538cb0802132301k5b2d502fy36c19c6895c0dd4c@mail.gmail.com> References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> <2F5E96D5-CF7A-42AC-B04E-CB8183F7AB7D@masklinn.net> <89759538-180F-44E6-BD70-70EA32EF6DDA@cs.otago.ac.nz> <337538cb0802132301k5b2d502fy36c19c6895c0dd4c@mail.gmail.com> Message-ID: <9AFD96A1-67CB-45D5-8BAD-7DA93281130D@gmail.com> Erlang currently sucks for working with Unicode, and as a consequence, sucks for working with strings. This isn't a fault of the language, just the lack of libraries. Pretending that lists with a bit of DIY are good enough doesn't help. Yeah, you can load text in any Unicode encoding into an Erlang list with no problems... but there's much more to supporting Unicode than that. For example, say you've got the string "??????" (which is Russian for "hi") encoded in UTF-8 in list L: L = [208, 191, 209, 128, 208, 184, 208, 178, 208, 181, 209, 130] Now say you want to convert it to uppercase. Well, you can't. string:to_upper() won't work, as the only encoding it's aware of is ISO Latin-1. As soon as you've got text in anything other than ISO Latin-1, the arguments about niceties of being able to do maps/folds/ comprehensions on lists pretending to be strings become void. You can't reliably iterate over each character in a UTF-8 or UTF-16 string in a plain list, because they are variable-width encodings. Neither could you do it even if your strings were in UTF-32, because they may have composed characters, and you'd have to normalize the string first... and then you're well on your way to re-implementing Unicode in Erlang yourself. Good luck. Anyway, I've been working on an Erlang Unicode string library based on ICU (http://www.icu-project.org/) for the past week. It's coming along nicely, and I'll release an alpha version in another week or so. Erlang is a great language and platform, and non-existent Unicode support is probably the biggest drawback it has. I hope we'll get it fixed soon. -- http://12monkeys.co.uk http://hypernumbers.com From kettlgruber Thu Feb 14 11:40:59 2008 From: kettlgruber (Gerald Kettlgruber) Date: Thu, 14 Feb 2008 11:40:59 +0100 Subject: [erlang-questions] (no subject) In-Reply-To: <20080122083047.98160@gmx.net> References: <20080122083047.98160@gmx.net> Message-ID: <200802141140.59398.kettlgruber@gmail.com> Servus, duat ma lad, dass i so spot erst zruck schreib, hab bissal an Stress jetzt gehabt und dann voikommen vergessen. Jo des Studentenleben haett i ma bissal anders vorgestellt, is doch verdamm anstrengend bei uns, aber jetzt san ja eh Ferien. War jetzt 4 Tage lang Tiefschneefahren und Schneewandern am Hochkar mit Bergfuehrer und allem Drum und Dran, war afoch gewaltig. I muas sagen nachdem versteh i vollkommen was du da auffiast, weil es is afoch des geilste, wenn ma afoch moi was net so alltaegliches macht, da was ma afoch wieder fia wos ma lebt. Bist du jetzt scho in Honkong? Und pass auf wosd mochst goi!, weil des afoch so aufn Berg kraxln is scho sick. Aber is ja nuamoi oise guad ausgaunga. Wuensch da nu a schene Reise, i muas jetzt mal wieder bissal was arbeiten. Lg Ketti Am Dienstag, 22. Januar 2008 09:30:47 schrieb Christoph Kai?l: > He Ketti > > WIe gehts. Schon ewog nix mehr von dir gehoert. wie is des leben aus > student so i hoff du host vue freizeit,des is des wichtigste. > > In ungefaehr 2,5 wochen gehts bei mir daun noch Hong kong. I glaub du host > ei mie blogadress gibs deine eltern a vielleicht sans interessiert a poor > plaetze werd i sicha a besuchen wo se worn > > christophkaisslmalaysia.meinblog.at > > lg CHristoph From hasan.veldstra Thu Feb 14 10:43:09 2008 From: hasan.veldstra (Hasan Veldstra) Date: Thu, 14 Feb 2008 09:43:09 +0000 Subject: [erlang-questions] UTF8 In-Reply-To: <23def8000802120815m6703f285t1494cfccff0ab01d@mail.gmail.com> References: <23def8000802112053i70dec636kadb9ec56b13772f0@mail.gmail.com> <23def8000802120815m6703f285t1494cfccff0ab01d@mail.gmail.com> Message-ID: > Yeah, that worked thanks! I had tried what you did, but it did not > work with the UTF-32 data. Do you know why? As Alex said, you can only have bytes (0-255) in your binaries. > And how do you suppose my data was turned into UTF-32. I got the > data originally from an HTTP GET request that returned a UTF-8 > encoded XML file. The file its self says it's UTF-8, and the > header tuple said the document was using the UTF-8 charset. Does > Erlang convert the data automatically? I don't know. As far as Erlang is concerned, it's all just numbers, and so no conversions are done. Maybe a library you're using did it for you somewhere, or the document is actually in UTF-32, despite what the headers say. -- http://12monkeys.co.uk http://hypernumbers.com From hasan.veldstra Thu Feb 14 11:42:38 2008 From: hasan.veldstra (Hasan Veldstra) Date: Thu, 14 Feb 2008 10:42:38 +0000 Subject: [erlang-questions] UTF8 In-Reply-To: <23def8000802120821u79dd458vbe0d9689f281697a@mail.gmail.com> References: <23def8000802112053i70dec636kadb9ec56b13772f0@mail.gmail.com> <23def8000802120821u79dd458vbe0d9689f281697a@mail.gmail.com> Message-ID: <044C986E-909C-421E-B127-0305A46DB003@gmail.com> > And how do you suppose my data was turned into UTF-32. I got the > data originally from an HTTP GET request that returned a UTF-8 > encoded XML file. The file its self says it's UTF-8, and the > header tuple said the document was using the UTF-8 charset. Does > Erlang convert the data automatically? Actually, 332 (U+14C) is also the UTF-16 encoding for "?". If I remember correctly, the XML standard requires that the documents be in UTF-8 or UTF-16. So it's most likely that your XML file is encoded in UTF-16, and the headers are wrong. -- http://12monkeys.co.uk http://hypernumbers.com From erlang Thu Feb 14 12:07:35 2008 From: erlang (Peter Lund) Date: Thu, 14 Feb 2008 12:07:35 +0100 Subject: [erlang-questions] Strings as Lists In-Reply-To: <9AFD96A1-67CB-45D5-8BAD-7DA93281130D@gmail.com> References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> <2F5E96D5-CF7A-42AC-B04E-CB8183F7AB7D@masklinn.net> <89759538-180F-44E6-BD70-70EA32EF6DDA@cs.otago.ac.nz> <337538cb0802132301k5b2d502fy36c19c6895c0dd4c@mail.gmail.com> <9AFD96A1-67CB-45D5-8BAD-7DA93281130D@gmail.com> Message-ID: <47B420F7.9040308@lundata.se> The list should contain 6 unicode characters (>255), not its encoding into utf-8. You should apply a fun "to_upper" on that list. Since the OTP libraries do not have to_upper defined for Cyrillic you need to write that yourself. When storing your Unicode strings, it is a good idea to convert it to utf-8 and then to a binary. Storing this binary is cheaper than storing the Unicode list. Lists in erlang consumes a lot of space. /Peter Hasan Veldstra skrev: > Erlang currently sucks for working with Unicode, and as a > consequence, sucks for working with strings. > > This isn't a fault of the language, just the lack of libraries. > > Pretending that lists with a bit of DIY are good enough doesn't help. > > Yeah, you can load text in any Unicode encoding into an Erlang list > with no problems... but there's much more to supporting Unicode than > that. > > For example, say you've got the string "??????" (which is > Russian for "hi") encoded in UTF-8 in list L: > > L = [208, 191, 209, 128, 208, 184, 208, 178, 208, 181, 209, 130] > > Now say you want to convert it to uppercase. Well, you can't. > string:to_upper() won't work, as the only encoding it's aware of is > ISO Latin-1. > > As soon as you've got text in anything other than ISO Latin-1, the > arguments about niceties of being able to do maps/folds/ > comprehensions on lists pretending to be strings become void. You > can't reliably iterate over each character in a UTF-8 or UTF-16 > string in a plain list, because they are variable-width encodings. > Neither could you do it even if your strings were in UTF-32, because > they may have composed characters, and you'd have to normalize the > string first... and then you're well on your way to re-implementing > Unicode in Erlang yourself. Good luck. > > Anyway, I've been working on an Erlang Unicode string library based > on ICU (http://www.icu-project.org/) for the past week. It's coming > along nicely, and I'll release an alpha version in another week or so. > > Erlang is a great language and platform, and non-existent Unicode > support is probably the biggest drawback it has. I hope we'll get it > fixed soon. > > > -- > http://12monkeys.co.uk > http://hypernumbers.com > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > > From bobcalco Thu Feb 14 13:09:43 2008 From: bobcalco (Bob Calco) Date: Thu, 14 Feb 2008 07:09:43 -0500 Subject: [erlang-questions] Strings as Lists In-Reply-To: <9AFD96A1-67CB-45D5-8BAD-7DA93281130D@gmail.com> References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> <2F5E96D5-CF7A-42AC-B04E-CB8183F7AB7D@masklinn.net> <89759538-180F-44E6-BD70-70EA32EF6DDA@cs.otago.ac.nz> <337538cb0802132301k5b2d502fy36c19c6895c0dd4c@mail.gmail.com> <9AFD96A1-67CB-45D5-8BAD-7DA93281130D@gmail.com> Message-ID: <006b01c86f02$7bc365c0$734a3140$@rr.com> Hasan: > Erlang currently sucks for working with Unicode, and as a > consequence, sucks for working with strings. > > This isn't a fault of the language, just the lack of libraries. <...> > As soon as you've got text in anything other than ISO Latin-1, the > arguments about niceties of being able to do maps/folds/ > comprehensions on lists pretending to be strings become void. You > can't reliably iterate over each character in a UTF-8 or UTF-16 > string in a plain list, because they are variable-width encodings. > Neither could you do it even if your strings were in UTF-32, because > they may have composed characters, and you'd have to normalize the > string first... and then you're well on your way to re-implementing > Unicode in Erlang yourself. Good luck. I have run into this brick wall as well. > Anyway, I've been working on an Erlang Unicode string library based > on ICU (http://www.icu-project.org/) for the past week. It's coming > along nicely, and I'll release an alpha version in another week or so. Excellent! > Erlang is a great language and platform, and non-existent Unicode > support is probably the biggest drawback it has. I hope we'll get it > fixed soon. Why don't you open a project on Google code so other folks can chip in? I for one would also like to see this capability added to Erlang as well. Sincerely, [X || X <- [47,66,111,98,32,59,41]]. From raimo+erlang-questions Thu Feb 14 15:23:18 2008 From: raimo+erlang-questions (Raimo Niskanen) Date: Thu, 14 Feb 2008 15:23:18 +0100 Subject: [erlang-questions] : : (no subject) In-Reply-To: <4fd059680802140429xfd0856cu89c1a97e4999549@mail.gmail.com> References: <20080122083047.98160@gmx.net> <200802141140.59398.kettlgruber@gmail.com> <20080214104410.GC16090@erix.ericsson.se> <4fd059680802140429xfd0856cu89c1a97e4999549@mail.gmail.com> Message-ID: <20080214142318.GB18101@erix.ericsson.se> On Thu, Feb 14, 2008 at 01:29:13PM +0100, Gerald Kettlgruber wrote: > Sorry, > > i didn't noticed, that my mailclient set the answeradress to erlangquestions > instead of a private adress. > I'm really sorry for that mistake. > No problem. > > On Thu, Feb 14, 2008 at 11:44 AM, Raimo Niskanen < > raimo+erlang-questions> wrote: > > > I hope you happened to include erlang-questions by mistake > > in the mail below? Or what happened? > > > > > > > > / Raimo Niskanen, erlang.org list admin, Erlang/OTP, Ericsson AB > > -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From kevin Thu Feb 14 16:40:56 2008 From: kevin (Kevin Scaldeferri) Date: Thu, 14 Feb 2008 07:40:56 -0800 Subject: [erlang-questions] UTF8 In-Reply-To: <044C986E-909C-421E-B127-0305A46DB003@gmail.com> References: <23def8000802112053i70dec636kadb9ec56b13772f0@mail.gmail.com> <23def8000802120821u79dd458vbe0d9689f281697a@mail.gmail.com> <044C986E-909C-421E-B127-0305A46DB003@gmail.com> Message-ID: <360F0E29-5168-43B2-935D-706174CEFAB7@scaldeferri.com> On Feb 14, 2008, at 2:42 AM, Hasan Veldstra wrote: > >> And how do you suppose my data was turned into UTF-32. I got the >> data originally from an HTTP GET request that returned a UTF-8 >> encoded XML file. The file its self says it's UTF-8, and the >> header tuple said the document was using the UTF-8 charset. Does >> Erlang convert the data automatically? > > Actually, 332 (U+14C) is also the UTF-16 encoding for "?". If I > remember correctly, the XML standard requires that the documents be > in UTF-8 or UTF-16. So it's most likely that your XML file is encoded > in UTF-16, and the headers are wrong. The XML standard says that the default encoding is UTF-8, but you can specify any encoding you want. -kevin From sean.hinde Thu Feb 14 17:24:05 2008 From: sean.hinde (Sean Hinde) Date: Thu, 14 Feb 2008 16:24:05 +0000 Subject: [erlang-questions] Strings as Lists In-Reply-To: <9AFD96A1-67CB-45D5-8BAD-7DA93281130D@gmail.com> References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> <2F5E96D5-CF7A-42AC-B04E-CB8183F7AB7D@masklinn.net> <89759538-180F-44E6-BD70-70EA32EF6DDA@cs.otago.ac.nz> <337538cb0802132301k5b2d502fy36c19c6895c0dd4c@mail.gmail.com> <9AFD96A1-67CB-45D5-8BAD-7DA93281130D@gmail.com> Message-ID: <9A3E1C2C-D6D7-4C9F-A04A-D7F2B34B3531@gmail.com> Has anyone here noticed that Erlang ships with a library module for charset conversion (xmerl_ucs). It may take you some part of the way Sean On 14 Feb 2008, at 09:37, Hasan Veldstra wrote: > > Erlang currently sucks for working with Unicode, and as a > consequence, sucks for working with strings. > > This isn't a fault of the language, just the lack of libraries. > > Pretending that lists with a bit of DIY are good enough doesn't help. > > Yeah, you can load text in any Unicode encoding into an Erlang list > with no problems... but there's much more to supporting Unicode than > that. > > For example, say you've got the string "??????" (which is > Russian for "hi") encoded in UTF-8 in list L: > > L = [208, 191, 209, 128, 208, 184, 208, 178, 208, 181, 209, 130] > > Now say you want to convert it to uppercase. Well, you can't. > string:to_upper() won't work, as the only encoding it's aware of is > ISO Latin-1. > > As soon as you've got text in anything other than ISO Latin-1, the > arguments about niceties of being able to do maps/folds/ > comprehensions on lists pretending to be strings become void. You > can't reliably iterate over each character in a UTF-8 or UTF-16 > string in a plain list, because they are variable-width encodings. > Neither could you do it even if your strings were in UTF-32, because > they may have composed characters, and you'd have to normalize the > string first... and then you're well on your way to re-implementing > Unicode in Erlang yourself. Good luck. > > Anyway, I've been working on an Erlang Unicode string library based > on ICU (http://www.icu-project.org/) for the past week. It's coming > along nicely, and I'll release an alpha version in another week or so. > > Erlang is a great language and platform, and non-existent Unicode > support is probably the biggest drawback it has. I hope we'll get it > fixed soon. > > > -- > http://12monkeys.co.uk > http://hypernumbers.com > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions From dustin.whitney Thu Feb 14 17:29:45 2008 From: dustin.whitney (Dustin Whitney) Date: Thu, 14 Feb 2008 11:29:45 -0500 Subject: [erlang-questions] UTF8 In-Reply-To: <360F0E29-5168-43B2-935D-706174CEFAB7@scaldeferri.com> References: <23def8000802112053i70dec636kadb9ec56b13772f0@mail.gmail.com> <23def8000802120821u79dd458vbe0d9689f281697a@mail.gmail.com> <044C986E-909C-421E-B127-0305A46DB003@gmail.com> <360F0E29-5168-43B2-935D-706174CEFAB7@scaldeferri.com> Message-ID: <23def8000802140829s1a16fa38s42a447f09e8b9899@mail.gmail.com> On Thu, Feb 14, 2008 at 10:40 AM, Kevin Scaldeferri wrote: > > On Feb 14, 2008, at 2:42 AM, Hasan Veldstra wrote: > > > > >> And how do you suppose my data was turned into UTF-32. I got the > >> data originally from an HTTP GET request that returned a UTF-8 > >> encoded XML file. The file its self says it's UTF-8, and the > >> header tuple said the document was using the UTF-8 charset. Does > >> Erlang convert the data automatically? > > > > Actually, 332 (U+14C) is also the UTF-16 encoding for "?". If I > > remember correctly, the XML standard requires that the documents be > > in UTF-8 or UTF-16. So it's most likely that your XML file is encoded > > in UTF-16, and the headers are wrong. > > The XML standard says that the default encoding is UTF-8, but you can > specify any encoding you want. > > -kevin Right, 332 not being able to be converted to a byte makes sense to me now, and I suppose converting it to UTF-8 resulting in 197, 140 makes sense now too (it will make more sense when I read further about what UTF-8 does for characters outside of the ASCII set). But yeah, I'm still not sure why the document that says it was encoded in UTF-8 ended up being in UTF-16 (or UTF-32). Anyway, I really appreciate the help. I've never really had to think about what was happening behind the scenes with my strings, but now I've got a pretty good understanding of how erlang deals with them. -Dustin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080214/28678369/attachment.html From dustin.whitney Thu Feb 14 17:39:21 2008 From: dustin.whitney (Dustin Whitney) Date: Thu, 14 Feb 2008 11:39:21 -0500 Subject: [erlang-questions] Strings as Lists In-Reply-To: <006b01c86f02$7bc365c0$734a3140$@rr.com> References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> <2F5E96D5-CF7A-42AC-B04E-CB8183F7AB7D@masklinn.net> <89759538-180F-44E6-BD70-70EA32EF6DDA@cs.otago.ac.nz> <337538cb0802132301k5b2d502fy36c19c6895c0dd4c@mail.gmail.com> <9AFD96A1-67CB-45D5-8BAD-7DA93281130D@gmail.com> <006b01c86f02$7bc365c0$734a3140$@rr.com> Message-ID: <23def8000802140839h1b5edc30lc22784220a247b52@mail.gmail.com> > > > > > Anyway, I've been working on an Erlang Unicode string library based > > on ICU (http://www.icu-project.org/) for the past week. It's coming > > along nicely, and I'll release an alpha version in another week or so. > > Excellent! Yes, I'll second that! -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080214/187eb1ff/attachment.html From masterofquestions Thu Feb 14 17:50:32 2008 From: masterofquestions (db) Date: Thu, 14 Feb 2008 08:50:32 -0800 (PST) Subject: [erlang-questions] Erlang OTP .rel file start/supervise application remote node In-Reply-To: <1218d6a50802070859v645fc175vc41fdc1f25ed6fd8@mail.gmail.com> References: <1218d6a50802070859v645fc175vc41fdc1f25ed6fd8@mail.gmail.com> Message-ID: Here is my answer to my own question: > Does erlang otp and .rel files allow starting/supervising application on > remote node? OTP does not support this feature in application level or in process level where supervisor on a different node and process on remote node. >If so, how do you define it in .rel file? I have gone through > all the documentations. Documentation mainly describes about how to > start/supervise application on the same nodes. No mention of > starting/supervise application on remote node. Does this mean otp does not > support it or it's undocumented? Erlang OTP module supervisor only able to supervise(start/stop/ monitor) process on the same node. Note, there is no supervisor support for process on remote node. From richardc Tue Feb 12 18:00:30 2008 From: richardc (Richard Carlsson) Date: Tue, 12 Feb 2008 18:00:30 +0100 Subject: [erlang-questions] Strings as Lists In-Reply-To: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> Message-ID: <47B1D0AE.5030803@it.uu.se> tsuraan wrote: > Why does erlang internally represent strings as lists? In every > language I've used other than Java, a string is a sequence of octets, > just like Erlang's binary type. I know that you can represent a string > efficiently by using <<"string">> rather than just "string", but why > doesn't erlang do this by default? Is it just because pre-12B binary > handling wasn't as efficient as list handling, or is Erlang intended to > support UTF-32? Strings as lists is simple and flexible (i.e., if you already have lists, you don't need to add another data type). Functions that work on lists, such as append, reverse, etc., can be used directly on strings; you don't need to program in different styles if you're traversing a list or a string; etc. Other languages that represent strings as lists include Prolog (which was a big influence on Erlang) and Haskell. That said, in larger systems it is better to represent string constants in a more space-efficient way. Binaries let you do this in Erlang, but they were a later addition to the language, and the syntax for constructing and decomposing binaries came even later. /Richard From dking Thu Feb 14 19:51:37 2008 From: dking (David King) Date: Thu, 14 Feb 2008 10:51:37 -0800 Subject: [erlang-questions] Erlounge in San Francisco, 17-22 February In-Reply-To: <3dbc6d1c0802131542p4537805erca28764d804c9f0e@mail.gmail.com> References: <3dbc6d1c0801190827l11ac1050yae37415a0e565270@mail.gmail.com> <3dbc6d1c0802011452v20c7df1fu966a326e8ed87e8b@mail.gmail.com> <76F389D3-F029-4EC3-9037-3D24B9ED6D15@gerakines.net> <3dbc6d1c0802071353v2873419x88587f630da567ac@mail.gmail.com> <3dbc6d1c0802121413o206a516ej1a9d328b3bf79d16@mail.gmail.com> <2FAE4954-2162-4B22-A1D4-CD6D88F736F0@ketralnis.com> <3dbc6d1c0802131542p4537805erca28764d804c9f0e@mail.gmail.com> Message-ID: <4C733E71-7C36-4F94-AD54-8D98BEFA5D12@ketralnis.com> >> Reddit is willing to use their office in SoMa near Moscone for an >> Erlang meetup > Reddit offices on 3rd St?* That suits me fine. We could meet there > and maybe go on for beer, for example to the 21st Amendment Brewery > which is close. 7.30 pm suit everyone? Sounds good to me. We're on the third floor, I'll try to put signs on the third floor pointing the way. 520 3rd Street 3rd Floor San Francisco 7:30p, Monday 18 Feb 2008 I'd appreciate (but not require) RSVPs so we know for how many to wait before moving on to drinks. On 13 Feb 2008, at 15:42, Robert Virding wrote: > > Robert > > *Google Earth is wonderful. Actually there is no end of fantastic > things you can do with it. > > On 13/02/2008, David King wrote: > Ok, now we > just need some place to meet. Suggestions please. > > Reddit is willing to use their office in SoMa near Moscone for an > Erlang meetup > From dloutrein.lists Thu Feb 14 20:05:51 2008 From: dloutrein.lists (denis) Date: Thu, 14 Feb 2008 14:05:51 -0500 Subject: [erlang-questions] Strings as Lists In-Reply-To: <47B1D0AE.5030803@it.uu.se> Message-ID: <001e01c86f3c$9eb43430$b029030a@mtl.ubisoft.org> In the project I currently work on, we faced a problem with the string. Not because there are stored as list (it's very handy sometimes), but because we can't find the type of the data. It's really frustating to not being able to know when we receive a list of integer, if it's really a list of integer or a string. This is the case when you need to convert your data into another representation, for instance json or whatever format. I know that there are tricks like {string, [...]}, but you need to parse all your data before to convert it. My wish is to have a real string type, whatever its representation is (list, binaries, ...) Denis > -----Message d'origine----- > De?: erlang-questions-bounces [mailto:erlang-questions- > bounces] De la part de Richard Carlsson > Envoy??: mardi 12 f?vrier 2008 12:01 > ??: tsuraan > Cc?: Erlang Questions > Objet?: Re: [erlang-questions] Strings as Lists > > tsuraan wrote: > > Why does erlang internally represent strings as lists? In every > > language I've used other than Java, a string is a sequence of octets, > > just like Erlang's binary type. I know that you can represent a string > > efficiently by using <<"string">> rather than just "string", but why > > doesn't erlang do this by default? Is it just because pre-12B binary > > handling wasn't as efficient as list handling, or is Erlang intended to > > support UTF-32? > > Strings as lists is simple and flexible (i.e., if you already have lists, > you don't need to add another data type). Functions that work on lists, > such as append, reverse, etc., can be used directly on strings; you > don't need to program in different styles if you're traversing a list > or a string; etc. Other languages that represent strings as lists include > Prolog (which was a big influence on Erlang) and Haskell. That said, in > larger systems it is better to represent string constants in a more > space-efficient way. Binaries let you do this in Erlang, but they were > a later addition to the language, and the syntax for constructing and > decomposing binaries came even later. > > /Richard > > > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions From alexey Thu Feb 14 20:37:28 2008 From: alexey (Alexey Shchepin) Date: Thu, 14 Feb 2008 21:37:28 +0200 Subject: [erlang-questions] Strings as Lists In-Reply-To: <47B1D0AE.5030803@it.uu.se> (Richard Carlsson's message of "Tue, 12 Feb 2008 18:00:30 +0100") References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> <47B1D0AE.5030803@it.uu.se> Message-ID: <87r6ff5oa4.fsf@alex64.sevcom.net> A non-text attachment was scrubbed... Name: smime.p7s Type: application/x-pkcs7-signature Size: 2061 bytes Desc: not available Url : http://www.erlang.org/pipermail/erlang-questions/attachments/20080214/18334789/attachment.bin From kevin Thu Feb 14 20:25:21 2008 From: kevin (Kevin Scaldeferri) Date: Thu, 14 Feb 2008 11:25:21 -0800 Subject: [erlang-questions] Strings as Lists In-Reply-To: <924E1C4E-0029-4EF7-92CD-54AD78B6345B@cs.otago.ac.nz> References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> <2F5E96D5-CF7A-42AC-B04E-CB8183F7AB7D@masklinn.net> <3dbc6d1c0802121413o7480d2abtc913801ceae67e8e@mail.gmail.com> <14EEE3D7-56F1-470A-BCE5-C5B534A6EF88@scaldeferri.com> <924E1C4E-0029-4EF7-92CD-54AD78B6345B@cs.otago.ac.nz> Message-ID: On Feb 13, 2008, at 8:02 PM, Richard A.O'Keefe wrote: > On 13 Feb 2008, at 12:41 pm, Kevin Scaldeferri wrote: >> Hold on... lists aren't really a particular convenient or efficient >> data structure for working with strings. > > For some people they are. > >> First off, I append to >> strings a lot more than I prepend to them. > > I take this to mean that you do stuff like > > S0 = ~0~, > S1 = S0 ++ ~1~, > ... > Sn = Sn_1 ++ ~n~ No, certainly not one character at a time. But I frequently build up an HTML document or some report piece by piece. > > > perhaps in a loop. Right, this is not efficient. But it is > spectacularly > inefficient in programming languages with more conventional > representations. > It is O(n**2). No, in a decent string implementation it is O(n). > For example, > x = "" > for (i = 1; i <= 100000; i++) x = x "a" > just took 30.5 seconds in awk on my machine, 62.2 seconds in Perl, > and a massive > 631 seconds in Java. You either have a very old perl, a very slow machine, or have implemented it quite badly: % time perl -le 'my $x = ""; $x .= "a" for 1..100_000; print length $x' 100000 perl -le '...' 0.02s user 0.00s system 89% cpu 0.024 total even faster (but even less realistic, and not really the same benchmark): % time perl -le 'my $x = "a" x 100_000; print length $x' 100000 perl -le '...' 0.00s user 0.00s system 85% cpu 0.006 total > >> Yeah, I could work with >> reversed strings, but that's a hack to deal with using the wrong data >> type. > > No, it has to do with the fact that appending on the right is O(n) > whether one uses lists or arrays. Arguably, you should be using the > right data type THE RIGHT WAY. Can you provide an example of your > code? Someone else explained how C++ strings/vectors handle this. Perl uses essentially the same strategy. > > >> Plus, I probably prefix match more often than suffix matching >> (although this is less lopsided than append vs. prepend). Of course, >> I also like to do substring matching and regular expressions quite a >> bit, and Boyer-Moore is definitely more efficient with arrays than >> lists. > > The Boyer-Moore algorithm requires space proportional to the alphabet > size. > The Unicode alphabet size is enormous (last time I looked there were > nearly > 100 000 characters defined). If you use UTF-8 encoded strings, you can use Boyer-Moore unmodified (matching at the level of bytes, rather than characters). For a fixed width encoding, you can also work with bytes, but you'll have to take the character width into account when considering how to slide. > Unicode substring matching is > definitely nasty, > given that, for example, you would like (e,floating acute) to match > ?, and > the Boyer-Moore algorithm assumes a unique encoding of any given > string, > which Unicode does not even begin to have. Then there are fun things > like > U+0028 is the code for the "(" character, but if I see a "(" and go > looking > for it, I might have to look for a U+0029 instead, Indeed, Unicode is really a PITA like this, but I don't think a list representation makes this magically go away, either. In fact, in your example with combining characters, you need to be able to backtrack, which is more awkward and less performant on lists than arrays. But, if you disagree, I think this would be a very interesting sort of benchmark to do. Currently, Erlang appears to perform quite awfully on anything to do with strings: http://shootout.alioth.debian.org/gp4/benchmark.php?test=all&lang=hipe&lang2=perl Now, most of these conflate string handling and file I/O, so it could be that file I/O is more of the problem. Or maybe they are badly implemented. Since you (and many on this list) are concerned highly with Unicode string handling, I think it would be quite interested to design a benchmark of that. Perhaps something that did substring (or regexp) matching on a large number of candidate strings. Perhaps Erlang would do better. Certainly I'd expect it to be much less code than C/C++ (although that's practically a given). I'd be very interested to compare to Perl's Unicode strings, or Java. >> >> It's probably worth noting that none of the languages which are >> considered _good_ for working with strings (AFAIK) use a list >> representation. > > Not really. Perl is normally "considered _good_ for working with > strings", > but it is pretty much hopeless at building strings by concatenation. I hope I've demonstrated above that this claim is false. -kevin From ok Fri Feb 15 03:33:01 2008 From: ok (Richard A. O'Keefe) Date: Fri, 15 Feb 2008 15:33:01 +1300 Subject: [erlang-questions] Strings as Lists In-Reply-To: <15474643.post@talk.nabble.com> References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> <0EA68804-E7BB-477A-9351-677188540F48@cs.otago.ac.nz> <15474643.post@talk.nabble.com> Message-ID: <74E843A6-771C-4DFD-8B97-C01B82808102@cs.otago.ac.nz> On 14 Feb 2008, at 7:07 pm, Zvi wrote: > Richard, > > I think you confusing datatype with it's implementation/ > representation. On the contrary. Remember the topic of this thread? Someone complained that Erlang uses lists for strings (as its default implementation). I have explained why this is a perfectly reasonable, indeed seriously good, way to go for *some* uses of strings, but I have *also* explicitly made the point that There Is More Than One Way To Do It, and that using the "default" representation in ANY programming language is not always a good idea. > My biggest problem with Erlang standard string representation is > that in > 64bit mode, each character taking 16 bytes. Now *you* are focussing on a particular implementation. Erlang isn't standing behind your chair pointing a gun at your head and saying "you MUST use lists for text or I will kill you"! Given that Erlang processes in a single program may easily be scattered across any number of machines, it seems to me that if you were seriously worried about storage, you would be worried about ALL storage, not just strings, and would be running many 32-bit OS-level processes on a machine in order to halve your storage requirements. As long as processes that communicated a lot tended to be in the same process, this should work. On today's multicore machines, this is (or should be) an attractive approach. Use a tuple, and you will still be taking 8 bytes per Unicode character when 3 will suffice. By packing 3 unicode characters to an integer, and using unrolled strict lists instead of plain lists (I have a first draft of an ursl module with a subset of the lists: operations, if anyone wants it) you can get 3*4 characters in 6*8 bytes, or 4 bytes each. That's a factor of four. And it's easy enough to write a preprocessor to convert string literals (possibly flagged in some way) to that form. More importantly, holding quantities of text in memory that are big enough for the space required to be a serious problem is Not The Erlang Way. The idea is to stream *chunks* of text through the system. > So typical message of 10KB after converted to XML become 20KB Why are you converting to XML? I know XML is bulky, but a doubling in size like that suggests a poorly chosen XML schema. Why are you not converting to *compressed* XML? > and after parsed by 64bit Erlang VM become 320KB. But why do that? Lists of characters are, and are intended to be, useful for *processing* (chunks of) text in Erlang. If someone is handing you globs of stuff that are you simply going to squirt down a wire, then a binary is exactly what you want. > Also, you forget that what was good for LISP Machines is not good for > current machine architectures. Please, do not make a habit of assuming your correspondent is a moron. You appear to have missed the point, which is that what people THOUGHT was good for Lisp machines WASN'T good for Lisp machines. The only real way to KNOW what is good or not is to implement and MEASURE. You had better believe that on a machine with a 16-bit bus, where we had a total of 4MB address space available for Prolog's use, people complained bitterly about the *obvious* inefficiency of using 8 bytes per character instead of 1. With respect to time, they were simply wrong. With respect to space, the answer was "program so it doesn't matter". We didn't go around converting bitmaps to lists! > Binary strings can be handled very efficiently using vectorized > SIMD code > and they use modern caches much more effectively, than lists. Um. There are so many presuppositions in there that it's really not practical to address them all in a single message. First, the number of things that can be done efficiently to *Unicode* using Vis/MMX/AltiVec instructions is rather limited. Second, what it's mostly limited to is things you should not be doing. But the big thing is that for many text processing tasks *both* lists *and* binaries are spectacularly inefficient because of the limits they put on sharing. For example, my XML processing kit in C cannot and will not *change* a document representation, so for most of the transformations I do, the transformed XML data structure shares a large proportion of its memory with the input. You can't do that with a byte-vector string, and SIMD instructions don't help with it. DAGs are wonderful! > > Deep lists and io-lists are essentially analog of Java's > StringBuffer or C++ > STL's ostringstream. Not "essentially". They are *essentially* trees that offer O(1) concatenation and shared substructure. StringBuilder (I do hope your Java code doesn't use StringBuffer any more) doesn't offer either of those. > So in general I want immutable String ADT. The ADT implementation > should be > smart enough, to switch to the best representation, according to > usage. Who was the famous computer scientist who said "If anyone says to you, 'I want a programming language in which I just say what I want', give him a lollipop." You want a data structure which can't change (it's immutable) but does change (it switches to another representation)? We've been there. Anyone else in this mailing list remember SETL? Anyone remember the hopes for automatic selection of representation? As I recall it, the optimiser got so big that they were never able to run it over the compiler. (And if anyone, DOES remember SETL and knows how I can get in touch with David Bacon, I'd be grateful. And if you have a copy of On Programming that you don't want, I could give it a loving home.) > > BTW: most sophisticated string implementation I know about was in > SNOBOL. I > think it was list of unique substrings. The Bell Labs SNOBOL4 system and the SPITBOL system used different string representations. The main problem for SNOBOL was trying to support computer hardware that didn't have byte addressing. From rvirding Fri Feb 15 03:56:46 2008 From: rvirding (Robert Virding) Date: Fri, 15 Feb 2008 03:56:46 +0100 Subject: [erlang-questions] Strings as Lists In-Reply-To: References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> <2F5E96D5-CF7A-42AC-B04E-CB8183F7AB7D@masklinn.net> <15448906.post@talk.nabble.com> <3dbc6d1c0802131525v28afff23rb78e3673cd9a994@mail.gmail.com> Message-ID: <3dbc6d1c0802141856y2ea5b449g42dafe7dcf3d8cbe@mail.gmail.com> On 14/02/2008, Christian S wrote: > > > Parsing a quoted string as a token from leex is difficult if you know > that the end-quote might not be included in the chunk you just fed > into leex, but the next chunk read from the tcp stream. No, you're wrong here, leex has been designed to handle just this case. See next bit below. With fully recursive grammars I can see how one wants to let yecc > handle it, but a quoted string is not really recursive: You cant have > a quoted string inside a quoted string the same way you can have, say, > an if-expression inside an if-expression inside an if-expression etc > in a programming language. > > Leex is a tool I would use for when I know I have some file of finite > length and I could do a two-pass parsing with yecc as the second > stage, I would not use it for tokenizing SMTP/IRC/NNTP... This is where you are wrong and have missed how leex works. From above as well. The i/o system was designed to handle just this case where you receive your data in chunks and you need to be able to handle the collecting of the data from these chunks into the correct units in a re-entrant. In this case tokens. Or it could be lines, or records, or all the tokens in an Erlang form, or ... . A process which is an IoDevice for the io module functions can do just this, this is what makes it an IoDevice. Unfortunately there is no good write up describing the i/o system and the proper interface needed this functionality is not properly defined in the io module. There was a description in the old book but not in the released sections. Someday if I get time I will fix it. Now leex was designed to fit into the i/o system so it can handle getting data in chunks in a re-entrant fashion. It depends on which functions in the generated file you call. That file has the same interface as the erl_scan module. The string/2/3 functions take a complete string and return the tokens in it. This is a one-shot deal. However the functions token/3 and tokens/3 are re-entrant. Token will read one token, while tokens will read all the tokens up to a a token which was declared as {end_token, ... }. Like dot ". " in Erlang. You first call them with a continuation of [], if there are enough characters then it returns {done,Result,LeftOverChars} otherwise it there weren't enough characters it returns {more,Continuation}. Then you call the function again with Continuation and more characters, and so until you get what you need or your characters run out. No more characters is signaled by calling with 'eof' instead of characters, an empty list does not have this effect. Check the documentation for erl_scan (though they don't have the token function). So leex can do exactly what you want. Unfortunately yecc doesn't have the same type of interface so it is not re-entrant and you have to give it all the tokens in one go. Even more unfortunately it could have been written in such a way. And could be rewritten as well. :-( Hope this helps. I will try to find some examples of code. Otherwise check in the file modules. Robert I'm looking for a better tool (as in quicker and easier code to > maintain/extend) than writing protocol parsing "by hand". > > PS. > I reserve the right to be completly mistaken about everything. > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080215/b2aedc97/attachment.html From rvirding Fri Feb 15 04:03:15 2008 From: rvirding (Robert Virding) Date: Fri, 15 Feb 2008 04:03:15 +0100 Subject: [erlang-questions] Erlounge in San Francisco, 17-22 February In-Reply-To: <4C733E71-7C36-4F94-AD54-8D98BEFA5D12@ketralnis.com> References: <3dbc6d1c0801190827l11ac1050yae37415a0e565270@mail.gmail.com> <3dbc6d1c0802011452v20c7df1fu966a326e8ed87e8b@mail.gmail.com> <76F389D3-F029-4EC3-9037-3D24B9ED6D15@gerakines.net> <3dbc6d1c0802071353v2873419x88587f630da567ac@mail.gmail.com> <3dbc6d1c0802121413o206a516ej1a9d328b3bf79d16@mail.gmail.com> <2FAE4954-2162-4B22-A1D4-CD6D88F736F0@ketralnis.com> <3dbc6d1c0802131542p4537805erca28764d804c9f0e@mail.gmail.com> <4C733E71-7C36-4F94-AD54-8D98BEFA5D12@ketralnis.com> Message-ID: <3dbc6d1c0802141903r2b38ceacsf4e4168921d20eab@mail.gmail.com> I'm coming. :-) Robert P.S. Sorry couldn't help that. On 14/02/2008, David King wrote: > > >> Reddit is willing to use their office in SoMa near Moscone for an > >> Erlang meetup > > > Reddit offices on 3rd St?* That suits me fine. We could meet there > > and maybe go on for beer, for example to the 21st Amendment Brewery > > which is close. 7.30 pm suit everyone? > > > Sounds good to me. We're on the third floor, I'll try to put signs on > the third floor pointing the way. > > 520 3rd Street > 3rd Floor > San Francisco > 7:30p, Monday 18 Feb 2008 > > I'd appreciate (but not require) RSVPs so we know for how many to wait > before moving on to drinks. > > > > On 13 Feb 2008, at 15:42, Robert Virding wrote: > > > > > Robert > > > > *Google Earth is wonderful. Actually there is no end of fantastic > > things you can do with it. > > > > On 13/02/2008, David King wrote: > Ok, now we > > just need some place to meet. Suggestions please. > > > > Reddit is willing to use their office in SoMa near Moscone for an > > Erlang meetup > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080215/21c3ae6e/attachment.html From ok Fri Feb 15 04:06:46 2008 From: ok (Richard A. O'Keefe) Date: Fri, 15 Feb 2008 16:06:46 +1300 Subject: [erlang-questions] Strings as Lists In-Reply-To: <1202974658.4369.24.camel@piko.site> References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> <2F5E96D5-CF7A-42AC-B04E-CB8183F7AB7D@masklinn.net> <3dbc6d1c0802121413o7480d2abtc913801ceae67e8e@mail.gmail.com> <14EEE3D7-56F1-470A-BCE5-C5B534A6EF88@scaldeferri.com> <972E01DC-2A4D-4EB8-B483-CFD98AB6E87F@cs.otago.ac.nz> <1202974658.4369.24.camel@piko.site> Message-ID: I wrote: >> No, it has to do with the fact that appending on the right is O(n) >> whether one uses lists or arrays. Since this is the *Erlang* mailing list, this should have been read as "whether one uses (immutable) lists or (immutable) arrays". On 14 Feb 2008, at 8:37 pm, Alp?r J?ttner wrote: > A minor correction: appending at the end of an array > (std::vector<>) is > O(1) operation in C++. std::vector<> is not a class of immutable arrays. Suppose we have two byte-strings of length n and m. If they are immutable, the concatenation cost is O(n+m). If you are willing to smash the one on the left, and it is "stretchy", the cost is STILL not O(1), it is O(m). The technique Alp?r J?ttner discussed is, or should be, in chapter 1 or 2 of any good data structures and algorithms book. > > All of these C++ counterparts requires unmeasurably low time ( < > 4ms) on > my laptop: And they all do it by doing something wildly irrelevant to Erlang: SMASHING a mutable data structure. Last year, on the same general topic, someone mentioned Phil Bagwell's VList data structure. Annoyingly, his paper doesn't really analyse the asymptotic performance of most operations. His comparison tables give specific times on specific machines for specific problems, not general formulas. He says that they could be made to support additions at either end but doesn't go into detail. Anyway, that could be quite a good structure for adding small amounts of text at either end, but I don't think it would handle general concatenation well. There *are* sequence data structures in the functional community that handle concatenation well. From lloy0076 Fri Feb 15 00:03:02 2008 From: lloy0076 (David Lloyd) Date: Fri, 15 Feb 2008 09:33:02 +1030 Subject: [erlang-questions] Mnesia and the 4Gb Limit Message-ID: <47B4C8A6.3000304@adam.com.au> Hi There, Does Mnesia/Dets still have the 4GB limit? Answers I've found on the 'net seem to indicate that 64bit Erlang has, essentially, erased this limit. I'm looking at a database table that miht be larger than 4Gb; it's already an in memory, MySQL table (MySQL cluster uses an in memory table structure) so I don't seem to have a "lack" of memory [last time I looked the min. memory in any one node on this cluster is 8Gb). DSL From jim Thu Feb 14 08:32:18 2008 From: jim (Jim Larson) Date: Wed, 13 Feb 2008 23:32:18 -0800 Subject: [erlang-questions] Erlounge in San Francisco, 17-22 February In-Reply-To: Your message of "Thu, 14 Feb 2008 00:42:29 +0100." <3dbc6d1c0802131542p4537805erca28764d804c9f0e@mail.gmail.com> Message-ID: <200802140732.m1E7WIEg086878@krumkake.jetcafe.org> In message <3dbc6d1c0802131542p4537805erca28764d804c9f0e> you wr ite: >Reddit offices on 3rd St?* That suits me fine. We could meet there and maybe >go on for beer, for example to the 21st Amendment Brewery which is close. >7.30 pm suit everyone? Sounds great to me. Could someone add the date, in case I'm misremembering? And someone familiar with the area could add a street address, approximate directions from BART, nearest parking, etc. Jim Larson From chandrashekhar.mullaparthi Fri Feb 15 10:21:35 2008 From: chandrashekhar.mullaparthi (Chandru) Date: Fri, 15 Feb 2008 09:21:35 +0000 Subject: [erlang-questions] Mnesia and the 4Gb Limit In-Reply-To: <47B4C8A6.3000304@adam.com.au> References: <47B4C8A6.3000304@adam.com.au> Message-ID: On 14/02/2008, David Lloyd wrote: > > Hi There, > > Does Mnesia/Dets still have the 4GB limit? Answers I've found on the > 'net seem to indicate that 64bit Erlang has, essentially, erased this limit. > > I'm looking at a database table that miht be larger than 4Gb; it's > already an in memory, MySQL table (MySQL cluster uses an in memory table > structure) so I don't seem to have a "lack" of memory [last time I > looked the min. memory in any one node on this cluster is 8Gb). > >From reading the manuals, it looks like dets still has this limit. What 64 bit erlang does is remove the restriction that an erlang node can only address 4GB of memory. This basically means you can have a database of more than 4GB, but *each* mnesia table on disk cannot be more than 2GB. You can use table fragmentation to get around this. I guess this restriction won't apply to mnesia ram_copies tables. I have created databases of up to 15GB without any problem using 64 bit erlang, but they were fragmented disc_copies tables. cheers Chandru From dmitriid Fri Feb 15 09:51:56 2008 From: dmitriid (Dmitrii 'Mamut' Dimandt) Date: Fri, 15 Feb 2008 10:51:56 +0200 Subject: [erlang-questions] Strings as Lists In-Reply-To: <47B1D0AE.5030803@it.uu.se> References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> <47B1D0AE.5030803@it.uu.se> Message-ID: <47B552AC.7070301@gmail.com> Richard Carlsson wrote: > tsuraan wrote: > >> Why does erlang internally represent strings as lists? In every >> language I've used other than Java, a string is a sequence of octets, >> just like Erlang's binary type. I know that you can represent a string >> efficiently by using <<"string">> rather than just "string", but why >> doesn't erlang do this by default? Is it just because pre-12B binary >> handling wasn't as efficient as list handling, or is Erlang intended to >> support UTF-32? >> > > Strings as lists is simple and flexible (i.e., if you already have lists, > you don't need to add another data type). Functions that work on lists, > such as append, reverse, etc., can be used directly on strings; you > don't need to program in different styles if you're traversing a list > or a string; etc. This is only true for ASCII text ;) Non-ASCII gets screwed up badly: lists:reverse("text") %% gives you "txet" lists:reverse("?????") %% Russian for text becomes [130,209,129,209,186,208,181,208,130,209] which is clearly not what I wanted :) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080215/37911ba2/attachment-0001.html From chsu79 Fri Feb 15 10:58:21 2008 From: chsu79 (Christian S) Date: Fri, 15 Feb 2008 10:58:21 +0100 Subject: [erlang-questions] Strings as Lists In-Reply-To: <47B552AC.7070301@gmail.com> References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> <47B1D0AE.5030803@it.uu.se> <47B552AC.7070301@gmail.com> Message-ID: 2008/2/15 Dmitrii 'Mamut' Dimandt : > This is only true for ASCII text ;) Non-ASCII gets screwed up badly: > > lists:reverse("text") %% gives you "txet" > lists:reverse("?????") %% Russian for text becomes > [130,209,129,209,186,208,181,208,130,209] which is clearly not what I wanted > :) This is what you should have in your list: 1> Text = [16#442, 16#435, 16#43a, 16#441, 16#442]. [1090,1077,1082,1089,1090] You can convert it to utf8 for output 2> xmerl_ucs:to_utf8(Text). [209,130,208,181,208,186,209,129,209,130] And you can reverse it and convert that to utf8. 3> xmerl_ucs:to_utf8(lists:reverse(Text)). [209,130,209,129,208,186,208,181,209,130] From dmitriid Tue Feb 12 08:48:09 2008 From: dmitriid (Dmitrii 'Mamut' Dimandt) Date: Tue, 12 Feb 2008 09:48:09 +0200 Subject: [erlang-questions] Documentation build process: creating DocBook XML? In-Reply-To: References: <8EDCB178-4069-4F2B-A5BF-385C1D5D0565@bway.net> Message-ID: <47B14F39.9080509@gmail.com> > I am well aware of DocBook it is a huge DTD. The possibility to use > existing backends for docbook to generate html and pdf could be > interesting. > But when I searched around for such backends a year or two ago I did not find > anything that was attractive enough. > > I followed the link above to the PHP doc and I was not impressed by > the format. The idea with > notes from readers is nice but would't a type of Wiki be nicer? > What else is so much better in the php doc's format? > > The number one advantage is ease of use and search engine optimization: http://www.p16blog.com/p16/2008/02/erlang-document.html It would be oh so nice to be able to just type in, say, http://erlang.org/doc/io:format or http://erlang.org/doc/io/format or http://erlang.org/doc/format and get the function or a list with suggestions (see, e.g., http://php.net/sprintf and http://php.net/sprint to see how it works for PHP) From dgud Fri Feb 15 10:59:40 2008 From: dgud (Dan Gudmundsson) Date: Fri, 15 Feb 2008 10:59:40 +0100 Subject: [erlang-questions] Mnesia and the 4Gb Limit In-Reply-To: References: <47B4C8A6.3000304@adam.com.au> Message-ID: <47B5628C.9010802@erix.ericsson.se> Only tables with storage 'disc_only_copies' uses dets, disc_copies uses disk_log to store the data. /Dan Chandru wrote: > On 14/02/2008, David Lloyd wrote: >> Hi There, >> >> Does Mnesia/Dets still have the 4GB limit? Answers I've found on the >> 'net seem to indicate that 64bit Erlang has, essentially, erased this limit. >> >> I'm looking at a database table that miht be larger than 4Gb; it's >> already an in memory, MySQL table (MySQL cluster uses an in memory table >> structure) so I don't seem to have a "lack" of memory [last time I >> looked the min. memory in any one node on this cluster is 8Gb). >> > >>From reading the manuals, it looks like dets still has this limit. > What 64 bit erlang does is remove the restriction that an erlang node > can only address 4GB of memory. This basically means you can have a > database of more than 4GB, but *each* mnesia table on disk cannot be > more than 2GB. You can use table fragmentation to get around this. I > guess this restriction won't apply to mnesia ram_copies tables. > > I have created databases of up to 15GB without any problem using 64 > bit erlang, but they were fragmented disc_copies tables. > > cheers > Chandru > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > From rdoering Fri Feb 15 11:20:43 2008 From: rdoering (Ralf Doering) Date: Fri, 15 Feb 2008 11:20:43 +0100 Subject: [erlang-questions] regexp:match crashes emulator Message-ID: <87zlu2v7us.fsf@netsys-it.de> Hi, after having a typo in my code I observed that incorrect quoting in regular expressions leeds to an endless loop in regexp:match, finally crashing emulator due to out of memory. Suppose I like to match strings starting with "*", and got regular expression wrong: "^\*" instead of "^\\*". Using this, I get a cpu loaded at 100% for some time and finally a crash. ,---- | Erlang (BEAM) emulator version 5.6.1 [source] [smp:2] [async-threads:0] [hipe] [kernel-poll:false] | | Eshell V5.6.1 (abort with ^G) | 1> regexp:match("*A", "^\*"). | | Crash dump was written to: erl_crash.dump | eheap_alloc: Cannot allocate 583848200 bytes of memory (of type "heap"). | Aborted (core dumped) `---- This happens with both R12B-1 and R11B-5. Is there any way to fix this? TIA, Ralf From richardc Fri Feb 15 11:27:47 2008 From: richardc (Richard Carlsson) Date: Fri, 15 Feb 2008 11:27:47 +0100 Subject: [erlang-questions] Strings as Lists In-Reply-To: <47B552AC.7070301@gmail.com> References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> <47B1D0AE.5030803@it.uu.se> <47B552AC.7070301@gmail.com> Message-ID: <47B56923.9010800@it.uu.se> Dmitrii 'Mamut' Dimandt wrote: > Richard Carlsson wrote: >> Strings as lists is simple and flexible (i.e., if you already have lists, >> you don't need to add another data type). Functions that work on lists, >> such as append, reverse, etc., can be used directly on strings; you >> don't need to program in different styles if you're traversing a list >> or a string; etc. > This is only true for ASCII text ;) Non-ASCII gets screwed up badly: > > lists:reverse("text") %% gives you "txet" > lists:reverse("?????") %% Russian for text becomes > [130,209,129,209,186,208,181,208,130,209] which is clearly not what I > wanted :) That's because the second line is currently not a legal Erlang program. The tokenizer will assume that your source code is encoded using Latin-1, and since you are giving the compiler garbage input, it gives you garbage output. Basically, the compiler thinks that you wrote "?\202?????\201?\202", not "?????", and the reverse of that is indeed "\202?\201?????\202?", which is what you got (regardless of what you _wanted_). What Erlang needs to support non Latin-1 languages, is filters for decoding input and encoding output. (Right now, you have to write the conversion functions yourself if you want to work with Russian text.) The internal string representation - lists of integers using one integer per code point - needs no modification, whether it's ASCII, Latin-1, or Unicode; what I said before applies equally well to all of them. Multibyte encodings are not practical for general string manipulations regardless of how they are stored in memory. /Richard From ulf.wiger Fri Feb 15 11:48:22 2008 From: ulf.wiger (Ulf Wiger (TN/EAB)) Date: Fri, 15 Feb 2008 11:48:22 +0100 Subject: [erlang-questions] Mnesia and the 4Gb Limit In-Reply-To: <47B5628C.9010802@erix.ericsson.se> References: <47B4C8A6.3000304@adam.com.au> <47B5628C.9010802@erix.ericsson.se> Message-ID: <47B56DF6.5030804@ericsson.com> Dan Gudmundsson skrev: > Only tables with storage 'disc_only_copies' uses dets, > disc_copies uses disk_log to store the data. > > /Dan Looking back at this experiment: http://www.erlang.org/pipermail/erlang-questions/2005-November/017728.html I can't recall whether I actually put more than 10 GB into one single disc_copy table. From the text, it appears as if it was more than 10 GB in RAM, but less than 4G on disk. Still, it gives an idea of the kind of characteristics you can get. BR, Ulf W > > Chandru wrote: >> On 14/02/2008, David Lloyd wrote: >>> Hi There, >>> >>> Does Mnesia/Dets still have the 4GB limit? Answers I've found on the >>> 'net seem to indicate that 64bit Erlang has, essentially, erased this limit. >>> >>> I'm looking at a database table that miht be larger than 4Gb; it's >>> already an in memory, MySQL table (MySQL cluster uses an in memory table >>> structure) so I don't seem to have a "lack" of memory [last time I >>> looked the min. memory in any one node on this cluster is 8Gb). >>> >> >From reading the manuals, it looks like dets still has this limit. >> What 64 bit erlang does is remove the restriction that an erlang node >> can only address 4GB of memory. This basically means you can have a >> database of more than 4GB, but *each* mnesia table on disk cannot be >> more than 2GB. You can use table fragmentation to get around this. I >> guess this restriction won't apply to mnesia ram_copies tables. >> >> I have created databases of up to 15GB without any problem using 64 >> bit erlang, but they were fragmented disc_copies tables. >> >> cheers >> Chandru >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions From bjorn Fri Feb 15 12:01:55 2008 From: bjorn (Bjorn Gustavsson) Date: 15 Feb 2008 12:01:55 +0100 Subject: [erlang-questions] Strings as Lists In-Reply-To: <47B56923.9010800@it.uu.se> References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> <47B1D0AE.5030803@it.uu.se> <47B552AC.7070301@gmail.com> <47B56923.9010800@it.uu.se> Message-ID: Richard Carlsson writes: > What Erlang needs to support non Latin-1 languages, is filters for decoding > input and encoding output. (Right now, you have to write the conversion > functions yourself if you want to work with Russian text.) The internal > string representation - lists of integers using one integer per code > point - needs no modification, whether it's ASCII, Latin-1, or Unicode; > what I said before applies equally well to all of them. Multibyte encodings > are not practical for general string manipulations regardless of how they > are stored in memory. I can confirm that is possible to use lists of Unicode characters, and quite easy too. In Wings 3D, I have implemented my own limited support for Unicode. 1. To translate lists of UTF-8 characters to lists of Unicode characters, there is the function wings_util:expand_utf8/1. (Wings keeps all text strings for other languages than English in text files, which are read as needed. If you want to have Russian text in strings in the actual source code files, you could write a simple parse transform to handle the translation.) 2. As a simple replacement for io:format/2, there is wings_util:format/2 which doesn't have all the functionality of io:format/2, but allows arguments to ~s to be lists containing Unicode characters. 3. For output, Wings has its own fonts and font handling (meaning that Wings has no need to translate back to UTF-8 on output). /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From ulf.wiger Fri Feb 15 12:20:46 2008 From: ulf.wiger (Ulf Wiger (TN/EAB)) Date: Fri, 15 Feb 2008 12:20:46 +0100 Subject: [erlang-questions] code dependency diagrams Message-ID: <47B5758E.40503@ericsson.com> I've mentioned on occasion that I'd like to see a visualization tool that shows an UML-style structure diagram for Erlang applications, but with annotations showing the direction and arity of the dependencies. Why? Because in some communities, you clearly don't understand modeling unless you can show a pictured of named boxes stringed together, but also because this sort of thing could be useful, if it also takes the opportunity to show the degree of dependency between two blocks of code. Writing code that counts dependencies between heaps of beam files is not difficult. It's quite possible that xref does it out of the box, but the xref manual is so scary that I can't bring myself to use it (a bit like others seem to feel about xmerl, I guess...) So I wrote my own little module to start with (I can provide it on request, but it's not interesting enough to burden the mailing list with). It will spit out things like: 3> depends:cycles(1157). [{"acc_ch","ccpc_gen",5,0}, {"agm_om","hcfa_gen",10,0}, {"agm_om","oms1",10,0}, {"agm_om","rcmKernel",2,0}, {"agm_om","sys1",4,0}, {"agm_om","sysCmd",1,0}, where 1157 in this case is an ets table, and the output is [{AppA, AppB, CallsAtoB, CallsBtoA}], and what's counted is really how many /modules/ have some dependency to some module in the other application. Obviously, there are other ways to measure the degree of dependency, but this is also not that interesting for now. (: (Running it on OTP really does reveal a few cyclical dependencies, mainly between stdlib and kernel, but also e.g. mnesia and snmp.) Now to the real challenge: drawing the &#*! chart. I made an attempt at using GraphViz, and generated a Dot file like this one: ================================================= digraph G { subgraph cluster_ags { style=filled; color=lightgrey; node [style=filled, color=white]; label = "ags"; } subgraph cluster_syf { style=filled; color=lightgrey; node [style=filled, color=white]; label = "syf"; } acc_ch -> ccpc_gen [headlabel = 5];ctxt_ch -> ccpc_gen [headlabel = 1];ctxt_ch -> sysCmd [headlabel = 8];} ================================================= ...then converted it to SVG using some WinGraphViz demo program. This worked reasonably well for small numbers of applications, but my full example (charting dependencies between two subsystems) had 150 entries, and that turned out a useless graph. Perhaps any block diagram with 150 blocks stringed together will be utterly useless, and the answer is to filter and aggregate the info. Or maybe there are knobs and levers in GraphViz that I have yet to learn about that will give me better layouts...? And now to the question: Which tool would you recommend I use? I looked at Eclipse once, but got the feeling that you won't get anywhere without first writing a thousand or so lines of Java code. Is this still the way to go? Bonus question: does anyone want to play with me on this? BR, Ulf W From masklinn Fri Feb 15 12:06:12 2008 From: masklinn (Masklinn) Date: Fri, 15 Feb 2008 12:06:12 +0100 Subject: [erlang-questions] Strings as Lists In-Reply-To: <47B56923.9010800@it.uu.se> References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> <47B1D0AE.5030803@it.uu.se> <47B552AC.7070301@gmail.com> <47B56923.9010800@it.uu.se> Message-ID: <15A4E683-094E-43D1-BDEE-D16EB936F660@masklinn.net> On 15 Feb 2008, at 11:27 , Richard Carlsson wrote: > Dmitrii 'Mamut' Dimandt wrote: >> Richard Carlsson wrote: >>> Strings as lists is simple and flexible (i.e., if you already have >>> lists, >>> you don't need to add another data type). Functions that work on >>> lists, >>> such as append, reverse, etc., can be used directly on strings; you >>> don't need to program in different styles if you're traversing a >>> list >>> or a string; etc. >> This is only true for ASCII text ;) Non-ASCII gets screwed up badly: >> >> lists:reverse("text") %% gives you "txet" >> lists:reverse("?????") %% Russian for text becomes >> [130,209,129,209,186,208,181,208,130,209] which is clearly not what I >> wanted :) > > That's because the second line is currently not a legal Erlang > program. > The tokenizer will assume that your source code is encoded using > Latin-1, > and since you are giving the compiler garbage input, it gives you > garbage > output. Basically, the compiler thinks that you wrote "? > \202?????\201?\202", > not "?????", and the reverse of that is indeed "\202? > \201?????\202?", > which is what you got (regardless of what you _wanted_). > > What Erlang needs to support non Latin-1 languages, is filters for > decoding > input and encoding output. Yep. How extensive would be the changes to perform to have a configurable tokenizer? Something like Python where you can specify the encoding of your source code if you want something other than the default (which, in python, is ASCII)? From vladdu55 Fri Feb 15 13:32:25 2008 From: vladdu55 (Vlad Dumitrescu) Date: Fri, 15 Feb 2008 13:32:25 +0100 Subject: [erlang-questions] code dependency diagrams In-Reply-To: <47B5758E.40503@ericsson.com> References: <47B5758E.40503@ericsson.com> Message-ID: <95be1d3b0802150432t56caf1e5q4c2ad61559e1426f@mail.gmail.com> Hi! On Fri, Feb 15, 2008 at 12:20 PM, Ulf Wiger (TN/EAB) wrote: > > I've mentioned on occasion that I'd like to see a visualization tool > that shows an UML-style structure diagram for Erlang applications, > but with annotations showing the direction and arity of the > dependencies. I would like to recommend an alternative to this kind of diagram, that offers much better understandability: a Dependency Structure Matrix (DSM). An example image can be found at http://erlide.sourceforge.net/untitled.png There are a few applications using those for software development (none that I am aware of are free, but IntelliJ IDEA has a trial version :-). The idea is to draw a matrix with as many rows and columns as modules and in the cells put the number of dependencies. Ideally, the matrix can be rearranged to have only zeroes above the diagonal. When this is not possible, there are circular dependencies. The rows and columns can be expanded/contracted according to the directory structure, giving a higher-level overview. Double-clicking on a cell could open a list of the dependencies, with links to the actual source code. This is something I will definitely want to include in Erlide, but it will have to wait until the more pressing urgencies are resolved. The missing piece of the puzzle is a graphical DSM component that is and free. best regards, Vlad From dmitriid Fri Feb 15 14:08:20 2008 From: dmitriid (Dmitrii 'Mamut' Dimandt) Date: Fri, 15 Feb 2008 15:08:20 +0200 Subject: [erlang-questions] Documentation build process: creating DocBook XML? In-Reply-To: <18357.34938.691663.177763@antilipe.corelatus.se> References: <8EDCB178-4069-4F2B-A5BF-385C1D5D0565@bway.net> <47B14F39.9080509@gmail.com> <18357.34938.691663.177763@antilipe.corelatus.se> Message-ID: <47B58EC4.9060201@gmail.com> > --- > > Looking at the "user comments" on the PHP site pretty much put me off > any ideas about having "user comments". What a collection of flotsam > and jetsam! > > Matthias > > You wouldn't believe but these comments sometimes do wonders for newbies :) Sometimes they explain the more obscure parts of the docs. However, maintaining the comments section requires a staff with a lot of spare time on their hands. From matthias Fri Feb 15 13:41:30 2008 From: matthias (Matthias Lang) Date: Fri, 15 Feb 2008 13:41:30 +0100 Subject: [erlang-questions] Documentation build process: creating DocBook XML? In-Reply-To: <47B14F39.9080509@gmail.com> References: <8EDCB178-4069-4F2B-A5BF-385C1D5D0565@bway.net> <47B14F39.9080509@gmail.com> Message-ID: <18357.34938.691663.177763@antilipe.corelatus.se> Dmitrii 'Mamut' Dimandt writes: > The number one advantage is ease of use and search engine optimization: > http://www.p16blog.com/p16/2008/02/erlang-document.html One problem with the Erlang documentation which was fixed recently (R12) was that the path to each manpage changed often, i.e. in one release it was www.erlang.org/doc/man/lib/stdlib-1.14.4/doc/html/lists.html and in another it was www.erlang.org/doc/man/lib/stdlib-1.14.3/doc/html/lists.html which is a pretty good way to stop anyone sane from linking to the documentation. That probably also did wonders for ranking, and it'll take while for the effect to wear off. > It would be oh so nice to be able to just type in, say, > http://erlang.org/doc/io:format or http://erlang.org/doc/io/format or > http://erlang.org/doc/format and get the function I have a shell script which does this: ~ >eman io fwr showing file:///usr/local/src/otp_doc_R11B-4/lib/stdlib-1.14.4/doc/html/io.html#fwrite/1 (it pops up the page in the currently running browser). As far as I know, I'm the only user. The web version doesn't get much traffic either. --- Looking at the "user comments" on the PHP site pretty much put me off any ideas about having "user comments". What a collection of flotsam and jetsam! Matthias From ebruno Fri Feb 15 14:28:34 2008 From: ebruno (Eric Bruno) Date: Fri, 15 Feb 2008 07:28:34 -0600 Subject: [erlang-questions] Erlounge in San Francisco, 17-22 February In-Reply-To: <200802140732.m1E7WIEg086878@krumkake.jetcafe.org> References: Your message of "Thu, 14 Feb 2008 00:42:29 +0100." <3dbc6d1c0802131542p4537805erca28764d804c9f0e@mail.gmail.com> <200802140732.m1E7WIEg086878@krumkake.jetcafe.org> Message-ID: Once you have the street address the BART web site www.bart.gov will give you the directions from the closet BART station to/from the address. Eric Bruno 408.495.5525 (voice) ebruno > -----Original Message----- > From: erlang-questions-bounces > [mailto:erlang-questions-bounces] On Behalf Of Jim Larson > Sent: Wednesday, February 13, 2008 11:32 PM > To: Robert Virding > Cc: Erlang > Subject: Re: [erlang-questions] Erlounge in San Francisco, > 17-22 February > > In message > <3dbc6d1c0802131542p4537805erca28764d804c9f0e> you wr > ite: > >Reddit offices on 3rd St?* That suits me fine. We could meet > there and > >maybe go on for beer, for example to the 21st Amendment > Brewery which is close. > >7.30 pm suit everyone? > > Sounds great to me. Could someone add the date, in case I'm > misremembering? And someone familiar with the area could add > a street address, approximate directions from BART, nearest > parking, etc. > > Jim Larson > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > From jakob Fri Feb 15 16:16:25 2008 From: jakob (Jakob Cederlund) Date: Fri, 15 Feb 2008 16:16:25 +0100 Subject: [erlang-questions] asn1 and the new ssl module In-Reply-To: <1ffe809c0802120934r5c580eeas2cb811a7e5c0b170@mail.gmail.com> References: <1ffe809c0802120934r5c580eeas2cb811a7e5c0b170@mail.gmail.com> Message-ID: <47B5ACC9.7010300@erix.ericsson.se> Nope, not yet. Currently, the new ssl (the one you get with {ssl_imp, new}) only supports these packet-options: raw, 1, 2, 4, cdr and line. (Packaging is handled by the function ssl_connection:check_packet/3.) The rest are fairly easy to add, and we hope to do that in the next release. Patches are welcome! :-) /Jakob Pablo Polvorin wrote: > Hi all, > I'm using the new ssl module to "upgrade" a gen_tcp socket to ssl. But > I couldn't find a way to easily receiving asn1 packets from it. > My question is, it's possible to use the {packet,asn1} option when > using the new ssl module?. > > ssl_connection.erl seems to not have any reference to that option. > > Finally I implemented the buffering and packet delimiting code in my > application, but I wonder if there is an easy and early way to > accomplish the same. > regards, > From vladdu55 Fri Feb 15 16:35:46 2008 From: vladdu55 (Vlad Dumitrescu) Date: Fri, 15 Feb 2008 16:35:46 +0100 Subject: [erlang-questions] code dependency diagrams In-Reply-To: References: <47B5758E.40503@ericsson.com> <95be1d3b0802150432t56caf1e5q4c2ad61559e1426f@mail.gmail.com> Message-ID: <95be1d3b0802150735wcef7a93s3adb4aea75d2f31d@mail.gmail.com> Hi, On Fri, Feb 15, 2008 at 4:22 PM, Christophe Romain wrote: > This DSM is really a good idea ! > and when you click on a row/column label, you can display a > conventional dependency graph. If you really want to, yes. The way the IntelliJ tool does it is that it marks with colors the dependents and the antecedents of the selected item. Of course, this works best for people that don't suffer from color blindness, but otherwise it's much more compact. See http://erlide.sf.net/dsm1.png for a snapshot. Dependencies "flow" from green to blue(=current) to yellow. Notice the red "bad guy" too. regards, Vlad -- Some people see things that are and ask, Why? Some people dream of things that never were and ask, Why not? Some people have to go to work and don't have time for all that. --- George Carlin From hasan.veldstra Fri Feb 15 18:35:05 2008 From: hasan.veldstra (Hasan Veldstra) Date: Fri, 15 Feb 2008 17:35:05 +0000 Subject: [erlang-questions] Strings as Lists In-Reply-To: References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> <47B1D0AE.5030803@it.uu.se> <47B552AC.7070301@gmail.com> Message-ID: <2D7249A6-2F28-4FCF-AABA-4DA0617F5C8C@gmail.com> > This is what you should have in your list: > 1> Text = [16#442, 16#435, 16#43a, 16#441, 16#442]. > [1090,1077,1082,1089,1090] > You can convert it to utf8 for output > > 2> xmerl_ucs:to_utf8(Text). > [209,130,208,181,208,186,209,129,209,130] > > And you can reverse it and convert that to utf8. > > 3> xmerl_ucs:to_utf8(lists:reverse(Text)). > [209,130,209,129,208,186,208,181,209,130] This would not work on a string with combining characters, e.g. ? represented as u followed by ?, or a CJKV ideograph. A lot of glyphs *cannot* be represented by a single Unicode codepoint. Plain lists or binaries are good enough in two cases: 1. You don't need to support anything other than ISO Latin-1 (i.e. Western European languages). 2. You don't need to do much with the Unicode text apart from simply storing it and spitting it back to the user as-is. For any other case, what Erlang/OTP offers now is subpar compared to other modern languages / platforms. Implementing Unicode from scratch is nasty, and the DIY attitude is unproductive and dangerous. There needs to be a standard library, used and tested by everyone. As I already mentioned in this thread, I'm working on such a library, and will release an alpha version soon. -- http://12monkeys.co.uk http://hypernumbers.com From masterofquestions Fri Feb 15 18:37:23 2008 From: masterofquestions (db) Date: Fri, 15 Feb 2008 09:37:23 -0800 (PST) Subject: [erlang-questions] compile debug_info smart_expections via autoconf automake? Message-ID: How do you setup configure.ac and Makefile.am to compile erlang programs with debug_info and/or smart_expections flags? My sample test_app setup files are found here: http://groups.google.com/group/erlang-questions/browse_thread/thread/c9df78f87797ff47 From opendev Fri Feb 15 19:24:12 2008 From: opendev (Joern) Date: Fri, 15 Feb 2008 19:24:12 +0100 Subject: [erlang-questions] code dependency diagrams In-Reply-To: <47B5758E.40503@ericsson.com> References: <47B5758E.40503@ericsson.com> Message-ID: <9e009ad0802151024m22c293f2u38bc3fe09f1a591@mail.gmail.com> Hi Ulf, On 15/02/2008, Ulf Wiger (TN/EAB) wrote: > And now to the question: Which tool would you recommend I use? > I looked at Eclipse once, but got the feeling that you won't get > anywhere without first writing a thousand or so lines of Java code. > Is this still the way to go? The yed package[1] (Java) might be a better alternative - the GraphML XML it supports (among other inputs formats) does not a look that scary and it's pretty versatile when it comes to automatic layout. There also is an Eclipse integration. I never used the latter but yed is a quite nice package. I am somewhat interested in the topic as well so if my time permits I am willing to throw your dependency graph data against a yet to be written converter (or XLST). Best regards from Berlin, Joern [1]: http://www.yworks.com/en/products_yed_about.html From dmercer Fri Feb 15 19:51:19 2008 From: dmercer (David Mercer) Date: Fri, 15 Feb 2008 12:51:19 -0600 Subject: [erlang-questions] Strings as Lists In-Reply-To: <2D7249A6-2F28-4FCF-AABA-4DA0617F5C8C@gmail.com> References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com><47B1D0AE.5030803@it.uu.se> <47B552AC.7070301@gmail.com> <2D7249A6-2F28-4FCF-AABA-4DA0617F5C8C@gmail.com> Message-ID: <010a01c87003$c1154ab0$891ea8c0@SSI.CORP> Out of curiosity, besides as an academic exercise and a point of debate, what is the practical use of reversing a string? I've been programming for a quarter century and am having trouble remembering when I last needed to reverse a string. Search? yes; compare? yes; substitute? yes; modify? yes. Just can't think of when I've needed to reverse a string. Is there some common protocol that requires you to send Unicode strings in reverse order or something? Cheers, DBM From kevin Fri Feb 15 20:20:14 2008 From: kevin (Kevin Scaldeferri) Date: Fri, 15 Feb 2008 11:20:14 -0800 Subject: [erlang-questions] Strings as Lists In-Reply-To: References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> <2F5E96D5-CF7A-42AC-B04E-CB8183F7AB7D@masklinn.net> <3dbc6d1c0802121413o7480d2abtc913801ceae67e8e@mail.gmail.com> <14EEE3D7-56F1-470A-BCE5-C5B534A6EF88@scaldeferri.com> <972E01DC-2A4D-4EB8-B483-CFD98AB6E87F@cs.otago.ac.nz> <1202974658.4369.24.camel@piko.site> Message-ID: <518CB40F-9028-4068-B6F7-C612253B6FDE@scaldeferri.com> On Feb 14, 2008, at 7:06 PM, Richard A. O'Keefe wrote: > I wrote: >>> No, it has to do with the fact that appending on the right is O(n) >>> whether one uses lists or arrays. > > Since this is the *Erlang* mailing list, this should have been read as > "whether one uses (immutable) lists or (immutable) arrays". > > On 14 Feb 2008, at 8:37 pm, Alp?r J?ttner wrote: >> A minor correction: appending at the end of an array >> (std::vector<>) is >> O(1) operation in C++. > > std::vector<> is not a class of immutable arrays. > Suppose we have two byte-strings of length n and m. > If they are immutable, the concatenation cost is O(n+m). > If you are willing to smash the one on the left, and it is "stretchy", > the cost is STILL not O(1), it is O(m). Pardon my ignorance, but how it is that concatenating to the end of a length n immutable list is not O(n)? Isn't it necessary to copy all the list elements? (It's also worth noting that while strictly speaking the append on a mutable array is O(m), in practice the coefficient is very small since it's implemented as a single memcpy.) -kevin From raould Fri Feb 15 21:05:26 2008 From: raould (Raoul Duke) Date: Fri, 15 Feb 2008 12:05:26 -0800 Subject: [erlang-questions] Erlounge in San Francisco, 17-22 February In-Reply-To: <200802140732.m1E7WIEg086878@krumkake.jetcafe.org> References: <3dbc6d1c0802131542p4537805erca28764d804c9f0e@mail.gmail.com> <200802140732.m1E7WIEg086878@krumkake.jetcafe.org> Message-ID: <91a2ba3e0802151205t6db6ed68y59c50d1d95d31bc4@mail.gmail.com> I am under the impression it is this coming Monday the 18th. On Wed, Feb 13, 2008 at 11:32 PM, Jim Larson wrote: > In message <3dbc6d1c0802131542p4537805erca28764d804c9f0e> you wr > ite: > > >Reddit offices on 3rd St?* That suits me fine. We could meet there and maybe > >go on for beer, for example to the 21st Amendment Brewery which is close. > >7.30 pm suit everyone? > > Sounds great to me. Could someone add the date, in case I'm > misremembering? And someone familiar with the area could add > a street address, approximate directions from BART, nearest > parking, etc. > > Jim Larson > > > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > From robi123 Fri Feb 15 21:16:17 2008 From: robi123 (Robin) Date: Fri, 15 Feb 2008 12:16:17 -0800 (PST) Subject: [erlang-questions] blocking vs non-blocking gen_tcp:accept() Message-ID: Does gen_tcp:accept() block the entire OS thread or just the calling erlang process? "One of the shortcomings of the gen_tcp module is that it only exports interface to a blocking accept call." -> http://www.trapexit.org/Building_a_Non-blocking_TCP_server_using_OTP_principles Does the performance gain of non-blocking accept justify the added complexity (finite state machine etc)? thanks, Robin From als Fri Feb 15 20:13:33 2008 From: als (Anthony Shipman) Date: Sat, 16 Feb 2008 06:13:33 +1100 Subject: [erlang-questions] Strings as Lists In-Reply-To: <2D7249A6-2F28-4FCF-AABA-4DA0617F5C8C@gmail.com> References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> <2D7249A6-2F28-4FCF-AABA-4DA0617F5C8C@gmail.com> Message-ID: <200802160613.33988.als@iinet.net.au> On Sat, 16 Feb 2008 04:35:05 am Hasan Veldstra wrote: > > This would not work on a string with combining characters, e.g. ? > represented as u followed by ?, or a CJKV ideograph. > > A lot of glyphs *cannot* be represented by a single Unicode codepoint. > > Plain lists or binaries are good enough in two cases: > 1. You don't need to support anything other than ISO Latin-1 (i.e. > Western European languages). > 2. You don't need to do much with the Unicode text apart from simply > storing it and spitting it back to the user as-is. How about this: A string is a list of characters. A character is one or more Unicode code points. A single code point can be represented by an integer. Multiple code points can be represented by a tuple. A list wouldn't be good as flatten would then destroy this structure. Utility functions convert between UTF8 in binaries and this structure. -- Anthony Shipman Mamas don't let your babies als grow up to be outsourced. From qrilka Fri Feb 15 21:42:49 2008 From: qrilka (Kirill Zaborski) Date: Fri, 15 Feb 2008 23:42:49 +0300 Subject: [erlang-questions] code dependency diagrams In-Reply-To: <9e009ad0802151024m22c293f2u38bc3fe09f1a591@mail.gmail.com> References: <47B5758E.40503@ericsson.com> <9e009ad0802151024m22c293f2u38bc3fe09f1a591@mail.gmail.com> Message-ID: <337538cb0802151242y28394552i1bdd71f4cc80f219@mail.gmail.com> BTW does anyone use some statndard (e.g. UML) diagrams for designing Erlang programs? Best regards, Kirill On Feb 15, 2008 9:24 PM, Joern wrote: > Hi Ulf, > > On 15/02/2008, Ulf Wiger (TN/EAB) wrote: > > > And now to the question: Which tool would you recommend I use? > > I looked at Eclipse once, but got the feeling that you won't get > > anywhere without first writing a thousand or so lines of Java code. > > Is this still the way to go? > > The yed package[1] (Java) might be a better alternative - the GraphML > XML it supports (among other inputs formats) does not a look that > scary and it's pretty versatile when it comes to automatic layout. > There also is an Eclipse integration. I never used the latter but yed > is a quite nice package. I am somewhat interested in the topic as well > so if my time permits I am willing to throw your dependency graph data > against a yet to be written converter (or XLST). > > Best regards from Berlin, > > > Joern > > [1]: http://www.yworks.com/en/products_yed_about.html > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > From vlm Fri Feb 15 21:45:45 2008 From: vlm (Lev Walkin) Date: Fri, 15 Feb 2008 12:45:45 -0800 Subject: [erlang-questions] Strings as Lists In-Reply-To: <010a01c87003$c1154ab0$891ea8c0@SSI.CORP> References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com><47B1D0AE.5030803@it.uu.se> <47B552AC.7070301@gmail.com> <2D7249A6-2F28-4FCF-AABA-4DA0617F5C8C@gmail.com> <010a01c87003$c1154ab0$891ea8c0@SSI.CORP> Message-ID: <47B5F9F9.8040900@lionet.info> David Mercer wrote: > Out of curiosity, besides as an academic exercise and a point of debate, > what is the practical use of reversing a string? I've been programming for > a quarter century and am having trouble remembering when I last needed to > reverse a string. Search? yes; compare? yes; substitute? yes; modify? yes. > Just can't think of when I've needed to reverse a string. Is there some > common protocol that requires you to send Unicode strings in reverse order > or something? When you need to do a manipulation on string in constant length, you need reverse. For example, to_upper() can be implemented as to_upper(L) = foldr(fun(C, A) -> [char_upper(C) | A] end, [], L). or to_upper(L) = map(fun char_upper/1, L). of which both both have O(n) space requirement, or via to_upper(L) = lists:reverse(to_upper(L, [])) to_upper([], Acc) -> Acc; to_upper([C|T], Acc) -> to_upper(T, [char_upper(T)|Acc]). which is O(n) in space. Both are O(n) in time, though with different coefficients. -- Lev Walkin vlm From samuel Fri Feb 15 21:54:05 2008 From: samuel (Samuel Tesla) Date: Fri, 15 Feb 2008 14:54:05 -0600 Subject: [erlang-questions] blocking vs non-blocking gen_tcp:accept() In-Reply-To: References: Message-ID: <4bd555f70802151254j4bfbfd5p26b491ce3d65304a@mail.gmail.com> Robin: Sorry if you got this twice, I realized just after I hit send that I had only replied to you. It only blocks the Erlang process, I believe. I've been meaning to post some code examples about this. What's always bugged me about that article is that it relies on prim_inet which is not guaranteed at all to remain the same across releases, whereas gen_tcp is (or at least guaranteed to be squawked about). I've written several TCP servers for personal projects, and I have found that there's no need to use anything but gen_tcp:accept (with a timeout). Here's an example of using gen_tcp:accept/2 in a gen_server that operates similarly to the one in that walkthrough. %% BEGIN CODE %% -module(tcp_lister). -behaviour(gen_server). -export([start_link/3]). -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]). -define(TCP_ACCEPT_TIMEOUT, 10000). -record(state, { listen, % listening socket sup % supervisor for client proxies }). start_link(Port, Opts, Sup) when is_integer(Port), is_list(Opts), is_atom(Sup) -> gen_server:start_link(?MODULE, [Port, Opts, Sup], []). init([Port, Opts, Sup]) -> {ok, Listen} = gen_tcp:listen(Port, Opts), State = #state{listen=Listen, sup=Sup}, gen_server:cast(self(), accept), ?MODULE:accept(), {ok, State}. handle_call(Request, From, State) -> {stop, {unknown_call, {Request, From}}, State}. handle_cast(accept, State) -> #state{listen=Listen, sup=Sup} = State, case gen_tcp:accept(Listen, ?TCP_ACCEPT_TIMEOUT) of {ok, Socket} -> Sup:start_client(Socket); {error, timeout} -> ok end, gen_server:cast(self(), accept), {noreply, State}; handle_cast(Msg, State) -> {stop, {unknown_cast, Msg}, State}. handle_info(Info, State) -> {stop, {unknown_info, Info}, State}. terminate(_Reason, _State) -> ok. code_change(_OldVsn, State, _Extra) -> {ok, State}. %% END CODE %% Then Sup:start_link/1 looks like this: %% BEGIN CODE %% start_client(Socket) -> {ok, Pid} = supervisor:start_child(?MODULE, []), gen_tcp:controlling_process(Socket, Pid), ok = client_module:set_socket(Pid, Socket), ok. %% END CODE %% And client_module:set_socket just lets the newly spawned process know what it's socket is just like in the trapexit article. There's several things this code doesn't handle. It could get other errors such as EMFILE or ENFILE from gen_tcp:accept/2. But in those cases the gen_server will blow up and get logged and the supervisor will do something appropriate. There is a brief moment during which sockets will sit idle in the buffer, but seriously, it's brief. The key thing here is that you're using gen_tcp:accept/2, so you won't be blocking the process forever. That means that the process will eventually loop through and check it's mailbox again and can handle all of the fun supervision-tree stuff gen_server does behind the scenes. Hope this helps! -- Samuel On Fri, Feb 15, 2008 at 2:16 PM, Robin wrote: > Does gen_tcp:accept() block the entire OS thread or just the calling > erlang process? > > "One of the shortcomings of the gen_tcp module is that it only exports > interface to a blocking accept call." -> > > http://www.trapexit.org/Building_a_Non-blocking_TCP_server_using_OTP_principles > > Does the performance gain of non-blocking accept justify the added > complexity (finite state machine etc)? > > thanks, > > Robin > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080215/7b212ed0/attachment-0001.html From dmercer Fri Feb 15 22:34:01 2008 From: dmercer (David Mercer) Date: Fri, 15 Feb 2008 15:34:01 -0600 Subject: [erlang-questions] Strings as Lists In-Reply-To: <47B5F9F9.8040900@lionet.info> References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com><47B1D0AE.5030803@it.uu.se> <47B552AC.7070301@gmail.com> <2D7249A6-2F28-4FCF-AABA-4DA0617F5C8C@gmail.com> <010a01c87003$c1154ab0$891ea8c0@SSI.CORP> <47B5F9F9.8040900@lionet.info> Message-ID: <011101c8701a$7be73630$891ea8c0@SSI.CORP> > When you need to do a manipulation on string in constant length, > you need reverse. For example, to_upper() can be implemented as My question was in regards to reversing strings, not lists of characters. Specifically, Hasan Veldstra's complaint that representing strings as lists doesn't work when you use lists:reverse to reverse them: > This would not work on a string with combining characters, e.g. ? > represented as u followed by ?, or a CJKV ideograph. > > A lot of glyphs *cannot* be represented by a single Unicode codepoint. Your example is a case on "unreversing" a reversal done during the up-casing process. My guess is that in the "? represented as u followed by ?" case, it would work just right: the "u" would be up-cased to "U", and the "?" would follow capital "U" (following the list:reverse to unreverse the list). I don't think up-casing a CJKV ideograph makes any sense, so you'd probably end up with the same string you started with. So the question goes back to Mr. Veldstra (or anyone) as to why you would want to reverse a Unicode string (unless it is to unreverse a previous algorithmic reversal, in which case we have no problem with combining characters). -----Original Message----- From: Lev Walkin [mailto:vlm] Sent: Friday, February 15, 2008 14:46 To: dmercer Cc: 'Erlang Questions' Subject: Re: [erlang-questions] Strings as Lists David Mercer wrote: > Out of curiosity, besides as an academic exercise and a point of debate, > what is the practical use of reversing a string? I've been programming for > a quarter century and am having trouble remembering when I last needed to > reverse a string. Search? yes; compare? yes; substitute? yes; modify? yes. > Just can't think of when I've needed to reverse a string. Is there some > common protocol that requires you to send Unicode strings in reverse order > or something? When you need to do a manipulation on string in constant length, you need reverse. For example, to_upper() can be implemented as to_upper(L) = foldr(fun(C, A) -> [char_upper(C) | A] end, [], L). or to_upper(L) = map(fun char_upper/1, L). of which both both have O(n) space requirement, or via to_upper(L) = lists:reverse(to_upper(L, [])) to_upper([], Acc) -> Acc; to_upper([C|T], Acc) -> to_upper(T, [char_upper(T)|Acc]). which is O(n) in space. Both are O(n) in time, though with different coefficients. -- Lev Walkin vlm From matthias Fri Feb 15 21:45:02 2008 From: matthias (Matthias Lang) Date: Fri, 15 Feb 2008 21:45:02 +0100 Subject: [erlang-questions] blocking vs non-blocking gen_tcp:accept() In-Reply-To: References: Message-ID: <18357.63950.182578.119672@antilipe.corelatus.se> Robin writes: > Does gen_tcp:accept() block the entire OS thread or just the calling > erlang process? Just the erlang process. (verifying this yourself is straightforward) > "One of the shortcomings of the gen_tcp module is that it only exports > interface to a blocking accept call." -> > http://www.trapexit.org/Building_a_Non-blocking_TCP_server_using_OTP_principles > > Does the performance gain of non-blocking accept justify the added > complexity (finite state machine etc)? I think the point the author of the trapexit article wanted to make was that the accept-blocks-the-calling-erlang-process design in gen_tcp means that you need an extra erlang process in your code. Matt From matthias Fri Feb 15 21:54:00 2008 From: matthias (Matthias Lang) Date: Fri, 15 Feb 2008 21:54:00 +0100 Subject: [erlang-questions] Strings as Lists In-Reply-To: <010a01c87003$c1154ab0$891ea8c0@SSI.CORP> References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> <47B1D0AE.5030803@it.uu.se> <47B552AC.7070301@gmail.com> <2D7249A6-2F28-4FCF-AABA-4DA0617F5C8C@gmail.com> <010a01c87003$c1154ab0$891ea8c0@SSI.CORP> Message-ID: <18357.64488.259860.404741@antilipe.corelatus.se> David Mercer writes: > Out of curiosity, besides as an academic exercise and a point of debate, > what is the practical use of reversing a string? I've been programming for > a quarter century and am having trouble remembering when I last needed to > reverse a string. Search? yes; compare? yes; substitute? yes; modify? yes. > Just can't think of when I've needed to reverse a string. Is there some > common protocol that requires you to send Unicode strings in reverse order > or something? Many tail-recursive algorithms produce reversed lists, so you need lists:reverse/1 to put them back again at the end. Typical example: to_upper(List) -> Rev = to_upper(List, []), lists:reverse(Rev). to_upper([H|T], Acc) -> to_upper(T, [H band bnot 16#20|Acc]); to_upper([], Acc) -> Acc. Yes, there are other ways of writing to_upper/1. Yes, I could have put a guard on it. Yes, I can hear the non-ASCII people grinding their teeth over the band bnot No, the lists:reverse/1 does not change the big O Matt From richardc Fri Feb 15 23:17:56 2008 From: richardc (Richard Carlsson) Date: Fri, 15 Feb 2008 23:17:56 +0100 Subject: [erlang-questions] Strings as Lists In-Reply-To: <010a01c87003$c1154ab0$891ea8c0@SSI.CORP> References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com><47B1D0AE.5030803@it.uu.se> <47B552AC.7070301@gmail.com> <2D7249A6-2F28-4FCF-AABA-4DA0617F5C8C@gmail.com> <010a01c87003$c1154ab0$891ea8c0@SSI.CORP> Message-ID: <47B60F94.2080001@it.uu.se> David Mercer wrote: > Out of curiosity, besides as an academic exercise and a point of debate, > what is the practical use of reversing a string? I've been programming for > a quarter century and am having trouble remembering when I last needed to > reverse a string. Search? yes; compare? yes; substitute? yes; modify? yes. > Just can't think of when I've needed to reverse a string. Is there some > common protocol that requires you to send Unicode strings in reverse order > or something? Well, sometimes you do need to trick certain imps to go back to the dimension they came from. (http://en.wikipedia.org/wiki/Mister_Mxyzptlk) Apart from that, there is not much real use for reversed strings. drahciR\ From tony Fri Feb 15 23:00:55 2008 From: tony (Tony Rogvall) Date: Fri, 15 Feb 2008 23:00:55 +0100 Subject: [erlang-questions] blocking vs non-blocking gen_tcp:accept() In-Reply-To: References: Message-ID: <63A37F62-8C4D-4417-85B0-606B7802A71D@rogvall.se> The only way (tm) to block the OS thread is to write your own loadable driver and sleep for a while. /Tony On 15 feb 2008, at 21.16, Robin wrote: > Does gen_tcp:accept() block the entire OS thread or just the calling > erlang process? > > "One of the shortcomings of the gen_tcp module is that it only exports > interface to a blocking accept call." -> > http://www.trapexit.org/Building_a_Non-blocking_TCP_server_using_OTP_principles > > Does the performance gain of non-blocking accept justify the added > complexity (finite state machine etc)? > > thanks, > > Robin > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions From hasan.veldstra Sat Feb 16 00:02:31 2008 From: hasan.veldstra (Hasan Veldstra) Date: Fri, 15 Feb 2008 23:02:31 +0000 Subject: [erlang-questions] Strings as Lists In-Reply-To: <011101c8701a$7be73630$891ea8c0@SSI.CORP> References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com><47B1D0AE.5030803@it.uu.se> <47B552AC.7070301@gmail.com> <2D7249A6-2F28-4FCF-AABA-4DA0617F5C8C@gmail.com> <010a01c87003$c1154ab0$891ea8c0@SSI.CORP> <47B5F9F9.8040900@lionet.info> <011101c8701a$7be73630$891ea8c0@SSI.CORP> Message-ID: <7908FBA0-BDA2-4CFF-A975-96245D71B374@gmail.com> David, > My question was in regards to reversing strings, not lists of > characters. > Specifically, Hasan Veldstra's complaint that representing strings > as lists > doesn't work when you use lists:reverse to reverse them: That wasn't what I said. I gave an example of when a string reversal would fail as a consequence of treating Unicode codepoints as characters ("characters" from user's point of view, not how Unicode defines "characters"). >> This would not work on a string with combining characters, e.g. ? >> represented as u followed by ?, or a CJKV ideograph. >> >> A lot of glyphs *cannot* be represented by a single Unicode >> codepoint. > > Your example is a case on "unreversing" a reversal done during the > up-casing > process. Sorry, I'm not following you here. I didn't even mention upcasing in my last message. > My guess is that in the "? represented as u followed by ?" case, > it would > work just right: the "u" would be up-cased to "U", and the "?" > would follow > capital "U" (following the list:reverse to unreverse the list). Yes, maybe this would work, thanks to Erlang's awareness of Western European scripts. How would you convert this string to uppercase in Erlang though: "???????? ?????"? With libraries that are available now, it's impossible. How about doing case-insensitive comparisons of strings containing Russian text? Or even doing a case-insensitive comparison of "stra?e" and "STRASSE"? Again, no library support. Or how about comparing two strings that look identical when printed, but one of them contains the pre-composed "?" character, while the other contains "u" followed by "?"? Again, you can't do this and similar comparisons reliably using plain lists. Unless you implement Unicode from scratch yourself, of course. > I don't think up-casing a CJKV ideograph makes any sense I know little about East Asian scripts, and I don't know if they have the uppercase/lowercase distinction, but I never said you'd want to upcase a CJKV ideograph. > So the question goes back to Mr. Veldstra (or anyone) as to why you > would > want to reverse a Unicode string I don't know. String reversal was a convenient example for the point I was trying to make. -- http://12monkeys.co.uk http://hypernumbers.com From chsu79 Sat Feb 16 00:33:44 2008 From: chsu79 (Christian S) Date: Sat, 16 Feb 2008 00:33:44 +0100 Subject: [erlang-questions] code dependency diagrams In-Reply-To: <337538cb0802151242y28394552i1bdd71f4cc80f219@mail.gmail.com> References: <47B5758E.40503@ericsson.com> <9e009ad0802151024m22c293f2u38bc3fe09f1a591@mail.gmail.com> <337538cb0802151242y28394552i1bdd71f4cc80f219@mail.gmail.com> Message-ID: On Feb 15, 2008 9:42 PM, Kirill Zaborski wrote: > BTW does anyone use some statndard (e.g. UML) diagrams for designing > Erlang programs? Also did anyone begin to use http://www.fmc-modeling.org/quick-intro that ulf w himself mentioned on the list months ago? It really looked good for Erlang. From dbarker Fri Feb 15 23:17:35 2008 From: dbarker (Deryk Barker) Date: Fri, 15 Feb 2008 14:17:35 -0800 Subject: [erlang-questions] UTF8 In-Reply-To: <3dbc6d1c0802131444u2816a661oac7e1c4520b86e59@mail.gmail.com> References: <23def8000802112053i70dec636kadb9ec56b13772f0@mail.gmail.com> <23def8000802120821u79dd458vbe0d9689f281697a@mail.gmail.com> <944da41d0802130053s67119d5ewc75de9bff40ccfa0@mail.gmail.com> <3dbc6d1c0802131444u2816a661oac7e1c4520b86e59@mail.gmail.com> Message-ID: <47B60F7F.8080207@camosun.bc.ca> Robert Virding wrote: > It is if they had kept of the old 9-bit bytes (characters) from DEC-10 > days. In those days you also had a real ctrl-key which set the 9th > bit. :-) Not a universal feature of the 9-bit byte, though. I worked on all three Honeywell (formerly GE and Xerox) 36-bit operating systems. The 36-bit word was divided into four 9-bit bytes, but terminals transmitted ASCII and the control key had its usual function. What was really fun was packed decimal: you could get eight 4-bit packed decimal digits into a 36-bit word, as they were packed two to a byte, so each byte consisted of 1 unused bit and two 4-bit digits. Decoding them in an octal core dump was really fun... From samuel Sat Feb 16 04:13:05 2008 From: samuel (Samuel Tesla) Date: Fri, 15 Feb 2008 21:13:05 -0600 Subject: [erlang-questions] blocking vs non-blocking gen_tcp:accept() In-Reply-To: <47B649B7.3040504@gmail.com> References: <4bd555f70802151254j4bfbfd5p26b491ce3d65304a@mail.gmail.com> <47B649B7.3040504@gmail.com> Message-ID: <4bd555f70802151913jd22b7dar4ec62623dad4a37a@mail.gmail.com> When is it not an acceptable design? I can't imagine that it's performance. Both of the large examples of TCP services that I've seen in Erlang (YAWS and ejabberd) use this model, and they're both documented to handle very heavy loads and perform very well. -- Samuel On Fri, Feb 15, 2008 at 8:25 PM, Serge Aleynikov wrote: > The objective of the article was to show how to build a TCP server using > only non-blocking processes and relying on the network driver to deliver > events of interest to the application layer. Blocking processes for N > seconds as in the code below is not always an acceptable design. > > I also wish that the non-blocking prim_inet:accept/2 call was exposed to > the gen_tcp module. Perhaps this was an oversight rather than a > conscious decision? > > Serge > > Samuel Tesla wrote: > > Robin: Sorry if you got this twice, I realized just after I hit send > that I > > had only replied to you. > > > > It only blocks the Erlang process, I believe. > > > > I've been meaning to post some code examples about this. > > > > What's always bugged me about that article is that it relies on > prim_inet > > which is not guaranteed at all to remain the same across releases, > whereas > > gen_tcp is (or at least guaranteed to be squawked about). I've written > > several TCP servers for personal projects, and I have found that there's > no > > need to use anything but gen_tcp:accept (with a timeout). > > > > Here's an example of using gen_tcp:accept/2 in a gen_server that > operates > > similarly to the one in that walkthrough. > > > > %% BEGIN CODE %% > > -module(tcp_lister). > > > > -behaviour(gen_server). > > > > -export([start_link/3]). > > -export([init/1, handle_call/3, handle_cast/2, handle_info/2, > > terminate/2, code_change/3]). > > > > -define(TCP_ACCEPT_TIMEOUT, 10000). > > > > -record(state, { > > listen, % listening socket > > sup % supervisor for client proxies > > }). > > > > start_link(Port, Opts, Sup) when is_integer(Port), > > is_list(Opts), > > is_atom(Sup) -> > > gen_server:start_link(?MODULE, [Port, Opts, Sup], []). > > > > init([Port, Opts, Sup]) -> > > {ok, Listen} = gen_tcp:listen(Port, Opts), > > State = #state{listen=Listen, sup=Sup}, > > gen_server:cast(self(), accept), > > ?MODULE:accept(), > > {ok, State}. > > > > handle_call(Request, From, State) -> > > {stop, {unknown_call, {Request, From}}, State}. > > > > handle_cast(accept, State) -> > > #state{listen=Listen, sup=Sup} = State, > > case gen_tcp:accept(Listen, ?TCP_ACCEPT_TIMEOUT) of > > {ok, Socket} -> Sup:start_client(Socket); > > {error, timeout} -> ok > > end, > > gen_server:cast(self(), accept), > > {noreply, State}; > > handle_cast(Msg, State) -> > > {stop, {unknown_cast, Msg}, State}. > > > > handle_info(Info, State) -> > > {stop, {unknown_info, Info}, State}. > > > > terminate(_Reason, _State) -> > > ok. > > > > code_change(_OldVsn, State, _Extra) -> > > {ok, State}. > > > > %% END CODE %% > > > > Then Sup:start_link/1 looks like this: > > > > %% BEGIN CODE %% > > start_client(Socket) -> > > {ok, Pid} = supervisor:start_child(?MODULE, []), > > gen_tcp:controlling_process(Socket, Pid), > > ok = client_module:set_socket(Pid, Socket), > > ok. > > %% END CODE %% > > > > And client_module:set_socket just lets the newly spawned process know > what > > it's socket is just like in the trapexit article. > > > > There's several things this code doesn't handle. It could get other > errors > > such as EMFILE or ENFILE from gen_tcp:accept/2. But in those cases the > > gen_server will blow up and get logged and the supervisor will do > something > > appropriate. There is a brief moment during which sockets will sit idle > in > > the buffer, but seriously, it's brief. > > > > The key thing here is that you're using gen_tcp:accept/2, so you won't > be > > blocking the process forever. That means that the process will > eventually > > loop through and check it's mailbox again and can handle all of the fun > > supervision-tree stuff gen_server does behind the scenes. > > > > Hope this helps! > > > > -- Samuel > > > > On Fri, Feb 15, 2008 at 2:16 PM, Robin wrote: > > > >> Does gen_tcp:accept() block the entire OS thread or just the calling > >> erlang process? > >> > >> "One of the shortcomings of the gen_tcp module is that it only exports > >> interface to a blocking accept call." -> > >> > >> > http://www.trapexit.org/Building_a_Non-blocking_TCP_server_using_OTP_principles > >> > >> Does the performance gain of non-blocking accept justify the added > >> complexity (finite state machine etc)? > >> > >> thanks, > >> > >> Robin > >> _______________________________________________ > >> erlang-questions mailing list > >> erlang-questions > >> http://www.erlang.org/mailman/listinfo/erlang-questions > >> > > > > > > ------------------------------------------------------------------------ > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions > > http://www.erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080215/955187c8/attachment-0001.html From icejmx Sat Feb 16 04:26:06 2008 From: icejmx (=?GB2312?B?w+nD6Q==?=) Date: Sat, 16 Feb 2008 11:26:06 +0800 Subject: [erlang-questions] help about process,why very slow. Message-ID: <47B657CE.4050105@gmail.com> Hello everyone! I recent study erlang familiar with the code to make a message transmitted server, have a problem! I development of the information transmitted server function: Aclient Bclient are connected to Server, and joined a group C, Aclient send message to group C , message will be transmitted to B by group C. SOCKET use the binary (active true), (2) packet. News Server design: Have a process responsible for monitoring all client even when the client connect server, another process (group_manager process) maintenance division List of members of the client group, each group (group process) to have an process within the group responsible for the client to transmit message. Performance testing problems encountered by: A test of million sent to the SERVER message used on the finished eight seconds, and automatic logoff, and the content of the message are the same, so, the test Lan network. SERVER through tcpdump monitor and indeed also in the eight seconds are all the message at the end, and not from the message into the A, however SERVER transmitted to the messages with for a very long time, over 10 minutes, finally, I end of the process. In server,use top,the cpu is 99% by beam.smp. PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 31586 root 17 0 70564 18m 1868 S 99.9 0.9 15:46.12 beam.smp Is it a problem I designed a very slow ? Or as a result of the process of communication? What measures can be taken tuning? Thank you help! the server code # -module(emssserver). # -export([init/0]). # -define(TCP_OPTIONS,[binary,{packet, 2}, {active, true}, {reuseaddr, true}]). # -define(PORT,7000). # -define(Debug,"YES"). # # -ifdef(Debug). # -define(DEBUG(Fmt, Args), io:format(Fmt, Args)). # -else. # -define(DEBUG(Fmt, Args), no_debug). # -endif. # -record(group,{name,gpid}). # -record(client, {name,pid,socket}). # # init()-> # {ok, Listen} = gen_tcp:listen(?PORT, ?TCP_OPTIONS), # register(accept_connection, spawn(fun() -> accept_connection(Listen) end)), # register(group_manage, spawn(fun() -> group_manage([]) end)). # # accept_connection(Listen) ->%% listen new client connection # {ok, Socket} = gen_tcp:accept(Listen), # Pid = spawn(fun() -> client_recv(Socket,"","") end), # gen_tcp:controlling_process(Socket,Pid), # accept_connection(Listen). # # client_recv(Socket,ClientName,GroupPid)->%%client process recv # receive # {tcp, Socket, Bin} -> # ?DEBUG("Server recv Data\r\n",""), # case binary_to_term(Bin) of # {join,JoinName,ClientNameTmp}->%%client join # ?DEBUG("client_recv Join:~s ~s\r\n",[JoinName,ClientNameTmp]), # G=#group{name=JoinName}, # group_manage ! {join,G,self()},%%get group pid # receive # {grouppid,GPid}->%%recv group pid # ?DEBUG("Client_recv grouppid ~w ~s\r\n",[GPid,ClientNameTmp]), # GPid!{join,Socket,ClientNameTmp,self()} %% send "join" msg to group # end, # client_recv(Socket,ClientNameTmp,GPid); # {send,GroupName,Msg}->%%send msg to group # ?DEBUG("client_recv Send:~s ~s\r\n",[GroupName,Msg]), # GroupPid!{send,ClientName,Msg}, # client_recv(Socket,ClientName,GroupPid) # end; # {tcp_closed, Socket} -> # ?DEBUG("client_recv close\r\n",[]) # end. # # group_manage(Group)->%%manage group member # ?DEBUG("group_manage start\r\n",[]), # receive # {join,JoinGroup,ClientPid}-> # ?DEBUG("group_manage Join:~s\r\n",[JoinGroup#group.name]), # case lists:keysearch(JoinGroup#group.name, #group.name, Group) of # false -> # Pid=spawn(fun() -> group([]) end), # ?DEBUG("group_manage group pid~w\r\n",[Pid]), # ClientPid!{grouppid,Pid},%%return client_recv group pid # JoinGroupp = #group{name=JoinGroup#group.name,gpid=Pid}, # Gs = [JoinGroupp|Group], # ?DEBUG("group_manage group:~w\r\n",[Gs]), # group_manage(Gs); # {value,SingleGroup} -> # ?DEBUG("group_manage group is set ~s\r\n",[SingleGroup#group.name]), # ClientPid!{grouppid,SingleGroup#group.gpid}, # group_manage(Group) # end # # end. # # group(Client)->%%send msg to all # ?DEBUG("group \r\n",[]), # receive # {join,Socket,ClientName,CPid} -> # ?DEBUG("group ClientName ~s\r\n",[ClientName]), # ?DEBUG("group Client set ~w\r\n",[Client]), # case lists:keysearch(ClientName,#client.name,Client) of # false-> # ?DEBUG("group new client\r\n",[]), # ClientNew = #client{name=ClientName,pid=CPid,socket=Socket}, # ClientTmp = [ClientNew|Client], # group(ClientTmp); # {value,SingleClient}-> # ?DEBUG("group client is set ~s\r\n",[SingleClient#client.name]), # group(Client) # end; # {send,ClientName,Msg}-> # ?DEBUG("group recv client send ~s\r\n",[Msg]), # lists:foreach(fun(T)->send(ClientName,T,Msg) end,Client), # group(Client) # end, # ok. # # send(FClientName,TClientName,Msg)-> # if # FClientName /= TClientName#client.name -> # ?DEBUG("send f:~s t:~s ~s\r\n",[FClientName,TClientName#client.name,Msg]), # M = {FClientName,Msg}, # gen_tcp:send(TClientName#client.socket,term_to_binary(M)); # true-> # ?DEBUG("send from eq to\r\n",[]) # end. the client code is "gen_tcp:send",iterative the code install three linux server. From icejmx Sat Feb 16 04:29:12 2008 From: icejmx (=?BIG5?B?usu6yw==?=) Date: Sat, 16 Feb 2008 11:29:12 +0800 Subject: [erlang-questions] help about process,why very slow. In-Reply-To: <47B657CE.4050105@gmail.com> References: <47B657CE.4050105@gmail.com> Message-ID: in server erlang shell.use i(). Heapstack Reds Msgs <0.40.0>erlang:apply/2 832040 1194744 2616 lists:foreach/2 442992 On Sat, Feb 16, 2008 at 11:26 AM, ?? wrote: > > Hello everyone! I recent study erlang familiar with the code to make a > message transmitted server, have a problem! > > I development of the information transmitted server function: > Aclient Bclient are connected to Server, and joined a group C, Aclient > send message to group C , message will be transmitted to B by group C. > SOCKET use the binary (active true), (2) packet. > > News Server design: > Have a process responsible for monitoring all client even when the > client connect server, another process (group_manager process) > maintenance division List of members of the client group, each group > (group process) to have an process within the group responsible for the > client to transmit message. > > > Performance testing problems encountered by: > A test of million sent to the SERVER message used on the finished eight > seconds, and automatic logoff, and the content of the message are the > same, so, the test Lan network. > SERVER through tcpdump monitor and indeed also in the eight seconds are > all the message at the end, and not from the message into the A, however > SERVER transmitted to the messages with for a very long time, over 10 > minutes, finally, I end of the process. > > In server,use top,the cpu is 99% by beam.smp. > PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND > 31586 root 17 0 70564 18m 1868 S 99.9 0.9 15:46.12 beam.smp > > Is it a problem I designed a very slow ? Or as a result of the process > of communication? What measures can be taken tuning? > > Thank you help! > > the server code > # -module(emssserver). > # -export([init/0]). > # -define(TCP_OPTIONS,[binary,{packet, 2}, {active, true}, {reuseaddr, > true}]). > # -define(PORT,7000). > # -define(Debug,"YES"). > # > # -ifdef(Debug). > # -define(DEBUG(Fmt, Args), io:format(Fmt, Args)). > # -else. > # -define(DEBUG(Fmt, Args), no_debug). > # -endif. > # -record(group,{name,gpid}). > # -record(client, {name,pid,socket}). > # > # init()-> > # {ok, Listen} = gen_tcp:listen(?PORT, ?TCP_OPTIONS), > # register(accept_connection, spawn(fun() -> accept_connection(Listen) > end)), > # register(group_manage, spawn(fun() -> group_manage([]) end)). > # > # accept_connection(Listen) ->%% listen new client connection > # {ok, Socket} = gen_tcp:accept(Listen), > # Pid = spawn(fun() -> client_recv(Socket,"","") end), > # gen_tcp:controlling_process(Socket,Pid), > # accept_connection(Listen). > # > # client_recv(Socket,ClientName,GroupPid)->%%client process recv > # receive > # {tcp, Socket, Bin} -> > # ?DEBUG("Server recv Data\r\n",""), > # case binary_to_term(Bin) of > # {join,JoinName,ClientNameTmp}->%%client join > # ?DEBUG("client_recv Join:~s ~s\r\n",[JoinName,ClientNameTmp]), > # G=#group{name=JoinName}, > # group_manage ! {join,G,self()},%%get group pid > # receive > # {grouppid,GPid}->%%recv group pid > # ?DEBUG("Client_recv grouppid ~w ~s\r\n",[GPid,ClientNameTmp]), > # GPid!{join,Socket,ClientNameTmp,self()} %% send "join" msg to group > # end, > # client_recv(Socket,ClientNameTmp,GPid); > # {send,GroupName,Msg}->%%send msg to group > # ?DEBUG("client_recv Send:~s ~s\r\n",[GroupName,Msg]), > # GroupPid!{send,ClientName,Msg}, > # client_recv(Socket,ClientName,GroupPid) > # end; > # {tcp_closed, Socket} -> > # ?DEBUG("client_recv close\r\n",[]) > # end. > # > # group_manage(Group)->%%manage group member > # ?DEBUG("group_manage start\r\n",[]), > # receive > # {join,JoinGroup,ClientPid}-> > # ?DEBUG("group_manage Join:~s\r\n",[JoinGroup#group.name]), > # case lists:keysearch(JoinGroup#group.name, #group.name, Group) of > # false -> > # Pid=spawn(fun() -> group([]) end), > # ?DEBUG("group_manage group pid~w\r\n",[Pid]), > # ClientPid!{grouppid,Pid},%%return client_recv group pid > # JoinGroupp = #group{name=JoinGroup#group.name,gpid=Pid}, > # Gs = [JoinGroupp|Group], > # ?DEBUG("group_manage group:~w\r\n",[Gs]), > # group_manage(Gs); > # {value,SingleGroup} -> > # ?DEBUG("group_manage group is set ~s\r\n",[SingleGroup#group.name]), > # ClientPid!{grouppid,SingleGroup#group.gpid}, > # group_manage(Group) > # end > # > # end. > # > # group(Client)->%%send msg to all > # ?DEBUG("group \r\n",[]), > # receive > # {join,Socket,ClientName,CPid} -> > # ?DEBUG("group ClientName ~s\r\n",[ClientName]), > # ?DEBUG("group Client set ~w\r\n",[Client]), > # case lists:keysearch(ClientName,#client.name,Client) of > # false-> > # ?DEBUG("group new client\r\n",[]), > # ClientNew = #client{name=ClientName,pid=CPid,socket=Socket}, > # ClientTmp = [ClientNew|Client], > # group(ClientTmp); > # {value,SingleClient}-> > # ?DEBUG("group client is set ~s\r\n",[SingleClient#client.name]), > # group(Client) > # end; > # {send,ClientName,Msg}-> > # ?DEBUG("group recv client send ~s\r\n",[Msg]), > # lists:foreach(fun(T)->send(ClientName,T,Msg) end,Client), > # group(Client) > # end, > # ok. > # > # send(FClientName,TClientName,Msg)-> > # if > # FClientName /= TClientName#client.name -> > # ?DEBUG("send f:~s t:~s > ~s\r\n",[FClientName,TClientName#client.name,Msg]), > # M = {FClientName,Msg}, > # gen_tcp:send(TClientName#client.socket,term_to_binary(M)); > # true-> > # ?DEBUG("send from eq to\r\n",[]) > # end. > > the client code is "gen_tcp:send",iterative > > the code install three linux server. > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080216/3d885779/attachment.html From icejmx Sat Feb 16 04:32:17 2008 From: icejmx (=?BIG5?B?usu6yw==?=) Date: Sat, 16 Feb 2008 11:32:17 +0800 Subject: [erlang-questions] help about process,why very slow. In-Reply-To: <47B657CE.4050105@gmail.com> References: <47B657CE.4050105@gmail.com> Message-ID: server code url http://icej.80s.net.cn/emssserver.erl On Sat, Feb 16, 2008 at 11:26 AM, ?? wrote: > > Hello everyone! I recent study erlang familiar with the code to make a > message transmitted server, have a problem! > > I development of the information transmitted server function: > Aclient Bclient are connected to Server, and joined a group C, Aclient > send message to group C , message will be transmitted to B by group C. > SOCKET use the binary (active true), (2) packet. > > News Server design: > Have a process responsible for monitoring all client even when the > client connect server, another process (group_manager process) > maintenance division List of members of the client group, each group > (group process) to have an process within the group responsible for the > client to transmit message. > > > Performance testing problems encountered by: > A test of million sent to the SERVER message used on the finished eight > seconds, and automatic logoff, and the content of the message are the > same, so, the test Lan network. > SERVER through tcpdump monitor and indeed also in the eight seconds are > all the message at the end, and not from the message into the A, however > SERVER transmitted to the messages with for a very long time, over 10 > minutes, finally, I end of the process. > > In server,use top,the cpu is 99% by beam.smp. > PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND > 31586 root 17 0 70564 18m 1868 S 99.9 0.9 15:46.12 beam.smp > > Is it a problem I designed a very slow ? Or as a result of the process > of communication? What measures can be taken tuning? > > Thank you help! > > the server code > # -module(emssserver). > # -export([init/0]). > # -define(TCP_OPTIONS,[binary,{packet, 2}, {active, true}, {reuseaddr, > true}]). > # -define(PORT,7000). > # -define(Debug,"YES"). > # > # -ifdef(Debug). > # -define(DEBUG(Fmt, Args), io:format(Fmt, Args)). > # -else. > # -define(DEBUG(Fmt, Args), no_debug). > # -endif. > # -record(group,{name,gpid}). > # -record(client, {name,pid,socket}). > # > # init()-> > # {ok, Listen} = gen_tcp:listen(?PORT, ?TCP_OPTIONS), > # register(accept_connection, spawn(fun() -> accept_connection(Listen) > end)), > # register(group_manage, spawn(fun() -> group_manage([]) end)). > # > # accept_connection(Listen) ->%% listen new client connection > # {ok, Socket} = gen_tcp:accept(Listen), > # Pid = spawn(fun() -> client_recv(Socket,"","") end), > # gen_tcp:controlling_process(Socket,Pid), > # accept_connection(Listen). > # > # client_recv(Socket,ClientName,GroupPid)->%%client process recv > # receive > # {tcp, Socket, Bin} -> > # ?DEBUG("Server recv Data\r\n",""), > # case binary_to_term(Bin) of > # {join,JoinName,ClientNameTmp}->%%client join > # ?DEBUG("client_recv Join:~s ~s\r\n",[JoinName,ClientNameTmp]), > # G=#group{name=JoinName}, > # group_manage ! {join,G,self()},%%get group pid > # receive > # {grouppid,GPid}->%%recv group pid > # ?DEBUG("Client_recv grouppid ~w ~s\r\n",[GPid,ClientNameTmp]), > # GPid!{join,Socket,ClientNameTmp,self()} %% send "join" msg to group > # end, > # client_recv(Socket,ClientNameTmp,GPid); > # {send,GroupName,Msg}->%%send msg to group > # ?DEBUG("client_recv Send:~s ~s\r\n",[GroupName,Msg]), > # GroupPid!{send,ClientName,Msg}, > # client_recv(Socket,ClientName,GroupPid) > # end; > # {tcp_closed, Socket} -> > # ?DEBUG("client_recv close\r\n",[]) > # end. > # > # group_manage(Group)->%%manage group member > # ?DEBUG("group_manage start\r\n",[]), > # receive > # {join,JoinGroup,ClientPid}-> > # ?DEBUG("group_manage Join:~s\r\n",[JoinGroup#group.name]), > # case lists:keysearch(JoinGroup#group.name, #group.name, Group) of > # false -> > # Pid=spawn(fun() -> group([]) end), > # ?DEBUG("group_manage group pid~w\r\n",[Pid]), > # ClientPid!{grouppid,Pid},%%return client_recv group pid > # JoinGroupp = #group{name=JoinGroup#group.name,gpid=Pid}, > # Gs = [JoinGroupp|Group], > # ?DEBUG("group_manage group:~w\r\n",[Gs]), > # group_manage(Gs); > # {value,SingleGroup} -> > # ?DEBUG("group_manage group is set ~s\r\n",[SingleGroup#group.name]), > # ClientPid!{grouppid,SingleGroup#group.gpid}, > # group_manage(Group) > # end > # > # end. > # > # group(Client)->%%send msg to all > # ?DEBUG("group \r\n",[]), > # receive > # {join,Socket,ClientName,CPid} -> > # ?DEBUG("group ClientName ~s\r\n",[ClientName]), > # ?DEBUG("group Client set ~w\r\n",[Client]), > # case lists:keysearch(ClientName,#client.name,Client) of > # false-> > # ?DEBUG("group new client\r\n",[]), > # ClientNew = #client{name=ClientName,pid=CPid,socket=Socket}, > # ClientTmp = [ClientNew|Client], > # group(ClientTmp); > # {value,SingleClient}-> > # ?DEBUG("group client is set ~s\r\n",[SingleClient#client.name]), > # group(Client) > # end; > # {send,ClientName,Msg}-> > # ?DEBUG("group recv client send ~s\r\n",[Msg]), > # lists:foreach(fun(T)->send(ClientName,T,Msg) end,Client), > # group(Client) > # end, > # ok. > # > # send(FClientName,TClientName,Msg)-> > # if > # FClientName /= TClientName#client.name -> > # ?DEBUG("send f:~s t:~s > ~s\r\n",[FClientName,TClientName#client.name,Msg]), > # M = {FClientName,Msg}, > # gen_tcp:send(TClientName#client.socket,term_to_binary(M)); > # true-> > # ?DEBUG("send from eq to\r\n",[]) > # end. > > the client code is "gen_tcp:send",iterative > > the code install three linux server. > > -- ??:erlang,python,php,java --------------------------------------------- ????? http://blog.80s.net.cn -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080216/5bc8d50b/attachment-0001.html From saleyn Sat Feb 16 03:25:59 2008 From: saleyn (Serge Aleynikov) Date: Fri, 15 Feb 2008 21:25:59 -0500 Subject: [erlang-questions] blocking vs non-blocking gen_tcp:accept() In-Reply-To: <4bd555f70802151254j4bfbfd5p26b491ce3d65304a@mail.gmail.com> References: <4bd555f70802151254j4bfbfd5p26b491ce3d65304a@mail.gmail.com> Message-ID: <47B649B7.3040504@gmail.com> The objective of the article was to show how to build a TCP server using only non-blocking processes and relying on the network driver to deliver events of interest to the application layer. Blocking processes for N seconds as in the code below is not always an acceptable design. I also wish that the non-blocking prim_inet:accept/2 call was exposed to the gen_tcp module. Perhaps this was an oversight rather than a conscious decision? Serge Samuel Tesla wrote: > Robin: Sorry if you got this twice, I realized just after I hit send that I > had only replied to you. > > It only blocks the Erlang process, I believe. > > I've been meaning to post some code examples about this. > > What's always bugged me about that article is that it relies on prim_inet > which is not guaranteed at all to remain the same across releases, whereas > gen_tcp is (or at least guaranteed to be squawked about). I've written > several TCP servers for personal projects, and I have found that there's no > need to use anything but gen_tcp:accept (with a timeout). > > Here's an example of using gen_tcp:accept/2 in a gen_server that operates > similarly to the one in that walkthrough. > > %% BEGIN CODE %% > -module(tcp_lister). > > -behaviour(gen_server). > > -export([start_link/3]). > -export([init/1, handle_call/3, handle_cast/2, handle_info/2, > terminate/2, code_change/3]). > > -define(TCP_ACCEPT_TIMEOUT, 10000). > > -record(state, { > listen, % listening socket > sup % supervisor for client proxies > }). > > start_link(Port, Opts, Sup) when is_integer(Port), > is_list(Opts), > is_atom(Sup) -> > gen_server:start_link(?MODULE, [Port, Opts, Sup], []). > > init([Port, Opts, Sup]) -> > {ok, Listen} = gen_tcp:listen(Port, Opts), > State = #state{listen=Listen, sup=Sup}, > gen_server:cast(self(), accept), > ?MODULE:accept(), > {ok, State}. > > handle_call(Request, From, State) -> > {stop, {unknown_call, {Request, From}}, State}. > > handle_cast(accept, State) -> > #state{listen=Listen, sup=Sup} = State, > case gen_tcp:accept(Listen, ?TCP_ACCEPT_TIMEOUT) of > {ok, Socket} -> Sup:start_client(Socket); > {error, timeout} -> ok > end, > gen_server:cast(self(), accept), > {noreply, State}; > handle_cast(Msg, State) -> > {stop, {unknown_cast, Msg}, State}. > > handle_info(Info, State) -> > {stop, {unknown_info, Info}, State}. > > terminate(_Reason, _State) -> > ok. > > code_change(_OldVsn, State, _Extra) -> > {ok, State}. > > %% END CODE %% > > Then Sup:start_link/1 looks like this: > > %% BEGIN CODE %% > start_client(Socket) -> > {ok, Pid} = supervisor:start_child(?MODULE, []), > gen_tcp:controlling_process(Socket, Pid), > ok = client_module:set_socket(Pid, Socket), > ok. > %% END CODE %% > > And client_module:set_socket just lets the newly spawned process know what > it's socket is just like in the trapexit article. > > There's several things this code doesn't handle. It could get other errors > such as EMFILE or ENFILE from gen_tcp:accept/2. But in those cases the > gen_server will blow up and get logged and the supervisor will do something > appropriate. There is a brief moment during which sockets will sit idle in > the buffer, but seriously, it's brief. > > The key thing here is that you're using gen_tcp:accept/2, so you won't be > blocking the process forever. That means that the process will eventually > loop through and check it's mailbox again and can handle all of the fun > supervision-tree stuff gen_server does behind the scenes. > > Hope this helps! > > -- Samuel > > On Fri, Feb 15, 2008 at 2:16 PM, Robin wrote: > >> Does gen_tcp:accept() block the entire OS thread or just the calling >> erlang process? >> >> "One of the shortcomings of the gen_tcp module is that it only exports >> interface to a blocking accept call." -> >> >> http://www.trapexit.org/Building_a_Non-blocking_TCP_server_using_OTP_principles >> >> Does the performance gain of non-blocking accept justify the added >> complexity (finite state machine etc)? >> >> thanks, >> >> Robin >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions From kangas Sat Feb 16 09:39:38 2008 From: kangas (Matt Kangas) Date: Sat, 16 Feb 2008 03:39:38 -0500 Subject: [erlang-questions] Documentation build process: user comments, finer-grained pages In-Reply-To: <18357.34938.691663.177763@antilipe.corelatus.se> References: <8EDCB178-4069-4F2B-A5BF-385C1D5D0565@bway.net> <47B14F39.9080509@gmail.com> <18357.34938.691663.177763@antilipe.corelatus.se> Message-ID: On Feb 15, 2008, at 7:41 AM, Matthias Lang wrote: > Looking at the "user comments" on the PHP site pretty much put me off > any ideas about having "user comments". What a collection of flotsam > and jetsam! For a moment, let's talk about blogs, rather than online software manuals. Many bloggers have strong feelings about allowing comments on their posts. They're either against it, or think it's an essential part of the medium. Often you can predict who will be on which side of the issue. Established authors don't like the "hassle" and "messiness" of comments. Authors who were weaned on blogging often see blogs as a "conversational" medium; without comments, there can be no conversation. Spammy comments is a big concern for top bloggers. Of course, quality of legitimate comments varies too. Solution? Better tools. :) One popular solution for top tech blogs (in USA, at least) is http://disqus.com/ - strong spam protection - threaded comments - ranking of comments up/down via "vote up/down" buttons - free Example of a site using disqus (not mine! :) http://www.scripting.com/stories/2008/02/15/iHeartEyetv.html As for Erlang's online manual... I agree with Dimitri that the comments in software manuals (ala php.net) are more useful to newbies than for old masters. It's the newbies who need multiple perspectives on the same topic; they don't see how everything fits together. By permitting comments, you let users fill in the gaps they think are important. Or, as someone much wiser than I has said, "With enough eyeballs, all bugs are shallow". :) Re: "flotsam", disqus-style ranking helps bubble the "best" comments (as voted by readers) to the top. PHP.net's docs lack this, but I think it's important. To do comments right, the Erlang docs would also need to be chopped into more distinct URLs. Comments at the bottom of a long page like http://erlang.org/doc/man/io.html make little sense. You want comments to be at the function level too. PS: Chopping into smaller pages benefits SEO. A URL like http://doc.erlang.org/io/format (with a matching title) will be ranked higher by Google for the query "erlang io:format" than its current counterpart. Cheers, --Matt -- Matt Kangas kangas ? www.p16blog.com From masterofquestions Sat Feb 16 06:41:36 2008 From: masterofquestions (db) Date: Fri, 15 Feb 2008 21:41:36 -0800 (PST) Subject: [erlang-questions] dynamically add mnesia fragmented table node & composite key as index Message-ID: <68447910-06e1-4bd6-b271-b4ea653d377c@n77g2000hse.googlegroups.com> Question 1: I start an application that initializes several fragmented mnesia nodes. I have hard coded this into config file. On later stage, if I wanted to add another fragmented mnesia node, what is the solution? Do I stop my application and then add a node in the config file? What approach I have to take, if I want to add node dynamically? Question 2: Can mnesia table index be made up of multiple attributes, as in composite key? thank you, sleepless with erlang. From icejmx Sat Feb 16 13:18:36 2008 From: icejmx (=?BIG5?B?usu6yw==?=) Date: Sat, 16 Feb 2008 20:18:36 +0800 Subject: [erlang-questions] help about process,why very slow. In-Reply-To: References: <47B657CE.4050105@gmail.com> Message-ID: help! On Feb 16, 2008 11:32 AM, ?? wrote: > server code url > http://icej.80s.net.cn/emssserver.erl > > On Sat, Feb 16, 2008 at 11:26 AM, ?? wrote: > > > > > Hello everyone! I recent study erlang familiar with the code to make a > > message transmitted server, have a problem! > > > > I development of the information transmitted server function: > > Aclient Bclient are connected to Server, and joined a group C, Aclient > > send message to group C , message will be transmitted to B by group C. > > SOCKET use the binary (active true), (2) packet. > > > > News Server design: > > Have a process responsible for monitoring all client even when the > > client connect server, another process (group_manager process) > > maintenance division List of members of the client group, each group > > (group process) to have an process within the group responsible for the > > client to transmit message. > > > > > > Performance testing problems encountered by: > > A test of million sent to the SERVER message used on the finished eight > > seconds, and automatic logoff, and the content of the message are the > > same, so, the test Lan network. > > SERVER through tcpdump monitor and indeed also in the eight seconds are > > all the message at the end, and not from the message into the A, however > > SERVER transmitted to the messages with for a very long time, over 10 > > minutes, finally, I end of the process. > > > > In server,use top,the cpu is 99% by beam.smp. > > PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND > > 31586 root 17 0 70564 18m 1868 S 99.9 0.9 15:46.12 beam.smp > > > > Is it a problem I designed a very slow ? Or as a result of the process > > of communication? What measures can be taken tuning? > > > > Thank you help! > > > > the server code > > # -module(emssserver). > > # -export([init/0]). > > # -define(TCP_OPTIONS,[binary,{packet, 2}, {active, true}, {reuseaddr, > > true}]). > > # -define(PORT,7000). > > # -define(Debug,"YES"). > > # > > # -ifdef(Debug). > > # -define(DEBUG(Fmt, Args), io:format(Fmt, Args)). > > # -else. > > # -define(DEBUG(Fmt, Args), no_debug). > > # -endif. > > # -record(group,{name,gpid}). > > # -record(client, {name,pid,socket}). > > # > > # init()-> > > # {ok, Listen} = gen_tcp:listen(?PORT, ?TCP_OPTIONS), > > # register(accept_connection, spawn(fun() -> accept_connection(Listen) > > end)), > > # register(group_manage, spawn(fun() -> group_manage([]) end)). > > # > > # accept_connection(Listen) ->%% listen new client connection > > # {ok, Socket} = gen_tcp:accept(Listen), > > # Pid = spawn(fun() -> client_recv(Socket,"","") end), > > # gen_tcp:controlling_process(Socket,Pid), > > # accept_connection(Listen). > > # > > # client_recv(Socket,ClientName,GroupPid)->%%client process recv > > # receive > > # {tcp, Socket, Bin} -> > > # ?DEBUG("Server recv Data\r\n",""), > > # case binary_to_term(Bin) of > > # {join,JoinName,ClientNameTmp}->%%client join > > # ?DEBUG("client_recv Join:~s ~s\r\n",[JoinName,ClientNameTmp]), > > # G=#group{name=JoinName}, > > # group_manage ! {join,G,self()},%%get group pid > > # receive > > # {grouppid,GPid}->%%recv group pid > > # ?DEBUG("Client_recv grouppid ~w ~s\r\n",[GPid,ClientNameTmp]), > > # GPid!{join,Socket,ClientNameTmp,self()} %% send "join" msg to group > > # end, > > # client_recv(Socket,ClientNameTmp,GPid); > > # {send,GroupName,Msg}->%%send msg to group > > # ?DEBUG("client_recv Send:~s ~s\r\n",[GroupName,Msg]), > > # GroupPid!{send,ClientName,Msg}, > > # client_recv(Socket,ClientName,GroupPid) > > # end; > > # {tcp_closed, Socket} -> > > # ?DEBUG("client_recv close\r\n",[]) > > # end. > > # > > # group_manage(Group)->%%manage group member > > # ?DEBUG("group_manage start\r\n",[]), > > # receive > > # {join,JoinGroup,ClientPid}-> > > # ?DEBUG("group_manage Join:~s\r\n",[JoinGroup#group.name]), > > # case lists:keysearch(JoinGroup#group.name, #group.name, Group) of > > # false -> > > # Pid=spawn(fun() -> group([]) end), > > # ?DEBUG("group_manage group pid~w\r\n",[Pid]), > > # ClientPid!{grouppid,Pid},%%return client_recv group pid > > # JoinGroupp = #group{name=JoinGroup#group.name,gpid=Pid}, > > # Gs = [JoinGroupp|Group], > > # ?DEBUG("group_manage group:~w\r\n",[Gs]), > > # group_manage(Gs); > > # {value,SingleGroup} -> > > # ?DEBUG("group_manage group is set ~s\r\n",[SingleGroup#group.name]), > > # ClientPid!{grouppid,SingleGroup#group.gpid}, > > # group_manage(Group) > > # end > > # > > # end. > > # > > # group(Client)->%%send msg to all > > # ?DEBUG("group \r\n",[]), > > # receive > > # {join,Socket,ClientName,CPid} -> > > # ?DEBUG("group ClientName ~s\r\n",[ClientName]), > > # ?DEBUG("group Client set ~w\r\n",[Client]), > > # case lists:keysearch(ClientName,#client.name,Client) of > > # false-> > > # ?DEBUG("group new client\r\n",[]), > > # ClientNew = #client{name=ClientName,pid=CPid,socket=Socket}, > > # ClientTmp = [ClientNew|Client], > > # group(ClientTmp); > > # {value,SingleClient}-> > > # ?DEBUG("group client is set ~s\r\n",[SingleClient#client.name]), > > # group(Client) > > # end; > > # {send,ClientName,Msg}-> > > # ?DEBUG("group recv client send ~s\r\n",[Msg]), > > # lists:foreach(fun(T)->send(ClientName,T,Msg) end,Client), > > # group(Client) > > # end, > > # ok. > > # > > # send(FClientName,TClientName,Msg)-> > > # if > > # FClientName /= TClientName#client.name -> > > # ?DEBUG("send f:~s t:~s > > ~s\r\n",[FClientName,TClientName#client.name,Msg]), > > # M = {FClientName,Msg}, > > # gen_tcp:send(TClientName#client.socket,term_to_binary(M)); > > # true-> > > # ?DEBUG("send from eq to\r\n",[]) > > # end. > > > > the client code is "gen_tcp:send",iterative > > > > the code install three linux server. > > > > > > > -- > ??:erlang,python,php,java > --------------------------------------------- > ????? > http://blog.80s.net.cn > -- ??:erlang,python,php,java --------------------------------------------- ????? http://blog.80s.net.cn -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080216/1fe92014/attachment.html From ulf Sat Feb 16 13:38:33 2008 From: ulf (Ulf Wiger) Date: Sat, 16 Feb 2008 13:38:33 +0100 Subject: [erlang-questions] dynamically add mnesia fragmented table node & composite key as index In-Reply-To: <68447910-06e1-4bd6-b271-b4ea653d377c@n77g2000hse.googlegroups.com> References: <68447910-06e1-4bd6-b271-b4ea653d377c@n77g2000hse.googlegroups.com> Message-ID: <8209f740802160438h518a8898xe801aa0622603c2f@mail.gmail.com> 2008/2/16, db : > Question 1: > I start an application that initializes several fragmented mnesia > nodes. I have hard coded this into config file. On later stage, if I > wanted to add another fragmented mnesia node, what is the solution? > Do I stop my application and then add a node in the config file? What > approach I have to take, if I want to add node dynamically? This is described in the Mnesia User Guide, together with examples. > Question 2: > Can mnesia table index be made up of multiple attributes, as in > composite key? No. Rdbms is able to do this. It's stable enough that you could play with it. If you'd want to bet your business on it, some significant work would be required (mainly in testing, but perhaps also some tricky re-coding, certainly porting to R12B, and long-term migration of some aspects in to mnesia, perhaps.) BR, Ulf W From ulf Sat Feb 16 13:48:40 2008 From: ulf (Ulf Wiger) Date: Sat, 16 Feb 2008 13:48:40 +0100 Subject: [erlang-questions] code dependency diagrams In-Reply-To: <9e009ad0802151024m22c293f2u38bc3fe09f1a591@mail.gmail.com> References: <47B5758E.40503@ericsson.com> <9e009ad0802151024m22c293f2u38bc3fe09f1a591@mail.gmail.com> Message-ID: <8209f740802160448o54f9934cs9e7079da73e86d0c@mail.gmail.com> Thanks, I'll try to find time to play with it. GraphML looks like an XML version of Dot - roughly the same structure, but less readable. (: But, hey, if we're generating the specification anyway, it might as well be XML.... BR, Ulf W 2008/2/15, Joern : > Hi Ulf, > > On 15/02/2008, Ulf Wiger (TN/EAB) wrote: > > > And now to the question: Which tool would you recommend I use? > > I looked at Eclipse once, but got the feeling that you won't get > > anywhere without first writing a thousand or so lines of Java code. > > Is this still the way to go? > > The yed package[1] (Java) might be a better alternative - the GraphML > XML it supports (among other inputs formats) does not a look that > scary and it's pretty versatile when it comes to automatic layout. > There also is an Eclipse integration. I never used the latter but yed > is a quite nice package. I am somewhat interested in the topic as well > so if my time permits I am willing to throw your dependency graph data > against a yet to be written converter (or XLST). > > Best regards from Berlin, > > > Joern > > [1]: http://www.yworks.com/en/products_yed_about.html > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > From tty.erlang Sat Feb 16 14:43:27 2008 From: tty.erlang (t ty) Date: Sat, 16 Feb 2008 08:43:27 -0500 Subject: [erlang-questions] Documentation build process: user comments, finer-grained pages In-Reply-To: References: <8EDCB178-4069-4F2B-A5BF-385C1D5D0565@bway.net> <47B14F39.9080509@gmail.com> <18357.34938.691663.177763@antilipe.corelatus.se> Message-ID: <290b3ba10802160543w7c57e619sf8ea9db0cb536962@mail.gmail.com> Perhaps have the docs linked under wikibooks (http://en.wikibooks.org/wiki/Erlang_Programming). Example: Within wikibooks have Module: erlang Function: is_list/1 (link back into erlang.org document that has the official description) Summary: Usage: Comments: Regards t On Feb 16, 2008 3:39 AM, Matt Kangas wrote: > On Feb 15, 2008, at 7:41 AM, Matthias Lang wrote: > > > Looking at the "user comments" on the PHP site pretty much put me off > > any ideas about having "user comments". What a collection of flotsam > > and jetsam! > > For a moment, let's talk about blogs, rather than online software > manuals. > > Many bloggers have strong feelings about allowing comments on their > posts. They're either against it, or think it's an essential part of > the medium. Often you can predict who will be on which side of the > issue. Established authors don't like the "hassle" and "messiness" of > comments. Authors who were weaned on blogging often see blogs as a > "conversational" medium; without comments, there can be no conversation. > > Spammy comments is a big concern for top bloggers. Of course, quality > of legitimate comments varies too. Solution? Better tools. :) > > One popular solution for top tech blogs (in USA, at least) is http://disqus.com/ > - strong spam protection > - threaded comments > - ranking of comments up/down via "vote up/down" buttons > - free > > Example of a site using disqus (not mine! :) > http://www.scripting.com/stories/2008/02/15/iHeartEyetv.html > > As for Erlang's online manual... I agree with Dimitri that the > comments in software manuals (ala php.net) are more useful to newbies > than for old masters. It's the newbies who need multiple perspectives > on the same topic; they don't see how everything fits together. By > permitting comments, you let users fill in the gaps they think are > important. > > Or, as someone much wiser than I has said, "With enough eyeballs, all > bugs are shallow". :) > > Re: "flotsam", disqus-style ranking helps bubble the "best" comments > (as voted by readers) to the top. PHP.net's docs lack this, but I > think it's important. > > To do comments right, the Erlang docs would also need to be chopped > into more distinct URLs. Comments at the bottom of a long page like http://erlang.org/doc/man/io.html > make little sense. You want comments to be at the function level too. > > PS: Chopping into smaller pages benefits SEO. A URL like http://doc.erlang.org/io/format > (with a matching title) will be ranked higher by Google for the > query "erlang io:format" than its current counterpart. > > Cheers, > --Matt > > -- > Matt Kangas > kangas ? www.p16blog.com > > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > From sean.hinde Sat Feb 16 15:43:49 2008 From: sean.hinde (Sean Hinde) Date: Sat, 16 Feb 2008 14:43:49 +0000 Subject: [erlang-questions] blocking vs non-blocking gen_tcp:accept() In-Reply-To: <4bd555f70802151913jd22b7dar4ec62623dad4a37a@mail.gmail.com> References: <4bd555f70802151254j4bfbfd5p26b491ce3d65304a@mail.gmail.com> <47B649B7.3040504@gmail.com> <4bd555f70802151913jd22b7dar4ec62623dad4a37a@mail.gmail.com> Message-ID: Telecom systems typically have to allow re-configuration on the fly of everything (e.g. by sending a reconf message to a process). They might also perform hearbeat monitoring of key processes. Both of these things are much easier if a process is not sitting in a long term blocking call. Sean On 16 Feb 2008, at 03:13, Samuel Tesla wrote: > When is it not an acceptable design? > > I can't imagine that it's performance. Both of the large examples > of TCP services that I've seen in Erlang (YAWS and ejabberd) use > this model, and they're both documented to handle very heavy loads > and perform very well. > > -- Samuel > > On Fri, Feb 15, 2008 at 8:25 PM, Serge Aleynikov > wrote: > The objective of the article was to show how to build a TCP server > using > only non-blocking processes and relying on the network driver to > deliver > events of interest to the application layer. Blocking processes for N > seconds as in the code below is not always an acceptable design. > > I also wish that the non-blocking prim_inet:accept/2 call was > exposed to > the gen_tcp module. Perhaps this was an oversight rather than a > conscious decision? > > Serge > > Samuel Tesla wrote: > > Robin: Sorry if you got this twice, I realized just after I hit > send that I > > had only replied to you. > > > > It only blocks the Erlang process, I believe. > > > > I've been meaning to post some code examples about this. > > > > What's always bugged me about that article is that it relies on > prim_inet > > which is not guaranteed at all to remain the same across releases, > whereas > > gen_tcp is (or at least guaranteed to be squawked about). I've > written > > several TCP servers for personal projects, and I have found that > there's no > > need to use anything but gen_tcp:accept (with a timeout). > > > > Here's an example of using gen_tcp:accept/2 in a gen_server that > operates > > similarly to the one in that walkthrough. > > > > %% BEGIN CODE %% > > -module(tcp_lister). > > > > -behaviour(gen_server). > > > > -export([start_link/3]). > > -export([init/1, handle_call/3, handle_cast/2, handle_info/2, > > terminate/2, code_change/3]). > > > > -define(TCP_ACCEPT_TIMEOUT, 10000). > > > > -record(state, { > > listen, % listening socket > > sup % supervisor for client proxies > > }). > > > > start_link(Port, Opts, Sup) when is_integer(Port), > > is_list(Opts), > > is_atom(Sup) -> > > gen_server:start_link(?MODULE, [Port, Opts, Sup], []). > > > > init([Port, Opts, Sup]) -> > > {ok, Listen} = gen_tcp:listen(Port, Opts), > > State = #state{listen=Listen, sup=Sup}, > > gen_server:cast(self(), accept), > > ?MODULE:accept(), > > {ok, State}. > > > > handle_call(Request, From, State) -> > > {stop, {unknown_call, {Request, From}}, State}. > > > > handle_cast(accept, State) -> > > #state{listen=Listen, sup=Sup} = State, > > case gen_tcp:accept(Listen, ?TCP_ACCEPT_TIMEOUT) of > > {ok, Socket} -> Sup:start_client(Socket); > > {error, timeout} -> ok > > end, > > gen_server:cast(self(), accept), > > {noreply, State}; > > handle_cast(Msg, State) -> > > {stop, {unknown_cast, Msg}, State}. > > > > handle_info(Info, State) -> > > {stop, {unknown_info, Info}, State}. > > > > terminate(_Reason, _State) -> > > ok. > > > > code_change(_OldVsn, State, _Extra) -> > > {ok, State}. > > > > %% END CODE %% > > > > Then Sup:start_link/1 looks like this: > > > > %% BEGIN CODE %% > > start_client(Socket) -> > > {ok, Pid} = supervisor:start_child(?MODULE, []), > > gen_tcp:controlling_process(Socket, Pid), > > ok = client_module:set_socket(Pid, Socket), > > ok. > > %% END CODE %% > > > > And client_module:set_socket just lets the newly spawned process > know what > > it's socket is just like in the trapexit article. > > > > There's several things this code doesn't handle. It could get > other errors > > such as EMFILE or ENFILE from gen_tcp:accept/2. But in those cases > the > > gen_server will blow up and get logged and the supervisor will do > something > > appropriate. There is a brief moment during which sockets will sit > idle in > > the buffer, but seriously, it's brief. > > > > The key thing here is that you're using gen_tcp:accept/2, so you > won't be > > blocking the process forever. That means that the process will > eventually > > loop through and check it's mailbox again and can handle all of > the fun > > supervision-tree stuff gen_server does behind the scenes. > > > > Hope this helps! > > > > -- Samuel > > > > On Fri, Feb 15, 2008 at 2:16 PM, Robin wrote: > > > >> Does gen_tcp:accept() block the entire OS thread or just the > calling > >> erlang process? > >> > >> "One of the shortcomings of the gen_tcp module is that it only > exports > >> interface to a blocking accept call." -> > >> > >> http://www.trapexit.org/Building_a_Non-blocking_TCP_server_using_OTP_principles > >> > >> Does the performance gain of non-blocking accept justify the added > >> complexity (finite state machine etc)? > >> > >> thanks, > >> > >> Robin > >> _______________________________________________ > >> erlang-questions mailing list > >> erlang-questions > >> http://www.erlang.org/mailman/listinfo/erlang-questions > >> > > > > > > > ------------------------------------------------------------------------ > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions From sean.hinde Sat Feb 16 15:48:47 2008 From: sean.hinde (Sean Hinde) Date: Sat, 16 Feb 2008 14:48:47 +0000 Subject: [erlang-questions] help about process,why very slow. In-Reply-To: References: <47B657CE.4050105@gmail.com> Message-ID: The problem here is almost certainly your use of {active, true}. The inbound mailbox will rapidly fill with a very large number of messages (1 million in your case), and this can cause the emulator to slow down during garbage collection. You need to introduce some flow control. The {active,once} socket option is normally used for this. Sean On 16 Feb 2008, at 12:18, ?? wrote: > help! > > On Feb 16, 2008 11:32 AM, ?? wrote: > server code url > http://icej.80s.net.cn/emssserver.erl > > On Sat, Feb 16, 2008 at 11:26 AM, ?? wrote: > > Hello everyone! I recent study erlang familiar with the code to make a > message transmitted server, have a problem! > > I development of the information transmitted server function: > Aclient Bclient are connected to Server, and joined a group C, Aclient > send message to group C , message will be transmitted to B by group C. > SOCKET use the binary (active true), (2) packet. > > News Server design: > Have a process responsible for monitoring all client even when the > client connect server, another process (group_manager process) > maintenance division List of members of the client group, each group > (group process) to have an process within the group responsible for > the > client to transmit message. > > > Performance testing problems encountered by: > A test of million sent to the SERVER message used on the finished > eight > seconds, and automatic logoff, and the content of the message are the > same, so, the test Lan network. > SERVER through tcpdump monitor and indeed also in the eight seconds > are > all the message at the end, and not from the message into the A, > however > SERVER transmitted to the messages with for a very long time, over 10 > minutes, finally, I end of the process. > > In server,use top,the cpu is 99% by beam.smp. > PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND > 31586 root 17 0 70564 18m 1868 S 99.9 0.9 15:46.12 beam.smp > > Is it a problem I designed a very slow ? Or as a result of the process > of communication? What measures can be taken tuning? > > Thank you help! > > the server code > # -module(emssserver). > # -export([init/0]). > # -define(TCP_OPTIONS,[binary,{packet, 2}, {active, true}, {reuseaddr, > true}]). > # -define(PORT,7000). > # -define(Debug,"YES"). > # > # -ifdef(Debug). > # -define(DEBUG(Fmt, Args), io:format(Fmt, Args)). > # -else. > # -define(DEBUG(Fmt, Args), no_debug). > # -endif. > # -record(group,{name,gpid}). > # -record(client, {name,pid,socket}). > # > # init()-> > # {ok, Listen} = gen_tcp:listen(?PORT, ?TCP_OPTIONS), > # register(accept_connection, spawn(fun() -> accept_connection(Listen) > end)), > # register(group_manage, spawn(fun() -> group_manage([]) end)). > # > # accept_connection(Listen) ->%% listen new client connection > # {ok, Socket} = gen_tcp:accept(Listen), > # Pid = spawn(fun() -> client_recv(Socket,"","") end), > # gen_tcp:controlling_process(Socket,Pid), > # accept_connection(Listen). > # > # client_recv(Socket,ClientName,GroupPid)->%%client process recv > # receive > # {tcp, Socket, Bin} -> > # ?DEBUG("Server recv Data\r\n",""), > # case binary_to_term(Bin) of > # {join,JoinName,ClientNameTmp}->%%client join > # ?DEBUG("client_recv Join:~s ~s\r\n",[JoinName,ClientNameTmp]), > # G=#group{name=JoinName}, > # group_manage ! {join,G,self()},%%get group pid > # receive > # {grouppid,GPid}->%%recv group pid > # ?DEBUG("Client_recv grouppid ~w ~s\r\n",[GPid,ClientNameTmp]), > # GPid!{join,Socket,ClientNameTmp,self()} %% send "join" msg to group > # end, > # client_recv(Socket,ClientNameTmp,GPid); > # {send,GroupName,Msg}->%%send msg to group > # ?DEBUG("client_recv Send:~s ~s\r\n",[GroupName,Msg]), > # GroupPid!{send,ClientName,Msg}, > # client_recv(Socket,ClientName,GroupPid) > # end; > # {tcp_closed, Socket} -> > # ?DEBUG("client_recv close\r\n",[]) > # end. > # > # group_manage(Group)->%%manage group member > # ?DEBUG("group_manage start\r\n",[]), > # receive > # {join,JoinGroup,ClientPid}-> > # ?DEBUG("group_manage Join:~s\r\n",[JoinGroup#group.name]), > # case lists:keysearch(JoinGroup#group.name, #group.name, Group) of > # false -> > # Pid=spawn(fun() -> group([]) end), > # ?DEBUG("group_manage group pid~w\r\n",[Pid]), > # ClientPid!{grouppid,Pid},%%return client_recv group pid > # JoinGroupp = #group{name=JoinGroup#group.name,gpid=Pid}, > # Gs = [JoinGroupp|Group], > # ?DEBUG("group_manage group:~w\r\n",[Gs]), > # group_manage(Gs); > # {value,SingleGroup} -> > # ?DEBUG("group_manage group is set ~s\r\n",[SingleGroup#group.name]), > # ClientPid!{grouppid,SingleGroup#group.gpid}, > # group_manage(Group) > # end > # > # end. > # > # group(Client)->%%send msg to all > # ?DEBUG("group \r\n",[]), > # receive > # {join,Socket,ClientName,CPid} -> > # ?DEBUG("group ClientName ~s\r\n",[ClientName]), > # ?DEBUG("group Client set ~w\r\n",[Client]), > # case lists:keysearch(ClientName,#client.name,Client) of > # false-> > # ?DEBUG("group new client\r\n",[]), > # ClientNew = #client{name=ClientName,pid=CPid,socket=Socket}, > # ClientTmp = [ClientNew|Client], > # group(ClientTmp); > # {value,SingleClient}-> > # ?DEBUG("group client is set ~s\r\n",[SingleClient#client.name]), > # group(Client) > # end; > # {send,ClientName,Msg}-> > # ?DEBUG("group recv client send ~s\r\n",[Msg]), > # lists:foreach(fun(T)->send(ClientName,T,Msg) end,Client), > # group(Client) > # end, > # ok. > # > # send(FClientName,TClientName,Msg)-> > # if > # FClientName /= TClientName#client.name -> > # ?DEBUG("send f:~s t:~s > ~s\r\n",[FClientName,TClientName#client.name,Msg]), > # M = {FClientName,Msg}, > # gen_tcp:send(TClientName#client.socket,term_to_binary(M)); > # true-> > # ?DEBUG("send from eq to\r\n",[]) > # end. > > the client code is "gen_tcp:send",iterative > > the code install three linux server. > > > > > -- > ??:erlang,python,php,java > --------------------------------------------- > ????? > http://blog.80s.net.cn > > > > -- > ??:erlang,python,php,java > --------------------------------------------- > ????? > http://blog.80s.net.cn > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions From nslater Sat Feb 16 16:15:15 2008 From: nslater (Noah Slater) Date: Sat, 16 Feb 2008 15:15:15 +0000 Subject: [erlang-questions] Problems with boot files and Erlang upgrades Message-ID: <20080216151514.GA10859@bytesexual.org> Hello, I am developing the CouchDB build system and am experiencing a problem with the use of Erlang boot files after the Erlang VM is upgraded post-build. I have CC'd the CouchDB group in case there are any lurking Erlang experts. I inherited the current build procedure (compiling a boot file) and while managing to shoehorn it into a Autotools environment I must admit to understanding little about the mechanics. The problem goes something like this: $ apt-get install -t testing erlang-nox # Install an old Erlang VM $ apt-get install -t experimental couchdb # Install CouchDB built for old VM $ apt-get install -t unstable erlang-nox # Install a new Erlang VM $ couchdb # Run CouchDB with the new Erlang VM CouchDB then crashes trying to open: /usr/lib/erlang/lib/kernel-2.11.5/ebin/error_handler.beam The actual BEAM is located here: /usr/lib/erlang/lib/kernel-2.12.1/ebin/error_handler.beam If you then install the latest CouchDB for the new Erlang VM everything works: apt-get install -t unstable couchdb As Sergei Golovan (Debian) points out: It's not a bytecompiling failure. Erlang libraries are hardcoded into a couchdb boot file (/usr/lib/couchdb/erlang/bin/couch.boot). I never used boot files, so I can't say how to fix this bug. But if it stays as it is then couchdb will need a rebuild after each erlang version update (which seems too restrictive to me). CouchDB compiles a boot file and launches it's self like so: /usr/bin/erl -sasl errlog_type error \ -pa /usr/lib/couchdb/erlang/lib/couch-0.7.3a684/ebin \ /usr/lib/couchdb/erlang/lib/couch_inets-4.7.5/ebin \ -boot /usr/lib/couchdb/erlang/bin/couch You can inspect the current build process: http://couchdb.googlecode.com/svn/trunk/src/Makefile.am http://couchdb.googlecode.com/svn/trunk/src/Emakefile.in http://couchdb.googlecode.com/svn/trunk/src/build_couch.erl.in Is there an option I could use so that the paths are not hard-coded. Is there an alternative to using boot files? Thanks, -- Noah Slater From icejmx Sat Feb 16 16:31:56 2008 From: icejmx (=?BIG5?B?usu6yw==?=) Date: Sat, 16 Feb 2008 23:31:56 +0800 Subject: [erlang-questions] help about process,why very slow. In-Reply-To: References: <47B657CE.4050105@gmail.com> Message-ID: thanks! I was revised to {active,once} and server cpu still occupy 99%, but my code in the local tests, use 127.0.0.1,100 million run by 40 seconds, and even in the server 127.0.0.1 of the cpu will be 99%. Is there any way to find out whether there is a server cpu 99%? very thanks! 2008/2/16 Sean Hinde : > The problem here is almost certainly your use of {active, true}. The > inbound mailbox will rapidly fill with a very large number of messages > (1 million in your case), and this can cause the emulator to slow down > during garbage collection. > > You need to introduce some flow control. The {active,once} socket > option is normally used for this. > > Sean > > On 16 Feb 2008, at 12:18, ?? wrote: > > > help! > > > > On Feb 16, 2008 11:32 AM, ?? wrote: > > server code url > > http://icej.80s.net.cn/emssserver.erl > > > > On Sat, Feb 16, 2008 at 11:26 AM, ?? wrote: > > > > Hello everyone! I recent study erlang familiar with the code to make a > > message transmitted server, have a problem! > > > > I development of the information transmitted server function: > > Aclient Bclient are connected to Server, and joined a group C, Aclient > > send message to group C , message will be transmitted to B by group C. > > SOCKET use the binary (active true), (2) packet. > > > > News Server design: > > Have a process responsible for monitoring all client even when the > > client connect server, another process (group_manager process) > > maintenance division List of members of the client group, each group > > (group process) to have an process within the group responsible for > > the > > client to transmit message. > > > > > > Performance testing problems encountered by: > > A test of million sent to the SERVER message used on the finished > > eight > > seconds, and automatic logoff, and the content of the message are the > > same, so, the test Lan network. > > SERVER through tcpdump monitor and indeed also in the eight seconds > > are > > all the message at the end, and not from the message into the A, > > however > > SERVER transmitted to the messages with for a very long time, over 10 > > minutes, finally, I end of the process. > > > > In server,use top,the cpu is 99% by beam.smp. > > PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND > > 31586 root 17 0 70564 18m 1868 S 99.9 0.9 15:46.12 beam.smp > > > > Is it a problem I designed a very slow ? Or as a result of the process > > of communication? What measures can be taken tuning? > > > > Thank you help! > > > > the server code > > # -module(emssserver). > > # -export([init/0]). > > # -define(TCP_OPTIONS,[binary,{packet, 2}, {active, true}, {reuseaddr, > > true}]). > > # -define(PORT,7000). > > # -define(Debug,"YES"). > > # > > # -ifdef(Debug). > > # -define(DEBUG(Fmt, Args), io:format(Fmt, Args)). > > # -else. > > # -define(DEBUG(Fmt, Args), no_debug). > > # -endif. > > # -record(group,{name,gpid}). > > # -record(client, {name,pid,socket}). > > # > > # init()-> > > # {ok, Listen} = gen_tcp:listen(?PORT, ?TCP_OPTIONS), > > # register(accept_connection, spawn(fun() -> accept_connection(Listen) > > end)), > > # register(group_manage, spawn(fun() -> group_manage([]) end)). > > # > > # accept_connection(Listen) ->%% listen new client connection > > # {ok, Socket} = gen_tcp:accept(Listen), > > # Pid = spawn(fun() -> client_recv(Socket,"","") end), > > # gen_tcp:controlling_process(Socket,Pid), > > # accept_connection(Listen). > > # > > # client_recv(Socket,ClientName,GroupPid)->%%client process recv > > # receive > > # {tcp, Socket, Bin} -> > > # ?DEBUG("Server recv Data\r\n",""), > > # case binary_to_term(Bin) of > > # {join,JoinName,ClientNameTmp}->%%client join > > # ?DEBUG("client_recv Join:~s ~s\r\n",[JoinName,ClientNameTmp]), > > # G=#group{name=JoinName}, > > # group_manage ! {join,G,self()},%%get group pid > > # receive > > # {grouppid,GPid}->%%recv group pid > > # ?DEBUG("Client_recv grouppid ~w ~s\r\n",[GPid,ClientNameTmp]), > > # GPid!{join,Socket,ClientNameTmp,self()} %% send "join" msg to group > > # end, > > # client_recv(Socket,ClientNameTmp,GPid); > > # {send,GroupName,Msg}->%%send msg to group > > # ?DEBUG("client_recv Send:~s ~s\r\n",[GroupName,Msg]), > > # GroupPid!{send,ClientName,Msg}, > > # client_recv(Socket,ClientName,GroupPid) > > # end; > > # {tcp_closed, Socket} -> > > # ?DEBUG("client_recv close\r\n",[]) > > # end. > > # > > # group_manage(Group)->%%manage group member > > # ?DEBUG("group_manage start\r\n",[]), > > # receive > > # {join,JoinGroup,ClientPid}-> > > # ?DEBUG("group_manage Join:~s\r\n",[JoinGroup#group.name]), > > # case lists:keysearch(JoinGroup#group.name, #group.name, Group) of > > # false -> > > # Pid=spawn(fun() -> group([]) end), > > # ?DEBUG("group_manage group pid~w\r\n",[Pid]), > > # ClientPid!{grouppid,Pid},%%return client_recv group pid > > # JoinGroupp = #group{name=JoinGroup#group.name,gpid=Pid}, > > # Gs = [JoinGroupp|Group], > > # ?DEBUG("group_manage group:~w\r\n",[Gs]), > > # group_manage(Gs); > > # {value,SingleGroup} -> > > # ?DEBUG("group_manage group is set ~s\r\n",[SingleGroup#group.name]), > > # ClientPid!{grouppid,SingleGroup#group.gpid}, > > # group_manage(Group) > > # end > > # > > # end. > > # > > # group(Client)->%%send msg to all > > # ?DEBUG("group \r\n",[]), > > # receive > > # {join,Socket,ClientName,CPid} -> > > # ?DEBUG("group ClientName ~s\r\n",[ClientName]), > > # ?DEBUG("group Client set ~w\r\n",[Client]), > > # case lists:keysearch(ClientName,#client.name,Client) of > > # false-> > > # ?DEBUG("group new client\r\n",[]), > > # ClientNew = #client{name=ClientName,pid=CPid,socket=Socket}, > > # ClientTmp = [ClientNew|Client], > > # group(ClientTmp); > > # {value,SingleClient}-> > > # ?DEBUG("group client is set ~s\r\n",[SingleClient#client.name]), > > # group(Client) > > # end; > > # {send,ClientName,Msg}-> > > # ?DEBUG("group recv client send ~s\r\n",[Msg]), > > # lists:foreach(fun(T)->send(ClientName,T,Msg) end,Client), > > # group(Client) > > # end, > > # ok. > > # > > # send(FClientName,TClientName,Msg)-> > > # if > > # FClientName /= TClientName#client.name -> > > # ?DEBUG("send f:~s t:~s > > ~s\r\n",[FClientName,TClientName#client.name,Msg]), > > # M = {FClientName,Msg}, > > # gen_tcp:send(TClientName#client.socket,term_to_binary(M)); > > # true-> > > # ?DEBUG("send from eq to\r\n",[]) > > # end. > > > > the client code is "gen_tcp:send",iterative > > > > the code install three linux server. > > > > > > > > > > -- > > ??:erlang,python,php,java > > --------------------------------------------- > > ????? > > http://blog.80s.net.cn > > > > > > > > -- > > ??:erlang,python,php,java > > --------------------------------------------- > > ????? > > http://blog.80s.net.cn > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions > > http://www.erlang.org/mailman/listinfo/erlang-questions > > -- ??:erlang,python,php,java --------------------------------------------- ????? http://blog.80s.net.cn -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080216/ba6a8395/attachment-0001.html From saleyn Sat Feb 16 16:53:49 2008 From: saleyn (Serge Aleynikov) Date: Sat, 16 Feb 2008 10:53:49 -0500 Subject: [erlang-questions] blocking vs non-blocking gen_tcp:accept() In-Reply-To: References: <4bd555f70802151254j4bfbfd5p26b491ce3d65304a@mail.gmail.com> <47B649B7.3040504@gmail.com> <4bd555f70802151913jd22b7dar4ec62623dad4a37a@mail.gmail.com> Message-ID: <47B7070D.5000303@gmail.com> In addition to Sean's good example, I'd like to say that while blocking calls such as gen_tcp:accept/2 generally don't have anything to do with performance issues, in a large distributed system they may introduce undesired properties leading to a loss of predictive behavior. Say, if you need to synchronize a restart of several nodes, upgrade mnesia schema and transition process state to a new version of code in a hot system then blocking calls surely complicate these tasks by quite a bit as they may cause timeouts in other processes. Using blocking calls in stand-alone components such as ejabberds and YAWS may not be an issue at all up until you start integrating them in larger systems with a central point of control. Serge Sean Hinde wrote: > Telecom systems typically have to allow re-configuration on the fly of > everything (e.g. by sending a reconf message to a process). They might > also perform hearbeat monitoring of key processes. Both of these things > are much easier if a process is not sitting in a long term blocking call. > > Sean > > On 16 Feb 2008, at 03:13, Samuel Tesla wrote: > >> When is it not an acceptable design? >> >> I can't imagine that it's performance. Both of the large examples of >> TCP services that I've seen in Erlang (YAWS and ejabberd) use this >> model, and they're both documented to handle very heavy loads and >> perform very well. >> >> -- Samuel >> >> On Fri, Feb 15, 2008 at 8:25 PM, Serge Aleynikov >> wrote: >> The objective of the article was to show how to build a TCP server using >> only non-blocking processes and relying on the network driver to deliver >> events of interest to the application layer. Blocking processes for N >> seconds as in the code below is not always an acceptable design. >> >> I also wish that the non-blocking prim_inet:accept/2 call was exposed to >> the gen_tcp module. Perhaps this was an oversight rather than a >> conscious decision? >> >> Serge >> >> Samuel Tesla wrote: >> > Robin: Sorry if you got this twice, I realized just after I hit send >> that I >> > had only replied to you. >> > >> > It only blocks the Erlang process, I believe. >> > >> > I've been meaning to post some code examples about this. >> > >> > What's always bugged me about that article is that it relies on >> prim_inet >> > which is not guaranteed at all to remain the same across releases, >> whereas >> > gen_tcp is (or at least guaranteed to be squawked about). I've written >> > several TCP servers for personal projects, and I have found that >> there's no >> > need to use anything but gen_tcp:accept (with a timeout). >> > >> > Here's an example of using gen_tcp:accept/2 in a gen_server that >> operates >> > similarly to the one in that walkthrough. >> > >> > %% BEGIN CODE %% >> > -module(tcp_lister). >> > >> > -behaviour(gen_server). >> > >> > -export([start_link/3]). >> > -export([init/1, handle_call/3, handle_cast/2, handle_info/2, >> > terminate/2, code_change/3]). >> > >> > -define(TCP_ACCEPT_TIMEOUT, 10000). >> > >> > -record(state, { >> > listen, % listening socket >> > sup % supervisor for client proxies >> > }). >> > >> > start_link(Port, Opts, Sup) when is_integer(Port), >> > is_list(Opts), >> > is_atom(Sup) -> >> > gen_server:start_link(?MODULE, [Port, Opts, Sup], []). >> > >> > init([Port, Opts, Sup]) -> >> > {ok, Listen} = gen_tcp:listen(Port, Opts), >> > State = #state{listen=Listen, sup=Sup}, >> > gen_server:cast(self(), accept), >> > ?MODULE:accept(), >> > {ok, State}. >> > >> > handle_call(Request, From, State) -> >> > {stop, {unknown_call, {Request, From}}, State}. >> > >> > handle_cast(accept, State) -> >> > #state{listen=Listen, sup=Sup} = State, >> > case gen_tcp:accept(Listen, ?TCP_ACCEPT_TIMEOUT) of >> > {ok, Socket} -> Sup:start_client(Socket); >> > {error, timeout} -> ok >> > end, >> > gen_server:cast(self(), accept), >> > {noreply, State}; >> > handle_cast(Msg, State) -> >> > {stop, {unknown_cast, Msg}, State}. >> > >> > handle_info(Info, State) -> >> > {stop, {unknown_info, Info}, State}. >> > >> > terminate(_Reason, _State) -> >> > ok. >> > >> > code_change(_OldVsn, State, _Extra) -> >> > {ok, State}. >> > >> > %% END CODE %% >> > >> > Then Sup:start_link/1 looks like this: >> > >> > %% BEGIN CODE %% >> > start_client(Socket) -> >> > {ok, Pid} = supervisor:start_child(?MODULE, []), >> > gen_tcp:controlling_process(Socket, Pid), >> > ok = client_module:set_socket(Pid, Socket), >> > ok. >> > %% END CODE %% >> > >> > And client_module:set_socket just lets the newly spawned process >> know what >> > it's socket is just like in the trapexit article. >> > >> > There's several things this code doesn't handle. It could get other >> errors >> > such as EMFILE or ENFILE from gen_tcp:accept/2. But in those cases the >> > gen_server will blow up and get logged and the supervisor will do >> something >> > appropriate. There is a brief moment during which sockets will sit >> idle in >> > the buffer, but seriously, it's brief. >> > >> > The key thing here is that you're using gen_tcp:accept/2, so you >> won't be >> > blocking the process forever. That means that the process will >> eventually >> > loop through and check it's mailbox again and can handle all of the fun >> > supervision-tree stuff gen_server does behind the scenes. >> > >> > Hope this helps! >> > >> > -- Samuel >> > >> > On Fri, Feb 15, 2008 at 2:16 PM, Robin wrote: >> > >> >> Does gen_tcp:accept() block the entire OS thread or just the calling >> >> erlang process? >> >> >> >> "One of the shortcomings of the gen_tcp module is that it only exports >> >> interface to a blocking accept call." -> >> >> >> >> >> http://www.trapexit.org/Building_a_Non-blocking_TCP_server_using_OTP_principles >> >> >> >> >> Does the performance gain of non-blocking accept justify the added >> >> complexity (finite state machine etc)? >> >> >> >> thanks, >> >> >> >> Robin >> >> _______________________________________________ >> >> erlang-questions mailing list >> >> erlang-questions >> >> http://www.erlang.org/mailman/listinfo/erlang-questions >> >> >> > >> > >> > >> ------------------------------------------------------------------------ >> > >> > _______________________________________________ >> > erlang-questions mailing list >> > erlang-questions >> > http://www.erlang.org/mailman/listinfo/erlang-questions >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions >> http://www.erlang.org/mailman/listinfo/erlang-questions > > From rrerlang Wed Feb 13 13:20:47 2008 From: rrerlang (Robert Raschke) Date: Wed, 13 Feb 2008 12:20:47 +0000 Subject: [erlang-questions] Service Change request in C node In-Reply-To: Message-ID: <43670c78a0983a7bfb0d42511cdb9edf@tombob.com> I haven't used erl_interface in a very long time. I would use ei instead these days. And having dug out some very old code of mine, here's how I used to decode/encode lists of strings. Maybe you can use this as a pointer in the right direction. In essence, you will need to unpack the list by first figuring out how many elements are in it, and then traversing the list, getting your strings. I'm sure a solution using erl_interface would be reasonably similar in structure. #include "ei.h" void build_result(ei_x_buff *args, ei_x_buff *result) { int n=0; char **s_array=NULL; int k; if (ei_decode_list_header(args->buff, &args->index, &n) < 0) { error(); return; } if (n > 0) { if ((s_array = decode_string_list(args->buff, &args->index, n)) == NULL) { error(); return; } } /* result is list of strings */ for (k = 0; k < n; k++) { ei_x_encode_list_header(result, 1); ei_x_encode_string(result, s_array[k]); } ei_x_encode_empty_list(result); } char ** decode_string_list(const char *buff, int *index, int n) { int i; int type; int len; int arity; char **s_array = (char **) calloc(n, sizeof(char *)); for (i = 0; i < n; i++) { ei_get_type(buff, index, &type, &len); s_array[i] = (char *) malloc(len + 1); if (ei_decode_string(buff, index, s_array[i]) < 0) { free_string_array(s_array, i+1); return NULL; } } /* Trailing [] (NIL). */ if (ei_decode_list_header(buff, index, &arity) < 0 || arity != 0) { free_string_array(s_array, n); return NULL; } return s_array; } void free_string_array(char **s_array, int n) { int i; for (i = 0; i < n; i++) { free(s_array[i]); } free(s_array); } Robby From masterofquestions Sat Feb 16 22:18:49 2008 From: masterofquestions (db) Date: Sat, 16 Feb 2008 13:18:49 -0800 (PST) Subject: [erlang-questions] compile debug_info smart_expections via autoconf automake? In-Reply-To: References: Message-ID: <74b669d0-7684-45b6-8d6e-e6b9932d0357@q70g2000hsb.googlegroups.com> This works for debug_info: ./configure ERLCFLAGS='+defug_info' I want to also compile with smart_exceptions, but not sure how to call it from command line or by setting ERLCFLAGS. I have it in my Emakefile as: {"./src/*", [debug_info,{parse_transform,smart_exceptions}, {outdir, "./ebin"}]}. smart_exceptions are great for newbie and helps when you trying to understand someone else code. Thomas Lindgren, how about spilling some of your wisdoms. It's a great tool by the way. On Feb 15, 12:37 pm, db wrote: > How do you setup configure.ac and Makefile.am to compile erlang > programs with debug_info and/or smart_expections flags? > > My sample test_app setup files are found here:http://groups.google.com/group/erlang-questions/browse_thread/thread/... > _______________________________________________ > erlang-questions mailing list > erlang-questi...://www.erlang.org/mailman/listinfo/erlang-questions From pfisher Sun Feb 17 07:38:24 2008 From: pfisher (Paul Fisher) Date: Sun, 17 Feb 2008 00:38:24 -0600 Subject: [erlang-questions] EEP 8 applied to bahavior definitions? Message-ID: <1203230304.6046.47.camel@pfisher-laptop> It would be nice if the type and function specifications found in EEP 8 could be applied to behavior definitions. Something along the lines of how records are handled (but I don't have a firm suggestion on syntax). Thoughts? -- paul From gerold Sun Feb 17 11:24:42 2008 From: gerold (cactus) Date: Sun, 17 Feb 2008 02:24:42 -0800 (PST) Subject: [erlang-questions] [erl -name] crashes on vista In-Reply-To: References: <0a3701c86698$7dc67780$79536680$@at> <65b64fcd-c89a-40f1-b59d-1c828898f9d0@s19g2000prg.googlegroups.com> <95be1d3b0802041100t3a2eb6f7t661fbeb518e5b7d9@mail.gmail.com> Message-ID: <3599895d-b8ec-43ca-8613-a963a9501b8f@72g2000hsu.googlegroups.com> so - after installing of servicepack 1 for vista -> EVERYTHING WORKS FINE NOW :-) strange - but we can close this thread now :-) greetz from vienna On 4 Feb., 21:05, cactus wrote: > hej, > so i tried to run the epmd directly: > * on standard port 4369 it fails > * on other port e.g. 4368 it works > > ----------------------------------------------------------------- > C:\Program Files\erl5.6\erts-5.6\bin>epmd -port 4369 > epmd: Mon Feb 04 20:58:49 2008: epmd running - daemon = 0 > epmd: Mon Feb 04 20:58:49 2008: failed to bind socket: No error > > C:\Program Files\erl5.6\erts-5.6\bin>epmd -port 4368 > epmd: Mon Feb 04 20:58:57 2008: epmd running - daemon = 0 > ------------------------------------------------------------------ > > * the 'erl -sname' gives me the same error message than the 'erl - > name' > > => can i specify when i start 'erl -name' that it should use other > port than standard ? > > => i also will check again my firewall settings..... > > On Feb 4, 8:00?pm, "Vlad Dumitrescu" wrote: > > > > > Hi, > > > On Feb 4, 2008 6:58 PM, cactus wrote: > > > > hi - hmmmm on my windows xp box (where everything works fine) i did > > > not have to run an epmd > > > When starting an Erlang node with "erl -sname" or "erl -name", epmd > > should get started automatically. You can check the process list to > > see if it's there. > > > > => by the way - what is the epmd for - sounds like some kind of unix > > > style daemon ? > > > yes, something like that. If you checkhttp://www.erlang.org/doc/apps/erts/index.html, you will be able to > > find the documentation for it. > > > > => so for me it looks like thatvistasomehow blocks registering of > > > erlang node > > > => i already turned off all the firewalls ... > > > has anyone any experience with erlang onvista? > > > It works for me without problems. Could you try "erl -sname h1"? For > > me it doesn't work to use -name without specifying a full host name > > (but there's a different error message). > > > best regards, > > Vlad > > _______________________________________________ > > erlang-questions mailing list > > erlang-questi...://www.erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > erlang-questions mailing list > erlang-questi...://www.erlang.org/mailman/listinfo/erlang-questions- Zitierten Text ausblenden - > > - Zitierten Text anzeigen - From icejmx Sun Feb 17 14:03:11 2008 From: icejmx (=?BIG5?B?usu6yw==?=) Date: Sun, 17 Feb 2008 21:03:11 +0800 Subject: [erlang-questions] help about process,why very slow. In-Reply-To: <47B70925.5080805@itsbeen.sent.com> References: <47B657CE.4050105@gmail.com> <47B70925.5080805@itsbeen.sent.com> Message-ID: hi! I checked the server found in erlang shell activated when launched smp, my server is single core, smp cancelled after the running of the entire service soon, but still high cpu occupiers, the test data will be 1000000 continuing seconds cpu 99% usage, may I ask you what optimization approach? Cpu occupiers will be reduced? thanks All! 2008/2/17 myname iserl : > Hi, > > Sorry, for offlist. > I don't use erlang yet and I don't really know erlang at all, > but I read the list often. > > For monitoring why your server is using 99% you might try: > > http://www.erlang.org/documentation/doc-5.2/lib/observer-0.9/doc/html/etop_ug.html > http://www.erlang.org/doc/efficiency_guide/profiling.html > > http://www.erlang.org/doc/man/eprof.html > http://www.erlang.org/doc/man/fprof.html > http://www.erlang.org/doc/apps/tools/cprof_chapter.html > > Good luck > > ?? wrote: > > thanks! > > I was revised to {active,once} and server cpu still occupy 99%, but my > > code in the local tests, use 127.0.0.1 ,100 million > > run by 40 seconds, and even in the server 127.0.0.1 > > of the cpu will be 99%. > > > > Is there any way to find out whether there is a server cpu 99%? > > > > very thanks! > > > > 2008/2/16 Sean Hinde >>: > > > > The problem here is almost certainly your use of {active, true}. The > > inbound mailbox will rapidly fill with a very large number of > messages > > (1 million in your case), and this can cause the emulator to slow > down > > during garbage collection. > > > > You need to introduce some flow control. The {active,once} socket > > option is normally used for this. > > > > Sean > > > > On 16 Feb 2008, at 12:18, ?? wrote: > > > > > help! > > > > > > On Feb 16, 2008 11:32 AM, ?? > > wrote: > > > server code url > > > http://icej.80s.net.cn/emssserver.erl > > > > > > On Sat, Feb 16, 2008 at 11:26 AM, ?? > > wrote: > > > > > > Hello everyone! I recent study erlang familiar with the code to > > make a > > > message transmitted server, have a problem! > > > > > > I development of the information transmitted server function: > > > Aclient Bclient are connected to Server, and joined a group C, > > Aclient > > > send message to group C , message will be transmitted to B by > > group C. > > > SOCKET use the binary (active true), (2) packet. > > > > > > News Server design: > > > Have a process responsible for monitoring all client even when > the > > > client connect server, another process (group_manager process) > > > maintenance division List of members of the client group, each > group > > > (group process) to have an process within the group responsible > for > > > the > > > client to transmit message. > > > > > > > > > Performance testing problems encountered by: > > > A test of million sent to the SERVER message used on the finished > > > eight > > > seconds, and automatic logoff, and the content of the message are > the > > > same, so, the test Lan network. > > > SERVER through tcpdump monitor and indeed also in the eight > seconds > > > are > > > all the message at the end, and not from the message into the A, > > > however > > > SERVER transmitted to the messages with for a very long time, > over 10 > > > minutes, finally, I end of the process. > > > > > > In server,use top,the cpu is 99% by beam.smp. > > > PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND > > > 31586 root 17 0 70564 18m 1868 S 99.9 0.9 15:46.12 beam.smp > > > > > > Is it a problem I designed a very slow ? Or as a result of the > > process > > > of communication? What measures can be taken tuning? > > > > > > Thank you help! > > > > > > the server code > > > # -module(emssserver). > > > # -export([init/0]). > > > # -define(TCP_OPTIONS,[binary,{packet, 2}, {active, true}, > > {reuseaddr, > > > true}]). > > > # -define(PORT,7000). > > > # -define(Debug,"YES"). > > > # > > > # -ifdef(Debug). > > > # -define(DEBUG(Fmt, Args), io:format(Fmt, Args)). > > > # -else. > > > # -define(DEBUG(Fmt, Args), no_debug). > > > # -endif. > > > # -record(group,{name,gpid}). > > > # -record(client, {name,pid,socket}). > > > # > > > # init()-> > > > # {ok, Listen} = gen_tcp:listen(?PORT, ?TCP_OPTIONS), > > > # register(accept_connection, spawn(fun() -> > > accept_connection(Listen) > > > end)), > > > # register(group_manage, spawn(fun() -> group_manage([]) end)). > > > # > > > # accept_connection(Listen) ->%% listen new client connection > > > # {ok, Socket} = gen_tcp:accept(Listen), > > > # Pid = spawn(fun() -> client_recv(Socket,"","") end), > > > # gen_tcp:controlling_process(Socket,Pid), > > > # accept_connection(Listen). > > > # > > > # client_recv(Socket,ClientName,GroupPid)->%%client process recv > > > # receive > > > # {tcp, Socket, Bin} -> > > > # ?DEBUG("Server recv Data\r\n",""), > > > # case binary_to_term(Bin) of > > > # {join,JoinName,ClientNameTmp}->%%client join > > > # ?DEBUG("client_recv Join:~s ~s\r\n",[JoinName,ClientNameTmp]), > > > # G=#group{name=JoinName}, > > > # group_manage ! {join,G,self()},%%get group pid > > > # receive > > > # {grouppid,GPid}->%%recv group pid > > > # ?DEBUG("Client_recv grouppid ~w ~s\r\n",[GPid,ClientNameTmp]), > > > # GPid!{join,Socket,ClientNameTmp,self()} %% send "join" msg to > group > > > # end, > > > # client_recv(Socket,ClientNameTmp,GPid); > > > # {send,GroupName,Msg}->%%send msg to group > > > # ?DEBUG("client_recv Send:~s ~s\r\n",[GroupName,Msg]), > > > # GroupPid!{send,ClientName,Msg}, > > > # client_recv(Socket,ClientName,GroupPid) > > > # end; > > > # {tcp_closed, Socket} -> > > > # ?DEBUG("client_recv close\r\n",[]) > > > # end. > > > # > > > # group_manage(Group)->%%manage group member > > > # ?DEBUG("group_manage start\r\n",[]), > > > # receive > > > # {join,JoinGroup,ClientPid}-> > > > # ?DEBUG("group_manage Join:~s\r\n",[JoinGroup#group.name]), > > > # case lists:keysearch(JoinGroup#group.name, #group.name, Group) > of > > > # false -> > > > # Pid=spawn(fun() -> group([]) end), > > > # ?DEBUG("group_manage group pid~w\r\n",[Pid]), > > > # ClientPid!{grouppid,Pid},%%return client_recv group pid > > > # JoinGroupp = #group{name=JoinGroup#group.name,gpid=Pid}, > > > # Gs = [JoinGroupp|Group], > > > # ?DEBUG("group_manage group:~w\r\n",[Gs]), > > > # group_manage(Gs); > > > # {value,SingleGroup} -> > > > # ?DEBUG("group_manage group is set > > ~s\r\n",[SingleGroup#group.name]), > > > # ClientPid!{grouppid,SingleGroup#group.gpid}, > > > # group_manage(Group) > > > # end > > > # > > > # end. > > > # > > > # group(Client)->%%send msg to all > > > # ?DEBUG("group \r\n",[]), > > > # receive > > > # {join,Socket,ClientName,CPid} -> > > > # ?DEBUG("group ClientName ~s\r\n",[ClientName]), > > > # ?DEBUG("group Client set ~w\r\n",[Client]), > > > # case lists:keysearch(ClientName,#client.name,Client) of > > > # false-> > > > # ?DEBUG("group new client\r\n",[]), > > > # ClientNew = #client{name=ClientName,pid=CPid,socket=Socket}, > > > # ClientTmp = [ClientNew|Client], > > > # group(ClientTmp); > > > # {value,SingleClient}-> > > > # ?DEBUG("group client is set > ~s\r\n",[SingleClient#client.name]), > > > # group(Client) > > > # end; > > > # {send,ClientName,Msg}-> > > > # ?DEBUG("group recv client send ~s\r\n",[Msg]), > > > # lists:foreach(fun(T)->send(ClientName,T,Msg) end,Client), > > > # group(Client) > > > # end, > > > # ok. > > > # > > > # send(FClientName,TClientName,Msg)-> > > > # if > > > # FClientName /= TClientName#client.name -> > > > # ?DEBUG("send f:~s t:~s > > > ~s\r\n",[FClientName,TClientName#client.name,Msg]), > > > # M = {FClientName,Msg}, > > > # gen_tcp:send(TClientName#client.socket,term_to_binary(M)); > > > # true-> > > > # ?DEBUG("send from eq to\r\n",[]) > > > # end. > > > > > > the client code is "gen_tcp:send",iterative > > > > > > the code install three linux server. > > > > > > > > > > > > > > > -- > > > ??:erlang,python,php,java > > > --------------------------------------------- > > > ????? > > > http://blog.80s.net.cn > > > > > > > > > > > > -- > > > ??:erlang,python,php,java > > > --------------------------------------------- > > > ????? > > > http://blog.80s.net.cn > > > _______________________________________________ > > > erlang-questions mailing list > > > erlang-questions > > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > > > > > > -- > > ??:erlang,python,php,java > > --------------------------------------------- > > ????? > > http://blog.80s.net.cn > > > > > > ------------------------------------------------------------------------ > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions > > http://www.erlang.org/mailman/listinfo/erlang-questions > -- ??:erlang,python,php,java --------------------------------------------- ????? http://blog.80s.net.cn -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080217/6d152813/attachment-0001.html From sean.hinde Sun Feb 17 14:19:18 2008 From: sean.hinde (Sean Hinde) Date: Sun, 17 Feb 2008 13:19:18 +0000 Subject: [erlang-questions] help about process,why very slow. In-Reply-To: References: <47B657CE.4050105@gmail.com> <47B70925.5080805@itsbeen.sent.com> Message-ID: <85293094-E978-4728-9D0D-616B9B6FBBB8@gmail.com> Hi, Why do you think the CPU should be anything other than 100% when you have just sent 1000000 messages into the system. It is of course busy processing the messages. Sean On 17 Feb 2008, at 13:03, ?? wrote: > hi! > I checked the server found in erlang shell activated when launched > smp, my server is single core, smp cancelled after the running of > the entire service soon, but still high cpu occupiers, the test data > will be 1000000 continuing seconds cpu 99% usage, may I ask you what > optimization approach? Cpu occupiers will be reduced? > > thanks All! > > 2008/2/17 myname iserl : > Hi, > > Sorry, for offlist. > I don't use erlang yet and I don't really know erlang at all, > but I read the list often. > > For monitoring why your server is using 99% you might try: > http://www.erlang.org/documentation/doc-5.2/lib/observer-0.9/doc/html/etop_ug.html > http://www.erlang.org/doc/efficiency_guide/profiling.html > > http://www.erlang.org/doc/man/eprof.html > http://www.erlang.org/doc/man/fprof.html > http://www.erlang.org/doc/apps/tools/cprof_chapter.html > > Good luck > > ?? wrote: > > thanks! > > I was revised to {active,once} and server cpu still occupy 99%, > but my > > code in the local tests, use 127.0.0.1 ,100 > million > > run by 40 seconds, and even in the server 127.0.0.1 > > > of the cpu will be 99%. > > > > Is there any way to find out whether there is a server cpu 99%? > > > > very thanks! > > > > 2008/2/16 Sean Hinde >>: > > > > The problem here is almost certainly your use of {active, > true}. The > > inbound mailbox will rapidly fill with a very large number of > messages > > (1 million in your case), and this can cause the emulator to > slow down > > during garbage collection. > > > > You need to introduce some flow control. The {active,once} > socket > > option is normally used for this. > > > > Sean > > > > On 16 Feb 2008, at 12:18, ?? wrote: > > > > > help! > > > > > > On Feb 16, 2008 11:32 AM, ?? > > wrote: > > > server code url > > > http://icej.80s.net.cn/emssserver.erl > > > > > > On Sat, Feb 16, 2008 at 11:26 AM, ?? > > wrote: > > > > > > Hello everyone! I recent study erlang familiar with the > code to > > make a > > > message transmitted server, have a problem! > > > > > > I development of the information transmitted server function: > > > Aclient Bclient are connected to Server, and joined a group > C, > > Aclient > > > send message to group C , message will be transmitted to B by > > group C. > > > SOCKET use the binary (active true), (2) packet. > > > > > > News Server design: > > > Have a process responsible for monitoring all client even > when the > > > client connect server, another process (group_manager > process) > > > maintenance division List of members of the client group, > each group > > > (group process) to have an process within the group > responsible for > > > the > > > client to transmit message. > > > > > > > > > Performance testing problems encountered by: > > > A test of million sent to the SERVER message used on the > finished > > > eight > > > seconds, and automatic logoff, and the content of the > message are the > > > same, so, the test Lan network. > > > SERVER through tcpdump monitor and indeed also in the eight > seconds > > > are > > > all the message at the end, and not from the message into > the A, > > > however > > > SERVER transmitted to the messages with for a very long > time, over 10 > > > minutes, finally, I end of the process. > > > > > > In server,use top,the cpu is 99% by beam.smp. > > > PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND > > > 31586 root 17 0 70564 18m 1868 S 99.9 0.9 15:46.12 beam.smp > > > > > > Is it a problem I designed a very slow ? Or as a result of > the > > process > > > of communication? What measures can be taken tuning? > > > > > > Thank you help! > > > > > > the server code > > > # -module(emssserver). > > > # -export([init/0]). > > > # -define(TCP_OPTIONS,[binary,{packet, 2}, {active, true}, > > {reuseaddr, > > > true}]). > > > # -define(PORT,7000). > > > # -define(Debug,"YES"). > > > # > > > # -ifdef(Debug). > > > # -define(DEBUG(Fmt, Args), io:format(Fmt, Args)). > > > # -else. > > > # -define(DEBUG(Fmt, Args), no_debug). > > > # -endif. > > > # -record(group,{name,gpid}). > > > # -record(client, {name,pid,socket}). > > > # > > > # init()-> > > > # {ok, Listen} = gen_tcp:listen(?PORT, ?TCP_OPTIONS), > > > # register(accept_connection, spawn(fun() -> > > accept_connection(Listen) > > > end)), > > > # register(group_manage, spawn(fun() -> group_manage([]) > end)). > > > # > > > # accept_connection(Listen) ->%% listen new client connection > > > # {ok, Socket} = gen_tcp:accept(Listen), > > > # Pid = spawn(fun() -> client_recv(Socket,"","") end), > > > # gen_tcp:controlling_process(Socket,Pid), > > > # accept_connection(Listen). > > > # > > > # client_recv(Socket,ClientName,GroupPid)->%%client process > recv > > > # receive > > > # {tcp, Socket, Bin} -> > > > # ?DEBUG("Server recv Data\r\n",""), > > > # case binary_to_term(Bin) of > > > # {join,JoinName,ClientNameTmp}->%%client join > > > # ?DEBUG("client_recv Join:~s ~s\r\n", > [JoinName,ClientNameTmp]), > > > # G=#group{name=JoinName}, > > > # group_manage ! {join,G,self()},%%get group pid > > > # receive > > > # {grouppid,GPid}->%%recv group pid > > > # ?DEBUG("Client_recv grouppid ~w ~s\r\n", > [GPid,ClientNameTmp]), > > > # GPid!{join,Socket,ClientNameTmp,self()} %% send "join" > msg to group > > > # end, > > > # client_recv(Socket,ClientNameTmp,GPid); > > > # {send,GroupName,Msg}->%%send msg to group > > > # ?DEBUG("client_recv Send:~s ~s\r\n",[GroupName,Msg]), > > > # GroupPid!{send,ClientName,Msg}, > > > # client_recv(Socket,ClientName,GroupPid) > > > # end; > > > # {tcp_closed, Socket} -> > > > # ?DEBUG("client_recv close\r\n",[]) > > > # end. > > > # > > > # group_manage(Group)->%%manage group member > > > # ?DEBUG("group_manage start\r\n",[]), > > > # receive > > > # {join,JoinGroup,ClientPid}-> > > > # ?DEBUG("group_manage Join:~s\r\n",[JoinGroup#group.name]), > > > # case lists:keysearch(JoinGroup#group.name, #group.name, > Group) of > > > # false -> > > > # Pid=spawn(fun() -> group([]) end), > > > # ?DEBUG("group_manage group pid~w\r\n",[Pid]), > > > # ClientPid!{grouppid,Pid},%%return client_recv group pid > > > # JoinGroupp = #group{name=JoinGroup#group.name,gpid=Pid}, > > > # Gs = [JoinGroupp|Group], > > > # ?DEBUG("group_manage group:~w\r\n",[Gs]), > > > # group_manage(Gs); > > > # {value,SingleGroup} -> > > > # ?DEBUG("group_manage group is set > > ~s\r\n",[SingleGroup#group.name]), > > > # ClientPid!{grouppid,SingleGroup#group.gpid}, > > > # group_manage(Group) > > > # end > > > # > > > # end. > > > # > > > # group(Client)->%%send msg to all > > > # ?DEBUG("group \r\n",[]), > > > # receive > > > # {join,Socket,ClientName,CPid} -> > > > # ?DEBUG("group ClientName ~s\r\n",[ClientName]), > > > # ?DEBUG("group Client set ~w\r\n",[Client]), > > > # case lists:keysearch(ClientName,#client.name,Client) of > > > # false-> > > > # ?DEBUG("group new client\r\n",[]), > > > # ClientNew = > #client{name=ClientName,pid=CPid,socket=Socket}, > > > # ClientTmp = [ClientNew|Client], > > > # group(ClientTmp); > > > # {value,SingleClient}-> > > > # ?DEBUG("group client is set ~s\r\n", > [SingleClient#client.name]), > > > # group(Client) > > > # end; > > > # {send,ClientName,Msg}-> > > > # ?DEBUG("group recv client send ~s\r\n",[Msg]), > > > # lists:foreach(fun(T)->send(ClientName,T,Msg) end,Client), > > > # group(Client) > > > # end, > > > # ok. > > > # > > > # send(FClientName,TClientName,Msg)-> > > > # if > > > # FClientName /= TClientName#client.name -> > > > # ?DEBUG("send f:~s t:~s > > > ~s\r\n",[FClientName,TClientName#client.name,Msg]), > > > # M = {FClientName,Msg}, > > > # gen_tcp:send(TClientName#client.socket,term_to_binary(M)); > > > # true-> > > > # ?DEBUG("send from eq to\r\n",[]) > > > # end. > > > > > > the client code is "gen_tcp:send",iterative > > > > > > the code install three linux server. > > > > > > > > > > > > > > > -- > > > ??:erlang,python,php,java > > > --------------------------------------------- > > > ????? > > > http://blog.80s.net.cn > > > > > > > > > > > > -- > > > ??:erlang,python,php,java > > > --------------------------------------------- > > > ????? > > > http://blog.80s.net.cn > > > _______________________________________________ > > > erlang-questions mailing list > > > erlang-questions > > > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > > > > > > -- > > ??:erlang,python,php,java > > --------------------------------------------- > > ????? > > http://blog.80s.net.cn > > > > > > > ------------------------------------------------------------------------ > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > -- > ??:erlang,python,php,java > --------------------------------------------- > ????? > http://blog.80s.net.cn > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions From sgolovan Sun Feb 17 15:06:23 2008 From: sgolovan (Sergei Golovan) Date: Sun, 17 Feb 2008 17:06:23 +0300 Subject: [erlang-questions] Internal error in v3_codegen on Linux@Sparc Message-ID: Hi! Building of Erlang/OTP R12B-1 on Debian Linux at Sparc architecture (Dual-core UltraSPARC III machine) gave the following error: erlc -W +debug_info -I/build/buildd/erlang-12.b.1-dfsg/lib/stdlib +warn_unused_vars -o../ebin asn1rt_ber_bin_v2.erl Function: encode_tags/2 ./asn1rt_ber_bin_v2.erl:none: internal error in v3_codegen; crash reason: {{case_clause, {'EXIT', {{case_clause, {{{l, {block, [{l,{match_fail,{badmatch,{var,ker46}}},44,[],[]}]}, 43, [{ker46,40,44}], []}, {ker46,40,42}}, {{sr,[{0,cor1},{1,cor0}],[],[]},0}}}, [{v3_codegen,'-select_extract_tuple/6-anonymous-0-',5}, {v3_codegen,select_extract_tuple,6}, {v3_codegen,select_val,5}, {v3_codegen,'-select_cg/6-anonymous-0-',5}, {lists,mapfoldl,3}, {v3_codegen,select_cg,6}, {v3_codegen,match_cg,5}, {v3_codegen,match_cg,6}]}}}, [{compile,'-select_passes/2-anonymous-2-',2}, {compile,'-internal_comp/4-anonymous-1-',2}, {compile,fold_comp,3}, {compile,internal_comp,4}, {compile,internal,3}]} (full build log is available at http://buildd.debian.org/fetch.cgi?&pkg=erlang&ver=1%3A12.b.1-dfsg-2&arch=sparc&stamp=1203250875&file=log) Is this a bug in compiler, or may be the error reflects some deeper problem (in Erlang VM, or even in Linux kernel)? Building the same sources several days ago ended up with a segfault during the same asn1rt_ber_bin_v2.erl compiling). -- Sergei Golovan From icejmx Sun Feb 17 15:16:32 2008 From: icejmx (=?GB2312?B?w+nD6Q==?=) Date: Sun, 17 Feb 2008 22:16:32 +0800 Subject: [erlang-questions] help about process,why very slow. In-Reply-To: <85293094-E978-4728-9D0D-616B9B6FBBB8@gmail.com> References: <47B657CE.4050105@gmail.com> <47B70925.5080805@itsbeen.sent.com> <85293094-E978-4728-9D0D-616B9B6FBBB8@gmail.com> Message-ID: <47B841C0.1090200@gmail.com> Sean Hinde ??: > Hi, > > Why do you think the CPU should be anything other than 100% when you > have just sent 1000000 messages into the system. It is of course busy > processing the messages. > > Sean > > On 17 Feb 2008, at 13:03, ?? wrote: > >> hi! >> I checked the server found in erlang shell activated when launched >> smp, my server is single core, smp cancelled after the running of the >> entire service soon, but still high cpu occupiers, the test data will >> be 1000000 continuing seconds cpu 99% usage, may I ask you what >> optimization approach? Cpu occupiers will be reduced? >> >> thanks All! >> >> 2008/2/17 myname iserl : >> Hi, >> >> Sorry, for offlist. >> I don't use erlang yet and I don't really know erlang at all, >> but I read the list often. >> >> For monitoring why your server is using 99% you might try: >> http://www.erlang.org/documentation/doc-5.2/lib/observer-0.9/doc/html/etop_ug.html >> >> http://www.erlang.org/doc/efficiency_guide/profiling.html >> >> http://www.erlang.org/doc/man/eprof.html >> http://www.erlang.org/doc/man/fprof.html >> http://www.erlang.org/doc/apps/tools/cprof_chapter.html >> >> Good luck >> >> ?? wrote: >> > thanks! >> > I was revised to {active,once} and server cpu still occupy 99%, but my >> > code in the local tests, use 127.0.0.1 ,100 million >> > run by 40 seconds, and even in the server 127.0.0.1 >> >> > of the cpu will be 99%. >> > >> > Is there any way to find out whether there is a server cpu 99%? >> > >> > very thanks! >> > >> > 2008/2/16 Sean Hinde > >: >> > >> > The problem here is almost certainly your use of {active, true}. The >> > inbound mailbox will rapidly fill with a very large number of messages >> > (1 million in your case), and this can cause the emulator to slow down >> > during garbage collection. >> > >> > You need to introduce some flow control. The {active,once} socket >> > option is normally used for this. >> > >> > Sean >> > >> > On 16 Feb 2008, at 12:18, ?? wrote: >> > >> > > help! >> > > >> > > On Feb 16, 2008 11:32 AM, ?? > > > wrote: >> > > server code url >> > > http://icej.80s.net.cn/emssserver.erl >> > > >> > > On Sat, Feb 16, 2008 at 11:26 AM, ?? > > > wrote: >> > > >> > > Hello everyone! I recent study erlang familiar with the code to >> > make a >> > > message transmitted server, have a problem! >> > > >> > > I development of the information transmitted server function: >> > > Aclient Bclient are connected to Server, and joined a group C, >> > Aclient >> > > send message to group C , message will be transmitted to B by >> > group C. >> > > SOCKET use the binary (active true), (2) packet. >> > > >> > > News Server design: >> > > Have a process responsible for monitoring all client even when the >> > > client connect server, another process (group_manager process) >> > > maintenance division List of members of the client group, each group >> > > (group process) to have an process within the group responsible for >> > > the >> > > client to transmit message. >> > > >> > > >> > > Performance testing problems encountered by: >> > > A test of million sent to the SERVER message used on the finished >> > > eight >> > > seconds, and automatic logoff, and the content of the message are >> the >> > > same, so, the test Lan network. >> > > SERVER through tcpdump monitor and indeed also in the eight seconds >> > > are >> > > all the message at the end, and not from the message into the A, >> > > however >> > > SERVER transmitted to the messages with for a very long time, >> over 10 >> > > minutes, finally, I end of the process. >> > > >> > > In server,use top,the cpu is 99% by beam.smp. >> > > PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND >> > > 31586 root 17 0 70564 18m 1868 S 99.9 0.9 15:46.12 beam.smp >> > > >> > > Is it a problem I designed a very slow ? Or as a result of the >> > process >> > > of communication? What measures can be taken tuning? >> > > >> > > Thank you help! >> > > >> > > the server code >> > > # -module(emssserver). >> > > # -export([init/0]). >> > > # -define(TCP_OPTIONS,[binary,{packet, 2}, {active, true}, >> > {reuseaddr, >> > > true}]). >> > > # -define(PORT,7000). >> > > # -define(Debug,"YES"). >> > > # >> > > # -ifdef(Debug). >> > > # -define(DEBUG(Fmt, Args), io:format(Fmt, Args)). >> > > # -else. >> > > # -define(DEBUG(Fmt, Args), no_debug). >> > > # -endif. >> > > # -record(group,{name,gpid}). >> > > # -record(client, {name,pid,socket}). >> > > # >> > > # init()-> >> > > # {ok, Listen} = gen_tcp:listen(?PORT, ?TCP_OPTIONS), >> > > # register(accept_connection, spawn(fun() -> >> > accept_connection(Listen) >> > > end)), >> > > # register(group_manage, spawn(fun() -> group_manage([]) end)). >> > > # >> > > # accept_connection(Listen) ->%% listen new client connection >> > > # {ok, Socket} = gen_tcp:accept(Listen), >> > > # Pid = spawn(fun() -> client_recv(Socket,"","") end), >> > > # gen_tcp:controlling_process(Socket,Pid), >> > > # accept_connection(Listen). >> > > # >> > > # client_recv(Socket,ClientName,GroupPid)->%%client process recv >> > > # receive >> > > # {tcp, Socket, Bin} -> >> > > # ?DEBUG("Server recv Data\r\n",""), >> > > # case binary_to_term(Bin) of >> > > # {join,JoinName,ClientNameTmp}->%%client join >> > > # ?DEBUG("client_recv Join:~s ~s\r\n",[JoinName,ClientNameTmp]), >> > > # G=#group{name=JoinName}, >> > > # group_manage ! {join,G,self()},%%get group pid >> > > # receive >> > > # {grouppid,GPid}->%%recv group pid >> > > # ?DEBUG("Client_recv grouppid ~w ~s\r\n",[GPid,ClientNameTmp]), >> > > # GPid!{join,Socket,ClientNameTmp,self()} %% send "join" msg to >> group >> > > # end, >> > > # client_recv(Socket,ClientNameTmp,GPid); >> > > # {send,GroupName,Msg}->%%send msg to group >> > > # ?DEBUG("client_recv Send:~s ~s\r\n",[GroupName,Msg]), >> > > # GroupPid!{send,ClientName,Msg}, >> > > # client_recv(Socket,ClientName,GroupPid) >> > > # end; >> > > # {tcp_closed, Socket} -> >> > > # ?DEBUG("client_recv close\r\n",[]) >> > > # end. >> > > # >> > > # group_manage(Group)->%%manage group member >> > > # ?DEBUG("group_manage start\r\n",[]), >> > > # receive >> > > # {join,JoinGroup,ClientPid}-> >> > > # ?DEBUG("group_manage Join:~s\r\n",[JoinGroup#group.name]), >> > > # case lists:keysearch(JoinGroup#group.name, #group.name, Group) of >> > > # false -> >> > > # Pid=spawn(fun() -> group([]) end), >> > > # ?DEBUG("group_manage group pid~w\r\n",[Pid]), >> > > # ClientPid!{grouppid,Pid},%%return client_recv group pid >> > > # JoinGroupp = #group{name=JoinGroup#group.name,gpid=Pid}, >> > > # Gs = [JoinGroupp|Group], >> > > # ?DEBUG("group_manage group:~w\r\n",[Gs]), >> > > # group_manage(Gs); >> > > # {value,SingleGroup} -> >> > > # ?DEBUG("group_manage group is set >> > ~s\r\n",[SingleGroup#group.name]), >> > > # ClientPid!{grouppid,SingleGroup#group.gpid}, >> > > # group_manage(Group) >> > > # end >> > > # >> > > # end. >> > > # >> > > # group(Client)->%%send msg to all >> > > # ?DEBUG("group \r\n",[]), >> > > # receive >> > > # {join,Socket,ClientName,CPid} -> >> > > # ?DEBUG("group ClientName ~s\r\n",[ClientName]), >> > > # ?DEBUG("group Client set ~w\r\n",[Client]), >> > > # case lists:keysearch(ClientName,#client.name,Client) of >> > > # false-> >> > > # ?DEBUG("group new client\r\n",[]), >> > > # ClientNew = #client{name=ClientName,pid=CPid,socket=Socket}, >> > > # ClientTmp = [ClientNew|Client], >> > > # group(ClientTmp); >> > > # {value,SingleClient}-> >> > > # ?DEBUG("group client is set ~s\r\n",[SingleClient#client.name]), >> > > # group(Client) >> > > # end; >> > > # {send,ClientName,Msg}-> >> > > # ?DEBUG("group recv client send ~s\r\n",[Msg]), >> > > # lists:foreach(fun(T)->send(ClientName,T,Msg) end,Client), >> > > # group(Client) >> > > # end, >> > > # ok. >> > > # >> > > # send(FClientName,TClientName,Msg)-> >> > > # if >> > > # FClientName /= TClientName#client.name -> >> > > # ?DEBUG("send f:~s t:~s >> > > ~s\r\n",[FClientName,TClientName#client.name,Msg]), >> > > # M = {FClientName,Msg}, >> > > # gen_tcp:send(TClientName#client.socket,term_to_binary(M)); >> > > # true-> >> > > # ?DEBUG("send from eq to\r\n",[]) >> > > # end. >> > > >> > > the client code is "gen_tcp:send",iterative >> > > >> > > the code install three linux server. >> > > >> > > >> > > >> > > >> > > -- >> > > ??:erlang,python,php,java >> > > --------------------------------------------- >> > > ????? >> > > http://blog.80s.net.cn >> > > >> > > >> > > >> > > -- >> > > ??:erlang,python,php,java >> > > --------------------------------------------- >> > > ????? >> > > http://blog.80s.net.cn >> > > _______________________________________________ >> > > erlang-questions mailing list >> > > erlang-questions >> > > http://www.erlang.org/mailman/listinfo/erlang-questions >> > >> > >> > >> > >> > -- >> > ??:erlang,python,php,java >> > --------------------------------------------- >> > ????? >> > http://blog.80s.net.cn >> > >> > >> > >> ------------------------------------------------------------------------ >> > >> > _______________________________________________ >> > erlang-questions mailing list >> > erlang-questions >> > http://www.erlang.org/mailman/listinfo/erlang-questions >> >> >> >> -- >> ??:erlang,python,php,java >> --------------------------------------------- >> ????? >> http://blog.80s.net.cn >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions >> http://www.erlang.org/mailman/listinfo/erlang-questions > > Because my colleagues tested c development message server spread , I remember that he did not like the cpu to occupy 99% so high, I like to use erlang replacement, I need to said erlang better spread to my boss.trouble. -- ??:erlang,python,java,php -------------------------------- ?????http://blog.80s.net.cn From berlin.brown Sun Feb 17 23:05:07 2008 From: berlin.brown (Berlin Brown) Date: Sun, 17 Feb 2008 17:05:07 -0500 Subject: [erlang-questions] Unicode, decoding the content from a HTML page (www_tools and rfc4627) Message-ID: I was using the rfc4627 library which I think uses "xmerl_ucs:from_utf8(Str)" ... for example. Trying to decode a web page, the binary contents and convert them into utf-8. E.g. I did the following: -module(socialstats). -export([start_social/0]). -import(url, [test/0, raw_get_url/2]). -import(rfc4627, [unicode_decode/1]). start_social() -> io:format("*** Running social statistics~n"), case url:raw_get_url("http://botnode.com/", 60000) of {ok, Data} -> %% val = list_to_binary(xmerl_ucs:from_utf8([Data])), val = rfc4627:unicode_decode(Data), io:format("Data is valid: ~p ~n", val), {ok, Data}; {error, What} -> io:format("ERR:~p ~n", [What]), {error, What} end, io:format("*** Done [!]~n"). -- Berlin Brown http://botspiritcompany.com/botlist/spring/help/about.html From haroldship Sun Feb 17 23:05:51 2008 From: haroldship (Harold Ship) Date: Mon, 18 Feb 2008 00:05:51 +0200 Subject: [erlang-questions] closures and list comprehensions Message-ID: <1052246C-648C-4CDB-925D-1C184B142A0F@bezeqint.net> Hello I'm fairly new to Erlang, and I'm just starting to get the hang of it. I have a question about using spawn/1, giving it a fun which is a closure that contains a list comprehension. The example is like this: my_func([First|Rest]) -> Me = self(), spawn(fun() -> Me ! do_something([X || X <- Rest, X < First]) end), do_something_else(), receive Result -> do_something_with(Result) end. My question is, in which process is the list comprehension evaluated? It seems to me that it should be evaluated in the spawned process but I can't reason it out. Thanks in advance, Harold Ship From dizzyd Mon Feb 18 03:52:56 2008 From: dizzyd (Dave Smith) Date: Sun, 17 Feb 2008 19:52:56 -0700 Subject: [erlang-questions] Associating contextual info with monitors Message-ID: Greetings, On several occasions, I've found myself wanting to be able to do some cleanup (e.g. remove an entry in ets) when a process dies. Usually I solve this by maintaining an ets table keyed by pid, that stores the necessary contextual info needed for cleanup, and then setup a monitor on the pid of interest. This works ok, but it's a little annoying to need to maintain yet another ets table for this context info that is only used when the process dies. It seems like what I _really_ want is a way to associate a term with a monitor -- that way when I get the DOWN message, I would also get the associated term and have everything I need to do the cleanup. Is there a "Right Way" to accomplish this? Maintaining ets tables for this sort of contextual info seems a bit overkill -- is there a simpler approach? Has anyone else ever encountered this sort of issue? I tried searching through the archives for this problem, but couldn't find the right set of search terms. :) Thanks, D. From rpettit Mon Feb 18 03:58:57 2008 From: rpettit (Rick Pettit) Date: Sun, 17 Feb 2008 20:58:57 -0600 Subject: [erlang-questions] Associating contextual info with monitors In-Reply-To: References: Message-ID: <20080218025857.GA10836@vailsys.com> On Sun, Feb 17, 2008 at 07:52:56PM -0700, Dave Smith wrote: > Greetings, > > On several occasions, I've found myself wanting to be able to do some > cleanup (e.g. remove an entry in ets) when a process dies. Usually I > solve this by maintaining an ets table keyed by pid, that stores the > necessary contextual info needed for cleanup, and then setup a monitor > on the pid of interest. This works ok, but it's a little annoying to > need to maintain yet another ets table for this context info that is > only used when the process dies. It seems like what I _really_ want is > a way to associate a term with a monitor -- that way when I get the > DOWN message, I would also get the associated term and have everything > I need to do the cleanup. > > Is there a "Right Way" to accomplish this? Maintaining ets tables for > this sort of contextual info seems a bit overkill -- is there a > simpler approach? Has anyone else ever encountered this sort of issue? > I tried searching through the archives for this problem, but couldn't > find the right set of search terms. :) The way I typically solve this problem is by putting the cleanup code in a gen_server:terminate/2 callback (this way when the gen_server dies it cleans up after itself). For instances where the processes being spawned aren't gen_* servers, I would most likely spawn a wrapper process which in turn spawn_links the real child process, then blocks forever waiting to receive the EXIT for that process (the cleanup code is triggered upon receipt of the EXIT, then the wrapper process itself terminates). -Rick From exta7 Mon Feb 18 04:50:15 2008 From: exta7 (Zvi) Date: Sun, 17 Feb 2008 19:50:15 -0800 (PST) Subject: [erlang-questions] Programming challenge Message-ID: <15538398.post@talk.nabble.com> Hi All, I just looked on LinkedIn for Erlang jobs (out of curriousity, not that I looking for a job) and found this one: http://www.linkedin.com/jobs?viewJob=&jobId=469388&fromSearch=0&sik=1203301840118 Whichbriefly mention Erlang: "Comfortable working with at least one dynamically typed scripting language like Ruby, Python, Erlang or Perl" Then I saw this: "Programming challenge: Without using any built in date or time functions, write a function or method that accepts two mandatory arguments. The first argument is a string of the format "[H]H:MM {AM|PM}" and the second argument is an integer. Assume the integer is the number of minutes to add to the string. The return value of the function should be a string of the same format as the first argument. For example AddMinutes("9:13 AM", 10) would return "9:23 AM". The exercise isn't meant to be too hard. We just want to see how you code. Feel free to do it procedurally or in an object oriented way, whichever you prefer. Use any language you want." So I decided to write it in Erlang. Bellow is my code. Critique is wellcome. Zvi. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -module(time). -author("Zvi"). -export([add/2]). %% add M minutes to the time string Time add(Time, M) when is_list(Time) andalso M>=0 -> add(list_to_binary(Time), M); add(<>, M) when AMPM=:=$A orelse AMPM=:=$P -> MM1 = list_to_integer(binary_to_list(MM)), HH1 = list_to_integer(binary_to_list(HH)), MM2 = MM1 + M, HH2 = HH1 + MM2 div 60, MM3 = MM2 rem 60, HH3 = HH2 rem 12, AMPM2 = toggleAMPM(AMPM, HH2 div 12), pad0(HH3)++":"++pad0(MM3)++" "++[AMPM2]++"M"; add(<<_H:1/bytes,":",_MM:2/bytes," AM">> = Bin, M) -> add(<<"0",Bin/bytes>>, M); add(<<_H:1/bytes,":",_MM:2/bytes," PM">> = Bin, M) -> add(<<"0",Bin/bytes>>, M). pad0(N) when N<10 -> "0"++integer_to_list(N); pad0(N) -> integer_to_list(N). toggleAMPM($A,0) -> $A; toggleAMPM($A,1) -> $P; toggleAMPM($P,0) -> $P; toggleAMPM($P,1) -> $A. -- View this message in context: http://www.nabble.com/Programming-challenge-tp15538398p15538398.html Sent from the Erlang Questions mailing list archive at Nabble.com. From ok Mon Feb 18 06:27:42 2008 From: ok (Richard A.O'Keefe) Date: Mon, 18 Feb 2008 18:27:42 +1300 Subject: [erlang-questions] Strings as Lists In-Reply-To: <518CB40F-9028-4068-B6F7-C612253B6FDE@scaldeferri.com> References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> <2F5E96D5-CF7A-42AC-B04E-CB8183F7AB7D@masklinn.net> <3dbc6d1c0802121413o7480d2abtc913801ceae67e8e@mail.gmail.com> <14EEE3D7-56F1-470A-BCE5-C5B534A6EF88@scaldeferri.com> <972E01DC-2A4D-4EB8-B483-CFD98AB6E87F@cs.otago.ac.nz> <1202974658.4369.24.camel@piko.site> <518CB40F-9028-4068-B6F7-C612253B6FDE@scaldeferri.com> Message-ID: On 16 Feb 2008, at 8:20 am, Kevin Scaldeferri wrote: > > On Feb 14, 2008, at 7:06 PM, Richard A. O'Keefe wrote: > >> I wrote: >>>> No, it has to do with the fact that appending on the right is O(n) >>>> whether one uses lists or arrays. > > Pardon my ignorance, but how it is that concatenating to the end of > a length n immutable list is not O(n)? Isn't it necessary to copy > all the list elements? As you can see from the quoted text above, that's EXACTLY what I said. > > (It's also worth noting that while strictly speaking the append on > a mutable array is O(m), in practice the coefficient is very small > since it's implemented as a single memcpy.) memcpy() isn't that fast. By using suitable (immutable) trees, you can get concatenation down to O(1) while still keeping random access to O(lg n). The way Erlang (ab) uses lists as "iolists" you can get concatenation in O(1) followed by O(n) flattening, so it's easy for an Erlang program to build a string cheaply in either left to right or right to left order using lists, but wouldn't be using binaries. From roger.larsson Wed Feb 13 22:34:44 2008 From: roger.larsson (Roger Larsson) Date: Wed, 13 Feb 2008 22:34:44 +0100 Subject: [erlang-questions] Low Level Virtual Machine (LLVM) for optimization across the intire lifetime of a program Message-ID: <200802132234.44206.roger.larsson@e-gatan.se> Found this interesting report via lwn.net http://llvm.org/pubs/2004-01-30-CGO-LLVM.html From the home page http://llvm.org/ "A compilation strategy designed to enable effective program optimization across the entire lifetime of a program. LLVM supports effective optimization at compile time, link-time (particularly interprocedural), run-time and offline (i.e., after software is installed), while remaining transparent to developers and maintaining compatibility with existing build scripts. A virtual instruction set - LLVM is a low-level object code representation that uses simple RISC-like instructions, but provides rich, language-independent, type information and dataflow (SSA) information about operands. This combination enables sophisticated transformations on object code, while remaining light-weight enough to be attached to the executable. This combination is key to allowing link-time, run-time, and offline transformations. A compiler infrastructure - LLVM is also a collection of source code that implements the language and compilation strategy. The primary components of the LLVM infrastructure are a GCC-based C & C++ front-end, a link-time optimization framework with a growing set of global and interprocedural analyses and transformations, static back-ends for the X86, X86-64, PowerPC 32/64, ARM, Thumb, IA-64, Alpha and SPARC architectures, a back-end which emits portable C code, and a Just-In-Time compiler for X86, X86-64, PowerPC 32/64 processors. LLVM does not imply things that you would expect from a high-level virtual machine. It does not require garbage collection or run-time code generation (In fact, LLVM makes a great static compiler!). Note that optional LLVM components can be used to build high-level virtual machines and other systems that need these services." This sounds like a much better match for code generation than Java or CLI. A suitable examination work? /RogerL From bengt.kleberg Mon Feb 18 09:06:51 2008 From: bengt.kleberg (Bengt Kleberg) Date: Mon, 18 Feb 2008 09:06:51 +0100 Subject: [erlang-questions] closures and list comprehensions In-Reply-To: <1052246C-648C-4CDB-925D-1C184B142A0F@bezeqint.net> References: <1052246C-648C-4CDB-925D-1C184B142A0F@bezeqint.net> Message-ID: <1203322011.5635.4.camel@seasc0625.dyn.rnd.as.sw.ericsson.se> Greetings, You are correct, the list comprehension will be done in the spawned process. Everything in the fun will be done when the fun is evaluated, which is in the new process. bengt On Mon, 2008-02-18 at 00:05 +0200, Harold Ship wrote: > Hello > > I'm fairly new to Erlang, and I'm just starting to get the hang of it. > > I have a question about using spawn/1, giving it a fun which is a > closure that contains a list comprehension. The example is like this: > > my_func([First|Rest]) -> > Me = self(), > spawn(fun() -> Me ! do_something([X || X <- Rest, X < First]) end), > do_something_else(), > receive > Result -> > do_something_with(Result) > end. > > > My question is, in which process is the list comprehension evaluated? > It seems to me that it should be evaluated in the spawned process but > I can't reason it out. > > Thanks in advance, > Harold Ship > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions From opendev Mon Feb 18 09:59:12 2008 From: opendev (Joern) Date: Mon, 18 Feb 2008 09:59:12 +0100 Subject: [erlang-questions] Associating contextual info with monitors In-Reply-To: References: Message-ID: <9e009ad0802180059i1376997dvc0c26373df4c4979@mail.gmail.com> Hello Dave, On 18/02/2008, Dave Smith wrote: > On several occasions, I've found myself wanting to be able to do some > cleanup (e.g. remove an entry in ets) when a process dies. I suppose that's the right way to do it - it was quite a recurring pattern during the Erlang project I undertook last year (for what that's worth). Being able to associate extra data with a monitor would have made this extra functionality obsolete. The state associated with the monitored processes was always in the domain of the monitoring behaviour (e.g. connections per ip address) however. Which meant that in many cases you actually wanted to have access to this information for other reasons than cleaning up. So either there needs to be a possibility to read the extra data from a monitor or you keep just another state term in your process. Best regards from Berlin, Joern From ingela Mon Feb 18 10:20:54 2008 From: ingela (Ingela Anderton Andin) Date: Mon, 18 Feb 2008 10:20:54 +0100 Subject: [erlang-questions] asn1 and the new ssl module In-Reply-To: References: Message-ID: <47B94DF6.6070308@erix.ericsson.se> Hi! The new ssl implementation is pure Erlang as apposed to the old one where all ssl-stuff is handled on c-level and then a clear-text message is sent from c to Erlang via a socket using the inet-driver to parse packet headers. Now in the new implementation the inet-drivers header parsing has to be emulated as the messages received on the socket are encrypted and must be decrypted before header parsing can be done. The first version of new ssl released in R12B is not yet ready to replace the old one. For instance not all packet types are emulated. Only {packet, N} and {packet, cdr} is fully implemented and tested. Before dropping the old ssl-solution of course all documented packet types will be supported. (Probably also the currently undocumented http-packet type.) Regards Ingela -OTP team > Hi all, I'm using the new ssl module to "upgrade" a gen_tcp socket to ssl. But I couldn't find a way to easily receiving asn1 packets from it. My question is, it's possible to use the > {packet,asn1} option when using the new ssl module?. ssl_connection.erl seems to not have any reference to that option. Finally I implemented the buffering and packet delimiting code in > my application, but I wonder if there is an easy and early way to accomplish the same. regards, > -- Pablo Polvorin From Bruce Mon Feb 18 10:28:19 2008 From: Bruce (Bruce Fitzsimons) Date: Mon, 18 Feb 2008 22:28:19 +1300 Subject: [erlang-questions] program: 3GPP Charging Gateway Function - open-cgf Message-ID: <47B94FB3.5010902@Fitzsimons.org> Hello list, I have written a GSM/UMTS Charging Gateway Function server in Erlang, and it is mostly tested and running nicely. This server allows GGSNs, SGSNs, and other things that stream their CDRs over GTP' (gtp prime) to have somewhere to write them to disk. There doesn't appear to be a similar opensource offering anywhere, although I'll admit it is quite a small niche. It is hosted at: http://open-cgf.googlecode.com or http://code.google.com/p/open-cgf/ (all roads lead to Rome) Comments welcome, if you find bugs please use the googlecode issue tracker. The supervisor is currently set not to restart any of the children, so it will crash hard on any errors. Regards, Bruce PS I'm never ever going to name an Erlang project using a hyphen ever again From matthias Mon Feb 18 10:28:42 2008 From: matthias (Matthias Lang) Date: Mon, 18 Feb 2008 10:28:42 +0100 Subject: [erlang-questions] Programming challenge In-Reply-To: <15538398.post@talk.nabble.com> References: <15538398.post@talk.nabble.com> Message-ID: <18361.20426.62069.490233@antilipe.corelatus.se> Zvi writes: > So I decided to write it in Erlang. Bellow is my code. Critique is wellcome. Why do so much work yourself? The io library can do lots for you, i.e. {ok, [H, M, AMPM], []} = io_lib:fread("~d:~d ~s", Time_string), io_lib:fwrite("~p:~2.2.0w ~s", [Hours rem 12, Minutes rem 60, AM]) I don't much like the MM1, MM2, MM3 stuff either, there's an awful lot of shuffling going on there which obscures what's actually being done. The original question said "The exercise isn't meant to be too hard. We just want to see how you code". I didn't think of the problem with wrapping from 11:59 AM to 12:01 PM (your code gets it wrong, it wraps to 00:01 PM) until I tried some cases. I wonder if the "interviewers" outsmarted themselves or if they were being nasty. Not good either way. You also have to decide what to do for a bunch of other odd cases. Is five minutes after midnight 00:05 AM or is it 12:05 AM? Do you allow negative jumps? Negative wrapping across midnight? If a user enters 14:01 PM, should we accept that? What about "9:0 AM"? Anyway, I've spent enough time on this now. My solution is appended. Matt ---------------------------------------------------------------------- -module(time_exercise). -export([add_minutes/2]). add_minutes(Time_string, Jump_minutes) -> {ok, [H, M, AMPM], []} = io_lib:fread("~d:~d ~s", Time_string), Total = time_to_minutes(H, M, AMPM) + Jump_minutes, minutes_to_string(Total). time_to_minutes(Hours, Minutes, "AM") when Hours < 12, Hours >= 0, Minutes < 60, Minutes >= 0 -> Hours * 60 + Minutes; time_to_minutes(Hours, Minutes, "PM") when Hours < 12, Hours >= 0, Minutes < 60, Minutes >= 0 -> (Hours + 12) * 60 + Minutes; time_to_minutes(12, Minutes, "PM") when Minutes < 60, Minutes >= 0 -> 12 * 60 + Minutes. minutes_to_string(Minutes) when Minutes >= 0 -> Hours = (Minutes div 60) rem 24, {A_hours, AMPM} = ampm(Hours), Deep = io_lib:fwrite("~p:~2.2.0w ~s", [A_hours, Minutes rem 60, AMPM]), lists:flatten(Deep). ampm(12) -> {12, "PM"}; ampm(Hours) when Hours > 12 -> {Hours rem 12, "PM"}; ampm(Hours) when Hours < 12 -> {Hours, "AM"}. From vances Mon Feb 18 11:13:06 2008 From: vances (Vance Shipley) Date: Mon, 18 Feb 2008 05:13:06 -0500 Subject: [erlang-questions] 3GPP Home Subscriber Server (HSS) Project Message-ID: <20080218101306.GV59248@h216-235-12-173.host.egate.net> I have just put up the first release of my project to create a Home Subscriber Server (HSS) network element of a 3GPP IP Multimedia Subsystem (IMS) Core Network (CN). You can find it hosted here: http://hss.googlecode.com This project implements the database schema described in 23.008 Subscriber Data, the procedures in 29.228 Signaling and the algorithms in 35.206 MILENAGE. It does not implement the DIAMETER protocol stack itself. My immediate intention is to use it with Yxa providing the SIP stack for CSCF network elements so this is unecessary. It is released under a New BSD License for unrestrictive use. I hope someone finds it interesting or useful. -Vance From j.bhanot Mon Feb 18 11:29:21 2008 From: j.bhanot (J Bhanot) Date: Mon, 18 Feb 2008 15:59:21 +0530 Subject: [erlang-questions] Using erl_call Message-ID: Hi, How can we use erl_call in C node. I have tried using system("erl_call -s -a 'erlang time' -n e1"); but, get the error sh: erl_call: command not found guess because its not shell command.... Is there any other way of doing this. Regards, jb____________________________________________ =====-----=====-----===== Notice: The information contained in this e-mail message and/or attachments to it may contain confidential or privileged information. If you are not the intended recipient, any dissemination, use, review, distribution, printing or copying of the information contained in this e-mail message and/or attachments to it are strictly prohibited. If you have received this communication in error, please notify us by reply e-mail or telephone and immediately and permanently delete the message and any attachments. Thank you -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080218/6f17c129/attachment.html From andreas.hillqvist Mon Feb 18 11:55:50 2008 From: andreas.hillqvist (Andreas Hillqvist) Date: Mon, 18 Feb 2008 11:55:50 +0100 Subject: [erlang-questions] help about process,why very slow. In-Reply-To: <47B841C0.1090200@gmail.com> References: <47B657CE.4050105@gmail.com> <47B70925.5080805@itsbeen.sent.com> <85293094-E978-4728-9D0D-616B9B6FBBB8@gmail.com> <47B841C0.1090200@gmail.com> Message-ID: <8268eea30802180255v27e83dcv251c04bd42072cd3@mail.gmail.com> Would it be appropiate to use the overload(http://www.erlang.org/doc/man/overload.html) module in this case? I guess it is more sutible when you can reply busy, like in http protocal. Where a busy reply could be sent before the http request is parsed, to reduce load. I can not se that it would do any good in this micro benchmark. You are welcomme to show how it can be applied. Regards, Andreas Hillqvist 2008/2/17, ?? : > Sean Hinde ??: > > Hi, > > > > Why do you think the CPU should be anything other than 100% when you > > have just sent 1000000 messages into the system. It is of course busy > > processing the messages. > > > > Sean > > > > On 17 Feb 2008, at 13:03, ?? wrote: > > > >> hi! > >> I checked the server found in erlang shell activated when launched > >> smp, my server is single core, smp cancelled after the running of the > >> entire service soon, but still high cpu occupiers, the test data will > >> be 1000000 continuing seconds cpu 99% usage, may I ask you what > >> optimization approach? Cpu occupiers will be reduced? > >> > >> thanks All! > >> > >> 2008/2/17 myname iserl : > >> Hi, > >> > >> Sorry, for offlist. > >> I don't use erlang yet and I don't really know erlang at all, > >> but I read the list often. > >> > >> For monitoring why your server is using 99% you might try: > >> http://www.erlang.org/documentation/doc-5.2/lib/observer-0.9/doc/html/etop_ug.html > >> > >> http://www.erlang.org/doc/efficiency_guide/profiling.html > >> > >> http://www.erlang.org/doc/man/eprof.html > >> http://www.erlang.org/doc/man/fprof.html > >> http://www.erlang.org/doc/apps/tools/cprof_chapter.html > >> > >> Good luck > >> > >> ?? wrote: > >> > thanks! > >> > I was revised to {active,once} and server cpu still occupy 99%, but my > >> > code in the local tests, use 127.0.0.1 ,100 million > >> > run by 40 seconds, and even in the server 127.0.0.1 > >> > >> > of the cpu will be 99%. > >> > > >> > Is there any way to find out whether there is a server cpu 99%? > >> > > >> > very thanks! > >> > > >> > 2008/2/16 Sean Hinde >> >: > >> > > >> > The problem here is almost certainly your use of {active, true}. The > >> > inbound mailbox will rapidly fill with a very large number of messages > >> > (1 million in your case), and this can cause the emulator to slow down > >> > during garbage collection. > >> > > >> > You need to introduce some flow control. The {active,once} socket > >> > option is normally used for this. > >> > > >> > Sean > >> > > >> > On 16 Feb 2008, at 12:18, ?? wrote: > >> > > >> > > help! > >> > > > >> > > On Feb 16, 2008 11:32 AM, ?? >> > > wrote: > >> > > server code url > >> > > http://icej.80s.net.cn/emssserver.erl > >> > > > >> > > On Sat, Feb 16, 2008 at 11:26 AM, ?? >> > > wrote: > >> > > > >> > > Hello everyone! I recent study erlang familiar with the code to > >> > make a > >> > > message transmitted server, have a problem! > >> > > > >> > > I development of the information transmitted server function: > >> > > Aclient Bclient are connected to Server, and joined a group C, > >> > Aclient > >> > > send message to group C , message will be transmitted to B by > >> > group C. > >> > > SOCKET use the binary (active true), (2) packet. > >> > > > >> > > News Server design: > >> > > Have a process responsible for monitoring all client even when the > >> > > client connect server, another process (group_manager process) > >> > > maintenance division List of members of the client group, each group > >> > > (group process) to have an process within the group responsible for > >> > > the > >> > > client to transmit message. > >> > > > >> > > > >> > > Performance testing problems encountered by: > >> > > A test of million sent to the SERVER message used on the finished > >> > > eight > >> > > seconds, and automatic logoff, and the content of the message are > >> the > >> > > same, so, the test Lan network. > >> > > SERVER through tcpdump monitor and indeed also in the eight seconds > >> > > are > >> > > all the message at the end, and not from the message into the A, > >> > > however > >> > > SERVER transmitted to the messages with for a very long time, > >> over 10 > >> > > minutes, finally, I end of the process. > >> > > > >> > > In server,use top,the cpu is 99% by beam.smp. > >> > > PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND > >> > > 31586 root 17 0 70564 18m 1868 S 99.9 0.9 15:46.12 beam.smp > >> > > > >> > > Is it a problem I designed a very slow ? Or as a result of the > >> > process > >> > > of communication? What measures can be taken tuning? > >> > > > >> > > Thank you help! > >> > > > >> > > the server code > >> > > # -module(emssserver). > >> > > # -export([init/0]). > >> > > # -define(TCP_OPTIONS,[binary,{packet, 2}, {active, true}, > >> > {reuseaddr, > >> > > true}]). > >> > > # -define(PORT,7000). > >> > > # -define(Debug,"YES"). > >> > > # > >> > > # -ifdef(Debug). > >> > > # -define(DEBUG(Fmt, Args), io:format(Fmt, Args)). > >> > > # -else. > >> > > # -define(DEBUG(Fmt, Args), no_debug). > >> > > # -endif. > >> > > # -record(group,{name,gpid}). > >> > > # -record(client, {name,pid,socket}). > >> > > # > >> > > # init()-> > >> > > # {ok, Listen} = gen_tcp:listen(?PORT, ?TCP_OPTIONS), > >> > > # register(accept_connection, spawn(fun() -> > >> > accept_connection(Listen) > >> > > end)), > >> > > # register(group_manage, spawn(fun() -> group_manage([]) end)). > >> > > # > >> > > # accept_connection(Listen) ->%% listen new client connection > >> > > # {ok, Socket} = gen_tcp:accept(Listen), > >> > > # Pid = spawn(fun() -> client_recv(Socket,"","") end), > >> > > # gen_tcp:controlling_process(Socket,Pid), > >> > > # accept_connection(Listen). > >> > > # > >> > > # client_recv(Socket,ClientName,GroupPid)->%%client process recv > >> > > # receive > >> > > # {tcp, Socket, Bin} -> > >> > > # ?DEBUG("Server recv Data\r\n",""), > >> > > # case binary_to_term(Bin) of > >> > > # {join,JoinName,ClientNameTmp}->%%client join > >> > > # ?DEBUG("client_recv Join:~s ~s\r\n",[JoinName,ClientNameTmp]), > >> > > # G=#group{name=JoinName}, > >> > > # group_manage ! {join,G,self()},%%get group pid > >> > > # receive > >> > > # {grouppid,GPid}->%%recv group pid > >> > > # ?DEBUG("Client_recv grouppid ~w ~s\r\n",[GPid,ClientNameTmp]), > >> > > # GPid!{join,Socket,ClientNameTmp,self()} %% send "join" msg to > >> group > >> > > # end, > >> > > # client_recv(Socket,ClientNameTmp,GPid); > >> > > # {send,GroupName,Msg}->%%send msg to group > >> > > # ?DEBUG("client_recv Send:~s ~s\r\n",[GroupName,Msg]), > >> > > # GroupPid!{send,ClientName,Msg}, > >> > > # client_recv(Socket,ClientName,GroupPid) > >> > > # end; > >> > > # {tcp_closed, Socket} -> > >> > > # ?DEBUG("client_recv close\r\n",[]) > >> > > # end. > >> > > # > >> > > # group_manage(Group)->%%manage group member > >> > > # ?DEBUG("group_manage start\r\n",[]), > >> > > # receive > >> > > # {join,JoinGroup,ClientPid}-> > >> > > # ?DEBUG("group_manage Join:~s\r\n",[JoinGroup#group.name]), > >> > > # case lists:keysearch(JoinGroup#group.name, #group.name, Group) of > >> > > # false -> > >> > > # Pid=spawn(fun() -> group([]) end), > >> > > # ?DEBUG("group_manage group pid~w\r\n",[Pid]), > >> > > # ClientPid!{grouppid,Pid},%%return client_recv group pid > >> > > # JoinGroupp = #group{name=JoinGroup#group.name,gpid=Pid}, > >> > > # Gs = [JoinGroupp|Group], > >> > > # ?DEBUG("group_manage group:~w\r\n",[Gs]), > >> > > # group_manage(Gs); > >> > > # {value,SingleGroup} -> > >> > > # ?DEBUG("group_manage group is set > >> > ~s\r\n",[SingleGroup#group.name]), > >> > > # ClientPid!{grouppid,SingleGroup#group.gpid}, > >> > > # group_manage(Group) > >> > > # end > >> > > # > >> > > # end. > >> > > # > >> > > # group(Client)->%%send msg to all > >> > > # ?DEBUG("group \r\n",[]), > >> > > # receive > >> > > # {join,Socket,ClientName,CPid} -> > >> > > # ?DEBUG("group ClientName ~s\r\n",[ClientName]), > >> > > # ?DEBUG("group Client set ~w\r\n",[Client]), > >> > > # case lists:keysearch(ClientName,#client.name,Client) of > >> > > # false-> > >> > > # ?DEBUG("group new client\r\n",[]), > >> > > # ClientNew = #client{name=ClientName,pid=CPid,socket=Socket}, > >> > > # ClientTmp = [ClientNew|Client], > >> > > # group(ClientTmp); > >> > > # {value,SingleClient}-> > >> > > # ?DEBUG("group client is set ~s\r\n",[SingleClient#client.name]), > >> > > # group(Client) > >> > > # end; > >> > > # {send,ClientName,Msg}-> > >> > > # ?DEBUG("group recv client send ~s\r\n",[Msg]), > >> > > # lists:foreach(fun(T)->send(ClientName,T,Msg) end,Client), > >> > > # group(Client) > >> > > # end, > >> > > # ok. > >> > > # > >> > > # send(FClientName,TClientName,Msg)-> > >> > > # if > >> > > # FClientName /= TClientName#client.name -> > >> > > # ?DEBUG("send f:~s t:~s > >> > > ~s\r\n",[FClientName,TClientName#client.name,Msg]), > >> > > # M = {FClientName,Msg}, > >> > > # gen_tcp:send(TClientName#client.socket,term_to_binary(M)); > >> > > # true-> > >> > > # ?DEBUG("send from eq to\r\n",[]) > >> > > # end. > >> > > > >> > > the client code is "gen_tcp:send",iterative > >> > > > >> > > the code install three linux server. > >> > > > >> > > > >> > > > >> > > > >> > > -- > >> > > ??:erlang,python,php,java > >> > > --------------------------------------------- > >> > > ????? > >> > > http://blog.80s.net.cn > >> > > > >> > > > >> > > > >> > > -- > >> > > ??:erlang,python,php,java > >> > > --------------------------------------------- > >> > > ????? > >> > > http://blog.80s.net.cn > >> > > _______________________________________________ > >> > > erlang-questions mailing list > >> > > erlang-questions > >> > > http://www.erlang.org/mailman/listinfo/erlang-questions > >> > > >> > > >> > > >> > > >> > -- > >> > ??:erlang,python,php,java > >> > --------------------------------------------- > >> > ????? > >> > http://blog.80s.net.cn > >> > > >> > > >> > > >> ------------------------------------------------------------------------ > >> > > >> > _______________________________________________ > >> > erlang-questions mailing list > >> > erlang-questions > >> > http://www.erlang.org/mailman/listinfo/erlang-questions > >> > >> > >> > >> -- > >> ??:erlang,python,php,java > >> --------------------------------------------- > >> ????? > >> http://blog.80s.net.cn > >> _______________________________________________ > >> erlang-questions mailing list > >> erlang-questions > >> http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > Because my colleagues tested c development message server spread , I > remember that he did not like the cpu to occupy 99% so high, I like to > use erlang replacement, I need to said erlang better spread to my > boss.trouble. > > > -- > ??:erlang,python,java,php > -------------------------------- > ?????http://blog.80s.net.cn > > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions From anthony.hw.kong Mon Feb 18 12:43:49 2008 From: anthony.hw.kong (Anthony Kong) Date: Mon, 18 Feb 2008 22:43:49 +1100 Subject: [erlang-questions] Using erl_call In-Reply-To: References: Message-ID: Can You specify full path? e.g. assuming *nix based OS, system("/usr/bin/erl_call ..."); 2008/2/18 J Bhanot : > > Hi, > > How can we use erl_call in C node. > > I have tried using system("erl_call -s -a 'erlang time' -n e1"); > > but, get the error sh: erl_call: command not found > > guess because its not shell command.... > > Is there any other way of doing this. > > Regards, > > jb____________________________________________=====-----=====-----===== > Notice: The information contained in this e-mail > message and/or attachments to it may contain > confidential or privileged information. If you are > not the intended recipient, any dissemination, use, > review, distribution, printing or copying of the > information contained in this e-mail message > and/or attachments to it are strictly prohibited. If > you have received this communication in error, > please notify us by reply e-mail or telephone and > immediately and permanently delete the message > and any attachments. Thank you > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > -- /*--*/ Don't EVER make the mistake that you can design something better than what you get from ruthless massively parallel trial-and-error with a feedback cycle. That's giving your intelligence _much_ too much credit. - Linus Torvalds From icejmx Mon Feb 18 12:56:10 2008 From: icejmx (=?GB2312?B?w+nD6Q==?=) Date: Mon, 18 Feb 2008 19:56:10 +0800 Subject: [erlang-questions] help about process,why very slow. In-Reply-To: <8268eea30802180255v27e83dcv251c04bd42072cd3@mail.gmail.com> References: <47B657CE.4050105@gmail.com> <47B70925.5080805@itsbeen.sent.com> <85293094-E978-4728-9D0D-616B9B6FBBB8@gmail.com> <47B841C0.1090200@gmail.com> <8268eea30802180255v27e83dcv251c04bd42072cd3@mail.gmail.com> Message-ID: <47B9725A.5010600@gmail.com> Andreas Hillqvist ??: > Would it be appropiate to use the > overload(http://www.erlang.org/doc/man/overload.html) module in this > case? > > I guess it is more sutible when you can reply busy, like in http protocal. > Where a busy reply could be sent before the http request is parsed, to > reduce load. > > I can not se that it would do any good in this micro benchmark. > You are welcomme to show how it can be applied. > > > Regards, > Andreas Hillqvist > > 2008/2/17, ?? : > >> Sean Hinde ??: >> >>> Hi, >>> >>> Why do you think the CPU should be anything other than 100% when you >>> have just sent 1000000 messages into the system. It is of course busy >>> processing the messages. >>> >>> Sean >>> >>> On 17 Feb 2008, at 13:03, ?? wrote: >>> >>> >>>> hi! >>>> I checked the server found in erlang shell activated when launched >>>> smp, my server is single core, smp cancelled after the running of the >>>> entire service soon, but still high cpu occupiers, the test data will >>>> be 1000000 continuing seconds cpu 99% usage, may I ask you what >>>> optimization approach? Cpu occupiers will be reduced? >>>> >>>> thanks All! >>>> >>>> 2008/2/17 myname iserl : >>>> Hi, >>>> >>>> Sorry, for offlist. >>>> I don't use erlang yet and I don't really know erlang at all, >>>> but I read the list often. >>>> >>>> For monitoring why your server is using 99% you might try: >>>> http://www.erlang.org/documentation/doc-5.2/lib/observer-0.9/doc/html/etop_ug.html >>>> >>>> http://www.erlang.org/doc/efficiency_guide/profiling.html >>>> >>>> http://www.erlang.org/doc/man/eprof.html >>>> http://www.erlang.org/doc/man/fprof.html >>>> http://www.erlang.org/doc/apps/tools/cprof_chapter.html >>>> >>>> Good luck >>>> >>>> ?? wrote: >>>> >>>>> thanks! >>>>> I was revised to {active,once} and server cpu still occupy 99%, but my >>>>> code in the local tests, use 127.0.0.1 ,100 million >>>>> run by 40 seconds, and even in the server 127.0.0.1 >>>>> >>>> >>>> >>>>> of the cpu will be 99%. >>>>> >>>>> Is there any way to find out whether there is a server cpu 99%? >>>>> >>>>> very thanks! >>>>> >>>>> 2008/2/16 Sean Hinde >>>> >>>> >: >>>> >>>>> The problem here is almost certainly your use of {active, true}. The >>>>> inbound mailbox will rapidly fill with a very large number of messages >>>>> (1 million in your case), and this can cause the emulator to slow down >>>>> during garbage collection. >>>>> >>>>> You need to introduce some flow control. The {active,once} socket >>>>> option is normally used for this. >>>>> >>>>> Sean >>>>> >>>>> On 16 Feb 2008, at 12:18, ?? wrote: >>>>> >>>>> >>>>>> help! >>>>>> >>>>>> On Feb 16, 2008 11:32 AM, ?? >>>>> >>>>> > wrote: >>>>> >>>>>> server code url >>>>>> http://icej.80s.net.cn/emssserver.erl >>>>>> >>>>>> On Sat, Feb 16, 2008 at 11:26 AM, ?? >>>>> >>>>> > wrote: >>>>> >>>>>> Hello everyone! I recent study erlang familiar with the code to >>>>>> >>>>> make a >>>>> >>>>>> message transmitted server, have a problem! >>>>>> >>>>>> I development of the information transmitted server function: >>>>>> Aclient Bclient are connected to Server, and joined a group C, >>>>>> >>>>> Aclient >>>>> >>>>>> send message to group C , message will be transmitted to B by >>>>>> >>>>> group C. >>>>> >>>>>> SOCKET use the binary (active true), (2) packet. >>>>>> >>>>>> News Server design: >>>>>> Have a process responsible for monitoring all client even when the >>>>>> client connect server, another process (group_manager process) >>>>>> maintenance division List of members of the client group, each group >>>>>> (group process) to have an process within the group responsible for >>>>>> the >>>>>> client to transmit message. >>>>>> >>>>>> >>>>>> Performance testing problems encountered by: >>>>>> A test of million sent to the SERVER message used on the finished >>>>>> eight >>>>>> seconds, and automatic logoff, and the content of the message are >>>>>> >>>> the >>>> >>>>>> same, so, the test Lan network. >>>>>> SERVER through tcpdump monitor and indeed also in the eight seconds >>>>>> are >>>>>> all the message at the end, and not from the message into the A, >>>>>> however >>>>>> SERVER transmitted to the messages with for a very long time, >>>>>> >>>> over 10 >>>> >>>>>> minutes, finally, I end of the process. >>>>>> >>>>>> In server,use top,the cpu is 99% by beam.smp. >>>>>> PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND >>>>>> 31586 root 17 0 70564 18m 1868 S 99.9 0.9 15:46.12 beam.smp >>>>>> >>>>>> Is it a problem I designed a very slow ? Or as a result of the >>>>>> >>>>> process >>>>> >>>>>> of communication? What measures can be taken tuning? >>>>>> >>>>>> Thank you help! >>>>>> >>>>>> the server code >>>>>> # -module(emssserver). >>>>>> # -export([init/0]). >>>>>> # -define(TCP_OPTIONS,[binary,{packet, 2}, {active, true}, >>>>>> >>>>> {reuseaddr, >>>>> >>>>>> true}]). >>>>>> # -define(PORT,7000). >>>>>> # -define(Debug,"YES"). >>>>>> # >>>>>> # -ifdef(Debug). >>>>>> # -define(DEBUG(Fmt, Args), io:format(Fmt, Args)). >>>>>> # -else. >>>>>> # -define(DEBUG(Fmt, Args), no_debug). >>>>>> # -endif. >>>>>> # -record(group,{name,gpid}). >>>>>> # -record(client, {name,pid,socket}). >>>>>> # >>>>>> # init()-> >>>>>> # {ok, Listen} = gen_tcp:listen(?PORT, ?TCP_OPTIONS), >>>>>> # register(accept_connection, spawn(fun() -> >>>>>> >>>>> accept_connection(Listen) >>>>> >>>>>> end)), >>>>>> # register(group_manage, spawn(fun() -> group_manage([]) end)). >>>>>> # >>>>>> # accept_connection(Listen) ->%% listen new client connection >>>>>> # {ok, Socket} = gen_tcp:accept(Listen), >>>>>> # Pid = spawn(fun() -> client_recv(Socket,"","") end), >>>>>> # gen_tcp:controlling_process(Socket,Pid), >>>>>> # accept_connection(Listen). >>>>>> # >>>>>> # client_recv(Socket,ClientName,GroupPid)->%%client process recv >>>>>> # receive >>>>>> # {tcp, Socket, Bin} -> >>>>>> # ?DEBUG("Server recv Data\r\n",""), >>>>>> # case binary_to_term(Bin) of >>>>>> # {join,JoinName,ClientNameTmp}->%%client join >>>>>> # ?DEBUG("client_recv Join:~s ~s\r\n",[JoinName,ClientNameTmp]), >>>>>> # G=#group{name=JoinName}, >>>>>> # group_manage ! {join,G,self()},%%get group pid >>>>>> # receive >>>>>> # {grouppid,GPid}->%%recv group pid >>>>>> # ?DEBUG("Client_recv grouppid ~w ~s\r\n",[GPid,ClientNameTmp]), >>>>>> # GPid!{join,Socket,ClientNameTmp,self()} %% send "join" msg to >>>>>> >>>> group >>>> >>>>>> # end, >>>>>> # client_recv(Socket,ClientNameTmp,GPid); >>>>>> # {send,GroupName,Msg}->%%send msg to group >>>>>> # ?DEBUG("client_recv Send:~s ~s\r\n",[GroupName,Msg]), >>>>>> # GroupPid!{send,ClientName,Msg}, >>>>>> # client_recv(Socket,ClientName,GroupPid) >>>>>> # end; >>>>>> # {tcp_closed, Socket} -> >>>>>> # ?DEBUG("client_recv close\r\n",[]) >>>>>> # end. >>>>>> # >>>>>> # group_manage(Group)->%%manage group member >>>>>> # ?DEBUG("group_manage start\r\n",[]), >>>>>> # receive >>>>>> # {join,JoinGroup,ClientPid}-> >>>>>> # ?DEBUG("group_manage Join:~s\r\n",[JoinGroup#group.name]), >>>>>> # case lists:keysearch(JoinGroup#group.name, #group.name, Group) of >>>>>> # false -> >>>>>> # Pid=spawn(fun() -> group([]) end), >>>>>> # ?DEBUG("group_manage group pid~w\r\n",[Pid]), >>>>>> # ClientPid!{grouppid,Pid},%%return client_recv group pid >>>>>> # JoinGroupp = #group{name=JoinGroup#group.name,gpid=Pid}, >>>>>> # Gs = [JoinGroupp|Group], >>>>>> # ?DEBUG("group_manage group:~w\r\n",[Gs]), >>>>>> # group_manage(Gs); >>>>>> # {value,SingleGroup} -> >>>>>> # ?DEBUG("group_manage group is set >>>>>> >>>>> ~s\r\n",[SingleGroup#group.name]), >>>>> >>>>>> # ClientPid!{grouppid,SingleGroup#group.gpid}, >>>>>> # group_manage(Group) >>>>>> # end >>>>>> # >>>>>> # end. >>>>>> # >>>>>> # group(Client)->%%send msg to all >>>>>> # ?DEBUG("group \r\n",[]), >>>>>> # receive >>>>>> # {join,Socket,ClientName,CPid} -> >>>>>> # ?DEBUG("group ClientName ~s\r\n",[ClientName]), >>>>>> # ?DEBUG("group Client set ~w\r\n",[Client]), >>>>>> # case lists:keysearch(ClientName,#client.name,Client) of >>>>>> # false-> >>>>>> # ?DEBUG("group new client\r\n",[]), >>>>>> # ClientNew = #client{name=ClientName,pid=CPid,socket=Socket}, >>>>>> # ClientTmp = [ClientNew|Client], >>>>>> # group(ClientTmp); >>>>>> # {value,SingleClient}-> >>>>>> # ?DEBUG("group client is set ~s\r\n",[SingleClient#client.name]), >>>>>> # group(Client) >>>>>> # end; >>>>>> # {send,ClientName,Msg}-> >>>>>> # ?DEBUG("group recv client send ~s\r\n",[Msg]), >>>>>> # lists:foreach(fun(T)->send(ClientName,T,Msg) end,Client), >>>>>> # group(Client) >>>>>> # end, >>>>>> # ok. >>>>>> # >>>>>> # send(FClientName,TClientName,Msg)-> >>>>>> # if >>>>>> # FClientName /= TClientName#client.name -> >>>>>> # ?DEBUG("send f:~s t:~s >>>>>> ~s\r\n",[FClientName,TClientName#client.name,Msg]), >>>>>> # M = {FClientName,Msg}, >>>>>> # gen_tcp:send(TClientName#client.socket,term_to_binary(M)); >>>>>> # true-> >>>>>> # ?DEBUG("send from eq to\r\n",[]) >>>>>> # end. >>>>>> >>>>>> the client code is "gen_tcp:send",iterative >>>>>> >>>>>> the code install three linux server. >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> ??:erlang,python,php,java >>>>>> --------------------------------------------- >>>>>> ????? >>>>>> http://blog.80s.net.cn >>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> ??:erlang,python,php,java >>>>>> --------------------------------------------- >>>>>> ????? >>>>>> http://blog.80s.net.cn >>>>>> _______________________________________________ >>>>>> erlang-questions mailing list >>>>>> erlang-questions >>>>>> http://www.erlang.org/mailman/listinfo/erlang-questions >>>>>> >>>>> >>>>> >>>>> -- >>>>> ??:erlang,python,php,java >>>>> --------------------------------------------- >>>>> ????? >>>>> http://blog.80s.net.cn >>>>> >>>>> >>>>> >>>>> >>>> ------------------------------------------------------------------------ >>>> >>>>> _______________________________________________ >>>>> erlang-questions mailing list >>>>> erlang-questions >>>>> http://www.erlang.org/mailman/listinfo/erlang-questions >>>>> >>>> >>>> -- >>>> ??:erlang,python,php,java >>>> --------------------------------------------- >>>> ????? >>>> http://blog.80s.net.cn >>>> _______________________________________________ >>>> erlang-questions mailing list >>>> erlang-questions >>>> http://www.erlang.org/mailman/listinfo/erlang-questions >>>> >>> >> Because my colleagues tested c development message server spread , I >> remember that he did not like the cpu to occupy 99% so high, I like to >> use erlang replacement, I need to said erlang better spread to my >> boss.trouble. >> >> >> -- >> ??:erlang,python,java,php >> -------------------------------- >> ?????http://blog.80s.net.cn >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions >> http://www.erlang.org/mailman/listinfo/erlang-questions >> thanks! I have try! -- ??:erlang,python,java,php -------------------------------- ?????http://blog.80s.net.cn From bekesa Mon Feb 18 12:44:26 2008 From: bekesa (Andras Georgy Bekes) Date: Mon, 18 Feb 2008 12:44:26 +0100 Subject: [erlang-questions] Associating contextual info with monitors In-Reply-To: <20080218025857.GA10836@vailsys.com> References: <20080218025857.GA10836@vailsys.com> Message-ID: <200802181244.26628.bekesa@sch.bme.hu> > For instances where the processes being spawned aren't gen_* servers, > I would most likely spawn a wrapper process which in turn spawn_links > the real child process, then blocks forever waiting to receive the > EXIT for that process (the cleanup code is triggered upon receipt of > the EXIT, then the wrapper process itself terminates). So you write something like this: ----- Worker=spawn_link(fun()-> doit() end), receive {'EXIT',Worker,Reason}-> cleanup() end ----- Isn't it simpler to write ----- try doit() catch Class:Error -> do_something(Class,Error) after cleanup() end ----- ? This doesn't use the extra process, and anyways, isn't this the purpose of try-catch? You can even omit the catch section, it is not mandatory. Georgy From kenneth.lundin Mon Feb 18 13:27:51 2008 From: kenneth.lundin (Kenneth Lundin) Date: Mon, 18 Feb 2008 13:27:51 +0100 Subject: [erlang-questions] Using erl_call In-Reply-To: References: Message-ID: Of course you need to have the correct path setup in order to find erl_call. But I think it is really questionable why you should execute erl_call at all from a C-node as you call it. A C-node is for me a C-program communicationg with other Erlang-nodes and C-nodes using the Erlang distribution Protocol. The C-node is implemented with help of the ei and erl_interface library functions which are available in the erl_interface application. Erl_call is a C-program that acts as a temporary short lived C-node. Erl_call is written using the erl_interface functions mentioned above and was originally meant to be an example of how to use these functions to implement a C-node. So if you already have a C-node you don't need to execute erl_call. You can look at the erl_call source code and do something similar in your own C-node if you have not already implemented functionality for invoking a function on an Erlang-node from a C-node. /Kenneth , Erlang/OTP team at Ericsson On 2/18/08, Anthony Kong wrote: > Can You specify full path? > > e.g. assuming *nix based OS, > > system("/usr/bin/erl_call ..."); > > > 2008/2/18 J Bhanot : > > > > Hi, > > > > How can we use erl_call in C node. > > > > I have tried using system("erl_call -s -a 'erlang time' -n e1"); > > > > but, get the error sh: erl_call: command not found > > > > guess because its not shell command.... > > > > Is there any other way of doing this. > > > > Regards, > > > > jb____________________________________________=====-----=====-----===== > > Notice: The information contained in this e-mail > > message and/or attachments to it may contain > > confidential or privileged information. If you are > > not the intended recipient, any dissemination, use, > > review, distribution, printing or copying of the > > information contained in this e-mail message > > and/or attachments to it are strictly prohibited. If > > you have received this communication in error, > > please notify us by reply e-mail or telephone and > > immediately and permanently delete the message > > and any attachments. Thank you > > > > > > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > > -- > /*--*/ > Don't EVER make the mistake that you can design something better than > what you get from ruthless massively parallel trial-and-error with a > feedback cycle. That's giving your intelligence _much_ too much > credit. > > - Linus Torvalds > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > From j.bhanot Mon Feb 18 13:32:16 2008 From: j.bhanot (J Bhanot) Date: Mon, 18 Feb 2008 18:02:16 +0530 Subject: [erlang-questions] Using erl_call In-Reply-To: Message-ID: Hi Anthony, I want to start the Erlang node from my c node only.... i.e. I execute only C program and both nodes are up and start communicating........ I don't want to manually start erlang node or execute another script which does so.... Thanks, jb =====-----=====-----===== Notice: The information contained in this e-mail message and/or attachments to it may contain confidential or privileged information. If you are not the intended recipient, any dissemination, use, review, distribution, printing or copying of the information contained in this e-mail message and/or attachments to it are strictly prohibited. If you have received this communication in error, please notify us by reply e-mail or telephone and immediately and permanently delete the message and any attachments. Thank you -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080218/f02af232/attachment.html From anthony.hw.kong Mon Feb 18 14:43:43 2008 From: anthony.hw.kong (Anthony Kong) Date: Tue, 19 Feb 2008 00:43:43 +1100 Subject: [erlang-questions] Using erl_call In-Reply-To: References: Message-ID: Hi, jb, Yeah, I think Kenneth is right. He has to be right because he wrote the some of the erl_interface documentation, I just realised ;-) So, first of all, sorry, I answered your question as if it is a normal C programming question. What you did (calling erl_call) can also be done using perl or similar scripting languages, or even from a shell directly. So, calling erl_call using system() in c is really not what c-node is about. So, in essence, Kenneth's idea is: A c-node should interface with an erlang node using the said C API. You should take a look at the erl_call.c file as an example. (Correct me if I'm wrong, Ken) I took a look at it and I found it fairly straight forward to understand. It uses a set of ei_XXX API to get host name and then interact with an erlang nodes e.g. ei_gethostbyname and ei_connect_xinit Lastly, if I understand correctly what you want in your last mail, I think nothing stopped you from system("erl -s ...."), sleep for a while, check the return code, and then initiate a sequence of ei_XXX API to connect to this newly started erlang node. (So, only one program to start both nodes) . Hope this helps. Cheers, Anthony On Feb 18, 2008 11:32 PM, J Bhanot wrote: > > Hi Anthony, > > I want to start the Erlang node from my c node only.... > > i.e. I execute only C program and both nodes are up and start > communicating........ > > I don't want to manually start erlang node or execute another script which > does so.... > > Thanks, > > > jb From j.bhanot Mon Feb 18 15:32:59 2008 From: j.bhanot (J Bhanot) Date: Mon, 18 Feb 2008 20:02:59 +0530 Subject: [erlang-questions] Using erl_call In-Reply-To: Message-ID: Hi Kenneth and Anthony, On having a deeper look at reply from Kenneth....it's making sense to me now... Many thanks for your help...... Cheers, jb =====-----=====-----===== Notice: The information contained in this e-mail message and/or attachments to it may contain confidential or privileged information. If you are not the intended recipient, any dissemination, use, review, distribution, printing or copying of the information contained in this e-mail message and/or attachments to it are strictly prohibited. If you have received this communication in error, please notify us by reply e-mail or telephone and immediately and permanently delete the message and any attachments. Thank you -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080218/64c88d70/attachment.html From erlang Mon Feb 18 15:49:37 2008 From: erlang (Joe Armstrong) Date: Mon, 18 Feb 2008 15:49:37 +0100 Subject: [erlang-questions] Strings as Lists In-Reply-To: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> Message-ID: <9b08084c0802180649k75218a8jf4316379d6767c67@mail.gmail.com> One problem with strings unicode, regexps etc. is how you input the string. To me, embedding regexps, LaTeX etc. in strings is painful and I make loads of mistakes forgetting to quote things. Would it be a good idea to have something like python string literals, changing the details of course, just to confuse python programmers :-) To turn off quoting write ~n"abc\n", being short for [97,98,99,92,110], as opposed to "abc\n" which is short for [97,98,99,10] This would be especially useful for regexps ~r" ..." and allow things like regexp:match(~r".......", ...) to be compiled far better than is possible today. We could use ~n"...." turn off quoting ~r"...." string is a regexp ~x"..." string is xml ~x/FlunkyStuff ... FunkyStuff (string is xml terminated by FunkyStuff) ~myExpander/FunkyStuff .... FunckyStuff (expand ... -- ie the stuff between FunckyStuff literals, with the function myExpander (must be defined in a parse transform) - this mechanism would generalise the ideas of "..." being syntactic sugar for a list. So ~Op"......" would mean that "...." was syntactic sugar for *anything* Is this a good idea or an invitation to write totally unreadable code? This would make Erlang more powerful (and is backwards compatible) but less readable - is the extra power worth the readability? /Joe Armstrong 2008/2/12 tsuraan : > Why does erlang internally represent strings as lists? In every language > I've used other than Java, a string is a sequence of octets, just like > Erlang's binary type. I know that you can represent a string efficiently by > using <<"string">> rather than just "string", but why doesn't erlang do this > by default? Is it just because pre-12B binary handling wasn't as efficient > as list handling, or is Erlang intended to support UTF-32? > > Thanks for any input! > > > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > From bcully Mon Feb 18 16:35:53 2008 From: bcully (Brian Cully) Date: Mon, 18 Feb 2008 10:35:53 -0500 Subject: [erlang-questions] Strings as Lists In-Reply-To: <9b08084c0802180649k75218a8jf4316379d6767c67@mail.gmail.com> References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> <9b08084c0802180649k75218a8jf4316379d6767c67@mail.gmail.com> Message-ID: <89AB7A75-0087-40EE-9905-C1C6DAB86D86@gmail.com> On 18-Feb-2008, at 09:49, Joe Armstrong wrote: > ~n"...." turn off quoting > ~r"...." string is a regexp > ~x"..." string is xml > ~x/FlunkyStuff ... FunkyStuff (string is xml terminated by > FunkyStuff) > ~myExpander/FunkyStuff .... FunckyStuff I agree with the difficulty of embedding languages into strings, and avoid it myself whenever possible. Mostly because I'm puritanical, but whatever. My issue regards overloading the double-quote character. I'd rather something completely generic to avoid situations like this: ~r"/"/" ~xml"" and so on. perl's qr/w/x operators might be worth looking at. They don't completely fix the issue, but they work around it by allowing the programmer to specify delimiters. Personally, I'd rather just natural syntax. Both regexp and xml naturally terminate or have errors, so switching the parser into an xml/regexp mode seems reasonable to me. -bjc From raimo+erlang-questions Mon Feb 18 17:20:41 2008 From: raimo+erlang-questions (Raimo Niskanen) Date: Mon, 18 Feb 2008 17:20:41 +0100 Subject: [erlang-questions] BitTorrent downloads Message-ID: <20080218162041.GA9954@erix.ericsson.se> During the release of Erlang/OTP R12B-1 we happened to be flooded by spam backscatter that severely affected the available download capacity. During that time Holger Hoffstaette, thanks a lot!, kindly provided a BitTorrent download. Some made good use of it and as you all know the more that uses a BitTorrent the faster it gets. Holger shall not have to do it in the future since we have now set up a BitTorrent tracker at http://www.erlang.org:6969 that lists the available .torrent files and some statistics. New and large release files will appear there. We also have an initial seeder limited to 400 kBit/s to guarantee that the BitTorrent distribution gets started Please try it soon so we know it works before the release of R12B-2 when it will see its first real action. -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From alexvazquezfente Mon Feb 18 17:26:09 2008 From: alexvazquezfente (Alex Vazquez) Date: Mon, 18 Feb 2008 17:26:09 +0100 Subject: [erlang-questions] Compile R11B-5 with libc6 2.7 Message-ID: <21e305470802180826y52e4270cr48a256ded23d3da8@mail.gmail.com> Hi guys, this is my first post to the list so excuse me if it is the wrong place or the wrong way of doing it. I am compiling Erlang/OTP R11B-5 from source on a Debian 64 bits machine. All is ok until the compilation of the file otp_src_R11B-5/erts/emulator/hipe/hipe_x86_signal.c, where i get undefined references to the symbols INIT and __next_sigaction. After looking at the file it is clear that the problem is that the version of libc installed on in my system is 2.7-5 while that file checks version of libc up to version 2.6: #if __GLIBC__ == 2 && (__GLIBC_MINOR__ >= 3 && __GLIBC_MINOR__ <= 6) ... definition of 'INIT' macro and '__next_sigaction' function ... #endif /* glibc 2.3 */ I know the *best* solution would be to use R12B, which explicitely checks for libc 2.7 but i can't do that, so my question is: Is there any compatibility problem on using a patch like below, and use libc 2.7 with R11B-5? I assume it is no problem at all since 2.7 changes on libc should be minimum and not break API but i would be grateful if you could confirm. --- hipe_x86_signal.c 2008-02-18 13:14:07.656139358 +0100 +++ hipe_x86_signal_glibc2-7.c 2008-02-18 16:40:54.252522271 +0100 @@ -34,7 +34,7 @@ #endif #include "hipe_signal.h" -#if __GLIBC__ == 2 && (__GLIBC_MINOR__ >= 3 && __GLIBC_MINOR__ <= 6) +#if __GLIBC__ == 2 && (__GLIBC_MINOR__ >= 3 && __GLIBC_MINOR__ <= 7) /* See comment below for glibc 2.2. */ #ifndef __USE_GNU #define __USE_GNU /* to un-hide RTLD_NEXT */ Thank you, -- Alejandro Vazquez Fente -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080218/f78d4c94/attachment.html From kostis Mon Feb 18 17:41:04 2008 From: kostis (Kostis Sagonas) Date: Mon, 18 Feb 2008 17:41:04 +0100 Subject: [erlang-questions] Compile R11B-5 with libc6 2.7 In-Reply-To: <21e305470802180826y52e4270cr48a256ded23d3da8@mail.gmail.com> References: <21e305470802180826y52e4270cr48a256ded23d3da8@mail.gmail.com> Message-ID: <47B9B520.3030409@cs.ntua.gr> Alex Vazquez wrote: > Hi guys, > ... > Is there any compatibility problem on using a patch like below, and use > libc 2.7 with R11B-5? I assume it is no problem at all since 2.7 changes > on libc should be minimum and not break API but i would be grateful if > you could confirm. Your change is correct and it should work without any problems. Kostis From vlm Mon Feb 18 22:13:55 2008 From: vlm (Lev Walkin) Date: Mon, 18 Feb 2008 13:13:55 -0800 Subject: [erlang-questions] Strings as Lists In-Reply-To: <89AB7A75-0087-40EE-9905-C1C6DAB86D86@gmail.com> References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> <9b08084c0802180649k75218a8jf4316379d6767c67@mail.gmail.com> <89AB7A75-0087-40EE-9905-C1C6DAB86D86@gmail.com> Message-ID: <47B9F513.4010501@lionet.info> Brian Cully wrote: > On 18-Feb-2008, at 09:49, Joe Armstrong wrote: > >> ~n"...." turn off quoting >> ~r"...." string is a regexp >> ~x"..." string is xml >> ~x/FlunkyStuff ... FunkyStuff (string is xml terminated by >> FunkyStuff) >> ~myExpander/FunkyStuff .... FunckyStuff > > I agree with the difficulty of embedding languages into strings, and > avoid it myself whenever possible. Mostly because I'm puritanical, but > whatever. > > My issue regards overloading the double-quote character. I'd rather > something completely generic to avoid situations like this: > > ~r"/"/" > ~xml"" > and so on. > > perl's qr/w/x operators might be worth looking at. They don't > completely fix the issue, but they work around it by allowing the > programmer to specify delimiters. > > Personally, I'd rather just natural syntax. Both regexp and xml > naturally terminate or have errors, so switching the parser into an > xml/regexp mode seems reasonable to me. It then becomes a problem to parse the straight HTML, which could contain JavaScript. The browser is supposed to have similar smarts in how it treats javascript quoting inside a quoted attribute. However, this would ask for the order-2 smarts from the erlang parser. I'd propose something like trac code, which is {{{literal"string", code, etc.}}} where the number and the shape of braces is debatable. To avoid confusion with tuples, perhaps 3 angle braces would do. Example: <<<"some invalid> htmlcode>>> which parses quite straightforwardly. -- vlm From kangas Tue Feb 19 00:03:59 2008 From: kangas (Matt Kangas) Date: Mon, 18 Feb 2008 18:03:59 -0500 Subject: [erlang-questions] Strings as Lists In-Reply-To: <89AB7A75-0087-40EE-9905-C1C6DAB86D86@gmail.com> References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> <9b08084c0802180649k75218a8jf4316379d6767c67@mail.gmail.com> <89AB7A75-0087-40EE-9905-C1C6DAB86D86@gmail.com> Message-ID: <46E00C9E-B4B4-4D5F-AF8C-4F7C49377B8A@bway.net> On Feb 18, 2008, at 10:35 AM, Brian Cully wrote: > On 18-Feb-2008, at 09:49, Joe Armstrong wrote: > >> ~n"...." turn off quoting >> ~r"...." string is a regexp >> ~x"..." string is xml >> ~x/FlunkyStuff ... FunkyStuff (string is xml terminated by >> FunkyStuff) >> ~myExpander/FunkyStuff .... FunckyStuff > > perl's qr/w/x operators might be worth looking at. They don't > completely fix the issue, but they work around it by allowing the > programmer to specify delimiters. Interesting ideas! For comparison's sake, and food for thought, here's how this issue is handled in several other languages: ----------------------- Perl: per Brian's comment above, and more (~8 variations) http://perldoc.perl.org/perlop.html#Quote-and-Quote-like-Operators Python: http://docs.python.org/ref/strings.html * single or double-quoted : normal string literals, all escapes processed * Triple-quoted strings ("""example""", '''example''') may contain unescaped newlines or quotes * These may be prefixed by [uU] and/or [rR] * u"", U"" = unicode string * r"", R"" = raw (regexp) string, not interpreted for escape sequences PHP: http://www.php.net/manual/en/language.types.string.php * single-quoted : limited escapes * double-quoted : all escapes processed, plus variables ($foo) expanded * "heredoc syntax", ala Perl or Bourne shell Ruby: http://www.ruby-doc.org/docs/ProgrammingRuby/html/tut_stdtypes.html#S2 * single-quoted : limited escapes * double-quoted : all escapes processed * %q or %Q : user-defined delimiter (ala Perl qr/w/x operators) * "heredoc syntax" ----------------------- I like Python's approach, because the elements are "stackable": you can combine prefixes to say ur"\u0062\n" which yields three unicode characters ('LATIN SMALL LETTER B', 'REVERSE SOLIDUS', 'LATIN SMALL LETTER N'). I also find Python triple- quotes to be as useful as "heredocs" in perl/php/ruby/bash, but the syntax is simpler. Cheers, --Matt -- Matt Kangas kangas ? www.p16blog.com From fritchie Tue Feb 19 01:02:19 2008 From: fritchie (Scott Lystig Fritchie) Date: Mon, 18 Feb 2008 18:02:19 -0600 Subject: [erlang-questions] compile debug_info smart_expections via autoconf automake? In-Reply-To: Message of "Sat, 16 Feb 2008 13:18:49 PST." <74b669d0-7684-45b6-8d6e-e6b9932d0357@q70g2000hsb.googlegroups.com> Message-ID: <52840.1203379339@snookles.snookles.com> db wrote: db> I want to also compile with smart_exceptions, but not sure how to db> call it from command line or by setting ERLCFLAGS. Perhaps this is what you're looking for? ERL_FLAGS += -W +debug_info +'{parse_transform, smart_exceptions}' \ -pa /path/to/smart_exceptions/ebin Assuming that your Makefile uses $(ERL_FLAGS) in the right place. :-) -Scott From ok Tue Feb 19 04:55:33 2008 From: ok (Richard A. O'Keefe) Date: Tue, 19 Feb 2008 16:55:33 +1300 Subject: [erlang-questions] Strings as Lists In-Reply-To: <9b08084c0802180649k75218a8jf4316379d6767c67@mail.gmail.com> References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> <9b08084c0802180649k75218a8jf4316379d6767c67@mail.gmail.com> Message-ID: On 19 Feb 2008, at 3:49 am, Joe Armstrong wrote: [expressing PERL envy, basically]. > > To me, embedding regexps, LaTeX etc. in strings is painful and I make > loads of mistakes forgetting to quote things. Patient: Doctor, it hurts when I do . Doctor: Then don't do that. We've had essentially this discussion before. I'm reminded of the classic design botch in SGML. XML has in which the only special characters are the "]]>" ending quote, the others being taken literally. Too bad if you want to nest them! SGML also has which lets you use ... to quote the characters ... *and* to put a wrapper around them. It would be perfect for quoting bits of SGML in tutorials except that (here comes the botch): it is closed by *any* end-tag, not just the one it started with. There really is no programming language which handles "textual things inside textual things" terribly well. The quoting and meta-quoting stuff ends up being pretty nasty no matter what you do. The specific proposal Joe made just now - would make life horrible for editors like Emacs - would make things very confusing for people - would STILL be hard to use. So, in the light of the old joke, let's not do that. Principle 1: NO NESTING. I love nested blocks, and have since Algol 60. I love nested expressions, and have since Lisp. But when you want to combine multiple notations, as for example XSLT (hiss, spit) does, nesting is for the birds. I would have called this ONE HEADACHE AT A TIME, but cannot see how to get by with fewer than two. Principle 2: NAME AND CONQUER. If it's big enough to be a problem, it's big enough to have a name. Principle 3: WHAT I SEE ISN'T WHAT HE GETS. In order to be used in Erlang programs, a notation has to be accepted by the Erlang tool chain, but it does not have to be part of the Erlang language or understood by the Erlang compiler. We have already accepted this idea for Yecc and Leex. Keeping it out of the compiler is also suggested by the next principle: Principle 4: LET A HUNDRED SCHOOLS CONTEND. It's most unlikely that we'll come up with the right design, or even the right *kind* of design, on the first pop. Maybe the right way to do it is to write all our code in Microsoft Word (hiss, spit, screech, jump, claw!) using styles to distinguish one reading of the text from another. Maybe we should be using an SGML-based or XML-based markup language (not entirely unlike the one I proposed some years ago, perhaps) with something like Amaya as our editor. Maybe we should be asking the aliens from Zeta Reticuli to do our programming for us. Principle 5: RUN IT UP THE FLAGPOLE AND SEE IF ANYONE FAINTS. Here's a sketch of something that can handle large chunks of text in a mixture of notations. The key ideas are - there are Notations (hmm, haven't I heard that before, oh yes, it was SGML...). A Notation provides a rule for quoting interpolated text, and may also be associated with a syntax checker. - there is interpolation, of two kinds. In the case of Literal interpolation, a string in any notation is interpolated as literal data according to the Notation's rule. In the case of Interpreted interpolation, a text in one notation may be interpolated in text of the same notation only, the result being subject to the syntax check of the notation, if any. - @id@ indicates literal interpolation @@ is a plain @ %id% indicates interpreted interpolation %% is a plain % %\n is removed; it's continuation. These characters were chosen to be minimally obtrusive in LaTeX and regular expressions and Erlang text. - Text chunks have names, which can be used in Erlang code. - Text chunks may have arguments. ::= '(' [] 'is' '\n' * '.' '\n' ::= * ['%'] '\n' ::= '%' '%' | '%' '%' | '@' '@' | '@' '@' | [^%@\n] ::= | '(' [ {',' }] ') The set of notations we'd need has yet to be determined, but it would certainly include latex regexp xml string (" and \ are special) atom (' and \ are special) url (\ is illegal) Example: time()/regexp is ^1?[0-9]:[0-5][0-9] [AP]M$ . explanation()/latex is The regular expression \verb|@time()@| matches any string of the form \textit{h}:\textit{m}\verb*| |\textit{ampm} where \textit{h} is one or two decimal digits, representing an hour 1--12, \textit{m} is two decimal digits, with a leading zero if necessary, representing a minute 00--59, and \textit{ampm} is either AM (\textit{ante meridiem}) or PM (\textit{post meridiem}).\foot{For the pedants amongst you, note that it is meridiEM, not meridiAN} . base()/url is http://erlang.example.org/% . relative()/url is erlang/doc/preproc/hundred.html% . complete()/url is %base()%%relative%% . omnium_gatherum() is {@time()@,()@,()@}% . A preprocessor would turn this into plain Erlang. There isn't actually much, if anything, in this that is specific to Erlang. From kangas Tue Feb 19 07:00:44 2008 From: kangas (Matt Kangas) Date: Tue, 19 Feb 2008 01:00:44 -0500 Subject: [erlang-questions] Strings as Lists In-Reply-To: References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> <9b08084c0802180649k75218a8jf4316379d6767c67@mail.gmail.com> Message-ID: In my humble opinion, as an Erlang outsider (imo)... > Principle 5: > RUN IT UP THE FLAGPOLE AND SEE IF ANYONE FAINTS. Absolutely. :-) > Principle 4: > LET A HUNDRED SCHOOLS CONTEND. Erm... are you the one now expressing PERL envy? :-) One of Perl's mottos, after all, is: "There's more than one way to do it." I think there is value in providing *one obvious solution* to a problem. If it solves > 90% of common use-cases, is syntactically simple, and easy to use in the default configuration, then it's probably worth considering. The value here is not total expressive power, but instead the likelihood of adoption by users, and thus likelihood of solving real, in-the-wild problems. (Yes, this is the standard "Zen of Python" retort to Perl mongers.) I'm fascinated by the flexibility you propose, but confused about the implications. Should we need to support a Tower of Hanoi for notations? How likely are users to ever embed > 1 notation? > 2? --Matt On Feb 18, 2008, at 10:55 PM, Richard A. O'Keefe wrote: > On 19 Feb 2008, at 3:49 am, Joe Armstrong wrote: > [expressing PERL envy, basically]. >> > >> To me, embedding regexps, LaTeX etc. in strings is painful and I make >> loads of mistakes forgetting to quote things. > > Patient: Doctor, it hurts when I do . > Doctor: Then don't do that. > > We've had essentially this discussion before. > I'm reminded of the classic design botch in SGML. > XML has > in which the only special characters are the "]]>" ending quote, > the others being taken literally. Too bad if you want to nest them! > SGML also has > which lets you use ... to quote the characters ... *and* > to put a wrapper around them. It would be perfect for quoting bits > of SGML in tutorials except that (here comes the botch): it is closed > by *any* end-tag, not just the one it started with. > > There really is no programming language which handles "textual things > inside > textual things" terribly well. The quoting and meta-quoting stuff > ends up > being pretty nasty no matter what you do. The specific proposal Joe > made > just now > - would make life horrible for editors like Emacs > - would make things very confusing for people > - would STILL be hard to use. > > So, in the light of the old joke, let's not do that. > > Principle 1: > NO NESTING. > I love nested blocks, and have since Algol 60. > I love nested expressions, and have since Lisp. > But when you want to combine multiple notations, as for example > XSLT (hiss, spit) does, nesting is for the birds. > I would have called this ONE HEADACHE AT A TIME, but cannot see > how to get by with fewer than two. > > Principle 2: > NAME AND CONQUER. > If it's big enough to be a problem, it's big enough to have a name. > > Principle 3: > WHAT I SEE ISN'T WHAT HE GETS. > In order to be used in Erlang programs, a notation has to be accepted > by the Erlang tool chain, but it does not have to be part of the > Erlang > language or understood by the Erlang compiler. We have already > accepted this idea for Yecc and Leex. Keeping it out of the compiler > is also suggested by the next principle: > > Principle 4: > LET A HUNDRED SCHOOLS CONTEND. > It's most unlikely that we'll come up with the right design, or even > the right *kind* of design, on the first pop. Maybe the right way to > do it is to write all our code in Microsoft Word (hiss, spit, > screech, > jump, claw!) using styles to distinguish one reading of the text from > another. Maybe we should be using an SGML-based or XML-based markup > language (not entirely unlike the one I proposed some years ago, > perhaps) with something like Amaya as our editor. Maybe we should be > asking the aliens from Zeta Reticuli to do our programming for us. > > Principle 5: > RUN IT UP THE FLAGPOLE AND SEE IF ANYONE FAINTS. > > Here's a sketch of something that can handle large chunks of text in > a mixture > of notations. The key ideas are > - there are Notations (hmm, haven't I heard that before, oh yes, it > was SGML...). A Notation provides a rule for quoting interpolated > text, and may also be associated with a syntax checker. > - there is interpolation, of two kinds. In the case of Literal > interpolation, a string in any notation is interpolated as literal > data according to the Notation's rule. In the case of Interpreted > interpolation, a text in one notation may be interpolated in text > of the same notation only, the result being subject to the syntax > check of the notation, if any. > - @id@ indicates literal interpolation > @@ is a plain @ > %id% indicates interpreted interpolation > %% is a plain % > %\n is removed; it's continuation. > These characters were chosen to be minimally obtrusive in LaTeX > and regular expressions and Erlang text. > - Text chunks have names, which can be used in Erlang code. > - Text chunks may have arguments. > > ::= > '(' [] 'is' '\n' > * > '.' '\n' > ::= > * ['%'] '\n' > > ::= > '%' '%' > | '%' '%' > | '@' '@' > | '@' '@' > | [^%@\n] > > ::= > > | '(' [ {',' }] ') > > The set of notations we'd need has yet to be determined, > but it would certainly include > latex > regexp > xml > string (" and \ are special) > atom (' and \ are special) > url (\ is illegal) > > Example: > time()/regexp is > ^1?[0-9]:[0-5][0-9] [AP]M$ > . > explanation()/latex is > The regular expression \verb|@time()@| matches > any string of the form > \textit{h}:\textit{m}\verb*| |\textit{ampm} > where \textit{h} is one or two decimal digits, > representing an hour 1--12, \textit{m} is two > decimal digits, with a leading zero if necessary, > representing a minute 00--59, and \textit{ampm} > is either AM (\textit{ante meridiem}) or > PM (\textit{post meridiem}).\foot{For the pedants > amongst you, note that it is meridiEM, not > meridiAN} > . > base()/url is > http://erlang.example.org/% > . > relative()/url is > erlang/doc/preproc/hundred.html% > . > complete()/url is > %base()%%relative%% > . > omnium_gatherum() is > {@time()@,()@,()@}% > . > > A preprocessor would turn this into plain Erlang. > > There isn't actually much, if anything, in this that is specific to > Erlang. -- Matt Kangas kangas ? www.p16blog.com From kangas Tue Feb 19 08:16:57 2008 From: kangas (Matt Kangas) Date: Tue, 19 Feb 2008 02:16:57 -0500 Subject: [erlang-questions] Low Level Virtual Machine (LLVM) for optimization across the intire lifetime of a program In-Reply-To: <200802132234.44206.roger.larsson@e-gatan.se> References: <200802132234.44206.roger.larsson@e-gatan.se> Message-ID: For what it's worth, LLVM ships with Mac OS X 10.5. It's embedded in the OpenGL stack, for compiling vertex shaders -- which may/may not be supported natively on any given video card, hence the need for a JIT: http://lists.cs.uiuc.edu/pipermail/llvmdev/2006-August/006492.html http://arstechnica.com/reviews/os/mac-os-x-10-5.ars/11#llvm --Matt On Feb 13, 2008, at 4:34 PM, Roger Larsson wrote: > Found this interesting report via lwn.net > > http://llvm.org/pubs/2004-01-30-CGO-LLVM.html > >> From the home page http://llvm.org/ > > "A compilation strategy designed to enable effective program > optimization > across the entire lifetime of a program. LLVM supports effective > optimization > at compile time, link-time (particularly interprocedural), run-time > and > offline (i.e., after software is installed), while remaining > transparent to > developers and maintaining compatibility with existing build scripts. > > A virtual instruction set - LLVM is a low-level object code > representation > that uses simple RISC-like instructions, but provides rich, > language-independent, type information and dataflow (SSA) > information about > operands. This combination enables sophisticated transformations on > object > code, while remaining light-weight enough to be attached to the > executable. > This combination is key to allowing link-time, run-time, and offline > transformations. > > A compiler infrastructure - LLVM is also a collection of source code > that > implements the language and compilation strategy. The primary > components of > the LLVM infrastructure are a GCC-based C & C++ front-end, a link-time > optimization framework with a growing set of global and > interprocedural > analyses and transformations, static back-ends for the X86, X86-64, > PowerPC > 32/64, ARM, Thumb, IA-64, Alpha and SPARC architectures, a back-end > which > emits portable C code, and a Just-In-Time compiler for X86, X86-64, > PowerPC > 32/64 processors. > > LLVM does not imply things that you would expect from a high-level > virtual > machine. It does not require garbage collection or run-time code > generation > (In fact, LLVM makes a great static compiler!). Note that optional > LLVM > components can be used to build high-level virtual machines and > other systems > that need these services." > > This sounds like a much better match for code generation than Java > or CLI. > A suitable examination work? > > /RogerL > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions -- Matt Kangas kangas ? www.p16blog.com From masklinn Tue Feb 19 08:26:02 2008 From: masklinn (Masklinn) Date: Tue, 19 Feb 2008 08:26:02 +0100 Subject: [erlang-questions] Strings as Lists In-Reply-To: References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> <9b08084c0802180649k75218a8jf4316379d6767c67@mail.gmail.com> Message-ID: <505523D1-A960-492C-B564-F09A88536CDF@masklinn.net> On 19 Feb 2008, at 04:55 , Richard A. O'Keefe wrote: > - would make life horrible for editors like Emacs I don't see why, really. Emacs seems to do quite well with Python's 16 string forms or so (single-quoted, double-quoted, triple single- quoted, triple double-quoted, and any of these can be prefixed by "r" for rawstrings, "u" for unicode strings, or both) or with Ruby's HEREDOCS (seems to have issues with PHP's, but ruby-mode shows it can handle these things) > > - would make things very confusing for people Anything can make "things" very confusing for people, and frankly when I compare /regexps/ in Ruby or r"rawstrings" in Python (or @"rawstrings" in C#) to writing \\regular \\\\expressions\\ in \\\ \Java, the formers are *far less* confusing and *infinitely more* readable than the latter. Your take on it is interesting/nice though. From tumanian Tue Feb 19 11:54:12 2008 From: tumanian (Gurgen Tumanian) Date: Tue, 19 Feb 2008 14:54:12 +0400 Subject: [erlang-questions] Erlang interview questions Message-ID: <85d11a2e0802190254p4fa92977j3618665e7be6b276@mail.gmail.com> Dear all. I was wondering what questions you typically ask during Erlang intervies to check the knowlege of language? And what are the problems that you present for more senior development positions? Regards Gurgen Tumanyan -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080219/8b4d739c/attachment.html From ignatios Tue Feb 19 12:30:51 2008 From: ignatios (Ignatios Souvatzis) Date: Tue, 19 Feb 2008 12:30:51 +0100 Subject: [erlang-questions] Strings as Lists In-Reply-To: <15474643.post@talk.nabble.com> References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> <0EA68804-E7BB-477A-9351-677188540F48@cs.otago.ac.nz> <15474643.post@talk.nabble.com> Message-ID: <20080219113051.GA25040@cs.uni-bonn.de> Hi, On Wed, Feb 13, 2008 at 10:07:52PM -0800, Zvi wrote: > > I think you confusing datatype with it's implementation/representation. > My biggest problem with Erlang standard string representation is that in > 64bit mode, each character taking 16 bytes. >From the "use the right datatype for the job" corner: I was afraid of the 8 bytes / character problem when I started my pet project. However, I keep the data inside mnesia, and I observed that mnesia seems to store strings in a compressed form, so I never bothered to add explicit to-binary conversion (... myself?) Regards, -is From chsu79 Tue Feb 19 13:14:36 2008 From: chsu79 (Christian S) Date: Tue, 19 Feb 2008 13:14:36 +0100 Subject: [erlang-questions] Erlang interview questions In-Reply-To: <85d11a2e0802190254p4fa92977j3618665e7be6b276@mail.gmail.com> References: <85d11a2e0802190254p4fa92977j3618665e7be6b276@mail.gmail.com> Message-ID: 2008/2/19 Gurgen Tumanian : > I was wondering what questions you typically ask during Erlang intervies to > check the knowlege of language? And what are the problems that you present > for more senior development positions? I consider good OTP design knowledge to be the skill that defines being a senior Erlang developer. I base that on that you need experience with a larger project to realize the value in OTP design principles, what works and what does not pay off. Also, it is a non-obvious step from just knowing the language well. From chsu79 Tue Feb 19 13:27:12 2008 From: chsu79 (Christian S) Date: Tue, 19 Feb 2008 13:27:12 +0100 Subject: [erlang-questions] Strings as Lists In-Reply-To: <20080219113051.GA25040@cs.uni-bonn.de> References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> <0EA68804-E7BB-477A-9351-677188540F48@cs.otago.ac.nz> <15474643.post@talk.nabble.com> <20080219113051.GA25040@cs.uni-bonn.de> Message-ID: > I was afraid of the 8 bytes / character problem when I started my pet > project. However, I keep the data inside mnesia, and I observed that > mnesia seems to store strings in a compressed form, so I never bothered > to add explicit to-binary conversion (... myself?) Yes, when integers are smaller than 255 (a true string() type value) then the list can (will?) be turned into a vector in the external representation [1]. A guess is that it wouldn't be difficult to add a 16-bit vector representation for an imaginary string16() type, but it would be a bit more difficult to measure if it is worth it. Especially when binary comprehensions makes it so easy to do something similar but explicitly. [1] : http://www.erlang.org/doc/apps/erts/erl_ext_dist.html#8.12 From tsuraan Tue Feb 19 15:39:03 2008 From: tsuraan (tsuraan) Date: Tue, 19 Feb 2008 08:39:03 -0600 Subject: [erlang-questions] Strings as Lists In-Reply-To: References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> <9b08084c0802180649k75218a8jf4316379d6767c67@mail.gmail.com> Message-ID: <84fb38e30802190639h478f478ax487e8d1e013fa9b1@mail.gmail.com> > There really is no programming language which handles "textual things > inside > textual things" terribly well. What's wrong with heredocs, like ruby or sh has? $stdout.write < References: <47B657CE.4050105@gmail.com> <47B70925.5080805@itsbeen.sent.com> <85293094-E978-4728-9D0D-616B9B6FBBB8@gmail.com> <47B841C0.1090200@gmail.com> Message-ID: <3bebeff1-2d94-4d18-947f-c02bacaaaac6@e6g2000prf.googlegroups.com> Was the c version faster as well? In other words what was the difference in the time it took each version to process 1000000? On Feb 17, 8:16 am, ?? wrote: > Sean Hinde ??: > > > Hi, > > > Why do you think the CPU should be anything other than 100% when you > > have just sent 1000000 messages into the system. It is of course busy > > processing the messages. > > > Sean > > > On 17 Feb 2008, at 13:03, ?? wrote: > > >> hi! > >> I checked the server found in erlang shell activated when launched > >> smp, my server is single core, smp cancelled after the running of the > >> entire service soon, but still high cpu occupiers, the test data will > >> be 1000000 continuing seconds cpu 99% usage, may I ask you what > >> optimization approach? Cpu occupiers will be reduced? > > >> thanks All! > > >> 2008/2/17 myname iserl : > >> Hi, > > >> Sorry, for offlist. > >> I don't use erlang yet and I don't really know erlang at all, > >> but I read the list often. > > >> For monitoring why your server is using 99% you might try: > >>http://www.erlang.org/documentation/doc-5.2/lib/observer-0.9/doc/html... > > >>http://www.erlang.org/doc/efficiency_guide/profiling.html > > >>http://www.erlang.org/doc/man/eprof.html > >>http://www.erlang.org/doc/man/fprof.html > >>http://www.erlang.org/doc/apps/tools/cprof_chapter.html > > >> Good luck > > >> ?? wrote: > >> > thanks! > >> > I was revised to {active,once} and server cpu still occupy 99%, but my > >> > code in the local tests, use 127.0.0.1 ,100 million > >> > run by 40 seconds, and even in the server 127.0.0.1 > >> > >> > of the cpu will be 99%. > > >> > Is there any way to find out whether there is a server cpu 99%? > > >> > very thanks! > > >> > 2008/2/16 Sean Hinde >> >: > > >> > The problem here is almost certainly your use of {active, true}. The > >> > inbound mailbox will rapidly fill with a very large number of messages > >> > (1 million in your case), and this can cause the emulator to slow down > >> > during garbage collection. > > >> > You need to introduce some flow control. The {active,once} socket > >> > option is normally used for this. > > >> > Sean > > >> > On 16 Feb 2008, at 12:18, ?? wrote: > > >> > > help! > > >> > > On Feb 16, 2008 11:32 AM, ?? >> > > wrote: > >> > > server code url > >> > >http://icej.80s.net.cn/emssserver.erl > > >> > > On Sat, Feb 16, 2008 at 11:26 AM, ?? >> > > wrote: > > >> > > Hello everyone! I recent study erlang familiar with the code to > >> > make a > >> > > message transmitted server, have a problem! > > >> > > I development of the information transmitted server function: > >> > > Aclient Bclient are connected to Server, and joined a group C, > >> > Aclient > >> > > send message to group C , message will be transmitted to B by > >> > group C. > >> > > SOCKET use the binary (active true), (2) packet. > > >> > > News Server design: > >> > > Have a process responsible for monitoring all client even when the > >> > > client connect server, another process (group_manager process) > >> > > maintenance division List of members of the client group, each group > >> > > (group process) to have an process within the group responsible for > >> > > the > >> > > client to transmit message. > > >> > > Performance testing problems encountered by: > >> > > A test of million sent to the SERVER message used on the finished > >> > > eight > >> > > seconds, and automatic logoff, and the content of the message are > >> the > >> > > same, so, the test Lan network. > >> > > SERVER through tcpdump monitor and indeed also in the eight seconds > >> > > are > >> > > all the message at the end, and not from the message into the A, > >> > > however > >> > > SERVER transmitted to the messages with for a very long time, > >> over 10 > >> > > minutes, finally, I end of the process. > > >> > > In server,use top,the cpu is 99% by beam.smp. > >> > > PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND > >> > > 31586 root 17 0 70564 18m 1868 S 99.9 0.9 15:46.12 beam.smp > > >> > > Is it a problem I designed a very slow ? Or as a result of the > >> > process > >> > > of communication? What measures can be taken tuning? > > >> > > Thank you help! > > >> > > the server code > >> > > # -module(emssserver). > >> > > # -export([init/0]). > >> > > # -define(TCP_OPTIONS,[binary,{packet, 2}, {active, true}, > >> > {reuseaddr, > >> > > true}]). > >> > > # -define(PORT,7000). > >> > > # -define(Debug,"YES"). > >> > > # > >> > > # -ifdef(Debug). > >> > > # -define(DEBUG(Fmt, Args), io:format(Fmt, Args)). > >> > > # -else. > >> > > # -define(DEBUG(Fmt, Args), no_debug). > >> > > # -endif. > >> > > # -record(group,{name,gpid}). > >> > > # -record(client, {name,pid,socket}). > >> > > # > >> > > # init()-> > >> > > # {ok, Listen} = gen_tcp:listen(?PORT, ?TCP_OPTIONS), > >> > > # register(accept_connection, spawn(fun() -> > >> > accept_connection(Listen) > >> > > end)), > >> > > # register(group_manage, spawn(fun() -> group_manage([]) end)). > >> > > # > >> > > # accept_connection(Listen) ->%% listen new client connection > >> > > # {ok, Socket} = gen_tcp:accept(Listen), > >> > > # Pid = spawn(fun() -> client_recv(Socket,"","") end), > >> > > # gen_tcp:controlling_process(Socket,Pid), > >> > > # accept_connection(Listen). > >> > > # > >> > > # client_recv(Socket,ClientName,GroupPid)->%%client process recv > >> > > # receive > >> > > # {tcp, Socket, Bin} -> > >> > > # ?DEBUG("Server recv Data\r\n",""), > >> > > # case binary_to_term(Bin) of > >> > > # {join,JoinName,ClientNameTmp}->%%client join > >> > > # ?DEBUG("client_recv Join:~s ~s\r\n",[JoinName,ClientNameTmp]), > >> > > # G=#group{name=JoinName}, > >> > > # group_manage ! {join,G,self()},%%get group pid > >> > > # receive > >> > > # {grouppid,GPid}->%%recv group pid > >> > > # ?DEBUG("Client_recv grouppid ~w ~s\r\n",[GPid,ClientNameTmp]), > >> > > # GPid!{join,Socket,ClientNameTmp,self()} %% send "join" msg to > >> group > >> > > # end, > >> > > # client_recv(Socket,ClientNameTmp,GPid); > >> > > # {send,GroupName,Msg}->%%send msg to group > >> > > # ?DEBUG("client_recv Send:~s ~s\r\n",[GroupName,Msg]), > >> > > # GroupPid!{send,ClientName,Msg}, > >> > > # client_recv(Socket,ClientName,GroupPid) > >> > > # end; > >> > > # {tcp_closed, Socket} -> > >> > > # ?DEBUG("client_recv close\r\n",[]) > >> > > # end. > >> > > # > >> > > # group_manage(Group)->%%manage group member > >> > > # ?DEBUG("group_manage start\r\n",[]), > >> > > # receive > >> > > # {join,JoinGroup,ClientPid}-> > >> > > # ?DEBUG("group_manage Join:~s\r\n",[JoinGroup#group.name]), > >> > > # case lists:keysearch(JoinGroup#group.name, #group.name, Group) of > >> > > # false -> > >> > > # Pid=spawn(fun() -> group([]) end), > >> > > # ?DEBUG("group_manage group pid~w\r\n",[Pid]), > >> > > # ClientPid!{grouppid,Pid},%%return client_recv group pid > >> > > # JoinGroupp = #group{name=JoinGroup#group.name,gpid=Pid}, > >> > > # Gs = [JoinGroupp|Group], > >> > > # ?DEBUG("group_manage group:~w\r\n",[Gs]), > >> > > # group_manage(Gs); > >> > > # {value,SingleGroup} -> > >> > > # ?DEBUG("group_manage group is set > >> > ~s\r\n",[SingleGroup#group.name]), > >> > > # ClientPid!{grouppid,SingleGroup#group.gpid}, > >> > > # group_manage(Group) > >> > > # end > >> > > # > >> > > # end. > >> > > # > >> > > # group(Client)->%%send msg to all > >> > > # ?DEBUG("group \r\n",[]), > >> > > # receive > >> > > # {join,Socket,ClientName,CPid} -> > >> > > # ?DEBUG("group ClientName ~s\r\n",[ClientName]), > >> > > # ?DEBUG("group Client set ~w\r\n",[Client]), > >> > > # case lists:keysearch(ClientName,#client.name,Client) of > >> > > # false-> > >> > > # ?DEBUG("group new client\r\n",[]), > >> > > # ClientNew = #client{name=ClientName,pid=CPid,socket=Socket}, > >> > > # ClientTmp = [ClientNew|Client], > >> > > # group(ClientTmp); > >> > > # {value,SingleClient}-> > >> > > # ?DEBUG("group client is set ~s\r\n",[SingleClient#client.name]), > >> > > # group(Client) > >> > > # end; > >> > > # {send,ClientName,Msg}-> > >> > > # ?DEBUG("group recv client send ~s\r\n",[Msg]), > >> > > # lists:foreach(fun(T)->send(ClientName,T,Msg) end,Client), > >> > > # group(Client) > >> > > # end, > >> > > # ok. > >> > > # > >> > > # send(FClientName,TClientName,Msg)-> > >> > > # if > >> > > # FClientName /= TClientName#client.name -> > >> > > # ?DEBUG("send f:~s t:~s > >> > > ~s\r\n",[FClientName,TClientName#client.name,Msg]), > >> > > # M = {FClientName,Msg}, > >> > > # gen_tcp:send(TClientName#client.socket,term_to_binary(M)); > >> > > # true-> > >> > > # ?DEBUG("send from eq to\r\n",[]) > >> > > # end. > > >> > > the client code is "gen_tcp:send",iterative > > >> > > the code install three linux server. > > >> > > -- > >> > > ??:erlang,python,php,java > >> > > --------------------------------------------- > >> > > ????? > >> > >http://blog.80s.net.cn > > >> > > -- > >> > > ??:erlang,python,php,java > >> > > --------------------------------------------- > >> > > ????? > >> > >http://blog.80s.net.cn > >> > > _______________________________________________ > >> > > erlang-questions mailing list > >> > > erlang-questi... > >> > >http://www.erlang.org/mailman/listinfo/erlang-questions > > >> > -- > >> > ??:erlang,python,php,java > >> > --------------------------------------------- > >> > ????? > >> >http://blog.80s.net.cn > > >> ------------------------------------------------------------------------ > > >> > _______________________________________________ > >> > erlang-questions mailing list > >> > erlang-questi... > >> >http://www.erlang.org/mailman/listinfo/erlang-questions > > >> -- > >> ??:erlang,python,php,java > >> --------------------------------------------- > >> ????? > >>http://blog.80s.net.cn > >> _______________________________________________ > >> erlang-questions mailing list > >> erlang-questi... > >>http://www.erlang.org/mailman/listinfo/erlang-questions > > Because my colleagues tested c development message server spread , I > remember that he did not like the cpu to occupy 99% so high, I like to > use erlang replacement, I need to said erlang better... > > read more >> From dot Tue Feb 19 16:16:07 2008 From: dot (Tony Finch) Date: Tue, 19 Feb 2008 15:16:07 +0000 Subject: [erlang-questions] Strings as Lists In-Reply-To: <84fb38e30802190639h478f478ax487e8d1e013fa9b1@mail.gmail.com> References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> <9b08084c0802180649k75218a8jf4316379d6767c67@mail.gmail.com> <84fb38e30802190639h478f478ax487e8d1e013fa9b1@mail.gmail.com> Message-ID: On Tue, 19 Feb 2008, tsuraan wrote: > > What's wrong with heredocs, like ruby or sh has? > What are the problems with this style of string? They are OK so long as the language supports indented here docs which remove leading whitespace, so that they don't screw up the layout of the code. Tony. -- f.a.n.finch http://dotat.at/ SOUTHEAST ICELAND: SOUTHERLY, VEERING WESTERLY FOR A TIME, 6 TO GALE 8. ROUGH OR VERY ROUGH. RAIN OR SHOWERS. MODERATE OR GOOD, OCCASIONALLY POOR. From guido Fri Feb 15 22:16:44 2008 From: guido (Guido Witmond) Date: Fri, 15 Feb 2008 22:16:44 +0100 Subject: [erlang-questions] Include file problem Message-ID: <0399CEA3-3244-48CF-A2ED-EAACE19E1125@witmond.nl> Hello all, I'm writing a small app that needs to parse an xml string. However to use the xmerl_xpath library I need to include the file xmerl.hrl. And the only way I get that is by writing down the entrire path starting at the root: -include_lib("/opt/local/lib/erlang/lib/xmerl-1.1.6/include/xmerl.hrl"). I would expect to write just the basename: -include_lib("xmerl.hrl"). So what could be the problem? I'm running on OS/X 10.4.11 with macports erlang R12 in /opt/local/ lib/erlang. regards, Guido. From ahmed.nawras Tue Feb 19 19:18:30 2008 From: ahmed.nawras (Ahmed Ali) Date: Tue, 19 Feb 2008 22:18:30 +0400 Subject: [erlang-questions] Include file problem In-Reply-To: <0399CEA3-3244-48CF-A2ED-EAACE19E1125@witmond.nl> References: <0399CEA3-3244-48CF-A2ED-EAACE19E1125@witmond.nl> Message-ID: Hi Guide, Try the following: -include_lib("xmerl-1.1.6/include/xmerl.hrl"). This will start the include from the default lib directory. I guess it should work. Best regards, Ahmed On Feb 16, 2008 1:16 AM, Guido Witmond wrote: > Hello all, > > I'm writing a small app that needs to parse an xml string. > > However to use the xmerl_xpath library I need to include the file > xmerl.hrl. And the only way I get that > is by writing down the entrire path starting at the root: > > -include_lib("/opt/local/lib/erlang/lib/xmerl-1.1.6/include/xmerl.hrl"). > > I would expect to write just the basename: > > -include_lib("xmerl.hrl"). > > So what could be the problem? > > I'm running on OS/X 10.4.11 with macports erlang R12 in /opt/local/ > lib/erlang. > > regards, Guido. > > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > From dave.rafkind Tue Feb 19 19:54:39 2008 From: dave.rafkind (Dave Rafkind) Date: Tue, 19 Feb 2008 13:54:39 -0500 Subject: [erlang-questions] Associating contextual info with monitors In-Reply-To: <9e009ad0802180059i1376997dvc0c26373df4c4979@mail.gmail.com> References: <9e009ad0802180059i1376997dvc0c26373df4c4979@mail.gmail.com> Message-ID: <47BB25EF.3070007@gmail.com> Joern wrote: > The state associated with the monitored processes was always in the > domain of the monitoring behaviour (e.g. connections per ip address) > however. Which meant that in many cases you actually wanted to have > access to this information for other reasons than cleaning up. So > either there needs to be a possibility to read the extra data from a > monitor or you keep just another state term in your process. On a somewhat related topic, I find myself wanting the following idiom: - A gen_server that manages - several processes (gen_servers, gen_fsm, or whatevs) where - all are supervised by a supervisor The gen_server manages all the state and brings up and shuts down the other processes. So far it seems like I should start the supervisor with just the manager under it, and then store the supervisor's Pid in the manager, and then let the manger dynamically add and remove children from the supervisor when appropriate. However, this seems a bit awkward, the supervisor and the manager should be combined in some way; is this possible? (can a module have 2 behaviours?) Or is there a better way to do it? From vances Tue Feb 19 20:55:51 2008 From: vances (Vance Shipley) Date: Tue, 19 Feb 2008 14:55:51 -0500 Subject: [erlang-questions] Associating contextual info with monitors In-Reply-To: <47BB25EF.3070007@gmail.com> References: <9e009ad0802180059i1376997dvc0c26373df4c4979@mail.gmail.com> <47BB25EF.3070007@gmail.com> Message-ID: <20080219195550.GX59248@h216-235-12-173.host.egate.net> On Tue, Feb 19, 2008 at 01:54:39PM -0500, Dave Rafkind wrote: } The gen_server manages all the state and brings up and shuts down the } other processes. So far it seems like I should start the supervisor with } just the manager under it, and then store the supervisor's Pid in the } manager, and then let the manger dynamically add and remove children } from the supervisor when appropriate. I use exactly that system quite often. } However, this seems a bit awkward, the supervisor and the manager should } be combined in some way; is this possible? (can a module have 2 } behaviours?) Or is there a better way to do it? It is quite possible to use more than one behaviour model attribute in a module however you can't combine supervisor and gen_server as they both need an init/1 callback and in general conflict. You can always write your own supervisor if you are dissatisfied with what OTP provides. You'd best know what you are doing though. I suspect that one day I will create my own supervisor to handle supervision trees which span multiple nodes. Such a supervisor needs application specific handling as you have to consider what to do when you get a {nodedown, Node} message. Is that child dead or just "in a tunnel" to use a cellular analogy? -Vance From erlangy Tue Feb 19 22:11:07 2008 From: erlangy (Michael McDaniel) Date: Tue, 19 Feb 2008 13:11:07 -0800 Subject: [erlang-questions] Include file problem In-Reply-To: References: <0399CEA3-3244-48CF-A2ED-EAACE19E1125@witmond.nl> Message-ID: <20080219211107.GJ6593@delora.autosys.us> -include_lib("xmerl/include/xmerl.hrl"). On Tue, Feb 19, 2008 at 10:18:30PM +0400, Ahmed Ali wrote: > Hi Guide, > > Try the following: > > -include_lib("xmerl-1.1.6/include/xmerl.hrl"). > > This will start the include from the default lib directory. I guess it > should work. > > Best regards, > > Ahmed > > On Feb 16, 2008 1:16 AM, Guido Witmond wrote: > > Hello all, > > > > I'm writing a small app that needs to parse an xml string. > > > > However to use the xmerl_xpath library I need to include the file > > xmerl.hrl. And the only way I get that > > is by writing down the entrire path starting at the root: > > > > -include_lib("/opt/local/lib/erlang/lib/xmerl-1.1.6/include/xmerl.hrl"). > > > > I would expect to write just the basename: > > > > -include_lib("xmerl.hrl"). > > > > So what could be the problem? > > > > I'm running on OS/X 10.4.11 with macports erlang R12 in /opt/local/ > > lib/erlang. > > > > regards, Guido. > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions -- Michael McDaniel Portland, Oregon, USA http://autosys.us +1 503 283 5284 From masse Fri Feb 15 15:33:05 2008 From: masse (Mats Cronqvist) Date: Fri, 15 Feb 2008 15:33:05 +0100 Subject: [erlang-questions] Documentation build process: creating DocBook XML? In-Reply-To: <18357.34938.691663.177763@antilipe.corelatus.se> References: <8EDCB178-4069-4F2B-A5BF-385C1D5D0565@bway.net> <47B14F39.9080509@gmail.com> <18357.34938.691663.177763@antilipe.corelatus.se> Message-ID: <47B5A2A1.8040107@cronqvi.st> Matthias Lang wrote: > I have a shell script which does this: > > ~ >eman io fwr > showing file:///usr/local/src/otp_doc_R11B-4/lib/stdlib-1.14.4/doc/html/io.html#fwrite/1 > > (it pops up the page in the currently running browser). As far as I > know, I'm the only user. The web version doesn't get much traffic > either. i used a (modified) version of it. worked fine, but i liked gotapi.com/erlang better. alas, since R12 that's stopped working properly... mats From guido Tue Feb 19 23:39:46 2008 From: guido (Guido Witmond) Date: Tue, 19 Feb 2008 23:39:46 +0100 Subject: [erlang-questions] Include file problem In-Reply-To: <20080219211107.GJ6593@delora.autosys.us> References: <0399CEA3-3244-48CF-A2ED-EAACE19E1125@witmond.nl> <20080219211107.GJ6593@delora.autosys.us> Message-ID: I tried -include_lib("xmerl-1.1.6/include/xmerl.hrl"). but that failed as well. It was -include_lib("xmerl/include/xmerl.hrl"). that did the trick. Thanks for all the quick replies. Guido. On 19 Feb 2008, at 22:11 , Michael McDaniel wrote: > > -include_lib("xmerl/include/xmerl.hrl"). > > > > On Tue, Feb 19, 2008 at 10:18:30PM +0400, Ahmed Ali wrote: >> Hi Guide, >> >> Try the following: >> >> -include_lib("xmerl-1.1.6/include/xmerl.hrl"). >> >> This will start the include from the default lib directory. I >> guess it >> should work. >> >> Best regards, >> >> Ahmed >> >> On Feb 16, 2008 1:16 AM, Guido Witmond wrote: >>> Hello all, >>> >>> I'm writing a small app that needs to parse an xml string. >>> >>> However to use the xmerl_xpath library I need to include the file >>> xmerl.hrl. And the only way I get that >>> is by writing down the entrire path starting at the root: >>> >>> -include_lib("/opt/local/lib/erlang/lib/xmerl-1.1.6/include/ >>> xmerl.hrl"). >>> >>> I would expect to write just the basename: >>> >>> -include_lib("xmerl.hrl"). >>> >>> So what could be the problem? >>> >>> I'm running on OS/X 10.4.11 with macports erlang R12 in /opt/local/ >>> lib/erlang. >>> >>> regards, Guido. >>> From icejmx Wed Feb 20 03:02:42 2008 From: icejmx (=?GB2312?B?w+nD6Q==?=) Date: Wed, 20 Feb 2008 10:02:42 +0800 Subject: [erlang-questions] help about process,why very slow. In-Reply-To: <3bebeff1-2d94-4d18-947f-c02bacaaaac6@e6g2000prf.googlegroups.com> References: <47B657CE.4050105@gmail.com> <47B70925.5080805@itsbeen.sent.com> <85293094-E978-4728-9D0D-616B9B6FBBB8@gmail.com> <47B841C0.1090200@gmail.com> <3bebeff1-2d94-4d18-947f-c02bacaaaac6@e6g2000prf.googlegroups.com> Message-ID: <47BB8A42.9050301@gmail.com> parnell ??: > Was the c version faster as well? In other words what was the > difference in the time it took each version to process 1000000? > > On Feb 17, 8:16 am, ?? wrote: > >> Sean Hinde ??: >> >> >>> Hi, >>> >>> Why do you think the CPU should be anything other than 100% when you >>> have just sent 1000000 messages into the system. It is of course busy >>> processing the messages. >>> >>> Sean >>> >>> On 17 Feb 2008, at 13:03, ?? wrote: >>> >>>> hi! >>>> I checked the server found in erlang shell activated when launched >>>> smp, my server is single core, smp cancelled after the running of the >>>> entire service soon, but still high cpu occupiers, the test data will >>>> be 1000000 continuing seconds cpu 99% usage, may I ask you what >>>> optimization approach? Cpu occupiers will be reduced? >>>> >>>> thanks All! >>>> >>>> 2008/2/17 myname iserl : >>>> Hi, >>>> >>>> Sorry, for offlist. >>>> I don't use erlang yet and I don't really know erlang at all, >>>> but I read the list often. >>>> >>>> For monitoring why your server is using 99% you might try: >>>> http://www.erlang.org/documentation/doc-5.2/lib/observer-0.9/doc/html... >>>> >>>> http://www.erlang.org/doc/efficiency_guide/profiling.html >>>> >>>> http://www.erlang.org/doc/man/eprof.html >>>> http://www.erlang.org/doc/man/fprof.html >>>> http://www.erlang.org/doc/apps/tools/cprof_chapter.html >>>> >>>> Good luck >>>> >>>> ?? wrote: >>>> >>>>> thanks! >>>>> I was revised to {active,once} and server cpu still occupy 99%, but my >>>>> code in the local tests, use 127.0.0.1 ,100 million >>>>> run by 40 seconds, and even in the server 127.0.0.1 >>>>> >>>> >>>> >>>>> of the cpu will be 99%. >>>>> >>>>> Is there any way to find out whether there is a server cpu 99%? >>>>> >>>>> very thanks! >>>>> >>>>> 2008/2/16 Sean Hinde >>>> >>>> >: >>>> >>>>> The problem here is almost certainly your use of {active, true}. The >>>>> inbound mailbox will rapidly fill with a very large number of messages >>>>> (1 million in your case), and this can cause the emulator to slow down >>>>> during garbage collection. >>>>> >>>>> You need to introduce some flow control. The {active,once} socket >>>>> option is normally used for this. >>>>> >>>>> Sean >>>>> >>>>> On 16 Feb 2008, at 12:18, ?? wrote: >>>>> >>>>>> help! >>>>>> >>>>>> On Feb 16, 2008 11:32 AM, ?? >>>>> >>>>> > wrote: >>>>> >>>>>> server code url >>>>>> http://icej.80s.net.cn/emssserver.erl >>>>>> >>>>>> On Sat, Feb 16, 2008 at 11:26 AM, ?? >>>>> >>>>> > wrote: >>>>> >>>>>> Hello everyone! I recent study erlang familiar with the code to >>>>>> >>>>> make a >>>>> >>>>>> message transmitted server, have a problem! >>>>>> >>>>>> I development of the information transmitted server function: >>>>>> Aclient Bclient are connected to Server, and joined a group C, >>>>>> >>>>> Aclient >>>>> >>>>>> send message to group C , message will be transmitted to B by >>>>>> >>>>> group C. >>>>> >>>>>> SOCKET use the binary (active true), (2) packet. >>>>>> >>>>>> News Server design: >>>>>> Have a process responsible for monitoring all client even when the >>>>>> client connect server, another process (group_manager process) >>>>>> maintenance division List of members of the client group, each group >>>>>> (group process) to have an process within the group responsible for >>>>>> the >>>>>> client to transmit message. >>>>>> >>>>>> Performance testing problems encountered by: >>>>>> A test of million sent to the SERVER message used on the finished >>>>>> eight >>>>>> seconds, and automatic logoff, and the content of the message are >>>>>> >>>> the >>>> >>>>>> same, so, the test Lan network. >>>>>> SERVER through tcpdump monitor and indeed also in the eight seconds >>>>>> are >>>>>> all the message at the end, and not from the message into the A, >>>>>> however >>>>>> SERVER transmitted to the messages with for a very long time, >>>>>> >>>> over 10 >>>> >>>>>> minutes, finally, I end of the process. >>>>>> >>>>>> In server,use top,the cpu is 99% by beam.smp. >>>>>> PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND >>>>>> 31586 root 17 0 70564 18m 1868 S 99.9 0.9 15:46.12 beam.smp >>>>>> >>>>>> Is it a problem I designed a very slow ? Or as a result of the >>>>>> >>>>> process >>>>> >>>>>> of communication? What measures can be taken tuning? >>>>>> >>>>>> Thank you help! >>>>>> >>>>>> the server code >>>>>> # -module(emssserver). >>>>>> # -export([init/0]). >>>>>> # -define(TCP_OPTIONS,[binary,{packet, 2}, {active, true}, >>>>>> >>>>> {reuseaddr, >>>>> >>>>>> true}]). >>>>>> # -define(PORT,7000). >>>>>> # -define(Debug,"YES"). >>>>>> # >>>>>> # -ifdef(Debug). >>>>>> # -define(DEBUG(Fmt, Args), io:format(Fmt, Args)). >>>>>> # -else. >>>>>> # -define(DEBUG(Fmt, Args), no_debug). >>>>>> # -endif. >>>>>> # -record(group,{name,gpid}). >>>>>> # -record(client, {name,pid,socket}). >>>>>> # >>>>>> # init()-> >>>>>> # {ok, Listen} = gen_tcp:listen(?PORT, ?TCP_OPTIONS), >>>>>> # register(accept_connection, spawn(fun() -> >>>>>> >>>>> accept_connection(Listen) >>>>> >>>>>> end)), >>>>>> # register(group_manage, spawn(fun() -> group_manage([]) end)). >>>>>> # >>>>>> # accept_connection(Listen) ->%% listen new client connection >>>>>> # {ok, Socket} = gen_tcp:accept(Listen), >>>>>> # Pid = spawn(fun() -> client_recv(Socket,"","") end), >>>>>> # gen_tcp:controlling_process(Socket,Pid), >>>>>> # accept_connection(Listen). >>>>>> # >>>>>> # client_recv(Socket,ClientName,GroupPid)->%%client process recv >>>>>> # receive >>>>>> # {tcp, Socket, Bin} -> >>>>>> # ?DEBUG("Server recv Data\r\n",""), >>>>>> # case binary_to_term(Bin) of >>>>>> # {join,JoinName,ClientNameTmp}->%%client join >>>>>> # ?DEBUG("client_recv Join:~s ~s\r\n",[JoinName,ClientNameTmp]), >>>>>> # G=#group{name=JoinName}, >>>>>> # group_manage ! {join,G,self()},%%get group pid >>>>>> # receive >>>>>> # {grouppid,GPid}->%%recv group pid >>>>>> # ?DEBUG("Client_recv grouppid ~w ~s\r\n",[GPid,ClientNameTmp]), >>>>>> # GPid!{join,Socket,ClientNameTmp,self()} %% send "join" msg to >>>>>> >>>> group >>>> >>>>>> # end, >>>>>> # client_recv(Socket,ClientNameTmp,GPid); >>>>>> # {send,GroupName,Msg}->%%send msg to group >>>>>> # ?DEBUG("client_recv Send:~s ~s\r\n",[GroupName,Msg]), >>>>>> # GroupPid!{send,ClientName,Msg}, >>>>>> # client_recv(Socket,ClientName,GroupPid) >>>>>> # end; >>>>>> # {tcp_closed, Socket} -> >>>>>> # ?DEBUG("client_recv close\r\n",[]) >>>>>> # end. >>>>>> # >>>>>> # group_manage(Group)->%%manage group member >>>>>> # ?DEBUG("group_manage start\r\n",[]), >>>>>> # receive >>>>>> # {join,JoinGroup,ClientPid}-> >>>>>> # ?DEBUG("group_manage Join:~s\r\n",[JoinGroup#group.name]), >>>>>> # case lists:keysearch(JoinGroup#group.name, #group.name, Group) of >>>>>> # false -> >>>>>> # Pid=spawn(fun() -> group([]) end), >>>>>> # ?DEBUG("group_manage group pid~w\r\n",[Pid]), >>>>>> # ClientPid!{grouppid,Pid},%%return client_recv group pid >>>>>> # JoinGroupp = #group{name=JoinGroup#group.name,gpid=Pid}, >>>>>> # Gs = [JoinGroupp|Group], >>>>>> # ?DEBUG("group_manage group:~w\r\n",[Gs]), >>>>>> # group_manage(Gs); >>>>>> # {value,SingleGroup} -> >>>>>> # ?DEBUG("group_manage group is set >>>>>> >>>>> ~s\r\n",[SingleGroup#group.name]), >>>>> >>>>>> # ClientPid!{grouppid,SingleGroup#group.gpid}, >>>>>> # group_manage(Group) >>>>>> # end >>>>>> # >>>>>> # end. >>>>>> # >>>>>> # group(Client)->%%send msg to all >>>>>> # ?DEBUG("group \r\n",[]), >>>>>> # receive >>>>>> # {join,Socket,ClientName,CPid} -> >>>>>> # ?DEBUG("group ClientName ~s\r\n",[ClientName]), >>>>>> # ?DEBUG("group Client set ~w\r\n",[Client]), >>>>>> # case lists:keysearch(ClientName,#client.name,Client) of >>>>>> # false-> >>>>>> # ?DEBUG("group new client\r\n",[]), >>>>>> # ClientNew = #client{name=ClientName,pid=CPid,socket=Socket}, >>>>>> # ClientTmp = [ClientNew|Client], >>>>>> # group(ClientTmp); >>>>>> # {value,SingleClient}-> >>>>>> # ?DEBUG("group client is set ~s\r\n",[SingleClient#client.name]), >>>>>> # group(Client) >>>>>> # end; >>>>>> # {send,ClientName,Msg}-> >>>>>> # ?DEBUG("group recv client send ~s\r\n",[Msg]), >>>>>> # lists:foreach(fun(T)->send(ClientName,T,Msg) end,Client), >>>>>> # group(Client) >>>>>> # end, >>>>>> # ok. >>>>>> # >>>>>> # send(FClientName,TClientName,Msg)-> >>>>>> # if >>>>>> # FClientName /= TClientName#client.name -> >>>>>> # ?DEBUG("send f:~s t:~s >>>>>> ~s\r\n",[FClientName,TClientName#client.name,Msg]), >>>>>> # M = {FClientName,Msg}, >>>>>> # gen_tcp:send(TClientName#client.socket,term_to_binary(M)); >>>>>> # true-> >>>>>> # ?DEBUG("send from eq to\r\n",[]) >>>>>> # end. >>>>>> >>>>>> the client code is "gen_tcp:send",iterative >>>>>> >>>>>> the code install three linux server. >>>>>> >>>>>> -- >>>>>> ??:erlang,python,php,java >>>>>> --------------------------------------------- >>>>>> ????? >>>>>> http://blog.80s.net.cn >>>>>> >>>>>> -- >>>>>> ??:erlang,python,php,java >>>>>> --------------------------------------------- >>>>>> ????? >>>>>> http://blog.80s.net.cn >>>>>> _______________________________________________ >>>>>> erlang-questions mailing list >>>>>> erlang-questi... >>>>>> http://www.erlang.org/mailman/listinfo/erlang-questions >>>>>> >>>>> -- >>>>> ??:erlang,python,php,java >>>>> --------------------------------------------- >>>>> ????? >>>>> http://blog.80s.net.cn >>>>> >>>> ------------------------------------------------------------------------ >>>> >>>>> _______________________________________________ >>>>> erlang-questions mailing list >>>>> erlang-questi... >>>>> http://www.erlang.org/mailman/listinfo/erlang-questions >>>>> >>>> -- >>>> ??:erlang,python,php,java >>>> --------------------------------------------- >>>> ????? >>>> http://blog.80s.net.cn >>>> _______________________________________________ >>>> erlang-questions mailing list >>>> erlang-questi... >>>> http://www.erlang.org/mailman/listinfo/erlang-questions >>>> >> Because my colleagues tested c development message server spread , I >> remember that he did not like the cpu to occupy 99% so high, I like to >> use erlang replacement, I need to said erlang better... >> >> read more >> >> > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions I tested the performance of erlang better, in the same group on the machines and spread contrast,later. But the server, I wrote a simple function with the spread, testing some error.Test data are as follows: erlang? num send time recv time send/s recv/s 1 8.667778 23.121259 115,369.82 43,250.23 2 8.260629 20.104712 121,056.15 49,739.58 3 8.108403 21.915384 123,328.84 45,630.04 4 8.140427 21.756103 122,843.67 45,964.11 5 8.191785 20.626905 122,073.51 48,480.37 6 7.418387 21.703533 134,800.19 46,075.44 7 8.167769 21.822701 122,432.45 45,823.84 8 8.449056 21.717407 118,356.41 46,046.01 9 8.210315 21.939503 121,798.00 45,579.88 10 8.416223 21.857715 118,818.14 45,750.43 average 8.2030772 21.6565222 122,087.718 46,233.993 spread: num send time recv time send/s recv/s 1 33.96289 42.26861 29,443.90 23,658.22 2 35.60048 39.92257 28,089.51 25,048.49 3 36.90358 40.85970 27,097.64 24,473.99 4 36.44208 45.73787 27,440.80 21,863.72 5 37.18958 43.11423 26,889.26 23,194.20 6 37.68567 43.12220 26,535.29 23,189.91 7 36.12817 46.69936 27,679.24 21,413.57 8 36.38800 43.80660 27,481.58 22,827.61 9 36.19551 48.22904 27,627.74 20,734.40 10 35.96400 46.55988 27,805.58 21,477.72 average 36.24600 44.03201 27,589.25 22,710.75 -- ??:erlang,python,java,php -------------------------------- ?????http://blog.80s.net.cn From dave Wed Feb 20 04:43:46 2008 From: dave (Dave Peticolas) Date: Tue, 19 Feb 2008 19:43:46 -0800 Subject: [erlang-questions] Associating contextual info with monitors In-Reply-To: <20080218025857.GA10836@vailsys.com> References: <20080218025857.GA10836@vailsys.com> Message-ID: <47BBA1F2.7070703@krondo.com> Rick Pettit wrote: > On Sun, Feb 17, 2008 at 07:52:56PM -0700, Dave Smith wrote: >> Greetings, >> >> On several occasions, I've found myself wanting to be able to do some >> cleanup (e.g. remove an entry in ets) when a process dies. Usually I >> solve this by maintaining an ets table keyed by pid, that stores the >> necessary contextual info needed for cleanup, and then setup a monitor >> on the pid of interest. This works ok, but it's a little annoying to >> need to maintain yet another ets table for this context info that is >> only used when the process dies. It seems like what I _really_ want is >> a way to associate a term with a monitor -- that way when I get the >> DOWN message, I would also get the associated term and have everything >> I need to do the cleanup. >> >> Is there a "Right Way" to accomplish this? Maintaining ets tables for >> this sort of contextual info seems a bit overkill -- is there a >> simpler approach? Has anyone else ever encountered this sort of issue? >> I tried searching through the archives for this problem, but couldn't >> find the right set of search terms. :) > > The way I typically solve this problem is by putting the cleanup code in > a gen_server:terminate/2 callback (this way when the gen_server dies it > cleans up after itself). Now I thought that terminate/2 is only called when a gen_server requests a stop from a callback function (by returning {stop, ...}), but not when it dies from, say, an exception. Is that not right? > For instances where the processes being spawned aren't gen_* servers, I would > most likely spawn a wrapper process which in turn spawn_links the real child > process, then blocks forever waiting to receive the EXIT for that process (the > cleanup code is triggered upon receipt of the EXIT, then the wrapper process > itself terminates). From ulf Wed Feb 20 08:13:54 2008 From: ulf (Ulf Wiger) Date: Wed, 20 Feb 2008 08:13:54 +0100 Subject: [erlang-questions] Associating contextual info with monitors In-Reply-To: <47BBA1F2.7070703@krondo.com> References: <20080218025857.GA10836@vailsys.com> <47BBA1F2.7070703@krondo.com> Message-ID: <8209f740802192313p3b81558dn6136b490c3a2eeb4@mail.gmail.com> No, terminate() is always called, if possible. If the server isn't trapping exits, the server may die without being able to do any cleanup. BR, Ulf W 2008/2/20, Dave Peticolas : > Rick Pettit wrote: > > On Sun, Feb 17, 2008 at 07:52:56PM -0700, Dave Smith wrote: > >> Greetings, > >> > >> On several occasions, I've found myself wanting to be able to do some > >> cleanup (e.g. remove an entry in ets) when a process dies. Usually I > >> solve this by maintaining an ets table keyed by pid, that stores the > >> necessary contextual info needed for cleanup, and then setup a monitor > >> on the pid of interest. This works ok, but it's a little annoying to > >> need to maintain yet another ets table for this context info that is > >> only used when the process dies. It seems like what I _really_ want is > >> a way to associate a term with a monitor -- that way when I get the > >> DOWN message, I would also get the associated term and have everything > >> I need to do the cleanup. > >> > >> Is there a "Right Way" to accomplish this? Maintaining ets tables for > >> this sort of contextual info seems a bit overkill -- is there a > >> simpler approach? Has anyone else ever encountered this sort of issue? > >> I tried searching through the archives for this problem, but couldn't > >> find the right set of search terms. :) > > > > The way I typically solve this problem is by putting the cleanup code in > > a gen_server:terminate/2 callback (this way when the gen_server dies it > > cleans up after itself). > > Now I thought that terminate/2 is only called when a gen_server requests > a stop from a callback function (by returning {stop, ...}), but not when > it dies from, say, an exception. Is that not right? > > > > For instances where the processes being spawned aren't gen_* servers, I > would > > most likely spawn a wrapper process which in turn spawn_links the real > child > > process, then blocks forever waiting to receive the EXIT for that process > (the > > cleanup code is triggered upon receipt of the EXIT, then the wrapper > process > > itself terminates). > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > From zerthurd Wed Feb 20 11:29:31 2008 From: zerthurd (Maxim Treskin) Date: Wed, 20 Feb 2008 16:29:31 +0600 Subject: [erlang-questions] Megaco: Disconnection of remote mg when syntax error Message-ID: Hello How I can disconnect remote media gateway when I receive message with syntax error from it? In this case megaco stack calls function UserMod:handle_syntax_error/4 with parameters: ReceiveHandle, Version, ErrorDesc, Extra and I cannot retrieve ConnHandler of remote MG. Digging in megaco_messenger.erl did not helps me. Thank you. -- Maxim Treskin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080220/723b32c4/attachment.html From zerthurd Wed Feb 20 11:50:34 2008 From: zerthurd (Maxim Treskin) Date: Wed, 20 Feb 2008 16:50:34 +0600 Subject: [erlang-questions] Megaco: Disconnection of remote mg when syntax error In-Reply-To: References: Message-ID: Possible solution: add ConnHandle to arguments of UserMod:handle_syntax_error/4 in megaco_messenger:prepare_message/5 Is it bad idea? -- Maxim Treskin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080220/68682955/attachment.html From Raymond.Xiong Wed Feb 20 11:30:23 2008 From: Raymond.Xiong (Raymond Xiong) Date: Wed, 20 Feb 2008 18:30:23 +0800 Subject: [erlang-questions] failed to enable SMP support in otp_src_R12B-1 Message-ID: <20080220103022.GA742@Sun.Com> Hello, I have a Sun Ultra 40(a dual-core amd64 machine) which runs Solaris Nevada. I used to run otp_src_R12B-0 on it and had no problem in enabling SMP support in Erlang emulator(actually I did nothing for that, it was enabled automatically). However, recently I upgrated the machine to Solaris Nevada latest build, which had some changes in sctp header files and caused otp_src_R12B-0 failed to compile. So I downloaded otp_src_R12B-1, configured and compiled it. But this time I couldn't enable SMP support, even if I configured it explicitly with SMP support: $ CPPFLAGS=-I/usr/include/gd2 ./configure --prefix=/myroot \ --enable-smp-support --enable-threads (I specified CPPFLAGS because libgd header files were placed under /usr/include/gd2 on Solaris) Has anyone encountered the same issue? I checked makefiles but didn't figure out how they worked together to generate ERTS_SMP. Thanks for any help. - rayx From jakob Wed Feb 20 14:08:03 2008 From: jakob (Jakob Cederlund) Date: Wed, 20 Feb 2008 14:08:03 +0100 Subject: [erlang-questions] asn1 and the new ssl module In-Reply-To: <1ffe809c0802151131s2fd81c16vdb7aebd67fabd51@mail.gmail.com> References: <1ffe809c0802120934r5c580eeas2cb811a7e5c0b170@mail.gmail.com> <47B5ACC9.7010300@erix.ericsson.se> <1ffe809c0802151131s2fd81c16vdb7aebd67fabd51@mail.gmail.com> Message-ID: <47BC2633.20605@erix.ericsson.se> thisIt was very useful, thanks! And here is a patch. It simply adds asn1 package support for the new ssl. It should work with R12B-1, and probably fine with R12B. Hope this helps! /Jakob Pablo Polvorin wrote: > Thanks for the clarification! > > ...it isn't a patch, .. probably it isn't usefull to you. . > anyway, this is the code i'm using > http://ppolv.wordpress.com/2008/02/15/erlang-ssl-and-asn1/ > > cheers > pablo > > 2008/2/15, Jakob Cederlund : > >> Nope, not yet. >> Currently, the new ssl (the one you get with {ssl_imp, new}) only >> supports these packet-options: raw, 1, 2, 4, cdr and line. (Packaging is >> handled by the function ssl_connection:check_packet/3.) The rest are >> fairly easy to add, and we hope to do that in the next release. Patches >> are welcome! :-) >> >> /Jakob >> >> >> Pablo Polvorin wrote: >> > Hi all, >> > I'm using the new ssl module to "upgrade" a gen_tcp socket to ssl. But >> > I couldn't find a way to easily receiving asn1 packets from it. >> > My question is, it's possible to use the {packet,asn1} option when >> > using the new ssl module?. >> > >> > ssl_connection.erl seems to not have any reference to that option. >> > >> > Finally I implemented the buffering and packet delimiting code in my >> > application, but I wonder if there is an easy and early way to >> > accomplish the same. >> > regards, >> > >> >> >> > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080220/4b4c1fa7/attachment.html -------------- next part -------------- A non-text attachment was scrubbed... Name: ssl_asn1.patch Type: text/x-patch Size: 1129 bytes Desc: not available Url : http://www.erlang.org/pipermail/erlang-questions/attachments/20080220/4b4c1fa7/attachment.bin From erlang Wed Feb 20 14:38:40 2008 From: erlang (Joe Armstrong) Date: Wed, 20 Feb 2008 14:38:40 +0100 Subject: [erlang-questions] long term stability of zlib/crypto Message-ID: <9b08084c0802200538s5dabb969y320c21cbc515c4fb@mail.gmail.com> Hello, I'm thinking on making an S3 thingy to complement my home backup system. I was thinking of a) compressing the data (to reduce my S3 bills) b) encrypting the data (privacy) - Now the problem - I need stable zip/unzip crypt/decrypt pairs. I don't want to backup the data only to find that it is unreadable by my great-great-great-great-.....-great grandaughter in a million years time (or even by me in five years time) "pure erlang" would be OK (but inefficient) - but I'm probably in the market for a small and simple pure-c library with encryption and compression. Any recommendations for such a C library (actually pure Erlang might not be so bad, The compress/encrypt cycle is very rare) - has anybody thought about how to ensure that crypto/comprerssion libraries are long-term stable. The recent mails in this group saying that the zlib compression failed the round trip http://www.trapexit.org/forum/viewtopic.php?p=38378&sid=bc56571842ce1810e7923f09f0040d77 sent some alarm bells ringing ... /Joe From opendev Wed Feb 20 15:05:08 2008 From: opendev (Joern) Date: Wed, 20 Feb 2008 15:05:08 +0100 Subject: [erlang-questions] long term stability of zlib/crypto In-Reply-To: <9b08084c0802200538s5dabb969y320c21cbc515c4fb@mail.gmail.com> References: <9b08084c0802200538s5dabb969y320c21cbc515c4fb@mail.gmail.com> Message-ID: <9e009ad0802200605o8c9b29ew3645c9e3209c42a6@mail.gmail.com> Hi Joe, On 20/02/2008, Joe Armstrong wrote: > Any recommendations for such a C library (actually pure Erlang might > not be so bad, > The compress/encrypt cycle is very rare) - has anybody thought about > how to ensure that crypto/comprerssion libraries are long-term stable. Have a look at http://www.7-zip.org/ - there is a pure LZMA SDK in C/CPP. There are also the sevenzip application sources which include AES encryption. The latter (or both, I didn't check in detail) features LZMA + ZIP, GZIP and BZIP2 for roundtrip compression. Best regards, Joern -- From vlm Wed Feb 20 15:16:22 2008 From: vlm (Lev Walkin) Date: Wed, 20 Feb 2008 06:16:22 -0800 Subject: [erlang-questions] long term stability of zlib/crypto In-Reply-To: <9b08084c0802200538s5dabb969y320c21cbc515c4fb@mail.gmail.com> References: <9b08084c0802200538s5dabb969y320c21cbc515c4fb@mail.gmail.com> Message-ID: <47BC3636.7050609@lionet.info> Joe Armstrong wrote: > Hello, > > I'm thinking on making an S3 thingy to complement my home backup system. > > I was thinking of a) compressing the data (to reduce my S3 bills) > b) encrypting the data (privacy) - > > Now the problem - I need stable zip/unzip crypt/decrypt > pairs. I don't want to backup the data only to find that > it is unreadable by my great-great-great-great-.....-great grandaughter > in a million years time (or even by me in five years time) > > "pure erlang" would be OK (but inefficient) - but I'm probably in the market > for a small and simple pure-c library with encryption and compression. > > Any recommendations for such a C library (actually pure Erlang might > not be so bad, > The compress/encrypt cycle is very rare) - has anybody thought about > how to ensure that crypto/comprerssion libraries are long-term stable. > > The recent mails in this group saying that the zlib compression > failed the round trip > > http://www.trapexit.org/forum/viewtopic.php?p=38378&sid=bc56571842ce1810e7923f09f0040d77 > > sent some alarm bells ringing ... Joe, it seems that the roundtrip problem with zlib is a pure erlang problem; the world around us uses zlib quite extensively, without any hitches (except for IE6's https/gzip implementation). The bigger problem is encryption. You'd probably like a strong encryption to withstand a million year of crypto attacks to your collection of nudity. This means, today, that you'd better stick with AES-256 as a block cipher, with some asymmetric key schema on top of it. Perhaps, RSA-4096 would be sufficient. Furthermore, if you need the file container to have more or less standard file format so the future generations could read it you would need something like PKCS#12 wrapper around the key/cert pair, and so on and so forth. In short, it is not going to be a small and simple C library. The only way to do it small and simple would be to invent an ad hoc format for this specific problem, and this most certainly is not going to end up a secure one. I'd advocate for the better OpenSSL binding. Much of necessary functionality is available through the OpenSSL API. -- Lev Walkin vlm From bmk Wed Feb 20 15:13:01 2008 From: bmk (Micael Karlberg) Date: Wed, 20 Feb 2008 15:13:01 +0100 Subject: [erlang-questions] Megaco: Disconnection of remote mg when syntax error In-Reply-To: References: Message-ID: <47BC356D.5000900@erix.ericsson.se> Hi, Try to use the Extra argument. The transport module calls the megaco:process_received_message/5 function to deliver a new message. The Extra argument is an opaque data structure that is passed through to the user callback module, in this case the handle_syntax_error/4 function. You can put info here to allow the megaco user to identify which connection the message is related to. Regards, /BMK Maxim Treskin wrote: > Hello > > How I can disconnect remote media gateway when I receive message with > syntax error from it? > In this case megaco stack calls function UserMod:handle_syntax_error/4 > with parameters: > ReceiveHandle, Version, ErrorDesc, Extra > and I cannot retrieve ConnHandler of remote MG. Digging in > megaco_messenger.erl did not helps me. > > Thank you. > > -- > Maxim Treskin > > From dgud Wed Feb 20 15:39:10 2008 From: dgud (Dan Gudmundsson) Date: Wed, 20 Feb 2008 15:39:10 +0100 Subject: [erlang-questions] long term stability of zlib/crypto In-Reply-To: <47BC3636.7050609@lionet.info> References: <9b08084c0802200538s5dabb969y320c21cbc515c4fb@mail.gmail.com> <47BC3636.7050609@lionet.info> Message-ID: <47BC3B8E.6040708@erix.ericsson.se> Isn't the zlib problem fixed? When I read the thread I got the impression that we had fixed the problem when we changed the zlib version ( ok so we didn't only switch version the release was a little short). We have made a couple of fixes in that zlib area since R11B-2, send me a counter example if it still doesn't work in R12B-1 and I will try to fix it. /Dan Lev Walkin wrote: > Joe Armstrong wrote: >> Hello, >> >> I'm thinking on making an S3 thingy to complement my home backup system. >> >> I was thinking of a) compressing the data (to reduce my S3 bills) >> b) encrypting the data (privacy) - >> >> Now the problem - I need stable zip/unzip crypt/decrypt >> pairs. I don't want to backup the data only to find that >> it is unreadable by my great-great-great-great-.....-great grandaughter >> in a million years time (or even by me in five years time) >> >> "pure erlang" would be OK (but inefficient) - but I'm probably in the market >> for a small and simple pure-c library with encryption and compression. >> >> Any recommendations for such a C library (actually pure Erlang might >> not be so bad, >> The compress/encrypt cycle is very rare) - has anybody thought about >> how to ensure that crypto/comprerssion libraries are long-term stable. >> >> The recent mails in this group saying that the zlib compression >> failed the round trip >> >> http://www.trapexit.org/forum/viewtopic.php?p=38378&sid=bc56571842ce1810e7923f09f0040d77 >> >> sent some alarm bells ringing ... > > Joe, it seems that the roundtrip problem with zlib is a pure erlang > problem; the world around us uses zlib quite extensively, without any > hitches (except for IE6's https/gzip implementation). The bigger problem > is encryption. You'd probably like a strong encryption to withstand > a million year of crypto attacks to your collection of nudity. This > means, today, that you'd better stick with AES-256 as a block cipher, > with some asymmetric key schema on top of it. Perhaps, RSA-4096 would > be sufficient. Furthermore, if you need the file container to have > more or less standard file format so the future generations could read > it you would need something like PKCS#12 wrapper around the > key/cert pair, and so on and so forth. > > In short, it is not going to be a small and simple C library. The only > way to do it small and simple would be to invent an ad hoc format > for this specific problem, and this most certainly is not going > to end up a secure one. > > I'd advocate for the better OpenSSL binding. Much of necessary > functionality is available through the OpenSSL API. > From gleber.p Wed Feb 20 16:03:03 2008 From: gleber.p (Gleber) Date: Wed, 20 Feb 2008 16:03:03 +0100 Subject: [erlang-questions] net_kernel:nodes_info() error Message-ID: <14f0e3620802200703m5f1b2beue7dfde00c5f729b7@mail.gmail.com> Hello, While figuring out how to make Distel work with long domain names, I've encountered the following error: gleber:~$ erl Erlang (BEAM) emulator version 5.6.1 [source] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.6.1 (abort with ^G) 1> net_kernel:nodes_info(). ** exception error: bad argument in function ets:first/1 called as ets:first(sys_dist) in call from net_kernel:get_nodes/1 in call from net_kernel:get_nodes_info/0 2> ets:i(). id name type size mem owner ---------------------------------------------------------------------------- 11 code set 259 10768 code_server 12 code_names set 52 5065 code_server 13 shell_records ordered_set 0 72 <0.24.0> ac_tab ac_tab set 6 855 application_controller file_io_servers file_io_servers set 0 279 file_server_2 global_locks global_locks set 0 279 global_name_server global_names global_names set 0 279 global_name_server global_names_ext global_names_ext set 0 279 global_name_server global_pid_ids global_pid_ids bag 0 279 global_name_server global_pid_names global_pid_names bag 0 279 global_name_server inet_cache inet_cache bag 0 279 inet_db inet_db inet_db set 21 546 inet_db inet_hosts inet_hosts set 0 279 inet_db ok 3> My system is Ubuntu Gutsy 7.10 with Erlang 12B built from debian experimental deb-src files. Do anyone know what this means? Is it a bug? -- Gleb Peregud http://gleber.pl/ "Only two things are infinite, the universe and human stupidity, and I'm not sure about the former." -- Albert Einstein -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080220/3deb60a8/attachment-0001.html From chsu79 Wed Feb 20 16:11:04 2008 From: chsu79 (Christian S) Date: Wed, 20 Feb 2008 16:11:04 +0100 Subject: [erlang-questions] long term stability of zlib/crypto In-Reply-To: <47BC3B8E.6040708@erix.ericsson.se> References: <9b08084c0802200538s5dabb969y320c21cbc515c4fb@mail.gmail.com> <47BC3636.7050609@lionet.info> <47BC3B8E.6040708@erix.ericsson.se> Message-ID: Isnt the solution to secure backup functionality to have reoccuring tests of reading the backups? Same way one have fire drills. I dont know how many stories I have heard about backup media that aren't readable once they were needed. And that the last readable backup was 2 years old or something scary like that. From erlangy Wed Feb 20 18:22:43 2008 From: erlangy (Michael McDaniel) Date: Wed, 20 Feb 2008 09:22:43 -0800 Subject: [erlang-questions] net_kernel:nodes_info() error In-Reply-To: <14f0e3620802200703m5f1b2beue7dfde00c5f729b7@mail.gmail.com> References: <14f0e3620802200703m5f1b2beue7dfde00c5f729b7@mail.gmail.com> Message-ID: <20080220172243.GO6593@delora.autosys.us> On Wed, Feb 20, 2008 at 04:03:03PM +0100, Gleber wrote: > Hello, > > While figuring out how to make Distel work with long domain names, I've > encountered the following error: > > gleber:~$ erl ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ I have same Ubuntu 7.10 w/Erlang R12B ; need to start erl with a name $ erl -sname fu Erlang (BEAM) emulator version 5.6 [async-threads:0] [hipe] [kernel-poll:false] => reading /home/mmcdanie/.erlang => ** Found 0 name clashes in code paths Eshell V5.6 (abort with ^G) (fu)1> net_kernel:nodes_info(). {ok,[]} (fu)2> I get same error if starting erl without name; I think because starting with no name means there is no node name. See net_kernel docs ... " An Erlang node is started using the command line flag -name or -sname: $ erl -sname foobar " > Erlang (BEAM) emulator version 5.6.1 [source] [async-threads:0] [hipe] > [kernel-poll:false] > > Eshell V5.6.1 (abort with ^G) > 1> net_kernel:nodes_info(). > ** exception error: bad argument > in function ets:first/1 > called as ets:first(sys_dist) > in call from net_kernel:get_nodes/1 > in call from net_kernel:get_nodes_info/0 > 2> ets:i(). > id name type size mem owner > ---------------------------------------------------------------------------- > 11 code set 259 10768 code_server > 12 code_names set 52 5065 code_server > 13 shell_records ordered_set 0 72 <0.24.0> > ac_tab ac_tab set 6 855 application_controller > file_io_servers file_io_servers set 0 279 file_server_2 > global_locks global_locks set 0 279 global_name_server > global_names global_names set 0 279 global_name_server > global_names_ext global_names_ext set 0 279 global_name_server > global_pid_ids global_pid_ids bag 0 279 global_name_server > global_pid_names global_pid_names bag 0 279 global_name_server > inet_cache inet_cache bag 0 279 inet_db > inet_db inet_db set 21 546 inet_db > inet_hosts inet_hosts set 0 279 inet_db > ok > 3> > > My system is Ubuntu Gutsy 7.10 with Erlang 12B built from debian experimental > deb-src files. > > Do anyone know what this means? Is it a bug? > > > > -- > Gleb Peregud > http://gleber.pl/ > > "Only two things are infinite, the universe and human stupidity, and I'm not > sure about the former." > -- Albert Einstein > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions -- Michael McDaniel Portland, Oregon, USA http://autosys.us +1 503 283 5284 From nick Wed Feb 20 16:23:03 2008 From: nick (Niclas Eklund) Date: Wed, 20 Feb 2008 16:23:03 +0100 (MET) Subject: [erlang-questions] net_kernel:nodes_info() error In-Reply-To: <14f0e3620802200703m5f1b2beue7dfde00c5f729b7@mail.gmail.com> Message-ID: Hello! Try: shell> erl -sname hello erl> net_kernel:nodes_info(). {ok,[]} /Nick On Wed, 20 Feb 2008, Gleber wrote: > Hello, > > While figuring out how to make Distel work with long domain names, I've > encountered the following error: > > gleber:~$ erl > Erlang (BEAM) emulator version 5.6.1 [source] [async-threads:0] [hipe] > [kernel-poll:false] > > Eshell V5.6.1 (abort with ^G) > 1> net_kernel:nodes_info(). > ** exception error: bad argument > in function ets:first/1 > called as ets:first(sys_dist) > in call from net_kernel:get_nodes/1 > in call from net_kernel:get_nodes_info/0 > 2> ets:i(). > id name type size mem owner > ---------------------------------------------------------------------------- > 11 code set 259 10768 code_server > 12 code_names set 52 5065 code_server > 13 shell_records ordered_set 0 72 <0.24.0> > ac_tab ac_tab set > 6 855 application_controller > file_io_servers file_io_servers set 0 279 file_server_2 > global_locks global_locks set 0 279 global_name_server > global_names global_names set 0 279 global_name_server > global_names_ext global_names_ext set 0 279 global_name_server > global_pid_ids global_pid_ids bag 0 279 global_name_server > global_pid_names global_pid_names bag 0 279 global_name_server > inet_cache inet_cache bag 0 279 inet_db > inet_db inet_db set 21 546 inet_db > inet_hosts inet_hosts set 0 279 inet_db > ok > 3> > > My system is Ubuntu Gutsy 7.10 with Erlang 12B built from > debian experimental deb-src files. > > Do anyone know what this means? Is it a bug? > > > > -- > Gleb Peregud > http://gleber.pl/ > > "Only two things are infinite, the universe and human stupidity, and I'm not > sure about the former." > -- Albert Einstein > From pat.eyler Wed Feb 20 18:50:09 2008 From: pat.eyler (pat eyler) Date: Wed, 20 Feb 2008 10:50:09 -0700 Subject: [erlang-questions] Practical Erlang Message-ID: <6fd0654b0802200950g1d4e5b94y163bd6e7d68cc7fa@mail.gmail.com> It's nice to get worf from the horses mouth. I've been blogging about another new Erlang book (from O'Reilly this time), and one of the authors (Francesco Cesarini) dropped by to add his confirmation to O'Reilly's. ... It is a fact. "Practical Erlang Programming" will be published by O'Reilly. ... Yay! I'll blog more as I have more info http://on-erlang.blogspot.com/2008/02/not-just-rumour.html -- thanks, -pate ------------------------- Duty makes us do things, Love make us do things well. http://on-ruby.blogspot.com http://on-erlang.blogspot.com http://on-soccer.blogspot.com From rapsey Wed Feb 20 19:10:40 2008 From: rapsey (Rapsey) Date: Wed, 20 Feb 2008 19:10:40 +0100 Subject: [erlang-questions] rotating logs dont work Message-ID: <97619b170802201010q797abfe1jf0ac1826274594f@mail.gmail.com> hello, I'm sure this is another stupid question with an obvious answer, but I can't seem to get rotating logs to work. This is my log.config file: [{sasl, [ % tty for debugging, false for production {sasl_error_logger, tty}, % options: all, error, progress {errlog_type, all}, {errlog_logger_mf_dir, "/Users/rapsey/workspace/erlang/logs"}, {errlog_logger_mf_maxbytes, 8388608}, {errlog_logger_mf_maxfiles, 20} ]}]. The erl command: erl -boot start_sasl -config log Nothing gets put in the logs directory. If I change log.config to only use 1 log file: [{sasl, [ {sasl_error_logger, {file, "/Users/rapsey/workspace/erlang/logs/log"}} ]}]. Messages will be logged just fine. Anyone know what I'm forgetting? thank you, Sergej -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080220/981bd5df/attachment.html From matthew Wed Feb 20 20:21:56 2008 From: matthew (Matthew Dempsky) Date: Wed, 20 Feb 2008 11:21:56 -0800 Subject: [erlang-questions] rotating logs dont work In-Reply-To: <97619b170802201010q797abfe1jf0ac1826274594f@mail.gmail.com> References: <97619b170802201010q797abfe1jf0ac1826274594f@mail.gmail.com> Message-ID: On 2/20/08, Rapsey wrote: > {errlog_logger_mf_dir, > "/Users/rapsey/workspace/erlang/logs"}, > {errlog_logger_mf_maxbytes, 8388608}, > {errlog_logger_mf_maxfiles, 20} I've never used SASL's error logging, but checking the sasl(6) man page indicates you probably meant error_logger_mf_* instead of errlog_.... From pablo.polvorin Wed Feb 20 20:25:18 2008 From: pablo.polvorin (Pablo Polvorin) Date: Wed, 20 Feb 2008 16:25:18 -0300 Subject: [erlang-questions] asn1 and the new ssl module In-Reply-To: <47BC2633.20605@erix.ericsson.se> References: <1ffe809c0802120934r5c580eeas2cb811a7e5c0b170@mail.gmail.com> <47B5ACC9.7010300@erix.ericsson.se> <1ffe809c0802151131s2fd81c16vdb7aebd67fabd51@mail.gmail.com> <47BC2633.20605@erix.ericsson.se> Message-ID: <1ffe809c0802201125m2498461fqfc9bdfff801d4431@mail.gmail.com> Hi, thanks for the patch! perhaps i had been doing something wrong, but i couldn't make your patch work for my. Immediately after upgrading a gen_tcp socket to ssl, I get this error {function_clause, [{ssl_connection,check_packet,[asn1,<<>>,0].. After fixing this adding a new case to check_packet(asn1,..), it still doesn't work, and returns data that is not an asn1-completed packet. Digging in the ber encoding documentation and asn1rt_ber_bin:decode_tag_and_length/1, each packet seems to looks like <>, where the size of the Tag field isn't know, and the size of the PacketLength field could be anything between 1 and 128 bytes. Are you taking this into account? Here is my version of a patch(R12B-1) for this, its based in my previous code (and so depends on the asn1 application.. witch is somewhat awkward as the api for decode_tag_and_length/1 doesn't define what error it would throw when the tag or length field isn't complete). best regards, pablo. 2008/2/20, Jakob Cederlund : > > thisIt was very useful, thanks! > And here is a patch. It simply adds asn1 package support for the new ssl. > It should work with R12B-1, and probably fine with R12B. > Hope this helps! > /Jakob > > > > Pablo Polvorin wrote: > Thanks for the clarification! > > ...it isn't a patch, .. probably it isn't usefull to you. . > anyway, this is the code i'm using > http://ppolv.wordpress.com/2008/02/15/erlang-ssl-and-asn1/ > > cheers > pablo > > 2008/2/15, Jakob Cederlund : > > > Nope, not yet. > Currently, the new ssl (the one you get with {ssl_imp, new}) only > supports these packet-options: raw, 1, 2, 4, cdr and line. (Packaging is > handled by the function ssl_connection:check_packet/3.) The rest are > fairly easy to add, and we hope to do that in the next release. Patches > are welcome! :-) > > /Jakob > > > Pablo Polvorin wrote: > > Hi all, > > I'm using the new ssl module to "upgrade" a gen_tcp socket to ssl. But > > I couldn't find a way to easily receiving asn1 packets from it. > > My question is, it's possible to use the {packet,asn1} option when > > using the new ssl module?. > > > > ssl_connection.erl seems to not have any reference to that option. > > > > Finally I implemented the buffering and packet delimiting code in my > > application, but I wonder if there is an easy and early way to > > accomplish the same. > > regards, > > > > > > > > > > -------------- next part -------------- A non-text attachment was scrubbed... Name: ssl_asn1_myversion.patch Type: text/x-diff Size: 2367 bytes Desc: not available Url : http://www.erlang.org/pipermail/erlang-questions/attachments/20080220/78e15009/attachment.bin From qrilka Wed Feb 20 20:32:05 2008 From: qrilka (Kirill Zaborski) Date: Wed, 20 Feb 2008 22:32:05 +0300 Subject: [erlang-questions] rotating logs dont work In-Reply-To: References: <97619b170802201010q797abfe1jf0ac1826274594f@mail.gmail.com> Message-ID: <337538cb0802201132rb01e28ana0f3e64a4282c25e@mail.gmail.com> Are there some better ways of logging except SASL? Best regards, Kirill On Feb 20, 2008 10:21 PM, Matthew Dempsky wrote: > On 2/20/08, Rapsey wrote: > > {errlog_logger_mf_dir, > > "/Users/rapsey/workspace/erlang/logs"}, > > {errlog_logger_mf_maxbytes, 8388608}, > > {errlog_logger_mf_maxfiles, 20} > > I've never used SASL's error logging, but checking the sasl(6) man > page indicates you probably meant error_logger_mf_* instead of > errlog_.... > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > From rapsey Wed Feb 20 20:32:30 2008 From: rapsey (Rapsey) Date: Wed, 20 Feb 2008 20:32:30 +0100 Subject: [erlang-questions] rotating logs dont work In-Reply-To: References: <97619b170802201010q797abfe1jf0ac1826274594f@mail.gmail.com> Message-ID: <97619b170802201132u34734e8t1e9951f544bbad53@mail.gmail.com> Doh. I always get stumped on the dumbest things. thanks. On Wed, Feb 20, 2008 at 8:21 PM, Matthew Dempsky wrote: > On 2/20/08, Rapsey wrote: > > {errlog_logger_mf_dir, > > "/Users/rapsey/workspace/erlang/logs"}, > > {errlog_logger_mf_maxbytes, 8388608}, > > {errlog_logger_mf_maxfiles, 20} > > I've never used SASL's error logging, but checking the sasl(6) man > page indicates you probably meant error_logger_mf_* instead of > errlog_.... > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080220/c4faac3e/attachment-0001.html From ok Thu Feb 21 00:07:30 2008 From: ok (Richard A. O'Keefe) Date: Thu, 21 Feb 2008 12:07:30 +1300 Subject: [erlang-questions] Strings as Lists In-Reply-To: References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> <9b08084c0802180649k75218a8jf4316379d6767c67@mail.gmail.com> Message-ID: <7ABFCE6D-9BFA-4798-856C-4CEE2D6DA1EF@cs.otago.ac.nz> On 19 Feb 2008, at 7:00 pm, Matt Kangas wrote: >> Principle 4: >> LET A HUNDRED SCHOOLS CONTEND. > > > Erm... are you the one now expressing PERL envy? :-) One of Perl's > mottos, after all, is: "There's more than one way to do it." I am *not* suggesting that there ought to be many ways to do it in the language. What I am suggesting is pretty much the opposite. The idea in Perl is to avoid design work. I'm saying let's try lots of designs BEFORE adding anything to the language, and then let's add at most ONE thing. After all, I said to let a hundred schools CONTEND, not to let a hundred schools PREVAIL. > I think there is value in providing *one obvious solution* to a > problem. "For every problem, there is an answer which is simple, obvious, and WRONG." Joe probably thinks his sketch is close to being "one obvious solution" to the needs he expressed. But I think it is horribly ugly, error prone, and more of a pain in the rectal region to deal with than the problem it is supposed to solve. > If it solves > 90% of common use-cases, Then it isn't a solution. Let's face it, what we have NOW solves > 90% of common use-cases. > is syntactically simple, the solution Joe proposed is NOT syntactically simple. It puts a great deal of syntactic (and some semantic) processing in the lexical analyser, which is not a really wonderful place to put it. For the problem he is trying to deal with, this may not be avoidable: trying to embed several levels of lexical structure that were never designed to fit together is NOT going to be easy. > > I'm fascinated by the flexibility you propose, but confused about the > implications. Should we need to support a Tower of Hanoi for > notations? How likely are users to ever embed > 1 notation? > 2? I see no tower of Hanoi here. In fact it is precisely the point of my design that to support an additional notation - the "meta-notation" (function header, lines, %% and @@ insertions, and dot) are all handled by the *framework*, which remains completely ignorant of any specific notation - you add ONE function that takes a string and adds the quotation needed for your particular notation. Instead of towers, there are at most bucket brigades. Here's another approach. My emacs-like text editor "thief" has a command ESC [ ` which means "convert region to HTML by changing the characters <>"'& to entity references." (All the HTML commands are on ESC [.) So I can (and do) write whatever I want, such as embedded programming language text, just the way it looks, and then convert it. I also have a library package with quoting and unquoting code for AWK C and C++ (without trigraphs) C and C++ (with trigraphs) Csh DEC-10 Prolog Fortran 77 and 90 (but only printing characters) Java Lisp M4 Quintus Prolog sh TeX I happen not to have needed Eiffel, Erlang, or Haskell in this library yet, but it is really quite a small matter of programming to do that. It would also be a small matter of programming to plug these into my editor. So if I wanted a fragment of TeX in the query of a URL, I would then be able to 1. Type the text the way I would normally type it. 2. Select the TeX part and ESC ` u (quote region as URL) 3. Select the whole URL and ESC ` e (quote region as Erlang) Please remember, the framework for this DOES exist, but quote-as-URL and quote-as-Erlang currently do NOT. What I am demonstrating here is a DESIGN. This design completely solves the problem of WRITING embedded notations without ANY language change whatever. (As does my previous proposal; that was for a fairly language-independent preprocessor, NOT for something to go in the Erlang compiler.) It doesn't really solve the problem of writing embedded notations READABLY, which my previous proposal did (and which Joe's proposal failed to). The simplest most obvious design that could solve Joe's problem in a readable way has four levels: (1) lexical: some kind of 'literal' string (2) syntactic: no change to the existing language whatever (3) library: a suite of functions that take a string and add whatever quotation is needed for a specified notation to treat all the characters literally (rather like my C library mentioned above). (4) optimisation: the compiler is allowed, but not required, to evaluate calls to certain functions with known arguments at compile time; the quoting functions may but need not be in the set of such functions. The difficult thing is (1), which I think Joe wants anyway. I'm aware of several lexical devices for this, and they all stink in one way or another, because there isn't ANY delimiter character that you might not want to include in the data; it is even conceivable that the data might include at least one instance of every character. The only lexical design that doesn't have that problem is the old Fortran 66 H notation, which is easy enough to generate with a text editor. Perhaps if we say that a literal string begins with n+2 quotation marks and a single character that is not a letter, digit, space, or tab, and then ends with another copy of that single character followed by n+2 quotation marks. (In Erlang, the quotation marks could be " for a string or ' for an atom.) For any literal string, there is some longest block of quotation marks, so it is always possible to select a bracketing run that is longer. Note that the single character that ends the run of quotation marks could be a new line, so we could have Literal_String = """ Here is `'"\$^some literal text with an embedded but no trailing newline """, Another = ""!He said "Foo!" But that was not the end!!"" Hm. I think I may finally have something simple, obvious, readable, and it just might work. From taj.khattra Thu Feb 21 01:38:48 2008 From: taj.khattra (Taj Khattra) Date: Wed, 20 Feb 2008 16:38:48 -0800 Subject: [erlang-questions] Strings as Lists In-Reply-To: <7ABFCE6D-9BFA-4798-856C-4CEE2D6DA1EF@cs.otago.ac.nz> References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> <9b08084c0802180649k75218a8jf4316379d6767c67@mail.gmail.com> <7ABFCE6D-9BFA-4798-856C-4CEE2D6DA1EF@cs.otago.ac.nz> Message-ID: <57a21f730802201638h6e451465kf186591baedbc0bf@mail.gmail.com> > Perhaps if we > say that a literal string begins with n+2 quotation marks and a > single character > that is not a letter, digit, space, or tab, and then ends with > another copy of > that single character followed by n+2 quotation marks. here's an excerpt from http://www.lua.org/manual/5.1/manual.html#2.1 specifying how literal strings can be defined in Lua: Literal strings can also be defined using a long format enclosed by long brackets. We define an opening long bracket of level n as an opening square bracket followed by n equal signs followed by another opening square bracket. So, an opening long bracket of level 0 is written as [[, an opening long bracket of level 1 is written as [=[, and so on. A closing long bracket is defined similarly; for instance, a closing long bracket of level 4 is written as ]====]. A long string starts with an opening long bracket of any level and ends at the first closing long bracket of the same level. Literals in this bracketed form may run for several lines, do not interpret any escape sequences, and ignore long brackets of any other level. They may contain anything except a closing bracket of the proper level. From dking Thu Feb 21 04:48:18 2008 From: dking (David King) Date: Wed, 20 Feb 2008 19:48:18 -0800 Subject: [erlang-questions] Preprocessor bug? Message-ID: <981B483C-DC9E-4905-8973-0253E402FE87@ketralnis.com> I'm not sure if this is a bug or, if it is a bug, it even needs to be fixed. This code: f(F,A) when is_function(F,1) -> F(A); f(F,B) when is_function(F,2) -> F(B,B). main() -> f(fun(a) -> io:format("f(g/1): ~p~n",[a]) end, a), f(fun(b,b) -> io:format("f(g/2): ~p~n",[b]) end, b). compiles and works as expected, unless -compile(inline) is specified. If -compile(inline) is specified, the compiler dies with "error: function called with wrong number of arguments!". I would think that when the pre-processor can't determine at pre-compile time which clause to run, it just wouldn't run one, but this is a mess I know I'm getting into when I use -compile(inline), so it might not even matter. From Raymond.Xiong Thu Feb 21 08:19:02 2008 From: Raymond.Xiong (Raymond Xiong) Date: Thu, 21 Feb 2008 15:19:02 +0800 Subject: [erlang-questions] failed to enable SMP support in otp_src_R12B-1 In-Reply-To: <18364.7591.965193.617900@harpo.it.uu.se> References: <20080220103022.GA742@Sun.Com> <18364.7591.965193.617900@harpo.it.uu.se> Message-ID: <20080221071901.GA19236@Sun.Com> On 02/20/08, Mikael Pettersson wrote: > Raymond Xiong writes: > > Hello, > > > > I have a Sun Ultra 40(a dual-core amd64 machine) which runs > > Solaris Nevada. I used to run otp_src_R12B-0 on it and had > > no problem in enabling SMP support in Erlang emulator(actually > > I did nothing for that, it was enabled automatically). > > > > However, recently I upgrated the machine to Solaris Nevada > > latest build, which had some changes in sctp header files > > and caused otp_src_R12B-0 failed to compile. So I downloaded > > otp_src_R12B-1, configured and compiled it. But this time > > I couldn't enable SMP support, even if I configured it > > explicitly with SMP support: > > > > $ CPPFLAGS=-I/usr/include/gd2 ./configure --prefix=/myroot \ > > --enable-smp-support --enable-threads > > > > (I specified CPPFLAGS because libgd header files were placed > > under /usr/include/gd2 on Solaris) > > > > Has anyone encountered the same issue? > > You need to provide us with details about HOW it failed. > A complete log from ./configure and make would be a good start. Mikael, I did some more experiments on my machine and found the following results: Scenario 1) - configure with no "--enable-smp-support" - no smp support Scenario 2) - confiure with "--enable-smp-support" - have smp support Scenario 3) - configure with no "--enable-smp-support" - gmake && gmake install - re-configure with "--enable-smp-support" - gmake && gmake install - still no smp support Scenario 4) - configure with no "--enable-smp-support" - gmake && gmake install - gmake clean - re-configure with "--enable-smp-support" - gmake && gmake install - have smp support The only difference between scenario 3 and scenario 4 is the call of "gmake clean" before re-configuration. I didn't realize it's necessary before(I had thought after re-configuration every thing will be rebuilt. But it seemed that's not the case. Is it correct?). I also have a question on scenario 1 and scenario 2. From my testing result, "--enable-smp-support" must be specified explicitly on my machine. But it was said in README that this feature is detected automaticaly, is it ture? BTW, I wonder how default values of these features(ie. SMP) are defined? From my understanding, for each target(OS/platform) a profile will be created, which will be used by Makefile in all subdirs. On my machine, that file is make/i386-pc-solaris2.11/otp.mk. I see "HIPE_ENABLED" in this file, but there is no variables like "SMP_ENABLED". -- Thanks, Raymond From gleber.p Thu Feb 21 09:14:51 2008 From: gleber.p (Gleber) Date: Thu, 21 Feb 2008 09:14:51 +0100 Subject: [erlang-questions] net_kernel:nodes_info() error In-Reply-To: References: <14f0e3620802200703m5f1b2beue7dfde00c5f729b7@mail.gmail.com> Message-ID: <14f0e3620802210014p58883b6j5e548a82c27cf30d@mail.gmail.com> Thanks a lot. I should have checked docs... :) P.S. Nicolas, sorry for the off-list reply. On Wed, Feb 20, 2008 at 4:23 PM, Niclas Eklund wrote: > > Hello! > > Try: > > shell> erl -sname hello > > erl> net_kernel:nodes_info(). > {ok,[]} > > > /Nick > > > > > > On Wed, 20 Feb 2008, Gleber wrote: > > > Hello, > > > > While figuring out how to make Distel work with long domain names, I've > > encountered the following error: > > > > gleber:~$ erl > > Erlang (BEAM) emulator version 5.6.1 [source] [async-threads:0] [hipe] > > [kernel-poll:false] > > > > Eshell V5.6.1 (abort with ^G) > > 1> net_kernel:nodes_info(). > > ** exception error: bad argument > > in function ets:first/1 > > called as ets:first(sys_dist) > > in call from net_kernel:get_nodes/1 > > in call from net_kernel:get_nodes_info/0 > > 2> ets:i(). > > id name type size mem owner > > ---------------------------------------------------------------------------- > > 11 code set 259 10768 code_server > > 12 code_names set 52 5065 code_server > > 13 shell_records ordered_set 0 72 <0.24.0> > > ac_tab ac_tab set > > 6 855 application_controller > > file_io_servers file_io_servers set 0 279 file_server_2 > > global_locks global_locks set 0 279 global_name_server > > global_names global_names set 0 279 global_name_server > > global_names_ext global_names_ext set 0 279 global_name_server > > global_pid_ids global_pid_ids bag 0 279 global_name_server > > global_pid_names global_pid_names bag 0 279 global_name_server > > inet_cache inet_cache bag 0 279 inet_db > > inet_db inet_db set 21 546 inet_db > > inet_hosts inet_hosts set 0 279 inet_db > > ok > > 3> > > > > My system is Ubuntu Gutsy 7.10 with Erlang 12B built from > > debian experimental deb-src files. > > > > Do anyone know what this means? Is it a bug? > > > > > > > > -- > > Gleb Peregud > > http://gleber.pl/ > > > > "Only two things are infinite, the universe and human stupidity, and I'm not > > sure about the former." > > -- Albert Einstein > > > > > -- Gleb Peregud http://gleber.pl/ "Only two things are infinite, the universe and human stupidity, and I'm not sure about the former." -- Albert Einstein From zerthurd Thu Feb 21 09:40:41 2008 From: zerthurd (Maxim Treskin) Date: Thu, 21 Feb 2008 14:40:41 +0600 Subject: [erlang-questions] Megaco: Disconnection of remote mg when syntax error In-Reply-To: <47BC356D.5000900@erix.ericsson.se> References: <47BC356D.5000900@erix.ericsson.se> Message-ID: Thank you very much It is strange for me. Why all megaco_user callbacks takes ConnHandle as one of arguments, but handle_syntax_error takes only ReceiveHandle? -- Maxim Treskin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080221/1b4b6050/attachment.html From richardc Thu Feb 21 10:19:23 2008 From: richardc (Richard Carlsson) Date: Thu, 21 Feb 2008 10:19:23 +0100 Subject: [erlang-questions] Preprocessor bug? In-Reply-To: <981B483C-DC9E-4905-8973-0253E402FE87@ketralnis.com> References: <981B483C-DC9E-4905-8973-0253E402FE87@ketralnis.com> Message-ID: <47BD421B.5010201@it.uu.se> David King wrote: > I'm not sure if this is a bug or, if it is a bug, it even needs to be > fixed. This code: > > f(F,A) when is_function(F,1) -> > F(A); > f(F,B) when is_function(F,2) -> > F(B,B). > > main() -> > f(fun(a) -> ... end, a), > f(fun(b,b) -> ... end, b). > > compiles and works as expected, unless -compile(inline) is specified. > If -compile(inline) is specified, the compiler dies with "error: > function called with wrong number of arguments!". Hmm, yes, it's not unreasonable to call it a bug. For now, if you have fun-calls that are guarded by is_function test that check the arity, you should not turn on inlining. I might have a look at it and see if the inliner can be taught about the is_function/2 test, so it can throw away the unselectable clauses. No guarantees or time line for that project, though. /Richard From tobbe Thu Feb 21 11:03:11 2008 From: tobbe (Torbjorn Tornkvist) Date: Thu, 21 Feb 2008 11:03:11 +0100 Subject: [erlang-questions] rotating logs dont work In-Reply-To: <337538cb0802201132rb01e28ana0f3e64a4282c25e@mail.gmail.com> References: <97619b170802201010q797abfe1jf0ac1826274594f@mail.gmail.com> <337538cb0802201132rb01e28ana0f3e64a4282c25e@mail.gmail.com> Message-ID: Kirill Zaborski wrote: > Are there some better ways of logging except SASL? Not sure aboute 'better'; but an alternative can be found in the yfront app. of jungerl, named wraplog.erl: Example use: -define(LOG_SIZE, 2000000). -define(NO_LOG_FILES, 9). ... LogDir = "/tmp", wraplog:start_sup_handler(LogDir, ?LOG_SIZE, ?NO_LOG_FILES), .... --Tobbe > > Best regards, > Kirill > > On Feb 20, 2008 10:21 PM, Matthew Dempsky wrote: >> On 2/20/08, Rapsey wrote: >>> {errlog_logger_mf_dir, >>> "/Users/rapsey/workspace/erlang/logs"}, >>> {errlog_logger_mf_maxbytes, 8388608}, >>> {errlog_logger_mf_maxfiles, 20} >> I've never used SASL's error logging, but checking the sasl(6) man >> page indicates you probably meant error_logger_mf_* instead of >> errlog_.... >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions >> http://www.erlang.org/mailman/listinfo/erlang-questions >> From masterofquestions Thu Feb 21 13:18:09 2008 From: masterofquestions (db) Date: Thu, 21 Feb 2008 07:18:09 -0500 Subject: [erlang-questions] OTP node config file: set global Vars in node config Message-ID: <1218d6a50802210418q2479ee7arb65a629fe784403c@mail.gmail.com> anyone knows how I can define global config parameters without specifying the application and how do I access this global node config Vars inside the code? application:get_env, gets the environment vars for the application. What if I wanted to get environment vars, global to the node(all application)? If the above is not possible, and I specify config tuple {myapp, [{Var, Val}]}. Does it mean I have to start the myapp application to access these myapp specific Vars, in erl shell? thank you, -- rk -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080221/97ca73a3/attachment.html From saleyn Thu Feb 21 14:09:02 2008 From: saleyn (Serge Aleynikov) Date: Thu, 21 Feb 2008 08:09:02 -0500 Subject: [erlang-questions] OTP node config file: set global Vars in node config In-Reply-To: <1218d6a50802210418q2479ee7arb65a629fe784403c@mail.gmail.com> References: <1218d6a50802210418q2479ee7arb65a629fe784403c@mail.gmail.com> Message-ID: <47BD77EE.7030102@gmail.com> There's only one repository of configuration data in OTP maintained by the application_controller on per-application basis. However, you can always use file:consult/1 call to have custom configuration read from a file. The question is then which OTP application would be responsible for loading that config data from file? Once you create such an application, you may as well stick to the standard OTP application behavior and use application:get_env/2 for that purpose. The only exception I recall being when we had a need to implement something custom on that front was to load application configuration data and convert it into a compiled bytecode so that key/value lookups would work faster. Serge db wrote: > anyone knows how I can define global config parameters without specifying > the application and how do I access this global node config Vars inside the > code? > > application:get_env, gets the environment vars for the application. What if > I wanted to get environment vars, global to the node(all application)? > > If the above is not possible, and I specify config tuple {myapp, [{Var, > Val}]}. Does it mean I have to start the myapp application to access these > myapp specific Vars, in erl shell? > > thank you, From pfisher Thu Feb 21 14:54:15 2008 From: pfisher (Paul Fisher) Date: Thu, 21 Feb 2008 07:54:15 -0600 Subject: [erlang-questions] failed to enable SMP support in otp_src_R12B-1 In-Reply-To: <20080221071901.GA19236@Sun.Com> References: <20080220103022.GA742@Sun.Com> <18364.7591.965193.617900@harpo.it.uu.se> <20080221071901.GA19236@Sun.Com> Message-ID: <1203602055.5958.1.camel@pfisher-laptop> On Thu, 2008-02-21 at 15:19 +0800, Raymond Xiong wrote: > I also have a question on scenario 1 and scenario 2. From > my testing result, "--enable-smp-support" must be specified > explicitly on my machine. But it was said in README that this > feature is detected automaticaly, is it ture? This has been my experience... I've just gotten in the habit of enabling everything explicitly. -- paul From exta7 Thu Feb 21 15:20:21 2008 From: exta7 (Zvi) Date: Thu, 21 Feb 2008 06:20:21 -0800 (PST) Subject: [erlang-questions] Auto generated functions In-Reply-To: <15312902.post@talk.nabble.com> References: <597c69660802041439p20d3a032mfbff16817f752fec@mail.gmail.com> <15312902.post@talk.nabble.com> Message-ID: <15612426.post@talk.nabble.com> In Javascript, unlike Erlang, anonymous function can call itself, without using Y-combinator tricks. Does it mean that JS is more functional than Erlang: factorial = function(n){ return (n==0) ? 1 : n*arguments.callee(n-1); }; Factorial = fun(0) -> 1; (N) -> N*???(N-1). Zvi Zvi wrote: > > Y-combinator is cool, but I'm just currious why Erlang doesn't have some > mechanism allowing fun to reference to itself (doesn't mutter if it's > named or annonymous fun), same way as every process can get it's own PID > using self(), i.e. (here I using this() to reference to function from > inside): > > Len = fun([]) -> 0; > ([_|T]) -> this()(T)+1 end. > > Is there something in BEAM instruction set, that preventing from > implementing this? > > thanks, > Zvi > -- View this message in context: http://www.nabble.com/Auto-generated-functions-tp15279499p15612426.html Sent from the Erlang Questions mailing list archive at Nabble.com. From richardc Thu Feb 21 16:21:40 2008 From: richardc (Richard Carlsson) Date: Thu, 21 Feb 2008 16:21:40 +0100 Subject: [erlang-questions] Auto generated functions In-Reply-To: <15612426.post@talk.nabble.com> References: <597c69660802041439p20d3a032mfbff16817f752fec@mail.gmail.com> <15312902.post@talk.nabble.com> <15612426.post@talk.nabble.com> Message-ID: <47BD9704.1080607@it.uu.se> Zvi wrote: > In Javascript, unlike Erlang, anonymous function can call itself, without > using Y-combinator tricks. > Does it mean that JS is more functional than Erlang: > > factorial = function(n){ return (n==0) ? 1 : n*arguments.callee(n-1); }; No, it means that JS is more *Object Oriented* than Erlang. But in Erlang, you don't need to use any "Y-combinator tricks": simply pass the function itself as an extra argument. FactX = fun(0, F) -> 1; (N, F) -> N * F(N-1, F) end, 13 = FactX(6, FactX) In practice, this is also how the self-reference works in JS. The extra parameter is an added cost, that you don't have in Erlang unless you actually need it (which is not often). /Richard From thomasl_erlang Thu Feb 21 16:39:46 2008 From: thomasl_erlang (Thomas Lindgren) Date: Thu, 21 Feb 2008 07:39:46 -0800 (PST) Subject: [erlang-questions] Auto generated functions In-Reply-To: <15612426.post@talk.nabble.com> Message-ID: <765783.52286.qm@web38810.mail.mud.yahoo.com> --- Zvi wrote: > In Javascript, unlike Erlang, anonymous function can > call itself, without > using Y-combinator tricks. > Does it mean that JS is more functional than Erlang: Depends. What's the lambda calculus for it? Best, Thomas ____________________________________________________________________________________ Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping From theczintheroc2007 Thu Feb 21 20:15:27 2008 From: theczintheroc2007 (Colin Z) Date: Thu, 21 Feb 2008 14:15:27 -0500 Subject: [erlang-questions] Beyond Strings as Lists Message-ID: This entire discussion brings up a larger issue to me. As a newbie to the community, looking objectively at it from the outside, I think Erlang has come to a crossroads of sorts. It's on the verge of realizing a vast potential. Choices that are made now are going to affect whether it ends up on a path to fame or obscurity. It's the only language out there that really offers the feature set necessary to easily take full advantage of the emerging multi-core/multi-CPU/distributed setups that are soon going to be the norm for hardware environments. By virtue of being a functional language, it's never going to be adopted as a "code monkey" language like C# or Java. Typical enterprise-level outfits aren't ever going to have their rank and file developers using Erlang. I believe Erlang's niche will expand into a middle-ware platform that is used to abstract away the details of traditional multi-threaded and distributed architectures. It will be the mid and high level developers and architects, or 3rd party developers, who engineer this. Code monkeys will continue to do their work in imperative and OO languages that plug into the Erlang-based middle-ware. So, in this respect, demand for competent Erlang programmers will remain high, as well as the salaries they can command. What's going to make or break this deal is polish and marketing. Annoying terms to be sure. As a lone, individual programmer, I love Erlang. Imagining it from a product manager's perspective, though, I would never choose it in its current state. Most enterprise-level managers won't take a language seriously and adopt it for their project if you tell them the standard dev tool is Emacs or an Eclipse plugin maintained by a couple people. The official documentation available for Erlang/OTP right now is only just adequate and painful to slog through and decipher. Compare it to Sun's or Microsoft's or even PHP's web documentation, though, and it appears lacking and less clean. The community is slowly growing, but good tutorials are still few and far between, are usually full of grammatical errors, and are usually very difficult to locate via Google searches. It seems to me that all the pieces are there. Erlang has support for all the little things that make or break a platform (unit testing comes to mind). What it lacks most right now is integration of all those pieces into a unified, standardized, and understandable whole. Managers and developers like to feel secure and looked out for. They like to feel as if there's competent, powerful support out there for the language they've chosen and that it has strong, directed leadership guiding it towards a definite vision. This convinces them that it's not just a fly-by-night fad and that they won't be left hanging out to dry. Joe does a great job of generating enthusiasm about what Erlang has to offer technically. What Erlang has right now though is an image crisis. It has no marketing or polish or pizazz behind it. It lacks an efficient, organized committee-based senior community. It lacks tools with support for the things Erlang does best. (Is there any reason why Erlang tools can't or don't support something like Intellisense for the patterns a function or receive block is able to match; or the possible patterns returned from a function?) Is there any reason why no one has asked for an interview with Charles Ying about his team's experiences? You've got AMAZON using Erlang. That's a big deal. How about the guys over at Vendetta Online? You've got the entire video game industry (*cough*Blizzard*cough*) waiting to be sold on the virtues of Erlang. What about the YAWS people? You need to all be scratching each others' backs here. If all you get out of Amazon running simpleDB on Erlang is a blog post by Ying stating the fact and suggesting you read Joe's book, you're missing out on a lot of hype. This string as lists debate is a perfect example and is much needed. Any modern language that doesn't have powerful, unified, built-in support for something as simple as a string will be laughed out of the industry. Does Erlang have an official User Experience team looking at this stuff? A "higher authority" that sets standards that both minuscule and massive things like method naming conventions, APIs, or new features must pass through before being adopted? Is anyone working to update the Erlang website to give it a more modern face lift? Hell, 50% of why Ruby and RoR got popular was because they had some glossy buttons and gradients on their page. Please understand that these criticisms are coming from a total Erlang newbie that really does enjoy and care about the language. Most of the questions are rhetorical. They are just things I'm throwing out, as a newbie, that other average newbies will be considering and asking about when they themselves look into Erlang. I hope you understand how important little things like this are to the further success of the language. I really want to see Erlang realize its full potential. -Colin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080221/5b16e067/attachment-0001.html From machinshin2002 Thu Feb 21 19:41:29 2008 From: machinshin2002 (Vat Raghavan) Date: Thu, 21 Feb 2008 10:41:29 -0800 (PST) Subject: [erlang-questions] Practical Erlang Message-ID: <23537.61381.qm@web31507.mail.mud.yahoo.com> that is great news and i'm really excited to hear it! I hope it covers gen_server, gen_fsm, et.al. in good detail, that's the big thing that's missing from joe's book, and i don't understand. --vat ----.signature---- Without the hope that things will get better, that our inheritors will know a world that is fuller and richer than our own, life is pointless, and evolution is vastly overrated -- Delenn ----- Original Message ---- From: pat eyler To: Erlang Sent: Wednesday, February 20, 2008 12:50:09 PM Subject: [erlang-questions] Practical Erlang It's nice to get worf from the horses mouth. I've been blogging about another new Erlang book (from O'Reilly this time), and one of the authors (Francesco Cesarini) dropped by to add his confirmation to O'Reilly's. ... It is a fact. "Practical Erlang Programming" will be published by O'Reilly. ... Yay! I'll blog more as I have more info http://on-erlang.blogspot.com/2008/02/not-just-rumour.html -- thanks, -pate ------------------------- Duty makes us do things, Love make us do things well. http://on-ruby.blogspot.com http://on-erlang.blogspot.com http://on-soccer.blogspot.com _______________________________________________ erlang-questions mailing list erlang-questions http://www.erlang.org/mailman/listinfo/erlang-questions ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ From askyrme Thu Feb 21 22:21:52 2008 From: askyrme (Alexandre Skyrme) Date: Thu, 21 Feb 2008 18:21:52 -0300 (BRT) Subject: [erlang-questions] how: Setting Process Limit with escript or Running w/o Compiling Message-ID: <45940.201.18.18.100.1203628912.squirrel@webmail.inf.puc-rio.br> Greetings, I'm interested in running Erlang code _without_ compiling it and recently I found out about escript. I've been able to run some code with it, however I cannot get around the default maximum process limit (32768) when using it. Is there some way to change that limit within Erlang code or maybe by using some command line option to escript (such as the +P used with erl)? I'd also be interested in any alternatives, other than escript, to run Erlang code without compiling it. Using Erlang's shell interactively seems to result in code compilation before execution. Simply using erl with the -s, -noshell and "run start stop" options, only seems to work if I first compile. In case it makes any difference, I'm using Erlang on Ubuntu 7.10, AMD64, installed from the Ubuntu repository package, without HiPE. Thanks in advance for any suggestions. Regards, -- Alexandre Skyrme From rsaccon Thu Feb 21 22:39:34 2008 From: rsaccon (Roberto Saccon) Date: Thu, 21 Feb 2008 18:39:34 -0300 Subject: [erlang-questions] how: Setting Process Limit with escript or Running w/o Compiling In-Reply-To: <45940.201.18.18.100.1203628912.squirrel@webmail.inf.puc-rio.br> References: <45940.201.18.18.100.1203628912.squirrel@webmail.inf.puc-rio.br> Message-ID: AFAIK, everything not-compiling (e.g. shell, escript) boils down to erl_eval:exprs/2. On Thu, Feb 21, 2008 at 6:21 PM, Alexandre Skyrme wrote: > Greetings, > > I'm interested in running Erlang code _without_ compiling it and recently > I found out about escript. I've been able to run some code with it, > however I cannot get around the default maximum process limit (32768) when > using it. > > Is there some way to change that limit within Erlang code or maybe by > using some command line option to escript (such as the +P used with erl)? > > I'd also be interested in any alternatives, other than escript, to run > Erlang code without compiling it. Using Erlang's shell interactively seems > to result in code compilation before execution. Simply using erl with the > -s, -noshell and "run start stop" options, only seems to work if I first > compile. > > In case it makes any difference, I'm using Erlang on Ubuntu 7.10, AMD64, > installed from the Ubuntu repository package, without HiPE. > > Thanks in advance for any suggestions. > > Regards, > -- > Alexandre Skyrme > > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > -- Roberto Saccon http://rsaccon.com From francesco Thu Feb 21 22:50:31 2008 From: francesco (Francesco Cesarini) Date: Thu, 21 Feb 2008 21:50:31 +0000 Subject: [erlang-questions] Practical Erlang Programming In-Reply-To: <23537.61381.qm@web31507.mail.mud.yahoo.com> References: <23537.61381.qm@web31507.mail.mud.yahoo.com> Message-ID: <47BDF227.80102@erlang-consulting.com> Hi Vat, There will be a chapter on behaviors, but unfortunately, not with the level of detail you are asking for. Our main goal is to cover Erlang in depth. Make sure that newbies struggling with recursion can easily understand it or developers being exposed to pattern matching for the first time use it optimally. The contents of the book are pretty much outlined by the introductory Erlang courses Jan-Henry and I have been giving in the last decade, and based on the knowledge and experience gained when teaching. We know which students struggle where, and try to address it in the book. We plan to cover less than Joe, but more in depth. In these lines, we are very interested in hearing what others feel we should include in such a book. We have lots of ideas on OTP, but that in itself is a completely different beast we hope to tackle as soon as this book is out. So hope you have a bit of patience and bear with us.... Regards, Francesco PS. The correct title is "Practical Erlang Programming" -- http://www.erlang-consulting.com Vat Raghavan wrote: > that is great news and i'm really excited to hear it! > I hope it covers gen_server, gen_fsm, et.al. in good detail, that's the big thing that's missing from joe's book, and i don't understand. > > --vat > > ----.signature---- > Without the hope that things will get better, that our inheritors will know a world that is fuller and richer than our own, > life is pointless, and evolution is vastly overrated > -- Delenn > > > ----- Original Message ---- > From: pat eyler > To: Erlang > Sent: Wednesday, February 20, 2008 12:50:09 PM > Subject: [erlang-questions] Practical Erlang > > It's nice to get worf from the horses mouth. I've been > blogging about another new Erlang book (from O'Reilly > this time), and one of the authors (Francesco Cesarini) > dropped by to add his confirmation to O'Reilly's. > > ... It is a fact. "Practical Erlang Programming" will > be published by O'Reilly. ... > > Yay! I'll blog more as I have more info > > http://on-erlang.blogspot.com/2008/02/not-just-rumour.html > > From bcully Fri Feb 22 00:07:30 2008 From: bcully (Brian Cully) Date: Thu, 21 Feb 2008 18:07:30 -0500 Subject: [erlang-questions] Practical Erlang Programming In-Reply-To: <47BDF227.80102@erlang-consulting.com> References: <23537.61381.qm@web31507.mail.mud.yahoo.com> <47BDF227.80102@erlang-consulting.com> Message-ID: On 21-Feb-2008, at 16:50, Francesco Cesarini wrote: > In these lines, we are very interested in hearing what others > feel we should include in such a book. > > We have lots of ideas on OTP, but that in itself is a completely > different beast we hope to tackle as soon as this book is out. So hope > you have a bit of patience and bear with us.... Unfortunately, what I would really like is something akin to an OTP Illustrated. OTP is by far the hardest thing I have to wrap my head around. Proper use of supervisor tree, best practices on function placement, common idioms, etc.,. A lot of the other stuff you can pick up pretty quickly from the man pages an existing sources, but for some reason I have a hard time getting very far into OTP. My biggest problems all tend to revolve around optimal use of those libraries and understanding the culture they promulgated. -bjc From tty.erlang Fri Feb 22 00:15:08 2008 From: tty.erlang (t ty) Date: Thu, 21 Feb 2008 18:15:08 -0500 Subject: [erlang-questions] Practical Erlang Programming In-Reply-To: References: <23537.61381.qm@web31507.mail.mud.yahoo.com> <47BDF227.80102@erlang-consulting.com> Message-ID: <290b3ba10802211515r3cf6f120i8eb7b49a3e4e49c8@mail.gmail.com> You could of course take the Erlang/OTP training course :) t On Thu, Feb 21, 2008 at 6:07 PM, Brian Cully wrote: > On 21-Feb-2008, at 16:50, Francesco Cesarini wrote: > > In these lines, we are very interested in hearing what others > > feel we should include in such a book. > > > > We have lots of ideas on OTP, but that in itself is a completely > > different beast we hope to tackle as soon as this book is out. So hope > > you have a bit of patience and bear with us.... > > Unfortunately, what I would really like is something akin to an OTP > Illustrated. OTP is by far the hardest thing I have to wrap my head > around. Proper use of supervisor tree, best practices on function > placement, common idioms, etc.,. > > A lot of the other stuff you can pick up pretty quickly from the man > pages an existing sources, but for some reason I have a hard time > getting very far into OTP. > > My biggest problems all tend to revolve around optimal use of those > libraries and understanding the culture they promulgated. > > -bjc > > > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > From dmercer Fri Feb 22 00:17:00 2008 From: dmercer (David Mercer) Date: Thu, 21 Feb 2008 17:17:00 -0600 Subject: [erlang-questions] Practical Erlang Programming In-Reply-To: References: <23537.61381.qm@web31507.mail.mud.yahoo.com><47BDF227.80102@erlang-consulting.com> Message-ID: <00fc01c874df$dd0c50c0$891ea8c0@SSI.CORP> I'll second Brian's view. If you have some experience with different programming languages, Erlang itself is just another language. What sets it apart is the OTP libraries that have been built to create reliable, fault-tolerant, scalable systems. Another book on just the Erlang programming language would not find a place on my bookshelf. DBM -----Original Message----- From: erlang-questions-bounces [mailto:erlang-questions-bounces] On Behalf Of Brian Cully Sent: Thursday, February 21, 2008 17:08 To: Francesco Cesarini Cc: Erlang Subject: Re: [erlang-questions] Practical Erlang Programming On 21-Feb-2008, at 16:50, Francesco Cesarini wrote: > In these lines, we are very interested in hearing what others > feel we should include in such a book. > > We have lots of ideas on OTP, but that in itself is a completely > different beast we hope to tackle as soon as this book is out. So hope > you have a bit of patience and bear with us.... Unfortunately, what I would really like is something akin to an OTP Illustrated. OTP is by far the hardest thing I have to wrap my head around. Proper use of supervisor tree, best practices on function placement, common idioms, etc.,. A lot of the other stuff you can pick up pretty quickly from the man pages an existing sources, but for some reason I have a hard time getting very far into OTP. My biggest problems all tend to revolve around optimal use of those libraries and understanding the culture they promulgated. -bjc _______________________________________________ erlang-questions mailing list erlang-questions http://www.erlang.org/mailman/listinfo/erlang-questions From bjt Fri Feb 22 00:41:17 2008 From: bjt (Benjamin Tolputt) Date: Fri, 22 Feb 2008 10:41:17 +1100 Subject: [erlang-questions] Practical Erlang Programming In-Reply-To: References: <23537.61381.qm@web31507.mail.mud.yahoo.com> <47BDF227.80102@erlang-consulting.com> Message-ID: <47BE0C1D.8060004@pmp.com.au> On 22-Feb-2008, Brian Cully wrote: > Unfortunately, what I would really like is something akin to an OTP > Illustrated. OTP is by far the hardest thing I have to wrap my head > around. Proper use of supervisor tree, best practices on function > placement, common idioms, etc.,. > This is something I agree is an issue for people (such as Biran & myself) getting into Erlang. I understand the appeal of a book describing the basics of a language. For the author, it has a much broader market (i.e. all those who don't know the language), and for the beginner it doesn't make assumptions on their knowledge of the language. The problem with these books is that they only take you so far. Most decent developers I have worked with can pick up a language in a style/genre they are familiar with within a few days (i.e. a C++ programmer can pick up the syntax/semantics of Java pretty damn quick, a Lisp programmer tends to pick up Erlang syntax/semantics in around the same time). The issue isn't the language, but the best use of the language library building blocks (or even knowing of their existence). Let's take Java as an example. Sure, there are a literal tonne of books on the syntax/semantics of Java. However, there is around the same amount of books describing various libraries/frameworks one can use with Java. Erlang currently already has a good book on the syntax/semantics - Joe's Programming Erlang. I don't need another one of those on my shelf. What I need is a book that shows me how to get the most out of the Erlang library building blocks - namely OTP. Regards, B.J.Tolputt From tomas.abrahamsson Fri Feb 22 01:12:01 2008 From: tomas.abrahamsson (Tomas Abrahamsson) Date: Fri, 22 Feb 2008 01:12:01 +0100 Subject: [erlang-questions] code dependency diagrams In-Reply-To: <47B5758E.40503@ericsson.com> References: <47B5758E.40503@ericsson.com> Message-ID: On Fri, Feb 15, 2008 at 12:20 PM, Ulf Wiger (TN/EAB) wrote: > > I've mentioned on occasion that I'd like to see a visualization tool > that shows an UML-style structure diagram for Erlang applications, > but with annotations showing the direction and arity of the > dependencies. ... > And now to the question: Which tool would you recommend I use? > I looked at Eclipse once, but got the feeling that you won't get > anywhere without first writing a thousand or so lines of Java code. > Is this still the way to go? Perhaps something like this would be useful: http://www.win.tue.nl/~dholten/extravis/index.htm I haven't tried it myself, though. (The available program seems to be a windows binary, but perhaps one could ask the author) /Tomas From bjt Fri Feb 22 01:29:22 2008 From: bjt (Benjamin Tolputt) Date: Fri, 22 Feb 2008 11:29:22 +1100 Subject: [erlang-questions] Practical Erlang Programming In-Reply-To: <47BE0C1D.8060004@pmp.com.au> References: <23537.61381.qm@web31507.mail.mud.yahoo.com> <47BDF227.80102@erlang-consulting.com> <47BE0C1D.8060004@pmp.com.au> Message-ID: <47BE1762.2040308@pmp.com.au> Benjamin Tolputt wrote: > Erlang currently already has a good book on the syntax/semantics - > Joe's Programming Erlang. I don't need another one of those on my shelf. I should note that the above has nothing to do with what I think upcoming book will be in terms of quality. It may be much better than Joe's (though I can't tell that until it comes out). It's just that, no matter how good it is, with Joe's book already out there - it's not going to be a must read for me. Sorry, I realised the quoted comment could be taken the wrong way when I read it coming back in to the inbox from the mailing list. Regards, B.J.Tolputt From gbulmer Fri Feb 22 01:33:48 2008 From: gbulmer (G Bulmer) Date: Fri, 22 Feb 2008 00:33:48 +0000 Subject: [erlang-questions] link: Asterisk PBX on an FPGA Message-ID: <505CCDB4-7593-4BD8-B3D0-2B41900C4665@gmail.com> I stumbled across a few interesting telecoms Open Hardware projects. Many of you chaps know far more than I ever will about telecoms, so I thought you may be interested if you've not seen these before. An Australian chap has designed and built a small office PBX using Analog Devices Blackfin processor. Blackfin is interesting because it runs Linux (uCLinux) and also has has +1 G-op DSP hardware on a chip that costs less than $20 in quantity. He has also designed and built the analogue phone line FSX/FSO interfaces too: http://www.rowetel.com/ucasterisk/ip04.html It has 4 analogue POTS interfaces, and supports VoIP with a 10/100 ethernet interface. He reckons it runs on less than 5W of power. He is working on an 8 FSX/FSO and dual ethernet board for 2008Q2. This could hurt the low-end PBX vendors. The hardware design is Open, including eCAD and PCB layouts, so anyone can do it all yourself, and even modify it. He uses the blackfin DSP to run the whole system: Linux, Asterisk, and his line echo cancelation code. He is interested in providing low-cost telecoms infrastructure into developing countries, and this takes so little power it could be solar powered. Amazingly, the board is just an ordinary double sided PCB, so it is within the capabilities of small organisations to make for themselves. Just as impressive is this FPGA-only board running uCLinux + Asterisk: http://www.rowetel.com/blog/?p=40 The FPGA used has a 300MHz Power PC core, and hence runs uCLinux and Asterisk; the FPGA is also used to accelerate some of the processes like FIR filters for echo cancelation. They say the FPGA is about $12 in quantity, so it could be a pretty cheap PBX. He reports: "... you could include an E1 framer on the FPGA and possibly even the DSP side of analog interfaces ...", " ... also working on hardware-acceleration for codecs like G729... ", "... they are digging into the key issues of Asterisk (like the drawbacks of it?s threaded design and bottlenecks like echo cancellation) ...", and " The Bill of Materials BOM can also be reduced by absorbing system functions into the FPGA." It might be interesting having Erlang on this kind of stuff. I'd rather use Erlang than tussle with Asterisk for my telecom infrastructure:-) I imagine a pretty lean Linux would be enough to support an 'embedded' Erlang. This type of hardware may revolutionise telecoms in small, relatively poor countries. Maybe long range WiFi (or cheap wimax) may be adequate to hook it together :-) http://www.engadget.com/2007/06/19/venezuelans-set-new-wifi-distance- record-237-miles/ Maybe someone at Ericsson might be interested in helping these efforts as a long term investment in developing countries? I found it fascinating, so I hope I didn't waste your time. G Bulmer From daveb Fri Feb 22 01:41:03 2008 From: daveb (Dave Bryson) Date: Thu, 21 Feb 2008 18:41:03 -0600 Subject: [erlang-questions] Practical Erlang Programming In-Reply-To: <47BE0C1D.8060004@pmp.com.au> References: <23537.61381.qm@web31507.mail.mud.yahoo.com> <47BDF227.80102@erlang-consulting.com> <47BE0C1D.8060004@pmp.com.au> Message-ID: <17C9D1AD-FE18-4B17-BC8E-997178291555@miceda.org> On Feb 21, 2008, at 5:41 PM, Benjamin Tolputt wrote: > I don't need another one of those on my shelf. > What I need is a book that shows me how to get the most out of the > Erlang library building blocks - namely OTP. I agree. This is exactly the kind of book I'm looking for - one that goes deeper into OTP, and Concurrent programming. With the material available on the Erlang site and the definitive guide from Joe Armstrong I don't need another basic book. Dave > From raould Fri Feb 22 02:40:09 2008 From: raould (Raoul Duke) Date: Thu, 21 Feb 2008 17:40:09 -0800 Subject: [erlang-questions] deadlock (etc.) checking/avoidance? Message-ID: <91a2ba3e0802211740l51bd7521x928551d9adb65087@mail.gmail.com> hi, I've seen various things (Carlsson's paper, mention of Ostrovsk?'s paper) but don't know of / are there any really production-ready tools or approaches for dealing with concurrency bugs like deadlock in Erlang? Or is there (not meant to be a slur) just some common un-theoretic approach where when a heartbeat fails things just get restarted and we assume it won't re-deadlock for ever? thanks. From vlm Fri Feb 22 03:19:35 2008 From: vlm (Lev Walkin) Date: Thu, 21 Feb 2008 18:19:35 -0800 Subject: [erlang-questions] deadlock (etc.) checking/avoidance? In-Reply-To: <91a2ba3e0802211740l51bd7521x928551d9adb65087@mail.gmail.com> References: <91a2ba3e0802211740l51bd7521x928551d9adb65087@mail.gmail.com> Message-ID: <47BE3137.4030205@lionet.info> Raoul Duke wrote: > hi, > > I've seen various things (Carlsson's paper, mention of Ostrovsk?'s > paper) but don't know of / are there any really production-ready tools > or approaches for dealing with concurrency bugs like deadlock in > Erlang? Or is there (not meant to be a slur) just some common > un-theoretic approach where when a heartbeat fails things just get > restarted and we assume it won't re-deadlock for ever? In my experience, I have found that always having a timeout (either implicitly via gen_server:call(), where we have 5s default timeout, or explicitly with receive after X) and the linked processes helps tremendously with catching and debugging the concurrency problems. You just have to catch such errors and log them appropriately to make sure you know about them eventually, even post factum. Certainly, a supervision tree must be built while assuming that the underlying processes _will_ fail, eventually, but not making a big deal out of it. Plus, some things like forwarding a setter/transaction function instead of locking/modifying/unlocking the state in a separate process help as well. -- Lev Walkin vlm From daveb Fri Feb 22 05:44:00 2008 From: daveb (Dave Bryson) Date: Thu, 21 Feb 2008 22:44:00 -0600 Subject: [erlang-questions] Adding a non-OTP module to a supervisor Message-ID: <3D5D9888-4F8A-4887-9FE7-485229545021@miceda.org> Is it possible to add a non-OTP module to the supervior strategy? I have a module that doesn't use an OTP behavior (not gen_server,gen_event, etc...). The module registers a couple of processes for handling receive... after...timeout events. Can this module be added as callback module to the supervisor strategy and be treated as a worker? Thanks! Dave From pfisher Fri Feb 22 06:22:15 2008 From: pfisher (Paul Fisher) Date: Thu, 21 Feb 2008 23:22:15 -0600 Subject: [erlang-questions] Adding a non-OTP module to a supervisor In-Reply-To: <3D5D9888-4F8A-4887-9FE7-485229545021@miceda.org> References: <3D5D9888-4F8A-4887-9FE7-485229545021@miceda.org> Message-ID: <1203657736.5958.9.camel@pfisher-laptop> On Thu, 2008-02-21 at 22:44 -0600, Dave Bryson wrote: > Is it possible to add a non-OTP module to the supervior strategy? > > I have a module that doesn't use an OTP behavior (not > gen_server,gen_event, etc...). The module registers a couple of > processes for handling receive... after...timeout events. Can this > module be added as callback module to the supervisor strategy and be > treated as a worker? All that is required is that the {M, F, A} provided to the supervisor in the child specification returns {ok, pid()} when invoked. Just create a module that implements the supervisor behavior and return a child spec, which starts you module. -- paul From andreas.hillqvist Fri Feb 22 08:28:39 2008 From: andreas.hillqvist (Andreas Hillqvist) Date: Fri, 22 Feb 2008 08:28:39 +0100 Subject: [erlang-questions] Adding a non-OTP module to a supervisor In-Reply-To: <3D5D9888-4F8A-4887-9FE7-485229545021@miceda.org> References: <3D5D9888-4F8A-4887-9FE7-485229545021@miceda.org> Message-ID: <8268eea30802212328g3ca9fa40p61e75058a014a815@mail.gmail.com> Look at the supervisor_bridge (http://www.erlang.org/doc/man/supervisor_bridge.html) I belive it is what you want Regards Andreas Hillqvist 2008/2/22, Dave Bryson : > Is it possible to add a non-OTP module to the supervior strategy? > > I have a module that doesn't use an OTP behavior (not > gen_server,gen_event, etc...). The module registers a couple of > processes for handling receive... after...timeout events. Can this > module be added as callback module to the supervisor strategy and be > treated as a worker? > > Thanks! > Dave > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > From adam Fri Feb 22 09:00:36 2008 From: adam (Adam Lindberg) Date: Fri, 22 Feb 2008 09:00:36 +0100 Subject: [erlang-questions] Beyond Strings as Lists In-Reply-To: References: Message-ID: <6344005f0802220000v1c07453dhbcebe14f15e13d51@mail.gmail.com> Yes, the website really needs a face lift. Just compare it to that of Python: http://python.org/ I think that the Erlang Extension Proposal (EEP) initiative can take Erlang a long way just by enabling people from the outside (and that actually means people outside Ericsson) can take a shot at improving or changing the language. That process should be encourage and the community should be empowered to create, discuss and make these EEPs happen. Much of this I think is in how Erlang and the EEP process is presented. And that happens through the website. Right now the website is very static. There's no feeling of community there, you can only consume. Not produce. (And it also has a very very 90's look ^_^ ). There is TrapExit, but that feels more like a secondary source. Not secondary in quality or quantity, but not the place to go if you want the _official_ view on the language and not if you want to help develop or change the language itself. It's great for user-to-user support though. The Erlang website needs to be integrated properly with the community, like a list of user groups, conferences, the mailing lists, links to the TrapExit wiki etc. All in one place. The first few days of learning the language you should not have to leave the website, even for Google. Just my 2 cents, Adam 2008/2/21 Colin Z : > This entire discussion brings up a larger issue to me. As a newbie to the > community, looking objectively at it from the outside, I think Erlang has > come to a crossroads of sorts. It's on the verge of realizing a vast > potential. Choices that are made now are going to affect whether it ends up > on a path to fame or obscurity. > > It's the only language out there that really offers the feature set > necessary to easily take full advantage of the emerging > multi-core/multi-CPU/distributed setups that are soon going to be the norm > for hardware environments. > > By virtue of being a functional language, it's never going to be adopted > as a "code monkey" language like C# or Java. Typical enterprise-level > outfits aren't ever going to have their rank and file developers using > Erlang. I believe Erlang's niche will expand into a middle-ware platform > that is used to abstract away the details of traditional multi-threaded and > distributed architectures. It will be the mid and high level developers and > architects, or 3rd party developers, who engineer this. Code monkeys will > continue to do their work in imperative and OO languages that plug into the > Erlang-based middle-ware. So, in this respect, demand for competent Erlang > programmers will remain high, as well as the salaries they can command. > > What's going to make or break this deal is polish and marketing. Annoying > terms to be sure. As a lone, individual programmer, I love Erlang. Imagining > it from a product manager's perspective, though, I would never choose it in > its current state. Most enterprise-level managers won't take a language > seriously and adopt it for their project if you tell them the standard dev > tool is Emacs or an Eclipse plugin maintained by a couple people. > > The official documentation available for Erlang/OTP right now is only just > adequate and painful to slog through and decipher. Compare it to Sun's or > Microsoft's or even PHP's web documentation, though, and it appears lacking > and less clean. The community is slowly growing, but good tutorials are > still few and far between, are usually full of grammatical errors, and are > usually very difficult to locate via Google searches. > > It seems to me that all the pieces are there. Erlang has support for all > the little things that make or break a platform (unit testing comes to > mind). What it lacks most right now is integration of all those pieces into > a unified, standardized, and understandable whole. Managers and developers > like to feel secure and looked out for. They like to feel as if there's > competent, powerful support out there for the language they've chosen and > that it has strong, directed leadership guiding it towards a definite > vision. This convinces them that it's not just a fly-by-night fad and that > they won't be left hanging out to dry. > > Joe does a great job of generating enthusiasm about what Erlang has to > offer technically. What Erlang has right now though is an image crisis. It > has no marketing or polish or pizazz behind it. It lacks an efficient, > organized committee-based senior community. It lacks tools with support for > the things Erlang does best. (Is there any reason why Erlang tools can't or > don't support something like Intellisense for the patterns a function or > receive block is able to match; or the possible patterns returned from a > function?) > > Is there any reason why no one has asked for an interview with Charles > Ying about his team's experiences? You've got AMAZON using Erlang. That's a > big deal. How about the guys over at Vendetta Online? You've got the entire > video game industry (*cough*Blizzard*cough*) waiting to be sold on the > virtues of Erlang. What about the YAWS people? You need to all be scratching > each others' backs here. If all you get out of Amazon running simpleDB on > Erlang is a blog post by Ying stating the fact and suggesting you read Joe's > book, you're missing out on a lot of hype. > > This string as lists debate is a perfect example and is much needed. Any > modern language that doesn't have powerful, unified, built-in support for > something as simple as a string will be laughed out of the industry. Does > Erlang have an official User Experience team looking at this stuff? A > "higher authority" that sets standards that both minuscule and massive > things like method naming conventions, APIs, or new features must pass > through before being adopted? > > Is anyone working to update the Erlang website to give it a more modern > face lift? Hell, 50% of why Ruby and RoR got popular was because they had > some glossy buttons and gradients on their page. > > Please understand that these criticisms are coming from a total Erlang > newbie that really does enjoy and care about the language. Most of the > questions are rhetorical. They are just things I'm throwing out, as a > newbie, that other average newbies will be considering and asking about when > they themselves look into Erlang. I hope you understand how important little > things like this are to the further success of the language. I really want > to see Erlang realize its full potential. > > -Colin > > > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080222/e875eb53/attachment-0001.html From jan Fri Feb 22 11:02:03 2008 From: jan (Jan Henry Nystrom) Date: Fri, 22 Feb 2008 11:02:03 +0100 Subject: [erlang-questions] Practical Erlang Programming In-Reply-To: <17C9D1AD-FE18-4B17-BC8E-997178291555@miceda.org> References: <23537.61381.qm@web31507.mail.mud.yahoo.com> <47BDF227.80102@erlang-consulting.com> <47BE0C1D.8060004@pmp.com.au> <17C9D1AD-FE18-4B17-BC8E-997178291555@miceda.org> Message-ID: <47BE9D9B.8010801@erlang-consulting.com> Dave Bryson wrote: > On Feb 21, 2008, at 5:41 PM, Benjamin Tolputt wrote: >> I don't need another one of those on my shelf. >> What I need is a book that shows me how to get the most out of the >> Erlang library building blocks - namely OTP. > > I agree. This is exactly the kind of book I'm looking for - one that > goes deeper into OTP, and Concurrent programming. > > With the material available on the Erlang site and the definitive > guide from Joe Armstrong I don't need another basic book. We have to take on thing at the time. If we were to cater to everyones demands in this one book it would be too heavy to get of the bookshelf, let alone read comfortably. We are very aware of the different needs for books, but we believe that this one is needed and that it will help to pave the way for a OTP-book, and more others to follow. /Cheers Henry (co-author of Practical Erlang Programming) > > Dave > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions -- Jan Henry Nystrom Training Manager @ Erlang Training and Consulting Ltd http://www.erlang-consulting.com From thomasl_erlang Fri Feb 22 10:43:29 2008 From: thomasl_erlang (Thomas Lindgren) Date: Fri, 22 Feb 2008 01:43:29 -0800 (PST) Subject: [erlang-questions] Practical Erlang Programming In-Reply-To: Message-ID: <666266.47210.qm@web38805.mail.mud.yahoo.com> --- Brian Cully wrote: > Unfortunately, what I would really like is > something akin to an OTP > Illustrated. OTP is by far the hardest thing I have > to wrap my head > around. Proper use of supervisor tree, best > practices on function > placement, common idioms, etc.,. Isn't Joel Reymont writing a book on more advanced topics? That might be what you're looking for, once it turns up. I guess the choice of audience is because O'Reilly (ironically enough, given that they turned down Joe's previous book proposal) want/need to sell to Erlang beginners, rather than to those who level up from Joe's PragProg book. Best, Thomas ____________________________________________________________________________________ Never miss a thing. Make Yahoo your home page. http://www.yahoo.com/r/hs From francesco Fri Feb 22 12:14:46 2008 From: francesco (Francesco Cesarini) Date: Fri, 22 Feb 2008 11:14:46 +0000 Subject: [erlang-questions] Practical Erlang Programming In-Reply-To: <17C9D1AD-FE18-4B17-BC8E-997178291555@miceda.org> References: <23537.61381.qm@web31507.mail.mud.yahoo.com> <47BDF227.80102@erlang-consulting.com> <47BE0C1D.8060004@pmp.com.au> <17C9D1AD-FE18-4B17-BC8E-997178291555@miceda.org> Message-ID: <47BEAEA6.4090603@erlang-consulting.com> Hi All, in line with the comments, which are much appreciated, these are my thoughts. When I walk into a book store, I do not want to see one or two Erlang books, I want to see a whole section dedicated to them. Many books on basic Erlang, Industrial SW design, Mnesia, OTP, drivers, Concurrent Programming, Erlang web applications, Erlang and IM, handbooks, cookbooks, and more. We are not aiming at a book which is of better quality than Joe's, nor as a book to replace Joe's. That comment stood out, and I hope I am taking it out of context. Those who have met Joe will know his book is a reflection of his character and enthusiasm. We see ours as a complement for those who want to read more about Erlang in depth. We are very interested in writing a book on OTP. We have the material and the examples which we know work. But we want to do it in the right order by first writing a book on Erlang. As none of us has ever written a book, starting with Erlang makes sense. From there, we will be better prepared to tackle OTP. As everyone says, OTP is much harder to learn than Erlang. I can add that the same applies to teaching and explaining it. I am sure this can be extended to writing about it. Our hope is not to preach to the converted and sell books to everyone who already is on this mailing list. We are instead hoping on giving a helping hand in doubling the users on this list, thus creating a larger market for an OTP book. This will hopefully result in a proposal O'Reilly deems as interesting, for which there is not only a need for, but also a market. We will certainly be referencing these emails when we submit it. In the meantime, I encourage others to start writing even more books on the subject, including OTP. From what I know, there are quite a few in the pipeline, but not enough to motivate a whole section at Barnes & Noble or Waterstone's. As mentioned previously if you have any feedback on what you might want to see in a basic Erlang book, we are very interested in hearing it. Regards, Francesco -- http://www.erlang-consulting.com From tumanian Fri Feb 22 12:32:47 2008 From: tumanian (Gurgen Tumanian) Date: Fri, 22 Feb 2008 15:32:47 +0400 Subject: [erlang-questions] Trouble with accepting SSL on slow connections Message-ID: <85d11a2e0802220332t6a17cc25l72b67a5501ac83cc@mail.gmail.com> Dear All. I am having trouble with accepting SSl connections on slow links in case of delays over 2000ms. ssl:ssl_accept fails with {error, esslconnect}. I tried runnig ssl_esock with debug output on, and i have found out that the reason of esslaccept is the EAGAIN error reported by underlying OS(FreeBSD ) when the ssl module tries to receive the client sertificate. The debug output is this: ==========LOOP=============^M MASKS SET FOR FD: 11 (read) 9 (read) 8 (read) 10 (read) 5 (read) ^M CONNECTIONS:^M - SSL_ACCEPT [0x8138d80] (fd = 11)^M - JOINED [0x812f900] (origin = accept)^M (fd = 8, eof = 0, wq = 0, bp = 0)^M (proxyfd = 9, eof = 0, wq = 0, bp = 0)^M - JOINED [0x80fb300] (origin = accept)^M (fd = 7, eof = 1, wq = 0, bp = 0)^M (proxyfd = 10, eof = 0, wq = 0, bp = 1)^M - PASSIVE_LISTENING [0x80e7b80] (fd = 6)^M - ACTIVE_LISTENING [0x80e7700] (fd = 5, acceptors = 8)^M Before poll/select: 6 descriptors (total 11)^M -----------------------------------^M SSL_ACCEPT fd = 11^M esock_ssl_accept: calling SSL_accept fd = 11^M state before: UNKWN ^M info: before/accept initialization^M info: SSLv3 read client hello A^M info: SSLv3 write server hello A^M info: SSLv3 write certificate A^M info: SSLv3 write certificate request A^M info: SSLv3 flush data^M info: error in SSLv3 read client certificate A^M info: error in SSLv3 read client certificate A^M sock_errno 35 errno 35 ^M SSL_accept = -1^M ssl_error: SSL_ERROR_WANT_READ^M state after: 3RCC_A^M ret -1 os error Resource temporarily unavailable^M ==========LOOP=============^M As far as i understand the SSL_accept(that handles the accept in ssl_esock) function should have tried continuously on receiveing client certificate if the OS reported EAGAIN. However it does not,and i am really clueless about any workarounds or changes that would solve this problem. Any help would be appreciated. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080222/4124b2a7/attachment.html From martin Fri Feb 22 13:31:26 2008 From: martin (Martin Carlson) Date: Fri, 22 Feb 2008 12:31:26 +0000 Subject: [erlang-questions] Rare emulator crash Message-ID: <47BEC09E.9050100@erlang-consulting.com> Hi all, We are running a set of nodes in a distributed environment running R11B and OpenSuSe 10.2. We have recently observed an emulator crash which leaves no erl_crash.dump nor any core. However it is terminated with the following message: *** glibc detected *** /home/erix/erts-5.5.3/bin/beam.smp: double free or corruption (out): 0xb45018b8 *** ======= Backtrace: ========= /lib/libc.so.6[0xb7dce6e1] /lib/libc.so.6(cfree+0x89)[0xb7dcfd79] /home/erix/erts-5.5.3/bin/beam.smp(driver_free+0x21)[0x80b14a1] /home/erix/erts-5.5.3/bin/beam.smp[0x80b7db9] ======= Memory map: ======== 08048000-0817e000 r-xp 00000000 08:07 5543376 /home/erix/erts-5.5.3/bin/beam.smp 0817e000-0817f000 r-xp 00135000 08:07 5543376 /home/erix/erts-5.5.3/bin/beam.smp 0817f000-081a7000 rwxp 00136000 08:07 5543376 /home/erix/erts-5.5.3/bin/beam.smp 081a7000-081f9000 rwxp 081a7000 00:00 0 [heap] b3a16000-b3e4b000 rwxp b3a16000 00:00 0 b3ecb000-b40cc000 rwxp b3ecb000 00:00 0 b41cc000-b42e7000 r-xp 00000000 08:06 2354496 /usr/lib/libcrypto.so.0.9.8 b42e7000-b42ed000 r-xp 0011b000 08:06 2354496 /usr/lib/libcrypto.so.0.9.8 b42ed000-b42fc000 rwxp 00121000 08:06 2354496 /usr/lib/libcrypto.so.0.9.8 b42fc000-b4508000 rwxp b42fc000 00:00 0 b4508000-b4600000 ---p b4508000 00:00 0 b46ae000-b46b8000 r-xp 00000000 08:06 870104 /lib/libgcc_s.so.1 b46b8000-b46ba000 rwxp 00009000 08:06 870104 /lib/libgcc_s.so.1 b46ba000-b46cb000 r-xp 00000000 08:06 870117 /lib/libz.so.1.2.3 b46cb000-b46cd000 rwxp 00010000 08:06 870117 /lib/libz.so.1.2.3 b46d7000-b46de000 r-xs 00000000 08:06 2380765 /usr/lib/gconv/gconv-modules.cache b46de000-b4719000 r-xp 00000000 08:06 2397784 /usr/lib/locale/en_US.utf8/LC_CTYPE b4719000-b4a1c000 rwxp b4719000 00:00 0 b4a1c000-b4a1d000 ---p b4a1c000 00:00 0 b4a1d000-b521d000 rwxp b4a1d000 00:00 0 b521d000-b521e000 ---p b521d000 00:00 0 b521e000-b5a1e000 rwxp b521e000 00:00 0 b5a1e000-b5a1f000 ---p b5a1e000 00:00 0 b5a1f000-b621f000 rwxp b5a1f000 00:00 0 b621f000-b6220000 ---p b621f000 00:00 0 b6220000-b6a20000 rwxp b6220000 00:00 0 b6a20000-b6a21000 ---p b6a20000 00:00 0 b6a21000-b7221000 rwxp b6a21000 00:00 0 b7221000-b7222000 ---p b7221000 00:00 0 b7222000-b7d6a000 rwxp b7222000 00:00 0 b7d6a000-b7e92000 r-xp 00000000 08:06 870060 /lib/libc-2.5.so b7e92000-b7e93000 r-xp 00128000 08:06 870060 /lib/libc-2.5.so b7e93000-b7e95000 rwxp 00129000 08:06 870060 /lib/libc-2.5.so b7e95000-b7e98000 rwxp b7e95000 00:00 0 b7e98000-b7e9f000 r-xp 00000000 08:06 870090 /lib/librt-2.5.so b7e9f000-b7ea1000 rwxp 00006000 08:06 870090 /lib/librt-2.5.so b7ea1000-b7edc000 r-xp 00000000 08:06 870112 /lib/libncurses.so.5.5 b7edc000-b7ee3000 r-xp 0003a000 08:06 870112 /lib/libncurses.so.5.5 b7ee3000-b7ee8000 rwxp 00041000 08:06 870112 /lib/libncurses.so.5.5 b7ee8000-b7ee9000 rwxp b7ee8000 00:00 0 b7ee9000-b7efd000 r-xp 00000000 08:06 870086 /lib/libpthread-2.5.so b7efd000-b7eff000 rwxp 00013000 08:06 870086 /lib/libpthread-2.5.so b7eff000-b7f01000 rwxp b7eff000 00:00 0 b7f01000-b7f25000 r-xp 00000000 08:06 870068 /lib/libm-2.5.so b7f25000-b7f27000 rwxp 00023000 08:06 870068 /lib/libm-2.5.so b7f27000-b7f29000 r-xp 00000000 08:06 870066 /lib/libdl-2.5.so b7f29000-b7f2b000 rwxp 00001000 08:06 870066 /lib/libdl-2.5.so b7f2b000-b7f2d000 r-xp 00000000 08:06 870094 /lib/libutil-2.5.so b7f2d000-b7f2f000 rwxp 00001000 08:06 870094 /lib/libutil-2.5.so b7f34000-b7f37000 r-xp 00000000 08:07 5544113 /home/erix/lib/crypto-1.5/priv/lib/crypto_drv.so b7f37000-b7f38000 r-xp 00002000 08:07 5544113 /home/erix/lib/crypto-1.5/priv/lib/crypto_drv.so b7f38000-b7f39000 rwxp 00003000 08:07 5544113 /home/erix/lib/crypto-1.5/priv/lib/crypto_drv.so b7f39000-b7f3a000 rwxp b7f39000 00:00 0 b7f3a000-b7f3b000 r-xp b7f3a000 00:00 0 [vdso] b7f3b000-b7f56000 r-xp 00000000 08:06 870053 /lib/ld-2.5.so b7f56000-b7f58000 rwxp 0001a000 08:06 870053 /lib/ld-2.5.so bf9d7000-bf9ec000 rwxp bf9d7000 00:00 0 [stack] heart: Thu Feb 21 13:18:34 2008: Erlang has closed. And is restarted by heart. The system is fairly heavy on TCP/IP traffic and file IO. The crash manifests itself when network interfaces are shut down on the switches. Which leaves me suspecting the inets driver, unfortunately i have no back trace to narrow down the problem at this point. As shown buy glibc debug printout it seems like free is called on an invalid pointer, Have anybody seen this before while running with standard OTP drivers (crypto), SMP (4 proc), Kernel poll and IO threads? //Martin Carlson Erlang Training & Consulting http://www.erlang-consulting.com From sgolovan Fri Feb 22 14:10:13 2008 From: sgolovan (Sergei Golovan) Date: Fri, 22 Feb 2008 16:10:13 +0300 Subject: [erlang-questions] Internal error in v3_codegen on Linux@Sparc In-Reply-To: <18366.49497.948738.628539@alkaid.it.uu.se> References: <18366.49497.948738.628539@alkaid.it.uu.se> Message-ID: On 2/22/08, Mikael Pettersson wrote: > > I can't reproduce this problem on either a USII running Aurora Linux with > gcc-4.2.3 + kernel 2.6.25-rc2, or a dual USIIIi running Solaris 9 with gcc-4.2.3. Thanks for the info. Debian on USII works just fine, so, the problem is likely in Linux kernel on USIII (or Debian kernel on USIII). I don't think that it's connected with glibc or gcc version because it crashed on glibc2.5-2.7 and gcc 4.1-4.3. > > Thus it may be a generic USIII problem in the Linux kernel, or it may be > a problem with one of the many patches Debian applies to the kernel, the > gcc used to compile the kernel, the regular gcc (which may or may not be > the one used to compiler the kernel), glibc, and finally Erlang/OTP (yes > I noticed you patched Erlang too). It's true, though there's only one sparc-specific patch (it removes some optimization whish caused crashes in the past, when Erlang was supposed to be built on 32-bit Sparcs too). -- Sergei Golovan From mikpe Wed Feb 20 13:31:35 2008 From: mikpe (Mikael Pettersson) Date: Wed, 20 Feb 2008 13:31:35 +0100 Subject: [erlang-questions] failed to enable SMP support in otp_src_R12B-1 In-Reply-To: <20080220103022.GA742@Sun.Com> References: <20080220103022.GA742@Sun.Com> Message-ID: <18364.7591.965193.617900@harpo.it.uu.se> Raymond Xiong writes: > Hello, > > I have a Sun Ultra 40(a dual-core amd64 machine) which runs > Solaris Nevada. I used to run otp_src_R12B-0 on it and had > no problem in enabling SMP support in Erlang emulator(actually > I did nothing for that, it was enabled automatically). > > However, recently I upgrated the machine to Solaris Nevada > latest build, which had some changes in sctp header files > and caused otp_src_R12B-0 failed to compile. So I downloaded > otp_src_R12B-1, configured and compiled it. But this time > I couldn't enable SMP support, even if I configured it > explicitly with SMP support: > > $ CPPFLAGS=-I/usr/include/gd2 ./configure --prefix=/myroot \ > --enable-smp-support --enable-threads > > (I specified CPPFLAGS because libgd header files were placed > under /usr/include/gd2 on Solaris) > > Has anyone encountered the same issue? You need to provide us with details about HOW it failed. A complete log from ./configure and make would be a good start. From mikpe Thu Feb 21 09:56:08 2008 From: mikpe (Mikael Pettersson) Date: Thu, 21 Feb 2008 09:56:08 +0100 Subject: [erlang-questions] failed to enable SMP support in otp_src_R12B-1 In-Reply-To: <20080221071901.GA19236@Sun.Com> References: <20080220103022.GA742@Sun.Com> <18364.7591.965193.617900@harpo.it.uu.se> <20080221071901.GA19236@Sun.Com> Message-ID: <18365.15528.896326.984436@harpo.it.uu.se> Raymond Xiong writes: > On 02/20/08, Mikael Pettersson wrote: > > Raymond Xiong writes: > > > Hello, > > > > > > I have a Sun Ultra 40(a dual-core amd64 machine) which runs > > > Solaris Nevada. I used to run otp_src_R12B-0 on it and had > > > no problem in enabling SMP support in Erlang emulator(actually > > > I did nothing for that, it was enabled automatically). > > > > > > However, recently I upgrated the machine to Solaris Nevada > > > latest build, which had some changes in sctp header files > > > and caused otp_src_R12B-0 failed to compile. So I downloaded > > > otp_src_R12B-1, configured and compiled it. But this time > > > I couldn't enable SMP support, even if I configured it > > > explicitly with SMP support: > > > > > > $ CPPFLAGS=-I/usr/include/gd2 ./configure --prefix=/myroot \ > > > --enable-smp-support --enable-threads > > > > > > (I specified CPPFLAGS because libgd header files were placed > > > under /usr/include/gd2 on Solaris) > > > > > > Has anyone encountered the same issue? > > > > You need to provide us with details about HOW it failed. > > A complete log from ./configure and make would be a good start. > > Mikael, > > I did some more experiments on my machine and found the following > results: > > Scenario 1) > - configure with no "--enable-smp-support" > - no smp support > > Scenario 2) > - confiure with "--enable-smp-support" > - have smp support > > Scenario 3) > - configure with no "--enable-smp-support" > - gmake && gmake install > - re-configure with "--enable-smp-support" > - gmake && gmake install > - still no smp support > > Scenario 4) > - configure with no "--enable-smp-support" > - gmake && gmake install > - gmake clean > - re-configure with "--enable-smp-support" > - gmake && gmake install > - have smp support > > The only difference between scenario 3 and scenario 4 is > the call of "gmake clean" before re-configuration. I didn't > realize it's necessary before(I had thought after > re-configuration every thing will be rebuilt. But it seemed > that's not the case. Is it correct?). A minimum of make clean is definitely needed between config changes. The make system to build Erlang/OTP has always been iffy. > I also have a question on scenario 1 and scenario 2. From > my testing result, "--enable-smp-support" must be specified > explicitly on my machine. But it was said in README that this > feature is detected automaticaly, is it ture? It's autoenabled on supported machines, where supported does not mean "it may work" but means "the OTP team regularly tests on it and they believe it works". From mikpe Fri Feb 22 13:34:33 2008 From: mikpe (Mikael Pettersson) Date: Fri, 22 Feb 2008 13:34:33 +0100 Subject: [erlang-questions] Internal error in v3_codegen on Linux@Sparc In-Reply-To: References: Message-ID: <18366.49497.948738.628539@alkaid.it.uu.se> Sergei Golovan writes: > Hi! > > Building of Erlang/OTP R12B-1 on Debian Linux at Sparc architecture > (Dual-core UltraSPARC III machine) gave the following error: > > erlc -W +debug_info -I/build/buildd/erlang-12.b.1-dfsg/lib/stdlib > +warn_unused_vars -o../ebin asn1rt_ber_bin_v2.erl > Function: encode_tags/2 > ./asn1rt_ber_bin_v2.erl:none: internal error in v3_codegen; > crash reason: {{case_clause, > {'EXIT', > {{case_clause, > {{{l, > {block, > [{l,{match_fail,{badmatch,{var,ker46}}},44,[],[]}]}, > 43, > [{ker46,40,44}], > []}, > {ker46,40,42}}, > {{sr,[{0,cor1},{1,cor0}],[],[]},0}}}, > [{v3_codegen,'-select_extract_tuple/6-anonymous-0-',5}, > {v3_codegen,select_extract_tuple,6}, > {v3_codegen,select_val,5}, > {v3_codegen,'-select_cg/6-anonymous-0-',5}, > {lists,mapfoldl,3}, > {v3_codegen,select_cg,6}, > {v3_codegen,match_cg,5}, > {v3_codegen,match_cg,6}]}}}, > [{compile,'-select_passes/2-anonymous-2-',2}, > {compile,'-internal_comp/4-anonymous-1-',2}, > {compile,fold_comp,3}, > {compile,internal_comp,4}, > {compile,internal,3}]} > > (full build log is available at > http://buildd.debian.org/fetch.cgi?&pkg=erlang&ver=1%3A12.b.1-dfsg-2&arch=sparc&stamp=1203250875&file=log) > > Is this a bug in compiler, or may be the error reflects some deeper > problem (in Erlang VM, or even in Linux kernel)? Building the same > sources several days ago ended up with a segfault during the same > asn1rt_ber_bin_v2.erl compiling). I can't reproduce this problem on either a USII running Aurora Linux with gcc-4.2.3 + kernel 2.6.25-rc2, or a dual USIIIi running Solaris 9 with gcc-4.2.3. Thus it may be a generic USIII problem in the Linux kernel, or it may be a problem with one of the many patches Debian applies to the kernel, the gcc used to compile the kernel, the regular gcc (which may or may not be the one used to compiler the kernel), glibc, and finally Erlang/OTP (yes I noticed you patched Erlang too). From jakob Fri Feb 22 15:33:23 2008 From: jakob (Jakob Cederlund) Date: Fri, 22 Feb 2008 15:33:23 +0100 Subject: [erlang-questions] asn1 and the new ssl module In-Reply-To: <1ffe809c0802201125m2498461fqfc9bdfff801d4431@mail.gmail.com> References: <1ffe809c0802120934r5c580eeas2cb811a7e5c0b170@mail.gmail.com> <47B5ACC9.7010300@erix.ericsson.se> <1ffe809c0802151131s2fd81c16vdb7aebd67fabd51@mail.gmail.com> <47BC2633.20605@erix.ericsson.se> <1ffe809c0802201125m2498461fqfc9bdfff801d4431@mail.gmail.com> Message-ID: <47BEDD33.7090107@erix.ericsson.se> Hmm, I did something wrong here, I should of course skip the tag first. Please try the following change to ssl_connection, or use your own patch. check_asn1(<>) when (Byte band 127) == 127 -> asn1_long_tag(Bin, 1); check_asn1(<>) when Size < 127 -> {Size + 1, 0}; check_asn1(<>) -> {1, 0}; check_asn1(<>) -> {Size+2, 0}; check_asn1(<>) -> {Size+3, 0}; check_asn1(<>) -> {Size+4, 0}; check_asn1(<>) -> {Size+5, 0}. asn1_long_tag(<>, N) when (Byte band 128) == 128 -> asn1_long_tag(Bin, N+1); asn1_long_tag(<<_, Bin/binary>>, N) -> {BytesToRead, _} = check_asn1(Bin), {BytesToRead+N, 0}. /Jakob Pablo Polvorin wrote: > Hi, > thanks for the patch! > perhaps i had been doing something wrong, but i couldn't make your > patch work for my. > Immediately after upgrading a gen_tcp socket to ssl, I get this error > {function_clause, > [{ssl_connection,check_packet,[asn1,<<>>,0].. > > After fixing this adding a new case to check_packet(asn1,..), it still > doesn't work, and returns data that is not an asn1-completed packet. > > Digging in the ber encoding documentation and > asn1rt_ber_bin:decode_tag_and_length/1, each packet seems to looks > like <>, where the size of the Tag field > isn't know, and the size of the PacketLength field could be anything > between 1 and 128 bytes. Are you taking this into account? > > Here is my version of a patch(R12B-1) for this, its based in my > previous code (and so depends on the asn1 application.. witch is > somewhat awkward as the api for decode_tag_and_length/1 doesn't define > what error it would throw when the tag or length field isn't > complete). > > best regards, pablo. > > > > 2008/2/20, Jakob Cederlund : > >> thisIt was very useful, thanks! >> And here is a patch. It simply adds asn1 package support for the new ssl. >> It should work with R12B-1, and probably fine with R12B. >> Hope this helps! >> /Jakob >> >> >> >> Pablo Polvorin wrote: >> Thanks for the clarification! >> >> ...it isn't a patch, .. probably it isn't usefull to you. . >> anyway, this is the code i'm using >> http://ppolv.wordpress.com/2008/02/15/erlang-ssl-and-asn1/ >> >> cheers >> pablo >> >> 2008/2/15, Jakob Cederlund : >> >> >> Nope, not yet. >> Currently, the new ssl (the one you get with {ssl_imp, new}) only >> supports these packet-options: raw, 1, 2, 4, cdr and line. (Packaging is >> handled by the function ssl_connection:check_packet/3.) The rest are >> fairly easy to add, and we hope to do that in the next release. Patches >> are welcome! :-) >> >> /Jakob >> >> >> Pablo Polvorin wrote: >> > Hi all, >> > I'm using the new ssl module to "upgrade" a gen_tcp socket to ssl. But >> > I couldn't find a way to easily receiving asn1 packets from it. >> > My question is, it's possible to use the {packet,asn1} option when >> > using the new ssl module?. >> > >> > ssl_connection.erl seems to not have any reference to that option. >> > >> > Finally I implemented the buffering and packet delimiting code in my >> > application, but I wonder if there is an easy and early way to >> > accomplish the same. >> > regards, >> > >> >> >> >> >> >> >> >> >> From tty.erlang Fri Feb 22 15:53:59 2008 From: tty.erlang (t ty) Date: Fri, 22 Feb 2008 09:53:59 -0500 Subject: [erlang-questions] Practical Erlang Programming In-Reply-To: <666266.47210.qm@web38805.mail.mud.yahoo.com> References: <666266.47210.qm@web38805.mail.mud.yahoo.com> Message-ID: <290b3ba10802220653i22200b98g83a3abd8e41c0155@mail.gmail.com> Unfortunately Joel has decided to drop the project. http://twitter.com/wagerlabs/statuses/659726302 t On Fri, Feb 22, 2008 at 4:43 AM, Thomas Lindgren wrote: > > --- Brian Cully wrote: > > Unfortunately, what I would really like is > > something akin to an OTP > > Illustrated. OTP is by far the hardest thing I have > > to wrap my head > > around. Proper use of supervisor tree, best > > practices on function > > placement, common idioms, etc.,. > > Isn't Joel Reymont writing a book on more advanced > topics? That might be what you're looking for, once it > turns up. > > I guess the choice of audience is because O'Reilly > (ironically enough, given that they turned down Joe's > previous book proposal) want/need to sell to Erlang > beginners, rather than to those who level up from > Joe's PragProg book. > > Best, > Thomas > > > > > ____________________________________________________________________________________ > Never miss a thing. Make Yahoo your home page. > http://www.yahoo.com/r/hs > > > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > From james.hague Fri Feb 22 16:06:56 2008 From: james.hague (James Hague) Date: Fri, 22 Feb 2008 09:06:56 -0600 Subject: [erlang-questions] Erlang image improvements (was: Re: Beyond Strings as Lists) Message-ID: > Right now the website is very static. There's no feeling of community there, > you can only consume. Not produce. (And it also has a very very 90's look > ^_^ ). I completely disagree about the 90s. look. It works. It's not painful to look at. The Python site is no better, visually. But this is irrelevant anyway. >From my point of view: 1. The docs *are* ugly. They're bulky. The high-level categorization of topics makes no sense to me. Too much nesting. The erts/stdlib distinction is artificial (I frequently look at both to figure out where the module I want is). 2. The EEP concept is great, but can we remove the dependency on the Python formatting tools? I spent 20 minutes one day trying to get those tools to work under Windows and failed. A cleaner, simpler alternative in Erlang makes sense. I would have submitted 3-4 EEPs by now. This might be a fun project! 3. The libraries have accumulated much cruft and could use a housecleaning pass. lists:reverse/1 should be auto-imported by default so there's no need for "lists" header. "sets" and "ord_sets" and "gb_sets" (and the equivalent dict versions) are still a muddle. Simple helper functions would make some modules easier to use. ets:new_set() could hide the quirkiness of ets:new, for example. From chsu79 Fri Feb 22 16:14:58 2008 From: chsu79 (Christian S) Date: Fri, 22 Feb 2008 16:14:58 +0100 Subject: [erlang-questions] Erlang image improvements (was: Re: Beyond Strings as Lists) In-Reply-To: References: Message-ID: On Fri, Feb 22, 2008 at 4:06 PM, James Hague wrote: > > Right now the website is very static. There's no feeling of community there, > > you can only consume. Not produce. (And it also has a very very 90's look > > ^_^ ). > > I completely disagree about the 90s. look. It works. It's not > painful to look at. The Python site is no better, visually. But this > is irrelevant anyway. I like how this thread reminds me of "bikeshedding". So like, what colors should the new frontpage be? From masterofquestions Fri Feb 22 18:26:38 2008 From: masterofquestions (db) Date: Fri, 22 Feb 2008 12:26:38 -0500 Subject: [erlang-questions] loop over ets table in serialized manner with gen_fsm Message-ID: <1218d6a50802220926h30ccc208v73ab2ef5c2253b85@mail.gmail.com> What I need is to loop over ets table in serialized fashion. I am thinking of using ets table with gen_fsm to work together. gen_fsm will have 3 state: first, next, last. This way I can serialize the access to ets table and ets record navigation is looped over. When an an event happens(method 1), I need to get ets record and send it back to the requester. or requester will send a message(method2), in which case, gen_fsm should get ets record and send it back to the requester. does gen_fms allow you to send message(ets record) back to the requester. Any alternatives I can look into? -- rk That which we persist in doing becomes easier for us to do; not that the nature of the thing itself is changed, but that our power to do is increased. - Ralph Waldo Emerson -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080222/4c8e5cef/attachment.html From fess-erlang Fri Feb 22 19:56:37 2008 From: fess-erlang (fess) Date: Fri, 22 Feb 2008 10:56:37 -0800 Subject: [erlang-questions] Practical Erlang Programming In-Reply-To: <47BE1762.2040308@pmp.com.au> References: <23537.61381.qm@web31507.mail.mud.yahoo.com> <47BDF227.80102@erlang-consulting.com> <47BE0C1D.8060004@pmp.com.au> <47BE1762.2040308@pmp.com.au> Message-ID: From: http://dukesoferl.blogspot.com/ [ http:// dukesoferl.blogspot.com/2008/02/so-guys-erlang-consulting-and- training.html ] > I applaud Francesco, and Jan-Henry in getting another book out there. > Obviously they have learned from their history areas where new > comers to > erlang have troubles, and they're making a book to plug that hole. > They are of course asking you to look back on your experience > coming into erlang, think about what concepts you had troubles with > and let them know Here are some dumb hicups I encountered on my way into erlang: How to debug. Somehow I glossed over in joes book the bit pointing out that [ $m,$a,$t,$c,$h | Tail ] is the same as [ "match" | Tail ] which is so much nicer. Why are people always reversing lists, and why don't they just append with, List ++ [Item] Why io:lists are cool, why deep lists are cool, flatten later. Uh, ways of handling strings, since the one "way" is so debatable. how to debug the oh so clear error messages that come back from things. the earlier you get what "bad match" vs function clause is, the better, as well as the other standard tuples that once you learn to read you forget how horribly frustrating they were to begin with so you forget to teach the newbs about it. the concepts of failing and relying on those oh so clear error messages, how best to clear those error messages up. the concepts of failing early and restarting, [ which you don't want to do until you get used to knowing where something broke reading those error tuples. ] How incredibly useful guards are, [ and use dialyzer ] handy guard tricks to make your guards better. -define(is_string(String), begin is_list(String), is_integer(hd (String)) end ) -define(is_deeplist(List), begin is_list(List), is_list(hd(List)) end ) what's the deal with andalso orelse vs commas and semicolons. I hope those help, those are at least some newbie topics which I can remember having little moments of realization about. And of course shortly after all that newbie stuff, I want more in depth info on OTP, we did a lot of digging into code to figure out what was going on with code_change, and even then who knows if our concepts are correct, So I agree with the angst that anyone doing a next book, please do that. even a next wiki page, more more more. thanks. --fess From kostis Fri Feb 22 21:02:29 2008 From: kostis (Kostis Sagonas) Date: Fri, 22 Feb 2008 22:02:29 +0200 Subject: [erlang-questions] Practical Erlang Programming In-Reply-To: References: <23537.61381.qm@web31507.mail.mud.yahoo.com> <47BDF227.80102@erlang-consulting.com> <47BE0C1D.8060004@pmp.com.au> <47BE1762.2040308@pmp.com.au> Message-ID: <47BF2A55.1080204@cs.ntua.gr> fess wrote: > > Here are some dumb hicups I encountered on my way into erlang: > > Somehow I glossed over in joes book the bit pointing out > that [ $m,$a,$t,$c,$h | Tail ] is the same as [ "match" | Tail ] > which is so much nicer. It's actually good that you missed this in Joe's book because it is not the same... Instead, [ $m,$a,$t,$c,$h | Tail ] is the same as "match" ++ Tail This is exactly the problem in people getting so much used in IO lists: they end up thinking that flattened vs. unflattened lists are the same. They are not. Cheers, Kostis From fess-erlang Fri Feb 22 21:20:26 2008 From: fess-erlang (fess) Date: Fri, 22 Feb 2008 12:20:26 -0800 Subject: [erlang-questions] Practical Erlang Programming In-Reply-To: <47BF2A55.1080204@cs.ntua.gr> References: <23537.61381.qm@web31507.mail.mud.yahoo.com> <47BDF227.80102@erlang-consulting.com> <47BE0C1D.8060004@pmp.com.au> <47BE1762.2040308@pmp.com.au> <47BF2A55.1080204@cs.ntua.gr> Message-ID: <16958CDC-1731-466D-9F6B-56048620B940@fess.org> On Feb 22, 2008, at 12:02 PM, Kostis Sagonas wrote: > fess wrote: >> that [ $m,$a,$t,$c,$h | Tail ] is the same as [ "match" | Tail ] >> which is so much nicer. > > It's actually good that you missed this in Joe's book because it is > not the same... > > Instead, [ $m,$a,$t,$c,$h | Tail ] is the same as "match" ++ Tail haha, I can't believe I wrote that that way, thanks for the correction, that's what I meant. Yes, I have made deeplists when I didn't want to. that's another gotcha. --fess From kangas Fri Feb 22 21:22:21 2008 From: kangas (Matt Kangas) Date: Fri, 22 Feb 2008 15:22:21 -0500 Subject: [erlang-questions] Strings as Lists In-Reply-To: <57a21f730802201638h6e451465kf186591baedbc0bf@mail.gmail.com> References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> <9b08084c0802180649k75218a8jf4316379d6767c67@mail.gmail.com> <7ABFCE6D-9BFA-4798-856C-4CEE2D6DA1EF@cs.otago.ac.nz> <57a21f730802201638h6e451465kf186591baedbc0bf@mail.gmail.com> Message-ID: Taj -- thank you for the example of literal-string quoting from Lua! Seems an interesting yet simple approach. Richard -- re: your last post on this subject, which I found quite illuminating as well... A syntax for literal string declarations is, by definition, syntactic sugar. It's not making the core language more expressive. It's for improving the human-machine interface in specific situations. Since usability is really the goal, then your first-and-foremost requirement is to... make it usable in those situations. Syntactic power (nesting multiple syntaxes) is *very nice*, but should be a distinctly secondary goal. As you said, no one quoting character sequence will suffice for _all_ situations. In the case of multi-line strings, approaches we've seen include: 1) Define a framework, have the framework know (and hide) the appropriate terminating char-sequence 2) Let the user define a terminating char sequence. (Perl/PHP/Ruby's answer) 3) Have one terminating multi-line char sequence. (Python's answer) 4) Have one char-sequence, but permit its length to vary to allow nesting, within reason. (Lua's answer) Richard, from your last post: > Literal_String = """ > Here is `'"\$^some literal text with an embedded > but no trailing newline > """, > Another = ""!He said "Foo!" But that was not the end!!"" That example falls into camp (2), user-defined terminating char, yes? I suppose the motivation for (3) or (4) could be, perhaps, a desire to make the string-enclosing syntax consistent, thus making it easier to read unfamiliar code. The reader doesn't have to guess (or look carefully for) what terminating-sequence the author chose. (4) encourages consistency while still permitting nesting. As I said before, I think nesting is a nice, not necessary, property. I presume you won't consider anything a "solution" unless it _is_ nestable. :) Comparing (1) and (2), I believe the programmer who's writing the code is best-positioned to decide what's an appropriate terminating sequence. I think hiding the terminating sequence behind a name ("/ xml", "/latex", "/url") is likely to cause bugs, or at least weird compilation errors. And.. we haven't discussed "raw" strings for regexes. Doh! Joe's original proposal was: > ~n"...." turn off quoting > ~r"...." string is a regexp > ~x"..." string is xml > ~x/FlunkyStuff ... FunkyStuff (string is xml terminated by > FunkyStuff) > ~myExpander/FunkyStuff .... FunckyStuff Richard, which parts of this seem especially troublesome, and which are salvageable? (IMO, seems like a combination of camps (1) and (2) per above...) --Matt On Feb 20, 2008, at 7:38 PM, Taj Khattra wrote: >> Perhaps if we >> say that a literal string begins with n+2 quotation marks and a >> single character >> that is not a letter, digit, space, or tab, and then ends with >> another copy of >> that single character followed by n+2 quotation marks. > > here's an excerpt from http://www.lua.org/manual/5.1/manual.html#2.1 > specifying how literal strings can be defined in Lua: > > Literal strings can also be defined using a long format enclosed by > long brackets. We define an opening long bracket of level n as an > opening square bracket followed by n equal signs followed by another > opening square bracket. So, an opening long bracket of level 0 is > written as [[, an opening long bracket of level 1 is written as [=[, > and so on. A closing long bracket is defined similarly; for instance, > a closing long bracket of level 4 is written as ]====]. A long string > starts with an opening long bracket of any level and ends at the first > closing long bracket of the same level. Literals in this bracketed > form may run for several lines, do not interpret any escape sequences, > and ignore long brackets of any other level. They may contain anything > except a closing bracket of the proper level. > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions -- Matt Kangas kangas ? www.p16blog.com From eider.oliveira Fri Feb 22 22:09:42 2008 From: eider.oliveira (Eider Oliveira) Date: Fri, 22 Feb 2008 18:09:42 -0300 Subject: [erlang-questions] Possible bug in slave:start? Message-ID: <2e53f4ef0802221309u3afdb5e3p479c2404ddf1b6c5@mail.gmail.com> I have a piece of code which runs differently if the remote node is started through slave:start: eider:~/bench> erl +K true -rsh ssh -sname bench -setcookie bench_cookie Erlang (BEAM) emulator version 5.6 [source] [smp:2] [async-threads:0] [hipe] [kernel-poll:true] Eshell V5.6 (abort with ^G) (bench)1> slave:start('igaessi14-b',bench1,lists:concat([" -setcookie ",erlang:get_cookie()])). {ok,'bench1'} (bench)2> mnesia:create_schema([node()|nodes()]). {error,{"Cannot install fallback", {file_error,"/home/eider/bench/Mnesia.bench1/FALLBACK.TMP.BUPTMP", enoent}}} (bench)3> q(). ok The problem is the /home/eider/bench/Mnesia.bench1 directory was created on the first machine (igaessi12-b): eider:~/bench> ls -l Mne* drwxr-xr-x 2 eider implantacao 48 2008-02-22 17:30 Mnesia.bench1 drwxr-xr-x 2 eider implantacao 112 2008-02-22 17:30 Mnesia.bench If erlang is started at the second machine (igaessi14-b) when the previous code run, it works correctly: eider:~/bench> erl +K true -rsh ssh -sname bench -setcookie bench_cookie Erlang (BEAM) emulator version 5.6 [source] [smp:2] [async-threads:0] [hipe] [kernel-poll:true] Eshell V5.6 (abort with ^G) (bench)1> slave:start('igaessi14-b',bench1,lists:concat([" -setcookie ",erlang:get_cookie()])). {error,{already_running,'bench1'}} (bench)2> mnesia:create_schema([node()|nodes()]). ok (bench)3> q(). ok -- Eider Oliveira Site: http://eider.eti.br Blog: http://eider.eti.br/Home/Blog/Blog.html "If I had more time, I'd have written you a shorter letter." Pascal -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080222/bd4f5ffc/attachment.html From dave Sat Feb 23 03:42:30 2008 From: dave (Dave Peticolas) Date: Fri, 22 Feb 2008 18:42:30 -0800 Subject: [erlang-questions] Associating contextual info with monitors In-Reply-To: <8209f740802192313p3b81558dn6136b490c3a2eeb4@mail.gmail.com> References: <20080218025857.GA10836@vailsys.com> <47BBA1F2.7070703@krondo.com> <8209f740802192313p3b81558dn6136b490c3a2eeb4@mail.gmail.com> Message-ID: <47BF8816.3080305@krondo.com> Ulf Wiger wrote: > No, terminate() is always called, if possible. If the server isn't > trapping exits, the server may die without being able to do any > cleanup. Thanks for your answer. Now trapping exits is required for terminate to be called, right? The gen_server docs seem to indicate this. In my testing, it seems like terminate is only called if the gen_server is trapping exits, even if it is a 'normal' shutdown. thanks, dave > BR, > Ulf W > > 2008/2/20, Dave Peticolas : >> Rick Pettit wrote: >>> On Sun, Feb 17, 2008 at 07:52:56PM -0700, Dave Smith wrote: >>>> Greetings, >>>> >>>> On several occasions, I've found myself wanting to be able to do some >>>> cleanup (e.g. remove an entry in ets) when a process dies. Usually I >>>> solve this by maintaining an ets table keyed by pid, that stores the >>>> necessary contextual info needed for cleanup, and then setup a monitor >>>> on the pid of interest. This works ok, but it's a little annoying to >>>> need to maintain yet another ets table for this context info that is >>>> only used when the process dies. It seems like what I _really_ want is >>>> a way to associate a term with a monitor -- that way when I get the >>>> DOWN message, I would also get the associated term and have everything >>>> I need to do the cleanup. >>>> >>>> Is there a "Right Way" to accomplish this? Maintaining ets tables for >>>> this sort of contextual info seems a bit overkill -- is there a >>>> simpler approach? Has anyone else ever encountered this sort of issue? >>>> I tried searching through the archives for this problem, but couldn't >>>> find the right set of search terms. :) >>> The way I typically solve this problem is by putting the cleanup code in >>> a gen_server:terminate/2 callback (this way when the gen_server dies it >>> cleans up after itself). >> Now I thought that terminate/2 is only called when a gen_server requests >> a stop from a callback function (by returning {stop, ...}), but not when >> it dies from, say, an exception. Is that not right? >> >> >>> For instances where the processes being spawned aren't gen_* servers, I >> would >>> most likely spawn a wrapper process which in turn spawn_links the real >> child >>> process, then blocks forever waiting to receive the EXIT for that process >> (the >>> cleanup code is triggered upon receipt of the EXIT, then the wrapper >> process >>> itself terminates). >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > From joelr1 Sat Feb 23 11:58:00 2008 From: joelr1 (Joel Reymont) Date: Sat, 23 Feb 2008 10:58:00 +0000 (UTC) Subject: [erlang-questions] Practical Erlang Programming References: <666266.47210.qm@web38805.mail.mud.yahoo.com> <290b3ba10802220653i22200b98g83a3abd8e41c0155@mail.gmail.com> Message-ID: t ty gmail.com> writes: > > Unfortunately Joel has decided to drop the project. > > http://twitter.com/wagerlabs/statuses/659726302 I want to point out that did not drop the project. I dropped the book but I'm posting the "book" to my blog. Take a look at the Introduction to the Erlang FFI and Parsing Binaries with Erlang, for example. Posting hardcore stuff to the blog allows me much more freedom and the revenue from consulting projects that come as a result far outweighs any possible book revenues. Thanks, Joel --- http://wagerlabs.com From sumith Sat Feb 23 13:13:08 2008 From: sumith (Sumith Gamage) Date: Sat, 23 Feb 2008 17:43:08 +0530 Subject: [erlang-questions] Problem in file:rawopen/2 Message-ID: <20080223121630.BF8C419DC35C@mail.wavenet.lk> Dear All, I use following code segment to copy directory in Linux. io:fwrite("~p:~p:copy_file(~p, ~p, ~p): Called.~n", [?MODULE, ?LINE, Src, Dest, Opts]), {ok, InFd} = file:rawopen(Src, {binary, read}), io:fwrite("~p:~p:copy_file: Opend read file (~p, ~p).~n", [?MODULE, ?LINE, Src, InFd]), {ok, OutFd} = file:rawopen(Dest, {binary, write}), io:fwrite("~p:~p:copy_file: Opend write file (~p, ~p).~n", [?MODULE, ?LINE, Dest, OutFd]), It works fine. I used the same code in Windows it fails with the same even with the same Erlang version (I tried with 5.5.5 & 5.6 both). Here is the output (with version 5.5.5): target_system:199:copy_file("tmp/erts-5.6/bin/epmd", "tmp/bin/epmd", [preserve]) : Called. =ERROR REPORT==== 23-Feb-2008::17:39:37 === Error in process <0.2389.0> with exit value: {{badmatch,{error,enoent}},[{target _system,copy_file,3},{target_system,create,1},{erl_eval,do_apply,5},{shell,e xprs ,6},{shell,eval_loop,3}]} ** exited: {{badmatch,{error,enoent}}, [{target_system,copy_file,3}, {target_system,create,1}, {erl_eval,do_apply,5}, {shell,exprs,6}, {shell,eval_loop,3}]} ** Kindly suggest me a workaround for this. Thanks in advance...! Sumith From francesco Sat Feb 23 13:54:53 2008 From: francesco (Francesco Cesarini) Date: Sat, 23 Feb 2008 12:54:53 +0000 Subject: [erlang-questions] Practical Erlang Programming In-Reply-To: References: <666266.47210.qm@web38805.mail.mud.yahoo.com> <290b3ba10802220653i22200b98g83a3abd8e41c0155@mail.gmail.com> Message-ID: <47C0179D.2080609@erlang-consulting.com> > Posting hardcore stuff to the blog allows me much more freedom > and the revenue from consulting projects that come as a result > far outweighs any possible book revenues. > I can second that. One does not write an Erlang book for the money, but for the fun and experience of doing it while knowing it will help spread Erlang to new users (When choosing a publisher, unrivaled dissemination and distribution channels is the reason we decided to go for O'Reilly). I hope Joel will some day collect all the articles from his blog into a book. Francesco -- http://www.erlang-consulting.com From tty.erlang Sat Feb 23 14:27:13 2008 From: tty.erlang (t ty) Date: Sat, 23 Feb 2008 08:27:13 -0500 Subject: [erlang-questions] Practical Erlang Programming In-Reply-To: References: <666266.47210.qm@web38805.mail.mud.yahoo.com> <290b3ba10802220653i22200b98g83a3abd8e41c0155@mail.gmail.com> Message-ID: <290b3ba10802230527p597da9a0xdaccfc3fb327f358@mail.gmail.com> I appologize for the mis-impression i gave. t On Sat, Feb 23, 2008 at 5:58 AM, Joel Reymont wrote: > t ty gmail.com> writes: > > > > > Unfortunately Joel has decided to drop the project. > > > > http://twitter.com/wagerlabs/statuses/659726302 > > I want to point out that did not drop the project. I dropped the book but > I'm posting the "book" to my blog. Take a look at the Introduction to the > Erlang FFI and Parsing Binaries with Erlang, for example. > > Posting hardcore stuff to the blog allows me much more freedom > and the revenue from consulting projects that come as a result > far outweighs any possible book revenues. > > Thanks, Joel > > --- > http://wagerlabs.com > > > > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > From tose Sat Feb 23 14:58:13 2008 From: tose (Tomas Stejskal) Date: Sat, 23 Feb 2008 14:58:13 +0100 Subject: [erlang-questions] Binary matching problem Message-ID: <47C02675.2050309@netsource.cz> Hello, as a newbie I've played with the module id3_v1.erl from Joe's book and I've found some strange behavior regarding binary matching. The module's purpose is reading an id3 version 1 or version 1.1 tag from a mp3 file. Here is modified version of the module: --- -module(id3_v1). -export([read_v1_or_v11_tag/1, read_only_v1_tag/1]). -import(lists, [reverse/1]). read_v1_or_v11_tag(File) -> read_id3_tag(File, fun parse_v1_or_v11_tag/1). read_only_v1_tag(File) -> read_id3_tag(File, fun parse_only_v1_tag/1). read_id3_tag(File, Parse) -> case file:open(File, [read, binary, raw]) of {ok, S} -> Size = filelib:file_size(File), {ok, Bin} = file:pread(S, Size - 128, 128), Result = Parse(Bin), file:close(S), Result; Error -> {File, Error} end. parse_only_v1_tag(<<"TAG", Title:30/binary, Artist:30/binary, Album:30/binary, _Year:4/binary, _Comment:30/binary, _Genre:8>>) -> {ok, {"ID3v1", [{title, trim(Title)}, {artist, trim(Artist)}, {album, trim(Album)}]}}; parse_only_v1_tag(_) -> error. parse_v1_or_v11_tag(<<"TAG", Title:30/binary, Artist:30/binary, Album:30/binary, _Year:4/binary, _Comment:28/binary, 0:8, Track:8, _Genre:8>>) -> {ok, {"ID3v1.1", [{track, Track}, {title, trim(Title)}, {artist, trim(Artist)}, {album, trim(Album)}]}}; parse_v1_or_v11_tag(<<"TAG", Title:30/binary, Artist:30/binary, Album:30/binary, _Year:4/binary, _Comment:30/binary, _Genre:8>>) -> {ok, {"ID3v1", [{title, trim(Title)}, {artist, trim(Artist)}, {album, trim(Album)}]}}; parse_v1_or_v11_tag(_) -> error. trim(Bin) -> list_to_binary(trim_blanks(binary_to_list(Bin))). trim_blanks(L) -> reverse(skip_blanks_and_zero(reverse(L))). skip_blanks_and_zero([$\s|T]) -> skip_blanks_and_zero(T); skip_blanks_and_zero([0|T]) -> skip_blanks_and_zero(T); skip_blanks_and_zero(L) -> L. --- When I use the function read_v1_or_v11_tag on a mp3 file containing version 1 tag, it returns an error. However, when the function read_only_v1_tag is applied on the same file, it reads the tag data correctly. The only difference between these two functions is that the former has an extra branch to read version 1.1 tag. Is this a bug or have I missed something? I've included an example file which contains only the id3 v1 tag data (last 128 bytes of the mp3 file). Thanks in advance /Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: id3_v1.mp3 Type: audio/mpeg Size: 128 bytes Desc: not available Url : http://www.erlang.org/pipermail/erlang-questions/attachments/20080223/ea6a3e11/attachment.mp3 From Raymond.Xiong Fri Feb 22 10:34:26 2008 From: Raymond.Xiong (Raymond Xiong) Date: Fri, 22 Feb 2008 17:34:26 +0800 Subject: [erlang-questions] failed to enable SMP support in otp_src_R12B-1 In-Reply-To: <18365.15528.896326.984436@harpo.it.uu.se> References: <20080220103022.GA742@Sun.Com> <18364.7591.965193.617900@harpo.it.uu.se> <20080221071901.GA19236@Sun.Com> <18365.15528.896326.984436@harpo.it.uu.se> Message-ID: <20080222093425.GA22309@Sun.Com> On 02/21/08, Mikael Pettersson wrote: > > The only difference between scenario 3 and scenario 4 is > > the call of "gmake clean" before re-configuration. I didn't > > realize it's necessary before(I had thought after > > re-configuration every thing will be rebuilt. But it seemed > > that's not the case. Is it correct?). > > A minimum of make clean is definitely needed between config changes. > The make system to build Erlang/OTP has always been iffy. > > > I also have a question on scenario 1 and scenario 2. From > > my testing result, "--enable-smp-support" must be specified > > explicitly on my machine. But it was said in README that this > > feature is detected automaticaly, is it ture? > > It's autoenabled on supported machines, where supported does > not mean "it may work" but means "the OTP team regularly tests > on it and they believe it works". Thanks for the explanation! If you don't mind, I have two more minor questions: 1) I am creating erlang package for opensolaris. Suppose all erlang/otp files will be placed under /usr/erlang when user installs that package, so I configure it with "--prefix=/usr/erlang" Then I use INSTALL_PREFIX variable to compile and install a temporary copy of erlang while creating package: # env INSTALL_PREFIX=/myroot gmake all install Then I checked /myroot/usr/erlang/bin/erl, and found it contained the following: # cat /myroot/usr/erlang/bin/erl ROOTDIR=/myroot/usr/erlang/lib/erlang ... Note the "/myroot" prefix in $ROOTDIR, that means I can't just use the file to create package, instead I need to use some file utilities to remove the "/myroot" prefix in it and other shell scripts. Do you know if there is a better way to do this? 2) Because opensolaris doesn't have a odbc library yet, is there a way(for example, something like "--disable-odbc") to explicitly disable odbc checking? -- Regards, Raymond From richardc Sat Feb 23 20:03:21 2008 From: richardc (Richard Carlsson) Date: Sat, 23 Feb 2008 20:03:21 +0100 Subject: [erlang-questions] Preprocessor bug? In-Reply-To: <981B483C-DC9E-4905-8973-0253E402FE87@ketralnis.com> References: <981B483C-DC9E-4905-8973-0253E402FE87@ketralnis.com> Message-ID: <47C06DF9.5060005@it.uu.se> I have changed the inliner so that instead of reporting a compile-time error (which was really the wrong thing to do), it now quietly skips the attempt to inline the call if the arities don't match. (The fix is simple: find the place which prints the error report, and change it to return {E,S} in case of arity mismatch. Or wait for the next OTP release.) Handling is_function/2 would let it remove the redundant code as well. I'm leaving that for later. /Richard David King wrote: > I'm not sure if this is a bug or, if it is a bug, it even needs to be > fixed. This code: > > f(F,A) when is_function(F,1) -> > F(A); > f(F,B) when is_function(F,2) -> > F(B,B). > > main() -> > f(fun(a) -> > io:format("f(g/1): ~p~n",[a]) > end, a), > f(fun(b,b) -> > io:format("f(g/2): ~p~n",[b]) > end, b). > > compiles and works as expected, unless -compile(inline) is specified. > If -compile(inline) is specified, the compiler dies with "error: > function called with wrong number of arguments!". I would think that > when the pre-processor can't determine at pre-compile time which > clause to run, it just wouldn't run one, but this is a mess I know I'm > getting into when I use -compile(inline), so it might not even matter. > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions -- "Having users is like optimization: the wise course is to delay it." -- Paul Graham From S.J.Thompson Mon Feb 18 21:24:50 2008 From: S.J.Thompson (S.J.Thompson) Date: Mon, 18 Feb 2008 20:24:50 +0000 (GMT) Subject: [erlang-questions] Funded PhD studentships at The University Of Kent, UK Message-ID: Funding is available for the following PhD studentships within the TCS group at the University of Kent. Applicants should contact the project supervisor directly for further details. Project Supervisor: Dr Olaf Chitil (O.Chitil) Project Title: Tracing Functional Programs with Hat Hat (www.haskell.org/hat) is a sophisticated tool for locating faults in Haskell programs. Hat consists of a trace generation system plus various tools for viewing a trace. The aim of the research project is to improve Hat by both extending it and easing its application in practise: (1) Apply several theoretical results of a recent EPSRC project on tracing in Hat (e.g. algorithmic debugging with functions as finite maps). (2) Integrate the trace generator of Hat into the byte code interpreter of the Glasgow Haskell system (GHC). (3) Enable traced code to call and be called from unmodified non-tracing code, such that Hat can use pre-compiled libraries of GHC. Project Title: The Essence of Transfinite Reductions Project Supervisor: Dr Stefan Kahrs (S.M.Kahrs) Infinitary Rewriting is an area of Term Rewriting in which research has studied infinitary terms and infinitary reductions. While the notion of infinitary terms is fairly settled, the existing notions of infinitary reduction leave a lot to be desired - the definitions are suspiciously complicated, the established results less than impressive. Thus, there appears to be a lot of room for improvement. There are different angles that are worth exploring. Firstly, there are several alternative ways to define transfinite reductions. Secondly, one would hope that some of these alternative ways lead to good properties of transfinite reduction. Thirdly, it is not even a priori clear what would constitute such a good property. Project Title: Refactoring Proofs Project Supervisor: Prof Simon Thompson (S.J.Thompson) Refactoring allows the programmer to modify the design or structure of a program without changing its behaviour. Recent work in the Functional Programming group at Kent has developed refactoring systems for Haskell 98 (HaRe) and Erlang (Wrangler). Programming and proof have much in common, and indeed under the "propositions as types" analogy, they are different views of the same objects. The aim of this project is to explore how refactoring can be incorporated into proof development systems, and will combine theoretical work, implementation and usability analysis to ensure that the results will be of value to users of proof assistants. The aim of this project is to investigate refactoring for proofs. From matthias Sat Feb 23 21:55:01 2008 From: matthias (Matthias Lang) Date: Sat, 23 Feb 2008 21:55:01 +0100 Subject: [erlang-questions] Problem in file:rawopen/2 In-Reply-To: <20080223121630.BF8C419DC35C@mail.wavenet.lk> References: <20080223121630.BF8C419DC35C@mail.wavenet.lk> Message-ID: <18368.34853.207725.722736@antilipe.corelatus.se> Sumith Gamage writes: > I use following code segment to copy directory in Linux. > {ok, OutFd} = file:rawopen(Dest, {binary, write}), > I used the same code in Windows it fails with the same even with the same > Erlang version (I tried with 5.5.5 & 5.6 both). > Kindly suggest me a workaround for this. file:rawopen/2 isn't documented. Looking at the library source, there's a comment above rawopen: %% Obsolete, undocumented, local node only, don't use! Matt From per Sun Feb 24 00:11:02 2008 From: per (Per Hedeland) Date: Sun, 24 Feb 2008 00:11:02 +0100 (CET) Subject: [erlang-questions] Trouble with accepting SSL on slow connections In-Reply-To: <85d11a2e0802220332t6a17cc25l72b67a5501ac83cc@mail.gmail.com> Message-ID: <200802232311.m1NNB2gW046896@pluto.hedeland.org> "Gurgen Tumanian" wrote: > >I am having trouble with accepting SSl connections on slow links in case of >delays over 2000ms. ssl:ssl_accept fails with {error, esslconnect}. [snip] >As far as i understand the SSL_accept(that handles the accept in ssl_esock) >function should have tried continuously on receiveing client certificate if >the OS reported EAGAIN. No, in non-blocking mode (which ssl_esock uses) it's supposed to do just what your trace showed, return -1 with SSL_ERROR_WANT_READ, which tells the caller that it should put the socket file descriptor back in its poll set and call SSL_accept again when poll/select says that there is (may be) something to read - otherwise the non-blocking mode would be completely defeated, and the caller could be stuck forever if a client yanked the network cable or whatever. As far as I can see ssl_esock follows this protocol, and the loop you show is exactly what is supposed to be going on. The question then is why it gives up after 2000 ms. Are you using ssl:ssl_accept/2, i.e. with a timeout? --Per Hedeland From lloy0076 Sun Feb 24 00:33:23 2008 From: lloy0076 (David Lloyd) Date: Sun, 24 Feb 2008 10:03:23 +1030 Subject: [erlang-questions] Preventing Recursion from Crashing Me... Message-ID: <47C0AD43.6030206@adam.com.au> I rather quickly discovered that: -module(math1). -export([factorial/1]). factorial(0) -> 1; factorial(N) -> N * factorial(N-1). ... erl % c(math1). % math1:factorial(1000000). ...was able to take sufficient resources that I only just managed to send a ctrl+alt+break (I'm running Gnome/JDS on Solaris SXCE b72 on a Intel Quad Core E6600 with 4Gb of memory). Apart from not using naive fibonacci ( :P ) is there a way to prevent erlang from running away with such processes? DSL From kostis Sun Feb 24 09:29:14 2008 From: kostis (Kostis Sagonas) Date: Sun, 24 Feb 2008 10:29:14 +0200 Subject: [erlang-questions] Problem in file:rawopen/2 In-Reply-To: <18368.34853.207725.722736@antilipe.corelatus.se> References: <20080223121630.BF8C419DC35C@mail.wavenet.lk> <18368.34853.207725.722736@antilipe.corelatus.se> Message-ID: <47C12ADA.9070306@cs.ntua.gr> Matthias Lang wrote: > Sumith Gamage writes: > > > I use following code segment to copy directory in Linux. > > > {ok, OutFd} = file:rawopen(Dest, {binary, write}), > > > I used the same code in Windows it fails with the same even with the same > > Erlang version (I tried with 5.5.5 & 5.6 both). > > > Kindly suggest me a workaround for this. > > file:rawopen/2 isn't documented. > > Looking at the library source, there's a comment above rawopen: > > %% Obsolete, undocumented, local node only, don't use! Matt is of course right in pointing out these, but this really begs the questions: - Since this function is obsolete, why does it survive across multiple OTP releases? - Assuming the previous question has a good answer, why aren't such functions marked as obsolete so that at least the compiler warns for its uses? Kostis From mickael.remond Sun Feb 24 09:34:49 2008 From: mickael.remond (=?UTF-8?Q?Micka=C3=ABl_R=C3=A9mond?=) Date: Sun, 24 Feb 2008 09:34:49 +0100 Subject: [erlang-questions] On books and French Erlang User Group (was Practical Erlang Programming) In-Reply-To: <47C0179D.2080609@erlang-consulting.com> References: <666266.47210.qm@web38805.mail.mud.yahoo.com> <290b3ba10802220653i22200b98g83a3abd8e41c0155@mail.gmail.com> <47C0179D.2080609@erlang-consulting.com> Message-ID: Hello, Le 23 f?vr. 08 ? 13:54, Francesco Cesarini a ?crit : > >> Posting hardcore stuff to the blog allows me much more freedom >> and the revenue from consulting projects that come as a result >> far outweighs any possible book revenues. >> > I can second that. One does not write an Erlang book for the money, > but > for the fun and experience of doing it while knowing it will help > spread > Erlang to new users (When choosing a publisher, unrivaled > dissemination > and distribution channels is the reason we decided to go for > O'Reilly). > I hope Joel will some day collect all the articles from his blog > into a > book. I can confirm this regarding the motivation for writing a book. You should not do that for money because, if you get back to a hourly earning, you often end up being paid much under the minimum salary. Writing a book is however a good way to promote a language. The french Erlang community has been very active after my French book. I should probably make it more lively again. Please, ping me if you are interested in participating to an Erlang User Group in France. This group will be active very soon :) Cheers, -- Micka?l R?mond http://www.process-one.net/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080224/4c6abca0/attachment.html From matthias Sun Feb 24 10:08:27 2008 From: matthias (Matthias Lang) Date: Sun, 24 Feb 2008 10:08:27 +0100 Subject: [erlang-questions] Problem in file:rawopen/2 In-Reply-To: <47C12ADA.9070306@cs.ntua.gr> References: <20080223121630.BF8C419DC35C@mail.wavenet.lk> <18368.34853.207725.722736@antilipe.corelatus.se> <47C12ADA.9070306@cs.ntua.gr> Message-ID: <18369.13323.49870.779574@antilipe.corelatus.se> > > Sumith Gamage writes: > > > > > I use following code segment to copy directory in Linux. > > > > > {ok, OutFd} = file:rawopen(Dest, {binary, write}), > > > > > I used the same code in Windows it fails with the same even > > > with the same Erlang version (I tried with 5.5.5 & 5.6 both). > > > > > Kindly suggest me a workaround for this. Matthias>> file:rawopen/2 isn't documented. Matthias>> Looking at the library source, there's a comment above Matthias>> rawopen: Matthias>> %% Obsolete, undocumented, local node only, don't use! Kostis> Matt is of course right in pointing out these, but this Kostis> really begs the questions: Kostis> - Since this function is obsolete, why does it survive Kostis> across multiple OTP releases? Kostis> - Assuming the previous question has a good answer, why Kostis> aren't such functions marked as obsolete so that at least Kostis> the compiler warns for its uses? Taking a few steps back at this problem, Sumith is trying to copy a directory by opening it as a file and copying the contents. This is a trick, i.e. it exploits knowledge about how directories are implemented in some operating systems. He's then combining that first trick with a second trick, namely using an undocumented function. That has "will probably blow up in your face" written all over it. Taking a guess, on Windows directories are implemented such that the 'a directory is a file' abstraction doesn't hold. Maybe someone who actually knows something about windows can confirm. Back to Kostis, who already knows the answer to "why is it still there", but I'll bite anyway: ic/src/icenum.erl: case file:rawopen(FName, {binary, write}) of ic/src/icstruct.erl: case file:rawopen(FName, {binary, write}) of ic/src/icstruct.erl: case file:rawopen(FName, {binary, write}) of ic/src/icstruct.erl: case file:rawopen(FName, {binary, write}) of ic/src/icunion.erl: case file:rawopen(FName, {binary, write}) of mnesia/src/mnesia_lib.erl: case file:rawopen(Fname, read) of mnesia/src/mnesia_lib.erl: case file:rawopen(From, {binary, read}) of mnesia/src/mnesia_lib.erl: case file:rawopen(To, {binary, write}) of A warning wouldn't hurt, though compiler-administered electric shocks would be more effective. Matt From alpar Sun Feb 24 12:01:35 2008 From: alpar (=?ISO-8859-1?Q?Alp=E1r_J=FCttner?=) Date: Sun, 24 Feb 2008 11:01:35 +0000 Subject: [erlang-questions] Preventing Recursion from Crashing Me... In-Reply-To: <47C0AD43.6030206@adam.com.au> References: <47C0AD43.6030206@adam.com.au> Message-ID: <1203850895.4347.20.camel@piko.site> The problem is that you use non-tail recursion in your factorial implementation. Try this instead: -module(math1). -export([factorial/1]). factorial(0) -> 1; factorial(N) -> factorial(1,N). factorial(P,1) -> P; factorial(P,N) -> factorial(P*N,N-1). This will not exhaust the system memory. Still do not expect a result for factorial(1000000). First, it would take a very long time to compute it (multiplication of such a big numbers are very slow). Secondly, after a lot of computation you will get this: % X=math1:factorial(1000000),0. ** exception error: a system limit has been reached in function math1:factorial/2 My guess is that factorial(1000000) is just too big to store even as a bignum. At least you can compute factorial(100000) using the tail-recursive implementation. Regards, Alpar On Sun, 2008-02-24 at 10:03 +1030, David Lloyd wrote: > I rather quickly discovered that: > > -module(math1). > -export([factorial/1]). > > factorial(0) -> 1; > factorial(N) -> N * factorial(N-1). > > > ... > > erl > % c(math1). > % math1:factorial(1000000). > > ...was able to take sufficient resources that I only just managed to > send a ctrl+alt+break (I'm running Gnome/JDS on Solaris SXCE b72 on a > Intel Quad Core E6600 with 4Gb of memory). > > Apart from not using naive fibonacci ( :P ) is there a way to prevent > erlang from running away with such processes? > > DSL > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions From ahmed.diaa Sun Feb 24 13:13:44 2008 From: ahmed.diaa (Ahmed Diaa) Date: Sun, 24 Feb 2008 13:13:44 +0100 Subject: [erlang-questions] Distributed Erlang Message-ID: Hello all , My question is about having two erlang nodes running on two machines I'm trying to ping nodes , using net_adm:ping function , it always return pang Notes: 1- When i try it between two machines on one domain , it works fine 2- When i try net_adm:names(HOST) and give HOST as the ip address ,it returns the name of node on that host with the port listening on (even for machines not on same domain) BUT when trying ping that node , it doesn't work so , any hints? thanks in advance Ahmed Diaa Software Developer Customer Adaptation Center E Ericsson Egypt Ltd, ECN: 821 7087 Mobile: +20 16 5501-604 E-mail: ahmed.diaa Office address: KM28, Smart Village, Cairo/Alex Desert Road, B86, Ericsson This communication is confidential and intended solely for the addressee(s). Any unauthorized review, use, disclosure or distribution is prohibited. If you believe this message has been sent to you in error, please notify the sender by replying to this transmission and delete the message without disclosing it. Thank you. E-mail including attachments is susceptible to data corruption, interruption, unauthorized amendment, tampering and viruses, and we only send and receive e-mails on the basis that we are not liable for any such corruption, interception, amendment, tampering or viruses or any consequences thereof. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080224/f2fa6481/attachment.html From matthias Sun Feb 24 12:42:13 2008 From: matthias (Matthias Lang) Date: Sun, 24 Feb 2008 12:42:13 +0100 Subject: [erlang-questions] Problem in file:rawopen/2 In-Reply-To: <18369.13323.49870.779574@antilipe.corelatus.se> References: <20080223121630.BF8C419DC35C@mail.wavenet.lk> <18368.34853.207725.722736@antilipe.corelatus.se> <47C12ADA.9070306@cs.ntua.gr> <18369.13323.49870.779574@antilipe.corelatus.se> Message-ID: <18369.22549.266292.892066@antilipe.corelatus.se> > > > Sumith Gamage writes: > > > > I use following code segment to copy directory in Linux. > > > > {ok, OutFd} = file:rawopen(Dest, {binary, write}), > > > > It works fine If I ignore your claim that the posted code copies a directory, i.e. assume that nothing clever is going on, then everything gets much less unlikely*. You probably just want to use file:open(Src, [binary, read, raw]) and file:open(Dest, [binary, write, raw])call, with the options [raw, Matt * I say that because attempting to open a directory doesn't even work on linux. It probably hasn't worked on any unix for about 15 years. From matthew Mon Feb 25 01:57:34 2008 From: matthew (Matthew Dempsky) Date: Sun, 24 Feb 2008 16:57:34 -0800 Subject: [erlang-questions] Distributed Erlang In-Reply-To: References: Message-ID: On 2/24/08, Ahmed Diaa wrote: > so , any hints? Yes, give us more details on how you started erlang (e.g., -name, -sname, etc.) and the actual commands you ran. We can only guess otherwise. :-) From dave Mon Feb 25 02:22:41 2008 From: dave (Dave Peticolas) Date: Sun, 24 Feb 2008 17:22:41 -0800 Subject: [erlang-questions] Associating contextual info with monitors In-Reply-To: <8209f740802240900r36360497o403a9a848aad895a@mail.gmail.com> References: <20080218025857.GA10836@vailsys.com> <47BBA1F2.7070703@krondo.com> <8209f740802192313p3b81558dn6136b490c3a2eeb4@mail.gmail.com> <47BF8816.3080305@krondo.com> <8209f740802240900r36360497o403a9a848aad895a@mail.gmail.com> Message-ID: <47C21861.4070300@krondo.com> Ah, I understand now. Thanks for your patience! dave Ulf Wiger wrote: > Yes, that's what I meant. I was typing in my response > using my cell phone, and was perhaps a bit curt. > > terminate() is always called when the callback throws > an exception, but if the process receives an EXIT signal, > it can only call terminate() if the EXIT signal doesn't kill > it right away (i.e. it has to be trapping exits, and the exit > reason must be something other than 'kill'). > > BR, > Ulf W > > 2008/2/23, Dave Peticolas : >> Ulf Wiger wrote: >> > No, terminate() is always called, if possible. If the server isn't >> > trapping exits, the server may die without being able to do any >> > cleanup. >> >> >> Thanks for your answer. Now trapping exits is required for terminate >> to be called, right? The gen_server docs seem to indicate this. >> >> In my testing, it seems like terminate is only called if the >> gen_server is trapping exits, even if it is a 'normal' shutdown. >> >> thanks, >> >> dave >> >> >> >> > BR, >> > Ulf W >> > >> > 2008/2/20, Dave Peticolas : >> >> Rick Pettit wrote: >> >>> On Sun, Feb 17, 2008 at 07:52:56PM -0700, Dave Smith wrote: >> >>>> Greetings, >> >>>> >> >>>> On several occasions, I've found myself wanting to be able to do some >> >>>> cleanup (e.g. remove an entry in ets) when a process dies. Usually I >> >>>> solve this by maintaining an ets table keyed by pid, that stores the >> >>>> necessary contextual info needed for cleanup, and then setup a monitor >> >>>> on the pid of interest. This works ok, but it's a little annoying to >> >>>> need to maintain yet another ets table for this context info that is >> >>>> only used when the process dies. It seems like what I _really_ want is >> >>>> a way to associate a term with a monitor -- that way when I get the >> >>>> DOWN message, I would also get the associated term and have everything >> >>>> I need to do the cleanup. >> >>>> >> >>>> Is there a "Right Way" to accomplish this? Maintaining ets tables for >> >>>> this sort of contextual info seems a bit overkill -- is there a >> >>>> simpler approach? Has anyone else ever encountered this sort of issue? >> >>>> I tried searching through the archives for this problem, but couldn't >> >>>> find the right set of search terms. :) >> >>> The way I typically solve this problem is by putting the cleanup code in >> >>> a gen_server:terminate/2 callback (this way when the gen_server dies it >> >>> cleans up after itself). >> >> Now I thought that terminate/2 is only called when a gen_server requests >> >> a stop from a callback function (by returning {stop, ...}), but not when >> >> it dies from, say, an exception. Is that not right? >> >> >> >> >> >>> For instances where the processes being spawned aren't gen_* servers, I >> >> would >> >>> most likely spawn a wrapper process which in turn spawn_links the real >> >> child >> >>> process, then blocks forever waiting to receive the EXIT for that process >> >> (the >> >>> cleanup code is triggered upon receipt of the EXIT, then the wrapper >> >> process >> >>> itself terminates). >> >> _______________________________________________ >> >> erlang-questions mailing list >> >> erlang-questions >> >> http://www.erlang.org/mailman/listinfo/erlang-questions >> >> >> > >> >> > From ok Mon Feb 25 02:34:40 2008 From: ok (Richard A. O'Keefe) Date: Mon, 25 Feb 2008 14:34:40 +1300 Subject: [erlang-questions] Strings as Lists In-Reply-To: References: <84fb38e30802120819q17f79420xc5d33f3c83a599f9@mail.gmail.com> <9b08084c0802180649k75218a8jf4316379d6767c67@mail.gmail.com> <7ABFCE6D-9BFA-4798-856C-4CEE2D6DA1EF@cs.otago.ac.nz> <57a21f730802201638h6e451465kf186591baedbc0bf@mail.gmail.com> Message-ID: <86ED4E67-F00C-478B-BA57-7A3D022C9BE9@cs.otago.ac.nz> On 23 Feb 2008, at 9:22 am, Matt Kangas wrote: > 1) Define a framework, have the framework know (and hide) the > appropriate terminating char-sequence > 2) Let the user define a terminating char sequence. (Perl/PHP/ > Ruby's answer) > 3) Have one terminating multi-line char sequence. (Python's answer) > 4) Have one char-sequence, but permit its length to vary to allow > nesting, within reason. (Lua's answer) > > Richard, from your last post: > >> Literal_String = """ >> Here is `'"\$^some literal text with an embedded >> but no trailing newline >> """, >> Another = ""!He said "Foo!" But that was not the end!!"" > > > That example falls into camp (2), user-defined terminating char, yes? It's really closer to (1), or arguably to (4). The framework says the opening and closing sequences are x y and y x respectively, where x is 2 or more quotation marks and y is either a newline or a printing character that is not a quotation mark. The user only gets to chose how many quotation marks to use and which non-quotation mark. *ALL* strings still begin and end with a quotation mark. It is important that there isn't any such animal as a user-defined terminating CHARACTER but a user-selected terminating SEQUENCE. > I suppose the motivation for (3) or (4) could be, perhaps, a desire > to make the string-enclosing syntax consistent, thus making it > easier to read unfamiliar code. The reader doesn't have to guess > (or look carefully for) what terminating-sequence the author chose. > (4) encourages consistency while still permitting nesting. My suggestion also addresses this: "funny" strings always begin and end with multiple quotation marks, so anything without multiple quotation marks isn't a "funny" string. > > Comparing (1) and (2), I believe the programmer who's writing the > code is best-positioned to decide what's an appropriate terminating > sequence. I can't believe this. My experience of using \verb|x| in LaTeX is that time after time I've found myself choosing a delimiting character that doesn't work. Fond as I am of TeX, it has warts, and this is one of them. What's even worse is that something that *did* work may cease to after what looks like a small edit. With my proposed literal string notation, and with several others, it would be very straightforward to have an editor command literal-quote- region that (a) determined the length of the longest run of quotation marks and (b) always generated "..."| .... |"..." or, if | were frequent, or for any other reason, selected some other suitable character. Combine this with literal-unquote-region, and one can easily - unquote the region - make an edit - requote it and expect the result to work, whereas author-chosen terminators are less likely to work. > I think hiding the terminating sequence behind a name ("/xml", "/ > latex", "/url") is likely to cause bugs, or at least weird > compilation errors. My proposal does *NOT* hide terminating sequences behind /xml or / latex or /url or anything else. Those things (mainly) name *ESCAPING* rules determining what happens *after* the string has been read; they have nothing whatsoever to do with deciding where the string *ends*. > > And.. we haven't discussed "raw" strings for regexes. Doh! It's there. > > Joe's original proposal was: > >> ~n"...." turn off quoting >> ~r"...." string is a regexp >> ~x"..." string is xml >> ~x/FlunkyStuff ... FunkyStuff (string is xml terminated by >> FunkyStuff) >> ~myExpander/FunkyStuff .... FunckyStuff > > Richard, which parts of this seem especially troublesome, and which > are salvageable? For one thing, ~n obviously cannot work; nor can anything which relies on the termination sequence being a single character. Actually, it doesn't turn off quoting; it quotes really hard. What it turns off is presumably *escaping*. For another, "n" is just too little a letter to bear a heavy freight of meaning. All of these single letter modifiers are just too Perlish, too arcane, too obscure. I often irritate my daughters by quoting one of T.S.Eliot's "Casey" poems to them: "You gotta use words when you talk to me." While strings may be a *compact* notation for regular expressions, they are often a grossly inconvenient one. With hindsight, I realise that I have spent more time desperately hacking away at regexp backslashes than I would have lost by using some kind of S-expression-like format. Stringy representations are popular in C and AWK because they don't *have* any S-expression-like format, but Erlang does. Why stretch the syntax to breaking point just in order to make it easier to do the wrong thing? The same goes for ~x. Last year I explained how easy it would be to mix XML with Erlang syntax, and why this would be so much *better* than having XML strings. I don't want to have to go through all that again. Even without that, an S-expression-like form (such as I use when hacking XML in Scheme) is unutterably more convenient in almost every way than a string-like form. And of course I repeat that the main point of my proposal is keeping all this stuff *out* of the language until we have some experience with several solutions and know which one(s) work(s) best. From raould Mon Feb 25 04:09:34 2008 From: raould (Raoul Duke) Date: Sun, 24 Feb 2008 19:09:34 -0800 Subject: [erlang-questions] deadlock (etc.) checking/avoidance? In-Reply-To: <8209f740802240842h15a69c71tddfa97903bdbb3fe@mail.gmail.com> References: <91a2ba3e0802211740l51bd7521x928551d9adb65087@mail.gmail.com> <8209f740802240842h15a69c71tddfa97903bdbb3fe@mail.gmail.com> Message-ID: <91a2ba3e0802241909r8174742sf1f2e738f00c238b@mail.gmail.com> hi, > I'm sure I have the code somewhere. I had some ideas > about how to make it incremental (currently, it wants > processes to claim all resources before doing anything > with them, which is not always convenient.) Sounds darned cool. Pretty please productize it :-) sincerely. From j.bhanot Mon Feb 25 06:34:22 2008 From: j.bhanot (J Bhanot) Date: Mon, 25 Feb 2008 11:04:22 +0530 Subject: [erlang-questions] Global Variable Message-ID: Hi, I simple want to use if-else statements and use data from that to build message... e,g, if condition = 1then msg = 1 else if condition = 2 then msg = msg + 2 if condition = 3 then return msg Basically, i want to build message recursively based upon conditions...i.e. msg is my global variable I just could not find out the way it can be done in erlang Thanks, jb ____________________________________________ =====-----=====-----===== Notice: The information contained in this e-mail message and/or attachments to it may contain confidential or privileged information. If you are not the intended recipient, any dissemination, use, review, distribution, printing or copying of the information contained in this e-mail message and/or attachments to it are strictly prohibited. If you have received this communication in error, please notify us by reply e-mail or telephone and immediately and permanently delete the message and any attachments. Thank you -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080225/9a5c6967/attachment-0001.html From chandrashekhar.mullaparthi Mon Feb 25 07:59:21 2008 From: chandrashekhar.mullaparthi (Chandru) Date: Mon, 25 Feb 2008 06:59:21 +0000 Subject: [erlang-questions] Global Variable In-Reply-To: References: Message-ID: On 25/02/2008, J Bhanot wrote: > > Hi, > > I simple want to use if-else statements and use data from that to build > message... > > e,g, > > if condition = 1then > > msg = 1 > > else > > if condition = 2 then > > msg = msg + 2 > > if condition = 3 then > > return msg > > Basically, i want to build message recursively based upon conditions...i.e. > msg is my global variable > > I just could not find out the way it can be done in erlang Something like this? build_msg(Msg, [1 | Conditions]) -> build_msg(1, Conditions); build_msg(Msg, [2 | Conditions]) -> build_msg(Msg + 2, Conditions); build_msg(Msg, [3 | _]) -> Msg; build_msg(Msg, [_ | Conditions]) -> build_msg(Msg, Conditions); build_msg(Msg, []) -> Msg. From nick.james Mon Feb 25 10:46:32 2008 From: nick.james (nick james) Date: Mon, 25 Feb 2008 09:46:32 -0000 Subject: [erlang-questions] Beginner Message-ID: <000001c87793$4e358f90$4200a8c0@pcnickjames> Hi, I have a program which results in a run time error I don't understand. The program is: -module(lists1). -export([min/1]). min(N) when number(N) -> N; min([H|[]]) -> H; min([H|T]) -> tailMin = min(T), if tailMin > H -> H; tailMin =< H -> tailMin end . And the output is: Eshell V5.6 (abort with ^G) 1> c(lists1). {ok,lists1} 2> lists1:min(1). 1 3> lists1:min([1]). 1 4> lists1:min([1,2]). ** exception error: no match of right hand side value 2 in function lists1:min/1 5> My expectation is that lists1:min([1,2]) would be picked up by min([H|T]) . Can anyone enlighten me? Nick James Cadar Measurement Solutions Ltd tel 08453 708 709 Registered in England, no.2027817, 100 Fitzwalter Road, Sheffield S2 2SP -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080225/abf04ec1/attachment.html From rec Mon Feb 25 11:01:34 2008 From: rec (Roger Critchlow) Date: Mon, 25 Feb 2008 03:01:34 -0700 Subject: [erlang-questions] Beginner In-Reply-To: <000001c87793$4e358f90$4200a8c0@pcnickjames> References: <000001c87793$4e358f90$4200a8c0@pcnickjames> Message-ID: <66d1c98f0802250201r648cbabbp27e04cd951b7e03b@mail.gmail.com> Nick -- tailMin isn't a name you can bind to a value, use TailMin instead. tailMin = 2 asserts that the atom 'tailMin' is equal to the integer 2. -- rec -- 2008/2/25 nick james : > Hi, > > I have a program which results in a run time error I don't understand. > The program is: > > > > -module(lists1). > > -export([min/1]). > > > > min(N) when number(N) -> > > N; > > > > min([H|[]]) -> > > H; > > > > min([H|T]) -> > > tailMin = min(T), > > if > > tailMin > H -> > > H; > > tailMin =< H -> > > tailMin > > end > > . > > > > And the output is: > > Eshell V5.6 (abort with ^G) > > 1> c(lists1). > > {ok,lists1} > > 2> lists1:min(1). > > 1 > > 3> lists1:min([1]). > > 1 > > 4> lists1:min([1,2]). > > ** exception error: no match of right hand side value 2 > > in function lists1:min/1 > > 5> > > > > My expectation is that lists1:min([1,2]) would be picked up by min([H|T]) > . Can anyone enlighten me? > > > > *Nick James* > Cadar Measurement Solutions Ltd > tel 08453 708 709 > Registered in England, no.2027817, 100 Fitzwalter Road, Sheffield S2 2SP > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080225/9594a83a/attachment.html From chsu79 Mon Feb 25 11:04:29 2008 From: chsu79 (Christian S) Date: Mon, 25 Feb 2008 11:04:29 +0100 Subject: [erlang-questions] Beginner In-Reply-To: <000001c87793$4e358f90$4200a8c0@pcnickjames> References: <000001c87793$4e358f90$4200a8c0@pcnickjames> Message-ID: > tailMin = min(T), Variables are capitalized. It is a syntax thing. Words that aren't capitalized are atoms. So: Call the variable TailMin instead. From matthew Mon Feb 25 12:23:58 2008 From: matthew (Matthew Dempsky) Date: Mon, 25 Feb 2008 03:23:58 -0800 Subject: [erlang-questions] Distributed Erlang In-Reply-To: References: Message-ID: (Please reply to the list so that others might answer as well.) On 2/25/08, Ahmed Diaa wrote: > Thanks mathew > i started erlang like this > On Machine 1 : > erl -name node1 -setcookie abc > On Machine 2 : > erl -name node2 -setcookie abc > > so? And what does node() return on each node? Do the host name parts of those resolve in DNS correctly? Does IP allow traffic to pass between them correctly? E.g., if node() returns node1, does "ping machine-1.ericsson.com" work on Machine 2? Are there any firewalls between the machines that would block TCP traffic to port 4369 or any higher ports? E.g., does "telnet machine-1.ericsson.com 4369" print "Connected to [something]." or does it hang at "Trying [some IP]..."? If TCP traffic to port 4369 is working, check the output of inet:i() on machine 1, and look for a listening socket, something like: 6 inet_tcp 0 0 <0.20.0> *:52549 *:* ACCEPTING In this case, what does "telnet machine-1.ericsson.com 52549" (substituting 52549 as appropriate) do when run on Machine 2? From andreas.hillqvist Mon Feb 25 12:37:15 2008 From: andreas.hillqvist (Andreas Hillqvist) Date: Mon, 25 Feb 2008 12:37:15 +0100 Subject: [erlang-questions] Beginner In-Reply-To: <000001c87793$4e358f90$4200a8c0@pcnickjames> References: <000001c87793$4e358f90$4200a8c0@pcnickjames> Message-ID: <8268eea30802250337k75de2216g40d4d9e32005c830@mail.gmail.com> You could write: min([H]) -> insted of: min([H | []]) -> An alternativ is to make the function tail-recursive: min([H | T]) -> min(H, T); min(N) when number(N) -> N. min(Min, [H | T]) when H > Min -> min(Min, T); min(Min, [H | T]) when H =< Min -> min(H, T); min(Min, []) -> Min. (The code is untested.) Kind regard Andreas Hillqvist 2008/2/25, nick james : > > > > Hi, > > I have a program which results in a run time error I don't understand. > The program is: > > > > -module(lists1). > > -export([min/1]). > > > > min(N) when number(N) -> > > N; > > > > min([H|[]]) -> > > H; > > > > min([H|T]) -> > > tailMin = min(T), > > if > > tailMin > H -> > > H; > > tailMin =< H -> > > tailMin > > end > > . > > > > And the output is: > > Eshell V5.6 (abort with ^G) > > 1> c(lists1). > > {ok,lists1} > > 2> lists1:min(1). > > 1 > > 3> lists1:min([1]). > > 1 > > 4> lists1:min([1,2]). > > ** exception error: no match of right hand side value 2 > > in function lists1:min/1 > > 5> > > > > My expectation is that lists1:min([1,2]) would be picked up by min([H|T]) . > Can anyone enlighten me? > > > > Nick James > Cadar Measurement Solutions Ltd > tel 08453 708 709 > Registered in England, no.2027817, 100 Fitzwalter Road, Sheffield S2 2SP > > > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > From bengt.kleberg Mon Feb 25 13:35:16 2008 From: bengt.kleberg (Bengt Kleberg) Date: Mon, 25 Feb 2008 13:35:16 +0100 Subject: [erlang-questions] Binary matching problem In-Reply-To: <47C02675.2050309@netsource.cz> References: <47C02675.2050309@netsource.cz> Message-ID: <1203942916.5644.23.camel@seasc0625.dyn.rnd.as.sw.ericsson.se> Greetings, The example file and code works for me. Erlang (BEAM) emulator version 5.5.5.5 2> id3_v1:read_v1_or_v11_tag("id3_v1.mp3"). {ok,{"ID3v1", [{title,<<68,117,154,105,232,107,121>>}, {artist,<<"Daniel Landa">>}, {album,<<"Best Of">>}]}} bengt On Sat, 2008-02-23 at 14:58 +0100, Tomas Stejskal wrote: > Hello, > > as a newbie I've played with the module id3_v1.erl from Joe's book and > I've found some strange behavior regarding binary matching. The module's > purpose is reading an id3 version 1 or version 1.1 tag from a mp3 file. > > Here is modified version of the module: > > --- > -module(id3_v1). > -export([read_v1_or_v11_tag/1, read_only_v1_tag/1]). > -import(lists, [reverse/1]). > > read_v1_or_v11_tag(File) -> > read_id3_tag(File, fun parse_v1_or_v11_tag/1). > > read_only_v1_tag(File) -> > read_id3_tag(File, fun parse_only_v1_tag/1). > > read_id3_tag(File, Parse) -> > case file:open(File, [read, binary, raw]) of > {ok, S} -> > Size = filelib:file_size(File), > {ok, Bin} = file:pread(S, Size - 128, 128), > Result = Parse(Bin), > file:close(S), > Result; > Error -> > {File, Error} > end. > > parse_only_v1_tag(<<"TAG", Title:30/binary, > Artist:30/binary, Album:30/binary, > _Year:4/binary, _Comment:30/binary, > _Genre:8>>) -> > {ok, > {"ID3v1", > [{title, trim(Title)}, > {artist, trim(Artist)}, > {album, trim(Album)}]}}; > parse_only_v1_tag(_) -> > error. > > parse_v1_or_v11_tag(<<"TAG", Title:30/binary, > Artist:30/binary, Album:30/binary, > _Year:4/binary, _Comment:28/binary, > 0:8, Track:8, _Genre:8>>) -> > {ok, > {"ID3v1.1", > [{track, Track}, {title, trim(Title)}, > {artist, trim(Artist)}, {album, trim(Album)}]}}; > parse_v1_or_v11_tag(<<"TAG", Title:30/binary, > Artist:30/binary, Album:30/binary, > _Year:4/binary, _Comment:30/binary, > _Genre:8>>) -> > {ok, > {"ID3v1", > [{title, trim(Title)}, > {artist, trim(Artist)}, > {album, trim(Album)}]}}; > parse_v1_or_v11_tag(_) -> > error. > > trim(Bin) -> > list_to_binary(trim_blanks(binary_to_list(Bin))). > > trim_blanks(L) -> > reverse(skip_blanks_and_zero(reverse(L))). > > skip_blanks_and_zero([$\s|T]) -> > skip_blanks_and_zero(T); > skip_blanks_and_zero([0|T]) -> > skip_blanks_and_zero(T); > skip_blanks_and_zero(L) -> > L. > --- > > When I use the function read_v1_or_v11_tag on a mp3 file containing > version 1 tag, it returns an error. However, when the function > read_only_v1_tag is applied on the same file, it reads the tag data > correctly. The only difference between these two functions is that the > former has an extra branch to read version 1.1 tag. > > Is this a bug or have I missed something? > > I've included an example file which contains only the id3 v1 tag data > (last 128 bytes of the mp3 file). > > Thanks in advance > > /Tom > > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions From richardc Mon Feb 25 14:15:51 2008 From: richardc (Richard Carlsson) Date: Mon, 25 Feb 2008 14:15:51 +0100 Subject: [erlang-questions] Preventing Recursion from Crashing Me... In-Reply-To: <47C0AD43.6030206@adam.com.au> References: <47C0AD43.6030206@adam.com.au> Message-ID: <47C2BF87.9010403@it.uu.se> David Lloyd wrote: > I rather quickly discovered that: > > factorial(0) -> 1; > factorial(N) -> N * factorial(N-1). > > % math1:factorial(1000000). > > ...was able to take sufficient resources that I only just managed to > send a ctrl+alt+break (I'm running Gnome/JDS on Solaris SXCE b72 on a > Intel Quad Core E6600 with 4Gb of memory). > > Apart from not using naive fibonacci ( :P ) is there a way to prevent ^factorial > erlang from running away with such processes? The recursion in itself is not a problem (try changing * to +), but when you get up to really huge numbers, almost all the CPU time is being spent inside the bignum-arithmetic routines. These are implemented in C, and for obvious performance reasons they do not check for signals, and the Erlang process cannot be rescheduled in the middle of such an operation, so you may well have problems interrupting the process in a pathological case like this. When I tested this, I noticed that the print-formatting in the shell actually takes quite a long time. On my desktop machine, _computing_ factorial(10000) takes a fraction of a second, but printing it takes almost a full second in itself. factorial(100000) takes about 35 seconds to compute, and one minute 25 seconds to format (the result is many screen pages). The formatting time is actually spent in the built-in function integer_to_list(N), so there may be reason to look at whether this is inefficiently implemented also for smaller numbers. Computing factorial(1000000), on my 1GB desktop Pentium 4 used 100% of one "cpu" (hyperthreaded, not multicore) for more than 20 minutes before I killed the job (no problem using ctrl-G and "kill" in the shell), with peak memory usage of no more than 30 MB, and the OS (Windows) remained responsive. I don't really understand how Erlang could hog your 4GB Quad-core machine executing the above program. /Richard From als Mon Feb 25 14:37:14 2008 From: als (Anthony Shipman) Date: Tue, 26 Feb 2008 00:37:14 +1100 Subject: [erlang-questions] how to find a user-defined behaviour? Message-ID: <200802260037.14596.als@iinet.net.au> I've defined a user-defined behaviour in a directory of modules. The beam files are written to a different directory with an {outdir, OUT} compiler option. The compiler now can't find the beam file that specifies the behaviour, even if I do erl -make -pz OUT It can find the behaviour if I manually copy the beam file back to the source directory. -- Anthony Shipman Mamas don't let your babies als grow up to be outsourced. From bjorn Mon Feb 25 12:15:26 2008 From: bjorn (Bjorn Gustavsson) Date: 25 Feb 2008 12:15:26 +0100 Subject: [erlang-questions] Problem in file:rawopen/2 In-Reply-To: <47C12ADA.9070306@cs.ntua.gr> References: <20080223121630.BF8C419DC35C@mail.wavenet.lk> <18368.34853.207725.722736@antilipe.corelatus.se> <47C12ADA.9070306@cs.ntua.gr> Message-ID: Kostis Sagonas writes: > Matt is of course right in pointing out these, but this really begs the > questions: > > - Since this function is obsolete, why does it survive across multiple > OTP releases? > > - Assuming the previous question has a good answer, why aren't such > functions marked as obsolete so that at least the compiler warns > for its uses? Oversight, I suppose. file:rawopen/2 was kept when the 'raw' flag for file:open/2 was introduced, because of some hairy start-up problem. I think that the need for file:rawopen/2 disappeared when the prim_file module was introduced. We will deprecate file:rawopen/2 in R12B-2. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From bjorn Mon Feb 25 12:18:19 2008 From: bjorn (Bjorn Gustavsson) Date: 25 Feb 2008 12:18:19 +0100 Subject: [erlang-questions] Problem in file:rawopen/2 In-Reply-To: <18369.13323.49870.779574@antilipe.corelatus.se> References: <20080223121630.BF8C419DC35C@mail.wavenet.lk> <18368.34853.207725.722736@antilipe.corelatus.se> <47C12ADA.9070306@cs.ntua.gr> <18369.13323.49870.779574@antilipe.corelatus.se> Message-ID: Matthias Lang writes: > > Taking a few steps back at this problem, Sumith is trying to copy a > directory by opening it as a file and copying the contents. This is a > trick, i.e. it exploits knowledge about how directories are > implemented in some operating systems. He's then combining that first > trick with a second trick, namely using an undocumented function. That > has "will probably blow up in your face" written all over it. I don't think he actually opens the directory itself. That is supposed to give an {error,eisdir} on any platform. (Erlang has never allowed reading directories as files, even on Unix systems.) > A warning wouldn't hurt, though compiler-administered electric > shocks would be more effective. Good idea. :-) /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From tose Mon Feb 25 15:23:06 2008 From: tose (Tomas Stejskal) Date: Mon, 25 Feb 2008 15:23:06 +0100 Subject: [erlang-questions] Binary matching problem In-Reply-To: <1203942916.5644.23.camel@seasc0625.dyn.rnd.as.sw.ericsson.se> References: <47C02675.2050309@netsource.cz> <1203942916.5644.23.camel@seasc0625.dyn.rnd.as.sw.ericsson.se> Message-ID: <47C2CF4A.60606@netsource.cz> It doesn't really work for me. I have erlang R12B-1 and it seems you've tried it out on version R11B5, maybe it's a bug in R12. /Tom Bengt Kleberg wrote: > Greetings, > > The example file and code works for me. > > Erlang (BEAM) emulator version 5.5.5.5 > 2> id3_v1:read_v1_or_v11_tag("id3_v1.mp3"). > {ok,{"ID3v1", > [{title,<<68,117,154,105,232,107,121>>}, > {artist,<<"Daniel Landa">>}, > {album,<<"Best Of">>}]}} > > > bengt > > On Sat, 2008-02-23 at 14:58 +0100, Tomas Stejskal wrote: >> Hello, >> >> as a newbie I've played with the module id3_v1.erl from Joe's book and >> I've found some strange behavior regarding binary matching. The module's >> purpose is reading an id3 version 1 or version 1.1 tag from a mp3 file. >> >> Here is modified version of the module: >> >> --- >> -module(id3_v1). >> -export([read_v1_or_v11_tag/1, read_only_v1_tag/1]). >> -import(lists, [reverse/1]). >> >> read_v1_or_v11_tag(File) -> >> read_id3_tag(File, fun parse_v1_or_v11_tag/1). >> >> read_only_v1_tag(File) -> >> read_id3_tag(File, fun parse_only_v1_tag/1). >> >> read_id3_tag(File, Parse) -> >> case file:open(File, [read, binary, raw]) of >> {ok, S} -> >> Size = filelib:file_size(File), >> {ok, Bin} = file:pread(S, Size - 128, 128), >> Result = Parse(Bin), >> file:close(S), >> Result; >> Error -> >> {File, Error} >> end. >> >> parse_only_v1_tag(<<"TAG", Title:30/binary, >> Artist:30/binary, Album:30/binary, >> _Year:4/binary, _Comment:30/binary, >> _Genre:8>>) -> >> {ok, >> {"ID3v1", >> [{title, trim(Title)}, >> {artist, trim(Artist)}, >> {album, trim(Album)}]}}; >> parse_only_v1_tag(_) -> >> error. >> >> parse_v1_or_v11_tag(<<"TAG", Title:30/binary, >> Artist:30/binary, Album:30/binary, >> _Year:4/binary, _Comment:28/binary, >> 0:8, Track:8, _Genre:8>>) -> >> {ok, >> {"ID3v1.1", >> [{track, Track}, {title, trim(Title)}, >> {artist, trim(Artist)}, {album, trim(Album)}]}}; >> parse_v1_or_v11_tag(<<"TAG", Title:30/binary, >> Artist:30/binary, Album:30/binary, >> _Year:4/binary, _Comment:30/binary, >> _Genre:8>>) -> >> {ok, >> {"ID3v1", >> [{title, trim(Title)}, >> {artist, trim(Artist)}, >> {album, trim(Album)}]}}; >> parse_v1_or_v11_tag(_) -> >> error. >> >> trim(Bin) -> >> list_to_binary(trim_blanks(binary_to_list(Bin))). >> >> trim_blanks(L) -> >> reverse(skip_blanks_and_zero(reverse(L))). >> >> skip_blanks_and_zero([$\s|T]) -> >> skip_blanks_and_zero(T); >> skip_blanks_and_zero([0|T]) -> >> skip_blanks_and_zero(T); >> skip_blanks_and_zero(L) -> >> L. >> --- >> >> When I use the function read_v1_or_v11_tag on a mp3 file containing >> version 1 tag, it returns an error. However, when the function >> read_only_v1_tag is applied on the same file, it reads the tag data >> correctly. The only difference between these two functions is that the >> former has an extra branch to read version 1.1 tag. >> >> Is this a bug or have I missed something? >> >> I've included an example file which contains only the id3 v1 tag data >> (last 128 bytes of the mp3 file). >> >> Thanks in advance >> >> /Tom >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions >> http://www.erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions From theczintheroc2007 Mon Feb 25 16:03:18 2008 From: theczintheroc2007 (Colin Z) Date: Mon, 25 Feb 2008 10:03:18 -0500 Subject: [erlang-questions] Erlang image improvements (was: Re: Beyond Strings as Lists) Message-ID: >>I like how this thread reminds me of "bikeshedding". >>So like, what colors should the new frontpage be? That's kind of my point. There's no centralized, official place to go to propose or organize these kinds of things. Or maybe there is(?) As I've admitted, I'm a newbie to the community. But so far I haven't found anything like I'm describing. If so, where do you apply? Who do you contact? How do you get involved meaningfully? Regarding bikeshedding...why would I go off and create a mock-up of a new Erlang homepage if I don't feel like there's any hope that someone with any authority will see it or even care? Open source is one thing, but just look to Linux to see that it still requires some kind of hierarchy or organization. If such a thing existed then they could, say, hold a contest and solicit designs for a new homepage. That way you not only get a new homepage, but you also generate hype for the language. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080225/0aa4914d/attachment.html From juanjo Mon Feb 25 16:29:20 2008 From: juanjo (Juan Jose Comellas) Date: Mon, 25 Feb 2008 13:29:20 -0200 Subject: [erlang-questions] Supervisor on-demand Message-ID: <1c3be50f0802250729i7a6c044foc3a6577cbd00228a@mail.gmail.com> I have the following scenario and I'm not really sure of how to represent it with OTP. I have an application (appmod) running within Yaws that has to create a worker process every time it receives an HTTP request.The worker process is created for a specific ID that comes with the request and for different requests that contain the same ID, the same worker process must be used. Once instantiated, the worker process must remain up and until it is explicitly stopped. I want to monitor the worker processes with an OTP supervisor, but so far I'm not completely sure of what the correct approach should be. Should I call supervisor:start_link() the first time I get a request for a specific ID and then supervisor:start_child() for the following ones? Or should I just create one supervisor process per worker process I have? Can anyone share some tips with me on how to design a solution for this problem within OTP? Thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080225/81649efc/attachment.html From kostis Mon Feb 25 16:36:10 2008 From: kostis (Kostis Sagonas) Date: Mon, 25 Feb 2008 17:36:10 +0200 Subject: [erlang-questions] Binary matching problem In-Reply-To: <47C2CF4A.60606@netsource.cz> References: <47C02675.2050309@netsource.cz> <1203942916.5644.23.camel@seasc0625.dyn.rnd.as.sw.ericsson.se> <47C2CF4A.60606@netsource.cz> Message-ID: <47C2E06A.7070604@cs.ntua.gr> Tomas Stejskal wrote: > It doesn't really work for me. I have erlang R12B-1 and it seems you've > tried it out on version R11B5, maybe it's a bug in R12. This appears to be a BEAM compiler bug in R12B. I cannot test it in vanilla R12B, but it's present even in the current development version, so I am certain it is the same problem. Eshell V5.6.2 (abort with ^G) 1> c(id3_v1). {ok,id3_v1} 2> id3_v1:read_v1_or_v11_tag("id3_v1.mp3"). error Incidentally, the problem disappears if you compile to native code via Core Erlang (but not via BEAM): 3> hipe:c(id3_v1, [core]). {ok,id3_v1} 4> id3_v1:read_v1_or_v11_tag("id3_v1.mp3"). {ok,{"ID3v1", [{title,<<68,117,154,105,232,107,121>>}, {artist,<<"Daniel Landa">>}, {album,<<"Best Of">>}]}} The problem is most probably due to generating erroneous control flow. In the list of instructions: {test,bs_start_match2,{f,15},[{x,0},1,0,{x,0}]} {test,bs_match_string,{f,15},[{x,0},24,<<"TAG">>]} {test,bs_get_binary2, {f,15}, [{x,0},1,{integer,30},8,{field_flags,0},{x,1}]} {test,bs_get_binary2, {f,15}, [{x,0},2,{integer,30},8,{field_flags,0},{x,2}]} {test,bs_get_binary2, {f,15}, [{x,0},3,{integer,30},8,{field_flags,0},{x,3}]} {test,bs_skip_bits2, {f,15}, [{x,0},{integer,4},8,{field_flags,0}]} {test,bs_skip_bits2, {f,14}, [{x,0},{integer,28},8,{field_flags,0}]} {test,bs_get_integer2, {f,15}, <--------------- [{x,0},4,{integer,8},1,{field_flags,0},{x,4}]} {test,bs_get_integer2, {f,15}, <--------------- [{x,0},5,{integer,8},1,{field_flags,0},{x,5}]} {test,bs_test_tail2,{f,15},[{x,0},8]} <--------------- {test,is_eq_exact,{f,15},[{x,4},{integer,0}]} <------------ .......... the labels with the arrows should read {f,14} instead (and perhaps there should be some bs_restore instructions in label 14). Bjorn, now do your magic ;-) Kostis From andreas.hillqvist Mon Feb 25 16:45:24 2008 From: andreas.hillqvist (Andreas Hillqvist) Date: Mon, 25 Feb 2008 16:45:24 +0100 Subject: [erlang-questions] Supervisor on-demand In-Reply-To: <1c3be50f0802250729i7a6c044foc3a6577cbd00228a@mail.gmail.com> References: <1c3be50f0802250729i7a6c044foc3a6577cbd00228a@mail.gmail.com> Message-ID: <8268eea30802250745h211bd4c3pa6be53d4cced7b90@mail.gmail.com> Hi. It sounds like simple_one_for_one would work for you. It is possible to pass the id or any additional parameters to start_child: supervisor:start_child(SupRef, [YourId]) Regards Andreas Hillqvist 2008/2/25, Juan Jose Comellas : > I have the following scenario and I'm not really sure of how to represent it > with OTP. I have an application (appmod) running within Yaws that has to > create a worker process every time it receives an HTTP request.The worker > process is created for a specific ID that comes with the request and for > different requests that contain the same ID, the same worker process must be > used. Once instantiated, the worker process must remain up and until it is > explicitly stopped. > > I want to monitor the worker processes with an OTP supervisor, but so far > I'm not completely sure of what the correct approach should be. Should I > call supervisor:start_link() the first time I get a request for a specific > ID and then supervisor:start_child() for the following ones? Or should I > just create one supervisor process per worker process I have? Can anyone > share some tips with me on how to design a solution for this problem within > OTP? > > Thanks. > > > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > From juanjo Mon Feb 25 16:54:39 2008 From: juanjo (Juan Jose Comellas) Date: Mon, 25 Feb 2008 13:54:39 -0200 Subject: [erlang-questions] Supervisor on-demand In-Reply-To: <8268eea30802250745h211bd4c3pa6be53d4cced7b90@mail.gmail.com> References: <1c3be50f0802250729i7a6c044foc3a6577cbd00228a@mail.gmail.com> <8268eea30802250745h211bd4c3pa6be53d4cced7b90@mail.gmail.com> Message-ID: <1c3be50f0802250754t4e3179f9vf41f0071a780509c@mail.gmail.com> Don't I have to call supervisor:start_link() before issuing a start_child()? What would I return from the Module:init() callback that is called from supervisor:start_link()? Right now this is what this function looks like: init([Provider, Host, Port, Password]) -> {{one_for_one, 1, 60}, [{Provider, {fs_provider, start_link, [provider_name(Provider), Host, Port, Password]}, transient, 15, worker, [fs_provider]}]}. I tried calling supervisor:start_link() at the beginning of my program and returning 'ignore' from the Module:init() callback but the supervisor would not start. On 2/25/08, Andreas Hillqvist wrote: > > Hi. > > It sounds like simple_one_for_one would work for you. > It is possible to pass the id or any additional parameters to start_child: > supervisor:start_child(SupRef, [YourId]) > > > Regards > Andreas Hillqvist > > 2008/2/25, Juan Jose Comellas : > > > I have the following scenario and I'm not really sure of how to > represent it > > with OTP. I have an application (appmod) running within Yaws that has to > > create a worker process every time it receives an HTTP request.Theworker > > process is created for a specific ID that comes with the request and for > > different requests that contain the same ID, the same worker process > must be > > used. Once instantiated, the worker process must remain up and until it > is > > explicitly stopped. > > > > I want to monitor the worker processes with an OTP supervisor, but so > far > > I'm not completely sure of what the correct approach should be. Should I > > call supervisor:start_link() the first time I get a request for a > specific > > ID and then supervisor:start_child() for the following ones? Or should I > > just create one supervisor process per worker process I have? Can anyone > > share some tips with me on how to design a solution for this problem > within > > OTP? > > > > Thanks. > > > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080225/8162e553/attachment.html From tty.erlang Mon Feb 25 17:08:52 2008 From: tty.erlang (t ty) Date: Mon, 25 Feb 2008 11:08:52 -0500 Subject: [erlang-questions] Supervisor on-demand In-Reply-To: <1c3be50f0802250754t4e3179f9vf41f0071a780509c@mail.gmail.com> References: <1c3be50f0802250729i7a6c044foc3a6577cbd00228a@mail.gmail.com> <8268eea30802250745h211bd4c3pa6be53d4cced7b90@mail.gmail.com> <1c3be50f0802250754t4e3179f9vf41f0071a780509c@mail.gmail.com> Message-ID: <290b3ba10802250808pd38e189r32edb538a6b828aa@mail.gmail.com> Have a look at http://erlang.org/doc/design_principles/part_frame.html section 5.9 Simple-One-For-One Supervisors for details. Regards t 2008/2/25 Juan Jose Comellas : > Don't I have to call supervisor:start_link() before issuing a start_child()? > What would I return from the Module:init() callback that is called from > supervisor:start_link()? Right now this is what this function looks like: > > init([Provider, Host, Port, Password]) -> > {{one_for_one, 1, 60}, > [{Provider, {fs_provider, start_link, [provider_name(Provider), Host, > Port, Password]}, > transient, 15, worker, [fs_provider]}]}. > > I tried calling supervisor:start_link() at the beginning of my program and > returning 'ignore' from the Module:init() callback but the supervisor would > not start. > > > > > > On 2/25/08, Andreas Hillqvist wrote: > > Hi. > > > > It sounds like simple_one_for_one would work for you. > > It is possible to pass the id or any additional parameters to start_child: > > supervisor:start_child(SupRef, [YourId]) > > > > > > Regards > > Andreas Hillqvist > > > > 2008/2/25, Juan Jose Comellas : > > > > > I have the following scenario and I'm not really sure of how to > represent it > > > with OTP. I have an application (appmod) running within Yaws that has to > > > create a worker process every time it receives an HTTP request.The > worker > > > process is created for a specific ID that comes with the request and for > > > different requests that contain the same ID, the same worker process > must be > > > used. Once instantiated, the worker process must remain up and until it > is > > > explicitly stopped. > > > > > > I want to monitor the worker processes with an OTP supervisor, but so > far > > > I'm not completely sure of what the correct approach should be. Should I > > > call supervisor:start_link() the first time I get a request for a > specific > > > ID and then supervisor:start_child() for the following ones? Or should I > > > just create one supervisor process per worker process I have? Can anyone > > > share some tips with me on how to design a solution for this problem > within > > > OTP? > > > > > > Thanks. > > > > > > > > > > > _______________________________________________ > > > erlang-questions mailing list > > > erlang-questions > > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > From golubovsky Mon Feb 25 17:58:37 2008 From: golubovsky (Dimitry Golubovsky) Date: Mon, 25 Feb 2008 11:58:37 -0500 Subject: [erlang-questions] (newbie) How to install Erlang selectively Message-ID: Hi, I need to perform a customized/selective Erlang installation, basically only kernel, sasl, stdlib (and whatever they require, but nothing beyond that). How can I do that? Just doing configure; make; make install gives me over 80M installation. I looked at CEAN, but it has only R11 available, I would like to have R12. Thanks. Please cc: to golubovsky -- Dimitry Golubovsky Anywhere on the Web From ahmed.diaa Mon Feb 25 18:28:06 2008 From: ahmed.diaa (Ahmed Diaa) Date: Mon, 25 Feb 2008 18:28:06 +0100 Subject: [erlang-questions] Distributed Erlang In-Reply-To: References: Message-ID: Thanks Matthew it was a problem of DNS , i solved it by editing the /etc/hosts file adding entires for the 2 machines , ip address vs. host names now it works Thanks again Best Regards -----Original Message----- From: Matthew Dempsky [mailto:matthew] Sent: Monday, February 25, 2008 1:24 PM To: Ahmed Diaa Cc: Erlang Questions Subject: Re: [erlang-questions] Distributed Erlang (Please reply to the list so that others might answer as well.) On 2/25/08, Ahmed Diaa wrote: > Thanks mathew > i started erlang like this > On Machine 1 : > erl -name node1 -setcookie abc > On Machine 2 : > erl -name node2 -setcookie abc > > so? And what does node() return on each node? Do the host name parts of those resolve in DNS correctly? Does IP allow traffic to pass between them correctly? E.g., if node() returns node1, does "ping machine-1.ericsson.com" work on Machine 2? Are there any firewalls between the machines that would block TCP traffic to port 4369 or any higher ports? E.g., does "telnet machine-1.ericsson.com 4369" print "Connected to [something]." or does it hang at "Trying [some IP]..."? If TCP traffic to port 4369 is working, check the output of inet:i() on machine 1, and look for a listening socket, something like: 6 inet_tcp 0 0 <0.20.0> *:52549 *:* ACCEPTING In this case, what does "telnet machine-1.ericsson.com 52549" (substituting 52549 as appropriate) do when run on Machine 2? From kg9020 Mon Feb 25 19:16:23 2008 From: kg9020 (kg9020) Date: Mon, 25 Feb 2008 12:16:23 -0600 Subject: [erlang-questions] Erlang RB12-1 Mac OS X Leopard problems Message-ID: <96fd17a20802251016x46dc40d5qc3338ae9fb183a50@mail.gmail.com> Hello, Is there anyone else having problems with RB12-1 tried several configure options like darwin-universal would not build. When I did get a build to work erl c(program) gave file error I went back to RB12-0 able to build with 64 bit smp .. no problems same configure on RB12-1 fails. aezbizs-macbook-pro-17:doc a$ sw_vers ProductName: Mac OS X ProductVersion: 10.5.2 BuildVersion: 9C31 aezbizs-macbook-pro-17:doc a$ sw_vers ProductName: Mac OS X ProductVersion: 10.5.2 BuildVersion: 9C31 Let me know if more information is needed thanks art -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080225/ab423f91/attachment.html From thomasl_erlang Mon Feb 25 19:34:43 2008 From: thomasl_erlang (Thomas Lindgren) Date: Mon, 25 Feb 2008 10:34:43 -0800 (PST) Subject: [erlang-questions] (newbie) How to install Erlang selectively In-Reply-To: Message-ID: <185529.99632.qm@web38804.mail.mud.yahoo.com> --- Dimitry Golubovsky wrote: > Hi, > > I need to perform a customized/selective Erlang > installation, > basically only kernel, sasl, stdlib (and whatever > they require, but > nothing beyond that). Create a 'release' containing only the applications you need. Have a look at the OTP docs for how to do this. Best, Thomas ____________________________________________________________________________________ Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping From twoggle Mon Feb 25 21:35:07 2008 From: twoggle (Tim Fletcher) Date: Mon, 25 Feb 2008 20:35:07 +0000 Subject: [erlang-questions] how: to serialize a function? Message-ID: Given an example function like so: > F = fun(X) -> X * X end. My first question is: how can I serialize (and de-serialize) that function completely (i.e. including its args)? I know that it's easy to send that function between processes/nodes, but how do I replicate that serialization myself? Next, given that I can get a string representation of the function like so: > erlang:fun_to_list(F). "#Fun" My second question is: what function do I use to turn that string back into (a proper "reference" to) the function F? From lucindo Mon Feb 25 21:51:38 2008 From: lucindo (Renato Lucindo) Date: Mon, 25 Feb 2008 17:51:38 -0300 Subject: [erlang-questions] how: to serialize a function? In-Reply-To: References: Message-ID: <49376cdb0802251251r10be0940s71bbba08c2dc45b5@mail.gmail.com> 1> F = fun(X) -> X * X end. #Fun 2> B = term_to_binary(F). <<131,112,0,0,2,177,1,193,97,132,164,217,241,72,144,2,77, 131,144,112,241,112,21,0,0,0,2,0,0,...>> %%% you can send the binary to other processes 3> apply(F, [2]). 4 4> apply(binary_to_term(B), [2]). 4 5> []'s Lucindo On Mon, Feb 25, 2008 at 5:35 PM, Tim Fletcher wrote: > Given an example function like so: > > > F = fun(X) -> X * X end. > > My first question is: how can I serialize (and de-serialize) that > function completely (i.e. including its args)? I know that it's easy > to send that function between processes/nodes, but how do I replicate > that serialization myself? > > Next, given that I can get a string representation of the function like so: > > > erlang:fun_to_list(F). > "#Fun" > > My second question is: what function do I use to turn that string back > into (a proper "reference" to) the function F? > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > From matthew Mon Feb 25 22:10:00 2008 From: matthew (Matthew Dempsky) Date: Mon, 25 Feb 2008 13:10:00 -0800 Subject: [erlang-questions] how: to serialize a function? In-Reply-To: References: Message-ID: On 2/25/08, Tim Fletcher wrote: > Next, given that I can get a string representation of the function like so: > > > erlang:fun_to_list(F). > "#Fun" > > My second question is: what function do I use to turn that string back > into (a proper "reference" to) the function F? The string representation of a fun is insufficient to reconstruct the fun. It lacks important things like bound variables. You need to use term_to_binary and binary_to_term for that. From twoggle Mon Feb 25 22:16:32 2008 From: twoggle (Tim Fletcher) Date: Mon, 25 Feb 2008 21:16:32 +0000 Subject: [erlang-questions] how: to serialize a function? In-Reply-To: References: Message-ID: > The string representation of a fun is insufficient to reconstruct the > fun. It lacks important things like bound variables. You need to use > term_to_binary and binary_to_term for that. Just checking - I wasn't sure whether it was something that could somehow be "looked up" in the process that defined the function. Thanks both. From matthew Mon Feb 25 22:33:33 2008 From: matthew (Matthew Dempsky) Date: Mon, 25 Feb 2008 13:33:33 -0800 Subject: [erlang-questions] how: to serialize a function? In-Reply-To: References: Message-ID: On 2/25/08, Tim Fletcher wrote: > Just checking - I wasn't sure whether it was something that could > somehow be "looked up" in the process that defined the function. Nope, two different funs at the same place with different bound variables will have the same string representation, even though they're different terms: 1> A = fun() -> true end. #Fun 2> B = fun() -> false end. #Fun 3> A == B. false From lucindo Mon Feb 25 22:52:18 2008 From: lucindo (Renato Lucindo) Date: Mon, 25 Feb 2008 18:52:18 -0300 Subject: [erlang-questions] how: to serialize a function? In-Reply-To: References: Message-ID: <49376cdb0802251352g52430fd3lf74d0e7c50791ae5@mail.gmail.com> With some limitations its possible to use something like this: Eshell V5.6 (abort with ^G) 1> EvalStr = fun(Str) -> 1> {ok, Tokens, _} = erl_scan:string(Str), 1> {ok, [Form]} = erl_parse:parse_exprs(Tokens), 1> {value, Result, _} = erl_eval:expr(Form, erl_eval:new_bindings()), 1> Result 1> end. #Fun 2> FStr = "fun(X) -> X * X end.". "fun(X) -> X * X end." 3> F = EvalStr(FStr). #Fun 4> F(4). 16 5> GStr = "fun(X) -> A = 10, X * A end.". "fun(X) -> A = 10, X * A end." 6> G = EvalStr(GStr). #Fun 7> G(4). 40 8> []'s Lucindo On Mon, Feb 25, 2008 at 6:33 PM, Matthew Dempsky wrote: > On 2/25/08, Tim Fletcher wrote: > > > Just checking - I wasn't sure whether it was something that could > > somehow be "looked up" in the process that defined the function. > > Nope, two different funs at the same place with different bound > variables will have the same string representation, even though > they're different terms: > > 1> A = fun() -> true end. > #Fun > 2> B = fun() -> false end. > #Fun > 3> A == B. > false > > > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > From rvirding Tue Feb 26 01:58:55 2008 From: rvirding (Robert Virding) Date: Tue, 26 Feb 2008 01:58:55 +0100 Subject: [erlang-questions] Erlounge in San Francisco, 17-22 February In-Reply-To: <3dbc6d1c0802141903r2b38ceacsf4e4168921d20eab@mail.gmail.com> References: <3dbc6d1c0801190827l11ac1050yae37415a0e565270@mail.gmail.com> <3dbc6d1c0802011452v20c7df1fu966a326e8ed87e8b@mail.gmail.com> <76F389D3-F029-4EC3-9037-3D24B9ED6D15@gerakines.net> <3dbc6d1c0802071353v2873419x88587f630da567ac@mail.gmail.com> <3dbc6d1c0802121413o206a516ej1a9d328b3bf79d16@mail.gmail.com> <2FAE4954-2162-4B22-A1D4-CD6D88F736F0@ketralnis.com> <3dbc6d1c0802131542p4537805erca28764d804c9f0e@mail.gmail.com> <4C733E71-7C36-4F94-AD54-8D98BEFA5D12@ketralnis.com> <3dbc6d1c0802141903r2b38ceacsf4e4168921d20eab@mail.gmail.com> Message-ID: <3dbc6d1c0802251658t3618b17dg88b6c7dd6838a50d@mail.gmail.com> Thanks for the turn-out last Monday. It was fun to meet other Erlangers in San Francisco, especially, for me, new faces I hadn't met before. I'm back in Sweden now and managed to bring home some real US-flu. :-) Anyway I got the most important things done early on, like meeting the right people. I have 2 photos from the 21st amendment which I can post if there is interest. Thanks again, Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080226/5fcf3ccb/attachment.html From xmlarchitect Tue Feb 26 02:44:43 2008 From: xmlarchitect (=Bill.Barnhill) Date: Tue, 26 Feb 2008 01:44:43 +0000 (UTC) Subject: [erlang-questions] Erlang RB12-1 Mac OS X Leopard problems References: <96fd17a20802251016x46dc40d5qc3338ae9fb183a50@mail.gmail.com> Message-ID: gmail.com> writes: > > Is there anyone else having problems with RB12-1 > tried several configure options like darwin-universal would not build. > Had this this problem myself, with libgd seemingly the culprit. Built successfully by: ./configure \ --enable-smp-support \ --enable-hipe \ --enable-darwin-64bit \ --without-gd \ --enable-kernel-poll make sudo make install Hope that helps, =Bill.Barnhill Communitivity, Inc. From berlin.brown Tue Feb 26 06:20:38 2008 From: berlin.brown (Berlin Brown) Date: Tue, 26 Feb 2008 00:20:38 -0500 Subject: [erlang-questions] Erlang Testing frameworks, sorry. Message-ID: I have been researching the erlang test frameworks. I still can't come to a consensus on what to use. I can tell you my background and why I am trying to do and maybe you can help. I am used to junit/unit test driven development and ideally would like a stable system that has some of these properties. I have also been looking at the behavior driven systems like ruby's rspec and maybe combining the unit testing and behavior tests. Is there anything similar. I also, don't want to stray too far from what is established on the erlang platform ("When in rome?") So far, I want to use test server; it is unique but seems very stable and robust. http://www.erlang.org/project/test_server/index.html -- Berlin Brown http://botspiritcompany.com/botlist/spring/help/about.html From bengt.kleberg Tue Feb 26 08:08:07 2008 From: bengt.kleberg (Bengt Kleberg) Date: Tue, 26 Feb 2008 08:08:07 +0100 Subject: [erlang-questions] Erlang Testing frameworks, sorry. In-Reply-To: References: Message-ID: <1204009687.5644.33.camel@seasc0625.dyn.rnd.as.sw.ericsson.se> Greetings, You do not mention if you have looked in the FAQ: http://erlang.org/faq/faq.html#AEN785 In addition to those there is also Eunit (http://svn.process-one.net/contribs/trunk/eunit/doc/overview-summary.html) and yatsy (http://code.google.com/p/yatsy/) bengt On Tue, 2008-02-26 at 00:20 -0500, Berlin Brown wrote: > I have been researching the erlang test frameworks. I still can't > come to a consensus on what to use. > > I can tell you my background and why I am trying to do and maybe you can help. > > I am used to junit/unit test driven development and ideally would like > a stable system that has some of these properties. I have also been > looking at the behavior driven systems like ruby's rspec and maybe > combining the unit testing and behavior tests. > > Is there anything similar. I also, don't want to stray too far from > what is established on the erlang platform ("When in rome?") > > So far, I want to use test server; it is unique but seems very stable > and robust. > http://www.erlang.org/project/test_server/index.html > From ulf.wiger Tue Feb 26 08:33:06 2008 From: ulf.wiger (Ulf Wiger (TN/EAB)) Date: Tue, 26 Feb 2008 08:33:06 +0100 Subject: [erlang-questions] Erlang Testing frameworks, sorry. In-Reply-To: References: Message-ID: <47C3C0B2.2070703@ericsson.com> Berlin Brown skrev: > > So far, I want to use test server; it is unique but seems very stable > and robust. > http://www.erlang.org/project/test_server/index.html As of OTP R12B, Common Test is a supported part of OTP. http://www.erlang.org/doc/apps/common_test/index.html It is used for test automation for some very important products within Ericsson. BR, Ulf W From Dmitri.Girenko Tue Feb 26 08:51:24 2008 From: Dmitri.Girenko (Dmitri Girenko) Date: Tue, 26 Feb 2008 09:51:24 +0200 Subject: [erlang-questions] filelib:fold_files (file:list_dir) and unicode filesystems Message-ID: <697074A35ED91748882E3850BDCE295EE093E5@leenu.akumiitti.net> Hi all, I have a process that monitors specific folders for changed files. The problem is that when a filename contains Unicode characters which are outside of the system default codepage (Latin-1), those files are just invisible to erlang. There's a workaround for linux - using UTF-8 translation seems to work, but apparently it doesn't work on windows. I think that once the "string as a list" problem is settled down, then the efile driver should be updated to support Unicode filenames, maybe using UTF-16 string encoding, rather than UTF-8. Are there any plans to do this? Dmitri Girenko Porkkalankatu 13C 00180 Helsinki, Finland Tel: +358-201-500-574 Mobile: +358-50-40-333-21 Fax: +358-201-500-501 From andreas.hillqvist Tue Feb 26 08:56:31 2008 From: andreas.hillqvist (Andreas Hillqvist) Date: Tue, 26 Feb 2008 08:56:31 +0100 Subject: [erlang-questions] Supervisor on-demand In-Reply-To: <1c3be50f0802250754t4e3179f9vf41f0071a780509c@mail.gmail.com> References: <1c3be50f0802250729i7a6c044foc3a6577cbd00228a@mail.gmail.com> <8268eea30802250745h211bd4c3pa6be53d4cced7b90@mail.gmail.com> <1c3be50f0802250754t4e3179f9vf41f0071a780509c@mail.gmail.com> Message-ID: <8268eea30802252356w4ff80115i6c9eff2e1f9df88c@mail.gmail.com> Could you clarify: "the worker process must remain up"? I do not belive that a simple_one_for_one supervisor restars a process if it crash. So if you want your child processe to restart if they crash, you will probebly need a one_for_one supervisor. In any case you will have to call: supervisor:start_link() I belive returning ignore from Module:init() cancels the supervisor startup. Regards Andreas Hillqvist 2008/2/25, Juan Jose Comellas : > Don't I have to call supervisor:start_link() before issuing a start_child()? > What would I return from the Module:init() callback that is called from > supervisor:start_link()? Right now this is what this function looks like: > > init([Provider, Host, Port, Password]) -> > {{one_for_one, 1, 60}, > [{Provider, {fs_provider, start_link, [provider_name(Provider), Host, > Port, Password]}, > transient, 15, worker, [fs_provider]}]}. > > I tried calling supervisor:start_link() at the beginning of my program and > returning 'ignore' from the Module:init() callback but the supervisor would > not start. > > > > > On 2/25/08, Andreas Hillqvist wrote: > > Hi. > > > > It sounds like simple_one_for_one would work for you. > > It is possible to pass the id or any additional parameters to start_child: > > supervisor:start_child(SupRef, [YourId]) > > > > > > Regards > > Andreas Hillqvist > > > > 2008/2/25, Juan Jose Comellas : > > > > > I have the following scenario and I'm not really sure of how to > represent it > > > with OTP. I have an application (appmod) running within Yaws that has to > > > create a worker process every time it receives an HTTP request.The > worker > > > process is created for a specific ID that comes with the request and for > > > different requests that contain the same ID, the same worker process > must be > > > used. Once instantiated, the worker process must remain up and until it > is > > > explicitly stopped. > > > > > > I want to monitor the worker processes with an OTP supervisor, but so > far > > > I'm not completely sure of what the correct approach should be. Should I > > > call supervisor:start_link() the first time I get a request for a > specific > > > ID and then supervisor:start_child() for the following ones? Or should I > > > just create one supervisor process per worker process I have? Can anyone > > > share some tips with me on how to design a solution for this problem > within > > > OTP? > > > > > > Thanks. > > > > > > > > > > > _______________________________________________ > > > erlang-questions mailing list > > > erlang-questions > > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > From bengt.kleberg Tue Feb 26 09:40:10 2008 From: bengt.kleberg (Bengt Kleberg) Date: Tue, 26 Feb 2008 09:40:10 +0100 Subject: [erlang-questions] filelib:fold_files (file:list_dir) and unicode filesystems In-Reply-To: <697074A35ED91748882E3850BDCE295EE093E5@leenu.akumiitti.net> References: <697074A35ED91748882E3850BDCE295EE093E5@leenu.akumiitti.net> Message-ID: <1204015210.5644.56.camel@seasc0625.dyn.rnd.as.sw.ericsson.se> Greetings, How do you mean "invisible to erlang"? I have a file called ???. It was created in a plan9 tool (http://plan9.bell-labs.com/sys/doc/acme.html) and plan9 uses unicode throughout (http://plan9.bell-labs.com/sys/doc/utf.html). Using default settings on unix the file is displayed as ??????. Using erlang the file is also ?????? . ; erl Eshell V5.5.5.5 (abort with ^G) 2> ls(). ?????? ok bengt On Tue, 2008-02-26 at 09:51 +0200, Dmitri Girenko wrote: > Hi all, > > I have a process that monitors specific folders for changed files. The > problem is that when a filename contains Unicode characters which are > outside of the system default codepage (Latin-1), those files are just > invisible to erlang. > > There's a workaround for linux - using UTF-8 translation seems to work, > but apparently it doesn't work on windows. > > I think that once the "string as a list" problem is settled down, then > the efile driver should be updated to support Unicode filenames, maybe > using UTF-16 string encoding, rather than UTF-8. > > Are there any plans to do this? > > Dmitri Girenko > > Porkkalankatu 13C 00180 > Helsinki, Finland > Tel: +358-201-500-574 > Mobile: +358-50-40-333-21 > Fax: +358-201-500-501 > > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions From Dmitri.Girenko Tue Feb 26 12:03:12 2008 From: Dmitri.Girenko (Dmitri Girenko) Date: Tue, 26 Feb 2008 13:03:12 +0200 Subject: [erlang-questions] filelib:fold_files (file:list_dir)and unicode filesystems In-Reply-To: <1204015210.5644.56.camel@seasc0625.dyn.rnd.as.sw.ericsson.se> References: <697074A35ED91748882E3850BDCE295EE093E5@leenu.akumiitti.net> <1204015210.5644.56.camel@seasc0625.dyn.rnd.as.sw.ericsson.se> Message-ID: <697074A35ED91748882E3850BDCE295EE093F2@leenu.akumiitti.net> Hello, > Greetings, > > How do you mean "invisible to erlang"? > > I have a file called ???. It was created in a plan9 tool > (http://plan9.bell-labs.com/sys/doc/acme.html) and plan9 uses unicode > throughout (http://plan9.bell-labs.com/sys/doc/utf.html). Using default > settings on unix the file is displayed as ??????. Using erlang the file > is also ?????? . I'm sorry, I should had been more specific. You are right, this is a UTF-8 encoded file name and this is a possible workaround for *nix systems. (The name later has to be kept in UTF-8 or translated to UTF-16 if needed). But on windows I have the following: ________________ Erlang (BEAM) emulator version 5.6 [smp:2] [async-threads:0] Eshell V5.6 (abort with ^G) 1> ls(). 1.txt 128.css ????.txt 2> filelib:fold_files(".",".*txt",false,fun(F,_)->io:format("~s~n",[F]) end, []). ./1.txt Ok 4> file:list_dir("."). {ok,["????.txt","1.txt"]} So list_dir sees as "????" and fold_files does not show it at all. Is that regexp matching problem or file listing? Also, it is impossible to open that file for IO. Probably using utf-8 on *nix seems to be a sufficient workaround and win32 compatibility... has to be ... well, you know (: BR Dmitri > ; erl > Eshell V5.5.5.5 (abort with ^G) > 2> ls(). > ?????? > ok > > > bengt > > On Tue, 2008-02-26 at 09:51 +0200, Dmitri Girenko wrote: > > Hi all, > > > > I have a process that monitors specific folders for changed files. The > > problem is that when a filename contains Unicode characters which are > > outside of the system default codepage (Latin-1), those files are just > > invisible to erlang. > > > > There's a workaround for linux - using UTF-8 translation seems to work, > > but apparently it doesn't work on windows. > > > > I think that once the "string as a list" problem is settled down, then > > the efile driver should be updated to support Unicode filenames, maybe > > using UTF-16 string encoding, rather than UTF-8. > > > > Are there any plans to do this? > > > > Dmitri Girenko > > > > Porkkalankatu 13C 00180 > > Helsinki, Finland > > Tel: +358-201-500-574 > > Mobile: +358-50-40-333-21 > > Fax: +358-201-500-501 > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions > > http://www.erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions From matthias Tue Feb 26 12:40:42 2008 From: matthias (Matthias Lang) Date: Tue, 26 Feb 2008 12:40:42 +0100 Subject: [erlang-questions] Erlounge Stockholm Tuesday March 4 Message-ID: <18371.64186.572194.775614@antilipe.corelatus.se> Hi, A few of us are getting together for some beers, a bite to eat and some nominally Erlang-related conversation next week, Tuesday 4. March at the Corelatus pub, officially known as "Man in the Moon", Tegnergatan 2 in Stockholm, starting at about 18:30. Here's a phone book map: http://hitta.se/ViewDetailsPink.aspx?vad=man+in+the+moon&var=&Vkiid=hnXidcC%2fB%2flidWoexPllNQ%3d%3d&Vkid=13307057&isAlternateNumberResult=False I'm going to book a table. If you tell me you're coming, I'll book more. Matt From dzuikov Tue Feb 26 14:57:46 2008 From: dzuikov (Dmitry Zuikov) Date: Tue, 26 Feb 2008 16:57:46 +0300 Subject: [erlang-questions] Load balancing with pool Message-ID: <188935990802260557s7b9821dbif1e27feb117cde64@mail.gmail.com> Hi All, Could anybody point me a manual or an example or something to learn how to use pool to run OTP application on several nodes and balance loading between them. I have read the standard manual for pool but still have no idea how to apply it. Could I make an already written OTP application to run on cluster, or I have to rewrite it with pool:pspawn_link instead of spawn_link ? Thanks in advance, --- Regards Dmitry -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080226/8fdf5e90/attachment.html From kg9020 Tue Feb 26 15:44:07 2008 From: kg9020 (kg9020) Date: Tue, 26 Feb 2008 08:44:07 -0600 Subject: [erlang-questions] Erlang RB12-1 Mac OS X Leopard problems Message-ID: <96fd17a20802260644k16912008i9906937f2740b8b1@mail.gmail.com> Follow up on RB12-1/configure --enable-threads --enable-smp-support --enable-kernel-poll --enable-darwin-64bit --without-gd make resulted in follow error Undefined symbols: "_main", referenced from: start in crt1.10.5.o ld: symbol(s) not found collect2: ld returned 1 exit status make[4]: *** [../priv/bin/i386-apple-darwin9.2.0/obj_init_port] Error 1 make[3]: *** [opt] Error 2 make[2]: *** [opt] Error 2 make[1]: *** [opt] Error 2 make: *** [libs] Error 2 art 2008/2/26 : > Send erlang-questions mailing list submissions to > erlang-questions > > To subscribe or unsubscribe via the World Wide Web, visit > http://www.erlang.org/mailman/listinfo/erlang-questions > or, via email, send a message with subject or body 'help' to > erlang-questions-request > > You can reach the person managing the list at > erlang-questions-owner > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of erlang-questions digest..." > > Today's Topics: > > 1. Erlang RB12-1 Mac OS X Leopard problems (kg9020) > 2. Re: (newbie) How to install Erlang selectively (Thomas Lindgren) > 3. how: to serialize a function? (Tim Fletcher) > 4. Re: how: to serialize a function? (Renato Lucindo) > 5. Re: how: to serialize a function? (Matthew Dempsky) > 6. Re: how: to serialize a function? (Tim Fletcher) > 7. Re: how: to serialize a function? (Matthew Dempsky) > 8. Re: how: to serialize a function? (Renato Lucindo) > 9. Re: Erlounge in San Francisco, 17-22 February (Robert Virding) > 10. Re: Erlang RB12-1 Mac OS X Leopard problems (=Bill.Barnhill) > 11. Erlang Testing frameworks, sorry. (Berlin Brown) > 12. Re: Erlang Testing frameworks, sorry. (Bengt Kleberg) > > > ---------- Forwarded message ---------- > From: kg9020 > To: erlang-questions > Date: Mon, 25 Feb 2008 12:16:23 -0600 > Subject: [erlang-questions] Erlang RB12-1 Mac OS X Leopard problems > Hello, > Is there anyone else having problems with RB12-1 > tried several configure options like darwin-universal would not build. > > When I did get a build to work > erl c(program) gave file error > > I went back to RB12-0 able to build with 64 bit smp .. no problems > same configure on RB12-1 fails. > > aezbizs-macbook-pro-17:doc a$ sw_vers > ProductName: Mac OS X > ProductVersion: 10.5.2 > BuildVersion: 9C31 > > aezbizs-macbook-pro-17:doc a$ sw_vers > ProductName: Mac OS X > ProductVersion: 10.5.2 > BuildVersion: 9C31 > > Let me know if more information is needed > > thanks > > art > > > > > ---------- Forwarded message ---------- > From: Thomas Lindgren > To: erlang-questions > Date: Mon, 25 Feb 2008 10:34:43 -0800 (PST) > Subject: Re: [erlang-questions] (newbie) How to install Erlang selectively > > --- Dimitry Golubovsky wrote: > > > Hi, > > > > I need to perform a customized/selective Erlang > > installation, > > basically only kernel, sasl, stdlib (and whatever > > they require, but > > nothing beyond that). > > Create a 'release' containing only the applications > you need. Have a look at the OTP docs for how to do > this. > > Best, > Thomas > > > > > > ____________________________________________________________________________________ > Looking for last minute shopping deals? > Find them fast with Yahoo! Search. > http://tools.search.yahoo.com/newsearch/category.php?category=shopping > > > > ---------- Forwarded message ---------- > From: "Tim Fletcher" > To: erlang-questions > Date: Mon, 25 Feb 2008 20:35:07 +0000 > Subject: [erlang-questions] how: to serialize a function? > Given an example function like so: > > > F = fun(X) -> X * X end. > > My first question is: how can I serialize (and de-serialize) that > function completely (i.e. including its args)? I know that it's easy > to send that function between processes/nodes, but how do I replicate > that serialization myself? > > Next, given that I can get a string representation of the function like > so: > > > erlang:fun_to_list(F). > "#Fun" > > My second question is: what function do I use to turn that string back > into (a proper "reference" to) the function F? > > > > ---------- Forwarded message ---------- > From: "Renato Lucindo" > To: "Tim Fletcher" > Date: Mon, 25 Feb 2008 17:51:38 -0300 > Subject: Re: [erlang-questions] how: to serialize a function? > 1> F = fun(X) -> X * X end. > #Fun > 2> B = term_to_binary(F). > <<131,112,0,0,2,177,1,193,97,132,164,217,241,72,144,2,77, > 131,144,112,241,112,21,0,0,0,2,0,0,...>> > %%% you can send the binary to other processes > 3> apply(F, [2]). > 4 > 4> apply(binary_to_term(B), [2]). > 4 > 5> > > []'s > > Lucindo > > On Mon, Feb 25, 2008 at 5:35 PM, Tim Fletcher wrote: > > Given an example function like so: > > > > > F = fun(X) -> X * X end. > > > > My first question is: how can I serialize (and de-serialize) that > > function completely (i.e. including its args)? I know that it's easy > > to send that function between processes/nodes, but how do I replicate > > that serialization myself? > > > > Next, given that I can get a string representation of the function like > so: > > > > > erlang:fun_to_list(F). > > "#Fun" > > > > My second question is: what function do I use to turn that string back > > into (a proper "reference" to) the function F? > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > > ---------- Forwarded message ---------- > From: "Matthew Dempsky" > To: "Tim Fletcher" > Date: Mon, 25 Feb 2008 13:10:00 -0800 > Subject: Re: [erlang-questions] how: to serialize a function? > On 2/25/08, Tim Fletcher wrote: > > Next, given that I can get a string representation of the function like > so: > > > > > erlang:fun_to_list(F). > > "#Fun" > > > > My second question is: what function do I use to turn that string back > > into (a proper "reference" to) the function F? > > The string representation of a fun is insufficient to reconstruct the > fun. It lacks important things like bound variables. You need to use > term_to_binary and binary_to_term for that. > > > > ---------- Forwarded message ---------- > From: "Tim Fletcher" > To: "Matthew Dempsky" > Date: Mon, 25 Feb 2008 21:16:32 +0000 > Subject: Re: [erlang-questions] how: to serialize a function? > > The string representation of a fun is insufficient to reconstruct the > > fun. It lacks important things like bound variables. You need to use > > term_to_binary and binary_to_term for that. > > Just checking - I wasn't sure whether it was something that could > somehow be "looked up" in the process that defined the function. > > Thanks both. > > > > ---------- Forwarded message ---------- > From: "Matthew Dempsky" > To: "Tim Fletcher" > Date: Mon, 25 Feb 2008 13:33:33 -0800 > Subject: Re: [erlang-questions] how: to serialize a function? > On 2/25/08, Tim Fletcher wrote: > > Just checking - I wasn't sure whether it was something that could > > somehow be "looked up" in the process that defined the function. > > Nope, two different funs at the same place with different bound > variables will have the same string representation, even though > they're different terms: > > 1> A = fun() -> true end. > #Fun > 2> B = fun() -> false end. > #Fun > 3> A == B. > false > > > > ---------- Forwarded message ---------- > From: "Renato Lucindo" > To: "Matthew Dempsky" > Date: Mon, 25 Feb 2008 18:52:18 -0300 > Subject: Re: [erlang-questions] how: to serialize a function? > With some limitations its possible to use something like this: > > Eshell V5.6 (abort with ^G) > 1> EvalStr = fun(Str) -> > 1> {ok, Tokens, _} = erl_scan:string(Str), > 1> {ok, [Form]} = erl_parse:parse_exprs(Tokens), > 1> {value, Result, _} = erl_eval:expr(Form, erl_eval:new_bindings()), > 1> Result > 1> end. > #Fun > 2> FStr = "fun(X) -> X * X end.". > "fun(X) -> X * X end." > 3> F = EvalStr(FStr). > #Fun > 4> F(4). > 16 > 5> GStr = "fun(X) -> A = 10, X * A end.". > "fun(X) -> A = 10, X * A end." > 6> G = EvalStr(GStr). > #Fun > 7> G(4). > 40 > 8> > > []'s > > Lucindo > > On Mon, Feb 25, 2008 at 6:33 PM, Matthew Dempsky > wrote: > > On 2/25/08, Tim Fletcher wrote: > > > > > Just checking - I wasn't sure whether it was something that could > > > somehow be "looked up" in the process that defined the function. > > > > Nope, two different funs at the same place with different bound > > variables will have the same string representation, even though > > they're different terms: > > > > 1> A = fun() -> true end. > > #Fun > > 2> B = fun() -> false end. > > #Fun > > 3> A == B. > > false > > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > > ---------- Forwarded message ---------- > From: "Robert Virding" > To: "Erlang Questions" > Date: Tue, 26 Feb 2008 01:58:55 +0100 > Subject: Re: [erlang-questions] Erlounge in San Francisco, 17-22 February > Thanks for the turn-out last Monday. It was fun to meet other Erlangers in > San Francisco, especially, for me, new faces I hadn't met before. I'm back > in Sweden now and managed to bring home some real US-flu. :-) Anyway I got > the most important things done early on, like meeting the right people. > > I have 2 photos from the 21st amendment which I can post if there is > interest. > > Thanks again, > > Robert > > > > ---------- Forwarded message ---------- > From: "=Bill.Barnhill" > To: erlang-questions > Date: Tue, 26 Feb 2008 01:44:43 +0000 (UTC) > Subject: Re: [erlang-questions] Erlang RB12-1 Mac OS X Leopard problems > gmail.com> writes: > > > > > Is there anyone else having problems with RB12-1 > > tried several configure options like darwin-universal would not build. > > > > Had this this problem myself, with libgd seemingly the culprit. > > Built successfully by: > > ./configure \ > --enable-smp-support \ > --enable-hipe \ > --enable-darwin-64bit \ > --without-gd \ > --enable-kernel-poll > > make > > sudo make install > > > Hope that helps, > =Bill.Barnhill > Communitivity, Inc. > > > > > > > > ---------- Forwarded message ---------- > From: "Berlin Brown" > To: erlang-questions > Date: Tue, 26 Feb 2008 00:20:38 -0500 > Subject: [erlang-questions] Erlang Testing frameworks, sorry. > I have been researching the erlang test frameworks. I still can't > come to a consensus on what to use. > > I can tell you my background and why I am trying to do and maybe you can > help. > > I am used to junit/unit test driven development and ideally would like > a stable system that has some of these properties. I have also been > looking at the behavior driven systems like ruby's rspec and maybe > combining the unit testing and behavior tests. > > Is there anything similar. I also, don't want to stray too far from > what is established on the erlang platform ("When in rome?") > > So far, I want to use test server; it is unique but seems very stable > and robust. > http://www.erlang.org/project/test_server/index.html > > -- > Berlin Brown > http://botspiritcompany.com/botlist/spring/help/about.html > > > > ---------- Forwarded message ---------- > From: Bengt Kleberg > To: > Date: Tue, 26 Feb 2008 08:08:07 +0100 > Subject: Re: [erlang-questions] Erlang Testing frameworks, sorry. > Greetings, > > You do not mention if you have looked in the FAQ: > > http://erlang.org/faq/faq.html#AEN785 > > > In addition to those there is also > > Eunit > (http://svn.process-one.net/contribs/trunk/eunit/doc/overview-summary.html > ) > and > yatsy (http://code.google.com/p/yatsy/) > > > bengt > > On Tue, 2008-02-26 at 00:20 -0500, Berlin Brown wrote: > > I have been researching the erlang test frameworks. I still can't > > come to a consensus on what to use. > > > > I can tell you my background and why I am trying to do and maybe you can > help. > > > > I am used to junit/unit test driven development and ideally would like > > a stable system that has some of these properties. I have also been > > looking at the behavior driven systems like ruby's rspec and maybe > > combining the unit testing and behavior tests. > > > > Is there anything similar. I also, don't want to stray too far from > > what is established on the erlang platform ("When in rome?") > > > > So far, I want to use test server; it is unique but seems very stable > > and robust. > > http://www.erlang.org/project/test_server/index.html > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.erlang.org/pipermail/erlang-questions/attachments/20080226/d57b0eeb/attachment-0001.html From dizzyd Tue Feb 26 15:49:50 2008 From: dizzyd (Dave Smith) Date: Tue, 26 Feb 2008 07:49:50 -0700 Subject: [erlang-questions] Erlang Testing frameworks, sorry. In-Reply-To: <47C3C0B2.2070703@ericsson.com> References: <47C3C0B2.2070703@ericsson.com> Message-ID: Berlin, I recently went through this same decision process and finally decided to learn how to use Common Test. It's a part of the OTP distro, so you don't have to worry about maintaining a separate version of the testing framework somewhere and it's pretty easy to use once you get it setup. It has some really nice reporting tools and is clearly a very mature framework...it's just the install stuff that I have issues with. :) My "setup" involved investigating the run_test.in script found in erlang/lib/common_test-/priv. Once I figured out what that was doing, I wrote a macro (included below) for GNU make that makes it easy for me to add unit tests to an apps Makefile: # -------------------------------------------------------------------- # # Macro for running unit tests using common_test fx # # -------------------------------------------------------------------- define run-tests @mkdir -p test/logs @erl -pa $(PWD)/ebin $(PWD)/include \ -noshell -s ct_run script_start -s erlang halt \ -dir . -logdir test/logs \ -env TEST_DIR $(PWD)/test $* endef With that macro included in my make file, I can run tests by creating a directory named "test" and dropping test suites in that directory with the appropriate names (foo_SUITE.erl, as the case may be). I invoke the macro in my app's Makefile like so: test: $(run-tests) I know that this isn't the how the instructions in the common_test system recommends doing things. However, from my perspective requiring developers to copy the entire common_test and test_server apps to another directory just so a .in file can be processed is a little redundant. I'm sure there are downsides with my approach, but from a development standpoint it works and is easy to work with. Hope that helps... D. On Tue, Feb 26, 2008 at 12:33 AM, Ulf Wiger (TN/EAB) wrote: > Berlin Brown skrev: > > > > > So far, I want to use test server; it is unique but seems very stable > > and robust. > > http://www.erlang.org/project/test_server/index.html > > As of OTP R12B, Common Test is a supported part of OTP. > > http://www.erlang.org/doc/apps/common_test/index.html > > It is used for test automation for some very important > products within Ericsson. > > > BR, > Ulf W > > > _______________________________________________ > erlang-questions mailing list > erlang-questions > http://www.erlang.org/mailman/listinfo/erlang-questions > From kevin Tue Feb 26 16:04:08 2008 From: kevin (Kevin A. Smith) Date: Tue, 26 Feb 2008 10:04:08 -0500 Subject: [erlang-questions] Erlang RB12-1 Mac OS X Leopard problems In-Reply-To: <96fd17a20802260644k16912008i9906937f2740b8b1@mail.gmail.com> References: <96fd17a20802260644k16912008i9906937f2740b8b1@mail.gmail.com> Message-ID: <9E4F3D88-5639-41DA-A3A9-B701C8937C10@hypotheticalabs.com> Do you have all the Apple developer tools installed? And if you do, do you have the updated version for Leopard? --Kevin On Feb 26, 2008, at 9:44 AM, kg9020 wrote: > Follow up on RB12-1 > /configure --enable-threads --enable-smp-support --enable-kernel- > poll --enable-darwin-64bit --without-gd > > make resulted in follow error > > Undefined symbols: > "_main", referenced from: > start in crt1.10.5.o > ld: symbol(s) not found > collect2: ld returned 1 exit status > make[4]: *** [../priv/bin/i386-apple-darwin9.2.0/obj_init_port] > Error 1 > make[3]: *** [opt] Error 2 > make[2]: *** [opt] Error 2 > make[1]: *** [opt] Error 2 > make: *** [libs] Error 2 > > art > > > > 2008/2/26 : > Send erlang-questions mailing list submissions to > erlang-questions > > To subscribe or unsubscribe via the World Wide Web, visit > http://www.erlang.org/mailman/listinfo/erlang-questions > or, via email, send a message with subject or body 'help' to > erlang-questions-request > > You can reach the person managing the list at > erlang-questions-owner > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of erlang-questions digest..." > > Today's Topics: > > 1. Erlang RB12-1 Mac OS X Leopard problems (kg9020) > 2. Re: (newbie) How to install Erlang selectively (Thomas Lindgren) > 3. how: to serialize a function? (Tim Fletcher) > 4. Re: how: to serialize a function? (Renato Lucindo) > 5. Re: how: to serialize a function? (Matthew Dempsky) > 6. Re: how: to serialize a function? (Tim Fletcher) > 7. Re: how: to serialize a function? (Matthew Dempsky) > 8. Re: how: to serialize a function? (Renato Lucindo) > 9. Re: Erlounge in San Francisco, 17-22 February (Robert Virding) > 10. Re: Erlang RB12-1 Mac OS X Leopard problems (=Bill.Barnhill) > 11. Erlang Testing frameworks, sorry. (Berlin Brown) > 12. Re: Erlang Testing frameworks, sorry. (Bengt Kleberg) > > > ---------- Forwarded message ---------- > From: kg9020 > To: erlang-questions > Date: Mon, 25 Feb 2008 12:16:23 -0600 > Subject: [erlang-questions] Erlang RB12-1 Mac OS X Leopard problems > Hello, > > Is there anyone else having problems with RB12-1 > tried several configure options like darwin-universal would not build. > > When I did get a build to work > erl c(program) gave file error > > I went back to RB12-0 able to build with 64 bit smp .. no problems > same configure on RB12-1 fails. > > aezbizs-macbook-pro-17:doc a$ sw_vers > ProductName: Mac OS X > ProductVersion: 10.5.2 > BuildVersion: 9C31 > > aezbizs-macbook-pro-17:doc a$ sw_vers > ProductName: Mac OS X > ProductVersion: 10.5.2 > BuildVersion: 9C31 > > Let me know if more information is needed > > thanks > > art > > > > > ---------- Forwarded message ---------- > From: Thomas Lindgren > To: erlang-questions > Date: Mon, 25 Feb 2008 10:34:43 -0800 (PST) > Subject: Re: [erlang-questions] (newbie) How to install Erlang > selectively > > --- Dimitry Golubovsky wrote: > > > Hi, > > > > I need to perform a customized/selective Erlang > > installation, > > basically only kernel, sasl, stdlib (and whatever > > they require, but > > nothing beyond that). > > Create a 'release' containing only the applications > you need. Have a look at the OTP docs for how to do > this. > > Best, > Thomas > > > > > > ____________________________________________________________________________________ > Looking for last minute shopping deals? > Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping > > > > ---------- Forwarded message ---------- > From: "Tim Fletcher" > To: erlang-questions > Date: Mon, 25 Feb 2008 20:35:07 +0000 > Subject: [erlang-questions] how: to serialize a function? > Given an example function like so: > > > F = fun(X) -> X * X end. > > My first question is: how can I serialize (and de-serialize) that > function completely (i.e. including its args)? I know that it's easy > to send that function between processes/nodes, but how do I replicate > that serialization myself? > > Next, given that I can get a string representation of the function > like so: > > > erlang:fun_to_list(F). > "#Fun" > > My second question is: what function do I use to turn that string back > into (a proper "reference" to) the function F? > > > > ---------- Forwarded message ---------- > From: "Renato Lucindo" > To: "Tim Fletcher" > Date: Mon, 25 Feb 2008 17:51:38 -0300 > Subject: Re: [erlang-questions] how: to serialize a function? > 1> F = fun(X) -> X * X end. > #Fun > 2> B = term_to_binary(F). > <<131,112,0,0,2,177,1,193,97,132,164,217,241,72,144