From lenartlad@REDACTED Tue Jan 2 11:43:18 2007 From: lenartlad@REDACTED (Ladislav Lenart) Date: Tue, 02 Jan 2007 11:43:18 +0100 Subject: [erlang-questions] gen_fsm In-Reply-To: <3A76756EED583B43A4AD704E29CCD079715D2B@mail.aprsmartlogik.com> References: <3A76756EED583B43A4AD704E29CCD079715D2B@mail.aprsmartlogik.com> Message-ID: <459A3746.20604@volny.cz> Bob Cowdery wrote: > I've been looking at gen_fsm as I need a state machine implementation. > Are there any examples of using this module? I've googled around but > can't find anything. Hello, I've grasped the gen_fsm module by reading OTP Design principles at: http://www.erlang.org/doc/doc-5.5.2/doc/design_principles/part_frame.html See Gen_Fsm Behavior in more detail, there is also a simple code_lock example. Hope this helps, Ladislav Lenart From Bob.Cowdery@REDACTED Tue Jan 2 19:34:01 2007 From: Bob.Cowdery@REDACTED (Bob Cowdery) Date: Tue, 2 Jan 2007 18:34:01 -0000 Subject: [erlang-questions] dets examples Message-ID: <3A76756EED583B43A4AD704E29CCD0797411D5@mail.aprsmartlogik.com> Hi all I hope this isn't staring me in the face again! Are there any examples of using dets. I can't get it to do anything sensible. Thanks Bob From Bob.Cowdery@REDACTED Tue Jan 2 21:08:40 2007 From: Bob.Cowdery@REDACTED (Bob Cowdery) Date: Tue, 2 Jan 2007 20:08:40 -0000 Subject: [erlang-questions] dets examples Message-ID: <3A76756EED583B43A4AD704E29CCD079715D34@mail.aprsmartlogik.com> Posted a little too soon. I'm starting to find my way around it now. >> The api is nearly exactly the same as ets. Explain what you fail to do. On 1/2/07, Bob Cowdery wrote: > Hi all > > I hope this isn't staring me in the face again! Are there any examples of > using dets. I can't get it to do anything sensible. > > Thanks > Bob > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From sgolovan@REDACTED Tue Jan 2 23:57:21 2007 From: sgolovan@REDACTED (Sergei Golovan) Date: Wed, 3 Jan 2007 01:57:21 +0300 Subject: [erlang-questions] Non-free files in Erlang/OTP distribution? Message-ID: Hi! I'm packaging Erlang/OTP for Debian GNU/Linux distribution. Today there was a bugreport (http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=405360) concerning a license of some files, included in the Erlang/OTP distribution. The suspicious files are otp_src_R11B-2/lib/erl_interface/src/misc/eimd5.c otp_src_R11B-2/lib/erl_interface/src/misc/eimd5.h otp_src_R11B-2/erts/emulator/beam/erl_md5.c They contain (modified) reference implementation of MD5 digest algorithm. The included licence states: * License is also granted to make and use derivative works provided * that such works are identified as "derived from the RSA Data * Security, Inc. MD5 Message-Digest Algorithm" in all material * mentioning or referencing the derived work. The problem is that the license doesn't permit redistribution of derived works explicitly. Therefore it is considered non-free. Can you tell me, how do you interpret the license. Don't you think that Erlang/OTP distribution can't contain these files, derived from RSA code? Best wishes! -- Sergei Golovan From serge@REDACTED Wed Jan 3 00:52:12 2007 From: serge@REDACTED (Serge Aleynikov) Date: Tue, 02 Jan 2007 18:52:12 -0500 Subject: [erlang-questions] R11B-2: one more bug with the "-smp" switch Message-ID: <459AF02C.1080600@hq.idt.net> Happy New bug, everyone! ;-) $ uname -a Linux xxxxxx 2.6.9-34.ELsmp #1 SMP Fri Feb 24 16:54:53 EST 2006 i686 i686 i386 GNU/Linux $ cat test.erl -module(test). -export([f/1]). f(Args) -> io:format("~s~n", [filename:join(Args)]). $ erl -noshell -run test f "/usr" "local" -s erlang halt /usr/local $ erl -smp -noshell -run test f "/usr" "local" -s erlang halt {"init terminating in do_boot",{undef,[{test,f,[["/usr","local"]]},{init,start_it,1},{init,start_em,1}]}} Crash dump was written to: erl_crash.dump init terminating in do_boot () Regards, Serge -- Serge Aleynikov Routing R&D, IDT Telecom Tel: +1 (973) 438-3436 Fax: +1 (973) 438-1464 From kg9020@REDACTED Wed Jan 3 02:12:41 2007 From: kg9020@REDACTED (kg9020@REDACTED) Date: Tue, 2 Jan 2007 19:12:41 -0600 Subject: [erlang-questions] writing programs to work with port Message-ID: <96fd17a20701021712p2ac2cbc3kb230a510e7081edf@mail.gmail.com> Following the "Writing an Erlang Port using OTP Principles" tutorial is this the best way to have a program work with a port to an extprg ? Looking at the "Interoperability Tutorial" it appears to only cover the Erlang port to extprg and not the issues with intergration of an application or program working with the port. Issue such as keeping track of the pid and how to issue read and write to the port from with in a program. The examples appear to show results from the Erlang shell. I would like to know are there more examples or tutorials on how program an interface to port. Newbie -------------- next part -------------- An HTML attachment was scrubbed... URL: From serge@REDACTED Wed Jan 3 03:23:11 2007 From: serge@REDACTED (Serge Aleynikov) Date: Tue, 02 Jan 2007 21:23:11 -0500 Subject: [erlang-questions] writing programs to work with port In-Reply-To: <96fd17a20701021712p2ac2cbc3kb230a510e7081edf@mail.gmail.com> References: <96fd17a20701021712p2ac2cbc3kb230a510e7081edf@mail.gmail.com> Message-ID: <459B138F.6060100@hq.idt.net> Here's another helpful tutorial: http://wiki.trapexit.org/index.php/How_to_use_ei_to_marshal_binary_terms_in_port_programs kg9020@REDACTED wrote: > Following the "Writing an Erlang Port using OTP Principles" tutorial is > this > the best way to have a program work with a port to an extprg ? Looking at > the "Interoperability Tutorial" it appears to only cover the Erlang port to > extprg and not the issues with intergration of an application or program > working with the port. Issue such as keeping track of the pid and how to > issue read and write to the port from with in a program. The examples > appear to show results from the Erlang shell. I would like to know are > there more examples or tutorials on how program an interface to port. > > Newbie > > > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From darrinth@REDACTED Wed Jan 3 04:35:02 2007 From: darrinth@REDACTED (Darrin Thompson) Date: Tue, 2 Jan 2007 22:35:02 -0500 Subject: [erlang-questions] HOWTO: Jabberlang vs. talk.google.com Message-ID: I successfully connected with talk.google.com using jabberlang from process-one svn. Here's how: sudo stunnel -c -d localhost:5222 -r talk.google.com:5223 > {ok, X} = xmpp:start("localhost", 5222, "gmail.com"). % username is myuser, NOT myuser@REDACTED > xmpp:set_login_information(X, "myuser", {password, "mypass"}). > xmpp:connect(X). Hope that saves some poor soul a few hours. :-) Process-one folks: look, I know you're all busy running an actual business and stuff, but could jabberlang please get some attention sometime? Even a bunch of half baked patches or workspace snapshots would be helpful. -- Darrin From darrinth@REDACTED Wed Jan 3 04:44:52 2007 From: darrinth@REDACTED (Darrin Thompson) Date: Tue, 2 Jan 2007 22:44:52 -0500 Subject: [erlang-questions] HOWTO: Jabberlang vs. talk.google.com In-Reply-To: References: Message-ID: On 1/2/07, Darrin Thompson wrote: > I successfully connected with talk.google.com using jabberlang from > process-one svn. > Except I forgot that I needed a patch. Jabberlang is sending presence stanzas with type="available" which isn't allowed by the xmpp spec, at least not the ones google folks read. :-) The spec recommends no type attribute to indicate "available". Index: src/xmpp.erl =================================================================== --- src/xmpp.erl (revision 8) +++ src/xmpp.erl (working copy) @@ -196,6 +196,9 @@ send_presence(Socket, Show, Status) -> send_presence(Socket, "available", Show, Status). +send_presence(Socket, "available", Show, Status) -> + Message = io_lib:format("~s~s", [Show, Status]), + gen_tcp:send(Socket, Message); send_presence(Socket, Type, Show, Status) -> Message = io_lib:format("~s~s", [Type, Show, Status]), gen_tcp:send(Socket, Message). From surindar.shanthi@REDACTED Wed Jan 3 08:05:23 2007 From: surindar.shanthi@REDACTED (Surindar Sivanesan) Date: Wed, 3 Jan 2007 12:35:23 +0530 Subject: [erlang-questions] enfile error in socket Message-ID: <42ea5fb60701022305x5d660849rf901314bfd2b8409@mail.gmail.com> Dear all, I faced a *enfile* error in socket connection while running an aplication in erlang version 5.5 in Windows Server 2003. I tried to increase the environment variable for ERL_MAX_PORT using *erlang: **open_port**/2*. But i dont know how to use the first parameter (*PortName*) of this function. Please guide me in changing ERL_MAX_PORT. -- with regards, S.Surindar -------------- next part -------------- An HTML attachment was scrubbed... URL: From bengt.kleberg@REDACTED Wed Jan 3 08:27:52 2007 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Wed, 03 Jan 2007 08:27:52 +0100 Subject: [erlang-questions] enfile error in socket In-Reply-To: <42ea5fb60701022305x5d660849rf901314bfd2b8409@mail.gmail.com> References: <42ea5fb60701022305x5d660849rf901314bfd2b8409@mail.gmail.com> Message-ID: <459B5AF8.4050301@ericsson.com> On 2007-01-03 08:05, Surindar Sivanesan wrote: > > Dear all, > > I faced a *enfile* error in socket connection while running an > aplication in erlang version 5.5 in Windows Server 2003. > > I tried to increase the environment variable for ERL_MAX_PORT using > *erlang:*|*open_port*| */2*. But i dont know how to use the first there is no (direct) connection between erlang ports and sockets. changing ERL_MAX_PORT will not help you with a *enfile* error in socket connection. bengt -- EPO guidelines 1978: "If the contribution to the known art resides solely in a computer program then the subject matter is not patentable in whatever manner it may be presented in the claims." From surindar.shanthi@REDACTED Wed Jan 3 08:42:08 2007 From: surindar.shanthi@REDACTED (Surindar Sivanesan) Date: Wed, 3 Jan 2007 13:12:08 +0530 Subject: [erlang-questions] enfile error in socket In-Reply-To: <459B5AF8.4050301@ericsson.com> References: <42ea5fb60701022305x5d660849rf901314bfd2b8409@mail.gmail.com> <459B5AF8.4050301@ericsson.com> Message-ID: <42ea5fb60701022342o52d0c696oc1122db698094616@mail.gmail.com> Thanks for quick reply. It would be helpful, if you provide me the solution for the enfile error. On 1/3/07, Bengt Kleberg wrote: > > On 2007-01-03 08:05, Surindar Sivanesan wrote: > > > > Dear all, > > > > I faced a *enfile* error in socket connection while running an > > aplication in erlang version 5.5 in Windows Server 2003. > > > > I tried to increase the environment variable for ERL_MAX_PORT using > > *erlang:*|*open_port*| */2*. But i dont know how to use the first > > there is no (direct) connection between erlang ports and sockets. > changing ERL_MAX_PORT will not help you with a *enfile* error in socket > connection. > > > bengt > -- > EPO guidelines 1978: "If the contribution to the known art resides > solely in a computer program then the subject matter is not > patentable in whatever manner it may be presented in the claims." > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- with regards, S.Surindar -------------- next part -------------- An HTML attachment was scrubbed... URL: From joost.damad@REDACTED Wed Jan 3 09:57:16 2007 From: joost.damad@REDACTED (Joost Yervante Damad) Date: Wed, 3 Jan 2007 09:57:16 +0100 Subject: [erlang-questions] gen_fsm In-Reply-To: <3A76756EED583B43A4AD704E29CCD079715D2B@mail.aprsmartlogik.com> References: <3A76756EED583B43A4AD704E29CCD079715D2B@mail.aprsmartlogik.com> Message-ID: <200701030957.17100.joost.damad@siemens.com> On Thursday 28 December 2006 16:38, Bob Cowdery wrote: > I've been looking at gen_fsm as I need a state machine implementation. Are > there any examples of using this module? I've googled around but can't find > anything. > > Thanks > Bob You might want to give google codesearch a try: http://www.google.com/codesearch?q=gen_fsm&hl=en&btnG=Search+Code Greetings, Joost From kenneth.lundin@REDACTED Wed Jan 3 10:03:16 2007 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Wed, 3 Jan 2007 10:03:16 +0100 Subject: [erlang-questions] Non-free files in Erlang/OTP distribution? In-Reply-To: References: Message-ID: Hi, What about this statement from RSA? (the link below) I think it clarifies that it is ok to redistribute derivative work regarding the MD5 Message-Digest Algorithm. http://www.ietf.org/ietf/IPR/RSA-MD-all It is written by: "Linn, John" February 19, 2000 and begin like this: The purpose of this memo is to clarify the status of intellectual property rights asserted by RSA Security Inc. ("RSA") in the MD2, MD4 and MD5 message-digest algorithms, which are documented in RFC-1319, RFC-1320, and RFC-1321 respectively. Implementations of these message-digest algorithms, including implementations derived from the reference C code in RFC-1319, RFC-1320, and RFC-1321, may be made, used, and sold without license from RSA for any purpose. It then continues, but I think the above statement is clear enough. Note, the code distributed with Erlang/OTP is derivative work from the reference implementation in RFC 1321. /Regards Kenneth On 1/2/07, Sergei Golovan wrote: > Hi! > > I'm packaging Erlang/OTP for Debian GNU/Linux distribution. Today > there was a bugreport > (http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=405360) concerning a > license of some files, included in the Erlang/OTP distribution. > > The suspicious files are > > otp_src_R11B-2/lib/erl_interface/src/misc/eimd5.c > otp_src_R11B-2/lib/erl_interface/src/misc/eimd5.h > otp_src_R11B-2/erts/emulator/beam/erl_md5.c > > They contain (modified) reference implementation of MD5 digest algorithm. > > The included licence states: > > * License is also granted to make and use derivative works provided > * that such works are identified as "derived from the RSA Data > * Security, Inc. MD5 Message-Digest Algorithm" in all material > * mentioning or referencing the derived work. > > The problem is that the license doesn't permit redistribution of > derived works explicitly. Therefore it is considered non-free. > > Can you tell me, how do you interpret the license. Don't you think > that Erlang/OTP distribution can't contain these files, derived from > RSA code? > > Best wishes! > -- > Sergei Golovan > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From mickael.remond@REDACTED Wed Jan 3 10:29:00 2007 From: mickael.remond@REDACTED (Mickael Remond) Date: 03 Jan 2007 10:29:00 +0100 Subject: [erlang-questions] HOWTO: Jabberlang vs. talk.google.com Message-ID: <3250664961.2717142@smtp.bouygtel.fr> Hello Darrin, I confirm that we are listening. We are busy preparing the integration of a common exmpp module that will not require to have ejabberd installed. Then, we can focus on improving Jabberlang itself. I can provide you with a SVN account on our repository if you want to help us in this task. Best wishes, -- Mickael Remond http://www.process-one.net/ From Erik.Stenman@REDACTED Wed Jan 3 12:31:57 2007 From: Erik.Stenman@REDACTED (Erik Stenman) Date: Wed, 03 Jan 2007 12:31:57 +0100 Subject: [erlang-questions] bad_object in mnesia Message-ID: <459B942D.9090901@Kreditor.se> Has anyone had any experience with mnesia returning bad_object? Every now and then one of our mnesia database tables breaks in some way. The breakage manifests itself in one of two ways: 1. Transactions on the tables aborts with {badarg, [TABLENAME]} 2. Reads on the table returns {error, {bad_object, "FULLPATH_TO_TABLENAME.DAT"}} This happens in a running system where the table has been used for a long time. I can not find any documentation in mnesia (nor in dets) stating that mnesia can return the error code bad_object. Has anyone seen any documentation of this? Is it a bug in mnesia or in the documentation? (I.e. is this supposed to be happening and it is just not documented? In that case what are you supposed to do when you get such an error message?) The error seems to indicate that the table is corrupt in some way. Sometimes the table can be fixed by simply restarting mnesia, sometimes we have to copy the table from another node in order to fix the problem. Any input appreciated. We have seen this error in R10-B8 and recently in the latest R11-B2. Erik Stenman From sgolovan@REDACTED Wed Jan 3 12:55:00 2007 From: sgolovan@REDACTED (Sergei Golovan) Date: Wed, 3 Jan 2007 14:55:00 +0300 Subject: [erlang-questions] Non-free files in Erlang/OTP distribution? In-Reply-To: References: Message-ID: On 1/3/07, Kenneth Lundin wrote: > Hi, > > What about this statement from RSA? (the link below) > I think it clarifies that it is ok to redistribute derivative work > regarding the MD5 Message-Digest Algorithm. > > http://www.ietf.org/ietf/IPR/RSA-MD-all Thanks! It looks like what I tried to find. Though I would like to see not only "may be made, used, and sold", but also "distributed" :) -- Sergei Golovan From hans.bolinder@REDACTED Wed Jan 3 15:07:22 2007 From: hans.bolinder@REDACTED (Hans Bolinder) Date: Wed, 3 Jan 2007 15:07:22 +0100 Subject: [erlang-questions] bad_object in mnesia In-Reply-To: <459B942D.9090901@Kreditor.se> References: <459B942D.9090901@Kreditor.se> Message-ID: <17819.47258.636345.513262@gargle.gargle.HOWL> [Erik Stenman:] > Has anyone had any experience with mnesia returning bad_object? > ... > 2. Reads on the table returns {error, {bad_object, > "FULLPATH_TO_TABLENAME.DAT"}} > This happens in a running system where the table has been used for a > long time. This is most likely a bug in Dets. Any information you have that can help in reproducing the bug would be appreciated. (Mail me privately if you prefer that.) Best regards, Hans Bolinder, Erlang/OTP From thomasl_erlang@REDACTED Wed Jan 3 15:21:00 2007 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Wed, 3 Jan 2007 06:21:00 -0800 (PST) Subject: [erlang-questions] SCTP status Message-ID: <326590.29442.qm@web38811.mail.mud.yahoo.com> Can anyone tell me about the status of the SCTP patches that were submitted a while ago? Will they be integrated If so, what is the timeplan? Thanks in advance. Best, Thomas __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From serge@REDACTED Wed Jan 3 15:56:05 2007 From: serge@REDACTED (Serge Aleynikov) Date: Wed, 03 Jan 2007 09:56:05 -0500 Subject: [erlang-questions] SCTP status In-Reply-To: <326590.29442.qm@web38811.mail.mud.yahoo.com> References: <326590.29442.qm@web38811.mail.mud.yahoo.com> Message-ID: <459BC405.2020200@hq.idt.net> I submitted the R11B-1 SCTP patches a while back, and R11B-2 patches a few days ago. I know that Raimo was busy in Dec and didn't have time to review this then... I'm also eager to receive feedback, as maintaining the patches outside of OTP releases is quite painful indeed. Serge Thomas Lindgren wrote: > Can anyone tell me about the status of the SCTP > patches that were submitted a while ago? Will they be > integrated If so, what is the timeplan? Thanks in > advance. > > Best, > Thomas > From kenneth.lundin@REDACTED Wed Jan 3 16:04:59 2007 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Wed, 3 Jan 2007 16:04:59 +0100 Subject: [erlang-questions] SCTP status In-Reply-To: <326590.29442.qm@web38811.mail.mud.yahoo.com> References: <326590.29442.qm@web38811.mail.mud.yahoo.com> Message-ID: Hi, The status of the SCTP pathces is very good. Our plan is to integrate them into an R11B-x release as soon as we can. I can not promise when that will be but it will most probably not make it into the R11B-3 planned to be released in Jan-Feb. Earliest possible is then the next release R11B-4 which we have not set a date for yet. Probably April. Regards Kenneth (OTP responsible at Ericsson) On 1/3/07, Thomas Lindgren wrote: > > Can anyone tell me about the status of the SCTP > patches that were submitted a while ago? Will they be > integrated If so, what is the timeplan? Thanks in > advance. > > Best, > Thomas > > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From serge@REDACTED Wed Jan 3 18:08:15 2007 From: serge@REDACTED (Serge Aleynikov) Date: Wed, 03 Jan 2007 12:08:15 -0500 Subject: [erlang-questions] N-Queens Message-ID: <459BE2FF.5040603@hq.idt.net> Greetings! I wrote an N-Queen problem solver in C/C++/OCaml/Erlang for conducting a benchmarking exercise. Here are results: $ wc -l nqueens.{c,cpp,ml,erl} 93 nqueens.c 109 nqueens.cpp 61 nqueens.ml 61 nqueens.erl On my host timing is as follows: $ make run # 8 queens, 1000 times # Program Time ./queens_c: 0.96 ./queens_cpp: 1.16 ./queens_ml: 0.77 # OCaml natively compiled ./queens_ml.bcode: 22.55 # OCaml bytecode compiled nqueens.beam: 8.56 Note that Erlang code is natively compiled. Without the native flag it gives about the same time as queens_ml.bcode. If we use optimization (-O3 for C/C++ and -unsafe for OCaml) the timing picture is slightly different. I am curious if anyone can suggest any improvement to nqueens.erl (preserving the algorithm) that would increase its performance (other that parallelization). Regards, Serge -------------- next part -------------- A non-text attachment was scrubbed... Name: nqueens.tar.gz Type: application/x-gzip Size: 3321 bytes Desc: not available URL: From james.hague@REDACTED Wed Jan 3 19:01:11 2007 From: james.hague@REDACTED (James Hague) Date: Wed, 3 Jan 2007 12:01:11 -0600 Subject: [erlang-questions] lists:reverse/1 as a built-in function Message-ID: lists:reverse/1 is already a function written in C, but is there any reason it can't be put on equal footing with length/1, size/1, integer_to_list/2, and so on. Surely reverse is the most commonly used stdlib function, so why not promote it to a true built-in, so there's no need to prefix it with "lists:"? James P.S. I already import lists:reverse in most modules I write, to avoid the prefix, but it seems redundant. From dmitry.kargapolov@REDACTED Thu Jan 4 01:03:57 2007 From: dmitry.kargapolov@REDACTED (Dmitriy Kargapolov) Date: Wed, 03 Jan 2007 19:03:57 -0500 Subject: [erlang-questions] R11B-2 SMP + HiPE: not loading native code Message-ID: <459C446D.1020406@corp.idt.net> Hi, When loading natively compiled code (+native) in R11B-2 emulator running in SMP mode (-smp) I'm getting the following warning: =INFO REPORT==== 3-Jan-2007::18:53:24 === Warning: not loading native code for module test: it was compiled for an incompatible runtime system Does this mean HiPE and SMP could not be used together? From kostis@REDACTED Thu Jan 4 01:15:46 2007 From: kostis@REDACTED (Kostis Sagonas) Date: Thu, 04 Jan 2007 01:15:46 +0100 Subject: [erlang-questions] R11B-2 SMP + HiPE: not loading native code In-Reply-To: <459C446D.1020406@corp.idt.net> References: <459C446D.1020406@corp.idt.net> Message-ID: <459C4732.5020906@cs.ntua.gr> Dmitriy Kargapolov wrote: > Hi, > When loading natively compiled code (+native) in R11B-2 emulator running > in SMP mode (-smp) I'm getting the following warning: > > =INFO REPORT==== 3-Jan-2007::18:53:24 === > Warning: not loading native code for module test: it > was compiled for an incompatible runtime system > > Does this mean HiPE and SMP could not be used together? It simply means that, unlike BEAM code, there is a dependency between the native code generated using some runtime system and the runtime system on which the code is actually run. Put differently, it just means that you have to re-generate the native code using the SMP-enabled system, not generate it using the "standard" one and then try to use it in the SMP one. Kostis From serge@REDACTED Thu Jan 4 02:09:32 2007 From: serge@REDACTED (Serge Aleynikov) Date: Wed, 03 Jan 2007 20:09:32 -0500 Subject: [erlang-questions] R11B-2 SMP + HiPE: not loading native code In-Reply-To: <459C4732.5020906@cs.ntua.gr> References: <459C446D.1020406@corp.idt.net> <459C4732.5020906@cs.ntua.gr> Message-ID: <459C53CC.10004@hq.idt.net> Is there any way to hint erlc (via command line) to use SMP-enabled beam? I was only able to do it like this: $ export ERLC_EMULATOR="erl -smp" $ erlc +native test.erl whereas "erlc +smp +native test.erl" doesn't use the SMP BEAM. Serge Kostis Sagonas wrote: > Dmitriy Kargapolov wrote: >> Hi, >> When loading natively compiled code (+native) in R11B-2 emulator running >> in SMP mode (-smp) I'm getting the following warning: >> >> =INFO REPORT==== 3-Jan-2007::18:53:24 === >> Warning: not loading native code for module test: it >> was compiled for an incompatible runtime system >> >> Does this mean HiPE and SMP could not be used together? > > It simply means that, unlike BEAM code, there is a dependency between > the native code generated using some runtime system and the runtime > system on which the code is actually run. > > Put differently, it just means that you have to re-generate the native > code using the SMP-enabled system, not generate it using the "standard" > one and then try to use it in the SMP one. > > Kostis > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- Serge Aleynikov Routing R&D, IDT Telecom Tel: +1 (973) 438-3436 Fax: +1 (973) 438-1464 From kostis@REDACTED Thu Jan 4 11:23:12 2007 From: kostis@REDACTED (Kostis Sagonas) Date: Thu, 04 Jan 2007 11:23:12 +0100 Subject: [erlang-questions] R11B-2 SMP + HiPE: not loading native code In-Reply-To: <459C53CC.10004@hq.idt.net> References: <459C446D.1020406@corp.idt.net> <459C4732.5020906@cs.ntua.gr> <459C53CC.10004@hq.idt.net> Message-ID: <459CD590.9010303@cs.ntua.gr> Serge Aleynikov wrote: > Is there any way to hint erlc (via command line) to use SMP-enabled beam? > > I was only able to do it like this: > > $ export ERLC_EMULATOR="erl -smp" > $ erlc +native test.erl > > whereas "erlc +smp +native test.erl" doesn't use the SMP BEAM. Both "erl" and "erlc" are scripts that call the corresponding executables depending on the command line switches. I guess the best solution to this problem is that the "erlc" script should accept the same switches as "erl". In particular, it should accept the "-smp" and "-hybrid" switches. Let's hope that the OTP folks are kind enough to do this change. Kostis From mikpe@REDACTED Thu Jan 4 13:25:10 2007 From: mikpe@REDACTED (Mikael Pettersson) Date: Thu, 4 Jan 2007 13:25:10 +0100 Subject: [erlang-questions] N-Queens In-Reply-To: <459BE2FF.5040603@hq.idt.net> References: <459BE2FF.5040603@hq.idt.net> Message-ID: <17820.61990.109482.629648@alkaid.it.uu.se> Serge Aleynikov writes: > Greetings! > > I wrote an N-Queen problem solver in C/C++/OCaml/Erlang for conducting a > benchmarking exercise. Here are results: > > $ wc -l nqueens.{c,cpp,ml,erl} > 93 nqueens.c > 109 nqueens.cpp > 61 nqueens.ml > 61 nqueens.erl > > On my host timing is as follows: > > $ make run # 8 queens, 1000 times > # Program Time > ./queens_c: 0.96 > ./queens_cpp: 1.16 > ./queens_ml: 0.77 # OCaml natively compiled > ./queens_ml.bcode: 22.55 # OCaml bytecode compiled > nqueens.beam: 8.56 > > Note that Erlang code is natively compiled. Without the native flag it > gives about the same time as queens_ml.bcode. > > If we use optimization (-O3 for C/C++ and -unsafe for OCaml) the timing > picture is slightly different. > > I am curious if anyone can suggest any improvement to nqueens.erl > (preserving the algorithm) that would increase its performance (other > that parallelization). Both the C/C++ and O'Caml versions use mutable arrays and omit runtime safety checks, while the Erlang version is using tuples and runtime type and index checks. Apples and oranges... It's not surprising Erlang is slow here, but I am surprised to see interpreted O'Caml being so much slower. In any case, the simplest way to speed up nqueens.erl is to convert it to use HiPE arrays. Also lose the higher-order stuff, and use =:= not ==. /Mikael From kostis@REDACTED Thu Jan 4 13:49:59 2007 From: kostis@REDACTED (Kostis Sagonas) Date: Thu, 04 Jan 2007 13:49:59 +0100 Subject: [erlang-questions] N-Queens In-Reply-To: <17820.61990.109482.629648@alkaid.it.uu.se> References: <459BE2FF.5040603@hq.idt.net> <17820.61990.109482.629648@alkaid.it.uu.se> Message-ID: <459CF7F7.7060803@cs.ntua.gr> Mikael Pettersson wrote: > Serge Aleynikov writes: > > Greetings! > > > > I wrote an N-Queen problem solver in C/C++/OCaml/Erlang for conducting a > > benchmarking exercise. Here are results: > > > > $ wc -l nqueens.{c,cpp,ml,erl} > > 93 nqueens.c > > 109 nqueens.cpp > > 61 nqueens.ml > > 61 nqueens.erl > > > > On my host timing is as follows: > > > > $ make run # 8 queens, 1000 times > > # Program Time > > ./queens_c: 0.96 > > ./queens_cpp: 1.16 > > ./queens_ml: 0.77 # OCaml natively compiled > > ./queens_ml.bcode: 22.55 # OCaml bytecode compiled > > nqueens.beam: 8.56 > > > > Note that Erlang code is natively compiled. Without the native flag it > > gives about the same time as queens_ml.bcode. > > > > If we use optimization (-O3 for C/C++ and -unsafe for OCaml) the timing > > picture is slightly different. > > > > I am curious if anyone can suggest any improvement to nqueens.erl > > (preserving the algorithm) that would increase its performance (other > > that parallelization). > > Both the C/C++ and O'Caml versions use mutable arrays and omit > runtime safety checks, while the Erlang version is using tuples > and runtime type and index checks. Apples and oranges... > > It's not surprising Erlang is slow here, but I am surprised to > see interpreted O'Caml being so much slower. I very much second what Mikael wrote. The comparison is really like comparing apples and oranges. Erlang is simply not designed for kinds of tasks like nqueens and it is penalized by various restrictions in the kinds of compiler optimizations which are allowed. > In any case, the simplest way to speed up nqueens.erl is to > convert it to use HiPE arrays. Also lose the higher-order stuff, > and use =:= not ==. I've only converted Serge's program to use HiPE arrays and =:= instead of ==, but have not removed the higher-order stuff which add a significant overhead. The resulting program (attached) runs about twice as fast. Kostis -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: nqueens_ha.erl URL: From darrinth@REDACTED Thu Jan 4 14:15:06 2007 From: darrinth@REDACTED (Darrin Thompson) Date: Thu, 4 Jan 2007 08:15:06 -0500 Subject: [erlang-questions] Non-free files in Erlang/OTP distribution? In-Reply-To: References: Message-ID: On 1/3/07, Sergei Golovan wrote: > On 1/3/07, Kenneth Lundin wrote: > > Hi, > > > > What about this statement from RSA? (the link below) > > I think it clarifies that it is ok to redistribute derivative work > > regarding the MD5 Message-Digest Algorithm. > > > > http://www.ietf.org/ietf/IPR/RSA-MD-all > > Thanks! It looks like what I tried to find. Though I would like to see > not only "may be made, used, and sold", but also "distributed" :) > The ultimate decision is best made on debian-legal, no? The RSA thing may already have come up. -- Darrin From rickard.s.green@REDACTED Thu Jan 4 14:41:01 2007 From: rickard.s.green@REDACTED (Rickard Green) Date: Thu, 04 Jan 2007 14:41:01 +0100 Subject: [erlang-questions] R11B-2: one more bug with the "-smp" switch In-Reply-To: <459AF02C.1080600@hq.idt.net> References: <459AF02C.1080600@hq.idt.net> Message-ID: <459D03ED.5090701@ericsson.com> I haven't been able to reproduce this. Have this happened just once or does this happen all the time? Have you set any environment variables affecting the emulator such as ERL_FLAGS? If so, what values do you use? BR, Rickard Green, Erlang/OTP Serge Aleynikov wrote: > Happy New bug, everyone! ;-) > > $ uname -a > Linux xxxxxx 2.6.9-34.ELsmp #1 SMP Fri Feb 24 16:54:53 EST 2006 i686 > i686 i386 GNU/Linux > > $ cat test.erl > -module(test). > -export([f/1]). > > f(Args) -> > io:format("~s~n", [filename:join(Args)]). > > $ erl -noshell -run test f "/usr" "local" -s erlang halt > /usr/local > $ erl -smp -noshell -run test f "/usr" "local" -s erlang halt > {"init terminating in > do_boot",{undef,[{test,f,[["/usr","local"]]},{init,start_it,1},{init,start_em,1}]}} > > Crash dump was written to: erl_crash.dump > init terminating in do_boot () > > > Regards, > > Serge > From serge@REDACTED Thu Jan 4 15:21:46 2007 From: serge@REDACTED (Serge Aleynikov) Date: Thu, 04 Jan 2007 09:21:46 -0500 Subject: [erlang-questions] R11B-2 SMP + HiPE: not loading native code In-Reply-To: <459CD590.9010303@cs.ntua.gr> References: <459C446D.1020406@corp.idt.net> <459C4732.5020906@cs.ntua.gr> <459C53CC.10004@hq.idt.net> <459CD590.9010303@cs.ntua.gr> Message-ID: <459D0D7A.7050108@hq.idt.net> Kostis Sagonas wrote: > Serge Aleynikov wrote: >> Is there any way to hint erlc (via command line) to use SMP-enabled beam? >> >> I was only able to do it like this: >> >> $ export ERLC_EMULATOR="erl -smp" >> $ erlc +native test.erl >> >> whereas "erlc +smp +native test.erl" doesn't use the SMP BEAM. > > Both "erl" and "erlc" are scripts that call the corresponding > executables depending on the command line switches. That's what I thought, but unfortunately erlc is not a script. $ readelf -h erlc ELF Header: Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 Class: ELF32 Data: 2's complement, little endian Version: 1 (current) OS/ABI: UNIX - System V ABI Version: 0 Type: EXEC (Executable file) ... > I guess the best solution to this problem is that the "erlc" script > should accept the same switches as "erl". In particular, it should > accept the "-smp" and "-hybrid" switches. > > Let's hope that the OTP folks are kind enough to do this change. I also think it's a good idea. Serge From kostis@REDACTED Thu Jan 4 15:29:06 2007 From: kostis@REDACTED (Kostis Sagonas) Date: Thu, 04 Jan 2007 15:29:06 +0100 Subject: [erlang-questions] R11B-2 SMP + HiPE: not loading native code In-Reply-To: <459D0D7A.7050108@hq.idt.net> References: <459C446D.1020406@corp.idt.net> <459C4732.5020906@cs.ntua.gr> <459C53CC.10004@hq.idt.net> <459CD590.9010303@cs.ntua.gr> <459D0D7A.7050108@hq.idt.net> Message-ID: <459D0F32.90006@cs.ntua.gr> Serge Aleynikov wrote: > Kostis Sagonas wrote: >> Serge Aleynikov wrote: >>> Is there any way to hint erlc (via command line) to use SMP-enabled >>> beam? >>> >>> I was only able to do it like this: >>> >>> $ export ERLC_EMULATOR="erl -smp" >>> $ erlc +native test.erl >>> >>> whereas "erlc +smp +native test.erl" doesn't use the SMP BEAM. >> >> Both "erl" and "erlc" are scripts that call the corresponding >> executables depending on the command line switches. > > That's what I thought, but unfortunately erlc is not a script. Strictly, you are right. (*) However, its functionality is really that of a script and what I am suggesting is easily doable. Kostis (*) It is not a script is so that it also works on Windows. From serge@REDACTED Thu Jan 4 15:48:26 2007 From: serge@REDACTED (Serge Aleynikov) Date: Thu, 04 Jan 2007 09:48:26 -0500 Subject: [erlang-questions] N-Queens In-Reply-To: <459CF7F7.7060803@cs.ntua.gr> References: <459BE2FF.5040603@hq.idt.net> <17820.61990.109482.629648@alkaid.it.uu.se> <459CF7F7.7060803@cs.ntua.gr> Message-ID: <459D13BA.4090100@hq.idt.net> This problem domain is certainly not meant for Erlang. The purpose of this exercise was to compare speed of OCaml's staticly checked bytecode and dynamically checked Erlang's. My initial (wrong) guess also was that interpreted OCaml should be faster. It is pleasant to see that the scheduling overhead of Erlang VM is not significant in this problem compared to OCaml. Also I was quite surprised that OCaml could beat C performance-wise with standard compilation options (with full optimization on, they have about the same performance). BTW, on this host the nqueens_ha version of the code gives: nqueens_ha.beam: 6.79s Regards, Serge Kostis Sagonas wrote: > Mikael Pettersson wrote: >> Serge Aleynikov writes: >> > Greetings! >> > > I wrote an N-Queen problem solver in C/C++/OCaml/Erlang for >> conducting a > benchmarking exercise. Here are results: >> > > $ wc -l nqueens.{c,cpp,ml,erl} >> > 93 nqueens.c >> > 109 nqueens.cpp >> > 61 nqueens.ml >> > 61 nqueens.erl >> > > On my host timing is as follows: >> > > $ make run # 8 queens, 1000 times >> > # Program Time >> > ./queens_c: 0.96 >> > ./queens_cpp: 1.16 >> > ./queens_ml: 0.77 # OCaml natively compiled >> > ./queens_ml.bcode: 22.55 # OCaml bytecode compiled >> > nqueens.beam: 8.56 >> > > Note that Erlang code is natively compiled. Without the native >> flag it > gives about the same time as queens_ml.bcode. >> > > If we use optimization (-O3 for C/C++ and -unsafe for OCaml) the >> timing > picture is slightly different. >> > > I am curious if anyone can suggest any improvement to >> nqueens.erl > (preserving the algorithm) that would increase its >> performance (other > that parallelization). >> >> Both the C/C++ and O'Caml versions use mutable arrays and omit >> runtime safety checks, while the Erlang version is using tuples >> and runtime type and index checks. Apples and oranges... >> >> It's not surprising Erlang is slow here, but I am surprised to >> see interpreted O'Caml being so much slower. > > I very much second what Mikael wrote. The comparison is really like > comparing apples and oranges. Erlang is simply not designed for kinds > of tasks like nqueens and it is penalized by various restrictions in the > kinds of compiler optimizations which are allowed. > >> In any case, the simplest way to speed up nqueens.erl is to >> convert it to use HiPE arrays. Also lose the higher-order stuff, >> and use =:= not ==. > > I've only converted Serge's program to use HiPE arrays and =:= instead > of ==, but have not removed the higher-order stuff which add a > significant overhead. The resulting program (attached) runs about twice > as fast. > > Kostis > > > ------------------------------------------------------------------------ > > %% Purpose: Eight queens problem solver using HiPE arrays > %% Author: Kostis Sagonas > %% Date: 4-Jan-2007 > %% Compile: erlc +native nqueens_ha.erl > %% Run: erl -noshell -run nqueens_ha main 8 1000 -s erlang halt > -module(nqueens_ha). > -export([main/1, queens/3]). > > loop(N, N, F, A) -> F(N, A); > loop(I, N, F, A) -> A1 = F(I, A), loop(I+1, N, F, A1). > > loop_nl(I, N, F) -> loop(I, N, F, ok), io:nl(). > > %% Output solution to console if Display is true. > %% Throws 'abort' when counter signals that MaxCount is reached. > output(_Board, _SolCount, false) -> ok; > output( Board, SolCount, _Display) -> > io:format("~-8w/", [SolCount]), > N = hipe_bifs:array_length(Board) - 1, > loop_nl(0, N, fun(I,_) -> io:format("~2w" , [I]) end), > loop_nl(0, N, fun(I,_) -> io:format("~8w: ", [I]), > QI = hipe_bifs:array_sub(Board, I), > loop_nl(0, N, fun(J,_) when J =:= QI -> io:put_chars("Q "); > (_,_) -> io:put_chars("* ") > end) > end). > > % Is the queen at row I not threatened > safe(_Brd, N, I, N) -> I =:= N; % last column > safe( Brd, N, I, J) -> > case hipe_bifs:array_sub(Brd, I) - hipe_bifs:array_sub(Brd, J) of > 0 -> I =:= J; % vert/horiz threat > D -> case abs(D) =:= I - J of > true -> I =:= J; % diag threat > false -> safe(Brd, N, I, J+1) > end > end. > > % Main algorithm > queens(N, Times, MaxSol) > when is_integer(N), is_integer(Times), is_integer(MaxSol), N > 0, Times > 0 -> > Board = hipe_bifs:array(N, 0), > F = fun(_,_) -> queens1(Board, MaxSol, 0, Times =:= 1, 0) end, > TotalSol = (catch loop(0, Times-1, F, 0)), > io:format("Total: ~w solutions~n", [TotalSol]). > > queens1(Brd, MaxSol, SolCount, Display, I) -> > F = fun(J, Sum) -> hipe_bifs:array_update(Brd, I, J), queens2(Brd, MaxSol, Sum, Display, I) end, > loop(0, hipe_bifs:array_length(Brd) - 1, F, SolCount). > > queens2(Board, MaxSol, SolCount, Display, I) -> > N = hipe_bifs:array_length(Board) - 1, > case safe(Board, N, I, 0) of > false -> SolCount; > true when I =:= N -> SC = SolCount+1, > output(Board, SC, Display), > SC =:= MaxSol andalso throw(MaxSol), > SC; > _ -> queens1(Board, MaxSol, SolCount, Display, I+1) > end. > > % Main function > main([Size, Times]) -> main([Size, Times, "0"]); > main([Size, Times, MaxSol]) when is_list(Size), is_list(Times), is_list(MaxSol) -> > queens(list_to_integer(Size), list_to_integer(Times), list_to_integer(MaxSol)). From sgolovan@REDACTED Thu Jan 4 15:48:10 2007 From: sgolovan@REDACTED (Sergei Golovan) Date: Thu, 4 Jan 2007 17:48:10 +0300 Subject: [erlang-questions] Non-free files in Erlang/OTP distribution? In-Reply-To: References: Message-ID: On 1/4/07, Darrin Thompson wrote: > The ultimate decision is best made on debian-legal, no? The RSA thing > may already have come up. Yes, you're right. But after some discussion in Debian BTS the priority of this bug was lowered, so, we have some time to ask in debian-legal. -- Sergei Golovan From erlang@REDACTED Thu Jan 4 16:59:36 2007 From: erlang@REDACTED (Erlang list) Date: Thu, 04 Jan 2007 15:59:36 +0000 Subject: [erlang-questions] Receiving identical messages from Erlang and from JInterface Message-ID: <459D2468.6090103@oxyware.com> I am just starting to use Erlang and I've run into something I don't understand. Here is a transcript of a shell session when I send two identical messages from a remote Erlang node: (foo@REDACTED)102> b(). ok (foo@REDACTED)103> process_info(self(), messages). {messages,[]} (foo@REDACTED)104> % send duplicate messages from Erlang (foo@REDACTED)104> process_info(self(), messages). {messages,[{<5007.61.0>,hello},{<5007.61.0>,hello}]} (foo@REDACTED)105> receive {P,X} -> {P,X} after 2000 -> false end. {<5007.61.0>,hello} (foo@REDACTED)106> b(). P = <5007.61.0> X = hello ok (foo@REDACTED)107> receive {P,X} -> {P,X} after 2000 -> false end. {<5007.61.0>,hello} (foo@REDACTED)108> process_info(self(), messages). {messages,[]} (foo@REDACTED)109> This works as expected. However, when I do the same but send the messages from a Java program using JInterface the first message is received but pattern matching for the second message seems to fail: (foo@REDACTED)111> b(). ok (foo@REDACTED)112> process_info(self(), messages). {messages,[]} (foo@REDACTED)113> % send duplicate messages from JInterface (foo@REDACTED)113> process_info(self(), messages). {messages,[{<4999.1.0>,hello},{<4999.1.0>,hello}]} (foo@REDACTED)114> receive {P,X} -> {P,X} after 2000 -> false end. {<4999.1.0>,hello} (foo@REDACTED)115> b(). P = <4999.1.0> X = hello ok (foo@REDACTED)116> receive {P,X} -> {P,X} after 2000 -> false end. false (foo@REDACTED)117> process_info(self(), messages). {messages,[{<4999.1.0>,hello}]} (foo@REDACTED)118> The essentials of the Java program are: OtpNode node = new OtpNode("jnode", "secretcookie"); OtpMbox mbox = node.createMbox("mbox1"); OtpErlangObject[] msg = new OtpErlangObject[2]; msg[0] = mbox.self(); msg[1] = new OtpErlangAtom("hello"); OtpErlangTuple tuple = new OtpErlangTuple(msg); mbox.send("foobox", "foo@REDACTED", tuple); erlang:system_info(version) = "5.5.1", R11B Both clients on Windows Win2K, receiver (zippy) is Linux. Any ideas or clues as to where to look or why this doesn't appear to work? Happy New Year everyone 3|;-P From bjorn@REDACTED Thu Jan 4 17:02:50 2007 From: bjorn@REDACTED (Bjorn Gustavsson) Date: 04 Jan 2007 17:02:50 +0100 Subject: [erlang-questions] Arrays and setelement In-Reply-To: <200612291328.kBTDSZcG018977@harpo.it.uu.se> References: <200612291328.kBTDSZcG018977@harpo.it.uu.se> Message-ID: Mikael Pettersson writes: > --===============2110319572== > > On Fri, 29 Dec 2006 03:11:19 +0000, Joel Reymont wrote: > >> setelement works by copying, except when the BEAM compiler > >> can prove that intermediate copies are redundant, in which > >> cases it simple performs assignments. There is an additional constraint: the tuple must not have been garbage collected so that it is in the old generation heap, becase that could create a pointer from the old generation heap to the youngest generation heap (which the garbage collector cannot handle). > The BEAM compiler uses this to optimise tuple and record > initialisation. It may or may not be able to do it in more > general cases; Bj?rn Gustavsson should be able to tell us that. Because of the constraint mentioned above, the compiler only optimizes setelement calls in a straight block of code ("basic block") to be sure that the tuple being modified is in the youngest generation. Furthermore, the first argument for setelement/3 (the Index argument) must be a literal index for the optimization to place. Therefore, the second call to setelement/3 will be replaced with the cheaper "destructive setelement instruction" in this code set(T0) -> T = setelement(3, T0, a), setelement(2, T, b). but not in this code set(I, J, T0) -> T = setelement(I, T0, a), setelement(J, T, b). /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From serge@REDACTED Thu Jan 4 17:03:32 2007 From: serge@REDACTED (Serge Aleynikov) Date: Thu, 04 Jan 2007 11:03:32 -0500 Subject: [erlang-questions] R11B-2: one more bug with the "-smp" switch In-Reply-To: <459D03ED.5090701@ericsson.com> References: <459AF02C.1080600@hq.idt.net> <459D03ED.5090701@ericsson.com> Message-ID: <459D2554.1020406@hq.idt.net> For some reason I can't reproduce it today on the same machine either. Sorry, must be a New Year thingy... :-( Rickard Green wrote: > I haven't been able to reproduce this. Have this happened just once or > does this happen all the time? Have you set any environment variables > affecting the emulator such as ERL_FLAGS? If so, what values do you use? > > BR, > Rickard Green, Erlang/OTP > > Serge Aleynikov wrote: >> Happy New bug, everyone! ;-) >> >> $ uname -a >> Linux xxxxxx 2.6.9-34.ELsmp #1 SMP Fri Feb 24 16:54:53 EST 2006 i686 >> i686 i386 GNU/Linux >> >> $ cat test.erl >> -module(test). >> -export([f/1]). >> >> f(Args) -> >> io:format("~s~n", [filename:join(Args)]). >> >> $ erl -noshell -run test f "/usr" "local" -s erlang halt >> /usr/local >> $ erl -smp -noshell -run test f "/usr" "local" -s erlang halt >> {"init terminating in >> do_boot",{undef,[{test,f,[["/usr","local"]]},{init,start_it,1},{init,start_em,1}]}} >> >> >> Crash dump was written to: erl_crash.dump >> init terminating in do_boot () >> >> >> Regards, >> >> Serge >> > -- Serge Aleynikov Routing R&D, IDT Telecom Tel: +1 (973) 438-3436 Fax: +1 (973) 438-1464 From richardc@REDACTED Thu Jan 4 17:27:05 2007 From: richardc@REDACTED (Richard Carlsson) Date: Thu, 04 Jan 2007 17:27:05 +0100 Subject: [erlang-questions] Receiving identical messages from Erlang and from JInterface In-Reply-To: <459D2468.6090103@oxyware.com> References: <459D2468.6090103@oxyware.com> Message-ID: <459D2AD9.8020608@it.uu.se> Erlang list wrote: > However, when I do the same but send the > messages from a Java program using JInterface the first message is > received but pattern matching for the second message seems to fail: > > (foo@REDACTED)113> process_info(self(), messages). > {messages,[{<4999.1.0>,hello},{<4999.1.0>,hello}]} > (foo@REDACTED)114> receive {P,X} -> {P,X} after 2000 -> false > end. > {<4999.1.0>,hello} > (foo@REDACTED)115> b(). > P = <4999.1.0> > X = hello > ok > (foo@REDACTED)116> receive {P,X} -> {P,X} after 2000 -> false > end. > false > (foo@REDACTED)117> process_info(self(), messages). > {messages,[{<4999.1.0>,hello}]} Try using different variable names in the second receive, e.g. {P1,X1}. This should make it extract the second message from the mailbox. Then you can check whether P =:= P1, which is probably not the case since you got this problem. After that, perhaps term_to_binary(P) and term_to_binary(P1) might give more information about what is happening. /Richard From richardc@REDACTED Thu Jan 4 20:18:25 2007 From: richardc@REDACTED (Richard Carlsson) Date: Thu, 04 Jan 2007 20:18:25 +0100 Subject: [erlang-questions] Receiving identical messages from Erlang and from JInterface In-Reply-To: <459D3EEF.6050508@oxyware.com> References: <459D2468.6090103@oxyware.com> <459D2AD9.8020608@it.uu.se> <459D3EEF.6050508@oxyware.com> Message-ID: <459D5301.2060308@it.uu.se> Hubert Matthews wrote: > Richard Carlsson wrote: >> Try using different variable names in the second receive, e.g. {P1,X1}. > > Doing that works fine. What I'm trying to understand is why seemingly > identical terms sent from an Erlang client match but when sent from Java > don't match. If they were incorrectly sent by Java then why are they > displayed correctly in the process' message queue? There seems to be a difference in the bit representation, which is for some reason not visible in the displayed form <4999.1.0>. > P == P1 gives false, as does P =:= P1. > > (foo@REDACTED)60> term_to_binary(P). > <<131,103,100,0,11,106,110,111,100,101,64,106,117,109,98,111,0,0,0,1,0,0,0,0,3>> > > (foo@REDACTED)61> term_to_binary(P1). > <<131,103,100,0,11,106,110,111,100,101,64,106,117,109,98,111,0,0,0,1,0,0,0,0,1>> > > The last byte is different: 3 then 1. > > When sent from Erlang I get something completely different: > > (foo@REDACTED)68> term_to_binary(PE). > <<131,103,100,0,24,119,105,98,98,108,101,64,106,117,109,98,111,46,111,120,121,119,97,114,101,46,110,101,116,...>> I expect that there is someone out there on the list with more knowledge about pid encodings and Jinterface who can see what the problem is. /Richard From david.nospam.hopwood@REDACTED Thu Jan 4 22:11:45 2007 From: david.nospam.hopwood@REDACTED (David Hopwood) Date: Thu, 04 Jan 2007 21:11:45 +0000 Subject: [erlang-questions] N-Queens In-Reply-To: <17820.61990.109482.629648@alkaid.it.uu.se> References: <459BE2FF.5040603@hq.idt.net> <17820.61990.109482.629648@alkaid.it.uu.se> Message-ID: <459D6D91.5040107@blueyonder.co.uk> Mikael Pettersson wrote: > Serge Aleynikov writes: > > Greetings! > > > > I wrote an N-Queen problem solver in C/C++/OCaml/Erlang for conducting a > > benchmarking exercise. Here are results: > > > > $ wc -l nqueens.{c,cpp,ml,erl} > > 93 nqueens.c > > 109 nqueens.cpp > > 61 nqueens.ml > > 61 nqueens.erl > > > > On my host timing is as follows: > > > > $ make run # 8 queens, 1000 times > > # Program Time > > ./queens_c: 0.96 > > ./queens_cpp: 1.16 > > ./queens_ml: 0.77 # OCaml natively compiled > > ./queens_ml.bcode: 22.55 # OCaml bytecode compiled > > nqueens.beam: 8.56 > > > > Note that Erlang code is natively compiled. Without the native flag it > > gives about the same time as queens_ml.bcode. > > > > If we use optimization (-O3 for C/C++ and -unsafe for OCaml) the timing > > picture is slightly different. > > > > I am curious if anyone can suggest any improvement to nqueens.erl > > (preserving the algorithm) that would increase its performance (other > > that parallelization). > > Both the C/C++ and O'Caml versions use mutable arrays and omit > runtime safety checks, while the Erlang version is using tuples > and runtime type and index checks. Apples and oranges... The O'Caml version that takes 0.77 seconds is not omitting runtime safety checks. The time for O'Caml compiled with -unsafe was not given. -- David Hopwood From per@REDACTED Thu Jan 4 23:40:45 2007 From: per@REDACTED (Per Hedeland) Date: Thu, 4 Jan 2007 23:40:45 +0100 (CET) Subject: [erlang-questions] Receiving identical messages from Erlang and from JInterface In-Reply-To: <459D5301.2060308@it.uu.se> Message-ID: <200701042240.l04MejZf073837@pluto.hedeland.org> Richard Carlsson wrote: > >Hubert Matthews wrote: >> Richard Carlsson wrote: >>> Try using different variable names in the second receive, e.g. {P1,X1}. >> >> Doing that works fine. What I'm trying to understand is why seemingly >> identical terms sent from an Erlang client match but when sent from Java >> don't match. If they were incorrectly sent by Java then why are they >> displayed correctly in the process' message queue? > >There seems to be a difference in the bit representation, which is for >some reason not visible in the displayed form <4999.1.0>. > >> P == P1 gives false, as does P =:= P1. >> >> (foo@REDACTED)60> term_to_binary(P). >> <<131,103,100,0,11,106,110,111,100,101,64,106,117,109,98,111,0,0,0,1,0,0,0,0,3>> >> >> (foo@REDACTED)61> term_to_binary(P1). >> <<131,103,100,0,11,106,110,111,100,101,64,106,117,109,98,111,0,0,0,1,0,0,0,0,1>> >> >> The last byte is different: 3 then 1. That would be the "creation" part of the pid (managed by epmd), intended to be able to differentiate between processes from different invocations of a node with a given name - e.g. if the node restarts, all the processes spawned at startup are likely to get the same "number" as in the previous startup, yet they are not the same processes: (foo@REDACTED)1> self(). <0.36.0> (foo@REDACTED)2> term_to_binary(v(1)). <<131,103,100,0,9,102,111,111,64,112,108,117,116,111,0,0,0,36,0,0,0,0,2>> ^ (kill the node and start it again) (foo@REDACTED)1> self(). <0.36.0> (foo@REDACTED)2> term_to_binary(v(1)). <<131,103,100,0,9,102,111,111,64,112,108,117,116,111,0,0,0,36,0,0,0,0,3>> ^ I don't know anything about JInterface, but if those messages were sent from two different invocations of the Java program, it seems everything is working as designed (otherwise not:-). >> When sent from Erlang I get something completely different: >> >> (foo@REDACTED)68> term_to_binary(PE). >> <<131,103,100,0,24,119,105,98,98,108,101,64,106,117,109,98,111,46,111,120,121,119,97,114,101,46,110,101,116,...>> It's essentially due to the node name that is part of the external representation of a pid: (foo@REDACTED)3> [106,110,111,100,101,64,106,117,109,98,111]. "jnode@REDACTED" (foo@REDACTED)4> [119,105,98,98,108,101,64,106,117,109,98,111,46,111,120,121,119,97,114,101,46,110,101,116]. "wibble@REDACTED" Btw, you should probably choose "long" or "short" host name the same way for Erlang and JInterface - for Erlang nodes, those started with -name vs -sname can't talk to each other - this is apparently not the case with Erlang + Java, but there might be other problems waiting to happen... --Per Hedeland From joelr1@REDACTED Sat Jan 6 15:57:10 2007 From: joelr1@REDACTED (Joel Reymont) Date: Sat, 6 Jan 2007 14:57:10 +0000 Subject: [erlang-questions] Knowledge base in Erlang Message-ID: Folks, I'm tasked with rewriting a project from Lisp to Erlang. The project has a frames system where "objects" are represented as collections of properties. The "schemas" are kept separate from the data and schemas can inherit from other schemas. The complication in my case is that updates are versioned. Each update is time-stamped and old data is pushed away. This makes it easy to see the state of the system at any given point in time. I'm thinking of using a table per object property and indexing it on {object id, timestamp}. I know that I can use ordered_set but I'm wondering about the order. Can I retrieve the data matching the highest index value which in my case would be the last value pushed? What about the lowest index value? How many tables can you keep in Mnesia? Would it make more sense to have a table per property _and_ object instance, i.e. call the table property_object_id and keep the index just on timestamp? This would, of course, exponentially increase the number of tables in the system. Thanks, Joel -- http://wagerlabs.com/ From sean.hinde@REDACTED Sat Jan 6 18:14:20 2007 From: sean.hinde@REDACTED (Sean Hinde) Date: Sat, 6 Jan 2007 17:14:20 +0000 Subject: [erlang-questions] Knowledge base in Erlang In-Reply-To: References: Message-ID: <458DCEFD-58DA-47E9-99BF-6A1C3494B110@gmail.com> On 6 Jan 2007, at 14:57, Joel Reymont wrote: > Folks, > > I'm tasked with rewriting a project from Lisp to Erlang. The project > has a frames system where "objects" are represented as collections of > properties. The "schemas" are kept separate from the data and schemas > can inherit from other schemas. > > The complication in my case is that updates are versioned. Each > update is time-stamped and old data is pushed away. This makes it > easy to see the state of the system at any given point in time. > > I'm thinking of using a table per object property and indexing it on > {object id, timestamp}. I know that I can use ordered_set but I'm > wondering about the order. Can I retrieve the data matching the > highest index value which in my case would be the last value pushed? > What about the lowest index value? mnesia:dirty_first/last/1 > > How many tables can you keep in Mnesia? Would it make more sense to > have a table per property _and_ object instance, i.e. call the table > property_object_id and keep the index just on timestamp? This would, > of course, exponentially increase the number of tables in the system. probably not a good idea (depending on the size of the system). You can have about as many tables as there are available ets tables in the system. Sean From micke@REDACTED Sat Jan 6 20:52:36 2007 From: micke@REDACTED (Michael Fogeborg) Date: Sat, 06 Jan 2007 20:52:36 +0100 Subject: [erlang-questions] Any erlang'ers in India Message-ID: I'm in India (Delhi and north...) from 10 til 25 of january. Are there any Indian erlang'ers ? -- From joelr1@REDACTED Sat Jan 6 23:49:13 2007 From: joelr1@REDACTED (Joel Reymont) Date: Sat, 6 Jan 2007 22:49:13 +0000 Subject: [erlang-questions] Arrays and setelement In-Reply-To: References: <200612291328.kBTDSZcG018977@harpo.it.uu.se> Message-ID: Bjorn, What is the reason behind the literal index restriction? Why not allow the optimization if J was assured by a 'when' guard to be, say, an integer. Thanks, Joel On Jan 4, 2007, at 4:02 PM, Bjorn Gustavsson wrote: > Furthermore, the first argument for setelement/3 (the Index argument) > must be a literal index for the optimization to place. > > Therefore, the second call to setelement/3 will be replaced with the > cheaper "destructive setelement instruction" in this code > > set(T0) -> > T = setelement(3, T0, a), > setelement(2, T, b). > > but not in this code > > set(I, J, T0) -> > T = setelement(I, T0, a), > setelement(J, T, b). -- http://wagerlabs.com/ From bob@REDACTED Sun Jan 7 00:03:13 2007 From: bob@REDACTED (Bob Ippolito) Date: Sat, 6 Jan 2007 15:03:13 -0800 Subject: [erlang-questions] Tuning mnesia for mnesia:dirty_update_counter w/ disc_copies? Message-ID: <6a36e7290701061503k3c99136dqb4c1905916f352b1@mail.gmail.com> I started using mnesia recently in one of my applications (running on R11B-2, FreeBSD) so that the data was persistent in case I had to restart the server (the distribution features are also interesting, but not neccessary yet). The application originally used ets, but now it's using mnesia tables with disc_copies. My usage pattern is such that my application does almost 100% dirty reads and writes. The writes are entirely done by mnesia:dirty_update_counter (with one transactional read+write to handle the 0 case), and the reads are done with dirty_read. This is currently all serialized through one process on one node anyway, so I have no use for the transactional features at the moment. I only have a few hundred records in the table, but dirty_update_counter is being called extremely often. So often in fact that occasionally I get these messages (it also ends up using a lot of RAM): =ERROR REPORT==== 6-Jan-2007::14:43:26 === Mnesia(...): ** WARNING ** Mnesia is overloaded: {dump_log, write_threshold} Is there anything I can tune, or will I have to switch back to something RAM based (e.g. using ets, but flushing periodically to Mnesia)? For reference, the code looks like this: track(Tag, Inc) -> %% dirty_update_counter is silly case mnesia:dirty_update_counter(db, Tag, Inc) of X when X == Inc, Inc > 0 -> F = fun () -> [R] = mnesia:read(db, Tag, write), mnesia:write(R) end, mnesia:transaction(F); _ -> ok end. fetch(Tag) -> case mnesia:dirty_read(db, Tag) of [#db{tag=Tag, count=Res}] -> Res; [] -> 0 end. -bob From bjorn@REDACTED Sun Jan 7 11:37:02 2007 From: bjorn@REDACTED (Bjorn Gustavsson) Date: 07 Jan 2007 11:37:02 +0100 Subject: [erlang-questions] Arrays and setelement In-Reply-To: References: <200612291328.kBTDSZcG018977@harpo.it.uu.se> Message-ID: Joel Reymont writes: > Bjorn, > > What is the reason behind the literal index restriction? Speed. Allowing a variable for Index would have made the instruction slower and/or increased the code size. (And increased code size for the Beam interpreter could mean less speed as well, because of worse cache hit rat.) /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From joelr1@REDACTED Sun Jan 7 14:14:22 2007 From: joelr1@REDACTED (Joel Reymont) Date: Sun, 7 Jan 2007 13:14:22 +0000 Subject: [erlang-questions] Arrays and setelement In-Reply-To: References: <200612291328.kBTDSZcG018977@harpo.it.uu.se> Message-ID: <8ECBEEBB-2B98-4879-9172-2317F2088009@gmail.com> Bjorn, I have a nagging suspicion that performing the optimization for a "certified" integer won't slow things down much or increase code size. This would be a localized change that would also remove one of the biggest drawbacks to Erlang, in my opinion. Can you point me to the section of the source code that takes care of this optimization? I would try a mod and check performance. Thanks, Joel On Jan 7, 2007, at 10:37 AM, Bjorn Gustavsson wrote: > Joel Reymont writes: > >> Bjorn, >> >> What is the reason behind the literal index restriction? > > Speed. Allowing a variable for Index would have made the instruction > slower and/or increased the code size. (And increased code size for > the > Beam interpreter could mean less speed as well, because of worse cache > hit rat.) -- http://wagerlabs.com/ From ingela@REDACTED Mon Jan 8 11:07:49 2007 From: ingela@REDACTED (Ingela Anderton Andin) Date: Mon, 08 Jan 2007 11:07:49 +0100 Subject: [erlang-questions] odbc:param_query works in window ? In-Reply-To: References: Message-ID: <45A217F5.4040805@erix.ericsson.se> Hi! In your particular case it looks like the driver does not support parameterized queries, not all drivers do! However there is still a problem with the released windows version where all data was "inserted into"/"selected from" the database but something broke during the process of returning the answer to Erlang. Just before Christmas I though I found a pointer error causing this but on second thought I was mistaken in what was actually caused the problem. There seems to be a possibility of this being a windows compiler problem. (We have a pretty old windows compiler). The latest not yet released version of odbc tries to works around this and seems to works well on windows, but I am not totally convinced that the potential compiler problem is the real cause. We just added some new test platforms for the odbc application and though it is running well on most platforms there are some of the new unixplatforms where there seems to be a problem. So until I can verify what the problem is there potential could still be a nasty pointer error somewhere so the hunt continues... Ingela - OTP team > Message: 2 > Date: Wed, 27 Dec 2006 18:17:19 +0530 > From: "Siddharth Pareek" > Subject: [erlang-questions] odbc:param_query works in window ? > To: "Erlang" > Message-ID: <00a701c729b5$2bf7fbc0$2301a8c0@REDACTED> > Content-Type: text/plain; charset="iso-8859-1" > > > hi, > i was using the parameterzed query in Erlang using the module odbc:param_query. > The mesage passed is : odbc:param_query(Ref,"Select count(*) from counter where type=?",[{{sql_varchar,20},["crick"]}]). > > > Below is the error that is generated. > > {error,connection_closed} > =ERROR REPORT==== 27-Dec-2006::18:15:10 === > ** Generic server <0.95.0> terminating > ** Last message in was {#Port<0.185>,{exit_status,10}} > ** When Server state == {state,#Port<0.185>, > {<0.35.0>,#Ref<0.0.0.280>} > <0.35.0>, > undefined, > on, > true, > true, > on, > connected, > undefined, > 0, > [#Port<0.183>,#Port<0.184> > #Port<0.186>, > #Port<0.187>} > ** Reason for termination == > ** {port_exit,does_not_support_param_arrays} > > Is there any problem in my message passing or I also heard that windows does not support the param_query .... > > Thanks and Regards, > Siddharth Pareek > From joelr1@REDACTED Mon Jan 8 11:43:30 2007 From: joelr1@REDACTED (Joel Reymont) Date: Mon, 8 Jan 2007 10:43:30 +0000 Subject: [erlang-questions] Highest number of processes in your system Message-ID: Folks, What is the highest number of processes that you have seen in your system? Anyone with over a million processes? Thanks, Joel -- http://wagerlabs.com/ From lenartlad@REDACTED Mon Jan 8 12:03:10 2007 From: lenartlad@REDACTED (Ladislav Lenart) Date: Mon, 08 Jan 2007 12:03:10 +0100 Subject: [erlang-questions] Question about record_info Message-ID: <45A224EE.6080306@volny.cz> Hello, How can I obtain info about a record given its name? For example let's suppose I have an obligate person record with fields: name, phone and address. I would like to be able to do the following: record_info(fields, person) %% -> {name, phone, address} The following is what the reference manual says about the topic (section 8.7 Internal Representation of Records): ---------------------------------------------------------------- To each module using records, a pseudo function is added during compilation to obtain information about records: record_info(fields, Record) -> [Field] record_info(size, Record) -> Size Size is the size of the tuple representation, that is one more than the number of fields. ---------------------------------------------------------------- But whatever I try, I get either: * undef for record_info function, * illegal record info, * record Name undefined. Please help. Thanks, Ladislav Lenart From luna@REDACTED Mon Jan 8 12:36:26 2007 From: luna@REDACTED (Daniel Luna) Date: Mon, 8 Jan 2007 12:36:26 +0100 (CET) Subject: [erlang-questions] Question about record_info In-Reply-To: <45A224EE.6080306@volny.cz> References: <45A224EE.6080306@volny.cz> Message-ID: On Mon, 8 Jan 2007, Ladislav Lenart wrote: > How can I obtain info about a record given its name? > For example let's suppose I have an obligate person > record with fields: name, phone and address. I would > like to be able to do the following: > record_info(fields, person) %% -> {name, phone, address} > > The following is what the reference manual says about the > topic (section 8.7 Internal Representation of Records): > > ---------------------------------------------------------------- > To each module using records, a pseudo function is added > during compilation to obtain information about records: > > record_info(fields, Record) -> [Field] > record_info(size, Record) -> Size > > Size is the size of the tuple representation, that is one > more than the number of fields. > ---------------------------------------------------------------- > > But whatever I try, I get either: > * undef for record_info function, > * illegal record info, > * record Name undefined. record_info is not a proper function. It only exists during compilation, which means that it cannot take variable arguments. record_info(fields, address) %% works Rec = address, record_info(fields, Rec) %% doesn't work! Of course it only works if the address record is defined in that module. If you do want a function that uses record_info, try to use a macro instead. This will work: -define(print_fields(Rec), io:format("~p~n", [record_info(fields, Rec)])). And then use: ?print_fields(address) This will not work: print_fields(Rec) -> io:format("~p~n", [record_info(fields, Rec)]). So you need two things: 1. the record needs to be defined in the module where you use record_info (through an -include or through -record). 2. The argument to record_info needs to be an 'atom' and not a Variable. /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 lenartlad@REDACTED Mon Jan 8 14:03:30 2007 From: lenartlad@REDACTED (Ladislav Lenart) Date: Mon, 08 Jan 2007 14:03:30 +0100 Subject: [erlang-questions] Question about record_info In-Reply-To: References: <45A224EE.6080306@volny.cz> Message-ID: <45A24122.7040304@volny.cz> Daniel Luna wrote: > On Mon, 8 Jan 2007, Ladislav Lenart wrote: >> How can I obtain info about a record given its name? >> For example let's suppose I have an obligate person >> record with fields: name, phone and address. I would >> like to be able to do the following: >> record_info(fields, person) %% -> {name, phone, address} >> >> The following is what the reference manual says about the >> topic (section 8.7 Internal Representation of Records): >> >> ---------------------------------------------------------------- >> To each module using records, a pseudo function is added >> during compilation to obtain information about records: >> >> record_info(fields, Record) -> [Field] >> record_info(size, Record) -> Size >> >> Size is the size of the tuple representation, that is one >> more than the number of fields. >> ---------------------------------------------------------------- >> >> But whatever I try, I get either: >> * undef for record_info function, >> * illegal record info, >> * record Name undefined. > > record_info is not a proper function. It only exists during compilation, > which means that it cannot take variable arguments. > > record_info(fields, address) %% works > > Rec = address, > record_info(fields, Rec) %% doesn't work! > > Of course it only works if the address record is defined in that module. > > If you do want a function that uses record_info, try to use a macro > instead. > > This will work: > > -define(print_fields(Rec), io:format("~p~n", [record_info(fields, Rec)])). > > And then use: ?print_fields(address) > > This will not work: > > print_fields(Rec) -> > io:format("~p~n", [record_info(fields, Rec)]). > > > So you need two things: > > 1. the record needs to be defined in the module where you use > record_info (through an -include or through -record). > > 2. The argument to record_info needs to be an 'atom' and not a Variable. Thank you, I finally managed to make it work. My problem was that I didn't know that record_info is not a normal function. I thought that it is automatically compiled to each module that uses records and not that it only exists during compilation of the module. Thanks again, Ladislav Lenart From lucian@REDACTED Mon Jan 8 14:11:34 2007 From: lucian@REDACTED (Lucian PARVU) Date: Mon, 08 Jan 2007 15:11:34 +0200 Subject: [erlang-questions] opensuse 10.2 erlang build error Message-ID: <45A24306.6070603@itcnetworks.ro> Hi All, In case you have this issue, you can use this fix: [ISSUE] Erlan otp_src_11B-2 Build Error on OpenSuse 10.2: .... /i686-pc-linux-gnu/opt/hybrid/hipe_x86_signal.o: In function `my_sigaction': /otp_src_R11B-2/erts/emulator/hipe/hipe_x86_signal.c:220: undefined reference to `INIT' /otp_src_R11B-2/erts/emulator/hipe/hipe_x86_signal.c:230: undefined reference to `__next_sigaction' obj/i686-pc-linux-gnu/opt/hybrid/hipe_x86_signal.o: In function `hipe_signal_init': /otp_src_R11B-2/erts/emulator/hipe/hipe_x86_signal.c:305: undefined reference to `INIT' obj/i686-pc-linux-gnu/opt/hybrid/hipe_x86_signal.o: In function `my_sigaction': /otp_src_R11B-2/erts/emulator/hipe/hipe_x86_signal.c:220: undefined reference to `INIT' /otp_src_R11B-2/erts/emulator/hipe/hipe_x86_signal.c:230: undefined reference to `__next_sigaction' /otp_src_R11B-2/erts/emulator/hipe/hipe_x86_signal.c:220: undefined reference to `INIT' /otp_src_R11B-2/erts/emulator/hipe/hipe_x86_signal.c:230: undefined reference to `__next_sigaction' [CAUSE] OpenSuse 10.2 uses glibc version 2.5 [FIX] You need to modify otp_src_R11B-2/erts/emulator/hipe/hipe_x86_signal.c line 37 to: #if __GLIBC__ == 2 && (__GLIBC_MINOR__ == 3 || __GLIBC_MINOR__ == 4 || __GLIBC_MINOR__ == 5) Thanks, Lucian Parvu ITC Networks From richardc@REDACTED Mon Jan 8 16:13:21 2007 From: richardc@REDACTED (Richard Carlsson) Date: Mon, 08 Jan 2007 16:13:21 +0100 Subject: [erlang-questions] lists:reverse/1 as a built-in function In-Reply-To: References: Message-ID: <45A25F91.2010502@it.uu.se> James Hague wrote: > lists:reverse/1 is already a function written in C, but is there any > reason it can't be put on equal footing with length/1, size/1, > integer_to_list/2, and so on. Surely reverse is the most commonly > used stdlib function, so why not promote it to a true built-in, so > there's no need to prefix it with "lists:"? The set of auto-imported functions ("built-in" is a much wider concept) is not possible to extend without breaking backwards compatibility. Once upon a time, for some random reason, the unfortunate choice was made to let the auto-imported functions take priority over any locally defined function of the same name. Hence, adding e.g. lists:reverse/1 to the set would cause it to be called instead of any user-defined local reverse/1. Although the compiler would warn about the local, conflicting definition (which is not used), the program would still compile, but get a different behaviour. It might be a rare thing for people to define a local function called reverse/1, but this kind of change is usually unacceptable for many users. It would be possible to reverse the priority of auto-imported and local functions in a new version of the compiler, with an option to use the old behaviour, but it seems to me that even this kind of change is politically difficult. (There are several other useful language changes that could be handled the same way, if users would accept it.) I'm pretty sure that such compiler switches and incompatibilities are not seen as much of a problem (compared to the advantages of getting an improved language) by individual users and hobby programmers, but those professionals out there who are maintaining large systems might have completely different opinions about it, and I'd really like to hear what they have to say. Any takers? /Richard From rpettit@REDACTED Mon Jan 8 16:38:04 2007 From: rpettit@REDACTED (Rick Pettit) Date: Mon, 8 Jan 2007 09:38:04 -0600 Subject: [erlang-questions] Highest number of processes in your system In-Reply-To: References: Message-ID: <20070108153804.GA5261@vailsys.com> On Mon, Jan 08, 2007 at 10:43:30AM +0000, Joel Reymont wrote: > Folks, > > What is the highest number of processes that you have seen in your > system? > > Anyone with over a million processes? A google search for "erlang million processes" turns up many links, one of which being: http://en.wikipedia.org/wiki/Erlang_programming_language "It should also be noted that Erlang processes are neither OS processes nor OS threads, they are lightweight threads somewhat similar to Java's 'green threads'. As a result, Erlang processes are extremely lightweight (the estimated minimal overhead of an Erlang process is 300 bytes) and a very large number of them can be created without performance degradation (a benchmark with 20 million processes was tried[1])." And the link for the benchmarking: http://groups.google.com/group/comp.lang.functional/msg/33b7a62afb727a4f?dmode=source -Rick From serge@REDACTED Mon Jan 8 17:18:21 2007 From: serge@REDACTED (Serge Aleynikov) Date: Mon, 08 Jan 2007 11:18:21 -0500 Subject: [erlang-questions] New tutorial added Message-ID: <45A26ECD.7080206@hq.idt.net> Hi, I added a new tutorial on trapexit: "Gen_event demystified". http://wiki.trapexit.org/index.php/Gen_event_demystified Regards, Serge From sanjaya@REDACTED Tue Jan 9 09:26:11 2007 From: sanjaya@REDACTED (Sanjaya Vitharana) Date: Tue, 9 Jan 2007 13:56:11 +0530 Subject: [erlang-questions] restarting childs under simple_one_for_one supervisor Message-ID: <032e01c733c7$dd5a2750$9a0810ac@wavenet.lk> Hi All, Scenario: simple_one_for_one supervisor supervising for bunch of fsms (gen_fsm). Need to restart all the childs (fsms) under that simple_one_for_one supervisor. Questions: 1.) Are there any way to restart the childs (fsms) one by one? 2.) Are their any way to restart the simple_one_for_one supervisor instead of above 1 ? so the childs will restart automatically. 3.) What is the proper way if above 1 & 2 methods are not suit for the task. NOTE: Erlang Manual Says ... The functions terminate_child/2, delete_child/2 and restart_child/2 are invalid for simple_one_for_one supervisors and will return {error,simple_one_for_one} if the specified supervisor uses this restart strategy. Thanks in Advance Sanjaya Vitharana. -------------- next part -------------- An HTML attachment was scrubbed... URL: From Lennart.Ohman@REDACTED Tue Jan 9 11:06:35 2007 From: Lennart.Ohman@REDACTED (=?iso-8859-1?Q?Lennart_=D6hman?=) Date: Tue, 9 Jan 2007 11:06:35 +0100 Subject: [erlang-questions] restarting childs under simple_one_for_onesupervisor References: <032e01c733c7$dd5a2750$9a0810ac@wavenet.lk> Message-ID: Hi, I believe the answer to your question is in, as you seem to be suspecting, (3). The simple-one-for-one is not meant for what I believe you want to do. A child of a simple-one-for-one is not expected to be managed that much in detail on command by its supervisor. I guess you have been "attracted" to the possibility to start children (dynamically) after the creation of the supervisor. And it seems very easy to start alot of the same kind of process children!? You can do this almost as easy with a regular one-for-one supervisor. You simply start a one-for-one without any "regular" children. Then you add what ever children you need as dynamic children. Then you can manage them (from a process outside the hierarchy) as necessary. Your only "trouble" would be that you need to come up with a (within this supervisor) unique name for each and every one of them. Hope this puts you on a track to solving your problem. Best Regards Lennart ------------------------------------------------------------- Lennart Ohman phone : +46-8-587 623 27 Sj?land & Thyselius Telecom AB cellular: +46-70-552 6735 Sehlstedtsgatan 6 fax : +46-8-667 8230 SE-115 28 STOCKHOLM, SWEDEN email : lennart.ohman@REDACTED ________________________________ Fr?n: erlang-questions-bounces@REDACTED genom Sanjaya Vitharana Skickat: ti 2007-01-09 09:26 Till: erlang-questions@REDACTED ?mne: [erlang-questions] restarting childs under simple_one_for_onesupervisor Hi All, Scenario: simple_one_for_one supervisor supervising for bunch of fsms (gen_fsm). Need to restart all the childs (fsms) under that simple_one_for_one supervisor. Questions: 1.) Are there any way to restart the childs (fsms) one by one? 2.) Are their any way to restart the simple_one_for_one supervisor instead of above 1 ? so the childs will restart automatically. 3.) What is the proper way if above 1 & 2 methods are not suit for the task. NOTE: Erlang Manual Says ... The functions terminate_child/2, delete_child/2 and restart_child/2 are invalid for simple_one_for_one supervisors and will return {error,simple_one_for_one} if the specified supervisor uses this restart strategy. Thanks in Advance Sanjaya Vitharana. -------------- next part -------------- An HTML attachment was scrubbed... URL: From joelr1@REDACTED Tue Jan 9 12:24:07 2007 From: joelr1@REDACTED (Joel Reymont) Date: Tue, 9 Jan 2007 11:24:07 +0000 Subject: [erlang-questions] Generating a variable in a macro Message-ID: <791EBDF7-E650-4242-9EFD-2E8B4A177999@gmail.com> Folks, Is there a way to "auto-generate" a variable in a macro ala (gensym) in Lisp? I have a macro that looks like this: -define(make_shared_table(Table, Nodes, Any), case mnesia:create_table(Table, [ {disc_copies, Nodes}, {type, set}, {attributes, record_info(fields, Table)} ]) of {atomic, ok} -> ok; Any -> error_logger:error_report([{message, "Cannot install table"}, {table, Table}, {error, Any}, {nodes, Nodes}]) end()). I use it like this ?make_shared_table(counter, Nodes, Any1), ?make_shared_table(schema, Nodes, Any2), Unless I pass Any1, Any2, etc. into the macro, erl will complain that the use of Any is unsafe. Any workarounds apart from passing the error variable as a macro argument? Thanks, Joel -- http://wagerlabs.com/ From vladdu55@REDACTED Tue Jan 9 12:52:00 2007 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Tue, 9 Jan 2007 12:52:00 +0100 Subject: [erlang-questions] Generating a variable in a macro In-Reply-To: <791EBDF7-E650-4242-9EFD-2E8B4A177999@gmail.com> References: <791EBDF7-E650-4242-9EFD-2E8B4A177999@gmail.com> Message-ID: <95be1d3b0701090352i1ebf0741s5e2b40b85c09073a@mail.gmail.com> Hi, On 1/9/07, Joel Reymont wrote: > Is there a way to "auto-generate" a variable in a macro ala (gensym) > in Lisp? The short answer is sorry, no. You could use a function instead of a macro and inline it - did you try that? The longer answer to your question is that it could probably be done by using "gensym(Any)" in the macro instead of "Any" and adding a parse transform to transform that into a generated symbol. The problem is that the macro is inlined before the parsing and the parser has no clue about what the scope of each macro is (so that it uses the same symbol inside the same macro expansion, but different ones in different expansions) best regards, Vlad From mats.cronqvist@REDACTED Tue Jan 9 12:50:19 2007 From: mats.cronqvist@REDACTED (Mats Cronqvist) Date: Tue, 09 Jan 2007 12:50:19 +0100 Subject: [erlang-questions] Generating a variable in a macro In-Reply-To: <791EBDF7-E650-4242-9EFD-2E8B4A177999@gmail.com> References: <791EBDF7-E650-4242-9EFD-2E8B4A177999@gmail.com> Message-ID: <45A3817B.5020908@ericsson.com> Joel Reymont wrote: > Any workarounds apart from passing the > error variable as a macro argument? turn make_shared_table/3 into a function? mats From joelr1@REDACTED Tue Jan 9 12:56:15 2007 From: joelr1@REDACTED (Joel Reymont) Date: Tue, 9 Jan 2007 11:56:15 +0000 Subject: [erlang-questions] Generating a variable in a macro In-Reply-To: <45A3817B.5020908@ericsson.com> References: <791EBDF7-E650-4242-9EFD-2E8B4A177999@gmail.com> <45A3817B.5020908@ericsson.com> Message-ID: <5904C914-A2C4-4DAF-B4A5-67C5F6804481@gmail.com> I thought of that but there's record_info which is compile-time. On Jan 9, 2007, at 11:50 AM, Mats Cronqvist wrote: > Joel Reymont wrote: >> Any workarounds apart from passing the error variable as a macro >> argument? > > turn make_shared_table/3 into a function? > > mats -- http://wagerlabs.com/ From vladdu55@REDACTED Tue Jan 9 13:08:36 2007 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Tue, 9 Jan 2007 13:08:36 +0100 Subject: [erlang-questions] Generating a variable in a macro In-Reply-To: <5904C914-A2C4-4DAF-B4A5-67C5F6804481@gmail.com> References: <791EBDF7-E650-4242-9EFD-2E8B4A177999@gmail.com> <45A3817B.5020908@ericsson.com> <5904C914-A2C4-4DAF-B4A5-67C5F6804481@gmail.com> Message-ID: <95be1d3b0701090408x7ecc7c33qa26d070bf9fd3f8d@mail.gmail.com> You could wrap the mnesia:create_shared_table() call inside a macro and use it from an inlined function. /Vlad On 1/9/07, Joel Reymont wrote: > I thought of that but there's record_info which is compile-time. > > On Jan 9, 2007, at 11:50 AM, Mats Cronqvist wrote: > > > Joel Reymont wrote: > >> Any workarounds apart from passing the error variable as a macro > >> argument? > > > > turn make_shared_table/3 into a function? > > > > mats > > -- > http://wagerlabs.com/ > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From richardc@REDACTED Tue Jan 9 13:11:26 2007 From: richardc@REDACTED (Richard Carlsson) Date: Tue, 09 Jan 2007 13:11:26 +0100 Subject: [erlang-questions] Generating a variable in a macro In-Reply-To: <791EBDF7-E650-4242-9EFD-2E8B4A177999@gmail.com> References: <791EBDF7-E650-4242-9EFD-2E8B4A177999@gmail.com> Message-ID: <45A3866E.1000605@it.uu.se> Joel Reymont wrote: > Is there a way to "auto-generate" a variable in a macro ala (gensym) > in Lisp? > [...] > Unless I pass Any1, Any2, etc. into the macro, erl will complain that > the use of Any is unsafe. Any workarounds apart from passing the > error variable as a macro argument? The standard trick is to wrap the macro body in a fun-application, i.e.: ((fun () -> ...body... end)()) this keeps new variables in the body from being exported into the surrounding environment. To avoid collisions between local variables and existing variables in the environment, it is a good idea to prefix all local variables with e.g., "__" or similar, as in: -define(foo(Table, Nodes), ((fun () -> case mnesia:create_table(Table,[...]) of {atomic, ok} -> ok; __Any -> error_logger:error_report(...) end end)())). This is relatively foolproof, but note that the macros don't nest. /Richard From joelr1@REDACTED Tue Jan 9 13:14:21 2007 From: joelr1@REDACTED (Joel Reymont) Date: Tue, 9 Jan 2007 12:14:21 +0000 Subject: [erlang-questions] Generating a variable in a macro In-Reply-To: <95be1d3b0701090408x7ecc7c33qa26d070bf9fd3f8d@mail.gmail.com> References: <791EBDF7-E650-4242-9EFD-2E8B4A177999@gmail.com> <45A3817B.5020908@ericsson.com> <5904C914-A2C4-4DAF-B4A5-67C5F6804481@gmail.com> <95be1d3b0701090408x7ecc7c33qa26d070bf9fd3f8d@mail.gmail.com> Message-ID: <634623A9-5270-44E3-9F57-8F642D6FF627@gmail.com> I must be dumb today. How do I do this? On Jan 9, 2007, at 12:08 PM, Vlad Dumitrescu wrote: > You could wrap the mnesia:create_shared_table() call inside a macro > and use it from an inlined function. > -- http://wagerlabs.com/ From sean.hinde@REDACTED Tue Jan 9 13:24:20 2007 From: sean.hinde@REDACTED (Sean Hinde) Date: Tue, 9 Jan 2007 12:24:20 +0000 Subject: [erlang-questions] Accessing default values of a record Message-ID: Hi, I'm looking (staring actually!) at a generic function for doing mnesia table transformations (e.g. at startup after a code upgrade). It is easy enough to programmatically work out the difference between new and old record fields by comparing the existing mnesia:table_info (Tab, attributes) with the record_info in the new code. But there seems to be no obvious way to access default values in the new record definition. This would be useful to give new fields in the transformed tables nice default values. One way to achieve this would be to provide a mechanism akin to record_info, but which constructs a default record from its name e.g. -record(test, {key, val, new_val = []}). mk_rec(Rec_name) -> record_info(default, Rec_name). 1> test:mk_rec(test). {test, undefined, undefined, []} Seem like a useful idea? Sean From ulf@REDACTED Tue Jan 9 13:30:24 2007 From: ulf@REDACTED (Ulf Wiger) Date: Tue, 09 Jan 2007 13:30:24 +0100 Subject: [erlang-questions] Generating a variable in a macro In-Reply-To: <5904C914-A2C4-4DAF-B4A5-67C5F6804481@gmail.com> References: <791EBDF7-E650-4242-9EFD-2E8B4A177999@gmail.com> <45A3817B.5020908@ericsson.com> <5904C914-A2C4-4DAF-B4A5-67C5F6804481@gmail.com> Message-ID: Den 2007-01-09 12:56:15 skrev Joel Reymont : > I thought of that but there's record_info which is compile-time. I made a small parse transform that allows you to easily work around this problem: http://forum.trapexit.org/viewtopic.php?t=6385&sid=697cc32b3303ea35a8396c19cbb50438 Adding the two lines: -compile({parse_transform, exprecs}). -export_records([r1,r2]). %insert your own record names You get exported functions for creating, modifying and inspecting the given records. BR, Ulf W > > On Jan 9, 2007, at 11:50 AM, Mats Cronqvist wrote: > >> Joel Reymont wrote: >>> Any workarounds apart from passing the error variable as a macro >>> argument? >> >> turn make_shared_table/3 into a function? >> >> mats > > -- > http://wagerlabs.com/ > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- Ulf Wiger From vladdu55@REDACTED Tue Jan 9 13:36:50 2007 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Tue, 9 Jan 2007 13:36:50 +0100 Subject: [erlang-questions] Accessing default values of a record In-Reply-To: References: Message-ID: <95be1d3b0701090436h14a4a29ai443ed8ba7c2ecd9b@mail.gmail.com> Hi, On 1/9/07, Sean Hinde wrote: > But there seems to be no obvious way to access default values in the > new record definition. This would be useful to give new fields in the > transformed tables nice default values. > > One way to achieve this would be to provide a mechanism akin to > record_info, but which constructs a default record from its name e.g. In jungerl/lib/msc/rec_info.erl you can see how to transform a record into a {key, value} list. By calling rec_info:to_list(#your_record(), you will get the default values of the fields. Hope this helps. regards, Vlad From sean.hinde@REDACTED Tue Jan 9 13:50:41 2007 From: sean.hinde@REDACTED (Sean Hinde) Date: Tue, 9 Jan 2007 12:50:41 +0000 Subject: [erlang-questions] Accessing default values of a record In-Reply-To: <95be1d3b0701090436h14a4a29ai443ed8ba7c2ecd9b@mail.gmail.com> References: <95be1d3b0701090436h14a4a29ai443ed8ba7c2ecd9b@mail.gmail.com> Message-ID: <62EFE0A6-0A02-4ED8-A3DB-E20156880D05@gmail.com> On 9 Jan 2007, at 12:36, Vlad Dumitrescu wrote: > Hi, > > On 1/9/07, Sean Hinde wrote: >> But there seems to be no obvious way to access default values in the >> new record definition. This would be useful to give new fields in the >> transformed tables nice default values. >> >> One way to achieve this would be to provide a mechanism akin to >> record_info, but which constructs a default record from its name e.g. > > In jungerl/lib/msc/rec_info.erl you can see how to transform a record > into a {key, value} list. By calling rec_info:to_list(#your_record(), > you will get the default values of the fields. Actually not. The point is that I need the record name to be a variable. I want to iterate through a list of record names and create a default record for each one. Sean From gunilla@REDACTED Tue Jan 9 14:00:26 2007 From: gunilla@REDACTED (Gunilla Arendt) Date: Tue, 09 Jan 2007 14:00:26 +0100 Subject: [erlang-questions] Help with 'make' module and the shell (devel loop issue) In-Reply-To: <20061229171250.GB1262@samizdatdigital.com> References: <20061229031332.GA1262@samizdatdigital.com> <95be1d3b0612282315r28e01f15nae043944ab1fcc26@mail.gmail.com> <20061229171250.GB1262@samizdatdigital.com> Message-ID: <45A391EA.9070500@erix.ericsson.se> Jonathan Gold wrote: > Thanks for the suggestion. I had 'load' in Emakefile, but as you > pointed out, it may not (and indeed didn't work). Invoking it from the > shell as you have below seems to work. The entries in Emakefile can be on the format {Module, Options} where Options is a list of _compiler_ options. 'load' is not a compiler option and is silently ignored. (Try calling compile:file(, [load]) for example). However, 'load' is a _make_ option. That is, calling make:all([load]) will compile modules according to the Emakefile as well as load them. Regards, Gunilla, Erlang/OTP team From mats.cronqvist@REDACTED Tue Jan 9 13:14:00 2007 From: mats.cronqvist@REDACTED (Mats Cronqvist) Date: Tue, 09 Jan 2007 13:14:00 +0100 Subject: [erlang-questions] lists:reverse/1 as a built-in function In-Reply-To: <45A25F91.2010502@it.uu.se> References: <45A25F91.2010502@it.uu.se> Message-ID: <45A38708.9010906@ericsson.com> Richard Carlsson wrote: > I'm pretty sure that [non-backwards-compatible changes] are > not seen as much of a problem (compared to the advantages of getting an > improved language) by individual users and hobby programmers, but those > professionals out there who are maintaining large systems might have > completely different opinions about it, and I'd really like to hear > what they have to say. Any takers? for us (the AXD, an ericsson product with +1MLOC erlang) just recompiling the entire system is a pretty big deal. handling changes that requires editing of our source code is of course even worse. OTOH, it's not in our best interest for the language to stagnate, or to squander OTP resources on demanding support for every mis-feature/bug ever introduced. as i see it, the solution is not in avoiding obsoletion, but in having a (shudder) process for it. a brief sentence in the release notes is not enough. perhaps something like this; institution of Erlang Workgroup for Obsoletion Control (EWOC), consisting of paying customers, OTP people and independent eminent computer scientists (i.e. richard carlsson :>). feature X is proposed to EWOC for obsoletion. following an (archived) discussion in EWOC, feature X is decided be obsoleted in release R. in release R-1 you get; a discussion about X in the release notes. a description about how to remove X and replace it with spiffy new feature Y. if possible, a tool/script/emacs macro to automatically replace X with Y. a compiler warning. a compiler flag to abort if X is found. in release R you get; a compiler that aborts if X is found. a compiler flag to allow X. EWOC would consider things like; how will removal of X affect performance? how hard would it be to SAFELY remove/replace usage of X? how strong is the case for replacing X? given something like this, i think the paying users could accept almost anything. mats p.s. most of this is probably already used in, say, python. it was also discussed at the 2006 user conference. p.p.s. my choice for first obsoletion; the parts of the pre-processor that's incompatible with epp_dodger. the permissiveness of the pre-processor is a show stopper for erl_syntax based refactoring tools. From mats.cronqvist@REDACTED Tue Jan 9 16:07:43 2007 From: mats.cronqvist@REDACTED (Mats Cronqvist) Date: Tue, 09 Jan 2007 16:07:43 +0100 Subject: [erlang-questions] Generating a variable in a macro In-Reply-To: References: <791EBDF7-E650-4242-9EFD-2E8B4A177999@gmail.com> <45A3817B.5020908@ericsson.com> <5904C914-A2C4-4DAF-B4A5-67C5F6804481@gmail.com> Message-ID: <45A3AFBF.10806@ericsson.com> Ulf Wiger wrote: > You get exported functions for creating, > modifying and inspecting the given records. why the record_info functions are not laid out in the beam files (like the module_info functions) is a mystery to me. surely that would be The Right Thing (tm). From thomasl_erlang@REDACTED Tue Jan 9 16:21:29 2007 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Tue, 9 Jan 2007 07:21:29 -0800 (PST) Subject: [erlang-questions] lists:reverse/1 as a built-in function In-Reply-To: <45A25F91.2010502@it.uu.se> Message-ID: <864204.54214.qm@web38812.mail.mud.yahoo.com> --- Richard Carlsson wrote: > Once upon a time, for some random reason, the > unfortunate choice was > made to let the auto-imported functions take > priority over any locally > defined function of the same name. /.../ Arguably (indeed, reasonably), behaving this way is a big honking bug, because it contradicts ordinary scoping and makes the language (or OTP:s implementation of it) behave peculiarly in various ways. There is no good reason to keep it around for anyone except for hypothetical projects that now may rely on this bug. And even they might be happier to get rid of it. It's not hard. (For guards, the compiler would still have to resolve all calls into the appropriate guard function calls, i.e., erlang:*. But guards are basically outside the normal hierarchy since you can't define new guard operations or new guard scopes.) If backwards (bugwards...) compatibility is desired, that could instead be provided with a compiler switch (--auto-imports-override-locals or whatever). Less broken misfeatures have been removed this way before, so I don't see why this one has to be kept around. Best, Thomas __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From thomasl_erlang@REDACTED Tue Jan 9 16:50:00 2007 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Tue, 9 Jan 2007 07:50:00 -0800 (PST) Subject: [erlang-questions] Generating a variable in a macro In-Reply-To: <45A3AFBF.10806@ericsson.com> Message-ID: <20070109155000.97516.qmail@web38805.mail.mud.yahoo.com> --- Mats Cronqvist wrote: > why the record_info functions are not laid out in > the beam files (like the > module_info functions) is a mystery to me. surely > that would be The Right Thing > (tm). Well, that might give users the idea that records are more than syntactic sugar for tuples. But they're not. Best, Thomas (who thinks they _should_ be) __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From mats.cronqvist@REDACTED Tue Jan 9 17:32:13 2007 From: mats.cronqvist@REDACTED (Mats Cronqvist) Date: Tue, 09 Jan 2007 17:32:13 +0100 Subject: [erlang-questions] Generating a variable in a macro In-Reply-To: <20070109155000.97516.qmail@web38805.mail.mud.yahoo.com> References: <20070109155000.97516.qmail@web38805.mail.mud.yahoo.com> Message-ID: <45A3C38D.4080206@ericsson.com> Thomas Lindgren wrote: > --- Mats Cronqvist > wrote: >> why the record_info functions are not laid out in >> the beam files (like the >> module_info functions) is a mystery to me. surely >> that would be The Right Thing >> (tm). > > Well, that might give users the idea that records are > more than syntactic sugar for tuples. But they're not. that sounds pretty weak... mats From lenartlad@REDACTED Tue Jan 9 17:40:40 2007 From: lenartlad@REDACTED (Ladislav Lenart) Date: Tue, 09 Jan 2007 17:40:40 +0100 Subject: [erlang-questions] Generating a variable in a macro In-Reply-To: <20070109155000.97516.qmail@web38805.mail.mud.yahoo.com> References: <20070109155000.97516.qmail@web38805.mail.mud.yahoo.com> Message-ID: <45A3C588.4040905@volny.cz> Thomas Lindgren wrote: > --- Mats Cronqvist > wrote: >> why the record_info functions are not laid out in >> the beam files (like the >> module_info functions) is a mystery to me. surely >> that would be The Right Thing >> (tm). > > Well, that might give users the idea that records are > more than syntactic sugar for tuples. But they're not. But they should do their best to pretend the opposite. Otherwise the programmer has to mess with their internals until one day he realizes that a life might be a little easier without them... :-) Just take a look at today's discussion threads: * Generating a variable in a macro - the core of the problem is that record_info is not a normal function. * Accessing default values of a record - not having this functionality can introduce code duplication. Ladislav Lenart From sean.hinde@REDACTED Tue Jan 9 17:54:43 2007 From: sean.hinde@REDACTED (Sean Hinde) Date: Tue, 9 Jan 2007 16:54:43 +0000 Subject: [erlang-questions] Generating a variable in a macro In-Reply-To: <45A3C588.4040905@volny.cz> References: <20070109155000.97516.qmail@web38805.mail.mud.yahoo.com> <45A3C588.4040905@volny.cz> Message-ID: <0502DB76-C651-4B86-9CCA-19FA0760C8C8@gmail.com> On 9 Jan 2007, at 16:40, Ladislav Lenart wrote: > Just take a look at today's discussion threads: > * Generating a variable in a macro - the core of the > problem is that record_info is not a normal function. > * Accessing default values of a record - not having > this functionality can introduce code duplication. And potentially quite a lot of code duplication. In a system with hundreds of mnesia tables it means that all those hundreds of table record definition must be backed up by a function that provides the same information but accessible at runtime just in case some table should be upgraded. Likelihood of everything always being correct? Close to zero :-( Sean From mats.cronqvist@REDACTED Tue Jan 9 16:03:58 2007 From: mats.cronqvist@REDACTED (Mats Cronqvist) Date: Tue, 09 Jan 2007 16:03:58 +0100 Subject: [erlang-questions] Generating a variable in a macro In-Reply-To: <5904C914-A2C4-4DAF-B4A5-67C5F6804481@gmail.com> References: <791EBDF7-E650-4242-9EFD-2E8B4A177999@gmail.com> <45A3817B.5020908@ericsson.com> <5904C914-A2C4-4DAF-B4A5-67C5F6804481@gmail.com> Message-ID: <45A3AEDE.3000004@ericsson.com> Joel Reymont wrote: > I thought of that but there's record_info which is compile-time. > > On Jan 9, 2007, at 11:50 AM, Mats Cronqvist wrote: > >> Joel Reymont wrote: >>> Any workarounds apart from passing the error variable as a macro >>> argument? >> >> turn make_shared_table/3 into a function? >> i thought i was missing something... how about this; -define(ri(Rec),{Rec,record_info(fields,Rec)}). used like this; make_shared_table(?ri(counter)). e.g. -record(counter,{joel,rules}). -define(ri(Rec),{Rec,record_info(fields,Rec)}). x()-> (?ri(counter)). calling x/0 will return {counter,[joel,rules]} mats From lenartlad@REDACTED Tue Jan 9 18:58:00 2007 From: lenartlad@REDACTED (Ladislav Lenart) Date: Tue, 09 Jan 2007 18:58:00 +0100 Subject: [erlang-questions] Edoc question - documenting multiple throws Message-ID: <45A3D7A8.6060001@volny.cz> Hello, How can I document a function that can throw multiple exceptions using edoc? I tried %% @doc Bla. %% @throws ex1 %% @throws ex2 and %% @doc Bla. %% @throws ex1, ex2 but none of them works. The edoc documentation states the following: -------------------------------- @throws Specifies which types of terms may be thrown by the function, if its execution terminates abruptly due to a call to erlang:throw(Term). The content is a type expression (see Type specifications), and can be a union type. -------------------------------- Union type, according to Type specifiactions, seems to support "," as a valid separator... Thanks, Ladislav Lenart From thomasl_erlang@REDACTED Tue Jan 9 19:07:42 2007 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Tue, 9 Jan 2007 10:07:42 -0800 (PST) Subject: [erlang-questions] Generating a variable in a macro In-Reply-To: <45A3C38D.4080206@ericsson.com> Message-ID: <365643.97534.qm@web38810.mail.mud.yahoo.com> --- Mats Cronqvist wrote: > Thomas Lindgren wrote: > > --- Mats Cronqvist > > wrote: > >> why the record_info functions are not laid out > in > >> the beam files (like the > >> module_info functions) is a mystery to me. surely > >> that would be The Right Thing > >> (tm). > > > > Well, that might give users the idea that records > are > > more than syntactic sugar for tuples. But they're > not. > > that sounds pretty weak... "Records" as used today are declared in include files which then are textually inserted into one or many modules. A record declaration does thus not in general have a unique point of definition. A single record name #r can also be declared differently in different modules. There is finally no general way to know that the tuple {r, foo, 4711} should use the record_info definition in mod1 or the one in mod2. Or neither. Just see the record notation as macros. (Which is, after all, what it is.) Best, Thomas __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From james.hague@REDACTED Tue Jan 9 19:08:48 2007 From: james.hague@REDACTED (James Hague) Date: Tue, 9 Jan 2007 12:08:48 -0600 Subject: [erlang-questions] lists:reverse/1 as a built-in function In-Reply-To: <45A25F91.2010502@it.uu.se> References: <45A25F91.2010502@it.uu.se> Message-ID: On 1/8/07, Richard Carlsson wrote: > > The set of auto-imported functions ("built-in" is a much wider concept) > is not possible to extend without breaking backwards compatibility. Thanks for the reply, Richard. It occasionally bothers me that relative oddies like term_to_binary are auto-imported, but reverse isn't. But in any case this has clearly started up some interesting discussion! James From richardc@REDACTED Tue Jan 9 19:43:55 2007 From: richardc@REDACTED (Richard Carlsson) Date: Tue, 09 Jan 2007 19:43:55 +0100 Subject: [erlang-questions] Edoc question - documenting multiple throws In-Reply-To: <45A3D7A8.6060001@volny.cz> References: <45A3D7A8.6060001@volny.cz> Message-ID: <45A3E26B.6030804@it.uu.se> Ladislav Lenart wrote: > How can I document a function that can throw multiple exceptions using edoc? > I tried > %% @doc Bla. > %% @throws ex1 > %% @throws ex2 > and > %% @doc Bla. > %% @throws ex1, ex2 > but none of them works. You should use "|" or "+" as union separator. > Union type, according to Type specifiactions, seems to support "," as a valid > separator... Nope. /Richard From lcoquelle@REDACTED Wed Jan 10 06:04:33 2007 From: lcoquelle@REDACTED (Ludovic Coquelle) Date: Wed, 10 Jan 2007 13:04:33 +0800 Subject: [erlang-questions] String encoding and character set Message-ID: Hi, Looking for a solution to deals with string encoding (and convertion) in Erlang, I found an 'iconv' driver in Jungerl. But it has no documentation at all (ok, it should be fairly simple) and no activity status. Futhermore, do you guys think it is a good way to do encoding convertion in Erlang? Any other suggestion? (I'm a bit tired to always get the same comment about Erlang: there is no good string library ... and it's a show stop to Erlang adoption by certain project and mine particularly) -------------- next part -------------- An HTML attachment was scrubbed... URL: From dmitriid@REDACTED Wed Jan 10 08:36:09 2007 From: dmitriid@REDACTED (Dmitrii 'Mamut' Dimandt) Date: Wed, 10 Jan 2007 09:36:09 +0200 Subject: [erlang-questions] String encoding and character set In-Reply-To: References: Message-ID: <45A49769.4070908@gmail.com> I've long wondered if a driver for IBM's ICU could be written for Erlang. But that means actually sitting down and writing it :) And I personally can't do that :( Ludovic Coquelle wrote: > Hi, > Looking for a solution to deals with string encoding (and convertion) > in Erlang, I found an 'iconv' driver in Jungerl. > But it has no documentation at all (ok, it should be fairly simple) > and no activity status. > > Futhermore, do you guys think it is a good way to do encoding > convertion in Erlang? > Any other suggestion? > > (I'm a bit tired to always get the same comment about Erlang: there is > no good string library ... and it's a show stop to Erlang adoption by > certain project and mine particularly) > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mats.cronqvist@REDACTED Wed Jan 10 09:45:02 2007 From: mats.cronqvist@REDACTED (Mats Cronqvist) Date: Wed, 10 Jan 2007 09:45:02 +0100 Subject: [erlang-questions] Generating a variable in a macro In-Reply-To: <365643.97534.qm@web38810.mail.mud.yahoo.com> References: <365643.97534.qm@web38810.mail.mud.yahoo.com> Message-ID: <45A4A78E.70405@ericsson.com> Thomas Lindgren wrote: > --- Mats Cronqvist > wrote: > >> Thomas Lindgren wrote: >>> --- Mats Cronqvist >>> wrote: >>>> why the record_info functions are not laid out >> in >>>> the beam files (like the >>>> module_info functions) is a mystery to me. surely >>>> that would be The Right Thing >>>> (tm). >>> Well, that might give users the idea that records >> are >>> more than syntactic sugar for tuples. But they're >> not. >> >> that sounds pretty weak... > > "Records" as used today are declared in include files > which then are textually inserted into one or many > modules. A record declaration does thus not in general > have a unique point of definition. A single record > name #r can also be declared differently in different > modules. There is finally no general way to know that > the tuple {r, foo, 4711} should use the record_info > definition in mod1 or the one in mod2. Or neither. this is actually exactly why i originally proposed exporting a record_info/2 function from every module; so that i could write a tool to check that all my modules actually DO use the same definition of all records. i think we can all agree that records suck (as does all macros). but i think a record_info function would make them suck slightly less. mats From tobbe@REDACTED Wed Jan 10 10:21:37 2007 From: tobbe@REDACTED (Torbjorn Tornkvist) Date: Wed, 10 Jan 2007 10:21:37 +0100 Subject: [erlang-questions] String encoding and character set In-Reply-To: References: Message-ID: Ludovic Coquelle wrote: > Hi, > Looking for a solution to deals with string encoding (and convertion) in > Erlang, I found an 'iconv' driver in Jungerl. > But it has no documentation at all (ok, it should be fairly simple) and > no activity status. Well, it is very easy to use: iconv:start() - to start the server/driver then in your code: ... %% Convert from ASCII to UCS2 {ok, Cd} = iconv:open(?CSET_UCS2, ?CSET_ASCII), {ok, Uname} = iconv:conv(Cd, Aname), iconv:close(Cd), ... Regarding activity: it is 'finished' :-) and in active use > > Futhermore, do you guys think it is a good way to do encoding convertion > in Erlang? Why not, the iconv driver is (for example) used in existing products to encode UCS2 names from Win-servers to whatever the user is using in his browser. This is done on-the-fly, in both directions. You can also see example on its use in the esmb code in Jungerl. > Any other suggestion? > > (I'm a bit tired to always get the same comment about Erlang: there is > no good string library ... and it's a show stop to Erlang adoption by > certain project and mine particularly) So what, exactly, is missing (apart from a proper string data type...) ? Cheers, Tobbe From lcoquelle@REDACTED Wed Jan 10 11:28:47 2007 From: lcoquelle@REDACTED (Ludovic Coquelle) Date: Wed, 10 Jan 2007 18:28:47 +0800 Subject: [erlang-questions] String encoding and character set In-Reply-To: References: Message-ID: On 1/10/07, Torbjorn Tornkvist wrote: > > Ludovic Coquelle wrote: > > I found an 'iconv' driver in Jungerl. > > But it has no documentation at all (ok, it should be fairly simple) and > > no activity status. > > Well, it is very easy to use: Indeed, really easy! Thank you for the detailed answer. Anyway to "guess" the encoding of an input string? > (I'm a bit tired to always get the same comment about Erlang: there is > > no good string library ... and it's a show stop to Erlang adoption by > > certain project and mine particularly) > > So what, exactly, is missing (apart from a proper string data type...) ? Perhaps I was not clear... I don't think Erlang "miss" something about string manipulation (only this encoding that you just solve) but that's maybe because I come with some Prolog experience. Anyway I just don't understand the real advantage of a string data type (for me it only means that performance could be better), so I don't understand why people complain so much about that. Any previous discussion pointer about string data type? -------------- next part -------------- An HTML attachment was scrubbed... URL: From dinesh.titanz@REDACTED Wed Jan 10 12:36:48 2007 From: dinesh.titanz@REDACTED (dinesh sundar) Date: Wed, 10 Jan 2007 17:06:48 +0530 Subject: [erlang-questions] problem while sending and receiving messages while threading otp modules with udp connection.. Message-ID: <77e5015c0701100336i3a3b01ffqd3300baec471b188@mail.gmail.com> Hi All I have a *supervisor*, a *genserver* which receives messages through udp and a *gen fsm* module which sends the messages using the same socket. The application *runs fine* when i start it the supervisor *without using threads*..ie it is able to receive and send messages.. But when i run the supervisor using threads i am unable to receive and send message through gen server and gen fsm module respectively.. Is that when i spawn *otp* modules i must pass a reference to all the otp modules or there is something i am missing.. For Eg.. Application runs fine when i start things as ordinary: ie supervisor:start("","",""). But when i start it using thread I am unable to run the application For eg: *spawn(supervisor,start,["",""]).* But some times i am able to send but unable to receive the messages using udp connection.But I am passing the socket reference to all the modules(genserver and gen fsm). Is there any other thing that should be done.. Thanks in advance Regards A.K -------------- next part -------------- An HTML attachment was scrubbed... URL: From bengt.kleberg@REDACTED Wed Jan 10 13:13:21 2007 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Wed, 10 Jan 2007 13:13:21 +0100 Subject: [erlang-questions] problem while sending and receiving messages while threading otp modules with udp connection.. In-Reply-To: <77e5015c0701100336i3a3b01ffqd3300baec471b188@mail.gmail.com> References: <77e5015c0701100336i3a3b01ffqd3300baec471b188@mail.gmail.com> Message-ID: <45A4D861.4060207@ericsson.com> On 2007-01-10 12:36, dinesh sundar wrote: > Hi All > > > I have a *supervisor*, a *genserver* which receives > messages through udp and a *gen fsm* module which sends the messages > using the same socket. > The application *runs fine* when i start it the supervisor *without > using threads*..ie it is able to receive and send messages.. first i would like to mention that most people use the word ''threads'' to mean execution contexts that share memory. erlang processes do not share memory, so they are processes. > But when i run the supervisor using threads i am unable to receive and > send message through gen server and gen fsm module respectively.. if you could scale down this supervisor to as few lines as possible (that still fail) and then post it, that would make it easier to help. from your description i can only think of asking if you have taken into account the documentation for gen_udp that says: ''open(Port) -> {ok, Socket} | {error, Reason} ...deleted Associates a UDP port number (Port) with the calling process.'' ie, it is only the process that calls open/1 that will get the messages. bengt -- EPO guidelines 1978: "If the contribution to the known art resides solely in a computer program then the subject matter is not patentable in whatever manner it may be presented in the claims." From mikpe@REDACTED Wed Jan 10 17:04:19 2007 From: mikpe@REDACTED (Mikael Pettersson) Date: Wed, 10 Jan 2007 17:04:19 +0100 Subject: [erlang-questions] opensuse 10.2 erlang build error In-Reply-To: <45A24306.6070603@itcnetworks.ro> References: <45A24306.6070603@itcnetworks.ro> Message-ID: <17829.3715.45753.28384@alkaid.it.uu.se> Lucian PARVU writes: > Hi All, > > In case you have this issue, you can use this fix: > > [ISSUE] > Erlan otp_src_11B-2 Build Error on OpenSuse 10.2: > > .... /i686-pc-linux-gnu/opt/hybrid/hipe_x86_signal.o: In function > `my_sigaction': > /otp_src_R11B-2/erts/emulator/hipe/hipe_x86_signal.c:220: undefined > reference to `INIT' ... > [CAUSE] > OpenSuse 10.2 uses glibc version 2.5 > > [FIX] > You need to modify otp_src_R11B-2/erts/emulator/hipe/hipe_x86_signal.c > line 37 to: > #if __GLIBC__ == 2 && (__GLIBC_MINOR__ == 3 || __GLIBC_MINOR__ == 4 || > __GLIBC_MINOR__ == 5) You didn't post a proper `patch' file. I've checked in the following fix, which will be included in the next R11B release. It's been tested on FC6/x86_64 with glibc-2.5. /Mikael --- otp-0109/erts/emulator/hipe/hipe_x86_signal.c.~1~ 2006-08-25 12:03:01.000000000 +0200 +++ otp-0109/erts/emulator/hipe/hipe_x86_signal.c 2007-01-10 13:01:03.000000000 +0100 @@ -34,7 +34,7 @@ #endif #include "hipe_signal.h" -#if __GLIBC__ == 2 && (__GLIBC_MINOR__ == 3 || __GLIBC_MINOR__ == 4) +#if __GLIBC__ == 2 && (__GLIBC_MINOR__ >= 3 && __GLIBC_MINOR__ <= 5) /* See comment below for glibc 2.2. */ #ifndef __USE_GNU #define __USE_GNU /* to un-hide RTLD_NEXT */ From mike@REDACTED Wed Jan 10 18:02:49 2007 From: mike@REDACTED (Michael C Williams) Date: Wed, 10 Jan 2007 18:02:49 +0100 (MET) Subject: [erlang-questions] lists:reverse/1 as a built-in function In-Reply-To: <864204.54214.qm@web38812.mail.mud.yahoo.com> Message-ID: --- Richard Carlsson wrote: > Once upon a time, for some random reason, the > unfortunate choice was > made to let the auto-imported functions take > priority over any locally > defined function of the same name. /.../ I think I was I who introduced this behaviour in an early version of the JAM Erlang VM. We were experimenting with built in functions and wanted to be able to override incorrectly implemented built in functions without recompiling / building a new VN. At that time, we were using SUN workstations based on 68030 processors and recompiling and linking took a looooong time. /m From thomasl_erlang@REDACTED Wed Jan 10 18:24:34 2007 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Wed, 10 Jan 2007 09:24:34 -0800 (PST) Subject: [erlang-questions] Generating a variable in a macro In-Reply-To: <45A4A78E.70405@ericsson.com> Message-ID: <20070110172434.27357.qmail@web38806.mail.mud.yahoo.com> --- Mats Cronqvist wrote: > this is actually exactly why i originally > proposed exporting a record_info/2 > function from every module; so that i could write a > tool to check that all my > modules actually DO use the same definition of all > records. In many cases, it is likely the answer will be negative. The record name #state is pretty popular, for instance ... Anyway, I'd recommend the short term solution of browbeating the Dialyzer people into checking how and where record names are used. Or even checking where all the regular macros are used -- having different definitions of interesting ?constants is no good either. In fact, maybe this checking can be done simply by messing around with the preprocessor a bit. Knowing which files get included where should be a good start, for instance. > i think we can all agree that records suck (as > does all macros). /.../ (Lisp macros don't suck! :-) Best, Thomas ____________________________________________________________________________________ Cheap talk? Check out Yahoo! Messenger's low PC-to-Phone call rates. http://voice.yahoo.com From lucian@REDACTED Wed Jan 10 18:27:50 2007 From: lucian@REDACTED (Lucian Parvu) Date: Wed, 10 Jan 2007 19:27:50 +0200 Subject: [erlang-questions] opensuse 10.2 erlang build error In-Reply-To: <17829.3715.45753.28384@alkaid.it.uu.se> Message-ID: <20070110172750.C052486A531@mail.itcnetworks> This is the first time I post on erlang mailing list. I'll take care next time to follow the proper patch procedures. Thanks, Lucian -----Original Message----- From: Mikael Pettersson [mailto:mikpe@REDACTED] Sent: Wednesday, January 10, 2007 6:04 PM To: Lucian PARVU Cc: Erlang-Questions (E-mail) Subject: Re: [erlang-questions] opensuse 10.2 erlang build error Lucian PARVU writes: > Hi All, > > In case you have this issue, you can use this fix: > > [ISSUE] > Erlan otp_src_11B-2 Build Error on OpenSuse 10.2: > > .... /i686-pc-linux-gnu/opt/hybrid/hipe_x86_signal.o: In function > `my_sigaction': > /otp_src_R11B-2/erts/emulator/hipe/hipe_x86_signal.c:220: undefined > reference to `INIT' ... > [CAUSE] > OpenSuse 10.2 uses glibc version 2.5 > > [FIX] > You need to modify otp_src_R11B-2/erts/emulator/hipe/hipe_x86_signal.c > line 37 to: > #if __GLIBC__ == 2 && (__GLIBC_MINOR__ == 3 || __GLIBC_MINOR__ == 4 || > __GLIBC_MINOR__ == 5) You didn't post a proper `patch' file. I've checked in the following fix, which will be included in the next R11B release. It's been tested on FC6/x86_64 with glibc-2.5. /Mikael --- otp-0109/erts/emulator/hipe/hipe_x86_signal.c.~1~ 2006-08-25 12:03:01.000000000 +0200 +++ otp-0109/erts/emulator/hipe/hipe_x86_signal.c 2007-01-10 13:01:03.000000000 +0100 @@ -34,7 +34,7 @@ #endif #include "hipe_signal.h" -#if __GLIBC__ == 2 && (__GLIBC_MINOR__ == 3 || __GLIBC_MINOR__ == 4) +#if __GLIBC__ == 2 && (__GLIBC_MINOR__ >= 3 && __GLIBC_MINOR__ <= 5) /* See comment below for glibc 2.2. */ #ifndef __USE_GNU #define __USE_GNU /* to un-hide RTLD_NEXT */ !DSPAM:19,45a5112c170564799618498! From mats.cronqvist@REDACTED Wed Jan 10 18:37:56 2007 From: mats.cronqvist@REDACTED (Mats Cronqvist) Date: Wed, 10 Jan 2007 18:37:56 +0100 Subject: [erlang-questions] Generating a variable in a macro In-Reply-To: <20070110172434.27357.qmail@web38806.mail.mud.yahoo.com> References: <20070110172434.27357.qmail@web38806.mail.mud.yahoo.com> Message-ID: <45A52474.30703@ericsson.com> Thomas Lindgren wrote: > --- Mats Cronqvist > wrote: >> i think we can all agree that records suck (as >> does all macros). /.../ > > (Lisp macros don't suck! :-) fine, i should have qualified that; C-style macros suck. AFAIK, Lisp macros are more similar to Erlang parse transforms. mats From mj@REDACTED Wed Jan 10 20:12:53 2007 From: mj@REDACTED (Mikkel Jensen) Date: Wed, 10 Jan 2007 20:12:53 +0100 Subject: [erlang-questions] Xmerl full format export Message-ID: Hi there, I'm having some difficulty exporting a full format XML structure using xmerl:export/2. ... XmlSimple = {text, ["Hello World!"]}, xmerl:export_simple([XmlSimple], xmerl_xml), % Works OK XmlFull = xmerl_scan:string("Hello World!"), xmerl:export([XmlFull], xmerl_xml). % Doesn't work! ... The error is: ** exited: {function_clause,[{xmerl,export_element, [{{xmlElement, text, text, [], {xmlNamespace,[],[]}, [], 1, [], [{xmlText, [{text,1}], 1, [], "Hello World!", text}], [], "C:/Apps/eclipse", undeclared}, []}, [xmerl_xml]]}, {xmerl,export_content,2}, {xmerl,export1,3}, {erl_eval,do_apply,5}, {shell,exprs,6}, {shell,eval_loop,3}]} ** The simple format works fine but that doesn't help since I need to modify existing documents and I can't import to this format... What am I doing wrong? - Mikkel -------------- next part -------------- An HTML attachment was scrubbed... URL: From vladdu55@REDACTED Wed Jan 10 21:05:56 2007 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Wed, 10 Jan 2007 20:05:56 +0000 Subject: [erlang-questions] Xmerl full format export In-Reply-To: References: Message-ID: <95be1d3b0701101205s23da238en9d021ae73ba79d4a@mail.gmail.com> Hi, On 1/10/07, Mikkel Jensen wrote: > XmlFull = xmerl_scan:string("Hello World!"), > xmerl:export([XmlFull], xmerl_xml). % Doesn't work! Try {XmlFull, _} = xmerl_scan:string("Hello World!"), because xmerl_scan:string returns {xml(), rest_of_input} best regards, Vlad From mj@REDACTED Wed Jan 10 21:11:06 2007 From: mj@REDACTED (Mikkel Jensen) Date: Wed, 10 Jan 2007 21:11:06 +0100 Subject: [erlang-questions] Xmerl full format export In-Reply-To: <95be1d3b0701101205s23da238en9d021ae73ba79d4a@mail.gmail.com> References: <95be1d3b0701101205s23da238en9d021ae73ba79d4a@mail.gmail.com> Message-ID: Thanks alot Vlad! I knew I was missing something obvious (doh!) - Mikkel On 1/10/07, Vlad Dumitrescu wrote: > > Hi, > > On 1/10/07, Mikkel Jensen wrote: > > XmlFull = xmerl_scan:string("Hello World!"), > > xmerl:export([XmlFull], xmerl_xml). % Doesn't work! > > Try > > {XmlFull, _} = xmerl_scan:string("Hello World!"), > > because xmerl_scan:string returns {xml(), rest_of_input} > > best regards, > Vlad -------------- next part -------------- An HTML attachment was scrubbed... URL: From fritchie@REDACTED Thu Jan 11 07:36:30 2007 From: fritchie@REDACTED (Scott Lystig Fritchie) Date: Thu, 11 Jan 2007 00:36:30 -0600 Subject: [erlang-questions] Detecting 'inconsistent_database' and other Mnesia events Message-ID: <200701110636.l0B6aUYe024543@snookles.snookles.com> Good evening. As I've been refactoring a Mnesia-based application, it struck me that mnesia:subscribe/1 cannot be called until Mnesia has been started. As a Mnesia event subscriber, if I want extremely *prompt* and *reliable* notification of important events such as the 'inconsistent_database' warning ... hm, it seems I'm stuck with a race condition, possibly missing the event between starting Mnesia and becoming an event subscriber. My solution, before refactoring, was to have my custom error_logger report handler check for "inconsistent_database" in any string that it was about to write to disk. Not very elegant, but effective. After refactoring, my report handler is now in a hunk of code that can/will be shared by many applications, and the code that reacts to the Mnesia error will differ from app to app. So ... are there any easy ways around this problem, something I've missed? -Scott P.S. Hm. Here's the only thing that I can come up with, hitting my brain about 5 seconds before pressing "Send". 1. Add yet another custom report handler, foo, callback for error_logger. 2. In foo.erl, have a callback func that looks something like: handle_event({_T, _GL, SomeWackyTermThing}, State) -> scream_murder_then_halt_abruptly(), {ok, State}; handle_event(_Event, State) -> {ok, State}. ... where SomeWackyTermThing is really whatever report/format/whatever that Mnesia logs when 'inconsistent_database' is detected. 3. Fiddle a lot with creating Mnesia inconsistencies to try to figure out *exactly* what that !@#$! error logger event looks like. From nrai@REDACTED Thu Jan 11 08:30:18 2007 From: nrai@REDACTED (Nitin Rai) Date: Thu, 11 Jan 2007 13:00:18 +0530 Subject: [erlang-questions] how to connect Erlang Nodes over SSH Message-ID: <060d01c73552$5bb75380$2701a8c0@calance.com> Hi I want to communicate between two Erlang nodes running on Linux platforms using the Secure Shell (SSH). At this moment i am able to achieve this for nodes running on normal linux Shells but how to achieve this over SSH. Can you please suggest me a way to connect Erlang Nodes over SSH. Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From bengt.kleberg@REDACTED Thu Jan 11 09:11:13 2007 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Thu, 11 Jan 2007 09:11:13 +0100 Subject: [erlang-questions] how to connect Erlang Nodes over SSH In-Reply-To: <060d01c73552$5bb75380$2701a8c0@calance.com> References: <060d01c73552$5bb75380$2701a8c0@calance.com> Message-ID: <45A5F121.60207@ericsson.com> On 2007-01-11 08:30, Nitin Rai wrote: > Hi > > I want to communicate between two Erlang nodes running on Linux > platforms using the Secure Shell (SSH). At this moment i am able to > achieve this for nodes running on normal linux Shells but how to achieve > this over SSH. Can you please suggest me a way to connect Erlang Nodes > over SSH. is this what you want? (from the erl man page): -rsh Program: Specifies an alternative to rsh for starting a slave node on a remote host. See slave(3). bengt -- EPO guidelines 1978: "If the contribution to the known art resides solely in a computer program then the subject matter is not patentable in whatever manner it may be presented in the claims." From ft@REDACTED Thu Jan 11 15:31:43 2007 From: ft@REDACTED (Fredrik Thulin) Date: Thu, 11 Jan 2007 15:31:43 +0100 Subject: [erlang-questions] kernel-poll problem Message-ID: <45A64A4F.4010107@it.su.se> Hi I have a box where I can't start erl with +K true : $ /pkg/erlang/R11B-2_poll/bin/erl +K true erts_poll_create_pollset(): Failed to create epoll set: enosys (38) Aborted $ This is on Linux 2.6.11 (under Xen), with glibc 2.3.3. Has anyone seen this, or better still, solved this? /Fredrik From serge@REDACTED Thu Jan 11 15:48:13 2007 From: serge@REDACTED (Serge Aleynikov) Date: Thu, 11 Jan 2007 09:48:13 -0500 Subject: [erlang-questions] Detecting 'inconsistent_database' and other Mnesia events In-Reply-To: <200701110636.l0B6aUYe024543@snookles.snookles.com> References: <200701110636.l0B6aUYe024543@snookles.snookles.com> Message-ID: <45A64E2D.9030608@hq.idt.net> In my experience getting "inconsistent_database" event at startup is a rather uncommon event (we've only seen it during testing when one master node was in the middle of a mnesia:wait_for_tables/2 call, while the other master node would get restarted, but even then the call to mnesia:subscribe/1 succeeded prior to doing mnesia:wait_for_tables/2, and the event was handled properly). However I see your point and it doesn't sound like a bad thing to add a startup option in order to avoid that possible race condition. As far as the error_logger approach is concerned, the event term is: {error, GL, {Pid, Format, Args}} where Format = "Mnesia(~p): ** ERROR ** mnesia_event got {inconsistent_database, ~w, ~w}~n", Args = [MnesiaNode,Reason,Node]}} though this is a rather absurd way of detecting the fault. :-( Regards, Serge Scott Lystig Fritchie wrote: > Good evening. As I've been refactoring a Mnesia-based application, it > struck me that mnesia:subscribe/1 cannot be called until Mnesia has > been started. > > As a Mnesia event subscriber, if I want extremely *prompt* and > *reliable* notification of important events such as the > 'inconsistent_database' warning ... hm, it seems I'm stuck with a race > condition, possibly missing the event between starting Mnesia and > becoming an event subscriber. > > My solution, before refactoring, was to have my custom error_logger > report handler check for "inconsistent_database" in any string that it > was about to write to disk. Not very elegant, but effective. > > After refactoring, my report handler is now in a hunk of code that > can/will be shared by many applications, and the code that reacts to > the Mnesia error will differ from app to app. > > So ... are there any easy ways around this problem, something I've > missed? > > -Scott > > P.S. Hm. Here's the only thing that I can come up with, hitting my > brain about 5 seconds before pressing "Send". > > 1. Add yet another custom report handler, foo, callback for > error_logger. > > 2. In foo.erl, have a callback func that looks something like: > > handle_event({_T, _GL, SomeWackyTermThing}, State) -> > scream_murder_then_halt_abruptly(), > {ok, State}; > handle_event(_Event, State) -> > {ok, State}. > > ... where SomeWackyTermThing is really whatever report/format/whatever > that Mnesia logs when 'inconsistent_database' is detected. > > 3. Fiddle a lot with creating Mnesia inconsistencies to try to figure > out *exactly* what that !@#$! error logger event looks like. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From ulf@REDACTED Thu Jan 11 16:05:36 2007 From: ulf@REDACTED (Ulf Wiger) Date: Thu, 11 Jan 2007 16:05:36 +0100 Subject: [erlang-questions] Detecting 'inconsistent_database' and other Mnesia events In-Reply-To: <200701110636.l0B6aUYe024543@snookles.snookles.com> References: <200701110636.l0B6aUYe024543@snookles.snookles.com> Message-ID: Den 2007-01-11 07:36:30 skrev Scott Lystig Fritchie : > Good evening. As I've been refactoring a Mnesia-based application, it > struck me that mnesia:subscribe/1 cannot be called until Mnesia has > been started. > > As a Mnesia event subscriber, if I want extremely *prompt* and > *reliable* notification of important events such as the > 'inconsistent_database' warning ... hm, it seems I'm stuck with a race > condition, possibly missing the event between starting Mnesia and > becoming an event subscriber. We approached it differently. There are other things to worry about besides inconsistencies. Sometimes, the database may not come up at all. A simple example of what can cause this: 1) node A goes down, node B logs this 2) node B crashes and burns, never to recover 3) node A tries to start, finds B missing At this point A concludes that it was not alive when B died, and thus B is likely to have more current data. A then decides to wait for B... In a non-stop system, it is arguably better to restart with the best data available than to sit idly for hours waiting for a repair man to come out and replace a busted disk (or whatever). We chose to run with -kernel dist_auto_connect once and a backdoor ping, in order to preempt the situations that can cause mnesia inconsistencies (and other mayhem). Then we run an application _before_ mnesia which handshakes with its peers on other mnesia nodes, and performs a dependency analysis on the loaders (the info returned from wait_for_tables). If it finds that the loaders are deadlocked, or if nodes are missing (e.g. due to the situation described above) a force_load_tables() will eventually be triggered. The same application also sets mnesia master nodes in order to recover from partitioned network. The problem with this is obviously that it's not universally applicable. What to as a result of loader deadlock or partitioned network is decidedly application-specific. It's possible that a generic decision support framework could be made out of what we've done, but you shouldn't hold your breath waiting for us to do that (you know - if it works, don't touch it, and all that.) Personally, I would like to see an add-on to mnesia offer this type of functionality. Whenever Dan gets loads of free time on his hands perhaps...? BR, Ulf W -- Ulf Wiger From kostis@REDACTED Thu Jan 11 17:53:23 2007 From: kostis@REDACTED (Kostis Sagonas) Date: Thu, 11 Jan 2007 17:53:23 +0100 Subject: [erlang-questions] Latent bugs in Erlang/OTP Message-ID: <45A66B83.5090701@cs.ntua.gr> Partly due to extending Dialyzer and partly wanting to satisfying my scientific curiosity, I've been spending a significant portion of my recent time looking for bugs in Erlang code, mainly in OTP. More importantly, I am trying to get a grasp on the reasons why even the most competent Erlang programmers write code that contains latent bugs. This, in the hope that this knowledge can be fed back into Dialyzer or some other similar tool. Still, the things I've run across so far are interesting -- perhaps even worth of a talk at some forum. Let me share with you one of the latest ones -- discovered by the development version of Dialyzer which, among other things, infers integer ranges. The beginning of lib/orber/src/orber_tb.erl in R11B-2 reads: %%---------------------------------------------------------------------- -module(orber_tb). ... -export([wait_for_tables/1, wait_for_tables/2, is_loaded/0, is_loaded/1, is_running/0, is_running/1, info/2, error/2, unique/1]). %%---------------------------------------------------------------------- Note that two wait_for_tables functions are exported, those with arities 1 and 2. These functions are defined as follows: %%---------------------------------------------------------------------- %% function : wait_for_tables/1 %% Arguments: Tables - list of mnesia tables %% Timeout - integer (no point in allowing infinity) %% Attempts - integer > 0 How many times should we try %% Returns : %% Exception: %% Effect : %%---------------------------------------------------------------------- wait_for_tables(Tables) -> wait_for_tables(Tables, 30000, -1). wait_for_tables(Tables, Timeout) -> wait_for_tables(Tables, Timeout, -1). wait_for_tables(Tables, _Timeout, 0) -> error("Mnesia failed to load the some or all of the following" "tables:~n~p", [Tables]), {error, "The requested Mnesia tables not yet available."}; wait_for_tables(Tables, Timeout, Attempts) -> case mnesia:wait_for_tables(Tables, Timeout) of ok -> ok; {timeout, BadTabList} -> info("Mnesia hasn't loaded the following tables (~p msec):~n~p", [Timeout, BadTabList]), wait_for_tables(BadTabList, Timeout, Attempts-1); {error, Reason} -> error("Mnesia failed to load the some or all of the following" "tables:~n~p", [Tables]), {error, Reason} end. %%---------------------------------------------------------------------- Notice the comments above the functions. Obviously, they refer to all three functions, not only wait_for_tables/1. They indicate that the programmer intended that the second argument of the wait_for_tables/2 function (the timeout) is an integer, but note that this intention is nowhere reflected in the code (e.g. in the form of an is_integer/1 guard). The third argument of wait_for_tables/3 is even more interesting. (Reasons in increasing order of importance.) 1. Its "starting" value (-1) is _inconsistent_ with the documentation 2. This value has _NO effect whatsoever_ to the intention of the programmer of counting the number of attempts. (Recall that this is a non-exported function, thus a positive value of "Attempts" will never be supplied for this function.) 3. This -1 value in conjunction with the fact that there is no guarantee that Timeout is an integer is a serious bug waiting to happen. Imagine the effect that a call wait_for_tables(SomeTables, infinity) will have to the system. It will throw it to an almost endless loop which, thanks to the fact that Erlang has bignum arithmetic, will first consume all available heap and then crash the node running this code. This is a bug that is very difficult to discover by testing. Now, all this is currently identified by the *development* version of Dialyzer as: {orber_tb,wait_for_tables,3}: Type guard {integer,0} will always fail since variable has type neg_integer()! which, admittedly, does not explain to the programmer the problem in exactly the same way that I did ;-). Instead, it simply points out that the first clause of this function is just dead code. There was a relatively recent comment to this mailing list by Mats Cronqvist: running dialyzer on well-tested code will turn up tons of errors. alas, that almost always turns out to be dead code. I guess one point I am implicitly trying to make here is that even dead code might not be so harmless as its "dead" status might suggest, and worth taking a closer look. Typically, competent programmers do not write dead code. Feedback is welcome, Kostis From mikpe@REDACTED Thu Jan 11 17:57:36 2007 From: mikpe@REDACTED (Mikael Pettersson) Date: Thu, 11 Jan 2007 17:57:36 +0100 (MET) Subject: [erlang-questions] kernel-poll problem Message-ID: <200701111657.l0BGvamk026209@harpo.it.uu.se> On Thu, 11 Jan 2007 15:31:43 +0100, Fredrik Thulin wrote: > $ /pkg/erlang/R11B-2_poll/bin/erl +K true > erts_poll_create_pollset(): Failed to create epoll set: enosys (38) ENOSYS means that this kernel doesn't have epoll system calls. Either it's too old, or EPOLL has been disabled. > Aborted > $ > > This is on Linux 2.6.11 (under Xen), with glibc 2.3.3. > > Has anyone seen this, or better still, solved this? Enable EPOLL in your kernel, or upgrade to a newer kernel. 2.6.11 is pretty ancient. /Mikael From fritchie@REDACTED Thu Jan 11 18:22:39 2007 From: fritchie@REDACTED (Scott Lystig Fritchie) Date: Thu, 11 Jan 2007 11:22:39 -0600 Subject: [erlang-questions] Detecting 'inconsistent_database' and other Mnesia events In-Reply-To: Message of "Thu, 11 Jan 2007 16:05:36 +0100." Message-ID: <200701111722.l0BHMdfG004390@snookles.snookles.com> >>>>> "uw" == Ulf Wiger writes: uw> We approached it differently. There are other things to worry uw> about besides inconsistencies. Sometimes, the database may not uw> come up at all. Yup, I agree. However ... the customer I'm working for would not be excessively forgiving if I didn't try to avoid a race condition like Mnesia event subscription. {shrug} Many thanks to Serge for sleuthing the term used (eventually) by mnesia_event:report_error/2. Definitely absurd, but avoids the race condition. I've encountered the situation that Ulf describes. Fortunately, not in the field. :-) uw> It's possible that a uw> generic decision support framework could be made out of what we've uw> done, but you shouldn't hold your breath waiting for us to do that uw> (you know - if it works, don't touch it, and all that.) Our solution involves less code and more human intervention: * Using -kernel dist_auto_connect once * Only one mechanism for reconnecting nodes: a human runs the init.d restart script to restart the entire application on a node. * On app startup, mnesia:wait_for_tables/2 is used with a 10 second timeout to wait for a known small table (with a higher 'load_order' priority). If it can't be loaded in that amount of time, an alarm is set and an alert message is logged to identify the missing nodes. That table is replicated similarly to all other tables, so (I hope) failing to load that table means possible trouble with any other table. * Bundled a utility to make it easy for Ops technicians to run mnesia:set_master_nodes/1 if it's necessary. Until someone wants to pay me overtime to reinvent Ericsson's decision support wheel, the above has had a positive-enough reaction with customers and their network ops staffs. -Scott From david.nospam.hopwood@REDACTED Fri Jan 12 00:05:20 2007 From: david.nospam.hopwood@REDACTED (David Hopwood) Date: Thu, 11 Jan 2007 23:05:20 +0000 Subject: [erlang-questions] [cyclone-l] memory safety bug! In-Reply-To: References: Message-ID: <45A6C2B0.1020501@blueyonder.co.uk> [cross-posted from the Cyclone mailing list to the Erlang list] Michael Hicks wrote: > Looks like memory safety is a concern for NASA too: > > http://www.spaceref.com/news/viewnews.html?id=1185 "We think that the failure was due to a software load we sent up in June of last year. This software tried to synch up two flight processors. Two addresses were incorrect - two memory addresses were over written. As the geometry evolved, we drove the [solar] arrays against a hard stop and the spacecraft went into safe mode. The radiator for the battery pointed at the sun, the temperature went up, and battery failed. But this should be treated as preliminary." The discussion below assumes that this brief description is accurate, as far as it goes. It sounds like memory safety would have been necessary, but not sufficient to avoid mission failure. Memory-safety doesn't prevent run-time errors [*]; it only turns them into "nicer" fault behaviour, for example an exception or a trap to an emergency handler. So what would probably have happened in a memory-safe language is that spacecraft would have gone into safe mode earlier, as a result of whatever fault caused the "two memory addresses [to be] overwritten". However, no memory would have been corrupted as a result of this fault. Upgrading software in flight is always, and foreseeably, a risky operation. What is needed to recover from this kind of situation is a 'downgrade' facility as well as memory safety. By downgrade, I mean a facility that allows the system to go back to a previous state and software configuration in case an upgrade fails. An example of a language that provides this is Erlang (see section 3.8 of , although that doesn't go into much detail specifically about downgrade). Going into safe mode probably should not have caused the battery radiator to point continuously to the sun; that sounds like a separate design problem. But a downgrade facility would have allowed a failed upgrade to very quickly cause the spacecraft to go back to the previous, known-working software, instead of into safe mode. (There are other kinds of plausible fault that could be recovered if caught soon enough, such as faults that would cause fuel or power to be expended.) Mars -> Earth -> Mars communication latency varies between 6.5 and 45 minutes, which might be too long for successful recovery if the downgrade has to be triggered from Earth after observing the fault. So downgrade should probably be automatic, if a fault occurs within the current roundtrip communication time of an upgrade. [*] Memory safety can make errors more reproducible and visible during testing, but let's assume for the sake of argument that whatever defect was in the new software version would still have got through ground-based testing. -- David Hopwood From autophile@REDACTED Fri Jan 12 03:23:19 2007 From: autophile@REDACTED (autophile) Date: Fri, 12 Jan 2007 02:23:19 +0000 Subject: [erlang-questions] leex problem outputting file References: Message-ID: <20070112022319.8D3995A1FA@mail.erlangsystems.com> Hi all... Not sure what I'm doing wrong here. I have the version of leex which is in the User Contributions section. I've compiled it, so I now have ~/Desktop/leex/leex.beam. Now I change directory to foo (which contains my regexp_lexer.xrl) and run erl: erl -pa ~/Desktop/leex/leex.beam Quote: Erlang (BEAM) emulator version 5.5.2 [source] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.5.2 (abort with ^G) 1> leex:file(regexp_lexer.xrl). Parsing file regexp_lexer.xrl, contained 14 rules. NFA contains 42 states, DFA contains 16 states, minimised to 16 states. Writing file regexp_lexer.erl, open error error (end of quote) What's wrong? Thanks! --Rob _________________________________________________________ Post sent from http://www.trapexit.org From bengt.kleberg@REDACTED Fri Jan 12 08:44:35 2007 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Fri, 12 Jan 2007 08:44:35 +0100 Subject: [erlang-questions] leex problem outputting file In-Reply-To: <20070112022319.8D3995A1FA@mail.erlangsystems.com> References: <20070112022319.8D3995A1FA@mail.erlangsystems.com> Message-ID: <45A73C63.9060203@ericsson.com> On 2007-01-12 03:23, autophile wrote: > Hi all... > > Not sure what I'm doing wrong here. I have the version of leex which is in the User Contributions section. I've compiled it, so I now have ~/Desktop/leex/leex.beam. > > Now I change directory to foo (which contains my regexp_lexer.xrl) and run erl: ...deleted > Writing file regexp_lexer.erl, open error > error you probably have already checked this, but do you have write permission in directory foo? or is there already a file called regexp_lexer.erl which you are not allowed to remove? bengt -- EPO guidelines 1978: "If the contribution to the known art resides solely in a computer program then the subject matter is not patentable in whatever manner it may be presented in the claims." From bjorn@REDACTED Fri Jan 12 09:39:45 2007 From: bjorn@REDACTED (Bjorn Gustavsson) Date: 12 Jan 2007 09:39:45 +0100 Subject: [erlang-questions] Latent bugs in Erlang/OTP In-Reply-To: <45A66B83.5090701@cs.ntua.gr> References: <45A66B83.5090701@cs.ntua.gr> Message-ID: Kostis Sagonas writes: > > I guess one point I am implicitly trying to make here is that even dead > code might not be so harmless as its "dead" status might suggest, and > worth taking a closer look. Typically, competent programmers do not > write dead code. > I agree. Code can be dead because the pattern and/or guard is wrong, meaning that some condition you intended to handle is not handled. A Dialyzer warning for dead code once helped me to find a serious bug in Wings; the real bug was in another clause, but I would never have started examining that code without the hint from Dialyzer. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From robert.virding@REDACTED Fri Jan 12 11:17:07 2007 From: robert.virding@REDACTED (Robert Virding) Date: Fri, 12 Jan 2007 11:17:07 +0100 Subject: [erlang-questions] lists:reverse/1 as a built-in function Message-ID: <45A76023.9030500@telia.com> I think the main problem here is semantic, what is meant by a built-in function, BIF. BIFs have always meant things that were part of the Erlang language but didn't have a special syntax; they looked like "normal" function calls. How they are implemented is completely irrelevant! Spawn, link, size etc are all just as much a part of the language as ! and receive, but they have no special syntax, they are BIFs. Both spawn/3 and spawn/4 are BIFs, spawn/3 is implemented in C while spawn/4 is implemented in Erlang. The unfinished Erlang standard addresses the use of the term BIF. Unfortunately the reference manual is not clear on this point. So with this in mind it is not really strange that BIFs are auto-imported, and have priority over "normal" functions defined in modules; they are part of the language. It is perhaps unfortunate that we allowed definition of functions with the same name and arity as the auto-imported ones. What is a bit of a mess is that some BIFs are auto-imported while some you can only reach by explicitly using the module name erlang. Well all exist in the module erlang but for some this is implicit. Unfortunately there seems to be no clear logic why some BIFs are auto-imported and some need to be prefixed with erlang. This is an old problem. The meaning of BIF was not really a problem until functions which are clearly not BIFs were implemented in C for efficiency, functions like append and reverse. These functions are perfectly logically part of the module lists. What is needed is a new term to describe functions which are implemented in C in the emulator which are not BIFs. Robert From attila.rajmund.nohl@REDACTED Fri Jan 12 11:32:30 2007 From: attila.rajmund.nohl@REDACTED (attila.rajmund.nohl@REDACTED) Date: Fri, 12 Jan 2007 11:32:30 +0100 (CET) Subject: [erlang-questions] Open TCP ports Message-ID: Hello! Is there a way to determine that which erlang processes are listening on a given TCP port? The operating system tells me that the erlang VM is listening on that port, but I need to know that which erlang process is using that port. Bye,NAR -- "Beware of bugs in the above code; I have only proved it correct, not tried it." From mats.cronqvist@REDACTED Fri Jan 12 12:04:31 2007 From: mats.cronqvist@REDACTED (Mats Cronqvist) Date: Fri, 12 Jan 2007 12:04:31 +0100 Subject: [erlang-questions] Open TCP ports In-Reply-To: References: Message-ID: <45A76B3F.1050406@ericsson.com> attila.rajmund.nohl@REDACTED wrote: > Hello! > > Is there a way to determine that which erlang processes are listening on > a given TCP port? The operating system tells me that the erlang VM is > listening on that port, but I need to know that which erlang process is > using that port. inet:i(). From erik.reitsma@REDACTED Fri Jan 12 13:01:41 2007 From: erik.reitsma@REDACTED (Erik Reitsma (RY/ETM)) Date: Fri, 12 Jan 2007 13:01:41 +0100 Subject: [erlang-questions] Open TCP ports In-Reply-To: <45A76B3F.1050406@ericsson.com> Message-ID: <110BA8ACEE682C479D0B008B6BE4AEB101F455D0@esealmw107.eemea.ericsson.se> I use the following code, because I not only need to have the ports printed in the shell, but I need to do something with it. I use the fact that all sockets are ports with name "tcp_inet". It returns a list of tuples {Port, Address, PeerAddress, PeerPort, Owner, Input, Output}, where Owner is the process that listens to local port Port. If there is no peer address and peer port, it is only listening, not yet connected. Key functions to use are erlang:ports/0, erlang:port_info/1, inet:sockname/1 and inet:peername/1. get_sockets() -> SockPorts = lists:filter(fun({Sock,Info}) -> lists:keysearch(name,1,Info)=={value,{name,"tcp_inet"}} end, [{SockPort,erlang:port_info(SockPort)}||SockPort<-erlang:ports()] ), SockPortsInfo = lists:map( fun({Sock,Info}) -> {socket_info,Name,Links,ID,Owner,Input,Output} = get_socket_info(Info), {Address,Port} = case catch inet:sockname(Sock) of {ok,{IP,PortNo}} -> {print_ip(IP),PortNo}; NoSock -> {"-",-1} end, {PeerAddress,PeerPort} = case catch inet:peername(Sock) of {ok,{PIP,PPortNo}} -> {print_ip(PIP),PPortNo}; PNoSock -> {"-",-1} end, {Port,Address,PeerAddress,PeerPort,Owner,Input,Output} end, SockPorts), GoodSocks = lists:filter( fun({-1,_,_,-1,_,_,_}) -> false; (_) -> true end, SockPortsInfo). get_socket_info(Info) -> get_socket_info(Info,{socket_info,"undefined",[],-1,undefined,-1,-1}). get_socket_info([],Res) -> Res; get_socket_info([{name,Name}|More],{socket_info,_Name,Links,ID,Connected ,Input,Output}) -> get_socket_info(More,{socket_info,_Name,Links,ID,Connected,Input,Output} ); get_socket_info([{links,Links}|More],{socket_info,Name,_Links,ID,Connect ed,Input,Output}) -> get_socket_info(More,{socket_info,Name,Links,ID,Connected,Input,Output}) ; get_socket_info([{id,ID}|More],{socket_info,Name,Links,_ID,Connected,Inp ut,Output}) -> get_socket_info(More,{socket_info,Name,Links,ID,Connected,Input,Output}) ; get_socket_info([{connected,Connected}|More],{socket_info,Name,Links,ID, _Connected,Input,Output}) -> get_socket_info(More,{socket_info,Name,Links,ID,Connected,Input,Output}) ; get_socket_info([{input,Input}|More],{socket_info,Name,Links,ID,Connecte d,_Input,Output}) -> get_socket_info(More,{socket_info,Name,Links,ID,Connected,Input,Output}) ; get_socket_info([{output,Output}|More],{socket_info,Name,Links,ID,Connec ted,Input,_Output}) -> get_socket_info(More,{socket_info,Name,Links,ID,Connected,Input,Output}) ; get_socket_info([H|More],Res) -> get_socket_info(More,Res). print_ip({B1,B2,B3,B4}) -> integer_to_list(B1) ++ "." ++ integer_to_list(B2) ++ "." ++ integer_to_list(B3) ++ "." ++ integer_to_list(B4); print_ip(Other) -> lists:flatten(io_lib:format("~p",[Other])). -----Original Message----- From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Mats Cronqvist Sent: Friday, January 12, 2007 12:05 PM To: erlang-questions@REDACTED Subject: Re: [erlang-questions] Open TCP ports attila.rajmund.nohl@REDACTED wrote: > Hello! > > Is there a way to determine that which erlang processes are listening > on a given TCP port? The operating system tells me that the erlang VM > is listening on that port, but I need to know that which erlang > process is using that port. inet:i(). _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions From saifi@REDACTED Fri Jan 12 13:09:27 2007 From: saifi@REDACTED (=?iso-8859-1?Q?Saifi?=) Date: Fri, 12 Jan 2007 17:39:27 +0530 Subject: [erlang-questions] FAQ Sec 1.5 query Message-ID: <20070112120927.14280.qmail@coolhost77.com> Hi: Sec 1.5 of FAQ talks about the organizations using Erlang in development, and cites the case of AXD301 ATM switch. I am keen to explore the suitability of implementing the following functionality 1. ip forwarding, packet filtering 2. ipsec with erlang and C hooks in Linux kernel. The message oriented semantics of IPSec exchanges (ISAKMP and IKE) seem very much amenable to implementation in erlang. What are the thoughts of the more experienced erlangers on this list ? The key capability required here would be 1. access to socket options (sockopt) 2. attaching hooks from tcp/ip stack to erlang rt. 3. certain specific interception capabilities. Additionally, has there been any precedence of OSPF implementation in erlang ? I would be grateful for any thoughts, suggestions shared on this topic. thanks Saifi. TWINCLING Society http://www.twincling.org/ From thomasl_erlang@REDACTED Fri Jan 12 14:22:49 2007 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Fri, 12 Jan 2007 05:22:49 -0800 (PST) Subject: [erlang-questions] lists:reverse/1 as a built-in function In-Reply-To: <45A76023.9030500@telia.com> Message-ID: <508117.44669.qm@web38803.mail.mud.yahoo.com> --- Robert Virding wrote: > So with this in mind it is not really strange that > BIFs are > auto-imported, and have priority over "normal" > functions defined in > modules; they are part of the language. It is > perhaps unfortunate that > we allowed definition of functions with the same > name and arity as the > auto-imported ones. It might have seemed like a good design choice at the time, but note that auto-import (with "override") has several unfortunate ramifications, which is why it should be aged out. As Richard mentioned, one such consequence is the difficulty in extending the set of BIFs. Standardizing the set of functions implemented in C doesn't sound like a viable long term solution (nor does standardizing the set of overridden functions). Disallowing functions with the same names as builtins doesn't sound like a very good design choice either. Do note that there already is a simple, straightforward option that does the right thing. Best, Thomas ____________________________________________________________________________________ 8:00? 8:25? 8:40? Find a flick in no time with the Yahoo! Search movie showtime shortcut. http://tools.search.yahoo.com/shortcuts/#news From autophile@REDACTED Fri Jan 12 17:51:57 2007 From: autophile@REDACTED (autophile) Date: Fri, 12 Jan 2007 16:51:57 +0000 Subject: [erlang-questions] leex problem outputting file References: Message-ID: <20070112165157.A9B345A1FA@mail.erlangsystems.com> Yes, I have write permission to the directory, and there is no regexp_lexer.erl file. I'm at a loss here... can anyone suggest any debugging steps I can take to get to the root of this problem? Thanks, --Rob _________________________________________________________ Post sent from http://www.trapexit.org From ejonesca@REDACTED Fri Jan 12 19:18:24 2007 From: ejonesca@REDACTED (ejonesca@REDACTED) Date: Fri, 12 Jan 2007 10:18:24 -0800 (PST) Subject: [erlang-questions] newbie install help Message-ID: <20070112181824.80695.qmail@web32913.mail.mud.yahoo.com> I'm trying to install erlang on a Suse 10.0 machine. When I run configure: ./configure --prefix=/home/erlang/erlang It ends with: ... configure: error: No curses library functions found configure: error: /home/eralng/otp_src_R11B-2/erts/configure failed for erts Running rpm -qa | grep curses yields: ncurses-5.4-71 yast2-ncurses-2.12.6-2 Any help will be appreciated. Thanks. ____________________________________________________________________________________ Finding fabulous fares is fun. Let Yahoo! FareChase search your favorite travel sites to find flight and hotel bargains. http://farechase.yahoo.com/promo-generic-14795097 From autophile@REDACTED Fri Jan 12 19:33:17 2007 From: autophile@REDACTED (autophile) Date: Fri, 12 Jan 2007 18:33:17 +0000 Subject: [erlang-questions] leex problem outputting file References: Message-ID: <20070112183317.F364B5A1F9@mail.erlangsystems.com> Problem found, by reading the leex source. When writing the output file, leex first tries to open leex.hrl in the following search path: . code:lib_dir()/tools/include However, since I had not installed leex in either . or tools/include, leex did not find leex.hrl. (Note to Robert: Please put a better error message in! "Couldn't find leex.hrl" would make much more sense than "open error" :) Perhaps using code:code_path() would make more sense? --Rob _________________________________________________________ Post sent from http://www.trapexit.org From rprice@REDACTED Fri Jan 12 20:01:48 2007 From: rprice@REDACTED (Roger Price) Date: Fri, 12 Jan 2007 20:01:48 +0100 (CET) Subject: [erlang-questions] newbie install help In-Reply-To: <20070112181824.80695.qmail@web32913.mail.mud.yahoo.com> References: <20070112181824.80695.qmail@web32913.mail.mud.yahoo.com> Message-ID: On Fri, 12 Jan 2007, ejonesca@REDACTED wrote: > When I run configure: > ./configure --prefix=/home/erlang/erlang > It ends with: > configure: error: No curses library functions found Perhaps you need to load the package ncurses-devel. Best Regards, Roger From ejonesca@REDACTED Fri Jan 12 22:26:09 2007 From: ejonesca@REDACTED (ejonesca@REDACTED) Date: Fri, 12 Jan 2007 13:26:09 -0800 (PST) Subject: [erlang-questions] newbie install help Message-ID: <20070112212609.1720.qmail@web32915.mail.mud.yahoo.com> That took care of things. Thank you. ----- Original Message ---- From: Roger Price To: Erlang mailing list Sent: Friday, January 12, 2007 12:01:48 PM Subject: Re: [erlang-questions] newbie install help On Fri, 12 Jan 2007, ejonesca@REDACTED wrote: > When I run configure: > ./configure --prefix=/home/erlang/erlang > It ends with: > configure: error: No curses library functions found Perhaps you need to load the package ncurses-devel. Best Regards, Roger _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions ____________________________________________________________________________________ Want to start your own business? Learn how on Yahoo! Small Business. http://smallbusiness.yahoo.com/r-index From klacke@REDACTED Fri Jan 12 22:53:14 2007 From: klacke@REDACTED (Claes Wikstrom) Date: Fri, 12 Jan 2007 22:53:14 +0100 Subject: [erlang-questions] FAQ Sec 1.5 query In-Reply-To: <20070112120927.14280.qmail@coolhost77.com> References: <20070112120927.14280.qmail@coolhost77.com> Message-ID: <45A8034A.1090607@hyber.org> Saifi wrote: > Hi: > > Sec 1.5 of FAQ talks about the organizations using Erlang in development, > and cites the case of AXD301 ATM switch. > > I am keen to explore the suitability of implementing the following functionality > 1. ip forwarding, packet filtering > 2. ipsec > with erlang and C hooks in Linux kernel. > > The message oriented semantics of IPSec exchanges (ISAKMP and IKE) seem > very much amenable to implementation in erlang. > What are the thoughts of the more experienced erlangers on this list ? > Implementation of ISAKMP/IKE would fit erlang just perfectly. I've worked with other proprietary implementations of ISAKMP/IKE at it really itched hard to just rewrite the whole thing in Erlang. All MP code can nicely be written directly in erlang using bignums. > The key capability required here would be > 1. access to socket options (sockopt) > 2. attaching hooks from tcp/ip stack to erlang rt. > 3. certain specific interception capabilities. > Well different OSes have different means to do this. Linux and BSD does it entirely different. I'd just do a OS dependant proper interface (linked in driver) to the kernel functions to populate SAD/SDP entries. > Additionally, has there been any precedence of OSPF implementation in erlang ? > I know of none - but here again similar situation with a highly complex userspace protocol program which needs a (OS specific) driver to populate and read kernel datastructures. Thus, also OSPF would be excellent to implement in erlang > I would be grateful for any thoughts, suggestions shared on this topic. > Hard protocols to tackle - good luck - you need it. /klacke From surindar.shanthi@REDACTED Sun Jan 14 13:23:39 2007 From: surindar.shanthi@REDACTED (Surindar Sivanesan) Date: Sun, 14 Jan 2007 17:53:39 +0530 Subject: [erlang-questions] TCP/IP socket communication problem Message-ID: <42ea5fb60701140423hce29757he94da59afc15f362@mail.gmail.com> Dear all, We are using an application in erlang which is acting as a server. This server is continuously listening and ready to accept any client in TCP/IP communication. Around *50 clients* connecting with this server application. This application is working fine for some time. At one point of time, while the server is accepting a communication using the BIF *gen_tcp:accept/1*, *{error,enfile}* error is occurred and *all the 50 clients using that socket are disconnected abruptly*. We are using Windows 2003 server OS and Erlang *ERTS **5.5*. Please provide me the solution if any to solve this problem Thanks in advance -- with regards, S.Surindar -------------- next part -------------- An HTML attachment was scrubbed... URL: From robert.virding@REDACTED Sun Jan 14 18:32:26 2007 From: robert.virding@REDACTED (Robert Virding) Date: Sun, 14 Jan 2007 18:32:26 +0100 Subject: [erlang-questions] lists:reverse/1 as a built-in function In-Reply-To: <508117.44669.qm@web38803.mail.mud.yahoo.com> References: <508117.44669.qm@web38803.mail.mud.yahoo.com> Message-ID: <45AA692A.9080608@telia.com> Thomas Lindgren wrote: > --- Robert Virding wrote: > >>So with this in mind it is not really strange that >>BIFs are >>auto-imported, and have priority over "normal" >>functions defined in >>modules; they are part of the language. It is >>perhaps unfortunate that >>we allowed definition of functions with the same >>name and arity as the >>auto-imported ones. > > > It might have seemed like a good design choice at the > time, but note that auto-import (with "override") has > several unfortunate ramifications, which is why it > should be aged out. As Richard mentioned, one such > consequence is the difficulty in extending the set of > BIFs. Sorry I think there is definitely a difference in stature between functions which are part of the language, BIFs like spawn and link, and normal user defined functions. If I redefine spawn then I have changed the semantics of Erlang, just as if I were to allow modifying how receive or ! works. Just because they have a special syntax does mean that they are more fundamental than spawn or link. The reason we did not define a special syntax for them was because they do not need it, and because what a language does NOT need is a lot of unnecessary extra syntax. But we can make operators for the lot of them and the problem will be solved. > Standardizing the set of functions implemented in C > doesn't sound like a viable long term solution (nor > does standardizing the set of overridden functions). > Disallowing functions with the same names as builtins > doesn't sound like a very good design choice either. > Do note that there already is a simple, > straightforward option that does the right thing. I never said we should standardise the set of functions implemented in C, just that we should find a name for functions which are implemented in C but not part of the language. Using the name BIFs for everything does not show the difference in stature of the functions. I have no problems with choice functions from the standard libraries being implemented in C, it is a question for the development team to decide which functions are worth the extra effort, but there should definitely not be a coupling between how functions are implemented and how they are called. Just because lists:append/2 and lists:reverse/2 (not /1 if I remember) are implemented in C does not mean you should be able to call them with just append and reverse. Robert From alex.arnon@REDACTED Sun Jan 14 22:33:03 2007 From: alex.arnon@REDACTED (Alex Arnon) Date: Mon, 15 Jan 2007 00:33:03 +0300 Subject: [erlang-questions] lists:reverse/1 as a built-in function In-Reply-To: <508117.44669.qm@web38803.mail.mud.yahoo.com> References: <45A76023.9030500@telia.com> <508117.44669.qm@web38803.mail.mud.yahoo.com> Message-ID: <944da41d0701141333x648ed3di1c29155b88f2228b@mail.gmail.com> I agree with Thomas, this is a terrible wart and a BUG, whichever way you look at it. Very very bad, for several reasons: 1) Breaks the Principle of Least Astonishment. I'm certainly a little shocked to learn of it, and I've been mucking about with Erlang for awhile. 2) An excellent way to future-buggify existing code. Who knows when some funciton will become a BIF, and break currently running code? 3) The "function call" concept is overloaded without any indication (unless you slog through the docs, and again things might change from version to version). If you want to give certain functions a different stature, make it easily evident in the syntax. And the inconsistency with some BIFs having to be called with "erlang:" prepended... If anyone asks, I support Thomas's suggestion for preserving backward compatibility via compiler flags :) On 1/12/07, Thomas Lindgren wrote: > > > --- Robert Virding wrote: > > So with this in mind it is not really strange that > > BIFs are > > auto-imported, and have priority over "normal" > > functions defined in > > modules; they are part of the language. It is > > perhaps unfortunate that > > we allowed definition of functions with the same > > name and arity as the > > auto-imported ones. > > It might have seemed like a good design choice at the > time, but note that auto-import (with "override") has > several unfortunate ramifications, which is why it > should be aged out. As Richard mentioned, one such > consequence is the difficulty in extending the set of > BIFs. > > Standardizing the set of functions implemented in C > doesn't sound like a viable long term solution (nor > does standardizing the set of overridden functions). > Disallowing functions with the same names as builtins > doesn't sound like a very good design choice either. > Do note that there already is a simple, > straightforward option that does the right thing. > > Best, > Thomas > > > > > > ____________________________________________________________________________________ > 8:00? 8:25? 8:40? Find a flick in no time > with the Yahoo! Search movie showtime shortcut. > http://tools.search.yahoo.com/shortcuts/#news > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From headspin@REDACTED Mon Jan 15 00:45:57 2007 From: headspin@REDACTED (dda) Date: Mon, 15 Jan 2007 00:45:57 +0100 Subject: [erlang-questions] String encoding and character set In-Reply-To: References: Message-ID: I have started a long while ago a module dealing with character encodings ? Unicode vs the rest of the ISO jungle ? and implementing a half-assed string type; but my day/evening jobs are getting in the way. This module, which does work to some extent, was/is geared towards CJK[V] languages, these being my area of expertise ? but is agnostic enough to handle anything. If people are interested in working on this project, I could donate the code as is, and help on my spare free time. -- dda On 1/10/07, Ludovic Coquelle wrote: > Hi, > Looking for a solution to deals with string encoding (and convertion) in > Erlang, I found an 'iconv' driver in Jungerl. > But it has no documentation at all (ok, it should be fairly simple) and no > activity status. > > Futhermore, do you guys think it is a good way to do encoding convertion in > Erlang? > Any other suggestion? > > (I'm a bit tired to always get the same comment about Erlang: there is no > good string library ... and it's a show stop to Erlang adoption by certain > project and mine particularly) From headspin@REDACTED Mon Jan 15 00:50:14 2007 From: headspin@REDACTED (dda) Date: Mon, 15 Jan 2007 00:50:14 +0100 Subject: [erlang-questions] String encoding and character set In-Reply-To: References: Message-ID: String types ? at least well-implemented ones ? don't just store a string, but also encoding information. They are/should be geared towards pain-free manipulation of text data, and by text I mean things outside ASCII-land. Encodings-aware string manipulation functions don't function on bytes, but on characters, a quite different notion. We don't have this in Erlang. -- dda On 1/10/07, Ludovic Coquelle wrote: > Anyway I just don't understand the real advantage of a string data type > (for me it only means that performance could be better), > so I don't understand why people complain so much about that. From lcoquelle@REDACTED Mon Jan 15 02:44:44 2007 From: lcoquelle@REDACTED (Ludovic Coquelle) Date: Mon, 15 Jan 2007 09:44:44 +0800 Subject: [erlang-questions] String encoding and character set In-Reply-To: References: Message-ID: Thanks, this simple remark just help me to understand what is meant by "string type"! On 1/15/07, dda wrote: > > String types ? at least well-implemented ones ? don't just store a > string, but also encoding information. They are/should be geared > towards pain-free manipulation of text data, and by text I mean things > outside ASCII-land. Encodings-aware string manipulation functions > don't function on bytes, but on characters, a quite different notion. > We don't have this in Erlang. > > -- > dda > > On 1/10/07, Ludovic Coquelle wrote: > > Anyway I just don't understand the real advantage of a string data type > > (for me it only means that performance could be better), > > so I don't understand why people complain so much about that. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bjorn@REDACTED Mon Jan 15 09:48:41 2007 From: bjorn@REDACTED (Bjorn Gustavsson) Date: 15 Jan 2007 09:48:41 +0100 Subject: [erlang-questions] lists:reverse/1 as a built-in function In-Reply-To: <45AA692A.9080608@telia.com> References: <508117.44669.qm@web38803.mail.mud.yahoo.com> <45AA692A.9080608@telia.com> Message-ID: Robert Virding writes: > Sorry I think there is definitely a difference in stature between > functions which are part of the language, BIFs like spawn and link, and > normal user defined functions. If I redefine spawn then I have changed > the semantics of Erlang, just as if I were to allow modifying how > receive or ! works. Just because they have a special syntax does mean > that they are more fundamental than spawn or link. The reason we did not > define a special syntax for them was because they do not need it, and > because what a language does NOT need is a lot of unnecessary extra > syntax. But we can make operators for the lot of them and the problem > will be solved. > The current behaviour would be fine if it was decided once and for all which functions are BIFs, and we never added new BIFs. Unfortunately, we do add new BIFs, and if we choose to make them auto-imported, we may break code that was written long before the BIF was introduced. That is bad. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From bengt.kleberg@REDACTED Mon Jan 15 10:03:14 2007 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Mon, 15 Jan 2007 10:03:14 +0100 Subject: [erlang-questions] Erlang sighting in POSIX Parallel Programming text Message-ID: <45AB4352.9000305@ericsson.com> greetings, just for fun: in an article about POSIX Parallel Programming there is a mentioning of Erlang. http://www.informit.com/articles/article.asp?p=679545&rl=1 bengt -- EPO guidelines 1978: "If the contribution to the known art resides solely in a computer program then the subject matter is not patentable in whatever manner it may be presented in the claims." From nick@REDACTED Mon Jan 15 12:27:15 2007 From: nick@REDACTED (Niclas Eklund) Date: Mon, 15 Jan 2007 12:27:15 +0100 (MET) Subject: [erlang-questions] Latent bugs in Erlang/OTP In-Reply-To: <45A66B83.5090701@cs.ntua.gr> Message-ID: Hello! Actually, that function behaves exactly as intended. For those of you not familiar with Orber you should know that this is an internal function, which may not be used by other applications. Let's begin with the comment (i.e. argument datatypes), which defines what other modules may pass but that doesn't mean that the orber_tb module may not use other values internally. Hence, it's consistent. If the user may define, for example, the Timeout parameter the value check will be performed in the module handling environment parameters (orber_env.erl). From my point of view it's rather pointless to check the value in each place it is used if one can achieve the same thing in one single place. Why -1? Previously mnesia:wait_for_tables(Tables, infinity) was always used. Hence, to be fully backward compatible but still be able to inform the user that there is a problem loading Mnesia tables. Using -1 prevents that the following clause never match: wait_for_tables(Tables, _Timeout, 0) -> error("Mnesia failed to load the some or all of the following" "tables:~n~p", [Tables]), {error, "The requested Mnesia tables not yet available."}; I.e. the same behavior as for mnesia:wait_for_tables(Tables, infinity). But why isn't orber_tb:wait_for_tables/3 exported? When the user will be allowed to define this parameter it will be. You wrote: 3. This -1 value in conjunction with the fact that there is no guarantee that Timeout is an integer is a serious bug waiting to happen. Imagine the effect that a call wait_for_tables(SomeTables, infinity) will have to the system. It will throw it to an almost endless loop which, thanks to the fact that Erlang has bignum arithmetic, will first consume all available heap and then crash the node running this code. This is a bug that is very difficult to discover by testing. If the Timeout would be set to infinity, mnesia:wait_for_tables/2 will not return until all tables are loaded or an error is detected, which aborts orber_tb:wait_for_tables as well (i.e. invoked at most once). Best regards, Nick On Thu, 11 Jan 2007, Kostis Sagonas wrote: > Partly due to extending Dialyzer and partly wanting to satisfying my > scientific curiosity, I've been spending a significant portion of my > recent time looking for bugs in Erlang code, mainly in OTP. > > More importantly, I am trying to get a grasp on the reasons why even the > most competent Erlang programmers write code that contains latent bugs. > This, in the hope that this knowledge can be fed back into Dialyzer or > some other similar tool. Still, the things I've run across so far are > interesting -- perhaps even worth of a talk at some forum. > > > Let me share with you one of the latest ones -- discovered by the > development version of Dialyzer which, among other things, infers > integer ranges. > > The beginning of lib/orber/src/orber_tb.erl in R11B-2 reads: > > %%---------------------------------------------------------------------- > -module(orber_tb). > ... > -export([wait_for_tables/1, wait_for_tables/2, > is_loaded/0, is_loaded/1, is_running/0, is_running/1, > info/2, error/2, unique/1]). > %%---------------------------------------------------------------------- > > Note that two wait_for_tables functions are exported, those with arities > 1 and 2. These functions are defined as follows: > > %%---------------------------------------------------------------------- > %% function : wait_for_tables/1 > %% Arguments: Tables - list of mnesia tables > %% Timeout - integer (no point in allowing infinity) > %% Attempts - integer > 0 How many times should we try > %% Returns : > %% Exception: > %% Effect : > %%---------------------------------------------------------------------- > wait_for_tables(Tables) -> > wait_for_tables(Tables, 30000, -1). > > wait_for_tables(Tables, Timeout) -> > wait_for_tables(Tables, Timeout, -1). > > wait_for_tables(Tables, _Timeout, 0) -> > error("Mnesia failed to load the some or all of the following" > "tables:~n~p", [Tables]), > {error, "The requested Mnesia tables not yet available."}; > wait_for_tables(Tables, Timeout, Attempts) -> > case mnesia:wait_for_tables(Tables, Timeout) of > ok -> > ok; > {timeout, BadTabList} -> > info("Mnesia hasn't loaded the following tables (~p msec):~n~p", > [Timeout, BadTabList]), > wait_for_tables(BadTabList, Timeout, Attempts-1); > {error, Reason} -> > error("Mnesia failed to load the some or all of the following" > "tables:~n~p", [Tables]), > {error, Reason} > end. > %%---------------------------------------------------------------------- > > Notice the comments above the functions. Obviously, they refer to all > three functions, not only wait_for_tables/1. They indicate that the > programmer intended that the second argument of the wait_for_tables/2 > function (the timeout) is an integer, but note that this intention is > nowhere reflected in the code (e.g. in the form of an is_integer/1 guard). > > The third argument of wait_for_tables/3 is even more interesting. > (Reasons in increasing order of importance.) > > 1. Its "starting" value (-1) is _inconsistent_ with the documentation > > 2. This value has _NO effect whatsoever_ to the intention of the > programmer of counting the number of attempts. > (Recall that this is a non-exported function, thus a positive value > of "Attempts" will never be supplied for this function.) > > 3. This -1 value in conjunction with the fact that there is no > guarantee that Timeout is an integer is a serious bug waiting to > happen. Imagine the effect that a call > > wait_for_tables(SomeTables, infinity) > > will have to the system. It will throw it to an almost endless > loop which, thanks to the fact that Erlang has bignum arithmetic, > will first consume all available heap and then crash the node > running this code. This is a bug that is very difficult to > discover by testing. > > > Now, all this is currently identified by the *development* version of > Dialyzer as: > > {orber_tb,wait_for_tables,3}: > Type guard {integer,0} will always fail > since variable has type neg_integer()! > > which, admittedly, does not explain to the programmer the problem in > exactly the same way that I did ;-). Instead, it simply points out > that the first clause of this function is just dead code. > > There was a relatively recent comment to this mailing list by Mats > Cronqvist: > > running dialyzer on well-tested code will turn up tons of > errors. alas, that almost always turns out to be dead code. > > > I guess one point I am implicitly trying to make here is that even dead > code might not be so harmless as its "dead" status might suggest, and > worth taking a closer look. Typically, competent programmers do not > write dead code. > > > Feedback is welcome, > > Kostis > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From mats.cronqvist@REDACTED Mon Jan 15 12:51:24 2007 From: mats.cronqvist@REDACTED (Mats Cronqvist) Date: Mon, 15 Jan 2007 12:51:24 +0100 Subject: [erlang-questions] Latent bugs in Erlang/OTP In-Reply-To: <45A66B83.5090701@cs.ntua.gr> References: <45A66B83.5090701@cs.ntua.gr> Message-ID: <45AB6ABC.7030805@ericsson.com> Kostis Sagonas wrote: > Partly due to extending Dialyzer and partly wanting to satisfying my > scientific curiosity, I've been spending a significant portion of my > recent time looking for bugs in Erlang code, mainly in OTP. > [...] > There was a relatively recent comment to this mailing list by Mats > Cronqvist: > > running dialyzer on well-tested code will turn up tons of > errors. alas, that almost always turns out to be dead code. > > > I guess one point I am implicitly trying to make here is that even dead > code might not be so harmless as its "dead" status might suggest, and > worth taking a closer look. Typically, competent programmers do not > write dead code. for the record, i agree with Kostis' comment about competence and lack of dead code. the problem i was lamenting is one of bootstrapping. if you have a bunch of code that generates 1,666(*) dialyzer warnings, it takes some convincing to go through all the old cruft and figure out which pieces can be safely removed. and until you've done that the interesting warnings will be lost in the noise. perhaps the dialyzer can be enhanced to rewrite the sources dead-code free? mats * actual number From viganiko@REDACTED Mon Jan 15 19:05:30 2007 From: viganiko@REDACTED (VIG Aniko) Date: Mon, 15 Jan 2007 19:05:30 +0100 Subject: [erlang-questions] Thesis Presentation on Erlang Refactoring (London, UK) Message-ID: <20070115175511.M29553@inf.elte.hu> Dear all, Our thesis presentation is on Erlang refactoring using a relational database to store the source code (static and semantic information too). It currently supports funciton and variable renaming, permutating function and tuple arguments and eliminating variables by rewriting named subexpressions. In the presentation, we will speak about the structure of the toolkit, the relations between Emacs, Distel, Elrang and MySQL, as well as the implementation of the refactorings. Our thesis project was done with the support ELTE IKKK and Ericsson Hungary in Budapest with the cooperation of the University of Kent in Canterbury. The presentation will start at 17.00 on 8th of February in Erlang Training and Consulting's London office at http://maps.google.co.uk/maps? f=q&hl=en&q=erlang+consulting,+london&ll=51.521401,- 0.080166&spn=0.023605,0.058537 . Let them know if you are planing on attending. Regards, Aniko Vig and Tamas Nagy From autophile@REDACTED Mon Jan 15 19:53:03 2007 From: autophile@REDACTED (Robert Baruch) Date: Mon, 15 Jan 2007 13:53:03 -0500 Subject: [erlang-questions] lists:reverse/1 as a built-in function In-Reply-To: References: <508117.44669.qm@web38803.mail.mud.yahoo.com> <45AA692A.9080608@telia.com> Message-ID: <6965656B-4C1D-4E0A-BB6A-8DFC9D28B92E@zoominternet.net> Personally, I'd like to decouple the "BIF problem" from the "import problem", like this: Use Java-like package rules in Erlang, applied like this: (in file baz.erl): -module(foo.bar.baz). example_function(Arg) -> false. foo.bar is the package name. baz is the "class" name. If you call example_function(Arg) inside baz.erl, you don't need to use a fully qualified name. If you call example_function(Arg) inside an erl file declared as - module(foo.bar.X) then you need to call it as baz:example_function(Arg). If you call example_function(Arg) anywhere else, you need to either call it as foo.bar.baz:example_function(Arg), or you need to -import (foo.bar), and then you must call it as baz:example_function(Arg). The reason that I call baz the "class" name is that I'm thinking of functions declared in module X as equivalent to Java's static functions of a class X. The rules above should duplicate the essential parts of the Java name resolution. Once these rules are in place, the next thing is to allow any functions declared in the erlang module to be used without fully qualifying the name. Thus, a function foo(Arg) declared in erlang can be called as foo(Arg) in any module. This is the equivalent of "java.lang" in Java, except messier because the erlang module is not further subdivided into related groups of functions. >:( Finally, document well which functions are BIF's. This is the equivalent of the "native" keyword in Java, except of course you don't have the ability to declare a native function in a module. If a BIF happens to be in the erlang module, you can use it without fully qualifying the name. If a BIF is not in the erlang module, you must qualify the name according to the package rules above. That is, a BIF is treated no differently from any other function when it comes to name qualification. This solution decouples the "BIF problem" from the "import problem". If a function becomes a BIF, programs would not have to change. To transition, the next version of the compiler could have two modes, one in which the package rules are followed, and one where the old package rules are followed, but spits out deprecation warnings. The compiler version after that would not support the old package rule mode. Yes, it will break existing applications... but then they could always use the old version of the compiler, which, presumably, they used to create the original application. If they want to upgrade to a new version of the compiler, they have to fix all of their deprecated issues. Then again, what do I know -- my main programming language is Java :) --Rob On Jan 15, 2007, at 3:48 AM, Bjorn Gustavsson wrote: > > The current behaviour would be fine if it was decided once and for all > which functions are BIFs, and we never added new BIFs. > > Unfortunately, we do add new BIFs, and if we choose to make them > auto-imported, > we may break code that was written long before the BIF was introduced. > That is bad. > > /Bjorn > -- > Bj?rn Gustavsson, Erlang/OTP, Ericsson AB > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > From sand@REDACTED Tue Jan 16 05:17:49 2007 From: sand@REDACTED (sand@REDACTED) Date: Mon, 15 Jan 2007 20:17:49 -0800 Subject: [erlang-questions] Reflecting changes to Daylight Saving Time in U.S. Message-ID: <17836.20973.354773.678048@priss.frightenedpiglet.com> On Linux, Erlang uses standard POSIX facilities to specify time zones, correct? Just double-checking, as the documentation is deliberately vague on that point, and the U.S Daylight Saving Time rules will be changing soon. Thanks, Derek -- Derek Upham sand@REDACTED From luke@REDACTED Tue Jan 16 07:37:59 2007 From: luke@REDACTED (LUKE) Date: Tue, 16 Jan 2007 14:37:59 +0800 Subject: [erlang-questions] Newbie~~The ERLANG/OTP V5.5.2 create a target system on WIN2003 Server Message-ID: <00bd01c73938$de7cef70$0701a8c0@lukeserver> Create a target system fail. step1: i create a file(C:\Program Files\erl5.5.2\mysystem.rel) file content: %% mysystem.rel {release, {"MYSYSTEM", "FIRST"}, {erts, "5.5.2"}, [{kernel, "2.11.2"}, {stdlib, "1.14.2"}, {sasl, "2.1.4"}, {pea, "1.0"}]}. step2: mkdir C:\target_system\myapps\pea-1.0\ebin cd C:\Program Files\erl5.5.2\ execute the command erl -pa C:\target_system\myapps\pea-1.0\ebin step3: 1> target_system:create("mysystem"). The result is ** exited: {undef,[{target_system,create,["mysystem"]}, {erl_eval,do_apply,5}, {shell,exprs,6}, {shell,eval_loop,3}]} ** =ERROR REPORT==== 16-Jan-2007::14:34:57 === Error in process <0.28.0> with exit value: {undef,[{target_system,create,["mysys tem"]},{erl_eval,do_apply,5},{shell,exprs,6},{shell,eval_loop,3}]} -------------- next part -------------- An HTML attachment was scrubbed... URL: From bengt.kleberg@REDACTED Tue Jan 16 08:53:30 2007 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Tue, 16 Jan 2007 08:53:30 +0100 Subject: [erlang-questions] Newbie~~The ERLANG/OTP V5.5.2 create a target system on WIN2003 Server In-Reply-To: <00bd01c73938$de7cef70$0701a8c0@lukeserver> References: <00bd01c73938$de7cef70$0701a8c0@lukeserver> Message-ID: <45AC847A.9050300@ericsson.com> On 2007-01-16 07:37, LUKE wrote: > Create a target system fail. ...deleted > step3: > 1> target_system:create("mysystem"). > The result is > > ** exited: {undef,[{target_system,create,["mysystem"]}, > {erl_eval,do_apply,5}, > {shell,exprs,6}, > {shell,eval_loop,3}]} ** > from the erlang shell, what does m(target_system). show? could you post the code for target_system:create/1 ? bengt -- EPO guidelines 1978: "If the contribution to the known art resides solely in a computer program then the subject matter is not patentable in whatever manner it may be presented in the claims." From thomasl_erlang@REDACTED Tue Jan 16 11:25:13 2007 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Tue, 16 Jan 2007 02:25:13 -0800 (PST) Subject: [erlang-questions] lists:reverse/1 as a built-in function In-Reply-To: <6965656B-4C1D-4E0A-BB6A-8DFC9D28B92E@zoominternet.net> Message-ID: <438343.71869.qm@web38808.mail.mud.yahoo.com> --- Robert Baruch wrote: > Personally, I'd like to decouple the "BIF problem" > from the "import > problem", like this: > > > Use Java-like package rules in Erlang, applied like > this: /.../ First of all, I'd recommend you have a look at Erlang's packages, which are fairly Java-inspired, as far as I know. > If you call example_function(Arg) anywhere else, you > need to either > call it as foo.bar.baz:example_function(Arg), or you > need to -import > (foo.bar), and then you must call it as > baz:example_function(Arg). What if example_function/1 is imported into module m and also is defined in m? If I (locally, in m) call example_function(1), which function would this proposal invoke? For example: -module(m). -compile(export_all). %% f/1 is auto-imported f(1) -> ok. g(X) -> f(X). %% which f/1 is called? So far, we have two proposals: - the auto-imported function is invoked (current compiler) - the local function is invoked (proper scoping) > The reason that I call baz the "class" name /.../ Not to sound too bad-tempered, but please don't do that :-) The Java terminology doesn't quite transplant, so it's liable to just be confusing. > /.../ That is, a BIF > is treated no differently from any other function > when it comes to name qualification. I agree with this part, which I call "proper scoping" above. Best, Thomas ____________________________________________________________________________________ Sucker-punch spam with award-winning protection. Try the free Yahoo! Mail Beta. http://advision.webevents.yahoo.com/mailbeta/features_spam.html From erlang@REDACTED Tue Jan 16 11:53:53 2007 From: erlang@REDACTED (Joe Armstrong) Date: Tue, 16 Jan 2007 11:53:53 +0100 Subject: [erlang-questions] starting and cleanly stopping erlang Message-ID: <9b08084c0701160253p697a6307j6396e6f9a05bb097@mail.gmail.com> I have written a linked-in driver - that appears to work. Let's assume it is started with myLinkedInDriver:start() and stopped with myLinkedInDriver:stop() I want to do the following. - automatically start the linked-in driver when I start Erlang - automatically stop the linked in driver when I stop Erlang I want to stop the linked in driver in a controlled manner. ie I want *something* to call myLinkedInDriver:stop() and allow me to close the thing down in an orderly manner. If my linked in driver is not correctly closed down then I'll have to do a whole lot of work the next time start the system. What the minimal amount of junk I have to use to get this behaviour? I think I need a minimum of an OTP application + a boot script + some command line arguments to erl to disable control C handling etc. Does anybody know how do do this? /Joe -------------- next part -------------- An HTML attachment was scrubbed... URL: From luke@REDACTED Tue Jan 16 12:08:47 2007 From: luke@REDACTED (LUKE) Date: Tue, 16 Jan 2007 19:08:47 +0800 Subject: [erlang-questions] Newbie~~The ERLANG/OTP V5.5.2 create a target system on WIN2003 Server References: <00bd01c73938$de7cef70$0701a8c0@lukeserver> <45AC847A.9050300@ericsson.com> Message-ID: <018001c7395e$b479aad0$0701a8c0@lukeserver> Sorry my english is ver poor. ================================================================= 2> m(target_system). =ERROR REPORT==== 16-Jan-2007::19:06:04 === Error in process <0.30.0> with exit value: {undef,[{target_system,module_info,[] },{c,m,1},{erl_eval,do_apply,5},{shell,exprs,6},{shell,eval_loop,3}]} ** exited: {undef,[{target_system,module_info,[]}, {c,m,1}, {erl_eval,do_apply,5}, {shell,exprs,6}, {shell,eval_loop,3}]} ** ================================================================= May be i did not understand why i want to create a target system. I just follow the help(System Principles) to do the job. The help say that. Step 1. First create a .rel file (see rel(4)) that specifies the erts version and lists all applications that should be included in the new basic target system. An example is the following mysystem.rel file: %% mysystem.rel {release, {"MYSYSTEM", "FIRST"}, {erts, "5.1"}, [{kernel, "2.7"}, {stdlib, "1.10"}, {sasl, "1.9.3"}, {pea, "1.0"}]}. The listed applications are not only original Erlang/OTP applications but possibly also new applications that you have written yourself (here examplified by the application pea). Step 2. From the directory where the mysystem.rel file reside, start the Erlang/OTP system: erl -pa /home/user/target_system/myapps/pea-1.0/ebin where also the path to the pea-1.0 ebin directory is provided. Step 2. Now create the target system: 1> target_system:create("mysystem"). ----- Original Message ----- From: "Bengt Kleberg" To: Sent: Tuesday, January 16, 2007 3:53 PM Subject: Re: [erlang-questions] Newbie~~The ERLANG/OTP V5.5.2 create a target system on WIN2003 Server > On 2007-01-16 07:37, LUKE wrote: >> Create a target system fail. > > ...deleted >> step3: >> 1> target_system:create("mysystem"). >> The result is >> >> ** exited: {undef,[{target_system,create,["mysystem"]}, >> {erl_eval,do_apply,5}, >> {shell,exprs,6}, >> {shell,eval_loop,3}]} ** >> > > from the erlang shell, what does m(target_system). show? > could you post the code for target_system:create/1 ? > > > bengt > -- > EPO guidelines 1978: "If the contribution to the known art resides > solely in a computer program then the subject matter is not > patentable in whatever manner it may be presented in the claims." > > > > __________ NOD32 1981 (20070116) Information __________ > > This message was checked by NOD32 antivirus system. > http://www.eset.com > -------------------------------------------------------------------------------- > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > __________ NOD32 1981 (20070116) Information __________ > > This message was checked by NOD32 antivirus system. > http://www.eset.com > From serge@REDACTED Tue Jan 16 14:13:28 2007 From: serge@REDACTED (Serge Aleynikov) Date: Tue, 16 Jan 2007 08:13:28 -0500 Subject: [erlang-questions] starting and cleanly stopping erlang In-Reply-To: <9b08084c0701160253p697a6307j6396e6f9a05bb097@mail.gmail.com> References: <9b08084c0701160253p697a6307j6396e6f9a05bb097@mail.gmail.com> Message-ID: <45ACCF78.9000101@hq.idt.net> Joe Armstrong wrote: > I have written a linked-in driver - that appears to work. Let's assume it > is started with myLinkedInDriver:start() and stopped with > myLinkedInDriver:stop() > > I want to do the following. > > - automatically start the linked-in driver when I start Erlang > - automatically stop the linked in driver when I stop Erlang > > I want to stop the linked in driver in a controlled manner. ie I want > *something* to call > myLinkedInDriver:stop() and allow me to close the thing down in an orderly > manner. > > If my linked in driver is not correctly closed down then I'll have to do a > whole lot of work > the next time start the system. > > What the minimal amount of junk I have to use to get this behaviour? > > I think I need a minimum of an OTP application + a boot script + some > command > line arguments to erl to disable control C handling etc. 1. An OTP application with a gen_server process for your driver -module(myLinkedInDriver). -export([ ..., init/1 | OtherGenServerCallbacks ]). init(Args) -> process_flag(trap_exit, true), % terminate/2 won't be called unless % you trap exit signals case erl_ddll:load_driver(Path, Name) of ok -> Port = open_port({spawn, ?MODULE}, []), % Do other initialization here ... {ok, State}; {error, Reason} -> {stop, Reason} end. ... terminate(shutdown, State) -> % do required clean up here ... ok. 2. An application module and supervisor module that starts your gen_server. (Callbacks for the two can be implemented in the same module). 3. An *.app file listing your application modules 4. A *.rel file needed to generate a boot script (use "erlc YourApp.rel" to generate a boot script) 5. If you don't plan to do an embedded system and not interested in logging, and release handling, then merely getting an emulator to start/stop your app in a controlled manner can be accomplished by: erl -noshell -detach -pa $YOUR_APP/ebin +Bi -boot $APP_NAME 6. If auto-restart of erl is needed, set the HEART_COMMAND env option, and use "-heart" command-line option at startup above. 7. An alternative (advised) way to start a node is by using run_erl (that allows to do logging of console output, gives login to the console using to_erl, and does log rotation). See: http://www.erlang.org/ml-archive/erlang-questions/200506/msg00057.html and also be careful about using -heart option of erl together with run_erl. Details and patch are here: http://www.erlang.org/ml-archive/erlang-questions/200601/msg00473.html 8. SysV startup/shutdown script that allows to start/stop the node in a controlled manner (i.e. doing shutdown via starting a remote node and issuing init:stop() using rpc or else using erl_call utility with an '-t' option that requires this patch: http://www.erlang.org/pipermail/erlang-questions/attachments/20051016/cdc432d5/erl_call.ksh ) Regards, Serge > Does anybody know how do do this? > > /Joe > > > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From autophile@REDACTED Tue Jan 16 17:50:45 2007 From: autophile@REDACTED (Robert Baruch) Date: Tue, 16 Jan 2007 11:50:45 -0500 Subject: [erlang-questions] lists:reverse/1 as a built-in function In-Reply-To: <438343.71869.qm@web38808.mail.mud.yahoo.com> References: <438343.71869.qm@web38808.mail.mud.yahoo.com> Message-ID: <14B42CF2-D393-440E-926A-32DCB16A48FC@zoominternet.net> On Jan 16, 2007, at 5:25 AM, Thomas Lindgren wrote: > > First of all, I'd recommend you have a look at > Erlang's packages, which are fairly Java-inspired, as > far as I know. Yeah, I've seen that already. It's okay, but I don't think it goes far enough. Again, it seems to me that modules are useful for grouping related functionality (such as functions about lists, or functions about strings), and so I considered a module as conceptually equivalent to a Java class with all static methods, and an Erlang package name is a way of grouping modules, just as a Java package name is a way of grouping Java classes. In Java, if you import, say, java.io.InputStream, then you would still have to refer to static InputStream methods using InputStream.method() and not just method(). Similarly, if you import java.io.*, that allows you to refer to any class X in java.io as X instead of as java.io.X. Based on that idea, -import(foo.bar.baz) where baz is a module name would allow you to use baz:function(), but should not allow you to use function(). This is the equivalent to Java's import java.io.InputStream. Also, you get the added advantage that -import(foo.bar) will allow you to access any module X in package foo.bar using X:method() instead of foo.bar.X:method(). This is the equivalent to Java's import java.io.*. > >> If you call example_function(Arg) anywhere else, you >> need to either >> call it as foo.bar.baz:example_function(Arg), or you >> need to -import >> (foo.bar), and then you must call it as >> baz:example_function(Arg). > > What if example_function/1 is imported into module m > and also is defined in m? If I (locally, in m) call > example_function(1), which function would this > proposal invoke? If example_function/1 is imported into module m, then it must be imported from some module X. Then you must call X's example_function/ 1 as X:example_function/1, and m's function would just be called as example_function/1. The names would not clash because they exist in different namespaces. > > For example: > > -module(m). > -compile(export_all). > %% f/1 is auto-imported > > f(1) -> ok. > > g(X) -> f(X). %% which f/1 is called? You could handle this in one of two ways: (1) This would be a compile-time error. At the time that you declare f (1), f/1 has already been declared because it was auto-imported. This is pretty strict, but requires the least number of compilation passes. (2) The auto-imported f/1 is not available in this module without full qualification. Thus, f(X) will always call m:f/1, and to use the "auto-imported" f/1, you have to fully qualify it (as, for example, erlang:f/1). This would require two-pass compilation, since first you have to determine the local names that are declared, then you have to resolve the calls based on the declared local names. Java doesn't really have an equivalent to this issue, because there is no global namespace for methods to pollute. All methods exist in their class's namespace, and the only auto-import done is java.lang.*, which still means you have to use X.method when calling a method in java.lang.X. > >> The reason that I call baz the "class" name /.../ > > Not to sound too bad-tempered, but please don't do > that :-) The Java terminology doesn't quite > transplant, so it's liable to just be confusing. Yeah, you're right :) I'll try to stick to "package and module" when talking about Erlang :) But just in case people are getting confused, here's my dictionary :) Java class -> Erlang module Java package -> Erlang package Java method -> Erlang function --Rob From autophile@REDACTED Tue Jan 16 18:09:27 2007 From: autophile@REDACTED (Robert Baruch) Date: Tue, 16 Jan 2007 12:09:27 -0500 Subject: [erlang-questions] lists:reverse/1 as a built-in function In-Reply-To: <438343.71869.qm@web38808.mail.mud.yahoo.com> References: <438343.71869.qm@web38808.mail.mud.yahoo.com> Message-ID: BTW, I just realized one problem with my proposal. If I have a module bar in package foo (i.e. foo/bar.erl) and a module baz in package foo.bar (i.e. foo/bar/baz.erl), you could run into problems when you try to -import(foo.bar). My proposal would not know whether this means you want to import the module bar in package foo, or all modules in package foo.bar. If you're gonna steal from Java, may as well go all the way :) The modification that would make this work is that -import(foo.bar.*) imports all modules in foo.bar, while -import(foo.bar) imports module bar from package foo. And, just like in Java, you have to add a rule to name resolution so that if you use a module name which exists in two packages, both of which you import, a compile-time error occurs -- you must fully qualify the name. Example: (assumes that you have module m in package foo.bar and in package baz) -module(myproject.my_module). -import(foo.bar.*). -import(baz.*). fun(Arg) -> m:do_it(Arg). This is a compile time error. Does m:do_it refer to foo.bar.m.do_it/1 or baz.m.do_it/1? You'd have to write either fun(Arg) -> foo.bar.m:do_it(Arg). or fun(Arg) -> baz.m:do_it(Arg). depending on which m you wanted. --Rob From thomasl_erlang@REDACTED Tue Jan 16 18:25:14 2007 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Tue, 16 Jan 2007 09:25:14 -0800 (PST) Subject: [erlang-questions] lists:reverse/1 as a built-in function In-Reply-To: <14B42CF2-D393-440E-926A-32DCB16A48FC@zoominternet.net> Message-ID: <924913.88467.qm@web38814.mail.mud.yahoo.com> --- Robert Baruch wrote: > If example_function/1 is imported into module m, > then it must be > imported from some module X. Then you must call X's > example_function/ > 1 as X:example_function/1, and m's function would > just be called as > example_function/1. The names would not clash > because they exist in > different namespaces. Well, one might think so. (I for one think the language should behave that way: local definitions hide enclosing ones with the same name.) But currently the result depends on whether example_function is explicitly imported or auto-imported. So, to recapitulate: example_function is locally defined and also imported. 1. If example_function is explicitly imported (with -import), we get a compilation error. (Apparently, this is seen as a name clash that can't be resolved.) Example: -module(test1). -compile(export_all). -import(other_m, [g/1]). f(X) -> g(X). g(X) -> X. 2. If example_function is auto-imported, we get a compiler warning, and the call will invoke the BIF, not the local function. (The name clash is resolved "the wrong way") Example: -module(test). -compile(export_all). f(X) -> element(1,X). element(A,X) -> X. (Try test:f({a}).) Best, Thomas ____________________________________________________________________________________ 8:00? 8:25? 8:40? Find a flick in no time with the Yahoo! Search movie showtime shortcut. http://tools.search.yahoo.com/shortcuts/#news From david.nospam.hopwood@REDACTED Tue Jan 16 19:14:48 2007 From: david.nospam.hopwood@REDACTED (David Hopwood) Date: Tue, 16 Jan 2007 18:14:48 +0000 Subject: [erlang-questions] lists:reverse/1 as a built-in function In-Reply-To: <924913.88467.qm@web38814.mail.mud.yahoo.com> References: <924913.88467.qm@web38814.mail.mud.yahoo.com> Message-ID: <45AD1618.7010709@blueyonder.co.uk> Thomas Lindgren wrote: > So, to recapitulate: example_function is locally > defined and also imported. > > 1. If example_function is explicitly imported (with > -import), we get a compilation error. (Apparently, > this is seen as a name clash that can't be resolved.) > > Example: > -module(test1). > -compile(export_all). > -import(other_m, [g/1]). > > f(X) -> g(X). > g(X) -> X. > > 2. If example_function is auto-imported, we get a > compiler warning, and the call will invoke the BIF, > not the local function. (The name clash is resolved > "the wrong way") At least we do get a warning. If we want to be able to change this in future, the text of the warning should be modified to explicitly say that the local function may be invoked instead in some future version of Erlang. -- David Hopwood From autophile@REDACTED Tue Jan 16 19:28:55 2007 From: autophile@REDACTED (Robert Baruch) Date: Tue, 16 Jan 2007 13:28:55 -0500 Subject: [erlang-questions] lists:reverse/1 as a built-in function In-Reply-To: <924913.88467.qm@web38814.mail.mud.yahoo.com> References: <924913.88467.qm@web38814.mail.mud.yahoo.com> Message-ID: <9B17547C-D2C8-4217-9A4A-FBDA2704B6FB@zoominternet.net> On Jan 16, 2007, at 12:25 PM, Thomas Lindgren wrote: > So, to recapitulate: example_function is locally > defined and also imported. > (...) > 2. If example_function is auto-imported, we get a > compiler warning, and the call will invoke the BIF, > not the local function. (The name clash is resolved > "the wrong way") > > Example: > -module(test). > -compile(export_all). > > f(X) -> element(1,X). > element(A,X) -> X. > > (Try test:f({a}).) > Actually, I think I had envisioned the BIF not being invoked, but rather the local function. In any case, at least there's a warning -- and if it's a warning, then no matter which way you resolve it, there's a chance the resolution didn't read the programmer's mind properly :) If you really want strict (maybe it could be a compiler option), then this would be an error. --Rob From yarivvv@REDACTED Wed Jan 17 00:20:15 2007 From: yarivvv@REDACTED (Yariv Sadan) Date: Tue, 16 Jan 2007 18:20:15 -0500 Subject: [erlang-questions] MSLUG meeting in Montreal tomorrow Message-ID: <17244f480701161520r30237cacjcf0fef71c3671faf@mail.gmail.com> Hi all, In case you haven't seen it on my blog or planeterlang.org, I will be giving a talk about ErlyWeb in the Montreal Scheme/Lisp User's Group (MSLUG) meeting at 7pm tomorrow. Here's the link: http://schemeway.dyndns.org/mslug. The talk is free and anyone who's interested is welcome to attend. Regards, Yariv From robert.virding@REDACTED Wed Jan 17 00:33:14 2007 From: robert.virding@REDACTED (Robert Virding) Date: Wed, 17 Jan 2007 00:33:14 +0100 Subject: [erlang-questions] String encoding and character set In-Reply-To: References: Message-ID: <45AD60BA.4010103@telia.com> We do actually, in fact we have something much much better, a list. Using a list you don't have to worry about encodings but can use the unicode value directly in the string/list. This makes all processing much easier. Then when you are done you can convert it to what ever encoding you want. I don't really understand why anyone would want to process data in an unnecessarily complex format instead of a simple one. Robert dda wrote: > String types ? at least well-implemented ones ? don't just store a > string, but also encoding information. They are/should be geared > towards pain-free manipulation of text data, and by text I mean things > outside ASCII-land. Encodings-aware string manipulation functions > don't function on bytes, but on characters, a quite different notion. > We don't have this in Erlang. > From lcoquelle@REDACTED Wed Jan 17 01:59:51 2007 From: lcoquelle@REDACTED (Ludovic Coquelle) Date: Wed, 17 Jan 2007 08:59:51 +0800 Subject: [erlang-questions] String encoding and character set In-Reply-To: <45AD60BA.4010103@telia.com> References: <45AD60BA.4010103@telia.com> Message-ID: My guess is that with a string format you can access the nth character of the message by its position, which can be very difficult to do with a list if the encoding support different size for different characters (and sometimes the same character can have different encoding depending of previous ones: contextual encoding) ... I guess the string type abstract all that, but list is enough encoding like ASCII, UTF8. So two questions: (1) am I clear? (2) if yes, am I right? ;) On 1/17/07, Robert Virding wrote: > > We do actually, in fact we have something much much better, a list. > Using a list you don't have to worry about encodings but can use the > unicode value directly in the string/list. This makes all processing > much easier. Then when you are done you can convert it to what ever > encoding you want. > > I don't really understand why anyone would want to process data in an > unnecessarily complex format instead of a simple one. > > Robert > > dda wrote: > > String types ? at least well-implemented ones ? don't just store a > > string, but also encoding information. They are/should be geared > > towards pain-free manipulation of text data, and by text I mean things > > outside ASCII-land. Encodings-aware string manipulation functions > > don't function on bytes, but on characters, a quite different notion. > > We don't have this in Erlang. > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From headspin@REDACTED Wed Jan 17 02:07:04 2007 From: headspin@REDACTED (dda) Date: Wed, 17 Jan 2007 02:07:04 +0100 Subject: [erlang-questions] Fwd: String encoding and character set In-Reply-To: References: <45AD60BA.4010103@telia.com> Message-ID: Nope. Let's take for instance a utf-8 string. As an Erlang list, there's no way, in the language, to extract safely one character or more from the string. You cannot extract, in say "?????ISO????? ?? ??." [that's Korean if you're wondering] the 6th to 11th characters ? ISO??? ? without doing more contorsions than a circus artist. A list is not a string, it's raw data left for us to muck with. -- dda On 1/17/07, Robert Virding wrote: > We do actually, in fact we have something much much better, a list. > Using a list you don't have to worry about encodings but can use the > unicode value directly in the string/list. This makes all processing > much easier. Then when you are done you can convert it to what ever > encoding you want. > > I don't really understand why anyone would want to process data in an > unnecessarily complex format instead of a simple one. > > Robert > > dda wrote: > > String types ? at least well-implemented ones ? don't just store a > > string, but also encoding information. They are/should be geared > > towards pain-free manipulation of text data, and by text I mean things > > outside ASCII-land. Encodings-aware string manipulation functions > > don't function on bytes, but on characters, a quite different notion. > > We don't have this in Erlang. From bob@REDACTED Wed Jan 17 02:28:35 2007 From: bob@REDACTED (Bob Ippolito) Date: Tue, 16 Jan 2007 17:28:35 -0800 Subject: [erlang-questions] Fwd: String encoding and character set In-Reply-To: References: <45AD60BA.4010103@telia.com> Message-ID: <6a36e7290701161728r37693ca7u8bbdd9eb28e9e1@mail.gmail.com> Robert is recommending that text should be dealt with in UCS-4, where characters and list items are the same thing. Other encodings should be dealt with at IO boundaries. -bob On 1/16/07, dda wrote: > Nope. Let's take for instance a utf-8 string. As an Erlang list, > there's no way, in the language, to extract safely one character or > more from the string. You cannot extract, in say "?????ISO????? ?? > ??." [that's Korean if you're wondering] the 6th to 11th characters ? > ISO??? ? without doing more contorsions than a circus artist. A list > is not a string, it's raw data left for us to muck with. > > -- > dda > > On 1/17/07, Robert Virding wrote: > > We do actually, in fact we have something much much better, a list. > > Using a list you don't have to worry about encodings but can use the > > unicode value directly in the string/list. This makes all processing > > much easier. Then when you are done you can convert it to what ever > > encoding you want. > > > > I don't really understand why anyone would want to process data in an > > unnecessarily complex format instead of a simple one. > > > > Robert > > > > dda wrote: > > > String types ? at least well-implemented ones ? don't just store a > > > string, but also encoding information. They are/should be geared > > > towards pain-free manipulation of text data, and by text I mean things > > > outside ASCII-land. Encodings-aware string manipulation functions > > > don't function on bytes, but on characters, a quite different notion. > > > We don't have this in Erlang. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From dominique.boucher@REDACTED Wed Jan 17 02:31:34 2007 From: dominique.boucher@REDACTED (Dominique Boucher) Date: Tue, 16 Jan 2007 20:31:34 -0500 Subject: [erlang-questions] MSLUG meeting in Montreal tomorrow In-Reply-To: <17244f480701161520r30237cacjcf0fef71c3671faf@mail.gmail.com> References: <17244f480701161520r30237cacjcf0fef71c3671faf@mail.gmail.com> Message-ID: <001301c739d7$3f4f1e10$a081a8c0@lelouch> And even though it is mainly a Scheme/Lisp user group, the web site is Erlang/Yaws-powered! ;-) But it does not use ErlyWeb... yet ;-( Dominique -----Original Message----- From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Yariv Sadan Sent: January 16, 2007 6:20 PM To: erlang-questions Subject: [erlang-questions] MSLUG meeting in Montreal tomorrow Hi all, In case you haven't seen it on my blog or planeterlang.org, I will be giving a talk about ErlyWeb in the Montreal Scheme/Lisp User's Group (MSLUG) meeting at 7pm tomorrow. Here's the link: http://schemeway.dyndns.org/mslug. The talk is free and anyone who's interested is welcome to attend. Regards, Yariv _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions From rlenglet@REDACTED Wed Jan 17 02:36:45 2007 From: rlenglet@REDACTED (Romain Lenglet) Date: Wed, 17 Jan 2007 10:36:45 +0900 Subject: [erlang-questions] Fwd: String encoding and character set In-Reply-To: References: <45AD60BA.4010103@telia.com> Message-ID: <45AD7DAC.8060009@users.forge.objectweb.org> As Robert explained, the current convention for representing strings in Erlang is a flat list of Unicode code-points as integers. Every element in such a list is a character, represented by its Unicode code-point integer value. The 11th character of a string is the 11th element in the list. If you want to encode such a string, you are free to do so, and that is relatively easy. But the current convention is to represent strings *unencoded*, as such lists of Unicode code points. One drawback with this convention is that the standard external representation is inefficient (e.g. when you send a term in an Erlang message) for strings containing characters which code-point is > 255. Please read the long discussion that we had last summer: http://www.erlang.org/pipermail/erlang-questions/2006-June/021168.html http://www.erlang.org/pipermail/erlang-questions/2006-June/021214.html http://www.erlang.org/pipermail/erlang-questions/2006-June/021215.html etc. etc. dda wrote: > Nope. Let's take for instance a utf-8 string. As an Erlang list, > there's no way, in the language, to extract safely one character or > more from the string. You cannot extract, in say "?????ISO????? ?? > ??." [that's Korean if you're wondering] the 6th to 11th characters ? > ISO??? ? without doing more contorsions than a circus artist. A list > is not a string, it's raw data left for us to muck with. > > -- > dda > > On 1/17/07, Robert Virding wrote: >> We do actually, in fact we have something much much better, a list. >> Using a list you don't have to worry about encodings but can use the >> unicode value directly in the string/list. This makes all processing >> much easier. Then when you are done you can convert it to what ever >> encoding you want. >> >> I don't really understand why anyone would want to process data in an >> unnecessarily complex format instead of a simple one. >> >> Robert >> >> dda wrote: >>> String types ? at least well-implemented ones ? don't just store a >>> string, but also encoding information. They are/should be geared >>> towards pain-free manipulation of text data, and by text I mean things >>> outside ASCII-land. Encodings-aware string manipulation functions >>> don't function on bytes, but on characters, a quite different notion. >>> We don't have this in Erlang. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From lcoquelle@REDACTED Wed Jan 17 02:50:49 2007 From: lcoquelle@REDACTED (Ludovic Coquelle) Date: Wed, 17 Jan 2007 09:50:49 +0800 Subject: [erlang-questions] build system Message-ID: Hi, I'm currently working on my first OTP application, and still wondering about the good build system to use. Anything which is part of the Erlang/OTP distribution? (would be good to avoid dependency to external build tool) I can use the Emakefile, but I don't see how to: (1) build the boot script, (2) deals automaticaly with version (3) other? I have googlelized and found different tools: * as I target a Linux machine, I could use a 'normal' make * builder from Jungerl (same as included in tsung distribution? [ https://svn.process-one.net/tsung/trunk/priv/builder.erl]) * erlware [http://www.erlware.org/] * sinan [http://code.google.com/p/sinan/] (which lack a bit of documentation...) * erlIDE for Eclipse [http://erlide.sourceforge.net/] What are you using guys? Any suggestion? -------------- next part -------------- An HTML attachment was scrubbed... URL: From cyberlync@REDACTED Wed Jan 17 03:23:28 2007 From: cyberlync@REDACTED (Eric Merritt) Date: Tue, 16 Jan 2007 18:23:28 -0800 Subject: [erlang-questions] build system In-Reply-To: References: Message-ID: On 1/16/07, Ludovic Coquelle wrote: > Hi, > I'm currently working on my first OTP application, and still wondering about > the good build system to use. > > Anything which is part of the Erlang/OTP distribution? There isn't anything like a build system in the actual distribution. > (would be good to > avoid dependency to external build tool) > I can use the Emakefile, but I don't see how to: (1) build the boot script, > (2) deals automaticaly with version (3) other? Emakefile works but its just like make and no more. If you are comfortable with make it will work fine. > > I have googlelized and found different tools: > * as I target a Linux machine, I could use a 'normal' make > * builder from Jungerl (same as included in tsung distribution? Builder isn't a build system it just builds releases. So its not an option. > [https://svn.process-one.net/tsung/trunk/priv/builder.erl]) > * erlware [ http://www.erlware.org/] Erlware has been around for awhile and it works well. Its oriented towards otp apps and that may be a factor to consider. > * sinan [http://code.google.com/p/sinan/] (which lack a bit of > documentation...) This is my project. It lacks documentation because it isn't yet complete. Its a ground up rewrite of a working build system that I use. It simplifies a lot of the complexities of the earlier build system and I think it will be well received when its done. I am rather proud of it, but it wont be usable for a week or so (dependency handling rewrite is taking longer then I imagined). > * erlIDE for Eclipse [ http://erlide.sourceforge.net/] This isn't a build system either, its an IDE. > > What are you using guys? Any suggestion? The only choices available right now is Emakefile, make and erlware. Erlware requires otp apps but you would need to do that anyway before you wrote anything significant. Sinan requires otp apps as well, but its not ready for consumption yet. From toby@REDACTED Wed Jan 17 03:33:53 2007 From: toby@REDACTED (Toby Thain) Date: Wed, 17 Jan 2007 00:33:53 -0200 Subject: [erlang-questions] build system In-Reply-To: References: Message-ID: <4BDCFFF2-8E19-4BD2-8BE8-73ABBA1946D9@smartgames.ca> On 16-Jan-07, at 11:50 PM, Ludovic Coquelle wrote: > Hi, > I'm currently working on my first OTP application, and still > wondering about the good build system to use. > > Anything which is part of the Erlang/OTP distribution? (would be > good to avoid dependency to external build tool) > I can use the Emakefile, but I don't see how to: (1) build the boot > script, (2) deals automaticaly with version (3) other? > > I have googlelized and found different tools: > * as I target a Linux machine, I could use a 'normal' make That's what I did: http://www.telegraphics.com.au/svn/ettt/trunk/ > * builder from Jungerl (same as included in tsung distribution? > [https://svn.process-one.net/tsung/trunk/priv/builder.erl]) > * erlware [ http://www.erlware.org/] > * sinan [http://code.google.com/p/sinan/] (which lack a bit of > documentation...) > * erlIDE for Eclipse [ http://erlide.sourceforge.net/] > > What are you using guys? Any suggestion? > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From ok@REDACTED Wed Jan 17 05:38:17 2007 From: ok@REDACTED (Richard A. O'Keefe) Date: Wed, 17 Jan 2007 17:38:17 +1300 (NZDT) Subject: [erlang-questions] lists:reverse/1 as a built-in function Message-ID: <200701170438.l0H4cHOp145653@atlas.otago.ac.nz> Just because something is a core part of the language doesn't mean I always want it. I believe that (1) Infix and prefix operator syntax should simply be an alternative way of writing an ordinary function call, so that X+1 and '+'(X,1) should be exactly the same thing. (2) There should be three mutually exclusive ways to make a function available for calling without a prefix: (a) define it in the module (b) explicitly import it from some module (c) obtain it from erlang: if neither (a) nor (b) applies. This means that adding new functions to erlang: cannot break working code because working code would have to do (a) or (b). (3) Imitating Java and especially imitating Java's inside-out packages is a Bad Thing. From ok@REDACTED Wed Jan 17 05:56:31 2007 From: ok@REDACTED (Richard A. O'Keefe) Date: Wed, 17 Jan 2007 17:56:31 +1300 (NZDT) Subject: [erlang-questions] String encoding and character set Message-ID: <200701170456.l0H4uVee145774@atlas.otago.ac.nz> "Ludovic Coquelle" wrote: My guess is that with a string format you can access the nth character of the message by its position, which can be very difficult to do with a list if the encoding support different size for different characters (and sometimes the same character can have different encoding depending of previous ones: contextual encoding) ... Note that Unicode has "floating diacriticals" AND it has a number of "precomposed characters". Floating diacriticals means user_character --> base_character floating_diacritical* (where a floating_diacritical could be "dot below" or "accent grave above" amongst many possibilities). Precomposed characters means that a large number of base_character+floating_diacritical combinations are also assigned single code points. For example, e-acute could be one code-point (identical to the Latin-1 value) or two (base e, ' diacritical). There is in fact no theoretical limit to the number or kind of floating diacritical accents that may be added to any base. So in Unicode, "access(ing) the nth character ... by its position" is not only ambiguous (do you mean "characters" or "code points") but essentially useless. You might pick up an "e", but it is _really_ just the first part of e-acute. The fundamental operations on strings are (1) decode binary to string using some encoding (2) encode string to binary using some encoding (3) compare using locale- and application-appropriate rules (4) parse, typically using regular expressions (5) unparse The combination {Encoding_Name_Atom,Binary} can *be* a string if you really want. From jahakala@REDACTED Wed Jan 17 06:28:23 2007 From: jahakala@REDACTED (Jani Hakala) Date: Wed, 17 Jan 2007 07:28:23 +0200 Subject: [erlang-questions] String encoding and character set In-Reply-To: <200701170456.l0H4uVee145774@atlas.otago.ac.nz> (Richard A. O'Keefe's message of "Wed\, 17 Jan 2007 17\:56\:31 +1300 \(NZDT\)") References: <200701170456.l0H4uVee145774@atlas.otago.ac.nz> Message-ID: <87y7o2b4so.fsf@pingviini.kortex.jyu.fi> "Richard A. O'Keefe" writes: > > So in Unicode, "access(ing) the nth character ... by its position" is > not only ambiguous (do you mean "characters" or "code points") but > essentially useless. You might pick up an "e", but it is _really_ just > the first part of e-acute. > Accessing the nth glyph in case of unicode string shouldn't be ambiguous? If there was a glyph type in erlang it would be possible to have a list of glyphs and accessing the nth glyph should be possible. Jani Hakala From surindar.shanthi@REDACTED Wed Jan 17 06:30:23 2007 From: surindar.shanthi@REDACTED (Surindar Sivanesan) Date: Wed, 17 Jan 2007 11:00:23 +0530 Subject: [erlang-questions] TCP/IP socket communication problem In-Reply-To: <9b08084c0701160219w5d127c04ra3b10c5712e55655@mail.gmail.com> References: <42ea5fb60701140423hce29757he94da59afc15f362@mail.gmail.com> <9b08084c0701160219w5d127c04ra3b10c5712e55655@mail.gmail.com> Message-ID: <42ea5fb60701162130n5c8dafc2m7c61b44a15695dcc@mail.gmail.com> Dear Joe, The application is a huge one and could not be sent through mail. So, I have pasted the part of the code where I face error... server_connection(ListeningSocket)-> ConnectionResult=gen_tcp:accept(ListeningSocket), case ConnectionResult of {ok,AcceptedSocket}-> spawn(identify_client,receive_request,[ConnectionResult]), server_connection(ListeningSocket); {error,Reason}-> io:fwrite("Reason for error in accepting socket is ~p\n",[Reason]); ListenResult=gen_tcp:listen(get(port),[list,{backlog,210},{packet, 0},{active, false}]), case ListenResult of {ok,ListenSocket1}-> server_connection(ListenSocket1); {error,Reason1}-> io:fwrite("Reason for error in second listen is ~p\n",[Reason1]); _-> io:fwrite("Some other error in listening in server_connection1\n") end _-> io:fwrite("Some other error in listening in server_connection2\n") end. This server_connection function continues to listen in the 'ListeningSocket' provided by a parent module. If any client is connecting, this function will spawn a process with that socket to receive the messages from the client. Like wise, 50 clients have established communication and the messages are transmitted to and fro. At some point of time, the gen_tcp:accept/1 function returns {error,enfile} and all the 50 client server communication are closed. When the server_connection function tends to listen socket again using gen_tcp:listen/2, again an error is occurred. Please let me know if you find any clue regarding this problem. Regards, S.Surindar. On 1/16/07, Joe Armstrong wrote: > > You have not sent any code, it is impossible to answer your question if > you have > don't send the code that you suspect is not working correctly. > > If you post the code then we can try running in on a different OS > to see if we can reproduce the problem. > > /Joe > > > On 1/14/07, Surindar Sivanesan < surindar.shanthi@REDACTED > wrote: > > > Dear all, > > > > We are using an application in erlang which is acting as a server. This > > server is continuously listening and ready to accept any client in TCP/IP > > communication. > > Around *50 clients* connecting with this server application. This > > application is working fine for some time. > > At one point of time, while the server is accepting a communication > > using the BIF *gen_tcp:accept/1*, *{error,enfile}* error is occurred and > > *all the 50 clients using that socket are disconnected abruptly*. > > We are using Windows 2003 server OS and Erlang *ERTS **5.5*. > > > > Please provide me the solution if any to solve this problem > > > > Thanks in advance > > > > -- > > with regards, > > S.Surindar > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > > > -- with regards, S.Surindar -------------- next part -------------- An HTML attachment was scrubbed... URL: From avindev@REDACTED Wed Jan 17 06:43:50 2007 From: avindev@REDACTED (Arbow) Date: Wed, 17 Jan 2007 13:43:50 +0800 Subject: [erlang-questions] cean site quite slow, why? Message-ID: In these days, I found install modules from cean quite slow, some modules large than 100k, will be request timeout: Install "asn1" error: req_timedout Install "btt" error: req_timedout Install "cosNotification" error: req_timedout error: req_timedout Install "dialyzer" ... Any way, cean site seems not updated for a long time, does anyone know the progress about it's development ? From ok@REDACTED Wed Jan 17 07:19:36 2007 From: ok@REDACTED (Richard A. O'Keefe) Date: Wed, 17 Jan 2007 19:19:36 +1300 (NZDT) Subject: [erlang-questions] String encoding and character set Message-ID: <200701170619.l0H6JaK1145096@atlas.otago.ac.nz> I wrote: > So in Unicode, "access(ing) the nth character ... by its position" is > not only ambiguous (do you mean "characters" or "code points") but > essentially useless. Jani Hakala seems to wish for an ideal world: Accessing the nth glyph in case of unicode string shouldn't be ambiguous? I didn't say "glyph" (which is in any case a rendering concept, *NOT* a Unicode concept), I said "character". If there was a glyph type in erlang it would be possible to have a list of glyphs and accessing the nth glyph should be possible. There *is* a type in Erlang which can be (and is) used for Unicode >>codepoints<<, and that is 'integer'. I have no idea what you mean by 'glyph'. I repeat the point I made before: a *single* logical text unit as far as some user is concerned might be *many* Unicode codepoints, and might moreover be expressed as more than one sequence of codepoints. I know of several Unicode characters that can be encoded in three different ways, and if memory serves me I once found one that could be encoded in five. If glpyh=codepoint, then a tuple of integers gives us O(1) indexing. If glpyh=base + diacriticals, there is *NO* programming language that has a string type that gives us O(1) indexing. From dmitriid@REDACTED Wed Jan 17 11:23:04 2007 From: dmitriid@REDACTED (Dmitrii 'Mamut' Dimandt) Date: Wed, 17 Jan 2007 12:23:04 +0200 Subject: [erlang-questions] Fwd: String encoding and character set In-Reply-To: <45AD7DAC.8060009@users.forge.objectweb.org> References: <45AD60BA.4010103@telia.com> <45AD7DAC.8060009@users.forge.objectweb.org> Message-ID: <45ADF908.6050904@gmail.com> Do list_to_binary/binary_to_list preserve codepoints? That is, does L1 = binary_to_list(list_to_binary(L2)) imply that L1 = L2? If not, then we loose an effective way of sending strings as binary Romain Lenglet wrote: > As Robert explained, the current convention for representing strings in > Erlang is a flat list of Unicode code-points as integers. Every element > in such a list is a character, represented by its Unicode code-point > integer value. The 11th character of a string is the 11th element in the > list. If you want to encode such a string, you are free to do so, and > that is relatively easy. But the current convention is to represent > strings *unencoded*, as such lists of Unicode code points. > From alex.arnon@REDACTED Wed Jan 17 14:32:31 2007 From: alex.arnon@REDACTED (Alex Arnon) Date: Wed, 17 Jan 2007 15:32:31 +0200 Subject: [erlang-questions] Fwd: String encoding and character set In-Reply-To: <45ADF908.6050904@gmail.com> References: <45AD60BA.4010103@telia.com> <45AD7DAC.8060009@users.forge.objectweb.org> <45ADF908.6050904@gmail.com> Message-ID: <944da41d0701170532g7aadbe18p5976686b84260438@mail.gmail.com> No they do not - the list is expected to contain byte values. On 1/17/07, Dmitrii 'Mamut' Dimandt wrote: > > Do list_to_binary/binary_to_list preserve codepoints? That is, does L1 = > binary_to_list(list_to_binary(L2)) imply that L1 = L2? If not, then we loose > an effective way of sending strings as binary > > > Romain Lenglet wrote: > > As Robert explained, the current convention for representing strings in > > Erlang is a flat list of Unicode code-points as integers. Every element > > in such a list is a character, represented by its Unicode code-point > > integer value. The 11th character of a string is the 11th element in the > > list. If you want to encode such a string, you are free to do so, and > > that is relatively easy. But the current convention is to represent > > strings *unencoded*, as such lists of Unicode code points. > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From xpdoka@REDACTED Wed Jan 17 14:48:01 2007 From: xpdoka@REDACTED (Dominic Williams) Date: Wed, 17 Jan 2007 14:48:01 +0100 (CET) Subject: [erlang-questions] Fwd: String encoding and character set In-Reply-To: <944da41d0701170532g7aadbe18p5976686b84260438@mail.gmail.com> References: <45AD60BA.4010103@telia.com> <45AD7DAC.8060009@users.forge.objectweb.org> <45ADF908.6050904@gmail.com> <944da41d0701170532g7aadbe18p5976686b84260438@mail.gmail.com> Message-ID: <21804.217.128.75.198.1169041681.squirrel@www.geekisp.com> > No they do not - the list is expected to contain byte values. Indeed, but term_to_binary and back works fine. Regards, Dominic Williams http://www.dominicwilliams.net ---- From icfp.publicity@REDACTED Wed Jan 17 23:02:09 2007 From: icfp.publicity@REDACTED (Matthew Fluet (ICFP Publicity Chair)) Date: Wed, 17 Jan 2007 16:02:09 -0600 Subject: [erlang-questions] ICFP07 Call for Papers Message-ID: <53ff55480701171402t3b2c7202r601ee7433613c91c@mail.gmail.com> Call for Papers ICFP 2007: International Conference on Functional Programming Freiburg, Germany, 1-3 October 2007 ICFP 2007 seeks original papers on the art and science of functional programming. Submissions are invited on all topics from principles to practice, from foundations to features, from abstraction to application. The scope includes all languages that encourage functional programming, including both purely applicative and imperative languages, as well as languages with objects and concurrency. Particular topics of interest include * Applications and domain-specific languages: systems programming; scientific and numerical computing; symbolic computing; artificial intelligence; databases; graphical user interfaces; multimedia programming; scripting; system administration; distributed-systems and web programming; XML processing; security * Foundations: formal semantics; lambda calculus; type theory; monads; continuations; control; state; effects * Design: algorithms and data structures; modules; type systems; concurrency and distribution; components and composition; relations to object-oriented or logic programming * Implementation: abstract machines; compile-time and run-time optimization; just-in-time compilers; memory management; parallel hardware; interfaces to foreign functions, services, components or low-level machine resources * Transformation and analysis: abstract interpretation; partial evaluation; program transformation * Software-development techniques: design patterns; specification; verification; validation; debugging; test generation; tracing; profiling * Practice and experience: novel results drawn from experience in education or industry * Functional pearls: elegant, instructive examples of functional programming A functional pearl need not report original research results, but it must be instructive, elegant, and fun. ICFP 2007 also seeks Experience Reports. An Experience Report is a short paper (2-4 pages) which need not present novel results, but which should provide evidence that functional programming really works or should describe obstacles that prevented it from working. Detailed guidelines appear below. What's new this year? ~~~~~~~~~~~~~~~~~~~~~ Experienced ICFP authors may want to pay special attention to the points below, which are new this year. * Double-blind review * Author-date citations * Supplemental material in a separate document, not appended to the main text * Morning deadline (but equivalent to late afternoon or early evening in many time zones of interest) * Experience Reports Instructions for authors ~~~~~~~~~~~~~~~~~~~~~~~~ By 11:00 AM Friday, 6 April 2007, Samoan time, submit an abstract of at most 300 words and a full paper of at most 12 pages or an Experience Report of at most 4 pages. Submissions will be accepted electronically, at a URL to be named later. The deadline is set at Samoan time, so if your submission is in by 11:00 AM Friday according to your local time, wherever you are, the submission will be on time. The world clock at http://www.timeanddate.com/worldclock/fixedtime.html?month=4&day=6&year=2007&hour=11&min=0&sec=0&p1=282 can give you the equivalent in your local time, e.g., 3:00 PM Friday in Portland, 6:00 PM Friday in Boston, and midnight Friday in Freiburg. The deadline is firm. Your submission should explain its contributions in both general and technical terms, clearly identifying what has been accomplished, explaining why it is significant, and comparing it with previous work. Make the technical content understandable to a broad audience. Each submission must adhere to SIGPLAN's republication policy, which appears in full at http://www.acm.org/sigplan/republicationpolicy.htm. The policy means in part that your paper may not have already appeared in a journal, conference, or workshop with published proceedings; that you may not submit substantially the same work simultaneously to ICFP and to another venue; and that your submission must discuss any closely related material, including your own, that was previously accepted at a journal, conference, or workshop with or without published proceedings. Full details of the policy are available at the SIGPLAN site. If you are in any doubt about whether this policy applies to your paper, either consult the program chair in advance or notify the chair when you submit. To do otherwise risks summary rejection of your submission. If your submission is accepted, you must assign copyright to ACM. Proceedings will be published by the ACM Press. Double-blind review ~~~~~~~~~~~~~~~~~~~ To increase confidence in the fairness and objectivity of the reviewing process, reviewing will be double blind. Make it possible for reviewers to evaluate your paper without having to know who you are. It should suffice to omit your names from your submission and to avoid revealing your identity through citation; detailed guidelines are available at http://icfp07.eecs.harvard.edu/blind.html. Formatting ~~~~~~~~~~ Your submission must be printable on US Letter sized paper and be either PDF or PostScript that is interpretable by Ghostscript. If this requirement is a hardship, make contact with the program chair at least one week before the deadline. Your submission must be at most 12 pages (4 pages for an Experience Report), including bibliography and figures, in the standard ACM conference format: two columns, nine-point font on a ten-point baseline, with pages 20pc (3.33in) wide and 54pc (9in) tall, with a column gutter of 2pc (0.33in). (A suitable LaTeX class file is available from SIGPLAN; see http://www.acm.org/sigs/sigplan/authorInformation.htm. Categories, keywords, and so on are optional.) If you wish to supply material beyond the 12-page limit, up to and including a full technical report, you may attach a separate document to your submission, on the understanding that reviewers are not expected to read it. (As a particular example, if you feel that your submission should be supported by a lengthy technical report, do not cite such a technical report on the web, since doing so would reveal your identity. Please instead attach that report to your submission.) Detailed instructions for attaching supplementary documents will be available on the submission web site. The length limit is firm; submissions that do not meet these guidelines will not be considered. Citation ~~~~~~~~ We recommend (but do not require) that you put your citations into author-date form. This procedure makes your paper easier to review. For example, if you cite a result on testing as ``(Claessen and Hughes 2000)'', many reviewers will recognize the result instantly. On the other hand, if you cite it as ``[4]'', even the best-informed reviewer has to page through your paper to find the reference. By using author-date form, you enable a knowledgeable reviewer to focus on content, not arbitrary numbering of references. LaTeX users can simply use the natbib package along with the plainnat bibliography style. Author response ~~~~~~~~~~~~~~~ You will have a 48-hour period (11:00 23 May to 11:00 25 May 2007 Samoa time) to read and respond to reviews. Details of the author-response process will be available as it approaches. Special categories of papers ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In addition to research papers, ICFP solicits two kinds of papers that do not require original research contributions: functional pearls, which are full papers, and Experience Reports, which are limited to four pages. Authors submitting such papers may wish to consider the following advice. Functional pearls ~~~~~~~~~~~~~~~~~ To paraphrase both Jon Bentley and Richard Bird, the ideal pearl goes beyond solid engineering into the realm of insight and creativity. Just as a natural pearl grows from a grain of sand that has irritated an oyster, a topnotch functional pearl should grow from a real problem that has irritated a programmer. A pearl should be polished, elegant, instructive, and entertaining. Ideally it should teach important programming techniques and fundamental design principles. Past pearls have included instructive examples of program calculation or proof, nifty presentations of old or new data structures, and interesting applications and programming techniques. Papers submitted to ICFP as pearls often miss the mark, by being too trivial, too complicated, or somehow not quite the elegant solution one hopes for. The key to an accepted pearl is polishing. Your pearl is likely to be rejected if your readers get bored, if the material gets too complicated, if too much specialized knowledge is needed, or if the writing is distasteful. Richard Bird advises: * Throw away the rule book for writing research papers. * Get in quick; get out quick. * Be self-contained; don't go deep into related work, with lengthy references. * You are telling a story, so some element of surprise is welcome. * Above all, be engaging. * Give a talk on the pearl to non-specialists, your students, or your department. If you changed the order of presentation for the talk, consider using the new order in the next draft. * Put the pearl away for a while, then take it out and polish it again. Experience reports ~~~~~~~~~~~~~~~~~~ ICFP has long solicited submissions on the practice and experience of functional programming. But reports of experience are inherently different from research papers, and when judged by the criteria of scientific merit, novelty, or research contribution, they have not competed well against traditional ICFP submissions. Yet we believe that the functional- programming community would benefit from being able to draw on and cite the experience of others. For this reason, we have introduced the ICFP Experience Report. Unlike a normal ICFP paper, the purpose of an Experience Report is not to add to the body of knowledge of the functional-programming community. Rather, the purpose of an Experience Report is to help create a body of published, refereed, citable *evidence* that functional programming really works---or to describe obstacles that prevented it from working. An Experience Report is distinguished from a normal ICFP paper by its title, by its length, and by the criteria used to evaluate it. * Both in the proceedings and in any citations, the title of each accepted Experience Report must begin with the words "Experience Report", followed by a colon. * Experience Reports are limited in length: the suggested length is 2 pages and the maximum length is 4 pages. Each accepted Experience Report will be presented at the conference, but depending on the number of Experience Reports and regular papers accepted, authors of Experience Reports may be asked to give shorter talks. * Because the purpose of Experience Reports is to enable our community to accumulate a published, citable body of evidence about the efficacy of functional programming, an acceptable Experience Report need not present novel results or conclusions. It is sufficient if the Report states a clear thesis and provides supporting evidence. The thesis must be relevant to ICFP, but it need not be novel. The program committee will accept or reject Experience Reports based on whether they judge the evidence to be convincing. Anecdotal evidence will be acceptable provided it is well argued and the author explains what efforts were made to gather as much evidence as possible. The committee will be especially convinced by evidence that includes *comparisons* of situations before and after the introduction or discontinuation of functional programming. Evidence drawn from a single person's experience may be sufficient, but more weight will be given to evidence drawn from the experience of groups of people. Possible topics for an Experience Report include, but are not limited to * Insights gained from real-world projects using functional programming * Comparison of functional programming with conventional programming in the context of an industrial project or a university curriculum * Project-management, business, or legal issues encountered when using functional programming in a real-world project * Curricular issues encountered when using functional programming in education * Real-world constraints that created special challenges for an implementation of a functional language or for functional programming in general An Experience Report should be short and to the point: if functional programming worked for you in the same ways it has worked for others, you need only to summarize the results---the main part of your paper should discuss how well it worked and in what context. Most readers will not want to know all the details of your project and its implementation, but please characterize your project and its context well enough so that readers can judge to what degree your experience is relevant to their own projects. Be especially careful to highlight any unusual aspects of your project. Also keep in mind that specifics about your project are more valuable than generalities about functional programming; for example, it is more valuable to say that your team delivered its software a month ahead of schedule than it is to say that functional programming made your team more productive. If your paper not only describes experience but also presents new technical results, or if your experience refutes cherished beliefs of the functional-programming community, you may be better off submitting it as a full paper, which will be judged by the usual criteria of novelty, originality, and relevance. If you unsure in which category to submit, the program chair will be happy to help you decide. Other information ~~~~~~~~~~~~~~~~~ Conference Chair ~~~~~~~~~~~~~~~~ Ralf Hinze (Universit?t Bonn) Program Chair ~~~~~~~~~~~~~ Norman Ramsey Harvard University Cambridge, MA, 02148 USA Email: icfp07@REDACTED Phone: +1 617 496 8615 Mail sent to the address above is filtered for spam. If you send mail and do not receive a prompt response, particularly if the deadline is looming, feel free to telephone and reverse the charges. Program Committee ~~~~~~~~~~~~~~~~~ Nick Benton (Microsoft Research) Matthew Fluet (Toyota Technological Institute) Jeremy Gibbons (University of Oxford) Kevin Hammond (University of St Andrews) Bastiaan Heeren (Utrecht University) Graham Hutton (University of Nottingham) Mark P. Jones (Portland State University) Gabriele Keller (University of New South Wales) Fabrice Le Fessant (INRIA/LIX, France) Todd Millstein (UCLA) Mike Sperber (DeinProgramm) Christopher A. Stone (Harvey Mudd College) Andrew Tolmach (Portland State University and INRIA Rocquencourt) Janis Voigtl?nder (Technische Universit?t Dresden) Stephanie Weirich (University of Pennsylvania) Important Dates ~~~~~~~~~~~~~~~ Submission: 11:00 6 April 2007, Samoa time (AST) Author response: 11:00 23 May to 11:00 25 May 2007 (AST) Notification: 8 June 2007 Final papers due: 20 July 2007 ICFP 2007 Web Site ~~~~~~~~~~~~~~~~~~ http://www.informatik.uni-bonn.de/~ralf/icfp07.html Special Issue of JFP ~~~~~~~~~~~~~~~~~~~~ Authors of the best final papers, as determined by the program committee, will be invited to submit journal versions for a special issue of the Journal of Functional Programming. From autophile@REDACTED Wed Jan 17 23:14:41 2007 From: autophile@REDACTED (autophile) Date: Wed, 17 Jan 2007 22:14:41 +0000 Subject: [erlang-questions] Why ~n instead of n? References: Message-ID: <20070117221441.902555A1F9@mail.erlangsystems.com> Does anyone know why there is a ~n in the io:fwrite format when n seems to work just as well? Is it there for historical reasons? Am I committing a sin by using n and could lightning strike my program dead under some obscure circumstance? Thanks, --Rob _________________________________________________________ Post sent from http://www.trapexit.org From erlangx@REDACTED Wed Jan 17 23:20:40 2007 From: erlangx@REDACTED (Michael McDaniel) Date: Wed, 17 Jan 2007 14:20:40 -0800 Subject: [erlang-questions] Why ~n instead of n? In-Reply-To: <20070117221441.902555A1F9@mail.erlangsystems.com> References: <20070117221441.902555A1F9@mail.erlangsystems.com> Message-ID: <20070117222040.GD2665@delora.autosys.us> On Wed, Jan 17, 2007 at 10:14:41PM +0000, autophile wrote: > > Does anyone know why there is a ~n in the io:fwrite format when n seems to work just as well? Is it there for historical reasons? Am I committing a sin by using n and could lightning strike my program dead under some obscure circumstance? > > Thanks, > > --Rob ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ How are you using it? My results appear to be different from yours ... $ uname -a Linux delora 2.6.17-10-386 #2 Fri Oct 13 18:41:40 UTC 2006 i686 GNU/Linux $ $ erl Erlang (BEAM) emulator version 5.5.2 [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.5.2 (abort with ^G) 1> io:fwrite('~pn', [{a,b,c}]). {a,b,c}nok 2> io:fwrite('~p~n', [{a,b,c}]). {a,b,c} ok 3> q(). ok 4> $ $ ~Michael From robert.virding@REDACTED Wed Jan 17 23:38:34 2007 From: robert.virding@REDACTED (Robert Virding) Date: Wed, 17 Jan 2007 23:38:34 +0100 Subject: [erlang-questions] Why ~n instead of n? In-Reply-To: <20070117221441.902555A1F9@mail.erlangsystems.com> References: <20070117221441.902555A1F9@mail.erlangsystems.com> Message-ID: <45AEA56A.50704@telia.com> Hopefully there will be no lightning strike. :-) There was meant to be a difference: \n is the newline character while ~n is causes a system-dependant new line in the current implementation. There is in fact no difference. Robert autophile wrote: > Does anyone know why there is a ~n in the io:fwrite format when n seems to work just as well? Is it there for historical reasons? Am I committing a sin by using n and could lightning strike my program dead under some obscure circumstance? > > Thanks, > > --Rob > _________________________________________________________ > Post sent from http://www.trapexit.org > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From autophile@REDACTED Thu Jan 18 00:10:08 2007 From: autophile@REDACTED (Robert Baruch) Date: Wed, 17 Jan 2007 18:10:08 -0500 Subject: [erlang-questions] Why ~n instead of n? In-Reply-To: <20070117222040.GD2665@delora.autosys.us> References: <20070117221441.902555A1F9@mail.erlangsystems.com> <20070117222040.GD2665@delora.autosys.us> Message-ID: <1578F273-F21A-4A4B-8C8F-1DA13E1A0B72@zoominternet.net> On Jan 17, 2007, at 5:20 PM, Michael McDaniel wrote: > > How are you using it? My results appear to be different > from yours ... Hmm, for some reason the backslash character didn't appear. It's supposed to be backslash-n. --Rob From autophile@REDACTED Thu Jan 18 00:16:26 2007 From: autophile@REDACTED (Robert Baruch) Date: Wed, 17 Jan 2007 18:16:26 -0500 Subject: [erlang-questions] Why ~n instead of n? In-Reply-To: <45AEA56A.50704@telia.com> References: <20070117221441.902555A1F9@mail.erlangsystems.com> <45AEA56A.50704@telia.com> Message-ID: <3EA069C8-2101-456C-8676-60061D7C25EC@zoominternet.net> On Jan 17, 2007, at 5:38 PM, Robert Virding wrote: > Hopefully there will be no lightning strike. :-) > > There was meant to be a difference: \n is the newline character > while ~n > is causes a system-dependant new line in the current implementation. > There is in fact no difference. OK, so if I were running on a Windows system, ~n should emit \r\n (i.e. hex 0x0D, 0x0A), and on *nix, \n (i.e. 0x0A). But when you say "in fact no difference", does that mean that although ~n *should* emit 0x0D 0x0A on a Windows system, it in fact doesn't? Thanks, --Rob From lcoquelle@REDACTED Thu Jan 18 01:18:10 2007 From: lcoquelle@REDACTED (Ludovic Coquelle) Date: Thu, 18 Jan 2007 08:18:10 +0800 Subject: [erlang-questions] build system In-Reply-To: References: Message-ID: Thank you for your feedbacks! Eric, all what you said make sense to me! ;) But I still have some (hopefully more precises) questions: * Isn't Emakefile limited in what it can do? what I mean is that I don't see how to implement a rule to compile some ASN.1 code for example. * Doesn't erlIDE have a build system? does it use the one of eclipse? * What (will) make a difference (if any) between erlware and sinan? On 1/17/07, Eric Merritt wrote: > On 1/16/07, Ludovic Coquelle wrote: > > Hi, > > I'm currently working on my first OTP application, and still wondering about > > the good build system to use. > > > > Anything which is part of the Erlang/OTP distribution? > > There isn't anything like a build system in the actual distribution. > > > (would be good to > > avoid dependency to external build tool) > > I can use the Emakefile, but I don't see how to: (1) build the boot script, > > (2) deals automaticaly with version (3) other? > > Emakefile works but its just like make and no more. If you are > comfortable with make it will work fine. > > > > > I have googlelized and found different tools: > > * as I target a Linux machine, I could use a 'normal' make > > * builder from Jungerl (same as included in tsung distribution? > > Builder isn't a build system it just builds releases. So its not an option. > > > [https://svn.process-one.net/tsung/trunk/priv/builder.erl]) > > * erlware [ http://www.erlware.org/] > > Erlware has been around for awhile and it works well. Its oriented > towards otp apps and that may be a factor to consider. > > > * sinan [http://code.google.com/p/sinan/] (which lack a bit of > > documentation...) > > This is my project. It lacks documentation because it isn't yet > complete. Its a ground up rewrite of a working build system that I > use. It simplifies a lot of the complexities of the earlier build > system and I think it will be well received when its done. I am rather > proud of it, but it wont be usable for a week or so (dependency > handling rewrite is taking longer then I imagined). > > > * erlIDE for Eclipse [ http://erlide.sourceforge.net/] > > This isn't a build system either, its an IDE. > > > > What are you using guys? Any suggestion? > > The only choices available right now is Emakefile, make and erlware. > Erlware requires otp apps but you would need to do that anyway before > you wrote anything significant. Sinan requires otp apps as well, but > its not ready for consumption yet. > From cyberlync@REDACTED Thu Jan 18 01:33:43 2007 From: cyberlync@REDACTED (Eric Merritt) Date: Wed, 17 Jan 2007 16:33:43 -0800 Subject: [erlang-questions] build system In-Reply-To: References: Message-ID: On 1/17/07, Ludovic Coquelle wrote: > Thank you for your feedbacks! > Eric, all what you said make sense to me! ;) > But I still have some (hopefully more precises) questions: > * Isn't Emakefile limited in what it can do? what I mean is that I > don't see how to implement a rule to compile some ASN.1 code for > example. I am not really that familiar with it. Someone mentioned that it was make implemented in erlang some time ago and I assumed it was true. As to its limitations I couldn't tell you. > * Doesn't erlIDE have a build system? does it use the one of eclipse? It does build files thats true. However, I wouldn't classify that as a build system. That said if you use erlide it will happily build the files that are part of your project. > * What (will) make a difference (if any) between erlware and sinan? This is a conversion that Martin and I have spent a lot of time on. In the end it comes down to your preference. erlware has the concept of a central build area for all of your erlang projects. Its also built around make and shell scripts. Erlware has a very unixy feel that many may find appealing. Sinan does a per project or per application build (though the dependency repo is shared). Sinan is written and extensible in Erlang. If anything Sinan feels like a much smarter version of java's ant then anything else. They both understand and require OTP infrastructure in the projects that they are capable of building. They both use the same repository format. They both are capable of generating 'getting started' project templates that are buildable from the get go. There are a lot of similarities between the two in output. However, they approach the problem of building otp apps very differently. I don't believe that one is intrinsically superior then the other, its just a matter of which you are more comfortable with. > On 1/17/07, Eric Merritt wrote: > > On 1/16/07, Ludovic Coquelle wrote: > > > Hi, > > > I'm currently working on my first OTP application, and still wondering about > > > the good build system to use. > > > > > > Anything which is part of the Erlang/OTP distribution? > > > > There isn't anything like a build system in the actual distribution. > > > > > (would be good to > > > avoid dependency to external build tool) > > > I can use the Emakefile, but I don't see how to: (1) build the boot script, > > > (2) deals automaticaly with version (3) other? > > > > Emakefile works but its just like make and no more. If you are > > comfortable with make it will work fine. > > > > > > > > I have googlelized and found different tools: > > > * as I target a Linux machine, I could use a 'normal' make > > > * builder from Jungerl (same as included in tsung distribution? > > > > Builder isn't a build system it just builds releases. So its not an option. > > > > > [https://svn.process-one.net/tsung/trunk/priv/builder.erl]) > > > * erlware [ http://www.erlware.org/] > > > > Erlware has been around for awhile and it works well. Its oriented > > towards otp apps and that may be a factor to consider. > > > > > * sinan [http://code.google.com/p/sinan/] (which lack a bit of > > > documentation...) > > > > This is my project. It lacks documentation because it isn't yet > > complete. Its a ground up rewrite of a working build system that I > > use. It simplifies a lot of the complexities of the earlier build > > system and I think it will be well received when its done. I am rather > > proud of it, but it wont be usable for a week or so (dependency > > handling rewrite is taking longer then I imagined). > > > > > * erlIDE for Eclipse [ http://erlide.sourceforge.net/] > > > > This isn't a build system either, its an IDE. > > > > > > What are you using guys? Any suggestion? > > > > The only choices available right now is Emakefile, make and erlware. > > Erlware requires otp apps but you would need to do that anyway before > > you wrote anything significant. Sinan requires otp apps as well, but > > its not ready for consumption yet. > > > From rlenglet@REDACTED Thu Jan 18 01:53:16 2007 From: rlenglet@REDACTED (Romain Lenglet) Date: Thu, 18 Jan 2007 09:53:16 +0900 Subject: [erlang-questions] Fwd: String encoding and character set In-Reply-To: <944da41d0701170532g7aadbe18p5976686b84260438@mail.gmail.com> References: <45AD60BA.4010103@telia.com> <45AD7DAC.8060009@users.forge.objectweb.org> <45ADF908.6050904@gmail.com> <944da41d0701170532g7aadbe18p5976686b84260438@mail.gmail.com> Message-ID: <45AEC4FC.3080906@users.forge.objectweb.org> Yes they do. If the list is flat and contains only integer values (code-points) between 0 and 255, then a special external representation is used, which is efficient. But if the list is not flat, or contains values < 0 or > 255, then the normal external representation for lists and integers is used, which is quite inefficient in that case. Therefore, if you want to transfer non-ASCII strings efficiently, you should rather encode them yourself into binaries, not using list_to_binary/1. Alex Arnon wrote: > No they do not - the list is expected to contain byte values. > > On 1/17/07, *Dmitrii 'Mamut' Dimandt* > wrote: > > Do list_to_binary/binary_to_list preserve codepoints? That is, does > L1 = binary_to_list(list_to_binary(L2)) imply that L1 = L2? If not, > then we loose an effective way of sending strings as binary > > > Romain Lenglet wrote: > > As Robert explained, the current convention for representing > strings in > > Erlang is a flat list of Unicode code-points as integers. Every > element > > in such a list is a character, represented by its Unicode code-point > > integer value. The 11th character of a string is the 11th element > in the > > list. If you want to encode such a string, you are free to do so, and > > that is relatively easy. But the current convention is to represent > > strings *unencoded*, as such lists of Unicode code points. > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > From rlenglet@REDACTED Thu Jan 18 02:30:49 2007 From: rlenglet@REDACTED (Romain Lenglet) Date: Thu, 18 Jan 2007 10:30:49 +0900 Subject: [erlang-questions] Fwd: String encoding and character set In-Reply-To: <17838.51446.201348.253435@antilipe.corelatus.se> References: <45AD60BA.4010103@telia.com> <45AD7DAC.8060009@users.forge.objectweb.org> <45ADF908.6050904@gmail.com> <944da41d0701170532g7aadbe18p5976686b84260438@mail.gmail.com> <45AEC4FC.3080906@users.forge.objectweb.org> <17838.51446.201348.253435@antilipe.corelatus.se> Message-ID: <45AECDC9.2050908@users.forge.objectweb.org> Matthias Lang wrote: > Romain Lenglet writes: > > Yes they do. > > > > If the list is flat and contains only integer values (code-points) > > between 0 and 255, then a special external representation is used, which > > is efficient. But if the list is not flat, or contains values < 0 or > > > 255, then the normal external representation for lists and integers is > > used, which is quite inefficient in that case. > > Are you mixing up term_to_binary and list_to_binary? Yes. (^_^) > list_to_binary gives you a badarg if you have values > 255. > > What are you talking about? I was talking about term_to_binary/1. Sorry. I misread Dmitrii's original message. > Matthias > > > > > > Therefore, if you want to transfer non-ASCII strings efficiently, you > > should rather encode them yourself into binaries, not using > > list_to_binary/1. > > > > Alex Arnon wrote: > > > No they do not - the list is expected to contain byte values. > > > > > > On 1/17/07, *Dmitrii 'Mamut' Dimandt* > > > wrote: > > > > > > Do list_to_binary/binary_to_list preserve codepoints? That is, does > > > L1 = binary_to_list(list_to_binary(L2)) imply that L1 = L2? If not, > > > then we loose an effective way of sending strings as binary > > > > > > > > > Romain Lenglet wrote: > > > > As Robert explained, the current convention for representing > > > strings in > > > > Erlang is a flat list of Unicode code-points as integers. Every > > > element > > > > in such a list is a character, represented by its Unicode code-point > > > > integer value. The 11th character of a string is the 11th element > > > in the > > > > list. If you want to encode such a string, you are free to do so, and > > > > that is relatively easy. But the current convention is to represent > > > > strings *unencoded*, as such lists of Unicode code points. > > > > > > > > > > _______________________________________________ > > > 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 onlyou.gan@REDACTED Thu Jan 18 03:57:03 2007 From: onlyou.gan@REDACTED (William Gan) Date: Thu, 18 Jan 2007 10:57:03 +0800 Subject: [erlang-questions] How to add a option for inet:getopts Message-ID: <1169089023.4085.7.camel@localhost.localdomain> Hello, I am preparing to implement a transparent proxy by erlang, and I need an equivalent call for 'getsockopt(fd,SOL_IP,SO_ORIGINAL_DST,&server,&slen)'. Can anyone give me some advice how to add such a call in erlang? William Gan From jeffm@REDACTED Thu Jan 18 05:08:22 2007 From: jeffm@REDACTED (jm) Date: Thu, 18 Jan 2007 15:08:22 +1100 Subject: [erlang-questions] subnet masking with binary matching Message-ID: <45AEF2B6.1040502@ghostgun.com> Using binary matching to perform subnet masking with the following code, which should work with both IPv4 and IPv6 as far as I can tell, mask_address(Addr, Maskbits) -> B = list_to_binary(tuple_to_list(Addr)), io:format("address as binary: ~p ~p~n", [B,Maskbits]), <> = B, Subnet. which errors with {badmatch,<<4 bytes>>} when called by mask_address({192,168,1,128}, 25). yet works when called by mask_address({192,168,1,0}, 24). Can anyone tell me how to fix this? Jeff. From jeffm@REDACTED Thu Jan 18 06:03:00 2007 From: jeffm@REDACTED (jm) Date: Thu, 18 Jan 2007 16:03:00 +1100 Subject: [erlang-questions] subnet masking with binary matching In-Reply-To: <45AEF2B6.1040502@ghostgun.com> References: <45AEF2B6.1040502@ghostgun.com> Message-ID: <45AEFF84.6000800@ghostgun.com> It's been pointed out to me that binary has to be a multiple of 8 (thanks goes to Vance). So, the question now becomes is there an "erlang way" to do masking of IP addresses or should be done with a shift followed by an AND as I would do in C. Now I have an idea of why this broke I'll give it another go. Other than the "application...of bit stream programming in erlang" is there any documentation on the binary matching? I seem to remember seeing some somewhere, but I've looked around the erlang doc and seem to have missed it. Jeff. jm wrote: > Using binary matching to perform subnet masking with the following code, > which should work with both IPv4 and IPv6 as far as I can tell, > > mask_address(Addr, Maskbits) -> > B = list_to_binary(tuple_to_list(Addr)), > io:format("address as binary: ~p ~p~n", [B,Maskbits]), > <> = B, > Subnet. > > which errors with > > {badmatch,<<4 bytes>>} > > when called by > > mask_address({192,168,1,128}, 25). > > yet works when called by > > mask_address({192,168,1,0}, 24). > > Can anyone tell me how to fix this? > > Jeff. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From casper2000a@REDACTED Thu Jan 18 06:32:25 2007 From: casper2000a@REDACTED (Eranga Udesh) Date: Thu, 18 Jan 2007 11:02:25 +0530 Subject: [erlang-questions] Sudden death of Erlang Node Message-ID: <20070118053240.672A619DC418@mail.wavenet.lk> Hi, I have a very busy Erlang node running in a Quad Proc server with plenty of Ram. The server utilization is quite normal. However time to time, the Erlang node goes to sudden death without any warnings. The erlang.log.x log files only show that the "heart" couldn't kill the server and the node restarting info. Also I cannot find any erl_crash.dump file. Later I introduced ERL_CRASH_DUMP and ERL_CRASH_DUMP_SECONDS environment variable with different settings, but no luck. I use Erlang version 11B-2. Has anybody experienced this sort of problem before? Please advice if you know any other settings to set to identify the issue. Thanks in advance. - Eranga -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob@REDACTED Thu Jan 18 06:33:28 2007 From: bob@REDACTED (Bob Ippolito) Date: Wed, 17 Jan 2007 21:33:28 -0800 Subject: [erlang-questions] subnet masking with binary matching In-Reply-To: <45AEFF84.6000800@ghostgun.com> References: <45AEF2B6.1040502@ghostgun.com> <45AEFF84.6000800@ghostgun.com> Message-ID: <6a36e7290701172133y32604ba9h57192af147b435d0@mail.gmail.com> There's plenty of documentation for all of Erlang's pattern matching features in the reference manual. You could just do this: mask_address(Addr, Maskbits) -> B = list_to_binary(tuple_to_list(Addr)), io:format("address as binary: ~p ~p~n", [B,Maskbits]), Rest = (size(B) * 8) - Maskbits, <> = B, Subnet. If/when the feature enhancements proposed in that paper end up in Erlang, then this code would be shorter and cleaner. It sure would make a huge difference in a lot of my code, but even the current syntax is much better than bit twiddling other languages. -bob On 1/17/07, jm wrote: > It's been pointed out to me that binary has to be a multiple of 8 > (thanks goes to Vance). So, the question now becomes is there an "erlang > way" to do masking of IP addresses or should be done with a shift > followed by an AND as I would do in C. Now I have an idea of why this > broke I'll give it another go. > > Other than the "application...of bit stream programming in erlang" is > there any documentation on the binary matching? I seem to remember > seeing some somewhere, but I've looked around the erlang doc and seem to > have missed it. > > Jeff. > > jm wrote: > > Using binary matching to perform subnet masking with the following code, > > which should work with both IPv4 and IPv6 as far as I can tell, > > > > mask_address(Addr, Maskbits) -> > > B = list_to_binary(tuple_to_list(Addr)), > > io:format("address as binary: ~p ~p~n", [B,Maskbits]), > > <> = B, > > Subnet. > > > > which errors with > > > > {badmatch,<<4 bytes>>} > > > > when called by > > > > mask_address({192,168,1,128}, 25). > > > > yet works when called by > > > > mask_address({192,168,1,0}, 24). > > > > Can anyone tell me how to fix this? > > > > 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 jeffm@REDACTED Thu Jan 18 07:06:37 2007 From: jeffm@REDACTED (jm) Date: Thu, 18 Jan 2007 17:06:37 +1100 Subject: [erlang-questions] subnet masking with binary matching In-Reply-To: <6a36e7290701172133y32604ba9h57192af147b435d0@mail.gmail.com> References: <45AEF2B6.1040502@ghostgun.com> <45AEFF84.6000800@ghostgun.com> <6a36e7290701172133y32604ba9h57192af147b435d0@mail.gmail.com> Message-ID: <45AF0E6D.1040304@ghostgun.com> Bob Ippolito wrote: > There's plenty of documentation for all of Erlang's pattern matching > features in the reference manual. > > You could just do this: > > mask_address(Addr, Maskbits) -> > B = list_to_binary(tuple_to_list(Addr)), > io:format("address as binary: ~p ~p~n", [B,Maskbits]), > Rest = (size(B) * 8) - Maskbits, > <> = B, > Subnet. > > If/when the feature enhancements proposed in that paper end up in > Erlang, then this code would be shorter and cleaner. It sure would > make a huge difference in a lot of my code, but even the current > syntax is much better than bit twiddling other languages. > > -bob > Found the ref manual after I sent the email. Had the browser open at the kernel and stdlib only before that. thanks. that works and help increase my comprehension of the language. Almost reached for the bit ops. Now I can get back to trying to actually debug a short module. Jeff. From raimo+erlang-questions@REDACTED Thu Jan 18 08:39:28 2007 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Thu, 18 Jan 2007 08:39:28 +0100 Subject: [erlang-questions] : Why ~n instead of n? In-Reply-To: <3EA069C8-2101-456C-8676-60061D7C25EC@zoominternet.net> References: <20070117221441.902555A1F9@mail.erlangsystems.com> <45AEA56A.50704@telia.com> <3EA069C8-2101-456C-8676-60061D7C25EC@zoominternet.net> Message-ID: <20070118073928.GA26383@erix.ericsson.se> On Wed, Jan 17, 2007 at 06:16:26PM -0500, Robert Baruch wrote: > > On Jan 17, 2007, at 5:38 PM, Robert Virding wrote: > > > Hopefully there will be no lightning strike. :-) > > > > There was meant to be a difference: \n is the newline character > > while ~n > > is causes a system-dependant new line in the current implementation. > > There is in fact no difference. > > OK, so if I were running on a Windows system, ~n should emit \r\n > (i.e. hex 0x0D, 0x0A), and on *nix, \n (i.e. 0x0A). But when you say > "in fact no difference", does that mean that although ~n *should* > emit 0x0D 0x0A on a Windows system, it in fact doesn't? > You are absolutely right! > Thanks, > > --Rob > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From kostis@REDACTED Thu Jan 18 09:01:08 2007 From: kostis@REDACTED (Kostis Sagonas) Date: Thu, 18 Jan 2007 09:01:08 +0100 Subject: [erlang-questions] subnet masking with binary matching In-Reply-To: <6a36e7290701172133y32604ba9h57192af147b435d0@mail.gmail.com> References: <45AEF2B6.1040502@ghostgun.com> <45AEFF84.6000800@ghostgun.com> <6a36e7290701172133y32604ba9h57192af147b435d0@mail.gmail.com> Message-ID: <45AF2944.6020101@cs.ntua.gr> Bob Ippolito wrote: > > You could just do this: > > mask_address(Addr, Maskbits) -> > B = list_to_binary(tuple_to_list(Addr)), > io:format("address as binary: ~p ~p~n", [B,Maskbits]), > Rest = (size(B) * 8) - Maskbits, > <> = B, > Subnet. > > If/when the feature enhancements proposed in that paper end up in > Erlang, then this code would be shorter and cleaner. It sure would > make a huge difference in a lot of my code, but even the current > syntax is much better than bit twiddling other languages. I second the last sentence. By the way, the feature enhancements proposed in our paper are already in the development version of Erlang/OTP and will most probably be released as part of R11B-3. Jeff's code would need to be slightly modified and use the "bitstr" type specifier: mask_address(Addr, Maskbits) -> B = list_to_binary(tuple_to_list(Addr)), io:format("address as binary: ~p ~p~n", [B,Maskbits]), <> = B, Subnet. Kostis From autophile@REDACTED Thu Jan 18 06:13:18 2007 From: autophile@REDACTED (Robert Baruch) Date: Thu, 18 Jan 2007 00:13:18 -0500 Subject: [erlang-questions] subnet masking with binary matching In-Reply-To: <45AEFF84.6000800@ghostgun.com> References: <45AEF2B6.1040502@ghostgun.com> <45AEFF84.6000800@ghostgun.com> Message-ID: <9AFD4F5D-EAD6-4327-92E3-08B8714EE18D@zoominternet.net> Binary matching is, inexplicably, covered in Programming Examples, the Bit Syntax chapter. This works: <> = <<1,2>>. A. 2 B. 2 This does not work: <> = <<1,2>>. you get a badmatch. So I suggest you do something like Hostbits = 32 - Maskbits, <> = B --Rob On Jan 18, 2007, at 12:03 AM, jm wrote: > It's been pointed out to me that binary has to be a multiple of 8 > (thanks goes to Vance). So, the question now becomes is there an > "erlang > way" to do masking of IP addresses or should be done with a shift > followed by an AND as I would do in C. Now I have an idea of why this > broke I'll give it another go. > > Other than the "application...of bit stream programming in erlang" is > there any documentation on the binary matching? I seem to remember > seeing some somewhere, but I've looked around the erlang doc and > seem to > have missed it. > > Jeff. > > jm wrote: >> Using binary matching to perform subnet masking with the following >> code, >> which should work with both IPv4 and IPv6 as far as I can tell, >> >> mask_address(Addr, Maskbits) -> >> B = list_to_binary(tuple_to_list(Addr)), >> io:format("address as binary: ~p ~p~n", [B,Maskbits]), >> <> = B, >> Subnet. >> >> which errors with >> >> {badmatch,<<4 bytes>>} >> >> when called by >> >> mask_address({192,168,1,128}, 25). >> >> yet works when called by >> >> mask_address({192,168,1,0}, 24). >> >> Can anyone tell me how to fix this? >> >> 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 thomasl_erlang@REDACTED Thu Jan 18 13:19:20 2007 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Thu, 18 Jan 2007 04:19:20 -0800 (PST) Subject: [erlang-questions] Why ~n instead of n? In-Reply-To: <20070117221441.902555A1F9@mail.erlangsystems.com> Message-ID: <660092.48582.qm@web38802.mail.mud.yahoo.com> --- autophile wrote: > Does anyone know why there is a ~n in the io:fwrite > format when n seems to work just as well? Is it > there for historical reasons? Am I committing a sin > by using n and could lightning strike my program > dead under some obscure circumstance? In addition to the previously listed reasons, ~n also permits counted operations: 1> io:format("~3n", []). Best, Thomas ____________________________________________________________________________________ 8:00? 8:25? 8:40? Find a flick in no time with the Yahoo! Search movie showtime shortcut. http://tools.search.yahoo.com/shortcuts/#news From autophile@REDACTED Thu Jan 18 06:02:36 2007 From: autophile@REDACTED (Robert Baruch) Date: Thu, 18 Jan 2007 00:02:36 -0500 Subject: [erlang-questions] subnet masking with binary matching In-Reply-To: <45AEF2B6.1040502@ghostgun.com> References: <45AEF2B6.1040502@ghostgun.com> Message-ID: <5BF1F477-FE25-4209-87C6-9EEC38FE6CA8@zoominternet.net> The binary you're matching to has to total a multiple of 8 bits long. Maybe Erlang is assuming _Host is some multiple of 8 bits, and therefore since Maskbits is not a multiple of 8 bits, the match fails? --Rob On Jan 17, 2007, at 11:08 PM, jm wrote: > Using binary matching to perform subnet masking with the following > code, > which should work with both IPv4 and IPv6 as far as I can tell, > > mask_address(Addr, Maskbits) -> > B = list_to_binary(tuple_to_list(Addr)), > io:format("address as binary: ~p ~p~n", [B,Maskbits]), > <> = B, > Subnet. > > which errors with > > {badmatch,<<4 bytes>>} > > when called by > > mask_address({192,168,1,128}, 25). > > yet works when called by > > mask_address({192,168,1,0}, 24). > > Can anyone tell me how to fix this? > > Jeff. > _______________________________________________ From siddharthpareek@REDACTED Thu Jan 18 15:50:01 2007 From: siddharthpareek@REDACTED (Siddharth Pareek) Date: Thu, 18 Jan 2007 20:20:01 +0530 Subject: [erlang-questions] JInterface and node discovery Message-ID: <000601c73b0f$f2ea2d50$2301a8c0@calance.com> hi , I had gone through the previous answers with the same subject as mentioned above but my problem is a little bit different . I too wana know the nodes which are in cluster ..but the cluster are on the different machines. Executing the following code will return me only the nodes that are clustered on a single machine . Is there any way by which i can get the names of all the nodes that are clustered on other machine along with my machine nodes. private static final int epmdPort = 4369; private static final byte names4req = (byte) 110; private static int traceLevel = 0; private static final int traceThreshold = 4; Socket s = null; try { final OtpOutputStream obuf = new OtpOutputStream(); s = new Socket(InetAddress.getLocalHost(), epmdPort); obuf.write2BE(1); obuf.write1(names4req); // send request obuf.writeTo(s.getOutputStream()); if (traceLevel >= traceThreshold) { System.out.println("-> NAMES (r4) "); // get reply final byte[] buffer = new byte[256]; final ByteArrayOutputStream out = new ByteArrayOutputStream(256); while (true) { final int bytesRead = s.getInputStream().read(buffer); if (bytesRead == -1) { break; } out.write(buffer, 0, bytesRead); } final byte[] tmpbuf = out.toByteArray(); final OtpInputStream ibuf = new OtpInputStream(tmpbuf); ibuf.read4BE(); // read port int final int n = tmpbuf.length; final byte[] buf = new byte[n - 4]; System.arraycopy(tmpbuf, 4, buf, 0, n - 4); final String all = new String(buf); return all.split("\n"); Thanks and Regards, Siddharth Pareek -------------- next part -------------- An HTML attachment was scrubbed... URL: From serge@REDACTED Thu Jan 18 16:26:29 2007 From: serge@REDACTED (Serge Aleynikov) Date: Thu, 18 Jan 2007 10:26:29 -0500 Subject: [erlang-questions] Sudden death of Erlang Node In-Reply-To: <20070118053240.672A619DC418@mail.wavenet.lk> References: <20070118053240.672A619DC418@mail.wavenet.lk> Message-ID: <45AF91A5.7070309@hq.idt.net> Eranga Udesh wrote: > Hi, > > I have a very busy Erlang node running in a Quad Proc server with plenty of > Ram. The server utilization is quite normal. You indicate that you have a "very busy" node, yet it's utilization is "quite normal". I find these definition contradictory. Could you define the peak utilization in CPU percentage consumption? If it is, say, over 90% that can't be considered normal. > However time to time, the > Erlang node goes to sudden death without any warnings. The erlang.log.x log > files only show that the "heart" couldn't kill the server and the node > restarting info. Also I cannot find any erl_crash.dump file. Later I > introduced ERL_CRASH_DUMP and ERL_CRASH_DUMP_SECONDS environment variable > with different settings, but no luck. I use Erlang version 11B-2. We've experienced a similar issue intermittently with R11B-0 (without SMP - which is what we are running in production). The details can be found in this thread: http://www.erlang.org/pipermail/erlang-questions/2006-December/024365.html Are you seeing the following message in the log? "heart: Wed Dec 13 18:59:54 2006: Erlang has closed." I managed to reproduce a similar issue by creating sustained CPU load at 100%. strace showed that at some point a node failed to allocate memory by calling mmap(). After that the node closed all file descriptors, which was immediately detected by the "heart" process that in turn killed and restarted the node. The only artifact seen was the error message above in the erlang.log.x file. I don't know exactly if this was the same cause as we had in production (at least the production process didn't seem to have exhausted the memory) but the heart message in the log was identical. What else can cause an Erlang node to close the pipe connecting it to the heart process? I suggest you set up a monitoring process on that machine to log some statistics about the process (such as timestamp + /proc/PID/status), so that you can correlate process memory with a time of the failure. Not sure how much this is helpful in your case, but this similar issue pops up once every couple of months in our production system followed by an automatic restart that remains unresolved. Serge From headspin@REDACTED Wed Jan 17 15:00:52 2007 From: headspin@REDACTED (dda) Date: Wed, 17 Jan 2007 15:00:52 +0100 Subject: [erlang-questions] String encoding and character set In-Reply-To: <200701170456.l0H4uVee145774@atlas.otago.ac.nz> References: <200701170456.l0H4uVee145774@atlas.otago.ac.nz> Message-ID: Those "floating diacritics" are handled through Normalisation. An intelligent set of string functions should be able to normalize strings and extract a character correctly whether it was originally encoded on one or two codepoints. The UCD provides all the information about this. Parsing only with regexes is slow, even on languages that have fast-ish regexes [Erlang's alas not in this case]. While I do like regexes, there's a lot that can be done faster with dedicated string manipulation functions. -- dda On 1/17/07, Richard A. O'Keefe wrote: > "Ludovic Coquelle" wrote: > My guess is that with a string format you can access the nth > character of the message by its position, which can be very > difficult to do with a list if the encoding support different > size for different characters (and sometimes the same character > can have different encoding depending of previous ones: > contextual encoding) ... > > Note that Unicode has "floating diacriticals" AND it has a number > of "precomposed characters". > Floating diacriticals means > > user_character --> base_character floating_diacritical* > > (where a floating_diacritical could be "dot below" or "accent grave > above" amongst many possibilities). Precomposed characters means that > a large number of base_character+floating_diacritical combinations > are also assigned single code points. For example, e-acute could be > one code-point (identical to the Latin-1 value) or two (base e, ' diacritical). > There is in fact no theoretical limit to the number or kind of floating > diacritical accents that may be added to any base. > > So in Unicode, "access(ing) the nth character ... by its position" is > not only ambiguous (do you mean "characters" or "code points") but > essentially useless. You might pick up an "e", but it is _really_ just > the first part of e-acute. > > The fundamental operations on strings are > > (1) decode binary to string using some encoding > (2) encode string to binary using some encoding > (3) compare using locale- and application-appropriate rules > (4) parse, typically using regular expressions > (5) unparse > > The combination {Encoding_Name_Atom,Binary} can *be* a string if > you really want. From vladdu55@REDACTED Thu Jan 18 22:20:53 2007 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Thu, 18 Jan 2007 21:20:53 +0000 Subject: [erlang-questions] JInterface and node discovery In-Reply-To: <000601c73b0f$f2ea2d50$2301a8c0@calance.com> References: <000601c73b0f$f2ea2d50$2301a8c0@calance.com> Message-ID: <95be1d3b0701181320s2e65532eo201b1abb113e9de2@mail.gmail.com> Hi, On 1/18/07, Siddharth Pareek wrote: > I too wana know the nodes which are in cluster ..but the cluster > are on the different machines. One simple solution would be to call your code with the host name as a parameter and iterate over all machines in the cluster. I don't think a global registry exists, each epmd keeps track of the local nodes and those connected to them (which should be able to be retrieved with the method you used, maybe there are no connection between nodes on different machines?) Hope this helps. Best regards, Vlad From klacke@REDACTED Thu Jan 18 22:41:37 2007 From: klacke@REDACTED (Claes Wikstrom) Date: Thu, 18 Jan 2007 22:41:37 +0100 Subject: [erlang-questions] subnet masking with binary matching In-Reply-To: <6a36e7290701172133y32604ba9h57192af147b435d0@mail.gmail.com> References: <45AEF2B6.1040502@ghostgun.com> <45AEFF84.6000800@ghostgun.com> <6a36e7290701172133y32604ba9h57192af147b435d0@mail.gmail.com> Message-ID: <45AFE991.9090004@hyber.org> Bob Ippolito wrote: > There's plenty of documentation for all of Erlang's pattern matching > features in the reference manual. > A good solution is also to represent IP addresses as integers. I've found it easier to manipulate IPs as integers than 4/8 tuples or binaries. On ints we can do many bit-twiddler operations that are otherwise hard. /klacke From robert.virding@REDACTED Thu Jan 18 23:08:55 2007 From: robert.virding@REDACTED (Robert Virding) Date: Thu, 18 Jan 2007 23:08:55 +0100 Subject: [erlang-questions] : Why ~n instead of n? In-Reply-To: <20070118073928.GA26383@erix.ericsson.se> References: <20070117221441.902555A1F9@mail.erlangsystems.com> <45AEA56A.50704@telia.com> <3EA069C8-2101-456C-8676-60061D7C25EC@zoominternet.net> <20070118073928.GA26383@erix.ericsson.se> Message-ID: <45AFEFF7.6090001@telia.com> Use io_lib to see exactly what characters are emitted: 2> io_lib:fwrite("abc\n", []). "abc\n" 3> io_lib:fwrite("abc~n", []). [97,98,99,"\n"] and you see that they are the same. It is the low-level driver which fixes the end-line to be either \n or \r\n as necessary. It also makes end-of-line on input be \n removing the \r. When we added ~n we meant it to be converted at a higher level, but that never happened. That is why I said there is no difference. If this the best solution I don't know, but it would probably break code if it was changed, people are used to using \n. Robert Raimo Niskanen wrote: > On Wed, Jan 17, 2007 at 06:16:26PM -0500, Robert Baruch wrote: > >>On Jan 17, 2007, at 5:38 PM, Robert Virding wrote: >> >> >>>Hopefully there will be no lightning strike. :-) >>> >>>There was meant to be a difference: \n is the newline character >>>while ~n >>>is causes a system-dependant new line in the current implementation. >>>There is in fact no difference. >> >>OK, so if I were running on a Windows system, ~n should emit \r\n >>(i.e. hex 0x0D, 0x0A), and on *nix, \n (i.e. 0x0A). But when you say >>"in fact no difference", does that mean that although ~n *should* >>emit 0x0D 0x0A on a Windows system, it in fact doesn't? >> > > > You are absolutely right! > > > >>Thanks, >> >>--Rob >> >>_______________________________________________ >>erlang-questions mailing list >>erlang-questions@REDACTED >>http://www.erlang.org/mailman/listinfo/erlang-questions > > From robert.virding@REDACTED Thu Jan 18 23:27:06 2007 From: robert.virding@REDACTED (Robert Virding) Date: Thu, 18 Jan 2007 23:27:06 +0100 Subject: [erlang-questions] lists:reverse/1 as a built-in function In-Reply-To: <200701170438.l0H4cHOp145653@atlas.otago.ac.nz> References: <200701170438.l0H4cHOp145653@atlas.otago.ac.nz> Message-ID: <45AFF43A.8040601@telia.com> I agree with 1 & 3 but I am a bit dubious about 2. It means you have added an extra default level for system functions and it is not really consistent. Although it would probably not break much code. I personally wonder if you are going to change how BIFs are handled and go the whole hog and make it completely consistent with normal functions: either they are local or imported. That's it. At least you always KNOW what it means. Although it would break code. :-) Actually Jonas Barklund and I had a very reasonable solution: 1. ALL functions without module are either local or imported. 2. All BIFs are pre-imported automatically for you 3. There is an unimport declaration. (works for all imports) So if you wanted use BIFs as local functions then you would unimport them from 'erlang'. Very consistent and explicit about what is going on, and backwards compatible. We also had another idea which I really liked: split the predefined module 'erlang' into a number of predefined modules like process, atom, number, .... And some left in erlang. These modules would be like todays erlang in that they would be part of the language and specially treated. I hink the result would be easier to handle that the wopping great erlang of today. Alas some worried about backwards incompatibility if people had there own modules with the same names. Robert Richard A. O'Keefe wrote: > Just because something is a core part of the language doesn't mean I > always want it. I believe that > (1) Infix and prefix operator syntax should simply be an alternative > way of writing an ordinary function call, so that X+1 and '+'(X,1) > should be exactly the same thing. > (2) There should be three mutually exclusive ways to make a function > available for calling without a prefix: > (a) define it in the module > (b) explicitly import it from some module > (c) obtain it from erlang: if neither (a) nor (b) applies. > This means that adding new functions to erlang: cannot break working > code because working code would have to do (a) or (b). > (3) Imitating Java and especially imitating Java's inside-out packages > is a Bad Thing. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From autophile@REDACTED Thu Jan 18 23:39:27 2007 From: autophile@REDACTED (Robert Baruch) Date: Thu, 18 Jan 2007 17:39:27 -0500 Subject: [erlang-questions] lists:reverse/1 as a built-in function In-Reply-To: <45AFF43A.8040601@telia.com> References: <200701170438.l0H4cHOp145653@atlas.otago.ac.nz> <45AFF43A.8040601@telia.com> Message-ID: <013425C3-C691-45AC-9761-C8B8A31F4C36@zoominternet.net> On Jan 18, 2007, at 5:27 PM, Robert Virding wrote: > I agree with 1 & 3 but I am a bit dubious about 2... ... > > Richard A. O'Keefe wrote: >> Just because something is a core part of the language doesn't mean I >> always want it. I believe that >> ... >> (3) Imitating Java and especially imitating Java's inside-out >> packages >> is a Bad Thing. Maybe I stepped into a holy war. I've been working with Java since 1.1 (which is, like, *forever* in Internet time!) and the package naming and resolution scheme has never confused me. Without having any point to address other than "Java sucks", though, I guess that means I won't bother anymore with advocating a Java-like solution :/ --Rob From serge@REDACTED Fri Jan 19 04:24:01 2007 From: serge@REDACTED (Serge Aleynikov) Date: Thu, 18 Jan 2007 22:24:01 -0500 Subject: [erlang-questions] How to add a option for inet:getopts In-Reply-To: <1169089023.4085.7.camel@localhost.localdomain> References: <1169089023.4085.7.camel@localhost.localdomain> Message-ID: <45B039D1.8040106@hq.idt.net> The only way to get this socket option accessible from Erlang is to add support for it in the network driver (inet_drv.c). Serge William Gan wrote: > Hello, > > I am preparing to implement a transparent proxy by erlang, and I need an > equivalent call for > 'getsockopt(fd,SOL_IP,SO_ORIGINAL_DST,&server,&slen)'. > > Can anyone give me some advice how to add such a call in erlang? > > William Gan > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From casper2000a@REDACTED Fri Jan 19 07:15:45 2007 From: casper2000a@REDACTED (Eranga Udesh) Date: Fri, 19 Jan 2007 11:45:45 +0530 Subject: [erlang-questions] Sudden death of Erlang Node In-Reply-To: <45AF91A5.7070309@hq.idt.net> Message-ID: <20070119061602.B6E3619DC40F@mail.wavenet.lk> Thanks for the info. I said "very busy" to indicate the system I am talking about handles over 1000-1500 message passing, 750-1000 process spawning, 250-500 mnesia DB access, 500-750 Erl Port calls, etc, Per Second (/s) kind of busyness. However the CPU utilization doesn't go beyond 25% in any of the 4 CPU in the system and memory is over 40% free. Based on that, even though my end problem seems similar, the cause for it may not be. I am running 11B-2 compiled with SMP support, but the node is not started in SMP mode. In this particular node, I am running a couple of Erl Port Drivers developed in C. I guess if I can generate the erl_crash.dump, I should be able to find the cause for the problem. Why it's not generating? What methods do I have to identify the issue in a situation like this (activate debug, crash dump, etc)? Thanks, - Eranga -----Original Message----- From: Serge Aleynikov [mailto:serge@REDACTED] Sent: Thursday, January 18, 2007 8:56 PM To: Eranga Udesh Cc: erlang-questions@REDACTED Subject: Re: [erlang-questions] Sudden death of Erlang Node Eranga Udesh wrote: > Hi, > > I have a very busy Erlang node running in a Quad Proc server with plenty of > Ram. The server utilization is quite normal. You indicate that you have a "very busy" node, yet it's utilization is "quite normal". I find these definition contradictory. Could you define the peak utilization in CPU percentage consumption? If it is, say, over 90% that can't be considered normal. > However time to time, the > Erlang node goes to sudden death without any warnings. The erlang.log.x log > files only show that the "heart" couldn't kill the server and the node > restarting info. Also I cannot find any erl_crash.dump file. Later I > introduced ERL_CRASH_DUMP and ERL_CRASH_DUMP_SECONDS environment variable > with different settings, but no luck. I use Erlang version 11B-2. We've experienced a similar issue intermittently with R11B-0 (without SMP - which is what we are running in production). The details can be found in this thread: http://www.erlang.org/pipermail/erlang-questions/2006-December/024365.html Are you seeing the following message in the log? "heart: Wed Dec 13 18:59:54 2006: Erlang has closed." I managed to reproduce a similar issue by creating sustained CPU load at 100%. strace showed that at some point a node failed to allocate memory by calling mmap(). After that the node closed all file descriptors, which was immediately detected by the "heart" process that in turn killed and restarted the node. The only artifact seen was the error message above in the erlang.log.x file. I don't know exactly if this was the same cause as we had in production (at least the production process didn't seem to have exhausted the memory) but the heart message in the log was identical. What else can cause an Erlang node to close the pipe connecting it to the heart process? I suggest you set up a monitoring process on that machine to log some statistics about the process (such as timestamp + /proc/PID/status), so that you can correlate process memory with a time of the failure. Not sure how much this is helpful in your case, but this similar issue pops up once every couple of months in our production system followed by an automatic restart that remains unresolved. Serge From siddharthpareek@REDACTED Fri Jan 19 07:52:29 2007 From: siddharthpareek@REDACTED (Siddharth Pareek) Date: Fri, 19 Jan 2007 12:22:29 +0530 Subject: [erlang-questions] connect to node by jinterface Message-ID: <000601c73b96$65425e50$2301a8c0@calance.com> hi , Can any one lemme know how to connect to the node that is created on any other machine through jniterface and then able to send messages to it . I tried out the following but it is not working : OtpSelf self = new OtpSelf("localhost", "abc"); OtpPeer other = new OtpPeer(master1@REDACTED); conn = self.connect(other); OtpErlangString otpErlangString = new OtpErlangString("hi"); conn.send(master1@REDACTED, otpErlangString); Do I am doing something wrong. Thanks and Regards, Siddharth Pareek -------------- next part -------------- An HTML attachment was scrubbed... URL: From ft@REDACTED Fri Jan 19 08:16:23 2007 From: ft@REDACTED (Fredrik Thulin) Date: Fri, 19 Jan 2007 08:16:23 +0100 Subject: [erlang-questions] Sudden death of Erlang Node In-Reply-To: <20070119061602.B6E3619DC40F@mail.wavenet.lk> References: <20070119061602.B6E3619DC40F@mail.wavenet.lk> Message-ID: <45B07047.5060408@it.su.se> Eranga Udesh wrote: > Thanks for the info. > > I said "very busy" to indicate the system I am talking about handles over > 1000-1500 message passing, 750-1000 process spawning, 250-500 mnesia DB > access, 500-750 Erl Port calls, etc, Per Second (/s) kind of busyness. > However the CPU utilization doesn't go beyond 25% in any of the 4 CPU in the > system and memory is over 40% free. > > Based on that, even though my end problem seems similar, the cause for it > may not be. I am running 11B-2 compiled with SMP support, but the node is > not started in SMP mode. I'm pretty sure that if you don't start your node in SMP mode, it will only use one of your processors. Are you sure that the 25% CPU load is not really one of your four processors running at 100%? /Fredrik From tobbe@REDACTED Fri Jan 19 08:31:24 2007 From: tobbe@REDACTED (Torbjorn Tornkvist) Date: Fri, 19 Jan 2007 08:31:24 +0100 Subject: [erlang-questions] Sudden death of Erlang Node In-Reply-To: <20070119061602.B6E3619DC40F@mail.wavenet.lk> References: <45AF91A5.7070309@hq.idt.net> <20070119061602.B6E3619DC40F@mail.wavenet.lk> Message-ID: I don't know why you don't get an erl_crash dump. But if/when you do get one, then I can recommend the crashdump_viewer. It is excellent actually!! 1> crashdump_viewer:start(). WebTool is available at http://localhost:8888/ ok Cheers, Tobbe Eranga Udesh wrote: > Thanks for the info. > > I said "very busy" to indicate the system I am talking about handles over > 1000-1500 message passing, 750-1000 process spawning, 250-500 mnesia DB > access, 500-750 Erl Port calls, etc, Per Second (/s) kind of busyness. > However the CPU utilization doesn't go beyond 25% in any of the 4 CPU in the > system and memory is over 40% free. > > Based on that, even though my end problem seems similar, the cause for it > may not be. I am running 11B-2 compiled with SMP support, but the node is > not started in SMP mode. > > In this particular node, I am running a couple of Erl Port Drivers developed > in C. > I guess if I can generate the erl_crash.dump, I should be able to find the > cause for the problem. Why it's not generating? > > What methods do I have to identify the issue in a situation like this > (activate debug, crash dump, etc)? > > Thanks, > - Eranga > > > > -----Original Message----- > From: Serge Aleynikov [mailto:serge@REDACTED] > Sent: Thursday, January 18, 2007 8:56 PM > To: Eranga Udesh > Cc: erlang-questions@REDACTED > Subject: Re: [erlang-questions] Sudden death of Erlang Node > > Eranga Udesh wrote: >> Hi, >> >> I have a very busy Erlang node running in a Quad Proc server with plenty > of >> Ram. The server utilization is quite normal. > > You indicate that you have a "very busy" node, yet it's utilization is > "quite normal". I find these definition contradictory. Could you > define the peak utilization in CPU percentage consumption? If it is, > say, over 90% that can't be considered normal. > >> However time to time, the >> Erlang node goes to sudden death without any warnings. The erlang.log.x > log >> files only show that the "heart" couldn't kill the server and the node >> restarting info. Also I cannot find any erl_crash.dump file. Later I >> introduced ERL_CRASH_DUMP and ERL_CRASH_DUMP_SECONDS environment variable >> with different settings, but no luck. I use Erlang version 11B-2. > > We've experienced a similar issue intermittently with R11B-0 (without > SMP - which is what we are running in production). The details can be > found in this thread: > > http://www.erlang.org/pipermail/erlang-questions/2006-December/024365.html > > Are you seeing the following message in the log? > > "heart: Wed Dec 13 18:59:54 2006: Erlang has closed." > > I managed to reproduce a similar issue by creating sustained CPU load at > 100%. strace showed that at some point a node failed to allocate memory > by calling mmap(). After that the node closed all file descriptors, > which was immediately detected by the "heart" process that in turn > killed and restarted the node. The only artifact seen was the error > message above in the erlang.log.x file. > > I don't know exactly if this was the same cause as we had in production > (at least the production process didn't seem to have exhausted the > memory) but the heart message in the log was identical. What else can > cause an Erlang node to close the pipe connecting it to the heart process? > > I suggest you set up a monitoring process on that machine to log some > statistics about the process (such as timestamp + /proc/PID/status), so > that you can correlate process memory with a time of the failure. > > Not sure how much this is helpful in your case, but this similar issue > pops up once every couple of months in our production system followed by > an automatic restart that remains unresolved. > > Serge > From per@REDACTED Fri Jan 19 08:41:44 2007 From: per@REDACTED (Per Hedeland) Date: Fri, 19 Jan 2007 08:41:44 +0100 (CET) Subject: [erlang-questions] How to add a option for inet:getopts In-Reply-To: <45B039D1.8040106@hq.idt.net> Message-ID: <200701190741.l0J7fiNU042365@pluto.hedeland.org> Serge Aleynikov wrote: > >The only way to get this socket option accessible from Erlang is to add >support for it in the network driver (inet_drv.c). That would be the "proper" way to do it (plus you need support at least in inet.erl, plus ssl has its own machinery for sockets and their options in the unlikely case that you'd want to use the option there), and shouldn't be insurmountable. It's a bit boring though since you'd probably need to support the mods yourself across Erlang/OTP upgrades for all future - I'd guess that the OTP group would be reluctant to incorporate support for the option as it is linux-with-iptables-specific. However another way ("untested") occurred to me: You could write a small linked-in driver to set the option, and pass it the socket file descriptor, that you can get hold of via the undocumented inet:getfd/1 function. --Per Hedeland >Serge > >William Gan wrote: >> Hello, >> >> I am preparing to implement a transparent proxy by erlang, and I need an >> equivalent call for >> 'getsockopt(fd,SOL_IP,SO_ORIGINAL_DST,&server,&slen)'. >> >> Can anyone give me some advice how to add such a call in erlang? >> >> William Gan From per@REDACTED Fri Jan 19 08:46:59 2007 From: per@REDACTED (Per Hedeland) Date: Fri, 19 Jan 2007 08:46:59 +0100 (CET) Subject: [erlang-questions] subnet masking with binary matching In-Reply-To: <45AEFF84.6000800@ghostgun.com> Message-ID: <200701190746.l0J7kwB7042413@pluto.hedeland.org> Just a side note, >jm wrote: >> Using binary matching to perform subnet masking with the following code, >> which should work with both IPv4 and IPv6 as far as I can tell, >> >> mask_address(Addr, Maskbits) -> >> B = list_to_binary(tuple_to_list(Addr)), It will actually *not* work for IPv6, as each tuple element there holds two address octets. You'd typically get a badarg from list_to_binary/1, but if you're really unlucky the thing could end up silently doing something completely wrong. --Per Hedeland From onlyou.gan@REDACTED Fri Jan 19 11:08:13 2007 From: onlyou.gan@REDACTED (William Gan) Date: Fri, 19 Jan 2007 18:08:13 +0800 Subject: [erlang-questions] How to add a option for inet:getopts In-Reply-To: <200701190741.l0J7fiNU042365@pluto.hedeland.org> References: <200701190741.l0J7fiNU042365@pluto.hedeland.org> Message-ID: <1169201293.3022.12.camel@localhost.localdomain> On Fri, 2007-01-19 at 08:41 +0100, Per Hedeland wrote: I had read the chapter 'Interoperability Tutorial' of Erlang/OTP document and understood the machinery of linked-in driver. Then I traced the call of getopts, and I understood how to modify the Erlang/OTP to fulfill my requirement. That's my work yesterday. Today I have modified the code to fulfill my requirement, but it is untested and broke the rule of transplant. Thank Serge Aleynikov and Per Hedeland for your help very much. > Serge Aleynikov wrote: > > > >The only way to get this socket option accessible from Erlang is to add > >support for it in the network driver (inet_drv.c). > > That would be the "proper" way to do it (plus you need support at least > in inet.erl, plus ssl has its own machinery for sockets and their > options in the unlikely case that you'd want to use the option there), > and shouldn't be insurmountable. It's a bit boring though since you'd > probably need to support the mods yourself across Erlang/OTP upgrades > for all future - I'd guess that the OTP group would be reluctant to > incorporate support for the option as it is > linux-with-iptables-specific. > > However another way ("untested") occurred to me: You could write a small > linked-in driver to set the option, and pass it the socket file > descriptor, that you can get hold of via the undocumented inet:getfd/1 > function. > > --Per Hedeland > > >Serge > > > >William Gan wrote: > >> Hello, > >> > >> I am preparing to implement a transparent proxy by erlang, and I need an > >> equivalent call for > >> 'getsockopt(fd,SOL_IP,SO_ORIGINAL_DST,&server,&slen)'. > >> > >> Can anyone give me some advice how to add such a call in erlang? > >> > >> William Gan From casper2000a@REDACTED Fri Jan 19 12:48:39 2007 From: casper2000a@REDACTED (Eranga Udesh) Date: Fri, 19 Jan 2007 17:18:39 +0530 Subject: [erlang-questions] Sudden death of Erlang Node In-Reply-To: <45B07047.5060408@it.su.se> Message-ID: <20070119114853.CF59619DC40C@mail.wavenet.lk> Yes, the whole node runs in One OS process. However the maximum per CPU load didn't go beyond 25% at any time. Also this particular Erlang Node's CPU utilization didn't exceed more than 15%. All the above info is from Linux TOP. Thanks, - Eranga -----Original Message----- From: Fredrik Thulin [mailto:ft@REDACTED] Sent: Friday, January 19, 2007 12:46 PM To: Eranga Udesh Cc: erlang-questions@REDACTED; 'Serge Aleynikov' Subject: Re: [erlang-questions] Sudden death of Erlang Node Eranga Udesh wrote: > Thanks for the info. > > I said "very busy" to indicate the system I am talking about handles over > 1000-1500 message passing, 750-1000 process spawning, 250-500 mnesia DB > access, 500-750 Erl Port calls, etc, Per Second (/s) kind of busyness. > However the CPU utilization doesn't go beyond 25% in any of the 4 CPU in the > system and memory is over 40% free. > > Based on that, even though my end problem seems similar, the cause for it > may not be. I am running 11B-2 compiled with SMP support, but the node is > not started in SMP mode. I'm pretty sure that if you don't start your node in SMP mode, it will only use one of your processors. Are you sure that the 25% CPU load is not really one of your four processors running at 100%? /Fredrik From kenneth.lundin@REDACTED Fri Jan 19 12:59:31 2007 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Fri, 19 Jan 2007 12:59:31 +0100 Subject: [erlang-questions] How to add a option for inet:getopts In-Reply-To: <45B039D1.8040106@hq.idt.net> References: <1169089023.4085.7.camel@localhost.localdomain> <45B039D1.8040106@hq.idt.net> Message-ID: Hi, We have preliminary planned to implement a new option called "raw" as an extension to the inet:getopts(Socket,Options) and inet:setopts(Socket,Options) and all other places where socket options are handled. The new "raw" option would look something like this: {{raw,Level,OptionCode},OptionValue} Both OptionCode and OptionValue is positive integers assumed to be mapped on UINT32 in C. Thus the use is limited to OptionValues that fits in an UINT32. Of course the inet_driver will be updated to support this as well. With this new raw option it should be possible to use various non standard and non supported socket options directly from Erlang code. Thus the example 'getsockopt(fd,SOL_IP,SO_ORIGINAL_DST,&server,&slen)'. could be implemented something like this: -define(SOL_IP,10). % the value 10 is only an example -define(SO_ORIGINAL_DST,47). % the value 47 is only an example %% The user has to find the right values from the C header files. .... inet:getopts(Socket,[{raw,$SOL_IP,$SO_ORIGINAL_DST}]) which should return [{{raw,$SOL_IP,$SO_ORIGINAL_DST},OptionValue}] Note that this is preliminary ideas which may be adjusted when we implement it. /Regards Kenneth (Erlang responsible at Ericsson) On 1/19/07, Serge Aleynikov wrote: > The only way to get this socket option accessible from Erlang is to add > support for it in the network driver (inet_drv.c). > > Serge > > William Gan wrote: > > Hello, > > > > I am preparing to implement a transparent proxy by erlang, and I need an > > equivalent call for > > 'getsockopt(fd,SOL_IP,SO_ORIGINAL_DST,&server,&slen)'. > > > > Can anyone give me some advice how to add such a call in erlang? > > > > William Gan > > > > _______________________________________________ > > 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@REDACTED Fri Jan 19 13:31:55 2007 From: per@REDACTED (Per Hedeland) Date: Fri, 19 Jan 2007 13:31:55 +0100 (CET) Subject: [erlang-questions] How to add a option for inet:getopts In-Reply-To: Message-ID: <200701191231.l0JCVtGw047932@pluto.hedeland.org> "Kenneth Lundin" wrote: > >We have preliminary planned to implement a new option called "raw" as >an extension to the >inet:getopts(Socket,Options) >and >inet:setopts(Socket,Options) >and all other places where socket options are handled. > >The new "raw" option would look something like this: >{{raw,Level,OptionCode},OptionValue} That's nice... >Both OptionCode and OptionValue is positive integers assumed to be mapped on >UINT32 in C. Thus the use is limited to OptionValues that fits in an UINT32. ... but unfortunately the example here, SO_ORIGINAL_DST, returns a 'struct sockaddr_in', so it wouldn't help in this case. Maybe you could have the value be a binary instead? (With the Erlang user being responsible for packing/unpacking it the same as a C compiler on a given host architecture would.) In that case getopts/2 would need a size too, maybe just always have that included in the "name tuple". --Per Hedeland From serge@REDACTED Fri Jan 19 14:29:51 2007 From: serge@REDACTED (Serge Aleynikov) Date: Fri, 19 Jan 2007 08:29:51 -0500 Subject: [erlang-questions] How to add a option for inet:getopts In-Reply-To: References: <1169089023.4085.7.camel@localhost.localdomain> <45B039D1.8040106@hq.idt.net> Message-ID: <45B0C7CF.40204@hq.idt.net> Kenneth, Thanks for sharing this preliminary info. As a caveat, it looks to me that this option would require to run erl with root privileges (that from the security point of view is not a good thing). There's actually a work around on Linux for this using 'cap_net_raw' capability, where you can start the process as root, set the capability and switch to effective user. This would allow to retain access to a raw socket and not to be root. If interested I can provide a sample code. Regards, Serge Kenneth Lundin wrote: > Hi, > > We have preliminary planned to implement a new option called "raw" as > an extension to the > inet:getopts(Socket,Options) > and > inet:setopts(Socket,Options) > and all other places where socket options are handled. > > The new "raw" option would look something like this: > {{raw,Level,OptionCode},OptionValue} > > Both OptionCode and OptionValue is positive integers assumed to be > mapped on > UINT32 in C. Thus the use is limited to OptionValues that fits in an > UINT32. > Of course the inet_driver will be updated to support this as well. > > With this new raw option it should be possible to use various non > standard and > non supported socket options directly from Erlang code. > Thus the example > > 'getsockopt(fd,SOL_IP,SO_ORIGINAL_DST,&server,&slen)'. > > could be implemented something like this: > > -define(SOL_IP,10). % the value 10 is only an example > -define(SO_ORIGINAL_DST,47). % the value 47 is only an example > %% The user has to find the right values from the C header files. > .... > inet:getopts(Socket,[{raw,$SOL_IP,$SO_ORIGINAL_DST}]) > > which should return > > [{{raw,$SOL_IP,$SO_ORIGINAL_DST},OptionValue}] > > Note that this is preliminary ideas which may be adjusted when we > implement it. > > /Regards Kenneth (Erlang responsible at Ericsson) > > On 1/19/07, Serge Aleynikov wrote: >> The only way to get this socket option accessible from Erlang is to add >> support for it in the network driver (inet_drv.c). >> >> Serge >> >> William Gan wrote: >> > Hello, >> > >> > I am preparing to implement a transparent proxy by erlang, and I >> need an >> > equivalent call for >> > 'getsockopt(fd,SOL_IP,SO_ORIGINAL_DST,&server,&slen)'. >> > >> > Can anyone give me some advice how to add such a call in erlang? >> > >> > William Gan From serge@REDACTED Fri Jan 19 14:55:39 2007 From: serge@REDACTED (Serge Aleynikov) Date: Fri, 19 Jan 2007 08:55:39 -0500 Subject: [erlang-questions] Sudden death of Erlang Node In-Reply-To: <20070119061602.B6E3619DC40F@mail.wavenet.lk> References: <20070119061602.B6E3619DC40F@mail.wavenet.lk> Message-ID: <45B0CDDB.4040907@hq.idt.net> The reason it doesn't record the erl_crash.dump is most likely because the emulator gets killed (with a SIGKILL) by the heart process before it has a chance to record anything useful in logs. As indicated in my last email the (only?) reason for such a harsh action on heart's behalf is that the emulator closed the file descriptor of the pipe connecting it to the heart process, and heart initiated recovery. What caused the emulator to close that file descriptor (aside from memory exhaustion) is something that have kept bothering me for a while, but given the fact that it happens very rarely makes it nearly impossible to reproduce, and strace is not practical as it would fill up all disk space by trace data before the issue occurs. Perhaps the recovery strategy of heart needs to be changed from SIGKILL to SIGTERM, followed by a short sleep to give Erlang a change and write log details before exiting, and SIGKILL after that if the emulator's PID is still running. Has anyone else seen a similar behavior or have other ideas? Serge Eranga Udesh wrote: > Thanks for the info. > > I said "very busy" to indicate the system I am talking about handles over > 1000-1500 message passing, 750-1000 process spawning, 250-500 mnesia DB > access, 500-750 Erl Port calls, etc, Per Second (/s) kind of busyness. > However the CPU utilization doesn't go beyond 25% in any of the 4 CPU in the > system and memory is over 40% free. > > Based on that, even though my end problem seems similar, the cause for it > may not be. I am running 11B-2 compiled with SMP support, but the node is > not started in SMP mode. > > In this particular node, I am running a couple of Erl Port Drivers developed > in C. > I guess if I can generate the erl_crash.dump, I should be able to find the > cause for the problem. Why it's not generating? > > What methods do I have to identify the issue in a situation like this > (activate debug, crash dump, etc)? > > Thanks, > - Eranga > > > > -----Original Message----- > From: Serge Aleynikov [mailto:serge@REDACTED] > Sent: Thursday, January 18, 2007 8:56 PM > To: Eranga Udesh > Cc: erlang-questions@REDACTED > Subject: Re: [erlang-questions] Sudden death of Erlang Node > > Eranga Udesh wrote: >> Hi, >> >> I have a very busy Erlang node running in a Quad Proc server with plenty > of >> Ram. The server utilization is quite normal. > > You indicate that you have a "very busy" node, yet it's utilization is > "quite normal". I find these definition contradictory. Could you > define the peak utilization in CPU percentage consumption? If it is, > say, over 90% that can't be considered normal. > >> However time to time, the >> Erlang node goes to sudden death without any warnings. The erlang.log.x > log >> files only show that the "heart" couldn't kill the server and the node >> restarting info. Also I cannot find any erl_crash.dump file. Later I >> introduced ERL_CRASH_DUMP and ERL_CRASH_DUMP_SECONDS environment variable >> with different settings, but no luck. I use Erlang version 11B-2. > > We've experienced a similar issue intermittently with R11B-0 (without > SMP - which is what we are running in production). The details can be > found in this thread: > > http://www.erlang.org/pipermail/erlang-questions/2006-December/024365.html > > Are you seeing the following message in the log? > > "heart: Wed Dec 13 18:59:54 2006: Erlang has closed." > > I managed to reproduce a similar issue by creating sustained CPU load at > 100%. strace showed that at some point a node failed to allocate memory > by calling mmap(). After that the node closed all file descriptors, > which was immediately detected by the "heart" process that in turn > killed and restarted the node. The only artifact seen was the error > message above in the erlang.log.x file. > > I don't know exactly if this was the same cause as we had in production > (at least the production process didn't seem to have exhausted the > memory) but the heart message in the log was identical. What else can > cause an Erlang node to close the pipe connecting it to the heart process? > > I suggest you set up a monitoring process on that machine to log some > statistics about the process (such as timestamp + /proc/PID/status), so > that you can correlate process memory with a time of the failure. > > Not sure how much this is helpful in your case, but this similar issue > pops up once every couple of months in our production system followed by > an automatic restart that remains unresolved. > > Serge > > From per@REDACTED Fri Jan 19 15:06:31 2007 From: per@REDACTED (Per Hedeland) Date: Fri, 19 Jan 2007 15:06:31 +0100 (CET) Subject: [erlang-questions] How to add a option for inet:getopts In-Reply-To: <45B0C7CF.40204@hq.idt.net> Message-ID: <200701191406.l0JE6Vpr049672@pluto.hedeland.org> Serge Aleynikov wrote: > >Thanks for sharing this preliminary info. As a caveat, it looks to me >that this option would require to run erl with root privileges (that >from the security point of view is not a good thing). There's actually >a work around on Linux for this using 'cap_net_raw' capability, where >you can start the process as root, set the capability and switch to >effective user. This would allow to retain access to a raw socket and >not to be root. What Kenneth described has nothing to do with raw sockets, it's just the option name that is "raw" - rather than encoded as an atom in Erlang and with associated knowledge of value format etc all the way down to the inet driver. What you describe is interesting/useful in other contexts, but could easily be implemented with a custom linked-in driver I believe - and this may be more appropriate anyway, since there isn't even an emerging standard for how to do these things as far as I know. --Per From serge@REDACTED Fri Jan 19 15:26:01 2007 From: serge@REDACTED (Serge Aleynikov) Date: Fri, 19 Jan 2007 09:26:01 -0500 Subject: [erlang-questions] How to add a option for inet:getopts In-Reply-To: <200701191406.l0JE6Vpr049672@pluto.hedeland.org> References: <200701191406.l0JE6Vpr049672@pluto.hedeland.org> Message-ID: <45B0D4F9.30700@hq.idt.net> Per Hedeland wrote: > What Kenneth described has nothing to do with raw sockets, it's just the > option name that is "raw" - rather than encoded as an atom in Erlang and > with associated knowledge of value format etc all the way down to the > inet driver. Sorry, I read Kenneth's email too fast and diagonally and totally missed his point! :-( The keyword "raw" brought some unrelated memories... > What you describe is interesting/useful in other contexts, but could > easily be implemented with a custom linked-in driver I believe - and > this may be more appropriate anyway, since there isn't even an emerging > standard for how to do these things as far as I know. Hmm. Is there a way to do the following call in a custom linked-in driver without being a root? socket(PF_INET, SOCK_RAW, IPPROTO_RAW); Regards, Serge From serge@REDACTED Fri Jan 19 15:28:34 2007 From: serge@REDACTED (Serge Aleynikov) Date: Fri, 19 Jan 2007 09:28:34 -0500 Subject: [erlang-questions] Sudden death of Erlang Node In-Reply-To: <45B0CDDB.4040907@hq.idt.net> References: <20070119061602.B6E3619DC40F@mail.wavenet.lk> <45B0CDDB.4040907@hq.idt.net> Message-ID: <45B0D592.7020206@hq.idt.net> BTW, if the issue is indeed related to the heart process killing the emulator, you can start the node without the "-heart" option (perhaps using alternative recovery such as a loop in the shell script starting run_erl), and seeing if you get a crash dump. Serge Serge Aleynikov wrote: > The reason it doesn't record the erl_crash.dump is most likely because > the emulator gets killed (with a SIGKILL) by the heart process before it > has a chance to record anything useful in logs. As indicated in my last > email the (only?) reason for such a harsh action on heart's behalf is > that the emulator closed the file descriptor of the pipe connecting it > to the heart process, and heart initiated recovery. > > What caused the emulator to close that file descriptor (aside from > memory exhaustion) is something that have kept bothering me for a while, > but given the fact that it happens very rarely makes it nearly > impossible to reproduce, and strace is not practical as it would fill up > all disk space by trace data before the issue occurs. > > Perhaps the recovery strategy of heart needs to be changed from SIGKILL > to SIGTERM, followed by a short sleep to give Erlang a change and write > log details before exiting, and SIGKILL after that if the emulator's PID > is still running. > > Has anyone else seen a similar behavior or have other ideas? > > Serge > > Eranga Udesh wrote: >> Thanks for the info. >> >> I said "very busy" to indicate the system I am talking about handles over >> 1000-1500 message passing, 750-1000 process spawning, 250-500 mnesia DB >> access, 500-750 Erl Port calls, etc, Per Second (/s) kind of busyness. >> However the CPU utilization doesn't go beyond 25% in any of the 4 CPU in the >> system and memory is over 40% free. >> >> Based on that, even though my end problem seems similar, the cause for it >> may not be. I am running 11B-2 compiled with SMP support, but the node is >> not started in SMP mode. >> >> In this particular node, I am running a couple of Erl Port Drivers developed >> in C. >> I guess if I can generate the erl_crash.dump, I should be able to find the >> cause for the problem. Why it's not generating? >> >> What methods do I have to identify the issue in a situation like this >> (activate debug, crash dump, etc)? >> >> Thanks, >> - Eranga >> >> >> >> -----Original Message----- >> From: Serge Aleynikov [mailto:serge@REDACTED] >> Sent: Thursday, January 18, 2007 8:56 PM >> To: Eranga Udesh >> Cc: erlang-questions@REDACTED >> Subject: Re: [erlang-questions] Sudden death of Erlang Node >> >> Eranga Udesh wrote: >>> Hi, >>> >>> I have a very busy Erlang node running in a Quad Proc server with plenty >> of >>> Ram. The server utilization is quite normal. >> You indicate that you have a "very busy" node, yet it's utilization is >> "quite normal". I find these definition contradictory. Could you >> define the peak utilization in CPU percentage consumption? If it is, >> say, over 90% that can't be considered normal. >> >>> However time to time, the >>> Erlang node goes to sudden death without any warnings. The erlang.log.x >> log >>> files only show that the "heart" couldn't kill the server and the node >>> restarting info. Also I cannot find any erl_crash.dump file. Later I >>> introduced ERL_CRASH_DUMP and ERL_CRASH_DUMP_SECONDS environment variable >>> with different settings, but no luck. I use Erlang version 11B-2. >> We've experienced a similar issue intermittently with R11B-0 (without >> SMP - which is what we are running in production). The details can be >> found in this thread: >> >> http://www.erlang.org/pipermail/erlang-questions/2006-December/024365.html >> >> Are you seeing the following message in the log? >> >> "heart: Wed Dec 13 18:59:54 2006: Erlang has closed." >> >> I managed to reproduce a similar issue by creating sustained CPU load at >> 100%. strace showed that at some point a node failed to allocate memory >> by calling mmap(). After that the node closed all file descriptors, >> which was immediately detected by the "heart" process that in turn >> killed and restarted the node. The only artifact seen was the error >> message above in the erlang.log.x file. >> >> I don't know exactly if this was the same cause as we had in production >> (at least the production process didn't seem to have exhausted the >> memory) but the heart message in the log was identical. What else can >> cause an Erlang node to close the pipe connecting it to the heart process? >> >> I suggest you set up a monitoring process on that machine to log some >> statistics about the process (such as timestamp + /proc/PID/status), so >> that you can correlate process memory with a time of the failure. >> >> Not sure how much this is helpful in your case, but this similar issue >> pops up once every couple of months in our production system followed by >> an automatic restart that remains unresolved. >> >> Serge From valentin@REDACTED Fri Jan 19 15:52:22 2007 From: valentin@REDACTED (Valentin Micic) Date: Fri, 19 Jan 2007 16:52:22 +0200 Subject: [erlang-questions] Sudden death of Erlang Node References: <20070119061602.B6E3619DC40F@mail.wavenet.lk> <45B0CDDB.4040907@hq.idt.net> Message-ID: <007a01c73bd9$aec66c90$6501a8c0@moneymaker2> Serge Aleynikov wrote: > > What caused the emulator to close that file descriptor (aside from > memory exhaustion) is something that have kept bothering me for a while, > Quite some time ago I've been asking a similar question in a slightly different context: in my particular case, an Erlang node running R9 would close a listening socket (file descriptor), that was advertised via epmd, with consequence that nobody from outside could connect to the node. Node itself would crunch its numbers happily away. Interestingly, this was happening at the same time every day, always on the same node -- enough for us to conclude that it had to be network related + particular OS patch level helped with lunar phases... out of desperation, we complied run-time for this particular OS patch level, using newer version of complier, and, to my surprise, problem hasn't occurred since. Out of curiosity, does your run-time reports to stdout something like: "driver went away without deselecting..." or some similar phrase? * * * On the other hand, Frederik noticed something very valid: 25% on quad CPU machine is 100% of a single CPU. Depending on a particular OS version, kernel may schedule beam always on a single CPU, and when this happens, heart process may not receive it's heartbeat on time... * * * What's your disk I/O like? I've noticed a very strange behaviour on beams started with a single thread (i.e. without +A n option) and running dets intensive applications. Under heavy traffic beam spends to much time waiting for I/O, thus delaying process scheduling and message processing. We had such a situation (a huge mnesia database spread over multiple dets files with relatively high I/O), and we solved it by starting additional threads. On pre-SMP Erlang, thread pool was used to support port drivers (including disk I/O), thus enabling "main" thread to run scheduling even when disk is busy. However, if you running 32-bit Erlang, do not get carried away with number of threads, because you could easily run out of memory. V. From joelr1@REDACTED Fri Jan 19 16:19:31 2007 From: joelr1@REDACTED (Joel Reymont) Date: Fri, 19 Jan 2007 15:19:31 +0000 Subject: [erlang-questions] Disabling error reporting Message-ID: <61D8DD55-F179-40E4-A35F-6E3681F65DE4@gmail.com> Folks, I'm running a bunch of tests and some include processes that fail. I'm getting a bunch of messages in the terminal like this: =ERROR REPORT==== 19-Jan-2007::15:11:13 === ** Generic server <0.1434.0> terminating ** Last message in was {'EXIT',<0.1438.0>,bummer} ** When Server state == {data,id, <0.1077.0>, user, none, [next_op], [<0.1440.0>], 1, 1} ** Reason for termination == ** {error,bummer} How do I prevent these from printing while my test harness is running? I'm not using the OTP test harness at all. Thanks, Joel -- http://wagerlabs.com/ From valentin@REDACTED Fri Jan 19 16:21:22 2007 From: valentin@REDACTED (Valentin Micic) Date: Fri, 19 Jan 2007 17:21:22 +0200 Subject: [erlang-questions] How to add a option for inet:getopts References: <200701191406.l0JE6Vpr049672@pluto.hedeland.org> <45B0D4F9.30700@hq.idt.net> Message-ID: <008e01c73bdd$7af6bbf0$6501a8c0@moneymaker2> > > Hmm. Is there a way to do the following call in a custom linked-in > driver without being a root? > > socket(PF_INET, SOCK_RAW, IPPROTO_RAW); > Interesting... if one changes shared object (implementing linked-in driver) owner to "root" and than use chmod 4755, would this make a whole run-time execute with root privileges? V. From luke@REDACTED Fri Jan 19 16:35:32 2007 From: luke@REDACTED (LUKE) Date: Fri, 19 Jan 2007 23:35:32 +0800 Subject: [erlang-questions] Can not understand the example. Message-ID: <001401c73bdf$7d76c530$0c01a8c0@lukeserver> -module(tut1). -export([fac/1]). fac(1) -> 1; fac(N) -> N * fac(N - 1). ================================== How can i know the function will STOP at N=1? =================================== -module(tut4). -export([list_length/1]). list_length([]) -> 0; list_length([First | Rest]) -> 1 + list_length(Rest). =================================== How can i know the loop will stop when First=[ ]? =================================== How to explain theses code? In perl: for (my $i=0;$i<=10;$i++){ .... } It is very clear the process will stop when $i > 10. -------------- next part -------------- An HTML attachment was scrubbed... URL: From per@REDACTED Fri Jan 19 16:41:55 2007 From: per@REDACTED (Per Hedeland) Date: Fri, 19 Jan 2007 16:41:55 +0100 (CET) Subject: [erlang-questions] How to add a option for inet:getopts In-Reply-To: <008e01c73bdd$7af6bbf0$6501a8c0@moneymaker2> Message-ID: <200701191541.l0JFftKi051592@pluto.hedeland.org> "Valentin Micic" wrote: >[Serge wrote:] >> >> Hmm. Is there a way to do the following call in a custom linked-in >> driver without being a root? >> >> socket(PF_INET, SOCK_RAW, IPPROTO_RAW); Hm, I was considering whether to waste list bandwith just to let everyone know that Serge reported in off-list mail that he realized his misunderstanding, but now it's done.:-) I.e. of course my suggestion was that the linked-in driver could do the capability-dropping (with non-standard system calls), not that it could have special privileges. >Interesting... if one changes shared object (implementing linked-in driver) >owner to "root" and than use chmod 4755, would this make a whole run-time >execute with root privileges? Nope - runtime-loading of a shared object doesn't count as "execution" on any Unix I know of, thus setuid is irrelevant (and even execute permission is irrelevant IIRC - at least it should be). --Per From tobbe@REDACTED Fri Jan 19 16:55:33 2007 From: tobbe@REDACTED (Torbjorn Tornkvist) Date: Fri, 19 Jan 2007 16:55:33 +0100 Subject: [erlang-questions] Can not understand the example. In-Reply-To: <001401c73bdf$7d76c530$0c01a8c0@lukeserver> References: <001401c73bdf$7d76c530$0c01a8c0@lukeserver> Message-ID: LUKE wrote: > -module(tut1). > -export([fac/1]). > > fac(1) -> > 1; > fac(N) -> > N * fac(N - 1). > ================================== > How can i know the function will STOP at N=1? > =================================== > -module(tut4). > > -export([list_length/1]). > > list_length([]) -> > 0; > list_length([First | Rest]) -> > 1 + list_length(Rest). > =================================== > How can i know the loop will stop when First=[ ]? > =================================== > How to explain theses code? > > In perl: > for (my $i=0;$i<=10;$i++){ > .... > } > > It is very clear the process will stop when $i > 10. > Ha ha...thank god its Friday :-) --Tobbe From richardc@REDACTED Fri Jan 19 16:58:53 2007 From: richardc@REDACTED (Richard Carlsson) Date: Fri, 19 Jan 2007 16:58:53 +0100 Subject: [erlang-questions] Can not understand the example. In-Reply-To: <001401c73bdf$7d76c530$0c01a8c0@lukeserver> References: <001401c73bdf$7d76c530$0c01a8c0@lukeserver> Message-ID: <45B0EABD.20001@it.uu.se> LUKE wrote: > -module(tut1). > -export([fac/1]). > > fac(1) -> > 1; > fac(N) -> > N * fac(N - 1). > ================================== > How can i know the function will STOP at N=1? The clauses are always tested in top-down order. /Richard From xpdoka@REDACTED Fri Jan 19 17:00:48 2007 From: xpdoka@REDACTED (Dominic Williams) Date: Fri, 19 Jan 2007 17:00:48 +0100 (CET) Subject: [erlang-questions] Disabling error reporting Message-ID: <32271.217.128.75.198.1169222448.squirrel@www.geekisp.com> Hi Joel, > How do I prevent these from printing while my test harness is running? You need to set {error_logger, false} or {error_logger, file, "MyFile"} in the kernel application. Details depend on how you start the node on which the tests run. If you start it by hand, you do: erl -kernel error_logger false If you start a slave node: slave:start(myhost, mynode, "-kernel error_logger false"). Otherwise in a .app file (check app(3) documentation). Cheers, Dominic Williams http://www.dominicwilliams.net ---- From headspin@REDACTED Fri Jan 19 17:03:34 2007 From: headspin@REDACTED (dda) Date: Fri, 19 Jan 2007 17:03:34 +0100 Subject: [erlang-questions] The Third ACM SIGPLAN History of Programming Languages Conference (HOPL-III) Message-ID: Dunno whether this was posted before, but... http://research.ihost.com/hopl/ The Third ACM SIGPLAN History of Programming Languages Conference (HOPL-III) San Diego, California, June 9-10, 2007 (co-located with FCRC 2007, June 9-16, 2007) in cooperation with ACM SIGSOFT Accepted Papers for HOPL-III are: * "A history of Erlang" by Joe Armstrong [etc...] Nice to see Erlang accepted... The selection so far is a bit, er, eclectic, to say the least. -- dda From joelr1@REDACTED Fri Jan 19 17:05:46 2007 From: joelr1@REDACTED (Joel Reymont) Date: Fri, 19 Jan 2007 16:05:46 +0000 Subject: [erlang-questions] Disabling error reporting In-Reply-To: <32271.217.128.75.198.1169222409.squirrel@www.geekisp.com> References: <61D8DD55-F179-40E4-A35F-6E3681F65DE4@gmail.com> <32271.217.128.75.198.1169222409.squirrel@www.geekisp.com> Message-ID: <7C2D03F5-996D-4F21-831F-367FC7BDC607@gmail.com> On Jan 19, 2007, at 4:00 PM, Dominic Williams wrote: > > erl -kernel error_logger false Now I get a bunch of these: {error_logger,{{2007,1,19},{16,3,44}},"** Generic server ~p terminating \n** Last message in was ~p~n** When Server state == ~p~n** Reason for termination == ~n** ~p~n",[<0.172.0>, {exit,bummer},none,bummer]} {error_logger,{{2007,1,19},{16,3,44}},crash_report,[[{pid,<0.172.0>}, {registered_name,[]},{error_info,bummer},{initial_call,{gen,init_it, [gen_server,<0.168.0>,<0.168.0>,dummy_task,[10,bummer],[]]}}, {ancestors,[<0.168.0>,<0.37.0>]},{messages,[]},{links,[<0.168.0>]}, {dictionary,[]},{trap_exit,true},{status,running},{heap_size,377}, {stack_size,21},{reductions,114}],[]]} Thanks, Joel -- http://wagerlabs.com/ From mickael.remond@REDACTED Fri Jan 19 17:18:32 2007 From: mickael.remond@REDACTED (=?ISO-8859-1?Q?Micka=EBl_R=E9mond?=) Date: Fri, 19 Jan 2007 17:18:32 +0100 Subject: [erlang-questions] Sponsoring: Looking for a Windows network developer In-Reply-To: References: Message-ID: <991D45ED-C7A5-4F3B-A9B5-9A615226A414@process-one.net> Hello, Le 16 d?c. 06 ? 14:48, Micka?l R?mond a ?crit : > Hello, > > We are looking for a Windows network developer to analyse the > Erlang enotsock problem on some Windows XP installation and provide > a fix. As a follow-up: The problem has been fixed. Thank you to Michael Fogeborg, Jani Hakala and Kenneth Lundin. For those interested, more details are available from: http://www.process-one.net/en/blogs/article/ erlang_networking_fixed_on_windows_xp/ Cheers, -- Micka?l R?mond http://www.process-one.net/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf.wiger@REDACTED Fri Jan 19 19:09:19 2007 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Fri, 19 Jan 2007 19:09:19 +0100 Subject: [erlang-questions] Can not understand the example. In-Reply-To: <001401c73bdf$7d76c530$0c01a8c0@lukeserver> Message-ID: <6616D98C65DD514BA2E1DDC5F92231556D8452@esealmw115.eemea.ericsson.se> Perhaps you should read the on-line erlang course: http://www.erlang.org/course/course.html Especially: http://www.erlang.org/course/sequential_programming.html To answer your question, the following quote from the above course: Clauses are scanned sequentially until a match is found. Perhaps another missing detail is that the return value of a function is the result of the last expression. In the case of fac(1), it's the number 1. Also from the above course: Evaluation example factorial(0) -> 1; factorial(N) -> N * factorial(N-1) > factorial(3) matches N = 3 in clause 2 == 3 * factorial(3 - 1) == 3 * factorial(2) matches N =2 in clause 2 == 3 * 2 * factorial(2 - 1) == 3 * 2 * factorial(1) matches N = 1 in clause 2 == 3 * 2 * 1 * factorial(1 - 1) == 3 * 2 * 1 * factorial(0) == 3 * 2 * 1 * 1 (clause 1) == 6 BR, Ulf W ________________________________ From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of LUKE Sent: den 19 januari 2007 16:36 To: erlang-questions@REDACTED Subject: [erlang-questions] Can not understand the example. -module(tut1). -export([fac/1]). fac(1) -> 1; fac(N) -> N * fac(N - 1). ================================== How can i know the function will STOP at N=1? =================================== -module(tut4). -export([list_length/1]). list_length([]) -> 0; list_length([First | Rest]) -> 1 + list_length(Rest). =================================== How can i know the loop will stop when First=[ ]? =================================== How to explain theses code? In perl: for (my $i=0;$i<=10;$i++){ .... } It is very clear the process will stop when $i > 10. -------------- next part -------------- An HTML attachment was scrubbed... URL: From valentin@REDACTED Fri Jan 19 19:56:24 2007 From: valentin@REDACTED (Valentin Micic) Date: Fri, 19 Jan 2007 20:56:24 +0200 Subject: [erlang-questions] How to add a option for inet:getopts References: <200701191541.l0JFftKi051592@pluto.hedeland.org> Message-ID: <00b001c73bfb$875cbb60$6501a8c0@moneymaker2> --Per wrote: > > Nope - runtime-loading of a shared object doesn't count as "execution" > on any Unix I know of, thus setuid is irrelevant (and even execute > permission is irrelevant IIRC - at least it should be). > Thanks. Makes sense. V. From Martin.Logan@REDACTED Fri Jan 19 22:58:37 2007 From: Martin.Logan@REDACTED (Logan, Martin) Date: Fri, 19 Jan 2007 15:58:37 -0600 Subject: [erlang-questions] build system In-Reply-To: References: Message-ID: <26AB42AB6A76E2419D26E66ECF1538468B35E2@chiresexc02.resource.corp.lcl> > * What (will) make a difference (if any) between erlware and sinan? This is a conversion that Martin and I have spent a lot of time on. In the end it comes down to your preference. erlware has the concept of a central build area for all of your erlang projects. Its also built around make and shell scripts. Erlware has a very unixy feel that many may find appealing. Sinan does a per project or per application build (though the dependency repo is shared). Sinan is written and extensible in Erlang. If anything Sinan feels like a much smarter version of java's ant then anything else. They both understand and require OTP infrastructure in the projects that they are capable of building. They both use the same repository format. They both are capable of generating 'getting started' project templates that are buildable from the get go. There are a lot of similarities between the two in output. However, they approach the problem of building otp apps very differently. I don't believe that one is intrinsically superior then the other, its just a matter of which you are more comfortable with. This was stated quite well. Both will get you to where you want to go. If you are the type of person that thrives on new innovative ideas and is not afraid of something different that very well could improve the way you do things Sinan could be just right for you, alternatively, if you are a real linux/unix head and prefer to use something that may be more familiar to you perhaps you may find erlware to be a more comfortable environment. Cheers, Martin From jeffm@REDACTED Sat Jan 20 01:50:20 2007 From: jeffm@REDACTED (jm) Date: Sat, 20 Jan 2007 11:50:20 +1100 Subject: [erlang-questions] [Fwd: Re: subnet masking with binary matching] Message-ID: <45B1674C.4040705@ghostgun.com> Meant to email this to the list not directly. -------- Original Message -------- Thanks. I'll have to keep that in mind. I haven't looked at the IPv6 support that closely it's just in the back of my mind at the moment. As long as the code is structured correctly with no major assumptions I'm hoping that in will be a simple matter to go back and tweak a few lines here and there. Jeff. Per Hedeland wrote: > Just a side note, > >> jm wrote: >>> Using binary matching to perform subnet masking with the following code, >>> which should work with both IPv4 and IPv6 as far as I can tell, >>> >>> mask_address(Addr, Maskbits) -> >>> B = list_to_binary(tuple_to_list(Addr)), > > It will actually *not* work for IPv6, as each tuple element there holds > two address octets. You'd typically get a badarg from list_to_binary/1, > but if you're really unlucky the thing could end up silently doing > something completely wrong. > > --Per Hedeland From casper2000a@REDACTED Sat Jan 20 03:32:35 2007 From: casper2000a@REDACTED (Eranga Udesh) Date: Sat, 20 Jan 2007 08:02:35 +0530 Subject: [erlang-questions] Sudden death of Erlang Node In-Reply-To: <007a01c73bd9$aec66c90$6501a8c0@moneymaker2> Message-ID: <20070120023234.07A1E19DC42E@mail.wavenet.lk> Thanks for the info. I've also experienced the File Descriptor issue a long time back. I am convinced that occurred due to an exhaustion of CPU at that time. I ran my system in Dual CPU machine on Erlang 10B, so it actually ran only in a single OS Process, so occupying a single CPU. I was using RH 3.0 and due to OS native IOWait issue it RH has, IOWait took almost 100% of the CPU and suddenly the connectivity from external nodes or pipe stopped. However all the local node processing as well as connectivity with already connected nodes worked without any issues. * * * I use RH 3.0 release 3 and its TOP utility shows individual CPU processing utilization. So when I said 25%, it's the utilization of that CPU which had the maximum utilization, but all others utilization were lower than that. * * * I think I didn't say a single OS Thread, but a single OS Process. I use +A option and the Erl node is started with +A192, so the whole node runs in 192 OS Threads. However since the -smp flag is not used, it only runs in a single OS Process with 192 OS Threads. Thanks, - Eranga -----Original Message----- From: Valentin Micic [mailto:valentin@REDACTED] Sent: Friday, January 19, 2007 8:22 PM To: Serge Aleynikov; Eranga Udesh Cc: erlang-questions@REDACTED Subject: Re: [erlang-questions] Sudden death of Erlang Node Serge Aleynikov wrote: > > What caused the emulator to close that file descriptor (aside from > memory exhaustion) is something that have kept bothering me for a while, > Quite some time ago I've been asking a similar question in a slightly different context: in my particular case, an Erlang node running R9 would close a listening socket (file descriptor), that was advertised via epmd, with consequence that nobody from outside could connect to the node. Node itself would crunch its numbers happily away. Interestingly, this was happening at the same time every day, always on the same node -- enough for us to conclude that it had to be network related + particular OS patch level helped with lunar phases... out of desperation, we complied run-time for this particular OS patch level, using newer version of complier, and, to my surprise, problem hasn't occurred since. Out of curiosity, does your run-time reports to stdout something like: "driver went away without deselecting..." or some similar phrase? * * * On the other hand, Frederik noticed something very valid: 25% on quad CPU machine is 100% of a single CPU. Depending on a particular OS version, kernel may schedule beam always on a single CPU, and when this happens, heart process may not receive it's heartbeat on time... * * * What's your disk I/O like? I've noticed a very strange behaviour on beams started with a single thread (i.e. without +A n option) and running dets intensive applications. Under heavy traffic beam spends to much time waiting for I/O, thus delaying process scheduling and message processing. We had such a situation (a huge mnesia database spread over multiple dets files with relatively high I/O), and we solved it by starting additional threads. On pre-SMP Erlang, thread pool was used to support port drivers (including disk I/O), thus enabling "main" thread to run scheduling even when disk is busy. However, if you running 32-bit Erlang, do not get carried away with number of threads, because you could easily run out of memory. V. From rasmussen.bryan@REDACTED Sat Jan 20 21:45:45 2007 From: rasmussen.bryan@REDACTED (bryan rasmussen) Date: Sat, 20 Jan 2007 21:45:45 +0100 Subject: [erlang-questions] yaws and lighttpd? Message-ID: <3bb44c6e0701201245h196c0155s2c8303da93a301ed@mail.gmail.com> I've seen the apache benchmarks of course, any lighttpd erlang benchmarks out there? cheers, Bryan Rasmussen From ok@REDACTED Mon Jan 22 06:13:44 2007 From: ok@REDACTED (Richard A. O'Keefe) Date: Mon, 22 Jan 2007 18:13:44 +1300 (NZDT) Subject: [erlang-questions] String encoding and character set Message-ID: <200701220513.l0M5DiEN179142@atlas.otago.ac.nz> I pointed out that the presence of floating diacriticals makes the ordinary word "character" ambiguous when applied to Unicode. dda wrote: Those "floating diacritics" are handled through Normalisation. No, they are not. Normalisation means that each combination of base character plus diacriticals will be encoded in one and only one way (just _which_ way depends on which of several different kinds of normalisation you choose), but it does not and cannot eliminate any and every floating diactrical. For example, consider the sequence U+0028 LEFT PARENTHESIS U+0302 COMBINING CIRCUMFLEX ACCENT This will *display* as a single "character" (equivalent to "\^(" in TeX) but it is two *codepoints* and Normalisation will do NOTHING about this, because these codepoints are already in the right order and there is no precomposed left parenthesis with circumflex the sequence could be normalised to. An intelligent set of string functions should be able to normalize strings Indeed it should. But in those *normalised* strings some characters will be one codepoint and many will NOT, and there is no easy way to tell which are which without looking at each. and extract a character correctly whether it was originally encoded on one or two codepoints. Originally shmoriginally. That doesn't matter. *AFTER* normalisation some characters will require more than one codepoint, and anyone who doesn't understand that does not yet understand Unicode. Parsing only with regexes is slow Compared with what? And be sure to compare apples with apples: regular expressions *can* be compiled to native code and in my view *should* be. Most regular expression implementations compile to some sort of byte code, but that's not the fault of regular expressions as such. even on languages that have fast-ish regexes [Erlang's alas not in this case]. Be specific. Which languages (more precisely, which libraries) do you have in mind? Bearing in mind that there is no reason whatever why they *couldn't* compile to native code, which ones did you measure that do? While I do like regexes, there's a lot that can be done faster with dedicated string manipulation functions. The last time I was able to enumerate all the programming languages I knew, the list ran to about 200. I have met remarkably few with tolerable "dedicated string manipulation functions". I still dwell with glee on the performance comparisons I did between Xerox Quintus Prolog (using 2-word list cells and definite clause grammars for string manipulation) and Xerox Interlisp-D (using 1 byte per character and with special helper microcode). The general mechanism was *faster*. (In retrospect, the main reason was probably that using DCGs for parsing instead of string functions meant a whole LOT less copying.) I repeat that > The fundamental operations on strings are > > (1) decode binary to string using some encoding > (2) encode string to binary using some encoding > (3) compare using locale- and application-appropriate rules ===> > (4) parse, typically using regular expressions ===> > (5) unparse There is no "one size fits all" string representation. Some make parsing easy, some make unparsing easy;. From ok@REDACTED Mon Jan 22 06:16:42 2007 From: ok@REDACTED (Richard A. O'Keefe) Date: Mon, 22 Jan 2007 18:16:42 +1300 (NZDT) Subject: [erlang-questions] lists:reverse/1 as a built-in function Message-ID: <200701220516.l0M5GgjA175233@atlas.otago.ac.nz> Robert Baruch wrote: I've been working with Java since 1.1 (which is, like, *forever* in Internet time!) and the package naming and resolution scheme has never confused me. Without having any point to address other than "Java sucks", though, I guess that means I won't bother anymore with advocating a Java-like solution :/ I, on the other hand, have been working with Java since 0.9 (yes, really, well, OK, supervising students working with Java 0.9). I didn't say that "the package naming and resolution scheme" was CONFUSING. It's just inside-out, and as a result far clumsier than it ever needed to be. (The same applies to the Erlang imitation of it.) From gordonguthrie@REDACTED Mon Jan 22 09:07:03 2007 From: gordonguthrie@REDACTED (Gordon Guthrie) Date: Mon, 22 Jan 2007 08:07:03 -0000 (GMT) Subject: [erlang-questions] Yaws problem with erl_ddll Message-ID: <64143.82.41.159.220.1169453223.squirrel@backawinner.gg> Folks Ubuntu Edgy Eft has Erlang RB10 and yaws available as packages, lovely, lets install them. Then trying to get yaws to run I hit the problem that other people have with setuid_drv not being loaded - see here http://www.erlang.org/pipermail/erlang-questions/2006-November/023941.html No problem uninstall the packages and install from source: * Erlang R11B-2 * Yaws-1.66 Same problem! First up I check if setuid_drv is on the machine and has sensible permissions: gordonguthrie@REDACTED:/usr/local/lib/yaws/priv$ ls -all total 40 drwxr-xr-x 2 root root 4096 2007-01-22 07:33 . drwxr-xr-x 6 root root 4096 2007-01-21 23:51 .. -rwxr-xr-x 1 root root 18466 2007-01-22 07:33 epam -rwxr-xr-x 1 root root 9695 2007-01-22 07:33 setuid_drv.so A bit more digging shows that the setuid_drv.so is failing to load, the relevant line in yaws.erl is in the function getuid() erl_ddll:load_driver(filename:dirname(code:which(?MODULE)) ++ "/../priv/", "setuid_drv"), The return value for this isn't being checked, but returns {error,{open_error,-10}} The parameters being passed in seem fine: 2> filename:dirname(code:which(yaws)). "/usr/local/lib/yaws/ebin" So, time to look into erl_ddll.erl and see what happens, at which point the trail goes cold. The return code (error,{open_error,-10}} comes from these lines: do_load_driver(Path, Driver, DriverFlags) -> case erl_ddll:try_load(Path, Driver,[{monitor,pending}]++DriverFlags) of But there is no sign of the function erl_ddl:try_load... It is not defined in erl_ddll.erl, grepping the entire source tree shows no evidence of it... What am I missing? Gordon <--- scratching head! From kostis@REDACTED Mon Jan 22 09:36:44 2007 From: kostis@REDACTED (Kostis Sagonas) Date: Mon, 22 Jan 2007 09:36:44 +0100 Subject: [erlang-questions] Yaws problem with erl_ddll In-Reply-To: <64143.82.41.159.220.1169453223.squirrel@backawinner.gg> References: <64143.82.41.159.220.1169453223.squirrel@backawinner.gg> Message-ID: <45B4779C.4020301@cs.ntua.gr> Gordon Guthrie wrote: > Folks > > Ubuntu Edgy Eft has Erlang RB10 and yaws available as packages, lovely, > lets install them. > > [SNIP] > > But there is no sign of the function erl_ddl:try_load... > > It is not defined in erl_ddll.erl, grepping the entire source tree shows > no evidence of it... > > What am I missing? This function is implemented in C (erts/emulator/beam/erl_bif_ddll.c). Kostis From ft@REDACTED Mon Jan 22 09:39:15 2007 From: ft@REDACTED (Fredrik Thulin) Date: Mon, 22 Jan 2007 09:39:15 +0100 Subject: [erlang-questions] Yaws problem with erl_ddll In-Reply-To: <64143.82.41.159.220.1169453223.squirrel@backawinner.gg> References: <64143.82.41.159.220.1169453223.squirrel@backawinner.gg> Message-ID: <45B47833.8060304@it.su.se> Gordon Guthrie wrote: ... > It is not defined in erl_ddll.erl, grepping the entire source tree shows > no evidence of it... > > What am I missing? See my mail to the yaws mailing list before the weekend. The problem is that gcc is used for building setuid_drv, but ld is used for linking. http://sourceforge.net/mailarchive/forum.php?thread_id=31498404&forum_id=12456 /Fredrik From xpdoka@REDACTED Mon Jan 22 10:07:51 2007 From: xpdoka@REDACTED (Dominic Williams) Date: Mon, 22 Jan 2007 10:07:51 +0100 (CET) Subject: [erlang-questions] Disabling error reporting In-Reply-To: <7C2D03F5-996D-4F21-831F-367FC7BDC607@gmail.com> References: <61D8DD55-F179-40E4-A35F-6E3681F65DE4@gmail.com> <32271.217.128.75.198.1169222409.squirrel@www.geekisp.com> <7C2D03F5-996D-4F21-831F-367FC7BDC607@gmail.com> Message-ID: <5009.217.128.75.198.1169456871.squirrel@www.geekisp.com> >> erl -kernel error_logger false > > Now I get a bunch of these: > > {error_logger,{{2007,1,19},{16,3,44}},"** Generic server ~p > terminating \n** Last message in was ~p~n** When Server state == > ~p~n** Reason for termination == ~n** ~p~n",[<0.172.0>, > {exit,bummer},none,bummer]} > {error_logger,{{2007,1,19},{16,3,44}},crash_report,[[{pid,<0.172.0>}, > {registered_name,[]},{error_info,bummer},{initial_call,{gen,init_it, > [gen_server,<0.168.0>,<0.168.0>,dummy_task,[10,bummer],[]]}}, > {ancestors,[<0.168.0>,<0.37.0>]},{messages,[]},{links,[<0.168.0>]}, > {dictionary,[]},{trap_exit,true},{status,running},{heap_size,377}, > {stack_size,21},{reductions,114}],[]]} Well, this appears to be a bug that appeared somewhere around R10B. It used to work. The {file, "log"} still works fine: erl -kernel error_logger "{file,\"log\"}" Regards, Dominic Williams http://www.dominicwilliams.net ---- From vladdu55@REDACTED Mon Jan 22 10:34:43 2007 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Mon, 22 Jan 2007 10:34:43 +0100 Subject: [erlang-questions] Calling C code Message-ID: <95be1d3b0701220134w67d4b94egb98ead6c0d9ec840@mail.gmail.com> Hi all, I have a tricky question. I have a distributed application that needs to do some simulations. Not very extensive, but a lot of them. Doing it in Erlang is way too slow and talking through a port is also too slow, but I really need the distribution and the higher level stuff that Erlang provides. Question 1: by using a linked-in driver, are the calls direct, or do they go through the same layers as to a port? If the answer above is "as to a port", then I had this idea: since hipe is compiling to native code, it might be possible to convince it to create a stub that will just call a statically linked C routine. Now this isn't anything that should be a general feature of Erlang, but for this particular application it would be acceptable to use a tweaked VM. Question 2 (going mainly to the hipe team), is whether this is feasible at all. Thank you in advance! Best regards, Vlad From mikpe@REDACTED Mon Jan 22 11:20:28 2007 From: mikpe@REDACTED (Mikael Pettersson) Date: Mon, 22 Jan 2007 11:20:28 +0100 (MET) Subject: [erlang-questions] Calling C code Message-ID: <200701221020.l0MAKSWA006960@harpo.it.uu.se> On Mon, 22 Jan 2007 10:34:43 +0100, Vlad Dumitrescu wrote: > I have a tricky question. I have a distributed application that needs > to do some simulations. Not very extensive, but a lot of them. Doing > it in Erlang is way too slow and talking through a port is also too > slow, but I really need the distribution and the higher level stuff > that Erlang provides. > > Question 1: by using a linked-in driver, are the calls direct, or do > they go through the same layers as to a port? > > If the answer above is "as to a port", then I had this idea: since > hipe is compiling to native code, it might be possible to convince it > to create a stub that will just call a statically linked C routine. > > Now this isn't anything that should be a general feature of Erlang, > but for this particular application it would be acceptable to use a > tweaked VM. > > Question 2 (going mainly to the hipe team), is whether this is feasible at all. I think you would be much better off just adding a few BIFs that contain your C code, or calls into your C code. When native code calls C code there some important glue in between. That glue is implemented by a per-C-function stub statically compiled into the runtime system. But you can't just call random C stuff from these stubs, they're very much only intended for calling BIFs and a small set of helper procedures for the HiPE compiler. Alternatively you can try to rework your application to batch requests so that the calling mechanism isn't performance-critical any more. /Mikael From vladdu55@REDACTED Mon Jan 22 11:37:26 2007 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Mon, 22 Jan 2007 11:37:26 +0100 Subject: [erlang-questions] Calling C code In-Reply-To: <200701221020.l0MAKSWA006960@harpo.it.uu.se> References: <200701221020.l0MAKSWA006960@harpo.it.uu.se> Message-ID: <95be1d3b0701220237s41047f5djdd699577f8808fa9@mail.gmail.com> Hi, On 1/22/07, Mikael Pettersson wrote: > On Mon, 22 Jan 2007 10:34:43 +0100, Vlad Dumitrescu wrote: > > If the answer above is "as to a port", then I had this idea: since > > hipe is compiling to native code, it might be possible to convince it > > to create a stub that will just call a statically linked C routine. > > > > Question 2 (going mainly to the hipe team), is whether this is feasible at all. > > I think you would be much better off just adding a few BIFs that > contain your C code, or calls into your C code. Ok, I see. I was hoping that there was an easier way than writing BIFs. > When native code calls C code there some important glue in between. > That glue is implemented by a per-C-function stub statically compiled > into the runtime system. But you can't just call random C stuff from > these stubs, they're very much only intended for calling BIFs and > a small set of helper procedures for the HiPE compiler. The C code isn't really random, it just does some computations and is almost completely self-contained (only uses functions in "math.h") and the algorithm is time-bounded. A perfect candidate for a BIF :-) I will look at how lists:reverse/1 is implemented, maybe it's not that difficult as I thought. > Alternatively you can try to rework your application to batch requests > so that the calling mechanism isn't performance-critical any more. Yes, this is an alternative. Trouble is that I need to supervise the simulations, and I feel that it might be easier to go the "native call" way than the other. Thanks! Best regards, Vlad From lenartlad@REDACTED Mon Jan 22 11:52:35 2007 From: lenartlad@REDACTED (Ladislav Lenart) Date: Mon, 22 Jan 2007 11:52:35 +0100 Subject: [erlang-questions] OO programming style in Erlang? Message-ID: <45B49773.5040105@volny.cz> Hello, I started to program in Erlang recently and have some "conceptual issues" I am pretty sure you could help me with... [1] Suppose I have to write a piece of functionality. I can implement this functionality in a library module fun_lib.erl which essentially consists of two types of functions: * get_something(InternalState) -> something * set_something(InternalState, Something) -> NewInternalState But I can as well implement this functionality in two modules, fun.erl and fun_cb.erl where fun_cb.erl is a gen_server (or any other behavior) callback module and fun.erl is the public interface API for communicating with the process, i.e.: fun:something(Pid) -> gen_server:cast(Pid, something). I could combine these two solutions as well by implementing fun_lib module first and then implement fun_cb in terms of fun_lib. *Question:* Based on what should I decide how a particular piece of functionality should be implemented? *Question:* Is this division recommended or should I put all these parts (library, public process API and callback functions) to just one module, fun.erl? [2] I have an OO experience and I like the basic ideas of encapsulation and polymorphism but can not find a way how to materialize these in my Erlang programs. For example, there are dict and orddict modules which have compatible (polymorphic) interfaces but differ in their implementations. This is essentially good, but when I actually use one of these modules, my code will look like orddict:new() orddict:store(...) But this is bad because when I later decide to change (my) implementation I actually have to go through my code and replace orddict with dict. So this is not a polymorphism I am looking for. Next problem (from this point of view) is pattern matching which commands me to implement all the polymorphic behaviors in one module and implement as many branches of each function as many different (but polymorphic) behaviors there should be. But I don't like this because it means to modify an existing module instead of extending it by writing a new (but polymorphic) one next to it. According to this idea, there would be only one dict module which would merge orddict and unordered dict (and any later) implementations... *Question:* Is there a way such polymorphism can be achieved in Erlang without actually merging (see above) the modules that should behave polymorphically? Please don't take this as a critic of Erlang, but rather as a request of an OO programmer to ease his transition to the new fascinating world of concurrent programming... Hints, tips and tricks are also welcome. Thank you, Ladislav Lenart From ulf@REDACTED Mon Jan 22 12:39:10 2007 From: ulf@REDACTED (Ulf Wiger) Date: Mon, 22 Jan 2007 12:39:10 +0100 Subject: [erlang-questions] OO programming style in Erlang? In-Reply-To: <45B49773.5040105@volny.cz> References: <45B49773.5040105@volny.cz> Message-ID: Den 2007-01-22 11:52:35 skrev Ladislav Lenart : > *Question:* Based on what should I decide how a particular > piece of functionality should be implemented? As far as possible, try to separate side-effect free code from that with side-effects. Typically, at least 90% of your code can be made side-effect free, and it's a good idea to really isolate the remaining 10%. This also affects your interface design. Try to make sure that your interfaces do not mandate side-effects. Compare e.g. dict.erl and ets.erl ets:insert(Tab, Obj) -> true % mandates side-effects dict:store(Key, Value, Dict1) -> Dict2 % doesn't > For example, there are dict and orddict modules which have compatible > (polymorphic) interfaces but differ in their implementations. This is > essentially good, but when I actually use one of these modules, my > code will look like > > orddict:new() > orddict:store(...) > > But this is bad because when I later decide to change (my) > implementation I actually have to go through my code and > replace orddict with dict. So this is not a polymorphism > I am looking for. A fairly common solution to this dilemma is to use your own wrapper functions dict_new() -> orddict:new(). etc. You could also use a macro, of course: -define(DICT, orddict). ?DICT:store(...) but I much prefer the wrapper function. One reason is that ?DICT can really be any syntactic expression, so anytime a macro is used, the reader has to make sure he/she knows what's hidden behind it. > *Question:* Is there a way such polymorphism can be > achieved in Erlang without actually merging (see above) > the modules that should behave polymorphically? No universally agreed upon common method, no, if I understood your question correctly. Xmerl, for example, introduced a notion of module inheritance, with which one were supposed to extend the functionality of export callbacks. See e.g. http://jungerl.cvs.sourceforge.net/jungerl/jungerl/lib/xmerl/src/xmerl.erl?revision=1.2&view=markup mainly lines 267-313. (or the OTP source tree for a more current version.) I don't know if anyone has actually made use of it. BR, Ulf W -- Ulf Wiger From kostis@REDACTED Mon Jan 22 12:44:01 2007 From: kostis@REDACTED (Kostis Sagonas) Date: Mon, 22 Jan 2007 13:44:01 +0200 Subject: [erlang-questions] OO programming style in Erlang? In-Reply-To: <45B49773.5040105@volny.cz> References: <45B49773.5040105@volny.cz> Message-ID: <45B4A381.3040806@cs.ntua.gr> Ladislav Lenart wrote: > > [2] > I have an OO experience and I like the basic ideas of encapsulation > and polymorphism but can not find a way how to materialize these in > my Erlang programs. > > For example, there are dict and orddict modules which have compatible > (polymorphic) interfaces but differ in their implementations. This is > essentially good, but when I actually use one of these modules, my > code will look like > > orddict:new() > orddict:store(...) > > But this is bad because when I later decide to change (my) implementation > I actually have to go through my code and replace orddict with dict. So > this is not a polymorphism I am looking for. One way of avoiding this problem is the one we follow in various modules of the HiPE compiler. We use the preprocessor as follows: -define(DICT, orddict). and then write all calls as: ?DICT:new() ?DICT:store(...) Not really deep, but it does what we want. Kostis From patrick@REDACTED Mon Jan 22 13:01:54 2007 From: patrick@REDACTED (Patrick Collison) Date: Mon, 22 Jan 2007 12:01:54 +0000 Subject: [erlang-questions] Mnesia and primary keys Message-ID: Hi, I'm new to both Erlang and Mnesia, and having trouble wrapping my head around how Mnesia handles primary keys. Suppose (in a RDBMS) I have two tables -- customers and orders. One customer may have many orders. Ordinarily, of course, this would be solved by having some a customer_id that each row in the order table references. Bog-standard stuff. As far as I can see (from reading the documentation I can find), Mnesia doesn't assist you in any way in creating such primary keys (as PostgreSQL, Oracle, MySQL (and pretty much any other systems) do). Ensuring uniqueness, incrementing IDs, etc., seems to be left up to the application programmer. Am I missing the correct, "Erlang-style" manner of implementing this kind of trivial cross-referencing, or am I unaware of facilities that Mnesia does actually provide? Cheers, -Patrick From mats.cronqvist@REDACTED Mon Jan 22 13:11:46 2007 From: mats.cronqvist@REDACTED (Mats Cronqvist) Date: Mon, 22 Jan 2007 13:11:46 +0100 Subject: [erlang-questions] OO programming style in Erlang? In-Reply-To: <45B4A381.3040806@cs.ntua.gr> References: <45B49773.5040105@volny.cz> <45B4A381.3040806@cs.ntua.gr> Message-ID: <45B4AA02.8070906@ericsson.com> Kostis Sagonas wrote: > Ladislav Lenart wrote: >> [2] >> I have an OO experience and I like the basic ideas of encapsulation >> and polymorphism but can not find a way how to materialize these in >> my Erlang programs. >> >> For example, there are dict and orddict modules which have compatible >> (polymorphic) interfaces but differ in their implementations. This is >> essentially good, but when I actually use one of these modules, my >> code will look like >> >> orddict:new() >> orddict:store(...) >> >> But this is bad because when I later decide to change (my) implementation >> I actually have to go through my code and replace orddict with dict. So >> this is not a polymorphism I am looking for. > > One way of avoiding this problem is the one we follow in various modules > of the HiPE compiler. We use the preprocessor as follows: > > -define(DICT, orddict). > > and then write all calls as: > > ?DICT:new() > ?DICT:store(...) > > Not really deep, but it does what we want. i personally prefer the import statement in cases like this; -import(orddict,[new/0,store/3]). the code becomes; new(), store(...) mats From chsu79@REDACTED Mon Jan 22 13:23:08 2007 From: chsu79@REDACTED (Christian S) Date: Mon, 22 Jan 2007 13:23:08 +0100 Subject: [erlang-questions] Mnesia and primary keys In-Reply-To: References: Message-ID: This seems to be what you want: http://www.erlang.org/ml-archive/erlang-questions/200508/msg00291.html PS. Primary key is not exactly the same concept as "autoincrement" or "unique" key fields. From sean.hinde@REDACTED Mon Jan 22 13:23:53 2007 From: sean.hinde@REDACTED (Sean Hinde) Date: Mon, 22 Jan 2007 12:23:53 +0000 Subject: [erlang-questions] OO programming style in Erlang? In-Reply-To: References: <45B49773.5040105@volny.cz> Message-ID: <7CD50168-D053-4158-95AD-1E502A99F9B0@gmail.com> On 22 Jan 2007, at 11:39, Ulf Wiger wrote: > Den 2007-01-22 11:52:35 skrev Ladislav Lenart : > >> *Question:* Is there a way such polymorphism can be >> achieved in Erlang without actually merging (see above) >> the modules that should behave polymorphically? > > No universally agreed upon common method, no, > if I understood your question correctly. > > Xmerl, for example, introduced a notion of module > inheritance, with which one were supposed to extend > the functionality of export callbacks. See e.g. > http://jungerl.cvs.sourceforge.net/jungerl/jungerl/lib/xmerl/src/ > xmerl.erl?revision=1.2&view=markup > mainly lines 267-313. > (or the OTP source tree for a more current version.) > > I don't know if anyone has actually made use of it. I suspect not. IMO the most important thing to take away from this discussion is that OO style is not the normal or best way to program in Erlang. Try not to think of erlang processes as simply repositories of state - they are so much more than that.. Model each real world activity as an erlang process, and have each process maintain as much state as it needs to function as that real world process. The API into the process would not typically be get/set operations, but real world calls like make_sale() or purchase(). It can all be at a much higher level using Erlang. If you also follow the other advice in Ulf's post you will be getting there :-) Sean From patrick@REDACTED Mon Jan 22 13:34:46 2007 From: patrick@REDACTED (Patrick Collison) Date: Mon, 22 Jan 2007 12:34:46 +0000 Subject: [erlang-questions] Mnesia and primary keys In-Reply-To: References: Message-ID: <6F3681C8-EB55-4EBC-A0B5-B6F7B677BEB3@collison.ie> Cool, that helps -- thanks. On a broader level, though, _should_ I be approaching Mnesia in this way? Is there any better way of maintaining relations than doing all the ID creation manually? Can Mnesia deal with constraints like uniqueness? (Some Googling doesn't throw up anything obvious.) Cheers, -Patrick On 22 Jan 2007, at 12:23, Christian S wrote: > This seems to be what you want: > > http://www.erlang.org/ml-archive/erlang-questions/200508/msg00291.html > > PS. > Primary key is not exactly the same concept as "autoincrement" or > "unique" > key fields. From chsu79@REDACTED Mon Jan 22 13:51:15 2007 From: chsu79@REDACTED (Christian S) Date: Mon, 22 Jan 2007 13:51:15 +0100 Subject: [erlang-questions] Mnesia and primary keys In-Reply-To: <6F3681C8-EB55-4EBC-A0B5-B6F7B677BEB3@collison.ie> References: <6F3681C8-EB55-4EBC-A0B5-B6F7B677BEB3@collison.ie> Message-ID: Creating unique keys and implementing joins to extract data is a perfectly fine relational database approach. Mnesia allows you to customize your db access to get those last microseconds out of your queries, this is why it is so "raw" compared to SQL databases. There are some candy available out there to make it less time consuming to write db code: rdbms in jungerl.sourceforge.net, and there is qlc which comes with Erlang/OTP. On 1/22/07, Patrick Collison wrote: > Cool, that helps -- thanks. > > On a broader level, though, _should_ I be approaching Mnesia in this > way? Is there any better way of maintaining relations than doing all > the ID creation manually? Can Mnesia deal with constraints like > uniqueness? (Some Googling doesn't throw up anything obvious.) > > Cheers, > > -Patrick > > On 22 Jan 2007, at 12:23, Christian S wrote: > > > This seems to be what you want: > > > > http://www.erlang.org/ml-archive/erlang-questions/200508/msg00291.html > > > > PS. > > Primary key is not exactly the same concept as "autoincrement" or > > "unique" > > key fields. > > From lenartlad@REDACTED Mon Jan 22 13:52:44 2007 From: lenartlad@REDACTED (Ladislav Lenart) Date: Mon, 22 Jan 2007 13:52:44 +0100 Subject: [erlang-questions] OO programming style in Erlang? In-Reply-To: References: <45B49773.5040105@volny.cz> Message-ID: <45B4B39C.3060106@volny.cz> Ulf Wiger wrote: > As far as possible, try to separate side-effect free code > from that with side-effects. Typically, at least 90% of > your code can be made side-effect free, and it's a good > idea to really isolate the remaining 10%. > > This also affects your interface design. Try to make > sure that your interfaces do not mandate side-effects. > Compare e.g. dict.erl and ets.erl > > ets:insert(Tab, Obj) -> true % mandates side-effects > dict:store(Key, Value, Dict1) -> Dict2 % doesn't Does this mean that 90% should be implemented as a library functions and the reminding 10% should be isolated in a process? > A fairly common solution to this dilemma is to use > your own wrapper functions > > dict_new() -> > orddict:new(). > > etc. > > You could also use a macro, of course: > > -define(DICT, orddict). > > ?DICT:store(...) > > but I much prefer the wrapper function. > One reason is that ?DICT can really be any > syntactic expression, so anytime a macro is > used, the reader has to make sure he/she knows > what's hidden behind it. The macro is an obvious solution I wasn't aware of. Thank you. The problem with wrapper function without using the macro is that change of dict type still means to change all wrapper functions. But one interesting solution using a wrapper module comes to my mind now: %%% Read: dictionary interface -module(dict_int). %%% Common dict interface -export([new_orddict/0, new_dict/0, store/3, fetch/2, ...]). %% Two public "instance" creation functions. new_orddict() -> new(orddict). new_dict() -> new(dict). %% Private instance creation function. new(Impl) -> {Impl, Impl:new()}. %% Setter function. store(Key, Value, {Impl, Dict}) -> {Impl, Impl:store(Key, Value, Dict)}. %% Getter functions. fetch(Key, {Impl, Dict}) -> Impl:fetch(Key, Dict). Using this "pattern", one could maybe come up with more abstract interfaces, for example: %%% Read: collection interface -module(cltn_int) -export([new_list/0, new_dict/0, foreach/2, ...]). foreach({lists, Cltn}, OneArgFun) -> lists:foreach(OneArgFun, Cltn); foreach({Impl, Cltn}, OneArgFun) when Impl == dict or Impl == orddict -> List = Impl:to_list(Cltn), foreach({lists, List}, OneArgFun). But the problem is that all this work is left to the application programmer and so it might turn out to be not worth doing at all. What do you think? I will stick to macro or macro/wrapper function combination for some time... >> *Question:* Is there a way such polymorphism can be >> achieved in Erlang without actually merging (see above) >> the modules that should behave polymorphically? > > No universally agreed upon common method, no, > if I understood your question correctly. > > Xmerl, for example, introduced a notion of module > inheritance, with which one were supposed to extend > the functionality of export callbacks. See e.g. > http://jungerl.cvs.sourceforge.net/jungerl/jungerl/lib/xmerl/src/xmerl.erl?revision=1.2&view=markup > > mainly lines 267-313. > (or the OTP source tree for a more current version.) I was explicitly omiting inheritance from my set of questions because it is not an essential OO feature to me... Thank you again for your anwers (you all), Ladislav Lenart From ulf@REDACTED Mon Jan 22 14:03:50 2007 From: ulf@REDACTED (Ulf Wiger) Date: Mon, 22 Jan 2007 14:03:50 +0100 Subject: [erlang-questions] OO programming style in Erlang? In-Reply-To: <7CD50168-D053-4158-95AD-1E502A99F9B0@gmail.com> References: <45B49773.5040105@volny.cz> <7CD50168-D053-4158-95AD-1E502A99F9B0@gmail.com> Message-ID: Den 2007-01-22 13:23:53 skrev Sean Hinde : > On 22 Jan 2007, at 11:39, Ulf Wiger wrote: > >> Den 2007-01-22 11:52:35 skrev Ladislav Lenart : >> >>> *Question:* Is there a way such polymorphism can be >>> achieved in Erlang without actually merging (see above) >>> the modules that should behave polymorphically? >> >> No universally agreed upon common method, no, >> if I understood your question correctly. >> >> Xmerl, for example, introduced a notion of module >> inheritance, [...] >> >> I don't know if anyone has actually made use of it. > > I suspect not. > > IMO the most important thing to take away from this > discussion is that OO style is not the normal or > best way to program in Erlang. I read that as Sean's very polite way of dismissing that last piece of "advice" as utter crap. (: I should perhaps have stated more clearly that I didn't mean to suggest that I had a good solution, and the rest of the community didn't get it. Suffice it to say that I wrote that code originally back in 2000, and I've never reused the concept since. I agree fully with Sean. BR, Ulf W -- Ulf Wiger From ulf@REDACTED Mon Jan 22 14:31:49 2007 From: ulf@REDACTED (Ulf Wiger) Date: Mon, 22 Jan 2007 14:31:49 +0100 Subject: [erlang-questions] OO programming style in Erlang? In-Reply-To: <45B4B39C.3060106@volny.cz> References: <45B49773.5040105@volny.cz> <45B4B39C.3060106@volny.cz> Message-ID: Den 2007-01-22 13:52:44 skrev Ladislav Lenart : > Ulf Wiger wrote: > > As far as possible, try to separate side-effect free code > > from that with side-effects. Typically, at least 90% of > > your code can be made side-effect free, and it's a good > > idea to really isolate the remaining 10%. > > [...] > > Does this mean that 90% should be implemented as a > library functions and the reminding 10% should be > isolated in a process? Well, it is highly implementation-specific how you choose to use processes, but the above probably works as a rule of thumb. See e.g. Joe Armstrong's PhD thesis, Making Reliable Systems in the Presence of Software Errors, esp. chapters 4 and 8. (http://www.sics.se/~joe/thesis/armstrong_thesis_2003.pdf) There are different types of side-effects: processes, ets tables, process dictionary, mnesia, ... All have their place, but functions that do not depend on side-effects are much easier to debug and reason about, so it's important to structure the use of side-effects. It could also be that one first puts data in an ets table, and later decides that it's better to have a gen_server or other keeping the data. If ets accesses are littered all over the place, this is obviously very difficult to change. > But one interesting solution using a wrapper > module comes to my mind now: [...] You may want to read Richard Carlsson's Parameterized Modules in Erlang: http://www.erlang.se/workshop/2003/paper/p29-carlsson.pdf The concepts described in the paper have actually been implemented, albeit flagged as 'experimental'. BR, Ulf W -- Ulf Wiger From klacke@REDACTED Mon Jan 22 15:22:39 2007 From: klacke@REDACTED (Claes Wikstrom) Date: Mon, 22 Jan 2007 15:22:39 +0100 Subject: [erlang-questions] build system In-Reply-To: <26AB42AB6A76E2419D26E66ECF1538468B35E2@chiresexc02.resource.corp.lcl> References: <26AB42AB6A76E2419D26E66ECF1538468B35E2@chiresexc02.resource.corp.lcl> Message-ID: <45B4C8AF.3060200@hyber.org> Logan, Martin wrote: > > This was stated quite well. Both will get you to where you want to go. > If you are the type of person that thrives on new innovative ideas and > is not afraid of something different that very well could improve the > way you do things Sinan could be just right for you, alternatively, if > you are a real linux/unix head and prefer to use something that may be > more familiar to you perhaps you may find erlware to be a more > comfortable environment. Or ehhhumm, In the latter case I might prefer to just write a normal Makefile. /klacke From autophile@REDACTED Mon Jan 22 15:43:37 2007 From: autophile@REDACTED (Robert Baruch) Date: Mon, 22 Jan 2007 09:43:37 -0500 Subject: [erlang-questions] lists:reverse/1 as a built-in function In-Reply-To: <200701220516.l0M5GgjA175233@atlas.otago.ac.nz> References: <200701220516.l0M5GgjA175233@atlas.otago.ac.nz> Message-ID: <372BD4A8-C398-4854-BC30-F202532DDA15@zoominternet.net> On Jan 22, 2007, at 12:16 AM, Richard A. O'Keefe wrote: > I didn't say that "the package naming and resolution scheme" was > CONFUSING. It's just inside-out, and as a result far clumsier than > it ever needed to be. (The same applies to the Erlang imitation of > it.) Well, if that's the case, then would it make any difference if the proposal were modified so that the package naming scheme is reversed? So that instead of importing, say, erlang.lang.lists, we import lists.lang.erlang? Or maybe would you rather have just a flat package namespace? I really don't understand why the package naming scheme is inside-out -- it only looks that way to me when compared to domain names. To me, it's reasonable to have the package naming scheme reflect the directory structure. I don't know any directory structure that uses, say "lib" first, then "src" and then the name of the application -- they use app/src/lib for the source code to app's library. If you could elaborate on what you find inside-out and clumsy, then maybe the proposal could be modified. But I'm still not sure what concrete objections there are. --Rob From lenartlad@REDACTED Mon Jan 22 17:14:48 2007 From: lenartlad@REDACTED (Ladislav Lenart) Date: Mon, 22 Jan 2007 17:14:48 +0100 Subject: [erlang-questions] OO programming style in Erlang? In-Reply-To: References: <45B49773.5040105@volny.cz> <45B4B39C.3060106@volny.cz> Message-ID: <45B4E2F8.2090305@volny.cz> Ulf Wiger wrote: > You may want to read Richard Carlsson's > Parameterized Modules in Erlang: > http://www.erlang.se/workshop/2003/paper/p29-carlsson.pdf > > The concepts described in the paper have actually been > implemented, albeit flagged as 'experimental'. Sounds very interesting to me. Do you know by change if this feature will be ported to standard Erlang implementation? Ladislav Lenart From ulf@REDACTED Mon Jan 22 17:41:21 2007 From: ulf@REDACTED (Ulf Wiger) Date: Mon, 22 Jan 2007 17:41:21 +0100 Subject: [erlang-questions] OO programming style in Erlang? In-Reply-To: <45B4E2F8.2090305@volny.cz> References: <45B49773.5040105@volny.cz> <45B4B39C.3060106@volny.cz> <45B4E2F8.2090305@volny.cz> Message-ID: Den 2007-01-22 17:14:48 skrev Ladislav Lenart : > Ulf Wiger wrote: >> You may want to read Richard Carlsson's >> Parameterized Modules in Erlang: >> http://www.erlang.se/workshop/2003/paper/p29-carlsson.pdf >> >> The concepts described in the paper have actually been >> implemented, albeit flagged as 'experimental'. > > Sounds very interesting to me. > Do you know by change if this feature will > be ported to standard Erlang implementation? They are implemented in the standard Erlang distribution. They are just not officially supported, nor documented. BR, Ulf W -- Ulf Wiger From nem@REDACTED Mon Jan 22 21:04:54 2007 From: nem@REDACTED (Geoff Cant) Date: Tue, 23 Jan 2007 09:04:54 +1300 Subject: [erlang-questions] Supervisors, control over restart timing Message-ID: Hi all, I'm wondering if there's a standard/idiomatic way of controlling the restart timing within a supervisor. I have a supervisor that supervises a number of connections to external servers. I'd like these to reconnect with exponential backoff between attempts. The supervisor seems like a natural place to do this, but I haven't seen anything in the OTP docs to suggest a way to do it. Am I trying to put this functionality in the wrong place? How does everyone else do this? Cheers, -- Geoff -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 185 bytes Desc: not available URL: From Martin.Logan@REDACTED Mon Jan 22 21:16:37 2007 From: Martin.Logan@REDACTED (Logan, Martin) Date: Mon, 22 Jan 2007 14:16:37 -0600 Subject: [erlang-questions] build system In-Reply-To: <45B4C8AF.3060200@hyber.org> References: <26AB42AB6A76E2419D26E66ECF1538468B35E2@chiresexc02.resource.corp.lcl> <45B4C8AF.3060200@hyber.org> Message-ID: <26AB42AB6A76E2419D26E66ECF1538468B35F8@chiresexc02.resource.corp.lcl> -----Original Message----- From: Claes Wikstrom [mailto:klacke@REDACTED] Sent: Monday, January 22, 2007 8:23 AM To: Logan, Martin Cc: Eric Merritt; Ludovic Coquelle; Erlang Subject: Re: [erlang-questions] build system Logan, Martin wrote: > > This was stated quite well. Both will get you to where you want to go. > If you are the type of person that thrives on new innovative ideas and > is not afraid of something different that very well could improve the > way you do things Sinan could be just right for you, alternatively, if > you are a real linux/unix head and prefer to use something that may be > more familiar to you perhaps you may find erlware to be a more > comfortable environment. Or ehhhumm, In the latter case I might prefer to just write a normal Makefile. Klake, The problem with rolling your own make file, and hence the whole reason for writing a build system like Erlware OTP Base in the first place, is that the make file changes from project to project. Having projects that all have different build environments can become unmanageable in a one man dev shop, in a multi person professional environment it spells massive inefficiency. In my experience a standardized build environment is the bedrock that good software development is built on. At Orbitz where I currently work not having a standard environment would grind our development to a halt. Consistency across teams is one of the main attributes of our environment that makes it possible for our teams to work together as efficiently as they do. Cheers, Martin From dmitry.kargapolov@REDACTED Mon Jan 22 22:48:08 2007 From: dmitry.kargapolov@REDACTED (Dmitriy Kargapolov) Date: Mon, 22 Jan 2007 16:48:08 -0500 Subject: [erlang-questions] async driver in multithread mode - segmentation fault Message-ID: <45B53118.50509@corp.idt.net> Hi, I was trying to implement asynchronous driver which is invoked in a separate thread. It crashes with "segmentation fail" message when second call is issued, in driver_async(). I'm attaching dummy short test which shows the problem. I intentionally removed from the code most of driver_free() calls to reduce potential problem source. following command makes it failed: erl +A4 -noshell -s drv t -s init stop but no-thread-pool one works fine: erl -noshell -s drv t -s init stop Tested in R11-0, R11-2, smp and non-smp Linux. Any idea / help is appreciated. Thanks. -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: drv.c URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: drv.erl URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: Makefile URL: From per@REDACTED Tue Jan 23 01:41:06 2007 From: per@REDACTED (Per Hedeland) Date: Tue, 23 Jan 2007 01:41:06 +0100 (CET) Subject: [erlang-questions] Calling C code In-Reply-To: <95be1d3b0701220134w67d4b94egb98ead6c0d9ec840@mail.gmail.com> Message-ID: <200701230041.l0N0f6gC041260@pluto.hedeland.org> "Vlad Dumitrescu" wrote: > >I have a tricky question. I have a distributed application that needs >to do some simulations. Not very extensive, but a lot of them. Doing >it in Erlang is way too slow and talking through a port is also too >slow, but I really need the distribution and the higher level stuff >that Erlang provides. > >Question 1: by using a linked-in driver, are the calls direct, or do >they go through the same layers as to a port? It seems this question wasn't actually answered - and the answer is perhaps not obvious since the question is a bit weird.:-) The only way to interact with a linked-in driver is through a port, so of course it's not just "as" but actually "to a port"... However I suspect that maybe by "a port" you mean "an external port program", and in that case there is of course a potentially huge difference in communication overhead compared to a linked-in driver, as the external program runs in a separate OS process (i.e. there will be context switches) and all communication is via pipes. Whether that means that "the calls are direct" depends on what calls you're thinking of:-) - as the interaction is through a port, there's no way to "directly" "call" arbitrary functions in the driver, and depending on what data you want to exchange with the driver, it may need some processing by your Erlang code and/or the runtime system, but it's all "just" function calls within the same process. Undoubtedly BIFs are more "direct", but it may not motivate going down that path... --Per Hedeland From ok@REDACTED Tue Jan 23 04:01:45 2007 From: ok@REDACTED (Richard A. O'Keefe) Date: Tue, 23 Jan 2007 16:01:45 +1300 (NZDT) Subject: [erlang-questions] lists:reverse/1 as a bui\lt-in function Message-ID: <200701230301.l0N31jet182036@atlas.otago.ac.nz> I wrote that Java's package scheme is "inside-out". Robert Baruch misread "inside-out" as "back-to-front" and asked Well, if that's the case, then would it make any difference if the proposal were modified so that the package naming scheme is reversed? So that instead of importing, say, erlang.lang.lists, we import lists.lang.erlang? Or maybe would you rather have just a flat package namespace? Neither. The issue is not "which order to we write dotted names", but "where do we START from"? Java chose absolute package names. That is what is bad. To take just one obvious example, suppose a group of classes/modules are developed by the Acme Widget company, so all those dotted names start out nz.co.acme_widget.intercal. Then the Acme Widget company get taken over by Southern Doohicky, Inc, and now we *want* the names to be au.com.southern_doohickey.intercal. Because package names are *absolute*, every dotted package name has to be changed. But if dotted names were *relative* to the containing class/ module, only one name in the entire build would need changing. unnnecessarily There are some occasions when you want absolute names, typically when referring to the library that came with the language. But when you have much of your own code, what you nearly always want is relative names so that renaming and sharing are easier. I really don't understand why the package naming scheme is inside-out -- it only looks that way to me when compared to domain names. That's because you have misread "inside-out" as "back to front". I don't care (as yet) whether dotted names are written left to right or right to left, but it matters a lot where they start from. From niranjan@REDACTED Tue Jan 23 04:17:58 2007 From: niranjan@REDACTED (Niranjan Gunasekera) Date: Tue, 23 Jan 2007 09:17:58 +0600 Subject: [erlang-questions] async driver in multithread mode - segmentationfault References: <45B53118.50509@corp.idt.net> Message-ID: <03f701c73e9d$1f6d68c0$850810ac@wavenet.lk> Yes I have the same problem. I have sent a mail to this community, but haven't got a reply yet. The driver_async works fine with R10B-10. I have the problem with R11-2 (I haven't test it with R11-0) Pls help. Thanks Niranjan Gunasekera ----- Original Message ----- From: "Dmitriy Kargapolov" To: Cc: Sent: Tuesday, January 23, 2007 3:48 AM Subject: [erlang-questions] async driver in multithread mode - segmentationfault > Hi, > I was trying to implement asynchronous driver which is invoked in a > separate thread. It crashes with "segmentation fail" message when second > call is issued, in driver_async(). > > I'm attaching dummy short test which shows the problem. I intentionally > removed from the code most of driver_free() calls to reduce potential > problem source. > > following command makes it failed: > erl +A4 -noshell -s drv t -s init stop > but no-thread-pool one works fine: > erl -noshell -s drv t -s init stop > > Tested in R11-0, R11-2, smp and non-smp Linux. > Any idea / help is appreciated. > Thanks. > ---------------------------------------------------------------------------- ---- > > #include > #include > > /* Driver interface declarations */ > > static int init(void); > static ErlDrvData start(ErlDrvPort port, char *command); > static void stop(ErlDrvData drv_data); > static void finish(void); > static void output(ErlDrvData drv_data, char *buf, int len); > static void ready_async(ErlDrvData drv_data, ErlDrvThreadData async_data); > > static ErlDrvEntry test_driver_entry = { > init, /* init */ > start, /* start */ > stop, /* stop */ > output, /* output */ > NULL, /* ready_input */ > NULL, /* ready_output */ > "drv", /* the name of the driver */ > finish, /* finish */ > NULL, /* handle */ > NULL, /* control */ > NULL, /* timeout */ > NULL, /* outputv */ > ready_async, /* ready_async */ > NULL, /* flush */ > NULL, /* call */ > NULL /* event */ > }; > > /* INITIALIZATION AFTER LOADING */ > > /* > * This is the init function called after this driver has been loaded. > * It must *not* be declared static. Must return the address to > * the driver entry. > */ > > DRIVER_INIT(test_drv) > { > return &test_driver_entry; > } > > // This is called directly after the driver has been loaded by erl_ddll:load_driver/2 > // > static int init(void) > { > fprintf(stderr, "init called from %0X\r\n", pthread_self()); > } > > typedef struct { > ErlDrvPort port; > } my_drv_data; > > static ErlDrvData start(ErlDrvPort port, char *command) > { > fprintf(stderr, "start(%0X, %s) called from\r\n", port, command, pthread_self()); > if (port == NULL) { > return ERL_DRV_ERROR_GENERAL; > } > my_drv_data *data = driver_alloc (sizeof(my_drv_data)); > if (data == NULL) { > return ERL_DRV_ERROR_GENERAL; > } > data->port = port; > return (ErlDrvData) data; > } > > static void stop(ErlDrvData drv_data) > { > fprintf(stderr, "stop(%0X) called from thread %0X\r\n", drv_data, pthread_self()); > if (drv_data == 0) return; > fprintf(stderr, "port used by stop(): %0X\r\n", ((my_drv_data *) drv_data)->port); > // driver_free (drv_data); > } > > static void finish() > { > fprintf(stderr, "finish() called from thread %0X\r\n", pthread_self()); > } > > static void do_invoke(void *data) > { > fprintf(stderr, "do_invoke(%0X) called from thread %0X\r\n", data, pthread_self()); > } > > static void do_free(void *data) > { > fprintf(stderr, "do_free(%0X) called from thread %0X\r\n", data, pthread_self()); > } > > static void ready_async(ErlDrvData drv_data, ErlDrvThreadData async_data) > { > fprintf(stderr, "ready_async(%0X, %0X) called from thread %0X\r\n", drv_data, async_data, pthread_self()); > if (drv_data == 0) return; > ErlDrvPort port = ((my_drv_data *) drv_data)->port; > fprintf(stderr, "port used by ready_async(): %0X\r\n", port); > ei_x_buff *test = driver_alloc (sizeof (ei_x_buff)); > ei_x_new_with_version (test); > ei_x_encode_atom (test, "aaa"); > driver_output(port, test->buff, test->index); > } > > static void output(ErlDrvData drv_data, char *buf, int len) > { > fprintf(stderr, "output(%0X, %0X, %d) called from thread %0X\r\n", drv_data, buf, len, pthread_self()); > if (len <= 0) return; > if (drv_data == 0) return; > ErlDrvPort port = ((my_drv_data *) drv_data)->port; > fprintf(stderr, "port used by output(): %0X\r\n", port); > driver_async (port, NULL, do_invoke, NULL, do_free); > } > ---------------------------------------------------------------------------- ---- > > -module(drv). > -compile(export_all). > > % test api > > -define(SERVER, ?MODULE). > > start(Path) -> > gen_server:start({local, ?SERVER}, ?MODULE, Path, []). > > test_call(Msg) -> > gen_server:call(?SERVER, {test, self(), Msg}). > > % gen_server callbacks > > -record(state, {port}). > > init(Path) -> > process_flag(trap_exit, true), > OpenPort = fun() -> > case catch open_port({spawn, drv}, [binary]) of > Port when is_port(Port) -> > {ok, #state{port = Port}}; > Error -> > {stop, Error} > end > end, > case erl_ddll:load_driver(Path, "drv") of > ok -> > OpenPort(); > {error, already_loaded} -> > OpenPort(); > Other -> > {stop, Other} > end. > > handle_call(Msg, From, State = #state{port = Port}) when is_port(Port) -> > port_command(Port, term_to_binary({From, Msg})), > {noreply, State}; > > handle_call(_Msg, _From, State) -> > {reply, ok, State}. > > handle_cast(_Msg, State) -> > {noreply, State}. > > handle_info({Port, {data, Bin}}, State) when is_port(Port), is_binary(Bin) -> > case binary_to_term(Bin) of > {data, To, Msg} -> > gen_server:reply(To, {data, Msg}); > Other -> > io:format("test> unknown reply: ~p~n", [Other]) > end, > {noreply, State}; > > handle_info(Msg, State) -> > io:format("test> other message: ~p~n", [Msg]), > {noreply, State}. > > terminate(_Reason, #state{port = Port}) when is_port(Port) -> > port_close(Port), > ok; > > terminate(_Reason, _State) -> > ok. > > code_change(_OldVsn, State, _Extra) -> > {ok, State}. > > % end of gen_server callbacks > > t() -> > start("."), > Ret1 = (catch test_call("lalala")), > io:format("~nret1: '~p'~n", [Ret1]), > Ret2 = (catch test_call("pipipi")), > io:format("~nret2: '~p'~n", [Ret2]). > ---------------------------------------------------------------------------- ---- > > ERL_TOP = /opt/erlang/current/lib/erlang > > EI_ROOT = $(ERL_TOP)/lib/erl_interface-3.5.5.2 > > EI_INCLUDE = -I$(ERL_TOP)/usr/include -I$(EI_ROOT)/include > > EI_LIB = -L$(EI_ROOT)/lib -lei > > OUR_C_FLAGS = -g -Wall -fpic $(EI_INCLUDE) > CFLAGS += $(OUR_C_FLAGS) > CXXFLAGS += $(OUR_C_FLAGS) > > EBIN_DIR = . > ERLC = $(ERL_TOP)/bin/erlc > ERLC_FLAGS = -W > > TARGETS = drv.beam drv.so > > all: $(TARGETS) > > clean: > rm -f $(TARGETS) *.o > rm -f core erl_crash.dump > rm -f *~ > > %.so: %.cc > $(CXX) $(CXXFLAGS) $< -shared -o $@ > > %.so: %.o > $(CC) $(CFLAGS) -shared $< $(EI_LIB) -o $@ > > %: %.cc > $(CXX) $(CXXFLAGS) $< -o $@ > > %.beam: %.erl > $(ERLC) $(ERLC_FLAGS) -o $(EBIN_DIR) $< > ---------------------------------------------------------------------------- ---- > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From vladdu55@REDACTED Tue Jan 23 09:16:40 2007 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Tue, 23 Jan 2007 09:16:40 +0100 Subject: [erlang-questions] Calling C code In-Reply-To: <200701230041.l0N0f6gC041260@pluto.hedeland.org> References: <95be1d3b0701220134w67d4b94egb98ead6c0d9ec840@mail.gmail.com> <200701230041.l0N0f6gC041260@pluto.hedeland.org> Message-ID: <95be1d3b0701230016j5e88e15y72782a83ea32558e@mail.gmail.com> Hi, On 1/23/07, Per Hedeland wrote: > "Vlad Dumitrescu" wrote: > >Question 1: by using a linked-in driver, are the calls direct, or do > >they go through the same layers as to a port? > > It seems this question wasn't actually answered - and the answer is > perhaps not obvious since the question is a bit weird.:-) The only way > to interact with a linked-in driver is through a port, so of course it's > not just "as" but actually "to a port"... However I suspect that maybe > by "a port" you mean "an external port program", and in that case there > is of course a potentially huge difference in communication overhead > compared to a linked-in driver, as the external program runs in a > separate OS process (i.e. there will be context switches) and all > communication is via pipes. > > Whether that means that "the calls are direct" depends on what calls > you're thinking of:-) - as the interaction is through a port, there's no > way to "directly" "call" arbitrary functions in the driver, and > depending on what data you want to exchange with the driver, it may need > some processing by your Erlang code and/or the runtime system, but it's > all "just" function calls within the same process. Undoubtedly BIFs are > more "direct", but it may not motivate going down that path... You are right, of course... It is a mix of mixing things up a little (external port vs linked in driver) and of badly formulating the question... and a bit of not rtfm, actually :-) The layers I referred to were actually the serialization layer used in communicating with a port. What I would really like to be able to do is to be able to access Erlang data directly, i.e. have a pointer to the data, not a serialized form or a copy of it -- which is safe if it is read-only, as in my case, but not in the general case. But for that a BIF may be needed... I am investigating alternative solutions, I was just hoping there was a relatively quick way to test how this could work or I have to take a completely different approach. Thanks! best regards, Vlad From adam@REDACTED Tue Jan 23 16:13:46 2007 From: adam@REDACTED (Adam Lindberg) Date: Tue, 23 Jan 2007 16:13:46 +0100 Subject: [erlang-questions] OO programming style in Erlang? In-Reply-To: <7CD50168-D053-4158-95AD-1E502A99F9B0@gmail.com> References: <45B49773.5040105@volny.cz> <7CD50168-D053-4158-95AD-1E502A99F9B0@gmail.com> Message-ID: <6344005f0701230713k3ef64ba6j52f5e430d4977fec@mail.gmail.com> As a side topic regarding OO and Erlang ways of thinking, here's a good article about Erlang and concurrency. It touches object orientation and comparisons with Java for example, and is somewhat of a mind opener. :-) http://www.defmacro.org/ramblings/concurrency.html On 1/22/07, Sean Hinde wrote: > > On 22 Jan 2007, at 11:39, Ulf Wiger wrote: > > > Den 2007-01-22 11:52:35 skrev Ladislav Lenart : > > > >> *Question:* Is there a way such polymorphism can be > >> achieved in Erlang without actually merging (see above) > >> the modules that should behave polymorphically? > > > > No universally agreed upon common method, no, > > if I understood your question correctly. > > > > Xmerl, for example, introduced a notion of module > > inheritance, with which one were supposed to extend > > the functionality of export callbacks. See e.g. > > http://jungerl.cvs.sourceforge.net/jungerl/jungerl/lib/xmerl/src/ > > xmerl.erl?revision=1.2&view=markup > > mainly lines 267-313. > > (or the OTP source tree for a more current version.) > > > > I don't know if anyone has actually made use of it. > > I suspect not. > > IMO the most important thing to take away from this discussion is > that OO style is not the normal or best way to program in Erlang. > > Try not to think of erlang processes as simply repositories of state > - they are so much more than that.. Model each real world activity as > an erlang process, and have each process maintain as much state as it > needs to function as that real world process. > > The API into the process would not typically be get/set operations, > but real world calls like make_sale() or purchase(). It can all be at > a much higher level using Erlang. > > If you also follow the other advice in Ulf's post you will be getting > there :-) > > Sean > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- Adam Lindberg Mobile: +46734228920 From sean.hinde@REDACTED Tue Jan 23 16:29:07 2007 From: sean.hinde@REDACTED (Sean Hinde) Date: Tue, 23 Jan 2007 15:29:07 +0000 Subject: [erlang-questions] OO programming style in Erlang? In-Reply-To: <6344005f0701230713k3ef64ba6j52f5e430d4977fec@mail.gmail.com> References: <45B49773.5040105@volny.cz> <7CD50168-D053-4158-95AD-1E502A99F9B0@gmail.com> <6344005f0701230713k3ef64ba6j52f5e430d4977fec@mail.gmail.com> Message-ID: <1CD865CB-E081-4302-B21E-2F6237821549@gmail.com> Nice and well written article. I've been thinking about making a blog post with the title "Erlang is objects done right" But given the amount of free time I have these days I might as well summarise it here: Two events from the past came together in my mind recently. For many years before becoming an Erlang addict I tried half heartedly to learn "programming". My job did not require it, but it seemed like a useful skill. I recall becoming very frustrated with the concept that calling a method of an object was referred to as sending the object a message. How can it be sending a message I thought - messages are things that can only be passed between things with their own parallel existence. That attempt to learn that language (possibly C++, I don't recall) soon ended in distraction. The second event 8 or 9 years later was a conversation with possibly the world's greatest C++ zealot. One argument used to persuade me to give up on Erlang for C++ included the phrase "But Sean, you are the most object oriented guy I know. Erlang is all about sending messages between objects". I could only agree. So, I conclude Erlang is objects done right. This should not be taken as any kind of contradiction to my statement quoted below :-) Sean On 23 Jan 2007, at 15:13, Adam Lindberg wrote: > As a side topic regarding OO and Erlang ways of thinking, here's a > good article about Erlang and concurrency. It touches object > orientation and comparisons with Java for example, and is somewhat of > a mind opener. :-) > > http://www.defmacro.org/ramblings/concurrency.html > > On 1/22/07, Sean Hinde wrote: >> >> On 22 Jan 2007, at 11:39, Ulf Wiger wrote: >> >> > Den 2007-01-22 11:52:35 skrev Ladislav Lenart : >> > >> >> *Question:* Is there a way such polymorphism can be >> >> achieved in Erlang without actually merging (see above) >> >> the modules that should behave polymorphically? >> > >> > No universally agreed upon common method, no, >> > if I understood your question correctly. >> > >> > Xmerl, for example, introduced a notion of module >> > inheritance, with which one were supposed to extend >> > the functionality of export callbacks. See e.g. >> > http://jungerl.cvs.sourceforge.net/jungerl/jungerl/lib/xmerl/src/ >> > xmerl.erl?revision=1.2&view=markup >> > mainly lines 267-313. >> > (or the OTP source tree for a more current version.) >> > >> > I don't know if anyone has actually made use of it. >> >> I suspect not. >> >> IMO the most important thing to take away from this discussion is >> that OO style is not the normal or best way to program in Erlang. >> >> Try not to think of erlang processes as simply repositories of state >> - they are so much more than that.. Model each real world activity as >> an erlang process, and have each process maintain as much state as it >> needs to function as that real world process. >> >> The API into the process would not typically be get/set operations, >> but real world calls like make_sale() or purchase(). It can all be at >> a much higher level using Erlang. >> >> If you also follow the other advice in Ulf's post you will be getting >> there :-) >> >> Sean >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > > -- > Adam Lindberg > Mobile: +46734228920 From yan.guiborat@REDACTED Tue Jan 23 16:56:06 2007 From: yan.guiborat@REDACTED (netboz) Date: Tue, 23 Jan 2007 07:56:06 -0800 (PST) Subject: [erlang-questions] OO programming style in Erlang? In-Reply-To: <45B49773.5040105@volny.cz> References: <45B49773.5040105@volny.cz> Message-ID: <8524306.post@talk.nabble.com> Hi, Concerning OO programmation with erlang, you may have a look at eXAT, if you don't already know it. http://www.diit.unict.it/users/csanto/exat/index.html It's may be much more a theorical illustration but anyway very fonctionnal. And moreover very interesting, as it brings some elements of what OO programming could be like when rethinked/revisited with erlang. Netboz. -- View this message in context: http://www.nabble.com/-erlang-questions--OO-programming-style-in-Erlang--tf3053123.html#a8524306 Sent from the Erlang Questions mailing list archive at Nabble.com. From lenartlad@REDACTED Tue Jan 23 17:26:33 2007 From: lenartlad@REDACTED (Ladislav Lenart) Date: Tue, 23 Jan 2007 17:26:33 +0100 Subject: [erlang-questions] OO programming style in Erlang? In-Reply-To: <6344005f0701230713k3ef64ba6j52f5e430d4977fec@mail.gmail.com> References: <45B49773.5040105@volny.cz> <7CD50168-D053-4158-95AD-1E502A99F9B0@gmail.com> <6344005f0701230713k3ef64ba6j52f5e430d4977fec@mail.gmail.com> Message-ID: <45B63739.5010505@volny.cz> Adam Lindberg wrote: > As a side topic regarding OO and Erlang ways of thinking, here's a > good article about Erlang and concurrency. It touches object > orientation and comparisons with Java for example, and is somewhat of > a mind opener. :-) > > http://www.defmacro.org/ramblings/concurrency.html I read the article recently but didn't find any Erlang vs. OO comparison or objections against OO itself. Only the concurrency programming was demonstrated on one mainstream hybrid OO language... When I started the thread I didn't want to ask "How can I write OO in Erlang" (the mail has a bad subject) but rather "How to write properly in Erlang" which is what I have stll trouble with (at least it seems to me that way). But I guess that this, as everything, takes time to learn... Regarding OO, there is only a few programming languages that are "OO enough for me" (picking only those I know): Smalltalk, CLOS. I've also read some articles about Self and it looks quite good but I have never programmed in it. Ladislav Lenart From bjorn@REDACTED Tue Jan 23 17:37:57 2007 From: bjorn@REDACTED (Bjorn Gustavsson) Date: 23 Jan 2007 17:37:57 +0100 Subject: [erlang-questions] [erlang-bugs] async driver in multithread mode - segmentation fault In-Reply-To: <45B53118.50509@corp.idt.net> References: <45B53118.50509@corp.idt.net> Message-ID: Thanks for the bug report. We have found the bug and we will include a correction in R11B-3 (probably to be released within 1 or 2 weeks). /Bjorn Dmitriy Kargapolov writes: > Hi, > I was trying to implement asynchronous driver which is invoked in a > separate thread. It crashes with "segmentation fail" message when > second call is issued, in driver_async(). > > I'm attaching dummy short test which shows the problem. I > intentionally removed from the code most of driver_free() calls to > reduce potential problem source. > . . . -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From sean.hinde@REDACTED Tue Jan 23 17:52:49 2007 From: sean.hinde@REDACTED (Sean Hinde) Date: Tue, 23 Jan 2007 16:52:49 +0000 Subject: [erlang-questions] OO programming style in Erlang? In-Reply-To: <45B63739.5010505@volny.cz> References: <45B49773.5040105@volny.cz> <7CD50168-D053-4158-95AD-1E502A99F9B0@gmail.com> <6344005f0701230713k3ef64ba6j52f5e430d4977fec@mail.gmail.com> <45B63739.5010505@volny.cz> Message-ID: <84180340-454B-450B-8FFA-72F086DB493F@gmail.com> > > When I started the thread I didn't want to ask "How can > I write OO in Erlang" (the mail has a bad subject) but > rather "How to write properly in Erlang" which is what > I have stll trouble with (at least it seems to me that > way). But I guess that this, as everything, takes time > to learn... One great way to pick up the idioms is to study code by the masters. The OTP sources can be a great source of inspiration and examples of the "right way". Quite a bit (most) of the code in Jungerl also probably qualifies. Yaws is high profile but probably not my favourite example of good erlang style (too much use of get/put (yagpb) ). mnesia is quite awesome, but rather heavyweight as a learning tool. Suggestions for "Best Practice" open source erlang projects anyone? > Regarding OO, there is only a few programming languages > that are "OO enough for me" (picking only those I know): > Smalltalk, CLOS. I've also read some articles about Self > and it looks quite good but I have never programmed in it. A certian Lisp/Smalltalk hacker round these parts keeps telling me that Smalltalk is something like Erlang in concept, but I never quite listened hard enough to see why ;-) Sean From lenartlad@REDACTED Tue Jan 23 18:30:53 2007 From: lenartlad@REDACTED (Ladislav Lenart) Date: Tue, 23 Jan 2007 18:30:53 +0100 Subject: [erlang-questions] OO programming style in Erlang? In-Reply-To: <84180340-454B-450B-8FFA-72F086DB493F@gmail.com> References: <45B49773.5040105@volny.cz> <7CD50168-D053-4158-95AD-1E502A99F9B0@gmail.com> <6344005f0701230713k3ef64ba6j52f5e430d4977fec@mail.gmail.com> <45B63739.5010505@volny.cz> <84180340-454B-450B-8FFA-72F086DB493F@gmail.com> Message-ID: <45B6464D.1060606@volny.cz> Sean Hinde wrote: >> >> When I started the thread I didn't want to ask "How can >> I write OO in Erlang" (the mail has a bad subject) but >> rather "How to write properly in Erlang" which is what >> I have stll trouble with (at least it seems to me that >> way). But I guess that this, as everything, takes time >> to learn... > > One great way to pick up the idioms is to study code by the masters. The > OTP sources can be a great source of inspiration and examples of the > "right way". > > Quite a bit (most) of the code in Jungerl also probably qualifies. Yaws > is high profile but probably not my favourite example of good erlang > style (too much use of get/put (yagpb) ). > > mnesia is quite awesome, but rather heavyweight as a learning tool. > > Suggestions for "Best Practice" open source erlang projects anyone? Yes, this is certainly a good start. I will definitely take a look at (some of) them. >> Regarding OO, there is only a few programming languages >> that are "OO enough for me" (picking only those I know): >> Smalltalk, CLOS. I've also read some articles about Self >> and it looks quite good but I have never programmed in it. > > A certian Lisp/Smalltalk hacker round these parts keeps telling me that > Smalltalk is something like Erlang in concept, but I never quite > listened hard enough to see why ;-) I'd say it is actually quite true. Joe Armstrong had a presentation on this (well, last) year's ESUG (European Smalltalk User Group Conferrence). In the begining of his presentation, he said: "Erlang is Smalltalk Alan Kay wanted it to be." and all the (presumably Smalltalk) audience laughed... :-) But from a point of view of an experienced Smalltalker, I must say that the shift from Smalltalk to Erlang is not so trivial, mainly because of a quite complex and fixed syntax. I got quite used to the idea of minimal language syntax and extendable libraries over the years. And this I miss a lot in Erlang. A simple example to illustrate my point follows (maybe you will even tell me a simple way how to do something like this in Erlang?)... Let's suppose I have to write a lot of code like this in Smalltalk: anObject isNil ifFalse: [anObject doSomething]. I can "extend the language" by providing a new method which takes a block of code as its only argument: Object>>ifNotNilDo: oneArgBlock "This is the branch where object (self in this context) is not nil and so the block is evaluated (with the object as its argument)." ^oneArgBlock value: self. UndefinedObject>>ifNotNilDo: oneArgBlock "This is the branch where object (self in this context) is actually nil and so the block is ignored and nil is returned." ^self. Now I can replace the code above with shorter and more readable form: anObject ifNotNilDo: [:obj | obj doSomething]. Sorry for the Smalltalk excursion... :-) Ladislav Lenart From sean.hinde@REDACTED Tue Jan 23 19:23:25 2007 From: sean.hinde@REDACTED (Sean Hinde) Date: Tue, 23 Jan 2007 18:23:25 +0000 Subject: [erlang-questions] OO programming style in Erlang? In-Reply-To: <45B6464D.1060606@volny.cz> References: <45B49773.5040105@volny.cz> <7CD50168-D053-4158-95AD-1E502A99F9B0@gmail.com> <6344005f0701230713k3ef64ba6j52f5e430d4977fec@mail.gmail.com> <45B63739.5010505@volny.cz> <84180340-454B-450B-8FFA-72F086DB493F@gmail.com> <45B6464D.1060606@volny.cz> Message-ID: <94598D18-234A-4BF0-868B-BDEADE26A81E@gmail.com> On 23 Jan 2007, at 17:30, Ladislav Lenart wrote: > Sean Hinde wrote: >> A certian Lisp/Smalltalk hacker round these parts keeps telling me >> that >> Smalltalk is something like Erlang in concept, but I never quite >> listened hard enough to see why ;-) > > But from a point of view of an experienced Smalltalker, > I must say that the shift from Smalltalk to Erlang is not > so trivial, mainly because of a quite complex and fixed > syntax. I got quite used to the idea of minimal language > syntax and extendable libraries over the years. And this > I miss a lot in Erlang. A simple example to illustrate my > point follows (maybe you will even tell me a simple way > how to do something like this in Erlang?)... And now you are at it as well ! > > Let's suppose I have to write a lot of code like this > in Smalltalk: > > anObject isNil > ifFalse: [anObject doSomething]. Well, fairly meaningless so far. One comment - Erlang is not about sending messages as some kind of alternative to calling a method. Code that implements the business logic is normally written as a bunch of pure functions that take data structures as inputs and return manipulated data structures. No side effects or external state change in sight. String a bunch of these together and you have as complex a logic as you want. Data structures are by nature highly symbolic (the atom type) and (apart from dedicated ADTs like dict and gb_trees) tend to be complex, exposed and passed around and operated on directly by pure functions. The process structure in a typical Erlang based system is not about distributing state, but more about modelling things that have to happen concurrently. > > I can "extend the language" by providing a new method > which takes a block of code as its only argument: > > Object>>ifNotNilDo: oneArgBlock > "This is the branch where object (self in this > context) is not nil and so the block is evaluated > (with the object as its argument)." > ^oneArgBlock value: self. > > UndefinedObject>>ifNotNilDo: oneArgBlock > "This is the branch where object (self in this > context) is actually nil and so the block is ignored > and nil is returned." > ^self. > > Now I can replace the code above with shorter and more > readable form: > > anObject ifNotNilDo: [:obj | obj doSomething]. In Erlang you just write what you mean. function(false) -> do_something_with_false(); function(Not_false) -> do_something_else(Not_false). There is no complicated way to add a new clause to this function, only the simple and obvious: function(false) -> do_something_with_false(); function({error, Reason}) -> do_something_with_error(Reason); function(Not_false) -> do_something_else(Not_false). No need for all the multi levels of indirection and "no idea what might be overriding this" but grep might help problems ;-) As far as I can see the only time you might ever need to add some clauses to such a function via some other source code file is if you were using a closed source library. Then you would just put a wrapper function around the library: wrapper({my_data, Data}) -> do_my_stuff(Data); wrapper(Else) -> closed_lib:function(Else) But hey, there are no closed source libraries for Erlang. Perhaps the closest thing to what you are after is the an OTP behaviour. But almost every complex Erlang System uses no more that the 2 or 3 that come with OTP (gen_server, errr, actually that would suffice!) > > Sorry for the Smalltalk excursion... :-) Quite alright. I did download Squeak the other day, but couldn't figure out how to start an emacs buffer Sean From Martin.Logan@REDACTED Tue Jan 23 19:25:09 2007 From: Martin.Logan@REDACTED (Logan, Martin) Date: Tue, 23 Jan 2007 12:25:09 -0600 Subject: [erlang-questions] OO programming style in Erlang? In-Reply-To: <45B63739.5010505@volny.cz> References: <45B49773.5040105@volny.cz> <7CD50168-D053-4158-95AD-1E502A99F9B0@gmail.com><6344005f0701230713k3ef64ba6j52f5e430d4977fec@mail.gmail.com> <45B63739.5010505@volny.cz> Message-ID: <26AB42AB6A76E2419D26E66ECF1538468B3603@chiresexc02.resource.corp.lcl> If you are doing this, learning proper Erlang style, on your own then it takes a while to learn. I made great progress on my own. My progress was sped up dramatically when a then young Francesco Cesarini came to my dev shop and taught us a thing or two. Oh, and make sure you read all the coding practice(style and design guide etc...) docs up on www.erlang.org. Oh, and one more thing, use OTP, application, supervisor, gen_server at a minimum. Cheers, Martin www.erlware.org P.S Francesco, please send me 500 USD for that plug. -----Original Message----- From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Ladislav Lenart Sent: Tuesday, January 23, 2007 10:27 AM Cc: Erlang-Questions (E-mail) Subject: Re: [erlang-questions] OO programming style in Erlang? Adam Lindberg wrote: > As a side topic regarding OO and Erlang ways of thinking, here's a > good article about Erlang and concurrency. It touches object > orientation and comparisons with Java for example, and is somewhat of > a mind opener. :-) > > http://www.defmacro.org/ramblings/concurrency.html I read the article recently but didn't find any Erlang vs. OO comparison or objections against OO itself. Only the concurrency programming was demonstrated on one mainstream hybrid OO language... When I started the thread I didn't want to ask "How can I write OO in Erlang" (the mail has a bad subject) but rather "How to write properly in Erlang" which is what I have stll trouble with (at least it seems to me that way). But I guess that this, as everything, takes time to learn... Regarding OO, there is only a few programming languages that are "OO enough for me" (picking only those I know): Smalltalk, CLOS. I've also read some articles about Self and it looks quite good but I have never programmed in it. Ladislav Lenart _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions From lenartlad@REDACTED Tue Jan 23 19:33:32 2007 From: lenartlad@REDACTED (Ladislav Lenart) Date: Tue, 23 Jan 2007 19:33:32 +0100 Subject: [erlang-questions] OO programming style in Erlang? In-Reply-To: <8524306.post@talk.nabble.com> References: <45B49773.5040105@volny.cz> <8524306.post@talk.nabble.com> Message-ID: <45B654FC.1000704@volny.cz> netboz wrote: > Hi, > > Concerning OO programmation with erlang, you may > have a look at eXAT, if you don't already know it. > > http://www.diit.unict.it/users/csanto/exat/index.html > > It's may be much more a theorical illustration but anyway > very fonctionnal. > And moreover very interesting, as it brings some elements > of what OO programming could be like when rethinked/revisited with erlang. This (conceptually) sounds very much like what I want to accomplish and it has some nice insights too... :-) Thank you, Ladislav Lenart From Martin.Logan@REDACTED Tue Jan 23 19:33:33 2007 From: Martin.Logan@REDACTED (Logan, Martin) Date: Tue, 23 Jan 2007 12:33:33 -0600 Subject: [erlang-questions] function prime Message-ID: <26AB42AB6A76E2419D26E66ECF1538468B3605@chiresexc02.resource.corp.lcl> I was thinking, well this is the second time, that it would be nice to add the ability to name functions with a ' suffix (ala Haskell). I can't think of a place where that would be ambiguous... I am sure I could be wrong though. I have seeing func(A, B) -> ... Func2(AA, BB) fun2(A, B) -> etc funcN(A, B) -> it would be much nicer to use func(A, B) -> func'(A, B) func''(A, B) Function prime and function double prime is much nicer than function one and function two. I think so at least - it makes me feel smart and I can pretend to be a real computer scientist. Cheers, Martin -------------- next part -------------- An HTML attachment was scrubbed... URL: From lenartlad@REDACTED Tue Jan 23 20:11:51 2007 From: lenartlad@REDACTED (Ladislav Lenart) Date: Tue, 23 Jan 2007 20:11:51 +0100 Subject: [erlang-questions] OO programming style in Erlang? In-Reply-To: <94598D18-234A-4BF0-868B-BDEADE26A81E@gmail.com> References: <45B49773.5040105@volny.cz> <7CD50168-D053-4158-95AD-1E502A99F9B0@gmail.com> <6344005f0701230713k3ef64ba6j52f5e430d4977fec@mail.gmail.com> <45B63739.5010505@volny.cz> <84180340-454B-450B-8FFA-72F086DB493F@gmail.com> <45B6464D.1060606@volny.cz> <94598D18-234A-4BF0-868B-BDEADE26A81E@gmail.com> Message-ID: <45B65DF7.1040805@volny.cz> Sean Hinde wrote: > > On 23 Jan 2007, at 17:30, Ladislav Lenart wrote: > >> Sean Hinde wrote: >>> A certian Lisp/Smalltalk hacker round these parts keeps telling me that >>> Smalltalk is something like Erlang in concept, but I never quite >>> listened hard enough to see why ;-) >> >> But from a point of view of an experienced Smalltalker, >> I must say that the shift from Smalltalk to Erlang is not >> so trivial, mainly because of a quite complex and fixed >> syntax. I got quite used to the idea of minimal language >> syntax and extendable libraries over the years. And this >> I miss a lot in Erlang. A simple example to illustrate my >> point follows (maybe you will even tell me a simple way >> how to do something like this in Erlang?)... > > And now you are at it as well ! > >> >> Let's suppose I have to write a lot of code like this >> in Smalltalk: >> >> anObject isNil >> ifFalse: [anObject doSomething]. > > Well, fairly meaningless so far. > > One comment - Erlang is not about sending messages as some kind of > alternative to calling a method. Code that implements the business logic > is normally written as a bunch of pure functions that take data > structures as inputs and return manipulated data structures. No side > effects or external state change in sight. String a bunch of these > together and you have as complex a logic as you want. > > Data structures are by nature highly symbolic (the atom type) and (apart > from dedicated ADTs like dict and gb_trees) tend to be complex, exposed > and passed around and operated on directly by pure functions. And this I guess is the part I have a psychological problem with. I am used to an idiom where data are hidden behind an interface that operates on them. This decouples user of the module from having to deal with internals of that module. But as you described it, data are exposed in Erlang. So each time you want to change the representation (add something because of one new function), you have to revisit many of the existing functions that operate on that representation. This seems more than a few changes to me... Ladislav Lenart From Martin.Logan@REDACTED Tue Jan 23 20:30:47 2007 From: Martin.Logan@REDACTED (Logan, Martin) Date: Tue, 23 Jan 2007 13:30:47 -0600 Subject: [erlang-questions] OO programming style in Erlang? In-Reply-To: <45B65DF7.1040805@volny.cz> References: <45B49773.5040105@volny.cz> <7CD50168-D053-4158-95AD-1E502A99F9B0@gmail.com><6344005f0701230713k3ef64ba6j52f5e430d4977fec@mail.gmail.com><45B63739.5010505@volny.cz><84180340-454B-450B-8FFA-72F086DB493F@gmail.com><45B6464D.1060606@volny.cz><94598D18-234A-4BF0-868B-BDEADE26A81E@gmail.com> <45B65DF7.1040805@volny.cz> Message-ID: <26AB42AB6A76E2419D26E66ECF1538468B3609@chiresexc02.resource.corp.lcl> And this I guess is the part I have a psychological problem with. I am used to an idiom where data are hidden behind an interface that operates on them. This decouples user of the module from having to deal with internals of that module. But as you described it, data are exposed in Erlang. So each time you want to change the representation (add something because of one new function), you have to revisit many of the existing functions that operate on that representation. This seems more than a few changes to me... No more so than you would with an object. In both cases it depends on what you are doing with your structure, are your changes backward compatible. Look at the dict module for a good example. The only real difference between that and an object called dict is the structure is passed back and forth from the caller to the function operating on it. Martin From sean.hinde@REDACTED Tue Jan 23 20:44:11 2007 From: sean.hinde@REDACTED (Sean Hinde) Date: Tue, 23 Jan 2007 19:44:11 +0000 Subject: [erlang-questions] OO programming style in Erlang? In-Reply-To: <45B65DF7.1040805@volny.cz> References: <45B49773.5040105@volny.cz> <7CD50168-D053-4158-95AD-1E502A99F9B0@gmail.com> <6344005f0701230713k3ef64ba6j52f5e430d4977fec@mail.gmail.com> <45B63739.5010505@volny.cz> <84180340-454B-450B-8FFA-72F086DB493F@gmail.com> <45B6464D.1060606@volny.cz> <94598D18-234A-4BF0-868B-BDEADE26A81E@gmail.com> <45B65DF7.1040805@volny.cz> Message-ID: <2C9AFAF2-F3C9-4F27-ABA7-0CE344BFBC62@gmail.com> On 23 Jan 2007, at 19:11, Ladislav Lenart wrote: > And this I guess is the part I have a psychological problem with. > I am used to an idiom where data are hidden behind an interface > that operates on them. This decouples user of the module from > having to deal with internals of that module. But as you described > it, data are exposed in Erlang. So each time you want to change the > representation (add something because of one new function), you have > to revisit many of the existing functions that operate on that > representation. This seems more than a few changes to me... Not so bad. If you use records then it is just a recompile (I recommend incororating edep into your build process). If you seriously change the meaning of the data then I see no difference - all users have to take care of the new meaning anyway. If you are simply changing the representation without changing the meaning then you must have a lot of spare time on your hands :-) Presumably writing your system in erlang means you have some concurrency. One guideline would be to design the boundaries between processes so that the interfaces are simple or regular, and reserve the complex stuff to be inside the process and hence limited to a few modules. I guess in that sense there is some similarity to Smalltalk, except that the granularity is larger and the decision criteria for the boundaries is different. Also fair to say that in some systems I have worked on it has become extremely tedious and error prone to change the representation of pervasive data structures. At such times I have even wished for some static typing help :-) Of course there is nothing stopping you from building your own dict style modules for common data structures in your app - the erlang way for this (as well described by Uffe) is to pass the whole old data structure into the function, and get back a new one modified - pure functions without side effects. Sean From taavi@REDACTED Tue Jan 23 20:48:18 2007 From: taavi@REDACTED (Taavi Talvik) Date: Tue, 23 Jan 2007 21:48:18 +0200 Subject: [erlang-questions] OO programming style in Erlang? In-Reply-To: <45B65DF7.1040805@volny.cz> References: <45B49773.5040105@volny.cz> <7CD50168-D053-4158-95AD-1E502A99F9B0@gmail.com> <6344005f0701230713k3ef64ba6j52f5e430d4977fec@mail.gmail.com> <45B63739.5010505@volny.cz> <84180340-454B-450B-8FFA-72F086DB493F@gmail.com> <45B6464D.1060606@volny.cz> <94598D18-234A-4BF0-868B-BDEADE26A81E@gmail.com> <45B65DF7.1040805@volny.cz> Message-ID: >> Data structures are by nature highly symbolic (the atom type) and >> (apart >> from dedicated ADTs like dict and gb_trees) tend to be complex, >> exposed >> and passed around and operated on directly by pure functions. > > And this I guess is the part I have a psychological problem with. > I am used to an idiom where data are hidden behind an interface > that operates on them. This decouples user of the module from > having to deal with internals of that module. But as you described > it, data are exposed in Erlang. So each time you want to change the > representation (add something because of one new function), you have > to revisit many of the existing functions that operate on that > representation. This seems more than a few changes to me... Yes, psychological problem or matter of discipline. For exacmple, dict uses complex internal representation. But besides possibility to examine (or display with io:format("~p", Dict)) internal structure you don't need to know it. D0 = dict:new(), D1 = dict:store(files, [], D0), D2 = dict:append(files, f1, D1), D3 = dict:append(files, f2, D2), D4 = dict:append(files, f3, D3), dict:fetch(files, D4). [f1,f2,f3] Same with digraph, set, queue, gb_* and your own generic modules;) If you think of modules as encapsulation units (class) and exported functions as accessor functions, rest is unimportant internal representation. Of course - for doing interesting things you have to know your own data structures. And you pay price for doing interesting things having to think about data structures and having to rewrite functions from time to time. best regards, taavi From sean.hinde@REDACTED Tue Jan 23 20:52:46 2007 From: sean.hinde@REDACTED (Sean Hinde) Date: Tue, 23 Jan 2007 19:52:46 +0000 Subject: [erlang-questions] link/monitor rarely enough Message-ID: Hi, I find myself writing more and more code where two processes must monitor each other in different ways. Example - two processes: Thing_1 and Thing_2. Thing_1 must die if Thing_2 dies. Thing_2 must receive a message if Thing_1 dies. To do this with monitor/link is tedious and hard to get right, because as soon as one traps exits all sorts of other linked processes must be tracked by Pid and special actions taken. Dull Dull Dull I end up using both monitor and link, with horrible cruft to track everything. Please, the powers that be in Ericsson, implement the full mechanism described by Robert Virding on 22nd Oct last year: "With links there are 3 parameters which describe the link: signal/message, single/multiple and uni-/bidirectional. With link/1 you get a signal-single-bidirectional connection berween the processes and with monitor/1 you get a message-multiple-unidirectional connection. You could of course have any combination of these parameters that you need. " Thanks! Sean From goran.bage@REDACTED Tue Jan 23 21:07:41 2007 From: goran.bage@REDACTED (Goran Bage) Date: Tue, 23 Jan 2007 21:07:41 +0100 Subject: [erlang-questions] function prime In-Reply-To: <26AB42AB6A76E2419D26E66ECF1538468B3605@chiresexc02.resource.corp.lcl> References: <26AB42AB6A76E2419D26E66ECF1538468B3605@chiresexc02.resource.corp.lcl> Message-ID: <45B66B0D.3070507@mobilearts.com> Why not func(..) func_(..) func__(..) maybe a little more confusing, but it works now Logan, Martin wrote: > I was thinking, well this is the second time, that it would be nice to > add the ability to name functions with a ? suffix (ala Haskell). I > can?t think of a place where that would be ambiguous? I am sure I could > be wrong though. I have seeing > > > > func(A, B) -> ? > > Func2(AA, BB) > > > > fun2(A, B) -> > > > > etc > > > > funcN(A, B) -> > > > > it would be much nicer to use > > > > > > func(A, B) -> > > > > func?(A, B) > > > > func??(A, B) > > > > > > Function prime and function double prime is much nicer than function one > and function two. I think so at least ? it makes me feel smart and I > can pretend to be a real computer scientist. > > > > Cheers, > > Martin > > > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- -- Goran -------------------- May the Snow be with you -------- Goran Bage Byvagen 10, SE-133 34 Saltsjobaden, Sweden email:goran.bage@REDACTED, phone: +46 8 7172907 From yarivvv@REDACTED Tue Jan 23 22:38:26 2007 From: yarivvv@REDACTED (Yariv Sadan) Date: Tue, 23 Jan 2007 16:38:26 -0500 Subject: [erlang-questions] OO programming style in Erlang? In-Reply-To: References: <45B49773.5040105@volny.cz> Message-ID: <17244f480701231338w6d9e6824o81a04bfa603401a1@mail.gmail.com> > You could also use a macro, of course: > > -define(DICT, orddict). > > ?DICT:store(...) Related to the macro advice, it should probably be mentioned that if the type of the module isn't known until runtime, Erlang lets you use an atom variable in place of the module and/or function name, with a (small?) performance cost. E.g., assuming Module and Function are atoms, this is legal: foo(Module, Function, Param) -> Module:Function(Param). > > Xmerl, for example, introduced a notion of module > inheritance, with which one were supposed to extend > the functionality of export callbacks. See e.g. > http://jungerl.cvs.sourceforge.net/jungerl/jungerl/lib/xmerl/src/xmerl.erl?revision=1.2&view=markup > mainly lines 267-313. > (or the OTP source tree for a more current version.) > > I don't know if anyone has actually made use of it. > I have run into few cases where module extension was so desirable I wished it were part of the language. Since it wasn't, I implemented it in Smerl, but it's not as user-friendly as a language feature would have been. At the minimum, you would have to call {ok, M} = smerl:for_module(MyModule), M1 = smerl:extend(BaseModule, M), smerl:compile(M1). ErlyWeb uses this feature in a few places, but one of the reasons it works well is that ErlyWeb compiles application modules for you, so you don't have to worry about using Smerl directly. It wouldn't be very hard to respin the Smerl code into a parse transform, so if you wanted a child module to extend a base module, you could write in the child module -parse_transform(extend, [BaseModule]). but since the ErlyWeb compilation mechanism was sufficient for me I haven't done it :) Best regards, Yariv From ok@REDACTED Tue Jan 23 23:29:12 2007 From: ok@REDACTED (Richard A. O'Keefe) Date: Wed, 24 Jan 2007 11:29:12 +1300 (NZDT) Subject: [erlang-questions] OO programming style in Erlang? Message-ID: <200701232229.l0NMTCYJ190282@atlas.otago.ac.nz> Adam Lindberg wrote: I recall becoming very frustrated with the concept that calling a method of an object was referred to as sending the object a message. How can it be sending a message I thought - messages are things that can only be passed between things with their own parallel existence. To talk about "message passing" doesn't really make sense for Ada or Common Lisp (which use generic functions) or C++ or Java, but it *does* make sense in Smalltalk, where messages do actually exist as separate objects whenever you look for them and can be inspected, modified, and forwarded to other objects. Object subclass: #Message instanceVariableNames: 'selector args lookupClass' ... "I represent a selector and its argument values. Generally the system does not use instances of Message for efficiency reasons. However, when a message is not understood by its receiver, the [system] will make up an instance of me in order to capture the information involved in an actual message transmission. This instance is sent to the receiver as the argument of #doesNotUnderstand:." ... sendTo: receiver ^receiver perform: selector withArguments: args When debugging Smalltalk programs, you can see actual Message objects. I should also point out that Smalltalk has had concurrency since before Smalltalk-80 and that in CORBA message passing does actually mean passing real messages over wires (or can mean that). That attempt to learn that language (possibly C++, I don't recall) soon ended in distraction. I think it was Dennis Ritchie (one of the inventors of C) who wrote "90% of C I use every day; 90% of C++ I don't understand." C++ is very far from being a typical object-oriented language. Indeed, the latest additions to the standard C++ library make little or no use of inheritence but essential use of its Turing-complete template facility. From ok@REDACTED Tue Jan 23 23:44:02 2007 From: ok@REDACTED (Richard A. O'Keefe) Date: Wed, 24 Jan 2007 11:44:02 +1300 (NZDT) Subject: [erlang-questions] OO programming style in Erlang? Message-ID: <200701232244.l0NMi24o192192@atlas.otago.ac.nz> Ladislav Lenart wrote: Let's suppose I have to write a lot of code like this in Smalltalk: anObject isNil ifFalse: [anObject doSomething]. I can "extend the language" by providing a new method which takes a block of code as its only argument: Object>>ifNotNilDo: oneArgBlock "This is the branch where object (self in this context) is not nil and so the block is evaluated (with the object as its argument)." ^oneArgBlock value: self. UndefinedObject>>ifNotNilDo: oneArgBlock "This is the branch where object (self in this context) is actually nil and so the block is ignored and nil is returned." ^self. PLEASE don't do that. #ifNil: #ifNotNil: #ifNil:ifNotNil: and #ifNotNil:ifNil: exist in more than one version of Smalltalk and there is no point in being incompatible with them. Now I can replace the code above with shorter and more readable form: anObject ifNotNilDo: [:obj | obj doSomething]. Or, in some existing Smalltalks: anObject ifNotNil: [anObject doSomething] And in Erlang you can write case X of [] -> do something ; _ -> do something else end You have missed out one important step. The usual Smalltalk syntax for conditionals and loops *does* make use of blocks (= anonymous functions = Erlang 'fun' expressions), *but* those blocks are actually compiled in line. If you want that to happen, you *also* have to patch the Smalltalk compiler. (Which, given that Smalltalk provides compiler sources, is not entirely out of the question. But it's harder than it looks.) Erlang has several extension facilities: - the C-wannabe preprocessor - parse transforms - hacking the (open source) compiler but none of them is quite as convenient as Lisp macros or Scheme hygienic macros and the syntax of Erlang has much to do with that. However, the conventional infix operators in Erlang syntax have, I suspect, had much to do with Erlang's acceptance. From autophile@REDACTED Tue Jan 23 23:47:02 2007 From: autophile@REDACTED (Robert Baruch) Date: Tue, 23 Jan 2007 17:47:02 -0500 Subject: [erlang-questions] lists:reverse/1 as a bui\lt-in function In-Reply-To: <200701230301.l0N31jet182036@atlas.otago.ac.nz> References: <200701230301.l0N31jet182036@atlas.otago.ac.nz> Message-ID: <5E4707A7-2398-48C1-B094-51F5861B5D0C@zoominternet.net> On Jan 22, 2007, at 10:01 PM, Richard A. O'Keefe wrote: > Neither. The issue is not "which order to we write dotted names", but > "where do we START from"? Java chose absolute package names. That is > what is bad. To take just one obvious example, suppose a group of > classes/modules are developed by the Acme Widget company, so all those > dotted names start out > nz.co.acme_widget.intercal. > Then the Acme Widget company get taken over by Southern Doohicky, Inc, > and now we *want* the names to be > au.com.southern_doohickey.intercal. > Because package names are *absolute*, every dotted package name has to > be changed. But if dotted names were *relative* to the containing > class/ > module, only one name in the entire build would need changing. > unnnecessarily Ahhhh, now I understand the issue. It is certainly true that when the developer of some code decides to change their root package name, any application using that new code, as well as any code in the library itself, has to redo the package imports. I seem to recall the Java language had that happen to it at one point, but I can't remember what it was -- I think it was Swing that changed over to using the javax package. I'm sure that caused the Swing developers some pain, and it cause me pain as well. Anyway, yes, I can definitely see the advantage of a package name being relative. Say I download someone's Erlang library. They decided to call it intercal, but in order to prevent a namespace clash with other applications that may also be called intercal, they put it in nz.co.acme_widget.intercal -- that is, this intercal is acme_widget's intercal, and not that other guy's intercal. It would still be useful if I could import nz.co.acme_widget.* so that I could use intercal.foo.bar/1 -- that is, the bar function in the foo module in the intercal directory. The compiler would have to do a search through the import specs to locate a valid intercal.foo.bar/1, and if more than one were found, an error would be generated. But now we get your problem again -- if they decide to change their name, I have to go through every file of mine and change import nz.co.acme_widget.* to au.com.southern_doohickey.*, and that would really suck if I had 100 files. Of course, that's what -include is for :) So the modifications would be: 0. Imports are relative to some root. That root itself may be relative to some other root. If an import is relative to no root, then it is in the top-level namespace. 1. Name resolution searches through the imports, either matching a non-* import, or appending the name to a * import. If more than one import matches, an error is generated. 2. The name of a module is relative to some root. That root itself may be relative to some other root. If a module name is relative to no root, then it is in the top-level namespace. Thus, suppose we had product intercal, with the following directory structure: intercal/Foo.erl intercal/Bar.erl intercal/lower/Util.erl intercal/lower/IO.erl We would want Util and IO to be relative to .. (i.e. the directory above). We would further want Foo and Bar relative to .., and we would want intercal to be relative to nz.co.acme_widget. Note that we don't have to go through the bother of having a directory nz/co/ acme_widget, which I've always been annoyed at :) Now, internal to the intercal product, Util.erl can now call Foo.baz/ 1, because Util is relative to .., and therefore Foo.baz should be located in ../Foo.erl. Furthermore, Util.erl could choose to -import(Foo). This means that it can now call baz/1, because the name resolver found a match in ../ Foo.baz/1. This will also result in an error if there is a top-level Foo module with a baz/1 function, because then we don't know if you meant Foo.baz/1 or ../Foo.baz/1. The resolution is to specify either .Foo.baz (top-level) or nz.co.acme_widget.intercal.Foo.baz (fully qualified) -- or maybe even something that would allow you to specify a relative path. It's a bit complex, now. --Rob From ok@REDACTED Wed Jan 24 00:28:50 2007 From: ok@REDACTED (Richard A. O'Keefe) Date: Wed, 24 Jan 2007 12:28:50 +1300 (NZDT) Subject: [erlang-questions] function prime Message-ID: <200701232328.l0NNSoBP192640@atlas.otago.ac.nz> Martin Logan wrote: I was thinking, well this is the second time, that it would be nice to add the ability to name functions with a ' suffix (ala Haskell). I have been using languages with this feature since ML came out. This is a feature to be used very sparingly indeed, if at all. I can't think of a place where that would be ambiguous... I am sure I could be wrong though. Consider this O'CAML example: f x 'c' Now consider f x'c' Historically, Erlang's lexical structure is derived from Prolog (although for some incomprehensible it does not use Prolog symbols for bitwise operators). In Prolog, quoted symbols could be used as operators (as Haskell allows backquoted symbols) so that X'f'Y would have had to be the operator f applied to arguments X and Y. Erlang syntax doesn't allow user-defined operators, so you might be able to get away with it, but there really doesn't seem to be that much benefit. As for the argument that func func func' is nicer than func1 func'' func2 have you considered func''''' func5 func'''''' func6 By the way, anything past x''' is a solecism. "Primes" are historically Roman numerals, not unary. So it should go ' '' ''' iv v vi x x x x x x x It makes me feel smart and I can pretend to be a real computer scientist. I suggest that real computer scientists are characterised by a concern for clarity and appropriate choice of algorithm rather than "cuteness". From ok@REDACTED Wed Jan 24 00:57:07 2007 From: ok@REDACTED (Richard A. O'Keefe) Date: Wed, 24 Jan 2007 12:57:07 +1300 (NZDT) Subject: [erlang-questions] OO programming style in Erlang? Message-ID: <200701232357.l0NNv7Gb190526@atlas.otago.ac.nz> Ladislav Lenart wrote: And this I guess is the part I have a psychological problem with. I am used to an idiom where data are hidden behind an interface that operates on them. This decouples user of the module from having to deal with internals of that module. But as you described it, data are exposed in Erlang. So each time you want to change the representation (add something because of one new function), you have to revisit many of the existing functions that operate on that representation. This seems more than a few changes to me... There are basically three reasons why this is not an issue. In Erlang programming you just don't change data structures that much. There's a slogan I've seen to the effect that "it's better to have 100 functions operating on 1 data structure than 10 functions each on 10 data structures", but I've been unable to find the source. Where you *do* change data structures you use Erlang records (which try to look like Haskell and ML records) and if you are simply adding or reordering fields no source changes are required. Finally, while a data structure implemented by some module (such as sets or dictionaries) *can* be manipulated directly by external code, in practice nobody is stupid enough to do it. As long as clients only use the official exported functions, changes to the data structure representation are no trouble at all. I note that Smalltalk and Java expose everything (via reflection) and so does C++ (Object * can be cast to void * and thence to anything you want). You are used to languages (possibly Eiffel or Ada?) where programmers *can't* access the implementation of data structures; in C++, Java, Smalltalk and Erlang programmers can but *don't*. From lcoquelle@REDACTED Wed Jan 24 01:33:44 2007 From: lcoquelle@REDACTED (Ludovic Coquelle) Date: Wed, 24 Jan 2007 08:33:44 +0800 Subject: [erlang-questions] OO programming style in Erlang? In-Reply-To: <26AB42AB6A76E2419D26E66ECF1538468B3603@chiresexc02.resource.corp.lcl> References: <45B49773.5040105@volny.cz> <7CD50168-D053-4158-95AD-1E502A99F9B0@gmail.com> <6344005f0701230713k3ef64ba6j52f5e430d4977fec@mail.gmail.com> <45B63739.5010505@volny.cz> <26AB42AB6A76E2419D26E66ECF1538468B3603@chiresexc02.resource.corp.lcl> Message-ID: On 1/24/07, Logan, Martin wrote: > [...] Oh, and make sure you read all > the coding practice(style and design guide etc...) docs up on > www.erlang.org. Oh, and one more thing, use OTP, application, > supervisor, gen_server at a minimum. Wow! I'm beginning Erlang, and thought using OTP is good practice! Could you explain why you recommend to use it at minimum? is it for efficiency purpose? or for code management/reusability? From lcoquelle@REDACTED Wed Jan 24 03:12:39 2007 From: lcoquelle@REDACTED (Ludovic Coquelle) Date: Wed, 24 Jan 2007 10:12:39 +0800 Subject: [erlang-questions] OO programming style in Erlang? In-Reply-To: References: <45B49773.5040105@volny.cz> <7CD50168-D053-4158-95AD-1E502A99F9B0@gmail.com> <6344005f0701230713k3ef64ba6j52f5e430d4977fec@mail.gmail.com> <45B63739.5010505@volny.cz> <26AB42AB6A76E2419D26E66ECF1538468B3603@chiresexc02.resource.corp.lcl> Message-ID: I got a lot of reply for that! thanks to everybody Sorry Martin if I misunderstood your message! My English is too bad, and maybe I miss my morning coffee ;) So it's clear fo rme now: use at least application, supervisor and gen_server On 1/24/07, Ludovic Coquelle wrote: > On 1/24/07, Logan, Martin wrote: > > [...] Oh, and make sure you read all > > the coding practice(style and design guide etc...) docs up on > > www.erlang.org. Oh, and one more thing, use OTP, application, > > supervisor, gen_server at a minimum. > > Wow! I'm beginning Erlang, and thought using OTP is good practice! > Could you explain why you recommend to use it at minimum? is it for > efficiency purpose? or for code management/reusability? > From rsaccon@REDACTED Wed Jan 24 06:59:18 2007 From: rsaccon@REDACTED (Roberto Saccon) Date: Wed, 24 Jan 2007 02:59:18 -0300 Subject: [erlang-questions] erlang:md5() / crypto:md5() - any differences ? Message-ID: What is the difference between the md5 functions in erlang module / crypto module ? regards -- Roberto Saccon -------------- next part -------------- An HTML attachment was scrubbed... URL: From jeffm@REDACTED Wed Jan 24 07:30:06 2007 From: jeffm@REDACTED (jm) Date: Wed, 24 Jan 2007 17:30:06 +1100 Subject: [erlang-questions] Best way to do wall time alarms? Message-ID: <45B6FCEE.1030204@ghostgun.com> Haven't had a change to investigate this and thought someone may have a good idea as to the best approach. I'm after a way for a process to be notified on the hour and then every quarter hour there after, eg, 00:00, 00:15, 00:30, 00:45, etc. The use of a quarter hour is just an example and in the real application it will be configurable. The use of notify hints at the use of gen_event as the receive or as an intermediary. The question really then is what is the best way to generate these events? Is there a standard approach, etc? Jeff. From wink@REDACTED Wed Jan 24 08:04:34 2007 From: wink@REDACTED (Wink Saville) Date: Tue, 23 Jan 2007 23:04:34 -0800 Subject: [erlang-questions] Asynchronous Messaging support in the OS Message-ID: Hello, I have been working with a messaging framework for the last 4+ years and like many of the properties it has, but feel that a significant empediment is that asynchronous messaging is not directly supported by the kernel. For instance, I'd like to open a file or network socket and receive a series of messages with data asynchronously rather than having to "read" the data synchronously. Anyway, I have implemented a proof of concept asynchronous messaging system for the Linux kernel. This code adds the notion of an "mproc", which is a thread with a queue plus messages and auxiliary memory. Messages are sent to an mproc by placing the message on its queue. At some time in the future the mproc will be awoken because its queue is not empty. The mproc removes the next message from the queue and performs any processing necessary. It then frees the message and checks for another message. It will continue to process messages until there are none at which time it will wait for more messages. I was wondering if such a messaging system could be used with the Erlang send/receive operations? Could someone point me to any documentation that describes how Erlang implements its message passing? For those interested, my proof of concept code is here http://www.saville.com/linux/async/. I apologize in advance for the lack of documentation. Also, if you visit that page you'll find a little documentation on a technique I call ACE (Atomic Code Execution). I've documented that as it is fundamental to my implementation and allows the kernel to efficiently and asynchronously send messages to user space. Thanks, Wink Saville From bengt.kleberg@REDACTED Wed Jan 24 08:44:52 2007 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Wed, 24 Jan 2007 08:44:52 +0100 Subject: [erlang-questions] Best way to do wall time alarms? In-Reply-To: <45B6FCEE.1030204@ghostgun.com> References: <45B6FCEE.1030204@ghostgun.com> Message-ID: <45B70E74.6020107@ericsson.com> On 2007-01-24 07:30, jm wrote: > Haven't had a change to investigate this and thought someone may have a > good idea as to the best approach. I'm after a way for a process to be > notified on the hour and then every quarter hour there after, eg, 00:00, > 00:15, 00:30, 00:45, etc. The use of a quarter hour is just an example > and in the real application it will be configurable. The use of notify > hints at the use of gen_event as the receive or as an intermediary. The > question really then is what is the best way to generate these events? > Is there a standard approach, etc? perhaps the module timer and one of the functions: apply_interval or send_interval could help you to do what you want? bengt -- EPO guidelines 1978: "If the contribution to the known art resides solely in a computer program then the subject matter is not patentable in whatever manner it may be presented in the claims." From raimo+erlang-questions@REDACTED Wed Jan 24 09:04:15 2007 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Wed, 24 Jan 2007 09:04:15 +0100 Subject: [erlang-questions] function prime In-Reply-To: <26AB42AB6A76E2419D26E66ECF1538468B3605@chiresexc02.resource.corp.lcl> References: <26AB42AB6A76E2419D26E66ECF1538468B3605@chiresexc02.resource.corp.lcl> Message-ID: <20070124080415.GA27937@erix.ericsson.se> Well, since single quote is used to quote atoms - it is incompatible. OTOH backtick is unused, so: func() -> ok; 'func`'() -> ok. Remains to allow: func`() -> ok. But backtick should be used for something more important, I think... On Tue, Jan 23, 2007 at 12:33:33PM -0600, Logan, Martin wrote: > I was thinking, well this is the second time, that it would be nice to > add the ability to name functions with a ' suffix (ala Haskell). I > can't think of a place where that would be ambiguous... I am sure I > could be wrong though. I have seeing > > > > func(A, B) -> ... > > Func2(AA, BB) > > > > fun2(A, B) -> > > > > etc > > > > funcN(A, B) -> > > > > it would be much nicer to use > > > > > > func(A, B) -> > > > > func'(A, B) > > > > func''(A, B) > > > > > > Function prime and function double prime is much nicer than function one > and function two. I think so at least - it makes me feel smart and I > can pretend to be a real computer scientist. > > > > Cheers, > > Martin > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From ulf.wiger@REDACTED Wed Jan 24 09:30:21 2007 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Wed, 24 Jan 2007 09:30:21 +0100 Subject: [erlang-questions] Best way to do wall time alarms? In-Reply-To: <45B70E74.6020107@ericsson.com> Message-ID: <6616D98C65DD514BA2E1DDC5F922315573B3C3@esealmw115.eemea.ericsson.se> Bengt Kleberg wrote: > EPO guidelines 1978: "If the contribution to the known art resides > solely in a computer program then the subject matter is not > patentable in whatever manner it may be presented in the claims." You need to update your signature. ;) The "New Guidelines": 1. Art 52(2) EPC is a list of non-inventions. 2. The "programs for computers" listed therein are "computer-implementable inventions". 3. Programs can be patented as such, when they have a "further technical effect". 4. Practically all programs have a "further technical effect". http://swpat.ffii.org/log/epgl01A/index.en.html The Guidelines for Examination clarify that while a program is not patentable in itself, what it does is, assuming that the program actually solves a technical problem and does something (observably) useful. Then, the concepts embodied in the program are patentable (barring prior art). BR, /Ulf W From bjorn@REDACTED Wed Jan 24 09:35:05 2007 From: bjorn@REDACTED (Bjorn Gustavsson) Date: 24 Jan 2007 09:35:05 +0100 Subject: [erlang-questions] erlang:md5() / crypto:md5() - any differences ? In-Reply-To: References: Message-ID: "Roberto Saccon" writes: > What is the difference between the md5 functions in erlang module / crypto > module ? None. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From jeffm@REDACTED Wed Jan 24 09:48:12 2007 From: jeffm@REDACTED (jm) Date: Wed, 24 Jan 2007 19:48:12 +1100 Subject: [erlang-questions] Best way to do wall time alarms? In-Reply-To: <45B70E74.6020107@ericsson.com> References: <45B6FCEE.1030204@ghostgun.com> <45B70E74.6020107@ericsson.com> Message-ID: <45B71D4C.9000007@ghostgun.com> Bengt Kleberg wrote: > On 2007-01-24 07:30, jm wrote: >> Haven't had a change to investigate this and thought someone may have a >> good idea as to the best approach. I'm after a way for a process to be >> notified on the hour and then every quarter hour there after, eg, 00:00, >> 00:15, 00:30, 00:45, etc. The use of a quarter hour is just an example >> and in the real application it will be configurable. The use of notify >> hints at the use of gen_event as the receive or as an intermediary. The >> question really then is what is the best way to generate these events? >> Is there a standard approach, etc? > > perhaps the module > timer > and one of the functions: > apply_interval > or > send_interval > > could help you to do what you want? Thanks. I'm busy attempting to get my head around mnesia at the moment, hence not having a chance to investigate this. This question was sitting in the back of my mind distracting me and I thought that there must be a standard implementation as it's a common and basic thing to do. So far I've found the man page (part of stdlib) for timer which I'll have to read later. Jeff. From matthias@REDACTED Wed Jan 24 10:12:04 2007 From: matthias@REDACTED (Matthias Lang) Date: Wed, 24 Jan 2007 10:12:04 +0100 Subject: [erlang-questions] Best way to do wall time alarms? In-Reply-To: <6616D98C65DD514BA2E1DDC5F922315573B3C3@esealmw115.eemea.ericsson.se> References: <45B70E74.6020107@ericsson.com> <6616D98C65DD514BA2E1DDC5F922315573B3C3@esealmw115.eemea.ericsson.se> Message-ID: <17847.8932.127386.795522@antilipe.corelatus.se> Ulf Wiger (TN/EAB) writes: > > Bengt Kleberg wrote: > > EPO guidelines 1978: "If the contribution to the known art resides > > solely in a computer program then the subject matter is not > > patentable in whatever manner it may be presented in the claims." > > You need to update your signature. ;) > > The "New Guidelines": > > 1. Art 52(2) EPC is a list of non-inventions. > 2. The "programs for computers" listed therein are > "computer-implementable inventions". > 3. Programs can be patented as such, when they have a > "further technical effect". > 4. Practically all programs have a "further technical effect". > > http://swpat.ffii.org/log/epgl01A/index.en.html > > The Guidelines for Examination clarify that while a program > is not patentable in itself, what it does is, assuming that > the program actually solves a technical problem and does > something (observably) useful. Then, the concepts embodied > in the program are patentable (barring prior art). The "New Guidelines" are not entirely uncontroversial. In particular the meaning of "as such" seems to vary | Brussels, 24 May 2006. In a reply to a question from Polish MEP and | inventor Adam Gierek, the European Commission has confirmed that the | European Patent Office's (EPO) case law is not binding for member | states, nor (under the proposed Community Patent regulation) for the | European Court of Justice (ECJ). For the first time, the Commission | has also clearly stated that computer programs are not patentable | subject matter, without hiding behind the infamous "as such" cop-out. | | http://wiki.ffii.org/ComGierekPr060524En Matthias From bengt.kleberg@REDACTED Wed Jan 24 10:42:06 2007 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Wed, 24 Jan 2007 10:42:06 +0100 Subject: [erlang-questions] Best way to do wall time alarms? In-Reply-To: <6616D98C65DD514BA2E1DDC5F922315573B3C3@esealmw115.eemea.ericsson.se> References: <6616D98C65DD514BA2E1DDC5F922315573B3C3@esealmw115.eemea.ericsson.se> Message-ID: <45B729EE.6060708@ericsson.com> On 2007-01-24 09:30, Ulf Wiger (TN/EAB) wrote: > > Bengt Kleberg wrote: >> EPO guidelines 1978: "If the contribution to the known art resides >> solely in a computer program then the subject matter is not >> patentable in whatever manner it may be presented in the claims." > > You need to update your signature. ;) > > The "New Guidelines": ...deleted if somebody knows the correct translation of: det var b?ttre f?rr i will add it to my current signature. bengt -- EPO guidelines 1978: "If the contribution to the known art resides solely in a computer program then the subject matter is not patentable in whatever manner it may be presented in the claims." From erlang@REDACTED Wed Jan 24 11:11:28 2007 From: erlang@REDACTED (Erlang list) Date: Wed, 24 Jan 2007 10:11:28 +0000 Subject: [erlang-questions] lists:reverse/1 as a built-in function In-Reply-To: <45AFF43A.8040601@telia.com> References: <200701170438.l0H4cHOp145653@atlas.otago.ac.nz> <45AFF43A.8040601@telia.com> Message-ID: <45B730D0.3020105@oxyware.com> Robert Virding wrote: > We also had another idea which I really liked: split the predefined > module 'erlang' into a number of predefined modules like process, > atom, number, .... And some left in erlang. These modules would be > like todays erlang in that they would be part of the language and > specially treated. I hink the result would be easier to handle that > the wopping great erlang of today. Alas some worried about > backwards incompatibility if people had there own modules with the > same names. What about also adding in module aliases at the same time? If you had -alias(mypkg, erlang). as a way of saying that mypkg:* is an alias for erlang:* you might help or avoid a lot of migration issues. Alternatively, you could have compiler switches instead. There are two prior art data points to consider here. C++ namespaces, although they lack access control, can be aliased: namespace lib=lib_2007_01_21; which allows for shorthand names or for migration issues. The other point is that Java uses by convention a company's domain name as the package suffix. This is fine until your company gets bought (or a project is open sourced or otherwise moved) when code that works now needs to be changed because of package naming issues. An alias in Java would help a lot. -- Hubert Matthews http://www.oxyware.com/ Software Consultant hubert@REDACTED From lenartlad@REDACTED Wed Jan 24 12:11:13 2007 From: lenartlad@REDACTED (Ladislav Lenart) Date: Wed, 24 Jan 2007 12:11:13 +0100 Subject: [erlang-questions] Eclipse/Erlide autoindent problem Message-ID: <45B73ED1.2010802@volny.cz> Hello, I have installed Eclipse with Erlide plugin recently. It is almost what I need except when I type -module(test). -export([f/1]). f(Condition) -> case Condition true -> do_true(); false -> do_false() end, do_next1(), do_next2(). next and all other lines after a case statement are ill-indented (see the example above). Is there a way how to fix this issue (maybe am I just missing something?) or, alternatively, can I completely disable autoindent feature? I was looking in Preferences and in Erlide plugin but didn't find anything related to this. But it is fairly possible that I missed it because I am not used to Eclipse at all. Thank you, Ladislav Lenart From vladdu55@REDACTED Wed Jan 24 12:27:13 2007 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Wed, 24 Jan 2007 12:27:13 +0100 Subject: [erlang-questions] Eclipse/Erlide autoindent problem In-Reply-To: <45B73ED1.2010802@volny.cz> References: <45B73ED1.2010802@volny.cz> Message-ID: <95be1d3b0701240327g79e9408fkaf118be8d7d7237b@mail.gmail.com> Hi, On 1/24/07, Ladislav Lenart wrote: > I have installed Eclipse with Erlide plugin recently. > It is almost what I need except when I type > > f(Condition) -> > case Condition > true -> > do_true(); > false -> > do_false() > end, > do_next1(), > do_next2(). > > next and all other lines after a case statement > are ill-indented (see the example above). This is a problem we're aware of and tried to fix it for a while, but for some reason fixing something always breaks something else... Sometimes marking the function body and choosing "Indent lines" in the context menu helps. Also maybe it would be better to send bug reports to erlide-devel@REDACTED or even enter them in the project tracker at http://sourceforge.net/tracker/?group_id=58889&atid=489191 best regards, Vlad From ulf.wiger@REDACTED Wed Jan 24 13:02:23 2007 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Wed, 24 Jan 2007 13:02:23 +0100 Subject: [erlang-questions] Best way to do wall time alarms? In-Reply-To: <17847.8932.127386.795522@antilipe.corelatus.se> Message-ID: <6616D98C65DD514BA2E1DDC5F922315573B82C@esealmw115.eemea.ericsson.se> Matthias Lang: > > The "New Guidelines" are not entirely uncontroversial. In > particular the meaning of "as such" seems to vary > > | Brussels, 24 May 2006. In a reply to a question > | from Polish MEP and inventor Adam Gierek, the > | European Commission has confirmed that the > | European Patent Office's (EPO) case law is not > | binding for member states, nor (under the proposed > | Community Patent regulation) for the European Court > | of Justice (ECJ). For the first time, the Commission > | has also clearly stated that computer programs are > | not patentable subject matter, without hiding behind > | the infamous "as such" cop-out. > | > | http://wiki.ffii.org/ComGierekPr060524En Thanks for that entertaining link. I will admit that I got stuck on the reference to the "patent by Microsoft on allowing copy/paste of arbitrary data" http://v3.espacenet.com/textdoc?DB=EPODOC&IDX=EP0717354&F=0 Here I was thinking that the Macintosh Clipboard Model (also adopted by OS/2) was truly extensible, in that it made the source application responsible for the data rendering, when the data were pasted into another application. I'm looking forward to the upcoming lawsuit, when Microsoft sues Apple retroactively for violating its 2006 patent already in 1984. (: Ok, enough O.T. It's a good thing GS doesn't include a clipboard... BR, Ulf W From sean.hinde@REDACTED Wed Jan 24 13:15:41 2007 From: sean.hinde@REDACTED (Sean Hinde) Date: Wed, 24 Jan 2007 12:15:41 +0000 Subject: [erlang-questions] Programming question Message-ID: <3D85890B-9358-4163-9A65-CCC5760AD8FC@gmail.com> Hi, A quick question for Erlang gurus out there. I have two processes A and B. B spends most of its life in a series of gen_server calls towards A: loopB(PidA, S) -> Res = gen_server:call(PidA, {op, stuff}), S1 = process(Res, S), loopB(PidA, S1). The question is how do I set things up so that if A dies B is killed? Thanks, Sean From lenartlad@REDACTED Wed Jan 24 13:48:16 2007 From: lenartlad@REDACTED (Ladislav Lenart) Date: Wed, 24 Jan 2007 13:48:16 +0100 Subject: [erlang-questions] Eclipse/Erlide autoindent problem In-Reply-To: <95be1d3b0701240327g79e9408fkaf118be8d7d7237b@mail.gmail.com> References: <45B73ED1.2010802@volny.cz> <95be1d3b0701240327g79e9408fkaf118be8d7d7237b@mail.gmail.com> Message-ID: <45B75590.2040408@volny.cz> Vlad Dumitrescu wrote: > Hi, > > On 1/24/07, Ladislav Lenart wrote: >> I have installed Eclipse with Erlide plugin recently. >> It is almost what I need except when I type >> >> f(Condition) -> >> case Condition >> true -> >> do_true(); >> false -> >> do_false() >> end, >> do_next1(), >> do_next2(). >> >> next and all other lines after a case statement >> are ill-indented (see the example above). > > This is a problem we're aware of and tried to fix it for a while, but > for some reason fixing something always breaks something else... This is not good. Is there a way how to completely disable autoindent feature then? Or another one: What IDE do you use to write Erlang programs (anybody)? > Sometimes marking the function body and choosing "Indent lines" in the > context menu helps. > > Also maybe it would be better to send bug reports to > erlide-devel@REDACTED or even enter them in the project > tracker at http://sourceforge.net/tracker/?group_id=58889&atid=489191 Ok, sorry, I'll do it next time... :-) Ladislav Lenart From lenartlad@REDACTED Wed Jan 24 13:49:28 2007 From: lenartlad@REDACTED (Ladislav Lenart) Date: Wed, 24 Jan 2007 13:49:28 +0100 Subject: [erlang-questions] OO programming style in Erlang? In-Reply-To: <200701232357.l0NNv7Gb190526@atlas.otago.ac.nz> References: <200701232357.l0NNv7Gb190526@atlas.otago.ac.nz> Message-ID: <45B755D8.4010603@volny.cz> Richard A. O'Keefe wrote: > Ladislav Lenart wrote: > > And this I guess is the part I have a psychological problem with. > I am used to an idiom where data are hidden behind an interface > that operates on them. This decouples user of the module from > having to deal with internals of that module. But as you described > it, data are exposed in Erlang. So each time you want to change the > representation (add something because of one new function), you have > to revisit many of the existing functions that operate on that > representation. This seems more than a few changes to me... > > There are basically three reasons why this is not an issue. > > In Erlang programming you just don't change > data structures that much. There's a slogan I've seen to the effect > that "it's better to have 100 functions operating on 1 data structure > than 10 functions each on 10 data structures", but I've been unable to > find the source. That's a good one. > Where you *do* change data structures you use Erlang records (which try > to look like Haskell and ML records) and if you are simply adding or > reordering fields no source changes are required. Yes, I use them but don't like the syntax very much (it is very obvious that it is only a compiler feature and not a full data type). > Finally, while a data structure implemented by some module (such as > sets or dictionaries) *can* be manipulated directly by external code, > in practice nobody is stupid enough to do it. As long as clients only > use the official exported functions, changes to the data structure > representation are no trouble at all. No, this is not what I was worrying about. It seemed strange to me that I have to know exactly which function I need to invoke on a particular item. In Smalltalk, I just write "aCollection can be anything - List, Set, Dictionary, ..." aCollection collect: [:each | each something]. because aCollection knows what kind of collection it actually is. In Erlang, I have to know lists:map(...) dict:map(...) orddict:map(...) Furthemore lists:map expects fun/1 while dict/orddict:map expects fun/2. I got some good suggestions to deal with this issue, wrapper functions and macros. The thing I don't like is that I have to solve it myself... But these are details really, I was just curious. > I note that Smalltalk and Java expose everything (via reflection) and > so does C++ (Object * can be cast to void * and thence to anything you > want). You are used to languages (possibly Eiffel or Ada?) where > programmers *can't* access the implementation of data structures; > in C++, Java, Smalltalk and Erlang programmers can but *don't*. I am used to Smalltalk so I can but don't... :-) Ladislav Lenart From vladdu55@REDACTED Wed Jan 24 14:01:38 2007 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Wed, 24 Jan 2007 14:01:38 +0100 Subject: [erlang-questions] Eclipse/Erlide autoindent problem In-Reply-To: <45B75590.2040408@volny.cz> References: <45B73ED1.2010802@volny.cz> <95be1d3b0701240327g79e9408fkaf118be8d7d7237b@mail.gmail.com> <45B75590.2040408@volny.cz> Message-ID: <95be1d3b0701240501n67eaed48we3cc0ead04c9fb8e@mail.gmail.com> On 1/24/07, Ladislav Lenart wrote: > Vlad Dumitrescu wrote: > > This is a problem we're aware of and tried to fix it for a while, but > > for some reason fixing something always breaks something else... > > This is not good. Is there a way how to completely disable > autoindent feature then? I don't think so -- but I can build a new version with it disabled, if you really need that. > Or another one: What IDE do you use to write Erlang programs (anybody)? Emacs, of course! :-) best regards, Vlad From chsu79@REDACTED Wed Jan 24 14:11:10 2007 From: chsu79@REDACTED (Christian S) Date: Wed, 24 Jan 2007 14:11:10 +0100 Subject: [erlang-questions] lists:reverse/1 as a built-in function In-Reply-To: <45B730D0.3020105@oxyware.com> References: <200701170438.l0H4cHOp145653@atlas.otago.ac.nz> <45AFF43A.8040601@telia.com> <45B730D0.3020105@oxyware.com> Message-ID: On 1/24/07, Erlang list wrote: > What about also adding in module aliases at the same time? If you had > -alias(mypkg, erlang). as a way of saying that mypkg:* is an alias > for erlang:* you might help or avoid a lot of migration issues. > Alternatively, you could have compiler switches instead. This would break existing semantics. I think it would be worth it though (if accompanied by Richard O'Keefe's reified environments idea [1]). Right now we do not have actual module objects, we only have names for them. The alternative you represent would mean that the module name "foo" could refer to different modules (or no module at all) when called as Mod:fun() from other modules. Unless you suggest that aliases to have larger scope than modules? Site wide? If there was a "module object", a new type, one could resolve the name "foo" into a module object, and then use that module object when calling Mod:fun(). This opens up some questions on how module versioning should be handled. If one were to cheat, one could add a layer of indirection by having the global module name-space to be made of references instead of atoms, and have each module use a private mapping of atom module-names to reference module-names. If something like this was done, one would necessarily have to look through lots of code. [1]: http://www.erlang.org/pipermail/erlang-questions/2006-November/024026.html From thomasl_erlang@REDACTED Wed Jan 24 14:23:29 2007 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Wed, 24 Jan 2007 05:23:29 -0800 (PST) Subject: [erlang-questions] OO programming style in Erlang? In-Reply-To: <45B65DF7.1040805@volny.cz> Message-ID: <608253.80383.qm@web38811.mail.mud.yahoo.com> --- Ladislav Lenart wrote: > And this I guess is the part I have a psychological > problem with. > I am used to an idiom where data are hidden behind > an interface > that operates on them. This decouples user of the > module from > having to deal with internals of that module. But as > you described > it, data are exposed in Erlang. So each time you > want to change the > representation (add something because of one new > function), you have > to revisit many of the existing functions that > operate on that > representation. This seems more than a few changes > to me... The classic approach is to use abstract data types, ADTs: provide an API for operating on the data, and implement the operations in a module. The actual data representation is thus safely stored in a single place and can be changed without disturbing the clients. 'dict' is a fairly good example of working in this style. I use it all the time for some kinds of data. Erlang also provides pattern matching, which usually(*) exposes the internals of your data, and records, which provide a weak sort of abstraction. In some cases, using these leads to more concise code than ADTs and so it may after all be better to go that way. But, as you seem to be aware, there may also be future headaches in doing so. Best, Thomas (*) Richard O'Keefe has proposed a way to combine hiding and pattern matching in Erlang, but it hasn't been implemented as far as I know. ____________________________________________________________________________________ The fish are biting. Get more visitors on your site using Yahoo! Search Marketing. http://searchmarketing.yahoo.com/arp/sponsoredsearch_v2.php From yerl@REDACTED Wed Jan 24 14:38:25 2007 From: yerl@REDACTED (yerl@REDACTED) Date: Wed, 24 Jan 2007 14:38:25 +0100 Subject: [erlang-questions] Eclipse/Erlide autoindent problem Message-ID: Emacs ----Message d'origine---- >Date: Wed, 24 Jan 2007 14:01:38 +0100 >De: "Vlad Dumitrescu" >A: "Ladislav Lenart" >Copie ?: "Erlang-Questions (E-mail)" >Sujet: Re: [erlang-questions] Eclipse/Erlide autoindent problem > >On 1/24/07, Ladislav Lenart wrote: >> Vlad Dumitrescu wrote: >> > This is a problem we're aware of and tried to fix it for a while, but >> > for some reason fixing something always breaks something else... >> >> This is not good. Is there a way how to completely disable >> autoindent feature then? > >I don't think so -- but I can build a new version with it disabled, if >you really need that. > >> Or another one: What IDE do you use to write Erlang programs (anybody)? > >Emacs, of course! :-) > >best regards, >Vlad >_______________________________________________ >erlang-questions mailing list >erlang-questions@REDACTED >http://www.erlang.org/mailman/listinfo/erlang-questions > From mats.cronqvist@REDACTED Wed Jan 24 14:42:27 2007 From: mats.cronqvist@REDACTED (Mats Cronqvist) Date: Wed, 24 Jan 2007 14:42:27 +0100 Subject: [erlang-questions] Programming question In-Reply-To: <3D85890B-9358-4163-9A65-CCC5760AD8FC@gmail.com> References: <3D85890B-9358-4163-9A65-CCC5760AD8FC@gmail.com> Message-ID: <45B76243.1000104@ericsson.com> Sean Hinde wrote: > Hi, > > A quick question for Erlang gurus out there. > > I have two processes A and B. B spends most of its life in a series > of gen_server calls towards A: > > loopB(PidA, S) -> > Res = gen_server:call(PidA, {op, stuff}), > S1 = process(Res, S), > loopB(PidA, S1). > > The question is how do I set things up so that if A dies B is killed? as a non-guru, i was thinking that happened automatically as soon as you made the call? 1> is_process_alive(Pid). false 2> gen_server:call(Pid, {op, stuff}). ** exited: {noproc,{gen_server,call,[<0.14604.0>,{op,stuff}]}} ** or is that too late? mats From mats.cronqvist@REDACTED Wed Jan 24 14:48:53 2007 From: mats.cronqvist@REDACTED (Mats Cronqvist) Date: Wed, 24 Jan 2007 14:48:53 +0100 Subject: [erlang-questions] Eclipse/Erlide autoindent problem In-Reply-To: <45B75590.2040408@volny.cz> References: <45B73ED1.2010802@volny.cz> <95be1d3b0701240327g79e9408fkaf118be8d7d7237b@mail.gmail.com> <45B75590.2040408@volny.cz> Message-ID: <45B763C5.8010305@ericsson.com> Ladislav Lenart wrote: > Or another one: What IDE do you use to write Erlang programs (anybody)? emacs. there is an official emacs mode, and with the distel and esense contribs it integrates with the debugger and documentation (among other things). mats esense.sourceforge.net jungerl.sourceforge.net From javierparis@REDACTED Wed Jan 24 15:00:43 2007 From: javierparis@REDACTED (Javier =?iso-8859-1?q?Par=EDs?=) Date: Wed, 24 Jan 2007 15:00:43 +0100 Subject: [erlang-questions] Programming question In-Reply-To: <3D85890B-9358-4163-9A65-CCC5760AD8FC@gmail.com> References: <3D85890B-9358-4163-9A65-CCC5760AD8FC@gmail.com> Message-ID: <200701241500.43856.javierparis@udc.es> El Mi?rcoles, 24 de Enero de 2007 13:15, Sean Hinde escribi?: > Hi, > > A quick question for Erlang gurus out there. > > I have two processes A and B. B spends most of its life in a series > of gen_server calls towards A: > > loopB(PidA, S) -> > Res = gen_server:call(PidA, {op, stuff}), > S1 = process(Res, S), > loopB(PidA, S1). > > The question is how do I set things up so that if A dies B is killed? Just link them: In B, before calling loopB: ... link(PidA), loopB(PidA, S). Regards. From sean.hinde@REDACTED Wed Jan 24 15:09:00 2007 From: sean.hinde@REDACTED (Sean Hinde) Date: Wed, 24 Jan 2007 14:09:00 +0000 Subject: [erlang-questions] Programming question In-Reply-To: <45B76243.1000104@ericsson.com> References: <3D85890B-9358-4163-9A65-CCC5760AD8FC@gmail.com> <45B76243.1000104@ericsson.com> Message-ID: <2D1EF7CE-B891-4B96-A588-30D5F4414AED@gmail.com> On 24 Jan 2007, at 13:42, Mats Cronqvist wrote: > Sean Hinde wrote: >> Hi, >> >> A quick question for Erlang gurus out there. >> >> I have two processes A and B. B spends most of its life in a series >> of gen_server calls towards A: >> >> loopB(PidA, S) -> >> Res = gen_server:call(PidA, {op, stuff}), >> S1 = process(Res, S), >> loopB(PidA, S1). >> >> The question is how do I set things up so that if A dies B is killed? > > > as a non-guru, i was thinking that happened automatically as soon > as you made > the call? > > 1> is_process_alive(Pid). > false > 2> gen_server:call(Pid, {op, stuff}). > ** exited: {noproc,{gen_server,call,[<0.14604.0>,{op,stuff}]}} ** loopB spends most of its time waiting for a reply to the call. The likelihood is that Process A will die during the processing of the call, not while it is being "sent". In that case the above will not happen. Question still stands :-) Sean From gordonguthrie@REDACTED Wed Jan 24 15:13:32 2007 From: gordonguthrie@REDACTED (Gordon Guthrie) Date: Wed, 24 Jan 2007 14:13:32 -0000 (GMT) Subject: [erlang-questions] Interesting Paper "The Problem With Threads" Message-ID: <62100.193.113.57.167.1169648012.squirrel@backawinner.gg> Folks Came across this paper on reddit: 'The Problem With Threads' by Edward A Lee http://www.eecs.berkeley.edu/Pubs/TechRpts/2006/EECS-2006-1.pdf The only really new thing that caught my attention was: The cost of context switching is high, so only a tiny percentage of the possible interleavings of thread instructions ever occur in practice. I conjecture that most multi-threaded general-purpose applications are, in fact, so full of concurrency bugs that as multi-core architectures become commonplace, these bugs will begin to show up as system failures. This scenario is bleak for computer vendors: their next generation of machines will become widely known as the ones on which many programs crash. He makes a strange statement about syntax, which I would tend to disagree with: Regrettably, programmers seem to be more guided by syntax than semantics. The alternatives to threads that have taken root, like MPI and OpenMP, share this same key feature. They make no syntactic change to languages. Alternatives that replace these languages with entirely new syntax, such as Erlang or Ada, have not taken root, and probably will not Earlier in the paper he plows through computation theory to show that multi-threaded programming is demonstrably non-determinative and that possible thread interleavings cannot be realistically quantified, culminating in what reads like a classic EUC punchline: (Cue drumroll) To offer a third analogy, a folk definition of insanity is to do the same thing over and over again and to expect the results to be different. By this definition, we in fact require that programmers of multithreaded systems be insane. Were they sane, they could not understand their programs. (Rimshot) He might say that, I couldn't possibly comment :) Gordon From bengt.kleberg@REDACTED Wed Jan 24 15:19:56 2007 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Wed, 24 Jan 2007 15:19:56 +0100 Subject: [erlang-questions] Eclipse/Erlide autoindent problem In-Reply-To: <45B75590.2040408@volny.cz> References: <45B73ED1.2010802@volny.cz> <95be1d3b0701240327g79e9408fkaf118be8d7d7237b@mail.gmail.com> <45B75590.2040408@volny.cz> Message-ID: <45B76B0C.6050405@ericsson.com> On 2007-01-24 13:48, Ladislav Lenart wrote: ...deleted > Or another one: What IDE do you use to write Erlang programs (anybody)? acme (in its wily disguise: http://sourceforge.net/projects/wily/ ) bengt -- Those were the days... EPO guidelines 1978: "If the contribution to the known art resides solely in a computer program then the subject matter is not patentable in whatever manner it may be presented in the claims." From sean.hinde@REDACTED Wed Jan 24 15:20:07 2007 From: sean.hinde@REDACTED (Sean Hinde) Date: Wed, 24 Jan 2007 14:20:07 +0000 Subject: [erlang-questions] Programming question In-Reply-To: <200701241500.43856.javierparis@udc.es> References: <3D85890B-9358-4163-9A65-CCC5760AD8FC@gmail.com> <200701241500.43856.javierparis@udc.es> Message-ID: <970F752B-6586-4062-B0A4-ED1EFC291163@gmail.com> On 24 Jan 2007, at 14:00, Javier Par?s wrote: > El Mi?rcoles, 24 de Enero de 2007 13:15, Sean Hinde escribi?: >> Hi, >> >> A quick question for Erlang gurus out there. >> >> I have two processes A and B. B spends most of its life in a series >> of gen_server calls towards A: >> >> loopB(PidA, S) -> >> Res = gen_server:call(PidA, {op, stuff}), >> S1 = process(Res, S), >> loopB(PidA, S1). >> >> The question is how do I set things up so that if A dies B is killed? > > Just link them: > > In B, before calling loopB: Please try it. What happens if A dies while B is waiting for the result of the call? Sean From ulf.wiger@REDACTED Wed Jan 24 15:22:59 2007 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Wed, 24 Jan 2007 15:22:59 +0100 Subject: [erlang-questions] Programming question In-Reply-To: <2D1EF7CE-B891-4B96-A588-30D5F4414AED@gmail.com> Message-ID: <6616D98C65DD514BA2E1DDC5F922315573BB53@esealmw115.eemea.ericsson.se> Through the use of supervisors, you can either set up the processes under a one_for_all supervisor or a rest_for_one, where B is started after A. Then, if A dies, the supervisor will kill B. BR, Ulf W > -----Original Message----- > From: erlang-questions-bounces@REDACTED > [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Sean Hinde > Sent: den 24 januari 2007 15:09 > To: Mats Cronqvist (TN/EAB) > Cc: Erlang Questions > Subject: Re: [erlang-questions] Programming question > > > On 24 Jan 2007, at 13:42, Mats Cronqvist wrote: > > > Sean Hinde wrote: > >> Hi, > >> > >> A quick question for Erlang gurus out there. > >> > >> I have two processes A and B. B spends most of its life in > a series > >> of gen_server calls towards A: > >> > >> loopB(PidA, S) -> > >> Res = gen_server:call(PidA, {op, stuff}), > >> S1 = process(Res, S), > >> loopB(PidA, S1). > >> > >> The question is how do I set things up so that if A dies B > is killed? > > > > > > as a non-guru, i was thinking that happened automatically > as soon as > > you made the call? > > > > 1> is_process_alive(Pid). > > false > > 2> gen_server:call(Pid, {op, stuff}). > > ** exited: {noproc,{gen_server,call,[<0.14604.0>,{op,stuff}]}} ** > > loopB spends most of its time waiting for a reply to the > call. The likelihood is that Process A will die during the > processing of the call, not while it is being "sent". In that > case the above will not happen. Question still stands :-) > > Sean > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From lenartlad@REDACTED Wed Jan 24 15:28:02 2007 From: lenartlad@REDACTED (Ladislav Lenart) Date: Wed, 24 Jan 2007 15:28:02 +0100 Subject: [erlang-questions] Programming question In-Reply-To: <3D85890B-9358-4163-9A65-CCC5760AD8FC@gmail.com> References: <3D85890B-9358-4163-9A65-CCC5760AD8FC@gmail.com> Message-ID: <45B76CF2.2020400@volny.cz> Sean Hinde wrote: > Hi, > > A quick question for Erlang gurus out there. > > I have two processes A and B. B spends most of its life in a series > of gen_server calls towards A: > > loopB(PidA, S) -> > Res = gen_server:call(PidA, {op, stuff}), > S1 = process(Res, S), > loopB(PidA, S1). > > The question is how do I set things up so that if A dies B is killed? I am not a guru, but if "to die" means to terminate abnormally, you can link the two processes. BUT since links are bi-directional, if B dies, A will be killed as well. If this is not what you want, you can either start trapping exit signals OR you might take a look at erlang:monitor. It should allow you to create one-directional link. Modify B as follows: * Create a monitor to process A (during initialization perhaps) and store the resulting reference (Ref) as part of B's internal state. * Modify loopB so it can receive the following message: {'DOWN', Ref, process, PidA, Info} where Info is either the exit reason, noproc or noconnection. You can terminate the process when this message is received. BTW I have a question too. If B is implemented in terms of gen_server, I have to implement handle_info callback function in order to react upon receive of a 'DOWN' message from the monitor, right? Hope this helps, Ladislav Lenart From autophile@REDACTED Wed Jan 24 15:34:44 2007 From: autophile@REDACTED (Robert Baruch) Date: Wed, 24 Jan 2007 09:34:44 -0500 Subject: [erlang-questions] Eclipse/Erlide autoindent problem In-Reply-To: <45B75590.2040408@volny.cz> References: <45B73ED1.2010802@volny.cz> <95be1d3b0701240327g79e9408fkaf118be8d7d7237b@mail.gmail.com> <45B75590.2040408@volny.cz> Message-ID: <8F5ADC16-FA1F-4B18-B7A4-BEEA7FBD444F@zoominternet.net> On Jan 24, 2007, at 7:48 AM, Ladislav Lenart wrote: > Vlad Dumitrescu wrote: > Or another one: What IDE do you use to write Erlang programs > (anybody)? > I currently use Emacs -- don't laugh! I use the Mac OSX version of Emacs, which is Aquamacs Emacs. It seems to make more sense than plain vanilla Emacs :) Of course, it isn't an IDE. --Rob From richardc@REDACTED Wed Jan 24 15:53:44 2007 From: richardc@REDACTED (Richard Carlsson) Date: Wed, 24 Jan 2007 15:53:44 +0100 Subject: [erlang-questions] Programming question In-Reply-To: <3D85890B-9358-4163-9A65-CCC5760AD8FC@gmail.com> References: <3D85890B-9358-4163-9A65-CCC5760AD8FC@gmail.com> Message-ID: <45B772F8.5000804@it.uu.se> Sean Hinde wrote: > Hi, > > A quick question for Erlang gurus out there. > > I have two processes A and B. B spends most of its life in a series > of gen_server calls towards A: > > loopB(PidA, S) -> > Res = gen_server:call(PidA, {op, stuff}), > S1 = process(Res, S), > loopB(PidA, S1). > > The question is how do I set things up so that if A dies B is killed? Assuming that normal linking of B to A does not work (e.g. if B is trapping exits, does not accept an exit message in the waiting state, and you can't change the code of A and B), you could spawn a small simple watchdog process, and link it to both A and B. It should wait for the termination of either of them. If A dies, the watchdog kills B by brute force, i.e., exit(B, kill). If B dies, the watchdog dies with it, quietly. Or you could go the whole OTP hog and use a full supervisor model, as Uffe suggested. /Richard From sean.hinde@REDACTED Wed Jan 24 16:10:20 2007 From: sean.hinde@REDACTED (Sean Hinde) Date: Wed, 24 Jan 2007 15:10:20 +0000 Subject: [erlang-questions] Programming question In-Reply-To: <45B76CF2.2020400@volny.cz> References: <3D85890B-9358-4163-9A65-CCC5760AD8FC@gmail.com> <45B76CF2.2020400@volny.cz> Message-ID: <9036821B-65F3-401A-89CB-5590340B2AD2@gmail.com> On 24 Jan 2007, at 14:28, Ladislav Lenart wrote: > Sean Hinde wrote: >> Hi, >> >> A quick question for Erlang gurus out there. >> >> I have two processes A and B. B spends most of its life in a series >> of gen_server calls towards A: >> >> loopB(PidA, S) -> >> Res = gen_server:call(PidA, {op, stuff}), >> S1 = process(Res, S), >> loopB(PidA, S1). >> >> The question is how do I set things up so that if A dies B is killed? > > I am not a guru, but if "to die" means to terminate abnormally, > you can link the two processes. BUT since links are bi-directional, > if B dies, A will be killed as well. This won't do it. If A dies while processing the call from B, even when linked, then B does not die. > > If this is not what you want, you can either start trapping exit > signals OR you might take a look at erlang:monitor. It should > allow you to create one-directional link. Modify B as follows: > * Create a monitor to process A (during initialization perhaps) > and store the resulting reference (Ref) as part of B's internal > state. > * Modify loopB so it can receive the following message: > {'DOWN', Ref, process, PidA, Info} You will notice that B does not have a receive statement of its own. It is relying on gen_server, so this will not help. > where Info is either the exit reason, noproc or noconnection. > You can terminate the process when this message is received. > > BTW I have a question too. If B is implemented in terms of > gen_server, I have to implement handle_info callback function > in order to react upon receive of a 'DOWN' message from the > monitor, right? Yes, that would be the thing to do. OTP behaviours are pretty strightforward once you get you head around them Sean From sean.hinde@REDACTED Wed Jan 24 16:12:54 2007 From: sean.hinde@REDACTED (Sean Hinde) Date: Wed, 24 Jan 2007 15:12:54 +0000 Subject: [erlang-questions] Programming question In-Reply-To: <6616D98C65DD514BA2E1DDC5F922315573BB53@esealmw115.eemea.ericsson.se> References: <6616D98C65DD514BA2E1DDC5F922315573BB53@esealmw115.eemea.ericsson.se> Message-ID: Well, we do not use OTP supervisors. We have our own which implements something not dissimilar to the timed backoff restarts that someone asked for recently on the list. It does not however support the *many supervisor strategies. Sean On 24 Jan 2007, at 14:22, Ulf Wiger ((TN/EAB)) wrote: > > Through the use of supervisors, you can either set up the > processes under a one_for_all supervisor or a rest_for_one, > where B is started after A. Then, if A dies, the supervisor > will kill B. > > BR, > Ulf W > >> -----Original Message----- >> From: erlang-questions-bounces@REDACTED >> [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Sean Hinde >> Sent: den 24 januari 2007 15:09 >> To: Mats Cronqvist (TN/EAB) >> Cc: Erlang Questions >> Subject: Re: [erlang-questions] Programming question >> >> >> On 24 Jan 2007, at 13:42, Mats Cronqvist wrote: >> >>> Sean Hinde wrote: >>>> Hi, >>>> >>>> A quick question for Erlang gurus out there. >>>> >>>> I have two processes A and B. B spends most of its life in >> a series >>>> of gen_server calls towards A: >>>> >>>> loopB(PidA, S) -> >>>> Res = gen_server:call(PidA, {op, stuff}), >>>> S1 = process(Res, S), >>>> loopB(PidA, S1). >>>> >>>> The question is how do I set things up so that if A dies B >> is killed? >>> >>> >>> as a non-guru, i was thinking that happened automatically >> as soon as >>> you made the call? >>> >>> 1> is_process_alive(Pid). >>> false >>> 2> gen_server:call(Pid, {op, stuff}). >>> ** exited: {noproc,{gen_server,call,[<0.14604.0>,{op,stuff}]}} ** >> >> loopB spends most of its time waiting for a reply to the >> call. The likelihood is that Process A will die during the >> processing of the call, not while it is being "sent". In that >> case the above will not happen. Question still stands :-) >> >> Sean >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> From sean.hinde@REDACTED Wed Jan 24 16:15:26 2007 From: sean.hinde@REDACTED (Sean Hinde) Date: Wed, 24 Jan 2007 15:15:26 +0000 Subject: [erlang-questions] Eclipse/Erlide autoindent problem In-Reply-To: <8F5ADC16-FA1F-4B18-B7A4-BEEA7FBD444F@zoominternet.net> References: <45B73ED1.2010802@volny.cz> <95be1d3b0701240327g79e9408fkaf118be8d7d7237b@mail.gmail.com> <45B75590.2040408@volny.cz> <8F5ADC16-FA1F-4B18-B7A4-BEEA7FBD444F@zoominternet.net> Message-ID: On 24 Jan 2007, at 14:34, Robert Baruch wrote: > > On Jan 24, 2007, at 7:48 AM, Ladislav Lenart wrote: > >> Vlad Dumitrescu wrote: > >> Or another one: What IDE do you use to write Erlang programs >> (anybody)? >> > > I currently use Emacs -- don't laugh! I use the Mac OSX version of > Emacs, which is Aquamacs Emacs. It seems to make more sense than > plain vanilla Emacs :) > > Of course, it isn't an IDE. When you add distel it becomes pretty close to one I'd say. Sean From sean.hinde@REDACTED Wed Jan 24 16:48:30 2007 From: sean.hinde@REDACTED (Sean Hinde) Date: Wed, 24 Jan 2007 15:48:30 +0000 Subject: [erlang-questions] Programming question In-Reply-To: <45B772F8.5000804@it.uu.se> References: <3D85890B-9358-4163-9A65-CCC5760AD8FC@gmail.com> <45B772F8.5000804@it.uu.se> Message-ID: <1F0B4B81-7018-48F4-A76A-5A97701B5DB5@gmail.com> On 24 Jan 2007, at 14:53, Richard Carlsson wrote: > Sean Hinde wrote: >> Hi, >> A quick question for Erlang gurus out there. >> I have two processes A and B. B spends most of its life in a >> series of gen_server calls towards A: >> loopB(PidA, S) -> >> Res = gen_server:call(PidA, {op, stuff}), >> S1 = process(Res, S), >> loopB(PidA, S1). >> The question is how do I set things up so that if A dies B is killed? > > Assuming that normal linking of B to A does not work (e.g. if B is > trapping exits, does not accept an exit message in the waiting state, > and you can't change the code of A and B), you could spawn a small > simple watchdog process, and link it to both A and B. It should wait > for the termination of either of them. If A dies, the watchdog kills > B by brute force, i.e., exit(B, kill). If B dies, the watchdog dies > with it, quietly. Apologies to all! There was an error in my example. gen_server does indeed do the right thing in this case. The problem occurs in this code: loopB(PidA, S) -> Res = (catch gen_server:call(PidA, {op, stuff})), S1 = process(Res, S), loopB(PidA, S1). Here the gen_server:call catches the {'EXIT', Reason} signal from the dying B process and turns it into a call to exit(Reason). process B just gets an {'EXIT', Reason} result to the call, but it doesn't know if Process A is still alive (there can be several reasons for the {'EXIT', Reason}. One fix might be for gen:call() to issue another exit signal towards the calling process after returning the result. Sean From lenartlad@REDACTED Wed Jan 24 16:52:06 2007 From: lenartlad@REDACTED (Ladislav Lenart) Date: Wed, 24 Jan 2007 16:52:06 +0100 Subject: [erlang-questions] Eclipse/Erlide autoindent problem In-Reply-To: <45B763C5.8010305@ericsson.com> References: <45B73ED1.2010802@volny.cz> <95be1d3b0701240327g79e9408fkaf118be8d7d7237b@mail.gmail.com> <45B75590.2040408@volny.cz> <45B763C5.8010305@ericsson.com> Message-ID: <45B780A6.6080205@volny.cz> Mats Cronqvist wrote: > Ladislav Lenart wrote: >> Or another one: What IDE do you use to write Erlang programs (anybody)? > > emacs. there is an official emacs mode, and with the distel and esense > contribs it integrates with the debugger and documentation (among other things). REALLY cool, thanks! Ladislav Lenart From lenartlad@REDACTED Wed Jan 24 16:23:50 2007 From: lenartlad@REDACTED (Ladislav Lenart) Date: Wed, 24 Jan 2007 16:23:50 +0100 Subject: [erlang-questions] Programming question In-Reply-To: <9036821B-65F3-401A-89CB-5590340B2AD2@gmail.com> References: <3D85890B-9358-4163-9A65-CCC5760AD8FC@gmail.com> <45B76CF2.2020400@volny.cz> <9036821B-65F3-401A-89CB-5590340B2AD2@gmail.com> Message-ID: <45B77A06.80204@volny.cz> Sean Hinde wrote: > > On 24 Jan 2007, at 14:28, Ladislav Lenart wrote: > >> Sean Hinde wrote: >>> Hi, >>> >>> A quick question for Erlang gurus out there. >>> >>> I have two processes A and B. B spends most of its life in a series >>> of gen_server calls towards A: >>> >>> loopB(PidA, S) -> >>> Res = gen_server:call(PidA, {op, stuff}), >>> S1 = process(Res, S), >>> loopB(PidA, S1). >>> >>> The question is how do I set things up so that if A dies B is killed? >> >> I am not a guru, but if "to die" means to terminate abnormally, >> you can link the two processes. BUT since links are bi-directional, >> if B dies, A will be killed as well. > > This won't do it. If A dies while processing the call from B, even when > linked, then B does not die. Sorry for my slowness, but why not? Ladislav Lenart From rrerlang@REDACTED Wed Jan 24 18:22:57 2007 From: rrerlang@REDACTED (Robert Raschke) Date: Wed, 24 Jan 2007 17:22:57 +0000 Subject: [erlang-questions] Eclipse/Erlide autoindent problem In-Reply-To: <45B76B0C.6050405@ericsson.com> Message-ID: Bengt wrote: > On 2007-01-24 13:48, Ladislav Lenart wrote: > ...deleted >> Or another one: What IDE do you use to write Erlang programs (anybody)? > > acme (in its wily disguise: http://sourceforge.net/projects/wily/ ) > seconded, although I'm running it on Windows via the stunning acme stand alone version from http://caerwyn.com/acme/ Robby -- r dot raschke at tombob dot com From jh-erlang@REDACTED Wed Jan 24 18:37:05 2007 From: jh-erlang@REDACTED (Justin Heesemann) Date: Wed, 24 Jan 2007 18:37:05 +0100 Subject: [erlang-questions] weird problem with erl and ouput to stdout(?) Message-ID: <200701241837.05468.jh-erlang@ionium.org> hi.. i've successfully compiled erlang on a amd64 with selinux/grsecurity kernel. gcc version 4.1.1 (Gentoo 4.1.1-r1) glibc version 2.4 now when i run "erl" for example, it simply segfaults. # ./erl Segmentation fault funny thing is: # ./erl | cat Eshell V5.5.2 (abort with ^G) 1> works just fine! and so it does, when i redirect the output of erl in any other way.. the last things the non working ( output to stdout) version does is: stat("/usr/local/src/otp_src_R11B-2/lib/stdlib/ebin/io_lib_format.beam", {st_mode=S_IFREG|0644, st_size=193 84, ...}) = 0 open("/usr/local/src/otp_src_R11B-2/lib/stdlib/ebin/io_lib_format.beam", O_RDONLY) = 3 read(3, "FOR1\0\0K\260BEAMAtom\0\0\2d\0\0\0G\rio_lib_"..., 19384) = 19384 close(3) = 0 getcwd("/usr/local/src/otp_src_R11B-2/bin", 8191) = 34 --- SIGSEGV (Segmentation fault) @ 0 (0) --- +++ killed by SIGSEGV +++ Process 10240 detached oh.. and i tried it with hipe and without, with threads and without, with smp and without... -- Justin From klacke@REDACTED Wed Jan 24 19:50:40 2007 From: klacke@REDACTED (Claes Wikstrom) Date: Wed, 24 Jan 2007 19:50:40 +0100 Subject: [erlang-questions] Programming question In-Reply-To: <1F0B4B81-7018-48F4-A76A-5A97701B5DB5@gmail.com> References: <3D85890B-9358-4163-9A65-CCC5760AD8FC@gmail.com> <45B772F8.5000804@it.uu.se> <1F0B4B81-7018-48F4-A76A-5A97701B5DB5@gmail.com> Message-ID: <45B7AA80.3070608@hyber.org> Sean Hinde wrote: > > One fix might be for gen:call() to issue another exit signal towards > the calling process after returning the result. > Uhhh I wonder how much code would break by that. Quite a lot. -klacke From klacke@REDACTED Wed Jan 24 19:52:17 2007 From: klacke@REDACTED (Claes Wikstrom) Date: Wed, 24 Jan 2007 19:52:17 +0100 Subject: [erlang-questions] weird problem with erl and ouput to stdout(?) In-Reply-To: <200701241837.05468.jh-erlang@ionium.org> References: <200701241837.05468.jh-erlang@ionium.org> Message-ID: <45B7AAE1.5010508@hyber.org> Justin Heesemann wrote: > hi.. > i've successfully compiled erlang on a amd64 with selinux/grsecurity kernel. > gcc version 4.1.1 (Gentoo 4.1.1-r1) > glibc version 2.4 > > now when i run "erl" for example, it simply segfaults. > > # ./erl > Segmentation fault > > funny thing is: > # ./erl | cat > Eshell V5.5.2 (abort with ^G) > 1> try # erl -oldshell Does that work ?? /klacke From sean.hinde@REDACTED Wed Jan 24 20:01:45 2007 From: sean.hinde@REDACTED (Sean Hinde) Date: Wed, 24 Jan 2007 19:01:45 +0000 Subject: [erlang-questions] Programming question In-Reply-To: <45B7AA80.3070608@hyber.org> References: <3D85890B-9358-4163-9A65-CCC5760AD8FC@gmail.com> <45B772F8.5000804@it.uu.se> <1F0B4B81-7018-48F4-A76A-5A97701B5DB5@gmail.com> <45B7AA80.3070608@hyber.org> Message-ID: On 24 Jan 2007, at 18:50, Claes Wikstrom wrote: > Sean Hinde wrote: > >> One fix might be for gen:call() to issue another exit signal >> towards the calling process after returning the result. > > Uhhh I wonder how much code would break by that. Quite a lot. Are you sure? The two processes are linked, so presumably the caller wants to receive exit signals. Indeed the caller will always receive an 'EXIT' signal whenever the linked process dies, *except* if it dies while handling a call from the caller which is wrapped in a catch. Seems to me that if there is a backwards compatibilty issue, it is that other bugs are hidden by this behaviour which are just waiting to happen. Sean > > -klacke From jh-erlang@REDACTED Wed Jan 24 20:09:54 2007 From: jh-erlang@REDACTED (Justin Heesemann) Date: Wed, 24 Jan 2007 20:09:54 +0100 Subject: [erlang-questions] weird problem with erl and ouput to stdout(?) In-Reply-To: <45B7AAE1.5010508@hyber.org> References: <200701241837.05468.jh-erlang@ionium.org> <45B7AAE1.5010508@hyber.org> Message-ID: <200701242009.54239.jh-erlang@ionium.org> On Wednesday, January 24, 2007 07:52:17 PM you wrote: > try > > # erl -oldshell > > Does that work?? > > /klacke it does. /me stares at the erl prompt. how did you do that??? how and why does it work?? -- Justin From ok@REDACTED Thu Jan 25 03:26:16 2007 From: ok@REDACTED (Richard A. O'Keefe) Date: Thu, 25 Jan 2007 15:26:16 +1300 (NZDT) Subject: [erlang-questions] OO programming style in Erlang? Message-ID: <200701250226.l0P2QGVK193451@atlas.otago.ac.nz> Ladislav Lenart wrote: No, this is not what I was worrying about. It seemed strange to me that I have to know exactly which function I need to invoke on a particular item. That is because it is precisely the *function* that you are expected to be primarily interested in; the data is there to let the function do its job, as it were. In Smalltalk, I just write "aCollection can be anything - List, Set, Dictionary, ..." aCollection collect: [:each | each something]. because aCollection knows what kind of collection it actually is. Speaking as someone who is still trying to finish his own Smalltalk compiler, it really isn't quite that simple, even in Smalltalk. To start with, what does #collect: return? List: my Smalltalk doesn't have one, but LinkedList>>collect: unexpectedly returns an Array, not a LinkedList; Dictionary: you would *expect* this definition, collect: aBlock |result| result := self copyEmpty. self keysAndValuesDo: [:key :value | result at: key put: (aBlock value: value)]. ^result but in fact you get an OrderedCollection Set>>collect: returns a Set, and surprisingly to many people, so does IdentitySet>>collect: The real gem is ByteVector>>collect: where I have had to file bug reports in two Smalltalk systems because it was originally written to return a ByteVector, but there is of course no guarantee that the function passed to it will provide byte results. For real grins/groans, try this: 'abc' collect: [:x | 2] Arguably a system that follows the ANSI Smalltalk standard must get this and the ByteVector case wrong. My SequencedReadableCollection class goes to quite a lot of trouble: first it builds an array of the results, then it checks whether something just like the receiver could hold them. If it could, it returns something like the receiver, if not, an Array. So 'abc' collect: [:each | each asUppercase] => 'ABC' 'abc' collect: [:each | 2] => #(2 2 2) Ahem. The point I want to establish here is You don't need to know what the receiver is in order to know >>what selector to use<<, but you DO need to know what the receiver is in order to know - whether it will work at all - what you will get if it does. Let's take one more example, Set>>collect:. If we are mapping over a set, there are at least four cases: - we want exactly one element in the result for each element in the source, whether any of them are equal or not => Array withAll: set collect: aBlock "mine" or (Array withAll: set) collect: aBlock "ANSI, less efficient" - we want a set of results, and the way to tell whether two results are equal is the built in #= method => Set withAll: set collect: aBlock or set collect: aBlock - we want a set of results, but two results are to count as equal if and only if they are the very same object (#==) => IdentitySet withAll: set collect: aBlock "mine" - we want a set of results, but we need another definition of equality (say, ignoring alphabetic case) => (PluggableSet equalBlock: #equalsIgnoringCase: hashBlock: #hashIgnoringCase:) addAll: set collecting: aBlock In Erlang, I have to know lists:map(...) dict:map(...) orddict:map(...) Furthemore lists:map expects fun/1 while dict/orddict:map expects fun/2. Not "furthermore", BECAUSE list mapping and dictionary mapping have different interfaces you have to know which one you are going to call. lists:map(L, F) is the equivalent of OrderedCollection>>collect:. dict:map(D, F) is the equivalent of Dictionary>>keysAndValuesCollect:, or it would be if #keysAndValuesCollect: existed. The orddict module is extremely unusual in having the same interface as the dict module. However, it does NOT have the same PERFORMANCE characteristics. So once again, if you want to have any idea how well your code is likely to work, you had BETTER know which version you are using. (And wouldn't it be nice if the documentation said something about performance?) In fact, there really aren't that many places that you would want to use orddict at all. I got some good suggestions to deal with this issue, wrapper functions and macros. No, those are not good suggestsions, because they are all about helping you hide information that is actually important to you. One thing I have found in writing my own Smalltalk system (27 kSLOC in the library and rising) is that every time I add a new leaf class to an existing tree of classes, refactoring is needed, sometimes extensive refactoring, despite modelling the interfaces on a 26+-year-old success. One thing I have found in using existing Smalltalk systems is that very often inherited methods *don't* work (see String>>collect: above). The thing I don't like is that I have to solve it myself... For the reasons given above, I just plain CANNOT believe that there is a genuine problem with Erlang that you need to solve. The problem that you have is in your expectation that things *should* work in Erlang as they *don't in fact* work in OO languages. There really are very very very few cases where one data structure can be substituted for another in Erlang. From ok@REDACTED Thu Jan 25 03:37:21 2007 From: ok@REDACTED (Richard A. O'Keefe) Date: Thu, 25 Jan 2007 15:37:21 +1300 (NZDT) Subject: [erlang-questions] lists:reverse/1 as a built-in function Message-ID: <200701250237.l0P2bLT4198426@atlas.otago.ac.nz> From erlang-questions-bounces@REDACTED Thu Jan 25 02:17:02 2007 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=sK6YA9ORDeNrI63kxUfziw15UKRBly2B2JZu04y70NLvcrkDzZ1L/LB8v/zI8P1ow4aPS2ZWe46F+q27IkA9CFWCF3S+E+eiD+aIlUW7LN5eZbAkBsPTRk3BdN5ZrF56naz2ETxU/85DgKIaquzJpHaRLdzGPbPD4jeQPJDlAwU= Date: Wed, 24 Jan 2007 14:11:10 +0100 From: To: "Erlang list" In-Reply-To: <45B730D0.3020105@REDACTED> MIME-Version: 1.0 Content-Disposition: inline References: <200701170438.l0H4cHOp145653@REDACTED> <45AFF43A.8040601@REDACTED> <45B730D0.3020105@REDACTED> Cc: erlang-questions@REDACTED Subject: Re: [erlang-questions] lists:reverse/1 as a built-in function X-BeenThere: erlang-questions@REDACTED X-Mailman-Version: 2.1.6 Precedence: list List-Id: Erlang/OTP discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: erlang-questions-bounces@REDACTED Errors-To: erlang-questions-bounces@REDACTED X-PMX-Version: 5.3.0.289146, Antispam-Engine: 2.5.0.283055, Antispam-Data: 2007.1.24.50433 X-PerlMx-Spam: Gauge=IIIIIII, Probability=7%, Report='__CD 0, __CP_URI_IN_BODY 0, __CT 0, __CTE 0, __CTYPE_CHARSET_QUOTED 0, __CT_TEXT_PLAIN 0, __HAS_MSGID 0, __MIME_TEXT_ONLY 0, __MIME_VERSION 0, __SANE_MSGID 0' X-OriginalArrivalTime: 24 Jan 2007 13:17:01.0866 (UTC) FILETIME=[EF3DE8A0:01C73FB9] On 1/24/07, Erlang list wrote: > What about also adding in module aliases at the same time? If you had > -alias(mypkg, erlang). as a way of saying that mypkg:* is an alias > for erlang:* you might help or avoid a lot of migration issues. > Alternatively, you could have compiler switches instead. "Christian S" replied: This would break existing semantics. I think it would be worth it though (if accompanied by Richard O'Keefe's reified environments idea [1]). Just a quick reminder: my "reified environments idea" says that the world contains modules and environments. Each module lives in some specific environment, and module/environment names that the module uses are interpreted in that environment. An environment contains mappings for names (exactly like a file system directory) and some names are mapped to modules (like files) and some are mapped to environments (like directories). One of the main points is that you should be able to have a group of modules sharing an environment (more or less an application) and then you should be able to name one of those modules in another environment (the "facade" or "entry" module), and the two names don't have to be the same. I didn't think about multiple names for the same module in the same environment, but it's just like hard links in UNIX, so why not? From klacke@REDACTED Thu Jan 25 08:44:59 2007 From: klacke@REDACTED (Claes Wikstrom) Date: Thu, 25 Jan 2007 08:44:59 +0100 Subject: [erlang-questions] weird problem with erl and ouput to stdout(?) In-Reply-To: <200701242009.54239.jh-erlang@ionium.org> References: <200701241837.05468.jh-erlang@ionium.org> <45B7AAE1.5010508@hyber.org> <200701242009.54239.jh-erlang@ionium.org> Message-ID: <45B85FFB.8020700@hyber.org> Justin Heesemann wrote: > On Wednesday, January 24, 2007 07:52:17 PM you wrote: >> try >> >> # erl -oldshell >> >> Does that work?? >> >> /klacke > > it does. > /me stares at the erl prompt. > how did you do that??? > > how and why does it work?? > > since it worked when you tried it through a pipe. The oldshell option doesn't use the so called ttsl_drv.c driver to handle the terminal - it just uses read/write to fd 0/1 Hence there is a problem with the terminal driver. You may try to check which version/variant you have of the ncurses libs /klacke From vladdu55@REDACTED Thu Jan 25 08:57:00 2007 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Thu, 25 Jan 2007 08:57:00 +0100 Subject: [erlang-questions] lists:reverse/1 as a built-in function In-Reply-To: References: <200701170438.l0H4cHOp145653@atlas.otago.ac.nz> <45AFF43A.8040601@telia.com> <45B730D0.3020105@oxyware.com> Message-ID: <95be1d3b0701242357pf2f6d2ax8e017e518fc51c20@mail.gmail.com> Hi, On 1/24/07, Christian S wrote: > Right now we do not have actual module objects, we only have names for > them. The alternative you represent would mean that the module name > "foo" could refer to different modules (or no module at all) when > called as Mod:fun() from other modules. Just a pedantic pointer: even today, if you use for example lists:reverse(L) you can't be sure if it is the stdlib lists module, because the system's code path may contain another lists.beam before the stdlib one... Of course, in practice this doesn't happen, but it's not imposed by the system or the compiler, just by discipline and best practices. best regards, Vlad From mats.cronqvist@REDACTED Thu Jan 25 09:23:33 2007 From: mats.cronqvist@REDACTED (Mats Cronqvist) Date: Thu, 25 Jan 2007 09:23:33 +0100 Subject: [erlang-questions] Programming question In-Reply-To: <1F0B4B81-7018-48F4-A76A-5A97701B5DB5@gmail.com> References: <3D85890B-9358-4163-9A65-CCC5760AD8FC@gmail.com> <45B772F8.5000804@it.uu.se> <1F0B4B81-7018-48F4-A76A-5A97701B5DB5@gmail.com> Message-ID: <45B86905.5000100@ericsson.com> Sean Hinde wrote: > > There was an error in my example. gen_server does indeed do the right > thing in this case. The problem occurs in this code: > > loopB(PidA, S) -> > Res = (catch gen_server:call(PidA, {op, stuff})), > S1 = process(Res, S), > loopB(PidA, S1). > Here the gen_server:call catches the {'EXIT', Reason} signal from the > dying B process and turns it into a call to exit(Reason). > > process B just gets an {'EXIT', Reason} result to the call, but it > doesn't know if Process A is still alive (there can be several > reasons for the {'EXIT', Reason}. > One fix might be for gen:call() to issue another exit signal towards > the calling process after returning the result. surely if you catch the exit and it turns out you really wanted it, you should re-throw? how about try Res = gen_server:call(PidA, {op, stuff}), S1 = process(Res, S), loopB(PidA, S1) catch C:R -> case is_process_alive(PidA) of true -> loopB(PidA,dosomething({C,R},S)); false -> exit({C,R}) end end mats From sgolovan@REDACTED Thu Jan 25 12:12:17 2007 From: sgolovan@REDACTED (Sergei Golovan) Date: Thu, 25 Jan 2007 14:12:17 +0300 Subject: [erlang-questions] Erlang in Debian on m68k architecture Message-ID: Hi! As one can see, erlang Debian package (R11B-2 relese, 11.b.2 in Debian versioning) fails to build on m68k now (http://buildd.debian.org/fetch.cgi?&pkg=erlang&ver=1%3A11.b.2-4&arch=m68k&stamp=1167824208&file=log). After some research, we've found that erlang relies on the alignment of some global variable. The following patch fixes it: ------------------------------------------------------------------ --- erlang-11.b.2.orig/erts/emulator/beam/binary.c +++ erlang-11.b.2/erts/emulator/beam/binary.c @@ -31,7 +31,7 @@ #include "erl_bits.h" Uint erts_allocated_binaries; -erts_mtx_t erts_bin_alloc_mtx; +erts_mtx_t erts_bin_alloc_mtx __attribute__ ((aligned (4))); void erts_init_binary(void) ------------------------------------------------------------------ So, the question is the following: Are global variables supposed to be always aligned? Is this a bug in GCC that it doesn't align the variable? Or is this a bug in erlang, and the fact that it works on other architectures is a lucky coincidence? Best wishes! -- Sergei Golovan From sean.hinde@REDACTED Thu Jan 25 12:47:55 2007 From: sean.hinde@REDACTED (Sean Hinde) Date: Thu, 25 Jan 2007 11:47:55 +0000 Subject: [erlang-questions] Programming question In-Reply-To: <45B86905.5000100@ericsson.com> References: <3D85890B-9358-4163-9A65-CCC5760AD8FC@gmail.com> <45B772F8.5000804@it.uu.se> <1F0B4B81-7018-48F4-A76A-5A97701B5DB5@gmail.com> <45B86905.5000100@ericsson.com> Message-ID: On 25 Jan 2007, at 08:23, Mats Cronqvist wrote: > Sean Hinde wrote: >> >> One fix might be for gen:call() to issue another exit signal towards >> the calling process after returning the result. > > surely if you catch the exit and it turns out you really wanted > it, you > should re-throw? > > how about > > try > Res = gen_server:call(PidA, {op, stuff}), > S1 = process(Res, S), > loopB(PidA, S1) > catch > C:R -> > case is_process_alive(PidA) of > true -> loopB(PidA,dosomething({C,R},S)); > false -> exit({C,R}) > end > end This would work, but my is it ugly - how is anyone supposed to remember to do that every time they want to be sure that the called process has gone down (as opposed to any other reason for the call to thrown an exception). The problem as I see it is that the calling process only sometimes get its 'EXIT' message - it depends on context. Sean From mikpe@REDACTED Thu Jan 25 12:48:50 2007 From: mikpe@REDACTED (Mikael Pettersson) Date: Thu, 25 Jan 2007 12:48:50 +0100 Subject: [erlang-questions] Erlang in Debian on m68k architecture In-Reply-To: References: Message-ID: <17848.39202.780026.211263@alkaid.it.uu.se> Sergei Golovan writes: > Hi! > > As one can see, erlang Debian package (R11B-2 relese, 11.b.2 in Debian > versioning) fails to build on m68k now > (http://buildd.debian.org/fetch.cgi?&pkg=erlang&ver=1%3A11.b.2-4&arch=m68k&stamp=1167824208&file=log). > > After some research, we've found that erlang relies on the alignment > of some global variable. The following patch fixes it: > ------------------------------------------------------------------ > --- erlang-11.b.2.orig/erts/emulator/beam/binary.c > +++ erlang-11.b.2/erts/emulator/beam/binary.c > @@ -31,7 +31,7 @@ > #include "erl_bits.h" > > Uint erts_allocated_binaries; > -erts_mtx_t erts_bin_alloc_mtx; > +erts_mtx_t erts_bin_alloc_mtx __attribute__ ((aligned (4))); > > void > erts_init_binary(void) > ------------------------------------------------------------------ > > So, the question is the following: Are global variables supposed to be > always aligned? Is this a bug in GCC that it doesn't align the > variable? Definitely smells like a toolchain bug to me. In this case, since you've enabled threads, erts_mtx_t is a properly declared struct type containing among other things a pthread_mutex_t, an int, and a couple of pointers. I don't remember how strict M68K is about alignment, but presumably it wants non-arbitrary alignment for word-sized fields, especially perhaps if they're used for atomic accesses. The error could be in gcc, gas, ld, or even libc. As GDB session on the core dump should tell us more about the location of the crash, the failing instruction, and what data it tried to access. /Mikael From mats.cronqvist@REDACTED Thu Jan 25 13:08:24 2007 From: mats.cronqvist@REDACTED (Mats Cronqvist) Date: Thu, 25 Jan 2007 13:08:24 +0100 Subject: [erlang-questions] Programming question In-Reply-To: References: <3D85890B-9358-4163-9A65-CCC5760AD8FC@gmail.com> <45B772F8.5000804@it.uu.se> <1F0B4B81-7018-48F4-A76A-5A97701B5DB5@gmail.com> <45B86905.5000100@ericsson.com> Message-ID: <45B89DB8.3090201@ericsson.com> Sean Hinde wrote: > > On 25 Jan 2007, at 08:23, Mats Cronqvist wrote: > >> Sean Hinde wrote: >>> >>> One fix might be for gen:call() to issue another exit signal towards >>> the calling process after returning the result. >> >> surely if you catch the exit and it turns out you really wanted it, >> you >> should re-throw? >> >> how about >> >> try >> Res = gen_server:call(PidA, {op, stuff}), >> S1 = process(Res, S), >> loopB(PidA, S1) >> catch >> C:R -> >> case is_process_alive(PidA) of >> true -> loopB(PidA,dosomething({C,R},S)); >> false -> exit({C,R}) >> end >> end > > This would work, but my is it ugly - hey! it took me several seconds to write that code! some respect please :> > how is anyone supposed to remember > to do that every time they want to be sure that the called process has > gone down (as opposed to any other reason for the call to thrown an > exception). > > The problem as I see it is that the calling process only sometimes get > its 'EXIT' message - it depends on context. but it does get it's exit message. always. the "context" is that you catch it and throw it away... mats p.s. i wonder if C and R above (the exception class and reason) will give you enough info the distinguish a dead server from other causes of exits. maybe it ought to be something like this; try gen_server:call(PidA, {op, stuff}) of Res -> loopB(PidA, process(Res, S)) catch exit:{no_proc,_} -> exit(server_was_dead_when_we_called); exit:insert_correct_value -> exit(server_died_while_processing); C:R -> loopB(PidA,handle_other_errors({C,R},S)) end the 4 branches here are unavoidable, i think, since there are 4 different outcomes to the gen_server call. From sgolovan@REDACTED Thu Jan 25 13:19:51 2007 From: sgolovan@REDACTED (Sergei Golovan) Date: Thu, 25 Jan 2007 15:19:51 +0300 Subject: [erlang-questions] Erlang in Debian on m68k architecture In-Reply-To: <17848.39202.780026.211263@alkaid.it.uu.se> References: <17848.39202.780026.211263@alkaid.it.uu.se> Message-ID: On 1/25/07, Mikael Pettersson wrote: > Definitely smells like a toolchain bug to me. In this case, since you've > enabled threads, erts_mtx_t is a properly declared struct type containing > among other things a pthread_mutex_t, an int, and a couple of pointers. > I don't remember how strict M68K is about alignment, but presumably it wants > non-arbitrary alignment for word-sized fields, especially perhaps if they're > used for atomic accesses. > > The error could be in gcc, gas, ld, or even libc. > > As GDB session on the core dump should tell us more about the location > of the crash, the failing instruction, and what data it tried to access. Here are two backtraces, without and with DEBUG defined. If you need some additional info, I'll try to give it also Without debug: ----------------------------------------------------- Program terminated with signal 11, Segmentation fault. #0 0x8007783a in erts_garbage_collect (p=0xc03000e4, need=5, objv=0x800f8764, nobj=1) at beam/ggc.c:1814 1814 MOVE_BOXED(ptr,val,n_htop,g_ptr++); (gdb) bt #0 0x8007783a in erts_garbage_collect (p=0xc03000e4, need=5, objv=0x800f8764, nobj=1) at beam/ggc.c:1814 #1 0x80089348 in process_main () at m68k-unknown-linux-gnu/opt/plain/beam_hot.h:1368 #2 0x8002a236 in erl_start (argc=37, argv=0xeffff594) at beam/erl_init.c:928 #3 0x80017daa in main (argc=37, argv=0xeffff594) at sys/unix/erl_main.c:28 (gdb) p erts_garbage_collect::p $1 = (Process *) 0xc03000e4 (gdb) p erts_garbage_collect::ptr No symbol "ptr" in specified context. (gdb) p erts_garbage_collect::val No symbol "val" in specified context. ----------------------------------------------------- With debug. ----------------------------------------------------- (gdb) bt #0 0xc0103522 in kill () from /lib/libc.so.6 #1 0xc004a87e in pthread_kill () from /lib/libpthread.so.0 #2 0xc004a8b6 in raise () from /lib/libpthread.so.0 #3 0xc0103380 in raise () from /lib/libc.so.6 #4 0xc0104266 in abort () from /lib/libc.so.6 #5 0x8009b534 in et_abort (expr=0x800fb643 "_is_aligned(x)", file=0x800fa37f "beam/erl_lock_check.c", line=1018) at beam/erl_term.c:45 #6 0x8009c1b4 in checked_make_boxed (x=0x0, file=0x800fa37f "beam/erl_lock_check.c", line=1018) at beam/erl_term.c:123 #7 0x80092bca in erts_lc_init_lock (lck=0x8015abe2, name=0x800f0178 "binary_alloc", flags=0) at beam/erl_lock_check.c:1018 #8 0x800504c0 in erts_mtx_init (mtx=0x8015abba, name=0x800f0178 "binary_alloc") at beam/erl_threads.h:249 #9 0x800731e6 in erts_init_binary () at beam/binary.c:40 #10 0x8002d85c in erl_init () at beam/erl_init.c:211 #11 0x8002e568 in erl_start (argc=37, argv=0xeffff58c) at beam/erl_init.c:907 #12 0x8001a6fe in main (argc=37, argv=0xeffff584) at sys/unix/erl_main.c:28 ----------------------------------------------------- -- Sergei Golovan From sean.hinde@REDACTED Thu Jan 25 13:26:43 2007 From: sean.hinde@REDACTED (Sean Hinde) Date: Thu, 25 Jan 2007 12:26:43 +0000 Subject: [erlang-questions] Programming question In-Reply-To: <45B89DB8.3090201@ericsson.com> References: <3D85890B-9358-4163-9A65-CCC5760AD8FC@gmail.com> <45B772F8.5000804@it.uu.se> <1F0B4B81-7018-48F4-A76A-5A97701B5DB5@gmail.com> <45B86905.5000100@ericsson.com> <45B89DB8.3090201@ericsson.com> Message-ID: <1C56697A-2407-4501-8EC0-B9BE239742FF@gmail.com> On 25 Jan 2007, at 12:08, Mats Cronqvist wrote: > Sean Hinde wrote: >> >> On 25 Jan 2007, at 08:23, Mats Cronqvist wrote: >> >>> Sean Hinde wrote: >>>> >>>> One fix might be for gen:call() to issue another exit signal >>>> towards >>>> the calling process after returning the result. >>> >>> surely if you catch the exit and it turns out you really >>> wanted it, >>> you >>> should re-throw? >>> >>> how about >>> >>> try >>> Res = gen_server:call(PidA, {op, stuff}), >>> S1 = process(Res, S), >>> loopB(PidA, S1) >>> catch >>> C:R -> >>> case is_process_alive(PidA) of >>> true -> loopB(PidA,dosomething({C,R},S)); >>> false -> exit({C,R}) >>> end >>> end >> >> This would work, but my is it ugly - > > hey! it took me several seconds to write that code! some respect > please :> Heh Heh. OK, It's beautiful code, if it makes you feel better, but as a required construct it is still ugly :-) >> >> The problem as I see it is that the calling process only sometimes >> get >> its 'EXIT' message - it depends on context. > > but it does get it's exit message. always. the "context" is that > you catch it > and throw it away... No! Receiving an exit message is different to catching an exception. The problem is that the gen_server:call mechanism does just that, it catches an exit message from the called process and turns it into a simple exception. This is why I suggest that *if* the exception thrown by gen_server:call was actually caused by an exit message from the called process then the gen_server should throw the exception *and* resend the EXIT message to the called process. Sean From richardc@REDACTED Thu Jan 25 13:35:11 2007 From: richardc@REDACTED (Richard Carlsson) Date: Thu, 25 Jan 2007 13:35:11 +0100 Subject: [erlang-questions] Programming question In-Reply-To: References: <3D85890B-9358-4163-9A65-CCC5760AD8FC@gmail.com> <45B772F8.5000804@it.uu.se> <1F0B4B81-7018-48F4-A76A-5A97701B5DB5@gmail.com> <45B86905.5000100@ericsson.com> Message-ID: <45B8A3FF.1080401@it.uu.se> Sean Hinde wrote: > On 25 Jan 2007, at 08:23, Mats Cronqvist wrote: >> try >> Res = gen_server:call(PidA, {op, stuff}), >> S1 = process(Res, S), >> loopB(PidA, S1) >> catch >> C:R -> >> case is_process_alive(PidA) of >> true -> loopB(PidA,dosomething({C,R},S)); >> false -> exit({C,R}) >> end >> end > > This would work, but my is it ugly - how is anyone supposed to > remember to do that every time they want to be sure that the called > process has gone down (as opposed to any other reason for the call to > thrown an exception). > > The problem as I see it is that the calling process only sometimes > get its 'EXIT' message - it depends on context. If you have a library that uses the RPC model, as in the case of 'gen_server:call(...)', it is probably a bad idea to try to solve the problems with RPC that have been known for ages, such as "what do I do if the server goes down", by adding some ad-hoc handling code to every remote call. (It can and will be screwed up anyway.) I think that the interface should be used as it was intended (treating exceptions due to server-down as any other exception out from the call), and that additional supervision should be placed somewhere else, outside the main program logic. Sean is basically right here: he _ought_ to be able to use normal links for this purpose (after all, links are the central built-in "additional supervision" method in Erlang), regardless of whether the implementation of gen_server:call() does things with links and trapping of signals: that stuff should have been made transparent to the user, but is obviously not. (One problem is that there can only be a single link between two processes, so gen_server can't know whether or not it should re-issue the caught signal to the caller.) If this aspect of gen_server (and similar library functions) cannot be fixed, e.g. by using monitors instead of links, then at a minimum it should be documented that the functions will steal exit signals if you try to link directly to the server. Meanwhile, the fix I suggested previously should work fine: use an intermediate process, whose signals the gen_server library does not interfere with. /Richard From erlang@REDACTED Thu Jan 25 13:33:47 2007 From: erlang@REDACTED (Hubert Matthews) Date: Thu, 25 Jan 2007 12:33:47 +0000 Subject: [erlang-questions] Inferno - erroneous comments about Erlang? Message-ID: <45B8A3AB.5040209@oxyware.com> http://www.vitanuova.com/mkt/press/Inferno_overview.pdf contains at the end a table comparing Inferno, Erlang and lots of other approaches to distributed systems. I think they are incorrect about a lot of stuff in this table, particularly about Erlang. Any comments? -- Hubert Matthews http://www.oxyware.com/ Software Consultant hubert@REDACTED From mikpe@REDACTED Thu Jan 25 13:46:10 2007 From: mikpe@REDACTED (Mikael Pettersson) Date: Thu, 25 Jan 2007 13:46:10 +0100 Subject: [erlang-questions] Erlang in Debian on m68k architecture In-Reply-To: References: <17848.39202.780026.211263@alkaid.it.uu.se> Message-ID: <17848.42642.955433.454642@alkaid.it.uu.se> Sergei Golovan writes: > On 1/25/07, Mikael Pettersson wrote: > > Definitely smells like a toolchain bug to me. In this case, since you've > > enabled threads, erts_mtx_t is a properly declared struct type containing > > among other things a pthread_mutex_t, an int, and a couple of pointers. > > I don't remember how strict M68K is about alignment, but presumably it wants > > non-arbitrary alignment for word-sized fields, especially perhaps if they're > > used for atomic accesses. > > > > The error could be in gcc, gas, ld, or even libc. > > > > As GDB session on the core dump should tell us more about the location > > of the crash, the failing instruction, and what data it tried to access. > > Here are two backtraces, without and with DEBUG defined. If you need > some additional info, I'll try to give it also ... > With debug. > ----------------------------------------------------- > (gdb) bt > #0 0xc0103522 in kill () from /lib/libc.so.6 > #1 0xc004a87e in pthread_kill () from /lib/libpthread.so.0 > #2 0xc004a8b6 in raise () from /lib/libpthread.so.0 > #3 0xc0103380 in raise () from /lib/libc.so.6 > #4 0xc0104266 in abort () from /lib/libc.so.6 > #5 0x8009b534 in et_abort (expr=0x800fb643 "_is_aligned(x)", > file=0x800fa37f "beam/erl_lock_check.c", line=1018) at > beam/erl_term.c:45 > #6 0x8009c1b4 in checked_make_boxed (x=0x0, file=0x800fa37f > "beam/erl_lock_check.c", line=1018) at beam/erl_term.c:123 > #7 0x80092bca in erts_lc_init_lock (lck=0x8015abe2, name=0x800f0178 > "binary_alloc", flags=0) at beam/erl_lock_check.c:1018 > #8 0x800504c0 in erts_mtx_init (mtx=0x8015abba, name=0x800f0178 > "binary_alloc") at beam/erl_threads.h:249 > #9 0x800731e6 in erts_init_binary () at beam/binary.c:40 > #10 0x8002d85c in erl_init () at beam/erl_init.c:211 > #11 0x8002e568 in erl_start (argc=37, argv=0xeffff58c) at beam/erl_init.c:907 > #12 0x8001a6fe in main (argc=37, argv=0xeffff584) at sys/unix/erl_main.c:28 > ----------------------------------------------------- What's happening is that an embedded Eterm field in the mutex, placed there and used by the lock checker, isn't word-aligned, which triggers an abort() in make_boxed(). In your non-debug GDB trace this error went unnoticed but later on _seriously_ broke the GC. The problem is still one of alignment. It seems that your M68K toolchain doesn't align struct { int x; } var; to a 32-bit boundary. Whether that is the bug, or whether the lock checker's alignment-of-static-data assumption is the bug, I cannot tell until someone sends me a pointer to the M68K Linux (or SVR4) ABI document. /Mikael From richardc@REDACTED Thu Jan 25 13:53:36 2007 From: richardc@REDACTED (Richard Carlsson) Date: Thu, 25 Jan 2007 13:53:36 +0100 Subject: [erlang-questions] Inferno - erroneous comments about Erlang? In-Reply-To: <45B8A3AB.5040209@oxyware.com> References: <45B8A3AB.5040209@oxyware.com> Message-ID: <45B8A850.20401@it.uu.se> Hubert Matthews wrote: > http://www.vitanuova.com/mkt/press/Inferno_overview.pdf > > contains at the end a table comparing Inferno, Erlang and lots of > other approaches to distributed systems. I think they are incorrect > about a lot of stuff in this table, particularly about Erlang. Any > comments? Indeed - they should check every box except "native OS". /Richard From mats.cronqvist@REDACTED Thu Jan 25 13:57:38 2007 From: mats.cronqvist@REDACTED (Mats Cronqvist) Date: Thu, 25 Jan 2007 13:57:38 +0100 Subject: [erlang-questions] Programming question In-Reply-To: <1C56697A-2407-4501-8EC0-B9BE239742FF@gmail.com> References: <3D85890B-9358-4163-9A65-CCC5760AD8FC@gmail.com> <45B772F8.5000804@it.uu.se> <1F0B4B81-7018-48F4-A76A-5A97701B5DB5@gmail.com> <45B86905.5000100@ericsson.com> <45B89DB8.3090201@ericsson.com> <1C56697A-2407-4501-8EC0-B9BE239742FF@gmail.com> Message-ID: <45B8A942.4070808@ericsson.com> Sean Hinde wrote: > No! Receiving an exit message is different to catching an exception. The > problem is that the gen_server:call mechanism does just that, it catches > an exit message from the called process and turns it into a simple > exception. > > This is why I suggest that *if* the exception thrown by gen_server:call > was actually caused by an exit message from the called process then the > gen_server should throw the exception *and* resend the EXIT message to > the called process. my bad. you are obviously correct. mats From sgolovan@REDACTED Thu Jan 25 15:22:06 2007 From: sgolovan@REDACTED (Sergei Golovan) Date: Thu, 25 Jan 2007 17:22:06 +0300 Subject: [erlang-questions] Erlang in Debian on m68k architecture In-Reply-To: <17848.42642.955433.454642@alkaid.it.uu.se> References: <17848.39202.780026.211263@alkaid.it.uu.se> <17848.42642.955433.454642@alkaid.it.uu.se> Message-ID: On 1/25/07, Mikael Pettersson wrote: > The problem is still one of alignment. It seems that your M68K > toolchain doesn't align > > struct { int x; } var; > > to a 32-bit boundary. Whether that is the bug, or whether the > lock checker's alignment-of-static-data assumption is the bug, > I cannot tell until someone sends me a pointer to the M68K Linux > (or SVR4) ABI document. Then I would like to ask another question: Are there other variables in erlang, which must be aligned to a 32-bit boundary? Or fixing erts_bin_alloc_mtx alignment is sufficient? -- Sergei Golovan From sgolovan@REDACTED Thu Jan 25 15:29:48 2007 From: sgolovan@REDACTED (Sergei Golovan) Date: Thu, 25 Jan 2007 17:29:48 +0300 Subject: [erlang-questions] Erlang in Debian on m68k architecture In-Reply-To: References: Message-ID: On 1/25/07, Roman Zippel wrote: > It's aligned, but unfortunately not as much as erlang liked. > Unfortunately that's also a very common error source in quite a few > packages, which then only fail on m68k. We've found GCC option -malign-int for m68k. Citing from the manual: -malign-int -mno-align-int Control whether GCC aligns "int", "long", "long long", "float", "double", and "long double" variables on a 32-bit boundary (-malign-int) or a 16-bit boundary (-mno-align-int). Aligning variables on 32-bit boundaries produces code that runs somewhat faster on processors with 32-bit busses at the expense of more mem- ory. Warning: if you use the -malign-int switch, GCC will align struc- tures containing the above types differently than most published application binary interface specifications for the m68k. Can the issue with alignment of the structure be resolved using this option? Or this option isn't recommended to use? -- Sergei Golovan From ulf.wiger@REDACTED Thu Jan 25 15:41:20 2007 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Thu, 25 Jan 2007 15:41:20 +0100 Subject: [erlang-questions] Inferno - erroneous comments about Erlang? In-Reply-To: <45B8A850.20401@it.uu.se> Message-ID: <6616D98C65DD514BA2E1DDC5F92231558D7BEB@esealmw115.eemea.ericsson.se> For C/C++ Language Support, they could add the same kind of footnote as for Limbo, and for embedded environment, they could add a footnote similar to that of Java (but citing a smaller footprint.) I'm not sure what the most glaring misunderstanding is - whether it is the alledged lack of a royalty-free distribution or the supposed lack of a VM. (: At least, Erlang gets one tick more than XML/SOAP... BR, Ulf W > -----Original Message----- > From: erlang-questions-bounces@REDACTED > [mailto:erlang-questions-bounces@REDACTED] On Behalf Of > Richard Carlsson > Sent: den 25 januari 2007 13:54 > To: Hubert Matthews > Cc: Erlang-Questions (E-mail) > Subject: Re: [erlang-questions] Inferno - erroneous comments > about Erlang? > > Hubert Matthews wrote: > > http://www.vitanuova.com/mkt/press/Inferno_overview.pdf > > > > contains at the end a table comparing Inferno, Erlang and lots of > > other approaches to distributed systems. I think they are > incorrect > > about a lot of stuff in this table, particularly about Erlang. Any > > comments? > > Indeed - they should check every box except "native OS". > > /Richard > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From lenartlad@REDACTED Thu Jan 25 16:05:03 2007 From: lenartlad@REDACTED (Ladislav Lenart) Date: Thu, 25 Jan 2007 16:05:03 +0100 Subject: [erlang-questions] Emacs and Erlang Message-ID: <45B8C71F.1030002@volny.cz> Hello, Based on your replies to my question on "Eclipse/Erlide autoindent problem" I have decided to use Emacs as my Erlang IDE. I have two questions related to this... [1] When Erlang mode is activated, "Erlang" menu appears and one of its submenus is "Man pages" context of which is "Error! Why?". The info text informs me to setup erlang-root-dir which I already did. Any ideas? [2] I have also installed ECB for better code navigation and it works quite good except for one tiny little detail. When a selected source file contains more than a few functions, they are "grouped" in method buffer. Is it possible to disable this grouping of functions so that method buffer always shows a flat list? I was trying to find it in ECB docs but did not succeed. Thank you, Ladislav Lenart From bjorn@REDACTED Thu Jan 25 16:04:09 2007 From: bjorn@REDACTED (Bjorn Gustavsson) Date: 25 Jan 2007 16:04:09 +0100 Subject: [erlang-questions] Erlang in Debian on m68k architecture In-Reply-To: References: Message-ID: "Sergei Golovan" writes: > On 1/25/07, Roman Zippel wrote: > > It's aligned, but unfortunately not as much as erlang liked. > > Unfortunately that's also a very common error source in quite a few > > packages, which then only fail on m68k. > > We've found GCC option -malign-int for m68k. Citing from the manual: > -malign-int > -mno-align-int > Control whether GCC aligns "int", "long", "long long", "float", > "double", and "long double" variables on a 32-bit boundary > (-malign-int) or a 16-bit boundary (-mno-align-int). Aligning > variables on 32-bit boundaries produces code that runs somewhat > faster on processors with 32-bit busses at the expense of more mem- > ory. > > Warning: if you use the -malign-int switch, GCC will align struc- > tures containing the above types differently than most published > application binary interface specifications for the m68k. > > Can the issue with alignment of the structure be resolved using this > option? Or this option isn't recommended to use? Yes, it can. The emulator assumes that ints are 32 bit aligned. Also make sure that malloc() returns 32-bit aligned memory blocks. However, this option could cause structs including from system header files to be aligned differently, which can cause code that call system calls or library function to fail (especially code in the emulator/sys/ and emulator/drivers/ directories). /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From rvg@REDACTED Thu Jan 25 16:28:17 2007 From: rvg@REDACTED (Rudolph van Graan) Date: Thu, 25 Jan 2007 17:28:17 +0200 Subject: [erlang-questions] Eclipse/Erlide autoindent problem In-Reply-To: <8F5ADC16-FA1F-4B18-B7A4-BEEA7FBD444F@zoominternet.net> References: <45B73ED1.2010802@volny.cz> <95be1d3b0701240327g79e9408fkaf118be8d7d7237b@mail.gmail.com> <45B75590.2040408@volny.cz> <8F5ADC16-FA1F-4B18-B7A4-BEEA7FBD444F@zoominternet.net> Message-ID: <50A92368-0FB5-4351-ACA1-AD68775CDE2A@patternmatched.com> >> > > I currently use Emacs -- don't laugh! I use the Mac OSX version of > Emacs, which is Aquamacs Emacs. It seems to make more sense than > plain vanilla Emacs :) I've found that Aquamacs is VERY slow, especially with large, wrapping buffers. Building Emacs in darwinports with Aqua support makes it much better. R From mats.cronqvist@REDACTED Thu Jan 25 17:00:56 2007 From: mats.cronqvist@REDACTED (Mats Cronqvist) Date: Thu, 25 Jan 2007 17:00:56 +0100 Subject: [erlang-questions] setting up emacs for erlang Message-ID: <45B8D438.5070302@ericsson.com> an emacs configured properly(1) is a pretty good IDE for erlang. it has smooth integration with the debugger, the erlang shell, the documentation etc. alas, getting it all to work is not particularly trivial. so please find enclosed a .emacs file that illustrates how it can be done(2). note that it assumes you've installed distel(3) and esense(4) first (which i highly recommend). mats (1) where i define "properly" to mean "the way i like it" (2) not done very well though; i'm a pretty lousy elisper (3) jungerl.sourceforge.net (4) esense.sourceforge.net ;; utility function to (brokenly :< ) handle versioned dirs (defun wild (dir stem) "returns the last (alphabetically) filename that matches dir/stem*." (car (reverse (sort (let (value) (dolist (element (file-name-all-completions stem dir) value) (setq value (cons (concat dir element) value)))) 'string-lessp)))) ;; we need to find the paths to OTP, distel and esense ;; ;; for OTP, we need the dir containing man and lib. ;; on debian, that would be /usr/lib/erlang ;; for esense, we need the dir where esense.el lives ;; e.g. $HOME/code/esense-1.9 ;; for distel, we need distel.el ;; e.g. $HOME/jungerl/lib/distel/elisp ;; you also need to add the corresponding bit to $HOME/.erlang ;; code:add_patha(os:getenv("HOME")++"/jungerl/lib/distel/ebin"). (defvar erlang-erl-path "/usr/lib/erlang") (defvar erlang-esense-path (wild (concat (getenv "HOME") "/code/") "esense-")) (defvar erlang-distel-path (concat (getenv "HOME") "/jungerl/lib/distel/elisp")) ;; hopefully no further configuration is needed ;; find the erlang mode .el file (defvar erlang-erlmode-path (concat (wild (concat erlang-erl-path "/lib/") "tools-") "emacs")) (add-to-list 'load-path erlang-erlmode-path) (add-to-list 'load-path erlang-esense-path) (add-to-list 'load-path erlang-distel-path) (show-paren-mode t) (global-font-lock-mode t) (add-hook 'erlang-load-hook 'my-erlang-load-hook) ;; use to start an erlang shell with boot flags (defun erl-shell (flags) "Start an erlang shell with flags" (interactive (list (read-string "Flags: "))) (set 'inferior-erlang-machine-options (split-string flags)) (erlang-shell)) (defun my-erlang-load-hook () (require 'distel) (distel-setup) ;; when loading a beam file from emacs, add the path to erlang (setq erl-reload-dwim t) (require 'esense) (setq esense-indexer-program (concat erlang-esense-path "esense.sh")) (setq esense-completion-display-method 'frame) ;; find the man pages (setq erlang-root-dir erlang-erl-path)) (add-hook 'erlang-mode-hook 'my-erlang-mode-hook) (defun my-erlang-mode-hook () ;;esense (esense-mode) ;; distel The Right Way(tm) (local-set-key [(meta l)] 'erl-find-mod) (local-set-key [(meta \()] 'erl-openparent) (local-set-key [(meta /)] 'erl-complete) (local-set-key [(control x) (\?)] 'erlang-man-function) ;; make hack for compile command ;; uses Makefile if it exists, else looks for ../inc & ../ebin (unless (null buffer-file-name) (make-local-variable 'compile-command) (setq compile-command (if (file-exists-p "Makefile") "make -k" (concat (concat "erlc " (concat (if (file-exists-p "../ebin") "-o ../ebin " "") (if (file-exists-p "../inc") "-I ../inc " "")) "+debug_info -W " buffer-file-name)))))) (add-hook 'comint-mode-hook 'my-comint) (defun my-comint () ;; try to make the shell more like the real shell (local-set-key [tab] 'comint-dynamic-complete) (local-set-key [(control up)] 'previous-line) (local-set-key [(control down)] 'next-line) (local-set-key [up] 'comint-previous-input) (local-set-key [down] 'comint-next-input)) (add-hook 'erlang-shell-mode-hook 'my-erlang-shell) (defun my-erlang-shell () (setq comint-dynamic-complete-functions '(my-erl-complete comint-replace-by-expanded-history))) (defun my-erl-complete () "Call erl-complete if we have an Erlang node name" (if erl-nodename-cache (erl-complete erl-nodename-cache) nil)) (require 'erlang-start) From mikpe@REDACTED Thu Jan 25 17:21:40 2007 From: mikpe@REDACTED (Mikael Pettersson) Date: Thu, 25 Jan 2007 17:21:40 +0100 Subject: [erlang-questions] Erlang in Debian on m68k architecture In-Reply-To: References: <17848.39202.780026.211263@alkaid.it.uu.se> <17848.42642.955433.454642@alkaid.it.uu.se> Message-ID: <17848.55572.297293.948535@alkaid.it.uu.se> Sergei Golovan writes: > On 1/25/07, Mikael Pettersson wrote: > > The problem is still one of alignment. It seems that your M68K > > toolchain doesn't align > > > > struct { int x; } var; > > > > to a 32-bit boundary. Whether that is the bug, or whether the > > lock checker's alignment-of-static-data assumption is the bug, > > I cannot tell until someone sends me a pointer to the M68K Linux > > (or SVR4) ABI document. > > Then I would like to ask another question: Are there other variables > in erlang, which must be aligned to a 32-bit boundary? Or fixing > erts_bin_alloc_mtx alignment is sufficient? There are many many many places where alignment is required, and where incorrect alignment could cause almost random and impossible to debug problems. It is possible to enforce alignment with directives, the problem is locating all the relevant places, and to ensure that alignment directives don't cause unexpected internal padding. (Yes there are assumptions about that as well.) Unless you're dying to use Erlang on M68K, don't bother. /Mikael From sean.hinde@REDACTED Thu Jan 25 17:33:21 2007 From: sean.hinde@REDACTED (Sean Hinde) Date: Thu, 25 Jan 2007 16:33:21 +0000 Subject: [erlang-questions] Programming question In-Reply-To: <45B8A3FF.1080401@it.uu.se> References: <3D85890B-9358-4163-9A65-CCC5760AD8FC@gmail.com> <45B772F8.5000804@it.uu.se> <1F0B4B81-7018-48F4-A76A-5A97701B5DB5@gmail.com> <45B86905.5000100@ericsson.com> <45B8A3FF.1080401@it.uu.se> Message-ID: <888DDAC9-EB22-4B9B-B9C5-76B770330069@gmail.com> On 25 Jan 2007, at 12:35, Richard Carlsson wrote: > Sean Hinde wrote: >> >> The problem as I see it is that the calling process only >> sometimes get its 'EXIT' message - it depends on context. > > If you have a library that uses the RPC model, as in the case of > 'gen_server:call(...)', it is probably a bad idea to try to solve the > problems with RPC that have been known for ages, such as "what do I do > if the server goes down", by adding some ad-hoc handling code to every > remote call. (It can and will be screwed up anyway.) I think that the > interface should be used as it was intended (treating exceptions > due to > server-down as any other exception out from the call), and that > additional supervision should be placed somewhere else, outside the > main program logic. > > Sean is basically right here: he _ought_ to be able to use normal > links for this purpose (after all, links are the central built-in > "additional supervision" method in Erlang), regardless of whether > the implementation of gen_server:call() does things with links and > trapping of signals: that stuff should have been made transparent to > the user, but is obviously not. (One problem is that there can only > be a single link between two processes, so gen_server can't know > whether or not it should re-issue the caught signal to the caller.) Actually it can, because gen_server can rely solely on monitor for its own purposes. If it gets an 'EXIT' message then it can be certain that it is because the two processes have been explicitly linked. I would be happy to have a compatibility mode for dealing with old nodes, but I think the default behaviour should for gen_server to selectively receive its own 'DOWN' message, and leave the EXIT message on the queue. > > If this aspect of gen_server (and similar library functions) cannot > be fixed, e.g. by using monitors instead of links, then at a > minimum it > should be documented that the functions will steal exit signals if you > try to link directly to the server. I agree with the documentation comment. It was extremely surprising the first time I saw this behaviour. It resulted in several outages of live systems where processes were not restarted simply because of when they died (not code written by me, so at least two folks have had this problem). There must be many other systems out there that are just waiting to suffer the same fate. > > Meanwhile, the fix I suggested previously should work fine: use an > intermediate process, whose signals the gen_server library does not > interfere with. To require a 3rd process between the two linked process just to propogate the EXIT seems like extreme overkill. In my current application the two process are dynamically created per call - this would add a 50% overhead to every request. I don't buy the backwards compatibility argument for this unintuitive and IMO buggy behaviour. If we look at the cases: 1. Two processes are not linked. Today - if the other process dies during the call then gen:call() just throws an exception. With my change - exactly the same 2. Two processes are linked, with the gen:call not wrapped in a catch Today - if the other process dies during the call it throws an exception and the local process dies With my change - same result, the 'EXIT' message arrives later after the caller died 3. Two processes are linked, gen:call wrapped in a catch, trapexit = true Today - if the other process dies during the call then an exception is caught. There is no 'EXIT' message, even though this has to be handled if the linked process dies at any other time. With my change - The same exception is raised from the call, but the existing 'EXIT' message handling will also be invoked. - To me this is a pure bug fix 4. Two processes are linked, gen:call wrapped in a catch, trapexit = false Today - Exception is raised as normal, and the calling process lives on. With proposed change: Exception is raised as normal but the calling process is killed later by the 'EXIT' signal. This last case could be seen as a backwards compatibility problem, but given that the called process can potentially die at any time outside the call, I would say that the gen_server behaviour is just hiding a latent bug in the original code, which is likely to happen at some point anyway. Worst case we could have a separate call defined with the new behaviour Sean From sgolovan@REDACTED Thu Jan 25 17:58:09 2007 From: sgolovan@REDACTED (Sergei Golovan) Date: Thu, 25 Jan 2007 19:58:09 +0300 Subject: [erlang-questions] Erlang in Debian on m68k architecture In-Reply-To: <17848.55572.297293.948535@alkaid.it.uu.se> References: <17848.39202.780026.211263@alkaid.it.uu.se> <17848.42642.955433.454642@alkaid.it.uu.se> <17848.55572.297293.948535@alkaid.it.uu.se> Message-ID: On 1/25/07, Mikael Pettersson wrote: > There are many many many places where alignment is required, > and where incorrect alignment could cause almost random and > impossible to debug problems. > > It is possible to enforce alignment with directives, the problem > is locating all the relevant places, and to ensure that alignment > directives don't cause unexpected internal padding. (Yes there are > assumptions about that as well.) > > Unless you're dying to use Erlang on M68K, don't bother. Thaks for the info! I would just like erlang to run on all Debian GNU/Linux supported architectures. I'm not using erlang on m68k architecture myself. -- Sergei Golovan From ulf.wiger@REDACTED Thu Jan 25 18:23:32 2007 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Thu, 25 Jan 2007 18:23:32 +0100 Subject: [erlang-questions] Programming question In-Reply-To: <888DDAC9-EB22-4B9B-B9C5-76B770330069@gmail.com> Message-ID: <6616D98C65DD514BA2E1DDC5F92231558D7EAB@esealmw115.eemea.ericsson.se> > To require a 3rd process between the two linked process just > to propogate the EXIT seems like extreme overkill. In my > current application the two process are dynamically created > per call - this would add a 50% overhead to every request. To be fair, this would be 50% overhead on the cost of spawning processes, which is about 5-10 us/spawn. It is hardly noticeable in most cases. I agree that gen_server shouldn't touch the EXIT messages. While changing this might cause some consternation among a few users with legacy code, I believe the current behaviour violates the principle of least astonishment and, as you've described, can lead to highly unexpected timing bugs. gen:call() doesn't enable exit trapping under any circumstances (nor does it link to the server), so if the process is trapping exits, and is linked to the server, it is certainly because someone else made it so. It is then reasonable to expect that some other code expects an EXIT message to arrive. One of the main reasons why monitors were added in the first place was the problem that link/unlink and EXIT message handling can't be handled locally, since no matter how many times you call link(), there will only be one link, and the first call to unlink removes that link. Furthermore, there is only one EXIT message (except if link(DeadPid) has been called one or more times), and the handling of that message must be a process-global matter. BR, Ulf W > -----Original Message----- > From: erlang-questions-bounces@REDACTED > [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Sean Hinde > Sent: den 25 januari 2007 17:33 > To: Erlang Questions > Subject: Re: [erlang-questions] Programming question > > > On 25 Jan 2007, at 12:35, Richard Carlsson wrote: > > > Sean Hinde wrote: > >> > >> The problem as I see it is that the calling process only > sometimes > >> get its 'EXIT' message - it depends on context. > > > > If you have a library that uses the RPC model, as in the case of > > 'gen_server:call(...)', it is probably a bad idea to try to > solve the > > problems with RPC that have been known for ages, such as > "what do I do > > if the server goes down", by adding some ad-hoc handling > code to every > > remote call. (It can and will be screwed up anyway.) I > think that the > > interface should be used as it was intended (treating > exceptions due > > to server-down as any other exception out from the call), and that > > additional supervision should be placed somewhere else, outside the > > main program logic. > > > > Sean is basically right here: he _ought_ to be able to use normal > > links for this purpose (after all, links are the central built-in > > "additional supervision" method in Erlang), regardless of > whether the > > implementation of gen_server:call() does things with links and > > trapping of signals: that stuff should have been made > transparent to > > the user, but is obviously not. (One problem is that there > can only be > > a single link between two processes, so gen_server can't > know whether > > or not it should re-issue the caught signal to the caller.) > > Actually it can, because gen_server can rely solely on > monitor for its own purposes. If it gets an 'EXIT' message > then it can be certain that it is because the two processes > have been explicitly linked. > > I would be happy to have a compatibility mode for dealing > with old nodes, but I think the default behaviour should for > gen_server to selectively receive its own 'DOWN' message, and > leave the EXIT message on the queue. > > > > > > If this aspect of gen_server (and similar library > functions) cannot be > > fixed, e.g. by using monitors instead of links, then at a > minimum it > > should be documented that the functions will steal exit > signals if you > > try to link directly to the server. > > I agree with the documentation comment. It was extremely > surprising the first time I saw this behaviour. It resulted > in several outages of live systems where processes were not > restarted simply because of when they died (not code written > by me, so at least two folks have had this problem). There > must be many other systems out there that are just waiting to > suffer the same fate. > > > > > Meanwhile, the fix I suggested previously should work fine: use an > > intermediate process, whose signals the gen_server library does not > > interfere with. > > To require a 3rd process between the two linked process just > to propogate the EXIT seems like extreme overkill. In my > current application the two process are dynamically created > per call - this would add a 50% overhead to every request. > > I don't buy the backwards compatibility argument for this > unintuitive and IMO buggy behaviour. If we look at the cases: > > 1. Two processes are not linked. > > Today - if the other process dies during the call then > gen:call() just throws an exception. > With my change - exactly the same > > 2. Two processes are linked, with the gen:call not wrapped in a catch > > Today - if the other process dies during the call it throws > an exception and the local process dies With my change - same > result, the 'EXIT' message arrives later after the caller died > > 3. Two processes are linked, gen:call wrapped in a catch, > trapexit = true > > Today - if the other process dies during the call then an > exception is caught. There is no 'EXIT' message, even though > this has to be handled if the linked process dies at any other time. > With my change - The same exception is raised from the call, > but the existing 'EXIT' message handling will also be > invoked. - To me this is a pure bug fix > > 4. Two processes are linked, gen:call wrapped in a catch, > trapexit = false > > Today - Exception is raised as normal, and the calling > process lives on. > With proposed change: Exception is raised as normal but the > calling process is killed later by the 'EXIT' signal. > > This last case could be seen as a backwards compatibility > problem, but given that the called process can potentially > die at any time outside the call, I would say that the > gen_server behaviour is just hiding a latent bug in the > original code, which is likely to happen at some point anyway. > > Worst case we could have a separate call defined with the new > behaviour > > Sean > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From H.Li@REDACTED Thu Jan 25 18:32:03 2007 From: H.Li@REDACTED (H.Li@REDACTED) Date: Thu, 25 Jan 2007 17:32:03 -0000 (GMT) Subject: [erlang-questions] ANNOUNCE: Wrangler, an Erlang Refactorer Message-ID: <1330.212.139.234.108.1169746323.squirrel@webmail.cs.kent.ac.uk> Dear Erlangers, As part of our project on Formally-Based Tool Support for Erlang Development, http://www.cs.kent.ac.uk/projects/forse/ We are pleased to announce the availability of Wrangler-0.1, a snapshot of our Erlang Refactorer prototype, which support a small number of basic Erlang refactorings including renaming of vairable/function/module names and generalisation of a function definition. You can get Wrangler-0.1 (bundled with Distel) via http://www.cs.kent.ac.uk/projects/forse/ Please see the README and Documentation for build/use instructions, and let us know about any problems, bugs, suggestions. Our project Email address is: erlang-refactor@REDACTED We have been working with the Erlang researchers at the E?tv?s Lor?nd Unversity in Hungary, who are also looking into refactorings, and we hope in due course to make a joint release of our work. Happy Refactoring! Simon Thompson, Huiqing Li From sean.hinde@REDACTED Thu Jan 25 19:31:36 2007 From: sean.hinde@REDACTED (Sean Hinde) Date: Thu, 25 Jan 2007 18:31:36 +0000 Subject: [erlang-questions] Programming question In-Reply-To: <6616D98C65DD514BA2E1DDC5F92231558D7EAB@esealmw115.eemea.ericsson.se> References: <6616D98C65DD514BA2E1DDC5F92231558D7EAB@esealmw115.eemea.ericsson.se> Message-ID: <1EDAA422-49BA-4969-9E4F-D335BC69BB91@gmail.com> On 25 Jan 2007, at 17:23, Ulf Wiger ((TN/EAB)) wrote: > >> To require a 3rd process between the two linked process just >> to propogate the EXIT seems like extreme overkill. In my >> current application the two process are dynamically created >> per call - this would add a 50% overhead to every request. > > To be fair, this would be 50% overhead on the cost of > spawning processes, which is about 5-10 us/spawn. > It is hardly noticeable in most cases. OK, perhaps this was the worst reason I could choose to explain why requiring an extra process is a bad idea. Others are obvious - added complexity, more code that has nothing to do with the end user requirements, potential for additional bugs, harder to understand etc etc etc. > I agree that gen_server shouldn't touch the EXIT > messages. While changing this might cause some > consternation among a few users with legacy code, > I believe the current behaviour violates the > principle of least astonishment and, as you've > described, can lead to highly unexpected timing bugs. Great! Now we must convince the OTP team.. Sean > > gen:call() doesn't enable exit trapping under any > circumstances (nor does it link to the server), > so if the process is trapping exits, and is linked > to the server, it is certainly because someone else > made it so. It is then reasonable to expect that > some other code expects an EXIT message to arrive. > > One of the main reasons why monitors were added in > the first place was the problem that link/unlink > and EXIT message handling can't be handled locally, > since no matter how many times you call link(), > there will only be one link, and the first call > to unlink removes that link. Furthermore, there > is only one EXIT message (except if link(DeadPid) > has been called one or more times), and the > handling of that message must be a process-global > matter. > > > BR, > Ulf W > >> -----Original Message----- >> From: erlang-questions-bounces@REDACTED >> [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Sean Hinde >> Sent: den 25 januari 2007 17:33 >> To: Erlang Questions >> Subject: Re: [erlang-questions] Programming question >> >> >> On 25 Jan 2007, at 12:35, Richard Carlsson wrote: >> >>> Sean Hinde wrote: >>>> >>>> The problem as I see it is that the calling process only >> sometimes >>>> get its 'EXIT' message - it depends on context. >>> >>> If you have a library that uses the RPC model, as in the case of >>> 'gen_server:call(...)', it is probably a bad idea to try to >> solve the >>> problems with RPC that have been known for ages, such as >> "what do I do >>> if the server goes down", by adding some ad-hoc handling >> code to every >>> remote call. (It can and will be screwed up anyway.) I >> think that the >>> interface should be used as it was intended (treating >> exceptions due >>> to server-down as any other exception out from the call), and that >>> additional supervision should be placed somewhere else, outside the >>> main program logic. >>> >>> Sean is basically right here: he _ought_ to be able to use normal >>> links for this purpose (after all, links are the central built-in >>> "additional supervision" method in Erlang), regardless of >> whether the >>> implementation of gen_server:call() does things with links and >>> trapping of signals: that stuff should have been made >> transparent to >>> the user, but is obviously not. (One problem is that there >> can only be >>> a single link between two processes, so gen_server can't >> know whether >>> or not it should re-issue the caught signal to the caller.) >> >> Actually it can, because gen_server can rely solely on >> monitor for its own purposes. If it gets an 'EXIT' message >> then it can be certain that it is because the two processes >> have been explicitly linked. >> >> I would be happy to have a compatibility mode for dealing >> with old nodes, but I think the default behaviour should for >> gen_server to selectively receive its own 'DOWN' message, and >> leave the EXIT message on the queue. >> >> >>> >>> If this aspect of gen_server (and similar library >> functions) cannot be >>> fixed, e.g. by using monitors instead of links, then at a >> minimum it >>> should be documented that the functions will steal exit >> signals if you >>> try to link directly to the server. >> >> I agree with the documentation comment. It was extremely >> surprising the first time I saw this behaviour. It resulted >> in several outages of live systems where processes were not >> restarted simply because of when they died (not code written >> by me, so at least two folks have had this problem). There >> must be many other systems out there that are just waiting to >> suffer the same fate. >> >>> >>> Meanwhile, the fix I suggested previously should work fine: use an >>> intermediate process, whose signals the gen_server library does not >>> interfere with. >> >> To require a 3rd process between the two linked process just >> to propogate the EXIT seems like extreme overkill. In my >> current application the two process are dynamically created >> per call - this would add a 50% overhead to every request. >> >> I don't buy the backwards compatibility argument for this >> unintuitive and IMO buggy behaviour. If we look at the cases: >> >> 1. Two processes are not linked. >> >> Today - if the other process dies during the call then >> gen:call() just throws an exception. >> With my change - exactly the same >> >> 2. Two processes are linked, with the gen:call not wrapped in a catch >> >> Today - if the other process dies during the call it throws >> an exception and the local process dies With my change - same >> result, the 'EXIT' message arrives later after the caller died >> >> 3. Two processes are linked, gen:call wrapped in a catch, >> trapexit = true >> >> Today - if the other process dies during the call then an >> exception is caught. There is no 'EXIT' message, even though >> this has to be handled if the linked process dies at any other time. >> With my change - The same exception is raised from the call, >> but the existing 'EXIT' message handling will also be >> invoked. - To me this is a pure bug fix >> >> 4. Two processes are linked, gen:call wrapped in a catch, >> trapexit = false >> >> Today - Exception is raised as normal, and the calling >> process lives on. >> With proposed change: Exception is raised as normal but the >> calling process is killed later by the 'EXIT' signal. >> >> This last case could be seen as a backwards compatibility >> problem, but given that the called process can potentially >> die at any time outside the call, I would say that the >> gen_server behaviour is just hiding a latent bug in the >> original code, which is likely to happen at some point anyway. >> >> Worst case we could have a separate call defined with the new >> behaviour >> >> Sean >> >> >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> From ulf@REDACTED Thu Jan 25 19:53:02 2007 From: ulf@REDACTED (Ulf Wiger) Date: Thu, 25 Jan 2007 19:53:02 +0100 Subject: [erlang-questions] orddict (was Re: OO programming style in Erlang?) In-Reply-To: <200701250226.l0P2QGVK193451@atlas.otago.ac.nz> References: <200701250226.l0P2QGVK193451@atlas.otago.ac.nz> Message-ID: Den 2007-01-25 03:26:16 skrev Richard A. O'Keefe : > The orddict module is extremely unusual in having the same interface > as the dict module. So does the ordsets module have the same interface as the sets module. > However, it does NOT have the same PERFORMANCE > characteristics. So once again, if you want to have any idea how well > your code is likely to work, you had BETTER know which version you are > using. (And wouldn't it be nice if the documentation said something > about performance?) In fact, there really aren't that many places that > you would want to use orddict at all. I can think of one good reason to use ordsets/orddict: debugging. It is decidedly more enjoyable to watch (trace/debugging) printouts of ordsets and orddicts compared to sets/dicts. Pretty-printing of large dicts in the shell is in fact everything but pretty. Personally, I use ordsets quite often. I seldomly use orddict, however, but if I do it is exactly for the reason above, and in cases where performance is not critical. BR, Ulf W -- Ulf Wiger From erlang@REDACTED Thu Jan 25 21:11:38 2007 From: erlang@REDACTED (Erlang (INS)) Date: Thu, 25 Jan 2007 18:11:38 -0200 Subject: [erlang-questions] Node crash without crashdump - only using yaws + mnesia Message-ID: <200701252011.l0PKBgFm018636@morgoth.cslab.ericsson.net> Hi, I have a node which only runs yaws and mnesia (using extra_db_node) and it crashes without generating the crash dump file. OS: Windows 2000 ERTS version: Erlang (BEAM) emulator version 5.4 [source] [threads:10] Erlang applications: {yaws,"yaws WWW server","1.56"}, {crypto,"CRYPTO version 1","1.2.1"}, {mnesia,"MNESIA CXC 138 12","4.2"}, {sasl,"SASL CXC 138 11","2.0"}, {stdlib,"ERTS CXC 138 10","1.13"}, {kernel,"ERTS CXC 138 10","2.10"} Kernel log with several yaws errors like: =ERROR REPORT==== 25-Jan-2007::09:47:14 === Yaws process died: {{error,einval}, [{yaws,gen_tcp_send,2}, {yaws_server,deliver_accumulated,5}, {yaws_server,handle_ut,4}, {yaws_server,aloop,3}, {yaws_server,acceptor0,2}, {proc_lib,init_p,5}]} =ERROR REPORT==== 25-Jan-2007::10:18:22 === ERROR: Can't parse post body for 'GET' requests =ERROR REPORT==== 25-Jan-2007::10:20:04 === ERROR: Can't parse post body for 'GET' requests Before the crash the console outputs: TYPE ASSERTION FAILED, file beam/erl_term.c, line 92: tag_val_def: 0x18 abnormal program termination Please any help appreciated. Thanks, Eduardo -------------- next part -------------- An HTML attachment was scrubbed... URL: From robert.virding@REDACTED Fri Jan 26 02:54:06 2007 From: robert.virding@REDACTED (Robert Virding) Date: Fri, 26 Jan 2007 02:54:06 +0100 Subject: [erlang-questions] orddict (was Re: OO programming style in Erlang?) In-Reply-To: References: <200701250226.l0P2QGVK193451@atlas.otago.ac.nz> Message-ID: <45B95F3E.6090303@telia.com> Ulf Wiger wrote: > Den 2007-01-25 03:26:16 skrev Richard A. O'Keefe : > >>The orddict module is extremely unusual in having the same interface >>as the dict module. > > So does the ordsets module have the same interface as the sets module. Yup, it sure does. Both pairs were designed to have the smae interfaces, dict and orddict, sets and ordsets. >> However, it does NOT have the same PERFORMANCE >>characteristics. So once again, if you want to have any idea how well >>your code is likely to work, you had BETTER know which version you are >>using. (And wouldn't it be nice if the documentation said something >>about performance?) In fact, there really aren't that many places that >>you would want to use orddict at all. > > > I can think of one good reason to use ordsets/orddict: debugging. > > It is decidedly more enjoyable to watch (trace/debugging) > printouts of ordsets and orddicts compared to sets/dicts. > Pretty-printing of large dicts in the shell is in fact > everything but pretty. > > Personally, I use ordsets quite often. I seldomly use orddict, > however, but if I do it is exactly for the reason above, and > in cases where performance is not critical. Orddict and ordsets are better when the number of elements is small. They are much lighter structures and faster to set up. Dict and sets are much heavier objects more tuned to a large number of elements. I once managed to get over 800000 elements into a dict, but it wasn't fast. And sometimes it is practical to have a simple well designed data structure. Apart from being easier to read when printed. :-) I have a dream! What I would really like is a dict with the access functions written in C. That would rock! If the internal structures were normal erlang tuples and lists like today then it would be easy to implement some functions in erlang, like fold and map, and some in C, like fetch and store. The best of both worlds. It would be good base to implement Ets in erlang using processes and eliminating all synch problem in SMP. Robert From ok@REDACTED Fri Jan 26 03:15:15 2007 From: ok@REDACTED (Richard A. O'Keefe) Date: Fri, 26 Jan 2007 15:15:15 +1300 (NZDT) Subject: [erlang-questions] orddict (was Re: OO programming style in Erlang?) Message-ID: <200701260215.l0Q2FFd0205763@atlas.otago.ac.nz> "Ulf Wiger" wrote: I can think of one good reason to use ordsets/orddict: debugging. It is decidedly more enjoyable to watch (trace/debugging) printouts of ordsets and orddicts compared to sets/dicts. Pretty-printing of large dicts in the shell is in fact everything but pretty. Way back in the very early 1980s, Chris Mellish was working on interpreting English sentences (about elementary physics problems). He quickly ran into a debugging problem: the semantic structures he was building were very large, so the average procedure call as displayed by the debugger took rather more than one screen-full. So DEC-10 Prolog acquired the command print(Term) which was exactly like write(Term) but first checked for a user-defined portray(Term), and called that instead if it was defined. As I added data structures to the DEC-10 Prolog library, it became clear that this needed to be done recursively, so we arrived at the current definition. print(Term) :- ( var(Term) -> write(Term) ; number(Term) -> write(Term) ; current_predicate(portray, portray(_)), portray(Term) -> true ; like write/1 but recursive calls call print/1 instead of write/1 ). This meant that when testing a tree-like dictionary data structure, it could be made to print as Dict{k1->v1, ..., kn->vn}, _whatever_ the internal representation, as long as the principal functors (name/arity) used were distinct from others. It's a pity that Erlang's data representation has no way of labelling terms like this. If only records were a real data type, it _could_. From dcaoyuan@REDACTED Fri Jan 26 07:07:23 2007 From: dcaoyuan@REDACTED (Caoyuan Deng) Date: Fri, 26 Jan 2007 14:07:23 +0800 Subject: [erlang-questions] Is it possible to define group in erlhive? Message-ID: I took a look at the USER_GUIDE of erlhive, and is wondering if it's possible to define group level access control for a group of users. Thanks. From ulf@REDACTED Fri Jan 26 08:21:23 2007 From: ulf@REDACTED (Ulf Wiger) Date: Fri, 26 Jan 2007 08:21:23 +0100 Subject: [erlang-questions] Is it possible to define group in erlhive? In-Reply-To: References: Message-ID: Den 2007-01-26 07:07:23 skrev Caoyuan Deng : > I took a look at the USER_GUIDE of erlhive, and is wondering if it's > possible to define group level access control for a group of users. > > Thanks. (This question is better posted on the erlhive-devel mailing list. You can find it via http://erlhive.sourceforge.net) Currently, there is no such thing as general group-level access control. The basic access control mechanisms are public and private data and public and private modules. I would like to keep it that way. However, in the blog example, properties are used to implement custom access control. In: http://erlhive.svn.sourceforge.net/viewvc/erlhive/lib/erlhive/examples/blog/src/flexiblog.erl?revision=54&view=markup you can see how it's done. The flexiblog module recognizes the roles 'admin', 'author', 'reviewer', and 'reader', and uses the authenticated user name to screen commands. As all the blog data is stored in the private area of the application owner, the only way to get to the data is through the public API. I did advertise a role-based access control module, and it is still in the pipe, somewhere. My current priority is to try to get ErlyWeb to work in erlhive. The main challenge the access control module (which is a user-level module) is not so much the logic, but figuring out how to make it as transparent and "pluggable" as possible. BR, Ulf W -- Ulf Wiger From samuelrivas@REDACTED Fri Jan 26 09:01:22 2007 From: samuelrivas@REDACTED (Samuel Rivas) Date: Fri, 26 Jan 2007 09:01:22 +0100 Subject: [erlang-questions] Programming question In-Reply-To: <6616D98C65DD514BA2E1DDC5F92231558D7EAB@esealmw115.eemea.ericsson.se> References: <888DDAC9-EB22-4B9B-B9C5-76B770330069@gmail.com> <6616D98C65DD514BA2E1DDC5F92231558D7EAB@esealmw115.eemea.ericsson.se> Message-ID: <20070126080122.GA25633@lambdastream.com> Ulf Wiger (TN/EAB) wrote: > I agree that gen_server shouldn't touch the EXIT > messages. While changing this might cause some > consternation among a few users with legacy code, > I believe the current behaviour violates the > principle of least astonishment and, as you've > described, can lead to highly unexpected timing bugs. > > gen:call() doesn't enable exit trapping under any > circumstances (nor does it link to the server), > so if the process is trapping exits, and is linked > to the server, it is certainly because someone else > made it so. It is then reasonable to expect that > some other code expects an EXIT message to arrive. There is another issue with the catch sentence in the block that handles call requests in gen_server.erl: call(Name, Request) -> case catch gen:call(Name, '$gen_call', Request) of {ok,Res} -> Res; {'EXIT',Reason} -> exit({Reason, {?MODULE, call, [Name, Request]}}) end. call(Name, Request, Timeout) -> case catch gen:call(Name, '$gen_call', Request, Timeout) of {ok,Res} -> Res; {'EXIT',Reason} -> exit({Reason, {?MODULE, call, [Name, Request, Timeout]}}) end. That does not do well with the behaviour that a try-catch user expects. An uncatched signal becomes a return term. So a gen_server with the next code: handle_call(trhow_it, _From, State) -> throw(ouch), {reply, ok, State}; handle_call(weird, _From, State) -> throw({reply, ok, State}), {stop, ok, State}; handle_call(expected, _From, State) -> erlang:error({nocatch, ouch}), {reply, ok, State}. Behaves as funny as: 16> gen_server_throw:start_link(). {ok,<0.78.0>} 17> gen_server:call(test, weird). ok 18> gen_server:call(test, trhow_it). =ERROR REPORT==== 26-Jan-2007::08:47:46 === ** Generic server test terminating ** Last message in was trhow_it ** When Server state == {} ** Reason for termination == ** {bad_return_value,ouch} ** exited: {bad_return_value,ouch} ** 19> gen_server_throw:start_link(). ok,<0.83.0>} 20> gen_server:call(test, expected). =ERROR REPORT==== 26-Jan-2007::08:48:07 === ** Generic server test terminating ** Last message in was expected ** When Server state == {} ** Reason for termination == ** {{nocatch,ouch}, [{gen_server_throw,handle_call,3}, {gen_server,handle_msg,6}, {proc_lib,init_p,5}]} ** exited: {{nocatch,ouch}, [{gen_server_throw,handle_call,3}, {gen_server,handle_msg,6}, {proc_lib,init_p,5}]} ** - I would expect that 'throw_it' caused an exception similar to 'expected' (with the right stack trace) - I would expect that 'weird' caused a similar exception too, but it does not even crash the server. I did not find any mention about throw issues in the manual either. Regards -- Samuel From ulf@REDACTED Fri Jan 26 09:27:33 2007 From: ulf@REDACTED (Ulf Wiger) Date: Fri, 26 Jan 2007 09:27:33 +0100 Subject: [erlang-questions] Programming question In-Reply-To: <20070126080122.GA25633@lambdastream.com> References: <888DDAC9-EB22-4B9B-B9C5-76B770330069@gmail.com> <6616D98C65DD514BA2E1DDC5F92231558D7EAB@esealmw115.eemea.ericsson.se> <20070126080122.GA25633@lambdastream.com> Message-ID: Den 2007-01-26 09:01:22 skrev Samuel Rivas : > handle_call(trhow_it, _From, State) -> > throw(ouch), > {reply, ok, State}; > handle_call(weird, _From, State) -> > throw({reply, ok, State}), > {stop, ok, State}; > handle_call(expected, _From, State) -> > erlang:error({nocatch, ouch}), > {reply, ok, State}. [...] > - I would expect that 'throw_it' caused an exception similar > to 'expected' (with the right stack trace) The exception in this case is raised by the gen_server module, which expects a return value from Mod:handle_call/3 to be {reply,Rep,S1} | {noreply,S1} | {stop,Reason,S1} | {stop,Rep,Reason,S1} 'ouch' doesn't qualify as a valid return value. In the case of 'expected', your code raises an exception, which is caught by the gen_server module, which adds some info (e.g. last message) and then exits (I'm not looking at the code - can't remember if it calls exit/1 or error/1.) > - I would expect that 'weird' caused a similar exception too, > but it does not even crash the server. ...because gen_server uses an old-style catch, and therefore cannot tell the difference between your thrown value and a normal (and legal) return value. -- Ulf Wiger From samuelrivas@REDACTED Fri Jan 26 09:39:06 2007 From: samuelrivas@REDACTED (Samuel Rivas) Date: Fri, 26 Jan 2007 09:39:06 +0100 Subject: [erlang-questions] Programming question In-Reply-To: References: <888DDAC9-EB22-4B9B-B9C5-76B770330069@gmail.com> <6616D98C65DD514BA2E1DDC5F92231558D7EAB@esealmw115.eemea.ericsson.se> <20070126080122.GA25633@lambdastream.com> Message-ID: <20070126083906.GA26600@lambdastream.com> Ulf Wiger wrote: > > - I would expect that 'throw_it' caused an exception similar > > to 'expected' (with the right stack trace) > > The exception in this case is raised by the gen_server module, > which expects a return value from Mod:handle_call/3 to be > {reply,Rep,S1} | {noreply,S1} | {stop,Reason,S1} > | {stop,Rep,Reason,S1} > > 'ouch' doesn't qualify as a valid return value. > > In the case of 'expected', your code raises an exception, > which is caught by the gen_server module, which adds some > info (e.g. last message) and then exits (I'm not looking > at the code - can't remember if it calls exit/1 or error/1.) > > > > - I would expect that 'weird' caused a similar exception too, > > but it does not even crash the server. > > ...because gen_server uses an old-style catch, and therefore > cannot tell the difference between your thrown value and a > normal (and legal) return value. I knew it, my point is that you have to read the source. Otherwise the results are astonishing. Regards -- Samuel From ulf.wiger@REDACTED Fri Jan 26 10:01:58 2007 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Fri, 26 Jan 2007 10:01:58 +0100 Subject: [erlang-questions] Programming question In-Reply-To: <20070126083906.GA26600@lambdastream.com> Message-ID: <6616D98C65DD514BA2E1DDC5F92231558D826E@esealmw115.eemea.ericsson.se> Yes, this is one of the problems with the old catch/throw, which were eminently documented in Richard Carlsson's et al paper on Erlang's Exception Handling Revisited http://www.erlang.se/workshop/2004/exception.pdf BR, Ulf W > -----Original Message----- > From: erlang-questions-bounces@REDACTED > [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Samuel Rivas > Sent: den 26 januari 2007 09:39 > To: erlang-questions@REDACTED > Subject: Re: [erlang-questions] Programming question > > Ulf Wiger wrote: > > > - I would expect that 'throw_it' caused an exception similar > > > to 'expected' (with the right stack trace) > > > > The exception in this case is raised by the gen_server > module, which > > expects a return value from Mod:handle_call/3 to be > {reply,Rep,S1} | > > {noreply,S1} | {stop,Reason,S1} > > | {stop,Rep,Reason,S1} > > > > 'ouch' doesn't qualify as a valid return value. > > > > In the case of 'expected', your code raises an exception, which is > > caught by the gen_server module, which adds some info (e.g. last > > message) and then exits (I'm not looking at the code - > can't remember > > if it calls exit/1 or error/1.) > > > > > > > - I would expect that 'weird' caused a similar exception too, > > > but it does not even crash the server. > > > > ...because gen_server uses an old-style catch, and therefore cannot > > tell the difference between your thrown value and a normal > (and legal) > > return value. > > I knew it, my point is that you have to read the source. > Otherwise the results are astonishing. > > Regards > -- > Samuel > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From samuelrivas@REDACTED Fri Jan 26 11:50:10 2007 From: samuelrivas@REDACTED (Samuel Rivas) Date: Fri, 26 Jan 2007 11:50:10 +0100 Subject: [erlang-questions] Programming question In-Reply-To: <6616D98C65DD514BA2E1DDC5F92231558D826E@esealmw115.eemea.ericsson.se> References: <20070126083906.GA26600@lambdastream.com> <6616D98C65DD514BA2E1DDC5F92231558D826E@esealmw115.eemea.ericsson.se> Message-ID: <20070126105010.GA27366@lambdastream.com> Ulf Wiger (TN/EAB) wrote: > Yes, this is one of the problems with the old > catch/throw, which were eminently documented in > Richard Carlsson's et al paper on Erlang's Exception Handling Revisited Ya. I started using try/catch some time ago, but I usually stumble upon OTP, Either because of the famous "tagged returns VS exceptions" or because of gotchas with the standard behaviours. We have developed a custom supervisor and a library wrapping gen_server usage to avoid some issues. I guess it is difficult to fix preserving backwards compatibility, maybe it is worth developing a second generation of behaviours ... Regards -- Samuel From thomasl_erlang@REDACTED Fri Jan 26 12:30:43 2007 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Fri, 26 Jan 2007 03:30:43 -0800 (PST) Subject: [erlang-questions] Programming question In-Reply-To: <20070126105010.GA27366@lambdastream.com> Message-ID: <20070126113043.80514.qmail@web38805.mail.mud.yahoo.com> --- Samuel Rivas wrote: > I guess it is difficult to fix preserving > backwards > compatibility, maybe it is worth developing a second > generation of behaviours ... While they don't do it in order to use try/catch, it has been my experience that veteran erlang companies (or companies with erlang veterans) remarkably often develop and use their own SASL-equivalents. Best, Thomas ____________________________________________________________________________________ Now that's room service! Choose from over 150,000 hotels in 45,000 destinations on Yahoo! Travel to find your fit. http://farechase.yahoo.com/promo-generic-14795097 From xpdoka@REDACTED Fri Jan 26 13:43:50 2007 From: xpdoka@REDACTED (Dominic Williams) Date: Fri, 26 Jan 2007 13:43:50 +0100 (CET) Subject: [erlang-questions] Distinguishing CORBA user and system exceptions Message-ID: <33971.217.128.75.198.1169815430.squirrel@www.geekisp.com> Hello, Is there a simple way of distinguishing between user and system CORBA exceptions ? They both have the same form: {'EXCEPTION', E}, where E is a tuple (or record) whose first element is an atom. Neither of the options I see seems very satisfactory: - check whether the atom is one of the 36 or so system exceptions; - if the second element of the tuple looks like "IDL:Foo/Bar:1.0", we have a user exception; - if the exception is a 4-tuple whose last element is one of 'COMPLETED_NO', 'COMPLETED_YES', 'COMPLETED_MAYBE', we (probably) have a system exception. Am I missing something? Cheers, Dominic Williams http://www.dominicwilliams.net ---- From nick@REDACTED Fri Jan 26 16:05:10 2007 From: nick@REDACTED (Niclas Eklund) Date: Fri, 26 Jan 2007 16:05:10 +0100 (MET) Subject: [erlang-questions] Distinguishing CORBA user and system exceptions In-Reply-To: <33971.217.128.75.198.1169815430.squirrel@www.geekisp.com> Message-ID: Hello! Not documented, but since you feel that such a function is usefull I've added it; will be named orber:is_system_exception/1 and included in the next release. /Nick On Fri, 26 Jan 2007, Dominic Williams wrote: > Hello, > > Is there a simple way of distinguishing between user and > system CORBA exceptions ? > > They both have the same form: {'EXCEPTION', E}, where E is a > tuple (or record) whose first element is an atom. > > Neither of the options I see seems very satisfactory: > > - check whether the atom is one of the 36 or so system > exceptions; > > - if the second element of the tuple looks like > "IDL:Foo/Bar:1.0", we have a user exception; > > - if the exception is a 4-tuple whose last element is one of > 'COMPLETED_NO', 'COMPLETED_YES', 'COMPLETED_MAYBE', we > (probably) have a system exception. > > Am I missing something? > > Cheers, > > Dominic Williams > http://www.dominicwilliams.net > > ---- > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From xpdoka@REDACTED Fri Jan 26 17:28:33 2007 From: xpdoka@REDACTED (Dominic Williams) Date: Fri, 26 Jan 2007 17:28:33 +0100 (CET) Subject: [erlang-questions] Distinguishing CORBA user and system exceptions In-Reply-To: References: Message-ID: <31687.217.128.75.198.1169828913.squirrel@www.geekisp.com> Hi Nick, > Not documented, but since you feel that such a function is usefull I've > added it; will be named orber:is_system_exception/1 and included in > the next release. Gee, thanks for such a quick and helpful response ! Dominic Williams http://www.dominicwilliams.net ---- From Martin.Logan@REDACTED Fri Jan 26 22:00:04 2007 From: Martin.Logan@REDACTED (Logan, Martin) Date: Fri, 26 Jan 2007 15:00:04 -0600 Subject: [erlang-questions] Erlhive Message-ID: <26AB42AB6A76E2419D26E66ECF1538468B3656@chiresexc02.resource.corp.lcl> Ulf, I remember you talking about this quite a while ago. I am glad to see it is out. Do you have some info that better describes the aim of the project. I think you should add that to your home page, as well as send it to me :-). Cheers, Martin -------------- next part -------------- An HTML attachment was scrubbed... URL: From Martin.Logan@REDACTED Fri Jan 26 23:24:56 2007 From: Martin.Logan@REDACTED (Logan, Martin) Date: Fri, 26 Jan 2007 16:24:56 -0600 Subject: [erlang-questions] Erlhive In-Reply-To: <26AB42AB6A76E2419D26E66ECF1538468B3656@chiresexc02.resource.corp.lcl> References: <26AB42AB6A76E2419D26E66ECF1538468B3656@chiresexc02.resource.corp.lcl> Message-ID: <26AB42AB6A76E2419D26E66ECF1538468B3657@chiresexc02.resource.corp.lcl> Sorry, this was meant to be sent offline. ________________________________ From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Logan, Martin Sent: Friday, January 26, 2007 3:00 PM To: Erlang-Questions (E-mail) Subject: [erlang-questions] Erlhive Ulf, I remember you talking about this quite a while ago. I am glad to see it is out. Do you have some info that better describes the aim of the project. I think you should add that to your home page, as well as send it to me :-). Cheers, Martin -------------- next part -------------- An HTML attachment was scrubbed... URL: From e0sow9002@REDACTED Sat Jan 27 08:05:54 2007 From: e0sow9002@REDACTED (e0sow9002@REDACTED) Date: 27 Jan 2007 07:05:54 -0000 Subject: [erlang-questions] (no subject) Message-ID: <27067-19931@sneakemail.com> How do I run an erlang program from the command line? Please excuse me if I have missed where this is documented, but I've looked in all what seem obvious places. The FAQ, Getting started etc. Thanks. From e0sow9002@REDACTED Sat Jan 27 08:05:55 2007 From: e0sow9002@REDACTED (e0sow9002@REDACTED) Date: 27 Jan 2007 07:05:55 -0000 Subject: [erlang-questions] (no subject) Message-ID: <30087-23514@sneakemail.com> How do I run an erlang program from the command line? Please excuse me if I have missed where this is documented, but I've looked in all what seem obvious places. The FAQ, Getting started etc. Thanks. From e0sow9002@REDACTED Sat Jan 27 08:05:55 2007 From: e0sow9002@REDACTED (e0sow9002@REDACTED) Date: 27 Jan 2007 07:05:55 -0000 Subject: [erlang-questions] (no subject) Message-ID: <31418-10630@sneakemail.com> How do I run an erlang program from the command line? Please excuse me if I have missed where this is documented, but I've looked in all what seem obvious places. The FAQ, Getting started etc. Thanks. From e0sow9002@REDACTED Sat Jan 27 08:06:02 2007 From: e0sow9002@REDACTED (e0sow9002@REDACTED) Date: 27 Jan 2007 07:06:02 -0000 Subject: [erlang-questions] (no subject) Message-ID: <30087-33800@sneakemail.com> How do I run an erlang program from the command line? Please excuse me if I have missed where this is documented, but I've looked in all what seem obvious places. The FAQ, Getting started etc. Thanks. From e0sow9002@REDACTED Sat Jan 27 08:06:04 2007 From: e0sow9002@REDACTED (e0sow9002@REDACTED) Date: 27 Jan 2007 07:06:04 -0000 Subject: [erlang-questions] (no subject) Message-ID: <30284-75399@sneakemail.com> How do I run an erlang program from the command line? Please excuse me if I have missed where this is documented, but I've looked in all what seem obvious places. The FAQ, Getting started etc. Thanks. From e0sow9002@REDACTED Sat Jan 27 08:06:04 2007 From: e0sow9002@REDACTED (e0sow9002@REDACTED) Date: 27 Jan 2007 07:06:04 -0000 Subject: [erlang-questions] (no subject) Message-ID: <27041-75560@sneakemail.com> How do I run an erlang program from the command line? Please excuse me if I have missed where this is documented, but I've looked in all what seem obvious places. The FAQ, Getting started etc. Thanks. From e0sow9002@REDACTED Sat Jan 27 08:06:27 2007 From: e0sow9002@REDACTED (e0sow9002@REDACTED) Date: 27 Jan 2007 07:06:27 -0000 Subject: [erlang-questions] (no subject) Message-ID: <27041-54198@sneakemail.com> How do I run an erlang program from the command line? Please excuse me if I have missed where this is documented, but I've looked in all what seem obvious places. The FAQ, Getting started etc. Thanks. From e0sow9002@REDACTED Sat Jan 27 08:06:41 2007 From: e0sow9002@REDACTED (e0sow9002@REDACTED) Date: 27 Jan 2007 07:06:41 -0000 Subject: [erlang-questions] (no subject) Message-ID: <31418-76806@sneakemail.com> How do I run an erlang program from the command line? Please excuse me if I have missed where this is documented, but I've looked in all what seem obvious places. The FAQ, Getting started etc. Thanks. From e0sow9002@REDACTED Sat Jan 27 08:06:41 2007 From: e0sow9002@REDACTED (e0sow9002@REDACTED) Date: 27 Jan 2007 07:06:41 -0000 Subject: [erlang-questions] (no subject) Message-ID: <31892-22030@sneakemail.com> How do I run an erlang program from the command line? Please excuse me if I have missed where this is documented, but I've looked in all what seem obvious places. The FAQ, Getting started etc. Thanks. From matthias@REDACTED Sat Jan 27 11:46:19 2007 From: matthias@REDACTED (Matthias Lang) Date: Sat, 27 Jan 2007 11:46:19 +0100 Subject: [erlang-questions] (no subject) In-Reply-To: <30284-75399@sneakemail.com> References: <30284-75399@sneakemail.com> Message-ID: <17851.11643.560322.630735@antilipe.corelatus.se> e0sow9002@REDACTED writes: > How do I run an erlang program from the command line? > > Please excuse me if I have missed where this is documented, but > I've looked in all what seem obvious places. The FAQ, Getting > started etc. You could look at question 5.7 in the Erlang FAQ "How do I run an Erlang program directly from the unix shell?" http://www.erlang.org/faq/x479.html#AEN523 Or you could ask google word-for-word exactly what you asked the mailing list several times over: "How do I run an erlang program from the command line?" http://www.google.se/search?hl=en&client=firefox-a&rls=org.debian%3Aen-US%3Aunofficial&hs=fL5&q=How+do+I+run+an+erlang+program+from+the+command+line&btnG=Search And the very first link is to an explanation of how to do it. The trap exit wiki has even more detailed instructions: http://wiki.trapexit.org/index.php/Running_Erlang_Code_From_The_Command_Line It could be that you want to make an executable and run that directly, in which case http://www.erlang.org/faq/x479.html#AEN667 might be of interest. Matthias From rasmussen.bryan@REDACTED Mon Jan 29 15:09:47 2007 From: rasmussen.bryan@REDACTED (bryan rasmussen) Date: Mon, 29 Jan 2007 15:09:47 +0100 Subject: [erlang-questions] IDX-xmnesia? Message-ID: <3bb44c6e0701290609u8836616w10e75bfee5b62b08@mail.gmail.com> Any existence of IDX-xmnesia still? cheers, Bryan Rasmussen From per.gustafsson@REDACTED Mon Jan 29 17:42:05 2007 From: per.gustafsson@REDACTED (Per Gustafsson) Date: Mon, 29 Jan 2007 17:42:05 +0100 Subject: [erlang-questions] Erlang Extension Proposals (EEPs) Message-ID: <45BE23DD.5090900@it.uu.se> In conjunction with the Erlang User Conference 2006 there was a workshop concerning the future development of Erlang. In this workshop a decision was made to adopt the Python process for future Erlang development. Since nothing has happened since then I have taken it upon myself to edit PEP 1, the python extension proposal which describes how the python process works. This should be viewed as a draft so please feel free to suggest changes. There are also a lot of decision that needs to be made and issues that need to be solved. I'll list some of them below. 1. We need to have some EEP editors 2. We need an e-mail address for the EEP editors, I have suggested eeps@REDACTED 3. We need tools to generate html from EEPs. I have altered some of the python tools to acheive this, but the resulting script is very brittle and probably won't work for most EEPs 4. We need a subversion repository to keep track of the EEPs The draft for EEP 1 can be found at: http://user.it.uu.se/~pergu/eep/eep-0001.html Per Gustafsson From forsyth@REDACTED Mon Jan 29 18:22:51 2007 From: forsyth@REDACTED (Charles Forsyth) Date: Mon, 29 Jan 2007 17:22:51 +0000 Subject: [erlang-questions] Inferno - erroneous comments Message-ID: <7d0eb19b503908b0898b3afc2765573f@terzarima.net> >I'm not sure what the most glaring misunderstanding >is - whether it is the alledged lack of a royalty-free >distribution or the supposed lack of a VM. (: quite. i'm not really sure where that table came from. the overview or at least the table must be many years old, since it bothers to mention CORBA which i haven't come across for ages. (although looking at the erlang archives for this item, i saw CORBA mentioned on this list recently: it's a proper little zombie, isn't it!). still, i'd have thought i'd have been asked to check the content, but that seems unlikely given what it has says about Erlang, because i knew much more about it than that table shows (incorrectly). i'd looked at Erlang quite early on, and having checked my mailbox here (at my home address) just now i see in 1997 a fairly terse e-mail saying i couldn't have the source to the emulator for the university distribution of Free(!) Erlang so i could port it to Plan 9: ``at this moment I see no reason for us to add another platform'' (but i was offering to do the work!). happily i also find a message from December 1998 announcing Open Source Erlang: with results we see today. (sadly by that time i'd got myself too involved in starting a company and with no time to do the port. i'm sure there's a lesson there.) anyway, now that it has been pointed out to me, i'll see if i can find the source to the offending document and simply delete the table. quite apart from wronging Erlang, i think tickbox charts and feature lists are a terrible way to compare software systems. >At least, Erlang gets one tick more than XML/SOAP... i myself get quite ticked off about XML/SOAP. it's a little startling that this has suddenly surfaced now, however, after all these years, because just a few weeks ago i happened to spot Yariv Sadan's Erlang projects on googlecode, which led me to his blog, which led me to some other interesting things, which got me thinking. (and not before time, friends and colleagues might say.) sorry for the fuss. Charles Forsyth Vita Nuova From thomasl_erlang@REDACTED Mon Jan 29 20:51:33 2007 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Mon, 29 Jan 2007 11:51:33 -0800 (PST) Subject: [erlang-questions] Erlang Extension Proposals (EEPs) In-Reply-To: <45BE23DD.5090900@it.uu.se> Message-ID: <26293.46674.qm@web38804.mail.mud.yahoo.com> --- Per Gustafsson wrote: > In conjunction with the Erlang User Conference 2006 > there was a workshop > concerning the future development of Erlang. > > In this workshop a decision was made to adopt the > Python process for > future Erlang development. Since nothing has > happened since then I have > taken it upon myself to edit PEP 1, the python > extension proposal which > describes how the python process works. This should > be viewed as a draft > so please feel free to suggest changes. There are > also a lot of decision > that needs to be made and issues that need to be > solved. I'll list some > of them below. I think the basic concept sounds useful, since it may make proposals more concrete and discussions better focused, and it preserves a history of the decisions made. Of course, there still may be devils in the details. My first question is: is this intended for changes to Erlang, or to Erlang/OTP? Given that the ultimate acceptance decision seems to taken by OTP, it seems like we're really talking about Erlang/OTP? (Alternatively, that the two are basically the same. This issue is a bit unclear at present.) And, second question, will OTP henceforth primarily use this process to introduce changes to the language? Best, Thomas ____________________________________________________________________________________ Never Miss an Email Stay connected with Yahoo! Mail on your mobile. Get started! http://mobile.yahoo.com/services?promote=mail From robert.virding@REDACTED Mon Jan 29 22:53:39 2007 From: robert.virding@REDACTED (Robert Virding) Date: Mon, 29 Jan 2007 22:53:39 +0100 Subject: [erlang-questions] Erlang Extension Proposals (EEPs) In-Reply-To: <26293.46674.qm@web38804.mail.mud.yahoo.com> References: <26293.46674.qm@web38804.mail.mud.yahoo.com> Message-ID: <45BE6CE3.1020500@telia.com> Thomas Lindgren wrote: > --- Per Gustafsson wrote: > >>In conjunction with the Erlang User Conference 2006 >>there was a workshop >>concerning the future development of Erlang. >> >>In this workshop a decision was made to adopt the >>Python process for >>future Erlang development. Since nothing has >>happened since then I have >>taken it upon myself to edit PEP 1, the python >>extension proposal which >>describes how the python process works. This should >>be viewed as a draft >>so please feel free to suggest changes. There are >>also a lot of decision >>that needs to be made and issues that need to be >>solved. I'll list some >>of them below. > > I think the basic concept sounds useful, since it may > make proposals more concrete and discussions better > focused, and it preserves a history of the decisions > made. Of course, there still may be devils in the > details. There are always devils in the details! :-) But I agree with you. > My first question is: is this intended for changes to > Erlang, or to Erlang/OTP? Given that the ultimate > acceptance decision seems to taken by OTP, it seems > like we're really talking about Erlang/OTP? > (Alternatively, that the two are basically the same. > This issue is a bit unclear at present.) I think that that will, in most cases, be relatively clear. If a change is about the language or a small set of core modules then it is Erlang, otherwise it is OTP. This assumes that the OTP version of the language Erlang also defines the language. The problem with this is of course that if someone wanted to do their own implementation of Erlang there is no real definition of the language and EEP will not help here. Another problem is all the stuff in the emulator which mightn't be considered part of the language but which are necessary to make OTP run. For example boot/startup procedure and some ETS tables whichare predefined by the system. One solution would be to revive the erlang spec and run it in conjunction with, and separately from, the OTP emulator. If there is an interest. > And, second question, will OTP henceforth primarily > use this process to introduce changes to the language? Hopefully, if the suggestion is adopted, they will. That would also be a good way for them to announce their future plans. Robert From robert.virding@REDACTED Mon Jan 29 23:00:03 2007 From: robert.virding@REDACTED (Robert Virding) Date: Mon, 29 Jan 2007 23:00:03 +0100 Subject: [erlang-questions] Erlang Extension Proposals (EEPs) In-Reply-To: <45BE23DD.5090900@it.uu.se> References: <45BE23DD.5090900@it.uu.se> Message-ID: <45BE6E63.200@telia.com> An small irreverent comment. All the EEPS remind me of the coyote and the road runner. :-) But I like the suggestion. Robert From toby@REDACTED Mon Jan 29 23:28:49 2007 From: toby@REDACTED (Toby Thain) Date: Mon, 29 Jan 2007 20:28:49 -0200 Subject: [erlang-questions] Erlang Extension Proposals (EEPs) In-Reply-To: <45BE6E63.200@telia.com> References: <45BE23DD.5090900@it.uu.se> <45BE6E63.200@telia.com> Message-ID: <21911233-D34F-4DF0-8F83-88C9FDFCDADE@smartgames.ca> On 29-Jan-07, at 8:00 PM, Robert Virding wrote: > An small irreverent comment. All the EEPS remind me of the coyote and > the road runner. :-) Aren't those "meeps"? PS. I can offer a Subversion server or other hosting services from colo in Canada. > > But I like the suggestion. > > Robert > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From jeffm@REDACTED Tue Jan 30 04:04:02 2007 From: jeffm@REDACTED (jm) Date: Tue, 30 Jan 2007 14:04:02 +1100 Subject: [erlang-questions] guard sequence for string? Message-ID: <45BEB5A2.3080709@ghostgun.com> Is there a guard sequence to test if a supplied parameter is a ascii string, ie, is_string, the same as there is is_integer? I check the docs and am unable to find anything. I tried is_list() but this doesn't seem to do what I want (it was a long shot). So what's the stardard approach here? Jeff. From mats.cronqvist@REDACTED Tue Jan 30 09:09:43 2007 From: mats.cronqvist@REDACTED (Mats Cronqvist) Date: Tue, 30 Jan 2007 09:09:43 +0100 Subject: [erlang-questions] guard sequence for string? In-Reply-To: <45BEB5A2.3080709@ghostgun.com> References: <45BEB5A2.3080709@ghostgun.com> Message-ID: <45BEFD47.7010705@ericsson.com> jm wrote: > Is there a guard sequence to test if a supplied parameter is a ascii > string, ie, is_string, the same as there is is_integer? I check the docs > and am unable to find anything. I tried is_list() but this doesn't seem > to do what I want (it was a long shot). So what's the stardard approach > here? variations on this theme, i'm afraid. is_string([]) -> true; is_string([H|T]) when integer(H), H >= $ , H =< $~ -> is_string(T); is_string(_) -> false. From samuelrivas@REDACTED Tue Jan 30 10:07:56 2007 From: samuelrivas@REDACTED (Samuel Rivas) Date: Tue, 30 Jan 2007 10:07:56 +0100 Subject: [erlang-questions] guard sequence for string? In-Reply-To: <45BEB5A2.3080709@ghostgun.com> References: <45BEB5A2.3080709@ghostgun.com> Message-ID: <20070130090756.GA27034@lambdastream.com> jm wrote: > Is there a guard sequence to test if a supplied parameter is a ascii > string, ie, is_string, the same as there is is_integer? I check the docs > and am unable to find anything. I tried is_list() but this doesn't seem > to do what I want (it was a long shot). So what's the stardard approach > here? Well, it is not as good as one would like, but you have io_lib:char_list/1. Sadly, you cannot use it as a guard. Regards -- Samuel From francesco@REDACTED Tue Jan 30 10:08:13 2007 From: francesco@REDACTED (Francesco Cesarini) Date: Tue, 30 Jan 2007 09:08:13 +0000 Subject: [erlang-questions] fP IEEE Software Special Issue on Rapid Application Development with Dynamically Typed Languages Message-ID: <45BF0AFD.30108@erlang-consulting.com> Sounds perfect for Erlang. Any one have a success story they want to share? Regards, Francesco Subject: Extended deadline: CfP IEEE Software Special Issue on Rapid Application Development with Dynamically Typed Languages ============================================================================ IEEE Software Special Issue Rapid Application Development with Dynamically Typed Languages Call for Papers Publication: September/October 2007 Extended submission deadline: 15 February 2007 ============================================================================ Dynamically typed programming languages were once seen as slow, unreliable, and suitable only for small throw-away tasks. However, their ability to aid rapid systems development and to facilitate the pervasive, mobile, and frequently updated systems that are increasingly in demand in the modern world has led to their stock rising considerably. While developers are ever keen to find out more about the details of dynamic programming languages, managers are interested in finding out how they can complement existing approved languages without diluting their organizations' technical focus. We thus solicit contributions in several areas related to dynamic programming languages. Topics of interest include: * Dynamic programming languages "in use". * Organizations' experiences in integrating dynamic programming languages into their existing language menagerie. * Experiences of and techniques for using dynamic programming languages effectively (including efficiency and scalability concerns). * How dynamic programming languages have evolved and how they might develop in the future. * New techniques in challenging areas such as metaprogramming, reflection, dynamic reconfigurability, and mobility. For detailed author guidelines, please visit: http://www.computer.org/software/author.htm Manuscripts must not exceed 5,400 words including figures and tables, which count for 200 words each. Submissions in excess of these limits may be rejected without refereeing. The articles we deem within the theme's scope will be peer-reviewed and are subject to editing for magazine style, clarity, organization, and space. For more information, please contact the Guest Editors Laurence Tratt and Roel Wuyts at dyn@REDACTED From VAUCHER@REDACTED Tue Jan 30 13:20:41 2007 From: VAUCHER@REDACTED (VAUCHER Laurent) Date: Tue, 30 Jan 2007 13:20:41 +0100 Subject: [erlang-questions] Compiling erlang on AIX 5.3 Message-ID: <55DDB08CC9CD2941A70E8D626789A2C903FBB261@ec8l7ljvo9h5dde.hosting.exch> Hi. I'm trying to compile R11B2 on AIX 5.3 and, as you might guess, it fails. I can help fixing it, but I will need some help. First, the ./configure script warns me that odbc will not be built (that's probably normal). Then, when doing make, compilation fails on erts/emulator/sys/unix/erl_check_io.c The problem comes from AIX, in fact, because the included file does a very nasty trick: it simply #defines events and revents. And those identifiers are used as struct fields in erts/emulator/beam/erl_driver.h Well, I have found a kind of workaround, which is to force #include just before the struct definition. I have not yet found how to protect this include so that it only happens on AIX. Compilation seems to proceed further, but then === Entering application parsetools make[3]: Entering directory `/tmp/otp_src_R11B-2/lib/parsetools/src' erlc -W +debug_info -I/tmp/otp_src_R11B-2/lib/stdlib/include -o../ebin yecc.erl Could not load program /tmp/otp_src_R11B-2/bin/powerpc-ibm-aix5.3.0.0/beam: The program does not have an entry point or the o_snentry field in the auxiliary header is invalid. Examine file headers with the 'dump -ohv' command. make[3]: *** [../ebin/yecc.beam] Error 255 make[3]: Leaving directory `/tmp/otp_src_R11B-2/lib/parsetools/src' make[2]: *** [opt] Error 2 make[2]: Leaving directory `/tmp/otp_src_R11B-2/lib/parsetools' make[1]: *** [opt] Error 2 make[1]: Leaving directory `/tmp/otp_src_R11B-2/lib' make: *** [secondary_bootstrap_build] Error 2 I have no idea what this can mean. The suggested dump -ohv on 'beam' gives the following result /tmp/otp_src_R11B-2>dump -ohv bin/powerpc-ibm-aix5.3.0.0/beam bin/powerpc-ibm-aix5.3.0.0/beam: ***Object Module Header*** # Sections Symbol Ptr # Symbols Opt Hdr Len Flags 5 0x00019018 7882 72 0x1002 Flags=( EXEC DYNLOAD DEP_SYSTEM ) Timestamp = "Jan 24 11:35:43 2007" Magic = 0x1df (32-bit XCOFF) ***Optional Header*** Tsize Dsize Bsize Tstart Dstart 0x00007078 0x00000894 0x000000c0 0x10000150 0x200001c8 SNloader SNentry SNtext SNtoc SNdata 0x0004 0x0000 0x0001 0x0002 0x0002 TXTalign DATAalign TOC vstamp entry 0x0005 0x0003 0x200009f4 0x0001 0xffffffff maxSTACK maxDATA SNbss magic modtype 0x00000000 0x00000000 0x0003 0x010b 1L ***Section Header Information*** Section Header for .text PHYaddr VTRaddr SCTsiz RAWptr RELptr 0x10000150 0x10000150 0x00007078 0x00000150 0x000156e6 LN#ptr #RELent #LINent Flags 0x00015f2e 0x0074 0x0827 0x00000020 Section Header for .data PHYaddr VTRaddr SCTsiz RAWptr RELptr 0x200001c8 0x200001c8 0x00000894 0x000071c8 0x00015b6e LN#ptr #RELent #LINent Flags 0x00000000 0x0060 0x0000 0x00000040 Section Header for .bss PHYaddr VTRaddr SCTsiz RAWptr RELptr 0x20000a5c 0x20000a5c 0x000000c0 0x00000000 0x00000000 LN#ptr #RELent #LINent Flags 0x00000000 0x0000 0x0000 0x00000080 Section Header for .loader PHYaddr VTRaddr SCTsiz RAWptr RELptr 0x00000000 0x00000000 0x00000627 0x00007a5c 0x00000000 LN#ptr #RELent #LINent Flags 0x00000000 0x0000 0x0000 0x00001000 Section Header for .debug PHYaddr VTRaddr SCTsiz RAWptr RELptr 0x00000000 0x00000000 0x0000d661 0x00008084 0x00000000 LN#ptr #RELent #LINent Flags 0x00000000 0x0000 0x0000 0x00002000 Does anyone have an idea here? Laurent Vaucher. From kenneth.lundin@REDACTED Tue Jan 30 14:51:44 2007 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Tue, 30 Jan 2007 14:51:44 +0100 Subject: [erlang-questions] Erlang Extension Proposals (EEPs) In-Reply-To: <26293.46674.qm@web38804.mail.mud.yahoo.com> References: <45BE23DD.5090900@it.uu.se> <26293.46674.qm@web38804.mail.mud.yahoo.com> Message-ID: On 1/29/07, Thomas Lindgren wrote: > > --- Per Gustafsson wrote: > > > In conjunction with the Erlang User Conference 2006 > > there was a workshop > > concerning the future development of Erlang. > > > > In this workshop a decision was made to adopt the > > Python process for > > future Erlang development. Since nothing has > > happened since then I have > > taken it upon myself to edit PEP 1, the python > > extension proposal which > > describes how the python process works. This should > > be viewed as a draft > > so please feel free to suggest changes. There are > > also a lot of decision > > that needs to be made and issues that need to be > > solved. I'll list some > > of them below. > > I think the basic concept sounds useful, since it may > make proposals more concrete and discussions better > focused, and it preserves a history of the decisions > made. Of course, there still may be devils in the > details. > > My first question is: is this intended for changes to > Erlang, or to Erlang/OTP? Given that the ultimate > acceptance decision seems to taken by OTP, it seems > like we're really talking about Erlang/OTP? First what do you mean with Erlang, OTP and Erlang/OTP? My view of it is that: - Erlang/OTP is equivalent with OTP - Erlang is the language and the only full implementation that I am aware of is delivered as part of Erlang/OTP. The EEP process mainly is intended for: - changes to the Erlang language - changed behaviour of the Erlang runtime system (might be thought of as part of the language) - significant changes to standard libraries (stdlib, kernel) - system principles, ... - there are always grey zones and we have treat each EEP in a good way. > (Alternatively, that the two are basically the same. > This issue is a bit unclear at present.) > > And, second question, will OTP henceforth primarily > use this process to introduce changes to the language? Yes, the OTP team at Ericsson will primarily use this process to introduce changes in language, runtime system and libraries. The OTP team will of course be represented as editors and will have a lot to say about if, when and how new things are introduced. > > Best, > Thomas > Regards Kenneth (OTP team at Ericsson) ____________________________________________________________________________________ > Never Miss an Email > Stay connected with Yahoo! Mail on your mobile. Get started! > http://mobile.yahoo.com/services?promote=mail > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From emil.hellman@REDACTED Tue Jan 30 15:05:01 2007 From: emil.hellman@REDACTED (Emil Hellman) Date: Tue, 30 Jan 2007 15:05:01 +0100 Subject: [erlang-questions] Compilation question... Message-ID: Hello! I have a small feature I want to several modules. My thought is to add this feature if I encounter a '-myfeature(Args)' in the module. Example: -module(foo). -export([bar/0]). -myfeature(Args). Where args could be several different things. So essentially if I find this "tag" in the module I would like to append some code to the file (dependant on the args). And then compile the modified module. However, I don't want the generated code to be appended to the actual module, simply added temporarily during the compilation. To do this I need some guidance. What module(s) contain the code that is used by the compiler? I checked out 'compile.erl', but I think I want to do something to the modules before this code is called (though I might be wrong here). Any guidance would be greatly appreciated. Regards, Emil From ulf@REDACTED Tue Jan 30 15:30:06 2007 From: ulf@REDACTED (Ulf Wiger) Date: Tue, 30 Jan 2007 15:30:06 +0100 Subject: [erlang-questions] Compilation question... In-Reply-To: References: Message-ID: Den 2007-01-30 15:05:01 skrev Emil Hellman : > Hello! > > I have a small feature I want to several modules. My thought is to add > this feature if I encounter a '-myfeature(Args)' in the module. > > Example: > > -module(foo). > -export([bar/0]). > -myfeature(Args). > > Where args could be several different things. > > So essentially if I find this "tag" in the module I would like to > append some code to the file (dependant on the args). And then compile > the modified module. However, I don't want the generated code to be > appended to the actual module, simply added temporarily during the > compilation. It sounds like you want a parse transform. Look e.g. at some of the user contributions at trapexit. My recommendation is to use syntax_tools, even though the learning curve is somewhat steep. You can recognize attributes during the parse transform like so (example from erlhive.erl): recognize_form(E, O) -> case erl_syntax:type(E) of attribute -> AName = erl_syntax:attribute_name(E), rewrite_attribute(AName, E, O); ... end A bit of warning, though: After doing a parse transform with syntax_tools, you have to call erl_syntax:revert(Form) to bring it back to the standard Erlang abstract format. I've encountered some problems esp when reverting rewritten attributes. I believe most of them have been related to the handling of dotted module names, since they are represented in the parse tree as record expressions. My workaround has been to write a custom revert() which converts the module names back to atoms again, and then calls the standard revert. (I've reported this to the OTP team - at least as regards revert() of -import/2 attributes containing dotted module names. A fix will come in some post-R11B-2 release.) BR, Ulf W -- Ulf Wiger From per.gustafsson@REDACTED Tue Jan 30 16:00:05 2007 From: per.gustafsson@REDACTED (Per Gustafsson) Date: Tue, 30 Jan 2007 16:00:05 +0100 Subject: [erlang-questions] Compilation question... In-Reply-To: References: Message-ID: <45BF5D75.5010604@it.uu.se> Emil Hellman wrote: > Hello! > > I have a small feature I want to several modules. My thought is to add > this feature if I encounter a '-myfeature(Args)' in the module. > > Example: > > -module(foo). > -export([bar/0]). > -myfeature(Args). > > Where args could be several different things. > > So essentially if I find this "tag" in the module I would like to > append some code to the file (dependant on the args). And then compile > the modified module. However, I don't want the generated code to be > appended to the actual module, simply added temporarily during the > compilation. > > To do this I need some guidance. What module(s) contain the code that > is used by the compiler? I checked out 'compile.erl', but I think I > want to do something to the modules before this code is called (though > I might be wrong here). If you do not want to use a parse transform you can try to use an include directive and the preprocessor to solve your problem. It would look something like this: -module(foo). -export([bar/0]). -define(FEATURE_TYPE1,true). -define(ARGS,Args). -include("myfeature.hrl"). ... and in myfeature.hrl: -ifdef(FEATURE_TYPE1). Code to append using ?ARGS -endif. This of course less versatile than a parse transform, but it is easier to implement. Per From thomasl_erlang@REDACTED Tue Jan 30 17:08:14 2007 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Tue, 30 Jan 2007 08:08:14 -0800 (PST) Subject: [erlang-questions] Erlang Extension Proposals (EEPs) In-Reply-To: Message-ID: <774697.17446.qm@web38804.mail.mud.yahoo.com> --- Kenneth Lundin wrote: > On 1/29/07, Thomas Lindgren > wrote: > > > > --- Per Gustafsson > wrote: > > > > > In conjunction with the Erlang User Conference > 2006 > > > there was a workshop > > > concerning the future development of Erlang. > > > > > > In this workshop a decision was made to adopt > the > > > Python process for > > > future Erlang development. Since nothing has > > > happened since then I have > > > taken it upon myself to edit PEP 1, the python > > > extension proposal which > > > describes how the python process works. This > should > > > be viewed as a draft > > > so please feel free to suggest changes. There > are > > > also a lot of decision > > > that needs to be made and issues that need to be > > > solved. I'll list some > > > of them below. > > > > I think the basic concept sounds useful, since it > may > > make proposals more concrete and discussions > better > > focused, and it preserves a history of the > decisions > > made. Of course, there still may be devils in the > > details. > > > > My first question is: is this intended for changes > to > > Erlang, or to Erlang/OTP? Given that the ultimate > > acceptance decision seems to taken by OTP, it > seems > > like we're really talking about Erlang/OTP? > > First what do you mean with Erlang, OTP and > Erlang/OTP? Erlang: a popular programming language OTP: an Ericsson organization Erlang/OTP: the OTP implementation of Erlang (and more) > My view of it is that: > - Erlang/OTP is equivalent with OTP > - Erlang is the language and the only full > implementation that I am aware of is > delivered as part of Erlang/OTP. > > The EEP process mainly is intended for: > - changes to the Erlang language > - changed behaviour of the Erlang runtime system > (might be thought of > as part of the language) > - significant changes to standard libraries (stdlib, > kernel) > - system principles, ... > - there are always grey zones and we have treat each > EEP in a good way. > > > > (Alternatively, that the two are basically the > same. > > This issue is a bit unclear at present.) > > > > And, second question, will OTP henceforth > primarily > > use this process to introduce changes to the > language? > > > Yes, the OTP team at Ericsson will primarily use > this process to introduce > changes in language, runtime system and libraries. > > The OTP team will of course be represented as > editors and will have a > lot to say > about if, when and how new things are introduced. Okay, that clarifies it. The other approach (as exemplified by the old spec, for instance) is to see Erlang the language as something independent of Erlang/OTP, in which case it might have been more suitable not to hand all the decision making power to OTP. But I have no big objection to leaving those decisions to OTP if we are talking about the future development of the Erlang part of the Erlang/OTP platform. Best, Thomas ____________________________________________________________________________________ The fish are biting. Get more visitors on your site using Yahoo! Search Marketing. http://searchmarketing.yahoo.com/arp/sponsoredsearch_v2.php From joelr1@REDACTED Tue Jan 30 18:49:57 2007 From: joelr1@REDACTED (Joel Reymont) Date: Tue, 30 Jan 2007 17:49:57 +0000 Subject: [erlang-questions] XML-RPC Message-ID: Folks, What's a good XML-RPC implementation for Erlang? Thanks, Joel -- http://wagerlabs.com/ From james.hague@REDACTED Tue Jan 30 20:49:23 2007 From: james.hague@REDACTED (James Hague) Date: Tue, 30 Jan 2007 13:49:23 -0600 Subject: [erlang-questions] Erlang Extension Proposals (EEPs) In-Reply-To: <45BE23DD.5090900@it.uu.se> References: <45BE23DD.5090900@it.uu.se> Message-ID: I like this idea a lot. Erlang is wonderful, but certainly not perfect. Lots of ideas have been discussed off and on here, but there's no clear place to go to see the state of proposed changes. Whover maintains the web page containing EEPs can organize them into major and minor proposals. Major being changes to the core language or important library functions, minor being new library functions that won't affect existing code. From robert.virding@REDACTED Wed Jan 31 00:17:18 2007 From: robert.virding@REDACTED (Robert Virding) Date: Wed, 31 Jan 2007 00:17:18 +0100 Subject: [erlang-questions] Erlang Extension Proposals (EEPs) In-Reply-To: <21911233-D34F-4DF0-8F83-88C9FDFCDADE@smartgames.ca> References: <45BE23DD.5090900@it.uu.se> <45BE6E63.200@telia.com> <21911233-D34F-4DF0-8F83-88C9FDFCDADE@smartgames.ca> Message-ID: <45BFD1FE.9040101@telia.com> Toby Thain wrote: > > On 29-Jan-07, at 8:00 PM, Robert Virding wrote: > >> An small irreverent comment. All the EEPS remind me of the coyote and >> the road runner. :-) > > > Aren't those "meeps"? Close enough, close enough to sound right. Robert From jeffm@REDACTED Wed Jan 31 00:58:19 2007 From: jeffm@REDACTED (jm) Date: Wed, 31 Jan 2007 10:58:19 +1100 Subject: [erlang-questions] guard sequence for string? In-Reply-To: <45BEFD47.7010705@ericsson.com> References: <45BEB5A2.3080709@ghostgun.com> <45BEFD47.7010705@ericsson.com> Message-ID: <45BFDB9B.7010608@ghostgun.com> Mats Cronqvist wrote: > jm wrote: >> Is there a guard sequence to test if a supplied parameter is a ascii >> string, ie, is_string, the same as there is is_integer? I check the docs >> and am unable to find anything. I tried is_list() but this doesn't seem >> to do what I want (it was a long shot). So what's the stardard approach >> here? > > variations on this theme, i'm afraid. > > is_string([]) -> true; > is_string([H|T]) when integer(H), H >= $ , H =< $~ -> is_string(T); > is_string(_) -> false. > _______________________________________________ Thanks. I worked around it by re-ordering things in the mean time. The work around is not as reliable as as using a guard. When I looking back over that code again in the next few days I'll have to give this a try. Jeff. From jocke@REDACTED Wed Jan 31 01:30:44 2007 From: jocke@REDACTED (Joakim G.) Date: Wed, 31 Jan 2007 01:30:44 +0100 Subject: [erlang-questions] XML-RPC In-Reply-To: References: Message-ID: <45BFE334.3020801@tail-f.com> There is a standalone xmlrpc lib in jungerl. It is used in 24/7 installations. Yaws has a built-in ditto (based on the jungerl version). /Jocke Joel Reymont wrote: > Folks, > > What's a good XML-RPC implementation for Erlang? > > Thanks, Joel > > -- > http://wagerlabs.com/ > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From tom@REDACTED Wed Jan 31 08:34:26 2007 From: tom@REDACTED (Tom Samplonius) Date: Tue, 30 Jan 2007 23:34:26 -0800 (PST) Subject: [erlang-questions] Erlang Extension Proposals (EEPs) In-Reply-To: <774697.17446.qm@web38804.mail.mud.yahoo.com> Message-ID: <16250661.151170228866547.JavaMail.root@ly.sdf.com> ----- "Thomas Lindgren" wrote: > Erlang: a popular programming language > OTP: an Ericsson organization > Erlang/OTP: the OTP implementation of Erlang (and > more) But OTP is also a bunch of libraries that are useful, not just an organization. I see that the general impression is that the OTP code is complex, but it does do something useful. Given how fractionalized that LISP has become because each implementation has libraries that perform the same function, but just work different (ex. sockets do not work the same way), leading to wrapper libraries that try to provide a generic interface that works anywhere. It is a real mess, marginalizing LISP to a prototyping language (ex. http://reddit.com/ was re-written in Python from CMU Lisp, because it was unstable, and sockets and threads don't work the same way in all LISPs). Since the work on OTP has already been done. It is specified, designed, and implemented, it should be considered "core", so applications can depend on OTP supporting tools/libraries/etc beubg present in every erlang install. At minimum this would help ensure that Ericsson erlang and FOSS erlang remain the same. Tom From joelr1@REDACTED Wed Jan 31 11:07:58 2007 From: joelr1@REDACTED (Joel Reymont) Date: Wed, 31 Jan 2007 10:07:58 +0000 Subject: [erlang-questions] xmerl still slow? Message-ID: <7EEBE8F9-9971-42B9-8F94-23E752104A10@gmail.com> Folks, I stumbled upon a thread from '05 that mentions eXpat having 5 times the performance of xmerl. Is xmerl still considered slow? Have there been any improvements over the past couple of years? I like the template engine at http://dev.hyperstruct.net/seethrough/ since it does not include any erlang code in the template itself. The project uses xmerl, thus my asking. Thanks, Joel -- http://wagerlabs.com/ From chsu79@REDACTED Wed Jan 31 11:24:48 2007 From: chsu79@REDACTED (Christian S) Date: Wed, 31 Jan 2007 11:24:48 +0100 Subject: [erlang-questions] xmerl still slow? In-Reply-To: <7EEBE8F9-9971-42B9-8F94-23E752104A10@gmail.com> References: <7EEBE8F9-9971-42B9-8F94-23E752104A10@gmail.com> Message-ID: Why does that template-method require a fast xml parser? Parse once and save the result for each application. On 1/31/07, Joel Reymont wrote: > Folks, > > I stumbled upon a thread from '05 that mentions eXpat having 5 times > the performance of xmerl. > > Is xmerl still considered slow? Have there been any improvements over > the past couple of years? > > I like the template engine at http://dev.hyperstruct.net/seethrough/ > since it does not include any erlang code in the template itself. The > project uses xmerl, thus my asking. > > Thanks, Joel > > -- > http://wagerlabs.com/ > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From joelr1@REDACTED Wed Jan 31 11:27:25 2007 From: joelr1@REDACTED (Joel Reymont) Date: Wed, 31 Jan 2007 10:27:25 +0000 Subject: [erlang-questions] xmerl still slow? In-Reply-To: References: <7EEBE8F9-9971-42B9-8F94-23E752104A10@gmail.com> Message-ID: <2D1F4603-513E-46C2-BE9A-9F72194777B9@gmail.com> On Jan 31, 2007, at 10:24 AM, Christian S wrote: > Why does that template-method require a fast xml parser? Parse once > and > save the result for each application. That would be "compile once", I think, as the template is dynamic by nature and content still needs to be inserted into placeholders. -- http://wagerlabs.com/ From joelr1@REDACTED Wed Jan 31 11:31:14 2007 From: joelr1@REDACTED (Joel Reymont) Date: Wed, 31 Jan 2007 10:31:14 +0000 Subject: [erlang-questions] xmerl still slow? In-Reply-To: References: <7EEBE8F9-9971-42B9-8F94-23E752104A10@gmail.com> Message-ID: Christian, On Jan 31, 2007, at 10:24 AM, Christian S wrote: > Why does that template-method require a fast xml parser? Parse once > and > save the result for each application. You are right. The approach that SeeThrough uses is the following: apply_template(File, Env) -> {Tree, _Misc} = xmerl_scan:file(File), xmerl:export_simple( [visit(Tree, Env)], xmerl_xml). There's nothing to say that the template cannot be pre-scanned and saved once, followed by multiple applications of xmerl:export_simple. I'm still wondering if any performance optimizations have gone into xmerl in the past two years. Anyone? Thanks, Joel -- http://wagerlabs.com/ From bertil.karlsson@REDACTED Wed Jan 31 12:13:23 2007 From: bertil.karlsson@REDACTED (Bertil Karlsson) Date: Wed, 31 Jan 2007 12:13:23 +0100 Subject: [erlang-questions] xmerl still slow? In-Reply-To: References: <7EEBE8F9-9971-42B9-8F94-23E752104A10@gmail.com> Message-ID: <45C079D3.6030901@ericsson.com> There have not been any performance optimisations. /Bertil Joel Reymont wrote: > Christian, > > On Jan 31, 2007, at 10:24 AM, Christian S wrote: > > >> Why does that template-method require a fast xml parser? Parse once >> and >> save the result for each application. >> > > You are right. The approach that SeeThrough uses is the following: > > apply_template(File, Env) -> > {Tree, _Misc} = xmerl_scan:file(File), > xmerl:export_simple( > [visit(Tree, Env)], xmerl_xml). > > There's nothing to say that the template cannot be pre-scanned and > saved once, followed by multiple applications of xmerl:export_simple. > > I'm still wondering if any performance optimizations have gone into > xmerl in the past two years. Anyone? > > Thanks, Joel > > -- > http://wagerlabs.com/ > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From Erik.Stenman@REDACTED Wed Jan 31 12:35:18 2007 From: Erik.Stenman@REDACTED (Erik Stenman) Date: Wed, 31 Jan 2007 12:35:18 +0100 Subject: [erlang-questions] xmerl still slow? In-Reply-To: <7EEBE8F9-9971-42B9-8F94-23E752104A10@gmail.com> References: <7EEBE8F9-9971-42B9-8F94-23E752104A10@gmail.com> Message-ID: <45C07EF6.1090502@kreditor.se> Joel Reymont wrote: > Folks, > > I stumbled upon a thread from '05 that mentions eXpat having 5 times > the performance of xmerl. > Show me an application where this performance difference matter, and I'll show you an application that shouldn't use XML. /Erik From sean.hinde@REDACTED Wed Jan 31 12:43:38 2007 From: sean.hinde@REDACTED (Sean Hinde) Date: Wed, 31 Jan 2007 11:43:38 +0000 Subject: [erlang-questions] xmerl still slow? In-Reply-To: <7EEBE8F9-9971-42B9-8F94-23E752104A10@gmail.com> References: <7EEBE8F9-9971-42B9-8F94-23E752104A10@gmail.com> Message-ID: <7393A129-120C-4E1E-843C-F0E0831C0679@gmail.com> On 31 Jan 2007, at 10:07, Joel Reymont wrote: > Folks, > > I stumbled upon a thread from '05 that mentions eXpat having 5 times > the performance of xmerl. Maybe Erlang is not the language you are looking for ;-) Alternatively google for erlang expat. Sean From joelr1@REDACTED Wed Jan 31 13:23:18 2007 From: joelr1@REDACTED (Joel Reymont) Date: Wed, 31 Jan 2007 12:23:18 +0000 Subject: [erlang-questions] xmerl still slow? In-Reply-To: <7393A129-120C-4E1E-843C-F0E0831C0679@gmail.com> References: <7EEBE8F9-9971-42B9-8F94-23E752104A10@gmail.com> <7393A129-120C-4E1E-843C-F0E0831C0679@gmail.com> Message-ID: On Jan 31, 2007, at 11:43 AM, Sean Hinde wrote: > Maybe Erlang is not the language you are looking for ;-) Ruby, Ruby! No, actually, Erlang _is_ the language I'm looking for. > Alternatively google for erlang expat. I know that ejabberd uses it but pulling it out and dealing with it is... better left until I'm absolutely sure xmerl can't handle what I'm doing. Thanks, Joel -- http://wagerlabs.com/ From joelr1@REDACTED Wed Jan 31 13:24:03 2007 From: joelr1@REDACTED (Joel Reymont) Date: Wed, 31 Jan 2007 12:24:03 +0000 Subject: [erlang-questions] xmerl still slow? In-Reply-To: <45C07EF6.1090502@kreditor.se> References: <7EEBE8F9-9971-42B9-8F94-23E752104A10@gmail.com> <45C07EF6.1090502@kreditor.se> Message-ID: On Jan 31, 2007, at 11:35 AM, Erik Stenman wrote: > Show me an application where this performance difference matter, > and I'll show you an application that shouldn't use XML. I'll take you up on this challenge. ejabberd? -- http://wagerlabs.com/ From joelr1@REDACTED Wed Jan 31 13:25:32 2007 From: joelr1@REDACTED (Joel Reymont) Date: Wed, 31 Jan 2007 12:25:32 +0000 Subject: [erlang-questions] xmerl still slow? In-Reply-To: <45C07EF6.1090502@kreditor.se> References: <7EEBE8F9-9971-42B9-8F94-23E752104A10@gmail.com> <45C07EF6.1090502@kreditor.se> Message-ID: <9953D703-ECB5-4BD7-97F1-D6BFA88480A3@gmail.com> On Jan 31, 2007, at 11:35 AM, Erik Stenman wrote: > Show me an application where this performance difference matter, > and I'll show you an application that shouldn't use XML. Should I assume that Kreditor uses xmerl and there are no complains about its performance? Thanks, Joel -- http://wagerlabs.com/ From tobbe@REDACTED Wed Jan 31 13:28:45 2007 From: tobbe@REDACTED (Torbjorn Tornkvist) Date: Wed, 31 Jan 2007 13:28:45 +0100 Subject: [erlang-questions] xmerl still slow? In-Reply-To: <7EEBE8F9-9971-42B9-8F94-23E752104A10@gmail.com> References: <7EEBE8F9-9971-42B9-8F94-23E752104A10@gmail.com> Message-ID: An alternative to xmerl may be: erlsom. --Tobbe Joel Reymont wrote: > Folks, > > I stumbled upon a thread from '05 that mentions eXpat having 5 times > the performance of xmerl. > > Is xmerl still considered slow? Have there been any improvements over > the past couple of years? > > I like the template engine at http://dev.hyperstruct.net/seethrough/ > since it does not include any erlang code in the template itself. The > project uses xmerl, thus my asking. > > Thanks, Joel > > -- > http://wagerlabs.com/ > > > From joelr1@REDACTED Wed Jan 31 13:46:54 2007 From: joelr1@REDACTED (Joel Reymont) Date: Wed, 31 Jan 2007 12:46:54 +0000 Subject: [erlang-questions] xmerl still slow? In-Reply-To: References: <7EEBE8F9-9971-42B9-8F94-23E752104A10@gmail.com> Message-ID: <8370EF19-9B8B-4E7B-BAD9-C314C17822A0@gmail.com> On Jan 31, 2007, at 12:28 PM, Torbjorn Tornkvist wrote: > > An alternative to xmerl may be: erlsom. What would be the advantage? Also, can erlsom do this? xmerl:export_simple([visit(Tree, Env)], xmerl_xml). Thanks, Joel -- http://wagerlabs.com/ From rasmussen.bryan@REDACTED Wed Jan 31 14:03:40 2007 From: rasmussen.bryan@REDACTED (bryan rasmussen) Date: Wed, 31 Jan 2007 14:03:40 +0100 Subject: [erlang-questions] xmerl still slow? In-Reply-To: <45C07EF6.1090502@kreditor.se> References: <7EEBE8F9-9971-42B9-8F94-23E752104A10@gmail.com> <45C07EF6.1090502@kreditor.se> Message-ID: <3bb44c6e0701310503rd0333ads4b01922d70bfc375@mail.gmail.com> A performance difference of 5 times being irrelevant because if it is relevant then you shouldn't use XML? That hardly seem reasonable given that in most cases where XML is used in multiple user applications the difference between 5 seconds and 25 seconds is considered as being the difference between acceptable and not. Cheers, Bryan Rasmussen On 1/31/07, Erik Stenman wrote: > Joel Reymont wrote: > > Folks, > > > > I stumbled upon a thread from '05 that mentions eXpat having 5 times > > the performance of xmerl. > > > Show me an application where this performance difference matter, > and I'll show you an application that shouldn't use XML. > > /Erik > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From ulf.wiger@REDACTED Wed Jan 31 14:29:00 2007 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Wed, 31 Jan 2007 14:29:00 +0100 Subject: [erlang-questions] xmerl still slow? In-Reply-To: <8370EF19-9B8B-4E7B-BAD9-C314C17822A0@gmail.com> Message-ID: <6616D98C65DD514BA2E1DDC5F9223155DF313C@esealmw115.eemea.ericsson.se> I think that the thing that is slow in xmerl is the actual parsing. xmerl:export_simple/2 has nothing to do with that. It assumes that the user provides a simplified representation of XML - {Tag, [Attr], Content}, where Attr = {Key, ValueStr}. (It can also take regular xmerl records, though...) If you have a simple enough XML structure to begin with, and you really don't need things like verifying parse, XPATH, entity expansion, Unicode, etc., you can easily put together a customized XML parser. See e.g. http://www.erlang.org/pipermail/erlang-questions/2005-October/017459.htm l BR, Ulf W > -----Original Message----- > From: erlang-questions-bounces@REDACTED > [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Joel Reymont > Sent: den 31 januari 2007 13:47 > To: Torbjorn Tornkvist > Cc: Erlang Questions > Subject: Re: [erlang-questions] xmerl still slow? > > > On Jan 31, 2007, at 12:28 PM, Torbjorn Tornkvist wrote: > > > > An alternative to xmerl may be: erlsom. > > What would be the advantage? > > Also, can erlsom do this? > > xmerl:export_simple([visit(Tree, Env)], xmerl_xml). > > Thanks, Joel > > -- > http://wagerlabs.com/ > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From Erik.Stenman@REDACTED Wed Jan 31 14:31:56 2007 From: Erik.Stenman@REDACTED (Erik Stenman) Date: Wed, 31 Jan 2007 14:31:56 +0100 Subject: [erlang-questions] xmerl still slow? In-Reply-To: <3bb44c6e0701310503rd0333ads4b01922d70bfc375@mail.gmail.com> References: <7EEBE8F9-9971-42B9-8F94-23E752104A10@gmail.com> <45C07EF6.1090502@kreditor.se> <3bb44c6e0701310503rd0333ads4b01922d70bfc375@mail.gmail.com> Message-ID: <45C09A4C.8040405@kreditor.se> bryan rasmussen wrote: > A performance difference of 5 times being irrelevant because if it is > relevant then you shouldn't use XML? That hardly seem reasonable given > that in most cases where XML is used in multiple user applications the > difference between 5 seconds and 25 seconds is considered as being the > difference between acceptable and not. I stand by my statement. If you are spending 5s *parsing* XML then you are using the wrong protocol (at least for an interactive application), or a very old computer. /Erik > > Cheers, > Bryan Rasmussen > > On 1/31/07, Erik Stenman wrote: >> Joel Reymont wrote: >> > Folks, >> > >> > I stumbled upon a thread from '05 that mentions eXpat having 5 times >> > the performance of xmerl. >> > >> Show me an application where this performance difference matter, >> and I'll show you an application that shouldn't use XML. >> >> /Erik >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > From Erik.Stenman@REDACTED Wed Jan 31 14:32:59 2007 From: Erik.Stenman@REDACTED (Erik Stenman) Date: Wed, 31 Jan 2007 14:32:59 +0100 Subject: [erlang-questions] xmerl still slow? In-Reply-To: References: <7EEBE8F9-9971-42B9-8F94-23E752104A10@gmail.com> <45C07EF6.1090502@kreditor.se> Message-ID: <45C09A8B.1000100@kreditor.se> Joel Reymont wrote: > > On Jan 31, 2007, at 11:35 AM, Erik Stenman wrote: > >> Show me an application where this performance difference matter, >> and I'll show you an application that shouldn't use XML. > > I'll take you up on this challenge. ejabberd? Are you saying ejabberd has a performance problem? /Erik From Erik.Stenman@REDACTED Wed Jan 31 14:34:48 2007 From: Erik.Stenman@REDACTED (Erik Stenman) Date: Wed, 31 Jan 2007 14:34:48 +0100 Subject: [erlang-questions] xmerl still slow? In-Reply-To: <9953D703-ECB5-4BD7-97F1-D6BFA88480A3@gmail.com> References: <7EEBE8F9-9971-42B9-8F94-23E752104A10@gmail.com> <45C07EF6.1090502@kreditor.se> <9953D703-ECB5-4BD7-97F1-D6BFA88480A3@gmail.com> Message-ID: <45C09AF8.3060508@kreditor.se> Joel Reymont wrote: > > On Jan 31, 2007, at 11:35 AM, Erik Stenman wrote: > >> Show me an application where this performance difference matter, >> and I'll show you an application that shouldn't use XML. > > Should I assume that Kreditor uses xmerl and there are no complains > about its performance? "You might think so, I couldn't possibly comment." /Erik From joelr1@REDACTED Wed Jan 31 14:45:29 2007 From: joelr1@REDACTED (Joel Reymont) Date: Wed, 31 Jan 2007 13:45:29 +0000 Subject: [erlang-questions] xmerl still slow? In-Reply-To: <45C09A8B.1000100@kreditor.se> References: <7EEBE8F9-9971-42B9-8F94-23E752104A10@gmail.com> <45C07EF6.1090502@kreditor.se> <45C09A8B.1000100@kreditor.se> Message-ID: <223AD462-FF3B-4AA8-B897-F162B7DBCCFA@gmail.com> On Jan 31, 2007, at 1:32 PM, Erik Stenman wrote: > Are you saying ejabberd has a performance problem? I'm saying that they went with expat instead of xmerl for performance reasons. It appears that performance mattered to them. According to you they shouldn't be using XML but it's part of the XMPP protocol specification :-). -- http://wagerlabs.com/ From bjorn@REDACTED Wed Jan 31 14:58:15 2007 From: bjorn@REDACTED (Bjorn Gustavsson) Date: 31 Jan 2007 14:58:15 +0100 Subject: [erlang-questions] Erlang/OTP R11B-3 has been released Message-ID: Bug fix release : otp_src_R11B-3 Build date : 2007-01-30 This is bug fix release 3 for the R11B release. You can download the full source distribution from http://www.erlang.org/download/otp_src_R11B-3.tar.gz http://www.erlang.org/download/otp_src_R11B-3.readme Note: To unpack the TAR archive you need a GNU TAR compatible program. For instance, on MacOS X before 10.3 you must use the 'gnutar' command; you can't use the 'tar' command or StuffIt to unpack the sources. For installation instructions please read the README that is part of the distribution. The Windows binary distribution can be downloaded from http://www.erlang.org/download/otp_win32_R11B-3.exe On-line documentation can be found at http://www.erlang.org/doc.html. You can also download the complete HTML documentation or the Unix manual files http://www.erlang.org/download/otp_doc_html_R11B-3.tar.gz http://www.erlang.org/download/otp_doc_man_R11B-3.tar.gz We also want to thank those that sent us patches, suggestions and bug reports, The OTP Team -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From luna@REDACTED Wed Jan 31 15:44:05 2007 From: luna@REDACTED (Daniel Luna) Date: Wed, 31 Jan 2007 15:44:05 +0100 (CET) Subject: [erlang-questions] Erlang/OTP R11B-3 has been released In-Reply-To: References: Message-ID: On Wed, 31 Jan 2007, Bjorn Gustavsson wrote: > Bug fix release : otp_src_R11B-3 And already the first bug report... make[2]: Entering directory `/home/luna/usr/src/otp_src_R11B-3/lib/dialyzer/src' Dialyzer will now build auxiliary information needed for subsequent analyses... A PLT for following libs will be built: [kernel,mnesia,stdlib] To select a different set please edit the file /home/luna/usr/src/otp_src_R11B-3/lib/dialyzer /home/luna/usr/src/otp_src_R11B-3/bin/dialyzer --check_init_plt Checking whether the initial PLT exists and is up-to-date... no Creating initial PLT (will take several minutes; please be patient) =ERROR REPORT==== 31-Jan-2007::15:37:42 === beam/beam_load.c(796): Error loading module dict: not a BEAM file: no IFF 'FOR1' chunk make[2]: *** [/home/luna/usr/src/otp_src_R11B-3/lib/dialyzer/plt/dialyzer_init_plt] Segmentation /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 thomasl_erlang@REDACTED Wed Jan 31 16:06:05 2007 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Wed, 31 Jan 2007 07:06:05 -0800 (PST) Subject: [erlang-questions] Erlang Extension Proposals (EEPs) In-Reply-To: <16250661.151170228866547.JavaMail.root@ly.sdf.com> Message-ID: <701122.65440.qm@web38804.mail.mud.yahoo.com> --- Tom Samplonius wrote: > > ----- "Thomas Lindgren" > wrote: > > Erlang: a popular programming language > > OTP: an Ericsson organization > > Erlang/OTP: the OTP implementation of Erlang (and > > more) > > But OTP is also a bunch of libraries that are > useful, not just an organization. I see that the > general impression is that the OTP code is complex, > but it does do something useful. That "OTP" would be "Erlang/OTP" in the terminology above. > Given how fractionalized that LISP has become > because each implementation has libraries that > perform the same function, but just work different > (ex. sockets do not work the same way), leading to > wrapper libraries that try to provide a generic > interface that works anywhere. It is a real mess, > marginalizing LISP to a prototyping language (ex. > http://reddit.com/ was re-written in Python from CMU > Lisp, because it was unstable, and sockets and > threads don't work the same way in all LISPs). (Perhaps the authors of Reddit simply were more comfortable with a scripting language like Python, and switched when they ran into problems? It didn't sound like it was a huge effort to port the application to a whole new _language_, after all.) Ironically, Common Lisp is FAR MORE standardized than Erlang. The problems of porting, e.g., Common Lisp do not appear in Erlang only because with Erlang there is nowhere to port. If there was a second source for Erlang, I would hands down expect future functionality to diverge, and probably the existing libraries too (as bug fixes are introduced, for example). Anyway, the issue of whether to require 100% compatibility with Erlang/OTP (later in your mail) is moot, since, as Kenneth has told us, EEPs are intended precisely for Erlang/OTP. Best, Thomas ____________________________________________________________________________________ Food fight? Enjoy some healthy debate in the Yahoo! Answers Food & Drink Q&A. http://answers.yahoo.com/dir/?link=list&sid=396545367 From lenartlad@REDACTED Wed Jan 31 16:20:23 2007 From: lenartlad@REDACTED (Ladislav Lenart) Date: Wed, 31 Jan 2007 16:20:23 +0100 Subject: [erlang-questions] gen_server cast question Message-ID: <45C0B3B7.1060706@volny.cz> Hello, I was browsing erlang (library) sources and found the following in gen_server module: do_send(Dest, Msg) -> case catch erlang:send(Dest, Msg, [noconnect]) of noconnect -> spawn(erlang, send, [Dest, Msg]); Other -> Other end. do_send is called for example from gen_server:cast/2. I know what the code above does, but don't understand how the following can work: gen_server:cast(Ref, msg1), gen_server:cast(Ref, msg2), gen_server:cast(Ref, msg3) Suppose that Ref points to a process which resides on the node that is not yet connected to the current node. When the first cast is evaluated, noconnect is returned and new process is spawned that sends the message msg1 to Ref. If the second cast is also evaluated before the connection to the node is established, second process is spawned that sends the message msg2 to Ref. I think that there is a possibility that Ref will not receive messages msg1, msg2 and msg3 in expected order because of the internal spawning. What am I missing here? Ladislav Lenart From Erik.Stenman@REDACTED Wed Jan 31 16:44:46 2007 From: Erik.Stenman@REDACTED (Erik Stenman) Date: Wed, 31 Jan 2007 16:44:46 +0100 Subject: [erlang-questions] xmerl still slow? In-Reply-To: <223AD462-FF3B-4AA8-B897-F162B7DBCCFA@gmail.com> References: <7EEBE8F9-9971-42B9-8F94-23E752104A10@gmail.com> <45C07EF6.1090502@kreditor.se> <45C09A8B.1000100@kreditor.se> <223AD462-FF3B-4AA8-B897-F162B7DBCCFA@gmail.com> Message-ID: <45C0B96E.5070403@kreditor.se> Joel Reymont wrote: > > On Jan 31, 2007, at 1:32 PM, Erik Stenman wrote: > >> Are you saying ejabberd has a performance problem? > > I'm saying that they went with expat instead of xmerl for performance > reasons. Are you sure? There are several reasons for going with expat instead of xmerl, I am not sure that performance is the reason ejabberd uses expat. More likely they wanted a finished fully implemented streaming xml-parser. But I have no insight into the development of ejabberd so I don't know. > It appears that performance mattered to them. According to you they > shouldn't be using XML but it's part of the XMPP protocol > specification :-). I still say that if parsing XML takes to much time then there is something wrong with your protocol. Too bad if the protocol is forced on you. My experience is that you very seldom have to worry about Erlang performance. Implement your application first. Then measure. Then use HiPE. Then worry. You probably don't even have to measure because the prototype is fast enough. /Erik From Martin.Logan@REDACTED Wed Jan 31 17:20:33 2007 From: Martin.Logan@REDACTED (Logan, Martin) Date: Wed, 31 Jan 2007 10:20:33 -0600 Subject: [erlang-questions] gen_server cast question In-Reply-To: <45C0B3B7.1060706@volny.cz> References: <45C0B3B7.1060706@volny.cz> Message-ID: <26AB42AB6A76E2419D26E66ECF1538468B369A@chiresexc02.resource.corp.lcl> -----Original Message----- From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Ladislav Lenart Sent: Wednesday, January 31, 2007 9:20 AM To: Erlang-Questions (E-mail) Subject: [erlang-questions] gen_server cast question Hello, I was browsing erlang (library) sources and found the following in gen_server module: do_send(Dest, Msg) -> case catch erlang:send(Dest, Msg, [noconnect]) of noconnect -> spawn(erlang, send, [Dest, Msg]); Other -> Other end. do_send is called for example from gen_server:cast/2. I know what the code above does, but don't understand how the following can work: gen_server:cast(Ref, msg1), gen_server:cast(Ref, msg2), gen_server:cast(Ref, msg3) Suppose that Ref points to a process which resides on the node that is not yet connected to the current node. When the first cast is evaluated, noconnect is returned and new process is spawned that sends the message msg1 to Ref. If the second cast is also evaluated before the connection to the node is established, second process is spawned that sends the message msg2 to Ref. I think that there is a possibility that Ref will not receive messages msg1, msg2 and msg3 in expected order because of the internal spawning. ------------ Message order is not guaranteed with asynchronous messaging in any case. You should never rely on it. Also, as an aside, it would be strange to have a reference to a process for a node that is not connected, that suggests poor design. _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions From yarivvv@REDACTED Wed Jan 31 17:24:41 2007 From: yarivvv@REDACTED (Yariv Sadan) Date: Wed, 31 Jan 2007 11:24:41 -0500 Subject: [erlang-questions] xmerl still slow? In-Reply-To: <7EEBE8F9-9971-42B9-8F94-23E752104A10@gmail.com> References: <7EEBE8F9-9971-42B9-8F94-23E752104A10@gmail.com> Message-ID: <17244f480701310824k7bb75226i703e202c5c792039@mail.gmail.com> If you care so much about performance, use ErlTL. It compiles to .beam and you can even compile it with HiPE. You can't have a faster template language implementation. Yariv On 1/31/07, Joel Reymont wrote: > Folks, > > I stumbled upon a thread from '05 that mentions eXpat having 5 times > the performance of xmerl. > > Is xmerl still considered slow? Have there been any improvements over > the past couple of years? > > I like the template engine at http://dev.hyperstruct.net/seethrough/ > since it does not include any erlang code in the template itself. The > project uses xmerl, thus my asking. > > Thanks, Joel > > -- > http://wagerlabs.com/ > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From ulf@REDACTED Wed Jan 31 18:30:51 2007 From: ulf@REDACTED (Ulf Wiger) Date: Wed, 31 Jan 2007 18:30:51 +0100 Subject: [erlang-questions] gen_server cast question In-Reply-To: <26AB42AB6A76E2419D26E66ECF1538468B369A@chiresexc02.resource.corp.lcl> References: <45C0B3B7.1060706@volny.cz> <26AB42AB6A76E2419D26E66ECF1538468B369A@chiresexc02.resource.corp.lcl> Message-ID: Den 2007-01-31 17:20:33 skrev Logan, Martin : > Message order is not guaranteed with asynchronous messaging in any case. > You should never rely on it. Also, as an aside, it would be strange to > have a reference to a process for a node that is not connected, that > suggests poor design. In Barklund's formal semantics for Erlang (http://citeseer.ist.psu.edu/fredlund01framework.html) the following is stated: "The semantics communication (rule com) is such that if two consecutive messages m1 and m2 are sent by process p1 to process p2 then message m1 will always arrive before message m2." I'm not sure where else it is defined, but I'm pretty sure that you can rely on this being true. BR, Ulf W -- Ulf Wiger From lenartlad@REDACTED Wed Jan 31 18:46:32 2007 From: lenartlad@REDACTED (Ladislav Lenart) Date: Wed, 31 Jan 2007 18:46:32 +0100 Subject: [erlang-questions] gen_server cast question In-Reply-To: References: <45C0B3B7.1060706@volny.cz> <26AB42AB6A76E2419D26E66ECF1538468B369A@chiresexc02.resource.corp.lcl> Message-ID: <45C0D5F8.2070606@volny.cz> Ulf Wiger wrote: > Den 2007-01-31 17:20:33 skrev Logan, Martin : > >> Message order is not guaranteed with asynchronous messaging in any case. >> You should never rely on it. Also, as an aside, it would be strange to >> have a reference to a process for a node that is not connected, that >> suggests poor design. > > In Barklund's formal semantics for Erlang > (http://citeseer.ist.psu.edu/fredlund01framework.html) > > the following is stated: > > "The semantics communication (rule com) is such that if two consecutive > messages m1 and m2 are sent by process p1 to process > p2 then message m1 will always arrive before message m2." > > I'm not sure where else it is defined, but I'm pretty sure that you can > rely on this being true. I also think that the order is guaranteed (between two processes that is): [from Concurrent Programming in Erlang, page 69] Messages are always delivered to the recipient, and always in the same order they were sent. But then I think that presence of spawn in do_send breaks this "rule"... Ladislav Lenart From Martin.Logan@REDACTED Wed Jan 31 18:59:06 2007 From: Martin.Logan@REDACTED (Logan, Martin) Date: Wed, 31 Jan 2007 11:59:06 -0600 Subject: [erlang-questions] gen_server cast question In-Reply-To: <26AB42AB6A76E2419D26E66ECF1538468B369A@chiresexc02.resource.corp.lcl> References: <45C0B3B7.1060706@volny.cz> <26AB42AB6A76E2419D26E66ECF1538468B369A@chiresexc02.resource.corp.lcl> Message-ID: <26AB42AB6A76E2419D26E66ECF1538468B36A0@chiresexc02.resource.corp.lcl> Oops, as Ulf pointed out, for a single process message ordering is guaranteed. You should not rely on it for multiple processes. -----Original Message----- From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Logan, Martin Sent: Wednesday, January 31, 2007 10:21 AM To: Ladislav Lenart; Erlang-Questions (E-mail) Subject: Re: [erlang-questions] gen_server cast question -----Original Message----- From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Ladislav Lenart Sent: Wednesday, January 31, 2007 9:20 AM To: Erlang-Questions (E-mail) Subject: [erlang-questions] gen_server cast question Hello, I was browsing erlang (library) sources and found the following in gen_server module: do_send(Dest, Msg) -> case catch erlang:send(Dest, Msg, [noconnect]) of noconnect -> spawn(erlang, send, [Dest, Msg]); Other -> Other end. do_send is called for example from gen_server:cast/2. I know what the code above does, but don't understand how the following can work: gen_server:cast(Ref, msg1), gen_server:cast(Ref, msg2), gen_server:cast(Ref, msg3) Suppose that Ref points to a process which resides on the node that is not yet connected to the current node. When the first cast is evaluated, noconnect is returned and new process is spawned that sends the message msg1 to Ref. If the second cast is also evaluated before the connection to the node is established, second process is spawned that sends the message msg2 to Ref. I think that there is a possibility that Ref will not receive messages msg1, msg2 and msg3 in expected order because of the internal spawning. ------------ Message order is not guaranteed with asynchronous messaging in any case. You should never rely on it. Also, as an aside, it would be strange to have a reference to a process for a node that is not connected, that suggests poor design. _______________________________________________ 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 tom@REDACTED Wed Jan 31 21:23:56 2007 From: tom@REDACTED (Tom Samplonius) Date: Wed, 31 Jan 2007 12:23:56 -0800 (PST) Subject: [erlang-questions] Erlang Extension Proposals (EEPs) In-Reply-To: <701122.65440.qm@web38804.mail.mud.yahoo.com> Message-ID: <17265362.241170275036790.JavaMail.root@ly.sdf.com> ----- "Thomas Lindgren" wrote: ... > > Given how fractionalized that LISP has become > > because each implementation has libraries that > > perform the same function, but just work different > > (ex. sockets do not work the same way), leading to > > wrapper libraries that try to provide a generic > > interface that works anywhere. It is a real mess, > > marginalizing LISP to a prototyping language (ex. > > http://reddit.com/ was re-written in Python from CMU > > Lisp, because it was unstable, and sockets and > > threads don't work the same way in all LISPs). > > (Perhaps the authors of Reddit simply were more > comfortable with a scripting language like Python, and > switched when they ran into problems? It didn't sound > like it was a huge effort to port the application to a > whole new _language_, after all.) No. They were using CMUCL in production and CLISP in development. Sockets and threads don't work the same way between the CMUCL and CLISP implementations. And the production CMUCL environment would crash all the time. CL apps have to be married to a particularly implementation of CL. But those implementations don't run on every OS (or even most OSes), meaning that you are often tied to an OS too. Besides, Python isn't just a scripting language. It is partially interpreted, dynamic, so very similar to erlang in many ways. > Ironically, Common Lisp is FAR MORE standardized than > Erlang. The problems of porting, e.g., Common Lisp do > not appear in Erlang only because with Erlang there is > nowhere to port. If there was a second source for > Erlang, I would hands down expect future functionality > to diverge, and probably the existing libraries too > (as bug fixes are introduced, for example). I guess we have different ideas of what "standardization" means. Socket programming is a basic feature, and it doesn't work the same, everywhere in the CL world. I think we also have different ideas on what "port" means too. Erlang does not run on everything yet, so there is more porting of the environment to do. Now, given that there is only a single erlang implementation, application porting is mostly a non-issue. And it should be. Application "porting" isn't a problem worth fixing. If you have to change your code to run under a different implementation, it means the language implementation has failed. > Anyway, the issue of whether to require 100% > compatibility with Erlang/OTP (later in your mail) is > moot, since, as Kenneth has told us, EEPs are intended > precisely for Erlang/OTP. > > Best, > Thomas Tom From Erik.Stenman@REDACTED Wed Jan 31 21:45:10 2007 From: Erik.Stenman@REDACTED (Erik Stenman) Date: Wed, 31 Jan 2007 21:45:10 +0100 Subject: [erlang-questions] xmerl still slow? In-Reply-To: <3bb44c6e0701311151g33aa90dct27823a986272b47e@mail.gmail.com> References: <7EEBE8F9-9971-42B9-8F94-23E752104A10@gmail.com> <45C07EF6.1090502@kreditor.se> <3bb44c6e0701310503rd0333ads4b01922d70bfc375@mail.gmail.com> <45C09A4C.8040405@kreditor.se> <3bb44c6e0701311151g33aa90dct27823a986272b47e@mail.gmail.com> Message-ID: <45C0FFD6.9040709@kreditor.se> bryan rasmussen wrote: [...] > There must be a high end of how long it takes to parse something that > you consider acceptable, and it is highly likely that five times > longer than that high end is considered unacceptable. OK, I was too simplistic in my statement in order to make a point briefly and with a hint of humor. There are actually several problems with the original question and the subject of the thread: "xmerl still slow?". Joel worries that xmerl is slow based on an off-hand remark that Chandru made in January 2005: "Using expat is about 5 times faster than xmerl in our crude measurements." Based on this Joel asks: "Is xmerl still considered slow? Have there been any improvements over the past couple of years?" I got the impression he was setting out on a new project and started by looking for the fastest XML-parser. I tried to point out that this is the wrong question to ask by saying: "Show me an application where this performance difference matter, and I'll show you an application that shouldn't use XML." What I meant, but failed to mention was: 1. I don't consider xmerl slow. 2. I have no idea whether eXpat is 5 times faster or not. And I don't think anyone else has a clear idea either. 3. First write your application using the simplest methods available. (E.g. if you need xml in Erlang use xmerl in stead of a linked in driver.) Then worry about performance. You very seldom know the performance needs of your application, nor the performance of your implementation before you have written at least a prototype. 4. If xmerl is your performance bottleneck then you probably have bigger problems than choosing your xml-parser implementation. 5. I don't think XML is the right thing(tm). If you can avoid XML then do it, but don't forget point 3, "use the simplest methods available". If XML is the simplest method, then by all means use it. [...] > I suppose that we differ in that I think this difference will > come up quite a bit and you think it will only exist so few times as > to be negligible. Yes. My point is that this difference is something you should try to neglect. You should only worry about performance if you really really have to. If you *have* to worry about performance then you should probably first look at your protocol and your data representation, then at your implementation. And if you in the end find that xmerl is too slow, then you could try to improve the performance of xmerl, but apparently no one has felt the need to do that so far. /Erik From goertzen@REDACTED Wed Jan 31 21:45:53 2007 From: goertzen@REDACTED (Daniel Goertzen) Date: Wed, 31 Jan 2007 14:45:53 -0600 Subject: [erlang-questions] Erlang bindings for FUSE Message-ID: <45C10001.4000808@ertw.com> I am exploring the possibility of working on Erlang bindings for FUSE (http://fuse.sourceforge.net/) and before I get too far I'd like to ask if anyone knows of any work that may have already been done in this area. Thanks, Dan. From joelr1@REDACTED Wed Jan 31 22:14:31 2007 From: joelr1@REDACTED (Joel Reymont) Date: Wed, 31 Jan 2007 21:14:31 +0000 Subject: [erlang-questions] xmerl still slow? In-Reply-To: <17244f480701310824k7bb75226i703e202c5c792039@mail.gmail.com> References: <7EEBE8F9-9971-42B9-8F94-23E752104A10@gmail.com> <17244f480701310824k7bb75226i703e202c5c792039@mail.gmail.com> Message-ID: Yariv, On Jan 31, 2007, at 4:24 PM, Yariv Sadan wrote: > If you care so much about performance, use ErlTL. It compiles to .beam > and you can even compile it with HiPE. You can't have a faster > template language implementation. I very much appreciate your offer but I prefer to use Seethrough [1] since it does not require embedding Erlang code into the templates. I consider this approach a bit more elegant. Thanks, Joel [1] http://tinyurl.com/2mqp6v -- http://wagerlabs.com/ From toby@REDACTED Wed Jan 31 22:23:53 2007 From: toby@REDACTED (Toby Thain) Date: Wed, 31 Jan 2007 19:23:53 -0200 Subject: [erlang-questions] Erlang/OTP R11B-3 has been released In-Reply-To: References: Message-ID: On 31-Jan-07, at 11:58 AM, Bjorn Gustavsson wrote: > Bug fix release : otp_src_R11B-3 > Build date : 2007-01-30 > > This is bug fix release 3 for the R11B release. > You can download the full source distribution from > > http://www.erlang.org/download/otp_src_R11B-3.tar.gz > http://www.erlang.org/download/otp_src_R11B-3.readme > > Note: To unpack the TAR archive you need a GNU TAR compatible > program. For instance, on MacOS X before 10.3 you must use the > 'gnutar' command ... Or on Solaris 10, /usr/sfw/bin/gtar --Toby > -- > Bj?rn Gustavsson, Erlang/OTP, Ericsson AB > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From rasmussen.bryan@REDACTED Wed Jan 31 22:22:33 2007 From: rasmussen.bryan@REDACTED (bryan rasmussen) Date: Wed, 31 Jan 2007 22:22:33 +0100 Subject: [erlang-questions] xmerl still slow? In-Reply-To: <45C0FFD6.9040709@kreditor.se> References: <7EEBE8F9-9971-42B9-8F94-23E752104A10@gmail.com> <45C07EF6.1090502@kreditor.se> <3bb44c6e0701310503rd0333ads4b01922d70bfc375@mail.gmail.com> <45C09A4C.8040405@kreditor.se> <3bb44c6e0701311151g33aa90dct27823a986272b47e@mail.gmail.com> <45C0FFD6.9040709@kreditor.se> Message-ID: <3bb44c6e0701311322v160a64e5n2fd1a751f574d8da@mail.gmail.com> > Joel worries that xmerl is slow based on an off-hand remark > that Chandru made in January 2005: > > I got the impression he was setting out on a new project and > started by looking for the fastest XML-parser. > I tried to point out that this is the wrong question to ask by saying: > "Show me an application where this performance difference matter, > and I'll show you an application that shouldn't use XML." > > What I meant, but failed to mention was: > > 3. First write your application using the simplest methods > available. ok, so I think we can agree that worrying at the start of a project about which xml parser to use due to performance reasons is something of a premature optimization, but I would suppose not completely when the choice is between a processor native to the implementation language/framework and a non-native one. anyway sorry to have misunderstood. I just thought it didn't make any sense. Cheers, Bryan Rasmussen From mattias.wadman@REDACTED Wed Jan 31 22:56:48 2007 From: mattias.wadman@REDACTED (Mattias Wadman) Date: Wed, 31 Jan 2007 22:56:48 +0100 Subject: [erlang-questions] Erlang bindings for FUSE In-Reply-To: <45C10001.4000808@ertw.com> References: <45C10001.4000808@ertw.com> Message-ID: <45C110A0.3010507@galaxen.se> Daniel Goertzen wrote: > I am exploring the possibility of working on Erlang bindings for FUSE > (http://fuse.sourceforge.net/) and before I get too far I'd like to ask > if anyone knows of any work that may have already been done in this area. Im been experimenting with fuse binding for erlang for some time, have done some progress but it goes quite slowly, its done on my free time. Current status is that i have a quite working port driver (running as a separate process) for talking to the fuse kernel module, decode/encode of the protocol, various help modules for dealing with errnos (to map errno atoms to numbers) etc. Just starting to think about/write the equivalent of fuse_lowlevel.c and fuse.c. My approach is to use libfuse only for mounting and get a open fd to the fuse device and then do all communication directly from erlang. The libfuse highlevel API (which most other bindings uses) is either non-concurrent or uses posix threads for concurrency, which i think would be bad. I have no public source repository yet, so just ask and i will send you (or anyone else interested?) a snapshot. -Mattias From cyberlync@REDACTED Wed Jan 31 23:21:51 2007 From: cyberlync@REDACTED (Eric Merritt) Date: Wed, 31 Jan 2007 14:21:51 -0800 Subject: [erlang-questions] Erlang Extension Proposals (EEPs) In-Reply-To: <45BE23DD.5090900@it.uu.se> References: <45BE23DD.5090900@it.uu.se> Message-ID: So this is a great idea and of huge benefit to the community. That being the case, how are we going to move this process forward? Who are the editors? Has that been decided? Has the eeps mailing list been set up? Has any one stepped up to handle the eep html conversion? Could we go with what you have already written for now? Has subversion space been made available? Who is going to maintain the infrastructure for eeps? These are questions, not answers, I know. However, maybe in answering these questions this process can move forward instead of bogging down in rather non-topical discussion as it has so far. On 1/29/07, Per Gustafsson wrote: > In conjunction with the Erlang User Conference 2006 there was a workshop > concerning the future development of Erlang. > > In this workshop a decision was made to adopt the Python process for > future Erlang development. Since nothing has happened since then I have > taken it upon myself to edit PEP 1, the python extension proposal which > describes how the python process works. This should be viewed as a draft > so please feel free to suggest changes. There are also a lot of decision > that needs to be made and issues that need to be solved. I'll list some > of them below. > > 1. We need to have some EEP editors > 2. We need an e-mail address for the EEP editors, I have suggested > eeps@REDACTED > 3. We need tools to generate html from EEPs. I have altered some of the > python tools to acheive this, but the resulting script is very brittle > and probably won't work for most EEPs > 4. We need a subversion repository to keep track of the EEPs > > The draft for EEP 1 can be found at: > > http://user.it.uu.se/~pergu/eep/eep-0001.html > > Per Gustafsson > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From rasmussen.bryan@REDACTED Wed Jan 31 20:51:51 2007 From: rasmussen.bryan@REDACTED (bryan rasmussen) Date: Wed, 31 Jan 2007 20:51:51 +0100 Subject: [erlang-questions] xmerl still slow? In-Reply-To: <45C09A4C.8040405@kreditor.se> References: <7EEBE8F9-9971-42B9-8F94-23E752104A10@gmail.com> <45C07EF6.1090502@kreditor.se> <3bb44c6e0701310503rd0333ads4b01922d70bfc375@mail.gmail.com> <45C09A4C.8040405@kreditor.se> Message-ID: <3bb44c6e0701311151g33aa90dct27823a986272b47e@mail.gmail.com> okay but I stand by my statement then, because if 5 seconds is wrong then if you are using xmerl and it takes 5 times longer than some other parser that takes only one second then it implies that one second of parsing is wrong as well, if we go by your original statement that a difference of five times being important implies that you shouldn't be using xml. you see, There must be a high end of how long it takes to parse something that you consider acceptable, and it is highly likely that five times longer than that high end is considered unacceptable. However if that is the case then there can be a situation where something is unacceptable with Xmerl and acceptable with another parser, I suppose that we differ in that I think this difference will come up quite a bit and you think it will only exist so few times as to be negligible. cheers, Bryan Rasmussen On 1/31/07, Erik Stenman wrote: > bryan rasmussen wrote: > > A performance difference of 5 times being irrelevant because if it is > > relevant then you shouldn't use XML? That hardly seem reasonable given > > that in most cases where XML is used in multiple user applications the > > difference between 5 seconds and 25 seconds is considered as being the > > difference between acceptable and not. > I stand by my statement. If you are spending 5s *parsing* XML then > you are using the wrong protocol (at least for an interactive application), > or a very old computer. > > /Erik > > > > Cheers, > > Bryan Rasmussen > > > > On 1/31/07, Erik Stenman wrote: > >> Joel Reymont wrote: > >> > Folks, > >> > > >> > I stumbled upon a thread from '05 that mentions eXpat having 5 times > >> > the performance of xmerl. > >> > > >> Show me an application where this performance difference matter, > >> and I'll show you an application that shouldn't use XML. > >> > >> /Erik > >> _______________________________________________ > >> 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 goertzen@REDACTED Wed Jan 31 23:45:53 2007 From: goertzen@REDACTED (Daniel Goertzen) Date: Wed, 31 Jan 2007 16:45:53 -0600 Subject: [erlang-questions] Erlang bindings for FUSE In-Reply-To: <45C110A0.3010507@galaxen.se> References: <45C10001.4000808@ertw.com> <45C110A0.3010507@galaxen.se> Message-ID: <45C11C21.8070608@ertw.com> Good thing I asked! I would very much like to see what you've got. I concur with your decision to drop the high level libfuse API. Regards, Dan. Mattias Wadman wrote: > Daniel Goertzen wrote: >> I am exploring the possibility of working on Erlang bindings for FUSE >> (http://fuse.sourceforge.net/) and before I get too far I'd like to >> ask if anyone knows of any work that may have already been done in >> this area. > > Im been experimenting with fuse binding for erlang for some time, have > done some progress but it goes quite slowly, its done on my free time. > > Current status is that i have a quite working port driver (running as > a separate process) for talking to the fuse kernel module, > decode/encode of the protocol, various help modules for dealing with > errnos (to map errno atoms to numbers) etc. > Just starting to think about/write the equivalent of fuse_lowlevel.c > and fuse.c. > > My approach is to use libfuse only for mounting and get a open fd to > the fuse device and then do all communication directly from erlang. > The libfuse highlevel API (which most other bindings uses) is either > non-concurrent or uses posix threads for concurrency, which i think > would be bad. > > I have no public source repository yet, so just ask and i will send > you (or anyone else interested?) a snapshot. > > -Mattias > >