From dizzyd@REDACTED Thu May 1 00:22:14 2008 From: dizzyd@REDACTED (Dave Smith) Date: Wed, 30 Apr 2008 16:22:14 -0600 Subject: [erlang-questions] gen_tcp nonblocking send In-Reply-To: <4818E6BD.2020402@ot-e.biz> References: <4818E6BD.2020402@ot-e.biz> Message-ID: It is my understanding that gen_tcp:send never blocks, since it's just queuing up a message for the process handling the socket. If I had to guess, I'd say that under the covers it's queuing up the data using the driver_enq (see ERTS erl_driver) and then when the socket is ready to write, the VM pushes that data into the socket (since all sockets are non-blocking in the VM, or so I would presume). Hope that helps... D. On Wed, Apr 30, 2008 at 3:38 PM, Daniel Ginsburg wrote: > Is there any way to make gen_tcp:send operate in non-blocking mode? > > As I read the documentation, there are two possible ways to handle > stalling reader: > 1) block forever > 2) use {send_timeout, N} and when timeout occurs, close the socket. > > In my application 2 is unacceptable and 1 is suboptimal. > > What I'd really like to have is an opportunity to know that kernel send > buffer is filled and send would block, and conversely, when stalled > receiver has recovered and I can send more data. It that possible with > standard erlang library? I'd really hate to write my own driver to > handle this. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From jarrod@REDACTED Thu May 1 00:24:32 2008 From: jarrod@REDACTED (Jarrod Roberson) Date: Wed, 30 Apr 2008 18:24:32 -0400 Subject: [erlang-questions] what is the correct syntax to spawm a MFA with no arguments? In-Reply-To: <4818E171.2000701@rldn.net> References: <4818E171.2000701@rldn.net> Message-ID: > yes thanks to everyone who has responded, I was just hoping there is another way without having to -export what appears _should_ be a "private" implementation detail. -------------- next part -------------- An HTML attachment was scrubbed... URL: From kevin@REDACTED Thu May 1 00:44:34 2008 From: kevin@REDACTED (Kevin Scaldeferri) Date: Wed, 30 Apr 2008 15:44:34 -0700 Subject: [erlang-questions] what is the correct syntax to spawm a MFA with no arguments? In-Reply-To: References: <4818E171.2000701@rldn.net> Message-ID: On Apr 30, 2008, at 3:24 PM, Jarrod Roberson wrote: > > yes thanks to everyone who has responded, I was just hoping there is > another way without having to -export what appears _should_ be a > "private" implementation detail. What was wrong with spawn(fun loop/0)? Because I believe that's considered the usual way to address this issue. From rvirding@REDACTED Thu May 1 00:55:16 2008 From: rvirding@REDACTED (Robert Virding) Date: Thu, 1 May 2008 00:55:16 +0200 Subject: [erlang-questions] what is the correct syntax to spawm a MFA with no arguments? In-Reply-To: References: <4818E171.2000701@rldn.net> Message-ID: <3dbc6d1c0804301555i3bd04d28nd77e5d74860273d2@mail.gmail.com> That, unfortunately, is a property of spawning MFA and it has been since the beginning of time (AE Anno Erlang). It was also the major reason for adding spawning a fun, to avoiding exporting private functions. So you either spawn MFA and export, or spawn a fun and don't. Robert 2008/5/1 Jarrod Roberson : > > yes thanks to everyone who has responded, I was just hoping there is > another way without having to -export what appears _should_ be a "private" > implementation detail. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dg@REDACTED Thu May 1 01:01:43 2008 From: dg@REDACTED (Daniel Ginsburg) Date: Thu, 01 May 2008 03:01:43 +0400 Subject: [erlang-questions] gen_tcp nonblocking send In-Reply-To: References: <4818E6BD.2020402@ot-e.biz> Message-ID: <4818FA57.4080406@ot-e.biz> Dave Smith wrote: > It is my understanding that gen_tcp:send never blocks, since it's just > queuing up a message for the process handling the socket. If I had to > guess, I'd say that under the covers it's queuing up the data using > the driver_enq (see ERTS erl_driver) and then when the socket is ready > to write, the VM pushes that data into the socket (since all sockets > are non-blocking in the VM, or so I would presume). > > Hope that helps... > > D. > > Well, gen_tcp:send does block, and it is quite easy to verify it. If gen_tcp:send would never block by always queueing send-request, it would be even worse, because such behavior would give no backpressure to fast sender and make request queue to build up possibly indefinitely. One way or another, it doesn't solve my problem. Let me expand a little bit on it. What I have is a protocol which basically sends {key, value} over TCP connection. Set of keys is large but limited. Receiver is not really interested to hear all the changes of value for a particular key, it just wants to know the most recent values for a key. It is also very important to communicate changes of value for any key as fast as possible. In case when receiver is able to cope with the load, the best tactic is to send all the changes as soon as they occur. But when receiver is overloaded (or there's network congestion), there's important optimization. If we have {k1, val1} sitting in queue and there's another update for that key, we can, instead of adding it to the queue, simply replace {k1, val1} with {k1, val2}. Thus saving network resources and reducing load on receiver. In order to do that, I need to keep my own queue and I need a way to know when it is safe to start dequeuing pairs and send them to the socket. Now I deal with the situation by use of hold-off timer. When I send a pair with key k1, I start a timer, and until the timer expires, all the updates for that key are delayed, unnecessary ones are dropped and replaced with the most recent version. It does help with overload, but it also delays updates when there's no overload or congestion. From igorrs@REDACTED Thu May 1 02:11:49 2008 From: igorrs@REDACTED (Igor Ribeiro Sucupira) Date: Wed, 30 Apr 2008 21:11:49 -0300 Subject: [erlang-questions] gen_tcp nonblocking send In-Reply-To: <4818E6BD.2020402@ot-e.biz> References: <4818E6BD.2020402@ot-e.biz> Message-ID: I don't think that is possible. Once you've sent data, there's no way to "unsend" it. If a timeout occurs, you never know how much of the data the receiver has got. Can't you close the socket and reconnect everytime you have a timeout? Igor. On Wed, Apr 30, 2008 at 6:38 PM, Daniel Ginsburg wrote: > > Is there any way to make gen_tcp:send operate in non-blocking mode? > > As I read the documentation, there are two possible ways to handle > stalling reader: > 1) block forever > 2) use {send_timeout, N} and when timeout occurs, close the socket. > > In my application 2 is unacceptable and 1 is suboptimal. > > What I'd really like to have is an opportunity to know that kernel send > buffer is filled and send would block, and conversely, when stalled > receiver has recovered and I can send more data. It that possible with > standard erlang library? I'd really hate to write my own driver to > handle this. From dizzyd@REDACTED Thu May 1 02:11:59 2008 From: dizzyd@REDACTED (Dave Smith) Date: Wed, 30 Apr 2008 18:11:59 -0600 Subject: [erlang-questions] gen_tcp nonblocking send In-Reply-To: <4818FA57.4080406@ot-e.biz> References: <4818E6BD.2020402@ot-e.biz> <4818FA57.4080406@ot-e.biz> Message-ID: On Wed, Apr 30, 2008 at 5:01 PM, Daniel Ginsburg wrote: > > Well, gen_tcp:send does block, and it is quite easy to verify it. You are, of course, right. :) A little digging turned up this link http://www.erlang.org/pipermail/erlang-questions/2006-April/019924.html where it discuss how the port is marked as busy and thus blocks the caller while the buffers are emptied. Very interesting and very stupid of me to comment without being certain of it. :) Thanks for helping me learn a bit more. D. From igorrs@REDACTED Thu May 1 02:44:32 2008 From: igorrs@REDACTED (Igor Ribeiro Sucupira) Date: Wed, 30 Apr 2008 21:44:32 -0300 Subject: [erlang-questions] gen_tcp nonblocking send In-Reply-To: <4818FA57.4080406@ot-e.biz> References: <4818E6BD.2020402@ot-e.biz> <4818FA57.4080406@ot-e.biz> Message-ID: On Wed, Apr 30, 2008 at 8:01 PM, Daniel Ginsburg wrote: > > Dave Smith wrote: > > It is my understanding that gen_tcp:send never blocks, since it's just > > queuing up a message for the process handling the socket. If I had to > > guess, I'd say that under the covers it's queuing up the data using > > the driver_enq (see ERTS erl_driver) and then when the socket is ready > > to write, the VM pushes that data into the socket (since all sockets > > are non-blocking in the VM, or so I would presume). > > > > Hope that helps... > > > > D. > > > > > Well, gen_tcp:send does block, and it is quite easy to verify it. > > If gen_tcp:send would never block by always queueing send-request, it > would be even worse, because such behavior would give no backpressure to > fast sender and make request queue to build up possibly indefinitely. > > One way or another, it doesn't solve my problem. Let me expand a little > bit on it. > > What I have is a protocol which basically sends {key, value} over TCP > connection. Set of keys is large but limited. Receiver is not really > interested to hear all the changes of value for a particular key, it > just wants to know the most recent values for a key. It is also very > important to communicate changes of value for any key as fast as possible. > > In case when receiver is able to cope with the load, the best tactic is > to send all the changes as soon as they occur. But when receiver is > overloaded (or there's network congestion), there's important > optimization. If we have {k1, val1} sitting in queue and there's another > update for that key, we can, instead of adding it to the queue, simply > replace {k1, val1} with {k1, val2}. Thus saving network resources and > reducing load on receiver. In order to do that, I need to keep my own > queue and I need a way to know when it is safe to start dequeuing pairs > and send them to the socket. > > Now I deal with the situation by use of hold-off timer. When I send a > pair with key k1, I start a timer, and until the timer expires, all the > updates for that key are delayed, unnecessary ones are dropped and > replaced with the most recent version. It does help with overload, but > it also delays updates when there's no overload or congestion. I don't think it's safe to set a send_timeout and then keep sending data after a timeout occurs. Your best option is probably to wait until the server has received the current key/value you're sending. After the operation is completed, you can, of course, send the most recent value of the key, supposing it has been updated. Igor. From dnew@REDACTED Thu May 1 03:03:20 2008 From: dnew@REDACTED (Darren New) Date: Wed, 30 Apr 2008 18:03:20 -0700 Subject: [erlang-questions] what is the correct syntax to spawm a MFA with no arguments? In-Reply-To: <3dbc6d1c0804301555i3bd04d28nd77e5d74860273d2@mail.gmail.com> References: <4818E171.2000701@rldn.net> <3dbc6d1c0804301555i3bd04d28nd77e5d74860273d2@mail.gmail.com> Message-ID: <481916D8.10408@san.rr.com> Robert Virding wrote: > That, unfortunately, is a property of spawning MFA and it has been since > the beginning of time (AE Anno Erlang). I know very little about Erlang overall, but isn't the point of exporting this to make it available for code upgrades? I.e., without exporting the entry, it would be very difficult to have spawn(M,F,A) spawn code that had changed recently, yes? -- Darren New / San Diego, CA, USA (PST) "That's pretty. Where's that?" "It's the Age of Channelwood." "We should go there on vacation some time." From saleyn@REDACTED Thu May 1 04:36:59 2008 From: saleyn@REDACTED (Serge Aleynikov) Date: Wed, 30 Apr 2008 22:36:59 -0400 Subject: [erlang-questions] file:read_file/2 bug? Message-ID: <48192CCB.2070209@gmail.com> For some reason file:read_file/1 always returns empty binary when reading from any file in the "/proc" filesystem. 1> file:read_file("/proc/self/environ"). {ok,<<>>} 2> {ok, FD} = file:open("/proc/self/environ", [read]). {ok,<0.39.0>} 3> file:read(FD, 1024). {ok,[82, 69, 77, ... 121|...]} Serge From igorrs@REDACTED Thu May 1 06:20:19 2008 From: igorrs@REDACTED (Igor Ribeiro Sucupira) Date: Thu, 1 May 2008 01:20:19 -0300 Subject: [erlang-questions] file:read_file/2 bug? In-Reply-To: <48192CCB.2070209@gmail.com> References: <48192CCB.2070209@gmail.com> Message-ID: On Wed, Apr 30, 2008 at 11:36 PM, Serge Aleynikov wrote: > For some reason file:read_file/1 always returns empty binary when > reading from any file in the "/proc" filesystem. > > 1> file:read_file("/proc/self/environ"). > {ok,<<>>} I suppose it must be fetching S bytes from the file, with S being the file size. :-) This behaviour probably has something to do with the fact that read_file should be an efficient operation. Igor. > 2> {ok, FD} = file:open("/proc/self/environ", [read]). > {ok,<0.39.0>} > 3> file:read(FD, 1024). > {ok,[82, > 69, > 77, > ... > 121|...]} > > Serge From richardc@REDACTED Thu May 1 12:04:49 2008 From: richardc@REDACTED (Richard Carlsson) Date: Thu, 01 May 2008 12:04:49 +0200 Subject: [erlang-questions] what is the correct syntax to spawm a MFA with no arguments? In-Reply-To: <481916D8.10408@san.rr.com> References: <4818E171.2000701@rldn.net> <3dbc6d1c0804301555i3bd04d28nd77e5d74860273d2@mail.gmail.com> <481916D8.10408@san.rr.com> Message-ID: <481995C1.4020506@it.uu.se> Darren New wrote: > I know very little about Erlang overall, but isn't the point of > exporting this to make it available for code upgrades? I.e., without > exporting the entry, it would be very difficult to have spawn(M,F,A) > spawn code that had changed recently, yes? No, because if you are using spawn(fun loop/0), or if you want to pass some arguments, use spawn (fun () -> loop(X, Y, Z) end), then obviously both the spawning code and the code for the fun is in the _same module_, so if the spawner is running the new code, the new process will also be running the new code. Code upgrade is only done per whole module. Also note that since the body of the fun is a tail call to the loop function, the fun-object is just a temporary object which is discarded once the new process starts executing in loop(). So, spawning from funs in this way is totally safe with respect to code upgrade. The warning about funs and code upgrade only has to do with stuff like storing a fun in a data structure somewhere, and then later digging it out and running it. It is by that time possible that the module where the fun was defined has been reloaded, but you'll still be running the old code that the fun belongs to. (You might often actually want this.) When you do a spawn from a literal fun for code in the same module, this cannot happen. Don't export internal functions. Always use spawn(fun ...), unless you feel that you _must_ be able to have a varying parameter list. (And in that case I'll come over and slap you silly, the lot of you.) /Richard From per@REDACTED Thu May 1 12:20:47 2008 From: per@REDACTED (Per Hedeland) Date: Thu, 1 May 2008 12:20:47 +0200 (CEST) Subject: [erlang-questions] gen_tcp nonblocking send In-Reply-To: <4818FA57.4080406@ot-e.biz> Message-ID: <200805011020.m41AKlKa069023@pluto.hedeland.org> Daniel Ginsburg wrote: > >What I have is a protocol which basically sends {key, value} over TCP >connection. Set of keys is large but limited. Receiver is not really >interested to hear all the changes of value for a particular key, it >just wants to know the most recent values for a key. It is also very >important to communicate changes of value for any key as fast as possible. > >In case when receiver is able to cope with the load, the best tactic is >to send all the changes as soon as they occur. But when receiver is >overloaded (or there's network congestion), there's important >optimization. If we have {k1, val1} sitting in queue and there's another >update for that key, we can, instead of adding it to the queue, simply >replace {k1, val1} with {k1, val2}. Thus saving network resources and >reducing load on receiver. In order to do that, I need to keep my own >queue and I need a way to know when it is safe to start dequeuing pairs >and send them to the socket. I think this fits a common Erlang solution: "use another process". I.e. have a separate "sender" process that just does the potentially blocking gen_tcp:send(), ack'ing back to the "real" sender when it returns. The "real", intelligent sender will send messages to this process instead of calling gen_tcp:send() directly, and when it has sent a message and not yet received the corresponding ack, it must go into "intelligent queuing mode", where it buffers updates and eliminates obsoleted ones. Implementing this in Erlang is simpler than describing it.:-) --Per Hedeland From catsunny@REDACTED Thu May 1 12:42:39 2008 From: catsunny@REDACTED (catsunny) Date: Thu, 01 May 2008 18:42:39 +0800 Subject: [erlang-questions] Why lists:dropwhile() didn't return the expected result? Message-ID: Hello, Hope I am not ask silly questions. I am new to erlang. So it's probably my mistake. The following is what I did: 13> K=fun 13> (X) when X>4 -> 13> true; 13> (X) when X==4 -> 13> true; 13> (X) when X<4 -> 13> false 13> end 13> . #Fun 14> lists:dropwhile(K,[1,2,3,4,5,6,7,8]). [1,2,3,4,5,6,7,8] 15> K(1). false 16> K(55). true At prompt line 14, I hope the return value to be [1,2,3], but it's [1,2,3,4,5,6,7,8]. Why? Thanks. Catsunny 2008-05-01 From dg@REDACTED Thu May 1 12:42:24 2008 From: dg@REDACTED (Daniel Ginsburg) Date: Thu, 01 May 2008 14:42:24 +0400 Subject: [erlang-questions] gen_tcp nonblocking send In-Reply-To: <200805011020.m41AKlKa069023@pluto.hedeland.org> References: <200805011020.m41AKlKa069023@pluto.hedeland.org> Message-ID: <48199E90.7020401@ot-e.biz> On 01.05.2008 14:20 Per Hedeland wrote: > I think this fits a common Erlang solution: "use another process". > I.e. have a separate "sender" process that just does the potentially > blocking gen_tcp:send(), ack'ing back to the "real" sender when it > returns. The "real", intelligent sender will send messages to this > process instead of calling gen_tcp:send() directly, and when it has sent > a message and not yet received the corresponding ack, it must go into > "intelligent queuing mode", where it buffers updates and eliminates > obsoleted ones. Implementing this in Erlang is simpler than describing > it.:-) > Yeah, this is what I figured when I woke up this morning. I'm hacking on it right now. Thanks for the kind advice. Indeed, Erlang's answer to any problem - just spawn yet another process :) -- dg From tty.erlang@REDACTED Thu May 1 13:29:11 2008 From: tty.erlang@REDACTED (t ty) Date: Thu, 1 May 2008 07:29:11 -0400 Subject: [erlang-questions] Why lists:dropwhile() didn't return the expected result? In-Reply-To: References: Message-ID: <290b3ba10805010429h676f1d6em799376999a7c4dfe@mail.gmail.com> dropwhile docs says "Drops Elem while Pred return true and returns remaining list" and in your example K(1) = false i.e. the first element dropwhile encounters Pred return false and the remaining list (which is the whole list) is returned. Look into lists:takewhile/2 instead. t On Thu, May 1, 2008 at 6:42 AM, catsunny wrote: > Hello, > Hope I am not ask silly questions. I am new to erlang. So it's probably my > mistake. > The following is what I did: > > 13> K=fun > 13> (X) when X>4 -> > 13> true; > 13> (X) when X==4 -> > 13> true; > 13> (X) when X<4 -> > 13> false > 13> end > 13> . > #Fun > 14> lists:dropwhile(K,[1,2,3,4,5,6,7,8]). > [1,2,3,4,5,6,7,8] > 15> K(1). > false > 16> K(55). > true > > At prompt line 14, I hope the return value to be [1,2,3], but it's > [1,2,3,4,5,6,7,8]. Why? > > Thanks. > Catsunny > 2008-05-01 > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From vychodil.hynek@REDACTED Thu May 1 13:33:19 2008 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Thu, 1 May 2008 13:33:19 +0200 Subject: [erlang-questions] Why lists:dropwhile() didn't return the expected result? In-Reply-To: References: Message-ID: <4d08db370805010433u69bddc46i7761166edfb30262@mail.gmail.com> lists:dropwhile do drop while fun is true so fun K is false for first member than nothing is dropped out. 1> K= fun(X) -> X<4 end. #Fun 2> lists:dropwhile(K,[1,2,3,4,5,6,7,8]). [4,5,6,7,8] On Thu, May 1, 2008 at 12:42 PM, catsunny wrote: > Hello, > Hope I am not ask silly questions. I am new to erlang. So it's probably my > mistake. > The following is what I did: > > 13> K=fun > 13> (X) when X>4 -> > 13> true; > 13> (X) when X==4 -> > 13> true; > 13> (X) when X<4 -> > 13> false > 13> end > 13> . > #Fun > 14> lists:dropwhile(K,[1,2,3,4,5,6,7,8]). > [1,2,3,4,5,6,7,8] > 15> K(1). > false > 16> K(55). > true > > At prompt line 14, I hope the return value to be [1,2,3], but it's > [1,2,3,4,5,6,7,8]. Why? > > Thanks. > Catsunny > 2008-05-01 > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- --Hynek (Pichi) Vychodil -------------- next part -------------- An HTML attachment was scrubbed... URL: From vychodil.hynek@REDACTED Thu May 1 13:37:08 2008 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Thu, 1 May 2008 13:37:08 +0200 Subject: [erlang-questions] Why lists:dropwhile() didn't return the expected result? In-Reply-To: References: Message-ID: <4d08db370805010437q58bb5cean5527782e1aa6f7f7@mail.gmail.com> Use lists:takewhile instead. 1> K=fun(X)->X<4 end. #Fun 2> lists:takewhile(K,[1,2,3,4,5,6,7,8]). [1,2,3] On Thu, May 1, 2008 at 12:42 PM, catsunny wrote: > Hello, > Hope I am not ask silly questions. I am new to erlang. So it's probably my > mistake. > The following is what I did: > > 13> K=fun > 13> (X) when X>4 -> > 13> true; > 13> (X) when X==4 -> > 13> true; > 13> (X) when X<4 -> > 13> false > 13> end > 13> . > #Fun > 14> lists:dropwhile(K,[1,2,3,4,5,6,7,8]). > [1,2,3,4,5,6,7,8] > 15> K(1). > false > 16> K(55). > true > > At prompt line 14, I hope the return value to be [1,2,3], but it's > [1,2,3,4,5,6,7,8]. Why? > > Thanks. > Catsunny > 2008-05-01 > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- --Hynek (Pichi) Vychodil -------------- next part -------------- An HTML attachment was scrubbed... URL: From catsunny@REDACTED Thu May 1 14:08:59 2008 From: catsunny@REDACTED (catsunny) Date: Thu, 01 May 2008 20:08:59 +0800 Subject: [erlang-questions] Why lists:dropwhile() didn't return the expected result?[Understood] In-Reply-To: <4d08db370805010437q58bb5cean5527782e1aa6f7f7@mail.gmail.com> References: <4d08db370805010437q58bb5cean5527782e1aa6f7f7@mail.gmail.com> Message-ID: Hello, every one, Thank you, t ty and Hynek Vychodil, very much. At the time when I read the library refence, I misunderstood the description, it says: Drops elements Elem from List1 while Pred(Elem) returns true and returns the remaining list. But I took while for when, so in my mind it becomes: Drops elements Elem from List1 when Pred(Elem) returns true and returns the remaining list. Because I don't know much English, I confused at the too detailed description. Now I know what the correct syntax is. Thank you again. catsunny. 2008-05-01 From Raymond.Xiong@REDACTED Thu May 1 14:24:09 2008 From: Raymond.Xiong@REDACTED (Raymond Xiong) Date: Thu, 01 May 2008 20:24:09 +0800 Subject: [erlang-questions] build 64bit Erlang on Solairs Message-ID: <20080501122408.GA3630@Sun.Com> I am trying to build 64bit Erlang on Soalris, but encountered some issue. Below are the details, thanks for any suggestion in advance. I used the following commands(especially, I used -m64 flag to tell gcc to generate 64bit code, and used "-R/usr/lib/64 -L/usr/lib/64" to tell ld use 64bit lib): # echo $ENV CC=gcc CFLAGS=-m64 LDFLAGS="-R/usr/lib/64 -L/usr/lib/64" CPPFLAGS="-I /usr/include/gd2" CXX=g++ # env $ENV configure --with-ssl=/usr/sfw --enable-dynamic-ssl-lib # env $ENV gmake install The above command could generate 64bit .o object files successfully, but it failed when trying to generate beam.bmp executable file. Here is the log: gcc -o /export/erlang/usr/src/cmd/erlang/root/otp_src_R12B-1/bin/sparc-sun-solaris2.11/beam.smp -R/usr/lib/64 -L/usr/lib/64 obj/sparc-sun-solaris2.11/opt/smp/erl_main.o ...(snipped) ld: fatal: file obj/sparc-sun-solaris2.11/opt/smp/erl_main.o: wrong ELF class: ELFCLASS64 >From what I know, the above error message means that ld was trying to generate 32bit binary file, but found the object files passed to it were 64bit files. According to ld(1) man page on Solaris, ld can guess to generate 32bit binary file or 64bit binary file: "No command-line option is required to distinguish 32-bit objects or 64-bit objects. The link-editor uses the ELF class of the first relocatable object on the command-line to govern the mode in which to operate." But why in this case it didn't get it right? I guess(I am not sure, it is just my guess) it was due to the fact that ssl encryption library I specified on configure command line was 32bit. Solaris does have 64bit ssl lib, it is under /usr/sfw/lib/64. But since Erlang use --with-ssl for both lib and header files, I cannot specify "--with-ssl=/usr/sfw/lib/64". How can I specify to use 64bit ssl lib? I guess there must be many people who compile 64bit Erlang on Solaris, I googled this but only found this thread, which sugested to hard code gcc to "gcc -m64": http://www.erlang.org/pipermail/erlang-questions/2006-July/021336.html I suppose there must be a better way than that? Thanks, Raymond From chsu79@REDACTED Thu May 1 15:27:55 2008 From: chsu79@REDACTED (Christian S) Date: Thu, 1 May 2008 15:27:55 +0200 Subject: [erlang-questions] file:read_file/2 bug? In-Reply-To: <48192CCB.2070209@gmail.com> References: <48192CCB.2070209@gmail.com> Message-ID: On Thu, May 1, 2008 at 4:36 AM, Serge Aleynikov wrote: > For some reason file:read_file/1 always returns empty binary when > reading from any file in the "/proc" filesystem. Running strace reveals what is done behind the scenes: stat64("/proc/self/environ", {st_mode=S_IFREG|0400, st_size=0, ...}) = 0 open("/proc/self/environ", O_RDONLY|O_LARGEFILE) = 7 close(7) = 0 Looking at /erts/emulator/drivers/unix/unix_efile.c one can also see that efile_openfile calls stat() on the filename before it open() the file. I dont understand why everything is done in efile_openfile that is done, but my guess is that if one first open() the file then use fstat() on the file descriptor, then the proc filesystem would report nonzero file length. Understanding would make it worthwile to submit a patch for the efile driver. The linux kernel generates the proc file's content as a snapshot at the instance the file is opened. Before open() it doesnt know how long the content will be. From valentin@REDACTED Thu May 1 15:50:15 2008 From: valentin@REDACTED (Valentin Micic) Date: Thu, 1 May 2008 15:50:15 +0200 Subject: [erlang-questions] gen_tcp nonblocking send References: <200805011020.m41AKlKa069023@pluto.hedeland.org> <48199E90.7020401@ot-e.biz> Message-ID: <004101c8ab92$4d9d2ba0$6701a8c0@moneymaker2> Does this mean that O_NDELAY is not supported in Erlang? Not even as an undocumented feature? ;-) V. ----- Original Message ----- From: "Daniel Ginsburg" To: "Per Hedeland" Cc: Sent: Thursday, May 01, 2008 12:42 PM Subject: Re: [erlang-questions] gen_tcp nonblocking send > On 01.05.2008 14:20 Per Hedeland wrote: > >> I think this fits a common Erlang solution: "use another process". >> I.e. have a separate "sender" process that just does the potentially >> blocking gen_tcp:send(), ack'ing back to the "real" sender when it >> returns. The "real", intelligent sender will send messages to this >> process instead of calling gen_tcp:send() directly, and when it has sent >> a message and not yet received the corresponding ack, it must go into >> "intelligent queuing mode", where it buffers updates and eliminates >> obsoleted ones. Implementing this in Erlang is simpler than describing >> it.:-) >> > > Yeah, this is what I figured when I woke up this morning. I'm hacking on > it right now. > > Thanks for the kind advice. Indeed, Erlang's answer to any problem - > just spawn yet another process :) > > -- > dg > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From Raymond.Xiong@REDACTED Thu May 1 14:51:39 2008 From: Raymond.Xiong@REDACTED (Raymond Xiong) Date: Thu, 01 May 2008 20:51:39 +0800 Subject: [erlang-questions] build 64bit Erlang on Solairs In-Reply-To: <20080501122408.GA3630@Sun.Com> References: <20080501122408.GA3630@Sun.Com> Message-ID: <20080501125139.GA3764@Sun.Com> On 05/01/08, Raymond Xiong wrote: > I am trying to build 64bit Erlang on Soalris, but encountered > some issue. Below are the details, thanks for any suggestion > in advance. > > I used the following commands(especially, I used -m64 flag to > tell gcc to generate 64bit code, and used "-R/usr/lib/64 > -L/usr/lib/64" to tell ld use 64bit lib): > > # echo $ENV > CC=gcc CFLAGS=-m64 LDFLAGS="-R/usr/lib/64 -L/usr/lib/64" CPPFLAGS="-I /usr/include/gd2" CXX=g++ > # env $ENV configure --with-ssl=/usr/sfw --enable-dynamic-ssl-lib > # env $ENV gmake install > > The above command could generate 64bit .o object files > successfully, but it failed when trying to generate beam.bmp > executable file. Here is the log: > > gcc -o /export/erlang/usr/src/cmd/erlang/root/otp_src_R12B-1/bin/sparc-sun-solaris2.11/beam.smp -R/usr/lib/64 -L/usr/lib/64 obj/sparc-sun-solaris2.11/opt/smp/erl_main.o ...(snipped) > ld: fatal: file obj/sparc-sun-solaris2.11/opt/smp/erl_main.o: > wrong ELF class: ELFCLASS64 > A bit more information on this. The above command was due to the following rules in erts/emulator/Makefile.in: $(BINDIR)/$(EMULATOR_EXECUTABLE): $(INIT_OBJS) $(OBJS) $(PURIFY) $(LD) -o $(BINDIR)/$(EMULATOR_EXECUTABLE) \ $(HIPEBEAMLDFLAGS) $(LDFLAGS) $(DEXPORT) $(INIT_OBJS) $(OBJS) $(LIBS) As you see, user specified CFLAGS value(-m64, in this case) is not used. So I have actually two questions: 1) Do we need to add CFLAGS in above command? (if ld can determince 32bit/64bit mode itself, maybe this is not necessary. The issue is, in my experiments on Solaris, ld couldn't get it right. I guess it might be due to ssl lib, but I am not sure) 2) How to configure to use 64bit ssl lib? Thanks for any help. Raymond > From what I know, the above error message means that ld was > trying to generate 32bit binary file, but found the object > files passed to it were 64bit files. > > According to ld(1) man page on Solaris, ld can guess to generate > 32bit binary file or 64bit binary file: > > "No command-line option is required to distinguish 32-bit > objects or 64-bit objects. The link-editor uses the ELF > class of the first relocatable object on the command-line to > govern the mode in which to operate." > > But why in this case it didn't get it right? I guess(I am not > sure, it is just my guess) it was due to the fact that ssl > encryption library I specified on configure command line was > 32bit. > > Solaris does have 64bit ssl lib, it is under /usr/sfw/lib/64. > But since Erlang use --with-ssl for both lib and header files, I > cannot specify "--with-ssl=/usr/sfw/lib/64". > > How can I specify to use 64bit ssl lib? > > I guess there must be many people who compile 64bit Erlang on > Solaris, I googled this but only found this thread, which > sugested to hard code gcc to "gcc -m64": > > http://www.erlang.org/pipermail/erlang-questions/2006-July/021336.html > > I suppose there must be a better way than that? > > Thanks, > Raymond > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- Regards, Raymond From daveb@REDACTED Thu May 1 15:56:49 2008 From: daveb@REDACTED (Dave Bryson) Date: Thu, 1 May 2008 08:56:49 -0500 Subject: [erlang-questions] Sometime it's the simple stuff... Message-ID: I need to take an IP address in the form of "[{10,0,1,100}]" and create an http URL like this: "http://10.0.1.100/". I've tried using io_lib:format and successfully generated a list. But, the inets http client doesn't like the format and complains of a malformed URL. What's the easiest way to convert an IP to the String version? Thanks! Dave From dg@REDACTED Thu May 1 16:03:39 2008 From: dg@REDACTED (Daniel Ginsburg) Date: Thu, 01 May 2008 18:03:39 +0400 Subject: [erlang-questions] gen_tcp nonblocking send In-Reply-To: <004101c8ab92$4d9d2ba0$6701a8c0@moneymaker2> References: <200805011020.m41AKlKa069023@pluto.hedeland.org> <48199E90.7020401@ot-e.biz> <004101c8ab92$4d9d2ba0$6701a8c0@moneymaker2> Message-ID: <4819CDBB.7020301@ot-e.biz> On 01.05.2008 17:50 Valentin Micic wrote: > Does this mean that O_NDELAY is not supported in Erlang? Not even as an > undocumented feature? ;-) > Internally, sockets are non-blocking (see erts/emulator/drivers/common/inet_drv.c), but as far as I understand, gen_tcp and all the underlying libraries like prim_inet expose only blocking send API to erlang processes. There's nice workaround, as Per suggested. I tried it, and it works like charm (thanks again, Per!). There's also unresolved problem with hot code upgrade for blocked process, but for me this is a minor issue. -- dg From mikpe@REDACTED Thu May 1 16:18:32 2008 From: mikpe@REDACTED (Mikael Pettersson) Date: Thu, 1 May 2008 16:18:32 +0200 Subject: [erlang-questions] build 64bit Erlang on Solairs In-Reply-To: <20080501122408.GA3630@Sun.Com> References: <20080501122408.GA3630@Sun.Com> Message-ID: <18457.53560.59691.24368@harpo.it.uu.se> Raymond Xiong writes: > I am trying to build 64bit Erlang on Soalris, but encountered > some issue. Below are the details, thanks for any suggestion > in advance. > > I used the following commands(especially, I used -m64 flag to > tell gcc to generate 64bit code, and used "-R/usr/lib/64 > -L/usr/lib/64" to tell ld use 64bit lib): > > # echo $ENV > CC=gcc CFLAGS=-m64 LDFLAGS="-R/usr/lib/64 -L/usr/lib/64" CPPFLAGS="-I /usr/include/gd2" CXX=g++ > # env $ENV configure --with-ssl=/usr/sfw --enable-dynamic-ssl-lib > # env $ENV gmake install > > The above command could generate 64bit .o object files > successfully, but it failed when trying to generate beam.bmp > executable file. Here is the log: > > gcc -o /export/erlang/usr/src/cmd/erlang/root/otp_src_R12B-1/bin/sparc-sun-solaris2.11/beam.smp -R/usr/lib/64 -L/usr/lib/64 obj/sparc-sun-solaris2.11/opt/smp/erl_main.o ...(snipped) > ld: fatal: file obj/sparc-sun-solaris2.11/opt/smp/erl_main.o: > wrong ELF class: ELFCLASS64 > > >From what I know, the above error message means that ld was > trying to generate 32bit binary file, but found the object > files passed to it were 64bit files. > > According to ld(1) man page on Solaris, ld can guess to generate > 32bit binary file or 64bit binary file: But the command above is not ld but gcc, and gcc requires -m64 to produce a 64-bit executable if its default is 32-bit. What happens is that gcc passes more options to ld than just the object file names, and typically one of those options selects the executable format. Hence gcc needs to be told if you want a non-default format. [snip] > I guess there must be many people who compile 64bit Erlang on > Solaris, I googled this but only found this thread, which > sugested to hard code gcc to "gcc -m64": > > http://www.erlang.org/pipermail/erlang-questions/2006-July/021336.html > > I suppose there must be a better way than that? env CFLAGS='-m64 -O2' LDFLAGS=-m64 ./configure ; make also works; I just did that to build R12B-2 on a Solaris 10 box. The advantage of "env CC=gcc64 ./configure; make" is that you don't have to worry about missing some *FLAGS variable. /Mikael From jarrod@REDACTED Thu May 1 17:53:41 2008 From: jarrod@REDACTED (Jarrod Roberson) Date: Thu, 1 May 2008 11:53:41 -0400 Subject: [erlang-questions] what is the correct syntax to spawm a MFA with no arguments? In-Reply-To: <481995C1.4020506@it.uu.se> References: <4818E171.2000701@rldn.net> <3dbc6d1c0804301555i3bd04d28nd77e5d74860273d2@mail.gmail.com> <481916D8.10408@san.rr.com> <481995C1.4020506@it.uu.se> Message-ID: On Thu, May 1, 2008 at 6:04 AM, Richard Carlsson wrote: > Darren New wrote: > > I know very little about Erlang overall, but isn't the point of > > exporting this to make it available for code upgrades? I.e., without > > exporting the entry, it would be very difficult to have spawn(M,F,A) > > spawn code that had changed recently, yes? > > No, because if you are using spawn(fun loop/0), or if you want to pass > some arguments, use spawn (fun () -> loop(X, Y, Z) end), then obviously > both the spawning code and the code for the fun is in the _same module_, > so if the spawner is running the new code, the new process will also > be running the new code. Code upgrade is only done per whole module. > > Also note that since the body of the fun is a tail call to the loop > function, the fun-object is just a temporary object which is discarded > once the new process starts executing in loop(). So, spawning from > funs in this way is totally safe with respect to code upgrade. > The warning about funs and code upgrade only has to do with stuff like > storing a fun in a data structure somewhere, and then later digging it > out and running it. It is by that time possible that the module where > the fun was defined has been reloaded, but you'll still be running the > old code that the fun belongs to. (You might often actually want this.) > When you do a spawn from a literal fun for code in the same module, this > cannot happen. > > so are you saying you can do hot code reloading _without_ using the MFA version of spawn? -------------- next part -------------- An HTML attachment was scrubbed... URL: From Raymond.Xiong@REDACTED Thu May 1 17:37:09 2008 From: Raymond.Xiong@REDACTED (Raymond Xiong) Date: Thu, 01 May 2008 23:37:09 +0800 Subject: [erlang-questions] build 64bit Erlang on Solairs In-Reply-To: <18457.53560.59691.24368@harpo.it.uu.se> References: <20080501122408.GA3630@Sun.Com> <18457.53560.59691.24368@harpo.it.uu.se> Message-ID: <20080501153708.GA3849@Sun.Com> On 05/01/08, Mikael Pettersson wrote: > > > > gcc -o /export/erlang/usr/src/cmd/erlang/root/otp_src_R12B-1/bin/sparc-sun-solaris2.11/beam.smp -R/usr/lib/64 -L/usr/lib/64 obj/sparc-sun-solaris2.11/opt/smp/erl_main.o ...(snipped) > > ld: fatal: file obj/sparc-sun-solaris2.11/opt/smp/erl_main.o: > > wrong ELF class: ELFCLASS64 > > > > >From what I know, the above error message means that ld was > > trying to generate 32bit binary file, but found the object > > files passed to it were 64bit files. > > > > According to ld(1) man page on Solaris, ld can guess to generate > > 32bit binary file or 64bit binary file: > > But the command above is not ld but gcc, and gcc requires -m64 to > produce a 64-bit executable if its default is 32-bit. What happens > is that gcc passes more options to ld than just the object file names, > and typically one of those options selects the executable format. > Hence gcc needs to be told if you want a non-default format. Mikael, Thanks for the information, I had thought gcc just let ld to decide that. If so, however, isn't it better to add CFLAGS in the follwing line in erts/emulator/Makefile.in? $(BINDIR)/$(EMULATOR_EXECUTABLE): $(INIT_OBJS) $(OBJS) $(PURIFY) $(LD) -o $(BINDIR)/$(EMULATOR_EXECUTABLE) \ $(HIPEBEAMLDFLAGS) $(LDFLAGS) $(DEXPORT) $(INIT_OBJS) $(OBJS) $(LIBS) > > [snip] > > I guess there must be many people who compile 64bit Erlang on > > Solaris, I googled this but only found this thread, which > > sugested to hard code gcc to "gcc -m64": > > > > http://www.erlang.org/pipermail/erlang-questions/2006-July/021336.html > > > > I suppose there must be a better way than that? > > env CFLAGS='-m64 -O2' LDFLAGS=-m64 ./configure ; make > > also works; I just did that to build R12B-2 on a Solaris 10 box. Yes, I believe it would work(I haven't try it on my SPARC box yet, because the machine is slow and it takes more than half an hour to finish). However, I doubt if you can enable ssl support. I expect the following command would fail because mixing of 32-bit objects and 64-bit objects is not permitted: env CFLAGS='-m64 -O2' LDFLAGS=-m64 ./configure --with-ssl=/usr/sfw \ --enable-dynamic-ssl-lib ; make 64bit ssl lib is under /usr/sfw/lib/64, do you have any suggestion on how to let Erlang use 64bit ssl lib under that subdir(but header files are still under /usr/sfw/include of course)? > > The advantage of "env CC=gcc64 ./configure; make" is that > you don't have to worry about missing some *FLAGS variable. > Yes, as a user I understand that, but I am building a package for OpenSolaris, so I need a more formal way. Thanks for your help! -- Regards, Raymond From chsu79@REDACTED Thu May 1 18:31:14 2008 From: chsu79@REDACTED (Christian S) Date: Thu, 1 May 2008 18:31:14 +0200 Subject: [erlang-questions] Sometime it's the simple stuff... In-Reply-To: References: Message-ID: On Thu, May 1, 2008 at 3:56 PM, Dave Bryson wrote: > I need to take an IP address in the form of "[{10,0,1,100}]" and > create an http URL like this: "http://10.0.1.100/". I've tried using > io_lib:format and successfully generated a list. But, the inets http > client doesn't like the format and complains of a malformed URL. Is it perhaps that you have missed that io_lib:format returns an iolist() and not a flat string() ? You can compose your own iolist_to_list from erlang:iolist_to_binary with erlang:binary_to_list. The slightly different lists:flatten works too, for this case. Since you didnt explain how things failed, you leave me/us having to guess. From richardc@REDACTED Thu May 1 18:39:05 2008 From: richardc@REDACTED (Richard Carlsson) Date: Thu, 01 May 2008 18:39:05 +0200 Subject: [erlang-questions] what is the correct syntax to spawm a MFA with no arguments? In-Reply-To: References: <4818E171.2000701@rldn.net> <3dbc6d1c0804301555i3bd04d28nd77e5d74860273d2@mail.gmail.com> <481916D8.10408@san.rr.com> <481995C1.4020506@it.uu.se> Message-ID: <4819F229.1040808@it.uu.se> Jarrod Roberson wrote: > so are you saying you can do hot code reloading _without_ using the MFA > version of spawn? Yes. If you spawn a process whose starting point is in the same module, you just use spawn(fun loop/0) or spawn(fun () -> loop(...) end). If you spawn a process that starts in _another_ module, you can write spawn(fun moo:loop()) or spawn(fun () -> moo:loop(...) end). Of course, in the latter case the function must be exported from moo, but you never need to export a function in the current module just because you want it to be the starting point of a process. I know that Joe's book (sadly) contains a remark that indicates that there is some problem with dynamic code loading and spawning from a fun, but that remark is just misleading. If you avoid exporting functions that shouldn't really be exported, tools like dialyzer can make a much better job of finding out what your program is doing (and tell you where you screw up). /Richard From vychodil.hynek@REDACTED Thu May 1 19:13:38 2008 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Thu, 1 May 2008 19:13:38 +0200 Subject: [erlang-questions] what is the correct syntax to spawm a MFA with no arguments? In-Reply-To: <4819F229.1040808@it.uu.se> References: <4818E171.2000701@rldn.net> <3dbc6d1c0804301555i3bd04d28nd77e5d74860273d2@mail.gmail.com> <481916D8.10408@san.rr.com> <481995C1.4020506@it.uu.se> <4819F229.1040808@it.uu.se> Message-ID: <4d08db370805011013m157ac3cer7fc5754825688792@mail.gmail.com> Really? Are you sure? Well, then describe us how long live running server turning around one loop/x function can change code of loop when you don't export loop/x function or some other function called from its loop. Just explain. On Thu, May 1, 2008 at 6:39 PM, Richard Carlsson wrote: > Jarrod Roberson wrote: > > so are you saying you can do hot code reloading _without_ using the MFA > > version of spawn? > > Yes. If you spawn a process whose starting point is in the same module, > you just use spawn(fun loop/0) or spawn(fun () -> loop(...) end). If you > spawn a process that starts in _another_ module, you can write > spawn(fun moo:loop()) or spawn(fun () -> moo:loop(...) end). Of course, > in the latter case the function must be exported from moo, but you never > need to export a function in the current module just because you want it > to be the starting point of a process. > > I know that Joe's book (sadly) contains a remark that indicates that > there is some problem with dynamic code loading and spawning from a fun, > but that remark is just misleading. > > If you avoid exporting functions that shouldn't really be exported, > tools like dialyzer can make a much better job of finding out what > your program is doing (and tell you where you screw up). > > /Richard > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- --Hynek (Pichi) Vychodil -------------- next part -------------- An HTML attachment was scrubbed... URL: From daveb@REDACTED Thu May 1 19:43:56 2008 From: daveb@REDACTED (Dave Bryson) Date: Thu, 1 May 2008 12:43:56 -0500 Subject: [erlang-questions] Sometime it's the simple stuff... In-Reply-To: <6c2563b20805010948g74a9142at97b77e67e4a8f03a@mail.gmail.com> References: <6c2563b20805010948g74a9142at97b77e67e4a8f03a@mail.gmail.com> Message-ID: <88C9691D-4A30-45D7-AD57-54D2AC189131@miceda.org> That did the trick! Thank you. Here's what I did: Given an IP in the form: [{10,0,1,195}] And a Port number: 3000 make_url(Ip,Port) -> [{A,B,C,D}] = Ip, X = io_lib:format("http://~p.~p.~p.~p:~p/",[A,B,C,D,Port]), lists:flatten(X). Returns: "http://10.0.1.195:3000/" which is exactly what I needed for the inets http client. Thanks again, Dave On May 1, 2008, at 11:48 AM, Edwin Fine wrote: > You didn't show the output of your io_lib:format call, but > io_lib:format often returns a deep list instead of just a flat list, > so you might need to use lists:flatten(io_lib:format(...)). Hope > that helps. > > On Thu, May 1, 2008 at 9:56 AM, Dave Bryson wrote: > I need to take an IP address in the form of "[{10,0,1,100}]" and > create an http URL like this: "http://10.0.1.100/". I've tried using > io_lib:format and successfully generated a list. But, the inets http > client doesn't like the format and complains of a malformed URL. > > What's the easiest way to convert an IP to the String version? > > Thanks! > Dave > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > From valentin@REDACTED Thu May 1 20:16:21 2008 From: valentin@REDACTED (Valentin Micic) Date: Thu, 1 May 2008 20:16:21 +0200 Subject: [erlang-questions] gen_tcp nonblocking send References: <200805011020.m41AKlKa069023@pluto.hedeland.org> <48199E90.7020401@ot-e.biz> <004101c8ab92$4d9d2ba0$6701a8c0@moneymaker2> <4819CDBB.7020301@ot-e.biz> Message-ID: <005c01c8abb7$77dff530$6701a8c0@moneymaker2> As you've said -- it is a workaround. Consider that under some circumstances such workaround may cause problems -- think of it this way: You're not really solving the problem, just shifting it elsewhere. Under normal circumstances (as you've outlined), if sender and receiver are not in some kind of "synchronous" engagement, in other words, if your next send does not depend on receiving something from a remote peer; and you have a "sluggish" remote receiver, your process would block once local buffer is full. If you change this by introducing intermediate server, as suggested -- call it a REALY; you are not changing the fact that this RELAY will block when local sending buffer gets full. However, as the sending process is now sending "normal" Erlang messages, it will have no way of figuring out that RELAY's buffer is full, thus, it will keep sending, eventually clogging RELAY's process message queue. In my experience, once process has a few hundred thousands of such messages in its queue, Erlang scheduling starts having problems (actually, this is largely due to the CPU utilization, but there is a relationship), hence you are degrading performance of other processes as well. OTOH, if one assumes that O_NDELAY would return immediately once the local buffer is full, this would help solving the problem you're referring to, by allowing a programmer to find the most suitable solution to a given problem - anything from immediate disconnection/reconnection to some form of internal buffering (which, mind you, cost only in terms of memory, and not so much in CPU cycles). I could understand the problems around introduction of O_NDELAY, e.g. how to communicate to client that only N octets were sent, and that rest should be resent. Well, maybe introducing a separate function, say gen_tcp:non_blocking_send, that would return a binary consisting of unsent octets (or empty binary if all has been sent), might not be so far fetched (hint, hint). V. ----- Original Message ----- From: "Daniel Ginsburg" To: "Valentin Micic" Cc: "Per Hedeland" ; Sent: Thursday, May 01, 2008 4:03 PM Subject: Re: [erlang-questions] gen_tcp nonblocking send > On 01.05.2008 17:50 Valentin Micic wrote: > >> Does this mean that O_NDELAY is not supported in Erlang? Not even as an >> undocumented feature? ;-) >> > > Internally, sockets are non-blocking (see > erts/emulator/drivers/common/inet_drv.c), but as far as I understand, > gen_tcp and all the underlying libraries like prim_inet expose only > blocking send API to erlang processes. > > There's nice workaround, as Per suggested. I tried it, and it works like > charm (thanks again, Per!). > > There's also unresolved problem with hot code upgrade for blocked process, > but for me this is a minor issue. > > -- > dg > From igorrs@REDACTED Thu May 1 20:24:49 2008 From: igorrs@REDACTED (Igor Ribeiro Sucupira) Date: Thu, 1 May 2008 15:24:49 -0300 Subject: [erlang-questions] file:read_file/2 bug? In-Reply-To: References: <48192CCB.2070209@gmail.com> Message-ID: On Thu, May 1, 2008 at 10:27 AM, Christian S wrote: > On Thu, May 1, 2008 at 4:36 AM, Serge Aleynikov wrote: > > Looking at /erts/emulator/drivers/unix/unix_efile.c one can also see > that efile_openfile calls stat() on the filename before it open() the > file. > > I dont understand why everything is done in efile_openfile that is > done, but my guess is that if one first open() the file then use > fstat() on the file descriptor, then the proc filesystem would report > nonzero file length. I've run this C code: int env_fd = open("/proc/self/environ", O_RDONLY); struct stat env_stat; fstat(env_fd, &env_stat); And got env_stat.st_size == 0. Igor. > Understanding would make it worthwile to submit a patch for the efile driver. > > The linux kernel generates the proc file's content as a snapshot at > the instance the file is opened. Before open() it doesnt know how long > the content will be. From per@REDACTED Thu May 1 20:30:44 2008 From: per@REDACTED (Per Hedeland) Date: Thu, 1 May 2008 20:30:44 +0200 (CEST) Subject: [erlang-questions] Why lists:dropwhile() didn't return the expected result?[Understood] In-Reply-To: Message-ID: <200805011830.m41IUiaw079076@pluto.hedeland.org> catsunny wrote: >At the time when I read the library refence, I misunderstood the >description, it says: > > Drops elements Elem from List1 while Pred(Elem) returns true and >returns the remaining list. > >But I took while for when, so in my mind it becomes: > Drops elements Elem from List1 when Pred(Elem) returns true and returns >the remaining list. And if your really want "when", the function to use is lists:filter/2 - a.k.a "takewhen".:-) --Per From dking@REDACTED Thu May 1 20:34:01 2008 From: dking@REDACTED (David King) Date: Thu, 1 May 2008 11:34:01 -0700 Subject: [erlang-questions] Slave nodes without proxied I/O? In-Reply-To: References: Message-ID: <73AF1508-8DE3-437F-8208-521C84A35683@ketralnis.com> > By default, nodes started as slave nodes with slave:start/1 have their > I/O proxied through the master node that started them. (That is, I/O > operations done with the 'file' module are done on the master's > filesystem, not the slaves'). > Is there any way to turn this off? Given the lack of response here, I'll assume that there isn't an easy to to turn it off. Barring that, is there a way to kill the 'file' server on the slave (which is just a proxy-process, that passes its messages to the 'file' server on the master), and ask it to re-create a new non-proxied server? From richardc@REDACTED Thu May 1 20:40:16 2008 From: richardc@REDACTED (Richard Carlsson) Date: Thu, 01 May 2008 20:40:16 +0200 Subject: [erlang-questions] what is the correct syntax to spawm a MFA with no arguments? In-Reply-To: <6c2563b20805011020i52393758p99a046c1f3f294af@mail.gmail.com> References: <4818E171.2000701@rldn.net> <3dbc6d1c0804301555i3bd04d28nd77e5d74860273d2@mail.gmail.com> <481916D8.10408@san.rr.com> <481995C1.4020506@it.uu.se> <4819F229.1040808@it.uu.se> <6c2563b20805011020i52393758p99a046c1f3f294af@mail.gmail.com> Message-ID: <481A0E90.10103@it.uu.se> Edwin Fine wrote: > Unfortunately, although your comment is in the latest errata of Joe's > book (thank you!), Pragmatic Programmers has not yet updated the PDF for > Programming Erlang. When they do, perhaps the prevalence of this myth > (which I did not know was a myth until about 10 minutes ago :) will be > reduced. I find it hard to understand how such an error could have made > it through the book review process, which is usually very good with > PragProg. Well, A) as we've noted, not many people have grasped this detail (not even Joe - the implementation of funs were not finalized until after he had left Ericsson), and B) I didn't read that part of the book before it was published, shame on me. I don't want to slag off Joe here; it's hard to keep track of what's going on with a language implementation when you're not involved on that technical level anymore. I ought to have read all of it, but I only found time to review the chapters on sequential programming. I hope it can be fixed in the next edition. /Richard From per@REDACTED Thu May 1 20:50:29 2008 From: per@REDACTED (Per Hedeland) Date: Thu, 1 May 2008 20:50:29 +0200 (CEST) Subject: [erlang-questions] gen_tcp nonblocking send In-Reply-To: <4819CDBB.7020301@ot-e.biz> Message-ID: <200805011850.m41IoTEn079528@pluto.hedeland.org> Daniel Ginsburg wrote: > >On 01.05.2008 17:50 Valentin Micic wrote: > >> Does this mean that O_NDELAY is not supported in Erlang? Not even as an >> undocumented feature? ;-) >> > >Internally, sockets are non-blocking (see >erts/emulator/drivers/common/inet_drv.c), but as far as I understand, >gen_tcp and all the underlying libraries like prim_inet expose only >blocking send API to erlang processes. And *you* don't really want non-blocking send (in the O_NDELAY sense) anyway, but async send. Looking at prim_inet will tell you how to get it, but I think in this case the "de-sync'ing" intermediate process is a reasonable solution. Async accept is another story... --Per From igorrs@REDACTED Thu May 1 21:07:39 2008 From: igorrs@REDACTED (Igor Ribeiro Sucupira) Date: Thu, 1 May 2008 16:07:39 -0300 Subject: [erlang-questions] gen_tcp nonblocking send In-Reply-To: <005c01c8abb7$77dff530$6701a8c0@moneymaker2> References: <200805011020.m41AKlKa069023@pluto.hedeland.org> <48199E90.7020401@ot-e.biz> <004101c8ab92$4d9d2ba0$6701a8c0@moneymaker2> <4819CDBB.7020301@ot-e.biz> <005c01c8abb7$77dff530$6701a8c0@moneymaker2> Message-ID: On Thu, May 1, 2008 at 3:16 PM, Valentin Micic wrote: > As you've said -- it is a workaround. Consider that under some circumstances > such workaround may cause problems -- think of it this way: You're not > really solving the problem, just shifting it elsewhere. > > > > Under normal circumstances (as you've outlined), if sender and receiver are > not in some kind of "synchronous" engagement, in other words, if your next > send does not depend on receiving something from a remote peer; and you have > a "sluggish" remote receiver, your process would block once local buffer is > full. If you change this by introducing intermediate server, as suggested -- > call it a REALY; you are not changing the fact that this RELAY will block > when local sending buffer gets full. However, as the sending process is now > sending "normal" Erlang messages, it will have no way of figuring out that > RELAY's buffer is full, thus, it will keep sending, eventually clogging > RELAY's process message queue. This is not the kind of solution we were suggesting to Daniel. He's got a continuous flux of update messages, of which he wants to send only the most recent to the server. We don't want him to introduce a relay that will just forward all messages it receives. The idea is to have a relay that will take care of sending only the most recent message once the last send returns. (In fact, I implemented that yesterday, to make sure it was easy :p) An example: - Update {k1, 17} sent to relay process. - Relay process starts sending (using another process) {k1, 17}. - Update {k1, 18} sent to relay process. - Update {k1, 19} sent to relay process ({k1, 18} is discarded). - Update {k1, 20} sent to relay process ({k1, 19} is discarded). - Sending of {k1, 17} finishes. - Sending of {k1, 20} starts. That won't cause any problems to any process message queue. Igor. > In my experience, once process has a few > hundred thousands of such messages in its queue, Erlang scheduling starts > having problems (actually, this is largely due to the CPU utilization, but > there is a relationship), hence you are degrading performance of other > processes as well. > > > > OTOH, if one assumes that O_NDELAY would return immediately once the local > buffer is full, this would help solving the problem you're referring to, by > allowing a programmer to find the most suitable solution to a given > problem - anything from immediate disconnection/reconnection to some form of > internal buffering (which, mind you, cost only in terms of memory, and not > so much in CPU cycles). > > > > I could understand the problems around introduction of O_NDELAY, e.g. how to > communicate to client that only N octets were sent, and that rest should be > resent. Well, maybe introducing a separate function, say > gen_tcp:non_blocking_send, that would return a binary consisting of unsent > octets (or empty binary if all has been sent), might not be so far fetched > (hint, hint). > > > > > V. > > ----- Original Message ----- > From: "Daniel Ginsburg" > > To: "Valentin Micic" > Cc: "Per Hedeland" ; > Sent: Thursday, May 01, 2008 4:03 PM > Subject: Re: [erlang-questions] gen_tcp nonblocking send > > > > > > On 01.05.2008 17:50 Valentin Micic wrote: > > > >> Does this mean that O_NDELAY is not supported in Erlang? Not even as an > >> undocumented feature? ;-) > >> > > > > Internally, sockets are non-blocking (see > > erts/emulator/drivers/common/inet_drv.c), but as far as I understand, > > gen_tcp and all the underlying libraries like prim_inet expose only > > blocking send API to erlang processes. > > > > There's nice workaround, as Per suggested. I tried it, and it works like > > charm (thanks again, Per!). > > > > There's also unresolved problem with hot code upgrade for blocked process, > > but for me this is a minor issue. > > > > -- > > dg > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From per@REDACTED Thu May 1 20:43:56 2008 From: per@REDACTED (Per Hedeland) Date: Thu, 1 May 2008 20:43:56 +0200 (CEST) Subject: [erlang-questions] file:read_file/2 bug? In-Reply-To: Message-ID: <200805011843.m41Ihu9T079459@pluto.hedeland.org> "Christian S" wrote: > >I dont understand why everything is done in efile_openfile that is >done, but my guess is that if one first open() the file then use >fstat() on the file descriptor, then the proc filesystem would report >nonzero file length. Your guess is wrong: $ cat stdin_size.c #include #include #include #include main() { struct stat buf; fstat(0, &buf); printf("size=%d\n", buf.st_size); } $ ./stdin_size < /proc/self/environ size=0 >The linux kernel generates the proc file's content as a snapshot at >the instance the file is opened. Before open() it doesnt know how long >the content will be. AFAIK, the snapshotting happens when you read(2) the file, which can have a variety of interesting effects (probably not in this particular case, but in general). Basically, the Linux /proc file system is handy for the "I just want to have a peek at some system stuff" scenario, but if you want to use it programmatically and get dependable results, you need to be *very* careful. I don't think any of the Erlang file(3) functionality is quite up to the general task. --Per From dg@REDACTED Thu May 1 21:15:32 2008 From: dg@REDACTED (Daniel Ginsburg) Date: Thu, 01 May 2008 23:15:32 +0400 Subject: [erlang-questions] gen_tcp nonblocking send In-Reply-To: <200805011850.m41IoTEn079528@pluto.hedeland.org> References: <200805011850.m41IoTEn079528@pluto.hedeland.org> Message-ID: <481A16D4.7070703@ot-e.biz> Per Hedeland wrote: >> Internally, sockets are non-blocking (see >> erts/emulator/drivers/common/inet_drv.c), but as far as I understand, >> gen_tcp and all the underlying libraries like prim_inet expose only >> blocking send API to erlang processes. >> > > And *you* don't really want non-blocking send (in the O_NDELAY sense) > anyway, but async send. Looking at prim_inet will tell you how to get > it, but I think in this case the "de-sync'ing" intermediate process is a > reasonable solution. Async accept is another story... > > --Per > Sure, solution with intermediary worked just fine. Thought, I don't understand why I shouldn't want nonblocking send? In a sense of O_NDELAY+select/poll/whatever Indeed, if I were able to get 1) indication that send buffer is full in form of return code from send call 2) indication that some space in send buffer was freed up in form of message to my process I could implement what I want without any intermediary. It must be my previous background that makes me want this mode of operation. I had to wrap my mind a bit around intermediary process. I think it's ok, though. I have learnt something today. From dg@REDACTED Thu May 1 21:16:58 2008 From: dg@REDACTED (Daniel Ginsburg) Date: Thu, 01 May 2008 23:16:58 +0400 Subject: [erlang-questions] gen_tcp nonblocking send In-Reply-To: <005c01c8abb7$77dff530$6701a8c0@moneymaker2> References: <200805011020.m41AKlKa069023@pluto.hedeland.org> <48199E90.7020401@ot-e.biz> <004101c8ab92$4d9d2ba0$6701a8c0@moneymaker2> <4819CDBB.7020301@ot-e.biz> <005c01c8abb7$77dff530$6701a8c0@moneymaker2> Message-ID: <481A172A.8080707@ot-e.biz> Valentin Micic wrote: > Under normal circumstances (as you've outlined), if sender and > receiver are not in some kind of "synchronous" engagement, in other > words, if your next send does not depend on receiving something from a > remote peer; and you have a "sluggish" remote receiver, your process > would block once local buffer is full. True. > If you change this by introducing intermediate server, as suggested > -- call it a REALY; you are not changing the fact that this RELAY > will block when local sending buffer gets full. True. > However, as the sending process is now sending "normal" Erlang > messages, it will have no way of figuring out that RELAY's buffer is > full, thus, it will keep sending, eventually clogging RELAY's process > message queue. The trick is to introduce "some kind of synchronous engagement" you referred earlier between the sending process and the relay. Thus you can avoid filling up the relay's queue. If you will, relay is a "converter" between two modes of operation: non-pipelined-request-reply between relay and sender, and pipelined-but-possibly-blocking-on-send-buffer-filling-up between relay and remote receiver. > In my experience, once process has a few hundred thousands of such > messages in its queue, Erlang scheduling starts having problems > (actually, this is largely due to the CPU utilization, but there is a > relationship), hence you are degrading performance of other processes > as well. > True, but avoidable. From per@REDACTED Thu May 1 21:22:20 2008 From: per@REDACTED (Per Hedeland) Date: Thu, 1 May 2008 21:22:20 +0200 (CEST) Subject: [erlang-questions] gen_tcp nonblocking send In-Reply-To: <005c01c8abb7$77dff530$6701a8c0@moneymaker2> Message-ID: <200805011922.m41JMKl4080221@pluto.hedeland.org> "Valentin Micic" wrote: > >As you've said -- it is a workaround. Consider that under some circumstances >such workaround may cause problems -- think of it this way: You're not >really solving the problem, just shifting it elsewhere. But that was precisely what he *wanted*: the possibility to note the problem and deal with it "elsewhere" (i.e. his sender will maintain its own queue and eliminate useless data there). >Under normal circumstances (as you've outlined), if sender and receiver are >not in some kind of "synchronous" engagement, in other words, if your next >send does not depend on receiving something from a remote peer; and you have >a "sluggish" remote receiver, your process would block once local buffer is >full. If you change this by introducing intermediate server, as suggested -- >call it a REALY; you are not changing the fact that this RELAY will block >when local sending buffer gets full. However, as the sending process is now >sending "normal" Erlang messages, it will have no way of figuring out that >RELAY's buffer is full, thus, it will keep sending, eventually clogging >RELAY's process message queue. You didn't read my suggestion carefully enough - try again. >OTOH, if one assumes that O_NDELAY would return immediately once the local >buffer is full, this would help solving the problem you're referring to, by >allowing a programmer to find the most suitable solution to a given >problem - anything from immediate disconnection/reconnection to some form of >internal buffering (which, mind you, cost only in terms of memory, and not >so much in CPU cycles). IMO, exposing O_NDELAY/O_NONBLOCK at the Erlang level would be a huge mistake. Networking (and many other "interactions with the environment") is so simple in Erlang because it just hides all the gory details that you get immediately thrown in your face when using a C interface to the same functionality. And when you really need some functionality provided by the gory-details interface but not by the Erlang counterpart, there's often a nice Erlangish way to achieve it, that just wouldn't be possible at the gory-details and/or C level. This case is an excellent illustration of that - in Erlang, you don't want a send() that says "sorry, I only managed to send N bytes of your complex nested list/binary structure, you need to re-send the rest" - but you might want a send() that doesn't block, but just sends you a message when it's done. Which is exactly what my "relay" process suggestion implements, and which *could* be provided as a standard gen_tcp(3) API function - but it's probably an uncommon enough need that doing that isn't motivated. --Per From chsu79@REDACTED Thu May 1 21:38:21 2008 From: chsu79@REDACTED (Christian S) Date: Thu, 1 May 2008 21:38:21 +0200 Subject: [erlang-questions] file:read_file/2 bug? In-Reply-To: <200805011843.m41Ihu9T079459@pluto.hedeland.org> References: <200805011843.m41Ihu9T079459@pluto.hedeland.org> Message-ID: On Thu, May 1, 2008 at 8:43 PM, Per Hedeland wrote: > Your guess is wrong: > $ ./stdin_size < /proc/self/environ > size=0 First, sorry for spreading mis-information. Thanks for doing the homework I should have done. Second. Wow. I used to do c programming. Why do they do this to themself? > AFAIK, the snapshotting happens when you read(2) the file, which can > have a variety of interesting effects (probably not in this particular > case, but in general). Basically, the Linux /proc file system is handy > for the "I just want to have a peek at some system stuff" scenario, but > if you want to use it programmatically and get dependable results, you > need to be *very* careful. Looking at some implementations of /proc files, it sure seems more common to generate content as the file is read. I havent even found a single occurance of something generating the content at open-time. (I only recall this being an issue when rewinding and re-reading some proc file once, but this was ages ago) > I don't think any of the Erlang file(3) > functionality is quite up to the general task. My approach have been like Serge's second attempt, to open then read with a sufficiently big read byte-count. That's an Erlang file-module approach. Are you saying that there is problems with that too? From richardc@REDACTED Thu May 1 21:40:17 2008 From: richardc@REDACTED (Richard Carlsson) Date: Thu, 01 May 2008 21:40:17 +0200 Subject: [erlang-questions] what is the correct syntax to spawm a MFA with no arguments? In-Reply-To: <6c2563b20805011219q7359fe2bib93e5273722c6912@mail.gmail.com> References: <4818E171.2000701@rldn.net> <3dbc6d1c0804301555i3bd04d28nd77e5d74860273d2@mail.gmail.com> <481916D8.10408@san.rr.com> <481995C1.4020506@it.uu.se> <4819F229.1040808@it.uu.se> <6c2563b20805011020i52393758p99a046c1f3f294af@mail.gmail.com> <481A0E90.10103@it.uu.se> <6c2563b20805011219q7359fe2bib93e5273722c6912@mail.gmail.com> Message-ID: <481A1CA1.1020201@it.uu.se> Edwin Fine wrote: > Sorry, Richard, I didn't know you were involved in the review process. > My comment was not directed at you (or anyone else, for that matter). I > keep forgetting how imprecise a communication mechanism email is :( Don't worry. /Richard From igorrs@REDACTED Thu May 1 21:52:17 2008 From: igorrs@REDACTED (Igor Ribeiro Sucupira) Date: Thu, 1 May 2008 16:52:17 -0300 Subject: [erlang-questions] gen_tcp nonblocking send In-Reply-To: <200805011922.m41JMKl4080221@pluto.hedeland.org> References: <005c01c8abb7$77dff530$6701a8c0@moneymaker2> <200805011922.m41JMKl4080221@pluto.hedeland.org> Message-ID: On Thu, May 1, 2008 at 4:22 PM, Per Hedeland wrote: > "Valentin Micic" wrote: > > > >As you've said -- it is a workaround. Consider that under some circumstances > >such workaround may cause problems -- think of it this way: You're not > >really solving the problem, just shifting it elsewhere. > > But that was precisely what he *wanted*: the possibility to note the > problem and deal with it "elsewhere" (i.e. his sender will maintain its > own queue and eliminate useless data there). > > > >Under normal circumstances (as you've outlined), if sender and receiver are > >not in some kind of "synchronous" engagement, in other words, if your next > >send does not depend on receiving something from a remote peer; and you have > >a "sluggish" remote receiver, your process would block once local buffer is > >full. If you change this by introducing intermediate server, as suggested -- > >call it a REALY; you are not changing the fact that this RELAY will block > >when local sending buffer gets full. However, as the sending process is now > >sending "normal" Erlang messages, it will have no way of figuring out that > >RELAY's buffer is full, thus, it will keep sending, eventually clogging > >RELAY's process message queue. > > You didn't read my suggestion carefully enough - try again. > > > >OTOH, if one assumes that O_NDELAY would return immediately once the local > >buffer is full, this would help solving the problem you're referring to, by > >allowing a programmer to find the most suitable solution to a given > >problem - anything from immediate disconnection/reconnection to some form of > >internal buffering (which, mind you, cost only in terms of memory, and not > >so much in CPU cycles). > > IMO, exposing O_NDELAY/O_NONBLOCK at the Erlang level would be a huge > mistake. I'm in almost perfect agreement with you. I don't even see why O_NDELAY would make Daniel's program easier to implement (well... maybe I'm missing something...). But, how do you deal with the situation (definitely not Daniel's case) in which you just want to NOT send the message if the buffer is full ("Oh... system overload... nevermind... I don't want to make the situation worst... I'll come back when I have something important...")? :-) send_timeout wouldn't be of help here. Igor. > Networking (and many other "interactions with the environment") > is so simple in Erlang because it just hides all the gory details that > you get immediately thrown in your face when using a C interface to the > same functionality. And when you really need some functionality provided > by the gory-details interface but not by the Erlang counterpart, there's > often a nice Erlangish way to achieve it, that just wouldn't be possible > at the gory-details and/or C level. > > This case is an excellent illustration of that - in Erlang, you don't > want a send() that says "sorry, I only managed to send N bytes of your > complex nested list/binary structure, you need to re-send the rest" - > but you might want a send() that doesn't block, but just sends you a > message when it's done. Which is exactly what my "relay" process > suggestion implements, and which *could* be provided as a standard > gen_tcp(3) API function - but it's probably an uncommon enough need that > doing that isn't motivated. > > --Per From richardc@REDACTED Thu May 1 22:12:29 2008 From: richardc@REDACTED (Richard Carlsson) Date: Thu, 01 May 2008 22:12:29 +0200 Subject: [erlang-questions] what is the correct syntax to spawm a MFA with no arguments? In-Reply-To: <4d08db370805011013m157ac3cer7fc5754825688792@mail.gmail.com> References: <4818E171.2000701@rldn.net> <3dbc6d1c0804301555i3bd04d28nd77e5d74860273d2@mail.gmail.com> <481916D8.10408@san.rr.com> <481995C1.4020506@it.uu.se> <4819F229.1040808@it.uu.se> <4d08db370805011013m157ac3cer7fc5754825688792@mail.gmail.com> Message-ID: <481A242D.50502@it.uu.se> Hynek Vychodil wrote: > Really? Are you sure? Well, then describe us how long live running > server turning around one loop/x function can change code of loop > when you don't export loop/x function or some other function called > from its loop. Just explain. Don't mix up two different things: 1) starting a new process, and 2) keeping a process running in a loop. What I'm saying is that to start a process, there is no problem at all using a fun, or at least, using a literal fun that just contains a tail call. The following would be a bad idea: spawn(fun () -> loop(), io:format("done") end) because the return address to the io:format call would be pushed on the stack (the call to loop() is not tail recursive), and therefore, this fun cannot be discarded as long as loop() is running. Not good. But for spawn(fun loop/0) or spawn(fun () -> loop() end), there is no reference left to the fun, as soon as the call to loop() is entered. But _after_ the process has started, you still need the server loop to execute a tail call to an exported function, using M:F(...) syntax (or apply), in order to support code upgrade. This is a completely different thing. Normally, the starting point for a process is not the actual loop function itself, but typically an init function which in its turn enters the main loop (which could be an exported function). But even if you start the process directly in the loop function, you can use another function name for code upgrade. For example: -export([start/0, upgrade/1]). start() -> spawn(fun loop(0) end). upgrade(S) -> loop(S). loop(S) -> receive X when is_integer(X) -> loop(S+X); upgrade -> ?MODULE:upgrade(S) end. But preferably, the user interface (start, stop, etc.) and the server loop with its entry point for upgrading should be in separate modules to keep the interface cleaner. And in that case you might as well put the init function in that other module as well. But you could still use spawn(fun moo:init/0) or spawn(fun () -> moo:init(X, Y, Z) end) to start the process; there is no need to use spawn/3. Here are a couple of examples of mistakes you might make if you just focus on the spawning of the process. The first one is so easy that only beginners make it: -export([start/0, loop/1]). start() -> spawn(?MODULE, loop, [0]). loop(S) -> receive X when is_integer(X) -> loop(S+X) end. (the actual server loop never checks for code upgrades, even though it is using an exported function). The second is one you might make and think that it's not a problem because you're only using spawn/3 and fully qualified calls: -module(myserver). -export([start/0]). start() -> spawn(myserver_impl, init, [0]). -module(myserver_impl). -export([init/1, loop/1]). init(S) -> loop(S), ok. loop(S) -> receive X when is_integer(X) -> ?MODULE:loop(S+X) end. Here, code upgrade will work once, but the second time you try it your server process will be killed, because it is still holding on to a return pointer to the first version of the module (note that the call from init/1 to loop/1 is not a tail call), and Erlang only supports two parallel versions of the code, and all processes that need even older code will be killed. There are two main points to understand when it comes to making code upgrade work: - Your process must regularly (at least each time new code has been loaded) execute a tail-recursive non-local call. - You must not leave any return addresses on the process stack that point to old versions of the code, or store funs in the process state that point to old code. It's the second point that's hardest to grasp, because you need a bit of understanding of how the implementation of a functional language with tail recursion optimization and garbage collection works. So, it can be quite easy to screw up code upgrade without using any funs at all (which most people seem not to worry a lot about), and there are really no problems with spawning new processes using spawn(fun ...), which many people seem to worry about. Just relax and learn to love the bomb. :-) /Richard From valentin@REDACTED Thu May 1 22:01:38 2008 From: valentin@REDACTED (Valentin Micic) Date: Thu, 1 May 2008 22:01:38 +0200 Subject: [erlang-questions] gen_tcp nonblocking send References: <200805011922.m41JMKl4080221@pluto.hedeland.org> Message-ID: <007601c8abc6$377c0c90$6701a8c0@moneymaker2> > > You didn't read my suggestion carefully enough - try again. > You're right -- I did not read it carefully enough. Your suggestion would not develop a scheduling problem. However, after reading it again, I'm really not sure why would O_NDEALY be such an evil thing, if it is implemented as a separate function call (and not as a flag), that would return a binary containing unsent octets. It would certainly help (in this case not-so) intelligent queuing on the caller side -- unlike your sender that needs to do pre-emptive queuing, until it receive's ack from "relay", it would need to queue only unsent octets, right? V. From igorrs@REDACTED Fri May 2 00:34:28 2008 From: igorrs@REDACTED (Igor Ribeiro Sucupira) Date: Thu, 1 May 2008 19:34:28 -0300 Subject: [erlang-questions] gen_tcp nonblocking send In-Reply-To: <007601c8abc6$377c0c90$6701a8c0@moneymaker2> References: <200805011922.m41JMKl4080221@pluto.hedeland.org> <007601c8abc6$377c0c90$6701a8c0@moneymaker2> Message-ID: On Thu, May 1, 2008 at 5:01 PM, Valentin Micic wrote: > > > > You didn't read my suggestion carefully enough - try again. > > > > You're right -- I did not read it carefully enough. Your suggestion would > not develop a scheduling problem. However, after reading it again, I'm > really not sure why would O_NDEALY be such an evil thing, if it is > implemented as a separate function call (and not as a flag), that would > return a binary containing unsent octets. It would certainly help (in this > case not-so) intelligent queuing on the caller side -- unlike your sender > that needs to do pre-emptive queuing, until it receive's ack from "relay", > it would need to queue only unsent octets, right? I don't really see the point of dealing with "partial sends" and queuing unsent octets, if all you want is to send the whole message. It doesn't look necessary in a concurrent environment with lightweight threads. As for O_NDELAY, I still think it could be useful in some situation, but not in this case, for a similar reason: you'll be sending the data anyway, as soon as you can do it. So, why not just spawn a process to do exactly that wait-and-send? Igor. From igorrs@REDACTED Fri May 2 00:55:31 2008 From: igorrs@REDACTED (Igor Ribeiro Sucupira) Date: Thu, 1 May 2008 19:55:31 -0300 Subject: [erlang-questions] gen_tcp nonblocking send In-Reply-To: References: <200805011922.m41JMKl4080221@pluto.hedeland.org> <007601c8abc6$377c0c90$6701a8c0@moneymaker2> Message-ID: On Thu, May 1, 2008 at 7:34 PM, Igor Ribeiro Sucupira wrote: > On Thu, May 1, 2008 at 5:01 PM, Valentin Micic wrote: > > > > > > You didn't read my suggestion carefully enough - try again. > > > > > > > You're right -- I did not read it carefully enough. Your suggestion would > > not develop a scheduling problem. However, after reading it again, I'm > > really not sure why would O_NDEALY be such an evil thing, if it is > > implemented as a separate function call (and not as a flag), that would > > return a binary containing unsent octets. It would certainly help (in this > > case not-so) intelligent queuing on the caller side -- unlike your sender > > that needs to do pre-emptive queuing, until it receive's ack from "relay", > > it would need to queue only unsent octets, right? > > > I don't really see the point of dealing with "partial sends" and > queuing unsent octets, if all you want is to send the whole message. > It doesn't look necessary in a concurrent environment with lightweight threads. > > As for O_NDELAY, I still think it could be useful in some situation, > but not in this case, In fact, it maybe could make a small difference here. In the implementation we've suggested, we could have this: t0) Start sending {k1, v0}. Local buffer is full. send-process blocked. t1) k1 updated to v1. t2) Local buffer has space. {k1, v0} being sent. t3) k1 updated to v2. t4) {k1, v0} sent. Start sending v2. Maybe O_NDELAY would allow us to do this: t0) Start trying actively (non-blocking) to send {k1, v0}. Local buffer is full. t1) k1 updated to v1. Give up on v0. Now we're trying to send {k1, v1}. t2) Local buffer has space. {k1, v1} being sent. t3) k1 updated to v2. t4) {k1, v1} sent. Start sending v2. Which is clearly better. Igor. > for a similar reason: you'll be sending the data > anyway, as soon as you can do it. So, why not just spawn a process to > do exactly that wait-and-send? > > Igor. > From 0x6e6562@REDACTED Fri May 2 03:03:44 2008 From: 0x6e6562@REDACTED (Ben Hood) Date: Fri, 2 May 2008 02:03:44 +0100 Subject: [erlang-questions] os_mon in OS X Message-ID: <74FB8CA7-7AEC-4DD9-831F-594647BFDC27@gmail.com> Hi, The get_uint32_measurement/2 call in cpu_sup seems to throw a bad match when the locale of the shell that the process is running in does not use a decimal point to denote a fraction. For example, if the result of /usr/bin/uptime is 1:59 up 1 day, 6:07, 5 users, load averages: 0,77 0,94 1,02 then the get_uint32_measurement fails. This occurs in R12B-1 with uname Darwin Macintosh-3.local 9.2.2 Darwin Kernel Version 9.2.2: Tue Mar 4 21:17:34 PST 2008; root:xnu-1228.4.31~1/RELEASE_I386 i386 There was a thread (http://forum.trapexit.org/mailinglists/viewtopic.php?t=4687&sid=89d1b0afdf03311a49b26a6376bef3e3 ) about this a few years ago, I don't know whether this is still an issue. Thx, Ben From mailparmalat@REDACTED Fri May 2 10:16:54 2008 From: mailparmalat@REDACTED (Chih-Wei Yu) Date: Fri, 2 May 2008 10:16:54 +0200 Subject: [erlang-questions] R12B-1 runtime-errors In-Reply-To: <4818F591.90905@cs.ntua.gr> References: <200804302142.m3ULgkGF028808@mail.pharos-avantgard.com> <4818F591.90905@cs.ntua.gr> Message-ID: <673036f20805020116p146bb8d2gfba47188e2ed3b18@mail.gmail.com> Thanks, I'll migrate to R12B-2 and give it a shot. Regards, Chih-Wei Yu On 5/1/08, Kostis Sagonas wrote: > > Valentin Micic wrote: > >> The one that Chih-Wei is talking about produces a core dump with SIGBUS >> signal as a cause. Who can assist with this, or rather, where can we mail >> the core dump and more details about the crash? >> > > Before sending the core dump, you should first check one of the following: > > - try your program with R12B-2 where the issue is most probably fixed > > - If you have a very good reason to stick to R12B-1, you should first > apply the patch which was posted in the mailing list and solves a > similar problem as the one you reported. > > If with these the problem persists then you should minimize your program > and post it to erlang-bugs. > > Kostis > -------------- next part -------------- An HTML attachment was scrubbed... URL: From vychodil.hynek@REDACTED Fri May 2 10:52:12 2008 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Fri, 2 May 2008 10:52:12 +0200 Subject: [erlang-questions] what is the correct syntax to spawm a MFA with no arguments? In-Reply-To: <481A242D.50502@it.uu.se> References: <4818E171.2000701@rldn.net> <3dbc6d1c0804301555i3bd04d28nd77e5d74860273d2@mail.gmail.com> <481916D8.10408@san.rr.com> <481995C1.4020506@it.uu.se> <4819F229.1040808@it.uu.se> <4d08db370805011013m157ac3cer7fc5754825688792@mail.gmail.com> <481A242D.50502@it.uu.se> Message-ID: <4d08db370805020152t66e56294sc860b698cb041262@mail.gmail.com> On Thu, May 1, 2008 at 10:12 PM, Richard Carlsson wrote: > Hynek Vychodil wrote: > > > Really? Are you sure? Well, then describe us how long live running > > server turning around one loop/x function can change code of loop > > when you don't export loop/x function or some other function called > > from its loop. Just explain. > > > > Don't mix up two different things: 1) starting a new process, and 2) > keeping a process running in a loop. What I'm saying is that to start > a process, there is no problem at all using a fun, or at least, using > a literal fun that just contains a tail call. The following would > be a bad idea: > > spawn(fun () -> loop(), io:format("done") end) > > because the return address to the io:format call would be pushed on > the stack (the call to loop() is not tail recursive), and therefore, > this fun cannot be discarded as long as loop() is running. Not good. > But for spawn(fun loop/0) or spawn(fun () -> loop() end), there is no > reference left to the fun, as soon as the call to loop() is entered. What fool doing it? > > > But _after_ the process has started, you still need the server loop > to execute a tail call to an exported function, using M:F(...) syntax > (or apply), in order to support code upgrade. This is a completely > different thing. > > Normally, the starting point for a process is not the actual loop > function itself, but typically an init function which in its turn > enters the main loop (which could be an exported function). But even > if you start the process directly in the loop function, you can use > another function name for code upgrade. > For example: > > -export([start/0, upgrade/1]). > start() -> spawn(fun loop(0) end). > upgrade(S) -> loop(S). > loop(S) -> > receive > X when is_integer(X) -> loop(S+X); > upgrade -> ?MODULE:upgrade(S) > end. *** or some other function called from its loop *** in my question. Nothing new on the world. > > > But preferably, the user interface (start, stop, etc.) and the server > loop with its entry point for upgrading should be in separate modules > to keep the interface cleaner. And in that case you might as well put > the init function in that other module as well. But you could still > use spawn(fun moo:init/0) or spawn(fun () -> moo:init(X, Y, Z) end) > to start the process; there is no need to use spawn/3. > > Here are a couple of examples of mistakes you might make if you just > focus on the spawning of the process. The first one is so easy that > only beginners make it: > > -export([start/0, loop/1]). > start() -> spawn(?MODULE, loop, [0]). > loop(S) -> > receive > X when is_integer(X) -> loop(S+X) > end. > > (the actual server loop never checks for code upgrades, even though > it is using an exported function). If it is not time critical think you can just use loop(S) -> receive X when is_integer(X) -> ?MODULE, loop(S+X) end. > > The second is one you might make and think that it's not a problem > because you're only using spawn/3 and fully qualified calls: > > -module(myserver). > -export([start/0]). > start() -> spawn(myserver_impl, init, [0]). > > -module(myserver_impl). > -export([init/1, loop/1]). > init(S) -> loop(S), ok. What fool adding ",ok" in this function? Just remove this stupid thing! > loop(S) -> > receive > X when is_integer(X) -> ?MODULE:loop(S+X) > end. > > Here, code upgrade will work once, but the second time you try it > your server process will be killed, because it is still holding on > to a return pointer to the first version of the module (note that > the call from init/1 to loop/1 is not a tail call), and Erlang > only supports two parallel versions of the code, and all processes > that need even older code will be killed. > > There are two main points to understand when it comes to making > code upgrade work: > > - Your process must regularly (at least each time new code has > been loaded) execute a tail-recursive non-local call. > > - You must not leave any return addresses on the process stack > that point to old versions of the code, or store funs in the > process state that point to old code. > Yes of course, but tell something new for me. > It's the second point that's hardest to grasp, because you need > a bit of understanding of how the implementation of a functional > language with tail recursion optimization and garbage collection > works. > > So, it can be quite easy to screw up code upgrade without using any > funs at all (which most people seem not to worry a lot about), and > there are really no problems with spawning new processes using > spawn(fun ...), which many people seem to worry about. Just relax > and learn to love the bomb. :-) > > /Richard > -- --Hynek (Pichi) Vychodil -------------- next part -------------- An HTML attachment was scrubbed... URL: From 0x6e6562@REDACTED Fri May 2 11:02:35 2008 From: 0x6e6562@REDACTED (Ben Hood) Date: Fri, 2 May 2008 10:02:35 +0100 Subject: [erlang-questions] os_mon on OS X Message-ID: <3E6FA007-65FB-4620-A1D6-7DDC4862C094@gmail.com> Hi, The get_uint32_measurement/2 call in cpu_sup seems to throw a bad match when the locale of the shell that the process is running in does not use a decimal point to denote a fraction. For example, if the result of /usr/bin/uptime is 1:59 up 1 day, 6:07, 5 users, load averages: 0,77 0,94 1,02 then the get_uint32_measurement fails. This occurs in R12B-1 with uname Darwin Macintosh-3.local 9.2.2 Darwin Kernel Version 9.2.2: Tue Mar 4 21:17:34 PST 2008; root:xnu-1228.4.31~1/RELEASE_I386 i386 There was a thread (http://forum.trapexit.org/mailinglists/viewtopic.php?t=4687&sid=89d1b0afdf03311a49b26a6376bef3e3 ) about this a few years ago, I don't know whether this is still an issue. Thx, Ben -------------- next part -------------- An HTML attachment was scrubbed... URL: From vychodil.hynek@REDACTED Fri May 2 11:57:16 2008 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Fri, 2 May 2008 11:57:16 +0200 Subject: [erlang-questions] what is the correct syntax to spawm a MFA with no arguments? In-Reply-To: <481AD9DF.1000405@it.uu.se> References: <3dbc6d1c0804301555i3bd04d28nd77e5d74860273d2@mail.gmail.com> <481916D8.10408@san.rr.com> <481995C1.4020506@it.uu.se> <4819F229.1040808@it.uu.se> <4d08db370805011013m157ac3cer7fc5754825688792@mail.gmail.com> <481A242D.50502@it.uu.se> <4d08db370805020152t66e56294sc860b698cb041262@mail.gmail.com> <481AD9DF.1000405@it.uu.se> Message-ID: <4d08db370805020257v3f4e38cepc65ae5e13d758e3b@mail.gmail.com> I'm sorry. I read again whole conversation and I found that I didn't understand exactly what you want tell. You wrote "no, it is not necessarily " and I read "no, it is not at all" and didn't understand "... but if you want, you can use first one". You want describe all possibilities and wrote those ones which not described in previous but I think that added ones are all by you. Sorry again. You clarified code loading nice in previous post. On Fri, May 2, 2008 at 11:07 AM, Richard Carlsson wrote: > Hynek Vychodil wrote: > > > What fool doing it? > > [...] > > *** or some other function called from its loop *** in my question. > > Nothing new on the world. > > [...] > > What fool adding ",ok" in this function? Just remove this stupid thing! > > [...] > > Yes of course, but tell something new for me. > > > > It was you who asked me to clarify my previous statements, and I spend > a lot of time writing such a clarification. Is it really too much to ask > from you to be polite in return? > > Your actual question was "Really? Are you sure? Well, then describe us how > long live running server turning around one loop/x function can change > code > of loop when you don't export loop/x function or some other function > called > from its loop. Just explain." (Also not very polite, but I still tried my > best to give you an answer.) Your question seemed strange to me, since I > have never said that you didn't need to export _any_ function for the > process. So, I tried to give a full explanation of what I meant: that > there > is a difference between exporting the _starting_ point of the process, and > exporting the _upgrade_ point of the process loop, and only the latter > needs > to use an exported function. > > /Richard > > > -- --Hynek (Pichi) Vychodil -------------- next part -------------- An HTML attachment was scrubbed... URL: From richardc@REDACTED Fri May 2 12:00:12 2008 From: richardc@REDACTED (Richard Carlsson) Date: Fri, 02 May 2008 12:00:12 +0200 Subject: [erlang-questions] what is the correct syntax to spawm a MFA with no arguments? In-Reply-To: <4d08db370805020257v3f4e38cepc65ae5e13d758e3b@mail.gmail.com> References: <3dbc6d1c0804301555i3bd04d28nd77e5d74860273d2@mail.gmail.com> <481916D8.10408@san.rr.com> <481995C1.4020506@it.uu.se> <4819F229.1040808@it.uu.se> <4d08db370805011013m157ac3cer7fc5754825688792@mail.gmail.com> <481A242D.50502@it.uu.se> <4d08db370805020152t66e56294sc860b698cb041262@mail.gmail.com> <481AD9DF.1000405@it.uu.se> <4d08db370805020257v3f4e38cepc65ae5e13d758e3b@mail.gmail.com> Message-ID: <481AE62C.7020908@it.uu.se> Hynek Vychodil wrote: > I'm sorry. I read again whole conversation and I found that I didn't > understand exactly what you want tell. You wrote "no, it is not > necessarily " and I read "no, it is not at all" and didn't understand > "... but if you want, you can use first one". You want describe all > possibilities and wrote those ones which not described in previous but I > think that added ones are all by you. Sorry again. You clarified code > loading nice in previous post. Thank you, /Richard From per@REDACTED Fri May 2 12:35:47 2008 From: per@REDACTED (Per Hedeland) Date: Fri, 2 May 2008 12:35:47 +0200 (CEST) Subject: [erlang-questions] file:read_file/2 bug? In-Reply-To: Message-ID: <200805021035.m42AZlXu098915@pluto.hedeland.org> "Christian S" wrote: > >On Thu, May 1, 2008 at 8:43 PM, Per Hedeland wrote: > >> I don't think any of the Erlang file(3) >> functionality is quite up to the general task. > >My approach have been like Serge's second attempt, to open then read >with a sufficiently big read byte-count. That's an Erlang file-module >approach. Are you saying that there is problems with that too? If you can read the whole thing in one call to read(2) (i.e. the OS system call), you should be safe - but in some cases this may not be reasonable, some /proc entries can deliver *very* long (exact length not known in advance) lists of items. And even in the case that it is reasonable, you may want to double-check whether file:read(FD, N) always turns into a single call to read(2), no matter how big N is (it probably does, but...). --Per From per@REDACTED Fri May 2 12:53:35 2008 From: per@REDACTED (Per Hedeland) Date: Fri, 2 May 2008 12:53:35 +0200 (CEST) Subject: [erlang-questions] gen_tcp nonblocking send In-Reply-To: Message-ID: <200805021053.m42ArYaI099182@pluto.hedeland.org> "Igor Ribeiro Sucupira" wrote: > >But, how do you deal with the situation (definitely not Daniel's case) >in which you just want to NOT send the message if the buffer is full >("Oh... system overload... nevermind... I don't want to make the >situation worst... I'll come back when I have something >important...")? :-) Well, definitely not by using O_NDELAY/O_NONBLOCK, since they do not (in general) provide that functionality - they will let you send however much that fits in the send buffer and leave you to deal with the rest. In fact I don't think there is a portable way to do what you're asking about - i.e. basically check whether there is enough buffer space without attempting to send anything. I do think *this* functionality could be useful in Daniel's case though - he'd probably prefer to queue and possibly eliminate also the message that hit the "buffer full" condition. --Per From dg@REDACTED Fri May 2 13:14:56 2008 From: dg@REDACTED (Daniel Ginsburg) Date: Fri, 02 May 2008 15:14:56 +0400 Subject: [erlang-questions] gen_tcp nonblocking send In-Reply-To: <200805021053.m42ArYaI099182@pluto.hedeland.org> References: <200805021053.m42ArYaI099182@pluto.hedeland.org> Message-ID: <481AF7B0.9030900@ot-e.biz> On 02.05.2008 14:53 Per Hedeland wrote: > I do think *this* functionality could be useful in Daniel's case though > - he'd probably prefer to queue and possibly eliminate also the message > that hit the "buffer full" condition. > It would be a minor optimization. There're quite a few other messages sitting in kernel's send buffer, and it is not possible to eliminate them either. -- dg From per@REDACTED Fri May 2 13:26:21 2008 From: per@REDACTED (Per Hedeland) Date: Fri, 2 May 2008 13:26:21 +0200 (CEST) Subject: [erlang-questions] gen_tcp nonblocking send In-Reply-To: <007601c8abc6$377c0c90$6701a8c0@moneymaker2> Message-ID: <200805021126.m42BQLV0099968@pluto.hedeland.org> "Valentin Micic" wrote: > >You're right -- I did not read it carefully enough. Your suggestion would >not develop a scheduling problem. However, after reading it again, I'm >really not sure why would O_NDEALY be such an evil thing, if it is >implemented as a separate function call (and not as a flag), that would >return a binary containing unsent octets. But what's the point of giving that back to the application, when the only thing the application can do with it is to keep it around until gen_tcp says "OK, I can take some more" (an async message that the app has to "actively" receive) - at which point the application gives it back to gen_tcp, who may *still* not be able to send it all, and gives a new binary back, which the application has to keep around until... Seems to me like requiring quite a bit of complex programming for no gain. > It would certainly help (in this >case not-so) intelligent queuing on the caller side -- unlike your sender >that needs to do pre-emptive queuing, until it receive's ack from "relay", >it would need to queue only unsent octets, right? Yes, there is of course some possibility that new messages may arrive to sender before the ack after a gen_tcp:send() that didn't "really" block arrives. A "good" solution to that would be to (instead of the "relay" process) have an option that made gen_tcp:send() say "this will take a while, I'll send you a message when I'm done" instead of blocking, but *only* in the case where it would otherwise block (as opposed to what I called "async send", which does it always), without passing the unsent octets back. But again, is it worth the added complexity? Now you have a multiple-choice sender, and to fully test it you *must* produce the blocking scenario, whereas the simple async-send -> ack scheme always works the same, and only requires the code that you need for the "really blocking" case anyway. Of course there are cases where you have to deal with complexity to get the performance you need, but then a) you should first make sure that this really is one of those, and b) the next step would be to get rid of the "relay" process and have gen_tcp provide the simple async-send -> ack interface directly (after all, the relay process is just undoing what prim_inet does). --Per From richardc@REDACTED Fri May 2 11:07:43 2008 From: richardc@REDACTED (Richard Carlsson) Date: Fri, 02 May 2008 11:07:43 +0200 Subject: [erlang-questions] what is the correct syntax to spawm a MFA with no arguments? In-Reply-To: <4d08db370805020152t66e56294sc860b698cb041262@mail.gmail.com> References: <4818E171.2000701@rldn.net> <3dbc6d1c0804301555i3bd04d28nd77e5d74860273d2@mail.gmail.com> <481916D8.10408@san.rr.com> <481995C1.4020506@it.uu.se> <4819F229.1040808@it.uu.se> <4d08db370805011013m157ac3cer7fc5754825688792@mail.gmail.com> <481A242D.50502@it.uu.se> <4d08db370805020152t66e56294sc860b698cb041262@mail.gmail.com> Message-ID: <481AD9DF.1000405@it.uu.se> Hynek Vychodil wrote: > What fool doing it? > [...] > *** or some other function called from its loop *** in my question. > Nothing new on the world. > [...] > What fool adding ",ok" in this function? Just remove this stupid thing! > [...] > Yes of course, but tell something new for me. It was you who asked me to clarify my previous statements, and I spend a lot of time writing such a clarification. Is it really too much to ask from you to be polite in return? Your actual question was "Really? Are you sure? Well, then describe us how long live running server turning around one loop/x function can change code of loop when you don't export loop/x function or some other function called from its loop. Just explain." (Also not very polite, but I still tried my best to give you an answer.) Your question seemed strange to me, since I have never said that you didn't need to export _any_ function for the process. So, I tried to give a full explanation of what I meant: that there is a difference between exporting the _starting_ point of the process, and exporting the _upgrade_ point of the process loop, and only the latter needs to use an exported function. /Richard From cjsvance@REDACTED Fri May 2 16:05:18 2008 From: cjsvance@REDACTED (Christopher Vance) Date: Sat, 3 May 2008 00:05:18 +1000 Subject: [erlang-questions] faxien dead? Message-ID: In the erlyverse, there appears to be lots of fragmentation and ideas, with competing projects for collections, etc., but they all seem to peter out before too long. Should we expect faxien eventually to catch up to a current erts, or is it (faxien) not worth the effort anyway? The promise of an OTP builder is nice, given the effort it took to make my builds work on a combination of OSs, and my hopes for platform independence, but the erlang in my environment is too new for faxien to cope with. -- Christopher Vance From tobbe@REDACTED Fri May 2 19:21:49 2008 From: tobbe@REDACTED (Torbjorn Tornkvist) Date: Fri, 02 May 2008 19:21:49 +0200 Subject: [erlang-questions] faxien dead? In-Reply-To: References: Message-ID: Christopher Vance wrote: > In the erlyverse, there appears to be lots of fragmentation and ideas, > with competing projects for collections, etc., but they all seem to > peter out before too long. > > Should we expect faxien eventually to catch up to a current erts, or > is it (faxien) not worth the effort anyway? I've been trying out the Erlware tools the last weeks and I think they are excellent! Still a bit rough here and there but it can only get better. I plan to do a little writeup of my experiences soon. But already today I can recommend Erlware. It is extremely nice to develop without having to think about where a particular .hrl file is, or check for any required libs. It is all taken care of. For the first time I'm able to write a proper OTP application with very little effort. So I hope erlware can continue to develop into becoming the defacto standard way of packaging and releasing Erlang libraries and applications. --Tobbe From cyberlync@REDACTED Fri May 2 19:26:32 2008 From: cyberlync@REDACTED (Eric Merritt) Date: Fri, 2 May 2008 17:26:32 +0000 Subject: [erlang-questions] faxien dead? In-Reply-To: References: Message-ID: On Fri, May 2, 2008 at 2:05 PM, Christopher Vance wrote: > In the erlyverse, there appears to be lots of fragmentation and ideas, > with competing projects for collections, etc., but they all seem to > peter out before too long. > > Should we expect faxien eventually to catch up to a current erts, or > is it (faxien) not worth the effort anyway? Faxien and erlware in general is far from dead. Our dev list is active and all the projects are continually developed. We are getting ready to do our 1.0 release here in the next week or so. At that time faxien will be bumped. While it was in beta are concentrating on adding features and stabilizing the system not necessarily being up on the latest version of erts. When we do this release we will make a commitment to getting up on the latest erts as it comes out. This is all pretty obvious just by looking at the mailing list archives. > > The promise of an OTP builder is nice, given the effort it took to > make my builds work on a combination of OSs, and my hopes for platform > independence, but the erlang in my environment is too new for faxien > to cope with. Wait a week or so ;) > > -- > Christopher Vance > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From valentin@REDACTED Fri May 2 20:03:57 2008 From: valentin@REDACTED (Valentin Micic) Date: Fri, 2 May 2008 20:03:57 +0200 Subject: [erlang-questions] gen_tcp nonblocking send References: <200805021126.m42BQLV0099968@pluto.hedeland.org> Message-ID: <00b101c8ac7e$e500f0c0$6701a8c0@moneymaker2> "When there is no choice, there is no management". Norbert Wiener Assuming that not every problem is the same, there is always some merit in being able to do things differently -- I, for one, like to have a choice when deciding about how to do things. As for complexity and weather or not is worth it, well, I suppose that would depend on a problem one tries to solve. Easier and simple is usually good but not always better - sometimes an extra effort may help in a long run. Sometimes the fact that you did not manage to send the whole buffer may be information in its own right (and, by definition, prompt you to do something about it). Thus, you may choose to raise a performance related alarm/event, or decide to start using additional communication channels, etc. And yes, you may achieve all of it by blocking, and then timing out, and then do something about it, and yes, that might be the best approach in 99% of situations (*). But there is always a time when it doesn't, hence, the question than would be, is a workaround worth it or not? V. (*) Think of situations where both peers are using a single process (each) for reading and writing to a socket, and potential for a deadlock caused by exhaustion of both buffers - I saw this happening when multiple processes are sharing a connection (via relay) during heavy traffic loads. Being able to timely service receive instead of blocking on send will most certainly prevent such a situation. ----- Original Message ----- From: "Per Hedeland" To: Cc: ; Sent: Friday, May 02, 2008 1:26 PM Subject: Re: [erlang-questions] gen_tcp nonblocking send > "Valentin Micic" wrote: >> >>You're right -- I did not read it carefully enough. Your suggestion would >>not develop a scheduling problem. However, after reading it again, I'm >>really not sure why would O_NDEALY be such an evil thing, if it is >>implemented as a separate function call (and not as a flag), that would >>return a binary containing unsent octets. > > But what's the point of giving that back to the application, when the > only thing the application can do with it is to keep it around until > gen_tcp says "OK, I can take some more" (an async message that the app > has to "actively" receive) - at which point the application gives it > back to gen_tcp, who may *still* not be able to send it all, and gives a > new binary back, which the application has to keep around until... Seems > to me like requiring quite a bit of complex programming for no gain. > >> It would certainly help (in this >>case not-so) intelligent queuing on the caller side -- unlike your sender >>that needs to do pre-emptive queuing, until it receive's ack from "relay", >>it would need to queue only unsent octets, right? > > Yes, there is of course some possibility that new messages may arrive to > sender before the ack after a gen_tcp:send() that didn't "really" block > arrives. A "good" solution to that would be to (instead of the "relay" > process) have an option that made gen_tcp:send() say "this will take a > while, I'll send you a message when I'm done" instead of blocking, but > *only* in the case where it would otherwise block (as opposed to what I > called "async send", which does it always), without passing the unsent > octets back. > > But again, is it worth the added complexity? Now you have a > multiple-choice sender, and to fully test it you *must* produce the > blocking scenario, whereas the simple async-send -> ack scheme always > works the same, and only requires the code that you need for the "really > blocking" case anyway. Of course there are cases where you have to deal > with complexity to get the performance you need, but then a) you should > first make sure that this really is one of those, and b) the next step > would be to get rid of the "relay" process and have gen_tcp provide the > simple async-send -> ack interface directly (after all, the relay > process is just undoing what prim_inet does). > > --Per > From igorrs@REDACTED Fri May 2 22:53:40 2008 From: igorrs@REDACTED (Igor Ribeiro Sucupira) Date: Fri, 2 May 2008 17:53:40 -0300 Subject: [erlang-questions] gen_tcp nonblocking send In-Reply-To: <200805021053.m42ArYaI099182@pluto.hedeland.org> References: <200805021053.m42ArYaI099182@pluto.hedeland.org> Message-ID: On Fri, May 2, 2008 at 7:53 AM, Per Hedeland wrote: > "Igor Ribeiro Sucupira" wrote: > > > > >But, how do you deal with the situation (definitely not Daniel's case) > >in which you just want to NOT send the message if the buffer is full > >("Oh... system overload... nevermind... I don't want to make the > >situation worst... I'll come back when I have something > >important...")? :-) > > Well, definitely not by using O_NDELAY/O_NONBLOCK, since they do not (in > general) provide that functionality - they will let you send however > much that fits in the send buffer and leave you to deal with the rest. I meant the "0 byte sent" case. I have this bad habit of being too brief sometimes. :-) Igor. > In fact I don't think there is a portable way to do what you're asking > about - i.e. basically check whether there is enough buffer space > without attempting to send anything. > > I do think *this* functionality could be useful in Daniel's case though > - he'd probably prefer to queue and possibly eliminate also the message > that hit the "buffer full" condition. > > --Per From igorrs@REDACTED Fri May 2 23:02:09 2008 From: igorrs@REDACTED (Igor Ribeiro Sucupira) Date: Fri, 2 May 2008 18:02:09 -0300 Subject: [erlang-questions] gen_tcp nonblocking send In-Reply-To: <00b101c8ac7e$e500f0c0$6701a8c0@moneymaker2> References: <200805021126.m42BQLV0099968@pluto.hedeland.org> <00b101c8ac7e$e500f0c0$6701a8c0@moneymaker2> Message-ID: On Fri, May 2, 2008 at 3:03 PM, Valentin Micic wrote: > > (*) Think of situations where both peers are using a single process (each) > for reading and writing to a socket, and potential for a deadlock caused by > exhaustion of both buffers - I saw this happening when multiple processes > are sharing a connection (via relay) during heavy traffic loads. Being able > to timely service receive instead of blocking on send will most certainly > prevent such a situation. In the sequential world, there are always lots of good reasons to avoid blocking. Igor. > ----- Original Message ----- > From: "Per Hedeland" > To: > Cc: ; > Sent: Friday, May 02, 2008 1:26 PM > Subject: Re: [erlang-questions] gen_tcp nonblocking send > > > > > > "Valentin Micic" wrote: > >> > >>You're right -- I did not read it carefully enough. Your suggestion would > >>not develop a scheduling problem. However, after reading it again, I'm > >>really not sure why would O_NDEALY be such an evil thing, if it is > >>implemented as a separate function call (and not as a flag), that would > >>return a binary containing unsent octets. > > > > But what's the point of giving that back to the application, when the > > only thing the application can do with it is to keep it around until > > gen_tcp says "OK, I can take some more" (an async message that the app > > has to "actively" receive) - at which point the application gives it > > back to gen_tcp, who may *still* not be able to send it all, and gives a > > new binary back, which the application has to keep around until... Seems > > to me like requiring quite a bit of complex programming for no gain. > > > >> It would certainly help (in this > >>case not-so) intelligent queuing on the caller side -- unlike your sender > >>that needs to do pre-emptive queuing, until it receive's ack from "relay", > >>it would need to queue only unsent octets, right? > > > > Yes, there is of course some possibility that new messages may arrive to > > sender before the ack after a gen_tcp:send() that didn't "really" block > > arrives. A "good" solution to that would be to (instead of the "relay" > > process) have an option that made gen_tcp:send() say "this will take a > > while, I'll send you a message when I'm done" instead of blocking, but > > *only* in the case where it would otherwise block (as opposed to what I > > called "async send", which does it always), without passing the unsent > > octets back. > > > > But again, is it worth the added complexity? Now you have a > > multiple-choice sender, and to fully test it you *must* produce the > > blocking scenario, whereas the simple async-send -> ack scheme always > > works the same, and only requires the code that you need for the "really > > blocking" case anyway. Of course there are cases where you have to deal > > with complexity to get the performance you need, but then a) you should > > first make sure that this really is one of those, and b) the next step > > would be to get rid of the "relay" process and have gen_tcp provide the > > simple async-send -> ack interface directly (after all, the relay > > process is just undoing what prim_inet does). > > > > --Per > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From per@REDACTED Sat May 3 00:35:00 2008 From: per@REDACTED (Per Hedeland) Date: Sat, 3 May 2008 00:35:00 +0200 (CEST) Subject: [erlang-questions] gen_tcp nonblocking send In-Reply-To: Message-ID: <200805022235.m42MZ0L6013424@pluto.hedeland.org> "Igor Ribeiro Sucupira" wrote: > >On Fri, May 2, 2008 at 7:53 AM, Per Hedeland wrote: >> "Igor Ribeiro Sucupira" wrote: >> > >> >> >But, how do you deal with the situation (definitely not Daniel's case) >> >in which you just want to NOT send the message if the buffer is full >> >("Oh... system overload... nevermind... I don't want to make the >> >situation worst... I'll come back when I have something >> >important...")? :-) >> >> Well, definitely not by using O_NDELAY/O_NONBLOCK, since they do not (in >> general) provide that functionality - they will let you send however >> much that fits in the send buffer and leave you to deal with the rest. > > >I meant the "0 byte sent" case. I realized that, was just saying that O_NDELAY/O_NONBLOCK don't (in general) provide it. With some man page browsing, I found that on FreeBSD you can apparently get the "don't send anything if you can't send it all" effect by diddling the SO_SNDLOWAT setting (or in fact you will get it by default if what you're trying to send is smaller than the default SO_SNDLOWAT) - but on Linux it is at least not documented as having this effect, and is in any case hardwired to 1 (can't be changed). --Per From cjsvance@REDACTED Sat May 3 04:48:18 2008 From: cjsvance@REDACTED (Christopher Vance) Date: Sat, 3 May 2008 12:48:18 +1000 Subject: [erlang-questions] faxien dead? In-Reply-To: References: Message-ID: On Sat, May 3, 2008 at 3:26 AM, Eric Merritt wrote: > Wait a week or so ;) Okay. Thanks. -- Christopher Vance From cjsvance@REDACTED Sat May 3 04:49:37 2008 From: cjsvance@REDACTED (Christopher Vance) Date: Sat, 3 May 2008 12:49:37 +1000 Subject: [erlang-questions] faxien dead? In-Reply-To: References: Message-ID: On Sat, May 3, 2008 at 3:21 AM, Torbjorn Tornkvist wrote: > I've been trying out the Erlware tools the last weeks and > I think they are excellent! Still a bit rough here and there > but it can only get better. I plan to do a little writeup > of my experiences soon. > > But already today I can recommend Erlware. Okay. > It is extremely nice to develop without having to think > about where a particular .hrl file is, or check for any > required libs. It is all taken care of. For the first time > I'm able to write a proper OTP application with very > little effort. > > So I hope erlware can continue to develop into becoming > the defacto standard way of packaging and releasing Erlang > libraries and applications. Excellent. Thanks. -- Christopher Vance From jeffm@REDACTED Sat May 3 06:51:33 2008 From: jeffm@REDACTED (jm) Date: Sat, 03 May 2008 14:51:33 +1000 Subject: [erlang-questions] io:format printing integers prefixed with zero(0) Message-ID: <481BEF55.1050206@ghostgun.com> Given an integer is there a format which will prefix it with zeros to a fixed width? eg, 3 => 003 50 => 050 205 => 205 the equivelant of C's printf("%3.3d", i). Jeff. From erlangy@REDACTED Sat May 3 07:22:06 2008 From: erlangy@REDACTED (Michael McDaniel) Date: Fri, 2 May 2008 22:22:06 -0700 Subject: [erlang-questions] io:format printing integers prefixed with zero(0) In-Reply-To: <481BEF55.1050206@ghostgun.com> References: <481BEF55.1050206@ghostgun.com> Message-ID: <20080503052206.GA6784@delora.autosys.us> On Sat, May 03, 2008 at 02:51:33PM +1000, jm wrote: > Given an integer is there a format which will prefix it with zeros to a > fixed width? eg, > > 3 => 003 > 50 => 050 > 205 => 205 > > the equivelant of C's printf("%3.3d", i). > > > Jeff. > _______________________________________________ (del@REDACTED)40> io:fwrite("~3.3.0w ", [1]). 001 ok (del@REDACTED)41> io:fwrite("~3.3.0w ", [10]). 010 ok (del@REDACTED)42> io:fwrite("~3.3.0w ", [100]). 100 ok (del@REDACTED)43> see io docs; file:///usr/local/lib/erlang/lib/stdlib-1.15/doc/html/io.html on my system ~Michael From qrilka@REDACTED Sat May 3 20:00:31 2008 From: qrilka@REDACTED (Kirill Zaborski) Date: Sat, 3 May 2008 22:00:31 +0400 Subject: [erlang-questions] How do I compute daytime difference properly? Message-ID: <337538cb0805031100j257b64e6ob0a5109acf549c54@mail.gmail.com> Reading calendar module documentation I see the note: "For computing differences between epochs in time, use the functions counting gregorian days or seconds. If epochs are given as local time, they must be converted to universal time, in order to get the correct value of the elapsed time between epochs. Use of the function time_difference/2 is discouraged." But it's not quite clear to me... E.g. I have 2 values LocalTime1 and LocalTime2 which are somewhat like tuples erlang:localtime/0 and need to compute time difference e.g. in seconds. So should I then convert this values to UTC and then use calendar:datetime_to_gregorian_seconds/1 and then do the subtraction? Or maybe there is some easier way? Best regards, Kirill. -------------- next part -------------- An HTML attachment was scrubbed... URL: From igorrs@REDACTED Sat May 3 21:10:28 2008 From: igorrs@REDACTED (Igor Ribeiro Sucupira) Date: Sat, 3 May 2008 16:10:28 -0300 Subject: [erlang-questions] How do I compute daytime difference properly? In-Reply-To: <337538cb0805031100j257b64e6ob0a5109acf549c54@mail.gmail.com> References: <337538cb0805031100j257b64e6ob0a5109acf549c54@mail.gmail.com> Message-ID: I think there's no easier way of doing that. 2008/5/3 Kirill Zaborski : > > Reading calendar module documentation I see the note: > "For computing differences between epochs in time, use the functions > counting gregorian days or seconds. If epochs are given as local time, they > must be converted to universal time, in order to get the correct value of > the elapsed time between epochs. Use of the function time_difference/2 is > discouraged." > But it's not quite clear to me... > E.g. I have 2 values LocalTime1 and LocalTime2 which are somewhat like > tuples erlang:localtime/0 and need to compute time difference e.g. in > seconds. So should I then convert this values to UTC and then use > calendar:datetime_to_gregorian_seconds/1 and then do the subtraction? > Or maybe there is some easier way? > > Best regards, > Kirill. From billrobertson42@REDACTED Mon May 5 02:38:09 2008 From: billrobertson42@REDACTED (Bill Robertson) Date: Sun, 4 May 2008 17:38:09 -0700 (PDT) Subject: [erlang-questions] Suggestion for the Mnesia manual Message-ID: <886853.81952.qm@web51907.mail.re2.yahoo.com> In section 3.3.1 (Initializing a Schema and Starting Mnesia) of the Mnesia manual, there is a function similar to this... -module(foo). -export([init/0, init2/0, init3/0]). -record(foo, {a, b}). -record(bar, {a, b}). -record(baz, {a, b}). init() -> mnesia:create_table(t1, [{attributes,record_info(fields, foo)}, {disk_only_copies, [node()]} ]), mnesia:create_table(t2, [{attributes,record_info(fields, bar)}, {disk_only_copies, [node()]} ]), mnesia:create_table(t3, [{attributes,record_info(fields, baz)}, {disk_only_copies, [node()]} ]). 43> foo:init(). {aborted,{badarg,t3,disk_only_copies}} The example in the manual is o.k. because it does not misspell "disc" like my code did. I'm new to the language, so I didn't realize what the real problem was. I only saw the error for the third table, and I spent the entire afternoon trying to figure out why the third statement failed when the first two didn't. Of course, that wasn't the problem at all. I just failed to understand that I was only seeing the return value of the last expression in the function and that they had all failed. I would like to suggest that the example in the Mnesia manual be rewritten to put the table information into a list and then call mnesia:create_table() in a list comprehension and return the result of that. This version returns the result of all calls, and might save somebody new to the language some time if they base their code off of the manual, because they would see all of their errors. init2() -> Tables = [{t1, [{attributes,record_info(fields, foo)}, {disk_only_copies, [node()]} ]}, {t2, [{attributes,record_info(fields, bar)}, {disk_only_copies, [node()]} ]}, {t3, [{attributes,record_info(fields, baz)}, {disk_only_copies, [node()]} ]}], [create_table(Table) || Table <- Tables]. create_table(TableInfo) -> {Table, Args} = TableInfo, mnesia:create_table(Table, Args). 44> foo:init2(). [{aborted,{badarg,t1,disk_only_copies}}, {aborted,{badarg,t2,disk_only_copies}}, {aborted,{badarg,t3,disk_only_copies}}] init3() -> Tables = [{t1, [{attributes,record_info(fields, foo)}, {disc_only_copies, [node()]} ]}, {t2, [{attributes,record_info(fields, bar)}, {disc_only_copies, [node()]} ]}, {t3, [{attributes,record_info(fields, baz)}, {disc_only_copies, [node()]} ]}], [create_table(Table) || Table <- Tables]. 45> foo:init3(). [{atomic,ok},{atomic,ok},{atomic,ok}] Thanks ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ From chlorophil@REDACTED Mon May 5 04:36:16 2008 From: chlorophil@REDACTED (Philip Robinson) Date: Mon, 5 May 2008 12:36:16 +1000 Subject: [erlang-questions] Suggestion for the Mnesia manual In-Reply-To: <886853.81952.qm@web51907.mail.re2.yahoo.com> References: <886853.81952.qm@web51907.mail.re2.yahoo.com> Message-ID: Hi Bill. I am a big fan of putting the expected return value on every line that is otherwise used for side-effects. Unification will then ensure that the code aborts on the first line in error; the later lines don't even get a chance to run. i.e.: init() -> {atomic, ok} = mnesia:create_table(t1...), {atomic, ok} = mnesia:create_table(t2...), {atomic, ok} = mnesia:create_table(t2...). Even using anonymous vars helps, e.g.: {ok, _} = some_side_effect_fun(), ensures that the return value wasn't {error, 'some message'} before continuing. Cheers, Philip On Mon, May 5, 2008 at 10:38 AM, Bill Robertson wrote: > In section 3.3.1 (Initializing a Schema and Starting Mnesia) of the > Mnesia manual, > there is a function similar to this... > > -module(foo). > -export([init/0, init2/0, init3/0]). > > -record(foo, {a, b}). > -record(bar, {a, b}). > -record(baz, {a, b}). > > init() -> > mnesia:create_table(t1, [{attributes,record_info(fields, foo)}, > {disk_only_copies, [node()]} ]), > mnesia:create_table(t2, [{attributes,record_info(fields, bar)}, > {disk_only_copies, [node()]} ]), > mnesia:create_table(t3, [{attributes,record_info(fields, baz)}, > {disk_only_copies, [node()]} ]). > > 43> foo:init(). > {aborted,{badarg,t3,disk_only_copies}} > > The example in the manual is o.k. because it does not misspell "disc" > like my code did. I'm new to the language, so I didn't realize what > the real problem was. I only saw the error for the third table, and > I spent the entire afternoon trying to figure out why the third statement > failed when the first two didn't. Of course, that wasn't the problem > at all. I just failed to understand that I was only seeing the return > value of the last expression in the function and that they had all > failed. > > I would like to suggest that the example in the Mnesia manual be > rewritten to put the table information into a list and then call > mnesia:create_table() in a list comprehension and return the result > of that. This version returns the result of all calls, and might > save somebody new to the language some time if they base their > code off of the manual, because they would see all of their errors. > > init2() -> > Tables = [{t1, [{attributes,record_info(fields, foo)}, > {disk_only_copies, [node()]} ]}, > {t2, [{attributes,record_info(fields, bar)}, > {disk_only_copies, [node()]} ]}, > {t3, [{attributes,record_info(fields, baz)}, > {disk_only_copies, [node()]} ]}], > [create_table(Table) || Table <- Tables]. > > create_table(TableInfo) -> > {Table, Args} = TableInfo, > mnesia:create_table(Table, Args). > > 44> foo:init2(). > [{aborted,{badarg,t1,disk_only_copies}}, > {aborted,{badarg,t2,disk_only_copies}}, > {aborted,{badarg,t3,disk_only_copies}}] > > init3() -> > Tables = [{t1, [{attributes,record_info(fields, foo)}, > {disc_only_copies, [node()]} ]}, > {t2, [{attributes,record_info(fields, bar)}, > {disc_only_copies, [node()]} ]}, > {t3, [{attributes,record_info(fields, baz)}, > {disc_only_copies, [node()]} ]}], > [create_table(Table) || Table <- Tables]. > > 45> foo:init3(). > [{atomic,ok},{atomic,ok},{atomic,ok}] > > Thanks From kostis@REDACTED Mon May 5 08:48:03 2008 From: kostis@REDACTED (Kostis Sagonas) Date: Mon, 05 May 2008 09:48:03 +0300 Subject: [erlang-questions] Suggestion for the Mnesia manual In-Reply-To: References: <886853.81952.qm@web51907.mail.re2.yahoo.com> Message-ID: <481EADA3.5090006@cs.ntua.gr> Philip Robinson wrote: > > I am a big fan of putting the expected return value on every line that > is otherwise used for side-effects. Unification will then ensure that > the code aborts on the first line in error; the later lines don't even > get a chance to run. > > i.e.: > init() -> > {atomic, ok} = mnesia:create_table(t1...), > {atomic, ok} = mnesia:create_table(t2...), > {atomic, ok} = mnesia:create_table(t2...). > > Even using anonymous vars helps, e.g.: > {ok, _} = some_side_effect_fun(), > ensures that the return value wasn't {error, 'some message'} before continuing. I am a very big fan of the practice that Philip advocates because it can avoid serious and often very subtle bugs in Erlang code. In fact, in the latest dialyzer, the one in R12B-2, we have added a command-line option -Wunmatched_returns that warns for calls used for side-effects which ignore their return value. (The option is off by default.) It strongly prefers code such as the above and will warn about calls which ignore their return value, such as: init() -> mnesia:create_table(t1, [{attributes,record_info(fields, foo)}, {disk_only_copies, [node()]} ]), mnesia:create_table(t2, [{attributes,record_info(fields, bar)}, {disk_only_copies, [node()]} ]), mnesia:create_table(t3, [{attributes,record_info(fields, baz)}, {disk_only_copies, [node()]} ]). or for code which exists all over the place, even in standard libraries, such as the one below (from escript.erl): compile(Parse, Args) -> case compile:forms(Parse, [report]) of {ok,Module,BeamCode} -> erlang:load_module(Module, BeamCode), run_code(Module, Args); _Other -> fatal("There were compilation errors.") end. which makes implicit assumptions (e.g. that the load always succeeds) that might not always hold. Kostis From ingela@REDACTED Mon May 5 09:12:57 2008 From: ingela@REDACTED (Ingela Anderton Andin) Date: Mon, 05 May 2008 09:12:57 +0200 Subject: [erlang-questions] Sometime it's the simple stuff... In-Reply-To: References: Message-ID: <481EB379.5030502@erix.ericsson.se> > I need to take an IP address in the form of "[{10,0,1,100}]" and > create an http URL like this: "http://10.0.1.100/". I've tried using > io_lib:format and successfully generated a list. But, the inets http > client doesn't like the format and complains of a malformed URL. Here I use io_lib:format to create a URL-string from your exampel (I guess that you mean that you have the ip-address on tupel format and not that you have a string looking like "[{10,0,1,100}]") and the inets client will parse it just fine. I did not do http:request as I have no server at this address... 1> URL = lists:flatten(io_lib:format("http://~w.~w.~w.~w/", tuple_to_list({10,0,1,100}))). "http://10.0.1.100/" 2> http_uri:parse(URL). {http,[],"10.0.1.100",80,"/",[]} ... but to prove my point I can do: 3> http:request(URL). {error,econnrefused} ... e.i it tried to call gen_tcp:connect and got connection refused, hence it has already parsed the URL successfully. But if you miss out one of the first "/" for instance: 4> http_uri:parse("http:/10.0.1.100/"). {error,{malformed_url,"http:/10.0.1.100"}} 5> http:request("http:/10.0.1.100/"). {error,{malformed_url,"http:/10.0.1.100"}} Maybe you missed something? Regards Ingela -OTP team From nick@REDACTED Mon May 5 09:40:22 2008 From: nick@REDACTED (Nick Gerakines) Date: Mon, 5 May 2008 00:40:22 -0700 Subject: [erlang-questions] Sometime it's the simple stuff... In-Reply-To: References: Message-ID: This is what I came up with. Keep in mind its late. %% @spec url_from_ip(IpTuple) -> string(). %% where %% IpTuple = {integer(), integer(), integer(), integer()} %% @doc Stringify a url out of an ip. %% Use: url_from_ip({10, 0, 100, 1}). url_from_ip(IpTuple) -> "http://" ++ lists:foldl(fun(A, "") -> A; (A, Acc) -> Acc ++ "." ++ A end, "", [integer_to_list(X)|| X <- tuple_to_list(IpTuple)]) ++ "/". *duck* # Nick Gerakines On Thu, May 1, 2008 at 6:56 AM, Dave Bryson wrote: > I need to take an IP address in the form of "[{10,0,1,100}]" and > create an http URL like this: "http://10.0.1.100/". I've tried using > io_lib:format and successfully generated a list. But, the inets http > client doesn't like the format and complains of a malformed URL. > > What's the easiest way to convert an IP to the String version? > > Thanks! > Dave > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From erlang@REDACTED Mon May 5 11:17:11 2008 From: erlang@REDACTED (Peter Lund) Date: Mon, 05 May 2008 11:17:11 +0200 Subject: [erlang-questions] io:format printing integers prefixed with zero(0) In-Reply-To: <20080503052206.GA6784@delora.autosys.us> References: <481BEF55.1050206@ghostgun.com> <20080503052206.GA6784@delora.autosys.us> Message-ID: <481ED097.9000602@lundata.se> or: 1> string:right(integer_to_list(3),3,$0). "003" 2> string:right(integer_to_list(50),3,$0). "050" 3> string:right(integer_to_list(205),3,$0). "205" 4> string:right(integer_to_list(33205),3,$0). "205" does almost the same... Michael McDaniel skrev: > On Sat, May 03, 2008 at 02:51:33PM +1000, jm wrote: > >> Given an integer is there a format which will prefix it with zeros to a >> fixed width? eg, >> >> 3 => 003 >> 50 => 050 >> 205 => 205 >> >> the equivelant of C's printf("%3.3d", i). >> >> >> Jeff. >> _______________________________________________ >> > > > > (del@REDACTED)40> io:fwrite("~3.3.0w ", [1]). > 001 ok > (del@REDACTED)41> io:fwrite("~3.3.0w ", [10]). > 010 ok > (del@REDACTED)42> io:fwrite("~3.3.0w ", [100]). > 100 ok > (del@REDACTED)43> > > > see io docs; file:///usr/local/lib/erlang/lib/stdlib-1.15/doc/html/io.html > on my system > > > ~Michael > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > From Jouni.Ryno@REDACTED Mon May 5 12:44:06 2008 From: Jouni.Ryno@REDACTED (Jouni =?ISO-8859-1?Q?Ryn=F6?=) Date: Mon, 05 May 2008 13:44:06 +0300 Subject: [erlang-questions] Suggestion for the Mnesia manual In-Reply-To: <481EADA3.5090006@cs.ntua.gr> References: <886853.81952.qm@web51907.mail.re2.yahoo.com> <481EADA3.5090006@cs.ntua.gr> Message-ID: <1209984246.7887.44.camel@adic.fmi.fi> So from analysis point of view, recursion still would be better? (sorry, deleted the original example, but this was directly from my own code, revealed by dialyzer ...) Instead of this (dialyzer tells me, that it produces value of type ['ok']) [ok = gen_server:cast(Client, {parameter, Para}) || Client <- ClientList] use the recursion serve_clients(Message, [Client|ClientList]) -> ok = gen_server:cast(Client, Message), serve_clients(Message, ClientList); serve_clients(Message, []) -> ok. Or to keep list comprehensions and make dialyzer happy with Oks = [ok || _Res <- ClienList], Oks = ?[ok = gen_server:cast(Client, {parameter, Para}) || Client <- ClientList] Jouni On Mon, 2008-05-05 at 09:48 +0300, Kostis Sagonas wrote: > Philip Robinson wrote: > > > > I am a big fan of putting the expected return value on every line that > > is otherwise used for side-effects. Unification will then ensure that > > the code aborts on the first line in error; the later lines don't even > > get a chance to run. > > > > i.e.: > > init() -> > > {atomic, ok} = mnesia:create_table(t1...), > > {atomic, ok} = mnesia:create_table(t2...), > > {atomic, ok} = mnesia:create_table(t2...). > > > > Even using anonymous vars helps, e.g.: > > {ok, _} = some_side_effect_fun(), > > ensures that the return value wasn't {error, 'some message'} before continuing. > > I am a very big fan of the practice that Philip advocates because it can > avoid serious and often very subtle bugs in Erlang code. In fact, in > the latest dialyzer, the one in R12B-2, we have added a command-line > option -Wunmatched_returns that warns for calls used for side-effects > which ignore their return value. (The option is off by default.) > > It strongly prefers code such as the above and will warn about calls > which ignore their return value, such as: > > init() -> > mnesia:create_table(t1, [{attributes,record_info(fields, foo)}, > {disk_only_copies, [node()]} ]), > mnesia:create_table(t2, [{attributes,record_info(fields, bar)}, > {disk_only_copies, [node()]} ]), > mnesia:create_table(t3, [{attributes,record_info(fields, baz)}, > {disk_only_copies, [node()]} ]). > > or for code which exists all over the place, even in standard libraries, > such as the one below (from escript.erl): > > compile(Parse, Args) -> > case compile:forms(Parse, [report]) of > {ok,Module,BeamCode} -> > erlang:load_module(Module, BeamCode), > run_code(Module, Args); > _Other -> > fatal("There were compilation errors.") > end. > > which makes implicit assumptions (e.g. that the load always succeeds) > that might not always hold. > > Kostis > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- Jouni Ryn? mailto://Jouni.Ryno@REDACTED/ http://space.fmi.fi/~ryno/ Finnish Meteorological Institute http://www.fmi.fi/ P.O.BOX 503 Tel (+358)-9-19294656 FIN-00101 Helsinki FAX (+358)-9-19294603 Finland priv-GSM (+358)-50-5302903 "It's just zeros and ones, it cannot be hard" From kostis@REDACTED Mon May 5 13:05:17 2008 From: kostis@REDACTED (Kostis Sagonas) Date: Mon, 05 May 2008 14:05:17 +0300 Subject: [erlang-questions] Suggestion for the Mnesia manual In-Reply-To: <1209984246.7887.44.camel@adic.fmi.fi> References: <886853.81952.qm@web51907.mail.re2.yahoo.com> <481EADA3.5090006@cs.ntua.gr> <1209984246.7887.44.camel@adic.fmi.fi> Message-ID: <481EE9ED.3060601@cs.ntua.gr> Jouni Ryn? wrote: > So from analysis point of view, recursion still would be better? (sorry, > deleted the original example, but this was directly from my own code, > revealed by dialyzer ...) > > Instead of this (dialyzer tells me, that it produces value of type > ['ok']) > [ok = gen_server:cast(Client, {parameter, Para}) || Client <- > ClientList] > > use the recursion > serve_clients(Message, [Client|ClientList]) -> > ok = gen_server:cast(Client, Message), > serve_clients(Message, ClientList); > serve_clients(Message, []) -> > ok. The best way to write the above is using lists:foreach/2 as in: lists:foreach(fun (Client) -> gen_server:cast(Client, {parameter, Para}) end, Clients) which achieves what you want, in my opinion expresses the intention of the programmer clearer than a comprehension and makes dialyzer happy. Kostis PS. I am aware that in R12B, lists comprehensions are compiled in such a way that a list for the result is not constructed when the result is not used, but this is just a compiler optimization which happens at a later stage - not something formally defined in the language or in Core Erlang. From daveb@REDACTED Mon May 5 14:32:08 2008 From: daveb@REDACTED (Dave Bryson) Date: Mon, 5 May 2008 07:32:08 -0500 Subject: [erlang-questions] Sometime it's the simple stuff... In-Reply-To: <481EB379.5030502@erix.ericsson.se> References: <481EB379.5030502@erix.ericsson.se> Message-ID: Thanks Ingela. That's the approach I'm using now. Although I didn't think about using "tuple_to_list()". I was patten matching on the tuple: {A,B,C,D} = {10,0.1.100}. You approach is cleaner. Thanks again, Dave On May 5, 2008, at 2:12 AM, Ingela Anderton Andin wrote: >> I need to take an IP address in the form of "[{10,0,1,100}]" and >> create an http URL like this: "http://10.0.1.100/". I've tried >> using >> io_lib:format and successfully generated a list. But, the inets http >> client doesn't like the format and complains of a malformed URL. > > Here I use io_lib:format to create a URL-string from your exampel (I > guess that you mean that you have the ip-address on tupel > format and not that you have a string looking like "[{10,0,1,100}]") > and > the inets client will parse it just fine. I did not do http:request > as I have > no server at this address... > > 1> URL = lists:flatten(io_lib:format("http://~w.~w.~w.~w/", > tuple_to_list({10,0,1,100}))). > "http://10.0.1.100/" > 2> http_uri:parse(URL). > {http,[],"10.0.1.100",80,"/",[]} > > ... but to prove my point I can do: > > 3> http:request(URL). > {error,econnrefused} > > ... e.i it tried to call gen_tcp:connect and got connection refused, > hence it has already parsed the URL > successfully. > > But if you miss out one of the first "/" for instance: > > 4> http_uri:parse("http:/10.0.1.100/"). > {error,{malformed_url,"http:/10.0.1.100"}} > > 5> http:request("http:/10.0.1.100/"). > {error,{malformed_url,"http:/10.0.1.100"}} > > Maybe you missed something? > > Regards Ingela -OTP team > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From raimo+erlang-questions@REDACTED Mon May 5 15:16:22 2008 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Mon, 5 May 2008 15:16:22 +0200 Subject: [erlang-questions] : build 64bit Erlang on Solairs In-Reply-To: <20080501153708.GA3849@Sun.Com> References: <20080501122408.GA3630@Sun.Com> <18457.53560.59691.24368@harpo.it.uu.se> <20080501153708.GA3849@Sun.Com> Message-ID: <20080505131622.GA12042@erix.ericsson.se> On Thu, May 01, 2008 at 11:37:09PM +0800, Raymond Xiong wrote: > On 05/01/08, Mikael Pettersson wrote: > > > > > > gcc -o /export/erlang/usr/src/cmd/erlang/root/otp_src_R12B-1/bin/sparc-sun-solaris2.11/beam.smp -R/usr/lib/64 -L/usr/lib/64 obj/sparc-sun-solaris2.11/opt/smp/erl_main.o ...(snipped) > > > ld: fatal: file obj/sparc-sun-solaris2.11/opt/smp/erl_main.o: > > > wrong ELF class: ELFCLASS64 > > > > > > >From what I know, the above error message means that ld was > > > trying to generate 32bit binary file, but found the object > > > files passed to it were 64bit files. > > > > > > According to ld(1) man page on Solaris, ld can guess to generate > > > 32bit binary file or 64bit binary file: > > > > But the command above is not ld but gcc, and gcc requires -m64 to > > produce a 64-bit executable if its default is 32-bit. What happens > > is that gcc passes more options to ld than just the object file names, > > and typically one of those options selects the executable format. > > Hence gcc needs to be told if you want a non-default format. > > Mikael, > > Thanks for the information, I had thought gcc just let ld to > decide that. > > If so, however, isn't it better to add CFLAGS in the follwing > line in erts/emulator/Makefile.in? > > $(BINDIR)/$(EMULATOR_EXECUTABLE): $(INIT_OBJS) $(OBJS) > $(PURIFY) $(LD) -o $(BINDIR)/$(EMULATOR_EXECUTABLE) \ > $(HIPEBEAMLDFLAGS) $(LDFLAGS) $(DEXPORT) $(INIT_OBJS) $(OBJS) $(LIBS) > It sounds weird to add CFLAGS to the LD command line. > > > > [snip] > > > I guess there must be many people who compile 64bit Erlang on > > > Solaris, I googled this but only found this thread, which > > > sugested to hard code gcc to "gcc -m64": > > > > > > http://www.erlang.org/pipermail/erlang-questions/2006-July/021336.html > > > > > > I suppose there must be a better way than that? > > > > env CFLAGS='-m64 -O2' LDFLAGS=-m64 ./configure ; make > > > > also works; I just did that to build R12B-2 on a Solaris 10 box. > > Yes, I believe it would work(I haven't try it on my SPARC box yet, > because the machine is slow and it takes more than half an hour > to finish). > > However, I doubt if you can enable ssl support. I expect the > following command would fail because mixing of 32-bit objects > and 64-bit objects is not permitted: > > env CFLAGS='-m64 -O2' LDFLAGS=-m64 ./configure --with-ssl=/usr/sfw \ > --enable-dynamic-ssl-lib ; make > > 64bit ssl lib is under /usr/sfw/lib/64, do you have any suggestion > on how to let Erlang use 64bit ssl lib under that subdir(but header > files are still under /usr/sfw/include of course)? > In our nightly builds we have a directory early in the path that contains two scripts, essentially: gcc: #! /bin/sh exec /usr/local/pgm/.../bin/gcc -m64 ${1+"$@"} ld: #! /bin/sh exec /usr/ccs/bin/ld -64 ${1+"$@"} and we set: PATH=/usr/local/bin:/usr/sfw/bin:... LD_LIBRARY_PATH=/usr/local/lib:/usr/sfw/lib LD_LIBRARY_PATH_64=/usr/sfw/lib/64 We have it building and running, but it is not a pretty solution. > > > > The advantage of "env CC=gcc64 ./configure; make" is that > > you don't have to worry about missing some *FLAGS variable. > > > > Yes, as a user I understand that, but I am building a package > for OpenSolaris, so I need a more formal way. > > Thanks for your help! > > -- > Regards, > Raymond > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From raimo+erlang-questions@REDACTED Mon May 5 15:31:37 2008 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Mon, 5 May 2008 15:31:37 +0200 Subject: [erlang-questions] : file:read_file/2 bug? In-Reply-To: References: <48192CCB.2070209@gmail.com> Message-ID: <20080505133137.GB12042@erix.ericsson.se> On Thu, May 01, 2008 at 03:27:55PM +0200, Christian S wrote: > On Thu, May 1, 2008 at 4:36 AM, Serge Aleynikov wrote: > > For some reason file:read_file/1 always returns empty binary when > > reading from any file in the "/proc" filesystem. > > Running strace reveals what is done behind the scenes: > > stat64("/proc/self/environ", {st_mode=S_IFREG|0400, st_size=0, ...}) = 0 > open("/proc/self/environ", O_RDONLY|O_LARGEFILE) = 7 > close(7) = 0 > > Looking at /erts/emulator/drivers/unix/unix_efile.c one can also see > that efile_openfile calls stat() on the filename before it open() the > file. > > I dont understand why everything is done in efile_openfile that is > done, but my guess is that if one first open() the file then use > fstat() on the file descriptor, then the proc filesystem would report > nonzero file length. > efile_openfile begins with a stat() to check that the file is a regular file. After open() it returns the size to the caller of efile_openfile, that is efile_drv.c, so it can know how large buffer to allocate for the file contents. To begin with a stat() then open() and then do a stat() for the size on the file descriptor might be a fix to use on the "/proc" file system. E.g "/dev/null" has already got special treatement, so why not "/proc". > Understanding would make it worthwile to submit a patch for the efile driver. > > The linux kernel generates the proc file's content as a snapshot at > the instance the file is opened. Before open() it doesnt know how long > the content will be. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From bekesa@REDACTED Mon May 5 16:10:53 2008 From: bekesa@REDACTED (Andras Georgy Bekes) Date: Mon, 05 May 2008 16:10:53 +0200 Subject: [erlang-questions] dialyzer <-> exceptions Message-ID: <200805051610.53576.bekesa@sch.bme.hu> Hi, I've just found that dialyzer is not type checking exceptions. What I mean: ----------------------------------------- f()-> ok. case catch f() of ok -> ok; _ -> nok end, ----------------------------------------- Here dializer approximates the type of catch f() to 'any' type, and therefore not complaining about the second, unreachable case. With try-catch, things are better: ----------------------------------------- try f() of ok -> ok; _ -> %% detected as unreachable nok catch _:_ -> %% not detected as unrechable something end, ----------------------------------------- So it approximates caught or try-caugth exception values with 'any' type even if no exception can occur. My questions are: Will dialyzer type-check exceptions in the future, or this would imply a total rewrite of it and therefore not planned? If yes, when? Georgy From raimo+erlang-questions@REDACTED Mon May 5 16:25:47 2008 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Mon, 5 May 2008 16:25:47 +0200 Subject: [erlang-questions] [Suspected Spam] Re: Sometime it's the simple stuff... In-Reply-To: References: Message-ID: <20080505142547.GC12042@erix.ericsson.se> Try this undocumented feature: inet_parse:ntoa({127,0,0,1}) -> "127.0.0.1" inet_parse:ntoa({0,0,0,0,0,65535,32512,1}). "::FFFF:127.0.0.1" On Mon, May 05, 2008 at 12:40:22AM -0700, Nick Gerakines wrote: > This is what I came up with. Keep in mind its late. > > %% @spec url_from_ip(IpTuple) -> string(). > %% where > %% IpTuple = {integer(), integer(), integer(), integer()} > %% @doc Stringify a url out of an ip. > %% Use: url_from_ip({10, 0, 100, 1}). > url_from_ip(IpTuple) -> > "http://" ++ > lists:foldl(fun(A, "") -> A; (A, Acc) -> Acc ++ "." ++ A end, "", > [integer_to_list(X)|| X <- tuple_to_list(IpTuple)]) > ++ "/". > > *duck* > > # Nick Gerakines > > On Thu, May 1, 2008 at 6:56 AM, Dave Bryson wrote: > > I need to take an IP address in the form of "[{10,0,1,100}]" and > > create an http URL like this: "http://10.0.1.100/". I've tried using > > io_lib:format and successfully generated a list. But, the inets http > > client doesn't like the format and complains of a malformed URL. > > > > What's the easiest way to convert an IP to the String version? > > > > Thanks! > > Dave > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From tobias.lindahl@REDACTED Mon May 5 16:49:47 2008 From: tobias.lindahl@REDACTED (Tobias Lindahl) Date: Mon, 05 May 2008 16:49:47 +0200 Subject: [erlang-questions] dialyzer <-> exceptions In-Reply-To: <200805051610.53576.bekesa@sch.bme.hu> References: <200805051610.53576.bekesa@sch.bme.hu> Message-ID: <481F1E8B.2040004@it.uu.se> Hi Georgy, Andras Georgy Bekes wrote: > Hi, > > I've just found that dialyzer is not type checking exceptions. > > What I mean: > ----------------------------------------- > f()-> > ok. > > case catch f() of > ok -> > ok; > _ -> > nok > end, > ----------------------------------------- > Here dializer approximates the type of catch f() to 'any' type, and > therefore not complaining about the second, unreachable case. > > With try-catch, things are better: > ----------------------------------------- > try f() of > ok -> > ok; > _ -> %% detected as unreachable > nok > catch > _:_ -> %% not detected as unrechable > something > end, > ----------------------------------------- > > So it approximates caught or try-caugth exception values with 'any' type > even if no exception can occur. First, I would like to point out that the information Dialyzer can find is much better in the try...catch than in the simple catch. I strongly encourage the use of the former construct. We recently changed all code in the HiPE compiler to use try, and it is not that much work (although I wasn't the one doing it ;-) ) > My questions are: Will dialyzer type-check exceptions in the future, > or this would imply a total rewrite of it and therefore not planned? > If yes, when? In principle, Dialyzer could find all the exceptions that can occur, but since there would be very many case clauses etc, it is more reasonable to limit the tracking to (for example) thrown values. This is something we have discussed, and while we are not currently working on it, it will probably happen in the future. I cannot give you any time estimate on this, but in the meantime it will probably help both Dialyzer and your code to migrate from using catch to try...catch anyway. Tobias > > Georgy > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From kostis@REDACTED Mon May 5 16:59:41 2008 From: kostis@REDACTED (Kostis Sagonas) Date: Mon, 05 May 2008 17:59:41 +0300 Subject: [erlang-questions] dialyzer <-> exceptions In-Reply-To: <200805051610.53576.bekesa@sch.bme.hu> References: <200805051610.53576.bekesa@sch.bme.hu> Message-ID: <481F20DD.2000407@cs.ntua.gr> Andras Georgy Bekes wrote: > > I've just found that dialyzer is not type checking exceptions. > > What I mean: > ----------------------------------------- > f() -> > ok. > > case catch f() of > ok -> > ok; > _ -> > nok > end, > ----------------------------------------- > Here dialyzer approximates the type of catch f() to 'any' type, and > therefore not complaining about the second, unreachable case. > > With try-catch, things are better: > ----------------------------------------- > try f() of > ok -> > ok; > _ -> %% detected as unreachable > nok > catch > _:_ -> %% not detected as unrechable > something > end, > ----------------------------------------- > > So it approximates caught or try-caught exception values with 'any' type > even if no exception can occur. This thread is very much related to the thread we had last week about catch vs. try-catch, the latter being a much much nicer construct IMO. Dialyzer currently bases its analysis on something called success typings, which approximates successful *returns* from functions, not exceptions that a function might possibly throw. There is a rather fundamental reason for this: in Erlang in principle any function can throw some exception. In the case of catch f() to detect that the second branch is unreachable dialyzer would have to find that f() cannot possibly throw some exception. (This is obviously easy in this case, but complicated in general.) In the case of try-catch, its clear that _ refers to return values only, not exceptions. One more (very good, IMO) reason to prefer try-catch. > My questions are: Will dialyzer type-check exceptions in the future, or > this would imply a total rewrite of it and therefore not planned? If > yes, when? The answer to your question is: tracking exceptions requires a significantly different kind of analysis than the one currently present in dialyzer to infer the exception information, but it does not require a total rewrite of the pass which generates the warnings. It's not something that we have currently planned for, but it is something we have in our minds. Whether it will actually happen or not depends on mundane issues such as funding either from a research foundation or from some other interested source. Kostis From vsarpe@REDACTED Mon May 5 17:14:42 2008 From: vsarpe@REDACTED (Vlad12) Date: Mon, 5 May 2008 08:14:42 -0700 (PDT) Subject: [erlang-questions] Erlang trace files Message-ID: <17027765.post@talk.nabble.com> Greetings Erlang community, I am an undergraduate student currently working on developing software to visually represent interactions in concurrent programing. I have discovered that Erlang is a language that can be represented by the Actor Model. I am looking to first investigate the patterns of communication between processes. For this I want to look at large-scale concurrency-related software developed in Erlang. I am asking anyone with experience in Erlang that have developed programs supporting concurrency, and are willing, to provide a simple trace file of the programs runtime (or part of the runtime) as well as a short description of the program (post here or email me). Furthermore, anyone that are aware of large-scale concurrency-based software or any useful tools for tracing Erlang programs to post here or email me. You can reach me at: vsarpe@REDACTED Your help is greatly appreciated. Sincerely, Vlad S., University of Calgary (Bioinformatics) -- View this message in context: http://www.nabble.com/Erlang-trace-files-tp17027765p17027765.html Sent from the Erlang Questions mailing list archive at Nabble.com. From jachym.holecek@REDACTED Mon May 5 17:23:33 2008 From: jachym.holecek@REDACTED (Jachym Holecek) Date: Mon, 05 May 2008 17:23:33 +0200 Subject: [erlang-questions] GC trace data Message-ID: Hello, I'm using 'erlang:trace(Pid, true, [garbage_collection])' to benchmark process memory usage and I'm not sure about the exact meaning of data delivered with gc_start/gc_end events. Here's list of keys and how I understand them: heap_block_size - Total heap size. heap_size - Size of used part of the heap. mbuf_size - Size of messages queued in process mailbox. old_heap_block_size - ?? old_heap_size - ?? recent_size - ?? stack_size - Current stack size. Does it sound sensible? Can someone help me fill in the blanks? What I really care about is: 1. stack size (got that), 2. mailbox size (got that), 3. size of used part of heap (could be 'heap_size' or 'heap_size + old_heap_size' or something completely different?). I'm running R11B in case it makes any difference. Thanks in advance, -- Jachym From bob@REDACTED Mon May 5 18:19:02 2008 From: bob@REDACTED (Bob Ippolito) Date: Mon, 5 May 2008 09:19:02 -0700 Subject: [erlang-questions] io:format printing integers prefixed with zero(0) In-Reply-To: <481ED097.9000602@lundata.se> References: <481BEF55.1050206@ghostgun.com> <20080503052206.GA6784@delora.autosys.us> <481ED097.9000602@lundata.se> Message-ID: <6a36e7290805050919y182e2570u49e45f695c23096c@mail.gmail.com> I just happened to have written a string formatting library yesterday, modeled after Python 2.6's PEP 3101 Advanced String Formatting. it's in the mochiweb repository here: http://mochiweb.googlecode.com/svn/trunk/src/mochifmt.erl Basically: > lists:flatten(mochifmt:format("{0:03}", {3})). "003" Or since it's just one number: > lists:flatten(mochifmt:format_field(3, "03")). "003" If you need a list rather than an iolist you can use: > mochifmt:f("{0:03}", {3}). "003" Similarly, bformat is the same as format but it gives you a binary (just using iolist_to_binary). On Mon, May 5, 2008 at 2:17 AM, Peter Lund wrote: > or: > > 1> string:right(integer_to_list(3),3,$0). > "003" > 2> string:right(integer_to_list(50),3,$0). > "050" > 3> string:right(integer_to_list(205),3,$0). > "205" > 4> string:right(integer_to_list(33205),3,$0). > "205" > > does almost the same... > > Michael McDaniel skrev: > > > > On Sat, May 03, 2008 at 02:51:33PM +1000, jm wrote: > > > >> Given an integer is there a format which will prefix it with zeros to a > >> fixed width? eg, > >> > >> 3 => 003 > >> 50 => 050 > >> 205 => 205 > >> > >> the equivelant of C's printf("%3.3d", i). > >> > >> > >> Jeff. > >> _______________________________________________ > >> > > > > > > > > (del@REDACTED)40> io:fwrite("~3.3.0w ", [1]). > > 001 ok > > (del@REDACTED)41> io:fwrite("~3.3.0w ", [10]). > > 010 ok > > (del@REDACTED)42> io:fwrite("~3.3.0w ", [100]). > > 100 ok > > (del@REDACTED)43> > > > > > > see io docs; file:///usr/local/lib/erlang/lib/stdlib-1.15/doc/html/io.html > > on my system > > > > > > ~Michael > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From jilani@REDACTED Mon May 5 19:27:43 2008 From: jilani@REDACTED (Jilani Khaldi) Date: Mon, 05 May 2008 19:27:43 +0200 Subject: [erlang-questions] io:format printing integers prefixed with zero(0) In-Reply-To: <6a36e7290805050919y182e2570u49e45f695c23096c@mail.gmail.com> References: <481BEF55.1050206@ghostgun.com> <20080503052206.GA6784@delora.autosys.us> <481ED097.9000602@lundata.se> <6a36e7290805050919y182e2570u49e45f695c23096c@mail.gmail.com> Message-ID: <481F438F.3010602@cheapnet.it> Bob Ippolito wrote: > I just happened to have written a string formatting library yesterday, > modeled after Python 2.6's PEP 3101 Advanced String Formatting. it's > in the mochiweb repository here: > http://mochiweb.googlecode.com/svn/trunk/src/mochifmt.erl 28> mochifmt:test(). ** exception error: undefined function mochinum:digits/1 in function mochifmt:format_field/3 in call from mochifmt:format2/4 in call from mochifmt:bformat/2 in call from mochifmt:test_format/0 in call from mochifmt:test/0 //JK From bob@REDACTED Mon May 5 19:41:00 2008 From: bob@REDACTED (Bob Ippolito) Date: Mon, 5 May 2008 10:41:00 -0700 Subject: [erlang-questions] io:format printing integers prefixed with zero(0) In-Reply-To: <481F438F.3010602@cheapnet.it> References: <481BEF55.1050206@ghostgun.com> <20080503052206.GA6784@delora.autosys.us> <481ED097.9000602@lundata.se> <6a36e7290805050919y182e2570u49e45f695c23096c@mail.gmail.com> <481F438F.3010602@cheapnet.it> Message-ID: <6a36e7290805051041r3ca2e748w9e27a1ce999a355c@mail.gmail.com> Yes, it requires other parts of mochiweb to run the full test suite. On Mon, May 5, 2008 at 10:27 AM, Jilani Khaldi wrote: > Bob Ippolito wrote: > > I just happened to have written a string formatting library yesterday, > > modeled after Python 2.6's PEP 3101 Advanced String Formatting. it's > > in the mochiweb repository here: > > http://mochiweb.googlecode.com/svn/trunk/src/mochifmt.erl > 28> mochifmt:test(). > ** exception error: undefined function mochinum:digits/1 > in function mochifmt:format_field/3 > in call from mochifmt:format2/4 > in call from mochifmt:bformat/2 > in call from mochifmt:test_format/0 > in call from mochifmt:test/0 > > //JK > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From jilani@REDACTED Mon May 5 19:45:48 2008 From: jilani@REDACTED (Jilani Khaldi) Date: Mon, 05 May 2008 19:45:48 +0200 Subject: [erlang-questions] io:format printing integers prefixed with zero(0) In-Reply-To: <481F438F.3010602@cheapnet.it> References: <481BEF55.1050206@ghostgun.com> <20080503052206.GA6784@delora.autosys.us> <481ED097.9000602@lundata.se> <6a36e7290805050919y182e2570u49e45f695c23096c@mail.gmail.com> <481F438F.3010602@cheapnet.it> Message-ID: <481F47CC.5020608@cheapnet.it> Jilani Khaldi wrote: > Bob Ippolito wrote: >> I just happened to have written a string formatting library yesterday, >> modeled after Python 2.6's PEP 3101 Advanced String Formatting. it's >> in the mochiweb repository here: >> http://mochiweb.googlecode.com/svn/trunk/src/mochifmt.erl > 28> mochifmt:test(). > ** exception error: undefined function mochinum:digits/1 As usual. Found 2 secs after pressing "Send"! //JK From bob@REDACTED Mon May 5 19:51:06 2008 From: bob@REDACTED (Bob Ippolito) Date: Mon, 5 May 2008 10:51:06 -0700 Subject: [erlang-questions] io:format printing integers prefixed with zero(0) In-Reply-To: <6a36e7290805051041r3ca2e748w9e27a1ce999a355c@mail.gmail.com> References: <481BEF55.1050206@ghostgun.com> <20080503052206.GA6784@delora.autosys.us> <481ED097.9000602@lundata.se> <6a36e7290805050919y182e2570u49e45f695c23096c@mail.gmail.com> <481F438F.3010602@cheapnet.it> <6a36e7290805051041r3ca2e748w9e27a1ce999a355c@mail.gmail.com> Message-ID: <6a36e7290805051051u2289c540i347dc6d6a73c232@mail.gmail.com> The version I just checked in wraps the mochinum calls with try and calls the stdlib equivalents, it should run independently now. On Mon, May 5, 2008 at 10:41 AM, Bob Ippolito wrote: > Yes, it requires other parts of mochiweb to run the full test suite. > > > > On Mon, May 5, 2008 at 10:27 AM, Jilani Khaldi wrote: > > Bob Ippolito wrote: > > > I just happened to have written a string formatting library yesterday, > > > modeled after Python 2.6's PEP 3101 Advanced String Formatting. it's > > > in the mochiweb repository here: > > > http://mochiweb.googlecode.com/svn/trunk/src/mochifmt.erl > > 28> mochifmt:test(). > > ** exception error: undefined function mochinum:digits/1 > > in function mochifmt:format_field/3 > > in call from mochifmt:format2/4 > > in call from mochifmt:bformat/2 > > in call from mochifmt:test_format/0 > > in call from mochifmt:test/0 > > > > //JK > > > > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > From greg.burri@REDACTED Mon May 5 20:07:20 2008 From: greg.burri@REDACTED (Greg Burri) Date: Mon, 5 May 2008 20:07:20 +0200 Subject: [erlang-questions] How do I compute daytime difference properly? In-Reply-To: References: <337538cb0805031100j257b64e6ob0a5109acf549c54@mail.gmail.com> Message-ID: <60ed8a460805051107i2e6693cexa2402b8c7ab1d648@mail.gmail.com> Hi, Maybe like this : delta_date_ms(D1, D2) -> 1000000000 * abs(element(1, D1) - element(1, D2)) + 1000 * abs(element(2, D1) - element(2, D2)) + trunc(abs(element(3, D1) - element(3, D2)) / 1000). /Greg On Sat, May 3, 2008 at 9:10 PM, Igor Ribeiro Sucupira wrote: > I think there's no easier way of doing that. > > 2008/5/3 Kirill Zaborski : > > > > > > Reading calendar module documentation I see the note: > > "For computing differences between epochs in time, use the functions > > counting gregorian days or seconds. If epochs are given as local time, they > > must be converted to universal time, in order to get the correct value of > > the elapsed time between epochs. Use of the function time_difference/2 is > > discouraged." > > But it's not quite clear to me... > > E.g. I have 2 values LocalTime1 and LocalTime2 which are somewhat like > > tuples erlang:localtime/0 and need to compute time difference e.g. in > > seconds. So should I then convert this values to UTC and then use > > calendar:datetime_to_gregorian_seconds/1 and then do the subtraction? > > Or maybe there is some easier way? > > > > Best regards, > > Kirill. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From jarrod@REDACTED Mon May 5 20:22:13 2008 From: jarrod@REDACTED (Jarrod Roberson) Date: Mon, 5 May 2008 14:22:13 -0400 Subject: [erlang-questions] How to start an erlang applications from the command line non-interactively? Message-ID: I have the Pragmatic Programmers book, and have searched Google and can't figure out how to start my program from the command line in _non_ interactive mode. I am using windows at the moment as well, but I can translate from *nix instructions. I have tried the -s and -run options to erl but they both leave me in an interactive erlang shell. I want the interpreter to start up and run my app and detach from the shell "stand alone". -------------- next part -------------- An HTML attachment was scrubbed... URL: From qrilka@REDACTED Mon May 5 20:34:21 2008 From: qrilka@REDACTED (Kirill Zaborski) Date: Mon, 5 May 2008 22:34:21 +0400 Subject: [erlang-questions] How do I compute daytime difference properly? In-Reply-To: <60ed8a460805051107i2e6693cexa2402b8c7ab1d648@mail.gmail.com> References: <337538cb0805031100j257b64e6ob0a5109acf549c54@mail.gmail.com> <60ed8a460805051107i2e6693cexa2402b8c7ab1d648@mail.gmail.com> Message-ID: <337538cb0805051134k6c84bd30u604eb79de322ba10@mail.gmail.com> DateTime tuple (from erlang:localtime/0) has format {{Year, Month, Day},{Hour, Minute,Second}}. Not sure what exact meaning has you function (even if we neglect time part), e.g. what if I subtract 12:00:00 30th of April 2008 from 12:00:00 1st of May 2008? It looks like we'll get 1000.029 but what are the units? I'd like to get 1 day or 86400 seconds. On Mon, May 5, 2008 at 10:07 PM, Greg Burri wrote: > Hi, > Maybe like this : > > delta_date_ms(D1, D2) -> > 1000000000 * abs(element(1, D1) - element(1, D2)) + 1000 * > abs(element(2, D1) - element(2, D2)) + trunc(abs(element(3, D1) - > element(3, D2)) / 1000). > > > /Greg > > On Sat, May 3, 2008 at 9:10 PM, Igor Ribeiro Sucupira wrote: > > I think there's no easier way of doing that. > > > > 2008/5/3 Kirill Zaborski : > > > > > > > > > > Reading calendar module documentation I see the note: > > > "For computing differences between epochs in time, use the functions > > > counting gregorian days or seconds. If epochs are given as local time, they > > > must be converted to universal time, in order to get the correct value of > > > the elapsed time between epochs. Use of the function time_difference/2 is > > > discouraged." > > > But it's not quite clear to me... > > > E.g. I have 2 values LocalTime1 and LocalTime2 which are somewhat like > > > tuples erlang:localtime/0 and need to compute time difference e.g. in > > > seconds. So should I then convert this values to UTC and then use > > > calendar:datetime_to_gregorian_seconds/1 and then do the subtraction? > > > Or maybe there is some easier way? > > > > > > Best regards, > > > Kirill. > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From nick@REDACTED Mon May 5 20:42:00 2008 From: nick@REDACTED (Nick Gerakines) Date: Mon, 5 May 2008 11:42:00 -0700 Subject: [erlang-questions] How to start an erlang applications from the command line non-interactively? In-Reply-To: References: Message-ID: There are a few ways to do what you want. Both of them involve using the -detached erl arg. If you are using an application you'll want to create a boot script using the .app and .rel file. I consider this crucial for deploying applications. erl -name myapp@`hostname` -noshell -detached -setcookie myappcookie -boot myapp If you've got a simple MFA that you want to run in the background you can do it with -s. Consider the module foo that exports the method bar: erl -name fooapp@`hostname` -noshell -detached +W w +A 1 +Ktrue -setcookie foocookie -s foo bar Just keep in mind that to connect to detached erlang nodes, you'll need to be sure your cookies match. Otherwise you should be good to go. I tend to do something like: $ erl -name fooapp_ctl@`hostname` -setcookie foocookie Eshell V5.6.1 (abort with ^G) (fooapp_ctl@REDACTED)1> ^G User switch command --> r'fooapp@REDACTED' --> c Eshell V5.6.1 (abort with ^G) (fooapp@REDACTED)1> # Nick Gerakines 2008/5/5 Jarrod Roberson : > I have the Pragmatic Programmers book, and have searched Google and can't > figure out how to start my program from the command line in _non_ > interactive mode. > I am using windows at the moment as well, but I can translate from *nix > instructions. > > I have tried the -s and -run options to erl but they both leave me in an > interactive erlang shell. > > I want the interpreter to start up and run my app and detach from the shell > "stand alone". > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From gleber.p@REDACTED Mon May 5 20:44:24 2008 From: gleber.p@REDACTED (Gleb Peregud) Date: Mon, 5 May 2008 20:44:24 +0200 Subject: [erlang-questions] How to start an erlang applications from the command line non-interactively? In-Reply-To: References: Message-ID: <14f0e3620805051144vdae95eawa539f0d8a6038f4c@mail.gmail.com> On 5/5/08, Jarrod Roberson wrote: > I have the Pragmatic Programmers book, and have searched Google and can't > figure out how to start my program from the command line in _non_ > interactive mode. > I am using windows at the moment as well, but I can translate from *nix > instructions. > > I have tried the -s and -run options to erl but they both leave me in an > interactive erlang shell. > > I want the interpreter to start up and run my app and detach from the shell > "stand alone". > Let's say that your beam files are in ./ebin/ and there is module "gui" with function "run". To run it in non-iteractive mode use this: erl -noshell -pa ebin/ -s gui run -s erlang halt Additionally take a look at "man run_erl", which handles detaching of erlang app (and other daemon-related stuff) -- Gleb Peregud http://gleber.pl/ Every minute is to be grasped. Time waits for nobody. -- Inscription on a Zen Gong From anders.nygren@REDACTED Mon May 5 20:45:01 2008 From: anders.nygren@REDACTED (Anders Nygren) Date: Mon, 5 May 2008 13:45:01 -0500 Subject: [erlang-questions] How to start an erlang applications from the command line non-interactively? In-Reply-To: References: Message-ID: 2008/5/5 Jarrod Roberson : > I have the Pragmatic Programmers book, and have searched Google and can't > figure out how to start my program from the command line in _non_ > interactive mode. > I am using windows at the moment as well, but I can translate from *nix > instructions. > > I have tried the -s and -run options to erl but they both leave me in an > interactive erlang shell. > > I want the interpreter to start up and run my app and detach from the shell > "stand alone". > Try with -detached or -noshell Also for running as a service on windows see erlsrv /Anders > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From igorrs@REDACTED Mon May 5 20:56:33 2008 From: igorrs@REDACTED (Igor Ribeiro Sucupira) Date: Mon, 5 May 2008 15:56:33 -0300 Subject: [erlang-questions] How do I compute daytime difference properly? In-Reply-To: <60ed8a460805051107i2e6693cexa2402b8c7ab1d648@mail.gmail.com> References: <337538cb0805031100j257b64e6ob0a5109acf549c54@mail.gmail.com> <60ed8a460805051107i2e6693cexa2402b8c7ab1d648@mail.gmail.com> Message-ID: I suppose the problems with time_difference are related to daylight savings and such. If I'm right, there's no point in reimplementing the algorithm if you don't address those problems. Igor. On Mon, May 5, 2008 at 3:07 PM, Greg Burri wrote: > Hi, > Maybe like this : > > delta_date_ms(D1, D2) -> > 1000000000 * abs(element(1, D1) - element(1, D2)) + 1000 * > abs(element(2, D1) - element(2, D2)) + trunc(abs(element(3, D1) - > element(3, D2)) / 1000). > > > /Greg > > > > On Sat, May 3, 2008 at 9:10 PM, Igor Ribeiro Sucupira wrote: > > I think there's no easier way of doing that. > > > > 2008/5/3 Kirill Zaborski : > > > > > > > > > > Reading calendar module documentation I see the note: > > > "For computing differences between epochs in time, use the functions > > > counting gregorian days or seconds. If epochs are given as local time, they > > > must be converted to universal time, in order to get the correct value of > > > the elapsed time between epochs. Use of the function time_difference/2 is > > > discouraged." > > > But it's not quite clear to me... > > > E.g. I have 2 values LocalTime1 and LocalTime2 which are somewhat like > > > tuples erlang:localtime/0 and need to compute time difference e.g. in > > > seconds. So should I then convert this values to UTC and then use > > > calendar:datetime_to_gregorian_seconds/1 and then do the subtraction? > > > Or maybe there is some easier way? > > > > > > Best regards, > > > Kirill. > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > From gleber.p@REDACTED Mon May 5 21:38:44 2008 From: gleber.p@REDACTED (Gleb Peregud) Date: Mon, 5 May 2008 21:38:44 +0200 Subject: [erlang-questions] How to start an erlang applications from the command line non-interactively? In-Reply-To: <481F5FD9.7090200@san.rr.com> References: <14f0e3620805051144vdae95eawa539f0d8a6038f4c@mail.gmail.com> <481F5FD9.7090200@san.rr.com> Message-ID: <14f0e3620805051238x1f7aa5d6n96948e360f9cf61c@mail.gmail.com> On 5/5/08, Darren New wrote: > Gleb Peregud wrote: > > erl -noshell -pa ebin/ -s gui run -s erlang halt > > Shouldn't this be > erl -noshell -pa ebin/ -s gui run -s init stop > > Otherwise, don't you risk aborting I/O threads before the buffers are > flushed and such? I thought "halt" was a rather brutal exit? > > -- > Darren New / San Diego, CA, USA (PST) > "That's pretty. Where's that?" > "It's the Age of Channelwood." > "We should go there on vacation some time." > You are right. I've copy-pasted code from simple project, where these details were not important :) I'll CC to erlang-questions for others to see this -- Gleb Peregud http://gleber.pl/ Every minute is to be grasped. Time waits for nobody. -- Inscription on a Zen Gong From jarrod@REDACTED Mon May 5 21:59:16 2008 From: jarrod@REDACTED (Jarrod Roberson) Date: Mon, 5 May 2008 15:59:16 -0400 Subject: [erlang-questions] How to start an erlang applications from the command line non-interactively? In-Reply-To: <481F538E.7030800@gmail.com> References: <481F538E.7030800@gmail.com> Message-ID: On Mon, May 5, 2008 at 2:35 PM, Jacob Torrey wrote: > Jarrod, > Use the command flag -noshell or -detatched with -run or -s to have it > not drop you back in interactive mode after it's done. > > Jacob -detached doesn't seem to do anything on windows, it just exits and my http daemon doesn't run. -noshell seems to work, what is the difference between the two options? C:\src>erl -detached -s httpd start C:\src> -------------- next part -------------- An HTML attachment was scrubbed... URL: From jarrod@REDACTED Mon May 5 22:05:01 2008 From: jarrod@REDACTED (Jarrod Roberson) Date: Mon, 5 May 2008 16:05:01 -0400 Subject: [erlang-questions] How to start an erlang applications from the command line non-interactively? In-Reply-To: References: Message-ID: On Mon, May 5, 2008 at 2:42 PM, Nick Gerakines wrote: > There are a few ways to do what you want. Both of them involve using > the -detached erl arg. > > If you are using an application you'll want to create a boot script > using the .app and .rel file. I consider this crucial for deploying > applications. > > erl -name myapp@`hostname` -noshell -detached -setcookie myappcookie -boot > myapp > > If you've got a simple MFA that you want to run in the background you > can do it with -s. > > Consider the module foo that exports the method bar: > > erl -name fooapp@`hostname` -noshell -detached +W w +A 1 +Ktrue > -setcookie foocookie -s foo bar > > Just keep in mind that to connect to detached erlang nodes, you'll > need to be sure your cookies match. Otherwise you should be good to > go. > > I tend to do something like: > > $ erl -name fooapp_ctl@`hostname` -setcookie foocookie > > Eshell V5.6.1 (abort with ^G) > (fooapp_ctl@REDACTED)1> ^G > User switch command > --> r'fooapp@REDACTED' > --> c > Eshell V5.6.1 (abort with ^G) > (fooapp@REDACTED)1> > > # Nick Gerakines thanks for the response, I got it working with -noshell, I am looking for more info on the .app option. Can someone give me an example on passing arguments using the -s option? The docs are as clear on the actual syntax. I have a function start(Port, Htdocs) that I want to call with 8888, "C:/htdocs" and I can't figure out what the appropriate syntax should be. -------------- next part -------------- An HTML attachment was scrubbed... URL: From cyberlync@REDACTED Mon May 5 22:52:38 2008 From: cyberlync@REDACTED (Eric Merritt) Date: Mon, 5 May 2008 20:52:38 +0000 Subject: [erlang-questions] Dialyzer programmatic interface and output_plt Message-ID: Guys, Thanks for getting the programmatic interface to dialyzer back into a working state! That helps a lot. However, it seems that dialyzer no longer understands the output_plt option. I don't believe it was ever documented but it used to work, now dialyzer seems to ignore it. Is there some other way to get dialyzer to create a plt file using the erlang interface? On a side note. The documentation for dialyzer:run/1 is a bit misleading. It seems to indicate that you should pass the Msg part of the warning tuple to dialyzer:format_warning/1. In actuality you should pass the entire warning tuple. It also documents errors as being strings but I don't believe that they are strings. Unless I am missing something they follow the same semantics as warnings. Thanks, Eric From erlang-questions_efine@REDACTED Mon May 5 23:08:46 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Mon, 5 May 2008 17:08:46 -0400 Subject: [erlang-questions] Problem with pattern matching in large binaries In-Reply-To: <6c2563b20805051356w3d3309dcxf866d47f56cefa90@mail.gmail.com> References: <6c2563b20805051356w3d3309dcxf866d47f56cefa90@mail.gmail.com> Message-ID: <6c2563b20805051408r2c2bb169iaec242834bb8a843@mail.gmail.com> I am really baffled with this, and it smells like a bug to me, but I am quite new to Erlang and don't want to make any assumptions, so I am throwing this open to the community. I am using Erlang R12B-2, compiled on Ubuntu Linux Feisty (64-bit, x86_64), Core 2 Quad E6600, 8 GB RAM. I have a text file that is 1,037,563,663 bytes in length. In the shell, I read it all into memory as follows: >{ok,B} = file:read_file("/tmp/data"). ... > byte_size(B). 1037563663 So far so good. Then I decide I want to look at the last 100 bytes of the binary. >Offset = byte_size(B) - 100. 1037563563 Makes sense. Now to skip the first Offset bytes: > <<_Skip:Offset/binary,Last100/binary>> = B. > byte_size(Last100). 100 > byte_size(_Skip). 500692651 WTF??? Checking Last100 showed that it was indeed the data from offset 500693651, not the last 100 bytes. Where did the other 500MB-odd go? Looking on Google revealed that if there is any binary matching limit, it is 2 ^ 27 bytes, which this is smaller than. And this limit is supposedly on 32 bits, and I am using 64 bits. Then I tried this: >{B1,B2} = split_binary(B, byte_size(B) div 2). > byte_size(B1). 518781831 > byte_size(B2). 518781832 ><<_Yipes2:518781700/binary,Last132/binary>> = B2. Checking Last132 showed that it was actually the last 132 bytes of the file. So it's not file:read_file misbehaving - it did read the whole file into B. It seems to be the size component of a pattern match that has some limitation. I have looked in the Advanced section (9) of the Erlang Efficiency guide, and the limit of a binary match on a 64 bit system is supposed to be 2305843009213693951 bytes. Is this an undocumented bug? From jarrod@REDACTED Mon May 5 23:54:53 2008 From: jarrod@REDACTED (Jarrod Roberson) Date: Mon, 5 May 2008 17:54:53 -0400 Subject: [erlang-questions] How to start an erlang applications from the command line non-interactively? In-Reply-To: <6c2563b20805051436we7911e1xd7fc22bd343ecc16@mail.gmail.com> References: <6c2563b20805051436we7911e1xd7fc22bd343ecc16@mail.gmail.com> Message-ID: On Mon, May 5, 2008 at 5:36 PM, Edwin Fine wrote: > > I have a function start(Port, Htdocs) that I want to call with 8888, > > "C:/htdocs" and I can't figure out what the appropriate syntax should > be. > This can be nasty to get right. It depends on how the command line > interprets characters like single quote and double quote. > It also depends on whether you use -s or -run. > > -s interprets all function arguments as atoms, so your program will > get all the values as atoms. You will usually need to write a special > MFA to convert the atoms to the actual types of the parameters > desired. Note that all arguments get passed in a single list when > called like this (see start_cmd_line/3). > > -run interprets all function arguments as strings, so your program > will get all the values as string. You will often have to write a > special MFA to convert the strings to the actual types of the > parameters desired. > > For example: > > -module(foo). > -export([start_cmd_line/1, start/3]). > > start_cmd_line([NameAtom, IntValue, StrValue]) when is_atom(NameAtom), > is_atom(IntValue), is_atom(StrValue) -> > Name = NameAtom, % Not really necessary because NameAtom is already an > atom > Int = list_to_integer(atom_to_list(IntValue)), % Could throw an > exception > Str = atom_to_list(StrValue), > start(Name, Int, Str). > > start(Name, Int, Str) -> > io:format("Name: ~p, Int: ~p, Str: ~p~n", [Name, Int, Str]), > % Etc > ok. > > If you started the above by > > erl -s foo Jarrod 12345 "This is a string" > > you would get an output something like this: > Erlang (BEAM) emulator version 5.6.2 [source] [64-bit] [smp:4] > [async-threads:0] [hipe] [kernel-poll:false] > > Name: 'Jarrod', Int: 12345, Str: "This is a string" > Eshell V5.6.2 (abort with ^G) > 1> > > Hope this helps. > thanks that clears things up greatly. -------------- next part -------------- An HTML attachment was scrubbed... URL: From Raymond.Xiong@REDACTED Tue May 6 05:48:31 2008 From: Raymond.Xiong@REDACTED (Raymond Xiong) Date: Tue, 06 May 2008 11:48:31 +0800 Subject: [erlang-questions] : build 64bit Erlang on Solairs In-Reply-To: <20080505131622.GA12042@erix.ericsson.se> References: <20080501122408.GA3630@Sun.Com> <18457.53560.59691.24368@harpo.it.uu.se> <20080501153708.GA3849@Sun.Com> <20080505131622.GA12042@erix.ericsson.se> Message-ID: <20080506034830.GA7789@Sun.Com> On 05/05/08, Raimo Niskanen wrote: > > > > If so, however, isn't it better to add CFLAGS in the follwing > > line in erts/emulator/Makefile.in? > > > > $(BINDIR)/$(EMULATOR_EXECUTABLE): $(INIT_OBJS) $(OBJS) > > $(PURIFY) $(LD) -o $(BINDIR)/$(EMULATOR_EXECUTABLE) \ > > $(HIPEBEAMLDFLAGS) $(LDFLAGS) $(DEXPORT) $(INIT_OBJS) $(OBJS) $(LIBS) > > > > It sounds weird to add CFLAGS to the LD command line. > I agree it's better to use "LDFLAGS=-m64". > > > > > > env CFLAGS='-m64 -O2' LDFLAGS=-m64 ./configure ; make > > > > > > also works; I just did that to build R12B-2 on a Solaris 10 box. > > > > Yes, I believe it would work(I haven't try it on my SPARC box yet, > > because the machine is slow and it takes more than half an hour > > to finish). > > > > However, I doubt if you can enable ssl support. I expect the > > following command would fail because mixing of 32-bit objects > > and 64-bit objects is not permitted: > > > > env CFLAGS='-m64 -O2' LDFLAGS=-m64 ./configure --with-ssl=/usr/sfw \ > > --enable-dynamic-ssl-lib ; make > > > > 64bit ssl lib is under /usr/sfw/lib/64, do you have any suggestion > > on how to let Erlang use 64bit ssl lib under that subdir(but header > > files are still under /usr/sfw/include of course)? > > > > In our nightly builds we have a directory early in the path > that contains two scripts, essentially: > gcc: > #! /bin/sh > exec /usr/local/pgm/.../bin/gcc -m64 ${1+"$@"} > ld: > #! /bin/sh > exec /usr/ccs/bin/ld -64 ${1+"$@"} > and we set: > PATH=/usr/local/bin:/usr/sfw/bin:... > LD_LIBRARY_PATH=/usr/local/lib:/usr/sfw/lib > LD_LIBRARY_PATH_64=/usr/sfw/lib/64 > > We have it building and running, but it is not a pretty solution. Thanks for the tip. It (and the command Mikael mentioned before) helped me to identify where these issues were. However, I cannot use it because a) it doesnt' work out of box b) the hack cannot be accepted in my build environment. I have two patches for erts/configure and lib/orber/c_src/Makefile.in to fix this issue. It works for me on Solaris, so it may be helpful to others. Here are the introductions: $ cd otp_src_R12B-1/ $ gpatch -p0 < orber_lib_makefile.patch $ gpatch -p0 < erts_configure.patch $ env CC=gcc CFLAGS='-m64 -O3' LDFLAGS="-m64" CPPFLAGS="-I /usr/include/gd2" CXX=g++ ./configure --prefix=/usr --with-ssl=/usr/sfw --enable-dynamic-ssl-lib $ gmake With above steps, I can build 64bit executables and shared objects. The only issue is erl_rx_driver.so: $ file ./lib/common_test/c_src/erl_rx_driver.so ./lib/common_test/c_src/erl_rx_driver.so: ELF 32-bit MSB dynamic lib SPARC Version 1, dynamically linked, not stripped The reason is its Makefile is hardcoded, rather than generated by configure script(there is no Makefile.in under this subdir). I decide to skip the issue for now. Another thing is that I think the use of LD_LIBRARY_PATH is due to a bug in lib/crypto/c_src/Makefile.in, which I reported a while back: http://www.erlang.org/pipermail/erlang-patches/2008-March/000241.html -- Regards, Raymond -------------- next part -------------- --- erts/configure.orig Sun May 4 23:17:15 2008 +++ erts/configure Mon May 5 00:34:55 2008 @@ -20722,6 +20722,12 @@ SSL_LIBDIR="$with_ssl/lib/VC" else SSL_LIBDIR="$with_ssl/lib" + if test "$GCC" = yes && echo $CFLAGS | grep "\-m64" >/dev/null; then + case $host_os in + solaris2*) + SSL_LIBDIR="$with_ssl/lib/64";; + esac + fi fi SSL_INCLUDE="-I$with_ssl/include" OPENSSL_CMD="$with_ssl/bin/openssl" -------------- next part -------------- --- lib/orber/c_src/Makefile.in.orig Sun May 4 22:36:42 2008 +++ lib/orber/c_src/Makefile.in Sun May 4 22:38:06 2008 @@ -102,7 +102,7 @@ -mkdir -p $(BINDIR) $(BINDIR)/obj_init_port: $(OBJ_FILES) - $(CC) -o $@ $(OBJ_FILES) $(LIBS) + $(CC) -o $@ $(ALL_CFLAGS) $(LDFLAGS) $(OBJ_FILES) $(LIBS) $(OBJDIR)/%.o: %.c $(CC) -c -o $@ $(ALL_CFLAGS) $< From bengt.kleberg@REDACTED Tue May 6 07:08:45 2008 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Tue, 06 May 2008 07:08:45 +0200 Subject: [erlang-questions] How to start an erlang applications from the command line non-interactively? In-Reply-To: References: <6c2563b20805051436we7911e1xd7fc22bd343ecc16@mail.gmail.com> Message-ID: <1210050525.14607.84.camel@seasc0642.dyn.rnd.as.sw.ericsson.se> Greetings, Are you sure about erl -s foo Jarrod 12345 "This is a string" resulting in Name: 'Jarrod', Int: 12345, Str: "This is a string" ? On my machine I have to use erl -s foo Jarrod 12345 'This is a string' Note the ' instead of ". When choosing between -s and -run, IMHO -run is better integrated with unix than -s (C does not have atoms). bengt On Mon, 2008-05-05 at 17:54 -0400, Jarrod Roberson wrote: > > > On Mon, May 5, 2008 at 5:36 PM, Edwin Fine > wrote: > > I have a function start(Port, Htdocs) that I want to call > with 8888, > > "C:/htdocs" and I can't figure out what the appropriate > syntax should be. > > This can be nasty to get right. It depends on how the command > line > interprets characters like single quote and double quote. > It also depends on whether you use -s or -run. > > -s interprets all function arguments as atoms, so your program > will > get all the values as atoms. You will usually need to write a > special > MFA to convert the atoms to the actual types of the parameters > desired. Note that all arguments get passed in a single list > when > called like this (see start_cmd_line/3). > > -run interprets all function arguments as strings, so your > program > will get all the values as string. You will often have to > write a > special MFA to convert the strings to the actual types of the > parameters desired. > > For example: > > -module(foo). > -export([start_cmd_line/1, start/3]). > > start_cmd_line([NameAtom, IntValue, StrValue]) when > is_atom(NameAtom), > is_atom(IntValue), is_atom(StrValue) -> > Name = NameAtom, % Not really necessary because NameAtom is > already an atom > Int = list_to_integer(atom_to_list(IntValue)), % Could > throw an exception > Str = atom_to_list(StrValue), > start(Name, Int, Str). > > start(Name, Int, Str) -> > io:format("Name: ~p, Int: ~p, Str: ~p~n", [Name, Int, > Str]), > % Etc > ok. > > If you started the above by > > erl -s foo Jarrod 12345 "This is a string" > > you would get an output something like this: > Erlang (BEAM) emulator version 5.6.2 [source] [64-bit] [smp:4] > [async-threads:0] [hipe] [kernel-poll:false] > > Name: 'Jarrod', Int: 12345, Str: "This is a string" > Eshell V5.6.2 (abort with ^G) > 1> > > Hope this helps. > > thanks that clears things up greatly. > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From jeffm@REDACTED Tue May 6 07:21:52 2008 From: jeffm@REDACTED (jm) Date: Tue, 06 May 2008 15:21:52 +1000 Subject: [erlang-questions] io:format printing integers prefixed with zero(0) In-Reply-To: <20080503052206.GA6784@delora.autosys.us> References: <481BEF55.1050206@ghostgun.com> <20080503052206.GA6784@delora.autosys.us> Message-ID: <481FEAF0.5020903@ghostgun.com> Michael McDaniel wrote: > > (del@REDACTED)40> io:fwrite("~3.3.0w ", [1]). > 001 ok > (del@REDACTED)41> io:fwrite("~3.3.0w ", [10]). > 010 ok > (del@REDACTED)42> io:fwrite("~3.3.0w ", [100]). > 100 ok > (del@REDACTED)43> > > > see io docs; file:///usr/local/lib/erlang/lib/stdlib-1.15/doc/html/io.html > on my system Thanks this is what I was after. Jeff. From catsunny@REDACTED Tue May 6 07:44:14 2008 From: catsunny@REDACTED (Catsunny) Date: Tue, 06 May 2008 13:44:14 +0800 Subject: [erlang-questions] mime_decode_string/1? Message-ID: Hi, I wonder if there is something wrong in the erlang documentation->STDLIB Reference->base64? The documentation says: base64 MODULE base64 MODULE SUMMARY Implements base 64 encode and decode, see RFC2045. DESCRIPTION Implements base 64 encode and decode, see RFC2045. EXPORTS encode(Data) -> Base64 encode_to_string(Data) -> Base64String Types: Data = string() | binary() Base64 = binary() Base64String = string() Encodes a plain ASCII string into base64. The result will be 33% larger than the data. decode(Base64) -> Data decode_to_string(Base64) -> DataString mime_decode(Base64) -> Data mime_decode_string(Base64) -> DataString Types: Base64 = string() | binary() Data = binary() DataString = string() Decodes a base64 encoded string to plain ASCII. The string should only consist of characters in the base64 set, see RFC4648. mime_decode/1 and mime_decode_to_string/1 strips away illegal characters, while decode/1 and decode_to_string/1 fails if an illegal charactrer is found. -------------------------------------------------------------------------------- stdlib 1.15.1 Copyright ? 1991-2008 Ericsson AB All the functions is ok except the last one, mime_decode_string/1: 11> base64:mime_decode_string(base64:encode_to_string("??")). ** exception error: undefined function base64:mime_decode_string/1. Is this an error in the library reference manual? Thank you! catsunny From kenneth.lundin@REDACTED Tue May 6 08:09:01 2008 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Tue, 6 May 2008 08:09:01 +0200 Subject: [erlang-questions] mime_decode_string/1? In-Reply-To: References: Message-ID: Hi, Yes it is an error in the documentation of the base64 module. There is no function called mime_decode_string/1, it should be mime_decode_to_string/1 instead. Thanks for pointing out this error, it will be fixed in the R12B-3 release. /Kenneth Erlang/OTP, Ericsson On 5/6/08, Catsunny wrote: > Hi, > I wonder if there is something wrong in the erlang documentation->STDLIB > Reference->base64? The documentation says: > > base64 > MODULE > base64 > MODULE SUMMARY > Implements base 64 encode and decode, see RFC2045. > DESCRIPTION > Implements base 64 encode and decode, see RFC2045. > > EXPORTS > encode(Data) -> Base64 > encode_to_string(Data) -> Base64String > > > Types: > > Data = string() | binary() > Base64 = binary() > Base64String = string() > > > Encodes a plain ASCII string into base64. The result will be 33% larger > than the data. > > decode(Base64) -> Data > decode_to_string(Base64) -> DataString > mime_decode(Base64) -> Data > mime_decode_string(Base64) -> DataString > > > Types: > > Base64 = string() | binary() > Data = binary() > DataString = string() > > > Decodes a base64 encoded string to plain ASCII. The string should only > consist of characters in the base64 set, see RFC4648. mime_decode/1 and > mime_decode_to_string/1 strips away illegal characters, while decode/1 and > decode_to_string/1 fails if an illegal charactrer is found. > > > -------------------------------------------------------------------------------- > stdlib 1.15.1 > Copyright ? 1991-2008 Ericsson AB > > All the functions is ok except the last one, mime_decode_string/1: > 11> base64:mime_decode_string(base64:encode_to_string("??")). > ** exception error: undefined function base64:mime_decode_string/1. > Is this an error in the library reference manual? > > Thank you! > catsunny > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From lemenkov@REDACTED Tue May 6 09:38:33 2008 From: lemenkov@REDACTED (Peter Lemenkov) Date: Tue, 6 May 2008 11:38:33 +0400 Subject: [erlang-questions] planet.trapexit.org down? Message-ID: Hello All! Seems that nobody takes care of this rss-aggregation - its latest update was about than two weeks ago. Another one issue is that it produces wrong xml-page (it can't be loaded into my Firefox). Maybe someone could ping guys behind trapexit.org? -- With best regards! From vychodil.hynek@REDACTED Tue May 6 10:35:01 2008 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Tue, 6 May 2008 10:35:01 +0200 Subject: [erlang-questions] How to start an erlang applications from the command line non-interactively? In-Reply-To: <1210050525.14607.84.camel@seasc0642.dyn.rnd.as.sw.ericsson.se> References: <6c2563b20805051436we7911e1xd7fc22bd343ecc16@mail.gmail.com> <1210050525.14607.84.camel@seasc0642.dyn.rnd.as.sw.ericsson.se> Message-ID: <4d08db370805060135hf487efet325147a8ebafb1bd@mail.gmail.com> There is not difference between ' and " from called program point of view. Both strings are passed as one argv zero byte terminated string. Program can't get knowledge which sort of quotes was used. There is only difference from shell's point of view. What sort of shell you use? On Tue, May 6, 2008 at 7:08 AM, Bengt Kleberg wrote: > Greetings, > > Are you sure about > erl -s foo Jarrod 12345 "This is a string" > resulting in > Name: 'Jarrod', Int: 12345, Str: "This is a string" > ? > > On my machine I have to use > erl -s foo Jarrod 12345 'This is a string' > > Note the ' instead of ". > > > When choosing between -s and -run, IMHO -run is better integrated with > unix than -s (C does not have atoms). > > > bengt > > On Mon, 2008-05-05 at 17:54 -0400, Jarrod Roberson wrote: > > > > > > On Mon, May 5, 2008 at 5:36 PM, Edwin Fine > > wrote: > > > I have a function start(Port, Htdocs) that I want to call > > with 8888, > > > "C:/htdocs" and I can't figure out what the appropriate > > syntax should be. > > > > This can be nasty to get right. It depends on how the command > > line > > interprets characters like single quote and double quote. > > It also depends on whether you use -s or -run. > > > > -s interprets all function arguments as atoms, so your program > > will > > get all the values as atoms. You will usually need to write a > > special > > MFA to convert the atoms to the actual types of the parameters > > desired. Note that all arguments get passed in a single list > > when > > called like this (see start_cmd_line/3). > > > > -run interprets all function arguments as strings, so your > > program > > will get all the values as string. You will often have to > > write a > > special MFA to convert the strings to the actual types of the > > parameters desired. > > > > For example: > > > > -module(foo). > > -export([start_cmd_line/1, start/3]). > > > > start_cmd_line([NameAtom, IntValue, StrValue]) when > > is_atom(NameAtom), > > is_atom(IntValue), is_atom(StrValue) -> > > Name = NameAtom, % Not really necessary because NameAtom is > > already an atom > > Int = list_to_integer(atom_to_list(IntValue)), % Could > > throw an exception > > Str = atom_to_list(StrValue), > > start(Name, Int, Str). > > > > start(Name, Int, Str) -> > > io:format("Name: ~p, Int: ~p, Str: ~p~n", [Name, Int, > > Str]), > > % Etc > > ok. > > > > If you started the above by > > > > erl -s foo Jarrod 12345 "This is a string" > > > > you would get an output something like this: > > Erlang (BEAM) emulator version 5.6.2 [source] [64-bit] [smp:4] > > [async-threads:0] [hipe] [kernel-poll:false] > > > > Name: 'Jarrod', Int: 12345, Str: "This is a string" > > Eshell V5.6.2 (abort with ^G) > > 1> > > > > Hope this helps. > > > > thanks that clears things up greatly. > > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- --Hynek (Pichi) Vychodil -------------- next part -------------- An HTML attachment was scrubbed... URL: From tobias.lindahl@REDACTED Tue May 6 10:35:20 2008 From: tobias.lindahl@REDACTED (Tobias Lindahl) Date: Tue, 06 May 2008 10:35:20 +0200 Subject: [erlang-questions] Dialyzer programmatic interface and output_plt In-Reply-To: References: Message-ID: <48201848.3070205@it.uu.se> Eric Merritt wrote: > Guys, > > Thanks for getting the programmatic interface to dialyzer back into a > working state! That helps a lot. However, it seems that dialyzer no > longer understands the output_plt option. I don't believe it was ever > documented but it used to work, now dialyzer seems to ignore it. Is > there some other way to get dialyzer to create a plt file using the > erlang interface? For me the option {output_plt, File} works. I tested it with the released sytem (R12B-2) and it seems to work there too. Is there a small test case that you can send me? This is currently the only way of creating a plt using the erlang interface. I am rewriting the plt handling so this will change in the next release. > On a side note. The documentation for dialyzer:run/1 is a bit > misleading. It seems to indicate that you should pass the Msg part of > the warning tuple to dialyzer:format_warning/1. In actuality you > should pass the entire warning tuple. Yes, the documentation is wrong. > It also documents errors as > being strings but I don't believe that they are strings. Unless I am > missing something they follow the same semantics as warnings. The errors are strings, but the documentation is once again wrong. The return from dialyzer:run/1 should be {ok, Warnings} | {error, Warnings, Errors} Where Warnings are as specified in the documentation, and Errors :: [string()]. Thanks for the reports. Both the erlang interface and the gui should be better tested by us, but we are using the command line interface in our testsuits. We should probably do something about this, but alas, sometimes it feels that we don't even have time for the research... Tobias > > Thanks, > Eric > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From mats.cronqvist@REDACTED Tue May 6 11:07:04 2008 From: mats.cronqvist@REDACTED (Mats Cronqvist) Date: Tue, 06 May 2008 11:07:04 +0200 Subject: [erlang-questions] finns find Erlang non-sucky Message-ID: <48201FB8.9070009@kreditor.se> my guess is Erlang will soon be considered kosher inside Ericsson. http://nokia.taleo.net/careersection/10120/jobdetail.ftl?lang=en&job=321961&src=JB-10720 -------------- next part -------------- A non-text attachment was scrubbed... Name: mats_cronqvist.vcf Type: text/x-vcard Size: 179 bytes Desc: not available URL: From sverker@REDACTED Tue May 6 11:09:28 2008 From: sverker@REDACTED (Sverker Eriksson) Date: Tue, 06 May 2008 11:09:28 +0200 Subject: [erlang-questions] Problem with pattern matching in large binaries In-Reply-To: References: Message-ID: <48202048.1060305@erix.ericsson.se> Edwin Fine wrote: > I have a text file that is 1,037,563,663 bytes in length. In the > shell, I read it all into memory as follows: > > >{ok,B} = file:read_file("/tmp/data"). [...] > > <<_Skip:Offset/binary,Last100/binary>> = B. > > byte_size(Last100). > 100 > > byte_size(_Skip). > 500692651 > > WTF??? Checking Last100 showed that it was indeed the data from offset > 500693651, not the last 100 bytes. Where did the other 500MB-odd go? > [...] Per Gustafsson wrote: > I took a look at this and it seems that in the BYTE_OFFSET macro on line > 153 in erl_bits.h there is a cast to unsigned that really should be to > Uint that probably causes this problem, but I do not have a good machine > for testing this change. (Our amd64 does not have enough memory to build > a 1 Gb binary) > > Per > I will take a look at this with my Intel Quad, 64bit, 4 Gb. If Per is right, a fix will be released to R12B-3. /Sverker, Erlang/OTP, Ericsson From ingela@REDACTED Tue May 6 11:43:13 2008 From: ingela@REDACTED (Ingela Anderton Andin) Date: Tue, 06 May 2008 11:43:13 +0200 Subject: [erlang-questions] erlang-questions Digest, Vol 12, Issue 16 In-Reply-To: References: Message-ID: <48202831.5020306@erix.ericsson.se> Thank you for reporting this. It should be mime_decode_to_string/1 e.i a documentation error. base64:mime_decode_to_string(base64:encode_to_string("??")). "??" Regards Ingela, Erlang/OTP Ericsson > All the functions is ok except the last one, mime_decode_string/1: > 11> base64:mime_decode_string(base64:encode_to_string("??")). > ** exception error: undefined function base64:mime_decode_string/1. > Is this an error in the library reference manual? > Thank you! > catsunny From launoja@REDACTED Tue May 6 12:12:20 2008 From: launoja@REDACTED (Jani Launonen) Date: Tue, 06 May 2008 13:12:20 +0300 Subject: [erlang-questions] finns find Erlang non-sucky In-Reply-To: <48201FB8.9070009@kreditor.se> References: <48201FB8.9070009@kreditor.se> Message-ID: ----- Alkuper?inen viesti ----- L?hett?j?: Mats Cronqvist P?iv?ys: tiistai, toukokuu 6, 2008 12:22 pm Aihe: [erlang-questions] finns find Erlang non-sucky Vastaanottaja: Erlang mailing list > my guess is Erlang will soon be considered kosher inside > Ericsson. > http://nokia.taleo.net/careersection/10120/jobdetail.ftl?lang=en&job=321961&src=JB-10720 Not so fast! The job is located in San Francisco --- not here in Finland --- but now I expect to see the day when Nokia in Finland seeks for Erlang developers... :) > From raimo+erlang-questions@REDACTED Tue May 6 12:28:52 2008 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Tue, 6 May 2008 12:28:52 +0200 Subject: [erlang-questions] : : build 64bit Erlang on Solairs In-Reply-To: <20080506034830.GA7789@Sun.Com> References: <20080501122408.GA3630@Sun.Com> <18457.53560.59691.24368@harpo.it.uu.se> <20080501153708.GA3849@Sun.Com> <20080505131622.GA12042@erix.ericsson.se> <20080506034830.GA7789@Sun.Com> Message-ID: <20080506102851.GA27719@erix.ericsson.se> Thank you for your valuable effort. I have made changes for the OpenSSL 64 bit build issue on Solaris in our development branch, plus the Orber problem is gone since R12B-2, so can you try again with a snapshot release: http://www.erlang.org/download/snapshots/otp_src_R12B-3.tar.gz Do not take the one 06-May-2008 02:54 since it accidentally does not have my erts/configure.in changes. I am interested in knowing how much is missing in a snapshot release (7-may) for your builds to work as you need. More comments inserted below... On Tue, May 06, 2008 at 11:48:31AM +0800, Raymond Xiong wrote: > On 05/05/08, Raimo Niskanen wrote: > > > > > > If so, however, isn't it better to add CFLAGS in the follwing > > > line in erts/emulator/Makefile.in? > > > > > > $(BINDIR)/$(EMULATOR_EXECUTABLE): $(INIT_OBJS) $(OBJS) > > > $(PURIFY) $(LD) -o $(BINDIR)/$(EMULATOR_EXECUTABLE) \ > > > $(HIPEBEAMLDFLAGS) $(LDFLAGS) $(DEXPORT) $(INIT_OBJS) $(OBJS) $(LIBS) > > > > > > > It sounds weird to add CFLAGS to the LD command line. > > > > I agree it's better to use "LDFLAGS=-m64". > : > > > > In our nightly builds we have a directory early in the path > > that contains two scripts, essentially: > > gcc: > > #! /bin/sh > > exec /usr/local/pgm/.../bin/gcc -m64 ${1+"$@"} > > ld: > > #! /bin/sh > > exec /usr/ccs/bin/ld -64 ${1+"$@"} > > and we set: > > PATH=/usr/local/bin:/usr/sfw/bin:... > > LD_LIBRARY_PATH=/usr/local/lib:/usr/sfw/lib > > LD_LIBRARY_PATH_64=/usr/sfw/lib/64 > > > > We have it building and running, but it is not a pretty solution. > > Thanks for the tip. It (and the command Mikael mentioned before) > helped me to identify where these issues were. However, I cannot > use it because a) it doesnt' work out of box b) the hack cannot > be accepted in my build environment. > > I have two patches for erts/configure and lib/orber/c_src/Makefile.in > to fix this issue. It works for me on Solaris, so it may be > helpful to others. Here are the introductions: > > $ cd otp_src_R12B-1/ > $ gpatch -p0 < orber_lib_makefile.patch The orber C code was obsoleted and removed in OTP_R12B-2. > $ gpatch -p0 < erts_configure.patch > $ env CC=gcc CFLAGS='-m64 -O3' LDFLAGS="-m64" CPPFLAGS="-I /usr/include/gd2" CXX=g++ ./configure --prefix=/usr --with-ssl=/usr/sfw --enable-dynamic-ssl-lib > $ gmake > I agree it must be the right(tm) way to do it to specify CC="gcc" and CFLAGS="-m64". I believe that for the "ld" linker the correct LDFLAGS should be -64, but I do not recall how they are passed. However I think the configure script should detect that the compiler produces 8-byte integers and figure out the linker flags. At least there is already such code in erts/configure.in. > With above steps, I can build 64bit executables and shared > objects. The only issue is erl_rx_driver.so: > > $ file ./lib/common_test/c_src/erl_rx_driver.so > ./lib/common_test/c_src/erl_rx_driver.so: ELF 32-bit MSB > dynamic lib SPARC Version 1, dynamically linked, not stripped > > The reason is its Makefile is hardcoded, rather than generated > by configure script(there is no Makefile.in under this subdir). > I decide to skip the issue for now. I will talk to the application responsible about this. > > Another thing is that I think the use of LD_LIBRARY_PATH is due > to a bug in lib/crypto/c_src/Makefile.in, which I reported a > while back: > > http://www.erlang.org/pipermail/erlang-patches/2008-March/000241.html I will try that patch and see if it burns... > > -- > Regards, > Raymond > --- erts/configure.orig Sun May 4 23:17:15 2008 > +++ erts/configure Mon May 5 00:34:55 2008 > @@ -20722,6 +20722,12 @@ > SSL_LIBDIR="$with_ssl/lib/VC" > else > SSL_LIBDIR="$with_ssl/lib" > + if test "$GCC" = yes && echo $CFLAGS | grep "\-m64" >/dev/null; then > + case $host_os in > + solaris2*) > + SSL_LIBDIR="$with_ssl/lib/64";; > + esac > + fi > fi > SSL_INCLUDE="-I$with_ssl/include" > OPENSSL_CMD="$with_ssl/bin/openssl" > --- lib/orber/c_src/Makefile.in.orig Sun May 4 22:36:42 2008 > +++ lib/orber/c_src/Makefile.in Sun May 4 22:38:06 2008 > @@ -102,7 +102,7 @@ > -mkdir -p $(BINDIR) > > $(BINDIR)/obj_init_port: $(OBJ_FILES) > - $(CC) -o $@ $(OBJ_FILES) $(LIBS) > + $(CC) -o $@ $(ALL_CFLAGS) $(LDFLAGS) $(OBJ_FILES) $(LIBS) > > $(OBJDIR)/%.o: %.c > $(CC) -c -o $@ $(ALL_CFLAGS) $< > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From bengt.kleberg@REDACTED Tue May 6 13:13:04 2008 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Tue, 06 May 2008 13:13:04 +0200 Subject: [erlang-questions] How to start an erlang applications from the command line non-interactively? In-Reply-To: <4d08db370805060135hf487efet325147a8ebafb1bd@mail.gmail.com> References: <6c2563b20805051436we7911e1xd7fc22bd343ecc16@mail.gmail.com> <1210050525.14607.84.camel@seasc0642.dyn.rnd.as.sw.ericsson.se> <4d08db370805060135hf487efet325147a8ebafb1bd@mail.gmail.com> Message-ID: <1210072384.14607.120.camel@seasc0642.dyn.rnd.as.sw.ericsson.se> Greetings, You are correct, it does depend upon the shell. I did not see you mentioning this is the original email. That is why I asked. I use rc (see http://swtch.com/plan9port/man/man1/rc.html or if you are patient http://cm.bell-labs.com/sys/doc/rc.html). bengt On Tue, 2008-05-06 at 10:35 +0200, Hynek Vychodil wrote: > There is not difference between ' and " from called program point of > view. Both strings are passed as one argv zero byte terminated string. > Program can't get knowledge which sort of quotes was used. There is > only difference from shell's point of view. What sort of shell you > use? > > On Tue, May 6, 2008 at 7:08 AM, Bengt Kleberg > wrote: > Greetings, > > Are you sure about > erl -s foo Jarrod 12345 "This is a string" > > resulting in > Name: 'Jarrod', Int: 12345, Str: "This is a string" > > ? > > On my machine I have to use > erl -s foo Jarrod 12345 'This is a string' > > Note the ' instead of ". > > > When choosing between -s and -run, IMHO -run is better > integrated with > unix than -s (C does not have atoms). > > > bengt > > > On Mon, 2008-05-05 at 17:54 -0400, Jarrod Roberson wrote: > > > > > > On Mon, May 5, 2008 at 5:36 PM, Edwin Fine > > wrote: > > > I have a function start(Port, Htdocs) that I want > to call > > with 8888, > > > "C:/htdocs" and I can't figure out what the > appropriate > > syntax should be. > > > > This can be nasty to get right. It depends on how > the command > > line > > interprets characters like single quote and double > quote. > > It also depends on whether you use -s or -run. > > > > -s interprets all function arguments as atoms, so > your program > > will > > get all the values as atoms. You will usually need > to write a > > special > > MFA to convert the atoms to the actual types of the > parameters > > desired. Note that all arguments get passed in a > single list > > when > > called like this (see start_cmd_line/3). > > > > -run interprets all function arguments as strings, > so your > > program > > will get all the values as string. You will often > have to > > write a > > special MFA to convert the strings to the actual > types of the > > parameters desired. > > > > For example: > > > > -module(foo). > > -export([start_cmd_line/1, start/3]). > > > > start_cmd_line([NameAtom, IntValue, StrValue]) when > > is_atom(NameAtom), > > is_atom(IntValue), is_atom(StrValue) -> > > Name = NameAtom, % Not really necessary because > NameAtom is > > already an atom > > Int = list_to_integer(atom_to_list(IntValue)), % > Could > > throw an exception > > Str = atom_to_list(StrValue), > > start(Name, Int, Str). > > > > start(Name, Int, Str) -> > > io:format("Name: ~p, Int: ~p, Str: ~p~n", [Name, > Int, > > Str]), > > % Etc > > ok. > > > > If you started the above by > > > > erl -s foo Jarrod 12345 "This is a string" > > > > you would get an output something like this: > > Erlang (BEAM) emulator version 5.6.2 [source] > [64-bit] [smp:4] > > [async-threads:0] [hipe] [kernel-poll:false] > > > > Name: 'Jarrod', Int: 12345, Str: "This is a string" > > Eshell V5.6.2 (abort with ^G) > > 1> > > > > Hope this helps. > > > > thanks that clears things up greatly. > > > > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > -- > --Hynek (Pichi) Vychodil From raimo+erlang-questions@REDACTED Tue May 6 13:43:52 2008 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Tue, 6 May 2008 13:43:52 +0200 Subject: [erlang-questions] : : : build 64bit Erlang on Solairs In-Reply-To: <20080506102851.GA27719@erix.ericsson.se> References: <20080501122408.GA3630@Sun.Com> <18457.53560.59691.24368@harpo.it.uu.se> <20080501153708.GA3849@Sun.Com> <20080505131622.GA12042@erix.ericsson.se> <20080506034830.GA7789@Sun.Com> <20080506102851.GA27719@erix.ericsson.se> Message-ID: <20080506114352.GA31297@erix.ericsson.se> On Tue, May 06, 2008 at 12:28:52PM +0200, Raimo Niskanen wrote: : : > > With above steps, I can build 64bit executables and shared > > objects. The only issue is erl_rx_driver.so: > > > > $ file ./lib/common_test/c_src/erl_rx_driver.so > > ./lib/common_test/c_src/erl_rx_driver.so: ELF 32-bit MSB > > dynamic lib SPARC Version 1, dynamically linked, not stripped > > > > The reason is its Makefile is hardcoded, rather than generated > > by configure script(there is no Makefile.in under this subdir). > > I decide to skip the issue for now. > > I will talk to the application responsible about this. > I have some feedback. The makefile for common_test/c_src is a known problem. But the rx driver is about to be replaced, and when that happens the configure/make for common_test will be adapted to the OTP build environment. The reason is that common_test was first developed outside of OTP so its build tools started off as completely independent of OTP. -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From Jouni.Ryno@REDACTED Tue May 6 13:50:22 2008 From: Jouni.Ryno@REDACTED (Jouni =?ISO-8859-1?Q?Ryn=F6?=) Date: Tue, 06 May 2008 14:50:22 +0300 Subject: [erlang-questions] finns find Erlang non-sucky In-Reply-To: References: <48201FB8.9070009@kreditor.se> Message-ID: <1210074622.4393.23.camel@adic.fmi.fi> On Tue, 2008-05-06 at 13:12 +0300, Jani Launonen wrote: > > ----- Alkuper?inen viesti ----- > L?hett?j?: Mats Cronqvist > P?iv?ys: tiistai, toukokuu 6, 2008 12:22 pm > Aihe: [erlang-questions] finns find Erlang non-sucky > Vastaanottaja: Erlang mailing list > > > my guess is Erlang will soon be considered kosher inside > > Ericsson. > > http://nokia.taleo.net/careersection/10120/jobdetail.ftl?lang=en&job=321961&src=JB-10720 > > Not so fast! The job is located in San Francisco --- not here in Finland --- but now I expect to see the day when Nokia in Finland seeks for Erlang developers... :) > I would not expect Nokia to announce about the Erlang career in Finland. Cheaper to phone call the 4 persons or so, who publicly use or have used it in Finland ... :) Actually, it looks like I'm able to quad the number of Erlang persons in FMI this summer (erlang weather station ...) Jouni -- Jouni Ryn? mailto://Jouni.Ryno@REDACTED/ http://space.fmi.fi/~ryno/ Finnish Meteorological Institute http://www.fmi.fi/ P.O.BOX 503 Tel (+358)-9-19294656 FIN-00101 Helsinki FAX (+358)-9-19294603 Finland priv-GSM (+358)-50-5302903 "It's just zeros and ones, it cannot be hard" From 0x6e6562@REDACTED Tue May 6 14:18:06 2008 From: 0x6e6562@REDACTED (Ben Hood) Date: Tue, 6 May 2008 13:18:06 +0100 Subject: [erlang-questions] os_mon in OS X In-Reply-To: <482049BB.6020004@erix.ericsson.se> References: <74FB8CA7-7AEC-4DD9-831F-594647BFDC27@gmail.com> <482049BB.6020004@erix.ericsson.se> Message-ID: Hi Bj?rn-Egil, Unfortunately I can't either because my locale doesn't use commas for decimal places. The user that reported this to me (using RabbitMQ server) sent error dump via a chat session which I don't have a transcript for. So I have asked him to resend it and I will post it. That user had a German locale so the output of uptime was 1:59 up 1 day, 6:07, 5 users, load averages: 0,77 0,94 1,02 with commas instead of decimal points. Looking through the code that parses the output from uptime, it assumes that you have decimal points. IMHO It's a really stupid thing from the setup of the OS because by localizing the output of well known unix commands, you can potentially break a lot of code that parses the output. However, it resulted in an error whilst using RabbitMQ (which is written in Erlang) so we will take this down as a known issue, unless of course you feel it is worth fixing. Thx, Ben On 6 May 2008, at 13:06, Bj?rn-Egil Dahlberg wrote: > Hi Ben, > > Ben Hood wrote: >> The get_uint32_measurement/2 call in cpu_sup seems to throw a bad >> match when the locale of the shell that the process is running in >> does not use a decimal point to denote a fraction. >> For example, if the result of /usr/bin/uptime is >> 1:59 up 1 day, 6:07, 5 users, load averages: 0,77 0,94 1,02 >> then the get_uint32_measurement fails. >> This occurs in R12B-1 with uname >> Darwin Macintosh-3.local 9.2.2 Darwin Kernel Version 9.2.2: Tue Mar >> 4 21:17:34 PST 2008; root:xnu-1228.4.31~1/RELEASE_I386 i386 > > I can't reproduce this error, using: > > Darwin dwalin 9.2.2 Darwin Kernel Version 9.2.2: Tue Mar 4 21:17:34 > PST 2008; root:xnu-1228.4.31~1/RELEASE_I386 i386 > > Since r12b os_mon uses "LANG=C uptime" as basis for load > determination on darwin. This should produce, > > dwalin:~ egil$ LANG=C uptime > 14:03 up 7 days, 22:31, 3 users, load averages: 0.10 0.27 0.28 > > It would be helpful if you could send a complete error dump if/when > the error occurs. > > Regards, > Bj?rn-Egil > Erlang/OTP > > From erlang-questions_efine@REDACTED Tue May 6 15:51:10 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Tue, 6 May 2008 09:51:10 -0400 Subject: [erlang-questions] How to start an erlang applications from the command line non-interactively? In-Reply-To: <6c2563b20805060650se287311va05346de023f1d66@mail.gmail.com> References: <6c2563b20805051436we7911e1xd7fc22bd343ecc16@mail.gmail.com> <1210050525.14607.84.camel@seasc0642.dyn.rnd.as.sw.ericsson.se> <4d08db370805060135hf487efet325147a8ebafb1bd@mail.gmail.com> <1210072384.14607.120.camel@seasc0642.dyn.rnd.as.sw.ericsson.se> <6c2563b20805060650se287311va05346de023f1d66@mail.gmail.com> Message-ID: <6c2563b20805060651s2d86d455h95ca2f4e35ff9ded@mail.gmail.com> As I said in my post on this topic, "This can be nasty to get right. It depends on how the command line interprets characters like single quote and double quote. It also depends on whether you use -s or -run." On Tue, May 6, 2008 at 7:13 AM, Bengt Kleberg wrote: > Greetings, > > You are correct, it does depend upon the shell. I did not see you > mentioning this is the original email. That is why I asked. > > I use rc (see http://swtch.com/plan9port/man/man1/rc.html or if you are > patient http://cm.bell-labs.com/sys/doc/rc.html). > > > bengt > > > > On Tue, 2008-05-06 at 10:35 +0200, Hynek Vychodil wrote: > > There is not difference between ' and " from called program point of > > view. Both strings are passed as one argv zero byte terminated string. > > Program can't get knowledge which sort of quotes was used. There is > > only difference from shell's point of view. What sort of shell you > > use? > > > > On Tue, May 6, 2008 at 7:08 AM, Bengt Kleberg > > wrote: > > Greetings, > > > > Are you sure about > > erl -s foo Jarrod 12345 "This is a string" > > > > resulting in > > Name: 'Jarrod', Int: 12345, Str: "This is a string" > > > > ? > > > > On my machine I have to use > > erl -s foo Jarrod 12345 'This is a string' > > > > Note the ' instead of ". > > > > > > When choosing between -s and -run, IMHO -run is better > > integrated with > > unix than -s (C does not have atoms). > > > > > > bengt > > > > > > On Mon, 2008-05-05 at 17:54 -0400, Jarrod Roberson wrote: > > > > > > > > > On Mon, May 5, 2008 at 5:36 PM, Edwin Fine > > > wrote: > > > > I have a function start(Port, Htdocs) that I want > > to call > > > with 8888, > > > > "C:/htdocs" and I can't figure out what the > > appropriate > > > syntax should be. > > > > > > This can be nasty to get right. It depends on how > > the command > > > line > > > interprets characters like single quote and double > > quote. > > > It also depends on whether you use -s or -run. > > > > > > -s interprets all function arguments as atoms, so > > your program > > > will > > > get all the values as atoms. You will usually need > > to write a > > > special > > > MFA to convert the atoms to the actual types of the > > parameters > > > desired. Note that all arguments get passed in a > > single list > > > when > > > called like this (see start_cmd_line/3). > > > > > > -run interprets all function arguments as strings, > > so your > > > program > > > will get all the values as string. You will often > > have to > > > write a > > > special MFA to convert the strings to the actual > > types of the > > > parameters desired. > > > > > > For example: > > > > > > -module(foo). > > > -export([start_cmd_line/1, start/3]). > > > > > > start_cmd_line([NameAtom, IntValue, StrValue]) when > > > is_atom(NameAtom), > > > is_atom(IntValue), is_atom(StrValue) -> > > > Name = NameAtom, % Not really necessary because > > NameAtom is > > > already an atom > > > Int = list_to_integer(atom_to_list(IntValue)), % > > Could > > > throw an exception > > > Str = atom_to_list(StrValue), > > > start(Name, Int, Str). > > > > > > start(Name, Int, Str) -> > > > io:format("Name: ~p, Int: ~p, Str: ~p~n", [Name, > > Int, > > > Str]), > > > % Etc > > > ok. > > > > > > If you started the above by > > > > > > erl -s foo Jarrod 12345 "This is a string" > > > > > > you would get an output something like this: > > > Erlang (BEAM) emulator version 5.6.2 [source] > > [64-bit] [smp:4] > > > [async-threads:0] [hipe] [kernel-poll:false] > > > > > > Name: 'Jarrod', Int: 12345, Str: "This is a string" > > > Eshell V5.6.2 (abort with ^G) > > > 1> > > > > > > Hope this helps. > > > > > > thanks that clears things up greatly. > > > > > > > > > > > > > _______________________________________________ > > > erlang-questions mailing list > > > erlang-questions@REDACTED > > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > > > > > > -- > > --Hynek (Pichi) Vychodil > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > From erlang-questions_efine@REDACTED Tue May 6 16:10:47 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Tue, 6 May 2008 10:10:47 -0400 Subject: [erlang-questions] Problem with pattern matching in large binaries In-Reply-To: <48202048.1060305@erix.ericsson.se> References: <48202048.1060305@erix.ericsson.se> Message-ID: <6c2563b20805060710y46fc60b1uc5670906d99d26bd@mail.gmail.com> Thanks for the info. I rebuilt my Erlang VM after making Per's change, and the behavior is now as follows: 1> {ok,B} = file:read_file("large_test_data.txt"). {ok,<<"...">>} 2> byte_size(B). 1037563663 3> Offset = byte_size(B) - 100. 1037563563 4> <<_Skip:Offset/binary,Last100/binary>> = B. <<"...">> 5> byte_size(Last100). 100 6> byte_size(_Skip). 1037563563 %% This is now correct. Before the 1-line change I made to erl_bits.h, this was incorrect Everything I was trying to do now works correctly. All that is left is to regression test my applications, just in case. Maybe you could make this available as a patch - it's a trivial change. Thanks again. Regards Edwin Fine Fine Computer Consultants, Inc. On Tue, May 6, 2008 at 5:09 AM, Sverker Eriksson wrote: > Edwin Fine wrote: > > I have a text file that is 1,037,563,663 bytes in length. In the > > shell, I read it all into memory as follows: > > > > >{ok,B} = file:read_file("/tmp/data"). > [...] > > > > > <<_Skip:Offset/binary,Last100/binary>> = B. > > > byte_size(Last100). > > 100 > > > byte_size(_Skip). > > 500692651 > > > > WTF??? Checking Last100 showed that it was indeed the data from offset > > 500693651, not the last 100 bytes. Where did the other 500MB-odd go? > > > [...] > > Per Gustafsson wrote: > > I took a look at this and it seems that in the BYTE_OFFSET macro on line > > 153 in erl_bits.h there is a cast to unsigned that really should be to > > Uint that probably causes this problem, but I do not have a good machine > > for testing this change. (Our amd64 does not have enough memory to build > > a 1 Gb binary) > > > > Per > > > > I will take a look at this with my Intel Quad, 64bit, 4 Gb. > > If Per is right, a fix will be released to R12B-3. > > /Sverker, Erlang/OTP, Ericsson > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > From kostis@REDACTED Tue May 6 16:59:01 2008 From: kostis@REDACTED (Kostis Sagonas) Date: Tue, 06 May 2008 17:59:01 +0300 Subject: [erlang-questions] Problem with pattern matching in large binaries In-Reply-To: <48202048.1060305@erix.ericsson.se> References: <48202048.1060305@erix.ericsson.se> Message-ID: <48207235.6010300@cs.ntua.gr> Sverker Eriksson wrote: > > Per Gustafsson wrote: >> I took a look at this and it seems that in the BYTE_OFFSET macro on line >> 153 in erl_bits.h there is a cast to unsigned that really should be to >> Uint that probably causes this problem, but I do not have a good machine >> for testing this change. (Our amd64 does not have enough memory to build >> a 1 Gb binary) > > I will take a look at this with my Intel Quad, 64bit, 4 Gb. > > If Per is right, a fix will be released to R12B-3. I have not seen Per's mail on the mailing list (just the above reply), but I can confirm that by modifying the macro on line 153 as Per suggested, some things work as expected regarding big binary construction on a 64 bit machine. For example, without the fix, I get: 1> B = <<1:(2 bsl 32)>>. <<>> which is clearly bogus, while with the fix: 1> B = <<1:(2 bsl 32)>>. <<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,...>> which seems much more likely to be the correct result. Indeed: 2> byte_size(B). 1073741824 3> 2 bsl 32. 8589934592 For those eager to try it: the fix is trivial and can be applied by interested parties by hand, instead of waiting till the official release of R12B-3. Kostis From 0x6e6562@REDACTED Tue May 6 18:20:46 2008 From: 0x6e6562@REDACTED (Ben Hood) Date: Tue, 6 May 2008 17:20:46 +0100 Subject: [erlang-questions] os_mon in OS X In-Reply-To: References: <74FB8CA7-7AEC-4DD9-831F-594647BFDC27@gmail.com> <482049BB.6020004@erix.ericsson.se> Message-ID: <01BC8448-F207-40ED-AE31-B25EACBCE049@gmail.com> Bj?rn-Egil, On 6 May 2008, at 13:18, Ben Hood wrote: > The user that reported this to me (using RabbitMQ server) sent error > dump via a chat session which I don't have a transcript for. So I > have asked him to resend it and I will post it. > This is the error trace: =ERROR REPORT==== 6-May-2008::14:47:00 === Error in process <0.52.0> on node 'rabbit@REDACTED' with exit value: {{badmatch,{error,{fread,float}}},[{cpu_sup,get_uint32_measurement,2}, {cpu_ sup,measurement_server_loop,1}]} Regards, Ben From cyberlync@REDACTED Tue May 6 23:19:08 2008 From: cyberlync@REDACTED (Eric Merritt) Date: Tue, 6 May 2008 21:19:08 +0000 Subject: [erlang-questions] Dialyzer programmatic interface and output_plt In-Reply-To: <48201848.3070205@it.uu.se> References: <48201848.3070205@it.uu.se> Message-ID: On Tue, May 6, 2008 at 8:35 AM, Tobias Lindahl wrote: > > Eric Merritt wrote: > > > Guys, > > > > Thanks for getting the programmatic interface to dialyzer back into a > > working state! That helps a lot. However, it seems that dialyzer no > > longer understands the output_plt option. I don't believe it was ever > > documented but it used to work, now dialyzer seems to ignore it. Is > > there some other way to get dialyzer to create a plt file using the > > erlang interface? > > > > For me the option {output_plt, File} works. I tested it with the released > sytem (R12B-2) and it seems to work there too. Is there a small test case > that you can send me? I will see if I can put together a simple test case for you. At the very least I can verify that its not my issue. > This is currently the only way of creating a plt using the erlang > interface. I am rewriting the plt handling so this will change in the next > release. Thats just fine with me. As long as there is at least one way ;) From jgray@REDACTED Tue May 6 23:41:29 2008 From: jgray@REDACTED (Jonathan Gray) Date: Tue, 6 May 2008 14:41:29 -0700 (PDT) Subject: [erlang-questions] Strange issue with Jinterface and marshalling Message-ID: <54538.99.153.112.161.1210110089.squirrel@webmail.streamy.com> I am having a very strange problem when marshalling an Erlang term in Java using Jinterface and sending it to a native erlang program. I am able to unmarshall from Erlang to Java, and marshall and unmarshall within Java. After spending some time looking into the raw data, it appears that when I marshall the same term within Erlang there is an extra byte at the front that is missing from the Java marshalled bytes. It is a hex 0x83 (integer 131). If I append this to the front of my byte array in Java, and then send, my erlang program can demarshall it without any problem whatsoever. The Jinterface library is able to demarshall either format (w/ and w/o the header) into the exact same erlang terms. Is this some type of version header? I'm using the Jinterface library that came with the erlang version I am using. We have moved forward by simply appending this extra byte, but this is a very strange behavior and we'd like to figure out what it's all about. Thanks for any help. Jonathan Gray From jgray@REDACTED Tue May 6 23:31:14 2008 From: jgray@REDACTED (Jonathan Gray) Date: Tue, 6 May 2008 14:31:14 -0700 (PDT) Subject: [erlang-questions] how: Strange issue with Jinterface and marshalling Message-ID: <54474.99.153.112.161.1210109474.squirrel@webmail.streamy.com> I am having a very strange problem when marshalling an Erlang term in Java using Jinterface and sending it to a native erlang program. I am able to unmarshall from Erlang to Java, and marshall and unmarshall within Java. After spending some time looking into the raw data, it appears that when I marshall the same term within Erlang there is an extra byte at the front that is missing from the Java marshalled bytes. It is a hex 0x83 (integer 131). If I append this to the front of my byte array in Java, and then send, my erlang program can demarshall it without any problem whatsoever. The Jinterface library is able to demarshall either format (w/ and w/o the header) into the exact same erlang terms. Is this some type of version header? I'm using the Jinterface library that came with the erlang version I am using. We have moved forward by simply appending this extra byte, but this is a very strange behavior and we'd like to figure out what it's all about. Thanks for any help. Jonathan Gray From erlangy@REDACTED Wed May 7 00:41:55 2008 From: erlangy@REDACTED (Michael McDaniel) Date: Tue, 6 May 2008 15:41:55 -0700 Subject: [erlang-questions] how: Strange issue with Jinterface and marshalling In-Reply-To: <54474.99.153.112.161.1210109474.squirrel@webmail.streamy.com> References: <54474.99.153.112.161.1210109474.squirrel@webmail.streamy.com> Message-ID: <20080506224155.GE6759@delora.autosys.us> a web search with these terms .. erlang jinterface byte 131 reveals this thread ... http://www.erlang.org/pipermail/erlang-questions/2005-June/015760.html "... > Yes, the 131 (*) is always there, because term_to_binary encodes > into Erlang external format. > > See also $ERL_TOP/erts/emulator/internal_doc/erl_ext_dist.txt for > details about the format, if you're interested. ..." ~Michael On Tue, May 06, 2008 at 02:31:14PM -0700, Jonathan Gray wrote: > I am having a very strange problem when marshalling an Erlang term in Java > using Jinterface and sending it to a native erlang program. > > I am able to unmarshall from Erlang to Java, and marshall and unmarshall > within Java. > > After spending some time looking into the raw data, it appears that when I > marshall the same term within Erlang there is an extra byte at the front > that is missing from the Java marshalled bytes. It is a hex 0x83 (integer > 131). > > If I append this to the front of my byte array in Java, and then send, my > erlang program can demarshall it without any problem whatsoever. The > Jinterface library is able to demarshall either format (w/ and w/o the > header) into the exact same erlang terms. > > Is this some type of version header? I'm using the Jinterface library > that came with the erlang version I am using. > > We have moved forward by simply appending this extra byte, but this is a > very strange behavior and we'd like to figure out what it's all about. > > Thanks for any help. > > Jonathan Gray > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- Michael McDaniel Portland, Oregon, USA http://autosys.us +1 503 283 5284 From igorrs@REDACTED Wed May 7 02:29:20 2008 From: igorrs@REDACTED (Igor Ribeiro Sucupira) Date: Tue, 6 May 2008 21:29:20 -0300 Subject: [erlang-questions] GC trace data In-Reply-To: References: Message-ID: erl -man erlang Explains everything. Or in the web: http://www.erlang.org/doc/man/erlang.html On Mon, May 5, 2008 at 12:23 PM, Jachym Holecek wrote: > Hello, > > I'm using 'erlang:trace(Pid, true, [garbage_collection])' to benchmark > process memory usage and I'm not sure about the exact meaning of data > delivered with gc_start/gc_end events. Here's list of keys and how I > understand them: > > heap_block_size - Total heap size. > heap_size - Size of used part of the heap. > mbuf_size - Size of messages queued in process mailbox. > old_heap_block_size - ?? > old_heap_size - ?? > recent_size - ?? > stack_size - Current stack size. > > Does it sound sensible? Can someone help me fill in the blanks? > > What I really care about is: 1. stack size (got that), 2. mailbox > size (got that), 3. size of used part of heap (could be 'heap_size' > or 'heap_size + old_heap_size' or something completely different?). > > I'm running R11B in case it makes any difference. > > Thanks in advance, > -- Jachym From fritchie@REDACTED Wed May 7 06:16:05 2008 From: fritchie@REDACTED (Scott Lystig Fritchie) Date: Tue, 06 May 2008 23:16:05 -0500 Subject: [erlang-questions] Control-Z as a scheduler test ... provokes gen_leader bug? Message-ID: <200805070416.m474G5ns079624@snookles.snookles.com> Hi, all. I've got a question about the fairness of using Control-Z as a brute-force method of disrupting the VM's scheduler. I used Control-Z and "kill -STOP {pid}" to simulate Erlang VM failures. It's easier than yanking Ethernet cables and plugging them back in. (Especially when all nodes are running on the same physical machine.) After all, such suspension simulates a *really* slow/overloaded/ unresponsive-but-not-yet-dead Erlang VM. I'm searching for opinions on a couple of questions, actually. 1. Is this a failure case that can happen in The Real World? Crazier things have happened, such as: a. "killall -STOP beam" b. Suspending an entire machine by sending a BREAK to a Sun RS-232 serial console (or name-your-hardware/OS-equivalent). c. Virtual memory thrashing causing the OS scheduler avoid scheduling the beam process for many seconds. 2. When it comes to long-term/persistent data storage (and other apps), people can get pretty pissed off even when one-in-a-million events happen. (Er, I dunno if there's a question here. :) 3. Hrm, it looks like using the heart app would avoid this. What strategies do you use, if your app isn't running as "root" and so "whole OS reboot" isn't an option? Below is the set of steps to demonstrate the problem with a 3-node gen_leader system. Is it possible that the bug lies within gdict.erl or test_cb.erl instead? -Scott 1. In the shell of each of the three nodes: gdict:new(foo, ['a@REDACTED', 'b@REDACTED', 'c@REDACTED'], []). 2. On any one of the three nodes: gdict:store(k1, 1, foo). gdict:store(k2, 2, foo). gdict:store(k3, 3, foo). 3. In the shell of the elected node, press Control-z to suspend the VM. For example's sake, we'll assume it's node 'a@REDACTED'. 4. Wait for the other two nodes to notice the timeout of 'a@REDACTED'. Then wait for the election announcement on one of the surviving nodes. Call the new elected node X. 5. Type "fg" to resume node 'a@REDACTED'. I see no election notice, so node X is still the leader. 6. On one of the other two nodes, 'b@REDACTED' or 'c@REDACTED': gdict:store(k4, 4, foo). 7. Run the following on each node: gdict:fetch_keys(foo). 8. The results that I see are: node 'a@REDACTED' node 'b@REDACTED' node 'b@REDACTED' [k1,k2,k3] [k1,k2,k3,k4] [k1,k2,k3,k4] 9. On node 'a@REDACTED": gdict:store(k8, 88888, foo). 10. Run the following on each node: gdict:fetch_keys(foo). 11. The results that I see are: node 'a@REDACTED' node 'b@REDACTED' node 'b@REDACTED' [k1,k2,k3,k8] [k1,k2,k3,k4] [k1,k2,k3,k4] From Raymond.Xiong@REDACTED Wed May 7 07:43:29 2008 From: Raymond.Xiong@REDACTED (Raymond Xiong) Date: Wed, 07 May 2008 13:43:29 +0800 Subject: [erlang-questions] : : build 64bit Erlang on Solairs In-Reply-To: <20080506102851.GA27719@erix.ericsson.se> References: <20080501122408.GA3630@Sun.Com> <18457.53560.59691.24368@harpo.it.uu.se> <20080501153708.GA3849@Sun.Com> <20080505131622.GA12042@erix.ericsson.se> <20080506034830.GA7789@Sun.Com> <20080506102851.GA27719@erix.ericsson.se> Message-ID: <20080507054328.GA10048@Sun.Com> On 05/06/08, Raimo Niskanen wrote: > > http://www.erlang.org/download/snapshots/otp_src_R12B-3.tar.gz > > Do not take the one 06-May-2008 02:54 since it accidentally > does not have my erts/configure.in changes. I am interested in > knowing how much is missing in a snapshot release (7-may) > for your builds to work as you need. Raimo, I gave it a quick try and it worked fine with the following command: $ env CC=gcc CFLAGS='-m64 -O3' LDFLAGS="-m64" CPPFLAGS="-I /usr/include/gd2" CXX=g++ ./configure --prefix=/export/tmp_b --with-ssl=/usr/sfw --enable-dynamic-ssl-lib See more below... > > $ gpatch -p0 < erts_configure.patch > > $ env CC=gcc CFLAGS='-m64 -O3' LDFLAGS="-m64" CPPFLAGS="-I /usr/include/gd2" CXX=g++ ./configure --prefix=/usr --with-ssl=/usr/sfw --enable-dynamic-ssl-lib > > $ gmake > > > > I agree it must be the right(tm) way to do it to specify > CC="gcc" and CFLAGS="-m64". I believe that for the "ld" > linker the correct LDFLAGS should be -64, but I do not > recall how they are passed. However I think the configure > script should detect that the compiler produces 8-byte > integers and figure out the linker flags. At least there > is already such code in erts/configure.in. > Yes, I also think it is a bit weird to define "-m64" in LDFLAGS, but that is the only way to get it working. If you don't set it (or set it to "-64"), the build would fail when it generates beam executable file. See following log: gcc -o /export/tmp_a/otp_src_R12B-1/bin/sparc-sun-solaris2.11/beam \ -64 obj/sparc-sun-solaris2.11/opt/plain/erl_main.o ... gcc: unrecognized option `-64' ld: fatal: file obj/sparc-sun-solaris2.11/opt/plain/erl_main.o: wrong ELF class: ELFCLASS64 ld: fatal: File processing errors. No output written to /export/tmp_a/otp_src_R12B-1/bin/sparc-sun-solaris2.11/beam The reason is in the follwing lines in erts/emulator/Makefile.in: $(BINDIR)/$(EMULATOR_EXECUTABLE): $(INIT_OBJS) $(OBJS) $(PURIFY) $(LD) -o $(BINDIR)/$(EMULATOR_EXECUTABLE) \ $(HIPEBEAMLDFLAGS) $(LDFLAGS) $(DEXPORT) $(INIT_OBJS) $(OBJS) $(LIBS) That's why I asked in previous mail if it's beter to include CFLAGS in above lines. But as you mentioned, it is probably not a good practice. I googled on the net and found using -m64 in LDFLAGs seems to be a popular solution to such issue. So I am OK with this usage. Thanks, Raymond From raimo+erlang-questions@REDACTED Wed May 7 09:00:05 2008 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Wed, 7 May 2008 09:00:05 +0200 Subject: [erlang-questions] how: Strange issue with Jinterface and marshalling In-Reply-To: <54474.99.153.112.161.1210109474.squirrel@webmail.streamy.com> References: <54474.99.153.112.161.1210109474.squirrel@webmail.streamy.com> Message-ID: <20080507070005.GA19641@erix.ericsson.se> On Tue, May 06, 2008 at 02:31:14PM -0700, Jonathan Gray wrote: > I am having a very strange problem when marshalling an Erlang term in Java > using Jinterface and sending it to a native erlang program. > > I am able to unmarshall from Erlang to Java, and marshall and unmarshall > within Java. > > After spending some time looking into the raw data, it appears that when I > marshall the same term within Erlang there is an extra byte at the front > that is missing from the Java marshalled bytes. It is a hex 0x83 (integer > 131). > > If I append this to the front of my byte array in Java, and then send, my > erlang program can demarshall it without any problem whatsoever. The > Jinterface library is able to demarshall either format (w/ and w/o the > header) into the exact same erlang terms. > > Is this some type of version header? I'm using the Jinterface library > that came with the erlang version I am using. > > We have moved forward by simply appending this extra byte, but this is a > very strange behavior and we'd like to figure out what it's all about. OtpOutputStream is a raw creature with several uses. One of them can be to encode an Erlang term in external format (aka marshal). There is no such function in Jinterface (as far as I know) as erlang:term_to_binary/1. Jinterface is focused on communicating with Erlang nodes. If you use OtpMbox.send() it will add the version tag itself. But if you want to create a marshalled Erlang term using OtpOutputStream you have to prepend it with the external format version magic byte 131, though you should use the constant OtpExternal.versionTag instead; it is clearer. > > Thanks for any help. > > Jonathan Gray > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From raimo+erlang-questions@REDACTED Wed May 7 10:01:55 2008 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Wed, 7 May 2008 10:01:55 +0200 Subject: [erlang-questions] : : : build 64bit Erlang on Solairs In-Reply-To: <20080507054328.GA10048@Sun.Com> References: <20080501122408.GA3630@Sun.Com> <18457.53560.59691.24368@harpo.it.uu.se> <20080501153708.GA3849@Sun.Com> <20080505131622.GA12042@erix.ericsson.se> <20080506034830.GA7789@Sun.Com> <20080506102851.GA27719@erix.ericsson.se> <20080507054328.GA10048@Sun.Com> Message-ID: <20080507080155.GB19641@erix.ericsson.se> On Wed, May 07, 2008 at 01:43:29PM +0800, Raymond Xiong wrote: > On 05/06/08, Raimo Niskanen wrote: > > > > http://www.erlang.org/download/snapshots/otp_src_R12B-3.tar.gz > > > > Do not take the one 06-May-2008 02:54 since it accidentally > > does not have my erts/configure.in changes. I am interested in > > knowing how much is missing in a snapshot release (7-may) > > for your builds to work as you need. > > Raimo, > > I gave it a quick try and it worked fine with the following > command: > > $ env CC=gcc CFLAGS='-m64 -O3' LDFLAGS="-m64" CPPFLAGS="-I > /usr/include/gd2" CXX=g++ ./configure --prefix=/export/tmp_b > --with-ssl=/usr/sfw --enable-dynamic-ssl-lib > Great! > See more below... > > > > $ gpatch -p0 < erts_configure.patch > > > $ env CC=gcc CFLAGS='-m64 -O3' LDFLAGS="-m64" CPPFLAGS="-I /usr/include/gd2" CXX=g++ ./configure --prefix=/usr --with-ssl=/usr/sfw --enable-dynamic-ssl-lib > > > $ gmake > > > > > > > I agree it must be the right(tm) way to do it to specify > > CC="gcc" and CFLAGS="-m64". I believe that for the "ld" > > linker the correct LDFLAGS should be -64, but I do not > > recall how they are passed. However I think the configure > > script should detect that the compiler produces 8-byte > > integers and figure out the linker flags. At least there > > is already such code in erts/configure.in. > > > > Yes, I also think it is a bit weird to define "-m64" in LDFLAGS, > but that is the only way to get it working. If you don't set it > (or set it to "-64"), the build would fail when it generates > beam executable file. See following log: > > gcc -o /export/tmp_a/otp_src_R12B-1/bin/sparc-sun-solaris2.11/beam \ > -64 obj/sparc-sun-solaris2.11/opt/plain/erl_main.o ... > gcc: unrecognized option `-64' > ld: fatal: file obj/sparc-sun-solaris2.11/opt/plain/erl_main.o: wrong ELF class: ELFCLASS64 > ld: fatal: File processing errors. No output written to /export/tmp_a/otp_src_R12B-1/bin/sparc-sun-solaris2.11/beam > > The reason is in the follwing lines in erts/emulator/Makefile.in: > > $(BINDIR)/$(EMULATOR_EXECUTABLE): $(INIT_OBJS) $(OBJS) > $(PURIFY) $(LD) -o $(BINDIR)/$(EMULATOR_EXECUTABLE) \ > $(HIPEBEAMLDFLAGS) $(LDFLAGS) $(DEXPORT) $(INIT_OBJS) $(OBJS) $(LIBS) > > That's why I asked in previous mail if it's beter to include > CFLAGS in above lines. But as you mentioned, it is probably > not a good practice. I googled on the net and found using > -m64 in LDFLAGs seems to be a popular solution to such issue. > So I am OK with this usage. It seems $(LD) is really gcc (from your build log), and I am not surprised gcc wants -m64. Probably our 'ld' wrapper script that adds -64 to /usr/ccs/bin/ld is not actually used. I have now checked erts/configure.in and it sets LD='$(CC)'. To be even more formally right you might add LD=gcc to your build command line, to justify LDFLAGS=-m64. > > Thanks, > Raymond > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From Raymond.Xiong@REDACTED Wed May 7 10:13:24 2008 From: Raymond.Xiong@REDACTED (Raymond Xiong) Date: Wed, 07 May 2008 16:13:24 +0800 Subject: [erlang-questions] : : : build 64bit Erlang on Solairs In-Reply-To: <20080507080155.GB19641@erix.ericsson.se> References: <20080501122408.GA3630@Sun.Com> <18457.53560.59691.24368@harpo.it.uu.se> <20080501153708.GA3849@Sun.Com> <20080505131622.GA12042@erix.ericsson.se> <20080506034830.GA7789@Sun.Com> <20080506102851.GA27719@erix.ericsson.se> <20080507054328.GA10048@Sun.Com> <20080507080155.GB19641@erix.ericsson.se> Message-ID: <20080507081323.GA10393@Sun.Com> On 05/07/08, Raimo Niskanen wrote: > > It seems $(LD) is really gcc (from your build log), and I am > not surprised gcc wants -m64. Probably our 'ld' wrapper > script that adds -64 to /usr/ccs/bin/ld is not actually used. > > I have now checked erts/configure.in and it sets LD='$(CC)'. > > To be even more formally right you might add LD=gcc to your > build command line, to justify LDFLAGS=-m64. Yes, that makes sense. Thanks for your help! Raymond From bjorn@REDACTED Wed May 7 10:15:11 2008 From: bjorn@REDACTED (Bjorn Gustavsson) Date: 07 May 2008 10:15:11 +0200 Subject: [erlang-questions] Location options in file:pread/2 and /3 In-Reply-To: <16834826.post@talk.nabble.com> References: <16834826.post@talk.nabble.com> Message-ID: Zvi writes: > Are all these options are still supported in file:pread/2 and file:pread/3 ? > >From my tests, only file:position accepts them. file:pread/2 and /3 only > accepts Offset and giving {error,badarg} for the rest. They are accepted if the file has not been opened in raw mode. There is a note about that in the documentation for pread/3: "If IoDevice has been opened in raw mode, some restrictions apply: Location is only allowed to be an integer; and the current position of the file is undefined after the operation." /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From raimo+erlang-questions@REDACTED Wed May 7 10:33:43 2008 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Wed, 7 May 2008 10:33:43 +0200 Subject: [erlang-questions] : : : : build 64bit Erlang on Solairs In-Reply-To: <20080506114352.GA31297@erix.ericsson.se> References: <20080501122408.GA3630@Sun.Com> <18457.53560.59691.24368@harpo.it.uu.se> <20080501153708.GA3849@Sun.Com> <20080505131622.GA12042@erix.ericsson.se> <20080506034830.GA7789@Sun.Com> <20080506102851.GA27719@erix.ericsson.se> <20080506114352.GA31297@erix.ericsson.se> Message-ID: <20080507083343.GC19641@erix.ericsson.se> On Tue, May 06, 2008 at 01:43:52PM +0200, Raimo Niskanen wrote: > On Tue, May 06, 2008 at 12:28:52PM +0200, Raimo Niskanen wrote: > : > : > > > With above steps, I can build 64bit executables and shared > > > objects. The only issue is erl_rx_driver.so: > > > > > > $ file ./lib/common_test/c_src/erl_rx_driver.so > > > ./lib/common_test/c_src/erl_rx_driver.so: ELF 32-bit MSB > > > dynamic lib SPARC Version 1, dynamically linked, not stripped > > > > > > The reason is its Makefile is hardcoded, rather than generated > > > by configure script(there is no Makefile.in under this subdir). > > > I decide to skip the issue for now. > > > > I will talk to the application responsible about this. > > > > I have some feedback. The makefile for common_test/c_src is > a known problem. But the rx driver is about to be replaced, > and when that happens the configure/make for common_test > will be adapted to the OTP build environment. Update: this will take a while. It will not happen until we have a new regexp library. We probably will have to fix the build for the old rx driver in common_test... > > The reason is that common_test was first developed > outside of OTP so its build tools started off as > completely independent of OTP. > > -- > > / Raimo Niskanen, Erlang/OTP, Ericsson AB > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From Raymond.Xiong@REDACTED Wed May 7 10:55:59 2008 From: Raymond.Xiong@REDACTED (Raymond Xiong) Date: Wed, 07 May 2008 16:55:59 +0800 Subject: [erlang-questions] : : : : build 64bit Erlang on Solairs In-Reply-To: <20080507083343.GC19641@erix.ericsson.se> References: <20080501122408.GA3630@Sun.Com> <18457.53560.59691.24368@harpo.it.uu.se> <20080501153708.GA3849@Sun.Com> <20080505131622.GA12042@erix.ericsson.se> <20080506034830.GA7789@Sun.Com> <20080506102851.GA27719@erix.ericsson.se> <20080506114352.GA31297@erix.ericsson.se> <20080507083343.GC19641@erix.ericsson.se> Message-ID: <20080507085559.GB10434@Sun.Com> On 05/07/08, Raimo Niskanen wrote: > On Tue, May 06, 2008 at 01:43:52PM +0200, Raimo Niskanen wrote: > > On Tue, May 06, 2008 at 12:28:52PM +0200, Raimo Niskanen wrote: > > : > > : > > > > With above steps, I can build 64bit executables and shared > > > > objects. The only issue is erl_rx_driver.so: > > > > > > > > $ file ./lib/common_test/c_src/erl_rx_driver.so > > > > ./lib/common_test/c_src/erl_rx_driver.so: ELF 32-bit MSB > > > > dynamic lib SPARC Version 1, dynamically linked, not stripped > > > > > > > > The reason is its Makefile is hardcoded, rather than generated > > > > by configure script(there is no Makefile.in under this subdir). > > > > I decide to skip the issue for now. > > > > > > I will talk to the application responsible about this. > > > > > > > I have some feedback. The makefile for common_test/c_src is > > a known problem. But the rx driver is about to be replaced, > > and when that happens the configure/make for common_test > > will be adapted to the OTP build environment. > > Update: this will take a while. It will not happen until > we have a new regexp library. We probably will > have to fix the build for the old rx driver > in common_test... Thanks for those information. I will ignore this issue for now. Raymond > > > > > The reason is that common_test was first developed > > outside of OTP so its build tools started off as > > completely independent of OTP. > > > > -- > > > > / Raimo Niskanen, Erlang/OTP, Ericsson AB > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > -- > > / Raimo Niskanen, Erlang/OTP, Ericsson AB -- Regards, Raymond From jachym.holecek@REDACTED Wed May 7 14:14:21 2008 From: jachym.holecek@REDACTED (Jachym Holecek) Date: Wed, 07 May 2008 14:14:21 +0200 Subject: [erlang-questions] GC trace data In-Reply-To: References: Message-ID: On Wed, 07 May 2008 02:29:20 +0200, Igor Ribeiro Sucupira wrote: > erl -man erlang > Explains everything. Well, not in R11B (which is the version I've read before asking). > Or in the web: > http://www.erlang.org/doc/man/erlang.html Thanks, current version describes everything indeed; in particular spawn_opt/4's `fullsweep_after' option gives overview of how GC works which is what I missed before. -- Jachym From hanssv@REDACTED Wed May 7 15:07:01 2008 From: hanssv@REDACTED (Hans Svensson) Date: Wed, 07 May 2008 15:07:01 +0200 Subject: [erlang-questions] once again gen_leader question patched vs non-patched version In-Reply-To: <1218d6a50804292003w480fde67ka0a7eab713d850f@mail.gmail.com> References: <1218d6a50804292003w480fde67ka0a7eab713d850f@mail.gmail.com> Message-ID: <4821A975.8050209@cs.chalmers.se> Given that we use 'gdict' (the global dictionary example, usually distributed together with gen_leader) the following sequence of commands establishes a global dictionary with a configuration similar to yours (my candidates are node1 and node2, and the workers are node3 and node4) all commands are run on a separate node named test: (test@REDACTED)6> nodes(). [node1@REDACTED,node2@REDACTED,node3@REDACTED,node4@REDACTED] (test@REDACTED)7> spawn('node1@REDACTED',gdict,new,[test_ldr,['node1@REDACTED','node2@REDACTED'],['node3@REDACTED','node4@REDACTED']]). <5145.56.0> (test@REDACTED)8> spawn('node2@REDACTED',gdict,new,[test_ldr,['node1@REDACTED','node2@REDACTED'],['node3@REDACTED','node4@REDACTED']]). <5237.55.0> (test@REDACTED)9> spawn('node3@REDACTED',gdict,new,[test_ldr,['node1@REDACTED','node2@REDACTED'],['node3@REDACTED','node4@REDACTED']]). <5238.55.0> (test@REDACTED)10> spawn('node4@REDACTED',gdict,new,[test_ldr,['node1@REDACTED','node2@REDACTED'],['node3@REDACTED','node4@REDACTED']]). <5239.59.0> (test@REDACTED)11> gdict:append(key,value,{test_ldr,'node1@REDACTED'}). ok (test@REDACTED)12> gdict:find(key,{test_ldr,'node2@REDACTED'}). {ok,[value]} (test@REDACTED)13> gdict:find(key,{test_ldr,'node3@REDACTED'}). {ok,[value]} There are some (perhaps not so intuitive) differences between gen_server (where only one process is involved and its global name could be used) and gen_leader (with one process on each candidate/worker that is addressed {name,node}). Also the preferred way of using gen_leader is do define a callback-module, and not call for example gen_leader:leader_call() directly! Hope this helps, /Hans -- Hans Svensson hanssv@REDACTED Computer Science and Engineering, Chalmers University of Technology, Gothenburg, Sweden http://www.cs.chalmers.se/~hanssv db wrote: > I am currently running gen_leader instances only on candidate nodes. > My worker and candidate nodes are follows: > > Candidate Nodes: [a@REDACTED,b@REDACTED] > Worker Nodes: [wa@REDACTED,wb@REDACTED] > > Call is made from node c@REDACTED, which is neither candidate/worker, > causes noproc error. See below. If a node wants to call > gen_leader:leader_call, does it have to run a gen_leader instance? I > tried running gen_leader instance on the workers also, but it crashed > both the gen_leader instances on node a@REDACTED and b@REDACTED I ran both > versions of gen_leader, patched version and non-patched version. On > patched version, I couldn't run gen_leader instance on worker nodes > (this crashed all instances of gen_leader on all nodes), but was able > to run it on non-patched version. Which is the desired behavior, in > regards to gen_leader instance running on worker nodes? > > Also, what is the actual steps to run the gen_leader, so that the > remote nodes (neither worker/candidate) can communicate with elected > leader to send task, which then pushed down to the worker nodes? > > (c@REDACTED)3> gen_leader:leader_call(leader_boo, {lookup, "dummy"}). > ** exception exit: {{gen_leader,leader_call,2}, > {line,246}, > {noproc, > {gen_leader,leader_call, > [leader_boo,{lookup,"dummy"}]}}} > in function gen_leader:leader_call/2 > > > Thank you, From daveb@REDACTED Wed May 7 15:48:23 2008 From: daveb@REDACTED (Dave Bryson) Date: Wed, 7 May 2008 08:48:23 -0500 Subject: [erlang-questions] Preventing a race condition when using dets/ets Message-ID: <75FE0C6D-9136-4DB1-9D33-D48242BB05FC@miceda.org> Say for example I have the following code: {_,N} = ets:lookup(?MODULE,counter), ok = ets:insert(?MODULE, {counter, N+1}). and two processes attempt to access the code at the same time. What's the best approach to prevent a race condition in this situation? Thanks, Dave From pfisher@REDACTED Wed May 7 15:57:15 2008 From: pfisher@REDACTED (Paul Fisher) Date: Wed, 07 May 2008 08:57:15 -0500 Subject: [erlang-questions] Preventing a race condition when using dets/ets In-Reply-To: <75FE0C6D-9136-4DB1-9D33-D48242BB05FC@miceda.org> References: <75FE0C6D-9136-4DB1-9D33-D48242BB05FC@miceda.org> Message-ID: <1210168635.25763.14.camel@pfisher-laptop> On Wed, 2008-05-07 at 08:48 -0500, Dave Bryson wrote: > Say for example I have the following code: > > {_,N} = ets:lookup(?MODULE,counter), > ok = ets:insert(?MODULE, {counter, N+1}). Two options: 1) use ets:update_counter/3, if it is really an integer value with the table being public 2) have a gen_server process "own" the ets table and perform all operations on behalf of callers (gen_server:call/2, 3) with the table being private -- paul From daveb@REDACTED Wed May 7 16:08:24 2008 From: daveb@REDACTED (Dave Bryson) Date: Wed, 7 May 2008 09:08:24 -0500 Subject: [erlang-questions] Preventing a race condition when using dets/ets In-Reply-To: <1210168635.25763.14.camel@pfisher-laptop> References: <75FE0C6D-9136-4DB1-9D33-D48242BB05FC@miceda.org> <1210168635.25763.14.camel@pfisher-laptop> Message-ID: On May 7, 2008, at 8:57 AM, Paul Fisher wrote: > On Wed, 2008-05-07 at 08:48 -0500, Dave Bryson wrote: >> Say for example I have the following code: >> >> {_,N} = ets:lookup(?MODULE,counter), >> ok = ets:insert(?MODULE, {counter, N+1}). > > Two options: > 1) use ets:update_counter/3, if it is really an integer value with the > table being public > 2) have a gen_server process "own" the ets table and perform all > operations on behalf of callers (gen_server:call/2, 3) with the table > being private Thanks for the response. So just to be clear, if the only access to the ets table is through calls to a gen_server process, it (gen_server) will ensure that only one process at a time can access the ets table? Thanks again! Dave From mikael@REDACTED Wed May 7 16:12:28 2008 From: mikael@REDACTED (Mikael Lixenstrand) Date: Wed, 7 May 2008 16:12:28 +0200 Subject: [erlang-questions] Thousands of SCTP sockets Message-ID: I tries write a programme with thousands of sctp sockets with multi homing. When I open a socket against an IP i don't have to specify port but when man use several addresses I have to specify port. Could this be avoid a do not want to keep track of ports that have been used. I know that ports have to be the same on all IPs but i feel that i shouldn't matter. -------------- next part -------------- An HTML attachment was scrubbed... URL: From pfisher@REDACTED Wed May 7 16:20:20 2008 From: pfisher@REDACTED (Paul Fisher) Date: Wed, 07 May 2008 09:20:20 -0500 Subject: [erlang-questions] Preventing a race condition when using dets/ets In-Reply-To: References: <75FE0C6D-9136-4DB1-9D33-D48242BB05FC@miceda.org> <1210168635.25763.14.camel@pfisher-laptop> Message-ID: <1210170020.25763.26.camel@pfisher-laptop> On Wed, 2008-05-07 at 09:08 -0500, Dave Bryson wrote: > On May 7, 2008, at 8:57 AM, Paul Fisher wrote: > > 2) have a gen_server process "own" the ets table and perform all > > operations on behalf of callers (gen_server:call/2, 3) with the table > > being private > > Thanks for the response. So just to be clear, if the only access to > the ets table is through calls to a gen_server process, it > (gen_server) will ensure that only one process at a time can access > the ets table? Since the gen_server process is the only one interacting with the ets table, and it processes messages one-at-a-time, then there is only one process accessing the table. Now this means that you need to wrap the read/increment/write into processing that the gen_server does in response to a single message, which I did not make clear in the initial response (e.g. gen_server:call( my_server, {counter_increment, 1} ) ). -- paul Robert Virding's First Rule: "Any sufficiently complicated concurrent program in another language contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of Erlang." From mats.cronqvist@REDACTED Wed May 7 17:25:23 2008 From: mats.cronqvist@REDACTED (Mats Cronqvist) Date: Wed, 07 May 2008 17:25:23 +0200 Subject: [erlang-questions] Preventing a race condition when using dets/ets In-Reply-To: References: <75FE0C6D-9136-4DB1-9D33-D48242BB05FC@miceda.org> <1210168635.25763.14.camel@pfisher-laptop> Message-ID: <4821C9E3.3090706@kreditor.se> Dave Bryson wrote: > On May 7, 2008, at 8:57 AM, Paul Fisher wrote: > > >> On Wed, 2008-05-07 at 08:48 -0500, Dave Bryson wrote: >> >>> Say for example I have the following code: >>> >>> {_,N} = ets:lookup(?MODULE,counter), >>> ok = ets:insert(?MODULE, {counter, N+1}). >>> >> Two options: >> 1) use ets:update_counter/3, if it is really an integer value with the >> table being public >> 2) have a gen_server process "own" the ets table and perform all >> operations on behalf of callers (gen_server:call/2, 3) with the table >> being private >> > > Thanks for the response. So just to be clear, if the only access to > the ets table is through calls to a gen_server process, it > (gen_server) will ensure that only one process at a time can access > the ets table? the only way to ensure atomicity when using ets is to have a table owning process (it doesn't have to be a gen_server, of course). you can set the 'private' attribute on the table (see ets:new/2) to ensure this. given this; 15> F = fun(T)-> [{_,N}] = ets:lookup(T,counter),ets:insert(T,{counter, N+1}) end. #Fun 16> ets:new(foo,[named_table,private]). foo 17> ets:insert(foo,{counter,0}). true 18> F(foo). true 19> ets:lookup(foo,counter). [{counter,1}] the gen_server could be pretty generic; handle_call({atomic,F},_From,State) -> {reply,F(?MODULE),State}. warning: code is totally untested. only proven correct by extensive model checking. mats -------------- next part -------------- A non-text attachment was scrubbed... Name: mats_cronqvist.vcf Type: text/x-vcard Size: 179 bytes Desc: not available URL: From sverker@REDACTED Wed May 7 17:44:57 2008 From: sverker@REDACTED (Sverker Eriksson) Date: Wed, 07 May 2008 17:44:57 +0200 Subject: [erlang-questions] Preventing a race condition when using dets/ets In-Reply-To: <1210168635.25763.14.camel@pfisher-laptop> References: <75FE0C6D-9136-4DB1-9D33-D48242BB05FC@miceda.org> <1210168635.25763.14.camel@pfisher-laptop> Message-ID: <4821CE79.3040301@erix.ericsson.se> Paul Fisher wrote: > On Wed, 2008-05-07 at 08:48 -0500, Dave Bryson wrote: > >> Say for example I have the following code: >> >> {_,N} = ets:lookup(?MODULE,counter), >> ok = ets:insert(?MODULE, {counter, N+1}). >> > > Two options: > 1) use ets:update_counter/3, if it is really an integer value with the > table being public > 2) have a gen_server process "own" the ets table and perform all > operations on behalf of callers (gen_server:call/2, 3) with the table > being privat Just thought I would mention... As from R12B-2, one call to ets:update_counter/3 can update several integer-counters within the same ets-object. ets:insert(Tab,{key,Done,LeftToDo}). : ets:update_counter(Tab,key,[{2,1},{3,-1}]). /Sverker, Erlang/OTP Ericsson From masterofquestions@REDACTED Wed May 7 17:51:06 2008 From: masterofquestions@REDACTED (db) Date: Wed, 7 May 2008 11:51:06 -0400 Subject: [erlang-questions] few questions: common sense is not so common Message-ID: <1218d6a50805070851p2c204831tf6724fea719039c5@mail.gmail.com> Hi, I have few questions that need be cleared up. Here they are: q1) How come there isn't a way to empty the gen_server mailbox? I have seen only pattern matching for desired messages. q2) I need a way to provide a wrapper around a another gen_server module, what is the recommended approach? (Start the both gen_servers and use wrapper as a proxy messenger to the other gen_server). q3) Do you advice using sequential receives? (I have a process that does the gathering. It waits for so certain # of processes to send reduced results and then forwards the final gathered result to another process. Gather process then loops over for another set of new receive). q4) Sending large list of tuple as messages, 1000 elements, between processes on remote nodes be a wise approach? Thank you, -- 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 From raimo+erlang-questions@REDACTED Wed May 7 18:13:23 2008 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Wed, 7 May 2008 18:13:23 +0200 Subject: [erlang-questions] Thousands of SCTP sockets In-Reply-To: References: Message-ID: <20080507161323.GA9530@erix.ericsson.se> On Wed, May 07, 2008 at 04:12:28PM +0200, Mikael Lixenstrand wrote: > I tries write a programme with thousands of sctp sockets with multi homing. > When I open a socket against an IP i don't have to specify port but when man > use several addresses I have to specify port. Could this be avoid a do not > want to keep track of ports that have been used. I know that ports have to > be the same on all IPs but i feel that i shouldn't matter. It says in http://tools.ietf.org/html/draft-ietf-tsvwg-sctpsocket-13#section-8.1 that "For SCTP, the port given in each socket address must be the same, or sctp_bindx() will fail, setting errno to EINVAL.", which may suggest that if you give a wildcard port for every IP address, it may not be the same port, hence EINVAL. It would be a nice feature if the socket layer would find a port that is free for all IP addresses but perhaps it is too hard. I have nevertheless traced a multi-home open a'la: gen_sctp:open(4711, [{ip,{192,168,0,17}},{ip,{127,0,0,1}}]). and it is the driver that reports back an error if I use port 0 instead of 4711 - the error comes from the code calling bindx() in the SCTP API, so it is most probably the socket layer that fails since using port 4711 does not. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From jarrod@REDACTED Wed May 7 20:33:20 2008 From: jarrod@REDACTED (Jarrod Roberson) Date: Wed, 7 May 2008 14:33:20 -0400 Subject: [erlang-questions] How to get strings instead of ints out of this code? Message-ID: Erlang (BEAM) emulator version 5.6 [smp:2] [async-threads:0] Eshell V5.6 (abort with ^G) 1> [A,B|T] = "abcdefg". "abcdefg" 2> A. 97 3> B. 98 4> T. "cdefg" I know _why_ A. and B. print out as ints and why T. prints out as a string of characters, how do I get A and B to print out as characters? -------------- next part -------------- An HTML attachment was scrubbed... URL: From pfisher@REDACTED Wed May 7 20:45:16 2008 From: pfisher@REDACTED (Paul Fisher) Date: Wed, 07 May 2008 13:45:16 -0500 Subject: [erlang-questions] How to get strings instead of ints out of this code? In-Reply-To: References: Message-ID: <1210185916.25763.36.camel@pfisher-laptop> On Wed, 2008-05-07 at 14:33 -0400, Jarrod Roberson wrote: > Erlang (BEAM) emulator version 5.6 [smp:2] [async-threads:0] > > Eshell V5.6 (abort with ^G) > 1> [A,B|T] = "abcdefg". > "abcdefg" > 2> A. > 97 If you mean just in the shell, then: 2> [A]. "a" -- paul From vlm@REDACTED Wed May 7 20:50:44 2008 From: vlm@REDACTED (Lev Walkin) Date: Wed, 07 May 2008 11:50:44 -0700 Subject: [erlang-questions] How to get strings instead of ints out of this code? In-Reply-To: References: Message-ID: <4821FA04.7040206@lionet.info> Jarrod Roberson wrote: > Erlang (BEAM) emulator version 5.6 [smp:2] [async-threads:0] > > Eshell V5.6 (abort with ^G) > 1> [A,B|T] = "abcdefg". > "abcdefg" > 2> A. > 97 > 3> B. > 98 > 4> T. > "cdefg" > > I know _why_ A. and B. print out as ints and why T. prints out as a > string of characters, how do I get A and B to print out as characters? Try [A]. There's no such thing as an individual character in Erlang. Essentially, you have to create a string of 1 character to have it printed as a character (sort of). Alternatively, you could just convert it to atom and print: 1> list_to_atom([98]). b 2> -- Lev Walkin From hariharasudhan.d@REDACTED Wed May 7 21:58:54 2008 From: hariharasudhan.d@REDACTED (Hariharasudhan.D Dhakshinamoorthy) Date: Wed, 7 May 2008 12:58:54 -0700 Subject: [erlang-questions] Help needed on Yaws 1.68 Installation Message-ID: <1ca10cd20805071258w408d3736s2c45a924499b929f@mail.gmail.com> I extracted Yaws 1.68 under c:\work\ardorbytes\showmercy> went into the bash mode and did ./configure && make this is what i get. ---------------------------------------------------------------------------------------------------------------------------------------------- C:\work\ardorbytes\showmercy\yaws-1.68>bash bash-3.2$ ./configure && make checking build system type... i686-pc-cygwin checking host system type... i686-pc-cygwin checking target system type... i686-pc-cygwin checking for erl... /cygdrive/c/work/ardorbytes/erlang/erl5.6.2/bin/erl checking for erlc... /cygdrive/c/work/ardorbytes/erlang/erl5.6.2/bin/erlc checking for gcc... gcc checking for C compiler default output file name... a.exe checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... .exe checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking how to run the C preprocessor... gcc -E checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking whether gcc needs -traditional... no checking whether make sets $(MAKE)... yes checking for a BSD-compatible install... /usr/bin/install -c checking for werl... /cygdrive/c/work/ardorbytes/erlang/erl5.6.2/bin/werl configure: creating ./config.status config.status: creating include.mk make[1]: Entering directory `c:/work/ardorbytes/showmercy/yaws-1.68/c_src' touch ../priv/.foo make[1]: Leaving directory `c:/work/ardorbytes/showmercy/yaws-1.68/c_src' make[1]: Entering directory `c:/work/ardorbytes/showmercy/yaws-1.68/src' . ../vsn.mk; \ sed -e "s/%VSN%/1.68/" -e \ "s;%VARDIR%;/usr/local/var;g" -e \ "s;%ETCDIR%;/usr/local/etc;g" \ < yaws_generated.template > yaws_generated.erl "/cygdrive/c/work/ardorbytes/erlang/erl5.6.2/bin/erlc" -W -pa ../../yaws -o ../ebin yaws.erl c:/work/ARDORB~1/SHOWME~1/yaws-1.68/src/yaws.erl:322: Warning: erlang:fault/1 is deprecated and will be removed in R13B; use erlang:error/1 c:/work/ARDORB~1/SHOWME~1/yaws-1.68/src/yaws.erl:378: Warning: calendar:local_time_to_universal_time/1 is deprecated and will be removed in in a future release; use calendar:local_time_to_universal_time_dst/1 c:/work/ARDORB~1/SHOWME~1/yaws-1.68/src/yaws.erl:384: Warning: calendar:local_time_to_universal_time/1 is deprecated and will be removed in in a future release; use calendar:local_time_to_universal_time_dst/1 c:/work/ARDORB~1/SHOWME~1/yaws-1.68/src/yaws.erl:533: Warning: calendar:local_time_to_universal_time/1 is deprecated and will be removed in in a future release; use calendar:local_time_to_universal_time_dst/1 c:/work/ARDORB~1/SHOWME~1/yaws-1.68/src/yaws.erl:656: Warning: calendar:local_time_to_universal_time/1 is deprecated and will be removed in in a future release; use calendar:local_time_to_universal_time_dst/1 c:/work/ARDORB~1/SHOWME~1/yaws-1.68/src/yaws.erl:1840: Warning: erlang:fault/1 is deprecated and will be removed in R13B; use erlang:error/1 c:/work/ARDORB~1/SHOWME~1/yaws-1.68/src/yaws.erl:1853: Warning: erlang:fault/1 is deprecated and will be removed in R13B; use erlang:error/1 "/cygdrive/c/work/ardorbytes/erlang/erl5.6.2/bin/erlc" -W -pa ../../yaws -o ../ebin yaws_app.erl "/cygdrive/c/work/ardorbytes/erlang/erl5.6.2/bin/erlc" -W -pa ../../yaws -o ../ebin yaws_ticker.erl "/cygdrive/c/work/ardorbytes/erlang/erl5.6.2/bin/erlc" -W -pa ../../yaws -o ../ebin yaws_config.erl c:/work/ARDORB~1/SHOWME~1/yaws-1.68/src/yaws_config.erl:1247: Warning: erlang:fault/1 is deprecated and will be removed in R13B; use erlang:error/1 c:/work/ARDORB~1/SHOWME~1/yaws-1.68/src/yaws_config.erl:1371: Warning: erlang:fault/1 is deprecated and will be removed in R13B; use erlang:error/1 c:/work/ARDORB~1/SHOWME~1/yaws-1.68/src/yaws_config.erl:1502: Warning: erlang:fault/1 is deprecated and will be removed in R13B; use erlang:error/1 "/cygdrive/c/work/ardorbytes/erlang/erl5.6.2/bin/erlc" -W -pa ../../yaws -o ../ebin yaws_server.erl c:/work/ARDORB~1/SHOWME~1/yaws-1.68/src/yaws_server.erl:14: Warning: undefined callback function code_change/3 (behaviour 'gen_server') c:/work/ARDORB~1/SHOWME~1/yaws-1.68/src/yaws_server.erl:70: Warning: variable 'S' is unused c:/work/ARDORB~1/SHOWME~1/yaws-1.68/src/yaws_server.erl:130: Warning: erlang:fault/1 is deprecated and will be removed in R13B; use erlang:error/1 c:/work/ARDORB~1/SHOWME~1/yaws-1.68/src/yaws_server.erl:181: Warning: erlang:fault/1 is deprecated and will be removed in R13B; use erlang:error/1 c:/work/ARDORB~1/SHOWME~1/yaws-1.68/src/yaws_server.erl:187: Warning: erlang:fault/1 is deprecated and will be removed in R13B; use erlang:error/1 c:/work/ARDORB~1/SHOWME~1/yaws-1.68/src/yaws_server.erl:338: Warning: erlang:fault/1 is deprecated and will be removed in R13B; use erlang:error/1 c:/work/ARDORB~1/SHOWME~1/yaws-1.68/src/yaws_server.erl:437: Warning: erlang:fault/1 is deprecated and will be removed in R13B; use erlang:error/1 c:/work/ARDORB~1/SHOWME~1/yaws-1.68/src/yaws_server.erl:514: Warning: erlang:fault/1 is deprecated and will be removed in R13B; use erlang:error/1 c:/work/ARDORB~1/SHOWME~1/yaws-1.68/src/yaws_server.erl:534: Warning: erlang:fault/1 is deprecated and will be removed in R13B; use erlang:error/1 c:/work/ARDORB~1/SHOWME~1/yaws-1.68/src/yaws_server.erl:691: Warning: ssl:accept/2: deprecated; use ssl:transport_accept/1,2 and ssl:ssl_accept/1,2 c:/work/ARDORB~1/SHOWME~1/yaws-1.68/src/yaws_server.erl:2005: Warning: erlang:fault/1 is deprecated and will be removed in R13B; use erlang:error/1 c:/work/ARDORB~1/SHOWME~1/yaws-1.68/src/yaws_server.erl:2447: Warning: erlang:fault/1 is deprecated and will be removed in R13B; use erlang:error/1 "/cygdrive/c/work/ardorbytes/erlang/erl5.6.2/bin/erlc" -W -pa ../../yaws -o ../ebin yaws_sup.erl "/cygdrive/c/work/ardorbytes/erlang/erl5.6.2/bin/erlc" -W -pa ../../yaws -o ../ebin yaws_api.erl c:/work/ARDORB~1/SHOWME~1/yaws-1.68/src/yaws_api.erl:453: Warning: erlang:fault/1 is deprecated and will be removed in R13B; use erlang:error/1 c:/work/ARDORB~1/SHOWME~1/yaws-1.68/src/yaws_api.erl:694: Warning: function find_cookie_val2/2 is unused c:/work/ARDORB~1/SHOWME~1/yaws-1.68/src/yaws_api.erl:710: Warning: function find_cookie_val3/2 is unused c:/work/ARDORB~1/SHOWME~1/yaws-1.68/src/yaws_api.erl:1390: Warning: erlang:fault/1 is deprecated and will be removed in R13B; use erlang:error/1 c:/work/ARDORB~1/SHOWME~1/yaws-1.68/src/yaws_api.erl:1404: Warning: erlang:fault/1 is deprecated and will be removed in R13B; use erlang:error/1 c:/work/ARDORB~1/SHOWME~1/yaws-1.68/src/yaws_api.erl:1663: Warning: erlang:fault/1 is deprecated and will be removed in R13B; use erlang:error/1 c:/work/ARDORB~1/SHOWME~1/yaws-1.68/src/yaws_api.erl:1667: Warning: function binding_exists/1 is unused "/cygdrive/c/work/ardorbytes/erlang/erl5.6.2/bin/erlc" -W -pa ../../yaws -o ../ebin yaws_log.erl c:/work/ARDORB~1/SHOWME~1/yaws-1.68/src/yaws_log.erl:16: Warning: undefined callback function code_change/3 (behaviour 'gen_server') "/cygdrive/c/work/ardorbytes/erlang/erl5.6.2/bin/erlc" -W -pa ../../yaws -o ../ebin yaws_ls.erl "/cygdrive/c/work/ardorbytes/erlang/erl5.6.2/bin/erlc" -W -pa ../../yaws -o ../ebin yaws_debug.erl c:/work/ARDORB~1/SHOWME~1/yaws-1.68/src/yaws_debug.erl:26: Warning: erlang:fault/1 is deprecated and will be removed in R13B; use erlang:error/1 c:/work/ARDORB~1/SHOWME~1/yaws-1.68/src/yaws_debug.erl:112: Warning: erlang:fault/1 is deprecated and will be removed in R13B; use erlang:error/1 c:/work/ARDORB~1/SHOWME~1/yaws-1.68/src/yaws_debug.erl:288: Warning: erlang:fault/1 is deprecated and will be removed in R13B; use erlang:error/1 "/cygdrive/c/work/ardorbytes/erlang/erl5.6.2/bin/erlc" -W -pa ../../yaws -o ../ebin yaws_compile.erl "/cygdrive/c/work/ardorbytes/erlang/erl5.6.2/bin/erlc" -W -pa ../../yaws -o ../ebin yaws_ctl.erl c:/work/ARDORB~1/SHOWME~1/yaws-1.68/src/yaws_ctl.erl:33: Warning: erlang:fault/1 is deprecated and will be removed in R13B; use erlang:error/1 "/cygdrive/c/work/ardorbytes/erlang/erl5.6.2/bin/erlc" -W -pa ../../yaws -o ../ebin yaws_cgi.erl "/cygdrive/c/work/ardorbytes/erlang/erl5.6.2/bin/erlc" -W -pa ../../yaws -o ../ebin yaws_zlib.erl "/cygdrive/c/work/ardorbytes/erlang/erl5.6.2/bin/erlc" -W -pa ../../yaws -o ../ebin yaws_generated.erl "/cygdrive/c/work/ardorbytes/erlang/erl5.6.2/bin/erlc" -W -pa ../../yaws -o ../ebin mime_type_c.erl if [ ! -z "" ]; then \ echo > charset.def; \ else rm charset.def 2> /dev/null; touch charset.def; fi /cygdrive/c/work/ardorbytes/erlang/erl5.6.2/bin/erl -noshell -pa ../ebin -s mime_type_c compile process_begin: CreateProcess(NULL, /cygdrive/c/work/ardorbytes/erlang/erl5.6.2/bin/erl -noshell -pa ../ebin -s mime_type_c compile, ...) failed. make (e=3): The system cannot find the path specified. make[1]: *** [mime_types.erl] Error 3 make[1]: Leaving directory `c:/work/ardorbytes/showmercy/yaws-1.68/src' make: *** [all] Error 1 bash-3.2$ ------------------------------------------------------------------------------------------------------------------------------------------------ I am not able to understand the error which path does it not able to find , please help me out. As everybody mentioned , windows installer is very much needed :-) Regards, Hariharasudhan.D -------------- next part -------------- An HTML attachment was scrubbed... URL: From rpettit@REDACTED Wed May 7 22:01:36 2008 From: rpettit@REDACTED (Rick Pettit) Date: Wed, 7 May 2008 15:01:36 -0500 (CDT) Subject: [erlang-questions] few questions: common sense is not so common In-Reply-To: <1218d6a50805070851p2c204831tf6724fea719039c5@mail.gmail.com> References: <1218d6a50805070851p2c204831tf6724fea719039c5@mail.gmail.com> Message-ID: <49851.192.168.34.20.1210190496.squirrel@squirrelmail.vail> On Wed, May 7, 2008 10:51 am, db wrote: > Hi, > > I have few questions that need be cleared up. Here they are: > > q1) How come there isn't a way to empty the gen_server mailbox? I > have seen only pattern matching for desired messages. Take a closer look at gen_server:handle_info/2 documentation. -Rick From gleber.p@REDACTED Wed May 7 22:20:42 2008 From: gleber.p@REDACTED (Gleb Peregud) Date: Wed, 7 May 2008 22:20:42 +0200 Subject: [erlang-questions] few questions: common sense is not so common In-Reply-To: <1218d6a50805070851p2c204831tf6724fea719039c5@mail.gmail.com> References: <1218d6a50805070851p2c204831tf6724fea719039c5@mail.gmail.com> Message-ID: <14f0e3620805071320g120309a5w77b27828db49ca5e@mail.gmail.com> On 5/7/08, db wrote: > Hi, > > I have few questions that need be cleared up. Here they are: > > q1) How come there isn't a way to empty the gen_server mailbox? I > have seen only pattern matching for desired messages. > > q2) I need a way to provide a wrapper around a another gen_server > module, what is the recommended approach? (Start the both gen_servers > and use wrapper as a proxy messenger to the other gen_server). > > q3) Do you advice using sequential receives? (I have a process that > does the gathering. It waits for so certain # of processes to send > reduced results and then forwards the final gathered result to another > process. Gather process then loops over for another set of new > receive). > > q4) Sending large list of tuple as messages, 1000 elements, between > processes on remote nodes be a wise approach? > > > Thank you, > -- > 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 > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > q4) and q5) looks like one i had while implementing distributed decision trees construction algorithm. Is your task similar to this one? btw, is anyone interested in distributed decision trees construction algorithm written in Erlang? I've written it as one of the projects at the University. Frankly speaking it is not efficient (~10% speedup with 2 computers instead of 1), but probably it may be improved quite easily :) Documentation is included. -- Gleb Peregud http://gleber.pl/ Every minute is to be grasped. Time waits for nobody. -- Inscription on a Zen Gong From per@REDACTED Wed May 7 22:59:31 2008 From: per@REDACTED (Per Hedeland) Date: Wed, 7 May 2008 22:59:31 +0200 (CEST) Subject: [erlang-questions] How to get strings instead of ints out of this code? In-Reply-To: <4821FA04.7040206@lionet.info> Message-ID: <200805072059.m47KxVJt058229@pluto.hedeland.org> Lev Walkin wrote: > >Jarrod Roberson wrote: >> Erlang (BEAM) emulator version 5.6 [smp:2] [async-threads:0] >> >> Eshell V5.6 (abort with ^G) >> 1> [A,B|T] = "abcdefg". >> "abcdefg" >> 2> A. >> 97 >> 3> B. >> 98 >> 4> T. >> "cdefg" >> >> I know _why_ A. and B. print out as ints and why T. prints out as a >> string of characters, how do I get A and B to print out as characters? > >Try [A]. There's no such thing as an individual character in Erlang. Yes there is, just as much as there is in, say, C... A character is just an integer, you have to interpret it as a character code if that is what you want. If you want to print some data in Erlang, you use one of the io(3) functions, typically format/2 (or /3), and in doing so you get to specify how that data is to be interpreted. The shell is no different - some people seem to think that the output the shell generates is somehow the "true value" of the expression that was evaluated, but it's just using the ~p "control sequence", which tries to "detect strings" but otherwise just prints the value "prettily" in standard syntax: 1> A=$a. 97 2> io:format("~p~n", [A]). 97 ok So, if you give ~p an integer, it prints it as an integer. If you want to print a character, the control sequence to use is ~c: 3> io:format("~c~n", [A]). a ok --Per Hedeland From bernied@REDACTED Thu May 8 00:04:17 2008 From: bernied@REDACTED (Bernhard Damberger) Date: Wed, 7 May 2008 15:04:17 -0700 (PDT) Subject: [erlang-questions] yaws.hyber.org down? Message-ID: <17114807.post@talk.nabble.com> I was trying to get to http://yaws.hyber.org for the last couple of days and I can't seem to get through. Is it down for anyone else? $ curl http://yaws.hyber.org curl: (7) couldn't connect to host $ ping yaws.hyber.org PING yaws.hyber.org (195.198.247.81): 56 data bytes 64 bytes from 195.198.247.81: icmp_seq=0 ttl=54 time=204.481 ms 64 bytes from 195.198.247.81: icmp_seq=1 ttl=54 time=202.782 ms ... Is anyone else having trouble reaching the yaws server? _bernhard -- View this message in context: http://www.nabble.com/yaws.hyber.org-down--tp17114807p17114807.html Sent from the Erlang Questions mailing list archive at Nabble.com. From discipleofranok@REDACTED Thu May 8 00:40:54 2008 From: discipleofranok@REDACTED (Jacob Torrey) Date: Wed, 07 May 2008 18:40:54 -0400 Subject: [erlang-questions] yaws.hyber.org down? In-Reply-To: <17114807.post@talk.nabble.com> References: <17114807.post@talk.nabble.com> Message-ID: <48222FF6.6010402@gmail.com> I can't reach it either Bernhard Damberger wrote: > I was trying to get to http://yaws.hyber.org for the last couple of days and > I can't seem to get through. Is it down for anyone else? > > $ curl http://yaws.hyber.org > curl: (7) couldn't connect to host > $ ping yaws.hyber.org > PING yaws.hyber.org (195.198.247.81): 56 data bytes > 64 bytes from 195.198.247.81: icmp_seq=0 ttl=54 time=204.481 ms > 64 bytes from 195.198.247.81: icmp_seq=1 ttl=54 time=202.782 ms > ... > > Is anyone else having trouble reaching the yaws server? > > _bernhard From cyberlync@REDACTED Thu May 8 01:48:09 2008 From: cyberlync@REDACTED (Eric Merritt) Date: Wed, 7 May 2008 23:48:09 +0000 Subject: [erlang-questions] Dialyzer and multiple plt files Message-ID: Guys (probably Tobias ;) Is there a way to get Dialyzer to use multiple plt files for its analysis. Let me give you the background. Sinan uses dialyzer for its analysis task. During its first run in a project it generates a new plt file for that projects dependencies and stores it in the build area. Depending on the project that can take a huge amount of time. I think a nice way to solve this problem is to generate plt files for an OTP app and distribute those files with that app. Then in my analysis phase I just have to identify the plt files stored in the dependencies and let Dialyzer make use of them. I don't believe this is possible at the moment and it may be that I am the only one with this type of requirement, but it would be a nice feature to have. Thanks, Eric From per.melin@REDACTED Thu May 8 02:47:37 2008 From: per.melin@REDACTED (Per Melin) Date: Thu, 8 May 2008 02:47:37 +0200 Subject: [erlang-questions] erlang:phash2(make_ref(), 1 bsl 32) Message-ID: I thought that would be the easiest way to generate an integer unique enough for my needs. But it seems to always repeat in 2^18 (262144) iterations. That is because #Ref<_._.X.Y> gives the same phash2 as #Ref<_._.X+1.Y> in any range between 2^20 and 2^32. Isn't that a little unfortunate? -------------- next part -------------- An HTML attachment was scrubbed... URL: From masterofquestions@REDACTED Thu May 8 03:37:34 2008 From: masterofquestions@REDACTED (db) Date: Wed, 7 May 2008 21:37:34 -0400 Subject: [erlang-questions] few questions: common sense is not so common In-Reply-To: <14f0e3620805071320g120309a5w77b27828db49ca5e@mail.gmail.com> References: <1218d6a50805070851p2c204831tf6724fea719039c5@mail.gmail.com> <14f0e3620805071320g120309a5w77b27828db49ca5e@mail.gmail.com> Message-ID: <1218d6a50805071837lf824401q4c1f120198a432a5@mail.gmail.com> Do you have a link where I can download erlang version of distributed decision support tree? I don't feel like reinventing the wheel. On Wed, May 7, 2008 at 4:20 PM, Gleb Peregud wrote: > > q4) and q5) looks like one i had while implementing distributed > decision trees construction algorithm. Is your task similar to this > one? > > btw, is anyone interested in distributed decision trees construction > algorithm written in Erlang? I've written it as one of the projects at > the University. Frankly speaking it is not efficient (~10% speedup > with 2 computers instead of 1), but probably it may be improved quite > easily :) Documentation is included. > > -- > Gleb Peregud > http://gleber.pl/ > > Every minute is to be grasped. > Time waits for nobody. > -- Inscription on a Zen Gong > Thank you, -- 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 From matthew@REDACTED Thu May 8 04:28:41 2008 From: matthew@REDACTED (Matthew Dempsky) Date: Wed, 7 May 2008 19:28:41 -0700 Subject: [erlang-questions] [erlang-bugs] Weird pg2 behavior In-Reply-To: References: <18431.9227.133848.989614@gargle.gargle.HOWL> <18435.1529.209488.50485@gargle.gargle.HOWL> <18437.48350.271334.980195@gargle.gargle.HOWL> Message-ID: Has there been any progress on this? This bug bit us again today. :-( (A pid from a node on a machine that had been decommissioned and not running any Erlang code for months now but still present on our network was still lurking in one of our pg2 groups. Yesterday we finally repurposed this machine, removing it from our network, which had the unexpected side effect of causing Pid ! Msg in some heavily used code to start adding several seconds of delay due to the runtime attempting to autoconnect to that long-dead node.) On Fri, Apr 18, 2008 at 1:23 AM, Matthew Dempsky wrote: > On Wed, Apr 16, 2008 at 1:46 AM, Hans Bolinder > > wrote: > > > I think pg2 should monitor all pids rather than link to local pids > > only. Carefully setting up monitors, like Global does since R11B-4, > > should work. > > Sounds good to me. Can we hope to see this in R12B-3? :-) > From masterofquestions@REDACTED Thu May 8 04:44:50 2008 From: masterofquestions@REDACTED (db) Date: Wed, 7 May 2008 22:44:50 -0400 Subject: [erlang-questions] Link for Erlang Code Replacement Pdf by Peter H|gfeldt is inaccessible Message-ID: <1218d6a50805071944t36e5c5f3h265692f77623c99f@mail.gmail.com> I am trying get my hands on hot code loading pdf files written by Peter H|gfeldt. The links for it are not working. I have tried the following links and both links don't work at all: www.erlang.org/doc/misc http://www.erlang.org/pipermail/erlang-questions/2003-May/008831.html Is there a new link to these pdf files that I am not aware of? Thank you, -- 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 From masterofquestions@REDACTED Thu May 8 05:01:17 2008 From: masterofquestions@REDACTED (db) Date: Wed, 7 May 2008 23:01:17 -0400 Subject: [erlang-questions] Health check up on erlang nodes & nagios plugin Message-ID: <1218d6a50805072001q32132a7cge0ed82025c265a5@mail.gmail.com> Is there a way to determine what processes are consuming how much resources/load on each erlang nodes? Has anyone hacked up a nagios plugin to work with erlang nodes? -- 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 From exta7@REDACTED Thu May 8 05:33:15 2008 From: exta7@REDACTED (Zvi) Date: Wed, 7 May 2008 20:33:15 -0700 (PDT) Subject: [erlang-questions] Location options in file:pread/2 and /3 In-Reply-To: References: <16834826.post@talk.nabble.com> Message-ID: <17117871.post@talk.nabble.com> Bjorn, yes I was opening file in raw mode. BR, Zvi Bjorn Gustavsson wrote: > > Zvi writes: > >> Are all these options are still supported in file:pread/2 and >> file:pread/3 ? >> >From my tests, only file:position accepts them. file:pread/2 and /3 only >> accepts Offset and giving {error,badarg} for the rest. > > They are accepted if the file has not been opened in raw mode. > There is a note about that in the documentation for pread/3: > > "If IoDevice has been opened in raw mode, some restrictions apply: > Location is only allowed to be an integer; and the current position of the > file is undefined after the operation." > > /Bjorn > -- > Bj?rn Gustavsson, Erlang/OTP, Ericsson AB > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > -- View this message in context: http://www.nabble.com/Location-options-in-file%3Apread-2-and--3-tp16834826p17117871.html Sent from the Erlang Questions mailing list archive at Nabble.com. From billrobertson42@REDACTED Thu May 8 04:52:25 2008 From: billrobertson42@REDACTED (Bill Robertson) Date: Wed, 7 May 2008 19:52:25 -0700 (PDT) Subject: [erlang-questions] More Mnesia Questions Message-ID: <584089.72503.qm@web51903.mail.re2.yahoo.com> Thanks to all for the help on creating tables. I like the {atomic, ok} = mnesia:create_table() badmatch idiom, and I have rewritten other parts of the code I'm working on to take advantage of that. I have a couple more questions though. (always...) If any of them are already answered in documentation, please point me to what I obviously missed. 1. I think the answer is no, but is it possible to define a constraint in mnesia? for example a foreign key constraint? Maybe you could define a fun() and pass that to mnesia for it to store for a table and mnesia would check the return value of that fun before allowing the modification to the table occur? I see some notion of events in the ref manual (http://www.erlang.org/doc/man/mnesia.html). Would it be possible to roll that into mnesia myself? 2. I want to track the selection frequency of terms, and then frequently retrieve the N most popular terms. In a relational database, I would just create an index in descending order and use an appropriate order by clause. I don't see any options to do that with an mnesia index though. Would qlc be smart enough to figure it out walk the index backwards? How would you even do that in qlc? 3. If I want "building block" functions to do primitive operations in mnesia, I think it would be necessary to have these functions return funs, and then collect all of the funs in a larger fun that would define larger behaviors and then execute the entire thing in a single call to transaction. Is there a way to start a transactions, call arbitrary mnesia functions, and then either commit or rollback the transaction? It does not appear this would work from what I see in the api. 4. Is it possible for mnesia to have a disk table that only has a subset of its contents in memory? (without work on my part of course) --- And, in the event that I decide I'm spending too much time spinning my wheels... I hear there is a native erlang mysql driver. Where is it? Is it the project on google code? (http://code.google.com/p/erlang-mysql-driver/) Is there a shred of documentation for it? Thanks again ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ From dnew@REDACTED Thu May 8 05:56:40 2008 From: dnew@REDACTED (Darren New) Date: Wed, 07 May 2008 20:56:40 -0700 Subject: [erlang-questions] erlang:phash2(make_ref(), 1 bsl 32) In-Reply-To: References: Message-ID: <482279F8.5060309@san.rr.com> Per Melin wrote: > Isn't that a little unfortunate? I'm no expert, but my understanding is that make_ref() doesn't make a particularly unique reference. It wouldn't serve well as (say) a primary key in a long-term database, unlike (say) a microsoft-style GUID. Am I right in this? I was thinking about this and came to the conclusion that either {node(),now()} or {make_ref(),now()} would be unique enough to hash into a long-term unique value. -- Darren New / San Diego, CA, USA (PST) "That's pretty. Where's that?" "It's the Age of Channelwood." "We should go there on vacation some time." From bob@REDACTED Thu May 8 06:25:42 2008 From: bob@REDACTED (Bob Ippolito) Date: Wed, 7 May 2008 21:25:42 -0700 Subject: [erlang-questions] erlang:phash2(make_ref(), 1 bsl 32) In-Reply-To: References: Message-ID: <6a36e7290805072125u4258465ei6aef7c7e2cd62901@mail.gmail.com> 2008/5/7 Per Melin : > I thought that would be the easiest way to generate an integer unique enough > for my needs. But it seems to always repeat in 2^18 (262144) iterations. > > That is because #Ref<_._.X.Y> gives the same phash2 as #Ref<_._.X+1.Y> in > any range between 2^20 and 2^32. > > Isn't that a little unfortunate? You could always just use a random number... crypto:rand_uniform(0, 1 bsl 32). -bob From tty.erlang@REDACTED Thu May 8 06:49:28 2008 From: tty.erlang@REDACTED (t ty) Date: Thu, 8 May 2008 00:49:28 -0400 Subject: [erlang-questions] Health check up on erlang nodes & nagios plugin In-Reply-To: <1218d6a50805072001q32132a7cge0ed82025c265a5@mail.gmail.com> References: <1218d6a50805072001q32132a7cge0ed82025c265a5@mail.gmail.com> Message-ID: <290b3ba10805072149u7ca92395o3661cee4121f162a@mail.gmail.com> Never hacked nagios plugin to work with erlang nodes. However nagios plugins are just scripts/programs that conform to printing/returning certain strings. I would look at 'escript' or 'erl -noshell' for your problem. t On Wed, May 7, 2008 at 11:01 PM, db wrote: > Is there a way to determine what processes are consuming how much > resources/load on each erlang nodes? Has anyone hacked up a nagios > plugin to work with erlang nodes? > > -- > 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 > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From jeffm@REDACTED Thu May 8 06:56:45 2008 From: jeffm@REDACTED (jm) Date: Thu, 08 May 2008 14:56:45 +1000 Subject: [erlang-questions] Health check up on erlang nodes & nagios plugin In-Reply-To: <290b3ba10805072149u7ca92395o3661cee4121f162a@mail.gmail.com> References: <1218d6a50805072001q32132a7cge0ed82025c265a5@mail.gmail.com> <290b3ba10805072149u7ca92395o3661cee4121f162a@mail.gmail.com> Message-ID: <4822880D.60303@ghostgun.com> This is a "hit and run" suggestion as I haven't been following along. Have you taken a look at http://easyerl.blogspot.com/2007/11/nagios-beurk-nrpe-support-for-erlang.html Jeff. t ty wrote: > Never hacked nagios plugin to work with erlang nodes. However nagios > plugins are just scripts/programs that conform to printing/returning > certain strings. I would look at 'escript' or 'erl -noshell' for your > problem. > > t > > On Wed, May 7, 2008 at 11:01 PM, db wrote: > >> Is there a way to determine what processes are consuming how much >> resources/load on each erlang nodes? Has anyone hacked up a nagios >> plugin to work with erlang nodes? >> >> -- >> 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 >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> >> > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From kostis@REDACTED Thu May 8 07:48:43 2008 From: kostis@REDACTED (Kostis Sagonas) Date: Thu, 08 May 2008 08:48:43 +0300 Subject: [erlang-questions] Dialyzer and multiple plt files In-Reply-To: References: Message-ID: <4822943B.9080505@cs.ntua.gr> Eric Merritt wrote: > Guys (probably Tobias ;) > > Is there a way to get Dialyzer to use multiple plt files for its > analysis. Let me give you the background. Sinan uses dialyzer for its > analysis task. During its first run in a project it generates a new > plt file for that projects dependencies and stores it in the build > area. Depending on the project that can take a huge amount of time. I > think a nice way to solve this problem is to generate plt files for an > OTP app and distribute those files with that app. Then in my analysis > phase I just have to identify the plt files stored in the dependencies > and let Dialyzer make use of them. I don't believe this is possible at > the moment and it may be that I am the only one with this type of > requirement, but it would be a nice feature to have. The feature you want is a nice thing to have but realizing it properly is quite complicated. The reason is that good PLTs cannot be built in isolation: dependencies between applications have to be taken into account and these dependencies are often circular -- Erlang does not enforce an hierarchical module system as e.g. ML does. Also, for a sound analysis, these dependencies have to be checked every time a PLT is used. We have been discussing this issue for quite a while now and recently (10 days ago) decided to change the way PLTs are built and used so that it is possible to merge two (or more) PLTs. This will achieve something very similar to what you want: you will be able to build PLTs on a per application basis, but these PLTs will not be coming pre-built in the OTP system. Interested users will need to build them themselves. Hopefully, this change will make it into R12B-3. Stay tuned, Kostis From cyberlync@REDACTED Thu May 8 08:29:06 2008 From: cyberlync@REDACTED (Eric Merritt) Date: Wed, 7 May 2008 23:29:06 -0700 Subject: [erlang-questions] Dialyzer and multiple plt files In-Reply-To: <4822943B.9080505@cs.ntua.gr> References: <4822943B.9080505@cs.ntua.gr> Message-ID: Kostis, Thanks for the update. I look forward to the change. This will allow me to add this feature to sinan built, faxien distributed apps. It should make for a pretty interesting new feature! Thanks, Eric On Wed, May 7, 2008 at 10:48 PM, Kostis Sagonas wrote: > > Eric Merritt wrote: > > > Guys (probably Tobias ;) > > > > Is there a way to get Dialyzer to use multiple plt files for its > > analysis. Let me give you the background. Sinan uses dialyzer for its > > analysis task. During its first run in a project it generates a new > > plt file for that projects dependencies and stores it in the build > > area. Depending on the project that can take a huge amount of time. I > > think a nice way to solve this problem is to generate plt files for an > > OTP app and distribute those files with that app. Then in my analysis > > phase I just have to identify the plt files stored in the dependencies > > and let Dialyzer make use of them. I don't believe this is possible at > > the moment and it may be that I am the only one with this type of > > requirement, but it would be a nice feature to have. > > > > The feature you want is a nice thing to have but realizing it properly is > quite complicated. The reason is that good PLTs cannot be built in > isolation: dependencies between applications have to be taken into account > and these dependencies are often circular -- Erlang does not enforce an > hierarchical module system as e.g. ML does. Also, for a sound analysis, > these dependencies have to be checked every time a PLT is used. > > We have been discussing this issue for quite a while now and recently (10 > days ago) decided to change the way PLTs are built and used so that it is > possible to merge two (or more) PLTs. This will achieve something very > similar to what you want: you will be able to build PLTs on a per > application basis, but these PLTs will not be coming pre-built in the OTP > system. Interested users will need to build them themselves. Hopefully, > this change will make it into R12B-3. > > Stay tuned, > > Kostis > From kenneth.lundin@REDACTED Thu May 8 08:43:58 2008 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Thu, 8 May 2008 08:43:58 +0200 Subject: [erlang-questions] Link for Erlang Code Replacement Pdf by Peter H|gfeldt is inaccessible In-Reply-To: <1218d6a50805071944t36e5c5f3h265692f77623c99f@mail.gmail.com> References: <1218d6a50805071944t36e5c5f3h265692f77623c99f@mail.gmail.com> Message-ID: Hi, What about OTP Design Principles Chapter 12 http://www.erlang.org/doc/design_principles/part_frame.html This might be what you are looking for. /Kenneth Erlang/OTP, Ericsson On 5/8/08, db wrote: > I am trying get my hands on hot code loading pdf files written by > Peter H|gfeldt. The links for it are not working. > > I have tried the following links and both links don't work at all: > www.erlang.org/doc/misc > http://www.erlang.org/pipermail/erlang-questions/2003-May/008831.html > > Is there a new link to these pdf files that I am not aware of? > > Thank you, > -- > 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 > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From rpettit@REDACTED Thu May 8 08:44:25 2008 From: rpettit@REDACTED (Rick Pettit) Date: Thu, 8 May 2008 01:44:25 -0500 (CDT) Subject: [erlang-questions] [erlang-bugs] Weird pg2 behavior In-Reply-To: References: <18431.9227.133848.989614@gargle.gargle.HOWL> <18435.1529.209488.50485@gargle.gargle.HOWL> <18437.48350.271334.980195@gargle.gargle.HOWL> Message-ID: <51899.192.168.34.20.1210229065.squirrel@squirrelmail.vail> On Wed, May 7, 2008 9:28 pm, Matthew Dempsky wrote: > Has there been any progress on this? This bug bit us again today. :-( > > (A pid from a node on a machine that had been decommissioned and not > running any Erlang code for months now but still present on our > network was still lurking in one of our pg2 groups. Yesterday we > finally repurposed this machine, removing it from our network, which > had the unexpected side effect of causing Pid ! Msg in some heavily > used code to start adding several seconds of delay due to the runtime > attempting to autoconnect to that long-dead node.) Is there a complete list of currently known pg2 bugs published someplace (besides this email thread), perhaps with suggested work arounds until a new pg2 can be released? In my case hot loading of all modules which contain client code performing pg2 lookups is an option, so I have a chance to avoid disaster (as described by Matthew above) if I act fast :-) -Rick > On Fri, Apr 18, 2008 at 1:23 AM, Matthew Dempsky > wrote: >> On Wed, Apr 16, 2008 at 1:46 AM, Hans Bolinder >> >> wrote: >> >> > I think pg2 should monitor all pids rather than link to local pids >> > only. Carefully setting up monitors, like Global does since R11B-4, >> > should work. >> >> Sounds good to me. Can we hope to see this in R12B-3? :-) >> > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From cyberlync@REDACTED Thu May 8 09:06:41 2008 From: cyberlync@REDACTED (Eric Merritt) Date: Thu, 8 May 2008 00:06:41 -0700 Subject: [erlang-questions] Dialyzer programmatic interface and output_plt In-Reply-To: References: <48201848.3070205@it.uu.se> Message-ID: > > > > > > > For me the option {output_plt, File} works. I tested it with the released > > sytem (R12B-2) and it seems to work there too. Is there a small test case > > that you can send me? > > I will see if I can put together a simple test case for you. At the > very least I can verify that its not my issue. > > So I have confirmed that with the following options no actual plt file is generated though the generation runs without fault. If I use a simpler set of options a plt file does result. I am not sure what the difference is. It does take over an hour to run on this though. (replace and with real directories, of course). Opts = [{files_rec,["/repo/ktuo-0.4.0.1/ebin", "/repo/ewrepo-0.16.6.0/ebin", "/repo/ibrowse-1.4/ebin", "/repo/ewlib-0.7.4.0/ebin", "/repo/eunit-2.0/ebin", "/repo/sgte-0.7.1/ebin", "/repo/mnesia-4.4.2/ebin", "/repo/xmerl-1.1.8/ebin", "/repo/dialyzer-1.8.0/ebin", "/repo/gs-1.5.9/ebin", "/repo/hipe-3.6.6/ebin", "/repo/tools-2.6.1/ebin", "/repo/edoc-0.7.5/ebin", "/repo/compiler-4.5.2/ebin", "/repo/syntax_tools-1.5.4/ebin", "/repo/crary-0.2.0/ebin", "/repo/sasl-2.1.5.2/ebin", "/repo/uri-0.1.0/ebin", "/repo/kernel-2.12.2/ebin", "/repo/stdlib-1.15.2/ebin"]}, {from,byte_code}, {output_plt,"/_build/development/info/dialyzer_plt"}], dialyzer:run(Opts). However, If i do something trivial like Opts = [{files_rec,["/repo/ktuo-0.4.0.1/ebin"]}, {from,byte_code}, {output_plt,"/_build/development/info/dialyzer_plt"}], dialyzer:run(Opts). A plt file is output as expected. I have started going through and trying to see when dialyzer falls over but its slow enough that its going to take me awhile. From raimo+erlang-questions@REDACTED Thu May 8 09:56:57 2008 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Thu, 8 May 2008 09:56:57 +0200 Subject: [erlang-questions] Link for Erlang Code Replacement Pdf by Peter H|gfeldt is inaccessible In-Reply-To: <1218d6a50805071944t36e5c5f3h265692f77623c99f@mail.gmail.com> References: <1218d6a50805071944t36e5c5f3h265692f77623c99f@mail.gmail.com> Message-ID: <20080508075656.GA6542@erix.ericsson.se> On Wed, May 07, 2008 at 10:44:50PM -0400, db wrote: > I am trying get my hands on hot code loading pdf files written by > Peter H|gfeldt. The links for it are not working. > > I have tried the following links and both links don't work at all: > www.erlang.org/doc/misc > http://www.erlang.org/pipermail/erlang-questions/2003-May/008831.html > > Is there a new link to these pdf files that I am not aware of? We changed the /doc tree to contain the current documentation and simplified the generation of it. The misc subdirectory got lost in the move. I found the old version at: http://www.erlang.org/doc.OLD/misc/ but we have not decided what to do with it yet. > > Thank you, > -- > 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 > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From tumanian@REDACTED Thu May 8 10:42:10 2008 From: tumanian@REDACTED (Gurgen Tumanian) Date: Thu, 8 May 2008 13:42:10 +0500 Subject: [erlang-questions] Strange arithmetic behaviour Message-ID: <85d11a2e0805080142x2b9d9615mbe8a6dd7e1b4aa87@mail.gmail.com> Dear all. There is some kind of strange behaviour that i have noticed when dealing with big float values. For example: 123123123123123123123.0 - 123123123123123123121.0 is 0.00000e+0 when i expect 2.0 or something like that in e notation. I found this kind of errors with round() and trunc(). for example: trunc(1233333333333333123333333333.12311111111) is 1233333333333333065680814080. or round(1233333333333333123333333333.12311111111) is 1233333333333333065680814080. furthermore 1233333333333333123333333333.12311111111 = 123333333333333312367575676573.92311111111 matches I have tested this on R11-B5 and on R12-B1 Is this a big nasty bug, or am i missing something? Regards Gurgen Tumanyan Smart Tech -------------- next part -------------- An HTML attachment was scrubbed... URL: From francesco@REDACTED Thu May 8 10:50:40 2008 From: francesco@REDACTED (Francesco Cesarini) Date: Thu, 08 May 2008 09:50:40 +0100 Subject: [erlang-questions] planet.trapexit.org down? In-Reply-To: References: Message-ID: <4822BEE0.8000400@erlang-consulting.com> We've had reoccurring hard disk problems on the machine running trapexit. The site has been going up and down (or grinding to a halt) like you would never believe. The increase in traffic at times cripples the machine (Intensive SQL queries).. We will be moving everything in about two months to better (and hopefully more stable) hardware while giving the site an overhaul and implementing a bunch of new ideas we have. Until then, chase us if you do see errors or outages. We do our best, but are so busy at times that extra help is always welcome. Francesco -- http://www.erlang-consulting.com Peter Lemenkov wrote: > Hello All! > Seems that nobody takes care of this rss-aggregation - its latest > update was about than two weeks ago. > > Another one issue is that it produces wrong xml-page (it can't be > loaded into my Firefox). > > Maybe someone could ping guys behind trapexit.org? > > From gleber.p@REDACTED Thu May 8 11:20:10 2008 From: gleber.p@REDACTED (Gleb Peregud) Date: Thu, 8 May 2008 11:20:10 +0200 Subject: [erlang-questions] Strange arithmetic behaviour In-Reply-To: <85d11a2e0805080142x2b9d9615mbe8a6dd7e1b4aa87@mail.gmail.com> References: <85d11a2e0805080142x2b9d9615mbe8a6dd7e1b4aa87@mail.gmail.com> Message-ID: <14f0e3620805080220i67dc9a2ckcc8ab03568639a00@mail.gmail.com> These are results from Python interactive shell: >>> 123123123123123123123.0 - 123123123123123123121.0 0.0 >>> print '%f' % math.floor(1233333333333333123333333333.12311111111); 1233333333333333065680814080.000000 >>> print '%f' % 1233333333333333123333333333.12311111111 1233333333333333065680814080.000000 As you can see results are the same. I think it is because of internal IEEE-something floating point number representation. As you can see in the last example, number "1233333333333333123333333333.12311111111" is converted to "1233333333333333065680814080.000000" without applying to it any operations. Probably it is because internal float representation does not allow this precision in this particular situation On 5/8/08, Gurgen Tumanian wrote: > Dear all. > > There is some kind of strange behaviour that i have noticed when dealing > with big float values. > For example: > > 123123123123123123123.0 - 123123123123123123121.0 is 0.00000e+0 when i > expect 2.0 or something like that in e notation. > I found this kind of errors with round() and trunc(). for example: > trunc(1233333333333333123333333333.12311111111) is > 1233333333333333065680814080. > or > round(1233333333333333123333333333.12311111111) is > 1233333333333333065680814080. > > furthermore > 1233333333333333123333333333.12311111111 = > 123333333333333312367575676573.92311111111 matches > > > I have tested this on R11-B5 and on R12-B1 > > Is this a big nasty bug, or am i missing something? > > Regards > Gurgen Tumanyan > Smart Tech > -- Gleb Peregud http://gleber.pl/ Every minute is to be grasped. Time waits for nobody. -- Inscription on a Zen Gong From gleber.p@REDACTED Thu May 8 11:23:37 2008 From: gleber.p@REDACTED (Gleb Peregud) Date: Thu, 8 May 2008 11:23:37 +0200 Subject: [erlang-questions] few questions: common sense is not so common In-Reply-To: <1218d6a50805071837lf824401q4c1f120198a432a5@mail.gmail.com> References: <1218d6a50805070851p2c204831tf6724fea719039c5@mail.gmail.com> <14f0e3620805071320g120309a5w77b27828db49ca5e@mail.gmail.com> <1218d6a50805071837lf824401q4c1f120198a432a5@mail.gmail.com> Message-ID: <14f0e3620805080223i3b3e64b6t969142063fd6c7b0@mail.gmail.com> On 5/8/08, db wrote: > Do you have a link where I can download erlang version of distributed > decision support tree? I don't feel like reinventing the wheel. > > On Wed, May 7, 2008 at 4:20 PM, Gleb Peregud wrote: >> >> q4) and q5) looks like one i had while implementing distributed >> decision trees construction algorithm. Is your task similar to this >> one? >> >> btw, is anyone interested in distributed decision trees construction >> algorithm written in Erlang? I've written it as one of the projects at >> the University. Frankly speaking it is not efficient (~10% speedup >> with 2 computers instead of 1), but probably it may be improved quite >> easily :) Documentation is included. >> >> -- >> Gleb Peregud >> http://gleber.pl/ >> >> Every minute is to be grasped. >> Time waits for nobody. >> -- Inscription on a Zen Gong >> > > Thank you, > -- > 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 > Because few people showed interest in it, i'll publish it on Google Code asap (unfortunately time is against me). But i have to warn you: It is not written as an OTP application. It is one of the first Erlang programs written by me, hence there are probably things, which are written not in the true erlangish way. And probably it won't be very easy to grasp, because documentation is not verbose -- Gleb Peregud http://gleber.pl/ Every minute is to be grasped. Time waits for nobody. -- Inscription on a Zen Gong From mikpe@REDACTED Thu May 8 11:31:22 2008 From: mikpe@REDACTED (Mikael Pettersson) Date: Thu, 8 May 2008 11:31:22 +0200 Subject: [erlang-questions] Strange arithmetic behaviour In-Reply-To: <85d11a2e0805080142x2b9d9615mbe8a6dd7e1b4aa87@mail.gmail.com> References: <85d11a2e0805080142x2b9d9615mbe8a6dd7e1b4aa87@mail.gmail.com> Message-ID: <18466.51306.151559.499170@harpo.it.uu.se> Gurgen Tumanian writes: > Dear all. > > There is some kind of strange behaviour that i have noticed when dealing > with big float values. > For example: > > 123123123123123123123.0 - 123123123123123123121.0 is 0.00000e+0 when i > expect 2.0 or something like that in e notation. > I found this kind of errors with round() and trunc(). for example: > trunc(1233333333333333123333333333.12311111111) is > 1233333333333333065680814080. > or > round(1233333333333333123333333333.12311111111) is > 1233333333333333065680814080. > > furthermore > 1233333333333333123333333333.12311111111 = > 123333333333333312367575676573.92311111111 matches > > > I have tested this on R11-B5 and on R12-B1 > > Is this a big nasty bug, or am i missing something? You're missing that a) Erlang floats have finite precision, per IEEE 64-bit FP standard, and b) the Erlang reader accepts overspecified floats and maps them to its internal finite precision without warning when loss of precision occurs One could argue that the reader should warn when precision loss occurs, but that's just one of many cases where floating-point numbers may experience precision losses, and the other cases also do not warn. From tumanian@REDACTED Thu May 8 11:40:12 2008 From: tumanian@REDACTED (Gurgen Tumanian) Date: Thu, 8 May 2008 14:40:12 +0500 Subject: [erlang-questions] Strange arithmetic behaviour In-Reply-To: <18466.51306.151559.499170@harpo.it.uu.se> References: <85d11a2e0805080142x2b9d9615mbe8a6dd7e1b4aa87@mail.gmail.com> <18466.51306.151559.499170@harpo.it.uu.se> Message-ID: <85d11a2e0805080240q15ed52dfx94bd519796602101@mail.gmail.com> I did expect this kind of behaviour from C, since the values i did experiment with were out of the C float range. However I did expect that erlang could handle this in some meaningfull way. It does handle big integers that are over the C int range, doesn't it? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matthias@REDACTED Thu May 8 10:58:05 2008 From: matthias@REDACTED (Matthias Lang) Date: Thu, 8 May 2008 10:58:05 +0200 Subject: [erlang-questions] Strange arithmetic behaviour In-Reply-To: <85d11a2e0805080142x2b9d9615mbe8a6dd7e1b4aa87@mail.gmail.com> References: <85d11a2e0805080142x2b9d9615mbe8a6dd7e1b4aa87@mail.gmail.com> Message-ID: <18466.49309.258494.651720@antilipe.corelatus.se> Gurgen Tumanian writes: > There is some kind of strange behaviour that i have noticed when dealing > with big float values. This problem is not a "big nasty bug", it's a fundamental consequence of the way floating point numbers are commonly represented. It is basically unrelated to Erlang, you'll get the same behaviour in C, for instance. Your first subtraction is a textbook example of the relative error growing dramatically when you subtract two large numbers which are close together. This wikipedia article is a quick introduction to the topic: http://en.wikipedia.org/wiki/Floating_point Matt ---------------------------------------------------------------------- > For example: > > 123123123123123123123.0 - 123123123123123123121.0 is 0.00000e+0 when i > expect 2.0 or something like that in e notation. > I found this kind of errors with round() and trunc(). for example: > trunc(1233333333333333123333333333.12311111111) is > 1233333333333333065680814080. > or > round(1233333333333333123333333333.12311111111) is > 1233333333333333065680814080. > > furthermore > 1233333333333333123333333333.12311111111 = > 123333333333333312367575676573.92311111111 matches > > > I have tested this on R11-B5 and on R12-B1 > > Is this a big nasty bug, or am i missing something? > > Regards > Gurgen Tumanyan > Smart Tech > Dear all.

There is some kind of strange behaviour that i have noticed when dealing with big float values.
For example:

 123123123123123123123.0 - 123123123123123123121.0 is 0.00000e+0  when i expect 2.0 or  something like that in e notation.
> I found this kind of errors with round() and trunc(). for example:
trunc(1233333333333333123333333333.12311111111) is 1233333333333333065680814080.
or
round(1233333333333333123333333333.12311111111) is 1233333333333333065680814080.
>
furthermore
1233333333333333123333333333.12311111111 = 123333333333333312367575676573.92311111111 matches


I have tested this on R11-B5 and on R12-B1

Is this a big nasty bug, or am i missing something?
>
Regards
Gurgen Tumanyan
Smart Tech



> _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From mats.cronqvist@REDACTED Thu May 8 11:52:28 2008 From: mats.cronqvist@REDACTED (Mats Cronqvist) Date: Thu, 08 May 2008 11:52:28 +0200 Subject: [erlang-questions] planet.trapexit.org down? In-Reply-To: <4822BEE0.8000400@erlang-consulting.com> References: <4822BEE0.8000400@erlang-consulting.com> Message-ID: <4822CD5C.4030607@kreditor.se> Francesco Cesarini wrote: > We've had reoccurring hard disk problems on the machine running > trapexit. The site has been going up and down (or grinding to a halt) > like you would never believe. The increase in traffic at times cripples > the machine (Intensive SQL queries).. We will be moving everything in > about two months to better (and hopefully more stable) hardware while > giving the site an overhaul and implementing a bunch of new ideas we > have. Until then, chase us if you do see errors or outages. We do our > best, but are so busy at times that extra help is always welcome. > SQL? wtf! -------------- next part -------------- A non-text attachment was scrubbed... Name: mats_cronqvist.vcf Type: text/x-vcard Size: 179 bytes Desc: not available URL: From raimo+erlang-questions@REDACTED Thu May 8 12:11:40 2008 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Thu, 8 May 2008 12:11:40 +0200 Subject: [erlang-questions] : Strange arithmetic behaviour In-Reply-To: <85d11a2e0805080240q15ed52dfx94bd519796602101@mail.gmail.com> References: <85d11a2e0805080142x2b9d9615mbe8a6dd7e1b4aa87@mail.gmail.com> <18466.51306.151559.499170@harpo.it.uu.se> <85d11a2e0805080240q15ed52dfx94bd519796602101@mail.gmail.com> Message-ID: <20080508101140.GC6542@erix.ericsson.se> On Thu, May 08, 2008 at 02:40:12PM +0500, Gurgen Tumanian wrote: > I did expect this kind of behaviour from C, since the values i did > experiment with were out of the C float range. However I did expect that > erlang could handle this in some meaningfull way. It does handle big > integers that are over the C int range, doesn't it? Sorry to disappoint you. Integers are infinite size (almost), but floats are IEEE 64 bit. Suppose you had arbitrary precision floats and did 1.0 / 3.0 Then you could not store the result because there is no exact result in base 2. So you would have to give a rounding strategy for every division, or have an implicit. And that would probable be stranger than IEEE floats. But interesting. And I would not want to write the library that does e.g sin, cos, tan, asin, acos, atan, pow, exp, erf for a given arbitrary rounding strategy. Someone else? > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From chsu79@REDACTED Thu May 8 12:40:13 2008 From: chsu79@REDACTED (Christian S) Date: Thu, 8 May 2008 12:40:13 +0200 Subject: [erlang-questions] planet.trapexit.org down? In-Reply-To: <4822CD5C.4030607@kreditor.se> References: <4822BEE0.8000400@erlang-consulting.com> <4822CD5C.4030607@kreditor.se> Message-ID: > SQL? wtf! ftw bbq From per.melin@REDACTED Thu May 8 13:02:03 2008 From: per.melin@REDACTED (Per Melin) Date: Thu, 8 May 2008 13:02:03 +0200 Subject: [erlang-questions] erlang:phash2(make_ref(), 1 bsl 32) In-Reply-To: <482279F8.5060309@san.rr.com> References: <482279F8.5060309@san.rr.com> Message-ID: 2008/5/8 Darren New : > I'm no expert, but my understanding is that make_ref() doesn't make a > particularly unique reference. You're right. But for what I need in this particular case it's perfect. It only has to be unique per node, and only a few million times. I could even use a counter, but then I'd have to have a process on each node just to own the counter. I'll use some combination of make_ref() and now() and it'll be fine. I just wonder if it isn't a weakness in how phash2 works with refs? -------------- next part -------------- An HTML attachment was scrubbed... URL: From adam@REDACTED Thu May 8 13:19:44 2008 From: adam@REDACTED (Adam Lindberg) Date: Thu, 8 May 2008 13:19:44 +0200 Subject: [erlang-questions] planet.trapexit.org down? In-Reply-To: References: <4822BEE0.8000400@erlang-consulting.com> <4822CD5C.4030607@kreditor.se> Message-ID: <6344005f0805080419u7a309b7erff7a92ddcb541ff@mail.gmail.com> On Thu, May 8, 2008 at 12:40 PM, Christian S wrote: > > SQL? wtf! > ftw bbq We've looked into migrating it to an WTF-based database server, but the query language is just too foul to work with... Cheers, Adam -- Adam Lindberg http://www.erlang-consulting.com From andy@REDACTED Thu May 8 14:13:06 2008 From: andy@REDACTED (Andy Gross) Date: Thu, 8 May 2008 08:13:06 -0400 Subject: [erlang-questions] erlang:phash2(make_ref(), 1 bsl 32) In-Reply-To: References: <482279F8.5060309@san.rr.com> Message-ID: <800CA5CA-C555-4DAE-9F76-DE8D4BD8A861@andygross.org> I use crypto:sha(term_to_binary({make_ref(), now()}), then hexify it with the mochihex module from mochiweb, e.g. >> mochihex:to_hex(crypto:sha(term_to_binary({make_ref(), now()}))). "1477cfafb3ec026ab1c6c6ff0f0fb6c7ee001554" - Andy On May 8, 2008, at 7:02 AM, Per Melin wrote: > 2008/5/8 Darren New : > I'm no expert, but my understanding is that make_ref() doesn't make a > particularly unique reference. > > > You're right. But for what I need in this particular case it's > perfect. It only has to be unique per node, and only a few million > times. I could even use a counter, but then I'd have to have a > process on each node just to own the counter. > > I'll use some combination of make_ref() and now() and it'll be fine. > I just wonder if it isn't a weakness in how phash2 works with refs? > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From andy@REDACTED Thu May 8 14:19:58 2008 From: andy@REDACTED (Andy Gross) Date: Thu, 8 May 2008 08:19:58 -0400 Subject: [erlang-questions] [erlang-bugs] Weird pg2 behavior In-Reply-To: References: <18431.9227.133848.989614@gargle.gargle.HOWL> <18435.1529.209488.50485@gargle.gargle.HOWL> <18437.48350.271334.980195@gargle.gargle.HOWL> Message-ID: We also use pg2 heavily in our production network, and are also interested in seeing a resolution to this bug. It hasn't popped up in production yet, but when we moved offices we spent a couple of days trying to purge our pg2 groups of old, stale pids running on IP addresses from the old office space, to no avail. Eventually each developer just switched cookies to prevent whatever rogue pg2 instance was poisoning the group membership. Could someone in-the-know describe the monitoring changes made to global mentioned below? Would a patch from the community with a test suite be considered for inclusion in any R12-X release? - Andy On May 7, 2008, at 10:28 PM, Matthew Dempsky wrote: > Has there been any progress on this? This bug bit us again today. :-( > > (A pid from a node on a machine that had been decommissioned and not > running any Erlang code for months now but still present on our > network was still lurking in one of our pg2 groups. Yesterday we > finally repurposed this machine, removing it from our network, which > had the unexpected side effect of causing Pid ! Msg in some heavily > used code to start adding several seconds of delay due to the runtime > attempting to autoconnect to that long-dead node.) > > On Fri, Apr 18, 2008 at 1:23 AM, Matthew Dempsky > wrote: >> On Wed, Apr 16, 2008 at 1:46 AM, Hans Bolinder >> >> wrote: >> >>> I think pg2 should monitor all pids rather than link to local pids >>> only. Carefully setting up monitors, like Global does since R11B-4, >>> should work. >> >> Sounds good to me. Can we hope to see this in R12B-3? :-) >> > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From richardc@REDACTED Thu May 8 11:00:30 2008 From: richardc@REDACTED (Richard Carlsson) Date: Thu, 08 May 2008 11:00:30 +0200 Subject: [erlang-questions] Old school exceptions vs. new age one In-Reply-To: <4815F580.2060308@it.uu.se> References: <521254.57783.qm@web38807.mail.mud.yahoo.com> <4815F580.2060308@it.uu.se> Message-ID: <4822C12E.6070601@it.uu.se> Richard Carlsson wrote: > Thomas Lindgren wrote: >> Another part of the effort to turn Erlang into ML, eh? >> :-) > > On the contrary - the exception handling in ML lacks the > success-case branch that you get in Erlang with try...of... > (hence, it is ML that needs to be turned into Erlang). :-) Heh! I just found this nicely written blog article: http://enfranchisedmind.com/blog/2008/05/07/why-ocaml-sucks/ In particular, see point 8 about exceptions in O'Caml. :-) /Richard From kaiduanx@REDACTED Thu May 8 15:24:45 2008 From: kaiduanx@REDACTED (Kaiduan Xie) Date: Thu, 8 May 2008 09:24:45 -0400 Subject: [erlang-questions] Link for Erlang Code Replacement Pdf by Peter H|gfeldt is inaccessible In-Reply-To: References: <1218d6a50805071944t36e5c5f3h265692f77623c99f@mail.gmail.com> Message-ID: Yes, I tried with the instruction from the OPT Design Principles step by step, and it worked well. You also need to read System Principles. kaiduan On 5/8/08, Kenneth Lundin wrote: > > Hi, > > What about OTP Design Principles Chapter 12 > http://www.erlang.org/doc/design_principles/part_frame.html > > This might be what you are looking for. > > /Kenneth Erlang/OTP, Ericsson > > On 5/8/08, db wrote: > > I am trying get my hands on hot code loading pdf files written by > > Peter H|gfeldt. The links for it are not working. > > > > I have tried the following links and both links don't work at all: > > www.erlang.org/doc/misc > > http://www.erlang.org/pipermail/erlang-questions/2003-May/008831.html > > > > Is there a new link to these pdf files that I am not aware of? > > > > Thank you, > > -- > > 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 > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From hans.bolinder@REDACTED Thu May 8 16:30:26 2008 From: hans.bolinder@REDACTED (Hans Bolinder) Date: Thu, 8 May 2008 16:30:26 +0200 Subject: [erlang-questions] erlang:phash2(make_ref(), 1 bsl 32) In-Reply-To: References: Message-ID: <18467.3714.350514.42985@gargle.gargle.HOWL> [Per Melin:] > I thought that would be the easiest way to generate an integer > unique enough for my needs. But it seems to always repeat in 2^18 > (262144) iterations. > > That is because #Ref<_._.X.Y> gives the same phash2 as > #Ref<_._.X+1.Y> in any range between 2^20 and 2^32. Once upon a time references were 18 bits wide, but there is no reason why a hash function should not hash all bits. It's probably a copy/paste bug. I've added a comment to the source code. Thanks for pointing it out. Best regards, Hans Bolinder, Erlang/OTP, Ericsson From pietererlang@REDACTED Thu May 8 19:02:49 2008 From: pietererlang@REDACTED (Pieter Erlang) Date: Thu, 8 May 2008 19:02:49 +0200 Subject: [erlang-questions] bit operations/matching Message-ID: Hi, Can someone explain why line 2 fails (and line 3 not)? (also reproducible in other ways) Thx Pieter PS. unfortunately and only temporarily running on windows xp Erlang (BEAM) emulator version 5.6.2 [async-threads:0] Eshell V5.6.2 (abort with ^G) 1> B = <<0:1000>>. <<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,...>> 2> <<_:80,Val:2,_/binary>> = B. ** exception error: no match of right hand side value <<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,...>> 3> <<_:80,Val:8,_/binary>> = B. <<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,...>> 4> -------------- next part -------------- An HTML attachment was scrubbed... URL: From igorrs@REDACTED Thu May 8 19:26:03 2008 From: igorrs@REDACTED (Igor Ribeiro Sucupira) Date: Thu, 8 May 2008 14:26:03 -0300 Subject: [erlang-questions] bit operations/matching In-Reply-To: References: Message-ID: Because (1000 - 80 - 2) is not a multiple of 8. :-) 2008/5/8 Pieter Erlang : > Hi, > > Can someone explain why line 2 fails (and line 3 not)? > (also reproducible in other ways) > > Thx > Pieter > PS. unfortunately and only temporarily running on windows xp > > > Erlang (BEAM) emulator version 5.6.2 [async-threads:0] > > Eshell V5.6.2 (abort with ^G) > 1> B = <<0:1000>>. > <<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, > 0,...>> > 2> <<_:80,Val:2,_/binary>> = B. > ** exception error: no match of right hand side value > <<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, > 0,...>> > 3> <<_:80,Val:8,_/binary>> = B. > <<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, > 0,...>> > 4> > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From waqner@REDACTED Thu May 8 19:40:05 2008 From: waqner@REDACTED (Alexander Wagner) Date: Thu, 8 May 2008 19:40:05 +0200 Subject: [erlang-questions] bit operations/matching In-Reply-To: References: Message-ID: <200805081940.05467.waqner@gmx.net> > Can someone explain why line 2 fails (and line 3 not)? The binary() type consist of full bytes, so your binary tail has to be a multiple of 8 bits long. This works (although there might be a more elegant way): <<_:80,Val:2,_:6,_/binary>> = B. Regards, Wag -- If you pay peanuts expect monkeys to do the work. From kostis@REDACTED Thu May 8 20:19:39 2008 From: kostis@REDACTED (Kostis Sagonas) Date: Thu, 08 May 2008 21:19:39 +0300 Subject: [erlang-questions] bit operations/matching In-Reply-To: References: Message-ID: <4823443B.6040303@cs.ntua.gr> Pieter Erlang wrote: > Hi, > > Can someone explain why line 2 fails (and line 3 not)? > (also reproducible in other ways) > > > Erlang (BEAM) emulator version 5.6.2 [async-threads:0] > > Eshell V5.6.2 (abort with ^G) > 1> B = <<0:1000>>. > <<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, > 0,...>> > 2> <<_:80,Val:2,_/binary>> = B. > ** exception error: no match of right hand side value > <<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, > 0,...>> Till a point, Erlang supported only binaries == sequences of bytes. Till then, the type qualifier that was to be used for matching against a sequence of bytes was "binary". Starting with R12, this type qualifier has been properly renamed "bytes" (but "binary" has been maintained for backwards compatibility reasons) so that programmers like Pieter Erlang are less likely to be confused by matching failures: ------------------------------------------------------------------------- Eshell V5.6.3 (abort with ^G) 1> B = <<0:1000>>. <<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,...>> 2> <<_:80,Val:2,_/binary>> = B. ** exception error: no match of right hand side value <<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,...>> 3> <<_:80,Val:2,_/bytes>> = B. ** exception error: no match of right hand side value <<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,...>> ------------------------------------------------------------------------- I would strongly recommend that programs using "binary" get changed to "bytes". If one really wants bit level pattern matching, the qualifier "bits" has been added for that purpose: ------------------------------------------------------------------------- 4> <<_:80,Val:2,_/bits>> = B. <<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,...>> 5> <<_:13,Val:69,_/bits>> = B. <<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,...>> ------------------------------------------------------------------------- Kostis From pietererlang@REDACTED Thu May 8 20:43:21 2008 From: pietererlang@REDACTED (Pieter Erlang) Date: Thu, 8 May 2008 20:43:21 +0200 Subject: [erlang-questions] bit operations/matching In-Reply-To: <4823443B.6040303@cs.ntua.gr> References: <4823443B.6040303@cs.ntua.gr> Message-ID: thx a lot...works now! Pieter On 5/8/08, Kostis Sagonas wrote: > > Pieter Erlang wrote: > >> Hi, >> >> Can someone explain why line 2 fails (and line 3 not)? >> (also reproducible in other ways) >> >> >> Erlang (BEAM) emulator version 5.6.2 [async-threads:0] >> >> Eshell V5.6.2 (abort with ^G) >> 1> B = <<0:1000>>. >> <<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, >> 0,...>> >> 2> <<_:80,Val:2,_/binary>> = B. >> ** exception error: no match of right hand side value >> <<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, >> 0,...>> >> > > Till a point, Erlang supported only binaries == sequences of bytes. > Till then, the type qualifier that was to be used for matching against a > sequence of bytes was "binary". > > Starting with R12, this type qualifier has been properly renamed "bytes" > (but "binary" has been maintained for backwards compatibility reasons) so > that programmers like Pieter Erlang are less likely to be confused by > matching failures: > > ------------------------------------------------------------------------- > Eshell V5.6.3 (abort with ^G) > 1> B = <<0:1000>>. > <<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, > 0,...>> > 2> <<_:80,Val:2,_/binary>> = B. > ** exception error: no match of right hand side value > <<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, > 0,...>> > 3> <<_:80,Val:2,_/bytes>> = B. > ** exception error: no match of right hand side value > <<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, > 0,...>> > ------------------------------------------------------------------------- > > I would strongly recommend that programs using "binary" get changed to > "bytes". > > If one really wants bit level pattern matching, the qualifier "bits" has > been added for that purpose: > > ------------------------------------------------------------------------- > 4> <<_:80,Val:2,_/bits>> = B. > <<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, > 0,...>> > 5> <<_:13,Val:69,_/bits>> = B. > <<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, > 0,...>> > ------------------------------------------------------------------------- > > > Kostis > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dougedmunds@REDACTED Thu May 8 20:46:41 2008 From: dougedmunds@REDACTED (DougEdmunds) Date: Thu, 08 May 2008 11:46:41 -0700 Subject: [erlang-questions] beersong.erl on trapexit Message-ID: <48234A91.1080707@gmail.com> Could someone show me how to modify beersong.erl (on trapexit.org) so it puts the result out into a variable? i.e. > Beersong = beersong:sing(), io:format("~p~n),[Beersong]. Thanks -dae From icfp.publicity@REDACTED Thu May 8 21:02:14 2008 From: icfp.publicity@REDACTED (Matthew Fluet (ICFP Publicity Chair)) Date: Thu, 8 May 2008 14:02:14 -0500 Subject: [erlang-questions] Workshop on Generic Programming: Call for Papers (co-located w/ ICFP08) Message-ID: <53ff55480805081202u2aa0f504jba139cd59f7e1ebf@mail.gmail.com> CALL FOR PAPERS Workshop on Generic Programming 2008 Victoria, Canada, 20th September 2008 http://www.comlab.ox.ac.uk/ralf.hinze/wgp2008/cfp.{html,pdf,ps,txt} The Workshop on Generic Programming is sponsored by ACM SIGPLAN and forms part of ICFP 2008. Previous Workshops on Generic Programming have been held in Marstrand (affiliated with MPC), Ponte de Lima (affiliated with MPC), Nottingham (informal workshop), Dagstuhl (IFIP WG2.1 Working Conference), Oxford (informal workshop), Utrecht (informal workshop), and Portland (affiliated with ICFP). Scope ----- Generic programming is about making programs more adaptable by making them more general. Generic programs often embody non-traditional kinds of polymorphism; ordinary programs are obtained from them by suitably instantiating their parameters. In contrast with normal programs, the parameters of a generic program are often quite rich in structure; for example they may be other programs, types or type constructors, class hierarchies, or even programming paradigms. Generic programming techniques have always been of interest, both to practitioners and to theoreticians, but only recently have generic programming techniques become a specific focus of research in the functional and object-oriented programming language communities. This workshop will bring together leading researchers in generic programming from around the world, and feature papers capturing the state of the art in this important emerging area. We welcome contributions on all aspects, theoretical as well as practical, of o adaptive object-oriented programming, o aspect-oriented programming, o component-based programming, o generic programming, o meta-programming, o polytypic programming, o programming with modules, and so on. Submission details ------------------ Deadline for submission: 30th June 2008 Notification of acceptance: 14th July 2008 Final submission due: 28th July 2008 Workshop: 20th September 2008 Authors should submit papers, in PostScript or PDF format, formatted for A4 paper, to Ralf Hinze (ralf.hinze@REDACTED) or Don Syme (Don.Syme@REDACTED) by 30th June 2008. The length should be restricted to 12 pages in standard (two-column, 9pt) ACM. Accepted papers are published by the ACM and will additionally appear in the ACM digital library. Programme committee ------------------- Ralf Hinze (co-chair) University of Oxford Patrik Jansson Chalmers University Andrew Lumsdaine Indiana University Conor McBride University of Nottingham Adriaan Moors Universiteit Leuven Fritz Ruehr Willamette University Tim Sheard Portland State University Don Syme (co-chair) Microsoft Research Todd Veldhuizen University of Waterloo From per.melin@REDACTED Fri May 9 00:56:07 2008 From: per.melin@REDACTED (Per Melin) Date: Fri, 9 May 2008 00:56:07 +0200 Subject: [erlang-questions] beersong.erl on trapexit In-Reply-To: References: <48234A91.1080707@gmail.com> Message-ID: 2008/5/8 DougEdmunds : > Could someone show me how to modify beersong.erl > (on trapexit.org) so it puts the result out into > a variable? > > i.e. > Beersong = beersong:sing(), io:format("~p~n),[Beersong]. > sing_verse(Bottle) -> sing_verse(Bottle, []). sing_verse(-1, Song) -> lists:reverse(Song); sing_verse(Bottle, Song) -> receive {Bottle, Verse} -> sing_verse(Bottle-1, [lists:flatten(Verse)|Song]) after 3000 -> io:format("Verse not received after 3 seconds" " - re-starting singer~n"), spawn_singer(Bottle), sing_verse(Bottle, Song) -------------- next part -------------- An HTML attachment was scrubbed... URL: From matthew@REDACTED Fri May 9 03:20:18 2008 From: matthew@REDACTED (Matthew Dempsky) Date: Thu, 8 May 2008 18:20:18 -0700 Subject: [erlang-questions] erlang:phash2(make_ref(), 1 bsl 32) In-Reply-To: References: <482279F8.5060309@san.rr.com> Message-ID: 2008/5/8 Per Melin : > You're right. But for what I need in this particular case it's perfect. It > only has to be unique per node, and only a few million times. I could even > use a counter, but then I'd have to have a process on each node just to own > the counter. You can create a public ets table and use ets:update_counter to atomically update it. From Jay@REDACTED Fri May 9 04:49:01 2008 From: Jay@REDACTED (Jay Nelson) Date: Thu, 8 May 2008 19:49:01 -0700 Subject: [erlang-questions] [clarify] edoc type definition formatting Message-ID: When I create an @type definition that is longer than a line, it wraps in the output HTML. Is there any way to preserve indenting and newlines or make a pretty-printed format instead of just a long single line that wraps? jay From pfisher@REDACTED Fri May 9 05:25:33 2008 From: pfisher@REDACTED (Paul Fisher) Date: Thu, 08 May 2008 22:25:33 -0500 Subject: [erlang-questions] inets mod_get mishandles inaccessible files Message-ID: <1210303533.15666.23.camel@localhost> When the inets httpd mod_get processes a request for a non-existent file the connection is closed without a response. I would expect it to return a 404 instead. Here is what comes out in the error_log: [08/May/2008:21:47:08 -0500], traverse exit from apply: mod_get:do => {{badmatch,{error,enoent}}, [{mod_get,get_modification_date,1}, {mod_get,do_get,1}, {httpd_response,traverse_modules,2}, {httpd_response,generate_and_send_response,1}, {httpd_request_handler,handle_response,1}, {gen_server,handle_msg,5}, {proc_lib,init_p,5}]} ?Apparently mod_get:do_get/1 (and associated functions) is not prepared to get {error, enoent} back from mod_alias:path/3, and there seems to be no provision for generating a 404 response in do_get. It also looks like files/directories with invalid permissions within the document_root would also generate the same issue. In the end it appears that a non-trivial patch would be required to handle all of the cases and return appropriate responses in all cases. Would such a patch be acceptable for integration into a future OTP release? This is with R12B-2. -- paul From litaocheng@REDACTED Fri May 9 06:21:57 2008 From: litaocheng@REDACTED (=?GB2312?B?s8nBoszO?=) Date: Fri, 9 May 2008 12:21:57 +0800 Subject: [erlang-questions] erlang:localtime_to_universaltime/2 work unexpect? Message-ID: Hi everyone. When I using erlang:localtime_to_universaltime/2 , I have some doubt. My time zone is GMT + 8, asia/shanghai(china). this segment is printed out from my erl: > lists:map(fun(I) -> erlang:localtime_to_universaltime(I, true) end, [ {{1977, 7, 10}, {10, 20, 03}}, {{1978, 7, 10}, {10, 20, 03}}, {{1997, 7, 10}, {10, 20, 03}}, {{1999, 7, 10}, {10, 20, 3}}, {{2000, 7, 10}, {10, 20, 3}}, {{2008, 5, 9}, {10, 20, 03}}]). [{{1977,7,10},{2,20,3}}, {{1978,7,10},{1,20,3}}, {{1997,7,10},{1,20,3}}, {{1999,7,10},{1,20,3}}, {{2000,7,10},{2,20,3}}, {{2008,5,9},{2,20,3}}] I find from 1978 to 1999 the DST is active, other not. I can't understand why have this phenomenon. everyone can give me an answer? thanks! -- ??? --------------------------------------------------------- ?????? ?????? -------------- next part -------------- An HTML attachment was scrubbed... URL: From bengt.kleberg@REDACTED Fri May 9 07:12:07 2008 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Fri, 09 May 2008 07:12:07 +0200 Subject: [erlang-questions] erlang:localtime_to_universaltime/2 work unexpect? In-Reply-To: References: Message-ID: <1210309927.6152.8.camel@seasc0642.dyn.rnd.as.sw.ericsson.se> Greetings, Could you please try calendar:local_time_to_universal_time_dst/1 and see if the phenomenon remains. According to the documentation "Use local_time_to_universal_time_dst/1 instead, as it gives a more correct and complete result." bengt On Fri, 2008-05-09 at 12:21 +0800, ??? wrote: > {{1977, 7, 10}, {10, 20, 03}}, > {{1978, 7, 10}, {10, 20, 03}}, > {{1997, 7, 10}, {10, 20, 03}}, > {{1999, 7, 10}, {10, 20, 3}}, > {{2000, 7, 10}, {10, 20, 3}}, > {{2008, 5, 9}, {10, 20, 03}}]). > From raimo+erlang-questions@REDACTED Fri May 9 08:45:33 2008 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Fri, 9 May 2008 08:45:33 +0200 Subject: [erlang-questions] : erlang:phash2(make_ref(), 1 bsl 32) In-Reply-To: References: <482279F8.5060309@san.rr.com> Message-ID: <20080509064533.GA30730@erix.ericsson.se> On Thu, May 08, 2008 at 06:20:18PM -0700, Matthew Dempsky wrote: > 2008/5/8 Per Melin : > > You're right. But for what I need in this particular case it's perfect. It > > only has to be unique per node, and only a few million times. I could even > > use a counter, but then I'd have to have a process on each node just to own > > the counter. > > You can create a public ets table and use ets:update_counter to > atomically update it. That is much faster than a server, but you still need a process to own the ets table. Is that really a problem? > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From raimo+erlang-questions@REDACTED Fri May 9 09:08:37 2008 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Fri, 9 May 2008 09:08:37 +0200 Subject: [erlang-questions] erlang:localtime_to_universaltime/2 work unexpect? In-Reply-To: References: Message-ID: <20080509070837.GB30730@erix.ericsson.se> On Fri, May 09, 2008 at 12:21:57PM +0800, ?????? wrote: > Hi everyone. > When I using erlang:localtime_to_universaltime/2 , I have some doubt. > My time zone is GMT + 8, asia/shanghai(china). > this segment is printed out from my erl: > > > lists:map(fun(I) -> erlang:localtime_to_universaltime(I, true) end, [ > {{1977, 7, 10}, {10, 20, 03}}, > {{1978, 7, 10}, {10, 20, 03}}, > {{1997, 7, 10}, {10, 20, 03}}, > {{1999, 7, 10}, {10, 20, 3}}, > {{2000, 7, 10}, {10, 20, 3}}, > {{2008, 5, 9}, {10, 20, 03}}]). > > [{{1977,7,10},{2,20,3}}, > {{1978,7,10},{1,20,3}}, > {{1997,7,10},{1,20,3}}, > {{1999,7,10},{1,20,3}}, > {{2000,7,10},{2,20,3}}, > {{2008,5,9},{2,20,3}}] > > > > I find from 1978 to 1999 the DST is active, other not. > I can't understand why have this phenomenon. everyone can give me an > answer? > thanks! > You should have a look at the timezone definitions in your host OS. On e.g linux use: zdump -v /etc/localtime That will give you the definition your host OS uses. For me in Europe/Stockholm using your example I get DST from 1997 but not earlier. In the zdump output it is clear that DST was defined 1916 but then not until 1980 and if I recall correctly that is the truth from political decisions. > > > -- > ?????? > --------------------------------------------------------- > ???????????? > ???????????? > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From per.melin@REDACTED Fri May 9 09:53:03 2008 From: per.melin@REDACTED (Per Melin) Date: Fri, 9 May 2008 09:53:03 +0200 Subject: [erlang-questions] : erlang:phash2(make_ref(), 1 bsl 32) In-Reply-To: <20080509064533.GA30730@erix.ericsson.se> References: <482279F8.5060309@san.rr.com> <20080509064533.GA30730@erix.ericsson.se> Message-ID: 2008/5/9 Raimo Niskanen : > > > You can create a public ets table and use ets:update_counter to > > atomically update it. > > That is much faster than a server, but you still need a process to > own the ets table. Is that really a problem? Not at all. It would just be more convenient to use make_ref(), which I imagine exists for just this purpose. I never meant to say that this was a real problem, I just wanted to point out a possible weakness in phash/phash2. From richardc@REDACTED Fri May 9 11:27:52 2008 From: richardc@REDACTED (Richard Carlsson) Date: Fri, 09 May 2008 11:27:52 +0200 Subject: [erlang-questions] [clarify] edoc type definition formatting In-Reply-To: References: Message-ID: <48241918.2090903@it.uu.se> Jay Nelson wrote: > When I create an @type definition that is longer than a line, it > wraps in the output HTML. Is there any way to preserve indenting and > newlines or make a pretty-printed format instead of just a long > single line that wraps? Not as such, but you can use full XHTML in the description, so you should be able to use

,
,  ,

,
, etc.

     /Richard

-- 
  "Having users is like optimization: the wise course is to delay it."
    -- Paul Graham


From ulf.wiger@REDACTED  Fri May  9 12:24:17 2008
From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB))
Date: Fri, 09 May 2008 12:24:17 +0200
Subject: [erlang-questions] More Mnesia Questions
In-Reply-To: <584089.72503.qm@web51903.mail.re2.yahoo.com>
References: <584089.72503.qm@web51903.mail.re2.yahoo.com>
Message-ID: <48242651.70801@ericsson.com>

Bill Robertson skrev:

> 2. I want to track the selection frequency of terms, and then
> frequently retrieve the N most popular terms. In a relational
 > database, I would just create an index in descending order and use
 > an appropriate order by clause. I don't see any options to do that
 > with an mnesia index though. Would qlc be smart enough to figure it
 > out walk the index backwards? How would you even do that in qlc?

If you want to jump in at the (very) deep end, the rdbms contrib
has support for ordered indexes, as well as first/next/prev
operations via index.

http://jungerl.cvs.sourceforge.net/jungerl/jungerl/lib/rdbms/

Unfortunately, it's not been updated for the last 2 years,
so it would not work in R12B. If you want to hack your own indexing
support, you might get inspired (or put off) by peeking at e.g.
rdbms_index.erl. Most of it should work without having to patch
mnesia... (:


BR,
Ulf W


From gleber.p@REDACTED  Fri May  9 12:58:32 2008
From: gleber.p@REDACTED (Gleb Peregud)
Date: Fri, 9 May 2008 12:58:32 +0200
Subject: [erlang-questions] few questions: common sense is not so common
In-Reply-To: <14f0e3620805080223i3b3e64b6t969142063fd6c7b0@mail.gmail.com>
References: <1218d6a50805070851p2c204831tf6724fea719039c5@mail.gmail.com>
	<14f0e3620805071320g120309a5w77b27828db49ca5e@mail.gmail.com>
	<1218d6a50805071837lf824401q4c1f120198a432a5@mail.gmail.com>
	<14f0e3620805080223i3b3e64b6t969142063fd6c7b0@mail.gmail.com>
Message-ID: <14f0e3620805090358x29dd6916q3edb0d4ed1f09f13@mail.gmail.com>

Here you go.

Introducing erl-dectree (i know, name is lame ;)

http://code.google.com/p/erl-dectree/

Feel free to do whatever you want. It is licensed under new BSD
license. Documentation is located in docs/documentation.pdf (i'll
upload source file if someone wants it).

It is my first open source project, hence feel free to point at errors
if found and i'll be grateful for any advices :)

On 5/8/08, Gleb Peregud  wrote:
> On 5/8/08, db  wrote:
>> Do you have a link where I can download erlang version of distributed
>> decision support tree?  I don't feel like reinventing the wheel.
>>
>> On Wed, May 7, 2008 at 4:20 PM, Gleb Peregud  wrote:
>>>
>>>  q4) and q5) looks like one i had while implementing distributed
>>>  decision trees construction algorithm. Is your task similar to this
>>>  one?
>>>
>>>  btw, is anyone interested in distributed decision trees construction
>>>  algorithm written in Erlang? I've written it as one of the projects at
>>>  the University. Frankly speaking it is not efficient (~10% speedup
>>>  with 2 computers instead of 1), but probably it may be improved quite
>>>  easily :) Documentation is included.
>>>
>>>  --
>>>  Gleb Peregud
>>>  http://gleber.pl/
>>>
>>>  Every minute is to be grasped.
>>>  Time waits for nobody.
>>>  -- Inscription on a Zen Gong
>>>
>>
>> Thank you,
>> --
>> 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
>>
>
> Because few people showed interest in it, i'll publish it on Google
> Code asap (unfortunately time is against me).
>
> But i have to warn you: It is not written as an OTP application. It is
> one of the first Erlang programs written by me, hence there are
> probably things, which are written not in the true erlangish way. And
> probably it won't be very easy to grasp, because documentation is not
> verbose
>
> --
> Gleb Peregud
> http://gleber.pl/
>
> Every minute is to be grasped.
> Time waits for nobody.
> -- Inscription on a Zen Gong
>


-- 
Gleb Peregud
http://gleber.pl/

Every minute is to be grasped.
Time waits for nobody.
-- Inscription on a Zen Gong


From Woolla_T@REDACTED  Thu May  8 11:34:47 2008
From: Woolla_T@REDACTED (Trevor Woollacott [ MTN - Innovation Centre ])
Date: Thu, 8 May 2008 11:34:47 +0200
Subject: [erlang-questions] Strange arithmetic behaviour
In-Reply-To: <85d11a2e0805080142x2b9d9615mbe8a6dd7e1b4aa87@mail.gmail.com>
References: <85d11a2e0805080142x2b9d9615mbe8a6dd7e1b4aa87@mail.gmail.com>
Message-ID: <70D00C33FCD1FD4A860DEAC228277C0C0464BFAC@MTNMAIL1.mtn.co.za>

Hi

 

This occurs in most programming languages due to the way floating point
arithmetic is performed. 

 

If I try it in Python I get:

>>> 123123123123123123123.0 - 123123123123123123121.0

0.0

 

Take out the decimal place and you get:

>>> 123123123123123123123 - 123123123123123123121

2

 

 

Try the following in Erlang:

10.1-0.1-10 = 0.00000e+0

 

However:

10.1-10-0.1 = -3.60822e-16

 

It's not a bug, it's a limitation

 

Regards,

Trevor

________________________________

From: erlang-questions-bounces@REDACTED
[mailto:erlang-questions-bounces@REDACTED] On Behalf Of Gurgen
Tumanian
Sent: Thursday, 08 May 2008 10:42 AM
To: erlang-questions@REDACTED
Subject: [erlang-questions] Strange arithmetic behaviour

 

Dear all.

There is some kind of strange behaviour that i have noticed when dealing
with big float values.
For example:

 123123123123123123123.0 - 123123123123123123121.0 is 0.00000e+0  when i
expect 2.0 or  something like that in e notation.
I found this kind of errors with round() and trunc(). for example: 
trunc(1233333333333333123333333333.12311111111) is
1233333333333333065680814080.
or
round(1233333333333333123333333333.12311111111) is
1233333333333333065680814080.

furthermore 
1233333333333333123333333333.12311111111 =
123333333333333312367575676573.92311111111 matches


I have tested this on R11-B5 and on R12-B1

Is this a big nasty bug, or am i missing something?

Regards
Gurgen Tumanyan
Smart Tech




NOTE: This e-mail message is subject to the MTN Group disclaimer see http://www.mtn.co.za/default.aspx?pid=34411 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From masklinn@REDACTED  Fri May  9 15:13:00 2008
From: masklinn@REDACTED (Masklinn)
Date: Fri, 9 May 2008 15:13:00 +0200
Subject: [erlang-questions] Strange arithmetic behaviour
In-Reply-To: <70D00C33FCD1FD4A860DEAC228277C0C0464BFAC@MTNMAIL1.mtn.co.za>
References: <85d11a2e0805080142x2b9d9615mbe8a6dd7e1b4aa87@mail.gmail.com>
	<70D00C33FCD1FD4A860DEAC228277C0C0464BFAC@MTNMAIL1.mtn.co.za>
Message-ID: <5D56A501-27BD-4D7E-B9ED-E3CEC94C4042@masklinn.net>


On 8 May 2008, at 11:34 , Trevor Woollacott [ MTN - Innovation  
Centre ] wrote:

> Hi
>
>
>
> This occurs in most programming languages due to the way floating  
> point
> arithmetic is performed.

Pretty much all of them, really. And it's not like the "issue" (or non- 
issue) hasn't been studied and explained clearly by David Goldberg in  
his quite well known (but not quite read often enough) "What Every  
Computer Scientist Should Know About Floating-Point Arithmetic" (http://physics.ohio-state.edu/~dws/grouplinks/floating_point_math.pdf 
).


From Jay@REDACTED  Fri May  9 15:19:11 2008
From: Jay@REDACTED (Jay Nelson)
Date: Fri, 9 May 2008 06:19:11 -0700
Subject: [erlang-questions] [clarify] edoc type definition formatting
In-Reply-To: <48241918.2090903@it.uu.se>
References: 
	<48241918.2090903@it.uu.se>
Message-ID: <6DAB529F-6672-41BB-BFC6-FEF0632145F7@duomark.com>

XHTML formatting works fine in the body of an @doc statement, but I  
can't seem to get any formatting commands recognized in the type  
definition section (the right hand side of the =) of an @type statement.

Looking at the generated XHTML I see now that the type is in an 

pair, and the definition itself is a separate section inside a

section. What I need to do is get the replaced with something else, but I guess as a last resort I could add a stylesheet definition that changes the formatting of . I doubt it matters, but I have my type definition in an @headerfile that gets included into my .erl file. On May 9, 2008, at 2:27 AM, Richard Carlsson wrote: > Jay Nelson wrote: >> When I create an @type definition that is longer than a line, it >> wraps in the output HTML. Is there any way to preserve indenting >> and newlines or make a pretty-printed format instead of just a >> long single line that wraps? > > Not as such, but you can use full XHTML in the description, so you > should be able to use

,
,  ,

,
, etc.
>
>     /Richard



From egil@REDACTED  Fri May  9 15:36:02 2008
From: egil@REDACTED (=?ISO-8859-1?Q?Bj=F6rn-Egil_Dahlberg?=)
Date: Fri, 09 May 2008 15:36:02 +0200
Subject: [erlang-questions] os_mon in OS X
In-Reply-To: <01BC8448-F207-40ED-AE31-B25EACBCE049@gmail.com>
References: <74FB8CA7-7AEC-4DD9-831F-594647BFDC27@gmail.com>	<482049BB.6020004@erix.ericsson.se>	
	<01BC8448-F207-40ED-AE31-B25EACBCE049@gmail.com>
Message-ID: <48245342.7090907@erix.ericsson.se>

Ben Hood wrote:
> Bj?rn-Egil,
> 
> On 6 May 2008, at 13:18, Ben Hood wrote:
>> The user that reported this to me (using RabbitMQ server) sent error  
>> dump via a chat session which I don't have a transcript for. So I  
>> have asked him to resend it and I will post it.
>>
> 
> This is the error trace:
> 
> =ERROR REPORT==== 6-May-2008::14:47:00 ===
> Error in process <0.52.0> on node 'rabbit@REDACTED' with exit value:  
> {{badmatch,{error,{fread,float}}},[{cpu_sup,get_uint32_measurement,2}, 
> {cpu_
> sup,measurement_server_loop,1}]}

It seems to be an error in cpu_sup for darwin and locales, it should 
probably use LC_ALL=C uptime instead of LANG=C uptime.

This should resolve it (not fully tested though). diff follows:

------------------------------------------------------------

diff -Naur otp_src_R12B-2/lib/os_mon/src/cpu_sup.erl 
otp_src_R12B-2_cpu_sup_fix/lib/os_mon/src/cpu_sup.erl
--- otp_src_R12B-2/lib/os_mon/src/cpu_sup.erl	2008-05-09 
15:08:52.228457000 +0200
+++ otp_src_R12B-2_cpu_sup_fix/lib/os_mon/src/cpu_sup.erl	2008-05-09 
15:08:43.138456000 +0200
@@ -264,7 +264,7 @@
      end;
  get_uint32_measurement(Request, #internal{os_type = {unix, darwin}}) ->
      %% Get the load average using uptime, overriding Locale setting.
-    D = os:cmd("LANG=C uptime") -- "\n",
+    D = os:cmd("LANG=C LC_ALL=C uptime") -- "\n",
      %% Here is a sample uptime string from Mac OS 10.3.8 (C Locale):
      %%    "11:17  up 12 days, 20:39, 2 users, load averages: 1.07 0.95 
0.66"
      %% The safest way to extract the load averages seems to be grab 
everything


------------------------------------------------------------

I agree, it is sad that output like this is modified by locale settings 
which makes it a little difficult to parse. A more robust way should be 
implemented then parsing human readables. No such implementation is on 
the horizon nor seriously contemplated at the moment.

Regards,
Bj?rn-Egil
Erlang/OTP


From ingela@REDACTED  Fri May  9 15:45:25 2008
From: ingela@REDACTED (Ingela Anderton Andin)
Date: Fri, 09 May 2008 15:45:25 +0200
Subject: [erlang-questions] inets mod_get mishandles inaccessible files
	(Paul Fisher)
In-Reply-To: 
References: 
Message-ID: <48245575.1000808@erix.ericsson.se>

Hi!

Thank you for pointing this out.
I do however not think that any non-trivial patch will be needed. This 
should do the trick:

--- mod_get.erl@@/inets-5.0.8   2008-02-07 09:57:55.000000000 +0100
+++ mod_get.erl 2008-05-09 15:30:54.000000000 +0200
@@ -52,18 +52,17 @@
     ?DEBUG("do_get -> Request URI: ~p",[Info#mod.request_uri]),
     Path = mod_alias:path(Info#mod.data, Info#mod.config_db,
                          Info#mod.request_uri),
-    {FileInfo, LastModified} = get_modification_date(Path),
-
-    send_response(Info#mod.socket,Info#mod.socket_type, Path, Info,
-                 FileInfo, LastModified).
+
+    send_response(Info#mod.socket,Info#mod.socket_type, Path, Info).


 %% The common case when no range is specified
-send_response(_Socket, _SocketType, Path, Info, FileInfo, LastModified)->
+send_response(_Socket, _SocketType, Path, Info)->
     %% Send the file!
     %% Find the modification date of the file
     case file:open(Path,[raw,binary]) of
        {ok, FileDescriptor} ->
+           {FileInfo, LastModified} = get_modification_date(Path),
            ?DEBUG("do_get -> FileDescriptor: ~p",[FileDescriptor]),
            Suffix = httpd_util:suffix(Path),
            MimeType = httpd_util:lookup_mime_default(Info#mod.config_db,

>
> When the inets httpd mod_get processes a request for a non-existent file
> the connection is closed without a response.  I would expect it to
> return a 404 instead.  Here is what comes out in the error_log:
>
> [08/May/2008:21:47:08 -0500], traverse exit from apply: mod_get:do => 
> {{badmatch,{error,enoent}},
>  [{mod_get,get_modification_date,1},
>   {mod_get,do_get,1},
>   {httpd_response,traverse_modules,2},
>   {httpd_response,generate_and_send_response,1},
>   {httpd_request_handler,handle_response,1},
>   {gen_server,handle_msg,5},
>   {proc_lib,init_p,5}]}
>
> ?Apparently mod_get:do_get/1 (and associated functions) is not prepared
> to get {error, enoent} back from mod_alias:path/3, 
It does not get {error, enoent} from mod_alias:path/3. The badmatch 
occurs in the function
get_modification_date.

get_modification_date(Path)->
    {ok, FileInfo0} = file:read_file_info(Path),
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   Here was the badmatch

    LastModified =
    case catch httpd_util:rfc1123_date(FileInfo0#file_info.mtime) of
        Date when is_list(Date) -> [{last_modified, Date}];
        _ -> []
    end,
    {FileInfo0, LastModified}.

> and there seems to be
> no provision for generating a 404 response in do_get.  It also looks
> like files/directories with invalid permissions within the document_root
> would also generate the same issue.
>
>   
File errors are handeled by the module httpd_fil:handle_error.
 
[...]
case file:open(Path,[raw,binary]) of
    {ok, FileDescriptor} ->
          [...]
    {error, Reason} ->
        Status = httpd_file:handle_error(Reason, "open", Info, Path),
        {proceed,
         [{status, Status}| Info#mod.data]}

> In the end it appears that a non-trivial patch would be required to
> handle all of the cases and return appropriate responses in all cases.
> Would such a patch be acceptable for integration into a future OTP
> release?
>
> This is with R12B-2.
>
>   
All relevant patches will of course be considered. 

Regards Ingela Erlang/OTP Ericsson





From pfisher@REDACTED  Fri May  9 16:01:34 2008
From: pfisher@REDACTED (Paul Fisher)
Date: Fri, 09 May 2008 09:01:34 -0500
Subject: [erlang-questions] inets mod_get mishandles inaccessible files
	(Paul Fisher)
In-Reply-To: <48245575.1000808@erix.ericsson.se>
References: 
	<48245575.1000808@erix.ericsson.se>
Message-ID: <1210341694.15666.31.camel@localhost>

On Fri, 2008-05-09 at 15:45 +0200, Ingela Anderton Andin wrote:
> Thank you for pointing this out.
> I do however not think that any non-trivial patch will be needed. This 
> should do the trick:
> 
> --- mod_get.erl@@/inets-5.0.8   2008-02-07 09:57:55.000000000 +0100
> +++ mod_get.erl 2008-05-09 15:30:54.000000000 +0200
> @@ -52,18 +52,17 @@
>      ?DEBUG("do_get -> Request URI: ~p",[Info#mod.request_uri]),
>      Path = mod_alias:path(Info#mod.data, Info#mod.config_db,
>                           Info#mod.request_uri),
> -    {FileInfo, LastModified} = get_modification_date(Path),
> -
> -    send_response(Info#mod.socket,Info#mod.socket_type, Path, Info,
> -                 FileInfo, LastModified).
> +
> +    send_response(Info#mod.socket,Info#mod.socket_type, Path, Info).
> 
> 
>  %% The common case when no range is specified
> -send_response(_Socket, _SocketType, Path, Info, FileInfo, LastModified)->
> +send_response(_Socket, _SocketType, Path, Info)->
>      %% Send the file!
>      %% Find the modification date of the file
>      case file:open(Path,[raw,binary]) of
>         {ok, FileDescriptor} ->
> +           {FileInfo, LastModified} = get_modification_date(Path),
>             ?DEBUG("do_get -> FileDescriptor: ~p",[FileDescriptor]),
>             Suffix = httpd_util:suffix(Path),
>             MimeType = httpd_util:lookup_mime_default(Info#mod.config_db,

Thanks! That makes sense and handles all of the missing and inaccessible
(permissions) cases.  A shame that the equivalent of fstat() is not
available through the file module, but I understand that not all io
devices would have sane values.


> > [08/May/2008:21:47:08 -0500], traverse exit from apply: mod_get:do => 
> > {{badmatch,{error,enoent}},
> >  [{mod_get,get_modification_date,1},
> >   {mod_get,do_get,1},
> >
> > ?Apparently mod_get:do_get/1 (and associated functions) is not prepared
> > to get {error, enoent} back from mod_alias:path/3, 
> It does not get {error, enoent} from mod_alias:path/3. The badmatch 
> occurs in the function
> get_modification_date.

Of course you are correct... must have been too late when I ran into
this and wrote the note.


-- 
paul



From pfisher@REDACTED  Fri May  9 16:59:58 2008
From: pfisher@REDACTED (Paul Fisher)
Date: Fri, 09 May 2008 09:59:58 -0500
Subject: [erlang-questions] inets httpd mod_log output issue
Message-ID: <1210345198.15666.34.camel@localhost>

The 'compact' 'error_log_format' generates things like the following in
the
log files:

[09/May/2008:09:19:57 -0500] access to /foo/flooga.txt failed for 127.0.0.1, reason: [104,116,116,112,100,95,102,105,108,101,58,32,67,97,110,39,116,32,111,112,101,110,47,104,111,109,101,47,112,102,105,115,104,101,114,47,108,109,47,108,109,45,116,114,117,110,107,47,98,108,100,47,101,114,108,97,110,103,47,105,110,101,116,115,109,103,114,47,112,114,105,118,47,102,111,111,47,102,108,111,111,103,97,46,116,120,116]


This is caused by the following in httpd_log:do_error_entry/5 (line 108
and
119):

    compact ->
        io_lib:format( "[~s] access to ~s failed for ~s, reason: ~w~n", 
                       [Date, URI, RemoteHost, Reason])	     

Simply changing the ~w to ~s is not sensible, since this code clearly
expects the value of Reason to be something other than a character list
at
times.  I guess it would be possible to do the following:

    compact when is_list(Reason), is_integer(hd(Reason)),
                 hd(Reason) > 0, hd(Reason) =< 255 ->
        io_lib:format( "[~s] access to ~s failed for ~s, reason: ~s~n", 
                       [Date, URI, RemoteHost, Reason]);
    compact ->
        io_lib:format( "[~s] access to ~s failed for ~s, reason: ~w~n", 
                       [Date, URI, RemoteHost, Reason])	     


... but maybe there is a better way?

?R12B-2, of course.


-- 
paul

Robert Virding's First Rule:
"Any sufficiently complicated concurrent program in another language
contains an ad hoc, informally-specified, bug-ridden, slow
implementation of half of Erlang."



From tobias.lindahl@REDACTED  Fri May  9 17:00:24 2008
From: tobias.lindahl@REDACTED (Tobias Lindahl)
Date: Fri, 09 May 2008 17:00:24 +0200
Subject: [erlang-questions] Dialyzer programmatic interface
	and	output_plt
In-Reply-To: 
References: 	<48201848.3070205@it.uu.se>	
	
Message-ID: <48246708.4030504@it.uu.se>

Eric,

I found the problem. The analysis contains a bunch of files that could 
not be scanned. The errors are returned from the analysis, and when such 
errors occur the output plt is not written.

I think it is a bit inconsistent to not abort the analysis and then 
refuse to write the plt. It is probably a good idea to simply abort when 
I find that I cannot scan all files.

If you want a patch please tell me. Otherwise, you can assume that if 
there are errors in the return, the plt is not written.

Anyway, thanks for the report.

Tobias


Eric Merritt wrote:
>>  > >
>>  >
>>  >  For me the option {output_plt, File} works. I tested it with the released
>>  > sytem (R12B-2) and it seems to work there too. Is there a small test case
>>  > that you can send me?
>>
>>  I will see if I can put together a simple test case for you. At the
>>  very least I can verify that its not my issue.
>>
>>
> 
> So I have confirmed that with the following options no actual plt file
> is generated though the generation runs without fault. If I use a
> simpler set of options a plt file does result. I am not sure what the
> difference is. It does take over an hour to run on this though.
> (replace  and  with real directories, of
> course).
> 
> Opts = [{files_rec,["/repo/ktuo-0.4.0.1/ebin",
>              "/repo/ewrepo-0.16.6.0/ebin",
>              "/repo/ibrowse-1.4/ebin",
>              "/repo/ewlib-0.7.4.0/ebin",
>              "/repo/eunit-2.0/ebin",
>              "/repo/sgte-0.7.1/ebin",
>              "/repo/mnesia-4.4.2/ebin",
>              "/repo/xmerl-1.1.8/ebin",
>              "/repo/dialyzer-1.8.0/ebin",
>              "/repo/gs-1.5.9/ebin",
>              "/repo/hipe-3.6.6/ebin",
>              "/repo/tools-2.6.1/ebin",
>              "/repo/edoc-0.7.5/ebin",
>              "/repo/compiler-4.5.2/ebin",
>              "/repo/syntax_tools-1.5.4/ebin",
>              "/repo/crary-0.2.0/ebin",
>              "/repo/sasl-2.1.5.2/ebin",
>              "/repo/uri-0.1.0/ebin",
>              "/repo/kernel-2.12.2/ebin",
>              "/repo/stdlib-1.15.2/ebin"]},
>  {from,byte_code},
>  {output_plt,"/_build/development/info/dialyzer_plt"}],
> dialyzer:run(Opts).
> 
> 
> However, If i do something trivial like
> 
> Opts = [{files_rec,["/repo/ktuo-0.4.0.1/ebin"]},
>  {from,byte_code},
>  {output_plt,"/_build/development/info/dialyzer_plt"}],
> dialyzer:run(Opts).
> 
> A plt file is output as expected.
> 
> I have started going through and trying to see when dialyzer falls
> over but its slow enough that its going to take me awhile.
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions


From alexander.lamb@REDACTED  Fri May  9 17:07:46 2008
From: alexander.lamb@REDACTED (Alexander Lamb)
Date: Fri, 9 May 2008 17:07:46 +0200
Subject: [erlang-questions] Strategies for updating Mnesia tables
Message-ID: <62B5ED90-9A76-4C4C-A546-35C43A7060DD@rodanotech.ch>

Hello,

Although Mnesia columns can store any kind of Erlang terms, it can  
happen that we need to add a column after an application is deployed.
I understood (and tried) how to update the table.

However, on the contrary to traditionnal SQL databases, this will have  
an impact on my code. Indeed, something like:

ps_get_profiles(System_Name,Production_Type) ->
	F = fun() -> mnesia:match_object(profiles,{profiles, 
{'_','_','_'},System_Name,Production_Type,'_','_','_'},read) end,
	case mnesia:transaction(F) of
		{atomic, Records}	-> {ok, Records};
		{aborted, Reason}	-> {error, Reason}
	end.

Will simply find 0 records once I add a column, hence failing silently.

Is there a way to match against a variable number of columns, giving  
the first columns patterns. Something like:

	F = fun() -> mnesia:match_object(profiles,{profiles, 
{'_','_','_'},System_Name,Production_Type,'_','_','_', * },read) end,

See the "*" at the end of the match_object match part.

What is the strategy when updating software that necessitates adding  
or changing Mnesia tables.

Thanks,

Alex
--
Alexander Lamb
Founding Associate
RODANOTECH S?rl

4 ch. de la Tour de Champel
1206 Geneva
Switzerland

Tel:  022 347 77 37
Fax: 022 347 77 38

http://www.rodanotech.ch





From alexander.lamb@REDACTED  Fri May  9 17:29:46 2008
From: alexander.lamb@REDACTED (Alexander Lamb)
Date: Fri, 9 May 2008 17:29:46 +0200
Subject: [erlang-questions] Confused about the "rex" server
Message-ID: 

Hello list,

I am a bit confused about references of what is called "rex server".

I wrote a module with exported functions. I need to call these  
functions from a JInterface. So as I discovered in the documentation,  
I create a node and a mailbox (I will have several mailboxes in  
separate threads).
However, what I understood from a previous reply from Raimo, is that a  
rpc is actually a message send with some particular way of giving the  
parameters. In this message send, there is a reference to "rex". What  
does that actually mean? I didn't find the documentation related to  
this.

Now, on the receiving side, how do things happen?

Do I need to spawn a process for each call received? Or does "rex"  
handle this for me? Or would it be better to send messages instead of  
calling functions?

Alex
--
Alexander Lamb
Founding Associate
RODANOTECH S?rl

4 ch. de la Tour de Champel
1206 Geneva
Switzerland

Tel:  022 347 77 37
Fax: 022 347 77 38

http://www.rodanotech.ch





From ulf.wiger@REDACTED  Fri May  9 17:42:06 2008
From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB))
Date: Fri, 09 May 2008 17:42:06 +0200
Subject: [erlang-questions] Strategies for updating Mnesia tables
In-Reply-To: <62B5ED90-9A76-4C4C-A546-35C43A7060DD@rodanotech.ch>
References: <62B5ED90-9A76-4C4C-A546-35C43A7060DD@rodanotech.ch>
Message-ID: <482470CE.2010103@ericsson.com>

Alexander Lamb skrev:
> 
> Is there a way to match against a variable number of
 > columns, giving the first columns patterns.
 > Something like:
> 
>  F = fun() -> mnesia:match_object(
 >                profiles,
 >                {profiles, {'_','_','_'},
 >                System_Name,Production_Type,
 >                '_','_','_', * },read) end,
> 
> See the "*" at the end of the match_object match part.

If you use records, you can write

   #profiles{key = {'_','_','_'},
             system_name = System_Name,
             production_type = Production_Type,
             _ = '_'}

Remember to load a new version of the module at the
same time as you convert the table.

If you don't use records, you can spend a few more
CPU cycles and do something like this:

search_pattern(Tab, KV_list) ->
     Wild = mnesia:table_info(Tab, wild_pattern),
     Attrs = mnesia:table_info(Tab, attributes),
     lists:foldl(
         fun({K,V}, R) ->
             setelement(attr_pos(K,Attrs), R, V)
         end, Wild, KV_list).

attr_pos(Attr, Attrs) ->
     pos(Attrs, Attr, 2).

pos([A|_], A, P) -> P;
pos([_|As], A, P) ->
     pos(As, A, P+1).


BR,
Ulf W


From alexander.lamb@REDACTED  Fri May  9 17:58:33 2008
From: alexander.lamb@REDACTED (Alexander Lamb)
Date: Fri, 9 May 2008 17:58:33 +0200
Subject: [erlang-questions] Strategies for updating Mnesia tables
In-Reply-To: <482470CE.2010103@ericsson.com>
References: <62B5ED90-9A76-4C4C-A546-35C43A7060DD@rodanotech.ch>
	<482470CE.2010103@ericsson.com>
Message-ID: 


Le 9 mai 08 ? 17:42, Ulf Wiger (TN/EAB) a ?crit :

> Alexander Lamb skrev:
>> Is there a way to match against a variable number of
> > columns, giving the first columns patterns.
> > Something like:
>> F = fun() -> mnesia:match_object(
> >                profiles,
> >                {profiles, {'_','_','_'},
> >                System_Name,Production_Type,
> >                '_','_','_', * },read) end,
>> See the "*" at the end of the match_object match part.
>
> If you use records, you can write
>
>  #profiles{key = {'_','_','_'},
>            system_name = System_Name,
>            production_type = Production_Type,
>            _ = '_'}
>
> Remember to load a new version of the module at the
> same time as you convert the table.
>
Not quite certain what you mean. I do use records:

To define the table I used:

-record(profiles, {full_profile, system_name, production_type,  
timestamp, features, security_level}).

So if I understand correctly, I can do:

R = #profiles{full_profile = {'_','_','_'} , system_name =  
System_Name, production_type = Production_Type, _ = '_' },
F = fun() -> mnesia:match_object(profiles,R,read) end,

Or am I totally wrong?

Thanks,

Alex

> If you don't use records, you can spend a few more
> CPU cycles and do something like this:
>
> search_pattern(Tab, KV_list) ->
>    Wild = mnesia:table_info(Tab, wild_pattern),
>    Attrs = mnesia:table_info(Tab, attributes),
>    lists:foldl(
>        fun({K,V}, R) ->
>            setelement(attr_pos(K,Attrs), R, V)
>        end, Wild, KV_list).
>
> attr_pos(Attr, Attrs) ->
>    pos(Attrs, Attr, 2).
>
> pos([A|_], A, P) -> P;
> pos([_|As], A, P) ->
>    pos(As, A, P+1).
>
>
> BR,
> Ulf W
>



From ulf.wiger@REDACTED  Fri May  9 20:22:54 2008
From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB))
Date: Fri, 09 May 2008 20:22:54 +0200
Subject: [erlang-questions] Strategies for updating Mnesia tables
In-Reply-To: 
References: <62B5ED90-9A76-4C4C-A546-35C43A7060DD@rodanotech.ch>
	<482470CE.2010103@ericsson.com>
	
Message-ID: <4824967E.8020207@ericsson.com>

Alexander Lamb skrev:
> 
> Le 9 mai 08 ? 17:42, Ulf Wiger (TN/EAB) a ?crit :
> 
>>
>> If you use records, you can write
>>
>>  #profiles{key = {'_','_','_'},
>>            system_name = System_Name,
>>            production_type = Production_Type,
>>            _ = '_'}
>>
>> Remember to load a new version of the module at the
>> same time as you convert the table.
>>
> Not quite certain what you mean. I do use records:

I'm sorry. I should have been more clear.

> To define the table I used:
> 
> -record(profiles, {full_profile, system_name, production_type, 
> timestamp, features, security_level}).
> 
> So if I understand correctly, I can do:
> 
> R = #profiles{full_profile = {'_','_','_'} , system_name = System_Name, 
> production_type = Production_Type, _ = '_' },
> F = fun() -> mnesia:match_object(profiles,R,read) end,
> 
> Or am I totally wrong?

Yes. What I was referring to was that your code relies on
a compile-time definition of records, and the syntax
above will be expanded to the pattern that you had
initially (remember that records are just syntactic sugar).
If you follow something like this sequence:

1. suspend your processes (sys:suspend(Pid))
2. load new versions of the modules that depend on the
    record definition
3. Transform the mnesia table
4. Let your processes continue (sys:resume(Pid))

Then, your wildcard syntax will work, and be consistent with
the representation in the mnesia table.

My other alternative retrieves the record information from
mnesia and will always work, but comes with a runtime
penalty.

BR,
Ulf W


From pfisher@REDACTED  Fri May  9 20:38:29 2008
From: pfisher@REDACTED (Paul Fisher)
Date: Fri, 09 May 2008 13:38:29 -0500
Subject: [erlang-questions] mod_esi should return 400 status for missing
	function
Message-ID: <1210358309.15666.55.camel@localhost>

If a Module/Function request matching an erl_script_alias registration
does not exist as a function in the module registered, the current
implementation returns a "500 Internal Server Error", rather than a more
appropriate "400 Bad Request".

Here is a patch that does this:

--- inets/src/http_server/mod_esi.erl.orig      2008-05-09 13:09:07.000000000 -0500
+++ inets/src/http_server/mod_esi.erl   2008-05-09 13:13:52.000000000 -0500
@@ -287,6 +287,9 @@
 %% before anythig is sent back to the client.
 erl_scheme_webpage_whole(Module, Function, Env, Input, ModData) ->
     case (catch Module:Function(Env, Input)) of
+       {'EXIT',{undef, _}} ->
+           {proceed, [{status, {400, ModData#mod.request_uri, "Bad Request"}}
+                      | ModData#mod.data]};
        {'EXIT',Reason} ->
            {proceed, [{status, {500, none, Reason}} |
                       ModData#mod.data]};


-- 
paul



From vinoski@REDACTED  Sat May 10 05:35:44 2008
From: vinoski@REDACTED (Steve Vinoski)
Date: Fri, 9 May 2008 23:35:44 -0400
Subject: [erlang-questions] mod_esi should return 400 status for missing
	function
In-Reply-To: <1210358309.15666.55.camel@localhost>
References: <1210358309.15666.55.camel@localhost>
Message-ID: <65b2728e0805092035la104d50s56db96c269cbc9ae@mail.gmail.com>

On 5/9/08, Paul Fisher  wrote:
> If a Module/Function request matching an erl_script_alias registration
>  does not exist as a function in the module registered, the current
>  implementation returns a "500 Internal Server Error", rather than a more
>  appropriate "400 Bad Request".

Sorry, but 400 is definitely not the right status code for this. The
HTTP spec defines 400 as follows:

"10.4.1 400 Bad Request

The request could not be understood by the server due to malformed
syntax. The client SHOULD NOT repeat the request without
modifications."

In other words, 400 means the request from the client is syntactically
malformed, which does not apply in this case.

500 is the correct error to return for this case. The client is
apparently requesting a known and valid resource, but the server, due
to an incorrect configuration or implementation, is unable to fulfill
the request. The 500 HTTP status code is defined as follows:

"10.5.1 500 Internal Server Error

The server encountered an unexpected condition which prevented it from
fulfilling the request."

which is perfect and exactly right for this scenario.

--steve


From pfisher@REDACTED  Sat May 10 15:57:34 2008
From: pfisher@REDACTED (Paul Fisher)
Date: Sat, 10 May 2008 08:57:34 -0500
Subject: [erlang-questions] mod_esi should return 400 status for	missing
	function
In-Reply-To: <65b2728e0805092035la104d50s56db96c269cbc9ae@mail.gmail.com>
References: <1210358309.15666.55.camel@localhost>
	<65b2728e0805092035la104d50s56db96c269cbc9ae@mail.gmail.com>
Message-ID: <1210427854.15666.75.camel@localhost>

On Fri, 2008-05-09 at 23:35 -0400, Steve Vinoski wrote:
> On 5/9/08, Paul Fisher  wrote:
> > If a Module/Function request matching an erl_script_alias registration
> >  does not exist as a function in the module registered, the current
> >  implementation returns a "500 Internal Server Error", rather than a more
> >  appropriate "400 Bad Request".
> 
> Sorry, but 400 is definitely not the right status code for this. The
> HTTP spec defines 400 as follows:
> 
> "10.4.1 400 Bad Request
> 
> The request could not be understood by the server due to malformed
> syntax. The client SHOULD NOT repeat the request without
> modifications."
>
> In other words, 400 means the request from the client is syntactically
> malformed, which does not apply in this case.

?Sorry, but with respect I have to disagree.  I'll admit 404 is probably
a more precise 4xx series response, but it is definitely a *client*
error and and not a *server* error,  ?The client sent a request for an
invalid resource -- a function not being available in the module
responding to this resource path.  This is exactly the same as a request
for a file that is not available in the filesystem directory. ?
Therefore a 4xx and not a 5xx.

404 is doc'd as:

   The server has not found anything matching the Request-URI. No
   indication is given of whether the condition is temporary or
   permanent. The 410 (Gone) status code SHOULD be used if the server
   knows, through some internally configurable mechanism, that an old
   resource is permanently unavailable and has no forwarding address.
   This status code is commonly used when the server does not wish to
   reveal exactly why the request has been refused, or when no other
   response is applicable.

Which is the entirely appropriate response (especially the part about
not revealing why the request was refused.)

?
> 500 is the correct error to return for this case. The client is
> apparently requesting a known and valid resource, but the server, due
> to an incorrect configuration or implementation, is unable to fulfill
> the request. The 500 HTTP status code is defined as follows:
> 
> "10.5.1 500 Internal Server Error
> 
> The server encountered an unexpected condition which prevented it from
> fulfilling the request."
> 
> which is perfect and exactly right for this scenario.

The client is not requesting a "known and valid resource", that is for
the server-side to define, which in the case of mod_esi implementations
is the functions exported from the module(s) registered.  If a valid
mod_esi implementation is registered for a resource path, then by
definition its public methods defined the resource space... since
nothing else possibly could.

It would possible for a 500 to be returned in the case that the module
was registered and did not exist, but that should really be detected
when mod_esi interprets the configuration and checks if the module(s)
named exist.


-- 
paul



From pfisher@REDACTED  Sat May 10 18:48:10 2008
From: pfisher@REDACTED (Paul Fisher)
Date: Sat, 10 May 2008 11:48:10 -0500
Subject: [erlang-questions] mod_esi should return 400 status	for	missing
	function
In-Reply-To: <1210427854.15666.75.camel@localhost>
References: <1210358309.15666.55.camel@localhost>
	<65b2728e0805092035la104d50s56db96c269cbc9ae@mail.gmail.com>
	<1210427854.15666.75.camel@localhost>
Message-ID: <1210438090.15666.94.camel@localhost>

On Sat, 2008-05-10 at 08:57 -0500, Paul Fisher wrote:
> The client is not requesting a "known and valid resource", that is for
> the server-side to define, which in the case of mod_esi implementations
> is the functions exported from the module(s) registered.  If a valid
> mod_esi implementation is registered for a resource path, then by
> definition its public methods defined the resource space... since
> nothing else possibly could.

As an example, the Googles gdata API documentation seems to support this
interpretation:

?http://code.google.com/apis/gdata/reference.html#http-status-codes

Specifically this bit:

"Passing a standard parameter not understood by a given service results
in a 403 Forbidden response. Passing an unsupported nonstandard
parameter results in a 400 Bad Request response. For information on
other status codes..."

In the mod_esi case we are talking about passing a resource component
(e.g. the Function in the resource names ".../Module:Function" or
".../Module/Function") which is an expected component of the resource
path that is expected by mod_esi structure, but not understood by the
service implementation (i.e. function not defined).  I'm not sure that I
agree with their use of 403, since I have always reserved that for
authentication/access control issues, but fundamentally we are talking
about 4xx series errors.

I stand by my patch with a 404 response code:

--- inets/src/http_server/mod_esi.erl.orig      2008-05-09 13:09:07.000000000 -0500
+++ inets/src/http_server/mod_esi.erl   2008-05-10 11:46:03.000000000 -0500
@@ -287,6 +287,9 @@
 %% before anythig is sent back to the client.
 erl_scheme_webpage_whole(Module, Function, Env, Input, ModData) ->
     case (catch Module:Function(Env, Input)) of
+       {'EXIT',{undef, _}} ->
+           {proceed, [{status, {404, ModData#mod.request_uri, "Not found"}}
+                      | ModData#mod.data]};
        {'EXIT',Reason} ->
            {proceed, [{status, {500, none, Reason}} |
                       ModData#mod.data]};



-- 
paul



From vinoski@REDACTED  Sat May 10 21:05:56 2008
From: vinoski@REDACTED (Steve Vinoski)
Date: Sat, 10 May 2008 15:05:56 -0400
Subject: [erlang-questions] mod_esi should return 400 status for missing
	function
In-Reply-To: <1210438090.15666.94.camel@localhost>
References: <1210358309.15666.55.camel@localhost>
	<65b2728e0805092035la104d50s56db96c269cbc9ae@mail.gmail.com>
	<1210427854.15666.75.camel@localhost>
	<1210438090.15666.94.camel@localhost>
Message-ID: <65b2728e0805101205o57a33bb5n72b08304f76a8841@mail.gmail.com>

On 5/10/08, Paul Fisher  wrote:
> On Sat, 2008-05-10 at 08:57 -0500, Paul Fisher wrote:
>  > The client is not requesting a "known and valid resource", that is for
>  > the server-side to define, which in the case of mod_esi implementations
>  > is the functions exported from the module(s) registered.  If a valid
>  > mod_esi implementation is registered for a resource path, then by
>  > definition its public methods defined the resource space... since
>  > nothing else possibly could.

Yes, this explanation makes sense.

> As an example, the Googles gdata API documentation seems to support this
>  interpretation:
>
>  ?http://code.google.com/apis/gdata/reference.html#http-status-codes
>
>  Specifically this bit:
>
>  "Passing a standard parameter not understood by a given service results
>  in a 403 Forbidden response. Passing an unsupported nonstandard
>  parameter results in a 400 Bad Request response. For information on
>  other status codes..."
>
>  In the mod_esi case we are talking about passing a resource component
>  (e.g. the Function in the resource names ".../Module:Function" or
>  ".../Module/Function") which is an expected component of the resource
>  path that is expected by mod_esi structure, but not understood by the
>  service implementation (i.e. function not defined).  I'm not sure that I
>  agree with their use of 403, since I have always reserved that for
>  authentication/access control issues, but fundamentally we are talking
>  about 4xx series errors.

Actually 403 is correct for their case. 403, according to the spec,
means "the server understood the request but is refusing to fulfill
it." 401 is the more appropriate code for authentication and access
control issues.

>  I stand by my patch with a 404 response code:

Based on your explanation in your previous message and this one, I
fully agree that 404, but definitely not 400, is correct.

--steve

From wenewboy@REDACTED  Sun May 11 00:30:51 2008
From: wenewboy@REDACTED (wenew zhang)
Date: Sun, 11 May 2008 06:30:51 +0800
Subject: [erlang-questions] How to start a .app from os's shell
Message-ID: <4eaa09eb0805101530t56bae2cfp2ddb0cd3e4e4c060@mail.gmail.com>

i have a .app file,when i want start it,i must start erl-shell and then type
"application:start(myerlang.app).",
i want start is in os's shell howto do that?

Best Regards
Wenew Zhang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From wenewboy@REDACTED  Sun May 11 00:38:11 2008
From: wenewboy@REDACTED (wenew zhang)
Date: Sun, 11 May 2008 06:38:11 +0800
Subject: [erlang-questions] Cant't start odbc from .app file
Message-ID: <4eaa09eb0805101538i4d44451bj8d4b17218d7ecec2@mail.gmail.com>

authserver.app
{application, authserver,
 [
  {description, "Authory TCP server"},
  {vsn, "1.0"},
  {id, "authserver"},
  {modules,      [authserver]},
  {registered,   [authserver]},
  {applications, [kernel, stdlib, odbc]},
  %%
  %% mod: Specify the module name to start the application, plus args
  %%
  {mod, {auth_sup, []}},
  {env, []}
 ]
}.
i try put odbc in modules,registered ,it doesn't  work too,
my os is:Ubuntu 8.04

Best Regards

Wenew Zhang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From david.hopwood@REDACTED  Sun May 11 00:55:18 2008
From: david.hopwood@REDACTED (David-Sarah Hopwood)
Date: Sat, 10 May 2008 23:55:18 +0100
Subject: [erlang-questions] Printing of floating-point numbers (was: Strange
	arithmetic behaviour)
In-Reply-To: <14f0e3620805080220i67dc9a2ckcc8ab03568639a00@mail.gmail.com>
References: <85d11a2e0805080142x2b9d9615mbe8a6dd7e1b4aa87@mail.gmail.com>
	<14f0e3620805080220i67dc9a2ckcc8ab03568639a00@mail.gmail.com>
Message-ID: <482627D6.4000907@industrial-designers.co.uk>

Gleb Peregud wrote:
> These are results from Python interactive shell:
> 
>>>> 123123123123123123123.0 - 123123123123123123121.0
> 0.0
>>>> print '%f' % math.floor(1233333333333333123333333333.12311111111);
> 1233333333333333065680814080.000000
>>>> print '%f' % 1233333333333333123333333333.12311111111
> 1233333333333333065680814080.000000
> 
> As you can see results are the same. I think it is because of internal
> IEEE-something floating point number representation. As you can see in
> the last example, number "1233333333333333123333333333.12311111111" is
> converted to "1233333333333333065680814080.000000" without applying to
> it any operations. Probably it is because internal float
> representation does not allow this precision in this particular
> situation

However, these examples show that neither Erlang nor Python are using
"parsimonious printing" of floating-point numbers. The results under
parsimonious printing would have the minimum number of digits of
precision needed to reproduce the floating-point number exactly.
There is a fair degree of concensus that this is the Right Thing for
any programming language. See for example
.

> On 5/8/08, Gurgen Tumanian  wrote:
>> Dear all.
>>
>> There is some kind of strange behaviour that i have noticed when dealing
>> with big float values. [...]
>> furthermore
>> 1233333333333333123333333333.12311111111 =
>> 123333333333333312367575676573.92311111111 matches

There is probably a typo here; these do not match.

Raimo Niskanen wrote:
> And I would not want to write the library that does e.g
> sin, cos, tan, asin, acos, atan, pow, exp, erf
> for a given arbitrary rounding strategy.
> Someone else?

Google "arbitrary precision floating point". (Some of the listed libraries
do arbitrary rounding strategies, some don't.) IMHO arbitrary-precision
floating point belongs in the standard library of any modern programming
language (excluding library profiles targetted to embedded systems).

-- 
David-Sarah Hopwood


From erlangy@REDACTED  Sun May 11 01:29:58 2008
From: erlangy@REDACTED (Michael McDaniel)
Date: Sat, 10 May 2008 16:29:58 -0700
Subject: [erlang-questions] Cant't start odbc from .app file
In-Reply-To: <4eaa09eb0805101538i4d44451bj8d4b17218d7ecec2@mail.gmail.com>
References: <4eaa09eb0805101538i4d44451bj8d4b17218d7ecec2@mail.gmail.com>
Message-ID: <20080510232958.GX8868@delora.autosys.us>

On Sun, May 11, 2008 at 06:38:11AM +0800, wenew zhang wrote:
> authserver.app
> {application, authserver,
>  [
>   {description, "Authory TCP server"},
>   {vsn, "1.0"},
>   {id, "authserver"},
>   {modules,      [authserver]},
>   {registered,   [authserver]},
>   {applications, [kernel, stdlib, odbc]},
>   %%
>   %% mod: Specify the module name to start the application, plus args
>   %%
>   {mod, {auth_sup, []}},
>   {env, []}
>  ]
> }.
> i try put odbc in modules,registered ,it doesn't  work too,
> my os is:Ubuntu 8.04
> 
> Best Regards
> 
> Wenew Zhang

> _______________________________________________

 Look at release file documentation.

 For example (adjust versions for your installation) ...

{release, {"OTP  APN 181 01","R12B"}, {erts, "5.6"},
 [  {kernel,"2.12"}
  , {stdlib,"1.15"}
  , {sasl,"2.1.5.2"}
  , {my_app, "0.9"}
  , {mnesia,"4.4"}
%  , {odbc, "2.0.9"}
%  , {os_mon,"2.1.3"}
%  , {ssl,"3.9"}
 ]
}.

 Then (if above filename was start_my_app.rel)
 
erl> systools:make_script("start_my_app",[]).

 which creates start_my_app.boot and start_my_app.script both
 of which I copy to the ebin directory.


 Example sys.config ...
 Copied in part or based on elog3.config from Joe Armstrong's new book,
 _Programming_Erlang_ ...


[{mnesia, [{dir,"./Mnesia.my_app"}  ,
%%           {debug, trace}                   ,            
             {schema_location, disc}]},
 {kernel,
  [    
   {start_timer, true} ,
   {inet_dist_listen_min, 4369},
   {inet_dist_listen_max, 4371}   
  ]} ,

{sasl, [
         {sasl_error_logger, false},
         %% define the parameters of the rotating log
         %% the log file directory
         {error_logger_mf_dir,"./error_logs"},
         %% # bytes per logfile
         {error_logger_mf_maxbytes,10485760}, % 10 MB
         %% maximum number of logfiles
         {error_logger_mf_maxfiles, 10}
        ]}
].


 Then, from the command line,

$ erl  -name my_app  -heart  -pa my_app/ebin  -boot my_app/ebin/start_my_app
  -config my_app/ebin/sys.config  -home ${HOME}  -setcookie fake  -detached


 The above presumes the starting directory is just above my_app directory
 which has typical OTP structure
 my_app/
        ebin/
     include/
        priv/
         src/


~Michael


From ahmed.nawras@REDACTED  Sun May 11 09:21:27 2008
From: ahmed.nawras@REDACTED (Ahmed Ali)
Date: Sun, 11 May 2008 11:21:27 +0400
Subject: [erlang-questions] How to start a .app from os's shell
In-Reply-To: <4eaa09eb0805101530t56bae2cfp2ddb0cd3e4e4c060@mail.gmail.com>
References: <4eaa09eb0805101530t56bae2cfp2ddb0cd3e4e4c060@mail.gmail.com>
Message-ID: 

Hi,

This has been raised a couple of days ago :). You can
Try:

erl -noshell -s application start myerlang

Best regards,

Ahmed Al-Issaei

2008/5/11 wenew zhang :
> i have a .app file,when i want start it,i must start erl-shell and then type
> "application:start(myerlang.app).",
> i want start is in os's shell howto do that?
>
> Best Regards
> Wenew Zhang
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>


From szabolcs.berecz@REDACTED  Sun May 11 13:05:14 2008
From: szabolcs.berecz@REDACTED (Szabolcs Berecz)
Date: Sun, 11 May 2008 15:35:14 +0430
Subject: [erlang-questions] managing large records
Message-ID: 

Hi,

I have a record with a lot of fields which are updated nontrivially. I
tried to create a process for this task which looks like this:

-record(mm, {a=1,b=4,c}).

new() ->
        loop(#mm{}).

loop(Mm) ->
        receive
                {set, Field, Value} ->
                        loop(Mm#mm{Field=Value});
                {get, Pid} ->
                        Pid ! Mm,
                        loop(Mm)
        end.

But as you probably know, it doesn't work because it needs to now the
value of Field at compile time (or at least, that's what I have
concluded).
So, my question is: how would you solve the problem (lot's of fields,
almost random updates)?

Szabi

-- 
DRM: Digital Restrictions Management -- learn about the dangers at
http://www.defectivebydesign.org/what_is_drm


From cthulahoops@REDACTED  Sun May 11 13:25:22 2008
From: cthulahoops@REDACTED (Adam Kelly)
Date: Sun, 11 May 2008 12:25:22 +0100
Subject: [erlang-questions] managing large records
In-Reply-To: 
References: 
Message-ID: <8d1798e90805110425q43392925g64f67ba2419731f7@mail.gmail.com>

> So, my question is: how would you solve the problem (lot's of fields,
> almost random updates)?

new() ->
       loop(dict:new()).

loop(Mm) ->
    receive
        {set, Field, Value} ->
             loop(dict:store(Field, Value, Mm));
        {get, Pid} ->
             Pid ! Mm,
             loop(Mm)
    end.

Something roughly like that anyway.  Have a look at the documentation for dict.

Adam.


From ulf@REDACTED  Sun May 11 13:26:12 2008
From: ulf@REDACTED (Ulf Wiger)
Date: Sun, 11 May 2008 13:26:12 +0200
Subject: [erlang-questions] managing large records
In-Reply-To: 
References: 
Message-ID: <8209f740805110426y33218901ifc0dfa248b714477@mail.gmail.com>

You could try exprecs:

http://forum.trapexit.org/viewtopic.php?p=21790#21790

BR,
Ulf W


2008/5/11 Szabolcs Berecz :
> Hi,
>
>  I have a record with a lot of fields which are updated nontrivially. I
>  tried to create a process for this task which looks like this:
>
>  -record(mm, {a=1,b=4,c}).
>
>  new() ->
>         loop(#mm{}).
>
>  loop(Mm) ->
>         receive
>                 {set, Field, Value} ->
>                         loop(Mm#mm{Field=Value});
>                 {get, Pid} ->
>                         Pid ! Mm,
>                         loop(Mm)
>         end.
>
>  But as you probably know, it doesn't work because it needs to now the
>  value of Field at compile time (or at least, that's what I have
>  concluded).
>  So, my question is: how would you solve the problem (lot's of fields,
>  almost random updates)?
>
>  Szabi
>
>  --
>  DRM: Digital Restrictions Management -- learn about the dangers at
>  http://www.defectivebydesign.org/what_is_drm
>  _______________________________________________
>  erlang-questions mailing list
>  erlang-questions@REDACTED
>  http://www.erlang.org/mailman/listinfo/erlang-questions
>


From matthew@REDACTED  Sun May 11 13:43:13 2008
From: matthew@REDACTED (Matthew Dempsky)
Date: Sun, 11 May 2008 04:43:13 -0700
Subject: [erlang-questions] managing large records
In-Reply-To: 
References: 
Message-ID: 

On Sun, May 11, 2008 at 4:05 AM, Szabolcs Berecz
 wrote:
> I have a record with a lot of fields which are updated nontrivially.

Why are you using a record instead of dict/gb_trees/ets/...?


From wenewboy@REDACTED  Sun May 11 15:54:48 2008
From: wenewboy@REDACTED (wenew zhang)
Date: Sun, 11 May 2008 21:54:48 +0800
Subject: [erlang-questions] How to start a .app from os's shell
In-Reply-To: 
References: <4eaa09eb0805101530t56bae2cfp2ddb0cd3e4e4c060@mail.gmail.com>
	
Message-ID: <4eaa09eb0805110654n4a9397eag7633fe70d004d91d@mail.gmail.com>

my startup command as below:
erl -name socketservernode@REDACTED -setcookie abc -boot
start_sasl -config socketlog -noshell -s application start socketserver &
but it doesn't work,
What's wrong with it?

Wenew Zhang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From judgefang@REDACTED  Sun May 11 16:07:49 2008
From: judgefang@REDACTED (Patrick Roemer)
Date: Sun, 11 May 2008 16:07:49 +0200
Subject: [erlang-questions] eunit, fixtures and processes
Message-ID: <4826FDB5.70206@gmail.com>

Hi,

as an Erlang novice, I'm currently struggling with the correct way to
set up eunit tests involving processes and fixtures.

The basic idea is this: Create the "server process under test" (PUT) on
setup, pass self() (the test module process) as a mock client process,
and register the PUT with a name used for lookup within the test cases.
Stop the PUT on teardown. (Note that it is intended that the client is
carried around as state for the whole life cycle.)

This seems to work nicely, but now I'd like to avoid the registration
and pass the PUT PID around as a fixture instead. But trying this, I
suddenly run into trouble, because the process running setup (and
registering self() as the mock client) is a different one than the
process running the actual test case, expecting to receive messages from
the server.

The eunit documentation suggests "local" mode (instead of the "spawn"
default) to run setup/teardown and tests in the same process. However,
in my setup this only works for the first test case, subsequent ones
still seem to run in dedicated processes.

My best guess that I still haven't groked the basic mechanics and idioms
of fixture setup and instantiators in eunit. I have tried to express
test creation in different ways, but almost always ended up with "bad
test" failures. :( Or is the test design as such inappropriate? I have
attached a minimalist sample below. If somebody please could push me
into the right direction - any help appreciated.

Best regards,
Patrick

Code:

-module(fixture_sample).

-include_lib("eunit/include/eunit.hrl").

-export([echo/1]).

-define(TIMEOUT, 50).

echo(Client) ->
    receive
        stop -> void;
        Msg ->
            eunit:debug({'echo', Client, Msg}),
            Client ! {echo, Msg},
            echo(Client)
    end.

all_tests_test_() ->
    {foreach, local,
        fun test_setup/0,
        fun test_tear_down/1,
        [
            instantiate_test(fun test_one/1),
            instantiate_test(fun test_two/1)
        ]
    }.

test_setup() ->
    eunit:debug({'setup', self()}),
    spawn(?MODULE, echo, [self()]).

test_tear_down(Server) ->
        eunit:debug({'teardown', self()}),
        Server ! stop.

test_one(Server) ->
    eunit:debug({'test one', self()}),
    assert_echo(Server, 'Hello').

test_two(Server) ->
    eunit:debug({'test two', self()}),
    assert_echo(Server, 'Hello2').

assert_echo(Server, Msg) ->
    Server ! Msg,
    receive
        {echo, Msg} -> ok
    after ?TIMEOUT ->
        throw("Message expected")
    end.

instantiate_test(Fun) ->
    fun(Fixture) ->
        eunit:debug({'instantiate', self()}),
        ?_test(Fun(Fixture)) end.


Output:

*eunit debug*: {instantiate,<0.48.0>}
*eunit debug*: {instantiate,<0.48.0>}
*eunit debug*: {setup,<0.284.0>}
*eunit debug*: {instantiate,<0.284.0>}
*eunit debug*: {'test one',<0.284.0>}
*eunit debug*: {echo,<0.284.0>,'Hello'}
*eunit debug*: {teardown,<0.284.0>}
*eunit debug*: {setup,<0.284.0>}
*eunit debug*: {instantiate,<0.284.0>}
*eunit debug*: {'test two',<0.288.0>}  <-- another process?!
*eunit debug*: {echo,<0.284.0>,'Hello2'}
fixture_sample:55:instantiate_test...*eunit debug*: {teardown,<0.284.0>}
*failed*
::throw:"Message expected"
  in function fixture_sample:assert_echo/2



From thomasl_erlang@REDACTED  Sun May 11 20:35:28 2008
From: thomasl_erlang@REDACTED (Thomas Lindgren)
Date: Sun, 11 May 2008 11:35:28 -0700 (PDT)
Subject: [erlang-questions] managing large records
In-Reply-To: 
Message-ID: <18209.54302.qm@web38804.mail.mud.yahoo.com>


--- Szabolcs Berecz  wrote:

> Hi,
> 
> I have a record with a lot of fields which are
> updated nontrivially. I
> tried to create a process for this task which looks
> like this:
> 
> -record(mm, {a=1,b=4,c}).
> 
> new() ->
>         loop(#mm{}).
> 
> loop(Mm) ->
>         receive
>                 {set, Field, Value} ->
>                         loop(Mm#mm{Field=Value});
>                 {get, Pid} ->
>                         Pid ! Mm,
>                         loop(Mm)
>         end.
> 
> But as you probably know, it doesn't work because it
> needs to now the
> value of Field at compile time (or at least, that's
> what I have
> concluded).
> So, my question is: how would you solve the problem
> (lot's of fields,
> almost random updates)?

As mentioned before, dict or similar is probably a
fine choice. Another option is to roll your own:

0. Map field names to integers by hand.

n(field_1) -> 1;
...
n(field_k) -> K;
n(_) -> exit(unknown_field).


1. represent the fields as a tuple Rec of K elements,
with elements starting as undefined (for instance)

2. Read/write the fields using

     element(n(Field), Rec)
     setelement(n(Field), Rec, Value)

Best,
Thomas


      ____________________________________________________________________________________
Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ


From hferreiro@REDACTED  Fri May  9 19:17:30 2008
From: hferreiro@REDACTED (Henrique Ferreiro =?ISO-8859-1?Q?Garc=EDa?=)
Date: Fri, 09 May 2008 19:17:30 +0200
Subject: [erlang-questions] Erlang Core problem
Message-ID: <1210353450.11246.6.camel@macbook>

Hello,

I have a problem when compiling from Core:

$ erlc +to_core list.erl
$ erlc +from_core list.core
./list.core:21: syntax error before: LITERAL

Looking at the Core Erlang language specification, there doesn't seem to
exist such a construction.

Can anyone explain what is happening here?

-- 
Henrique Ferreiro Garc?a 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: list.erl
Type: text/x-erlang
Size: 83 bytes
Desc: not available
URL: 
-------------- next part --------------
module 'list' ['len'/1,
	       'module_info'/0,
	       'module_info'/1]
    attributes []
'len'/1 =
    %% Line 4
    fun (_cor0) ->
	case _cor0 of
	  <[_cor3|Xs]> when 'true' ->
	      let <_cor1> =
		  apply 'len'/1
		      (Xs)
	      in  call 'erlang':'+'
		      (1, _cor1)
	  %% Line 5
	  <[]> when 'true' ->
	      0
	  ( <_cor2> when 'true' ->
		primop 'match_fail'
		    ({'function_clause',_cor2})
	    -| LITERAL<[compiler_generated]> )
	end
'module_info'/0 =
    fun () ->
	call 'erlang':'get_module_info'
	    ('list')
'module_info'/1 =
    fun (_cor0) ->
	call 'erlang':'get_module_info'
	    ('list', _cor0)
end
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Esta ? unha parte de mensaxe asinada	dixitalmente
URL: 

From per@REDACTED  Sun May 11 22:08:43 2008
From: per@REDACTED (Per Hedeland)
Date: Sun, 11 May 2008 22:08:43 +0200 (CEST)
Subject: [erlang-questions] Changing time
Message-ID: <200805112008.m4BK8hCZ074013@pluto.hedeland.org>

Hi,

The Erlang emulator includes some sophisticated code to deal with sudden
changes to the system time, which tries to maintain "delta" timers such
as 'receive ... after' while gradually adapting time-of-day as seen by
the emulator to agree with with the new system time.

Unfortunately this code works only on Linux and Solaris (maybe on
Windows too, I wouldn't know) - on other systems, e.g. *BSD, you can
play this game:

1. Start erlang.
2. Set the system time back by, say, 5 minutes.
3. Invoke timer:sleep(1).
4. Watch the call take 5 minutes to complete.

Now, system time "shouldn't" move backwards, but in real life it
sometimes does, and "don't do that" isn't always a viable response. And
while "weird" things may happen to timers that are running across the
time change, I think it definitely violates the POLA that timers started
*after* the time change are completely broken.

A suggested fix is below (diff against R12B-2) - as far as I can see, it
will work pretty well both for timers running across the time change and
for timers started after it - worst case it will cause one timer to have
double the requested timeout, but once the new system time has been
discovered, it should Do the Right Thing, and it's independent of the
magnitude of the time change.

By the way, the discussion about the +c option in the erl(1) man page is
wrong - Erlang timers are not based on erlang:now/0. Timers and
erlang:now/0 use the same underlying timing mechanism, which may or may
not have compensation for "sudden changes of system time" depending on
the OS and the usage of +c, but erlang:now/0 fulfills its promise of
delivering monotonously increasing numbers regardless - also with the
patch below.

--Per Hedeland

--- erts/emulator/beam/erl_time_sup.c.orig	2008-04-07 15:58:13.000000000 +0200
+++ erts/emulator/beam/erl_time_sup.c	2008-05-09 23:15:39.000000000 +0200
@@ -383,13 +383,12 @@
 	CLOCK_RESOLUTION;
 
     /* Sometimes the time jump backwards,
-       resulting in a negative elapsed time. We compensate for
-       this by simply pretend as if the time stood still. :) */
+       resulting in a negative elapsed time. */
 
     if (elapsed > 0) {
 	do_time_add(elapsed);
-	last_delivered = cur_time;
     }
+    last_delivered = cur_time;
 }
 #endif
 





From richardc@REDACTED  Sun May 11 22:14:35 2008
From: richardc@REDACTED (Richard Carlsson)
Date: Sun, 11 May 2008 22:14:35 +0200
Subject: [erlang-questions] eunit, fixtures and processes
In-Reply-To: <4826FDB5.70206@gmail.com>
References: <4826FDB5.70206@gmail.com>
Message-ID: <482753AB.6040500@it.uu.se>

Patrick Roemer wrote:
> The eunit documentation suggests "local" mode (instead of the "spawn"
> default) to run setup/teardown and tests in the same process. However,
> in my setup this only works for the first test case, subsequent ones
> still seem to run in dedicated processes.

You found a bug! I've just fixed it; do try again with the latest
version at https://svn.process-one.net/contribs/trunk/eunit - I hope
that is all it takes. (The bug affected both foreach and foreachx.)

I have also removed the old undocumented function 'eunit:debug(X)'.
Instead, use the macro ?debugVal(X) or any of the other debug macros
(found at the end of eunit.hrl) - they will eventually be documented.

Thanks for the report!

     /Richard


-- 
  "Having users is like optimization: the wise course is to delay it."
    -- Paul Graham


From eric@REDACTED  Sun May 11 22:25:31 2008
From: eric@REDACTED (Eric Maland)
Date: Sun, 11 May 2008 13:25:31 -0700
Subject: [erlang-questions] Writing gen_servers with TCP listeners
Message-ID: <20548630-880B-4034-8957-B3ED51B16CF1@ackack.com>

Hello,

I am having some trouble writing a gen_server that is a tcp listener  
that works outside the shell.

My goal has been to write a gen_server that starts listening on a  
socket and manages a connection pool of accept()-ors.  This seems like  
a pretty standard behaviour and is very easy to implement, but every  
implementation I've produced runs perfectly in the shell but not in an  
erl instance without a shell.

This sort of problem seems to be referenced in a previous thread (http://www.erlang.org/pipermail/erlang-questions/2008-January/032400.html 
  ), but I have found 0 examples of how to apply the information there  
to a gen_server - clearly the server needs to live forever, but how do  
you get a gen_server to hang around?  Is it acceptable to implement a  
handle_call() that just does a receive after infinity -> foo end ???   
Who would call that?  I have tried that, and it seemed like after 10  
or so requests the server died (presumably on some timeout from the  
supervisor insantiating it??).

I found a great example of a gen_server tcp listener at http://www.duomark.com/erlang/tutorials/proxy.html 
   but this also exhibits the same problem outside the shell - it  
serves one request and then the socket is closed.

Does anyone have or know of a great tcp listener example that works  
outside the shell (eg started with: 'erl -boot start_sasl -s mymodule  
start'), or another interesting way to resolve this, specifically when  
writing  gen_server?

Here are some models I have gone through, all of which work in the  
shell but not outside the shell:

gen_server:init listen()'s ->
   spawn()'s a connection pool ->
     each pool process accept()'s and spawns another pool process

In the shell: works fine
Outside the shell: 2nd and subsequent accept() fails

gen_server:init listen()'s ->
   gen_server:init calls gen_server:cast(accept_loop) ->
     accept_loop loops forever, spawning handlers on each request (and  
gen_tcp:controlling_process the associated connections over to the  
processes)

In the shell: works fine
Outside the shell: 2nd and subsequent accept() fails

These all work great in the shell but serve 1-2 requests (depending on  
your platform) outside the shell before the socket closes.

Any advice on how to properly get the owner of the listening socket to  
stick around in a gen_server would be appreciated.

Thanks!
Eric


References:
1. http://www.erlang.org/pipermail/erlang-questions/2008-January/032400.html
2. http://www.duomark.com/erlang/tutorials/proxy.html


From hferreiro@REDACTED  Sun May 11 15:39:32 2008
From: hferreiro@REDACTED (Henrique Ferreiro =?ISO-8859-1?Q?Garc=EDa?=)
Date: Sun, 11 May 2008 15:39:32 +0200
Subject: [erlang-questions] Core Erlang problem
Message-ID: <1210513173.6666.3.camel@macbook>

Hello,

I have a problem when compiling from Core:

$ erlc +to_core list.erl
$ erlc +from_core list.core
./list.core:21: syntax error before: LITERAL

Looking at the Core Erlang language specification, there doesn't seem to
exist such a construction.

Can anyone explain what is happening here?

-- 
Henrique Ferreiro Garc?a 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: list.erl
Type: text/x-erlang
Size: 78 bytes
Desc: not available
URL: 
-------------- next part --------------
module 'list' ['len'/1,
	       'module_info'/0,
	       'module_info'/1]
    attributes []
'len'/1 =
    %% Line 4
    fun (_cor0) ->
	case _cor0 of
	  <[_cor3|Xs]> when 'true' ->
	      let <_cor1> =
		  apply 'len'/1
		      (Xs)
	      in  call 'erlang':'+'
		      (1, _cor1)
	  %% Line 5
	  <[]> when 'true' ->
	      0
	  ( <_cor2> when 'true' ->
		primop 'match_fail'
		    ({'function_clause',_cor2})
	    -| LITERAL<[compiler_generated]> )
	end
'module_info'/0 =
    fun () ->
	call 'erlang':'get_module_info'
	    ('list')
'module_info'/1 =
    fun (_cor0) ->
	call 'erlang':'get_module_info'
	    ('list', _cor0)
end

From richardc@REDACTED  Sun May 11 22:42:05 2008
From: richardc@REDACTED (Richard Carlsson)
Date: Sun, 11 May 2008 22:42:05 +0200
Subject: [erlang-questions] Erlang Core problem
In-Reply-To: <1210353450.11246.6.camel@macbook>
References: <1210353450.11246.6.camel@macbook>
Message-ID: <48275A1D.4050104@it.uu.se>

Henrique Ferreiro Garc?a wrote:
> I have a problem when compiling from Core:
> 
> $ erlc +to_core list.erl
> $ erlc +from_core list.core
> ./list.core:21: syntax error before: LITERAL
> 
> Looking at the Core Erlang language specification, there doesn't seem to
> exist such a construction.
> 
> Can anyone explain what is happening here?

Looks like a minor prettyprinter bug. (It thinks that it has found
something weird in the abstract syntax tree, and marks it up in a
funny way to make it more visible, but that makes the code impossible
to parse back. But the syntax tree was actually correct.)

However, I think that has been fixed in recent releases. What version
of Erlang/OTP are you using?

     /Richard

-- 
  "Having users is like optimization: the wise course is to delay it."
    -- Paul Graham


From hferreiro@REDACTED  Sun May 11 23:22:19 2008
From: hferreiro@REDACTED (Henrique Ferreiro =?ISO-8859-1?Q?Garc=EDa?=)
Date: Sun, 11 May 2008 23:22:19 +0200
Subject: [erlang-questions] Erlang Core problem
In-Reply-To: <48275A1D.4050104@it.uu.se>
References: <1210353450.11246.6.camel@macbook>  <48275A1D.4050104@it.uu.se>
Message-ID: <1210540940.6655.2.camel@macbook>

R11B. Do you know in which one was it fixed?

O Dom, 11-05-2008 ?s 22:42 +0200, Richard Carlsson escribiu:
> Henrique Ferreiro Garc?a wrote:
> > I have a problem when compiling from Core:
> > 
> > $ erlc +to_core list.erl
> > $ erlc +from_core list.core
> > ./list.core:21: syntax error before: LITERAL
> > 
> > Looking at the Core Erlang language specification, there doesn't seem to
> > exist such a construction.
> > 
> > Can anyone explain what is happening here?
> 
> Looks like a minor prettyprinter bug. (It thinks that it has found
> something weird in the abstract syntax tree, and marks it up in a
> funny way to make it more visible, but that makes the code impossible
> to parse back. But the syntax tree was actually correct.)
> 
> However, I think that has been fixed in recent releases. What version
> of Erlang/OTP are you using?
> 
>      /Richard
> 
-- 
Henrique Ferreiro Garc?a 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Esta ? unha parte de mensaxe asinada	dixitalmente
URL: 

From rvirding@REDACTED  Mon May 12 00:01:48 2008
From: rvirding@REDACTED (Robert Virding)
Date: Mon, 12 May 2008 00:01:48 +0200
Subject: [erlang-questions] Erlang Core problem
In-Reply-To: <1210540940.6655.2.camel@macbook>
References: <1210353450.11246.6.camel@macbook> <48275A1D.4050104@it.uu.se>
	<1210540940.6655.2.camel@macbook>
Message-ID: <3dbc6d1c0805111501y4dee1elcd3606389133450b@mail.gmail.com>

It seems to be fixed in R12B. At least I can find nothing in the code which
would generate such an output. Generally I found when working with LFE that
some of the Core erlang support modules weren't really up to date. This is
not that strange as they not really used by the compiler, I added them more
for fun as an added feature.

Robert

2008/5/11 Henrique Ferreiro Garc?a :

> R11B. Do you know in which one was it fixed?
>
> O Dom, 11-05-2008 ?s 22:42 +0200, Richard Carlsson escribiu:
> > Henrique Ferreiro Garc?a wrote:
> > > I have a problem when compiling from Core:
> > >
> > > $ erlc +to_core list.erl
> > > $ erlc +from_core list.core
> > > ./list.core:21: syntax error before: LITERAL
> > >
> > > Looking at the Core Erlang language specification, there doesn't seem
> to
> > > exist such a construction.
> > >
> > > Can anyone explain what is happening here?
> >
> > Looks like a minor prettyprinter bug. (It thinks that it has found
> > something weird in the abstract syntax tree, and marks it up in a
> > funny way to make it more visible, but that makes the code impossible
> > to parse back. But the syntax tree was actually correct.)
> >
> > However, I think that has been fixed in recent releases. What version
> > of Erlang/OTP are you using?
> >
> >      /Richard
> >
> --
> Henrique Ferreiro Garc?a 
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From judgefang@REDACTED  Sun May 11 23:47:35 2008
From: judgefang@REDACTED (Patrick Roemer)
Date: Sun, 11 May 2008 23:47:35 +0200
Subject: [erlang-questions] eunit, fixtures and processes
In-Reply-To: <482753AB.6040500@it.uu.se>
References: <4826FDB5.70206@gmail.com> <482753AB.6040500@it.uu.se>
Message-ID: <48276977.8070106@gmail.com>

Responding to Richard Carlsson:

>> The eunit documentation suggests "local" mode (instead of the "spawn"
>> default) to run setup/teardown and tests in the same process. However,
>> in my setup this only works for the first test case, subsequent ones
>> still seem to run in dedicated processes.
> 
> You found a bug! I've just fixed it; do try again with the latest
> version at https://svn.process-one.net/contribs/trunk/eunit - I hope
> that is all it takes. (The bug affected both foreach and foreachx.)

Thanks a lot for the very quick fix and answer! Works like a charm now. :)

Best regards,
Patrick


From dave@REDACTED  Mon May 12 00:48:32 2008
From: dave@REDACTED (Dave Peticolas)
Date: Sun, 11 May 2008 15:48:32 -0700
Subject: [erlang-questions] Writing gen_servers with TCP listeners
In-Reply-To: <20548630-880B-4034-8957-B3ED51B16CF1@ackack.com>
References: <20548630-880B-4034-8957-B3ED51B16CF1@ackack.com>
Message-ID: <482777C0.7030503@krondo.com>

Eric Maland wrote:
> Hello,
> 
> I am having some trouble writing a gen_server that is a tcp listener  
> that works outside the shell.
> 
> My goal has been to write a gen_server that starts listening on a  
> socket and manages a connection pool of accept()-ors.  This seems like  
> a pretty standard behaviour and is very easy to implement, but every  
> implementation I've produced runs perfectly in the shell but not in an  
> erl instance without a shell.
> 
> This sort of problem seems to be referenced in a previous thread (http://www.erlang.org/pipermail/erlang-questions/2008-January/032400.html 
>   ), but I have found 0 examples of how to apply the information there  
> to a gen_server - clearly the server needs to live forever, but how do  
> you get a gen_server to hang around?  Is it acceptable to implement a  
> handle_call() that just does a receive after infinity -> foo end ???   
> Who would call that?  I have tried that, and it seemed like after 10  
> or so requests the server died (presumably on some timeout from the  
> supervisor insantiating it??).
> 
> I found a great example of a gen_server tcp listener at http://www.duomark.com/erlang/tutorials/proxy.html 
>    but this also exhibits the same problem outside the shell - it  
> serves one request and then the socket is closed.
> 
> Does anyone have or know of a great tcp listener example that works  
> outside the shell (eg started with: 'erl -boot start_sasl -s mymodule  
> start'), or another interesting way to resolve this, specifically when  
> writing  gen_server?
> 
> Here are some models I have gone through, all of which work in the  
> shell but not outside the shell:
> 
> gen_server:init listen()'s ->
>    spawn()'s a connection pool ->
>      each pool process accept()'s and spawns another pool process
> 
> In the shell: works fine
> Outside the shell: 2nd and subsequent accept() fails
> 
> gen_server:init listen()'s ->
>    gen_server:init calls gen_server:cast(accept_loop) ->
>      accept_loop loops forever, spawning handlers on each request (and  
> gen_tcp:controlling_process the associated connections over to the  
> processes)
> 
> In the shell: works fine
> Outside the shell: 2nd and subsequent accept() fails
> 
> These all work great in the shell but serve 1-2 requests (depending on  
> your platform) outside the shell before the socket closes.
> 
> Any advice on how to properly get the owner of the listening socket to  
> stick around in a gen_server would be appreciated.

A gen_server will 'hang around' indefinitely by design, unless you tell
it to stop or one of its callbacks fail. I don't know if this is the
problem, but you need to make sure that the listening socket itself
always has an owner too, not just the sockets created by the listening
socket.

There's an example, by Serge Aleynikov, of how to do a generic tcp
server here:

http://trapexit.org/Building_a_Non-blocking_TCP_server_using_OTP_principles

I packaged it up for erlware (http://erlware.org) and you can install it
with their 'faxien' tool, or just grab the code here:

http://git.krondo.com/?p=erlware/gen_socket.git;a=summary

dave

> Thanks!
> Eric
> 
> 
> References:
> 1. http://www.erlang.org/pipermail/erlang-questions/2008-January/032400.html
> 2. http://www.duomark.com/erlang/tutorials/proxy.html
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
> 



From eric@REDACTED  Mon May 12 02:15:50 2008
From: eric@REDACTED (Eric Maland)
Date: Sun, 11 May 2008 17:15:50 -0700
Subject: [erlang-questions] Writing gen_servers with TCP listeners
In-Reply-To: <482777C0.7030503@krondo.com>
References: <20548630-880B-4034-8957-B3ED51B16CF1@ackack.com>
	<482777C0.7030503@krondo.com>
Message-ID: 

Thanks, this and the oserl code was good reading and extremely  
helpful.  Serge's tutorial is a bit terrifying given the use of  
prim_inet, though.

With your help I did find the solution and it had nothing to do  
(directly) with the relationship between the listening and accepting  
processes.

Here is what my start() looked like (in module 'sissie'):

start() ->
     sissie_db:start(),
     sissie_supervisor:start_link(1042, fun session_manager/1),

This worked fine from the erl console but when run with:

     erl -boot start_sasl -s sissie start

The socket closed immediately, and all the accept()ors failed.

I had made the assumption that since the supervisor starts my  
gen_server and the gen_server creates the listener, as well as spawns  
the accept()ors, that my gen_server's lifetime was what was important  
to the listening socket's longevity.

It turns out my parent module, 'sissie' was the important process due  
to its linkage to the supervisor.  When starting the server from the  
command line rather than the shell, 'sissie' would exit and that exit  
would chain down to the supervisor, its gen_servers, etc.

Any of these changes 'fixes' the problem:

start() ->
     sissie_db:start(),
     sissie_supervisor:start_link(1042, fun session_manager/1),
     receive after infinity -> true end. %%

start() ->
     sissie_db:start(),
     spawn(fun() ->
                   sissie_supervisor:start_link(1042, fun  
session_manager/1),
                   receive after infinity -> true end
           end).

start() ->
     sissie_db:start(),
     {ok, Pid} = sissie_supervisor:start_link(1042, fun  
session_manager/1),
     unlink(Pid).

The latter seems the most explicit, but I have to ask myself if  
there's not a better/prescribed method of starting a system like this  
other than what I'm doing.  I went through Joe Armstrong's book a  
little and found at least one example similar to the above, where the  
'starter' is unlinked from the supervisor at startup, so perhaps this  
is just normal and something that I must get used to.

Clearly I am new to Erlang and OTP.  Thanks again for your help.

Cheers
Eric

On May 11, 2008, at 3:48 PM, Dave Peticolas wrote:

> Eric Maland wrote:
>> Hello,
>> I am having some trouble writing a gen_server that is a tcp  
>> listener  that works outside the shell.
>> My goal has been to write a gen_server that starts listening on a   
>> socket and manages a connection pool of accept()-ors.  This seems  
>> like  a pretty standard behaviour and is very easy to implement,  
>> but every  implementation I've produced runs perfectly in the shell  
>> but not in an  erl instance without a shell.
>> This sort of problem seems to be referenced in a previous thread (http://www.erlang.org/pipermail/erlang-questions/2008-January/032400.html 
>>    ), but I have found 0 examples of how to apply the information  
>> there  to a gen_server - clearly the server needs to live forever,  
>> but how do  you get a gen_server to hang around?  Is it acceptable  
>> to implement a  handle_call() that just does a receive after  
>> infinity -> foo end ???   Who would call that?  I have tried that,  
>> and it seemed like after 10  or so requests the server died  
>> (presumably on some timeout from the  supervisor insantiating it??).
>> I found a great example of a gen_server tcp listener at http://www.duomark.com/erlang/tutorials/proxy.html 
>>     but this also exhibits the same problem outside the shell - it   
>> serves one request and then the socket is closed.
>> Does anyone have or know of a great tcp listener example that  
>> works  outside the shell (eg started with: 'erl -boot start_sasl -s  
>> mymodule  start'), or another interesting way to resolve this,  
>> specifically when  writing  gen_server?
>> Here are some models I have gone through, all of which work in the   
>> shell but not outside the shell:
>> gen_server:init listen()'s ->
>>   spawn()'s a connection pool ->
>>     each pool process accept()'s and spawns another pool process
>> In the shell: works fine
>> Outside the shell: 2nd and subsequent accept() fails
>> gen_server:init listen()'s ->
>>   gen_server:init calls gen_server:cast(accept_loop) ->
>>     accept_loop loops forever, spawning handlers on each request  
>> (and  gen_tcp:controlling_process the associated connections over  
>> to the  processes)
>> In the shell: works fine
>> Outside the shell: 2nd and subsequent accept() fails
>> These all work great in the shell but serve 1-2 requests (depending  
>> on  your platform) outside the shell before the socket closes.
>> Any advice on how to properly get the owner of the listening socket  
>> to  stick around in a gen_server would be appreciated.
>
> A gen_server will 'hang around' indefinitely by design, unless you  
> tell
> it to stop or one of its callbacks fail. I don't know if this is the
> problem, but you need to make sure that the listening socket itself
> always has an owner too, not just the sockets created by the listening
> socket.
>
> There's an example, by Serge Aleynikov, of how to do a generic tcp
> server here:
>
> http://trapexit.org/Building_a_Non-blocking_TCP_server_using_OTP_principles
>
> I packaged it up for erlware (http://erlware.org) and you can  
> install it
> with their 'faxien' tool, or just grab the code here:
>
> http://git.krondo.com/?p=erlware/gen_socket.git;a=summary
>
> dave
>
>> Thanks!
>> Eric
>> References:
>> 1. http://www.erlang.org/pipermail/erlang-questions/2008-January/032400.html
>> 2. http://www.duomark.com/erlang/tutorials/proxy.html
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://www.erlang.org/mailman/listinfo/erlang-questions
>



From ok@REDACTED  Mon May 12 03:35:05 2008
From: ok@REDACTED (Richard A. O'Keefe)
Date: Mon, 12 May 2008 13:35:05 +1200
Subject: [erlang-questions] Strange arithmetic behaviour
In-Reply-To: <5D56A501-27BD-4D7E-B9ED-E3CEC94C4042@masklinn.net>
References: <85d11a2e0805080142x2b9d9615mbe8a6dd7e1b4aa87@mail.gmail.com>
	<70D00C33FCD1FD4A860DEAC228277C0C0464BFAC@MTNMAIL1.mtn.co.za>
	<5D56A501-27BD-4D7E-B9ED-E3CEC94C4042@masklinn.net>
Message-ID: <09C97EFE-7D6B-4A31-ACEA-2A9858830BCE@cs.otago.ac.nz>

I wonder if the original poster wasn't a bit smarter than some of us
may have assumed.  The existence of bignums in Erlang proves that a
language need not be limited by the deficiencies of the hardware.
ANSI Smalltalk provides "ScaledDecimal" numbers, which are numbers
with a fixed number of decimal places after the point but an
unbounded number before it.  Maxima has bigfloats; source code can
be found at http://www.cs.berkeley.edu/~fateman/mma1.6/bf.lisp and
http://www.cs.berkeley.edu/~fateman/mma1.6/bfelem.lisp.  Heck,
XEmacs lisp comes with them built in (see
http://www.xemacs.org/Documentation/beta/html/lispref_10.html)
Mathematica also has bigfloats.  I have a vague recollection of
some Smalltalk having bigfloats, but cannot recall which (the ANSI
ScaledDecimal is great for money, not for trig.)

And of course Java has java.math.BigDecimal, described as
"Immutable, arbitrary-precision signed decimal numbers.
A BigDecimal consists of an arbitrary precision integer unscaled
value and a 32-bit integer scale."

The particularly interesting thing about BigDecimal is that it's
base 10.  (High speed base 10 floating point hardware is shipping
now in the current generation of Power and zSeries machines...)
Base 10 bigfloats are particularly interesting as being likely to
give results non-programmers would expect rather more often than
limited precision base 2 floats do.  But not ALL the time...




From kevin@REDACTED  Mon May 12 03:47:22 2008
From: kevin@REDACTED (Kevin A. Smith)
Date: Sun, 11 May 2008 21:47:22 -0400
Subject: [erlang-questions] Question about gen_server:multi_call/2
Message-ID: 

I've been reading the man page on gen_server and the section  
describing multi_call/2 states:

"Makes  a  synchronous call to all gen_servers locally registered
as Name at the specified nodes by first  sending  a  request  to
every  node  and  then  waiting for the replies."

Does this apply to gen_server:multi_call/2? If so, how can I register  
multiple processes on the same node with the same name?

Thanks,
Kevin


From wenewboy@REDACTED  Mon May 12 05:03:18 2008
From: wenewboy@REDACTED (wenew zhang)
Date: Mon, 12 May 2008 11:03:18 +0800
Subject: [erlang-questions] How to start a .app from os's shell
In-Reply-To: <48272AEA.5050602@san.rr.com>
References: <4eaa09eb0805101530t56bae2cfp2ddb0cd3e4e4c060@mail.gmail.com>
	
	<4eaa09eb0805110654n4a9397eag7633fe70d004d91d@mail.gmail.com>
	<48272AEA.5050602@san.rr.com>
Message-ID: <4eaa09eb0805112003q6c089523j100fba9e3c1f6889@mail.gmail.com>

Actually, It's works with domain name,i start erl shell like below,
erl -name socketservernode@REDACTED -setcookie abc -boot
start_sasl -config socketlog

and then start socketserver under erl-shell
like:application:start(socketserver).
i try :erl -name socketservernode@REDACTED -setcookie abc
-boot start_sasl -config socketlog -s application start socketserver
it's start a process,but socketserver doesn't  start

maybe i should study to write .boot file
Wenew Zhang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From anders.nygren@REDACTED  Mon May 12 05:23:12 2008
From: anders.nygren@REDACTED (Anders Nygren)
Date: Sun, 11 May 2008 22:23:12 -0500
Subject: [erlang-questions] How to start a .app from os's shell
In-Reply-To: <4eaa09eb0805112003q6c089523j100fba9e3c1f6889@mail.gmail.com>
References: <4eaa09eb0805101530t56bae2cfp2ddb0cd3e4e4c060@mail.gmail.com>
	
	<4eaa09eb0805110654n4a9397eag7633fe70d004d91d@mail.gmail.com>
	<48272AEA.5050602@san.rr.com>
	<4eaa09eb0805112003q6c089523j100fba9e3c1f6889@mail.gmail.com>
Message-ID: 

2008/5/11 wenew zhang :
> Actually, It's works with domain name,i start erl shell like below,
> erl -name socketservernode@REDACTED -setcookie abc -boot
> start_sasl -config socketlog
>
> and then start socketserver under erl-shell
> like:application:start(socketserver).
> i try :erl -name socketservernode@REDACTED -setcookie abc
> -boot start_sasl -config socketlog -s application start socketserver
> it's start a process,but socketserver doesn't  start
>

>From the erl documentation
-s Mod [Func [Arg1, Arg2, ...]](init flag)
    Makes init call the specified function. Func defaults to start. If
no arguments are provided, the function is assumed to be of arity 0.
Otherwise it is assumed to be of arity 1, taking the list
[Arg1,Arg2,...] as argument. All arguments are passed as atoms.

So the problem You have is that the -s application start socketserver
leads to a call like

application:start([socketserver]) where the application name is inside
a list, so
appliaction:start fails since it expects an atom.

If You instead add a function e.g
socketserver:start() ->
   application:start(socketserver).

and start Your application with -s socketserver start
it should work.

/Anders

> maybe i should study to write .boot file
> Wenew Zhang
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>


From wenewboy@REDACTED  Mon May 12 07:15:46 2008
From: wenewboy@REDACTED (wenew zhang)
Date: Mon, 12 May 2008 13:15:46 +0800
Subject: [erlang-questions] How to start a .app from os's shell
In-Reply-To: 
References: <4eaa09eb0805101530t56bae2cfp2ddb0cd3e4e4c060@mail.gmail.com>
	
	<4eaa09eb0805110654n4a9397eag7633fe70d004d91d@mail.gmail.com>
	<48272AEA.5050602@san.rr.com>
	<4eaa09eb0805112003q6c089523j100fba9e3c1f6889@mail.gmail.com>
	
Message-ID: <4eaa09eb0805112215l321e76f9g3e04c57e7494f1da@mail.gmail.com>

i try this:
 erl -s socket_server_app start [normal,[]]
Erlang (BEAM) emulator version 5.5.5 [source]
 [async-threads:0] [kernel-poll:false]


{"init terminating in
do_boot",{undef,[{socket_server_app,start,[['[normal,[]]']]},{init,start_it,1},{init,start_em,1}]}}

Crash dump was written to: erl_crash.dump
init terminating in do_boot ()

it's works normal if i type "socket_server_app:start(normal,[])." in
erl-shell,
there 's a problem how to pass normal,[] to start function,maybe i should
change the
source code that delete the "[]" argument(man erl said that argument must be
atoms) ,but i don't try it because i figure out this problem
use  boot script ,http://erlang-china.org/study/erlang-release-demo.html
thank all response very much

Wenew Zhang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From raimo+erlang-questions@REDACTED  Mon May 12 09:58:02 2008
From: raimo+erlang-questions@REDACTED (Raimo Niskanen)
Date: Mon, 12 May 2008 09:58:02 +0200
Subject: [erlang-questions] Confused about the "rex" server
In-Reply-To: 
References: 
Message-ID: <20080512075802.GA5547@erix.ericsson.se>

On Fri, May 09, 2008 at 05:29:46PM +0200, Alexander Lamb wrote:
> Hello list,
> 
> I am a bit confused about references of what is called "rex server".
> 
> I wrote a module with exported functions. I need to call these  
> functions from a JInterface. So as I discovered in the documentation,  
> I create a node and a mailbox (I will have several mailboxes in  
> separate threads).
> However, what I understood from a previous reply from Raimo, is that a  
> rpc is actually a message send with some particular way of giving the  
> parameters. In this message send, there is a reference to "rex". What  
> does that actually mean? I didn't find the documentation related to  
> this.

I am afraid the source code is the documentation in this case...

"rex" is the registered name of the Remote EXecution server
aka RPC server on every erlang node. It is part of the
Kernel application.

The Kernel application client code in the 'rpc' module
makes gen_server calls to that registered name. But there
is an alternative to gen_server calls that e.g C and
Java nodes use, and that is to send a message
{self(),{call,Mod,Fun,Args,Gleader}} to the registered
name "rex" on your desired node, and then wait for
a reply message {rex,Reply}.

> 
> Now, on the receiving side, how do things happen?

Read the source code for the 'rpc' module, function handle_call/3
clause ({call,...}, ...):
The RPC server spawns a worker process for each
RPC call, and waits for it to return a reply that
the RPC server in its turn returns to the caller.

The worker proceess protects the RPC server from
odd things that may happen in the applied RPC function,
and frees the RPC server so serve new calls before
the previous is complete.

> 
> Do I need to spawn a process for each call received? Or does "rex"  
> handle this for me? Or would it be better to send messages instead of  
> calling functions?

You can always customize a server. But if you only
want to call existing functions remotely, and you are
happy with the rather heavy footed and safe way
the RPC server does its calls, use it!

> 
> Alex
> --
> Alexander Lamb
> Founding Associate
> RODANOTECH S?rl
> 
> 4 ch. de la Tour de Champel
> 1206 Geneva
> Switzerland
> 
> Tel:  022 347 77 37
> Fax: 022 347 77 38
> 
> http://www.rodanotech.ch
> 
> 
> 
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions

-- 

/ Raimo Niskanen, Erlang/OTP, Ericsson AB


From alexander.lamb@REDACTED  Mon May 12 10:16:14 2008
From: alexander.lamb@REDACTED (Alexander Lamb)
Date: Mon, 12 May 2008 10:16:14 +0200
Subject: [erlang-questions] Confused about the "rex" server
In-Reply-To: <20080512075802.GA5547@erix.ericsson.se>
References: 
	<20080512075802.GA5547@erix.ericsson.se>
Message-ID: 

Thanks a lot!

Gradually getting the picture (and will have tons of questions for the  
class and conference in London:-)

So, until my app needs to do hundreds of thousands of calls, rex will  
be perfect. It also simplifies things on the server part. No more  
spawning of processes. Simply expose functions. Since the spawning of  
processes is handled by the rpc server.

Alex

Le 12 mai 08 ? 09:58, Raimo Niskanen a ?crit :

> On Fri, May 09, 2008 at 05:29:46PM +0200, Alexander Lamb wrote:
>> Hello list,
>>
>> I am a bit confused about references of what is called "rex server".
>>
>> I wrote a module with exported functions. I need to call these
>> functions from a JInterface. So as I discovered in the documentation,
>> I create a node and a mailbox (I will have several mailboxes in
>> separate threads).
>> However, what I understood from a previous reply from Raimo, is  
>> that a
>> rpc is actually a message send with some particular way of giving the
>> parameters. In this message send, there is a reference to "rex". What
>> does that actually mean? I didn't find the documentation related to
>> this.
>
> I am afraid the source code is the documentation in this case...
>
> "rex" is the registered name of the Remote EXecution server
> aka RPC server on every erlang node. It is part of the
> Kernel application.
>
> The Kernel application client code in the 'rpc' module
> makes gen_server calls to that registered name. But there
> is an alternative to gen_server calls that e.g C and
> Java nodes use, and that is to send a message
> {self(),{call,Mod,Fun,Args,Gleader}} to the registered
> name "rex" on your desired node, and then wait for
> a reply message {rex,Reply}.
>
>>
>> Now, on the receiving side, how do things happen?
>
> Read the source code for the 'rpc' module, function handle_call/3
> clause ({call,...}, ...):
> The RPC server spawns a worker process for each
> RPC call, and waits for it to return a reply that
> the RPC server in its turn returns to the caller.
>
> The worker proceess protects the RPC server from
> odd things that may happen in the applied RPC function,
> and frees the RPC server so serve new calls before
> the previous is complete.
>
>>
>> Do I need to spawn a process for each call received? Or does "rex"
>> handle this for me? Or would it be better to send messages instead of
>> calling functions?
>
> You can always customize a server. But if you only
> want to call existing functions remotely, and you are
> happy with the rather heavy footed and safe way
> the RPC server does its calls, use it!
>
>>
>> Alex
>> --
>> Alexander Lamb
>> Founding Associate
>> RODANOTECH S?rl
>>
>> 4 ch. de la Tour de Champel
>> 1206 Geneva
>> Switzerland
>>
>> Tel:  022 347 77 37
>> Fax: 022 347 77 38
>>
>> http://www.rodanotech.ch
>>
>>
>>
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://www.erlang.org/mailman/listinfo/erlang-questions
>
> -- 
>
> / Raimo Niskanen, Erlang/OTP, Ericsson AB
>



From ingela@REDACTED  Mon May 12 10:39:52 2008
From: ingela@REDACTED (Ingela Anderton Andin)
Date: Mon, 12 May 2008 10:39:52 +0200
Subject: [erlang-questions] erlang-questions] inets httpd mod_log output
	issue
In-Reply-To: 
References: 
Message-ID: <48280258.7020804@erix.ericsson.se>

> The 'compact' 'error_log_format' generates things like the following in
> the
> log files:
>
>[09/May/2008:09:19:57 -0500] access to /foo/flooga.txt failed for 127.0.0.1, reason: >[104,116,116,112,100,95,102,105,108,101,58,32,67,97,110,39,116,32,111,112,101,110,47,104,111,109,101,47,112,102,105,115,104,101,114,47,108,109,47,108,109,45,116,114,117,110,107,47,98,108,100,47,101,114,108,97,110,103,47,105,110,101,116,115,109,103,114,47,112,114,105,118,47,102,111,111,47,102,108,111,111,103,97,46,116,120,116]
>
>

Yes we know. Maybe you should be using pretty insteadof compact. The assumption here is that
if you want to use a tool to read the logs it will be very nice that each entry is only one line. And if
you are using a tool it will be easy to let the tool do its own formatting of the entry. But 
if the logs are mainly read by humans directly you should use pretty format. 

[...]


Regards Ingela Erlang/OTP, Ericsson






From francesco@REDACTED  Mon May 12 11:46:41 2008
From: francesco@REDACTED (Francesco Cesarini)
Date: Mon, 12 May 2008 10:46:41 +0100
Subject: [erlang-questions] 22 May 2008: Robert Virding on Lisp Flavoured
 Erlang, (Stockholm User Group Talk)
Message-ID: <48281201.9040602@erlang-consulting.com>

If you are interested in receiving these types of announcements, please 
register with the Erlang Stockholm User Group mailing list, as we will 
soon be moving all of these announcements there to offload the Erlang 
Questions List. All you need to do is send a blank email to 
erlangstockholm-subscribe@REDACTED and follow the instructions or 
visit the user group page on 
http://www.erlang-consulting.com/erlang/usergroup/erlangstockholm.html .

The second meeting of the Stockholm Erlang User Group will be hosted by 
Stockholm University on Thursday the 22nd of May starting at 18.30 
(Doors open at 18.00). Robert Virding, one of the original inventors of 
Erlang will present his latest open source project  Lisp Flavored Erlang 
(http://forum.trapexit.org/viewtopic.php?p=43887#43887). If you are 
interested in attending this free event, you have to register. By 
registering, you will enable us to plan room size and refreshments 
accordingly, provide Security with the name list of participants, and in 
those extreme cases where the number of places are limited, close 
registration as soon as we have reached the maximum room capacity or 
find a larger room (As happened last time). You can register on the 
Erlang Stockholm User Group Page here: 
http://www.erlang-consulting.com/erlang/usergroup/erlangstockholm.html

*Abstract:*In this talk we will describe and demonstrate Lisp Flavored 
Erlang (LFE). LFE allows you to write Erlang code in a lisp syntax and 
combines the versatility and extensibility of lisp with the COP power of 
Erlang. LFE is completely integrated with Erlang/OTP and code written in 
LFE can freely be used together with modules written in vanilla Erlang 
and applications in Erlang/OTP. LFE is also much easier to use than 
vanilla Erlang when generating code. We will describe the system, its 
tools and its implementation, and also demonstrate some of its features 
and using its programming environment.

* Biography:*Robert Virding is one of the original developers of Erlang 
at the Ericsson Computer Science Lab. While there he also did work on 
garbage collection and the implementation of high-level languages. He 
left Ericsson to found Bluetail, the first Erlang startup acquired by 
Nortel in 2000. He now works for the Swedish Defense Material 
Administration (FMV) where he is not able to use Erlang. He does, 
however, still program Erlang in his spare time and take part in the 
Erlang community.

See you there!
Francesco
--
http://www.erlang-consulting.com


From ingela@REDACTED  Mon May 12 11:59:48 2008
From: ingela@REDACTED (Ingela Anderton Andin)
Date: Mon, 12 May 2008 11:59:48 +0200
Subject: [erlang-questions] erlang-questions] inets httpd mod_log	output
 issue
In-Reply-To: <1210584756.15666.128.camel@localhost>
References: 	
	<48280258.7020804@erix.ericsson.se>
	<1210584756.15666.128.camel@localhost>
Message-ID: <48281514.8060506@erix.ericsson.se>

Paul Fisher wrote:
> On Mon, 2008-05-12 at 10:39 +0200, Ingela Anderton Andin wrote:
>   
>>> The 'compact' 'error_log_format' generates things like the following in
>>> the
>>> log files:
>>>
>>> [09/May/2008:09:19:57 -0500] access to /foo/flooga.txt failed for 127.0.0.1, reason: >[104,116,116,112,100,95,102,105,108,101,58,32,67,97,110,39,116,32,111,112,101,110,47,104,111,109,101,47,112,102,105,115,104,101,114,47,108,109,47,108,109,45,116,114,117,110,107,47,98,108,100,47,101,114,108,97,110,103,47,105,110,101,116,115,109,103,114,47,112,114,105,118,47,102,111,111,47,102,108,111,111,103,97,46,116,120,116]
>>>
>>>
>>>       
>> Yes we know. Maybe you should be using pretty insteadof compact. The assumption here is that
>> if you want to use a tool to read the logs it will be very nice that each entry is only one line. And if
>> you are using a tool it will be easy to let the tool do its own formatting of the entry. But 
>> if the logs are mainly read by humans directly you should use pretty format. 
>>     
>
> We (like I suspect lots of other production shops) write human
> readable/parsible logs as single line per entry, which is what 'compact'
> seemed to be.
>
>   
Well, if that is what web-application  developers wants maybe that is 
what we should make it into?!
Maybe our first assumption does not hold up.
I am just trying to explain what the initial intent was. We will take 
this under consideration.

> Why support the 'compact' form if it generates "write-only" log messages
> (intended never to be read by human or machine)?  Seriously, if there is
> no intent to "fix" the 'compact' form to print intelligible information,
> then deprecate it.
>   
It was intended  to be read  by a tool and serve as some kind of 
backwards compatibility
when we made the pretty format.

Regards Ingela, Erlang/OTP Ericsson

 




From per.melin@REDACTED  Mon May 12 12:42:46 2008
From: per.melin@REDACTED (Per Melin)
Date: Mon, 12 May 2008 12:42:46 +0200
Subject: [erlang-questions] mnesia_loader overrun by mnesia_table_events
Message-ID: 

I have a ram_copies table on node A and node B. It has ~900K records
and takes up ~900MB.

If I take down node B and then bring it back up it copies the table
from A very fast.

The problem is that during normal operations I do 5K-10K dirty writes
per second on node A. And under those conditions the copying never
terminates.

What happens, as far as I can tell, is that
mnesia_loader:spawned_receiver/8 calls ets:init_table/2, and by the
time it has copied some 300K records it has also received about 100K
of {mnesia_table_event, {write, ..., {dirty, ...}}} which builds up in
the inbox because they are not being taken care of yet. Now things
start to go slower and slower for init_table. Eventually there are
millions of table events in the inbox and the server runs out of
memory.

I understand that this is maybe an impossible situation. Or is there a solution?


From ulf@REDACTED  Mon May 12 13:02:40 2008
From: ulf@REDACTED (Ulf Wiger)
Date: Mon, 12 May 2008 13:02:40 +0200
Subject: [erlang-questions] mnesia_loader overrun by mnesia_table_events
In-Reply-To: 
References: 
Message-ID: <8209f740805120402s1e69054djf411d206561835d9@mail.gmail.com>

One solution that comes to mind is to use transactions rather than dirty writes.

BR,
Ulf W

2008/5/12, Per Melin :
> I have a ram_copies table on node A and node B. It has ~900K records
> and takes up ~900MB.
>
> If I take down node B and then bring it back up it copies the table
> from A very fast.
>
> The problem is that during normal operations I do 5K-10K dirty writes
> per second on node A. And under those conditions the copying never
> terminates.
>
> What happens, as far as I can tell, is that
> mnesia_loader:spawned_receiver/8 calls ets:init_table/2, and by the
> time it has copied some 300K records it has also received about 100K
> of {mnesia_table_event, {write, ..., {dirty, ...}}} which builds up in
> the inbox because they are not being taken care of yet. Now things
> start to go slower and slower for init_table. Eventually there are
> millions of table events in the inbox and the server runs out of
> memory.
>
> I understand that this is maybe an impossible situation. Or is there a
> solution?
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>


From ingela@REDACTED  Mon May 12 13:03:12 2008
From: ingela@REDACTED (Ingela Anderton Andin)
Date: Mon, 12 May 2008 13:03:12 +0200
Subject: [erlang-questions] mod_esi should return 400 status for
	missing	function
In-Reply-To: 
References: 
Message-ID: <482823F0.4000608@erix.ericsson.se>

[...]
>  I stand by my patch with a 404 response code:
>   

Based on your explanation in your previous message and this one, I
fully agree that 404, but definitely not 400, is correct.

I also agree that 404 is a *reasonable **interpretation of the spec
an 400 is not. I will change it be 404.

Regards Ingela Erlang/OTP Ericsson
*



From pfisher@REDACTED  Mon May 12 13:42:36 2008
From: pfisher@REDACTED (Paul Fisher)
Date: Mon, 12 May 2008 06:42:36 -0500
Subject: [erlang-questions] erlang-questions] inets httpd	mod_log	output
	issue
In-Reply-To: <48281514.8060506@erix.ericsson.se>
References: 
	<48280258.7020804@erix.ericsson.se>
	<1210584756.15666.128.camel@localhost>
	<48281514.8060506@erix.ericsson.se>
Message-ID: <1210592556.6453.14.camel@localhost>

On Mon, 2008-05-12 at 11:59 +0200, Ingela Anderton Andin wrote:
> Paul Fisher wrote:
> > We (like I suspect lots of other production shops) write human
> > readable/parsible logs as single line per entry, which is what 'compact'
> > seemed to be.
> >
> >   
> Well, if that is what web-application  developers wants maybe that is 
> what we should make it into?!
> Maybe our first assumption does not hold up.
> I am just trying to explain what the initial intent was. We will take 
> this under consideration.

I'm sorry that I misinterpreted your initial response.  I read "will not
fix", which is what generated my private message to you.  I would like
to make "single-line" logging work readably with inets mod_log, so lets
see if there is something we can work out as an acceptable patch.

What I ended up doing in my local R12B-2 build is the following, which
appears to work without breaking things:

--- inets/src/http_server/httpd_log.erl.orig    2008-05-09 10:13:24.000000000 -0500
+++ inets/src/http_server/httpd_log.erl 2008-05-09 10:32:38.000000000 -0500
@@ -104,6 +104,10 @@
        pretty ->
           io_lib:format("[~s] server crash for ~s, reason: ~n~p~n~n", 
                         [Date, RemoteHost, Reason]);
+       compact when is_list(Reason), is_integer(hd(Reason)),
+                     hd(Reason) > 0, hd(Reason) =< 255 ->
+           io_lib:format("[~s] server crash for ~s, reason: ~s~n", 
+                         [Date, RemoteHost, Reason]);
        compact ->
           io_lib:format("[~s] server crash for ~s, reason: ~w~n", 
                         [Date, RemoteHost, Reason])
@@ -115,6 +119,10 @@
        pretty ->
           io_lib:format("[~s] access to ~s failed for ~s reason: ~n~p~n",
                         [Date, URI, RemoteHost, Reason]);
+       compact when is_list(Reason), is_integer(hd(Reason)),
+                     hd(Reason) > 0, hd(Reason) =< 255 ->
+           io_lib:format( "[~s] access to ~s failed for ~s, reason: ~s~n", 
+                          [Date, URI, RemoteHost, Reason]);
        compact ->
           io_lib:format( "[~s] access to ~s failed for ~s, reason: ~w~n", 
                         [Date, URI, RemoteHost, Reason])            


-- 
paul



From ulf.wiger@REDACTED  Mon May 12 13:43:03 2008
From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB))
Date: Mon, 12 May 2008 13:43:03 +0200
Subject: [erlang-questions] Question about gen_server:multi_call/2
In-Reply-To: 
References: 
Message-ID: <48282D47.2000702@ericsson.com>

Kevin A. Smith skrev:
> I've been reading the man page on gen_server and the section  
> describing multi_call/2 states:
> 
> "Makes  a  synchronous call to all gen_servers locally registered
> as Name at the specified nodes by first  sending  a  request  to
> every  node  and  then  waiting for the replies."
> 
> Does this apply to gen_server:multi_call/2? If so, how can I register  
> multiple processes on the same node with the same name?

There will always be at most one process registered under
a given name on each node.

BR,
Ulf W


From per.melin@REDACTED  Mon May 12 14:12:43 2008
From: per.melin@REDACTED (Per Melin)
Date: Mon, 12 May 2008 14:12:43 +0200
Subject: [erlang-questions] mnesia_loader overrun by mnesia_table_events
In-Reply-To: <8209f740805120402s1e69054djf411d206561835d9@mail.gmail.com>
References: 
	<8209f740805120402s1e69054djf411d206561835d9@mail.gmail.com>
Message-ID: 

Oops. I only sent my replies to Ulf. See below.

> 2008/5/12 Ulf Wiger :
>> One solution that comes to mind is to use transactions rather than
dirty writes.
>
> I tried that, and then the copying works perfect, but Mnesia also
> can't keep up with the writes on the working node in the first place.
> Even if I collect the updates first and write 5000 per transaction and
> use sticky locking.
>
> Hold on. I just tried an explicit full table lock in the transaction.
> That seems to do the trick.
>
> I'll do more testing. If you don't hear anything else this was the
> solution. Thanks!

No, I'm back to square one. Now that Mnesia on the working node (A)
can keep up with the writes then the node coming back up (B) can't
keep up with the copying. It looks like a single transaction of 5000
writes is still sent as 5000 individual table events?


From raimo+erlang-questions@REDACTED  Mon May 12 14:12:52 2008
From: raimo+erlang-questions@REDACTED (Raimo Niskanen)
Date: Mon, 12 May 2008 14:12:52 +0200
Subject: [erlang-questions] Printing of floating-point numbers (was:
	Strange arithmetic behaviour)
In-Reply-To: <482627D6.4000907@industrial-designers.co.uk>
References: <85d11a2e0805080142x2b9d9615mbe8a6dd7e1b4aa87@mail.gmail.com>
	<14f0e3620805080220i67dc9a2ckcc8ab03568639a00@mail.gmail.com>
	<482627D6.4000907@industrial-designers.co.uk>
Message-ID: <20080512121252.GA10533@erix.ericsson.se>

On Sat, May 10, 2008 at 11:55:18PM +0100, David-Sarah Hopwood wrote:
> Gleb Peregud wrote:
> > These are results from Python interactive shell:
> > 
> >>>> 123123123123123123123.0 - 123123123123123123121.0
> > 0.0
> >>>> print '%f' % math.floor(1233333333333333123333333333.12311111111);
> > 1233333333333333065680814080.000000
> >>>> print '%f' % 1233333333333333123333333333.12311111111
> > 1233333333333333065680814080.000000
> > 
> > As you can see results are the same. I think it is because of internal
> > IEEE-something floating point number representation. As you can see in
> > the last example, number "1233333333333333123333333333.12311111111" is
> > converted to "1233333333333333065680814080.000000" without applying to
> > it any operations. Probably it is because internal float
> > representation does not allow this precision in this particular
> > situation
> 
> However, these examples show that neither Erlang nor Python are using
> "parsimonious printing" of floating-point numbers. The results under
> parsimonious printing would have the minimum number of digits of
> precision needed to reproduce the floating-point number exactly.
> There is a fair degree of concensus that this is the Right Thing for
> any programming language. See for example
> .

Erlang/OTP is using this since R12B-2 for print operators
~p ~P ~w and ~W (functions io_lib:write/1,2 and io_lib:print/1,4).

Eshell V5.6.2  (abort with ^G)
1> io:format("~p~n", [1233333333333333065680814080.000000]).
1.233333333333333e27
ok


:
> 
> Raimo Niskanen wrote:
> > And I would not want to write the library that does e.g
> > sin, cos, tan, asin, acos, atan, pow, exp, erf
> > for a given arbitrary rounding strategy.
> > Someone else?
> 
> Google "arbitrary precision floating point". (Some of the listed libraries
> do arbitrary rounding strategies, some don't.) IMHO arbitrary-precision
> floating point belongs in the standard library of any modern programming
> language (excluding library profiles targetted to embedded systems).

Then we are just waiting for someone to write an interface
to e.g MPFR [http://www.mpfr.org]...

> 
> -- 
> David-Sarah Hopwood
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions

-- 

/ Raimo Niskanen, Erlang/OTP, Ericsson AB


From alex.arnon@REDACTED  Mon May 12 14:29:59 2008
From: alex.arnon@REDACTED (Alex Arnon)
Date: Mon, 12 May 2008 15:29:59 +0300
Subject: [erlang-questions] Erlang Mode Mavens: customizations?
Message-ID: <944da41d0805120529kcdc0824t44cf75b270349106@mail.gmail.com>

Hi All,

I'd like to ask you Emacs Proficienados:
1. Which keybindings do you add to Erlang Mode? For example, do you bind
erlang-find-tag, erlang-indent-clause etc.?
2. Are there any other customizations you add on top of Erlang Mode?

Cheers,
Alex.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From kenneth.lundin@REDACTED  Mon May 12 14:57:04 2008
From: kenneth.lundin@REDACTED (Kenneth Lundin)
Date: Mon, 12 May 2008 14:57:04 +0200
Subject: [erlang-questions] [erlang-bugs] Weird pg2 behavior
In-Reply-To: 
References: 
	<18431.9227.133848.989614@gargle.gargle.HOWL>
	
	
	<18435.1529.209488.50485@gargle.gargle.HOWL>
	
	<18437.48350.271334.980195@gargle.gargle.HOWL>
	
	
	
Message-ID: 

Hi,

pg2 is in deep need of systematic tests and a number of bugfixes (at
least the one
discussed here).

The status of pg2 is like that because the module has obviously not
been used much at all. The only use of pg2 within OTP is from disk_log
(the distributed
logs part which also is rarely used).

We can not promise when we will have time to improve the pg2 module, it does not
come very high up in our priority list.

What we can say is that it is a far better chance to get it fixed
sooner as part of an
OTP release if a patch
and test suite is provided by someone in the community.

/Regards Kenneth Erlang/OTP, Ericsson

On 5/8/08, Andy Gross  wrote:
>
> We also use pg2 heavily in our production network, and are also
> interested in seeing a resolution to this bug.  It hasn't popped up in
> production yet, but when we moved offices we spent a couple of days
> trying to purge our pg2 groups of old, stale pids running on IP
> addresses from the old office space, to no avail.  Eventually each
> developer just switched cookies to prevent whatever rogue pg2 instance
> was poisoning the group membership.
>
> Could someone in-the-know describe the monitoring changes made to
> global mentioned below?   Would a patch from the community with a test
> suite be considered for inclusion in any R12-X release?
>
> - Andy
>
>
> On May 7, 2008, at 10:28 PM, Matthew Dempsky wrote:
>
> > Has there been any progress on this?  This bug bit us again today. :-(
> >
> > (A pid from a node on a machine that had been decommissioned and not
> > running any Erlang code for months now but still present on our
> > network was still lurking in one of our pg2 groups.  Yesterday we
> > finally repurposed this machine, removing it from our network, which
> > had the unexpected side effect of causing Pid ! Msg in some heavily
> > used code to start adding several seconds of delay due to the runtime
> > attempting to autoconnect to that long-dead node.)
> >
> > On Fri, Apr 18, 2008 at 1:23 AM, Matthew Dempsky
> >  wrote:
> >> On Wed, Apr 16, 2008 at 1:46 AM, Hans Bolinder
> >>
> >>  wrote:
> >>
> >>> I think pg2 should monitor all pids rather than link to local pids
> >>> only. Carefully setting up monitors, like Global does since R11B-4,
> >>> should work.
> >>
> >> Sounds good to me.  Can we hope to see this in R12B-3?  :-)
> >>
> > _______________________________________________
> > erlang-questions mailing list
> > erlang-questions@REDACTED
> > http://www.erlang.org/mailman/listinfo/erlang-questions
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>


From alexander.lamb@REDACTED  Mon May 12 18:43:38 2008
From: alexander.lamb@REDACTED (Alexander Lamb)
Date: Mon, 12 May 2008 18:43:38 +0200
Subject: [erlang-questions] First send from JInterface ok, second one blocs??
Message-ID: 

Hello,

I have something curious happening when sending messages to the rex  
rpc server.

The first time I send a message, everything is ok. The second time, it  
blocs and I finally get a timeout (e.g. the response is null).

I activated the trace, and here is what I get:

-> PUBLISH (r4) jnode@REDACTED port=55076
<- OK
-> LOOKUP (r4) alex@REDACTED
<- PORT 55021
-> MD5 CONNECT TO kirk.local:55021
-> HANDSHAKE sendName flags=3332 dist=5 local=jnode@REDACTED
<- HANDSHAKE recvStatus (ok) local=jnode@REDACTED
<- HANDSHAKE recvChallenge from=alex@REDACTED challenge=1257096912  
local=jnode@REDACTED
-> HANDSHAKE sendChallengeReply challenge=-63103116  
digest=16202c1233ac821560450cd85550f542 local=jnode@REDACTED
<- HANDSHAKE recvChallengeAck from=alex@REDACTED  
digest=c223cd415468ff024d0529992ab8ec48 local=jnode@REDACTED
-> REG_SEND {6,#Pid,'',rex}
    {#Pid,{call,profiles,get_default_menus, 
[[84,79,80]],user}}
<- SEND {2,'',#Pid}
    {rex,{ok,[{menu,home,{{home,"Home"},[{login,"Login"}, 
{logout,"Logout"},{about,"About"}]}},{menu,patients, 
{{patients,"Patients"},[]}},{menu,centers,{{centers,"Centers"}, 
[{search,"Search"},{list,"List"}]}},{menu,dashboard, 
{{dashboard,"Dashboard"},[{enrollment,"Enrollment"}, 
{statistics,"Statistics"},{initiation,"Initiation"}]}}]}}
-> LOOKUP (r4) alex@REDACTED
<- PORT 55021
-> MD5 CONNECT TO kirk.local:55021
-> HANDSHAKE sendName flags=3332 dist=5 local=jnode@REDACTED
-> CLOSE


So the funny thing is that something is doing a CLOSE. What does that  
mean??

Thanks,

Alex


From alexander.lamb@REDACTED  Mon May 12 19:32:22 2008
From: alexander.lamb@REDACTED (Alexander Lamb)
Date: Mon, 12 May 2008 19:32:22 +0200
Subject: [erlang-questions] First send from JInterface ok,
	second one blocs??
In-Reply-To: 
References: 
Message-ID: <532EB5E3-8DA1-41E5-9814-4F3D5F420665@rodanotech.ch>

Some more information: even if I create a new mailbox before each  
send, it behaves the same way. Impossible to do a second message send  
(or a ping). If I restart the java application, even without  
restarting the erlang server, it again works for the first send.

Alex

Le 12 mai 08 ? 18:43, Alexander Lamb a ?crit :

> Hello,
>
> I have something curious happening when sending messages to the rex
> rpc server.
>
> The first time I send a message, everything is ok. The second time, it
> blocs and I finally get a timeout (e.g. the response is null).
>
> I activated the trace, and here is what I get:
>
> -> PUBLISH (r4) jnode@REDACTED port=55076
> <- OK
> -> LOOKUP (r4) alex@REDACTED
> <- PORT 55021
> -> MD5 CONNECT TO kirk.local:55021
> -> HANDSHAKE sendName flags=3332 dist=5 local=jnode@REDACTED
> <- HANDSHAKE recvStatus (ok) local=jnode@REDACTED
> <- HANDSHAKE recvChallenge from=alex@REDACTED challenge=1257096912
> local=jnode@REDACTED
> -> HANDSHAKE sendChallengeReply challenge=-63103116
> digest=16202c1233ac821560450cd85550f542 local=jnode@REDACTED
> <- HANDSHAKE recvChallengeAck from=alex@REDACTED
> digest=c223cd415468ff024d0529992ab8ec48 local=jnode@REDACTED
> -> REG_SEND {6,#Pid,'',rex}
>    {#Pid,{call,profiles,get_default_menus,
> [[84,79,80]],user}}
> <- SEND {2,'',#Pid}
>    {rex,{ok,[{menu,home,{{home,"Home"},[{login,"Login"},
> {logout,"Logout"},{about,"About"}]}},{menu,patients,
> {{patients,"Patients"},[]}},{menu,centers,{{centers,"Centers"},
> [{search,"Search"},{list,"List"}]}},{menu,dashboard,
> {{dashboard,"Dashboard"},[{enrollment,"Enrollment"},
> {statistics,"Statistics"},{initiation,"Initiation"}]}}]}}
> -> LOOKUP (r4) alex@REDACTED
> <- PORT 55021
> -> MD5 CONNECT TO kirk.local:55021
> -> HANDSHAKE sendName flags=3332 dist=5 local=jnode@REDACTED
> -> CLOSE
>
>
> So the funny thing is that something is doing a CLOSE. What does that
> mean??
>
> Thanks,
>
> Alex
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>



From ddewaleffe@REDACTED  Mon May 12 21:51:12 2008
From: ddewaleffe@REDACTED (Dominique de Waleffe)
Date: Mon, 12 May 2008 21:51:12 +0200
Subject: [erlang-questions] 22 May 2008: Robert Virding on Lisp
	Flavoured Erlang, (Stockholm User Group Talk)
In-Reply-To: <48281201.9040602@erlang-consulting.com>
References: <48281201.9040602@erlang-consulting.com>
Message-ID: 

Are there any chance to have access to a recording of this event?

I think thins would be very interesting to more than 1 person.....

Lisp syntax + concurrency + typing.... a dream language....

D.

On Mon, May 12, 2008 at 11:46 AM, Francesco Cesarini <
francesco@REDACTED> wrote:

> If you are interested in receiving these types of announcements, please
> register with the Erlang Stockholm User Group mailing list, as we will
> soon be moving all of these announcements there to offload the Erlang
> Questions List. All you need to do is send a blank email to
> erlangstockholm-subscribe@REDACTED and follow the instructions or
> visit the user group page on
> http://www.erlang-consulting.com/erlang/usergroup/erlangstockholm.html .
>
> The second meeting of the Stockholm Erlang User Group will be hosted by
> Stockholm University on Thursday the 22nd of May starting at 18.30
> (Doors open at 18.00). Robert Virding, one of the original inventors of
> Erlang will present his latest open source project  Lisp Flavored Erlang
> (http://forum.trapexit.org/viewtopic.php?p=43887#43887). If you are
> interested in attending this free event, you have to register. By
> registering, you will enable us to plan room size and refreshments
> accordingly, provide Security with the name list of participants, and in
> those extreme cases where the number of places are limited, close
> registration as soon as we have reached the maximum room capacity or
> find a larger room (As happened last time). You can register on the
> Erlang Stockholm User Group Page here:
> http://www.erlang-consulting.com/erlang/usergroup/erlangstockholm.html
>
> *Abstract:*In this talk we will describe and demonstrate Lisp Flavored
> Erlang (LFE). LFE allows you to write Erlang code in a lisp syntax and
> combines the versatility and extensibility of lisp with the COP power of
> Erlang. LFE is completely integrated with Erlang/OTP and code written in
> LFE can freely be used together with modules written in vanilla Erlang
> and applications in Erlang/OTP. LFE is also much easier to use than
> vanilla Erlang when generating code. We will describe the system, its
> tools and its implementation, and also demonstrate some of its features
> and using its programming environment.
>
> * Biography:*Robert Virding is one of the original developers of Erlang
> at the Ericsson Computer Science Lab. While there he also did work on
> garbage collection and the implementation of high-level languages. He
> left Ericsson to found Bluetail, the first Erlang startup acquired by
> Nortel in 2000. He now works for the Swedish Defense Material
> Administration (FMV) where he is not able to use Erlang. He does,
> however, still program Erlang in his spare time and take part in the
> Erlang community.
>
> See you there!
> Francesco
> --
> http://www.erlang-consulting.com
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>



-- 
--
Dominique de Waleffe
ddewaleffe -at- gmail -dot- com
domi -at- dewaleffe -dot- org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From dougedmunds@REDACTED  Mon May 12 21:58:48 2008
From: dougedmunds@REDACTED (DougEdmunds)
Date: Mon, 12 May 2008 12:58:48 -0700
Subject: [erlang-questions] distinguishing function by arity
Message-ID: <4828A178.9060102@gmail.com>

Is there a performance hit caused by
using the same function name with
alternative arities (such as add/2, add/3)
instead of using different function
names (such as add2/2, add3/3)?

-- dae


From halfacanuck@REDACTED  Mon May 12 22:02:14 2008
From: halfacanuck@REDACTED (Ross Thomas)
Date: Mon, 12 May 2008 13:02:14 -0700
Subject: [erlang-questions] 22 May 2008: Robert Virding on Lisp
	Flavoured Erlang, (Stockholm User Group Talk)
In-Reply-To: 
References: <48281201.9040602@erlang-consulting.com>
	
Message-ID: 

I'd be interested in some sort of remote/after-the-fact access to this as
well... :)

-Ross


2008/5/12 Dominique de Waleffe :

> Are there any chance to have access to a recording of this event?
>
> I think thins would be very interesting to more than 1 person.....
>
> Lisp syntax + concurrency + typing.... a dream language....
>
> D.
>
>
> On Mon, May 12, 2008 at 11:46 AM, Francesco Cesarini <
> francesco@REDACTED> wrote:
>
>> If you are interested in receiving these types of announcements, please
>> register with the Erlang Stockholm User Group mailing list, as we will
>> soon be moving all of these announcements there to offload the Erlang
>> Questions List. All you need to do is send a blank email to
>> erlangstockholm-subscribe@REDACTED and follow the instructions or
>> visit the user group page on
>> http://www.erlang-consulting.com/erlang/usergroup/erlangstockholm.html .
>>
>> The second meeting of the Stockholm Erlang User Group will be hosted by
>> Stockholm University on Thursday the 22nd of May starting at 18.30
>> (Doors open at 18.00). Robert Virding, one of the original inventors of
>> Erlang will present his latest open source project  Lisp Flavored Erlang
>> (http://forum.trapexit.org/viewtopic.php?p=43887#43887). If you are
>> interested in attending this free event, you have to register. By
>> registering, you will enable us to plan room size and refreshments
>> accordingly, provide Security with the name list of participants, and in
>> those extreme cases where the number of places are limited, close
>> registration as soon as we have reached the maximum room capacity or
>> find a larger room (As happened last time). You can register on the
>> Erlang Stockholm User Group Page here:
>> http://www.erlang-consulting.com/erlang/usergroup/erlangstockholm.html
>>
>> *Abstract:*In this talk we will describe and demonstrate Lisp Flavored
>> Erlang (LFE). LFE allows you to write Erlang code in a lisp syntax and
>> combines the versatility and extensibility of lisp with the COP power of
>> Erlang. LFE is completely integrated with Erlang/OTP and code written in
>> LFE can freely be used together with modules written in vanilla Erlang
>> and applications in Erlang/OTP. LFE is also much easier to use than
>> vanilla Erlang when generating code. We will describe the system, its
>> tools and its implementation, and also demonstrate some of its features
>> and using its programming environment.
>>
>> * Biography:*Robert Virding is one of the original developers of Erlang
>> at the Ericsson Computer Science Lab. While there he also did work on
>> garbage collection and the implementation of high-level languages. He
>> left Ericsson to found Bluetail, the first Erlang startup acquired by
>> Nortel in 2000. He now works for the Swedish Defense Material
>> Administration (FMV) where he is not able to use Erlang. He does,
>> however, still program Erlang in his spare time and take part in the
>> Erlang community.
>>
>> See you there!
>> Francesco
>> --
>> http://www.erlang-consulting.com
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://www.erlang.org/mailman/listinfo/erlang-questions
>>
>
>
>
> --
> --
> Dominique de Waleffe
> ddewaleffe -at- gmail -dot- com
> domi -at- dewaleffe -dot- org
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From richardc@REDACTED  Mon May 12 23:06:58 2008
From: richardc@REDACTED (Richard Carlsson)
Date: Mon, 12 May 2008 23:06:58 +0200
Subject: [erlang-questions] distinguishing function by arity
In-Reply-To: <4828A178.9060102@gmail.com>
References: <4828A178.9060102@gmail.com>
Message-ID: <4828B172.4070800@it.uu.se>

DougEdmunds wrote:
> Is there a performance hit caused by
> using the same function name with
> alternative arities (such as add/2, add/3)
> instead of using different function
> names (such as add2/2, add3/3)?

No. Effectively, the arity is part of the function name,
so add/2 and add/3 really have different entry points.

     /Richard


From kevin@REDACTED  Mon May 12 23:18:03 2008
From: kevin@REDACTED (Kevin A. Smith)
Date: Mon, 12 May 2008 17:18:03 -0400
Subject: [erlang-questions] 22 May 2008: Robert Virding on Lisp
	Flavoured Erlang, (Stockholm User Group Talk)
In-Reply-To: 
References: <48281201.9040602@erlang-consulting.com>
	
Message-ID: 

+1
On May 12, 2008, at 3:51 PM, Dominique de Waleffe wrote:

> Are there any chance to have access to a recording of this event?
>
> I think thins would be very interesting to more than 1 person.....
>
> Lisp syntax + concurrency + typing.... a dream language....
>
> D.
>
> On Mon, May 12, 2008 at 11:46 AM, Francesco Cesarini  > wrote:
> If you are interested in receiving these types of announcements,  
> please
> register with the Erlang Stockholm User Group mailing list, as we will
> soon be moving all of these announcements there to offload the Erlang
> Questions List. All you need to do is send a blank email to
> erlangstockholm-subscribe@REDACTED and follow the  
> instructions or
> visit the user group page on
> http://www.erlang-consulting.com/erlang/usergroup/ 
> erlangstockholm.html .
>
> The second meeting of the Stockholm Erlang User Group will be hosted  
> by
> Stockholm University on Thursday the 22nd of May starting at 18.30
> (Doors open at 18.00). Robert Virding, one of the original inventors  
> of
> Erlang will present his latest open source project  Lisp Flavored  
> Erlang
> (http://forum.trapexit.org/viewtopic.php?p=43887#43887). If you are
> interested in attending this free event, you have to register. By
> registering, you will enable us to plan room size and refreshments
> accordingly, provide Security with the name list of participants,  
> and in
> those extreme cases where the number of places are limited, close
> registration as soon as we have reached the maximum room capacity or
> find a larger room (As happened last time). You can register on the
> Erlang Stockholm User Group Page here:
> http://www.erlang-consulting.com/erlang/usergroup/erlangstockholm.html
>
> *Abstract:*In this talk we will describe and demonstrate Lisp Flavored
> Erlang (LFE). LFE allows you to write Erlang code in a lisp syntax and
> combines the versatility and extensibility of lisp with the COP  
> power of
> Erlang. LFE is completely integrated with Erlang/OTP and code  
> written in
> LFE can freely be used together with modules written in vanilla Erlang
> and applications in Erlang/OTP. LFE is also much easier to use than
> vanilla Erlang when generating code. We will describe the system, its
> tools and its implementation, and also demonstrate some of its  
> features
> and using its programming environment.
>
> * Biography:*Robert Virding is one of the original developers of  
> Erlang
> at the Ericsson Computer Science Lab. While there he also did work on
> garbage collection and the implementation of high-level languages. He
> left Ericsson to found Bluetail, the first Erlang startup acquired by
> Nortel in 2000. He now works for the Swedish Defense Material
> Administration (FMV) where he is not able to use Erlang. He does,
> however, still program Erlang in his spare time and take part in the
> Erlang community.
>
> See you there!
> Francesco
> --
> http://www.erlang-consulting.com
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
>
>
> -- 
> --
> Dominique de Waleffe
> ddewaleffe -at- gmail -dot- com
> domi -at- dewaleffe -dot- org  
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions



From masse@REDACTED  Tue May 13 00:20:36 2008
From: masse@REDACTED (mats cronqvist)
Date: Tue, 13 May 2008 00:20:36 +0200
Subject: [erlang-questions] Erlang Mode Mavens: customizations?
In-Reply-To: <944da41d0805120529kcdc0824t44cf75b270349106@mail.gmail.com>
References: <944da41d0805120529kcdc0824t44cf75b270349106@mail.gmail.com>
Message-ID: <4828C2B4.2020907@cronqvi.st>

Alex Arnon wrote:
> Hi All,
>
> I'd like to ask you Emacs Proficienados:
> 1. Which keybindings do you add to Erlang Mode? For example, do you 
> bind erlang-find-tag, erlang-indent-clause etc.?
> 2. Are there any other customizations you add on top of Erlang Mode?
  maven... such a great word....
  although i'd hesitate to label myself maven, i did post my (now sadly 
out of date) .emacs a while ago. executive summary; "get distel."
  worth what you pay for it!

http://www.erlang.org/pipermail/erlang-questions/2007-January/024964.html


  mats


From raould@REDACTED  Tue May 13 01:35:30 2008
From: raould@REDACTED (Raoul Duke)
Date: Mon, 12 May 2008 16:35:30 -0700
Subject: [erlang-questions] extreme newbie debugging question: stacks vs.
	messages
Message-ID: <91a2ba3e0805121635h40d96f1bifa54aebeec444463@mail.gmail.com>

hi,

in a shared-mutable-state-concurrency program i can see thread stacks
in the debugger. that can be useful to see the history of changes. i
am guessing that stacks aren't quite the same in a message passing
world; are there standard tricks to watching a parallel/concurrent
program such that you can see some history with associated actor ids?
i guess at the very least one could log (message name, sender id),
maybe with all the values of variables in the current tail-call to the
event handler?

[i am in the midst of searching about this e.g. i skimmed
www.erlang.se/workshop/2004/cronqvist.pdf yet, but am trying to get
around to really reading it.]

thanks.


From dbudworth@REDACTED  Tue May 13 02:53:42 2008
From: dbudworth@REDACTED (David Budworth)
Date: Mon, 12 May 2008 19:53:42 -0500
Subject: [erlang-questions] Fwd:  Question about gen_server:multi_call/2
In-Reply-To: <2e23d1d20805121753m4cc619e7r1b71a88b827a3908@mail.gmail.com>
References: 
	<2e23d1d20805121753m4cc619e7r1b71a88b827a3908@mail.gmail.com>
Message-ID: <2e23d1d20805121753m568860f7sbddc1031c75a31d4@mail.gmail.com>

doh, forgot the reply all.

---------- Forwarded message ----------
From: David Budworth 
Date: Mon, May 12, 2008 at 7:53 PM
Subject: Re: [erlang-questions] Question about gen_server:multi_call/2
To: "Kevin A. Smith" 


I think it's just confusing wording.
reworded, it says that " the service named 'XXX' will be called on all nodes
that have a server locally registered with name 'XXX' "

ie: you have 5 nodes, 4 have a "local" server named XXX.  the server will be
called on all 4 of those nodes.


On Sun, May 11, 2008 at 8:47 PM, Kevin A. Smith 
wrote:

> I've been reading the man page on gen_server and the section
> describing multi_call/2 states:
>
> "Makes  a  synchronous call to all gen_servers locally registered
> as Name at the specified nodes by first  sending  a  request  to
> every  node  and  then  waiting for the replies."
>
> Does this apply to gen_server:multi_call/2? If so, how can I register
> multiple processes on the same node with the same name?
>
> Thanks,
> Kevin
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From fritchie@REDACTED  Tue May 13 04:22:58 2008
From: fritchie@REDACTED (Scott Lystig Fritchie)
Date: Mon, 12 May 2008 21:22:58 -0500
Subject: [erlang-questions] Question about gen_server:multi_call/2
In-Reply-To: Message of "Sun, 11 May 2008 21:47:22 EDT."
	 
Message-ID: <1869.1210645378@snookles.snookles.com>

Kevin A. Smith  wrote:

ks> I've been reading the man page on gen_server and the section
ks> describing multi_call/2 states:

Alas, gen_server:multi_call() cannot be used with non-locally-registered
servers.  You need to roll your own mechanism to do what you're looking
for, which isn't too difficult to do(*) for the simple case.  The
complexity lies in dealing with what happens when one of the remote
servers fails.

Using middle-man processes makes life a lot easier.  And by using
gen_server:call(), we get the remote node monitoring for free.  Untested
code, beware.

%% Inspired by dim memory of Joe Armstrong wisdom from years ago, bugs
%% mine not his.

multi_call(SpecList, Term, Timeout) when is_integer(Timeout) ->
    Me = self(),
    Pids = [spawn(fun() -> X = catch gen_server:call(Spec, Term, Timeout),
                           Me ! {self(), X}
                  end) || Spec <- SpecList],
    [receive {Pid, X} -> X end || Pid <- Pids].

Which doesn't sort real vs. error messages, like gen_server:multi_call()
does.  The above assumes the spawned pids never crashing (and thus
keeping you waiting forever), gen_server:call() handling server
failures, and perhaps several other assumptions I'm forgetting (and
probably let bugs sneak in).

See also in this mailing list (or was it on a TrapExit forum?), perhaps,
discussion about implementing pmap() robustly.

-Scott

(*) But I agree that multi_call() using a mix of Pids, {registered_name,
node}, and {global, Name} should be part of OTP's gen_server.


From igorrs@REDACTED  Tue May 13 06:13:29 2008
From: igorrs@REDACTED (Igor Ribeiro Sucupira)
Date: Tue, 13 May 2008 01:13:29 -0300
Subject: [erlang-questions] Strategies for updating Mnesia tables
In-Reply-To: <62B5ED90-9A76-4C4C-A546-35C43A7060DD@rodanotech.ch>
References: <62B5ED90-9A76-4C4C-A546-35C43A7060DD@rodanotech.ch>
Message-ID: 

On Fri, May 9, 2008 at 12:07 PM, Alexander Lamb
 wrote:
> Hello,
>
>  Although Mnesia columns can store any kind of Erlang terms, it can
>  happen that we need to add a column after an application is deployed.
>  I understood (and tried) how to update the table.
>
>  However, on the contrary to traditionnal SQL databases, this will have
>  an impact on my code. Indeed, something like:
>
>  ps_get_profiles(System_Name,Production_Type) ->
>         F = fun() -> mnesia:match_object(profiles,{profiles,
>  {'_','_','_'},System_Name,Production_Type,'_','_','_'},read) end,
>         case mnesia:transaction(F) of
>                 {atomic, Records}       -> {ok, Records};
>                 {aborted, Reason}       -> {error, Reason}
>         end.
>
>  Will simply find 0 records once I add a column, hence failing silently.

Well... the approach below is VERY ugly, but it should make you able
to add columns without recompiling.

ps_get_profiles(System_Name,Production_Type) ->
    F = fun() -> qlc:eval(qlc:q([ProfilesRecord ||
                                          ProfilesRecord <-
mnesia:table(profiles),
                                          System_Name =:= element(3,
ProfilesRecord),
                                          Production_Type =:=
element(4, ProfilesRecord),
                                          is_tuple(element(2, ProfilesRecord)),
                                          size(element(2,
ProfilesRecord)) =:= 3]))
          end,
    case mnesia:transaction(F) of
        {atomic, Records}       -> {ok, Records};
        {aborted, Reason}       -> {error, Reason}
    end.


But, as I'm pretty new to Erlang (couple of weeks), I suppose there
must be a more beautiful way of doing that.

Igor.

>  Is there a way to match against a variable number of columns, giving
>  the first columns patterns. Something like:
>
>         F = fun() -> mnesia:match_object(profiles,{profiles,
>  {'_','_','_'},System_Name,Production_Type,'_','_','_', * },read) end,
>
>  See the "*" at the end of the match_object match part.
>
>  What is the strategy when updating software that necessitates adding
>  or changing Mnesia tables.
>
>  Thanks,
>
>  Alex
>  --
>  Alexander Lamb
>  Founding Associate
>  RODANOTECH S?rl
>
>  4 ch. de la Tour de Champel
>  1206 Geneva
>  Switzerland
>
>  Tel:  022 347 77 37
>  Fax: 022 347 77 38
>
>  http://www.rodanotech.ch
>
>
>
>  _______________________________________________
>  erlang-questions mailing list
>  erlang-questions@REDACTED
>  http://www.erlang.org/mailman/listinfo/erlang-questions
>


From gleber.p@REDACTED  Tue May 13 08:36:01 2008
From: gleber.p@REDACTED (Gleb Peregud)
Date: Tue, 13 May 2008 08:36:01 +0200
Subject: [erlang-questions] Erlang Mode Mavens: customizations?
In-Reply-To: <4828C2B4.2020907@cronqvi.st>
References: <944da41d0805120529kcdc0824t44cf75b270349106@mail.gmail.com>
	<4828C2B4.2020907@cronqvi.st>
Message-ID: <14f0e3620805122336l64dc462n8e861d0277f33e5c@mail.gmail.com>

That's right. The best extension for the erlang mode is Distel, which
will add a whole bunch of new stuff to learn and master. It adds a lot
of useful functions for an erlang developer

On 5/13/08, mats cronqvist  wrote:
> Alex Arnon wrote:
> > Hi All,
> >
> > I'd like to ask you Emacs Proficienados:
> > 1. Which keybindings do you add to Erlang Mode? For example, do you
> > bind erlang-find-tag, erlang-indent-clause etc.?
> > 2. Are there any other customizations you add on top of Erlang Mode?
>   maven... such a great word....
>   although i'd hesitate to label myself maven, i did post my (now sadly
> out of date) .emacs a while ago. executive summary; "get distel."
>   worth what you pay for it!
>
> http://www.erlang.org/pipermail/erlang-questions/2007-January/024964.html
>
>
>   mats
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>

-- 
Sent from Gmail for mobile | mobile.google.com

Gleb Peregud
http://gleber.pl/

Every minute is to be grasped.
Time waits for nobody.
-- Inscription on a Zen Gong


From shehan@REDACTED  Tue May 13 08:58:41 2008
From: shehan@REDACTED (shehan)
Date: Tue, 13 May 2008 12:28:41 +0530
Subject: [erlang-questions] What is the most stable version ?
Message-ID: <20080513070301.5900019DC1C8@mail.wavenet.lk>

Hi all,

Pls tell me what is most stable & performance improve Erlang version
according to your experiences??  (12B-0 or 12B-1 or 12B-2) 

BR,

Shehan

-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From alex.arnon@REDACTED  Tue May 13 10:41:52 2008
From: alex.arnon@REDACTED (Alex Arnon)
Date: Tue, 13 May 2008 11:41:52 +0300
Subject: [erlang-questions] Erlang Mode Mavens: customizations?
In-Reply-To: <14f0e3620805122336l64dc462n8e861d0277f33e5c@mail.gmail.com>
References: <944da41d0805120529kcdc0824t44cf75b270349106@mail.gmail.com>
	<4828C2B4.2020907@cronqvi.st>
	<14f0e3620805122336l64dc462n8e861d0277f33e5c@mail.gmail.com>
Message-ID: <944da41d0805130141ub40d928scd90df9e7a256a0d@mail.gmail.com>

Thanks guys, I'll do that.
BTW, are there any Distel+Windows (XP/Vista) issues?


On Tue, May 13, 2008 at 9:36 AM, Gleb Peregud  wrote:

> That's right. The best extension for the erlang mode is Distel, which
> will add a whole bunch of new stuff to learn and master. It adds a lot
> of useful functions for an erlang developer
>
> On 5/13/08, mats cronqvist  wrote:
> > Alex Arnon wrote:
> > > Hi All,
> > >
> > > I'd like to ask you Emacs Proficienados:
> > > 1. Which keybindings do you add to Erlang Mode? For example, do you
> > > bind erlang-find-tag, erlang-indent-clause etc.?
> > > 2. Are there any other customizations you add on top of Erlang Mode?
> >   maven... such a great word....
> >   although i'd hesitate to label myself maven, i did post my (now sadly
> > out of date) .emacs a while ago. executive summary; "get distel."
> >   worth what you pay for it!
> >
> >
> http://www.erlang.org/pipermail/erlang-questions/2007-January/024964.html
> >
> >
> >   mats
> > _______________________________________________
> > erlang-questions mailing list
> > erlang-questions@REDACTED
> > http://www.erlang.org/mailman/listinfo/erlang-questions
> >
>
> --
> Sent from Gmail for mobile | mobile.google.com
>
> Gleb Peregud
> http://gleber.pl/
>
> Every minute is to be grasped.
> Time waits for nobody.
> -- Inscription on a Zen Gong
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From raimo+erlang-questions@REDACTED  Tue May 13 10:57:21 2008
From: raimo+erlang-questions@REDACTED (Raimo Niskanen)
Date: Tue, 13 May 2008 10:57:21 +0200
Subject: [erlang-questions] :  First send from JInterface ok,
	second one blocs??
In-Reply-To: <532EB5E3-8DA1-41E5-9814-4F3D5F420665@rodanotech.ch>
References: 
	<532EB5E3-8DA1-41E5-9814-4F3D5F420665@rodanotech.ch>
Message-ID: <20080513085721.GA16248@erix.ericsson.se>

Since you gave no example code I give you counterexample code.
I have done a simple RPC call example:
======================================
import com.ericsson.otp.erlang.*;

public class jrpc {
    public static void main(String[] argv) {
	System.out.println("jrpc hello world!");
	
	try {
	    OtpNode node = new OtpNode(argv[0], argv[1]);
	    OtpMbox mbox = node.createMbox();
	    
	    OtpErlangObject[] call = new OtpErlangObject[5];
	    call[0] = new OtpErlangAtom("call");
	    call[1] = new OtpErlangAtom("erlang");
	    call[2] = new OtpErlangAtom("display");
	    call[3] = new OtpErlangList(new OtpErlangAtom(argv[3]));
	    call[4] = new OtpErlangAtom("user");
	    
	    OtpErlangObject[] req = new OtpErlangObject[2];
	    req[0] = mbox.self();
	    req[1] = new OtpErlangTuple(call);
	    
	    OtpErlangTuple request = new OtpErlangTuple(req);
	    System.out.println("Sending: "+request);
	    mbox.send("rex", argv[2], request);
	    OtpErlangObject reply = mbox.receive();
	    System.out.println("Received: "+reply);
	    
	    System.out.println("Sending: "+request);
	    mbox.send("rex", argv[2], request);
	    reply = mbox.receive();
	    System.out.println("Received: "+reply);
	} catch (java.io.IOException e) {
	    System.out.println("Exited: "+e);
	} catch (OtpErlangException e) {
	    System.out.println("Exited: "+e);
	}
    }
}
======================================



I compile it and then start an erlang node "e@REDACTED". Then:

$java -DOtpConnection.trace=4 jrpc j@REDACTED `cat ~/.erlang.cookie` e@REDACTED hello
jrpc hello world!
-> PUBLISH (r4) j@REDACTED port=10793
<- OK
Sending: {#Pid,{call,erlang,display,[hello],user}}
-> LOOKUP (r4) e@REDACTED
<- PORT 29584
-> MD5 CONNECT TO localhost:29584
-> HANDSHAKE sendName flags=3332 dist=5 local=j@REDACTED
<- HANDSHAKE recvStatus (ok) local=j@REDACTED
<- HANDSHAKE recvChallenge from=e@REDACTED challenge=-250041024 local=j@REDACTED
-> HANDSHAKE sendChallengeReply challenge=2117997141 digest=82c7630368bc22523d0333142822ac34 local=j@REDACTED
<- HANDSHAKE recvChallengeAck from=e@REDACTED digest=b4d2aef7cb4a2e116842ff944e0a874e local=j@REDACTED
-> REG_SEND {6,#Pid,'',rex}
   {#Pid,{call,erlang,display,[hello],user}}
<- SEND {2,'',#Pid}
   {rex,true}
Received: {rex,true}
Sending: {#Pid,{call,erlang,display,[hello],user}}
-> REG_SEND {6,#Pid,'',rex}
   {#Pid,{call,erlang,display,[hello],user}}
<- SEND {2,'',#Pid}
   {rex,true}
Received: {rex,true}

On e@REDACTED it prints `hello' twice in the console. All is well.
If I on the other hand use the wrong connection cookie:

$ java -DOtpConnection.trace=4 jrpc j@REDACTED `cat ~/.erlang.cookie`XXX e@REDACTED hello
jrpc hello world!
-> PUBLISH (r4) j@REDACTED port=1075
<- OK
Sending: {#Pid,{call,erlang,display,[hello],user}}
-> LOOKUP (r4) e@REDACTED
<- PORT 29584
-> MD5 CONNECT TO localhost:29584
-> HANDSHAKE sendName flags=3332 dist=5 local=j@REDACTED
<- HANDSHAKE recvStatus (ok) local=j@REDACTED
<- HANDSHAKE recvChallenge from=e@REDACTED challenge=-1931661201 local=j@REDACTED
-> HANDSHAKE sendChallengeReply challenge=-430223828 digest=02405e8c4263de8ac92f09ec82804b07 local=j@REDACTED
-> CLOSE



The j@REDACTED apparently hangs in the mbox.send(), and
e@REDACTED prints:

=ERROR REPORT==== 13-May-2008::10:43:05 ===
** Connection attempt from disallowed node j@REDACTED ** 



On Mon, May 12, 2008 at 07:32:22PM +0200, Alexander Lamb wrote:
> Some more information: even if I create a new mailbox before each  
> send, it behaves the same way. Impossible to do a second message send  
> (or a ping). If I restart the java application, even without  
> restarting the erlang server, it again works for the first send.
> 
> Alex
> 
> Le 12 mai 08 ? 18:43, Alexander Lamb a ?crit :
> 
> > Hello,
> >
> > I have something curious happening when sending messages to the rex
> > rpc server.
> >
> > The first time I send a message, everything is ok. The second time, it
> > blocs and I finally get a timeout (e.g. the response is null).
> >
> > I activated the trace, and here is what I get:
> >
> > -> PUBLISH (r4) jnode@REDACTED port=55076
> > <- OK
> > -> LOOKUP (r4) alex@REDACTED
> > <- PORT 55021
> > -> MD5 CONNECT TO kirk.local:55021
> > -> HANDSHAKE sendName flags=3332 dist=5 local=jnode@REDACTED
> > <- HANDSHAKE recvStatus (ok) local=jnode@REDACTED
> > <- HANDSHAKE recvChallenge from=alex@REDACTED challenge=1257096912
> > local=jnode@REDACTED
> > -> HANDSHAKE sendChallengeReply challenge=-63103116
> > digest=16202c1233ac821560450cd85550f542 local=jnode@REDACTED
> > <- HANDSHAKE recvChallengeAck from=alex@REDACTED
> > digest=c223cd415468ff024d0529992ab8ec48 local=jnode@REDACTED

Since you got the "<- HANDSHAKE recvChallengeAck" it 
is not the connection cookie.

> > -> REG_SEND {6,#Pid,'',rex}
> >    {#Pid,{call,profiles,get_default_menus,
> > [[84,79,80]],user}}
> > <- SEND {2,'',#Pid}
> >    {rex,{ok,[{menu,home,{{home,"Home"},[{login,"Login"},
> > {logout,"Logout"},{about,"About"}]}},{menu,patients,
> > {{patients,"Patients"},[]}},{menu,centers,{{centers,"Centers"},
> > [{search,"Search"},{list,"List"}]}},{menu,dashboard,
> > {{dashboard,"Dashboard"},[{enrollment,"Enrollment"},
> > {statistics,"Statistics"},{initiation,"Initiation"}]}}]}}
> > -> LOOKUP (r4) alex@REDACTED

Are you initiating another connection to an already
connected node?

> > <- PORT 55021
> > -> MD5 CONNECT TO kirk.local:55021
> > -> HANDSHAKE sendName flags=3332 dist=5 local=jnode@REDACTED

You got thrown out this early. The other node does
not like you. I think it is duplicate connections.
See my example above of sending twice.

> > -> CLOSE
> >
> >
> > So the funny thing is that something is doing a CLOSE. What does that
> > mean??
> >
> > Thanks,
> >
> > Alex
> > _______________________________________________
> > erlang-questions mailing list
> > erlang-questions@REDACTED
> > http://www.erlang.org/mailman/listinfo/erlang-questions
> >
> 
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions

-- 

/ Raimo Niskanen, Erlang/OTP, Ericsson AB


From ingela@REDACTED  Tue May 13 11:15:38 2008
From: ingela@REDACTED (Ingela Anderton Andin)
Date: Tue, 13 May 2008 11:15:38 +0200
Subject: [erlang-questions] Clarification inets httpd mod_log output	issue
Message-ID: <48295C3A.5000608@erix.ericsson.se>

Hi!

I just want to clarify this issue.

When it comes to HTTP logs there are access and error logs. Access logs 
have a predefined format defined by the common log format
and this is followed by inets.  When it comes to the error log the 
format is  not strictly defined.
Inets provides a pretty and a compact representation where the pretty is 
"standard  Erlang indentation" and compact
is the same information but on only one line.

The real problem here is that currently there is no way in erlang io_lib 
to write a entry
with ~p semantics that will have no newline.  That is why the assumption 
was made that sometimes
it might be more important to get one line  to allow easy parsing  and 
let  the  tool handle the formating.
And otherwise use  pretty.  It is  an  error-log and we did not  want to 
sacrifice the information
from an arbitrary crash report just to make the one liner easy to read. 
(pretty is the easy to read the
on liner is actually not always easy to read even with "strings" printed 
as strings.)

We are considering possible improvements for this sometime in the future.

Regards Ingela Erlang/OTP, Ericsson




From alexander.lamb@REDACTED  Tue May 13 11:33:47 2008
From: alexander.lamb@REDACTED (Alexander Lamb)
Date: Tue, 13 May 2008 11:33:47 +0200
Subject: [erlang-questions] :  First send from JInterface ok,
	second one blocs??
In-Reply-To: <20080513085721.GA16248@erix.ericsson.se>
References: 
	<532EB5E3-8DA1-41E5-9814-4F3D5F420665@rodanotech.ch>
	<20080513085721.GA16248@erix.ericsson.se>
Message-ID: <21BB9916-5ABA-42C3-B5A7-30CC70A1D566@rodanotech.ch>

Le 13 mai 08 ? 10:57, Raimo Niskanen a ?crit :

> Since you gave no example code I give you counterexample code.
> I have done a simple RPC call example:

Well, this looks very close to what I am doing I start Erlang like that:

erl -mnesia -setcookie rodanotech -sname alex

I start Java (from Eclipse) with those arguments:

-Djetty.home="/Users/alamb/Library/jetty-5.1.14" -DOtpConnection.trace=4

When my app starts, I create a node like that:

		_otpNode = new OtpNode(OTP_NODE_NAME,OTP_NODE_COOKIE);

with:

	public static final String OTP_NODE_COOKIE = "rodanotech";
	public static final String OTP_NODE_NAME = "jnode";

then I have a class wich creates a mailbox in its constructor:

	_mbox = _node.createMbox();

Finally, I have a function which sends the message to the server:

private OtpErlangObject callFunctionInModuleOnNodeWithArgs(String  
functionName,String moduleName,String nodeName,OtpErlangList args)  
throws SFExceptionTimeout, SFExceptionError {
    OtpErlangObject[] rpc = new OtpErlangObject[2];
    OtpErlangObject[] call = new OtpErlangObject[5];

    call[0] = new OtpErlangAtom("call");
    call[1] = new OtpErlangAtom(moduleName);
    call[2] = new OtpErlangAtom(functionName);
    call[3] = args;
    call[4] = new OtpErlangAtom("user");
    rpc[0] = _mbox.self();
    rpc[1] = new OtpErlangTuple(call);

    OtpErlangObject response = null;

    _mbox.send("rex", nodeName, new OtpErlangTuple(rpc));
	System.out.println("--- message sent");
    try {
    	response = _mbox.receive(_timeout);
    	System.out.println("--- message received: " + response);
    } catch(Exception e) {
    	System.out.println("*** Error receiving message" + e);
    	e.printStackTrace();
    	throw new SFExceptionError(e.getMessage());
    }
    if(response == null)
    	throw new SFExceptionTimeout();
    try {
    	response =  
((com.ericsson.otp.erlang.OtpErlangTuple)response).elementAt(1); //  
skip "rex"
    	OtpErlangAtom status = (OtpErlangAtom) 
((com.ericsson.otp.erlang.OtpErlangTuple)response).elementAt(0);
    	response =  
((com.ericsson.otp.erlang.OtpErlangTuple)response).elementAt(1);
    	if(status.atomValue().equals("error"))
    		throw new SFExceptionError(response.toString());
    } catch(Exception e) {
    	System.out.println("*** Error decoding message" + e);
    	e.printStackTrace();
    	throw new SFExceptionError(e.getMessage());
    }
    return response;
}


Now, the problem is that it works fine the FIRST TIME I call this  
function... but the second time it doesn't and the call doesn't even  
reach my function in Erlang (I added a trace).
So it can't be a cookie problem since otherwise it would not even  
accept a first connection. Something is doing a "close". Should I do  
somthing special on the Erlang or Java side to make the connection  
persistent?

Here is the trace:

--- TEST START...
--- INIT OF SESSION...
--- App module init...
-> PUBLISH (r4) jnode@REDACTED port=57107
<- OK
-> LOOKUP (r4) alex@REDACTED
<- PORT 57102
-> MD5 CONNECT TO kirk.local:57102
-> HANDSHAKE sendName flags=3332 dist=5 local=jnode@REDACTED
<- HANDSHAKE recvStatus (ok) local=jnode@REDACTED
<- HANDSHAKE recvChallenge from=alex@REDACTED challenge=-41504799  
local=jnode@REDACTED
-> HANDSHAKE sendChallengeReply challenge=-1539340064  
digest=0f7f9711c77b2b1a28c0fab48b502046 local=jnode@REDACTED
<- HANDSHAKE recvChallengeAck from=alex@REDACTED  
digest=b04515d124bdaa99e579ebaaa88079d4 local=jnode@REDACTED
-> REG_SEND {6,#Pid,'',rex}
   {#Pid,{call,profiles,get_default_menus, 
[[84,79,80]],user}}
--- message sent
<- SEND {2,'',#Pid}
   {rex,{ok,[{menu,home,{{home,"Home"},[{login,"Login"}, 
{logout,"Logout"},{about,"About"}]}},{menu,patients, 
{{patients,"Patients"},[]}},{menu,centers,{{centers,"Centers"}, 
[{search,"Search"},{list,"List"}]}},{menu,dashboard, 
{{dashboard,"Dashboard"},[{enrollment,"Enrollment"}, 
{statistics,"Statistics"},{initiation,"Initiation"}]}}]}}
--- message received: {rex,{ok,[{menu,home,{{home,"Home"}, 
[{login,"Login"},{logout,"Logout"},{about,"About"}]}},{menu,patients, 
{{patients,"Patients"},[]}},{menu,centers,{{centers,"Centers"}, 
[{search,"Search"},{list,"List"}]}},{menu,dashboard, 
{{dashboard,"Dashboard"},[{enrollment,"Enrollment"}, 
{statistics,"Statistics"},{initiation,"Initiation"}]}}]}}
--- MSG: [{menu,home,{{home,"Home"},[{login,"Login"},{logout,"Logout"}, 
{about,"About"}]}},{menu,patients,{{patients,"Patients"},[]}}, 
{menu,centers,{{centers,"Centers"},[{search,"Search"},{list,"List"}]}}, 
{menu,dashboard,{{dashboard,"Dashboard"},[{enrollment,"Enrollment"}, 
{statistics,"Statistics"},{initiation,"Initiation"}]}}]
-> LOOKUP (r4) alex@REDACTED
<- PORT 57102
-> MD5 CONNECT TO kirk.local:57102
-> HANDSHAKE sendName flags=3332 dist=5 local=jnode@REDACTED
-> CLOSE
--- message sent
--- message received: null
**** EXCEPTION: ch.rodano.erl_jfoundations.model.SFExceptionTimeout


From kenneth.lundin@REDACTED  Tue May 13 12:03:57 2008
From: kenneth.lundin@REDACTED (Kenneth Lundin)
Date: Tue, 13 May 2008 12:03:57 +0200
Subject: [erlang-questions] What is the most stable version ?
In-Reply-To: <20080513070301.5900019DC1C8@mail.wavenet.lk>
References: <20080513070301.5900019DC1C8@mail.wavenet.lk>
Message-ID: 

Hi,

The most recent version in the R12B-x series is by intention always
the most stable and has the best overall performance. If there should
be something
that is significantly broken on important platforms (Linux x86,
Solaris, MacOSX, Windows) we will quickly fix that in a R12B-x+1
release.
I would say that it is very rare that something is broken like that.
Each R12B-x release can be seen as a number of patches added to the
previous one (including new functionality).

So the message from me is that it is always best to pick the most recent release
(currently R12B-2).

/Kenneth Erlang/OTP , Ericsson


On 5/13/08, shehan  wrote:
>
>
>
> Hi all,
>
> Pls tell me what is most stable & performance improve Erlang version
> according to your experiences??  (12B-0 or 12B-1 or 12B-2)
>
> BR,
>
> Shehan
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>


From alexander.lamb@REDACTED  Tue May 13 12:04:52 2008
From: alexander.lamb@REDACTED (Alexander Lamb)
Date: Tue, 13 May 2008 12:04:52 +0200
Subject: [erlang-questions] :  First send from JInterface ok,
	second one blocs??
In-Reply-To: <21BB9916-5ABA-42C3-B5A7-30CC70A1D566@rodanotech.ch>
References: 
	<532EB5E3-8DA1-41E5-9814-4F3D5F420665@rodanotech.ch>
	<20080513085721.GA16248@erix.ericsson.se>
	<21BB9916-5ABA-42C3-B5A7-30CC70A1D566@rodanotech.ch>
Message-ID: <06629D7A-6A06-4834-A2DD-D0F1C9E51E8E@rodanotech.ch>

I added an OtpNodeStatus to follow the status of the connection and on  
the second call here is what I get:

-> LOOKUP (r4) alex@REDACTED
<- PORT 57266
-> MD5 CONNECT TO kirk.local:57266
-> HANDSHAKE sendName flags=3332 dist=5 local=jnode@REDACTED
-> CLOSE
-- CONNECTION ATTEMPT: alex@REDACTED INCOMING: false INFO:  
java.io.IOException: Cannot connect to peer node

Because of the CLOSE, the connection attempt from alex@REDACTED is  
refused!

Le 13 mai 08 ? 11:33, Alexander Lamb a ?crit :

> Le 13 mai 08 ? 10:57, Raimo Niskanen a ?crit :
>
>> Since you gave no example code I give you counterexample code.
>> I have done a simple RPC call example:
>
> Well, this looks very close to what I am doing I start Erlang like  
> that:
>
> erl -mnesia -setcookie rodanotech -sname alex
>
> I start Java (from Eclipse) with those arguments:
>
> -Djetty.home="/Users/alamb/Library/jetty-5.1.14" - 
> DOtpConnection.trace=4
>
> When my app starts, I create a node like that:
>
> 		_otpNode = new OtpNode(OTP_NODE_NAME,OTP_NODE_COOKIE);
>
> with:
>
> 	public static final String OTP_NODE_COOKIE = "rodanotech";
> 	public static final String OTP_NODE_NAME = "jnode";
>
> then I have a class wich creates a mailbox in its constructor:
>
> 	_mbox = _node.createMbox();
>
> Finally, I have a function which sends the message to the server:
>
> private OtpErlangObject callFunctionInModuleOnNodeWithArgs(String
> functionName,String moduleName,String nodeName,OtpErlangList args)
> throws SFExceptionTimeout, SFExceptionError {
>    OtpErlangObject[] rpc = new OtpErlangObject[2];
>    OtpErlangObject[] call = new OtpErlangObject[5];
>
>    call[0] = new OtpErlangAtom("call");
>    call[1] = new OtpErlangAtom(moduleName);
>    call[2] = new OtpErlangAtom(functionName);
>    call[3] = args;
>    call[4] = new OtpErlangAtom("user");
>    rpc[0] = _mbox.self();
>    rpc[1] = new OtpErlangTuple(call);
>
>    OtpErlangObject response = null;
>
>    _mbox.send("rex", nodeName, new OtpErlangTuple(rpc));
> 	System.out.println("--- message sent");
>    try {
>    	response = _mbox.receive(_timeout);
>    	System.out.println("--- message received: " + response);
>    } catch(Exception e) {
>    	System.out.println("*** Error receiving message" + e);
>    	e.printStackTrace();
>    	throw new SFExceptionError(e.getMessage());
>    }
>    if(response == null)
>    	throw new SFExceptionTimeout();
>    try {
>    	response =
> ((com.ericsson.otp.erlang.OtpErlangTuple)response).elementAt(1); //
> skip "rex"
>    	OtpErlangAtom status = (OtpErlangAtom)
> ((com.ericsson.otp.erlang.OtpErlangTuple)response).elementAt(0);
>    	response =
> ((com.ericsson.otp.erlang.OtpErlangTuple)response).elementAt(1);
>    	if(status.atomValue().equals("error"))
>    		throw new SFExceptionError(response.toString());
>    } catch(Exception e) {
>    	System.out.println("*** Error decoding message" + e);
>    	e.printStackTrace();
>    	throw new SFExceptionError(e.getMessage());
>    }
>    return response;
> }
>
>
> Now, the problem is that it works fine the FIRST TIME I call this
> function... but the second time it doesn't and the call doesn't even
> reach my function in Erlang (I added a trace).
> So it can't be a cookie problem since otherwise it would not even
> accept a first connection. Something is doing a "close". Should I do
> somthing special on the Erlang or Java side to make the connection
> persistent?
>
> Here is the trace:
>
> --- TEST START...
> --- INIT OF SESSION...
> --- App module init...
> -> PUBLISH (r4) jnode@REDACTED port=57107
> <- OK
> -> LOOKUP (r4) alex@REDACTED
> <- PORT 57102
> -> MD5 CONNECT TO kirk.local:57102
> -> HANDSHAKE sendName flags=3332 dist=5 local=jnode@REDACTED
> <- HANDSHAKE recvStatus (ok) local=jnode@REDACTED
> <- HANDSHAKE recvChallenge from=alex@REDACTED challenge=-41504799
> local=jnode@REDACTED
> -> HANDSHAKE sendChallengeReply challenge=-1539340064
> digest=0f7f9711c77b2b1a28c0fab48b502046 local=jnode@REDACTED
> <- HANDSHAKE recvChallengeAck from=alex@REDACTED
> digest=b04515d124bdaa99e579ebaaa88079d4 local=jnode@REDACTED
> -> REG_SEND {6,#Pid,'',rex}
>   {#Pid,{call,profiles,get_default_menus,
> [[84,79,80]],user}}
> --- message sent
> <- SEND {2,'',#Pid}
>   {rex,{ok,[{menu,home,{{home,"Home"},[{login,"Login"},
> {logout,"Logout"},{about,"About"}]}},{menu,patients,
> {{patients,"Patients"},[]}},{menu,centers,{{centers,"Centers"},
> [{search,"Search"},{list,"List"}]}},{menu,dashboard,
> {{dashboard,"Dashboard"},[{enrollment,"Enrollment"},
> {statistics,"Statistics"},{initiation,"Initiation"}]}}]}}
> --- message received: {rex,{ok,[{menu,home,{{home,"Home"},
> [{login,"Login"},{logout,"Logout"},{about,"About"}]}},{menu,patients,
> {{patients,"Patients"},[]}},{menu,centers,{{centers,"Centers"},
> [{search,"Search"},{list,"List"}]}},{menu,dashboard,
> {{dashboard,"Dashboard"},[{enrollment,"Enrollment"},
> {statistics,"Statistics"},{initiation,"Initiation"}]}}]}}
> --- MSG: [{menu,home,{{home,"Home"},[{login,"Login"}, 
> {logout,"Logout"},
> {about,"About"}]}},{menu,patients,{{patients,"Patients"},[]}},
> {menu,centers,{{centers,"Centers"},[{search,"Search"}, 
> {list,"List"}]}},
> {menu,dashboard,{{dashboard,"Dashboard"},[{enrollment,"Enrollment"},
> {statistics,"Statistics"},{initiation,"Initiation"}]}}]
> -> LOOKUP (r4) alex@REDACTED
> <- PORT 57102
> -> MD5 CONNECT TO kirk.local:57102
> -> HANDSHAKE sendName flags=3332 dist=5 local=jnode@REDACTED
> -> CLOSE
> --- message sent
> --- message received: null
> **** EXCEPTION: ch.rodano.erl_jfoundations.model.SFExceptionTimeout
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>



From alexander.lamb@REDACTED  Tue May 13 12:27:05 2008
From: alexander.lamb@REDACTED (Alexander Lamb)
Date: Tue, 13 May 2008 12:27:05 +0200
Subject: [erlang-questions] : First send from JInterface ok,
	second one blocs?? FOUND THE PROBLEM
In-Reply-To: <95be1d3b0805130313i13c3749dy2214b1f814555cda@mail.gmail.com>
References: 
	<532EB5E3-8DA1-41E5-9814-4F3D5F420665@rodanotech.ch>
	<20080513085721.GA16248@erix.ericsson.se>
	<21BB9916-5ABA-42C3-B5A7-30CC70A1D566@rodanotech.ch>
	<06629D7A-6A06-4834-A2DD-D0F1C9E51E8E@rodanotech.ch>
	<95be1d3b0805130313i13c3749dy2214b1f814555cda@mail.gmail.com>
Message-ID: 

Ok,

I found the solution but I don't understand why:

When I started the erlang server, I initially wrote:

erl -mnesia -setcookie rodanotech -sname alex (notice the "sname")

It started the node as

(alex@REDACTED)1>

But from my Java program I was forced to write:

"alex@REDACTED" when sending a message from my mailbox.

For some unknown reason, the first call went ok, the any following one  
didn't.

I started a second erlang node to debug the problem and tried using:

erl -mnesia -setcookie rodanotech -name alex (notice without the "s"  
before name)

It started:

(alex@REDACTED)1>

Now it works... but why did it work for each first call when using - 
sname ??? That's what probably put me on the wrong direction to find  
the solution!!

Anyway, thanks a lot for all your help. Once all this is more or less  
stable, I will try to write a small example to explain what we are  
doing.

Alex
--
Alexander Lamb
Founding Associate
RODANOTECH S?rl

4 ch. de la Tour de Champel
1206 Geneva
Switzerland

Tel:  022 347 77 37
Fax: 022 347 77 38

http://www.rodanotech.ch




Le 13 mai 08 ? 12:13, Vlad Dumitrescu a ?crit :

> Hi,
>
> On Tue, May 13, 2008 at 12:04 PM, Alexander Lamb  > wrote:
> I added an OtpNodeStatus to follow the status of the connection and on
> the second call here is what I get:
>
> -> LOOKUP (r4) alex@REDACTED
> <- PORT 57266
> -> MD5 CONNECT TO kirk.local:57266
> -> HANDSHAKE sendName flags=3332 dist=5 local=jnode@REDACTED
> -> CLOSE
> -- CONNECTION ATTEMPT: alex@REDACTED INCOMING: false INFO:
> java.io.IOException: Cannot connect to peer node
>
> Because of the CLOSE, the connection attempt from alex@REDACTED is
> refused!
>
> Can you set a breakpoint on AbstractConnection.close() and look at  
> the stack to see who calls it? It would help to know.
>
> best regards,
> Vlad
>






From mats.cronqvist@REDACTED  Tue May 13 14:51:24 2008
From: mats.cronqvist@REDACTED (Mats Cronqvist)
Date: Tue, 13 May 2008 14:51:24 +0200
Subject: [erlang-questions] Erlang Mode Mavens: customizations?
In-Reply-To: <944da41d0805130141ub40d928scd90df9e7a256a0d@mail.gmail.com>
References: <944da41d0805120529kcdc0824t44cf75b270349106@mail.gmail.com>	<4828C2B4.2020907@cronqvi.st>	<14f0e3620805122336l64dc462n8e861d0277f33e5c@mail.gmail.com>
	<944da41d0805130141ub40d928scd90df9e7a256a0d@mail.gmail.com>
Message-ID: <48298ECC.80507@gmail.com>

Alex Arnon wrote:
> Thanks guys, I'll do that.
> BTW, are there any Distel+Windows (XP/Vista) issues?
  probably. i would guess it's not particularly well-tested. seems there 
is a world-wide shortage of emacs mavens using XP...


From klacke@REDACTED  Tue May 13 15:05:36 2008
From: klacke@REDACTED (Claes Wikstrom)
Date: Tue, 13 May 2008 15:05:36 +0200
Subject: [erlang-questions] flushing IO
Message-ID: <48299220.5080307@hyber.org>


One thing that is sorely missing from Erlang (still) is a
proper way to stop the node and flushing all I/O

init:stop() doesn't ensure that all IO sent through
for example io:format() is indeed flushed. We've had
to add the following incredibly ugly code.


stop(Code) ->
     %% Ugly stuff to make sure ouput is flushed
     User = whereis(user),
     lists:foreach(fun(Port) ->
                           case erlang:port_info(Port, connected) of
                               {connected, User} ->
                                   erlang:port_connect(Port, self()),
                                   Port ! {self(), close},
                                   receive
                                       {Port, closed} -> ok
                                   after 1000 -> ok
                                   end,
                                   erlang:halt(Code);
                               _ -> ok
                           end
                   end, erlang:ports()),
     timer:sleep(1000),
     erlang:halt(Code).


Moreover, ponder the following:

# time erl -noshell -s erlang halt
erl -noshell -s erlang halt  0.09s user 0.01s system 93% cpu 0.111 total
# time erl -noshell -s init stop
erl -noshell -s init stop  0.10s user 0.01s system 10% cpu 1.119 total


I've for quite some time been irritated with init:stop() being slow,
The only reason it appears to flush IO is that somewhere - deep down -
there is some code sleeping for 1 sec.  Buggy. Shutting down should
be more controlled. Not that I have any patches to contribute here and
even if I did I doubt that they would be accepted. Nevertheless, I just
wanted to:

a) Post code that ensures that all IO is flushed.
b) Report the bug.


In init.erl there is code

kill_all_ports(Heart,[P|Ps]) ->
     case erlang:port_info(P,connected) of
	{connected,Heart} ->
	    kill_all_ports(Heart,Ps);
	_ ->
	    case erlang:port_info(P, name) of
		{name, "async"} ->
		    kill_all_ports(Heart,Ps);
		_ ->
		    exit(P,kill),
		    kill_all_ports(Heart,Ps)
	    end
     end;
kill_all_ports(_,_) ->
     ok.


exit(Port, kill) doesn't flush the port IO whereas

                       erlang:port_connect(Port, self()),
                       Port ! {self(), close},
                       receive
                            {Port, closed} -> ok
                       .....

does.



/klacke





From mats.cronqvist@REDACTED  Tue May 13 15:30:55 2008
From: mats.cronqvist@REDACTED (Mats Cronqvist)
Date: Tue, 13 May 2008 15:30:55 +0200
Subject: [erlang-questions] distel doc online
Message-ID: <4829980F.2090705@gmail.com>

  for some fine reason the distel doc is written in the dreaded texinfo 
format.
  for the TeX-impared, i've put up an html version here;

http://cronqvi.st/distel


From stondage123@REDACTED  Tue May 13 16:51:41 2008
From: stondage123@REDACTED (Andrew Stone)
Date: Tue, 13 May 2008 07:51:41 -0700 (PDT)
Subject: [erlang-questions] 22 May 2008: Robert Virding on Lisp
	Flavoured Erlang, (Stockholm User Group Talk)
Message-ID: <219340.56202.qm@web35908.mail.mud.yahoo.com>

I'd love to see this also.

----- Original Message ----
From: Kevin A. Smith 
To: Dominique de Waleffe 
Cc: erlang-questions@REDACTED
Sent: Monday, May 12, 2008 5:18:03 PM
Subject: Re: [erlang-questions] 22 May 2008: Robert Virding on Lisp Flavoured Erlang, (Stockholm User Group Talk)

+1
On May 12, 2008, at 3:51 PM, Dominique de Waleffe wrote:

> Are there any chance to have access to a recording of this event?
>
> I think thins would be very interesting to more than 1 person.....
>
> Lisp syntax + concurrency + typing.... a dream language....
>
> D.
>
> On Mon, May 12, 2008 at 11:46 AM, Francesco Cesarini  > wrote:
> If you are interested in receiving these types of announcements,  
> please
> register with the Erlang Stockholm User Group mailing list, as we will
> soon be moving all of these announcements there to offload the Erlang
> Questions List. All you need to do is send a blank email to
> erlangstockholm-subscribe@REDACTED and follow the  
> instructions or
> visit the user group page on
> http://www.erlang-consulting.com/erlang/usergroup/ 
> erlangstockholm.html .
>
> The second meeting of the Stockholm Erlang User Group will be hosted  
> by
> Stockholm University on Thursday the 22nd of May starting at 18.30
> (Doors open at 18.00). Robert Virding, one of the original inventors  
> of
> Erlang will present his latest open source project  Lisp Flavored  
> Erlang
> (http://forum.trapexit.org/viewtopic.php?p=43887#43887). If you are
> interested in attending this free event, you have to register. By
> registering, you will enable us to plan room size and refreshments
> accordingly, provide Security with the name list of participants,  
> and in
> those extreme cases where the number of places are limited, close
> registration as soon as we have reached the maximum room capacity or
> find a larger room (As happened last time). You can register on the
> Erlang Stockholm User Group Page here:
> http://www.erlang-consulting.com/erlang/usergroup/erlangstockholm.html
>
> *Abstract:*In this talk we will describe and demonstrate Lisp Flavored
> Erlang (LFE). LFE allows you to write Erlang code in a lisp syntax and
> combines the versatility and extensibility of lisp with the COP  
> power of
> Erlang. LFE is completely integrated with Erlang/OTP and code  
> written in
> LFE can freely be used together with modules written in vanilla Erlang
> and applications in Erlang/OTP. LFE is also much easier to use than
> vanilla Erlang when generating code. We will describe the system, its
> tools and its implementation, and also demonstrate some of its  
> features
> and using its programming environment.
>
> * Biography:*Robert Virding is one of the original developers of  
> Erlang
> at the Ericsson Computer Science Lab. While there he also did work on
> garbage collection and the implementation of high-level languages. He
> left Ericsson to found Bluetail, the first Erlang startup acquired by
> Nortel in 2000. He now works for the Swedish Defense Material
> Administration (FMV) where he is not able to use Erlang. He does,
> however, still program Erlang in his spare time and take part in the
> Erlang community.
>
> See you there!
> Francesco
> --
> http://www.erlang-consulting.com
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
>
>
> -- 
> --
> Dominique de Waleffe
> ddewaleffe -at- gmail -dot- com
> domi -at- dewaleffe -dot- org  
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions

_______________________________________________
erlang-questions mailing list
erlang-questions@REDACTED
http://www.erlang.org/mailman/listinfo/erlang-questions



From raimo+erlang-questions@REDACTED  Tue May 13 14:38:26 2008
From: raimo+erlang-questions@REDACTED (Raimo Niskanen)
Date: Tue, 13 May 2008 14:38:26 +0200
Subject: [erlang-questions] :  : First send from JInterface ok,
	second one blocs?? FOUND THE PROBLEM
In-Reply-To: 
References: 
	<532EB5E3-8DA1-41E5-9814-4F3D5F420665@rodanotech.ch>
	<20080513085721.GA16248@erix.ericsson.se>
	<21BB9916-5ABA-42C3-B5A7-30CC70A1D566@rodanotech.ch>
	<06629D7A-6A06-4834-A2DD-D0F1C9E51E8E@rodanotech.ch>
	<95be1d3b0805130313i13c3749dy2214b1f814555cda@mail.gmail.com>
	
Message-ID: <20080513123826.GA6012@erix.ericsson.se>

On Tue, May 13, 2008 at 12:27:05PM +0200, Alexander Lamb wrote:
> Ok,
> 
> I found the solution but I don't understand why:
> 
> When I started the erlang server, I initially wrote:
> 
> erl -mnesia -setcookie rodanotech -sname alex (notice the "sname")
> 
> It started the node as
> 
> (alex@REDACTED)1>
> 
> But from my Java program I was forced to write:
> 
> "alex@REDACTED" when sending a message from my mailbox.

Why was you "forced to write" alex@REDACTED?
The example I tried used -sname e@REDACTED for
the Erlang node and j@REDACTED for the java node.
And while I wrote it I tried using the short host
name a'la e@REDACTED and j@REDACTED (but not kirk), and it worked.

> 
> For some unknown reason, the first call went ok, the any following one  
> didn't.

That is strange since you can not mix long and short names
in an Erlang network. Perhaps something is not quite
as it should be in Jinterface regarding long vs. short
node names.

> 
> I started a second erlang node to debug the problem and tried using:
> 
> erl -mnesia -setcookie rodanotech -name alex (notice without the "s"  
> before name)
> 
> It started:
> 
> (alex@REDACTED)1>
> 
> Now it works... but why did it work for each first call when using - 
> sname ??? That's what probably put me on the wrong direction to find  
> the solution!!
> 
> Anyway, thanks a lot for all your help. Once all this is more or less  
> stable, I will try to write a small example to explain what we are  
> doing.
> 
> Alex
> --
> Alexander Lamb
> Founding Associate
> RODANOTECH S?rl
> 
> 4 ch. de la Tour de Champel
> 1206 Geneva
> Switzerland
> 
> Tel:  022 347 77 37
> Fax: 022 347 77 38
> 
> http://www.rodanotech.ch
> 
> 
> 
> 
> Le 13 mai 08 ? 12:13, Vlad Dumitrescu a ?crit :
> 
> >Hi,
> >
> >On Tue, May 13, 2008 at 12:04 PM, Alexander Lamb 
> > wrote:
> >I added an OtpNodeStatus to follow the status of the connection and on
> >the second call here is what I get:
> >
> >-> LOOKUP (r4) alex@REDACTED
> ><- PORT 57266
> >-> MD5 CONNECT TO kirk.local:57266
> >-> HANDSHAKE sendName flags=3332 dist=5 local=jnode@REDACTED
> >-> CLOSE
> >-- CONNECTION ATTEMPT: alex@REDACTED INCOMING: false INFO:
> >java.io.IOException: Cannot connect to peer node
> >
> >Because of the CLOSE, the connection attempt from alex@REDACTED is
> >refused!
> >
> >Can you set a breakpoint on AbstractConnection.close() and look at  
> >the stack to see who calls it? It would help to know.
> >
> >best regards,
> >Vlad
> >
> 
> 
> 
> 

-- 

/ Raimo Niskanen, Erlang/OTP, Ericsson AB


From raimo+erlang-questions@REDACTED  Tue May 13 11:58:18 2008
From: raimo+erlang-questions@REDACTED (Raimo Niskanen)
Date: Tue, 13 May 2008 11:58:18 +0200
Subject: [erlang-questions] : :  First send from JInterface ok,
	second one blocs??
In-Reply-To: <3F5D02D3-A085-4B0F-937C-817E93B3569E@rodanotech.ch>
References: 
	<532EB5E3-8DA1-41E5-9814-4F3D5F420665@rodanotech.ch>
	<20080513085721.GA16248@erix.ericsson.se>
	<3F5D02D3-A085-4B0F-937C-817E93B3569E@rodanotech.ch>
Message-ID: <20080513095818.GA4594@erix.ericsson.se>

Comments inserted at the end.

On Tue, May 13, 2008 at 11:32:08AM +0200, Alexander Lamb wrote:
> 
> Le 13 mai 08 ? 10:57, Raimo Niskanen a ?crit :
> 
> >Since you gave no example code I give you counterexample code.
> >I have done a simple RPC call example:
> 
> Well, this looks very close to what I am doing I start Erlang like that:
> 
> erl -mnesia -setcookie rodanotech -sname alex
> 
> I start Java (from Eclipse) with those arguments:
> 
> -Djetty.home="/Users/alamb/Library/jetty-5.1.14" -DOtpConnection.trace=4
> 
> When my app starts, I create a node like that:
> 
> 		_otpNode = new OtpNode(OTP_NODE_NAME,OTP_NODE_COOKIE);
> 
> with:
> 
> 	public static final String OTP_NODE_COOKIE = "rodanotech";
> 	public static final String OTP_NODE_NAME = "jnode";
> 
> then I have a class wich creates a mailbox in its constructor:
> 
> 	_mbox = _node.createMbox();
> 
> Finally, I have a function which sends the message to the server:
> 
> private OtpErlangObject callFunctionInModuleOnNodeWithArgs(String  
> functionName,String moduleName,String nodeName,OtpErlangList args)  
> throws SFExceptionTimeout, SFExceptionError {
>     OtpErlangObject[] rpc = new OtpErlangObject[2];
>     OtpErlangObject[] call = new OtpErlangObject[5];
> 
>     call[0] = new OtpErlangAtom("call");
>     call[1] = new OtpErlangAtom(moduleName);
>     call[2] = new OtpErlangAtom(functionName);
>     call[3] = args;
>     call[4] = new OtpErlangAtom("user");
>     rpc[0] = _mbox.self();
>     rpc[1] = new OtpErlangTuple(call);
> 
>     OtpErlangObject response = null;
> 
>     _mbox.send("rex", nodeName, new OtpErlangTuple(rpc));
> 	System.out.println("--- message sent");
>     try {
>     	response = _mbox.receive(_timeout);
>     	System.out.println("--- message received: " + response);
>     } catch(Exception e) {
>     	System.out.println("*** Error receiving message" + e);
>     	e.printStackTrace();
>     	throw new SFExceptionError(e.getMessage());
>     }
>     if(response == null)
>     	throw new SFExceptionTimeout();
>     try {
>     	response =  
> ((com.ericsson.otp.erlang.OtpErlangTuple)response).elementAt(1); //  
> skip "rex"
>     	OtpErlangAtom status = (OtpErlangAtom) 
> ((com.ericsson.otp.erlang.OtpErlangTuple)response).elementAt(0);
>     	response =  
> ((com.ericsson.otp.erlang.OtpErlangTuple)response).elementAt(1);
>     	if(status.atomValue().equals("error"))
>     		throw new SFExceptionError(response.toString());
>     } catch(Exception e) {
>     	System.out.println("*** Error decoding message" + e);
>     	e.printStackTrace();
>     	throw new SFExceptionError(e.getMessage());
>     }
>     return response;
> }
> 
> 
> Now, the problem is that it works fine the FIRST TIME I call this  
> function... but the second time it doesn't and the call doesn't even  
> reach my function in Erlang (I added a trace).
> So it can't be a cookie problem since otherwise it would not even  
> accept a first connection. Something is doing a "close". Should I do  
> somthing special on the Erlang or Java side to make the connection  
> persistent?
> 
> Here is the trace:
> 
> --- TEST START...
> --- INIT OF SESSION...
> --- App module init...
> -> PUBLISH (r4) jnode@REDACTED port=57107
> <- OK
> -> LOOKUP (r4) alex@REDACTED
> <- PORT 57102
> -> MD5 CONNECT TO kirk.local:57102
> -> HANDSHAKE sendName flags=3332 dist=5 local=jnode@REDACTED
> <- HANDSHAKE recvStatus (ok) local=jnode@REDACTED
> <- HANDSHAKE recvChallenge from=alex@REDACTED challenge=-41504799  
> local=jnode@REDACTED
> -> HANDSHAKE sendChallengeReply challenge=-1539340064  
> digest=0f7f9711c77b2b1a28c0fab48b502046 local=jnode@REDACTED
> <- HANDSHAKE recvChallengeAck from=alex@REDACTED  
> digest=b04515d124bdaa99e579ebaaa88079d4 local=jnode@REDACTED
> -> REG_SEND {6,#Pid,'',rex}
>    {#Pid,{call,profiles,get_default_menus, 
> [[84,79,80]],user}}
> --- message sent
> <- SEND {2,'',#Pid}
>    {rex,{ok,[{menu,home,{{home,"Home"},[{login,"Login"}, 
> {logout,"Logout"},{about,"About"}]}},{menu,patients, 
> {{patients,"Patients"},[]}},{menu,centers,{{centers,"Centers"}, 
> [{search,"Search"},{list,"List"}]}},{menu,dashboard, 
> {{dashboard,"Dashboard"},[{enrollment,"Enrollment"}, 
> {statistics,"Statistics"},{initiation,"Initiation"}]}}]}}
> --- message received: {rex,{ok,[{menu,home,{{home,"Home"}, 
> [{login,"Login"},{logout,"Logout"},{about,"About"}]}},{menu,patients, 
> {{patients,"Patients"},[]}},{menu,centers,{{centers,"Centers"}, 
> [{search,"Search"},{list,"List"}]}},{menu,dashboard, 
> {{dashboard,"Dashboard"},[{enrollment,"Enrollment"}, 
> {statistics,"Statistics"},{initiation,"Initiation"}]}}]}}
> --- MSG: [{menu,home,{{home,"Home"},[{login,"Login"},{logout,"Logout"}, 
> {about,"About"}]}},{menu,patients,{{patients,"Patients"},[]}}, 
> {menu,centers,{{centers,"Centers"},[{search,"Search"},{list,"List"}]}}, 
> {menu,dashboard,{{dashboard,"Dashboard"},[{enrollment,"Enrollment"}, 
> {statistics,"Statistics"},{initiation,"Initiation"}]}}]
> -> LOOKUP (r4) alex@REDACTED

As I wrote in my previous mail: I can not understand
this second "-> LOOKUP". It seems like either a new
mbox or a new node is trying to send.

> <- PORT 57102
> -> MD5 CONNECT TO kirk.local:57102
> -> HANDSHAKE sendName flags=3332 dist=5 local=jnode@REDACTED

You get thrown out very early. The erlang node did not
like this node name. I suspect it is a double connection
from the same node name, that is you have created
a new java node with the same name and now tries to
do an RPC call from it.

Check when your objects goes out of scope, how they
get constructed and destructed.

> -> CLOSE
> --- message sent
> --- message received: null
> **** EXCEPTION: ch.rodano.erl_jfoundations.model.SFExceptionTimeout
> 

-- 

/ Raimo Niskanen, Erlang/OTP, Ericsson AB


From klacke@REDACTED  Tue May 13 20:23:49 2008
From: klacke@REDACTED (=?ISO-8859-1?Q?Claes_Wikstr=F6m?=)
Date: Tue, 13 May 2008 20:23:49 +0200
Subject: [erlang-questions] gen_tcp nonblocking send
In-Reply-To: <200805011020.m41AKlKa069023@pluto.hedeland.org>
References: <200805011020.m41AKlKa069023@pluto.hedeland.org>
Message-ID: <4829DCB5.7020903@hyber.org>

Per Hedeland wrote:

> I think this fits a common Erlang solution: "use another process".
> I.e. have a separate "sender" process that just does the potentially
> blocking gen_tcp:send(), ack'ing back to the "real" sender when it

And furthermore if the "intelligent" sender creates the binary() to send
there will be no copying of messages - unless the messages are "small"


/klacke


From vsarpe@REDACTED  Tue May 13 21:28:24 2008
From: vsarpe@REDACTED (Vlad12)
Date: Tue, 13 May 2008 12:28:24 -0700 (PDT)
Subject: [erlang-questions]  Tracing ejabberd
Message-ID: <17216480.post@talk.nabble.com>


Hello, 

Can anyone tell me why every time i run ejabberd on "live" mode (opens an
erlang shell at the node  ejabberd@REDACTED) it does not allow me to run
dbg or fprof functions?

shell$ ./ejabberdct live 

This is what i get if i try to run dbg:tracer(). :

(ejabberd@REDACTED)4> dbg:tracer().
** exited: {undef,[{dbg,tracer,[]},
                   {erl_eval,do_apply,5},
                   {shell,exprs,6},
                   {shell,eval_loop,3}]} **

=ERROR REPORT==== 13-May-2008::13:21:29 ===
Error in process <0.334.0> on node 'ejabberd@REDACTED' with exit value:
{undef,[{dbg,tracer,[]},{erl_eval,do_apply,5},{shell,exprs,6},{shell,eval_loop,3}]}


The error message is similar if i run fprof:trace(start). :

(ejabberd@REDACTED)9> fprof:trace(start).
{'EXIT',<0.354.0>,
        {undef,[{dbg,trace_port,[file,"fprof.trace"]},
                {fprof,open_dbg_trace_port,2},
                {fprof,handle_req,3},
                {fprof,server_loop,1}]}}

=ERROR REPORT==== 13-May-2008::13:25:53 ===
Error in process <0.354.0> on node 'ejabberd@REDACTED' with exit value:
{undef,[{dbg,trace_port,[file,"fprof.trace"]},{fprof,open_dbg_trace_port,2},{fprof,handle_req,3},{fprof,server_loop,1}]}

 Help is greatly appreciated 




-- 
View this message in context: http://www.nabble.com/Tracing-ejabberd-tp17216480p17216480.html
Sent from the Erlang Questions mailing list archive at Nabble.com.



From tuncer.ayaz@REDACTED  Tue May 13 22:52:02 2008
From: tuncer.ayaz@REDACTED (Tuncer Ayaz)
Date: Tue, 13 May 2008 22:52:02 +0200
Subject: [erlang-questions] Tracing ejabberd
In-Reply-To: <17216480.post@talk.nabble.com>
References: <17216480.post@talk.nabble.com>
Message-ID: <4ac8254d0805131352sfc63f9ah4e9a1a38f69f9526@mail.gmail.com>

On Tue, May 13, 2008 at 9:28 PM, Vlad12  wrote:
>
>  Hello,
>
>  Can anyone tell me why every time i run ejabberd on "live" mode (opens an
>  erlang shell at the node  ejabberd@REDACTED) it does not allow me to run
>  dbg or fprof functions?
>
>  shell$ ./ejabberdct live
>
>  This is what i get if i try to run dbg:tracer(). :
>
>  (ejabberd@REDACTED)4> dbg:tracer().
>  ** exited: {undef,[{dbg,tracer,[]},
>                    {erl_eval,do_apply,5},
>                    {shell,exprs,6},
>                    {shell,eval_loop,3}]} **

If I may trust my slowly building Erlang skills this
error means that the system is unable to locate either
the module 'dbg' or the method 'dbg:tracer'.

A wild guess is that ejabberd's runtime config does not
include too many additional libs/modules.

The solution to your problem is something which I hope
to know soon after having digged deeper into ejabberd.
I know this doesn't solve your issue but may help
clear the situation.

>  =ERROR REPORT==== 13-May-2008::13:21:29 ===
>  Error in process <0.334.0> on node 'ejabberd@REDACTED' with exit value:
>  {undef,[{dbg,tracer,[]},{erl_eval,do_apply,5},{shell,exprs,6},{shell,eval_loop,3}]}
>
>
>  The error message is similar if i run fprof:trace(start). :
>
>  (ejabberd@REDACTED)9> fprof:trace(start).
>  {'EXIT',<0.354.0>,
>         {undef,[{dbg,trace_port,[file,"fprof.trace"]},
>                 {fprof,open_dbg_trace_port,2},
>                 {fprof,handle_req,3},
>                 {fprof,server_loop,1}]}}
>
>  =ERROR REPORT==== 13-May-2008::13:25:53 ===
>  Error in process <0.354.0> on node 'ejabberd@REDACTED' with exit value:
>  {undef,[{dbg,trace_port,[file,"fprof.trace"]},{fprof,open_dbg_trace_port,2},{fprof,handle_req,3},{fprof,server_loop,1}]}
>
>   Help is greatly appreciated


From buricchio@REDACTED  Tue May 13 22:55:08 2008
From: buricchio@REDACTED (andrey-google)
Date: Tue, 13 May 2008 23:55:08 +0300
Subject: [erlang-questions] Erlang Mode Mavens: customizations?
In-Reply-To: <944da41d0805130141ub40d928scd90df9e7a256a0d@mail.gmail.com>
References: <944da41d0805120529kcdc0824t44cf75b270349106@mail.gmail.com>
	<4828C2B4.2020907@cronqvi.st>
	<14f0e3620805122336l64dc462n8e861d0277f33e5c@mail.gmail.com>
	<944da41d0805130141ub40d928scd90df9e7a256a0d@mail.gmail.com>
Message-ID: <1054344800.20080513235508@gmail.com>

Hi,
use Distel from google code http://code.google.com/p/distel/
it works on Windows XP well. SourceForge Distel 3.3 won't work on Windows XP.
You may try Wrangler+distel (good refactoring tool) http://www.cs.kent.ac.uk/projects/forse/
Bill Clementson posted very good Distel tutorials on his blog.
IMHO best erlang IDE is:
Emacs + Erlang mode + Distel/Wrangler + ECB + CEDET tools + Esense

> Thanks guys, I'll do that.
> BTW, are there any Distel+Windows (XP/Vista) issues?



From anders.nygren@REDACTED  Tue May 13 23:09:06 2008
From: anders.nygren@REDACTED (Anders Nygren)
Date: Tue, 13 May 2008 16:09:06 -0500
Subject: [erlang-questions] Erlang Mode Mavens: customizations?
In-Reply-To: <1054344800.20080513235508@gmail.com>
References: <944da41d0805120529kcdc0824t44cf75b270349106@mail.gmail.com>
	<4828C2B4.2020907@cronqvi.st>
	<14f0e3620805122336l64dc462n8e861d0277f33e5c@mail.gmail.com>
	<944da41d0805130141ub40d928scd90df9e7a256a0d@mail.gmail.com>
	<1054344800.20080513235508@gmail.com>
Message-ID: 

On Tue, May 13, 2008 at 3:55 PM, andrey-google  wrote:
> Hi,
>  use Distel from google code http://code.google.com/p/distel/
>  it works on Windows XP well. SourceForge Distel 3.3 won't work on Windows XP.
>  You may try Wrangler+distel (good refactoring tool) http://www.cs.kent.ac.uk/projects/forse/
>  Bill Clementson posted very good Distel tutorials on his blog.
>  IMHO best erlang IDE is:
>  Emacs + Erlang mode + Distel/Wrangler + ECB + CEDET tools + Esense
>

Don't forget flymake

/Anders

>
>  > Thanks guys, I'll do that.
>  > BTW, are there any Distel+Windows (XP/Vista) issues?
>
>
>
> _______________________________________________
>  erlang-questions mailing list
>  erlang-questions@REDACTED
>  http://www.erlang.org/mailman/listinfo/erlang-questions
>


From jeffm@REDACTED  Wed May 14 03:49:50 2008
From: jeffm@REDACTED (jm)
Date: Wed, 14 May 2008 11:49:50 +1000
Subject: [erlang-questions] size of an open file
Message-ID: <482A453E.9010807@ghostgun.com>

How do I get the size of an open file? file:read_file_info(Filename) 
does it based on the name of the file but what about using an IoDevice 
as returned by file:open/2.

Jeff.


From dbarker@REDACTED  Wed May 14 04:59:57 2008
From: dbarker@REDACTED (Deryk Barker)
Date: Tue, 13 May 2008 19:59:57 -0700
Subject: [erlang-questions] Registered names and pids
Message-ID: <482A55AD.3090900@camosun.bc.ca>

Maybe I shouldn't need to know this, but I can't find any obvious way: 
is it possible, given the name of a registered process, to find its pid: 
a) on the same nod b) on another node?

Merci.

-- 
|Deryk Barker, Computer Science Dept. | Music does not have to be understood|
|Camosun College, Victoria, BC, Canada| It has to be listened to.           |
|email: dbarker@REDACTED         |                                     |
|phone: +1 250 370 4452               |         Hermann Scherchen.          |




From anders.nygren@REDACTED  Wed May 14 05:24:32 2008
From: anders.nygren@REDACTED (Anders Nygren)
Date: Tue, 13 May 2008 22:24:32 -0500
Subject: [erlang-questions] Registered names and pids
In-Reply-To: <482A55AD.3090900@camosun.bc.ca>
References: <482A55AD.3090900@camosun.bc.ca>
Message-ID: 

On Tue, May 13, 2008 at 9:59 PM, Deryk Barker  wrote:
> Maybe I shouldn't need to know this, but I can't find any obvious way:
>  is it possible, given the name of a registered process, to find its pid:
>  a) on the same nod b) on another node?
>
>  Merci.

Locally registered name
whereis(Name)

Globally registered name
global:whereis_name(Name)

Locally registered on another node
rpc:call('Node, erlang, whereis,[Name]).

/Anders

>
>  --
>  |Deryk Barker, Computer Science Dept. | Music does not have to be understood|
>  |Camosun College, Victoria, BC, Canada| It has to be listened to.           |
>  |email: dbarker@REDACTED         |                                     |
>  |phone: +1 250 370 4452               |         Hermann Scherchen.          |
>
>
>  _______________________________________________
>  erlang-questions mailing list
>  erlang-questions@REDACTED
>  http://www.erlang.org/mailman/listinfo/erlang-questions
>


From erlangy@REDACTED  Wed May 14 05:25:01 2008
From: erlangy@REDACTED (Michael McDaniel)
Date: Tue, 13 May 2008 20:25:01 -0700
Subject: [erlang-questions] Registered names and pids
In-Reply-To: <482A55AD.3090900@camosun.bc.ca>
References: <482A55AD.3090900@camosun.bc.ca>
Message-ID: <20080514032501.GY8868@delora.autosys.us>

On Tue, May 13, 2008 at 07:59:57PM -0700, Deryk Barker wrote:
> Maybe I shouldn't need to know this, but I can't find any obvious way: 
> is it possible, given the name of a registered process, to find its pid: 
> a) on the same nod b) on another node?
> _______________________________________________

 
  see modules global and erlang

  e.g. ...

(fu@REDACTED)53> global:registered_names().
[mail_block_gserver,
 zadora_block_gserver,
 xq02_block_gserver,
 autosys_alarm,
 cougora_block_gserver]
(fu@REDACTED)54> global:whereis_name(mail_block_gserver). 
<5656.288.0>
(fu@REDACTED)55> global:whereis_name(autosys_alarm).     
<5447.76.0>
(fu@REDACTED)56> self().
<0.8952.0>
(fu@REDACTED)57> erlang:registered().
[auth,
 net_sup,
 net_kernel,
 kernel_sup,
 application_controller, ... ]
(fu@REDACTED)58> erlang:whereis(net_sup).
<0.17.0>


~Michael



> 
> Merci.
> 
> -- 
> |Deryk Barker, Computer Science Dept. | Music does not have to be understood|
> |Camosun College, Victoria, BC, Canada| It has to be listened to.           |
> |email: dbarker@REDACTED         |                                     |
> |phone: +1 250 370 4452               |         Hermann Scherchen.          |
> 
> 
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions

-- 
Michael McDaniel
Portland, Oregon, USA
http://autosys.us
+1 503 283 5284


From erlang-questions_efine@REDACTED  Wed May 14 07:12:16 2008
From: erlang-questions_efine@REDACTED (Edwin Fine)
Date: Wed, 14 May 2008 01:12:16 -0400
Subject: [erlang-questions] Automagically figuring out valid process_info
	Items
Message-ID: <6c2563b20805132212l5ad5bb6dsc03d754dbcef031c@mail.gmail.com>

I want to find out, at run time, which info items (e.g. heap_size)
process_info/2 supports. This is so I don't have to go changing code every
time an item is added (or removed, which seems unlikely). What I have done,
which I know is frowned upon, is to use the dreaded process_info/1 BIF to
get a list of supported info items, something like this:

5> [K || {K,_} <- process_info(pid(0,0,0))].
[registered_name,current_function,initial_call,status,
 message_queue_len,messages,links,dictionary,trap_exit,
 error_handler,priority,group_leader,total_heap_size,
 heap_size,stack_size,reductions,garbage_collection,
 suspending]

Two problems.

   - There is a dire warning in red that process_info/1 is for debugging
   only and that process_info/2 should be used for all other purposes,
   presumably on pain of death, shunning, excommunication, finger-pointing, or
   worse :)
   - Not all the supported info items are returned by process_info/1,
   which of course I can't complain about because it's for debugging only.

Short of hard-coding the names of all the info items, or scanning the
documentation at run-time, is there any way to do what I want to do using
only standard BIFs or some other clever thing?

Regards,
Edwin Fine
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From francesco@REDACTED  Wed May 14 09:01:31 2008
From: francesco@REDACTED (Francesco Cesarini)
Date: Wed, 14 May 2008 08:01:31 +0100
Subject: [erlang-questions] 22 May 2008: Robert Virding on
 Lisp	Flavoured Erlang, (Stockholm User Group Talk)
In-Reply-To: <219340.56202.qm@web35908.mail.mud.yahoo.com>
References: <219340.56202.qm@web35908.mail.mud.yahoo.com>
Message-ID: <482A8E4B.8030004@erlang-consulting.com>

Robert has kindly agreed to have this event taped. We'll put it on 
google video.

Francesco
--
http://www.erlang-consulting.com

Andrew Stone wrote:
> I'd love to see this also.
>
> ----- Original Message ----
> From: Kevin A. Smith 
> To: Dominique de Waleffe 
> Cc: erlang-questions@REDACTED
> Sent: Monday, May 12, 2008 5:18:03 PM
> Subject: Re: [erlang-questions] 22 May 2008: Robert Virding on Lisp Flavoured Erlang, (Stockholm User Group Talk)
>
> +1
> On May 12, 2008, at 3:51 PM, Dominique de Waleffe wrote:
>
>   
>> Are there any chance to have access to a recording of this event?
>>
>> I think thins would be very interesting to more than 1 person.....
>>
>> Lisp syntax + concurrency + typing.... a dream language....
>>
>> D.
>>
>> On Mon, May 12, 2008 at 11:46 AM, Francesco Cesarini >     
>>> wrote:
>>>       
>> If you are interested in receiving these types of announcements,  
>> please
>> register with the Erlang Stockholm User Group mailing list, as we will
>> soon be moving all of these announcements there to offload the Erlang
>> Questions List. All you need to do is send a blank email to
>> erlangstockholm-subscribe@REDACTED and follow the  
>> instructions or
>> visit the user group page on
>> http://www.erlang-consulting.com/erlang/usergroup/ 
>> erlangstockholm.html .
>>
>> The second meeting of the Stockholm Erlang User Group will be hosted  
>> by
>> Stockholm University on Thursday the 22nd of May starting at 18.30
>> (Doors open at 18.00). Robert Virding, one of the original inventors  
>> of
>> Erlang will present his latest open source project  Lisp Flavored  
>> Erlang
>> (http://forum.trapexit.org/viewtopic.php?p=43887#43887). If you are
>> interested in attending this free event, you have to register. By
>> registering, you will enable us to plan room size and refreshments
>> accordingly, provide Security with the name list of participants,  
>> and in
>> those extreme cases where the number of places are limited, close
>> registration as soon as we have reached the maximum room capacity or
>> find a larger room (As happened last time). You can register on the
>> Erlang Stockholm User Group Page here:
>> http://www.erlang-consulting.com/erlang/usergroup/erlangstockholm.html
>>
>> *Abstract:*In this talk we will describe and demonstrate Lisp Flavored
>> Erlang (LFE). LFE allows you to write Erlang code in a lisp syntax and
>> combines the versatility and extensibility of lisp with the COP  
>> power of
>> Erlang. LFE is completely integrated with Erlang/OTP and code  
>> written in
>> LFE can freely be used together with modules written in vanilla Erlang
>> and applications in Erlang/OTP. LFE is also much easier to use than
>> vanilla Erlang when generating code. We will describe the system, its
>> tools and its implementation, and also demonstrate some of its  
>> features
>> and using its programming environment.
>>
>> * Biography:*Robert Virding is one of the original developers of  
>> Erlang
>> at the Ericsson Computer Science Lab. While there he also did work on
>> garbage collection and the implementation of high-level languages. He
>> left Ericsson to found Bluetail, the first Erlang startup acquired by
>> Nortel in 2000. He now works for the Swedish Defense Material
>> Administration (FMV) where he is not able to use Erlang. He does,
>> however, still program Erlang in his spare time and take part in the
>> Erlang community.
>>
>> See you there!
>> Francesco
>> --
>> http://www.erlang-consulting.com
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://www.erlang.org/mailman/listinfo/erlang-questions
>>
>>
>>
>> -- 
>> --
>> Dominique de Waleffe
>> ddewaleffe -at- gmail -dot- com
>> domi -at- dewaleffe -dot- org  
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://www.erlang.org/mailman/listinfo/erlang-questions
>>     
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
>   



From alexander.lamb@REDACTED  Wed May 14 09:04:40 2008
From: alexander.lamb@REDACTED (Alexander Lamb)
Date: Wed, 14 May 2008 09:04:40 +0200
Subject: [erlang-questions] :  : First send from JInterface ok,
	second one blocs?? FOUND THE PROBLEM
In-Reply-To: <20080513123826.GA6012@erix.ericsson.se>
References: 
	<532EB5E3-8DA1-41E5-9814-4F3D5F420665@rodanotech.ch>
	<20080513085721.GA16248@erix.ericsson.se>
	<21BB9916-5ABA-42C3-B5A7-30CC70A1D566@rodanotech.ch>
	<06629D7A-6A06-4834-A2DD-D0F1C9E51E8E@rodanotech.ch>
	<95be1d3b0805130313i13c3749dy2214b1f814555cda@mail.gmail.com>
	
	<20080513123826.GA6012@erix.ericsson.se>
Message-ID: <365E10E3-595D-4795-980B-9A72A4329D50@rodanotech.ch>

Answers in the text.

Le 13 mai 08 ? 14:38, Raimo Niskanen a ?crit :

> On Tue, May 13, 2008 at 12:27:05PM +0200, Alexander Lamb wrote:
>> Ok,
>>
>> I found the solution but I don't understand why:
>>
>> When I started the erlang server, I initially wrote:
>>
>> erl -mnesia -setcookie rodanotech -sname alex (notice the "sname")
>>
>> It started the node as
>>
>> (alex@REDACTED)1>
>>
>> But from my Java program I was forced to write:
>>
>> "alex@REDACTED" when sending a message from my mailbox.
>
> Why was you "forced to write" alex@REDACTED?
> The example I tried used -sname e@REDACTED for
> the Erlang node and j@REDACTED for the java node.
> And while I wrote it I tried using the short host
> name a'la e@REDACTED and j@REDACTED (but not kirk), and it worked.

Because otherwise it wouldn't connect even though the node was started  
as alex@REDACTED

Now, my impression is that this is a special effect of MacOSX (I am  
running the 10.5.2 on Intel with the latest version of Erlang). It is  
probable that the way name resolution works locally (the two nodes on  
my desktop) is different from Linux.

>
>
>>
>> For some unknown reason, the first call went ok, the any following  
>> one
>> didn't.
>
> That is strange since you can not mix long and short names
> in an Erlang network. Perhaps something is not quite
> as it should be in Jinterface regarding long vs. short
> node names.

Exactly, but imagine the first lookup (the one which will lead to  
create a connection between the two nodes) is done in one way, then  
the second lookup (once the connection is made) is done differently...

>
>
>>
>> I started a second erlang node to debug the problem and tried using:
>>
>> erl -mnesia -setcookie rodanotech -name alex (notice without the "s"
>> before name)
>>
>> It started:
>>
>> (alex@REDACTED)1>
>>
>> Now it works... but why did it work for each first call when using -
>> sname ??? That's what probably put me on the wrong direction to find
>> the solution!!
>>
>> Anyway, thanks a lot for all your help. Once all this is more or less
>> stable, I will try to write a small example to explain what we are
>> doing.
>>
>> Alex
>> --
>> Alexander Lamb
>> Founding Associate
>> RODANOTECH S?rl
>>
>> 4 ch. de la Tour de Champel
>> 1206 Geneva
>> Switzerland
>>
>> Tel:  022 347 77 37
>> Fax: 022 347 77 38
>>
>> http://www.rodanotech.ch
>>
>>
>>
>>
>> Le 13 mai 08 ? 12:13, Vlad Dumitrescu a ?crit :
>>
>>> Hi,
>>>
>>> On Tue, May 13, 2008 at 12:04 PM, Alexander Lamb
>>>  wrote:
>>> I added an OtpNodeStatus to follow the status of the connection  
>>> and on
>>> the second call here is what I get:
>>>
>>> -> LOOKUP (r4) alex@REDACTED
>>> <- PORT 57266
>>> -> MD5 CONNECT TO kirk.local:57266
>>> -> HANDSHAKE sendName flags=3332 dist=5 local=jnode@REDACTED
>>> -> CLOSE
>>> -- CONNECTION ATTEMPT: alex@REDACTED INCOMING: false INFO:
>>> java.io.IOException: Cannot connect to peer node
>>>
>>> Because of the CLOSE, the connection attempt from alex@REDACTED is
>>> refused!
>>>
>>> Can you set a breakpoint on AbstractConnection.close() and look at
>>> the stack to see who calls it? It would help to know.
>>>
>>> best regards,
>>> Vlad
>>>
>>
>>
>>
>>
>
> -- 
>
> / Raimo Niskanen, Erlang/OTP, Ericsson AB
>



From francesco@REDACTED  Wed May 14 09:08:03 2008
From: francesco@REDACTED (Francesco Cesarini)
Date: Wed, 14 May 2008 08:08:03 +0100
Subject: [erlang-questions] Tracing ejabberd
In-Reply-To: <4ac8254d0805131352sfc63f9ah4e9a1a38f69f9526@mail.gmail.com>
References: <17216480.post@talk.nabble.com>
	<4ac8254d0805131352sfc63f9ah4e9a1a38f69f9526@mail.gmail.com>
Message-ID: <482A8FD3.2040000@erlang-consulting.com>

You are probably running Erlang in embedded mode, which loads all the 
modules at startup. I assume that the runtime tools application is not 
part of the build. That is where dbg is.

Also, because of the strange setup with ejabberd, you probably need to 
play around before you are able to get any trace messages.
to run dbg on an ejabbed node and bypass the group leader io problem, 
you have to

* Start a distributed Erlang Node
* Connect to the Ejabberd Cluster
* Start the tracer
* Connect the ejabberd nodes to the tracer
* Pick which processes and functions to trace

In pseudo code, you would do something like this:

erl -sname dbg -setcookie COOKIE   (Where COOKIE is the same cookie as 
the ejabberd node)

1> net_adm:ping(EJABBERDNODENAME). (Where EJABBERDNODENAME is the 
distributed Erlang node name running on EjabberD).
2> dbg:tracer().
3> lists:foreach(fun(Node) -> dbg:n(Node) end, nodes()).

You can now use all of the trace commands and get the ourput redirected 
to your shell. They include dbg:p/2 to pick which processes to trace and 
dbg:tp for global calls and dbg:tpl for local ones.

hope this helps,
Francesco
--
http://www.erlang-consulting.com

Tuncer Ayaz wrote:
> On Tue, May 13, 2008 at 9:28 PM, Vlad12  wrote:
>   
>>  Hello,
>>
>>  Can anyone tell me why every time i run ejabberd on "live" mode (opens an
>>  erlang shell at the node  ejabberd@REDACTED) it does not allow me to run
>>  dbg or fprof functions?
>>
>>  shell$ ./ejabberdct live
>>
>>  This is what i get if i try to run dbg:tracer(). :
>>
>>  (ejabberd@REDACTED)4> dbg:tracer().
>>  ** exited: {undef,[{dbg,tracer,[]},
>>                    {erl_eval,do_apply,5},
>>                    {shell,exprs,6},
>>                    {shell,eval_loop,3}]} **
>>     
>
> If I may trust my slowly building Erlang skills this
> error means that the system is unable to locate either
> the module 'dbg' or the method 'dbg:tracer'.
>
> A wild guess is that ejabberd's runtime config does not
> include too many additional libs/modules.
>
> The solution to your problem is something which I hope
> to know soon after having digged deeper into ejabberd.
> I know this doesn't solve your issue but may help
> clear the situation.
>
>   
>>  =ERROR REPORT==== 13-May-2008::13:21:29 ===
>>  Error in process <0.334.0> on node 'ejabberd@REDACTED' with exit value:
>>  {undef,[{dbg,tracer,[]},{erl_eval,do_apply,5},{shell,exprs,6},{shell,eval_loop,3}]}
>>
>>
>>  The error message is similar if i run fprof:trace(start). :
>>
>>  (ejabberd@REDACTED)9> fprof:trace(start).
>>  {'EXIT',<0.354.0>,
>>         {undef,[{dbg,trace_port,[file,"fprof.trace"]},
>>                 {fprof,open_dbg_trace_port,2},
>>                 {fprof,handle_req,3},
>>                 {fprof,server_loop,1}]}}
>>
>>  =ERROR REPORT==== 13-May-2008::13:25:53 ===
>>  Error in process <0.354.0> on node 'ejabberd@REDACTED' with exit value:
>>  {undef,[{dbg,trace_port,[file,"fprof.trace"]},{fprof,open_dbg_trace_port,2},{fprof,handle_req,3},{fprof,server_loop,1}]}
>>
>>   Help is greatly appreciated
>>     
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
>   



From matthias@REDACTED  Wed May 14 08:08:01 2008
From: matthias@REDACTED (Matthias Lang)
Date: Wed, 14 May 2008 08:08:01 +0200
Subject: [erlang-questions] Registered names and pids
In-Reply-To: <482A55AD.3090900@camosun.bc.ca>
References: <482A55AD.3090900@camosun.bc.ca>
Message-ID: <18474.33217.120772.989936@antilipe.corelatus.se>

Deryk Barker writes:
 > Maybe I shouldn't need to know this, but I can't find any obvious way: 
 > is it possible, given the name of a registered process, to find its pid: 
 > a) on the same nod b) on another node?

It sounds like you haven't stumbled across erlang:whereis/1 yet:

  1> Pid = spawn(fun() -> timer:sleep(12000) end).
  <0.34.0>
  2> register(name, Pid).
  true
  3> whereis(name).
  <0.34.0>

It also handles part b.

The 'erlang' module contains lots of useful things (and quite a few
obscure ones too), so it's worth taking a look through:

  http://erlang.org/doc/man/erlang.html

Matt


From vladdu55@REDACTED  Wed May 14 09:25:38 2008
From: vladdu55@REDACTED (Vlad Dumitrescu)
Date: Wed, 14 May 2008 09:25:38 +0200
Subject: [erlang-questions] : : First send from JInterface ok,
	second one blocs?? FOUND THE PROBLEM
In-Reply-To: <365E10E3-595D-4795-980B-9A72A4329D50@rodanotech.ch>
References: 
	<532EB5E3-8DA1-41E5-9814-4F3D5F420665@rodanotech.ch>
	<20080513085721.GA16248@erix.ericsson.se>
	<21BB9916-5ABA-42C3-B5A7-30CC70A1D566@rodanotech.ch>
	<06629D7A-6A06-4834-A2DD-D0F1C9E51E8E@rodanotech.ch>
	<95be1d3b0805130313i13c3749dy2214b1f814555cda@mail.gmail.com>
	
	<20080513123826.GA6012@erix.ericsson.se>
	<365E10E3-595D-4795-980B-9A72A4329D50@rodanotech.ch>
Message-ID: <95be1d3b0805140025o6a44060ax7f88626304d8fbf8@mail.gmail.com>

Hi,

On Wed, May 14, 2008 at 9:04 AM, Alexander Lamb
 wrote:

> Now, my impression is that this is a special effect of MacOSX (I am
> running the 10.5.2 on Intel with the latest version of Erlang). It is
> probable that the way name resolution works locally (the two nodes on
> my desktop) is different from Linux.
>

This could be the reason. Working with ErlIDE, I got many bug reports about
the connection between Java and Erlang not working on OSX. I think almost
all of them were caused by this mismatch between how Java and Erlang look up
hosts by name. We had to use long names for the Erlang nodes.

This doesn't really answer why it did work the first time. Like Raimo said,
maybe the connection is retried several times. The connection can be closed
for several reasons, for example if data that can't be decoded is received.
Hard to tell without any additional info.

regards,
Vlad
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From alexander.lamb@REDACTED  Wed May 14 09:34:07 2008
From: alexander.lamb@REDACTED (Alexander Lamb)
Date: Wed, 14 May 2008 09:34:07 +0200
Subject: [erlang-questions] : : First send from JInterface ok,
	second one blocs?? FOUND THE PROBLEM
In-Reply-To: <95be1d3b0805140025o6a44060ax7f88626304d8fbf8@mail.gmail.com>
References: 
	<532EB5E3-8DA1-41E5-9814-4F3D5F420665@rodanotech.ch>
	<20080513085721.GA16248@erix.ericsson.se>
	<21BB9916-5ABA-42C3-B5A7-30CC70A1D566@rodanotech.ch>
	<06629D7A-6A06-4834-A2DD-D0F1C9E51E8E@rodanotech.ch>
	<95be1d3b0805130313i13c3749dy2214b1f814555cda@mail.gmail.com>
	
	<20080513123826.GA6012@erix.ericsson.se>
	<365E10E3-595D-4795-980B-9A72A4329D50@rodanotech.ch>
	<95be1d3b0805140025o6a44060ax7f88626304d8fbf8@mail.gmail.com>
Message-ID: 

Is it important to dig further? Or can we (for the time being) suggest  
that on MacOSX NOT to use short names?

Of course, I can setup a test case, but being new to Erlang, I might  
not be looking for the right things.
Tell me if you want me to check some additional info!

To answer a previous question from Raimo, I traced the objects I use  
to connect (especially the mailbox) and I can confirm that my test was  
using only one object. Therefore, we are clearly in a situation where  
upon setting up the connection the lookup works one way and for  
following lookups it works in another way.

Alex

Le 14 mai 08 ? 09:25, Vlad Dumitrescu a ?crit :

> Hi,
>
> On Wed, May 14, 2008 at 9:04 AM, Alexander Lamb  > wrote:
> Now, my impression is that this is a special effect of MacOSX (I am
> running the 10.5.2 on Intel with the latest version of Erlang). It is
> probable that the way name resolution works locally (the two nodes on
> my desktop) is different from Linux.
>
> This could be the reason. Working with ErlIDE, I got many bug  
> reports about the connection between Java and Erlang not working on  
> OSX. I think almost all of them were caused by this mismatch between  
> how Java and Erlang look up hosts by name. We had to use long names  
> for the Erlang nodes.
>
> This doesn't really answer why it did work the first time. Like  
> Raimo said, maybe the connection is retried several times. The  
> connection can be closed for several reasons, for example if data  
> that can't be decoded is received. Hard to tell without any  
> additional info.
>
> regards,
> Vlad
>
>
>



From bengt.kleberg@REDACTED  Wed May 14 09:44:18 2008
From: bengt.kleberg@REDACTED (Bengt Kleberg)
Date: Wed, 14 May 2008 09:44:18 +0200
Subject: [erlang-questions] size of an open file
In-Reply-To: <482A453E.9010807@ghostgun.com>
References: <482A453E.9010807@ghostgun.com>
Message-ID: <1210751058.1111.9.camel@seasc0642.dyn.rnd.as.sw.ericsson.se>

Greetings,

You have 2 possibilities according to the manual of the file module:
1) file:position/2 should return the file size, if called with 'eof' as
Position
2) if this is for debugging you can use file:pid2name/1 and get the file
name (for subsequent use in file:read_file_info/1).


bengt

On Wed, 2008-05-14 at 11:49 +1000, jm wrote:
> How do I get the size of an open file? file:read_file_info(Filename) 
> does it based on the name of the file but what about using an IoDevice 
> as returned by file:open/2.
> 
> Jeff.
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions



From jachym.holecek@REDACTED  Wed May 14 09:56:42 2008
From: jachym.holecek@REDACTED (Jachym Holecek)
Date: Wed, 14 May 2008 09:56:42 +0200
Subject: [erlang-questions] Erlang Mode Mavens: customizations?
In-Reply-To: <1054344800.20080513235508@gmail.com>
References: <944da41d0805120529kcdc0824t44cf75b270349106@mail.gmail.com>
	<4828C2B4.2020907@cronqvi.st>
	<14f0e3620805122336l64dc462n8e861d0277f33e5c@mail.gmail.com>
	<944da41d0805130141ub40d928scd90df9e7a256a0d@mail.gmail.com>
	<1054344800.20080513235508@gmail.com>
Message-ID: 

On Tue, 13 May 2008 22:55:08 +0200, andrey-google   
wrote:
> Hi,
> use Distel from google code http://code.google.com/p/distel/
> it works on Windows XP well. SourceForge Distel 3.3 won't work on  
> Windows XP.
> You may try Wrangler+distel (good refactoring tool)  
> http://www.cs.kent.ac.uk/projects/forse/
> Bill Clementson posted very good Distel tutorials on his blog.
> IMHO best erlang IDE is:
> Emacs + Erlang mode + Distel/Wrangler + ECB + CEDET tools + Esense

+ tabbar mode.

     -- Jachym



From jeffm@REDACTED  Wed May 14 10:15:57 2008
From: jeffm@REDACTED (jm)
Date: Wed, 14 May 2008 18:15:57 +1000
Subject: [erlang-questions] size of an open file
In-Reply-To: <1210751058.1111.9.camel@seasc0642.dyn.rnd.as.sw.ericsson.se>
References: <482A453E.9010807@ghostgun.com>
	<1210751058.1111.9.camel@seasc0642.dyn.rnd.as.sw.ericsson.se>
Message-ID: <482A9FBD.8010401@ghostgun.com>



Bengt Kleberg wrote:
> Greetings,
>
> You have 2 possibilities according to the manual of the file module:
> 1) file:position/2 should return the file size, if called with 'eof' as
> Position
> 2) if this is for debugging you can use file:pid2name/1 and get the file
> name (for subsequent use in file:read_file_info/1).
>
>   

Thanks. Last question I hope. In attempting to tail a log file:  How do 
you detect that the file has rolled over, ie a new log file has been 
created?
Is there a smarter way than comparing the size of the open file and the 
size of the file by name? I can see a couple of problems with this method.
To begin with if the new log file grows larger than the old log file 
before there is a chance to switch files. I suppose you could do

 SizeOfOpen =:= SizeofNamedFile

but this doesn't seem right. Really, a comparison should be done on the 
filenames, ie compare the name of the currently open file with that of 
the requested filename to detect a roll over, but I don't see a 
file:read_file_info/1 for open files.

Jeff.



From raimo+erlang-questions@REDACTED  Wed May 14 10:50:55 2008
From: raimo+erlang-questions@REDACTED (Raimo Niskanen)
Date: Wed, 14 May 2008 10:50:55 +0200
Subject: [erlang-questions] :  : : First send from JInterface ok,
	second one blocs?? FOUND THE PROBLEM
In-Reply-To: 
References: <532EB5E3-8DA1-41E5-9814-4F3D5F420665@rodanotech.ch>
	<20080513085721.GA16248@erix.ericsson.se>
	<21BB9916-5ABA-42C3-B5A7-30CC70A1D566@rodanotech.ch>
	<06629D7A-6A06-4834-A2DD-D0F1C9E51E8E@rodanotech.ch>
	<95be1d3b0805130313i13c3749dy2214b1f814555cda@mail.gmail.com>
	
	<20080513123826.GA6012@erix.ericsson.se>
	<365E10E3-595D-4795-980B-9A72A4329D50@rodanotech.ch>
	<95be1d3b0805140025o6a44060ax7f88626304d8fbf8@mail.gmail.com>
	
Message-ID: <20080514085055.GB7111@erix.ericsson.se>

On Wed, May 14, 2008 at 09:34:07AM +0200, Alexander Lamb wrote:
> Is it important to dig further? Or can we (for the time being) suggest  
> that on MacOSX NOT to use short names?
> 
> Of course, I can setup a test case, but being new to Erlang, I might  
> not be looking for the right things.
> Tell me if you want me to check some additional info!
> 
> To answer a previous question from Raimo, I traced the objects I use  
> to connect (especially the mailbox) and I can confirm that my test was  
> using only one object. Therefore, we are clearly in a situation where  
> upon setting up the connection the lookup works one way and for  
> following lookups it works in another way.

Ok, that is strange, might be a bug.

It is also strange that short names does not
work at all. It does on other platforms.

But I do not feel a strong urge to investigate it
right now. If long names works on MacOS X we can
leave it at that for a the time being, but eventually
we will have to look into it...


> 
> Alex
> 
> Le 14 mai 08 ? 09:25, Vlad Dumitrescu a ?crit :
> 
> > Hi,
> >
> > On Wed, May 14, 2008 at 9:04 AM, Alexander Lamb  > > wrote:
> > Now, my impression is that this is a special effect of MacOSX (I am
> > running the 10.5.2 on Intel with the latest version of Erlang). It is
> > probable that the way name resolution works locally (the two nodes on
> > my desktop) is different from Linux.
> >
> > This could be the reason. Working with ErlIDE, I got many bug  
> > reports about the connection between Java and Erlang not working on  
> > OSX. I think almost all of them were caused by this mismatch between  
> > how Java and Erlang look up hosts by name. We had to use long names  
> > for the Erlang nodes.
> >
> > This doesn't really answer why it did work the first time. Like  
> > Raimo said, maybe the connection is retried several times. The  
> > connection can be closed for several reasons, for example if data  
> > that can't be decoded is received. Hard to tell without any  
> > additional info.
> >
> > regards,
> > Vlad
> >
> >
> >
> 
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions

-- 

/ Raimo Niskanen, Erlang/OTP, Ericsson AB


From johan556@REDACTED  Wed May 14 11:01:04 2008
From: johan556@REDACTED (Johan Holmberg)
Date: Wed, 14 May 2008 11:01:04 +0200
Subject: [erlang-questions] "open_port" problem on Windows (DETACHED_PROCESS)
Message-ID: <351ce2d70805140201x156b52c4j81839f11c55442a6@mail.gmail.com>

Hi!

I'm trying to use Erlang to run/control an existing application. I use
"open_port" to start the application, and communicate by
reading/writing to the STDIN/STDOUT of the application. I guess this
is quite a typical use of "open_port". I have developed the Erlang
code on Linux, and now when I move it to Windows I get into trouble:

My application starts other processes (compilers, linkers, ...), and
*each invocation* of these creates a new console window. So I get
hundreds of console windows that only exist for a short time.

I think I understand why this happens:

* my application, and the programs it starts are all "console
applications" on Windows

* a console application needs a "console". Either it inherits the one
its parent process uses, or the system will give it a new one.

* in the code for "open_port", Erlang seem to use the flag
"DETACHED_PROCESS" when calling CreateProcess.

* when my application starts other programs, they can't inherit the
console of my application (because of the DETACHED_PROCESS flag used
to start my application)

I have tried to create a minimal example to demonstrate my problem:

    P = open_port({spawn, "env sleep 20"}, [{line, 200}, exit_status]),

Even such a simple call creates a new console (for "sleep 20"). If I
remove the "env" no new console is created.

I guess that the flag DETACHED_PROCESS is used to isolate the process
created by "open_port" from the Erlang Windows-process. But is this
really needed? I think that Erlang would work better together with
console applications if the setting was simply removed.

I would appreciate any hints about what to do to avoid all the extra
consoles. Maybe I have missed some way of affecting how "open_port"
works?

(Currently I'm considering trying to build Erlang myself, and change
the CreateProcess call to not use DETACHED_PROCESS).

/Johan Holmberg


From klacke@REDACTED  Wed May 14 11:09:42 2008
From: klacke@REDACTED (Claes Wikstrom)
Date: Wed, 14 May 2008 11:09:42 +0200
Subject: [erlang-questions] bfile
Message-ID: <482AAC56.8030307@hyber.org>


Heads up for users out there that use the bfile package.
I've received two sets of patches fixing minor bugs in
bfile. New tarball found at

http://yaws.hyber.org/download/bfile-1.2.tgz

/klacke


From raimo+erlang-questions@REDACTED  Wed May 14 11:41:31 2008
From: raimo+erlang-questions@REDACTED (Raimo Niskanen)
Date: Wed, 14 May 2008 11:41:31 +0200
Subject: [erlang-questions] :  :  : : First send from JInterface ok,
	second one blocs?? FOUND THE PROBLEM
In-Reply-To: <20080514085055.GB7111@erix.ericsson.se>
References: <20080513085721.GA16248@erix.ericsson.se>
	<21BB9916-5ABA-42C3-B5A7-30CC70A1D566@rodanotech.ch>
	<06629D7A-6A06-4834-A2DD-D0F1C9E51E8E@rodanotech.ch>
	<95be1d3b0805130313i13c3749dy2214b1f814555cda@mail.gmail.com>
	
	<20080513123826.GA6012@erix.ericsson.se>
	<365E10E3-595D-4795-980B-9A72A4329D50@rodanotech.ch>
	<95be1d3b0805140025o6a44060ax7f88626304d8fbf8@mail.gmail.com>
	
	<20080514085055.GB7111@erix.ericsson.se>
Message-ID: <20080514094131.GA30969@erix.ericsson.se>

On Wed, May 14, 2008 at 10:50:55AM +0200, Raimo Niskanen wrote:
> On Wed, May 14, 2008 at 09:34:07AM +0200, Alexander Lamb wrote:
> > Is it important to dig further? Or can we (for the time being) suggest  
> > that on MacOSX NOT to use short names?
> > 

Sorry, I just had to test one final thing,
and I think I have reproduced your problem...

I tested on MacOS X Leopard uname -a:
Darwin foo 9.2.2 Darwin Kernel Version 9.2.2: Tue Mar  4 21:17:34 PST 2008; root:xnu-1228.4.31~1/RELEASE_I386 i386
It has a fresh update of Java.

If I start the erlang node with -sname e@REDACTED
and then run my test program as:
foo$ java -DOtpConnection.trace=4 jrpc j@REDACTED `cat ~/.erlang.cookie` e@REDACTED hello
it behaves as you describe. And what is interesting is,
now from your trace, same in mine:
-> LOOKUP (r4) alex@REDACTED
:
<- HANDSHAKE recvChallenge from=alex@REDACTED challenge=1257096912
: first send, now second...
-> LOOKUP (r4) alex@REDACTED

So Jinterface looks up alex@REDACTED, finds and contacts
it, and gets replies from alex@REDACTED An Erlang node
would have detected the difference in hostnames
and refused the connection, but Jinterface registers
the connection as being to alex@REDACTED, and when the
next messages is sent to alex@REDACTED, a new
lookup is made since the only existing connection
is to alex@REDACTED, and this time the Erlang node
detects a duplicate connection and closes it.

So there probably is no problem with long hostnames,
you just have to specify the hostname part of the
node name as -sname alex@REDACTED, not -sname alex.
And the MacOS X problem is probably a name resolution
problem for the domain .local.

But there is a bug that Jinterface does not refuse
the connection for mismatching hostname parts of
the node name, and thereby gets a faulty registered
connetion.



> > Of course, I can setup a test case, but being new to Erlang, I might  
> > not be looking for the right things.
> > Tell me if you want me to check some additional info!
> > 
> > To answer a previous question from Raimo, I traced the objects I use  
> > to connect (especially the mailbox) and I can confirm that my test was  
> > using only one object. Therefore, we are clearly in a situation where  
> > upon setting up the connection the lookup works one way and for  
> > following lookups it works in another way.
> 
> Ok, that is strange, might be a bug.
> 
> It is also strange that short names does not
> work at all. It does on other platforms.
> 
> But I do not feel a strong urge to investigate it
> right now. If long names works on MacOS X we can
> leave it at that for a the time being, but eventually
> we will have to look into it...
> 
> 
> > 
> > Alex
> > 
> > Le 14 mai 08 ? 09:25, Vlad Dumitrescu a ?crit :
> > 
> > > Hi,
> > >
> > > On Wed, May 14, 2008 at 9:04 AM, Alexander Lamb  > > > wrote:
> > > Now, my impression is that this is a special effect of MacOSX (I am
> > > running the 10.5.2 on Intel with the latest version of Erlang). It is
> > > probable that the way name resolution works locally (the two nodes on
> > > my desktop) is different from Linux.
> > >
> > > This could be the reason. Working with ErlIDE, I got many bug  
> > > reports about the connection between Java and Erlang not working on  
> > > OSX. I think almost all of them were caused by this mismatch between  
> > > how Java and Erlang look up hosts by name. We had to use long names  
> > > for the Erlang nodes.
> > >
> > > This doesn't really answer why it did work the first time. Like  
> > > Raimo said, maybe the connection is retried several times. The  
> > > connection can be closed for several reasons, for example if data  
> > > that can't be decoded is received. Hard to tell without any  
> > > additional info.
> > >
> > > regards,
> > > Vlad
> > >
> > >
> > >
> > 
> > _______________________________________________
> > erlang-questions mailing list
> > erlang-questions@REDACTED
> > http://www.erlang.org/mailman/listinfo/erlang-questions
> 
> -- 
> 
> / Raimo Niskanen, Erlang/OTP, Ericsson AB
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions

-- 

/ Raimo Niskanen, Erlang/OTP, Ericsson AB


From adam@REDACTED  Wed May 14 13:33:33 2008
From: adam@REDACTED (Adam Lindberg)
Date: Wed, 14 May 2008 13:33:33 +0200
Subject: [erlang-questions] Erlang Mode Mavens: customizations?
In-Reply-To: 
References: <944da41d0805120529kcdc0824t44cf75b270349106@mail.gmail.com>
	<4828C2B4.2020907@cronqvi.st>
	<14f0e3620805122336l64dc462n8e861d0277f33e5c@mail.gmail.com>
	<944da41d0805130141ub40d928scd90df9e7a256a0d@mail.gmail.com>
	<1054344800.20080513235508@gmail.com>
	
Message-ID: <6344005f0805140433t8920c2cr541ed6f21a6718f6@mail.gmail.com>

On Wed, May 14, 2008 at 9:56 AM, Jachym Holecek 
wrote:

> + tabbar mode.
>

+ erlware-mode (http://code.google.com/p/erlware-mode/)

My personal favourites are (add to your init.el/custom.el etc):

(defun duplicate-one-line ()
  "Duplicate the current line. There is a little bug: when current line is
the last line of the buffer, this will not work as expected. Anyway, that's
ok for me."
  (interactive)
  (let ((start (progn (beginning-of-line) (point)))
    (end (progn (next-line 1) (beginning-of-line) (point))))
    (insert-buffer-substring (current-buffer) start end)
    (forward-line -1)))
(global-set-key (kbd "C-=") 'duplicate-one-line)

(defun move-one-line-downward ()
  "Move current line downward once."
  (interactive)
  (forward-line)
  (transpose-lines 1)
  (forward-line -1))
(global-set-key (kbd "C-down") 'move-one-line-downward)

(defun move-one-line-upward ()
  "Move current line upward once."
  (interactive)
  (transpose-lines 1)
  (forward-line -2))
(global-set-key (kbd "C-up") 'move-one-line-upward)

(defvar previous-column nil "Save the column position")
(defun nuke-line ()
  "Kill current line and restore column position."
  (interactive)
  (setq previous-column (current-column))
  (kill-entire-line 1)
  (move-to-column previous-column))
(global-set-key [(shift delete)] 'nuke-line)

This makes Ctrl+= duplicate the current line, very handy! Ctrl+Up switches
the current and the line above and Ctrl+Down switches the current and the
line below enabling you to move a line up and down in the buffer. Also
handy! Lastly Shift+Delete is bound to kill the whole line and saving the
column position.

Taken from: http://exceedhl.wordpress.com/2006/07/13/tweak-emacs/

This one makes Shift+Backspace delete all whitespace around the cursor:
(global-set-key (kbd "S-BS") 'delete-horizontal-space)

The perfect challenge for a cunning elisp-developer would be to enhance the
move one line upward and downward functions to take care of Erlang's line
ending characters, i.e. so that commas, semicolons and periods aren't moved
together with the line.

Cheers!
Adam
--
Adam Lindberg
http://www.erlang-consulting.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From rvirding@REDACTED  Wed May 14 13:57:21 2008
From: rvirding@REDACTED (Robert Virding)
Date: Wed, 14 May 2008 13:57:21 +0200
Subject: [erlang-questions] Erlang Mode Mavens: customizations?
In-Reply-To: <6344005f0805140433t8920c2cr541ed6f21a6718f6@mail.gmail.com>
References: <944da41d0805120529kcdc0824t44cf75b270349106@mail.gmail.com>
	<4828C2B4.2020907@cronqvi.st>
	<14f0e3620805122336l64dc462n8e861d0277f33e5c@mail.gmail.com>
	<944da41d0805130141ub40d928scd90df9e7a256a0d@mail.gmail.com>
	<1054344800.20080513235508@gmail.com>
	
	<6344005f0805140433t8920c2cr541ed6f21a6718f6@mail.gmail.com>
Message-ID: <3dbc6d1c0805140457r4535c881k5fc365a30ebcf999@mail.gmail.com>

2008/5/14 Adam Lindberg :

> On Wed, May 14, 2008 at 9:56 AM, Jachym Holecek <
> jachym.holecek@REDACTED> wrote:
>
> > + tabbar mode.
> >
>
> ...
>
> This one makes Shift+Backspace delete all whitespace around the cursor:
> (global-set-key (kbd "S-BS") 'delete-horizontal-space)


Already got that on M-\, and I am so used to C-x C-t transpose-lines that my
fingers couldn't manage something new for that. :-)

Robert
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From adam@REDACTED  Wed May 14 14:02:33 2008
From: adam@REDACTED (Adam Lindberg)
Date: Wed, 14 May 2008 14:02:33 +0200
Subject: [erlang-questions] Erlang Mode Mavens: customizations?
In-Reply-To: <3dbc6d1c0805140457r4535c881k5fc365a30ebcf999@mail.gmail.com>
References: <944da41d0805120529kcdc0824t44cf75b270349106@mail.gmail.com>
	<4828C2B4.2020907@cronqvi.st>
	<14f0e3620805122336l64dc462n8e861d0277f33e5c@mail.gmail.com>
	<944da41d0805130141ub40d928scd90df9e7a256a0d@mail.gmail.com>
	<1054344800.20080513235508@gmail.com>
	
	<6344005f0805140433t8920c2cr541ed6f21a6718f6@mail.gmail.com>
	<3dbc6d1c0805140457r4535c881k5fc365a30ebcf999@mail.gmail.com>
Message-ID: <6344005f0805140502x7142575cw25fda24b7039e1f3@mail.gmail.com>

On Wed, May 14, 2008 at 1:57 PM, Robert Virding  wrote:

> Already got that on M-\, and I am so used to C-x C-t transpose-lines that
> my fingers couldn't manage something new for that. :-)
>

Yeah, the only problem is that on my keyboard, \ is bound to AltGr+'+', so
it's kind of awkward to press Alt+AltGr+'+' the whole time. :-)

And C-x C-t only moves upwards. :-)

Cheers!
Adam
--
Adam Lindberg
http://www.erlang-consulting.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From bengt.kleberg@REDACTED  Wed May 14 14:38:43 2008
From: bengt.kleberg@REDACTED (Bengt Kleberg)
Date: Wed, 14 May 2008 14:38:43 +0200
Subject: [erlang-questions] size of an open file
In-Reply-To: <482A9FBD.8010401@ghostgun.com>
References: <482A453E.9010807@ghostgun.com>
	<1210751058.1111.9.camel@seasc0642.dyn.rnd.as.sw.ericsson.se>
	<482A9FBD.8010401@ghostgun.com>
Message-ID: <1210768723.1111.18.camel@seasc0642.dyn.rnd.as.sw.ericsson.se>

Greetings,

What are your requirements?
Do you have enough time/cpu/etc to open/close the file when reading the
tail part of it?


bengt

On Wed, 2008-05-14 at 18:15 +1000, jm wrote:
> 
> Bengt Kleberg wrote:
> > Greetings,
> >
> > You have 2 possibilities according to the manual of the file module:
> > 1) file:position/2 should return the file size, if called with 'eof' as
> > Position
> > 2) if this is for debugging you can use file:pid2name/1 and get the file
> > name (for subsequent use in file:read_file_info/1).
> >
> >   
> 
> Thanks. Last question I hope. In attempting to tail a log file:  How do 
> you detect that the file has rolled over, ie a new log file has been 
> created?
> Is there a smarter way than comparing the size of the open file and the 
> size of the file by name? I can see a couple of problems with this method.
> To begin with if the new log file grows larger than the old log file 
> before there is a chance to switch files. I suppose you could do
> 
>  SizeOfOpen =:= SizeofNamedFile
> 
> but this doesn't seem right. Really, a comparison should be done on the 
> filenames, ie compare the name of the currently open file with that of 
> the requested filename to detect a roll over, but I don't see a 
> file:read_file_info/1 for open files.
> 
> Jeff.
> 
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions



From per@REDACTED  Wed May 14 15:02:51 2008
From: per@REDACTED (Per Hedeland)
Date: Wed, 14 May 2008 15:02:51 +0200 (CEST)
Subject: [erlang-questions] size of an open file
In-Reply-To: <482A9FBD.8010401@ghostgun.com>
Message-ID: <200805141302.m4ED2pce008864@pluto.hedeland.org>

jm  wrote:
>
>Thanks. Last question I hope. In attempting to tail a log file:  How do 
>you detect that the file has rolled over, ie a new log file has been 
>created?
>Is there a smarter way than comparing the size of the open file and the 
>size of the file by name? I can see a couple of problems with this method.
>To begin with if the new log file grows larger than the old log file 
>before there is a chance to switch files. I suppose you could do
>
> SizeOfOpen =:= SizeofNamedFile
>
>but this doesn't seem right. Really, a comparison should be done on the 
>filenames, ie compare the name of the currently open file with that of 
>the requested filename to detect a roll over, but I don't see a 
>file:read_file_info/1 for open files.

It's not in general possible to find the name for an open file on *nix,
even outside Erlang - e.g. an open file may not have a name, or it can
have multiple names. What you want to check on *nix is the inode number
(and major/minor device number if you're really paranod, since inode
numbers are per-device). This is provided by file:read_file_info/1 -
again not for open files, but if you are opening the files, you can of
course call it before you open... Windows is another story of course.

--Per


From bekesa@REDACTED  Wed May 14 16:20:19 2008
From: bekesa@REDACTED (Andras Georgy Bekes)
Date: Wed, 14 May 2008 16:20:19 +0200
Subject: [erlang-questions] eep: multiple patterns
Message-ID: <200805141620.19559.bekesa@sch.bme.hu>

Hi,

After we've discussed the topic (mainly in the "erlang *****" thread), 
I've made the eep-document. I send it to the list for further 
discussion.

I haven't received any comments on the proposed pattern-match-test 
construct, which is sad as I am not satisfied with what I'm about to 
recommend.

There are 3 possibilities:

1, Only _ (underbar) names are allowed.
+ sounds logical, because no variables will be bound anyways.
- Patterns with syntactic restrictions is a new concept in Erlang

2, Only _ and names beginning with _ are allowed.
+ giving meaningful names instead of _-s is a documentation of the code
+ multiple occurences of the same variable in a pattern are meaningful 
and useful
- Later use of a variables that occured in a pattern-match-test
is confusing, because they are totally independent
- Patterns with syntactic restrictions is a new concept in Erlang

3, No restrictions.
- Variables not beginning with _ are bad, because
  * not using it later results in compiler warning
  * using it later is confusing (see above)

I don't really like any of the above, but I still think that a 
pattern-match-test operator is very useful, so I'm eager to listen to 
every constructive opinion.

	Georgy
-------------- next part --------------
EEP: XX
Title: Multiple patterns
Version: XX
Last-Modified: XX
Author: Andr??s Georgy B??k??s 
Status: Draft
Type: Standards Track
Erlang-Version: R12B-?
Content-Type: text/plain
Created: 05-May-2008
Post-History: 14-May-2008


Abstract

    This EEP describes the syntax and semantics of multiple patterns
    for function clauses and case, receive, try-catch expressions.
    It also describes the pattern-match-test expression.


Rationale

    It is rather common to check the value of an expression with a
    case expression and do the same actions in some of the cases.
    Example:

        case Expression of
             Pattern1 ->
                      %% think lots of code here
             Pattern2 ->
                      %% think the same piece of code as above here
             Pattern3 ->
                      %% something else here
        end       

    In order to avoid duplicated code, the programmer might extract
    the duplicated body into a separate function, or might separate the
    classification of results from the execution of actions.
    Example:

        Type = case Expression of
                    Pattern1 -> {type1,Values...};
                    Pattern2 -> {type1,Values...};
                    Pattern3 -> {type2,Values...}
                 end,
        case Type of
             {type1,Patterns...} ->
                      %% think lots of code here
             {type2,Patterns...} ->
                      %% something else here
        end

   Both the solutions are lengthy.  According to a discussion on the
   mailing list erlang-questions [1], [2], the ultimate solution would
   be to introduce union- and negated patterns, but that would have
   unacceptable consequences (in performance).

   The proposed multiple-patterns together with pattern-match-test
   solves all the (practical) problems the union- and negated patterns
   could be used for.


Syntax

    In function heads:

        functionname(Pattern1) when GuardSequence1 |
        functionname(Pattern2) when GuardSequence2 ->
            %% function body to be executed in both cases
        functionname(Pattern3) when GuardSequence3 ->
        %% other function clauses

    In case expressions:

        case Expression of
             Pattern1 when GuardSequence1 |
             Pattern2 when GuardSequence2 ->
                      %% think the same piece of code as above here
             Pattern3 ->
                      %% something else here
        end       

    receive and try-catch expressions are analogous to the case
    expression.


Semantics:

    A function head or case, receive, try-catch expression with
    multiple patterns means that the body is selected whenever at
    least one of the patterns match.  The order in which the patterns
    are checked is obviously irrelevant.  Variables not bound in each
    of the cases should be considered unsafe, i.e. cannot be used in
    the body or after the case, receive or try-catch expression.

    Note that this behaviour could be easily implemented with a parse
    transformation: the body could be simply copied for each of the
    patterns.  However, the syntax would be very ugly, because it
    would have to use syntax that the current parser accepts.


Pattern-match-test Operator

    The pattern-match test operator is an operator-like construct.
    It is not an operator because one of its arguments is not an
    expression but a pattern. The operator tests whether its expression
    argument matches its pattern argument, and returns true or false.


Syntax

    PATTERN ~= Expression


Semantics

    The operator first evaluates Expression, then tests if it matches
    PATTERN.  The result is true/false.  No variables are bound. The
    operator should be allowed in guards.

    Note that this behaviour could be easily implemented with a parse
    transformation, by replacing each pattern-match-test with:

        case Expression of
            PATTERN ->
                true;
            _ ->
                false
        end

    but this can not be used in guards, and the most important use
    of the operator would be to extend pattern matching with negated
    patterns as in the following example pattern:

        PATTERN1 when not (PATTERN2 ~= Variable_bound_by_PATTERN1)


Compatibility

   Currently there is neither | nor ~= operator in Erlang, therefore
   legacy code works as before.


References


   [1] Discussion on union- and negated patterns
        http://www.erlang.org/pipermail/erlang-questions/2008-March/033718.html
   [2] Discussion on union- and negated patterns
        http://www.erlang.org/pipermail/erlang-questions/2008-March/033755.html


Copyright

    This document has been placed in the public domain.


Local Variables:
mode: indented-text
indent-tabs-mode: nil
sentence-end-double-space: t
fill-column: 70
coding: utf-8
End:

From Martin.Logan@REDACTED  Wed May 14 18:20:23 2008
From: Martin.Logan@REDACTED (Logan, Martin)
Date: Wed, 14 May 2008 11:20:23 -0500
Subject: [erlang-questions] Erlang Mode Mavens: customizations?
In-Reply-To: <944da41d0805120529kcdc0824t44cf75b270349106@mail.gmail.com>
References: <944da41d0805120529kcdc0824t44cf75b270349106@mail.gmail.com>
Message-ID: <1B67010539493A48B777F49CE49F574B04EC44@chiresexc04.resource.corp.lcl>

As an FYI there is an improved Erlang mode that features fixes to
electric new line problems, contains all edoc's skeletons with
consistent formatting, fixes indentation issues, and quite a host of
other things.  Here is the link to it:
http://code.google.com/p/erlware-mode/

 

Cheers,

Martin

 

________________________________

From: erlang-questions-bounces@REDACTED
[mailto:erlang-questions-bounces@REDACTED] On Behalf Of Alex Arnon
Sent: Monday, May 12, 2008 7:30 AM
To: Erlang Questions
Subject: [erlang-questions] Erlang Mode Mavens: customizations?

 

Hi All,

I'd like to ask you Emacs Proficienados:
1. Which keybindings do you add to Erlang Mode? For example, do you bind
erlang-find-tag, erlang-indent-clause etc.?
2. Are there any other customizations you add on top of Erlang Mode?

Cheers,
Alex.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From vsarpe@REDACTED  Wed May 14 18:40:02 2008
From: vsarpe@REDACTED (Vlad12)
Date: Wed, 14 May 2008 09:40:02 -0700 (PDT)
Subject: [erlang-questions] Tracing ejabberd
In-Reply-To: <17216480.post@talk.nabble.com>
References: <17216480.post@talk.nabble.com>
Message-ID: <17235507.post@talk.nabble.com>


How can i find the ejabberd cookie?
-- 
View this message in context: http://www.nabble.com/Tracing-ejabberd-tp17216480p17235507.html
Sent from the Erlang Questions mailing list archive at Nabble.com.



From vsarpe@REDACTED  Wed May 14 19:17:02 2008
From: vsarpe@REDACTED (Vlad12)
Date: Wed, 14 May 2008 10:17:02 -0700 (PDT)
Subject: [erlang-questions] Tracing ejabberd
In-Reply-To: <482A8FD3.2040000@erlang-consulting.com>
References: <17216480.post@talk.nabble.com>
	<4ac8254d0805131352sfc63f9ah4e9a1a38f69f9526@mail.gmail.com>
	<482A8FD3.2040000@erlang-consulting.com>
Message-ID: <17236414.post@talk.nabble.com>


 When i do the commands like you said, I get the following error: 

(dbg@REDACTED)3> net_adm:ping(ejabberd@REDACTED).
pong
(dbg@REDACTED)5> nodes().                         
[ejabberd@REDACTED]
(dbg@REDACTED)6> dbg:tracer().
{ok,<0.51.0>}
(dbg@REDACTED)8> lists:foreach(fun(Node) -> dbg:n(Node) end, nodes()).

=ERROR REPORT==== 14-May-2008::11:14:14 ===
Error in process <0.399.0> on node 'ejabberd@REDACTED' with exit value:
{undef,[{#Fun,[]}]}

 It somehow seems that it does not support any dbg functions on the node
itself even if i start them from another node. Is there a way I can modify
some ejabberd scripts to include the dbg library when starting the ejabberd
node? 



Francesco Cesarini (Erlang Consulting) wrote:
> 
> You are probably running Erlang in embedded mode, which loads all the 
> modules at startup. I assume that the runtime tools application is not 
> part of the build. That is where dbg is.
> 
> Also, because of the strange setup with ejabberd, you probably need to 
> play around before you are able to get any trace messages.
> to run dbg on an ejabbed node and bypass the group leader io problem, 
> you have to
> 
> * Start a distributed Erlang Node
> * Connect to the Ejabberd Cluster
> * Start the tracer
> * Connect the ejabberd nodes to the tracer
> * Pick which processes and functions to trace
> 
> In pseudo code, you would do something like this:
> 
> erl -sname dbg -setcookie COOKIE   (Where COOKIE is the same cookie as 
> the ejabberd node)
> 
> 1> net_adm:ping(EJABBERDNODENAME). (Where EJABBERDNODENAME is the 
> distributed Erlang node name running on EjabberD).
> 2> dbg:tracer().
> 3> lists:foreach(fun(Node) -> dbg:n(Node) end, nodes()).
> 
> You can now use all of the trace commands and get the ourput redirected 
> to your shell. They include dbg:p/2 to pick which processes to trace and 
> dbg:tp for global calls and dbg:tpl for local ones.
> 
> hope this helps,
> Francesco
> --
> http://www.erlang-consulting.com
> 
> Tuncer Ayaz wrote:
>> On Tue, May 13, 2008 at 9:28 PM, Vlad12  wrote:
>>   
>>>  Hello,
>>>
>>>  Can anyone tell me why every time i run ejabberd on "live" mode (opens
>>> an
>>>  erlang shell at the node  ejabberd@REDACTED) it does not allow me to
>>> run
>>>  dbg or fprof functions?
>>>
>>>  shell$ ./ejabberdct live
>>>
>>>  This is what i get if i try to run dbg:tracer(). :
>>>
>>>  (ejabberd@REDACTED)4> dbg:tracer().
>>>  ** exited: {undef,[{dbg,tracer,[]},
>>>                    {erl_eval,do_apply,5},
>>>                    {shell,exprs,6},
>>>                    {shell,eval_loop,3}]} **
>>>     
>>
>> If I may trust my slowly building Erlang skills this
>> error means that the system is unable to locate either
>> the module 'dbg' or the method 'dbg:tracer'.
>>
>> A wild guess is that ejabberd's runtime config does not
>> include too many additional libs/modules.
>>
>> The solution to your problem is something which I hope
>> to know soon after having digged deeper into ejabberd.
>> I know this doesn't solve your issue but may help
>> clear the situation.
>>
>>   
>>>  =ERROR REPORT==== 13-May-2008::13:21:29 ===
>>>  Error in process <0.334.0> on node 'ejabberd@REDACTED' with exit
>>> value:
>>> 
>>> {undef,[{dbg,tracer,[]},{erl_eval,do_apply,5},{shell,exprs,6},{shell,eval_loop,3}]}
>>>
>>>
>>>  The error message is similar if i run fprof:trace(start). :
>>>
>>>  (ejabberd@REDACTED)9> fprof:trace(start).
>>>  {'EXIT',<0.354.0>,
>>>         {undef,[{dbg,trace_port,[file,"fprof.trace"]},
>>>                 {fprof,open_dbg_trace_port,2},
>>>                 {fprof,handle_req,3},
>>>                 {fprof,server_loop,1}]}}
>>>
>>>  =ERROR REPORT==== 13-May-2008::13:25:53 ===
>>>  Error in process <0.354.0> on node 'ejabberd@REDACTED' with exit
>>> value:
>>> 
>>> {undef,[{dbg,trace_port,[file,"fprof.trace"]},{fprof,open_dbg_trace_port,2},{fprof,handle_req,3},{fprof,server_loop,1}]}
>>>
>>>   Help is greatly appreciated
>>>     
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://www.erlang.org/mailman/listinfo/erlang-questions
>>
>>   
> 
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
> 
> 

-- 
View this message in context: http://www.nabble.com/Tracing-ejabberd-tp17216480p17236414.html
Sent from the Erlang Questions mailing list archive at Nabble.com.



From dougedmunds@REDACTED  Wed May 14 19:20:39 2008
From: dougedmunds@REDACTED (DougEdmunds)
Date: Wed, 14 May 2008 10:20:39 -0700
Subject: [erlang-questions] Registered names and pids
In-Reply-To: 
References: <482A55AD.3090900@camosun.bc.ca>
	
Message-ID: <482B1F67.7060103@gmail.com>

Having wasted a lot of time on this question a couple of days
before the post, I vote whereis/1 as the most non-intuitively
named standard function.

Better would be waldo/1 (at least that's a name).  :)

-dae


Anders Nygren wrote:
> On Tue, May 13, 2008 at 9:59 PM, Deryk Barker  wrote:
>> Maybe I shouldn't need to know this, but I can't find any obvious way:
>>  is it possible, given the name of a registered process, to find its pid:
>>  a) on the same nod b) on another node?
>>
>>  Merci.
> 
> Locally registered name
> whereis(Name)
> 
> Globally registered name
> global:whereis_name(Name)
> 


From vsarpe@REDACTED  Wed May 14 20:01:14 2008
From: vsarpe@REDACTED (Vlad12)
Date: Wed, 14 May 2008 11:01:14 -0700 (PDT)
Subject: [erlang-questions] Tracing ejabberd
In-Reply-To: <17236414.post@talk.nabble.com>
References: <17216480.post@talk.nabble.com>
	<4ac8254d0805131352sfc63f9ah4e9a1a38f69f9526@mail.gmail.com>
	<482A8FD3.2040000@erlang-consulting.com>
	<17236414.post@talk.nabble.com>
Message-ID: <17237372.post@talk.nabble.com>


 Update: problem solved. You guys were right, the binary installation of
ejabberd lacks many debugging modules for the erlang shell. 

I installed the source code package and dbg works just fine inside the
ejabberdctl erlang shell. I was able to obtain a trace.

Thank all of you for the help 





Vlad12 wrote:
> 
>  When i do the commands like you said, I get the following error: 
> 
> (dbg@REDACTED)3> net_adm:ping(ejabberd@REDACTED).
> pong
> (dbg@REDACTED)5> nodes().                         
> [ejabberd@REDACTED]
> (dbg@REDACTED)6> dbg:tracer().
> {ok,<0.51.0>}
> (dbg@REDACTED)8> lists:foreach(fun(Node) -> dbg:n(Node) end, nodes()).
> 
> =ERROR REPORT==== 14-May-2008::11:14:14 ===
> Error in process <0.399.0> on node 'ejabberd@REDACTED' with exit value:
> {undef,[{#Fun,[]}]}
> 
>  It somehow seems that it does not support any dbg functions on the node
> itself even if i start them from another node. Is there a way I can modify
> some ejabberd scripts to include the dbg library when starting the
> ejabberd node? 
> 
> 
> 
> Francesco Cesarini (Erlang Consulting) wrote:
>> 
>> You are probably running Erlang in embedded mode, which loads all the 
>> modules at startup. I assume that the runtime tools application is not 
>> part of the build. That is where dbg is.
>> 
>> Also, because of the strange setup with ejabberd, you probably need to 
>> play around before you are able to get any trace messages.
>> to run dbg on an ejabbed node and bypass the group leader io problem, 
>> you have to
>> 
>> * Start a distributed Erlang Node
>> * Connect to the Ejabberd Cluster
>> * Start the tracer
>> * Connect the ejabberd nodes to the tracer
>> * Pick which processes and functions to trace
>> 
>> In pseudo code, you would do something like this:
>> 
>> erl -sname dbg -setcookie COOKIE   (Where COOKIE is the same cookie as 
>> the ejabberd node)
>> 
>> 1> net_adm:ping(EJABBERDNODENAME). (Where EJABBERDNODENAME is the 
>> distributed Erlang node name running on EjabberD).
>> 2> dbg:tracer().
>> 3> lists:foreach(fun(Node) -> dbg:n(Node) end, nodes()).
>> 
>> You can now use all of the trace commands and get the ourput redirected 
>> to your shell. They include dbg:p/2 to pick which processes to trace and 
>> dbg:tp for global calls and dbg:tpl for local ones.
>> 
>> hope this helps,
>> Francesco
>> --
>> http://www.erlang-consulting.com
>> 
>> Tuncer Ayaz wrote:
>>> On Tue, May 13, 2008 at 9:28 PM, Vlad12  wrote:
>>>   
>>>>  Hello,
>>>>
>>>>  Can anyone tell me why every time i run ejabberd on "live" mode (opens
>>>> an
>>>>  erlang shell at the node  ejabberd@REDACTED) it does not allow me to
>>>> run
>>>>  dbg or fprof functions?
>>>>
>>>>  shell$ ./ejabberdct live
>>>>
>>>>  This is what i get if i try to run dbg:tracer(). :
>>>>
>>>>  (ejabberd@REDACTED)4> dbg:tracer().
>>>>  ** exited: {undef,[{dbg,tracer,[]},
>>>>                    {erl_eval,do_apply,5},
>>>>                    {shell,exprs,6},
>>>>                    {shell,eval_loop,3}]} **
>>>>     
>>>
>>> If I may trust my slowly building Erlang skills this
>>> error means that the system is unable to locate either
>>> the module 'dbg' or the method 'dbg:tracer'.
>>>
>>> A wild guess is that ejabberd's runtime config does not
>>> include too many additional libs/modules.
>>>
>>> The solution to your problem is something which I hope
>>> to know soon after having digged deeper into ejabberd.
>>> I know this doesn't solve your issue but may help
>>> clear the situation.
>>>
>>>   
>>>>  =ERROR REPORT==== 13-May-2008::13:21:29 ===
>>>>  Error in process <0.334.0> on node 'ejabberd@REDACTED' with exit
>>>> value:
>>>> 
>>>> {undef,[{dbg,tracer,[]},{erl_eval,do_apply,5},{shell,exprs,6},{shell,eval_loop,3}]}
>>>>
>>>>
>>>>  The error message is similar if i run fprof:trace(start). :
>>>>
>>>>  (ejabberd@REDACTED)9> fprof:trace(start).
>>>>  {'EXIT',<0.354.0>,
>>>>         {undef,[{dbg,trace_port,[file,"fprof.trace"]},
>>>>                 {fprof,open_dbg_trace_port,2},
>>>>                 {fprof,handle_req,3},
>>>>                 {fprof,server_loop,1}]}}
>>>>
>>>>  =ERROR REPORT==== 13-May-2008::13:25:53 ===
>>>>  Error in process <0.354.0> on node 'ejabberd@REDACTED' with exit
>>>> value:
>>>> 
>>>> {undef,[{dbg,trace_port,[file,"fprof.trace"]},{fprof,open_dbg_trace_port,2},{fprof,handle_req,3},{fprof,server_loop,1}]}
>>>>
>>>>   Help is greatly appreciated
>>>>     
>>> _______________________________________________
>>> erlang-questions mailing list
>>> erlang-questions@REDACTED
>>> http://www.erlang.org/mailman/listinfo/erlang-questions
>>>
>>>   
>> 
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://www.erlang.org/mailman/listinfo/erlang-questions
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Tracing-ejabberd-tp17216480p17237372.html
Sent from the Erlang Questions mailing list archive at Nabble.com.



From vsarpe@REDACTED  Wed May 14 20:01:34 2008
From: vsarpe@REDACTED (Vlad12)
Date: Wed, 14 May 2008 11:01:34 -0700 (PDT)
Subject: [erlang-questions] Tracing ejabberd
Message-ID: <17237372.post@talk.nabble.com>


 Update: problem solved. You guys were right, the binary installation of
ejabberd lacks many debugging modules for the erlang shell. 

I installed the source code package and dbg works just fine inside the
ejabberdctl erlang shell. I was able to obtain a trace.

Thank all of you for the help 





-- 
View this message in context: http://www.nabble.com/Tracing-ejabberd-tp17216480p17237372.html
Sent from the Erlang Questions mailing list archive at Nabble.com.



From rvirding@REDACTED  Wed May 14 21:22:12 2008
From: rvirding@REDACTED (Robert Virding)
Date: Wed, 14 May 2008 21:22:12 +0200
Subject: [erlang-questions] Registered names and pids
In-Reply-To: <482B1F67.7060103@gmail.com>
References: <482A55AD.3090900@camosun.bc.ca>
	
	<482B1F67.7060103@gmail.com>
Message-ID: <3dbc6d1c0805141222w67cd31bt4b3d268da7603bfc@mail.gmail.com>

What whereis/1 asks where is the pid. :-)

2008/5/14 DougEdmunds :

> Having wasted a lot of time on this question a couple of days
> before the post, I vote whereis/1 as the most non-intuitively
> named standard function.
>
> Better would be waldo/1 (at least that's a name).  :)
>
> -dae
>
>
> Anders Nygren wrote:
> > On Tue, May 13, 2008 at 9:59 PM, Deryk Barker 
> wrote:
> >> Maybe I shouldn't need to know this, but I can't find any obvious way:
> >>  is it possible, given the name of a registered process, to find its
> pid:
> >>  a) on the same nod b) on another node?
> >>
> >>  Merci.
> >
> > Locally registered name
> > whereis(Name)
> >
> > Globally registered name
> > global:whereis_name(Name)
> >
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From daveb@REDACTED  Wed May 14 21:44:09 2008
From: daveb@REDACTED (Dave Bryson)
Date: Wed, 14 May 2008 14:44:09 -0500
Subject: [erlang-questions] Best approach to stop distributed erlang apps
Message-ID: 

I have an application distributed across X number of machines in a  
cluster.  I'm currently launching the apps in a -detached mode. To  
launch the apps, I'm using a shell script that loops through the nodes  
and runs a start script via SSH.  I'd like to be able to do the same  
thing to stop the apps ( completely stop the erlang runtime  
init:stop() ).  However, I  haven't been able to figure out the best  
approach to do that.  The only thing I've been successful with is to - 
remsh into each application and call "init:stop()".

Does anyone have a "best practice" approach to automate calling  
init:stop() across a cluster?

Thanks!
Dave


From igorrs@REDACTED  Wed May 14 22:21:36 2008
From: igorrs@REDACTED (Igor Ribeiro Sucupira)
Date: Wed, 14 May 2008 17:21:36 -0300
Subject: [erlang-questions] Registered names and pids
In-Reply-To: <482B1F67.7060103@gmail.com>
References: <482A55AD.3090900@camosun.bc.ca>
	
	<482B1F67.7060103@gmail.com>
Message-ID: 

On Wed, May 14, 2008 at 2:20 PM, DougEdmunds  wrote:
>
> Having wasted a lot of time on this question a couple of days
> before the post, I vote whereis/1 as the most non-intuitively
> named standard function.

My thoughts were the same after I saw that function (when learning
Erlang from Joe Armstrong's book).  :-)
But I'm lucky for having learnt it before I needed to use it.  :-)

Igor.

> Better would be waldo/1 (at least that's a name).  :)
>
> -dae
>
>
> Anders Nygren wrote:
>> On Tue, May 13, 2008 at 9:59 PM, Deryk Barker  wrote:
>>> Maybe I shouldn't need to know this, but I can't find any obvious way:
>>>  is it possible, given the name of a registered process, to find its pid:
>>>  a) on the same nod b) on another node?
>>>
>>>  Merci.
>>
>> Locally registered name
>> whereis(Name)
>>
>> Globally registered name
>> global:whereis_name(Name)
>>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>


From rpettit@REDACTED  Wed May 14 22:34:09 2008
From: rpettit@REDACTED (Rick Pettit)
Date: Wed, 14 May 2008 16:34:09 -0400 (EDT)
Subject: [erlang-questions] Best approach to stop distributed erlang apps
In-Reply-To: 
References: 
Message-ID: <53528.192.168.34.15.1210797249.squirrel@squirrelmail.vail>

On Wed, May 14, 2008 2:44 pm, Dave Bryson wrote:
> I have an application distributed across X number of machines in a
> cluster.  I'm currently launching the apps in a -detached mode. To
> launch the apps, I'm using a shell script that loops through the nodes
> and runs a start script via SSH.  I'd like to be able to do the same
> thing to stop the apps ( completely stop the erlang runtime
> init:stop() ).  However, I  haven't been able to figure out the best
> approach to do that.  The only thing I've been successful with is to -
> remsh into each application and call "init:stop()".
>
> Does anyone have a "best practice" approach to automate calling
> init:stop() across a cluster?

If order doesn't matter and a clean shutdown which flushes all I/O isn't
required you should be able to do something like:

  StopNode=fun(N) -> rpc:call(N,init,stop,[]) end,
  lists:foreach(StopNode, nodes()).

-Rick

P.S. I have not tested the code above :-)



From erlangy@REDACTED  Thu May 15 00:03:15 2008
From: erlangy@REDACTED (Michael McDaniel)
Date: Wed, 14 May 2008 15:03:15 -0700
Subject: [erlang-questions] Best approach to stop distributed erlang	apps
In-Reply-To: <53528.192.168.34.15.1210797249.squirrel@squirrelmail.vail>
References: 
	<53528.192.168.34.15.1210797249.squirrel@squirrelmail.vail>
Message-ID: <20080514220315.GH8868@delora.autosys.us>

On Wed, May 14, 2008 at 04:34:09PM -0400, Rick Pettit wrote:
> On Wed, May 14, 2008 2:44 pm, Dave Bryson wrote:
> > I have an application distributed across X number of machines in a
> > cluster.  I'm currently launching the apps in a -detached mode. To
> > launch the apps, I'm using a shell script that loops through the nodes
> > and runs a start script via SSH.  I'd like to be able to do the same
> > thing to stop the apps ( completely stop the erlang runtime
> > init:stop() ).  However, I  haven't been able to figure out the best
> > approach to do that.  The only thing I've been successful with is to -
> > remsh into each application and call "init:stop()".
> >
> > Does anyone have a "best practice" approach to automate calling
> > init:stop() across a cluster?
> 
> If order doesn't matter and a clean shutdown which flushes all I/O isn't
> required you should be able to do something like:
> 
>   StopNode=fun(N) -> rpc:call(N,init,stop,[]) end,
>   lists:foreach(StopNode, nodes()).
> 
> -Rick
> 
> P.S. I have not tested the code above :-)
> 
______________________________________________________________________

 Or, presuming that your distributed nodes are accepting messages,
 accept a 

 {From, stop} -> check that From is a friend and cleanup my junk ,
                 init:stop() ;

 message type in your receive loop.

 I use a configuration file containing a list of just who a "friend" is,
 i.e. who can send a valid stop command.


~Michael


From fritchie@REDACTED  Thu May 15 02:30:29 2008
From: fritchie@REDACTED (Scott Lystig Fritchie)
Date: Wed, 14 May 2008 19:30:29 -0500
Subject: [erlang-questions] erlang:monitor() lag time: how long to expect?
Message-ID: <65929.1210811429@snookles.snookles.com>

Hi, I've discovered that the lag time between calling erlang:monitor()
and receiving the {'DOWN', ...} message.  I'd like to ask how long is
reasonable to wait?

The proc I'm monitoring is on a remote node, and I'm monitoring it via
erlang:monitor(process, {registered_name_atom(), node_atom()}).  I have
two Erlang nodes, A & B, on two separate physical machines.  Both are
running R11B-5 on top of Linux, "erl -kernel net_ticktime 60 ...".

   1. B is quite busy doing stuff, but it's responding to
      gen_server:call() queries within the default 5 seconds.

   2. On A, I call monitor/2 for a process, my_server_proc, that hasn't
      started yet on B.

   3. 31 seconds later, B starts & registers the proc I want to monitor

   4. 32 seconds later, A gets a {'DOWN', ...} message for step #2's
      monitor.

I suppose I shouldn't be monitoring a proc that hasn't been started
yet.  ("Doctor, it hurts when ...")  And there's a work-around, I
suppose: use rpc:call(node_B, erlang, whereis, [my_server_proc]) to
verify that the server is actually running.

Has anyone else run into seemingly long-delayed {'DOWN', ...} messages?

-Scott

--- snip --- snip --- snip --- snip --- snip --- snip ---

node A : 20080514162806 : make_monitor 1: {my_server_proc,'test@REDACTED'} ref #Ref<0.0.0.247945>

node B : 20080514162837 : progress: [{supervisor,{local,foo_foo_sup}},{started,[{pid,<0.324.0>},{name,my_server_proc},{mfa,{foo_server,start_link,...

node A : 20080514162857 : gen_server:call({my_server_proc,'test@REDACTED'}, bar) returned ok

node A : 20080514162909 : got 'DOWN': my_server_proc Mref #Ref<0.0.0.247945>, Type process, Object {my_server_proc,'test@REDACTED'}, Info noproc



From ok@REDACTED  Thu May 15 03:27:55 2008
From: ok@REDACTED (Richard A. O'Keefe)
Date: Thu, 15 May 2008 13:27:55 +1200
Subject: [erlang-questions] eep: multiple patterns
In-Reply-To: <200805141620.19559.bekesa@sch.bme.hu>
References: <200805141620.19559.bekesa@sch.bme.hu>
Message-ID: <9D3B7052-670D-4E00-985F-CF4667DC06A1@cs.otago.ac.nz>

I feel that this proposal is a step in the wrong direction,
and has "hack" written all over it.

Let's start with the pattern-match operator,

	pattern ~= expression

I already feel slightly queasy at the fact that pattern matching
is associated with guards everywhere EXCEPT pattern = expression;
adding another construction that will work some but only some of
the time does not appeal to me.  Right now, I can do

	1 = f()

but I cannot do

	(X when X > 1) = f()

Right now, any instance of
	case E1 of P1 -> B1 end		% just one clause!
can be rewritten as
	(P1 = E1, B1).
Why not extend this to allow
	case E1 of P1 when G1 -> B1 end
to be written as
	((P1 when G1) = E1, B1)

I'm not pushing _hard_ for this, you understand, just
noting that there is a nasty and apparently unmotivated
gap in the language, and suggesting that something
should be done about it.  Abstract patterns are, of
course, a far better solution to the same issue.

Of course the same idea can be extended to ~=, and if ~=
were to be extended, it should be.

The draft EEP notes that the ~= construction adds no
real power (and, if we consider macros, no extra power
at all) in ordinary expressions.  It is ONLY useful in
guards.  But WHY is it useful?

~= is only useful because = is not allowed in guards.

Between a pattern match test that doesn't bind any
variables and a pattern match test that only binds
variables that happen not to be used anywhere else
there is no real difference.  ~= is a special case of
= .  So if we are willing to consider ~= in guards,
why not consider = in guards?

Indeed, why not?  If I can write

	f(L) when hd(L) > 0, hd(L) < 10 ->

why can't I write

	f(L) when N = hd(L), N > 0, N < 10 ->

In the past I have strongly defended the distinction
between guards and expressions, and I have not changed
my mind.  But allowing = in guards does not destroy any
of the properties of guards that have ever concerned me.

So instead of adding a new "crippled-bind" called ~=,
I suggest that it would be better to allow
Pattern = Expression as a guard.

What about the intended uses of ~= where the fact that
it does not bind variables is important?  Why then,
just restrict the corresponding = to not bind variables.
{foo,_,27} = hd(X) would have the same effect in a guard
as {foo,_,27} ~= hd(X) would have, so if we allowed =,
there would be no point in having ~= as well, while if
we had ~= we would still be left lamenting the
inexplicable prohibition on =.

Do I need to mention that the similarity between = and
~= would lead to errors when one was used but the other
intended?  No, I thought not.  ~= is something we are
better off without.  But its use in guards _is_ something
we could do with, only the existing = would be far better.

That's enough for one message, I think.

Maybe not.

I don't like vague suggestions that
"It is rather common to check the value of an expression with a
     case expression and do the same actions in some of the cases."
I want to see *actual cases*.

Oh, and did I point out that abstract patterns can solve the
"multiple patterns" problem neatly and clearly?



From jeffm@REDACTED  Thu May 15 08:55:39 2008
From: jeffm@REDACTED (jm)
Date: Thu, 15 May 2008 16:55:39 +1000
Subject: [erlang-questions] size of an open file
In-Reply-To: <1210768723.1111.18.camel@seasc0642.dyn.rnd.as.sw.ericsson.se>
References: <482A453E.9010807@ghostgun.com>	<1210751058.1111.9.camel@seasc0642.dyn.rnd.as.sw.ericsson.se>	<482A9FBD.8010401@ghostgun.com>
	<1210768723.1111.18.camel@seasc0642.dyn.rnd.as.sw.ericsson.se>
Message-ID: <482BDE6B.9020906@ghostgun.com>



Bengt Kleberg wrote:
> Greetings,
>
> What are your requirements?
> Do you have enough time/cpu/etc to open/close the file when reading the
> tail part of it?
>
>
> bengt
>
>   

This started as a programming exercise while I had nothing better to do 
waiting for a quote from a vendor. The idea was to get more experience 
with erlang by writing something which normally has side effects and to 
use some of the functions which I've not used in erlang yet.  I decided 
to try and imitate unix's "tail -F" to some extent, ie tail with follow 
file. There isn't any requirements beyond that. What I have at the 
moment reads in from a file and breaks it into lines. There are two 
version one which returns the lines and continutation info and another 
which uses lists:foreach to call a passed in function on each line.

The next step is to add the follow file functionality. Speed is not 
important. I may us it later in a program. If that happens then I'd be 
reading from multiple files similtaneously, so concurrentency may be.


Jeff.


From tobbe@REDACTED  Thu May 15 09:56:40 2008
From: tobbe@REDACTED (Torbjorn Tornkvist)
Date: Thu, 15 May 2008 09:56:40 +0200
Subject: [erlang-questions] facebook chat server
Message-ID: 

I picked up this on the #erlang channel:

 http://www.facebook.com/notes.php?id=9445547199


Pretty cool!

--Tobbe



From erlang-questions_efine@REDACTED  Thu May 15 09:58:34 2008
From: erlang-questions_efine@REDACTED (Edwin Fine)
Date: Thu, 15 May 2008 03:58:34 -0400
Subject: [erlang-questions] process_info/1 and process_info/2
Message-ID: <6c2563b20805150058x5c6dcd7dhd852754ac868af3a@mail.gmail.com>

Hi all,

I don't know if my first post just didn't make it, or got ignored because I
inadvertently offended someone, or perhaps it asked too boring a question. I
am trying again in the hope that it just got missed.

What I need to do is find out, at run time, which info items (e.g.
heap_size) process_info/2 supports. This is so I don't have to go changing
code every time an item is added (or removed, which seems unlikely). What I
have done is use the process_info/1 BIF (which I know is for debugging only)
to get a list of supported info items, something like this:

5> [K || {K,_} <- process_info(pid(0,0,0))].
[registered_name,current_function,initial_call,status,
 message_queue_len,messages,links,dictionary,trap_exit,
 error_handler,priority,group_leader,total_heap_size,
 heap_size,stack_size,reductions,garbage_collection,
 suspending]

Short of hard-coding the names of all the info items, or scanning the
documentation at run-time, is there any "legal" way to do what I want to do
other than what I have described?

Regards,
Edwin Fine
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From mats.cronqvist@REDACTED  Thu May 15 10:08:30 2008
From: mats.cronqvist@REDACTED (Mats Cronqvist)
Date: Thu, 15 May 2008 10:08:30 +0200
Subject: [erlang-questions] process_info/1 and process_info/2
In-Reply-To: <6c2563b20805150058x5c6dcd7dhd852754ac868af3a@mail.gmail.com>
References: <6c2563b20805150058x5c6dcd7dhd852754ac868af3a@mail.gmail.com>
Message-ID: <482BEF7E.2010800@gmail.com>

Edwin Fine wrote:
> Hi all,
>
> I don't know if my first post just didn't make it, or got ignored 
> because I inadvertently offended someone, or perhaps it asked too 
> boring a question. I am trying again in the hope that it just got missed.
> What I need to do is find out, at run time, which info items (e.g. 
> heap_size) process_info/2 supports. 

  the deafening silence was probably due to the answer is so boring; 
"there is no way to do that." afaik.

  mats


From vychodil.hynek@REDACTED  Thu May 15 10:42:16 2008
From: vychodil.hynek@REDACTED (Hynek Vychodil)
Date: Thu, 15 May 2008 10:42:16 +0200
Subject: [erlang-questions] eep: multiple patterns
In-Reply-To: <9D3B7052-670D-4E00-985F-CF4667DC06A1@cs.otago.ac.nz>
References: <200805141620.19559.bekesa@sch.bme.hu>
	<9D3B7052-670D-4E00-985F-CF4667DC06A1@cs.otago.ac.nz>
Message-ID: <4d08db370805150142g73796341t1c1932eee546cf91@mail.gmail.com>

+1

On Thu, May 15, 2008 at 3:27 AM, Richard A. O'Keefe 
wrote:

> I feel that this proposal is a step in the wrong direction,
> and has "hack" written all over it.
>
> Let's start with the pattern-match operator,
>
>        pattern ~= expression
>
> I already feel slightly queasy at the fact that pattern matching
> is associated with guards everywhere EXCEPT pattern = expression;
> adding another construction that will work some but only some of
> the time does not appeal to me.  Right now, I can do
>
>        1 = f()
>
> but I cannot do
>
>        (X when X > 1) = f()
>
> Right now, any instance of
>        case E1 of P1 -> B1 end         % just one clause!
> can be rewritten as
>        (P1 = E1, B1).
> Why not extend this to allow
>        case E1 of P1 when G1 -> B1 end
> to be written as
>        ((P1 when G1) = E1, B1)
>
> I'm not pushing _hard_ for this, you understand, just
> noting that there is a nasty and apparently unmotivated
> gap in the language, and suggesting that something
> should be done about it.  Abstract patterns are, of
> course, a far better solution to the same issue.
>
> Of course the same idea can be extended to ~=, and if ~=
> were to be extended, it should be.
>
> The draft EEP notes that the ~= construction adds no
> real power (and, if we consider macros, no extra power
> at all) in ordinary expressions.  It is ONLY useful in
> guards.  But WHY is it useful?
>
> ~= is only useful because = is not allowed in guards.
>
> Between a pattern match test that doesn't bind any
> variables and a pattern match test that only binds
> variables that happen not to be used anywhere else
> there is no real difference.  ~= is a special case of
> = .  So if we are willing to consider ~= in guards,
> why not consider = in guards?
>
> Indeed, why not?  If I can write
>
>        f(L) when hd(L) > 0, hd(L) < 10 ->
>
> why can't I write
>
>        f(L) when N = hd(L), N > 0, N < 10 ->
>
> In the past I have strongly defended the distinction
> between guards and expressions, and I have not changed
> my mind.  But allowing = in guards does not destroy any
> of the properties of guards that have ever concerned me.
>
> So instead of adding a new "crippled-bind" called ~=,
> I suggest that it would be better to allow
> Pattern = Expression as a guard.
>
> What about the intended uses of ~= where the fact that
> it does not bind variables is important?  Why then,
> just restrict the corresponding = to not bind variables.
> {foo,_,27} = hd(X) would have the same effect in a guard
> as {foo,_,27} ~= hd(X) would have, so if we allowed =,
> there would be no point in having ~= as well, while if
> we had ~= we would still be left lamenting the
> inexplicable prohibition on =.
>
> Do I need to mention that the similarity between = and
> ~= would lead to errors when one was used but the other
> intended?  No, I thought not.  ~= is something we are
> better off without.  But its use in guards _is_ something
> we could do with, only the existing = would be far better.
>
> That's enough for one message, I think.
>
> Maybe not.
>
> I don't like vague suggestions that
> "It is rather common to check the value of an expression with a
>     case expression and do the same actions in some of the cases."
> I want to see *actual cases*.
>
> Oh, and did I point out that abstract patterns can solve the
> "multiple patterns" problem neatly and clearly?
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>



-- 
--Hynek (Pichi) Vychodil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From raimo+erlang-questions@REDACTED  Thu May 15 10:55:00 2008
From: raimo+erlang-questions@REDACTED (Raimo Niskanen)
Date: Thu, 15 May 2008 10:55:00 +0200
Subject: [erlang-questions] EEP 10
Message-ID: <20080515085500.GA613@erix.ericsson.se>

EEP 10: Representing Unicode characters in Erlang
has been recognized by the EEP editor(s).

http://www.erlang.org/eeps/eep-0010.html

-- 

/ Raimo Niskanen, Erlang/OTP, Ericsson AB


From raimo+erlang-questions@REDACTED  Thu May 15 11:00:36 2008
From: raimo+erlang-questions@REDACTED (Raimo Niskanen)
Date: Thu, 15 May 2008 11:00:36 +0200
Subject: [erlang-questions] :  eep: multiple patterns
In-Reply-To: <9D3B7052-670D-4E00-985F-CF4667DC06A1@cs.otago.ac.nz>
References: <200805141620.19559.bekesa@sch.bme.hu>
	<9D3B7052-670D-4E00-985F-CF4667DC06A1@cs.otago.ac.nz>
Message-ID: <20080515090036.GB613@erix.ericsson.se>

On Thu, May 15, 2008 at 01:27:55PM +1200, Richard A. O'Keefe wrote:
> I feel that this proposal is a step in the wrong direction,
> and has "hack" written all over it.
> 
:
> 
> So instead of adding a new "crippled-bind" called ~=,
> I suggest that it would be better to allow
> Pattern = Expression as a guard.
> 
> What about the intended uses of ~= where the fact that
> it does not bind variables is important?  Why then,
> just restrict the corresponding = to not bind variables.
> {foo,_,27} = hd(X) would have the same effect in a guard
> as {foo,_,27} ~= hd(X) would have, so if we allowed =,
> there would be no point in having ~= as well, while if
> we had ~= we would still be left lamenting the
> inexplicable prohibition on =.
> 
> Do I need to mention that the similarity between = and
> ~= would lead to errors when one was used but the other
> intended?  No, I thought not.  ~= is something we are
> better off without.  But its use in guards _is_ something
> we could do with, only the existing = would be far better.
> 
> That's enough for one message, I think.
> 

So far I agree.

> Maybe not.
> 
> I don't like vague suggestions that
> "It is rather common to check the value of an expression with a
>      case expression and do the same actions in some of the cases."
> I want to see *actual cases*.

But on this one I have experienced so many *actual cases*
myself to accept it as an inconveniance. A solution
to the multiple patterns to one branch problem would
be convenient, indeed.

> 
> Oh, and did I point out that abstract patterns can solve the
> "multiple patterns" problem neatly and clearly?
> 
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions

-- 

/ Raimo Niskanen, Erlang/OTP, Ericsson AB


From bengt.kleberg@REDACTED  Thu May 15 11:06:07 2008
From: bengt.kleberg@REDACTED (Bengt Kleberg)
Date: Thu, 15 May 2008 11:06:07 +0200
Subject: [erlang-questions] size of an open file
In-Reply-To: <482BDE6B.9020906@ghostgun.com>
References: <482A453E.9010807@ghostgun.com>
	<1210751058.1111.9.camel@seasc0642.dyn.rnd.as.sw.ericsson.se>
	<482A9FBD.8010401@ghostgun.com>
	<1210768723.1111.18.camel@seasc0642.dyn.rnd.as.sw.ericsson.se>
	<482BDE6B.9020906@ghostgun.com>
Message-ID: <1210842367.21090.13.camel@seasc0642.dyn.rnd.as.sw.ericsson.se>

Greetings,

If I understand you correctly you have the resources to do the
following:
open the file and start to read from it. When you hit eof you wait a
while and try again. After some time of getting nothing but eof you can
test if the current position is bigger than the file size of the
original file name. When this happens you close the current file and
open the original file name. Repeat.

This will fail if the current file is (re)moved at position 1000, and
the new file with the original name manages to fill up to exactly 1000
before you test its size. Given a program that rapidly fills many small
files with exactly the same content that is not unlikely.
If you have that scenario you need to know how fast the file fills so
that you can test its size before it manages to become full.


bengt

On Thu, 2008-05-15 at 16:55 +1000, jm wrote:
> 
> Bengt Kleberg wrote:
> > Greetings,
> >
> > What are your requirements?
> > Do you have enough time/cpu/etc to open/close the file when reading the
> > tail part of it?
> >
> >
> > bengt
> >
> >   
> 
> This started as a programming exercise while I had nothing better to do 
> waiting for a quote from a vendor. The idea was to get more experience 
> with erlang by writing something which normally has side effects and to 
> use some of the functions which I've not used in erlang yet.  I decided 
> to try and imitate unix's "tail -F" to some extent, ie tail with follow 
> file. There isn't any requirements beyond that. What I have at the 
> moment reads in from a file and breaks it into lines. There are two 
> version one which returns the lines and continutation info and another 
> which uses lists:foreach to call a passed in function on each line.
> 
> The next step is to add the follow file functionality. Speed is not 
> important. I may us it later in a program. If that happens then I'd be 
> reading from multiple files similtaneously, so concurrentency may be.
> 
> 
> Jeff.
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions



From vladdu55@REDACTED  Thu May 15 11:24:29 2008
From: vladdu55@REDACTED (Vlad Dumitrescu)
Date: Thu, 15 May 2008 11:24:29 +0200
Subject: [erlang-questions] EEP 10
In-Reply-To: <20080515085500.GA613@erix.ericsson.se>
References: <20080515085500.GA613@erix.ericsson.se>
Message-ID: <95be1d3b0805150224m3f0291c1qf3912dea9723995c@mail.gmail.com>

Hi,

2008/5/15 Raimo Niskanen

>:

> EEP 10: Representing Unicode characters in Erlang
> has been recognized by the EEP editor(s).
>
> http://www.erlang.org/eeps/eep-0010.html
>
>
Cool! I think there is one aspect that is related and maybe should be
adressed, regarding handling of source files. I suppose keeping them as
latin1 will no longer be acceptable in the longer perspective, because
people may need to use non-latin1 string literals. The same applies to files
read with file:consult/1, for example, where the API doesn't yet allow
specifying the encoding.

I'm not sure if this should be a different eep or not.

Aside (just slightly): if the i18n can of worms is opened, then it will also
become useful to be able to localize strings for different languages and a
standard way to handle this will help a lot.

regards,
Vlad
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From matthias@REDACTED  Thu May 15 11:01:17 2008
From: matthias@REDACTED (Matthias Lang)
Date: Thu, 15 May 2008 11:01:17 +0200
Subject: [erlang-questions] process_info/1 and process_info/2
In-Reply-To: <6c2563b20805150058x5c6dcd7dhd852754ac868af3a@mail.gmail.com>
References: <6c2563b20805150058x5c6dcd7dhd852754ac868af3a@mail.gmail.com>
Message-ID: <18475.64477.164475.230759@antilipe.corelatus.se>

Edwin Fine writes:

 > I don't know if my first post just didn't make it, or got ignored because I
 > inadvertently offended someone, or perhaps it asked too boring a
 > question. 

I thought "the guy's figured out a perfectly workable solution but is
tying himself in knots to avoid using it because it doesn't seem
painful enough." Either that, or he hasn't managed to explain what he
really wants to do.

Matt


From bekesa@REDACTED  Thu May 15 13:07:18 2008
From: bekesa@REDACTED (Andras Georgy Bekes)
Date: Thu, 15 May 2008 13:07:18 +0200
Subject: [erlang-questions] eep: multiple patterns
In-Reply-To: <9D3B7052-670D-4E00-985F-CF4667DC06A1@cs.otago.ac.nz>
References: <200805141620.19559.bekesa@sch.bme.hu>
	<9D3B7052-670D-4E00-985F-CF4667DC06A1@cs.otago.ac.nz>
Message-ID: <200805151307.18370.bekesa@sch.bme.hu>

Hi,

> I feel that this proposal is a step in the wrong direction,
> and has "hack" written all over it.
I agree with some of what you've written, but you completely missed one 
very important detail.

> Let's start with the pattern-match operator,
It seems to me you also finished with the pattern-match operator.
The other part of the eep (multiple patterns) is OK?

> 	1 = f()
> but I cannot do
> 	(X when X > 1) = f()
I completely agree. Whe should be able to do the latter, however, I 
don't consider it important.

> ~= is only useful because = is not allowed in guards.
>
> So instead of adding a new "crippled-bind" called ~=,
> I suggest that it would be better to allow
> Pattern = Expression as a guard.
You can't negate it!

I've also written, I think the most important use of the ~= operator was 
to express negated patterns, i.e. the ability to write a guard that 
fails if (some part of) the matched value matches a pattern. It seems 
you completely missed this point.

> What about the intended uses of ~= where the fact that
> it does not bind variables is important?
If it doesn't match, it naturally can't bind variables.
That's it.

Please propose a different construct that expresses negated patterns, 
and is easy to implement, understand and use. I told you I am 
dissatisfied with what I'm about to propose, I just can't find a better 
solution.

> I don't like vague suggestions that
> "It is rather common to check the value of an expression with a
>      case expression and do the same actions in some of the cases."
> I want to see *actual cases*.
I think I am not allowed to copy-paste code pieces from AXD301 here.
Beleive me, I could.
Do you want me to obfuscate and send a few?

> Oh, and did I point out that abstract patterns can solve the
> "multiple patterns" problem neatly and clearly?
I accept your abstract patterns as useful and nice, but is quite a big 
change in the language. My proposal is a small change. Easy to learn, 
easy to implement, easy to document, no compatibility issues.

	Georgy


From mats.cronqvist@REDACTED  Thu May 15 13:40:56 2008
From: mats.cronqvist@REDACTED (Mats Cronqvist)
Date: Thu, 15 May 2008 13:40:56 +0200
Subject: [erlang-questions] :  eep: multiple patterns
In-Reply-To: <20080515090036.GB613@erix.ericsson.se>
References: <200805141620.19559.bekesa@sch.bme.hu>	<9D3B7052-670D-4E00-985F-CF4667DC06A1@cs.otago.ac.nz>
	<20080515090036.GB613@erix.ericsson.se>
Message-ID: <482C2148.3060405@gmail.com>

Raimo Niskanen wrote:
> On Thu, May 15, 2008 at 01:27:55PM +1200, Richard A. O'Keefe wrote:
>   
>> I don't like vague suggestions that
>> "It is rather common to check the value of an expression with a
>>      case expression and do the same actions in some of the cases."
>> I want to see *actual cases*.
>>     
>
> But on this one I have experienced so many *actual cases*
> myself to accept it as an inconveniance. A solution
> to the multiple patterns to one branch problem would
> be convenient, indeed.
>   
 +1
  i don't know where ro'k gets his code examples from, but i for one 
have seen tons and tons of code where many patterns winds up in the same 
branch.
  i find virding's suggestion [1] much nicer though;

foo(Pat11, ...) when Guard1 ;
foo(Pat12, ...) when Guard2 ;
foo(Pat13, ...) when Guard3 ->
    ...;


case ... of
    Pat1 when Guard1 ;
    Pat2 when Guard2 -> ...;
    ...
end

  as for the "~=" operator; i guess i don't see the point.

  mats


[1] 
http://www.erlang.org/pipermail/erlang-questions/2008-March/033784.html)



From lenartlad@REDACTED  Thu May 15 15:14:31 2008
From: lenartlad@REDACTED (Ladislav Lenart)
Date: Thu, 15 May 2008 15:14:31 +0200
Subject: [erlang-questions] [Q] how to start httpd in R12B
Message-ID: <482C3737.1010009@volny.cz>

Hello,

in R11B I used to start httpd server in my application top supervisor
via exported (but unsupported) httpd:start_link2/1 function which
no longer exist in R12B. So I changed it to httpd:start_standalone/1.
After all is started (db, inets, my supervisor which among other
things starts the HTTP server) I want to add default web users using
mod_auth:add_user/X. But this fails in gen_server:call/X because
the locally registered process httpd_auth_8008 does not exist.
I was trying to figure out who should start it (the mod_auth_server
module) from the sources but got lost on the way... :-(

My starting procedure is:
  1. Start mnesia (possibly creating a schema) and wait for tables.
  2. Start inets.
  3. Start my application which starts the top supervisor which
     starts the httpd. At this point, the only running HTTP related
     registered processes are:
       [httpc_sup,
        httpc_profile_sup,
        httpc_manager,
        httpc_handler_sup,
        httpd_sup].
  4. Ensure the default web users exist (crash).

The top supervisor init callback is (the interesting bit is WebSpec - httpd child spec):
init(Options) ->
     Environment = aw_options:read_option(environment, Options, aw_settings:read(environment, deployment)),
     WebSpec = {httpd,
	       {httpd, start_standalone, [aw_web:server_config(Environment)]},
	       transient,
	       infinity,
	       supervisor,
	       [httpd_sup]},
     MQSpec = {mqueue,
	      {aw_mqueue, start_link, []},
	      transient,
	      brutal_kill,
	      worker,
	      [aw_mqueue]},
     MailerOptions = aw_options:read_option(mailer, Options, aw_settings:read(mailer, [])),
     MailerSpec = {mailer,
		  {aw_mailer, start_link, [MailerOptions]},
		  transient,
		  5000,
		  worker,
		  [aw_mailer]},
     {ok, {{one_for_one, 10, 1}, [WebSpec, MQSpec, MailerSpec]}}.

My HTTP server configuration is (returned by aw_web:server_config/1,
mod_besi is our own extension):
[
      {server_name, ?server_name},
      {server_root, "/tmp"},
      {bind_address, ?listen_address},
      {port, Port},
      {document_root, document_root()},
      {mime_types, mime_types()},
      {directory_index, ["index.html"]},
      {besi_alias, {?mqueue_path, aw_web_mqueue}},
      {besi_alias, {?view_path, aw_web_view}},
      {besi_alias, {?edit_path, aw_web_edit}},
      {besi_environment, Environment},
      {directory, {?view_path, [{auth_name, ?admin_realm},
			      {auth_type, mnesia},
			      {allow_from, all},
			      {require_user, [?admin_view_user, ?admin_edit_user]}]}},
      {directory, {?edit_path, [{auth_name, ?admin_realm},
			      {auth_type, mnesia},
			      {allow_from, all},
			      {require_user, [?admin_edit_user]}]}},
      {directory, {?mqueue_path, [{allow_from, local_network()}]}},
      {modules, [mod_alias, mod_auth, mod_besi, mod_get, mod_head]}
]

The error message I get when starting my application is:
** exception error: no match of right hand side value
                     {error,
                      {bad_return,
                       {{aw_app,start,[normal,[]]},
                        {'EXIT',
                         {{badmatch,
                           {error,
                            {noproc,
                             {gen_server,call,
                              [httpd_auth_8008,
                               {add_user,undefined,8008,"/view",
                                [{httpd_user,"view",[...],...}],
                                "NoPassword"}]}}}},
                          [{aw_web,ensure_has_users,0},
                           {aw_app,start,2},
                           {application_master,start_it_old,4}]}}}}}
      in function  aw_app:start/1

Could someone please enlighten me?

Thanks in advance,

Ladislav Lenart




From alexd@REDACTED  Thu May 15 15:19:57 2008
From: alexd@REDACTED (alexd@REDACTED)
Date: Thu, 15 May 2008 14:19:57 +0100
Subject: [erlang-questions] SHA256 support in crypto
Message-ID: 

Hi - 

I was wondering if there were any plans to update the crypto module with 
support for SHA256, as described here :

http://www.erlang.org/pipermail/erlang-patches/2007-June/000177.html

?

Thanks for your help,


Alex.


From pfisher@REDACTED  Thu May 15 15:40:30 2008
From: pfisher@REDACTED (Paul Fisher)
Date: Thu, 15 May 2008 08:40:30 -0500
Subject: [erlang-questions] EEP 10
In-Reply-To: <20080515085500.GA613@erix.ericsson.se>
References: <20080515085500.GA613@erix.ericsson.se>
Message-ID: <1210858830.6462.137.camel@localhost>

On Thu, 2008-05-15 at 10:55 +0200, Raimo Niskanen wrote:
> EEP 10: Representing Unicode characters in Erlang
> has been recognized by the EEP editor(s).
> 
> http://www.erlang.org/eeps/eep-0010.html

Bravo!  Some comments:

1) "Formatting function section
In general, why the choice of ~ts for unicode string format specifier?
All others are single character and ~u is available, so ...


2) "Formatting functions" section
Is this really what was intended?

"9> io:format(Terminal,"~s",["sm?rg?s"]).

- would convert the string "sm?rg?s" (Swedish word for sandwich) to
UTF-8 before sending it to the terminal, ..."

I would have expected this to send the literal 0..255 latin1 characters
to the terminal rather than converting to utf-8, Behaving exactly as
file driver. Conversely, if ~s does not behave in this way, how would
you get the direct latin1 characters to the terminal? ?

?Is it the intent to have the terminal driver simply deal with utf-8,
converting (possibly) back to latin1 if the locale is not set to utf-8?
The section goes on to talk about io:read and terminal device driver,
saying "input should always be expected to be in UTF-8", which does seem
to indicate that this was the thinking.


3) I vote to support utf-16 in the binary support, might as well be
complete from the start.  The only issue is whether things like reading
files would automatically deal with the byte-order-mark used in
(some/most all) utf-16 docs.  Just something else to consider.


-- 
paul



From bekesa@REDACTED  Thu May 15 16:24:59 2008
From: bekesa@REDACTED (Andras Georgy Bekes)
Date: Thu, 15 May 2008 16:24:59 +0200
Subject: [erlang-questions] :  eep: multiple patterns
In-Reply-To: <482C2148.3060405@gmail.com>
References: <200805141620.19559.bekesa@sch.bme.hu>
	<20080515090036.GB613@erix.ericsson.se> <482C2148.3060405@gmail.com>
Message-ID: <200805151624.59310.bekesa@sch.bme.hu>

>   i find virding's suggestion [1] much nicer though;
>
> foo(Pat11, ...) when Guard1 ;
> foo(Pat12, ...) when Guard2 ;
> foo(Pat13, ...) when Guard3 ->
>     ...;
>
> case ... of
>     Pat1 when Guard1 ;
>     Pat2 when Guard2 -> ...;
>     ...
> end
Well, what I suggest differs only in a ; <=> | change.
I think ; is more confusing, because it already has a use.

>   as for the "~=" operator; i guess i don't see the point.
Few examples:

==================================================
Negated patterns:
---------------------------
case Expression of
    {X,Pattern} when not (X~=Pattern2) ->
	action1(X,Variables_in_Pattern);
    _ ->
	action2() %think lots of code here
end
---------------------------

The same Without ~= :
---------------------------
case Expression of
    {Pattern2,Pattern} ->
	action2(); %think lots of duplicated code here
    {X,Pattern} ->
	action1(X,Variables_in_Pattern);
    _ ->
	action2() %think lots of duplicated code here
end

==================================================
Conditional exception throwing:
---------------------------
(Pattern ~= Expression) andalso throw(Exception)
---------------------------
OR:
---------------------------
not (Pattern ~= Expression) andalso throw(Exception)
---------------------------

==================================================
Pattern-testing in short-circuit logic expressions:
---------------------------
case (Pattern1~=f1()) andalso (Pattern2~=f2()) of
   true ->
      action1();
   false ->
      action2()
end
---------------------------

Without ~= :
---------------------------
case f1() of
   Pattern1 ->
      case f2() of
         Pattern2 ->
            action1();
         _ ->
            action2()
      end;
   _ ->
     action2()
end
---------------------------

	Georgy


From erlangy@REDACTED  Thu May 15 17:19:40 2008
From: erlangy@REDACTED (Michael McDaniel)
Date: Thu, 15 May 2008 08:19:40 -0700
Subject: [erlang-questions] size of an open file
In-Reply-To: <1210842367.21090.13.camel@seasc0642.dyn.rnd.as.sw.ericsson.se>
References: <482A453E.9010807@ghostgun.com>
	<1210751058.1111.9.camel@seasc0642.dyn.rnd.as.sw.ericsson.se>
	<482A9FBD.8010401@ghostgun.com>
	<1210768723.1111.18.camel@seasc0642.dyn.rnd.as.sw.ericsson.se>
	<482BDE6B.9020906@ghostgun.com>
	<1210842367.21090.13.camel@seasc0642.dyn.rnd.as.sw.ericsson.se>
Message-ID: <20080515151940.GO8868@delora.autosys.us>


 I occasionally check the 'file modified' timestamp (file:read_file_info/1)
 and if it is later than the last time I saw data from a read, I close/open
 the file for further reads.  I use a timer (timer:apply_after/4) which gets
 reset each time I read data.  If timer expires (i.e. have not read data in
 N amount of time) a fun is run which does the check.  Good enough for my
 current use, maybe not for yours (you have to know how often you are 
 expecting new data).
 

~Michael


On Thu, May 15, 2008 at 11:06:07AM +0200, Bengt Kleberg wrote:
> Greetings,
> 
> If I understand you correctly you have the resources to do the
> following:
> open the file and start to read from it. When you hit eof you wait a
> while and try again. After some time of getting nothing but eof you can
> test if the current position is bigger than the file size of the
> original file name. When this happens you close the current file and
> open the original file name. Repeat.
> 
> This will fail if the current file is (re)moved at position 1000, and
> the new file with the original name manages to fill up to exactly 1000
> before you test its size. Given a program that rapidly fills many small
> files with exactly the same content that is not unlikely.
> If you have that scenario you need to know how fast the file fills so
> that you can test its size before it manages to become full.
> 
> 
> bengt
> 
> On Thu, 2008-05-15 at 16:55 +1000, jm wrote:
> > 
> > Bengt Kleberg wrote:
> > > Greetings,
> > >
> > > What are your requirements?
> > > Do you have enough time/cpu/etc to open/close the file when reading the
> > > tail part of it?
> > >
> > >
> > > bengt
> > >
> > >   
> > 
> > This started as a programming exercise while I had nothing better to do 
> > waiting for a quote from a vendor. The idea was to get more experience 
> > with erlang by writing something which normally has side effects and to 
> > use some of the functions which I've not used in erlang yet.  I decided 
> > to try and imitate unix's "tail -F" to some extent, ie tail with follow 
> > file. There isn't any requirements beyond that. What I have at the 
> > moment reads in from a file and breaks it into lines. There are two 
> > version one which returns the lines and continutation info and another 
> > which uses lists:foreach to call a passed in function on each line.
> > 
> > The next step is to add the follow file functionality. Speed is not 
> > important. I may us it later in a program. If that happens then I'd be 
> > reading from multiple files similtaneously, so concurrentency may be.
> > 
> > 
> > Jeff.
> > _______________________________________________
> > erlang-questions mailing list
> > erlang-questions@REDACTED
> > http://www.erlang.org/mailman/listinfo/erlang-questions
> 
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions


From lenartlad@REDACTED  Thu May 15 18:05:37 2008
From: lenartlad@REDACTED (Ladislav Lenart)
Date: Thu, 15 May 2008 18:05:37 +0200
Subject: [erlang-questions] [Bug] Re:  [Q] how to start httpd in R12B
In-Reply-To: <482C3737.1010009@volny.cz>
References: <482C3737.1010009@volny.cz>
Message-ID: <482C5F51.2000502@volny.cz>

Ladislav Lenart wrote:
> Hello,
> 
> in R11B I used to start httpd server in my application top supervisor
> via exported (but unsupported) httpd:start_link2/1 function which
> no longer exist in R12B. So I changed it to httpd:start_standalone/1.
> After all is started (db, inets, my supervisor which among other
> things starts the HTTP server) I want to add default web users using
> mod_auth:add_user/X. But this fails in gen_server:call/X because
> the locally registered process httpd_auth_8008 does not exist.
> I was trying to figure out who should start it (the mod_auth_server
> module) from the sources but got lost on the way... :-(
 > ...

Hello,

after all day I finally found the culprit in
   /usr/lib/erlang/lib/inets-5.0.5/src/mod_auth.erl

mod_auth:store/2 calls directory_config_check/2 to see if the supplied
parameters have allowed values. If successful, store_directory/3 is called.
The bug is in directory_config_check/2 which makes auth_type a mandatory
option.

The patch is attached.

BTW what is your strategy at finding the cause of such problems? I had
to resort to fwrites all over httpd_* modules because the error itself
was completely hidden by the supervisor machinery...

Ladislav Lenart
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mod_auth.diff
Type: text/x-diff
Size: 384 bytes
Desc: not available
URL: 

From erlang-questions_efine@REDACTED  Thu May 15 19:13:38 2008
From: erlang-questions_efine@REDACTED (Edwin Fine)
Date: Thu, 15 May 2008 13:13:38 -0400
Subject: [erlang-questions] Fwd: Suggestion: New Info item for process_info/2
In-Reply-To: <6c2563b20805151012h2c045828o635d3a719955a564@mail.gmail.com>
References: <6c2563b20805151012h2c045828o635d3a719955a564@mail.gmail.com>
Message-ID: <6c2563b20805151013g7e94b704kc1982b5dabd3d360@mail.gmail.com>

LOL. I probably deserved that. Thanks for the replies - SOMEONE is out
there!

Matt, the solution is workable, and I avoid pain as much as the next guy,
but I really want to have something that will TELL me what all the valid
process_info items are. process_info/1 only gives me SOME of them and is for
debugging only.

Ok, then; here's a suggestion:

Erlang team, How about adding an info item of "all" for process_info/2? It
won't break the interface, and it will allow people like me to "query"
process_info for which items are valid.

Regards,
Edwin Fine

On Thu, May 15, 2008 at 5:01 AM, Matthias Lang 
wrote:

> Edwin Fine writes:
>
>  > I don't know if my first post just didn't make it, or got ignored
> because I
>  > inadvertently offended someone, or perhaps it asked too boring a
>  > question.
>
> I thought "the guy's figured out a perfectly workable solution but is
> tying himself in knots to avoid using it because it doesn't seem
> painful enough." Either that, or he hasn't managed to explain what he
> really wants to do.
>
> Matt
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From ulf@REDACTED  Thu May 15 20:01:11 2008
From: ulf@REDACTED (Ulf Wiger)
Date: Thu, 15 May 2008 20:01:11 +0200
Subject: [erlang-questions] facebook chat server
In-Reply-To: 
References: 
Message-ID: <8209f740805151101u2ce8d7ddxfaef2702f662ae15@mail.gmail.com>

Yes, and thrift sounds interesting too. It took me a while to find the
erlang-related stuff
in trunk/, but there is some - in
http://svn.facebook.com/svnroot/thrift/trunk/tutorial/erl/,
for example.

BR,
Ulf W

2008/5/15 Torbjorn Tornkvist :
> I picked up this on the #erlang channel:
>
>  http://www.facebook.com/notes.php?id=9445547199
>
>
> Pretty cool!
>
> --Tobbe
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>


From dnew@REDACTED  Thu May 15 20:10:51 2008
From: dnew@REDACTED (Darren New)
Date: Thu, 15 May 2008 11:10:51 -0700
Subject: [erlang-questions] Side-effects in "if" guards
Message-ID: <482C7CAB.60903@san.rr.com>

Being a newbie to Erlang, I wonder if there's a reason for the "if" 
statement to disallow side-effects in the guards, or whether it's just a 
result of using the same language construct for "if" as for "receive". 
I.e., I understand why guards in "receive" can't have side-effects, but 
the guards in "if" don't really seem to have that same problem.

I often find myself often stumbling over that fact, needing to write a 
nested-three-deep "if" or auxiliary functions to do relatively simple 
(and side-effect-free operations) simply because the tests are too 
complex (calling my own code). For example, I can't say

   if X is a list, and the list is length five,
      and there are no duplicates -> good;

I have to
   if X is a list ->
      Y = string:tolower(X),
      if X = Y ->
        if X is length five ->
          V = my:no_duplicates(X),
            if V -> good;

Rather than the more straightforward
   if X is a list andalso string:tolower(X) = X
     andalso len(X) = 5 andalso true = my:noduplicates(X) -> good;

Is there a reason for this other than not having to define (and 
implement) two different kinds of guards?

Or am I doing something suboptimal in my programming by doing this, and 
there's really a clever but unobvious-to-me way of making this work better?

-- 
   Darren New / San Diego, CA, USA (PST)
     "That's pretty. Where's that?"
          "It's the Age of Channelwood."
     "We should go there on vacation some time."


From kevin@REDACTED  Thu May 15 20:18:23 2008
From: kevin@REDACTED (Kevin A. Smith)
Date: Thu, 15 May 2008 14:18:23 -0400
Subject: [erlang-questions] facebook chat server
In-Reply-To: <8209f740805151101u2ce8d7ddxfaef2702f662ae15@mail.gmail.com>
References: 
	<8209f740805151101u2ce8d7ddxfaef2702f662ae15@mail.gmail.com>
Message-ID: 

Thrift is quite interesting. It's been accepted as an Apache project  
and is currently in the project incubator. We're using it at work as  
an RPC mechanism across several different langauges (PHP, Python, and  
Java). It works quite well.

--Kevin
On May 15, 2008, at 2:01 PM, Ulf Wiger wrote:

> Yes, and thrift sounds interesting too. It took me a while to find the
> erlang-related stuff
> in trunk/, but there is some - in
> http://svn.facebook.com/svnroot/thrift/trunk/tutorial/erl/,
> for example.
>
> BR,
> Ulf W
>
> 2008/5/15 Torbjorn Tornkvist :
>> I picked up this on the #erlang channel:
>>
>> http://www.facebook.com/notes.php?id=9445547199
>>
>>
>> Pretty cool!
>>
>> --Tobbe
>>
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://www.erlang.org/mailman/listinfo/erlang-questions
>>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions



From tobbe@REDACTED  Thu May 15 20:46:29 2008
From: tobbe@REDACTED (Torbjorn Tornkvist)
Date: Thu, 15 May 2008 20:46:29 +0200
Subject: [erlang-questions] EEP 10
In-Reply-To: <20080515085500.GA613@erix.ericsson.se>
References: <20080515085500.GA613@erix.ericsson.se>
Message-ID: 

Raimo Niskanen wrote:
> EEP 10: Representing Unicode characters in Erlang
> has been recognized by the EEP editor(s).
> 
> http://www.erlang.org/eeps/eep-0010.html
> 

Excellent proposal!

Any timeplan for it?

--Tobbe



From richardc@REDACTED  Thu May 15 20:49:10 2008
From: richardc@REDACTED (Richard Carlsson)
Date: Thu, 15 May 2008 20:49:10 +0200
Subject: [erlang-questions] Side-effects in "if" guards
In-Reply-To: <482C7CAB.60903@san.rr.com>
References: <482C7CAB.60903@san.rr.com>
Message-ID: <482C85A6.1020208@it.uu.se>

Darren New wrote:
> Is there a reason for this other than not having to define (and 
> implement) two different kinds of guards?

The main snag is that the rules for both syntax and semantics of
guards is subtly different from those of normal expressions, so
it's hard to extend what you can write in an if-guard in a way that
does not change the behaviour anywhere in all the existing code.

And even if you manage to do that, you'd likely end up with a very
complicated rule system for what you can write and what it means,
that nobody could keep track of, so in the interest of sanity, it
is probably best to leave it alone.

     /Richard


From dmercer@REDACTED  Thu May 15 21:04:01 2008
From: dmercer@REDACTED (David Mercer)
Date: Thu, 15 May 2008 14:04:01 -0500
Subject: [erlang-questions] Side-effects in "if" guards
In-Reply-To: <482C85A6.1020208@it.uu.se>
References: <482C7CAB.60903@san.rr.com> <482C85A6.1020208@it.uu.se>
Message-ID: <000001c8b6be$7257d760$891ea8c0@SSI.CORP>

> The main snag is that the rules for both syntax and semantics of
> guards is subtly different from those of normal expressions, so
> it's hard to extend what you can write in an if-guard in a way that
> does not change the behaviour anywhere in all the existing code.

What are the subtle differences?  I suspect most new users do not completely
grok that, since this subject comes up repeatedly.

DBM



From per.melin@REDACTED  Thu May 15 21:18:20 2008
From: per.melin@REDACTED (Per Melin)
Date: Thu, 15 May 2008 21:18:20 +0200
Subject: [erlang-questions] Side-effects in "if" guards
In-Reply-To: <482C7CAB.60903@san.rr.com>
References: <482C7CAB.60903@san.rr.com>
Message-ID: 

2008/5/15 Darren New :
> Rather than the more straightforward
>   if X is a list andalso string:tolower(X) = X
>     andalso len(X) = 5 andalso true = my:noduplicates(X) -> good;

A check that involved should probably be factored into its own function anyway.

foo(X) ->
    case is_string_ok(X) of
        true -> good;
        false -> bad
    end.

is_string_ok(X) ->
    is_list(X) andalso length(X) == 5 andalso
    string:tolower(X) == X andalso my:no_duplicates(X).


From dmercer@REDACTED  Thu May 15 22:20:37 2008
From: dmercer@REDACTED (David Mercer)
Date: Thu, 15 May 2008 15:20:37 -0500
Subject: [erlang-questions] EEP 10
In-Reply-To: <20080515085500.GA613@erix.ericsson.se>
References: <20080515085500.GA613@erix.ericsson.se>
Message-ID: <000501c8b6c9$238f8870$891ea8c0@SSI.CORP>

In the "Bit Syntax" section, there is the line:

> Both UTF-8 and UTF-16 is easily interpreted with the current bit syntax
> implementation, but the suggested specific types would be convenient for
> the programmer.

I don't know of an "easy" way to write using the current bit syntax: 

	<> = BinString

I'd have thought we would need the utf8 (and utf16) binary extensions to do
this easily.  What is the "easy" way to do this without the proposed
extensions?

DBM


> -----Original Message-----
> From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-
> bounces@REDACTED] On Behalf Of Raimo Niskanen
> Sent: Thursday, May 15, 2008 03:55
> To: erlang-questions@REDACTED
> Subject: [erlang-questions] EEP 10
> 
> EEP 10: Representing Unicode characters in Erlang
> has been recognized by the EEP editor(s).
> 
> http://www.erlang.org/eeps/eep-0010.html
> 
> --
> 
> / Raimo Niskanen, Erlang/OTP, Ericsson AB
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions



From tumanian@REDACTED  Thu May 15 22:38:11 2008
From: tumanian@REDACTED (Gurgen Tumanian)
Date: Fri, 16 May 2008 01:38:11 +0500
Subject: [erlang-questions] Yaws vs httpd
Message-ID: <85d11a2e0805151338x551f3777ia6f6166343393a90@mail.gmail.com>

Dear all

I just came across httpd module of inets, and i am wondering what are the
pro's and con's of using each of them, especially in generating dynamic
content. Of course i understand that collecting ehtml structures is more
handy then generating pure html, but are there any other advantages of using
Yaws?

Regards
Gurgen Tumanyan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From erlang-questions_efine@REDACTED  Thu May 15 23:42:17 2008
From: erlang-questions_efine@REDACTED (Edwin Fine)
Date: Thu, 15 May 2008 17:42:17 -0400
Subject: [erlang-questions] Side-effects in "if" guards
In-Reply-To: <6c2563b20805151439w59ac4788u548dfbd2d10069f4@mail.gmail.com>
References: <482C7CAB.60903@san.rr.com>
	<6c2563b20805151439w59ac4788u548dfbd2d10069f4@mail.gmail.com>
Message-ID: <6c2563b20805151442u25fd07fbw23d3e52127862c40@mail.gmail.com>

I saw something like this in some Erlang code. It is possible to achieve a
similar effect without using "if" as follows:

is_list(X) andalso string:to_lower(X) == X andalso length(X) == 5 and also
my:no_duplicates(X) andalso do_something(X).

do_something(X) ->
    %% Stuff...
    true.

Note the use of "==" instead of "=". Huge difference.

This is similar to Unix-ish shell-scripting techniques such as [[ -z "$NAME"
]] && echo "NAME not defined"

Edwin


On Thu, May 15, 2008 at 2:10 PM, Darren New  wrote:

> Being a newbie to Erlang, I wonder if there's a reason for the "if"
> statement to disallow side-effects in the guards, or whether it's just a
> result of using the same language construct for "if" as for "receive".
> I.e., I understand why guards in "receive" can't have side-effects, but
> the guards in "if" don't really seem to have that same problem.
>
> I often find myself often stumbling over that fact, needing to write a
> nested-three-deep "if" or auxiliary functions to do relatively simple
> (and side-effect-free operations) simply because the tests are too
> complex (calling my own code). For example, I can't say
>
>   if X is a list, and the list is length five,
>      and there are no duplicates -> good;
>
> I have to
>   if X is a list ->
>      Y = string:tolower(X),
>      if X = Y ->
>        if X is length five ->
>          V = my:no_duplicates(X),
>            if V -> good;
>
> Rather than the more straightforward
>   if X is a list andalso string:tolower(X) = X
>     andalso len(X) = 5 andalso true = my:noduplicates(X) -> good;
>
> Is there a reason for this other than not having to define (and
> implement) two different kinds of guards?
>
> Or am I doing something suboptimal in my programming by doing this, and
> there's really a clever but unobvious-to-me way of making this work better?
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From per.melin@REDACTED  Thu May 15 23:45:00 2008
From: per.melin@REDACTED (Per Melin)
Date: Thu, 15 May 2008 23:45:00 +0200
Subject: [erlang-questions] EEP 10
In-Reply-To: <000501c8b6c9$238f8870$891ea8c0@SSI.CORP>
References: <20080515085500.GA613@erix.ericsson.se>
	<000501c8b6c9$238f8870$891ea8c0@SSI.CORP>
Message-ID: 

2008/5/15 David Mercer :
> I don't know of an "easy" way to write using the current bit syntax:
>
>        <> = BinString
>
> I'd have thought we would need the utf8 (and utf16) binary extensions to do
> this easily.  What is the "easy" way to do this without the proposed
> extensions?

Off the top of my head. I haven't really tested this, but I think it
should work. Don't know if it falls within what you'd call easy
though. I think it's easy enough.

Calling the function u(BinStr) should return Ch if u/1 is:

u(<<2#11110:5, Ch:28, _/binary>>) -> 2#11110 bsl 28 bor Ch;
u(<<2#1110:4, Ch:20, _/binary>>) -> 2#1110 bsl 20 bor Ch;
u(<<2#110:3, Ch:13, _/binary>>) -> 2#110 bsl 13 bor Ch;
u(<>) -> Ch.

Though, after googling for other solution (maybe I should have done
that first?) I realise that this would also happily process broken
UTF-8 without complaints.

(And it would be more efficient to reverse the order of the above
function definitions.)


From ok@REDACTED  Fri May 16 00:45:23 2008
From: ok@REDACTED (Richard A. O'Keefe)
Date: Fri, 16 May 2008 10:45:23 +1200
Subject: [erlang-questions] :  eep: multiple patterns
In-Reply-To: <20080515090036.GB613@erix.ericsson.se>
References: <200805141620.19559.bekesa@sch.bme.hu>
	<9D3B7052-670D-4E00-985F-CF4667DC06A1@cs.otago.ac.nz>
	<20080515090036.GB613@erix.ericsson.se>
Message-ID: <3F2B298F-E162-4BD7-9BFA-08ACFA86F57A@cs.otago.ac.nz>

On 15 May 2008, at 9:00 pm, Raimo Niskanen wrote:
>> I don't like vague suggestions that
>> "It is rather common to check the value of an expression with a
>>     case expression and do the same actions in some of the cases."
>> I want to see *actual cases*.
>
> But on this one I have experienced so many *actual cases*
> myself to accept it as an inconveniance. A solution
> to the multiple patterns to one branch problem would
> be convenient, indeed.

I may have expressed myself badly.  You may have noticed that my
message criticised the ~= part, but did not criticise the idea or
even the method of allowing multiple patterns.  I did not say that
no actual cases EXIST, only that I would like to SEE them.
Actual cases can be enormously helpful, not only in evaluating
the utility of a proposal, but in suggesting alternatives.

For example, had there been some real cases shown, I could have
responded by showing how abstract patterns handle them, and we
could then have debated whether *anonymous* multiple patterns are
a good idea.
>>

>> Oh, and did I point out that abstract patterns can solve the
>> "multiple patterns" problem neatly and clearly?

THIS Richard DOES want to discuss evidence!

--
"I don't want to discuss evidence." -- Richard Dawkins, in an
interview with Rupert Sheldrake.  (Fortean times 232, p55.)








From ok@REDACTED  Fri May 16 00:47:21 2008
From: ok@REDACTED (Richard A. O'Keefe)
Date: Fri, 16 May 2008 10:47:21 +1200
Subject: [erlang-questions] EEP 10
In-Reply-To: <95be1d3b0805150224m3f0291c1qf3912dea9723995c@mail.gmail.com>
References: <20080515085500.GA613@erix.ericsson.se>
	<95be1d3b0805150224m3f0291c1qf3912dea9723995c@mail.gmail.com>
Message-ID: <4E6055A8-EEF5-4845-9823-26D19A860A69@cs.otago.ac.nz>

Coincidentally, I have just been quoting Unicode Annex 31
in the Haskell-caf? mailing list.  That's the chapter on
what identifiers should look like.
--
"I don't want to discuss evidence." -- Richard Dawkins, in an
interview with Rupert Sheldrake.  (Fortean times 232, p55.)








From ok@REDACTED  Fri May 16 02:35:54 2008
From: ok@REDACTED (Richard A. O'Keefe)
Date: Fri, 16 May 2008 12:35:54 +1200
Subject: [erlang-questions] eep: multiple patterns
In-Reply-To: <200805151307.18370.bekesa@sch.bme.hu>
References: <200805141620.19559.bekesa@sch.bme.hu>
	<9D3B7052-670D-4E00-985F-CF4667DC06A1@cs.otago.ac.nz>
	<200805151307.18370.bekesa@sch.bme.hu>
Message-ID: <5D916667-D9C8-43C4-A1E6-916653C9CB00@cs.otago.ac.nz>

On 15 May 2008, at 11:07 pm, Andras Georgy Bekes wrote:
>> Let's start with the pattern-match operator,
> It seems to me you also finished with the pattern-match operator.
> The other part of the eep (multiple patterns) is OK?

As I said later in that message, I decided that I had enough for
one message.  There are a number of unpleasant aspects to the
details of the multiple pattern proposal.  Amongst them, the fact
that "|" is already a very important symbol in Erlang with about
as different a meaning as you could imagine, and the fact that it
not merely perpetuates but expands a nasty hole in Erlang.  Let
me briefly explain that point.

	If a language allows a complex construction,
	it should let you *name* an abstraction of that
	construction and uses instances of it.

To give an example where this isn't done, consider Java 1.5.
You can have types like
	Map > >
but you cannot *name* any of these; only classes can have names.
So when you see
	Vector x;
	Map > y;
	Map > > z;
there is no immediately visible connection between these types.
It's enough to make you reach for dear old M4 so you can write

	define(Features, `Vector< Long >')
	define(Product_Name, `String')
	define(Catalogue, `Map< Product_Name, Features >')
	define(Company_Name, `String')
	define(Meta_Catalogue, `Map< Company_Name, Catalogue >')

	Features x;
	Catalogue y;
	Meta_Catalogue z;

In the same way, in Erlang at present we can write complicated
expressions, and we have abstractions of expressions, called
functions.  We have complicated patterns, BUT we have no named
abstractions of patterns.

The multiple pattern proposal makes patterns even MORE complicated,
without naming them, so a human being reading one has to do an
immense amount of decoding to figure out what the pattern *means*.
If there are several places where you need (basically) the same
complex pattern, too bad: you have to write the thing out in full
each time because you can't NAME it and use it more than once.
This is a disaster for maintenance, because it is far too easy to
change *some* of the occurrences of the pattern and not others.

Abstract patterns let you name patterns (simple, complex, or already
in the first proposal, MULTIPLE) and use them whenever you want.

While the multiple patterns proposal is not _technically_ flawed,
or at least, not obviously so, it is not good software engineering.

>> So instead of adding a new "crippled-bind" called ~=,
>> I suggest that it would be better to allow
>> Pattern = Expression as a guard.
> You can't negate it!

Who says?  According to the current on-line Erlang reference
manual, you can't negate *anything* in a guard, so this is nothing
new.  If you want to extend the syntax so that you *can* negate
things in a guard, then why shouldn't = be as negatable as
anything else?  As long as we stick with the idea that guards
are *NOT* things that evaluate to true or evaluate false, but
rather things that succeed or fail, it is clear that Pat=GdExp
can succeed or fail, so it makes just as much sense to negate
*that* as anything else in a guard.
>

> I've also written, I think the most important use of the ~= operator  
> was
> to express negated patterns, i.e. the ability to write a guard that
> fails if (some part of) the matched value matches a pattern. It seems
> you completely missed this point.

Not *addressing* a point isn't the same as *missing* it.
Here's what the proposal actually says:

... the most important use
     of the operator would be to extend pattern matching with negated
     patterns as in the following example pattern:

         PATTERN1 when not (PATTERN2 ~= Variable_bound_by_PATTERN1)

I'm sorry to have to point this out, but this is not an example.
It's a *schematic* example, that illustrates but does not exemplify.
Once again I want ACTUAL examples from real programs.

By the way, the syntactic operator '~=' includes a character that
is used for negation in many languages, not least including C,
C++, C#, and Java.  I'm used to reading "~=" as "not equals", so
to me "when not (Pat ~= GdExp)" looks like a double negation, and
I find myself wanting to simplify it to "when Pat = GdExp".
If you want to appeal to UNIX tradition for pattern matching
operators, the traditional UNIX symbol for this is a simple "~"
as in the AWK expression "$1 ~ /^fred/".

> Please propose a different construct that expresses negated patterns,
> and is easy to implement, understand and use.

I am very far from being convinced that negation in patterns is
at all a good idea.  In fact, I think it has the potential to be
very confusing indeed.  However, I have now explained that

  - allowing = in guards is *always* more powerful than adding ~=
  - there is no reason why = in a guard cannot be negated,
    if there is anything in a guard that can be negated.

Now I add

  - my proposal has no new construct, it just removes a restriction
    on the use of an existing construct, so it is at least as easy
    to use and understand as ~=

  - the implementation of ~= would be very nearly identical to the
    implementation of =; there seems to be no reason to believe that
    = is any harder to implement in guards than ~=

I also repeat what I've been saying all along, which is that
the abstract pattern proposal has been around for a long time, and
keeps on turning out to be just right for new problems.

Let's suppose you want to express

	when not {foo,_,27} = X

OK, so write

	#foo_response(ping) -> {foo,_,27});
	#foo_response(pong) -> {foo,_,42});
	#foo_response(pang) -> bar.

   ...   when #foo_response(Pung) = X, Pung /= ping

We really cannot discuss this much further without *concrete cases*
so that we can judge what might *actually* be written.
>

> I think I am not allowed to copy-paste code pieces from AXD301 here.
> Beleive me, I could.
> Do you want me to obfuscate and send a few?

Yes please.

>
>
>> Oh, and did I point out that abstract patterns can solve the
>> "multiple patterns" problem neatly and clearly?
> I accept your abstract patterns as useful and nice, but is quite a big
> change in the language. My proposal is a small change.

Your proposal adds TWO changes to the language:
"|" in clause heads, and "~=" in guards.
>
> Easy to learn,

Just because something is small does not mean it is easy to learn.
As I've argued above, both "|" and "~=" are as confusing as heck.
("|" otherwise means "cons", "~" can mean "not" in other languages.)
"~=" is riddled with special restrictions.

>
> easy to implement,
> easy to document, no compatibility issues.

Yes, but if one is changing a language, one may as well make ONE change
that solves LOTS of problems, rather than cluttering it up with dozens
of special-purpose kluges.

--
"I don't want to discuss evidence." -- Richard Dawkins, in an
interview with Rupert Sheldrake.  (Fortean times 232, p55.)








From srparish@REDACTED  Fri May 16 04:47:42 2008
From: srparish@REDACTED (Scott Parish)
Date: Thu, 15 May 2008 19:47:42 -0700
Subject: [erlang-questions] proposal: polymorphism by a protocol of
	convention
Message-ID: <88fce4d0805151947g6ec8764bj7742cba43e0a9650@mail.gmail.com>

Problem:

I've been writing several libraries lately, and trying to keep the
general purpose as possible. One example is a URI library. I'd like to
have a function that a user can pass a mapping of values, and it will
return a string fit to be used in a REST query (eg
"color=red&size=5"). The problem is that while writing this library,
users will only be able to pass in mapping types that i've forseen
allowing them to use. For instance, if i allow of tuple lists and
dicts, and the user is using gb_trees, he's got to convert it.

Thus people end up creating libraries that aren't as flexible as end
users may wish, or they have to specifically account for and handle
all the different permutations of types being passed in.

Solution:

First add a convention that any derived type should be enclosed in a
"record" (a tuple where the first value is an atom uniquely
identifying the name of the derived type)

Next, include code modules that identify different types of
interfaces. For instance, there could be a "map" module with method
such as "get", "put", "delete", "has". Calling the map module, it
would inspect the tuple passed in, and using the record name, call the
same named function on that module.

For instance, lets say i call: "map:put(size, 5, dict:new())".
map:put/3 will see that the "type" is "dict" and it will call
dict:put/3.

The above map module could also fall back on tuple-lists if a type is not found.

This should allow people to start writing code abstracted away from
the specific implimentation modules.

Thoughts?

sRp


From ok@REDACTED  Fri May 16 04:52:30 2008
From: ok@REDACTED (Richard A. O'Keefe)
Date: Fri, 16 May 2008 14:52:30 +1200
Subject: [erlang-questions] :  eep: multiple patterns
In-Reply-To: <482C2148.3060405@gmail.com>
References: <200805141620.19559.bekesa@sch.bme.hu>	<9D3B7052-670D-4E00-985F-CF4667DC06A1@cs.otago.ac.nz>
	<20080515090036.GB613@erix.ericsson.se>
	<482C2148.3060405@gmail.com>
Message-ID: 

On 15 May 2008, at 11:40 pm, Mats Cronqvist wrote:
>  i don't know where ro'k gets his code examples from, but i for one
> have seen tons and tons of code where many patterns winds up in the  
> same
> branch.

It's not a question of where I get them but of where I *don't* get them.
Now that you've told me that you've seen "tons and tons",
please let me get them from you!

Please post some actual examples, sanitised if necessary.

This will improve the relevance/reality/usefulness of this thread
enormously.

--
"I don't want to discuss evidence." -- Richard Dawkins, in an
interview with Rupert Sheldrake.  (Fortean times 232, p55.)








From srparish@REDACTED  Fri May 16 04:59:44 2008
From: srparish@REDACTED (Scott Parish)
Date: Thu, 15 May 2008 19:59:44 -0700
Subject: [erlang-questions] proposal: pretty printing through polymorphism
Message-ID: <88fce4d0805151959g7dc1449br3380678b372961c6@mail.gmail.com>

Problem:

Right now pretty printing values shows the lowest layer data
structures. This is ugly and usually not what an end user wants/needs
to see. For instance:

1> dict:store(color, red, dict:store(size, 5, dict:new())).
{dict,2,
      16,
      16,
      8,
      80,
      48,
      {[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]},
      {{[],[],[[color|red]],[],[],[[size|5]],[],[],[],[],[],[],[],[],[],[]}}}

Solution:

The proposed solution would take advantage of the type of polymorphism
suggested in my prior email. Namely, there would be a function such as
string:pretty_print/1 which would take a derived datastructure, use
the record name to call RecordName:pretty_print/1. Things such as the
shell or io:format could then use this interface to print truely
pretty versions of derived types (if such is provided).

Side discussion:

Actually, a pretty_print would probably need to take more arguments
then just the data structure; it would probably need to be passed
information such as the width of the left margin and the wrap length.

Alternatively, instead of "pretty printing", a form could be returned
which would represent how to reproduce the data structure. This would
serve the dual purpose of being much easier for end users to read, as
well as being immediately copy/paste-able. For an example of what this
would look like, dict might return: "{dict, from_list, [[{color, red},
{size, 5}]]}" for my earlier example. io:format (and friends) of
course could then easily print this as "dict:from_list([{color, red},
{size, 5}])".

Thoughts?
sRp


From ok@REDACTED  Fri May 16 05:15:20 2008
From: ok@REDACTED (Richard A. O'Keefe)
Date: Fri, 16 May 2008 15:15:20 +1200
Subject: [erlang-questions] Side-effects in "if" guards
In-Reply-To: <6c2563b20805151442u25fd07fbw23d3e52127862c40@mail.gmail.com>
References: <482C7CAB.60903@san.rr.com>
	<6c2563b20805151439w59ac4788u548dfbd2d10069f4@mail.gmail.com>
	<6c2563b20805151442u25fd07fbw23d3e52127862c40@mail.gmail.com>
Message-ID: <6F5B5243-0805-437D-A257-D79E720F58D2@cs.otago.ac.nz>


On 16 May 2008, at 9:42 am, Edwin Fine wrote:
> I saw something like this in some Erlang code. It is possible to  
> achieve a similar effect without using "if" as follows:
>
> is_list(X) andalso string:to_lower(X) == X andalso length(X) == 5  
> and also my:no_duplicates(X) andalso do_something(X).

I respectfully suggest that it is Bad Style to put something with a side
effect in an 'andalso' or 'orelse'.  They are for evaluating conditions,
and if you put side effects, you are guaranteed to confuse people who
expect you to use them for that purpose.

	case is_list(X) andalso
	     string:to_lower(X) == X andalso
	     length(X) == 5 andalso
	     my:no_duplicates(X)
	  of true  -> do_something(X)
	   ; false -> ok
	end
is longer, but far far clearer.

--
"I don't want to discuss evidence." -- Richard Dawkins, in an
interview with Rupert Sheldrake.  (Fortean times 232, p55.)








From norton@REDACTED  Fri May 16 04:07:28 2008
From: norton@REDACTED (Joseph Wayne Norton)
Date: Fri, 16 May 2008 11:07:28 +0900
Subject: [erlang-questions] QuickCheck: Tokyo Training Session - June 4th,
	5th, 6th and 9th
Message-ID: 

A QuickCheck training session will be held in Tokyo from June 4th to June  
6th and June 9th.  QuickCheck is a software testing tool available both as  
open source and as a commercial software product.  The training will be  
given by one of the QuviQ instructors visiting from Sweden.  Please see  
the "Services" page of QuviQ's website (http://www.quviq.com) for a brief  
overview.

    QuickCheck for Erlang Users - June 4, 5, and 6
    QuickCheck Advanced - June 9

There are a few open seats for this exciting training session.  If you or  
someone that you know is interested, please send an e-mail to  
norton@REDACTED for futher information.

thanks,

- Joe N.

-- 
norton@REDACTED


From erlang-questions_efine@REDACTED  Fri May 16 08:23:13 2008
From: erlang-questions_efine@REDACTED (Edwin Fine)
Date: Fri, 16 May 2008 02:23:13 -0400
Subject: [erlang-questions] Side-effects in "if" guards
In-Reply-To: <6F5B5243-0805-437D-A257-D79E720F58D2@cs.otago.ac.nz>
References: <482C7CAB.60903@san.rr.com>
	<6c2563b20805151439w59ac4788u548dfbd2d10069f4@mail.gmail.com>
	<6c2563b20805151442u25fd07fbw23d3e52127862c40@mail.gmail.com>
	<6F5B5243-0805-437D-A257-D79E720F58D2@cs.otago.ac.nz>
Message-ID: <6c2563b20805152323n30496a2bue2a1e368d5b17239@mail.gmail.com>

Agreed... It's Bad Style. I was merely pointing out the syntactic
possibilities.

That being said, a bad programmer can screw up a program while using the
best programming language... and a good programmer can make something that
is usually Bad Style look better than the efforts of a bad programmer using
Good Style :)

On Thu, May 15, 2008 at 11:15 PM, Richard A. O'Keefe 
wrote:

>
> On 16 May 2008, at 9:42 am, Edwin Fine wrote:
>
>> I saw something like this in some Erlang code. It is possible to achieve a
>> similar effect without using "if" as follows:
>>
>> is_list(X) andalso string:to_lower(X) == X andalso length(X) == 5 and also
>> my:no_duplicates(X) andalso do_something(X).
>>
>
> I respectfully suggest that it is Bad Style to put something with a side
> effect in an 'andalso' or 'orelse'.  They are for evaluating conditions,
> and if you put side effects, you are guaranteed to confuse people who
> expect you to use them for that purpose.
>
>        case is_list(X) andalso
>             string:to_lower(X) == X andalso
>             length(X) == 5 andalso
>             my:no_duplicates(X)
>          of true  -> do_something(X)
>           ; false -> ok
>        end
> is longer, but far far clearer.
>
> --
> "I don't want to discuss evidence." -- Richard Dawkins, in an
> interview with Rupert Sheldrake.  (Fortean times 232, p55.)
>
>
>
>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From bengt.kleberg@REDACTED  Fri May 16 09:07:16 2008
From: bengt.kleberg@REDACTED (Bengt Kleberg)
Date: Fri, 16 May 2008 09:07:16 +0200
Subject: [erlang-questions] Fwd: Suggestion: New Info item
	for	process_info/2
In-Reply-To: <6c2563b20805151013g7e94b704kc1982b5dabd3d360@mail.gmail.com>
References: <6c2563b20805151012h2c045828o635d3a719955a564@mail.gmail.com>
	<6c2563b20805151013g7e94b704kc1982b5dabd3d360@mail.gmail.com>
Message-ID: <1210921636.21090.27.camel@seasc0642.dyn.rnd.as.sw.ericsson.se>

Greetings,

There is probably a reason for process_info/1 being restricted to
debugging (it might not be possible to interrupt and takes too much
time?). Adding 'all' to process_info/2 should turn it into
process_info/1 (or a super set of it) and make it as ''bad''.
What you probably want is process_info_available/0 which returns a list
of atoms.


bengt

On Thu, 2008-05-15 at 13:13 -0400, Edwin Fine wrote:
> LOL. I probably deserved that. Thanks for the replies - SOMEONE is out
> there!
> 
> Matt, the solution is workable, and I avoid pain as much as the next
> guy, but I really want to have something that will TELL me what all
> the valid process_info items are. process_info/1 only gives me SOME of
> them and is for debugging only.
> 
> Ok, then; here's a suggestion:
> 
> Erlang team, How about adding an info item of "all" for
> process_info/2? It won't break the interface, and it will allow people
> like me to "query" process_info for which items are valid.
> 
> Regards,
> Edwin Fine
> 
> On Thu, May 15, 2008 at 5:01 AM, Matthias Lang 
> wrote:
>         Edwin Fine writes:
>         
>          > I don't know if my first post just didn't make it, or got
>         ignored because I
>          > inadvertently offended someone, or perhaps it asked too
>         boring a
>          > question.
>         
>         
>         I thought "the guy's figured out a perfectly workable solution
>         but is
>         tying himself in knots to avoid using it because it doesn't
>         seem
>         painful enough." Either that, or he hasn't managed to explain
>         what he
>         really wants to do.
>         
>         Matt
>         
> 
> 
> 
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions



From bernied@REDACTED  Fri May 16 09:27:38 2008
From: bernied@REDACTED (Bernhard Damberger)
Date: Fri, 16 May 2008 00:27:38 -0700 (PDT)
Subject: [erlang-questions]  otp application organization
Message-ID: <17269040.post@talk.nabble.com>


I am trying to understand how to organize some otp based code I am thinking
of writing. I have WSDL for SOAP that has about 10 API calls which each take
a fair number of parameters and do a significant chunk of work.

What is the best way to organize this?

Do I create one gen_server per SOAP call to handle each different request?

Or do I create one gen_server for all the SOAP calls and do some sort of
dispatch internally?

What is the granularity that the gen_server should have?

In the former case it seems to me, an application then becomes a collection
of gen_servers which are all started up together?

Another question which is about Yaws. For this kind of application does it
make sense to have Yaws run the application, or to have it embedded in the
application?

Any hints or advice on the "standard" way to organize otp applications and
the granularity of various behaviors are greatly appreciated. Thanks.

_bernhard
-- 
View this message in context: http://www.nabble.com/otp-application-organization-tp17269040p17269040.html
Sent from the Erlang Questions mailing list archive at Nabble.com.



From raimo+erlang-questions@REDACTED  Fri May 16 09:35:56 2008
From: raimo+erlang-questions@REDACTED (Raimo Niskanen)
Date: Fri, 16 May 2008 09:35:56 +0200
Subject: [erlang-questions] Fwd: Suggestion: New Info item for
	process_info/2
In-Reply-To: <6c2563b20805151013g7e94b704kc1982b5dabd3d360@mail.gmail.com>
References: <6c2563b20805151012h2c045828o635d3a719955a564@mail.gmail.com>
	<6c2563b20805151013g7e94b704kc1982b5dabd3d360@mail.gmail.com>
Message-ID: <20080516073556.GA21667@erix.ericsson.se>

On Thu, May 15, 2008 at 01:13:38PM -0400, Edwin Fine wrote:
> LOL. I probably deserved that. Thanks for the replies - SOMEONE is out
> there!
> 
> Matt, the solution is workable, and I avoid pain as much as the next guy,
> but I really want to have something that will TELL me what all the valid
> process_info items are. process_info/1 only gives me SOME of them and is for
> debugging only.
> 
> Ok, then; here's a suggestion:
> 
> Erlang team, How about adding an info item of "all" for process_info/2? It
> won't break the interface, and it will allow people like me to "query"
> process_info for which items are valid.

We have thought of an 'all' item for process_info/2, but
all items includes very strange and specialized ones,
we are not proud of all of them, plus some are heavy
to produce and some give duplicate information.

Therefore we have more or less concluded that anyone
who wants all items does not want all items, just
all the ones that are interesting, and beleive me
you are not interested in getting all of the
items process_info/2 can produce, especially not
all it will be able to produce in the future.

Use your handcoded list, the chance an item will be removed
is small, but to be prepared for that you can call process_info/2
in a loop and shield it with a try .. catch block.

> 
> Regards,
> Edwin Fine
> 
> On Thu, May 15, 2008 at 5:01 AM, Matthias Lang 
> wrote:
> 
> > Edwin Fine writes:
> >
> >  > I don't know if my first post just didn't make it, or got ignored
> > because I
> >  > inadvertently offended someone, or perhaps it asked too boring a
> >  > question.
> >
> > I thought "the guy's figured out a perfectly workable solution but is
> > tying himself in knots to avoid using it because it doesn't seem
> > painful enough." Either that, or he hasn't managed to explain what he
> > really wants to do.
> >
> > Matt
> >
> >

> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions

-- 

/ Raimo Niskanen, Erlang/OTP, Ericsson AB


From kenneth.lundin@REDACTED  Fri May 16 09:37:01 2008
From: kenneth.lundin@REDACTED (Kenneth Lundin)
Date: Fri, 16 May 2008 09:37:01 +0200
Subject: [erlang-questions] Fwd: Suggestion: New Info item for
	process_info/2
In-Reply-To: <1210921636.21090.27.camel@seasc0642.dyn.rnd.as.sw.ericsson.se>
References: <6c2563b20805151012h2c045828o635d3a719955a564@mail.gmail.com>
	<6c2563b20805151013g7e94b704kc1982b5dabd3d360@mail.gmail.com>
	<1210921636.21090.27.camel@seasc0642.dyn.rnd.as.sw.ericsson.se>
Message-ID: 

Hi,

I have been reading this topic without making a reply simply because I don't
understand why you want to a program fetching process_info attributes which
the program don't know the meaning of.

Another fact that has relevance is that the list of available
process_info attributes
tend to be quite stable. It is very very rare that something is
removed and it does not happen too often that an attribut is added.

It is of course easy to add a function which can return a list of
the available process_info attributes, If it is important enough and i
am not convinced at all.

/Regards Kenneth Erlang/OTP Ericsson

On 5/16/08, Bengt Kleberg  wrote:
> Greetings,
>
> There is probably a reason for process_info/1 being restricted to
> debugging (it might not be possible to interrupt and takes too much
> time?). Adding 'all' to process_info/2 should turn it into
> process_info/1 (or a super set of it) and make it as ''bad''.
> What you probably want is process_info_available/0 which returns a list
> of atoms.
>
>
> bengt
>
> On Thu, 2008-05-15 at 13:13 -0400, Edwin Fine wrote:
> > LOL. I probably deserved that. Thanks for the replies - SOMEONE is out
> > there!
> >
> > Matt, the solution is workable, and I avoid pain as much as the next
> > guy, but I really want to have something that will TELL me what all
> > the valid process_info items are. process_info/1 only gives me SOME of
> > them and is for debugging only.
> >
> > Ok, then; here's a suggestion:
> >
> > Erlang team, How about adding an info item of "all" for
> > process_info/2? It won't break the interface, and it will allow people
> > like me to "query" process_info for which items are valid.
> >
> > Regards,
> > Edwin Fine
> >
> > On Thu, May 15, 2008 at 5:01 AM, Matthias Lang 
> > wrote:
> >         Edwin Fine writes:
> >
> >          > I don't know if my first post just didn't make it, or got
> >         ignored because I
> >          > inadvertently offended someone, or perhaps it asked too
> >         boring a
> >          > question.
> >
> >
> >         I thought "the guy's figured out a perfectly workable solution
> >         but is
> >         tying himself in knots to avoid using it because it doesn't
> >         seem
> >         painful enough." Either that, or he hasn't managed to explain
> >         what he
> >         really wants to do.
> >
> >         Matt
> >
> >
> >
> >
> > _______________________________________________
> > erlang-questions mailing list
> > erlang-questions@REDACTED
> > http://www.erlang.org/mailman/listinfo/erlang-questions
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>


From raimo+erlang-questions@REDACTED  Fri May 16 09:47:32 2008
From: raimo+erlang-questions@REDACTED (Raimo Niskanen)
Date: Fri, 16 May 2008 09:47:32 +0200
Subject: [erlang-questions] :  EEP 10
In-Reply-To: <1210858830.6462.137.camel@localhost>
References: <20080515085500.GA613@erix.ericsson.se>
	<1210858830.6462.137.camel@localhost>
Message-ID: <20080516074732.GB21667@erix.ericsson.se>

On Thu, May 15, 2008 at 08:40:30AM -0500, Paul Fisher wrote:
> On Thu, 2008-05-15 at 10:55 +0200, Raimo Niskanen wrote:
> > EEP 10: Representing Unicode characters in Erlang
> > has been recognized by the EEP editor(s).
> > 
> > http://www.erlang.org/eeps/eep-0010.html
> 
> Bravo!  Some comments:
> 
> 1) "Formatting function section
> In general, why the choice of ~ts for unicode string format specifier?
> All others are single character and ~u is available, so ...

Because ~u is used for io:fread for unsigned int, and we prefer
to have the same "meaning" for both fread and fwrite.

Furthermore the t modifier may be needed for fread ~a and ~c
and fwrite ~p and ~P.

> 
> 
> 2) "Formatting functions" section
> Is this really what was intended?
> 
> "9> io:format(Terminal,"~s",["sm?rg?s"]).
> 
> - would convert the string "sm?rg?s" (Swedish word for sandwich) to
> UTF-8 before sending it to the terminal, ..."
> 
> I would have expected this to send the literal 0..255 latin1 characters
> to the terminal rather than converting to utf-8, Behaving exactly as
> file driver. Conversely, if ~s does not behave in this way, how would
> you get the direct latin1 characters to the terminal? ???
> 
> ???Is it the intent to have the terminal driver simply deal with utf-8,
> converting (possibly) back to latin1 if the locale is not set to utf-8?
> The section goes on to talk about io:read and terminal device driver,
> saying "input should always be expected to be in UTF-8", which does seem
> to indicate that this was the thinking.

Yes. A terminal driver will speak UTF-8 with Erlang. Period.
The terminal driver is responsible for conversion to Latin-1.

> 
> 
> 3) I vote to support utf-16 in the binary support, might as well be
> complete from the start.  The only issue is whether things like reading
> files would automatically deal with the byte-order-mark used in
> (some/most all) utf-16 docs.  Just something else to consider.

Yes. UTF-8 and UTF-16. No timeplan. We will have to think about
the byte-order mark.

> 
> 
> -- 
> paul
> 
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions

-- 

/ Raimo Niskanen, Erlang/OTP, Ericsson AB


From adam@REDACTED  Fri May 16 10:31:43 2008
From: adam@REDACTED (Adam Lindberg)
Date: Fri, 16 May 2008 10:31:43 +0200
Subject: [erlang-questions] otp application organization
In-Reply-To: <17269040.post@talk.nabble.com>
References: <17269040.post@talk.nabble.com>
Message-ID: <6344005f0805160131q266cbb2cgfea6b63e0ddcf134@mail.gmail.com>

Hi Bernhard!

First of all, think about what you want to do. If we're talking about
decoding, the code should be run in the calling process, I suppose in your
case the Yaws processes (for each request), so that it's not bottlenecked in
a gen_server somewhere when it's not needed to.

If you're taking care of requests coming from a web server, they're run in
the request process in the beginning. Try to keep them there as long as
possible. Only route them to a common gen_server if they are dependent on
each other and the state of the gen_server.



Example 1: You have a booking system that enables you to book a meeting room
for example. In this case, there should be a gen_server (or any process, for
that matter) that takes care of all requests for a resource (e.g. a room)
that can be raced to or used simultaneously.

Example 2: You have a calendar system in which users can edit and view their
personal calendars. In this case, there should be a process for each users
calendar, and not for each request, since the users calendar is the resource
that is being used and can be raced to.

Example 3: You have a math server which performs calculations based on
independent input data. In this case, why not go for the web server process
all the way, since no central resource is being modeled in the system.



As for OTP applications, the common case is that an application owns a top
level supervisor, which starts any sub-processes (either at application
startup or dynamically when needed). Then everything is handled behind the
scenes when you call application:start(my_app).

So let's say we have the room booking system, here you would read which
rooms are available at startup, create a process for each room when you
start the application. Also if rooms are added at runtime, you can start
another process for them. Or remove, if a rooms is deleted. The application
supervisor is always started at application start and is always available so
that you can add and remove subprocesses.

If you're having a system which has these "semi-static" processes (based on
configuration) and also other dynamic process (e.g. created for off-loading
certain processing tasks) it could probably make sense to have one
supervisor for each type of process (look into the simple_one_for_one
supervisor pattern when creating small dynamic processes that perform a
small task and then die).



As for Yaws, it depends on how the rest of your systems looks. If you share
the node with many other applications that access Yaws too, make Yaws
standalone. If you have this and only this application using Yaws, why not
embed it? Another application could embed another Yaws on another port
should that be necessary and you can later rip out Yaws and make it
standalone when that is needed.



Hope this helps you!

Cheers!
Adam
--
Adam Lindberg
http://www.erlang-consulting.com

On Fri, May 16, 2008 at 9:27 AM, Bernhard Damberger 
wrote:

>
> I am trying to understand how to organize some otp based code I am thinking
> of writing. I have WSDL for SOAP that has about 10 API calls which each
> take
> a fair number of parameters and do a significant chunk of work.
>
> What is the best way to organize this?
>
> Do I create one gen_server per SOAP call to handle each different request?
>
> Or do I create one gen_server for all the SOAP calls and do some sort of
> dispatch internally?
>
> What is the granularity that the gen_server should have?
>
> In the former case it seems to me, an application then becomes a collection
> of gen_servers which are all started up together?
>
> Another question which is about Yaws. For this kind of application does it
> make sense to have Yaws run the application, or to have it embedded in the
> application?
>
> Any hints or advice on the "standard" way to organize otp applications and
> the granularity of various behaviors are greatly appreciated. Thanks.
>
> _bernhard
> --
> View this message in context:
> http://www.nabble.com/otp-application-organization-tp17269040p17269040.html
> Sent from the Erlang Questions mailing list archive at Nabble.com.
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From bekesa@REDACTED  Fri May 16 11:10:51 2008
From: bekesa@REDACTED (Andras Georgy Bekes)
Date: Fri, 16 May 2008 11:10:51 +0200
Subject: [erlang-questions] eep: multiple patterns
In-Reply-To: <5D916667-D9C8-43C4-A1E6-916653C9CB00@cs.otago.ac.nz>
References: <200805141620.19559.bekesa@sch.bme.hu>
	<200805151307.18370.bekesa@sch.bme.hu>
	<5D916667-D9C8-43C4-A1E6-916653C9CB00@cs.otago.ac.nz>
Message-ID: <200805161110.51758.bekesa@sch.bme.hu>

Hi,

I am trying to end this discussion with some usable result.

First let me state that
- I am now convinced that ~= is not a good idea, therefore I am not 
going to submit it in an eep.
- I am convinced that multiple patterns is a good idea (many of you 
stated that you like it). I am about to send it as an eep, we just have 
to agree on the right notation.

> Yes, but Virding's proposal uses ";" for the *SAME* meaning
> ("or") that it normally has.

My problem with ; is that it's ambiguous.
I can write at least one pattern that could be parsed into two different 
ASTs.

   Pattern when Guard; true ->
now is this a single pattern: Pattern when (Guard; true) ?
or is it multiple patterns: (Pattern when Guard); true ?

Both of them are syntactically correct and meaningful as well.
You can convince me that this is no problem, the new use of ; will not 
introduce any confusion, but I am aware.

I think using a new operator is better. 

> that "|" is already a very important symbol in Erlang with about
> as different a meaning
I think "|" in this context is not confusable with [_|_], but maybe yes. 
Can anyone suggest another operator?



Now I'll answer to a few other thoughts. I am trying to reply to only 
those where I hope my answer might take Erlang forward.

> The multiple pattern proposal makes patterns even MORE complicated,
> without naming them, so a human being reading one has to do an
> immense amount of decoding to figure out what the pattern *means*.
> If there are several places where you need (basically) the same
> complex pattern, too bad: you have to write the thing out in full
> each time because you can't NAME it and use it more than once.
> This is a disaster for maintenance, because it is far too easy to
> change *some* of the occurrences of the pattern and not others.
I have seen pieces of code when multiple patterns (as in my proposal) 
could have been used, but have not seen a single case when the same 
multiple pattern occured in several places.

> Abstract patterns let you name patterns (simple, complex, or already
> in the first proposal, MULTIPLE) and use them whenever you want.
I think the use of abstract patterns for what I suggest multiple 
patterns for leads to lengthy extra code that is unnecessary.
However, abstract patterns are great for other uses, but not for this 
very simple thing.

> > You can't negate it!
> Who says?  According to the current on-line Erlang reference
> manual, you can't negate *anything* in a guard,
>From the Reference Manual: "The set of valid guard expressions...
... arithmetic expressions...".

Example:
1> case a of X when not is_pid(X) -> not_pid end.
not_pid

>   - allowing = in guards is *always* more powerful than adding ~=
>   - there is no reason why = in a guard cannot be negated,
>     if there is anything in a guard that can be negated.
I agree. If you can negate it, it is clearly better than what I 
suggested with ~=. What would be the syntax and semantics?

It would stink because of the same problem of not binding variables (if 
negated)!

> I also repeat what I've been saying all along, which is that
> the abstract pattern proposal has been around for a long time, and
> keeps on turning out to be just right for new problems.
OK, as I said before, I am convinced that your abstract patterns are 
great, but when will the eep be ready?

	Georgy


From mats.cronqvist@REDACTED  Fri May 16 11:39:19 2008
From: mats.cronqvist@REDACTED (Mats Cronqvist)
Date: Fri, 16 May 2008 11:39:19 +0200
Subject: [erlang-questions] eep: multiple patterns
In-Reply-To: <200805161110.51758.bekesa@sch.bme.hu>
References: <200805141620.19559.bekesa@sch.bme.hu>	<200805151307.18370.bekesa@sch.bme.hu>	<5D916667-D9C8-43C4-A1E6-916653C9CB00@cs.otago.ac.nz>
	<200805161110.51758.bekesa@sch.bme.hu>
Message-ID: <482D5647.1030109@gmail.com>

Andras Georgy Bekes wrote:
> Hi,
>
> I am trying to end this discussion with some usable result.
>
> First let me state that
> - I am now convinced that ~= is not a good idea, therefore I am not 
> going to submit it in an eep.
> - I am convinced that multiple patterns is a good idea (many of you 
> stated that you like it). I am about to send it as an eep, we just have 
> to agree on the right notation.
>
>   
>> Yes, but Virding's proposal uses ";" for the *SAME* meaning
>> ("or") that it normally has.
>>     
>
> My problem with ; is that it's ambiguous.
> I can write at least one pattern that could be parsed into two different 
> ASTs.
>
>    Pattern when Guard; true ->
> now is this a single pattern: Pattern when (Guard; true) ?
> or is it multiple patterns: (Pattern when Guard); true ?
 i was reading virding's proposal as;

case bla of
  Pat when true ->;
  Pat when false->;
  Pat ->
    code()
end.

  but that's not what he wrote... 

  in that case i propose the above. currently gives syntax error.

  mats



From jay@REDACTED  Fri May 16 14:46:34 2008
From: jay@REDACTED (Jay Nelson)
Date: Fri, 16 May 2008 05:46:34 -0700
Subject: [erlang-questions] [clarify] Selective export
Message-ID: <746350A2-CEC2-4DC3-9E68-0B4F753C5A0F@duomark.com>

There was discussion of having functions exported only to specific  
modules so that their use could be restricted.  I don't see anything  
in the R12B-2 manual about this.  Has it made it to the language  
yet?  If not, is there a target release for this feature?

jay



From jay@REDACTED  Fri May 16 14:54:49 2008
From: jay@REDACTED (Jay Nelson)
Date: Fri, 16 May 2008 05:54:49 -0700
Subject: [erlang-questions] [clarify] Disjoint when clause
Message-ID: 

I would like to do the following:

f(A,B,C) when is_integer(A), is_integer(B), (C =:= foo; C =:= bar) ->
  do_stuff(A,B,C).

Of course, the parens aren't allowed.  Are there any better choices  
than:

f(A,B,C) when is_integer(A), is_integer(B), C =:= foo;
         is_integer(A), is_integer(B), C =:= bar ->
   do_stuff(A,B,C).

-or-

f(A,B,C) when is_integer(A), is_integer(B), C =:= foo ->
   do_stuff(A,B,C);
f(A,B,C) when is_integer(A), is_integer(B), C =:= bar ->
   do_stuff(A,B,C).


Or (what I am currently using):

f(A,B,C) when is_integer(A), is_integer(B) ->
   f_auth(A,B,C).

f_auth(A,B,C) when C =:= foo; C =:= bar ->
   do_stuff(A,B,C).


jay



From andreas.hillqvist@REDACTED  Fri May 16 15:04:30 2008
From: andreas.hillqvist@REDACTED (Andreas Hillqvist)
Date: Fri, 16 May 2008 15:04:30 +0200
Subject: [erlang-questions] [clarify] Disjoint when clause
In-Reply-To: 
References: 
Message-ID: <8268eea30805160604k78738498l6970f95fcb20d451@mail.gmail.com>

I have not tested. But shouldent it work to write it like:
    f(A,B,C) when is_integer(A), is_integer(B), (C =:= foo orelse C =:= bar) ->
        do_stuff(A,B,C).


Kind regards
Andreas Hillqvist

2008/5/16, Jay Nelson :
> I would like to do the following:
>
> f(A,B,C) when is_integer(A), is_integer(B), (C =:= foo; C =:= bar) ->
>  do_stuff(A,B,C).
>
> Of course, the parens aren't allowed.  Are there any better choices
> than:
>
> f(A,B,C) when is_integer(A), is_integer(B), C =:= foo;
>         is_integer(A), is_integer(B), C =:= bar ->
>   do_stuff(A,B,C).
>
> -or-
>
> f(A,B,C) when is_integer(A), is_integer(B), C =:= foo ->
>   do_stuff(A,B,C);
> f(A,B,C) when is_integer(A), is_integer(B), C =:= bar ->
>   do_stuff(A,B,C).
>
>
> Or (what I am currently using):
>
> f(A,B,C) when is_integer(A), is_integer(B) ->
>   f_auth(A,B,C).
>
> f_auth(A,B,C) when C =:= foo; C =:= bar ->
>   do_stuff(A,B,C).
>
>
> jay
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>


From jay@REDACTED  Fri May 16 15:17:03 2008
From: jay@REDACTED (Jay Nelson)
Date: Fri, 16 May 2008 06:17:03 -0700
Subject: [erlang-questions] [patch] Suggested improvement to supervisor.erl
Message-ID: <3ECF713D-96ED-43BD-BADE-F774E740EFE7@duomark.com>

I have heard others in the past complain about a simple_one_for_one  
supervisor which launches thousands of children.  When a node becomes  
sluggish (typically running out of memory or too many processes), it  
may be useful to look at the supervisors to find the culprit of the  
excessive demand.  The problem is that which_children/1 will generate  
a list of all the children, thus exacerbating the low resource issue.

I recently came across a situation where I wanted to have a count of  
the number of children, but didn't want to use additional memory in  
determining the number of processes.  My solution was a function  
count_children/1 which returns a property list of counts by  
traversing the existing supervisor children list without copying it.   
The resulting property list has the form:

[{specs, integer()}, {active, integer()}, {supervisors, integer()},  
{workers, integer()}]

In code, the results should of course be treated as a real property  
list, rather than relying on the order of attributes specified  
above.  Specs counts the number of child specifications present,  
active is the number of live child processes, supervisors is the  
number of supervisor processes and workers is the number of child  
processes including those that are no longer alive but have not been  
removed from the supervisor's list.

jay
--------------

Below is a patch that adds count_children/1:

--- stdlib/src/supervisor.erl.orig      2008-04-20 23:09:48.000000000  
-0700
+++ stdlib/src/supervisor.erl   2008-04-20 23:19:27.000000000 -0700
@@ -23,7 +23,7 @@
  -export([start_link/2,start_link/3,
          start_child/2, restart_child/2,
          delete_child/2, terminate_child/2,
-        which_children/1,
+        which_children/1, count_children/1,
          check_childspecs/1]).

  -export([behaviour_info/1]).
@@ -94,6 +94,9 @@
  which_children(Supervisor) ->
      call(Supervisor, which_children).

+count_children(Supervisor) ->
+    call(Supervisor, count_children).
+
  call(Supervisor, Req) ->
      gen_server:call(Supervisor, Req, infinity).

@@ -296,7 +299,49 @@
                     {Name, Pid, ChildType, Mods}
                   end,
                   State#state.children),
-    {reply, Resp, State}.
+    {reply, Resp, State};
+
+handle_call(count_children, _From, State) when ?is_simple(State) ->
+    [#child{child_type = CT}] = State#state.children,
+    {Active, Count} =
+       ?DICT:fold(fun(Pid, _Val, {Alive, Tot}) ->
+                          if is_pid(Pid) -> {Alive+1, Tot +1};
+                             true -> {Alive, Tot + 1} end
+                  end, {0, 0}, State#state.dynamics),
+    Reply = case CT of
+               supervisor -> [{specs, 1}, {active, Active},
+                              {supervisors, Count}, {workers, 0}];
+               worker -> [{specs, 1}, {active, Active},
+                          {supervisors, 0}, {workers, Count}]
+           end,
+    {reply, Reply, State};
+
+handle_call(count_children, _From, State) ->
+
+    %% Specs and children are together on the children list...
+    [Specs, Active, Supers, Workers] =
+       lists:foldl(fun(Child, Counts) ->
+                          count_child(Child, Counts)
+                  end, [0,0,0,0], State#state.children),
+
+    %% Reformat counts to a property list.
+    Reply = [{specs, Specs}, {active, Active},
+            {supervisors, Supers}, {workers, Workers}],
+    {reply, Reply, State}.
+
+
+count_child(#child{pid = Pid, child_type = worker},
+           [Specs, Active, Supers, Workers]) ->
+    case is_pid(Pid) andalso is_process_alive(Pid) of
+       true ->  [Specs+1, Active+1, Supers, Workers+1];
+       false -> [Specs+1, Active, Supers, Workers+1]
+    end;
+count_child(#child{pid = Pid, child_type = supervisor},
+           [Specs, Active, Supers, Workers]) ->
+    case is_pid(Pid) andalso is_process_alive(Pid) of
+       true ->  [Specs+1, Active+1, Supers+1, Workers];
+       false -> [Specs+1, Active, Supers+1, Workers]
+    end.




From jay@REDACTED  Fri May 16 15:24:45 2008
From: jay@REDACTED (Jay Nelson)
Date: Fri, 16 May 2008 06:24:45 -0700
Subject: [erlang-questions] [patch] Suggestion for enhancement to sasl_report
Message-ID: <74D0BC8E-02E5-4E90-8DEA-C9F370192384@duomark.com>

I recently tried to replace sasl_report with my own handler, but I  
decided I would like to retain the sasl error formatting.  Much to my  
chagrin I discovered that there is a call to io:format deep below  
write_report/3.

Below is a patch that is backwards compatible.  It adds a new  
function format_report/3 that is identical to write_report/3,  
however, it uses io_lib:format rather than io:format.  This is  
accomplished by adding an internal function write_report_action/4  
which calls either io_lib or io depending on the requested feature.   
Presumably this should be as fast as before because I explicitly set  
the module name and only add an extra function call (which hopefully  
inlines).

jay

-------------------

--- sasl/src/sasl_report.erl.orig       2008-04-20 22:48:50.000000000  
-0700
+++ sasl/src/sasl_report.erl    2008-04-23 08:20:20.000000000 -0700
@@ -17,23 +17,29 @@
  %%
  -module(sasl_report).

--export([write_report/3]).
+-export([write_report/3, format_report/3]).

-write_report(Fd, What, {Time, {error_report, _GL, {Pid, Type,  
Report}}}) ->
+format_report(Fd, What, Report) ->
+    io_report(io_lib, Fd, What, Report).
+
+write_report(Fd, What, Report) ->
+    io_report(io, Fd, What, Report).
+
+io_report(IO, Fd, What, {Time, {error_report, _GL, {Pid, Type,  
Report}}}) ->
      case is_my_error_report(What, Type) of
         true ->
             Head = write_head(Type, Time, Pid),
-           write_report2(Fd, Head, Type, Report);
+           write_report2(IO, Fd, Head, Type, Report);
         _ -> true
      end;
-write_report(Fd, What, {Time, {info_report, _GL, {Pid, Type,  
Report}}}) ->
+io_report(IO, Fd, What, {Time, {info_report, _GL, {Pid, Type,  
Report}}}) ->
      case is_my_info_report(What, Type) of
         true ->
             Head = write_head(Type, Time, Pid),
-           write_report2(Fd, Head, Type, Report);
+           write_report2(IO, Fd, Head, Type, Report);
         _ -> true
      end;
-write_report(_Fd, _, _) ->
+io_report(_IO, _Fd, _, _) ->
      false.

  is_my_error_report(all, Type)   ->  is_my_error_report(Type);
@@ -49,20 +55,26 @@
  is_my_info_report(progress)  -> true;
  is_my_info_report(_)                    -> false.

-write_report2(Fd, Head, supervisor_report, Report) ->
+write_report2(IO, Fd, Head, supervisor_report, Report) ->
      Name = sup_get(supervisor, Report),
      Context = sup_get(errorContext, Report),
      Reason = sup_get(reason, Report),
      Offender = sup_get(offender, Report),
-    io:format(Fd, Head ++ "     Supervisor: ~p~n     Context:     
~p~n     Reason:     "
-             "~80.18p~n     Offender:   ~80.18p~n~n",
-             [Name,Context,Reason,Offender]);
-write_report2(Fd, Head, progress, Report) ->
+    FmtString = "     Supervisor: ~p~n     Context:    ~p~n      
Reason:     "
+       "~80.18p~n     Offender:   ~80.18p~n~n",
+    write_report_action(IO, Fd, Head ++ FmtString,
+                       [Name,Context,Reason,Offender]);
+write_report2(IO, Fd, Head, progress, Report) ->
      Format = format_key_val(Report),
-    io:format(Fd, Head ++ "~s", [Format]);
-write_report2(Fd, Head, crash_report, Report) ->
+    write_report_action(IO, Fd, Head ++ "~s", [Format]);
+write_report2(IO, Fd, Head, crash_report, Report) ->
      Format = proc_lib:format(Report),
-    io:format(Fd, Head ++ "~s", [Format]).
+    write_report_action(IO, Fd, Head ++ "~s", [Format]).
+
+write_report_action(io, Fd, Format, Args) ->
+    io:format(Fd, Format, Args);
+write_report_action(io_lib, _Fd, Format, Args) ->
+    io_lib:format(Format, Args).

  format_key_val([{Tag,Data}|Rep]) ->
      io_lib:format("    ~16w: ~p~n",[Tag,Data]) ++ format_key_val(Rep);




From shamcs83@REDACTED  Fri May 16 15:38:08 2008
From: shamcs83@REDACTED (sham)
Date: Fri, 16 May 2008 06:38:08 -0700 (PDT)
Subject: [erlang-questions]  One sample program want to know how it works
Message-ID: <17274934.post@talk.nabble.com>


-module(xXx).
-export([x/1]).

-define(x,x(.
-define(Xx,X.
-define(X,X)
->. ?x?X?Xx.
This is the program.I want to know how it works.
Please anyone help me.

Thanks&Regards
Sham.M
-- 
View this message in context: http://www.nabble.com/One-sample-program-want-to-know-how-it-works-tp17274934p17274934.html
Sent from the Erlang Questions mailing list archive at Nabble.com.



From luna@REDACTED  Fri May 16 16:25:38 2008
From: luna@REDACTED (Daniel Luna)
Date: Fri, 16 May 2008 16:25:38 +0200 (CEST)
Subject: [erlang-questions] One sample program want to know how it works
In-Reply-To: <17274934.post@talk.nabble.com>
References: <17274934.post@talk.nabble.com>
Message-ID: 

On Fri, 16 May 2008, sham wrote:
> -module(xXx).
> -export([x/1]).
>
> -define(x,x(.
> -define(Xx,X.
> -define(X,X)
> ->. ?x?X?Xx.
> This is the program.I want to know how it works.
> Please anyone help me.

Quite simple really... :-)

It's good to know that macro defines end in a . and that the 
endparenthesis is optional.

/Luna
-- 
Daniel Luna                           | Top reasons that I have a beard:
luna@REDACTED                     |  a) Laziness.
http://www.update.uu.se/~luna/        |  b) I can.
Don't look at my homepage (it stinks).|  c) I can get away with it.


From per.melin@REDACTED  Fri May 16 16:39:08 2008
From: per.melin@REDACTED (Per Melin)
Date: Fri, 16 May 2008 16:39:08 +0200
Subject: [erlang-questions] [clarify] Disjoint when clause
In-Reply-To: <8268eea30805160604k78738498l6970f95fcb20d451@mail.gmail.com>
References: 
	<8268eea30805160604k78738498l6970f95fcb20d451@mail.gmail.com>
Message-ID: 

2008/5/16 Andreas Hillqvist :
> I have not tested. But shouldent it work to write it like:
>    f(A,B,C) when is_integer(A), is_integer(B), (C =:= foo orelse C =:= bar) ->
>        do_stuff(A,B,C).

Comma/semicolon, andalso/orelse and and/or have different priority (in
that order), so you shouldn't need the parens.

f(A,B,C) when is_integer(A), is_integer(B), C == foo orelse C == bar ->
 do_stuff(A,B,C).

But the intent is of course communicated more clearly with the parens,
so I would keep them anyway.


From shamcs83@REDACTED  Fri May 16 16:40:05 2008
From: shamcs83@REDACTED (sham)
Date: Fri, 16 May 2008 07:40:05 -0700 (PDT)
Subject: [erlang-questions]  One sample program want to know how it works
Message-ID: <17274934.post@talk.nabble.com>


-module(xXx).
-export([x/1]).

-define(x,x(.
-define(Xx,X.
-define(X,X)
->. ?x?X?Xx.
This is the program.I want to know how it works.
Please anyone help me.

Thanks&Regards
Sham.M
-- 
View this message in context: http://www.nabble.com/One-sample-program-want-to-know-how-it-works-tp17274934p17274934.html
Sent from the Erlang Questions mailing list archive at Nabble.com.



From richardc@REDACTED  Fri May 16 16:12:04 2008
From: richardc@REDACTED (Richard Carlsson)
Date: Fri, 16 May 2008 16:12:04 +0200
Subject: [erlang-questions] One sample program want to know how it works
In-Reply-To: <17274934.post@talk.nabble.com>
References: <17274934.post@talk.nabble.com>
Message-ID: <482D9634.703@it.uu.se>

sham wrote:
> -module(xXx).
> -export([x/1]).
> 
> -define(x,x(.
> -define(Xx,X.
> -define(X,X)
> ->. ?x?X?Xx.
> This is the program.I want to know how it works.
> Please anyone help me.

Ah, Grasshopper, when you can snatch the pebble from my hand,
then it will be time for you to leave.

     /R




From adam@REDACTED  Fri May 16 17:26:35 2008
From: adam@REDACTED (Adam Lindberg)
Date: Fri, 16 May 2008 17:26:35 +0200
Subject: [erlang-questions] [clarify] ets API
Message-ID: <6344005f0805160826p362aee72sff91dd561d6d79e9@mail.gmail.com>

Hi,

What are the reasons for ets to exit with badarg when creating duplicate
tables?

How would I differ from a real badarg and a duplicate table? I guess I
can't?

Cheers!
Adam
--
Adam Lindberg
http://www.erlang-consulting.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From erlang-questions_efine@REDACTED  Fri May 16 17:44:46 2008
From: erlang-questions_efine@REDACTED (Edwin Fine)
Date: Fri, 16 May 2008 11:44:46 -0400
Subject: [erlang-questions] Fwd: Suggestion: New Info item for
	process_info/2
In-Reply-To: <20080516073556.GA21667@erix.ericsson.se>
References: <6c2563b20805151012h2c045828o635d3a719955a564@mail.gmail.com>
	<6c2563b20805151013g7e94b704kc1982b5dabd3d360@mail.gmail.com>
	<20080516073556.GA21667@erix.ericsson.se>
Message-ID: <6c2563b20805160844g5d58bbd1xece8515128a284fe@mail.gmail.com>

Raimo,

I get what you are saying; thanks for the enlightenment. Still, I think if I
had a list of available data points (and you could create the
process_info_items() call only to return the interesting ones, possibly), I
could display them to the user, who could decide, no, that one is ugly and I
won't select it for display. Isn't it better to give a choice and have
someone refuse it, that to deny it to them? I don't know. It's just a
thought.

On Fri, May 16, 2008 at 3:35 AM, Raimo Niskanen <
raimo+erlang-questions@REDACTED>
wrote:

> On Thu, May 15, 2008 at 01:13:38PM -0400, Edwin Fine wrote:
> > LOL. I probably deserved that. Thanks for the replies - SOMEONE is out
> > there!
> >
> > Matt, the solution is workable, and I avoid pain as much as the next guy,
> > but I really want to have something that will TELL me what all the valid
> > process_info items are. process_info/1 only gives me SOME of them and is
> for
> > debugging only.
> >
> > Ok, then; here's a suggestion:
> >
> > Erlang team, How about adding an info item of "all" for process_info/2?
> It
> > won't break the interface, and it will allow people like me to "query"
> > process_info for which items are valid.
>
> We have thought of an 'all' item for process_info/2, but
> all items includes very strange and specialized ones,
> we are not proud of all of them, plus some are heavy
> to produce and some give duplicate information.
>
> Therefore we have more or less concluded that anyone
> who wants all items does not want all items, just
> all the ones that are interesting, and beleive me
> you are not interested in getting all of the
> items process_info/2 can produce, especially not
> all it will be able to produce in the future.
>
> Use your handcoded list, the chance an item will be removed
> is small, but to be prepared for that you can call process_info/2
> in a loop and shield it with a try .. catch block.
>
> >
> > Regards,
> > Edwin Fine
> >
> > On Thu, May 15, 2008 at 5:01 AM, Matthias Lang 
> > wrote:
> >
> > > Edwin Fine writes:
> > >
> > >  > I don't know if my first post just didn't make it, or got ignored
> > > because I
> > >  > inadvertently offended someone, or perhaps it asked too boring a
> > >  > question.
> > >
> > > I thought "the guy's figured out a perfectly workable solution but is
> > > tying himself in knots to avoid using it because it doesn't seem
> > > painful enough." Either that, or he hasn't managed to explain what he
> > > really wants to do.
> > >
> > > Matt
> > >
> > >
>
> > _______________________________________________
> > erlang-questions mailing list
> > erlang-questions@REDACTED
> > http://www.erlang.org/mailman/listinfo/erlang-questions
>
> --
>
> / Raimo Niskanen, Erlang/OTP, Ericsson AB
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From erlang-questions_efine@REDACTED  Fri May 16 17:46:08 2008
From: erlang-questions_efine@REDACTED (Edwin Fine)
Date: Fri, 16 May 2008 11:46:08 -0400
Subject: [erlang-questions] Fwd: Suggestion: New Info item for
	process_info/2
In-Reply-To: <1210921636.21090.27.camel@seasc0642.dyn.rnd.as.sw.ericsson.se>
References: <6c2563b20805151012h2c045828o635d3a719955a564@mail.gmail.com>
	<6c2563b20805151013g7e94b704kc1982b5dabd3d360@mail.gmail.com>
	<1210921636.21090.27.camel@seasc0642.dyn.rnd.as.sw.ericsson.se>
Message-ID: <6c2563b20805160846x38771365k44c8dab156e4bfa5@mail.gmail.com>

Actually, Bengt, that is *exactly* what I would like. Great suggestion.
Ed

On Fri, May 16, 2008 at 3:07 AM, Bengt Kleberg 
wrote:

> Greetings,
>
> There is probably a reason for process_info/1 being restricted to
> debugging (it might not be possible to interrupt and takes too much
> time?). Adding 'all' to process_info/2 should turn it into
> process_info/1 (or a super set of it) and make it as ''bad''.
> What you probably want is process_info_available/0 which returns a list
> of atoms.
>
>
> bengt
>
> On Thu, 2008-05-15 at 13:13 -0400, Edwin Fine wrote:
> > LOL. I probably deserved that. Thanks for the replies - SOMEONE is out
> > there!
> >
> > Matt, the solution is workable, and I avoid pain as much as the next
> > guy, but I really want to have something that will TELL me what all
> > the valid process_info items are. process_info/1 only gives me SOME of
> > them and is for debugging only.
> >
> > Ok, then; here's a suggestion:
> >
> > Erlang team, How about adding an info item of "all" for
> > process_info/2? It won't break the interface, and it will allow people
> > like me to "query" process_info for which items are valid.
> >
> > Regards,
> > Edwin Fine
> >
> > On Thu, May 15, 2008 at 5:01 AM, Matthias Lang 
> > wrote:
> >         Edwin Fine writes:
> >
> >          > I don't know if my first post just didn't make it, or got
> >         ignored because I
> >          > inadvertently offended someone, or perhaps it asked too
> >         boring a
> >          > question.
> >
> >
> >         I thought "the guy's figured out a perfectly workable solution
> >         but is
> >         tying himself in knots to avoid using it because it doesn't
> >         seem
> >         painful enough." Either that, or he hasn't managed to explain
> >         what he
> >         really wants to do.
> >
> >         Matt
> >
> >
> >
> >
> > _______________________________________________
> > erlang-questions mailing list
> > erlang-questions@REDACTED
> > http://www.erlang.org/mailman/listinfo/erlang-questions
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From matthew@REDACTED  Fri May 16 19:01:38 2008
From: matthew@REDACTED (Matthew Dempsky)
Date: Fri, 16 May 2008 10:01:38 -0700
Subject: [erlang-questions] [clarify] ets API
In-Reply-To: <6344005f0805160826p362aee72sff91dd561d6d79e9@mail.gmail.com>
References: <6344005f0805160826p362aee72sff91dd561d6d79e9@mail.gmail.com>
Message-ID: 

2008/5/16 Adam Lindberg :
> What are the reasons for ets to exit with badarg when creating duplicate
> tables?

Duplicate named tables?  Because the name is the only way to reference
the table, and you can't specify which table you mean in future calls
if two share a name.

> How would I differ from a real badarg and a duplicate table? I guess I
> can't?

You can check a table's existence with ets:info/2.


From vsarpe@REDACTED  Fri May 16 20:25:50 2008
From: vsarpe@REDACTED (Vlad12)
Date: Fri, 16 May 2008 11:25:50 -0700 (PDT)
Subject: [erlang-questions]  File IO
Message-ID: <17281272.post@talk.nabble.com>


Hi, I am trying to create an erlang program that takes a binary trace file
and converts it into normal text.

My question is, how can i write a bunch of terms to a file. Here is how my
code looks like, but using different terms (in string representation) and
this compiles, runs, but produces an empty file. Am I missing something
important?

-module(test).
-export([write/1]).
-import(lists,[foreach/2]).

write(WriteFile) ->
   {ok, WriteDescr} = file:open(WriteFile, [raw, write]),
   Terms = ["one","two","three","four","five"],
   Writer=fun(Term) -> file:write(WriteDescr, Term) end,
   lists:foreach(Writer, Terms).

Vlad.
-- 
View this message in context: http://www.nabble.com/File-IO-tp17281272p17281272.html
Sent from the Erlang Questions mailing list archive at Nabble.com.



From gleber.p@REDACTED  Fri May 16 20:42:06 2008
From: gleber.p@REDACTED (Gleb Peregud)
Date: Fri, 16 May 2008 20:42:06 +0200
Subject: [erlang-questions] File IO
In-Reply-To: <17281272.post@talk.nabble.com>
References: <17281272.post@talk.nabble.com>
Message-ID: <14f0e3620805161142r456cc82alb63938ecb9d35cd5@mail.gmail.com>

I haven't checked it myself, but i think you sould close file when
done writing (to force erlang/OS to flush IO). Add
file:close(WriteDescr). at the end of the function

On 5/16/08, Vlad12  wrote:
>
> Hi, I am trying to create an erlang program that takes a binary trace file
> and converts it into normal text.
>
> My question is, how can i write a bunch of terms to a file. Here is how my
> code looks like, but using different terms (in string representation) and
> this compiles, runs, but produces an empty file. Am I missing something
> important?
>
> -module(test).
> -export([write/1]).
> -import(lists,[foreach/2]).
>
> write(WriteFile) ->
>    {ok, WriteDescr} = file:open(WriteFile, [raw, write]),
>    Terms = ["one","two","three","four","five"],
>    Writer=fun(Term) -> file:write(WriteDescr, Term) end,
>    lists:foreach(Writer, Terms).
>
> Vlad.
> --
> View this message in context:
> http://www.nabble.com/File-IO-tp17281272p17281272.html
> Sent from the Erlang Questions mailing list archive at Nabble.com.
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>


-- 
Gleb Peregud
http://gleber.pl/

Every minute is to be grasped.
Time waits for nobody.
-- Inscription on a Zen Gong


From matthew@REDACTED  Fri May 16 21:00:07 2008
From: matthew@REDACTED (Matthew Dempsky)
Date: Fri, 16 May 2008 12:00:07 -0700
Subject: [erlang-questions] Change in garbage collector behavior?
Message-ID: 

I tried to create a small data structure with a lot of shared
subparts, but it seems in R12B-1 and R12B-2 both lead to crashes after
doing this.  I'm guessing it's in the garbage collector, because if I
don't store the result in a variable, it runs fine, but otherwise it
crashes later on.  I was pretty sure in the past (R11B-* or so),
Erlang has gracefully handled data structures with shared subparts
within a process; has this changed "recently"?

On an Ubuntu 7.10 machine running Erlang R12B-1 (I get similar results
on OS X 10.5 with either R12B-1 or R12B-2, but a segmentation fault
instead of a crash dump):

$ erl
Erlang (BEAM) emulator version 5.6.1 [source] [64-bit] [smp:4]
[async-threads:4] [hipe] [kernel-poll:true]

Eshell V5.6.1  (abort with ^G)
1> F = fun(N) -> lists:foldl(fun(_, X) -> [X | X] end, [],
lists:seq(1, N)) end.
#Fun
2> A = F(20), ok.
ok
3> F(30), ok.
ok
4> B = F(30), ok.
ok
    %% It hangs here for a short while
Crash dump was written to: erl_crash.dump
eheap_alloc: Cannot allocate 17196648072 bytes of memory (of type "heap_frag").
Aborted


From tuncer.ayaz@REDACTED  Fri May 16 21:02:56 2008
From: tuncer.ayaz@REDACTED (Tuncer Ayaz)
Date: Fri, 16 May 2008 21:02:56 +0200
Subject: [erlang-questions] File IO
In-Reply-To: <14f0e3620805161142r456cc82alb63938ecb9d35cd5@mail.gmail.com>
References: <17281272.post@talk.nabble.com>
	<14f0e3620805161142r456cc82alb63938ecb9d35cd5@mail.gmail.com>
Message-ID: <4ac8254d0805161202w54ad6c77wab22dcd3a5345acb@mail.gmail.com>

On Fri, May 16, 2008 at 8:42 PM, Gleb Peregud  wrote:
> I haven't checked it myself, but i think you sould close file when
> done writing (to force erlang/OS to flush IO). Add
> file:close(WriteDescr). at the end of the function

Adding file:close is good but even without file:close
the file gets written, it's only delayed a bit and
the file may be locked.

Am I wrong to remember/assume that file io is done
async'ly and possibly via message passing internally?

> On 5/16/08, Vlad12  wrote:
>>
>> Hi, I am trying to create an erlang program that takes a binary trace file
>> and converts it into normal text.
>>
>> My question is, how can i write a bunch of terms to a file. Here is how my
>> code looks like, but using different terms (in string representation) and
>> this compiles, runs, but produces an empty file. Am I missing something
>> important?
>>
>> -module(test).
>> -export([write/1]).
>> -import(lists,[foreach/2]).
>>
>> write(WriteFile) ->
>>    {ok, WriteDescr} = file:open(WriteFile, [raw, write]),
>>    Terms = ["one","two","three","four","five"],
>>    Writer=fun(Term) -> file:write(WriteDescr, Term) end,
>>    lists:foreach(Writer, Terms).
>>
>> Vlad.
>> --
>> View this message in context:
>> http://www.nabble.com/File-IO-tp17281272p17281272.html
>> Sent from the Erlang Questions mailing list archive at Nabble.com.
>>
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://www.erlang.org/mailman/listinfo/erlang-questions
>>
>
>
> --
> Gleb Peregud
> http://gleber.pl/
>
> Every minute is to be grasped.
> Time waits for nobody.
> -- Inscription on a Zen Gong


From per.melin@REDACTED  Fri May 16 21:25:24 2008
From: per.melin@REDACTED (Per Melin)
Date: Fri, 16 May 2008 21:25:24 +0200
Subject: [erlang-questions] Change in garbage collector behavior?
In-Reply-To: 
References: 
Message-ID: 

2008/5/16 Matthew Dempsky :
4> B = F(30), ok.

That's over a billion lists. How much memory do you have?

I can do F(1000) on my machine if I throw away the result, and it
returns immediately. I know that my machine is neither that fast nor
has that much memory. It looks like it's smart enough to never build
the accumulator if it's not used.


From adam@REDACTED  Fri May 16 21:30:50 2008
From: adam@REDACTED (Adam Lindberg)
Date: Fri, 16 May 2008 21:30:50 +0200
Subject: [erlang-questions] [clarify] ets API
In-Reply-To: 
References: <6344005f0805160826p362aee72sff91dd561d6d79e9@mail.gmail.com>
	
Message-ID: <6344005f0805161230q77d5ec5fw6f072de1bd8edbc3@mail.gmail.com>

On Fri, May 16, 2008 at 7:01 PM, Matthew Dempsky 
wrote:

> > What are the reasons for ets to exit with badarg when creating duplicate
> > tables?
> Duplicate named tables?  Because the name is the only way to reference
> the table, and you can't specify which table you mean in future calls
> if two share a name.


Well, yes of course. Let me rephrase my question: What is the reason for ets
to exit with badarg instead of, for example, {error, duplicate_table}?



> How would I differ from a real badarg and a duplicate table? I guess I
> > can't?
>
You can check a table's existence with ets:info/2.


Which ets already does for me, except that it crashes with badarg. This is
harder to debug since you cannot differ between a bad argument (e.g.
ets:new("MyTable")) or a duplicate named table.

/Adam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From vsarpe@REDACTED  Fri May 16 21:52:55 2008
From: vsarpe@REDACTED (Vlad12)
Date: Fri, 16 May 2008 12:52:55 -0700 (PDT)
Subject: [erlang-questions] File IO
In-Reply-To: <4ac8254d0805161202w54ad6c77wab22dcd3a5345acb@mail.gmail.com>
References: <17281272.post@talk.nabble.com>
	<14f0e3620805161142r456cc82alb63938ecb9d35cd5@mail.gmail.com>
	<4ac8254d0805161202w54ad6c77wab22dcd3a5345acb@mail.gmail.com>
Message-ID: <17282943.post@talk.nabble.com>


Adding file:close(WriteDescr) did not solve the problem.

The file gets created but nothing get written. Strange



Tuncer Ayaz wrote:
> 
> On Fri, May 16, 2008 at 8:42 PM, Gleb Peregud  wrote:
>> I haven't checked it myself, but i think you sould close file when
>> done writing (to force erlang/OS to flush IO). Add
>> file:close(WriteDescr). at the end of the function
> 
> Adding file:close is good but even without file:close
> the file gets written, it's only delayed a bit and
> the file may be locked.
> 
> Am I wrong to remember/assume that file io is done
> async'ly and possibly via message passing internally?
> 
>> On 5/16/08, Vlad12  wrote:
>>>
>>> Hi, I am trying to create an erlang program that takes a binary trace
>>> file
>>> and converts it into normal text.
>>>
>>> My question is, how can i write a bunch of terms to a file. Here is how
>>> my
>>> code looks like, but using different terms (in string representation)
>>> and
>>> this compiles, runs, but produces an empty file. Am I missing something
>>> important?
>>>
>>> -module(test).
>>> -export([write/1]).
>>> -import(lists,[foreach/2]).
>>>
>>> write(WriteFile) ->
>>>    {ok, WriteDescr} = file:open(WriteFile, [raw, write]),
>>>    Terms = ["one","two","three","four","five"],
>>>    Writer=fun(Term) -> file:write(WriteDescr, Term) end,
>>>    lists:foreach(Writer, Terms).
>>>
>>> Vlad.
>>> --
>>> View this message in context:
>>> http://www.nabble.com/File-IO-tp17281272p17281272.html
>>> Sent from the Erlang Questions mailing list archive at Nabble.com.
>>>
>>> _______________________________________________
>>> erlang-questions mailing list
>>> erlang-questions@REDACTED
>>> http://www.erlang.org/mailman/listinfo/erlang-questions
>>>
>>
>>
>> --
>> Gleb Peregud
>> http://gleber.pl/
>>
>> Every minute is to be grasped.
>> Time waits for nobody.
>> -- Inscription on a Zen Gong
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
> 
> 

-- 
View this message in context: http://www.nabble.com/File-IO-tp17281272p17282943.html
Sent from the Erlang Questions mailing list archive at Nabble.com.



From stonecypher@REDACTED  Fri May 16 21:53:07 2008
From: stonecypher@REDACTED (John Haugeland)
Date: Fri, 16 May 2008 13:53:07 -0600
Subject: [erlang-questions] Design strategies for a test suite
Message-ID: <8f24f4b10805161253w1a85d67t34046d25796d9566@mail.gmail.com>

I hate having religious wars with myself.

I'm sort of torn on what I believe is the "appropriate" way to handle my new
testing suite, with regards to dealing with export clauses.  I'm not sure
how I feel about being unable to test non-exported functions.

On the one hand, it would be relatively easy to stick a macro into place to
define a stub that would get at the guts of a given module, as well as
provide an export stub for it.  Indeed, this would be a lot less of a
gutwrenching horror option if selective module access was a reality; then I
could explicitly say in my export that the newly exported stub was only
available to the testing rig, and a lot of the bile rushing into my mouth at
the thought of modifying the application's exported function list and
thereby destroying its interface sanctity would subside.

At the same time, there's a lot to be said for only testing what the module
author wants to show to the outside world.  (Granted, I'm a testing
whole-ist, and I want to get at every little detail, but still.)  The
problem is that I worry that this would encourage users of the testing kit
to expose parts of the module that they otherwise wouldn't, or to break down
their module into several smaller modules for the purposes of providing
testable interfaces.

At the same time, I find myself wondering whether such a breakdown wouldn't
be entirely inappropriate.  Indeed, I've already fallen subject to this
effect myself, and it has had some nice side-effects.

Now, in C++, my powers are great enough to use some tremendously ugly macro
magic to get through the access issue.  Unfortunately, that road is foggy at
best when your ninja skills in a given language are secure, and I'm on
pretty shaky footing in Erlang so far.  What I'm hoping is that there's some
wisdom that's already played out here, possibly for other reasons, on which
I can depend.

So, presume you're looking at a testing rig meant to have as little impact
on a given module as possible.  Right now I'm just allowing it to be blind
to a module's internals, which has allowed me to get my testing stuff down
to a single line of code in the module to be tested.  That said, this limits
my ability to test internals unless I'm willing to open new holes in my
black box for test wires.  And, frankly, I'm just not very happy with that
option.

Someone have a better idea?  I mean, if there was a way for me to just be
horrible and ignore the export inbound call limits, I'd do it in a
heartbeat, but I don't think that actually exists.

Should I just gracefully accept export([]) as a limitation?  Should I
require the use of a macro-granted magical gateway?  Is there another
option?

This would be a whole lot easier to resolve if I could limit which modules
were allowed to call a given function.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From kaczmarek.w@REDACTED  Fri May 16 21:59:52 2008
From: kaczmarek.w@REDACTED (Wojciech Kaczmarek)
Date: Fri, 16 May 2008 21:59:52 +0200
Subject: [erlang-questions] mnesia access context checking
Message-ID: <31ae10910805161259g4cd849a9m2550f5ddce4e5d7a@mail.gmail.com>

Is it possible to check in which access context is the current mnesia call
executed?

I have some mnesia operations packed in functions calling each other. What I
want to achieve is to derive access context in an inner call from an outer.
The most wanted feature is not to swich to transaction context in an inner
call when outer call was invoked as dirty. If there's no way to check mnesia
internals what's the current context, I'd need to pass an additional
parameter to my functions or use a process dictionary. Well, I'd like to
avoid such boilerplate code.

Any suggestions?

Regards
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From vsarpe@REDACTED  Fri May 16 22:06:01 2008
From: vsarpe@REDACTED (Vlad12)
Date: Fri, 16 May 2008 13:06:01 -0700 (PDT)
Subject: [erlang-questions] File IO
In-Reply-To: <17282943.post@talk.nabble.com>
References: <17281272.post@talk.nabble.com>
	<14f0e3620805161142r456cc82alb63938ecb9d35cd5@mail.gmail.com>
	<4ac8254d0805161202w54ad6c77wab22dcd3a5345acb@mail.gmail.com>
	<17282943.post@talk.nabble.com>
Message-ID: <17283194.post@talk.nabble.com>


Sorry for the confusion, it turns out that adding file:close solved the
porblem on the toy problem i used as a "test". I added file:close to my real
program and it didnt work.. then I relaized that part was never executed.

Thank you for your comments.


Vlad12 wrote:
> 
> Adding file:close(WriteDescr) did not solve the problem.
> 
> The file gets created but nothing get written. Strange
> 
> 
> 
> Tuncer Ayaz wrote:
>> 
>> On Fri, May 16, 2008 at 8:42 PM, Gleb Peregud  wrote:
>>> I haven't checked it myself, but i think you sould close file when
>>> done writing (to force erlang/OS to flush IO). Add
>>> file:close(WriteDescr). at the end of the function
>> 
>> Adding file:close is good but even without file:close
>> the file gets written, it's only delayed a bit and
>> the file may be locked.
>> 
>> Am I wrong to remember/assume that file io is done
>> async'ly and possibly via message passing internally?
>> 
>>> On 5/16/08, Vlad12  wrote:
>>>>
>>>> Hi, I am trying to create an erlang program that takes a binary trace
>>>> file
>>>> and converts it into normal text.
>>>>
>>>> My question is, how can i write a bunch of terms to a file. Here is how
>>>> my
>>>> code looks like, but using different terms (in string representation)
>>>> and
>>>> this compiles, runs, but produces an empty file. Am I missing something
>>>> important?
>>>>
>>>> -module(test).
>>>> -export([write/1]).
>>>> -import(lists,[foreach/2]).
>>>>
>>>> write(WriteFile) ->
>>>>    {ok, WriteDescr} = file:open(WriteFile, [raw, write]),
>>>>    Terms = ["one","two","three","four","five"],
>>>>    Writer=fun(Term) -> file:write(WriteDescr, Term) end,
>>>>    lists:foreach(Writer, Terms).
>>>>
>>>> Vlad.
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/File-IO-tp17281272p17281272.html
>>>> Sent from the Erlang Questions mailing list archive at Nabble.com.
>>>>
>>>> _______________________________________________
>>>> erlang-questions mailing list
>>>> erlang-questions@REDACTED
>>>> http://www.erlang.org/mailman/listinfo/erlang-questions
>>>>
>>>
>>>
>>> --
>>> Gleb Peregud
>>> http://gleber.pl/
>>>
>>> Every minute is to be grasped.
>>> Time waits for nobody.
>>> -- Inscription on a Zen Gong
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://www.erlang.org/mailman/listinfo/erlang-questions
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/File-IO-tp17281272p17283194.html
Sent from the Erlang Questions mailing list archive at Nabble.com.



From vsarpe@REDACTED  Fri May 16 22:06:31 2008
From: vsarpe@REDACTED (Vlad12)
Date: Fri, 16 May 2008 13:06:31 -0700 (PDT)
Subject: [erlang-questions] File IO
Message-ID: <17283194.post@talk.nabble.com>


Sorry for the confusion, it turns out that adding file:close solved the
porblem on the toy problem i used as a "test". I added file:close to my real
program and it didnt work.. then I relaized that part was never executed.

Thank you for your comments.


-- 
View this message in context: http://www.nabble.com/File-IO-tp17281272p17283194.html
Sent from the Erlang Questions mailing list archive at Nabble.com.



From matthew@REDACTED  Fri May 16 22:24:08 2008
From: matthew@REDACTED (Matthew Dempsky)
Date: Fri, 16 May 2008 13:24:08 -0700
Subject: [erlang-questions] Change in garbage collector behavior?
In-Reply-To: 
References: 
	
Message-ID: 

On Fri, May 16, 2008 at 12:25 PM, Per Melin  wrote:
> 2008/5/16 Matthew Dempsky :
> 4> B = F(30), ok.
>
> That's over a billion lists. How much memory do you have?

No it's not.  It's 30 cons cells.  I have plenty of memory for that.


From matthew@REDACTED  Fri May 16 22:27:58 2008
From: matthew@REDACTED (Matthew Dempsky)
Date: Fri, 16 May 2008 13:27:58 -0700
Subject: [erlang-questions] Design strategies for a test suite
In-Reply-To: <8f24f4b10805161253w1a85d67t34046d25796d9566@mail.gmail.com>
References: <8f24f4b10805161253w1a85d67t34046d25796d9566@mail.gmail.com>
Message-ID: 

2008/5/16 John Haugeland :
> This would be a whole lot easier to resolve if I could limit which modules
> were allowed to call a given function.

Document them in edoc with @private and just don't call them from other modules.


From pfisher@REDACTED  Fri May 16 22:30:23 2008
From: pfisher@REDACTED (Paul Fisher)
Date: Fri, 16 May 2008 15:30:23 -0500
Subject: [erlang-questions] Design strategies for a test suite
In-Reply-To: <8f24f4b10805161253w1a85d67t34046d25796d9566@mail.gmail.com>
References: <8f24f4b10805161253w1a85d67t34046d25796d9566@mail.gmail.com>
Message-ID: <1210969823.7327.46.camel@localhost>

On Fri, 2008-05-16 at 13:53 -0600, John Haugeland wrote:
> So, presume you're looking at a testing rig meant to have as little
> impact on a given module as possible.  Right now I'm just allowing it
> to be blind to a module's internals, which has allowed me to get my
> testing stuff down to a single line of code in the module to be
> tested.  That said, this limits my ability to test internals unless
> I'm willing to open new holes in my black box for test wires.  And,
> frankly, I'm just not very happy with that option.
> 
> Someone have a better idea?  I mean, if there was a way for me to just
> be horrible and ignore the export inbound call limits, I'd do it in a
> heartbeat, but I don't think that actually exists.
> 
> Should I just gracefully accept export([]) as a limitation?  Should I
> require the use of a macro-granted magical gateway?  Is there another
> option?

In general, I do the following at the beginning of the module:

%% API
-ifdef(NDEBUG).
-export([foo/0]).
-else.
-compile([export_all, debug_info]).
-endif.


And then at the end of the file I'll add test functions in the same way:

-ifndef(NDEBUG).

test() ->
    ok = alrules:start(),
    ok = test1(),
    ok.

test1() ->
    ok = foo()

-endif.

That way I can compile testable code with nothing and then production
code with NDEBUG defined.


-- 
paul



From per.melin@REDACTED  Fri May 16 22:36:25 2008
From: per.melin@REDACTED (Per Melin)
Date: Fri, 16 May 2008 22:36:25 +0200
Subject: [erlang-questions] mnesia access context checking
In-Reply-To: <31ae10910805161259g4cd849a9m2550f5ddce4e5d7a@mail.gmail.com>
References: <31ae10910805161259g4cd849a9m2550f5ddce4e5d7a@mail.gmail.com>
Message-ID: 

2008/5/16 Wojciech Kaczmarek :
> The most wanted feature is not to swich to transaction context in an inner
> call when outer call was invoked as dirty.

If you use normal read/write in your inner function and call it
through async_dirty/1 or sync_dirty/1, that should do what you want,
right?

>From the doc:
"Calling (nesting) a mnesia:[a]sync_dirty inside a transaction context
will inherit the transaction semantics."


From matthew@REDACTED  Fri May 16 22:41:40 2008
From: matthew@REDACTED (Matthew Dempsky)
Date: Fri, 16 May 2008 13:41:40 -0700
Subject: [erlang-questions] Change in garbage collector behavior?
In-Reply-To: 
References: 
	
	
Message-ID: 

On Fri, May 16, 2008 at 1:24 PM, Matthew Dempsky  wrote:
> No it's not.  It's 30 cons cells.  I have plenty of memory for that.

Doing some more testing, it seems this is only a problem at the shell.
 If I spawn a separate process from the shell to call F(30) and hold
onto the result, I don't have any GC issues.

Maybe the shell changed to involve multiple processes and now flattens
data structures (or maybe I'm hallucinating about being able to do
this kind of stuff at the shell before)?

Either way, my original concern is nullified.  Sorry for the noise.


From stonecypher@REDACTED  Fri May 16 22:45:27 2008
From: stonecypher@REDACTED (John Haugeland)
Date: Fri, 16 May 2008 14:45:27 -0600
Subject: [erlang-questions] Design strategies for a test suite
In-Reply-To: <8f24f4b10805161253w1a85d67t34046d25796d9566@mail.gmail.com>
References: <8f24f4b10805161253w1a85d67t34046d25796d9566@mail.gmail.com>
Message-ID: <8f24f4b10805161345n45b9a658k4387f1069b780282@mail.gmail.com>

Looks like I managed to send this to Paul privately instead of the list as
intended.  Gee, I love sucking at the internet.


> %% API
> -ifdef(NDEBUG).
> -export([foo/0]).
> -else.
> -compile([export_all, debug_info]).
> -endif.
>

I'm not really sure how I feel about the export prototype list changing on
terms of a macro define.  The thing that gives me pause is the importance of
a compile in Erlang's module system: just compiling something has some
pretty major impact on its use in a live system.  Still, it's not any worse
than the things I'd already come up with.

I'm starting to think this Selective Export thing might be what I want.  I
don't see much talk of how it's done exactly, and when I googled I got stuff
from Eiffel and Haskell.  That said, what Eiffel and Haskell have seem to be
what I want.  I went digging through the eeps looking for a discussion of
what's intended, but didn't find one.  I'm kind of a noob, here; where
should I be looking to see what's planned?

Am I right in believing we'd be seeing something like this?

-export([foo/0, foo/1]).
-export_to(some_module, [bar/0]).

That sort of thing seems extremely desirable to me.  One of the biggest
problems I'm having with Erlang right now is a way to govern display at the
code level of facilities.  I'm very much a C++ mindset person, and I'm very
much in desire of some way to seal off access to a lot of stuff that's just
sitting out exposed right now.

Selective export would allow me to do the kind of closed-access thing I'm
used to from friend declarations, and if it worked with one's own module,
it'd provide me a way to make spawnable functions internal only (something I
really, really badly want) just by naming the module in its own export
clause.

-module(protected_example).
-export_to(protected_example, [privateish_spawnable/0]).    % want badly

So, pardon me please for speaking up at what's probably late in the game,
but where can I go to read about the current mindset for selective export,
and whether it's expected as a language feature?  (It would be tremendously
useful.)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From alpar@REDACTED  Fri May 16 22:50:37 2008
From: alpar@REDACTED (=?ISO-8859-1?Q?Alp=E1r_J=FCttner?=)
Date: Fri, 16 May 2008 21:50:37 +0100
Subject: [erlang-questions] Change in garbage collector behavior?
In-Reply-To: 
References: 
Message-ID: <1210971037.4417.4.camel@piko.site>

> 4> B = F(30), ok.
> ok

For me, this 'ok' means that everything is alright with the execution of
F, and also with the assignment of its result to B.

Isn't it possible that the shell somehow wants to pass the result in a
message into another process (and therefore copy it)?

Alpar


>     %% It hangs here for a short while
> Crash dump was written to: erl_crash.dump
> eheap_alloc: Cannot allocate 17196648072 bytes of memory (of type "heap_frag").
> Aborted
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions



From vsarpe@REDACTED  Fri May 16 22:51:22 2008
From: vsarpe@REDACTED (Vlad12)
Date: Fri, 16 May 2008 13:51:22 -0700 (PDT)
Subject: [erlang-questions] File IO
In-Reply-To: <4ac8254d0805161202w54ad6c77wab22dcd3a5345acb@mail.gmail.com>
References: <17281272.post@talk.nabble.com>
	<14f0e3620805161142r456cc82alb63938ecb9d35cd5@mail.gmail.com>
	<4ac8254d0805161202w54ad6c77wab22dcd3a5345acb@mail.gmail.com>
Message-ID: <17284012.post@talk.nabble.com>


Ok by adding file:close, I can get Terms to be written into the file, but
only if they are in string format. For some reason, I cannot write any
touples into a file.

Terms = ["one", "two"]     % this gets written
Terms = [{one}, {two}]   % this does not get written
Terms = [{"one"}, {"two"}]  % this does not get written

Does anyone know how to get around this, to write touples into files?

Vlad

-- 
View this message in context: http://www.nabble.com/File-IO-tp17281272p17284012.html
Sent from the Erlang Questions mailing list archive at Nabble.com.



From richardc@REDACTED  Fri May 16 22:58:40 2008
From: richardc@REDACTED (Richard Carlsson)
Date: Fri, 16 May 2008 22:58:40 +0200
Subject: [erlang-questions] Design strategies for a test suite
In-Reply-To: <8f24f4b10805161253w1a85d67t34046d25796d9566@mail.gmail.com>
References: <8f24f4b10805161253w1a85d67t34046d25796d9566@mail.gmail.com>
Message-ID: <482DF580.3070007@it.uu.se>

John Haugeland wrote:
> Someone have a better idea?  I mean, if there was a way for me to just 
> be horrible and ignore the export inbound call limits, I'd do it in a 
> heartbeat, but I don't think that actually exists.
> 
> Should I just gracefully accept export([]) as a limitation?  Should I 
> require the use of a macro-granted magical gateway?  Is there another 
> option?

If you use eunit, you can:
  - Write internal test functions that are automatically exported
    (you don't have to write -export() declarations for them), but
    which disappear when you compile with testing disabled.
  - Put external test functions for x.erl in a module x_tests.erl
    and they will be run automatically when module x is tested.
  - Do a lot of neat stuff rather easily.

If you prefer not to use eunit, you can still use similar conventions,
and use conditional compilation to decide whether internal test
functions should be compiled and exported or be excluded completely,
while the tests for the external interface are kept in another module.
I think that's the best you can hope for.

     /Richard

-- 
  "Having users is like optimization: the wise course is to delay it."
    -- Paul Graham


From vladdu55@REDACTED  Fri May 16 23:00:39 2008
From: vladdu55@REDACTED (Vlad Dumitrescu)
Date: Fri, 16 May 2008 23:00:39 +0200
Subject: [erlang-questions] File IO
In-Reply-To: <17284012.post@talk.nabble.com>
References: <17281272.post@talk.nabble.com>
	<14f0e3620805161142r456cc82alb63938ecb9d35cd5@mail.gmail.com>
	<4ac8254d0805161202w54ad6c77wab22dcd3a5345acb@mail.gmail.com>
	<17284012.post@talk.nabble.com>
Message-ID: <95be1d3b0805161400k7abca2ban678a7ae34c012b12@mail.gmail.com>

Hi,

On Fri, May 16, 2008 at 10:51 PM, Vlad12  wrote:

> Does anyone know how to get around this, to write touples into files?
>

The docs for file:write/2 specify that the second argument is an iolist().
If you want to output a term, you will have to convert it to its printable
value with for example io_lib:format("~w", [Term]). Or instead of using
file:write/2, you can use io:format/2.

regards,
Vlad
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From matthew@REDACTED  Fri May 16 23:02:00 2008
From: matthew@REDACTED (Matthew Dempsky)
Date: Fri, 16 May 2008 14:02:00 -0700
Subject: [erlang-questions] Change in garbage collector behavior?
In-Reply-To: <1210971037.4417.4.camel@piko.site>
References: 
	<1210971037.4417.4.camel@piko.site>
Message-ID: 

On Fri, May 16, 2008 at 1:50 PM, Alp?r J?ttner  wrote:
>> 4> B = F(30), ok.
>> ok
>
> For me, this 'ok' means that everything is alright with the execution of
> F, and also with the assignment of its result to B.
>
> Isn't it possible that the shell somehow wants to pass the result in a
> message into another process (and therefore copy it)?

Yeah, this is the same conclusion/hypothesis I've tentatively come to. :-)


From per.melin@REDACTED  Fri May 16 23:02:24 2008
From: per.melin@REDACTED (Per Melin)
Date: Fri, 16 May 2008 23:02:24 +0200
Subject: [erlang-questions] Change in garbage collector behavior?
In-Reply-To: 
References: 
	
	
	
Message-ID: 

>> No it's not.  It's 30 cons cells.  I have plenty of memory for that.
> Either way, my original concern is nullified.  Sorry for the noise.

Well, at least I got to put my foot in my mouth in the process. I feel
really stupid now.

Anyway:

2> B = F(20), ok.
ok
3> erlang:memory(processes).
21964814
4> erlang:memory(processes).
42026910
5> erlang:memory(processes).
64995342
6> erlang:memory(processes).
165291926
7> erlang:memory(processes).
190358406
8> f().
ok
9> erlang:memory(processes).
190388838
10> garbage_collect().
true
11> erlang:memory(processes).
818718

There's 5-10 seconds between each call.


From per.melin@REDACTED  Fri May 16 23:05:52 2008
From: per.melin@REDACTED (Per Melin)
Date: Fri, 16 May 2008 23:05:52 +0200
Subject: [erlang-questions] File IO
In-Reply-To: <17284012.post@talk.nabble.com>
References: <17281272.post@talk.nabble.com>
	<14f0e3620805161142r456cc82alb63938ecb9d35cd5@mail.gmail.com>
	<4ac8254d0805161202w54ad6c77wab22dcd3a5345acb@mail.gmail.com>
	<17284012.post@talk.nabble.com>
Message-ID: 

2008/5/16 Vlad12 :
> Does anyone know how to get around this, to write touples into files?

term_to_binary(Term)


From stonecypher@REDACTED  Fri May 16 23:08:23 2008
From: stonecypher@REDACTED (John Haugeland)
Date: Fri, 16 May 2008 15:08:23 -0600
Subject: [erlang-questions] Design strategies for a test suite
In-Reply-To: <8f24f4b10805161402p2601d303rd520300056664b8e@mail.gmail.com>
References: <8f24f4b10805161253w1a85d67t34046d25796d9566@mail.gmail.com>
	<482DF580.3070007@it.uu.se>
	<8f24f4b10805161402p2601d303rd520300056664b8e@mail.gmail.com>
Message-ID: <8f24f4b10805161408u46c0cb3bj3e45c1327f2b889a@mail.gmail.com>

>
> If you use eunit, you can:
>  - Write internal test functions that are automatically exported
>   (you don't have to write -export() declarations for them), but
>   which disappear when you compile with testing disabled.
>

Do you happen to know how this is implemented?  I confess this actually
sounds a whole lot like the macro compile solution suggested earlier, but
I'm curious whether someone else has found a different way.






>  - Put external test functions for x.erl in a module x_tests.erl
>   and they will be run automatically when module x is tested.
>

Yeah, I've already got that running in mine.  :)






>  - Do a lot of neat stuff rather easily.
>

I'd appreciate someone else's perspective on what exactly constitutes "neat"
from the perspective of a testing suite.  The reason I'm implementing my own
is to get some functionality that I haven't found in any other erlang test
suites (with the exception of a commercial suite, but Mine Shall Be Free
(tm)).






> If you prefer not to use eunit, you can still use similar conventions,
> and use conditional compilation to decide whether internal test
> functions should be compiled and exported or be excluded completely,
> while the tests for the external interface are kept in another module.
> I think that's the best you can hope for.
>

Maybe so.  Admittedly, I'm now getting really really into the idea of
selective export, as it provides me a much better way.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From per.melin@REDACTED  Fri May 16 23:45:43 2008
From: per.melin@REDACTED (Per Melin)
Date: Fri, 16 May 2008 23:45:43 +0200
Subject: [erlang-questions] Change in garbage collector behavior?
In-Reply-To: <1210971037.4417.4.camel@piko.site>
References: 
	<1210971037.4417.4.camel@piko.site>
Message-ID: 

2008/5/16 Alp?r J?ttner :
> Isn't it possible that the shell somehow wants to pass the result in a
> message into another process (and therefore copy it)?

To work through the shame I traced the process which grows (which is
running functions in the shell module) and it does indeed receive a
message with the value of the assignment. Unless I'm shooting myself
in the foot again.

After doing: A = F(4), ok.

{trace_ts,<0.24.0>,'receive',
    {shell_rep,<0.30.0>,
        {value,ok,
            [{'A',[[[[[]],[]],[[]],[]],[[[]],[]],[[]],[]]},
             {'F',#Fun},
             {'S',<0.30.0>}],
            []}},
    {1210,973308,195294}}


From matthew@REDACTED  Fri May 16 23:49:04 2008
From: matthew@REDACTED (Matthew Dempsky)
Date: Fri, 16 May 2008 14:49:04 -0700
Subject: [erlang-questions] Change in garbage collector behavior?
In-Reply-To: 
References: 
	<1210971037.4417.4.camel@piko.site>
	
Message-ID: 

On Fri, May 16, 2008 at 2:45 PM, Per Melin  wrote:
> 2008/5/16 Alp?r J?ttner :
>> Isn't it possible that the shell somehow wants to pass the result in a
>> message into another process (and therefore copy it)?
>
> To work through the shame I traced the process which grows (which is
> running functions in the shell module) and it does indeed receive a
> message with the value of the assignment. Unless I'm shooting myself
> in the foot again.

That sounds about right.  The values need to be saved somewhere for
them to remain bound even when the current shell process exits/dies.

So your original explanation was technically correct, albeit perhaps
inadvertently so. :-)


From twoggle@REDACTED  Sat May 17 15:18:59 2008
From: twoggle@REDACTED (Tim Fletcher)
Date: Sat, 17 May 2008 06:18:59 -0700 (PDT)
Subject: [erlang-questions] [how] RSA-SHA1 signing function?
Message-ID: 

Looking at crypto:rsa_verify/3 I can't find an "opposite" function to
create a signature from some data and a private key. Does such a
function (or set of functions) exist?


From richardc@REDACTED  Sat May 17 17:30:40 2008
From: richardc@REDACTED (Richard Carlsson)
Date: Sat, 17 May 2008 17:30:40 +0200
Subject: [erlang-questions] Design strategies for a test suite
In-Reply-To: <8f24f4b10805161408u46c0cb3bj3e45c1327f2b889a@mail.gmail.com>
References: <8f24f4b10805161253w1a85d67t34046d25796d9566@mail.gmail.com>	<482DF580.3070007@it.uu.se>	<8f24f4b10805161402p2601d303rd520300056664b8e@mail.gmail.com>
	<8f24f4b10805161408u46c0cb3bj3e45c1327f2b889a@mail.gmail.com>
Message-ID: <482EFA20.1030104@it.uu.se>

John Haugeland wrote:
>     If you use eunit, you can:
>      - Write internal test functions that are automatically exported
>       (you don't have to write -export() declarations for them), but
>       which disappear when you compile with testing disabled.
> 
> Do you happen to know how this is implemented?  I confess this actually 
> sounds a whole lot like the macro compile solution suggested earlier, 
> but I'm curious whether someone else has found a different way.

It is, but with the extra twist of parse transforms that automatically
export test functions (detected based on naming conventions). You could
reuse that code if you want (it's LGPL).

> I'd appreciate someone else's perspective on what exactly constitutes 
> "neat" from the perspective of a testing suite.  The reason I'm 
> implementing my own is to get some functionality that I haven't found in 
> any other erlang test suites (with the exception of a commercial suite, 
> but Mine Shall Be Free (tm)).

Well, feel free to come with suggestions about features that I could add
to eunit (within reason - I won't try to compete with QuickCheck).

     /Richard


From twoggle@REDACTED  Sat May 17 20:48:00 2008
From: twoggle@REDACTED (Tim Fletcher)
Date: Sat, 17 May 2008 11:48:00 -0700 (PDT)
Subject: [erlang-questions] [clarify] using ssh_rsa/ssh_file
In-Reply-To: 
References: 
Message-ID: 

I've found ssh_rsa:sign/2, which looks to be exactly what I need, and
I managed to load my user key using ssh_file:private_identity_key/2.
Two follow up questions:

- How do I load a key from an arbitrary path?

- What's the status of these modules? Would I be correct to assume
they aren't (yet) meant to be used directly?


From stonecypher@REDACTED  Sat May 17 21:24:07 2008
From: stonecypher@REDACTED (John Haugeland)
Date: Sat, 17 May 2008 13:24:07 -0600
Subject: [erlang-questions] Design strategies for a test suite
In-Reply-To: <482EFA20.1030104@it.uu.se>
References: <8f24f4b10805161253w1a85d67t34046d25796d9566@mail.gmail.com>
	<482DF580.3070007@it.uu.se>
	<8f24f4b10805161402p2601d303rd520300056664b8e@mail.gmail.com>
	<8f24f4b10805161408u46c0cb3bj3e45c1327f2b889a@mail.gmail.com>
	<482EFA20.1030104@it.uu.se>
Message-ID: <8f24f4b10805171224u7d3cbfcfld55bcc096591efa5@mail.gmail.com>

> Do you happen to know how this is implemented?  I confess this actually
>> sounds a whole lot like the macro compile solution suggested earlier, but
>> I'm curious whether someone else has found a different way.
>>
>
> It is, but with the extra twist of parse transforms that automatically
> export test functions (detected based on naming conventions).


That's an interesting technique.  I've done something a lot more low-tech: I
just read through the module header with beam_lib, looking for a module
attribute called -testerl(), which indicates the test module.  Then there's
a behavior that implements the testing module interface, which gets, er,
called.  And zoom, off it goes.  I'm kind of operating in the reflection
mindset right now, so the interface provides a bunch of stuff that tells the
testing rig how the test module expects to be run under certain
circumstances, and yadda yadda yadda.  This is how you run an acceptance
test, this is how you run a detailed test, and I'm fighting the star trek
fan's urge to teach it to run a level six analysis on anything.






> You could reuse that code if you want (it's LGPL).


I appreciate the offer - it's very kind of you - but I'm an anti-GPL zealot
type (I'm all for the BSD style, and use the MIT license personally).
Besides, part of the reason I'm writing this is to come to better terms with
the problem, so taking someone else's work impedes my own growth.  Still,
thank you for the offer.

Besides, I kind of want to keep the entire tool in the raw code.  I've never
really been able to explain why, but I have a resistance to anything that
isn't done in the code.  A lot of it is about making the tool accessable to
novices, a lot of it is about making the tool easier for others to
understand, and a lot of it is about being fundamentally too lazy to figure
out what a parse transform actually is.  :D  But really, if there's a part
of this that I can do in code, I will, every time.






>
>  I'd appreciate someone else's perspective on what exactly constitutes
>> "neat" from the perspective of a testing suite.  The reason I'm implementing
>> my own is to get some functionality that I haven't found in any other erlang
>> test suites (with the exception of a commercial suite, but Mine Shall Be
>> Free (tm)).
>>
>
> Well, feel free to come with suggestions about features that I could add
> to eunit (within reason - I won't try to compete with QuickCheck).
>

Oh that's kind of what I was asking you.  And, well, I am trying to compete
with QuickCheck.  :D  I spent a while dicking around, reading people's
theses and watching crap on google video and etc, and I found a number of
techniques that I think are quite interesting and approachable for
implementation (as well as one that's quite interesting that I haven't yet
figured out how to implement, namely automatically derived models for path
coverage analysis.)

But it's good to know who my peers and betters (pardon me if I think of you
more as an arch-villian; my world is very comic book) are.

Also, you will never use your weather satellite on New Eden City, Professor
Carlsson!  I *will* stop your fiendish plan.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From stonecypher@REDACTED  Sat May 17 22:16:12 2008
From: stonecypher@REDACTED (John Haugeland)
Date: Sat, 17 May 2008 14:16:12 -0600
Subject: [erlang-questions] Design strategies for a test suite
In-Reply-To: <8f24f4b10805171224u7d3cbfcfld55bcc096591efa5@mail.gmail.com>
References: <8f24f4b10805161253w1a85d67t34046d25796d9566@mail.gmail.com>
	<482DF580.3070007@it.uu.se>
	<8f24f4b10805161402p2601d303rd520300056664b8e@mail.gmail.com>
	<8f24f4b10805161408u46c0cb3bj3e45c1327f2b889a@mail.gmail.com>
	<482EFA20.1030104@it.uu.se>
	<8f24f4b10805171224u7d3cbfcfld55bcc096591efa5@mail.gmail.com>
Message-ID: <8f24f4b10805171316s116ddcc3j64cac675183d3785@mail.gmail.com>

Actually, orbitz on freenode #erlang just gave me a tremendously interesting
new mechanism that's left me feeling quite stupid for not having thought of
it: provide a function that returns the non-exported functions as lambdas.
Yes, it's related to the "omg you're breaking export" mindset, but if you
take export to be "the things which should be usable under normal
circumstances" and declare test time to be a magical time when the laws of
common sense don't apply, then this suddenly becomes by far the least
offensive hack to this end that I've seen.

Here's a super-cheesy example which works (obviously you'd want to export
information like name and arity and whatever, but this gets the idea
across):




-module(run_lambda_export).
-export([go/0]).

go() ->

    [ F0, F1 ] = lambda_export:get_funcs(),
    io:format("~p~n~p~n", [ F0(), F1(hello) ]),
    done.







-module(lambda_export).
-export([get_funcs/0]).


internal() -> a_winner_is_yuo.

hidden(X) -> { you_sent, X }.

get_funcs() ->
  [ fun internal/0, fun hidden/1 ].
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From johan556@REDACTED  Sat May 17 23:33:30 2008
From: johan556@REDACTED (Johan Holmberg)
Date: Sat, 17 May 2008 23:33:30 +0200
Subject: [erlang-questions] rsync-like function in Erlang?
Message-ID: <351ce2d70805171433y3d179240wd0adcc3b38ac6cbd@mail.gmail.com>

Hi!

I have a number of Erlang-nodes running on different physical
machines. I want each node to have a local copy of the same directory
tree. Is there any existing Erlang-library that can do this?

The erlang nodes I use can be on either Linux or Windows.

I don't need an actual "rsync clone", just something that can make
sure two directory trees on different machines stay in sync. And I
would prefer that small changes to one of the trees were detected fast
(like in rsync(1) or unison(1)).

I realize that one solution would be to build some kind of wrapper in
Erlang around rsync(1) or unison(1) (maybe such a thing already
exist?) But I would prefer a pure Erlang solution if possible.

/Johan Holmberg


From ulf@REDACTED  Sun May 18 00:19:23 2008
From: ulf@REDACTED (Ulf Wiger)
Date: Sun, 18 May 2008 00:19:23 +0200
Subject: [erlang-questions] One sample program want to know how it works
In-Reply-To: <17274934.post@talk.nabble.com>
References: <17274934.post@talk.nabble.com>
Message-ID: <8209f740805171519m25995dfct750f379a7f1223ae@mail.gmail.com>

You can cheat and look at
http://ulf.wiger.net/weblog/2007/11/21/extending-the-erlang-shell-part-2/

were I happened to use an example just like yours. (:

BR,
Ulf W

2008/5/16 sham :
>
> -module(xXx).
> -export([x/1]).
>
> -define(x,x(.
> -define(Xx,X.
> -define(X,X)
> ->. ?x?X?Xx.
> This is the program.I want to know how it works.
> Please anyone help me.
>
> Thanks&Regards
> Sham.M
> --
> View this message in context: http://www.nabble.com/One-sample-program-want-to-know-how-it-works-tp17274934p17274934.html
> Sent from the Erlang Questions mailing list archive at Nabble.com.
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>


From igorrs@REDACTED  Sun May 18 04:06:19 2008
From: igorrs@REDACTED (Igor Ribeiro Sucupira)
Date: Sat, 17 May 2008 23:06:19 -0300
Subject: [erlang-questions] Side-effects in "if" guards
In-Reply-To: <482C7CAB.60903@san.rr.com>
References: <482C7CAB.60903@san.rr.com>
Message-ID: 

On Thu, May 15, 2008 at 3:10 PM, Darren New  wrote:
> Being a newbie to Erlang, I wonder if there's a reason for the "if"
> statement to disallow side-effects in the guards, or whether it's just a
> result of using the same language construct for "if" as for "receive".
> I.e., I understand why guards in "receive" can't have side-effects, but
> the guards in "if" don't really seem to have that same problem.
>
> I often find myself often stumbling over that fact, needing to write a
> nested-three-deep "if" or auxiliary functions to do relatively simple
> (and side-effect-free operations) simply because the tests are too
> complex (calling my own code). For example, I can't say
>
>   if X is a list, and the list is length five,
>      and there are no duplicates -> good;
>
> I have to
>   if X is a list ->
>      Y = string:tolower(X),
>      if X = Y ->
>        if X is length five ->
>          V = my:no_duplicates(X),
>            if V -> good;
>
> Rather than the more straightforward
>   if X is a list andalso string:tolower(X) = X
>     andalso len(X) = 5 andalso true = my:noduplicates(X) -> good;
>
> Is there a reason for this other than not having to define (and
> implement) two different kinds of guards?
>
> Or am I doing something suboptimal in my programming by doing this, and
> there's really a clever but unobvious-to-me way of making this work better?


In your example, I would use a case (in fact, I very rarely use ifs):

case is_list(X) andalso string:tolower(X) =:= X andalso length(X) == 5
andalso my:noduplicates(X) of
    true -> good;
    false -> bad.


Igor.

> --
>   Darren New / San Diego, CA, USA (PST)
>     "That's pretty. Where's that?"
>          "It's the Age of Channelwood."
>     "We should go there on vacation some time."
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>


From igorrs@REDACTED  Sun May 18 04:31:02 2008
From: igorrs@REDACTED (Igor Ribeiro Sucupira)
Date: Sat, 17 May 2008 23:31:02 -0300
Subject: [erlang-questions] facebook chat server
In-Reply-To: 
References: 
	<8209f740805151101u2ce8d7ddxfaef2702f662ae15@mail.gmail.com>
	
Message-ID: 

I'm too lazy to read about Thrift, so I'll ask my question here (:p):
Why is this better than using CORBA?

Thanks.
Igor.

On Thu, May 15, 2008 at 3:18 PM, Kevin A. Smith
 wrote:
> Thrift is quite interesting. It's been accepted as an Apache project
> and is currently in the project incubator. We're using it at work as
> an RPC mechanism across several different langauges (PHP, Python, and
> Java). It works quite well.
>
> --Kevin
> On May 15, 2008, at 2:01 PM, Ulf Wiger wrote:
>
>> Yes, and thrift sounds interesting too. It took me a while to find the
>> erlang-related stuff
>> in trunk/, but there is some - in
>> http://svn.facebook.com/svnroot/thrift/trunk/tutorial/erl/,
>> for example.
>>
>> BR,
>> Ulf W
>>
>> 2008/5/15 Torbjorn Tornkvist :
>>> I picked up this on the #erlang channel:
>>>
>>> http://www.facebook.com/notes.php?id=9445547199
>>>
>>>
>>> Pretty cool!
>>>
>>> --Tobbe
>>>
>>> _______________________________________________
>>> erlang-questions mailing list
>>> erlang-questions@REDACTED
>>> http://www.erlang.org/mailman/listinfo/erlang-questions
>>>
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://www.erlang.org/mailman/listinfo/erlang-questions
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>


From kevin@REDACTED  Sun May 18 05:31:43 2008
From: kevin@REDACTED (Kevin A. Smith)
Date: Sat, 17 May 2008 23:31:43 -0400
Subject: [erlang-questions] facebook chat server
In-Reply-To: 
References: 
	<8209f740805151101u2ce8d7ddxfaef2702f662ae15@mail.gmail.com>
	
	
Message-ID: 

I like Thrift because there's no ORB, the client/server model is  
actually pretty sane, and the IDL strikes the right balance between  
completeness and usefulness. I can actually read the source to Thrift  
and understand what the code is doing. The last time I did anything  
with CORBA (around the late 1990's) it was all so complicated and  
difficult to use. It seemed like "Hello, World" required a ton of  
infrastructure and 100 lines of code. IMHO SOAP is just as bad with  
all the WS-* madness and lack of interop between impls.

When I considered Thrift the only real inter-language alternatives  
were SOAP (ugh!), CORBA (double-ugh!), Thrift, or roll-your own.  
Thrift let me write the code I needed to write with minimal fuss. The  
servers have been in production for 7 months without a single crash or  
problem.

--Kevin
On May 17, 2008, at 10:31 PM, Igor Ribeiro Sucupira wrote:

> I'm too lazy to read about Thrift, so I'll ask my question here (:p):
> Why is this better than using CORBA?
>
> Thanks.
> Igor.
>
> On Thu, May 15, 2008 at 3:18 PM, Kevin A. Smith
>  wrote:
>> Thrift is quite interesting. It's been accepted as an Apache project
>> and is currently in the project incubator. We're using it at work as
>> an RPC mechanism across several different langauges (PHP, Python, and
>> Java). It works quite well.
>>
>> --Kevin
>> On May 15, 2008, at 2:01 PM, Ulf Wiger wrote:
>>
>>> Yes, and thrift sounds interesting too. It took me a while to find  
>>> the
>>> erlang-related stuff
>>> in trunk/, but there is some - in
>>> http://svn.facebook.com/svnroot/thrift/trunk/tutorial/erl/,
>>> for example.
>>>
>>> BR,
>>> Ulf W
>>>
>>> 2008/5/15 Torbjorn Tornkvist :
>>>> I picked up this on the #erlang channel:
>>>>
>>>> http://www.facebook.com/notes.php?id=9445547199
>>>>
>>>>
>>>> Pretty cool!
>>>>
>>>> --Tobbe
>>>>
>>>> _______________________________________________
>>>> erlang-questions mailing list
>>>> erlang-questions@REDACTED
>>>> http://www.erlang.org/mailman/listinfo/erlang-questions
>>>>
>>> _______________________________________________
>>> erlang-questions mailing list
>>> erlang-questions@REDACTED
>>> http://www.erlang.org/mailman/listinfo/erlang-questions
>>
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://www.erlang.org/mailman/listinfo/erlang-questions
>>



From ulf@REDACTED  Sun May 18 11:48:00 2008
From: ulf@REDACTED (Ulf Wiger)
Date: Sun, 18 May 2008 11:48:00 +0200
Subject: [erlang-questions] erlang:monitor() lag time: how long to
	expect?
In-Reply-To: <65929.1210811429@snookles.snookles.com>
References: <65929.1210811429@snookles.snookles.com>
Message-ID: <8209f740805180248i4171d0e4vad5de6fd0d417692@mail.gmail.com>

I can't say much about the delay. It seems surprisingly long,
if it isn't because the communication times out.

But using monitor on a process that hasn't been started yet
is perfectly valid, and shouldn't cause any weird effects.

BR,
Ulf W

2008/5/15 Scott Lystig Fritchie :
> Hi, I've discovered that the lag time between calling erlang:monitor()
> and receiving the {'DOWN', ...} message.  I'd like to ask how long is
> reasonable to wait?
>
> The proc I'm monitoring is on a remote node, and I'm monitoring it via
> erlang:monitor(process, {registered_name_atom(), node_atom()}).  I have
> two Erlang nodes, A & B, on two separate physical machines.  Both are
> running R11B-5 on top of Linux, "erl -kernel net_ticktime 60 ...".
>
>   1. B is quite busy doing stuff, but it's responding to
>      gen_server:call() queries within the default 5 seconds.
>
>   2. On A, I call monitor/2 for a process, my_server_proc, that hasn't
>      started yet on B.
>
>   3. 31 seconds later, B starts & registers the proc I want to monitor
>
>   4. 32 seconds later, A gets a {'DOWN', ...} message for step #2's
>      monitor.
>
> I suppose I shouldn't be monitoring a proc that hasn't been started
> yet.  ("Doctor, it hurts when ...")  And there's a work-around, I
> suppose: use rpc:call(node_B, erlang, whereis, [my_server_proc]) to
> verify that the server is actually running.
>
> Has anyone else run into seemingly long-delayed {'DOWN', ...} messages?
>
> -Scott
>
> --- snip --- snip --- snip --- snip --- snip --- snip ---
>
> node A : 20080514162806 : make_monitor 1: {my_server_proc,'test@REDACTED'} ref #Ref<0.0.0.247945>
>
> node B : 20080514162837 : progress: [{supervisor,{local,foo_foo_sup}},{started,[{pid,<0.324.0>},{name,my_server_proc},{mfa,{foo_server,start_link,...
>
> node A : 20080514162857 : gen_server:call({my_server_proc,'test@REDACTED'}, bar) returned ok
>
> node A : 20080514162909 : got 'DOWN': my_server_proc Mref #Ref<0.0.0.247945>, Type process, Object {my_server_proc,'test@REDACTED'}, Info noproc
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>


From exta7@REDACTED  Sun May 18 12:52:03 2008
From: exta7@REDACTED (Zvi)
Date: Sun, 18 May 2008 03:52:03 -0700 (PDT)
Subject: [erlang-questions] One sample program want to know how it works
In-Reply-To: <17274934.post@talk.nabble.com>
References: <17274934.post@talk.nabble.com>
Message-ID: <17301499.post@talk.nabble.com>


what's confusing here is that, as a programmer, you expect following format
for define preprocessor directive:

-define(NAME, VALUE).

Note the closing parenthesis ")" before the dot "."

For strict preprocessor implementation I would expect, this sample to fail
on sytax error. But it's not
So, probably the real format for deine (or attributes in general) is,
either:

-define(NAME, VALUE).

OR

-define(NAME, VALUE .

Then everything is works using substitution:

-define(x,x(.
-define(Xx,X.
-define(X,X)
->. ?x?X?Xx.

SUBSTITUTE:  ?x => "x("

-define(Xx,X.
-define(X,X)
->. x(?X?Xx.

SUBSTITUTE: ?X => "X)\n->"

-define(Xx,X.
x(X)
->?Xx.

SUBSTITUTE: ?Xx => X

x(X) 
-> X.


Zvi


sham wrote:
> 
> -module(xXx).
> -export([x/1]).
> 
> -define(x,x(.
> -define(Xx,X.
> -define(X,X)
> ->. ?x?X?Xx.
> This is the program.I want to know how it works.
> Please anyone help me.
> 
> Thanks&Regards
> Sham.M
> 

-- 
View this message in context: http://www.nabble.com/One-sample-program-want-to-know-how-it-works-tp17274934p17301499.html
Sent from the Erlang Questions mailing list archive at Nabble.com.



From ulf@REDACTED  Sun May 18 15:16:46 2008
From: ulf@REDACTED (Ulf Wiger)
Date: Sun, 18 May 2008 15:16:46 +0200
Subject: [erlang-questions] One sample program want to know how it works
In-Reply-To: <17301499.post@talk.nabble.com>
References: <17274934.post@talk.nabble.com> <17301499.post@talk.nabble.com>
Message-ID: <8209f740805180616m30281179we83a46827e560141@mail.gmail.com>

2008/5/18 Zvi :
>
> what's confusing here is that, as a programmer, you expect following format
> for define preprocessor directive:
>
> -define(NAME, VALUE).
>
> Note the closing parenthesis ")" before the dot "."

For the benefit of newcomers, the program being discussed /was/
the winner of the Obfuscated Erlang Competition, so as such, it is
not so surprising that it's difficult to understand - that was the very
purpose of the program.

But sure, making use of the fact that macro definitions can be
syntactically incomplete, and furthermore the fact that the closing
parenthesis is optional, is highly discouraged in all programs not
especially written for the purpose of obfuscation.  (:

BR,
Ulf W


From ft@REDACTED  Fri May 16 15:19:10 2008
From: ft@REDACTED (Fredrik Thulin)
Date: Fri, 16 May 2008 15:19:10 +0200
Subject: [erlang-questions] [clarify] Disjoint when clause
In-Reply-To: 
References: 
Message-ID: <482D89CE.7030905@it.su.se>

Jay Nelson wrote:
> I would like to do the following:
> 
> f(A,B,C) when is_integer(A), is_integer(B), (C =:= foo; C =:= bar) ->
>   do_stuff(A,B,C).

f(A,B,C) when is_integer(A), (C =:= foo orelse C =:= bar) ->
    do_stuff(A,B,C).

(unlike Anders, who were faster, I _have_ tested it ;) )

/Fredrik


From rvirding@REDACTED  Mon May 19 00:58:19 2008
From: rvirding@REDACTED (Robert Virding)
Date: Mon, 19 May 2008 00:58:19 +0200
Subject: [erlang-questions] Side-effects in "if" guards
In-Reply-To: <000001c8b6be$7257d760$891ea8c0@SSI.CORP>
References: <482C7CAB.60903@san.rr.com> <482C85A6.1020208@it.uu.se>
	<000001c8b6be$7257d760$891ea8c0@SSI.CORP>
Message-ID: <3dbc6d1c0805181558v78b53011i857611f6ce8c11b5@mail.gmail.com>

2008/5/15 David Mercer :

> > The main snag is that the rules for both syntax and semantics of
> > guards is subtly different from those of normal expressions, so
> > it's hard to extend what you can write in an if-guard in a way that
> > does not change the behaviour anywhere in all the existing code.
>
> What are the subtle differences?  I suspect most new users do not
> completely
> grok that, since this subject comes up repeatedly.


There are 2 differences between guards and normal expressions:

1. The most obvious: guards are restricted to using a subset of BIFs.
Basically those that are side-effect free. This is both easy and difficult
to understand. Easy, because you can read in the manual which ones are
allowed, difficult because it may not be obvious why only a restricted
subset is allowed.

2. The more subtle difference is handling of errors. In a "normal"
expression, even ones only using the guard subset, an error generates an
error which crashes the process if not caught in some way. In a guard,
however, no error is generated, the only result is that the guard fails and
the next if/case/receive clause is tried.

This means that the following are *NOT* equivalent:

    if  5 * X > 39 -> ... ;
        true -> ...
    end

    case 5 * X > 39 of
        true -> ... ;
        false -> ...
    end

Assume X is not a number. In the 'if' case then all that will happen is that
the if test, a guard, will fail and the second clause will be chosen as the
test in an if is a guard. In the 'case' case, however, an error will be
generated and neither case chosen.

A normal expression has two outcomes: it can succeed and return a value or
it can generate an error. A guard (expression) has 3 outcomes: it return
true (succeed), it return false (fail) or it can generate an error. BUT for
a guard generating an error results in the guard failing, i.e. it is
equivalent to it returning false.

This was done to make the testing easier and remove obvious explicit type
tests. As guards originally were just flat sequences of simple tests this
caused no real logical problem. When guards were extended to be a sequence
of guards, separated by ';', an error now caused that guard in the sequence
to fail leading to testing the next sequence. As guards were still flat
sequences of simple tests it was still easy to comprehend.

Now guards can be full boolean expressions and it is not quite so clear how
errors in guards should be handled. How far do you go up before returning
false? The actual operation which caused the error? Up to the next boolean
operator and return false to it? All the way? What is done is the same as
before, an error fails that guard in the guard sequence.

This answer became a little longer than I had anticipated but I hope things
are a little clearer now.

Robert
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From rvirding@REDACTED  Mon May 19 01:01:55 2008
From: rvirding@REDACTED (Robert Virding)
Date: Mon, 19 May 2008 01:01:55 +0200
Subject: [erlang-questions] One sample program want to know how it works
In-Reply-To: <17301499.post@talk.nabble.com>
References: <17274934.post@talk.nabble.com> <17301499.post@talk.nabble.com>
Message-ID: <3dbc6d1c0805181601y49c9a742md2106f79a7ffd6d@mail.gmail.com>

2008/5/18 Zvi :

>
> what's confusing here is that, as a programmer, you expect following format
> for define preprocessor directive:
>
> -define(NAME, VALUE).
>
> Note the closing parenthesis ")" before the dot "."
>
> For strict preprocessor implementation I would expect, this sample to fail
> on sytax error. But it's not
> So, probably the real format for deine (or attributes in general) is,
> either:
>
> -define(NAME, VALUE).
>
> OR
>
> -define(NAME, VALUE .


Yes I was a bit lazy when writing epp and did not handle that error case.
:-) I suppose someone really should fix it. But it makes for good obfuscated
code.

Robert
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From dking@REDACTED  Mon May 19 04:03:57 2008
From: dking@REDACTED (David King)
Date: Sun, 18 May 2008 19:03:57 -0700
Subject: [erlang-questions] planet.trapexit.org down?
In-Reply-To: <6344005f0805080419u7a309b7erff7a92ddcb541ff@mail.gmail.com>
References: 
	<4822BEE0.8000400@erlang-consulting.com>
	<4822CD5C.4030607@kreditor.se>
	
	<6344005f0805080419u7a309b7erff7a92ddcb541ff@mail.gmail.com>
Message-ID: <741F5E26-B4C0-43A0-BF28-3B4DB15C9F32@ketralnis.com>

>>>  SQL? wtf!
>> ftw bbq
> We've looked into migrating it to an WTF-based database server, but
> the query language is just too foul to work with...

I CAN HAZ DATAS?



From golubovsky@REDACTED  Mon May 19 06:33:53 2008
From: golubovsky@REDACTED (Dimitry Golubovsky)
Date: Mon, 19 May 2008 00:33:53 -0400
Subject: [erlang-questions] Experimental compilation of Haskell to Erlang
Message-ID: 

Hi,

Some time ago I became interested in compilation of Haskell programs
(via Yhc Core) to Erlang to be able to run Haskell code in Erlang
environment.

This experiment seems to have been successful, so I'd like to publish
its results for everyone to read and criticize.

Results of the experiment are described in this Haskell Wiki article:

http://www.haskell.org/haskellwiki/Yhc/Erlang/Proof_of_concept

Any feedback is appreciated.

Thanks.

-- 
Dimitry Golubovsky

Anywhere on the Web


From lcoquelle@REDACTED  Mon May 19 08:47:33 2008
From: lcoquelle@REDACTED (Ludovic Coquelle)
Date: Mon, 19 May 2008 14:47:33 +0800
Subject: [erlang-questions] facebook chat server
In-Reply-To: 
References: 
	<8209f740805151101u2ce8d7ddxfaef2702f662ae15@mail.gmail.com>
	
	
	
Message-ID: 

I have been using ICE a little bit, and it is also quite easy to use
(compared to CORBA). However there is no Erlang support (there is a
user-contrib for Ocaml though). ICE offer any combination of sync/async
request/respond; it also comes with few tools (efficient publish-subscribe
server, service location system ...).

Anyone could tell me diff between ICE and Thrift?
I haven't investigated Thrift enough, but it seems to be mainly a sync RPC
IDL ... I would love to be wrong on that :)

On Sun, May 18, 2008 at 11:31 AM, Kevin A. Smith 
wrote:

> I like Thrift because there's no ORB, the client/server model is
> actually pretty sane, and the IDL strikes the right balance between
> completeness and usefulness. I can actually read the source to Thrift
> and understand what the code is doing. The last time I did anything
> with CORBA (around the late 1990's) it was all so complicated and
> difficult to use. It seemed like "Hello, World" required a ton of
> infrastructure and 100 lines of code. IMHO SOAP is just as bad with
> all the WS-* madness and lack of interop between impls.
>
> When I considered Thrift the only real inter-language alternatives
> were SOAP (ugh!), CORBA (double-ugh!), Thrift, or roll-your own.
> Thrift let me write the code I needed to write with minimal fuss. The
> servers have been in production for 7 months without a single crash or
> problem.
>
> --Kevin
> On May 17, 2008, at 10:31 PM, Igor Ribeiro Sucupira wrote:
>
> > I'm too lazy to read about Thrift, so I'll ask my question here (:p):
> > Why is this better than using CORBA?
> >
> > Thanks.
> > Igor.
> >
> > On Thu, May 15, 2008 at 3:18 PM, Kevin A. Smith
> >  wrote:
> >> Thrift is quite interesting. It's been accepted as an Apache project
> >> and is currently in the project incubator. We're using it at work as
> >> an RPC mechanism across several different langauges (PHP, Python, and
> >> Java). It works quite well.
> >>
> >> --Kevin
> >> On May 15, 2008, at 2:01 PM, Ulf Wiger wrote:
> >>
> >>> Yes, and thrift sounds interesting too. It took me a while to find
> >>> the
> >>> erlang-related stuff
> >>> in trunk/, but there is some - in
> >>> http://svn.facebook.com/svnroot/thrift/trunk/tutorial/erl/,
> >>> for example.
> >>>
> >>> BR,
> >>> Ulf W
> >>>
> >>> 2008/5/15 Torbjorn Tornkvist :
> >>>> I picked up this on the #erlang channel:
> >>>>
> >>>> http://www.facebook.com/notes.php?id=9445547199
> >>>>
> >>>>
> >>>> Pretty cool!
> >>>>
> >>>> --Tobbe
> >>>>
> >>>> _______________________________________________
> >>>> erlang-questions mailing list
> >>>> erlang-questions@REDACTED
> >>>> http://www.erlang.org/mailman/listinfo/erlang-questions
> >>>>
> >>> _______________________________________________
> >>> erlang-questions mailing list
> >>> erlang-questions@REDACTED
> >>> http://www.erlang.org/mailman/listinfo/erlang-questions
> >>
> >> _______________________________________________
> >> erlang-questions mailing list
> >> erlang-questions@REDACTED
> >> http://www.erlang.org/mailman/listinfo/erlang-questions
> >>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From adam@REDACTED  Mon May 19 08:53:29 2008
From: adam@REDACTED (Adam Lindberg)
Date: Mon, 19 May 2008 08:53:29 +0200
Subject: [erlang-questions] planet.trapexit.org down?
In-Reply-To: <741F5E26-B4C0-43A0-BF28-3B4DB15C9F32@ketralnis.com>
References: 
	<4822BEE0.8000400@erlang-consulting.com>
	<4822CD5C.4030607@kreditor.se>
	
	<6344005f0805080419u7a309b7erff7a92ddcb541ff@mail.gmail.com>
	<741F5E26-B4C0-43A0-BF28-3B4DB15C9F32@ketralnis.com>
Message-ID: <6344005f0805182353u2715bd8m53318bc0bf99fec6@mail.gmail.com>

On Mon, May 19, 2008 at 4:03 AM, David King  wrote:

> >>>  SQL? wtf!
> >> ftw bbq
> > We've looked into migrating it to an WTF-based database server, but
> > the query language is just too foul to work with...
>
> I CAN HAZ DATAS?


39> lolcats:query(Server, "I CAN HAZ DATAS?").
{server_busy, "OH HAI, IM IN UR DATABASE SERVR OPTIMIZIN UR DATA, PLZ WAIT
KTHXBYE"}
40>

--
Adam Lindberg
http://www.erlang-consulting.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From ingela@REDACTED  Mon May 19 09:20:33 2008
From: ingela@REDACTED (Ingela Anderton Andin)
Date: Mon, 19 May 2008 09:20:33 +0200
Subject: [erlang-questions] erlang-questions] [clarify] using
	ssh_rsa/ssh_file
In-Reply-To: 
References: 
Message-ID: <48312A41.6090704@erix.ericsson.se>

Hi!
> I've found ssh_rsa:sign/2, which looks to be exactly what I need, and
> I managed to load my user key using ssh_file:private_identity_key/2.
> Two follow up questions:
>
> - How do I load a key from an arbitrary path?
>
> - What's the status of these modules? Would I be correct to assume
> they aren't (yet) meant to be used directly?
>
>   
You are correctly assuming that these modules are not meant to be a 
public API,
and hence are not documented.
The plan is that this code will be moved into  a new application called 
public_key
and made available as a public API. (Probably slightly remodulated).  I 
can however
not give you any time when this will be ready, I am just saying it is 
planed for a future
release.

Regards Ingela - Erlang/OTP Ericsson


From john.hughes@REDACTED  Mon May 19 09:54:48 2008
From: john.hughes@REDACTED (John Hughes)
Date: Mon, 19 May 2008 09:54:48 +0200
Subject: [erlang-questions] QuickCheck video demos
Message-ID: <001b01c8b985$9cf4ffb0$d6deff10$@hughes@quviq.com>

Just a brief announcement: we've put a couple of video demos of QuickCheck
up at quviq.com. They're about 5 minutes each. If you're interested in
watching them, you'll find them on the "Demos" tab.

 

John

-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From twoggle@REDACTED  Mon May 19 10:05:18 2008
From: twoggle@REDACTED (Tim Fletcher)
Date: Mon, 19 May 2008 01:05:18 -0700 (PDT)
Subject: [erlang-questions] erlang-questions] [clarify] using
	ssh_rsa/ssh_file
In-Reply-To: <48312A41.6090704@erix.ericsson.se>
References:  
	<48312A41.6090704@erix.ericsson.se>
Message-ID: <8052ce64-e12a-4a24-bf0a-59aa1e83116d@c58g2000hsc.googlegroups.com>

Ok, thanks for the info.


From john.hughes@REDACTED  Mon May 19 10:07:14 2008
From: john.hughes@REDACTED (John Hughes)
Date: Mon, 19 May 2008 10:07:14 +0200
Subject: [erlang-questions] Favourite editors and test tools?
Message-ID: <002c01c8b987$59c1b650$0d4522f0$@hughes@quviq.com>

I'm planning to conduct a straw poll to find out which editors and test
tools are most widely used in the Erlang community. The motivation is the
ProTest project (http://www.protest-project.eu/), which is developing Erlang
tools-it would be useful to know which environments it's most important to
integrate with, for maximum impact.

 

Don't try to vote yet! I'm planning to send another mail in a couple of
days, with links to click on to vote for your favourite editor and favourite
test tool. But the question is, which editors and test tools to include?
Right now I'm planning to include

 

Editors:

Emacs

Emacs + distel

Vi

Eclipse

 

Test tools:

EUnit

Common Test

 

If you'd like me to add another alternative to the poll, just let me know.
Rather too many than too few.

 

John

-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From bengt.kleberg@REDACTED  Mon May 19 10:37:42 2008
From: bengt.kleberg@REDACTED (Bengt Kleberg)
Date: Mon, 19 May 2008 10:37:42 +0200
Subject: [erlang-questions] Favourite editors and test tools?
In-Reply-To: <002c01c8b987$59c1b650$0d4522f0$@hughes@quviq.com>
References: <002c01c8b987$59c1b650$0d4522f0$@hughes@quviq.com>
Message-ID: <1211186262.4232.17.camel@seasc0642.dyn.rnd.as.sw.ericsson.se>

Greetings,

Would it be possible to include Other and enter a name oneself on the
vote?


bengt

On Mon, 2008-05-19 at 10:07 +0200, John Hughes wrote:
> I?m planning to conduct a straw poll to find out which editors and
> test tools are most widely used in the Erlang community. The
> motivation is the ProTest project (http://www.protest-project.eu/),
> which is developing Erlang tools?it would be useful to know which
> environments it?s most important to integrate with, for maximum
> impact.
> 
>  
> 
> Don?t try to vote yet! I?m planning to send another mail in a couple
> of days, with links to click on to vote for your favourite editor and
> favourite test tool. But the question is, which editors and test tools
> to include? Right now I?m planning to include
> 
>  
> 
> Editors:
> 
> Emacs
> 
> Emacs + distel
> 
> Vi
> 
> Eclipse
> 
>  
> 
> Test tools:
> 
> EUnit
> 
> Common Test
> 
>  
> 
> If you?d like me to add another alternative to the poll, just let me
> know. Rather too many than too few.
> 
>  
> 
> John
> 
> 
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions



From rapsey@REDACTED  Mon May 19 10:43:01 2008
From: rapsey@REDACTED (Rapsey)
Date: Mon, 19 May 2008 10:43:01 +0200
Subject: [erlang-questions] Favourite editors and test tools?
In-Reply-To: <7785930012984102501@unknownmsgid>
References: <7785930012984102501@unknownmsgid>
Message-ID: <97619b170805190143o55f05aa1v2f972af6727b63f0@mail.gmail.com>

I use TextMate.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From ulf.wiger@REDACTED  Mon May 19 10:54:39 2008
From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB))
Date: Mon, 19 May 2008 10:54:39 +0200
Subject: [erlang-questions] proposal: pretty printing through
	polymorphism
In-Reply-To: <88fce4d0805151959g7dc1449br3380678b372961c6@mail.gmail.com>
References: <88fce4d0805151959g7dc1449br3380678b372961c6@mail.gmail.com>
Message-ID: <4831404F.2040608@ericsson.com>


A while back, I hacked the Erlang shell in order to
allow custom pretty-printing:

http://ulf.wiger.net/weblog/2007/11/20/extending-the-erlang-shell-part-1/

You can find the code here:

svn co http://svn.ulf.wiger.net/ext_shell/trunk

The trunk is for R12B. See also

http://svn.ulf.wiger.net/ext_shell/branches/r11b/
http://svn.ulf.wiger.net/ext_shell/branches/r12b/

Please feel free to play around with it and propose
improvements.

BR,
Ulf W

Scott Parish skrev:
> Problem:
> 
> Right now pretty printing values shows the lowest layer data
> structures. This is ugly and usually not what an end user wants/needs
> to see. For instance:
> 
> 1> dict:store(color, red, dict:store(size, 5, dict:new())).
> {dict,2,
>       16,
>       16,
>       8,
>       80,
>       48,
>       {[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]},
>       {{[],[],[[color|red]],[],[],[[size|5]],[],[],[],[],[],[],[],[],[],[]}}}
> 
> Solution:
> 
> The proposed solution would take advantage of the type of polymorphism
> suggested in my prior email. Namely, there would be a function such as
> string:pretty_print/1 which would take a derived datastructure, use
> the record name to call RecordName:pretty_print/1. Things such as the
> shell or io:format could then use this interface to print truely
> pretty versions of derived types (if such is provided).
> 
> Side discussion:
> 
> Actually, a pretty_print would probably need to take more arguments
> then just the data structure; it would probably need to be passed
> information such as the width of the left margin and the wrap length.
> 
> Alternatively, instead of "pretty printing", a form could be returned
> which would represent how to reproduce the data structure. This would
> serve the dual purpose of being much easier for end users to read, as
> well as being immediately copy/paste-able. For an example of what this
> would look like, dict might return: "{dict, from_list, [[{color, red},
> {size, 5}]]}" for my earlier example. io:format (and friends) of
> course could then easily print this as "dict:from_list([{color, red},
> {size, 5}])".
> 
> Thoughts?
> sRp
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions


From ingela@REDACTED  Mon May 19 11:03:47 2008
From: ingela@REDACTED (Ingela Anderton Andin)
Date: Mon, 19 May 2008 11:03:47 +0200
Subject: [erlang-questions] [Bug] Re: [Q] how to start httpd in R12B
	(Ladislav Lenart)
In-Reply-To: 
References: 
Message-ID: <48314273.105@erix.ericsson.se>

Hi Lenart,

> Hello,
> after all day I finally found the culprit in
>  /usr/lib/erlang/lib/inets-5.0.5/src/mod_auth.erl

> mod_auth:store/2 calls directory_config_check/2 to see if the supplied
> parameters have allowed values. If successful, store_directory/3 is called.
> The bug is in directory_config_check/2 which makes auth_type a mandatory
> option.

> The patch is attached.

Thank you for the patch. Seems like this 
directory_config_check/2 was not a 100 % backward-compatible.

> BTW what is your strategy at finding the cause of such problems? I had
> to resort to fwrites all over httpd_* modules because the error itself
> was completely hidden by the supervisor machinery...

I use Erlang trace.

Regards Ingela Erlang/OTP Ericsson




From kevin@REDACTED  Mon May 19 12:37:03 2008
From: kevin@REDACTED (Kevin A. Smith)
Date: Mon, 19 May 2008 06:37:03 -0400
Subject: [erlang-questions] facebook chat server
In-Reply-To: 
References: 
	<8209f740805151101u2ce8d7ddxfaef2702f662ae15@mail.gmail.com>
	
	
	
	
Message-ID: <9AD81180-4875-4D1C-84C5-E7C9ACEACD45@hypotheticalabs.com>

You have it about right. Thrift is supplies just sync RPC which was  
all I needed at the time. It's not a replacement for more  
sophisticated frameworks like ICE or CORBA but it does hit the sweet  
spot, IMHO, for 80% of the cross-language use cases.

--Kevin
On May 19, 2008, at 2:47 AM, Ludovic Coquelle wrote:

> I have been using ICE a little bit, and it is also quite easy to use  
> (compared to CORBA). However there is no Erlang support (there is a  
> user-contrib for Ocaml though). ICE offer any combination of sync/ 
> async request/respond; it also comes with few tools (efficient  
> publish-subscribe server, service location system ...).
>
> Anyone could tell me diff between ICE and Thrift?
> I haven't investigated Thrift enough, but it seems to be mainly a  
> sync RPC IDL ... I would love to be wrong on that :)
>
> On Sun, May 18, 2008 at 11:31 AM, Kevin A. Smith  > wrote:
> I like Thrift because there's no ORB, the client/server model is
> actually pretty sane, and the IDL strikes the right balance between
> completeness and usefulness. I can actually read the source to Thrift
> and understand what the code is doing. The last time I did anything
> with CORBA (around the late 1990's) it was all so complicated and
> difficult to use. It seemed like "Hello, World" required a ton of
> infrastructure and 100 lines of code. IMHO SOAP is just as bad with
> all the WS-* madness and lack of interop between impls.
>
> When I considered Thrift the only real inter-language alternatives
> were SOAP (ugh!), CORBA (double-ugh!), Thrift, or roll-your own.
> Thrift let me write the code I needed to write with minimal fuss. The
> servers have been in production for 7 months without a single crash or
> problem.
>
> --Kevin
> On May 17, 2008, at 10:31 PM, Igor Ribeiro Sucupira wrote:
>
> > I'm too lazy to read about Thrift, so I'll ask my question here  
> (:p):
> > Why is this better than using CORBA?
> >
> > Thanks.
> > Igor.
> >
> > On Thu, May 15, 2008 at 3:18 PM, Kevin A. Smith
> >  wrote:
> >> Thrift is quite interesting. It's been accepted as an Apache  
> project
> >> and is currently in the project incubator. We're using it at work  
> as
> >> an RPC mechanism across several different langauges (PHP, Python,  
> and
> >> Java). It works quite well.
> >>
> >> --Kevin
> >> On May 15, 2008, at 2:01 PM, Ulf Wiger wrote:
> >>
> >>> Yes, and thrift sounds interesting too. It took me a while to find
> >>> the
> >>> erlang-related stuff
> >>> in trunk/, but there is some - in
> >>> http://svn.facebook.com/svnroot/thrift/trunk/tutorial/erl/,
> >>> for example.
> >>>
> >>> BR,
> >>> Ulf W
> >>>
> >>> 2008/5/15 Torbjorn Tornkvist :
> >>>> I picked up this on the #erlang channel:
> >>>>
> >>>> http://www.facebook.com/notes.php?id=9445547199
> >>>>
> >>>>
> >>>> Pretty cool!
> >>>>
> >>>> --Tobbe
> >>>>
> >>>> _______________________________________________
> >>>> erlang-questions mailing list
> >>>> erlang-questions@REDACTED
> >>>> http://www.erlang.org/mailman/listinfo/erlang-questions
> >>>>
> >>> _______________________________________________
> >>> erlang-questions mailing list
> >>> erlang-questions@REDACTED
> >>> http://www.erlang.org/mailman/listinfo/erlang-questions
> >>
> >> _______________________________________________
> >> erlang-questions mailing list
> >> erlang-questions@REDACTED
> >> http://www.erlang.org/mailman/listinfo/erlang-questions
> >>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>



From per.melin@REDACTED  Mon May 19 12:47:29 2008
From: per.melin@REDACTED (Per Melin)
Date: Mon, 19 May 2008 12:47:29 +0200
Subject: [erlang-questions] Favourite editors and test tools?
In-Reply-To: <97619b170805190143o55f05aa1v2f972af6727b63f0@mail.gmail.com>
References: <7785930012984102501@unknownmsgid>
	<97619b170805190143o55f05aa1v2f972af6727b63f0@mail.gmail.com>
Message-ID: 

2008/5/19 Rapsey :
> I use TextMate.

I'm also on TextMate, despite its (currently) somewhat poor Erlang
support. I'd be surprised if it was "widely used in the Erlang
community" but maybe it should be added as an alternative, as it is
the favorite editor of many OS X users.

(I used to be a heavy Vi(m) user. Vim is a very nice editor which
is/was a pain to script. Then I tried Emacs, which I found easy to
script but a pain to use as an editor.)


From stonecypher@REDACTED  Mon May 19 15:30:54 2008
From: stonecypher@REDACTED (John Haugeland)
Date: Mon, 19 May 2008 07:30:54 -0600
Subject: [erlang-questions] [erlang-bugs] Please ignore the previous post
In-Reply-To: <18481.23548.600744.500155@antilipe.corelatus.se>
References: <8f24f4b10805150948h76ac696ege0db0d9344cbe91f@mail.gmail.com>
	<18481.23548.600744.500155@antilipe.corelatus.se>
Message-ID: <8f24f4b10805190630q218fdd5dv50b35beb34d1d585@mail.gmail.com>

Core2Duo running Vista (Dell Vostro 1700) and erl5.5.5 (I think it's 11b3?)

Sorry, should've mentioned that up front.

On Mon, May 19, 2008 at 4:52 AM, Matthias Lang 
wrote:

> John Haugeland writes:
>  > As many are now pointing out, my error is that floating point is a
> limited
>  > accuracy medium.  I was under the misimpression that Erlang had infinite
>  > precision libraries in use for all numeric types; this turns out only to
> be
>  > true of integers.
>
> This thread is now pretty much wrapped up, but there's still on thing
> missing: information on how to reproduce the results you got.
>
> Specifically, Matthew Demsky couldn't reproduce it with R12 on OSX, I
> couldn't reproduce it with various combinations of R7, R8, R9, R10,
> R11, R12 and AMD and Intel machines running linux. I couldn't
> reproduce it on MIPS and PPC linux machines with software floating
> point emulation either.
>
> So what were you using?
>
> Matt
>



-- 
---
GuaranteedVPS.com - bandwidth commitments and root starting from $12.98/mo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From raimo+erlang-questions@REDACTED  Mon May 19 16:58:39 2008
From: raimo+erlang-questions@REDACTED (Raimo Niskanen)
Date: Mon, 19 May 2008 16:58:39 +0200
Subject: [erlang-questions] : Fwd: Suggestion: New Info item for
	process_info/2
In-Reply-To: <6c2563b20805160846x38771365k44c8dab156e4bfa5@mail.gmail.com>
References: <6c2563b20805151012h2c045828o635d3a719955a564@mail.gmail.com>
	<6c2563b20805151013g7e94b704kc1982b5dabd3d360@mail.gmail.com>
	<1210921636.21090.27.camel@seasc0642.dyn.rnd.as.sw.ericsson.se>
	<6c2563b20805160846x38771365k44c8dab156e4bfa5@mail.gmail.com>
Message-ID: <20080519145839.GB9638@erix.ericsson.se>

On Fri, May 16, 2008 at 11:46:08AM -0400, Edwin Fine wrote:
> Actually, Bengt, that is *exactly* what I would like. Great suggestion.
> Ed
> 
> On Fri, May 16, 2008 at 3:07 AM, Bengt Kleberg 
> wrote:
> 
> > Greetings,
> >
> > There is probably a reason for process_info/1 being restricted to
> > debugging (it might not be possible to interrupt and takes too much
> > time?). Adding 'all' to process_info/2 should turn it into
> > process_info/1 (or a super set of it) and make it as ''bad''.
> > What you probably want is process_info_available/0 which returns a list
> > of atoms.

That might be useful for tools.

-- 

/ Raimo Niskanen, Erlang/OTP, Ericsson AB


From francesco@REDACTED  Mon May 19 18:12:43 2008
From: francesco@REDACTED (Francesco Cesarini)
Date: Mon, 19 May 2008 17:12:43 +0100
Subject: [erlang-questions] Erlang London / Stockholm UG meetings this week
Message-ID: <4831A6FB.6090007@erlang-consulting.com>

Hi All,

a note to remind you that if you are planing to attend Robert Virding's 
presentation on Lisp Flavored Erlang on the 22nd of May in Stockholm, 
you need to register. There are plenty of spaces available, so spread 
the word and bring your friends, but it is good if we know in advance 
how many you are just in case we need to move to an even larger lecture 
hall. You can sign up following the register link: 
http://www.erlang-consulting.com/erlang/events.html#58 
 Stockholms 
Universitet is kindly providing the lecture room. Fredrik Thulin will 
introduce the event and give a brief presentation on the usage of Erlang 
within the University. To subscribe to the Stockholm UG mailing list, 
send a blank email to erlangstockholm-subscribe@REDACTED

For those in London, the UG meeting will be on the 21st of May. Hunter 
Morris, CTO and co-founder of Smarkets, a London-based betting exchange 
startup with a primarily Erlang code base will be presenting their 
Erlang Web Framework.  For more informaiton on this event and to 
register, visit http://www.erlang-consulting.com/erlang/events.html#56 
To subscribe to the London UG mailing list, send a blank email to 
erlang-london-subscribe@REDACTED

See you there,

Francesco
--
http://www.erlang-consulting.com


From neavirc@REDACTED  Mon May 19 18:58:35 2008
From: neavirc@REDACTED (Sergey S.)
Date: Mon, 19 May 2008 09:58:35 -0700
Subject: [erlang-questions] Some questions about ^G
Message-ID: <5e693d1f0805190958g7bd7c67ndba3871a436d0b15@mail.gmail.com>

Hello!

I've found I can use ^C to access various useful commands, but I've some
questions:

1. Is there possibility to extend the list of commands by adding user
defined ones (just like with user_default.erl)?
2. Does the "^G, q" mean the same as erlang:quit()?

Thanks.

--
Best regards.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From theczintheroc2007@REDACTED  Mon May 19 19:26:07 2008
From: theczintheroc2007@REDACTED (Colin Z)
Date: Mon, 19 May 2008 13:26:07 -0400
Subject: [erlang-questions] Change a Spec of a running supervisor
Message-ID: 

In a supervisor, I use a config variable to determine what module to use in
one of its worker specifications.

Is there a way to change a spec while an application/supervisor is already
running?

It's easy enough to change the code of an already loaded module (just
recompile), but how can I switch between using two different modules?

Specific example:
I have module for handling logins that I want my supervisor to be in charge
of. Say that I've started the application and my config variable was
"basicLoginHandler". Without bringing down the entire application, how can I
later make the supervisor terminate its "basicLoginHandler" spec and start a
new worker using a module called "advancedLoginHandler" that I've decided
should be used instead?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From neavirc@REDACTED  Mon May 19 19:30:27 2008
From: neavirc@REDACTED (Sergey S.)
Date: Mon, 19 May 2008 10:30:27 -0700
Subject: [erlang-questions] wall_clock, runtime - what is the difference?
Message-ID: <5e693d1f0805191030m117ea7d3s5251d49957b5b427@mail.gmail.com>

Hello.

As I know there are two methods of getting the elapsed time: using
statistics(runtime) and statistics(wall_clock). What is the difference?

Thanks.

--
Best regards.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From colm.dougan@REDACTED  Mon May 19 19:55:34 2008
From: colm.dougan@REDACTED (Colm)
Date: Mon, 19 May 2008 10:55:34 -0700 (PDT)
Subject: [erlang-questions] zlib deflate problem
Message-ID: 

Hi,

I'm having a problem with erlang's zlib/deflate.  The problem is that
if I try to deflate a piece of data that is a multiple of 4000 bytes
(which also happens to be the zlib internal buffer size, I noticed)
and then inflate it I get an inflate exception.  Below is some sample
code.

I realize I can set different internal buffer size using
zlib:setBufSize but that doesn't really help as I can't predict the
size of data I will be deflating/inflating.

Am I doing something dumb here or is this a bug in the erlang zlib
interface?  I strongly suspect it is the former.

Thanks,
Colm



-module(zlib_deflate_problem).
-export([start/0, start/1]).

-define(DATA_SIZE, 4000).

start() ->
  start(?DATA_SIZE).

start(DataSize) ->
   % Generate a binary of size "0" x DATA_SIZE
   Data = list_to_binary(
       lists:map(fun(_) -> 0 end, lists:seq(1, DataSize))
   ),
   io:format("Raw data -> ~p~n", [size(Data)]),

   ZInflate = zlib:open(),
   ok = zlib:inflateInit(ZInflate),

   ZDeflate = zlib:open(),
   ok = zlib:deflateInit(ZDeflate),

   Deflated = zlib:deflate(ZDeflate, Data, sync),
   io:format("Deflated -> ~p~n", [Deflated]),

   Inflated = case catch zlib:inflate(ZInflate, Deflated) of
       {'EXIT', {'data_error', _Backtrace} } ->
           io:format("zlib:inflate data_error~n"),
           [];
       {'EXIT', Reason} ->
           io:format("zlib:inflate error -> [~p]~n", [Reason]),
           [];
       [] ->
           io:format("zlib:inflate empty response~n"), [];
       Iolist ->
           Iolist
   end,

   io:format("Inflated -> ~p~n", [iolist_size(Inflated)]),

   ok.


From anders.nygren@REDACTED  Mon May 19 20:14:47 2008
From: anders.nygren@REDACTED (Anders Nygren)
Date: Mon, 19 May 2008 13:14:47 -0500
Subject: [erlang-questions] Change a Spec of a running supervisor
In-Reply-To: 
References: 
Message-ID: 

2008/5/19 Colin Z :
> In a supervisor, I use a config variable to determine what module to use in
> one of its worker specifications.
>
> Is there a way to change a spec while an application/supervisor is already
> running?
>
> It's easy enough to change the code of an already loaded module (just
> recompile), but how can I switch between using two different modules?
>
> Specific example:
> I have module for handling logins that I want my supervisor to be in charge
> of. Say that I've started the application and my config variable was
> "basicLoginHandler". Without bringing down the entire application, how can I
> later make the supervisor terminate its "basicLoginHandler" spec and start a
> new worker using a module called "advancedLoginHandler" that I've decided
> should be used instead?
>

Look at supervisor:terminate_child and supervisor:start_child

/Anders


From matthias@REDACTED  Mon May 19 20:24:16 2008
From: matthias@REDACTED (Matthias Lang)
Date: Mon, 19 May 2008 20:24:16 +0200
Subject: [erlang-questions] wall_clock, runtime - what is the difference?
In-Reply-To: <5e693d1f0805191030m117ea7d3s5251d49957b5b427@mail.gmail.com>
References: <5e693d1f0805191030m117ea7d3s5251d49957b5b427@mail.gmail.com>
Message-ID: <18481.50640.378900.57585@antilipe.corelatus.se>

Sergey S. writes:

 > As I know there are two methods of getting the elapsed time: using
 > statistics(runtime) and statistics(wall_clock). What is the difference?

Wall clock is the time that elapses on the clock on your wall.

Runtime is the amount of time which elapsed while your process was
actually using the CPU. 

Take a look at

  http://en.wikipedia.org/wiki/Wall_time

Matt


From pablosan@REDACTED  Mon May 19 20:35:41 2008
From: pablosan@REDACTED (Paul Nelson)
Date: Mon, 19 May 2008 13:35:41 -0500
Subject: [erlang-questions] wall_clock, runtime - what is the difference?
In-Reply-To: <5e693d1f0805191030m117ea7d3s5251d49957b5b427@mail.gmail.com>
References: <5e693d1f0805191030m117ea7d3s5251d49957b5b427@mail.gmail.com>
Message-ID: 

I don't know for sure, but I can make an educated guess. Since erlang is not
guaranteed to have 100% of your CPU time, runtime would be the actual amount
of processing time used by erlang. "wall_clock" time is simply recording the
actual time the process started and the actual time the process ended and
giving you the difference in "real time" (i.e. time as reported by a clock
on the wall).

That's my educated guess, anyway. :-)

-Pablosan (Paul Nelson)

2008/5/19 Sergey S. :

> Hello.
>
> As I know there are two methods of getting the elapsed time: using
> statistics(runtime) and statistics(wall_clock). What is the difference?
>
> Thanks.
>
> --
> Best regards.
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>



-- 
Salient Blue. It's NOT people.
My blog: http://blog.salientblue.com
My TDD playground: http://salientblue.com/codenotes
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From steven.charles.davis@REDACTED  Mon May 19 21:39:17 2008
From: steven.charles.davis@REDACTED (Steve Davis)
Date: Mon, 19 May 2008 14:39:17 -0500
Subject: [erlang-questions] How to "chain" filters?
Message-ID: <4831D765.8000009@gmail.com>

To give a simple example below -- I wish to perform check2() only on the 
elements that pass check() and I can't see an elegant way to do it!

-module(filter).
-export([init/0]).

init() ->
	L = [1,2,3,4,5,6,7,8,9,10],
	check(L),
	check2(L, []).

check(L) -> lists:filter(fun(X) -> X rem 2 =:= 0 end, L).

check2([], A) -> A;
check2([H | T], A) ->
	C = lists:filter(fun(X) -> (X + H) rem 3 =:= 0 end, T),
	C1 = [{H, X, H / X} || X <- C],
	check2(T, lists:append(A, C1)).

In my actual code I have 5 non-trivial filters and I'm trying at all 
costs to avoid duplication of tests, The example code below exactly 
specifies the issue (without the detail). i.e. for members of the list 
data that pass the initial check (in this case they are even numbers), 
perfom check2... check2 requires that each candidate element should be 
checked against all other members of the list (but not itself) and 
should not duplicate any pairwise test in the "expensive" check2...
(my data is actually records so avoiding the issue by using the fact 
that value of the list elements in the example is not going to help!)




From erlang-questions_efine@REDACTED  Mon May 19 21:44:03 2008
From: erlang-questions_efine@REDACTED (Edwin Fine)
Date: Mon, 19 May 2008 15:44:03 -0400
Subject: [erlang-questions] zlib deflate problem
In-Reply-To: 
References: 
Message-ID: <6c2563b20805191244m576aaf58t9df87d1c0647f4bb@mail.gmail.com>

Colm,

This works without crashing:
-module(zlib_deflate_problem).
-export([start/0, start/1]).

-define(DATA_SIZE, 4000).

start() ->
 start(?DATA_SIZE).

start(DataSize) ->
  Data = <<0:DataSize/unit:8>>,
  io:format("Raw data -> ~p~n", [size(Data)]),

  Z = zlib:open(),
  ok = zlib:deflateInit(Z),
  Deflated = zlib:deflate(Z, Data, finish),
  ok = zlib:deflateEnd(Z),

  io:format("Deflated -> ~p~n", [Deflated]),

  ok = zlib:inflateInit(Z),
  io:format("Inflate buf size -> ~p~n", [zlib:getBufSize(Z)]),

  Inflated = case catch zlib:inflate(Z, Deflated) of
      {'EXIT', {'data_error', _Backtrace} } ->
          io:format("zlib:inflate data_error~n"),
          [];
      {'EXIT', Reason} ->
          io:format("zlib:inflate error -> [~p]~n", [Reason]),
          [];
      [] ->
          io:format("zlib:inflate empty response~n"), [];
      Iolist ->
          Iolist
  end,

  ok = zlib:inflateEnd(Z),
  ok = zlib:close(Z),

  io:format("Inflated -> ~p~n", [iolist_size(Inflated)]).

Hope this helps.
Ed

On Mon, May 19, 2008 at 1:55 PM, Colm  wrote:

> Hi,
>
> I'm having a problem with erlang's zlib/deflate.  The problem is that
> if I try to deflate a piece of data that is a multiple of 4000 bytes
> (which also happens to be the zlib internal buffer size, I noticed)
> and then inflate it I get an inflate exception.  Below is some sample
> code.
>
> I realize I can set different internal buffer size using
> zlib:setBufSize but that doesn't really help as I can't predict the
> size of data I will be deflating/inflating.
>
> Am I doing something dumb here or is this a bug in the erlang zlib
> interface?  I strongly suspect it is the former.
>
> Thanks,
> Colm
>
>
>
> -module(zlib_deflate_problem).
> -export([start/0, start/1]).
>
> -define(DATA_SIZE, 4000).
>
> start() ->
>  start(?DATA_SIZE).
>
> start(DataSize) ->
>   % Generate a binary of size "0" x DATA_SIZE
>   Data = list_to_binary(
>       lists:map(fun(_) -> 0 end, lists:seq(1, DataSize))
>   ),

fyi, this would be MUCH easier as
Data = <<0:?DATA_SIZE/unit:8>>.

>
>   io:format("Raw data -> ~p~n", [size(Data)]),
>
>   ZInflate = zlib:open(),
>   ok = zlib:inflateInit(ZInflate),
>
>   ZDeflate = zlib:open(),
>   ok = zlib:deflateInit(ZDeflate),
>
>   Deflated = zlib:deflate(ZDeflate, Data, sync),
>   io:format("Deflated -> ~p~n", [Deflated]),
>
>   Inflated = case catch zlib:inflate(ZInflate, Deflated) of
>       {'EXIT', {'data_error', _Backtrace} } ->
>           io:format("zlib:inflate data_error~n"),
>           [];
>       {'EXIT', Reason} ->
>           io:format("zlib:inflate error -> [~p]~n", [Reason]),
>           [];
>       [] ->
>           io:format("zlib:inflate empty response~n"), [];
>       Iolist ->
>           Iolist
>   end,
>
>   io:format("Inflated -> ~p~n", [iolist_size(Inflated)]),
>
>   ok.
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From rvirding@REDACTED  Mon May 19 22:20:13 2008
From: rvirding@REDACTED (Robert Virding)
Date: Mon, 19 May 2008 22:20:13 +0200
Subject: [erlang-questions] How to "chain" filters?
In-Reply-To: <4831D765.8000009@gmail.com>
References: <4831D765.8000009@gmail.com>
Message-ID: <3dbc6d1c0805191320p5ee15289h8dfb244cfd836719@mail.gmail.com>

2008/5/19 Steve Davis :

> To give a simple example below -- I wish to perform check2() only on the
> elements that pass check() and I can't see an elegant way to do it!
>
> -module(filter).
> -export([init/0]).
>
> init() ->
>        L = [1,2,3,4,5,6,7,8,9,10],
>        check(L),
>        check2(L, []).


The thing to remember here is that filter, and hence check/1, return the
list of filtered elements. You use this in check2/2. So init/1 should be
written:

init() ->
    L0 = [1,2,3,4,5,6,7,8,9,10],
    L1 = check(L0),
    check2(L1, []).

If you have a sequence of checks you would get:

    L1 = check1(L0),
    L2 = check2(L1),
    L3 = check3(L2),
    ...

This could be written as folding a list of checks over the returned lists:

   Checks =
        [fun (L) ->check1(L) end,
         fun (L) -> check2(L) end,
         ...],
    lists:foldl(fun (C, L) -> C(L) end, InitialList, Checks)

If this is clearer is a matter of taste. It is at least easier to modify
checks list without having to change variable names. :-)

check(L) -> lists:filter(fun(X) -> X rem 2 =:= 0 end, L).
>
> check2([], A) -> A;
> check2([H | T], A) ->
>        C = lists:filter(fun(X) -> (X + H) rem 3 =:= 0 end, T),
>        C1 = [{H, X, H / X} || X <- C],
>        check2(T, lists:append(A, C1)).


You can combine the filter and the list comprehension into one list
comprehension:

    C1 = [{H,X,H/X} || X <- T, (X+H) rem 3 =:= 0 ]

In your code you are really using the list comprehension as a map.

A final point: depending on the length of the output list and the
significance of the order of elements it might be better to push the new
elements onto the accumulator list and reverse the result at the end.

Although I realise that this is just example code. :-) Out of interest what
are doing?

Robert

In my actual code I have 5 non-trivial filters and I'm trying at all
> costs to avoid duplication of tests, The example code below exactly
> specifies the issue (without the detail). i.e. for members of the list
> data that pass the initial check (in this case they are even numbers),
> perfom check2... check2 requires that each candidate element should be
> checked against all other members of the list (but not itself) and
> should not duplicate any pairwise test in the "expensive" check2...
> (my data is actually records so avoiding the issue by using the fact
> that value of the list elements in the example is not going to help!)
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From colm.dougan@REDACTED  Mon May 19 23:00:13 2008
From: colm.dougan@REDACTED (Colm Dougan)
Date: Mon, 19 May 2008 22:00:13 +0100
Subject: [erlang-questions] zlib deflate problem
In-Reply-To: <6c2563b20805191244m576aaf58t9df87d1c0647f4bb@mail.gmail.com>
References: 
	<6c2563b20805191244m576aaf58t9df87d1c0647f4bb@mail.gmail.com>
Message-ID: <24d4f39c0805191400n50056866o10a76e0745ff74b1@mail.gmail.com>

Edwin,

On Mon, May 19, 2008 at 8:44 PM, Edwin Fine
 wrote:
> Colm,
>
> This works without crashing:

Thanks.  Unless I'm missing something the main functional change
between our versions is that you have used  'finish' when deflating
whileI have used 'sync'.

I'm wondering why the 'sync' version doesn't work as I was using it
deliberately.  Am I using 'sync' in an inappropriate way?   Or could
there be a bug in the C layer of the erlang zlib interface wrt to sync
in the case that the input data is a multiple of the internal buffer
size?  Again more likely it is my fault.

Thanks,
Colm


From tty.erlang@REDACTED  Tue May 20 03:07:12 2008
From: tty.erlang@REDACTED (t ty)
Date: Mon, 19 May 2008 21:07:12 -0400
Subject: [erlang-questions] Erlang London / Stockholm UG meetings this
	week
In-Reply-To: <4831A6FB.6090007@erlang-consulting.com>
References: <4831A6FB.6090007@erlang-consulting.com>
Message-ID: <290b3ba10805191807m18f7e730ica029a96cf28e06c@mail.gmail.com>

Hello,

Will both events be taped for those of us unfortunately enough to be
on the wrong side of the Atlantic ?

Thanks,

Tee

On Mon, May 19, 2008 at 12:12 PM, Francesco Cesarini
 wrote:
> Hi All,
>
> a note to remind you that if you are planing to attend Robert Virding's
> presentation on Lisp Flavored Erlang on the 22nd of May in Stockholm,
> you need to register. There are plenty of spaces available, so spread
> the word and bring your friends, but it is good if we know in advance
> how many you are just in case we need to move to an even larger lecture
> hall. You can sign up following the register link:
> http://www.erlang-consulting.com/erlang/events.html#58
>  Stockholms
> Universitet is kindly providing the lecture room. Fredrik Thulin will
> introduce the event and give a brief presentation on the usage of Erlang
> within the University. To subscribe to the Stockholm UG mailing list,
> send a blank email to erlangstockholm-subscribe@REDACTED
>
> For those in London, the UG meeting will be on the 21st of May. Hunter
> Morris, CTO and co-founder of Smarkets, a London-based betting exchange
> startup with a primarily Erlang code base will be presenting their
> Erlang Web Framework.  For more informaiton on this event and to
> register, visit http://www.erlang-consulting.com/erlang/events.html#56
> To subscribe to the London UG mailing list, send a blank email to
> erlang-london-subscribe@REDACTED
>
> See you there,
>
> Francesco
> --
> http://www.erlang-consulting.com
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>


From matthew@REDACTED  Tue May 20 04:15:08 2008
From: matthew@REDACTED (Matthew Dempsky)
Date: Mon, 19 May 2008 19:15:08 -0700
Subject: [erlang-questions] zlib deflate problem
In-Reply-To: 
References: 
Message-ID: 

On Mon, May 19, 2008 at 10:55 AM, Colm  wrote:
> Am I doing something dumb here or is this a bug in the erlang zlib
> interface?  I strongly suspect it is the former.

Your code looks fine to me.  Can you try applying the patch below to
erts/emulator/drivers/common/zlib_drv.c and checks for any
regressions?  (Z_BUF_ERROR is a non-fatal error case for inflate(3);
it just indicates that zlib wasn't able to make any progress with the
data given.)

--- zlib_drv.c.orig	2008-05-19 19:09:00.000000000 -0700
+++ zlib_drv.c	2008-05-19 19:09:12.000000000 -0700
@@ -257,6 +257,10 @@
 		driver_deq(d->port, len);
 		return res;
 	    }
+	    if (res == Z_BUF_ERROR) {
+		res = Z_OK;
+	    }
 	    if (res < 0) {
 		return res;
 	    }


From steven.charles.davis@REDACTED  Tue May 20 05:46:30 2008
From: steven.charles.davis@REDACTED (Steve Davis)
Date: Mon, 19 May 2008 22:46:30 -0500
Subject: [erlang-questions] How to "chain" filters?
In-Reply-To: <3dbc6d1c0805191320p5ee15289h8dfb244cfd836719@mail.gmail.com>
References: <4831D765.8000009@gmail.com>
	<3dbc6d1c0805191320p5ee15289h8dfb244cfd836719@mail.gmail.com>
Message-ID: <48324996.2060103@gmail.com>

Thanks Robert! Some great pointers there. Here's what I have managed to 
actually make work out of all that...

-module(filter).
-export([run/0]).

run() ->
     check([1,2,3,4,5,6,7,8,9,10]).

check(L) -> check(L, []).
	
check ([H | T], A) ->
     C = [{H, X, H / X} || X <- T, H rem 2 =:= 0, (X + H) rem 3 =:= 0],
     check(T, [C | A]);
check([], A) -> lists:flatten(lists:reverse(A)).


...this produces the correct output, i.e...

2> filter:run().
[{2,4,0.5},
  {2,7,0.2857142857142857},
  {2,10,0.2},
  {4,5,0.8},
  {4,8,0.5},
  {6,9,0.6666666666666666},
  {8,10,0.8}]

I do think that using foldl is probably the right/more elegant/more 
readable solution but I can't (yet) figure out how to get it to work for 
this instance :( (i.e. I don't understand "folding" so I'm reading and 
learning more as I write --- it's a concurrent world, after all :)

I'm a bit concerned that I can't really tell whether redundant checks 
are being made -- in a list comprehension would the test for "even" stop 
there and not try to do the second text for (X + H) rem 3 - this is a 
considerably more expensive test in my application.

Sidenote: The app domain is physics simulation - I'm new to Erlang but 
learning fast as I can, and this is what I need for a particular part of 
the collision prediction algorithm (note: this isn't the usual collision 
*detection* as all current algorithms for that stop me spinning various 
things out into concurrent processes...). I'm doing the entire thing in 
Erlang first to find out what algorithms actually *need* to be coded in 
C++ (if any -- wow, wouldn't that be something :).


From ft@REDACTED  Tue May 20 08:26:12 2008
From: ft@REDACTED (Fredrik Thulin)
Date: Tue, 20 May 2008 08:26:12 +0200
Subject: [erlang-questions] Erlang London / Stockholm UG meetings this
 week
In-Reply-To: <4831A6FB.6090007@erlang-consulting.com>
References: <4831A6FB.6090007@erlang-consulting.com>
Message-ID: <48326F04.5080105@it.su.se>

Francesco Cesarini wrote:
> Hi All,
> 
> a note to remind you that if you are planing to attend Robert Virding's 
> presentation on Lisp Flavored Erlang on the 22nd of May in Stockholm, 
> you need to register. There are plenty of spaces available, so spread 
> the word and bring your friends, but it is good if we know in advance 
> how many you are just in case we need to move to an even larger lecture 
> hall. You can sign up following the register link: 
> http://www.erlang-consulting.com/erlang/events.html#58 
>  Stockholms 
> Universitet is kindly providing the lecture room. Fredrik Thulin will 
> introduce the event and give a brief presentation on the usage of Erlang 
> within the University. To subscribe to the Stockholm UG mailing list, 
> send a blank email to erlangstockholm-subscribe@REDACTED

The exact location is Avdelningen f?r IT och media, Frescati Hagv?g 10 
(http://hitta.se/SearchCombi.aspx?vad=&var=frescati+hagv%e4g+10).

You can either take a 10 minute walk from the subway station 
(Universitetet), or a shorter walk from bus number 40 or 70. The closest 
bus stop is Universitetet s?dra.

If you register very late (as in Wednesday or Thursday), it is more 
likely that we will have people standing in the back of the conference 
room than that we can scramble up a lecture hall in the last minute.

Welcome!

/Fredrik


From ft@REDACTED  Tue May 20 08:40:21 2008
From: ft@REDACTED (Fredrik Thulin)
Date: Tue, 20 May 2008 08:40:21 +0200
Subject: [erlang-questions] Change a Spec of a running supervisor
In-Reply-To: 
References: 
Message-ID: <48327255.9040404@it.su.se>

Colin Z wrote:
> In a supervisor, I use a config variable to determine what module to use in
> one of its worker specifications.
> 
> Is there a way to change a spec while an application/supervisor is already
> running?
> 
> It's easy enough to change the code of an already loaded module (just
> recompile), but how can I switch between using two different modules?
> 
> Specific example:
> I have module for handling logins that I want my supervisor to be in charge
> of. Say that I've started the application and my config variable was
> "basicLoginHandler". Without bringing down the entire application, how can I
> later make the supervisor terminate its "basicLoginHandler" spec and start a
> new worker using a module called "advancedLoginHandler" that I've decided
> should be used instead?

It's an RTFM really, but I'll try to be polite ;)

See the manual for the supervisor module 
(http://www.erlang.org/doc/man/supervisor.html) - there are functions 
called start_child, delete_child and of course which_children.

/Fredrik


From per.melin@REDACTED  Tue May 20 12:05:03 2008
From: per.melin@REDACTED (Per Melin)
Date: Tue, 20 May 2008 12:05:03 +0200
Subject: [erlang-questions] How to "chain" filters?
In-Reply-To: <48324996.2060103@gmail.com>
References: <4831D765.8000009@gmail.com>
	<3dbc6d1c0805191320p5ee15289h8dfb244cfd836719@mail.gmail.com>
	<48324996.2060103@gmail.com>
Message-ID: 

2008/5/20 Steve Davis :
> check ([H | T], A) ->
>     C = [{H, X, H / X} || X <- T, H rem 2 =:= 0, (X + H) rem 3 =:= 0],
>     check(T, [C | A]);
> check([], A) -> lists:flatten(lists:reverse(A)).

In the above you iterate over T when H is odd and no cases apply. This
should be more efficient:

check([H | T], A) when H rem 2 =:= 0 ->
    C = [{H, X, H / X} || X <- T, (X + H) rem 3 =:= 0],
    check(T, [C | A]);
check([_ | T], A) -> check(T, A);
check([], A) -> lists:flatten(lists:reverse(A)).


From francesco@REDACTED  Tue May 20 09:36:26 2008
From: francesco@REDACTED (Francesco Cesarini)
Date: Tue, 20 May 2008 08:36:26 +0100
Subject: [erlang-questions] Erlang London / Stockholm UG meetings this
 week
In-Reply-To: <290b3ba10805191807m18f7e730ica029a96cf28e06c@mail.gmail.com>
References: <4831A6FB.6090007@erlang-consulting.com>
	<290b3ba10805191807m18f7e730ica029a96cf28e06c@mail.gmail.com>
Message-ID: <48327F7A.1020303@erlang-consulting.com>

Yes, both events will be taped.

Francesco
--
http://www.erlang-consulting.com

t ty wrote:
> Hello,
>
> Will both events be taped for those of us unfortunately enough to be
> on the wrong side of the Atlantic ?
>
> Thanks,
>
> Tee
>
> On Mon, May 19, 2008 at 12:12 PM, Francesco Cesarini
>  wrote:
>   
>> Hi All,
>>
>> a note to remind you that if you are planing to attend Robert Virding's
>> presentation on Lisp Flavored Erlang on the 22nd of May in Stockholm,
>> you need to register. There are plenty of spaces available, so spread
>> the word and bring your friends, but it is good if we know in advance
>> how many you are just in case we need to move to an even larger lecture
>> hall. You can sign up following the register link:
>> http://www.erlang-consulting.com/erlang/events.html#58
>>  Stockholms
>> Universitet is kindly providing the lecture room. Fredrik Thulin will
>> introduce the event and give a brief presentation on the usage of Erlang
>> within the University. To subscribe to the Stockholm UG mailing list,
>> send a blank email to erlangstockholm-subscribe@REDACTED
>>
>> For those in London, the UG meeting will be on the 21st of May. Hunter
>> Morris, CTO and co-founder of Smarkets, a London-based betting exchange
>> startup with a primarily Erlang code base will be presenting their
>> Erlang Web Framework.  For more informaiton on this event and to
>> register, visit http://www.erlang-consulting.com/erlang/events.html#56
>> To subscribe to the London UG mailing list, send a blank email to
>> erlang-london-subscribe@REDACTED
>>
>> See you there,
>>
>> Francesco
>> --
>> http://www.erlang-consulting.com
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://www.erlang.org/mailman/listinfo/erlang-questions
>>
>>     
>
>   




From dougedmunds@REDACTED  Tue May 20 15:05:40 2008
From: dougedmunds@REDACTED (DougEdmunds)
Date: Tue, 20 May 2008 06:05:40 -0700
Subject: [erlang-questions] [Announce] Erlbol: Erlang <--> REBOL interface
Message-ID: <4832CCA4.5080604@gmail.com>

Erlbol

The Erlbol project uses REBOL as a GUI for Erlang code.
Data is exchanged by tcp/ip connection (Erlang server, REBOL
client), using Erlang's external term format as the
binary grammar.

Project site: http://erlbol.dougedmunds.com

-dae


From juanjo@REDACTED  Tue May 20 15:08:43 2008
From: juanjo@REDACTED (Juan Jose Comellas)
Date: Tue, 20 May 2008 10:08:43 -0300
Subject: [erlang-questions] rsync-like function in Erlang?
In-Reply-To: <351ce2d70805171433y3d179240wd0adcc3b38ac6cbd@mail.gmail.com>
References: <351ce2d70805171433y3d179240wd0adcc3b38ac6cbd@mail.gmail.com>
Message-ID: <1c3be50f0805200608r504dfb80w1b25bb389a36ac7d@mail.gmail.com>

Have you thought about using a distributed version control system such as
Git for this? I have the same problem, with the added need to track the
history of changes of each file, and I'm planning to build an Erlang wrapper
over Git. This wrapper could also provide a transactional interface to the
filesystem, giving you the ability to rollback to a previous version of the
file in case of a problem.


On Sat, May 17, 2008 at 6:33 PM, Johan Holmberg  wrote:

> Hi!
>
> I have a number of Erlang-nodes running on different physical
> machines. I want each node to have a local copy of the same directory
> tree. Is there any existing Erlang-library that can do this?
>
> The erlang nodes I use can be on either Linux or Windows.
>
> I don't need an actual "rsync clone", just something that can make
> sure two directory trees on different machines stay in sync. And I
> would prefer that small changes to one of the trees were detected fast
> (like in rsync(1) or unison(1)).
>
> I realize that one solution would be to build some kind of wrapper in
> Erlang around rsync(1) or unison(1) (maybe such a thing already
> exist?) But I would prefer a pure Erlang solution if possible.
>
> /Johan Holmberg
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From colm.dougan@REDACTED  Tue May 20 19:43:43 2008
From: colm.dougan@REDACTED (Colm Dougan)
Date: Tue, 20 May 2008 18:43:43 +0100
Subject: [erlang-questions] zlib deflate problem
In-Reply-To: 
References: 
	
Message-ID: <24d4f39c0805201043m73cee5a8xe37299270466cd22@mail.gmail.com>

On Tue, May 20, 2008 at 3:15 AM, Matthew Dempsky  wrote:
> On Mon, May 19, 2008 at 10:55 AM, Colm  wrote:
>> Am I doing something dumb here or is this a bug in the erlang zlib
>> interface?  I strongly suspect it is the former.
>
> Your code looks fine to me.  Can you try applying the patch below to
> erts/emulator/drivers/common/zlib_drv.c and checks for any
> regressions?  (Z_BUF_ERROR is a non-fatal error case for inflate(3);
> it just indicates that zlib wasn't able to make any progress with the
> data given.)
>
> --- zlib_drv.c.orig     2008-05-19 19:09:00.000000000 -0700
> +++ zlib_drv.c  2008-05-19 19:09:12.000000000 -0700
> @@ -257,6 +257,10 @@
>                driver_deq(d->port, len);
>                return res;
>            }
> +           if (res == Z_BUF_ERROR) {
> +               res = Z_OK;
> +           }
>            if (res < 0) {
>                return res;
>            }


Matthew - I tried your patch and it worked.   I don't see any
regression but I haven't done extensive testing. If you think this is
the appropriate fix (rather than an exploratory patch) then I can
install the patched erlang on my running system and do more testing.

Thanks,
Colm


From matthew@REDACTED  Tue May 20 20:22:22 2008
From: matthew@REDACTED (Matthew Dempsky)
Date: Tue, 20 May 2008 11:22:22 -0700
Subject: [erlang-questions] zlib deflate problem
In-Reply-To: <24d4f39c0805201043m73cee5a8xe37299270466cd22@mail.gmail.com>
References: 
	
	<24d4f39c0805201043m73cee5a8xe37299270466cd22@mail.gmail.com>
Message-ID: 

On Tue, May 20, 2008 at 10:43 AM, Colm Dougan  wrote:
> Matthew - I tried your patch and it worked.   I don't see any
> regression but I haven't done extensive testing. If you think this is
> the appropriate fix (rather than an exploratory patch) then I can
> install the patched erlang on my running system and do more testing.

I think it should be safe for more testing.


From johan556@REDACTED  Tue May 20 22:45:00 2008
From: johan556@REDACTED (Johan Holmberg)
Date: Tue, 20 May 2008 22:45:00 +0200
Subject: [erlang-questions] rsync-like function in Erlang?
In-Reply-To: <1c3be50f0805200608r504dfb80w1b25bb389a36ac7d@mail.gmail.com>
References: <351ce2d70805171433y3d179240wd0adcc3b38ac6cbd@mail.gmail.com>
	<1c3be50f0805200608r504dfb80w1b25bb389a36ac7d@mail.gmail.com>
Message-ID: <351ce2d70805201345x69f01612v323de6a140ae6025@mail.gmail.com>

2008/5/20 Juan Jose Comellas :
> Have you thought about using a distributed version control system such as
> Git for this? I have the same problem, with the added need to track the
> history of changes of each file, and I'm planning to build an Erlang wrapper
> over Git. This wrapper could also provide a transactional interface to the
> filesystem, giving you the ability to rollback to a previous version of the
> file in case of a problem.
>

Interesting idea. I have thought about using Subversion (the version
control system we normally use), but dismissed it as to complicated
(with the need for a third machine, the Subversion-server, and with
all the space overhead in the local .svn directories).

Does Git work well on Windows? And can it operate in client-server
fashion, or does it need filesystem access between the machines?

Your kind of solution could perhaps suit me too, even if I'm not
primarily interested in the change history.

/Johan Holmberg

>
> On Sat, May 17, 2008 at 6:33 PM, Johan Holmberg  wrote:
>>
>> Hi!
>>
>> I have a number of Erlang-nodes running on different physical
>> machines. I want each node to have a local copy of the same directory
>> tree. Is there any existing Erlang-library that can do this?
>>
>> The erlang nodes I use can be on either Linux or Windows.
>>
>> I don't need an actual "rsync clone", just something that can make
>> sure two directory trees on different machines stay in sync. And I
>> would prefer that small changes to one of the trees were detected fast
>> (like in rsync(1) or unison(1)).
>>
>> I realize that one solution would be to build some kind of wrapper in
>> Erlang around rsync(1) or unison(1) (maybe such a thing already
>> exist?) But I would prefer a pure Erlang solution if possible.
>>
>> /Johan Holmberg
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://www.erlang.org/mailman/listinfo/erlang-questions
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>


From tuncer.ayaz@REDACTED  Tue May 20 23:23:25 2008
From: tuncer.ayaz@REDACTED (Tuncer Ayaz)
Date: Tue, 20 May 2008 23:23:25 +0200
Subject: [erlang-questions] rsync-like function in Erlang?
In-Reply-To: <351ce2d70805201345x69f01612v323de6a140ae6025@mail.gmail.com>
References: <351ce2d70805171433y3d179240wd0adcc3b38ac6cbd@mail.gmail.com>
	<1c3be50f0805200608r504dfb80w1b25bb389a36ac7d@mail.gmail.com>
	<351ce2d70805201345x69f01612v323de6a140ae6025@mail.gmail.com>
Message-ID: <4ac8254d0805201423l7e4037d1td9474cd125e3d32e@mail.gmail.com>

On Tue, May 20, 2008 at 10:45 PM, Johan Holmberg  wrote:
> 2008/5/20 Juan Jose Comellas :
>> Have you thought about using a distributed version control system such as
>> Git for this? I have the same problem, with the added need to track the
>> history of changes of each file, and I'm planning to build an Erlang wrapper
>> over Git. This wrapper could also provide a transactional interface to the
>> filesystem, giving you the ability to rollback to a previous version of the
>> file in case of a problem.
>>
>
> Interesting idea. I have thought about using Subversion (the version
> control system we normally use), but dismissed it as to complicated
> (with the need for a third machine, the Subversion-server, and with
> all the space overhead in the local .svn directories).
>
> Does Git work well on Windows? And can it operate in client-server
> fashion, or does it need filesystem access between the machines?

Git works on Windows but not yet quite as good as on the _you know
where it originated :D_ OS
http://code.google.com/p/msysgit/
http://code.google.com/p/msysgit/wiki/GitCheetah

You can host your repository on a central server and have clones
aka checkouts on the clients. You _can_ use Git in a central
repo way.

> Your kind of solution could perhaps suit me too, even if I'm not
> primarily interested in the change history.

well, having the change history doesn't hurt either :)

maybe using a central configuration management solution
like http://reductivelabs.com/trac/puppet might make sense.




From alpar@REDACTED  Wed May 21 00:07:29 2008
From: alpar@REDACTED (=?ISO-8859-1?Q?Alp=E1r_J=FCttner?=)
Date: Tue, 20 May 2008 23:07:29 +0100
Subject: [erlang-questions] rsync-like function in Erlang?
In-Reply-To: <4ac8254d0805201423l7e4037d1td9474cd125e3d32e@mail.gmail.com>
References: <351ce2d70805171433y3d179240wd0adcc3b38ac6cbd@mail.gmail.com>
	<1c3be50f0805200608r504dfb80w1b25bb389a36ac7d@mail.gmail.com>
	<351ce2d70805201345x69f01612v323de6a140ae6025@mail.gmail.com>
	<4ac8254d0805201423l7e4037d1td9474cd125e3d32e@mail.gmail.com>
Message-ID: <1211321249.4502.15.camel@piko.site>

> > Does Git work well on Windows? And can it operate in client-server
> > fashion, or does it need filesystem access between the machines?
> 
> Git works on Windows but not yet quite as good as on the _you know
> where it originated :D_ OS

What about using Mercurial instead? Its performance and feature set is
more or less the same as of git, but it also has a good (and fast)
native Windows support. Moreover, its user interface is also considered
to be easier and cleaner, and it is very well documented.

Regards,
Alpar




From cyberlync@REDACTED  Wed May 21 01:52:19 2008
From: cyberlync@REDACTED (Eric Merritt)
Date: Tue, 20 May 2008 16:52:19 -0700
Subject: [erlang-questions] proposal: pretty printing through
	polymorphism
In-Reply-To: <4831404F.2040608@ericsson.com>
References: <88fce4d0805151959g7dc1449br3380678b372961c6@mail.gmail.com>
	<4831404F.2040608@ericsson.com>
Message-ID: 

I think this is probably worth more then simple shell printing. Having
usefully printed data structures in logs, etc would probably be pretty
useful. Though implementing it all over the place would probably be
non-trivial.

On Mon, May 19, 2008 at 1:54 AM, Ulf Wiger (TN/EAB)
 wrote:
>
> A while back, I hacked the Erlang shell in order to
> allow custom pretty-printing:
>
> http://ulf.wiger.net/weblog/2007/11/20/extending-the-erlang-shell-part-1/
>
> You can find the code here:
>
> svn co http://svn.ulf.wiger.net/ext_shell/trunk
>
> The trunk is for R12B. See also
>
> http://svn.ulf.wiger.net/ext_shell/branches/r11b/
> http://svn.ulf.wiger.net/ext_shell/branches/r12b/
>
> Please feel free to play around with it and propose
> improvements.
>
> BR,
> Ulf W
>
> Scott Parish skrev:
>> Problem:
>>
>> Right now pretty printing values shows the lowest layer data
>> structures. This is ugly and usually not what an end user wants/needs
>> to see. For instance:
>>
>> 1> dict:store(color, red, dict:store(size, 5, dict:new())).
>> {dict,2,
>>       16,
>>       16,
>>       8,
>>       80,
>>       48,
>>       {[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]},
>>       {{[],[],[[color|red]],[],[],[[size|5]],[],[],[],[],[],[],[],[],[],[]}}}
>>
>> Solution:
>>
>> The proposed solution would take advantage of the type of polymorphism
>> suggested in my prior email. Namely, there would be a function such as
>> string:pretty_print/1 which would take a derived datastructure, use
>> the record name to call RecordName:pretty_print/1. Things such as the
>> shell or io:format could then use this interface to print truely
>> pretty versions of derived types (if such is provided).
>>
>> Side discussion:
>>
>> Actually, a pretty_print would probably need to take more arguments
>> then just the data structure; it would probably need to be passed
>> information such as the width of the left margin and the wrap length.
>>
>> Alternatively, instead of "pretty printing", a form could be returned
>> which would represent how to reproduce the data structure. This would
>> serve the dual purpose of being much easier for end users to read, as
>> well as being immediately copy/paste-able. For an example of what this
>> would look like, dict might return: "{dict, from_list, [[{color, red},
>> {size, 5}]]}" for my earlier example. io:format (and friends) of
>> course could then easily print this as "dict:from_list([{color, red},
>> {size, 5}])".
>>
>> Thoughts?
>> sRp
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://www.erlang.org/mailman/listinfo/erlang-questions
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>


From mickael.remond@REDACTED  Wed May 21 08:26:18 2008
From: mickael.remond@REDACTED (=?UTF-8?Q?Micka=C3=ABl_R=C3=A9mond?=)
Date: Wed, 21 May 2008 08:26:18 +0200
Subject: [erlang-questions] Feature request: save shell history
Message-ID: 

Hello,

I have a simple feature request: It would be nice to save the Erlang  
shell history to be able to reuse commands from previous shell  
sessions (Something like .bash_history). I a often frustrated to have  
written recently a nice one liner, left the session and closed the  
terminal for a while and then realize that I would need that one liner  
command again.

It can help command line administration of Erlang application in my  
opinion :)

-- 
Micka?l R?mond
  http://www.process-one.net/



-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From tuncer.ayaz@REDACTED  Wed May 21 08:51:11 2008
From: tuncer.ayaz@REDACTED (Tuncer Ayaz)
Date: Wed, 21 May 2008 08:51:11 +0200
Subject: [erlang-questions] rsync-like function in Erlang?
In-Reply-To: <1211321249.4502.15.camel@piko.site>
References: <351ce2d70805171433y3d179240wd0adcc3b38ac6cbd@mail.gmail.com>
	<1c3be50f0805200608r504dfb80w1b25bb389a36ac7d@mail.gmail.com>
	<351ce2d70805201345x69f01612v323de6a140ae6025@mail.gmail.com>
	<4ac8254d0805201423l7e4037d1td9474cd125e3d32e@mail.gmail.com>
	<1211321249.4502.15.camel@piko.site>
Message-ID: <4ac8254d0805202351t52e4577dncbbff9cbe19541d9@mail.gmail.com>

On Wed, May 21, 2008 at 12:07 AM, Alp?r J?ttner  wrote:
>> > Does Git work well on Windows? And can it operate in client-server
>> > fashion, or does it need filesystem access between the machines?
>>
>> Git works on Windows but not yet quite as good as on the _you know
>> where it originated :D_ OS
>
> What about using Mercurial instead? Its performance and feature set is
> more or less the same as of git, but it also has a good (and fast)
> native Windows support. Moreover, its user interface is also considered
> to be easier and cleaner, and it is very well documented.

Hg (Mercurial) is good enough and the ui of Git is
only considered hard because all the internal commands are
visible in your normal PATH. If you need to accomplish
something complicated it's good to have the commands
and if you can't ignore them it makes Git look complex.

For a decent comparison have a look at the following article:
http://www.infoq.com/articles/dvcs-guide


From ulf.wiger@REDACTED  Wed May 21 09:20:05 2008
From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB))
Date: Wed, 21 May 2008 09:20:05 +0200
Subject: [erlang-questions] proposal: pretty printing through
	polymorphism
In-Reply-To: 
References: <88fce4d0805151959g7dc1449br3380678b372961c6@mail.gmail.com>	
	<4831404F.2040608@ericsson.com>
	
Message-ID: <4833CD25.8050005@ericsson.com>

Eric Merritt skrev:
> I think this is probably worth more then simple shell
 > printing. Having usefully printed data structures in
 > logs, etc would probably be pretty useful. Though
 > implementing it all over the place would probably be
> non-trivial.

The shell pretty-printing could be generalized, though.
It uses a function called io_lib_pretty:print/5, and
if there were an easy way to call on a library function
that automatically uses the pretty-printing functions
loaded into the shell, it could be used from anywhere.

One annoying part of this is trying to find the shell
instance. I wrote about this in my gproc paper, partly
as a small step in this direction:

http://svn.ulf.wiger.net/gproc/doc/erlang07-wiger.pdf

Another alternative is of course to lift the implementation
of custom pretty-printing out of the shell module and
making a general library out of it. It would be reasonable
to also extent ADT modules with a pretty_print() hook,
but the thing that the shell pretty-printing does is
also to recognize an ADT when it appears inside a larger
structure.

Another area where ROK's abstract patterns would come in
handy, perhaps?  (:

BR,
Ulf W


> 
> On Mon, May 19, 2008 at 1:54 AM, Ulf Wiger (TN/EAB)
>  wrote:
>> A while back, I hacked the Erlang shell in order to
>> allow custom pretty-printing:
>>
>> http://ulf.wiger.net/weblog/2007/11/20/extending-the-erlang-shell-part-1/
>>
>> You can find the code here:
>>
>> svn co http://svn.ulf.wiger.net/ext_shell/trunk
>>
>> The trunk is for R12B. See also
>>
>> http://svn.ulf.wiger.net/ext_shell/branches/r11b/
>> http://svn.ulf.wiger.net/ext_shell/branches/r12b/
>>
>> Please feel free to play around with it and propose
>> improvements.
>>
>> BR,
>> Ulf W
>>
>> Scott Parish skrev:
>>> Problem:
>>>
>>> Right now pretty printing values shows the lowest layer data
>>> structures. This is ugly and usually not what an end user wants/needs
>>> to see. For instance:
>>>
>>> 1> dict:store(color, red, dict:store(size, 5, dict:new())).
>>> {dict,2,
>>>       16,
>>>       16,
>>>       8,
>>>       80,
>>>       48,
>>>       {[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]},
>>>       {{[],[],[[color|red]],[],[],[[size|5]],[],[],[],[],[],[],[],[],[],[]}}}
>>>
>>> Solution:
>>>
>>> The proposed solution would take advantage of the type of polymorphism
>>> suggested in my prior email. Namely, there would be a function such as
>>> string:pretty_print/1 which would take a derived datastructure, use
>>> the record name to call RecordName:pretty_print/1. Things such as the
>>> shell or io:format could then use this interface to print truely
>>> pretty versions of derived types (if such is provided).
>>>
>>> Side discussion:
>>>
>>> Actually, a pretty_print would probably need to take more arguments
>>> then just the data structure; it would probably need to be passed
>>> information such as the width of the left margin and the wrap length.
>>>
>>> Alternatively, instead of "pretty printing", a form could be returned
>>> which would represent how to reproduce the data structure. This would
>>> serve the dual purpose of being much easier for end users to read, as
>>> well as being immediately copy/paste-able. For an example of what this
>>> would look like, dict might return: "{dict, from_list, [[{color, red},
>>> {size, 5}]]}" for my earlier example. io:format (and friends) of
>>> course could then easily print this as "dict:from_list([{color, red},
>>> {size, 5}])".
>>>
>>> Thoughts?
>>> sRp
>>> _______________________________________________
>>> erlang-questions mailing list
>>> erlang-questions@REDACTED
>>> http://www.erlang.org/mailman/listinfo/erlang-questions
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://www.erlang.org/mailman/listinfo/erlang-questions
>>


From john.hughes@REDACTED  Wed May 21 09:25:32 2008
From: john.hughes@REDACTED (John Hughes)
Date: Wed, 21 May 2008 09:25:32 +0200
Subject: [erlang-questions] What tools do you use to develop Erlang code?
Message-ID: <14f001c8bb13$db9b9b40$92d2d1c0$@hughes@quviq.com>

Here's a chance to tell the world which tools you like best for developing
Erlang code! I've put together a short questionnaire that asks about
editors, test tools, and version control systems. You can find it-together
with the answers so far-at 

 

http://www.cs.chalmers.se/~rjmh/ErlangSurvey/ErlangUsers.cgi

 

Please take a couple of minutes to complete it-it won't take longer than
that, I promise! 

 

The motivation for doing this is the ProTest project
(www.protest-project.eu), which is building Erlang development tools-this
survey will tell us which tools it's most valuable to integrate with.

 

Thanks to all those who made useful suggestions to me over the last couple
of days. I've added many tools in response, added questions about version
control systems, and made all the tool lists extensible-so you can add your
favourite even if I didn't!

 

Now click the link and fill in the form..

 

http://www.cs.chalmers.se/~rjmh/ErlangSurvey/ErlangUsers.cgi

 

Thanks!

 

John

-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From sverker@REDACTED  Wed May 21 09:55:53 2008
From: sverker@REDACTED (Sverker Eriksson)
Date: Wed, 21 May 2008 09:55:53 +0200
Subject: [erlang-questions] zlib deflate problem
In-Reply-To: 
References: 		<24d4f39c0805201043m73cee5a8xe37299270466cd22@mail.gmail.com>
	
Message-ID: <4833D589.4070200@erix.ericsson.se>

Matthew Dempsky wrote:
> On Tue, May 20, 2008 at 10:43 AM, Colm Dougan  wrote:
>   
>> Matthew - I tried your patch and it worked.   I don't see any
>> regression but I haven't done extensive testing. If you think this is
>> the appropriate fix (rather than an exploratory patch) then I can
>> install the patched erlang on my running system and do more testing.
>>     
>
> I think it should be safe for more testing.
>
>   
Hi guys

I've been looking at your patch Matthew, trying to understand it to 
decide if it should be part of the next OTP release. Do you have any 
more arguments why this would be the right way to do it?

> --- zlib_drv.c.orig	2008-05-19 19:09:00.000000000 -0700
> +++ zlib_drv.c	2008-05-19 19:09:12.000000000 -0700
> @@ -257,6 +257,10 @@
>  		driver_deq(d->port, len);
>  		return res;
>  	    }
> +	    if (res == Z_BUF_ERROR) {
> +		res = Z_OK;
> +	    }
>  	    if (res < 0) {
>  		return res;
>  	    }

As I understand it, a return of Z_BUF_ERROR from inflate() means 
something like "call me again with more buffer space". But in this case 
we don't call again.

Do you have any more light to shed?

/Sverker, Erlang/OTP Ericsson



From lemenkov@REDACTED  Wed May 21 10:32:17 2008
From: lemenkov@REDACTED (Peter Lemenkov)
Date: Wed, 21 May 2008 12:32:17 +0400
Subject: [erlang-questions] Feature request: save shell history
In-Reply-To: 
References: 
Message-ID: 

2008/5/21 Micka?l R?mond :
> Hello,
> I have a simple feature request: It would be nice to save the Erlang shell
> history to be able to reuse commands from previous shell sessions

Very useful and long-awaited feature!

+1 to request.
-- 
With best regards!

From martin@REDACTED  Wed May 21 12:59:23 2008
From: martin@REDACTED (Martin Carlson)
Date: Wed, 21 May 2008 11:59:23 +0100
Subject: [erlang-questions] New postgres driver (0.1.3)
Message-ID: <20080521105923.GH3275@martins-desktop.office.erlangsystems.com>

Hi all,

There is a new version of the driver available for download on:
http://www.erlang-consulting.com/erlang/opensource.html.

Fixes the silent boot-up when authentication fail as well as a bug where only one connection was created towards the database regardless of what the pool size was.

Note:
Make sure the database uses MD5 authentication or you will not be able to authenticate. This is a limitation in the driver.

//Martin



From juanjo@REDACTED  Wed May 21 17:00:00 2008
From: juanjo@REDACTED (Juan Jose Comellas)
Date: Wed, 21 May 2008 12:00:00 -0300
Subject: [erlang-questions] rsync-like function in Erlang?
In-Reply-To: <351ce2d70805201345x69f01612v323de6a140ae6025@mail.gmail.com>
References: <351ce2d70805171433y3d179240wd0adcc3b38ac6cbd@mail.gmail.com>
	<1c3be50f0805200608r504dfb80w1b25bb389a36ac7d@mail.gmail.com>
	<351ce2d70805201345x69f01612v323de6a140ae6025@mail.gmail.com>
Message-ID: <1c3be50f0805210800g4b0ecd31u96a5bc431beccce7@mail.gmail.com>

The problem is that if you use Subversion you lose the ability to easily
merge changes made across different servers. In my case this won't happen
very often, but I do need to have the option of doing it when two servers
"sharing" the same filesystem can't see each other and have to perform
simultaneous changes on the same files.

Git works on Windows, but not as good as it does on Linux. My problem, for
the time being, is restricted to Linux so it is not a problem.



On Tue, May 20, 2008 at 5:45 PM, Johan Holmberg  wrote:

> 2008/5/20 Juan Jose Comellas :
> > Have you thought about using a distributed version control system such as
> > Git for this? I have the same problem, with the added need to track the
> > history of changes of each file, and I'm planning to build an Erlang
> wrapper
> > over Git. This wrapper could also provide a transactional interface to
> the
> > filesystem, giving you the ability to rollback to a previous version of
> the
> > file in case of a problem.
> >
>
> Interesting idea. I have thought about using Subversion (the version
> control system we normally use), but dismissed it as to complicated
> (with the need for a third machine, the Subversion-server, and with
> all the space overhead in the local .svn directories).
>
> Does Git work well on Windows? And can it operate in client-server
> fashion, or does it need filesystem access between the machines?
>
> Your kind of solution could perhaps suit me too, even if I'm not
> primarily interested in the change history.
>
> /Johan Holmberg
>
> >
> > On Sat, May 17, 2008 at 6:33 PM, Johan Holmberg 
> wrote:
> >>
> >> Hi!
> >>
> >> I have a number of Erlang-nodes running on different physical
> >> machines. I want each node to have a local copy of the same directory
> >> tree. Is there any existing Erlang-library that can do this?
> >>
> >> The erlang nodes I use can be on either Linux or Windows.
> >>
> >> I don't need an actual "rsync clone", just something that can make
> >> sure two directory trees on different machines stay in sync. And I
> >> would prefer that small changes to one of the trees were detected fast
> >> (like in rsync(1) or unison(1)).
> >>
> >> I realize that one solution would be to build some kind of wrapper in
> >> Erlang around rsync(1) or unison(1) (maybe such a thing already
> >> exist?) But I would prefer a pure Erlang solution if possible.
> >>
> >> /Johan Holmberg
> >> _______________________________________________
> >> erlang-questions mailing list
> >> erlang-questions@REDACTED
> >> http://www.erlang.org/mailman/listinfo/erlang-questions
> >
> >
> > _______________________________________________
> > erlang-questions mailing list
> > erlang-questions@REDACTED
> > http://www.erlang.org/mailman/listinfo/erlang-questions
> >
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From matthew@REDACTED  Wed May 21 18:06:39 2008
From: matthew@REDACTED (Matthew Dempsky)
Date: Wed, 21 May 2008 09:06:39 -0700
Subject: [erlang-questions] zlib deflate problem
In-Reply-To: <4833D589.4070200@erix.ericsson.se>
References: 
	
	<24d4f39c0805201043m73cee5a8xe37299270466cd22@mail.gmail.com>
	
	<4833D589.4070200@erix.ericsson.se>
Message-ID: 

On Wed, May 21, 2008 at 12:55 AM, Sverker Eriksson
 wrote:
> As I understand it, a return of Z_BUF_ERROR from inflate() means
> something like "call me again with more buffer space". But in this case
> we don't call again.

zlib.h says "inflate() returns [...] Z_BUF_ERROR if no progress is
possible or if there was not enough room in the output buffer when
Z_FINISH is used."  zlib_drv.c calls inflate() with  with Z_NO_FLUSH,
not Z_FINISH, so Z_BUF_ERROR can only indicate no progress was
possible, which will be correctly handled by noticing that avail_out
!= 0.

(However, it now seems suspicious to me now that the flush argument to
zlib_inflate() is unused.)


From matthew@REDACTED  Wed May 21 18:14:08 2008
From: matthew@REDACTED (Matthew Dempsky)
Date: Wed, 21 May 2008 09:14:08 -0700
Subject: [erlang-questions] zlib deflate problem
In-Reply-To: 
References: 
	
	<24d4f39c0805201043m73cee5a8xe37299270466cd22@mail.gmail.com>
	
	<4833D589.4070200@erix.ericsson.se>
	
Message-ID: 

On Wed, May 21, 2008 at 9:06 AM, Matthew Dempsky  wrote:
> (However, it now seems suspicious to me now that the flush argument to
> zlib_inflate() is unused.)

Actually, this seems fine since the zlib module interface doesn't give
any control over the flush argument.  However, it might be misleading
that zlib:inflate/2 passed Z_NO_FLUSH to the zlib driver, which
unpacks it and passes it to zlib_inflate, but then zlib_inflate uses
Z_SYNC_FLUSH.


From james.hague@REDACTED  Wed May 21 18:58:14 2008
From: james.hague@REDACTED (James Hague)
Date: Wed, 21 May 2008 11:58:14 -0500
Subject: [erlang-questions] [Announce] Erlbol: Erlang <--> REBOL
	interface
In-Reply-To: <4832CCA4.5080604@gmail.com>
References: <4832CCA4.5080604@gmail.com>
Message-ID: 

REBOL is an excellent tool for creating user interfaces, so this is
something that I'm very interested in.  Nicely done!

It would be interesting to write a front end for the Erlang shell
itself in REBOL.  The werl.exe interface is functional, but a pain to
change because it's rolled into the same executable as BEAM.


From exta7@REDACTED  Wed May 21 19:22:25 2008
From: exta7@REDACTED (Zvi)
Date: Wed, 21 May 2008 10:22:25 -0700 (PDT)
Subject: [erlang-questions] Feature request: save shell history
In-Reply-To: 
References: 
Message-ID: <17364524.post@talk.nabble.com>


I have the opposite shell feature request, something, like  "Clear Screen" -
cls(). To remove the clutter from the shell window - at least for werl.exe
on Windows.


Erlang (BEAM) emulator version 5.6.2 [smp:2] [async-threads:0]

Eshell V5.6.2  (abort with ^G)
1> os:cmd("cls").
"\f"
2> io:format("\f").
^Lok
3> 


Micka?l R?mond-3 wrote:
> 
> Hello,
> 
> I have a simple feature request: It would be nice to save the Erlang  
> shell history to be able to reuse commands from previous shell  
> sessions (Something like .bash_history). I a often frustrated to have  
> written recently a nice one liner, left the session and closed the  
> terminal for a while and then realize that I would need that one liner  
> command again.
> 
> It can help command line administration of Erlang application in my  
> opinion :)
> 
> -- 
> Micka?l R?mond
>   http://www.process-one.net/
> 
> 
> 
> 
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
> 

-- 
View this message in context: http://www.nabble.com/Feature-request%3A-save-shell-history-tp17356782p17364524.html
Sent from the Erlang Questions mailing list archive at Nabble.com.



From johan556@REDACTED  Wed May 21 20:42:14 2008
From: johan556@REDACTED (Johan Holmberg)
Date: Wed, 21 May 2008 20:42:14 +0200
Subject: [erlang-questions] Relocating Erlang installation on Windows?
Message-ID: <351ce2d70805211142v3ad7df8fj127ab5c2fc08261a@mail.gmail.com>

Hi!

I had hoped that a Windows installation of Erlang could be moved to
another place in the filesystem and still work. But I just found out
that a file "erl.ini" contains absolute paths to the original
installation directory.

I wonder if there is some way of getting the installation "position
independent"?

And are there other places beside the "erl.ini" file where absolute
paths to the original installation directory are stored?

I want to be able to check in an Erlang installation in for example
Subversion, and have users check out the directory tree *without*
requiring each user to place the files in the same place in the
filesystem.

/Johan Holmberg


From james.hague@REDACTED  Wed May 21 20:51:38 2008
From: james.hague@REDACTED (James Hague)
Date: Wed, 21 May 2008 13:51:38 -0500
Subject: [erlang-questions] Feature request: save shell history
In-Reply-To: <17364524.post@talk.nabble.com>
References: 
	<17364524.post@talk.nabble.com>
Message-ID: 

And *please*, save window size and position for werl.exe.


From johan556@REDACTED  Wed May 21 21:01:42 2008
From: johan556@REDACTED (Johan Holmberg)
Date: Wed, 21 May 2008 21:01:42 +0200
Subject: [erlang-questions] "open_port" problem on Windows
	(DETACHED_PROCESS)
In-Reply-To: <351ce2d70805140201x156b52c4j81839f11c55442a6@mail.gmail.com>
References: <351ce2d70805140201x156b52c4j81839f11c55442a6@mail.gmail.com>
Message-ID: <351ce2d70805211201o321e66c9q5d63473f3f99900d@mail.gmail.com>

On Wed, May 14, 2008 at 11:01 AM, Johan Holmberg  wrote:
>
> I'm trying to use Erlang to run/control an existing application. I use
> "open_port" to start the application, and communicate by
> reading/writing to the STDIN/STDOUT of the application.
[...]
> My application starts other processes (compilers, linkers, ...), and
> *each invocation* of these creates a new console window. So I get
> hundreds of console windows that only exist for a short time.
[...]
> I would appreciate any hints about what to do to avoid all the extra
> consoles. Maybe I have missed some way of affecting how "open_port"
> works?
>

Richard Carlsson showed me an undocumented option to "open_port"
called "hide". Setting this option causes CreateProcess to be called
with the SW_HIDE flag. With this option, I don't see all the windows
any more. But I guess they are still created by Windows, just not
shown.

> (Currently I'm considering trying to build Erlang myself, and change
> the CreateProcess call to not use DETACHED_PROCESS).
>

I actually did build Erlang from source too, to be able to experiment
with running Erlang without the DETACHED_PROCESS option. I added an
option {detached, true/false} to "open_port", so I could choose at
runtime if I wanted the DETACHED_PROCESS option or not.

Currently I use {detached, false} when running my application. My gut
feeling is that this is better than using the "hide" option when
running "erl" in a console. It seems wrong to me that a console
application should be forced to deal with "windows stuff"
unnecessarily.

 /Johan Holmberg


From mcanato@REDACTED  Wed May 21 21:12:59 2008
From: mcanato@REDACTED (Matteo)
Date: Wed, 21 May 2008 21:12:59 +0200
Subject: [erlang-questions] Erlang regex
Message-ID: 

Hi to all,
i'm a noob of erlang programming. I would like to have some infos about
extracting a substring from a string....
Or better, my situation is this:

i have a string:
str="OK 01 xxxxxxxx\r\n"); // where xxxxxxxx is a string that i dont know
and every time change...

and i need to extract the "xxxxxxx" into another string (str2 for exaple).

Sorry for my english.

Best regards
M.Canato
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From pablo.polvorin@REDACTED  Wed May 21 21:48:52 2008
From: pablo.polvorin@REDACTED (Pablo Polvorin)
Date: Wed, 21 May 2008 16:48:52 -0300
Subject: [erlang-questions] Erlang regex
In-Reply-To: 
References: 
Message-ID: <1ffe809c0805211248i1afc64b9vc14b1f715fee6eae@mail.gmail.com>

Hello,
instead of regular expression, I would suggest to use pattern matching instead:
1> A = <<"OK 01 xxxxxxxx\r\n">>.
<<"OK 01 xxxxxxxx\r\n">>
2> <<"OK 01",X/binary>> = A.
<<"OK 01 xxxxxxxx\r\n">>
3> X.
<<" xxxxxxxx\r\n">>

besides that, if what you are parsing is some sort of network
protocol, you won't want to represent strings as lists(), but use
binaries like in the previous example.


2008/5/21, Matteo :
> Hi to all,
> i'm a noob of erlang programming. I would like to have some infos about
> extracting a substring from a string....
> Or better, my situation is this:
>
> i have a string:
> str="OK 01 xxxxxxxx\r\n"); // where xxxxxxxx is a string that i dont know
> and every time change...
>
> and i need to extract the "xxxxxxx" into another string (str2 for exaple).
>
> Sorry for my english.
>
> Best regards
> M.Canato
>


-- 
--
pablo
http://ppolv.wordpress.com
----


From igorrs@REDACTED  Wed May 21 21:56:19 2008
From: igorrs@REDACTED (Igor Ribeiro Sucupira)
Date: Wed, 21 May 2008 16:56:19 -0300
Subject: [erlang-questions] Erlang regex
In-Reply-To: 
References: 
Message-ID: 

2008/5/21 Matteo :
> Hi to all,
> i'm a noob of erlang programming. I would like to have some infos about
> extracting a substring from a string....
> Or better, my situation is this:
>
> i have a string:
> str="OK 01 xxxxxxxx\r\n"); // where xxxxxxxx is a string that i dont know


Is this "OK 01 " fixed? If it is, you could just do:
UnknownPart = lists:nthtail(6, Str)

If it's not, please explain what you need.

Also take a look at the regexp module.

Igor.

> and every time change...
>
> and i need to extract the "xxxxxxx" into another string (str2 for exaple).
>
> Sorry for my english.
>
> Best regards
> M.Canato
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>


From mcanato@REDACTED  Wed May 21 21:57:36 2008
From: mcanato@REDACTED (Matteo)
Date: Wed, 21 May 2008 21:57:36 +0200
Subject: [erlang-questions] Erlang regex
In-Reply-To: <1ffe809c0805211248i1afc64b9vc14b1f715fee6eae@mail.gmail.com>
References: 
	<1ffe809c0805211248i1afc64b9vc14b1f715fee6eae@mail.gmail.com>
Message-ID: 

Hi Pablo,
thanks for the quick reply!
You have understand exactly my problem: i'm reading the data from a custom
network protocol.

So i will use the binaries.
Thanks again,
M.Canato



On Wed, May 21, 2008 at 9:48 PM, Pablo Polvorin 
wrote:

> Hello,
> instead of regular expression, I would suggest to use pattern matching
> instead:
> 1> A = <<"OK 01 xxxxxxxx\r\n">>.
> <<"OK 01 xxxxxxxx\r\n">>
> 2> <<"OK 01",X/binary>> = A.
> <<"OK 01 xxxxxxxx\r\n">>
> 3> X.
> <<" xxxxxxxx\r\n">>
>
> besides that, if what you are parsing is some sort of network
> protocol, you won't want to represent strings as lists(), but use
> binaries like in the previous example.
>
>
> 2008/5/21, Matteo :
> > Hi to all,
> > i'm a noob of erlang programming. I would like to have some infos about
> > extracting a substring from a string....
> > Or better, my situation is this:
> >
> > i have a string:
> > str="OK 01 xxxxxxxx\r\n"); // where xxxxxxxx is a string that i dont know
> > and every time change...
> >
> > and i need to extract the "xxxxxxx" into another string (str2 for
> exaple).
> >
> > Sorry for my english.
> >
> > Best regards
> > M.Canato
> >
>
>
> --
> --
> pablo
> http://ppolv.wordpress.com
> ----
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From igorrs@REDACTED  Wed May 21 22:02:08 2008
From: igorrs@REDACTED (Igor Ribeiro Sucupira)
Date: Wed, 21 May 2008 17:02:08 -0300
Subject: [erlang-questions] Erlang regex
In-Reply-To: <1ffe809c0805211248i1afc64b9vc14b1f715fee6eae@mail.gmail.com>
References: 
	<1ffe809c0805211248i1afc64b9vc14b1f715fee6eae@mail.gmail.com>
Message-ID: 

On Wed, May 21, 2008 at 4:48 PM, Pablo Polvorin
 wrote:
> Hello,
> instead of regular expression, I would suggest to use pattern matching instead:
> 1> A = <<"OK 01 xxxxxxxx\r\n">>.
> <<"OK 01 xxxxxxxx\r\n">>
> 2> <<"OK 01",X/binary>> = A.

List equivalent would be something like:
"OK 01 " ++ UnknownPart = Str

The difference from my other suggestion would be that you're now
checking if the strings starts with "OK 01 ", instead of just cropping
the first 6 characters.

Igor.

> <<"OK 01 xxxxxxxx\r\n">>
> 3> X.
> <<" xxxxxxxx\r\n">>
>
> besides that, if what you are parsing is some sort of network
> protocol, you won't want to represent strings as lists(), but use
> binaries like in the previous example.
>
>
> 2008/5/21, Matteo :
>> Hi to all,
>> i'm a noob of erlang programming. I would like to have some infos about
>> extracting a substring from a string....
>> Or better, my situation is this:
>>
>> i have a string:
>> str="OK 01 xxxxxxxx\r\n"); // where xxxxxxxx is a string that i dont know
>> and every time change...
>>
>> and i need to extract the "xxxxxxx" into another string (str2 for exaple).
>>
>> Sorry for my english.
>>
>> Best regards
>> M.Canato
>>
>
>
> --
> --
> pablo
> http://ppolv.wordpress.com
> ----
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>


From mcanato@REDACTED  Wed May 21 22:13:45 2008
From: mcanato@REDACTED (Matteo)
Date: Wed, 21 May 2008 22:13:45 +0200
Subject: [erlang-questions] Erlang regex
In-Reply-To: 
References: 
	<1ffe809c0805211248i1afc64b9vc14b1f715fee6eae@mail.gmail.com>
	
Message-ID: 

On Wed, May 21, 2008 at 10:02 PM, Igor Ribeiro Sucupira 
wrote:

> On Wed, May 21, 2008 at 4:48 PM, Pablo Polvorin
>  wrote:
> > Hello,
> > instead of regular expression, I would suggest to use pattern matching
> instead:
> > 1> A = <<"OK 01 xxxxxxxx\r\n">>.
> > <<"OK 01 xxxxxxxx\r\n">>
> > 2> <<"OK 01",X/binary>> = A.
>
> List equivalent would be something like:
> "OK 01 " ++ UnknownPart = Str
>
> The difference from my other suggestion would be that you're now
> checking if the strings starts with "OK 01 ", instead of just cropping
> the first 6 characters.



Hi,
only with OK 01 i've to read the next chars. In my other protocol i've got
other OK response but they are use for tracing the state of my app, and i
don't need to read the other chars.

M.Canato





>
>
> Igor.
>
> > <<"OK 01 xxxxxxxx\r\n">>
> > 3> X.
> > <<" xxxxxxxx\r\n">>
> >
> > besides that, if what you are parsing is some sort of network
> > protocol, you won't want to represent strings as lists(), but use
> > binaries like in the previous example.
> >
> >
> > 2008/5/21, Matteo :
> >> Hi to all,
> >> i'm a noob of erlang programming. I would like to have some infos about
> >> extracting a substring from a string....
> >> Or better, my situation is this:
> >>
> >> i have a string:
> >> str="OK 01 xxxxxxxx\r\n"); // where xxxxxxxx is a string that i dont
> know
> >> and every time change...
> >>
> >> and i need to extract the "xxxxxxx" into another string (str2 for
> exaple).
> >>
> >> Sorry for my english.
> >>
> >> Best regards
> >> M.Canato
> >>
> >
> >
> > --
> > --
> > pablo
> > http://ppolv.wordpress.com
> > ----
> > _______________________________________________
> > erlang-questions mailing list
> > erlang-questions@REDACTED
> > http://www.erlang.org/mailman/listinfo/erlang-questions
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From igorrs@REDACTED  Wed May 21 22:29:52 2008
From: igorrs@REDACTED (Igor Ribeiro Sucupira)
Date: Wed, 21 May 2008 17:29:52 -0300
Subject: [erlang-questions] erlang:monitor() lag time: how long to
	expect?
In-Reply-To: <65929.1210811429@snookles.snookles.com>
References: <65929.1210811429@snookles.snookles.com>
Message-ID: 

I don't know the reason for the delay, but you shouldn't be trying to
monitor something that does not exist.

>From the man pages:
"When a process is monitored by registered name, the process that has
the registered name at the time when erlang:monitor/2 is called will
be monitored. The monitor will not be effected, if the registered name
is unregistered."

Igor.

On Wed, May 14, 2008 at 9:30 PM, Scott Lystig Fritchie
 wrote:
> Hi, I've discovered that the lag time between calling erlang:monitor()
> and receiving the {'DOWN', ...} message.  I'd like to ask how long is
> reasonable to wait?
>
> The proc I'm monitoring is on a remote node, and I'm monitoring it via
> erlang:monitor(process, {registered_name_atom(), node_atom()}).  I have
> two Erlang nodes, A & B, on two separate physical machines.  Both are
> running R11B-5 on top of Linux, "erl -kernel net_ticktime 60 ...".
>
>   1. B is quite busy doing stuff, but it's responding to
>      gen_server:call() queries within the default 5 seconds.
>
>   2. On A, I call monitor/2 for a process, my_server_proc, that hasn't
>      started yet on B.
>
>   3. 31 seconds later, B starts & registers the proc I want to monitor
>
>   4. 32 seconds later, A gets a {'DOWN', ...} message for step #2's
>      monitor.
>
> I suppose I shouldn't be monitoring a proc that hasn't been started
> yet.  ("Doctor, it hurts when ...")  And there's a work-around, I
> suppose: use rpc:call(node_B, erlang, whereis, [my_server_proc]) to
> verify that the server is actually running.
>
> Has anyone else run into seemingly long-delayed {'DOWN', ...} messages?
>
> -Scott
>
> --- snip --- snip --- snip --- snip --- snip --- snip ---
>
> node A : 20080514162806 : make_monitor 1: {my_server_proc,'test@REDACTED'} ref #Ref<0.0.0.247945>
>
> node B : 20080514162837 : progress: [{supervisor,{local,foo_foo_sup}},{started,[{pid,<0.324.0>},{name,my_server_proc},{mfa,{foo_server,start_link,...
>
> node A : 20080514162857 : gen_server:call({my_server_proc,'test@REDACTED'}, bar) returned ok
>
> node A : 20080514162909 : got 'DOWN': my_server_proc Mref #Ref<0.0.0.247945>, Type process, Object {my_server_proc,'test@REDACTED'}, Info noproc


From igorrs@REDACTED  Wed May 21 22:41:48 2008
From: igorrs@REDACTED (Igor Ribeiro Sucupira)
Date: Wed, 21 May 2008 17:41:48 -0300
Subject: [erlang-questions] Erlang regex
In-Reply-To: 
References: 
	<1ffe809c0805211248i1afc64b9vc14b1f715fee6eae@mail.gmail.com>
	
	
Message-ID: 

OK. So (you probably already know that) you should be fine with
something like this:

case BinStr of
    <<"OK 01 ", Rest/binary>> -> doSomethingWithRest;
    _ -> do_nothing
end.

On Wed, May 21, 2008 at 5:13 PM, Matteo  wrote:
>
>
> On Wed, May 21, 2008 at 10:02 PM, Igor Ribeiro Sucupira 
> wrote:
>>
>> On Wed, May 21, 2008 at 4:48 PM, Pablo Polvorin
>>  wrote:
>> > Hello,
>> > instead of regular expression, I would suggest to use pattern matching
>> > instead:
>> > 1> A = <<"OK 01 xxxxxxxx\r\n">>.
>> > <<"OK 01 xxxxxxxx\r\n">>
>> > 2> <<"OK 01",X/binary>> = A.
>>
>> List equivalent would be something like:
>> "OK 01 " ++ UnknownPart = Str
>>
>> The difference from my other suggestion would be that you're now
>> checking if the strings starts with "OK 01 ", instead of just cropping
>> the first 6 characters.
>
> Hi,
> only with OK 01 i've to read the next chars. In my other protocol i've got
> other OK response but they are use for tracing the state of my app, and i
> don't need to read the other chars.
>
> M.Canato
>
>
>
>
>>
>> Igor.
>>
>> > <<"OK 01 xxxxxxxx\r\n">>
>> > 3> X.
>> > <<" xxxxxxxx\r\n">>
>> >
>> > besides that, if what you are parsing is some sort of network
>> > protocol, you won't want to represent strings as lists(), but use
>> > binaries like in the previous example.
>> >
>> >
>> > 2008/5/21, Matteo :
>> >> Hi to all,
>> >> i'm a noob of erlang programming. I would like to have some infos about
>> >> extracting a substring from a string....
>> >> Or better, my situation is this:
>> >>
>> >> i have a string:
>> >> str="OK 01 xxxxxxxx\r\n"); // where xxxxxxxx is a string that i dont
>> >> know
>> >> and every time change...
>> >>
>> >> and i need to extract the "xxxxxxx" into another string (str2 for
>> >> exaple).
>> >>
>> >> Sorry for my english.
>> >>
>> >> Best regards
>> >> M.Canato
>> >>
>> >
>> >
>> > --
>> > --
>> > pablo
>> > http://ppolv.wordpress.com
>> > ----
>> > _______________________________________________
>> > erlang-questions mailing list
>> > erlang-questions@REDACTED
>> > http://www.erlang.org/mailman/listinfo/erlang-questions
>> >
>
>


From pablo.polvorin@REDACTED  Wed May 21 23:06:31 2008
From: pablo.polvorin@REDACTED (Pablo Polvorin)
Date: Wed, 21 May 2008 18:06:31 -0300
Subject: [erlang-questions] Feature request: save shell history
In-Reply-To: 
References: 
	<17364524.post@talk.nabble.com>
	
Message-ID: <1ffe809c0805211406kdc1f446q5f099265c4507494@mail.gmail.com>

Hello,
in the meantime, you can "rlwrap" the old shell:
rlwrap erl -oldshell

actually I never used that trick, but seems quite useful (its even possible
to do CTRL-R  to search in the history).
On the other side, tab-completion won't work, and I don't know what the
limitations of the -oldshell are.



2008/5/21 James Hague :

> And *please*, save window size and position for werl.exe.
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>



-- 
--
pablo
http://ppolv.wordpress.com
----
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From erlang@REDACTED  Wed May 21 23:28:06 2008
From: erlang@REDACTED (Dominic Williams)
Date: Wed, 21 May 2008 23:28:06 +0200
Subject: [erlang-questions] Design strategies for a test suite
In-Reply-To: <8f24f4b10805161253w1a85d67t34046d25796d9566@mail.gmail.com>
References: <8f24f4b10805161253w1a85d67t34046d25796d9566@mail.gmail.com>
Message-ID: <483493E6.3030904@dominicwilliams.net>

Hi John,

> I'm sort of torn on what I believe is the "appropriate"
> way to handle my new testing suite, with regards to
> dealing with export clauses.  I'm not sure how I feel
> about being unable to test non-exported functions.

Others have answered about /how/ you may test unexported
functions, so I thought I'd chip in to ask you /why/ you
would want to?

I could fairly be described as a test-driven development
fanatic, and I never ever ever do that. Never did in C++
either, BTW.

Regards,

Dominic Williams
http://dominicwilliams.net

----


From erlang@REDACTED  Wed May 21 23:37:00 2008
From: erlang@REDACTED (Dominic Williams)
Date: Wed, 21 May 2008 23:37:00 +0200
Subject: [erlang-questions] facebook chat server
In-Reply-To: 
References: 	<8209f740805151101u2ce8d7ddxfaef2702f662ae15@mail.gmail.com>		
	
Message-ID: <483495FC.2010007@dominicwilliams.net>

Hi Kevin,

Kevin A. Smith a ?crit :
> I like Thrift because there's no ORB, the client/server
> model is actually pretty sane, and the IDL strikes the
> right balance between completeness and usefulness. I can
> actually read the source to Thrift and understand what
> the code is doing. The last time I did anything with
> CORBA (around the late 1990's) it was all so complicated
> and difficult to use. It seemed like "Hello, World"
> required a ton of infrastructure and 100 lines of code.
> IMHO SOAP is just as bad with all the WS-* madness and
> lack of interop between impls.

Back in the late nineties, were you using CORBA from C or C++?

I have not looked at Thrift, but using CORBA from Python and
Erlang is a breeze. Even the Java binding is quite nice,
certainly a lot simpler than C++.

Regards,

Dominic Williams
http://dominicwilliams.net

----


From per@REDACTED  Wed May 21 23:38:37 2008
From: per@REDACTED (Per Hedeland)
Date: Wed, 21 May 2008 23:38:37 +0200 (CEST)
Subject: [erlang-questions] erlang:monitor() lag time: how long to
	expect?
In-Reply-To: 
Message-ID: <200805212138.m4LLcbqS026215@pluto.hedeland.org>

"Igor Ribeiro Sucupira"  wrote:
>
>I don't know the reason for the delay, but you shouldn't be trying to
>monitor something that does not exist.

Maybe you "shouldn't be trying", but it *must* be OK to do that,
otherwise monitor() would be near useless - you would always have to
(somehow) check that the process still existed after calling monitor().

1> register(foo, spawn(fun() -> timer:sleep(100) end)).
true
2> erlang:monitor(process, foo).   % took more than 100 ms to type:-)
#Ref<0.0.0.44>
3> flush().
Shell got {'DOWN',#Ref<0.0.0.44>,process,{foo,nonode@REDACTED},noproc}
ok

(Yes, you could use spawn_monitor() in the particular case that you are
spawning the process, but not in general.)

>>From the man pages:
>"When a process is monitored by registered name, the process that has
>the registered name at the time when erlang:monitor/2 is called will
>be monitored. The monitor will not be effected, if the registered name
>is unregistered."

Uh, I believe that just says that the monitoring continues even if the
name is unregistered - has no bearing on what happens when you try to
monitor something that doesn't exist in the first place. The relevant
part is in the next paragraph:

   A  'DOWN'  message will be sent to the monitoring process if Item dies,
   if Item does not exist, or if the connection is lost to the node  which
   ^^^^^^^^^^^^^^^^^^^^^^
   Item resides on. A 'DOWN' message has the following pattern:
   [snip]

I don't know the reason for Scott's delay either though...

--Per Hedeland



From kevin@REDACTED  Wed May 21 23:40:02 2008
From: kevin@REDACTED (Kevin A. Smith)
Date: Wed, 21 May 2008 17:40:02 -0400
Subject: [erlang-questions] facebook chat server
In-Reply-To: <483495FC.2010007@dominicwilliams.net>
References: 	<8209f740805151101u2ce8d7ddxfaef2702f662ae15@mail.gmail.com>		
	
	<483495FC.2010007@dominicwilliams.net>
Message-ID: <2CBBCB38-7789-440E-8BAA-5BA6DB5E6D55@hypotheticalabs.com>

How did you ever guess? :-) C++ and Java. And I still have the scars :(
On May 21, 2008, at 5:37 PM, Dominic Williams wrote:

> Hi Kevin,
>
> Kevin A. Smith a ?crit :
>> I like Thrift because there's no ORB, the client/server
>> model is actually pretty sane, and the IDL strikes the
>> right balance between completeness and usefulness. I can
>> actually read the source to Thrift and understand what
>> the code is doing. The last time I did anything with
>> CORBA (around the late 1990's) it was all so complicated
>> and difficult to use. It seemed like "Hello, World"
>> required a ton of infrastructure and 100 lines of code.
>> IMHO SOAP is just as bad with all the WS-* madness and
>> lack of interop between impls.
>
> Back in the late nineties, were you using CORBA from C or C++?
>
> I have not looked at Thrift, but using CORBA from Python and
> Erlang is a breeze. Even the Java binding is quite nice,
> certainly a lot simpler than C++.
>
> Regards,
>
> Dominic Williams
> http://dominicwilliams.net
>
> ----



From igorrs@REDACTED  Thu May 22 02:45:57 2008
From: igorrs@REDACTED (Igor Ribeiro Sucupira)
Date: Wed, 21 May 2008 21:45:57 -0300
Subject: [erlang-questions] erlang:monitor() lag time: how long to
	expect?
In-Reply-To: <200805212138.m4LLcbqS026215@pluto.hedeland.org>
References: 
	<200805212138.m4LLcbqS026215@pluto.hedeland.org>
Message-ID: 

On Wed, May 21, 2008 at 6:38 PM, Per Hedeland  wrote:
> "Igor Ribeiro Sucupira"  wrote:
>>
>>>From the man pages:
>>"When a process is monitored by registered name, the process that has
>>the registered name at the time when erlang:monitor/2 is called will
>>be monitored. The monitor will not be effected, if the registered name
>>is unregistered."
>
> Uh, I believe that just says that the monitoring continues even if the
> name is unregistered - has no bearing on what happens when you try to
> monitor something that doesn't exist in the first place. The relevant
> part is in the next paragraph:


Hum... that's correct. The first sentence had confused me. The
following paragraph (which I hadn't read  :p) makes it clear.

Igor.

>   A  'DOWN'  message will be sent to the monitoring process if Item dies,
>   if Item does not exist, or if the connection is lost to the node  which
>   ^^^^^^^^^^^^^^^^^^^^^^
>   Item resides on. A 'DOWN' message has the following pattern:
>   [snip]
>
> I don't know the reason for Scott's delay either though...
>
> --Per Hedeland


From vinoski@REDACTED  Thu May 22 04:56:16 2008
From: vinoski@REDACTED (Steve Vinoski)
Date: Wed, 21 May 2008 22:56:16 -0400
Subject: [erlang-questions] facebook chat server
In-Reply-To: <2CBBCB38-7789-440E-8BAA-5BA6DB5E6D55@hypotheticalabs.com>
References: 
	<8209f740805151101u2ce8d7ddxfaef2702f662ae15@mail.gmail.com>
	
	
	
	<483495FC.2010007@dominicwilliams.net>
	<2CBBCB38-7789-440E-8BAA-5BA6DB5E6D55@hypotheticalabs.com>
Message-ID: <65b2728e0805211956v3bb89b84q66a141721fce332b@mail.gmail.com>

This is getting off topic, but since it's CORBA I have to chime in. :-)

Doug Lea, Mark Linton, and I wrote the CORBA C++ mapping in the early
90s with hard-core C++ experts in mind. I can honestly say I've never
had any difficulty whatsoever with the C++ mapping. You might argue
that I have a big advantage since I helped write it, but I've gone
years without writing any CORBA code and have had zero trouble
recalling the C++ mapping rules again when necessary. There's a small
set of rules in the mapping that you need to learn; when you do so,
you find that it's all pretty consistent.

The Java mapping OTOH is a bit of a mess, because it's unlike any
normal Java coding or idioms. Java programmers have to resort to
different and somewhat unique approaches when they use that mapping.

What all those years of CORBA taught me, BTW, is that RPC, for a
number of reasons, is generally A Really Bad Idea. Call it a hard-won
lesson. The Erlang flavor of RPC is great because the entire Erlang
system has distribution fundamentally designed and built into it, but
for normal languages, RPC creates more problems than it solves.

--steve

On 5/21/08, Kevin A. Smith  wrote:
> How did you ever guess? :-) C++ and Java. And I still have the scars :(
>
> On May 21, 2008, at 5:37 PM, Dominic Williams wrote:
>
>  > Hi Kevin,
>  >
>  > Kevin A. Smith a ?crit :
>  >> I like Thrift because there's no ORB, the client/server
>  >> model is actually pretty sane, and the IDL strikes the
>  >> right balance between completeness and usefulness. I can
>  >> actually read the source to Thrift and understand what
>  >> the code is doing. The last time I did anything with
>  >> CORBA (around the late 1990's) it was all so complicated
>  >> and difficult to use. It seemed like "Hello, World"
>  >> required a ton of infrastructure and 100 lines of code.
>  >> IMHO SOAP is just as bad with all the WS-* madness and
>  >> lack of interop between impls.
>  >
>  > Back in the late nineties, were you using CORBA from C or C++?
>  >
>  > I have not looked at Thrift, but using CORBA from Python and
>  > Erlang is a breeze. Even the Java binding is quite nice,
>  > certainly a lot simpler than C++.
>  >
>  > Regards,
>  >
>  > Dominic Williams
>  > http://dominicwilliams.net
>  >
>  > ----
>
>  _______________________________________________
>  erlang-questions mailing list
>  erlang-questions@REDACTED
>  http://www.erlang.org/mailman/listinfo/erlang-questions
>


From ulf@REDACTED  Thu May 22 08:37:05 2008
From: ulf@REDACTED (Ulf Wiger)
Date: Thu, 22 May 2008 08:37:05 +0200
Subject: [erlang-questions] Call for Papers - CUFP 2008
In-Reply-To: <8209f740803311327t5fdacfddp7320fce3e03571f8@mail.gmail.com>
References: <8209f740803311327t5fdacfddp7320fce3e03571f8@mail.gmail.com>
Message-ID: <8209f740805212337w3f2c624rf2c952b961dbde9f@mail.gmail.com>

Hello,

Just a friendly reminder that the submission deadline (June 2)
for the CUFP workshop is approaching.

http://cufp.functionalprogramming.com

Those of you who ponder whether or not to attend, may also consider
the Erlang workshop (of course):

http://www.erlang.org/workshop/2008/

and the Developer Tracks on Functional Programming:

http://www.deinprogramm.de/defun-2008/

DEFUN is particularly interested in good tutorials.

BR,
Ulf W

2008/3/31 Ulf Wiger :
>   Commercial Users of Functional Programming Workshop (CUFP) 2008
>
>              Functional Programming As a Means, Not an End
>
>                          Call for Presentations
>
>                         Sponsored by SIGPLAN
>                       Co-located with ICFP 2008
>    _________________________________________________________________
>
>                Presentation proposals due 2 June 2008
>
>                http://cufp.functionalprogramming.com
>    _________________________________________________________________
>
>  Functional languages have been under academic development for over
> 25
>  years, and remain fertile ground for programming language research.
>  Recently, however, developers in industrial, governmental, and open
>  source projects have begun to use functional programming
> successfully
>  in practical applications. In these settings, functional
> programming
>  has often provided dramatic leverage, including whole new ways of
>  thinking about the original problem.
>
>  The goal of the CUFP workshop is to act as a voice for these users
> of
>  functional programming. The workshop supports the increasing
> viability
>  of functional programming in the commercial, governmental, and
>  open-source space by providing a forum for professionals to share
>  their experiences and ideas, whether those ideas are related to
>  business, management, or engineering. The workshop is also designed
> to
>  enable the formation and reinforcement of relationships that
> further
>  the commercial use of functional programming. Providing user
> feedback
>  to language designers and implementors is not a primary goal of the
>  workshop, though it will be welcome if it occurs.
>
> Speaking at CUFP
>
>  If you use functional programming as a means, rather than as an
> end,
>  we invite you to offer to give a talk at the workshop.
> Alternatively,
>  if you know someone who would give a good talk, please nominate
> them!
>
>  Talks are typically 30-45 minutes long, but can be shorter. They
> aim
>  to inform participants about how functional programming played out
> in
>  real-world applications, focusing especially on the re-usable
> lessons
>  learned, or insights gained. Your talk does not need to be highly
>  technical; for this audience, reflections on the commercial,
>  management, or software engineering aspects are, if anything, more
>  important. You do not need to submit a paper!
>
>  If you are interested in offering a talk, or nominating someone to
> do
>  so, send an e-mail to jim (dot) d (dot) grundy (at) intel (dot) com
> or
>  simonpj (at) microsoft (dot) com by 2 June 2008 with a short
>  description of what you'd like to talk about or what you think your
>  nominee should give a talk about. Such descriptions should be about
>  one page long.
>
> Program Plans
>
>  CUFP 2008 will last a full day and feature an invited presentation
>  from Michael Hopcroft, the product unit manager for the forthcoming
>  release of Microsoft Visual Studio F#. Additionally, the program
>  will include a mix of presentations and discussion sessions. Topics
>  will range over a wide area, including:
>    * Case studies of successful and unsuccessful uses of functional
>      programming;
>    * Business opportunities and risks from using functional
> languages;
>    * Enablers for functional language use in a commercial setting;
>    * Barriers to the adoption of functional languages, and
>    * Mitigation strategies for overcoming limitations of functional
>      programming.
>
>  There will be no published proceedings, as the meeting is intended
> to
>  be more a discussion forum than a technical interchange.
>
> Program Committee
>
>    * Lennart Augustsson  com>
>    * Matthias Blume 
>    * Adam Granicz 
>    * Jim Grundy (co-chair)  (dot) com>
>    * John Lalonde 
>    * Andy Martin 
>    * Yaron Minsky 
>    * Simon Peyton Jones (co-chair)  com>
>    * Ulf Wiger 
>
>  This will be the fifth CUFP, for more information - including
> reports
>  from attendees of previous events - see the workshop web site:
>  http://cufp.functionalprogramming.com
>


From erlang@REDACTED  Thu May 22 09:21:44 2008
From: erlang@REDACTED (Peter Lund)
Date: Thu, 22 May 2008 09:21:44 +0200
Subject: [erlang-questions] Erlang regex
In-Reply-To: 
References: 
Message-ID: <48351F08.2040708@lundata.se>

Please read the docs: stdlib -> string

There you find it....

Matteo skrev:
> Hi to all,
> i'm a noob of erlang programming. I would like to have some infos 
> about extracting a substring from a string....
> Or better, my situation is this:
>
> i have a string:
> str="OK 01 xxxxxxxx\r\n"); // where xxxxxxxx is a string that i dont 
> know and every time change...
>
> and i need to extract the "xxxxxxx" into another string (str2 for exaple).
>
> Sorry for my english.
>
> Best regards
> M.Canato
> ------------------------------------------------------------------------
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions



From zambal@REDACTED  Thu May 22 09:22:24 2008
From: zambal@REDACTED (zambal)
Date: Thu, 22 May 2008 00:22:24 -0700 (PDT)
Subject: [erlang-questions] facebook chat server
In-Reply-To: <65b2728e0805211956v3bb89b84q66a141721fce332b@mail.gmail.com>
References: 
	<8209f740805151101u2ce8d7ddxfaef2702f662ae15@mail.gmail.com> 
	 
	 
	 
	<483495FC.2010007@dominicwilliams.net>
	<2CBBCB38-7789-440E-8BAA-5BA6DB5E6D55@hypotheticalabs.com> 
	<65b2728e0805211956v3bb89b84q66a141721fce332b@mail.gmail.com>
Message-ID: 

On May 22, 4:56?am, "Steve Vinoski"  wrote:
> What all those years of CORBA taught me, BTW, is that RPC, for a
> number of reasons, is generally A Really Bad Idea. Call it a hard-won
> lesson. The Erlang flavor of RPC is great because the entire Erlang
> system has distribution fundamentally designed and built into it, but
> for normal languages, RPC creates more problems than it solves.
>
> --steve

Would you care to elaborate on why you think using RPC could be a bad
idea? Some people at my company are trying to push the use of SOAP in
our development process and I'm not sure if it's worth the added
complexity, so I can use some good counter arguments ;-)

Thanks,
Vincent



From alexander.lamb@REDACTED  Thu May 22 09:51:47 2008
From: alexander.lamb@REDACTED (Alexander Lamb)
Date: Thu, 22 May 2008 09:51:47 +0200
Subject: [erlang-questions] Simple question about nodes distribution
Message-ID: <753EF6A3-1439-4A7A-9911-F7A2D5197C6E@rodanotech.ch>

Hello list,

Starting to experiment with multiple nodes (and Mnesia) and already  
stumbling on something:

If I start a node like this:

erl -mnesia -setcookie rodanotech -name alex@REDACTED

then a second node like this:

erl -mnesia -setcookie rodanotech -name alex2@REDACTED

Why, when I ask for nodes() on either system, does it answer with an  
empty list.

I experimented further with mnesia. I have a schema on node alex. I  
start mnesia.
Then, on node alex2 I create a mnesia schema and start mnesia.
Then from the node where Mnesia is running with existing tables I try:

mnesia:add_table_copy(schema,'alex2@REDACTED',disc_copies).

but it fails with: {aborted,{badarg,schema,disc_copies}}

so I try:

mnesia:add_table_copy(profiles,'alex2@REDACTED',disc_copies).

But it also fails this time with: {aborted, 
{not_active,schema,alex2@REDACTED}}

I must be getting something wrong initially...

Thanks for any hints,

Alex



From per.melin@REDACTED  Thu May 22 10:14:34 2008
From: per.melin@REDACTED (Per Melin)
Date: Thu, 22 May 2008 10:14:34 +0200
Subject: [erlang-questions] Simple question about nodes distribution
In-Reply-To: <753EF6A3-1439-4A7A-9911-F7A2D5197C6E@rodanotech.ch>
References: <753EF6A3-1439-4A7A-9911-F7A2D5197C6E@rodanotech.ch>
Message-ID: 

2008/5/22 Alexander Lamb :
> Why, when I ask for nodes() on either system, does it answer with an
> empty list.

You need to let the nodes know that they should connect. For example
with net_kernel:connect_node/1, or just:

(alex@REDACTED)1> net_adm:ping('alex2@REDACTED').


> I experimented further with mnesia. I have a schema on node alex. I
> start mnesia.
> Then, on node alex2 I create a mnesia schema and start mnesia.

You need the same schema on both nodes. You can't create them
independently. Give both nodes to mnesia:create_schema/1.

You can of course also add a node to a schema. I've always found this
a bit awkward, so maybe I'm doing it wrong, but the way I add an extra
node is with mnesia:change_config(extra_db_nodes, ['alex2@REDACTED'])
and then mnesia:change_table_copy_type(schema, 'alex2@REDACTED',
disc_copies).


From chandrashekhar.mullaparthi@REDACTED  Thu May 22 10:24:17 2008
From: chandrashekhar.mullaparthi@REDACTED (Chandru)
Date: Thu, 22 May 2008 09:24:17 +0100
Subject: [erlang-questions] Simple question about nodes distribution
In-Reply-To: <753EF6A3-1439-4A7A-9911-F7A2D5197C6E@rodanotech.ch>
References: <753EF6A3-1439-4A7A-9911-F7A2D5197C6E@rodanotech.ch>
Message-ID: 

2008/5/22 Alexander Lamb :
> Hello list,
>
> Starting to experiment with multiple nodes (and Mnesia) and already
> stumbling on something:
>
> If I start a node like this:
>
> erl -mnesia -setcookie rodanotech -name alex@REDACTED
>
> then a second node like this:
>
> erl -mnesia -setcookie rodanotech -name alex2@REDACTED
>
> Why, when I ask for nodes() on either system, does it answer with an
> empty list.

-mnesia is not a valid option. You have to have some communication
between the nodes for them to be aware of each other. An erlang node
starting on a host will not automatically know about all other nodes
on that machine. Try net_adm:ping(alex2@REDACTED) from alex@REDACTED
and then check nodes().

>
> I experimented further with mnesia. I have a schema on node alex. I
> start mnesia.
> Then, on node alex2 I create a mnesia schema and start mnesia.
> Then from the node where Mnesia is running with existing tables I try:
>
> mnesia:add_table_copy(schema,'alex2@REDACTED',disc_copies).
>
> but it fails with: {aborted,{badarg,schema,disc_copies}}
>
> so I try:
>
> mnesia:add_table_copy(profiles,'alex2@REDACTED',disc_copies).
>
> But it also fails this time with: {aborted,
> {not_active,schema,alex2@REDACTED}}
>
> I must be getting something wrong initially...
>

If you want to share tables across nodes, the mnesia schema has to be
shared between them. You can do this by specifying the list of all
nodes when first creating the schema (See section 3.3.1 in the mnesia
user guide http://www.erlang.org/doc/apps/mnesia/Mnesia_chap3.html#3
), or you first add the new nodes to the schema before copying tables
across (http://www.erlang.org/doc/apps/mnesia/Mnesia_chap5.html#5.6).

Another thing to understand is if your schema is of type ram_copies,
you cannot have disk based tables.

cheers
Chandru


From alexander.lamb@REDACTED  Thu May 22 10:25:51 2008
From: alexander.lamb@REDACTED (Alexander Lamb)
Date: Thu, 22 May 2008 10:25:51 +0200
Subject: [erlang-questions] Simple question about nodes distribution
In-Reply-To: 
References: <753EF6A3-1439-4A7A-9911-F7A2D5197C6E@rodanotech.ch>
	
Message-ID: <59ECC120-EC8B-449E-840C-6FD664DD0540@rodanotech.ch>

Thanks, this was the step I was missing.

Alex


Le 22 mai 08 ? 10:14, Per Melin a ?crit :

> 2008/5/22 Alexander Lamb :
>> Why, when I ask for nodes() on either system, does it answer with an
>> empty list.
>
> You need to let the nodes know that they should connect. For example
> with net_kernel:connect_node/1, or just:
>
> (alex@REDACTED)1> net_adm:ping('alex2@REDACTED').
>
>
>> I experimented further with mnesia. I have a schema on node alex. I
>> start mnesia.
>> Then, on node alex2 I create a mnesia schema and start mnesia.
>
> You need the same schema on both nodes. You can't create them
> independently. Give both nodes to mnesia:create_schema/1.
>
> You can of course also add a node to a schema. I've always found this
> a bit awkward, so maybe I'm doing it wrong, but the way I add an extra
> node is with mnesia:change_config(extra_db_nodes, ['alex2@REDACTED'])
> and then mnesia:change_table_copy_type(schema, 'alex2@REDACTED',
> disc_copies).
>



From mats.cronqvist@REDACTED  Thu May 22 10:55:30 2008
From: mats.cronqvist@REDACTED (Mats Cronqvist)
Date: Thu, 22 May 2008 10:55:30 +0200
Subject: [erlang-questions] What tools do you use to develop Erlang code?
In-Reply-To: <14f001c8bb13$db9b9b40$92d2d1c0$@hughes@quviq.com>
References: <14f001c8bb13$db9b9b40$92d2d1c0$@hughes@quviq.com>
Message-ID: <48353502.3090502@gmail.com>

John Hughes wrote:
>
> Here?s a chance to tell the world which tools you like best for 
> developing Erlang code! I?ve put together a short questionnaire that 
> asks about editors, test tools, and version control systems. You can 
> find it?together with the answers so far?at
>
> http://www.cs.chalmers.se/~rjmh/ErlangSurvey/ErlangUsers.cgi 
> 
>
so right now (121 responses) the "favorite editor" alternatives add up 
to 87%. perhaps there's some truncing ass opposed to rounding going on?

mats


From vladdu55@REDACTED  Thu May 22 11:06:26 2008
From: vladdu55@REDACTED (Vlad Dumitrescu)
Date: Thu, 22 May 2008 11:06:26 +0200
Subject: [erlang-questions] What tools do you use to develop Erlang code?
In-Reply-To: <-1412032102263525371@unknownmsgid>
References: <-1412032102263525371@unknownmsgid>
Message-ID: <95be1d3b0805220206j488928eqf680099602e3ee81@mail.gmail.com>

2008/5/21 John Hughes :

>  Here's a chance to tell the world which tools you like best for
> developing Erlang code! I've put together a short questionnaire that asks
> about editors, test tools, and version control systems. You can find
> it?together with the answers so far?at
>
Hi!

It might be interesting to note that soon (after the summer) Erlide will
start to be used as the strongly recommended IDE in a large project at
Ericsson.

best regards,
Vlad
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From ulf.wiger@REDACTED  Thu May 22 11:10:20 2008
From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB))
Date: Thu, 22 May 2008 11:10:20 +0200
Subject: [erlang-questions] What tools do you use to develop Erlang code?
In-Reply-To: <48353502.3090502@gmail.com>
References: <14f001c8bb13$db9b9b40$92d2d1c0$@hughes@quviq.com>
	<48353502.3090502@gmail.com>
Message-ID: <4835387C.8020205@ericsson.com>

Mats Cronqvist skrev:
> John Hughes wrote:
>> Here?s a chance to tell the world which tools you like best for 
>> developing Erlang code! I?ve put together a short questionnaire that 
>> asks about editors, test tools, and version control systems. You can 
>> find it?together with the answers so far?at
>>
>> http://www.cs.chalmers.se/~rjmh/ErlangSurvey/ErlangUsers.cgi 
>> 
>>
> so right now (121 responses) the "favorite editor" alternatives add up 
> to 87%. perhaps there's some truncing ass opposed to rounding going on?

I noticed that 0% use Xemacs + Distel, but I know that
most in our unit use Xemacs, and Distel is installed
by default, so... 0% is probably an under-approximation. (:

BR,
Ulf W


From john.hughes@REDACTED  Thu May 22 11:18:25 2008
From: john.hughes@REDACTED (John Hughes)
Date: Thu, 22 May 2008 11:18:25 +0200
Subject: [erlang-questions] What tools do you use to develop Erlang code?
In-Reply-To: <48353502.3090502@gmail.com>
References: <14f001c8bb13$db9b9b40$92d2d1c0$@hughes@quviq.com>
	<48353502.3090502@gmail.com>
Message-ID: <48353A61.8040605@quviq.com>

Mats Cronqvist wrote:
> John Hughes wrote:
>>
>> Here?s a chance to tell the world which tools you like best for 
>> developing Erlang code! I?ve put together a short questionnaire that 
>> asks about editors, test tools, and version control systems. You can 
>> find it?together with the answers so far?at
>>
>> http://www.cs.chalmers.se/~rjmh/ErlangSurvey/ErlangUsers.cgi 
>> 
>>
> so right now (121 responses) the "favorite editor" alternatives add up 
> to 87%. perhaps there's some truncing ass opposed to rounding going on?
>
> mats
>
Now they add up to 102%--much better! Thanks, Mats, that'll teach me to 
be lazy...

John


From mats.cronqvist@REDACTED  Thu May 22 11:30:14 2008
From: mats.cronqvist@REDACTED (Mats Cronqvist)
Date: Thu, 22 May 2008 11:30:14 +0200
Subject: [erlang-questions] What tools do you use to develop Erlang code?
In-Reply-To: <48353A61.8040605@quviq.com>
References: <14f001c8bb13$db9b9b40$92d2d1c0$@hughes@quviq.com>
	<48353502.3090502@gmail.com> <48353A61.8040605@quviq.com>
Message-ID: <48353D26.8080003@gmail.com>

John Hughes wrote:
> Mats Cronqvist wrote:
>> John Hughes wrote:
>>>
>>> Here?s a chance to tell the world which tools you like best for 
>>> developing Erlang code! I?ve put together a short questionnaire that 
>>> asks about editors, test tools, and version control systems. You can 
>>> find it?together with the answers so far?at
>>>
>>> http://www.cs.chalmers.se/~rjmh/ErlangSurvey/ErlangUsers.cgi 
>>> 
>>>
>> so right now (121 responses) the "favorite editor" alternatives add 
>> up to 87%. perhaps there's some truncing ass opposed to rounding 
>> going on?
>>
>> mats
>>
> Now they add up to 102%--much better! Thanks, Mats, that'll teach me 
> to be lazy... 

  cool. i hit update every 5 minutes, so i need it to be absolutely 
correct :>
  btw, sorry about the "ass" in my post. it was a typo, honest!

  mats


From ulf.wiger@REDACTED  Thu May 22 12:52:52 2008
From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB))
Date: Thu, 22 May 2008 12:52:52 +0200
Subject: [erlang-questions] rpc is bad? (was Re:  facebook chat server)
In-Reply-To: <65b2728e0805211956v3bb89b84q66a141721fce332b@mail.gmail.com>
References: 	<8209f740805151101u2ce8d7ddxfaef2702f662ae15@mail.gmail.com>				<483495FC.2010007@dominicwilliams.net>	<2CBBCB38-7789-440E-8BAA-5BA6DB5E6D55@hypotheticalabs.com>
	<65b2728e0805211956v3bb89b84q66a141721fce332b@mail.gmail.com>
Message-ID: <48355084.70208@ericsson.com>

Steve Vinoski skrev:
> 
> What all those years of CORBA taught me, BTW, is that RPC,
 > for a number of reasons, is generally A Really Bad Idea.
 > Call it a hard-won lesson. The Erlang flavor of RPC is
 > great because the entire Erlang system has distribution
 > fundamentally designed and built into it, but for normal
 > languages, RPC creates more problems than it solves.
> 
> --steve

This is certainly something that I'd love to see you expand
in a blog article. Specifically, I'd like to hear your views
on what the better alternative would be.
(No touch of sarcasm - I'm genuinely interested.)

One of these days, I'll try to write some understandable
documentation for my VCC code (version-controlled channels,
http://svn.ulf.wiger.net/vcc/trunk/vcc/SPECIFICATION.txt).

This is basically a more complex version of Joe's lib_chan,
with support for automatic transformation of data between
nodes running different versions, and at least the
ambition to also support non-Erlang peers.

The non-Erlang allowances are a 32-bit aligned framing protocol
per-channel encode/decode and an XML-based meta protocol.

For Erlang-to-Erlang, it could be used to cleanly separate
communication for different applications, and could offer
a reliable way to perform redundancy upgrade, install
contract checkers, etc.

The channels have asynchronous semantics, but - partly inspired
by Haskell - you can send a message on a temporary channel
(using an existing channel as template), and optionally have
it automatically removed when the other side has sent a
reply.

I'd love to receive feedback, or even better: volunteers to
help finish it. It's been gathering dust for a while, but
I keep coming back to the conclusion that it would be very
useful.

BR,
Ulf W


From stonecypher@REDACTED  Thu May 22 18:00:32 2008
From: stonecypher@REDACTED (John Haugeland)
Date: Thu, 22 May 2008 10:00:32 -0600
Subject: [erlang-questions] erlang-questions Digest, Vol 12, Issue 70
In-Reply-To: 
References: 
Message-ID: <8f24f4b10805220900h788694e8g3bf5a58e1c17b8fd@mail.gmail.com>

> Others have answered about /how/ you may test unexported
> functions, so I thought I'd chip in to ask you /why/ you
> would want to?
>

To see if they're working.  Just because something's internal doesn't mean
it doesn't need to be verified.  I mean I understand and respect the
perspective that what's exported is the determinant and the important part
of a module; at the same time, testing is about making sure I got my stuff
right, and errors and defects are just as likely in private code as they are
in public.

Practically speaking, many tests aren't viable if they have to be dispatched
upstream.  In particular, testing something to make sure it behaves
correctly with malformed data is nearly impossible if you're only feeding it
data from your normal upstream code.

Yes, there's something to be said for tests that only mimic real world
circumstances, but there's also something to be said for exhaustive testing,
and something which is limited to the currently realistic set of
circumstances and causations is anything but exhaustive.  Code sensibly.
Test paranoiacally.

Anyway, it's an opinion.



    - John



------
GuaranteedVPS.com - bandwidth commitments and root starting from $12.98/mo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From drxyzzy@REDACTED  Thu May 22 18:00:36 2008
From: drxyzzy@REDACTED (Hal Snyder)
Date: Thu, 22 May 2008 11:00:36 -0500
Subject: [erlang-questions] rpc is bad? (was Re:  facebook chat server)
In-Reply-To: <48355084.70208@ericsson.com>
References: 	<8209f740805151101u2ce8d7ddxfaef2702f662ae15@mail.gmail.com>				<483495FC.2010007@dominicwilliams.net>	<2CBBCB38-7789-440E-8BAA-5BA6DB5E6D55@hypotheticalabs.com>
	<65b2728e0805211956v3bb89b84q66a141721fce332b@mail.gmail.com>
	<48355084.70208@ericsson.com>
Message-ID: <06DFEF61-E78A-4BC8-8E6A-7F4568261B96@gmail.com>

RPC gives me the same uneasy feeling as NFS (at least the early  
versions). NFS had a tendency to introduce single points of failure  
into a reliable system and to turn small failures into large ones; a  
clear sign that you're doing something at the wrong layer.

Of course there are still times when both are nice to have around.

Hal

On May 22, 2008, at 5:52 AM, Ulf Wiger (TN/EAB) wrote:

> Steve Vinoski skrev:
>>
>> What all those years of CORBA taught me, BTW, is that RPC,
>> for a number of reasons, is generally A Really Bad Idea.
>> Call it a hard-won lesson. The Erlang flavor of RPC is
>> great because the entire Erlang system has distribution
>> fundamentally designed and built into it, but for normal
>> languages, RPC creates more problems than it solves.
>>
>> --steve
>
> This is certainly something that I'd love to see you expand
> in a blog article. Specifically, I'd like to hear your views
> on what the better alternative would be.
> (No touch of sarcasm - I'm genuinely interested.)
>
> One of these days, I'll try to write some understandable
> documentation for my VCC code (version-controlled channels,
> http://svn.ulf.wiger.net/vcc/trunk/vcc/SPECIFICATION.txt).
>
> This is basically a more complex version of Joe's lib_chan,
> with support for automatic transformation of data between
> nodes running different versions, and at least the
> ambition to also support non-Erlang peers.
>
> The non-Erlang allowances are a 32-bit aligned framing protocol
> per-channel encode/decode and an XML-based meta protocol.
>
> For Erlang-to-Erlang, it could be used to cleanly separate
> communication for different applications, and could offer
> a reliable way to perform redundancy upgrade, install
> contract checkers, etc.
>
> The channels have asynchronous semantics, but - partly inspired
> by Haskell - you can send a message on a temporary channel
> (using an existing channel as template), and optionally have
> it automatically removed when the other side has sent a
> reply.
>
> I'd love to receive feedback, or even better: volunteers to
> help finish it. It's been gathering dust for a while, but
> I keep coming back to the conclusion that it would be very
> useful.
>
> BR,
> Ulf W


From vinoski@REDACTED  Thu May 22 18:55:06 2008
From: vinoski@REDACTED (Steve Vinoski)
Date: Thu, 22 May 2008 12:55:06 -0400
Subject: [erlang-questions] rpc is bad? (was Re:  facebook chat server)
In-Reply-To: <48355084.70208@ericsson.com>
References: 
	<8209f740805151101u2ce8d7ddxfaef2702f662ae15@mail.gmail.com>
	
	
	
	<483495FC.2010007@dominicwilliams.net>
	<2CBBCB38-7789-440E-8BAA-5BA6DB5E6D55@hypotheticalabs.com>
	<65b2728e0805211956v3bb89b84q66a141721fce332b@mail.gmail.com>
	<48355084.70208@ericsson.com>
Message-ID: <65b2728e0805220955p52904b2ex9e48bc8b36f70eb9@mail.gmail.com>

On 5/22/08, Ulf Wiger (TN/EAB)  wrote:
> Steve Vinoski skrev:
> >
> > What all those years of CORBA taught me, BTW, is that RPC,
> >
>  > for a number of reasons, is generally A Really Bad Idea.
>  > Call it a hard-won lesson. The Erlang flavor of RPC is
>  > great because the entire Erlang system has distribution
>  > fundamentally designed and built into it, but for normal
>  > languages, RPC creates more problems than it solves.
>
>  This is certainly something that I'd love to see you expand
>  in a blog article. Specifically, I'd like to hear your views
>  on what the better alternative would be.
>  (No touch of sarcasm - I'm genuinely interested.)

Well, if you had time you could dig through my various IEEE Internet
Computing columns from the past 6 years and find many reasons listed
there. For example, "RPC Under Fire" from the Sep/Oct 2005 lists a
number of problems:

 (note that it's PDF)

Also, pretty much any of my columns that cover REST to any degree
would also contain mentions of RPC's shortcomings. All the columns can
be found here:



But if you don't have the time or energy, the fundamental problem is
that RPC tries to make a distributed invocation look like a local one.
This can't work because the failure modes in distributed systems are
quite different from those in local systems, so you find yourself
having to introduce more and more infrastructure that tries to hide
all the hard details and problems that lurk beneath. That's how we got
Apollo NCS and Sun RPC and DCE and CORBA and DSOM and DCOM and EJB and
SOAP and JAX-RPC, to name a few off the top of my head, each better
than what came before in some ways but worse in other ways, especially
footprint and complexity. But it's all for naught because no amount of
infrastructure can ever hide those problems of distribution. Network
partitions are real, timeouts are real, remote host and service
crashes are real, the need for piecemeal system upgrade and handling
version differences between systems is real, etc. The distributed
systems programmer *must* deal with these and other issues because
they affect different applications very differently; no amount of
hiding or abstraction can make these problems disappear. As I said
about such systems in a recent column:

"The layers of complexity required to maintain the resulting leaky
illusion of local/remote transparency are reminiscent of the
convoluted equations that pre-Copernican astronomers used to explain
how the Sun and other planets revolved around the Earth." (from
"Serendipitous Reuse"
)

RPC systems in C++, Java, etc. also tend to introduce higher degrees
of coupling than one would like in a distributed system. Typically you
have some sort of IDL that's used to generate stubs/proxies/skeletons
-- code that turns the local calls into remote ones, which nobody
wants to write or maintain by hand. The IDL is often simple, but the
generated code is usually not. That code is normally compiled into
each app in the system. Change the IDL and you have to regenerate the
code, recompile it, and then retest and redeploy your apps, and you
typically have to do that atomically, either all apps or none, because
versioning is not accounted for. In an already-deployed production
system, it can be pretty hard to do atomic upgrades across the entire
system. Overall, this approach makes for brittle, tightly-coupled
systems.

Such systems also have problems with impedance mismatch between the
IDL and whatever languages you're translating it to. If the IDL is
minimal so that it can be used with a wide variety of programming
languages, it means advanced features of well-stocked languages like
Java and C++ can't be used. OTOH if you make the IDL more powerful so
that it's closer to such languages, then translating it to C or other
more basic languages becomes quite difficult. On top of all that, no
matter how you design the IDL type system, all the types won't --
indeed, can't -- map cleanly into every desired programming language.
This turns into the need for non-idiomatic programming in one or more
of the supported languages, and developers using those languages tend
to complain about that. If you turn the whole process around by using
a programming language like Java for your RPC IDL in an attempt to
avoid the mismatch problems, you find it works only for that language,
and that translating that language into other languages is quite
difficult.

There's also the need with these systems to have the same or similar
infrastructure on both ends of the wire. Earlier posters to this
thread complained about this, for example, when they mentioned having
to have CORBA ORBs underneath all their participating applications. If
you can't get the exact same infrastructure under all endpoints, then
you need to use interoperable infrastructure, which obviously relies
on interoperability standards. These, unfortunately, are often
problematic as well. CORBA interoperability, for example, eventually
became pretty good, but it took about a decade. CORBA started out with
no interoperability protocol at all (in fact, it originally specified
no network protocol at all), and then we suffered with interop
problems for a few years once IIOP came along and both the protocol
itself and implementations of it matured.

Ultimately, RPC is a leaky abstraction. It can't hide what it tries to
hide, and because of that, it can easily make the overall problem more
difficult to deal with by adding a lot of accidental complexity.

In my previous message I specifically mentioned Erlang as having
gotten it right. I believe that to be true not only because the
handling of distribution is effectively built in and dealt with
directly, but also because Erlang makes no attempt to hide those hard
problems from the developer. Rather, it makes them known to the
developer by providing facilities for dealing with timeouts, failures,
versioning, etc. I think what Erlang gives us goes a very long way and
is well beyond anything I've experienced before. Erlang really doesn't
provide RPC according to the strict definition of the term, BTW,
because remote calls don't actually look like local ones.

(BTW, this is the kind of stuff I'll be talking about at Erlang
eXchange next month.)

>  One of these days, I'll try to write some understandable
>  documentation for my VCC code (version-controlled channels,
>  http://svn.ulf.wiger.net/vcc/trunk/vcc/SPECIFICATION.txt).
>
>  This is basically a more complex version of Joe's lib_chan,
>  with support for automatic transformation of data between
>  nodes running different versions, and at least the
>  ambition to also support non-Erlang peers.
>
>  The non-Erlang allowances are a 32-bit aligned framing protocol
>  per-channel encode/decode and an XML-based meta protocol.
>
>  For Erlang-to-Erlang, it could be used to cleanly separate
>  communication for different applications, and could offer
>  a reliable way to perform redundancy upgrade, install
>  contract checkers, etc.
>
>  The channels have asynchronous semantics, but - partly inspired
>  by Haskell - you can send a message on a temporary channel
>  (using an existing channel as template), and optionally have
>  it automatically removed when the other side has sent a
>  reply.
>
>  I'd love to receive feedback, or even better: volunteers to
>  help finish it. It's been gathering dust for a while, but
>  I keep coming back to the conclusion that it would be very
>  useful.

That sounds pretty interesting. Have you looked at BEEP (Blocks
Extensible Exchange Protocol, ) at all? Some of
what you describe above sounds similar, on the surface at least, to
what BEEP does, and even uses similar terminology.

--steve


From matthew@REDACTED  Thu May 22 21:01:58 2008
From: matthew@REDACTED (Matthew Dempsky)
Date: Thu, 22 May 2008 12:01:58 -0700
Subject: [erlang-questions] zlib deflate problem
In-Reply-To: <4833D589.4070200@erix.ericsson.se>
References: 
	
	<24d4f39c0805201043m73cee5a8xe37299270466cd22@mail.gmail.com>
	
	<4833D589.4070200@erix.ericsson.se>
Message-ID: 

Has there been any further internal discussion on this patch?  I just
stumbled across this same bug as well.

On Wed, May 21, 2008 at 12:55 AM, Sverker Eriksson
 wrote:
> Matthew Dempsky wrote:
>> On Tue, May 20, 2008 at 10:43 AM, Colm Dougan  wrote:
>>
>>> Matthew - I tried your patch and it worked.   I don't see any
>>> regression but I haven't done extensive testing. If you think this is
>>> the appropriate fix (rather than an exploratory patch) then I can
>>> install the patched erlang on my running system and do more testing.
>>>
>>
>> I think it should be safe for more testing.
>>
>>
> Hi guys
>
> I've been looking at your patch Matthew, trying to understand it to
> decide if it should be part of the next OTP release. Do you have any
> more arguments why this would be the right way to do it?
>
>> --- zlib_drv.c.orig   2008-05-19 19:09:00.000000000 -0700
>> +++ zlib_drv.c        2008-05-19 19:09:12.000000000 -0700
>> @@ -257,6 +257,10 @@
>>               driver_deq(d->port, len);
>>               return res;
>>           }
>> +         if (res == Z_BUF_ERROR) {
>> +             res = Z_OK;
>> +         }
>>           if (res < 0) {
>>               return res;
>>           }
>
> As I understand it, a return of Z_BUF_ERROR from inflate() means
> something like "call me again with more buffer space". But in this case
> we don't call again.
>
> Do you have any more light to shed?
>
> /Sverker, Erlang/OTP Ericsson
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>


From Martin.Logan@REDACTED  Thu May 22 21:24:53 2008
From: Martin.Logan@REDACTED (Logan, Martin)
Date: Thu, 22 May 2008 14:24:53 -0500
Subject: [erlang-questions] [how] RSA-SHA1 signing function?
In-Reply-To: 
References: 
Message-ID: <1B67010539493A48B777F49CE49F574B08E10E@chiresexc04.resource.corp.lcl>

You can write your own pretty easily.  My simple implementation can be
found in a library called cryptographic.  I have it uploaded to an
Erlware (www.erlware.org) repository currently.  The code is short and
you can email me at martinjlogan@REDACTED if you have any questions.

-----Original Message-----
From: erlang-questions-bounces@REDACTED
[mailto:erlang-questions-bounces@REDACTED] On Behalf Of Tim Fletcher
Sent: Saturday, May 17, 2008 8:19 AM
To: erlang-questions@REDACTED
Subject: [erlang-questions] [how] RSA-SHA1 signing function?

Looking at crypto:rsa_verify/3 I can't find an "opposite" function to
create a signature from some data and a private key. Does such a
function (or set of functions) exist?
_______________________________________________
erlang-questions mailing list
erlang-questions@REDACTED
http://www.erlang.org/mailman/listinfo/erlang-questions


From pfisher@REDACTED  Fri May 23 04:29:33 2008
From: pfisher@REDACTED (Paul Fisher)
Date: Thu, 22 May 2008 21:29:33 -0500
Subject: [erlang-questions] distel-mode with *.beam files separate from
	source
Message-ID: <1211509773.6476.58.camel@localhost>

???I'm having trouble using distel debugging mode (erl-toggle-interpret)
when my src/ directory is soft-linked next to the ebin directory.  In
other words, I have the following directory structure:

    top/
        bld/
            erlang/
                application/
                    ebin/
?                        *.app files
                        *.beam files
?                    src/ -> top/project/application/
        project/
            application/
?                *.app files
                *.erl files

Basically, the idea is that project/* is under version control and then
the erlang applications are built into the top/bld/erlang/ directory
outside of version control in order to not pollute the project/*
structure with *.beam files, as well as aid in packaging.

Problem is that even though the erlang node has
top/bld/erlang/application/ebin in the path, distel mode does not appear
to try ../src/ based on the module location reported by the node.

Is there any way to make a structure like this work?


-- 
paul



From ulf.wiger@REDACTED  Fri May 23 08:46:31 2008
From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB))
Date: Fri, 23 May 2008 08:46:31 +0200
Subject: [erlang-questions] rpc is bad? (was Re:  facebook chat server)
In-Reply-To: <65b2728e0805220955p52904b2ex9e48bc8b36f70eb9@mail.gmail.com>
References: 	
	<8209f740805151101u2ce8d7ddxfaef2702f662ae15@mail.gmail.com>	
		
		
		
	<483495FC.2010007@dominicwilliams.net>	
	<2CBBCB38-7789-440E-8BAA-5BA6DB5E6D55@hypotheticalabs.com>	
	<65b2728e0805211956v3bb89b84q66a141721fce332b@mail.gmail.com>	
	<48355084.70208@ericsson.com>
	<65b2728e0805220955p52904b2ex9e48bc8b36f70eb9@mail.gmail.com>
Message-ID: <48366847.3050302@ericsson.com>

Steve Vinoski skrev:
> On 5/22/08, Ulf Wiger (TN/EAB)  wrote:
> 
>>  One of these days, I'll try to write some understandable
>>  documentation for my VCC code (version-controlled channels,
>>  http://svn.ulf.wiger.net/vcc/trunk/vcc/SPECIFICATION.txt).
>>
>>  ...
> 
> That sounds pretty interesting. Have you looked at BEEP (Blocks
> Extensible Exchange Protocol, ) at all?
 > Some of what you describe above sounds similar, on the surface
 > at least, to what BEEP does, and even uses similar terminology.

Yes, I did look at BEEP at the time, and stole some ideas, but
ultimately it didn't do the things I needed (exactly where it
fell short, I don't recall, since it was three years ago and
I didn't write it down). My best guess would be that the version
negotiation, and possibly channel monitoring, were the missing
bits. Version control should be part of the core protocol, but
monitoring might not have to be.

BR,
Ulf W


From mats.cronqvist@REDACTED  Fri May 23 10:55:27 2008
From: mats.cronqvist@REDACTED (Mats Cronqvist)
Date: Fri, 23 May 2008 10:55:27 +0200
Subject: [erlang-questions] distel-mode with *.beam files separate from
 source
In-Reply-To: <1211509773.6476.58.camel@localhost>
References: <1211509773.6476.58.camel@localhost>
Message-ID: <4836867F.6020002@gmail.com>

Paul Fisher wrote:
> ??I'm having trouble using distel debugging mode (erl-toggle-interpret)
> when my src/ directory is soft-linked next to the ebin directory.  In
> other words, I have the following directory structure:
>
>     top/
>         bld/
>             erlang/
>                 application/
>                     ebin/
> ?                        *.app files
>                         *.beam files
> ?                    src/ -> top/project/application/
>         project/
>             application/
> ?                *.app files
>                 *.erl files
>
> Basically, the idea is that project/* is under version control and then
> the erlang applications are built into the top/bld/erlang/ directory
> outside of version control in order to not pollute the project/*
> structure with *.beam files, as well as aid in packaging.
>
> Problem is that even though the erlang node has
> top/bld/erlang/application/ebin in the path, distel mode does not appear
> to try ../src/ based on the module location reported by the node.
  could be that the OTP filelib functions don't follow links.
  are you using the GNU autotools to build out-of-tree?

  mats


From zambal@REDACTED  Fri May 23 11:12:55 2008
From: zambal@REDACTED (zambal)
Date: Fri, 23 May 2008 02:12:55 -0700 (PDT)
Subject: [erlang-questions] rpc is bad? (was Re: facebook chat server)
In-Reply-To: <65b2728e0805220955p52904b2ex9e48bc8b36f70eb9@mail.gmail.com>
References: 
	<8209f740805151101u2ce8d7ddxfaef2702f662ae15@mail.gmail.com> 
	 
	 
	 
	<483495FC.2010007@dominicwilliams.net>
	<2CBBCB38-7789-440E-8BAA-5BA6DB5E6D55@hypotheticalabs.com> 
	<65b2728e0805211956v3bb89b84q66a141721fce332b@mail.gmail.com> 
	<48355084.70208@ericsson.com>
	<65b2728e0805220955p52904b2ex9e48bc8b36f70eb9@mail.gmail.com>
Message-ID: 

Hi Steve,

I indeed haven't found time yet to read the articles that you mention,
but the explanation in your mail already gives me excellent food for
thought about the weaker spots in most RPC protocols.

Thanks a lot,
Vincent


From sverker@REDACTED  Fri May 23 11:13:07 2008
From: sverker@REDACTED (Sverker Eriksson)
Date: Fri, 23 May 2008 11:13:07 +0200
Subject: [erlang-questions] zlib deflate problem
In-Reply-To: 
References: 	
		
	<24d4f39c0805201043m73cee5a8xe37299270466cd22@mail.gmail.com>	
		
	<4833D589.4070200@erix.ericsson.se>
	
Message-ID: <48368AA3.5010103@erix.ericsson.se>

Yes, I have tested this myself now with some extra tracing. It is 
absolutely a bug not handling the non fatal error case of Z_BUF_ERROR. A 
fix will be included in R12B-3. I will do some more investigating, but 
as it looks now it will be the patch you suggested, Matthew.

/Sverker, Erlang/OTP Ericsson

Matthew Dempsky wrote:
> Has there been any further internal discussion on this patch?  I just
> stumbled across this same bug as well.
>
> On Wed, May 21, 2008 at 12:55 AM, Sverker Eriksson
>  wrote:
>   
>> Matthew Dempsky wrote:
>>     
>>> On Tue, May 20, 2008 at 10:43 AM, Colm Dougan  wrote:
>>>
>>>       
>>>> Matthew - I tried your patch and it worked.   I don't see any
>>>> regression but I haven't done extensive testing. If you think this is
>>>> the appropriate fix (rather than an exploratory patch) then I can
>>>> install the patched erlang on my running system and do more testing.
>>>>
>>>>         
>>> I think it should be safe for more testing.
>>>
>>>
>>>       
>> Hi guys
>>
>> I've been looking at your patch Matthew, trying to understand it to
>> decide if it should be part of the next OTP release. Do you have any
>> more arguments why this would be the right way to do it?
>>
>>     
>>> --- zlib_drv.c.orig   2008-05-19 19:09:00.000000000 -0700
>>> +++ zlib_drv.c        2008-05-19 19:09:12.000000000 -0700
>>> @@ -257,6 +257,10 @@
>>>               driver_deq(d->port, len);
>>>               return res;
>>>           }
>>> +         if (res == Z_BUF_ERROR) {
>>> +             res = Z_OK;
>>> +         }
>>>           if (res < 0) {
>>>               return res;
>>>           }
>>>       
>> As I understand it, a return of Z_BUF_ERROR from inflate() means
>> something like "call me again with more buffer space". But in this case
>> we don't call again.
>>
>> Do you have any more light to shed?
>>
>> /Sverker, Erlang/OTP Ericsson
>>
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://www.erlang.org/mailman/listinfo/erlang-questions
>>
>>     



From rvirding@REDACTED  Fri May 23 12:27:38 2008
From: rvirding@REDACTED (Robert Virding)
Date: Fri, 23 May 2008 12:27:38 +0200
Subject: [erlang-questions] eep: multiple patterns
In-Reply-To: <482D5647.1030109@gmail.com>
References: <200805141620.19559.bekesa@sch.bme.hu>
	<200805151307.18370.bekesa@sch.bme.hu>
	<5D916667-D9C8-43C4-A1E6-916653C9CB00@cs.otago.ac.nz>
	<200805161110.51758.bekesa@sch.bme.hu> <482D5647.1030109@gmail.com>
Message-ID: <3dbc6d1c0805230327i74b0ecd2ob0f7971fe2577ae8@mail.gmail.com>

Sorry for taking so long to comment this, but I have been thinking. :-)
Comments follow.

2008/5/16 Mats Cronqvist :

> Andras Georgy Bekes wrote:
> > Hi,
> >
> > I am trying to end this discussion with some usable result.
> >
> > First let me state that
> > - I am now convinced that ~= is not a good idea, therefore I am not
> > going to submit it in an eep.
>

Here I disagree, sort of. While I also think the ~= is not a good idea, I
agree with Richard O'Keefe that having = as a legal guard test is a Good
Thing. I also don't see any logical problems with it. If you have the
semantics:

- if match succeeds it returns true and binds any unbound variables
- if match fails, it returns false, i.e. it does generate an error

Then you modify all boolean operations so that if they succeed, return true,
then any new variables which are bound in them are exported, while if they
fail, return false, no variables are exported.

- This will work for the whole guard as if the guard fails then no variables
are exported but the clause is not chosen anyway.
- No problems with not(...) as it will never export variables.
- Same with other boolean operators, success implies export. This makes
checking for variable bindings in and after guards relatively easy.

As far as I can see there are no problems with this.

Then as we allow = as a boolean test in guards we can extend it to be a
valid *test* in list/binary comprehensions as well. It the match succeeds
the test succeeds and exports the any new variable bindings. Someone asked
for this earlier and while just having it in lc/bc might be a bit off having
it as a valid *guard* test means it becomes acceptable as lc/bc test. It
also easy to implement. I have the this feature already in LFE.

> - I am convinced that multiple patterns is a good idea (many of you
> > stated that you like it). I am about to send it as an eep, we just have
> > to agree on the right notation.
> >
> >
> >> Yes, but Virding's proposal uses ";" for the *SAME* meaning
> >> ("or") that it normally has.
> >>
> >
> > My problem with ; is that it's ambiguous.
> > I can write at least one pattern that could be parsed into two different
> > ASTs.
> >
> >    Pattern when Guard; true ->
> > now is this a single pattern: Pattern when (Guard; true) ?
> > or is it multiple patterns: (Pattern when Guard); true ?
>  i was reading virding's proposal as;
>
> case bla of
>  Pat when true ->;
>  Pat when false->;
>  Pat ->
>    code()
> end.
>
>  but that's not what he wrote...
>
>  in that case i propose the above. currently gives syntax error.
>

I don't have a problem with this, but I don't really see the need. The only
time I have had repeated bodies they have been very simple no repeating just
them has been very straight forward. While using ->; as syntax would be easy
and cause no inconsistencies it has the downside that you would fail to
capture the case where you have forgotten to give a body.

Actually thinking about it a bit more if you allow = in guards you really
don't *need* this multiple pattern feature as you can express it as
alternate guards. The problem would be that it would be more difficult to
implement this pattern matching as efficiently as when it occurs the the
head.

So maybe this solves the syntax question automatically.

Robert
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From mats.cronqvist@REDACTED  Fri May 23 13:05:59 2008
From: mats.cronqvist@REDACTED (Mats Cronqvist)
Date: Fri, 23 May 2008 13:05:59 +0200
Subject: [erlang-questions] eep: multiple patterns
In-Reply-To: <3dbc6d1c0805230327i74b0ecd2ob0f7971fe2577ae8@mail.gmail.com>
References: <200805141620.19559.bekesa@sch.bme.hu>	
	<200805151307.18370.bekesa@sch.bme.hu>	
	<5D916667-D9C8-43C4-A1E6-916653C9CB00@cs.otago.ac.nz>	
	<200805161110.51758.bekesa@sch.bme.hu> <482D5647.1030109@gmail.com>
	<3dbc6d1c0805230327i74b0ecd2ob0f7971fe2577ae8@mail.gmail.com>
Message-ID: <4836A517.2040909@gmail.com>

Robert Virding wrote:
> Sorry for taking so long to comment this, but I have been thinking. 
> :-) Comments follow.
>
> 2008/5/16 Mats Cronqvist  >:
[...]
>
>      i was reading virding's proposal as;
>
>     case bla of
>      Pat when true ->;
>      Pat when false->;
>      Pat ->
>        code()
>     end.
>
>      but that's not what he wrote...
>
>      in that case i propose the above. currently gives syntax error.
>
>
> I don't have a problem with this, but I don't really see the need. The 
> only time I have had repeated bodies they have been very simple no 
> repeating just them has been very straight forward.
[...]

  i read the above as "i've never needed this myself, so it must be 
unnecessary."
  let me assure you that there are major telecom equipment vendors whose 
code bases would benefit greatly from this syntax.
  although i (no longer) has access to that code, the pattern appears 
quite often in event-driven programming. here's a very small example 
from a simple GUI application;

loop(St) ->
    receive
    %% user deleted top window
    {?MODULE,{signal,{window1,_}}}       -> quit();
    %% user selected quit menu item
    {?MODULE,{signal,{quit1,_}}}       -> quit();
    %% user selected  connect menu item
    {?MODULE,{signal,{connect,_}}}       -> loop(conn(St));
    %% user selected  disconnect menu item
    {?MODULE,{signal,{disconnect,_}}} -> loop(disc(St));
    %% user selected about menu item
    {?MODULE,{signal,{about1,_}}}       -> loop(show_about(St));
    %% user clicked ok in about dialog
    {?MODULE,{signal,{dialogb,_}}}      -> loop(hide_about(St));
    %% user deleted about dialog
    {?MODULE,{signal,{dialog1,_}}}       -> loop(hide_about(St));
    %% we got data from the top_top process
    {data,Data}                       -> loop(update(St,Data));
    %% quit from the erlang shell
    quit                              -> quit();
    %% log other signals
    X                                 -> io:fwrite("got ~p~n",[X]),loop(St)
    end.



From rvirding@REDACTED  Fri May 23 13:24:26 2008
From: rvirding@REDACTED (Robert Virding)
Date: Fri, 23 May 2008 13:24:26 +0200
Subject: [erlang-questions] eep: multiple patterns
In-Reply-To: <4836A517.2040909@gmail.com>
References: <200805141620.19559.bekesa@sch.bme.hu>
	<200805151307.18370.bekesa@sch.bme.hu>
	<5D916667-D9C8-43C4-A1E6-916653C9CB00@cs.otago.ac.nz>
	<200805161110.51758.bekesa@sch.bme.hu> <482D5647.1030109@gmail.com>
	<3dbc6d1c0805230327i74b0ecd2ob0f7971fe2577ae8@mail.gmail.com>
	<4836A517.2040909@gmail.com>
Message-ID: <3dbc6d1c0805230424s6b3163felc9c36bc53b9dd8c@mail.gmail.com>

2008/5/23 Mats Cronqvist :

> Robert Virding wrote:
>
>>
>> I don't have a problem with this, but I don't really see the need. The
>> only time I have had repeated bodies they have been very simple no repeating
>> just them has been very straight forward.
>>
> [...]
>
>  i read the above as "i've never needed this myself, so it must be
> unnecessary."
>  let me assure you that there are major telecom equipment vendors whose
> code bases would benefit greatly from this syntax.


No, I meant my comment literally. It is not a problem that *I* have had so
*I* don't see the need. If others have trouble with this then *they* see the
need. So be it.

I accept the suggestion. But allowing = in guards really makes it
unnecessary.

In your example it could actually only be used in 1 place.

Robert
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From pfisher@REDACTED  Fri May 23 13:30:23 2008
From: pfisher@REDACTED (Paul Fisher)
Date: Fri, 23 May 2008 06:30:23 -0500
Subject: [erlang-questions] distel-mode with *.beam files separate
	from	source
In-Reply-To: <4836867F.6020002@gmail.com>
References: <1211509773.6476.58.camel@localhost> <4836867F.6020002@gmail.com>
Message-ID: <1211542223.6310.7.camel@localhost>

On Fri, 2008-05-23 at 10:55 +0200, Mats Cronqvist wrote:
> Paul Fisher wrote:
> >     top/
> >         bld/
> >             erlang/
> >                 application/
> >                     ebin/
> > ?                        *.app files
> >                         *.beam files
> > ?                    src/ -> top/project/application/
> >         project/
> >             application/
> > ?                *.app files
> >                 *.erl files
> >
> > Basically, the idea is that project/* is under version control and then
> > the erlang applications are built into the top/bld/erlang/ directory
> > outside of version control in order to not pollute the project/*
> > structure with *.beam files, as well as aid in packaging.
> >
> > Problem is that even though the erlang node has
> > top/bld/erlang/application/ebin in the path, distel mode does not appear
> > to try ../src/ based on the module location reported by the node.
>   could be that the OTP filelib functions don't follow links.
>   are you using the GNU autotools to build out-of-tree?

Did a little digging and from the bottom distel:find_source/1 certainly
seems to find the source file (by the
path /top/project/application/source.erl) correctly, so maybe there is
something else going one unrelated to the source tree, or possibly
tangentially related.  Here is the actual error I get in the
*erl-output* buffer that is created when I toggle on interactive:

** Invalid beam file or no abstract code:
"/top/project/application/source.erl"

I cannot find (with simple grep searching for either "Invalid beam file"
or "no abstract code") where this message is generated in either the
lisp or the erlang code for distel. A pointer to the right place to look
would be greatly appreciated.


thanks,

-- 
paul



From colm.dougan@REDACTED  Fri May 23 14:29:29 2008
From: colm.dougan@REDACTED (Colm Dougan)
Date: Fri, 23 May 2008 13:29:29 +0100
Subject: [erlang-questions] zlib deflate problem
In-Reply-To: <48368AA3.5010103@erix.ericsson.se>
References: 
	
	<24d4f39c0805201043m73cee5a8xe37299270466cd22@mail.gmail.com>
	
	<4833D589.4070200@erix.ericsson.se>
	
	<48368AA3.5010103@erix.ericsson.se>
Message-ID: <24d4f39c0805230529v52c92f38l7f1808655bfd403c@mail.gmail.com>

On Fri, May 23, 2008 at 10:13 AM, Sverker Eriksson
 wrote:
> Yes, I have tested this myself now with some extra tracing. It is
> absolutely a bug not handling the non fatal error case of Z_BUF_ERROR. A
> fix will be included in R12B-3. I will do some more investigating, but
> as it looks now it will be the patch you suggested, Matthew.

Thanks Sverker and Matthew.

Sverker - if you decide on a different patch then please let me know
as I have already patched my running system with Matthew's patch.

Cheers,
Colm


>
> Matthew Dempsky wrote:
>> Has there been any further internal discussion on this patch?  I just
>> stumbled across this same bug as well.
>>
>> On Wed, May 21, 2008 at 12:55 AM, Sverker Eriksson
>>  wrote:
>>
>>> Matthew Dempsky wrote:
>>>
>>>> On Tue, May 20, 2008 at 10:43 AM, Colm Dougan  wrote:
>>>>
>>>>
>>>>> Matthew - I tried your patch and it worked.   I don't see any
>>>>> regression but I haven't done extensive testing. If you think this is
>>>>> the appropriate fix (rather than an exploratory patch) then I can
>>>>> install the patched erlang on my running system and do more testing.
>>>>>
>>>>>
>>>> I think it should be safe for more testing.
>>>>
>>>>
>>>>
>>> Hi guys
>>>
>>> I've been looking at your patch Matthew, trying to understand it to
>>> decide if it should be part of the next OTP release. Do you have any
>>> more arguments why this would be the right way to do it?
>>>
>>>
>>>> --- zlib_drv.c.orig   2008-05-19 19:09:00.000000000 -0700
>>>> +++ zlib_drv.c        2008-05-19 19:09:12.000000000 -0700
>>>> @@ -257,6 +257,10 @@
>>>>               driver_deq(d->port, len);
>>>>               return res;
>>>>           }
>>>> +         if (res == Z_BUF_ERROR) {
>>>> +             res = Z_OK;
>>>> +         }
>>>>           if (res < 0) {
>>>>               return res;
>>>>           }
>>>>
>>> As I understand it, a return of Z_BUF_ERROR from inflate() means
>>> something like "call me again with more buffer space". But in this case
>>> we don't call again.
>>>
>>> Do you have any more light to shed?
>>>
>>> /Sverker, Erlang/OTP Ericsson
>>>
>>> _______________________________________________
>>> erlang-questions mailing list
>>> erlang-questions@REDACTED
>>> http://www.erlang.org/mailman/listinfo/erlang-questions
>>>
>>>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>


From alexd@REDACTED  Fri May 23 15:09:22 2008
From: alexd@REDACTED (alexd@REDACTED)
Date: Fri, 23 May 2008 14:09:22 +0100
Subject: [erlang-questions] Multiple UDP receivers and senders
Message-ID: 

The gen_tcp documentation states : 

"It is worth noting that the accept call does not have to be issued from 
the socket owner process. Using version 5.5.3 and higher of the emulator, 
multiple simultaneous accept calls can be issued from different processes, 
which allows for a pool of acceptor processes handling incoming 
connections."

Does anybody know if a similar thing is possible with gen_udp? i.e. I'd 
like to have a pool of Erlang processes receiving messages sent to a 
particular port.

Also, does anybody know if it is possible to open a UDP socket in one 
Erlang process, receiving UDP messages in that process, whilst 
simultaneously sending UDP messages from the same port in a different 
Erlang process?

Thanks very much for your help!


Alex.


From mats.cronqvist@REDACTED  Fri May 23 14:44:42 2008
From: mats.cronqvist@REDACTED (Mats Cronqvist)
Date: Fri, 23 May 2008 14:44:42 +0200
Subject: [erlang-questions] distel-mode with *.beam files separate from
 source
In-Reply-To: <1211542223.6310.7.camel@localhost>
References: <1211509773.6476.58.camel@localhost>	 <4836867F.6020002@gmail.com>
	<1211542223.6310.7.camel@localhost>
Message-ID: <4836BC3A.8040602@gmail.com>

Paul Fisher wrote:
> On Fri, 2008-05-23 at 10:55 +0200, Mats Cronqvist wrote:
>   
>> Paul Fisher wrote:
>>     
>>>     top/
>>>         bld/
>>>             erlang/
>>>                 application/
>>>                     ebin/
>>> ?                        *.app files
>>>                         *.beam files
>>> ?                    src/ -> top/project/application/
>>>         project/
>>>             application/
>>> ?                *.app files
>>>                 *.erl files
>>>
>>> Basically, the idea is that project/* is under version control and then
>>> the erlang applications are built into the top/bld/erlang/ directory
>>> outside of version control in order to not pollute the project/*
>>> structure with *.beam files, as well as aid in packaging.
>>>
>>> Problem is that even though the erlang node has
>>> top/bld/erlang/application/ebin in the path, distel mode does not appear
>>> to try ../src/ based on the module location reported by the node.
>>>       
>>   could be that the OTP filelib functions don't follow links.
>>   are you using the GNU autotools to build out-of-tree?
>>     
>
> Did a little digging and from the bottom distel:find_source/1 certainly
> seems to find the source file (by the
> path /top/project/application/source.erl) correctly, so maybe there is
> something else going one unrelated to the source tree, or possibly
> tangentially related.  Here is the actual error I get in the
> *erl-output* buffer that is created when I toggle on interactive:
>
> ** Invalid beam file or no abstract code:
> "/top/project/application/source.erl"

  this in all likelihood means that the beam does not contain any debug 
info.
  try "erlc +debug_info" (the erlc equivalent of cc -g)

  the int man page (http://erlang.org/doc/man/int.html) says this;
"The interpreter needs both the source code and the object code, and the 
object code *must* include debug information. That is, only modules 
compiled with the option debug_info set can be interpreted."

  how you're supposed to get from the error message to finding that 
piece of doc is unclear. probably includes sacrificing chickens inside 
pentagrams (at least that's how i did it.)

  mats


From pfisher@REDACTED  Fri May 23 15:26:03 2008
From: pfisher@REDACTED (Paul Fisher)
Date: Fri, 23 May 2008 08:26:03 -0500
Subject: [erlang-questions] distel-mode with *.beam files separate
	from	source
In-Reply-To: <4836BC3A.8040602@gmail.com>
References: <1211509773.6476.58.camel@localhost>
	<4836867F.6020002@gmail.com> <1211542223.6310.7.camel@localhost>
	<4836BC3A.8040602@gmail.com>
Message-ID: <1211549163.6310.22.camel@localhost>

On Fri, 2008-05-23 at 14:44 +0200, Mats Cronqvist wrote:
> Paul Fisher wrote:
> > Did a little digging and from the bottom distel:find_source/1 certainly
> > seems to find the source file (by the
> > path /top/project/application/source.erl) correctly, so maybe there is
> > something else going one unrelated to the source tree, or possibly
> > tangentially related.  Here is the actual error I get in the
> > *erl-output* buffer that is created when I toggle on interactive:
> >
> > ** Invalid beam file or no abstract code:
> > "/top/project/application/source.erl"
> 
>   this in all likelihood means that the beam does not contain any debug 
> info.
>   try "erlc +debug_info" (the erlc equivalent of cc -g)

I'm certain that it does have debugging information, so the error
message is really not accurately reflecting the problem, which
ultimately the fact that int:i/1 cannot find any beam file to associate
with the absolute source path name.

The problem is that distel:find_source/1 in the face of this arrangement
locates the source file as:

  top/project/application/source.erl

rather than

  top/bld/erlang/application/src/source.erl

Then when it hands the former to the int:i/1 the interpreter does not
know how to find the source.beam file based on that location.

The core problem is that distel:get_source_file/2 should locate the
source at the latter location before the former location.  It prefers
the source file attribute in the beam file over all other alternatives
because src_from_beam/1 is first in the list that is passed to
try_srcs/1.  Works just great, except for these "out of tree" build
environments.

Seems to be that it would be preferable to simply move the result of
src_from_beam/1 to the end of the list that is handed to try_srcs/1.
Thoughts?

BTW, I see I forgot to answer you question about if I am using GNU
autotools to do the build.  The answer is no, just a few dozen line of
gmake gooberware in our build system.


-- 
paul



From chandrashekhar.mullaparthi@REDACTED  Fri May 23 15:27:53 2008
From: chandrashekhar.mullaparthi@REDACTED (Chandru)
Date: Fri, 23 May 2008 14:27:53 +0100
Subject: [erlang-questions] Multiple UDP receivers and senders
In-Reply-To: 
References: 
Message-ID: 

2008/5/23  :
> Also, does anybody know if it is possible to open a UDP socket in one
> Erlang process, receiving UDP messages in that process, whilst
> simultaneously sending UDP messages from the same port in a different
> Erlang process?
>

Yes - this is possible.

cheers
Chandru


From alexd@REDACTED  Fri May 23 15:52:36 2008
From: alexd@REDACTED (alexd@REDACTED)
Date: Fri, 23 May 2008 14:52:36 +0100
Subject: [erlang-questions] Multiple UDP receivers and senders
In-Reply-To: 
References: 
	
Message-ID: 

Chandru  wrote on 23/05/2008 
14:27:53:


> 2008/5/23  :
> > Also, does anybody know if it is possible to open a UDP socket in one
> > Erlang process, receiving UDP messages in that process, whilst
> > simultaneously sending UDP messages from the same port in a different
> > Erlang process?
> >
> 
> Yes - this is possible.

Great!

Do I need to do something special? Currently, I get {error, closed} when I 
try it. 

I suppose it's worth mentioning that I'm in two different Erlang VMs here, 
rather than different Erlang processes in the same VM.

Thanks!


Alex.


From pfisher@REDACTED  Fri May 23 16:15:00 2008
From: pfisher@REDACTED (Paul Fisher)
Date: Fri, 23 May 2008 09:15:00 -0500
Subject: [erlang-questions] distel-mode with *.beam files
	separate	from	source
In-Reply-To: <1211549163.6310.22.camel@localhost>
References: <1211509773.6476.58.camel@localhost>
	<4836867F.6020002@gmail.com> <1211542223.6310.7.camel@localhost>
	<4836BC3A.8040602@gmail.com>  <1211549163.6310.22.camel@localhost>
Message-ID: <1211552100.6310.26.camel@localhost>

On Fri, 2008-05-23 at 08:26 -0500, Paul Fisher wrote:
> On Fri, 2008-05-23 at 14:44 +0200, Mats Cronqvist wrote:
> > Paul Fisher wrote:
> > > Did a little digging and from the bottom distel:find_source/1 certainly
> > > seems to find the source file (by the
> > > path /top/project/application/source.erl) correctly, so maybe there is
> > > something else going one unrelated to the source tree, or possibly
> > > tangentially related.  Here is the actual error I get in the
> > > *erl-output* buffer that is created when I toggle on interactive:
> > >
> > > ** Invalid beam file or no abstract code:
> > > "/top/project/application/source.erl"
> > 
> >   this in all likelihood means that the beam does not contain any debug 
> > info.
> >   try "erlc +debug_info" (the erlc equivalent of cc -g)
> 
> I'm certain that it does have debugging information, so the error
> message is really not accurately reflecting the problem, which
> ultimately the fact that int:i/1 cannot find any beam file to associate
> with the absolute source path name.

"Certain" in the "it just has to be true" sense... ;->  Apparently it
does not, which leads me to another, very simple question:

Why doesn't the following, placed in the source file, result in
debugging information being generated in the .beam file

-compile([export_all, debug_info]).

?  The export_all works as expected, but the debug_info option does not
seem to work.


-- 
paul



From chandrashekhar.mullaparthi@REDACTED  Fri May 23 16:29:36 2008
From: chandrashekhar.mullaparthi@REDACTED (Chandru)
Date: Fri, 23 May 2008 15:29:36 +0100
Subject: [erlang-questions] Multiple UDP receivers and senders
In-Reply-To: 
References: 
	
	
Message-ID: 

2008/5/23  :
> Chandru  wrote on 23/05/2008
> 14:27:53:
>
>
>> 2008/5/23  :
>> > Also, does anybody know if it is possible to open a UDP socket in one
>> > Erlang process, receiving UDP messages in that process, whilst
>> > simultaneously sending UDP messages from the same port in a different
>> > Erlang process?
>> >
>>
>> Yes - this is possible.
>
> Great!
>
> Do I need to do something special? Currently, I get {error, closed} when I
> try it.
>
> I suppose it's worth mentioning that I'm in two different Erlang VMs here,
> rather than different Erlang processes in the same VM.
>

Ah, I see. I don't think this is supported. I vaguely remember a
discussion about something related on the mailing list a while ago,
but a search did not reveal it.

Chandru


From gleber.p@REDACTED  Fri May 23 16:54:19 2008
From: gleber.p@REDACTED (Gleb Peregud)
Date: Fri, 23 May 2008 07:54:19 -0700 (PDT)
Subject: [erlang-questions] re cord_info in module_info
In-Reply-To: 
References: <9b08084c0703060120q2158da64jf8c7d589209f77e3@mail.gmail.com>
	
Message-ID: <17427391.post@talk.nabble.com>



Bjorn Gustavsson wrote:
> It has been suggested before.
> 
> We might implement it, but definitely not before the book is out.
> 
> ...
> 
> /Bjorn
> -- 
> Bj?rn Gustavsson, Erlang/OTP, Ericsson AB
Hello.

Joe's book is already out ;) Is this feature on the to-do list?
-- 
View this message in context: http://www.nabble.com/record_info-in-module_info-tp9328852p17427391.html
Sent from the Erlang Questions mailing list archive at Nabble.com.



From matthew@REDACTED  Fri May 23 18:31:32 2008
From: matthew@REDACTED (Matthew Dempsky)
Date: Fri, 23 May 2008 09:31:32 -0700
Subject: [erlang-questions] zlib deflate problem
In-Reply-To: <48368AA3.5010103@erix.ericsson.se>
References: 
	
	<24d4f39c0805201043m73cee5a8xe37299270466cd22@mail.gmail.com>
	
	<4833D589.4070200@erix.ericsson.se>
	
	<48368AA3.5010103@erix.ericsson.se>
Message-ID: 

Awesome. Looking forward to R12B-3. :-)

On Fri, May 23, 2008 at 2:13 AM, Sverker Eriksson
 wrote:
> Yes, I have tested this myself now with some extra tracing. It is absolutely
> a bug not handling the non fatal error case of Z_BUF_ERROR. A fix will be
> included in R12B-3. I will do some more investigating, but as it looks now
> it will be the patch you suggested, Matthew.
>
> /Sverker, Erlang/OTP Ericsson
>
> Matthew Dempsky wrote:
>>
>> Has there been any further internal discussion on this patch?  I just
>> stumbled across this same bug as well.
>>
>> On Wed, May 21, 2008 at 12:55 AM, Sverker Eriksson
>>  wrote:
>>
>>>
>>> Matthew Dempsky wrote:
>>>
>>>>
>>>> On Tue, May 20, 2008 at 10:43 AM, Colm Dougan 
>>>> wrote:
>>>>
>>>>
>>>>>
>>>>> Matthew - I tried your patch and it worked.   I don't see any
>>>>> regression but I haven't done extensive testing. If you think this is
>>>>> the appropriate fix (rather than an exploratory patch) then I can
>>>>> install the patched erlang on my running system and do more testing.
>>>>>
>>>>>
>>>>
>>>> I think it should be safe for more testing.
>>>>
>>>>
>>>>
>>>
>>> Hi guys
>>>
>>> I've been looking at your patch Matthew, trying to understand it to
>>> decide if it should be part of the next OTP release. Do you have any
>>> more arguments why this would be the right way to do it?
>>>
>>>
>>>>
>>>> --- zlib_drv.c.orig   2008-05-19 19:09:00.000000000 -0700
>>>> +++ zlib_drv.c        2008-05-19 19:09:12.000000000 -0700
>>>> @@ -257,6 +257,10 @@
>>>>              driver_deq(d->port, len);
>>>>              return res;
>>>>          }
>>>> +         if (res == Z_BUF_ERROR) {
>>>> +             res = Z_OK;
>>>> +         }
>>>>          if (res < 0) {
>>>>              return res;
>>>>          }
>>>>
>>>
>>> As I understand it, a return of Z_BUF_ERROR from inflate() means
>>> something like "call me again with more buffer space". But in this case
>>> we don't call again.
>>>
>>> Do you have any more light to shed?
>>>
>>> /Sverker, Erlang/OTP Ericsson
>>>
>>> _______________________________________________
>>> erlang-questions mailing list
>>> erlang-questions@REDACTED
>>> http://www.erlang.org/mailman/listinfo/erlang-questions
>>>
>>>
>
>


From raould@REDACTED  Fri May 23 19:04:50 2008
From: raould@REDACTED (Raoul Duke)
Date: Fri, 23 May 2008 10:04:50 -0700
Subject: [erlang-questions] rpc is bad? (was Re: facebook chat server)
In-Reply-To: 
References: 
	
	
	
	<483495FC.2010007@dominicwilliams.net>
	<2CBBCB38-7789-440E-8BAA-5BA6DB5E6D55@hypotheticalabs.com>
	<65b2728e0805211956v3bb89b84q66a141721fce332b@mail.gmail.com>
	<48355084.70208@ericsson.com>
	<65b2728e0805220955p52904b2ex9e48bc8b36f70eb9@mail.gmail.com>
	
Message-ID: <91a2ba3e0805231004y4f7cebecxd2a3e0694a6c89b3@mail.gmail.com>

> thought about the weaker spots in most RPC protocols.

is this-all presumably pretty much the same thing as the classic
fallacies of distributed computing?

(although that list seems to keep growing random e.g.
http://feedblog.org/2007/09/23/distributed-computing-fallacy-9/ :-)

sincerely.


From vinoski@REDACTED  Fri May 23 19:54:36 2008
From: vinoski@REDACTED (Steve Vinoski)
Date: Fri, 23 May 2008 13:54:36 -0400
Subject: [erlang-questions] rpc is bad? (was Re: facebook chat server)
In-Reply-To: <91a2ba3e0805231004y4f7cebecxd2a3e0694a6c89b3@mail.gmail.com>
References: 
	
	
	<483495FC.2010007@dominicwilliams.net>
	<2CBBCB38-7789-440E-8BAA-5BA6DB5E6D55@hypotheticalabs.com>
	<65b2728e0805211956v3bb89b84q66a141721fce332b@mail.gmail.com>
	<48355084.70208@ericsson.com>
	<65b2728e0805220955p52904b2ex9e48bc8b36f70eb9@mail.gmail.com>
	
	<91a2ba3e0805231004y4f7cebecxd2a3e0694a6c89b3@mail.gmail.com>
Message-ID: <65b2728e0805231054r1faaa139o98a49532ddde40b@mail.gmail.com>

On 5/23/08, Raoul Duke  wrote:
> > thought about the weaker spots in most RPC protocols.
>
> is this-all presumably pretty much the same thing as the classic
>  fallacies of distributed computing?
>
>  (although that list seems to keep growing random e.g.
>  http://feedblog.org/2007/09/23/distributed-computing-fallacy-9/ :-)

It's related to the fallacies, yes. The fundamental problem of RPC,
which is trying to make remote calls look local, is based on
essentially trying to ignore the problems covered by the fallacies or
trying to pretend they don't even exist. You'll also find that many of
my columns for example reference the classic "A Note on Distributed
Computing" by Kendall, Waldo, Wollrath, and Wyant:



which covers some of the same territory. But the thoughts about the
impedance mismatches between IDLs and programming languages don't show
up in the fallacies at all and are generally often overlooked. I've
written about them here and there over the years, for example:



but I don't know of any definitive reference one can point to for this
issue. In that column, BTW, written a few years ago back when I was
still foolishly trying to make Web services work, I argued in favor of
IDLs over using a programming language to specify distributed
services. Given the choice of the two, I still strongly believe that's
correct, but today I would take a third option and argue against both,
as I did in my Mar/Apr 2008 column:



Today I think the impedance mismatch problem is worse than ever,
thanks to people who think they can sit comfortably within Java or C#
and just slap special programming language annotations to their
classes and methods so that tools can reverse-generate IDL and WSDL
from their code. It's the height of laziness and ignorance to think
that you can sit within the confines of a single language and generate
from it a language-independent distributed system that will avoid all
the impedance mismatch problems and distributed computing fallacies.
The people who push such tools and approaches ought to know better as
well.

--steve


From raould@REDACTED  Fri May 23 20:12:35 2008
From: raould@REDACTED (Raoul Duke)
Date: Fri, 23 May 2008 11:12:35 -0700
Subject: [erlang-questions] rpc is bad? (was Re: facebook chat server)
In-Reply-To: <65b2728e0805231054r1faaa139o98a49532ddde40b@mail.gmail.com>
References: 
	
	<483495FC.2010007@dominicwilliams.net>
	<2CBBCB38-7789-440E-8BAA-5BA6DB5E6D55@hypotheticalabs.com>
	<65b2728e0805211956v3bb89b84q66a141721fce332b@mail.gmail.com>
	<48355084.70208@ericsson.com>
	<65b2728e0805220955p52904b2ex9e48bc8b36f70eb9@mail.gmail.com>
	
	<91a2ba3e0805231004y4f7cebecxd2a3e0694a6c89b3@mail.gmail.com>
	<65b2728e0805231054r1faaa139o98a49532ddde40b@mail.gmail.com>
Message-ID: <91a2ba3e0805231112j2cd1f843r241c8ff8c50382a2@mail.gmail.com>

> from it a language-independent distributed system that will avoid all
> the impedance mismatch problems and distributed computing fallacies.
> The people who push such tools and approaches ought to know better as
> well.

Steve, your experience and comments are very interesting - you are
doing us all a service with your articles, thank you :)

Presumably some people manage to mostly get away with using web
services, or WSDL (i know i've been required to set up such a system
in previous jobs) and i guess apparently don't hit some eventual "holy
cow the universe is imploding how did this ever work" kid of
enlightenment moment. Why is that, or when will it happen, or what is
the prerequisite?

I guess in other words, if I were to try to convince somebody else
that the tricks above won't really work, what sorta-concrete-ish use
cases would be good examples?

And, to tie it back to Erlang, do you think that Erlang helps in some
way? (Presumably because it doesn't give you a mode where you think
things are instantaneous+synchronous by default.)

sincerely.


From zambal@REDACTED  Fri May 23 21:04:08 2008
From: zambal@REDACTED (zambal)
Date: Fri, 23 May 2008 12:04:08 -0700 (PDT)
Subject: [erlang-questions] distel-mode with *.beam files separate from
	source
In-Reply-To: <1211552100.6310.26.camel@localhost>
References: <1211509773.6476.58.camel@localhost> <4836867F.6020002@gmail.com> 
	<1211542223.6310.7.camel@localhost> <4836BC3A.8040602@gmail.com> 
	<1211549163.6310.22.camel@localhost>
	<1211552100.6310.26.camel@localhost>
Message-ID: <98a3dfca-c05a-4d2f-a10e-e05869ef3331@25g2000hsx.googlegroups.com>



On May 23, 4:15?pm, Paul Fisher  wrote:

> Why doesn't the following, placed in the source file, result in
> debugging information being generated in the .beam file
>
> -compile([export_all, debug_info]).
>
> ? ?The export_all works as expected, but the debug_info option does not
> seem to work.
>
> --
> paul

I had the same problem and came to the conclusion that if you use
c(File, Options) instead of c(File) to compile a module, you have to
explicitly set the debug_info as an option in order to compile it with
debug info, even if the -compile(debug_info) attribute is set.

Since the erlang-compile (C-c C-k) command in emacs uses c(File,
Options), the debug attribute flag in modules is ignored. After
looking into erlang.el, I learned that passing a prefix argument to
erlang-compile (so you have to press C-u C-c C-k), it sets the
debug_info option in its call to c(File, Options) and you have a
nicely debugable beam file :-)

However, it would be nice if somebody can confirm that the absence of
debug_info in Options of c(File, Options) indeed overrules the -
compile(debug_info) attribute.

vincent



From 0x6e6562@REDACTED  Fri May 23 21:58:18 2008
From: 0x6e6562@REDACTED (Ben Hood)
Date: Fri, 23 May 2008 20:58:18 +0100
Subject: [erlang-questions]  gproc
Message-ID: 

Hi,

I've read through Ulf's paper about gproc and would like to try out  
the code in svn,

I'm assuming that I have to apply all of the patches to my OTP  
installation.

Is there an easy way to do this, e.g. compiling them locally and  
starting Erlang with them in the load path?

Thx,

Ben


From 0x6e6562@REDACTED  Fri May 23 22:08:04 2008
From: 0x6e6562@REDACTED (Ben Hood)
Date: Fri, 23 May 2008 21:08:04 +0100
Subject: [erlang-questions] gproc
In-Reply-To: 
References: 
Message-ID: 

I think I've answered my own question:

1. svn co http://svn.ulf.wiger.net/gproc/ gproc
2. cd gproc
3. find . -name '*.erl' -exec erlc -o ebin {} \;
4. erl -pa ebin/ -boot start_sasl

1> gproc:info(whereis(gproc),gproc).
{gproc,[{{p,l,behaviour},gen_leader}]}

So simple, this is why I love Erlang.

Ben

On 23 May 2008, at 20:58, Ben Hood wrote:

> Hi,
>
> I've read through Ulf's paper about gproc and would like to try out  
> the code in svn,
>
> I'm assuming that I have to apply all of the patches to my OTP  
> installation.
>
> Is there an easy way to do this, e.g. compiling them locally and  
> starting Erlang with them in the load path?
>
> Thx,
>
> Ben



From vinoski@REDACTED  Sat May 24 00:24:48 2008
From: vinoski@REDACTED (Steve Vinoski)
Date: Fri, 23 May 2008 18:24:48 -0400
Subject: [erlang-questions] rpc is bad? (was Re: facebook chat server)
In-Reply-To: <91a2ba3e0805231112j2cd1f843r241c8ff8c50382a2@mail.gmail.com>
References:  <483495FC.2010007@dominicwilliams.net>
	<2CBBCB38-7789-440E-8BAA-5BA6DB5E6D55@hypotheticalabs.com>
	<65b2728e0805211956v3bb89b84q66a141721fce332b@mail.gmail.com>
	<48355084.70208@ericsson.com>
	<65b2728e0805220955p52904b2ex9e48bc8b36f70eb9@mail.gmail.com>
	
	<91a2ba3e0805231004y4f7cebecxd2a3e0694a6c89b3@mail.gmail.com>
	<65b2728e0805231054r1faaa139o98a49532ddde40b@mail.gmail.com>
	<91a2ba3e0805231112j2cd1f843r241c8ff8c50382a2@mail.gmail.com>
Message-ID: <65b2728e0805231524j4156f41cgb9506cc00d6d24d4@mail.gmail.com>

On 5/23/08, Raoul Duke  wrote:
> > from it a language-independent distributed system that will avoid all
>  > the impedance mismatch problems and distributed computing fallacies.
>  > The people who push such tools and approaches ought to know better as
>  > well.
>
> Steve, your experience and comments are very interesting - you are
>  doing us all a service with your articles, thank you :)

You're welcome, but thanks to you guys too -- this overall
conversation will likely serve as the basis for my next column. :-)

>  Presumably some people manage to mostly get away with using web
>  services, or WSDL (i know i've been required to set up such a system
>  in previous jobs) and i guess apparently don't hit some eventual "holy
>  cow the universe is imploding how did this ever work" kid of
>  enlightenment moment. Why is that, or when will it happen, or what is
>  the prerequisite?

That's an interesting question. The situation is, I think, similar to
Paul Graham's "Blub Paradox" 
where someone using a hypothetical average programming language named
Blub never even realizes there are better languages to use instead
because they think only in Blub. If all you know is generating WSDL
from a heavily-annotated Java class in Eclipse, you might not ever
consider there are better ways of getting the job done.

>  I guess in other words, if I were to try to convince somebody else
>  that the tricks above won't really work, what sorta-concrete-ish use
>  cases would be good examples?

WSDL, IDL and all that sort of stuff is made for cross-language,
cross-system integration. For me, therefore, the concrete cases
involve business changes requiring new integrations, such as mergers,
acquisitions, reorganizations, partnerships, new 3rd-party systems or
even just new versions of 3rd-party systems, etc. When faced with such
situations, which let's face it aren't all that uncommon, someone who
"designed" their system in a vacuum and generated WSDL and such from
their Java or C# code will be unhappy when they realize their
supposedly standard Web services stuff doesn't actually work with the
Web services stuff the other guy is using.

One of the most effective forms of enterprise integration I've seen
over the years is publish/subscribe messaging. I worked many years for
CORBA vendors, and we'd often lose potential deals to messaging
systems. Message queuing systems work well because (in no particular
order):

* they don't pretend to be programming language procedure or method
calls, so they avoid the associated impedance mismatch problems
* they don't try to hide distributed systems issues
* coupling is low -- drop a message into a queue here, pick up a
message from a queue there
* queues can be persistent, or more generally, delivery guarantees can
be varied as needed
* asynchrony
* payloads need not conform to some made-up IDL type system
* getting two different messaging systems to interoperate is easier
than getting two different RPC or distributed object systems to
interoperate

The problem with messaging systems, though, is that traditionally
they've been quite expensive. Thankfully, I believe AMQP
() solves that issue nicely, and of course Erlang is
the perfect way to implement it, which Alexis, Tony, and the rest of
the RabbitMQ guys have already done ().

>  And, to tie it back to Erlang, do you think that Erlang helps in some
>  way? (Presumably because it doesn't give you a mode where you think
>  things are instantaneous+synchronous by default.)

Let's say we view an enterprise system or even the web as an
integrated set of cells, where cells are ideally as loosely coupled as
possible. Within a cell, we can hopefully use whatever language or
technology we want in order to provide or consume services to/from
other cells with no fear of our technology or implementation choices
leaking across to other cells. I used the term "cell" rather than
"host" here, BTW, because distribution may be, and in fact most likely
is, employed not only between cells but also within cells. For
example, consider Amazon.com's S3 service as a cell; it consists of
large server farms in the back end which interoperate and communicate
using whatever software, systems, and protocols individual teams
within Amazon.com might choose to use, but users access the service
from their own cells via HTTP. For intra-enterprise non-web systems,
this concept also holds, because you might have, for example, a
replicated J2EE service running on a set of clustered hosts for
availability and reliability, talking to a replicated database in
another tier. Large enterprises would consist of many such cells, most
of them visible only internally on their own intranets.

In such situations, Erlang helps in at least two ways:

1. Implementing cells using Erlang is typically much easier than
implementing them with Java or C++ or C# or whatever. Not only is the
language simpler, but because Erlang/OTP already has many of the hard
parts of distribution and concurrency effectively built in, it allows
cells to be developed and implemented in less time with less code and
at lower cost. For heterogeneous cells, Erlang ports and FFIs make it
possible to join Erlang systems with other existing systems within the
same cell, too, such as Jinterface for Java systems.

2. Cells presumably integrate across fairly standard protocols, such
as HTTP, IIOP, or AMQP. Erlang is superior here too -- it already
supports a variety of standard protocols, and it makes writing new
clients and servers for other such protocols relatively easy.
Furthermore, it makes it easier and less expensive to write the
systems that sit at the edges of cells and integrate with other cells
such that those systems are scalable, reliable, and highly-available.

hope this helps,
--steve


From klacke@REDACTED  Sat May 24 00:30:41 2008
From: klacke@REDACTED (Claes Wikstrom)
Date: Sat, 24 May 2008 00:30:41 +0200
Subject: [erlang-questions] rpc is bad? (was Re: facebook chat server)
In-Reply-To: <65b2728e0805231054r1faaa139o98a49532ddde40b@mail.gmail.com>
References: 			<483495FC.2010007@dominicwilliams.net>	<2CBBCB38-7789-440E-8BAA-5BA6DB5E6D55@hypotheticalabs.com>	<65b2728e0805211956v3bb89b84q66a141721fce332b@mail.gmail.com>	<48355084.70208@ericsson.com>	<65b2728e0805220955p52904b2ex9e48bc8b36f70eb9@mail.gmail.com>		<91a2ba3e0805231004y4f7cebecxd2a3e0694a6c89b3@mail.gmail.com>
	<65b2728e0805231054r1faaa139o98a49532ddde40b@mail.gmail.com>
Message-ID: <48374591.4070203@hyber.org>

Steve Vinoski wrote:

> It's related to the fallacies, yes. The fundamental problem of RPC,
> which is trying to make remote calls look local, is based on
> essentially trying to ignore the problems covered by the fallacies or
> trying to pretend they don't even exist. 


I really like the above paragraph. Ages ago when I was naive, and I'd just
implemented distributed erlang with the basic concepts like
spawn/4, link/1 and most importantly {Name, Node} ! Message
I then set out to build higher level libraries on top of those
basic low level mechanisms. We still see the traces of those efforts
in the otp libs today.

Think rpc:multicall(), the pg and pg2 modules , mnesia hidden replication, etc.
Now some 10 years later I've never ever used those functions that try to hide
the network - even though I wrote them. Interesting.

I have used rpc:call/4 extensively though but it doesn't hide the network.

/klacke







From 0x6e6562@REDACTED  Sat May 24 01:40:24 2008
From: 0x6e6562@REDACTED (Ben Hood)
Date: Sat, 24 May 2008 00:40:24 +0100
Subject: [erlang-questions] rpc is bad? (was Re: facebook chat server)
In-Reply-To: <65b2728e0805231524j4156f41cgb9506cc00d6d24d4@mail.gmail.com>
References:  <483495FC.2010007@dominicwilliams.net>
	<2CBBCB38-7789-440E-8BAA-5BA6DB5E6D55@hypotheticalabs.com>
	<65b2728e0805211956v3bb89b84q66a141721fce332b@mail.gmail.com>
	<48355084.70208@ericsson.com>
	<65b2728e0805220955p52904b2ex9e48bc8b36f70eb9@mail.gmail.com>
	
	<91a2ba3e0805231004y4f7cebecxd2a3e0694a6c89b3@mail.gmail.com>
	<65b2728e0805231054r1faaa139o98a49532ddde40b@mail.gmail.com>
	<91a2ba3e0805231112j2cd1f843r241c8ff8c50382a2@mail.gmail.com>
	<65b2728e0805231524j4156f41cgb9506cc00d6d24d4@mail.gmail.com>
Message-ID: 

Steve,

Great post!

On 23 May 2008, at 23:24, Steve Vinoski wrote:

> Message queuing systems work well because (in no particular
> order):

.....

> * payloads need not conform to some made-up IDL type system
> * getting two different messaging systems to interoperate is easier
> than getting two different RPC or distributed object systems to
> interoperate

Just out of interest's sake, in your experience, is there a *right*  
way to interpret the payload of the message?

With IDL/WSDL you know ahead of time how to decode the payload, if you  
defer it to a *dynamic* approach, IMHO you have to some kind of a  
priori knowledge of the structure of the data and have to be able to  
create instances of those data structures on the fly in your target  
language.

I ask this question because I took the following approach ( http://hopper.squarespace.com/blog/2008/5/22/pet-store-part-1.html 
  ) to the problem you are talking about, but am just questioning  
whether my own approach has any merit at all.

Thx,

Ben



From hayeah@REDACTED  Sat May 24 02:43:03 2008
From: hayeah@REDACTED (Howard Yeh)
Date: Fri, 23 May 2008 17:43:03 -0700
Subject: [erlang-questions] atom table limit & erlang shell
Message-ID: 

Hi,

What happens if I exceed the atom table limit, and how would I know?

i am doing some code generation, which dynamically create maybe
2000~3000 new atoms (which are reused for later). Would that go over
the limit?

Anyway, it seems that the shell goes into a loop. The function that
does the generation would return properly, but I don't get the prompt
back...

it works fine for smaller test cases, so I am suspecting it might have
something to do with the atom table limit. Can somebody help me to
find out more?

Howard


From jeremy@REDACTED  Sat May 24 02:46:49 2008
From: jeremy@REDACTED (Jeremy Wall)
Date: Fri, 23 May 2008 19:46:49 -0500
Subject: [erlang-questions] Mocking in Erlang
Message-ID: <69d143cd0805231746p7f8ed4cdl91e0f6fdd7da8025@mail.gmail.com>

While browsing the erlang-questions list archives I found mention that
someone had written a Mocking Module for erlang that would mock processes.
I'm wondering if that ever got published anywhere or if there are other
mocking frameworks for erlang that have been used. I love TestFirst
development but it would be a lot easier if I could mock outside sources
when I write my tests.

-- 
Jeremy Wall
http://jeremy.marzhillstudios.com
Jeremy@REDACTED
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From ulf@REDACTED  Sat May 24 10:45:22 2008
From: ulf@REDACTED (Ulf Wiger)
Date: Sat, 24 May 2008 10:45:22 +0200
Subject: [erlang-questions] gproc
In-Reply-To: 
References: 
Message-ID: <8209f740805240145r36cde840wdfac36d077c6662e@mail.gmail.com>

Hi,

The patches are really only necessary if you want gproc to become
a part of the kernel application, and the behaviors to store
metadata in gproc automatically.

If you just want to use gproc, you don't need any patches,
but it would of course be nice to have a gproc application.
(One of these days...)

Also note that the gen_leader patch in the svn directory
really shouldn't be used. In my rush to meet the submission
deadline, I accidentally patched the old gen_leader instead
of the new one. The two changes I made to gen_leader were

- making sure that it can start when there is only one known
  node. This is a trivial case.
- making sure that it can start in local mode only, and later
  start the leader election. This is only needed if gproc is
  started before Distributed Erlang is started.

BR,
Ulf W

2008/5/23 Ben Hood <0x6e6562@REDACTED>:
> Hi,
>
> I've read through Ulf's paper about gproc and would like to try out
> the code in svn,
>
> I'm assuming that I have to apply all of the patches to my OTP
> installation.
>
> Is there an easy way to do this, e.g. compiling them locally and
> starting Erlang with them in the load path?
>
> Thx,
>
> Ben
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>


From rvirding@REDACTED  Sat May 24 12:38:04 2008
From: rvirding@REDACTED (Robert Virding)
Date: Sat, 24 May 2008 12:38:04 +0200
Subject: [erlang-questions] atom table limit & erlang shell
In-Reply-To: 
References: 
Message-ID: <3dbc6d1c0805240338v410cb46cm2dec3119914df936@mail.gmail.com>

Hi Howard,

I did a small test on my system, R12B-0 on Windows, with small loop which
just created atoms. It crashed the system when the atom table became full,
1048576 entries. Also this was the reason given in the crash dump. Why the
shell goes wrong I don't know, could be you do something else which hangs
it.

My code:

run(N) ->
    if (N rem 1000) =:= 0 -> io:fwrite("~p\n", [N]);
       true -> ok
    end,
    case catch list_to_atom("a" ++ integer_to_list(N)) of
        A when is_atom(A) -> run(N+1);
        Other -> {Other,N}
    end.

Printed 947000 before it crashes.

Robert


2008/5/24 Howard Yeh :

> Hi,
>
> What happens if I exceed the atom table limit, and how would I know?
>
> i am doing some code generation, which dynamically create maybe
> 2000~3000 new atoms (which are reused for later). Would that go over
> the limit?
>
> Anyway, it seems that the shell goes into a loop. The function that
> does the generation would return properly, but I don't get the prompt
> back...
>
> it works fine for smaller test cases, so I am suspecting it might have
> something to do with the atom table limit. Can somebody help me to
> find out more?
>
> Howard
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From ulf@REDACTED  Sat May 24 13:39:33 2008
From: ulf@REDACTED (Ulf Wiger)
Date: Sat, 24 May 2008 13:39:33 +0200
Subject: [erlang-questions] rpc is bad? (was Re: facebook chat server)
In-Reply-To: <65b2728e0805231524j4156f41cgb9506cc00d6d24d4@mail.gmail.com>
References: 
	<2CBBCB38-7789-440E-8BAA-5BA6DB5E6D55@hypotheticalabs.com>
	<65b2728e0805211956v3bb89b84q66a141721fce332b@mail.gmail.com>
	<48355084.70208@ericsson.com>
	<65b2728e0805220955p52904b2ex9e48bc8b36f70eb9@mail.gmail.com>
	
	<91a2ba3e0805231004y4f7cebecxd2a3e0694a6c89b3@mail.gmail.com>
	<65b2728e0805231054r1faaa139o98a49532ddde40b@mail.gmail.com>
	<91a2ba3e0805231112j2cd1f843r241c8ff8c50382a2@mail.gmail.com>
	<65b2728e0805231524j4156f41cgb9506cc00d6d24d4@mail.gmail.com>
Message-ID: <8209f740805240439w4126a851tb611a77289b35bfc@mail.gmail.com>

2008/5/24 Steve Vinoski :
> On 5/23/08, Raoul Duke  wrote:
>
>>  Presumably some people manage to mostly get away with using web
>>  services, or WSDL (i know i've been required to set up such a system
>>  in previous jobs) and i guess apparently don't hit some eventual "holy
>>  cow the universe is imploding how did this ever work" kid of
>>  enlightenment moment. Why is that, or when will it happen, or what is
>>  the prerequisite?
>
> That's an interesting question. The situation is, I think, similar to
> Paul Graham's "Blub Paradox" 
> where someone using a hypothetical average programming language named
> Blub never even realizes there are better languages to use instead
> because they think only in Blub. If all you know is generating WSDL
> from a heavily-annotated Java class in Eclipse, you might not ever
> consider there are better ways of getting the job done.

This reminds me of many discussions I've had with people about
concurrency models. My impression has been that many projects
set out to implement systems with lots of complex concurrency,
but without the underlying semantics to deal with it. They verify
their concepts using trivial examples (where the nastiness doesn't
surface), and then happily press on, thinking "how difficult can it
get?"). When their universe finally does implode, this is blamed on
all other kinds of issues, but few people are willing to accept the
idea that the underlying semantics of their architecture invariably
led them into a nightmare of complexity explosion that could have
been avoided with a different approach.

With the programming challenge some order of magnitude more
difficult than it should have been, you will of course have tons of
project management difficulties to pin your failure on. ;-)

BR,
Ulf W


From thomasl_erlang@REDACTED  Sat May 24 13:17:16 2008
From: thomasl_erlang@REDACTED (Thomas Lindgren)
Date: Sat, 24 May 2008 04:17:16 -0700 (PDT)
Subject: [erlang-questions] atom table limit & erlang shell
In-Reply-To: 
Message-ID: <472785.70532.qm@web38803.mail.mud.yahoo.com>


--- Howard Yeh  wrote:

> Hi,
> 
> What happens if I exceed the atom table limit, and
> how would I know?

Why not try it? For example,

atom_killer() -> atom_killer(0).

atom_killer(N) ->
   list_to_atom(integer_to_list(N)),
   atom_killer(N+1).

(Running that on my mac gave a bus error and a crash
dump.)

> i am doing some code generation, which dynamically
> create maybe
> 2000~3000 new atoms (which are reused for later).
> Would that go over
> the limit?

No, the max number is 1048576.

http://www.erlang.org/doc/efficiency_guide/advanced.html

You can also see the amount of memory used for
different purposes with erlang:memory/1, for instance
erlang:memory(atom_used).

Best,
Thomas



      


From saleyn@REDACTED  Sat May 24 14:37:06 2008
From: saleyn@REDACTED (Serge Aleynikov)
Date: Sat, 24 May 2008 08:37:06 -0400
Subject: [erlang-questions] inets - mod_esi accessing #mod.config_db
Message-ID: <48380BF2.1070203@gmail.com>

I am having trouble trying to figure out how to get the web server's 
document_root (or how to convert some RequestURI's document path to a 
filesystem path) inside a mod_esi's execution function.

Say, we have a function callable by a client through mod_esi:

get_image(SessionID, Env, Input) ->
     ImageFile = doc_root(filename:join(["/images", Input, ".gif"])),
     case read_image(ImageFile) of
     {ok, Image} ->
         mod_esi:deliver(SessionID, [
             "Content-type: image/gif\r\n\r\n",
         ]);
     {error, Reason} ->
         mod_esi:deliver(SessionID, [
             "status: ", integer_to_list(400), " Not Found\r\n\r\n"
         ])
     end.

doc_root(DocPath) ->
     ???

How do we implement the function doc_root?  It's quite easy if we have 
access to the #mod.config_db:
    mod_alias:path(Info#mod.data, Info#mod.config_db, DocPath)

However #mod{} record is not passed to the mod_esi's callback, so it's 
not possible to use mod_alias:path/3 as is.

Serge


From ulf@REDACTED  Sat May 24 14:55:01 2008
From: ulf@REDACTED (Ulf Wiger)
Date: Sat, 24 May 2008 14:55:01 +0200
Subject: [erlang-questions] cost of integrating 3rd party SW
Message-ID: <8209f740805240555l3262634aj3a1a59f7075a3b0c@mail.gmail.com>

Perhaps somewhat related to the "RPC is bad" thread,
do any of you know of any reasonably systematic
discussions about whether or not Erlang is good or
bad at interfacing with 3rd party components?

It's something that pops up every once in a while,
e.g. in the Facebook chat server article: that combining
Erlang with components written in other languages is
hard.

I know that sometimes, decisions have been made to
rather write a component from scratch in Erlang, rather
than interfacing with some COTS component, based on
the assumption that it will be both cheaper and better
to do this than to deal with the 3rd party component.
This is always a hard sell, and usually meets with the
exclamation: "aha! Erlang is bad at interfacing with other
software."

And of course, any programmer will always opt to write
something from scratch rather than reuse something
that someone else has written, right?  ;-)

What I'm after is a more sober and objective account,
based on real experience and (ideally) cost comparisons.
I'm perfectly ok if the conclusion is that Erlang indeed
does need to improve.

Cost is of course not the only parameter. Performance,
robustness, debugging and maintenance, impedance
mismatch (and if so, what is the preferred solution?
Keep Erlang or throw it out?)

BR,
Ulf W


From monch1962@REDACTED  Sat May 24 15:03:18 2008
From: monch1962@REDACTED (David Mitchell)
Date: Sat, 24 May 2008 23:03:18 +1000
Subject: [erlang-questions] Simple redirection question
Message-ID: 

Hello group,

I've got what's probably a very simple problem, but I can't work out
how to do it.

Simple code sample:
T = "os".
T:getenv().

I want the second line to perform "os:getenv()", but can't work out
how to do it.  I figure it must be possible to do this sort of
redirection somehow...

Any suggestions?

Thanks in advance

Dave M.


From monch1962@REDACTED  Sat May 24 15:08:42 2008
From: monch1962@REDACTED (David Mitchell)
Date: Sat, 24 May 2008 23:08:42 +1000
Subject: [erlang-questions] Simple redirection question
In-Reply-To: 
References: 
Message-ID: 

Never mind - this works...

T = list_to_atom("os").
T:getenv().

Dave M.

2008/5/24 David Mitchell :
> Hello group,
>
> I've got what's probably a very simple problem, but I can't work out
> how to do it.
>
> Simple code sample:
> T = "os".
> T:getenv().
>
> I want the second line to perform "os:getenv()", but can't work out
> how to do it.  I figure it must be possible to do this sort of
> redirection somehow...
>
> Any suggestions?
>
> Thanks in advance
>
> Dave M.
>


From erlang-questions_efine@REDACTED  Sat May 24 16:47:24 2008
From: erlang-questions_efine@REDACTED (Edwin Fine)
Date: Sat, 24 May 2008 10:47:24 -0400
Subject: [erlang-questions] cost of integrating 3rd party SW
In-Reply-To: <8209f740805240555l3262634aj3a1a59f7075a3b0c@mail.gmail.com>
References: <8209f740805240555l3262634aj3a1a59f7075a3b0c@mail.gmail.com>
Message-ID: <6c2563b20805240747o2cf4f5adge72fde42442d3713@mail.gmail.com>

I just wish that linked-in drivers were easier to implement. Ports are not
always appropriate. Having done a few integrations using Ruby's equivalent
of the LID, Erlang's was a bit of a shock to the system when I wanted to add
a simple CRC-16 routine in C. I eventually got it done, but it was a
comparative pain in the a**.

Edwin Fine

On Sat, May 24, 2008 at 8:55 AM, Ulf Wiger  wrote:

> Perhaps somewhat related to the "RPC is bad" thread,
> do any of you know of any reasonably systematic
> discussions about whether or not Erlang is good or
> bad at interfacing with 3rd party components?
>
> It's something that pops up every once in a while,
> e.g. in the Facebook chat server article: that combining
> Erlang with components written in other languages is
> hard.
>
> I know that sometimes, decisions have been made to
> rather write a component from scratch in Erlang, rather
> than interfacing with some COTS component, based on
> the assumption that it will be both cheaper and better
> to do this than to deal with the 3rd party component.
> This is always a hard sell, and usually meets with the
> exclamation: "aha! Erlang is bad at interfacing with other
> software."
>
> And of course, any programmer will always opt to write
> something from scratch rather than reuse something
> that someone else has written, right?  ;-)
>
> What I'm after is a more sober and objective account,
> based on real experience and (ideally) cost comparisons.
> I'm perfectly ok if the conclusion is that Erlang indeed
> does need to improve.
>
> Cost is of course not the only parameter. Performance,
> robustness, debugging and maintenance, impedance
> mismatch (and if so, what is the preferred solution?
> Keep Erlang or throw it out?)
>
> BR,
> Ulf W
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From 0x6e6562@REDACTED  Sat May 24 17:28:54 2008
From: 0x6e6562@REDACTED (Ben Hood)
Date: Sat, 24 May 2008 16:28:54 +0100
Subject: [erlang-questions] cost of integrating 3rd party SW
In-Reply-To: <8209f740805240555l3262634aj3a1a59f7075a3b0c@mail.gmail.com>
References: <8209f740805240555l3262634aj3a1a59f7075a3b0c@mail.gmail.com>
Message-ID: <70453ABE-4A5E-4879-BB89-B43675A2A742@gmail.com>

Ulf,

On 24 May 2008, at 13:55, Ulf Wiger wrote:

> Perhaps somewhat related to the "RPC is bad" thread,
> do any of you know of any reasonably systematic
> discussions about whether or not Erlang is good or
> bad at interfacing with 3rd party components?

I think it depends what you mean by being good at interfacing with  
foreign language components.

I don't think this is a Erlang specific issue.

Some runtimes can interpret foreign opcodes, e.g. JRuby or compile to  
a multitude of target languages, e.g. CLR,  but a lot of the time you  
are communicating via sockets.

And when you have socket communication, it just comes down to the  
serialization protocol between the two runtimes.

>
> It's something that pops up every once in a while,
> e.g. in the Facebook chat server article: that combining
> Erlang with components written in other languages is
> hard.

I don't think so. I think it's just as hard from any language. The  
gist of the Thrift is they've defined a cross-language serialization  
format.

>
> I know that sometimes, decisions have been made to
> rather write a component from scratch in Erlang, rather
> than interfacing with some COTS component, based on
> the assumption that it will be both cheaper and better
> to do this than to deal with the 3rd party component.
> This is always a hard sell, and usually meets with the
> exclamation: "aha! Erlang is bad at interfacing with other
> software."

What I would find really cool is to be able to embed a VM for a  
foreign language inside an Erlang runtime.

That way you could re-use 3rd party components in foreign instruction  
sets in the same address space as the Erlang code.

HTH,

Ben


From per.melin@REDACTED  Sat May 24 17:36:04 2008
From: per.melin@REDACTED (Per Melin)
Date: Sat, 24 May 2008 17:36:04 +0200
Subject: [erlang-questions] cost of integrating 3rd party SW
In-Reply-To: <8209f740805240555l3262634aj3a1a59f7075a3b0c@mail.gmail.com>
References: <8209f740805240555l3262634aj3a1a59f7075a3b0c@mail.gmail.com>
Message-ID: 

2008/5/24 Ulf Wiger :
> It's something that pops up every once in a while,
> e.g. in the Facebook chat server article: that combining
> Erlang with components written in other languages is
> hard.

As a consultant I see a lot of components built in-house at different
companies in different languages that use RDBMSs to interface with
each other and COTSs. Often it's the completely wrong tool for the
job, but it's used because it's easy. It doesn't matter if you mix
Java, C++, Ruby, Python, PHP, C# and Perl; they usually (always?) have
drivers/APIs to talk to the major RDBMSs, and you can assume that they
are well used and therefor (probably) stable.

When I read or hear someone talk about using Erlang as part of a
larger system the state of the RDBMS drivers usually comes into
question.

I'm currently trying to fit Erlang into one of these puzzles of
components that communicate through databases myself, and at least now
initially I'm feeling pain. Connecting to Oracle over ODBC on Linux
has so far been wobbly. Next to try is the Postgres driver, but at
version 0.1.x my expectations are low.


From rvirding@REDACTED  Sat May 24 17:39:40 2008
From: rvirding@REDACTED (Robert Virding)
Date: Sat, 24 May 2008 17:39:40 +0200
Subject: [erlang-questions] Leex - a lexical anaylzer generator, released
Message-ID: <3dbc6d1c0805240839k24b5a91cq71346591fe0faed8@mail.gmail.com>

This is the first proper release of leex. Changes from the previous
non-release version are:

- It now has a proper open-source license.
- An elusive bug has been found to have been a bug and has been fixed.
- A cool new option dfa_graph has been added. Thanks for Sebastian Egner for
showing me the possiblities.
- There is now some documentation. Yeah!

Apart from this there are no other noticeable changes. The Erlang and LFE
token syntaxes are included as examples.

It can be downloaded from TrapExit:

http://forum.trapexit.org/viewtopic.php?p=43924#43924

Robert
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From saleyn@REDACTED  Sat May 24 17:41:19 2008
From: saleyn@REDACTED (Serge Aleynikov)
Date: Sat, 24 May 2008 11:41:19 -0400
Subject: [erlang-questions] supervisor_bridge enhancement
Message-ID: <4838371F.9030308@gmail.com>

Currently the supervisor_bridge behavior doesn't expose 
Mod:handle_call/3 and Mod:handle_info/3 callbacks.  When using this 
behavior to provide custom startup for some application's server (such 
as inets' httpd) I frequently find it lacking the ability to report a 
Pid of the bridged child or provide handling of custom messages.

Attached is a prototype of supervisor_bridge extension that adds a new 
function get_child_pid/1, as well as new callbacks Mod:handle_call/3, 
Mod:handle_cast/2, and handle_info/2.

Some possible applications of this module could be to implement:
a. timed instantiation of the bridged Pid (e.g. run the bridged module 
only between certain hours of a day).
b. registration of the bridged Pid of a 3rd party server (if it doesn't 
register itself).

It would be nice if this supervisor_bridge extension could make it to 
the distribution.

Serge
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sup_bridge.erl
Type: text/x-erlang
Size: 6228 bytes
Desc: not available
URL: 

From vinoski@REDACTED  Sat May 24 23:37:01 2008
From: vinoski@REDACTED (Steve Vinoski)
Date: Sat, 24 May 2008 17:37:01 -0400
Subject: [erlang-questions] rpc is bad? (was Re: facebook chat server)
In-Reply-To: 
References: 
	<65b2728e0805211956v3bb89b84q66a141721fce332b@mail.gmail.com>
	<48355084.70208@ericsson.com>
	<65b2728e0805220955p52904b2ex9e48bc8b36f70eb9@mail.gmail.com>
	
	<91a2ba3e0805231004y4f7cebecxd2a3e0694a6c89b3@mail.gmail.com>
	<65b2728e0805231054r1faaa139o98a49532ddde40b@mail.gmail.com>
	<91a2ba3e0805231112j2cd1f843r241c8ff8c50382a2@mail.gmail.com>
	<65b2728e0805231524j4156f41cgb9506cc00d6d24d4@mail.gmail.com>
	
Message-ID: <65b2728e0805241437q35170ef8oa4e733b3a5973b0f@mail.gmail.com>

On 5/23/08, Ben Hood <0x6e6562@REDACTED> wrote:
> Steve,
>
>  Great post!

Thanks. :-)

>  On 23 May 2008, at 23:24, Steve Vinoski wrote:
>
>  > Message queuing systems work well because (in no particular
>  > order):
> .....
>
>  > * payloads need not conform to some made-up IDL type system
>  > * getting two different messaging systems to interoperate is easier
>  > than getting two different RPC or distributed object systems to
>  > interoperate
>
> Just out of interest's sake, in your experience, is there a *right*
>  way to interpret the payload of the message?
>
>  With IDL/WSDL you know ahead of time how to decode the payload, if you
>  defer it to a *dynamic* approach, IMHO you have to some kind of a
>  priori knowledge of the structure of the data and have to be able to
>  create instances of those data structures on the fly in your target
>  language.

Some sort of prior knowledge of what you're receiving is always
required, but such knowledge can contain many levels of indirection.
For example, you might dynamically load on demand the code necessary
to interpret the payload, perhaps based on a received key or something
like that, and so approaches can be extremely dynamic if desired. It
all depends on what you're trying to achieve, of course.

In IDL-based systems, the IDL language typically defines primitive
data types that can be combined into user-defined types like structs.
The system's protocol defines how these data types, both primitive and
user-defined, are to be written to and read from messages. As long as
both sides of the wire agree on the IDL types, the infrastructure
takes care of proper payload marshaling, and all is well.

In REST, payload types are indicated by media types. With the HTTP
flavor of REST, MIME types serve as media types. As long as sender and
receiver can agree on the MIME types for the messages they exchange,
and assuming both sides can properly encode and decode messages
containing those types, all is well.

In the first example there usually isn't any type information or extra
information of any sort encoded into the messages; receivers are
assumed to know what to expect, and it's assumed both sender and
receiver contain equivalent and compatible code artifacts, typically
auto-generated from the same IDL specifications, for interpreting
message payloads.

In the second example, sender and receiver agree on the MIME type,
thereby agreeing on the payload definition. MIME types are globally
known, so you can build totally independent applications that can
later exchange messages based on those MIME types. The payload itself
might contain extra information to help with decoding or it might not;
it all depends on the MIME type definition, to which both sender and
receiver are expected to conform. Coupling here is much less than with
the first approach, as I explained in this recent article:



These are but two examples, but many variations on these themes and
others have been employed in many different distributed systems.

As for data representation within the application, that's a whole
different issue, and it gets into the impedance mismatch problems I
talked about. Take XML or JSON, for example. Normally sent over the
wire as text, they are represented in different programming languages
differently, each representation preferably making the data as natural
as possible to use within that language. A JavaScript object one on
side of the wire already *is* JSON, for example, with zero impedance
mismatch, but when sent to Erlang, it typically becomes a mixture of
tuples, lists, atoms, and strings, with some degree of impedance
mismatch.

CORBA is one example of the IDL-based systems described above, so it
expects the receiver to know what to expect in each message, but it
does contain one interesting data type as far as representation goes:
the Any type. An Any is a (type, value) pair. The type is represented
by a TypeCode, which is essentially a pass-by-value CORBA object. The
value is some sort of language representation of an IDL type. When
marshaled, both type and value are included. The receiver knows only
to expect an Any because that's all the IDL specifies, but that
receiver might not have compile-time knowledge of the type the Any
contains. For example, an event service has to deal with event data
represented as Any; any event producer application can connect to the
service and deliver whatever data inside its Anys that it wants to,
and the event service has to be able to receive those events and then
send them back out to any interested subscribers. (Obviously, the
event service can't be recompiled every time someone invents a new IDL
type.) This gets real interesting in a language like C++ -- how do you
represent a type like a struct for which you have no compile-time
knowledge? One answer is that you represent it as a list of the
primitive IDL types that make up the struct, for which your
application will always have compile-time knowledge. The Any's
TypeCode can be traversed to determine all such primitives. Another
approach is to keep the Any data in marshaled form until it reaches a
point that knows how to unmarshal it. Implementing all that support in
a way that's reasonably efficient can be fun and challenging, but it's
an example that shows there could be many different representations
for the same data type, depending on context, even within just one
language.

>  I ask this question because I took the following approach ( http://hopper.squarespace.com/blog/2008/5/22/pet-store-part-1.html
>   ) to the problem you are talking about, but am just questioning
>  whether my own approach has any merit at all.

I glanced over it and it looks fine to me, though I did see the word
"RPC" used there a few times ;-). You're using AMQP and RabbitMQ,
which is good. Ultimately, you have to choose some form for your
message payloads, and you chose Cotton; while I've never heard of
Cotton before and so don't know any details about it, it seems to fit
your application well.

--steve


From vinoski@REDACTED  Sat May 24 23:52:48 2008
From: vinoski@REDACTED (Steve Vinoski)
Date: Sat, 24 May 2008 17:52:48 -0400
Subject: [erlang-questions] cost of integrating 3rd party SW
In-Reply-To: 
References: <8209f740805240555l3262634aj3a1a59f7075a3b0c@mail.gmail.com>
	
Message-ID: <65b2728e0805241452m107ec20av8acd029615ab6354@mail.gmail.com>

On 5/24/08, Per Melin  wrote:
> 2008/5/24 Ulf Wiger :
>
> > It's something that pops up every once in a while,
>  > e.g. in the Facebook chat server article: that combining
>  > Erlang with components written in other languages is
>  > hard.
>
>
> As a consultant I see a lot of components built in-house at different
>  companies in different languages that use RDBMSs to interface with
>  each other and COTSs. Often it's the completely wrong tool for the
>  job, but it's used because it's easy. It doesn't matter if you mix
>  Java, C++, Ruby, Python, PHP, C# and Perl; they usually (always?) have
>  drivers/APIs to talk to the major RDBMSs, and you can assume that they
>  are well used and therefor (probably) stable.
>
>  When I read or hear someone talk about using Erlang as part of a
>  larger system the state of the RDBMS drivers usually comes into
>  question.

Hi Ulf, I agree with Per -- databases seem to be a weak link. I have
an application where I had to front the database with a bridge written
in a different language and then integrate my Erlang app with that
through the network.

Other than that, I've had great success with network-based
integrations over various protocols.

--steve


From 0x6e6562@REDACTED  Sun May 25 00:25:31 2008
From: 0x6e6562@REDACTED (Ben Hood)
Date: Sat, 24 May 2008 23:25:31 +0100
Subject: [erlang-questions] rpc is bad? (was Re: facebook chat server)
In-Reply-To: <65b2728e0805241437q35170ef8oa4e733b3a5973b0f@mail.gmail.com>
References: 
	<65b2728e0805211956v3bb89b84q66a141721fce332b@mail.gmail.com>
	<48355084.70208@ericsson.com>
	<65b2728e0805220955p52904b2ex9e48bc8b36f70eb9@mail.gmail.com>
	
	<91a2ba3e0805231004y4f7cebecxd2a3e0694a6c89b3@mail.gmail.com>
	<65b2728e0805231054r1faaa139o98a49532ddde40b@mail.gmail.com>
	<91a2ba3e0805231112j2cd1f843r241c8ff8c50382a2@mail.gmail.com>
	<65b2728e0805231524j4156f41cgb9506cc00d6d24d4@mail.gmail.com>
	
	<65b2728e0805241437q35170ef8oa4e733b3a5973b0f@mail.gmail.com>
Message-ID: <93827D33-D0ED-4464-A41A-183DEBCBB491@gmail.com>

Steve,

On 24 May 2008, at 22:37, Steve Vinoski wrote:
> Another
> approach is to keep the Any data in marshaled form until it reaches a
> point that knows how to unmarshal it. Implementing all that support in
> a way that's reasonably efficient can be fun and challenging, but it's
> an example that shows there could be many different representations
> for the same data type, depending on context, even within just one
> language.

Good point. I think that at the end of the day what I going to couple  
you is the semantics of the operation even if you do find some kind of  
funky late-binding approach that can deal with different namespaces,  
field names, field ordering or class versions. Another approach may  
just be to let neural agents recognize the binary data structures and  
just train them until they're putting the data in the right pigeon  
holes (at least most of the time).

>
>> I ask this question because I took the following approach ( http://hopper.squarespace.com/blog/2008/5/22/pet-store-part-1.html
>>  ) to the problem you are talking about, but am just questioning
>> whether my own approach has any merit at all.
>
> I glanced over it and it looks fine to me, though I did see the word
> "RPC" used there a few times ;-).

Well it's asynchronous RPC if that makes it less evil ;-)

If understand you correctly though, you are saying that the RPC style  
of defining a endpoint to dispatch data to is limiting because if you  
change the *server* side semantics or syntax, this means that you have  
to change the client at the same time, right?

Ben



From ulf@REDACTED  Sun May 25 00:32:50 2008
From: ulf@REDACTED (Ulf Wiger)
Date: Sun, 25 May 2008 00:32:50 +0200
Subject: [erlang-questions] cost of integrating 3rd party SW
In-Reply-To: <65b2728e0805241452m107ec20av8acd029615ab6354@mail.gmail.com>
References: <8209f740805240555l3262634aj3a1a59f7075a3b0c@mail.gmail.com>
	
	<65b2728e0805241452m107ec20av8acd029615ab6354@mail.gmail.com>
Message-ID: <8209f740805241532n75f8c8f3p6f0616da98eed8e4@mail.gmail.com>

2008/5/24 Steve Vinoski :
> On 5/24/08, Per Melin  wrote:
>> 2008/5/24 Ulf Wiger :
>>
>> > It's something that pops up every once in a while,
>>  > e.g. in the Facebook chat server article: that combining
>>  > Erlang with components written in other languages is
>>  > hard.
>>
>>
>> As a consultant I see a lot of components built in-house at different
>>  companies in different languages that use RDBMSs to interface with
>>  each other and COTSs. Often it's the completely wrong tool for the
>>  job, but it's used because it's easy. It doesn't matter if you mix
>>  Java, C++, Ruby, Python, PHP, C# and Perl; they usually (always?) have
>>  drivers/APIs to talk to the major RDBMSs, and you can assume that they
>>  are well used and therefor (probably) stable.
>>
>>  When I read or hear someone talk about using Erlang as part of a
>>  larger system the state of the RDBMS drivers usually comes into
>>  question.
>
> Hi Ulf, I agree with Per -- databases seem to be a weak link. I have
> an application where I had to front the database with a bridge written
> in a different language and then integrate my Erlang app with that
> through the network.

This would seem to fit with Erlang's heritage - as the products
at Ericsson where Erlang has been used have not had any need
for external databases nor, indeed, any form of COM integration.
With the increased interest in ODBC, MySQL and PostgreSQL
connectivity, this will hopefully improve rather rapidly now.


> Other than that, I've had great success with network-based
> integrations over various protocols.

Would you say then that the dominant mode of integration
is still socket-based, even in environments where shared-
memory integration is possible (e.g. windows DLLs, CLR,
etc.)? I mean, is this the preferred way of integrating
components, even when not using Erlang, and even when
performance requirements are high?

I'm hoping/assuming that shared-memory integration will
become less and less interesting with the increasing
availability of multicore computers. From Erlang's point
of view, the VM can do blocking IO in its own thread
rather than periodically polling like it has to do on a
single core.

BR,
Ulf W


From Lennart.Ohman@REDACTED  Sun May 25 01:27:11 2008
From: Lennart.Ohman@REDACTED (=?iso-8859-1?Q?Lennart_=D6hman?=)
Date: Sun, 25 May 2008 01:27:11 +0200
Subject: [erlang-questions] supervisor_bridge enhancement
In-Reply-To: <4838371F.9030308@gmail.com>
References: <4838371F.9030308@gmail.com>
Message-ID: 

Hi Serge,
I believe you have to high expectations on the supervisor_bridge. It was once developed when OTP was new to accommodate the (then) usual situation that there was non-OTP-compliant code that needed to be ran in a supervision tree. So the superviso_bridge was only meant to handle the OTP-system-message communication between two supervisors. Today there should rarely be any need to use the supervisor_bridge.

Best regards
Lennart

-----Original Message-----
From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Serge Aleynikov
Sent: den 24 maj 2008 17:41
To: Erlang Users' List
Subject: [erlang-questions] supervisor_bridge enhancement

Currently the supervisor_bridge behavior doesn't expose
Mod:handle_call/3 and Mod:handle_info/3 callbacks.  When using this behavior to provide custom startup for some application's server (such as inets' httpd) I frequently find it lacking the ability to report a Pid of the bridged child or provide handling of custom messages.

Attached is a prototype of supervisor_bridge extension that adds a new function get_child_pid/1, as well as new callbacks Mod:handle_call/3, Mod:handle_cast/2, and handle_info/2.

Some possible applications of this module could be to implement:
a. timed instantiation of the bridged Pid (e.g. run the bridged module only between certain hours of a day).
b. registration of the bridged Pid of a 3rd party server (if it doesn't register itself).

It would be nice if this supervisor_bridge extension could make it to the distribution.

Serge


From hayeah@REDACTED  Sun May 25 23:23:35 2008
From: hayeah@REDACTED (Howard Yeh)
Date: Sun, 25 May 2008 14:23:35 -0700
Subject: [erlang-questions] something is looping, but can't figure out where.
Message-ID: 

Hi,

Earlier I was having problem with not getting the shell prompt back
after a computation (with something looping & consuming memory).
Putting the computation in a process seemed to have solved the
problem.

Now I am getting looping behaviour again. I am pretty sure my
computation is not looping, since it raises an error (previously I
could see the returned result). This time I have a timeout to kill the
linked computation process after 10 seconds.

After looping for 10 seconds, the computation process is killed, and i
get the shell prompt back. But something keeps looping (pegs CPU, but
consumes no memory).

Does c:i() list all the processes? Looking at the reduction counts,
nothing is increasing except the shell related processes. But those
processes are only reducing my sending the i() command.

I am really confused.

Howard


From vinoski@REDACTED  Mon May 26 00:14:12 2008
From: vinoski@REDACTED (Steve Vinoski)
Date: Sun, 25 May 2008 18:14:12 -0400
Subject: [erlang-questions] rpc is bad? (was Re: facebook chat server)
In-Reply-To: <48374591.4070203@hyber.org>
References:  <483495FC.2010007@dominicwilliams.net>
	<2CBBCB38-7789-440E-8BAA-5BA6DB5E6D55@hypotheticalabs.com>
	<65b2728e0805211956v3bb89b84q66a141721fce332b@mail.gmail.com>
	<48355084.70208@ericsson.com>
	<65b2728e0805220955p52904b2ex9e48bc8b36f70eb9@mail.gmail.com>
	
	<91a2ba3e0805231004y4f7cebecxd2a3e0694a6c89b3@mail.gmail.com>
	<65b2728e0805231054r1faaa139o98a49532ddde40b@mail.gmail.com>
	<48374591.4070203@hyber.org>
Message-ID: <65b2728e0805251514w563cc6eeg29a88599306813fb@mail.gmail.com>

On 5/23/08, Claes Wikstrom  wrote:
> Steve Vinoski wrote:
>
> > It's related to the fallacies, yes. The fundamental problem of RPC,
> > which is trying to make remote calls look local, is based on
> > essentially trying to ignore the problems covered by the fallacies or
> > trying to pretend they don't even exist.
>
>  I really like the above paragraph. Ages ago when I was naive, and I'd just
>  implemented distributed erlang with the basic concepts like
>  spawn/4, link/1 and most importantly {Name, Node} ! Message
>  I then set out to build higher level libraries on top of those
>  basic low level mechanisms. We still see the traces of those efforts
>  in the otp libs today.

Hey Klacke, all I can say is that I'm probably not alone in wishing
that ages ago I had been as naive as you claim to have been! :-) What
you've referred to as "basic" concepts in Distributed Erlang are IMO
amazingly powerful, succinct, and compelling.

>  Think rpc:multicall(), the pg and pg2 modules , mnesia hidden replication,
> etc.
>  Now some 10 years later I've never ever used those functions that try to
> hide
>  the network - even though I wrote them. Interesting.

Sometimes negative people will point out that my tastes in distributed
computing have changed over the years and that some of my recent
writings contradict what I wrote 10 or 15 years ago. My typical
response is "yes, I'm glad I can still learn!" ;-)

>  I have used rpc:call/4 extensively though but it doesn't hide the network.

Coincidentally, that's exactly one of the calls I had in mind when I
previously wrote that Erlang/OTP doesn't try to hide distribution from
the programmer.

--steve


From vinoski@REDACTED  Mon May 26 02:55:54 2008
From: vinoski@REDACTED (Steve Vinoski)
Date: Sun, 25 May 2008 20:55:54 -0400
Subject: [erlang-questions] cost of integrating 3rd party SW
In-Reply-To: <8209f740805241532n75f8c8f3p6f0616da98eed8e4@mail.gmail.com>
References: <8209f740805240555l3262634aj3a1a59f7075a3b0c@mail.gmail.com>
	
	<65b2728e0805241452m107ec20av8acd029615ab6354@mail.gmail.com>
	<8209f740805241532n75f8c8f3p6f0616da98eed8e4@mail.gmail.com>
Message-ID: <65b2728e0805251755s653c245erde656beb8024469@mail.gmail.com>

On 5/24/08, Ulf Wiger  wrote:
> 2008/5/24 Steve Vinoski :
>
> > On 5/24/08, Per Melin  wrote:
>  >> 2008/5/24 Ulf Wiger :
>  >>
>  >> > It's something that pops up every once in a while,
>  >>  > e.g. in the Facebook chat server article: that combining
>  >>  > Erlang with components written in other languages is
>  >>  > hard.
>  >>
>  >> As a consultant I see a lot of components built in-house at different
>  >>  companies in different languages that use RDBMSs to interface with
>  >>  each other and COTSs. Often it's the completely wrong tool for the
>  >>  job, but it's used because it's easy. It doesn't matter if you mix
>  >>  Java, C++, Ruby, Python, PHP, C# and Perl; they usually (always?) have
>  >>  drivers/APIs to talk to the major RDBMSs, and you can assume that they
>  >>  are well used and therefor (probably) stable.
>  >>
>  >>  When I read or hear someone talk about using Erlang as part of a
>  >>  larger system the state of the RDBMS drivers usually comes into
>  >>  question.
>  >
>  > Hi Ulf, I agree with Per -- databases seem to be a weak link. I have
>  > an application where I had to front the database with a bridge written
>  > in a different language and then integrate my Erlang app with that
>  > through the network.
>
> This would seem to fit with Erlang's heritage - as the products
>  at Ericsson where Erlang has been used have not had any need
>  for external databases nor, indeed, any form of COM integration.
>  With the increased interest in ODBC, MySQL and PostgreSQL
>  connectivity, this will hopefully improve rather rapidly now.

Sounds good!

>  > Other than that, I've had great success with network-based
>  > integrations over various protocols.
>
> Would you say then that the dominant mode of integration
>  is still socket-based, even in environments where shared-
>  memory integration is possible (e.g. windows DLLs, CLR,
>  etc.)? I mean, is this the preferred way of integrating
>  components, even when not using Erlang, and even when
>  performance requirements are high?

As far as I've seen, the answer is yes. Regarding shared memory in
particular, in my CORBA-related work over the years, which included
efforts for two different vendors and a variety of co-development
efforts with other vendors, we always provided shared memory
capabilities, but all told only 1 or 2 customers, literally, ever used
them. We found that it really wasn't any faster than the local
loopback. I can honestly say that I can't recall using any systems,
CORBA or otherwise, that actually make effective use of shared memory,
though I of course accept that others might have different experiences
with other software.

Now that I've written the above, I see that you're using the term
"shared memory" more generally to include things like shared libraries
and DLLs. From that perspective, it depends on what the 3rd-party
software is like. If it's like an SDK, then you usually end up linking
with 3rd-party shared libraries/DLLs. If it's a networked service,
then of course network integration is the way to go. In my experience,
with 3rd-party systems you get much more of the latter, not the
former, mainly because of the pain of maintaining binary compatibility
across versions of the shared libraries/DLLs for languages like Java
and C++. Over the past few years, though, there have been some efforts
both in C#/CLR and in something called the Service Component
Architecture (SCA) to create "assemblies" that are supposed to help
address some of those binary compatibility issues. I'm unaware of how
widely used either of them are, though; I could be mistaken but I
don't think there's been a lot of uptake of either, relatively.

>  I'm hoping/assuming that shared-memory integration will
>  become less and less interesting with the increasing
>  availability of multicore computers. From Erlang's point
>  of view, the VM can do blocking IO in its own thread
>  rather than periodically polling like it has to do on a
>  single core.

That's an excellent point.

--steve


From vinoski@REDACTED  Mon May 26 03:07:37 2008
From: vinoski@REDACTED (Steve Vinoski)
Date: Sun, 25 May 2008 21:07:37 -0400
Subject: [erlang-questions] rpc is bad? (was Re: facebook chat server)
In-Reply-To: <93827D33-D0ED-4464-A41A-183DEBCBB491@gmail.com>
References: 
	<65b2728e0805220955p52904b2ex9e48bc8b36f70eb9@mail.gmail.com>
	
	<91a2ba3e0805231004y4f7cebecxd2a3e0694a6c89b3@mail.gmail.com>
	<65b2728e0805231054r1faaa139o98a49532ddde40b@mail.gmail.com>
	<91a2ba3e0805231112j2cd1f843r241c8ff8c50382a2@mail.gmail.com>
	<65b2728e0805231524j4156f41cgb9506cc00d6d24d4@mail.gmail.com>
	
	<65b2728e0805241437q35170ef8oa4e733b3a5973b0f@mail.gmail.com>
	<93827D33-D0ED-4464-A41A-183DEBCBB491@gmail.com>
Message-ID: <65b2728e0805251807j284f1e8bufdc367df11a6c00c@mail.gmail.com>

On 5/24/08, Ben Hood <0x6e6562@REDACTED> wrote:
>  If understand you correctly though, you are saying that the RPC style
>  of defining a endpoint to dispatch data to is limiting because if you
>  change the *server* side semantics or syntax, this means that you have
>  to change the client at the same time, right?

I think that's part of the problem, yes. Basically, there's that pesky
IDL specification shared between clients and the server; changes to it
are difficult to deal with because 1) it changes the generated stubs
and skeletons that are compiled into the client and server, 2) changes
to types and methods can easily ripple through the application code
that uses the stubs and skeletons, necessitating source changes and
recompilation, and 3) it affects not only the distributed interface
shared across the network between client and server but for certain
programming languages might also create binary compatibility issues as
well. This can happen when a client calls a "distributed" object or
service that is actually loaded locally in the form of a shared
library or DLL, on demand, by the RPC or distributed object
infrastructure.

BTW, is this topic general enough and relevant enough that we should
continue it here? I feel like I'm spamming the list!

--steve


From ok@REDACTED  Mon May 26 04:54:17 2008
From: ok@REDACTED (Richard A. O'Keefe)
Date: Mon, 26 May 2008 14:54:17 +1200
Subject: [erlang-questions] eep: multiple patterns
In-Reply-To: <4836A517.2040909@gmail.com>
References: <200805141620.19559.bekesa@sch.bme.hu>	
	<200805151307.18370.bekesa@sch.bme.hu>	
	<5D916667-D9C8-43C4-A1E6-916653C9CB00@cs.otago.ac.nz>	
	<200805161110.51758.bekesa@sch.bme.hu> <482D5647.1030109@gmail.com>
	<3dbc6d1c0805230327i74b0ecd2ob0f7971fe2577ae8@mail.gmail.com>
	<4836A517.2040909@gmail.com>
Message-ID: 


On 23 May 2008, at 11:05 pm, Mats Cronqvist wrote:

Hooray!  Evidence!
>  let me assure you that there are major telecom equipment vendors  
> whose
> code bases would benefit greatly from this syntax.
>  although i (no longer) has access to that code, the pattern appears
> quite often in event-driven programming. here's a very small example
> from a simple GUI application;
>
> loop(St) ->
>    receive
>    %% user deleted top window
>    {?MODULE,{signal,{window1,_}}}       -> quit();
>    %% user selected quit menu item
>    {?MODULE,{signal,{quit1,_}}}       -> quit();
>    %% user selected  connect menu item
>    {?MODULE,{signal,{connect,_}}}       -> loop(conn(St));
>    %% user selected  disconnect menu item
>    {?MODULE,{signal,{disconnect,_}}} -> loop(disc(St));
>    %% user selected about menu item
>    {?MODULE,{signal,{about1,_}}}       -> loop(show_about(St));
>    %% user clicked ok in about dialog
>    {?MODULE,{signal,{dialogb,_}}}      -> loop(hide_about(St));
>    %% user deleted about dialog
>    {?MODULE,{signal,{dialog1,_}}}       -> loop(hide_about(St));
>    %% we got data from the top_top process
>    {data,Data}                       -> loop(update(St,Data));
>    %% quit from the erlang shell
>    quit                              -> quit();
>    %% log other signals
>    X                                 -> io:fwrite("got ~p~n", 
> [X]),loop(St)
>    end.
>

Let me start by making two changes to that code.
The first is to indent it, so that I can read it.
The second is to group together things with the same body.

     loop(St) ->
         receive
	    quit ->
		%% quit from the Erlang shell
		quit()
	  ; {?MODULE,{signal,{window1,_}}} ->
		%% User deleted top window.
		quit()
	  ; {?MODULE,{signal,{quit1,_}}} ->
		%% User selected 'Quit' menu item.
		quit()
	  ; {?MODULE,{signal,{connect,_}}} ->
		%% User selected 'Connect' menu item.
		loop(conn(St))
	  ; {?MODULE,{signal,{disconnect,_}}} ->
		%% User selected 'Disconnect' menu item.
		loop(disc(St))
	  ; {?MODULE,{signal,{about1,_}}} ->
		%% User selected 'About' menu item.
		loop(show_about(St))
	  ; {?MODULE,{signal,{dialogb,_}}} ->
		%% User clicked 'OK' in "about" dialogue.
		loop(hide_about(St))
	  ; {?MODULE,{signal,{dialog1,_}}} ->
		%% User deleted "about" dialogue.
	  ; {data,Data} ->
		%% We got data from the top_top process.
		loop(update(St, Data))
	  ; X ->
		%% Log other signals.
		io:fwrite("got ~p~n", [X]),
		loop(St)
	end.

In this case, it matters that *every* message is to be received and
acted on.  That means that we can once again use the factorisation
technique.

     loop(State) ->
	receive
	    Message ->
		loop(State, classify(Message))
	end.

     classify(quit)				-> quit;
     classify({?MODULE,{signal,{window1,_}}})	-> quit;
     classify({?MODULE,{signal,{quit1,_}}})	-> quit;
     classify({?MODULE,{signal,{connect,_}}})	-> connect;
     classify({?MODULE,{signal,{disconnect,_}}})	-> disconnect;
     classify({?MODULE,{signal,{about1,_}}})	-> show_about;
     classify({?MODULE,{signal,{dialog1,_}}})	-> hide_about;
     classify({?MODULE,{signal,{dialogb,_}}})	-> hide_about;
     classify({data,Data})			-> {data,Data};
     classify(X)					-> {error,X}.

     loop(_, quit) ->
	quit();
     loop(State, connect) ->
	loop(conn(State));
     loop(State, disconnect) ->
	loop(disc(State));
     loop(State, show_about) ->
	loop(show_about(State));
     loop(State, hide_about) ->
	loop(hide_about(State));
     loop(State, {data,Data}) ->
	loop(update(State, Data));
     loop(State, {error,X}) ->
	io:fwrite("got ~p~n", [X]),
	loop(State).

I like this because it makes a clean separation between
"what are the actions" and "what are the names for the actions".

Of course you can in-line this.  Just as we can have
case/case, we can have case/receive, getting

     loop(State) ->
	case receive
		 quit                              -> quit
	       ; {?MODULE,{signal,{window1,_}}}    -> quit
	       ; {?MODULE,{signal,{quit1,_}}}      -> quit
	       ; {?MODULE,{signal,{connect,_}}}    -> connect
	       ; {?MODULE,{signal,{disconnect,_}}} -> disconnect
	       ; {?MODULE,{signal,{about1,_}}}     -> show_about
	       ; {?MODULE,{signal,{dialog1,_}}}    -> hide_about
	       ; {?MODULE,{signal,{dialogb,_}}}    -> hide_about
	       ; {data,Data}                       -> {data,Data}
	       ; X                                 -> {error,X}
	     end
	  of quit       -> quit()
	   ; connect    -> loop(conn(State))
	   ; disconnect -> loop(disc(State))
	   ; show_about -> loop(show_about(State))
	   ; hide_about -> loop(hide_about(State))
	   ; {data,D}   -> loop(update(State, D))
	   ; {error,X}  -> io:fwrite("got ~p~n", [X]),
			   loop(State)
	end.

Now my first reaction on seeing a whole raft of {?MODULE,{signal, 
{Foo,_}}}
patterns was "this is too hard for me to read".  I would be trying to
simplify the protocol.  Separating the receive protocol from the action
selection makes this kind of maintenance easier.  Inlining means that
the versions with separate functions and with nested case/receive are
operationally equivalent.  A few hacks in the compiler could produce
essentially the same code as the original version, although I doubt that
it would be worth bothering.

Tastes vary.  To me, what we can write now in Erlang as it stands,
separating "what are the actions" from "what are the names for the  
actions",
is easier to read and understand than anything using multiple patterns
would be, not because multiple patterns are a bad idea as such, but  
because
combining multiple *complex* patterns into a single match makes the code
harder to read.  Multiple *simple* patterns might make for a more
interesting example.

--
"I don't want to discuss evidence." -- Richard Dawkins, in an
interview with Rupert Sheldrake.  (Fortean times 232, p55.)








From adam@REDACTED  Mon May 26 08:52:45 2008
From: adam@REDACTED (Adam Lindberg)
Date: Mon, 26 May 2008 08:52:45 +0200
Subject: [erlang-questions] Simple redirection question
In-Reply-To: 
References: 
	
Message-ID: <6344005f0805252352o53cc09fdj96bbe680587e1723@mail.gmail.com>

On Sat, May 24, 2008 at 3:08 PM, David Mitchell  wrote:
> Never mind - this works...
>
> T = list_to_atom("os").
> T:getenv().

Which is actually the long form for:
T = os,
T:getenv().


Cheers!
Adam
--
Adam Lindberg
http://www.erlang-consulting.com


From kode@REDACTED  Mon May 26 09:04:59 2008
From: kode@REDACTED (Bhasker Kode)
Date: Mon, 26 May 2008 12:34:59 +0530
Subject: [erlang-questions] bspawner: spawn distribution among distributed
	nodes
Message-ID: <3935b63b0805260004r60d8d7f9wb43ff01b130ed84c@mail.gmail.com>

Hi everyone,

I just wanted to announce of an the project i've just opened up called bspawner.

This project was an attempt to load-balance the task of spawning tasks
across multiple nodes . The steps involved can be isolated into a
couple of distinct problems.
  1. deciding which node needs to spawn a task
  2. communicating across these nodes
  3. maintaining a record of nodes, added /removed nodes ,etc

This project in its essence, deals with the first part and the
implementation of the message passing begins with the "messenger.erl"
program located at
http://www.erlang.org/doc/getting_started/conc_prog.html and will be
ported to different message-passing, load-balancing and
node-information maintenance based on feedback,suggestions ,comments,
and further changes inspired by the growing involvement of the erlang
community & encouragement from #erlang in particular.

Example
------------
Assuming that there are three nodes: nodeA,nodeB,nodeC

%%an un-balanced version

1>messenger:message(node1,{factorial,5}).
2>messenger:message(node1,{saveToDisk,"a.dat"}).
3>messenger:message(node1,{makeHttpRequest,Url}).
%%all requests originate from current node,and get spawned at target node1

%%un-balanced version

1>bspawner:bmessage(node1,{factorial,5}).
2>bspawner:bmessage(node1,{saveToDisk,"a.txt"}).
3>bspawner:bmessage(node1,{makeHttpRequest,Url}).

%%OR you can directly give in {M,F,A} format

1>bspawner:bspawn({bspawner_request,{NumberCrunchingMod,factorial,[5]} }).
2>bspawner:bspawn({bspawner_request,{io,CustomSaveToDisk,["a.txt"]} }).
3>bspawner:bspawn({bspawner_request,{ProxyPortHandler,makeHttpRequest,[Url]} }).

%% bmessage
%% replicates messenger:message(node1,"hi") but internally calls bspawn

1>bspawner:bmessage(node1,"hi").
%which is syntactic sugar for
2>bspawner:bspawn({ bspawner_request, {bspawner,message,["hi"]} })


This was however before i got to know about the pool module which is
exactly what i wanted in the first place. cheers to that, but it was a
fun learning experience anyway - and i'm looking to add more clarity
in terms of which node makes a request Vs which nose do processing,
possibly add features like to make sets  of nodes to do X,another set
to do Y, and more TODO's that i'd like to add along the way.

Links
--------
http://bspawner.googlecode.com
http://bosky101.blogspot.com/2008/05/erlang-distribution-bspawner.html


Keep Clicking,
Bhasker V Kode
bosky101 on #erlang


From peter@REDACTED  Mon May 26 09:23:56 2008
From: peter@REDACTED (Peter Mechlenborg)
Date: Mon, 26 May 2008 09:23:56 +0200
Subject: [erlang-questions] rpc is bad? (was Re: facebook chat server)
In-Reply-To: <65b2728e0805251807j284f1e8bufdc367df11a6c00c@mail.gmail.com>
References: 
	
	<91a2ba3e0805231004y4f7cebecxd2a3e0694a6c89b3@mail.gmail.com>
	<65b2728e0805231054r1faaa139o98a49532ddde40b@mail.gmail.com>
	<91a2ba3e0805231112j2cd1f843r241c8ff8c50382a2@mail.gmail.com>
	<65b2728e0805231524j4156f41cgb9506cc00d6d24d4@mail.gmail.com>
	
	<65b2728e0805241437q35170ef8oa4e733b3a5973b0f@mail.gmail.com>
	<93827D33-D0ED-4464-A41A-183DEBCBB491@gmail.com>
	<65b2728e0805251807j284f1e8bufdc367df11a6c00c@mail.gmail.com>
Message-ID: 

Hi

Steve Vinoski:

>
> BTW, is this topic general enough and relevant enough that we should
> continue it here? I feel like I'm spamming the list!

I find this thread very interesting, and also highly relevant for my
understanding of Erlang and how to use it well.  So don't hold back on my
behalf.

A side question.  Does anyone know of other forums that discuss how to build
distributed systems and/or server systems?

Cheers,

  --  Peter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From ulf.wiger@REDACTED  Mon May 26 11:13:25 2008
From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB))
Date: Mon, 26 May 2008 11:13:25 +0200
Subject: [erlang-questions] rpc is bad? (was Re: facebook chat server)
In-Reply-To: <65b2728e0805251514w563cc6eeg29a88599306813fb@mail.gmail.com>
References: 
	<483495FC.2010007@dominicwilliams.net>	<2CBBCB38-7789-440E-8BAA-5BA6DB5E6D55@hypotheticalabs.com>	<65b2728e0805211956v3bb89b84q66a141721fce332b@mail.gmail.com>	<48355084.70208@ericsson.com>	<65b2728e0805220955p52904b2ex9e48bc8b36f70eb9@mail.gmail.com>		<91a2ba3e0805231004y4f7cebecxd2a3e0694a6c89b3@mail.gmail.com>	<65b2728e0805231054r1faaa139o98a49532ddde40b@mail.gmail.com>	<48374591.4070203@hyber.org>
	<65b2728e0805251514w563cc6eeg29a88599306813fb@mail.gmail.com>
Message-ID: <483A7F35.60308@ericsson.com>

Steve Vinoski skrev:
> 
> Sometimes negative people will point out that my tastes
 > in distributed computing have changed over the years and
 > that some of my recent writings contradict what I wrote
 > 10 or 15 years ago. My typical response is "yes, I'm
 > glad I can still learn!" ;-)

An honorable stance. (:

I once read a similar exchange in a newspaper:

- Previously, you said A, and now you say the opposite!
- Yes, when I realise that I've been wrong, I change my
   position. What do you do?

BR,
Ulf W


From 0x6e6562@REDACTED  Mon May 26 11:21:09 2008
From: 0x6e6562@REDACTED (Ben Hood)
Date: Mon, 26 May 2008 10:21:09 +0100
Subject: [erlang-questions] rpc is bad? (was Re: facebook chat server)
In-Reply-To: 
References: 
	
	<91a2ba3e0805231004y4f7cebecxd2a3e0694a6c89b3@mail.gmail.com>
	<65b2728e0805231054r1faaa139o98a49532ddde40b@mail.gmail.com>
	<91a2ba3e0805231112j2cd1f843r241c8ff8c50382a2@mail.gmail.com>
	<65b2728e0805231524j4156f41cgb9506cc00d6d24d4@mail.gmail.com>
	
	<65b2728e0805241437q35170ef8oa4e733b3a5973b0f@mail.gmail.com>
	<93827D33-D0ED-4464-A41A-183DEBCBB491@gmail.com>
	<65b2728e0805251807j284f1e8bufdc367df11a6c00c@mail.gmail.com>
	
Message-ID: 


On 26 May 2008, at 08:23, Peter Mechlenborg wrote:
> Steve Vinoski:
> 
> BTW, is this topic general enough and relevant enough that we should
> continue it here? I feel like I'm spamming the list!
> I find this thread very interesting, and also highly relevant for my  
> understanding of Erlang and how to use it well.  So don't hold back  
> on my behalf.
>
> A side question.  Does anyone know of other forums that discuss how  
> to build distributed systems and/or server systems?

You could start a new list if you wanted to, e.g. on Google Groups.

Ben


From bjorn@REDACTED  Mon May 26 12:16:52 2008
From: bjorn@REDACTED (Bjorn Gustavsson)
Date: 26 May 2008 12:16:52 +0200
Subject: [erlang-questions] atom table limit & erlang shell
In-Reply-To: <472785.70532.qm@web38803.mail.mud.yahoo.com>
References: <472785.70532.qm@web38803.mail.mud.yahoo.com>
Message-ID: 

Thomas Lindgren  writes:
> 
> (Running that on my mac gave a bus error and a crash
> dump.)
> 

I have made a small correction, so that there will be
a controlled termination of the emulator if the allowed
number of atoms is exhausted. (That is, there will not
be a bus error, and the crash dump will not be truncated.)

The correction will be included R12B-3.

/Bjorn
-- 
Bj?rn Gustavsson, Erlang/OTP, Ericsson AB


From saleyn@REDACTED  Mon May 26 12:22:03 2008
From: saleyn@REDACTED (Serge Aleynikov)
Date: Mon, 26 May 2008 06:22:03 -0400
Subject: [erlang-questions] supervisor_bridge enhancement
In-Reply-To: 
References: <4838371F.9030308@gmail.com>
	
Message-ID: <483A8F4B.2010008@gmail.com>

I understand that the behavior was introduced as an interop bridge 
between OTP and non-OTP compliant code.  However, as you indicated, in 
that role it has very minimal use these days.  I believe that if it's 
extended with the suggested functionality, it would become more general 
and suitable for solving a broader range of problems (namely - extending 
a server with functionality without changing its code).  This is quite 
convenient when you need to embed some standard OTP application in your 
project and introduce additional functions that are not implemented by 
that application.  In this case the bridge serves as a middle-man 
between the user and the managed OTP app.

Serge

Lennart ?hman wrote:
> Hi Serge,
> I believe you have to high expectations on the supervisor_bridge. It was once developed when OTP was new to accommodate the (then) usual situation that there was non-OTP-compliant code that needed to be ran in a supervision tree. So the superviso_bridge was only meant to handle the OTP-system-message communication between two supervisors. Today there should rarely be any need to use the supervisor_bridge.
> 
> Best regards
> Lennart
> 
> -----Original Message-----
> From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Serge Aleynikov
> Sent: den 24 maj 2008 17:41
> To: Erlang Users' List
> Subject: [erlang-questions] supervisor_bridge enhancement
> 
> Currently the supervisor_bridge behavior doesn't expose
> Mod:handle_call/3 and Mod:handle_info/3 callbacks.  When using this behavior to provide custom startup for some application's server (such as inets' httpd) I frequently find it lacking the ability to report a Pid of the bridged child or provide handling of custom messages.
> 
> Attached is a prototype of supervisor_bridge extension that adds a new function get_child_pid/1, as well as new callbacks Mod:handle_call/3, Mod:handle_cast/2, and handle_info/2.
> 
> Some possible applications of this module could be to implement:
> a. timed instantiation of the bridged Pid (e.g. run the bridged module only between certain hours of a day).
> b. registration of the bridged Pid of a 3rd party server (if it doesn't register itself).
> 
> It would be nice if this supervisor_bridge extension could make it to the distribution.
> 
> Serge
> 



From als@REDACTED  Mon May 26 11:18:54 2008
From: als@REDACTED (Anthony Shipman)
Date: Mon, 26 May 2008 19:18:54 +1000
Subject: [erlang-questions] odbc doesn't give me all of my data
Message-ID: <200805261918.54234.als@iinet.net.au>

I've tried putting large blobs into a postgres database using the Erlang odbc 
application. The relevant versions are Erlang R11b.5, unixODBC 2.2.11, 
postgresql-odbc 8.1.200.

First I tried a column with the type 'bytea' which holds an arbitrary-length 
byte string. I was able to insert 10000 bytes. But a select query via 
odbc:sql_query() would only return 254 bytes.

Then I experimented with the type 'text' which holds an arbitrary-length 
character string. Again I inserted 10000 chars. The select query only 
returned 8001 chars.

I suspect that the problem is in unixODBC or postgresql-odbc and I will have 
to abandon this exercise, unless someone has some better ideas.

-- 
Anthony Shipman                    Mamas don't let your babies 
als@REDACTED                   grow up to be outsourced.


From anthony.hw.kong@REDACTED  Mon May 26 12:42:07 2008
From: anthony.hw.kong@REDACTED (Anthony Kong)
Date: Mon, 26 May 2008 20:42:07 +1000
Subject: [erlang-questions] rpc is bad? (was Re: facebook chat server)
In-Reply-To: <483A7F35.60308@ericsson.com>
References: 
	<65b2728e0805211956v3bb89b84q66a141721fce332b@mail.gmail.com>
	<48355084.70208@ericsson.com>
	<65b2728e0805220955p52904b2ex9e48bc8b36f70eb9@mail.gmail.com>
	
	<91a2ba3e0805231004y4f7cebecxd2a3e0694a6c89b3@mail.gmail.com>
	<65b2728e0805231054r1faaa139o98a49532ddde40b@mail.gmail.com>
	<48374591.4070203@hyber.org>
	<65b2728e0805251514w563cc6eeg29a88599306813fb@mail.gmail.com>
	<483A7F35.60308@ericsson.com>
Message-ID: 

On Mon, May 26, 2008 at 7:13 PM, Ulf Wiger (TN/EAB)
 wrote:
>
> An honorable stance. (:
>
> I once read a similar exchange in a newspaper:
>
> - Previously, you said A, and now you say the opposite!
> - Yes, when I realise that I've been wrong, I change my
>   position. What do you do?
>
> BR,
> Ulf W


It is probably John Maynard Keynes: "When the facts change, I change
my mind. What do you do, sir?"

I also want to take the chance to express my appreciation to Steve for
his sharing of insight and experience.

Cheers


From erlang@REDACTED  Mon May 26 13:41:11 2008
From: erlang@REDACTED (Dominic Williams)
Date: Mon, 26 May 2008 07:41:11 -0400 (EDT)
Subject: [erlang-questions] Mocking in Erlang
In-Reply-To: <69d143cd0805231746p7f8ed4cdl91e0f6fdd7da8025@mail.gmail.com>
References: <69d143cd0805231746p7f8ed4cdl91e0f6fdd7da8025@mail.gmail.com>
Message-ID: <34687.217.128.75.198.1211802071.squirrel@www.geekisp.com>

Hi Jeremy,

> While browsing the erlang-questions list archives I found mention that
> someone had written a Mocking Module for erlang that would mock processes.
> I'm wondering if that ever got published anywhere or if there are other
> mocking frameworks for erlang that have been used. I love TestFirst
> development but it would be a lot easier if I could mock outside sources
> when I write my tests.

Because the "protocol" (or alphabet) of an Erlang process is not
formalised (there is no interface definition), it is completely trivial to
to implement a mock of a process (with just enough messages for the
context of the test), so I write mocks all the time without needing a
framework.

Sometimes, I pass the test's self() directly and send/receive from the
test function. Sometimes, the test is a bit cleaner if I spawn a fun() ->
... end that is hard-coded to receive and/or send the exact messages I
need to make my test work.

It's so straightforward that I can't imagine a framework would do any good.

Regards,

Dominic Williams
http://dominicwilliams.net

----



From zambal@REDACTED  Mon May 26 14:24:16 2008
From: zambal@REDACTED (zambal)
Date: Mon, 26 May 2008 05:24:16 -0700 (PDT)
Subject: [erlang-questions] Leex - a lexical anaylzer generator, released
In-Reply-To: <3dbc6d1c0805240839k24b5a91cq71346591fe0faed8@mail.gmail.com>
References: <3dbc6d1c0805240839k24b5a91cq71346591fe0faed8@mail.gmail.com>
Message-ID: 

Hi Robert,

I have totally no experience with lex or any other tools in this
class,
but out of curiosity I was reading lfe_scan.xrl and was wondering what
these #' #` #; #, and #,@ separator rules are for. Are these just
reserved for later use or are they part of some undocumented syntax?

Thanks,
Vincent

PS Thanks for releasing LFE, it 'slurps' most of my spare time
lately ;-)


From thomasl_erlang@REDACTED  Mon May 26 14:55:42 2008
From: thomasl_erlang@REDACTED (Thomas Lindgren)
Date: Mon, 26 May 2008 05:55:42 -0700 (PDT)
Subject: [erlang-questions] rpc is bad? (was Re: facebook chat server)
In-Reply-To: <483A7F35.60308@ericsson.com>
Message-ID: <679879.84251.qm@web38807.mail.mud.yahoo.com>


--- "Ulf Wiger (TN/EAB)" 
wrote:

> I once read a similar exchange in a newspaper:
> 
> - Previously, you said A, and now you say the
> opposite!
> - Yes, when I realise that I've been wrong, I change
> my
>    position. What do you do?
> 

Heh. Here's how to claim you weren't even wrong,
merely misinformed:

"When the facts change, I change my mind. What do you
do, sir?" -- John Maynard Keynes

Best,
Thomas



      


From mark.peleus@REDACTED  Mon May 26 15:56:25 2008
From: mark.peleus@REDACTED (mark peleus)
Date: Mon, 26 May 2008 16:56:25 +0300
Subject: [erlang-questions] compile a module on different OS
Message-ID: <599dd3e0805260656r43c7452ao8217813cdcfa470a@mail.gmail.com>

Hello,

When I compile an erlang module on windows xp for example,
can I use the beam file on a linux system or do I have to compile it on each
system separately?

If my module includes .hrl file, do I still need it after compilation or can
I delete the hrl file when I have the compiled beam file?

Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From joelr1@REDACTED  Mon May 26 15:59:55 2008
From: joelr1@REDACTED (Joel Reymont)
Date: Mon, 26 May 2008 14:59:55 +0100
Subject: [erlang-questions] Hacking Mnesia for fun and profit
Message-ID: 

I'm hacking Mnesia again. Unlike my previous S3 backend, the goal this  
time is to be able to extend Mnesia with external modules that support  
disc_copies and ram_copies type of behavior.

I would much prefer to have a single generic extension but it's my  
guess that separate ram and disk behaviors will need to be supported.

I'm going deeper than before so here's a question for Mnesia experts:

Do I need to add extension-related code to prepare_ram_tab and  
do_change_copy in mnesia_checkpoint.erl?

Generally, I would much prefer to make existing Mnesia table types  
into disk and ram extensions but I think that's too much work for my  
budget. Plus, I think it would be much harder to convince the OTP team  
to support that change going forward :-).

	Thanks, Joel

--
wagerlabs.com



From rvirding@REDACTED  Mon May 26 17:10:33 2008
From: rvirding@REDACTED (Robert Virding)
Date: Mon, 26 May 2008 17:10:33 +0200
Subject: [erlang-questions] Leex - a lexical anaylzer generator, released
In-Reply-To: 
References: <3dbc6d1c0805240839k24b5a91cq71346591fe0faed8@mail.gmail.com>
	
Message-ID: <3dbc6d1c0805260810v27542486u9b2b1ebc7aa491f2@mail.gmail.com>

2008/5/26 zambal :

> Hi Robert,
>
> I have totally no experience with lex or any other tools in this
> class,
> but out of curiosity I was reading lfe_scan.xrl and was wondering what
> these #' #` #; #, and #,@ separator rules are for. Are these just
> reserved for later use or are they part of some undocumented syntax?


These are taken from Scheme R6RS and will most likely go as LFE has no use
for them.

#' #` #, #,@ are for use in syntax-case macros and mean:

#'  - (syntax ...)
#`  - (quasisyntax ...)
#,  - (unsyntax ...)
#,@ - (unsyntax-splicing ...)

#; - comment out next sepxr which could actually be useful

Also I missed #| ... |# for block comments. Might also be useful. Question
is if block comments are token or character based?

Be glad I didn't adopt R6RS symbol syntax, it is complex and full of special
cases. :-) I think having that if an (lisp) atom can be parsed as a number
then it is a number, else it is a symbol is much easier.

Glad you enjoy LFE.

Robert
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From vlm@REDACTED  Mon May 26 17:32:20 2008
From: vlm@REDACTED (Lev Walkin)
Date: Mon, 26 May 2008 08:32:20 -0700
Subject: [erlang-questions] compile a module on different OS
In-Reply-To: <599dd3e0805260656r43c7452ao8217813cdcfa470a@mail.gmail.com>
References: <599dd3e0805260656r43c7452ao8217813cdcfa470a@mail.gmail.com>
Message-ID: <483AD804.1010005@lionet.info>

mark peleus wrote:
> Hello,
> 
> When I compile an erlang module on windows xp for example,
> can I use the beam file on a linux system or do I have to compile it on 
> each system separately?

Yes. Former.

> If my module includes .hrl file, do I still need it after compilation or 
> can I delete the hrl file when I have the compiled beam file?


Yes. Latter.

-- 
Lev Walkin
vlm@REDACTED


From vychodil.hynek@REDACTED  Mon May 26 19:15:10 2008
From: vychodil.hynek@REDACTED (Hynek Vychodil)
Date: Mon, 26 May 2008 19:15:10 +0200
Subject: [erlang-questions] eep: multiple patterns
In-Reply-To: 
References: <200805141620.19559.bekesa@sch.bme.hu>
	<200805151307.18370.bekesa@sch.bme.hu>
	<5D916667-D9C8-43C4-A1E6-916653C9CB00@cs.otago.ac.nz>
	<200805161110.51758.bekesa@sch.bme.hu> <482D5647.1030109@gmail.com>
	<3dbc6d1c0805230327i74b0ecd2ob0f7971fe2577ae8@mail.gmail.com>
	<4836A517.2040909@gmail.com>
	
Message-ID: <4d08db370805261015r7466a74cw35d1a3f4c7e2020b@mail.gmail.com>

Thanks for very nice example.

On Mon, May 26, 2008 at 4:54 AM, Richard A. O'Keefe 
wrote:

>
> On 23 May 2008, at 11:05 pm, Mats Cronqvist wrote:
>
> Hooray!  Evidence!
> >  let me assure you that there are major telecom equipment vendors
> > whose
> > code bases would benefit greatly from this syntax.
> >  although i (no longer) has access to that code, the pattern appears
> > quite often in event-driven programming. here's a very small example
> > from a simple GUI application;
> >
> > loop(St) ->
> >    receive
> >    %% user deleted top window
> >    {?MODULE,{signal,{window1,_}}}       -> quit();
> >    %% user selected quit menu item
> >    {?MODULE,{signal,{quit1,_}}}       -> quit();
> >    %% user selected  connect menu item
> >    {?MODULE,{signal,{connect,_}}}       -> loop(conn(St));
> >    %% user selected  disconnect menu item
> >    {?MODULE,{signal,{disconnect,_}}} -> loop(disc(St));
> >    %% user selected about menu item
> >    {?MODULE,{signal,{about1,_}}}       -> loop(show_about(St));
> >    %% user clicked ok in about dialog
> >    {?MODULE,{signal,{dialogb,_}}}      -> loop(hide_about(St));
> >    %% user deleted about dialog
> >    {?MODULE,{signal,{dialog1,_}}}       -> loop(hide_about(St));
> >    %% we got data from the top_top process
> >    {data,Data}                       -> loop(update(St,Data));
> >    %% quit from the erlang shell
> >    quit                              -> quit();
> >    %% log other signals
> >    X                                 -> io:fwrite("got ~p~n",
> > [X]),loop(St)
> >    end.
> >
>
> Let me start by making two changes to that code.
> The first is to indent it, so that I can read it.
> The second is to group together things with the same body.
>
>     loop(St) ->
>         receive
>            quit ->
>                %% quit from the Erlang shell
>                quit()
>          ; {?MODULE,{signal,{window1,_}}} ->
>                %% User deleted top window.
>                quit()
>          ; {?MODULE,{signal,{quit1,_}}} ->
>                %% User selected 'Quit' menu item.
>                quit()
>          ; {?MODULE,{signal,{connect,_}}} ->
>                %% User selected 'Connect' menu item.
>                loop(conn(St))
>          ; {?MODULE,{signal,{disconnect,_}}} ->
>                %% User selected 'Disconnect' menu item.
>                loop(disc(St))
>          ; {?MODULE,{signal,{about1,_}}} ->
>                %% User selected 'About' menu item.
>                loop(show_about(St))
>          ; {?MODULE,{signal,{dialogb,_}}} ->
>                %% User clicked 'OK' in "about" dialogue.
>                loop(hide_about(St))
>          ; {?MODULE,{signal,{dialog1,_}}} ->
>                %% User deleted "about" dialogue.
>          ; {data,Data} ->
>                %% We got data from the top_top process.
>                loop(update(St, Data))
>          ; X ->
>                %% Log other signals.
>                 io:fwrite("got ~p~n", [X]),
>                loop(St)
>        end.
>
> In this case, it matters that *every* message is to be received and
> acted on.  That means that we can once again use the factorisation
> technique.
>
>     loop(State) ->
>        receive
>            Message ->
>                loop(State, classify(Message))
>        end.
>
>     classify(quit)                             -> quit;
>     classify({?MODULE,{signal,{window1,_}}})   -> quit;
>     classify({?MODULE,{signal,{quit1,_}}})     -> quit;
>     classify({?MODULE,{signal,{connect,_}}})   -> connect;
>     classify({?MODULE,{signal,{disconnect,_}}})        -> disconnect;
>     classify({?MODULE,{signal,{about1,_}}})    -> show_about;
>     classify({?MODULE,{signal,{dialog1,_}}})   -> hide_about;
>     classify({?MODULE,{signal,{dialogb,_}}})   -> hide_about;
>     classify({data,Data})                      -> {data,Data};
>     classify(X)                                        -> {error,X}.
>
>     loop(_, quit) ->
>        quit();
>     loop(State, connect) ->
>        loop(conn(State));
>     loop(State, disconnect) ->
>        loop(disc(State));
>     loop(State, show_about) ->
>        loop(show_about(State));
>     loop(State, hide_about) ->
>        loop(hide_about(State));
>     loop(State, {data,Data}) ->
>        loop(update(State, Data));
>     loop(State, {error,X}) ->
>         io:fwrite("got ~p~n", [X]),
>         loop(State).
>
> I like this because it makes a clean separation between
> "what are the actions" and "what are the names for the actions".
>
> Of course you can in-line this.  Just as we can have
> case/case, we can have case/receive, getting
>
>     loop(State) ->
>        case receive
>                 quit                              -> quit
>               ; {?MODULE,{signal,{window1,_}}}    -> quit
>               ; {?MODULE,{signal,{quit1,_}}}      -> quit
>               ; {?MODULE,{signal,{connect,_}}}    -> connect
>               ; {?MODULE,{signal,{disconnect,_}}} -> disconnect
>               ; {?MODULE,{signal,{about1,_}}}     -> show_about
>               ; {?MODULE,{signal,{dialog1,_}}}    -> hide_about
>               ; {?MODULE,{signal,{dialogb,_}}}    -> hide_about
>               ; {data,Data}                       -> {data,Data}
>               ; X                                 -> {error,X}
>             end
>          of quit       -> quit()
>           ; connect    -> loop(conn(State))
>           ; disconnect -> loop(disc(State))
>           ; show_about -> loop(show_about(State))
>           ; hide_about -> loop(hide_about(State))
>           ; {data,D}   -> loop(update(State, D))
>           ; {error,X}  -> io:fwrite("got ~p~n", [X]),
>                           loop(State)
>        end.
>
> Now my first reaction on seeing a whole raft of {?MODULE,{signal,
> {Foo,_}}}
> patterns was "this is too hard for me to read".  I would be trying to
> simplify the protocol.  Separating the receive protocol from the action
> selection makes this kind of maintenance easier.  Inlining means that
> the versions with separate functions and with nested case/receive are
> operationally equivalent.  A few hacks in the compiler could produce
> essentially the same code as the original version, although I doubt that
> it would be worth bothering.
>
> Tastes vary.  To me, what we can write now in Erlang as it stands,
> separating "what are the actions" from "what are the names for the
> actions",
> is easier to read and understand than anything using multiple patterns
> would be, not because multiple patterns are a bad idea as such, but
> because
> combining multiple *complex* patterns into a single match makes the code
> harder to read.  Multiple *simple* patterns might make for a more
> interesting example.
>
> --
> "I don't want to discuss evidence." -- Richard Dawkins, in an
> interview with Rupert Sheldrake.  (Fortean times 232, p55.)
>
>
>
>
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>



-- 
--Hynek (Pichi) Vychodil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From hayeah@REDACTED  Mon May 26 19:24:00 2008
From: hayeah@REDACTED (Howard Yeh)
Date: Mon, 26 May 2008 10:24:00 -0700
Subject: [erlang-questions] compile a module on different OS
In-Reply-To: <483AD804.1010005@lionet.info>
References: <599dd3e0805260656r43c7452ao8217813cdcfa470a@mail.gmail.com>
	<483AD804.1010005@lionet.info>
Message-ID: 

On 5/26/08, Lev Walkin  wrote:
> mark peleus wrote:
>  > Hello,
>  >
>  > When I compile an erlang module on windows xp for example,
>  > can I use the beam file on a linux system or do I have to compile it on
>  > each system separately?
>
>
> Yes. Former.
>
>
>  > If my module includes .hrl file, do I still need it after compilation or
>  > can I delete the hrl file when I have the compiled beam file?
>
>
>
> Yes. Latter.
>
But you probably don't want to delete the *.hrl files, just as you
don't want to delete *.erl if you ever want to recompile.
>
>  --
>  Lev Walkin
>  vlm@REDACTED
>  _______________________________________________
>  erlang-questions mailing list
>  erlang-questions@REDACTED
>  http://www.erlang.org/mailman/listinfo/erlang-questions
>


-- 
hayeah.wordpress.com
   --metacircular thinking


From erlang@REDACTED  Mon May 26 21:37:52 2008
From: erlang@REDACTED (Joe Armstrong)
Date: Mon, 26 May 2008 21:37:52 +0200
Subject: [erlang-questions] cost of integrating 3rd party SW
In-Reply-To: <8209f740805240555l3262634aj3a1a59f7075a3b0c@mail.gmail.com>
References: <8209f740805240555l3262634aj3a1a59f7075a3b0c@mail.gmail.com>
Message-ID: <9b08084c0805261237g3de1c184r3b8e208c201c0f9a@mail.gmail.com>

On Sat, May 24, 2008 at 2:55 PM, Ulf Wiger  wrote:
> Perhaps somewhat related to the "RPC is bad" thread,
> do any of you know of any reasonably systematic
> discussions about whether or not Erlang is good or
> bad at interfacing with 3rd party components?
>
> It's something that pops up every once in a while,
> e.g. in the Facebook chat server article: that combining
> Erlang with components written in other languages is
> hard.

It depends on the non-functional requirements, you must ask questions like:

    - Do the components run on the same machine?
    - Is a bug in one component allowed to crash the other component
    - can we upgrade the components without interrupting the service?

- interfacing *any* two languages hard if you require  things like the above

The only way to do this is to isolate the two components in OS processes
and let them communicate through some kind of stream interface.

This implies that both sides of the stream can easily serialise and parse the
data that is to be transferred. Once you've done this, connecting components is
trivial.

The *easiest* way to connect components is exemplified in the unix shell

cat  I know that sometimes, decisions have been made to
> rather write a component from scratch in Erlang, rather
> than interfacing with some COTS component, based on
> the assumption that it will be both cheaper and better
> to do this than to deal with the 3rd party component.

Most often the rewrite is due to the fact that the non-functional
behaviour in the
3-rd part component is wrong. Suppose we want to upgrade things "on the fly"
but this is not possible in the component.

Erlang was designed for building fault-tolerant systems - many components
cannot be just added off-the-shelf because they are less reliable than
the Erlang core.

> This is always a hard sell, and usually meets with the
> exclamation: "aha! Erlang is bad at interfacing with other
> software."

To which you reply "rubbish" - how easy is it to connect a prolog application
running on mac OS-X in Australia to a c# app on .net in China?

>
> And of course, any programmer will always opt to write
> something from scratch rather than reuse something
> that someone else has written, right?  ;-)

Guilty m'lord - but we don't rewrite - we improve, make better versions
that are more easily maintained. 80% of life-cyle costs are in maintenance
so regular re-writes which reduce code volume and improve quality are
justifiable. Those companies who do *not* make these changes
will have mounting problems in the future.

Rewriting assembler apps in fortran was probably a good idea
etc ...
...

> What I'm after is a more sober and objective account,
> based on real experience and (ideally) cost comparisons.
> I'm perfectly ok if the conclusion is that Erlang indeed
> does need to improve.



>
> Cost is of course not the only parameter. Performance,
> robustness, debugging and maintenance, impedance
> mismatch (and if so, what is the preferred solution?
> Keep Erlang or throw it out?)

Keep it

/Joe Armstrong

>
> BR,
> Ulf W
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>


From dnew@REDACTED  Mon May 26 21:17:11 2008
From: dnew@REDACTED (Darren New)
Date: Mon, 26 May 2008 12:17:11 -0700
Subject: [erlang-questions] Style (was eep: multiple patterns)
Message-ID: <483B0CB7.30101@san.rr.com>

Richard A. O'Keefe wrote:
 > I like this because it makes a clean separation between
 > "what are the actions" and "what are the names for the actions".

Is there anything you'd recommend to someone learning how best to use 
Erlang to get some of these useful idioms? The Erlang "style guide" 
doesn't really say anything unobvious or idomatic, for the most part. Is 
there code you'd particularly recommend reading, for example, or other 
sources of papers?


-- 
   Darren New / San Diego, CA, USA (PST)
     "That's pretty. Where's that?"
          "It's the Age of Channelwood."
     "We should go there on vacation some time."


From erlang@REDACTED  Mon May 26 22:35:28 2008
From: erlang@REDACTED (Joe Armstrong)
Date: Mon, 26 May 2008 22:35:28 +0200
Subject: [erlang-questions] rpc is bad? (was Re: facebook chat server)
In-Reply-To: <65b2728e0805251807j284f1e8bufdc367df11a6c00c@mail.gmail.com>
References: 
	
	<91a2ba3e0805231004y4f7cebecxd2a3e0694a6c89b3@mail.gmail.com>
	<65b2728e0805231054r1faaa139o98a49532ddde40b@mail.gmail.com>
	<91a2ba3e0805231112j2cd1f843r241c8ff8c50382a2@mail.gmail.com>
	<65b2728e0805231524j4156f41cgb9506cc00d6d24d4@mail.gmail.com>
	
	<65b2728e0805241437q35170ef8oa4e733b3a5973b0f@mail.gmail.com>
	<93827D33-D0ED-4464-A41A-183DEBCBB491@gmail.com>
	<65b2728e0805251807j284f1e8bufdc367df11a6c00c@mail.gmail.com>
Message-ID: <9b08084c0805261335u590e039avce1d39c5db8da888@mail.gmail.com>

 > BTW, is this topic general enough and relevant enough that we should
> continue it here? I feel like I'm spamming the list!
>
> --steve

Absolutely, I think this is a very interesting discussion - near to
the core thinking of how we program.

I've added some comments in:

http://armstrongonsoftware.blogspot.com/

/Joe Armstrong


> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>


From corticalcomputer@REDACTED  Tue May 27 02:37:59 2008
From: corticalcomputer@REDACTED (Gene Sher)
Date: Mon, 26 May 2008 17:37:59 -0700
Subject: [erlang-questions] Erlang and Stock Market Datafeed.
Message-ID: <2a67d3ff0805261737k6a06390axe1260f06328acae7@mail.gmail.com>

Is anyone currently working on using erlang to leech data from Market
Datafeeds? or know of such projects, or can suggest how one would for
example use erlang to directly interact with either the Etrade or scottrade
platform.

How would you aproach this (how for example to allow a program to work
directly with scottrader, or Etrader...) or at least where to start?

-Gene
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From jeremy@REDACTED  Tue May 27 03:46:04 2008
From: jeremy@REDACTED (Jeremy Wall)
Date: Mon, 26 May 2008 20:46:04 -0500
Subject: [erlang-questions] Mocking in Erlang
In-Reply-To: <34687.217.128.75.198.1211802071.squirrel@www.geekisp.com>
References: <69d143cd0805231746p7f8ed4cdl91e0f6fdd7da8025@mail.gmail.com>
	<34687.217.128.75.198.1211802071.squirrel@www.geekisp.com>
Message-ID: <69d143cd0805261846g46973594gbf58798c4b256330@mail.gmail.com>

what is the typical way to handle the case where your module uses ibrowse
say.

is the best practice in testing just to not mock ibrowse?
or do you typically just isolate the ibrowse calls in a small untested
function and test everything else as normal?
or is there some other trick I dont know about yet?

On Mon, May 26, 2008 at 6:41 AM, Dominic Williams <
erlang-dated-1212234074.c1eaa3@REDACTED> wrote:

> Hi Jeremy,
>
> > While browsing the erlang-questions list archives I found mention that
> > someone had written a Mocking Module for erlang that would mock
> processes.
> > I'm wondering if that ever got published anywhere or if there are other
> > mocking frameworks for erlang that have been used. I love TestFirst
> > development but it would be a lot easier if I could mock outside sources
> > when I write my tests.
>
> Because the "protocol" (or alphabet) of an Erlang process is not
> formalised (there is no interface definition), it is completely trivial to
> to implement a mock of a process (with just enough messages for the
> context of the test), so I write mocks all the time without needing a
> framework.
>
> Sometimes, I pass the test's self() directly and send/receive from the
> test function. Sometimes, the test is a bit cleaner if I spawn a fun() ->
> ... end that is hard-coded to receive and/or send the exact messages I
> need to make my test work.
>
> It's so straightforward that I can't imagine a framework would do any good.
>
> Regards,
>
> Dominic Williams
> http://dominicwilliams.net
>
> ----
>
>


-- 
Jeremy Wall
http://jeremy.marzhillstudios.com
Jeremy@REDACTED
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From vances@REDACTED  Tue May 27 06:27:15 2008
From: vances@REDACTED (Vance Shipley)
Date: Tue, 27 May 2008 05:27:15 +0100
Subject: [erlang-questions] cost of integrating 3rd party SW
In-Reply-To: <9b08084c0805261237g3de1c184r3b8e208c201c0f9a@mail.gmail.com>
References: <8209f740805240555l3262634aj3a1a59f7075a3b0c@mail.gmail.com>
	<9b08084c0805261237g3de1c184r3b8e208c201c0f9a@mail.gmail.com>
Message-ID: <20080527042715.GC138@softbank126030011139.bbtec.net>

On Mon, May 26, 2008 at 09:37:52PM +0200, Joe Armstrong wrote:
}      - Do the components run on the same machine?
}      - Is a bug in one component allowed to crash the other component
}      - can we upgrade the components without interrupting the service?

I have used a number of methods to write "drivers" for third party
libraries with C APIs.  First there was the Interface Generator (IG)
which was included in OTP long ago.  Later I used erl_interface and
once ei appeared wrote new drivers with that.  The first linked in
driver I wrote was static but now I write dynamically loadable linked 
in drivers.  Most of these make use of the thread pool.

I never really understood the dire warnings about bugs in the linked
in driver crashing the emulator.  In my systems the driver was an
integral part of the system and if it crashed it was catastrophic so
restarting the emulator was the correct action.  Properly configured
embedded systems handle the recovery.

When using erl_interface/ei the driver is in a seperate OS process
acting as a "C Node" and interfacing using normal Erlang distribution
protocol.  Here if the driver crashes the Erlang code simply sees a
node become unavailable (i.e. {nodedown, Node}).  This behaviour may
well be more appropriate for some applications.  My thinking is that
if I put my efforts into an effecient and  reliable linked in driver
I always have the option of dedicating a node to running the driver
and use it in the same way as as a C Node.  It may be a bit more
heavy weight approach but it has the advantages of being a real node.
A C Node doesn't behave exactly like an Erlang node.

I hear many complaints that writing drivers is hard.  While I did
find it hard the first time I did these things I was coding in C after
all and that is harder than what I've become so used to in Erlang.
The driver_entry callbacks and erl_driver API may take a bit to wrap
your head around however once you have you should find that it has
been made as easy as possible for you.  The emulator handles file
handle events and thread completion for you and you write handlers.

While all too often the first part of my projects are to write C code
just to allow me to write the rest in Erlang I feel it is worth it.

	-Vance


From erlang-questions_efine@REDACTED  Tue May 27 07:11:10 2008
From: erlang-questions_efine@REDACTED (Edwin Fine)
Date: Tue, 27 May 2008 01:11:10 -0400
Subject: [erlang-questions] cost of integrating 3rd party SW
In-Reply-To: <20080527042715.GC138@softbank126030011139.bbtec.net>
References: <8209f740805240555l3262634aj3a1a59f7075a3b0c@mail.gmail.com>
	<9b08084c0805261237g3de1c184r3b8e208c201c0f9a@mail.gmail.com>
	<20080527042715.GC138@softbank126030011139.bbtec.net>
Message-ID: <6c2563b20805262211s3fa1669ev4ac1c7b0f51ffbc9@mail.gmail.com>

Well, even though I've written embedded device drivers, operating system
device drivers, and Ruby "drivers", all in C, and Java JNI code in C++, I
found the Erlang model of linked-in drivers to be more frustrating and
finicky than all the others put together (though I believe the Perl native
interface has them all beat, from what I read). I think this frustration may
be in large part due to the documentation, which is not always clear and
understandable. I am sure once I have written many Linked-in Drivers I will
wonder what all the fuss I made was about, but the first ones I found a bit
of a pain to get going.

On Tue, May 27, 2008 at 12:27 AM, Vance Shipley  wrote:

> On Mon, May 26, 2008 at 09:37:52PM +0200, Joe Armstrong wrote:
> }      - Do the components run on the same machine?
> }      - Is a bug in one component allowed to crash the other component
> }      - can we upgrade the components without interrupting the service?
>
> I have used a number of methods to write "drivers" for third party
> libraries with C APIs.  First there was the Interface Generator (IG)
> which was included in OTP long ago.  Later I used erl_interface and
> once ei appeared wrote new drivers with that.  The first linked in
> driver I wrote was static but now I write dynamically loadable linked
> in drivers.  Most of these make use of the thread pool.
>
> I never really understood the dire warnings about bugs in the linked
> in driver crashing the emulator.  In my systems the driver was an
> integral part of the system and if it crashed it was catastrophic so
> restarting the emulator was the correct action.  Properly configured
> embedded systems handle the recovery.
>
> When using erl_interface/ei the driver is in a seperate OS process
> acting as a "C Node" and interfacing using normal Erlang distribution
> protocol.  Here if the driver crashes the Erlang code simply sees a
> node become unavailable (i.e. {nodedown, Node}).  This behaviour may
> well be more appropriate for some applications.  My thinking is that
> if I put my efforts into an effecient and  reliable linked in driver
> I always have the option of dedicating a node to running the driver
> and use it in the same way as as a C Node.  It may be a bit more
> heavy weight approach but it has the advantages of being a real node.
> A C Node doesn't behave exactly like an Erlang node.
>
> I hear many complaints that writing drivers is hard.  While I did
> find it hard the first time I did these things I was coding in C after
> all and that is harder than what I've become so used to in Erlang.
> The driver_entry callbacks and erl_driver API may take a bit to wrap
> your head around however once you have you should find that it has
> been made as easy as possible for you.  The emulator handles file
> handle events and thread completion for you and you write handlers.
>
> While all too often the first part of my projects are to write C code
> just to allow me to write the rest in Erlang I feel it is worth it.
>
>        -Vance
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From joelr1@REDACTED  Tue May 27 10:31:32 2008
From: joelr1@REDACTED (Joel Reymont)
Date: Tue, 27 May 2008 09:31:32 +0100
Subject: [erlang-questions] Erlang and Stock Market Datafeed.
In-Reply-To: <2a67d3ff0805261737k6a06390axe1260f06328acae7@mail.gmail.com>
References: <2a67d3ff0805261737k6a06390axe1260f06328acae7@mail.gmail.com>
Message-ID: 


On May 27, 2008, at 1:37 AM, Gene Sher wrote:

> How would you aproach this (how for example to allow a program to work
> directly with scottrader, or Etrader...) or at least where to start?


I suspect that scottrader and etrader do not allow you to interact  
with their servers directly. You probably need to interact with a DLL  
or some such that may let you talk to a local socket.

Contrast this with the Chicago Mercantile Exchange (CME) that lets you  
receive multicast data over a VPN directly off of their servers, as  
well as send orders via FIX/FAST.

I think you would need to post a bit more detail about the scottrade  
and etrade interfaces that you are working with.

	-joel

--
wagerlabs.com







From per.melin@REDACTED  Tue May 27 12:28:17 2008
From: per.melin@REDACTED (Per Melin)
Date: Tue, 27 May 2008 12:28:17 +0200
Subject: [erlang-questions] Erlang and Stock Market Datafeed.
In-Reply-To: 
References: <2a67d3ff0805261737k6a06390axe1260f06328acae7@mail.gmail.com>
	
Message-ID: 

2008/5/27 Joel Reymont :
> I suspect that scottrader and etrader do not allow you to interact
> with their servers directly.

I'm working with (European) online brokers and I can tell you it's a
constant whac-a-mole to block people who try to scrape stock prices,
close to real-time, to the tune of hundreds or thousands of requests
per second.

I've written a system (in Erlang) for a broker that routes instrument
price updates from a number of feeds to other systems (and soon
directly to thousands of clients). It also stores the prices and you
can query it over a REST interface. Right now I have half a million
instruments with 10k to 20k updates per second. It's fast, stable and
very few SLOC. A perfect fit for Erlang.


From erlang@REDACTED  Tue May 27 14:16:17 2008
From: erlang@REDACTED (Joe Armstrong)
Date: Tue, 27 May 2008 14:16:17 +0200
Subject: [erlang-questions] something is looping,
	but can't figure out where.
In-Reply-To: 
References: 
Message-ID: <9b08084c0805270516y276eb3b3y65c05162a07d5cd7@mail.gmail.com>

You can mess around with the BIFs processes() and process_info(Pid, Tag)

These BIFS are described in the man page for Erlang (erl -man erl) (or
pre-installed man pages for windows)   (or
http://www.erlang.org/doc/man/erlang.html))

processes() returns a list of all Pids in the system.

process_info(Pid, Tag) returns process information for the process
Pid. Tag says what kind of information
you want. process_info(Pid) returns even more info per process

A command like

> [ process_info(Pid) || Pid <- processes()]
...

Will help you track down which process has run  wild.

Exercise: using processes/0 and process_info/1 (or /2) write a
function find_looping_process() that
locates the bad process. Hint take two samples with 5 second intervals
and compare ...

/Joe Armstrong




On Sun, May 25, 2008 at 11:23 PM, Howard Yeh  wrote:
> Hi,
>
> Earlier I was having problem with not getting the shell prompt back
> after a computation (with something looping & consuming memory).
> Putting the computation in a process seemed to have solved the
> problem.
>
> Now I am getting looping behaviour again. I am pretty sure my
> computation is not looping, since it raises an error (previously I
> could see the returned result). This time I have a timeout to kill the
> linked computation process after 10 seconds.
>
> After looping for 10 seconds, the computation process is killed, and i
> get the shell prompt back. But something keeps looping (pegs CPU, but
> consumes no memory).
>
> Does c:i() list all the processes? Looking at the reduction counts,
> nothing is increasing except the shell related processes. But those
> processes are only reducing my sending the i() command.
>
> I am really confused.
>
> Howard
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>


From bekesa@REDACTED  Tue May 27 14:36:19 2008
From: bekesa@REDACTED (Andras Georgy Bekes)
Date: Tue, 27 May 2008 14:36:19 +0200
Subject: [erlang-questions] eep: multiple patterns
In-Reply-To: 
References: <200805141620.19559.bekesa@sch.bme.hu> <4836A517.2040909@gmail.com>
	
Message-ID: <200805271436.19305.bekesa@sch.bme.hu>

Hi,

> To me, what we can write now in Erlang as it stands, 
> separating "what are the actions" from "what are the names for the
> actions", is easier to read and understand than anything using
> multiple patterns would be,

OK, you showed us (again?) that a possible use of multiple patterns can 
be substituted with something else. It always can be done, and 
everybody knew that.

Following your way of thinking, we'd conclude that the 'case' construct 
is not needed because it can be substituted with auxiliary functions. 
Still we have the 'case' construct and like it.

> not because multiple patterns are a bad idea as 
> such, but because combining multiple *complex* patterns into a single
> match makes the code harder to read. 
That's subjective. To me, the multiple patterns version reads better.

>  Multiple *simple* patterns might make for a more interesting example.
OK, you asked for real-life examples. OK, simple pattern.
Here it is, straight from AXD301. I've replaced the "interesting" parts 
with foo, bar and baz. Everything else is original.

----------------------------------------
case classify_Foo(Foo) of
   undefined_Foo -> bar(); % lots of code here
   {meaningful_Foo, Bar, Baz} -> baz(Bar,Baz) % lots of code here
end,
...
classify_Foo(undefined) ->
    undefined_Foo;
classify_Foo({undefined, _, _}) ->
    undefined_Foo;
classify_Foo({Bar, Baz}) ->
    {meaningful_Foo, Bar, Baz};
classify_Foo({Bar, Baz, _}) ->
    {meaningful_Foo, Bar, Baz}.
----------------------------------------

How do you like it?
I prefer the multiple patterns version.

(Don't tell me the problem is with the data structures. We all know 
AXD301 is garbage :-) but still, our users like it.

	Georgy


From bekesa@REDACTED  Tue May 27 14:40:49 2008
From: bekesa@REDACTED (Andras Georgy Bekes)
Date: Tue, 27 May 2008 14:40:49 +0200
Subject: [erlang-questions] eep: multiple patterns
In-Reply-To: <482D5647.1030109@gmail.com>
References: <200805141620.19559.bekesa@sch.bme.hu>
	<200805161110.51758.bekesa@sch.bme.hu> <482D5647.1030109@gmail.com>
Message-ID: <200805271440.49872.bekesa@sch.bme.hu>

> case bla of
>   Pat when true ->;
>   Pat when false->;
>   Pat ->
>     code()
> end.
>
>   but that's not what he wrote...
>   in that case i propose the above. currently gives syntax error.
What about:

case bla of
  Pat when true \/
  Pat when false \/
  Pat ->

Never seen similar notation in other languages, but it should not be a 
problem :-)

	Georgy


From bekesa@REDACTED  Tue May 27 15:03:11 2008
From: bekesa@REDACTED (Andras Georgy Bekes)
Date: Tue, 27 May 2008 15:03:11 +0200
Subject: [erlang-questions] eep: multiple patterns
In-Reply-To: <3dbc6d1c0805230327i74b0ecd2ob0f7971fe2577ae8@mail.gmail.com>
References: <200805141620.19559.bekesa@sch.bme.hu> <482D5647.1030109@gmail.com>
	<3dbc6d1c0805230327i74b0ecd2ob0f7971fe2577ae8@mail.gmail.com>
Message-ID: <200805271503.11850.bekesa@sch.bme.hu>

Hi,

> I agree with Richard O'Keefe that having = as a legal guard 
> test is a Good Thing.
>
> - if match succeeds it returns true and binds any unbound variables
> - if match fails, it returns false, i.e. it does generate an error
>
> Then you modify all boolean operations so that if they succeed,
> return true, then any new variables which are bound in them are
> exported, while if they fail, return false, no variables are
> exported.
>
> - This will work for the whole guard as if the guard fails then no
> variables are exported but the clause is not chosen anyway.
> - No problems with not(...) as it will never export variables.
> - Same with other boolean operators, success implies export. This
> makes checking for variable bindings in and after guards relatively
> easy.
>
> As far as I can see there are no problems with this.

I think there is a problem. I think I can express a pattern that's 
matching must involve backtracking:

F(A1,A2...) when ({X,_}=A1 or {_,X}=A1) and ({X,_}=A2 ...

So this proposal leads to a language that's too powerful :-(
Just like my very original proposal [1].
The problem with it is discussed [2] through [3].

> Actually thinking about it a bit more if you allow = in guards you
> really don't *need* this multiple pattern feature as you can express
> it as alternate guards.
The "problem" is that this not only makes multiple patterns unnecessary, 
but also the whole "Pattern when Guards" stuff (i.e. the part before 
the 'when' keyword).

	Georgy


References:

[1]:
http://www.erlang.org/pipermail/erlang-questions/2008-March/033718.html

[2]: 
http://www.erlang.org/pipermail/erlang-questions/2008-March/033755.html

[3]:
http://www.erlang.org/pipermail/erlang-questions/2008-March/033799.html


From zambal@REDACTED  Tue May 27 15:17:52 2008
From: zambal@REDACTED (zambal)
Date: Tue, 27 May 2008 06:17:52 -0700 (PDT)
Subject: [erlang-questions] Leex - a lexical anaylzer generator, released
In-Reply-To: <3dbc6d1c0805260810v27542486u9b2b1ebc7aa491f2@mail.gmail.com>
References: <3dbc6d1c0805240839k24b5a91cq71346591fe0faed8@mail.gmail.com> 
	 
	<3dbc6d1c0805260810v27542486u9b2b1ebc7aa491f2@mail.gmail.com>
Message-ID: 

On May 26, 5:10?pm, "Robert Virding"  wrote:
> These are taken from Scheme R6RS and will most likely go as LFE has no use
> for them.
>
> #' #` #, #,@ are for use in syntax-case macros and mean:
>
> #' ?- (syntax ...)
> #` ?- (quasisyntax ...)
> #, ?- (unsyntax ...)
> #,@ - (unsyntax-splicing ...)
>
> #; - comment out next sepxr which could actually be useful

Thanks for clearing that up. If I understand you correctly these
things provide nothing that you can't do with LFE's macro form, right?

> Also I missed #| ... |# for block comments. Might also be useful. Question
> is if block comments are token or character based?

Actually, I haven't missed them at all. The only use case for me is
when pasting some text from an external source in my code, which
doesn't happen a lot.

> Be glad I didn't adopt R6RS symbol syntax, it is complex and full of special
> cases. :-) I think having that if an (lisp) atom can be parsed as a number
> then it is a number, else it is a symbol is much easier.

My knowledge about Scheme is superficial, but I can't imagine a
situation where you'd want an atom representing a number to be parsed
to anything else than a number either.

> Glad you enjoy LFE.

Yeah, I have lot's of fun with it, especially it's macro
functionality. Speaking of which, as far as I know it's currently not
possible to export a macro in a module, so that it's usable in other
modules. Is such functionality planned for a future release of LFE, if
possible at all (or desirable, I haven't thought a lot about the
consequences)?

Best,
Vincent


From bekesa@REDACTED  Tue May 27 15:45:56 2008
From: bekesa@REDACTED (Andras Georgy Bekes)
Date: Tue, 27 May 2008 15:45:56 +0200
Subject: [erlang-questions] eep: multiple patterns
In-Reply-To: <200805271503.11850.bekesa@sch.bme.hu>
References: <200805141620.19559.bekesa@sch.bme.hu>
	<3dbc6d1c0805230327i74b0ecd2ob0f7971fe2577ae8@mail.gmail.com>
	<200805271503.11850.bekesa@sch.bme.hu>
Message-ID: <200805271545.56539.bekesa@sch.bme.hu>

> I think there is a problem. I think I can express a pattern that's
> matching must involve backtracking:
>
> F(A1,A2...) when ({X,_}=A1 or {_,X}=A1) and ({X,_}=A2 ...
>
> So this proposal leads to a language that's too powerful :-(
I think this was a mistake.

"({X,_}=A1 or {_,X}=A1)" means:
- test {X,_}=A1 then if matches, bind X
- test {_,X}=A1 then if matches, bind X (if it is not already bound)
- return with true/false according to the results
- forget anything except for the variable bindings.

So there is no backtracking here.
It's time to re-read the other parts of your proposal.

> Then as we allow = as a boolean test in guards we can extend it to be
> a valid *test* in list/binary comprehensions as well. It the match
> succeeds the test succeeds and exports the any new variable bindings.
> Someone asked for this earlier and while just having it in lc/bc
> might be a bit off having it as a valid *guard* test means it becomes
> acceptable as lc/bc test. It also easy to implement. I have the this
> feature already in LFE.
Agreed.
On our way towards an embedded Prolog :-)
No backtracking (only becktracking to the last generator), no logic 
variables, but a very expressive sublanguage. If the ='s are allowed in 
guards this can't be problematic to implement.

	Georgy


From colm.dougan@REDACTED  Tue May 27 16:40:18 2008
From: colm.dougan@REDACTED (Colm Dougan)
Date: Tue, 27 May 2008 15:40:18 +0100
Subject: [erlang-questions] Compiling erlang core modules with +native and
	-smp
Message-ID: <24d4f39c0805270740x713d01a7l749d106982bb0c52@mail.gmail.com>

Hi list,

I had to compile the Debian version of erlang from source (to apply
the zlib patch) and I noticed that there was an optional native.diff
patch which builds the core erlang modules (stdlib, io_lib etc) using
the +native option.  I decided to try this patch as I need all the
performance I can get :)

Anyway, later when I ran some code with this erlang using the -smp
option to 'erl' I got lots of warnings like this :

=INFO REPORT==== 27-May-2008::15:31:24 ===
 Warning: not loading native code for module io_lib:
it was compiled for an incompatible runtime system; please regenerate
native code for this runtime system

I guess this is because the +native code is not compatible with -smp
and modules need to be compiled with both +native *and* -smp in order
for the native code to be used.

My question is - if I intend to use -smp on my runtime system would I
be better off :
a] compiling the erlang core modules with +native *and* -smp.  Has
anyone experience of doing this?
OR
b] don't compile the core modules with +native at all

In general, is it worthwhile compiling the core modules with +native?
i.e. have people seen decent performance wins by doing this or is it
not really worth it?

Thanks,
Colm


From mikpe@REDACTED  Tue May 27 17:24:43 2008
From: mikpe@REDACTED (Mikael Pettersson)
Date: Tue, 27 May 2008 17:24:43 +0200
Subject: [erlang-questions] Compiling erlang core modules with +native
	and	-smp
In-Reply-To: <24d4f39c0805270740x713d01a7l749d106982bb0c52@mail.gmail.com>
References: <24d4f39c0805270740x713d01a7l749d106982bb0c52@mail.gmail.com>
Message-ID: <18492.10171.469026.664042@harpo.it.uu.se>

Colm Dougan writes:
 > Hi list,
 > 
 > I had to compile the Debian version of erlang from source (to apply
 > the zlib patch) and I noticed that there was an optional native.diff
 > patch which builds the core erlang modules (stdlib, io_lib etc) using
 > the +native option.  I decided to try this patch as I need all the
 > performance I can get :)
 > 
 > Anyway, later when I ran some code with this erlang using the -smp
 > option to 'erl' I got lots of warnings like this :
 > 
 > =INFO REPORT==== 27-May-2008::15:31:24 ===
 >  Warning: not loading native code for module io_lib:
 > it was compiled for an incompatible runtime system; please regenerate
 > native code for this runtime system
 > 
 > I guess this is because the +native code is not compatible with -smp
 > and modules need to be compiled with both +native *and* -smp in order
 > for the native code to be used.

No, native and SMP are fully compatible. However, native code compiled
for an SMP runtime is incompatible with a non-SMP runtime, and native
code compiled for a non-SMP runtime is incompatible with an SMP runtime.
(And there is little we can do about that incompatibility without
sacrificing runtime performance on non-SMP, alas.)

You need to take care to use the same SMP-or-not runtime system at
compile-time as you intend to use at runtime.

/Mikael


From kostis@REDACTED  Tue May 27 17:25:18 2008
From: kostis@REDACTED (Kostis Sagonas)
Date: Tue, 27 May 2008 18:25:18 +0300
Subject: [erlang-questions] Compiling erlang core modules with +native
 and	-smp
In-Reply-To: <24d4f39c0805270740x713d01a7l749d106982bb0c52@mail.gmail.com>
References: <24d4f39c0805270740x713d01a7l749d106982bb0c52@mail.gmail.com>
Message-ID: <483C27DE.207@cs.ntua.gr>

Colm Dougan wrote:
> 
> Anyway, later when I ran some code with this erlang using the -smp
> option to 'erl' I got lots of warnings like this :
> 
> =INFO REPORT==== 27-May-2008::15:31:24 ===
>  Warning: not loading native code for module io_lib:
> it was compiled for an incompatible runtime system; please regenerate
> native code for this runtime system
> 
> I guess this is because the +native code is not compatible with -smp
> and modules need to be compiled with both +native *and* -smp in order
> for the native code to be used.

The latter.  In general, you can only use native code in the runtime 
system (and of course platform) which created the native code.  The 
issue is that native code might contain information (e.g. data structure 
offsets) which are runtime system specific.

> My question is - if I intend to use -smp on my runtime system would I
> be better off :
> a] compiling the erlang core modules with +native *and* -smp.  Has
> anyone experience of doing this?
> OR
> b] don't compile the core modules with +native at all
> 
> In general, is it worthwhile compiling the core modules with +native?
> i.e. have people seen decent performance wins by doing this or is it
> not really worth it?

You are asking two completely separate questions above.
The reasons for using native code are completely orthogonal to SMP.
Native code is for speed -- as a rough estimate expect a performance 
improvement of 2-3 times -- in programs using binaries is even more than 
that, in programs spending most of their time in message passing you may 
not notice any performance improvement.

Whether this improvement is something you care about, it's up to you.

However, be aware that up till R12B-2 native code has some limitations. 
The main one, in my opinion, is that you can not get precise stacktraces 
when an exception occurs. This limitation will be lifted in R12B-3.

Kostis


From anders.nygren@REDACTED  Tue May 27 17:27:45 2008
From: anders.nygren@REDACTED (Anders Nygren)
Date: Tue, 27 May 2008 10:27:45 -0500
Subject: [erlang-questions] ssl certificates
Message-ID: 

Hi
just wondering, is there any special information or options that must
be specified
when purchasing a SSL certificate, that is to be used with erlang/yaws.

/Anders


From colm.dougan@REDACTED  Tue May 27 18:17:22 2008
From: colm.dougan@REDACTED (Colm Dougan)
Date: Tue, 27 May 2008 17:17:22 +0100
Subject: [erlang-questions] Compiling erlang core modules with +native
	and -smp
In-Reply-To: <18492.10171.469026.664042@harpo.it.uu.se>
References: <24d4f39c0805270740x713d01a7l749d106982bb0c52@mail.gmail.com>
	<18492.10171.469026.664042@harpo.it.uu.se>
Message-ID: <24d4f39c0805270917q3e548785o26dea0a06daf86eb@mail.gmail.com>

On Tue, May 27, 2008 at 4:24 PM, Mikael Pettersson  wrote:
> Colm Dougan writes:
>  > Hi list,
>  >
>  > I had to compile the Debian version of erlang from source (to apply
>  > the zlib patch) and I noticed that there was an optional native.diff
>  > patch which builds the core erlang modules (stdlib, io_lib etc) using
>  > the +native option.  I decided to try this patch as I need all the
>  > performance I can get :)
>  >
>  > Anyway, later when I ran some code with this erlang using the -smp
>  > option to 'erl' I got lots of warnings like this :
>  >
>  > =INFO REPORT==== 27-May-2008::15:31:24 ===
>  >  Warning: not loading native code for module io_lib:
>  > it was compiled for an incompatible runtime system; please regenerate
>  > native code for this runtime system
>  >
>  > I guess this is because the +native code is not compatible with -smp
>  > and modules need to be compiled with both +native *and* -smp in order
>  > for the native code to be used.
>
> No, native and SMP are fully compatible. However, native code compiled
> for an SMP runtime is incompatible with a non-SMP runtime, and native
> code compiled for a non-SMP runtime is incompatible with an SMP runtime.
> (And there is little we can do about that incompatibility without
> sacrificing runtime performance on non-SMP, alas.)
>
> You need to take care to use the same SMP-or-not runtime system at
> compile-time as you intend to use at runtime.

I see.  Thanks.  This means that if I want to compile the erlang
standard library with +native then I have to know in advance whether I
will be using -smp on my runtime system.  Right?

I'm wondering if it would make sense to have a compile option that
compiles native code for both SMP and non SMP runtimes into the same
beam such that the relevant native native code can be selected at
runtime?   I don't know if that makes any sense - just wondering.

Thanks,
Colm


From rpettit@REDACTED  Tue May 27 18:34:40 2008
From: rpettit@REDACTED (Rick Pettit)
Date: Tue, 27 May 2008 12:34:40 -0400 (EDT)
Subject: [erlang-questions] bspawner: spawn distribution among
 distributed nodes
In-Reply-To: <3935b63b0805260004r60d8d7f9wb43ff01b130ed84c@mail.gmail.com>
References: <3935b63b0805260004r60d8d7f9wb43ff01b130ed84c@mail.gmail.com>
Message-ID: <51872.192.168.129.36.1211906080.squirrel@squirrelmail.vail>

On Mon, May 26, 2008 2:04 am, Bhasker Kode wrote:
> Hi everyone,
>
> I just wanted to announce of an the project i've just opened up called
> bspawner.
>
> This project was an attempt to load-balance the task of spawning tasks
> across multiple nodes . The steps involved can be isolated into a
> couple of distinct problems.
>   1. deciding which node needs to spawn a task
>   2. communicating across these nodes
>   3. maintaining a record of nodes, added /removed nodes ,etc

I wonder how this compares to pool(3) ?

-Rick

P.S. I've never used pool(3) personally but thought about playing with it
from time to time.

> This project in its essence, deals with the first part and the
> implementation of the message passing begins with the "messenger.erl"
> program located at
> http://www.erlang.org/doc/getting_started/conc_prog.html and will be
> ported to different message-passing, load-balancing and
> node-information maintenance based on feedback,suggestions ,comments,
> and further changes inspired by the growing involvement of the erlang
> community & encouragement from #erlang in particular.
>
> Example
> ------------
> Assuming that there are three nodes: nodeA,nodeB,nodeC
>
> %%an un-balanced version
>
> 1>messenger:message(node1,{factorial,5}).
> 2>messenger:message(node1,{saveToDisk,"a.dat"}).
> 3>messenger:message(node1,{makeHttpRequest,Url}).
> %%all requests originate from current node,and get spawned at target node1
>
> %%un-balanced version
>
> 1>bspawner:bmessage(node1,{factorial,5}).
> 2>bspawner:bmessage(node1,{saveToDisk,"a.txt"}).
> 3>bspawner:bmessage(node1,{makeHttpRequest,Url}).
>
> %%OR you can directly give in {M,F,A} format
>
> 1>bspawner:bspawn({bspawner_request,{NumberCrunchingMod,factorial,[5]} }).
> 2>bspawner:bspawn({bspawner_request,{io,CustomSaveToDisk,["a.txt"]} }).
> 3>bspawner:bspawn({bspawner_request,{ProxyPortHandler,makeHttpRequest,[Url]}
> }).
>
> %% bmessage
> %% replicates messenger:message(node1,"hi") but internally calls bspawn
>
> 1>bspawner:bmessage(node1,"hi").
> %which is syntactic sugar for
> 2>bspawner:bspawn({ bspawner_request, {bspawner,message,["hi"]} })
>
>
> This was however before i got to know about the pool module which is
> exactly what i wanted in the first place. cheers to that, but it was a
> fun learning experience anyway - and i'm looking to add more clarity
> in terms of which node makes a request Vs which nose do processing,
> possibly add features like to make sets  of nodes to do X,another set
> to do Y, and more TODO's that i'd like to add along the way.
>
> Links
> --------
> http://bspawner.googlecode.com
> http://bosky101.blogspot.com/2008/05/erlang-distribution-bspawner.html
>
>
> Keep Clicking,
> Bhasker V Kode
> bosky101 on #erlang
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>




From kode@REDACTED  Tue May 27 19:02:56 2008
From: kode@REDACTED (Bhasker Kode)
Date: Tue, 27 May 2008 22:32:56 +0530
Subject: [erlang-questions] bspawner: spawn distribution among
	distributed nodes
In-Reply-To: <51872.192.168.129.36.1211906080.squirrel@squirrelmail.vail>
References: <3935b63b0805260004r60d8d7f9wb43ff01b130ed84c@mail.gmail.com>
	<51872.192.168.129.36.1211906080.squirrel@squirrelmail.vail>
Message-ID: <3935b63b0805271002x6ee09b28id73859c184aae12b@mail.gmail.com>

On Tue, May 27, 2008 at 10:04 PM, Rick Pettit  wrote:
> On Mon, May 26, 2008 2:04 am, Bhasker Kode wrote:
>> Hi everyone,
>>
>> I just wanted to announce of an the project i've just opened up called
>> bspawner.
>>
>> This project was an attempt to load-balance the task of spawning tasks
>> across multiple nodes . The steps involved can be isolated into a
>> couple of distinct problems.
>>   1. deciding which node needs to spawn a task
>>   2. communicating across these nodes
>>   3. maintaining a record of nodes, added /removed nodes ,etc
>
> I wonder how this compares to pool(3) ?
>
> -Rick

Hey,

I'm sure it does a much better job at what it says it does:

    * The slave nodes send regular reports to the master about their
current load.
    * Queries can be sent to the master to determine which node will
have the least load.

In fact , I wasn't aware of this module when I was working on
bspawner. It 's more of a experimental project than the full fledged
version that pool offers. I' ping back as soon as I do some comparison
though, and that might throw light on where pool does X better & why.

Keep Clicking,
~B


From hayeah@REDACTED  Tue May 27 19:05:17 2008
From: hayeah@REDACTED (Howard Yeh)
Date: Tue, 27 May 2008 10:05:17 -0700
Subject: [erlang-questions] something is looping,
	but can't figure out where.
In-Reply-To: <9b08084c0805270516y276eb3b3y65c05162a07d5cd7@mail.gmail.com>
References: 
	<9b08084c0805270516y276eb3b3y65c05162a07d5cd7@mail.gmail.com>
Message-ID: 

oops, i keep on forgetting to reply to the list,

Hi Joe,

That's a pretty cool technique!

I now know that io:format is giving me grief. I originally thought
it's because the compiling environment (I am working on a frontend) I
am trying to print is too large, so its being messaged around (and its
output being redirected to groupleader) would peg my CPU and eat up my
memory.

erlang:display(Env).  is ok, presumably because it outputs directly to
stdout. So I ended up storing most of the information in an ets. But
io:format (and even io:write)  still loop.

Sorry for spamming, here's some diagnostic info, the environment
printed with erlang:display.

group leader:<0.24.0>  %% group:server
ETS: [{memory,39235},
     {owner,<0.45.0>},
     {name,'serl-info'},
     {size,80},
     {node,nonode@REDACTED},
     {named_table,true},
     {type,set},
     {keypos,1},
     {protection,protected}]
process memory: {memory,1457220}
Env:
[{definitions,[{specials,[{cons,{#Fun}},{tuple,{#Fun}},{not,{#Fun}},{'==',{#Fun}},{'*',{#Fun}},{'/',{#Fun}},{'-',{#Fun}},{'+',{#Fun}},{toplevel,{#Fun}},{do,{#Fun}},{if,{#Fun}},{call,{#Fun}},{fn,{#Fun}},{lsc,{#Fun}},{case,{#Fun}},{let,{#Fun}},{'eval-binding',{#Fun}},{defspecial,{#Fun}},{defm,{#Fun}},{def,{#Fun}},{'specials-output',{#Fun}},{'specials-export',{#Fun}},{'macros-output',{#Fun}},{'macros-export',{#Fun}},{'functions-output',{#Fun}},{'functions-export',{#Fun}},{'functions-import',{#Fun}},{module,{#Fun}},{'__atom',{#Fun}},{'__string',{#Fun}},{'__float',{#Fun}},{'__integer',{#Fun}},{'__brace',{#Fun}},{'__block',{#Fun}},{'__eof',{#Fun}},{'__bof',{#Fun}}]},{macros,[{ls,{#Fun}},{begin,{#Fun}},{'>>',{#Fun}},{'let*',{#Fun}},{export,{#Fun}},{import,{#Fun}},{'export-from',{#Fun}},{'import-from',{#Fun}},{'with-genvar',{#Fun}}]},{functions,[{'list-of',{#Fun}},{'una-op',{#Fun}},{'bin-op',{#Fun}},{'nest-bin-op',{#Fun}},{'if-clauses',{#Fun}},{'remote-call',{#Fun}},{'local-call',{#Fun}},{'fn-value',{#Fun}},{'lsc-bindings',{#Fun}},{'let-bindings',{#Fun}},{'macro-arg-end',{#Fun}},{'macro-aux-blocks',{#Fun}},{'macro-arg-blocks-2',{#Fun}},{'macro-arg-blocks',{#Fun}},{'macro-parse-args',{#Fun}},{'output-meta-fun',{#Fun}},{'output-fun',{#Fun}},{'get-defs',{#Fun}},{'def-info',{#Fun}},{'new-def',{#Fun}},{'get-exports',{#Fun}},{'export-defs',{#Fun}},{'output-forms',{#Fun}},{cleanup,{#Fun}},{'guard-seq',{#Fun}},{'guarded-clause',{#Fun}},{clause,{#Fun}},{'atom-cat',{#Fun}},{'split-tail',{#Fun}},{'upto-block',{#Fun}},{erlpp,{#Fun}},{'ast-data',{#Fun}},{'ast-mod',{#Fun}},{'ast-line',{#Fun}},{'ast-tag',{#Fun}}]}]},{exports,[{macros,[{'__atom',71,serl,'export-from'},{'__atom',71,serl,'import-from'},{'__atom',72,serl,export},{'__atom',72,serl,import},{'__atom',73,serl,'let*'},{'__atom',73,serl,'>>'},{'__atom',74,serl,begin},{'__atom',75,serl,ls}]},{specials,[{'__atom',42,serl,'__eof'},{'__atom',42,serl,'__bof'},{'__atom',42,serl,'__block'},{'__atom',42,serl,'__brace'},{'__atom',42,serl,'__integer'},{'__atom',42,serl,'__float'},{'__atom',42,serl,'__string'},{'__atom',42,serl,'__atom'},{'__atom',54,serl,module},{'__atom',55,serl,def},{'__atom',55,serl,defm},{'__atom',55,serl,defspecial},{'__atom',56,serl,'functions-import'},{'__atom',56,serl,'functions-export'},{'__atom',56,serl,'functions-output'},{'__atom',58,serl,'macros-export'},{'__atom',58,serl,'macros-output'},{'__atom',60,serl,'specials-export'},{'__atom',60,serl,'specials-output'},{'__atom',61,serl,'eval-binding'},{'__atom',62,serl,let},{'__atom',62,serl,lsc},{'__atom',63,serl,fn},{'__atom',63,serl,call},{'__atom',64,serl,case},{'__atom',64,serl,if},{'__atom',65,serl,do},{'__atom',65,serl,toplevel},{'__atom',66,serl,tuple},{'__atom',66,serl,cons},{'__atom',67,serl,'+'},{'__atom',67,serl,'-'},{'__atom',67,serl,'*'},{'__atom',67,serl,'/'},{'__atom',67,serl,'=='},{'__atom',68,serl,not}]},{functions,[{'__atom',44,serl,'ast-tag'},{'__atom',44,serl,'ast-line'},{'__atom',44,serl,'ast-mod'},{'__atom',44,serl,'ast-data'},{'__atom',45,serl,'upto-block'},{'__atom',46,serl,'atom-cat'},{'__atom',47,serl,erlpp},{'__atom',48,serl,'output-forms'}]}]},{lexical,[]},{imports,[{erlang,[{functions,[{length,{{erlang,length}}},{self,{{erlang,self}}}]}]},{lists,[{functions,[{foldl,{{lists,foldl}}},{foldr,{{lists,foldr}}},{foreach,{{lists,foreach}}},{map,{{lists,map}}},{member,{{lists,member}}},{reverse,{{lists,reverse}}}]}]},{scompile,[{functions,[{curmod,{{scompile,curmod}}},{error,{{scompile,error}}},{gensym,{{scompile,gensym}}},{genvar,{{scompile,genvar}}},{is_curmod,{{scompile,is_curmod}}},{lineno,{{scompile,lineno}}},{map_env0,{{scompile,map_env0}}},{transform,{{scompile,transform}}},{transform_each,{{scompile,transform_each}}}]}]},{serl,[{functions,[{'ast-tag',{{serl,'ast-tag'},[{doc,[]}]}},{'ast-line',{{serl,'ast-line'},[{doc,[]}]}},{'ast-mod',{{serl,'ast-mod'},[{doc,[]}]}},{'ast-data',{{serl,'ast-data'},[{doc,[]}]}},{'upto-block',{{serl,'upto-block'},[{doc,[]}]}},{'atom-cat',{{serl,'atom-cat'},[{doc,[]}]}},{erlpp,{{serl,erlpp},[{doc,[]}]}},{'output-forms',{{serl,'output-forms'},[{doc,[]}]}}]},{macros,[{'export-from',{{serl,'$mac-export-from'},[{doc,[]}]}},{'import-from',{{serl,'$mac-import-from'},[{doc,[]}]}},{export,{{serl,'$mac-export'},[{doc,[]}]}},{import,{{serl,'$mac-import'},[{doc,[]}]}},{'let*',{{serl,'$mac-let*'},[{doc,[]}]}},{'>>',{{serl,'$mac->>'},[{doc,[]}]}},{begin,{{serl,'$mac-begin'},[{doc,[]}]}},{ls,{{serl,'$mac-ls'},[{doc,[]}]}}]},{specials,[{'__eof',{{serl,'$special-__eof'},[{doc,[]}]}},{'__bof',{{serl,'$special-__bof'},[{doc,[]}]}},{'__block',{{serl,'$special-__block'},[{doc,[]}]}},{'__brace',{{serl,'$special-__brace'},[{doc,[]}]}},{'__integer',{{serl,'$special-__integer'},[{doc,[]}]}},{'__float',{{serl,'$special-__float'},[{doc,[]}]}},{'__string',{{serl,'$special-__string'},[{doc,[]}]}},{'__atom',{{serl,'$special-__atom'},[{doc,[]}]}},{module,{{serl,'$special-module'},[{doc,[]}]}},{def,{{serl,'$special-def'},[{doc,[]}]}},{defm,{{serl,'$special-defm'},[{doc,[]}]}},{defspecial,{{serl,'$special-defspecial'},[{doc,[]}]}},{'functions-import',{{serl,'$special-functions-import'},[{doc,[]}]}},{'functions-export',{{serl,'$special-functions-export'},[{doc,[]}]}},{'functions-output',{{serl,'$special-functions-output'},[{doc,[]}]}},{'macros-export',{{serl,'$special-macros-export'},[{doc,[]}]}},{'macros-output',{{serl,'$special-macros-output'},[{doc,[]}]}},{'specials-export',{{serl,'$special-specials-export'},[{doc,[]}]}},{'specials-output',{{serl,'$special-specials-output'},[{doc,[]}]}},{'eval-binding',{{serl,'$special-eval-binding'},[{doc,[]}]}},{let,{{serl,'$special-let'},[{doc,[]}]}},{lsc,{{serl,'$special-lsc'},[{doc,[]}]}},{fn,{{serl,'$special-fn'},[{doc,[]}]}},{call,{{serl,'$special-call'},[{doc,[]}]}},{case,{{serl,'$special-case'},[{doc,[]}]}},{if,{{serl,'$special-if'},[{doc,[]}]}},{do,{{serl,'$special-do'},[{doc,[]}]}},{toplevel,{{serl,'$special-toplevel'},[{doc,[]}]}},{tuple,{{serl,'$special-tuple'},[{doc,[]}]}},{cons,{{serl,'$special-cons'},[{doc,[]}]}},{'+',{{serl,'$special-+'},[{doc,[]}]}},{'-',{{serl,'$special--'},[{doc,[]}]}},{'*',{{serl,'$special-*'},[{doc,[]}]}},{'/',{{serl,'$special-/'},[{doc,[]}]}},{'==',{{serl,'$special-=='},[{doc,[]}]}},{not,{{serl,'$special-not'},[{doc,[]}]}}]}]},{verl,[{specials,[{'__bof',{{verl,'__sp_bof'}}},{'__eof',{{verl,'__sp_eof'}}},{'__float',{{verl,'__sp_float'}}},{'__integer',{{verl,'__sp_integer'}}},{'__string',{{verl,'__sp_string'}}},{'__atom',{{verl,'__sp_atom'}}},{'__var',{{verl,'__sp_var'}}},{'__block',{{verl,'__sp_block'}}},{'__brace',{{verl,'__sp_brace'}}},{'__call',{{verl,'__sp_call'}}},{'__quote',{{verl,'__sp_quote'}}},{'__bquote',{{verl,'__sp_bquote'}}},{defm,{{verl,'__sp_defm'}}},{'eval-binding',{{verl,'__sp_eval-binding'}}},{let,{{verl,'__sp_let'}}},{module,{{verl,'__sp_module'}}},{export,{{verl,'__sp_export'}}},{import,{{verl,'__sp_import'}}},{record,{{verl,'__sp_record'}}},{def,{{verl,'__sp_def'}}},{tuple,{{verl,'__sp_tuple'}}},{cons,{{verl,'__sp_cons'}}},{nil,{{verl,'__sp_nil'}}},{op,{{verl,'__sp_op'}}},{'+',{{verl,'__sp_+'}}},{'-',{{verl,'__sp_-'}}},{'*',{{verl,'__sp_*'}}},{'/',{{verl,'__sp_/'}}},{rem,{{verl,'__sp_rem'}}},{'++',{{verl,'__sp_++'}}},{'==',{{verl,'__sp_=='}}},{'<',{{verl,'__sp_<'}}},{'>',{{verl,'__sp_>'}}},{'>=',{{verl,'__sp_>='}}},{'=<',{{verl,'__sp_=<'}}},{and,{{verl,'__sp_and'}}},{or,{{verl,'__sp_or'}}},{andalso,{{verl,'__sp_andalso'}}},{orelse,{{verl,'__sp_orelse'}}},{not,{{verl,'__sp_not'}}},{catch,{{verl,'__sp_catch'}}},{if,{{verl,'__sp_if'}}},{case,{{verl,'__sp_case'}}},{try,{{verl,'__sp_try'}}},{fn,{{verl,'__sp_fn'}}},{do,{{verl,'__sp_begin'}}},{begin,{{verl,'__sp_begin'}}}]},{macros,[{ls,{{verl,'__mac_ls'}}},{'>>',{{verl,'__mac_>>'}}},{float,{{verl,'__mac_float'}}},{integer,{{verl,'__mac_integer'}}},{string,{{verl,'__mac_string'}}},{atom,{{verl,'__mac_atom'}}},{var,{{verl,'__mac_var'}}},{block,{{verl,'__mac_block'}}},{paren,{{verl,'__mac_paren'}}},{brace,{{verl,'__mac_brace'}}},{floats,{{verl,'__mac_floats'}}},{integers,{{verl,'__mac_integers'}}},{strings,{{verl,'__mac_strings'}}},{atoms,{{verl,'__mac_atoms'}}},{vars,{{verl,'__mac_vars'}}},{blocks,{{verl,'__mac_blocks'}}},{parens,{{verl,'__mac_parens'}}},{braces,{{verl,'__mac_braces'}}}]},{rmacros,[{a,{{verl,'__rm_a'}}},{c,{{verl,'__rm_c'}}},{s,{{verl,'__rm_s'}}}]},{functions,[{cat,{{lists,append}}},{fmt,{{io,format}}}]}]}]}]


can somebody briefly explain how io works? And how it interacts with
the shell. I was reading the source, but it's hard to make sense of
w/o some guidance. I just need a rough sense of who's talking to whom
about what.

howard
On 5/27/08, Joe Armstrong  wrote:
> You can mess around with the BIFs processes() and process_info(Pid, Tag)
>
>  These BIFS are described in the man page for Erlang (erl -man erl) (or
>  pre-installed man pages for windows)   (or
>  http://www.erlang.org/doc/man/erlang.html))
>
>  processes() returns a list of all Pids in the system.
>
>  process_info(Pid, Tag) returns process information for the process
>  Pid. Tag says what kind of information
>  you want. process_info(Pid) returns even more info per process
>
>  A command like
>
>  > [ process_info(Pid) || Pid <- processes()]
>  ...
>
>  Will help you track down which process has run  wild.
>
>  Exercise: using processes/0 and process_info/1 (or /2) write a
>  function find_looping_process() that
>  locates the bad process. Hint take two samples with 5 second intervals
>  and compare ...
>
>  /Joe Armstrong
>
>
>
>
>
>  On Sun, May 25, 2008 at 11:23 PM, Howard Yeh  wrote:
>  > Hi,
>  >
>  > Earlier I was having problem with not getting the shell prompt back
>  > after a computation (with something looping & consuming memory).
>  > Putting the computation in a process seemed to have solved the
>  > problem.
>  >
>  > Now I am getting looping behaviour again. I am pretty sure my
>  > computation is not looping, since it raises an error (previously I
>  > could see the returned result). This time I have a timeout to kill the
>  > linked computation process after 10 seconds.
>  >
>  > After looping for 10 seconds, the computation process is killed, and i
>  > get the shell prompt back. But something keeps looping (pegs CPU, but
>  > consumes no memory).
>  >
>  > Does c:i() list all the processes? Looking at the reduction counts,
>  > nothing is increasing except the shell related processes. But those
>  > processes are only reducing my sending the i() command.
>  >
>  > I am really confused.
>  >
>  > Howard
>
> > _______________________________________________
>  > erlang-questions mailing list
>  > erlang-questions@REDACTED
>  > http://www.erlang.org/mailman/listinfo/erlang-questions
>  >
>


-- 
hayeah.wordpress.com
   --metacircular thinking


From mark.peleus@REDACTED  Tue May 27 19:09:18 2008
From: mark.peleus@REDACTED (mark peleus)
Date: Tue, 27 May 2008 20:09:18 +0300
Subject: [erlang-questions] otp modules dependencies
Message-ID: <599dd3e0805271009s44306d79ob9c60b6504524a8c@mail.gmail.com>

Hi,

I have erlang installed (not otp) but I need a package from the otp, xmerl
for example.

If erlang and the otp are from the same version, I guess I can just copy
xmerl ebing folder to my erlang installation directory
and modify the path in the erlang start script.

How do I know if a package, xmerl in this case, is dependent on other
packages?

Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From hayeah@REDACTED  Tue May 27 19:35:27 2008
From: hayeah@REDACTED (Howard Yeh)
Date: Tue, 27 May 2008 10:35:27 -0700
Subject: [erlang-questions] otp modules dependencies
In-Reply-To: <599dd3e0805271009s44306d79ob9c60b6504524a8c@mail.gmail.com>
References: <599dd3e0805271009s44306d79ob9c60b6504524a8c@mail.gmail.com>
Message-ID: 

Isn't OTP installed by default (i'm new too)?

I typed xmerl:foo() to get xmerl loaded, then xmerl: to see what
functions are available. I didn't do anything special to install it.

On 5/27/08, mark peleus  wrote:
> Hi,
>
> I have erlang installed (not otp) but I need a package from the otp, xmerl
> for example.
>
> If erlang and the otp are from the same version, I guess I can just copy
> xmerl ebing folder to my erlang installation directory
>  and modify the path in the erlang start script.
>
> How do I know if a package, xmerl in this case, is dependent on other
> packages?
>
> Thanks
>
>
>
> _______________________________________________
>  erlang-questions mailing list
>  erlang-questions@REDACTED
>  http://www.erlang.org/mailman/listinfo/erlang-questions
>


-- 
hayeah.wordpress.com
   --metacircular thinking


From klacke@REDACTED  Tue May 27 19:45:58 2008
From: klacke@REDACTED (Claes Wikstrom)
Date: Tue, 27 May 2008 19:45:58 +0200
Subject: [erlang-questions] ssl certificates
In-Reply-To: 
References: 
Message-ID: <483C48D6.6000308@hyber.org>

Anders Nygren wrote:
> Hi
> just wondering, is there any special information or options that must
> be specified
> when purchasing a SSL certificate, that is to be used with erlang/yaws.

No

/klacke


From mikpe@REDACTED  Tue May 27 22:15:40 2008
From: mikpe@REDACTED (Mikael Pettersson)
Date: Tue, 27 May 2008 22:15:40 +0200
Subject: [erlang-questions] Compiling erlang core modules with +native
	and -smp
In-Reply-To: <24d4f39c0805270917q3e548785o26dea0a06daf86eb@mail.gmail.com>
References: <24d4f39c0805270740x713d01a7l749d106982bb0c52@mail.gmail.com>
	<18492.10171.469026.664042@harpo.it.uu.se>
	<24d4f39c0805270917q3e548785o26dea0a06daf86eb@mail.gmail.com>
Message-ID: <18492.27628.323325.808173@alkaid.it.uu.se>

Colm Dougan writes:
 > On Tue, May 27, 2008 at 4:24 PM, Mikael Pettersson  wrote:
 > > Colm Dougan writes:
 > >  > Hi list,
 > >  >
 > >  > I had to compile the Debian version of erlang from source (to apply
 > >  > the zlib patch) and I noticed that there was an optional native.diff
 > >  > patch which builds the core erlang modules (stdlib, io_lib etc) using
 > >  > the +native option.  I decided to try this patch as I need all the
 > >  > performance I can get :)
 > >  >
 > >  > Anyway, later when I ran some code with this erlang using the -smp
 > >  > option to 'erl' I got lots of warnings like this :
 > >  >
 > >  > =INFO REPORT==== 27-May-2008::15:31:24 ===
 > >  >  Warning: not loading native code for module io_lib:
 > >  > it was compiled for an incompatible runtime system; please regenerate
 > >  > native code for this runtime system
 > >  >
 > >  > I guess this is because the +native code is not compatible with -smp
 > >  > and modules need to be compiled with both +native *and* -smp in order
 > >  > for the native code to be used.
 > >
 > > No, native and SMP are fully compatible. However, native code compiled
 > > for an SMP runtime is incompatible with a non-SMP runtime, and native
 > > code compiled for a non-SMP runtime is incompatible with an SMP runtime.
 > > (And there is little we can do about that incompatibility without
 > > sacrificing runtime performance on non-SMP, alas.)
 > >
 > > You need to take care to use the same SMP-or-not runtime system at
 > > compile-time as you intend to use at runtime.
 > 
 > I see.  Thanks.  This means that if I want to compile the erlang
 > standard library with +native then I have to know in advance whether I
 > will be using -smp on my runtime system.  Right?

Yes.
It will fall back to the BEAM code if there's a load-time mismatch,
so things should still "work", but the load-time warnings and loss
of performance won't be nice.

 > I'm wondering if it would make sense to have a compile option that
 > compiles native code for both SMP and non SMP runtimes into the same
 > beam such that the relevant native native code can be selected at
 > runtime?   I don't know if that makes any sense - just wondering.

That would require support for "fat" binaries. We don't yet have that.

/Mikael


From 0x6e6562@REDACTED  Tue May 27 22:25:48 2008
From: 0x6e6562@REDACTED (Ben Hood)
Date: Tue, 27 May 2008 21:25:48 +0100
Subject: [erlang-questions] Leex - a lexical anaylzer generator, released
In-Reply-To: <3dbc6d1c0805240839k24b5a91cq71346591fe0faed8@mail.gmail.com>
References: <3dbc6d1c0805240839k24b5a91cq71346591fe0faed8@mail.gmail.com>
Message-ID: <0E07146E-57CA-47A1-9DD6-856DC2B7B477@gmail.com>

Robert,

On 24 May 2008, at 16:39, Robert Virding wrote:

> Apart from this there are no other noticeable changes. The Erlang  
> and LFE token syntaxes are included as examples.

This may sound like a stupid question, but how do you use it?

In the documentation, it says that you can tokenize a stream by calling

io:request(InFile, {get_until,Prompt,Module,tokens,[Line]})

and in the old example tutorial which uses leex:gen/2 to create the  
lexer, its uses the following:

io:requests(Stream, [{get_until,foo,Module, tokens,[LineNo]}])

to pass of the stream to the parser.

This doesn't seem to work with the new version of leex and I can't  
seem to find any documentation about io:request/1,2 or io:requests/1,2

Do you have a example that demonstrates glue code to create the lexer  
and parser and then interpret a stream using the current code base?

Thanks,

Ben


From erlang-questions_efine@REDACTED  Tue May 27 23:59:29 2008
From: erlang-questions_efine@REDACTED (Edwin Fine)
Date: Tue, 27 May 2008 17:59:29 -0400
Subject: [erlang-questions] otp modules dependencies
In-Reply-To: <599dd3e0805271009s44306d79ob9c60b6504524a8c@mail.gmail.com>
References: <599dd3e0805271009s44306d79ob9c60b6504524a8c@mail.gmail.com>
Message-ID: <6c2563b20805271459p3a156170r50a47c61d5fd6b54@mail.gmail.com>

Mark,

I'm not sure how you installed Erlang without installing the libraries. Are
you sure they are not there? If you are running on Linux, look in
/usr/local/lib/erlang/lib or maybe /usr/lib/erlang/lib and you should see
many modules, including xmerl-X.Y.Z. Sometimes when you download software
you need to compile, a module has -include_lib("xmerl.hrl"), or even
specifies the version in the include, and the Makefile defines a compiler
include path to a different version (e.g. xmerl-1.1.8). I had to change one
of Yaws 1.75 source files due to an include of a version-specific OTP
module.

Anyway, this would make the compile command fail, e.g.

$ cat > test.erl
-module(test).
-include_lib("xmerl.hrl").
^D

$ erlc -W test.erl
./test.erl:2: can't find include lib "xmerl.hrl"

But adding the correct -I fixes it:

$ erlc -I /usr/local/lib/erlang/lib/xmerl-1.1.8/include/ -W test.erl
$

As for run-time dependencies, you can find this out using the xref
application.

7> xref:start(s).
{ok,<0.41.0>}
8> xref:add_release(s, "/usr/local/lib/erlang/lib/xmerl-1.1.8", {name,
xmerl}).
xmerl: 2 unresolved calls
xmerl_b64Bin: 2 unresolved calls
xmerl_eventp: 3 unresolved calls
xmerl_lib: 8 unresolved calls
xmerl_scan: 128 unresolved calls
xmerl_validate: 3 unresolved calls
xmerl_xpath: 2 unresolved calls
xmerl_xpath_parse: 2 unresolved calls
xmerl_xpath_pred: 4 unresolved calls
xmerl_xsd: 10 unresolved calls
{ok,xmerl}
9> xref:set_library_path(s, code_path).
ok
10> xref:analyze(s, {module_call,xmerl}).
{ok,['$M_EXPR',erlang,lists,xmerl,xmerl_lib]}
11> xref:analyze(s,
{module_call,xmerl_lib}).
{ok,['$M_EXPR',lists,xmerl_lib,xmerl_ucs]}
12> xref:analyze(s, {module_call,xmerl_ucs}).
{ok,[io,lists,xmerl_ucs]}
13> xref:analyze(s, {module_call,io}).
{ok,[]}
14> xref:analyze(s, {module_call,lists}).
{ok,[]}
15> xref:analyze(s, {module_call,erlang}).
{ok,[]}

Hopefully I have done this right. It looks as if xmerl depends on erlang,
lists, itself, and xmerl_lib, and xmerl_lib depends on xmerl_ucs and io. I
could have done the above by writing a function but I was too lazy. I am
sure there's a better way to figure this out, I just don't know it, being
new to Erlang. My feeling  is that if the libraries that come with the
standard Erlang distribution really are not installed, install them because
you will almost certainly need many if not most of them at some point.

HTH



2008/5/27 mark peleus :

> Hi,
>
> I have erlang installed (not otp) but I need a package from the otp, xmerl
> for example.
>
> If erlang and the otp are from the same version, I guess I can just copy
> xmerl ebing folder to my erlang installation directory
> and modify the path in the erlang start script.
>
> How do I know if a package, xmerl in this case, is dependent on other
> packages?
>
> Thanks
>
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From ciukes2@REDACTED  Wed May 28 00:14:01 2008
From: ciukes2@REDACTED (Marcin Maciukiewicz)
Date: Wed, 28 May 2008 00:14:01 +0200
Subject: [erlang-questions] [gen_server] time out error when handle_call
	returns {noreply, State}
Message-ID: <8be022390805271514gfd1574ev4b5ec493a3d90301@mail.gmail.com>

Hi,

This are my first steps in Erlang World. So far I'm stuck with
gen_server:Module:handle_call/3.
I get time out every time when {noreply, State} is returned. Following
are code snippets:
* Server module: http://pastebin.com/f590f0e00
* Test module: http://pastebin.com/f2af1806b
* Console output: http://pastebin.com/f3b998308

As I understand, the correct value is returned from handle_call/3. No
problem with that. What I cannot determine is a reason for the time
out error.
So far I have found this post:
http://www.erlang.org/pipermail/erlang-questions/2006-March/019821.html
Following the advice I introduced pp:start/0. No success, same story again.

Can somebody help me out with the problem?

Thanks in advance,
Marcin.


From chandrashekhar.mullaparthi@REDACTED  Wed May 28 00:35:08 2008
From: chandrashekhar.mullaparthi@REDACTED (Chandru)
Date: Tue, 27 May 2008 23:35:08 +0100
Subject: [erlang-questions] [gen_server] time out error when handle_call
	returns {noreply, State}
In-Reply-To: <8be022390805271514gfd1574ev4b5ec493a3d90301@mail.gmail.com>
References: <8be022390805271514gfd1574ev4b5ec493a3d90301@mail.gmail.com>
Message-ID: 

2008/5/27 Marcin Maciukiewicz :
> Hi,
>
> This are my first steps in Erlang World. So far I'm stuck with
> gen_server:Module:handle_call/3.
%> I get time out every time when {noreply, State} is returned. Following
> are code snippets:
> * Server module: http://pastebin.com/f590f0e00
> * Test module: http://pastebin.com/f2af1806b
> * Console output: http://pastebin.com/f3b998308
>
> As I understand, the correct value is returned from handle_call/3. No
> problem with that. What I cannot determine is a reason for the time
> out error.

The possible return values from the handle_call/3 function are:

%%--------------------------------------------------------------------
%% Function: handle_call/3
%% Description: Handling call messages
%% Returns: {reply, Reply, State}          |
%%          {reply, Reply, State, Timeout} |
%%          {noreply, State}               |
%%          {noreply, State, Timeout}      |
%%          {stop, Reason, Reply, State}   | (terminate/2 is called)
%%          {stop, Reason, State}            (terminate/2 is called)
%--------------------------------------------------------------------

If you use {noreply, State} or {noreply, State, Timeout}, then  you have to
at some point invoke gen_server:reply/2 to return a reply to the caller.
This is to allow the server process to continue doing something while
possibly waiting for something to finish.

If you want to return a reply immediately, return {reply, Reply, State} or
{reply, Reply, State, Timeout} from your handle_call/3 callback.

This page in the online documentation describes the various options pretty
well.

http://www.erlang.org/doc/design_principles/gen_server_concepts.html#2

cheers
Chandru
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From rvirding@REDACTED  Wed May 28 01:14:06 2008
From: rvirding@REDACTED (Robert Virding)
Date: Wed, 28 May 2008 01:14:06 +0200
Subject: [erlang-questions] LFE syntax,
	was Leex - a lexical anaylzer generator, released
Message-ID: <3dbc6d1c0805271614v531c65f5p8170ecfb72d1ee61@mail.gmail.com>

2008/5/27 zambal :

> On May 26, 5:10 pm, "Robert Virding"  wrote:
> > These are taken from Scheme R6RS and will most likely go as LFE has no
> use
> > for them.
> >
> > #' #` #, #,@ are for use in syntax-case macros and mean:
> >
> > #'  - (syntax ...)
> > #`  - (quasisyntax ...)
> > #,  - (unsyntax ...)
> > #,@ - (unsyntax-splicing ...)
> >
> > #; - comment out next sepxr which could actually be useful
>
> Thanks for clearing that up. If I understand you correctly these
> things provide nothing that you can't do with LFE's macro form, right?


Well, at the moment they don't provide anything. The code to handle doesn't
exist. :-) And it probably never will, at least not in LFE. They are part of
the syntax-case macro handling in Scheme and provide something like normal
lisp backquote but wrapped in Schemes hygienic macro handling.

You can almost everything using LFE macros but without a gensym it is no
really safe. It looks like I will have to add it.

> Also I missed #| ... |# for block comments. Might also be useful. Question
> > is if block comments are token or character based?
>
> Actually, I haven't missed them at all. The only use case for me is
> when pasting some text from an external source in my code, which
> doesn't happen a lot.


I don't miss them either but some people like them. And if you have them you
can have long arguments on whether they should be token or character based,
and whether they should nest or not. -) I think the erlang-questions can do
without it.

> Glad you enjoy LFE.
>
> Yeah, I have lot's of fun with it, especially it's macro
> functionality. Speaking of which, as far as I know it's currently not
> possible to export a macro in a module, so that it's usable in other
> modules. Is such functionality planned for a future release of LFE, if
> possible at all (or desirable, I haven't thought a lot about the
> consequences)?


At present macros are not exported, the only solution today is to put them
in a separate file and include them with (include-file ...). You can also
slurp them into the shell. This is pretty much like you do in Erlang today.
It wouldn't be too difficult to define a way to export them and have the
macro expander check for their existence at macro expand time. It is a
possible new feature for the next release. You would have to be a bit sneaky
as their is no real support for macros in Erlang, it would be difficult to
integrate them as seamlessly as in Lisp.

Robert
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From taavi@REDACTED  Wed May 28 00:58:09 2008
From: taavi@REDACTED (Taavi Talvik)
Date: Wed, 28 May 2008 01:58:09 +0300
Subject: [erlang-questions] [gen_server] time out error when handle_call
	returns {noreply, State}
In-Reply-To: <8be022390805271514gfd1574ev4b5ec493a3d90301@mail.gmail.com>
References: <8be022390805271514gfd1574ev4b5ec493a3d90301@mail.gmail.com>
Message-ID: <217353B3-FE5A-44E2-8556-80F9C6FC85D7@uninet.ee>


On May 28, 2008, at 1:14 AM, Marcin Maciukiewicz wrote:

> Hi,
>
> This are my first steps in Erlang World. So far I'm stuck with
> gen_server:Module:handle_call/3.
> I get time out every time when {noreply, State} is returned. Following
> are code snippets:
> * Server module: http://pastebin.com/f590f0e00

alloc(Pid) -> gen_server:call(?MODULE, {alloc, Pid}, infinity).

handle_call({alloc, Pid}, From, State) ->
    ... some logic to save caller information From..
    {noreply, State}.

and somwhere else in code

gen_server:reply(From, finally_my_answer_is_ready).


or

handle_call({alloc, Pid}, From, State) ->
    {reply, my_answer_is_allready_available, State}.

if you can answer immediately.

best regards,
taavi


From rvirding@REDACTED  Wed May 28 01:56:40 2008
From: rvirding@REDACTED (Robert Virding)
Date: Wed, 28 May 2008 01:56:40 +0200
Subject: [erlang-questions] Leex - a lexical anaylzer generator, released
In-Reply-To: <0E07146E-57CA-47A1-9DD6-856DC2B7B477@gmail.com>
References: <3dbc6d1c0805240839k24b5a91cq71346591fe0faed8@mail.gmail.com>
	<0E07146E-57CA-47A1-9DD6-856DC2B7B477@gmail.com>
Message-ID: <3dbc6d1c0805271656l2fb4ca0fyb13d1ac7f2d10f24@mail.gmail.com>

2008/5/27 Ben Hood <0x6e6562@REDACTED>:

> Robert,
> On 24 May 2008, at 16:39, Robert Virding wrote:
>
>  Apart from this there are no other noticeable changes. The Erlang and LFE
>> token syntaxes are included as examples.
>>
>
> This may sound like a stupid question, but how do you use it?
>
> In the documentation, it says that you can tokenize a stream by calling
>
> io:request(InFile, {get_until,Prompt,Module,tokens,[Line]})
>
> and in the old example tutorial which uses leex:gen/2 to create the lexer,
> its uses the following:
>
> io:requests(Stream, [{get_until,foo,Module, tokens,[LineNo]}])
>
> to pass of the stream to the parser.
>
> This doesn't seem to work with the new version of leex and I can't seem to
> find any documentation about io:request/1,2 or io:requests/1,2


First things first: there is no documentation on io:request/1/2 and
io:requests/1/2. They are sort of internal functions that interface the io
system to scan input. They do the same thing excepts that with requests you
can give a list of requests, both input and output. No, don't ask there is
no documentation about the io system either. At least I don't think so. Tell
me if I am wrong.

It seems as if I have saved my summer from the long easy days of doing
nothing. :-)

Leex is compliant with the io system and its functions work with it.
Basically when you process an xrl file you get an erlang module with 3 main
interface functions:

string/1/2 which takes a string of characters and input and tries to
tokenise it. All or nothing.

token/2/3 takes enough characters from an io stream to return one token.

tokens/2/3 takes enough characters to tokenise upto and including an
end_token (see new leex.txt and erlang_scan.xrl) or to the end of input.

Assume we have the file mysynt.xrl, running this through leex and then
compiling the erl file will generate the module mysynt. You can then do:

{ok,InFile} = file:open("input.file", [read]),
{ok,Toks,EndLine} = io:request(InFile,
{get_until,prompt,mysynt,tokens,[1]}),

which opens the file "input.file" for reading and tries to tokenise the
whole file (the tokens function). If it succeeds then Toks will contain the
list of all tokens and EndLine will be the line number of the of input. N.B.
the prompt 'prompt' is ginored for files but must be there. If you just want
to read one token you would do:

{ok,Tok,EndLine} = io:request(InFile, {get_until,prompt,mysynt,token,[1]}),

which will read one token.

If you have built a parser with yecc into the module myparse you could then
parse the input tokens by calling:

myparse:parse(Toks)

N.B. a yecc parser assumes that you give it a list containing all the tokens
it needs, and no more, in the call. This is the reason for the tokens/1/2
call from leex, '.' in erlang is an end_token. There is a way to get a yecc
parser to get more tokens by itself but the interface to it is broken and
sucks.


> Do you have a example that demonstrates glue code to create the lexer and
> parser and then interpret a stream using the current code base?


That was it. You can check lfe_io.erl in the LFE and look at the
parse_file/1 and read_file/1 functions. I use my own parser as I need it to
return remaining tokens so I can read one sexpr at a time. Yecc will not do
this, although it wouldn't be difficult to get to do it. :-(

I will try to write a Rationale which describes the io system, and other
core features, in more detail and how it all hangs together.

I hope that helped a little. Maybe others could point you to more code using
leex and parsers.

Robert
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From erlang-questions_efine@REDACTED  Wed May 28 06:26:23 2008
From: erlang-questions_efine@REDACTED (Edwin Fine)
Date: Wed, 28 May 2008 00:26:23 -0400
Subject: [erlang-questions] os_mon_mib error
Message-ID: <6c2563b20805272126x7abde05dkd26b597a88e55269@mail.gmail.com>

Hi all,

I am learning to use OTP snmp. I've done an snmp:config() for a v3 agent,
which is running ok, it seems. However, when I do an snmpwalk, I get a
wrongValue error. I'm running Ubuntu Feisty x86_64 using Erlang/OTP R12B-2.
This only happens if I do an os_mon_mib:load(snmp_master_agent).

What am I doing wrong?

$ snmpwalk -v 3 -l authPriv -m ALL -u initial -a MD5 -A **** -x DES -X ****
127.0.0.1:4000 otp
... snip ...
OTP-MIB::applVsn.1.7 = STRING: 2.12.2
OTP-OS-MON-MIB::loadMemorySystemWatermark.0 = INTEGER: 80
OTP-OS-MON-MIB::loadMemoryErlProcWatermark.0 = INTEGER: 5
Error in packet.
Reason: (genError) A general failure occured
Failed object: OTP-OS-MON-MIB::loadMemoryErlProcWatermark.0
--------------
The agent error is:

User error: Got 8386678784 from {os_mon_mib,load_table,[]}. Using wrongValue
--------------
The agent log is as follows:

*** [2008:05:28 04:13:39 4488] SNMP A-NET-IF A-USM LOG ***
   process_incoming_msg ->
   authEngineID: "edwin engine", userName: "initial"
*** [2008:05:28 04:13:39 4488] SNMP A-NET-IF MPD LOG ***

   contextEngineID: "edwin engine", context: ""
*** [2008:05:28 04:13:39 4488] SNMP A-NET-IF LOG ***
   got pdu

{pdu,'get-next-request',1080822006,noError,0,[{varbind,[1,3,6,1,4,1,193,19,3,2,2,1,2,0],'NULL','NULL',1}]}

=ERROR REPORT==== 28-May-2008::00:13:39 ===
** User error: Got 8386678784 from {os_mon_mib,load_table,[]}. Using
wrongValue
*** [2008:05:28 04:13:39 4489] SNMP A-NET-IF LOG ***
   reply pdu:

{pdu,'get-response',1080822006,genErr,1,[{varbind,[1,3,6,1,4,1,193,19,3,2,2,1,2,0],'NULL','NULL',1}]}
*** [2008:05:28 04:13:39 4489] SNMP A-NET-IF INFO ***
   time in agent: 1703 mysec

Regards,
Edwin Fine
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From ok@REDACTED  Wed May 28 08:09:59 2008
From: ok@REDACTED (Richard A. O'Keefe)
Date: Wed, 28 May 2008 18:09:59 +1200
Subject: [erlang-questions] eep: multiple patterns
In-Reply-To: <200805271503.11850.bekesa@sch.bme.hu>
References: <200805141620.19559.bekesa@sch.bme.hu> <482D5647.1030109@gmail.com>
	<3dbc6d1c0805230327i74b0ecd2ob0f7971fe2577ae8@mail.gmail.com>
	<200805271503.11850.bekesa@sch.bme.hu>
Message-ID: <6F3859A0-C852-4D29-8B98-BF42B443FF44@cs.otago.ac.nz>

On 28 May 2008, at 1:03 am, Andras Georgy Bekes wrote:
> I think there is a problem. I think I can express a pattern that's
> matching must involve backtracking:
>
> F(A1,A2...) when ({X,_}=A1 or {_,X}=A1) and ({X,_}=A2 ...

I wondered if anyone would spot that.
But the same stricture that we worked out before will answer
again:  no binding inside guard disjuncts.

My feeling here is that elaborate guards with lots of disjunctions
are a bad idea anyway.  Oddly enough, I don't see people doing that
in Haskell, although I do see the equivalent of

	f(...)
	   when ... -> ...;
	   when ... -> ...;
	            -> ...;
	...







From mbj@REDACTED  Wed May 28 08:19:35 2008
From: mbj@REDACTED (Martin Bjorklund)
Date: Wed, 28 May 2008 08:19:35 +0200 (CEST)
Subject: [erlang-questions] os_mon_mib error
In-Reply-To: <6c2563b20805272126x7abde05dkd26b597a88e55269@mail.gmail.com>
References: <6c2563b20805272126x7abde05dkd26b597a88e55269@mail.gmail.com>
Message-ID: <20080528.081935.139741070.mbj@tail-f.com>

Hi,

"Edwin Fine"  wrote:
> Hi all,
> 
> I am learning to use OTP snmp. I've done an snmp:config() for a v3 agent,
> which is running ok, it seems. However, when I do an snmpwalk, I get a
> wrongValue error. I'm running Ubuntu Feisty x86_64 using Erlang/OTP R12B-2.
> This only happens if I do an os_mon_mib:load(snmp_master_agent).
> 
> What am I doing wrong?

This is a bug in os_mon.

> $ snmpwalk -v 3 -l authPriv -m ALL -u initial -a MD5 -A **** -x DES -X ****
> 127.0.0.1:4000 otp
> ... snip ...
> OTP-MIB::applVsn.1.7 = STRING: 2.12.2
> OTP-OS-MON-MIB::loadMemorySystemWatermark.0 = INTEGER: 80
> OTP-OS-MON-MIB::loadMemoryErlProcWatermark.0 = INTEGER: 5
> Error in packet.
> Reason: (genError) A general failure occured
> Failed object: OTP-OS-MON-MIB::loadMemoryErlProcWatermark.0

This tells us that doing a GET-NEXT on loadMemoryErlProcWatermark.0
fails.  The object after this one in the MIB is
loadSystemTotalMemory.

> The agent error is:
> 
> User error: Got 8386678784 from {os_mon_mib,load_table,[]}. Using wrongValue

This tells us that when the agent called the instrumentation function
for loadSystemTotalMemory (which is the function load_table in module
os_mon_mib), it returned 8386678784, which the agent says is a bad
value.

The reason for the wrongValue is that loadSystemTotalMemory is a
Gauge32, and 8386678784 is not a 32-bit integer.  And this is since
you run on a 64-bit platform.

The MIB could be extended with an object of type CounterBasedGauge64
from the HCNUM-TC MIB (RFC2856), or the implementation would have to
truncate this value.  In either case - bug in os_mon.


/martin


From ok@REDACTED  Wed May 28 08:42:39 2008
From: ok@REDACTED (Richard A. O'Keefe)
Date: Wed, 28 May 2008 18:42:39 +1200
Subject: [erlang-questions] eep: multiple patterns
In-Reply-To: <200805271436.19305.bekesa@sch.bme.hu>
References: <200805141620.19559.bekesa@sch.bme.hu> <4836A517.2040909@gmail.com>
	
	<200805271436.19305.bekesa@sch.bme.hu>
Message-ID: <6BA6A9E9-EF89-4FE6-B683-05F3866E9E09@cs.otago.ac.nz>


On 28 May 2008, at 12:36 am, Andras Georgy Bekes wrote:

> Hi,
>
>> To me, what we can write now in Erlang as it stands,
>> separating "what are the actions" from "what are the names for the
>> actions", is easier to read and understand than anything using
>> multiple patterns would be,
>
> OK, you showed us (again?) that a possible use of multiple patterns  
> can
> be substituted with something else. It always can be done, and
> everybody knew that.
>
> Following your way of thinking, we'd conclude that the 'case'  
> construct
> is not needed because it can be substituted with auxiliary functions.
> Still we have the 'case' construct and like it.

*NO*.  The argument is not "we can do without it"
but "we can *EASILY* do without it" and
"doing without it can lead to BETTER code".

I am not interested in some kind of academic purity or minimalism.
What bothers me is people adding kluge upon kluge to a language
until it is as complicated as C++ and programs written in it as
unreadable as C++ can far too easily be.  (Have you ever tried
reading the Boost sources?)

What I showed you was not that "a possible use of multiple patterns
can be replaced by something else" but that it can EASILY be done
and that the code is easier to read when you have done it.
>
>
>> not because multiple patterns are a bad idea as
>> such, but because combining multiple *complex* patterns into a single
>> match makes the code harder to read.
> That's subjective. To me, the multiple patterns version reads better.

"Subjective" is not the same as "idiosyncratic" or "unmeasurable".
We _can_ measure these things.

>
>
>> Multiple *simple* patterns might make for a more interesting example.
> OK, you asked for real-life examples. OK, simple pattern.
> Here it is, straight from AXD301. I've replaced the "interesting"  
> parts
> with foo, bar and baz. Everything else is original.

GREAT!
>
>
> ----------------------------------------
> case classify_Foo(Foo) of
>   undefined_Foo -> bar(); % lots of code here
>   {meaningful_Foo, Bar, Baz} -> baz(Bar,Baz) % lots of code here
> end,
> ...
> classify_Foo(undefined) ->
>    undefined_Foo;
> classify_Foo({undefined, _, _}) ->
>    undefined_Foo;
> classify_Foo({Bar, Baz}) ->
>    {meaningful_Foo, Bar, Baz};
> classify_Foo({Bar, Baz, _}) ->
>    {meaningful_Foo, Bar, Baz}.
> ----------------------------------------
>
> How do you like it?

I must say that the _Foo business is hard to read;
I can't help seeing {meaningful Foo, Bar, Baz}.

Cleaning it up as
     case classify_foo(Foo)
       of undefined ->
          bar()
        ; {meaningful,Bar,Baz} ->
          baz(Bar, Baz)
     end,
     ...
classify_foo(undefined        ) -> undefined;
classify_foo({undefined, _, _}) -> undefined;
classify_foo({Bar,     Baz, _}) -> {meaningful,Bar,Baz};
classify_foo({Bar,     Baz}   ) -> {meaningful,Bar,BAz}.

I like it *fine*, especially if the arms of the case are
split out as separate functions (should that be possible).

Something I particularly like about this is that I can
sort the patterns in classify_foo so as to bring out
similarities between them, without being constrained by
any need to group together things with the same consequence.
In particular, *this* way it is easy for me to rearrange
the patterns, as in fact I have done, to make the overlap
between
	{undefined, _, _}
and	{Bar,     Baz, _}
obvious.  Now that I can see it, I can wonder what
{undefined,Baz,_} is supposed to do, and then whether
{undefined,Baz} is also possible, and what IT should do.

In short, doing it the way I recommend clearly in this
case has the potential to lead to more insight about the
data structure and quite possibly more reliable code,
because it makes it easier for me to *see* what the heck
is going on (in both places, as it happens).
>
> I prefer the multiple patterns version.

Yes, but why?  What does it help you to SEE that is useful
for programming and maintenance that the other approach
doesn't help you to see at least as well?
>
>
> (Don't tell me the problem is with the data structures. We all know
> AXD301 is garbage :-) but still, our users like it.

A program need not be garbage in order to profit from overhauled
data structures.  The Quintus Prolog compiler was a great piece of
work, but spending two weeks of work cleaning up its data structures
bought a 20% speed up.  It's one kind of refactoring.




From ciukes2@REDACTED  Wed May 28 09:37:37 2008
From: ciukes2@REDACTED (Marcin Maciukiewicz)
Date: Wed, 28 May 2008 09:37:37 +0200
Subject: [erlang-questions] [gen_server] time out error when handle_call
	returns {noreply, State}
In-Reply-To: <217353B3-FE5A-44E2-8556-80F9C6FC85D7@uninet.ee>
References: <8be022390805271514gfd1574ev4b5ec493a3d90301@mail.gmail.com>
	<217353B3-FE5A-44E2-8556-80F9C6FC85D7@uninet.ee>
Message-ID: <8be022390805280037h4b746d64na91181098ef89bf1@mail.gmail.com>

Thank both of you guys for help. So far I understand what you say, but
I'm not sure how it may help.
In the following code, last executed line is #14. After that VM hangs
for 5 sec thus I don't see a reasonable place to put
gen_server:reply/2. call.
http://pastebin.com/f590f0e00

I feel I need an extra push to understand. The reason why I play with
{noreply, State} is because I want to understand how to deal with this
case.

Regards,
Marcin.

On Wed, May 28, 2008 at 12:58 AM, Taavi Talvik  wrote:
>
> On May 28, 2008, at 1:14 AM, Marcin Maciukiewicz wrote:
>
>> Hi,
>>
>> This are my first steps in Erlang World. So far I'm stuck with
>> gen_server:Module:handle_call/3.
>> I get time out every time when {noreply, State} is returned. Following
>> are code snippets:
>> * Server module: http://pastebin.com/f590f0e00
>
> alloc(Pid) -> gen_server:call(?MODULE, {alloc, Pid}, infinity).
>
> handle_call({alloc, Pid}, From, State) ->
>   ... some logic to save caller information From..
>   {noreply, State}.
>
> and somwhere else in code
>
> gen_server:reply(From, finally_my_answer_is_ready).
>
>
> or
>
> handle_call({alloc, Pid}, From, State) ->
>   {reply, my_answer_is_allready_available, State}.
>
> if you can answer immediately.
>
> best regards,
> taavi
>


From ulf.wiger@REDACTED  Wed May 28 09:41:42 2008
From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB))
Date: Wed, 28 May 2008 09:41:42 +0200
Subject: [erlang-questions] eep: multiple patterns
In-Reply-To: <6BA6A9E9-EF89-4FE6-B683-05F3866E9E09@cs.otago.ac.nz>
References: <200805141620.19559.bekesa@sch.bme.hu>
	<4836A517.2040909@gmail.com>		<200805271436.19305.bekesa@sch.bme.hu>
	<6BA6A9E9-EF89-4FE6-B683-05F3866E9E09@cs.otago.ac.nz>
Message-ID: <483D0CB6.2080103@ericsson.com>

Richard A. O'Keefe skrev:
> On 28 May 2008, at 12:36 am, Andras Georgy Bekes wrote:
> 
>> OK, you asked for real-life examples. OK, simple pattern.
>> Here it is, straight from AXD301. I've replaced the "interesting"  
>> parts
>> with foo, bar and baz. Everything else is original.
> 
> GREAT!
>>
...
> 
> Cleaning it up as
>      case classify_foo(Foo)
>        of undefined ->
>           bar()
>         ; {meaningful,Bar,Baz} ->
>           baz(Bar, Baz)
>      end,
>      ...
> classify_foo(undefined        ) -> undefined;
> classify_foo({undefined, _, _}) -> undefined;
> classify_foo({Bar,     Baz, _}) -> {meaningful,Bar,Baz};
> classify_foo({Bar,     Baz}   ) -> {meaningful,Bar,BAz}.
> 
> I like it *fine*, especially if the arms of the case are
> split out as separate functions (should that be possible).

I would just like to point out, for the record, that
this style of programming works well for gen_server-style
processes (and is, in fact, used in e.g. gen_server.erl),
but for selective receive, it is much harder, since
selective receive relies entirely on pattern matching,
and as such, is very difficult to modularize.

At the risk of starting to sound like a broken record,
I'd very much like to see suggestions that don't further
encourage programmers to use gen_server-style programming
where they really ought to be writing selective receive
clauses (textbook erlang state machines). There is already
a tendency to do this, as gen_server* gives you a lot of
stuff for free - handling of system messages, a consistent
way of reporting programming errors, etc.

* gen_fsm is too semantically similar to gen_server, and
   doesn't offer selective receive any more than gen_server
   does - at least not in a way that matters much.

The problem with this is that it leads to "happy-case
programming" in a bad sense. It works fine for a large
class of cases, but when you run into situations with
interleaving events, it blows up in your face.

For that reason, suggestions that allow for parameterized
guards, e.g. in selective receive, are much more attractive
than those that don't.

BR,
Ulf W


From ft@REDACTED  Wed May 28 10:01:41 2008
From: ft@REDACTED (Fredrik Thulin)
Date: Wed, 28 May 2008 10:01:41 +0200
Subject: [erlang-questions] [gen_server] time out error when handle_call
 returns {noreply, State}
In-Reply-To: <8be022390805280037h4b746d64na91181098ef89bf1@mail.gmail.com>
References: <8be022390805271514gfd1574ev4b5ec493a3d90301@mail.gmail.com>	<217353B3-FE5A-44E2-8556-80F9C6FC85D7@uninet.ee>
	<8be022390805280037h4b746d64na91181098ef89bf1@mail.gmail.com>
Message-ID: <483D1165.3060404@it.su.se>

Marcin Maciukiewicz wrote:
> Thank both of you guys for help. So far I understand what you say, but
> I'm not sure how it may help.
> In the following code, last executed line is #14. After that VM hangs
> for 5 sec thus I don't see a reasonable place to put
> gen_server:reply/2. call.
> http://pastebin.com/f590f0e00
> 
> I feel I need an extra push to understand. The reason why I play with
> {noreply, State} is because I want to understand how to deal with this
> case.

Which case is that?

If you want to call a gen_server and get a response from it, you call it 
using gen_server:call(...).

   For this case, the gen_server handle_call function MUST either return
   {reply, ...}, or arrange for some process (the gen_server or another,
   for example a spawned worker process) to call gen_server:reply(...)
   before the caller times out.

On the other hand, if you want to tell a gen_server that it should do 
something, but you don't care about a return value from the gen_server, 
you use gen_server:cast(...) instead. In the gen_server, you then code 
an appropriate handle_cast(...) function clause instead of a 
handle_call(...).

/Fredrik


From taavi@REDACTED  Wed May 28 10:29:06 2008
From: taavi@REDACTED (Taavi Talvik)
Date: Wed, 28 May 2008 11:29:06 +0300
Subject: [erlang-questions] [gen_server] time out error when handle_call
	returns {noreply, State}
In-Reply-To: <8be022390805280037h4b746d64na91181098ef89bf1@mail.gmail.com>
References: <8be022390805271514gfd1574ev4b5ec493a3d90301@mail.gmail.com>
	<217353B3-FE5A-44E2-8556-80F9C6FC85D7@uninet.ee>
	<8be022390805280037h4b746d64na91181098ef89bf1@mail.gmail.com>
Message-ID: <65E3BFBD-4FD4-437B-8EE1-96BAF36A2DC9@uninet.ee>


On May 28, 2008, at 10:37 AM, Marcin Maciukiewicz wrote:

> Thank both of you guys for help. So far I understand what you say, but
> I'm not sure how it may help.
> In the following code, last executed line is #14. After that VM hangs
> for 5 sec thus I don't see a reasonable place to put

No, no! VM does not hang!

All other processes continue normally! In Erlang you have thousands
of processes;) You can dedicate some of them for doing actual work..

Only your calling process is suspended until answer is available or
specifed timeout happens (which defaults to 5s).

>
> gen_server:reply/2. call.
> http://pastebin.com/f590f0e00
>
> I feel I need an extra push to understand. The reason why I play with
> {noreply, State} is because I want to understand how to deal with this
> case.

example:

handle_call({alloc, Pid}, From, State) ->
  actual_worker_process ! {please_calculate_reply_for_client, From,  
{alloc,Pid}},
  {noreply, State}.

and in actual_worker_proccess

start_worker() ->
    Pid = spawn(worker_loop),
    register(actual_worker_process, Pid).

worker_loop() ->
     receive
       {please_calculate_reply_for_client, Client, Args} ->
	  Result = .....(Args),
           gen_server:reply(Client, Result)
     end,
     worker_loop().

best regards,
taavi



From machinshin2002@REDACTED  Wed May 28 09:36:43 2008
From: machinshin2002@REDACTED (Vat Raghavan)
Date: Wed, 28 May 2008 00:36:43 -0700 (PDT)
Subject: [erlang-questions] extensions to syntax highlighting in erlang.
Message-ID: <905999.75748.qm@web31503.mail.mud.yahoo.com>

So i recently started running linux in a vm, and got into playing with gedit. and the syntax highlighting modules are simple clean and REALLY EASY to modify, so i've added in support for highlighting of edoc directives & edoc macros along with highlighting of records. i'll try and get this added to the core gedit but for now here it is for anyone who's interested :) 

there's a lot more that could be added, like different highlighting for binaries, or character types like $h, $e , etc. but i'm not currently interested in highlighting those, but that may change :) 



--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



      
-------------- next part --------------
A non-text attachment was scrubbed...
Name: erlang.lang
Type: application/octet-stream
Size: 9938 bytes
Desc: not available
URL: 

From machinshin2002@REDACTED  Wed May 28 10:15:59 2008
From: machinshin2002@REDACTED (Vat Raghavan)
Date: Wed, 28 May 2008 01:15:59 -0700 (PDT)
Subject: [erlang-questions] Syntax highlighting in gEdit : part 2 corrected
Message-ID: <86292.12253.qm@web31506.mail.mud.yahoo.com>

sigh. note to self: make sure you're looking at the latest version of your file when emailing to people across the world. 

this is the CORRECT version


 ----.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



      
-------------- next part --------------
A non-text attachment was scrubbed...
Name: erlang.lang
Type: application/octet-stream
Size: 10421 bytes
Desc: not available
URL: 

From ciukes2@REDACTED  Wed May 28 14:07:15 2008
From: ciukes2@REDACTED (Marcin Maciukiewicz)
Date: Wed, 28 May 2008 14:07:15 +0200
Subject: [erlang-questions] [gen_server] time out error when handle_call
	returns {noreply, State}
In-Reply-To: <483D1165.3060404@it.su.se>
References: <8be022390805271514gfd1574ev4b5ec493a3d90301@mail.gmail.com>
	<217353B3-FE5A-44E2-8556-80F9C6FC85D7@uninet.ee>
	<8be022390805280037h4b746d64na91181098ef89bf1@mail.gmail.com>
	<483D1165.3060404@it.su.se>
Message-ID: <8be022390805280507p64da8444g11e457804896e876@mail.gmail.com>

>> I feel I need an extra push to understand. The reason why I play with
>> {noreply, State} is because I want to understand how to deal with this
>> case.
>
> Which case is that?
Comes from "erlang-psql-driver" connection pooling code:
http://erlang-psql-driver.googlecode.com/svn/trunk/src/psql_pool.erl
Scroll down to "handle_call({alloc, Pid}...). For "nomatch" case
{noreply, State} is returned.

Trying to use the driver I end up in the scenario I described. Code
hungs for 5 seconds, then time out error happens.
The snippet I made (http://pastebin.com/f590f0e00) is an extract from
the situation I'm struggling with.
Firstly I was following the documentation
(http://erlang-psql-driver.googlecode.com/svn/trunk/doc/overview.edoc):
[code]
test()->
psql_pool:start_link(),
P = psql:allocate(),
... more code
[/code]
Code above causes time out. "more code" is not executed. After digging
the erlang-psql-driver code (good lesson for newbie like me) I
realized I have no idea how gen_server:call behaves when {noreply,
State} from handle_call is returned. An example from "Programming
Erlang" (http://media.pragprog.com/titles/jaerlang/code/my_bank.erl)
doesn't explain this too. This is how I end up with asking you guys
for help.

At the end of the day I want to learn the answers to following questions:
 - Why/When use {noreply, State} in handle_call
 - How to write proper code for this value returned - you gave me a
lot of input on that, thank you.
 - Why the heck psql:handle_call({allocate,Pid}... ) from
erlang-psql-driver is not working.

Regards,
Marcin.


From pfisher@REDACTED  Wed May 28 14:37:47 2008
From: pfisher@REDACTED (Paul Fisher)
Date: Wed, 28 May 2008 07:37:47 -0500
Subject: [erlang-questions] [gen_server] time out error when	handle_call
	returns {noreply, State}
In-Reply-To: <8be022390805280507p64da8444g11e457804896e876@mail.gmail.com>
References: <8be022390805271514gfd1574ev4b5ec493a3d90301@mail.gmail.com>
	<217353B3-FE5A-44E2-8556-80F9C6FC85D7@uninet.ee>
	<8be022390805280037h4b746d64na91181098ef89bf1@mail.gmail.com>
	<483D1165.3060404@it.su.se>
	<8be022390805280507p64da8444g11e457804896e876@mail.gmail.com>
Message-ID: <1211978267.6402.32.camel@localhost>

On Wed, 2008-05-28 at 14:07 +0200, Marcin Maciukiewicz wrote:
> At the end of the day I want to learn the answers to following questions:
>  - Why/When use {noreply, State} in handle_call

When you want to either: 1) not respond to the caller, forcing a timeout
(usually in the case of a bad request); or 2) respond asynchronously
from the return from the handle_call in order to allow the general
server to continue to process requests while some other process is
processing and generating the reply to the call (which it will respond
to with gen_server:reply)


>  - How to write proper code for this value returned - you gave me a
> lot of input on that, thank you.

>From the caller side, if the server is responding according to option #1
above, then you cannot do much more than you are doing now... the
timeout will occur.  If the server is responding according to option #2
above then you *may* just need to give it more time to respond, in which
case you use the gen_server:call variety that allows you to specify a
timeout.


>  - Why the heck psql:handle_call({allocate,Pid}... ) from
> erlang-psql-driver is not working.

Maybe taking a long time?  Someone familiar with the code will have to
comment.


--
paul



From erlang-questions_efine@REDACTED  Wed May 28 16:30:59 2008
From: erlang-questions_efine@REDACTED (Edwin Fine)
Date: Wed, 28 May 2008 10:30:59 -0400
Subject: [erlang-questions] os_mon_mib error
In-Reply-To: <20080528.081935.139741070.mbj@tail-f.com>
References: <6c2563b20805272126x7abde05dkd26b597a88e55269@mail.gmail.com>
	<20080528.081935.139741070.mbj@tail-f.com>
Message-ID: <6c2563b20805280730h16f4f4abt5696d2f3a0794e98@mail.gmail.com>

Thanks Martin!

It makes sense - the system has 8 GB of RAM (8386678784). Maybe what I will
do in the meantime is extend the MIB as you suggest just so I can move
forward. I'd rather not truncate the value since it is accurate.

Also, there are two values in the os_mon MIB that are incompletely defined:
loadAlarmsGroup and diskAlarmsGroup. I commented them out to avoid the error
messages.

Do I need to put in a bug report somewhere?

Regards,
Edwin


On Wed, May 28, 2008 at 2:19 AM, Martin Bjorklund  wrote:

> Hi,
>
> "Edwin Fine"  wrote:
> > Hi all,
> >
> > I am learning to use OTP snmp. I've done an snmp:config() for a v3 agent,
> > which is running ok, it seems. However, when I do an snmpwalk, I get a
> > wrongValue error. I'm running Ubuntu Feisty x86_64 using Erlang/OTP
> R12B-2.
> > This only happens if I do an os_mon_mib:load(snmp_master_agent).
> >
> > What am I doing wrong?
>
> This is a bug in os_mon.
>
> > $ snmpwalk -v 3 -l authPriv -m ALL -u initial -a MD5 -A **** -x DES -X
> ****
> > 127.0.0.1:4000 otp
> > ... snip ...
> > OTP-MIB::applVsn.1.7 = STRING: 2.12.2
> > OTP-OS-MON-MIB::loadMemorySystemWatermark.0 = INTEGER: 80
> > OTP-OS-MON-MIB::loadMemoryErlProcWatermark.0 = INTEGER: 5
> > Error in packet.
> > Reason: (genError) A general failure occured
> > Failed object: OTP-OS-MON-MIB::loadMemoryErlProcWatermark.0
>
> This tells us that doing a GET-NEXT on loadMemoryErlProcWatermark.0
> fails.  The object after this one in the MIB is
> loadSystemTotalMemory.
>
> > The agent error is:
> >
> > User error: Got 8386678784 from {os_mon_mib,load_table,[]}. Using
> wrongValue
>
> This tells us that when the agent called the instrumentation function
> for loadSystemTotalMemory (which is the function load_table in module
> os_mon_mib), it returned 8386678784, which the agent says is a bad
> value.
>
> The reason for the wrongValue is that loadSystemTotalMemory is a
> Gauge32, and 8386678784 is not a 32-bit integer.  And this is since
> you run on a 64-bit platform.
>
> The MIB could be extended with an object of type CounterBasedGauge64
> from the HCNUM-TC MIB (RFC2856), or the implementation would have to
> truncate this value.  In either case - bug in os_mon.
>
>
> /martin
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From lenartlad@REDACTED  Wed May 28 17:16:31 2008
From: lenartlad@REDACTED (Ladislav Lenart)
Date: Wed, 28 May 2008 17:16:31 +0200
Subject: [erlang-questions] [Q] dialyzer message: The pattern X can never
	match the type Y
Message-ID: <483D774F.7070301@volny.cz>

Hello,

first I'd like to say that dialyzer is a wonderful and
easy-to-use tool. It has already found several bugs for
me :-)

But I don't understand what dialyzer is trying to tell
me with a warning like:

   The pattern X can never match the type Y.

The actual code seems fine to me. It is similar to:

%%%%%%%%%%%%%%%%
-module(mod).

-export(f/1).

f(Arg) when Arg == foo; Arg == bar; Arg == baz ->
     case Arg of
         foo -> x();
         _ -> y()
     end.
%%%%%%%%%%%%%%%%

However, dialyzer does not report a warning like:

   The pattern 'foo' can never match the type 'baz'

for the module above.

So I'd like to know what does the warning mean.

Thanks in advance,

Ladislav Lenart



From stonecypher@REDACTED  Wed May 28 17:42:54 2008
From: stonecypher@REDACTED (John Haugeland)
Date: Wed, 28 May 2008 09:42:54 -0600
Subject: [erlang-questions] erlang-questions Digest, Vol 12, Issue 89
In-Reply-To: 
References: 
Message-ID: <8f24f4b10805280842r4fdd87far2d8079f0a4da446f@mail.gmail.com>

Well, if Vat can put up his gEdit highlighter, maybe I can put up my ConTEXT
highlighter.  Yay highlighters!  Boo emacs.

http://sc.tri-bit.com/outgoing/Erlang.chl
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From per.melin@REDACTED  Wed May 28 17:52:03 2008
From: per.melin@REDACTED (Per Melin)
Date: Wed, 28 May 2008 17:52:03 +0200
Subject: [erlang-questions] Tail recursive tests
Message-ID: 

>From time to time I find that I want to write something like:

foo([]) -> true;
foo([H|T]) -> bar(H) andalso foo(T).

Which works, but is not tail recursive. Is there any reason why it couldn't be?

Does anyone consider it bad form? I find it clearer than:

foo([H|T]) ->
    case bar(H) of
        true  -> foo(T);
        false -> false
    end.

This is *not* another variation of the old "I hate Erlang's case and
if" discussion. I'm only talking about functions that evaluates to a
boolean.

Here's a more involved example:

search_for_key(<<>>, _, _) ->
    false;
search_for_key(B, C, K) ->
    delim_char(C) andalso subsearch(B, K)
        orelse
            <> = B,
            search_for_key(B2, C2, K).


From kostis@REDACTED  Wed May 28 17:53:56 2008
From: kostis@REDACTED (Kostis Sagonas)
Date: Wed, 28 May 2008 18:53:56 +0300
Subject: [erlang-questions] [Q] dialyzer message: The pattern X can
 never match the type Y
In-Reply-To: <483D774F.7070301@volny.cz>
References: <483D774F.7070301@volny.cz>
Message-ID: <483D8014.50102@cs.ntua.gr>

Ladislav Lenart wrote:
> Hello,
> 
> first I'd like to say that dialyzer is a wonderful and
> easy-to-use tool.

Thanks!

> It has already found several bugs for me :-)

Don't worry: dialyzer has even found several bugs in its own code!

> But I don't understand what dialyzer is trying to tell
> me with a warning like:
> 
>    The pattern X can never match the type Y.
> 
> The actual code seems fine to me. It is similar to:
> 
> 	... CODE REMOVED ...
> 
> However, dialyzer does not report a warning like:

It might have helped if instead of presenting code that does not show 
the warning, you presented code which does.  Anyway, here is a slight 
modification of the program you sent:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-module(mod).
-export([f/1]).

f(Arg) when Arg == foo; Arg == bar; Arg == baz ->
    case Arg of
       foo -> ok1;                 % line 6
       gazonk -> weird;            % line 7
       _ -> ok2
    end.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

dialyzer will report that:

mod.erl:7: The pattern 'gazonk' can never match the type 'bar' | 'baz'

In the first line of the function, the type of the Arg variable is 
constrained to the type 'foo' | 'bar' | 'baz'.  In line 6, 'foo' is 
consumed and the remaining type is 'bar' | 'baz'.  Since 'gazonk' is not 
part of this type, you get the above warning.

Hope this explains what the warning means.

Kostis


From olopierpa@REDACTED  Wed May 28 18:21:10 2008
From: olopierpa@REDACTED (Pierpaolo Bernardi)
Date: Wed, 28 May 2008 18:21:10 +0200
Subject: [erlang-questions] Tail recursive tests
In-Reply-To: 
References: 
Message-ID: <7352e43a0805280921m57f8e143tfcc97e2cf1996399@mail.gmail.com>

On 5/28/08, Per Melin  wrote:
> >From time to time I find that I want to write something like:
>
> foo([]) -> true;
> foo([H|T]) -> bar(H) andalso foo(T).
>
> Which works, but is not tail recursive. Is there any reason why it couldn't be?

I agree with you.

see http://www.erlang.org/pipermail/erlang-questions/2003-March/008107.html
and preceding and following messages, for a previous discussion.

Cheers
P.


From per.melin@REDACTED  Wed May 28 18:38:16 2008
From: per.melin@REDACTED (Per Melin)
Date: Wed, 28 May 2008 18:38:16 +0200
Subject: [erlang-questions] Tail recursive tests
In-Reply-To: <7352e43a0805280921m57f8e143tfcc97e2cf1996399@mail.gmail.com>
References: 
	<7352e43a0805280921m57f8e143tfcc97e2cf1996399@mail.gmail.com>
Message-ID: 

2008/5/28 Pierpaolo Bernardi :
> I agree with you.
>
> see http://www.erlang.org/pipermail/erlang-questions/2003-March/008107.html
> and preceding and following messages, for a previous discussion.

Thanks. And there I found my answer: The right hand side is checked
for a correct type (boolean); therefor it cannot be tail recursive.


From wenewboy@REDACTED  Wed May 28 19:54:07 2008
From: wenewboy@REDACTED (wenew zhang)
Date: Thu, 29 May 2008 01:54:07 +0800
Subject: [erlang-questions] card game about gen_fsm how to
Message-ID: <4eaa09eb0805281054k1830e0edw5cc256c89e93e45f@mail.gmail.com>

Dear All,
    i used a gen_fsm in a cards game, when  gen_fsm-server in one status
,(just like 'SEND_CARDS'),of course,the gen_fsm hold many status like this,
but whichever status the gen_fsm in, the client can send a force quit
message to interrupt the current status,
i have more than ten status,need i write ten+ quit message process in each
status to fix this problem?

that's very boring

any simple solution to fix this?

tks

wenew zhang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From anders.nygren@REDACTED  Wed May 28 20:04:47 2008
From: anders.nygren@REDACTED (Anders Nygren)
Date: Wed, 28 May 2008 13:04:47 -0500
Subject: [erlang-questions] card game about gen_fsm how to
In-Reply-To: <4eaa09eb0805281054k1830e0edw5cc256c89e93e45f@mail.gmail.com>
References: <4eaa09eb0805281054k1830e0edw5cc256c89e93e45f@mail.gmail.com>
Message-ID: 

2008/5/28 wenew zhang :
> Dear All,
>     i used a gen_fsm in a cards game, when  gen_fsm-server in one status
> ,(just like 'SEND_CARDS'),of course,the gen_fsm hold many status like this,
> but whichever status the gen_fsm in, the client can send a force quit
> message to interrupt the current status,
> i have more than ten status,need i write ten+ quit message process in each
> status to fix this problem?
>
> that's very boring
>
> any simple solution to fix this?
>

use gen_fsm:send_all_state_event

and handle it in the handle_event/3 callback

/Anders

> tks
>
> wenew zhang
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>


From sean.hinde@REDACTED  Wed May 28 20:08:48 2008
From: sean.hinde@REDACTED (Sean Hinde)
Date: Wed, 28 May 2008 20:08:48 +0200
Subject: [erlang-questions] card game about gen_fsm how to
In-Reply-To: <4eaa09eb0805281054k1830e0edw5cc256c89e93e45f@mail.gmail.com>
References: <4eaa09eb0805281054k1830e0edw5cc256c89e93e45f@mail.gmail.com>
Message-ID: <990178B5-FE68-4263-98F3-00851B619A0F@gmail.com>

Hi,

gen_fsm provides the gen_fsm:send_all_state_event/2 API as a way to  
send messages that should be handled the same in all states. It will  
be handled in your Module:handle_event/3 callback.

Sean



On 28 May 2008, at 19:54, wenew zhang wrote:

> Dear All,
>     i used a gen_fsm in a cards game, when  gen_fsm-server in one  
> status ,(just like 'SEND_CARDS'),of course,the gen_fsm hold many  
> status like this,
> but whichever status the gen_fsm in, the client can send a force  
> quit message to interrupt the current status,
> i have more than ten status,need i write ten+ quit message process  
> in each status to fix this problem?
>
> that's very boring
>
> any simple solution to fix this?
>
> tks
>
> wenew zhang
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions



From wenewboy@REDACTED  Wed May 28 20:38:07 2008
From: wenewboy@REDACTED (wenew zhang)
Date: Thu, 29 May 2008 02:38:07 +0800
Subject: [erlang-questions] card game about gen_fsm how to
In-Reply-To: 
References: <4eaa09eb0805281054k1830e0edw5cc256c89e93e45f@mail.gmail.com>
	
Message-ID: <4eaa09eb0805281138o78c37c9et5c1f62ca740cf63c@mail.gmail.com>

oh,yes,it's works now

thank you very much!

wenew zhang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From wenewboy@REDACTED  Wed May 28 20:40:24 2008
From: wenewboy@REDACTED (wenew zhang)
Date: Thu, 29 May 2008 02:40:24 +0800
Subject: [erlang-questions] card game about gen_fsm how to
In-Reply-To: <990178B5-FE68-4263-98F3-00851B619A0F@gmail.com>
References: <4eaa09eb0805281054k1830e0edw5cc256c89e93e45f@mail.gmail.com>
	<990178B5-FE68-4263-98F3-00851B619A0F@gmail.com>
Message-ID: <4eaa09eb0805281140y4fa45085ob6f47053a9bbe3bb@mail.gmail.com>

yes,i did it as that way,

i very appreciate you reply

Best Regards

wenew zhang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From per.gustafsson@REDACTED  Wed May 28 21:42:12 2008
From: per.gustafsson@REDACTED (Per Gustafsson)
Date: Wed, 28 May 2008 21:42:12 +0200
Subject: [erlang-questions] [Q] dialyzer message: The pattern X can
 never match the type Y
In-Reply-To: <483D774F.7070301@volny.cz>
References: <483D774F.7070301@volny.cz>
Message-ID: <483DB594.7010404@it.uu.se>

Ladislav Lenart wrote:
> Hello,
>
> first I'd like to say that dialyzer is a wonderful and
> easy-to-use tool. It has already found several bugs for
> me :-)
>
> But I don't understand what dialyzer is trying to tell
> me with a warning like:
>
>    The pattern X can never match the type Y.
>
> The actual code seems fine to me. It is similar to:
>
> %%%%%%%%%%%%%%%%
> -module(mod).
>
> -export(f/1).
>
> f(Arg) when Arg == foo; Arg == bar; Arg == baz ->
>      case Arg of
>          foo -> x();
>          _ -> y()
>      end.
> %%%%%%%%%%%%%%%%
>
> However, dialyzer does not report a warning like:
>
>    The pattern 'foo' can never match the type 'baz'
>
> for the module above.
>
> So I'd like to know what does the warning mean.
>
> Thanks in advance,
>
> Ladislav Lenart
>
>   

The most likely reason you get a warning like that, which is hard to 
understand is that you have something like this:

-module(mod).

-export([g/0]).

g() ->
  f(bar),...,f(baz).

f(Arg) when Arg == foo; Arg == bar; Arg == baz ->
     case Arg of
         foo -> x();
         _ -> y()
     end.

That is you never actually call f/1 with foo and f/1 is not exported.

Per
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>   



From erlang@REDACTED  Wed May 28 22:18:04 2008
From: erlang@REDACTED (Joe Armstrong)
Date: Wed, 28 May 2008 22:18:04 +0200
Subject: [erlang-questions] Erlang lecture
Message-ID: <9b08084c0805281318m50c4e4bflb0c27694a6366ad@mail.gmail.com>

This is my "standard lecture"

http://www.infoq.com/presentations/erlang-software-for-a-concurrent-world

recorded at JAOO in september 2007 - it took a long time before it emerged

/Joe


From ok@REDACTED  Thu May 29 03:21:35 2008
From: ok@REDACTED (Richard A. O'Keefe)
Date: Thu, 29 May 2008 13:21:35 +1200
Subject: [erlang-questions] Style (was eep: multiple patterns)
In-Reply-To: <483B0CB7.30101@san.rr.com>
References: <483B0CB7.30101@san.rr.com>
Message-ID: <6B5CAE47-18B6-4B12-A5EC-7BAE3CC71366@cs.otago.ac.nz>


On 27 May 2008, at 7:17 am, Darren New wrote:

> Richard A. O'Keefe wrote:
>> I like this because it makes a clean separation between
>> "what are the actions" and "what are the names for the actions".
>
> Is there anything you'd recommend to someone learning how best to use
> Erlang to get some of these useful idioms?

Apparently this particular one *isn't* an idiom, although I think
it should be.  It's a consequence of a general language-independent
principle:

    when your code needs to be structured in two (or more)
    incompatible ways, split it into as many ways, each of
    which can be structured naturally.

and it is vaguely related to the old idea of TABLE-DRIVEN CODE,
as described in Kernighan & Plauger, "The Elements of Programming
Style".  In this case, the function that maps a wild range of
patterns (and guards) to action codes basically is the table
they're talking about.  It's not entirely unrelated to another
old programming idea, which was popularised for COBOL, but did
exist also as an addition to the Burroughs B6700 Algol compiler,
DECISION TABLES, where there is a tabular presentation of a
complex set of decisions about what to do, separated from the
code that performs the actions.

I suppose you could call it the "Decision Table" pattern,
for want of a better name.



From ok@REDACTED  Thu May 29 04:39:10 2008
From: ok@REDACTED (Richard A. O'Keefe)
Date: Thu, 29 May 2008 14:39:10 +1200
Subject: [erlang-questions] eep: multiple patterns
In-Reply-To: <483D0CB6.2080103@ericsson.com>
References: <200805141620.19559.bekesa@sch.bme.hu>
	<4836A517.2040909@gmail.com>		<200805271436.19305.bekesa@sch.bme.hu>
	<6BA6A9E9-EF89-4FE6-B683-05F3866E9E09@cs.otago.ac.nz>
	<483D0CB6.2080103@ericsson.com>
Message-ID: 


On 28 May 2008, at 7:41 pm, Ulf Wiger (TN/EAB) wrote:
> I would just like to point out, for the record, that
> this style of programming works well for gen_server-style
> processes (and is, in fact, used in e.g. gen_server.erl),
> but for selective receive, it is much harder, since
> selective receive relies entirely on pattern matching,
> and as such, is very difficult to modularize.

It's not completely clear to me what Ulf Wiger means by
"this style of programming".  Using "this style of
programming" to mean "the decision table pattern",
it works perfectly fine for selective receive.

	case receive			% DECISIONS!
		P1 when G1 -> A1
	      ; P2 when G2 -> A2
	      ...
	      ; Pn when Gn -> An
	      after T -> A0
	    end
	 of A1 ->			% ACTIONS!
	      B1
	  ; A2 ->
	      B2
	  ...
	  ; An ->
	      Bn
	  ; A0 ->
	      B0
	end

Indeed, I've always assumed that receives were actually
implemented that way under the covers and never bothered
to look.  Here the A1 are either atomic tags or
{tag,Datum,...} tuples naming what each pattern *means*.

Let's be clear here:  *most* of the time you shouldn't do
this, and if you find that you want to, you should first
think hard about refactoring your message protocol, even
to the extent of hiding behind a proxy process that
converts a messy protocol to a clean one (and has no other
tasks).  Having several patterns that map to the same thing
is a good sign that your information representation is
flawed.

One tool that would be nice to have, and perhaps the
Dialyzer already does this, is something that tells you
when the clauses of a function or of a case or of a
receive overlap.  In classic pattern-matching terminology,
I'm talking about "critical pairs", and they are critical
for programming reliability because they are the ones
where the order of the clauses matters for correctness.
Interleaving patterns and actions makes it harder to
visually compare the patterns to check for critical
pairs, omissions, &c; separating them makes it easier.

> At the risk of starting to sound like a broken record,
> I'd very much like to see suggestions that don't further
> encourage programmers to use gen_server-style programming
> where they really ought to be writing selective receive
> clauses (textbook erlang state machines). There is already
> a tendency to do this, as gen_server* gives you a lot of
> stuff for free - handling of system messages, a consistent
> way of reporting programming errors, etc.

Since the decision table pattern is fully compatible with
selective receive, I don't see the relevance of this point
to this thread.

> For that reason, suggestions that allow for parameterized
> guards, e.g. in selective receive, are much more attractive
> than those that don't.

I don't understand what "parameterized guards" means here.
This is a thread about multi-PATTERNS, not guards as such.



From yarivsadan@REDACTED  Thu May 29 07:12:29 2008
From: yarivsadan@REDACTED (Yariv Sadan)
Date: Wed, 28 May 2008 22:12:29 -0700
Subject: [erlang-questions] Twoorl: an open source Twitter clone
Message-ID: <17244f480805282212g32eaa0e1o78493087bd12fd0@mail.gmail.com>

Hi,

I created an open source Twitter clone in Erlang called Twoorl. I
wrote it on top of ErlyWeb/Yaws.  You can see it at http://twoorl.com.
The code is at http://code.google.com/p/twoorl.

I'll appreciate any feedback!

Thanks,
Yariv


From nick@REDACTED  Thu May 29 07:26:00 2008
From: nick@REDACTED (Nick Gerakines)
Date: Wed, 28 May 2008 22:26:00 -0700
Subject: [erlang-questions] Twoorl: an open source Twitter clone
In-Reply-To: <17244f480805282212g32eaa0e1o78493087bd12fd0@mail.gmail.com>
References: <17244f480805282212g32eaa0e1o78493087bd12fd0@mail.gmail.com>
Message-ID: 

MySQL? Seriously?

I've heard from multiple sources database congestion is a major source
of scaling problems for websites. Why take MySQL over a fragmented
mnesia store or a set of hybrid services?

# Nick Gerakines

On Wed, May 28, 2008 at 10:12 PM, Yariv Sadan  wrote:
> Hi,
>
> I created an open source Twitter clone in Erlang called Twoorl. I
> wrote it on top of ErlyWeb/Yaws.  You can see it at http://twoorl.com.
> The code is at http://code.google.com/p/twoorl.
>
> I'll appreciate any feedback!
>
> Thanks,
> Yariv
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>


From yarivsadan@REDACTED  Thu May 29 07:38:19 2008
From: yarivsadan@REDACTED (Yariv Sadan)
Date: Wed, 28 May 2008 22:38:19 -0700
Subject: [erlang-questions] Twoorl: an open source Twitter clone
In-Reply-To: 
References: <17244f480805282212g32eaa0e1o78493087bd12fd0@mail.gmail.com>
	
Message-ID: <17244f480805282238q79f294e5je25a8378c89c71f2@mail.gmail.com>

Facebook runs on MySQL -- that's pretty scalable :)

The main reason I didn't go with Mnesia for storing most data is the
dets issues discussed previously on this list (specifically, the long
repair times and the need for fragmentation over 4gb). I use Mnesia
for storing session data though.

Yariv

On Wed, May 28, 2008 at 10:26 PM, Nick Gerakines  wrote:
> MySQL? Seriously?
>
> I've heard from multiple sources database congestion is a major source
> of scaling problems for websites. Why take MySQL over a fragmented
> mnesia store or a set of hybrid services?
>
> # Nick Gerakines
>
> On Wed, May 28, 2008 at 10:12 PM, Yariv Sadan  wrote:
>> Hi,
>>
>> I created an open source Twitter clone in Erlang called Twoorl. I
>> wrote it on top of ErlyWeb/Yaws.  You can see it at http://twoorl.com.
>> The code is at http://code.google.com/p/twoorl.
>>
>> I'll appreciate any feedback!
>>
>> Thanks,
>> Yariv
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://www.erlang.org/mailman/listinfo/erlang-questions
>>
>


From rapsey@REDACTED  Thu May 29 07:55:02 2008
From: rapsey@REDACTED (Rapsey)
Date: Thu, 29 May 2008 07:55:02 +0200
Subject: [erlang-questions] Twoorl: an open source Twitter clone
In-Reply-To: <17244f480805282238q79f294e5je25a8378c89c71f2@mail.gmail.com>
References: <17244f480805282212g32eaa0e1o78493087bd12fd0@mail.gmail.com>
	
	<17244f480805282238q79f294e5je25a8378c89c71f2@mail.gmail.com>
Message-ID: <97619b170805282255k67d080dbhe7c8d8b8c431377b@mail.gmail.com>

Are the repair times really that much of a problem? It's not like servers or
erlang runtime crash that often.
I would think the advantages of using mnesia far outweight the
disadvantages. Mnesia is much easier to scale and work with than mysql.


Sergej


On Thu, May 29, 2008 at 7:38 AM, Yariv Sadan  wrote:

> Facebook runs on MySQL -- that's pretty scalable :)
>
> The main reason I didn't go with Mnesia for storing most data is the
> dets issues discussed previously on this list (specifically, the long
> repair times and the need for fragmentation over 4gb). I use Mnesia
> for storing session data though.
>
> Yariv
>
> On Wed, May 28, 2008 at 10:26 PM, Nick Gerakines 
> wrote:
> > MySQL? Seriously?
> >
> > I've heard from multiple sources database congestion is a major source
> > of scaling problems for websites. Why take MySQL over a fragmented
> > mnesia store or a set of hybrid services?
> >
> > # Nick Gerakines
> >
> > On Wed, May 28, 2008 at 10:12 PM, Yariv Sadan 
> wrote:
> >> Hi,
> >>
> >> I created an open source Twitter clone in Erlang called Twoorl. I
> >> wrote it on top of ErlyWeb/Yaws.  You can see it at http://twoorl.com.
> >> The code is at http://code.google.com/p/twoorl.
> >>
> >> I'll appreciate any feedback!
> >>
> >> Thanks,
> >> Yariv
> >> _______________________________________________
> >> erlang-questions mailing list
> >> erlang-questions@REDACTED
> >> http://www.erlang.org/mailman/listinfo/erlang-questions
> >>
> >
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From anders.nygren@REDACTED  Thu May 29 08:09:40 2008
From: anders.nygren@REDACTED (Anders Nygren)
Date: Thu, 29 May 2008 01:09:40 -0500
Subject: [erlang-questions] Twoorl: an open source Twitter clone
In-Reply-To: <97619b170805282255k67d080dbhe7c8d8b8c431377b@mail.gmail.com>
References: <17244f480805282212g32eaa0e1o78493087bd12fd0@mail.gmail.com>
	
	<17244f480805282238q79f294e5je25a8378c89c71f2@mail.gmail.com>
	<97619b170805282255k67d080dbhe7c8d8b8c431377b@mail.gmail.com>
Message-ID: 

2008/5/29 Rapsey :
> Are the repair times really that much of a problem? It's not like servers or
> erlang runtime crash that often.
> I would think the advantages of using mnesia far outweight the
> disadvantages. Mnesia is much easier to scale and work with than mysql.
>

I don't know who scared Yariv about dets, but it is interesting
to note in The Erlang Efficiency Guide it now says.

"2.6 Myth: Repairing a Dets file is very slow

The repair time is still proportional to the number of records in the
file, but Dets repairs used to be much, much slower in the past. Dets
has been massively rewritten and improved. "

So I don't know if his worries still apply.

/Anders

>
> Sergej
>
>
> On Thu, May 29, 2008 at 7:38 AM, Yariv Sadan  wrote:
>>
>> Facebook runs on MySQL -- that's pretty scalable :)
>>
>> The main reason I didn't go with Mnesia for storing most data is the
>> dets issues discussed previously on this list (specifically, the long
>> repair times and the need for fragmentation over 4gb). I use Mnesia
>> for storing session data though.
>>
>> Yariv
>>
>> On Wed, May 28, 2008 at 10:26 PM, Nick Gerakines 
>> wrote:
>> > MySQL? Seriously?
>> >
>> > I've heard from multiple sources database congestion is a major source
>> > of scaling problems for websites. Why take MySQL over a fragmented
>> > mnesia store or a set of hybrid services?
>> >
>> > # Nick Gerakines
>> >
>> > On Wed, May 28, 2008 at 10:12 PM, Yariv Sadan 
>> > wrote:
>> >> Hi,
>> >>
>> >> I created an open source Twitter clone in Erlang called Twoorl. I
>> >> wrote it on top of ErlyWeb/Yaws.  You can see it at http://twoorl.com.
>> >> The code is at http://code.google.com/p/twoorl.
>> >>
>> >> I'll appreciate any feedback!
>> >>
>> >> Thanks,
>> >> Yariv
>> >> _______________________________________________
>> >> erlang-questions mailing list
>> >> erlang-questions@REDACTED
>> >> http://www.erlang.org/mailman/listinfo/erlang-questions
>> >>
>> >
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://www.erlang.org/mailman/listinfo/erlang-questions
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>


From yarivsadan@REDACTED  Thu May 29 08:34:43 2008
From: yarivsadan@REDACTED (Yariv Sadan)
Date: Wed, 28 May 2008 23:34:43 -0700
Subject: [erlang-questions] Twoorl: an open source Twitter clone
In-Reply-To: 
References: <17244f480805282212g32eaa0e1o78493087bd12fd0@mail.gmail.com>
	
	<17244f480805282238q79f294e5je25a8378c89c71f2@mail.gmail.com>
	<97619b170805282255k67d080dbhe7c8d8b8c431377b@mail.gmail.com>
	
Message-ID: <17244f480805282334r3f9ebaegbb833557d91e42d@mail.gmail.com>

>
> I don't know who scared Yariv about dets, but it is interesting
> to note in The Erlang Efficiency Guide it now says.
>
> "2.6 Myth: Repairing a Dets file is very slow
>
> The repair time is still proportional to the number of records in the
> file, but Dets repairs used to be much, much slower in the past. Dets
> has been massively rewritten and improved. "
>
> So I don't know if his worries still apply.
>
> /Anders
>

That's great -- I didn't see that!

What scared me was when Klacke said dets should be rewritten.

Yariv


From yarivsadan@REDACTED  Thu May 29 08:39:34 2008
From: yarivsadan@REDACTED (Yariv Sadan)
Date: Wed, 28 May 2008 23:39:34 -0700
Subject: [erlang-questions] Twoorl: an open source Twitter clone
In-Reply-To: <97619b170805282255k67d080dbhe7c8d8b8c431377b@mail.gmail.com>
References: <17244f480805282212g32eaa0e1o78493087bd12fd0@mail.gmail.com>
	
	<17244f480805282238q79f294e5je25a8378c89c71f2@mail.gmail.com>
	<97619b170805282255k67d080dbhe7c8d8b8c431377b@mail.gmail.com>
Message-ID: <17244f480805282339k16442ddo2f48aa66c5f06f7d@mail.gmail.com>

I've been using MySQL for Vimagi (http://vimagi.com) and haven't had
any problems. ErlyDB makes working with MySQL very easy -- just as
easy as Mnesia (if not easier in some cases) in terms of APIs. The
main reasons I went with MySQL are that I didn't want to deal with
fragmentation and dets repair times (yes, I know it wouldn't really
affect an app such as Twoorl, but I've already gotten into the mindset
of avoiding dets).

I actually wouldn't mind offering Mnesia as an alternate data store if
someone wants to implement it :)

Yariv

2008/5/28 Rapsey :
> Are the repair times really that much of a problem? It's not like servers or
> erlang runtime crash that often.
> I would think the advantages of using mnesia far outweight the
> disadvantages. Mnesia is much easier to scale and work with than mysql.
>
>
> Sergej
>
>
> On Thu, May 29, 2008 at 7:38 AM, Yariv Sadan  wrote:
>>
>> Facebook runs on MySQL -- that's pretty scalable :)
>>
>> The main reason I didn't go with Mnesia for storing most data is the
>> dets issues discussed previously on this list (specifically, the long
>> repair times and the need for fragmentation over 4gb). I use Mnesia
>> for storing session data though.
>>
>> Yariv
>>
>> On Wed, May 28, 2008 at 10:26 PM, Nick Gerakines 
>> wrote:
>> > MySQL? Seriously?
>> >
>> > I've heard from multiple sources database congestion is a major source
>> > of scaling problems for websites. Why take MySQL over a fragmented
>> > mnesia store or a set of hybrid services?
>> >
>> > # Nick Gerakines
>> >
>> > On Wed, May 28, 2008 at 10:12 PM, Yariv Sadan 
>> > wrote:
>> >> Hi,
>> >>
>> >> I created an open source Twitter clone in Erlang called Twoorl. I
>> >> wrote it on top of ErlyWeb/Yaws.  You can see it at http://twoorl.com.
>> >> The code is at http://code.google.com/p/twoorl.
>> >>
>> >> I'll appreciate any feedback!
>> >>
>> >> Thanks,
>> >> Yariv
>> >> _______________________________________________
>> >> erlang-questions mailing list
>> >> erlang-questions@REDACTED
>> >> http://www.erlang.org/mailman/listinfo/erlang-questions
>> >>
>> >
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://www.erlang.org/mailman/listinfo/erlang-questions
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>


From ulf.wiger@REDACTED  Thu May 29 08:44:12 2008
From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB))
Date: Thu, 29 May 2008 08:44:12 +0200
Subject: [erlang-questions] eep: multiple patterns
In-Reply-To: 
References: <200805141620.19559.bekesa@sch.bme.hu>
	<4836A517.2040909@gmail.com>		<200805271436.19305.bekesa@sch.bme.hu>
	<6BA6A9E9-EF89-4FE6-B683-05F3866E9E09@cs.otago.ac.nz>
	<483D0CB6.2080103@ericsson.com>
	
Message-ID: <483E50BC.2060902@ericsson.com>

Richard A. O'Keefe skrev:
> 
> On 28 May 2008, at 7:41 pm, Ulf Wiger (TN/EAB) wrote:
>> I would just like to point out, for the record, that
>> this style of programming works well for gen_server-style
>> processes (and is, in fact, used in e.g. gen_server.erl),
>> but for selective receive, it is much harder, since
>> selective receive relies entirely on pattern matching,
>> and as such, is very difficult to modularize.
> 
> It's not completely clear to me what Ulf Wiger means by
> "this style of programming".  Using "this style of
> programming" to mean "the decision table pattern",
> it works perfectly fine for selective receive.

Apologies for being unclear.
It seemed to me as if the thread was approaching
the idea of

receive Msg ->
   case classify_msg(Msg) of
     Type -> Action
     ...
   end.

which is what I was referring to.
It is not surprising that the OTP behaviours gen_server
and gen_fsm both use FIFO message reception, and then
classify each message, sometimes using a callback.

Maybe it's another thread altogether, but, I was
under the impression that abstract patterns could
actually help this situation (too) somewhat.
My own impression is that this is a more pressing
problem to solve than making multiple patterns more
convenient. If the discussions are orthogonal, great,
but otherwise, I'd like to see this particular
problem considered as well.

BR,
Ulf W



From mikael@REDACTED  Thu May 29 09:01:50 2008
From: mikael@REDACTED (Mikael Lixenstrand)
Date: Thu, 29 May 2008 09:01:50 +0200
Subject: [erlang-questions] gen_sctp multi-homing
Message-ID: 

I have some questions regarding gen_sctp and multihoming. It?s possible to
create a socket to multiple local peers but i haven't figured out how to
connect a socket to multiple IPs on another host.

Is this possible with gen_sctp or would i need to implement something using
more sockets?
I would like to have one socket with multiple associations, one for each
peer on remote host.

/mikael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From lenartlad@REDACTED  Thu May 29 10:03:34 2008
From: lenartlad@REDACTED (Ladislav Lenart)
Date: Thu, 29 May 2008 10:03:34 +0200
Subject: [erlang-questions] [Q] dialyzer message: The pattern X can
 never match the type Y
In-Reply-To: <483DB594.7010404@it.uu.se>
References: <483D774F.7070301@volny.cz> <483DB594.7010404@it.uu.se>
Message-ID: <483E6356.3040804@volny.cz>

Per Gustafsson wrote:
> The most likely reason you get a warning like that, which is hard to 
> understand is that you have something like this:
> 
> -module(mod).
> 
> -export([g/0]).
> 
> g() ->
>   f(bar),...,f(baz).
> 
> f(Arg) when Arg == foo; Arg == bar; Arg == baz ->
>      case Arg of
>          foo -> x();
>          _ -> y()
>      end.
> 
> That is you never actually call f/1 with foo and f/1 is not exported.

Ok, this should be it, except that I think the code is actually
executed. Thanks to your explanation, I finally managed to create
a module that reports the warning. It is based on the real module.

Thank you both for your helpful explanations; I am already looking
forward to more enlightenment to come :-)

Ladislav Lenart

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: dialyzer_test.erl
URL: 

From lenartlad@REDACTED  Thu May 29 10:20:32 2008
From: lenartlad@REDACTED (Ladislav Lenart)
Date: Thu, 29 May 2008 10:20:32 +0200
Subject: [erlang-questions] [Q] R12B on Windows
Message-ID: <483E6750.1090903@volny.cz>

Hello,

we recently migrated to OTP version R12B and now struggle with
Windows version of our product. The deployed application works
fine on Linux, but hangs on Windows consuming one CPU core forever.
Since the boot stuff is the same for both platforms, we are kind
of lost on what's the cause. But it has something to do with the
transition to R12B, because R11B version of our product worked
without problems on Windows (XP).

Any clues on what we might have missed would be greatly appreciated,

Ladislav Lenart



From archevis@REDACTED  Thu May 29 10:27:10 2008
From: archevis@REDACTED (John M. Nordgaard)
Date: Thu, 29 May 2008 10:27:10 +0200 (CEST)
Subject: [erlang-questions] Sending a message to all linked processes
Message-ID: <49434.85.164.199.66.1212049630.squirrel@www.cyber.no>

Hi all,

Been looking through the documentation in search of an answer, and have
not been able to locate one, so I hope I haven't missed the obvious
here... my Erlang mileage is still nothing to brag about. :-)

I was wondering if there is a simple and straightforward way to send a
message to all linked processes. Now, I am aware that a process exit
signal is transmitted in a functionally similar manner, so it seems that
at least some form of "broadcast to all linked processes" operation exists
within the runtime. But is it possible to invoke such functionality
directly from source code?

The reason I ask is that I'm doing some research on systems with a very
large number of highly autonomous agents, and would like to be able to
broadcast messages to all agents without the hassle of manual PID book
keeping.

All hints and suggestiong are greatly appreciated! :-)

- john.





From Lennart.Ohman@REDACTED  Thu May 29 10:50:12 2008
From: Lennart.Ohman@REDACTED (=?iso-8859-1?Q?Lennart_=D6hman?=)
Date: Thu, 29 May 2008 10:50:12 +0200
Subject: [erlang-questions] Sending a message to all linked processes
In-Reply-To: <49434.85.164.199.66.1212049630.squirrel@www.cyber.no>
References: <49434.85.164.199.66.1212049630.squirrel@www.cyber.no>
Message-ID: 

Hi John, as a note to the audience - the following is not something I would consider  good practice. But I do also appreciate that sometimes you face "difficult" situations where the better practice of "book keeping" is not possible.

Take a look at the BIF process_info. You can found out, among many things, to where a particular process has links.

Best Regards
Lennart


-------------------------------------------------------------------------------
Lennart ?hman                    phone: +46 8 587 623 27
Sj?land & Thyselius Telecom AB   cell : +46 70 552 6735
H?lsingegatan 43, 10th floor     fax  : +46 8 667 8230
SE-113 31 STOCKHOLM, SWEDEN      email: lennart.ohman@REDACTED
-----Original Message-----
From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of John M. Nordgaard
Sent: den 29 maj 2008 10:27
To: erlang-questions@REDACTED
Subject: [erlang-questions] Sending a message to all linked processes

Hi all,

Been looking through the documentation in search of an answer, and have not been able to locate one, so I hope I haven't missed the obvious here... my Erlang mileage is still nothing to brag about. :-)

I was wondering if there is a simple and straightforward way to send a message to all linked processes. Now, I am aware that a process exit signal is transmitted in a functionally similar manner, so it seems that at least some form of "broadcast to all linked processes" operation exists within the runtime. But is it possible to invoke such functionality directly from source code?

The reason I ask is that I'm doing some research on systems with a very large number of highly autonomous agents, and would like to be able to broadcast messages to all agents without the hassle of manual PID book keeping.

All hints and suggestiong are greatly appreciated! :-)

- john.



_______________________________________________
erlang-questions mailing list
erlang-questions@REDACTED
http://www.erlang.org/mailman/listinfo/erlang-questions


From kostis@REDACTED  Thu May 29 10:56:21 2008
From: kostis@REDACTED (Kostis Sagonas)
Date: Thu, 29 May 2008 11:56:21 +0300
Subject: [erlang-questions] [Q] dialyzer message: The pattern X can
 never match the type Y
In-Reply-To: <483E6356.3040804@volny.cz>
References: <483D774F.7070301@volny.cz> <483DB594.7010404@it.uu.se>
	<483E6356.3040804@volny.cz>
Message-ID: <483E6FB5.9030100@cs.ntua.gr>

Ladislav Lenart wrote:
> 
> Ok, this should be it, except that I think the code is actually
> executed. Thanks to your explanation, I finally managed to create
> a module that reports the warning. It is based on the real module.

Well, this was it.  If you look at your test/0 function, the only call 
to create_files/2 where the second argument is the 'yrl' tuple is:

     create_files(Path, {yrl, "f", rebuilt_mod_time}),

The clause:

create_files(Path, {yrl, Prefix, Type}) when Type == up_to_date; Type == 
rebuilt_no_exist; Type == rebuilt_mod_time ->
     [YrlName, ErlName] = [filename:join(Path, Prefix ++ Each) || Each 
<- [".yrl", ".erl"]],
     MakeName = filename:join(Path, "Xmakefile"),
     EmptyContent = "",
     MakeContent = "{yrl, \"*.yrl\", []}.",
     {Date, _Time} = erlang:localtime(),
     case Type of
	up_to_date ->		% ***
	    ....
     end,
     create_file(YrlName, EmptyContent, {Date, SourceTime}),
     case Type of
	rebuilt_no_exist ->	% ***
	    ....
     end,
     create_file(MakeName, MakeContent, leave),
     case Type of
	up_to_date ->		% ***
	    ....
     end;

contains a lot of redundant code in the lines shown with ***

This code cannot possibly execute and therefore you get the warnings:

dialyzer_test.erl:77: The pattern 'up_to_date' can never match the type 
'rebuilt_mod_time'
dialyzer_test.erl:86: The pattern 'rebuilt_no_exist' can never match the 
type 'rebuilt_mod_time'
dialyzer_test.erl:93: The pattern 'up_to_date' can never match the type 
'rebuilt_mod_time'


Kostis


From hayeah@REDACTED  Thu May 29 10:57:29 2008
From: hayeah@REDACTED (Howard Yeh)
Date: Thu, 29 May 2008 01:57:29 -0700
Subject: [erlang-questions] Serl 0.1 Release Announcement
Message-ID: 

Hi,

I've been hacking on a Lisp front end for Erlang during the past few
months. It might be worth a look if you like common-lisp.

Serl is a S-exp based frontend designed for Erlang. If you like
Scheme, you might want to try LFE, but if you like Common-Lisp and its
comparative hairyness, Serl might be for you.

Against Lisp's syntatic purity I have sinned. Serl's syntax is
inspired by Lisp, Erlang, and Ruby (thus transitively Perl (*gasp*)).
That Serl rhymes with Perl is perhaps more than an unfortunate
accident.

X => variable
{} => tuple
[] => list
foo => atom
## And the Perlish part,
(foo .if (test)) => (if (test) (foo))
(bar .cdr .car) => (car (cdr (bar)))


Serl is mostly implemented in itself. I've found, so far, that the
apparent syntatic complexity doesn't make metaprogramming with
Common-Lisp style macro any harder. The syntatic extensions are
designed such that they are pattern matchable, and that they are all
"list-like". So even though Serl looks a bit more complex, the macro
programmer still works primarily with lists.

Pattern matching is a godsent.


-support for aribtrary namespaces.
--import/export of macros and special forms.
--special forms are just macros that takes the compiling environment
as an extra argument. Serl defines itself with special forms.

-avoids unintentional capturing in similar way as common-lisp's package.

-Syntax objects.
--Quotation and quasiquotation are used only to build syntax objects.
-macroexpansion in pattern.
--so named patterns are possible.
-syntax objects are pattern matchable.

-fancy lambda-list as in common-lisp.
--but unlike common-lisp, &option, &rest, and &key don't interfere
with each other.

-syntatically consistent reader macro based on heredoc.

See:

http://forum.trapexit.org/viewtopic.php?p=43927

Howard
-- 
hayeah.wordpress.com
   --metacircular thinking


From tobias.lindahl@REDACTED  Thu May 29 10:58:39 2008
From: tobias.lindahl@REDACTED (Tobias Lindahl)
Date: Thu, 29 May 2008 10:58:39 +0200
Subject: [erlang-questions] [Q] dialyzer message: The pattern X can
 never match the type Y
In-Reply-To: <483E6356.3040804@volny.cz>
References: <483D774F.7070301@volny.cz> <483DB594.7010404@it.uu.se>
	<483E6356.3040804@volny.cz>
Message-ID: <483E703F.3070801@it.uu.se>

Ladislav,

Per is correct in his explanation, but I just wanted to clarify further 
that the warnings from Dialyzer is correct.

In your code you have only one call to the non-exported function 
create_files/2 where the second argument is tagged with 'yrl'

  ...
  create_files(Path, {yrl, "f", rebuilt_mod_time}),
  ...

Since the function is not exported, the information gets forwarded from 
the call site. In the function clause where this is matched, you then 
check the third position of the tuple in the second argument.

create_files(Path, {yrl, Prefix, Type}) when Type == up_to_date; Type == 
rebuilt_no_exist; Type == rebuilt_mod_time ->
  ...
  case Type of
     up_to_date ->
  ...
  case Type of
     rebuilt_no_exist ->
  ...
  case Type of
     up_to_date ->
  ....

The case clauses cannot match because the atom is always 
'rebuilt_mod_time' because of the call forwarding, and Dialyzer emits 
warnings about this.

Ladislav Lenart wrote:
> Ok, this should be it, except that I think the code is actually
> executed. Thanks to your explanation, I finally managed to create
> a module that reports the warning. It is based on the real module.

I hope it is now clear that the code in the case clauses never executes. 
In fact, we strive to have sound (i.e., never false) warnings from 
Dialyzer, so we are very interested in getting reports where the 
warnings are suspicious, either to clarify them or to fix the bugs that 
cause them.

Best regards,
Tobias


> 
> Thank you both for your helpful explanations; I am already looking
> forward to more enlightenment to come :-)
> 
> Ladislav Lenart
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions


From rvirding@REDACTED  Thu May 29 11:04:38 2008
From: rvirding@REDACTED (Robert Virding)
Date: Thu, 29 May 2008 11:04:38 +0200
Subject: [erlang-questions] Sending a message to all linked processes
In-Reply-To: <49434.85.164.199.66.1212049630.squirrel@www.cyber.no>
References: <49434.85.164.199.66.1212049630.squirrel@www.cyber.no>
Message-ID: <3dbc6d1c0805290204l2d4935e7jacf50f25bc0399ae@mail.gmail.com>

2008/5/29 John M. Nordgaard :

> Hi all,
>
> Been looking through the documentation in search of an answer, and have
> not been able to locate one, so I hope I haven't missed the obvious
> here... my Erlang mileage is still nothing to brag about. :-)
>
> I was wondering if there is a simple and straightforward way to send a
> message to all linked processes. Now, I am aware that a process exit
> signal is transmitted in a functionally similar manner, so it seems that
> at least some form of "broadcast to all linked processes" operation exists
> within the runtime. But is it possible to invoke such functionality
> directly from source code?


send_links(Message) ->
    {link,Links} = process_info(self(), links),
    lists:foreach(fun (P) -> P ! Message end, Links).

Robert
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From per.melin@REDACTED  Thu May 29 11:20:27 2008
From: per.melin@REDACTED (Per Melin)
Date: Thu, 29 May 2008 11:20:27 +0200
Subject: [erlang-questions] Twoorl: an open source Twitter clone
In-Reply-To: <17244f480805282238q79f294e5je25a8378c89c71f2@mail.gmail.com>
References: <17244f480805282212g32eaa0e1o78493087bd12fd0@mail.gmail.com>
	
	<17244f480805282238q79f294e5je25a8378c89c71f2@mail.gmail.com>
Message-ID: 

2008/5/29 Yariv Sadan :
> Facebook runs on MySQL -- that's pretty scalable :)

By Twitter's own account the database has been their bottleneck all along.

> The main reason I didn't go with Mnesia for storing most data is the
> dets issues discussed previously on this list (specifically, the long
> repair times and the need for fragmentation over 4gb). I use Mnesia
> for storing session data though.

I wouldn't go for Mnesia either. If you're building something that's
should possibly scale to the level of Twitter, the 2 GB limit just
doesn't cut it, with or without fragmentation. And in the tests I've
done DETS got very slow long before it hit the size limit. If you use
disc_copies (which doesn't use DETS) instead of disc_only_copies
you're of course instead limited by RAM.

I (like everyone else) have built a (web) chat service that I'll
probably (alpha) release this weekend. The single biggest problem I've
been wrestling with is how to persist the messages in an efficient
manner. Right now I'm using term_to_binary and dumping that in a flat
file (much like disk_log), which works for all my needs, except for
full text search. I'd prefer not to build and store my own reverse
index.


From lenartlad@REDACTED  Thu May 29 12:07:03 2008
From: lenartlad@REDACTED (Ladislav Lenart)
Date: Thu, 29 May 2008 12:07:03 +0200
Subject: [erlang-questions] [Q] dialyzer message: The pattern X can
 never match the type Y
In-Reply-To: <483E6FB5.9030100@cs.ntua.gr>
References: <483D774F.7070301@volny.cz>
	<483DB594.7010404@it.uu.se>	<483E6356.3040804@volny.cz>
	<483E6FB5.9030100@cs.ntua.gr>
Message-ID: <483E8047.6000806@volny.cz>

Kostis Sagonas wrote:
> Ladislav Lenart wrote:
>> Ok, this should be it, except that I think the code is actually
>> executed. Thanks to your explanation, I finally managed to create
>> a module that reports the warning. It is based on the real module.
> 
> Well, this was it.  If you look at your test/0 function, the only call 
> to create_files/2 where the second argument is the 'yrl' tuple is:
> 
>      create_files(Path, {yrl, "f", rebuilt_mod_time}),

Ok, now I finally get it. Thank you all. I somehow misinterpreted
the report to say that rebuilt_mod_time is never used (sorry for
the noise).

Ladislav Lenart




From gleber.p@REDACTED  Thu May 29 12:44:16 2008
From: gleber.p@REDACTED (Gleb Peregud)
Date: Thu, 29 May 2008 12:44:16 +0200
Subject: [erlang-questions] Twoorl: an open source Twitter clone
In-Reply-To: 
References: <17244f480805282212g32eaa0e1o78493087bd12fd0@mail.gmail.com>
	
	<17244f480805282238q79f294e5je25a8378c89c71f2@mail.gmail.com>
	
Message-ID: <14f0e3620805290344w390cc147xb42c17dd4fe64899@mail.gmail.com>

On Thu, May 29, 2008 at 11:20 AM, Per Melin  wrote:
> Right now I'm using term_to_binary and dumping that in a flat
> file (much like disk_log), which works for all my needs, except for
> full text search. I'd prefer not to build and store my own reverse
> index.

I'm interested in an example of the reverse index implementation,
'cause i'll need one in my bachelors thesis (written in Erlang :) )

P.S. Sorry, Per, for sending previously this mail exclusively to you.
-- 
Gleb Peregud
http://gleber.pl/

Every minute is to be grasped.
Time waits for nobody.
-- Inscription on a Zen Gong


From ulf.wiger@REDACTED  Thu May 29 13:02:55 2008
From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB))
Date: Thu, 29 May 2008 13:02:55 +0200
Subject: [erlang-questions] Twoorl: an open source Twitter clone
In-Reply-To: <14f0e3620805290344w390cc147xb42c17dd4fe64899@mail.gmail.com>
References: <17244f480805282212g32eaa0e1o78493087bd12fd0@mail.gmail.com>		<17244f480805282238q79f294e5je25a8378c89c71f2@mail.gmail.com>	
	<14f0e3620805290344w390cc147xb42c17dd4fe64899@mail.gmail.com>
Message-ID: <483E8D5F.1090105@ericsson.com>

Gleb Peregud skrev:
> On Thu, May 29, 2008 at 11:20 AM, Per Melin  wrote:
>> Right now I'm using term_to_binary and dumping that in a flat
>> file (much like disk_log), which works for all my needs, except for
>> full text search. I'd prefer not to build and store my own reverse
>> index.
> 
> I'm interested in an example of the reverse index implementation,
> 'cause i'll need one in my bachelors thesis (written in Erlang :) )

For full-text search, you could peek at the rdbms_wsearch*.erl
modules in

http://jungerl.cvs.sourceforge.net/jungerl/jungerl/lib/rdbms/src/

They have not been integrated into rdbms, so they're mainly
there for future use.

The code implements full text searching using Porter's
stemming algorithm, courtesy Hans Nilsson.

BR,
Ulf W


From kevin@REDACTED  Thu May 29 13:09:20 2008
From: kevin@REDACTED (Kevin A. Smith)
Date: Thu, 29 May 2008 07:09:20 -0400
Subject: [erlang-questions] Ann: Erlang By Example
Message-ID: <6EE3D5D7-DFD6-4E53-B16A-D736C6256FDE@hypotheticalabs.com>

The Pragmatic Programmers, publishers of Joe's "Programming Erlang",  
have started offering screencasts covering a range of subjects  
available here:

http://www.pragprog.com/screencasts

I'm producing an introductory series on Erlang as part of this effort:

http://www.pragprog.com/screencasts/v-kserl/erlang-by-example

The series is targeted at experienced developers who are new to  
Erlang. The subjects covered so far are standard Erlang fare --  
message passing, pattern matching, and inter-node communication -- but  
I have plans to cover more advanced topics like mnesia and OTP in the  
coming episodes.

--Kevin


From saleyn@REDACTED  Thu May 29 13:25:22 2008
From: saleyn@REDACTED (Serge Aleynikov)
Date: Thu, 29 May 2008 07:25:22 -0400
Subject: [erlang-questions] gen_sctp multi-homing
In-Reply-To: 
References: 
Message-ID: <483E92A2.9040606@gmail.com>

You can call gen_sctp:connect/4 multiple times.  Note that this call 
doesn't create new sockets but establishes a new association on a given 
socket.

Serge

Mikael Lixenstrand wrote:
> I have some questions regarding gen_sctp and multihoming. It?s possible to
> create a socket to multiple local peers but i haven't figured out how to
> connect a socket to multiple IPs on another host.
> 
> Is this possible with gen_sctp or would i need to implement something using
> more sockets?
> I would like to have one socket with multiple associations, one for each
> peer on remote host.
> 
> /mikael
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions



From kevin@REDACTED  Thu May 29 14:57:30 2008
From: kevin@REDACTED (Kevin A. Smith)
Date: Thu, 29 May 2008 08:57:30 -0400
Subject: [erlang-questions] Flymake & include_lib
Message-ID: <97FC8F79-3215-4444-933A-6A93A1682EFF@hypotheticalabs.com>

I've been using flymake for a while now, really loving it BTW, but  
I've got a problem which is starting to drive me to distraction.

When I'm working on code with the typical OTP app directory structure  
(ebin, priv, include, src, etc) flymake errors trying to locate .hrl  
files when I include them thusly:

-include_lib("foo.hrl").

Flymake claims to not be able to find the file "foo.hrl" and so any  
code which uses the records defined in that file are also flagged as  
errors.

I'm certain there's a problem with the eflymake script I've been using  
to compile Erlang source but I can't seem to figure it out. It's  
probably just come path tweaking but I'm at a loss as to what I'm  
missing.

I've attached the compile script I'm using. I'd appreciate any  
pointers as to what the problem might be.

Thanks,
Kevin


-------------- next part --------------
A non-text attachment was scrubbed...
Name: eflymake
Type: application/octet-stream
Size: 253 bytes
Desc: not available
URL: 
-------------- next part --------------


From chandrashekhar.mullaparthi@REDACTED  Thu May 29 15:17:01 2008
From: chandrashekhar.mullaparthi@REDACTED (Chandru)
Date: Thu, 29 May 2008 14:17:01 +0100
Subject: [erlang-questions] Flymake & include_lib
In-Reply-To: <97FC8F79-3215-4444-933A-6A93A1682EFF@hypotheticalabs.com>
References: <97FC8F79-3215-4444-933A-6A93A1682EFF@hypotheticalabs.com>
Message-ID: 

2008/5/29 Kevin A. Smith :

> I've been using flymake for a while now, really loving it BTW, but I've got
> a problem which is starting to drive me to distraction.
>
> When I'm working on code with the typical OTP app directory structure
> (ebin, priv, include, src, etc) flymake errors trying to locate .hrl files
> when I include them thusly:
>
> -include_lib("foo.hrl").
>


I have no idea what Flymake is, but when using include_lib, you have to use
it thusly:

-include_lib("my_app/include/my_file.hrl").
-include_lib("my_app/any_directory/any_file.hrl").

I hope this helps.

cheers
Chandru
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From buricchio@REDACTED  Thu May 29 15:44:45 2008
From: buricchio@REDACTED (andrey-google)
Date: Thu, 29 May 2008 16:44:45 +0300
Subject: [erlang-questions] Flymake & include_lib
In-Reply-To: <97FC8F79-3215-4444-933A-6A93A1682EFF@hypotheticalabs.com>
References: <97FC8F79-3215-4444-933A-6A93A1682EFF@hypotheticalabs.com>
Message-ID: <1567789778.20080529164445@gmail.com>

Perhaps, you have script for flymake wih something like that:

...
compile:file(File_Name,[warn_obsolete_guard, ...])
...

where [warn_obsolete_guard, ...] is a list of compile options.

Then you may add the option {i,"/myproj/include/"}, where "/my/include/" is
your custom include directory:
...
compile:file(File_Name,[warn_obsolete_guard, {i,"/myproj/include/"}, ...])
...

> I've been using flymake for a while now, really loving it BTW, but  
> I've got a problem which is starting to drive me to distraction.

> When I'm working on code with the typical OTP app directory structure
> (ebin, priv, include, src, etc) flymake errors trying to locate .hrl
> files when I include them thusly:

> -include_lib("foo.hrl").

> Flymake claims to not be able to find the file "foo.hrl" and so any
> code which uses the records defined in that file are also flagged as
> errors.

> I'm certain there's a problem with the eflymake script I've been using
> to compile Erlang source but I can't seem to figure it out. It's  
> probably just come path tweaking but I'm at a loss as to what I'm  
> missing.

> I've attached the compile script I'm using. I'd appreciate any  
> pointers as to what the problem might be.

> Thanks,
> Kevin





-- 
Best regards,
 andrey-google                            mailto:buricchio@REDACTED



From kevin@REDACTED  Thu May 29 15:23:48 2008
From: kevin@REDACTED (Kevin A. Smith)
Date: Thu, 29 May 2008 09:23:48 -0400
Subject: [erlang-questions] Flymake & include_lib
In-Reply-To: 
References: <97FC8F79-3215-4444-933A-6A93A1682EFF@hypotheticalabs.com>
	
Message-ID: <6E4387D3-6AD7-41D4-9568-FE5CFD892C7B@hypotheticalabs.com>


On May 29, 2008, at 9:17 AM, Chandru wrote:

>
>
> 2008/5/29 Kevin A. Smith :
> I've been using flymake for a while now, really loving it BTW, but  
> I've got a problem which is starting to drive me to distraction.
>
> When I'm working on code with the typical OTP app directory  
> structure (ebin, priv, include, src, etc) flymake errors trying to  
> locate .hrl files when I include them thusly:
>
> -include_lib("foo.hrl").
>
>
> I have no idea what Flymake is, but when using include_lib, you have  
> to use it thusly:
>
> -include_lib("my_app/include/my_file.hrl").
> -include_lib("my_app/any_directory/any_file.hrl").
>
> I hope this helps.

Hrm. I feel dumb for missing this. Thanks!

--Kevin
>
>
> cheers
> Chandru



From erlang@REDACTED  Thu May 29 16:19:40 2008
From: erlang@REDACTED (Joe Armstrong)
Date: Thu, 29 May 2008 16:19:40 +0200
Subject: [erlang-questions] Twoorl: an open source Twitter clone
In-Reply-To: <17244f480805282339k16442ddo2f48aa66c5f06f7d@mail.gmail.com>
References: <17244f480805282212g32eaa0e1o78493087bd12fd0@mail.gmail.com>
	
	<17244f480805282238q79f294e5je25a8378c89c71f2@mail.gmail.com>
	<97619b170805282255k67d080dbhe7c8d8b8c431377b@mail.gmail.com>
	<17244f480805282339k16442ddo2f48aa66c5f06f7d@mail.gmail.com>
Message-ID: <9b08084c0805290719n793e210bhdff9cbaf2a53f494@mail.gmail.com>

How about a using a 2-3 node ram replicated Mnesia as a front-end
cache with MySQL as a backend
store?

Add a time to live argument to all data and flush the cache to the
backend in idle time.

Adjust the time to live so as to keep the cache a reasonable size.

Best of both worlds.

/Joe


On Thu, May 29, 2008 at 8:39 AM, Yariv Sadan  wrote:
> I've been using MySQL for Vimagi (http://vimagi.com) and haven't had
> any problems. ErlyDB makes working with MySQL very easy -- just as
> easy as Mnesia (if not easier in some cases) in terms of APIs. The
> main reasons I went with MySQL are that I didn't want to deal with
> fragmentation and dets repair times (yes, I know it wouldn't really
> affect an app such as Twoorl, but I've already gotten into the mindset
> of avoiding dets).
>
> I actually wouldn't mind offering Mnesia as an alternate data store if
> someone wants to implement it :)
>
> Yariv
>
> 2008/5/28 Rapsey :
>> Are the repair times really that much of a problem? It's not like servers or
>> erlang runtime crash that often.
>> I would think the advantages of using mnesia far outweight the
>> disadvantages. Mnesia is much easier to scale and work with than mysql.
>>
>>
>> Sergej
>>
>>
>> On Thu, May 29, 2008 at 7:38 AM, Yariv Sadan  wrote:
>>>
>>> Facebook runs on MySQL -- that's pretty scalable :)
>>>
>>> The main reason I didn't go with Mnesia for storing most data is the
>>> dets issues discussed previously on this list (specifically, the long
>>> repair times and the need for fragmentation over 4gb). I use Mnesia
>>> for storing session data though.
>>>
>>> Yariv
>>>
>>> On Wed, May 28, 2008 at 10:26 PM, Nick Gerakines 
>>> wrote:
>>> > MySQL? Seriously?
>>> >
>>> > I've heard from multiple sources database congestion is a major source
>>> > of scaling problems for websites. Why take MySQL over a fragmented
>>> > mnesia store or a set of hybrid services?
>>> >
>>> > # Nick Gerakines
>>> >
>>> > On Wed, May 28, 2008 at 10:12 PM, Yariv Sadan 
>>> > wrote:
>>> >> Hi,
>>> >>
>>> >> I created an open source Twitter clone in Erlang called Twoorl. I
>>> >> wrote it on top of ErlyWeb/Yaws.  You can see it at http://twoorl.com.
>>> >> The code is at http://code.google.com/p/twoorl.
>>> >>
>>> >> I'll appreciate any feedback!
>>> >>
>>> >> Thanks,
>>> >> Yariv
>>> >> _______________________________________________
>>> >> erlang-questions mailing list
>>> >> erlang-questions@REDACTED
>>> >> http://www.erlang.org/mailman/listinfo/erlang-questions
>>> >>
>>> >
>>> _______________________________________________
>>> erlang-questions mailing list
>>> erlang-questions@REDACTED
>>> http://www.erlang.org/mailman/listinfo/erlang-questions
>>
>>
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://www.erlang.org/mailman/listinfo/erlang-questions
>>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>


From kevin@REDACTED  Thu May 29 15:47:55 2008
From: kevin@REDACTED (Kevin A. Smith)
Date: Thu, 29 May 2008 09:47:55 -0400
Subject: [erlang-questions] Flymake & include_lib
In-Reply-To: <1567789778.20080529164445@gmail.com>
References: <97FC8F79-3215-4444-933A-6A93A1682EFF@hypotheticalabs.com>
	<1567789778.20080529164445@gmail.com>
Message-ID: 

The final fix was a variation on your suggestion and Chandru's:

1) I fixed my includes to use the correct pathing

2) I added a {i, "/path/to/my/code/dir"} option to the call to  
compile:file

Between the two of those, it seems to be fixed.

Thanks,
Kevin
On May 29, 2008, at 9:44 AM, andrey-google wrote:

> Perhaps, you have script for flymake wih something like that:
>
> ...
> compile:file(File_Name,[warn_obsolete_guard, ...])
> ...
>
> where [warn_obsolete_guard, ...] is a list of compile options.
>
> Then you may add the option {i,"/myproj/include/"}, where "/my/ 
> include/" is
> your custom include directory:
> ...
> compile:file(File_Name,[warn_obsolete_guard, {i,"/myproj/ 
> include/"}, ...])
> ...
>
>> I've been using flymake for a while now, really loving it BTW, but
>> I've got a problem which is starting to drive me to distraction.
>
>> When I'm working on code with the typical OTP app directory structure
>> (ebin, priv, include, src, etc) flymake errors trying to locate .hrl
>> files when I include them thusly:
>
>> -include_lib("foo.hrl").
>
>> Flymake claims to not be able to find the file "foo.hrl" and so any
>> code which uses the records defined in that file are also flagged as
>> errors.
>
>> I'm certain there's a problem with the eflymake script I've been  
>> using
>> to compile Erlang source but I can't seem to figure it out. It's
>> probably just come path tweaking but I'm at a loss as to what I'm
>> missing.
>
>> I've attached the compile script I'm using. I'd appreciate any
>> pointers as to what the problem might be.
>
>> Thanks,
>> Kevin
>
>
>
>
>
> -- 
> Best regards,
> andrey-google                            mailto:buricchio@REDACTED
>



From alexander.lamb@REDACTED  Thu May 29 16:43:45 2008
From: alexander.lamb@REDACTED (Alexander Lamb)
Date: Thu, 29 May 2008 16:43:45 +0200
Subject: [erlang-questions] R12B-0 problem on last MacOSX update
Message-ID: <89411490-7B45-4416-965B-835DAAF916BB@rodanotech.ch>

Hello List,

Just to share something:

I had R12B-0 on my MacBook Pro. I installed the latest MacOSX 10.5.3  
update. Following the update, I systematically had a bus error  
starting the Erlang shell.

So I didn't search longer, I installed R12B-2

R12B-0 had been installed using Macports.  There is no Macport for  
release 2. Macport install under /opt/local

So I dowloaded R12B-2, modified the configure file to install under / 
opt/local and the install went without trouble. Now everything is back  
up and running.

Alex


From vlm@REDACTED  Thu May 29 16:50:27 2008
From: vlm@REDACTED (Lev Walkin)
Date: Thu, 29 May 2008 07:50:27 -0700
Subject: [erlang-questions] Twoorl: an open source Twitter clone
In-Reply-To: <9b08084c0805290719n793e210bhdff9cbaf2a53f494@mail.gmail.com>
References: <17244f480805282212g32eaa0e1o78493087bd12fd0@mail.gmail.com>		<17244f480805282238q79f294e5je25a8378c89c71f2@mail.gmail.com>	<97619b170805282255k67d080dbhe7c8d8b8c431377b@mail.gmail.com>	<17244f480805282339k16442ddo2f48aa66c5f06f7d@mail.gmail.com>
	<9b08084c0805290719n793e210bhdff9cbaf2a53f494@mail.gmail.com>
Message-ID: <483EC2B3.5040904@lionet.info>

Joe Armstrong wrote:
> How about a using a 2-3 node ram replicated Mnesia as a front-end
> cache with MySQL as a backend
> store?
> 
> Add a time to live argument to all data and flush the cache to the
> backend in idle time.
> 
> Adjust the time to live so as to keep the cache a reasonable size.

This is the hardest part. It is easier to interface with memcached,
or several, at this point. You can even have more than 4g cached
in memory with several memcached and PAE on a single machine.

> Best of both worlds.
> 
> /Joe
> 
> 
> On Thu, May 29, 2008 at 8:39 AM, Yariv Sadan  wrote:
>> I've been using MySQL for Vimagi (http://vimagi.com) and haven't had
>> any problems. ErlyDB makes working with MySQL very easy -- just as
>> easy as Mnesia (if not easier in some cases) in terms of APIs. The
>> main reasons I went with MySQL are that I didn't want to deal with
>> fragmentation and dets repair times (yes, I know it wouldn't really
>> affect an app such as Twoorl, but I've already gotten into the mindset
>> of avoiding dets).
>>
>> I actually wouldn't mind offering Mnesia as an alternate data store if
>> someone wants to implement it :)
>>
>> Yariv
>>
>> 2008/5/28 Rapsey :
>>> Are the repair times really that much of a problem? It's not like servers or
>>> erlang runtime crash that often.
>>> I would think the advantages of using mnesia far outweight the
>>> disadvantages. Mnesia is much easier to scale and work with than mysql.
>>>
>>>
>>> Sergej
>>>
>>>
>>> On Thu, May 29, 2008 at 7:38 AM, Yariv Sadan  wrote:
>>>> Facebook runs on MySQL -- that's pretty scalable :)
>>>>
>>>> The main reason I didn't go with Mnesia for storing most data is the
>>>> dets issues discussed previously on this list (specifically, the long
>>>> repair times and the need for fragmentation over 4gb). I use Mnesia
>>>> for storing session data though.
>>>>
>>>> Yariv
>>>>
>>>> On Wed, May 28, 2008 at 10:26 PM, Nick Gerakines 
>>>> wrote:
>>>>> MySQL? Seriously?
>>>>>
>>>>> I've heard from multiple sources database congestion is a major source
>>>>> of scaling problems for websites. Why take MySQL over a fragmented
>>>>> mnesia store or a set of hybrid services?
>>>>>
>>>>> # Nick Gerakines
>>>>>
>>>>> On Wed, May 28, 2008 at 10:12 PM, Yariv Sadan 
>>>>> wrote:
>>>>>> Hi,
>>>>>>
>>>>>> I created an open source Twitter clone in Erlang called Twoorl. I
>>>>>> wrote it on top of ErlyWeb/Yaws.  You can see it at http://twoorl.com.
>>>>>> The code is at http://code.google.com/p/twoorl.
>>>>>>
>>>>>> I'll appreciate any feedback!
>>>>>>
>>>>>> Thanks,
>>>>>> Yariv
>>>>>> _______________________________________________
>>>>>> erlang-questions mailing list
>>>>>> erlang-questions@REDACTED
>>>>>> http://www.erlang.org/mailman/listinfo/erlang-questions
>>>>>>
>>>> _______________________________________________
>>>> erlang-questions mailing list
>>>> erlang-questions@REDACTED
>>>> http://www.erlang.org/mailman/listinfo/erlang-questions
>>>
>>> _______________________________________________
>>> erlang-questions mailing list
>>> erlang-questions@REDACTED
>>> http://www.erlang.org/mailman/listinfo/erlang-questions
>>>
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://www.erlang.org/mailman/listinfo/erlang-questions
>>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions



From thehcdreamer@REDACTED  Thu May 29 16:54:50 2008
From: thehcdreamer@REDACTED (Oscar Del Ben)
Date: Thu, 29 May 2008 16:54:50 +0200
Subject: [erlang-questions] R12B-0 problem on last MacOSX update
In-Reply-To: <89411490-7B45-4416-965B-835DAAF916BB@rodanotech.ch>
References: <89411490-7B45-4416-965B-835DAAF916BB@rodanotech.ch>
Message-ID: 

Hope we will see the R12B-2 in mac ports asap

2008/5/29, Alexander Lamb :
>
> Hello List,
>
> Just to share something:
>
> I had R12B-0 on my MacBook Pro. I installed the latest MacOSX 10.5.3
> update. Following the update, I systematically had a bus error
> starting the Erlang shell.
>
> So I didn't search longer, I installed R12B-2
>
> R12B-0 had been installed using Macports.  There is no Macport for
> release 2. Macport install under /opt/local
>
> So I dowloaded R12B-2, modified the configure file to install under /
> opt/local and the install went without trouble. Now everything is back
> up and running.
>
> Alex
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From mikael@REDACTED  Thu May 29 16:58:25 2008
From: mikael@REDACTED (Mikael Lixenstrand)
Date: Thu, 29 May 2008 16:58:25 +0200
Subject: [erlang-questions] gen_sctp multi-homing
In-Reply-To: <483E92A2.9040606@gmail.com>
References: 
	<483E92A2.9040606@gmail.com>
Message-ID: 

I try this but get Error Reason: eisconn (The socket is already connected.)

Could i have done anything else wrong?

gen_sctp:open(lists:merge(IP,?sctp_client_options)) of
    {ok, Socket} ->
        AssocList = lists:foldl(fun(IP, AccList) ->
            case gen_sctp:connect(Socket, IP, Port,[],
?sctp_connect_timeout) of
                {ok, Assoc} ->
                    [Assoc | AccList];
                {error, Reason} ->
                    AccList
            end
        end, [], IPList),

thanks for the help



2008/5/29, Serge Aleynikov :
>
> You can call gen_sctp:connect/4 multiple times.  Note that this call
> doesn't create new sockets but establishes a new association on a given
> socket.
>
> Serge
>
> Mikael Lixenstrand wrote:
>
>> I have some questions regarding gen_sctp and multihoming. It?s possible to
>> create a socket to multiple local peers but i haven't figured out how to
>> connect a socket to multiple IPs on another host.
>>
>> Is this possible with gen_sctp or would i need to implement something
>> using
>> more sockets?
>> I would like to have one socket with multiple associations, one for each
>> peer on remote host.
>>
>> /mikael
>>
>>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://www.erlang.org/mailman/listinfo/erlang-questions
>>
>
>


-- 
****************************
  Mikael Lixenstrand
  Sl?ttadammsgatan 9 a 12
  417 27 G?teborg
  mob   : 0707 593809
  icq   :169264851
  msn: lixen@REDACTED
****************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From mog-lists@REDACTED  Thu May 29 17:08:02 2008
From: mog-lists@REDACTED (mog)
Date: Thu, 29 May 2008 10:08:02 -0500
Subject: [erlang-questions] Flymake & include_lib
In-Reply-To: <1567789778.20080529164445@gmail.com>
References: <97FC8F79-3215-4444-933A-6A93A1682EFF@hypotheticalabs.com>
	<1567789778.20080529164445@gmail.com>
Message-ID: <483EC6D2.1080101@rldn.net>

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

You could do what i do in my eflymake script
main([File_Name]) ->
    compile:file(File_Name, [{i, "../include"}, warn_obsolete_guard,
warn_unused_import, warn_shadow_vars, warn_export_vars,
strong_validation, report]).

As that will get the include correctly if you build correctly anywhere
you do the
app/
    src/
    include/

format. hope that helps

Mog
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFIPsbReq+tARrxhnsRAh9BAJ9Z1XOWppV3Yy6IMSPXX79xTAaj5gCeN/Kh
1FCCp6kHFP120fTs4N8Nm8I=
=Z3fx
-----END PGP SIGNATURE-----



From jkglenn@REDACTED  Thu May 29 16:58:43 2008
From: jkglenn@REDACTED (Jacob Glenn)
Date: Thu, 29 May 2008 10:58:43 -0400
Subject: [erlang-questions] R12B-0 problem on last MacOSX update
In-Reply-To: 
Message-ID: 

http://git.erlang.geek.nz/?p=nemports.git;a=summary

On 5/29/08 10:54 AM, "Oscar Del Ben"  wrote:

> Hope we will see the R12B-2 in mac ports asap
> 
> 2008/5/29, Alexander Lamb :
>> Hello List,
>>  
>>  Just to share something:
>>  
>>  I had R12B-0 on my MacBook Pro. I installed the latest MacOSX 10.5.3
>>  update. Following the update, I systematically had a bus error
>>  starting the Erlang shell.
>>  
>>  So I didn't search longer, I installed R12B-2
>>  
>>  R12B-0 had been installed using Macports.  There is no Macport for
>>  release 2. Macport install under /opt/local
>>  
>>  So I dowloaded R12B-2, modified the configure file to install under /
>>  opt/local and the install went without trouble. Now everything is back
>>  up and running.
>>  
>>  Alex
>>  _______________________________________________
>>  erlang-questions mailing list
>>  erlang-questions@REDACTED
>>  http://www.erlang.org/mailman/listinfo/erlang-questions
>>  
>> 
> 
> 
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions


-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From twoggle@REDACTED  Thu May 29 17:59:57 2008
From: twoggle@REDACTED (Tim Fletcher)
Date: Thu, 29 May 2008 08:59:57 -0700 (PDT)
Subject: [erlang-questions] Twoorl: an open source Twitter clone
In-Reply-To: <483EC2B3.5040904@lionet.info>
References: <17244f480805282212g32eaa0e1o78493087bd12fd0@mail.gmail.com> 
	 
	<17244f480805282238q79f294e5je25a8378c89c71f2@mail.gmail.com> 
	<97619b170805282255k67d080dbhe7c8d8b8c431377b@mail.gmail.com> 
	<17244f480805282339k16442ddo2f48aa66c5f06f7d@mail.gmail.com> 
	<9b08084c0805290719n793e210bhdff9cbaf2a53f494@mail.gmail.com> 
	<483EC2B3.5040904@lionet.info>
Message-ID: 

> This is the hardest part. It is easier to interface with memcached,
> or several, at this point. You can even have more than 4g cached
> in memory with several memcached and PAE on a single machine.

If it helps, I have an Erlang Memcache client half written.


From gleber.p@REDACTED  Thu May 29 18:12:30 2008
From: gleber.p@REDACTED (Gleb Peregud)
Date: Thu, 29 May 2008 18:12:30 +0200
Subject: [erlang-questions] Twoorl: an open source Twitter clone
In-Reply-To: 
References: <17244f480805282212g32eaa0e1o78493087bd12fd0@mail.gmail.com>
	
	<17244f480805282238q79f294e5je25a8378c89c71f2@mail.gmail.com>
	<97619b170805282255k67d080dbhe7c8d8b8c431377b@mail.gmail.com>
	<17244f480805282339k16442ddo2f48aa66c5f06f7d@mail.gmail.com>
	<9b08084c0805290719n793e210bhdff9cbaf2a53f494@mail.gmail.com>
	<483EC2B3.5040904@lionet.info>
	
Message-ID: <14f0e3620805290912x2444dd6eh8450654f8b141fd9@mail.gmail.com>

On Thu, May 29, 2008 at 5:59 PM, Tim Fletcher  wrote:
> If it helps, I have an Erlang Memcache client half written.

There is one ready in Cacherl project (supports get, set and delete):
http://code.google.com/p/cacherl/source/browse/trunk/memcached/src/memcached_client.erl

Feel free to use it and expand it (vide. replace command ;) )

-- 
Gleb Peregud
http://gleber.pl/

Every minute is to be grasped.
Time waits for nobody.
-- Inscription on a Zen Gong


From anders.nygren@REDACTED  Thu May 29 18:26:12 2008
From: anders.nygren@REDACTED (Anders Nygren)
Date: Thu, 29 May 2008 11:26:12 -0500
Subject: [erlang-questions] Flymake & include_lib
In-Reply-To: <483EC6D2.1080101@rldn.net>
References: <97FC8F79-3215-4444-933A-6A93A1682EFF@hypotheticalabs.com>
	<1567789778.20080529164445@gmail.com> <483EC6D2.1080101@rldn.net>
Message-ID: 

On Thu, May 29, 2008 at 10:08 AM, mog  wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> You could do what i do in my eflymake script
> main([File_Name]) ->
>    compile:file(File_Name, [{i, "../include"}, warn_obsolete_guard,
> warn_unused_import, warn_shadow_vars, warn_export_vars,
> strong_validation, report]).
>
> As that will get the include correctly if you build correctly anywhere
> you do the
> app/
>    src/
>    include/
>
> format. hope that helps

Or to go one step further

main([File_Name]) ->
   Incls = [{i,Dir} || Dir <- filelib:wildcard("../../*/include")],
   compile:file(File_Name, Incls++[warn_obsolete_guard,
                            warn_unused_import,
                            warn_shadow_vars,
                            warn_export_vars,
                            strong_validation,
                            report]).

in case you have a structure like
lib/
    app1/
         src/
         include/
    app2/
         src/
         include/

And have includes between applications

/Anders

>
> Mog
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.6 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQFIPsbReq+tARrxhnsRAh9BAJ9Z1XOWppV3Yy6IMSPXX79xTAaj5gCeN/Kh
> 1FCCp6kHFP120fTs4N8Nm8I=
> =Z3fx
> -----END PGP SIGNATURE-----
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>


From fritchie@REDACTED  Thu May 29 19:42:12 2008
From: fritchie@REDACTED (Scott Lystig Fritchie)
Date: Thu, 29 May 2008 12:42:12 -0500
Subject: [erlang-questions] Relocating Erlang installation on Windows?
In-Reply-To: Message of "Wed, 21 May 2008 20:42:14 +0200."
	<351ce2d70805211142v3ad7df8fj127ab5c2fc08261a@mail.gmail.com> 
Message-ID: <52482.1212082932@snookles.snookles.com>

Johan Holmberg  wrote:

jh> I wonder if there is some way of getting the installation "position
jh> independent"?

Not that I'm aware of.  (I'm just catching up on my mailing list reading
and noticed that no one (?) has replied to your query.)

We use a shell script to relocate builds of R11B-5 on Linux, which is
included below.  It mostly works, but since we don't use "escript" and
some of the other scripts, I don't know if it does 100% the right thing
with all the scripts.  It also doesn't do anything with Windows-only
files.  Hope it helps.

-Scott

--- snip --- snip --- snip --- snip --- snip --- snip --- 

#!/bin/sh

##
## For copying when configured via:
## ./configure --prefix=/some/place/that/is/not/the/final/installation/dir
##

TAR_DEL_ARG=""
if [ "X$1" = "X-d" ]; then
	shift
	TAR_DEL_ARG="--remove-files"
fi

if [ $# -ne 3 ]; then
	echo usage: $0 [-d] src-dir dst-dir path-dir
	echo example: $0 /usr/local/gemini/erlang /new/dir /new/dir
	echo "NOTE: In most cases, dst-dir and path-dir will be the same."
	echo "      However, in some weird NFS cases, the dst-dir (where"
	echo "      this script will copy files) may be different from"
	echo "      path-dir (where final users will use/execute files)."
	echo NOTE: Both directories should be absolute paths.
	exit 1
fi

SRCDIR=$1
DSTDIR=$2
NEW_ROOTDIR=$3/lib/erlang

if [ ! -d $SRCDIR ]; then
	echo "Source directory $SRCDIR does not exist, aborting!"
	exit 1
fi
if [ ! -d $DSTDIR ]; then
	echo "Destination directory $DSTDIR does not exist, creating"
	mkdir $DSTDIR
	if [ $? -ne 0 ]; then
		echo "mkdir $DSTDIR failed, aborting!"
		exit 1
	fi
fi

echo -n "Copying files from $SRCDIR to $DSTDIR ... "
(cd $SRCDIR ; tar cf - $TAR_DEL_ARG .) | (cd $DSTDIR ; tar xfp -)
echo "done."

echo -n "Performing relocation steps ... "

cd $DSTDIR/bin
for f in dialyzer epmd erl erlc escript run_erl start to_erl typer
do
	if [ -h $f ]; then
		rm -f $f
		# Use wildcard to be Erlang-version-flexible (hopefully)
		ln -s ../lib/erlang/erts-*/bin/$f ./$f
	fi
done

cd ../lib/erlang/erts-*/bin
for f in erl start start_erl
do
	perl -np -e "s|%FINAL_ROOTDIR%|$NEW_ROOTDIR|" < $f.src > $f
	if [ -f $DSTDIR/lib/erlang/bin/$f ] ; then
		cp $f $DSTDIR/lib/erlang/bin/$f
	fi
done
echo "done."

cd $DSTDIR/lib/erlang/bin
rm epmd
ln -s ../erts-*/bin/epmd ./epmd

echo ""
echo "To use the new runtime environment, add the following directory"
echo "to your shell's PATH variable:"
echo ""
echo "	$DSTDIR/bin"
echo ""

exit 0


From 0x6e6562@REDACTED  Thu May 29 21:20:26 2008
From: 0x6e6562@REDACTED (Ben Hood)
Date: Thu, 29 May 2008 20:20:26 +0100
Subject: [erlang-questions] Leex - a lexical anaylzer generator, released
In-Reply-To: <3dbc6d1c0805271656l2fb4ca0fyb13d1ac7f2d10f24@mail.gmail.com>
References: <3dbc6d1c0805240839k24b5a91cq71346591fe0faed8@mail.gmail.com>
	<0E07146E-57CA-47A1-9DD6-856DC2B7B477@gmail.com>
	<3dbc6d1c0805271656l2fb4ca0fyb13d1ac7f2d10f24@mail.gmail.com>
Message-ID: <9924E672-5F09-4BA6-94D4-103F99894222@gmail.com>

Robert,

On 28 May 2008, at 00:56, Robert Virding wrote:
> Do you have a example that demonstrates glue code to create the  
> lexer and parser and then interpret a stream using the current code  
> base?
>
> That was it. You can check lfe_io.erl in the LFE and look at the  
> parse_file/1 and read_file/1 functions. I use my own parser as I  
> need it to return remaining tokens so I can read one sexpr at a  
> time. Yecc will not do this, although it wouldn't be difficult to  
> get to do it. :-(
>
> I will try to write a Rationale which describes the io system, and  
> other core features, in more detail and how it all hangs together.
>
> I hope that helped a little. Maybe others could point you to more  
> code using leex and parsers.

Thanks for your help. I've now gotten on top of leex and yecc to be  
able to solve my problem.

I wrote a general article about using leex and yecc, to maybe help  
other newcomers: http://hopper.squarespace.com/blog/2008/5/29/leex-and-yecc.html

HTH,

Ben




From stonecypher@REDACTED  Thu May 29 21:35:00 2008
From: stonecypher@REDACTED (John Haugeland)
Date: Thu, 29 May 2008 13:35:00 -0600
Subject: [erlang-questions] Sending a message to all linked processes
Message-ID: <8f24f4b10805291235r4350e83ey799ff8937735dfb5@mail.gmail.com>

> I was wondering if there is a simple and straightforward way to send a
> message to all linked processes. Now, I am aware that a process exit signal
> is transmitted in a functionally similar manner, so it seems that at least
> some form of "broadcast to all linked processes" operation exists within the
> runtime. But is it possible to invoke such functionality directly from
> source code?
>

There may be a better way, but here's how I do it:

get_linked_processes() -> [U] = [V||{links,V}<-process_info(self())], U.

[ LP ! message || LP <- get_linked_processes() ].

I suspect that process_info() isn't particularly cheap, so I recommend
reconsidering the bookkeeping.

  - John

---
GuaranteedVPS.com - bandwidth commitments and root starting from $12.98/mo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From zambal@REDACTED  Thu May 29 21:59:17 2008
From: zambal@REDACTED (zambal)
Date: Thu, 29 May 2008 12:59:17 -0700 (PDT)
Subject: [erlang-questions] LFE syntax,
	was Leex - a lexical anaylzer generator, released
In-Reply-To: <3dbc6d1c0805271614v531c65f5p8170ecfb72d1ee61@mail.gmail.com>
References: <3dbc6d1c0805271614v531c65f5p8170ecfb72d1ee61@mail.gmail.com>
Message-ID: <0210eeb4-c035-4e7a-bf3a-f96d046fca2a@l64g2000hse.googlegroups.com>

On May 28, 1:14?am, "Robert Virding"  wrote:
> ... At present macros are not exported, the only solution today is to put them
> in a separate file and include them with (include-file ...). You can also
> slurp them into the shell. This is pretty much like you do in Erlang today.
> It wouldn't be too difficult to define a way to export them and have the
> macro expander check for their existence at macro expand time. It is a
> possible new feature for the next release. You would have to be a bit sneaky
> as their is no real support for macros in Erlang, it would be difficult to
> integrate them as seamlessly as in Lisp.
>
> Robert

I thought at first that include-file didn't work yet, but it
apparently works if I omit the quote in the filename string.

Maybe you could make compiling/loading files more consistent in a next
LFE update, because the current situation seems to be like this:

(include-file "filename.ext")

(c '"module.erl") or (c 'module)

(slurp '"module.erl")


I currently tend to forget what convention to use when using one of
these functions :-)

Best,
Vincent



From circularfunc@REDACTED  Thu May 29 21:40:53 2008
From: circularfunc@REDACTED (Circular Function)
Date: Thu, 29 May 2008 19:40:53 +0000 (GMT)
Subject: [erlang-questions] erlang emulator, can write, but returns nothing
Message-ID: <903686.78231.qm@web28308.mail.ukl.yahoo.com>

hi

i just started with erlang downloaded it. i can get the emulator/editor to run the 1> prompt but when i write something and press enter it just switches to the next row without evaluating and prompts 1> again.

could it be a failed install(sure i installed it right though) or am i?missing something obvious?

im using windows vista by the way.

stefan



      ___________________________________________________
S?k efter k?rleken!
Hitta din tvillingsj?l p? Yahoo! Dejting: http://ad.doubleclick.net/clk;185753627;24584539;x?http://se.meetic.yahoo.net/index.php?mtcmk=148783
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From tobbe@REDACTED  Thu May 29 22:13:28 2008
From: tobbe@REDACTED (Torbjorn Tornkvist)
Date: Thu, 29 May 2008 22:13:28 +0200
Subject: [erlang-questions] Twoorl: an open source Twitter clone
In-Reply-To: 
References: <17244f480805282212g32eaa0e1o78493087bd12fd0@mail.gmail.com>		<17244f480805282238q79f294e5je25a8378c89c71f2@mail.gmail.com>
	
Message-ID: 

Per Melin wrote:
> 2008/5/29 Yariv Sadan :
>> Facebook runs on MySQL -- that's pretty scalable :)
> 
> By Twitter's own account the database has been their bottleneck all along.
> 
>> The main reason I didn't go with Mnesia for storing most data is the
>> dets issues discussed previously on this list (specifically, the long
>> repair times and the need for fragmentation over 4gb). I use Mnesia
>> for storing session data though.
> 
> I wouldn't go for Mnesia either. If you're building something that's
> should possibly scale to the level of Twitter, the 2 GB limit just
> doesn't cut it, with or without fragmentation. And in the tests I've
> done DETS got very slow long before it hit the size limit. If you use
> disc_copies (which doesn't use DETS) instead of disc_only_copies
> you're of course instead limited by RAM.
> 
> I (like everyone else) have built a (web) chat service that I'll
> probably (alpha) release this weekend. The single biggest problem I've
> been wrestling with is how to persist the messages in an efficient
> manner. Right now I'm using term_to_binary and dumping that in a flat
> file (much like disk_log), which works for all my needs, except for
> full text search. I'd prefer not to build and store my own reverse
> index.

One approach could perhaps be to break out the DB-part of CouchDB and
make it available as a general purpose Erlang library ?

--Tobbe



From gleber.p@REDACTED  Thu May 29 22:21:28 2008
From: gleber.p@REDACTED (Gleb Peregud)
Date: Thu, 29 May 2008 22:21:28 +0200
Subject: [erlang-questions] erlang emulator, can write,
	but returns nothing
In-Reply-To: <903686.78231.qm@web28308.mail.ukl.yahoo.com>
References: <903686.78231.qm@web28308.mail.ukl.yahoo.com>
Message-ID: <14f0e3620805291321w4aa1dbfdh8e039e356eadc46f@mail.gmail.com>

Are you sure you've placed dot (".") at the end of the command?

$ erl
Erlang (BEAM) emulator version 5.6.2 [source] [async-threads:0] [hipe]
[kernel-poll:false]

Eshell V5.6.2  (abort with ^G)
1> io:fwrite("Hello world!~n").
Hello world!
ok
2>


2008/5/29 Circular Function :
> hi
>
> i just started with erlang downloaded it. i can get the emulator/editor to
> run the 1> prompt but when i write something and press enter it just
> switches to the next row without evaluating and prompts 1> again.
>
> could it be a failed install(sure i installed it right though) or am
> i?missing something obvious?
>
> im using windows vista by the way.
>
> stefan
>
> ________________________________
> G?r det l?ngsamt? Skaffa dig en snabbare bredbandsuppkoppling..
> S?k och j?mf?r hos Yahoo! Shopping.
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>



-- 
Gleb Peregud
http://gleber.pl/

Every minute is to be grasped.
Time waits for nobody.
-- Inscription on a Zen Gong

From zambal@REDACTED  Thu May 29 22:21:56 2008
From: zambal@REDACTED (zambal)
Date: Thu, 29 May 2008 13:21:56 -0700 (PDT)
Subject: [erlang-questions] Serl 0.1 Release Announcement
In-Reply-To: 
References: 
Message-ID: <36b12808-e884-4875-b758-b72c0b622d86@k37g2000hsf.googlegroups.com>

On May 29, 10:57?am, "Howard Yeh"  wrote:
> Hi,
>
> I've been hacking on a Lisp front end for Erlang during the past few
> months. It might be worth a look if you like common-lisp.
>
> Serl is a S-exp based frontend designed for Erlang. If you like
> Scheme, you might want to try LFE, but if you like Common-Lisp and its
> comparative hairyness, Serl might be for you.

Congratulations with this first release. I guess my taste's more like
LFE's 'minimal' syntax, but more languages running on the Erlang run-
time is a good thing IMHO and I'm very curious in which direction your
project will develop.

BTW, Serl's parser doesn't seem to like text files with window line
endings ( \r\n ). When saved with Unix line endings, compilation of my
test file seemed to work.


From dave@REDACTED  Thu May 29 22:23:50 2008
From: dave@REDACTED (Dave Peticolas)
Date: Thu, 29 May 2008 13:23:50 -0700 (PDT)
Subject: [erlang-questions] eep: multiple patterns
In-Reply-To: <483E50BC.2060902@ericsson.com>
References: <200805141620.19559.bekesa@sch.bme.hu> <4836A517.2040909@gmail.com>
	
	<200805271436.19305.bekesa@sch.bme.hu>
	<6BA6A9E9-EF89-4FE6-B683-05F3866E9E09@cs.otago.ac.nz>
	<483D0CB6.2080103@ericsson.com>
	
	<483E50BC.2060902@ericsson.com>
Message-ID: <61214.63.82.98.51.1212092630.squirrel@mail.webfaction.com>

Ulf Wiger wrote:
> Richard A. O'Keefe skrev:
>>
>> On 28 May 2008, at 7:41 pm, Ulf Wiger (TN/EAB) wrote:
>>> I would just like to point out, for the record, that
>>> this style of programming works well for gen_server-style
>>> processes (and is, in fact, used in e.g. gen_server.erl),
>>> but for selective receive, it is much harder, since
>>> selective receive relies entirely on pattern matching,
>>> and as such, is very difficult to modularize.
>>
>> It's not completely clear to me what Ulf Wiger means by
>> "this style of programming".  Using "this style of
>> programming" to mean "the decision table pattern",
>> it works perfectly fine for selective receive.
>
> Apologies for being unclear.
> It seemed to me as if the thread was approaching
> the idea of
>
> receive Msg ->
>    case classify_msg(Msg) of
>      Type -> Action
>      ...
>    end.
>
> which is what I was referring to.
> It is not surprising that the OTP behaviours gen_server
> and gen_fsm both use FIFO message reception, and then
> classify each message, sometimes using a callback.
>
> Maybe it's another thread altogether, but, I was
> under the impression that abstract patterns could
> actually help this situation (too) somewhat.
> My own impression is that this is a more pressing
> problem to solve than making multiple patterns more
> convenient. If the discussions are orthogonal, great,
> but otherwise, I'd like to see this particular
> problem considered as well.

Could you expand on this point for the benefit of the newbies? :)
I'm not clear about what exactly is the problem with gen_server's
message handling and what the better approach is.

thanks,
dave



From dnew@REDACTED  Thu May 29 18:34:54 2008
From: dnew@REDACTED (Darren New)
Date: Thu, 29 May 2008 09:34:54 -0700
Subject: [erlang-questions] Performance of matches
Message-ID: <483EDB2E.9070103@san.rr.com>

Speaking of table-driven decisions...

Is a function like this efficiently matched?

table1("hello") -> ...;
table1("byebye") -> ...;
table1("morning") -> ...;
   ... and so on for dozens more ...

How about
table2(hello) -> ...;
table2(byebye) -> ...;
table2(morning) -> ...;
    ... And so on for dozens more ...

Is either of those O(1) lookup time?

-- 
   Darren New / San Diego, CA, USA (PST)
     "That's pretty. Where's that?"
          "It's the Age of Channelwood."
     "We should go there on vacation some time."


From 0x6e6562@REDACTED  Thu May 29 22:29:09 2008
From: 0x6e6562@REDACTED (Ben Hood)
Date: Thu, 29 May 2008 21:29:09 +0100
Subject: [erlang-questions] erlang emulator, can write,
	but returns nothing
In-Reply-To: <903686.78231.qm@web28308.mail.ukl.yahoo.com>
References: <903686.78231.qm@web28308.mail.ukl.yahoo.com>
Message-ID: <9BBD1972-3CE8-4907-8CE3-5D9E0211180B@gmail.com>

Stefan,

On 29 May 2008, at 20:40, Circular Function wrote:
>
> i just started with erlang downloaded it. i can get the emulator/ 
> editor to run the 1> prompt but when i write something and press  
> enter it just switches to the next row without evaluating and  
> prompts 1> again.

Did you end the statement with a dot?

E.g.

1> erlang:now()
1> .
{1212,92834,481044}
2>

HTH,

Ben
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From Lennart.Ohman@REDACTED  Thu May 29 22:40:36 2008
From: Lennart.Ohman@REDACTED (=?iso-8859-1?Q?Lennart_=D6hman?=)
Date: Thu, 29 May 2008 22:40:36 +0200
Subject: [erlang-questions] erlang emulator, can write,
 but returns nothing
In-Reply-To: <903686.78231.qm@web28308.mail.ukl.yahoo.com>
References: <903686.78231.qm@web28308.mail.ukl.yahoo.com>
Message-ID: 


Hi, take a look in the Getting Started chapter and you can read about how to use the shell. (Look for the "." dot in the syntax :) )
http://www.erlang.org/doc/getting_started/part_frame.html

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@REDACTED
________________________________
From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Circular Function
Sent: den 29 maj 2008 21:41
To: erlang-questions@REDACTED
Subject: [erlang-questions] erlang emulator, can write, but returns nothing

hi

i just started with erlang downloaded it. i can get the emulator/editor to run the 1> prompt but when i write something and press enter it just switches to the next row without evaluating and prompts 1> again.

could it be a failed install(sure i installed it right though) or am i?missing something obvious?

im using windows vista by the way.

stefan


________________________________
G?r det l?ngsamt? Skaffa dig en snabbare bredbandsuppkoppling..
S?k och j?mf?r hos Yahoo! Shopping.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From hayeah@REDACTED  Thu May 29 22:47:43 2008
From: hayeah@REDACTED (Howard Yeh)
Date: Thu, 29 May 2008 13:47:43 -0700
Subject: [erlang-questions] Serl 0.1 Release Announcement
In-Reply-To: <36b12808-e884-4875-b758-b72c0b622d86@k37g2000hsf.googlegroups.com>
References: 
	<36b12808-e884-4875-b758-b72c0b622d86@k37g2000hsf.googlegroups.com>
Message-ID: 

Hey, thanks for trying it out.

I completely forgot about the window line feed thing. I'll fix it.

Serl's syntax won't get any more complex. I would welcome suggestions
to make it simpler, however. At the moment, I find it at a nice
balance point between syntatic exuberance and metaprogrammability.

For the next few releases, I'd like to rewrite most of the supporting
modules in Serl, and in that process finding out more about Serl and
making the necessary improvements and hopefully weed out bad ideas.

In the future, I'd really want to try building an object system in
Erlang's spirit. With asychronous message passing and non-mutability
(!). It's kinda like Michaelangelo said about sculpturing, the object
system is already there in Erlang, I just need to chisel it out.

Erlang is super cool.

On 5/29/08, zambal  wrote:
> On May 29, 10:57 am, "Howard Yeh"  wrote:
>  > Hi,
>  >
>  > I've been hacking on a Lisp front end for Erlang during the past few
>  > months. It might be worth a look if you like common-lisp.
>  >
>  > Serl is a S-exp based frontend designed for Erlang. If you like
>  > Scheme, you might want to try LFE, but if you like Common-Lisp and its
>  > comparative hairyness, Serl might be for you.
>
>
> Congratulations with this first release. I guess my taste's more like
>  LFE's 'minimal' syntax, but more languages running on the Erlang run-
>  time is a good thing IMHO and I'm very curious in which direction your
>  project will develop.
>
>  BTW, Serl's parser doesn't seem to like text files with window line
>  endings ( \r\n ). When saved with Unix line endings, compilation of my
>  test file seemed to work.
>  _______________________________________________
>  erlang-questions mailing list
>  erlang-questions@REDACTED
>  http://www.erlang.org/mailman/listinfo/erlang-questions
>


-- 
hayeah.wordpress.com
   --metacircular thinking


From rvirding@REDACTED  Thu May 29 23:05:51 2008
From: rvirding@REDACTED (Robert Virding)
Date: Thu, 29 May 2008 23:05:51 +0200
Subject: [erlang-questions] Leex - a lexical anaylzer generator, released
In-Reply-To: <9924E672-5F09-4BA6-94D4-103F99894222@gmail.com>
References: <3dbc6d1c0805240839k24b5a91cq71346591fe0faed8@mail.gmail.com>
	<0E07146E-57CA-47A1-9DD6-856DC2B7B477@gmail.com>
	<3dbc6d1c0805271656l2fb4ca0fyb13d1ac7f2d10f24@mail.gmail.com>
	<9924E672-5F09-4BA6-94D4-103F99894222@gmail.com>
Message-ID: <3dbc6d1c0805291405w5dd5b82iafdadf9b83155285@mail.gmail.com>

2008/5/29 Ben Hood <0x6e6562@REDACTED>:

> Robert,
> Thanks for your help. I've now gotten on top of leex and yecc to be able to
> solve my problem.
>
> I wrote a general article about using leex and yecc, to maybe help other
> newcomers: http://hopper.squarespace.com/blog/2008/5/29/leex-and-yecc.html
>

Yes, I liked it. Thank you for doing of my leex documentation work for me.
:-)

As always, now that I have stuck my chin out and released it, report bugs
and come with comments.

Robert
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From ulf.wiger@REDACTED  Thu May 29 23:21:29 2008
From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB))
Date: Thu, 29 May 2008 23:21:29 +0200
Subject: [erlang-questions] eep: multiple patterns
In-Reply-To: <61214.63.82.98.51.1212092630.squirrel@mail.webfaction.com>
References: <200805141620.19559.bekesa@sch.bme.hu> <4836A517.2040909@gmail.com>
	
	<200805271436.19305.bekesa@sch.bme.hu>
	<6BA6A9E9-EF89-4FE6-B683-05F3866E9E09@cs.otago.ac.nz>
	<483D0CB6.2080103@ericsson.com>
	
	<483E50BC.2060902@ericsson.com>
	<61214.63.82.98.51.1212092630.squirrel@mail.webfaction.com>
Message-ID: <483F1E59.4090007@ericsson.com>

Dave Peticolas skrev:
> 
> Could you expand on this point for the benefit
 > of the newbies? :)
> I'm not clear about what exactly is the problem
 > with gen_server's message handling and what the
 > better approach is.

The problem is not with gen_server, which is wonderful
for implementing client-server patterns.

The issue is with FIFO message handling, at least when
used for complex state machines. It is very difficult
to write a behavior that lets the user have control
over selective message reception. In selective receive,
you can use only patterns and guards, and neither can
be extended with user-defined logic via a callback
function.

Here are some slides from EUC 2005 on the topic:
http://www.erlang.se/euc/05/1500Wiger.ppt


You could read the thread:
"plain_fsm - for beginners and purists"
from 2004:

http://www.erlang.org/pipermail/erlang-questions/2004-February/011403.html

and then the "higher-order receive anybody" thread:

http://www.erlang.org/pipermail/erlang-questions/2004-February/011514.html



This most likely give you more detail than you asked for. (:

BR,
Ulf W


From ok@REDACTED  Fri May 30 00:17:19 2008
From: ok@REDACTED (Richard A. O'Keefe)
Date: Fri, 30 May 2008 10:17:19 +1200
Subject: [erlang-questions] eep: multiple patterns
In-Reply-To: <483E50BC.2060902@ericsson.com>
References: <200805141620.19559.bekesa@sch.bme.hu>
	<4836A517.2040909@gmail.com>		<200805271436.19305.bekesa@sch.bme.hu>
	<6BA6A9E9-EF89-4FE6-B683-05F3866E9E09@cs.otago.ac.nz>
	<483D0CB6.2080103@ericsson.com>
	
	<483E50BC.2060902@ericsson.com>
Message-ID: <006DED5E-0122-4FED-B574-8BF195A3A7D4@cs.otago.ac.nz>


On 29 May 2008, at 6:44 pm, Ulf Wiger (TN/EAB) wrote:
> It seemed to me as if the thread was approaching
> the idea of
>
> receive Msg ->
>  case classify_msg(Msg) of
>    Type -> Action
>    ...
>  end.

This is due to an accident:  one example we were given
_did_ have a receive that was going to handle every
possible message (there was an X-> case at the end).
I wanted to concentrate on the "two cases" idea and
not on receiving.

> Maybe it's another thread altogether, but, I was
> under the impression that abstract patterns could
> actually help this situation (too) somewhat.

Yes they can.  I think I mentioned that, but I
wanted to show that the problem can be handled
without excessive pain in the language as it stands.

Let's take the running example:

    loop(State) ->
	case receive
		 quit                              -> quit
	       ; {?MODULE,{signal,{window1,_}}}    -> quit
	       ; {?MODULE,{signal,{quit1,_}}}      -> quit
	       ; {?MODULE,{signal,{connect,_}}}    -> connect
	       ; {?MODULE,{signal,{disconnect,_}}} -> disconnect
	       ; {?MODULE,{signal,{about1,_}}}     -> show_about
	       ; {?MODULE,{signal,{dialog1,_}}}    -> hide_about
	       ; {?MODULE,{signal,{dialogb,_}}}    -> hide_about
	       ; {data,Data}                       -> {data,Data}
	       ; X                                 -> {error,X}
	     end
	  of quit       -> quit()
	   ; connect    -> loop(conn(State))
	   ; disconnect -> loop(disc(State))
	   ; show_about -> loop(show_about(State))
	   ; hide_about -> loop(hide_about(State))
	   ; {data,D}   -> loop(update(State, D))
	   ; {error,X}  -> io:fwrite("got ~p~n", [X]),
			   loop(State)
	end.

Now let's do it with abstract patterns.

#quit() ->       quit;
#quit() ->       {?MODULE,{signal,{window1,_}}};
#quit() ->       {?MODULE,{signal,{quit1,_}}}.

#connect() ->    {?MODULE,{signal,{connect,_}}}.

#disconnect() -> {?MODULE,{signal,{disconnect,_}}}.

#show_about() -> {?MODULE,{signal,{about1,_}}}.

#hide_about() -> {?MODULE,{signal,{dialog1,_}}};
#hide_about() -> {?MODULE,{signal,{dialogb,_}}}.

#data(Data)   -> {data,Data}.

    loop(State) ->
	receive
	    #quit()       -> quit()
	  ; #connect()    -> loop(conn(State))
	  ; #disconnect() -> loop(disc(State))
	  ; #show_about() -> loop(show_about(State))
           ; #hide_about() -> loop(hide_about(State))
	  ; #data(Data)   -> loop(update(State, Data))
           ; X             -> io:fwrite("got ~p~n", [X]),
			     loop(State)
	end.

 From one point of view, of course, this simply *IS*
multiple patterns.  But the complexity has to be moved
out of the case or receive or whatever and given a *NAME*.
Once again we are separating "what is to be done" from
"how to do it", making it easier to understand each.



From dave@REDACTED  Fri May 30 00:52:22 2008
From: dave@REDACTED (Dave Peticolas)
Date: Thu, 29 May 2008 15:52:22 -0700 (PDT)
Subject: [erlang-questions] eep: multiple patterns
In-Reply-To: <483F1E59.4090007@ericsson.com>
References: <200805141620.19559.bekesa@sch.bme.hu> <4836A517.2040909@gmail.com>
	
	<200805271436.19305.bekesa@sch.bme.hu>
	<6BA6A9E9-EF89-4FE6-B683-05F3866E9E09@cs.otago.ac.nz>
	<483D0CB6.2080103@ericsson.com>
	
	<483E50BC.2060902@ericsson.com>
	<61214.63.82.98.51.1212092630.squirrel@mail.webfaction.com>
	<483F1E59.4090007@ericsson.com>
Message-ID: <13538.63.82.98.51.1212101542.squirrel@mail.webfaction.com>

Ulf Wiger wrote:
> Dave Peticolas skrev:
>>
>> Could you expand on this point for the benefit
>  > of the newbies? :)
>> I'm not clear about what exactly is the problem
>  > with gen_server's message handling and what the
>  > better approach is.
>
> The problem is not with gen_server, which is wonderful
> for implementing client-server patterns.
>
> The issue is with FIFO message handling, at least when
> used for complex state machines. It is very difficult
> to write a behavior that lets the user have control
> over selective message reception. In selective receive,
> you can use only patterns and guards, and neither can
> be extended with user-defined logic via a callback
> function.
>
> Here are some slides from EUC 2005 on the topic:
> http://www.erlang.se/euc/05/1500Wiger.ppt
>
>
> You could read the thread:
> "plain_fsm - for beginners and purists"
> from 2004:
>
> http://www.erlang.org/pipermail/erlang-questions/2004-February/011403.html
>
> and then the "higher-order receive anybody" thread:
>
> http://www.erlang.org/pipermail/erlang-questions/2004-February/011514.html
>
>
>
> This most likely give you more detail than you asked for. (:

Not at all, it is very informative, thanks!

dave



From 0x6e6562@REDACTED  Fri May 30 02:42:37 2008
From: 0x6e6562@REDACTED (Ben Hood)
Date: Fri, 30 May 2008 01:42:37 +0100
Subject: [erlang-questions] Leex - a lexical anaylzer generator, released
In-Reply-To: <3dbc6d1c0805291405w5dd5b82iafdadf9b83155285@mail.gmail.com>
References: <3dbc6d1c0805240839k24b5a91cq71346591fe0faed8@mail.gmail.com>
	<0E07146E-57CA-47A1-9DD6-856DC2B7B477@gmail.com>
	<3dbc6d1c0805271656l2fb4ca0fyb13d1ac7f2d10f24@mail.gmail.com>
	<9924E672-5F09-4BA6-94D4-103F99894222@gmail.com>
	<3dbc6d1c0805291405w5dd5b82iafdadf9b83155285@mail.gmail.com>
Message-ID: <43A4755C-221D-4DD0-8EBD-8D173E00515D@gmail.com>

Robert,

On 29 May 2008, at 22:05, Robert Virding wrote:
> As always, now that I have stuck my chin out and released it, report  
> bugs and come with comments.

One feature that I miss from other CC toolkits is being able to  
declare your regexs to be case insensitive.

Here's an example from a JavaCC grammar:

/* Reserved Words */
TOKEN [IGNORE_CASE] :
{
     <  NOT     : "NOT">
   | <  AND     : "AND">
   | <  OR      : "OR">
   | <  BETWEEN : "BETWEEN">
   | <  LIKE    : "LIKE">
   | <  ESCAPE  : "ESCAPE">
   | <  IN      : "IN">
   | <  IS      : "IS">
   | <  TRUE    : "TRUE" >
   | <  FALSE   : "FALSE" >
   | <  NULL    : "NULL" >
   | <  XPATH   : "XPATH" >
   | <  XQUERY  : "XQUERY" >
}

I ended having to put patterns in like

between|BETWEEN

to match lower and upper cases alike.

I know that you are bound by what the regexp module can give you though.

Just a thought,

Ben


From archevis@REDACTED  Fri May 30 08:36:13 2008
From: archevis@REDACTED (John M. Nordgaard)
Date: Fri, 30 May 2008 08:36:13 +0200 (CEST)
Subject: [erlang-questions] Sending a message to all linked processes
In-Reply-To: <3dbc6d1c0805290204l2d4935e7jacf50f25bc0399ae@mail.gmail.com>
References: <49434.85.164.199.66.1212049630.squirrel@www.cyber.no>
	<3dbc6d1c0805290204l2d4935e7jacf50f25bc0399ae@mail.gmail.com>
Message-ID: <62673.192.168.2.12.1212129373.squirrel@www.cyber.no>

>> Hi all,
>>
>> Been looking through the documentation in search of an answer, and have
>> not been able to locate one, so I hope I haven't missed the obvious
>> here... my Erlang mileage is still nothing to brag about. :-)
>>
>> I was wondering if there is a simple and straightforward way to send a
>> message to all linked processes. Now, I am aware that a process exit
>> signal is transmitted in a functionally similar manner, so it seems that
>> at least some form of "broadcast to all linked processes" operation
>> exists
>> within the runtime. But is it possible to invoke such functionality
>> directly from source code?
>
>
> send_links(Message) ->
>     {link,Links} = process_info(self(), links),
>     lists:foreach(fun (P) -> P ! Message end, Links).
>
> Robert

Except for a minor typo (links, not link, in line 2) this solution seems
to work like a charm... :-)

Thanks, Robert!

- john.




From archevis@REDACTED  Fri May 30 08:45:20 2008
From: archevis@REDACTED (John M. Nordgaard)
Date: Fri, 30 May 2008 08:45:20 +0200 (CEST)
Subject: [erlang-questions] Sending a message to all linked processes
In-Reply-To: <2a67d3ff0805290140n3340a398wab89b99c6750614c@mail.gmail.com>
References: <49434.85.164.199.66.1212049630.squirrel@www.cyber.no>
	<2a67d3ff0805290140n3340a398wab89b99c6750614c@mail.gmail.com>
Message-ID: <62707.192.168.2.12.1212129920.squirrel@www.cyber.no>

Hi Gene,

No, I'm not. This particular work is on swarm behavior.

- john.


> John,
>
> You're not by any chance working on a Neural Network project are you?
>
> -Gene
>
> On Thu, May 29, 2008 at 1:27 AM, John M. Nordgaard 
> wrote:
>
>> Hi all,
>>
>> Been looking through the documentation in search of an answer, and have
>> not been able to locate one, so I hope I haven't missed the obvious
>> here... my Erlang mileage is still nothing to brag about. :-)
>>
>> I was wondering if there is a simple and straightforward way to send a
>> message to all linked processes. Now, I am aware that a process exit
>> signal is transmitted in a functionally similar manner, so it seems that
>> at least some form of "broadcast to all linked processes" operation
>> exists
>> within the runtime. But is it possible to invoke such functionality
>> directly from source code?
>>
>> The reason I ask is that I'm doing some research on systems with a very
>> large number of highly autonomous agents, and would like to be able to
>> broadcast messages to all agents without the hassle of manual PID book
>> keeping.
>>
>> All hints and suggestiong are greatly appreciated! :-)
>>
>> - john.
>>
>>
>>
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://www.erlang.org/mailman/listinfo/erlang-questions
>>
>




From thomasl_erlang@REDACTED  Fri May 30 09:16:29 2008
From: thomasl_erlang@REDACTED (Thomas Lindgren)
Date: Fri, 30 May 2008 00:16:29 -0700 (PDT)
Subject: [erlang-questions] Performance of matches
In-Reply-To: <483EDB2E.9070103@san.rr.com>
Message-ID: <262114.60906.qm@web38804.mail.mud.yahoo.com>


--- Darren New  wrote:

> Speaking of table-driven decisions...
> 
> Is a function like this efficiently matched?
> 
> table1("hello") -> ...;
> table1("byebye") -> ...;
> table1("morning") -> ...;
>    ... and so on for dozens more ...
> 
> How about
> table2(hello) -> ...;
> table2(byebye) -> ...;
> table2(morning) -> ...;
>     ... And so on for dozens more ...
> 
> Is either of those O(1) lookup time?

It depends on the implementation, but pattern matching
compilers often try to visit each subterm only once,
so the first case might be something like

table1([C0|Cs]) ->
   case C0 of
      $h -> ... continue matching ello ...
      $b -> ... continue matching yebye ...
      $m -> ... continue matching orning ...
   end

If there are several cases beginning with $b, then the
clause in the middle will perform further
discrimination.

(But note that Erlang/OTP might do things differently;
I can't remember. "erlc -S" provides a way station on
this quest :-)

In the second case, all the terms are atoms, so the
compiler can generate the equivalent of a switch.
However, atom id:s used to identify atoms are usually
assigned at runtime (e.g., when a module with
previously unseen atoms is loaded). So the compiler
will normally convert such a switch into some
optimized tree of comparisons rather than a jump
table. (Sloppy compilers do a linear sequence of
matches; reasonably conscientous ones at least build a
binary tree.)

Best,
Thomas



      


From bjorn@REDACTED  Fri May 30 10:04:38 2008
From: bjorn@REDACTED (Bjorn Gustavsson)
Date: 30 May 2008 10:04:38 +0200
Subject: [erlang-questions] Performance of matches
In-Reply-To: <262114.60906.qm@web38804.mail.mud.yahoo.com>
References: <262114.60906.qm@web38804.mail.mud.yahoo.com>
Message-ID: 

Thomas Lindgren  writes:

> It depends on the implementation, but pattern matching
> compilers often try to visit each subterm only once,
> so the first case might be something like
> 
> table1([C0|Cs]) ->
>    case C0 of
>       $h -> ... continue matching ello ...
>       $b -> ... continue matching yebye ...
>       $m -> ... continue matching orning ...
>    end
>
> If there are several cases beginning with $b, then the
> clause in the middle will perform further
> discrimination.

The Beam compiler indeed generates that kind of code for matching.

> In the second case, all the terms are atoms, so the
> compiler can generate the equivalent of a switch.
> However, atom id:s used to identify atoms are usually
> assigned at runtime (e.g., when a module with
> previously unseen atoms is loaded). So the compiler
> will normally convert such a switch into some
> optimized tree of comparisons rather than a jump
> table. (Sloppy compilers do a linear sequence of
> matches; reasonably conscientous ones at least build a
> binary tree.)

Beam sorts the atoms when the code is loaded; a binary search
is used when the code is executed. (Atom id:s are generally
spaced too far apart for a jump table to be feasible.)

/Bjorn
-- 
Bj?rn Gustavsson, Erlang/OTP, Ericsson AB


From ulf.wiger@REDACTED  Fri May 30 10:25:04 2008
From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB))
Date: Fri, 30 May 2008 10:25:04 +0200
Subject: [erlang-questions] eep: multiple patterns
In-Reply-To: 
References: <200805141620.19559.bekesa@sch.bme.hu> <4836A517.2040909@gmail.com>
	
	<200805271436.19305.bekesa@sch.bme.hu>
	<6BA6A9E9-EF89-4FE6-B683-05F3866E9E09@cs.otago.ac.nz>
	<483D0CB6.2080103@ericsson.com>
	
	<483E50BC.2060902@ericsson.com>
	<61214.63.82.98.51.1212092630.squirrel@mail.webfaction.com>
	<483F1E59.4090007@ericsson.com>
	
Message-ID: <483FB9E0.80504@ericsson.com>

Richard A. O'Keefe skrev:
> 
> On 30 May 2008, at 9:21 am, Ulf Wiger (TN/EAB) wrote:
>> and then the "higher-order receive anybody" thread:
>>
>> http://www.erlang.org/pipermail/erlang-questions/2004-February/011514.html 
>>
> 
> Abstract patterns *almost* do that.
> You can specify "what to receive" as an abstract pattern,
> which can be passed around like a function,
> but all it can do is build a term containing selected
> data.  That's all you really need, so
>     Action(?#Filter)
> is in effect a higher order receive.

Here's a slightly sanitized example from an actual
product, using a main select statement with a filter
record, in line with the idea I suggested in my
EUC presentation. It is, in fact, the Extremely
Readable Rewrite of the real-life example in the
presentation. (:

I thought I'd try to convey a feeling for just
how hairy the receive clauses can get. I think
this is the worst one.

It would of course be a candidate for the sort of
refactoring you've shown on the other examples.
It is perhaps a matter of taste, whether or not
one prefers to extract as much code as possible out
of the receive statement (which in this case is 650
lines of code + comments). Most of the snipped
action bodies are only a handful of lines of code.
A few are considerably longer (up to 30 LOC).

Most of the action logic is performed in the
callback modules, which have to register
themselves with the main event loop.
These callbacks are relatively straightforward.

The callback modules can indicate which messages
they are expecting, allowing the main wait_loop
to buffer other messages. There can be many tens
of thousand ongoing sessions, but many possible
events affect all sessions or groups of sessions,
so it isn't obvious whether a central (buffering)
event loop is best, or decomposing it into one
or more processes per session.

Introducing a way to use selective receive,
and making heavy use of Erlang's pattern matching
as you can see, we have greatly reduced the
accidental complexity, but the application code
alone is still 100 KLOC - excluding platform and
middleware code.

(What does it do? It basically makes a Telephony
over IP network look like a legacy TDM switch,
in order to enable all legacy phone services
over an IP backbone. Obviously, all standard
requirements of 5-nines availability, scalability,
in-service upgrade, etc. apply.)

BR,
Ulf W

wait_loop(#mlgCmConnTable{hcKey       = HcKey,
                           hcId        = _HcId,
                           expectedMsg = Expected,
                           hcTrigger   = HcTrigger,
                           waitReq     = WaitReq} = HcRec,
           TraceLog) ->
     receive

         %%-------------------------------------------------------
         %% Data Checking/Collection procedures
         %%-------------------------------------------------------
         {distr_msg, DistrMsgId, {print_hc, Type}} ->
             ...;

         {collect_data, collect_data, CcpcArgs} ->
             ...,
             end_session(...);

         {collect_data, connection_trace, CcpcArgs} ->
             ...;

         {get_data,Sender} ->
             ...;

         %%-------------------------------------------------------
         %% Cleanup HC
         %%-------------------------------------------------------
         {distr_msg, DistrMsgId, ?HCMSG_REMOVE_HC} ->
             ...;

         {distr_msg, DistrMsgId, ?HCMSG_REMOVE_HC_DATA} ->
             ...;

         {distr_msg, DistrMsgId, ?HCMSG_REMOVE_ALL_HC} ->
             ...;

         {distr_msg, DistrMsgId, ?HCMSG_BEARER_RELEASED} ->
             ...;

         {distr_msg, DistrMsgId, ?HCMSG_RELEASE_BEARER} ->
             ...;

         %%-------------------------------------------------------
         %% Info HC
         %%-------------------------------------------------------
         {distr_msg, DistrMsgId, ?HCMSG_REPORT_LINE_EVENT} ->
             ...;

         %%-------------------------------------------------------
         %% Unexpected notify
         %%-------------------------------------------------------
         {distr_msg, DistrMsgId, {M, unexpected_gcp_notify=F, A}}
           when HcTrigger==?HC_TRIGGER_DEFAULT ->
             %% This is an on-hook sent ... in null context and with
             %% provisional event id. ...
             %% Make sure it does not interrupt any ongoing sequences.
             ...,
             end_session(Result);

         %%-------------------------------------------------------
         %% Update Context Server???
         %%-------------------------------------------------------
         {distr_msg, DistrMsgId, {M, F, A}}
         when atom(M), atom(F), list(A), F/=unexpected_gcp_notify ->
             ...,
             end_session(Result);

         ... (snipped housekeeping tasks)

         %%-------------------------------------------------------
         %% Cleanup HC
         %%-------------------------------------------------------
         {_, _, [_HcKey, M, F, ?HCMSG_REMOVE_HC = Msg]} -> ...;
         {_, _, [_HcKey, M, F, ?HCMSG_REMOVE_HC_DATA = Msg]} -> ...;
         {_, _, [_HcKey, M, release_on_notify = F,  Msg]} -> ...;

         %%-------------------------------------------------------
         %% Get HC Info
         %%-------------------------------------------------------
         {_, _, [_HcKey, M, get_hc_info = F, Msg]} -> ...;
         {_, _, [_HcKey, _M, get_tracelog = _F, _Msg]} -> ...;

         %%-------------------------------------------------------
         %% Only Gcp messages are accepted here.
         %%-------------------------------------------------------
         {_, _, [_HcKey, M, gcp_msg = F, Msg]}
         when WaitReq == ?HC_WAIT_FOR_GCP_REPLY ->
             HR1 = HcRec#mlgCmConnTable{
                        waitReq = ?HC_NO_PENDING_GCP_MSG},
             ...,
             end_session(apply(M, F, [HR1, Msg] ++ [TraceLog2]));

         %%-------------------------------------------------------
         %% Special case: transferDtmf + Notify. (signalCompletion)
         %%-------------------------------------------------------
         {_, _, [_HcKey, M, ?MSG_NOTIFY_SC = F, Msg]}
         when WaitReq == ?MSG_WAIT_REQ_SC ->
             HR1 = HcRec#mlgCmConnTable{
                      waitReq = ?HC_NO_PENDING_GCP_MSG},
             ...,
             end_session(apply(M, F2, [HR1, Msg] ++ [TraceLog2]));

         %%-------------------------------------------------------
         %% Special case for HCMSG_RELEASE to avoid deadlock
         %%-------------------------------------------------------
         {_, _, [_HcKey, _M, hc_msg = _F,
                 #mlgCmHcMsgRelease{
                    domain=Domain, function=Function} = Msg]}
         when ( is_tuple(hd(Expected)) andalso
                (element(1,hd(Expected)) == mlgCmHcMsgReleaseRes) 
andalso
                (WaitReq == ?HC_NO_PENDING_GCP_MSG) ) ->
             ...,
             end_session(...);

         %%-------------------------------------------------------
         %% Ignore HCMSG_RELEASE_COMPLETE in wrong states
         %%-------------------------------------------------------
     {_, _, [_HcKey, _M, hc_msg, #mlgCmHcMsgReleaseComplete{}]}
         when not 
(((HcTrigger#mlgCmHcTrigger.m==?HCTM_INTRA_DOMAIN_TERM) and
                    (HcTrigger#mlgCmHcTrigger.f==?HCTF_RP_AGW_TDM) and
                    (HcTrigger#mlgCmHcTrigger.a==?HCTA_RELEASE)) or
 
((HcTrigger#mlgCmHcTrigger.m==?HCTM_INTRA_DOMAIN_TERM) and
                    (HcTrigger#mlgCmHcTrigger.f==?HCTF_RP_AGW_TDM) and
                    (HcTrigger#mlgCmHcTrigger.a==?HCTA_SUBTRACT))) ->
             end_session(...);

         %%-------------------------------------------------------
         %% Clash handling:                              (...)
         %%       GW notifications ignored during renegotiation
         %%-------------------------------------------------------
         {_, _, [_HcKey, M,
                 gcp_notify = F,
                 [_HcInfo, _DcId,
                  {actionRequest,
                   #mlgArGcpData{
                     notification =
                       #mlgArNotify{
                          events = [{"ctyp/dtone","dtt",_}|_]}
                   }}] = Msg]}
      when ... -> ...;

         %%-------------------------------------------------------
         %% Clash handling:    (...)
         %%       CodecReneg hc_msg received while this half call
         %%       is already in renegotiation,
         %%-------------------------------------------------------
         {_, _, [_HcKey, _M, hc_msg = _F,
                 #mlgCmHcMsgCodecReneg{function = IncomingRenegF}] = Msg}
         when (HcRec#mlgCmConnTable.renegData)#mlgRenegData.renegState /=
           ?RENEG_NULL ->

             ...,
             end_session({?ES_UNCHANGED, ?EC_IGNORED, HR1, TL});

         %%-------------------------------------------------------
         %% Clash handling:    (...)
         %%       BRM BEAR_INFO msg is received when HC is
         %%       waiting for GCP modReply or hc_msg CodecRenegRes
         %%-------------------------------------------------------
         {_, _, [_HcKey, _M,
                 msg_received = _F,
            [[?BRM_BEARER_INFO = _MsgId, _Tid,
             [_Sid, _SDID, _BI]] | _] = Msg]}
         when
           HcTrigger#mlgCmHcTrigger.m == ?HCTM_CODEC_RENEG_ORIG_IM,
           HcTrigger#mlgCmHcTrigger.f == ?HCTF_RENEG_AUDIO_VOIP_VOIP,
           HcTrigger#mlgCmHcTrigger.a == ?HCTA_MODIFY;

           ... (snipped 11 more similar guard groups)
         ->
           ...;


         ... (a few more similar clash handling cases);

         %%-------------------------------------------------------
         %% Only hc messages can have the expected message set.
         %% ...
         %%-------------------------------------------------------
         {_, _, [_HcKey, M, hc_msg = F, Msg]}
         when ((element(?HC_MSG_REF_POS, Msg) == hd(Expected) orelse
                hd(Expected) == hc_msg) andalso
               (WaitReq == ?HC_NO_PENDING_GCP_MSG)) ->
             ...,
             end_session(apply(M, F, [HR1, Msg] ++ [TraceLog2]));

         %%-------------------------------------------------------
         %% RELEASE_BEARER, REMOVE_HC_DATA and REMOVE_HC peer msgs
         %% have to be processed immediately.
         %%-------------------------------------------------------

         {_, _, [_HcKey, M, hc_msg = F,
                 #mlgCmHcMsgPeerMsg{function = Func} = Msg]}
         when Func == ?HCTF_RELEASE_BEARER;
              Func == ?HCTF_REMOVE_HC;
              Func == ?HCTF_REMOVE_HC_DATA ->
             case {Func, HcTrigger} of
                 ...
             end;


         %%-------------------------------------------------------
         %% Immediate processing of all PDM half calls
         %%-------------------------------------------------------

         {_, _, [_HcKey, M, hc_msg = F, Msg]}
         when is_record(Msg,mlgCmHcMsgStatReq);
              is_record(Msg,mlgCmHcMsgStatReqRes);
              is_record(Msg,mlgCmHcMsgFetchStat);
              is_record(Msg,mlgCmHcMsgFetchStatRes);
              is_record(Msg,mlgCmHcMsgStatistics) ->
             ...,
             end_session(apply(M, F, [HcRec, Msg] ++ [TraceLog2]));


         ... (several internal messages snipped)

     after get_wait_loop_timeout(HcRec) ->
             handle_wait_loop_timeout(
               get_wait_loop_timeout(HcRec), HcRec, TraceLog)
     end.


From mats.cronqvist@REDACTED  Fri May 30 11:00:00 2008
From: mats.cronqvist@REDACTED (mats cronqvist)
Date: Fri, 30 May 2008 11:00:00 +0200
Subject: [erlang-questions] eep: multiple patterns
In-Reply-To: <006DED5E-0122-4FED-B574-8BF195A3A7D4@cs.otago.ac.nz>
References: <200805141620.19559.bekesa@sch.bme.hu>	<4836A517.2040909@gmail.com>		<200805271436.19305.bekesa@sch.bme.hu>	<6BA6A9E9-EF89-4FE6-B683-05F3866E9E09@cs.otago.ac.nz>	<483D0CB6.2080103@ericsson.com>		<483E50BC.2060902@ericsson.com>
	<006DED5E-0122-4FED-B574-8BF195A3A7D4@cs.otago.ac.nz>
Message-ID: <483FC210.9040600@gmail.com>

Richard A. O'Keefe wrote:
>
> Now let's do it with abstract patterns.
>
> #quit() ->       quit;
> #quit() ->       {?MODULE,{signal,{window1,_}}};
> #quit() ->       {?MODULE,{signal,{quit1,_}}}.
> #connect() ->    {?MODULE,{signal,{connect,_}}}.
> #disconnect() -> {?MODULE,{signal,{disconnect,_}}}.
> #show_about() -> {?MODULE,{signal,{about1,_}}}.
> #hide_about() -> {?MODULE,{signal,{dialog1,_}}};
> #hide_about() -> {?MODULE,{signal,{dialogb,_}}}.
>
> #data(Data)   -> {data,Data}.
>
>     loop(State) ->
> 	receive
> 	    #quit()       -> quit()
> 	  ; #connect()    -> loop(conn(State))
> 	  ; #disconnect() -> loop(disc(State))
> 	  ; #show_about() -> loop(show_about(State))
>           ; #hide_about() -> loop(hide_about(State))
> 	  ; #data(Data)   -> loop(update(State, Data))
>           ; X             -> io:fwrite("got ~p~n", [X]),
> 			     loop(State)
> 	end.
>   
  very nice! if only i could compile it...


  mats


From tuncer.ayaz@REDACTED  Fri May 30 12:33:44 2008
From: tuncer.ayaz@REDACTED (Tuncer Ayaz)
Date: Fri, 30 May 2008 12:33:44 +0200
Subject: [erlang-questions] Twoorl: an open source Twitter clone
In-Reply-To: <17244f480805282334r3f9ebaegbb833557d91e42d@mail.gmail.com>
References: <17244f480805282212g32eaa0e1o78493087bd12fd0@mail.gmail.com>
	
	<17244f480805282238q79f294e5je25a8378c89c71f2@mail.gmail.com>
	<97619b170805282255k67d080dbhe7c8d8b8c431377b@mail.gmail.com>
	
	<17244f480805282334r3f9ebaegbb833557d91e42d@mail.gmail.com>
Message-ID: <4ac8254d0805300333s70f79a96hc8af6bad8b6781ec@mail.gmail.com>

On Thu, May 29, 2008 at 8:34 AM, Yariv Sadan  wrote:
>>
>> I don't know who scared Yariv about dets, but it is interesting
>> to note in The Erlang Efficiency Guide it now says.
>>
>> "2.6 Myth: Repairing a Dets file is very slow
>>
>> The repair time is still proportional to the number of records in the
>> file, but Dets repairs used to be much, much slower in the past. Dets
>> has been massively rewritten and improved. "
>>
>> So I don't know if his worries still apply.
>>
>> /Anders
>>
>
> That's great -- I didn't see that!
>
> What scared me was when Klacke said dets should be rewritten.

Is dets and/or ets so needy of a rewrite that lifting the size
limit is not easily implementable with a comparable
performance profile to what it has now?

Sorry if I failed to find the appropriate thread in the mailing
list archives discussing this. If there is any it would be kind
to point me there instead.




From mats.cronqvist@REDACTED  Fri May 30 13:06:11 2008
From: mats.cronqvist@REDACTED (mats cronqvist)
Date: Fri, 30 May 2008 13:06:11 +0200
Subject: [erlang-questions] distel-mode with *.beam files separate from
 source
In-Reply-To: <1211549163.6310.22.camel@localhost>
References: <1211509773.6476.58.camel@localhost>	 <4836867F.6020002@gmail.com>
	<1211542223.6310.7.camel@localhost>	 <4836BC3A.8040602@gmail.com>
	<1211549163.6310.22.camel@localhost>
Message-ID: <483FDFA3.1020103@gmail.com>

Paul Fisher wrote:
> On Fri, 2008-05-23 at 14:44 +0200, Mats Cronqvist wrote:
>   
>> Paul Fisher wrote:
>>     
>>> Did a little digging and from the bottom distel:find_source/1 certainly
>>> seems to find the source file (by the
>>> path /top/project/application/source.erl) correctly, so maybe there is
>>> something else going one unrelated to the source tree, or possibly
>>> tangentially related.  Here is the actual error I get in the
>>> *erl-output* buffer that is created when I toggle on interactive:
>>>
>>> ** Invalid beam file or no abstract code:
>>> "/top/project/application/source.erl"
>>>       
>>   this in all likelihood means that the beam does not contain any debug 
>> info.
>>   try "erlc +debug_info" (the erlc equivalent of cc -g)
>>     
>
> I'm certain that it does have debugging information, so the error
> message is really not accurately reflecting the problem, which
> ultimately the fact that int:i/1 cannot find any beam file to associate
> with the absolute source path name.
>
> The problem is that distel:find_source/1 in the face of this arrangement
> locates the source file as:
>
>   top/project/application/source.erl
>
> rather than
>
>   top/bld/erlang/application/src/source.erl
>
> Then when it hands the former to the int:i/1 the interpreter does not
> know how to find the source.beam file based on that location.
>
> The core problem is that distel:get_source_file/2 should locate the
> source at the latter location before the former location.  It prefers
> the source file attribute in the beam file over all other alternatives
> because src_from_beam/1 is first in the list that is passed to
> try_srcs/1.  Works just great, except for these "out of tree" build
> environments.
>   
  i don't remember if i already answered this; apologies if i'm rehashing.
 
  seems there's a couple of issues.
 * i think distel:guess_source_file/2 is correct; if the erl file 
pointed to by the beam file exists, it's likely the correct one.
 * when erlc sticks the compilation info in the beam file, it follows links.
 * int:i/1 insists that the erl and the beam file must be either in the 
same dir, or in adjacent src/ebin dirs.

  the Right Thing (tm) would be to add to the int:i API, allowing us to 
specify absolute file names for the beam and the erl files separately.

  changing distel:guess_source_file/2 to match the inanity of int:i is 
probably the second best option.

  mats


From pfisher@REDACTED  Fri May 30 13:17:30 2008
From: pfisher@REDACTED (Paul Fisher)
Date: Fri, 30 May 2008 06:17:30 -0500
Subject: [erlang-questions] distel-mode with *.beam files separate
	from	source
In-Reply-To: <483FDFA3.1020103@gmail.com>
References: <1211509773.6476.58.camel@localhost>
	<4836867F.6020002@gmail.com> <1211542223.6310.7.camel@localhost>
	<4836BC3A.8040602@gmail.com> <1211549163.6310.22.camel@localhost>
	<483FDFA3.1020103@gmail.com>
Message-ID: <1212146250.6409.107.camel@localhost>

On Fri, 2008-05-30 at 13:06 +0200, mats cronqvist wrote:
> Paul Fisher wrote:
> > I'm certain that it does have debugging information, so the error
> > message is really not accurately reflecting the problem, which
> > ultimately the fact that int:i/1 cannot find any beam file to associate
> > with the absolute source path name.
> >
> > The problem is that distel:find_source/1 in the face of this arrangement
> > locates the source file as:
> >
> >   top/project/application/source.erl
> >
> > rather than
> >
> >   top/bld/erlang/application/src/source.erl
> >
> > Then when it hands the former to the int:i/1 the interpreter does not
> > know how to find the source.beam file based on that location.
> >
> > ...
>   i don't remember if i already answered this; apologies if i'm rehashing.
>  
>   seems there's a couple of issues.
>  * i think distel:guess_source_file/2 is correct; if the erl file 
> pointed to by the beam file exists, it's likely the correct one.
>  * when erlc sticks the compilation info in the beam file, it follows links.
>  * int:i/1 insists that the erl and the beam file must be either in the 
> same dir, or in adjacent src/ebin dirs.

All of this work correctly (as i noted in a follow-up message).  The
problem ultimately turned out to be the fact that the following:

-compile([export_all, debug_info]).

in the source file does *not* cause debugging information be be
generated in the beam file.  The export_all option is processed, no
problem, but not the debug_info option.  Apparently, with this
particular option, whatever is specified (or in this case the absence of
specification) on the erlc command line is taken as absolute.

I feel that this is a bug in the behavior of erlc, but it has apparently
been hashed over before with no change.


-- 
paul

Robert Virding's First Rule:
"Any sufficiently complicated concurrent program in another language
contains an ad hoc, informally-specified, bug-ridden, slow
implementation of half of Erlang."



From mats.cronqvist@REDACTED  Fri May 30 13:21:49 2008
From: mats.cronqvist@REDACTED (mats cronqvist)
Date: Fri, 30 May 2008 13:21:49 +0200
Subject: [erlang-questions] distel-mode with *.beam files separate from
 source
In-Reply-To: <1212146250.6409.107.camel@localhost>
References: <1211509773.6476.58.camel@localhost>	 <4836867F.6020002@gmail.com>
	<1211542223.6310.7.camel@localhost>	 <4836BC3A.8040602@gmail.com>
	<1211549163.6310.22.camel@localhost>	 <483FDFA3.1020103@gmail.com>
	<1212146250.6409.107.camel@localhost>
Message-ID: <483FE34D.7000601@gmail.com>

Paul Fisher wrote:
> On Fri, 2008-05-30 at 13:06 +0200, mats cronqvist wrote:
>   
>> Paul Fisher wrote:
>>     
>>> I'm certain that it does have debugging information, so the error
>>> message is really not accurately reflecting the problem, which
>>> ultimately the fact that int:i/1 cannot find any beam file to associate
>>> with the absolute source path name.
>>>
>>> The problem is that distel:find_source/1 in the face of this arrangement
>>> locates the source file as:
>>>
>>>   top/project/application/source.erl
>>>
>>> rather than
>>>
>>>   top/bld/erlang/application/src/source.erl
>>>
>>> Then when it hands the former to the int:i/1 the interpreter does not
>>> know how to find the source.beam file based on that location.
>>>
>>> ...
>>>       
>>   i don't remember if i already answered this; apologies if i'm rehashing.
>>  
>>   seems there's a couple of issues.
>>  * i think distel:guess_source_file/2 is correct; if the erl file 
>> pointed to by the beam file exists, it's likely the correct one.
>>  * when erlc sticks the compilation info in the beam file, it follows links.
>>  * int:i/1 insists that the erl and the beam file must be either in the 
>> same dir, or in adjacent src/ebin dirs.
>>     
>
> All of this work correctly (as i noted in a follow-up message).  

  oops. soory for adding to the noise.

  mats


From per.melin@REDACTED  Fri May 30 13:51:14 2008
From: per.melin@REDACTED (Per Melin)
Date: Fri, 30 May 2008 13:51:14 +0200
Subject: [erlang-questions] eep: multiple patterns
In-Reply-To: <483D0CB6.2080103@ericsson.com>
References: <200805141620.19559.bekesa@sch.bme.hu> <4836A517.2040909@gmail.com>
	
	<200805271436.19305.bekesa@sch.bme.hu>
	<6BA6A9E9-EF89-4FE6-B683-05F3866E9E09@cs.otago.ac.nz>
	<483D0CB6.2080103@ericsson.com>
Message-ID: 

2008/5/28 Ulf Wiger (TN/EAB) :
> At the risk of starting to sound like a broken record,
> I'd very much like to see suggestions that don't further
> encourage programmers to use gen_server-style programming
> where they really ought to be writing selective receive
> clauses (textbook erlang state machines).

Erlang and the BEAM have been very good to me when it comes to
degrading gracefully under too much load, and then returning to normal
once the load decreases. But one thing that has blown up my apps
several times is the performance characteristics of selective receive.

I'm not arguing against selective receive or "textbook erlang state
machines". On the contrary, I only wish I could write them more often.

For most cases it's fine, but still, these days I think long and hard
before I put a process in the state of "I'm going to ignore some
messages while I finish this task."


From ulf.wiger@REDACTED  Fri May 30 14:37:20 2008
From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB))
Date: Fri, 30 May 2008 14:37:20 +0200
Subject: [erlang-questions] eep: multiple patterns
In-Reply-To: 
References: <200805141620.19559.bekesa@sch.bme.hu>
	<4836A517.2040909@gmail.com>	
		
	<200805271436.19305.bekesa@sch.bme.hu>	
	<6BA6A9E9-EF89-4FE6-B683-05F3866E9E09@cs.otago.ac.nz>	
	<483D0CB6.2080103@ericsson.com>
	
Message-ID: <483FF500.3020101@ericsson.com>

Per Melin skrev:
> 
> Erlang and the BEAM have been very good to me when it
 > comes to degrading gracefully under too much load, and
 > then returning to normal once the load decreases. But one
 > thing that has blown up my apps several times is the
 > performance characteristics of selective receive.
> 
> I'm not arguing against selective receive or "textbook
 > erlang state machines". On the contrary, I only wish I
 > could write them more often.
> 
> For most cases it's fine, but still, these days I think
 > long and hard before I put a process in the state of
 > "I'm going to ignore some messages while I finish
 > this task."

Very wise, surely.

Still, the most frequently exercised version of selective
receive in most Erlang programs is of course
gen_server:call().  (:

And in general, that's usually sufficient. Top-level
states should not buffer messages, but rather throw
away anything they don't recognize (optionally exit,
which is what I think a gen_server should usually
do upon receipt of an unknown call or cast.)

If this is not sufficient, I guess it is almost
always because the process is handling more than
one state machine, and the logic might be reduced
to the above by using more processes.

The thing is, though, that since selective receive
is difficult to modularize, and it has known
performance problems if the message queue grows too
large, programmers will have a tendency to avoid it
even when it's absolutely necessary, in which case
they invariably end up either maintaining an impossibly
large state transition matrix, or implement selective
receive themselves (which is guaranteed to have even
worse characteristics than the built-in one.)

BR,
Ulf W


From vychodil.hynek@REDACTED  Fri May 30 14:47:30 2008
From: vychodil.hynek@REDACTED (Hynek Vychodil)
Date: Fri, 30 May 2008 14:47:30 +0200
Subject: [erlang-questions] Sending a message to all linked processes
In-Reply-To: <8f24f4b10805291235r4350e83ey799ff8937735dfb5@mail.gmail.com>
References: <8f24f4b10805291235r4350e83ey799ff8937735dfb5@mail.gmail.com>
Message-ID: <4d08db370805300547m1b6c66b2k88d36db593930125@mail.gmail.com>

you can just write :

[ LP ! Msg || LP <- begin {links, P} = process_info(self(), links), P end ].

or without pattern match check (less reliable way):

[ LP ! Msg || LP <- element(2, process_info(self(), links)) ].

2008/5/29 John Haugeland :

>
> I was wondering if there is a simple and straightforward way to send a
>> message to all linked processes. Now, I am aware that a process exit signal
>> is transmitted in a functionally similar manner, so it seems that at least
>> some form of "broadcast to all linked processes" operation exists within the
>> runtime. But is it possible to invoke such functionality directly from
>> source code?
>>
>
> There may be a better way, but here's how I do it:
>
> get_linked_processes() -> [U] = [V||{links,V}<-process_info(self())], U.
>
> [ LP ! message || LP <- get_linked_processes() ].
>
> I suspect that process_info() isn't particularly cheap, so I recommend
> reconsidering the bookkeeping.
>
>   - John
>
> ---
> GuaranteedVPS.com - bandwidth commitments and root starting from $12.98/mo
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>



-- 
--Hynek (Pichi) Vychodil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From erlang@REDACTED  Fri May 30 16:18:11 2008
From: erlang@REDACTED (Joe Armstrong)
Date: Fri, 30 May 2008 16:18:11 +0200
Subject: [erlang-questions] Twoorl: an open source Twitter clone
In-Reply-To: <17244f480805282212g32eaa0e1o78493087bd12fd0@mail.gmail.com>
References: <17244f480805282212g32eaa0e1o78493087bd12fd0@mail.gmail.com>
Message-ID: <9b08084c0805300718i636d1d8ci4b923ffe335ec8f9@mail.gmail.com>

Hi Yariv

Well done - now a few questions:

    - what is Twitter? and why is it good (if it is good) - can you
explain in a couple of paragraphs what it does? It seemed to be some
kind of new way for interrupting people ...

      (this is from one who thinks that e-mail is intrusive and whose
mobile phone is usually
       turned off :-)

  - the reaction to your work seems to be (oh but it doesn't  scale -
so Erlang must be no good -
    despite the fact that I believe you expressly said it was a quick
hack and wasn't designed to
   scale)

  - I might be nice to say "it doesn't scale YET" - and then sit back
and let us help
    you make it VERY scalable. I like a good challenge.

    Could you try to describe exactly what Twitter is (in an as
abstract way as possible) so that old
fogies like me can wrap our brains around the problem of making it scale -

   So what does it do? How many things must it scale to (give me
numbers here - what are
talking about - scaling is not some abstract quantity - it's number of
bytes of data delivered to end-users
per gram of CO2 - how many bytes/gm of CO2 are we aiming at?)

(aside) What does scalable mean? - I suppose the answer is some
constant cost per user.

A more literal answer would be "doesn't break when we add more users"
- but surely the cost
verses number of users curve must be more important.

In the context of Twitter what does the word "scalable mean" (how
about, we can handle
100,000 users per "box" - each box costs 500$ and consumes 25Watts -
this is constant up to
6x10^9 users)

So if anybody who knows about this stuff can chip in with a few
figures it would be helpful
- what are the desired costs for running twitter for a few million
people - how would you like
this to scale

(/aside)


/Joe Armstrong




On Thu, May 29, 2008 at 7:12 AM, Yariv Sadan  wrote:
> Hi,
>
> I created an open source Twitter clone in Erlang called Twoorl. I
> wrote it on top of ErlyWeb/Yaws.  You can see it at http://twoorl.com.
> The code is at http://code.google.com/p/twoorl.
>
> I'll appreciate any feedback!
>
> Thanks,
> Yariv
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>


From stonecypher@REDACTED  Fri May 30 16:20:54 2008
From: stonecypher@REDACTED (John Haugeland)
Date: Fri, 30 May 2008 08:20:54 -0600
Subject: [erlang-questions] Sending a message to all linked processes
In-Reply-To: <4d08db370805300547m1b6c66b2k88d36db593930125@mail.gmail.com>
References: <8f24f4b10805291235r4350e83ey799ff8937735dfb5@mail.gmail.com>
	<4d08db370805300547m1b6c66b2k88d36db593930125@mail.gmail.com>
Message-ID: <8f24f4b10805300720j369548d3ka3ee8b477fc38e23@mail.gmail.com>

I suppose I could.  However, since I use get_linked_processes() for other
things too, I made a library function out of it several months ago.  When I
answered the question, I just cut and pasted the library function.

When giving code examples, the easier they are to read, the better.  I don't
doubt that the receiving reader could have made that substitution
themselves.



On Fri, May 30, 2008 at 6:47 AM, Hynek Vychodil 
wrote:

> you can just write :
>
> [ LP ! Msg || LP <- begin {links, P} = process_info(self(), links), P end
> ].
>
> or without pattern match check (less reliable way):
>
> [ LP ! Msg || LP <- element(2, process_info(self(), links)) ].
>
> 2008/5/29 John Haugeland :
>
>>
>> I was wondering if there is a simple and straightforward way to send a
>>> message to all linked processes. Now, I am aware that a process exit signal
>>> is transmitted in a functionally similar manner, so it seems that at least
>>> some form of "broadcast to all linked processes" operation exists within the
>>> runtime. But is it possible to invoke such functionality directly from
>>> source code?
>>>
>>
>> There may be a better way, but here's how I do it:
>>
>> get_linked_processes() -> [U] = [V||{links,V}<-process_info(self())], U.
>>
>> [ LP ! message || LP <- get_linked_processes() ].
>>
>> I suspect that process_info() isn't particularly cheap, so I recommend
>> reconsidering the bookkeeping.
>>
>>   - John
>>
>> ---
>> GuaranteedVPS.com - bandwidth commitments and root starting from $12.98/mo
>>
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://www.erlang.org/mailman/listinfo/erlang-questions
>>
>
>
>
> --
> --Hynek (Pichi) Vychodil




-- 
---
GuaranteedVPS.com - bandwidth commitments and root starting from $12.98/mo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From stonecypher@REDACTED  Fri May 30 16:42:13 2008
From: stonecypher@REDACTED (John Haugeland)
Date: Fri, 30 May 2008 08:42:13 -0600
Subject: [erlang-questions] erlang-questions Digest, Vol 12, Issue 98
In-Reply-To: 
References: 
Message-ID: <8f24f4b10805300742r3cda023bi23f0d6fe3b398590@mail.gmail.com>

Forgive my being naive.

Now let's do it with abstract patterns.
>
> #quit() ->       quit;
> #quit() ->       {?MODULE,{signal,{window1,_}}};
> #quit() ->       {?MODULE,{signal,{quit1,_}}}.
>
> #connect() ->    {?MODULE,{signal,{connect,_}}}.
>
> #disconnect() -> {?MODULE,{signal,{disconnect,_}}}.
>
> #show_about() -> {?MODULE,{signal,{about1,_}}}.
>
> #hide_about() -> {?MODULE,{signal,{dialog1,_}}};
> #hide_about() -> {?MODULE,{signal,{dialogb,_}}}.
>
> #data(Data)   -> {data,Data}.
>
>    loop(State) ->
>        receive
>            #quit()       -> quit()
>          ; #connect()    -> loop(conn(State))
>          ; #disconnect() -> loop(disc(State))
>          ; #show_about() -> loop(show_about(State))
>           ; #hide_about() -> loop(hide_about(State))
>          ; #data(Data)   -> loop(update(State, Data))
>           ; X             -> io:fwrite("got ~p~n", [X]),
>                             loop(State)
>        end.
>

So what's the advantage of that over something like this?

isa_quit(State) ->
    case State of
        {?MODULE,{signal,{window1,_}}} -> true;
        {?MODULE,{signal,{quit1,_}  }} -> true;
        _                              -> false
    end.

isa_hide_about(State) ->
    case State of
        {?MODULE,{signal,{dialog1,_}}} -> true;
        {?MODULE,{signal,{dialogb,_}}} -> true;
        _                              -> false
    end.

isa_connect(State)    -> case State of {?MODULE,{signal,{connect,_}}}    ->
true; _ -> false end.
isa_disconnect(State) -> case State of {?MODULE,{signal,{disconnect,_}}} ->
true; _ -> false end.
isa_show_about(State) -> case State of {?MODULE,{signal,{about1,_}}}     ->
true; _ -> false end.

wrap_data(Data) -> {data,Data}.

loop(State) ->
    receive RcvState -> if
        isa_quit(RcvState)       -> quit();
        isa_connect(RcvState)    -> loop(conn(State));
        isa_disconnect(RcvState) -> loop(disc(State));
        isa_show_about(RcvState) -> loop(show_about(State));
        isa_hide_about(RcvState) -> loop(hide_about(State));
        isa_data(RcvState)       -> loop(update(State, RcvState));
        X             -> io:fwrite("got ~p~n", [X]), loop(State)
    end end.

Everything's still named and abstracted, easier to maintain, update and
repair, but this doesn't require new syntax or compiler alterations.  So,
what am I missing?

  - John, who REALLY REALLY WANTS SELECTIVE EXPORT BADLY
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From per.melin@REDACTED  Fri May 30 17:02:03 2008
From: per.melin@REDACTED (Per Melin)
Date: Fri, 30 May 2008 17:02:03 +0200
Subject: [erlang-questions] Twoorl: an open source Twitter clone
In-Reply-To: <9b08084c0805300718i636d1d8ci4b923ffe335ec8f9@mail.gmail.com>
References: <17244f480805282212g32eaa0e1o78493087bd12fd0@mail.gmail.com>
	<9b08084c0805300718i636d1d8ci4b923ffe335ec8f9@mail.gmail.com>
Message-ID: 

2008/5/30 Joe Armstrong :
>  - what is Twitter?

It was launched as a "micro-blogging" service. Each post is limited to
140 characters (like an SMS).

Users can follow what others post with RSS, SMS, instant messaging,
desktop applications (through an API), email or on the Twitter
website.

Some users have tens of thousands of "followers" and some follow
thousands of people.


>  - the reaction to your work seems to be (oh but it doesn't  scale -
> so Erlang must be no good -
>    despite the fact that I believe you expressly said it was a quick
> hack and wasn't designed to
>   scale)

I think the reason for this is because Twitter is plagued with daily
outages because they can't handle the load, and the internets have
been filled with speculation on why this is, and how these problems
could be avoided. In these discussions you can often find a commenter
saying that they would've used Erlang and that would've solved all
problems more or less automagically.


>   So what does it do? How many things must it scale to (give me
> numbers here - what are
> talking about - scaling is not some abstract quantity - it's number of
> bytes of data delivered to end-users
> per gram of CO2 - how many bytes/gm of CO2 are we aiming at?)

In March Twitter had on average 200 000 users per week with 3 million
messages sent per day.

They have raised $20 million in venture capital to a $100 million
valuation. So they can afford to buy hardware.


From sean.hinde@REDACTED  Fri May 30 17:06:13 2008
From: sean.hinde@REDACTED (Sean Hinde)
Date: Fri, 30 May 2008 16:06:13 +0100
Subject: [erlang-questions] eep: multiple patterns
In-Reply-To: <483FF500.3020101@ericsson.com>
References: <200805141620.19559.bekesa@sch.bme.hu>
	<4836A517.2040909@gmail.com>	
		
	<200805271436.19305.bekesa@sch.bme.hu>	
	<6BA6A9E9-EF89-4FE6-B683-05F3866E9E09@cs.otago.ac.nz>	
	<483D0CB6.2080103@ericsson.com>
	
	<483FF500.3020101@ericsson.com>
Message-ID: 


On 30 May 2008, at 13:37, Ulf Wiger (TN/EAB) wrote:

> Per Melin skrev:
>>
>> Erlang and the BEAM have been very good to me when it
>> comes to degrading gracefully under too much load, and
>> then returning to normal once the load decreases. But one
>> thing that has blown up my apps several times is the
>> performance characteristics of selective receive.
>>
>> I'm not arguing against selective receive or "textbook
>> erlang state machines". On the contrary, I only wish I
>> could write them more often.
>>
>> For most cases it's fine, but still, these days I think
>> long and hard before I put a process in the state of
>> "I'm going to ignore some messages while I finish
>> this task."
>
> The thing is, though, that since selective receive
> is difficult to modularize, and it has known
> performance problems if the message queue grows too
> large, programmers will have a tendency to avoid it
> even when it's absolutely necessary, in which case
> they invariably end up either maintaining an impossibly
> large state transition matrix, or implement selective
> receive themselves (which is guaranteed to have even
> worse characteristics than the built-in one.)

As I understand it, the problem of poor performance with large message  
queues is not specifically related to selective receive, but is  
related to garbage collection of a large queue however it grows.

Use of selective receive may or may not make it more likely that a  
queue will grow, that depends on the design of the application.

In my experience the biggest causes of unbounded queue growth are when  
one (or more) processes or external inputs overwhelm another process  
with messages in a heavily loaded system. Nothing to do with selective  
receive, more likely using {active true} on a socket or such like.

Sean



From matthew@REDACTED  Fri May 30 17:27:26 2008
From: matthew@REDACTED (Matthew Dempsky)
Date: Fri, 30 May 2008 08:27:26 -0700
Subject: [erlang-questions] Flymake & include_lib
In-Reply-To: 
References: <97FC8F79-3215-4444-933A-6A93A1682EFF@hypotheticalabs.com>
	<1567789778.20080529164445@gmail.com> <483EC6D2.1080101@rldn.net>
	
Message-ID: 

On Thu, May 29, 2008 at 9:26 AM, Anders Nygren  wrote:
> main([File_Name]) ->
>   Incls = [{i,Dir} || Dir <- filelib:wildcard("../../*/include")],
>   compile:file(File_Name, Incls++[warn_obsolete_guard,
>                            warn_unused_import,
>                            warn_shadow_vars,
>                            warn_export_vars,
>                            strong_validation,
>                            report]).

You'd be better off adding ../../*/ebin to the code path and using
-include_lib how it's intended to be used.


From per.melin@REDACTED  Fri May 30 17:38:34 2008
From: per.melin@REDACTED (Per Melin)
Date: Fri, 30 May 2008 17:38:34 +0200
Subject: [erlang-questions] eep: multiple patterns
In-Reply-To: 
References: <200805141620.19559.bekesa@sch.bme.hu> <4836A517.2040909@gmail.com>
	
	<200805271436.19305.bekesa@sch.bme.hu>
	<6BA6A9E9-EF89-4FE6-B683-05F3866E9E09@cs.otago.ac.nz>
	<483D0CB6.2080103@ericsson.com>
	
	<483FF500.3020101@ericsson.com>
	
Message-ID: 

2008/5/30 Sean Hinde :
> As I understand it, the problem of poor performance with large message
> queues is not specifically related to selective receive, but is related to
> garbage collection of a large queue however it grows.

If I send 100k 'foo' messages and then 100k 'bar' messages to a
process, and then do a catch-all receive until there are no messages
left, that takes 0.03 seconds.

If I do a selective receive of only the 'bar' messages, it takes 90 seconds.


From mark.peleus@REDACTED  Fri May 30 17:58:09 2008
From: mark.peleus@REDACTED (mark peleus)
Date: Fri, 30 May 2008 18:58:09 +0300
Subject: [erlang-questions] CMS based on erlang
Message-ID: <599dd3e0805300858l28811bc9rb6baa0ad7bf4334b@mail.gmail.com>

Hi,

Is erlang suitable for building a CMS (content management system)?
drupal  is a fantastic example for an open source CMS
that is easily extensible with impressive features out of the box.

The thread about the Twitter clone made me wonder if erlang could supply a
CMS that is
scalable fault tolerant and can support features like COMET.

I'm new to erlang so a discussion about this topic could clear allot for me.

Are there fundamental limitations in erlang in this area or is it just
doesn't fit for a CMS?

Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From sean.hinde@REDACTED  Fri May 30 18:01:45 2008
From: sean.hinde@REDACTED (Sean Hinde)
Date: Fri, 30 May 2008 17:01:45 +0100
Subject: [erlang-questions] eep: multiple patterns
In-Reply-To: 
References: <200805141620.19559.bekesa@sch.bme.hu> <4836A517.2040909@gmail.com>
	
	<200805271436.19305.bekesa@sch.bme.hu>
	<6BA6A9E9-EF89-4FE6-B683-05F3866E9E09@cs.otago.ac.nz>
	<483D0CB6.2080103@ericsson.com>
	
	<483FF500.3020101@ericsson.com>
	
	
Message-ID: <00B21EFF-74F9-41FA-A35D-6E3218F397CB@gmail.com>


On 30 May 2008, at 16:38, Per Melin wrote:

> 2008/5/30 Sean Hinde :
>> As I understand it, the problem of poor performance with large  
>> message
>> queues is not specifically related to selective receive, but is  
>> related to
>> garbage collection of a large queue however it grows.
>
> If I send 100k 'foo' messages and then 100k 'bar' messages to a
> process, and then do a catch-all receive until there are no messages
> left, that takes 0.03 seconds.
>
> If I do a selective receive of only the 'bar' messages, it takes 90  
> seconds.

There is no contradiction here. In the first test the message queue  
never grows so you do not get a slowdown.

Badly designed use of selective receive is one way to fill a message  
queue, but by no means the only way. As I understand it once a message  
has been examined and not matched it is not visited again until the  
pattern changes.

I believe that the slowdown you see is because the garbage collector  
is working very hard dealing with all the messages on the live heap.

Note I say "believe" here. This is how it was explained to me by  
someone who should know. I have not instrumented the system to prove  
it to myself.

Sean


From per.melin@REDACTED  Fri May 30 18:07:18 2008
From: per.melin@REDACTED (Per Melin)
Date: Fri, 30 May 2008 18:07:18 +0200
Subject: [erlang-questions] eep: multiple patterns
In-Reply-To: 
References: <200805141620.19559.bekesa@sch.bme.hu> <4836A517.2040909@gmail.com>
	
	<200805271436.19305.bekesa@sch.bme.hu>
	<6BA6A9E9-EF89-4FE6-B683-05F3866E9E09@cs.otago.ac.nz>
	<483D0CB6.2080103@ericsson.com>
	
	<483FF500.3020101@ericsson.com>
	
	
Message-ID: 

2008/5/30 Per Melin :
> If I send 100k 'foo' messages and then 100k 'bar' messages to a
> process, and then do a catch-all receive until there are no messages
> left, that takes 0.03 seconds.
>
> If I do a selective receive of only the 'bar' messages, it takes 90 seconds.

I found my old test code:

-module(selective).

-export([a/2, c/2]).

a(Atom, N) ->
    spawn(fun() -> b(Atom, N) end).

b(Atom, N) ->
    spam_me(foo, N),
    spam_me(bar, N),
    R = timer:tc(?MODULE, c, [Atom, N]),
    io:format("TC: ~p~n", [R]).

c(Atom, N) ->
    receive
        Atom -> c(Atom, N - 1)
    after 0 ->
        N
    end.

spam_me(Msg, Copies) ->
    lists:foreach(fun(_) -> self() ! Msg end, lists:duplicate(Copies, 0)).

---

2> selective:a(bar, 100000).
<0.38.0>
TC: {124130689,0}
3> selective:a(foo, 100000).
<0.40.0>
TC: {23176,0}


From patrickdlogan@REDACTED  Fri May 30 18:23:57 2008
From: patrickdlogan@REDACTED (Patrick Logan)
Date: Fri, 30 May 2008 09:23:57 -0700
Subject: [erlang-questions] Twoorl: an open source Twitter clone
Message-ID: 

"I might be nice to say "it doesn't scale YET" - and then sit back and
let us help you make it VERY scalable. I like a good challenge."

Another angle on this is to use ejabberd and XMPP. The XMPP folks are
interested in "micro-blogging", ejabberd is scalable, and XMPP itself
is federated. So why build an all-new system when the IETF has already
blessed a protocol for "micro-blogging"?

To match more of Twitter's features though, the system has to go
beyond XMPP per se and integrate with the web, with SMS, etc. That
could come along gradually, but I'm not sure why all of this shouldn't
be based on XMPP at the core of it?

Demo this on top of ejabberd and yaws as two key, scalable subsystems
within an overall "micro-blogging" architecture, so to speak.

-Patrick


From paul-trapexit@REDACTED  Fri May 30 18:57:31 2008
From: paul-trapexit@REDACTED (Paul Mineiro)
Date: Fri, 30 May 2008 09:57:31 -0700 (PDT)
Subject: [erlang-questions] flat representation with erlang term order
Message-ID: 

i'm trying to develop a disk based erlang term storage (dets replacement)
using tokyocabinet. i would like the b+tree to be sorted according to
erlang term order to make certain selects cheap.

i noticed that erlang:term_to_binary/1 does not preserve term order, i.e.,
comparing the resulting binaries with memcmp sometimes disagrees with
erlang term order.[1]  so the easy way is out.

some questions:

  * is there another flat representation of an erlang term available which
preserves erlang term order via memcmp?

  * alternatively, is there a function i can call from a linked-in driver
to compare two binaries derived from erlang:term_to_binary/1 which
corresponds to erlang term order?  tokyocabinet can use an arbitrary
comparison function (on bytes) so this could work.

other ideas would also be appreciated.

thanks,

-- p

[1]

6> A = 16#10000000ff01.
17592186109697
7> B = 16#100000000002.
17592186044418
8> A < B.
false
9> BA = term_to_binary (A).
<<131,110,6,0,1,255,0,0,0,16>>
10> BB = term_to_binary (B).
<<131,110,6,0,2,0,0,0,0,16>>
11> BA < BB.
true


In an artificial world, only extremists live naturally.

        -- Paul Graham


From per.melin@REDACTED  Fri May 30 19:00:00 2008
From: per.melin@REDACTED (Per Melin)
Date: Fri, 30 May 2008 19:00:00 +0200
Subject: [erlang-questions] Twoorl: an open source Twitter clone
In-Reply-To: 
References: 
Message-ID: 

2008/5/30 Patrick Logan :
> Another angle on this is to use ejabberd and XMPP.

Can you send a message with XMPP/ejabberd to a client that is not
online? If not, that will get you nowhere.

As far as I know (which in this case isn't far), Twitter already uses
ejabberd, but only to communicate with Jabber IM clients.

Someone from Twitter gave a presentation in 2007 called "Scaling
Twitter" which had a slide on Erlang as an alternative (to Ruby +
MySQL). It said: "What are you doing? Stabbing my eyes out with a
fork."

I guess they did have a quick look, and nothing more, at Erlang.


From sean.hinde@REDACTED  Fri May 30 19:30:03 2008
From: sean.hinde@REDACTED (Sean Hinde)
Date: Fri, 30 May 2008 18:30:03 +0100
Subject: [erlang-questions] flat representation with erlang term order
In-Reply-To: 
References: 
Message-ID: 


On 30 May 2008, at 17:57, Paul Mineiro wrote:

> i'm trying to develop a disk based erlang term storage (dets  
> replacement)
> using tokyocabinet. i would like the b+tree to be sorted according to
> erlang term order to make certain selects cheap.
>
> i noticed that erlang:term_to_binary/1 does not preserve term order,  
> i.e.,
> comparing the resulting binaries with memcmp sometimes disagrees with
> erlang term order.[1]  so the easy way is out.
>
>
>  * alternatively, is there a function i can call from a linked-in  
> driver
> to compare two binaries derived from erlang:term_to_binary/1 which
> corresponds to erlang term order?  tokyocabinet can use an arbitrary
> comparison function (on bytes) so this could work.

There is a C function erl_compare_ext/2 available in the erl_interface  
application. You will need to ensure that everything is in the right  
format, but once you achieve that, this is probably what you want :-)

Sean



From raould@REDACTED  Fri May 30 21:09:38 2008
From: raould@REDACTED (Raoul Duke)
Date: Fri, 30 May 2008 12:09:38 -0700
Subject: [erlang-questions] eep: multiple patterns
In-Reply-To: <483FB9E0.80504@ericsson.com>
References: <200805141620.19559.bekesa@sch.bme.hu>
	<200805271436.19305.bekesa@sch.bme.hu>
	<6BA6A9E9-EF89-4FE6-B683-05F3866E9E09@cs.otago.ac.nz>
	<483D0CB6.2080103@ericsson.com>
	
	<483E50BC.2060902@ericsson.com>
	<61214.63.82.98.51.1212092630.squirrel@mail.webfaction.com>
	<483F1E59.4090007@ericsson.com>
	
	<483FB9E0.80504@ericsson.com>
Message-ID: <91a2ba3e0805301209l81122adhe60b59fe7205cb81@mail.gmail.com>

>         %% Special case for HCMSG_RELEASE to avoid deadlock

super newbie question: in general, how do folks approach finding and
fixing deadlock issues in Erlang?

thanks. :)


From ulf.wiger@REDACTED  Fri May 30 23:06:25 2008
From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB))
Date: Fri, 30 May 2008 23:06:25 +0200
Subject: [erlang-questions] finding deadlocks (Re: eep: multiple patterns)
In-Reply-To: <91a2ba3e0805301209l81122adhe60b59fe7205cb81@mail.gmail.com>
References: <200805141620.19559.bekesa@sch.bme.hu>	<200805271436.19305.bekesa@sch.bme.hu>	<6BA6A9E9-EF89-4FE6-B683-05F3866E9E09@cs.otago.ac.nz>	<483D0CB6.2080103@ericsson.com>		<483E50BC.2060902@ericsson.com>	<61214.63.82.98.51.1212092630.squirrel@mail.webfaction.com>	<483F1E59.4090007@ericsson.com>		<483FB9E0.80504@ericsson.com>
	<91a2ba3e0805301209l81122adhe60b59fe7205cb81@mail.gmail.com>
Message-ID: <48406C51.6080203@ericsson.com>

Raoul Duke skrev:
>>         %% Special case for HCMSG_RELEASE to avoid deadlock
> 
> super newbie question: in general, how do folks approach finding and
> fixing deadlock issues in Erlang?
> 
> thanks. :)

We're straying from the multiple patterns thread,
so I changed the subject.

There are different kinds of deadlock.

http://img209.imageshack.us/img209/5781/deadlocknajkcomafarialibh3.jpg

One trivial form of deadlock in erlang is when
two processes call each other synchronously at the same
time. The nice way to try to avoid this is of course
to strive to only allow synchronous calls in one
direction. The low-level safety is to use gen_server:call()
and avoid using timeout 'infinity'. This way, at least
you will get a timeout and a crash report, alerting you of
the problem.

Programming entirely asynchronously, deadlocks can still
occur, but are harder to detect. Finding such deadlocks
is easier if transient states are signified by the name
of the function. Then, a process listing can help,
looking at the current function.

If a process is blocked in a receive clause, and it's
not clear what it's waiting for, sometimes a stack
trace (process_info(Pid, backtrace)) can help, but it's
a bit messy.

BR,
Ulf W


From miniboo@REDACTED  Fri May 30 23:30:29 2008
From: miniboo@REDACTED (Jennifer Bakker)
Date: Fri, 30 May 2008 14:30:29 -0700
Subject: [erlang-questions] troubleshoot install - odbc error
Message-ID: <9f6423c0805301430i33679352lc662a78f4e05d74d@mail.gmail.com>

Hi,

I am having some problems installing erlang/otp on my macbook pro.  Once I
unzip the binary distribution and try to run the configure command, I get an
error that looks like the following:

********************************************************************
**********************  APPLICATIONS DISABLED  **********************
*********************************************************************

odbc           : ODBC library - link check failed

*********************************************************************

Any help would be appreciated.

Thank You,

Jennifer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From raould@REDACTED  Fri May 30 23:33:49 2008
From: raould@REDACTED (Raoul Duke)
Date: Fri, 30 May 2008 14:33:49 -0700
Subject: [erlang-questions] finding deadlocks (Re: eep: multiple
	patterns)
In-Reply-To: <48406C51.6080203@ericsson.com>
References: <200805141620.19559.bekesa@sch.bme.hu>
	<483D0CB6.2080103@ericsson.com>
	
	<483E50BC.2060902@ericsson.com>
	<61214.63.82.98.51.1212092630.squirrel@mail.webfaction.com>
	<483F1E59.4090007@ericsson.com>
	
	<483FB9E0.80504@ericsson.com>
	<91a2ba3e0805301209l81122adhe60b59fe7205cb81@mail.gmail.com>
	<48406C51.6080203@ericsson.com>
Message-ID: <91a2ba3e0805301433v1b36bcb1yaa016e5ac59f60b0@mail.gmail.com>

hi,

> a bit messy.

Many thanks for the note.

Are there any tools folks do/might use in the Erlang field for
deadlock type issues e.g. state machine models + checking? I guess
there's the classic/holy-grail issue of having something where the
code + model are somehow magically kept in sync as changes are made to
either one.

sincerely.


From o.j.mason@REDACTED  Sat May 31 00:09:02 2008
From: o.j.mason@REDACTED (Oliver Mason)
Date: Fri, 30 May 2008 23:09:02 +0100
Subject: [erlang-questions] [Announce] yaml-erlang
Message-ID: <73768eac0805301509i699fe731s25b36bd2ca93ae4a@mail.gmail.com>

I've started writing a module to read in yaml files (see
http://www.yaml.org/);  the project is currently hosted on
http://code.google.com/p/yaml-erlang/
Version 0.1 can process basic lists and mappings (no
short-cuts/in-line variants yet).

Oliver


From manghwani@REDACTED  Sat May 31 00:35:18 2008
From: manghwani@REDACTED (Prakash Manghwani)
Date: Fri, 30 May 2008 18:35:18 -0400
Subject: [erlang-questions] erlang-questions Digest, Vol 12, Issue 102
In-Reply-To: 
References: 
Message-ID: <6fba5e310805301535q13954b7bm5ac8b6117ce3524a@mail.gmail.com>

Hello,

With respect to avoiding deadlocks or ensuring there are none, I would
design my system based on CSP (Communicating sequential processes)
concepts. i.e Independent processes communicating via a pipe without
any shared memory.

Prakash

> Message: 10
> Date: Fri, 30 May 2008 14:33:49 -0700
> From: "Raoul Duke" 
> Subject: Re: [erlang-questions] finding deadlocks (Re: eep: multiple
>        patterns)
> To: "Ulf Wiger (TN/EAB)" 
> Cc: Erlang mailing list 
> Message-ID:
>        <91a2ba3e0805301433v1b36bcb1yaa016e5ac59f60b0@REDACTED>
> Content-Type: text/plain; charset=ISO-8859-1
>
> hi,
>
>> a bit messy.
>
> Many thanks for the note.
>
> Are there any tools folks do/might use in the Erlang field for
> deadlock type issues e.g. state machine models + checking? I guess
> there's the classic/holy-grail issue of having something where the
> code + model are somehow magically kept in sync as changes are made to
> either one.
>
> sincerely.
>
>
> ------------------------------


From raould@REDACTED  Sat May 31 00:44:14 2008
From: raould@REDACTED (Raoul Duke)
Date: Fri, 30 May 2008 15:44:14 -0700
Subject: [erlang-questions] erlang-questions Digest, Vol 12, Issue 102
In-Reply-To: <6fba5e310805301535q13954b7bm5ac8b6117ce3524a@mail.gmail.com>
References: 
	<6fba5e310805301535q13954b7bm5ac8b6117ce3524a@mail.gmail.com>
Message-ID: <91a2ba3e0805301544q225a9b9bx71b096a5bbaf3c81@mail.gmail.com>

hi,

> With respect to avoiding deadlocks or ensuring there are none, I would
> design my system based on CSP (Communicating sequential processes)
> concepts. i.e Independent processes communicating via a pipe without
> any shared memory.

I believe that's sort of what Erlang does by nature ;-) so it is then
a question of what modeling tools exist and how well they work. It
isn't enough to design with CSP, you can still create deadlocks in it
- you have to run a checker over it to try to prove there isn't any.

sincerely.


From masterofquestions@REDACTED  Sat May 31 00:50:40 2008
From: masterofquestions@REDACTED (db)
Date: Fri, 30 May 2008 18:50:40 -0400
Subject: [erlang-questions] cacherl memcached app startup problem question
Message-ID: <1218d6a50805301550u50ddc883l4e07607c2e70f760@mail.gmail.com>

I am not sure what the problem is.  Mnesia directory actually gets
created at /var/mensia/cacherl@REDACTED but there is no content.
Is this something to do with disc_copies and any reason for using
disc_copies rather than ram_copies?  Another question, does cacherl
work with mysql memcached engine?

[a@REDACTED cacherl]# ./start.sh
Erlang (BEAM) emulator version 5.6.1 [source] [smp:2]
[async-threads:30] [hipe] [kernel-poll:true]

Eshell V5.6.1  (abort with ^G)
(cacherl@REDACTED)1>
=INFO REPORT==== 30-May-2008::17:16:51 ===
Creating mnesia table ns_default

=SUPERVISOR REPORT==== 30-May-2008::17:16:51 ===
     Supervisor: {local,memcached}
     Context:    start_error
     Reason:     {{badmatch,
                      {aborted,
                          {bad_type,ns_default,disc_copies,
                              'cacherl@REDACTED'}}},
                  [{memcached_mnesia,init_mnesia_table,2},
                   {memcached_mnesia,init,1},
                   {gen_server,init_it,6},
                   {proc_lib,init_p,5}]}
     Offender:   [{pid,undefined},
                  {name,memcached_mnesia},
                  {mfa,{memcached_mnesia,start_link,[]}},
                  {restart_type,permanent},
                  {shutdown,2000},
                  {child_type,worker}]


=CRASH REPORT==== 30-May-2008::17:16:51 ===
  crasher:
    pid: <0.69.0>
    registered_name: []
    exception exit: {shutdown,{memcached,start,[normal,[]]}}
      in function  application_master:init/4
    initial call: application_master:init(<0.6.0>,<0.68.0>,
                                          {appl_data,memcached,
                                           [memcached,memcached_mnesia],
                                           undefined,
                                           {memcached,[]},
                                           [memcached,memcached_mnesia,
                                            memcached_stats,memcached_util,
                                            memcached_purge,memcached_reader],
                                           [],infinity,infinity},
                                          normal)
    ancestors: [<0.68.0>]
    messages: [{'EXIT',<0.70.0>,normal}]
    links: [<0.68.0>,<0.6.0>]
    dictionary: []
    trap_exit: true
    status: running
    heap_size: 377
    stack_size: 23
    reductions: 87
  neighbours:

=INFO REPORT==== 30-May-2008::17:16:51 ===
    application: memcached
    exited: {shutdown,{memcached,start,[normal,[]]}}
    type: temporary

=INFO REPORT==== 30-May-2008::17:16:51 ===
started TCP listener on 0.0.0.0:11311


-- 
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


From sean.hinde@REDACTED  Sat May 31 01:52:41 2008
From: sean.hinde@REDACTED (Sean Hinde)
Date: Sat, 31 May 2008 00:52:41 +0100
Subject: [erlang-questions] eep: multiple patterns
In-Reply-To: 
References: <200805141620.19559.bekesa@sch.bme.hu> <4836A517.2040909@gmail.com>
	
	<200805271436.19305.bekesa@sch.bme.hu>
	<6BA6A9E9-EF89-4FE6-B683-05F3866E9E09@cs.otago.ac.nz>
	<483D0CB6.2080103@ericsson.com>
	
	<483FF500.3020101@ericsson.com>
	
	
	
Message-ID: 

You are right.

I had thought that there was an optimisation where if the pattern was  
identical to last time the same receive was entered for that process  
then only newer messages were examined.

Seems like it could be a useful optimisation in any case :-)

Sean

On 30 May 2008, at 17:07, Per Melin wrote:

> 2008/5/30 Per Melin :
>> If I send 100k 'foo' messages and then 100k 'bar' messages to a
>> process, and then do a catch-all receive until there are no messages
>> left, that takes 0.03 seconds.
>>
>> If I do a selective receive of only the 'bar' messages, it takes 90  
>> seconds.
>
> I found my old test code:
>
> -module(selective).
>
> -export([a/2, c/2]).
>
> a(Atom, N) ->
>    spawn(fun() -> b(Atom, N) end).
>
> b(Atom, N) ->
>    spam_me(foo, N),
>    spam_me(bar, N),
>    R = timer:tc(?MODULE, c, [Atom, N]),
>    io:format("TC: ~p~n", [R]).
>
> c(Atom, N) ->
>    receive
>        Atom -> c(Atom, N - 1)
>    after 0 ->
>        N
>    end.
>
> spam_me(Msg, Copies) ->
>    lists:foreach(fun(_) -> self() ! Msg end, lists:duplicate(Copies,  
> 0)).
>
> ---
>
> 2> selective:a(bar, 100000).
> <0.38.0>
> TC: {124130689,0}
> 3> selective:a(foo, 100000).
> <0.40.0>
> TC: {23176,0}



From nick@REDACTED  Sat May 31 01:53:45 2008
From: nick@REDACTED (Nick Gerakines)
Date: Fri, 30 May 2008 16:53:45 -0700
Subject: [erlang-questions] [Announce] yaml-erlang
In-Reply-To: <73768eac0805301509i699fe731s25b36bd2ca93ae4a@mail.gmail.com>
References: <73768eac0805301509i699fe731s25b36bd2ca93ae4a@mail.gmail.com>
Message-ID: 

Oliver,

Nice! It looks like you havn't checked in anything to the Google Code
project. Is there an ETA on that?

# Nick Gerakines

On Fri, May 30, 2008 at 3:09 PM, Oliver Mason  wrote:
> I've started writing a module to read in yaml files (see
> http://www.yaml.org/);  the project is currently hosted on
> http://code.google.com/p/yaml-erlang/
> Version 0.1 can process basic lists and mappings (no
> short-cuts/in-line variants yet).
>
> Oliver
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>


From bob@REDACTED  Sat May 31 02:04:09 2008
From: bob@REDACTED (Bob Ippolito)
Date: Fri, 30 May 2008 17:04:09 -0700
Subject: [erlang-questions] [Announce] yaml-erlang
In-Reply-To: 
References: <73768eac0805301509i699fe731s25b36bd2ca93ae4a@mail.gmail.com>
	
Message-ID: <6a36e7290805301704v70f3710fyd76b36388616f0d2@mail.gmail.com>

There's a tarball in the download section

On Fri, May 30, 2008 at 4:53 PM, Nick Gerakines  wrote:
> Oliver,
>
> Nice! It looks like you havn't checked in anything to the Google Code
> project. Is there an ETA on that?
>
> # Nick Gerakines
>
> On Fri, May 30, 2008 at 3:09 PM, Oliver Mason  wrote:
>> I've started writing a module to read in yaml files (see
>> http://www.yaml.org/);  the project is currently hosted on
>> http://code.google.com/p/yaml-erlang/
>> Version 0.1 can process basic lists and mappings (no
>> short-cuts/in-line variants yet).
>>
>> Oliver
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://www.erlang.org/mailman/listinfo/erlang-questions
>>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>


From chsu79@REDACTED  Sat May 31 02:17:57 2008
From: chsu79@REDACTED (Christian S)
Date: Sat, 31 May 2008 02:17:57 +0200
Subject: [erlang-questions] troubleshoot install - odbc error
In-Reply-To: <9f6423c0805301430i33679352lc662a78f4e05d74d@mail.gmail.com>
References: <9f6423c0805301430i33679352lc662a78f4e05d74d@mail.gmail.com>
Message-ID: 

> **********************  APPLICATIONS DISABLED  **********************
> odbc           : ODBC library - link check failed

The configue-script will auto-detect if it can build some optional
applications.

No odbc library could be found on your macbook, so odbc has been disabled.

You can proceed and build (and the odbc application will not be included).


I've seen many reports similar to yours in other forums, so I ask you,
what made you percieve this was a no-go error?

PS
odbc is of interest if you need to connect to SQL-databases


From christopher316@REDACTED  Sat May 31 03:02:45 2008
From: christopher316@REDACTED (Christopher Atkins)
Date: Fri, 30 May 2008 21:02:45 -0400
Subject: [erlang-questions] eep: multiple patterns
Message-ID: <39aa3ff20805301802l7eabf4cajd76c956dd9c57755@mail.gmail.com>

Hello, I tried (poorly--I'm a complete novice) to implement a benchmark from
your earlier statement.  I didn't do the same thing (load up the message
mailbox before consuming them), but what I did write led to a perplexing (to
me) discovery.  If I uncomment the line in [loop1/0] below, performance for
that loop degrades by an order of magnitude.  Why is that?

-module(test_receive).
-compile(export_all).

start() ->
        statistics(runtime),
        statistics(wall_clock),
        PidLoop1 = spawn(?MODULE, loop1,[]),
        sender(PidLoop1, 10000000),
        {_, Loop1Time1} = statistics(runtime),
        {_, Loop1Time2} = statistics(wall_clock),
        io:format("Sent ~p messages in ~p /~p~n", [100000, Loop1Time1,
Loop1Time2]),
        statistics(runtime),
        statistics(wall_clock),
        PidLoop2 = spawn(?MODULE, loop2,[]),
        sender(PidLoop2, 10000000),
        {_, Loop2Time1} = statistics(runtime),
        {_, Loop2Time2} = statistics(wall_clock),
        io:format("Sent ~p messages in ~p /~p~n", [100000, Loop2Time1,
Loop2Time2]).

sender(_, 0) -> void;
sender(Pid, N) ->
        if
          N rem 2 =:= 2 ->
                Pid ! test2;
          true ->
                Pid ! test1
        end,
        sender(Pid, N - 1).

proc1(F) ->
        receive
                start -> spawn_link(F)
        end.

loop1() ->
        receive
                %%test1 -> loop1();
                test2 -> loop1()
        end.

loop2() ->
        receive
                _ -> loop2()
        end.


------------------------------------------------------------------------------------------------------------------------------
Message: 2
Date: Fri, 30 May 2008 18:07:18 +0200
From: "Per Melin" 
Subject: Re: [erlang-questions] eep: multiple patterns
To: "Sean Hinde" 
Cc: Erlang Questions 
Message-ID:
       
Content-Type: text/plain; charset=ISO-8859-1

2008/5/30 Per Melin :
> If I send 100k 'foo' messages and then 100k 'bar' messages to a
> process, and then do a catch-all receive until there are no messages
> left, that takes 0.03 seconds.
>
> If I do a selective receive of only the 'bar' messages, it takes 90
seconds.

I found my old test code:

-module(selective).

-export([a/2, c/2]).

a(Atom, N) ->
   spawn(fun() -> b(Atom, N) end).

b(Atom, N) ->
   spam_me(foo, N),
   spam_me(bar, N),
   R = timer:tc(?MODULE, c, [Atom, N]),
   io:format("TC: ~p~n", [R]).

c(Atom, N) ->
   receive
       Atom -> c(Atom, N - 1)
   after 0 ->
       N
   end.

spam_me(Msg, Copies) ->
   lists:foreach(fun(_) -> self() ! Msg end, lists:duplicate(Copies, 0)).

---

2> selective:a(bar, 100000).
<0.38.0>
TC: {124130689,0}
3> selective:a(foo, 100000).
<0.40.0>
TC: {23176,0}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From dizzyd@REDACTED  Sat May 31 04:51:35 2008
From: dizzyd@REDACTED (Dave Smith)
Date: Fri, 30 May 2008 20:51:35 -0600
Subject: [erlang-questions] Twoorl: an open source Twitter clone
In-Reply-To: 
References: <17244f480805282212g32eaa0e1o78493087bd12fd0@mail.gmail.com>
	<9b08084c0805300718i636d1d8ci4b923ffe335ec8f9@mail.gmail.com>
	
Message-ID: 

On Fri, May 30, 2008 at 9:02 AM, Per Melin  wrote:
> 2008/5/30 Joe Armstrong :
>>  - what is Twitter?
>
> It was launched as a "micro-blogging" service. Each post is limited to
> 140 characters (like an SMS).
>
> Users can follow what others post with RSS, SMS, instant messaging,
> desktop applications (through an API), email or on the Twitter
> website.
>
> Some users have tens of thousands of "followers" and some follow
> thousands of people.

Twitter is basically a large-scale notification problem -- N people
wanting to know most recent status of M other people, where the rate
of status change is high (multiple changes per minute) and the latency
of notification must be low. Furthermore, not all parties are
necessarily "online" at any given moment, so some sort of
store-and-forward must be present such that changes are not missed.

My understanding is that the reason they have such poor uptime is due
to the fact that they modeled the problem as a web-app instead of a
messaging system. Compounded on this poor design choice is that they
have achieved success and so are experiencing record growth every
month -- i.e. no time to recover from past success. :)

Certainly Erlang would be a great foundation for Twitter, but
honestly, the problem they have is not one of language choice so much
as correctly identifying the characteristics of the problem.  Along
these lines, twoorl repeats this mistake by modeling it as a web-app
instead of a messaging system, but again..just an opinion. :)

D.


From dizzyd@REDACTED  Sat May 31 04:51:27 2008
From: dizzyd@REDACTED (Dave Smith)
Date: Fri, 30 May 2008 20:51:27 -0600
Subject: [erlang-questions] Twoorl: an open source Twitter clone
In-Reply-To: 
References: <17244f480805282212g32eaa0e1o78493087bd12fd0@mail.gmail.com>
	<9b08084c0805300718i636d1d8ci4b923ffe335ec8f9@mail.gmail.com>
	
Message-ID: 

On Fri, May 30, 2008 at 9:02 AM, Per Melin  wrote:
> 2008/5/30 Joe Armstrong :
>>  - what is Twitter?
>
> It was launched as a "micro-blogging" service. Each post is limited to
> 140 characters (like an SMS).
>
> Users can follow what others post with RSS, SMS, instant messaging,
> desktop applications (through an API), email or on the Twitter
> website.
>
> Some users have tens of thousands of "followers" and some follow
> thousands of people.

Twitter is basically a large-scale notification problem -- N people
wanting to know most recent status of M other people, where the rate
of status change is high (multiple changes per minute) and the latency
of notification must be low. Furthermore, not all parties are
necessarily "online" at any given moment, so some sort of
store-and-forward must be present such that changes are not missed.

My understanding is that the reason they have such poor uptime is due
to the fact that they modeled the problem as a web-app instead of a
messaging system. Compounded on this poor design choice is that they
have achieved success and so are experiencing record growth every
month -- i.e. no time to recover from past success. :)

Certainly Erlang would be a great foundation for Twitter, but
honestly, the problem they have is not one of language choice so much
as correctly identifying the characteristics of the problem.  Along
these lines, twoorl repeats this mistake by modeling it as a web-app
instead of a messaging system, but again..just an opinion. :)

D.


From jay@REDACTED  Sat May 31 07:10:07 2008
From: jay@REDACTED (Jay Nelson)
Date: Fri, 30 May 2008 22:10:07 -0700
Subject: [erlang-questions] Message Receive Semantics (was eep: Multiple
	Patterns)
Message-ID: 

Sean Hinde wrote:

 > There is no contradiction here. In the first test the message queue
 > never grows so you do not get a slowdown.

As Per's later posted code showed, the mailbox was loaded with
messages before the consumers were started in both cases.  The
problem has nothing to do with garbage collection, but with the
linear scanning that takes place on the message queue.

 > Badly designed use of selective receive is one way to fill a message
 > queue, but by no means the only way. As I understand it once a  
message
 > has been examined and not matched it is not visited again until the
 > pattern changes.

The message queue is inspected one message at a time.  All patterns
are matched against that message.  If none match, the second message
in the queue is matched.  Progress continues until a match is found or
the end of the queue is hit.  If the end of the queue is hit and the  
receive
doesn't timeout, then none of the previous messages are revisited.  Once
a match happens, however, the scanning process goes back to the first
message in the queue because the act of finding a match may have now
made an earlier message match due to a change in pattern states.

Check out the following tutorial on my website.  It discusses the issues
related to the message queue.  Ulf doesn't like my conclusions because
they don't encourage power users, but the vast majority of message
handling situations are not as sophisticated as what his group deals  
with.

http://www.duomark.com/erlang/briefings/euc2006/index.html


I seem to recall that Francesco's group had a presentation last year on
priority messaging, but don't go there -- priorities with erlang message
semantics is a very messy problem to deal with.  You are much better
off finding an alternative to priorities, unless you unload the whole
message queue and manage it in your own process as a real priority
queue rather than a linear list.

jay



From jay@REDACTED  Sat May 31 07:19:13 2008
From: jay@REDACTED (Jay Nelson)
Date: Fri, 30 May 2008 22:19:13 -0700
Subject: [erlang-questions] Alternative approaches to selective receive
Message-ID: <11667BF8-8F98-4FA5-A290-52E36797A54F@duomark.com>

In the "eep: multiple patterns" thread, Ulf wrote:

 > I thought I'd try to convey a feeling for just
 > how hairy the receive clauses can get. I think
 > this is the worst one.

followed by a rather largish looking chunk of
complicated receive code.

Ulf, have you guys ever gotten a message queue
that is so convoluted with mixed traffic that you
decide to split the stream?

Example:

5 sources -> 1 complicated selective receive

versus

5 sources -> 1 router -> 20 session streams

The router looks for a simpler related class of
patterns that might identify sessions or some
other set of related messages.  It then just
forwards the messages to newly minted processes
that are simpler because they don't have to
disambiguate a mixed stream.

This approach is analogous to ROK's idea of
grouping patterns by classifying them.  You could
use that tag to then route and split the stream.
The session stream processes can use selective
receive to handle messages out of order, but the
number of complicated cases might be reduced.

jay



From ulf@REDACTED  Sat May 31 07:25:36 2008
From: ulf@REDACTED (Ulf Wiger)
Date: Sat, 31 May 2008 07:25:36 +0200
Subject: [erlang-questions] erlang-questions Digest, Vol 12, Issue 102
In-Reply-To: <91a2ba3e0805301544q225a9b9bx71b096a5bbaf3c81@mail.gmail.com>
References: 
	<6fba5e310805301535q13954b7bm5ac8b6117ce3524a@mail.gmail.com>
	<91a2ba3e0805301544q225a9b9bx71b096a5bbaf3c81@mail.gmail.com>
Message-ID: <8209f740805302225h2b27c63rf0d9765a3c2374db@mail.gmail.com>

There are some fairly exciting tools that can help along
the way:

1 McErlang is an innovative way of model checking erlang code
2 gen_trace has facilities for exporting to model checkers,
  and some work has been done on analysing "abstract
  traces" from running systems
3 QuickCheck doesn't go for deadlocks per se, but has a
  tendency to find weird and wonderful bugs in any program.

[1] http://babel.ls.fi.upm.es/~fred/McErlang/
[2] http://www.cs.chalmers.se/~hanssv/erlang_tracing/abstrfun.html
     http://www.erlang.org/pipermail/erlang-questions/2002-February/004343.html
[3] http://www.quviq.com

BR,
Ulf W

2008/5/31 Raoul Duke :
> hi,
>
>> With respect to avoiding deadlocks or ensuring there are none, I would
>> design my system based on CSP (Communicating sequential processes)
>> concepts. i.e Independent processes communicating via a pipe without
>> any shared memory.
>
> I believe that's sort of what Erlang does by nature ;-) so it is then
> a question of what modeling tools exist and how well they work. It
> isn't enough to design with CSP, you can still create deadlocks in it
> - you have to run a checker over it to try to prove there isn't any.
>
> sincerely.
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>


From ulf@REDACTED  Sat May 31 07:44:15 2008
From: ulf@REDACTED (Ulf Wiger)
Date: Sat, 31 May 2008 07:44:15 +0200
Subject: [erlang-questions] On selective receive (Re: eep: multiple patterns)
Message-ID: <8209f740805302244o2aa53054s856523553506aee8@mail.gmail.com>

I would really like to discourage people from avoiding
selective receive because it's "expensive". It can be
expensive on very large message queues, but this is
a pretty rare error condition, and fairly easily observable.

(I know of projects that have banned use of selective
receive for this reason, but without having thought much
about what to use instead, and when.)

You can use erlang:system_monitor/2 to quickly detect
if a process is growing memory in a strange way.

An old legacy Ericsson system implemented selective receive
in a way that the message queue could hold at most 6 messages.
Any more than that was obviously an error.

I think it might be useful to be able to specify such a limit as
a spawn option, perhaps together with maximum heap size.
Exceeding the limit could perhaps lead to the process being
killed (which might seem backwards in the case of the message
queue, but at least gives a visible indication), or that the sender
process would be suspended (which could potentially lead to the
whole system stopping.)

BR,
Ulf W

2008/5/31 Christopher Atkins :
> Hello, I tried (poorly--I'm a complete novice) to implement a benchmark from
> your earlier statement.  I didn't do the same thing (load up the message
> mailbox before consuming them), but what I did write led to a perplexing (to
> me) discovery.  If I uncomment the line in [loop1/0] below, performance for
> that loop degrades by an order of magnitude.  Why is that?
>
> -module(test_receive).
> -compile(export_all).
>
> start() ->
>         statistics(runtime),
>         statistics(wall_clock),
>         PidLoop1 = spawn(?MODULE, loop1,[]),
>         sender(PidLoop1, 10000000),
>         {_, Loop1Time1} = statistics(runtime),
>         {_, Loop1Time2} = statistics(wall_clock),
>         io:format("Sent ~p messages in ~p /~p~n", [100000, Loop1Time1,
> Loop1Time2]),
>         statistics(runtime),
>         statistics(wall_clock),
>         PidLoop2 = spawn(?MODULE, loop2,[]),
>         sender(PidLoop2, 10000000),
>         {_, Loop2Time1} = statistics(runtime),
>         {_, Loop2Time2} = statistics(wall_clock),
>         io:format("Sent ~p messages in ~p /~p~n", [100000, Loop2Time1,
> Loop2Time2]).
>
> sender(_, 0) -> void;
> sender(Pid, N) ->
>         if
>           N rem 2 =:= 2 ->
>                 Pid ! test2;
>           true ->
>                 Pid ! test1
>         end,
>         sender(Pid, N - 1).
>
> proc1(F) ->
>         receive
>                 start -> spawn_link(F)
>         end.
>
> loop1() ->
>         receive
>                 %%test1 -> loop1();
>                 test2 -> loop1()
>         end.
>
> loop2() ->
>         receive
>                 _ -> loop2()
>         end.
>
>
> ------------------------------------------------------------------------------------------------------------------------------
> Message: 2
> Date: Fri, 30 May 2008 18:07:18 +0200
> From: "Per Melin" 
> Subject: Re: [erlang-questions] eep: multiple patterns
> To: "Sean Hinde" 
> Cc: Erlang Questions 
> Message-ID:
>        
> Content-Type: text/plain; charset=ISO-8859-1
>
> 2008/5/30 Per Melin :
>> If I send 100k 'foo' messages and then 100k 'bar' messages to a
>> process, and then do a catch-all receive until there are no messages
>> left, that takes 0.03 seconds.
>>
>> If I do a selective receive of only the 'bar' messages, it takes 90
>> seconds.
>
> I found my old test code:
>
> -module(selective).
>
> -export([a/2, c/2]).
>
> a(Atom, N) ->
>    spawn(fun() -> b(Atom, N) end).
>
> b(Atom, N) ->
>    spam_me(foo, N),
>    spam_me(bar, N),
>    R = timer:tc(?MODULE, c, [Atom, N]),
>    io:format("TC: ~p~n", [R]).
>
> c(Atom, N) ->
>    receive
>        Atom -> c(Atom, N - 1)
>    after 0 ->
>        N
>    end.
>
> spam_me(Msg, Copies) ->
>    lists:foreach(fun(_) -> self() ! Msg end, lists:duplicate(Copies, 0)).
>
> ---
>
> 2> selective:a(bar, 100000).
> <0.38.0>
> TC: {124130689,0}
> 3> selective:a(foo, 100000).
> <0.40.0>
> TC: {23176,0}
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>


From ulf@REDACTED  Sat May 31 07:59:56 2008
From: ulf@REDACTED (Ulf Wiger)
Date: Sat, 31 May 2008 07:59:56 +0200
Subject: [erlang-questions] Message Receive Semantics (was eep: Multiple
	Patterns)
In-Reply-To: 
References: 
Message-ID: <8209f740805302259n62c23462r7974fd636bf9d9db@mail.gmail.com>

2008/5/31 Jay Nelson :

> Check out the following tutorial on my website.  It discusses the issues
> related to the message queue.  Ulf doesn't like my conclusions because
> they don't encourage power users, but the vast majority of message
> handling situations are not as sophisticated as what his group deals
> with.
>
> http://www.duomark.com/erlang/briefings/euc2006/index.html

I like your conclusions, Jay. (:

I've been on a crusade about selective receive for a few years,
since it dawned on me that the vast majority of people building
complex soft-real-time systems had no basic understanding
of the problem, and kept hitting the complexity wall, and /still/
didn't know what had hit them.

It took me a while to figure it out myself, and when I did I
looked around for teaching material or books that explain
it, but found basically nothing. *

I agree that the vast majority of processes do not have this
problem, but I think that it should be part of everyone's
repertoire to realize that it /can/ happen, and roughly under
which circumstances.

BR,
Ulf W

* In 2002, I had the opportunity to run my thoughts by Simon
Peyton-Jones. He was severely jetlagged and looked like
he was going to doze off while I explained it to him. Then
he quickly confirmed that it was "obvious" (that it would get
you into trouble) and "not a well known problem", before
excusing himself in order to hit the sack.


From ulf@REDACTED  Sat May 31 08:04:44 2008
From: ulf@REDACTED (Ulf Wiger)
Date: Sat, 31 May 2008 08:04:44 +0200
Subject: [erlang-questions] Alternative approaches to selective receive
In-Reply-To: <11667BF8-8F98-4FA5-A290-52E36797A54F@duomark.com>
References: <11667BF8-8F98-4FA5-A290-52E36797A54F@duomark.com>
Message-ID: <8209f740805302304g332a007bn986f2e8998c99a18@mail.gmail.com>

We have, in other cases.
This particular case is a bit unwieldy, in that the
signaling application alone is ca 100KLOC,
and also runs as a mission-critical service.

In cases where someone has written a multiplexing
state machine, it's usually fairly easy to create one
process for each, without altering the code much.
This goes a long way towards eliminating the bad
reordering effects, and is also a first step towards
rewriting the code in a nicer way.

BR,
Ulf W

2008/5/31 Jay Nelson :
> In the "eep: multiple patterns" thread, Ulf wrote:
>
>  > I thought I'd try to convey a feeling for just
>  > how hairy the receive clauses can get. I think
>  > this is the worst one.
>
> followed by a rather largish looking chunk of
> complicated receive code.
>
> Ulf, have you guys ever gotten a message queue
> that is so convoluted with mixed traffic that you
> decide to split the stream?
>
> Example:
>
> 5 sources -> 1 complicated selective receive
>
> versus
>
> 5 sources -> 1 router -> 20 session streams
>
> The router looks for a simpler related class of
> patterns that might identify sessions or some
> other set of related messages.  It then just
> forwards the messages to newly minted processes
> that are simpler because they don't have to
> disambiguate a mixed stream.
>
> This approach is analogous to ROK's idea of
> grouping patterns by classifying them.  You could
> use that tag to then route and split the stream.
> The session stream processes can use selective
> receive to handle messages out of order, but the
> number of complicated cases might be reduced.
>
> jay
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>


From mail.zin@REDACTED  Sat May 31 08:36:54 2008
From: mail.zin@REDACTED (Jong Hian Zin)
Date: Sat, 31 May 2008 14:36:54 +0800
Subject: [erlang-questions] Mnesia load and unload tables at runtime?
Message-ID: 

Is there a way that I can load a Mnesia ram_copies table during
runtime from file dumped by dump_tables, and "unload" it when I dont
need it, in order to save ram?

-- 
Jong Hian Zin


From paul-trapexit@REDACTED  Sat May 31 08:56:45 2008
From: paul-trapexit@REDACTED (Paul Mineiro)
Date: Fri, 30 May 2008 23:56:45 -0700 (PDT)
Subject: [erlang-questions] erl_compare_ext
Message-ID: 

following up on sean's pointer to erl_compare_ext:

i have a simple C program (attached) where erl_compare_ext says "44359 <
mpegs" and yet erlang shell says "mpegs < 44359".

any tips would be appreciated.

-- p

In an artificial world, only extremists live naturally.

        -- Paul Graham
-------------- next part --------------
A non-text attachment was scrubbed...
Name: flass.c
Type: text/x-csrc
Size: 779 bytes
Desc: 
URL: 

From md@REDACTED  Sat May 31 08:57:39 2008
From: md@REDACTED (Mathias Dalheimer)
Date: Sat, 31 May 2008 08:57:39 +0200
Subject: [erlang-questions] Model Checking (was: Re: erlang-questions Digest,
	Vol 12, Issue 102)
In-Reply-To: <91a2ba3e0805301544q225a9b9bx71b096a5bbaf3c81@mail.gmail.com>
References: 
	<6fba5e310805301535q13954b7bm5ac8b6117ce3524a@mail.gmail.com>
	<91a2ba3e0805301544q225a9b9bx71b096a5bbaf3c81@mail.gmail.com>
Message-ID: 

Hi,

On May 31, 2008, at 12:44 AM, Raoul Duke wrote:

> hi,
>
>> With respect to avoiding deadlocks or ensuring there are none, I  
>> would
>> design my system based on CSP (Communicating sequential processes)
>> concepts. i.e Independent processes communicating via a pipe without
>> any shared memory.
>
> I believe that's sort of what Erlang does by nature ;-) so it is then
> a question of what modeling tools exist and how well they work. It
> isn't enough to design with CSP, you can still create deadlocks in it
> - you have to run a checker over it to try to prove there isn't any.

I recently used Spin to verify several models of distributed systems.  
Spin follows the CSP paradigm - basically, you specify processes  
communicating over pipes. The model gets translated into a C program  
which is executed - Spin is highly optimized, although pretty memory  
intensive. Spin is not directly related to Erlang, but still highly  
useful.

 From a methodological point of view you can design your protocol (and  
the state machines) more or less interactively within Spin. After  
you've implemented some functionality, you can "compile" the model and  
run a verification. Spin provides builtin checks for deadlocks,  
livelocks as well as over-/underspecification of code. In addition,  
you can use linear temporal logic to specify your own properties.  
Xspin (an X-Windows frontend) can display the sequence of actions that  
violate any properties - so it's pretty easy to fix any problems.

In practice, I use Spin as the first step in distributed design and I  
can really recommend it. You can get Spin from http://spinroot.com. If  
you want to read more about it, "The Model Checker Spin" by Gerald  
Holtzmann gives you a nice introduction (online at http://spinroot.com/spin/Doc/ieee97.pdf) 
.

HTH,
-Mathias
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3596 bytes
Desc: not available
URL: 

From paul-trapexit@REDACTED  Sat May 31 08:58:59 2008
From: paul-trapexit@REDACTED (Paul Mineiro)
Date: Fri, 30 May 2008 23:58:59 -0700 (PDT)
Subject: [erlang-questions] erl_compare_ext
In-Reply-To: 
References: 
Message-ID: 

whoops, i see it now!  (erlang actually says 44359 < mpegs, so they
agree).

thanks,

-- p

On Fri, 30 May 2008, Paul Mineiro wrote:

> following up on sean's pointer to erl_compare_ext:
>
> i have a simple C program (attached) where erl_compare_ext says "44359 <
> mpegs" and yet erlang shell says "mpegs < 44359".
>
> any tips would be appreciated.
>
> -- p
>
> In an artificial world, only extremists live naturally.
>
>         -- Paul Graham

In an artificial world, only extremists live naturally.

        -- Paul Graham


From o.j.mason@REDACTED  Sat May 31 09:19:00 2008
From: o.j.mason@REDACTED (Oliver Mason)
Date: Sat, 31 May 2008 08:19:00 +0100
Subject: [erlang-questions] [Announce] yaml-erlang
In-Reply-To: <6a36e7290805301704v70f3710fyd76b36388616f0d2@mail.gmail.com>
References: <73768eac0805301509i699fe731s25b36bd2ca93ae4a@mail.gmail.com>
	
	<6a36e7290805301704v70f3710fyd76b36388616f0d2@mail.gmail.com>
Message-ID: <73768eac0805310019u4c3d830ci9fe0028f7b484628@mail.gmail.com>

Yes, sorry, for some reason I couldn't figure out how to check in the
source, so I put it under 'downloads'.  It was late last night when I
did that...

On 31/05/2008, Bob Ippolito  wrote:
> There's a tarball in the download section
>
>
>  On Fri, May 30, 2008 at 4:53 PM, Nick Gerakines  wrote:
>  > Oliver,
>  >
>  > Nice! It looks like you havn't checked in anything to the Google Code
>  > project. Is there an ETA on that?
>  >
>  > # Nick Gerakines
>  >
>  > On Fri, May 30, 2008 at 3:09 PM, Oliver Mason  wrote:
>  >> I've started writing a module to read in yaml files (see
>  >> http://www.yaml.org/);  the project is currently hosted on
>  >> http://code.google.com/p/yaml-erlang/
>  >> Version 0.1 can process basic lists and mappings (no
>  >> short-cuts/in-line variants yet).
>  >>
>  >> Oliver
>  >> _______________________________________________
>  >> erlang-questions mailing list
>  >> erlang-questions@REDACTED
>  >> http://www.erlang.org/mailman/listinfo/erlang-questions
>  >>
>  > _______________________________________________
>  > erlang-questions mailing list
>  > erlang-questions@REDACTED
>  > http://www.erlang.org/mailman/listinfo/erlang-questions
>  >
>


From ulf@REDACTED  Sat May 31 09:36:33 2008
From: ulf@REDACTED (Ulf Wiger)
Date: Sat, 31 May 2008 09:36:33 +0200
Subject: [erlang-questions] On selective receive (Re: eep: multiple
	patterns)
In-Reply-To: <8209f740805302244o2aa53054s856523553506aee8@mail.gmail.com>
References: <8209f740805302244o2aa53054s856523553506aee8@mail.gmail.com>
Message-ID: <8209f740805310036p3c4ba270wd2094536c9f8fe3c@mail.gmail.com>

Actually, I assume that in just about all cases where you
have a process that needs selective receive semantics,
it's probably perfectly ok to set a low limit on the maximum
length of the message queue. A buffering process could
be placed in front of it, which might also normally do
dispatch. It would not use selective receive, and so wouldn't
suffer much from a large message queue.

BR,
Ulf W

2008/5/31 Ulf Wiger :

> An old legacy Ericsson system implemented selective receive
> in a way that the message queue could hold at most 6 messages.
> Any more than that was obviously an error.
>
> I think it might be useful to be able to specify such a limit as
> a spawn option, perhaps together with maximum heap size.
> Exceeding the limit could perhaps lead to the process being
> killed (which might seem backwards in the case of the message
> queue, but at least gives a visible indication), or that the sender
> process would be suspended (which could potentially lead to the
> whole system stopping.)
>
> BR,
> Ulf W


From per.melin@REDACTED  Sat May 31 11:05:28 2008
From: per.melin@REDACTED (Per Melin)
Date: Sat, 31 May 2008 11:05:28 +0200
Subject: [erlang-questions] eep: multiple patterns
In-Reply-To: <39aa3ff20805301802l7eabf4cajd76c956dd9c57755@mail.gmail.com>
References: <39aa3ff20805301802l7eabf4cajd76c956dd9c57755@mail.gmail.com>
Message-ID: 

2008/5/31 Christopher Atkins :
> If I uncomment the line in [loop1/0] below, performance for
> that loop degrades by an order of magnitude.  Why is that?

You have a bug: N rem 2 =:= 2 can never be true. So you're only
sending 'test1' messages. If you fix that, you should see very
different results, even though you're only measuring the time it takes
to *send* the messages. A tip is to lower the number of messages to
100000 unless you want to bring your machine to its knees.

(I apologize to everyone for hijacking this thread.)



> -module(test_receive).
> -compile(export_all).
>
> start() ->
>         statistics(runtime),
>         statistics(wall_clock),
>         PidLoop1 = spawn(?MODULE, loop1,[]),
>         sender(PidLoop1, 10000000),
>         {_, Loop1Time1} = statistics(runtime),
>         {_, Loop1Time2} = statistics(wall_clock),
>         io:format("Sent ~p messages in ~p /~p~n", [100000, Loop1Time1,
> Loop1Time2]),
>         statistics(runtime),
>         statistics(wall_clock),
>         PidLoop2 = spawn(?MODULE, loop2,[]),
>         sender(PidLoop2, 10000000),
>         {_, Loop2Time1} = statistics(runtime),
>         {_, Loop2Time2} = statistics(wall_clock),
>         io:format("Sent ~p messages in ~p /~p~n", [100000, Loop2Time1,
> Loop2Time2]).
>
> sender(_, 0) -> void;
> sender(Pid, N) ->
>         if
>           N rem 2 =:= 2 ->
>                 Pid ! test2;
>           true ->
>                 Pid ! test1
>         end,
>         sender(Pid, N - 1).
>
> proc1(F) ->
>         receive
>                 start -> spawn_link(F)
>         end.
>
> loop1() ->
>         receive
>                 %%test1 -> loop1();
>                 test2 -> loop1()
>         end.
>
> loop2() ->
>         receive
>                 _ -> loop2()
>         end.
>


From steven.charles.davis@REDACTED  Sat May 31 11:27:12 2008
From: steven.charles.davis@REDACTED (Steve)
Date: Sat, 31 May 2008 02:27:12 -0700 (PDT)
Subject: [erlang-questions] Twoorl: an open source Twitter clone
In-Reply-To: 
References: <17244f480805282212g32eaa0e1o78493087bd12fd0@mail.gmail.com> 
	<9b08084c0805300718i636d1d8ci4b923ffe335ec8f9@mail.gmail.com> 
	 
	
Message-ID: <188c10fa-4083-49fc-b391-091ca19dd75d@z66g2000hsc.googlegroups.com>

"Dave Smith" wrote:

> My understanding is that the reason they have such poor uptime is due
> to the fact that they modeled the problem as a web-app instead of a
> messaging system.

Nice to hear a voice of reason. It perplexes me that people appear
surprised when their LAMP stack fails to scale.


From sean.hinde@REDACTED  Sat May 31 11:49:41 2008
From: sean.hinde@REDACTED (Sean Hinde)
Date: Sat, 31 May 2008 10:49:41 +0100
Subject: [erlang-questions] Message Receive Semantics (was eep: Multiple
	Patterns)
In-Reply-To: 
References: 
Message-ID: <13A4DBBA-438E-4791-8D76-1EBE71EDE182@gmail.com>


On 31 May 2008, at 06:10, Jay Nelson wrote:

> Sean Hinde wrote:
>
>> There is no contradiction here. In the first test the message queue
>> never grows so you do not get a slowdown.
>
> As Per's later posted code showed, the mailbox was loaded with
> messages before the consumers were started in both cases.  The
> problem has nothing to do with garbage collection, but with the
> linear scanning that takes place on the message queue.
>
>> Badly designed use of selective receive is one way to fill a message
>> queue, but by no means the only way. As I understand it once a
> message
>> has been examined and not matched it is not visited again until the
>> pattern changes.
>
> The message queue is inspected one message at a time.  All patterns
> are matched against that message.  If none match, the second message
> in the queue is matched.  Progress continues until a match is found or
> the end of the queue is hit.  If the end of the queue is hit and the
> receive
> doesn't timeout, then none of the previous messages are revisited.   
> Once
> a match happens, however, the scanning process goes back to the first
> message in the queue because the act of finding a match may have now
> made an earlier message match due to a change in pattern states.

Indeed, I posted my own followup agreeing that my understanding was  
wrong.

I still think that it would be an interesting optimisation - to store  
the last used pattern, and a pointer to where in the queue has been  
matched against that pattern - unless the pattern changes the system  
would not need to traverse the whole queue to re-test the same  
messages next time round the receive loop.

BR,
Sean



From gleber.p@REDACTED  Sat May 31 12:00:33 2008
From: gleber.p@REDACTED (Gleb Peregud)
Date: Sat, 31 May 2008 12:00:33 +0200
Subject: [erlang-questions] cacherl memcached app startup problem
	question
In-Reply-To: <1218d6a50805301550u50ddc883l4e07607c2e70f760@mail.gmail.com>
References: <1218d6a50805301550u50ddc883l4e07607c2e70f760@mail.gmail.com>
Message-ID: <14f0e3620805310300t175e4ea0wb539e3c8f1a84786@mail.gmail.com>

On Sat, May 31, 2008 at 12:50 AM, db  wrote:
> I am not sure what the problem is.  Mnesia directory actually gets
> created at /var/mensia/cacherl@REDACTED but there is no content.
> Is this something to do with disc_copies and any reason for using
> disc_copies rather than ram_copies?  Another question, does cacherl
> work with mysql memcached engine?
>
> [a@REDACTED cacherl]# ./start.sh
> Erlang (BEAM) emulator version 5.6.1 [source] [smp:2]
> [async-threads:30] [hipe] [kernel-poll:true]
>
> Eshell V5.6.1  (abort with ^G)
> (cacherl@REDACTED)1>
> =INFO REPORT==== 30-May-2008::17:16:51 ===
> Creating mnesia table ns_default
>
> =SUPERVISOR REPORT==== 30-May-2008::17:16:51 ===
>     Supervisor: {local,memcached}
>     Context:    start_error
>     Reason:     {{badmatch,
>                      {aborted,
>                          {bad_type,ns_default,disc_copies,
>                              'cacherl@REDACTED'}}},
>                  [{memcached_mnesia,init_mnesia_table,2},
>                   {memcached_mnesia,init,1},
>                   {gen_server,init_it,6},
>                   {proc_lib,init_p,5}]}
>     Offender:   [{pid,undefined},
>                  {name,memcached_mnesia},
>                  {mfa,{memcached_mnesia,start_link,[]}},
>                  {restart_type,permanent},
>                  {shutdown,2000},
>                  {child_type,worker}]
>
>
> =CRASH REPORT==== 30-May-2008::17:16:51 ===
>  crasher:
>    pid: <0.69.0>
>    registered_name: []
>    exception exit: {shutdown,{memcached,start,[normal,[]]}}
>      in function  application_master:init/4
>    initial call: application_master:init(<0.6.0>,<0.68.0>,
>                                          {appl_data,memcached,
>                                           [memcached,memcached_mnesia],
>                                           undefined,
>                                           {memcached,[]},
>                                           [memcached,memcached_mnesia,
>                                            memcached_stats,memcached_util,
>                                            memcached_purge,memcached_reader],
>                                           [],infinity,infinity},
>                                          normal)
>    ancestors: [<0.68.0>]
>    messages: [{'EXIT',<0.70.0>,normal}]
>    links: [<0.68.0>,<0.6.0>]
>    dictionary: []
>    trap_exit: true
>    status: running
>    heap_size: 377
>    stack_size: 23
>    reductions: 87
>  neighbours:
>
> =INFO REPORT==== 30-May-2008::17:16:51 ===
>    application: memcached
>    exited: {shutdown,{memcached,start,[normal,[]]}}
>    type: temporary
>
> =INFO REPORT==== 30-May-2008::17:16:51 ===
> started TCP listener on 0.0.0.0:11311
>
>
> --
> 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
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
Hello,

What system do you use? Is this Cygwin/WinXP? Anthony Kong had exacly
the same problem on Cygwin/WinXP and as far as i know was unable to
find the source. Anthony, may you comment on this issue? Having two
similar cases it would be easier to cope with this problem.

> Another question, does cacherl
> work with mysql memcached engine?
I've never worked with mysql memcached engine, but as an answer i'll
quote myself:

Cacherl is fully compatible with original memcached, hence you can
just replace your memcached with cacherl and it should work out of the
box, regardless language your application is written in and libraries
it uses.

Hence it will probably work :)


Best regards,
-- 
Gleb Peregud
http://gleber.pl/

Every minute is to be grasped.
Time waits for nobody.
-- Inscription on a Zen Gong


From circularfunc@REDACTED  Sat May 31 15:24:54 2008
From: circularfunc@REDACTED (Circular Function)
Date: Sat, 31 May 2008 13:24:54 +0000 (GMT)
Subject: [erlang-questions] run program from commandprompt? define function?
Message-ID: <626855.74663.qm@web28310.mail.ukl.yahoo.com>

-module(tut).
-export([double/1]).

double(X) ->
    2 * X.

saved that in tut.erl, placed it in the bin/ and tried to run it but it asks for a specific program to run.

Erlang (BEAM) emulator version 5.6.2 [async-threads:0]

Eshell V5.6.2  (abort with ^G)
1> c(tut).
../tut.erl:none: no such file or directory
error
2> 

so which install do i need?


how do i define a function?

can i do that directlyin the shell?

like in python:
def sq(x): return x*x

how would i dot hat in erlang?



      ___________________________________________________
S?k efter k?rleken!
Hitta din tvillingsj?l p? Yahoo! Dejting: http://ad.doubleclick.net/clk;185753627;24584539;x?http://se.meetic.yahoo.net/index.php?mtcmk=148783
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From circularfunc@REDACTED  Sat May 31 15:26:48 2008
From: circularfunc@REDACTED (Circular Function)
Date: Sat, 31 May 2008 13:26:48 +0000 (GMT)
Subject: [erlang-questions] -> == press enter?
Message-ID: <454529.76721.qm@web28310.mail.ukl.yahoo.com>

http://www.erlang.org/doc/getting_started/part_frame.html

should: 
->

be used? or it just means "press enter"?



      __________________________________________________________
Ta semester! - s?k efter resor hos Yahoo! Shopping.
J?mf?r pris p? flygbiljetter och hotellrum h?r:
http://shopping.yahoo.se/c-169901-resor-biljetter.html?partnerId=96914052
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From gleber.p@REDACTED  Sat May 31 16:08:46 2008
From: gleber.p@REDACTED (Gleb Peregud)
Date: Sat, 31 May 2008 16:08:46 +0200
Subject: [erlang-questions] -> == press enter?
In-Reply-To: <454529.76721.qm@web28310.mail.ukl.yahoo.com>
References: <454529.76721.qm@web28310.mail.ukl.yahoo.com>
Message-ID: <14f0e3620805310708u704b60des8cb811e458b97e99@mail.gmail.com>

I'm not sure what do you mean, but "->" is used in Erlang explicitly
when defining functions [1] or funs (precisely - on of their bodies)
[2], in case statements, in if statements [3] and in receive
statements [4]. Hence it doesn't just mean "press enter" :)

1] http://www.erlang.org/doc/getting_started/seq_prog.html#2.2
2] http://www.erlang.org/doc/getting_started/seq_prog.html#2.13
3] http://www.erlang.org/doc/getting_started/seq_prog.html#2.11
4] http://www.erlang.org/doc/getting_started/conc_prog.html#3.2

2008/5/31 Circular Function :
> http://www.erlang.org/doc/getting_started/part_frame.html
>
> should:
>
> ->
>
> be used? or it just means "press enter"?
>
> ________________________________
> Ta semester! - s?k efter resor hos Yahoo! Shopping.
> J?mf?r pris p? flygbiljetter och hotellrum:
> http://shopping..yahoo.se/c-169901-resor-biljetter.html
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>



-- 
Gleb Peregud
http://gleber.pl/

Every minute is to be grasped.
Time waits for nobody.
-- Inscription on a Zen Gong

From per.melin@REDACTED  Sat May 31 18:03:43 2008
From: per.melin@REDACTED (Per Melin)
Date: Sat, 31 May 2008 18:03:43 +0200
Subject: [erlang-questions] On selective receive (Re: eep: multiple
	patterns)
In-Reply-To: <8209f740805310036p3c4ba270wd2094536c9f8fe3c@mail.gmail.com>
References: <8209f740805302244o2aa53054s856523553506aee8@mail.gmail.com>
	<8209f740805310036p3c4ba270wd2094536c9f8fe3c@mail.gmail.com>
Message-ID: 

2008/5/31 Ulf Wiger :
> Actually, I assume that in just about all cases where you
> have a process that needs selective receive semantics,
> it's probably perfectly ok to set a low limit on the maximum
> length of the message queue. A buffering process could
> be placed in front of it, which might also normally do
> dispatch. It would not use selective receive, and so wouldn't
> suffer much from a large message queue.

The last time selective receive broke things for me was actually not
in my own code, but in Mnesia.

When Mnesia loads a distributed table from another node it subscribes
to table events before it starts to copy the table, and then ignores
those table event messages while it's (selectively) receiving the
table contents. Depending on the size of the table and the rate at
which the table is updated on the other node, this can make your
message queue grow until you run out of memory.

This is not a case where a long queue obviously is an error. Except
perhaps in the design.


> 2008/5/31 Ulf Wiger :
>
>> An old legacy Ericsson system implemented selective receive
>> in a way that the message queue could hold at most 6 messages.
>> Any more than that was obviously an error.
>>
>> I think it might be useful to be able to specify such a limit as
>> a spawn option, perhaps together with maximum heap size.
>> Exceeding the limit could perhaps lead to the process being
>> killed (which might seem backwards in the case of the message
>> queue, but at least gives a visible indication), or that the sender
>> process would be suspended (which could potentially lead to the
>> whole system stopping.)
>>
>> BR,
>> Ulf W
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>


From chsu79@REDACTED  Sat May 31 18:15:48 2008
From: chsu79@REDACTED (Christian S)
Date: Sat, 31 May 2008 18:15:48 +0200
Subject: [erlang-questions] how: Building Core Erlang abstract syntax trees
Message-ID: 

One can use compile:forms/2 to compile core erlang abstract syntax
trees directly, but what is the suggested way to construct these
trees?

There is lib/compile/src/core_parse.* (and especially the records in
the hrl file), and there is the 'cerl' module which has good edoc. The
module 'cerl' has node-constructors for the core erlang ast.

Looking at LFE, it doesnt make use of cerl, it hits the core erlang
records directly. Is this an oversight of Robert Virding or the more
practical thing to do?

Also, Core Erlang allows for annotations, what is the benefits one
could have from adding these? Static type analysis or can the compiler
make use of them?


From dbudworth@REDACTED  Sat May 31 20:30:04 2008
From: dbudworth@REDACTED (David Budworth)
Date: Sat, 31 May 2008 13:30:04 -0500
Subject: [erlang-questions] Fwd: run program from commandprompt? define
	function?
In-Reply-To: <2e23d1d20805311129l4e6c4f39p99751681d404e166@mail.gmail.com>
References: <626855.74663.qm@web28310.mail.ukl.yahoo.com>
	<2e23d1d20805311129l4e6c4f39p99751681d404e166@mail.gmail.com>
Message-ID: <2e23d1d20805311130leb0483ana7987d75cd986a1d@mail.gmail.com>

Forgot to reply-all, here it is again:

c(tut) will look in the current directory.  So if you moved it to bin, you
should run erl from there or do:cd("bin").

from the shell
as for defining functions from the shell, I don't believe you can define
normal module:function/arity style functions like in your tut.erl (that
function being tut:double/1)

but you can define fun's from the shell and call them, example:
1> Double = fun(X) -> 2 * X end.
#Fun
2> Double(5).
10
3>

the difference here is you have to make anonymous functions and bind them to
variables.  so they won't look quite the same as from a source file where
you use lowercase atom names.

make sense?

2008/5/31 Circular Function :

> -module(tut).
> -export([double/1]).
>
> double(X) ->
>     2 * X.
>
> saved that in tut.erl, placed it in the bin/ and tried to run it but it
> asks for a specific program to run.
>
> Erlang (BEAM) emulator version 5.6.2 [async-threads:0]
>
> Eshell V5.6.2  (abort with ^G)
> 1> c(tut).
> ./tut.erl:none: no such file or directory
> error
> 2>
>
> so which install do i need?
>
>
> how do i define a function?
>
> can i do that directlyin the shell?
>
> like in python:
> def sq(x): return x*x
>
> how would i dot hat in erlang?
>
> ------------------------------
> S?k efter k?rleken!
> Hitta din tvillingsj?l p? Yahoo! Dejting: http://se.meetic.yahoo.net
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From paul-trapexit@REDACTED  Sat May 31 20:43:57 2008
From: paul-trapexit@REDACTED (Paul Mineiro)
Date: Sat, 31 May 2008 11:43:57 -0700 (PDT)
Subject: [erlang-questions] need to call erl_init_marshal () ?
Message-ID: 

re: erl_compare_ext () to compare binaries in erlang term order in a
linked-in driver.

i got this working but it was very tricky, basically calling erl_init ()
from a linked-in driver does not work, but otherwise erl_compare_ext () is
silently broken, not in a crashing way, but in a "i claim to be a
comparison function but i'm not antisymmetric" way, which leads to bizarre
behaviour when used as the comparison function for tree lookup.

it turns out the thing to call is erl_init_marshal (), which is not
exported in any header so you have to declare it yourself (extern) and
then call it from the init hook of your linked-in driver.  and to know
that, you'd have to crawl through source code (or maybe now, find this
message via search engine).

is there a better way?

thanks,

-- p


From richardc@REDACTED  Sat May 31 21:08:02 2008
From: richardc@REDACTED (Richard Carlsson)
Date: Sat, 31 May 2008 21:08:02 +0200
Subject: [erlang-questions] how: Building Core Erlang abstract syntax
 trees
In-Reply-To: 
References: 
Message-ID: <4841A212.5070800@it.uu.se>

Christian S wrote:
> One can use compile:forms/2 to compile core erlang abstract syntax
> trees directly, but what is the suggested way to construct these
> trees?
> 
> There is lib/compile/src/core_parse.* (and especially the records in
> the hrl file), and there is the 'cerl' module which has good edoc. The
> module 'cerl' has node-constructors for the core erlang ast.
>
 > Looking at LFE, it doesnt make use of cerl, it hits the core erlang
 > records directly. Is this an oversight of Robert Virding or the more
 > practical thing to do?

This is for historical reasons. When we started working on Core Erlang,
Robert (and others) preferred working directly with records, while I
preferred using a "proper" abstract datatype (even though it meant
that I couldn't decompose structures using pattern matching). Also,
we had some different ideas regarding how some things such as literals
and variables ought to be represented. So you'll find that the central
parts of the compiler use the records defined in core_parse.hrl, while
cerl_inline and everything in lib/hipe/cerl uses the cerl.erl ADT (which
can be converted to/from the record format).

To ensure that there are no undetected mix-ups between the formats,
the ADT representation uses different tuple tags (the records in
core_parse.hrl all begin with "c_"), and the conversion functions
have to be used.

You can use any representation you like to build your own trees; it's
mostly a matter of programming style. The ADT is better at letting you
not have to distinguish between plain variables and function-variables
except where absolutely necessary.

> Also, Core Erlang allows for annotations, what is the benefits one
> could have from adding these? Static type analysis or can the compiler
> make use of them?

The compiler uses the annotations for various info, you can use them for
analyses etc., and you can pass hooks to lib/hipe/cerl_prettypr.erl to
format core code using HTML markup that depends on annotations (very
useful for visualizing the results of analyses).

     /Richard

PS. The "recursive environment" ADT in lib/compiler/src/rec_env.erl can
be very useful for making transformations. In particular, it makes the
generation of fresh variables easy.

-- 
  "Having users is like optimization: the wise course is to delay it."
    -- Paul Graham


From jay@REDACTED  Sat May 31 20:50:14 2008
From: jay@REDACTED (Jay Nelson)
Date: Sat, 31 May 2008 11:50:14 -0700
Subject: [erlang-questions] On selective receive (Re: eep: multiple
	patterns)
Message-ID: <5507E2DB-51F8-4A6B-BC6C-F0B0E3E81EC7@duomark.com>

 > I would really like to discourage people from avoiding
 > selective receive because it's "expensive".

I would second that.  Selective receive is similar to thinking
single threaded in a multi-threaded environment (the approach
that erlang in general supports).  Isolate a group of related
messages using the selective part and then you don't have to
worry about all the other interleave interruptions that may occur.

But as Ulf said, we aren't aware of any books on how to structure your
messaging architecture which take you stepwise up from a
simple architecture to a complicated selective receive.  I do
caution a beginner to start simple and build up; understand how
the message queue works by creating test scenarios that produce
specific results.

One of the early admonishments one hears is to always have a
catch all clause in your receive statements, which of course
eliminates selective receive and causes your code to process
messages in the order they arrived.  To get around this, you
can split the receive into separate functions, and then call one
function to handle one logical message stream and another
function to handle a different logical message stream.

The thing to watch out in the split receive case is the missing
message:

receive
    {a, How} -> do_stuff();
    {a, When, Why} -> do_stuff();
after 500 -> timeout
end.

receive
   {b, How} -> do_stuff();
   {b, When, Why} -> do_stuff();
after 500 -> timeout
end.

Now you can handle the two streams independently, maybe
giving more time to 'a' stream items than 'b' stream items.
But suppose you accidentally send a message with {c, X}
and it only happens once an hour.  You will gradually get a
queue which fills up with {c, X} messages, but you won't notice
the slowdown for a few days.

Whenever you have disjoint receive statements, you need to
take care that there is a technique for emptying unexpected
messages.  Even though your queue should never get long,
a new programmer on the staff may send a new message to
your process without you knowing and it will take a while
to discover the cause.

jay



From sten@REDACTED  Sat May 31 21:23:22 2008
From: sten@REDACTED (Sten Kvamme)
Date: Sat, 31 May 2008 21:23:22 +0200
Subject: [erlang-questions]  ArmEABI
Message-ID: 

Hello,
Is there an Arm EABI binary Erlang download?

Thanks,
Sten 


From tuncer.ayaz@REDACTED  Sat May 31 23:32:40 2008
From: tuncer.ayaz@REDACTED (Tuncer Ayaz)
Date: Sat, 31 May 2008 23:32:40 +0200
Subject: [erlang-questions] rsync-like function in Erlang?
In-Reply-To: <4ac8254d0805201423l7e4037d1td9474cd125e3d32e@mail.gmail.com>
References: <351ce2d70805171433y3d179240wd0adcc3b38ac6cbd@mail.gmail.com>
	<1c3be50f0805200608r504dfb80w1b25bb389a36ac7d@mail.gmail.com>
	<351ce2d70805201345x69f01612v323de6a140ae6025@mail.gmail.com>
	<4ac8254d0805201423l7e4037d1td9474cd125e3d32e@mail.gmail.com>
Message-ID: <4ac8254d0805311432k7d1bdb4ao5cc40c0149862f2e@mail.gmail.com>

On Tue, May 20, 2008 at 11:23 PM, Tuncer Ayaz  wrote:
> On Tue, May 20, 2008 at 10:45 PM, Johan Holmberg  wrote:
>> 2008/5/20 Juan Jose Comellas :
>>> Have you thought about using a distributed version control system such as
>>> Git for this? I have the same problem, with the added need to track the
>>> history of changes of each file, and I'm planning to build an Erlang wrapper
>>> over Git. This wrapper could also provide a transactional interface to the
>>> filesystem, giving you the ability to rollback to a previous version of the
>>> file in case of a problem.
>>>
>>
>> Interesting idea. I have thought about using Subversion (the version
>> control system we normally use), but dismissed it as to complicated
>> (with the need for a third machine, the Subversion-server, and with
>> all the space overhead in the local .svn directories).
>>
>> Does Git work well on Windows? And can it operate in client-server
>> fashion, or does it need filesystem access between the machines?
>
> Git works on Windows but not yet quite as good as on the _you know
> where it originated :D_ OS

Let me correct my statement and tell you that the current preview
of msysgit looks pretty good. Definitely good enough to use.




From yarivsadan@REDACTED  Sat May 31 23:39:40 2008
From: yarivsadan@REDACTED (Yariv Sadan)
Date: Sat, 31 May 2008 14:39:40 -0700
Subject: [erlang-questions] [erlyweb-list] Re: Twoorl: an open source
	Twitter clone
In-Reply-To: 
References: <17244f480805282212g32eaa0e1o78493087bd12fd0@mail.gmail.com>
	
Message-ID: <17244f480805311439u1921d72bga381adb22e9aa7ab@mail.gmail.com>

Thanks! Comet based scrolling is relatively low priority. There are a
bunch of other feature requests I'm working on. Twoorl users are a
small but pretty excited bunch :)
I'm not planning on keeping the current db-backed timeline rendering.
I realize it wouldn't  well when users start having too many friends.
To avoid this bottleneck, I'm planning on keeping a per-user data
store (in mnesia or memcache) for the last 20 twoorls (=tweets) from
their friends. New twoorls would be broadcasted (ie copied) to all
(active) followers. It's a space/speed tradeoff. This solution
wouldn't allow paging (unless I increase the cache size) but I think
it's a good tradeoff.

I still have some way to go before I hit these scaling problems, though.

Yariv

On Sat, May 31, 2008 at 8:53 AM, David Pollak
 wrote:
> Yariv,
> Nice stuff.  A question and an observation:
> Q: Are you planning to add a comet-based scrolling timeline?
> O: The creation of a timeline from the backing store on request strikes me
> as one that is prone to performance problems (see http://twitter.com)
> Thanks,
> David
>
> On Wed, May 28, 2008 at 10:12 PM, Yariv Sadan  wrote:
>>
>> Hi,
>>
>> I created an open source Twitter clone in Erlang called Twoorl. I
>> wrote it on top of ErlyWeb/Yaws.  You can see it at http://twoorl.com.
>> The code is at http://code.google.com/p/twoorl.
>>
>> I'll appreciate any feedback!
>>
>> Thanks,
>> Yariv
>>
>>
>
>
>
> --
> lift, the simply functional web framework http://liftweb.net
> Collaborative Task Management http://much4.us
> Follow me: http://twitter.com/dpp
> Git some: http://github.com/dpp
> --~--~---------~--~----~------------~-------~--~----~
> You received this message because you are subscribed to the Google Groups
> "erlyweb" group.
> To post to this group, send email to erlyweb@REDACTED
> To unsubscribe from this group, send email to
> erlyweb-unsubscribe@REDACTED
> For more options, visit this group at
> http://groups.google.com/group/erlyweb?hl=en
> -~----------~----~----~----~------~----~------~--~---
>
>


From lloy0076@REDACTED  Sat May 31 12:22:26 2008
From: lloy0076@REDACTED (David Lloyd)
Date: Sat, 31 May 2008 19:52:26 +0930
Subject: [erlang-questions] Performance of matches
In-Reply-To: <483EDB2E.9070103@san.rr.com>
References: <483EDB2E.9070103@san.rr.com>
Message-ID: <484126E2.5040000@adam.com.au>


Darren,

Darren New wrote:
> Speaking of table-driven decisions...
> 
> Is a function like this efficiently matched?
> 
> table1("hello") -> ...;
> table1("byebye") -> ...;
> table1("morning") -> ...;
>    ... and so on for dozens more ...
> 
> How about
> table2(hello) -> ...;
> table2(byebye) -> ...;
> table2(morning) -> ...;
>     ... And so on for dozens more ...
> 
> Is either of those O(1) lookup time?

It strikes me that this is something that is eminently easy to profile...

DSL