From andrew@REDACTED Sat Nov 1 00:03:05 2008 From: andrew@REDACTED (Andrew Thompson) Date: Fri, 31 Oct 2008 19:03:05 -0400 Subject: [erlang-questions] Detecting connection from a node using an invalid cookie with ei_connect Message-ID: <20081031230304.GF27095@hijacked.us> I've been playing with the ei library for the last few days and I've managed to use it to put together a threaded c node where the ei_accept is in the main thread and each node that connects has its messages processed in a new thread. This all worked fine until I accidentally connected from a node where the cookie was set wrong. Doing this makes ei_accept return -1 (ERL_ERROR) and set erl_errno to EIO. From what I can see, there's no way to distinguish a socket error from a node version mismatch or a cookie challenge failure. It seems like the easiest way would be to add some more error constants to ei.h like ERL_BADCOOKIE and ERL_BADVERSION and return those in the cases that ei_accept fails due to non timeout/IO reasons. Of course, any better suggestions are welcome. I'm not too eager to make my code dependant on a locally patched version of ei. erl_errno only seems to ever be set to POSIX error codes, so changing what that's set to looks to be a no-no. Also, I noticed that erl_errno doesn't work (fails with undefined reference to __erl_errno) on FreeBSD 6.3 unless I use the compiler flag -D_REENTRANT. I saw a couple similar error reports when googling, but no resolution. Andrew From klacke@REDACTED Sat Nov 1 00:59:37 2008 From: klacke@REDACTED (=?ISO-8859-1?Q?Claes_Wikstr=F6m?=) Date: Sat, 01 Nov 2008 00:59:37 +0100 Subject: [erlang-questions] erlang version Message-ID: <490B9BE9.5000708@hyber.org> Isn't it high time to replace the weird version string in the shell that says: Eshell V5.6.1 (abort with ^G) with the appropriate OTP version number. The 5.6.1 number doesn't convey a lot of info - does it. Be brave - change. Also, and worse, how do I find out which OTP version I'm actually running. 1> erlang:system_info(version). "5.6.1" 2> erlang:system_info(otp_release). "R12B" 3> Crucial info missing there. R12B what? Enlighten me please. So, two things that need to be fixed: 1. Shell prompt 2. Last number in OTP release number is not possible to find out /klacke From rvirding@REDACTED Sat Nov 1 03:02:50 2008 From: rvirding@REDACTED (Robert Virding) Date: Sat, 1 Nov 2008 03:02:50 +0100 Subject: [erlang-questions] Constraint satisfaction problems In-Reply-To: <3BE6DBA1F3BE9D4798255806113D56540F7FB8AA87@utx-exchange.utx.local> References: <3BE6DBA1F3BE9D4798255806113D56540F7FB8AA87@utx-exchange.utx.local> Message-ID: <3dbc6d1c0810311902s6165af50ha80dcf1c85ea54a1@mail.gmail.com> 2008/10/31 Imre Palik > During playing with project Euler I solved a few constraint satisfaction > problems with erlang. But whenever I code a solution, I have a really > awkward feeling, that it should be possible to do better, but I don't know > how. > > I tend to code a backtracking search with constraint propagation before > every step. I model the constraint graph with digraph, but then the > non-functional nature of the digraph package makes backtracking really > awkward. > > Is there any better way to solve constraint satisfaction problems? > What is the rationale behind those pesky side effects in digraph? I don't think is there is a deeper rationale behind the side effects in digraph other than that they are a result of it using ets internally. One solution would be to rewrite it, or at least a part of it, using dict or gb_trees but that might be overkill for what you want to do. Depends, I suppose, on how much functionality you need. What type of constraints are they? If your backtracking search algorithm is more suitable for prolog you could try erlog which is a prolog interpreter written in erlang. Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: From pguyot@REDACTED Sat Nov 1 09:02:23 2008 From: pguyot@REDACTED (Paul Guyot) Date: Sat, 1 Nov 2008 09:02:23 +0100 Subject: [erlang-questions] parse_transform and error messages In-Reply-To: <349ebab60810311049w736c9b5dha967e559db026a9c@mail.gmail.com> References: <81459DF7-80C7-49D1-80E1-2A8E9E5D1EEA@kallisys.net> <349ebab60810311049w736c9b5dha967e559db026a9c@mail.gmail.com> Message-ID: Le 31 oct. 08 ? 18:49, denis a ?crit : > You can do it by adding the term > {error, {Line, Module, Msg::io_list()}} > into the AST. > > You can generate an error in a module, and look at the generated AST > to have an example. Thank you! It is exactly what I was looking for, and it provides a nicer interface to our compile-time checks. Paul From jawadhussain619@REDACTED Sat Nov 1 08:38:03 2008 From: jawadhussain619@REDACTED (Jawad Hussain) Date: Sat, 1 Nov 2008 00:38:03 -0700 (PDT) Subject: [erlang-questions] Digest problem Message-ID: <607844.98331.qm@web32006.mail.mud.yahoo.com> hi i accidently clicked on option of digest please let me know how to undo it it is fillin my inbox like nythin best regards Jawad Hussain -------------- next part -------------- An HTML attachment was scrubbed... URL: From kevin@REDACTED Sat Nov 1 15:01:33 2008 From: kevin@REDACTED (Kevin A. Smith) Date: Sat, 1 Nov 2008 10:01:33 -0400 Subject: [erlang-questions] erlang version In-Reply-To: <490B9BE9.5000708@hyber.org> References: <490B9BE9.5000708@hyber.org> Message-ID: <87DBDA2E-84A7-4DDB-85D6-2BF0D797C363@hypotheticalabs.com> +1 I spend a good deal of time troubleshooting problems with our Erlang software at work. The current version reporting scheme makes it difficult to verify which OTP release (R11B, R12B-3, etc) is installed. "Unifying" the versions reported would definitely make my life easier. --Kevin On Oct 31, 2008, at 7:59 PM, Claes Wikstr?m wrote: > > Isn't it high time to replace the weird version string > in the shell that says: > > Eshell V5.6.1 (abort with ^G) > > with the appropriate OTP version number. The 5.6.1 number doesn't > convey a lot of info - does it. Be brave - change. > > > Also, and worse, how do I find out which OTP version I'm > actually running. > > 1> erlang:system_info(version). > "5.6.1" > 2> erlang:system_info(otp_release). > "R12B" > 3> > > > Crucial info missing there. R12B what? Enlighten me please. > > So, two things that need to be fixed: > > 1. Shell prompt > 2. Last number in OTP release number is not possible to find out > > > /klacke > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From kostis@REDACTED Sat Nov 1 15:05:55 2008 From: kostis@REDACTED (Kostis Sagonas) Date: Sat, 01 Nov 2008 16:05:55 +0200 Subject: [erlang-questions] HiPE code from i386 linux portable to amd64 linux? In-Reply-To: <18699.20096.786338.864783@harpo.it.uu.se> References: <24d4f39c0810310838h5bfc68e5yeedf855d6017b6a0@mail.gmail.com> <18699.20096.786338.864783@harpo.it.uu.se> Message-ID: <490C6243.5050001@cs.ntua.gr> Mikael Pettersson wrote: > > Is there any way to tell if a given beam contains > > native code that is incompatible.on a given erlang? > > Not in any easy-to-use way no. You currently have to load the > module and observe any warnings, and observe if it executes > in native or interpreted mode. The latter you can do by calling > hipe_bifs:in_native/0 and checking its boolean return value. It's indeed a bit unfortunate that one has to load the file to see whether it contains native code for the given architecture or not, but there is a better way to see whether a file contains native code or not. 1> code:is_module_native(foo). undefined 2> c(foo). {ok,foo} 3> code:is_module_native(foo). false 4> c(foo, [native]). {ok,foo} 5> code:is_module_native(foo). true Kostis From erlang-questions_efine@REDACTED Sat Nov 1 19:26:16 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Sat, 1 Nov 2008 14:26:16 -0400 Subject: [erlang-questions] erlang version In-Reply-To: <490B9BE9.5000708@hyber.org> References: <490B9BE9.5000708@hyber.org> Message-ID: <6c2563b20811011126xab7c413u1681d92d71e7eb0a@mail.gmail.com> Klacke, It would be nice to have that information obtainable all on one place, and displayed on the shell prompt, too. I am sure that I am stating the obvious here, but I'll do it anyway. I am just guessing, but I see a correlation between the last digit of the erts version (e.g. 5.6.1 -> 1) and the actual release. When I used R12B-3, erts was 5.6.3. Now I am using R12B-4, and erts is 5.6.4. So I suppose a reasonable way (that is not provably correct until told otherwise) to get the release string would be 4> erlang:system_info(otp_release) ++ "-" ++ hd(lists:reverse(string:tokens(erlang:system_info(version), "."))). "R12B-4" On the other hand, I agree that Erlang really should provide a way to get the point release, or complete otp_release including point release, without having to grovel around in the version string Regards, Edwin On Fri, Oct 31, 2008 at 7:59 PM, Claes Wikstr?m wrote: > > Isn't it high time to replace the weird version string > in the shell that says: > > Eshell V5.6.1 (abort with ^G) > > with the appropriate OTP version number. The 5.6.1 number doesn't > convey a lot of info - does it. Be brave - change. > > > Also, and worse, how do I find out which OTP version I'm > actually running. > > 1> erlang:system_info(version). > "5.6.1" > 2> erlang:system_info(otp_release). > "R12B" > 3> > > > Crucial info missing there. R12B what? Enlighten me please. > > So, two things that need to be fixed: > > 1. Shell prompt > 2. Last number in OTP release number is not possible to find out > > > /klacke > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From joelr1@REDACTED Sun Nov 2 00:52:46 2008 From: joelr1@REDACTED (Joel Reymont) Date: Sat, 1 Nov 2008 23:52:46 +0000 Subject: [erlang-questions] scanning the process list every few seconds Message-ID: Is it feasible to scan the process list every few seconds to grab the process info? I'm thinking 30-50K processes. Has anyone done this before? I'm trying to identify the bottleneck in my poker server and I can't think of any other approach. Thanks, Joel -- wagerlabs.com From ulf@REDACTED Sun Nov 2 08:24:21 2008 From: ulf@REDACTED (Ulf Wiger) Date: Sun, 2 Nov 2008 08:24:21 +0100 Subject: [erlang-questions] scanning the process list every few seconds In-Reply-To: References: Message-ID: <8209f740811020024j23c3ce42v7dc4cdd3c99a495@mail.gmail.com> What information are you after? With any luck, you can get the information you need without polling all processes, using erlang:system_monitor/2: http://www.erlang.org/doc/man/erlang.html#erlang:system_monitor-2 BR, Ulf W 2008/11/2 Joel Reymont : > Is it feasible to scan the process list every few seconds to grab the > process info? I'm thinking 30-50K processes. > > Has anyone done this before? > > I'm trying to identify the bottleneck in my poker server and I can't > think of any other approach. > > Thanks, Joel > > -- > wagerlabs.com > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From ulf@REDACTED Sun Nov 2 08:45:48 2008 From: ulf@REDACTED (Ulf Wiger) Date: Sun, 2 Nov 2008 08:45:48 +0100 Subject: [erlang-questions] HiPE code from i386 linux portable to amd64 linux? In-Reply-To: <24d4f39c0810310838h5bfc68e5yeedf855d6017b6a0@mail.gmail.com> References: <24d4f39c0810310838h5bfc68e5yeedf855d6017b6a0@mail.gmail.com> Message-ID: <8209f740811020045h5f0954ak27c3284b5de2102b@mail.gmail.com> 2008/10/31 Colm Dougan : > > Is there any way to tell if a given beam contains > native code that is incompatible.on a given erlang? How about this: Eshell V5.6.4 (abort with ^G) 1> beam_lib:chunks("test.beam",[hipe_unified_loader:chunk_name(erlang:system_info(hipe_architecture))]). {ok,{test,[{"HX86", <<131,108,0,0,0,11,104,2,107,0,5,51,46,54,46,56,98,0, 213,156,37,97,...>>}]}} Wholly undocumented, of course. (: BR, Ulf W From vlm@REDACTED Sun Nov 2 09:16:31 2008 From: vlm@REDACTED (Lev Walkin) Date: Sun, 02 Nov 2008 01:16:31 -0700 Subject: [erlang-questions] scanning the process list every few seconds In-Reply-To: <8209f740811020024j23c3ce42v7dc4cdd3c99a495@mail.gmail.com> References: <8209f740811020024j23c3ce42v7dc4cdd3c99a495@mail.gmail.com> Message-ID: <490D61DF.5090504@lionet.info> Ulf, how about suggesting your own "Extended Process Registry for Erlang" as a supplementary material? Isn't it any good? How relevant do you consider it is now? http://www.erlang.se/workshop/2007/proceedings/02wiger.pdf Ulf Wiger wrote: > What information are you after? > > With any luck, you can get the information you need without polling > all processes, using erlang:system_monitor/2: > > http://www.erlang.org/doc/man/erlang.html#erlang:system_monitor-2 > > BR, > Ulf W > > 2008/11/2 Joel Reymont : >> Is it feasible to scan the process list every few seconds to grab the >> process info? I'm thinking 30-50K processes. >> >> Has anyone done this before? >> >> I'm trying to identify the bottleneck in my poker server and I can't >> think of any other approach. >> >> Thanks, Joel >> >> -- >> wagerlabs.com >> >> >> >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From ulf@REDACTED Sun Nov 2 09:33:06 2008 From: ulf@REDACTED (Ulf Wiger) Date: Sun, 2 Nov 2008 09:33:06 +0100 Subject: [erlang-questions] scanning the process list every few seconds In-Reply-To: <490D61DF.5090504@lionet.info> References: <8209f740811020024j23c3ce42v7dc4cdd3c99a495@mail.gmail.com> <490D61DF.5090504@lionet.info> Message-ID: <8209f740811020133t30a5480by28d0bc92077b70e7@mail.gmail.com> 2008/11/2 Lev Walkin : > > Ulf, how about suggesting your own "Extended Process Registry for Erlang" as > a supplementary material? Isn't it any good? How relevant do you consider it > is now? I got the impression that Joel wants to keep track of dynamic characteristics, such as heap size, message queue length, etc., and I don't think the extended process registry will be of much help in that case. BR, Ulf W From joelr1@REDACTED Sun Nov 2 10:05:32 2008 From: joelr1@REDACTED (Joel Reymont) Date: Sun, 2 Nov 2008 09:05:32 +0000 Subject: [erlang-questions] scanning the process list every few seconds In-Reply-To: <8209f740811020133t30a5480by28d0bc92077b70e7@mail.gmail.com> References: <8209f740811020024j23c3ce42v7dc4cdd3c99a495@mail.gmail.com> <490D61DF.5090504@lionet.info> <8209f740811020133t30a5480by28d0bc92077b70e7@mail.gmail.com> Message-ID: <088244E8-233E-4FE8-8B03-A21DD1EB2BE6@gmail.com> On Nov 2, 2008, at 8:33 AM, Ulf Wiger wrote: > I got the impression that Joel wants to keep track of dynamic > characteristics, such as heap size, message queue length, etc., That's exactly what I'm after. How do people do this? How is this done on the big Ericsson projects? Also, what's a "busy port" in erlang:monitor parlance? Last but not least, I wish there was a way to keep track of message queue length using erlang:monitor. In my particular case, I get "player timeouts" under a certain load. This happens because a message from a player does not get to the game before a timer expires. I'm trying to answer a simple question: why does it happen? -- wagerlabs.com From ulf@REDACTED Sun Nov 2 10:18:28 2008 From: ulf@REDACTED (Ulf Wiger) Date: Sun, 2 Nov 2008 10:18:28 +0100 Subject: [erlang-questions] scanning the process list every few seconds In-Reply-To: <088244E8-233E-4FE8-8B03-A21DD1EB2BE6@gmail.com> References: <8209f740811020024j23c3ce42v7dc4cdd3c99a495@mail.gmail.com> <490D61DF.5090504@lionet.info> <8209f740811020133t30a5480by28d0bc92077b70e7@mail.gmail.com> <088244E8-233E-4FE8-8B03-A21DD1EB2BE6@gmail.com> Message-ID: <8209f740811020118j61b1b7fclc109a2433d8bc841@mail.gmail.com> 2008/11/2 Joel Reymont : > > On Nov 2, 2008, at 8:33 AM, Ulf Wiger wrote: > >> I got the impression that Joel wants to keep track of dynamic >> characteristics, such as heap size, message queue length, etc., > > That's exactly what I'm after. How do people do this? How is this done on > the big Ericsson projects? Well, erlang:system_monitor() can help, if you tell it to monitor heap size, since the message queue is on the heap. I also wish there'd be an option to warn if there are too many messages in the queue. I have an experimental version of plain_fsm that might help: http://www.erlang.org/pipermail/erlang-questions/2008-June/035568.html BR, Ulf W From freza@REDACTED Sun Nov 2 12:50:48 2008 From: freza@REDACTED (Jachym Holecek) Date: Sun, 2 Nov 2008 12:50:48 +0100 Subject: [erlang-questions] scanning the process list every few seconds In-Reply-To: <088244E8-233E-4FE8-8B03-A21DD1EB2BE6@gmail.com> References: <8209f740811020024j23c3ce42v7dc4cdd3c99a495@mail.gmail.com> <490D61DF.5090504@lionet.info> <8209f740811020133t30a5480by28d0bc92077b70e7@mail.gmail.com> <088244E8-233E-4FE8-8B03-A21DD1EB2BE6@gmail.com> Message-ID: <20081102115048.GA4673@hanele> # Joel Reymont 2008-11-02: > On Nov 2, 2008, at 8:33 AM, Ulf Wiger wrote: > > I got the impression that Joel wants to keep track of dynamic > > characteristics, such as heap size, message queue length, etc., > > That's exactly what I'm after. How do people do this? We used erlang:trace/3 (see 'garbage_collection' option) to track process memory usage, it provides fairly detailed information. But I suspect you don't want that enabled for thousands of processes at a time. -- Jachym From joelr1@REDACTED Sun Nov 2 18:23:31 2008 From: joelr1@REDACTED (Joel Reymont) Date: Sun, 2 Nov 2008 17:23:31 +0000 Subject: [erlang-questions] is there an elephant in the room? mnesia network partition Message-ID: I'm looking to launch a poker 'social network', the first and only one where you can actually play poker. I'm hesitant to go full-way with Mnesia, though, and wonder how others are handling this. I googled and poked around but there seems to be an elephant in the room and no one is talking about it. The elephant is that Mnesia does not self-heal after network splits. Could it be that this is a solved problem or has anyone avoided it because their data model does not require self-healing? How do big projects deal with it? Ericsson? I would like to run a few Mnesia nodes for high availability but it positively don't want my databases to diverge and I don't want to deal with reconciling the databases later. Strictly speaking, I could keep mnesia as a transient data store and keep my master database in a non-Erlang database. I just thought I'd poll the community regardless. Thanks, Joel -- wagerlabs.com From joelr1@REDACTED Sun Nov 2 18:50:21 2008 From: joelr1@REDACTED (Joel Reymont) Date: Sun, 2 Nov 2008 17:50:21 +0000 Subject: [erlang-questions] poll: monitoring performance of production erlang nodes Message-ID: <7A654DC2-5B72-4AC7-9D97-F980DD5ADA74@gmail.com> Forgive me for polling the community one last time... How do you folks with production Erlang systems monitor performance? I want to measure packet roundtrip to clients, memory use throughout the day, message queue lengths, etc. I have timings inserted in key places and a "statistics" server that collects the measurements in ETS. I can then ask for a data dump as CSV and analyze the data in a spreadsheet app or otherwise. How do YOU do it? Thanks, Joel -- wagerlabs.com From pfisher@REDACTED Sun Nov 2 19:02:09 2008 From: pfisher@REDACTED (Paul Fisher) Date: Sun, 02 Nov 2008 12:02:09 -0600 Subject: [erlang-questions] poll: monitoring performance of production erlang nodes In-Reply-To: <7A654DC2-5B72-4AC7-9D97-F980DD5ADA74@gmail.com> References: <7A654DC2-5B72-4AC7-9D97-F980DD5ADA74@gmail.com> Message-ID: <490DEB21.1000903@alertlogic.net> Joel Reymont wrote: > Forgive me for polling the community one last time... > > How do you folks with production Erlang systems monitor performance? > > I want to measure packet roundtrip to clients, memory use throughout > the day, message queue lengths, etc. > > I have timings inserted in key places and a "statistics" server that > collects the measurements in ETS. I can then ask for a data dump as > CSV and analyze the data in a spreadsheet app or otherwise. > > How do YOU do it? Statistics server/interface module that publishes the accumulated statistics on 5 minute intervals into log messages. We then persist and analyze these over time in an offline process. -- paul From gleber.p@REDACTED Sun Nov 2 19:03:56 2008 From: gleber.p@REDACTED (Gleb Peregud) Date: Sun, 2 Nov 2008 19:03:56 +0100 Subject: [erlang-questions] poll: monitoring performance of production erlang nodes In-Reply-To: <7A654DC2-5B72-4AC7-9D97-F980DD5ADA74@gmail.com> References: <7A654DC2-5B72-4AC7-9D97-F980DD5ADA74@gmail.com> Message-ID: <14f0e3620811021003y7adc18iddb73612d349a5d2@mail.gmail.com> I have a HTTP server started at every node which answers to "GET /stats" with something like "queue_length: 100 memory: 80" which is fetched by Cacti ever minute. Then Cacti draws nice graphs of it. Simple and works, though don't know if it is scalable :) On 11/2/08, Joel Reymont wrote: > Forgive me for polling the community one last time... > > How do you folks with production Erlang systems monitor performance? > > I want to measure packet roundtrip to clients, memory use throughout > the day, message queue lengths, etc. > > I have timings inserted in key places and a "statistics" server that > collects the measurements in ETS. I can then ask for a data dump as > CSV and analyze the data in a spreadsheet app or otherwise. > > How do YOU do it? > > Thanks, Joel > > -- > wagerlabs.com > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- Gleb Peregud http://gleber.pl/ Every minute is to be grasped. Time waits for nobody. -- Inscription on a Zen Gong From mickael.remond@REDACTED Sun Nov 2 19:38:52 2008 From: mickael.remond@REDACTED (=?utf-8?Q?Micka=C3=ABl_R=C3=A9mond?=) Date: Sun, 2 Nov 2008 19:38:52 +0100 Subject: [erlang-questions] poll: monitoring performance of production erlang nodes In-Reply-To: <7A654DC2-5B72-4AC7-9D97-F980DD5ADA74@gmail.com> References: <7A654DC2-5B72-4AC7-9D97-F980DD5ADA74@gmail.com> Message-ID: <558B65C8-5DC9-4062-ACE7-7A818F8A5705@process-one.net> Hello, We have written our own supervision and monitoring tool for ejabberd that abstract all the Internal Erlang gory details. We can then set up alerts on the monitored values (currently more than 250 different values including Erlang and XMPP ones) Some value are easy to track from the Erlang monitor API. For other, like message queue length as Ulf said it, you have to write your own custom code. -- Mickael Remond http://www.process-one.net/ Le 2 nov. 08 ? 18:50, Joel Reymont a ?crit : > Forgive me for polling the community one last time... > > How do you folks with production Erlang systems monitor performance? > > I want to measure packet roundtrip to clients, memory use throughout > the day, message queue lengths, etc. > > I have timings inserted in key places and a "statistics" server that > collects the measurements in ETS. I can then ask for a data dump as > CSV and analyze the data in a spreadsheet app or otherwise. > > How do YOU do it? > > Thanks, Joel > > -- > wagerlabs.com > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From ulf@REDACTED Sun Nov 2 20:55:48 2008 From: ulf@REDACTED (Ulf Wiger) Date: Sun, 2 Nov 2008 20:55:48 +0100 Subject: [erlang-questions] is there an elephant in the room? mnesia network partition In-Reply-To: References: Message-ID: <8209f740811021155l7675a558yb3a611f3ce457a3@mail.gmail.com> AFAIK, no general algorithm exists for self-healing after network splits. MySQL Cluster (NDB) e.g. solves it by requiring at least 3 copies of the data, and one arbitrator. In the case of a network split, you may continue if you can speak to the arbitrator; otherwise you're shut down. Mnesia provides the tools for resolving the situation, and one way to protect yourself from accidental inconsistencies is to use net_kernel dist_auto_connect_once, and keep a back door between the nodes (this has been discussed several times on this list.) Once you've determined that you have a split network, and which copies you want to continue with, you can restart the other nodes, possibly using mnesia:set_master_nodes/1 to make absolutely sure that they load their data from the right nodes. Setting this up is not terribly difficult. Interfacing to another DBMS is likely to be much more work, and you'd have to make really sure that they have a better strategy for coping with network splits than mnesia - I'm not at all sure that they do (but I'm willing to repent in the face of hard evidence). The lack of automatic handling of network splits has been mentioned a number of times as an argument against mnesia, but I really don't recall hearing much about how other DBMSs deal with it. There seems to be an assumption that since there isn't much discussion about network splits for other DBMSs, they must simply solve it transparently. I think this is a dangerous conclusion. BR, Ulf W 2008/11/2 Joel Reymont : > I'm looking to launch a poker 'social network', the first and only one > where you can actually play poker. I'm hesitant to go full-way with > Mnesia, though, and wonder how others are handling this. > > I googled and poked around but there seems to be an elephant in the > room and no one is talking about it. The elephant is that Mnesia does > not self-heal after network splits. > > Could it be that this is a solved problem or has anyone avoided it > because their data model does not require self-healing? How do big > projects deal with it? Ericsson? > > I would like to run a few Mnesia nodes for high availability but it > positively don't want my databases to diverge and I don't want to deal > with reconciling the databases later. > > Strictly speaking, I could keep mnesia as a transient data store and > keep my master database in a non-Erlang database. I just thought I'd > poll the community regardless. > > Thanks, Joel > > -- > wagerlabs.com > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From paul-trapexit@REDACTED Sun Nov 2 22:18:56 2008 From: paul-trapexit@REDACTED (Paul Mineiro) Date: Sun, 2 Nov 2008 13:18:56 -0800 (PST) Subject: [erlang-questions] poll: monitoring performance of production erlang nodes In-Reply-To: <7A654DC2-5B72-4AC7-9D97-F980DD5ADA74@gmail.com> References: <7A654DC2-5B72-4AC7-9D97-F980DD5ADA74@gmail.com> Message-ID: We have a statistics server that runs on all nodes and collects statistics associated with a key; the key space is automatically partitioned between the servers so that when we add more nodes the load is split. Associated with each key is an rrd file and we have a erlang port for rrdtool to write the data; the rrds are updated peridocially (e.g. every minute). Finally we use yaws cgi to access drraw which is a web graphical interface for rrdtool; we use a distributed filesystem so that any node can read any of the rrd files (basically, the access pattern is many readers one writer, with the servers negotiating who owns a particular key and thus rrd file; we wrote our own simple distributed filesystem in erlang because we're on EC2 and wanted some operational simplicity in the face of dynamic node membership; but in a normal fixed-set-of-servers setup there are lots of choices for the DFS bit). When we want to know about something, we sprinkle calls in the code that emit a statistic with a key; when new keys are encountered, new rrd files are created. It mostly works great. The one problem I have with the setup is that we end up having to litter the code with statistics collection calls; this can clutter the exposition. With language support, one could envision an aspect-oriented approach to statistics collection which would not clutter the code, similar to how traces work. (We could use traces now to collect timing statistics if we were willing to make intermediate functions for code regions of interest). Another possibility would be to define a parse_transform which inserts the statistics collection calls, keeping the code clean. However code maintenance is potentially complexified. In the end we are lazy so we live with it. I would love to see more language support for monitoring. Erlang is already very operationally oriented and this seems like an area where everybody is rolling their own and we could all benefit from a common approach. -- p On Sun, 2 Nov 2008, Joel Reymont wrote: > Forgive me for polling the community one last time... > > How do you folks with production Erlang systems monitor performance? > > I want to measure packet roundtrip to clients, memory use throughout > the day, message queue lengths, etc. > > I have timings inserted in key places and a "statistics" server that > collects the measurements in ETS. I can then ask for a data dump as > CSV and analyze the data in a spreadsheet app or otherwise. > > How do YOU do it? > > Thanks, Joel > > -- > wagerlabs.com > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > In an artificial world, only extremists live naturally. -- Paul Graham From joelr1@REDACTED Sun Nov 2 22:59:12 2008 From: joelr1@REDACTED (Joel Reymont) Date: Sun, 2 Nov 2008 21:59:12 +0000 Subject: [erlang-questions] poll: monitoring performance of production erlang nodes In-Reply-To: <558B65C8-5DC9-4062-ACE7-7A818F8A5705@process-one.net> References: <7A654DC2-5B72-4AC7-9D97-F980DD5ADA74@gmail.com> <558B65C8-5DC9-4062-ACE7-7A818F8A5705@process-one.net> Message-ID: Mickael, On Nov 2, 2008, at 6:38 PM, Micka?l R?mond wrote: > We have written our own supervision and monitoring tool for ejabberd > that abstract all the Internal Erlang gory details. Do you use SNMP? Why not? > We can then set up alerts on the monitored values (currently more > than 250 different values including Erlang and XMPP ones) Does this require inserting timing code into the ejabberd code base, e.g. T = now(), ..., Delta = timer:now_diff(now(), T)? Do you store time series in ETS? How often do you collect? Thanks, Joel -- wagerlabs.com From joelr1@REDACTED Sun Nov 2 23:04:23 2008 From: joelr1@REDACTED (Joel Reymont) Date: Sun, 2 Nov 2008 22:04:23 +0000 Subject: [erlang-questions] poll: monitoring performance of production erlang nodes In-Reply-To: References: <7A654DC2-5B72-4AC7-9D97-F980DD5ADA74@gmail.com> Message-ID: <3CE7FB8A-8224-49BA-98E9-A88314BBADC2@gmail.com> Paul, On Nov 2, 2008, at 9:18 PM, Paul Mineiro wrote: > (We could use traces now to collect > timing statistics if we were willing to make intermediate functions > for > code regions of interest). Why not trace and time message paths? One time stamps are enabled, you'll have "entry" and "exit" points for messages, function calls, etc. You could then collect data and use and external tool to analyze the paths for you. -- wagerlabs.com From eliliang@REDACTED Sun Nov 2 22:42:53 2008 From: eliliang@REDACTED (Eli Liang) Date: Sun, 2 Nov 2008 13:42:53 -0800 (PST) Subject: [erlang-questions] is there an elephant in the room? mnesia network partition In-Reply-To: <8209f740811021155l7675a558yb3a611f3ce457a3@mail.gmail.com> Message-ID: <103054.50736.qm@web30406.mail.mud.yahoo.com> Oracle deals with it very transparently starting with 10g via the Oracle Configuration Repository (OCR), and its Cluster Ready Services Daemon (CRSD). In particular, the Oracle Cluster Synchronization Service Daemon (OCSSD) sorts out any data corruption and gets data back into sync when the nodes are back in communications. All 3 of these services work together to handle automated healing after a network split. No administrator input is required. --- On Sun, 11/2/08, Ulf Wiger wrote: From: Ulf Wiger Subject: Re: [erlang-questions] is there an elephant in the room? mnesia network partition To: "Joel Reymont" Cc: "Erlang Questions" Date: Sunday, November 2, 2008, 2:55 PM AFAIK, no general algorithm exists for self-healing after network splits. MySQL Cluster (NDB) e.g. solves it by requiring at least 3 copies of the data, and one arbitrator. In the case of a network split, you may continue if you can speak to the arbitrator; otherwise you're shut down. Mnesia provides the tools for resolving the situation, and one way to protect yourself from accidental inconsistencies is to use net_kernel dist_auto_connect_once, and keep a back door between the nodes (this has been discussed several times on this list.) Once you've determined that you have a split network, and which copies you want to continue with, you can restart the other nodes, possibly using mnesia:set_master_nodes/1 to make absolutely sure that they load their data from the right nodes. Setting this up is not terribly difficult. Interfacing to another DBMS is likely to be much more work, and you'd have to make really sure that they have a better strategy for coping with network splits than mnesia - I'm not at all sure that they do (but I'm willing to repent in the face of hard evidence). The lack of automatic handling of network splits has been mentioned a number of times as an argument against mnesia, but I really don't recall hearing much about how other DBMSs deal with it. There seems to be an assumption that since there isn't much discussion about network splits for other DBMSs, they must simply solve it transparently. I think this is a dangerous conclusion. BR, Ulf W 2008/11/2 Joel Reymont : > I'm looking to launch a poker 'social network', the first and only one > where you can actually play poker. I'm hesitant to go full-way with > Mnesia, though, and wonder how others are handling this. > > I googled and poked around but there seems to be an elephant in the > room and no one is talking about it. The elephant is that Mnesia does > not self-heal after network splits. > > Could it be that this is a solved problem or has anyone avoided it > because their data model does not require self-healing? How do big > projects deal with it? Ericsson? > > I would like to run a few Mnesia nodes for high availability but it > positively don't want my databases to diverge and I don't want to deal > with reconciling the databases later. > > Strictly speaking, I could keep mnesia as a transient data store and > keep my master database in a non-Erlang database. I just thought I'd > poll the community regardless. > > Thanks, Joel > > -- > wagerlabs.com > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From jason.ganetsky@REDACTED Sun Nov 2 23:59:38 2008 From: jason.ganetsky@REDACTED (Jason Ganetsky) Date: Sun, 2 Nov 2008 17:59:38 -0500 Subject: [erlang-questions] is there an elephant in the room? mnesia network partition In-Reply-To: <8209f740811021155l7675a558yb3a611f3ce457a3@mail.gmail.com> References: <8209f740811021155l7675a558yb3a611f3ce457a3@mail.gmail.com> Message-ID: I actually came to the same point as you did, a few months ago, and had asked many people many questions. I also felt there was a lack of discussion. Our partitions were actually not caused by the network, but caused by a lack of a responsiveness of one node. It had too little memory and would end up swapping... while it was swapping, the second node declared the first dead... the first node would come back with its connection to the second broken, declaring the second dead. To solve the problem, we needed automatic healing. Essentially, you will have to come up with some mechanism to reconcile the differences between partitioned databases. Fortunately, in my application, there are ways to sensibly reconstruct the data from an external MySQL source. Also, you are going to have to minimize the externalities that may cause a partition. This means running both nodes on the same switch and making sure they are highly available (possibly dedicating the machine to mnesia). However, I ended up needing to read the Mnesia source to understand how it detects partitions, and how it subsequently behaves. Using set_master_nodes() has a number of undesirable traits... like it supresses the running_partitioned_network message that is used to detect partitions. I set it up so that both nodes in my pair would watch for partitions, both would discard data with irreconcilable differences, and both would restart Mnesia. For more details, feel free to e-mail me. -Jason On Sun, Nov 2, 2008 at 2:55 PM, Ulf Wiger wrote: > AFAIK, no general algorithm exists for self-healing after network > splits. MySQL Cluster (NDB) e.g. solves it by requiring at least > 3 copies of the data, and one arbitrator. In the case of a network > split, you may continue if you can speak to the arbitrator; otherwise > you're shut down. > > Mnesia provides the tools for resolving the situation, and one way > to protect yourself from accidental inconsistencies is to use > net_kernel dist_auto_connect_once, and keep a back door between > the nodes (this has been discussed several times on this list.) > Once you've determined that you have a split network, and which > copies you want to continue with, you can restart the other nodes, > possibly using mnesia:set_master_nodes/1 to make absolutely > sure that they load their data from the right nodes. > > Setting this up is not terribly difficult. Interfacing to another DBMS > is likely to be much more work, and you'd have to make really sure > that they have a better strategy for coping with network splits than > mnesia - I'm not at all sure that they do (but I'm willing to repent in > the face of hard evidence). > > The lack of automatic handling of network splits has been mentioned > a number of times as an argument against mnesia, but I really don't > recall hearing much about how other DBMSs deal with it. There seems > to be an assumption that since there isn't much discussion about > network splits for other DBMSs, they must simply solve it transparently. > I think this is a dangerous conclusion. > > BR, > Ulf W > > 2008/11/2 Joel Reymont : > > I'm looking to launch a poker 'social network', the first and only one > > where you can actually play poker. I'm hesitant to go full-way with > > Mnesia, though, and wonder how others are handling this. > > > > I googled and poked around but there seems to be an elephant in the > > room and no one is talking about it. The elephant is that Mnesia does > > not self-heal after network splits. > > > > Could it be that this is a solved problem or has anyone avoided it > > because their data model does not require self-healing? How do big > > projects deal with it? Ericsson? > > > > I would like to run a few Mnesia nodes for high availability but it > > positively don't want my databases to diverge and I don't want to deal > > with reconciling the databases later. > > > > Strictly speaking, I could keep mnesia as a transient data store and > > keep my master database in a non-Erlang database. I just thought I'd > > poll the community regardless. > > > > Thanks, Joel > > > > -- > > wagerlabs.com > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf@REDACTED Mon Nov 3 01:04:49 2008 From: ulf@REDACTED (Ulf Wiger) Date: Mon, 3 Nov 2008 01:04:49 +0100 Subject: [erlang-questions] is there an elephant in the room? mnesia network partition In-Reply-To: <103054.50736.qm@web30406.mail.mud.yahoo.com> References: <8209f740811021155l7675a558yb3a611f3ce457a3@mail.gmail.com> <103054.50736.qm@web30406.mail.mud.yahoo.com> Message-ID: <8209f740811021604g364dadecla2cc9e75af0845ea@mail.gmail.com> >From what I could tell from googling, Oracle does the same thing as NDB does, forcing one or more of the participants to reboot if split-brain is detected. In order to do this, you need to set things up so that you have at least three participants. In general, I'd say that the Oracle setups for high availability are far more complex than many of the applications using mnesia in the first place. The steps needed to do something like with mnesia aren't that difficult, and have been explained on the erlang-questions list. http://www.erlang.org/pipermail/erlang-questions/2007-January/024716.html But I think that part of the problem (?) is that many users of mnesia start out building something really simple, and only start thinking about network partitioning when it first hits them (at least that's been the case several times in the past.) So if mnesia is going to address the problem, it can't assume that the user is going to spend a fortune on hardware clusters, geographic redundancy, load balancers and dynamic DNS. Indeed, the third participant which is usually required in order to resolve the situation often isn't there in mnesia's case. The AXD 301, for example, had only two master control processors, so the solutions used by NDB and Oracle (as I understand them) wouldn't have been feasible without major redesign. I think it should be possible to write a small add-on to mnesia that covers most of the scary issues. Most of the needed knowledge is available on the web already. Someone just needs to take the time to do it. BR, Ulf W 2008/11/2 Eli Liang : > Oracle deals with it very transparently starting with 10g via the Oracle > Configuration Repository (OCR), and its Cluster Ready Services Daemon > (CRSD). In particular, the Oracle Cluster Synchronization Service Daemon > (OCSSD) sorts out any data corruption and gets data back into sync when the > nodes are back in communications. All 3 of these services work together to > handle automated healing after a network split. No administrator input is > required. > > --- On Sun, 11/2/08, Ulf Wiger wrote: > > From: Ulf Wiger > Subject: Re: [erlang-questions] is there an elephant in the room? mnesia > network partition > To: "Joel Reymont" > Cc: "Erlang Questions" > Date: Sunday, November 2, 2008, 2:55 PM > > AFAIK, no general algorithm exists for self-healing after network > splits. MySQL Cluster (NDB) e.g. solves it by requiring at least > 3 copies of the data, and one arbitrator. In the case of a network > split, you may continue if you can speak to the arbitrator; otherwise > you're shut down. > Mnesia provides the tools for resolving the situation, and one way > to protect yourself from accidental inconsistencies is to use > net_kernel dist_auto_connect_once, and keep a back door between > the nodes (this has been discussed several times on this list.) > Once you've determined that you have a split network, and which > copies you want to continue with, you can restart the other nodes, > possibly using mnesia:set_master_nodes/1 to make absolutely > sure that they load their data from the right nodes. > Setting this up is not terribly difficult. Interfacing to another DBMS > is likely to be much more work, and you'd have to make really sure > that they have a better strategy for coping with network splits than > mnesia - I'm not at all sure that they do (but I'm willing to repent in > the face of hard evidence). > The lack of automatic handling of network splits has been mentioned > a number of times as an argument against mnesia, but I really don't > recall hearing much about how other DBMSs deal with it. There seems > to be an assumption that since there isn't much discussion about > network splits for other DBMSs, they must simply solve it transparently. > I think this is a dangerous conclusion. > BR, > Ulf W > 2008/11/2 Joel Reymont : >> I'm looking to launch a poker 'social network', the first and > only one >> where you can actually play poker. I'm hesitant to go full-way with >> Mnesia, though, and wonder how others are handling this. >> >> I googled and poked around but there seems to be an elephant in the >> room and no one is talking about it. The elephant is that Mnesia does >> not self-heal after network splits. >> >> Could it be that this is a solved problem or has anyone avoided it >> because their data model does not require self-healing? How do big >> projects deal with it? Ericsson? >> >> I would like to run a few Mnesia nodes for high availability but it >> positively don't want my databases to diverge and I don't want to > deal >> with reconciling the databases later. >> >> Strictly speaking, I could keep mnesia as a transient data store and >> keep my master database in a non-Erlang database. I just thought I'd >> poll the community regardless. >> >> Thanks, Joel >> >> -- >> wagerlabs.com >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From christophe.romain@REDACTED Sun Nov 2 21:23:34 2008 From: christophe.romain@REDACTED (Christophe Romain) Date: Sun, 2 Nov 2008 21:23:34 +0100 Subject: [erlang-questions] CEAN 1.4 is released Message-ID: <20081102202334.GB4645@localhost> After nearly one year of no visible activity i'm happy to announce a new release of CEAN. CEAN-1.4 comes with Erlang R12B-4, and brings up many improvements in the build process. The aim is to reach a production quality level of autogenerated packages for all erlang contributions. The most valuable improvements in CEAN-1.4 are: * Work in cluster environment. It's possible to sync CEAN installation on several hosts using just one command. * A better package dependency resolver. Generated dependencies are reliable. * Main commands available from bash. No need to join an erlang shell to install packages. * Lots of new packages. * A package status matrix. CEAN also support updated packages for R11B-5. The cluster features are backported to the R11B version as well. http://cean.process-one.net/ From harveyd@REDACTED Mon Nov 3 03:13:46 2008 From: harveyd@REDACTED (Dale Harvey) Date: Mon, 3 Nov 2008 02:13:46 +0000 Subject: [erlang-questions] CrashDumpViewer broken in firefox Message-ID: The crashdumpviewer from webtools doesnt work in firefox (and probably a few other browsers) I had a quick check what the problem is and its in the way the filename is submitted, elements wont give the fill path to the file for obvious security reasons http://pastebin.me/490e5d4e9b4bc shows the full path in konqueror but only the filename in firefox, since the file is read from the disk and not uploaded there isnt anyway to access its full path, the only real way to fix it would to have it upload the file (although im not sure if inets supports that) -------------- next part -------------- An HTML attachment was scrubbed... URL: From harveyd@REDACTED Mon Nov 3 03:29:50 2008 From: harveyd@REDACTED (Dale Harvey) Date: Mon, 3 Nov 2008 02:29:50 +0000 Subject: [erlang-questions] CrashDumpViewer broken in firefox In-Reply-To: References: Message-ID: Sorry I also forgot to mention a dirty workaround is just to start the application as normal and from the shell crashdump_viewer:read_file(junk,"path=/path/to/erl_crash.dump"). then view the application in the browser 2008/11/3 Dale Harvey > The crashdumpviewer from webtools doesnt work in firefox > (and probably a few other browsers) > > I had a quick check what the problem is and its in > the way the filename is submitted, elements > wont give the fill path to the file for obvious security reasons > > http://pastebin.me/490e5d4e9b4bc > shows the full path in konqueror but only the filename in firefox, > > since the file is read from the disk and not uploaded there isnt anyway > to access its full path, the only real way to fix it would to have it > upload > the file (although im not sure if inets supports that) > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ok@REDACTED Mon Nov 3 05:06:47 2008 From: ok@REDACTED (Richard O'Keefe) Date: Mon, 3 Nov 2008 17:06:47 +1300 Subject: [erlang-questions] List to proplist? In-Reply-To: <200810311229.23420.bekesa@sch.bme.hu> References: <6c2563b20810192156i7516e69aqb4d0eda2e1ee98d9@mail.gmail.com> <200810301326.23513.bekesa@sch.bme.hu> <200810311229.23420.bekesa@sch.bme.hu> Message-ID: <1F4E0C12-3F83-4B53-B257-EB4852C64E1B@cs.otago.ac.nz> On 1 Nov 2008, at 12:29 am, Andras Georgy Bekes wrote: >> Between [E(X) || X (<-) F] >> and [E(X) || X <- unfold(S, F')] >> there is very little difference, >> *provided* the compiler knows about unfold and treats it specially. > > What do you mean by "treats it specially"? "Inlines the call to unfold/2." > >> I've been thinking that we wouldn't really need >> syntax for iterating over the elements of a tuple >> if the compiler knew how to handle >> [E(X) || X <- tuple_to_list(T)]. > The compiler handles this just right. What do you mean? No, the compiler does _not_ handle it just right. The compiler generates code that will actually BUILD THE LIST. We don't need that. While it is true that tuples are usually small, that _isn't_ true of the tuples one would want to map over. From ok@REDACTED Mon Nov 3 05:18:35 2008 From: ok@REDACTED (Richard O'Keefe) Date: Mon, 3 Nov 2008 17:18:35 +1300 Subject: [erlang-questions] List to proplist? In-Reply-To: <20263801.post@talk.nabble.com> References: <6c2563b20810192156i7516e69aqb4d0eda2e1ee98d9@mail.gmail.com> <620F5FF0-93F8-4E0E-BBDA-5404E82BB054@cs.otago.ac.nz> <18696.21498.534675.651372@ornendil.du.uab.ericsson.se> <1225284106.31992.26.camel@seasc0642.dyn.rnd.as.sw.ericsson.se> <8FEABB6E-34FB-4B72-8F73-9989A48C767D@cs.otago.ac.nz> <200810301326.23513.bekesa@sch.bme.hu> <20263801.post@talk.nabble.com> Message-ID: On 1 Nov 2008, at 12:05 am, Zvi wrote: > > I think compiler shouldn't be dependent on standard library, it > should be > vice versa. I don't see the 'language' and 'library' as being fundamentally distinct. Within fairly broad limits, the less that's "language" the better. Nothing prevents the "library" including *advice* for the compiler. (Anyone else old enough to remember compiler macros for Lisp?) To this day, GHC lets a library include special hints for the compiler. Nobody said that the special compiler knowledge about library functions had to be *built-in*. > > I for example don't like special treatment of lists:reverse. If > there is > some optimized feature in the compiler it should be made first-class > citizen > in the language via special syntax or new keyword or reusing already > existing syntax/keywords if it's possible and make sense. Well, that's an interesting fact about your likes and dislikes. > > For example instead of of writing lists:reverse(L) - you write ~L or > something like this. Yeek! I'd rather use APL! > When you see how frequently is lists:reverse used in > the tail-recursive functions it really make sense. Arguably a better way would be to remove the limitation on tail recursion that has been using reverse so much. > > Why there should be multiple variants for '<-' ? And isn't that the point of what I just wrote? > After all Erlang has > dynamic typing, recognizing which collection type is T at run-time > should > cost just one compare You are making the unwarranted and false assumption that there is a one-to-one correspondence between Erlang data types and abstract sequence types. For example, it would be nice to iterate over gb_sets. How do you propose to tell the difference between gb_sets:new() -- a set with no elements -- and {0,nil} -- a tuple with two elements -- using Erlang's dynamic typing? (Hint: the result of gb_sets:new() IS {0,nil}.) > . And if type guards or type spec is present, then it > may be recognized at compile-time. There are no type guards for recognising gb_sets. From jan@REDACTED Mon Nov 3 10:45:37 2008 From: jan@REDACTED (Jan Lehnardt) Date: Mon, 3 Nov 2008 10:45:37 +0100 Subject: [erlang-questions] is there an elephant in the room? mnesia network partition In-Reply-To: References: Message-ID: On Nov 2, 2008, at 18:23, Joel Reymont wrote: > Strictly speaking, I could keep mnesia as a transient data store and > keep my master database in a non-Erlang database. I just thought I'd > poll the community regardless. CouchDB (http://couchdb.org), written in Erlang, is built for applications where disconnected operation is the general case. It comes with peer-to- peer replication, automatic conflict detection and resolution (yay). It is not a drop-in replacement for Mnesia though, so work is required to use it in an Mnesia-based application. Also, it does not (yet) have a native Erlang interface, "only" a RESTy HTTP API that is extremely easy to work with. There are Erlang libraries interfacing with the HTTP API that should get you started. CouchDB will eventually feature a native Erlang API that doesn't require you to go through HTTP. (Shameless plug #315: if anyone wants to work on this, *cough*, we could use some help). Cheers Jan -- From hans.bolinder@REDACTED Mon Nov 3 12:18:49 2008 From: hans.bolinder@REDACTED (Hans Bolinder) Date: Mon, 3 Nov 2008 12:18:49 +0100 Subject: [erlang-questions] List to proplist? In-Reply-To: <49085DE3.502@it.uu.se> References: <6c2563b20810192156i7516e69aqb4d0eda2e1ee98d9@mail.gmail.com> <620F5FF0-93F8-4E0E-BBDA-5404E82BB054@cs.otago.ac.nz> <18696.21498.534675.651372@ornendil.du.uab.ericsson.se> <49085DE3.502@it.uu.se> Message-ID: <18702.56857.955063.164341@ornendil.du.uab.ericsson.se> [Richard Carlsson:] > Hans Bolinder wrote: > > [Richard O'Keefe:] > >> A version of unfold that I prefer is > >> > >> unfold(State, Splitter) -> > >> unfold(State, Splitter, []). > >> > >> unfold(State, Splitter, Acc) -> > >> case Splitter(State) > >> of [] -> lists:reverse(Acc) > >> ; [Item|State1] -> unfold(State1, Splitter, [Item|Acc]) > >> end. > > > > lists:unfold/2 has been added to the upcoming R12B-5 release. > > I was going to comment on this before, but didn't get around to it. > Please don't use the return convention above; it is not normal > Erlang programming style, and introduces an improper list for no > really good reason. A more traditional return convention would > use e.g., {Item,State1} | 'none'. Thank you for your comments. We have, however, decided not to modify the code provided by Richard O'Keefe. Best regards, Hans Bolinder, Erlang/OTP team, Ericsson From raimo+erlang-questions@REDACTED Mon Nov 3 12:23:45 2008 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Mon, 3 Nov 2008 12:23:45 +0100 Subject: [erlang-questions] Digest problem In-Reply-To: <607844.98331.qm@web32006.mail.mud.yahoo.com> References: <607844.98331.qm@web32006.mail.mud.yahoo.com> Message-ID: <20081103112344.GC5384@erix.ericsson.se> On Sat, Nov 01, 2008 at 12:38:03AM -0700, Jawad Hussain wrote: > hi > i accidently clicked on option of digest > please let me know how to undo it > it is fillin my inbox like nythin > best regards > Jawad Hussain http://www.erlang.org/mailman/options/erlang-questions/jawadhussain619@REDACTED > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From masse@REDACTED Mon Nov 3 15:00:44 2008 From: masse@REDACTED (mats cronqvist) Date: Mon, 03 Nov 2008 15:00:44 +0100 Subject: [erlang-questions] Pattern-matching function? In-Reply-To: <8ca3fbe80810301316k4e5d1009xf854a66c53c27008@mail.gmail.com> (anders conbere's message of "Thu\, 30 Oct 2008 13\:16\:40 -0700") References: <20081029140008.219340@gmx.net> <49087238.3030904@it.uu.se> <8ca3fbe80810290818o5447de7ct8a13305fffe6583a@mail.gmail.com> <3dbc6d1c0810291319u2a84bc8bjbc212b4efee0a863@mail.gmail.com> <87wsfq6trw.fsf@dixie.cronqvi.st> <3dbc6d1c0810300817u429f4865kbe099131d8fd4ed7@mail.gmail.com> <8ca3fbe80810300927o51c52aav18bcc0c91e78eda3@mail.gmail.com> <65b2728e0810301228j17a25647h78c4f9121a1ee0ed@mail.gmail.com> <8ca3fbe80810301316k4e5d1009xf854a66c53c27008@mail.gmail.com> Message-ID: <87ljw0di43.fsf@sterlett.hq.kred> "anders conbere" writes: > On Thu, Oct 30, 2008 at 12:28 PM, Steve Vinoski wrote: >> On 10/30/08, anders conbere wrote: [...] > That being said I would love to be able to do > URLS = [{module, roto_web_view} > {[], version}, > {["version"], version}, > {["register"], register}, > {["nodes"], get_nodes}, > {["nodes", NodeName], nodes}; > {["nodes", NodeName, "queues"], queues}; > {["nodes", NodeName, "messages"], messages}; > ], like this? 1> deep_match:dm("/nodes/foo/queues/"). {queues,["foo"]} 2> deep_match:dm("/version/"). version %% -*- erlang-indent-level: 2 -*- %%% Created : 3 Nov 2008 by Mats Cronqvist %% @doc %% @end -module('deep_match'). -author('Mats Cronqvist'). -export([dm/1]). matches() ->[{[], fun version/1}, {["version"], fun version/1}, {["register"], fun register/1}, {["nodes"], fun get_nodes/1}, {["nodes", ''], fun nodez/1}, {["nodes", '', "queues"], fun queues/1}, {["nodes", '', "messages"],fun messages/1} ]. dm(Str) -> until(string:tokens(Str,"/"),matches()). until(Toks,[]) -> exit({no_match,Toks}); until(Toks,[{CandToks,CandFun}|Cands]) -> try CandFun(deep_match(Toks,CandToks)) catch _:_ -> until(Toks,Cands) end. deep_match([],[]) -> []; deep_match([T|Toks],[T|CandToks]) -> deep_match(Toks,CandToks); deep_match([T|Toks],[T|CandToks]) -> deep_match(Toks,CandToks); deep_match([T|Toks],[''|CandToks]) -> [T|deep_match(Toks,CandToks)]. version([])->version. register([])->register. get_nodes([])->get_nodes. nodez(X)->{nodes,X}. queues(X)->{queues,X}. messages(X)->{messages,X}. From hans.bolinder@REDACTED Mon Nov 3 16:48:05 2008 From: hans.bolinder@REDACTED (Hans Bolinder) Date: Mon, 3 Nov 2008 16:48:05 +0100 Subject: [erlang-questions] List to proplist? In-Reply-To: <49085DE3.502@it.uu.se> References: <6c2563b20810192156i7516e69aqb4d0eda2e1ee98d9@mail.gmail.com> <620F5FF0-93F8-4E0E-BBDA-5404E82BB054@cs.otago.ac.nz> <18696.21498.534675.651372@ornendil.du.uab.ericsson.se> <49085DE3.502@it.uu.se> Message-ID: <18703.7477.990113.798730@ornendil.du.uab.ericsson.se> [Richard Carlsson:] > Hans Bolinder wrote: > > [Richard O'Keefe:] > >> A version of unfold that I prefer is > >> > >> unfold(State, Splitter) -> > >> unfold(State, Splitter, []). > >> > >> unfold(State, Splitter, Acc) -> > >> case Splitter(State) > >> of [] -> lists:reverse(Acc) > >> ; [Item|State1] -> unfold(State1, Splitter, [Item|Acc]) > >> end. > > I was going to comment on this before, but didn't get around to it. > Please don't use the return convention above; it is not normal > Erlang programming style, and introduces an improper list for no > really good reason. A more traditional return convention would > use e.g., {Item,State1} | 'none'. [I answered:] > Thank you for your comments. We have, however, decided not to modify > the code provided by Richard O'Keefe. After some more afterthought, we've decided to withdraw lists:unfold/2 from R12B-5. We feel that it was introduced a bit hastily, and that the normal procedure for introducing new functionality in Erlang and supporting libraries should be followed. Therefore an EEP will be written, giving plenty of time before R13B to collect further comments and suggestions. Best regards, Hans Bolinder, Erlang/OTP team, Ericsson From ulf@REDACTED Mon Nov 3 17:10:03 2008 From: ulf@REDACTED (Ulf Wiger) Date: Mon, 3 Nov 2008 17:10:03 +0100 Subject: [erlang-questions] List to proplist? In-Reply-To: <18703.7477.990113.798730@ornendil.du.uab.ericsson.se> References: <6c2563b20810192156i7516e69aqb4d0eda2e1ee98d9@mail.gmail.com> <620F5FF0-93F8-4E0E-BBDA-5404E82BB054@cs.otago.ac.nz> <18696.21498.534675.651372@ornendil.du.uab.ericsson.se> <49085DE3.502@it.uu.se> <18703.7477.990113.798730@ornendil.du.uab.ericsson.se> Message-ID: <8209f740811030810l2ab807bdmc2171a33098d6d26@mail.gmail.com> Perhaps we should also clarify exactly what warrants an EEP and what doesn't. In the case of mnesia:read/2, an EEP was apparently overkill, but in this case it isn't? BR, Ulf W 2008/11/3, Hans Bolinder : > [Richard Carlsson:] >> Hans Bolinder wrote: >> > [Richard O'Keefe:] >> >> A version of unfold that I prefer is >> >> >> >> unfold(State, Splitter) -> >> >> unfold(State, Splitter, []). >> >> >> >> unfold(State, Splitter, Acc) -> >> >> case Splitter(State) >> >> of [] -> lists:reverse(Acc) >> >> ; [Item|State1] -> unfold(State1, Splitter, [Item|Acc]) >> >> end. >> >> I was going to comment on this before, but didn't get around to it. >> Please don't use the return convention above; it is not normal >> Erlang programming style, and introduces an improper list for no >> really good reason. A more traditional return convention would >> use e.g., {Item,State1} | 'none'. > > [I answered:] >> Thank you for your comments. We have, however, decided not to modify >> the code provided by Richard O'Keefe. > > After some more afterthought, we've decided to withdraw lists:unfold/2 > from R12B-5. We feel that it was introduced a bit hastily, and that > the normal procedure for introducing new functionality in Erlang and > supporting libraries should be followed. Therefore an EEP will be > written, giving plenty of time before R13B to collect further comments > and suggestions. > > Best regards, > > Hans Bolinder, Erlang/OTP team, Ericsson > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From joelr1@REDACTED Mon Nov 3 18:39:44 2008 From: joelr1@REDACTED (Joel Reymont) Date: Mon, 3 Nov 2008 17:39:44 +0000 Subject: [erlang-questions] paypal integration Message-ID: <1C5CF5AA-C5BA-440B-AFEF-B12175128709@gmail.com> Does anyone have PayPal integration code, on top of Mochiweb, Yaws or otherwise? Thanks, Joel -- wagerlabs.com From joelr1@REDACTED Mon Nov 3 18:41:19 2008 From: joelr1@REDACTED (Joel Reymont) Date: Mon, 3 Nov 2008 17:41:19 +0000 Subject: [erlang-questions] SNMP for logging of performance stats Message-ID: <5632775C-0D95-495A-AD33-A642E821AB41@gmail.com> I understand that people are using SNMP to log performance stats. I also understand that tools like Cacti support processing of SNMP data. I'm not quite sure how it all ties together yet but are there any pitfalls that I should be aware of? Thanks, Joel -- wagerlabs.com From oscar@REDACTED Mon Nov 3 19:25:47 2008 From: oscar@REDACTED (=?ISO-8859-1?Q?Oscar_Hellstr=F6m?=) Date: Mon, 03 Nov 2008 18:25:47 +0000 Subject: [erlang-questions] SNMP for logging of performance stats In-Reply-To: <5632775C-0D95-495A-AD33-A642E821AB41@gmail.com> References: <5632775C-0D95-495A-AD33-A642E821AB41@gmail.com> Message-ID: <490F422B.6030808@erlang-consulting.com> Hi Joel, We use Cacti to log SNMP data from (at least) one of our products. I haven't been involved in the Cacti setup myself, but essentially the Cacti does SNMP Gets on an OID at an interval. AFAIK there haven't been any special issues with integrating Cacti and Erlang SNMP. Joel Reymont wrote: > I understand that people are using SNMP to log performance stats. I > also understand that tools like Cacti support processing of SNMP data. > > I'm not quite sure how it all ties together yet but are there any > pitfalls that I should be aware of? > > Thanks, Joel > > -- > wagerlabs.com > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions Best regards -- Oscar Hellstr?m, oscar@REDACTED Office: +44 20 7655 0337 Mobile: +44 798 45 44 773 Erlang Training and Consulting http://www.erlang-consulting.com/ From gleber.p@REDACTED Mon Nov 3 20:18:09 2008 From: gleber.p@REDACTED (Gleb Peregud) Date: Mon, 3 Nov 2008 20:18:09 +0100 Subject: [erlang-questions] Erlang Web by E.T.C. released Message-ID: <14f0e3620811031118u75ca9b5u2caf96dee0809f54@mail.gmail.com> I've stumbled upon interesting news: > The Erlang Web is an open source framework for the rapid > deployment of web based interfaces. By separating the HTML > generation, glue and logic while retaining it in the same memory > space, we provide a framework which gives the developer better > control of content management where reusability is the key. > Erlang Training and Consulting has been using the Erlang > Web in commercial applications for three years, and has now > decided to release it as open source. For more information and > to download the latest version of the code, read documentation > and view examples, visit the Erlang Web site. via http://www.erlang-consulting.com/aboutus/news.html#103 Project is available here: http://www.erlang-web.org/ -- Gleb Peregud http://gleber.pl/ Every minute is to be grasped. Time waits for nobody. -- Inscription on a Zen Gong From joe@REDACTED Mon Nov 3 20:19:33 2008 From: joe@REDACTED (Joe Williams) Date: Mon, 03 Nov 2008 13:19:33 -0600 Subject: [erlang-questions] SNMP for logging of performance stats In-Reply-To: <490F422B.6030808@erlang-consulting.com> References: <5632775C-0D95-495A-AD33-A642E821AB41@gmail.com> <490F422B.6030808@erlang-consulting.com> Message-ID: <490F4EC5.5030002@joetify.com> Regarding the setup, it's a normal PHP/MySQL setup with a cronjob to execute a poller. Regarding the OID, you may need to setup a graph template or something to get your data to display right. There are some built-in ones but it may not be suitable for what you are trying to do. -Joe ? wrote: > Hi Joel, > > We use Cacti to log SNMP data from (at least) one of our products. I > haven't been involved in the Cacti setup myself, but essentially the > Cacti does SNMP Gets on an OID at an interval. > > AFAIK there haven't been any special issues with integrating Cacti and > Erlang SNMP. > > Joel Reymont wrote: > >> I understand that people are using SNMP to log performance stats. I >> also understand that tools like Cacti support processing of SNMP data. >> >> I'm not quite sure how it all ties together yet but are there any >> pitfalls that I should be aware of? >> >> Thanks, Joel >> >> -- >> wagerlabs.com >> >> >> >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > Best regards > -- Name: Joseph A. Williams Email: joe@REDACTED From dizzyd@REDACTED Mon Nov 3 21:29:01 2008 From: dizzyd@REDACTED (Dave Smith) Date: Mon, 3 Nov 2008 13:29:01 -0700 Subject: [erlang-questions] SNMP for logging of performance stats In-Reply-To: <490F4EC5.5030002@joetify.com> References: <5632775C-0D95-495A-AD33-A642E821AB41@gmail.com> <490F422B.6030808@erlang-consulting.com> <490F4EC5.5030002@joetify.com> Message-ID: I'll second that -- we use SNMP heavily for our Erlang projects at my workplace. Erlang has _great_ SNMP support and makes it so easy to do. We've also written some tools that permit us to measure CPU% and RSS for individual Erlang nodes, which is quite helpful when doing performance/load testing. D. On Mon, Nov 3, 2008 at 12:19 PM, Joe Williams wrote: > Regarding the setup, it's a normal PHP/MySQL setup with a cronjob to > execute a poller. Regarding the OID, you may need to setup a graph > template or something to get your data to display right. There are some > built-in ones but it may not be suitable for what you are trying to do. > > -Joe > > > ? wrote: >> Hi Joel, >> >> We use Cacti to log SNMP data from (at least) one of our products. I >> haven't been involved in the Cacti setup myself, but essentially the >> Cacti does SNMP Gets on an OID at an interval. >> >> AFAIK there haven't been any special issues with integrating Cacti and >> Erlang SNMP. >> >> Joel Reymont wrote: >> >>> I understand that people are using SNMP to log performance stats. I >>> also understand that tools like Cacti support processing of SNMP data. >>> >>> I'm not quite sure how it all ties together yet but are there any >>> pitfalls that I should be aware of? >>> >>> Thanks, Joel >>> >>> -- >>> wagerlabs.com >>> >>> >>> >>> >>> >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://www.erlang.org/mailman/listinfo/erlang-questions >>> >> >> Best regards >> > > -- > Name: Joseph A. Williams > Email: joe@REDACTED > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From sten.gruener@REDACTED Mon Nov 3 22:52:58 2008 From: sten.gruener@REDACTED (Stasik) Date: Mon, 3 Nov 2008 13:52:58 -0800 (PST) Subject: [erlang-questions] FFI Interface - Limitation of the size of parameters In-Reply-To: References: Message-ID: <003cf10d-cf81-48c0-b52c-7c59113a4ab7@v16g2000prc.googlegroups.com> Hello, I sill have the problem to get ei working with linked in drivers. My erl module uses the complex5 structure. http://www3.erlang.org/doc/tutorial/complex5.erl When I try to implement this tutorial http://www.erlang.org/doc/tutorial/erl_interface.html to adopt the ei for standalone driver I get many mistakes. 1st problem is, that there is no binary mode. 2nd problem is, LID functions seem to expect signed chars, ei functions unsigned chars, its ok to workaround this. 3rd problem: even if it compiles with some warnings (regarding signed ints), erl does not want to start the driver and gives drv_not_loaded error without further error trace :( Does someone run ei with lid`s? An example would be very very nice. Cheers, Sten Gruener On Oct 10, 7:14?pm, Hasan Veldstra wrote: > Check out the ei library:http://www.erlang.org/doc/man/ei.html > > You can use the term_to_binary function on the Erlang side on any ? > term and then decode that in C using functions in ei. It works the ? > other way round too. > > On 10 Oct 2008, at 17:30PM, Stasik wrote: > > > > > Hello, > > > I am quite new to Erland, and try to get some Erlang-C Communication. > > I found a tutorial athttp://www.wagerlabs.com/blog/2008/02/erlang- > > ffi---in.html > > (which is a commented version of another tutorial, but it does not > > matter). Well, I was successful to compile the example and its pretty > > fine, BUT: I noticed that all exchanged parameters in port_driver.c > > are chars i.e.: > > - static void example_drv_output(ErlDrvData handle, char *buff, int > > bufflen) //here the input array consists of chars > > - driver_output(d->port, &res, 1); //here &res should point to a char, > > driver_output is a predefined function in erl_driver.h > > These limitations do not allow to send and receive any values which > > are bigger then 255 (and I do not want to split bigger numbers in > > bytes if there is a possibility to do it elegantly). > > > Well, is there a known solution for that problem? I would like to have > > an int range. > > > Cheers, > > Sten Gruener > > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions From babo.online@REDACTED Mon Nov 3 23:19:13 2008 From: babo.online@REDACTED (Attila Babo) Date: Mon, 3 Nov 2008 23:19:13 +0100 Subject: [erlang-questions] paypal integration In-Reply-To: <1C5CF5AA-C5BA-440B-AFEF-B12175128709@gmail.com> References: <1C5CF5AA-C5BA-440B-AFEF-B12175128709@gmail.com> Message-ID: <597c69660811031419j3b3d5b86r2697352ded5643dc@mail.gmail.com> Just found the other day but never tried it: http://code.google.com/p/erlpay/source/browse/trunk/licenses/Mochiweb-License-MIT From francesco@REDACTED Tue Nov 4 00:07:17 2008 From: francesco@REDACTED (Francesco Cesarini (Erlang Training and Consulting)) Date: Mon, 03 Nov 2008 23:07:17 +0000 Subject: [erlang-questions] paypal integration In-Reply-To: <1C5CF5AA-C5BA-440B-AFEF-B12175128709@gmail.com> References: <1C5CF5AA-C5BA-440B-AFEF-B12175128709@gmail.com> Message-ID: <490F8425.80307@erlang-consulting.com> We did it a few years ago with our web platform, which at the time was running yaws. I'd have to dig in the repository to find it. From what I remember, it was a fairly straightforward task. Francesco -- http://www.erlang-consulting.com Joel Reymont wrote: > Does anyone have PayPal integration code, on top of Mochiweb, Yaws or > otherwise? > > Thanks, Joel > > -- > wagerlabs.com > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From rory@REDACTED Tue Nov 4 00:10:12 2008 From: rory@REDACTED (Rory Byrne) Date: Tue, 4 Nov 2008 00:10:12 +0100 Subject: [erlang-questions] paypal integration In-Reply-To: <1C5CF5AA-C5BA-440B-AFEF-B12175128709@gmail.com> References: <1C5CF5AA-C5BA-440B-AFEF-B12175128709@gmail.com> Message-ID: <20081103231012.GA27761@almeida.jinsky.com> On Mon, Nov 03, 2008 at 05:39:44PM +0000, Joel Reymont wrote: > Does anyone have PayPal integration code, on top of Mochiweb, Yaws or > otherwise? > Ouch, I was dreading someone asking that. I've got an updated version of: http://code.google.com/p/erlpay/ It's far from pretty and not very user-friendly, but is should be moderately secure. I'm currently just putting it into production at: https://yupp.ie The paypal code is very basic - it just allows you to create encrypted buttons on the fly and to verify that the IPN notifications you receive really are from PayPal. To see it in action, just sign up for a bogus recruiter account at the site, then log in and click 'account' and then 'Buy Tokens'. If what you see there is enough functionality for your needs, then just ping me off-line and I'll sort you out with a copy (under BSD license) and some basic instructions. I certainly intend on updating the main erlpay codebase when I get a chance (the version up there is quite buggy), I'm just jammed for time at the moment. On a side note, you'll be interested to know that the Yupp.ie site is built using a modified version of Massimiliano Mirra's "seethrough" templating system [1]. I gather that you made some important contributions to that project. Nice! Rory [1] http://hyperstruct.net/2007/1/7/seethrough-a-simple-xml-xhtml-templating-system-for-erlang From q2h46uw02@REDACTED Tue Nov 4 07:16:07 2008 From: q2h46uw02@REDACTED (Kevin) Date: Tue, 04 Nov 2008 01:16:07 -0500 Subject: [erlang-questions] open_port CPU "leak" Message-ID: <1828-85825@sneakemail.com> Hello, this function I wrote slowly increases CPU usage if called in a fairly tight loop. Even replacing Command with "echo hello" will not fix the problem. I also tried called port_close but I got a weird error, I think because the port was already closed. Is this the way its done? So far I've found no better explanation in the books or docs? Thanks for any feedback. get_sha(Str) -> Command = "echo '" ++ Str ++ "' | sha1sum", Port = open_port({spawn, Command}, [exit_status]), Port ! {self(), {command, []}}, receive {Port, {data, Data}} -> %% chop off junk at end of sha1sum output, what is that crap??? string:substr(Data, 1, string:len(Data)-4); {Port, {exit_status, Status}} -> %% exited without a result {error, Status} end. From harry.weppner@REDACTED Tue Nov 4 07:18:20 2008 From: harry.weppner@REDACTED (Harald Weppner) Date: Mon, 3 Nov 2008 22:18:20 -0800 Subject: [erlang-questions] wish8.5 malloc:*** error for object 0x591978: Non-aligned pointer being freed Message-ID: Hi there, am wondering if anyone ran into this error before when accessing pretty much anything using gs? I came across this issue starting the debugger but even ex1.erl from the gs user's guide causes these error messages. I searched and didn't see this discussed before anywhere... A number of errors such as these are output in the erlang shell (note: they appear before displaying a window and after closing one): wish8.5(3213,0xa0bad074) malloc: *** error for object 0x591978: Non-aligned pointer being freed *** set a breakpoint in malloc_error_break to debug wish8.5(3213,0xa0bad074) malloc: *** error for object 0x5906a8: Non-aligned pointer being freed *** set a breakpoint in malloc_error_break to debug wish8.5(3213,0xa0bad074) malloc: *** error for object 0x59e098: Non-aligned pointer being freed *** set a breakpoint in malloc_error_break to debug [and a few more...] When I break at that point I see the following stack: (gdb) bt #0 0x96c7eb60 in malloc_error_break () #1 0x96c797c8 in szone_error () #2 0x002b4af8 in FcStrFree () #3 0x002b0254 in FcValueListDestroy () #4 0x002b0cb0 in FcPatternDestroy () #5 0x0002f4d4 in XftFontOpenInfo () #6 0x0003036c in XftFontOpenPattern () #7 0x0b0d169c in GetFont () #8 0x0b0d1ac4 in InitFont () #9 0x0b0d1e44 in TkpGetFontFromAttributes () #10 0x0b01d23c in Tk_AllocFontFromObj () #11 0x0b0139a8 in DoObjConfig () #12 0x0b013ed4 in Tk_SetOptions () #13 0x0b04dd60 in ConfigureMenuButton () #14 0x0b04e310 in Tk_MenubuttonObjCmd () #15 0x0a0101f8 in TclEvalObjvInternal () #16 0x0a054eb4 in TclExecuteByteCode () #17 0x0a05dbd8 in TclCompEvalObj () #18 0x0a05513c in TclExecuteByteCode () #19 0x0a09c174 in TclObjInterpProcCore () #20 0x0a0101f8 in TclEvalObjvInternal () #21 0x0a054eb4 in TclExecuteByteCode () #22 0x0a05dbd8 in TclCompEvalObj () #23 0x0a0124e0 in TclEvalObjEx () #24 0x0a09ae34 in Tcl_UplevelObjCmd () #25 0x0a0101f8 in TclEvalObjvInternal () #26 0x0a054eb4 in TclExecuteByteCode () #27 0x0a09c174 in TclObjInterpProcCore () #28 0x0a0101f8 in TclEvalObjvInternal () #29 0x0a054eb4 in TclExecuteByteCode () #30 0x0a05dbd8 in TclCompEvalObj () #31 0x0a0124e0 in TclEvalObjEx () #32 0x0a06ce10 in TclChannelEventScriptInvoker () #33 0x0a072994 in Tcl_NotifyChannel () #34 0x0a0c4f84 in FileHandlerEventProc () #35 0x0a08ae18 in Tcl_ServiceEvent () #36 0x0a08b254 in Tcl_DoOneEvent () #37 0x0b018e98 in Tk_MainLoop () #38 0x0b0280b4 in Tk_MainEx () #39 0x00005564 in main () The weird thing is that this happens only on a PPC Mac but doesn't exhibit this behavior on an Intel Mac. tcl/tk is at 8.5.5 on both machines and I believe X11 to be identical as well... Any input appreciated. Cheerio, Harry. From bengt.kleberg@REDACTED Tue Nov 4 07:36:36 2008 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Tue, 04 Nov 2008 07:36:36 +0100 Subject: [erlang-questions] open_port CPU "leak" In-Reply-To: <1828-85825@sneakemail.com> References: <1828-85825@sneakemail.com> Message-ID: <490FED74.9080609@ericsson.com> Greetings, A suggestion, in case that it is the result of "echo | sha1sum" that interests you (as opposed to open_port/2). Have you tried os:cmd/1? 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." On 2008-11-04 07:16, Kevin wrote: > Hello, this function I wrote slowly increases CPU usage if called in a > fairly tight loop. Even replacing Command > with "echo hello" will not fix the problem. I also tried called > port_close but I got a weird error, I think because > the port was already closed. Is this the way its done? So far I've > found no better explanation in the books or docs? > Thanks for any feedback. > > get_sha(Str) -> > > Command = "echo '" ++ Str ++ "' | sha1sum", > Port = open_port({spawn, Command}, [exit_status]), > Port ! {self(), {command, []}}, > receive > {Port, {data, Data}} -> > %% chop off junk at end of sha1sum output, what is that crap??? > string:substr(Data, 1, string:len(Data)-4); > {Port, {exit_status, Status}} -> %% exited without a result > {error, Status} > end. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From daniel.n.wiik@REDACTED Tue Nov 4 08:13:54 2008 From: daniel.n.wiik@REDACTED (Daniel Wiik) Date: Tue, 4 Nov 2008 08:13:54 +0100 Subject: [erlang-questions] open_port CPU "leak" In-Reply-To: <1828-85825@sneakemail.com> References: <1828-85825@sneakemail.com> Message-ID: Hi Kevin, Have tried the crypto module? Perhaps the crypto:sha/1 function will solve your problem in a faster and safer way. Best regards /Daniel On Tue, Nov 4, 2008 at 7:16 AM, Kevin wrote: > > Hello, this function I wrote slowly increases CPU usage if called in a > fairly tight loop. Even replacing Command > with "echo hello" will not fix the problem. I also tried called > port_close but I got a weird error, I think because > the port was already closed. Is this the way its done? So far I've > found no better explanation in the books or docs? > Thanks for any feedback. > > get_sha(Str) -> > > Command = "echo '" ++ Str ++ "' | sha1sum", > Port = open_port({spawn, Command}, [exit_status]), > Port ! {self(), {command, []}}, > receive > {Port, {data, Data}} -> > %% chop off junk at end of sha1sum output, what is that crap??? > string:substr(Data, 1, string:len(Data)-4); > {Port, {exit_status, Status}} -> %% exited without a result > {error, Status} > end. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jesper.louis.andersen@REDACTED Tue Nov 4 09:37:35 2008 From: jesper.louis.andersen@REDACTED (Jesper Louis Andersen) Date: Tue, 4 Nov 2008 09:37:35 +0100 Subject: [erlang-questions] wish8.5 malloc:*** error for object 0x591978: Non-aligned pointer being freed In-Reply-To: References: Message-ID: <56a0a2840811040037hcd5179cx1a00d1d061a0f57d@mail.gmail.com> This looks like a TCL-bug on Mac PPC more than an erlang bug. If I remember correctly, PPC only allows aligned data access and this looks like a pointer has been moved so it is not aligned anymore which causes the bug. I'd suggest you try the TCL-people. On Tue, Nov 4, 2008 at 7:18 AM, Harald Weppner wrote: > Hi there, > > am wondering if anyone ran into this error before when accessing > pretty much anything using gs? > > I came across this issue starting the debugger but even ex1.erl from > the gs user's guide causes these error messages. I searched and didn't > see this discussed before anywhere... > > A number of errors such as these are output in the erlang shell (note: > they appear before displaying a window and after closing one): > > wish8.5(3213,0xa0bad074) malloc: > *** error for object 0x591978: Non-aligned pointer being freed > *** set a breakpoint in malloc_error_break to debug > wish8.5(3213,0xa0bad074) malloc: > *** error for object 0x5906a8: Non-aligned pointer being freed > *** set a breakpoint in malloc_error_break to debug > wish8.5(3213,0xa0bad074) malloc: > *** error for object 0x59e098: Non-aligned pointer being freed > *** set a breakpoint in malloc_error_break to debug > [and a few more...] > > When I break at that point I see the following stack: > > (gdb) bt > #0 0x96c7eb60 in malloc_error_break () > #1 0x96c797c8 in szone_error () > #2 0x002b4af8 in FcStrFree () > #3 0x002b0254 in FcValueListDestroy () > #4 0x002b0cb0 in FcPatternDestroy () > #5 0x0002f4d4 in XftFontOpenInfo () > #6 0x0003036c in XftFontOpenPattern () > #7 0x0b0d169c in GetFont () > #8 0x0b0d1ac4 in InitFont () > #9 0x0b0d1e44 in TkpGetFontFromAttributes () > #10 0x0b01d23c in Tk_AllocFontFromObj () > #11 0x0b0139a8 in DoObjConfig () > #12 0x0b013ed4 in Tk_SetOptions () > #13 0x0b04dd60 in ConfigureMenuButton () > #14 0x0b04e310 in Tk_MenubuttonObjCmd () > #15 0x0a0101f8 in TclEvalObjvInternal () > #16 0x0a054eb4 in TclExecuteByteCode () > #17 0x0a05dbd8 in TclCompEvalObj () > #18 0x0a05513c in TclExecuteByteCode () > #19 0x0a09c174 in TclObjInterpProcCore () > #20 0x0a0101f8 in TclEvalObjvInternal () > #21 0x0a054eb4 in TclExecuteByteCode () > #22 0x0a05dbd8 in TclCompEvalObj () > #23 0x0a0124e0 in TclEvalObjEx () > #24 0x0a09ae34 in Tcl_UplevelObjCmd () > #25 0x0a0101f8 in TclEvalObjvInternal () > #26 0x0a054eb4 in TclExecuteByteCode () > #27 0x0a09c174 in TclObjInterpProcCore () > #28 0x0a0101f8 in TclEvalObjvInternal () > #29 0x0a054eb4 in TclExecuteByteCode () > #30 0x0a05dbd8 in TclCompEvalObj () > #31 0x0a0124e0 in TclEvalObjEx () > #32 0x0a06ce10 in TclChannelEventScriptInvoker () > #33 0x0a072994 in Tcl_NotifyChannel () > #34 0x0a0c4f84 in FileHandlerEventProc () > #35 0x0a08ae18 in Tcl_ServiceEvent () > #36 0x0a08b254 in Tcl_DoOneEvent () > #37 0x0b018e98 in Tk_MainLoop () > #38 0x0b0280b4 in Tk_MainEx () > #39 0x00005564 in main () > > > The weird thing is that this happens only on a PPC Mac but doesn't > exhibit this behavior on an Intel Mac. tcl/tk is at 8.5.5 on both > machines and I believe X11 to be identical as well... > > Any input appreciated. > > Cheerio, Harry. > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From jesper@REDACTED Tue Nov 4 09:58:07 2008 From: jesper@REDACTED (Jesper Eskilson) Date: Tue, 4 Nov 2008 09:58:07 +0100 Subject: [erlang-questions] Constraint satisfaction problems In-Reply-To: <3BE6DBA1F3BE9D4798255806113D56540F7FB8AA87@utx-exchange.utx.local> References: <3BE6DBA1F3BE9D4798255806113D56540F7FB8AA87@utx-exchange.utx.local> Message-ID: On Fri, Oct 31, 2008 at 8:55 AM, Imre Palik wrote: > During playing with project Euler I solved a few constraint satisfaction problems with erlang. But whenever I code a solution, I have a really awkward feeling, that it should be possible to do better, but I don't know how. > > I tend to code a backtracking search with constraint propagation before every step. I model the constraint graph with digraph, but then the non-functional nature of the digraph package makes backtracking really awkward. > > Is there any better way to solve constraint satisfaction problems? > What is the rationale behind those pesky side effects in digraph? If you want to solve Project Euler problems using constraints, I'd recommend using Prolog instead. GNU Prolog worked very nice for the problems I tried. Are there any good constraint libraries for Erlang? -- /Jesper From carsten@REDACTED Tue Nov 4 11:00:46 2008 From: carsten@REDACTED (Carsten Schultz) Date: Tue, 4 Nov 2008 11:00:46 +0100 Subject: [erlang-questions] open_port CPU "leak" In-Reply-To: <1828-85825@sneakemail.com> References: <1828-85825@sneakemail.com> Message-ID: <20081104100045.GB5060@penne.localnet> On Tue, Nov 04, 2008 at 01:16:07AM -0500, Kevin wrote: > > Hello, this function I wrote slowly increases CPU usage if called in a > fairly tight loop. Even replacing Command > with "echo hello" will not fix the problem. I also tried called > port_close but I got a weird error, I think because > the port was already closed. Is this the way its done? So far I've > found no better explanation in the books or docs? > Thanks for any feedback. > > get_sha(Str) -> > > Command = "echo '" ++ Str ++ "' | sha1sum", > Port = open_port({spawn, Command}, [exit_status]), > Port ! {self(), {command, []}}, > receive > {Port, {data, Data}} -> > %% chop off junk at end of sha1sum output, what is that crap??? > string:substr(Data, 1, string:len(Data)-4); > {Port, {exit_status, Status}} -> %% exited without a result > {error, Status} > end. Are there other messages sent that you are not interested in and that might pile up in the mail box? Try adding OtherMsg -> diagnostic output Best, Carsten -- Carsten Schultz (2:38, 33:47) http://carsten.codimi.de/ PGP/GPG key on the pgp.net key servers, fingerprint on my home page. From rvirding@REDACTED Tue Nov 4 11:48:16 2008 From: rvirding@REDACTED (Robert Virding) Date: Tue, 4 Nov 2008 11:48:16 +0100 Subject: [erlang-questions] Constraint satisfaction problems In-Reply-To: References: <3BE6DBA1F3BE9D4798255806113D56540F7FB8AA87@utx-exchange.utx.local> Message-ID: <3dbc6d1c0811040248t150f8e35u8518dde562af5a46@mail.gmail.com> 2008/11/4 Jesper Eskilson > On Fri, Oct 31, 2008 at 8:55 AM, Imre Palik wrote: > > During playing with project Euler I solved a few constraint satisfaction > problems with erlang. But whenever I code a solution, I have a really > awkward feeling, that it should be possible to do better, but I don't know > how. > > > > I tend to code a backtracking search with constraint propagation before > every step. I model the constraint graph with digraph, but then the > non-functional nature of the digraph package makes backtracking really > awkward. > > > > Is there any better way to solve constraint satisfaction problems? > > What is the rationale behind those pesky side effects in digraph? > > If you want to solve Project Euler problems using constraints, I'd > recommend using Prolog instead. GNU Prolog worked very nice for the > problems I tried. > > Are there any good constraint libraries for Erlang? There are no constraint libraries that I know of. However, there is Erlog which is a prolog implemented in Erlang which works quite well. Depending on the application. As yet it has no built-in constraint handling but that could be added if a serious request comes along. Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: From richardc@REDACTED Tue Nov 4 12:39:22 2008 From: richardc@REDACTED (Richard Carlsson) Date: Tue, 04 Nov 2008 12:39:22 +0100 Subject: [erlang-questions] Constraint satisfaction problems In-Reply-To: References: <3BE6DBA1F3BE9D4798255806113D56540F7FB8AA87@utx-exchange.utx.local> Message-ID: <4910346A.3020804@it.uu.se> Jesper Eskilson wrote: > On Fri, Oct 31, 2008 at 8:55 AM, Imre Palik wrote: >> During playing with project Euler I solved a few constraint >> satisfaction problems with erlang. But whenever I code a solution, >> I have a really awkward feeling, that it should be possible to do >> better, but I don't know how. >> >> I tend to code a backtracking search with constraint propagation >> before every step. I model the constraint graph with digraph, but >> then the non-functional nature of the digraph package makes >> backtracking really awkward. >> >> Is there any better way to solve constraint satisfaction problems? >> What is the rationale behind those pesky side effects in digraph? > > If you want to solve Project Euler problems using constraints, I'd > recommend using Prolog instead. GNU Prolog worked very nice for the > problems I tried. > > Are there any good constraint libraries for Erlang? Not that I know of, but there is a Masters' thesis from 1995 by Greger Ottoson that might provide some inspiration for anyone wanting to write such a library. (Greger added some destructive functions to the runtime system, but it could probably be made sufficiently efficient using ets tables or purely functional data structures instead.) ftp://ftp.csd.uu.se/pub/papers/masters-theses/0085-ottosson.ps.gz /Richard From ms@REDACTED Tue Nov 4 12:52:39 2008 From: ms@REDACTED (Martin Scholl) Date: Tue, 04 Nov 2008 12:52:39 +0100 Subject: [erlang-questions] file:open/2 and Unix Device Files Message-ID: <20081104125239.ucznf9xvok80oogk@webmail.diskware.net> Hello, I have just noticed that opening a device file other than "/dev/null" will fail with eisdir. I am just wondering what the intention behind this was. Could somebody elaborate on why this restriction is in place? Furthermore, will I have to modify efile_openfile() for each new released version of erlang, or is there a chance that future releases will support opening all kinds of device files? Thank you, Martin From colm.dougan@REDACTED Tue Nov 4 13:19:11 2008 From: colm.dougan@REDACTED (Colm Dougan) Date: Tue, 4 Nov 2008 12:19:11 +0000 Subject: [erlang-questions] file:open/2 and Unix Device Files In-Reply-To: <20081104125239.ucznf9xvok80oogk@webmail.diskware.net> References: <20081104125239.ucznf9xvok80oogk@webmail.diskware.net> Message-ID: <24d4f39c0811040419j7f4baaf5xce8cfbc32742eb0e@mail.gmail.com> On Tue, Nov 4, 2008 at 11:52 AM, Martin Scholl wrote: > Hello, > > > I have just noticed that opening a device file other than "/dev/null" > will fail with eisdir. > I am just wondering what the intention behind this was. Could somebody > elaborate on why this restriction is in place? I don't have the answer to that. However, in case you were not aware, if you open a file in "raw" mode then you can read device files. Colm From ms@REDACTED Tue Nov 4 14:12:24 2008 From: ms@REDACTED (Martin Scholl) Date: Tue, 04 Nov 2008 14:12:24 +0100 Subject: [erlang-questions] file:open/2 and Unix Device Files In-Reply-To: <24d4f39c0811040419j7f4baaf5xce8cfbc32742eb0e@mail.gmail.com> References: <20081104125239.ucznf9xvok80oogk@webmail.diskware.net> <24d4f39c0811040419j7f4baaf5xce8cfbc32742eb0e@mail.gmail.com> Message-ID: <20081104141224.wrxmjo4u800cocwg@webmail.diskware.net> Quoting Colm Dougan : > On Tue, Nov 4, 2008 at 11:52 AM, Martin Scholl wrote: >> Hello, >> >> >> I have just noticed that opening a device file other than "/dev/null" >> will fail with eisdir. >> I am just wondering what the intention behind this was. Could somebody >> elaborate on why this restriction is in place? > > I don't have the answer to that. However, in case you were not aware, > if you open a file in "raw" mode then you can read device files. > > Colm > From ms@REDACTED Tue Nov 4 14:18:02 2008 From: ms@REDACTED (Martin Scholl) Date: Tue, 04 Nov 2008 14:18:02 +0100 Subject: [erlang-questions] file:open/2 and Unix Device Files In-Reply-To: <24d4f39c0811040419j7f4baaf5xce8cfbc32742eb0e@mail.gmail.com> References: <20081104125239.ucznf9xvok80oogk@webmail.diskware.net> <24d4f39c0811040419j7f4baaf5xce8cfbc32742eb0e@mail.gmail.com> Message-ID: <20081104141802.6d8r63keo84kcggo@webmail.diskware.net> Hello again, Quoting Colm Dougan : [snip] > I don't have the answer to that. However, in case you were not aware, > if you open a file in "raw" mode then you can read device files. Thank you for hinting me this, but I am afraid it doesn't work for me(r): Erlang (BEAM) emulator version 5.6.4 [source] [64-bit] [smp:2] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.6.4 (abort with ^G) 1> {ok, File} = file:open("/dev/sdb", [raw]). ** exception error: no match of right hand side value {error,eisdir} 2> {ok, File} = file:open("/dev/sdb", [raw,binary]). ** exception error: no match of right hand side value {error,eisdir} 3> {ok, File} = file:open("/dev/sdb", [raw,binary,read]). ** exception error: no match of right hand side value {error,eisdir} 4> {ok, File} = file:open("/dev/sdb", [raw,binary,write]). ** exception error: no match of right hand side value {error,eisdir} 5> {ok, File} = file:open("/dev/sdb", [raw,binary,append]). ** exception error: no match of right hand side value {error,eisdir} 6> {ok, File} = file:open("/dev/sdb", [raw,binary,append,read]). ** exception error: no match of right hand side value {error,eisdir} 7> {ok, File} = file:open("/dev/sdb", [raw,binary,append,write]). ** exception error: no match of right hand side value {error,eisdir} Are you doing something different than what I have already tried? After a quick look at unix_efile.c:673 it seems impossible for me to open device files other than /dev/null "the standard way". Martin P.S.: I will not use those webmailers again. From koushik.list@REDACTED Tue Nov 4 14:39:49 2008 From: koushik.list@REDACTED (Koushik Narayanan) Date: Tue, 4 Nov 2008 19:09:49 +0530 Subject: [erlang-questions] Upgrading gen_tcp socket to ssl Message-ID: <1200c6750811040539m685a7faeya8b786fc22dcac52@mail.gmail.com> Hi All, In ssl-3.9, according to the documentation the connect/2 function allows upgrading a gen_tcp socket to a ssl socket. But when I try ssl:connect(Gen_tcp_socket,[{verify,0}]), I get {eoptions,{cacertfile,[]}}. The Gen_tcp_socket is a socket created using gen_tcp:connect/3. Since {verify,0}, why is a cacertfile required. ssl:connect/3 (for creating a ssl connection not upgrading existing one) works fine without cacertfile. What am I missing here? Regards, Koushik Narayanan -------------- next part -------------- An HTML attachment was scrubbed... URL: From colm.dougan@REDACTED Tue Nov 4 14:43:54 2008 From: colm.dougan@REDACTED (Colm Dougan) Date: Tue, 4 Nov 2008 13:43:54 +0000 Subject: [erlang-questions] file:open/2 and Unix Device Files In-Reply-To: <20081104141802.6d8r63keo84kcggo@webmail.diskware.net> References: <20081104125239.ucznf9xvok80oogk@webmail.diskware.net> <24d4f39c0811040419j7f4baaf5xce8cfbc32742eb0e@mail.gmail.com> <20081104141802.6d8r63keo84kcggo@webmail.diskware.net> Message-ID: <24d4f39c0811040543o751a909fk6a0de03c4ff58346@mail.gmail.com> On Tue, Nov 4, 2008 at 1:18 PM, Martin Scholl wrote: > Hello again, > > Quoting Colm Dougan : > [snip] >> I don't have the answer to that. However, in case you were not aware, >> if you open a file in "raw" mode then you can read device files. > Thank you for hinting me this, but I am afraid it doesn't work for me(r): > > Erlang (BEAM) emulator version 5.6.4 [source] [64-bit] [smp:2] > [async-threads:0] [hipe] [kernel-poll:false] > > Eshell V5.6.4 (abort with ^G) > 1> {ok, File} = file:open("/dev/sdb", [raw]). > ** exception error: no match of right hand side value {error,eisdir} > 2> {ok, File} = file:open("/dev/sdb", [raw,binary]). Apologies - I got my wires crossed. Opening file in raw mode works for /proc (whereas file:read_file doesn't) but it doesn't work for /dev. Colm From joelr1@REDACTED Tue Nov 4 16:00:46 2008 From: joelr1@REDACTED (Joel Reymont) Date: Tue, 4 Nov 2008 15:00:46 +0000 Subject: [erlang-questions] setting a timer for a given date and time Message-ID: What is a robust way of setting a timer for a given UTC date and time? I guess I can take the difference between now (UTC) and the given datetime using calendar:time_difference/2. This would give me seconds which I could multiply by 1000 to get the milliseconds the timer needs. Would this be the best approach, though? Thanks, Joel -- http://wagerlabs.com From ulf.wiger@REDACTED Tue Nov 4 16:07:14 2008 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Tue, 04 Nov 2008 16:07:14 +0100 Subject: [erlang-questions] setting a timer for a given date and time In-Reply-To: References: Message-ID: <49106522.7020502@ericsson.com> Joel Reymont skrev: > What is a robust way of setting a timer for a given UTC date and > time? > > I guess I can take the difference between now (UTC) and the given > datetime using calendar:time_difference/2. This would give me seconds > which I could multiply by 1000 to get the milliseconds the timer > needs. > > Would this be the best approach, though? I think that's the most common way to do it. Remember that you must stay within a "smallint" with the timer. To protect yourself from clock changes etc., you might want to sleep in smallish increments (perhaps minutes or seconds at a time, depending on what trade-off between safety and overhead that suits you best.) BR, Ulf W From koushik.list@REDACTED Tue Nov 4 16:35:04 2008 From: koushik.list@REDACTED (Koushik Narayanan) Date: Tue, 4 Nov 2008 21:05:04 +0530 Subject: [erlang-questions] Upgrading gen_tcp socket to ssl In-Reply-To: <1200c6750811040539m685a7faeya8b786fc22dcac52@mail.gmail.com> References: <1200c6750811040539m685a7faeya8b786fc22dcac52@mail.gmail.com> Message-ID: <1200c6750811040735x52dae1aao326acd225775b18a@mail.gmail.com> Hi All, In ssl-3.9, according to the documentation the connect/2 function allows upgrading a gen_tcp socket to a ssl socket. But when I try ssl:connect(Gen_tcp_socket,[{verify,0}]), I get {eoptions,{cacertfile,[]}}. The Gen_tcp_socket is a socket created using gen_tcp:connect/3. Since {verify,0}, why is a cacertfile required. ssl:connect/3 (for creating a ssl connection not upgrading existing one) works fine without cacertfile. What am I missing here? Regards, Koushik Narayanan -------------- next part -------------- An HTML attachment was scrubbed... URL: From vychodil.hynek@REDACTED Tue Nov 4 16:40:01 2008 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Tue, 4 Nov 2008 16:40:01 +0100 Subject: [erlang-questions] setting a timer for a given date and time In-Reply-To: References: Message-ID: <20081104154002.2B07B2402F@relay.gooddata.com> calendar:time_difference/2 is signed as deprecated in documentation. On Tue, Nov 4, 2008 at 4:00 PM, Joel Reymont wrote: > What is a robust way of setting a timer for a given UTC date and time? > > I guess I can take the difference between now (UTC) and the given > datetime using calendar:time_difference/2. This would give me seconds > which I could multiply by 1000 to get the milliseconds the timer > needs. > > Would this be the best approach, though? > > Thanks, Joel > > -- > http://wagerlabs.com > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- --Hynek (Pichi) Vychodil -------------- next part -------------- An HTML attachment was scrubbed... URL: From oscar@REDACTED Tue Nov 4 17:00:12 2008 From: oscar@REDACTED (=?ISO-8859-1?Q?Oscar_Hellstr=F6m?=) Date: Tue, 04 Nov 2008 16:00:12 +0000 Subject: [erlang-questions] setting a timer for a given date and time In-Reply-To: <20081104154002.2B07B2402F@relay.gooddata.com> References: <20081104154002.2B07B2402F@relay.gooddata.com> Message-ID: <4910718C.8010505@erlang-consulting.com> How about timer:now_diff/2 Hynek Vychodil wrote: > calendar:time_difference/2 is signed as deprecated in documentation. > > On Tue, Nov 4, 2008 at 4:00 PM, Joel Reymont > wrote: > > What is a robust way of setting a timer for a given UTC date and time? > > I guess I can take the difference between now (UTC) and the given > datetime using calendar:time_difference/2. This would give me seconds > which I could multiply by 1000 to get the milliseconds the timer > needs. > > Would this be the best approach, though? > > Thanks, Joel > > -- > http://wagerlabs.com > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > -- > --Hynek (Pichi) Vychodil > > > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions Best regards -- Oscar Hellstr?m, oscar@REDACTED Office: +44 20 7655 0337 Mobile: +44 798 45 44 773 Erlang Training and Consulting http://www.erlang-consulting.com/ From vychodil.hynek@REDACTED Tue Nov 4 17:12:49 2008 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Tue, 4 Nov 2008 17:12:49 +0100 Subject: [erlang-questions] setting a timer for a given date and time In-Reply-To: <4910718C.8010505@erlang-consulting.com> References: <20081104154002.2B07B2402F@relay.gooddata.com> <4910718C.8010505@erlang-consulting.com> Message-ID: <20081104161250.338422405D@relay.gooddata.com> I haven't found ({Date, Time}) -> {MegaSecs, Secs, MicroSecs} function. On Tue, Nov 4, 2008 at 5:00 PM, Oscar Hellstr?m wrote: > How about timer:now_diff/2 > > Hynek Vychodil wrote: > > calendar:time_difference/2 is signed as deprecated in documentation. > > > > On Tue, Nov 4, 2008 at 4:00 PM, Joel Reymont > > wrote: > > > > What is a robust way of setting a timer for a given UTC date and > time? > > > > I guess I can take the difference between now (UTC) and the given > > datetime using calendar:time_difference/2. This would give me seconds > > which I could multiply by 1000 to get the milliseconds the timer > > needs. > > > > Would this be the best approach, though? > > > > Thanks, Joel > > > > -- > > http://wagerlabs.com > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > > > > > > -- > > --Hynek (Pichi) Vychodil > > > > > > ------------------------------------------------------------------------ > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > Best regards > -- > Oscar Hellstr?m, oscar@REDACTED > Office: +44 20 7655 0337 > Mobile: +44 798 45 44 773 > Erlang Training and Consulting > http://www.erlang-consulting.com/ > -- --Hynek (Pichi) Vychodil -------------- next part -------------- An HTML attachment was scrubbed... URL: From oscar@REDACTED Tue Nov 4 18:12:25 2008 From: oscar@REDACTED (=?ISO-8859-1?Q?Oscar_Hellstr=F6m?=) Date: Tue, 04 Nov 2008 17:12:25 +0000 Subject: [erlang-questions] setting a timer for a given date and time In-Reply-To: <20081104154002.2B07B2402F@relay.gooddata.com> References: <20081104154002.2B07B2402F@relay.gooddata.com> Message-ID: <49108279.7060800@erlang-consulting.com> Hmm, it doesn't actually say deprecated, but obsolete: This function is obsolete. Use the conversion functions for gregorian days and seconds instead. Anyway, using calendar:datetime_to_gregorian_seconds/1 and comparing the datetimes should be what's needed here, right? Hynek Vychodil wrote: > calendar:time_difference/2 is signed as deprecated in documentation. > > On Tue, Nov 4, 2008 at 4:00 PM, Joel Reymont > wrote: > > What is a robust way of setting a timer for a given UTC date and time? > > I guess I can take the difference between now (UTC) and the given > datetime using calendar:time_difference/2. This would give me seconds > which I could multiply by 1000 to get the milliseconds the timer > needs. > > Would this be the best approach, though? > > Thanks, Joel > > -- > http://wagerlabs.com > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > -- > --Hynek (Pichi) Vychodil > > > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions Best regards -- Oscar Hellstr?m, oscar@REDACTED Office: +44 20 7655 0337 Mobile: +44 798 45 44 773 Erlang Training and Consulting http://www.erlang-consulting.com/ From oscar@REDACTED Tue Nov 4 18:13:48 2008 From: oscar@REDACTED (=?ISO-8859-1?Q?Oscar_Hellstr=F6m?=) Date: Tue, 04 Nov 2008 17:13:48 +0000 Subject: [erlang-questions] setting a timer for a given date and time In-Reply-To: <20081104161250.3F10424065@relay.gooddata.com> References: <20081104154002.2B07B2402F@relay.gooddata.com> <4910718C.8010505@erlang-consulting.com> <20081104161250.3F10424065@relay.gooddata.com> Message-ID: <491082CC.9090305@erlang-consulting.com> Just to keep myself busy. Hynek Vychodil wrote: > I haven't found ({Date, Time}) -> {MegaSecs, Secs, MicroSecs} function. % calendar:datetime_to_gregorian_seconds({{1970,1,1}, {0,0,0}}) -define(GREGORIAN_SECONDS_1970, 62167219200). datetime_to_now(DateTime) -> GSeconds = calendar:datetime_to_gregorian_seconds(DateTime), ESeconds = GSeconds - ?GREGORIAN_SECONDS_1970, {ESeconds div 1000000, ESeconds rem 1000000, 0}. > On Tue, Nov 4, 2008 at 5:00 PM, Oscar Hellstr?m > > wrote: > > How about timer:now_diff/2 > > Hynek Vychodil wrote: > > calendar:time_difference/2 is signed as deprecated in documentation. > > > > On Tue, Nov 4, 2008 at 4:00 PM, Joel Reymont > > >> wrote: > > > > What is a robust way of setting a timer for a given UTC date > and time? > > > > I guess I can take the difference between now (UTC) and the given > > datetime using calendar:time_difference/2. This would give me > seconds > > which I could multiply by 1000 to get the milliseconds the timer > > needs. > > > > Would this be the best approach, though? > > > > Thanks, Joel > > > > -- > > http://wagerlabs.com > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > > > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > > > > > > -- > > --Hynek (Pichi) Vychodil > > > > > > > ------------------------------------------------------------------------ > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > Best regards > -- > Oscar Hellstr?m, oscar@REDACTED > > Office: +44 20 7655 0337 > Mobile: +44 798 45 44 773 > Erlang Training and Consulting > http://www.erlang-consulting.com/ > > > > > -- > --Hynek (Pichi) Vychodil -- Oscar Hellstr?m, oscar@REDACTED Office: +44 20 7655 0337 Mobile: +44 798 45 44 773 Erlang Training and Consulting http://www.erlang-consulting.com/ From igouy2@REDACTED Tue Nov 4 17:04:17 2008 From: igouy2@REDACTED (Isaac Gouy) Date: Tue, 4 Nov 2008 08:04:17 -0800 (PST) Subject: [erlang-questions] Why isn't erlang strongly typed? Message-ID: <494359.16000.qm@web65402.mail.ac4.yahoo.com> On Thu Oct 23 02:04:47 CEST 2008, Richard O'Keefe wrote: -snip- > (I've been building a Smalltalk compiler in my spare time for a couple > of times. It ran its first method yesterday! Over and over and over > I've found single inheritance limiting.) Traits? http://www.iam.unibe.ch/~scg/Research/Traits/ > Do we have a serious problem with run-time type errors? > Is a type system the only, or the best, way to deal with them? afaict the OP's complaint was not about type errors but about the difficulty of understanding poorly documented 3rd party libraries in the absence of source code type information. The question would be more like - is a type system the only, or the best or a good or a better than nothing, way to support library exploration and comprehension. So the following comments are incidental to the OP's complaint: > One aspect of unit testing frameworks is that if you test each > function in a module even a few times, you are going to smoke > out most type errors fairly quickly. You will also find many > mistakes that a type system will not catch. At which point we become interested in the cost of unit testing to 'smoke out most type errors' and wonder if type checking and unit testing could perhaps be complementary practices. > A suitable notation, such as Smalltalk/Objective-C split method > names, can prevent most type errors in the first place. Let's not forget that, with no type information in the source code, Smalltalkers adopt the "best practice" of naming methods parameters like this - aString, anInteger :-) > Last year I kept a log of the mistakes I was finding in my > Smalltalk system. I haven't kept it up this year, because > I'd learned the main thing I wanted to learn: errors that > would have been caught by a type checker and not by other > means were quite rare. It's not a question of errors that would have been caught by other means - it's a question of errors that would have been caught by other means that are actually being used. And of course it depends what we imagine the type checker can do - can we catch nil/null references? A quick look through this fix list for a Smalltalk maintenance release gave me the impression that - 85% are changes to functionality/behaviour/appearance - ~5% we might expect to have found with static checks - ~10% we'd have to investigate more before we could say http://www.cincomsmalltalk.com/blog/blogView?showComments=true&entry=3268381755 From steven.charles.davis@REDACTED Tue Nov 4 19:31:05 2008 From: steven.charles.davis@REDACTED (Steve Davis) Date: Tue, 4 Nov 2008 10:31:05 -0800 (PST) Subject: [erlang-questions] Why isn't erlang strongly typed? In-Reply-To: <494359.16000.qm@web65402.mail.ac4.yahoo.com> References: <494359.16000.qm@web65402.mail.ac4.yahoo.com> Message-ID: <64ef9242-4d28-40bc-9b3d-16649468efa3@o4g2000pra.googlegroups.com> On Nov 4, 10:04?am, Isaac Gouy wrote: > On Thu Oct 23 02:04:47 CEST 2008, Richard O'Keefe wrote: > -snip- > > > Traits? > > http://www.iam.unibe.ch/~scg/Research/Traits/ > Very interesting document. My take on this is that OOP seems to be struggling against its own dictum that "everything is an object that has methods that define its behavior". My personal assessment of all that is that not all actions, or _functions_, are adequately covered by "methods" constrained in this way. You'll note that the "traits" (which are to my mind a 'hack' to resolve the limitation on methods) are disallowed from reading state, which seems to confirm the diagnosis. On the flip side, I also think that not everything is a function, and that objects do have a place in a programming language that goes beyond simple record definitions as preprocessor macros. /s From michal@REDACTED Tue Nov 4 19:42:12 2008 From: michal@REDACTED (Michal Slaski) Date: Tue, 4 Nov 2008 18:42:12 +0000 (GMT) Subject: [erlang-questions] New release of the Erlang Web In-Reply-To: <484589.10281225824046617.JavaMail.root@zimbra> Message-ID: <21849541.10301225824132452.JavaMail.root@zimbra> Hi, We have recently released a new version of the Erlang Web framework for the rapid deployment of web based interfaces. The framework follows the MVC pattern and separates HTML templates from glue and logic implemented in the controller functions. One of the new features introduced in this release is automatic generation of forms which can be based on Erlang records. This plays nice with mnesia database as it also uses records for its table definition. Other features include basic implementation of aspects, support for language translations and mapping URLs into function calls based on regular expressions. Erlang Training and Consulting has been using the Erlang Web in commercial applications for three years, and has released it as open source under a derivative of the EPL license. For more information visit the Erlang Web site at http://www.erlang-web.org/ You are very welcome to join the Erlang Web mailing list. You can also meet us at the Erlang User Conference next week, where we will be presenting the Erlang Web. Hope you like it! The Erlang Web Team -- http://www.erlang-consulting.com From holger@REDACTED Tue Nov 4 20:38:13 2008 From: holger@REDACTED (Holger Hoffstaette) Date: Tue, 04 Nov 2008 20:38:13 +0100 Subject: [erlang-questions] Why isn't erlang strongly typed? References: <494359.16000.qm@web65402.mail.ac4.yahoo.com> <64ef9242-4d28-40bc-9b3d-16649468efa3@o4g2000pra.googlegroups.com> Message-ID: On Tue, 04 Nov 2008 10:31:05 -0800, Steve Davis wrote: > On Nov 4, 10:04?am, Isaac Gouy wrote: >> On Thu Oct 23 02:04:47 CEST 2008, Richard O'Keefe wrote: -snip- >> >> Traits? >> >> http://www.iam.unibe.ch/~scg/Research/Traits/ >> > Very interesting document. My take on this is that OOP seems to be > struggling against its own dictum that "everything is an object that has > methods that define its behavior". [..] That's not caused by methods per se but by Smalltalk's single-inheritance nature and the concept of identity. IIRC Self had none of the problems of Traits (remember they were just tacked on). Similarly, functional re-composition via AOP works very well even in Java, and allows introduced behaviour to bring its own state. Does a representation of a function have identity? If so, does that make it an object? :) -h From steven.charles.davis@REDACTED Tue Nov 4 21:38:59 2008 From: steven.charles.davis@REDACTED (Steve Davis) Date: Tue, 4 Nov 2008 12:38:59 -0800 (PST) Subject: [erlang-questions] Why isn't erlang strongly typed? In-Reply-To: References: <494359.16000.qm@web65402.mail.ac4.yahoo.com> <64ef9242-4d28-40bc-9b3d-16649468efa3@o4g2000pra.googlegroups.com> Message-ID: <756cc63c-5896-4ca7-895e-4c0c3df4e23e@1g2000prd.googlegroups.com> On Nov 4, 1:38?pm, "Holger Hoffstaette" wrote: > On Tue, 04 Nov 2008 10:31:05 -0800, Steve Davis wrote: > > On Nov 4, 10:04?am, Isaac Gouy wrote: > >> On Thu Oct 23 02:04:47 CEST 2008, Richard O'Keefe wrote: -snip- > > >> Traits? > > >>http://www.iam.unibe.ch/~scg/Research/Traits/ > > > Very interesting document. My take on this is that OOP seems to be > > struggling against its own dictum that "everything is an object that has > > methods that define its behavior". [..] > > That's not caused by methods per se but by Smalltalk's single-inheritance > nature and the concept of identity. I'm not that familiar with Smalltalk but I understand that single inheritance and entity concepts in Java were influenced heavily by Smalltalk - in which case I'd have to disagree. Interfaces were the original "solution" (among other things, to make up for lack of multiple inheritance) but led to massive code repetition. Mixins were then tried as extensions of decorators but have their own "diamond of death" style issues. Traits seem to be another attempt that importantly *disallow access to state*. Hence my comments... > IIRC Self had none of the problems > of Traits (remember they were just tacked on). Similarly, functional > re-composition via AOP works very well even in Java, and allows introduced > behaviour to bring its own state. "Prefer composition over inheritance" is a useful guideline, true. But AOP uses bytecode injection, correct? Does bytecode manipulation not also imply that it's providing support for an inadequate language concept(s)? > Does a representation of a function have identity? If so, does that make > it an object? :) Um... define "object" in this context. My answer is yes to the first and no to the second (representational entities, in my book, don't have to mean these should influence language entities or be allowed to constrain its expressiveness. A case in point would be Erlang (either that, or I misunderstood your last point). /s From ok@REDACTED Tue Nov 4 22:27:55 2008 From: ok@REDACTED (Richard O'Keefe) Date: Wed, 5 Nov 2008 10:27:55 +1300 Subject: [erlang-questions] Constraint satisfaction problems In-Reply-To: <3dbc6d1c0811040248t150f8e35u8518dde562af5a46@mail.gmail.com> References: <3BE6DBA1F3BE9D4798255806113D56540F7FB8AA87@utx-exchange.utx.local> <3dbc6d1c0811040248t150f8e35u8518dde562af5a46@mail.gmail.com> Message-ID: I'm sure I remember a thesis about constraints for Erlang. I think I have a copy somewhere. I recall thinking "are they serious?" and not reading it. From ok@REDACTED Tue Nov 4 22:30:23 2008 From: ok@REDACTED (Richard O'Keefe) Date: Wed, 5 Nov 2008 10:30:23 +1300 Subject: [erlang-questions] file:open/2 and Unix Device Files In-Reply-To: <20081104125239.ucznf9xvok80oogk@webmail.diskware.net> References: <20081104125239.ucznf9xvok80oogk@webmail.diskware.net> Message-ID: On 5 Nov 2008, at 12:52 am, Martin Scholl wrote: > I have just noticed that opening a device file other than "/dev/null" > will fail with eisdir. It's amazing what you'll find in the archives. I asked this very question once, and was told that the key distinction is that reading from (or writing to) a file won't wait for _too_ long, but that devices can take very long amounts of time. From ok@REDACTED Tue Nov 4 22:49:06 2008 From: ok@REDACTED (Richard O'Keefe) Date: Wed, 5 Nov 2008 10:49:06 +1300 Subject: [erlang-questions] Why isn't erlang strongly typed? In-Reply-To: <756cc63c-5896-4ca7-895e-4c0c3df4e23e@1g2000prd.googlegroups.com> References: <494359.16000.qm@web65402.mail.ac4.yahoo.com> <64ef9242-4d28-40bc-9b3d-16649468efa3@o4g2000pra.googlegroups.com> <756cc63c-5896-4ca7-895e-4c0c3df4e23e@1g2000prd.googlegroups.com> Message-ID: On 5 Nov 2008, at 9:38 am, Steve Davis wrote: > I'm not that familiar with Smalltalk but I understand that single > inheritance and entity concepts in Java were influenced heavily by > Smalltalk - in which case I'd have to disagree. Interfaces were the > original "solution" (among other things, to make up for lack of > multiple inheritance) but led to massive code repetition. Mixins were > then tried as extensions of decorators but have their own "diamond of > death" style issues. Traits seem to be another attempt that > importantly *disallow access to state*. Hence my comments... Traits don't disallow access to state. They disallow *direct* access to state. They can use as much state as they want, provided they do so by calling methods from the class they are extending. The idea is "single inheritance for state, multiple inheritance for behaviour". Lisp mixins were around long before Java was dreamed of; did Java-style interfaces come from some earlier language? (I used to wonder how Java could possibly make interfaces efficient. Then I did some benchmarking and stopping wondering: it doesn't.) > > "Prefer composition over inheritance" is a useful guideline, true. But > AOP uses bytecode injection, correct? There's no reason why AOP can't use source weaving. >> Does a representation of a function have identity? If so, does that >> make >> it an object? :) > > Um... define "object" in this context. My answer is yes to the first > and no to the second (representational entities, in my book, don't > have to mean these should influence language entities or be allowed to > constrain its expressiveness It's traditional in Lisp-family languages that don't have OO already to emulate objects with closures. (See the "T" book.) That's because variables in a Lispy closure are mutable, unlike those in Erlang funs. Identity, (mutable) state, behaviour: that's the OO trinity and closures have them all. From wde@REDACTED Tue Nov 4 23:02:58 2008 From: wde@REDACTED (wde@REDACTED) Date: Tue, 4 Nov 2008 23:02:58 +0100 Subject: [erlang-questions] object oriented programming and design pattern Message-ID: <200811042216.mA4MGZne000621@morgoth.cslab.ericsson.net> Hello all, I am discovering the erlang language and the OTP framework. I would like to know if there are documents or books about design patterns in Erlang and how to implement OOP paradigms in Erlang (if it's possible). Thank you for your help. From webaccounts@REDACTED Wed Nov 5 00:15:36 2008 From: webaccounts@REDACTED (Dan Rubino) Date: Tue, 04 Nov 2008 23:15:36 +0000 Subject: [erlang-questions] object oriented programming and design pattern In-Reply-To: <200811042216.mA4MGZne000621@morgoth.cslab.ericsson.net> References: <200811042216.mA4MGZne000621@morgoth.cslab.ericsson.net> Message-ID: <1225840536.6561.18.camel@linux-box> Hi , I would recommend the Joe Armstrong book for learning Erlang and an introduction to OTP. As far as implementing OO in FP I think what you are after is an understanding of functional data structures. For that I recommend Chris Okasaki's book "Purely functional data structures" - alot of it is lazy however so doesnt apply to Erlang, interesting none the less. Cheers, Dan On Tue, 2008-11-04 at 23:02 +0100, wde@REDACTED wrote: > Hello all, > > I am discovering the erlang language and the OTP framework. > > I would like to know if there are documents or books about design patterns in Erlang and how to implement OOP paradigms in Erlang (if it's possible). > > > Thank you for your help. > > > > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From igouy2@REDACTED Wed Nov 5 00:33:25 2008 From: igouy2@REDACTED (Isaac Gouy) Date: Tue, 4 Nov 2008 15:33:25 -0800 (PST) Subject: [erlang-questions] Why isn't erlang strongly typed? In-Reply-To: Message-ID: <589608.73901.qm@web65402.mail.ac4.yahoo.com> --- Richard O'Keefe wrote: > > On 5 Nov 2008, at 9:38 am, Steve Davis wrote: > > I'm not that familiar with Smalltalk but I understand that single > > inheritance and entity concepts in Java were influenced heavily by > > Smalltalk - in which case I'd have to disagree. Interfaces were the > > original "solution" (among other things, to make up for lack of > > multiple inheritance) but led to massive code repetition. Mixins > were > > then tried as extensions of decorators but have their own "diamond > of > > death" style issues. Traits seem to be another attempt that > > importantly *disallow access to state*. Hence my comments... > > Traits don't disallow access to state. > They disallow *direct* access to state. > They can use as much state as they want, > provided they do so by calling methods from the > class they are extending. In other words, traits disallow access to state and require methods in the class (not in the trait) for access to state :-) From marcsugiyama@REDACTED Wed Nov 5 01:04:31 2008 From: marcsugiyama@REDACTED (Marc Sugiyama) Date: Tue, 4 Nov 2008 16:04:31 -0800 Subject: [erlang-questions] running out of memory trying to add_frag on a large mnesia table Message-ID: I have a large, fragmented mnesia table. I'm trying to add more fragments to it (see below). When I do: mnesia:change_table_frag(pvobject, {add_frag, [node()]). erl dies trying to allocate memory. top showed beam.smp using 2gb shortly before the memory allocation failure. I'm looking for some ideas about how I can refragment this table. My goal is to reduce the size of each fragment, but I'll be keeping all the fragments on the one machine. Thanks. Marc pvobject : with 2247463 records occupying 1030593978 bytes on disc pvobject_frag9 : with 2244007 records occupying 996368400 bytes on disc pvobject_frag8 : with 4384060 records occupying 1944822252 bytes on disc pvobject_frag7 : with 4378299 records occupying 1943621636 bytes on disc pvobject_frag6 : with 4388504 records occupying 1944472080 bytes on disc pvobject_frag5 : with 4375236 records occupying 1942309152 bytes on disc pvobject_frag4 : with 4372202 records occupying 1943407648 bytes on disc pvobject_frag3 : with 4387990 records occupying 1944152852 bytes on disc pvobject_frag2 : with 2246356 records occupying 1030532870 bytes on disc schema : with 11 records occupying 1651 words of mem pvobject_frag10: with 2246679 records occupying 1030323718 bytes on disc ===> System info in version "4.4.3", debug level = none <=== opt_disc. Directory "/var/home/pvadmin/mnesia" is used. use fallback at restart = false running db nodes = [pvstorage@REDACTED] stopped db nodes = [] master node tables = [] remote = [] ram_copies = [] disc_copies = [schema] disc_only_copies = [pvobject,pvobject_frag10,pvobject_frag2,pvobject_frag3, pvobject_frag4,pvobject_frag5,pvobject_frag6, pvobject_frag7,pvobject_frag8,pvobject_frag9] [{pvstorage@REDACTED,disc_copies}] = [schema] [{pvstorage@REDACTED,disc_only_copies}] = [pvobject_frag10,pvobject_frag2, pvobject_frag3,pvobject_frag4, pvobject_frag5,pvobject_frag6, pvobject_frag7,pvobject_frag8, pvobject_frag9,pvobject] 2 transactions committed, 0 aborted, 0 restarted, 0 logged to disc 0 held locks, 0 in queue; 0 local transactions, 0 remote 0 transactions waits for other nodes: [] ok From ok@REDACTED Wed Nov 5 02:12:27 2008 From: ok@REDACTED (Richard O'Keefe) Date: Wed, 5 Nov 2008 14:12:27 +1300 Subject: [erlang-questions] Why isn't erlang strongly typed? In-Reply-To: <589608.73901.qm@web65402.mail.ac4.yahoo.com> References: <589608.73901.qm@web65402.mail.ac4.yahoo.com> Message-ID: On 5 Nov 2008, at 12:33 pm, Isaac Gouy wrote: >> Traits don't disallow access to state. >> They disallow *direct* access to state. >> They can use as much state as they want, >> provided they do so by calling methods from the >> class they are extending. > > In other words, traits disallow access to state and require methods in > the class (not in the trait) for access to state :-) Many Smalltalk masters recommend what's called "self-encapsulation" where ANY class should encapsulate access to its state variables in a small handful of methods and ALL other methods should use those to access state rather that directly referring to instance variables. Nobody says that this disallows access to state! On the contrary, people talk about calling such accessor methods as "access to [state] data". See http://www.martinfowler.com/bliki/SelfEncapsulation.html for an example of this usage. Traits don't have any state of their own to access, so they can hardly be said to disallow access to what does not exist. For access to the state of the class they are bound in with, traits rely on self-encapsulation, not as a way of disallowing access to state, but as a way of ENABLING it. To call this extended use of self-encapsulation "disallowing access to state" would be rather like calling windows devices for disallowing access to light. From igouy2@REDACTED Wed Nov 5 03:26:16 2008 From: igouy2@REDACTED (Isaac Gouy) Date: Tue, 4 Nov 2008 18:26:16 -0800 (PST) Subject: [erlang-questions] Why isn't erlang strongly typed? In-Reply-To: Message-ID: <948309.65808.qm@web65403.mail.ac4.yahoo.com> --- Richard O'Keefe wrote: > > On 5 Nov 2008, at 12:33 pm, Isaac Gouy wrote: > >> Traits don't disallow access to state. > >> They disallow *direct* access to state. > >> They can use as much state as they want, > >> provided they do so by calling methods from the > >> class they are extending. > > > > In other words, traits disallow access to state and require methods > in > > the class (not in the trait) for access to state :-) > > Many Smalltalk masters recommend what's called "self-encapsulation" > where ANY class should encapsulate access to its state variables in > a small handful of methods and ALL other methods should use those > to access state rather that directly referring to instance variables. Famously Alan Snyder in "Encapsulation and Inheritance in Object-Oriented Programming Languages" 1986 http://citeseer.ist.psu.edu/old/snyder86encapsulation.html > Nobody says that this disallows access to state! Why would they when the class has state and it is accessed? :-) > On the contrary, people talk about calling such accessor methods > as "access to [state] data". See > http://www.martinfowler.com/bliki/SelfEncapsulation.html > for an example of this usage. The thing to remember about "accessor methods" in Smalltalk in contrast to "accessor methods" in Java, is that in Smalltalk they aren't "accessor methods" just methods - there's no well understood convention that 'they shall access state'. > Traits don't have any state of their own to access, > so they can hardly be said to disallow access to what does > not exist. For access to the state of the class they are > bound in with, traits rely on self-encapsulation, not as > a way of disallowing access to state, but as a way of > ENABLING it. Traits don't rely on "self encapsulation" - that would make the trait the "self" in "self encapsulation". Traits rely on a separate class providing "required methods", whether those "required methods" do in fact access state in the separate class is entirely up to that separate class. > To call this extended use of self-encapsulation > "disallowing access to state" would be rather like calling > windows devices for disallowing access to light. The window is in the class not in the trait. Anyway I doubt this is interesting to this audience - not even Luke Gorrie ;-) From cappy2112@REDACTED Wed Nov 5 06:08:10 2008 From: cappy2112@REDACTED (Tony Cappellini) Date: Tue, 4 Nov 2008 21:08:10 -0800 Subject: [erlang-questions] Learning Erlang from the Armstrong book Message-ID: <8249c4ac0811042108y6dad1319xa8ee901cfa2ca3e3@mail.gmail.com> Learning a new language is always a pain. Having a "popular book" being recommended as "the place to start from", then struggling trying to figure out why the code in the "recommended book" doesn't work is even more frustrating. Almost 50 pages into the book the author has a panel which reads" Some readers have mistakenly typed into the shell fragements ocf code contained in the source code listings. These are not valid shell commands and you will get some strange error message if you try to do this". Why is this not in the front of the book? ;-) So how is a newbie supposed to know which code in the "recommended" book is valid? From monch1962@REDACTED Wed Nov 5 06:33:33 2008 From: monch1962@REDACTED (David Mitchell) Date: Wed, 5 Nov 2008 16:33:33 +1100 Subject: [erlang-questions] Learning Erlang from the Armstrong book In-Reply-To: <8249c4ac0811042108y6dad1319xa8ee901cfa2ca3e3@mail.gmail.com> References: <8249c4ac0811042108y6dad1319xa8ee901cfa2ca3e3@mail.gmail.com> Message-ID: I don't have the book handy at the moment so I can't check the panel you're referring to, but I can't recall having problems learning Erlang from Joe's book. I knew of Erlang's existence, and I'd been reading *about* it for a while, but I'd never encountered Erlang code before I opened the book for the first time. I struggled with OTP because it wasn't covered (much) in the book, but I thought the coverage of the Erlang language itself was very good. In particular, I don't recall any problem running the examples, although I probably didn't try every single one. Dave M. 2008/11/5 Tony Cappellini : > Learning a new language is always a pain. > > Having a "popular book" being recommended as "the place to start > from", then struggling trying to figure out why the code in the > "recommended book" doesn't work is even more frustrating. > Almost 50 pages into the book the author has a panel which reads" Some > readers have mistakenly typed into the shell fragements ocf code > contained in the source code listings. These are not valid shell > commands and you will get some strange error message if you try to do > this". > > Why is this not in the front of the book? ;-) > > So how is a newbie supposed to know which code in the "recommended" > book is valid? > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From vlm@REDACTED Wed Nov 5 06:58:25 2008 From: vlm@REDACTED (Lev Walkin) Date: Tue, 04 Nov 2008 21:58:25 -0800 Subject: [erlang-questions] Learning Erlang from the Armstrong book In-Reply-To: <8249c4ac0811042108y6dad1319xa8ee901cfa2ca3e3@mail.gmail.com> References: <8249c4ac0811042108y6dad1319xa8ee901cfa2ca3e3@mail.gmail.com> Message-ID: <49113601.3070905@lionet.info> Tony Cappellini wrote: > Learning a new language is always a pain. > > Having a "popular book" being recommended as "the place to start > from", then struggling trying to figure out why the code in the > "recommended book" doesn't work is even more frustrating. > Almost 50 pages into the book the author has a panel which reads" Some > readers have mistakenly typed into the shell fragements ocf code > contained in the source code listings. These are not valid shell > commands and you will get some strange error message if you try to do > this". > > Why is this not in the front of the book? ;-) > > So how is a newbie supposed to know which code in the "recommended" > book is valid? The book has many pages. If one start from some random page, there's always a chance of missing some of the important statements earlier in the book. If one reads through the book right from the beginning, there's certainly less chance to overlook something fundamental. That said, let's check the facts. The following notice appears precisely at the 27'th page, the very _next_ page after the very _first_ example involving the shell (page 28): Warning: You can?t type everything you read in this book into the shell. In particular, you can?t type the code that?s listed in the Erlang program ?les into the shell. The syntactic for ms in an .erl ?le are not expressions and are not understood by the shell. The shell can evaluate only Erlang expressions and doesn?t understand anything else. In particular, you can?t type module annotations into the shell; these are things that start with a hyphen (such as -module, -export, and so on). -- Lev Walkin vlm@REDACTED From cappy2112@REDACTED Wed Nov 5 07:27:46 2008 From: cappy2112@REDACTED (Tony Cappellini) Date: Tue, 4 Nov 2008 22:27:46 -0800 Subject: [erlang-questions] Learning Erlang from the Armstrong book In-Reply-To: <49113601.3070905@lionet.info> References: <8249c4ac0811042108y6dad1319xa8ee901cfa2ca3e3@mail.gmail.com> <49113601.3070905@lionet.info> Message-ID: <8249c4ac0811042227n5bca5871v8ab26a558281b658@mail.gmail.com> I didn't start on a random page. I've read it from the beginning to page 48- This is the page where the quote is that I posted in my message. >>That said, let's check the facts. The following notice appears > >>precisely at the 27'th page, the very _next_ page after the very > >>_first_ example involving the shell (page 28): This quote appears on Page 14 in my book. It's likely we have different printings > > >>Warning: You can't type everything you read in this book into I probably read this last week or so, when I had first started reading the book, but it's soemthing that didn't stick with me. I'm just spoiled with languages where I can type anything into their shells (syntactically correct that is) Is the code on page 54 supposed to work in the shell? -------------- next part -------------- An HTML attachment was scrubbed... URL: From ingela@REDACTED Wed Nov 5 08:20:19 2008 From: ingela@REDACTED (Ingela Anderton Andin) Date: Wed, 05 Nov 2008 08:20:19 +0100 Subject: [erlang-questions] Upgrading gen_tcp socket to ssl In-Reply-To: References: Message-ID: <49114933.5090405@erix.ericsson.se> Hi! > Hi All, > > In ssl-3.9, according to the documentation the connect/2 function allows > upgrading a gen_tcp socket to a ssl socket. This is true but only if you use the new ssl-implementation, which in ssl-3.9 was a very limited implementation, there for testing and feedback, and proably only works well for a few basic tested scenarios. > But when I try ssl:connect(Gen_tcp_socket,[{verify,0}]), I get > {eoptions,{cacertfile,[]}}. > The Gen_tcp_socket is a socket created using gen_tcp:connect/3. > > Since {verify,0}, why is a cacertfile required. > Verify options was one of the things that was not fully implemented. Ssl-3.10 will soon be out in R12B-5 and then the new ssl-implementation will be much more complete but still there are a few limitations left before it can completely replace the old ssl. You are welcome to try it and we are of course interested in any feedback that you might have. Regards Ingela Erlang/OTP - Ericsson From zambal@REDACTED Wed Nov 5 10:01:25 2008 From: zambal@REDACTED (zambal) Date: Wed, 5 Nov 2008 01:01:25 -0800 (PST) Subject: [erlang-questions] Learning Erlang from the Armstrong book In-Reply-To: <8249c4ac0811042108y6dad1319xa8ee901cfa2ca3e3@mail.gmail.com> References: <8249c4ac0811042108y6dad1319xa8ee901cfa2ca3e3@mail.gmail.com> Message-ID: <3a0e5856-af10-4977-9219-bb6858034056@b31g2000prf.googlegroups.com> On 5 nov, 06:08, "Tony Cappellini" wrote: > So how is a newbie supposed to know which code in the "recommended" > book is valid? All code in the book is valid. It's just that not all code are valid shell expressions. Maybe this seems odd in the beginning, but as you learn more about the language,the run-time system and how code is organised, it starts to make sense. For now, you just have to remember the used convention in the book that code examples that should be run from the shell start with a shell command prompt like this: 1> ..... 2> ..... 3> etc. and the rest of all examples is code that should be written in an erlang source file (*.erl files). These code listings are typically function definitions that look like this: some_funtion(Parameter) -> ..., .... another_funtion() -> ..., .... Good luck with learning Erlang. After the basics it should really become fun! -- vincent From shomodj@REDACTED Wed Nov 5 11:11:31 2008 From: shomodj@REDACTED (Boris Shomodjvarac) Date: Wed, 05 Nov 2008 11:11:31 +0100 Subject: [erlang-questions] object oriented programming and design pattern In-Reply-To: <1225840536.6561.18.camel@linux-box> References: <200811042216.mA4MGZne000621@morgoth.cslab.ericsson.net> <1225840536.6561.18.camel@linux-box> Message-ID: <49117153.3060607@gmail.com> Dan Rubino wrote: > Hi , > > I would recommend the Joe Armstrong book for learning Erlang and an > introduction to OTP. > > As far as implementing OO in FP I think what you are after is an > understanding of functional data structures. For that I recommend Chris > Okasaki's book "Purely functional data structures" - alot of it is lazy > however so doesnt apply to Erlang, interesting none the less. I'm trying to reed that book but examples are in ML and Haskell, so right now I'm reading The Little MLer in order to understand Chris book. Does anyone have any examples from that book written in Erlang? -- "A language that doesn't affect the way you think about programming, is not worth knowing" - Alan Perlis From vlm@REDACTED Wed Nov 5 11:36:26 2008 From: vlm@REDACTED (Lev Walkin) Date: Wed, 05 Nov 2008 02:36:26 -0800 Subject: [erlang-questions] object oriented programming and design pattern In-Reply-To: <49117153.3060607@gmail.com> References: <200811042216.mA4MGZne000621@morgoth.cslab.ericsson.net> <1225840536.6561.18.camel@linux-box> <49117153.3060607@gmail.com> Message-ID: <4911772A.2050606@lionet.info> Boris Shomodjvarac wrote: > Dan Rubino wrote: >> Hi , >> >> I would recommend the Joe Armstrong book for learning Erlang and an >> introduction to OTP. >> >> As far as implementing OO in FP I think what you are after is an >> understanding of functional data structures. For that I recommend Chris >> Okasaki's book "Purely functional data structures" - alot of it is lazy >> however so doesnt apply to Erlang, interesting none the less. > > I'm trying to reed that book but examples are in ML and Haskell, so > right now I'm reading The Little MLer in order to understand Chris book. > Does anyone have any examples from that book written in Erlang? > http://learnyouahaskell.com/ This is Haskell for children (with pictures). The first few chapters are just enough to understand the syntax. -- Lev Walkin vlm@REDACTED From wde@REDACTED Wed Nov 5 12:34:59 2008 From: wde@REDACTED (wde@REDACTED) Date: Wed, 5 Nov 2008 12:34:59 +0100 Subject: [erlang-questions] object oriented programmingand design pattern Message-ID: <200811051146.mA5BkekY001295@morgoth.cslab.ericsson.net> Thank you for your responses, I found an interesting document about design pattern and erlang : http://osmirrors.cerias.purdue.edu/pub/FreeBSD/ports/local-distfiles/olgeni/master_thesis_patterns.pdf ======= le 05/11/2008, 11:36:26 vous ?criviez: ======= >Boris Shomodjvarac wrote: >> Dan Rubino wrote: >>> Hi , >>> >>> I would recommend the Joe Armstrong book for learning Erlang and an >>> introduction to OTP. >>> >>> As far as implementing OO in FP I think what you are after is an >>> understanding of functional data structures. For that I recommend Chris >>> Okasaki's book "Purely functional data structures" - alot of it is lazy >>> however so doesnt apply to Erlang, interesting none the less. >> >> I'm trying to reed that book but examples are in ML and Haskell, so >> right now I'm reading The Little MLer in order to understand Chris book. >> Does anyone have any examples from that book written in Erlang? >> > >http://learnyouahaskell.com/ > >This is Haskell for children (with pictures). The first few chapters >are just enough to understand the syntax. > > >-- >Lev Walkin >vlm@REDACTED >_______________________________________________ >erlang-questions mailing list >erlang-questions@REDACTED >http://www.erlang.org/mailman/listinfo/erlang-questions > = = = = = = = = = ========= = = = = = = = = = = wde wde@REDACTED 05/11/2008 From bgustavsson@REDACTED Wed Nov 5 15:42:45 2008 From: bgustavsson@REDACTED (Bjorn Gustavsson) Date: Wed, 5 Nov 2008 15:42:45 +0100 Subject: [erlang-questions] Erlang/OTP R12B-5 has been released Message-ID: <6672d0160811050642x34902d2bp5fdcfef993386f0c@mail.gmail.com> Bug fix release : otp_src_R12B-5 Build date : 2008-11-05 This is bug fix release 5 for the R12B release. You can find the README file for the release at http://www.erlang.org/download/otp_src_R12B-5.readme The source distribution and binary distribution for Windows can be downloaded from http://www.erlang.org/download/otp_src_R12B-5.tar.gz http://www.erlang.org/download/otp_win32_R12B-5.exe The distribution can also be downloaded using the BitTorrent protocol. Use the following torrent files to download the source distribution and binary distribution for Windows: http://www.erlang.org/download/otp_src_R12B-5.tar.gz.torrent http://www.erlang.org/download/otp_win32_R12B-5.exe.torrent Note: To unpack the TAR archive you need a GNU TAR compatible program. For installation instructions please read the README file that is part of the distribution. The on-line documentation can be found at: http://www.erlang.org/doc/ You can also download the complete HTML documentation or the Unix manual files http://www.erlang.org/download/otp_doc_html_R12B-5.tar.gz http://www.erlang.org/download/otp_doc_man_R12B-5.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 dave.smith.to@REDACTED Wed Nov 5 16:29:19 2008 From: dave.smith.to@REDACTED (Dave Smith) Date: Wed, 5 Nov 2008 10:29:19 -0500 Subject: [erlang-questions] Learning Erlang from the Armstrong book In-Reply-To: <8249c4ac0811042227n5bca5871v8ab26a558281b658@mail.gmail.com> References: <8249c4ac0811042108y6dad1319xa8ee901cfa2ca3e3@mail.gmail.com> <49113601.3070905@lionet.info> <8249c4ac0811042227n5bca5871v8ab26a558281b658@mail.gmail.com> Message-ID: <5ea453f90811050729n2809fcfdu6534f14168b67034@mail.gmail.com> >>I'm just spoiled with languages where I can type anything into their shells (syntactically correct It's a minor limitation -- I think you'll find the shell to be a very useful tool. And Joe's book is an excellent introduction to the language. -------------- next part -------------- An HTML attachment was scrubbed... URL: From colm.dougan@REDACTED Wed Nov 5 19:08:59 2008 From: colm.dougan@REDACTED (Colm Dougan) Date: Wed, 5 Nov 2008 18:08:59 +0000 Subject: [erlang-questions] Idiom for multiple case matches Message-ID: <24d4f39c0811051008n1ad4ed72o5f20b783a092a2f0@mail.gmail.com> Hi, I often find myself writing code like this : (Note: I'm only using vowels as a contrived example here). case Char of Vowel when Vowel =:= $a; Vowel =:= $e; Vowel =:= $i; Vowel =:= $o; Vowel =:= $u -> io:format("Handling vowel~n"); _ -> io:format("Not a vowel~n") end. Is there any better idiom for this? It usually becomes long-winded. For example, it would seem ideal to be able to do this : case Char of $a; $e; $i; $o; $u -> io:format("Handling vowel~n"); _ -> io:format("Not a vowel~n") end. Yeah I realise I could write function either with one massive guard statement or something like this : handle_char($a) -> handle_vowel($a); handle_char($e) -> handle_vowel($e); handle_char($i) -> handle_vowel($i); handle_char($o) -> handle_vowel($o); handle_char($u) -> handle_vowel($u); handle_char(Char) -> handle_non_vowel(Char). .. which is a nice approach but sometimes an inline case statement is all you want. Thanks,. Colm From karol.skocik@REDACTED Wed Nov 5 19:27:30 2008 From: karol.skocik@REDACTED (karol skocik) Date: Wed, 5 Nov 2008 19:27:30 +0100 Subject: [erlang-questions] Idiom for multiple case matches In-Reply-To: <24d4f39c0811051008n1ad4ed72o5f20b783a092a2f0@mail.gmail.com> References: <24d4f39c0811051008n1ad4ed72o5f20b783a092a2f0@mail.gmail.com> Message-ID: You might consider case lists:member(Char, [$a, $e, $i, $o, $u]) of true -> io:format("Handling vowel~n"); false -> io:format("Not a vowel~n") end. a viable approach, esp. because you can extract the list inside member() when you need it on more places. On Wed, Nov 5, 2008 at 7:08 PM, Colm Dougan wrote: > Hi, > > I often find myself writing code like this : > > (Note: I'm only using vowels as a contrived example here). > > case Char of > Vowel when Vowel =:= $a; > Vowel =:= $e; > Vowel =:= $i; > Vowel =:= $o; > Vowel =:= $u -> > io:format("Handling vowel~n"); > _ -> > io:format("Not a vowel~n") > end. > > Is there any better idiom for this? It usually becomes long-winded. > For example, it would seem ideal to be able to do this : > > case Char of > $a; $e; $i; $o; $u -> > io:format("Handling vowel~n"); > _ -> > io:format("Not a vowel~n") > end. > > Yeah I realise I could write function either with one massive guard > statement or something like this : > > handle_char($a) -> handle_vowel($a); > handle_char($e) -> handle_vowel($e); > handle_char($i) -> handle_vowel($i); > handle_char($o) -> handle_vowel($o); > handle_char($u) -> handle_vowel($u); > handle_char(Char) -> handle_non_vowel(Char). > > .. which is a nice approach but sometimes an inline case statement is > all you want. > > Thanks,. > Colm > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From koops.j@REDACTED Wed Nov 5 22:03:08 2008 From: koops.j@REDACTED (Jeroen Koops) Date: Wed, 5 Nov 2008 22:03:08 +0100 Subject: [erlang-questions] Invoking function as record-member Message-ID: <331a9abb0811051303w2d05ad5foe2203e25cce51379@mail.gmail.com> Hello, I have a record with a member to which I assign a function: $ cat test.hrl -record(test, { my_fun }). $ and, from the Erlang shell: 18> rr("test.hrl"). [test] 19> X=#test{my_fun = fun(X) -> X*2 end}. #test{my_fun = #Fun} When I try to invoke the function, the shell complains with a syntax error: 20> X#test.my_fun(1). ** 1: syntax error before: '(' ** Of course, it does work when first assigning the record-member to a variable: 21> Y=X#test.my_fun. #Fun 22> Y(1). 2 Is there some syntactical subtlety I'm missing out on, or is this something I should just not want? Thanks, Jeroen -------------- next part -------------- An HTML attachment was scrubbed... URL: From erlang-questions_efine@REDACTED Wed Nov 5 22:26:34 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Wed, 5 Nov 2008 16:26:34 -0500 Subject: [erlang-questions] Invoking function as record-member In-Reply-To: <331a9abb0811051303w2d05ad5foe2203e25cce51379@mail.gmail.com> References: <331a9abb0811051303w2d05ad5foe2203e25cce51379@mail.gmail.com> Message-ID: <6c2563b20811051326m1012d43co19db4613db10a07a@mail.gmail.com> It's a precedence problem. 4> rd(test, {my_fun}). test 5> MyFun = fun() -> "Hello" end. #Fun 6> MyRec = #test{my_fun = MyFun}. #test{my_fun = #Fun} 7> MyRec#test.my_fun(). * 1: syntax error before: '(' 7> (MyRec#test.my_fun)(). "Hello" 2008/11/5 Jeroen Koops > Hello, > > I have a record with a member to which I assign a function: > > $ cat test.hrl > -record(test, { my_fun }). > $ > > and, from the Erlang shell: > > 18> rr("test.hrl"). > [test] > 19> X=#test{my_fun = fun(X) -> X*2 end}. > #test{my_fun = #Fun} > > When I try to invoke the function, the shell complains with a syntax error: > > 20> X#test.my_fun(1). > ** 1: syntax error before: '(' ** > > Of course, it does work when first assigning the record-member to a > variable: > > 21> Y=X#test.my_fun. > #Fun > 22> Y(1). > 2 > > Is there some syntactical subtlety I'm missing out on, or is this something > I should just not want? > > Thanks, > > Jeroen > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lestat@REDACTED Wed Nov 5 22:29:05 2008 From: lestat@REDACTED (Tamas Nagy) Date: Wed, 5 Nov 2008 21:29:05 +0000 Subject: [erlang-questions] Invoking function as record-member In-Reply-To: <331a9abb0811051303w2d05ad5foe2203e25cce51379@mail.gmail.com> References: <331a9abb0811051303w2d05ad5foe2203e25cce51379@mail.gmail.com> Message-ID: <11C5A1C6-35F2-44CD-8F4A-F4CF80D89248@elte.hu> Hi! Try it like this: (X#test.my_fun)(1). Regards, Tamas On 5 Nov 2008, at 21:03, Jeroen Koops wrote: > Hello, > > I have a record with a member to which I assign a function: > > $ cat test.hrl > -record(test, { my_fun }). > $ > > and, from the Erlang shell: > > 18> rr("test.hrl"). > [test] > 19> X=#test{my_fun = fun(X) -> X*2 end}. > #test{my_fun = #Fun} > > When I try to invoke the function, the shell complains with a syntax > error: > > 20> X#test.my_fun(1). > ** 1: syntax error before: '(' ** > > Of course, it does work when first assigning the record-member to a > variable: > > 21> Y=X#test.my_fun. > #Fun > 22> Y(1). > 2 > > Is there some syntactical subtlety I'm missing out on, or is this > something I should just not want? > > Thanks, > > Jeroen > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From nem@REDACTED Thu Nov 6 00:03:29 2008 From: nem@REDACTED (Geoff Cant) Date: Thu, 06 Nov 2008 00:03:29 +0100 Subject: [erlang-questions] Post-EUC Erlang meetup Message-ID: Hi all, I'm going to be in Stockholm for a while after the EUC and was wondering if anyone was interested in getting together to discuss/hack on Erlang. I have some libraries to show, EEP ideas to discuss, and I'd love to hear about any projects people have been working on that didn't make the conference program. Who's interested? Also, any recommendations from Stockholm locals for a venue? Cheers, -- Geoff Cant From jebenitez@REDACTED Wed Nov 5 23:15:41 2008 From: jebenitez@REDACTED (Jose Enrique Benitez Jimenez) Date: Wed, 5 Nov 2008 17:15:41 -0500 Subject: [erlang-questions] Mnesia dynamic table creation Message-ID: Hello, I was study mnesia, and so far I dont know how to create a table in run-time, because the records most be set in the code before I compile it, How can I do that? Thank you very much. From kevin@REDACTED Thu Nov 6 04:37:12 2008 From: kevin@REDACTED (Kevin A. Smith) Date: Wed, 5 Nov 2008 22:37:12 -0500 Subject: [erlang-questions] R12B-5 and eunit Message-ID: <711C554A-53D6-4E10-8339-50EC3DE6C5D1@hypotheticalabs.com> I think I've found a bug in the eunit application. It looks like the header file, eunit.hrl, is missing. In fact, the entire include directory is missing from the application. I was really excited by the inclusion of eunit into the standard OTP releases since I think it's an excellent unit testing framework. Any chance we'll see a re-release of R12B-5 with this error fixed? --Kevin From erlangy@REDACTED Thu Nov 6 06:52:17 2008 From: erlangy@REDACTED (Michael McDaniel) Date: Wed, 5 Nov 2008 21:52:17 -0800 Subject: [erlang-questions] Erlang/OTP R12B-5 has been released In-Reply-To: <6672d0160811050642x34902d2bp5fdcfef993386f0c@mail.gmail.com> References: <6672d0160811050642x34902d2bp5fdcfef993386f0c@mail.gmail.com> Message-ID: <20081106055214.GP7020@delora.autosys.us> As always, thank you to the OTP team. Please mention where the MD5 sums reside for the releases; the obvious MD5 file candidate in the downloads directory appears empty. thanks, ~Michael On Wed, Nov 05, 2008 at 03:42:45PM +0100, Bjorn Gustavsson wrote: > Bug fix release : otp_src_R12B-5 > Build date : 2008-11-05 > > This is bug fix release 5 for the R12B release. > > You can find the README file for the release at > > http://www.erlang.org/download/otp_src_R12B-5.readme > > The source distribution and binary distribution for Windows can be > downloaded from > > http://www.erlang.org/download/otp_src_R12B-5.tar.gz > http://www.erlang.org/download/otp_win32_R12B-5.exe > > The distribution can also be downloaded using the BitTorrent > protocol. Use the following torrent files to download the source > distribution and binary distribution for Windows: > > http://www.erlang.org/download/otp_src_R12B-5.tar.gz.torrent > http://www.erlang.org/download/otp_win32_R12B-5.exe.torrent > > Note: To unpack the TAR archive you need a GNU TAR compatible program. > > For installation instructions please read the README file that is part > of the distribution. > > The on-line documentation can be found at: http://www.erlang.org/doc/ > You can also download the complete HTML documentation or the Unix manual files > > http://www.erlang.org/download/otp_doc_html_R12B-5.tar.gz > http://www.erlang.org/download/otp_doc_man_R12B-5.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 > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From koops.j@REDACTED Thu Nov 6 09:17:49 2008 From: koops.j@REDACTED (Jeroen Koops) Date: Thu, 6 Nov 2008 09:17:49 +0100 Subject: [erlang-questions] Invoking function as record-member In-Reply-To: <11C5A1C6-35F2-44CD-8F4A-F4CF80D89248@elte.hu> References: <331a9abb0811051303w2d05ad5foe2203e25cce51379@mail.gmail.com> <11C5A1C6-35F2-44CD-8F4A-F4CF80D89248@elte.hu> Message-ID: <331a9abb0811060017o5d9e6675t14bd451380aabd9b@mail.gmail.com> Thanks all! On Wed, Nov 5, 2008 at 10:29 PM, Tamas Nagy wrote: > Hi! > > Try it like this: > > (X#test.my_fun)(1). > > Regards, > Tamas > > On 5 Nov 2008, at 21:03, Jeroen Koops wrote: > > Hello, >> >> I have a record with a member to which I assign a function: >> >> $ cat test.hrl >> -record(test, { my_fun }). >> $ >> >> and, from the Erlang shell: >> >> 18> rr("test.hrl"). >> [test] >> 19> X=#test{my_fun = fun(X) -> X*2 end}. >> #test{my_fun = #Fun} >> >> When I try to invoke the function, the shell complains with a syntax >> error: >> >> 20> X#test.my_fun(1). >> ** 1: syntax error before: '(' ** >> >> Of course, it does work when first assigning the record-member to a >> variable: >> >> 21> Y=X#test.my_fun. >> #Fun >> 22> Y(1). >> 2 >> >> Is there some syntactical subtlety I'm missing out on, or is this >> something I should just not want? >> >> Thanks, >> >> Jeroen >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bgustavsson@REDACTED Thu Nov 6 09:28:34 2008 From: bgustavsson@REDACTED (Bjorn Gustavsson) Date: Thu, 6 Nov 2008 09:28:34 +0100 Subject: [erlang-questions] Erlang/OTP R12B-5 has been released In-Reply-To: <20081106055214.GP7020@delora.autosys.us> References: <6672d0160811050642x34902d2bp5fdcfef993386f0c@mail.gmail.com> <20081106055214.GP7020@delora.autosys.us> Message-ID: <6672d0160811060028n39ad0273tbb9ed8c7d140f168@mail.gmail.com> On Thu, Nov 6, 2008 at 6:52 AM, Michael McDaniel wrote: > As always, thank you to the OTP team. > > Please mention where the MD5 sums reside for the releases; the obvious > MD5 file candidate in the downloads directory appears empty. > Thanks! The MD5 file in the downloads directory has now been corrected. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From pguyot@REDACTED Thu Nov 6 10:06:11 2008 From: pguyot@REDACTED (Paul Guyot) Date: Thu, 6 Nov 2008 10:06:11 +0100 Subject: [erlang-questions] erlang-questions Digest, Vol 18, Issue 14 In-Reply-To: References: Message-ID: <62858BE3-1C6F-42C6-8AB9-C1D86CF26F3C@kallisys.net> > Date: Wed, 5 Nov 2008 15:42:45 +0100 > From: "Bjorn Gustavsson" > Subject: [erlang-questions] Erlang/OTP R12B-5 has been released > To: "erlang-questions@REDACTED" , > erlang-announce@REDACTED > Message-ID: > <6672d0160811050642x34902d2bp5fdcfef993386f0c@REDACTED> > Content-Type: text/plain; charset=ISO-8859-1 > > Bug fix release : otp_src_R12B-5 > Build date : 2008-11-05 > > This is bug fix release 5 for the R12B release. > > You can find the README file for the release at > > http://www.erlang.org/download/otp_src_R12B-5.readme Congratulation for the release. Thank you very much for the inclusion of patches and fixes, especially copy_hostent and dlopen on MacOS X. The inclusion of eunit into OTP is great news! However, as mentioned by Kevin Smith, eunit just doesn't work from OTP because eunit.hrl is missing. I also wish that the following bug fixes and enhancement were included, so we wouldn't have to run patched versions on production and test servers: Fix #1 ei_decode_big just doesn't work for half of big nums. ei_encode_big and ei_x_encode_big are missing. http://www.erlang.org/pipermail/erlang-bugs/2008-October/001023.html Fix #2 ei_decode_fun just doesn't work. http://www.erlang.org/pipermail/erlang-bugs/2008-October/001024.html Fix #3 calendar:local_time_to_universal_time_dst crashes on FreeBSD with TZ set to UTC, and maybe in other conditions. http://www.erlang.org/pipermail/erlang-bugs/2008-November/001077.html Enhancement #1 eunit to generate XML reports for easier integration with continuous integration toolchains (e.g. maven-erlang). http://support.process-one.net/browse/EUNIT-13 Would it be possible to have a timeframe for those? Regards, Paul From richardc@REDACTED Thu Nov 6 10:48:46 2008 From: richardc@REDACTED (Richard Carlsson) Date: Thu, 06 Nov 2008 10:48:46 +0100 Subject: [erlang-questions] R12B-5 and eunit In-Reply-To: <711C554A-53D6-4E10-8339-50EC3DE6C5D1@hypotheticalabs.com> References: <711C554A-53D6-4E10-8339-50EC3DE6C5D1@hypotheticalabs.com> Message-ID: <4912BD7E.7050707@it.uu.se> Kevin A. Smith wrote: > I think I've found a bug in the eunit application. It looks like the > header file, eunit.hrl, is missing. In fact, the entire include > directory is missing from the application. > > I was really excited by the inclusion of eunit into the standard OTP > releases since I think it's an excellent unit testing framework. Any > chance we'll see a re-release of R12B-5 with this error fixed? Looks like it's 'make install' that's broken - the file is included in the tarball and eunit builds without any problems, but the include directory is not copied during installation. The quick fix is to copy lib/eunit/include manually from the sources to the installation. The file is not included at all in the Windows distribution, and if you don't want to download and unpack the tarball, you can get the header directly from http://svn.process-one.net/contribs/trunk/eunit/include/ /Richard From tony@REDACTED Thu Nov 6 11:33:12 2008 From: tony@REDACTED (Tony Rogvall) Date: Thu, 6 Nov 2008 11:33:12 +0100 Subject: [erlang-questions] Problems with compiling esock_ssl solved Message-ID: Hi list! For you building on mac os x and stumble on this: I have a /opt/local installation of openssl 0.9.8 from macports and a "standard" 0.9.7 installation from Apple (will openssl ever reach 1.0 ;-) When configure without thinking about it, there will then be a linking problem since the compiler gcc4.0.1 will select headers from /opt/local/include (for some obscure reason) and libraries from /usr/lib. To solve this then do: configure --with-ssl=/opt/local ... to select the openssl from macports. Unfortunately 0.9.8 need zlib so you have to patch the ssl/c_src/ Makefile to add -lz maybe this could be done by default to next otp release? Hopefully someone has a better solution? totally confused (as always)! /Tony From zambal@REDACTED Thu Nov 6 13:15:34 2008 From: zambal@REDACTED (zambal) Date: Thu, 6 Nov 2008 04:15:34 -0800 (PST) Subject: [erlang-questions] Mnesia dynamic table creation In-Reply-To: References: Message-ID: Since records are in fact tupples, just use tupples instead of records. Example: Eshell V5.6.5 (abort with ^G) 1> mnesia:create_schema([node()]). ok 2> mnesia:start(). ok 3> mnesia:create_table(my_doc, [{attributes, [title, author, tags, body]}]). {atomic,ok} 4> mnesia:transaction(fun()-> mnesia:write({my_doc, "my first doc", "vincent", ["example", "programming"], "blah blah blah blah ..."}) end). {atomic,ok} 5> mnesia:transaction(fun()-> qlc:e(qlc:q([X || X <- mnesia:table(my_doc)])) end). {atomic,[{my_doc,"my first doc","vincent", ["example","programming"], "blah blah blah blah ..."}]} The only downside of this is that you can not use the records syntax for extracting individual fields from the resulting tupples. --- vincent On 5 nov, 23:15, "Jose Enrique Benitez Jimenez" wrote: > Hello, I was study mnesia, and so far I dont know how to create a table in run-time, because the records most be set in the code before I compile it, How can I do that? > > Thank you very much. > > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions From bgustavsson@REDACTED Thu Nov 6 14:24:57 2008 From: bgustavsson@REDACTED (Bjorn Gustavsson) Date: Thu, 6 Nov 2008 14:24:57 +0100 Subject: [erlang-questions] R12B-5 and eunit In-Reply-To: <4912BD7E.7050707@it.uu.se> References: <711C554A-53D6-4E10-8339-50EC3DE6C5D1@hypotheticalabs.com> <4912BD7E.7050707@it.uu.se> Message-ID: <6672d0160811060524q1ef0d4fcu2ef7e583c72d56e5@mail.gmail.com> On Thu, Nov 6, 2008 at 10:48 AM, Richard Carlsson wrote: > Looks like it's 'make install' that's broken - the file is included > in the tarball and eunit builds without any problems, but the include > directory is not copied during installation. The quick fix is to copy > lib/eunit/include manually from the sources to the installation. The > file is not included at all in the Windows distribution, and if you > don't want to download and unpack the tarball, you can get the header > directly from http://svn.process-one.net/contribs/trunk/eunit/include/ Yes, that was the problem. We usually don't do re-releases, but since the problem was in a Makefile (and not in any code), we have corrected lib/eunit/src/Makefile in the source tar file so that 'make install' will now install eunit.hrl. We have not corrected the Windows binary release, so on Windows you will have to install eunit.hrl yourself. You can find it here: http://www.erlang.org/download/eunit.hrl /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From dawsdesign@REDACTED Thu Nov 6 19:05:23 2008 From: dawsdesign@REDACTED (Matt Williamson) Date: Thu, 6 Nov 2008 13:05:23 -0500 Subject: [erlang-questions] Problems with sending UDP datagrams without buffering In-Reply-To: <4907A8A1.2090701@echostar.com> References: <4907A8A1.2090701@echostar.com> Message-ID: It's apparent from the subject, that Mark is talking about UDP datagrams. I agree with Trevor's suggestion. Check out http://www.erlang.org/doc/man/inet.html#setopts-2 {sndbuf, Integer}Gives the size of the send buffer to use for the socket. So: gen_udp:open( Port, [binary, {sndbuf, 700}] ). On Tue, Oct 28, 2008 at 7:04 PM, Mark Geib wrote: > I have a case where I MUST send datagrams that are smaller than a > network frame. The device I am sending to will not except larger datagrams. > > I am sending message that are less than 700 bytes in length, but on the > network using a sniffer I periodically see datagrams from the > application that are 7000 bytes or so in size. The data is correct, the > end device will not accept. > > I am sending these datagrams about every 20 miliseconds. > > Is there an option I am missing to force every gen_dup:send() to cause > the datagram to be sent.?? I am running on linux 2.6.27 kernel. > > -- > Principal Engineer > Cheyenne Software Engineering > mark.geib@REDACTED / 35-215 > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From pfisher@REDACTED Thu Nov 6 19:22:45 2008 From: pfisher@REDACTED (Paul Fisher) Date: Thu, 06 Nov 2008 12:22:45 -0600 Subject: [erlang-questions] driver_entry stop() and driver_async() interaction In-Reply-To: <48F75F09.7020108@alertlogic.net> References: <48F75F09.7020108@alertlogic.net> Message-ID: <491335F5.3060602@alertlogic.net> Can anyone comment on this question i sent a few weeks ago? When the port owner terminates and there are driver_async() requests scheduled and not yet executed, I am seeing them outstanding at the time of the stop() callback. Paul Fisher wrote: > Question about work scheduled on async threads via driver_async() and > still pending (i.e. they are still on the queue to be executed,) when > the stop() callback is invoked. Specifically, assuming smp w/async > thread pool and the driver marked ERL_DRV_FLAG_USE_PORT_LOCKING. > > Is it the responsibility of the code in the stop() callback to call > driver_async_cancel() on each outstanding async work item, or will this > be done automatically by the emulator before the call to stop()? > > If this is the responsibility of the code in stop(), is it guaranteed > that no async work item will be executing or scheduled during the call > to the stop() callback? > > If no guarantee is made, is holding the PDL necessary and sufficient to > guarantee this? -- paul From per@REDACTED Thu Nov 6 21:19:02 2008 From: per@REDACTED (Per Hedeland) Date: Thu, 6 Nov 2008 21:19:02 +0100 (CET) Subject: [erlang-questions] Problems with sending UDP datagrams without buffering In-Reply-To: Message-ID: <200811062019.mA6KJ256065896@pluto.hedeland.org> "Matt Williamson" wrote: > >It's apparent from the subject, that Mark is talking about UDP datagrams. Yes but... >I agree with Trevor's suggestion. Check out >http://www.erlang.org/doc/man/inet.html#setopts-2 > > >{sndbuf, Integer}Gives the size of the send buffer to use for the socket. >So: gen_udp:open( Port, [binary, {sndbuf, 700}] ). ...as has already been pointed out by Matthias, there's no way Erlang or anything else could be "merging" multiple UDP datagrams into one without completely wreaking havoc with UDP semantics - no matter what "buffering" is specified where, it simply won't happen. If Mark wants to see some progress here, he should follow Matthias' advice and provide a small program + instructions that would allow someone else to reproduce what he's seeing - and then we would likely find that he isn't doing what he thinks he is doing, or isn't seeing what he thinks he is seeing.:-) --Per Hedeland From rvirding@REDACTED Thu Nov 6 22:38:56 2008 From: rvirding@REDACTED (Robert Virding) Date: Thu, 6 Nov 2008 22:38:56 +0100 Subject: [erlang-questions] Post-EUC Erlang meetup In-Reply-To: References: Message-ID: <3dbc6d1c0811061338t58231218qce426a176cedab86@mail.gmail.com> I wouldn't mind having a little post EUC meeting. Robert 2008/11/6 Geoff Cant > > Hi all, I'm going to be in Stockholm for a while after the EUC and was > wondering if anyone was interested in getting together to discuss/hack > on Erlang. > > I have some libraries to show, EEP ideas to discuss, and I'd love to > hear about any projects people have been working on that didn't make the > conference program. > > Who's interested? Also, any recommendations from Stockholm locals for a > venue? > > Cheers, > -- > Geoff Cant > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From anders.nygren@REDACTED Thu Nov 6 23:35:28 2008 From: anders.nygren@REDACTED (Anders Nygren) Date: Thu, 6 Nov 2008 16:35:28 -0600 Subject: [erlang-questions] Post-EUC Erlang meetup In-Reply-To: <3dbc6d1c0811061338t58231218qce426a176cedab86@mail.gmail.com> References: <3dbc6d1c0811061338t58231218qce426a176cedab86@mail.gmail.com> Message-ID: Me too :) I will be in Stockholm 11 Nov - 17 Nov /Anders 2008/11/6 Robert Virding : > I wouldn't mind having a little post EUC meeting. > > Robert > > 2008/11/6 Geoff Cant >> >> Hi all, I'm going to be in Stockholm for a while after the EUC and was >> wondering if anyone was interested in getting together to discuss/hack >> on Erlang. >> >> I have some libraries to show, EEP ideas to discuss, and I'd love to >> hear about any projects people have been working on that didn't make the >> conference program. >> >> Who's interested? Also, any recommendations from Stockholm locals for a >> venue? >> >> Cheers, >> -- >> Geoff Cant >> >> _______________________________________________ >> 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 fritchie@REDACTED Fri Nov 7 06:44:41 2008 From: fritchie@REDACTED (Scott Lystig Fritchie) Date: Thu, 06 Nov 2008 23:44:41 -0600 Subject: [erlang-questions] running out of memory trying to add_frag on a large mnesia table In-Reply-To: Message of "Tue, 04 Nov 2008 16:04:31 PST." Message-ID: <46569.1226036681@snookles.snookles.com> Marc Sugiyama wrote: ms> I have a large, fragmented mnesia table. I'm trying to add more ms> fragments to it (see below). Marc, it's been a while since I've tried it, but you may be in a case of "Doctor, it hurts when....", unfortunately. IIRC, Mnesia uses temporary ETS tables for items that are being moved from one fragment to another. I have dim (and quite negative) memories not of memory exhaustion but of CPU exhaustion: the ETS tables were 'bag' or 'duplicate_bag' and thus have nasty O(N) behavior when trying to put more than 10-20K things into them. Back about two years ago (?), I posted a patch for Mnesia to use 'set' (or 'ordered_set') ETS tables instead ... then disavowed it, after I discovered bad behavior with the patch, too. :-( My "solution" was to create a table with 30 (approx.) or so fragments from the start. Then when adding a 31st fragment, the total number div 30 would be less than The ETS Major Pain Threshold of 10K or 20K or whatever it was. I'm going to guess that you'll need to use the mnesia dump, filter, and restore. Using the same hash function that mnesia_frag uses by default, your filter would spit out dump records with table names based on 70 fragments instead of your current 10. Er, and also replace the internal 'pvobject' state (inside the 'schema' table?) that contains the current fragmentation info with the new fragment number. And perhaps a few other bits. See mnesia:traverse_backup(), and get your fingers dirty with a few Mnesia internal details. A simple transformer fun to pretty-print the backup stream, helping to show what bits you may need to transform with a real fun. -Scott From vladdu55@REDACTED Fri Nov 7 09:35:10 2008 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Fri, 7 Nov 2008 09:35:10 +0100 Subject: [erlang-questions] extended jinterface Message-ID: <95be1d3b0811070035l246f8666g692716017a94db89@mail.gmail.com> Hi, This message is for anyone that is using jinterface. While working with erlide, I have added things to the basic jinterface library, most interesting being probably the equivalents of erl_format and erl_match, allowing for less painful term construction and deconstruction. There are also conversion routines from Java types to Erlang types, a Erlang to Java RPC mechanism (including generating erlang modules from java interfaces), routines to query epmd, and more. I think that it would be useful to have those things separately from erlide, and it is also probable that others have their own extensions that they might want to share. So I wonder if there is enough interest to make these extensions available standalone (either as a separate download from erlide, or as a separate project if more people want to contribute). best regards, Vlad From rvirding@REDACTED Fri Nov 7 11:14:49 2008 From: rvirding@REDACTED (Robert Virding) Date: Fri, 7 Nov 2008 11:14:49 +0100 Subject: [erlang-questions] Idiom for multiple case matches In-Reply-To: <24d4f39c0811051008n1ad4ed72o5f20b783a092a2f0@mail.gmail.com> References: <24d4f39c0811051008n1ad4ed72o5f20b783a092a2f0@mail.gmail.com> Message-ID: <3dbc6d1c0811070214h742d3e4ah6ea425ca23c16706@mail.gmail.com> A reasonable way of doing it would be: case is_vowel(Char) of true -> ... ; false -> ... end with is_vowel($a) -> true; ... is_vowel(_) -> false. It is clear what you are doing and it is easy to extend is_vowel/1 with new rule when more vowels are added. It also has the benefit of abstracting out the tests and making sure that all vowel testing in the code will always be correct. Robert 2008/11/5 Colm Dougan > Hi, > > I often find myself writing code like this : > > (Note: I'm only using vowels as a contrived example here). > > case Char of > Vowel when Vowel =:= $a; > Vowel =:= $e; > Vowel =:= $i; > Vowel =:= $o; > Vowel =:= $u -> > io:format("Handling vowel~n"); > _ -> > io:format("Not a vowel~n") > end. > > Is there any better idiom for this? It usually becomes long-winded. > For example, it would seem ideal to be able to do this : > > case Char of > $a; $e; $i; $o; $u -> > io:format("Handling vowel~n"); > _ -> > io:format("Not a vowel~n") > end. > > Yeah I realise I could write function either with one massive guard > statement or something like this : > > handle_char($a) -> handle_vowel($a); > handle_char($e) -> handle_vowel($e); > handle_char($i) -> handle_vowel($i); > handle_char($o) -> handle_vowel($o); > handle_char($u) -> handle_vowel($u); > handle_char(Char) -> handle_non_vowel(Char). > > .. which is a nice approach but sometimes an inline case statement is > all you want. > > Thanks,. > Colm > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From raimo+erlang-questions@REDACTED Fri Nov 7 11:47:59 2008 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Fri, 7 Nov 2008 11:47:59 +0100 Subject: [erlang-questions] : driver_entry stop() and driver_async() interaction In-Reply-To: <491335F5.3060602@alertlogic.net> References: <48F75F09.7020108@alertlogic.net> <491335F5.3060602@alertlogic.net> Message-ID: <20081107104759.GA1287@erix.ericsson.se> On Thu, Nov 06, 2008 at 12:22:45PM -0600, Paul Fisher wrote: > Can anyone comment on this question i sent a few weeks ago? > > When the port owner terminates and there are driver_async() requests > scheduled and not yet executed, I am seeing them outstanding at the time > of the stop() callback. We will take a look at it and make it clear in some documentation and give you an answer. It will take a bit of code review to be certain... > > > Paul Fisher wrote: > > Question about work scheduled on async threads via driver_async() and > > still pending (i.e. they are still on the queue to be executed,) when > > the stop() callback is invoked. Specifically, assuming smp w/async > > thread pool and the driver marked ERL_DRV_FLAG_USE_PORT_LOCKING. > > > > Is it the responsibility of the code in the stop() callback to call > > driver_async_cancel() on each outstanding async work item, or will this > > be done automatically by the emulator before the call to stop()? > > > > If this is the responsibility of the code in stop(), is it guaranteed > > that no async work item will be executing or scheduled during the call > > to the stop() callback? > > > > If no guarantee is made, is holding the PDL necessary and sufficient to > > guarantee this? > > > -- > paul > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From r.b.lists@REDACTED Fri Nov 7 12:56:33 2008 From: r.b.lists@REDACTED (Roland Braito) Date: Fri, 07 Nov 2008 12:56:33 +0100 Subject: [erlang-questions] extended jinterface In-Reply-To: <95be1d3b0811070035l246f8666g692716017a94db89@mail.gmail.com> References: <95be1d3b0811070035l246f8666g692716017a94db89@mail.gmail.com> Message-ID: <20081107115633.307250@gmx.net> Hi, Yes i've been wanting something along these lines for quite some time now... Please make it available! Thanks, Roland -------- Original-Nachricht -------- > Datum: Fri, 7 Nov 2008 09:35:10 +0100 > Von: "Vlad Dumitrescu" > An: erlang-questions > Betreff: [erlang-questions] extended jinterface > Hi, > > This message is for anyone that is using jinterface. > > While working with erlide, I have added things to the basic jinterface > library, most interesting being probably the equivalents of erl_format > and erl_match, allowing for less painful term construction and > deconstruction. There are also conversion routines from Java types to > Erlang types, a Erlang to Java RPC mechanism (including generating > erlang modules from java interfaces), routines to query epmd, and > more. > > I think that it would be useful to have those things separately from > erlide, and it is also probable that others have their own extensions > that they might want to share. > > So I wonder if there is enough interest to make these extensions > available standalone (either as a separate download from erlide, or as > a separate project if more people want to contribute). > > best regards, > Vlad > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- GMX Download-Spiele: Preizsturz! Alle Puzzle-Spiele Deluxe ?ber 60% billiger. http://games.entertainment.gmx.net/de/entertainment/games/download/puzzle/index.html From saleyn@REDACTED Fri Nov 7 13:36:44 2008 From: saleyn@REDACTED (Serge Aleynikov) Date: Fri, 07 Nov 2008 07:36:44 -0500 Subject: [erlang-questions] extended jinterface In-Reply-To: <95be1d3b0811070035l246f8666g692716017a94db89@mail.gmail.com> References: <95be1d3b0811070035l246f8666g692716017a94db89@mail.gmail.com> Message-ID: <4914365C.50604@gmail.com> I would be interested in porting these to OTP.NET as I've been using that for the GUI part of our apps. Vlad Dumitrescu wrote: > Hi, > > This message is for anyone that is using jinterface. > > While working with erlide, I have added things to the basic jinterface > library, most interesting being probably the equivalents of erl_format > and erl_match, allowing for less painful term construction and > deconstruction. There are also conversion routines from Java types to > Erlang types, a Erlang to Java RPC mechanism (including generating > erlang modules from java interfaces), routines to query epmd, and > more. > > I think that it would be useful to have those things separately from > erlide, and it is also probable that others have their own extensions > that they might want to share. > > So I wonder if there is enough interest to make these extensions > available standalone (either as a separate download from erlide, or as > a separate project if more people want to contribute). > > best regards, > Vlad > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From dmitriid@REDACTED Fri Nov 7 14:36:47 2008 From: dmitriid@REDACTED (Dmitrii Dimandt) Date: Fri, 07 Nov 2008 15:36:47 +0200 Subject: [erlang-questions] extended jinterface In-Reply-To: <95be1d3b0811070035l246f8666g692716017a94db89@mail.gmail.com> References: <95be1d3b0811070035l246f8666g692716017a94db89@mail.gmail.com> Message-ID: <12655666D1E22BB3A7716906@F74D39FA044AA309EAEA14B9> Can't say I've used jinterface extensvely, but i can see how this can be useful in the future --On November 7, 2008 9:35:10 AM +0100 Vlad Dumitrescu wrote: > Hi, > > This message is for anyone that is using jinterface. > > While working with erlide, I have added things to the basic jinterface > library, most interesting being probably the equivalents of erl_format > and erl_match, allowing for less painful term construction and > deconstruction. There are also conversion routines from Java types to > Erlang types, a Erlang to Java RPC mechanism (including generating > erlang modules from java interfaces), routines to query epmd, and > more. > > I think that it would be useful to have those things separately from > erlide, and it is also probable that others have their own extensions > that they might want to share. > > So I wonder if there is enough interest to make these extensions > available standalone (either as a separate download from erlide, or as > a separate project if more people want to contribute). > > best regards, > Vlad > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From masse@REDACTED Fri Nov 7 15:22:47 2008 From: masse@REDACTED (mats cronqvist) Date: Fri, 07 Nov 2008 15:22:47 +0100 Subject: [erlang-questions] Idiom for multiple case matches In-Reply-To: <3dbc6d1c0811070214h742d3e4ah6ea425ca23c16706@mail.gmail.com> (Robert Virding's message of "Fri\, 7 Nov 2008 11\:14\:49 +0100") References: <24d4f39c0811051008n1ad4ed72o5f20b783a092a2f0@mail.gmail.com> <3dbc6d1c0811070214h742d3e4ah6ea425ca23c16706@mail.gmail.com> Message-ID: <87k5bf1uq0.fsf@sterlett.hq.kred> "Robert Virding" writes: > A reasonable way of doing it would be: > > case is_vowel(Char) of > true -> ... ; > false -> ... > end is_wovel(C) -> lists:member(C,"aeiouy"). mats From vychodil.hynek@REDACTED Fri Nov 7 16:07:52 2008 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Fri, 7 Nov 2008 16:07:52 +0100 Subject: [erlang-questions] Idiom for multiple case matches In-Reply-To: <87k5bf1uq0.fsf@sterlett.hq.kred> References: <24d4f39c0811051008n1ad4ed72o5f20b783a092a2f0@mail.gmail.com> <3dbc6d1c0811070214h742d3e4ah6ea425ca23c16706@mail.gmail.com> <87k5bf1uq0.fsf@sterlett.hq.kred> Message-ID: <20081107150753.7D8B824062@relay.gooddata.com> On Fri, Nov 7, 2008 at 3:22 PM, mats cronqvist wrote: > "Robert Virding" writes: > > > A reasonable way of doing it would be: > > > > case is_vowel(Char) of > > true -> ... ; > > false -> ... > > end > > > is_wovel(C) -> lists:member(C,"aeiouy"). It is slower than Robert's solution. If performance is significant lists:member solution is worse. > > > mats > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- --Hynek (Pichi) Vychodil -------------- next part -------------- An HTML attachment was scrubbed... URL: From dmercer@REDACTED Fri Nov 7 17:20:07 2008 From: dmercer@REDACTED (David Mercer) Date: Fri, 7 Nov 2008 10:20:07 -0600 Subject: [erlang-questions] List to proplist? In-Reply-To: <620F5FF0-93F8-4E0E-BBDA-5404E82BB054@cs.otago.ac.nz> References: <6c2563b20810192156i7516e69aqb4d0eda2e1ee98d9@mail.gmail.com> <620F5FF0-93F8-4E0E-BBDA-5404E82BB054@cs.otago.ac.nz> Message-ID: On Monday, October 20, 2008, Richard O'Keefe wrote > A version of unfold that I prefer is > > unfold(State, Splitter) -> > unfold(State, Splitter, []). > > unfold(State, Splitter, Acc) -> > case Splitter(State) > of [] -> lists:reverse(Acc) > ; [Item|State1] -> unfold(State1, Splitter, [Item|Acc]) > end. Why is a cons cell, [Item|State1], preferred over a tuple, {Item, State1}? Just wondering if there is a performance consideration or some other consideration that I am missing. Please advise. Thank-you. David Mercer From ulf@REDACTED Fri Nov 7 17:52:24 2008 From: ulf@REDACTED (Ulf Wiger) Date: Fri, 7 Nov 2008 17:52:24 +0100 Subject: [erlang-questions] Idiom for multiple case matches In-Reply-To: <20081107150753.7D8B824062@relay.gooddata.com> References: <24d4f39c0811051008n1ad4ed72o5f20b783a092a2f0@mail.gmail.com> <3dbc6d1c0811070214h742d3e4ah6ea425ca23c16706@mail.gmail.com> <87k5bf1uq0.fsf@sterlett.hq.kred> <20081107150753.7D8B824062@relay.gooddata.com> Message-ID: <8209f740811070852k2a8c9df6lf932035f9e9fd4f1@mail.gmail.com> It's slower, true, but both are fairly fast*, and the lists:member/2 solution is also very concise. * I ran a small benchmark. On the given machine, Robert's solution took ca 0.05 usec/call, while Mats's solution took ca 0.09 usec/call (on average, iterating 1000 over the set of vowels "aeiouyAEIOUY"). Using the smaller set "aeiouy", Robert's code still took 0.05 usec/call, while Mats's code used 0.08 usec. BR, Ulf W 2008/11/7 Hynek Vychodil : > > > On Fri, Nov 7, 2008 at 3:22 PM, mats cronqvist wrote: >> >> "Robert Virding" writes: >> >> > A reasonable way of doing it would be: >> > >> > case is_vowel(Char) of >> > true -> ... ; >> > false -> ... >> > end >> >> >> is_wovel(C) -> lists:member(C,"aeiouy"). > > It is slower than Robert's solution. If performance is significant > lists:member solution is worse. >> >> >> mats >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions > > > > -- > --Hynek (Pichi) Vychodil > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From erlang-questions_efine@REDACTED Fri Nov 7 18:12:43 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Fri, 7 Nov 2008 12:12:43 -0500 Subject: [erlang-questions] Idiom for multiple case matches In-Reply-To: <8209f740811070852k2a8c9df6lf932035f9e9fd4f1@mail.gmail.com> References: <24d4f39c0811051008n1ad4ed72o5f20b783a092a2f0@mail.gmail.com> <3dbc6d1c0811070214h742d3e4ah6ea425ca23c16706@mail.gmail.com> <87k5bf1uq0.fsf@sterlett.hq.kred> <20081107150753.7D8B824062@relay.gooddata.com> <8209f740811070852k2a8c9df6lf932035f9e9fd4f1@mail.gmail.com> Message-ID: <6c2563b20811070912l1f79eda9i3345c6d0ce2ab9a@mail.gmail.com> Ulf, Isn't there also more garbage (as in GC) created by Mats' solution? Doesn't the list "aeiouy" get created and destroyed every time, or does the compiler "know" it is constant and make one constant copy of it that is not GC'ed? Regards, Edwin Fine On Fri, Nov 7, 2008 at 11:52 AM, Ulf Wiger wrote: > It's slower, true, but both are fairly fast*, and the lists:member/2 > solution is also very concise. > > * I ran a small benchmark. On the given machine, Robert's > solution took ca 0.05 usec/call, while Mats's solution took > ca 0.09 usec/call (on average, iterating 1000 over the set of > vowels "aeiouyAEIOUY"). Using the smaller set "aeiouy", > Robert's code still took 0.05 usec/call, while Mats's code > used 0.08 usec. > > BR, > Ulf W > > 2008/11/7 Hynek Vychodil : > > > > > > On Fri, Nov 7, 2008 at 3:22 PM, mats cronqvist > wrote: > >> > >> "Robert Virding" writes: > >> > >> > A reasonable way of doing it would be: > >> > > >> > case is_vowel(Char) of > >> > true -> ... ; > >> > false -> ... > >> > end > >> > >> > >> is_wovel(C) -> lists:member(C,"aeiouy"). > > > > It is slower than Robert's solution. If performance is significant > > lists:member solution is worse. > >> > >> > >> mats > >> _______________________________________________ > >> erlang-questions mailing list > >> erlang-questions@REDACTED > >> http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > > > > -- > > --Hynek (Pichi) Vychodil > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf@REDACTED Fri Nov 7 18:28:51 2008 From: ulf@REDACTED (Ulf Wiger) Date: Fri, 7 Nov 2008 18:28:51 +0100 Subject: [erlang-questions] Idiom for multiple case matches In-Reply-To: <6c2563b20811070912l1f79eda9i3345c6d0ce2ab9a@mail.gmail.com> References: <24d4f39c0811051008n1ad4ed72o5f20b783a092a2f0@mail.gmail.com> <3dbc6d1c0811070214h742d3e4ah6ea425ca23c16706@mail.gmail.com> <87k5bf1uq0.fsf@sterlett.hq.kred> <20081107150753.7D8B824062@relay.gooddata.com> <8209f740811070852k2a8c9df6lf932035f9e9fd4f1@mail.gmail.com> <6c2563b20811070912l1f79eda9i3345c6d0ce2ab9a@mail.gmail.com> Message-ID: <8209f740811070928m79dfb43cgb47ff9a9dc8fb6a8@mail.gmail.com> As of OTP R12B, constant terms are not re-created at each invocation, but created once at load time. BR, Ulf W 2008/11/7 Edwin Fine : > Ulf, > > Isn't there also more garbage (as in GC) created by Mats' solution? Doesn't > the list "aeiouy" get created and destroyed every time, or does the compiler > "know" it is constant and make one constant copy of it that is not GC'ed? > > Regards, > Edwin Fine > > On Fri, Nov 7, 2008 at 11:52 AM, Ulf Wiger wrote: >> >> It's slower, true, but both are fairly fast*, and the lists:member/2 >> solution is also very concise. >> >> * I ran a small benchmark. On the given machine, Robert's >> solution took ca 0.05 usec/call, while Mats's solution took >> ca 0.09 usec/call (on average, iterating 1000 over the set of >> vowels "aeiouyAEIOUY"). Using the smaller set "aeiouy", >> Robert's code still took 0.05 usec/call, while Mats's code >> used 0.08 usec. >> >> BR, >> Ulf W >> >> 2008/11/7 Hynek Vychodil : >> > >> > >> > On Fri, Nov 7, 2008 at 3:22 PM, mats cronqvist >> > wrote: >> >> >> >> "Robert Virding" writes: >> >> >> >> > A reasonable way of doing it would be: >> >> > >> >> > case is_vowel(Char) of >> >> > true -> ... ; >> >> > false -> ... >> >> > end >> >> >> >> >> >> is_wovel(C) -> lists:member(C,"aeiouy"). >> > >> > It is slower than Robert's solution. If performance is significant >> > lists:member solution is worse. >> >> >> >> >> >> mats >> >> _______________________________________________ >> >> erlang-questions mailing list >> >> erlang-questions@REDACTED >> >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > >> > >> > >> > -- >> > --Hynek (Pichi) Vychodil >> > >> > _______________________________________________ >> > erlang-questions mailing list >> > erlang-questions@REDACTED >> > http://www.erlang.org/mailman/listinfo/erlang-questions >> > >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > From chsu79@REDACTED Fri Nov 7 18:37:43 2008 From: chsu79@REDACTED (Christian) Date: Fri, 7 Nov 2008 18:37:43 +0100 Subject: [erlang-questions] Idiom for multiple case matches In-Reply-To: <6c2563b20811070912l1f79eda9i3345c6d0ce2ab9a@mail.gmail.com> References: <24d4f39c0811051008n1ad4ed72o5f20b783a092a2f0@mail.gmail.com> <3dbc6d1c0811070214h742d3e4ah6ea425ca23c16706@mail.gmail.com> <87k5bf1uq0.fsf@sterlett.hq.kred> <20081107150753.7D8B824062@relay.gooddata.com> <8209f740811070852k2a8c9df6lf932035f9e9fd4f1@mail.gmail.com> <6c2563b20811070912l1f79eda9i3345c6d0ce2ab9a@mail.gmail.com> Message-ID: And here is the release notes from R12B-0: > OTP-6850 Literal lists, tuples, and binaries are no longer constructed > at run-time as they used to be, but are stored in a > per-module constant pool. Literals that are used more than > once are stored only once. > > This is not a change to the language, only in the details of > its implementation. Therefore, the implications of this > change is described in the Efficiency Guide. 2008/11/7 Edwin Fine : > Ulf, > > Isn't there also more garbage (as in GC) created by Mats' solution? Doesn't > the list "aeiouy" get created and destroyed every time, or does the compiler > "know" it is constant and make one constant copy of it that is not GC'ed? > > Regards, > Edwin Fine > > On Fri, Nov 7, 2008 at 11:52 AM, Ulf Wiger wrote: >> >> It's slower, true, but both are fairly fast*, and the lists:member/2 >> solution is also very concise. >> >> * I ran a small benchmark. On the given machine, Robert's >> solution took ca 0.05 usec/call, while Mats's solution took >> ca 0.09 usec/call (on average, iterating 1000 over the set of >> vowels "aeiouyAEIOUY"). Using the smaller set "aeiouy", >> Robert's code still took 0.05 usec/call, while Mats's code >> used 0.08 usec. >> >> BR, >> Ulf W >> >> 2008/11/7 Hynek Vychodil : >> > >> > >> > On Fri, Nov 7, 2008 at 3:22 PM, mats cronqvist >> > wrote: >> >> >> >> "Robert Virding" writes: >> >> >> >> > A reasonable way of doing it would be: >> >> > >> >> > case is_vowel(Char) of >> >> > true -> ... ; >> >> > false -> ... >> >> > end >> >> >> >> >> >> is_wovel(C) -> lists:member(C,"aeiouy"). >> > >> > It is slower than Robert's solution. If performance is significant >> > lists:member solution is worse. >> >> >> >> >> >> mats >> >> _______________________________________________ >> >> erlang-questions mailing list >> >> erlang-questions@REDACTED >> >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > >> > >> > >> > -- >> > --Hynek (Pichi) Vychodil >> > >> > _______________________________________________ >> > erlang-questions mailing list >> > erlang-questions@REDACTED >> > http://www.erlang.org/mailman/listinfo/erlang-questions >> > >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From ulf@REDACTED Fri Nov 7 18:50:06 2008 From: ulf@REDACTED (Ulf Wiger) Date: Fri, 7 Nov 2008 18:50:06 +0100 Subject: [erlang-questions] Idiom for multiple case matches In-Reply-To: <20081107172952.4436E24065@relay.gooddata.com> References: <24d4f39c0811051008n1ad4ed72o5f20b783a092a2f0@mail.gmail.com> <3dbc6d1c0811070214h742d3e4ah6ea425ca23c16706@mail.gmail.com> <87k5bf1uq0.fsf@sterlett.hq.kred> <20081107150753.7D8B824062@relay.gooddata.com> <8209f740811070852k2a8c9df6lf932035f9e9fd4f1@mail.gmail.com> <6c2563b20811070912l1f79eda9i3345c6d0ce2ab9a@mail.gmail.com> <20081107172952.4436E24065@relay.gooddata.com> Message-ID: <8209f740811070950h67a54f08v55f0188ee51304ab@mail.gmail.com> Sure, it all boils down to what percentage of the computation time is taken up by this function. Both versions are cheap, but even normally cheap functions can be too slow sometimes. In general, it's good advice to prefer the concise and cheap version over the bulky but dirt-cheap. Cost-based choices at this level should only be done after careful profiling. BR, Ulf W 2008/11/7 Hynek Vychodil : > There is not GC pressure by creating list in R12B because this is constant > but there is possible pressure on the stack when looping and creting > integers on it. May be no. > More significant question is also which characters was used to match against > vowels. Anyway, 80% slow down can be good reason to not use lists:member for > me when performance is important. I think that when mostly tested characters > which are not vowels, it can be more. > > On Fri, Nov 7, 2008 at 6:12 PM, Edwin Fine > wrote: >> >> Ulf, >> >> Isn't there also more garbage (as in GC) created by Mats' solution? >> Doesn't the list "aeiouy" get created and destroyed every time, or does the >> compiler "know" it is constant and make one constant copy of it that is not >> GC'ed? >> >> Regards, >> Edwin Fine >> >> On Fri, Nov 7, 2008 at 11:52 AM, Ulf Wiger wrote: >>> >>> It's slower, true, but both are fairly fast*, and the lists:member/2 >>> solution is also very concise. >>> >>> * I ran a small benchmark. On the given machine, Robert's >>> solution took ca 0.05 usec/call, while Mats's solution took >>> ca 0.09 usec/call (on average, iterating 1000 over the set of >>> vowels "aeiouyAEIOUY"). Using the smaller set "aeiouy", >>> Robert's code still took 0.05 usec/call, while Mats's code >>> used 0.08 usec. >>> >>> BR, >>> Ulf W >>> >>> 2008/11/7 Hynek Vychodil : >>> > >>> > >>> > On Fri, Nov 7, 2008 at 3:22 PM, mats cronqvist >>> > wrote: >>> >> >>> >> "Robert Virding" writes: >>> >> >>> >> > A reasonable way of doing it would be: >>> >> > >>> >> > case is_vowel(Char) of >>> >> > true -> ... ; >>> >> > false -> ... >>> >> > end >>> >> >>> >> >>> >> is_wovel(C) -> lists:member(C,"aeiouy"). >>> > >>> > It is slower than Robert's solution. If performance is significant >>> > lists:member solution is worse. >>> >> >>> >> >>> >> mats >>> >> _______________________________________________ >>> >> erlang-questions mailing list >>> >> erlang-questions@REDACTED >>> >> http://www.erlang.org/mailman/listinfo/erlang-questions >>> > >>> > >>> > >>> > -- >>> > --Hynek (Pichi) Vychodil >>> > >>> > _______________________________________________ >>> > erlang-questions mailing list >>> > erlang-questions@REDACTED >>> > http://www.erlang.org/mailman/listinfo/erlang-questions >>> > >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://www.erlang.org/mailman/listinfo/erlang-questions >>> >> > > > > -- > --Hynek (Pichi) Vychodil > From v@REDACTED Fri Nov 7 19:25:54 2008 From: v@REDACTED (Valentin Micic) Date: Fri, 7 Nov 2008 20:25:54 +0200 Subject: [erlang-questions] Idiom for multiple case matches In-Reply-To: <8209f740811070928m79dfb43cgb47ff9a9dc8fb6a8@mail.gmail.com> Message-ID: <200811071824.mA7IOkKn010937@mail.pharos-avantgard.com> Wouldn't this be a good candidate for a macro? -define( IS_WOVEL( C ), lists:member(C,"aeiouy") ). It would save one function call that just makes another call. Maybe you'd like to run it against your benchmark? V. -----Original Message----- From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Ulf Wiger Sent: 07 November 2008 07:29 PM To: Edwin Fine Cc: Erlang Questions; mats cronqvist Subject: Re: [erlang-questions] Idiom for multiple case matches As of OTP R12B, constant terms are not re-created at each invocation, but created once at load time. BR, Ulf W 2008/11/7 Edwin Fine : > Ulf, > > Isn't there also more garbage (as in GC) created by Mats' solution? Doesn't > the list "aeiouy" get created and destroyed every time, or does the compiler > "know" it is constant and make one constant copy of it that is not GC'ed? > > Regards, > Edwin Fine > > On Fri, Nov 7, 2008 at 11:52 AM, Ulf Wiger wrote: >> >> It's slower, true, but both are fairly fast*, and the lists:member/2 >> solution is also very concise. >> >> * I ran a small benchmark. On the given machine, Robert's >> solution took ca 0.05 usec/call, while Mats's solution took >> ca 0.09 usec/call (on average, iterating 1000 over the set of >> vowels "aeiouyAEIOUY"). Using the smaller set "aeiouy", >> Robert's code still took 0.05 usec/call, while Mats's code >> used 0.08 usec. >> >> BR, >> Ulf W >> >> 2008/11/7 Hynek Vychodil : >> > >> > >> > On Fri, Nov 7, 2008 at 3:22 PM, mats cronqvist >> > wrote: >> >> >> >> "Robert Virding" writes: >> >> >> >> > A reasonable way of doing it would be: >> >> > >> >> > case is_vowel(Char) of >> >> > true -> ... ; >> >> > false -> ... >> >> > end >> >> >> >> >> >> is_wovel(C) -> lists:member(C,"aeiouy"). >> > >> > It is slower than Robert's solution. If performance is significant >> > lists:member solution is worse. >> >> >> >> >> >> mats >> >> _______________________________________________ >> >> erlang-questions mailing list >> >> erlang-questions@REDACTED >> >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > >> > >> > >> > -- >> > --Hynek (Pichi) Vychodil >> > >> > _______________________________________________ >> > erlang-questions mailing list >> > erlang-questions@REDACTED >> > http://www.erlang.org/mailman/listinfo/erlang-questions >> > >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions From ulf@REDACTED Fri Nov 7 20:03:07 2008 From: ulf@REDACTED (Ulf Wiger) Date: Fri, 7 Nov 2008 20:03:07 +0100 Subject: [erlang-questions] Idiom for multiple case matches In-Reply-To: <200811071824.mA7IOkKn010937@mail.pharos-avantgard.com> References: <8209f740811070928m79dfb43cgb47ff9a9dc8fb6a8@mail.gmail.com> <200811071824.mA7IOkKn010937@mail.pharos-avantgard.com> Message-ID: <8209f740811071103y40b71dedv375ea97b24e964c8@mail.gmail.com> The significant difference between the two solutions is really the complexity. The list variant has linear complexity, whereas the compiler can do better than that with disjunct function clause patterns. The longer the list of vowels, the bigger the difference, and the case where is_vowel(C) -> false is where the difference is greatest. Eliminating the redundant function call can be done by the compiler through inlining. BR, Ulf W 2008/11/7 Valentin Micic : > Wouldn't this be a good candidate for a macro? > > -define( IS_WOVEL( C ), lists:member(C,"aeiouy") ). > > It would save one function call that just makes another call. > Maybe you'd like to run it against your benchmark? > > V. > -----Original Message----- > From: erlang-questions-bounces@REDACTED > [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Ulf Wiger > Sent: 07 November 2008 07:29 PM > To: Edwin Fine > Cc: Erlang Questions; mats cronqvist > Subject: Re: [erlang-questions] Idiom for multiple case matches > > As of OTP R12B, constant terms are not re-created at each > invocation, but created once at load time. > > BR, > Ulf W > > 2008/11/7 Edwin Fine : >> Ulf, >> >> Isn't there also more garbage (as in GC) created by Mats' solution? > Doesn't >> the list "aeiouy" get created and destroyed every time, or does the > compiler >> "know" it is constant and make one constant copy of it that is not GC'ed? >> >> Regards, >> Edwin Fine >> >> On Fri, Nov 7, 2008 at 11:52 AM, Ulf Wiger wrote: >>> >>> It's slower, true, but both are fairly fast*, and the lists:member/2 >>> solution is also very concise. >>> >>> * I ran a small benchmark. On the given machine, Robert's >>> solution took ca 0.05 usec/call, while Mats's solution took >>> ca 0.09 usec/call (on average, iterating 1000 over the set of >>> vowels "aeiouyAEIOUY"). Using the smaller set "aeiouy", >>> Robert's code still took 0.05 usec/call, while Mats's code >>> used 0.08 usec. >>> >>> BR, >>> Ulf W >>> >>> 2008/11/7 Hynek Vychodil : >>> > >>> > >>> > On Fri, Nov 7, 2008 at 3:22 PM, mats cronqvist >>> > wrote: >>> >> >>> >> "Robert Virding" writes: >>> >> >>> >> > A reasonable way of doing it would be: >>> >> > >>> >> > case is_vowel(Char) of >>> >> > true -> ... ; >>> >> > false -> ... >>> >> > end >>> >> >>> >> >>> >> is_wovel(C) -> lists:member(C,"aeiouy"). >>> > >>> > It is slower than Robert's solution. If performance is significant >>> > lists:member solution is worse. >>> >> >>> >> >>> >> mats >>> >> _______________________________________________ >>> >> erlang-questions mailing list >>> >> erlang-questions@REDACTED >>> >> http://www.erlang.org/mailman/listinfo/erlang-questions >>> > >>> > >>> > >>> > -- >>> > --Hynek (Pichi) Vychodil >>> > >>> > _______________________________________________ >>> > erlang-questions mailing list >>> > erlang-questions@REDACTED >>> > http://www.erlang.org/mailman/listinfo/erlang-questions >>> > >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://www.erlang.org/mailman/listinfo/erlang-questions >>> >> >> > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From masse@REDACTED Fri Nov 7 20:40:29 2008 From: masse@REDACTED (mats cronqvist) Date: Fri, 07 Nov 2008 20:40:29 +0100 Subject: [erlang-questions] Idiom for multiple case matches In-Reply-To: <20081107150753.92D1E2406D@relay.gooddata.com> (Hynek Vychodil's message of "Fri\, 7 Nov 2008 16\:07\:52 +0100") References: <24d4f39c0811051008n1ad4ed72o5f20b783a092a2f0@mail.gmail.com> <3dbc6d1c0811070214h742d3e4ah6ea425ca23c16706@mail.gmail.com> <87k5bf1uq0.fsf@sterlett.hq.kred> <20081107150753.92D1E2406D@relay.gooddata.com> Message-ID: <87wsffpbo2.fsf@dixie.cronqvi.st> "Hynek Vychodil" writes: > On Fri, Nov 7, 2008 at 3:22 PM, mats cronqvist wrote: > > "Robert Virding" writes: > > > A reasonable way of doing it would be: > > > > case is_vowel(Char) of > > true -> ... ; > > false -> ... > > end > > is_wovel(C) -> lists:member(C,"aeiouy"). > > It is slower than Robert's solution. is it? so you measured it, but decided to save internet bandwidth by not posting the results. commendable. cause you surely wouldn't just guess and make a fool of yourself? > If performance is significant lists:member solution is worse. only if lists:member/1 come out near the top in your application CPU time profiling. now if you have an application where the CPU cost of sorting characters according to wovelness is significant, you should probably consider switching to C. otherwise, you should aim for code that communicates intent. mats From masse@REDACTED Fri Nov 7 20:55:11 2008 From: masse@REDACTED (mats cronqvist) Date: Fri, 07 Nov 2008 20:55:11 +0100 Subject: [erlang-questions] Idiom for multiple case matches In-Reply-To: <20081107172952.3953724062@relay.gooddata.com> (Hynek Vychodil's message of "Fri\, 7 Nov 2008 18\:29\:51 +0100") References: <24d4f39c0811051008n1ad4ed72o5f20b783a092a2f0@mail.gmail.com> <3dbc6d1c0811070214h742d3e4ah6ea425ca23c16706@mail.gmail.com> <87k5bf1uq0.fsf@sterlett.hq.kred> <20081107150753.7D8B824062@relay.gooddata.com> <8209f740811070852k2a8c9df6lf932035f9e9fd4f1@mail.gmail.com> <6c2563b20811070912l1f79eda9i3345c6d0ce2ab9a@mail.gmail.com> <20081107172952.3953724062@relay.gooddata.com> Message-ID: <87skq3pazk.fsf@dixie.cronqvi.st> "Hynek Vychodil" writes: > Anyway, 80% slow down can be good reason to not use lists:member for > me when performance is important. I think that when mostly tested > characters which are not vowels, it can be more. an "80% slowdown", or indeed any result of any micro-benchmark, is completely and utterly irrelevant. what is (often) important is overall application speed. unfortunately, optimizing a code base full of ad-hoc micro-optimizations can be... challenging. mats From erlang-questions_efine@REDACTED Fri Nov 7 21:23:25 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Fri, 7 Nov 2008 15:23:25 -0500 Subject: [erlang-questions] Idiom for multiple case matches In-Reply-To: <87skq3pazk.fsf@dixie.cronqvi.st> References: <24d4f39c0811051008n1ad4ed72o5f20b783a092a2f0@mail.gmail.com> <3dbc6d1c0811070214h742d3e4ah6ea425ca23c16706@mail.gmail.com> <87k5bf1uq0.fsf@sterlett.hq.kred> <20081107150753.7D8B824062@relay.gooddata.com> <8209f740811070852k2a8c9df6lf932035f9e9fd4f1@mail.gmail.com> <6c2563b20811070912l1f79eda9i3345c6d0ce2ab9a@mail.gmail.com> <20081107172952.3953724062@relay.gooddata.com> <87skq3pazk.fsf@dixie.cronqvi.st> Message-ID: <6c2563b20811071223q62c198c0o50fcdd84ebb98e17@mail.gmail.com> Thanks for all your answers. They were most illuminating, especially when I realized that I had once upon a time read those release notes and completely forgotten about this optimization (mea culpa). Edwin Original question: Isn't there also more garbage (as in GC) created by Mats' solution? Doesn't the list "aeiouy" get created and destroyed every time, or does the compiler "know" it is constant and make one constant copy of it that is not GC'ed? -------------- next part -------------- An HTML attachment was scrubbed... URL: From mrad-direct-erlang@REDACTED Fri Nov 7 21:27:42 2008 From: mrad-direct-erlang@REDACTED (Michael Radford) Date: Fri, 7 Nov 2008 12:27:42 -0800 Subject: [erlang-questions] Idiom for multiple case matches In-Reply-To: <87skq3pazk.fsf@dixie.cronqvi.st> References: <24d4f39c0811051008n1ad4ed72o5f20b783a092a2f0@mail.gmail.com> <3dbc6d1c0811070214h742d3e4ah6ea425ca23c16706@mail.gmail.com> <87k5bf1uq0.fsf@sterlett.hq.kred> <20081107150753.7D8B824062@relay.gooddata.com> <8209f740811070852k2a8c9df6lf932035f9e9fd4f1@mail.gmail.com> <6c2563b20811070912l1f79eda9i3345c6d0ce2ab9a@mail.gmail.com> <20081107172952.3953724062@relay.gooddata.com> <87skq3pazk.fsf@dixie.cronqvi.st> Message-ID: <20081107202742.GA3654@herbie> I hesitate to wade into this cranky-fest, but IMO this is extremely clear and easy to read: is_vowel ($a) -> true; is_vowel ($e) -> true; is_vowel ($i) -> true; is_vowel ($o) -> true; is_vowel ($u) -> true; is_vowel (_) -> false. That's just saying directly what you mean in a language that's nice enough to make it reasonably efficient. An "ad-hoc micro optimization" would be something like this, which does actually make a space/time tradeoff at runtime. static char is_vowel_table[256] = { 0, ..., 1, ... 0 }; #define IS_VOWEL(c) (is_vowel_table[c] != 0) True, the lists:member solution is less source code, but I think it's a toss-up in terms of clarity, and I have had far more problems dealing with code written by "shortest possible source code maniacs" than I have with "premature optimizers." I agree that micro benchmarks are irrelevant (except for library functions). But when you can have both clarity and efficiency as above, why not? Mike mats cronqvist writes: > "Hynek Vychodil" writes: > > > Anyway, 80% slow down can be good reason to not use lists:member for > > me when performance is important. I think that when mostly tested > > characters which are not vowels, it can be more. > > > an "80% slowdown", or indeed any result of any micro-benchmark, is > completely and utterly irrelevant. what is (often) important is > overall application speed. unfortunately, optimizing a code base > full of ad-hoc micro-optimizations can be... challenging. > > mats > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From sten@REDACTED Fri Nov 7 22:31:15 2008 From: sten@REDACTED (Sten Kvamme) Date: Fri, 07 Nov 2008 22:31:15 +0100 Subject: [erlang-questions] What makes erlang software complex Message-ID: <1226093475.14426.12.camel@bautasten> In imperative programming there is Cyclomatic complexity and N-path complexity. What makes an erlang program complex? Thanks, Sten Kvamme -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part URL: From vychodil.hynek@REDACTED Fri Nov 7 23:21:50 2008 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Fri, 7 Nov 2008 23:21:50 +0100 Subject: [erlang-questions] Idiom for multiple case matches In-Reply-To: <87wsffpbo2.fsf@dixie.cronqvi.st> References: <24d4f39c0811051008n1ad4ed72o5f20b783a092a2f0@mail.gmail.com> <3dbc6d1c0811070214h742d3e4ah6ea425ca23c16706@mail.gmail.com> <87k5bf1uq0.fsf@sterlett.hq.kred> <20081107150753.92D1E2406D@relay.gooddata.com> <87wsffpbo2.fsf@dixie.cronqvi.st> Message-ID: <20081107222151.6598F2406D@relay.gooddata.com> Ok, I bring it back. For this short lists function lists:member is almost same fast since lists:member is BIF. I didn't know it and I had not measured. Sorry. I have benchmarked it now and there is not significant difference in R12B-3 on my Intel Core2 Duo Debian Linux laptop. On Fri, Nov 7, 2008 at 8:40 PM, mats cronqvist wrote: > "Hynek Vychodil" writes: > > > On Fri, Nov 7, 2008 at 3:22 PM, mats cronqvist > wrote: > > > > "Robert Virding" writes: > > > > > A reasonable way of doing it would be: > > > > > > case is_vowel(Char) of > > > true -> ... ; > > > false -> ... > > > end > > > > is_wovel(C) -> lists:member(C,"aeiouy"). > > > > It is slower than Robert's solution. > > is it? so you measured it, but decided to save internet bandwidth by > not posting the results. commendable. cause you surely wouldn't just > guess and make a fool of yourself? > > > If performance is significant lists:member solution is worse. > > only if lists:member/1 come out near the top in your application CPU > time profiling. > > now if you have an application where the CPU cost of sorting > characters according to wovelness is significant, you should > probably consider switching to C. otherwise, you should aim for code > that communicates intent. > > mats > -- --Hynek (Pichi) Vychodil -------------- next part -------------- An HTML attachment was scrubbed... URL: From taavi@REDACTED Fri Nov 7 23:53:59 2008 From: taavi@REDACTED (Taavi Talvik) Date: Sat, 8 Nov 2008 00:53:59 +0200 Subject: [erlang-questions] What makes erlang software complex In-Reply-To: <1226093475.14426.12.camel@bautasten> References: <1226093475.14426.12.camel@bautasten> Message-ID: <67569AEB-7904-4C9F-AEE5-D6907FC7A34B@uninet.ee> On Nov 7, 2008, at 11:31 PM, Sten Kvamme wrote: > In imperative programming there is Cyclomatic complexity and N-path > complexity. What makes an erlang program complex? > > Thanks, > Sten Kvamme Personally I very much liked Joe Armstrong definition of "clean" and "dirty" in his thesis http://www.erlang.org/download/armstrong_thesis_2003.pdf section 8.3 page 171-174. Clean functions are easy - for certain set of input, certain set of output is produced. Probably both cyclomatic and n-path complexity can be applied to them. Dirty functions either produce side effects or depend on side effects. And their complexity is unknown, probably somewhere near infinity. disclaimer - I don't have formal theoretical background to discuss this;) best regards, taavi From stondage123@REDACTED Sat Nov 8 00:25:27 2008 From: stondage123@REDACTED (Andrew Stone) Date: Fri, 7 Nov 2008 15:25:27 -0800 (PST) Subject: [erlang-questions] What makes erlang software complex References: <1226093475.14426.12.camel@bautasten> <67569AEB-7904-4C9F-AEE5-D6907FC7A34B@uninet.ee> Message-ID: <621391.44554.qm@web35903.mail.mud.yahoo.com> mustn't feed trolls. trying so hard... ----- Original Message ---- From: Taavi Talvik To: Sten Kvamme Cc: erlang-questions@REDACTED Sent: Friday, November 7, 2008 5:53:59 PM Subject: Re: [erlang-questions] What makes erlang software complex On Nov 7, 2008, at 11:31 PM, Sten Kvamme wrote: > In imperative programming there is Cyclomatic complexity and N-path > complexity. What makes an erlang program complex? > > Thanks, > Sten Kvamme Personally I very much liked Joe Armstrong definition of "clean" and "dirty" in his thesis http://www.erlang.org/download/armstrong_thesis_2003.pdf section 8.3 page 171-174. Clean functions are easy - for certain set of input, certain set of output is produced. Probably both cyclomatic and n-path complexity can be applied to them. Dirty functions either produce side effects or depend on side effects. And their complexity is unknown, probably somewhere near infinity. disclaimer - I don't have formal theoretical background to discuss this;) best regards, taavi _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions From ulf@REDACTED Sat Nov 8 01:55:37 2008 From: ulf@REDACTED (Ulf Wiger) Date: Sat, 8 Nov 2008 01:55:37 +0100 Subject: [erlang-questions] Idiom for multiple case matches In-Reply-To: <20081107202742.GA3654@herbie> References: <24d4f39c0811051008n1ad4ed72o5f20b783a092a2f0@mail.gmail.com> <3dbc6d1c0811070214h742d3e4ah6ea425ca23c16706@mail.gmail.com> <87k5bf1uq0.fsf@sterlett.hq.kred> <20081107150753.7D8B824062@relay.gooddata.com> <8209f740811070852k2a8c9df6lf932035f9e9fd4f1@mail.gmail.com> <6c2563b20811070912l1f79eda9i3345c6d0ce2ab9a@mail.gmail.com> <20081107172952.3953724062@relay.gooddata.com> <87skq3pazk.fsf@dixie.cronqvi.st> <20081107202742.GA3654@herbie> Message-ID: <8209f740811071655gd9eee18x52efce1b49b2195f@mail.gmail.com> 2008/11/7 Michael Radford : > I hesitate to wade into this cranky-fest, but IMO this is extremely > clear and easy to read: > > is_vowel ($a) -> true; > is_vowel ($e) -> true; > is_vowel ($i) -> true; > is_vowel ($o) -> true; > is_vowel ($u) -> true; > is_vowel (_) -> false. Sure, and it's a useful and powerful idiom. But lists:member(C, "aeiou") is also extremely clear and easy to read, and a whole lot easier to write (esp if you use emacs and the - in this case - very annoying electric arrow, which will interfere with your trying to write one-line function clauses like this.) > True, the lists:member solution is less source code, but I think it's a > toss-up in terms of clarity, and I have had far more problems dealing > with code written by "shortest possible source code maniacs" than I have > with "premature optimizers." I don't think one qualifies as a "shortest possible source code maniac" for preferring a one-liner over a 5-line solution, if it's a toss-up in terms of clarity. (: > I agree that micro benchmarks are irrelevant (except for library > functions). But when you can have both clarity and efficiency as above, > why not? Let's call this a micro-benchmark as regards the speed vs clarify tradeoff. As both alternatives are ideomatic, quite readable and efficient, it really boils down to a matter of taste. Robert and Mats are to be commended primarily for suggesting elegant ways to solve the problem. I'm sure both of them apply both patterns in different situations, as their own tastes dictate. My objection was only with the notion that Mats' version should be discarded because of performance - not because it isn't slower (it is, always), but because it's generally not fruitful to make such decisions early, and at this level of abstraction. Perhaps I also reacted instinctively since I happen to know that Mats is certainly one of the most qualified to speak in this matter, having been responsible for system-level profiling and troubleshooting in the AXD 301 for nearly a decade. But of course, he's perfectly capable of fighting his own battles. (: BR, Ulf W > > Mike > > mats cronqvist writes: >> "Hynek Vychodil" writes: >> >> > Anyway, 80% slow down can be good reason to not use lists:member for >> > me when performance is important. I think that when mostly tested >> > characters which are not vowels, it can be more. >> >> >> an "80% slowdown", or indeed any result of any micro-benchmark, is >> completely and utterly irrelevant. what is (often) important is >> overall application speed. unfortunately, optimizing a code base >> full of ad-hoc micro-optimizations can be... challenging. >> >> mats >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From ulf@REDACTED Sat Nov 8 01:59:48 2008 From: ulf@REDACTED (Ulf Wiger) Date: Sat, 8 Nov 2008 01:59:48 +0100 Subject: [erlang-questions] What makes erlang software complex In-Reply-To: <1226093475.14426.12.camel@bautasten> References: <1226093475.14426.12.camel@bautasten> Message-ID: <8209f740811071659u2f35853esf752ad366c6eb36e@mail.gmail.com> 2008/11/7 Sten Kvamme : > In imperative programming there is Cyclomatic complexity and N-path > complexity. What makes an erlang program complex? Muddled thinking. A good Erlang program is close to the problem description, and, to quote Joe Armstrong, should hang together just like a good book. If you bother to make a good "outline" of your program, it will be clear - otherwise, likely not. BR, Ulf W From q2h46uw02@REDACTED Sat Nov 8 05:20:21 2008 From: q2h46uw02@REDACTED (Kevin) Date: Fri, 07 Nov 2008 23:20:21 -0500 Subject: [erlang-questions] gen_tcp:recv and hairloss Message-ID: <4507-26934@sneakemail.com> I'm having a hell of a time with gen_tcp:recv here are the options I use for gen_tcp:listen -define(TCP_OPTS, [binary, {packet, raw}, {active, false}, {reuseaddr, true}]). So the idea is all the listening and accept stuff is handled successfully at the top of a gen_server. Here's a simplified idea at the gen_server level, (there's some conditional handling that gets confusing so I took it out) loop(Sock, Fsm) -> case gen_tcp:recv(Sock, 0, ?RECV_TIMEOUT) of {ok, Request} -> ok = gen_fsm:send_event(Fsm, {Request, Sock}), loop(Sock, Fsm) {error, Reason} -> dont_worry_bout_it end. There might be a typo from the editing for this email, but this, so far, has worked great. Now in the Fsm, I examine the Request binary, have some fun with it, then use gen_tcp:send(Sock, Msg) to reply. This all works great, and I've hammered it and it takes a good load. So to recap, the gen server loops over the input, usually telnet for ....ing purposes, and passes each line to the Fsm, which then replies. I decided I wanted a tighter loop inside the Fsm, so I reproduced the same loop there, given the same socket, and I get the error "ealready", which means something like "operation already in progress". Basically I can't read from the socket unless I come back up out of the Fsm and let the same loop get the next line. What is so special about the gen_server process that can *read* from the socket and the fsm process that cant?!? I tried to reproduce the problem, and I'm having NO problem. One difference I can think of is that the recv in the Fsm is in a different process. Here is a simplified version that shows no problems. Its an echo server that goes quiet when you tell it "sssh" in telnet. start() -> {ok, LSock} = gen_tcp:listen(5678, [binary, {packet, raw}, {active, false}, {reuseaddr, true}]), {ok, Sock} = gen_tcp:accept(LSock), do_recv(Sock), gen_tcp:close(Sock). do_recv(Sock) -> case gen_tcp:recv(Sock, 0) of {ok, B} -> case B of <<"sssh\r\n">> -> %% silent mode sssh(Sock); X -> gen_tcp:send(Sock, X), do_recv(Sock) end; {error, Reason} -> io:format("Error:~p~n", [Reason]) end. sssh(Sock) -> case gen_tcp:recv(Sock, 0) of {ok, _} -> sssh(Sock); {error, Reason} -> io:format("Error2:~p~n", [Reason]) end. From nexes300@REDACTED Sat Nov 8 05:39:42 2008 From: nexes300@REDACTED (Charles Ahn) Date: Fri, 7 Nov 2008 20:39:42 -0800 Subject: [erlang-questions] Replacing default shell in sshd Message-ID: <36DA5914-CE4B-4131-9EEC-13C9FE1DA28B@gmail.com> I was looking at the ssh module because I was somewhat interested in making a MUD in erlang that people can ssh into, but I can't quite figure out how I should go about doing this. It appears that {shell, start, []} is the default shell, but when I read the related source it had a lot of code dealing with shell specific code, and I could not easily figure out exactly what messages the ssh module expects it to respond to. Can anyone tell me exactly what kind of behavior a replacement module requires for the ssh module to work correctly? Furthermore, does anyone see anything that makes the ssh module unsuitable for what I'd like to do? Also, just to point something out, when I start the ssh server, the server will crash if I do not have DSA keys in the system directory. Having RSA keys only does not work and, in fact, I am not certain the daemon is capable of using RSA keys server side. Charles -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2419 bytes Desc: not available URL: From chsu79@REDACTED Sat Nov 8 11:35:14 2008 From: chsu79@REDACTED (Christian) Date: Sat, 8 Nov 2008 11:35:14 +0100 Subject: [erlang-questions] gen_tcp:recv and hairloss In-Reply-To: <4507-26934@sneakemail.com> References: <4507-26934@sneakemail.com> Message-ID: > Basically I can't read from the socket unless I come back up out of the > Fsm and let the same loop get the next line. What is so > special about the gen_server process that can *read* from the socket and > the fsm process that cant?!? The process that accepts the connection is the owner of that socket, also called the controlling process. Only the owner can recv. You can transfer ownership using gen_tcp:controlling_process/2 (from the current owner). What I typically do is to follow the design where in your case the gen_fsm would start out as an ordinary process spawned by proc_lib, then using gen_fsm:enter_loop when a connection has been accepted. The server process will then start these acceptor processes, wait for them to report that a aconnection has been accepted, and thus start a new acceptor process. This always feels a bit clunky to set up, but the pay off in cleaner design makes it worth it. Your server process is never blocked. While an acceptor process is looping around in gen_tcp:accept until a connection is accepted, the server process is free to accept calls and casts for commands sent to or from already accepted connections. From erlang-questions@REDACTED Sat Nov 8 11:19:57 2008 From: erlang-questions@REDACTED (David Svanlund) Date: Sat, 8 Nov 2008 11:19:57 +0100 Subject: [erlang-questions] Replacing default shell in sshd In-Reply-To: <36DA5914-CE4B-4131-9EEC-13C9FE1DA28B@gmail.com> References: <36DA5914-CE4B-4131-9EEC-13C9FE1DA28B@gmail.com> Message-ID: Charles, I experimented with the ssh module a couple of days ago. The (incomplete) example code below might help you understand how to replace the default shell. -module(ssh_example). -export([start/0, dispatch/0, hello/0]). start() -> ssh:daemon({0,0,0,0}, 1122, [{shell, {?MODULE, dispatch, []}}, {user_passwords, [{"davidsvanlund", "banana"}]}]). dispatch() -> spawn(?MODULE, hello, []). hello() -> io:format("Hello user!\n"), loop(). loop() -> Line = io:get_line("> "), io:format(Line), loop(). David 8 nov 2008 kl. 05.39 skrev Charles Ahn: > I was looking at the ssh module because I was somewhat interested in > making a MUD in erlang that people can ssh into, but I can't quite > figure out how I should go about doing this. > > It appears that {shell, start, []} is the default shell, but when I > read the related source it had a lot of code dealing with shell > specific code, and I could not easily figure out exactly what > messages the ssh module expects it to respond to. Can anyone tell me > exactly what kind of behavior a replacement module requires for the > ssh module to work correctly? > > Furthermore, does anyone see anything that makes the ssh module > unsuitable for what I'd like to do? > > Also, just to point something out, when I start the ssh server, the > server will crash if I do not have DSA keys in the system directory. > Having RSA keys only does not work and, in fact, I am not certain > the daemon is capable of using RSA keys server side. > > Charles_______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From ppolv@REDACTED Sat Nov 8 16:29:14 2008 From: ppolv@REDACTED (Pablo Polvorin) Date: Sat, 8 Nov 2008 12:29:14 -0300 Subject: [erlang-questions] gen_tcp:recv and hairloss In-Reply-To: <4507-26934@sneakemail.com> References: <4507-26934@sneakemail.com> Message-ID: <1ffe809c0811080729q114030c7hd9baf9e507aa935b@mail.gmail.com> Hi, 2008/11/8 Kevin : > > I'm having a hell of a time with gen_tcp:recv > > here are the options I use for gen_tcp:listen > > -define(TCP_OPTS, [binary, {packet, raw}, {active, false}, {reuseaddr, > true}]). > > So the idea is all the listening and accept stuff is handled > successfully at the top of a gen_server. > > Here's a simplified idea at the gen_server level, (there's some > conditional handling that gets confusing so I took it out) > > loop(Sock, Fsm) -> > > case gen_tcp:recv(Sock, 0, ?RECV_TIMEOUT) of > {ok, Request} -> > ok = gen_fsm:send_event(Fsm, {Request, Sock}), > loop(Sock, Fsm) > {error, Reason} -> > dont_worry_bout_it > end. > > There might be a typo from the editing for this email, but this, so far, > has worked great. > > Now in the Fsm, I examine the Request binary, have some fun with it, > then use gen_tcp:send(Sock, Msg) > to reply. This all works great, and I've hammered it and it takes a > good load. > > So to recap, the gen server loops over the input, usually telnet for > ....ing purposes, and passes each line > to the Fsm, which then replies. > > I decided I wanted a tighter loop inside the Fsm, so I reproduced the > same loop there, given the same socket, > and I get the error "ealready", which means something like "operation > already in progress". > > Basically I can't read from the socket unless I come back up out of the > Fsm and let the same loop get the next line. What is so > special about the gen_server process that can *read* from the socket and > the fsm process that cant?!? there is nothing special about gen_server. I think your problem is that you are trying to perform two gen_tcp:recv/2 operation in parallel. > > I tried to reproduce the problem, and I'm having NO problem. One > difference I can think of is that the recv in the Fsm is in a different > process. > Here is a simplified version that shows no problems. Its an echo server > that goes quiet when you tell it "sssh" in telnet. > > start() -> > {ok, LSock} = gen_tcp:listen(5678, [binary, {packet, raw}, > {active, false}, > {reuseaddr, true}]), > {ok, Sock} = gen_tcp:accept(LSock), > do_recv(Sock), > gen_tcp:close(Sock). > > > do_recv(Sock) -> > case gen_tcp:recv(Sock, 0) of > {ok, B} -> > case B of > <<"sssh\r\n">> -> %% silent mode > sssh(Sock); > X -> > gen_tcp:send(Sock, X), > do_recv(Sock) > end; > {error, Reason} -> > io:format("Error:~p~n", [Reason]) > end. > > > sssh(Sock) -> > case gen_tcp:recv(Sock, 0) of > {ok, _} -> > sssh(Sock); > {error, Reason} -> > io:format("Error2:~p~n", [Reason]) > end. Test this and see what happens: test() -> {ok,LS} = gen_tcp:listen(7000,[binary,{active,false}]), {ok,Sock} = gen_tcp:accept(LS), spawn(fun() -> do_recv(Sock) end), spawn(fun() -> do_recv(Sock) end), ok. do_recv(Socket) -> io:format("Recv: ~p~n", [ gen_tcp:recv(Socket,0)]). From colm.dougan@REDACTED Sat Nov 8 16:35:42 2008 From: colm.dougan@REDACTED (Colm Dougan) Date: Sat, 8 Nov 2008 15:35:42 +0000 Subject: [erlang-questions] gen_tcp:recv and hairloss In-Reply-To: <4507-26934@sneakemail.com> References: <4507-26934@sneakemail.com> Message-ID: <24d4f39c0811080735q1fafd182rcd1432cde4a921e6@mail.gmail.com> On Sat, Nov 8, 2008 at 4:20 AM, Kevin wrote: > > Basically I can't read from the socket unless I come back up out of the > Fsm and let the same loop get the next line. What is so > special about the gen_server process that can *read* from the socket and > the fsm process that cant?!? This is just a shot in the dark - but if you passed the socket to another process and didn't do gen_tcp:controlling process then that may cause that kind of issue. Colm From q2h46uw02@REDACTED Sat Nov 8 17:23:29 2008 From: q2h46uw02@REDACTED (Kevin) Date: Sat, 08 Nov 2008 11:23:29 -0500 Subject: [erlang-questions] gen_tcp:recv and hairloss In-Reply-To: References: <4507-26934@sneakemail.com> Message-ID: <27121-76778@sneakemail.com> using controlling_process sounds like a great solution, but I've tried that. In the cleaned up code below, I try to assign the socket to the Fsm, but I get the error {error,not_owner}. You'd think that if only the controlling process could read from the socket, than I should never have gotten anywhere, since the only process that is actually reading from the socket is not the owner either! You'd think that in a language where threading and networking are king, they would mention in the docs that, oh, btw, only the owning process can call recv on a socket, but sending and closing, oh you can do that anytime you want. Another thing, the docs for controlling_process just give the impression that the owning process merely is the process that receives messages from the socket, that is, unless you set {active, false} loop(Sock, Fsm) -> case gen_tcp:recv(Sock, 0, ?RECV_TIMEOUT) of %% this works! {ok, Request} -> ok = gen_tcp:controlling_process(Sock, Fsm), %% {error,not_owner} ok = gen_fsm:send_event(Fsm, {Request, Sock}), loop(Sock, Fsm) {error, Reason} -> ok = gen_tcp:close(Sock), end. Christian chsu79-at-gmail.com |erlang| wrote: >> Basically I can't read from the socket unless I come back up out of the >> Fsm and let the same loop get the next line. What is so >> special about the gen_server process that can *read* from the socket and >> the fsm process that cant?!? >> > > The process that accepts the connection is the owner of that socket, also > called the controlling process. Only the owner can recv. You can > transfer ownership > using gen_tcp:controlling_process/2 (from the current owner). > > What I typically do is to follow the design where in your case the > gen_fsm would start out > as an ordinary process spawned by proc_lib, then using > gen_fsm:enter_loop when a connection > has been accepted. > > The server process will then start these acceptor processes, wait for > them to report that a aconnection > has been accepted, and thus start a new acceptor process. > > This always feels a bit clunky to set up, but the pay off in cleaner > design makes it worth it. Your server > process is never blocked. While an acceptor process is looping around > in gen_tcp:accept until a connection > is accepted, the server process is free to accept calls and casts for > commands sent to or from already > accepted connections. > > From erlang-questions@REDACTED Sat Nov 8 11:19:57 2008 From: erlang-questions@REDACTED (David Svanlund) Date: Sat, 8 Nov 2008 11:19:57 +0100 Subject: [erlang-questions] Replacing default shell in sshd In-Reply-To: <36DA5914-CE4B-4131-9EEC-13C9FE1DA28B@gmail.com> References: <36DA5914-CE4B-4131-9EEC-13C9FE1DA28B@gmail.com> Message-ID: Charles, I experimented with the ssh module a couple of days ago. The (incomplete) example code below might help you understand how to replace the default shell. -module(ssh_example). -export([start/0, dispatch/0, hello/0]). start() -> ssh:daemon({0,0,0,0}, 1122, [{shell, {?MODULE, dispatch, []}}, {user_passwords, [{"davidsvanlund", "banana"}]}]). dispatch() -> spawn(?MODULE, hello, []). hello() -> io:format("Hello user!\n"), loop(). loop() -> Line = io:get_line("> "), io:format(Line), loop(). David 8 nov 2008 kl. 05.39 skrev Charles Ahn: > I was looking at the ssh module because I was somewhat interested in > making a MUD in erlang that people can ssh into, but I can't quite > figure out how I should go about doing this. > > It appears that {shell, start, []} is the default shell, but when I > read the related source it had a lot of code dealing with shell > specific code, and I could not easily figure out exactly what > messages the ssh module expects it to respond to. Can anyone tell me > exactly what kind of behavior a replacement module requires for the > ssh module to work correctly? > > Furthermore, does anyone see anything that makes the ssh module > unsuitable for what I'd like to do? > > Also, just to point something out, when I start the ssh server, the > server will crash if I do not have DSA keys in the system directory. > Having RSA keys only does not work and, in fact, I am not certain > the daemon is capable of using RSA keys server side. > > Charles_______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From gleber.p@REDACTED Sat Nov 8 18:16:55 2008 From: gleber.p@REDACTED (Gleb Peregud) Date: Sat, 8 Nov 2008 18:16:55 +0100 Subject: [erlang-questions] clarify: intrument module - status Message-ID: <14f0e3620811080916t6bdd2e25heaa92e305176f833@mail.gmail.com> Hi folks, What is the status of module "intrument" [1] ? Note about it being experimental is quite old... Is it being used by someone? 1: http://www.erlang.org/doc/man/instrument.html BR -- Gleb Peregud http://gleber.pl/ Every minute is to be grasped. Time waits for nobody. -- Inscription on a Zen Gong From pablo.polvorin@REDACTED Sat Nov 8 16:38:11 2008 From: pablo.polvorin@REDACTED (Pablo Polvorin) Date: Sat, 8 Nov 2008 12:38:11 -0300 Subject: [erlang-questions] gen_tcp:recv and hairloss In-Reply-To: <4507-26934@sneakemail.com> References: <4507-26934@sneakemail.com> Message-ID: <1ffe809c0811080738l52d31eefo9587ea8ed9eae03c@mail.gmail.com> Hi, 2008/11/8 Kevin : > > I'm having a hell of a time with gen_tcp:recv > > here are the options I use for gen_tcp:listen > > -define(TCP_OPTS, [binary, {packet, raw}, {active, false}, {reuseaddr, > true}]). > > So the idea is all the listening and accept stuff is handled > successfully at the top of a gen_server. > > Here's a simplified idea at the gen_server level, (there's some > conditional handling that gets confusing so I took it out) > > loop(Sock, Fsm) -> > > case gen_tcp:recv(Sock, 0, ?RECV_TIMEOUT) of > {ok, Request} -> > ok = gen_fsm:send_event(Fsm, {Request, Sock}), > loop(Sock, Fsm) > {error, Reason} -> > dont_worry_bout_it > end. > > There might be a typo from the editing for this email, but this, so far, > has worked great. > > Now in the Fsm, I examine the Request binary, have some fun with it, > then use gen_tcp:send(Sock, Msg) > to reply. This all works great, and I've hammered it and it takes a > good load. > > So to recap, the gen server loops over the input, usually telnet for > ....ing purposes, and passes each line > to the Fsm, which then replies. > > I decided I wanted a tighter loop inside the Fsm, so I reproduced the > same loop there, given the same socket, > and I get the error "ealready", which means something like "operation > already in progress". > > Basically I can't read from the socket unless I come back up out of the > Fsm and let the same loop get the next line. What is so > special about the gen_server process that can *read* from the socket and > the fsm process that cant?!? > there is nothing special about gen_server. I think your problem is that you are trying to perform two gen_tcp:recv/2 operations on the same socket in parallel. > I tried to reproduce the problem, and I'm having NO problem. One > difference I can think of is that the recv in the Fsm is in a different > process. > Here is a simplified version that shows no problems. Its an echo server > that goes quiet when you tell it "sssh" in telnet. > > start() -> > {ok, LSock} = gen_tcp:listen(5678, [binary, {packet, raw}, > {active, false}, > {reuseaddr, true}]), > {ok, Sock} = gen_tcp:accept(LSock), > do_recv(Sock), > gen_tcp:close(Sock). > > > do_recv(Sock) -> > case gen_tcp:recv(Sock, 0) of > {ok, B} -> > case B of > <<"sssh\r\n">> -> %% silent mode > sssh(Sock); > X -> > gen_tcp:send(Sock, X), > do_recv(Sock) > end; > {error, Reason} -> > io:format("Error:~p~n", [Reason]) > end. > > > sssh(Sock) -> > case gen_tcp:recv(Sock, 0) of > {ok, _} -> > sssh(Sock); > {error, Reason} -> > io:format("Error2:~p~n", [Reason]) > end. > > Test this and see what happens: test() -> {ok,LS} = gen_tcp:listen(7000,[binary,{active,false}]), {ok,Sock} = gen_tcp:accept(LS), spawn(fun() -> do_recv(Sock) end), spawn(fun() -> do_recv(Sock) end), ok. do_recv(Socket) -> io:format("Recv: ~p~n", [ gen_tcp:recv(Socket,0)]). From colm.dougan@REDACTED Sat Nov 8 18:27:26 2008 From: colm.dougan@REDACTED (Colm Dougan) Date: Sat, 8 Nov 2008 17:27:26 +0000 Subject: [erlang-questions] gen_tcp:recv and hairloss In-Reply-To: <27121-76778@sneakemail.com> References: <4507-26934@sneakemail.com> <27121-76778@sneakemail.com> Message-ID: <24d4f39c0811080927q544c9cfbt36d0ca8971ea591@mail.gmail.com> On Sat, Nov 8, 2008 at 4:23 PM, Kevin wrote: > > loop(Sock, Fsm) -> > case gen_tcp:recv(Sock, 0, ?RECV_TIMEOUT) of %% this works! > {ok, Request} -> > ok = gen_tcp:controlling_process(Sock, Fsm), %% {error,not_owner} > ok = gen_fsm:send_event(Fsm, {Request, Sock}), > loop(Sock, Fsm) > {error, Reason} -> > ok = gen_tcp:close(Sock), > end. There isn't really enough code here to know enough about what the problem could be. It looks like you have 2 processes both of which want to go back and forth receiving from the same socket but I'm not really clear why you just can't use 1 processes to do all the socket handling. If you were to post a listing of both modules or at least enough code to demonstrate the problem then I'm sure we could be more help. Colm From justin@REDACTED Sat Nov 8 21:50:31 2008 From: justin@REDACTED (Justin Sheehy) Date: Sat, 8 Nov 2008 15:50:31 -0500 Subject: [erlang-questions] Pattern-matching function? In-Reply-To: <8ca3fbe80810300927o51c52aav18bcc0c91e78eda3@mail.gmail.com> Message-ID: On 10/30/08 12:27 PM, "anders conbere" wrote: > To illuminate a bit, I'm writing a mochiweb app and hating life > because I haven't found a good way to reduce the amount of noise > created by the gargantuan case statement created by splitting up the > url. When writing web applications like this in python, there are > often some nice tools provided to at least make the matching list of > routes more readable (see, routes, django urls, werkzeug etc.). Have you tried Webmachine? http://code.google.com/p/webmachine/ http://blog.therestfulway.com/2008/09/webmachine-is-resource-server-for-web. html It is a layer on top of mochiweb created to ease the building of well-behaved Web applications, and includes a URL dispatcher written by Robert Ahrens. The dispatcher isn't exactly what you describe, but is quite close and might serve your needs anyway as it has served ours very well. http://code.google.com/p/webmachine/wiki/DispatchConfiguration On 10/30/08 3:28 PM, "Steve Vinoski" wrote: > I don't use mochiweb so I can't comment on that, but with yaws I use > separate functions to handle each URI as described here: > > I like your use of the match-spec structure there, though we found something only slightly different to work well for us in Webmachine. > In my experience breaking the handlers into different functions makes > them more convenient to deal with. I'd be very surprised if you > couldn't do something similar with mochiweb. In my experience, if writing an app on pure mochiweb one tends to start out writing everything in one big loop function and slowly factor it out. Part of the goal in Webmachine is to do much of the right division of Web application code ahead of time, and also to more easily capture correct HTTP behavior while doing so. To that end we used the approach of resource definition modules, Which are the first unit of this division and which are parameterized and called as a result of the URL dispatch. > how do you actually pronounce "mochiweb" -- is it "mo-chee-web" or > "mo-key-web" or "mock-key-web" or ...?) mo-chee-web > I personally haven't seen any cases where I needed regexp URI matching > for my RESTful web service implementations, but I acknowledge your > mileage may vary. I've had the same experiences. I find regexes to be overkill here. On 10/30/08 4:16 PM, "anders conbere" wrote: > That being said I would love to be able to do > > URLS = [{module, roto_web_view} > {[], version}, > {["version"], version}, > {["register"], register}, > {["nodes"], get_nodes}, > {["nodes", NodeName], nodes}; > {["nodes", NodeName, "queues"], queues}; > {["nodes", NodeName, "messages"], messages}; > ], > > where each function get's passed the Request and any matches in the > order they were specified. The following is a valid dispatch configuration in Webmachine: URLS = [{[], roto_web_resource, [version]}, {["version"], roto_web_resource, [version]}, {["register"], roto_web_resource, [register]}, {["nodes"], roto_node_resource, [nodes]}, {["nodes", nodename], roto_node_resource, [node]}, {["nodes", nodename, "queues"], roto_node_resource, [queues]}, {["nodes", nodename, "messages"], roto_node_resource, [messages]}] I could have made it more identical with yours, but I wanted to also point out that there is some additional value to be had from the ease of breaking things up into multiple resource definitions. Here I made the arbitrary choice that all of the URLs under /nodes would be handles by one resource, and all others by a general resource -- the most sensible breakdown would of course depend a great deal on the structure of your application. Cheers, -Justin From q2h46uw02@REDACTED Sat Nov 8 20:45:15 2008 From: q2h46uw02@REDACTED (Kevin) Date: Sat, 08 Nov 2008 14:45:15 -0500 Subject: [erlang-questions] gen_tcp:recv and hairloss, easy to run example here In-Reply-To: <24d4f39c0811080927q544c9cfbt36d0ca8971ea591@mail.gmail.com> References: <4507-26934@sneakemail.com> <27121-76778@sneakemail.com> <24d4f39c0811080927q544c9cfbt36d0ca8971ea591@mail.gmail.com> Message-ID: <3606-52727@sneakemail.com> I distilled my bug down to two easy to run and understand files in appreciation for anybody who will take a look. Two files, cut at lines. compile with: erlc *.erl run with: erl -s ...._gen_server start_link telnet to: localhost 8000 type anything and hit return to echo, type "sssh" to change to inner recv, error message should echo back The structure of having an inner recv might seem strange, but it makes sense because the outer loop processes commands in text mode, and then switches down into a tight loop that handles an unlimited stream of binary until the end. The FSM controls this, and the main loop is above the FSM, so the FSM only knows when to take over the streaming. The example code does a bad job justifying the use of a FSM and the inner loop though :) Can't wait until somebody points out how clueless I am :-) %%-- cut here------------------------------------------------------------------ -module(...._gen_server). -behaviour(gen_server). -export([start_link/0]). -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]). -record(state, {lsocket, port}). -export([acceptor/1]). -define(TCP_OPTS, [binary, {packet, raw}, {active, false}, % get data from gen_tcp:recv/2 {reuseaddr, true}]). start_link() -> gen_server:start_link({local, ?MODULE}, ?MODULE, #state{}, []). init(State) -> case gen_tcp:listen(8000, ?TCP_OPTS) of {ok, LSocket} -> {ok, spawn_acceptor(State#state{lsocket=LSocket})}; {error, Reason} -> erlang:display(Reason), {stop, Reason} end. handle_cast({accepted}, State) -> {noreply, spawn_acceptor(State)}. spawn_acceptor(State = #state{lsocket=LSocket}) -> proc_lib:spawn_link(?MODULE, acceptor, [{self(), LSocket}]), State. acceptor({Server, LSock}) -> {ok, Sock} = gen_tcp:accept(LSock), gen_server:cast(Server, {accepted}), {ok, Fsm} = ...._fsm:start_link(), gen_tcp:send(Sock, "hello, I will echo, until you type sssh\r\n"), loop(Sock, Fsm). loop(Sock, Fsm) -> case gen_tcp:recv(Sock, 0) of {ok, Request} -> ok = gen_fsm:send_event(Fsm, {Request, Sock}), loop(Sock, Fsm); {error, Reason} -> io:format("gen_server recv error: ~p~n", [Reason]) end. handle_call(_Request, _From, State) -> {reply, ok, State}. handle_info(_Info, State) -> {noreply, State}. code_change(_OldVsn, State, _Extra) -> {ok, State}. terminate(_Reason, _State) -> ok. %%------------------------------------------------------------------------------ %%-- cut here------------------------------------------------------------------ -module(...._fsm). -behaviour(gen_fsm). -compile(export_all). %% gen_fsm stuf to stop the complaining -export([init/1, handle_info/3, code_change/4, handle_sync_event/4, terminate/3, handle_event/3]). -record(state, {}). start_link() -> gen_fsm:start_link(?MODULE, [], []). init([]) -> {ok, start_state, #state{}}. start_state({Request, Sock}, State) -> case Request of <<"sssh\r\n">> -> %% silent mode gen_tcp:send(Sock, "silent until you type nosssh\r\n"), sssh_loop(Sock), {next_state, start_state, State}; _ -> gen_tcp:send(Sock, Request), {next_state, start_state, State} end. sssh_loop(Sock) -> case gen_tcp:recv(Sock, 0) of {ok, Request} -> case Request of <<"nosssh\r\n">> -> %% silent mode nil; _ -> sssh_loop(Sock) end; {error, Reason} -> gen_tcp:send(Sock, "*** Sorry no silent mode, I keep getting error \"" ++ atom_to_list(Reason) ++ "\"\r\n") end. handle_event(stop, _StateName, State) -> {stop, normal, State}. terminate(_Reason, _StateName, _State) -> ok. handle_sync_event(_Event, _From, StateName, State) -> {reply, ok, StateName, State}. handle_info(_Info, StateName, State) -> {next_state, StateName, State}. code_change(_OldVsn, StateName, State, _Extra) -> {ok, StateName, State}. %%------------------------------------------------------------------------------ From chandrashekhar.mullaparthi@REDACTED Sun Nov 9 08:06:13 2008 From: chandrashekhar.mullaparthi@REDACTED (Chandru) Date: Sun, 9 Nov 2008 07:06:13 +0000 Subject: [erlang-questions] running out of memory trying to add_frag on a large mnesia table In-Reply-To: <46569.1226036681@snookles.snookles.com> References: <46569.1226036681@snookles.snookles.com> Message-ID: 2008/11/7 Scott Lystig Fritchie > Marc Sugiyama wrote: > > ms> I have a large, fragmented mnesia table. I'm trying to add more > ms> fragments to it (see below). > > I'm going to guess that you'll need to use the mnesia dump, filter, and > restore. Using the same hash function that mnesia_frag uses by default, > your filter would spit out dump records with table names based on 70 > fragments instead of your current 10. Er, and also replace the internal > 'pvobject' state (inside the 'schema' table?) that contains the current > fragmentation info with the new fragment number. And perhaps a few > other bits. > > That is going to be very painful and error prone. I've tried it before and it is not pretty. I would do it this way: 1. Take an mnesia backup 2. Delete the fragmented mnesia table from the schema 3. Create it again with the number of fragments you want 4. Traverse the backup and re-insert each record and let mnesia spread them across fragments. If the whole process of recreating the table takes too long, there are a couple of ways to speed it up. When doing (3), create the table as a ram_copies table After (4), change the table type to disc_copies using mnesia:change_table_copy_type/3 Chandru -------------- next part -------------- An HTML attachment was scrubbed... URL: From erlang-questions@REDACTED Sun Nov 9 10:20:37 2008 From: erlang-questions@REDACTED (David Svanlund) Date: Sun, 9 Nov 2008 10:20:37 +0100 Subject: [erlang-questions] Replacing default shell in sshd In-Reply-To: References: <36DA5914-CE4B-4131-9EEC-13C9FE1DA28B@gmail.com> Message-ID: <786EE590-9A0E-4347-904E-9755E6392023@pingpang.se> After some digging in shell.erl I believe that just ending the loop is the correct way to do it. The default shell doesn't do anything special, except cleanup. David 9 nov 2008 kl. 06.30 skrev Charles Ahn: > I've tried it out and it works! I was curious to see if the > io:get_line would only work in that particular spawned process and > so I split off the get_line to another process and it still works > somehow. Thanks for the help! > > Is there a better way of disconnecting the user than ending the loop > though? > > Charles > > On Nov 8, 2008, at 2:19 AM, David Svanlund wrote: > >> Charles, >> >> I experimented with the ssh module a couple of days ago. The >> (incomplete) example code below might help you understand how to >> replace the default shell. >> >> -module(ssh_example). >> -export([start/0, dispatch/0, hello/0]). >> >> start() -> >> ssh:daemon({0,0,0,0}, 1122, [{shell, {?MODULE, dispatch, []}}, >> {user_passwords, [{"davidsvanlund", "banana"}]}]). >> >> dispatch() -> >> spawn(?MODULE, hello, []). >> >> hello() -> >> io:format("Hello user!\n"), >> loop(). >> >> loop() -> >> Line = io:get_line("> "), >> io:format(Line), >> loop(). >> >> >> David >> >> >> 8 nov 2008 kl. 05.39 skrev Charles Ahn: >> >>> I was looking at the ssh module because I was somewhat interested in >>> making a MUD in erlang that people can ssh into, but I can't quite >>> figure out how I should go about doing this. >>> >>> It appears that {shell, start, []} is the default shell, but when I >>> read the related source it had a lot of code dealing with shell >>> specific code, and I could not easily figure out exactly what >>> messages the ssh module expects it to respond to. Can anyone tell me >>> exactly what kind of behavior a replacement module requires for the >>> ssh module to work correctly? >>> >>> Furthermore, does anyone see anything that makes the ssh module >>> unsuitable for what I'd like to do? >>> >>> Also, just to point something out, when I start the ssh server, the >>> server will crash if I do not have DSA keys in the system directory. >>> Having RSA keys only does not work and, in fact, I am not certain >>> the daemon is capable of using RSA keys server side. >>> >>> Charles_______________________________________________ >>> 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 nexes300@REDACTED Sun Nov 9 10:59:53 2008 From: nexes300@REDACTED (Charles Ahn) Date: Sun, 9 Nov 2008 01:59:53 -0800 Subject: [erlang-questions] Replacing default shell in sshd In-Reply-To: References: <36DA5914-CE4B-4131-9EEC-13C9FE1DA28B@gmail.com> Message-ID: Hello, I've noticed that when I end a connection by breaking out of the loop, all connections also get terminated (regardless of login). How do I prevent this from happening? Also, is there a way to tell the shell which user it is representing? Here's my loop code: loop(Rec) -> receive {Rec, Line} -> NewLine = <>, io:format("~s",[NewLine]) end, case Line of <<"quit\n">> -> io:format("Good bye!\n"); _ -> loop(Rec) end. Thanks again for the help so far. Charles On Nov 8, 2008, at 2:19 AM, David Svanlund wrote: > Charles, > > I experimented with the ssh module a couple of days ago. The > (incomplete) example code below might help you understand how to > replace the default shell. > > -module(ssh_example). > -export([start/0, dispatch/0, hello/0]). > > start() -> > ssh:daemon({0,0,0,0}, 1122, [{shell, {?MODULE, dispatch, []}}, > {user_passwords, [{"davidsvanlund", "banana"}]}]). > > dispatch() -> > spawn(?MODULE, hello, []). > > hello() -> > io:format("Hello user!\n"), > loop(). > > loop() -> > Line = io:get_line("> "), > io:format(Line), > loop(). > > > David > > > 8 nov 2008 kl. 05.39 skrev Charles Ahn: > >> I was looking at the ssh module because I was somewhat interested in >> making a MUD in erlang that people can ssh into, but I can't quite >> figure out how I should go about doing this. >> >> It appears that {shell, start, []} is the default shell, but when I >> read the related source it had a lot of code dealing with shell >> specific code, and I could not easily figure out exactly what >> messages the ssh module expects it to respond to. Can anyone tell me >> exactly what kind of behavior a replacement module requires for the >> ssh module to work correctly? >> >> Furthermore, does anyone see anything that makes the ssh module >> unsuitable for what I'd like to do? >> >> Also, just to point something out, when I start the ssh server, the >> server will crash if I do not have DSA keys in the system directory. >> Having RSA keys only does not work and, in fact, I am not certain >> the daemon is capable of using RSA keys server side. >> >> Charles_______________________________________________ >> 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 nexes300@REDACTED Sun Nov 9 12:46:17 2008 From: nexes300@REDACTED (Charles Ahn) Date: Sun, 9 Nov 2008 03:46:17 -0800 Subject: [erlang-questions] Replacing default shell in sshd In-Reply-To: References: <36DA5914-CE4B-4131-9EEC-13C9FE1DA28B@gmail.com> Message-ID: If so then the module seems designed to accommodate a single user at a time because, if two users are logged in, one user exiting also kills the connection for the second one. I tried to find out why but I can't understand what the ssh code is doing, or even when the shell code gets called (I wanted to find out where the shell gets called so I could figure out how I am supposed to get the user name from within the shell). I read along and then the code enters the mysterious world of supervisors and I get lost. Charles David Svanlund wrote: > After some digging in shell.erl I believe that just ending the loop is > the correct way to do it. The default shell doesn't do anything > special, except cleanup. > > David -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2419 bytes Desc: not available URL: From vinoski@REDACTED Sun Nov 9 16:29:57 2008 From: vinoski@REDACTED (Steve Vinoski) Date: Sun, 9 Nov 2008 10:29:57 -0500 Subject: [erlang-questions] gen_tcp:recv and hairloss, easy to run example here In-Reply-To: <3606-52727@sneakemail.com> References: <4507-26934@sneakemail.com> <27121-76778@sneakemail.com> <24d4f39c0811080927q544c9cfbt36d0ca8971ea591@mail.gmail.com> <3606-52727@sneakemail.com> Message-ID: <65b2728e0811090729w40c3f4epb8032901e796ed0e@mail.gmail.com> On 11/8/08, Kevin wrote: > I distilled my bug down to two easy to run and understand files in > appreciation for anybody who will take a look. As Pablo Polvorin already pointed out, you're calling gen_tcp:recv on the same socket from two different processes at the same time. Trace proves it: (<0.39.0>) returned from foo_fsm:init/1 -> {ok,start_state,{state}} (<0.31.0>) returned from foo_fsm:start_link/0 -> {ok,<0.39.0>} (<0.31.0>) call foo_gen_server:loop(#Port<0.456>,<0.39.0>) (<0.31.0>) call foo_gen_server:loop(#Port<0.456>,<0.39.0>) (<0.39.0>) call foo_fsm:start_state({<<"sssh\r\n">>,#Port<0.456>},{state}) (<0.39.0>) call foo_fsm:sssh_loop(#Port<0.456>) (<0.39.0>) returned from foo_fsm:sssh_loop/1 -> ok <0.31.0> is the foo_gen_server. It calls foo_fsm:start_link and then goes back to foo_gen_server:loop which calls recv on #Port<0.456>, our TCP socket. Meanwhile, foo_fsm:sssh_loop in process <0.39.0> also does a recv on #Port<0.456>, which fails because foo_gen_server is already in recv. The failure causes the send of the error text on the socket, and the send returns ok which is what sssh_loop returns. --steve From q2h46uw02@REDACTED Sun Nov 9 16:56:22 2008 From: q2h46uw02@REDACTED (Kevin) Date: Sun, 09 Nov 2008 10:56:22 -0500 Subject: [erlang-questions] gen_tcp:recv and hairloss, easy to run example here In-Reply-To: <65b2728e0811090729w40c3f4epb8032901e796ed0e@mail.gmail.com> References: <4507-26934@sneakemail.com> <27121-76778@sneakemail.com> <24d4f39c0811080927q544c9cfbt36d0ca8971ea591@mail.gmail.com> <3606-52727@sneakemail.com> <65b2728e0811090729w40c3f4epb8032901e796ed0e@mail.gmail.com> Message-ID: <7682-21204@sneakemail.com> Ooooh now I get it, I'm calling recv on 2 processes **at the same time** Even though, the process calling the fsm is really doing nothing useful except hogging the socket. If the fsm was in the same process it wouldn't make any difference in the execution of the code as far as I can tell. maybe this is why somebody suggested using gen_fsm:enter_loop. Not sure if it would work, but if it doesn't, its time for a refactor. Thanks everybody. Steve Vinoski vinoski-at-ieee.org |erlang| wrote: > On 11/8/08, Kevin wrote: > >> I distilled my bug down to two easy to run and understand files in >> appreciation for anybody who will take a look. >> > > > > As Pablo Polvorin already pointed out, you're calling gen_tcp:recv on > the same socket from two different processes at the same time. Trace > proves it: > > (<0.39.0>) returned from foo_fsm:init/1 -> {ok,start_state,{state}} > (<0.31.0>) returned from foo_fsm:start_link/0 -> {ok,<0.39.0>} > (<0.31.0>) call foo_gen_server:loop(#Port<0.456>,<0.39.0>) > (<0.31.0>) call foo_gen_server:loop(#Port<0.456>,<0.39.0>) > (<0.39.0>) call foo_fsm:start_state({<<"sssh\r\n">>,#Port<0.456>},{state}) > (<0.39.0>) call foo_fsm:sssh_loop(#Port<0.456>) > (<0.39.0>) returned from foo_fsm:sssh_loop/1 -> ok > > <0.31.0> is the foo_gen_server. It calls foo_fsm:start_link and then > goes back to foo_gen_server:loop which calls recv on #Port<0.456>, our > TCP socket. Meanwhile, foo_fsm:sssh_loop in process <0.39.0> also does > a recv on #Port<0.456>, which fails because foo_gen_server is already > in recv. The failure causes the send of the error text on the socket, > and the send returns ok which is what sssh_loop returns. > > --steve > > From erlang-questions_efine@REDACTED Sun Nov 9 19:44:13 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Sun, 9 Nov 2008 13:44:13 -0500 Subject: [erlang-questions] gen_tcp:recv and hairloss In-Reply-To: <27121-76778@sneakemail.com> References: <4507-26934@sneakemail.com> <27121-76778@sneakemail.com> Message-ID: <6c2563b20811091044q201e2ea8h187a3003c251e640@mail.gmail.com> On Sat, Nov 8, 2008 at 11:23 AM, Kevin wrote: > > using controlling_process sounds like a great solution, but I've tried > that. In the cleaned up code below, I try to assign > the socket to the Fsm, but I get the error {error,not_owner}. I use controlling_process all the time with no problem. May I suggest an alternative? 1. In the gen_server, open a socket and spawn_link a listener process that waits in an gen_tcp:accept on the socket. 2. When it gets an {ok, Sock}, start the fsm, passing it the socket. If necessary, put it in a waiting state until it is handed the ownership. 3. Give ownership of the socket to the fsm and (if necessary) tell it that it's got the socket so it can start working. 4. Loop back to the accept. Let the fsm do all the socket work, and the gen_server just kick off fsms when listening. Example (the ServerRef, unused here, is for calls the listener might want to make to the gen_server, like storing the Pid of each fsm in its state, for example): listener(ServerRef, LSocket) -> case gen_tcp:accept(LSocket) of {ok, Socket} -> case my_fsm:start(Socket) of {ok, Pid} -> case gen_tcp:controlling_process(Socket, Pid) of ok -> my_fsm:socket_ready(Pid), listener(ServerRef, LSocket); _Error -> gen_tcp:close(Socket), my_fsm:stop(Pid), listener(ServerRef, LSocket) end; _Error -> gen_tcp:close(Socket), listener(ServerRef, LSocket) end; _Error -> io:format("listener shutdown, accept error: ~p\n", [_Error]) end. Hope this helps. Regards, Edwin Fine -------------- next part -------------- An HTML attachment was scrubbed... URL: From q2h46uw02@REDACTED Sun Nov 9 20:10:37 2008 From: q2h46uw02@REDACTED (Kevin) Date: Sun, 09 Nov 2008 14:10:37 -0500 Subject: [erlang-questions] gen_tcp:recv and hairloss, one resolution In-Reply-To: <6c2563b20811091044q201e2ea8h187a3003c251e640@mail.gmail.com> References: <4507-26934@sneakemail.com> <27121-76778@sneakemail.com> <6c2563b20811091044q201e2ea8h187a3003c251e640@mail.gmail.com> Message-ID: <16297-24371@sneakemail.com> Hi all, thanks for all your good suggestions. I guess I was still getting my threading legs when I fell for the bug of calling recv in two independent processes. (I wasn't thinking of a gen_fsm as a separate process. In other words: loop(Sock, Fsm) -> case gen_tcp:recv(Sock, 0TIMEOUT) of {ok, Request} -> ok = gen_fsm:send_event(Fsm, {Request, Sock}), %% <--- calling recv again in here, do'h! loop(Sock, Fsm) {error, Reason} -> ok = gen_tcp:close(Sock), end. My solution so far has been simply this: loop(Sock, Fsm) -> ok = gen_fsm:sync_send_event(Fsm, Sock, infinity), loop(Sock, Fsm). and then I call recv in each state function, which might sound messy but it looks pretty clean actually, and now each state can decide how to handle streaming of data. It solves the socket ownership problem also since sync_send_event must not be spawning a new process like send_event does. From jebenitez@REDACTED Sun Nov 9 18:50:25 2008 From: jebenitez@REDACTED (Jose Enrique Benitez Jimenez) Date: Sun, 9 Nov 2008 12:50:25 -0500 Subject: [erlang-questions] Communicating Erlang and mozart Message-ID: Hello, I am developing a proyect involving Mozart and Erlang and I need to communicate each other, I was thinking to use socket, but then I do not know how to structure the messages so that they understand each other, What if there is any standard, which serves to this case, and if you can give me a simple example, It would be very helpful, thank you very much. Enrique From litaocheng@REDACTED Mon Nov 10 03:54:51 2008 From: litaocheng@REDACTED (litao cheng) Date: Mon, 10 Nov 2008 10:54:51 +0800 Subject: [erlang-questions] slave:pseudo/1,2 question Message-ID: hi, buddy. I have some questions about the slave:pseudo/1,2 function. the doc says: "A pseudo server is a server with a registered name which does absolutely nothing but pass on all message to the real server which executes at a master node. A pseudo server is an intermediary which only has the same registered name as the real server. " In my opinion, the pseudo server looks like a proxy, it transfers all the message to the process on the master, the process registered with the same name as the slave. but in the slave.erl line 79, the code is : relay1(Pid) -> receive X -> Pid ! X end, relay1(Pid). the Pid is returned by rpc:call, so i think the message can't send to the master. the correct way is: relay1(Name, Master) -> receive X -> {Name, Master} ! X end, relay1(Name, Master). Is it right? thanks! -------------- next part -------------- An HTML attachment was scrubbed... URL: From pablo.polvorin@REDACTED Mon Nov 10 07:00:57 2008 From: pablo.polvorin@REDACTED (Pablo Polvorin) Date: Mon, 10 Nov 2008 04:00:57 -0200 Subject: [erlang-questions] gen_tcp:recv and hairloss, one resolution In-Reply-To: <16297-24371@sneakemail.com> References: <4507-26934@sneakemail.com> <27121-76778@sneakemail.com> <6c2563b20811091044q201e2ea8h187a3003c251e640@mail.gmail.com> <16297-24371@sneakemail.com> Message-ID: <1ffe809c0811092200l4ba7e1f5j31884f299dca338a@mail.gmail.com> hi, > and then I call recv in each state function, which might sound messy but > it looks pretty clean actually, and now > each state can decide how to handle streaming of data. looks like you might be better using the socket in {active,once} mode? > > It solves the socket ownership problem also since sync_send_event must > not be spawning a new process like > send_event does. No, none of these function spawns a new process. Both are intended to communicate with an already existing process (a gen_fsm ) > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From 0x6e6562@REDACTED Mon Nov 10 16:03:33 2008 From: 0x6e6562@REDACTED (Ben Hood) Date: Mon, 10 Nov 2008 15:03:33 +0000 Subject: [erlang-questions] gen_server:cast/2 reordering Message-ID: <269388e30811100703p326528kd16ce8b7ee2366be@mail.gmail.com> Hi all, I am interested in the reordering semantics of gen_server:cast/2. I have just been looking at the source it and by default it uses the noconnect flag. There was this thread about it almost 2 years ago: http://www.erlang.org/pipermail/erlang-questions/2007-January/025047.html But this last question didn't seem to get answered. My question is: if I want to guarantee the message order from one particular process to another process, do I have to avoid using the noconnect flag, e.g. Dest ! { '$gen_cast, Msg} ? From masse@REDACTED Mon Nov 10 00:06:27 2008 From: masse@REDACTED (mats cronqvist) Date: Mon, 10 Nov 2008 00:06:27 +0100 Subject: [erlang-questions] Idiom for multiple case matches In-Reply-To: <20081107202742.GA3654@herbie> (Michael Radford's message of "Fri\, 7 Nov 2008 12\:27\:42 -0800") References: <24d4f39c0811051008n1ad4ed72o5f20b783a092a2f0@mail.gmail.com> <3dbc6d1c0811070214h742d3e4ah6ea425ca23c16706@mail.gmail.com> <87k5bf1uq0.fsf@sterlett.hq.kred> <20081107150753.7D8B824062@relay.gooddata.com> <8209f740811070852k2a8c9df6lf932035f9e9fd4f1@mail.gmail.com> <6c2563b20811070912l1f79eda9i3345c6d0ce2ab9a@mail.gmail.com> <20081107172952.3953724062@relay.gooddata.com> <87skq3pazk.fsf@dixie.cronqvi.st> <20081107202742.GA3654@herbie> Message-ID: <87fxm05wjw.fsf@dixie.cronqvi.st> Michael Radford writes: > I hesitate to wade into this cranky-fest, but IMO this is extremely > clear and easy to read: > > is_vowel ($a) -> true; > is_vowel ($e) -> true; > is_vowel ($i) -> true; > is_vowel ($o) -> true; > is_vowel ($u) -> true; > is_vowel (_) -> false. > > That's just saying directly what you mean in a language that's nice > enough to make it reasonably efficient. and what you mean is presumably that 'is_vowel' is a function that returns 'true' if its argument is a member of the list "aeiou", otherwise 'false'. the fact that this is a fairly common task is of course the reason why lists:member/2 exists in the first place. so by not using lists:member/2 here, you are obfuscating the fact that you are indeed testing if something is a member of a list. this is why your function is bad. it has nothing to do with the number of lines, but the fact that your function hides its intent by not solving the task the obvious way. it is of course also true that, all else being equal, short is better. and the style of cut-and-paste programming you use is also bad. for example, it's easy to get lost in the paste-fest and forget that "y" is a vowel. > I have had far more problems dealing with code written by "shortest > possible source code maniacs" than I have with "premature > optimizers." in that case a congratulate you. perhaps if you had spent a good ten years fighting losing battles against "premature optimizers" you'd be cranky too. mats From 0x6e6562@REDACTED Mon Nov 10 13:09:28 2008 From: 0x6e6562@REDACTED (Ben Hood) Date: Mon, 10 Nov 2008 12:09:28 +0000 Subject: [erlang-questions] gen_server:cast/2 reordering In-Reply-To: <269388e30811100318v6a4e682cm62ff094b11a2ca7b@mail.gmail.com> References: <269388e30811100318v6a4e682cm62ff094b11a2ca7b@mail.gmail.com> Message-ID: <269388e30811100409j3057f776lb9f9647e8b33fd17@mail.gmail.com> Hi all, I am interested in the reordering semantics of gen_server:cast/2. I have just been looking at the source it and by default it uses the noconnect flag. There was this thread about it almost 2 years ago: http://www.erlang.org/pipermail/erlang-questions/2007-January/025047.html But this last question didn't seem to get answered. My question is: if I want to guarantee the message order from one particular process to another process, do I have to avoid using the noconnect flag, e.g. Dest ! { '$gen_cast, Msg} ? Ben From litaocheng@REDACTED Mon Nov 10 14:34:14 2008 From: litaocheng@REDACTED (litao cheng) Date: Mon, 10 Nov 2008 21:34:14 +0800 Subject: [erlang-questions] slave:pseudo/1,2 question In-Reply-To: References: Message-ID: who can give me some response? thanks ! :) -------------- next part -------------- An HTML attachment was scrubbed... URL: From n39052@REDACTED Mon Nov 10 16:44:53 2008 From: n39052@REDACTED (Sergey A.) Date: Mon, 10 Nov 2008 07:44:53 -0800 Subject: [erlang-questions] The best way to write user-friendly log from an OTP application Message-ID: <3bff71aa0811100744k66cab5e6s8d3ad6267ddc5c6@mail.gmail.com> Hello. I'm looking for the best way to write a plain text log containing the reasons of some well-known errors happening in my OTP applications. The log should be like this: --------------------------------8<-------------------------------- [2008-11-6 23:0:53] Such an ip and port already in use. [2008-11-6 23:1:45] Login or password is wrong --------------------------------8<-------------------------------- Here is what I'm doing just now to achieve this behaviour: I use a gen_event module connected to the error_logger as a handler to catch all the errors (and it is where I write my log). But there are two mutually exclusive ways to denote that error has happened: 1) Do nothing. Just let the crash happen. A process will crash and you'll get a huuuuge message in your gen_event handler: {error, _, {_, _, [_, {_, _, {pg_error, [_, {code, "28000"}, {message, Message}, _, _, _]}}, _, _, authentication_error]}} all's OK, but working with messages like this is somewhat weary. 2) Decide the point where an error happen, and then call: error_logger:error_msg({my_error, Reason}) In this case, the message to catch in gen_event module will be like this: {error, _, {_, {my_error, Reason}, _}} [+] That message is much more easy to operate. [-] You need to call fun error_logger:error_msg/1 by hand (which sometimes can involve some tricky code) Is there any other way to catch errors in a centralised manner? What of the ways listed above is the best in your opinon and why? -- Sergey. From n39052@REDACTED Mon Nov 10 16:48:10 2008 From: n39052@REDACTED (Sergey A.) Date: Mon, 10 Nov 2008 07:48:10 -0800 Subject: [erlang-questions] [erlang-bugs] The best way to write user-friendly log from an OTP application Message-ID: <3bff71aa0811100748u70726e48i74bc5b0563e84485@mail.gmail.com> Oh, sorry! The previous message is for erlang-questions! It was my mistake :((( Thanks. From tobias.lindahl@REDACTED Mon Nov 10 17:07:09 2008 From: tobias.lindahl@REDACTED (Tobias Lindahl) Date: Mon, 10 Nov 2008 17:07:09 +0100 Subject: [erlang-questions] dialyzer maybe_improper_list usage and possible internal error In-Reply-To: References: Message-ID: <49185C2D.9090505@kreditor.se> Hi Bill, Foolish Ewe wrote: ... > -spec(compute_generator/3 :: (Q :: pos_integer(), P :: > maybe_improper_list(pos_integer(), pos_integer()), T :: > non_neg_integer())-> pos_integer()). > > > compute_generator( Q, P, T ) when (is_integer(Q) and is_list(P) and is_integer(T)) andalso ((Q > 0) and (T >= 0)) -> > > Such a spec crashes the dialyzer, (I was using R12B3.22.1 on OpenSuse 11.0 at the time): ... > > dialyzer: Internal problems were encountered in the analysis. > As per the discussion by the very helpful Lestat and Pergu (actually Pergu gave this fix for the problem) on the forum, the spec should have had [] as an alternative in the second parameter to maybe_improper_list, so the spec should have read. > -spec(compute_generator/3 :: (Q :: pos_integer(), P :: > maybe_improper_list(pos_integer(), pos_integer() | []), T :: > non_neg_integer())-> pos_integer()). > > > > compute_generator( Q, P, T ) when (is_integer(Q) and is_list(P) and is_integer(T)) andalso ((Q > 0) and (T >= 0)) -> > I've also sent copies to the folks I think wrote/maintain the dialyzer, so please forgive me if you get this message twice. > > Having given it a bit of consideration, I think there are a few issues to consider: > 1) The dialyzer should complain about the lame spec I made, but should not crash. I agree. it should be handled more gracefully. What happened is that an assert kicked in because of a malformed type. See below for a more precise explanation. > 2) However, the real problem is why did the dialyzer think that > function used an improper_list (or maybe_improper_list)? I'd like to > figure out why, perhaps I have some error I can't see myself. You use is_list(P) which only checks that P is either [] or [_|_] without looking at the termination. Dialyzer cannot say anything about the termination and gives the type maybe_improper_list(). The lists are a bit obscure in the internal representation, and some of the types are not really intended to be used in specs. As Pergu pointed out to you, the termination part of a maybe_improper_list(X, Y) must be a supertype of [], or it would be an improper_list(X, Y). If the termination does not contain [] then the list cannot be a proper list, so the maybe_ is dropped. Of course, this is nothing that a spec-writer should have to worry about, or at least get a friendly warning about rather than a crash. > 3) I suspect my code might be stressing the dialyzer and causing it > to have unexpected behavior (although I'm pretty reluctant to claim > my code is anywhere near bug free). In general, figuring out what > the dialyzer messages really mean is sometimes tricky, and in some > cases, I suspect the dialyzer messages do not indicate what is really > going on. Some static analysis tools give the values that govern > flow of control and show just how an unexpected state can be entered, > perhaps the dialyzer could do that as well. Perhaps I'll post some > examples in separate e-mails if there is sufficient interest in the > mailing list (or if the authors are willing to take a look, perhaps > we can see if my code is stressing the dialyzer in unexpected ways or > perhaps my code is indeed wrong. I am aware that sometimes the cause of the warnings are very hard to find. In rare cases you even need to know intricate details of the analysis to decipher them ;-) If you have doubts about the warnings, just send a (preferably minimal) test case to me and Kostis and we can help you. > 4) To increase the impact of a nice tool like the dialyzer, we might > be able to author a sort of howto guide (or a wiki) to give users > guidance in how to interpret and fix problems reported by the > dialyzer. E.g. I've noticed is that if a "low level" function is > invoked by higher level functions and they all have dialyzer errors, > fixing the low level function will correct/change errors reported in > thei higher level functions, so fixing those first makes sense. Yes, this is the way to do it. Start at leaf cases in the code and fix the warnings about those functions, and then work your way upwards to the interface functions. Indeed, there should be a howto on interpreting warnings. Unfortunately, I have little time to spend on such things nowadays. > 5) If I understand, the dialyzer generates a data flow graph. Could > the dialyzer emit a dot version of the data flow graph suitable for > importation into graphviz, it might be interesting to visualize that. If you're willing to hack a bit, look at the end of the file lib/dialyzer/src/dialyzer_callgraph.erl where there is a debug hack to output the callgraph in dot format. There might be something more official in the future, but don't hold your breath... Best, Tobias > > > Regards: > > Bill M. > > _________________________________________________________________ > Stay up to date on your PC, the Web, and your mobile phone with Windows Live > http://clk.atdmt.com/MRT/go/119462413/direct/01/ From n39052@REDACTED Mon Nov 10 17:40:22 2008 From: n39052@REDACTED (Sergey A.) Date: Mon, 10 Nov 2008 08:40:22 -0800 Subject: [erlang-questions] How can I turn a working escript into erl-shell? Message-ID: <3bff71aa0811100840g46353b8eyf51f992b78bc718c@mail.gmail.com> Hello. As I known there are two well-known approaches for writing a comand line interface for an erlang program: using escript and bash. I've chose escript as the language for writing my first interface. I hope it will be useful to see the source for somebody who is writing escript interface now. It's here: http://gist.github.com/23516 Now about the question I have. With bash I can turn a working script into any program just by calling something like: erl -sname dbg -remsh myapp # <-- this starts the Erlang shell and tell it to connect to a remote node. After the shell will be closed, script will continue Thus, the bash script can be used both as a tool for manipulating a working Erlang application (you can call rpc:call, or smth like) and as a tool for opening Erlang shell with all the arguments passed (which is very useful when debugging. It just make life easy). Is there any way to open the erlang shell from an escript? Thanks. -- Sergey. From n39052@REDACTED Mon Nov 10 17:50:09 2008 From: n39052@REDACTED (Sergey A.) Date: Mon, 10 Nov 2008 08:50:09 -0800 Subject: [erlang-questions] [erlang-bugs] The best way to write user-friendly log from an OTP application In-Reply-To: <3bff71aa0811100748u70726e48i74bc5b0563e84485@mail.gmail.com> References: <3bff71aa0811100748u70726e48i74bc5b0563e84485@mail.gmail.com> Message-ID: <3bff71aa0811100850q6d8e9af0vfccfee017b99a5de@mail.gmail.com> What a day! The letter with subject "The best way to write user-friendly log from an OTP application" is actually supposed to be sended to erlang-questions, not to erlang-bugs. 2008/11/10 Sergey A. : > Oh, sorry! The previous message is for erlang-questions! It was my mistake :((( > > Thanks. > Sorry again, guys. -- Sergey. From klacke@REDACTED Mon Nov 10 17:53:58 2008 From: klacke@REDACTED (Claes Wikstrom) Date: Mon, 10 Nov 2008 17:53:58 +0100 Subject: [erlang-questions] slave:pseudo/1,2 question In-Reply-To: References: Message-ID: <49186726.6030105@hyber.org> litao cheng wrote: > > > Is it right? > No, better to use the Pid - i.e. just as the code is today. /klacke From dmercer@REDACTED Mon Nov 10 18:05:15 2008 From: dmercer@REDACTED (David Mercer) Date: Mon, 10 Nov 2008 11:05:15 -0600 Subject: [erlang-questions] Idiom for multiple case matches In-Reply-To: <87fxm05wjw.fsf@dixie.cronqvi.st> References: <24d4f39c0811051008n1ad4ed72o5f20b783a092a2f0@mail.gmail.com><3dbc6d1c0811070214h742d3e4ah6ea425ca23c16706@mail.gmail.com><87k5bf1uq0.fsf@sterlett.hq.kred><20081107150753.7D8B824062@relay.gooddata.com><8209f740811070852k2a8c9df6lf932035f9e9fd4f1@mail.gmail.com><6c2563b20811070912l1f79eda9i3345c6d0ce2ab9a@mail.gmail.com><20081107172952.3953724062@relay.gooddata.com><87skq3pazk.fsf@dixie.cronqvi.st> <20081107202742.GA3654@herbie> <87fxm05wjw.fsf@dixie.cronqvi.st> Message-ID: <66BE84A76DFC4FBE86A2831B123B4893@SSI.CORP> Since this is, semantically, a set operation, should we not perhaps use sets:is_element/2 instead? Something like: vowels() -> sets:from_list("aeiou"). is_vowel(C) -> sets:is_element(C, vowels()). Just kidding, of course... (Obvious efficiency issues.) :-) DBM P.S. No, Mats, I did not benchmark this. :-) From dmercer@REDACTED Mon Nov 10 18:27:30 2008 From: dmercer@REDACTED (David Mercer) Date: Mon, 10 Nov 2008 11:27:30 -0600 Subject: [erlang-questions] Idiom for multiple case matches References: <24d4f39c0811051008n1ad4ed72o5f20b783a092a2f0@mail.gmail.com><3dbc6d1c0811070214h742d3e4ah6ea425ca23c16706@mail.gmail.com><87k5bf1uq0.fsf@sterlett.hq.kred><20081107150753.7D8B824062@relay.gooddata.com><8209f740811070852k2a8c9df6lf932035f9e9fd4f1@mail.gmail.com><6c2563b20811070912l1f79eda9i3345c6d0ce2ab9a@mail.gmail.com><20081107172952.3953724062@relay.gooddata.com><87skq3pazk.fsf@dixie.cronqvi.st> <20081107202742.GA3654@herbie> <87fxm05wjw.fsf@dixie.cronqvi.st> Message-ID: <73E0ADEA6FEE4DCB9E019E3CD962FFD5@SSI.CORP> For completeness, I did run some benchmarking. I hesitate to put my name to my solution, since it was suggested in jest, but I am vindicated because it performed as expected: 1,000,000 Iterations: Virding: Run-Time/Wall-Clock: 94/94 milliseconds Cronqvist: Run-Time/Wall-Clock: 141/141 milliseconds Mercer: Run-Time/Wall-Clock: 14547/14547 milliseconds Cheers, David > -----Original Message----- > From: David Mercer [mailto:dmercer@REDACTED] > Sent: Monday, November 10, 2008 11:05 > To: 'mats cronqvist'; 'Michael Radford' > Cc: 'Hynek Vychodil'; 'Erlang Questions' > Subject: RE: [erlang-questions] Idiom for multiple case matches > > Since this is, semantically, a set operation, should we not perhaps use > sets:is_element/2 instead? Something like: > > vowels() -> sets:from_list("aeiou"). > is_vowel(C) -> sets:is_element(C, vowels()). > > Just kidding, of course... (Obvious efficiency issues.) :-) > > DBM > > P.S. No, Mats, I did not benchmark this. :-) From 0x6e6562@REDACTED Mon Nov 10 12:18:47 2008 From: 0x6e6562@REDACTED (Ben Hood) Date: Mon, 10 Nov 2008 11:18:47 +0000 Subject: [erlang-questions] gen_server:cast/2 reordering Message-ID: <269388e30811100318v6a4e682cm62ff094b11a2ca7b@mail.gmail.com> Hi all, I am interested in the reordering semantics of gen_server:cast/2. I have just been looking at the source it and by default it uses the noconnect flag. There was this thread about it almost 2 years ago: http://www.erlang.org/pipermail/erlang-questions/2007-January/025047.html But this last question didn't seem to get answered. My question is: if I want to guarantee the message order from one particular process to another process, do I have to avoid using the noconnect flag, e.g. Dest ! { '$gen_cast, Msg} ? Ben From ulf.wiger@REDACTED Mon Nov 10 19:29:50 2008 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Mon, 10 Nov 2008 19:29:50 +0100 Subject: [erlang-questions] Idiom for multiple case matches In-Reply-To: <73E0ADEA6FEE4DCB9E019E3CD962FFD5@SSI.CORP> References: <24d4f39c0811051008n1ad4ed72o5f20b783a092a2f0@mail.gmail.com><3dbc6d1c0811070214h742d3e4ah6ea425ca23c16706@mail.gmail.com><87k5bf1uq0.fsf@sterlett.hq.kred><20081107150753.7D8B824062@relay.gooddata.com><8209f740811070852k2a8c9df6lf932035f9e9fd4f1@mail.gmail.com><6c2563b20811070912l1f79eda9i3345c6d0ce2ab9a@mail.gmail.com><20081107172952.3953724062@relay.gooddata.com><87skq3pazk.fsf@dixie.cronqvi.st> <20081107202742.GA3654@herbie> <87fxm05wjw.fsf@dixie.cronqvi.st> <73E0ADEA6FEE4DCB9E019E3CD962FFD5@SSI.CORP> Message-ID: <49187D9E.4010908@ericsson.com> So try it with the absolutely wonderful and indispensable parse transform utility ct_expand. ;-) http://forum.trapexit.org/viewtopic.php?p=20260#20260 BR, Ulf W David Mercer skrev: > For completeness, I did run some benchmarking. I hesitate to put my name to > my solution, since it was suggested in jest, but I am vindicated because it > performed as expected: > > 1,000,000 Iterations: > Virding: Run-Time/Wall-Clock: 94/94 milliseconds > Cronqvist: Run-Time/Wall-Clock: 141/141 milliseconds > Mercer: Run-Time/Wall-Clock: 14547/14547 milliseconds > > Cheers, > > David > >> -----Original Message----- >> From: David Mercer [mailto:dmercer@REDACTED] >> Sent: Monday, November 10, 2008 11:05 >> To: 'mats cronqvist'; 'Michael Radford' >> Cc: 'Hynek Vychodil'; 'Erlang Questions' >> Subject: RE: [erlang-questions] Idiom for multiple case matches >> >> Since this is, semantically, a set operation, should we not perhaps use >> sets:is_element/2 instead? Something like: >> >> vowels() -> sets:from_list("aeiou"). >> is_vowel(C) -> sets:is_element(C, vowels()). >> >> Just kidding, of course... (Obvious efficiency issues.) :-) >> >> DBM >> >> P.S. No, Mats, I did not benchmark this. :-) > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From kevin@REDACTED Mon Nov 10 19:44:52 2008 From: kevin@REDACTED (Kevin Scaldeferri) Date: Mon, 10 Nov 2008 10:44:52 -0800 Subject: [erlang-questions] Idiom for multiple case matches In-Reply-To: <87fxm05wjw.fsf@dixie.cronqvi.st> References: <24d4f39c0811051008n1ad4ed72o5f20b783a092a2f0@mail.gmail.com> <3dbc6d1c0811070214h742d3e4ah6ea425ca23c16706@mail.gmail.com> <87k5bf1uq0.fsf@sterlett.hq.kred> <20081107150753.7D8B824062@relay.gooddata.com> <8209f740811070852k2a8c9df6lf932035f9e9fd4f1@mail.gmail.com> <6c2563b20811070912l1f79eda9i3345c6d0ce2ab9a@mail.gmail.com> <20081107172952.3953724062@relay.gooddata.com> <87skq3pazk.fsf@dixie.cronqvi.st> <20081107202742.GA3654@herbie> <87fxm05wjw.fsf@dixie.cronqvi.st> Message-ID: <72D0DE1F-981E-4AFD-AE8B-8ACA25F350B3@scaldeferri.com> On Nov 9, 2008, at 3:06 PM, mats cronqvist wrote: > Michael Radford writes: > >> I hesitate to wade into this cranky-fest, but IMO this is extremely >> clear and easy to read: >> >> is_vowel ($a) -> true; >> is_vowel ($e) -> true; >> is_vowel ($i) -> true; >> is_vowel ($o) -> true; >> is_vowel ($u) -> true; >> is_vowel (_) -> false. >> >> That's just saying directly what you mean in a language that's nice >> enough to make it reasonably efficient. > > and what you mean is presumably that 'is_vowel' is a function that > returns 'true' if its argument is a member of the list "aeiou", > otherwise 'false'. > > the fact that this is a fairly common task is of course the reason > why lists:member/2 exists in the first place. so by not using > lists:member/2 here, you are obfuscating the fact that you are > indeed testing if something is a member of a list. Well, if you want to be pedantic, that's completely wrong. There's nothing list-like about the collection of vowels. It's a set. So, clearly, in the interest of clarity, we should use set:member/2, even though that's orders of magnitude slower. > and the style of cut-and-paste programming you use is also bad. for > example, it's easy to get lost in the paste-fest and forget that "y" > is a vowel. I've been watching this discussion waiting for someone to point out the glaring problem with this whole exercise, which is that "vowel- ness" is language-dependent. So, in that sense, all approaches which have been presented so far are wrong. -kevin From dmercer@REDACTED Mon Nov 10 20:16:37 2008 From: dmercer@REDACTED (David Mercer) Date: Mon, 10 Nov 2008 13:16:37 -0600 Subject: [erlang-questions] Idiom for multiple case matches In-Reply-To: <49187D9E.4010908@ericsson.com> References: <24d4f39c0811051008n1ad4ed72o5f20b783a092a2f0@mail.gmail.com><3dbc6d1c0811070214h742d3e4ah6ea425ca23c16706@mail.gmail.com><87k5bf1uq0.fsf@sterlett.hq.kred><20081107150753.7D8B824062@relay.gooddata.com><8209f740811070852k2a8c9df6lf932035f9e9fd4f1@mail.gmail.com><6c2563b20811070912l1f79eda9i3345c6d0ce2ab9a@mail.gmail.com><20081107172952.3953724062@relay.gooddata.com><87skq3pazk.fsf@dixie.cronqvi.st> <20081107202742.GA3654@herbie> <87fxm05wjw.fsf@dixie.cronqvi.st> <73E0ADEA6FEE4DCB9E019E3CD962FFD5@SSI.CORP> <49187D9E.4010908@ericsson.com> Message-ID: <5660069983654542B0A670B1149FED62@SSI.CORP> Actually, using Ulf's ct_expand parse transform, the results on the set look much better: 1000000 Iterations Virding: Run-Time/Wall-Clock: 94/94 milliseconds Cronqvist: Run-Time/Wall-Clock: 141/140 milliseconds Mercer: Run-Time/Wall-Clock: 843/844 milliseconds That's a 17x speed-up! However, now I get a compile warning: ./test.erl:0: Warning: variable 'V42' is unused I don't know enough about parse transforms to debug. Is there any documentation on creating them? DBM > -----Original Message----- > From: Ulf Wiger (TN/EAB) [mailto:ulf.wiger@REDACTED] > Sent: Monday, November 10, 2008 12:30 > To: dmercer@REDACTED > Cc: 'Erlang Questions' > Subject: Re: [erlang-questions] Idiom for multiple case matches > > > So try it with the absolutely wonderful and indispensable > parse transform utility ct_expand. ;-) > > http://forum.trapexit.org/viewtopic.php?p=20260#20260 > > > BR, > Ulf W > > > David Mercer skrev: > > For completeness, I did run some benchmarking. I hesitate to put my > name to > > my solution, since it was suggested in jest, but I am vindicated because > it > > performed as expected: > > > > 1,000,000 Iterations: > > Virding: Run-Time/Wall-Clock: 94/94 milliseconds > > Cronqvist: Run-Time/Wall-Clock: 141/141 milliseconds > > Mercer: Run-Time/Wall-Clock: 14547/14547 milliseconds > > > > Cheers, > > > > David > > > >> -----Original Message----- > >> From: David Mercer [mailto:dmercer@REDACTED] > >> Sent: Monday, November 10, 2008 11:05 > >> To: 'mats cronqvist'; 'Michael Radford' > >> Cc: 'Hynek Vychodil'; 'Erlang Questions' > >> Subject: RE: [erlang-questions] Idiom for multiple case matches > >> > >> Since this is, semantically, a set operation, should we not perhaps use > >> sets:is_element/2 instead? Something like: > >> > >> vowels() -> sets:from_list("aeiou"). > >> is_vowel(C) -> sets:is_element(C, vowels()). > >> > >> Just kidding, of course... (Obvious efficiency issues.) :-) > >> > >> DBM > >> > >> P.S. No, Mats, I did not benchmark this. :-) > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions From steven.charles.davis@REDACTED Mon Nov 10 20:19:50 2008 From: steven.charles.davis@REDACTED (Steve Davis) Date: Mon, 10 Nov 2008 11:19:50 -0800 (PST) Subject: [erlang-questions] Crazy Question: C -> Erlang Core Message-ID: This is the ultimate time-waster question, but interesting to consider (or at least I think so). Would it be possible to write a program (in erlang with yecc etc of course) that transforms C source into Erlang Core and thus allows it to compile to BEAM files? If not, suppose you put constraints on the kind of C program you wrote (and I'm wondering what those might be)? Ignore this if the question upsets you - I said it was crazy - also, responses including the BIF open_port are disallowed by the rules ;) /s *ducks* From erlang-questions_efine@REDACTED Mon Nov 10 20:29:05 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Mon, 10 Nov 2008 14:29:05 -0500 Subject: [erlang-questions] How can I turn a working escript into erl-shell? In-Reply-To: <3bff71aa0811100840g46353b8eyf51f992b78bc718c@mail.gmail.com> References: <3bff71aa0811100840g46353b8eyf51f992b78bc718c@mail.gmail.com> Message-ID: <6c2563b20811101129x58e934fbt84d9838a8202ab59@mail.gmail.com> Sergey, I use bash together with the -eval command-line option. I find this gives me great flexibility because I can embed Erlang code directly in my shell script and enjoy the benefits of both bash and escript. It took a while to get the magical incantations right, but now it works like a charm. If I need to talk to an application on another node, I can do so as you say using rpc. And, of course, starting a shell is trivial from bash. For example, here's a Bash shell function I use: kill_node() { echo "Node ${ERL_NODE_NAME} did not shut down when asked nicely, now halting it." ${ERL_CMD} -noshell -noinput -boot ${CLEAN_BOOT_FILE} -sname ${USER}$$ \ -eval ' Node = '''${ERL_NODE_NAME}''', rpc:call(Node, erlang, halt, [], 3000), init:stop(). ' } ERL_CMD uses erlexec directly, e.g. export ROOTDIR=... export BINDIR=... ERL_CMD="${BINDIR}/erlexec -config ${CONFIG_FILE}" Regards, Edwin On Mon, Nov 10, 2008 at 11:40 AM, Sergey A. wrote: > Hello. > > As I known there are two well-known approaches for writing a comand > line interface for an erlang program: using escript and bash. > > I've chose escript as the language for writing my first interface. > > I hope it will be useful to see the source for somebody who is writing > escript interface now. It's here: > > http://gist.github.com/23516 > > Now about the question I have. With bash I can turn a working script > into any program just by calling something like: > > erl -sname dbg -remsh myapp # <-- this starts the Erlang shell and > tell it to connect to a remote node. After the shell will be closed, > script will continue > > Thus, the bash script can be used both as a tool for manipulating a > working Erlang application (you can call rpc:call, or smth like) and > as a tool for opening Erlang shell with all the arguments passed > (which is very useful when debugging. It just make life easy). > > Is there any way to open the erlang shell from an escript? > > Thanks. > > -- > Sergey. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf.wiger@REDACTED Mon Nov 10 20:34:59 2008 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Mon, 10 Nov 2008 20:34:59 +0100 Subject: [erlang-questions] Idiom for multiple case matches In-Reply-To: <5660069983654542B0A670B1149FED62@SSI.CORP> References: <24d4f39c0811051008n1ad4ed72o5f20b783a092a2f0@mail.gmail.com><3dbc6d1c0811070214h742d3e4ah6ea425ca23c16706@mail.gmail.com><87k5bf1uq0.fsf@sterlett.hq.kred><20081107150753.7D8B824062@relay.gooddata.com><8209f740811070852k2a8c9df6lf932035f9e9fd4f1@mail.gmail.com><6c2563b20811070912l1f79eda9i3345c6d0ce2ab9a@mail.gmail.com><20081107172952.3953724062@relay.gooddata.com><87skq3pazk.fsf@dixie.cronqvi.st> <20081107202742.GA3654@herbie> <87fxm05wjw.fsf@dixie.cronqvi.st> <73E0ADEA6FEE4DCB9E019E3CD962FFD5@SSI.CORP> <49187D9E.4010908@ericsson.com> <5660069983654542B0A670B1149FED62@SSI.CORP> Message-ID: <49188CE3.7050903@ericsson.com> David Mercer skrev: > Actually, using Ulf's ct_expand parse transform, the results on the set look > much better: > > 1000000 Iterations > Virding: Run-Time/Wall-Clock: 94/94 milliseconds > Cronqvist: Run-Time/Wall-Clock: 141/140 milliseconds > Mercer: Run-Time/Wall-Clock: 843/844 milliseconds > > That's a 17x speed-up! Of course, it's still pretty slow for this particular problem, but hopefully people are able to extrapolate. (: > > However, now I get a compile warning: > > ./test.erl:0: Warning: variable 'V42' is unused > > I don't know enough about parse transforms to debug. Is there any > documentation on creating them? Not much, but it's fairly simple at one level. Mod:parse_transform(Forms, Options) -> NewForms The module in question makes use of syntax_tools, which is documented. To get rid of the warning, perhaps the simplest way ought to be to replace the call on lines 141-143: VarNames = erl_syntax_lib:new_variable_names( Arity, erl_syntax_lib:variables(Form)), to VarNames = erl_syntax_lib:new_variable_names( Arity, fun(I) -> list_to_atom( lists:concat( ["__", ?MODULE_STRING, integer_to_list(I)])) end, erl_syntax_lib:variables(Form)), ...or something like that. I haven't tested it. BR, Ulf W > > DBM > >> -----Original Message----- >> From: Ulf Wiger (TN/EAB) [mailto:ulf.wiger@REDACTED] >> Sent: Monday, November 10, 2008 12:30 >> To: dmercer@REDACTED >> Cc: 'Erlang Questions' >> Subject: Re: [erlang-questions] Idiom for multiple case matches >> >> >> So try it with the absolutely wonderful and indispensable >> parse transform utility ct_expand. ;-) >> >> http://forum.trapexit.org/viewtopic.php?p=20260#20260 >> >> >> BR, >> Ulf W >> >> >> David Mercer skrev: >>> For completeness, I did run some benchmarking. I hesitate to put my >> name to >>> my solution, since it was suggested in jest, but I am vindicated because >> it >>> performed as expected: >>> >>> 1,000,000 Iterations: >>> Virding: Run-Time/Wall-Clock: 94/94 milliseconds >>> Cronqvist: Run-Time/Wall-Clock: 141/141 milliseconds >>> Mercer: Run-Time/Wall-Clock: 14547/14547 milliseconds >>> >>> Cheers, >>> >>> David >>> >>>> -----Original Message----- >>>> From: David Mercer [mailto:dmercer@REDACTED] >>>> Sent: Monday, November 10, 2008 11:05 >>>> To: 'mats cronqvist'; 'Michael Radford' >>>> Cc: 'Hynek Vychodil'; 'Erlang Questions' >>>> Subject: RE: [erlang-questions] Idiom for multiple case matches >>>> >>>> Since this is, semantically, a set operation, should we not perhaps use >>>> sets:is_element/2 instead? Something like: >>>> >>>> vowels() -> sets:from_list("aeiou"). >>>> is_vowel(C) -> sets:is_element(C, vowels()). >>>> >>>> Just kidding, of course... (Obvious efficiency issues.) :-) >>>> >>>> DBM >>>> >>>> P.S. No, Mats, I did not benchmark this. :-) >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://www.erlang.org/mailman/listinfo/erlang-questions > From dmercer@REDACTED Mon Nov 10 20:48:57 2008 From: dmercer@REDACTED (David Mercer) Date: Mon, 10 Nov 2008 13:48:57 -0600 Subject: [erlang-questions] Function Spec Syntax Message-ID: <1AD39C50692242968456DDA13127070B@SSI.CORP> Out of curiosity, should I be using edoc @spec syntax, Dialyzer -spec syntax, or both in my modules? Mercer -------------- next part -------------- An HTML attachment was scrubbed... URL: From rvirding@REDACTED Mon Nov 10 21:33:25 2008 From: rvirding@REDACTED (Robert Virding) Date: Mon, 10 Nov 2008 21:33:25 +0100 Subject: [erlang-questions] Crazy Question: C -> Erlang Core In-Reply-To: References: Message-ID: <3dbc6d1c0811101233g4b94cf47x3ad15dd6e65e0a13@mail.gmail.com> Yes, it would be possible but there would be quite severe restrictions on the C you could write. Three main ones are: - no destructive operations on data as all data is immutable in Erlang - global data is tricky - many of the basic C data structures don't map easily to Erlang If you did it you would end up writing C in a very functional style. But you would get wonderful support for concurrency! Robert 2008/11/10 Steve Davis > This is the ultimate time-waster question, but interesting to consider > (or at least I think so). > > Would it be possible to write a program (in erlang with yecc etc of > course) that transforms C source into Erlang Core and thus allows it > to compile to BEAM files? If not, suppose you put constraints on the > kind of C program you wrote (and I'm wondering what those might be)? > > Ignore this if the question upsets you - I said it was crazy - also, > responses including the BIF open_port are disallowed by the rules ;) > > /s > *ducks* > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kenneth.lundin@REDACTED Mon Nov 10 21:35:07 2008 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Mon, 10 Nov 2008 21:35:07 +0100 Subject: [erlang-questions] gen_server:cast/2 reordering In-Reply-To: <269388e30811100703p326528kd16ce8b7ee2366be@mail.gmail.com> References: <269388e30811100703p326528kd16ce8b7ee2366be@mail.gmail.com> Message-ID: On Mon, Nov 10, 2008 at 4:03 PM, Ben Hood <0x6e6562@REDACTED> wrote: > Hi all, > > I am interested in the reordering semantics of gen_server:cast/2. > > I have just been looking at the source it and by default it uses the > noconnect flag. > > There was this thread about it almost 2 years ago: > > http://www.erlang.org/pipermail/erlang-questions/2007-January/025047.html > > But this last question didn't seem to get answered. > > My question is: if I want to guarantee the message order from one > particular process to another process, do I have to avoid using the > noconnect flag, e.g. > > Dest ! { '$gen_cast, Msg} > If you send to a process on the same E-node the ordering will be guaranteed even if you use gen_server:cast/2 since the noconnect flag will have no effect on local calls. If calling gen_server:cast/2 with a message to another E-node the ordering will not be guaranteed because of the spawn which happens if there is no existing connection to the addressed E-node. You can use Dest ! { '$gen_cast, Msg} to get a guaranteed order On the other hand your process will be blocked until a connection with the other E-node is established or the connection attempt has failed. /Kenneth Erlang/OTP Ericsson > ? > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From q2h46uw02@REDACTED Mon Nov 10 21:39:30 2008 From: q2h46uw02@REDACTED (Kevin) Date: Mon, 10 Nov 2008 15:39:30 -0500 Subject: [erlang-questions] gen_tcp:recv and hairloss In-Reply-To: <1ffe809c0811080738l52d31eefo9587ea8ed9eae03c@mail.gmail.com> References: <4507-26934@sneakemail.com> <1ffe809c0811080738l52d31eefo9587ea8ed9eae03c@mail.gmail.com> Message-ID: <10447-74249@sneakemail.com> > .... this and see what happens: > > ....() -> > {ok,LS} = gen_tcp:listen(7000,[binary,{active,false}]), > {ok,Sock} = gen_tcp:accept(LS), > spawn(fun() -> do_recv(Sock) end), > spawn(fun() -> do_recv(Sock) end), > ok. > > > do_recv(Socket) -> > io:format("Recv: ~p~n", [ gen_tcp:recv(Socket,0)]). > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > Point taken. I solved my problem by simply embracing gen_fsm:sync_send_event, which I was probably conceptually visualizing when I was using gen_fsm:send_event. A lot of advice I got was to use gen_tcp:controlling_process, but doesn't my success with passing a socket and reading in a Fsm, as well as the example above, show thats its a common myth that you need to use controlling_process if you wish to use gen_tcp:recv in a process that didn't accept the socket in the first place? I believe you only need to use controlling_process if you want the socket data sent as a erlang message to the process, and for that to happen it has to be {active, true}. From ok@REDACTED Tue Nov 11 00:56:01 2008 From: ok@REDACTED (Richard O'Keefe) Date: Tue, 11 Nov 2008 12:56:01 +1300 Subject: [erlang-questions] List to proplist? In-Reply-To: References: <6c2563b20810192156i7516e69aqb4d0eda2e1ee98d9@mail.gmail.com> <620F5FF0-93F8-4E0E-BBDA-5404E82BB054@cs.otago.ac.nz> Message-ID: On 8 Nov 2008, at 5:20 am, David Mercer wrote: > On Monday, October 20, 2008, Richard O'Keefe wrote > >> A version of unfold that I prefer is >> >> unfold(State, Splitter) -> >> unfold(State, Splitter, []). >> >> unfold(State, Splitter, Acc) -> >> case Splitter(State) >> of [] -> lists:reverse(Acc) >> ; [Item|State1] -> unfold(State1, Splitter, [Item|Acc]) >> end. > > Why is a cons cell, [Item|State1], preferred over a tuple, {Item, > State1}? Because it *MEANS* a cons. The algorithm uses [] to say "this State represents []" and [Item|State1] to say "this State represents [Item|Rest]". And yes, there is also a performance consideration that I wasn't blind to, but would not have allowed to override the mnemonic advantage had it gone the other way. From ok@REDACTED Tue Nov 11 01:08:07 2008 From: ok@REDACTED (Richard O'Keefe) Date: Tue, 11 Nov 2008 13:08:07 +1300 Subject: [erlang-questions] Idiom for multiple case matches In-Reply-To: <200811071824.mA7IOkKn010937@mail.pharos-avantgard.com> References: <200811071824.mA7IOkKn010937@mail.pharos-avantgard.com> Message-ID: <4DBCCFFE-37D3-4CC2-A856-25793B15C3E4@cs.otago.ac.nz> On 8 Nov 2008, at 7:25 am, Valentin Micic wrote: > Wouldn't this be a good candidate for a macro? > > -define( IS_WOVEL( C ), lists:member(C,"aeiouy") ). > > It would save one function call that just makes another call. > Maybe you'd like to run it against your benchmark? I'm extremely puzzled. The set of vowels in English is commonly defined as "aeiou", not including "y", which is called a "semi-vowel" and usually listed among the consonants. Basically, some "y"s are vowels and some are not, and you can't tell whether a particular character is acting as a vowel or not by looking only that that character. For example, "Union" begins with the vowel _letter_ U but the consonantal "y" _sound_; "hour" begins with the consonant _letter_ "h" but the vowel "ow" _sound_. Then there's the fact that most Western European languages include rather more vowel letters; considering the origins of Erlang it's relevant that Swedish is one of them. For that matter, the English writing system allows words like "na?ve", "co?perate", "Penelop?", and so on. I have a sister-in-law called "Ch?ri" who would like the third letter of her name treated as a vowel, and my father's middle name "?neas" starts with a vowel. Come to think of it, we all have "h?moglobin" in our veins, so there's another vowel. For what purpose are "aieouy" to be considered vowels and not all the other vowels in ISO Latin 1, let alone Unicode? For what purpose should "y" be considered a vowel even though it very often functions as a consonant? And now that we have PCRE (sigh) as a library, why is this not being handle by some sort of regular expression (which might, just _might_, have some hope of classifying letters with enough context inspected for the results to be reliable)? From ok@REDACTED Tue Nov 11 01:15:12 2008 From: ok@REDACTED (Richard O'Keefe) Date: Tue, 11 Nov 2008 13:15:12 +1300 Subject: [erlang-questions] What makes erlang software complex In-Reply-To: <1226093475.14426.12.camel@bautasten> References: <1226093475.14426.12.camel@bautasten> Message-ID: <431E8C08-4E0E-46F4-A6F1-656926B5D6AD@cs.otago.ac.nz> On 8 Nov 2008, at 10:31 am, Sten Kvamme wrote: > In imperative programming there is Cyclomatic complexity and N-path > complexity. What makes an erlang program complex? Cyclomatic complexity is just "count the IFs and add one" (flowchart version). As it happens, I'm on the Psychology of Programming Interest Group mailing list (the PPIG web site is www.ppig.org), and just last week someone asked about complexity. The short answer is that we haven't a clue how to measure "complexity" for ANY programming language. One thing that does seem clear is that complexity is a function of the reader as well as the text. Cyclomatic complexity can obviously be defined for functional code just as for imperative code. (Modulo difficult questions about how to count pattern matching.) Whether it would be useful to do so is another question; I've never found cyclomatic complexity particularly helpful for anything much. From oscar@REDACTED Tue Nov 11 02:53:36 2008 From: oscar@REDACTED (=?UTF-8?B?T3NjYXIgSGVsbHN0csO2bQ==?=) Date: Tue, 11 Nov 2008 01:53:36 +0000 Subject: [erlang-questions] Function Spec Syntax In-Reply-To: <1AD39C50692242968456DDA13127070B@SSI.CORP> References: <1AD39C50692242968456DDA13127070B@SSI.CORP> Message-ID: <4918E5A0.8000502@erlang-consulting.com> Hi, At the moment, both. That is, if you like to generate EDoc with type specifications *and* help dialyzer. As far as I know there are work being done on EDoc to understand -spec specs. David Mercer wrote: > Out of curiosity, should I be using edoc @spec syntax, Dialyzer ?spec > syntax, or both in my modules? > > > > Mercer > > > > > > > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions Best regards -- Oscar Hellstr?m, oscar@REDACTED Phone: +44 (0)798 45 44 773 Mobile: +44 (0)207 65 50 337 Web: http://www.erlang-consulting.com From erlang-questions_efine@REDACTED Tue Nov 11 03:15:12 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Mon, 10 Nov 2008 21:15:12 -0500 Subject: [erlang-questions] gen_tcp:recv and hairloss In-Reply-To: <10447-74249@sneakemail.com> References: <4507-26934@sneakemail.com> <1ffe809c0811080738l52d31eefo9587ea8ed9eae03c@mail.gmail.com> <10447-74249@sneakemail.com> Message-ID: <6c2563b20811101815t433005c5kd953e0b9a2427666@mail.gmail.com> > > > A lot of advice I got was to use gen_tcp:controlling_process, but > doesn't my success with passing a socket > and reading in a Fsm, as well as the example above, show thats its a > common myth that you need to use controlling_process if you > wish to use gen_tcp:recv in a process that didn't accept the socket in > the first place? I believe you only need to use > controlling_process if you want the socket data sent as a erlang message > to the process, and for that to happen it has to be {active, true}. Actually, there's more to it than that. When a process creates a socket, it becomes linked to the port corresponding to the socket. When that process dies, so do all the sockets (ports) it has created. If in the meantime you have passed such sockets to other processes, they will get a rude surprise (i.e. {error, closed}) when the creating process dies, because all the sockets it is linked to will get closed. Therefore, if you have a listener process that is trying to spawn independent processes that won't be affected if the listener dies, you must use gen_tcp:controlling_process/2 to transfer the socket to the other process. I'm sure there are other effects, too, but that's a biggie. In your case, if you actually want the gen_fsm's socket to close when your main process exits, then don't call controlling_process. Regards, Edwin -------------- next part -------------- An HTML attachment was scrubbed... URL: From mbj@REDACTED Tue Nov 11 08:49:03 2008 From: mbj@REDACTED (Martin Bjorklund) Date: Tue, 11 Nov 2008 08:49:03 +0100 (CET) Subject: [erlang-questions] The best way to write user-friendly log from an OTP application In-Reply-To: <3bff71aa0811100744k66cab5e6s8d3ad6267ddc5c6@mail.gmail.com> References: <3bff71aa0811100744k66cab5e6s8d3ad6267ddc5c6@mail.gmail.com> Message-ID: <20081111.084903.87091269.mbj@tail-f.com> Hi, "Sergey A." wrote: > I'm looking for the best way to write a plain text log containing the > reasons of some well-known errors happening in my OTP applications. > The log should be like this: > > --------------------------------8<-------------------------------- > [2008-11-6 23:0:53] Such an ip and port already in use. > [2008-11-6 23:1:45] Login or password is wrong > --------------------------------8<-------------------------------- > > Here is what I'm doing just now to achieve this behaviour: > > I use a gen_event module connected to the error_logger as a handler to > catch all the errors (and it is where I write my log). You might want to look at logger.erl and disk_log_h.erl in jungerl. > But there are two mutually exclusive ways to denote that error has happened: > > 1) Do nothing. Just let the crash happen. A process will crash and > you'll get a huuuuge message in your gen_event handler: [...] > 2) Decide the point where an error happen, and then call: > > error_logger:error_msg({my_error, Reason}) [...] > What of the ways listed above is the best in your opinon and why? As always, it depends on the application. In our system, we separate the normal error_logger log from logs aimed for the end user. We use the error_logger to print crashes and other internal errors. This log *should* always be empty, otherwise we have a bug in our system. We use the logger.erl and disk_log_h.erl modules for this log. Then we have a set of logs for the user (audit logs etc.) and for these we use explicit calls in the code. /martin From kenneth.lundin@REDACTED Tue Nov 11 08:50:37 2008 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Tue, 11 Nov 2008 08:50:37 +0100 Subject: [erlang-questions] clarify: intrument module - status In-Reply-To: <14f0e3620811080916t6bdd2e25heaa92e305176f833@mail.gmail.com> References: <14f0e3620811080916t6bdd2e25heaa92e305176f833@mail.gmail.com> Message-ID: The instrument module is used in combination with starting the VM with +Mistrue. It is not used often but can sometimes give very valuable info when it comes to analyzing the memory usage of a system. Especially when there is some unexpected memory consumption that needs to be tracked down. /Kenneth Erlang/OTP Ericsson On Sat, Nov 8, 2008 at 6:16 PM, Gleb Peregud wrote: > Hi folks, > > What is the status of module "intrument" [1] ? Note about it being > experimental is quite old... Is it being used by someone? > > 1: http://www.erlang.org/doc/man/instrument.html > > BR > -- > Gleb Peregud > http://gleber.pl/ > > Every minute is to be grasped. > Time waits for nobody. > -- Inscription on a Zen Gong > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From kostis@REDACTED Tue Nov 11 09:12:22 2008 From: kostis@REDACTED (Kostis Sagonas) Date: Tue, 11 Nov 2008 10:12:22 +0200 Subject: [erlang-questions] Function Spec Syntax In-Reply-To: <1AD39C50692242968456DDA13127070B@SSI.CORP> References: <1AD39C50692242968456DDA13127070B@SSI.CORP> Message-ID: <49193E66.4080203@cs.ntua.gr> David Mercer wrote: > Out of curiosity, should I be using edoc @spec syntax, Dialyzer ?spec > syntax, or both in my modules? The answer depends on what you want to do. If you need to generate documentation for your code now, your only option is to use edoc specs. However, note that edoc specs are just comments and are not really checked for consistency w.r.t. the code. If you want to have specifications whose correspondence with the code is mechanically checked, then you should use -specs. If you want both of the above, for the time being you should use both. But the current plan is that -specs will eventually supersede @specs and Edoc will be adapted to generate documentation from them. Most probably this will happen in R14 (March 2009 or about). Kostis From dmorton@REDACTED Tue Nov 11 09:44:05 2008 From: dmorton@REDACTED (damien morton) Date: Tue, 11 Nov 2008 19:44:05 +1100 Subject: [erlang-questions] match specifications - find all matches Message-ID: <8092dc770811110044r7616694do11c3f4e1f680b18e@mail.gmail.com> I'm trying to use compiled match specifications for an algorithm whereby I want to find from a set of functions all possible functions that might match a given message. The idea is to extract the arguments pattern and guards from each function and compile them all into one large match specification, with a single MatchFunction corresponding to each function. What I cant figure out is how to persuade the erlang:ms_test function to return multiple possible matches - it only returns the first match. Was thinking that I could use the trace functions somehow to do this, but they don't seem to be available from the erlang_ms_test function. If anyone has any pointers as to how to do this, they would be greatly appreciated. I know I can run a series of match-specs one at a time, but I expect that compiling them into one large match-spec will be more efficient. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ingela@REDACTED Tue Nov 11 10:24:31 2008 From: ingela@REDACTED (Ingela Anderton Andin) Date: Tue, 11 Nov 2008 10:24:31 +0100 Subject: [erlang-questions] Replacing default shell in sshd In-Reply-To: References: Message-ID: <49194F4F.5060307@erix.ericsson.se> Hi! > I was looking at the ssh module because I was somewhat interested in > making a MUD in erlang that people can ssh into, but I can't quite > figure out how I should go about doing this. > It appears that {shell, start, []} is the default shell, but when I > read the related source it had a lot of code dealing with shell > specific code, and I could not easily figure out exactly what messages > the ssh module expects it to respond to. Can anyone tell me exactly > what kind of behavior a replacement module requires for the ssh module > to work correctly? I am afraid the ssh code is not very clean at the moment. It has been subject to major refactoring leading up to ssh-1.0 version. Alas due to other things getting higher priority the work with this was not really completed and we where forced to make a somewhat "in between version" as there where changes needed by customers that could not wait but no time to finish it properly. (Still called it 1.0 to reflect that it was a major change and the API changed a lot). There are also a lot of code that is there to make it work at least as well as before but can be really ugly and confusing and in some cases even wrong, so to speak bug compatible with the older version. And of course a lot of code is there to still support the old API to make the transistion smoother. Unfotunatly the old API had almost no documentation and was not written by the OTP-team, so as far as we know latest ssh is backwards compatible. I do not have a good short answer for you at the moment. There is an example in ssh/exampels directory of a cli but I can not *guarantee *that It works or is up to date. Maybe it can help a little. We are continuously working to improve the ssh application and as usual there are also other things competing for our time so please have some patiences, it is getting there. > Furthermore, does anyone see anything that makes the ssh module > unsuitable for what I'd like to do? Conceptually I see no problem, but maybe there are some inmprovements needed in the ssh application before it will work smoothly. > Also, just to point something out, when I start the ssh server, the > server will crash if I do not have DSA keys in the system directory. > Having RSA keys only does not work and, in fact, I am not certain the > daemon is capable of using RSA keys server side. There might be a problem here we will look into it. Regards Ingela Erlang/OTP - Ericsson From ingela@REDACTED Tue Nov 11 10:38:45 2008 From: ingela@REDACTED (Ingela Anderton Andin) Date: Tue, 11 Nov 2008 10:38:45 +0100 Subject: [erlang-questions] Replacing default shell in sshd (Charles Ahn) In-Reply-To: References: Message-ID: <491952A5.5080206@erix.ericsson.se> erlang-questions-request@REDACTED wrote: [...] > I read along and then the code enters the mysterious world > of supervisors and I get lost. > > I am sure the mysterious world of supervisors are not the big problem of following the ssh code. Supervisors are not all that magical maybe if you are not used to them there are a few things you need to learn before everything becomes clear. People not used to gen_servers usually think they are magical too. But for reasons I explained earlier in this thread there are a lot mysterious code in ssh and we are doing our best to eventually remove it. Regards Ingela Erlang/OTP - Ericsson From pguyot@REDACTED Tue Nov 11 10:42:50 2008 From: pguyot@REDACTED (Paul Guyot) Date: Tue, 11 Nov 2008 10:42:50 +0100 Subject: [erlang-questions] dialyzer and re(3) Message-ID: <4CBA50BA-889C-45A4-B9FB-4240DBD5D679@kallisys.net> Hello, dialyzer does not know native functions of re(3) module and this makes it impossible to check our code that now uses re:compile/2, unless we remove re.beam from the plt. Is there a better workaround? Paul From nexes300@REDACTED Tue Nov 11 11:31:34 2008 From: nexes300@REDACTED (Charles Ahn) Date: Tue, 11 Nov 2008 02:31:34 -0800 Subject: [erlang-questions] Replacing default shell in sshd In-Reply-To: <49194F4F.5060307@erix.ericsson.se> References: <49194F4F.5060307@erix.ericsson.se> Message-ID: <01E8F38D-5170-46E4-8159-5F3908A42931@gmail.com> Hello, Actually that was very helpful because, after reading both you and some documentation mention this "example" directory, I decided to seriously look for it, and finally found it in the source (I was looking in the /usr/local/lib/erlang directories before). The example was actually helpful because I saw it pass a 2 arity fun to ssh_cli:listen, and I thought I'd look for something similar in the actual ssh code. After some digging around (and guessing what supervisors did) I found start_shell in ssh_cli.erl which made it clear that the shell option didn't have to be a tuple of {module, function, args} but could instead be a function, and that answered a question of how to tell the custom shell which user is logged in. It's a shame though, if the documentation specified what kind of values the shell option took then it would have been a lot simpler/clearer. Because I thought the shell option had to be of the form {module, function, [args]}, I saw no way to pass User info into it, but now I see that it is indeed easily possible by passing {shell, fun(U) customShell(U) end} as an option. I did know that there were API changes (it was why I updated to the newest version so I don't write a bunch of code that isn't supported later, heh) but I wasn't aware that it wasn't finished. Now that I have figured out how get the user name, I guess my only real problem with using ssh this way is that one user logging out seems to close all other connections as well. Other than that, it seems like this will work pretty well to make a mud, and I was rather impressed by the flexibility of the code (once I figured out how to make it do these flexible things) and the real problem for me was a lack of documentation. I do have one more question, if I use io:get_line and (before the user inputs anything) decide I no longer want to get anything, is there a way to cancel the get_line? Other than that, thanks for pointing me to that file! Charles On Nov 11, 2008, at 1:24 AM, Ingela Anderton Andin wrote: > Hi! > >> I was looking at the ssh module because I was somewhat interested in >> making a MUD in erlang that people can ssh into, but I can't quite >> figure out how I should go about doing this. > >> It appears that {shell, start, []} is the default shell, but when I >> read the related source it had a lot of code dealing with shell >> specific code, and I could not easily figure out exactly what >> messages >> the ssh module expects it to respond to. Can anyone tell me exactly >> what kind of behavior a replacement module requires for the ssh >> module >> to work correctly? > > I am afraid the ssh code is not very clean at the moment. It > has been subject to major refactoring leading up to ssh-1.0 version. > Alas > due to other things getting higher priority the work with this was not > really completed and we where forced to make a somewhat "in between > version" > as there where changes needed by customers that could not wait but > no time to > finish it properly. (Still called it 1.0 to reflect that it was a > major change and the > API changed a lot). There are also a lot of code that is there to > make it work > at least as well as before but can be really ugly and confusing and > in some cases even wrong, so to speak bug compatible with the older > version. > And of course a lot of code is there to still support the old API > to make the transistion > smoother. Unfotunatly the old API had almost no documentation and > was not written > by the OTP-team, so as far as we know latest ssh is backwards > compatible. > > I do not have a good short answer for you at the moment. There is an > example > in ssh/exampels directory of a cli but I can not *guarantee *that It > works or is > up to date. Maybe it can help a little. > > We are continuously working to improve the ssh application and as > usual there > are also other things competing for our time so please have some > patiences, it is > getting there. > >> Furthermore, does anyone see anything that makes the ssh module >> unsuitable for what I'd like to do? > > Conceptually I see no problem, but maybe there are some > inmprovements needed in > the ssh application before it will work smoothly. > >> Also, just to point something out, when I start the ssh server, the >> server will crash if I do not have DSA keys in the system directory. >> Having RSA keys only does not work and, in fact, I am not certain the >> daemon is capable of using RSA keys server side. > > There might be a problem here we will look into it. > > Regards Ingela Erlang/OTP - Ericsson > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2419 bytes Desc: not available URL: From kostis@REDACTED Tue Nov 11 11:33:44 2008 From: kostis@REDACTED (Kostis Sagonas) Date: Tue, 11 Nov 2008 12:33:44 +0200 Subject: [erlang-questions] dialyzer and re(3) In-Reply-To: <4CBA50BA-889C-45A4-B9FB-4240DBD5D679@kallisys.net> References: <4CBA50BA-889C-45A4-B9FB-4240DBD5D679@kallisys.net> Message-ID: <49195F88.3020302@cs.ntua.gr> Paul Guyot wrote: > Hello, > > dialyzer does not know native functions of re(3) module and this makes > it impossible to check our code that now uses re:compile/2, unless we > remove re.beam from the plt. I do not think you should worry about the above or take any action. The fact that dialyzer does not know anything about some function of the re module in no way affects the correctness of the analysis. It just means that dialyzer might not be able to detect all discrepancies involving re Nothing to worry about... Kostis From pguyot@REDACTED Tue Nov 11 12:15:57 2008 From: pguyot@REDACTED (Paul Guyot) Date: Tue, 11 Nov 2008 12:15:57 +0100 Subject: [erlang-questions] dialyzer and re(3) In-Reply-To: References: Message-ID: <174F0F95-A872-4E2D-9589-79096F66E003@kallisys.net> Le 11 nov. 08 ? 12:00, erlang-questions-request@REDACTED a ?crit : > Date: Tue, 11 Nov 2008 12:33:44 +0200 > From: Kostis Sagonas > Subject: Re: [erlang-questions] dialyzer and re(3) > To: erlang-questions@REDACTED > Message-ID: <49195F88.3020302@REDACTED> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > >> dialyzer does not know native functions of re(3) module and this >> makes >> it impossible to check our code that now uses re:compile/2, unless we >> remove re.beam from the plt. > > I do not think you should worry about the above or take any action. > The > fact that dialyzer does not know anything about some function of the > re > module in no way affects the correctness of the analysis. It just > means > that dialyzer might not be able to detect all discrepancies > involving re > > Nothing to worry about... I am not worrying about dialyzer's error message. Our continuous integration server runs dialyzer and fails if dialyzer reports anything of this level. I don't want to ignore dialyzer errors, so the workaround was to remove re.beam from the PLT -- therefore calls to re:compile/2 just becomes calls to an unknown function in an unknwon module, and this is not fatal. I am just wondering if there is a better workaround. While we appreciate dialyzer very much and we rely on it, we are somewhat disappointed by its current limitations and horrible slowness, especially when compared to ocaml compiler which does type inference and checking faster by a magnitude... Paul From masse@REDACTED Tue Nov 11 12:19:51 2008 From: masse@REDACTED (mats cronqvist) Date: Tue, 11 Nov 2008 12:19:51 +0100 Subject: [erlang-questions] Idiom for multiple case matches In-Reply-To: <66BE84A76DFC4FBE86A2831B123B4893@SSI.CORP> (David Mercer's message of "Mon\, 10 Nov 2008 11\:05\:15 -0600") References: <24d4f39c0811051008n1ad4ed72o5f20b783a092a2f0@mail.gmail.com> <3dbc6d1c0811070214h742d3e4ah6ea425ca23c16706@mail.gmail.com> <87k5bf1uq0.fsf@sterlett.hq.kred> <20081107150753.7D8B824062@relay.gooddata.com> <8209f740811070852k2a8c9df6lf932035f9e9fd4f1@mail.gmail.com> <6c2563b20811070912l1f79eda9i3345c6d0ce2ab9a@mail.gmail.com> <20081107172952.3953724062@relay.gooddata.com> <87skq3pazk.fsf@dixie.cronqvi.st> <20081107202742.GA3654@herbie> <87fxm05wjw.fsf@dixie.cronqvi.st> <66BE84A76DFC4FBE86A2831B123B4893@SSI.CORP> Message-ID: <87r65i8q7c.fsf@sterlett.hq.kred> "David Mercer" writes: > Since this is, semantically, a set operation, should we not perhaps use > sets:is_element/2 instead? Something like: > > vowels() -> sets:from_list("aeiou"). > is_vowel(C) -> sets:is_element(C, vowels()). > > Just kidding, of course... (Obvious efficiency issues.) :-) > > DBM > > P.S. No, Mats, I did not benchmark this. :-) benchmark is (or at least ought to be) required only if you claim *improved* performance... mats From 0x6e6562@REDACTED Tue Nov 11 12:53:16 2008 From: 0x6e6562@REDACTED (Ben Hood) Date: Tue, 11 Nov 2008 11:53:16 +0000 Subject: [erlang-questions] gen_server:cast/2 reordering In-Reply-To: References: <269388e30811100703p326528kd16ce8b7ee2366be@mail.gmail.com> Message-ID: <269388e30811110353n56dfb346r3e780141b2be32d0@mail.gmail.com> Kenneth, On Mon, Nov 10, 2008 at 8:35 PM, Kenneth Lundin wrote: > You can use > Dest ! { '$gen_cast, Msg} > to get a guaranteed order > On the other hand your process will be blocked until a connection with > the other E-node > is established or the connection attempt has failed. Thanks for the clarification and sorry for spamming the list (my message didn't appear to be visible on the list some few hours - maybe this is due to people downloading R12B-5) Ben From ali.yakout@REDACTED Tue Nov 11 12:51:54 2008 From: ali.yakout@REDACTED (Ali Yakout) Date: Tue, 11 Nov 2008 12:51:54 +0100 Subject: [erlang-questions] Edoc href problem with '&' Message-ID: Hi, I'm trying to place a link in my overview.edoc that contains the '&' character the overview.edoc contains something like Link $ gmake doc overview.edoc: at line 8: error in XML parser: {fatal, {error_scanning_entity_ref, {file,file_name_unknown}, {line,11}, {col,109}}}. edoc: error in doclet 'edoc_doclet': {'EXIT',error}. I tried to replace the '&' with the xml code \& >Link The edoc then succeeds but the link is unusable :( It appears in the html like http://mysite.com/url?docno=\&objectId=09004cff82bf1356\&action= current\&format=pdf Any clues for this problem? Thanks, Ali Yakout -------------- next part -------------- An HTML attachment was scrubbed... URL: From tobias.lindahl@REDACTED Tue Nov 11 13:36:33 2008 From: tobias.lindahl@REDACTED (Tobias Lindahl) Date: Tue, 11 Nov 2008 13:36:33 +0100 Subject: [erlang-questions] dialyzer and re(3) In-Reply-To: <174F0F95-A872-4E2D-9589-79096F66E003@kallisys.net> References: <174F0F95-A872-4E2D-9589-79096F66E003@kallisys.net> Message-ID: <49197C51.5050401@kreditor.se> Paul Guyot wrote: > > While we appreciate dialyzer very much and we rely on it, we are > somewhat disappointed by its current limitations and horrible > slowness, especially when compared to ocaml compiler which does type > inference and checking faster by a magnitude... Well, that is what you get when trying to infer types in a language that was not built for static type checking. Dialyzer came about as a way to get some of the benefits from static typing while keeping the benefits of dynamic typing. Dialyzer can certainly be both faster and more accurate, but it will probably never be as fast (or prohibiting) as the type inference/checking in ocaml. On the other hand, if you can live with the slowness and inaccuracy of Dialyzer, you might find a bug or two... Tobias From richardc@REDACTED Tue Nov 11 13:47:44 2008 From: richardc@REDACTED (Richard Carlsson) Date: Tue, 11 Nov 2008 13:47:44 +0100 Subject: [erlang-questions] Edoc href problem with '&' In-Reply-To: References: Message-ID: <49197EF0.6020203@it.uu.se> Ali Yakout wrote: > Hi, > > I'm trying to place a link in my overview.edoc that contains the '&' character > the overview.edoc contains something like > href="http://mysite.com/url?docno=&objectId=09004cff82bf1356&action=current&format=pdf" > > $ gmake doc > overview.edoc: at line 8: error in XML parser: {fatal, > {error_scanning_entity_ref, > {file,file_name_unknown}, > {line,11}, > {col,109}}}. > edoc: error in doclet 'edoc_doclet': {'EXIT',error}. This is normal - you cannot use & characters in the XHTML text except as part of an entity reference. > I tried to replace the '&' with the xml code \& > href=http://mysite.com/url?docno=\&objectId=09004cff82bf1356\&action=current\&format=pdf It should be written without a backslash: just & or & (and the href string needs double-quotes around it). > The edoc then succeeds but the link is unusable :( > It appears in the html like > http://mysite.com/url?docno=\&objectId=09004cff82bf1356\&action=current\&format=pdf > It is unusable because of the \ characters. When I write the link like this in overview.edoc: href="http://mysite.com/url?docno=&objectId=09004cff82bf1356&action=current&format=pdf" I get the following (identical) text in the generated HTML: href="http://mysite.com/url?docno=&objectId=09004cff82bf1356&action=current&format=pdf" which the browser interprets (or should interpret) as http://mysite.com/url?docno=&objectId=09004cff82bf1356&action=current&format=pdf and everything works fine. See for example this blog for more information: http://thesimpleweb.blogspot.com/2005/09/why-you-should-escape-your-ampersands.html (Since edoc parses your xhtml and later exports it to a new file, there is no choice involved - you must escape your ampersands, even in URLs.) /Richard From gleber.p@REDACTED Tue Nov 11 14:44:24 2008 From: gleber.p@REDACTED (Gleb Peregud) Date: Tue, 11 Nov 2008 14:44:24 +0100 Subject: [erlang-questions] How can I turn a working escript into erl-shell? In-Reply-To: <6c2563b20811101129x58e934fbt84d9838a8202ab59@mail.gmail.com> References: <3bff71aa0811100840g46353b8eyf51f992b78bc718c@mail.gmail.com> <6c2563b20811101129x58e934fbt84d9838a8202ab59@mail.gmail.com> Message-ID: <14f0e3620811110544o5ce61933u30991b223f9133f6@mail.gmail.com> Take a look at erl_call. It allows sending commands to the node (the 'rex' server) from the bash command line or script. It is also probably much faster then erl -eval '...' and does not appear in nodes(). BR On 11/10/08, Edwin Fine wrote: > Sergey, > > I use bash together with the -eval command-line option. I find this gives me > great flexibility because I can embed Erlang code directly in my shell > script and enjoy the benefits of both bash and escript. It took a while to > get the magical incantations right, but now it works like a charm. If I need > to talk to an application on another node, I can do so as you say using rpc. > And, of course, starting a shell is trivial from bash. > > For example, here's a Bash shell function I use: > > kill_node() { > echo "Node ${ERL_NODE_NAME} did not shut down when asked nicely, now > halting it." > ${ERL_CMD} -noshell -noinput -boot ${CLEAN_BOOT_FILE} -sname ${USER}$$ \ > -eval ' > Node = '''${ERL_NODE_NAME}''', > rpc:call(Node, erlang, halt, [], 3000), > init:stop(). ' > } > > ERL_CMD uses erlexec directly, e.g. > > export ROOTDIR=... > export BINDIR=... > ERL_CMD="${BINDIR}/erlexec -config ${CONFIG_FILE}" > > Regards, > Edwin > > On Mon, Nov 10, 2008 at 11:40 AM, Sergey A. wrote: > >> Hello. >> >> As I known there are two well-known approaches for writing a comand >> line interface for an erlang program: using escript and bash. >> >> I've chose escript as the language for writing my first interface. >> >> I hope it will be useful to see the source for somebody who is writing >> escript interface now. It's here: >> >> http://gist.github.com/23516 >> >> Now about the question I have. With bash I can turn a working script >> into any program just by calling something like: >> >> erl -sname dbg -remsh myapp # <-- this starts the Erlang shell and >> tell it to connect to a remote node. After the shell will be closed, >> script will continue >> >> Thus, the bash script can be used both as a tool for manipulating a >> working Erlang application (you can call rpc:call, or smth like) and >> as a tool for opening Erlang shell with all the arguments passed >> (which is very useful when debugging. It just make life easy). >> >> Is there any way to open the erlang shell from an escript? >> >> Thanks. >> >> -- >> Sergey. >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> >> > -- Gleb Peregud http://gleber.pl/ Every minute is to be grasped. Time waits for nobody. -- Inscription on a Zen Gong From thomasl_erlang@REDACTED Tue Nov 11 14:26:37 2008 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Tue, 11 Nov 2008 05:26:37 -0800 (PST) Subject: [erlang-questions] dialyzer and re(3) In-Reply-To: <174F0F95-A872-4E2D-9589-79096F66E003@kallisys.net> Message-ID: <344516.52834.qm@web38801.mail.mud.yahoo.com> --- On Tue, 11/11/08, Paul Guyot wrote: > While we appreciate dialyzer very much and we rely on it, > we are > somewhat disappointed by its current limitations and > horrible > slowness, especially when compared to ocaml compiler which > does type > inference and checking faster by a magnitude... Sounds like you really should switch to OCaml; I've heard it's very fast too. Good luck with your future endeavours. Best, Thomas From pguyot@REDACTED Tue Nov 11 15:48:51 2008 From: pguyot@REDACTED (Paul Guyot) Date: Tue, 11 Nov 2008 15:48:51 +0100 Subject: [erlang-questions] dialyzer and re(3) In-Reply-To: References: Message-ID: <8E08C960-51AC-4010-A932-265AAC8584A6@kallisys.net> Le 11 nov. 08 ? 15:27, erlang-questions-request@REDACTED a ?crit : > Message: 8 > Date: Tue, 11 Nov 2008 05:26:37 -0800 (PST) > From: Thomas Lindgren > Subject: Re: [erlang-questions] dialyzer and re(3) > To: erlang-questions@REDACTED > Message-ID: <344516.52834.qm@REDACTED> > Content-Type: text/plain; charset=us-ascii > > >> While we appreciate dialyzer very much and we rely on it, >> we are >> somewhat disappointed by its current limitations and >> horrible >> slowness, especially when compared to ocaml compiler which >> does type >> inference and checking faster by a magnitude... > > Sounds like you really should switch to OCaml; I've heard it's very > fast too. Good luck with your future endeavours. I only mentioned ocaml as an illustration that the job of infering types and checking them can be much faster than what dialyzer currently does, which is patent for anyone who worked with ocaml. Tobias argued that the job is slightly different, and I trust him on that matter. I just wish less CPU cycles would be spent on things like rebuilding the PLT at each release or checking the types for our project. Each language has its pros and cons, and I don't mean to start any ocaml vs erlang discussion here. Dialyzer was part of our choice of erlang for this project, and its slowness doesn't change anything. Paul From richardc@REDACTED Tue Nov 11 16:12:37 2008 From: richardc@REDACTED (Richard Carlsson) Date: Tue, 11 Nov 2008 16:12:37 +0100 Subject: [erlang-questions] dialyzer and re(3) In-Reply-To: <174F0F95-A872-4E2D-9589-79096F66E003@kallisys.net> References: <174F0F95-A872-4E2D-9589-79096F66E003@kallisys.net> Message-ID: <4919A0E5.2060506@it.uu.se> Paul Guyot wrote: > While we appreciate dialyzer very much and we rely on it, we are > somewhat disappointed by its current limitations and horrible > slowness, especially when compared to ocaml compiler which does type > inference and checking faster by a magnitude... While I'm sure that Dialyzer could be faster, it is not really fair to compare it to the OCaml type checker - after all, they get to tailor the problem to the algorithm, not the other way around. Dialyzer is more in the vein of LCLint, Splint, Coverity, etc., and needs to do a lot of work to rediscover what the programmer probably intended. (And on top of that, Dialyzer is implemented in Erlang, which in itself cannot really compete with OCaml for this kind of compute-intensive tasks.) /Richard From kostis@REDACTED Tue Nov 11 17:34:04 2008 From: kostis@REDACTED (Kostis Sagonas) Date: Tue, 11 Nov 2008 18:34:04 +0200 Subject: [erlang-questions] dialyzer and re(3) In-Reply-To: <8E08C960-51AC-4010-A932-265AAC8584A6@kallisys.net> References: <8E08C960-51AC-4010-A932-265AAC8584A6@kallisys.net> Message-ID: <4919B3FC.4040104@cs.ntua.gr> Paul Guyot wrote: > Le 11 nov. 08 ? 15:27, erlang-questions-request@REDACTED a ?crit : > >> While we appreciate dialyzer very much and we rely on it, >> we are somewhat disappointed by its current limitations Can you please be a bit more specific about "its current limitations" ? (perhaps even off the list if you think that's more appropriate). While we definitely do not claim that Dialyzer is perfect (in fact, we have a long TODO list but very little time and/or support), it's not certain that our appreciation of its limitations and the prioritization of the issues fully agrees with those of its users... >> horrible slowness, especially when compared to ocaml compiler >> which does type inference and checking faster by a magnitude... > > I only mentioned ocaml as an illustration that the job of infering > types and checking them can be much faster than what dialyzer > currently does, which is patent for anyone who worked with ocaml. > Tobias argued that the job is slightly different, and I trust him on > that matter. Well, you probably misinterpreted Tobias. The job is not just slightly different, it's *vastly* different. For example, in ocaml there are type declarations, so the types are given by the programmer and each value can only be part of a single type: in other words, there is no subtyping and e.g. unions other than those explicitly declared by the programmer do not exist. Also, recursive types are regular -- for example, all lists are properly nil-terminated. There are many more differences. Although different people have different preferences, it's generally hard to compare apples and oranges objectively... Kostis From gleber.p@REDACTED Tue Nov 11 17:54:52 2008 From: gleber.p@REDACTED (Gleb Peregud) Date: Tue, 11 Nov 2008 17:54:52 +0100 Subject: [erlang-questions] clarify: intrument module - status In-Reply-To: References: <14f0e3620811080916t6bdd2e25heaa92e305176f833@mail.gmail.com> Message-ID: <14f0e3620811110854t59dcbd9fh2a8eb2d56d0ad636@mail.gmail.com> Thanks for clarification! On 11/11/08, Kenneth Lundin wrote: > The instrument module is used in combination with starting the VM with > +Mistrue. > It is not used often but can sometimes give very valuable info when it > comes to analyzing > the memory usage of a system. Especially when there is some unexpected > memory consumption that needs to > be tracked down. > > /Kenneth Erlang/OTP Ericsson > > > On Sat, Nov 8, 2008 at 6:16 PM, Gleb Peregud wrote: >> Hi folks, >> >> What is the status of module "intrument" [1] ? Note about it being >> experimental is quite old... Is it being used by someone? >> >> 1: http://www.erlang.org/doc/man/instrument.html >> >> BR >> -- >> Gleb Peregud >> http://gleber.pl/ >> >> Every minute is to be grasped. >> Time waits for nobody. >> -- Inscription on a Zen Gong >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > -- Gleb Peregud http://gleber.pl/ Every minute is to be grasped. Time waits for nobody. -- Inscription on a Zen Gong From kevin@REDACTED Tue Nov 11 17:57:24 2008 From: kevin@REDACTED (Kevin Scaldeferri) Date: Tue, 11 Nov 2008 08:57:24 -0800 Subject: [erlang-questions] Idiom for multiple case matches In-Reply-To: <87myg68or3.fsf@sterlett.hq.kred> References: <24d4f39c0811051008n1ad4ed72o5f20b783a092a2f0@mail.gmail.com> <3dbc6d1c0811070214h742d3e4ah6ea425ca23c16706@mail.gmail.com> <87k5bf1uq0.fsf@sterlett.hq.kred> <20081107150753.7D8B824062@relay.gooddata.com> <8209f740811070852k2a8c9df6lf932035f9e9fd4f1@mail.gmail.com> <6c2563b20811070912l1f79eda9i3345c6d0ce2ab9a@mail.gmail.com> <20081107172952.3953724062@relay.gooddata.com> <87skq3pazk.fsf@dixie.cronqvi.st> <20081107202742.GA3654@herbie> <87fxm05wjw.fsf@dixie.cronqvi.st> <72D0DE1F-981E-4AFD-AE8B-8ACA25F350B3@scaldeferri.com> <87myg68or3.fsf@sterlett.hq.kred> Message-ID: <702C499E-7039-4D17-9717-1D2798B6BBC8@scaldeferri.com> >>> >>> >>> and what you mean is presumably that 'is_vowel' is a function that >>> returns 'true' if its argument is a member of the list "aeiou", >>> otherwise 'false'. >>> >>> the fact that this is a fairly common task is of course the reason >>> why lists:member/2 exists in the first place. so by not using >>> lists:member/2 here, you are obfuscating the fact that you are >>> indeed testing if something is a member of a list. >> >> Well, if you want to be pedantic, that's completely wrong. There's >> nothing list-like about the collection of vowels. It's a set. > > i believe a list without duplicates is a set. no? Almost, but not exactly. But since your goal was to eschew obfuscation, why would you rely on the maintainer of the code noticing there are no duplicates, when instead you could express the constraint explicitly by using the proper data structure? -kevin -------------- next part -------------- An HTML attachment was scrubbed... URL: From erlang-questions_efine@REDACTED Tue Nov 11 18:09:26 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Tue, 11 Nov 2008 12:09:26 -0500 Subject: [erlang-questions] How can I turn a working escript into erl-shell? In-Reply-To: <14f0e3620811110544o5ce61933u30991b223f9133f6@mail.gmail.com> References: <3bff71aa0811100840g46353b8eyf51f992b78bc718c@mail.gmail.com> <6c2563b20811101129x58e934fbt84d9838a8202ab59@mail.gmail.com> <14f0e3620811110544o5ce61933u30991b223f9133f6@mail.gmail.com> Message-ID: <6c2563b20811110909x4ef8702bo8f2e386a43d763f7@mail.gmail.com> Gleb, On Tue, Nov 11, 2008 at 8:44 AM, Gleb Peregud wrote: > Take a look at erl_call. It allows sending commands to the node (the > 'rex' server) from the bash command line or script. It is also > probably much faster then erl -eval '...' and does not appear in > nodes(). > Thanks, I'll take a look. Edwin -------------- next part -------------- An HTML attachment was scrubbed... URL: From ci07eet2@REDACTED Mon Nov 10 20:37:27 2008 From: ci07eet2@REDACTED (Emir Taner) Date: Mon, 10 Nov 2008 19:37:27 -0000 Subject: [erlang-questions] Dissertation Presentation at Erlang London User Group References: <64508943A039C34D97F136F9E2E0DD43016D2A43@UXEXMBU115.academic.windsor> <64508943A039C34D97F136F9E2E0DD43016D2A44@UXEXMBU115.academic.windsor> Message-ID: <64508943A039C34D97F136F9E2E0DD43016D2A45@UXEXMBU115.academic.windsor> Dear Erlang Users, I will be presenting my MSc Dissertation titled "Simulation based research for observing High Availability, Reliability, Performance and Scalability using Virtualization and Live Migration" at Erlang Consulting London Offices on Tuesday, November 11. I will talk about concurrent and distributed computing within the aspect of terminal services, identify some problems and propose solutions. Then I will review and analyze the data I have collected about the proposed solutions. The data was collected using a simulation that I have developed for this dissertation using Erlang/OTP. Further information can be found at: http://www.erlang-consulting.com/erlang/events.html#69 Best Regards, Emir Taner From jon@REDACTED Tue Nov 11 20:41:39 2008 From: jon@REDACTED (Jonathan Haddad) Date: Tue, 11 Nov 2008 11:41:39 -0800 Subject: [erlang-questions] Handling a large number of DETS and ETS tables Message-ID: <12d754400811111141k1b33d34cn588b1d429fdf47cb@mail.gmail.com> Hey folks, I'm creating an application that will handle several ets or dets tables at once. I won't know the names of the tables before hand, they'll be dynamically created. Each table will most likely correspond to a domain name that's being tracked within the system, but there might be more depending on what limits I hit. I'm slightly concerned about DETS 2GB limit, and we want to be able to move individual domains into different nodes. (rev 2 is having the system do that automatically). What's a good way of dynamically managing which ones I have? I'm considering 2 methods so far. 1. Use list_to_atom to convert the domain name to an atom, and use that to register a process for that table. Each process manages a single table. 2. Have a single process which has all tables in a list, and uses the appropriate one for each request. This introduces a bottleneck at that process and seems like I'd want to avoid this one. Not to mention I'm somewhat defeating the purpose of using a language built for concurrency. What should I be considering as far as I/O issues are concerned? How does an ETS write compare to a simple disk write? Does it hold the data in memory for reads? Thanks, Jon -------------- next part -------------- An HTML attachment was scrubbed... URL: From q2h46uw02@REDACTED Tue Nov 11 21:56:36 2008 From: q2h46uw02@REDACTED (Kevin) Date: Tue, 11 Nov 2008 15:56:36 -0500 Subject: [erlang-questions] is this try expression idiom common? Message-ID: <10498-52278@sneakemail.com> Whether its the pragmatic book or the online docs, the impression I've always gotten about try..catch expressions is this try FuncOrExpressionSequence of Pattern1 [when Guard1] -> Expressions1; Pattern2 [when Guard2] -> Expressions2; catch ExceptionType1: ExPattern1 [when ExGuard1] -> ExExpressions1; ExceptionType2: ExPattern2 [when ExGuard2] -> ExExpressions2; end In fact the pragmatic book calls try...catch "like a case expression on steroids. It?s basically a case expression with catch and after blocks at the end." So, to a newbie like me, I've always assumed you needed case like pattern matchers inside the try. This was seriously cramping my style. I've just discovered you can simply do this doit() -> try a(), b(), c() catch throw:_ -> something_failed end. a() -> ok. b() -> throw(not_ok). c() -> ok. I guess this creative formatting of try a(), b(), c() catch throw:_ -> something_failed end. To me this is a completely different idiom, absolutely nothing like a case expression, and opens erlang up to a more exception based control flow and error handling. Is this legit? Frowned upon? I searched the pragmatic book and there is not a single example of this. From chsu79@REDACTED Tue Nov 11 22:39:14 2008 From: chsu79@REDACTED (Christian) Date: Tue, 11 Nov 2008 22:39:14 +0100 Subject: [erlang-questions] is this try expression idiom common? In-Reply-To: <10498-52278@sneakemail.com> References: <10498-52278@sneakemail.com> Message-ID: Read this paper for the design and intended use of the "new" (but improved) exception handling. http://www.erlang.se/workshop/2004/exception.pdf A shorter, but not so detailed, read is the erlang reference manual: http://erlang.org/doc/reference_manual/expressions.html#6.19 In short, yeah it is perfectly fine and it is what is documented. It should be noted that Erlang failure handling is much more focused around letting another process supervise and handle crashes. What should catch exceptions and what should use crashing is not so simple to define though. > To me this is a completely different idiom, absolutely nothing like a > case expression, and opens erlang up to a more exception based control > flow and error handling. Is this legit? Frowned upon? I searched the > pragmatic book and there is not a single example of this. From masse@REDACTED Tue Nov 11 22:49:57 2008 From: masse@REDACTED (mats cronqvist) Date: Tue, 11 Nov 2008 22:49:57 +0100 Subject: [erlang-questions] Idiom for multiple case matches In-Reply-To: <702C499E-7039-4D17-9717-1D2798B6BBC8@scaldeferri.com> (Kevin Scaldeferri's message of "Tue\, 11 Nov 2008 08\:57\:24 -0800") References: <24d4f39c0811051008n1ad4ed72o5f20b783a092a2f0@mail.gmail.com> <3dbc6d1c0811070214h742d3e4ah6ea425ca23c16706@mail.gmail.com> <87k5bf1uq0.fsf@sterlett.hq.kred> <20081107150753.7D8B824062@relay.gooddata.com> <8209f740811070852k2a8c9df6lf932035f9e9fd4f1@mail.gmail.com> <6c2563b20811070912l1f79eda9i3345c6d0ce2ab9a@mail.gmail.com> <20081107172952.3953724062@relay.gooddata.com> <87skq3pazk.fsf@dixie.cronqvi.st> <20081107202742.GA3654@herbie> <87fxm05wjw.fsf@dixie.cronqvi.st> <72D0DE1F-981E-4AFD-AE8B-8ACA25F350B3@scaldeferri.com> <87myg68or3.fsf@sterlett.hq.kred> <702C499E-7039-4D17-9717-1D2798B6BBC8@scaldeferri.com> Message-ID: <87vduu3pbu.fsf@dixie.cronqvi.st> Kevin Scaldeferri writes: > Well, if you want to be pedantic, that's completely wrong. There's > nothing list-like about the collection of vowels. It's a set. > > i believe a list without duplicates is a set. no? > > Almost, but not exactly. i guess "almost" is a lot better than "completely wrong"... > But since your goal was to eschew obfuscation, why would you rely > on the maintainer of the code noticing there are no duplicates, when > instead you could express the constraint explicitly by using the > proper data structure? i certainly think that using the set module is a lot better than the hardcoded function head match approach. and if the set was larger, it would be the only sensible solution. otoh, the literal "aeiou" is a perfectly fine representation of the set of "proper" vowels (as long as one ignores its orderedness). hardcoding it is comparable to hardcoding 3.14159 instead of using math:pi(). as far as obfuscation goes; since text is traditionally represented as lists of small integers, it makes sense to express sets of characters that way too. mats From masse@REDACTED Tue Nov 11 22:54:44 2008 From: masse@REDACTED (mats cronqvist) Date: Tue, 11 Nov 2008 22:54:44 +0100 Subject: [erlang-questions] is this try expression idiom common? In-Reply-To: <10498-52278@sneakemail.com> (Kevin's message of "Tue\, 11 Nov 2008 15\:56\:36 -0500") References: <10498-52278@sneakemail.com> Message-ID: <87r65i3p3v.fsf@dixie.cronqvi.st> "Kevin" writes: > I guess this creative formatting of > > try a(), b(), c() > catch > throw:_ -> something_failed > end. > > > To me this is a completely different idiom, absolutely nothing like a > case expression, and opens erlang up to a more exception based control > flow and error handling. Is this legit? Frowned upon? I searched the > pragmatic book and there is not a single example of this. i do this all the time; try a(),b(),c() catch _:R -> oops(R) end. excellent style, imo :> mats From n39052@REDACTED Wed Nov 12 01:12:17 2008 From: n39052@REDACTED (Sergey A.) Date: Tue, 11 Nov 2008 16:12:17 -0800 Subject: [erlang-questions] How can I turn a working escript into erl-shell? In-Reply-To: <3bff71aa0811100840g46353b8eyf51f992b78bc718c@mail.gmail.com> References: <3bff71aa0811100840g46353b8eyf51f992b78bc718c@mail.gmail.com> Message-ID: <3bff71aa0811111612tbe755ddr24a2072acc896b60@mail.gmail.com> Edwin Fine, Gleb Peregud thanks for your suggestions. It looks like my decision to use escript was a mistake. Now I'm going to try bash for that. -- Sergey From n39052@REDACTED Wed Nov 12 01:13:42 2008 From: n39052@REDACTED (Sergey A.) Date: Tue, 11 Nov 2008 16:13:42 -0800 Subject: [erlang-questions] The best way to write user-friendly log from an OTP application In-Reply-To: <20081111.084903.87091269.mbj@tail-f.com> References: <3bff71aa0811100744k66cab5e6s8d3ad6267ddc5c6@mail.gmail.com> <20081111.084903.87091269.mbj@tail-f.com> Message-ID: <3bff71aa0811111613qf7b850cyb5d560ceb42468d@mail.gmail.com> Thanks, for your answer. > You might want to look at logger.erl and disk_log_h.erl in jungerl. Thanks, I'll take a look. > We use the error_logger to print crashes and other internal errors. > This log *should* always be empty, otherwise we have a bug in our > system. We use the logger.erl and disk_log_h.erl modules for this > log. > > Then we have a set of logs for the user (audit logs etc.) and for > these we use explicit calls in the code. Thanks! Your answer has shown me the benefits of such a separating. I need only to log crashes, so using error_logger:error_report/2 in conjunction with gen_event callback (for catching all the well-known errors and writing "user-friendly" logs for admins) seems to be a good solution for me. -- Sergey. From realaqura@REDACTED Wed Nov 12 04:48:19 2008 From: realaqura@REDACTED (leon zhao) Date: Wed, 12 Nov 2008 11:48:19 +0800 Subject: [erlang-questions] memory alloc failed? Message-ID: <2f39bec70811111948l5ad4b74bm3d949b41e17bcffa@mail.gmail.com> hi all: I have a multi-process project, it create and destroy 500 process per second, and maintain 3000 process, the beam use 900M memory to 1.2G, after running 20 hours, it was restarted by kernel, and i found error like this: __alloc_pages: 0-order allocation failed (gfp=0x20/1) so, anyone can tell me some information or some tips? May I use garbage_collect() before every process exit to force free memory? great thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From stondage123@REDACTED Wed Nov 12 04:51:54 2008 From: stondage123@REDACTED (Andrew Stone) Date: Tue, 11 Nov 2008 19:51:54 -0800 (PST) Subject: [erlang-questions] Communicating Erlang and mozart References: Message-ID: <503192.72878.qm@web35908.mail.mud.yahoo.com> Enrique, A sample is not particularly easy to give, however what you are talking about is a data serialization (marshaling) issue. See http://www.webopedia.com/TERM/D/data_marshalling.html It is my opinion that using sockets for communication between different languages has a number of benefits and I wouldn't want to dissuade you from using them. In fact I have a significant chunk of code that passes data back and forth over TCP between Erlang and C++. It marshals the private data members of C++ classes which then get unmarshaled into the appropriate data structure on the Erlang side. We use cdr marshaling for this, however there is an infinite number of possibile marshaling formats. One of the simplest is Joe Armstrongs UBF(A) http://www.sics.se/~joe/ubf/site/home.html. You could also of course transform all the data into xml or json and then convert the structures based on the json/xml back into the native data structures of Erlang and XML. Good luck. -Andrew ----- Original Message ---- From: Jose Enrique Benitez Jimenez To: erlang-questions@REDACTED Sent: Sunday, November 9, 2008 12:50:25 PM Subject: [erlang-questions] Communicating Erlang and mozart Hello, I am developing a proyect involving Mozart and Erlang and I need to communicate each other, I was thinking to use socket, but then I do not know how to structure the messages so that they understand each other, What if there is any standard, which serves to this case, and if you can give me a simple example, It would be very helpful, thank you very much. Enrique _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions From kenneth.lundin@REDACTED Wed Nov 12 08:57:06 2008 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Wed, 12 Nov 2008 08:57:06 +0100 Subject: [erlang-questions] Communicating Erlang and mozart In-Reply-To: <503192.72878.qm@web35908.mail.mud.yahoo.com> References: <503192.72878.qm@web35908.mail.mud.yahoo.com> Message-ID: Hi, There is already a data serialization format for Erlang and there is libraries for Java and C provided in the Open Source distribution which support this format. The data format can be used on a plain socket back and forth between Erlang and something external. There is also support for so called C-nodes and Java-nodes which means that a C-program or java program behaves as if it was a distributed Erlang node connecting to other nodes with the Erlang distribution protocol. I suggest you either use the C library (called erl_interface) and integrate it with Mozart or you implement the data serialization and perhaps also the distribution protocol directly in Mozart. You find the documentation of the distribution protocol and the data format here http://www.erlang.org/doc/apps/erts/erl_ext_dist.html#8 and here http://www.erlang.org/doc/apps/erts/erl_dist_protocol.html#9 Regards Kenneth Erlang/OTP, Ericsson On Wed, Nov 12, 2008 at 4:51 AM, Andrew Stone wrote: > Enrique, > > A sample is not particularly easy to give, however what you are talking > about is a data serialization (marshaling) issue. See http://www.webopedia.com/TERM/D/data_marshalling.html > > It is my opinion that > using sockets for communication between different languages has a > number of benefits and I wouldn't want to dissuade you from using them. > In fact I have a significant chunk of code that passes data back and > forth over TCP between Erlang and C++. It marshals the private data members of C++ classes which then get unmarshaled into the appropriate data structure on the Erlang side. We use cdr marshaling for this, however there is an infinite number of possibile marshaling formats. One of the simplest is Joe Armstrongs UBF(A) http://www.sics.se/~joe/ubf/site/home.html. You could also of course transform all the data into xml or json and then convert the structures based on the json/xml back into the native data structures of Erlang and XML. > > Good luck. > > -Andrew > > > > ----- Original Message ---- > From: Jose Enrique Benitez Jimenez > To: erlang-questions@REDACTED > Sent: Sunday, November 9, 2008 12:50:25 PM > Subject: [erlang-questions] Communicating Erlang and mozart > > Hello, I am developing a proyect involving Mozart and Erlang and I need to communicate each other, I was thinking to use socket, but then I do not know how to structure the messages so that they understand each other, What if there is any standard, which serves to this case, and if you can give me a simple example, It would be very helpful, thank you very much. > > Enrique > > > _______________________________________________ > 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 richardc@REDACTED Wed Nov 12 09:11:25 2008 From: richardc@REDACTED (Richard Carlsson) Date: Wed, 12 Nov 2008 09:11:25 +0100 Subject: [erlang-questions] is this try expression idiom common? In-Reply-To: <10498-52278@sneakemail.com> References: <10498-52278@sneakemail.com> Message-ID: <491A8FAD.6020506@it.uu.se> Kevin wrote: > Whether its the pragmatic book or the online docs, the impression I've > always gotten about try..catch expressions is this > > try FuncOrExpressionSequence of > Pattern1 [when Guard1] -> Expressions1; > Pattern2 [when Guard2] -> Expressions2; > catch > ExceptionType1: ExPattern1 [when ExGuard1] -> ExExpressions1; > ExceptionType2: ExPattern2 [when ExGuard2] -> ExExpressions2; > end > > In fact the pragmatic book calls try...catch "like a case expression on > steroids. It?s basically a case > expression with catch and after blocks at the end." > > So, to a newbie like me, I've always assumed you needed case like > pattern matchers inside the try. This was seriously cramping my style. Well, the Reference Manual in the online docs describe the version without "of" as a first example, and only later mentions that "The try expression can have an 'of' section". Perhaps it is presented differently in the book. > To me this is a completely different idiom, absolutely nothing like a > case expression, and opens erlang up to a more exception based control > flow and error handling. Is this legit? Frowned upon? I searched the > pragmatic book and there is not a single example of this. There is nothing particularly strange about it; just a shorthand for try ... of X -> X catch _Class:_Term -> something_failed end. i.e., "if it succeeds, just return whatever the body returned", just like 'case ... of X -> X end'. But 'try' is definitely a full-blown exception handling mechanism, that can be used and abused in many ways. Compared to the rest of the language, 'try' is a relatively new construct (the old 'catch Expr' construct was much too weak), and as a consequence, the Erlang community has not had so much time to develop a set of common conventions for when and how exceptions should be used. But it is certainly "legit" - that's why we added a better mechanism for it. /Richard From vlm@REDACTED Wed Nov 12 15:12:52 2008 From: vlm@REDACTED (Lev Walkin) Date: Wed, 12 Nov 2008 06:12:52 -0800 Subject: [erlang-questions] memory alloc failed? In-Reply-To: <2f39bec70811111948l5ad4b74bm3d949b41e17bcffa@mail.gmail.com> References: <2f39bec70811111948l5ad4b74bm3d949b41e17bcffa@mail.gmail.com> Message-ID: <491AE464.3050706@lionet.info> leon zhao wrote: > hi all: > I have a multi-process project, it create and destroy 500 process > per second, and maintain 3000 process, the beam use 900M memory to 1.2G, > after running 20 hours, it was restarted by kernel, and i found error > like this: > __alloc_pages: 0-order allocation failed (gfp=0x20/1) > > so, anyone can tell me some information or some tips? May I use > garbage_collect() before every process exit to force free memory? Whats your runtime version? -- Lev Walkin vlm@REDACTED From Dana.RUBINO@REDACTED Wed Nov 12 16:10:01 2008 From: Dana.RUBINO@REDACTED (Dana.RUBINO@REDACTED) Date: Wed, 12 Nov 2008 15:10:01 +0000 Subject: [erlang-questions] Supervisor behaviour query In-Reply-To: References: Message-ID: Ignore this one list - my start_link on the worker wasn't returning {ok, Pid} to the supervisor. Problem solved. Thanks, Dan ________________________________ From: RUBINO, Dana, GBM Sent: 12 November 2008 15:03 To: 'erlang-questions@REDACTED' Subject: Supervisor behaviour query Hi all, I have setup a supervisor structure as such: Supervisor (Node A) -> Supervisor (Node B) -> WorkerA -> WorkerB -> WorkerC I boot my app and the supervision tree starts all the processes and I can see the dependency tree when I fire up appmon as expected. When however I kill a worker via appmon the supervisor does not attempt to restart the killed process. Am I missing something? Does a supervisor not attempt to restart a process which has been killed purposely? (I am using one_for_one) Thanks, Dan *********************************************************************************** The Royal Bank of Scotland plc. Registered in Scotland No 90312. Registered Office: 36 St Andrew Square, Edinburgh EH2 2YB. Authorised and regulated by the Financial Services Authority This e-mail message is confidential and for use by the addressee only. If the message is received by anyone other than the addressee, please return the message to the sender by replying to it and then delete the message from your computer. Internet e-mails are not necessarily secure. The Royal Bank of Scotland plc does not accept responsibility for changes made to this message after it was sent. Whilst all reasonable care has been taken to avoid the transmission of viruses, it is the responsibility of the recipient to ensure that the onward transmission, opening or use of this message and any attachments will not adversely affect its systems or data. No responsibility is accepted by The Royal Bank of Scotland plc in this regard and the recipient should carry out such virus and other checks as it considers appropriate. Visit our websites at: www.rbs.com www.rbs.com/gbm www.rbsgc.com *********************************************************************************** -------------- next part -------------- An HTML attachment was scrubbed... URL: From Dana.RUBINO@REDACTED Wed Nov 12 16:02:43 2008 From: Dana.RUBINO@REDACTED (Dana.RUBINO@REDACTED) Date: Wed, 12 Nov 2008 15:02:43 +0000 Subject: [erlang-questions] Supervisor behaviour query Message-ID: Hi all, I have setup a supervisor structure as such: Supervisor (Node A) -> Supervisor (Node B) -> WorkerA -> WorkerB -> WorkerC I boot my app and the supervision tree starts all the processes and I can see the dependency tree when I fire up appmon as expected. When however I kill a worker via appmon the supervisor does not attempt to restart the killed process. Am I missing something? Does a supervisor not attempt to restart a process which has been killed purposely? (I am using one_for_one) Thanks, Dan *********************************************************************************** The Royal Bank of Scotland plc. Registered in Scotland No 90312. Registered Office: 36 St Andrew Square, Edinburgh EH2 2YB. Authorised and regulated by the Financial Services Authority This e-mail message is confidential and for use by the addressee only. If the message is received by anyone other than the addressee, please return the message to the sender by replying to it and then delete the message from your computer. Internet e-mails are not necessarily secure. The Royal Bank of Scotland plc does not accept responsibility for changes made to this message after it was sent. Whilst all reasonable care has been taken to avoid the transmission of viruses, it is the responsibility of the recipient to ensure that the onward transmission, opening or use of this message and any attachments will not adversely affect its systems or data. No responsibility is accepted by The Royal Bank of Scotland plc in this regard and the recipient should carry out such virus and other checks as it considers appropriate. Visit our websites at: www.rbs.com www.rbs.com/gbm www.rbsgc.com *********************************************************************************** -------------- next part -------------- An HTML attachment was scrubbed... URL: From cthulahoops@REDACTED Wed Nov 12 19:32:15 2008 From: cthulahoops@REDACTED (Adam Kelly) Date: Wed, 12 Nov 2008 18:32:15 +0000 Subject: [erlang-questions] Erlang random number generator weak? Message-ID: <8d1798e90811121032p2d1b6dd4w93d02bbeac3733e4@mail.gmail.com> Hi, While writing some test code, I noticed some extremely odd behaviour from the random module. Given a pretty standard parallel map function, and remembering that erlang:now() never returns the same value twice, I'd expect this code to produce random looking output. 62> pmap:pmap(fun(_) -> {A, B, C} = erlang:now(), random:seed(A, B, C), random:uniform(1000) end, lists:seq(1,10)). [31,32,33,34,34,35,36,37,38,39] Throwing away the first ten numbers gives a sequence with a definite pattern. (It increases and wraps around.) 63> pmap:pmap(fun(_) -> {A, B, C} = erlang:now(), random:seed(A, B, C), [random:uniform(1000) || X <- lists:seq(1, 10)], random:uniform(1000) end, lists:seq(1,10)). [724,993,935,204,354,451,652,853,951,152] It works just as well with a single process map, but then I'd have been able to initialise the random seed once and would never have noticed. 64> lists:map(fun(_) -> {A, B, C} = erlang:now(), random:seed(A, B, C), random:uniform(1000) end, lists:seq(1,10)). [288,289,290,291,292,292,293,294,294,295] So, is it an accepted fact that two processes started at almost the same time will produce highly correlated random sequences? Adam. From masse@REDACTED Wed Nov 12 21:04:00 2008 From: masse@REDACTED (mats cronqvist) Date: Wed, 12 Nov 2008 21:04:00 +0100 Subject: [erlang-questions] Erlang random number generator weak? In-Reply-To: <8d1798e90811121032p2d1b6dd4w93d02bbeac3733e4@mail.gmail.com> (Adam Kelly's message of "Wed\, 12 Nov 2008 18\:32\:15 +0000") References: <8d1798e90811121032p2d1b6dd4w93d02bbeac3733e4@mail.gmail.com> Message-ID: <874p2c7lu7.fsf@sterlett.hq.kred> "Adam Kelly" writes: > So, is it an accepted fact that two processes started at almost the > same time will produce highly correlated random sequences? not afaik. but i think it is (possibly un-)common knowledge that given very similar seeds, two sequences will start out similarly. the mess below shows the 10:th element of 10 sequences with similar seeds. the sequences diverges pretty rapidly. mats 1> L10=lists:seq(1,10). 2> [(fun()->random:seed(1,2,N), hd(lists:reverse([random:uniform(1000)||_<-L10])) end)() || N <- L10]. [96,449,802,154,507,859,212,565,917,270] From erlangy@REDACTED Wed Nov 12 21:02:58 2008 From: erlangy@REDACTED (ERLANG) Date: Wed, 12 Nov 2008 21:02:58 +0100 Subject: [erlang-questions] Report errors when using "-detached" option In-Reply-To: <8d1798e90811121032p2d1b6dd4w93d02bbeac3733e4@mail.gmail.com> References: <8d1798e90811121032p2d1b6dd4w93d02bbeac3733e4@mail.gmail.com> Message-ID: <5C33F0B3-5BE0-408F-ADDF-B4CB99BB0FC3@gmail.com> Hi List, Sometimes, I've to start my erlang applications with "-detached" option. Suppose that an application needs a directory somewhere to be able to run. If this directory is missing, nothing is reported in the shell du to the "-detached" option. So my question is related to how to report any error when using "- detached"? My erlang apps are usually started from shell scripts. It'll be very helpful if the erlang app can report errors with an "exit" code status different from 0. The shell script will use this exit code to throw the error to a higher level. I'm not interested to use the error logger to solve this problem. Regards Y. From erlangy@REDACTED Wed Nov 12 21:39:21 2008 From: erlangy@REDACTED (Michael McDaniel) Date: Wed, 12 Nov 2008 12:39:21 -0800 Subject: [erlang-questions] Report errors when using "-detached" option In-Reply-To: <5C33F0B3-5BE0-408F-ADDF-B4CB99BB0FC3@gmail.com> References: <8d1798e90811121032p2d1b6dd4w93d02bbeac3733e4@mail.gmail.com> <5C33F0B3-5BE0-408F-ADDF-B4CB99BB0FC3@gmail.com> Message-ID: <20081112203920.GB9968@delora.autosys.us> If I use -detached and want to start from scripts (on Linux), I use something like... ------------ export LOGS=/some/path/to/logs if ! $(test -d ${LOGS}) ; then echo "directory ${LOGS} does not exist" exit fi ... ------------ to check for directories or files (run 'man test' for all the flags). I do not know about MS Windows. ~Michael On Wed, Nov 12, 2008 at 09:02:58PM +0100, ERLANG wrote: > Hi List, > > Sometimes, I've to start my erlang applications with "-detached" > option. > Suppose that an application needs a directory somewhere to be able to > run. > If this directory is missing, nothing is reported in the shell du to > the "-detached" option. > > So my question is related to how to report any error when using "- > detached"? > > My erlang apps are usually started from shell scripts. It'll be very > helpful if the erlang app can report > errors with an "exit" code status different from 0. The shell script > will use this exit code to throw > the error to a higher level. > > I'm not interested to use the error logger to solve this problem. > > Regards > Y. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- Michael McDaniel Portland, Oregon, USA http://autosys.us From bob@REDACTED Wed Nov 12 22:18:28 2008 From: bob@REDACTED (Bob Ippolito) Date: Wed, 12 Nov 2008 22:18:28 +0100 Subject: [erlang-questions] Erlang random number generator weak? In-Reply-To: <874p2c7lu7.fsf@sterlett.hq.kred> References: <8d1798e90811121032p2d1b6dd4w93d02bbeac3733e4@mail.gmail.com> <874p2c7lu7.fsf@sterlett.hq.kred> Message-ID: <6a36e7290811121318p7b1f1f2fld328c29a2e749585@mail.gmail.com> We use the prng from the crypto module, the built-in random module is weak. On Wed, Nov 12, 2008 at 9:04 PM, mats cronqvist wrote: > "Adam Kelly" writes: > > >> So, is it an accepted fact that two processes started at almost the >> same time will produce highly correlated random sequences? > > not afaik. > > but i think it is (possibly un-)common knowledge that given very > similar seeds, two sequences will start out similarly. > > the mess below shows the 10:th element of 10 sequences with similar > seeds. the sequences diverges pretty rapidly. > > mats > > 1> L10=lists:seq(1,10). > 2> [(fun()->random:seed(1,2,N), hd(lists:reverse([random:uniform(1000)||_<-L10])) end)() || N <- L10]. > > [96,449,802,154,507,859,212,565,917,270] > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From rvirding@REDACTED Wed Nov 12 22:40:59 2008 From: rvirding@REDACTED (Robert Virding) Date: Wed, 12 Nov 2008 22:40:59 +0100 Subject: [erlang-questions] Erlang random number generator weak? In-Reply-To: <8d1798e90811121032p2d1b6dd4w93d02bbeac3733e4@mail.gmail.com> References: <8d1798e90811121032p2d1b6dd4w93d02bbeac3733e4@mail.gmail.com> Message-ID: <3dbc6d1c0811121340h3f29bb4di99ad8f096b6ef02b@mail.gmail.com> What you are running into is that the random module is erlang process based, it keeps a separate seed in each process which uses it. So when you start a number of processes using erlang:now as seed then they will get the sequence from erlang:now as first number. The subsequent numbers will diverge though. Note that the number sequence from random is in fact quite good, it uses a good algorithm. *BUT* it is deterministic if you know one number/seed, so while it is perfectly ok for simulation and such, it is *NOT* safe to use for cryptographic purposes! Robert 2008/11/12 Adam Kelly > Hi, > > While writing some test code, I noticed some extremely odd behaviour > from the random module. Given a pretty standard parallel map > function, and remembering that erlang:now() never returns the same > value twice, I'd expect this code to produce random looking output. > > 62> pmap:pmap(fun(_) -> {A, B, C} = erlang:now(), random:seed(A, B, > C), random:uniform(1000) end, lists:seq(1,10)). > [31,32,33,34,34,35,36,37,38,39] > > Throwing away the first ten numbers gives a sequence with a definite > pattern. (It increases and wraps around.) > > 63> pmap:pmap(fun(_) -> {A, B, C} = erlang:now(), random:seed(A, B, > C), [random:uniform(1000) || X <- lists:seq(1, 10)], > random:uniform(1000) end, lists:seq(1,10)). > [724,993,935,204,354,451,652,853,951,152] > > It works just as well with a single process map, but then I'd have > been able to initialise the random seed once and would never have > noticed. > > 64> lists:map(fun(_) -> {A, B, C} = erlang:now(), random:seed(A, B, > C), random:uniform(1000) end, lists:seq(1,10)). > [288,289,290,291,292,292,293,294,294,295] > > So, is it an accepted fact that two processes started at almost the > same time will produce highly correlated random sequences? > > Adam. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From erlangy@REDACTED Wed Nov 12 22:52:05 2008 From: erlangy@REDACTED (ERLANG) Date: Wed, 12 Nov 2008 22:52:05 +0100 Subject: [erlang-questions] Report errors when using "-detached" option In-Reply-To: <20081112203920.GB9968@delora.autosys.us> References: <8d1798e90811121032p2d1b6dd4w93d02bbeac3733e4@mail.gmail.com> <5C33F0B3-5BE0-408F-ADDF-B4CB99BB0FC3@gmail.com> <20081112203920.GB9968@delora.autosys.us> Message-ID: Hi Michael, > If I use -detached and want to start from scripts (on Linux), > I use something like... > > ------------ > export LOGS=/some/path/to/logs > > if ! $(test -d ${LOGS}) ; then > echo "directory ${LOGS} does not exist" > exit > fi > > ... > ------------ > Maybe I wasn't clear enough. The directory was just an example ;-) Suppose your application failed to start for some reason. The reason here isn't important at all. > to check for directories or files (run 'man test' for all the flags). > I do not know about MS Windows. Anyway, thanks. Regards Y. From erlangy@REDACTED Wed Nov 12 23:48:18 2008 From: erlangy@REDACTED (Michael McDaniel) Date: Wed, 12 Nov 2008 14:48:18 -0800 Subject: [erlang-questions] Report errors when using "-detached" option In-Reply-To: References: <8d1798e90811121032p2d1b6dd4w93d02bbeac3733e4@mail.gmail.com> <5C33F0B3-5BE0-408F-ADDF-B4CB99BB0FC3@gmail.com> <20081112203920.GB9968@delora.autosys.us> Message-ID: <20081112224818.GE9968@delora.autosys.us> On Wed, Nov 12, 2008 at 10:52:05PM +0100, ERLANG wrote: > Hi Michael, > >> If I use -detached and want to start from scripts (on Linux), >> I use something like... >> >> ------------ >> export LOGS=/some/path/to/logs >> >> if ! $(test -d ${LOGS}) ; then >> echo "directory ${LOGS} does not exist" >> exit >> fi >> >> ... >> ------------ >> > > Maybe I wasn't clear enough. The directory was just an example ;-) > Suppose your application failed to start for some reason. The reason > here isn't important at all. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ then I use application:start(sasl) in my program, and then use rb for looking at all the reports (from an erl shell) ~Michael > > >> to check for directories or files (run 'man test' for all the flags). >> I do not know about MS Windows. > > Anyway, thanks. > > Regards > Y. -- Michael McDaniel Portland, Oregon, USA http://autosys.us From erlangy@REDACTED Thu Nov 13 00:28:15 2008 From: erlangy@REDACTED (ERLANG) Date: Thu, 13 Nov 2008 00:28:15 +0100 Subject: [erlang-questions] Fwd: Report errors when using "-detached" option References: <20081112224818.GE9968@delora.autosys.us> Message-ID: Hi Michael, > then I use application:start(sasl) in my program, and then use rb for > looking at all the reports (from an erl shell) > That correct and my apps log everything too. But this will force you to use "rb" to check the logs for errors (warnings or watherver). This is what I want to avoid. The main idea here is to be able to return an exit code different from 0 to notify the shell script that erlang app failed to load for some reason. Regards Y. From colm.dougan@REDACTED Thu Nov 13 01:37:27 2008 From: colm.dougan@REDACTED (Colm Dougan) Date: Thu, 13 Nov 2008 00:37:27 +0000 Subject: [erlang-questions] Is it bad to use prim_file directly? Message-ID: <24d4f39c0811121637v1116374bsca56fdb6222d35cd@mail.gmail.com> Hi, I was looking at the yaws sources and I noticed that prim_file:read_file is used in preference to file:read_file. When I looked at the OTP sources it looks like the file API just calls prim_file but there is a gen_server sitting in the middle. Does anyone know of any down-sides to using prim_file directly or is this not recommended? Colm From harald.weppner@REDACTED Thu Nov 13 02:36:11 2008 From: harald.weppner@REDACTED (Weppner, Harald) Date: Wed, 12 Nov 2008 20:36:11 -0500 Subject: [erlang-questions] Semantics & mechanism of "preloaded" modules Message-ID: <4A5A2BA06DEBFC449C6EC3A7CEEFA92AC8DF7B@usphle16.phl.sap.corp> Hi there, We just came across a feature we didn't find documented in enough detail - namely the feature of preloading modules. Could someone shed some light on the semantics and mechanism of preloaded modules? Background: we wanted to turn on the debug output in module prim_inet only to find that it wouldn't report anything. We eventually stumbled over the fact that this module is preloaded and that it's part of a sticky directory. We then found the -nostick option to (re)load our version of the module prim_inet, which got us the output we expected. We'd love to understand where the preloaded module beams are stored and how we could have our version of the module preloaded!? My guess is that preloaded modules are included in the boot script and thus we'd simply have to regenerate the script? Thanks & cheerio, Harry. -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/x-pkcs7-signature Size: 1807 bytes Desc: not available URL: From pguyot@REDACTED Thu Nov 13 08:04:47 2008 From: pguyot@REDACTED (Paul Guyot) Date: Thu, 13 Nov 2008 08:04:47 +0100 Subject: [erlang-questions] dialyzer and re(3) In-Reply-To: <4919B3FC.4040104@cs.ntua.gr> References: <8E08C960-51AC-4010-A932-265AAC8584A6@kallisys.net> <4919B3FC.4040104@cs.ntua.gr> Message-ID: <713E90CA-515B-4C74-A00B-C8062201EBB3@kallisys.net> Le 11 nov. 08 ? 17:34, Kostis Sagonas a ?crit : >>> While we appreciate dialyzer very much and we rely on it, >>> we are somewhat disappointed by its current limitations > > Can you please be a bit more specific about "its current > limitations" ? > (perhaps even off the list if you think that's more appropriate). All limitations we noticed were mentioned here. For example, there is the lack of support for recursive types, or the contract induction that is sometimes too liberal. But we gave up on recursive types and being too liberal just means that dialyzer might miss bugs, which it always will anyway. Like many other erlang users, we wish there was a generalized support for types in stdlib, with a merge of edoc and -spec syntaxes, which is planned for R13 I read. A generalized support for parametrized types would also improve dialyzers' scope. For example a gb_sets where all elements are of a single type X would allow dialyzer to check operations such as gb_sets:add_element/2. We'd also love an extended support for apply/2 and apply/3 (which is more tricky) and for behaviour callbacks. For example, we implemented a parse_transform that checks at compile time that gen_server:call and cast calls match the handle_call and handle_cast callbacks, but this typically could be checked by dialyzer. Paul From mikael@REDACTED Thu Nov 13 09:54:49 2008 From: mikael@REDACTED (Mikael Lixenstrand) Date: Thu, 13 Nov 2008 09:54:49 +0100 Subject: [erlang-questions] start_erl Message-ID: I have an old Erlang application that i needs to move up to a OTP R12 release because i need the single bit support. /usr/lib/erlang/bin/start_erl /usr/lib/erlang /usr/lib/erlang/releases /usr/lib/erlang/releases/start_erl.data -sname Bosse0 -setcookie BOSSE -pa /usr/dallas/ebin +A 4 +Bi Erlang (BEAM) emulator version 5.6.3 [source] [smp:4] [async-threads:4] [hipe] [kernel-poll:false] Eshell V5.6.3 (abort with ^G) (Bosse0@REDACTED)1> works fine and i just get a shell i cant exit. /usr/lib/erlang/bin/run_erl -deamon /tmp/ /var/log/erlang0 "exec /usr/lib/erlang/bin/start_erl /usr/lib/erlang /usr/lib/erlang/releases /usr/lib/erlang/releases/start_erl.data -sname Bosse0 -setcookie BOSSE -pa /usr/dallas/ebin +A 4 +Bi" run_erl:577 [12924] Thu Nov 13 09:14:00 2008 Erlang closed the connection. I run erlang-R12B-3.3.el5 on rhel 5.1 when I used a otp R11B-5 built from source i had none of these problems. Does any body have any idea I ran out of all mine. / Mikael From isuri@REDACTED Thu Nov 13 11:46:27 2008 From: isuri@REDACTED (Isuri Apeksha) Date: Thu, 13 Nov 2008 16:16:27 +0530 Subject: [erlang-questions] Pass a String from erlang to C side and take using erl_eterm Message-ID: <000601c9457d$14b16b50$3e1441f0$@lk> Hi All, I need to pass a string from erlang to C side and need to take that using erl_eterm. Because of atom is not a garbage-collected, I could not able to convert list to atom and pass that atom to C side and take it using ERL_ATOM_PTR. Also string can be contain 0. Because of that I could not able to use erl_iolist_to_string function too. In this project I use C-Node. Please help me to solve this problem. Thanks, Isuri. -------------- next part -------------- An HTML attachment was scrubbed... URL: From pguyot@REDACTED Thu Nov 13 14:23:22 2008 From: pguyot@REDACTED (Paul Guyot) Date: Thu, 13 Nov 2008 14:23:22 +0100 Subject: [erlang-questions] re(3) structures across systems Message-ID: Hello, I noticed that the result of re:compile differs between a FreeBSD 64bits system and an x86 workstation running MacOS X 10.5.5 with erlang compiled on 32 bits. Except for the runtime architecture, both versions of erlang are identical. Yet, the structure compiled on the FreeBSD station works on the Mac and reciprocally. Can I rely on it? I believe I can because of the distributed nature of erlang, but since the structures differ, I thought I would raise the question, especially considering that re(3) is considered experimental. Paul From alceste@REDACTED Thu Nov 13 14:51:19 2008 From: alceste@REDACTED (Alceste Scalas) Date: Thu, 13 Nov 2008 14:51:19 +0100 Subject: [erlang-questions] Crazy Question: C -> Erlang Core In-Reply-To: <3dbc6d1c0811101233g4b94cf47x3ad15dd6e65e0a13@mail.gmail.com> References: <3dbc6d1c0811101233g4b94cf47x3ad15dd6e65e0a13@mail.gmail.com> Message-ID: <1226584279.7116.21.camel@gnatziu> Il giorno lun, 10/11/2008 alle 21.33 +0100, Robert Virding ha scritto: > Yes, it would be possible [to compile C in Core Erlang] but there > would be quite severe restrictions on the C you could write. Three > main ones are: > > - no destructive operations on data as all data is immutable in Erlang You could simulate destructive operations by using fresh variables. In other words, you could convert your C code into SSA (Static Single Assignment) form [1] and then compile it almost directly into Core Erlang. That's what we are doing for compiling a Matlab-like language into Core Erlang. See [2]. > - global data is tricky ...and very slow (you could simulate global variables using a server process). > - many of the basic C data structures don't map easily to Erlang Furthermore, if you need something like pointer arithmetics, you will need to simulate the memory as a global variable. Not very fun... Regards, alceste References: [1] Ron Cytron, Jeanne Ferrante, Barry K. Rosen, Mark N. Wegman, and F. Kenneth Zadeck. Efficiently computing static single assignment form and the control dependence graph. ACM Transactions on Programming Languages and Systems (TOPLAS), 13(4):451-490, 1991. [2] Alceste Scalas, Giovanni Casu and Piero Pili. High-performance Technical Computing with Erlang. Presentation at the VII ACM SIGPLAN Erlang Workshop, Victoria, British Columbia, Canada, September 27, 2008. http://www.erlang.org/workshop/2008/Sess23.pdf -- Alceste Scalas CRS4 - http://www.crs4.it/ From sten.gruener@REDACTED Thu Nov 13 15:16:32 2008 From: sten.gruener@REDACTED (Stasik) Date: Thu, 13 Nov 2008 06:16:32 -0800 (PST) Subject: [erlang-questions] Ei Smashing Stack on Ubuntu Message-ID: <49177644-2dd8-4e63-b577-817f036ff626@v22g2000pro.googlegroups.com> Hello, we develop a Erlang Interface to connect to player stage. Recently we add a EI interface functionality and it causes http://de.pastebin.ca/1253411 that error on Ubuntu. Have you seen it before? What can help? Cheers, Sten Gruener From takeru.inoue@REDACTED Thu Nov 13 15:33:11 2008 From: takeru.inoue@REDACTED (Takeru INOUE) Date: Thu, 13 Nov 2008 23:33:11 +0900 Subject: [erlang-questions] Workshop in Tokyo, Japan Message-ID: Dear Erlang Community, Let me tell you about activities of Japanese Erlang community. Next Thursday, the 2nd Erlang workshop will be held in Tokyo (1st one was last June). In Japan, Erlang community is very small, and the workshop is much smaller than the Erlang eXchange. We are, however, excited to have six interesting talks. More details including programme are found in the following page. http://teahut.sakura.ne.jp/b/2008-10-30-1.html This workshop is a small step for us, but I hope to lead to something like a joint workshop with Erlang eXchange in the near future. Regards, -- Takeru INOUE From dave.smith.to@REDACTED Thu Nov 13 16:40:22 2008 From: dave.smith.to@REDACTED (Dave Smith) Date: Thu, 13 Nov 2008 10:40:22 -0500 Subject: [erlang-questions] Crazy Question: C -> Erlang Core In-Reply-To: <1226584279.7116.21.camel@gnatziu> References: <3dbc6d1c0811101233g4b94cf47x3ad15dd6e65e0a13@mail.gmail.com> <1226584279.7116.21.camel@gnatziu> Message-ID: <5ea453f90811130740y6ba74f0dy797d7f68948edcd7@mail.gmail.com> C Flavoured Erlang??? Converting existing C projects to such a language would be a challenge. Even if you could transform the language elements, calls to standard libraries would need to be replaced with OTP. 2008/11/13 Alceste Scalas > Il giorno lun, 10/11/2008 alle 21.33 +0100, Robert Virding ha scritto: > > Yes, it would be possible [to compile C in Core Erlang] but there > > would be quite severe restrictions on the C you could write. Three > > main ones are: > > > > - no destructive operations on data as all data is immutable in Erlang > > You could simulate destructive operations by using fresh variables. In > other words, you could convert your C code into SSA (Static Single > Assignment) form [1] and then compile it almost directly into Core > Erlang. > > That's what we are doing for compiling a Matlab-like language into Core > Erlang. See [2]. > > > > - global data is tricky > > ...and very slow (you could simulate global variables using a server > process). > > > > - many of the basic C data structures don't map easily to Erlang > > Furthermore, if you need something like pointer arithmetics, you will > need to simulate the memory as a global variable. Not very fun... > > Regards, > > alceste > > References: > > [1] Ron Cytron, Jeanne Ferrante, Barry K. Rosen, Mark N. Wegman, > and F. Kenneth Zadeck. Efficiently computing static single > assignment form and the control dependence graph. ACM > Transactions on Programming Languages and Systems (TOPLAS), > 13(4):451-490, 1991. > > [2] Alceste Scalas, Giovanni Casu and Piero Pili. High-performance > Technical Computing with Erlang. Presentation at the VII ACM > SIGPLAN Erlang Workshop, Victoria, British Columbia, Canada, > September 27, 2008. > http://www.erlang.org/workshop/2008/Sess23.pdf > > -- > Alceste Scalas > CRS4 - http://www.crs4.it/ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kenneth.lundin@REDACTED Fri Nov 14 00:07:25 2008 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Fri, 14 Nov 2008 00:07:25 +0100 Subject: [erlang-questions] Communicating Erlang and mozart In-Reply-To: <491BD386.30600@madsgroup.com> References: <503192.72878.qm@web35908.mail.mud.yahoo.com> <491BD386.30600@madsgroup.com> Message-ID: Erlinterface is also the name of the application which contains both libei and liberlinterface which is deprecated. Kenneth erlang/otp ericsson 2008/11/13, Samuel : > Kenneth Lundin wrote: >> Hi, >> >> There is already a data serialization format for Erlang and there is >> libraries for Java and C provided in the Open Source distribution >> which support this >> format. >> [...] >> I suggest you either use the C library (called erl_interface) and >> integrate it with Mozart >> or you implement the data serialization and perhaps also the >> distribution protocol >> directly in Mozart. > > Isn't erl_interface deprecated in favour of ei? At least is what FAQ 5.8 > reads. > > Regards > -- > Samuel > -- Skickat fr?n min mobila enhet From kostis@REDACTED Fri Nov 14 11:24:55 2008 From: kostis@REDACTED (Kostis Sagonas) Date: Fri, 14 Nov 2008 12:24:55 +0200 Subject: [erlang-questions] dialyzer and re(3) In-Reply-To: <713E90CA-515B-4C74-A00B-C8062201EBB3@kallisys.net> References: <8E08C960-51AC-4010-A932-265AAC8584A6@kallisys.net> <4919B3FC.4040104@cs.ntua.gr> <713E90CA-515B-4C74-A00B-C8062201EBB3@kallisys.net> Message-ID: <491D51F7.5050208@cs.ntua.gr> Paul Guyot wrote: > > Le 11 nov. 08 ? 17:34, Kostis Sagonas a ?crit : > >>>> While we appreciate dialyzer very much and we rely on it, >>>> we are somewhat disappointed by its current limitations >> >> Can you please be a bit more specific about "its current limitations" ? >> (perhaps even off the list if you think that's more appropriate). > > All limitations we noticed were mentioned here. For example, there is > the lack of support for recursive types, or the contract induction that > is sometimes too liberal. But we gave up on recursive types and being > too liberal just means that dialyzer might miss bugs, which it always > will anyway. > > Like many other erlang users, we wish there was a generalized support > for types in stdlib, with a merge of edoc and -spec syntaxes, which is > planned for R13 I read. A generalized support for parametrized types > would also improve dialyzers' scope. For example a gb_sets where all > elements are of a single type X would allow dialyzer to check operations > such as gb_sets:add_element/2. We'd also love an extended support for > apply/2 and apply/3 (which is more tricky) and for behaviour callbacks. > For example, we implemented a parse_transform that checks at compile > time that gen_server:call and cast calls match the handle_call and > handle_cast callbacks, but this typically could be checked by dialyzer. These are all very good suggestions/wishes and most of them(*) are also on our TODO list. Let's see when we'll get to them... However, a nice property of open source projects is that they offer the opportunity for users to contribute. Dialyzer is no exception in this respect. Kostis (*) with the exception of apply. From pguyot@REDACTED Fri Nov 14 12:14:26 2008 From: pguyot@REDACTED (Paul Guyot) Date: Fri, 14 Nov 2008 12:14:26 +0100 Subject: [erlang-questions] dialyzer and re(3) In-Reply-To: References: Message-ID: <00C17146-320B-4F01-9FA4-8084615D4780@kallisys.net> > Message: 7 > Date: Fri, 14 Nov 2008 12:24:55 +0200 > From: Kostis Sagonas > Subject: Re: [erlang-questions] dialyzer and re(3) > To: erlang-questions@REDACTED > Message-ID: <491D51F7.5050208@REDACTED> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > However, a nice property of open source projects is that they offer > the > opportunity for users to contribute. Dialyzer is no exception in this > respect. Indeed, and that's why we send patches to erlang-bugs@, some of them that have yet to be reviewed and integrated :D Paul From kostis@REDACTED Fri Nov 14 12:56:39 2008 From: kostis@REDACTED (Kostis Sagonas) Date: Fri, 14 Nov 2008 12:56:39 +0100 Subject: [erlang-questions] dialyzer and re(3) In-Reply-To: <00C17146-320B-4F01-9FA4-8084615D4780@kallisys.net> References: <00C17146-320B-4F01-9FA4-8084615D4780@kallisys.net> Message-ID: <491D6777.4020901@cs.ntua.gr> Paul Guyot wrote: >> >> However, a nice property of open source projects is that they offer >> the >> opportunity for users to contribute. Dialyzer is no exception in this >> respect. > > Indeed, and that's why we send patches to erlang-bugs@, some of them > that have yet to be reviewed and integrated :D As far as Dialyzer is concerned, you might be pleasantly surprised in this respect. For example, yesterday a user sent us a patch adding an option for dumping the call graph of a module to a .dot and/or .ps file and it is already integrated in the development branch. Kostis From igor@REDACTED Fri Nov 14 13:26:24 2008 From: igor@REDACTED (Igor Goryachev) Date: Fri, 14 Nov 2008 15:26:24 +0300 Subject: [erlang-questions] mnesia lock, dead-lock or what? Message-ID: <871vxebij3.fsf@goryachev.org> Hello, everybody! We run a high-loaded cluster of several ejabberd (with some proprietary modules which do not use mnesia) nodes. The half of nodes is placed in one data center, the rest is in the another one. Some times (may be during network failures) the cluster suffers of locks inside mnesia subsystem which causes service degradation at all. I have already checked the code inside of mnesia transactions, for me -- it's fine. Well, we use R12B-3 (amd64, Debian GNU/Linux, package was rebuilded w/o smp and async-threads) on all our machines and here is the output of mnesia:info/0 during the deal ("myserver" and "otherserver\d+" are renamed real hosts for the security purposes): (ejabberd@REDACTED)2> mnesia:info(). ---> Processes holding locks <--- Lock: {{s2s,{"myserver","otherserver1"}}, write, {tid,370791,<4079.5909.10>}} Lock: {{s2s,{"myserver","otherserver2"}}, write, {tid,370784,<4077.8264.8>}} Lock: {{s2s,{"myserver","otherserver3"}}, read, {tid,370787,<3910.21053.1>}} Lock: {{s2s,{"myserver","otherserver3"}}, write, {tid,370787,<3910.21053.1>}} Lock: {{s2s,{"myserver","otherserver4"}},write,{tid,370791,<4077.4651.0>}} Lock: {{s2s,{"myserver","otherserver5"}}, write, {tid,370780,<4080.959.9>}} Lock: {{s2s,{"myserver","otherserver6"}}, write, {tid,370790,<4080.27328.7>}} Lock: {{s2s,{"myserver","otherserver7"}}, write, {tid,370790,<4078.29634.7>}} Lock: {{s2s,{"myserver","otherserver8"}}, write, {tid,370790,<4077.5830.9>}} Lock: {{s2s,{"myserver","otherserver9"}}, write, {tid,370790,<4079.25514.8>}} ---> Processes waiting for locks <--- ---> Participant transactions <--- Tid: 370780 (owned by <4080.959.9>) with participant objects {commit,ejabberd@REDACTED,presume_commit, [{{s2s,{"myserver","otherserver5"}}, {s2s, {"myserver","otherserver5"}, <4080.959.9>,"551643360"}, write}], [],[],[],[]} Tid: 370784 (owned by <4077.8264.8>) with participant objects {commit,ejabberd@REDACTED,presume_commit, [{{s2s,{"myserver","otherserver2"}}, {s2s, {"myserver","otherserver2"}, <4077.8264.8>,"2852318864"}, delete_object}], [],[],[],[]} Tid: 370790 (owned by <4080.27328.7>) with participant objects {commit,ejabberd@REDACTED,presume_commit, [{{s2s,{"myserver","otherserver6"}}, {s2s, {"myserver","otherserver6"}, <4080.27328.7>,"860186058"}, delete_object}], [],[],[],[]} Tid: 370790 (owned by <4078.29634.7>) with participant objects {commit,ejabberd@REDACTED,presume_commit, [{{s2s,{"myserver","otherserver7"}}, {s2s, {"myserver","otherserver7"}, <4078.29634.7>,"1948941028"}, delete_object}], [],[],[],[]} Tid: 370790 (owned by <4079.25514.8>) with participant objects {commit,ejabberd@REDACTED,presume_commit, [{{s2s,{"myserver","otherserver9"}}, {s2s, {"myserver","otherserver9"}, <4079.25514.8>,"325351070"}, delete_object}], [],[],[],[]} Tid: 370790 (owned by <4077.5830.9>) with participant objects {commit,ejabberd@REDACTED,presume_commit, [{{s2s,{"myserver","otherserver8"}}, {s2s, {"myserver","otherserver8"}, <4077.5830.9>,"1699221599"}, delete_object}], [],[],[],[]} ---> Coordinator transactions <--- Tid: 370787 (owned by <3910.21053.1>) Tid: 370788 (owned by <3910.32551.1>) ....... What does it mean? Why does it occur? How could we resolve this behaviour? Is there enough information for the investigation? Thank you very much for the attention. -- Igor Goryachev E-Mail/Jabber: igor@REDACTED From igor@REDACTED Fri Nov 14 14:03:06 2008 From: igor@REDACTED (Igor Goryachev) Date: Fri, 14 Nov 2008 16:03:06 +0300 Subject: [erlang-questions] [ejabberd] mnesia lock, dead-lock or what? In-Reply-To: <871vxebij3.fsf@goryachev.org> (Igor Goryachev's message of "Fri, 14 Nov 2008 15:26:24 +0300") References: <871vxebij3.fsf@goryachev.org> Message-ID: <87r65ea29h.fsf@goryachev.org> Igor Goryachev writes: [skipped] > delete_object}], > [],[],[],[]} > ---> Coordinator transactions <--- > Tid: 370787 (owned by <3910.21053.1>) > Tid: 370788 (owned by <3910.32551.1>) > ....... > > What does it mean? Why does it occur? How could we resolve this > behaviour? Is there enough information for the investigation? There is some additional information I forgot to provide at first: uname -a: Linux viper 2.6.18-5-amd64 #1 SMP Wed Sep 26 04:51:25 UTC 2007 x86_64 GNU/Linux erl: Erlang (BEAM) emulator version 5.6.3 [source] [64-bit] [kernel-poll:true] options: +P 500000 +K true -mnesia auto_repair true -kernel inet_dist_listen_min 5290 inet_dist_listen_max 5299 ERL_MAX_PORTS=300000 ERL_MAX_ETS_TABLES=150000 -- Igor Goryachev E-Mail/Jabber: igor@REDACTED From gleber.p@REDACTED Fri Nov 14 14:12:59 2008 From: gleber.p@REDACTED (Gleb Peregud) Date: Fri, 14 Nov 2008 14:12:59 +0100 Subject: [erlang-questions] dialyzer and re(3) In-Reply-To: <491D6777.4020901@cs.ntua.gr> References: <00C17146-320B-4F01-9FA4-8084615D4780@kallisys.net> <491D6777.4020901@cs.ntua.gr> Message-ID: <14f0e3620811140512w78caeeddwfe40f116523d3be5@mail.gmail.com> Awesome feature! Big thanks to this anonymous user :) On 11/14/08, Kostis Sagonas wrote: > Paul Guyot wrote: >>> >>> However, a nice property of open source projects is that they offer >>> the >>> opportunity for users to contribute. Dialyzer is no exception in this >>> respect. >> >> Indeed, and that's why we send patches to erlang-bugs@, some of them >> that have yet to be reviewed and integrated :D > > As far as Dialyzer is concerned, you might be pleasantly surprised in > this respect. For example, yesterday a user sent us a patch adding an > option for dumping the call graph of a module to a .dot and/or .ps file > and it is already integrated in the development branch. > > Kostis > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- Gleb Peregud http://gleber.pl/ Every minute is to be grasped. Time waits for nobody. -- Inscription on a Zen Gong From klacke@REDACTED Fri Nov 14 14:22:42 2008 From: klacke@REDACTED (=?ISO-8859-1?Q?Claes_Wikstr=F6m?=) Date: Fri, 14 Nov 2008 14:22:42 +0100 Subject: [erlang-questions] Fwd: Report errors when using "-detached" option In-Reply-To: References: <20081112224818.GE9968@delora.autosys.us> Message-ID: <491D7BA2.4000704@hyber.org> ERLANG wrote: > Hi Michael, > >> then I use application:start(sasl) in my program, and then use rb for >> looking at all the reports (from an erl shell) >> > > That correct and my apps log everything too. But this will force you > to use "rb" to check the logs for errors (warnings or watherver). > This is what I want to avoid. > > The main idea here is to be able to return an exit code different from > 0 to notify > the shell script that erlang app failed to load for some reason. This is indeed a real problem. If daemon startup fails, you typically want to indicate that through a call to exit(error_code) so that the invoker can check $? A tail-f we solved this by hacking the emulator startup a bit. I know we sent those patches to otp, but I'm not sure if they were ever incorporated. You can also implement some sort of status checker in your program. I a call that connects to the daemon and reports someting, thus startup could be: erl -detached ${flags} erl -s mymod check_status if [ ! $? = 0 ]; then echo "failed to start bla bla" exit 1 fi /klacke From erlangy@REDACTED Fri Nov 14 14:33:28 2008 From: erlangy@REDACTED (ERLANG) Date: Fri, 14 Nov 2008 14:33:28 +0100 Subject: [erlang-questions] Fwd: Report errors when using "-detached" option In-Reply-To: <491D7BA2.4000704@hyber.org> References: <20081112224818.GE9968@delora.autosys.us> <491D7BA2.4000704@hyber.org> Message-ID: <19326481-2E4E-471D-AFA4-7DD31E53C08E@gmail.com> Hi Claes, > This is indeed a real problem. If daemon startup fails, you typically > want to indicate that through a call to exit(error_code) so that the > invoker can check $? > I'l try that as I didn't know that the "error_code" will be returned even with "-detached" option. > A tail-f we solved this by hacking the emulator startup a bit. I know > we sent those patches to otp, but I'm not sure if they were ever > incorporated. > > You can also implement some sort of status checker in your program. > I a call that connects to the daemon and reports someting, thus > startup > could be: > > erl -detached ${flags} > erl -s mymod check_status > if [ ! $? = 0 ]; then > echo "failed to start bla bla" > exit 1 > fi > This is excatly what I decided to use but it looks a bit ugly ;-) Thanks for yout hint ;-) Regards Ferret. From erlangy@REDACTED Fri Nov 14 14:46:57 2008 From: erlangy@REDACTED (ERLANG) Date: Fri, 14 Nov 2008 14:46:57 +0100 Subject: [erlang-questions] Fwd: Report errors when using "-detached" option In-Reply-To: <491D7BA2.4000704@hyber.org> References: <20081112224818.GE9968@delora.autosys.us> <491D7BA2.4000704@hyber.org> Message-ID: HI Claes, > This is indeed a real problem. If daemon startup fails, you typically > want to indicate that through a call to exit(error_code) so that the > invoker can check $? > Hmmm. Calling "exit(error_code)" isn't reported to the invoker. So $? always equals to 0. Is this an expected behaviour of calling "exit(error_code)" when using "-detached" flag. I've checked that on both Linux and OSX Leopard with RB12-5. Regards Ferret From nicolas@REDACTED Fri Nov 14 15:08:09 2008 From: nicolas@REDACTED (Nicolas Niclausse) Date: Fri, 14 Nov 2008 15:08:09 +0100 Subject: [erlang-questions] Fwd: Report errors when using "-detached" option In-Reply-To: References: <20081112224818.GE9968@delora.autosys.us> <491D7BA2.4000704@hyber.org> Message-ID: <491D8649.2020701@niclux.org> ERLANG ecrivait le 14.11.2008 14:46: > HI Claes, > >> This is indeed a real problem. If daemon startup fails, you typically >> want to indicate that through a call to exit(error_code) so that the >> invoker can check $? >> > > Hmmm. Calling "exit(error_code)" isn't reported to the invoker. > So $? always equals to 0. > > Is this an expected behaviour of calling "exit(error_code)" when using > "-detached" flag. > halt(error_code) works. -- Nicolas From erlangy@REDACTED Fri Nov 14 15:32:53 2008 From: erlangy@REDACTED (ERLANG) Date: Fri, 14 Nov 2008 15:32:53 +0100 Subject: [erlang-questions] Fwd: Report errors when using "-detached" option In-Reply-To: <491D8649.2020701@niclux.org> References: <20081112224818.GE9968@delora.autosys.us> <491D7BA2.4000704@hyber.org> <491D8649.2020701@niclux.org> Message-ID: <3FD73867-982C-44AB-BD2D-3CAA07636040@gmail.com> Hi Nicolas, >>> This is indeed a real problem. If daemon startup fails, you >>> typically >>> want to indicate that through a call to exit(error_code) so that the >>> invoker can check $? >>> >> >> Hmmm. Calling "exit(error_code)" isn't reported to the invoker. >> So $? always equals to 0. >> >> Is this an expected behaviour of calling "exit(error_code)" when >> using >> "-detached" flag. >> > > halt(error_code) works. No, It doesn't. Regards Ferret From nicolas@REDACTED Fri Nov 14 16:03:11 2008 From: nicolas@REDACTED (Nicolas Niclausse) Date: Fri, 14 Nov 2008 16:03:11 +0100 Subject: [erlang-questions] Fwd: Report errors when using "-detached" option In-Reply-To: <3FD73867-982C-44AB-BD2D-3CAA07636040@gmail.com> References: <20081112224818.GE9968@delora.autosys.us> <491D7BA2.4000704@hyber.org> <491D8649.2020701@niclux.org> <3FD73867-982C-44AB-BD2D-3CAA07636040@gmail.com> Message-ID: <491D932F.3090002@niclux.org> ERLANG ecrivait le 14.11.2008 15:32: > Hi Nicolas, > >>>> This is indeed a real problem. If daemon startup fails, you typically >>>> want to indicate that through a call to exit(error_code) so that the >>>> invoker can check $? >>>> >>> >>> Hmmm. Calling "exit(error_code)" isn't reported to the invoker. >>> So $? always equals to 0. >>> >>> Is this an expected behaviour of calling "exit(error_code)" when using >>> "-detached" flag. >>> >> >> halt(error_code) works. > > No, It doesn't. ok, maybe i misunderstand the question; for the "status checker", halt can be useful to report a specific error code to the calling process: >erl Erlang (BEAM) emulator version 5.6.1 [source] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.6.1 (abort with ^G) 1> halt(4). >echo $? 4 -- Nicolas From pat.eyler@REDACTED Fri Nov 14 16:14:48 2008 From: pat.eyler@REDACTED (pat eyler) Date: Fri, 14 Nov 2008 08:14:48 -0700 Subject: [erlang-questions] Erlang Presentation in Salt Lake City in March 2009? Message-ID: <6fd0654b0811140714l4d1ac223r8ad27696b2fdd787@mail.gmail.com> Hello all, among my other hats, I'm co-organizing the MountainWest RubyConf in Salt Lake City, Utah for March, 2009. Last year we had a great presentation on CouchDB (thanks to Jan Lehnardt). This year I'd love to see a presentation on Erlang, or a panel presentation on Functional Languages. Is there anyone in the Utah/Colorado/Idaho/Arizona that would be interested in proposing an Erlang presentation, or working with a couple of Haskell/Ocaml/Scala folks to put together a joint effort? -- thanks, -pate ------------------------- Duty makes us do things, Love make us do things well. http://on-ruby.blogspot.com http://on-erlang.blogspot.com http://on-soccer.blogspot.com From florz@REDACTED Fri Nov 14 04:58:10 2008 From: florz@REDACTED (Florian Zumbiehl) Date: Fri, 14 Nov 2008 04:58:10 +0100 Subject: [erlang-questions] gen_tcp/inet/flow control/misc Message-ID: <20081114035810.GE12805@florz.florz.dyndns.org> Hi, I've got some questions regarding the behaviour of gen_tcp I wasn't quite able to answer from the documentation I could find on the web. 1. I'm not quite sure how write-side flow control on tcp sockets works. At the read side, I understand that using passive or active-once mode should cause back-pressure to the sending process to form if consumption proceeds slower than the data source's and the network's bandwidths. I guess that one usually doesn't really need to know more than that, but still: What buffers are there in between the file descriptor and the gen_tcp API? And which is the buffer affected by the recbuf option? At the write side, though, it's rather unclear to me how flow control works. Given that there is a send_timeout option and that gen_tcp:send/2 can return {error,timeout}, it seems likely that gen_tcp:send/2 works at least somewhat synchronously. On the other hand, there is the delay_send option, the documentation for which claims that "the driver will use any means available to queue up the message"--which sounds to me like completely asynchronous operation, so that no back-pressure would be felt by the inet:send/2-ing process, no matter how slow the data sink. However, it's neither stated that these options were somehow incompatible, nor can I find any explanation as to what interaction between these options to expect. So, the question basically condenses down to: What buffers are there in between the fd and the gen_tcp API, once again, and how do they interact with the various options? And how would I implement flow control at the write side? While I am at it: Is there any usual way for implementing (read: a ready-to-use implementation of) a limited-length (blocking) data queue between processes? Basically, what you'd need for implementing flow control between an outside source and an outside sink without the penalty of making all the processes in between work synchronously. 2. There is the wonderful packet type "line", the documentation for which says "Line mode, a packet is a line terminated with newline, lines longer than the receive buffer are truncated." Now, this may already have been answered in the above questions, but: I set recbuf to 5. Assuming that the unit for the recbuf size is bytes, it doesn't seem to work as documented: Lines much longer than 5 bytes were delivered to the receiving process. So, what's the real semantics of this? 3. What is the effect of the exit_on_close option? The documentation just states that you need it if you want to handle a half-closing peer--but nothing as to why it's an option at all, under which circumstances not to specify it, or just, what the effects actually are. In particular, it would be interesting to know how you learn about the peer shutting down its sending direction ... Well, that's it for now ;-) Florian From gbulmer@REDACTED Fri Nov 14 19:27:32 2008 From: gbulmer@REDACTED (G Bulmer) Date: Fri, 14 Nov 2008 19:27:32 +0100 Subject: [erlang-questions] Help! Do I need erl_driver_compat.h Message-ID: I'm trying to write a Linked-in driver. My guru's have suggested starting with the stdio buffered FILE i/o driver 'bfile' as a good skeleton. I have two question. Q1. File FILE_drv.c (conditionally) #includes , but I can't find that file anywhere (on my machine, or using google; almost a googlewhack). Briefly, what is it for? Is it 'deprecated', defunct, or does it come from some other contributed piece? This is for Erlang-DTrace, so I don't expect to run on many OS's for a while (Solaris/OpenSolaris, Mac OS X, BSD and VXworks for now), though I would like the code to build without error, even if it is all null functions, on Erlang/OTP platforms. I prefer to avoid stuff that I can't use, and can't test. So can I safely throw away the #include ? Q2. Why is the output done using ErlDrvData.control, and not ErlDrvData.output? I can see that it is well-organised if all I/O goes through the one ErlDrvData.control function (and that is a good reason to me), but is there a performance difference between the two approaches? Thanks in Advance for any help advice, GB PS. A tiny, irrelevant, point. In FILE_drv.c the macro symbol USE_STDIO is defined **always**, and then used to *conditionally* include stdio.h. I can't find any definition of USE_STDIO in the Erlang source, or anywhere under /usr, /bin or /etc on Mac OS X. I am not using stdio, so I'll remove all of this, but I am curious, is this necessary on some platform? // ---- #define USE_STDIO #ifdef WIN32 #define USE_STDIO #include #else #include #include #include #include #endif /*WIN32*/ #include "erl_driver.h" #ifndef ERL_DRV_NIL #include "erl_driver_compat.h" #endif #ifdef USE_STDIO // Always #include # include // as it will anyway? #else // ---- From matthias@REDACTED Fri Nov 14 22:13:34 2008 From: matthias@REDACTED (Matthias Lang) Date: Fri, 14 Nov 2008 22:13:34 +0100 Subject: [erlang-questions] gen_tcp/inet/flow control/misc In-Reply-To: <20081114035810.GE12805@florz.florz.dyndns.org> References: <20081114035810.GE12805@florz.florz.dyndns.org> Message-ID: <20081114211334.GA8809@contorpis.lisalinda.com> On Friday, November 14, Florian Zumbiehl wrote: > 1. I'm not quite sure how write-side flow control on tcp sockets works. ... > At the read side, Your description of the read side agrees with what I know. I have nothing to add. > At the write side, though, it's rather unclear to me how flow control > works. Given that there is a send_timeout option and that gen_tcp:send/2 > can return {error,timeout}, it seems likely that gen_tcp:send/2 works > at least somewhat synchronously. With default options, everything's straightforward: gen_tcp:send/2 blocks once the TCP window is full. Easy to verify by just trying it. If you use send_timeout, things get a bit weird and, I agree, the documentation doesn't really tell you what to expect. IIRC, it used to be weirder and undocumented, so things are improving. Knowing what the underlying C interface to sockets looks like, I expected gen_tcp:send/2 to tell me how much of the data in the call actually got sent. But no, gen_tcp:send/2 just returns {error, timeout}. Actually trying it with R12B, I saw that everything gets buffered inside Erlang and sent when the remote end starts empting the window again. That's a bit surprising, but actually nice and reasonable. An example: 28> f(), {ok, S} = gen_tcp:connect(localhost, 2222, [{send_timeout, 1000}]). {ok,#Port<0.113>} 29> Bin = list_to_binary(lists:duplicate(200000, 65)). <<"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"...>> 30> gen_tcp:send(S, Bin). ok 31> gen_tcp:send(S, Bin). ok 32> gen_tcp:send(S, Bin). {error,timeout} 33> gen_tcp:send(S, "the end"). {error,timeout} 34> gen_tcp:send(S, "is nigh"). ok After command 32, the window was full. Same for 33. I then turned on the receiver again and ran 34. The receiver got all the data from 30--34. Erlang must be buffering it. I'm not curious enough to know where exactly. > On the other hand, there is the delay_send option, the > documentation for which claims that "the driver will use any > means available to queue up the message"--which sounds to me like > completely asynchronous operation, so that no back-pressure would > be felt by the inet:send/2-ing process, no matter how slow the > data sink. However, it's neither stated that these options were > somehow incompatible, nor can I find any explanation as to what > interaction between these options to expect. You can probably just ignore delay_send, I don't think it's relevant to what I think you're trying to do. > So, the question basically condenses down to: What buffers are > there in between the fd and the gen_tcp API, once again, and > how do they interact with the various options? I think there's only really one. If you don't use send_delay, it's conceptually not there. If you do, it gets as large as it needs to be and empties when it can. > And how would I implement flow control at the write side? Avoid the problem: use a protocol with flow control. The engineer's solution: use {send_timeout, N} and resign yourself to not being able to know when a blocked socket becomes unblocked, at least not without sending it more data. The "pure Erlang" solution: don't use {send_timeout, N}. Instead, use multiple (Erlang) processes to keep track of whether the socket is blocked or not. Matt (I know, you asked more questions. Maybe someone else can pick up where I left off, otherwise, maybe next week. Or read the source and experiment.) From raould@REDACTED Fri Nov 14 23:12:35 2008 From: raould@REDACTED (Raoul Duke) Date: Fri, 14 Nov 2008 14:12:35 -0800 Subject: [erlang-questions] OTP in other languages? Message-ID: <91a2ba3e0811141412h639d6a22s3f8c54ddda7337fc@mail.gmail.com> hi, I appreciate that OTP is one of Erlang's tremendous strengths. Does anybody know of work to apply such good ideas in other language settings? thanks. From taavi@REDACTED Sat Nov 15 00:19:34 2008 From: taavi@REDACTED (Taavi Talvik) Date: Sat, 15 Nov 2008 01:19:34 +0200 Subject: [erlang-questions] OTP in other languages? In-Reply-To: <91a2ba3e0811141412h639d6a22s3f8c54ddda7337fc@mail.gmail.com> References: <91a2ba3e0811141412h639d6a22s3f8c54ddda7337fc@mail.gmail.com> Message-ID: <33E418A6-5ABD-4493-9C20-17EE19A5D431@uninet.ee> On Nov 15, 2008, at 12:12 AM, Raoul Duke wrote: > I appreciate that OTP is one of Erlang's tremendous strengths. Does > anybody know of work to apply such good ideas in other language > settings? Fail-fast seams to be universal concept for building fault tolerant systems (and even businesses): http://www.businessweek.com/magazine/content/07_26/b4040436.htm http://martinfowler.com/ieeeSoftware/failFast.pdf http://en.wikipedia.org/wiki/Fail-fast Joe Armstrong thesis (http://www.erlang.org/download/armstrong_thesis_2003.pdf , page 215+) provides software engineering principles many of which can be applied to system written in any language. best regards, taavi From dmorton@REDACTED Sat Nov 15 01:38:47 2008 From: dmorton@REDACTED (damien morton) Date: Sat, 15 Nov 2008 11:38:47 +1100 Subject: [erlang-questions] conditional expressions Message-ID: <8092dc770811141638h2a1bee2av19c04e76ce535992@mail.gmail.com> I keep wanting to have python-like boolean expression evaluation, in which a value of nil, 0, an empty list or an empty tuple are considered to be false. It would be great to have a consise way of saying "the value of this expression is expr1 if expr1 evaluates to a non-false value, or expr2 otherwise". In python, you would say "X = foo() or bar()", which would evaluate foo(), and if that evaluates to one of None,False,0,[],(),{}, then evaluate bar() I cant for the life of me figure out what the most concise way of stating that is in erlang. perhaps X = if (T1=foo()) =/= [] -> T1, false -> bar() end it would nice to be able to say something like X = foo() otherwise bar(). or somesuch -------------- next part -------------- An HTML attachment was scrubbed... URL: From rec@REDACTED Sat Nov 15 02:13:40 2008 From: rec@REDACTED (Roger Critchlow) Date: Fri, 14 Nov 2008 18:13:40 -0700 Subject: [erlang-questions] conditional expressions In-Reply-To: <8092dc770811141638h2a1bee2av19c04e76ce535992@mail.gmail.com> References: <8092dc770811141638h2a1bee2av19c04e76ce535992@mail.gmail.com> Message-ID: <66d1c98f0811141713n6961e091ndcaae79c5cea54f0@mail.gmail.com> I think you're looking for the andalso and orelse operators. You say: X = foo() orelse bar(), and bar() only gets called if the value of foo() is false. -- rec -- 2008/11/14 damien morton > I keep wanting to have python-like boolean expression evaluation, in which > a value of nil, 0, an empty list or an empty tuple are considered to be > false. > It would be great to have a consise way of saying "the value of this > expression is expr1 if expr1 evaluates to a non-false value, or expr2 > otherwise". > > In python, you would say "X = foo() or bar()", which would evaluate foo(), > and if that evaluates to one of None,False,0,[],(),{}, then evaluate bar() > > I cant for the life of me figure out what the most concise way of stating > that is in erlang. > > perhaps > X = if (T1=foo()) =/= [] -> T1, false -> bar() end > > it would nice to be able to say something like > X = foo() otherwise bar(). > > or somesuch > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tty.erlang@REDACTED Sat Nov 15 02:51:15 2008 From: tty.erlang@REDACTED (t ty) Date: Fri, 14 Nov 2008 20:51:15 -0500 Subject: [erlang-questions] OTP in other languages? In-Reply-To: <91a2ba3e0811141412h639d6a22s3f8c54ddda7337fc@mail.gmail.com> References: <91a2ba3e0811141412h639d6a22s3f8c54ddda7337fc@mail.gmail.com> Message-ID: <290b3ba10811141751k787d25fck2282d989405fb794@mail.gmail.com> You might consider contacting Marc Feeley (http://www.iro.umontreal.ca/~feeley/) regarding OTP for Scheme. IIRC he has a PhD candidate who started last year on this project. The Scala group has or may be starting a similar effort. Regards, Tee On Fri, Nov 14, 2008 at 5:12 PM, Raoul Duke wrote: > hi, > > I appreciate that OTP is one of Erlang's tremendous strengths. Does > anybody know of work to apply such good ideas in other language > settings? > > thanks. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From dmorton@REDACTED Sat Nov 15 05:59:15 2008 From: dmorton@REDACTED (damien morton) Date: Sat, 15 Nov 2008 15:59:15 +1100 Subject: [erlang-questions] base64 url-safe encoding Message-ID: <8092dc770811142059v42d5ccb9macc2c330cc6f0084@mail.gmail.com> RFC 4648 defines a "URL and Filename safe" base 64 alphabet, which replaces '+' with '-' and '/' with '_'. Would anyone have any objections if I added support for this into the base64 module? I'm adding in safe_encode(), safe_decode(), safe_encode_to_string(), and safe_decode_to_string() functions. How should I submit my patch? -------------- next part -------------- An HTML attachment was scrubbed... URL: From FoolishEwe@REDACTED Sat Nov 15 06:44:14 2008 From: FoolishEwe@REDACTED (Bill M.) Date: Sat, 15 Nov 2008 05:44:14 +0000 (UTC) Subject: [erlang-questions] =?utf-8?q?When_can_an_integer_=3E_0_not_be_a_p?= =?utf-8?q?os=5Finteger=28=29_in_the_Dialyzer=3F?= Message-ID: Hello All: Please consider the following functions (which perform a sieve of Eratosthenes to find all primes < N where N > 1, for convenience we assume relatively small values of N, like 2^10 or 2^20). Here is the code: %%%%%%%%%%%%%%%%%%% Cut Here%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -module(test). -export([test/0,list_primes/1]). test()-> list_primes(64). %% Functions supporting the Sieve Of Erastothenes For Computing Primes %% Not designed to be incredibly efficient, but correct and simple. %% @todo Check syntax on the @spec statement for this function %% @doc Computes the list of all primse up to N using Sieve of Erastotanes (correct, perhaps not efficient) -spec(list_primes/1 :: ( N :: pos_integer() )->[pos_integer()]). list_primes(N) when (is_integer(N) and (N > 1))-> Candidates = lists:seq(2,N), MaxFactor = round(math:sqrt(N) + 0.5) , %% poor man's ceiling function list_primes_helper(MaxFactor, Candidates). %% @private %% @doc Helper function for list_primes, does all the actual work of %% the sieve of Erastothanes %% @todo the PrimeCandidates should be of type [ pos_integer() ] but the dialyzer can't deal with it, so we must weaken it :-( -spec(list_primes_helper/2 :: (MaxFactor :: pos_integer(), PrimeCandidates :: [ pos_integer() ]) -> [ pos_integer() ]). list_primes_helper(MaxFactor, [Prime|Candidates]) when is_integer(MaxFactor) and is_integer(Prime) and (Prime > 0) and (MaxFactor > Prime) -> PrunedCandidates = [X || X <- Candidates, (X rem Prime) /= 0], [ Prime | list_primes_helper(MaxFactor, PrunedCandidates) ]; list_primes_helper(MaxFactor, [Prime|Candidates]) when is_integer(MaxFactor) and is_integer(Prime) and (MaxFactor > 0) and (Prime >= MaxFactor) -> [Prime | Candidates]; %% all pruning is complete, list_primes_helper(_MaxFactor, []) when is_integer(_MaxFactor) and (_MaxFactor > 0)-> []. %%%%%%%%%%%%%%%%%%% Cut Here %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Running the dialyzer from R12B4 gives (Note, I had to make the lines in the code snippet above fit in 80 columns or less, so the line number might be off): test.erl:20: Type specification test:list_primes_helper/2 :: (MaxFactor::pos_integer(),PrimeCandidates::[pos_integer()]) -> [pos_integer()] is a subtype of the success typing: (pos_integer(),[integer()]) -> [integer()] My guess is dialyzer didn't accurately guess the type of lists:seq(2,N). I'd like to ask a few questions of the dialyzer maintainers. 1) When there is a conflict between a signature and the usage of a function, would it be possible for the dialyzer to suggest why it thinks that would happen. Here it could extend the error message saying something like " as invoked by list_primes/1 at line 15, since actual parameter 2, Candidates, is of type [integer()] instead of [pos_integer()]." In practice, I think if the tool gives one reason why it thinks such an error is justified (enumerating all of the reasons would probably be overkill), then the user could address it (I know of a tool that does this for another language, and I find it helpful). Regards: Bill M. From kostis@REDACTED Sat Nov 15 09:39:33 2008 From: kostis@REDACTED (Kostis Sagonas) Date: Sat, 15 Nov 2008 10:39:33 +0200 Subject: [erlang-questions] When can an integer > 0 not be a pos_integer() in the Dialyzer? In-Reply-To: References: Message-ID: <491E8AC5.5050900@cs.ntua.gr> Bill M. wrote: > Hello All: > > Please consider the following functions > (which perform a sieve of Eratosthenes to find all primes < N where N > 1, ... CODE OMITTED ... > Running the dialyzer from R12B4 gives (Note, I had to make the lines > in the code snippet above fit in 80 columns or less, so the line > number might be off): > > test.erl:20: Type specification test:list_primes_helper/2 :: > (MaxFactor::pos_integer(),PrimeCandidates::[pos_integer()]) -> > [pos_integer()] is a subtype of the success typing: > (pos_integer(),[integer()]) -> [integer()] Well, running dialyzer on your code will not give you this. You will only get this if you explicitly turn on the option -Woverspecs. You should not. From the options that are turned off by default, the only two options we recommend turning on are: -Wunmatched_returns and -Wunderspecs The remaining options are mainly for developers & debugging. (The manual could have been more explicit regarding this point - it will be in the next version.) > My guess is dialyzer didn't accurately guess the type of lists:seq(2,N). Your guess is correct, but it also has to do with the fact that the spec for this function is not as refined as it can be. In R12B-4, it reads: -spec(seq/2 :: (integer(),integer()) -> [integer(),...]). and it nowhere specifies that if you feed it two pos_integer() it will return a list of pos_integer(). Kostis From richardc@REDACTED Sat Nov 15 12:49:58 2008 From: richardc@REDACTED (Richard Carlsson) Date: Sat, 15 Nov 2008 12:49:58 +0100 Subject: [erlang-questions] conditional expressions In-Reply-To: <8092dc770811141638h2a1bee2av19c04e76ce535992@mail.gmail.com> References: <8092dc770811141638h2a1bee2av19c04e76ce535992@mail.gmail.com> Message-ID: <491EB766.9050102@it.uu.se> damien morton wrote: > I keep wanting to have python-like boolean expression evaluation, in > which a value of nil, 0, an empty list or an empty tuple are considered > to be false. > > It would be great to have a consise way of saying "the value of this > expression is expr1 if expr1 evaluates to a non-false value, or expr2 > otherwise". > > In python, you would say "X = foo() or bar()", which would evaluate > foo(), and if that evaluates to one of None,False,0,[],(),{}, then > evaluate bar() Well, andalso/orelse (as someone suggested) don't work since they require that expr1 and expr2 evaluate to booleans and nothing else. > I cant for the life of me figure out what the most concise way of > stating that is in erlang. > > perhaps > X = if (T1=foo()) =/= [] -> T1, false -> bar() end > > it would nice to be able to say something like > X = foo() otherwise bar(). X = case foo() of [] -> bar(); X1 -> X1 end If you need to check for other values as well, replace '[] ->' with 'X when X =:= [] ; X =:= 0 ; ... ->' But I've always felt that this feature of Python/Perl/... boils down to sloppy programming style. It basically means that the caller hopes that the "empty or failure" case is signalled by one of the values reconized as pseudo-booleans by the language (the programmer might not actually know the exact interface of the called function, but guessed that this would work), and the resulting code says nothing to the reader about the actual set of return values. Furthermore, the code might do the wrong thing if the function tries to return e.g. '0' or '{}' on success (as opposed to False or None or whatever it usually uses for failure). It simply makes the code a lot less tight than it ought to be. And then, you still can't use the same idiom on abstract data types to treat e.g. an empty set as "false". /Richard From dmorton@REDACTED Sat Nov 15 15:22:03 2008 From: dmorton@REDACTED (damien morton) Date: Sun, 16 Nov 2008 01:22:03 +1100 Subject: [erlang-questions] Fwd: conditional expressions In-Reply-To: <8092dc770811150621s4ea0ef26ved59406d048c46b4@mail.gmail.com> References: <8092dc770811141638h2a1bee2av19c04e76ce535992@mail.gmail.com> <491EB766.9050102@it.uu.se> <8092dc770811150621s4ea0ef26ved59406d048c46b4@mail.gmail.com> Message-ID: <8092dc770811150622w6a49e49akb0afa15b3665e481@mail.gmail.com> ---------- Forwarded message ---------- From: damien morton Date: Sun, Nov 16, 2008 at 1:21 AM Subject: Re: [erlang-questions] conditional expressions To: Richard Carlsson On Sat, Nov 15, 2008 at 10:49 PM, Richard Carlsson wrote: > damien morton wrote: > >> ... > > > I cant for the life of me figure out what the most concise way of stating >> that is in erlang. >> >> perhaps >> X = if (T1=foo()) =/= [] -> T1, false -> bar() end >> >> it would nice to be able to say something like >> X = foo() otherwise bar(). >> > > X = case foo() of > [] -> bar(); > X1 -> X1 > end > > If you need to check for other values as well, replace '[] ->' with > 'X when X =:= [] ; X =:= 0 ; ... ->' > Ok, that works and is reasonably concise. > > > But I've always felt that this feature of Python/Perl/... boils down > to sloppy programming style. It basically means that the caller hopes > that the "empty or failure" case is signalled by one of the values > reconized as pseudo-booleans by the language (the programmer might > not actually know the exact interface of the called function, but > guessed that this would work), and the resulting code says nothing to > the reader about the actual set of return values. Furthermore, the > code might do the wrong thing if the function tries to return e.g. '0' > or '{}' on success (as opposed to False or None or whatever it usually > uses for failure). It simply makes the code a lot less tight than it > ought to be. And then, you still can't use the same idiom on abstract > data types to treat e.g. an empty set as "false". Well, Python does have a way of determining if an abstract data type is considered true or false - there's a method the ADT can implement for that. Still, what strikes me about the erlang libraries is the tremendous variety of techniques used to signal the return of a value or not. Sometimes nil/Value, sometimes false/Value, sometimes []/[Value], sometimes false/{value,Value} For a function that can return 0 or 1 answers, I personally like the []/[Value] approach. -------------- next part -------------- An HTML attachment was scrubbed... URL: From dmorton@REDACTED Sat Nov 15 16:09:43 2008 From: dmorton@REDACTED (damien morton) Date: Sun, 16 Nov 2008 02:09:43 +1100 Subject: [erlang-questions] conditional expressions In-Reply-To: <491EE12E.9060306@it.uu.se> References: <8092dc770811141638h2a1bee2av19c04e76ce535992@mail.gmail.com> <491EB766.9050102@it.uu.se> <8092dc770811150621s4ea0ef26ved59406d048c46b4@mail.gmail.com> <491EE12E.9060306@it.uu.se> Message-ID: <8092dc770811150709g724b97cdu5901f092f1856c68@mail.gmail.com> On Sun, Nov 16, 2008 at 1:48 AM, Richard Carlsson wrote: > damien morton wrote: > >> >> Still, what strikes me about the erlang libraries is the tremendous >> variety of techniques used to signal the return of a value or not. >> >> Sometimes nil/Value, sometimes false/Value, sometimes []/[Value], >> sometimes false/{value,Value} >> > > > I've tried to promote {value,X}/none as a standard maybe-type, but it's > hard to do much about all the existing code out there. > > For a function that can return 0 or 1 answers, I personally like the >> []/[Value] approach. >> > > []/[X] is ok for "searches" as in mnesia, where in some cases you can > get several elements as a result, but as a general mechanism it always > makes a reader think "so, can I ever get more than one value here?", so > it's not good for clarity. > Would {}/{X} be more clear for 0 or 1 answers, and []/[...] for 0 or more answers? Not too keen on the none/{value,Value} approach - it feels irregular somehow. -------------- next part -------------- An HTML attachment was scrubbed... URL: From mkurkov@REDACTED Sat Nov 15 16:03:37 2008 From: mkurkov@REDACTED (Mikl Kurkov) Date: Sat, 15 Nov 2008 07:03:37 -0800 (PST) Subject: [erlang-questions] Bug in trapexit article "How to use ei ..." Message-ID: <20516290.post@talk.nabble.com> It seems that the code in the trapexit article http://www.trapexit.org/How_to_use_ei_to_marshal_binary_terms_in_port_programs has some bugs that I ran into. In the next code [c] int read_cmd(byte *buf, int *size) { int len; if (read_exact(buf, 2) != 2) return(-1); len = (buf[0] << 8) | buf[1]; if (len > *size) { buf = (byte *) realloc(buf, len); if (buf == NULL) return -1; *size = len; } return read_exact(buf, len); } [/c] if the size of binary data is more than the size of the buffer then data is reallocated, but the pointer in the main function doesn't change. I think it should be something like this: [c] int read_cmd(byte **buf_ptr, int *size) { int len; char *buf = *buf_ptr;; if (read_exact(buf, 2) != 2) return -1; len = (buf[0] << 8) | buf[1]; if (len > *size) { buf = (byte *) realloc(buf, len); if (buf == NULL) return -1; *buf_ptr = buf; *size = len; } return read_exact(buf, len); } [/c] The call of read_cmd in the main function should be changed into [c] while (read_cmd(&buf, &size) > 0) { [/c] Besides the code doesn't work properly in the system with the char defined as signed type. Hope this information will be helpful for someone. -- Mikl -- View this message in context: http://www.nabble.com/Bug-in-trapexit-article-%22How-to-use-ei-...%22-tp20516290p20516290.html Sent from the Erlang Questions mailing list archive at Nabble.com. From masse@REDACTED Sat Nov 15 18:42:53 2008 From: masse@REDACTED (mats cronqvist) Date: Sat, 15 Nov 2008 18:42:53 +0100 Subject: [erlang-questions] conditional expressions In-Reply-To: <491EB766.9050102@it.uu.se> (Richard Carlsson's message of "Sat\, 15 Nov 2008 12\:49\:58 +0100") References: <8092dc770811141638h2a1bee2av19c04e76ce535992@mail.gmail.com> <491EB766.9050102@it.uu.se> Message-ID: <87d4gw7un6.fsf@dixie.cronqvi.st> Richard Carlsson writes: > > X = case foo() of > [] -> bar(); > X1 -> X1 > end strangely, this also works; case foo() of [] -> X = bar(); X -> ok end as long as X is bound in each clause, you're golden. this might qualify as a gotcha. mats From dmorton@REDACTED Sat Nov 15 19:17:52 2008 From: dmorton@REDACTED (damien morton) Date: Sun, 16 Nov 2008 05:17:52 +1100 Subject: [erlang-questions] conditional expressions In-Reply-To: <87d4gw7un6.fsf@dixie.cronqvi.st> References: <8092dc770811141638h2a1bee2av19c04e76ce535992@mail.gmail.com> <491EB766.9050102@it.uu.se> <87d4gw7un6.fsf@dixie.cronqvi.st> Message-ID: <8092dc770811151017o66d796afqabede54265020c0b@mail.gmail.com> 1> case [] of [] -> X = aaa; X -> ok end. aaa 2> case bbb of [] -> X = aaa; X -> ok end. ** exception error: no case clause matching bbb am I missing something? On Sun, Nov 16, 2008 at 4:42 AM, mats cronqvist wrote: > > strangely, this also works; > > case foo() of > [] -> X = bar(); > X -> ok > end > > as long as X is bound in each clause, you're golden. > > this might qualify as a gotcha. > > mats > -------------- next part -------------- An HTML attachment was scrubbed... URL: From vychodil.hynek@REDACTED Sat Nov 15 19:37:39 2008 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Sat, 15 Nov 2008 19:37:39 +0100 Subject: [erlang-questions] conditional expressions In-Reply-To: <8092dc770811151017o66d796afqabede54265020c0b@mail.gmail.com> References: <8092dc770811141638h2a1bee2av19c04e76ce535992@mail.gmail.com> <491EB766.9050102@it.uu.se> <87d4gw7un6.fsf@dixie.cronqvi.st> <8092dc770811151017o66d796afqabede54265020c0b@mail.gmail.com> Message-ID: <20081115183740.2A36624062@relay.gooddata.com> 2008/11/15 damien morton > 1> case [] of [] -> X = aaa; X -> ok end. > aaa > 2> case bbb of [] -> X = aaa; X -> ok end. > ** exception error: no case clause matching bbb > > am I missing something? > Yes, you missed that shell binds X to aaa in previous expression ;-) But I think, less magic will be X = case foo() of [] -> bar(); Y -> Y end > On Sun, Nov 16, 2008 at 4:42 AM, mats cronqvist wrote: > >> >> strangely, this also works; >> >> case foo() of >> [] -> X = bar(); >> X -> ok >> end >> >> as long as X is bound in each clause, you're golden. >> >> this might qualify as a gotcha. >> >> mats >> > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- --Hynek (Pichi) Vychodil -------------- next part -------------- An HTML attachment was scrubbed... URL: From erlangy@REDACTED Sat Nov 15 19:40:53 2008 From: erlangy@REDACTED (Michael McDaniel) Date: Sat, 15 Nov 2008 10:40:53 -0800 Subject: [erlang-questions] conditional expressions In-Reply-To: <8092dc770811151017o66d796afqabede54265020c0b@mail.gmail.com> References: <8092dc770811141638h2a1bee2av19c04e76ce535992@mail.gmail.com> <491EB766.9050102@it.uu.se> <87d4gw7un6.fsf@dixie.cronqvi.st> <8092dc770811151017o66d796afqabede54265020c0b@mail.gmail.com> Message-ID: <20081115184052.GX9968@delora.autosys.us> On Sun, Nov 16, 2008 at 05:17:52AM +1100, damien morton wrote: > 1> case [] of [] -> X = aaa; X -> ok end. > > aaa > > 2> case bbb of [] -> X = aaa; X -> ok end. > > ** exception error: no case clause matching bbb > > am I missing something? ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ From section '6.8 Case' of the Erlang Reference Manual (Version 5.6.5) "If there is no matching pattern with a true guard sequence, a case_clause run-time error will occur." bbb does not match anything in the second case above; you could substitute aaa for X in the second case and it would result the same. 3> X. aaa ~Michael > > On Sun, Nov 16, 2008 at 4:42 AM, mats cronqvist <[1]masse@REDACTED> > wrote: > > strangely, this also works; > case foo() of > [] -> X = bar(); > X -> ok > end > as long as X is bound in each clause, you're golden. > this might qualify as a gotcha. > mats > > References > > 1. mailto:masse@REDACTED > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- Michael McDaniel Portland, Oregon, USA http://autosys.us From david.koch@REDACTED Sat Nov 15 19:52:22 2008 From: david.koch@REDACTED (=?iso-8859-1?Q?david.koch@libertysurf.fr?=) Date: Sat, 15 Nov 2008 19:52:22 +0100 Subject: [erlang-questions] =?iso-8859-1?q?REF=3A_Major_rework_of_ESDL_in_?= =?iso-8859-1?q?progress_=28NON_URGENT=29?= Message-ID: Due to the needs for a personal project, I managed to update the latest 2 years old release of ESDL with to reflect the recent SDL 1.2.13 changes and also update the GLEXT and add full OpenAL 1.1 support. I am now adding the latest ODE 0.10.0 API compliance. Question before I go any further, should I also add more library support, such GLUT or the newest GLUX, GLEW, GLFW, sdl_image, sdl_mixer, sdl_ttf and all the companion libraries ? These MIGHT be of some needs somedays... I also though about AntTweakBar 1.12 ? That sounds a lot I know, and far away from the simple scope of using SDL. However would it be of any help for someone out there ? Allo, il y a quelqu'un qui m'entend ? David KOCH aka Kochise PS : The latest ErlIDE 0.3.111 still doesn't show in Eclipse Ganymede 3.4.1, is that normal ? I somewhat get random NULL JavaPointer errors... And in Live Expression I just get erlang:now() -> ERR: "rpc failed" ---------------------- ALICE N?1 de la RELATION CLIENT 2008*-------------------- D?couvrez vite l'offre exclusive ALICE BOX! En cliquant ici http://abonnement.aliceadsl.fr Offre soumise ? conditions.*Source : TNS SOFRES / BEARING POINT. Secteur Fournisseur d.Acc?s Internet From dmorton@REDACTED Sat Nov 15 19:54:19 2008 From: dmorton@REDACTED (damien morton) Date: Sun, 16 Nov 2008 05:54:19 +1100 Subject: [erlang-questions] Erlang 3000? Message-ID: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> I don't suppose there's and Erlang 3000 project in the works? The Python people set out to create Python 3000, throwing backwards compatibility out the window in favour of fixing language and library design errors. I mentioned earlier the variety of ways that the Erlang libraries signal returning a value or not. Some examples: proplists:get_value(Key, List) -> undefined | Value dict:find(Key, Dict) -> {ok, Value} | error gb_tree:lookup(Key, Tree) -> {value, Val} | none dets:lookup(Name, Key) -> [Object] | {error, Reason} ets:lookup(Tab, Key) -> [Object] All these operations on standard ADTs are roughly equivalent, and yet they have different or conflicting naming conventions, different return value protocols, and different orderings of their arguments. While ets:lookup and dets:lookup return a tuple, one of whose members is the key, gb_tree:lookup return the value of a {key,value} pair. gb_tree:lookup, dict:find and proplists:get_value all perform the same operation, and though the return value protocol is different in each case, at least the arguments are the same. The key asset for any well designed language or library is learnability, which comes from regularity, i.e. having learned something in one situation, one can apply that knowledge to similar situation with a high probability of success. Erlang already does a lot of things differently from other languages, but when every single library module does things differently from the others, well, that's a lot of heterogeneity for a novice to deal with. I wasted an hour so so tonight trying to figure out a problem that stemmed from proplists having a different argument ordering to ets - I just instinctively assumed they had the same argument ordering, and why shouldn't I? From vances@REDACTED Sat Nov 15 20:35:22 2008 From: vances@REDACTED (Vance Shipley) Date: Sat, 15 Nov 2008 14:35:22 -0500 Subject: [erlang-questions] conditional expressions In-Reply-To: <8092dc770811151017o66d796afqabede54265020c0b@mail.gmail.com> References: <8092dc770811141638h2a1bee2av19c04e76ce535992@mail.gmail.com> <491EB766.9050102@it.uu.se> <87d4gw7un6.fsf@dixie.cronqvi.st> <8092dc770811151017o66d796afqabede54265020c0b@mail.gmail.com> Message-ID: <20081115193518.GA1005@h216-235-12-168.host.egate.net> On Sun, Nov 16, 2008 at 05:17:52AM +1100, damien morton wrote: } am I missing something? Just the variable scope. Once you have run: 1> case [] of [] -> X = aaa; X -> ok end. aaa The variable X is now bound: 2> X. aaa If you forget it first: 3> f(X). ok Your second example will work: 4> case bbb of [] -> X = aaa; X -> ok end. ok -Vance From fredrik.svahn@REDACTED Sat Nov 15 22:22:04 2008 From: fredrik.svahn@REDACTED (Fredrik Svahn) Date: Sat, 15 Nov 2008 22:22:04 +0100 Subject: [erlang-questions] conditional expressions In-Reply-To: <8092dc770811151017o66d796afqabede54265020c0b@mail.gmail.com> References: <8092dc770811141638h2a1bee2av19c04e76ce535992@mail.gmail.com> <491EB766.9050102@it.uu.se> <87d4gw7un6.fsf@dixie.cronqvi.st> <8092dc770811151017o66d796afqabede54265020c0b@mail.gmail.com> Message-ID: X is bound to aaa in the first line you enter in the shell, so your second line is really "case bbb of [] -> aaa = aaa; aaa -> ok end.". You can unbind/forget X in the shell with f() or f(X), see help(). 1> case [] of [] -> X = aaa; X -> ok end. aaa 2> X. aaa 3> case bbb of [] -> X = aaa; X -> ok end. ** exception error: no case clause matching bbb 4> X. aaa 5> f(X). ok 6> X. * 1: variable 'X' is unbound 7> case bbb of [] -> X = aaa; X -> ok end. ok 8> X. bbb 2008/11/15 damien morton > 1> case [] of [] -> X = aaa; X -> ok end. > aaa > 2> case bbb of [] -> X = aaa; X -> ok end. > ** exception error: no case clause matching bbb > > am I missing something? > > On Sun, Nov 16, 2008 at 4:42 AM, mats cronqvist wrote: > >> >> strangely, this also works; >> >> case foo() of >> [] -> X = bar(); >> X -> ok >> end >> >> as long as X is bound in each clause, you're golden. >> >> this might qualify as a gotcha. >> >> mats >> > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rvirding@REDACTED Sat Nov 15 22:42:46 2008 From: rvirding@REDACTED (Robert Virding) Date: Sat, 15 Nov 2008 22:42:46 +0100 Subject: [erlang-questions] conditional expressions In-Reply-To: <8092dc770811151017o66d796afqabede54265020c0b@mail.gmail.com> References: <8092dc770811141638h2a1bee2av19c04e76ce535992@mail.gmail.com> <491EB766.9050102@it.uu.se> <87d4gw7un6.fsf@dixie.cronqvi.st> <8092dc770811151017o66d796afqabede54265020c0b@mail.gmail.com> Message-ID: <3dbc6d1c0811151342j85dd4c8laead08f6c7f5c01b@mail.gmail.com> You are evaluating these in the shell. In the first case X is bound to aaa, which means that when you evaluate the second case X is already bound. Which means that there is no matching clause. If you do: 1> case [] of [] -> X = aaa; X -> ok end. aaa 2> case bbb of [] -> Y = aaa; Y -> ok end. ok 3> {X,Y}. {aaa,bbb} it works. Robert 2008/11/15 damien morton > 1> case [] of [] -> X = aaa; X -> ok end. > aaa > 2> case bbb of [] -> X = aaa; X -> ok end. > ** exception error: no case clause matching bbb > > am I missing something? > > On Sun, Nov 16, 2008 at 4:42 AM, mats cronqvist wrote: > >> >> strangely, this also works; >> >> case foo() of >> [] -> X = bar(); >> X -> ok >> end >> >> as long as X is bound in each clause, you're golden. >> >> this might qualify as a gotcha. >> >> mats >> > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rvirding@REDACTED Sat Nov 15 22:58:52 2008 From: rvirding@REDACTED (Robert Virding) Date: Sat, 15 Nov 2008 22:58:52 +0100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> Message-ID: <3dbc6d1c0811151358y76d6b256vb12e9b6ced4a0b4c@mail.gmail.com> Also I forgot to mention that perhaps it should be called Erlang 2011 because I don't really want to wait until the year 3000 to see it. Or just perhaps Erlang2 and drop the pseudo years which never hold anyway. Robert again -------------- next part -------------- An HTML attachment was scrubbed... URL: From rvirding@REDACTED Sat Nov 15 22:56:59 2008 From: rvirding@REDACTED (Robert Virding) Date: Sat, 15 Nov 2008 22:56:59 +0100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> Message-ID: <3dbc6d1c0811151356s183172fcj79e463a8f7da9c6f@mail.gmail.com> You have mentioned a very real problem, although some of the things you point out are actually justified. For example ets/dets explicitly handle tuples where one of the elements is the key while dict/orddict/gb_trees work with separate keys and values so a difference here is expected. It is a pity that gb_trees does not have a dict compatible api where it is possible. That argument ordering is different and that sometimes the thing worked upon comes first, or last, or sometimes even in the middle is unfortunate. The different, or rather inconsistent, ways of indicating success/failure is also unfortunate. Reworking Erlang to fix many of these errors would probably worth the effort, though it might split the user group. One could also fix the syntax, although making it look more like C#/Java would probably be last on my list of priorities, if it ever got there in the first place. I mean the idea is to look forwards and try and get rid of old blemishes of the past and not import someone elses old crud. It would also be fun, though I think it would be more difficult than many believe. Robert 2008/11/15 damien morton > I don't suppose there's and Erlang 3000 project in the works? > > The Python people set out to create Python 3000, throwing backwards > compatibility out the window in favour of fixing language and library > design errors. > > I mentioned earlier the variety of ways that the Erlang libraries > signal returning a value or not. Some examples: > > proplists:get_value(Key, List) -> undefined | Value > > dict:find(Key, Dict) -> {ok, Value} | error > > gb_tree:lookup(Key, Tree) -> {value, Val} | none > > dets:lookup(Name, Key) -> [Object] | {error, Reason} > > ets:lookup(Tab, Key) -> [Object] > > All these operations on standard ADTs are roughly equivalent, and yet > they have different or conflicting naming conventions, different > return value protocols, and different orderings of their arguments. > > While ets:lookup and dets:lookup return a tuple, one of whose members > is the key, gb_tree:lookup return the value of a {key,value} pair. > > gb_tree:lookup, dict:find and proplists:get_value all perform the same > operation, and though the return value protocol is different in each > case, at least the arguments are the same. > > The key asset for any well designed language or library is > learnability, which comes from regularity, i.e. having learned > something in one situation, one can apply that knowledge to similar > situation with a high probability of success. > > Erlang already does a lot of things differently from other languages, > but when every single library module does things differently from the > others, well, that's a lot of heterogeneity for a novice to deal with. > > I wasted an hour so so tonight trying to figure out a problem that > stemmed from proplists having a different argument ordering to ets - I > just instinctively assumed they had the same argument ordering, and > why shouldn't I? > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dmorton@REDACTED Sat Nov 15 23:47:48 2008 From: dmorton@REDACTED (damien morton) Date: Sun, 16 Nov 2008 09:47:48 +1100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <3dbc6d1c0811151356s183172fcj79e463a8f7da9c6f@mail.gmail.com> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <3dbc6d1c0811151356s183172fcj79e463a8f7da9c6f@mail.gmail.com> Message-ID: <8092dc770811151447y6e4c6849v5a19ff5f6cba5713@mail.gmail.com> On Sun, Nov 16, 2008 at 8:56 AM, Robert Virding wrote: > You have mentioned a very real problem, although some of the things you > point out are actually justified. For example ets/dets explicitly handle > tuples where one of the elements is the key while dict/orddict/gb_trees work > with separate keys and values so a difference here is expected. It is a pity > that gb_trees does not have a dict compatible api where it is possible. Its also a pity gb_trees isn't simply named trees. The gb_ part is just obscure - why does it matter that the implementation of trees is of the type gb_ but the implementation of dict and set is not. 99% of users simply wont care. > That argument ordering is different and that sometimes the thing worked upon > comes first, or last, or sometimes even in the middle is unfortunate. The > different, or rather inconsistent, ways of indicating success/failure is > also unfortunate. A first step would be to develop some guidelines. The .NET 1.0 libraries were very poorly hacked together. For .NET 2.0, a set of guidelines were developed http://msdn.microsoft.com/en-us/library/ms229042.aspx One of their library designers, Rico Mariani, had this to say: The flip side of this is that it must not only be easy to use the API, but it must be easy to use the API in the best possible way. Think carefully about what patterns you offer and be sure that the most natural way to use your system gives results that are correct, is secure against attacks, and has great performance. Make it hard to do things the wrong way. A few years ago I wrote this: The Pit of Success: In stark contrast to a summit, a peak, or a journey across a desert to find victory through many trials and surprises, we want our customers to simply fall into winning practices by using our platform and frameworks. To the extent that we make it easy to get into trouble we fail. True productivity comes from being able to easily create great products? not from being able to easily create junk. Build a pit of success. > Reworking Erlang to fix many of these errors would probably worth the > effort, though it might split the user group. One could also fix the syntax, > although making it look more like C#/Java would probably be last on my list > of priorities, if it ever got there in the first place. I mean the idea is > to look forwards and try and get rid of old blemishes of the past and not > import someone elses old crud. Though there were worries that the Python 3000 effort might split the community, that doesn't seem to have happened. Tools have been produced that make porting to py3000 possible, and I understand that the language changes are relatively modest, removing the most glaring of language warts, and regularising and reorganising libraries. Probably the most useful part of the process is a document like this one: http://www.python.org/dev/peps/pep-3099/ "Things that will Not Change in Python 3000". My 2c worth - the focus of the effort should be in making the language and libraries more accessible. In the end, languages aren't only selected for utility, but also for learnability. Python has made huge inroads, I think, because its original focus on being a teaching language. > It would also be fun, though I think it would be more difficult than many > believe. I wonder. It depends on the scope of the changes. If its mostly a refactoring .... The Python 3000 process did provoke an orgy of proposals, but if the limits were set by the erlang luminaries early in the process, then perhaps the energies of the community could be better focussed. -------------- next part -------------- An HTML attachment was scrubbed... URL: From foolishewe@REDACTED Sun Nov 16 00:27:18 2008 From: foolishewe@REDACTED (Foolish Ewe) Date: Sat, 15 Nov 2008 18:27:18 -0500 Subject: [erlang-questions] When can an integer > 0 not be a pos_integer() in the Dialyzer? In-Reply-To: <491E8AC5.5050900@cs.ntua.gr> References: <491E8AC5.5050900@cs.ntua.gr> Message-ID: <837bc8cc0811151527i2cc0fc64h6026c54b326e67d0@mail.gmail.com> Hi Kostis: Wow that was fast :-). Speaking of fast, am I imagining things or is the dialyzer noticeably faster when using it in R12B4 than R12B3, Thanks for the quick response. I should have been a bit more thorough in reporting the command line options I used, I'm sorry about that. My gut reaction is to turn on the strictest possible checking in any static analysis tool, I'd much rather sweat it now than be chasing run time errors later. Bill M. On Sat, Nov 15, 2008 at 3:39 AM, Kostis Sagonas wrote: > Bill M. wrote: > >> Hello All: >> >> Please consider the following functions >> (which perform a sieve of Eratosthenes to find all primes < N where N > 1, >> > > ... CODE OMITTED ... > > Running the dialyzer from R12B4 gives (Note, I had to make the lines >> in the code snippet above fit in 80 columns or less, so the line >> number might be off): >> >> test.erl:20: Type specification test:list_primes_helper/2 :: >> (MaxFactor::pos_integer(),PrimeCandidates::[pos_integer()]) -> >> [pos_integer()] is a subtype of the success typing: >> (pos_integer(),[integer()]) -> [integer()] >> > > Well, running dialyzer on your code will not give you this. > You will only get this if you explicitly turn on the option -Woverspecs. > You should not. > > From the options that are turned off by default, the only two options we > recommend turning on are: -Wunmatched_returns and -Wunderspecs > > The remaining options are mainly for developers & debugging. > (The manual could have been more explicit regarding this point - it will be > in the next version.) > > My guess is dialyzer didn't accurately guess the type of lists:seq(2,N). >> > > Your guess is correct, but it also has to do with the fact that the spec > for this function is not as refined as it can be. In R12B-4, it reads: > > -spec(seq/2 :: (integer(),integer()) -> [integer(),...]). > > and it nowhere specifies that if you feed it two pos_integer() it will > return a list of pos_integer(). > > Kostis > -------------- next part -------------- An HTML attachment was scrubbed... URL: From exta7@REDACTED Sun Nov 16 01:07:41 2008 From: exta7@REDACTED (Zvi) Date: Sat, 15 Nov 2008 16:07:41 -0800 (PST) Subject: [erlang-questions] Erlang 3000? In-Reply-To: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> Message-ID: <20520907.post@talk.nabble.com> Damien, look at these threads: http://www.nabble.com/List-to-proplist--to20063268.html#a20265061 http://www.nabble.com/Hungarian-notation-for-Erlang---ETL-td14701912.html#a19822958 What you suggesting can be divided into 2 tasks: 1. New language spec 2. New standard library As there is a lot of legacy products in today's Erlang/OTP, I guess OTP team's first priority is backward compatibility. I heard, that some attempts to fork the language failed. It looks like each module in stdlib was developed by people from different galaxies :-) One of the problem, that Erlang is dynamicaly-typed language, and module writer use whatever atoms s/he want (i.e ok, done, ping, pong, pang, error, etc.), when in statically-typed language you return boolean, with only two known values. Anyway, you can see here the difference between languages, which require some discipline and those which don't. It very hard, to write libraries like this in Java or C++ (but very easy in Perl or other scripting languages). I think, the best path to approach this problem, is to start writing new stdlib, the basis of which will be gen_collection behaviour (something like STL in C++ for Erlang). For simplicity it will be just common API wrappers for various collections ADTs in Erlang stdlib. Even if there are will be some performance loss, it will make code much more readable and maintainable. The next step is to add to gen_collection data-parallel APIs (in the style of plists module). By data parallel constructs I not only mean, usual map / fold / filter, but also various methods, like lookup for multiple keys or adding multiple key/value pairs by single function call, or operating coillections as a whole. For this you do not need OTP team involvent, just start open source project on github. Zvi Damien Morton-2 wrote: > > I don't suppose there's and Erlang 3000 project in the works? > > The Python people set out to create Python 3000, throwing backwards > compatibility out the window in favour of fixing language and library > design errors. > > I mentioned earlier the variety of ways that the Erlang libraries > signal returning a value or not. Some examples: > > proplists:get_value(Key, List) -> undefined | Value > > dict:find(Key, Dict) -> {ok, Value} | error > > gb_tree:lookup(Key, Tree) -> {value, Val} | none > > dets:lookup(Name, Key) -> [Object] | {error, Reason} > > ets:lookup(Tab, Key) -> [Object] > > All these operations on standard ADTs are roughly equivalent, and yet > they have different or conflicting naming conventions, different > return value protocols, and different orderings of their arguments. > > While ets:lookup and dets:lookup return a tuple, one of whose members > is the key, gb_tree:lookup return the value of a {key,value} pair. > > gb_tree:lookup, dict:find and proplists:get_value all perform the same > operation, and though the return value protocol is different in each > case, at least the arguments are the same. > > The key asset for any well designed language or library is > learnability, which comes from regularity, i.e. having learned > something in one situation, one can apply that knowledge to similar > situation with a high probability of success. > > Erlang already does a lot of things differently from other languages, > but when every single library module does things differently from the > others, well, that's a lot of heterogeneity for a novice to deal with. > > I wasted an hour so so tonight trying to figure out a problem that > stemmed from proplists having a different argument ordering to ets - I > just instinctively assumed they had the same argument ordering, and > why shouldn't I? > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > -- View this message in context: http://www.nabble.com/Erlang-3000--tp20518620p20520907.html Sent from the Erlang Questions mailing list archive at Nabble.com. From dmorton@REDACTED Sun Nov 16 03:09:04 2008 From: dmorton@REDACTED (damien morton) Date: Sun, 16 Nov 2008 13:09:04 +1100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <20520907.post@talk.nabble.com> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20520907.post@talk.nabble.com> Message-ID: <8092dc770811151809u397b1c77t77030287bcf35478@mail.gmail.com> As you suggest, the 'minimal' change is to wrap the current set of collections and create a set of behaviours to regularise naming. From this a set of library guidelines could be born to guide other efforts in other modules. Can a module have multiple behaviours applied to it? What happens with conflicts, can one function satisfy two or more behaviour requirements? On Sun, Nov 16, 2008 at 11:07 AM, Zvi wrote: > > Damien, > > look at these threads: > > http://www.nabble.com/List-to-proplist--to20063268.html#a20265061 > > > http://www.nabble.com/Hungarian-notation-for-Erlang---ETL-td14701912.html#a19822958 > > What you suggesting can be divided into 2 tasks: > 1. New language spec > 2. New standard library > > As there is a lot of legacy products in today's Erlang/OTP, I guess OTP > team's first priority is backward compatibility. I heard, that some > attempts > to fork the language failed. > It looks like each module in stdlib was developed by people from different > galaxies :-) > One of the problem, that Erlang is dynamicaly-typed language, and module > writer use whatever atoms s/he want (i.e ok, done, ping, pong, pang, error, > etc.), when in statically-typed language you return boolean, with only two > known values. > > Anyway, you can see here the difference between languages, which require > some discipline and those which don't. It very hard, to write libraries > like > this in Java or C++ (but very easy in Perl or other scripting languages). > > I think, the best path to approach this problem, is to start writing new > stdlib, the basis of which will be gen_collection behaviour (something like > STL in C++ for Erlang). For simplicity it will be just common API wrappers > for various collections ADTs in Erlang stdlib. Even if there are will be > some performance loss, it will make code much more readable and > maintainable. > > The next step is to add to gen_collection data-parallel APIs (in the style > of plists module). > By data parallel constructs I not only mean, usual map / fold / filter, but > also various methods, like lookup for multiple keys or adding multiple > key/value pairs by single function call, or operating coillections as a > whole. > > For this you do not need OTP team involvent, just start open source project > on github. > > Zvi > > > > > Damien Morton-2 wrote: > > > > I don't suppose there's and Erlang 3000 project in the works? > > > > The Python people set out to create Python 3000, throwing backwards > > compatibility out the window in favour of fixing language and library > > design errors. > > > > I mentioned earlier the variety of ways that the Erlang libraries > > signal returning a value or not. Some examples: > > > > proplists:get_value(Key, List) -> undefined | Value > > > > dict:find(Key, Dict) -> {ok, Value} | error > > > > gb_tree:lookup(Key, Tree) -> {value, Val} | none > > > > dets:lookup(Name, Key) -> [Object] | {error, Reason} > > > > ets:lookup(Tab, Key) -> [Object] > > > > All these operations on standard ADTs are roughly equivalent, and yet > > they have different or conflicting naming conventions, different > > return value protocols, and different orderings of their arguments. > > > > While ets:lookup and dets:lookup return a tuple, one of whose members > > is the key, gb_tree:lookup return the value of a {key,value} pair. > > > > gb_tree:lookup, dict:find and proplists:get_value all perform the same > > operation, and though the return value protocol is different in each > > case, at least the arguments are the same. > > > > The key asset for any well designed language or library is > > learnability, which comes from regularity, i.e. having learned > > something in one situation, one can apply that knowledge to similar > > situation with a high probability of success. > > > > Erlang already does a lot of things differently from other languages, > > but when every single library module does things differently from the > > others, well, that's a lot of heterogeneity for a novice to deal with. > > > > I wasted an hour so so tonight trying to figure out a problem that > > stemmed from proplists having a different argument ordering to ets - I > > just instinctively assumed they had the same argument ordering, and > > why shouldn't I? > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > > -- > View this message in context: > http://www.nabble.com/Erlang-3000--tp20518620p20520907.html > Sent from the Erlang Questions mailing list archive at Nabble.com. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From steven.charles.davis@REDACTED Sun Nov 16 03:18:36 2008 From: steven.charles.davis@REDACTED (Steve Davis) Date: Sat, 15 Nov 2008 18:18:36 -0800 (PST) Subject: [erlang-questions] Erlang 3000? In-Reply-To: <20520907.post@talk.nabble.com> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20520907.post@talk.nabble.com> Message-ID: <67159637-129c-444c-8e7e-7684db967117@a17g2000prm.googlegroups.com> On Nov 15, 6:07?pm, Zvi wrote: > What you suggesting can be divided into 2 tasks: > 1. New language spec > 2. New standard library Of course 1.is vastly harder than 2. My estimate is that writing and getting consensus on 1 would indeed take until 3000AD. :) From kevin@REDACTED Sun Nov 16 03:18:31 2008 From: kevin@REDACTED (Kevin Scaldeferri) Date: Sat, 15 Nov 2008 18:18:31 -0800 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <20520907.post@talk.nabble.com> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20520907.post@talk.nabble.com> Message-ID: On Nov 15, 2008, at 4:07 PM, Zvi wrote: > One of the problem, that Erlang is dynamicaly-typed language, and > module > writer use whatever atoms s/he want (i.e ok, done, ping, pong, pang, > error, > etc.), when in statically-typed language you return boolean, with > only two > known values. > > Anyway, you can see here the difference between languages, which > require > some discipline and those which don't. It very hard, to write > libraries like > this in Java or C++ (but very easy in Perl or other scripting > languages). Quite honestly, I would say that the situation is worse in Erlang than most dynamically typed languages, because of: a) the existence of symbols, b) the lack of a canonical undef or nil object, and c) to a lesser degree, the strangeness of the if statement -kevin From rvirding@REDACTED Sun Nov 16 03:28:28 2008 From: rvirding@REDACTED (Robert Virding) Date: Sun, 16 Nov 2008 03:28:28 +0100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <20520907.post@talk.nabble.com> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20520907.post@talk.nabble.com> Message-ID: <3dbc6d1c0811151828y6eb258e2t19c816c055c96026@mail.gmail.com> Fortunately hungarian notation is just a convention, otherwise if it was in someway included in Erlang2 (or 3000) there would very soon be a new project Erlang 3, started by me. It sucks greatly. I must honestly say that I am not that convinced in having too many generic libraries. I think that generally you know, and need to know, the representations you use. They are not equivalent even if you hide them behind a interface which tries to make them so. This is not to say that you can't make the interfaces similar if it is possible. I see now in your nabble link you suggest something along these lines. There are many levels in an language definition/standard library and a big problem is working out where the limits are. What goes in the language and what is part of a library. The main problem is not the actual coding, well perhaps if you intend to rewrite the erlang VM, but working out the design and the design principles. Once these are done the coding is not that bad. Robert 2008/11/16 Zvi > > Damien, > > look at these threads: > > http://www.nabble.com/List-to-proplist--to20063268.html#a20265061 > > > http://www.nabble.com/Hungarian-notation-for-Erlang---ETL-td14701912.html#a19822958 > > What you suggesting can be divided into 2 tasks: > 1. New language spec > 2. New standard library > > As there is a lot of legacy products in today's Erlang/OTP, I guess OTP > team's first priority is backward compatibility. I heard, that some > attempts > to fork the language failed. > It looks like each module in stdlib was developed by people from different > galaxies :-) > One of the problem, that Erlang is dynamicaly-typed language, and module > writer use whatever atoms s/he want (i.e ok, done, ping, pong, pang, error, > etc.), when in statically-typed language you return boolean, with only two > known values. > > Anyway, you can see here the difference between languages, which require > some discipline and those which don't. It very hard, to write libraries > like > this in Java or C++ (but very easy in Perl or other scripting languages). > > I think, the best path to approach this problem, is to start writing new > stdlib, the basis of which will be gen_collection behaviour (something like > STL in C++ for Erlang). For simplicity it will be just common API wrappers > for various collections ADTs in Erlang stdlib. Even if there are will be > some performance loss, it will make code much more readable and > maintainable. > > The next step is to add to gen_collection data-parallel APIs (in the style > of plists module). > By data parallel constructs I not only mean, usual map / fold / filter, but > also various methods, like lookup for multiple keys or adding multiple > key/value pairs by single function call, or operating coillections as a > whole. > > For this you do not need OTP team involvent, just start open source project > on github. > > Zvi > > > > > Damien Morton-2 wrote: > > > > I don't suppose there's and Erlang 3000 project in the works? > > > > The Python people set out to create Python 3000, throwing backwards > > compatibility out the window in favour of fixing language and library > > design errors. > > > > I mentioned earlier the variety of ways that the Erlang libraries > > signal returning a value or not. Some examples: > > > > proplists:get_value(Key, List) -> undefined | Value > > > > dict:find(Key, Dict) -> {ok, Value} | error > > > > gb_tree:lookup(Key, Tree) -> {value, Val} | none > > > > dets:lookup(Name, Key) -> [Object] | {error, Reason} > > > > ets:lookup(Tab, Key) -> [Object] > > > > All these operations on standard ADTs are roughly equivalent, and yet > > they have different or conflicting naming conventions, different > > return value protocols, and different orderings of their arguments. > > > > While ets:lookup and dets:lookup return a tuple, one of whose members > > is the key, gb_tree:lookup return the value of a {key,value} pair. > > > > gb_tree:lookup, dict:find and proplists:get_value all perform the same > > operation, and though the return value protocol is different in each > > case, at least the arguments are the same. > > > > The key asset for any well designed language or library is > > learnability, which comes from regularity, i.e. having learned > > something in one situation, one can apply that knowledge to similar > > situation with a high probability of success. > > > > Erlang already does a lot of things differently from other languages, > > but when every single library module does things differently from the > > others, well, that's a lot of heterogeneity for a novice to deal with. > > > > I wasted an hour so so tonight trying to figure out a problem that > > stemmed from proplists having a different argument ordering to ets - I > > just instinctively assumed they had the same argument ordering, and > > why shouldn't I? > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > > -- > View this message in context: > http://www.nabble.com/Erlang-3000--tp20518620p20520907.html > Sent from the Erlang Questions mailing list archive at Nabble.com. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From steven.charles.davis@REDACTED Sun Nov 16 03:35:47 2008 From: steven.charles.davis@REDACTED (Steve Davis) Date: Sat, 15 Nov 2008 18:35:47 -0800 (PST) Subject: [erlang-questions] Erlang 3000? In-Reply-To: References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20520907.post@talk.nabble.com> Message-ID: A few opinions from me here... > a) the existence of symbols, Atoms are good. Good-er than they may first appear to be. > b) the lack of a canonical undef or nil object, and Nulls are bad. Bad-er than they may first appear to be. > c) to a lesser degree, the strangeness of the if statement Can't say I found a use for it yet... /s From dmorton@REDACTED Sun Nov 16 03:38:56 2008 From: dmorton@REDACTED (damien morton) Date: Sun, 16 Nov 2008 13:38:56 +1100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20520907.post@talk.nabble.com> Message-ID: <8092dc770811151838n2b8077faw5eb581460803aa5e@mail.gmail.com> Quick question: I've at least one attempt at a iterator/generator/stream implementation for erlang. Are these things just not performant enough to make them worthwhile? -------------- next part -------------- An HTML attachment was scrubbed... URL: From dmorton@REDACTED Sun Nov 16 03:43:33 2008 From: dmorton@REDACTED (damien morton) Date: Sun, 16 Nov 2008 13:43:33 +1100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20520907.post@talk.nabble.com> Message-ID: <8092dc770811151843n2b8ea65bn14327361a43990c7@mail.gmail.com> Is there anything you can do with an if statement that cant be done with a case statement? On Sun, Nov 16, 2008 at 1:35 PM, Steve Davis wrote: > A few opinions from me here... > > a) the existence of symbols, > Atoms are good. Good-er than they may first appear to be. > > b) the lack of a canonical undef or nil object, and > Nulls are bad. Bad-er than they may first appear to be. > > c) to a lesser degree, the strangeness of the if statement > Can't say I found a use for it yet... > > /s > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rvirding@REDACTED Sun Nov 16 03:46:34 2008 From: rvirding@REDACTED (Robert Virding) Date: Sun, 16 Nov 2008 03:46:34 +0100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20520907.post@talk.nabble.com> Message-ID: <3dbc6d1c0811151846v2454084dnc8830b6237ea6d6@mail.gmail.com> 2008/11/16 Kevin Scaldeferri > > Quite honestly, I would say that the situation is worse in Erlang than > most dynamically typed languages, because of: > > a) the existence of symbols, > b) the lack of a canonical undef or nil object, and > c) to a lesser degree, the strangeness of the if statement > I don't understand your reasons at all: Why do you want/need an undef or nil object in language where everything has a value? And where you have immutable data? Many complain about the if *expression* but I don't really understand why it warrants so much interest. I personally find that I don't use it much anyway, and that because I don't *need* to use it. I find that having pattern matching has changed my style of coding. I just checked my code for LFE and I found that where I most use a "tradional" if is is my checker module where I only check and don't produce anything. I honesty don't see how this can make it difficult to write libraries. I have written quite a few and that was not the problem in writing them. Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: From rvirding@REDACTED Sun Nov 16 03:51:19 2008 From: rvirding@REDACTED (Robert Virding) Date: Sun, 16 Nov 2008 03:51:19 +0100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <67159637-129c-444c-8e7e-7684db967117@a17g2000prm.googlegroups.com> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20520907.post@talk.nabble.com> <67159637-129c-444c-8e7e-7684db967117@a17g2000prm.googlegroups.com> Message-ID: <3dbc6d1c0811151851v4c8215f2o70245e1f89a6ac1@mail.gmail.com> 2008/11/16 Steve Davis > > On Nov 15, 6:07 pm, Zvi wrote: > > What you suggesting can be divided into 2 tasks: > > 1. New language spec > > 2. New standard library > > Of course 1.is vastly harder than 2. > > My estimate is that writing and getting consensus on 1 would indeed > take until 3000AD. At least! :-) Seriously I don't think you can aim for complete consensus, you will never get it. You need to start out with some form of rationale which lays down the basic ideas/principles for the new erlang, and explains the reasons behind them. This is something which, unfortunately, we never did. Once this is done it is easier to design and develop the system. Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: From dmorton@REDACTED Sun Nov 16 04:02:57 2008 From: dmorton@REDACTED (damien morton) Date: Sun, 16 Nov 2008 14:02:57 +1100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <3dbc6d1c0811151828y6eb258e2t19c816c055c96026@mail.gmail.com> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20520907.post@talk.nabble.com> <3dbc6d1c0811151828y6eb258e2t19c816c055c96026@mail.gmail.com> Message-ID: <8092dc770811151902n38f0af7ah525fad6d598d8be@mail.gmail.com> 2008/11/16 Robert Virding > Fortunately hungarian notation is just a convention, otherwise if it was in > someway included in Erlang2 (or 3000) there would very soon be a new project > Erlang 3, started by me. It sucks greatly. Down with Hungary and its bloody awful notation. > I must honestly say that I am not that convinced in having too many generic > libraries. I think that generally you know, and need to know, the > representations you use. They are not equivalent even if you hide them > behind a interface which tries to make them so. This is not to say that you > can't make the interfaces similar if it is possible. Genericity isn't really possible with erlang. What is possible is regularity. A 'dictionary' behaviour and a 'collection' behaviour would just about cover the various abstract data types. Maybe also an 'ordered' behaviour, and some distinction between set/bag would be useful. I think some kind of iterator/stream protocol might also be needed, but I dont see it used anywhere in erlang, and there might be a good reason for that. There are many levels in an language definition/standard library and a big > problem is working out where the limits are. What goes in the language and > what is part of a library. So lets just focus on the library. Any language changes will likely have to accommodate the current libraries with only minor changes. > The main problem is not the actual coding, well perhaps if you intend to > rewrite the erlang VM, but working out the design and the design principles. > Once these are done the coding is not that bad. So, if you were to rewrite the collection classes from scratch - what principles would you follow? > > Robert > > 2008/11/16 Zvi > > >> Damien, >> >> look at these threads: >> >> http://www.nabble.com/List-to-proplist--to20063268.html#a20265061 >> >> >> http://www.nabble.com/Hungarian-notation-for-Erlang---ETL-td14701912.html#a19822958 >> >> What you suggesting can be divided into 2 tasks: >> 1. New language spec >> 2. New standard library >> >> As there is a lot of legacy products in today's Erlang/OTP, I guess OTP >> team's first priority is backward compatibility. I heard, that some >> attempts >> to fork the language failed. >> It looks like each module in stdlib was developed by people from different >> galaxies :-) >> One of the problem, that Erlang is dynamicaly-typed language, and module >> writer use whatever atoms s/he want (i.e ok, done, ping, pong, pang, >> error, >> etc.), when in statically-typed language you return boolean, with only two >> known values. >> >> Anyway, you can see here the difference between languages, which require >> some discipline and those which don't. It very hard, to write libraries >> like >> this in Java or C++ (but very easy in Perl or other scripting languages). >> >> I think, the best path to approach this problem, is to start writing new >> stdlib, the basis of which will be gen_collection behaviour (something >> like >> STL in C++ for Erlang). For simplicity it will be just common API wrappers >> for various collections ADTs in Erlang stdlib. Even if there are will be >> some performance loss, it will make code much more readable and >> maintainable. >> >> The next step is to add to gen_collection data-parallel APIs (in the style >> of plists module). >> By data parallel constructs I not only mean, usual map / fold / filter, >> but >> also various methods, like lookup for multiple keys or adding multiple >> key/value pairs by single function call, or operating coillections as a >> whole. >> >> For this you do not need OTP team involvent, just start open source >> project >> on github. >> >> Zvi >> >> >> >> >> Damien Morton-2 wrote: >> > >> > I don't suppose there's and Erlang 3000 project in the works? >> > >> > The Python people set out to create Python 3000, throwing backwards >> > compatibility out the window in favour of fixing language and library >> > design errors. >> > >> > I mentioned earlier the variety of ways that the Erlang libraries >> > signal returning a value or not. Some examples: >> > >> > proplists:get_value(Key, List) -> undefined | Value >> > >> > dict:find(Key, Dict) -> {ok, Value} | error >> > >> > gb_tree:lookup(Key, Tree) -> {value, Val} | none >> > >> > dets:lookup(Name, Key) -> [Object] | {error, Reason} >> > >> > ets:lookup(Tab, Key) -> [Object] >> > >> > All these operations on standard ADTs are roughly equivalent, and yet >> > they have different or conflicting naming conventions, different >> > return value protocols, and different orderings of their arguments. >> > >> > While ets:lookup and dets:lookup return a tuple, one of whose members >> > is the key, gb_tree:lookup return the value of a {key,value} pair. >> > >> > gb_tree:lookup, dict:find and proplists:get_value all perform the same >> > operation, and though the return value protocol is different in each >> > case, at least the arguments are the same. >> > >> > The key asset for any well designed language or library is >> > learnability, which comes from regularity, i.e. having learned >> > something in one situation, one can apply that knowledge to similar >> > situation with a high probability of success. >> > >> > Erlang already does a lot of things differently from other languages, >> > but when every single library module does things differently from the >> > others, well, that's a lot of heterogeneity for a novice to deal with. >> > >> > I wasted an hour so so tonight trying to figure out a problem that >> > stemmed from proplists having a different argument ordering to ets - I >> > just instinctively assumed they had the same argument ordering, and >> > why shouldn't I? >> > _______________________________________________ >> > erlang-questions mailing list >> > erlang-questions@REDACTED >> > http://www.erlang.org/mailman/listinfo/erlang-questions >> > >> > >> >> -- >> View this message in context: >> http://www.nabble.com/Erlang-3000--tp20518620p20520907.html >> Sent from the Erlang Questions mailing list archive at Nabble.com. >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rvirding@REDACTED Sun Nov 16 04:18:05 2008 From: rvirding@REDACTED (Robert Virding) Date: Sun, 16 Nov 2008 04:18:05 +0100 Subject: [erlang-questions] base64 url-safe encoding In-Reply-To: <8092dc770811142059v42d5ccb9macc2c330cc6f0084@mail.gmail.com> References: <8092dc770811142059v42d5ccb9macc2c330cc6f0084@mail.gmail.com> Message-ID: <3dbc6d1c0811151918g679cabe1ob758c1e3cfce4ba2@mail.gmail.com> I see no problems with this. Send your patch to erlang-patches, you may have to become a member first though. I personally do not see this as big enough to warrant an EEP. Robert 2008/11/15 damien morton > RFC 4648 defines a "URL and Filename safe" base 64 alphabet, which replaces '+' with '-' and '/' with '_'. > > Would anyone have any objections if I added support for this into the base64 module? > > I'm adding in safe_encode(), safe_decode(), safe_encode_to_string(), and safe_decode_to_string() functions. > > How should I submit my patch? > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From foolishewe@REDACTED Sun Nov 16 05:50:36 2008 From: foolishewe@REDACTED (Foolish Ewe) Date: Sat, 15 Nov 2008 23:50:36 -0500 Subject: [erlang-questions] Dialyzer and how it handles lists in R12B4 Message-ID: <837bc8cc0811152050u217a92bfn4802baeb30113a9a@mail.gmail.com> Hello All: I appreciate the recent help I've received on the dialyzer. I'm using the dialyzer from the R12B4 distribution on a larger bit of code than my previous examples and it isn't trivial to whittle them down, due to functional dependencies. The code passes some preliminary testing. I've got two recurring dialyzer complaints (they look similar) The dialyzer invocation looks like: dialyzer --verbose --plt dialyzer.plt -Wunmatched_returns -Wunderspecs -r . | tee dialyzer.log Checking whether the PLT dialyzer.plt is up-to-date... yes Proceeding with analysis... [Stuff Deleted] The dialyzer complaints in my test case read: test.erl:213: Type specification test:public_share_matches_coefficients/3 :: (Parameters::#feldman_vss_parameters{},PublicShare::#feldman_vss_public_share{},CoefficientWitnesses::[non_neg_integer()]) -> bool() is a supertype of the success typing: (#feldman_vss_parameters{},#feldman_vss_public_share{},[non_neg_integer(),...]) -> bool() test.erl:231: Type specification test:validate_shares_and_reconstruct_secret/3 :: (Parameters::#feldman_vss_parameters{},ShareList::[#feldman_vss_private_share{}],CoefficientWitnesses::[non_neg_integer()]) -> non_neg_integer() is a supertype of the success typing: (#feldman_vss_parameters{},[#feldman_vss_private_share{}],[non_neg_integer(),...]) -> non_neg_integer() The whole files are a bit long for a code sample, after some sleep, perhaps I'll have some insights as to how to construct a smaller example. For now, as a compromise, I'll post the structure definitions, the functions and their -spec() statements. %% @doc key_length is in bits %% @version $Id$ from $HeadURL$ -record(feldman_vss_parameters, {key_length :: pos_integer(), %% key length in bits p :: pos_integer(), %% the generator's prime modulus q :: pos_integer(), %% the order of the generator g :: pos_integer(), %% a generator of order q over the integers 0..p-1 n :: pos_integer(), %% the number of participants t :: pos_integer() %% the reconstruction threshold }). %% @doc The part of the share given visible to other participants -record(feldman_vss_public_share, {share_holder_id :: non_neg_integer(), %% the participand holding this share witness :: non_neg_integer() %% the public witness of the share }). %% @doc augmented public share containing information not available to all participants -record(feldman_vss_private_share, {public_share :: #feldman_vss_public_share{}, secret_share :: non_neg_integer() }). %% @private %% @doc Given the parameters a public share and the list of coefficient witnesses, validates the public share -spec(public_share_matches_coefficients/3 :: ( Parameters::#feldman_vss_parameters{}, PublicShare::#feldman_vss_public_share{}, CoefficientWitnesses::[ non_neg_integer() ] ) -> bool()). public_share_matches_coefficients(Parameters, PublicShare, CoefficientWitnesses) when (is_record(Parameters, feldman_vss_parameters) and is_record(PublicShare, feldman_vss_public_share) and is_list(CoefficientWitnesses))-> Id = PublicShare#feldman_vss_public_share.share_holder_id, ShareWitness = PublicShare#feldman_vss_public_share.witness, %% io:format("validate_public_share(Parameters=~w PublicShare=~w CoefficientWitnesses=~w) ID=~w, ShareWitness=~w~n", %% [Parameters, PublicShare, CoefficientWitnesses, Id, ShareWitness]), ShareWitnessCheckValue = compute_witness_check_value(CoefficientWitnesses, Id, 0, Parameters#feldman_vss_parameters.p, Parameters#feldman_vss_parameters.q), Result = (ShareWitnessCheckValue == ShareWitness), Result. %% @doc Given the secret sharing encoding parameters, the list of private shares of an authorized subset and the coefficient witnesses %% @doc check the shares and if valid reconstruct the secret, throws invalid_invalid_shares_received exception if corrupted shares are received -spec(validate_shares_and_reconstruct_secret/3 :: (Parameters :: #feldman_vss_parameters{}, ShareList :: [#feldman_vss_private_share{}], CoefficientWitnesses :: [non_neg_integer()])->non_neg_integer()). validate_shares_and_reconstruct_secret(Parameters, ShareList, CoefficientWitnesses) when (is_list(ShareList) and is_record(Parameters, feldman_vss_parameters) and is_list(CoefficientWitnesses))-> %% io:format("reconstruct_secret(ShareList=~w, Parameters=~w, CoefficientWitnesses=~w) invoked~n", [ShareList, Parameters, CoefficientWitnesses]), PublicShares = [ Share#feldman_vss_private_share.public_share || Share<-ShareList ], ShareListIsValid = validate_public_shares(Parameters, PublicShares, CoefficientWitnesses), %% io:format("reconstruct_secret, ShareListIsValid =~w~n", [ShareListIsValid]), if (not ShareListIsValid)-> throw({invalid_shares_received, [ShareList, Parameters, CoefficientWitnesses]}); (ShareListIsValid)-> Result = reconstruct_secret(Parameters, ShareList), Result end. More information could be made availalble if needed. I would like to know: 1) Am I right that the dialyzer thinks that these functions need non-empty lists? 2) Why would the dialyzer think that? 3) What can I do to get information out of the dialyzer to get a better hint as to why it thinks that? Regards: Bill M. -------------- next part -------------- An HTML attachment was scrubbed... URL: From kevin@REDACTED Sun Nov 16 06:12:59 2008 From: kevin@REDACTED (Kevin Scaldeferri) Date: Sat, 15 Nov 2008 21:12:59 -0800 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <3dbc6d1c0811151846v2454084dnc8830b6237ea6d6@mail.gmail.com> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20520907.post@talk.nabble.com> <3dbc6d1c0811151846v2454084dnc8830b6237ea6d6@mail.gmail.com> Message-ID: <031EC830-4734-4099-8F2F-33F6954D5F4E@scaldeferri.com> On Nov 15, 2008, at 6:46 PM, Robert Virding wrote: > 2008/11/16 Kevin Scaldeferri > > Quite honestly, I would say that the situation is worse in Erlang than > most dynamically typed languages, because of: > > a) the existence of symbols, > b) the lack of a canonical undef or nil object, and > c) to a lesser degree, the strangeness of the if statement > > I don't understand your reasons at all: > > Why do you want/need an undef or nil object in language where > everything has a value? And where you have immutable data? Perhaps I was overly terse. I was not saying that any of the above are necessarily bad, but simply that they contribute to the situation where there are many modules with interfaces which are similar, but not quite the same. I.e. the complaint in the original email: > proplists:get_value(Key, List) -> undefined | Value > > dict:find(Key, Dict) -> {ok, Value} | error > > gb_tree:lookup(Key, Tree) -> {value, Val} | none > > dets:lookup(Name, Key) -> [Object] | {error, Reason} > > ets:lookup(Tab, Key) -> [Object] and the statement that I was responding to, but that you eliminated from the quote: > One of the problem, that Erlang is dynamicaly-typed language, and > module > writer use whatever atoms s/he want (i.e ok, done, ping, pong, pang, > error, > etc.), when in statically-typed language you return boolean, with > only two > known values. > > Anyway, you can see here the difference between languages, which > require > some discipline and those which don't. It very hard, to write > libraries like > this in Java or C++ (but very easy in Perl or other scripting > languages). I was saying that, contrary to this statement, other dynamic languages do not suffer this particular problem. It seems to me that one reason is that most of these languages have a null/undef/nil entity which is the natural thing to return when a lookup fails. Even in languages like Ruby which also have symbols/atoms, one would never return :error or :none or what have you, because nil is available. > Many complain about the if *expression* but I don't really > understand why it warrants so much interest. I personally find that > I don't use it much anyway, and that because I don't *need* to use > it. I find that having pattern matching has changed my style of > coding. I just checked my code for LFE and I found that where I most > use a "tradional" if is is my checker module where I only check and > don't produce anything. With regards to my point (3), what I am saying is that in languages with a "normal" if-statement, one often writes something like: if (thing = lookup(foo)) { ... do stuff with the thing... } else { ... it wasn't there } Of course, this relies on (a) having an if-statement that works like this, and (b) nil/undef/null being false in boolean context. Neither is the case in Erlang, so one instead tends to use a case, and it doesn't really matter if the return value of lookup is useful in boolean context. > > I honesty don't see how this can make it difficult to write > libraries. I have written quite a few and that was not the problem > in writing them. I did not say anything of the sort. I was saying that these may be factors that contribute to there not being a single, natural interface for this class of functions. -kevin -------------- next part -------------- An HTML attachment was scrubbed... URL: From kostis@REDACTED Sun Nov 16 10:01:54 2008 From: kostis@REDACTED (Kostis Sagonas) Date: Sun, 16 Nov 2008 11:01:54 +0200 Subject: [erlang-questions] When can an integer > 0 not be a pos_integer() in the Dialyzer? In-Reply-To: <837bc8cc0811151527i2cc0fc64h6026c54b326e67d0@mail.gmail.com> References: <491E8AC5.5050900@cs.ntua.gr> <837bc8cc0811151527i2cc0fc64h6026c54b326e67d0@mail.gmail.com> Message-ID: <491FE182.5080101@cs.ntua.gr> Foolish Ewe wrote: > Hi Kostis: > > Wow that was fast :-). Speaking of fast, am I imagining things or is the > dialyzer noticeably faster when using it in R12B4 than R12B3, Frankly, I do not remember. We try our best not to slow down Dialyzer as its code evolves and correct performance bottlenecks that we become aware of. Despite that, regarding the speed of Dialyzer, I find myself having similar feelings to those I have for my salary. It's sufficient for allowing me to live more or less comfortably with it, it improves a bit as time goes by, but it's always considerably less than what I would like it to be :-) > Thanks for the quick response. I should have been a bit more thorough > in reporting the command line options I used, I'm sorry about that. > My gut reaction is to turn on the strictest > possible checking in any static analysis tool, I'd much > rather sweat it now than be chasing run time errors later. Generally this is a good approach, but the problem in what you did is that you turned on options with contradictory aims: -Wunderspecs warns about specs whose constraints are not as strong as they can be (and you probably want to constrain the uses of some of your functions), while -Woverspecs warns about specs whose constraints are stronger than what can be inferred. In general, you want to use -specs that impose stronger constraints on your functions than what your function allows. For example, for the function: app([], L) -> L; app([H|L1], L2) -> [H|app(L1,L2)]. whose success typing is: -spec app(list(), any()) -> any(). (i.e. it requires a list in its first argument, accepts any term on its second, and can return any Erlang term), you probably *want* to use an less permissive spec like the one below: -spec app(list(), list()) -> list(). % overspecified (i.e. constrain the second argument and the result to be a list), but you do not want to accidentally specify a more liberal (overspecified) contract like: -spec app(any(), any()) -> any(). % underspecified Note that I am using the new notation for specs available from R12B-4 onwards. Kostis From steven.charles.davis@REDACTED Sun Nov 16 12:15:13 2008 From: steven.charles.davis@REDACTED (Steve Davis) Date: Sun, 16 Nov 2008 05:15:13 -0600 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <77636BF070754F5194D0472C1254D7AB@moneymaker2> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com><20520907.post@talk.nabble.com><67159637-129c-444c-8e7e-7684db967117@a17g2000prm.googlegroups.com> <3dbc6d1c0811151851v4c8215f2o70245e1f89a6ac1@mail.gmail.com> <77636BF070754F5194D0472C1254D7AB@moneymaker2> Message-ID: <492000C1.4000107@gmail.com> Valentin Micic wrote: > therefore, far better, to change oneself than the language. I am coming around to that conclusion. I recently understood that whilst I had various initial concerns, I honestly couldn't think of a "better way of doing things" once I'd really thought through all the angles. For a "certified Java professional", this has all been a bit of a culture shock. So yes -- I too realize that it is (mostly) me that has needed/does need to change. Erlang/OTP may not have had a cathedral-like architectural plan but it does have something buried in each line of library code that, while intangible, is **much more important** - practical real-world experience. From kostis@REDACTED Sun Nov 16 12:17:42 2008 From: kostis@REDACTED (Kostis Sagonas) Date: Sun, 16 Nov 2008 13:17:42 +0200 Subject: [erlang-questions] Dialyzer and how it handles lists in R12B4 In-Reply-To: <837bc8cc0811152050u217a92bfn4802baeb30113a9a@mail.gmail.com> References: <837bc8cc0811152050u217a92bfn4802baeb30113a9a@mail.gmail.com> Message-ID: <49200156.2050700@cs.ntua.gr> Foolish Ewe wrote: > Hello All: > > I appreciate the recent help I've received on the dialyzer. > > I'm using the dialyzer from the R12B4 distribution ... DELETED > I've got two recurring dialyzer complaints (they look similar) > The dialyzer complaints in my test case read: > test.erl:213: Type specification > test:public_share_matches_coefficients/3 :: > (Parameters::#feldman_vss_parameters{},PublicShare::#feldman_vss_public_share{},CoefficientWitnesses::[non_neg_integer()]) > -> bool() is a supertype of the success typing: > (#feldman_vss_parameters{},#feldman_vss_public_share{},[non_neg_integer(),...]) > -> bool() I think you are making a simple issue a bigger deal than it needs to be. Dialyzer is simply telling you that the third argument of this function is a non-empty list. The proper action here is to simply take the ',...' part of the message and place it in the spec of the file. Then the warnings will automagically disappear. > More information could be made available if needed. I would like to know: > 1) Am I right that the dialyzer thinks that these functions need > non-empty lists? Yes you are right. > 2) Why would the dialyzer think that? Because it does sophisticated analysis of the code ;-) > 3) What can I do to get information out of the dialyzer to get a better > hint as to why it thinks that? Unfortunately, nothing for the time being. Your only option is to stare at your code and see how you are using the 3rd argument (CoefficientWitnesses) of your function. Most probably all calls to the public_share_matches_coefficients/3 function are with non-empty lists in the third argument, or the remaining functions in this module where this argument is passed (e.g. the function compute_witness_check_value/5) only work with non-empty lists. Kostis From webaccounts@REDACTED Sun Nov 16 12:48:51 2008 From: webaccounts@REDACTED (Dan Rubino) Date: Sun, 16 Nov 2008 11:48:51 +0000 Subject: [erlang-questions] Slave nodes... Message-ID: <1226836131.6225.21.camel@linux-box> Hi all, I have just been looking at the slave (nodes) module. >From what I can see it says that (currently) nodes running on an NT machine cannot spawn slave nodes onto another host. Can anyone confirm if this is still the case? Also, I was wondering what the pattern was for storing node/host configuration data within an Erlang application? I currently pass all my configuration data in via the associated .app file. This of course gets messy quickly - is there another way of doing it that I may be missing perhaps? Many Thanks, Dan From valentin@REDACTED Sun Nov 16 10:05:32 2008 From: valentin@REDACTED (Valentin Micic) Date: Sun, 16 Nov 2008 11:05:32 +0200 Subject: [erlang-questions] Erlang 3000? References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com><20520907.post@talk.nabble.com><67159637-129c-444c-8e7e-7684db967117@a17g2000prm.googlegroups.com> <3dbc6d1c0811151851v4c8215f2o70245e1f89a6ac1@mail.gmail.com> Message-ID: <77636BF070754F5194D0472C1254D7AB@moneymaker2> A natural question at this point (at least for me) would be: Why do we want to change the language? I'll dare to put forward a view that claims that there is *nothing wrong with ERLANG*. My justification for this view is as follows: If you use ERLANG as much as I do, sooner or later you have to realize that it is far easier. well, if not easier than - profitable and more useful; therefore, far better, to change oneself than the language. It is true: whenever I hit the wall, all I had to do was to think a bit differently (*) and I'd be on a high ground again. So, why indeed do we try to change the language? If the goal is to make it a better, we should stick to what worked so far - gradual evolution as opposed to change-the-syntax-and-everything-but-vm-revolution. If the purpose is to gain the "masses" (**), as I understood it once, well, no amount of changes to the language will help. For that one just need money and marketing - hence lots of money. BR. V. (*) Mind you, in some other environments (say, languages, run-times, etc.) no amount of thinking differently would help. (**) Or critical mass, which is, IMHO, just euphemism for masses. ----- Original Message ----- From: Robert Virding To: Steve Davis Cc: erlang-questions@REDACTED Sent: Sunday, November 16, 2008 4:51 AM Subject: Re: [erlang-questions] Erlang 3000? 2008/11/16 Steve Davis On Nov 15, 6:07 pm, Zvi wrote: > What you suggesting can be divided into 2 tasks: > 1. New language spec > 2. New standard library Of course 1.is vastly harder than 2. My estimate is that writing and getting consensus on 1 would indeed take until 3000AD. At least! :-) Seriously I don't think you can aim for complete consensus, you will never get it. You need to start out with some form of rationale which lays down the basic ideas/principles for the new erlang, and explains the reasons behind them. This is something which, unfortunately, we never did. Once this is done it is easier to design and develop the system. Robert ------------------------------------------------------------------------------ _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From exta7@REDACTED Sun Nov 16 13:33:41 2008 From: exta7@REDACTED (Zvi) Date: Sun, 16 Nov 2008 04:33:41 -0800 (PST) Subject: [erlang-questions] Erlang 3000? In-Reply-To: <8092dc770811151809u397b1c77t77030287bcf35478@mail.gmail.com> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20520907.post@talk.nabble.com> <8092dc770811151809u397b1c77t77030287bcf35478@mail.gmail.com> Message-ID: <20524858.post@talk.nabble.com> Damien Morton-2 wrote: > > As you suggest, the 'minimal' change is to wrap the current set of > collections and create a set of behaviours to regularise naming. From this > a > set of library guidelines could be born to guide other efforts in other > modules. > Yes, this is what I proposed. This is the fastest way to start prototyping new stdlib, for the begining I propose to use new module names (i.e. for example gc_set instead set, gc_dict, instead dict , etc., where "gc_" perfix mean gen_collection), i.e. to not interfere with legacy code. I have 2 ideas here: 1. Maybe there is a reason from the beginning to have 2 collection behaviours, like in Python: a. gen_mapping (for dict, ets, dets, i.e. any key=>[value] mapping, maybe even funs) b. gen_sequence (for list, tuple, array, set, ordset, etc.). In some languages you may use index as a key - so maybe everything can be gen_mapping? 2. Use parametrized types, to specify ADT implementation details / policies. For example in case of distributed/SMP map/fold , using something as plists "malt" (i.e. how to split tasks between cores/nodes or just use sequential code - this is just example). Zvi Damien Morton-2 wrote: > > Can a module have multiple behaviours applied to it? What happens with > conflicts, can one function satisfy two or more behaviour requirements? > I don't know -- View this message in context: http://www.nabble.com/Erlang-3000--tp20518620p20524858.html Sent from the Erlang Questions mailing list archive at Nabble.com. From exta7@REDACTED Sun Nov 16 13:41:07 2008 From: exta7@REDACTED (Zvi) Date: Sun, 16 Nov 2008 04:41:07 -0800 (PST) Subject: [erlang-questions] Slave nodes... In-Reply-To: <1226836131.6225.21.camel@linux-box> References: <1226836131.6225.21.camel@linux-box> Message-ID: <20524925.post@talk.nabble.com> yes, I think on Windows you can only spawn local slaves (or can't spawn at all). I modified the source code to use psexec.exe instead of ssh, but if you want a clean solution, I think you need to write a little .bat/.cmd script, which spawning erl.exe on another node and specify it using -rsh option, when you launching you master node. Zvi Dan Rubino wrote: > > Hi all, > > I have just been looking at the slave (nodes) module. > >>From what I can see it says that (currently) nodes running on an NT > machine cannot spawn slave nodes onto another host. > > Can anyone confirm if this is still the case? > > Also, I was wondering what the pattern was for storing node/host > configuration data within an Erlang application? I currently pass all my > configuration data in via the associated .app file. > > This of course gets messy quickly - is there another way of doing it > that I may be missing perhaps? > > Many Thanks, > Dan > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > -- View this message in context: http://www.nabble.com/Slave-nodes...-tp20524567p20524925.html Sent from the Erlang Questions mailing list archive at Nabble.com. From dmorton@REDACTED Sun Nov 16 13:57:56 2008 From: dmorton@REDACTED (damien morton) Date: Sun, 16 Nov 2008 23:57:56 +1100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <20524858.post@talk.nabble.com> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20520907.post@talk.nabble.com> <8092dc770811151809u397b1c77t77030287bcf35478@mail.gmail.com> <20524858.post@talk.nabble.com> Message-ID: <8092dc770811160457y21cd63a3o9cd73ffeb9d078d@mail.gmail.com> On Sun, Nov 16, 2008 at 11:33 PM, Zvi wrote: > > This is the fastest way to start prototyping new stdlib, for the begining I > propose to use new module names (i.e. for example gc_set instead set, > gc_dict, instead dict , etc., where "gc_" perfix mean gen_collection), i.e. > to not interfere with legacy code. > > I have 2 ideas here: > > 1. Maybe there is a reason from the beginning to have 2 collection > behaviours, like in Python: > a. gen_mapping (for dict, ets, dets, i.e. any key=>[value] mapping, maybe > even funs) > b. gen_sequence (for list, tuple, array, set, ordset, etc.). In some > languages you may use index as a key - so maybe everything can be > gen_mapping? I think that what defines sequence is an iterator protocol rather than indexing. sequence module could then be a behavior AND a set of functions for operating on iterators (map, fold, ets) > > > 2. Use parametrized types, to specify ADT implementation details / > policies. > For example in case of distributed/SMP map/fold , using something as plists > "malt" (i.e. how to split tasks between cores/nodes or just use sequential > code - this is just example). Are parametrized types ready for prime-time? Like records, they aren't exactly first-class members of the language, and reading Richards paper on them, he has some concerns about performance. > > > Zvi > > > Damien Morton-2 wrote: > > > > Can a module have multiple behaviours applied to it? What happens with > > conflicts, can one function satisfy two or more behaviour requirements? > > > > I don't know > -- > View this message in context: > http://www.nabble.com/Erlang-3000--tp20518620p20524858.html > Sent from the Erlang Questions mailing list archive at Nabble.com. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From vychodil.hynek@REDACTED Sun Nov 16 14:19:27 2008 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Sun, 16 Nov 2008 14:19:27 +0100 Subject: [erlang-questions] Fwd: conditional expressions In-Reply-To: <8092dc770811150622w6a49e49akb0afa15b3665e481@mail.gmail.com> References: <8092dc770811141638h2a1bee2av19c04e76ce535992@mail.gmail.com> <491EB766.9050102@it.uu.se> <8092dc770811150621s4ea0ef26ved59406d048c46b4@mail.gmail.com> <8092dc770811150622w6a49e49akb0afa15b3665e481@mail.gmail.com> Message-ID: <20081116131928.2AA6924065@relay.gooddata.com> 2008/11/15 damien morton > > > ---------- Forwarded message ---------- > From: damien morton > Date: Sun, Nov 16, 2008 at 1:21 AM > Subject: Re: [erlang-questions] conditional expressions > To: Richard Carlsson > > > > > On Sat, Nov 15, 2008 at 10:49 PM, Richard Carlsson wrote: > >> damien morton wrote: >> >>> ... >> >> >> I cant for the life of me figure out what the most concise way of stating >>> that is in erlang. >>> >>> perhaps >>> X = if (T1=foo()) =/= [] -> T1, false -> bar() end >>> >>> it would nice to be able to say something like >>> X = foo() otherwise bar(). >>> >> >> X = case foo() of >> [] -> bar(); >> X1 -> X1 >> end >> >> If you need to check for other values as well, replace '[] ->' with >> 'X when X =:= [] ; X =:= 0 ; ... ->' >> > > Ok, that works and is reasonably concise. > > >> >> >> But I've always felt that this feature of Python/Perl/... boils down >> to sloppy programming style. It basically means that the caller hopes >> that the "empty or failure" case is signalled by one of the values >> reconized as pseudo-booleans by the language (the programmer might >> not actually know the exact interface of the called function, but >> guessed that this would work), and the resulting code says nothing to >> the reader about the actual set of return values. Furthermore, the >> code might do the wrong thing if the function tries to return e.g. '0' >> or '{}' on success (as opposed to False or None or whatever it usually >> uses for failure). It simply makes the code a lot less tight than it >> ought to be. And then, you still can't use the same idiom on abstract >> data types to treat e.g. an empty set as "false". > > > Well, Python does have a way of determining if an abstract data type is > considered true or false - there's a method the ADT can implement for that. > > Still, what strikes me about the erlang libraries is the tremendous variety > of techniques used to signal the return of a value or not. > > Sometimes nil/Value, sometimes false/Value, sometimes []/[Value], sometimes > false/{value,Value} > > For a function that can return 0 or 1 answers, I personally like the > []/[Value] approach. > It happen because there is not pattern matching in python, perl, ruby, ... but you don't need it in erlang since there is pattern matching in erlang. > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- --Hynek (Pichi) Vychodil -------------- next part -------------- An HTML attachment was scrubbed... URL: From webaccounts@REDACTED Sun Nov 16 14:55:48 2008 From: webaccounts@REDACTED (Dan Rubino) Date: Sun, 16 Nov 2008 13:55:48 +0000 Subject: [erlang-questions] Slave nodes... In-Reply-To: <20524925.post@talk.nabble.com> References: <1226836131.6225.21.camel@linux-box> <20524925.post@talk.nabble.com> Message-ID: <1226843748.6225.27.camel@linux-box> Thanks Zvi, Do you mean something similar to that suggested in: http://www.berabera.info/oldblog/lenglet/howtos/erlangkerberosremctl/index.html I would certainly be interested in hearing from someone who has experience deploying an erlang app across a number of nodes - I would like to know the best way of storing the node configuration i.e. describing which nodes are going to be used for particular conponents. Thanks, Dan On Sun, 2008-11-16 at 04:41 -0800, Zvi wrote: > yes, > > I think on Windows you can only spawn local slaves (or can't spawn at all). > I modified the source code to use psexec.exe instead of ssh, but if you want > a clean solution, I think you need to write a little .bat/.cmd script, which > spawning erl.exe on another node and specify it using -rsh option, when you > launching you master node. > > Zvi > > > Dan Rubino wrote: > > > > Hi all, > > > > I have just been looking at the slave (nodes) module. > > > >>From what I can see it says that (currently) nodes running on an NT > > machine cannot spawn slave nodes onto another host. > > > > Can anyone confirm if this is still the case? > > > > Also, I was wondering what the pattern was for storing node/host > > configuration data within an Erlang application? I currently pass all my > > configuration data in via the associated .app file. > > > > This of course gets messy quickly - is there another way of doing it > > that I may be missing perhaps? > > > > Many Thanks, > > Dan > > > > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > From masse@REDACTED Sun Nov 16 16:25:20 2008 From: masse@REDACTED (mats cronqvist) Date: Sun, 16 Nov 2008 16:25:20 +0100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <8092dc770811151843n2b8ea65bn14327361a43990c7@mail.gmail.com> (damien morton's message of "Sun\, 16 Nov 2008 13\:43\:33 +1100") References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20520907.post@talk.nabble.com> <8092dc770811151843n2b8ea65bn14327361a43990c7@mail.gmail.com> Message-ID: <87prkvsnfj.fsf@dixie.cronqvi.st> "damien morton" writes: > Is there anything you can do with an if statement that cant be done with a > case statement? no. and there is nothing you can do with a 'case' that you can't do with a 'try'. i think a reasonable goal for Erlang v2 (Etwo?) is to get rid of cruft like 'if', 'case', 'catch', 'and', 'or', the old guards etc. and perhaps provide a more consistent API to the libraries (in a new namespace?) mats From kevin@REDACTED Sun Nov 16 16:51:02 2008 From: kevin@REDACTED (Kevin Scaldeferri) Date: Sun, 16 Nov 2008 07:51:02 -0800 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <8092dc770811151447y6e4c6849v5a19ff5f6cba5713@mail.gmail.com> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <3dbc6d1c0811151356s183172fcj79e463a8f7da9c6f@mail.gmail.com> <8092dc770811151447y6e4c6849v5a19ff5f6cba5713@mail.gmail.com> Message-ID: <5A78A2D4-A2FC-42F8-9D8D-37670DBF1992@scaldeferri.com> On Nov 15, 2008, at 2:47 PM, damien morton wrote: > Though there were worries that the Python 3000 effort might split > the community, that doesn't seem to have happened. Tools have been > produced that make porting to py3000 possible, and I understand that > the language changes are relatively modest, removing the most > glaring of language warts, and regularising and reorganising > libraries. > I don't follow what's going on in the Python community, but just as a counterpoint, there seems like a strong possibility that Perl 6 will split the community. Quite bizarrely, the closer a complete, working implementation gets, the louder some people become about their opinion that it will never be a finished or viable platform. -kevin From dmorton@REDACTED Sun Nov 16 17:21:50 2008 From: dmorton@REDACTED (damien morton) Date: Mon, 17 Nov 2008 03:21:50 +1100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <8092dc770811160813n77568685x71eed336d06e446b@mail.gmail.com> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20520907.post@talk.nabble.com> <8092dc770811151809u397b1c77t77030287bcf35478@mail.gmail.com> <20524858.post@talk.nabble.com> <8092dc770811160457y21cd63a3o9cd73ffeb9d078d@mail.gmail.com> <8092dc770811160813n77568685x71eed336d06e446b@mail.gmail.com> Message-ID: <8092dc770811160821k2d44ddd0xe6c78f8ad84f6648@mail.gmail.com> I created a forum on Google Moderator for collecting together ideas on Erlang 3000. The forum is called Next(Erlang) and can be found at http://moderator.appspot.com/#15/e=bbc4&t=b355 Google Moderator is a combination of a discussion group with up/down voting on particular discussions. -------------- next part -------------- An HTML attachment was scrubbed... URL: From rvirding@REDACTED Sun Nov 16 17:28:11 2008 From: rvirding@REDACTED (Robert Virding) Date: Sun, 16 Nov 2008 17:28:11 +0100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <8092dc770811160821k2d44ddd0xe6c78f8ad84f6648@mail.gmail.com> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20520907.post@talk.nabble.com> <8092dc770811151809u397b1c77t77030287bcf35478@mail.gmail.com> <20524858.post@talk.nabble.com> <8092dc770811160457y21cd63a3o9cd73ffeb9d078d@mail.gmail.com> <8092dc770811160813n77568685x71eed336d06e446b@mail.gmail.com> <8092dc770811160821k2d44ddd0xe6c78f8ad84f6648@mail.gmail.com> Message-ID: <3dbc6d1c0811160828l19ae08dfi1de94f80d5349bc0@mail.gmail.com> I'm in. Robert 2008/11/16 damien morton > I created a forum on Google Moderator for collecting together ideas on > Erlang 3000. > The forum is called Next(Erlang) and can be found at > http://moderator.appspot.com/#15/e=bbc4&t=b355 > > Google Moderator is a combination of a discussion group with up/down voting > on particular discussions. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From exta7@REDACTED Sun Nov 16 17:56:56 2008 From: exta7@REDACTED (Zvi) Date: Sun, 16 Nov 2008 08:56:56 -0800 (PST) Subject: [erlang-questions] Erlang 3000? In-Reply-To: <3dbc6d1c0811160828l19ae08dfi1de94f80d5349bc0@mail.gmail.com> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20520907.post@talk.nabble.com> <8092dc770811151809u397b1c77t77030287bcf35478@mail.gmail.com> <20524858.post@talk.nabble.com> <8092dc770811160457y21cd63a3o9cd73ffeb9d078d@mail.gmail.com> <8092dc770811160821k2d44ddd0xe6c78f8ad84f6648@mail.gmail.com> <3dbc6d1c0811160828l19ae08dfi1de94f80d5349bc0@mail.gmail.com> Message-ID: <20527337.post@talk.nabble.com> don't you think it should be Erlang2 = erlang2:next(Erlang). {ok, Erlang2} = erlang2:next(Erlang). assuming, that erlang2 module is autoimported, then {ok, Erlang2} = next(Erlang). or just next(Erlang) (i.e. like C++ or [incr Tcl] ;-) ok, moving to google groups... Zvi Robert Virding-2 wrote: > > I'm in. > > Robert > > 2008/11/16 damien morton > >> I created a forum on Google Moderator for collecting together ideas on >> Erlang 3000. >> The forum is called Next(Erlang) and can be found at >> http://moderator.appspot.com/#15/e=bbc4&t=b355 >> >> Google Moderator is a combination of a discussion group with up/down >> voting >> on particular discussions. >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- View this message in context: http://www.nabble.com/Erlang-3000--tp20518620p20527337.html Sent from the Erlang Questions mailing list archive at Nabble.com. From rvirding@REDACTED Sun Nov 16 17:59:02 2008 From: rvirding@REDACTED (Robert Virding) Date: Sun, 16 Nov 2008 17:59:02 +0100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <031EC830-4734-4099-8F2F-33F6954D5F4E@scaldeferri.com> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20520907.post@talk.nabble.com> <3dbc6d1c0811151846v2454084dnc8830b6237ea6d6@mail.gmail.com> <031EC830-4734-4099-8F2F-33F6954D5F4E@scaldeferri.com> Message-ID: <3dbc6d1c0811160859y58498cfbwe5dec153ba3fd468@mail.gmail.com> This is a comment to lots of stuff, not just Kevins post. 2008/11/16 Kevin Scaldeferri > > With regards to my point (3), what I am saying is that in languages with a > "normal" if-statement, one often writes something like: > > if (thing = lookup(foo)) { > ... do stuff with the thing... > } else { > ... it wasn't there > } > Normal in this case means false/nil/0/whatever and everything else is true. This may be practical but it is really not an 'if'. I personally think that this is better expressed by: case lookup(foo) of {yes,Thing} -> ...; no -> ... end Most of the collection modules support this type of return value. Of course, this relies on (a) having an if-statement that works like this, > and (b) nil/undef/null being false in boolean context. Neither is the case > in Erlang, so one instead tends to use a case, and it doesn't really matter > if the return value of lookup is useful in boolean context. > Yes, and I think that is better. It is much more explicit what you mean. I absolutely agree that the collection modules we have have an appalling lack of consistency in their API's, most of it completely unnecessary. This is a result of how erlang was developed and grew. One could say the downside of having such a need driven development. The upside being of course that things you develop and add are really significant. This is something I will have to expand on later. There are many different levels at which Erlang could be modified/enhanced, one of course would be to "just" rewrite the libraries and make them more consistent. This would be a big win just in itself. Changing the funsdamentals of the language is more difficult. (duh!) One problem is to decide what is the language and where the libraries starts. My opinion has always been that the BIF's, not necessarily just those written in C, are part of the language. Many are as fundamental as ! and receive except that they don't have a special syntax and look like normal function calls. So the module erlang is really part of the language, well much of it anyway. Another problem, which somoeone also pointed to, is that many features of the language are very tightly integrated with each other and once you start poking at one you end up affecting them all. A simple example is, of course, pattern matching which is used everywhere and has the same behaviour everywhere. A much more subtle example is concurrency, messages, links/signals, receive, immutable data, error handling, ports, ... which all interact with each other and, in most cases, work coherently together and affect each other. Fiddling with them is much more difficult than at first it may seem. This is one of the points I try to make in my (as yet incomplete) Erlang Rationale. Will it ever be complete? Here I see a definite problem for an Erlang 2. Not insurmountable of course, but finally someone will have to put their foot down. Syntax is another problem, maybe practically even more difficult, but in one respect actually not too difficult. The main point is that the syntax and the semantics must "fit together" and support each other. This is one reason why I am not too keen on using a C/Java like syntax, it was designed for completely different semantics. More thoughts later, Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: From dmorton@REDACTED Sun Nov 16 18:25:05 2008 From: dmorton@REDACTED (damien morton) Date: Mon, 17 Nov 2008 04:25:05 +1100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <3dbc6d1c0811160859y58498cfbwe5dec153ba3fd468@mail.gmail.com> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20520907.post@talk.nabble.com> <3dbc6d1c0811151846v2454084dnc8830b6237ea6d6@mail.gmail.com> <031EC830-4734-4099-8F2F-33F6954D5F4E@scaldeferri.com> <3dbc6d1c0811160859y58498cfbwe5dec153ba3fd468@mail.gmail.com> Message-ID: <8092dc770811160925i579546a7y30dc8d8a716f0c@mail.gmail.com> 2008/11/17 Robert Virding > > Syntax is another problem, maybe practically even more difficult, but in > one respect actually not too difficult. The main point is that the syntax > and the semantics must "fit together" and support each other. This is one > reason why I am not too keen on using a C/Java like syntax, it was designed > for completely different semantics. > > More thoughts later, Another correspondent pointed out that the scope of the changes in Perl 6 is provoking Shock and Awe is some of Perl community - the changes are so extensive that the language is barely recognisable. On the other hand, you would be hard pressed to look at Python code and tell Python 3.0 from Python 2.0 by the syntax alone. In my opinion, any changes to the syntax should be very small, so small that Erlang programmers will be completely comfortable and familiar with next(Erlang). At the same time, there are minor changes that can be made which will make programmers from elsewhere also comfortable. My personal favourite would be an optional indentation mode, as done with F#, giving Python/Haskell style indentation sensitive coding. Wulf Wiger has already got a prototype here http://ulf.wiger.net/weblog/2008/06/11/indentation-sensitive-erlang-3/ --------------------- next(Erlang) -> Make proposals and Vote on them here: http://moderator.appspot.com/#16/e=bbc4 -------------- next part -------------- An HTML attachment was scrubbed... URL: From kevin@REDACTED Sun Nov 16 19:45:28 2008 From: kevin@REDACTED (Kevin Scaldeferri) Date: Sun, 16 Nov 2008 10:45:28 -0800 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <8092dc770811160925i579546a7y30dc8d8a716f0c@mail.gmail.com> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20520907.post@talk.nabble.com> <3dbc6d1c0811151846v2454084dnc8830b6237ea6d6@mail.gmail.com> <031EC830-4734-4099-8F2F-33F6954D5F4E@scaldeferri.com> <3dbc6d1c0811160859y58498cfbwe5dec153ba3fd468@mail.gmail.com> <8092dc770811160925i579546a7y30dc8d8a716f0c@mail.gmail.com> Message-ID: <0EB29AC7-FD4F-4704-9CDB-352B0316944A@scaldeferri.com> On Nov 16, 2008, at 9:25 AM, damien morton wrote: > 2008/11/17 Robert Virding > > Syntax is another problem, maybe practically even more difficult, > but in one respect actually not too difficult. The main point is > that the syntax and the semantics must "fit together" and support > each other. This is one reason why I am not too keen on using a C/ > Java like syntax, it was designed for completely different semantics. > > More thoughts later, > > Another correspondent pointed out that the scope of the changes in > Perl 6 is provoking Shock and Awe is some of Perl community - the > changes are so extensive that the language is barely recognisable. *looks around* Did someone say that? Because I don't think I said that... -kevin -------------- next part -------------- An HTML attachment was scrubbed... URL: From dmorton@REDACTED Sun Nov 16 22:21:42 2008 From: dmorton@REDACTED (damien morton) Date: Mon, 17 Nov 2008 08:21:42 +1100 Subject: [erlang-questions] serializing functions Message-ID: <8092dc770811161321l341abef9x56d3923a7ffcd4d3@mail.gmail.com> If I take the most basic of functions, e.g. fun()->0 end. and serialize it using term_to_binary(), it seems that this function is serialized to 650 bytes. I guess I was wondering if its better to send a Mod:Fun pair from one node to another, or to send an actual function() object. Now, I am still not sure if a function() can be sent over the wire, but a Mod:Fun pair sure is a whole lot more compact. What are the normal best practices when handling functions that might be send over the wire? Prefer Mod:Fun over function()? -------------- next part -------------- An HTML attachment was scrubbed... URL: From klas.johansson@REDACTED Sun Nov 16 22:47:43 2008 From: klas.johansson@REDACTED (Klas Johansson) Date: Sun, 16 Nov 2008 22:47:43 +0100 Subject: [erlang-questions] REF: Major rework of ESDL in progress (NON URGENT) In-Reply-To: References: Message-ID: Hi David, > Question before I go any further, should I also > add more library support, such GLUT or the newest > GLUX, GLEW, GLFW, sdl_image, sdl_mixer, sdl_ttf > and all the companion libraries ? These MIGHT be > of some needs somedays... If you go about hacking away on SDL_image and SDL_ttf you'd want the repository version, not the esdl-0.96.0626 download from the sourceforge download pages since there's already support for SDL_image (written to match 1.2.4) and SDL_ttf (2.0.7) in the repository. SDL_image is now up at 1.2.7 although it seems as if no new functions have been added to the API since 1.2.4 (I just had a quick look though). All of the 1.2.4 API is available through esdl, except what's related to SDL_RWops and the IMG_SetError function. There's an example in the test directory if you're interested: test_glimg.erl. Change log for SDL_image: http://www.libsdl.org/cgi/viewvc.cgi/trunk/SDL_image/CHANGES?view=markup SDL_ttf is now up at 2.0.10 although the only change since 2.0.7 which affects the API (again according to a quick glance; I may have missed something) seems to be the addition of TTF_GlyphIsProvided(). All of the 2.0.7 API is available through esdl, except what's related to SDL_RWops (TTF_OpenFontRW and TTF_OpenFontIndexRW) and the TTF_SetError function. There are two examples in the test directory that you might want to try: test_ttf.erl and test_glfont.erl. Change log for SDL_ttf: http://www.libsdl.org/cgi/viewvc.cgi/trunk/SDL_ttf/CHANGES?view=markup That is, most of the work getting a 100% coverage of SDL_image and SDL_ttf is related to the RWops stuff (which has to do with reading fonts/images from memory instead of files). Also, note that SDL_ttf and SDL_image are disabled by default for esdl, since they depend on libraries not in the plain vanilla SDL packages. Enable them in the Makefile (see the Readme for more information). On a side note, wxerlang (http://sourceforge.net/projects/wxerlang/) has built-in support for opengl canvases, should your personal project require any buttons, menus or other widgets... Cheers, Klas From masse@REDACTED Sun Nov 16 22:48:38 2008 From: masse@REDACTED (mats cronqvist) Date: Sun, 16 Nov 2008 22:48:38 +0100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <3dbc6d1c0811151846v2454084dnc8830b6237ea6d6@mail.gmail.com> (Robert Virding's message of "Sun\, 16 Nov 2008 03\:46\:34 +0100") References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20520907.post@talk.nabble.com> <3dbc6d1c0811151846v2454084dnc8830b6237ea6d6@mail.gmail.com> Message-ID: <87d4gvxryh.fsf@dixie.cronqvi.st> "Robert Virding" writes: > > Why do you want/need an undef or nil object in language where everything has a > value? And where you have immutable data? so you think initializing record fields to 'undefined' is state of the art? > Many complain about the if *expression* but I don't really understand why it > warrants so much interest. I personally find that I don't use it much anyway, > and that because I don't *need* to use it. you don't use it because it's cruft, and people complain about it because they dislike cruft. mats From richardc@REDACTED Sun Nov 16 22:59:06 2008 From: richardc@REDACTED (Richard Carlsson) Date: Sun, 16 Nov 2008 22:59:06 +0100 Subject: [erlang-questions] serializing functions In-Reply-To: <8092dc770811161321l341abef9x56d3923a7ffcd4d3@mail.gmail.com> References: <8092dc770811161321l341abef9x56d3923a7ffcd4d3@mail.gmail.com> Message-ID: <492097AA.7030909@it.uu.se> damien morton wrote: > If I take the most basic of functions, e.g. fun()->0 end. and serialize > it using term_to_binary(), it seems that this function is serialized to > 650 bytes. If you write "fun ... end" in the shell, you will get a rather peculiar closure that actually contains the abstract syntax tree for the fun-expression (which will be interpreted by erl_eval when the closure is applied). That's why it's rather big. > I guess I was wondering if its better to send a Mod:Fun pair from one > node to another, or to send an actual function() object. Now, I am still > not sure if a function() can be sent over the wire, but a Mod:Fun pair > sure is a whole lot more compact. > > What are the normal best practices when handling functions that might be > send over the wire? Prefer Mod:Fun over function()? To have a module send one of its anonymous funs to another node will work (and won't be larger than the size of any captured variables plus a few additional words to identify the fun), but it requires that the code (for the module in which the fun is written) on both nodes is exactly the same. You can have the best of two worlds by sending e.g. "fun foo:bar/0", which has a compact encoding and always calls the latest version of module foo, but is still a fun-object that you can apply as F(). /Richard -- "Having users is like optimization: the wise course is to delay it." -- Paul Graham From matthias@REDACTED Sun Nov 16 23:10:54 2008 From: matthias@REDACTED (Matthias Lang) Date: Sun, 16 Nov 2008 23:10:54 +0100 Subject: [erlang-questions] serializing functions In-Reply-To: <8092dc770811161321l341abef9x56d3923a7ffcd4d3@mail.gmail.com> References: <8092dc770811161321l341abef9x56d3923a7ffcd4d3@mail.gmail.com> Message-ID: <20081116221053.GA5751@contorpis.lisalinda.com> On Monday, November 17, damien morton wrote: > If I take the most basic of functions, e.g. fun()->0 end. and serialize it > using term_to_binary(), it seems that this function is serialized to 650 > bytes. I'd guess you concluded that after trying it in the shell, not a module. IIRC, funs made in the shell are special, they carry around a complete (?) representation of the fun. > I guess I was wondering if its better to send a Mod:Fun pair from one node > to another, or to send an actual function() object. In general, sending the module and the function name is not equivalent to sending a fun. > Now, I am still not sure if a function() can be sent over the wire, > but a Mod:Fun pair sure is a whole lot more compact. > What are the normal best practices when handling functions that might be > send over the wire? Prefer Mod:Fun over function()? The gotchas I can think of are related to code loading. Matt From david.koch@REDACTED Mon Nov 17 00:49:33 2008 From: david.koch@REDACTED (=?iso-8859-1?Q?david.koch@libertysurf.fr?=) Date: Mon, 17 Nov 2008 00:49:33 +0100 Subject: [erlang-questions] =?iso-8859-1?q?_Re=3A__REF=3A_Major_rework_of_?= =?iso-8859-1?q?ESDL_in_progress_=28NON_URGENT=29?= Message-ID: Thanks for the input, I was working from the archive version, not the repository, so I haven't figured much about sdl_image and sdl_ttf right now, was just asking before going any further. You just saved me a large amount of time ! Great... I do not plan to work with WX as GUI, but mostly want a try with GLAM at http://glam.sourceforge.net/ because relying on OpenGL for that kind of stuff makes things more powerful and portable, usable for games as well... And also less complicated with SDI/MDI and all related stuff ^_^ I will try to add as many libs support as possible to ESDL, even if it's not its main goal, but will try to add DLL delayed loading so that until there is no request to some libs, there will be no dependency trouble at program startup :) David KOCH ---------- Initial Header ----------- From : "Klas Johansson" To : "david.koch@REDACTED" Cc : erlang-questions Date : Sun, 16 Nov 2008 22:47:43 +0100 Subject : Re: [erlang-questions] REF: Major rework of ESDL in progress (NON URGENT) Hi David, > Question before I go any further, should I also > add more library support, such GLUT or the newest > GLUX, GLEW, GLFW, sdl_image, sdl_mixer, sdl_ttf > and all the companion libraries ? These MIGHT be > of some needs somedays... If you go about hacking away on SDL_image and SDL_ttf you'd want the repository version, not the esdl-0.96.0626 download from the sourceforge download pages since there's already support for SDL_image (written to match 1.2.4) and SDL_ttf (2.0.7) in the repository. SDL_image is now up at 1.2.7 although it seems as if no new functions have been added to the API since 1.2.4 (I just had a quick look though). All of the 1.2.4 API is available through esdl, except what's related to SDL_RWops and the IMG_SetError function. There's an example in the test directory if you're interested: test_glimg.erl. Change log for SDL_image: http://www.libsdl.org/cgi/viewvc.cgi/trunk/SDL_image/CHANGES? view=markup SDL_ttf is now up at 2.0.10 although the only change since 2.0.7 which affects the API (again according to a quick glance; I may have missed something) seems to be the addition of TTF_GlyphIsProvided(). All of the 2.0.7 API is available through esdl, except what's related to SDL_RWops (TTF_OpenFontRW and TTF_OpenFontIndexRW) and the TTF_SetError function. There are two examples in the test directory that you might want to try: test_ttf.erl and test_glfont.erl. Change log for SDL_ttf: http://www.libsdl.org/cgi/viewvc.cgi/trunk/SDL_ttf/CHANGES? view=markup That is, most of the work getting a 100% coverage of SDL_image and SDL_ttf is related to the RWops stuff (which has to do with reading fonts/images from memory instead of files). Also, note that SDL_ttf and SDL_image are disabled by default for esdl, since they depend on libraries not in the plain vanilla SDL packages. Enable them in the Makefile (see the Readme for more information). On a side note, wxerlang (http://sourceforge.net/projects/wxerlang/) has built-in support for opengl canvases, should your personal project require any buttons, menus or other widgets... Cheers, Klas ---------------------- ALICE N?1 de la RELATION CLIENT 2008*-------------------- D?couvrez vite l'offre exclusive ALICE BOX! En cliquant ici http://abonnement.aliceadsl.fr Offre soumise ? conditions.*Source : TNS SOFRES / BEARING POINT. Secteur Fournisseur d.Acc?s Internet From dmorton@REDACTED Mon Nov 17 01:02:34 2008 From: dmorton@REDACTED (damien morton) Date: Mon, 17 Nov 2008 11:02:34 +1100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <87d4gvxryh.fsf@dixie.cronqvi.st> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20520907.post@talk.nabble.com> <3dbc6d1c0811151846v2454084dnc8830b6237ea6d6@mail.gmail.com> <87d4gvxryh.fsf@dixie.cronqvi.st> Message-ID: <8092dc770811161602u1ad9e09enf9e095af1e7a0df1@mail.gmail.com> On Mon, Nov 17, 2008 at 8:48 AM, mats cronqvist wrote: > "Robert Virding" writes: > > > Why do you want/need an undef or nil object in language where everything > has a > > value? And where you have immutable data? > > None, True, False are just atoms in Python - nothing particularly special about them except the conventions for their use. > > Many complain about the if *expression* but I don't really understand why > it > > warrants so much interest. I personally find that I don't use it much > anyway, > > and that because I don't *need* to use it. > > you don't use it because it's cruft, and people complain about it > because they dislike cruft. > Right, and its cruft because it raises questions about which should be used in which circumstance. Most people will just ignore the "if" statement and use a "case" statement instead, but a novice will take a while to settle into that usage, always wondering if they should use one or the other. A rough grep through the erlang libraries produces some stats: 38 thousand "case" statements 1800 "if" statements. So here's a question: Are there any examples of "if" statements that would be awkward or difficult to express using a "case" statement? -------------- next part -------------- An HTML attachment was scrubbed... URL: From rvirding@REDACTED Mon Nov 17 01:36:38 2008 From: rvirding@REDACTED (Robert Virding) Date: Mon, 17 Nov 2008 01:36:38 +0100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <8092dc770811161602u1ad9e09enf9e095af1e7a0df1@mail.gmail.com> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20520907.post@talk.nabble.com> <3dbc6d1c0811151846v2454084dnc8830b6237ea6d6@mail.gmail.com> <87d4gvxryh.fsf@dixie.cronqvi.st> <8092dc770811161602u1ad9e09enf9e095af1e7a0df1@mail.gmail.com> Message-ID: <3dbc6d1c0811161636p53c581f8w75f37a0790df8944@mail.gmail.com> 2008/11/17 damien morton > > So here's a question: Are there any examples of "if" statements that would > be awkward or difficult to express using a "case" statement? > There is never a case when it would difficult to use case, just some cases where it be awkward or look really strange: case true of true when X > 39 -> ...; true -> ... end instead of if X > 39 -> ...; true -> ... end Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: From hokan.stenholm@REDACTED Mon Nov 17 01:44:26 2008 From: hokan.stenholm@REDACTED (=?ISO-8859-1?Q?H=E5kan_Stenholm?=) Date: Mon, 17 Nov 2008 01:44:26 +0100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <8092dc770811161602u1ad9e09enf9e095af1e7a0df1@mail.gmail.com> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20520907.post@talk.nabble.com> <3dbc6d1c0811151846v2454084dnc8830b6237ea6d6@mail.gmail.com> <87d4gvxryh.fsf@dixie.cronqvi.st> <8092dc770811161602u1ad9e09enf9e095af1e7a0df1@mail.gmail.com> Message-ID: <4920BE6A.5090709@bredband.net> damien morton wrote: > > > On Mon, Nov 17, 2008 at 8:48 AM, mats cronqvist > wrote: > > "Robert Virding" > > writes: > > > Why do you want/need an undef or nil object in language where > everything has a > > value? And where you have immutable data? > > > None, True, False are just atoms in Python - > nothing particularly special about them except the conventions for > their use. > > > > Many complain about the if *expression* but I don't really > understand why it > > warrants so much interest. I personally find that I don't use it > much anyway, > > and that because I don't *need* to use it. > > you don't use it because it's cruft, and people complain about it > because they dislike cruft. > > > Right, and its cruft because it raises questions about which should be > used in which circumstance. Most people will just ignore the "if" > statement and use a "case" statement instead, but a novice will take a > while to settle into that usage, always wondering if they should use > one or the other. > > A rough grep through the erlang libraries produces some stats: > > 38 thousand "case" statements > 1800 "if" statements. > > So here's a question: Are there any examples of "if" statements that > would be awkward or difficult to express using a "case" statement? Conditionals that have more than 2 branches where none of them branch on patterns - e.g. something like the to_upper code below: to_upper_char(C) when is_integer(C) -> if $a =< C, C =< $z -> C - 32; 16#E0 =< C, C =< 16#F6 -> C - 32; 16#F8 =< C, C =< 16#FE -> C - 32; true -> C end. Yes I know that this could be written as: to_upper_char(C) when is_integer(C) -> case ($a =< C andaslo C =< $z) orelse (16#E0 =< C andalso C =< 16#F6) orelse (16#F8 =< C andalso C =< 16#FE) of true -> C - 32; false -> C end. but lets assume that each branch needs to do something different, so we must either use nested cases or have multiple function clauses (one for each condition) to check all the guards. "if"s tend to be convenient in numerical code - like checking for multiple numeric ranges (as above) or to avoid silly things like: case .... of _ when ... -> ... _ when ... -> ... _ when ... -> ... ... end instead of: if ... -> ... ... -> ... ... -> ... ... end > > > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From dmorton@REDACTED Mon Nov 17 03:05:28 2008 From: dmorton@REDACTED (damien morton) Date: Mon, 17 Nov 2008 13:05:28 +1100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <4920BE6A.5090709@bredband.net> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20520907.post@talk.nabble.com> <3dbc6d1c0811151846v2454084dnc8830b6237ea6d6@mail.gmail.com> <87d4gvxryh.fsf@dixie.cronqvi.st> <8092dc770811161602u1ad9e09enf9e095af1e7a0df1@mail.gmail.com> <4920BE6A.5090709@bredband.net> Message-ID: <8092dc770811161805u50edb0ccy1a52454a266035f8@mail.gmail.com> Hmm. Took a look at a sampling of the "if" statements I found in the libraries. Of the ones I looked at, 90% or so were your basic if/else type statement, e.g: if Parent =:= self() -> undefined; true -> Cursor = #qlc_cursor{c = {self(), Parent}}, fun() -> delete_cursor(Cursor) end end, A portion of the remaining 10% were more complicated logic, such as: lookup_all(Key, [P | Ps]) -> if is_atom(P), P =:= Key -> [{Key, true} | lookup_all(Key, Ps)]; tuple_size(P) >= 1, element(1, P) =:= Key -> [P | lookup_all(Key, Ps)]; true -> lookup_all(Key, Ps) end; And a further portion of the remaining 10% were of the form you described, i.e. sequences of range tests. I see that there is an EEP for an is_between() BIF, with mention of supporting boolean expressions of the form "A < B < C", which are a wonderful convenience. I find myself wondering if "case" and "if" can be unified somehow. Consider these two hypothetical statements, which are equivalent: A=foo(), case {B,C}=A, is_list(B) -> do_list(B); -> do_other() end case foo() of {B,C}, is_list(B) -> do_list(B); -> do_other() end In the first statement, the attempted pattern match {B,C}=A is treated the same as a guard. Failure to match is treated the same as a failed guard. In the second statement, the value to match against is implicit. Hmm, needs more thought. On Mon, Nov 17, 2008 at 11:44 AM, H?kan Stenholm wrote: > > damien morton wrote: >> >> So here's a question: Are there any examples of "if" statements that would be awkward or difficult to express using a "case" statement? > > Conditionals that have more than 2 branches where none of them branch on patterns - e.g. something like the to_upper code below: > > to_upper_char(C) when is_integer(C) -> > if > $a =< C, C =< $z -> C - 32; > 16#E0 =< C, C =< 16#F6 -> C - 32; > 16#F8 =< C, C =< 16#FE -> C - 32; > true -> C > end. > > Yes I know that this could be written as: > > to_upper_char(C) when is_integer(C) -> > case ($a =< C andaslo C =< $z) orelse > (16#E0 =< C andalso C =< 16#F6) orelse > (16#F8 =< C andalso C =< 16#FE) of > true -> C - 32; > false -> C > end. > > but lets assume that each branch needs to do something different, so we must either use nested cases or have multiple function clauses (one for each condition) to check all the guards. > > "if"s tend to be convenient in numerical code - like checking for multiple numeric ranges (as above) or to avoid silly things like: > > case .... of > _ when ... -> ... > _ when ... -> ... > _ when ... -> ... > ... > end > > instead of: > > if > ... -> ... > ... -> ... > ... -> ... > ... > end From saleyn@REDACTED Mon Nov 17 04:39:27 2008 From: saleyn@REDACTED (Serge Aleynikov) Date: Sun, 16 Nov 2008 22:39:27 -0500 Subject: [erlang-questions] Bug in trapexit article "How to use ei ..." In-Reply-To: <20516290.post@talk.nabble.com> References: <20516290.post@talk.nabble.com> Message-ID: <4920E76F.6000009@gmail.com> Thanks for pointing it out. This code was more-or-less a quick&dirty copy/paste from http://www.erlang.org/doc/tutorial/erl_interface.html#5.2 that suffers from a buffer overrun issue. I posted the corrections that you found. Serge Mikl Kurkov wrote: > It seems that the code in the trapexit article > http://www.trapexit.org/How_to_use_ei_to_marshal_binary_terms_in_port_programs > has some bugs that I ran into. > In the next code > > [c] > int read_cmd(byte *buf, int *size) > { > int len; > > if (read_exact(buf, 2) != 2) > return(-1); > len = (buf[0] << 8) | buf[1]; > > if (len > *size) { > buf = (byte *) realloc(buf, len); > if (buf == NULL) > return -1; > *size = len; > } > return read_exact(buf, len); > } > [/c] > > if the size of binary data is more than the size of the buffer then data is > reallocated, but the pointer in the main function doesn't change. > I think it should be something like this: > > [c] > int read_cmd(byte **buf_ptr, int *size) > { > int len; > char *buf = *buf_ptr;; > > if (read_exact(buf, 2) != 2) > return -1; > > len = (buf[0] << 8) | buf[1]; > > if (len > *size) { > buf = (byte *) realloc(buf, len); > if (buf == NULL) > return -1; > *buf_ptr = buf; > *size = len; > } > > return read_exact(buf, len); > } > [/c] > > The call of read_cmd in the main function should be changed into > [c] > while (read_cmd(&buf, &size) > 0) { > [/c] > > Besides the code doesn't work properly in the system with the char defined > as signed type. > > Hope this information will be helpful for someone. > -- > Mikl From francesco@REDACTED Mon Nov 17 00:04:25 2008 From: francesco@REDACTED (Francesco Cesarini) Date: Sun, 16 Nov 2008 23:04:25 +0000 Subject: [erlang-questions] Bay Area Erlang Talks Wed. 19/11 Message-ID: <4920A6F9.7050402@erlang-consulting.com> Hi all, Yariv and I will be giving an Erlang talk for the Bay Area ACM chapter this Wednesday. It will be great to meet other Erlangers. Hope to see you there. Francesco Erlang - scalable concurrent + computing for everyone Presented by Francesco Cesarini and Yariv Sadan *Date: *Wednesday, 19 November 2008, 6:30 PM - Social, 7:00 PM Talk *Location: *Hewlett Packard, Pruneridge and Wolfe, Cupertino, Bldg. 48, Oak Room. *Cost: *Free and open to all who wish to attend, but membership is only $20/year. Topic *Francesco Cesarini: "Erlang Concurrency, What?s the Fuss?* Erlang?s concurrency model has been used in commercial systems for well over 15 years, but what differentiates it from other technologies? What are the constructs, what makes them so powerful and scalable, and when using them, what change in mindset is required from the developers? What makes Erlang an excellent choice when developing with SMP in mind? This talk, based on 15 years of concurrent functional programming in Erlang, attempts to answer all these questions. It covers the constructs which provide the concurrency model and the fault tolerance built around it. With live demos, we will be providing benchmarks on process creation and message passing. We will give practical examples of IM and SMS based systems which make the correct use of the concurrency model, providing case studies of systems that work, and ones that don?t. The talk will conclude with Erlang Training & Consulting?s experiences of using Erlang on multi-processor machines, and the challenges this boost in performance is giving our developers. ** *Yariv Sadan: Erlang explained by example* Erlang was originally designed for building large-scale real-time messaging systems. It has not been widely adopted among web developers, largely because it lacked good web development tools. This is unfortunate because Erlang's strengths in concurrency, distributed programming, and fault tolerance can be advantageous for web applications. ErlyWeb was created to fill this gap: its goal is to make building websites using Erlang as simple as, if not simpler than, using popular scripting languages such as Ruby, PHP and Python. In this talk, we will give a brief overview of ErlyWeb and show how to use it to create a simple real-time web-based chat application in Erlang. ** More on the SFBAY ACM home page! From dmorton@REDACTED Mon Nov 17 05:07:08 2008 From: dmorton@REDACTED (damien morton) Date: Mon, 17 Nov 2008 15:07:08 +1100 Subject: [erlang-questions] next(Erlang) Message-ID: <8092dc770811162007g6220c12bh4e7ac2973614fed2@mail.gmail.com> next(Erlang) -> go(" http://moderator.appspot.com/#16/e=bbc4 "). The above Google Moderator site allows you to make, discuss and vote on proposals for a notional future revision of Erlang. Feel free to drop by and add to the discussions. From mkurkov@REDACTED Mon Nov 17 06:58:41 2008 From: mkurkov@REDACTED (Mikl Kurkov) Date: Sun, 16 Nov 2008 21:58:41 -0800 (PST) Subject: [erlang-questions] Bug in trapexit article "How to use ei ..." In-Reply-To: <4920E76F.6000009@gmail.com> References: <20516290.post@talk.nabble.com> <4920E76F.6000009@gmail.com> Message-ID: <20534211.post@talk.nabble.com> Serge Aleynikov-2 wrote: > > Thanks for pointing it out. This code was more-or-less a quick&dirty > copy/paste from > http://www.erlang.org/doc/tutorial/erl_interface.html#5.2 that suffers > from a buffer overrun issue. I posted the corrections that you found. > It seems that you don't update buf_ptr in the new version of read_cmd function. Anyway, thanks for this article. It is very helpful and clear. Mikl -- View this message in context: http://www.nabble.com/Bug-in-trapexit-article-%22How-to-use-ei-...%22-tp20516290p20534211.html Sent from the Erlang Questions mailing list archive at Nabble.com. From bengt.kleberg@REDACTED Mon Nov 17 09:20:39 2008 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Mon, 17 Nov 2008 09:20:39 +0100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <3dbc6d1c0811161636p53c581f8w75f37a0790df8944@mail.gmail.com> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20520907.post@talk.nabble.com> <3dbc6d1c0811151846v2454084dnc8830b6237ea6d6@mail.gmail.com> <87d4gvxryh.fsf@dixie.cronqvi.st> <8092dc770811161602u1ad9e09enf9e095af1e7a0df1@mail.gmail.com> <3dbc6d1c0811161636p53c581f8w75f37a0790df8944@mail.gmail.com> Message-ID: <49212957.1090105@ericsson.com> Greetings, Perhaps somebody would care to post another example since this one is very easy to make un-strange: case X > 39 of true -> false -> end 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." On 2008-11-17 01:36, Robert Virding wrote: > 2008/11/17 damien morton > > > > So here's a question: Are there any examples of "if" statements that > would be awkward or difficult to express using a "case" statement? > > > There is never a case when it would difficult to use case, just some > cases where it be awkward or look really strange: > > case true of > true when X > 39 -> ...; > true -> ... > end > > instead of > > if X > 39 -> ...; > true -> ... > end > > Robert > > > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From bengt.kleberg@REDACTED Mon Nov 17 09:43:39 2008 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Mon, 17 Nov 2008 09:43:39 +0100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> Message-ID: <49212EBB.9080703@ericsson.com> Greetings, You could also add that the return values upon success are unnecessarily different: ets => true mnesia => ok 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." On 2008-11-15 19:54, damien morton wrote: > I don't suppose there's and Erlang 3000 project in the works? > > The Python people set out to create Python 3000, throwing backwards > compatibility out the window in favour of fixing language and library > design errors. > > I mentioned earlier the variety of ways that the Erlang libraries > signal returning a value or not. Some examples: > > proplists:get_value(Key, List) -> undefined | Value > > dict:find(Key, Dict) -> {ok, Value} | error > > gb_tree:lookup(Key, Tree) -> {value, Val} | none > > dets:lookup(Name, Key) -> [Object] | {error, Reason} > > ets:lookup(Tab, Key) -> [Object] > > All these operations on standard ADTs are roughly equivalent, and yet > they have different or conflicting naming conventions, different > return value protocols, and different orderings of their arguments. > > While ets:lookup and dets:lookup return a tuple, one of whose members > is the key, gb_tree:lookup return the value of a {key,value} pair. > > gb_tree:lookup, dict:find and proplists:get_value all perform the same > operation, and though the return value protocol is different in each > case, at least the arguments are the same. > > The key asset for any well designed language or library is > learnability, which comes from regularity, i.e. having learned > something in one situation, one can apply that knowledge to similar > situation with a high probability of success. > > Erlang already does a lot of things differently from other languages, > but when every single library module does things differently from the > others, well, that's a lot of heterogeneity for a novice to deal with. > > I wasted an hour so so tonight trying to figure out a problem that > stemmed from proplists having a different argument ordering to ets - I > just instinctively assumed they had the same argument ordering, and > why shouldn't I? > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From ttmrichter@REDACTED Mon Nov 17 11:18:58 2008 From: ttmrichter@REDACTED (Michael T. Richter) Date: Mon, 17 Nov 2008 18:18:58 +0800 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <492000C1.4000107@gmail.com> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20520907.post@talk.nabble.com> <67159637-129c-444c-8e7e-7684db967117@a17g2000prm.googlegroups.com> <3dbc6d1c0811151851v4c8215f2o70245e1f89a6ac1@mail.gmail.com> <77636BF070754F5194D0472C1254D7AB@moneymaker2> <492000C1.4000107@gmail.com> Message-ID: <1226917138.15595.5.camel@isolde> On Sun, 2008-11-16 at 05:15 -0600, Steve Davis wrote: > > therefore, far better, to change oneself than the language. > I am coming around to that conclusion. I recently understood that whilst > I had various initial concerns, I honestly couldn't think of a "better > way of doing things" once I'd really thought through all the angles. There are, however, some bona fide sharp edges in Erlang that could do with some blunting. I'm looking askance at records here, for example, as well as the inconsistency in the APIs that has been previously mentioned. -- Michael T. Richter (GoogleTalk: ttmrichter@REDACTED) I have to wonder why people think that when they can't manage local personnel within easy strangling and shooting distance, then they can manage personnel thousands of miles away that have different languages, cultures, and business rules. (Joe Celko) -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part URL: From Dana.RUBINO@REDACTED Mon Nov 17 11:53:42 2008 From: Dana.RUBINO@REDACTED (Dana.RUBINO@REDACTED) Date: Mon, 17 Nov 2008 10:53:42 +0000 Subject: [erlang-questions] Mnesia table replication Message-ID: Hi all, Is it possible to have two nodes with each node containing a RAM copy AND and DISK copy? I am thinking a command such as: mnesia:create_table(xyz, [Attrs, {disc_copies, [nodeA, nodeB]}, {ram_copies, [nodeA, nodeB]} ]). Would this work? Also, is there a way to verify which tables are being accessed i.e. through tv? Many Thanks, Dan *********************************************************************************** The Royal Bank of Scotland plc. Registered in Scotland No 90312. Registered Office: 36 St Andrew Square, Edinburgh EH2 2YB. Authorised and regulated by the Financial Services Authority This e-mail message is confidential and for use by the addressee only. If the message is received by anyone other than the addressee, please return the message to the sender by replying to it and then delete the message from your computer. Internet e-mails are not necessarily secure. The Royal Bank of Scotland plc does not accept responsibility for changes made to this message after it was sent. Whilst all reasonable care has been taken to avoid the transmission of viruses, it is the responsibility of the recipient to ensure that the onward transmission, opening or use of this message and any attachments will not adversely affect its systems or data. No responsibility is accepted by The Royal Bank of Scotland plc in this regard and the recipient should carry out such virus and other checks as it considers appropriate. Visit our websites at: www.rbs.com www.rbs.com/gbm www.rbsgc.com *********************************************************************************** -------------- next part -------------- An HTML attachment was scrubbed... URL: From Dana.RUBINO@REDACTED Mon Nov 17 11:57:04 2008 From: Dana.RUBINO@REDACTED (Dana.RUBINO@REDACTED) Date: Mon, 17 Nov 2008 10:57:04 +0000 Subject: [erlang-questions] Mnesia schema deployment best practice Message-ID: Hi, I am getting to the point where I need to automate the release of all the components in my app. Obviously the Mnesia schema will only need to be executed the first time the app is launched and not every time the app is started there after. What is the standard practice for releasing an Mnesia schema and seeding the DB as a one of at initial release? Thanks, Dan *********************************************************************************** The Royal Bank of Scotland plc. Registered in Scotland No 90312. Registered Office: 36 St Andrew Square, Edinburgh EH2 2YB. Authorised and regulated by the Financial Services Authority This e-mail message is confidential and for use by the addressee only. If the message is received by anyone other than the addressee, please return the message to the sender by replying to it and then delete the message from your computer. Internet e-mails are not necessarily secure. The Royal Bank of Scotland plc does not accept responsibility for changes made to this message after it was sent. Whilst all reasonable care has been taken to avoid the transmission of viruses, it is the responsibility of the recipient to ensure that the onward transmission, opening or use of this message and any attachments will not adversely affect its systems or data. No responsibility is accepted by The Royal Bank of Scotland plc in this regard and the recipient should carry out such virus and other checks as it considers appropriate. Visit our websites at: www.rbs.com www.rbs.com/gbm www.rbsgc.com *********************************************************************************** -------------- next part -------------- An HTML attachment was scrubbed... URL: From chandrashekhar.mullaparthi@REDACTED Mon Nov 17 12:12:42 2008 From: chandrashekhar.mullaparthi@REDACTED (Chandru) Date: Mon, 17 Nov 2008 11:12:42 +0000 Subject: [erlang-questions] Mnesia table replication In-Reply-To: References: Message-ID: Hi Dan, 2008/11/17 > Hi all, > > Is it possible to have two nodes with each node containing a RAM copy AND > and DISK copy? > > I am thinking a command such as: > > mnesia:create_table(xyz, [Attrs, > {disc_copies, [nodeA, nodeB]}, > {ram_copies, [nodeA, nodeB]} > ]). > > Would this work? > There is no need to do that. A copy of disc_copies table is also stored in RAM. > Also, is there a way to verify which tables are being accessed i.e. through > tv? > I don't think so. Out of curiosity, why would you want to do that? cheers Chandru -------------- next part -------------- An HTML attachment was scrubbed... URL: From vances@REDACTED Mon Nov 17 12:17:15 2008 From: vances@REDACTED (Vance Shipley) Date: Mon, 17 Nov 2008 06:17:15 -0500 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <49212957.1090105@ericsson.com> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20520907.post@talk.nabble.com> <3dbc6d1c0811151846v2454084dnc8830b6237ea6d6@mail.gmail.com> <87d4gvxryh.fsf@dixie.cronqvi.st> <8092dc770811161602u1ad9e09enf9e095af1e7a0df1@mail.gmail.com> <3dbc6d1c0811161636p53c581f8w75f37a0790df8944@mail.gmail.com> <49212957.1090105@ericsson.com> Message-ID: <20081117111714.GC1005@h216-235-12-168.host.egate.net> On Mon, Nov 17, 2008 at 09:20:39AM +0100, Bengt Kleberg wrote: } Perhaps somebody would care to post another example The if expression is well suited to handling boolean expressions: if HaveMoney and Hungry -> buy_food(); HaveMoney and not Hungry -> buy_beer(); not HaveMoney -> work() end It just reads better. As far as a new Erlang goes I'd mostly want the libraries modernized. Now that we have try ... catch ... end it would be nice if we didn't have to code for {ok, value} | {error, Reason} any longer. -Vance From Dana.RUBINO@REDACTED Mon Nov 17 12:18:02 2008 From: Dana.RUBINO@REDACTED (Dana.RUBINO@REDACTED) Date: Mon, 17 Nov 2008 11:18:02 +0000 Subject: [erlang-questions] Mnesia table replication In-Reply-To: References: Message-ID: Thanks Chandru, I guess I just wanted a way to verify that any process on nodeB for example would be reading from a RAM copy and not one on disk. If a ram copy is definitely created on the node where each disk copy is stored then its not a problem. Thanks for the help. Dan ________________________________ From: Chandru [mailto:chandrashekhar.mullaparthi@REDACTED] Sent: 17 November 2008 11:13 To: RUBINO, Dana, GBM Cc: erlang-questions@REDACTED Subject: Re: [erlang-questions] Mnesia table replication Hi Dan, 2008/11/17 > Hi all, Is it possible to have two nodes with each node containing a RAM copy AND and DISK copy? I am thinking a command such as: mnesia:create_table(xyz, [Attrs, {disc_copies, [nodeA, nodeB]}, {ram_copies, [nodeA, nodeB]} ]). Would this work? There is no need to do that. A copy of disc_copies table is also stored in RAM. Also, is there a way to verify which tables are being accessed i.e. through tv? I don't think so. Out of curiosity, why would you want to do that? cheers Chandru *********************************************************************************** The Royal Bank of Scotland plc. Registered in Scotland No 90312. Registered Office: 36 St Andrew Square, Edinburgh EH2 2YB. Authorised and regulated by the Financial Services Authority This e-mail message is confidential and for use by the addressee only. If the message is received by anyone other than the addressee, please return the message to the sender by replying to it and then delete the message from your computer. Internet e-mails are not necessarily secure. The Royal Bank of Scotland plc does not accept responsibility for changes made to this message after it was sent. Whilst all reasonable care has been taken to avoid the transmission of viruses, it is the responsibility of the recipient to ensure that the onward transmission, opening or use of this message and any attachments will not adversely affect its systems or data. No responsibility is accepted by The Royal Bank of Scotland plc in this regard and the recipient should carry out such virus and other checks as it considers appropriate. Visit our websites at: www.rbs.com www.rbs.com/gbm www.rbsgc.com *********************************************************************************** -------------- next part -------------- An HTML attachment was scrubbed... URL: From kenneth.lundin@REDACTED Mon Nov 17 12:29:04 2008 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Mon, 17 Nov 2008 12:29:04 +0100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> Message-ID: I agree that it is unfortunate that some of the library modules are not consistent with each other but I don't think this is a major problem for users of Erlang. I think it is a very bad idea to start discussing a new incompatible track of Erlang just because of this. The Erlang community is not big enough for this yet, what we need now is actions that stimulate the growth of the community. I definitely don't think the inconsistency in the tree, dict etc. APIs is one of the most important things in this. More important is to get more high quality reusable Open Source components and an easy way to find these. Also more important is to have more books and more "killer" applications built with Erlang. Applications that draw the attention to Erlang. When it comes to inconsistencies in libraries and language I think the best way is to prepare a suggestion on design rules for new API's both for collection ADT's and in general. Then this can be used as a basis for evolving stepwise into more consistent API's. There are ways to evolve without breaking compatibility new functions can easily be added and old ones can be deprecated. New modules can also easily be added etc. It is also very important to remember that backwards compatibility is one of the most appreciated characteristics of Erlang. It makes it possible for large and huge SW projects to shift to a new major release of Erlang/OTP with minimal work. This is essential in order to get users to upgrade to the next release. /Kenneth Erlang/OTP, Ericsson On Sat, Nov 15, 2008 at 7:54 PM, damien morton wrote: > I don't suppose there's and Erlang 3000 project in the works? > > The Python people set out to create Python 3000, throwing backwards > compatibility out the window in favour of fixing language and library > design errors. > > I mentioned earlier the variety of ways that the Erlang libraries > signal returning a value or not. Some examples: > > proplists:get_value(Key, List) -> undefined | Value > > dict:find(Key, Dict) -> {ok, Value} | error > > gb_tree:lookup(Key, Tree) -> {value, Val} | none > > dets:lookup(Name, Key) -> [Object] | {error, Reason} > > ets:lookup(Tab, Key) -> [Object] > > All these operations on standard ADTs are roughly equivalent, and yet > they have different or conflicting naming conventions, different > return value protocols, and different orderings of their arguments. > > While ets:lookup and dets:lookup return a tuple, one of whose members > is the key, gb_tree:lookup return the value of a {key,value} pair. > > gb_tree:lookup, dict:find and proplists:get_value all perform the same > operation, and though the return value protocol is different in each > case, at least the arguments are the same. > > The key asset for any well designed language or library is > learnability, which comes from regularity, i.e. having learned > something in one situation, one can apply that knowledge to similar > situation with a high probability of success. > > Erlang already does a lot of things differently from other languages, > but when every single library module does things differently from the > others, well, that's a lot of heterogeneity for a novice to deal with. > > I wasted an hour so so tonight trying to figure out a problem that > stemmed from proplists having a different argument ordering to ets - I > just instinctively assumed they had the same argument ordering, and > why shouldn't I? > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From Dana.RUBINO@REDACTED Mon Nov 17 13:00:11 2008 From: Dana.RUBINO@REDACTED (Dana.RUBINO@REDACTED) Date: Mon, 17 Nov 2008 12:00:11 +0000 Subject: [erlang-questions] Mnesia table replication In-Reply-To: References: Message-ID: Ok I have given it a go with a test table as such: -module(test). -record(test, {id, name}). test() -> mnesia:create_table(test, [{attributes, record_info(fields, test)}, {disc_copies, ['dan@REDACTED']}]). I then create two local nodes on the same machine and start up Mnesia on each. When looking at each node via the appmon I can see Mnesia has started - I can also ping one node from another. When however I run the test method on one node expecting it to create a replica on the other I get the following error: {aborted,{not_active,test,dan@REDACTED}} Have I missed a step here perhaps? Thanks, Dan ________________________________ From: Chandru [mailto:chandrashekhar.mullaparthi@REDACTED] Sent: 17 November 2008 11:13 To: RUBINO, Dana, GBM Cc: erlang-questions@REDACTED Subject: Re: [erlang-questions] Mnesia table replication Hi Dan, 2008/11/17 > Hi all, Is it possible to have two nodes with each node containing a RAM copy AND and DISK copy? I am thinking a command such as: mnesia:create_table(xyz, [Attrs, {disc_copies, [nodeA, nodeB]}, {ram_copies, [nodeA, nodeB]} ]). Would this work? There is no need to do that. A copy of disc_copies table is also stored in RAM. Also, is there a way to verify which tables are being accessed i.e. through tv? I don't think so. Out of curiosity, why would you want to do that? cheers Chandru *********************************************************************************** The Royal Bank of Scotland plc. Registered in Scotland No 90312. Registered Office: 36 St Andrew Square, Edinburgh EH2 2YB. Authorised and regulated by the Financial Services Authority This e-mail message is confidential and for use by the addressee only. If the message is received by anyone other than the addressee, please return the message to the sender by replying to it and then delete the message from your computer. Internet e-mails are not necessarily secure. The Royal Bank of Scotland plc does not accept responsibility for changes made to this message after it was sent. Whilst all reasonable care has been taken to avoid the transmission of viruses, it is the responsibility of the recipient to ensure that the onward transmission, opening or use of this message and any attachments will not adversely affect its systems or data. No responsibility is accepted by The Royal Bank of Scotland plc in this regard and the recipient should carry out such virus and other checks as it considers appropriate. Visit our websites at: www.rbs.com www.rbs.com/gbm www.rbsgc.com *********************************************************************************** -------------- next part -------------- An HTML attachment was scrubbed... URL: From chandrashekhar.mullaparthi@REDACTED Mon Nov 17 13:03:06 2008 From: chandrashekhar.mullaparthi@REDACTED (Chandru) Date: Mon, 17 Nov 2008 12:03:06 +0000 Subject: [erlang-questions] Mnesia schema deployment best practice In-Reply-To: References: Message-ID: Hi Dan, 2008/11/17 > Hi, > > I am getting to the point where I need to automate the release of all the > components in my app. > > Obviously the Mnesia schema will only need to be executed the first time > the app is launched and not every time the app is started there after. > > What is the standard practice for releasing an Mnesia schema and seeding > the DB as a one of at initial release? > > "It depends" is the answer. I'm not sure of standard practice, but we basically include it as part of the installation procedure for a service. If it is part of a network of mnesia nodes, you could create one by hand, and then make other nodes join the schema as they come up. I'm personally not comfortable with a node creating a schema automatically when it can't find one, because there can be all sorts of operational reasons for a schema not existing. If you are talking about long lived nodes, it is a good idea to create the schema manually, before you run the node at full steam. You'll need the following functions to make a new node join an existing schema. mnesia:add_table_copy/3 mnesia:change_table_copy_type/3 mnesia:change_config/2 The User Guide for mnesia details the procedure. cheers Chandru -------------- next part -------------- An HTML attachment was scrubbed... URL: From chandrashekhar.mullaparthi@REDACTED Mon Nov 17 13:07:22 2008 From: chandrashekhar.mullaparthi@REDACTED (Chandru) Date: Mon, 17 Nov 2008 12:07:22 +0000 Subject: [erlang-questions] Mnesia table replication In-Reply-To: References: Message-ID: 2008/11/17 > Ok I have given it a go with a test table as such: > > -module(test). > -record(test, {id, name}). > > test() -> > mnesia:create_table(test, [{attributes, record_info(fields, test)}, > {disc_copies, ['dan@REDACTED']}]). > > > I then create two local nodes on the same machine and start up Mnesia on > each. > > When looking at each node via the appmon I can see Mnesia has started - I > can also ping one node from another. > > When however I run the test method on one node expecting it to create a > replica on the other I get the following error: > > {aborted,{not_active,test,dan@REDACTED}} > > Have I missed a step here perhaps? > > Is the schema shared across both the nodes? What does mnesia:system_info(db_nodes) return? Chandru -------------- next part -------------- An HTML attachment was scrubbed... URL: From Dana.RUBINO@REDACTED Mon Nov 17 13:19:34 2008 From: Dana.RUBINO@REDACTED (Dana.RUBINO@REDACTED) Date: Mon, 17 Nov 2008 12:19:34 +0000 Subject: [erlang-questions] Mnesia table replication In-Reply-To: References: Message-ID: Thanks Chandru - that's been a great help. I ran mnesia:change_config(extra_db_nodes, ['dan@REDACTED']). The create table command now works - this will now I assume give me replication and conflict resolution between these two nodes? Thanks, Dan ________________________________ From: Chandru [mailto:chandrashekhar.mullaparthi@REDACTED] Sent: 17 November 2008 12:07 To: RUBINO, Dana, GBM Cc: erlang-questions@REDACTED Subject: Re: [erlang-questions] Mnesia table replication 2008/11/17 > Ok I have given it a go with a test table as such: -module(test). -record(test, {id, name}). test() -> mnesia:create_table(test, [{attributes, record_info(fields, test)}, {disc_copies, ['dan@REDACTED']}]). I then create two local nodes on the same machine and start up Mnesia on each. When looking at each node via the appmon I can see Mnesia has started - I can also ping one node from another. When however I run the test method on one node expecting it to create a replica on the other I get the following error: {aborted,{not_active,test,dan@REDACTED}} Have I missed a step here perhaps? Is the schema shared across both the nodes? What does mnesia:system_info(db_nodes) return? Chandru *********************************************************************************** The Royal Bank of Scotland plc. Registered in Scotland No 90312. Registered Office: 36 St Andrew Square, Edinburgh EH2 2YB. Authorised and regulated by the Financial Services Authority This e-mail message is confidential and for use by the addressee only. If the message is received by anyone other than the addressee, please return the message to the sender by replying to it and then delete the message from your computer. Internet e-mails are not necessarily secure. The Royal Bank of Scotland plc does not accept responsibility for changes made to this message after it was sent. Whilst all reasonable care has been taken to avoid the transmission of viruses, it is the responsibility of the recipient to ensure that the onward transmission, opening or use of this message and any attachments will not adversely affect its systems or data. No responsibility is accepted by The Royal Bank of Scotland plc in this regard and the recipient should carry out such virus and other checks as it considers appropriate. Visit our websites at: www.rbs.com www.rbs.com/gbm www.rbsgc.com *********************************************************************************** -------------- next part -------------- An HTML attachment was scrubbed... URL: From chandrashekhar.mullaparthi@REDACTED Mon Nov 17 13:31:23 2008 From: chandrashekhar.mullaparthi@REDACTED (Chandru) Date: Mon, 17 Nov 2008 12:31:23 +0000 Subject: [erlang-questions] Mnesia table replication In-Reply-To: References: Message-ID: 2008/11/17 > Thanks Chandru - that's been a great help. > > I ran mnesia:change_config(extra_db_nodes, ['dan@REDACTED']). > > The create table command now works - this will now I assume give me > replication and conflict resolution between these two nodes? > > Thanks, > Dan > > Dan, best to verify it using some mnesia commands. mnesia:info() will tell you a lot. Have a look at its output. If the table creation is successful across both nodes, you have replication. I'm not sure what you mean by 'conflict resolution'. Chandru -------------- next part -------------- An HTML attachment was scrubbed... URL: From chsu79@REDACTED Mon Nov 17 15:00:40 2008 From: chsu79@REDACTED (Christian) Date: Mon, 17 Nov 2008 15:00:40 +0100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> Message-ID: On Mon, Nov 17, 2008 at 12:29 PM, Kenneth Lundin wrote: > More important is to get more high quality reusable Open Source > components and an easy way to find these. > Also more important is to have more books and more "killer" > applications built with Erlang. Applications that draw > the attention to Erlang. "Me too" regarding all your points. I find that when advocating Erlang the most common question I get is doubt about the library availability to do "things". Where "things" are various problem domains. If it is to use established network protocols, encryption, databases, gui... There is a lot of "grassroots" development of libraries and applications now, but they do not converge to one-true-place where you can get an overview of them all. I lack a good overview of what areas Erlang would be suitable, but where there are no libraries. What is it that is missing to get the community to converge better? I really liked the content on the wiki Luke Gorrie used to run, but, after some serious downtime, it just died. I think jungerl had a goal to be the ultimate collection of erlang libraries, but it sort of died away when not getting any real face-to-face hackaton to learn to know each other and together improve quality and make a great software collection. And as usual nobody really has the time anyway. :-/ What does it take to get some community-driven subdomain sites under the erlang.org domain (so they will get a more official appearance) ? Will it absolutely not happen? Does it require an "ansvarig utgivare", signing contracts and all, responsible for the content etc? From thomasl_erlang@REDACTED Mon Nov 17 14:14:50 2008 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Mon, 17 Nov 2008 05:14:50 -0800 (PST) Subject: [erlang-questions] Erlang 3000? In-Reply-To: <031EC830-4734-4099-8F2F-33F6954D5F4E@scaldeferri.com> Message-ID: <87032.43706.qm@web111405.mail.gq1.yahoo.com> --- On Sun, 11/16/08, Kevin Scaldeferri wrote: > Perhaps I was overly terse. I was not saying that any of > the above are necessarily bad, but simply that they > contribute to the situation where there are many modules > with interfaces which are similar, but not quite the same. I think this is basically a consequence of rolling out new libraries without vetting the APIs and then being semi-unable to change them once they are out. It might of course also be noted that many long-lived and popular libraries have similar problems. Best, Thomas From james.hague@REDACTED Mon Nov 17 15:49:35 2008 From: james.hague@REDACTED (James Hague) Date: Mon, 17 Nov 2008 08:49:35 -0600 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> Message-ID: I've proposed all sorts of crackpot extensions to Erlang, but the two big things that really matter are: 1. Reworking the standard libraries: sets vs. ordsets vs. gb_sets, file_size is in filelib instead of file, reverse/1 should be accessible without importing lists, simple modules are overrun with rarely used cruft, separate out the simple ets from the not so simple match specification stuff, and so on. 2. Some form of lightweight hash table outside of ets. Ideally this would be the replacement for dict/orddict/gb_trees. From joelr1@REDACTED Mon Nov 17 16:02:58 2008 From: joelr1@REDACTED (Joel Reymont) Date: Mon, 17 Nov 2008 15:02:58 +0000 Subject: [erlang-questions] Off topic: Liberate OpenPoker Message-ID: <45B56A33-6E98-44B2-A26B-0AD9190BCBA0@gmail.com> http://www.wagerlabs.com/blog/2008/11/liberate-openpoker.html My apologies for the announcement but I thought there's a tiny bit of relevance. Thanks, Joel From vladdu55@REDACTED Mon Nov 17 16:20:22 2008 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Mon, 17 Nov 2008 16:20:22 +0100 Subject: [erlang-questions] code:get_path() returns badarg Message-ID: <95be1d3b0811170720l75db1d7off89a1f7a6e51099@mail.gmail.com> Hi! I will look at the code in more detail tomorrow, but maybe someone has the answer already... I am calling code:get_path() very early in the startup process and with R12 it often happens that this call crashes with {'EXIT',{badarg,[{code_server,call,2},... My first inspection leads me to guess that the code server isn't started properly and the badarg is because the name code_server isn't registered yet. I even added a code:module_info() call earlier, to let the code server start up properly, but to no avail. I don't know if it's because I should wait a little longer or there is another explanation. The error doesn't happen all the time (actually, I can't reproduce it myself), but I have many reports from different erlide users. Could somebody please guide me from here? best regards, Vlad From erlang-questions_efine@REDACTED Mon Nov 17 18:00:48 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Mon, 17 Nov 2008 12:00:48 -0500 Subject: [erlang-questions] Erlang 3000? In-Reply-To: References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> Message-ID: <6c2563b20811170900p3955fc44nfa46f9b17e7c9412@mail.gmail.com> Completely agree with Kenneth. Any software that grows organically is going to have inconsistencies. Software like Erlang has usually responded to real-world pressures, in real-world timeframes, and has not had the luxury of (say) a series of long design competitions and committees like Ada did (and IIRC, Ada is not that widely used for all that). Some would have a sigh of relief that Erlang didn't go through that process! I think Erlang has done pretty well, and it probably really IS premature to consider "purifying" it while it's trying to get a strong foothold in the development community. I would say that higher priorities are to improve its vertical (multicore) scalability, make more and easier to use tools for (inter alia) operational control and monitoring and release management, as well as productivity tools like better documentation and a well-indexed "apropos" type facility that allows one to search for any specific function, not just its module (I know there is a kluged up one in Emacs, but how about one that works across the board, not only in Emacs?). Other areas that might be fertile ground include distributed security - the current cookie/short name/long name model is a bit limiting, and making it easier to set up and view traces of running code. Maybe I am just dumb, but there are parts of Erlang that are so arcane that I need to have notes to explain to myself how to use them. It would also be extremely useful to beef up the FAQs by combing the Erlang mailing lists and extracting some of the more interesting and complex questions and answers. Yes, we can search the lists, but it can often be very time-consuming, and sometimes one can miss the target if the right Google incantation is not invoked. If most of the answers were condensed into the FAQ it would make a big difference, especially to less experienced Erlang devotees like myself. Thanks for a marvelous development platform, namely Erlang/OTP! Regards, Edwin Fine On Mon, Nov 17, 2008 at 6:29 AM, Kenneth Lundin wrote: > I agree that it is unfortunate that some of the library modules are > not consistent with each other > but I don't think this is a major problem for users of Erlang. > > I think it is a very bad idea to start discussing a new incompatible > track of Erlang just because of this. > > The Erlang community is not big enough for this yet, what we need now > is actions that stimulate the > growth of the community. > > I definitely don't think the inconsistency in the tree, dict etc. APIs > is one of the most important things in this. > > More important is to get more high quality reusable Open Source > components and an easy way to find these. > Also more important is to have more books and more "killer" > applications built with Erlang. Applications that draw > the attention to Erlang. > > When it comes to inconsistencies in libraries and language I think the > best way is to prepare a suggestion on design rules for new API's > both for collection ADT's and in general. Then this can be used as a > basis for evolving stepwise into more consistent API's. > > There are ways to evolve without breaking compatibility new functions > can easily be added and old ones can be deprecated. > New modules can also easily be added etc. > > It is also very important to remember that backwards compatibility is > one of the most appreciated characteristics of Erlang. It makes it > possible for > large and huge SW projects to shift to a new major release of > Erlang/OTP with minimal work. This is essential in order to > get users to upgrade to the next release. > > /Kenneth Erlang/OTP, Ericsson > > > On Sat, Nov 15, 2008 at 7:54 PM, damien morton > wrote: > > I don't suppose there's and Erlang 3000 project in the works? > > > > The Python people set out to create Python 3000, throwing backwards > > compatibility out the window in favour of fixing language and library > > design errors. > > > > I mentioned earlier the variety of ways that the Erlang libraries > > signal returning a value or not. Some examples: > > > > proplists:get_value(Key, List) -> undefined | Value > > > > dict:find(Key, Dict) -> {ok, Value} | error > > > > gb_tree:lookup(Key, Tree) -> {value, Val} | none > > > > dets:lookup(Name, Key) -> [Object] | {error, Reason} > > > > ets:lookup(Tab, Key) -> [Object] > > > > All these operations on standard ADTs are roughly equivalent, and yet > > they have different or conflicting naming conventions, different > > return value protocols, and different orderings of their arguments. > > > > While ets:lookup and dets:lookup return a tuple, one of whose members > > is the key, gb_tree:lookup return the value of a {key,value} pair. > > > > gb_tree:lookup, dict:find and proplists:get_value all perform the same > > operation, and though the return value protocol is different in each > > case, at least the arguments are the same. > > > > The key asset for any well designed language or library is > > learnability, which comes from regularity, i.e. having learned > > something in one situation, one can apply that knowledge to similar > > situation with a high probability of success. > > > > Erlang already does a lot of things differently from other languages, > > but when every single library module does things differently from the > > others, well, that's a lot of heterogeneity for a novice to deal with. > > > > I wasted an hour so so tonight trying to figure out a problem that > > stemmed from proplists having a different argument ordering to ets - I > > just instinctively assumed they had the same argument ordering, and > > why shouldn't I? > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tsuraan@REDACTED Mon Nov 17 20:25:24 2008 From: tsuraan@REDACTED (tsuraan) Date: Mon, 17 Nov 2008 13:25:24 -0600 Subject: [erlang-questions] tempfile, or O_EXCL Message-ID: <84fb38e30811171125u14276c03l53af6e5107a52ab4@mail.gmail.com> Is there any way to specify exclusive (posix O_EXCL) with write when opening a file in Erlang? I couldn't find a mkstemp anywhere in the standard library, so I wrote one myself, but without EXCL, it's not very safe. I'd like to fix that, but I don't see how to do so without being able to open a file in exclusive write mode. From masse@REDACTED Mon Nov 17 21:34:32 2008 From: masse@REDACTED (mats cronqvist) Date: Mon, 17 Nov 2008 21:34:32 +0100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <6c2563b20811170900p3955fc44nfa46f9b17e7c9412@mail.gmail.com> (Edwin Fine's message of "Mon\, 17 Nov 2008 12\:00\:48 -0500") References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <6c2563b20811170900p3955fc44nfa46f9b17e7c9412@mail.gmail.com> Message-ID: <87y6zinlbb.fsf@dixie.cronqvi.st> "Edwin Fine" writes: > (I know there is a kluged up one in Emacs, but how about one that > works across the board, not only in Emacs?). http://en.wikipedia.org/wiki/Kludge (sic); "a clumsy or inelegant solution to a problem" just for the record; the emacs/distel solution is possibly the most elegant erlang code written this millenium. at least by me :> mats From rvirding@REDACTED Mon Nov 17 22:05:19 2008 From: rvirding@REDACTED (Robert Virding) Date: Mon, 17 Nov 2008 22:05:19 +0100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> Message-ID: <3dbc6d1c0811171305n38c27ab1kf66ffa1fa670ffb1@mail.gmail.com> 2008/11/17 James Hague > I've proposed all sorts of crackpot extensions to Erlang, but the two > big things that really matter are: > > 1. Reworking the standard libraries: sets vs. ordsets vs. gb_sets, > file_size is in filelib instead of file, reverse/1 should be > accessible without importing lists, simple modules are overrun with > rarely used cruft, separate out the simple ets from the not so simple > match specification stuff, and so on. I quite agree with you here. Having inconsistent confusing libraries id difficult for everyone and is a turn-off for new comers. 2. Some form of lightweight hash table outside of ets. Ideally this > would be the replacement for dict/orddict/gb_trees. Yes, a built-in lightweight form of dictionaries would be nice, especially if you can match on them. Something like Joe's structs or ROK's frames. However, I do not really see them as a replacement for the existing tables as I don't think you can get them both lightweight and able to efficiently handle large amounts of data. Ets is not always the best alternative for large tables. Concerning Kenneth's post I will get to that with a proper comment. He is right, but also wrong and things do have to be fixed. Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: From dave.smith.to@REDACTED Mon Nov 17 22:10:22 2008 From: dave.smith.to@REDACTED (Dave Smith) Date: Mon, 17 Nov 2008 16:10:22 -0500 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <49212957.1090105@ericsson.com> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20520907.post@talk.nabble.com> <3dbc6d1c0811151846v2454084dnc8830b6237ea6d6@mail.gmail.com> <87d4gvxryh.fsf@dixie.cronqvi.st> <8092dc770811161602u1ad9e09enf9e095af1e7a0df1@mail.gmail.com> <3dbc6d1c0811161636p53c581f8w75f37a0790df8944@mail.gmail.com> <49212957.1090105@ericsson.com> Message-ID: <5ea453f90811171310s1b953297ne9ae2653d4268711@mail.gmail.com> 2008/11/17 Bengt Kleberg > Perhaps somebody would care to post another example since this one is > very easy to make un-strange: > > case X > 39 of > true -> > false -> > end > Example: if X > 39 -> ...; X > 29 -> ...; true -> ... end case true of true when X > 39 -> ...; true when X > 29 -> ...; true -> ... end case X > 39 of true -> ...; false -> case X > 29 of true -> ...; false -> ... end end -------------- next part -------------- An HTML attachment was scrubbed... URL: From erlang-questions_efine@REDACTED Mon Nov 17 22:18:06 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Mon, 17 Nov 2008 16:18:06 -0500 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <87y6zinlbb.fsf@dixie.cronqvi.st> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <6c2563b20811170900p3955fc44nfa46f9b17e7c9412@mail.gmail.com> <87y6zinlbb.fsf@dixie.cronqvi.st> Message-ID: <6c2563b20811171318k76c6f22fya8384b84ab10bf93@mail.gmail.com> I'm sure your code is great; it's a specific solution in erlang.el that's admittedly a kluge (kludge). I refer specifically to the following comment: ;; Warning, the function `erlang-man-function' is a hack! ;; It links itself into the man code in a non-clean way. I have ;; chosen to keep it since it provides a very useful functionality ;; which is not possible to achieve using a clean approach. ;; / AndersL On Mon, Nov 17, 2008 at 3:34 PM, mats cronqvist wrote: > "Edwin Fine" writes: > > > (I know there is a kluged up one in Emacs, but how about one that > > works across the board, not only in Emacs?). > > http://en.wikipedia.org/wiki/Kludge (sic); "a clumsy or inelegant > solution to a problem" > > just for the record; the emacs/distel solution is possibly the most > elegant erlang code written this millenium. at least by me :> > > mats > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dmorton@REDACTED Mon Nov 17 23:47:47 2008 From: dmorton@REDACTED (damien morton) Date: Tue, 18 Nov 2008 09:47:47 +1100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> Message-ID: <8092dc770811171447g6d1d840dx169b90e115e2f5c@mail.gmail.com> On Tue, Nov 18, 2008 at 1:49 AM, James Hague wrote: > I've proposed all sorts of crackpot extensions to Erlang, but the two > big things that really matter are: > > 1. Reworking the standard libraries: sets vs. ordsets vs. gb_sets, > file_size is in filelib instead of file, reverse/1 should be > accessible without importing lists, simple modules are overrun with > rarely used cruft, separate out the simple ets from the not so simple > match specification stuff, and so on. > 2. Some form of lightweight hash table outside of ets. Ideally this > would be the replacement for dict/orddict/gb_trees. Isn't dict the lightweight hashtable you are looking for? If not, what would be the difference bewteen this lightweight hashtable and dict/orddict/gb_trees/dict and ets? From dmorton@REDACTED Tue Nov 18 00:44:33 2008 From: dmorton@REDACTED (damien morton) Date: Tue, 18 Nov 2008 10:44:33 +1100 Subject: [erlang-questions] Fwd: Erlang 3000? In-Reply-To: <8092dc770811171453k276ac855y136aa53b713fb3e3@mail.gmail.com> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <6c2563b20811170900p3955fc44nfa46f9b17e7c9412@mail.gmail.com> <8092dc770811171453k276ac855y136aa53b713fb3e3@mail.gmail.com> Message-ID: <8092dc770811171544n37becf09k67cc44c1b45ad0a7@mail.gmail.com> ---------- Forwarded message ---------- From: damien morton Date: Tue, Nov 18, 2008 at 9:53 AM Subject: Re: [erlang-questions] Erlang 3000? To: Edwin Fine On Tue, Nov 18, 2008 at 4:00 AM, Edwin Fine wrote: > Completely agree with Kenneth. Any software that grows organically is going > to have inconsistencies. Software like Erlang has usually responded to > real-world pressures, in real-world timeframes, and has not had the luxury > of (say) a series of long design competitions and committees like Ada did > (and IIRC, Ada is not that widely used for all that). Some would have a sigh > of relief that Erlang didn't go through that process! I think Erlang has > done pretty well, and it probably really IS premature to consider > "purifying" it while it's trying to get a strong foothold in the development > community. I would say that higher priorities are to improve its vertical > (multicore) scalability, make more and easier to use tools for (inter alia) > operational control and monitoring and release management, as well as > productivity tools like better documentation and a well-indexed "apropos" > type facility that allows one to search for any specific function, not just > its module (I know there is a kluged up one in Emacs, but how about one that > works across the board, not only in Emacs?). Other areas that might be > fertile ground include distributed security - the current cookie/short > name/long name model is a bit limiting, and making it easier to set up and > view traces of running code. Maybe I am just dumb, but there are parts of > Erlang that are so arcane that I need to have notes to explain to myself how > to use them. The point is that designers of new libraries will look to the core libraries for guidance on what patterns, interfaces and protocols to follow. If the core is schizophrenic and full of entropy, growing the language will only multiply that entropy. If the core has low-entropy, growing the language will increase that entropy at a much slower rate. In my opinion, there needs to be two forces applied to the language/libraries - the force of growth and the force of reducing entropy. Refactoring is the entropy reduction strategy of choice, and if we are careful, that refactoring could be automated. From vances@REDACTED Tue Nov 18 01:16:03 2008 From: vances@REDACTED (Vance Shipley) Date: Mon, 17 Nov 2008 19:16:03 -0500 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> Message-ID: <20081118001602.GC1809@h216-235-12-168.host.egate.net> What ever happened to the initiative to put kernel and stdlib into packages? That seemed like an interesting branch. -Vance From rvirding@REDACTED Tue Nov 18 01:32:17 2008 From: rvirding@REDACTED (Robert Virding) Date: Tue, 18 Nov 2008 01:32:17 +0100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <20081118001602.GC1809@h216-235-12-168.host.egate.net> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20081118001602.GC1809@h216-235-12-168.host.egate.net> Message-ID: <3dbc6d1c0811171632t369eb208u5bebfd0f2a102af@mail.gmail.com> What do you mean by packages? Robert 2008/11/18 Vance Shipley > What ever happened to the initiative to put kernel and stdlib > into packages? That seemed like an interesting branch. > > -Vance > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From vances@REDACTED Tue Nov 18 01:50:24 2008 From: vances@REDACTED (Vance Shipley) Date: Mon, 17 Nov 2008 19:50:24 -0500 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <3dbc6d1c0811171632t369eb208u5bebfd0f2a102af@mail.gmail.com> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20081118001602.GC1809@h216-235-12-168.host.egate.net> <3dbc6d1c0811171632t369eb208u5bebfd0f2a102af@mail.gmail.com> Message-ID: <20081118005024.GD1809@h216-235-12-168.host.egate.net> On Tue, Nov 18, 2008 at 01:32:17AM +0100, Robert Virding wrote: } What do you mean by packages? The namespace packages. I recall seeing the libraries stuffed into packages to group things like maybe erlang.bif:link/1. -Vance From dmorton@REDACTED Tue Nov 18 01:56:54 2008 From: dmorton@REDACTED (damien morton) Date: Tue, 18 Nov 2008 11:56:54 +1100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <20081118005024.GD1809@h216-235-12-168.host.egate.net> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20081118001602.GC1809@h216-235-12-168.host.egate.net> <3dbc6d1c0811171632t369eb208u5bebfd0f2a102af@mail.gmail.com> <20081118005024.GD1809@h216-235-12-168.host.egate.net> Message-ID: <8092dc770811171656y2417e851sd81ef2ce30487456@mail.gmail.com> I tried this using filenames "foo.bar.erl" and importing them - and it throws an error currently, so it wouldnt break any code to do this. On Tue, Nov 18, 2008 at 11:50 AM, Vance Shipley wrote: > On Tue, Nov 18, 2008 at 01:32:17AM +0100, Robert Virding wrote: > } What do you mean by packages? > > The namespace packages. I recall seeing the libraries stuffed > into packages to group things like maybe erlang.bif:link/1. > > -Vance From dmorton@REDACTED Tue Nov 18 02:07:31 2008 From: dmorton@REDACTED (damien morton) Date: Tue, 18 Nov 2008 12:07:31 +1100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <8092dc770811171656y2417e851sd81ef2ce30487456@mail.gmail.com> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20081118001602.GC1809@h216-235-12-168.host.egate.net> <3dbc6d1c0811171632t369eb208u5bebfd0f2a102af@mail.gmail.com> <20081118005024.GD1809@h216-235-12-168.host.egate.net> <8092dc770811171656y2417e851sd81ef2ce30487456@mail.gmail.com> Message-ID: <8092dc770811171707t285d2c0aubed793220944d31e@mail.gmail.com> There is a proposal on the next(erlang) Google Moderator site: http://moderator.appspot.com/#15/e=bbc4&t=bbc5 "arbitrarily deep hierarchies of modules [with name-space protection for functions], instead of a flat global module names" On Tue, Nov 18, 2008 at 11:56 AM, damien morton wrote: > I tried this using filenames "foo.bar.erl" and importing them - and it > throws an error currently, so it wouldnt break any code to do this. > > On Tue, Nov 18, 2008 at 11:50 AM, Vance Shipley wrote: >> On Tue, Nov 18, 2008 at 01:32:17AM +0100, Robert Virding wrote: >> } What do you mean by packages? >> >> The namespace packages. I recall seeing the libraries stuffed >> into packages to group things like maybe erlang.bif:link/1. >> >> -Vance > From rvirding@REDACTED Tue Nov 18 02:10:19 2008 From: rvirding@REDACTED (Robert Virding) Date: Tue, 18 Nov 2008 02:10:19 +0100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <20081118005024.GD1809@h216-235-12-168.host.egate.net> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20081118001602.GC1809@h216-235-12-168.host.egate.net> <3dbc6d1c0811171632t369eb208u5bebfd0f2a102af@mail.gmail.com> <20081118005024.GD1809@h216-235-12-168.host.egate.net> Message-ID: <3dbc6d1c0811171710m483e9ffbx35c8a154c370e05d@mail.gmail.com> No way, don't like packages. Robert 2008/11/18 Vance Shipley > On Tue, Nov 18, 2008 at 01:32:17AM +0100, Robert Virding wrote: > } What do you mean by packages? > > The namespace packages. I recall seeing the libraries stuffed > into packages to group things like maybe erlang.bif:link/1. > > -Vance > -------------- next part -------------- An HTML attachment was scrubbed... URL: From vances@REDACTED Tue Nov 18 02:19:53 2008 From: vances@REDACTED (Vance Shipley) Date: Mon, 17 Nov 2008 20:19:53 -0500 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <3dbc6d1c0811171710m483e9ffbx35c8a154c370e05d@mail.gmail.com> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20081118001602.GC1809@h216-235-12-168.host.egate.net> <3dbc6d1c0811171632t369eb208u5bebfd0f2a102af@mail.gmail.com> <20081118005024.GD1809@h216-235-12-168.host.egate.net> <3dbc6d1c0811171710m483e9ffbx35c8a154c370e05d@mail.gmail.com> Message-ID: <20081118011952.GE1809@h216-235-12-168.host.egate.net> On Tue, Nov 18, 2008 at 02:10:19AM +0100, Robert Virding wrote: } No way, don't like packages. Well somebody around here was working on that at some time. -Vance To be clear: http://erlang.org/doc/man/packages.html From rvirding@REDACTED Tue Nov 18 02:22:30 2008 From: rvirding@REDACTED (Robert Virding) Date: Tue, 18 Nov 2008 02:22:30 +0100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <49221856.5070201@bigpond.net.au> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20081118001602.GC1809@h216-235-12-168.host.egate.net> <3dbc6d1c0811171632t369eb208u5bebfd0f2a102af@mail.gmail.com> <20081118005024.GD1809@h216-235-12-168.host.egate.net> <3dbc6d1c0811171710m483e9ffbx35c8a154c370e05d@mail.gmail.com> <49221856.5070201@bigpond.net.au> Message-ID: <3dbc6d1c0811171722l5ee4f016x5e40cf1604031d0d@mail.gmail.com> 2008/11/18 Benjamin Tolputt > > Also, Robert, I was interested in your disagreement with Kenneth (RE: > the need for an Erlang refactor) you said you would put together... is > that still coming? Yes, but it will have to wait until tomorrow, too late now. And I also agreed with him as well. Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: From rvirding@REDACTED Tue Nov 18 02:43:42 2008 From: rvirding@REDACTED (Robert Virding) Date: Tue, 18 Nov 2008 02:43:42 +0100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <492219B5.3020906@bigpond.net.au> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20081118001602.GC1809@h216-235-12-168.host.egate.net> <3dbc6d1c0811171632t369eb208u5bebfd0f2a102af@mail.gmail.com> <20081118005024.GD1809@h216-235-12-168.host.egate.net> <3dbc6d1c0811171710m483e9ffbx35c8a154c370e05d@mail.gmail.com> <49221856.5070201@bigpond.net.au> <3dbc6d1c0811171722l5ee4f016x5e40cf1604031d0d@mail.gmail.com> <492219B5.3020906@bigpond.net.au> Message-ID: <3dbc6d1c0811171743w73bf7280o79f7d3eee9dfacbe@mail.gmail.com> 2008/11/18 Benjamin Tolputt > Robert Virding wrote: > > Yes, but it will have to wait until tomorrow, too late now. And I also > > agreed with him as well. > > Not worried about the delay, just hoping to read it. The fact you agreed > with him on some aspects and not others (as do I) is what intrigues me. > I am curious to know how much consensus there might be on it. Not enough to stop a good fight. :-) Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob@REDACTED Tue Nov 18 02:58:52 2008 From: bob@REDACTED (Bob Ippolito) Date: Mon, 17 Nov 2008 17:58:52 -0800 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <20081118011952.GE1809@h216-235-12-168.host.egate.net> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20081118001602.GC1809@h216-235-12-168.host.egate.net> <3dbc6d1c0811171632t369eb208u5bebfd0f2a102af@mail.gmail.com> <20081118005024.GD1809@h216-235-12-168.host.egate.net> <3dbc6d1c0811171710m483e9ffbx35c8a154c370e05d@mail.gmail.com> <20081118011952.GE1809@h216-235-12-168.host.egate.net> Message-ID: <6a36e7290811171758i53e48c87xff0344ba723f7155@mail.gmail.com> On Mon, Nov 17, 2008 at 5:19 PM, Vance Shipley wrote: > On Tue, Nov 18, 2008 at 02:10:19AM +0100, Robert Virding wrote: > } No way, don't like packages. > > Well somebody around here was working on that at some time. I think the problem is that packages were implemented in an undesirable way. Erlang does have a package system, but AFIAK nobody uses it or likes it. What I don't like about the package system is that any time you use it you need to do a bunch of explicit stuff to use standard modules (e.g. -import(list) or something). -bob From saleyn@REDACTED Tue Nov 18 03:09:43 2008 From: saleyn@REDACTED (Serge Aleynikov) Date: Mon, 17 Nov 2008 21:09:43 -0500 Subject: [erlang-questions] code:get_path() returns badarg In-Reply-To: <95be1d3b0811170720l75db1d7off89a1f7a6e51099@mail.gmail.com> References: <95be1d3b0811170720l75db1d7off89a1f7a6e51099@mail.gmail.com> Message-ID: <492223E7.1080604@gmail.com> Please check the value of environment variable ERL_LIBS. If it's defined but empty or contains a non-existing path, you would get this behavior in versions between R12B and R12B-3. http://www.erlang.org/pipermail/erlang-patches/2008-October/000319.html Serge Vlad Dumitrescu wrote: > Hi! > > I will look at the code in more detail tomorrow, but maybe someone has > the answer already... > > I am calling code:get_path() very early in the startup process and > with R12 it often happens that this call crashes with > {'EXIT',{badarg,[{code_server,call,2},... > > My first inspection leads me to guess that the code server isn't > started properly and the badarg is because the name code_server isn't > registered yet. > > I even added a code:module_info() call earlier, to let the code server > start up properly, but to no avail. I don't know if it's because I > should wait a little longer or there is another explanation. > > The error doesn't happen all the time (actually, I can't reproduce it > myself), but I have many reports from different erlide users. > > Could somebody please guide me from here? > > best regards, > Vlad > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From dave.smith.to@REDACTED Tue Nov 18 03:25:29 2008 From: dave.smith.to@REDACTED (Dave Smith) Date: Mon, 17 Nov 2008 21:25:29 -0500 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <20081118011952.GE1809@h216-235-12-168.host.egate.net> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20081118001602.GC1809@h216-235-12-168.host.egate.net> <3dbc6d1c0811171632t369eb208u5bebfd0f2a102af@mail.gmail.com> <20081118005024.GD1809@h216-235-12-168.host.egate.net> <3dbc6d1c0811171710m483e9ffbx35c8a154c370e05d@mail.gmail.com> <20081118011952.GE1809@h216-235-12-168.host.egate.net> Message-ID: <5ea453f90811171825g3345284ek7c2f31635fdf3b9c@mail.gmail.com> So, what's the status of packages? Robert, Is you're objection to this particular implementation or is there some argument against an hierarchical module namespace in general? 2008/11/17 Vance Shipley > On Tue, Nov 18, 2008 at 02:10:19AM +0100, Robert Virding wrote: > } No way, don't like packages. > > Well somebody around here was working on that at some time. > > -Vance > > To be clear: http://erlang.org/doc/man/packages.html > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dave.smith.to@REDACTED Tue Nov 18 03:44:19 2008 From: dave.smith.to@REDACTED (Dave Smith) Date: Mon, 17 Nov 2008 21:44:19 -0500 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <6a36e7290811171758i53e48c87xff0344ba723f7155@mail.gmail.com> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20081118001602.GC1809@h216-235-12-168.host.egate.net> <3dbc6d1c0811171632t369eb208u5bebfd0f2a102af@mail.gmail.com> <20081118005024.GD1809@h216-235-12-168.host.egate.net> <3dbc6d1c0811171710m483e9ffbx35c8a154c370e05d@mail.gmail.com> <20081118011952.GE1809@h216-235-12-168.host.egate.net> <6a36e7290811171758i53e48c87xff0344ba723f7155@mail.gmail.com> Message-ID: <5ea453f90811171844j3d62d6a6v18d04087809f71a2@mail.gmail.com> 2008/11/17 Bob Ippolito > > > What I don't like about the package system is that any time you use it > you need to do a bunch of explicit stuff to use standard modules (e.g. > -import(list) or something). > I agree with you there. It could have been implemented in such a way that modules in the top level package are implicitly imported. The problem with this is the 'everything' is in the top level package. A better option would be to move all the standard modules under the erlang package (eg. erlang.lists) and have the compiler implicitly import everything under the erlang package. -------------- next part -------------- An HTML attachment was scrubbed... URL: From btolputt@REDACTED Tue Nov 18 02:26:13 2008 From: btolputt@REDACTED (Benjamin Tolputt) Date: Tue, 18 Nov 2008 12:26:13 +1100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <3dbc6d1c0811171722l5ee4f016x5e40cf1604031d0d@mail.gmail.com> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20081118001602.GC1809@h216-235-12-168.host.egate.net> <3dbc6d1c0811171632t369eb208u5bebfd0f2a102af@mail.gmail.com> <20081118005024.GD1809@h216-235-12-168.host.egate.net> <3dbc6d1c0811171710m483e9ffbx35c8a154c370e05d@mail.gmail.com> <49221856.5070201@bigpond.net.au> <3dbc6d1c0811171722l5ee4f016x5e40cf1604031d0d@mail.gmail.com> Message-ID: <492219B5.3020906@bigpond.net.au> Robert Virding wrote: > Yes, but it will have to wait until tomorrow, too late now. And I also > agreed with him as well. Not worried about the delay, just hoping to read it. The fact you agreed with him on some aspects and not others (as do I) is what intrigues me. I am curious to know how much consensus there might be on it. -- Regards, Benjamin Tolputt Analyst Programmer This email and any files transmitted with it are confidential to the intended recipient and may be privileged. If you have received this email inadvertently or you are not the intended recipient, you may not disseminate, distribute, copy or in any way rely on it. Further, you should notify the sender immediately and delete the email from your computer. Whilst we have taken precautions to alert us to the presence of computer viruses, we cannot guarantee that this email and any files transmitted with it are free from such viruses. From saleyn@REDACTED Tue Nov 18 04:01:38 2008 From: saleyn@REDACTED (Serge Aleynikov) Date: Mon, 17 Nov 2008 22:01:38 -0500 Subject: [erlang-questions] Bug in trapexit article "How to use ei ..." In-Reply-To: <20534211.post@talk.nabble.com> References: <20516290.post@talk.nabble.com> <4920E76F.6000009@gmail.com> <20534211.post@talk.nabble.com> Message-ID: <49223012.3000509@gmail.com> Thanks. Not bad for the Sun 10pm code review. ;-) Note that while this code is quite primitive, where it's purpose is to show a simple concept, if you need a more convenient C++ wrapper around ei, you can look at ei++ in this project: http://code.google.com/p/erlexec/source/browse/branches/auto/c_src/ei%2B%2B.h Currently ei::Serializer only has support for marshaling basic types (int, double, string, atom), but it's more convenient for a C++ user then plain ei. Serge Mikl Kurkov wrote: > > Serge Aleynikov-2 wrote: >> Thanks for pointing it out. This code was more-or-less a quick&dirty >> copy/paste from >> http://www.erlang.org/doc/tutorial/erl_interface.html#5.2 that suffers >> from a buffer overrun issue. I posted the corrections that you found. >> > > It seems that you don't update buf_ptr in the new version of read_cmd > function. > Anyway, thanks for this article. It is very helpful and clear. > > Mikl > From yoursurrogategod@REDACTED Tue Nov 18 04:09:43 2008 From: yoursurrogategod@REDACTED (Yves S. Garret) Date: Mon, 17 Nov 2008 19:09:43 -0800 (PST) Subject: [erlang-questions] A good example of design and implementation of a project in Erlang Message-ID: <86e90bf5-5ec0-495c-82f4-22aea3da97e1@v39g2000pro.googlegroups.com> Hi, I was wondering if someone knows of a good open source project that has, generally speaking, good software design, documentation and implementation. A project written in Erlang that makes use of tens of thousands of processes at any one moment (I would very much prefer one written in Erlang as opposed to another language, but that does not exclude projects done in other languages that fit the criteria as well). The reason being is that I would like to endeavor on a project of my own at one point, after gaining some mastery of the language, and appreciate a good template/blueprint to guide me. I initially thought that Yaws would do well. But quickly ruled it out. Despite the fact that it can generate tens of thousands of processes, few of them communicate with each other on a regular basis. It's a web server. It's neat, but just not suitable for my needs. The part of the design that takes into account the intricacies of Erlang where there are tens of thousands (hundreds or millions?) processes is what is most salient for me. --YSG From saleyn@REDACTED Tue Nov 18 04:14:57 2008 From: saleyn@REDACTED (Serge Aleynikov) Date: Mon, 17 Nov 2008 22:14:57 -0500 Subject: [erlang-questions] otp.net Message-ID: <49223331.5060400@gmail.com> I made several bug fixes and enhancements to the otp.net project in jungerl, and would like to find out if this project is being used by others before I commit my updates as not all modifications are backward compatible. We had a discussion with the author (Vlad) and he didn't seem to have objections. The changes are: - More robust error handling - Added delegates for connection state changes - Support for pid monitors - Support for short node names - Optional disabling of local epmd registration - Support for local processing of io_request's - RPC API extended to supply the pid of a local io server mailbox. - Support for IEEE 754 double encoding/decoding Serge From ok@REDACTED Tue Nov 18 04:20:55 2008 From: ok@REDACTED (Richard O'Keefe) Date: Tue, 18 Nov 2008 16:20:55 +1300 Subject: [erlang-questions] conditional expressions In-Reply-To: <8092dc770811141638h2a1bee2av19c04e76ce535992@mail.gmail.com> References: <8092dc770811141638h2a1bee2av19c04e76ce535992@mail.gmail.com> Message-ID: <3521EA45-40CD-442A-9DB2-3C0240BA5A1A@cs.otago.ac.nz> On 15 Nov 2008, at 1:38 pm, damien morton wrote: > I keep wanting to have python-like boolean expression evaluation, in > which a value of nil, 0, an empty list or an empty tuple are > considered to be false. You could do it via a macro that expanded ?PY_OR(e1, e2) to case py_val(e1) of {X} -> X ; false -> e2 end where py_val(undef) -> false; % Closer match for Undef than nil is py_val(0) -> false; py_val(0.0) -> false; py_val([]) -> false; py_val({}) -> false; py_val(false) -> false; py_val(X) -> {X}. However, this really is not very Erlang-like. (For one thing, it's not very Dialyser-friendly.) Lisp had a single value used to represent logical falsehood (NIL), the empty list ('() => NIL), and a three-letter atom ('NIL => NIL). Scheme found it very useful to separate them (#f, '(), and 'NIL are all different in Scheme). Erlang is closer to Scheme here. It may be that you are trying to write Python in Erlang, which isn't the best way to use Erlang. It may also be that you don't have (m)any cases where ALL of the 'false' values listed above are actually possible, just many cases where one of them is possible and you would like to use the same operator for all of them. Well, 'case' is definitely the construct you want. Can you provide some examples? From ok@REDACTED Tue Nov 18 04:24:10 2008 From: ok@REDACTED (Richard O'Keefe) Date: Tue, 18 Nov 2008 16:24:10 +1300 Subject: [erlang-questions] conditional expressions In-Reply-To: <66d1c98f0811141713n6961e091ndcaae79c5cea54f0@mail.gmail.com> References: <8092dc770811141638h2a1bee2av19c04e76ce535992@mail.gmail.com> <66d1c98f0811141713n6961e091ndcaae79c5cea54f0@mail.gmail.com> Message-ID: <5A0DCFB7-B080-4371-9766-1BB58F2FFB4D@cs.otago.ac.nz> On 15 Nov 2008, at 2:13 pm, Roger Critchlow wrote: > I think you're looking for the andalso and orelse operators. You say: > > X = foo() orelse bar(), > > and bar() only gets called if the value of foo() is false. However there is a strong restriction in Erlang that does not exist in Lisp, Scheme, Smalltalk, &c and does not exist in Python. False or 42 => 42 in Python 42 or False => 42 in Python 1 == 2 orelse 42 => ERROR! in Erlang 42 orelse 1 == 2 => ERROR! in Erlang In Erlang, both operands of an andalso or orelse operator must return 'true' or 'false'. I strongly suspect that the OP wants a non-empty list or tuple to count as true, rather than as an error. From saleyn@REDACTED Tue Nov 18 04:38:49 2008 From: saleyn@REDACTED (Serge Aleynikov) Date: Mon, 17 Nov 2008 22:38:49 -0500 Subject: [erlang-questions] conditional expressions In-Reply-To: <5A0DCFB7-B080-4371-9766-1BB58F2FFB4D@cs.otago.ac.nz> References: <8092dc770811141638h2a1bee2av19c04e76ce535992@mail.gmail.com> <66d1c98f0811141713n6961e091ndcaae79c5cea54f0@mail.gmail.com> <5A0DCFB7-B080-4371-9766-1BB58F2FFB4D@cs.otago.ac.nz> Message-ID: <492238C9.60900@gmail.com> Your 'must' statement is not entirely accurate. Consider this: 1 == 2 orelse throw(no_bool_return). Richard O'Keefe wrote: > On 15 Nov 2008, at 2:13 pm, Roger Critchlow wrote: > >> I think you're looking for the andalso and orelse operators. You say: >> >> X = foo() orelse bar(), >> >> and bar() only gets called if the value of foo() is false. > > However there is a strong restriction in Erlang that does not > exist in Lisp, Scheme, Smalltalk, &c and does not exist in > Python. > False or 42 => 42 in Python > 42 or False => 42 in Python > 1 == 2 orelse 42 => ERROR! in Erlang > 42 orelse 1 == 2 => ERROR! in Erlang > > In Erlang, both operands of an andalso or orelse operator > must return 'true' or 'false'. I strongly suspect that the > OP wants a non-empty list or tuple to count as true, rather > than as an error. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From bob@REDACTED Tue Nov 18 04:39:34 2008 From: bob@REDACTED (Bob Ippolito) Date: Mon, 17 Nov 2008 19:39:34 -0800 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <5ea453f90811171844j3d62d6a6v18d04087809f71a2@mail.gmail.com> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20081118001602.GC1809@h216-235-12-168.host.egate.net> <3dbc6d1c0811171632t369eb208u5bebfd0f2a102af@mail.gmail.com> <20081118005024.GD1809@h216-235-12-168.host.egate.net> <3dbc6d1c0811171710m483e9ffbx35c8a154c370e05d@mail.gmail.com> <20081118011952.GE1809@h216-235-12-168.host.egate.net> <6a36e7290811171758i53e48c87xff0344ba723f7155@mail.gmail.com> <5ea453f90811171844j3d62d6a6v18d04087809f71a2@mail.gmail.com> Message-ID: <6a36e7290811171939v5bdbc9bn50aa4bedd4f5501a@mail.gmail.com> On Mon, Nov 17, 2008 at 6:44 PM, Dave Smith wrote: > > > 2008/11/17 Bob Ippolito >> >> What I don't like about the package system is that any time you use it >> you need to do a bunch of explicit stuff to use standard modules (e.g. >> -import(list) or something). > > I agree with you there. It could have been implemented in such a way that > modules in the top level package are implicitly imported. The problem with > this is the 'everything' is in the top level package. A better option would > be to move all the standard modules under the erlang package (eg. > erlang.lists) and have the compiler implicitly import everything under the > erlang package. Eh. The easier way would be to assume that all module usage is absolute, unless you explicitly ask for a relative module. -bob From btolputt@REDACTED Tue Nov 18 02:20:22 2008 From: btolputt@REDACTED (Benjamin Tolputt) Date: Tue, 18 Nov 2008 12:20:22 +1100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <3dbc6d1c0811171710m483e9ffbx35c8a154c370e05d@mail.gmail.com> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20081118001602.GC1809@h216-235-12-168.host.egate.net> <3dbc6d1c0811171632t369eb208u5bebfd0f2a102af@mail.gmail.com> <20081118005024.GD1809@h216-235-12-168.host.egate.net> <3dbc6d1c0811171710m483e9ffbx35c8a154c370e05d@mail.gmail.com> Message-ID: <49221856.5070201@bigpond.net.au> Robert Virding wrote: > No way, don't like packages. Yeah, I remember the discussions on it. *laugh* In the scheme of all things Erlang though, I wouldn't classify it as something stopping adoption or causing confusion. I like the "concept" of packages or, more specifically, being able to write code such as "namespace1.module2:foo(bar)" without having to quote the atoms. But as far as next(erlang) is concerned, it could be on the back-burner compared to inconsistent interfaces and the like. Also, Robert, I was interested in your disagreement with Kenneth (RE: the need for an Erlang refactor) you said you would put together... is that still coming? -- Regards, Benjamin Tolputt Analyst Programmer This email and any files transmitted with it are confidential to the intended recipient and may be privileged. If you have received this email inadvertently or you are not the intended recipient, you may not disseminate, distribute, copy or in any way rely on it. Further, you should notify the sender immediately and delete the email from your computer. Whilst we have taken precautions to alert us to the presence of computer viruses, we cannot guarantee that this email and any files transmitted with it are free from such viruses. From zerthurd@REDACTED Tue Nov 18 05:56:13 2008 From: zerthurd@REDACTED (Maxim Treskin) Date: Tue, 18 Nov 2008 10:56:13 +0600 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <6a36e7290811171939v5bdbc9bn50aa4bedd4f5501a@mail.gmail.com> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20081118001602.GC1809@h216-235-12-168.host.egate.net> <3dbc6d1c0811171632t369eb208u5bebfd0f2a102af@mail.gmail.com> <20081118005024.GD1809@h216-235-12-168.host.egate.net> <3dbc6d1c0811171710m483e9ffbx35c8a154c370e05d@mail.gmail.com> <20081118011952.GE1809@h216-235-12-168.host.egate.net> <6a36e7290811171758i53e48c87xff0344ba723f7155@mail.gmail.com> <5ea453f90811171844j3d62d6a6v18d04087809f71a2@mail.gmail.com> <6a36e7290811171939v5bdbc9bn50aa4bedd4f5501a@mail.gmail.com> Message-ID: I think deep hierarchies of modules is very bad idea for usage in Erlang. The main approach in programming on Erlang is bunch of well defined isolated applications running on node(s), i.e. yaws+mnesia+kernel for web and so on. Each application contains number of modules and names and functions of these modules is unique through whole application. Moreover these names is very simple due to deep hierarhies of module absence in Erlang. I strongly against of functions like web.common.http.uri.util:escape/1. -- Maxim Treskin -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf@REDACTED Tue Nov 18 07:13:17 2008 From: ulf@REDACTED (Ulf Wiger) Date: Tue, 18 Nov 2008 07:13:17 +0100 Subject: [erlang-questions] A good example of design and implementation of a project in Erlang In-Reply-To: <86e90bf5-5ec0-495c-82f4-22aea3da97e1@v39g2000pro.googlegroups.com> References: <86e90bf5-5ec0-495c-82f4-22aea3da97e1@v39g2000pro.googlegroups.com> Message-ID: <8209f740811172213t416f8136yebf8db14091c9e59@mail.gmail.com> How about http://www.stacken.kth.se/project/yxa ? BR, Ulf W 2008/11/18, Yves S. Garret : > Hi, > > I was wondering if someone knows of a good open source project that > has, generally speaking, good software design, documentation and > implementation. A project written in Erlang that makes use of tens of > thousands of processes at any one moment (I would very much prefer one > written in Erlang as opposed to another language, but that does not > exclude projects done in other languages that fit the criteria as > well). The reason being is that I would like to endeavor on a project > of my own at one point, after gaining some mastery of the language, > and appreciate a good template/blueprint to guide me. > > I initially thought that Yaws would do well. But quickly ruled it > out. Despite the fact that it can generate tens of thousands of > processes, few of them communicate with each other on a regular basis. > It's a web server. It's neat, but just not suitable for my needs. The > part of the design that takes into account the intricacies of Erlang > where there are tens of thousands (hundreds or millions?) processes is > what is most salient for me. > > --YSG > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From dave.smith.to@REDACTED Tue Nov 18 07:36:43 2008 From: dave.smith.to@REDACTED (Dave Smith) Date: Tue, 18 Nov 2008 01:36:43 -0500 Subject: [erlang-questions] Erlang 3000? In-Reply-To: References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20081118001602.GC1809@h216-235-12-168.host.egate.net> <3dbc6d1c0811171632t369eb208u5bebfd0f2a102af@mail.gmail.com> <20081118005024.GD1809@h216-235-12-168.host.egate.net> <3dbc6d1c0811171710m483e9ffbx35c8a154c370e05d@mail.gmail.com> <20081118011952.GE1809@h216-235-12-168.host.egate.net> <6a36e7290811171758i53e48c87xff0344ba723f7155@mail.gmail.com> <5ea453f90811171844j3d62d6a6v18d04087809f71a2@mail.gmail.com> <6a36e7290811171939v5bdbc9bn50aa4bedd4f5501a@mail.gmail.com> Message-ID: <5ea453f90811172236w1ed5ba7w743c461f939c4d26@mail.gmail.com> Applications are not language constructs, but it has become convention to name module with the application name prepended with and '_' separator. This is a crude namespace which, in most cases, is fine. A larger application such as snmp, could benefit from packages, imo. How many times is a call to snmp_generic made from other modules in the snmp application? (154 times). If packages were use, the module snmp.generic could be called from snmp.standard_mib without needing to fully qualify the name. The package hierarchy does not need to be deep. 2008/11/17 Maxim Treskin > I think deep hierarchies of modules is very bad idea for usage in Erlang. > > The main approach in programming on Erlang is bunch of well defined > isolated applications running on node(s), i.e. yaws+mnesia+kernel for web > and so on. Each application contains number of modules and names and > functions of these modules is unique through whole application. Moreover > these names is very simple due to deep hierarhies of module absence in > Erlang. > I strongly against of functions like web.common.http.uri.util:escape/1. > > -- > Maxim Treskin > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bengt.kleberg@REDACTED Tue Nov 18 08:05:15 2008 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Tue, 18 Nov 2008 08:05:15 +0100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <5ea453f90811171825g3345284ek7c2f31635fdf3b9c@mail.gmail.com> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20081118001602.GC1809@h216-235-12-168.host.egate.net> <3dbc6d1c0811171632t369eb208u5bebfd0f2a102af@mail.gmail.com> <20081118005024.GD1809@h216-235-12-168.host.egate.net> <3dbc6d1c0811171710m483e9ffbx35c8a154c370e05d@mail.gmail.com> <20081118011952.GE1809@h216-235-12-168.host.egate.net> <5ea453f90811171825g3345284ek7c2f31635fdf3b9c@mail.gmail.com> Message-ID: <4922692B.3030506@ericsson.com> Greetings, One good (IMHO) critique of packages, as they are currently implemented, is found here: http://www.erlang.org/pipermail/erlang-questions/2006-November/023782.html On the other hand, packages, even as they are currently implemented, would make it possible to rewrite the libraries. That could also be done with the '.' replaced with '_' so it is not a very good argument. But I really would like to rewrite them. 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." On 2008-11-18 03:25, Dave Smith wrote: > > So, what's the status of packages? > > Robert, Is you're objection to this particular implementation or is > there some argument against an hierarchical module namespace in general? > > 2008/11/17 Vance Shipley > > > On Tue, Nov 18, 2008 at 02:10:19AM +0100, Robert Virding wrote: > } No way, don't like packages. > > Well somebody around here was working on that at some time. > > -Vance > > To be clear: http://erlang.org/doc/man/packages.html > _______________________________________________ > 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 vladdu55@REDACTED Tue Nov 18 09:29:52 2008 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Tue, 18 Nov 2008 09:29:52 +0100 Subject: [erlang-questions] code:get_path() returns badarg In-Reply-To: <492223E7.1080604@gmail.com> References: <95be1d3b0811170720l75db1d7off89a1f7a6e51099@mail.gmail.com> <492223E7.1080604@gmail.com> Message-ID: <95be1d3b0811180029k104e215fte602e5f119259a90@mail.gmail.com> On Tue, Nov 18, 2008 at 03:09, Serge Aleynikov wrote: > Please check the value of environment variable ERL_LIBS. If it's defined > but empty or contains a non-existing path, you would get this behavior in > versions between R12B and R12B-3. > > http://www.erlang.org/pipermail/erlang-patches/2008-October/000319.html Hi Serge, Thank you for the tip, but I don't think it's that. We are using R12B-4 and this problem only happens when starting the Erlang runtime from within Java, where I send the code:get_path() request right away. For the time being I will just try to wait until there is a process registered as "code_server", but I don't like that solution. The ideal way would be to have some kind of notification mechanism (which could be used for other things, too). best regards, Vlad From btolputt@REDACTED Tue Nov 18 03:48:25 2008 From: btolputt@REDACTED (Benjamin Tolputt) Date: Tue, 18 Nov 2008 13:48:25 +1100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <6a36e7290811171758i53e48c87xff0344ba723f7155@mail.gmail.com> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20081118001602.GC1809@h216-235-12-168.host.egate.net> <3dbc6d1c0811171632t369eb208u5bebfd0f2a102af@mail.gmail.com> <20081118005024.GD1809@h216-235-12-168.host.egate.net> <3dbc6d1c0811171710m483e9ffbx35c8a154c370e05d@mail.gmail.com> <20081118011952.GE1809@h216-235-12-168.host.egate.net> <6a36e7290811171758i53e48c87xff0344ba723f7155@mail.gmail.com> Message-ID: <49222CF9.9030308@bigpond.net.au> Bob Ippolito wrote: > I think the problem is that packages were implemented in an > undesirable way. Erlang does have a package system, but AFIAK nobody > uses it or likes it. > > What I don't like about the package system is that any time you use it > you need to do a bunch of explicit stuff to use standard modules (e.g. > -import(list) or something). > For me it would be enough if I could do the following: ------------------ %% File: namespace1.module1.erl -module(namespace1.module1). %% Namespace for this file - probable not required if I can simply name the file appropriately -namespace(default, namespace1). -namespace(using, namespace1.module2). -export([foo/0]). foo()-> module2:bar(), %% This will actually use namespace1.module2:bar() ok. ------------------ %% File: namespace1.module2.erl -module(namespace1.module2). %% Namespace for this file - probable not required if the compiler can work it out from filename -namespace(default, namespace1). -export([bar/0]). bar()-> file:get_cwd(). %% As there is no "namespace1.file.erl" module, this will use the standard file:get_cwd() fun ------------------ This would give standard behaviour for modules not within the namespace and for where the code never uses the "-namespace(...)" (such as all existing code). >From the look of it - it could be implemented simply by replacing any occurence of "module2" to "namespace1.module2" in the compilation phase. There are issues with the passing around of atoms though (for example, say I pass the atom tuple {module2, bar} to code outside the namespace and it then uses it to call module2:bar - what happens?). There is a bit of thought needed before this would go ahead, but I don't think the parties most needed in the discussions are interested in implementing this at the moment. -- Regards, Benjamin Tolputt Analyst Programmer This email and any files transmitted with it are confidential to the intended recipient and may be privileged. If you have received this email inadvertently or you are not the intended recipient, you may not disseminate, distribute, copy or in any way rely on it. Further, you should notify the sender immediately and delete the email from your computer. Whilst we have taken precautions to alert us to the presence of computer viruses, we cannot guarantee that this email and any files transmitted with it are free from such viruses. From erlang@REDACTED Tue Nov 18 09:58:56 2008 From: erlang@REDACTED (Joe Armstrong) Date: Tue, 18 Nov 2008 09:58:56 +0100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <4922692B.3030506@ericsson.com> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20081118001602.GC1809@h216-235-12-168.host.egate.net> <3dbc6d1c0811171632t369eb208u5bebfd0f2a102af@mail.gmail.com> <20081118005024.GD1809@h216-235-12-168.host.egate.net> <3dbc6d1c0811171710m483e9ffbx35c8a154c370e05d@mail.gmail.com> <20081118011952.GE1809@h216-235-12-168.host.egate.net> <5ea453f90811171825g3345284ek7c2f31635fdf3b9c@mail.gmail.com> <4922692B.3030506@ericsson.com> Message-ID: <9b08084c0811180058x227977c6x2446aa3a99ed2112@mail.gmail.com> let's throw in my 5 cents ... It is (of course) highly desirable to have a large set of libraries that are written in a consistent and predictable manner - the problem is how to we get there? I have actually been building a library that one day I hope to publish - it's got 70 modules in it so far ... Now there are some problems in building a large library. For reasons of consistency all the library modules have to follow some common programming rules - these rules have to encapsulate what we think is good style and best practise (whatever that means) Let's now imagine what happens when you build a large library. - you write the first module - no problems - you write the second module - ... - ... - you write the N'th module now you realize the design of some functions you want to call in module 6 was wrong. What do you do? - stop writing module N and go back to 6. In re-writing 6 you discover that 2 was wrong, what do you do? stop writing module 6 and go back to 2 ???? This is bad enough when one person writes all the code but when somebody else wrote the earlier code the problem gets *much* worse. - you've been a bit lazy with the documentation so you decide to write some decent documentation. When you get started you realise that what you are describing is a mess - it would be much easier if it had been written "like this" so you write the documentation describing what the code should have been - then go back and hack the code. - You've written the code but not much meta data. The meta data is the stuff describing the code (the type signatures, documentation etc.) - when the code base is small there is no problem (put it all in one directory) - as it grows you wish you'd organised it better so you put it in several directories. As it gets very large you realise that putting it into several directories makes doesn't help - there are so many directories that you can't find the code anyway - the only way to find things is to hope that Google has indexed it. - you wish you had added more meta data to your code (to allow accurate indexing) *hypothesis* as code bases get larger the most important thing is the quality of the meta data - not the data. The meta data determines our ability to find stuff - if we can't find stuff it does not matter how good it is. So how do I organise my 70 module library? - all code in one directory - whenever I find an inconsistency in an earlier module I go back and rewrite the original code (and everything that calls it) One thing I find *very* useful is to put all small pure functions that are generally useful in the *same* module. << There is a problem - functions have to belong to modules - but there are a *lot* of very small pure functions that can't really be said to belong to any particular module solution: Put them all in lib_extra.>> << I also use inheritance (If I don't want to touch an existing module) I write. -module(xx). -inherit(old_mod). -export([....]) This is just a simple parse transform, it makes stub functions for all the exported functions in old_mod that are not in xx. if xx has a new version of a routine in old_mod it will override that function. Why do it like this? - because I may not want to modify old_mod (if I have distributed it). >> At the end of the day I believe the meta data to be far more important than the code. getting the APIs right is the difficult bit. If anybody else tells me "I have to read the code to see what it does" I will scream - whenever I read code the following happens: - I don't understand it - I start to understand it - I get an overwhelming desire to rewrite it Reading code to discover what it does is a sign of incompleteness. A program is not complete until it has passed all its tests and has good documentation. If you have to read the code to figure out what the program does then the project is incomplete. We should really have a programming rule. The APIs and code should be in two *different* files - the reviewers should not be allowed to read the code (This is a *very good reason* why code and documentation should not be allowed in the same file) (( If code and documentation are allowed in the same file, then the person editing the documentation might accidentally read the code and thus describe the code *and not the interface* (which is a completely different thing)) Flame on: reading the code tells you what the code does (if you can understand it - but not "what it is *supposed* to do". So before we rush off and write the ultimate set of modules - can we try to write just ONE module in as beautiful way as possible. This module could serve as the great progenitor - it should be well written, well documented, with well thought-out meta data. *I know of no such module* (and in case you were wondering, my 70 module library is *not* beautifully annotated with meta-data). There is also the problem of style and taste - personally I favor the "one author many critical eyes" approach. When my Erlang book went to beta I got thousands of eyes staring at every line I'd written - this feedback was fantastic (thanks everybody) and significantly improved the quality. I don't believe in a group of people "voting" for features in code - But I do believe in readers and writers. Few writers of code (who make the decisions) but many readers. If we set this thong up I will donate parts of my library to the project - I've written a new XML thing that is rather pretty (I think) - it lacks test cases (because it's right :-) and meta data (because I'm lazy) and documentation (because we don't have a good documentation system in place) I think it would be great to set up an infrastructure for writing good quality community code - the things we have to setup are: - programming rules - review process - distribution process - production process We need methods for producing drop-dead-beautiful documentation (in PDF, HTML, ...) - think "book quality" We need an agreement on meta data. We need to an agreement on the distribution process. We need an infrastructure. The genius of the Wikipedia is that it is an organisational form that allows a lot of people to contribute by doing a little. Correcting a spelling mistake, asking a question, replying to a question has enormous power when done by hundreds or thousands of people. So here we have it - lots of jobs to be done. Me, I can author code, if somebody else can deign and host a web site with SW support for the review process it would be great. /Joe Armstrong On Tue, Nov 18, 2008 at 8:05 AM, Bengt Kleberg wrote: > Greetings, > > One good (IMHO) critique of packages, as they are currently implemented, > is found here: > http://www.erlang.org/pipermail/erlang-questions/2006-November/023782.html > > On the other hand, packages, even as they are currently implemented, > would make it possible to rewrite the libraries. That could also be done > with the '.' replaced with '_' so it is not a very good argument. But I > really would like to rewrite them. > > > 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." > > > On 2008-11-18 03:25, Dave Smith wrote: >> >> So, what's the status of packages? >> >> Robert, Is you're objection to this particular implementation or is >> there some argument against an hierarchical module namespace in general? >> >> 2008/11/17 Vance Shipley > >> >> On Tue, Nov 18, 2008 at 02:10:19AM +0100, Robert Virding wrote: >> } No way, don't like packages. >> >> Well somebody around here was working on that at some time. >> >> -Vance >> >> To be clear: http://erlang.org/doc/man/packages.html >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> >> >> >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From vladdu55@REDACTED Tue Nov 18 12:15:44 2008 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Tue, 18 Nov 2008 12:15:44 +0100 Subject: [erlang-questions] R12 connection problems from Java Message-ID: <95be1d3b0811180315j78fa76dex71ca9a95df00d962@mail.gmail.com> Hi! I wonder if anyone has seen this problem before: from Java we start an erlang runtime and sit in a loop, calling ping, until it responds. I have registered a NodeStatus instance that receives messages related to remote nodes. It correctly prints a IOException for the period until the erlang node responds. The problem is that sometimes, for some users, these messages are followed by OtpAuthExceptions. Restarting usually helps, so it's not a persistent problem (like having the wrong cookie), but it may happen again later. This has been seen only with R12B (I think R12B-4), R11 doesn't act the same way. I couldn't debug this situation because it never happened to me. Anyone has any hint about what happens? best regards, Vlad From russell.brown@REDACTED Tue Nov 18 13:31:32 2008 From: russell.brown@REDACTED (Russell Brown) Date: Tue, 18 Nov 2008 12:31:32 +0000 Subject: [erlang-questions] Bar Camp Sheffield: any expert free to lead a session? In-Reply-To: <95be1d3b0811180315j78fa76dex71ca9a95df00d962@mail.gmail.com> References: <95be1d3b0811180315j78fa76dex71ca9a95df00d962@mail.gmail.com> Message-ID: <4922B5A4.5000306@mac.com> Hi All, I have registered for Sheffield Bar Camp (Sheffield is an industrial city in the North of the UK). There seems to be an appetite for an Erlang session but no local expertise. Does anyone on this list have the time, skills and location to lead a session on anything at all? More details here http://barcampsheffield.net/ and here http://talk.barcampsheffield.net/index.php/topic,39.0.html. Cheers Russell From vances@REDACTED Tue Nov 18 19:28:22 2008 From: vances@REDACTED (Vance Shipley) Date: Tue, 18 Nov 2008 13:28:22 -0500 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <20081118001602.GC1809@h216-235-12-168.host.egate.net> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20081118001602.GC1809@h216-235-12-168.host.egate.net> Message-ID: <20081118182822.GG1809@h216-235-12-168.host.egate.net> On Mon, Nov 17, 2008 at 07:16:03PM -0500, Vance Shipley wrote: } What ever happened to the initiative to put kernel and stdlib } into packages? That seemed like an interesting branch. OK, that recollection was driving me nuts so I tried to find where I had gotten that impression and I found it right in the Erlang/OTP distribution. erts/emulator/beam/bif.tab: [...] # Add new BIFs to the end of the file. Do not bother adding a "packaged # BIF name" # (such as 'erl.lang.number'); if/when packages will be supported we # will add # all those names. [...] bif erlang:binary_to_term/1 bif 'erl.lang.binary':to_term/1 ebif_binary_to_term_1 Apparently some folks in the group thought packages might find legs at one point. -Vance From klacke@REDACTED Tue Nov 18 20:47:31 2008 From: klacke@REDACTED (Claes Wikstrom) Date: Tue, 18 Nov 2008 20:47:31 +0100 Subject: [erlang-questions] Fwd: Report errors when using "-detached" option In-Reply-To: <3FD73867-982C-44AB-BD2D-3CAA07636040@gmail.com> References: <20081112224818.GE9968@delora.autosys.us> <491D7BA2.4000704@hyber.org> <491D8649.2020701@niclux.org> <3FD73867-982C-44AB-BD2D-3CAA07636040@gmail.com> Message-ID: <49231BD3.6080507@hyber.org> ERLANG wrote: > Hi Nicolas, > >>>> This is indeed a real problem. If daemon startup fails, you >>>> typically >>>> want to indicate that through a call to exit(error_code) so that the >>>> invoker can check $? >>>> >>> Hmmm. Calling "exit(error_code)" isn't reported to the invoker. >>> So $? always equals to 0. >>> >>> Is this an expected behaviour of calling "exit(error_code)" when >>> using >>> "-detached" flag. >>> >> halt(error_code) works. > > No, It doesn't. > Yes it does, [klacke@REDACTED]~ > erl Erlang (BEAM) emulator version 5.6.5 [source] [smp:2] [async-threads:0] [kernel-poll:false] Eshell V5.6.5 (abort with ^G) 1> halt(77). [klacke@REDACTED]~ > echo $? 77 But that's not the point. What's needed is to fork(), let the new code run for a while and check config/whatever, if all is well it calls foo:bar(ok) and the invoker eventually gets a status code 0, whereas if the forked process (beam) calls foo:bar({error, Code}) the invoker of erl -detached2 ... gets Code in the UNIX shell /klacke From ok@REDACTED Tue Nov 18 22:48:14 2008 From: ok@REDACTED (Richard O'Keefe) Date: Wed, 19 Nov 2008 10:48:14 +1300 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <20081118005024.GD1809@h216-235-12-168.host.egate.net> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20081118001602.GC1809@h216-235-12-168.host.egate.net> <3dbc6d1c0811171632t369eb208u5bebfd0f2a102af@mail.gmail.com> <20081118005024.GD1809@h216-235-12-168.host.egate.net> Message-ID: On 18 Nov 2008, at 1:50 pm, Vance Shipley wrote: > The namespace packages. I recall seeing the libraries stuffed > into packages to group things like maybe erlang.bif:link/1. There are several reasons why I don't want anything like that to happen. First, we do not yet have a reasonable package system to put things into. We have a rather pointless and confusing 'flat namespace with dots in it' scheme, but it has problems and limitations which have been gone over in the mailing list several times. Second, be careful what you wish for. You might get it! I'm reminded of Piet Hein's THE OPPOSITE VIEW For many system shoppers it's a good-for-nothing system that classifies as opposites stupidity and wisdom because by logic-choppers it's accepted with avidity: stupidity's true opposite's the opposite stupidity. "The opposite stupidity" to a completely packageless system is something like the current Haskell libraries, with their hierarchical name spaces. A single conceptual unit in Haskell is these days typically broken down into three or four modules and you see stuff like this (taken from real Haskell code): import qualified Data.ByteString as BS import qualified Data.ByteString.Internal as BS import qualified Data.ByteString.Unsafe as BS These days I am seeing Haskell code with huge long lists of imports that could have been shorter if the fashion hadn't been for vast numbers of micro-packages. Of course developing some feature as a cluster of modules makes a great deal of sense, but clients should only have to deal with a single fa?ade module if at all possible. In this case, breaking up the 'erlang' module appears to offer clients no advantages. From ok@REDACTED Tue Nov 18 22:52:24 2008 From: ok@REDACTED (Richard O'Keefe) Date: Wed, 19 Nov 2008 10:52:24 +1300 Subject: [erlang-questions] conditional expressions In-Reply-To: <492238C9.60900@gmail.com> References: <8092dc770811141638h2a1bee2av19c04e76ce535992@mail.gmail.com> <66d1c98f0811141713n6961e091ndcaae79c5cea54f0@mail.gmail.com> <5A0DCFB7-B080-4371-9766-1BB58F2FFB4D@cs.otago.ac.nz> <492238C9.60900@gmail.com> Message-ID: <86BD4040-5B68-44A3-A689-CE62AB0880CC@cs.otago.ac.nz> On 18 Nov 2008, at 4:38 pm, Serge Aleynikov wrote: > Your 'must' statement is not entirely accurate. Was there any doubt about what I meant? Let's try again: both 'andalso' and 'orelse' in Erlang have the following properties: the first operand must either return 'true' or 'false' or raise an exception; the second operand, if executed, must either return 'true' or 'false' or raise an exception; the Dialyzer will complain if either operand looks as if it will return something other than 'false' or 'true'; and above all: you CANNOT use them to get the same effect as Lisp's (OR - -) and (AND - -) or Python's similar operators, which allow a normal result from the second operand to be anything at all. I have in fact complained about this, not because I particularly want non-Boolean results from these operators, but because the code that's inserted to check makes them non-tail-recursive. From ok@REDACTED Tue Nov 18 22:57:16 2008 From: ok@REDACTED (Richard O'Keefe) Date: Wed, 19 Nov 2008 10:57:16 +1300 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <5ea453f90811172236w1ed5ba7w743c461f939c4d26@mail.gmail.com> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20081118001602.GC1809@h216-235-12-168.host.egate.net> <3dbc6d1c0811171632t369eb208u5bebfd0f2a102af@mail.gmail.com> <20081118005024.GD1809@h216-235-12-168.host.egate.net> <3dbc6d1c0811171710m483e9ffbx35c8a154c370e05d@mail.gmail.com> <20081118011952.GE1809@h216-235-12-168.host.egate.net> <6a36e7290811171758i53e48c87xff0344ba723f7155@mail.gmail.com> <5ea453f90811171844j3d62d6a6v18d04087809f71a2@mail.gmail.com> <6a36e7290811171939v5bdbc9bn50aa4bedd4f5501a@mail.gmail.com> <5ea453f90811172236w1ed5ba7w743c461f939c4d26@mail.gmail.com> Message-ID: On 18 Nov 2008, at 7:36 pm, Dave Smith wrote: > The package hierarchy does not need to be deep. This is perfectly true. But if the Java and Haskell experiences are anything to go by, it WILL become deep whether it needs to or not. We can confidently expect people experienced in Java to continue using Java naming practices in Erlang. (Heck, haven't we already seen enough pointlessly ugly baStudlyCaps trickling into Erlang like pus from an Erebus-sized boil?) From dmorton@REDACTED Tue Nov 18 23:00:38 2008 From: dmorton@REDACTED (damien morton) Date: Wed, 19 Nov 2008 09:00:38 +1100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20081118005024.GD1809@h216-235-12-168.host.egate.net> <3dbc6d1c0811171710m483e9ffbx35c8a154c370e05d@mail.gmail.com> <20081118011952.GE1809@h216-235-12-168.host.egate.net> <6a36e7290811171758i53e48c87xff0344ba723f7155@mail.gmail.com> <5ea453f90811171844j3d62d6a6v18d04087809f71a2@mail.gmail.com> <6a36e7290811171939v5bdbc9bn50aa4bedd4f5501a@mail.gmail.com> <5ea453f90811172236w1ed5ba7w743c461f939c4d26@mail.gmail.com> Message-ID: <8092dc770811181400h2f241a1fu9336c9582cbfe61a@mail.gmail.com> So why not restrict the package hierarchy to two levels. package.module:function On Wed, Nov 19, 2008 at 8:57 AM, Richard O'Keefe wrote: > > On 18 Nov 2008, at 7:36 pm, Dave Smith wrote: >> The package hierarchy does not need to be deep. > > This is perfectly true. But if the Java and Haskell experiences > are anything to go by, it WILL become deep whether it needs to > or not. We can confidently expect people experienced in Java to > continue using Java naming practices in Erlang. (Heck, haven't > we already seen enough pointlessly ugly baStudlyCaps trickling > into Erlang like pus from an Erebus-sized boil?) > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From ok@REDACTED Tue Nov 18 23:18:10 2008 From: ok@REDACTED (Richard O'Keefe) Date: Wed, 19 Nov 2008 11:18:10 +1300 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <3dbc6d1c0811171305n38c27ab1kf66ffa1fa670ffb1@mail.gmail.com> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <3dbc6d1c0811171305n38c27ab1kf66ffa1fa670ffb1@mail.gmail.com> Message-ID: <78BB90AC-2B68-44F2-8D2E-58C31D5A4106@cs.otago.ac.nz> On 18 Nov 2008, at 10:05 am, Robert Virding wrote: > Yes, a built-in lightweight form of dictionaries would be nice, > especially if you can match on them. Something like Joe's structs or > ROK's frames. However, I do not really see them as a replacement for > the existing tables as I don't think you can get them both > lightweight and able to efficiently handle large amounts of data. 100% agreement from me on that one. Something that can act as a credible replacement for -record has to be as lightweight as it can be made. I now have a design for a 'micro-Erlang' and part of an implementation. I can happily say that it can be very lightweight indeed. Don't hold your breath waiting for it to be finished, though... The design does _not_ scale to large numbers of elements. I'm intrigued by Joe's new library and would be interested to hear more about it. From masklinn@REDACTED Tue Nov 18 23:20:29 2008 From: masklinn@REDACTED (Masklinn) Date: Tue, 18 Nov 2008 23:20:29 +0100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20081118001602.GC1809@h216-235-12-168.host.egate.net> <3dbc6d1c0811171632t369eb208u5bebfd0f2a102af@mail.gmail.com> <20081118005024.GD1809@h216-235-12-168.host.egate.net> <3dbc6d1c0811171710m483e9ffbx35c8a154c370e05d@mail.gmail.com> <20081118011952.GE1809@h216-235-12-168.host.egate.net> <6a36e7290811171758i53e48c87xff0344ba723f7155@mail.gmail.com> <5ea453f90811171844j3d62d6a6v18d04087809f71a2@mail.gmail.com> <6a36e7290811171939v5bdbc9bn50aa4bedd4f5501a@mail.gmail.com> <5ea453f90811172236w1ed5ba7w743c461f939c4d26@mail.gmail.com> Message-ID: On 18 nov. 08, at 22:57, "Richard O'Keefe" wrote: > > On 18 Nov 2008, at 7:36 pm, Dave Smith wrote: >> The package hierarchy does not need to be deep. > > This is perfectly true. But if the Java and Haskell experiences > are anything to go by, it WILL become deep whether it needs to > or not. Python also has arbitrarily nested package, but it doesn't seem to have that issue maybe due to it's direct physical mapping and importing flexibility (especially in top level packages). And although it's been slightly revised in 3000 and some people find __init__.py to be a kludge I find the system pleasant to work with. A sane (= not too deeply nested) example set by the standard library might also help (the lower nesting of the java stl is already 3 levels or so...) From dizzyd@REDACTED Wed Nov 19 00:00:27 2008 From: dizzyd@REDACTED (Dave Smith) Date: Tue, 18 Nov 2008 16:00:27 -0700 Subject: [erlang-questions] simple_one_for_one supervisor and code_change/3 Message-ID: Hi all... I've run into some strange behaviour when doing a hot-upgrade with a simple_one_for_one supervisor. Basically, I'm using {update, MyModule, {advanced, []}} in my .appup script so that MyModule will get a callback via code_upgrade/3. This has worked fine for me in the past (on other modules), so I'm reasonably sure that this much is right. The only difference I can identify with MyModule is that it is running as a "temporary" process under a simple_one_for_one supervisor. In this situation, it seems that release_handler_1 is unable to locate these instances of MyModule and so it never gets suspended or invoked via code_change/3. Has anyone else seen this behaviour? Am I just doing something stupid? :) Thanks, D. From tony@REDACTED Wed Nov 19 00:41:27 2008 From: tony@REDACTED (Tony Arcieri) Date: Tue, 18 Nov 2008 16:41:27 -0700 Subject: [erlang-questions] Why can't HiPE inline functions across modules? Message-ID: I've read that HiPE can't inline functions across modules. Is this merely an implementation issue of HiPE, or is there some intractable problem I'm missing? People typically bring up code change as the reason, however I don't see why HiPE couldn't walk the graph of modules for which inlining has been performed during a code change and deoptimize them all back to their original state, then start all inlining for these modules over from scratch again. Is there an intracticble problem I'm missing, or is cross-module inlining a feature that should appear on a HiPE wishlist? -- Tony Arcieri medioh.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From kostis@REDACTED Wed Nov 19 01:07:07 2008 From: kostis@REDACTED (Kostis Sagonas) Date: Wed, 19 Nov 2008 02:07:07 +0200 Subject: [erlang-questions] Why can't HiPE inline functions across modules? In-Reply-To: References: Message-ID: <492358AB.8040306@cs.ntua.gr> Tony Arcieri wrote: > I've read that HiPE can't inline functions across modules. Is this > merely an implementation issue of HiPE, or is there some intractable > problem I'm missing? None of the two. The semantics of Erlang dictates that module qualified calls go via the module/function look up table to see if a module update has been performed. That's how BEAM does it and it seemed natural to us that HiPE would also do the same thing. > People typically bring up code change as the reason, however I don't see > why HiPE couldn't walk the graph of modules for which inlining has been > performed during a code change and deoptimize them all back to their > original state, then start all inlining for these modules over from > scratch again. Well, provided you also come up with some other (preferably cheap) way of checking during execution that some /other/ module than the one under execution in has been updated, you can of course do what you suggest. Please send us the patch for it. Looking forward! Kostis PS. Oh, please do not forget to also handle that your code generates the same exceptions (and stack traces) as BEAM because otherwise some users might not like seeing different results than BEAM when running native code. But of course that's also not an intractable problem either ;-) From rvirding@REDACTED Wed Nov 19 03:40:23 2008 From: rvirding@REDACTED (Robert Virding) Date: Wed, 19 Nov 2008 03:40:23 +0100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> Message-ID: <3dbc6d1c0811181840h729f33ecs3d8c0e4f6b3006cf@mail.gmail.com> Yes, I agree with you, but. While it is perfectly true that more open source components and killer apps, or least working apps, would definitely help, I think you fail to realise the negative impact things like messy libraries and blogs about it can have. While I know that most of the libraries actually are quite good in spite of their APIs and that the erlang VM is very good and tested and robust it does not look like this for many people. Unless they take the time to study and test the system properly they may be scared off by what they perceive to be a sloppy and hastily put together system. Especially if they have read the same thing in some blogs. Therefore I think it is definitely worth redoing and cleaning up many of the libraries. Also we have against us that we don't run on the JVM, which I hold to be a real benefit of course. :-) Think of a world without last-call optimisation? I am less worried about splitting the erlang community as I don't think that it will happen. It may be a major change but it will never be something that just pops out of the blue so I assume people will adjust and appreciate the improvements. One thing we have to do to help the community is to make a proper language spec and rationale so that people can really know what erlang is and how it is supposed to work. This is a necessary prerequisite for new implementations other than the BEAM, and if erlang is successful these will come. While we are talking about change, I think a few syntax changes would be beneficial but I don't think they can ever be enough to appease the real syntax whiners. I separate those who complain about the syntax into whiners, those who whine about it not being like java, and those have actually tried it and come with serious criticism. This is not why I would like to make some changes. Thomas Lindgren mentioned one reason why the APIs look like they do, no vetting. Another early reason is that we were concentrating on some aspects of the language, and implementing it, and often we just need a library so we hacked one together. And we still have them hanging around. An unfortunate and slightly depressing prerequisite to these reasons is that some didn't have the inclination or time to make a good API. And I must admit I had a rather cavalier attitude to libraries before, if you need a library you write it yourself. Which probably didn't help much. :-) I agree with Joe on how to proceed, although I think you have to release the new libraries earlier to the eager waiting public, you can't wait until you have redone the whole lost before releasing them. However you *do* need a small group to work on the guidelines and programming rules and do the initial new libraries, both as tests of the rules and as examples. The group should be small or else it is difficult to work out a clear concise set of rules and guidelines. As always the problem is not what not add but what to remove. The funny thing is that I am probably the one who least cares if my stuff is ever used. Strange world. That's about it for this time, Robert 2008/11/17 Kenneth Lundin > I agree that it is unfortunate that some of the library modules are > not consistent with each other > but I don't think this is a major problem for users of Erlang. > > I think it is a very bad idea to start discussing a new incompatible > track of Erlang just because of this. > > The Erlang community is not big enough for this yet, what we need now > is actions that stimulate the > growth of the community. > > I definitely don't think the inconsistency in the tree, dict etc. APIs > is one of the most important things in this. > > More important is to get more high quality reusable Open Source > components and an easy way to find these. > Also more important is to have more books and more "killer" > applications built with Erlang. Applications that draw > the attention to Erlang. > > When it comes to inconsistencies in libraries and language I think the > best way is to prepare a suggestion on design rules for new API's > both for collection ADT's and in general. Then this can be used as a > basis for evolving stepwise into more consistent API's. > > There are ways to evolve without breaking compatibility new functions > can easily be added and old ones can be deprecated. > New modules can also easily be added etc. > > It is also very important to remember that backwards compatibility is > one of the most appreciated characteristics of Erlang. It makes it > possible for > large and huge SW projects to shift to a new major release of > Erlang/OTP with minimal work. This is essential in order to > get users to upgrade to the next release. > > /Kenneth Erlang/OTP, Ericsson > > > On Sat, Nov 15, 2008 at 7:54 PM, damien morton > wrote: > > I don't suppose there's and Erlang 3000 project in the works? > > > > The Python people set out to create Python 3000, throwing backwards > > compatibility out the window in favour of fixing language and library > > design errors. > > > > I mentioned earlier the variety of ways that the Erlang libraries > > signal returning a value or not. Some examples: > > > > proplists:get_value(Key, List) -> undefined | Value > > > > dict:find(Key, Dict) -> {ok, Value} | error > > > > gb_tree:lookup(Key, Tree) -> {value, Val} | none > > > > dets:lookup(Name, Key) -> [Object] | {error, Reason} > > > > ets:lookup(Tab, Key) -> [Object] > > > > All these operations on standard ADTs are roughly equivalent, and yet > > they have different or conflicting naming conventions, different > > return value protocols, and different orderings of their arguments. > > > > While ets:lookup and dets:lookup return a tuple, one of whose members > > is the key, gb_tree:lookup return the value of a {key,value} pair. > > > > gb_tree:lookup, dict:find and proplists:get_value all perform the same > > operation, and though the return value protocol is different in each > > case, at least the arguments are the same. > > > > The key asset for any well designed language or library is > > learnability, which comes from regularity, i.e. having learned > > something in one situation, one can apply that knowledge to similar > > situation with a high probability of success. > > > > Erlang already does a lot of things differently from other languages, > > but when every single library module does things differently from the > > others, well, that's a lot of heterogeneity for a novice to deal with. > > > > I wasted an hour so so tonight trying to figure out a problem that > > stemmed from proplists having a different argument ordering to ets - I > > just instinctively assumed they had the same argument ordering, and > > why shouldn't I? > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ok@REDACTED Wed Nov 19 04:33:54 2008 From: ok@REDACTED (Richard O'Keefe) Date: Wed, 19 Nov 2008 16:33:54 +1300 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <4920BE6A.5090709@bredband.net> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20520907.post@talk.nabble.com> <3dbc6d1c0811151846v2454084dnc8830b6237ea6d6@mail.gmail.com> <87d4gvxryh.fsf@dixie.cronqvi.st> <8092dc770811161602u1ad9e09enf9e095af1e7a0df1@mail.gmail.com> <4920BE6A.5090709@bredband.net> Message-ID: On 17 Nov 2008, at 1:44 pm, H?kan Stenholm wrote: > Conditionals that have more than 2 branches where none of them > branch on > patterns - e.g. something like the to_upper code below: > > to_upper_char(C) when is_integer(C) -> > if > $a =< C, C =< $z -> C - 32; > 16#E0 =< C, C =< 16#F6 -> C - 32; > 16#F8 =< C, C =< 16#FE -> C - 32; > true -> C > end. If this is supposed to convert ISO Latin 1 characters to upper case, it's wrong. (In at least two different ways, both of which are left as an exercise for the reader.) Code for such purposes simply shouldn't be written by hand these days, but should be generated by some sort of script from the (relevant portion of the) Unicode data base. As such, whether it's written using 'case', 'if', or embedded Intercal should be of no interest. > case .... of > _ when ... -> ... > _ when ... -> ... > _ when ... -> ... > ... > end Did I write up a proposal for case ... of ... when ... -> ... ; when ... -> ... ; ... ; ... when ... -> ... ; when ... -> ... ; ... ; ....... end or did I just stick it into my radically incomplete micro-Erlang? From dmorton@REDACTED Wed Nov 19 04:41:34 2008 From: dmorton@REDACTED (damien morton) Date: Wed, 19 Nov 2008 14:41:34 +1100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <9b08084c0811180058x227977c6x2446aa3a99ed2112@mail.gmail.com> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20081118001602.GC1809@h216-235-12-168.host.egate.net> <3dbc6d1c0811171632t369eb208u5bebfd0f2a102af@mail.gmail.com> <20081118005024.GD1809@h216-235-12-168.host.egate.net> <3dbc6d1c0811171710m483e9ffbx35c8a154c370e05d@mail.gmail.com> <20081118011952.GE1809@h216-235-12-168.host.egate.net> <5ea453f90811171825g3345284ek7c2f31635fdf3b9c@mail.gmail.com> <4922692B.3030506@ericsson.com> <9b08084c0811180058x227977c6x2446aa3a99ed2112@mail.gmail.com> Message-ID: <8092dc770811181941q351991bje8daefe1d2a950a1@mail.gmail.com> On Tue, Nov 18, 2008 at 7:58 PM, Joe Armstrong wrote: > let's throw in my 5 cents ... ... $9.95 > We need an infrastructure. The genius of the Wikipedia is that it is > an organisational form that allows a lot of people to contribute by > doing a little. Correcting a spelling mistake, asking a question, > replying to a question has enormous power when done by hundreds or > thousands of people. > > /Joe Armstrong Google Code provides for line-by-line and revision-by-revision reviews: http://code.google.com/p/support/wiki/CodeReviews From mikpe@REDACTED Wed Nov 19 10:08:32 2008 From: mikpe@REDACTED (Mikael Pettersson) Date: Wed, 19 Nov 2008 10:08:32 +0100 Subject: [erlang-questions] conditional expressions In-Reply-To: <86BD4040-5B68-44A3-A689-CE62AB0880CC@cs.otago.ac.nz> References: <8092dc770811141638h2a1bee2av19c04e76ce535992@mail.gmail.com> <66d1c98f0811141713n6961e091ndcaae79c5cea54f0@mail.gmail.com> <5A0DCFB7-B080-4371-9766-1BB58F2FFB4D@cs.otago.ac.nz> <492238C9.60900@gmail.com> <86BD4040-5B68-44A3-A689-CE62AB0880CC@cs.otago.ac.nz> Message-ID: <18723.55184.62163.949537@harpo.it.uu.se> Richard O'Keefe writes: > > On 18 Nov 2008, at 4:38 pm, Serge Aleynikov wrote: > > > Your 'must' statement is not entirely accurate. > > Was there any doubt about what I meant? > Let's try again: > both 'andalso' and 'orelse' in Erlang have the > following properties: > the first operand must either return 'true' or 'false' > or raise an exception; > the second operand, if executed, must either return > 'true' or 'false' or raise an exception; > the Dialyzer will complain if either operand looks > as if it will return something other than 'false' or 'true'; > and above all: > you CANNOT use them to get the same effect as > Lisp's (OR - -) and (AND - -) or Python's similar > operators, which allow a normal result from the > second operand to be anything at all. > > I have in fact complained about this, not because I particularly > want non-Boolean results from these operators, but because the > code that's inserted to check makes them non-tail-recursive. Indeed, the failure of these operators to be properly tail-recursive makes them utterly useless, and dangerous. The HiPE compiler once had a performance bug in its register allocator because some code used an 'andalso' to control a tail-recursive computation. Needless to say I've since placed a ban on andalso/orelse in the HiPE code I maintain. From mikpe@REDACTED Wed Nov 19 10:25:45 2008 From: mikpe@REDACTED (Mikael Pettersson) Date: Wed, 19 Nov 2008 10:25:45 +0100 Subject: [erlang-questions] Why can't HiPE inline functions across modules? In-Reply-To: References: Message-ID: <18723.56217.695096.186603@harpo.it.uu.se> Tony Arcieri writes: > I've read that HiPE can't inline functions across modules. Is this merely > an implementation issue of HiPE, or is there some intractable problem I'm > missing? > > People typically bring up code change as the reason, however I don't see why > HiPE couldn't walk the graph of modules for which inlining has been > performed during a code change and deoptimize them all back to their > original state, then start all inlining for these modules over from scratch > again. > > Is there an intracticble problem I'm missing For better or worse, HiPE is not structured as a typical Java JIT, but more as a traditional ahead-of-time compiler (though it can be invoked at runtime in a running system). One of its current limitations is that it does not retain the native code's original Erlang/BEAM code at runtime, and that makes runtime recompilation of native code impossible. This can be overcome by adding that metadata and code to process it at various runtime events, but that would require a substantial investment of money and manpower, both of which are in short supply now. From bqt@REDACTED Wed Nov 19 10:33:39 2008 From: bqt@REDACTED (Johnny Billquist) Date: Wed, 19 Nov 2008 10:33:39 +0100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20520907.post@talk.nabble.com> <3dbc6d1c0811151846v2454084dnc8830b6237ea6d6@mail.gmail.com> <87d4gvxryh.fsf@dixie.cronqvi.st> <8092dc770811161602u1ad9e09enf9e095af1e7a0df1@mail.gmail.com> <4920BE6A.5090709@bredband.net> Message-ID: <4923DD73.5090903@softjar.se> Richard O'Keefe wrote: > On 17 Nov 2008, at 1:44 pm, H?kan Stenholm wrote: >> Conditionals that have more than 2 branches where none of them >> branch on >> patterns - e.g. something like the to_upper code below: >> >> to_upper_char(C) when is_integer(C) -> >> if >> $a =< C, C =< $z -> C - 32; >> 16#E0 =< C, C =< 16#F6 -> C - 32; >> 16#F8 =< C, C =< 16#FE -> C - 32; >> true -> C >> end. > > If this is supposed to convert ISO Latin 1 characters > to upper case, it's wrong. (In at least two different > ways, both of which are left as an exercise for the > reader.) Code for such purposes simply shouldn't be > written by hand these days, but should be generated by > some sort of script from the (relevant portion of the) > Unicode data base. As such, whether it's written using > 'case', 'if', or embedded Intercal should be of no interest. ??? That's a perfectly correct translation from lowercase to uppercase for Latin-1. Unicode is something else. Or is there just some bug in the code as such that I fail to see? Johnny From imre@REDACTED Wed Nov 19 10:45:36 2008 From: imre@REDACTED (Imre Palik) Date: Wed, 19 Nov 2008 11:45:36 +0200 Subject: [erlang-questions] dynamic programming in erlang Message-ID: <3BE6DBA1F3BE9D4798255806113D56540F7FB8AA92@utx-exchange.utx.local> Hi, what is the proper way to do dynamic programming in erlang? Currently I use a gb_tree for the memo, but it is really slow in some cases. On really slow I mean it is faster to regenerate the solution of the subproblem every time, then to look it up. Any ideas how can I do it better? Thx Imre From chsu79@REDACTED Wed Nov 19 11:01:27 2008 From: chsu79@REDACTED (Christian) Date: Wed, 19 Nov 2008 11:01:27 +0100 Subject: [erlang-questions] Inserting a "seam" in external calls Message-ID: I spent time last night studying external calls in beam. What I wanted to investigate is how difficult it is to insert an optional layer of indirection that allow me to divert external calls to a mock or fake module (as the terminology is used in testing). beam_emu.c has the apply and fixed_apply functions that do the MFA lookup, as well as the parameterized module and error_handler issues. export.c contains the code that manages the single global hashlist containing all exported functions in the system beam_load.c makes sure there are stubs for all exports needed by a module as it is being loaded. Are you with me what I'm investigating for? I want a "seam", another layer of indirection really, that would allow my test suite to override external calls made from a module. And I want it to be isolated to just that test, so another test on the same module, a test executing concurrently, would not be affected and would perform the indented external calls. The functions apply and fixed_apply in beam_emu.c have access to the Process pointer and the MFAs, that would be one place to put logic that checks if calls to M should be diverted, for which modules calling into M, and for which processes (or having which group leader) this should be done. Is this the only place external calls are made through? Ideally, this indirection should add as little overhead as possible in per process size and per external call performed. This could make it a candidate for EEPing into OTP, otherwise I dont think many would want it. I did see some code in beam_load.c that iterated through the import table of the beam file it was loading, and it had an array of MFAs of bifs that it allowed to be redefined, it contained erlang:apply/2 and 3. What does this mean? Can a module override erlang:apply for its own nefarious goals and all external calls will change due to it? From olopierpa@REDACTED Wed Nov 19 11:11:16 2008 From: olopierpa@REDACTED (Pierpaolo Bernardi) Date: Wed, 19 Nov 2008 11:11:16 +0100 Subject: [erlang-questions] dynamic programming in erlang In-Reply-To: <3BE6DBA1F3BE9D4798255806113D56540F7FB8AA92@utx-exchange.utx.local> References: <3BE6DBA1F3BE9D4798255806113D56540F7FB8AA92@utx-exchange.utx.local> Message-ID: <7352e43a0811190211o744832fbk852ef64ee267337d@mail.gmail.com> On Wed, Nov 19, 2008 at 10:45 AM, Imre Palik wrote: > Hi, > > what is the proper way to do dynamic programming in erlang? > > Currently I use a gb_tree for the memo, but it is really slow in some cases. On really slow I mean it is faster to regenerate the solution of the subproblem every time, then to look it up. Any ideas how can I do it better? I think that without seeing your code, at least a sketch, it will be difficult to diagnose the problem. Cheers P. From bgustavsson@REDACTED Wed Nov 19 11:24:25 2008 From: bgustavsson@REDACTED (Bjorn Gustavsson) Date: Wed, 19 Nov 2008 11:24:25 +0100 Subject: [erlang-questions] Inserting a "seam" in external calls In-Reply-To: References: Message-ID: <6672d0160811190224t4bc9131fj8bb8668f97ada585@mail.gmail.com> On Wed, Nov 19, 2008 at 11:01 AM, Christian wrote: > I did see some code in beam_load.c that iterated through the import > table of the beam file it was loading, and it had an array of MFAs of > bifs that it allowed to be redefined, it contained erlang:apply/2 and > 3. What does this mean? Can a module override erlang:apply for its own > nefarious goals and all external calls will change due to it? No. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From hasan.veldstra@REDACTED Wed Nov 19 11:27:53 2008 From: hasan.veldstra@REDACTED (Hasan Veldstra) Date: Wed, 19 Nov 2008 10:27:53 +0000 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <4923DD73.5090903@softjar.se> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20520907.post@talk.nabble.com> <3dbc6d1c0811151846v2454084dnc8830b6237ea6d6@mail.gmail.com> <87d4gvxryh.fsf@dixie.cronqvi.st> <8092dc770811161602u1ad9e09enf9e095af1e7a0df1@mail.gmail.com> <4920BE6A.5090709@bredband.net> <4923DD73.5090903@softjar.se> Message-ID: <403F51C9-0E16-4EF2-A58A-18AFCCC215B0@gmail.com> On 19 Nov 2008, at 09:33AM, Johnny Billquist wrote: > Richard O'Keefe wrote: >> On 17 Nov 2008, at 1:44 pm, H?kan Stenholm wrote: >>> Conditionals that have more than 2 branches where none of them >>> branch on >>> patterns - e.g. something like the to_upper code below: >>> >>> to_upper_char(C) when is_integer(C) -> >>> if >>> $a =< C, C =< $z -> C - 32; >>> 16#E0 =< C, C =< 16#F6 -> C - 32; >>> 16#F8 =< C, C =< 16#FE -> C - 32; >>> true -> C >>> end. >> >> If this is supposed to convert ISO Latin 1 characters >> to upper case, it's wrong. (In at least two different >> ways, both of which are left as an exercise for the >> reader.) Code for such purposes simply shouldn't be >> written by hand these days, but should be generated by >> some sort of script from the (relevant portion of the) >> Unicode data base. As such, whether it's written using >> 'case', 'if', or embedded Intercal should be of no interest. > > ??? That's a perfectly correct translation from lowercase to uppercase > for Latin-1. > Unicode is something else. > > Or is there just some bug in the code as such that I fail to see? "stra?e" - German for "street" - can be encoded in ISO Latin 1, but both your code and the one in the standard string module will fail to convert it to upper-case properly. From thomasl_erlang@REDACTED Wed Nov 19 11:11:27 2008 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Wed, 19 Nov 2008 02:11:27 -0800 (PST) Subject: [erlang-questions] Erlang 3000? In-Reply-To: <3dbc6d1c0811181840h729f33ecs3d8c0e4f6b3006cf@mail.gmail.com> Message-ID: <749239.48552.qm@web111413.mail.gq1.yahoo.com> --- On Wed, 11/19/08, Robert Virding wrote: > Thomas Lindgren mentioned one reason why the APIs look like > they do, no > vetting. Another early reason is that we were concentrating > on some aspects > of the language, and implementing it, and often we just > need a library so we > hacked one together. And we still have them hanging around. > An unfortunate > and slightly depressing prerequisite to these reasons is > that some didn't > have the inclination or time to make a good API. Maybe Erlang/OTP needs, dare I say it, a chief architect? Or at least someone with (sine qua non) good taste in APIs, a strong conviction, and the raw hacking power to rewrite all submitted code to follow The One True Way :-) Best, Thomas From thomasl_erlang@REDACTED Wed Nov 19 11:04:04 2008 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Wed, 19 Nov 2008 02:04:04 -0800 (PST) Subject: [erlang-questions] Why can't HiPE inline functions across modules? In-Reply-To: Message-ID: <566389.37770.qm@web111407.mail.gq1.yahoo.com> --- On Wed, 11/19/08, Tony Arcieri wrote: > From: Tony Arcieri > Subject: [erlang-questions] Why can't HiPE inline functions across modules? > To: "Erlang Questions" > Date: Wednesday, November 19, 2008, 12:41 AM > I've read that HiPE can't inline functions across > modules. Is this merely > an implementation issue of HiPE, or is there some > intractable problem I'm > missing? > > People typically bring up code change as the reason, > however I don't see why > HiPE couldn't walk the graph of modules for which > inlining has been > performed during a code change and deoptimize them all back > to their > original state, then start all inlining for these modules > over from scratch > again. > > Is there an intracticble problem I'm missing, or is > cross-module inlining a > feature that should appear on a HiPE wishlist? Aha, a favorite old topic of mine. Here are some pointers to a more "compiler-based" approach that shows some of the issues and a bit of the potential, at least: Thomas Lindgren. Module Merging: aggressive optimization and code replacement in highly available systems. Uppsala University TR 154, 1998. (ftp://ftp.csd.uu.se/pub/papers/reports/0154.ps.gz) Thomas Lindgren, Cross-Module Optimization of Erlang. EUC 2001. (http://www.erlang.se/euc/01/thomasl.ps) Thomas Lindgren. Profile-driven Inlining for Erlang. EUC 2003. (http://www.erlang.se/euc/03/proceedings/1630Thomas.ps) The deoptimization approach has, as I understand it, been taken far in Java after being proposed for Self. Unfortunately for a low-budget community, it looks like a great deal of unglamorous, grotty engineering and testing to get it working flawlessly :-) Let's say someone wants to do it anyway. For Erlang, a start might be to implement and expose suitable low-level linking and loading primitives in Hipe and work from there. (Hipe already does dynamic linking, so it could be straightforward to repurpose and extend those.) Best, Thomas From bqt@REDACTED Wed Nov 19 12:03:12 2008 From: bqt@REDACTED (Johnny Billquist) Date: Wed, 19 Nov 2008 12:03:12 +0100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <403F51C9-0E16-4EF2-A58A-18AFCCC215B0@gmail.com> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20520907.post@talk.nabble.com> <3dbc6d1c0811151846v2454084dnc8830b6237ea6d6@mail.gmail.com> <87d4gvxryh.fsf@dixie.cronqvi.st> <8092dc770811161602u1ad9e09enf9e095af1e7a0df1@mail.gmail.com> <4920BE6A.5090709@bredband.net> <4923DD73.5090903@softjar.se> <403F51C9-0E16-4EF2-A58A-18AFCCC215B0@gmail.com> Message-ID: <4923F270.4070601@softjar.se> Hasan Veldstra wrote: > > On 19 Nov 2008, at 09:33AM, Johnny Billquist wrote: > >> Richard O'Keefe wrote: >>> On 17 Nov 2008, at 1:44 pm, H?kan Stenholm wrote: >>>> Conditionals that have more than 2 branches where none of them >>>> branch on >>>> patterns - e.g. something like the to_upper code below: >>>> >>>> to_upper_char(C) when is_integer(C) -> >>>> if >>>> $a =< C, C =< $z -> C - 32; >>>> 16#E0 =< C, C =< 16#F6 -> C - 32; >>>> 16#F8 =< C, C =< 16#FE -> C - 32; >>>> true -> C >>>> end. >>> >>> If this is supposed to convert ISO Latin 1 characters >>> to upper case, it's wrong. (In at least two different >>> ways, both of which are left as an exercise for the >>> reader.) Code for such purposes simply shouldn't be >>> written by hand these days, but should be generated by >>> some sort of script from the (relevant portion of the) >>> Unicode data base. As such, whether it's written using >>> 'case', 'if', or embedded Intercal should be of no interest. >> >> ??? That's a perfectly correct translation from lowercase to uppercase >> for Latin-1. >> Unicode is something else. >> >> Or is there just some bug in the code as such that I fail to see? > > "stra?e" - German for "street" - can be encoded in ISO Latin 1, but both > your code and the one in the standard string module will fail to convert > it to upper-case properly. Well, Latin-1 don't have an uppercase version of ?, so that letter can't be converted, if you want to stay in Latin-1. The rest will do just fine. So, within the limitations of Latin-1, the function works fine, as far as I can tell. Johnny From v@REDACTED Wed Nov 19 12:59:43 2008 From: v@REDACTED (Valentin Micic) Date: Wed, 19 Nov 2008 13:59:43 +0200 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <4923F270.4070601@softjar.se> Message-ID: <200811191158.mAJBwVKn010183@mail.pharos-avantgard.com> > Well, Latin-1 don't have an uppercase version of ?, so that letter can't > be converted What is the uppercase for "?"? V. From bengt.kleberg@REDACTED Wed Nov 19 13:23:25 2008 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Wed, 19 Nov 2008 13:23:25 +0100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <200811191158.mAJBwVKn010183@mail.pharos-avantgard.com> References: <200811191158.mAJBwVKn010183@mail.pharos-avantgard.com> Message-ID: <4924053D.9090509@ericsson.com> According to http://www.alvestrand.no/pipermail/idna-update/2008-March/001281.html: the facts of current German orthography are that the uppercase of ? is "SS" I stopped looking when I found a quote that supports my own opinion. 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." On 2008-11-19 12:59, Valentin Micic wrote: >> Well, Latin-1 don't have an uppercase version of ?, so that letter can't >> be converted > > What is the uppercase for "?"? > > V. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From richardc@REDACTED Wed Nov 19 13:46:01 2008 From: richardc@REDACTED (Richard Carlsson) Date: Wed, 19 Nov 2008 13:46:01 +0100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <4924053D.9090509@ericsson.com> References: <200811191158.mAJBwVKn010183@mail.pharos-avantgard.com> <4924053D.9090509@ericsson.com> Message-ID: <49240A89.6040600@it.uu.se> Bengt Kleberg wrote: > the facts of current German orthography are that the > uppercase of ? is "SS" Quite. The lesson should be that even "within the limitations of Latin-1", the idea that you can do case conversion on single code points is wrong. It is an operation that should be applied to strings, not individual characters. /Richard From masse@REDACTED Wed Nov 19 14:20:43 2008 From: masse@REDACTED (mats cronqvist) Date: Wed, 19 Nov 2008 14:20:43 +0100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: (Richard O'Keefe's message of "Wed\, 19 Nov 2008 16\:33\:54 +1300") References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20520907.post@talk.nabble.com> <3dbc6d1c0811151846v2454084dnc8830b6237ea6d6@mail.gmail.com> <87d4gvxryh.fsf@dixie.cronqvi.st> <8092dc770811161602u1ad9e09enf9e095af1e7a0df1@mail.gmail.com> <4920BE6A.5090709@bredband.net> Message-ID: <87abbvvolw.fsf@sterlett.hq.kred> "Richard O'Keefe" writes: > Did I write up a proposal for > case ... > of ... when ... -> ... > ; when ... -> ... > ; ... > ; ... when ... -> ... > ; when ... -> ... > ; ... > ; ....... > end > or did I just stick it into my radically incomplete micro-Erlang? i've seen it, and it pleased me greatly. mats From bqt@REDACTED Wed Nov 19 15:04:43 2008 From: bqt@REDACTED (Johnny Billquist) Date: Wed, 19 Nov 2008 15:04:43 +0100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <49240A89.6040600@it.uu.se> References: <200811191158.mAJBwVKn010183@mail.pharos-avantgard.com> <4924053D.9090509@ericsson.com> <49240A89.6040600@it.uu.se> Message-ID: <49241CFB.9000001@softjar.se> Richard Carlsson wrote: > Bengt Kleberg wrote: >> the facts of current German orthography are that the >> uppercase of ? is "SS" > > Quite. The lesson should be that even "within the limitations of > Latin-1", the idea that you can do case conversion on single > code points is wrong. It is an operation that should be applied > to strings, not individual characters. And I don't agree. You are mixing semantics with syntax, in my mind (syntax is probably not the right word here, but I'm no typographer so I don't know the correct term, but I hope you understand what I mean). There is no uppercase version of ?, so it can't be converted to uppercase. The fact that you write SS instead of ?, when you want it in uppercase don't mean that it's the same letter, just that it has the same meaning. Conversion of a string to uppercase can be regarded in two ways. Either you replace each character with it's uppercase version, and characters that don't have an uppercase version you leave be. Or you can try to convert the string as such to an uppercase version, where some letters might need to be replaced by sequences of other characters. I personally usually are satisfied with the previous, but I guess that's anyones choice. And I also believe that this is one of the more serious flaws of Unicode. It mixes semantics with syntax. So you have, for instance several A-ring characters, for use in different type of contexts, but that is all artificial and unfortunate. It's like in the old days, when you had several different minus signs on punched cards, for different uses. Hmm, looking at Unicode, I can see that they have reintroduced this ambiguity. You have hyphen-minus (U+002D), hyphen (U+2010) and minus (U+2212) and you also have a number of different dashes. Try to figure out which one you want when you are writing. (According to one myth this "problem" actually caused the Mariner 1 to fail and self destruct, since the poor Fortran programmer hade used a hyphen instead of a minus for a constant. Not sure if it's true or not, and the web don't give a sure answer.) (Oh, and the A-ring problem is that there is a unit called ?ngstr?m, which uses the symbol ?. However, in Swedish, A-ring (?) is a normal, plain letter, and the guy ?ngstr?m was a Swede, and the unit was named after him, with the first letter of his last name as the unit, but with Unicode we now need to know if we're writing the letter ?, or the unit ?, which is a different codepoint, even though it actually is the same letter. There are more examples like this, where Unicode mess things up because it mix the visual impression of a character with semantic meaning of the character.) And when I learned German in school many years ago, I was taught that ? was more or less the equivalent of sz. :-) Johnny From pablo.platt@REDACTED Wed Nov 19 15:27:11 2008 From: pablo.platt@REDACTED (Pablo Platt) Date: Wed, 19 Nov 2008 06:27:11 -0800 (PST) Subject: [erlang-questions] Erlang for a measurement system? Message-ID: <708273.62594.qm@web110012.mail.gq1.yahoo.com> Hi, We are considering erlang for building a controlled measurement system in our laboratory. The erlang software will control several devices using VISA (GPIB, RS232, USB). Are there any advantages for using erlang for this implementation? Will erlang be able to control two different devices in parallel in a reliable way because of its 'share nothing' principle? Is synchronizing several process (resolution of ms) an advantage of erlang or is it mainly an hardware issue? Is synchronizing several computers(resolution of ms) an advantage of erlang? Are there know implementations of erlang for controlling measurement devices (VISA)? Is there an advantage of using erlang compared to python (http://pypi.python.org/pypi/PyVISA/1.3). Appreciate your feedback, Pablo -------------- next part -------------- An HTML attachment was scrubbed... URL: From thomasl_erlang@REDACTED Wed Nov 19 15:05:55 2008 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Wed, 19 Nov 2008 06:05:55 -0800 (PST) Subject: [erlang-questions] Why can't HiPE inline functions across modules? In-Reply-To: <18723.56217.695096.186603@harpo.it.uu.se> Message-ID: <535272.92726.qm@web111411.mail.gq1.yahoo.com> --- On Wed, 11/19/08, Mikael Pettersson wrote: > For better or worse, HiPE is not structured as a typical > Java JIT, > but more as a traditional ahead-of-time compiler (though it > can be > invoked at runtime in a running system). One of its current > limitations > is that it does not retain the native code's original > Erlang/BEAM code > at runtime, and that makes runtime recompilation of native > code impossible. > > This can be overcome by adding that metadata and code to > process it > at various runtime events, but that would require a > substantial > investment of money and manpower, both of which are in > short supply now. The beam code of a module should (usually) be available for loading via the code server, though it might be useful to be less heavy-weight than reading and parsing the whole module. Also, one further important piece of infrastructure would be a (preferrably flexible) profiling framework to drive reoptimization. (Those interested might note that Hipe's predecessor Jerico actually had some of these features. See e.g. section 4.4 of the following: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.33.5232&rep=rep1&type=pdf ) Best, Thomas From dmercer@REDACTED Wed Nov 19 16:10:09 2008 From: dmercer@REDACTED (David Mercer) Date: Wed, 19 Nov 2008 09:10:09 -0600 Subject: [erlang-questions] conditional expressions In-Reply-To: <18723.55184.62163.949537@harpo.it.uu.se> References: <8092dc770811141638h2a1bee2av19c04e76ce535992@mail.gmail.com><66d1c98f0811141713n6961e091ndcaae79c5cea54f0@mail.gmail.com><5A0DCFB7-B080-4371-9766-1BB58F2FFB4D@cs.otago.ac.nz><492238C9.60900@gmail.com><86BD4040-5B68-44A3-A689-CE62AB0880CC@cs.otago.ac.nz> <18723.55184.62163.949537@harpo.it.uu.se> Message-ID: <208E29EE88AA4D98B5517BBA98A78B34@SSI.CORP> Can someone please explain the tail recursion problem with andalso? Thanks. David > -----Original Message----- > From: erlang-questions-bounces@REDACTED [mailto:erlang-questions- > bounces@REDACTED] On Behalf Of Mikael Pettersson > Sent: Wednesday, November 19, 2008 03:09 > To: Richard O'Keefe > Cc: erlang-questions@REDACTED > Subject: Re: [erlang-questions] conditional expressions > > Richard O'Keefe writes: > > > > On 18 Nov 2008, at 4:38 pm, Serge Aleynikov wrote: > > > > > Your 'must' statement is not entirely accurate. > > > > Was there any doubt about what I meant? > > Let's try again: > > both 'andalso' and 'orelse' in Erlang have the > > following properties: > > the first operand must either return 'true' or 'false' > > or raise an exception; > > the second operand, if executed, must either return > > 'true' or 'false' or raise an exception; > > the Dialyzer will complain if either operand looks > > as if it will return something other than 'false' or 'true'; > > and above all: > > you CANNOT use them to get the same effect as > > Lisp's (OR - -) and (AND - -) or Python's similar > > operators, which allow a normal result from the > > second operand to be anything at all. > > > > I have in fact complained about this, not because I particularly > > want non-Boolean results from these operators, but because the > > code that's inserted to check makes them non-tail-recursive. > > Indeed, the failure of these operators to be properly > tail-recursive makes them utterly useless, and dangerous. > > The HiPE compiler once had a performance bug in its > register allocator because some code used an 'andalso' > to control a tail-recursive computation. Needless to say > I've since placed a ban on andalso/orelse in the HiPE code > I maintain. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From richardc@REDACTED Wed Nov 19 16:28:24 2008 From: richardc@REDACTED (Richard Carlsson) Date: Wed, 19 Nov 2008 16:28:24 +0100 Subject: [erlang-questions] conditional expressions In-Reply-To: <208E29EE88AA4D98B5517BBA98A78B34@SSI.CORP> References: <8092dc770811141638h2a1bee2av19c04e76ce535992@mail.gmail.com><66d1c98f0811141713n6961e091ndcaae79c5cea54f0@mail.gmail.com><5A0DCFB7-B080-4371-9766-1BB58F2FFB4D@cs.otago.ac.nz><492238C9.60900@gmail.com><86BD4040-5B68-44A3-A689-CE62AB0880CC@cs.otago.ac.nz> <18723.55184.62163.949537@harpo.it.uu.se> <208E29EE88AA4D98B5517BBA98A78B34@SSI.CORP> Message-ID: <49243098.5060100@it.uu.se> David Mercer wrote: > Can someone please explain the tail recursion problem with andalso? Thanks. It checks that the return value of the right hand side is a boolean, so it must wait for the evaluation to return; it can't just do a tail call if the left hand side evaluates to true. (The OTP folks thought that error checking was more important than tail recursion for these operators.) /Richard From toby@REDACTED Wed Nov 19 16:41:32 2008 From: toby@REDACTED (Toby Thain) Date: Wed, 19 Nov 2008 10:41:32 -0500 Subject: [erlang-questions] Azul Systems - up to 864 cores "optimised for Java" Message-ID: <997C70E3-A2C7-49F6-A895-394E9E19B4B2@telegraphics.com.au> I wonder how Erlang would go. http://blogs.azulsystems.com/cliff/2008/11/a-brief-conversation-with- david-moon.html Brought back memories of similar-sized Transputer systems, and many echoes of the Transputer architecture. --Toby (Via wingolog, http://wingolog.org/archives/2008/11/19/dangling- pointers ) From kevin@REDACTED Wed Nov 19 16:45:11 2008 From: kevin@REDACTED (Kevin Scaldeferri) Date: Wed, 19 Nov 2008 07:45:11 -0800 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <49241CFB.9000001@softjar.se> References: <200811191158.mAJBwVKn010183@mail.pharos-avantgard.com> <4924053D.9090509@ericsson.com> <49240A89.6040600@it.uu.se> <49241CFB.9000001@softjar.se> Message-ID: On Nov 19, 2008, at 6:04 AM, Johnny Billquist wrote: > Richard Carlsson wrote: >> Bengt Kleberg wrote: >>> the facts of current German orthography are that the >>> uppercase of ? is "SS" >> >> Quite. The lesson should be that even "within the limitations of >> Latin-1", the idea that you can do case conversion on single >> code points is wrong. It is an operation that should be applied >> to strings, not individual characters. > > And I don't agree. You are mixing semantics with syntax, in my mind > (syntax is probably not the right word here, but I'm no typographer > so I > don't know the correct term, but I hope you understand what I mean). > There is no uppercase version of ?, so it can't be converted to > uppercase. > The fact that you write SS instead of ?, when you want it in uppercase > don't mean that it's the same letter, just that it has the same > meaning. At least in the context of the German language, ? is nothing more than a shorthand for ss. Similarly ? is shorthand for oe, and so on. If your string functions are not aware of this, then they are wrong. Of course, this exposes that the situation is quite complicated and subtle. Quite possibly these equivalences do not hold in other languages. This means that a function like "to_upper" operating on Latin-1 that isn't locale-aware is a wrong interface. > (Oh, and the A-ring problem is that there is a unit called ?ngstr?m, > which uses the symbol ?. However, in Swedish, A-ring (?) is a normal, > plain letter, and the guy ?ngstr?m was a Swede, and the unit was named > after him, with the first letter of his last name as the unit, but > with > Unicode we now need to know if we're writing the letter ?, or the unit > ?, which is a different codepoint, even though it actually is the same > letter...) Well this is really just another example. If you lowercase the Swedish letter ? you should get ?. However, it would be wrong to do the same for the symbol for the unit. > > There are more examples like this, where Unicode mess things up > because > it mix the visual impression of a character with semantic meaning of > the > character.) No, it doesn't do this at all. Unicode defines characters. It does not define glyphs. It is understood that the mapping of characters to glyphs is many-to-many. > > > And when I learned German in school many years ago, I was taught > that ? > was more or less the equivalent of sz. :-) The _pronunciation_ is somewhat like that. But the character is identical to ss. -kevin From ulf.wiger@REDACTED Wed Nov 19 16:46:54 2008 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Wed, 19 Nov 2008 16:46:54 +0100 Subject: [erlang-questions] Erlang for a measurement system? In-Reply-To: <708273.62594.qm@web110012.mail.gq1.yahoo.com> References: <708273.62594.qm@web110012.mail.gq1.yahoo.com> Message-ID: <492434EE.5050804@ericsson.com> How precise do the measurements need to be? You write "resolution of ms". If by that you mean +-1 ms, then you're problably going to have to control the machine pretty tightly, make sure that there are no cpu-bound tasks that can prolong context switches, etc. If it's ok to be off by some milliseconds now and again, then it will probably work. You should use a multi-core machine and make sure that the load stays fairly low. From a programming perspective, controlling different devices was one of Erlang's core requirements from the start. It's one of the things it does really, really well. BR, Ulf W Pablo Platt skrev: > Hi, > > We are considering erlang for building a controlled measurement system > in our laboratory. > The erlang software will control several devices using VISA (GPIB, > RS232, USB). > > Are there any advantages for using erlang for this implementation? > Will erlang be able to control two different devices in parallel in a > reliable way because of its 'share nothing' principle? > Is synchronizing several process (resolution of ms) an advantage of > erlang or is it mainly an hardware issue? > Is synchronizing several computers(resolution of ms) an advantage of erlang? > Are there know implementations of erlang for controlling measurement > devices (VISA)? > Is there an advantage of using erlang compared to python > (http://pypi.python.org/pypi/PyVISA/1.3). > > Appreciate your feedback, > Pablo > > > > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From toby@REDACTED Wed Nov 19 16:50:53 2008 From: toby@REDACTED (Toby Thain) Date: Wed, 19 Nov 2008 10:50:53 -0500 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <49241CFB.9000001@softjar.se> References: <200811191158.mAJBwVKn010183@mail.pharos-avantgard.com> <4924053D.9090509@ericsson.com> <49240A89.6040600@it.uu.se> <49241CFB.9000001@softjar.se> Message-ID: <709CAF15-2772-486C-9CAA-EA97797D6A8B@telegraphics.com.au> On 19-Nov-08, at 9:04 AM, Johnny Billquist wrote: > Richard Carlsson wrote: >> Bengt Kleberg wrote: >>> the facts of current German orthography are that the >>> uppercase of ? is "SS" >> >> Quite. The lesson should be that even "within the limitations of >> Latin-1", the idea that you can do case conversion on single >> code points is wrong. It is an operation that should be applied >> to strings, not individual characters. > > And I don't agree. You are mixing semantics with syntax, in my mind > (syntax is probably not the right word here, but I'm no typographer > so I > don't know the correct term, but I hope you understand what I mean). > There is no uppercase version of ?, so it can't be converted to > uppercase. > The fact that you write SS instead of ?, when you want it in uppercase > don't mean that it's the same letter, just that it has the same > meaning. > > Conversion of a string to uppercase can be regarded in two ways. > Either > you replace each character with it's uppercase version, and characters > that don't have an uppercase version you leave be. > > Or you can try to convert the string as such to an uppercase version, > where some letters might need to be replaced by sequences of other > characters. > > I personally usually are satisfied with the previous, but I guess > that's > anyones choice. How could a German reader *possibly* be satisfied with the incorrect result of the over-simple-minded method!! > > And I also believe that this is one of the more serious flaws of > Unicode. It mixes semantics with syntax. So you have, for instance > several A-ring characters, for use in different type of contexts, but > that is all artificial and unfortunate. > It's like in the old days, when you had several different minus > signs on > punched cards, for different uses. Hmm, looking at Unicode, I can see > that they have reintroduced this ambiguity. You have hyphen-minus > (U+002D), hyphen (U+2010) and minus (U+2212) and you also have a > number > of different dashes. > Try to figure out which one you want when you are writing. Nothing substitutes for a typographic education if you wish to use a typographic palette. > (According to one myth this "problem" actually caused the Mariner 1 to > fail and self destruct, since the poor Fortran programmer hade used a > hyphen instead of a minus for a constant. Not sure if it's true or > not, > and the web don't give a sure answer.) Unlikely to be true, but a failure of testing, surely. > > (Oh, and the A-ring problem is that there is a unit called ?ngstr?m, > which uses the symbol ?. However, in Swedish, A-ring (?) is a normal, > plain letter, and the guy ?ngstr?m was a Swede, and the unit was named > after him, with the first letter of his last name as the unit, but > with > Unicode we now need to know if we're writing the letter ?, or the unit > ?, which is a different codepoint, even though it actually is the same > letter. > There are more examples like this, Hundreds more (for example, Hebrew or Fraktur letters as mathematical symbols). And there may be an associated rationale. > where Unicode mess things up because > it mix the visual impression of a character with semantic meaning > of the > character.) > > And when I learned German in school many years ago, I was taught > that ? > was more or less the equivalent of sz. :-) Is that relevant? The orthographic rule is what it is. --Toby > > Johnny > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From v@REDACTED Wed Nov 19 17:08:02 2008 From: v@REDACTED (Valentin Micic) Date: Wed, 19 Nov 2008 18:08:02 +0200 Subject: [erlang-questions] Scharfes S (WAS: Erlang 3000?) In-Reply-To: <49241CFB.9000001@softjar.se> Message-ID: <200811191606.mAJG6oKn011499@mail.pharos-avantgard.com> I was under impression that one may write a lowercase ss with the same meaning and that "?" just represents a short way of writing "ss". As for pronunciation, I think that single s is indeed pronounced "sz", thus Suzuki in German sound quite contrary to what one would expect. I might be wrong, but scharfes s is used to eliminate "z" sound in "s", hence Strasse, I mean -- Stra?e. V. -----Original Message----- From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Johnny Billquist Sent: 19 November 2008 04:05 PM To: Richard Carlsson Cc: 'erlang-questions Questions' Subject: Re: [erlang-questions] Erlang 3000? Richard Carlsson wrote: > Bengt Kleberg wrote: >> the facts of current German orthography are that the >> uppercase of ? is "SS" > > Quite. The lesson should be that even "within the limitations of > Latin-1", the idea that you can do case conversion on single > code points is wrong. It is an operation that should be applied > to strings, not individual characters. And I don't agree. You are mixing semantics with syntax, in my mind (syntax is probably not the right word here, but I'm no typographer so I don't know the correct term, but I hope you understand what I mean). There is no uppercase version of ?, so it can't be converted to uppercase. The fact that you write SS instead of ?, when you want it in uppercase don't mean that it's the same letter, just that it has the same meaning. Conversion of a string to uppercase can be regarded in two ways. Either you replace each character with it's uppercase version, and characters that don't have an uppercase version you leave be. Or you can try to convert the string as such to an uppercase version, where some letters might need to be replaced by sequences of other characters. I personally usually are satisfied with the previous, but I guess that's anyones choice. And I also believe that this is one of the more serious flaws of Unicode. It mixes semantics with syntax. So you have, for instance several A-ring characters, for use in different type of contexts, but that is all artificial and unfortunate. It's like in the old days, when you had several different minus signs on punched cards, for different uses. Hmm, looking at Unicode, I can see that they have reintroduced this ambiguity. You have hyphen-minus (U+002D), hyphen (U+2010) and minus (U+2212) and you also have a number of different dashes. Try to figure out which one you want when you are writing. (According to one myth this "problem" actually caused the Mariner 1 to fail and self destruct, since the poor Fortran programmer hade used a hyphen instead of a minus for a constant. Not sure if it's true or not, and the web don't give a sure answer.) (Oh, and the A-ring problem is that there is a unit called ?ngstr?m, which uses the symbol ?. However, in Swedish, A-ring (?) is a normal, plain letter, and the guy ?ngstr?m was a Swede, and the unit was named after him, with the first letter of his last name as the unit, but with Unicode we now need to know if we're writing the letter ?, or the unit ?, which is a different codepoint, even though it actually is the same letter. There are more examples like this, where Unicode mess things up because it mix the visual impression of a character with semantic meaning of the character.) And when I learned German in school many years ago, I was taught that ? was more or less the equivalent of sz. :-) Johnny _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions From byron.hale@REDACTED Wed Nov 19 17:22:24 2008 From: byron.hale@REDACTED (Byron Hale) Date: Wed, 19 Nov 2008 08:22:24 -0800 Subject: [erlang-questions] Erlang fails to configure on Suse 10.3 Message-ID: <49243D40.3030508@einfo.com> Hi, The current and previous versions do not even configure on Suse 10.3, Intel, 64 bits, gcc (GCC) 4.2.1 (SUSE Linux) w/ c/c++ compiler installed, UNIXodbc (among others) installed. Current complaint: odbc : ODBC library - link check failed orber : No C++ compiler found See attachment for details. Thanks, Byron Hale -------------- next part -------------- A non-text attachment was scrubbed... Name: configure.log Type: text/x-log Size: 26751 bytes Desc: not available URL: From kostis@REDACTED Wed Nov 19 17:42:24 2008 From: kostis@REDACTED (Kostis Sagonas) Date: Wed, 19 Nov 2008 18:42:24 +0200 Subject: [erlang-questions] Erlang fails to configure on Suse 10.3 In-Reply-To: <49243D40.3030508@einfo.com> References: <49243D40.3030508@einfo.com> Message-ID: <492441F0.3080104@cs.ntua.gr> Byron Hale wrote: > Hi, > > The current and previous versions do not even configure on Suse 10.3, > > Intel, 64 bits, > > gcc (GCC) 4.2.1 (SUSE Linux) w/ c/c++ compiler installed, > > UNIXodbc (among others) installed. > > Current complaint: > > odbc : ODBC library - link check failed > orber : No C++ compiler found > > See attachment for details. It has configured alright. Issue 'make' and things will work fine. If you want to get rid of the second warning you much install g++ Kostis From julian@REDACTED Wed Nov 19 17:57:50 2008 From: julian@REDACTED (Julian =?iso-8859-1?q?B=E4ume?=) Date: Wed, 19 Nov 2008 17:57:50 +0100 Subject: [erlang-questions] Scharfes S (WAS: Erlang 3000?) In-Reply-To: <200811191606.mAJG6oKn011499@mail.pharos-avantgard.com> References: <200811191606.mAJG6oKn011499@mail.pharos-avantgard.com> Message-ID: <200811191757.51367.julian@svg4all.de> moin, On Wednesday 19 November 2008 17:08:02 Valentin Micic wrote: > I was under impression that one may write a lowercase ss with the same > meaning and that "?" just represents a short way of writing "ss". No, in fact you change the pronunciation of the vowel right before "?" or "ss". If you write "ss", the vowel before is spoken much shorter than with "?" following. > As for pronunciation, I think that single s is indeed pronounced "sz", thus > Suzuki in German sound quite contrary to what one would expect. I might be > wrong, but scharfes s is used to eliminate "z" sound in "s", hence Strasse, > I mean -- Stra?e. Pronunciation of the "ss" or "?" in words is the same. One example here is: "muss" and "Mu?". The difference in pronunciation is just that you speak a short "u" in the first and a long one in the second case. Concerning the uppercase version of "?": There is quite no need for that. The discussion about the need of an uppercase "?" is much older than computers.... Since April this year there is a Unicode character that represents the capital ?. This article in the English wikipedia gives a short overview about this topic: http://en.wikipedia.org/wiki/Capital_? Some time ago I read a very interesting discussion in a German typography forum about how this letter should look like. http://www.typografie.info/typoforum/viewtopic.php?f=2&t=300&st=0&sk=t&sd=a I guess, it was this one, but I'm not sure. just my 2ct.. Julian From rtrlists@REDACTED Wed Nov 19 18:05:04 2008 From: rtrlists@REDACTED (Robert Raschke) Date: Wed, 19 Nov 2008 17:05:04 +0000 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <709CAF15-2772-486C-9CAA-EA97797D6A8B@telegraphics.com.au> References: <200811191158.mAJBwVKn010183@mail.pharos-avantgard.com> <4924053D.9090509@ericsson.com> <49240A89.6040600@it.uu.se> <49241CFB.9000001@softjar.se> <709CAF15-2772-486C-9CAA-EA97797D6A8B@telegraphics.com.au> Message-ID: <6a3ae47e0811190905q2f1357dcq4a2cb78f574f4073@mail.gmail.com> Stuff like to_upper(), to_lower(), is_vowel() etc. is pretty specific to the language used when writing the text. It does not translate well between languages in general. Things are complicated by the fact that there are so many Latin influenced languages that make it appear like there are common operations that you can carry out. The ? letter in german actually evolved out of a ligature of fraktur s (kinda looks like an upside down l) and z (looks a bit like a g with its left hand side chopped off). So, in the language you have the need for several types of the "ess" sound, soft (s) and hard (sz). Since this latter one lended itself to getting squashed together a bit during printing, you end up with a nice looking "letter" (similar in spirit to the fi ligature, for example). The fraktur printing alphabet got replaced by the latin based one and the ligature got replace by that strange thing that looks like a beta. The old handwritten german was completely bizarre (I've forgotten the name of it, but it looked a lot like the sharp end of a saw). On top of all that, there was recently (last ten years ago or so) the decision to revise some of the writing standards of German, essentially making it completely valid to write ss instead of ?, oe instead of ?, etc. It can be funny how written language can evolve. In Dutch there used to be a letter y with two dots (umlaut) on it, nowadays they write that as ij. Robby From dmercer@REDACTED Wed Nov 19 18:21:02 2008 From: dmercer@REDACTED (David Mercer) Date: Wed, 19 Nov 2008 11:21:02 -0600 Subject: [erlang-questions] Scharfes S (WAS: Erlang 3000?) In-Reply-To: <200811191606.mAJG6oKn011499@mail.pharos-avantgard.com> References: <49241CFB.9000001@softjar.se> <200811191606.mAJG6oKn011499@mail.pharos-avantgard.com> Message-ID: <084FB1A70BF74B63AF14466CF82A8C34@SSI.CORP> There are two use cases of case-changing that I can think of. The first is for typographic reasons. I don't think a programmatic approach is ever going to satisfy every possible case automatically. The other, however, is normalization, probably for comparison purposes??i.e., case-insensitive comparisons. In that case, being correct typographically isn't as important as consistency in how you represent a character. Ignoring the Unicode normalization approaches (regarding accents and combining characters, etc.), a simplistic up-casing algorithm may be all that is needed. Someone might object to up-casing the "p" in "pH", for example, but this is not for typographical purposes, but simply for normalization purposes. With that in mind, I would imagine that that German beta-looking character probably should be normalized to "SS", but bear in mind that this is coming from someone who doesn't know German and probably would have pronounced "stra?e" STRAYB, so I won't be the one to write that canonical code. :-) Please let me know if there are use cases I am missing and which enhance this discussion. Cheers, David > -----Original Message----- > From: erlang-questions-bounces@REDACTED [mailto:erlang-questions- > bounces@REDACTED] On Behalf Of Valentin Micic > Sent: Wednesday, November 19, 2008 10:08 > To: 'Johnny Billquist'; 'Richard Carlsson' > Cc: 'erlang-questions Questions' > Subject: [erlang-questions] Scharfes S (WAS: Erlang 3000?) > > I was under impression that one may write a lowercase ss with the same > meaning and that "?" just represents a short way of writing "ss". > As for pronunciation, I think that single s is indeed pronounced "sz", > thus > Suzuki in German sound quite contrary to what one would expect. I might be > wrong, but scharfes s is used to eliminate "z" sound in "s", hence > Strasse, > I mean -- Stra?e. > > V. > > -----Original Message----- > From: erlang-questions-bounces@REDACTED > [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Johnny Billquist > Sent: 19 November 2008 04:05 PM > To: Richard Carlsson > Cc: 'erlang-questions Questions' > Subject: Re: [erlang-questions] Erlang 3000? > > Richard Carlsson wrote: > > Bengt Kleberg wrote: > >> the facts of current German orthography are that the > >> uppercase of ? is "SS" > > > > Quite. The lesson should be that even "within the limitations of > > Latin-1", the idea that you can do case conversion on single > > code points is wrong. It is an operation that should be applied > > to strings, not individual characters. > > And I don't agree. You are mixing semantics with syntax, in my mind > (syntax is probably not the right word here, but I'm no typographer so I > don't know the correct term, but I hope you understand what I mean). > There is no uppercase version of ?, so it can't be converted to uppercase. > The fact that you write SS instead of ?, when you want it in uppercase > don't mean that it's the same letter, just that it has the same meaning. > > Conversion of a string to uppercase can be regarded in two ways. Either > you replace each character with it's uppercase version, and characters > that don't have an uppercase version you leave be. > > Or you can try to convert the string as such to an uppercase version, > where some letters might need to be replaced by sequences of other > characters. > > I personally usually are satisfied with the previous, but I guess that's > anyones choice. > > And I also believe that this is one of the more serious flaws of > Unicode. It mixes semantics with syntax. So you have, for instance > several A-ring characters, for use in different type of contexts, but > that is all artificial and unfortunate. > It's like in the old days, when you had several different minus signs on > punched cards, for different uses. Hmm, looking at Unicode, I can see > that they have reintroduced this ambiguity. You have hyphen-minus > (U+002D), hyphen (U+2010) and minus (U+2212) and you also have a number > of different dashes. > Try to figure out which one you want when you are writing. > (According to one myth this "problem" actually caused the Mariner 1 to > fail and self destruct, since the poor Fortran programmer hade used a > hyphen instead of a minus for a constant. Not sure if it's true or not, > and the web don't give a sure answer.) > > (Oh, and the A-ring problem is that there is a unit called ?ngstr?m, > which uses the symbol ?. However, in Swedish, A-ring (?) is a normal, > plain letter, and the guy ?ngstr?m was a Swede, and the unit was named > after him, with the first letter of his last name as the unit, but with > Unicode we now need to know if we're writing the letter ?, or the unit > ?, which is a different codepoint, even though it actually is the same > letter. > There are more examples like this, where Unicode mess things up because > it mix the visual impression of a character with semantic meaning of the > character.) > > And when I learned German in school many years ago, I was taught that ? > was more or less the equivalent of sz. :-) > > Johnny > _______________________________________________ > 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 bgustavsson@REDACTED Wed Nov 19 18:24:46 2008 From: bgustavsson@REDACTED (Bjorn Gustavsson) Date: Wed, 19 Nov 2008 18:24:46 +0100 Subject: [erlang-questions] conditional expressions In-Reply-To: <49243098.5060100@it.uu.se> References: <8092dc770811141638h2a1bee2av19c04e76ce535992@mail.gmail.com> <66d1c98f0811141713n6961e091ndcaae79c5cea54f0@mail.gmail.com> <5A0DCFB7-B080-4371-9766-1BB58F2FFB4D@cs.otago.ac.nz> <492238C9.60900@gmail.com> <86BD4040-5B68-44A3-A689-CE62AB0880CC@cs.otago.ac.nz> <18723.55184.62163.949537@harpo.it.uu.se> <208E29EE88AA4D98B5517BBA98A78B34@SSI.CORP> <49243098.5060100@it.uu.se> Message-ID: <6672d0160811190924n7184a61di5c0a98cdb8bfb1f@mail.gmail.com> On Wed, Nov 19, 2008 at 4:28 PM, Richard Carlsson wrote: > David Mercer wrote: >> Can someone please explain the tail recursion problem with andalso? Thanks. > > It checks that the return value of the right hand side is a boolean, > so it must wait for the evaluation to return; it can't just do a tail > call if the left hand side evaluates to true. (The OTP folks thought > that error checking was more important than tail recursion for these > operators.) Maybe we should reconsider that decision for R13. I agree with Mikael that andalso/orelse are both useless and dangerous. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From dmercer@REDACTED Wed Nov 19 18:26:45 2008 From: dmercer@REDACTED (David Mercer) Date: Wed, 19 Nov 2008 11:26:45 -0600 Subject: [erlang-questions] conditional expressions In-Reply-To: <49243098.5060100@it.uu.se> References: <8092dc770811141638h2a1bee2av19c04e76ce535992@mail.gmail.com><66d1c98f0811141713n6961e091ndcaae79c5cea54f0@mail.gmail.com><5A0DCFB7-B080-4371-9766-1BB58F2FFB4D@cs.otago.ac.nz><492238C9.60900@gmail.com><86BD4040-5B68-44A3-A689-CE62AB0880CC@cs.otago.ac.nz> <18723.55184.62163.949537@harpo.it.uu.se> <208E29EE88AA4D98B5517BBA98A78B34@SSI.CORP> <49243098.5060100@it.uu.se> Message-ID: <384AEB4B78F2416295FEF882FAB2B581@SSI.CORP> Richard Carlsson wrote: > David Mercer wrote: > > Can someone please explain the tail recursion problem with andalso? > Thanks. > > It checks that the return value of the right hand side is a boolean, > so it must wait for the evaluation to return; it can't just do a tail > call if the left hand side evaluates to true. (The OTP folks thought > that error checking was more important than tail recursion for these > operators.) Thanks for the reply, but I still do not understand. If the first operand evaluates to true the second operand must necessarily be checked, since they both have to be true in order for the expression to evaluate to true. What am I missing (or mi?ing :-) )? Cheers, David From richardc@REDACTED Wed Nov 19 19:26:33 2008 From: richardc@REDACTED (Richard Carlsson) Date: Wed, 19 Nov 2008 19:26:33 +0100 Subject: [erlang-questions] conditional expressions In-Reply-To: <384AEB4B78F2416295FEF882FAB2B581@SSI.CORP> References: <8092dc770811141638h2a1bee2av19c04e76ce535992@mail.gmail.com><66d1c98f0811141713n6961e091ndcaae79c5cea54f0@mail.gmail.com><5A0DCFB7-B080-4371-9766-1BB58F2FFB4D@cs.otago.ac.nz><492238C9.60900@gmail.com><86BD4040-5B68-44A3-A689-CE62AB0880CC@cs.otago.ac.nz> <18723.55184.62163.949537@harpo.it.uu.se> <208E29EE88AA4D98B5517BBA98A78B34@SSI.CORP> <49243098.5060100@it.uu.se> <384AEB4B78F2416295FEF882FAB2B581@SSI.CORP> Message-ID: <49245A59.70807@it.uu.se> David Mercer wrote: > Richard Carlsson wrote: >> David Mercer wrote: >>> Can someone please explain the tail recursion problem with andalso? >> Thanks. >> >> It checks that the return value of the right hand side is a boolean, >> so it must wait for the evaluation to return; it can't just do a tail >> call if the left hand side evaluates to true. (The OTP folks thought >> that error checking was more important than tail recursion for these >> operators.) > > Thanks for the reply, but I still do not understand. If the first operand > evaluates to true the second operand must necessarily be checked, since they > both have to be true in order for the expression to evaluate to true. What > am I missing (or mi?ing :-) )? If the LHS is true, then it all hangs on the RHS, so you can A) call it with a tail call (if the result of the andalso will be returned as the result of the current function) and hope that it evaluates to a boolean as it ought to, or B) call it, get the return value, check that it is indeed a boolean, and either return it as it is or throw an exception if it is not a boolean. The current implementation does B, which makes it less suitable for this kind of thing: all_true([H|T]) -> H andalso all_true(T); all_true([]) -> true. which would be a simple traversal if the implementation was A, but as it is, we have to return down the stack and check that we are getting neat little booleans all the way. (Yes, type analysis could sometimes save the day, but far from always.) On the other hand, B prevents uses such as this: maybe_goodbye(X) -> X andalso io:format("adieu"). (which returns false if X is false, and otherwise prints a message and returns ok). /Richard From Jouni.Ryno@REDACTED Wed Nov 19 19:28:34 2008 From: Jouni.Ryno@REDACTED (=?ISO-8859-1?Q?Jouni_Ryn=F6?=) Date: Wed, 19 Nov 2008 20:28:34 +0200 Subject: [erlang-questions] Erlang 3000? capital ss In-Reply-To: <49241CFB.9000001@softjar.se> References: <200811191158.mAJBwVKn010183@mail.pharos-avantgard.com> <4924053D.9090509@ericsson.com> <49240A89.6040600@it.uu.se> <49241CFB.9000001@softjar.se> Message-ID: <2EFBC8FE-D7A1-4317-9684-9E33BB1FDCB1@fmi.fi> On Nov 19, 2008, at 16:04 , Johnny Billquist wrote: >> Bengt Kleberg wrote: >>> the facts of current German orthography are that the >>> uppercase of ? is "SS" >> >> Keep looking, there is, since spring 2008, capital ? ..., typography is still? open, see http://en.wikipedia.org/wiki/Capital_? Jouni From twoggle@REDACTED Wed Nov 19 21:12:00 2008 From: twoggle@REDACTED (Tim Fletcher) Date: Wed, 19 Nov 2008 12:12:00 -0800 (PST) Subject: [erlang-questions] Erlang 3000? In-Reply-To: <9b08084c0811180058x227977c6x2446aa3a99ed2112@mail.gmail.com> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20081118001602.GC1809@h216-235-12-168.host.egate.net> <3dbc6d1c0811171632t369eb208u5bebfd0f2a102af@mail.gmail.com> <20081118005024.GD1809@h216-235-12-168.host.egate.net> <3dbc6d1c0811171710m483e9ffbx35c8a154c370e05d@mail.gmail.com> <20081118011952.GE1809@h216-235-12-168.host.egate.net> <5ea453f90811171825g3345284ek7c2f31635fdf3b9c@mail.gmail.com> <4922692B.3030506@ericsson.com> <9b08084c0811180058x227977c6x2446aa3a99ed2112@mail.gmail.com> Message-ID: <208dea58-540f-45b0-91c6-c865a3ffa739@g38g2000yqn.googlegroups.com> > We need methods for producing drop-dead-beautiful documentation > (in PDF, HTML, ...) - think "book quality" What tools are used to generate the Erlang PDF manuals? Would they be suitable? > We need an infrastructure. The genius of the Wikipedia is that it is > an organisational form that allows a lot of people to contribute by > doing a little. Correcting a spelling mistake, asking a question, > replying to a question has enormous power when done by hundreds or > thousands of people. Agreed. I think using a distributed SCM such as git would be a good alternative to a web-based code review tool. The forking and pulling workflow supports code review as-is, albeit not explicitly (cf. http://shifteleven.com/articles/2008/05/17/code-reviews-inherit-in-git). Switching to an e-mail client, or some code review application is too much work, particularly for smaller contributions. From twoggle@REDACTED Wed Nov 19 21:16:31 2008 From: twoggle@REDACTED (Tim Fletcher) Date: Wed, 19 Nov 2008 12:16:31 -0800 (PST) Subject: [erlang-questions] EUC 2008 slides Message-ID: <2c8d3c6d-109b-44f3-b733-160a58b9e1cb@g38g2000yqn.googlegroups.com> Anyone published their slides from the EUC yet? From dmorton@REDACTED Wed Nov 19 21:27:02 2008 From: dmorton@REDACTED (damien morton) Date: Thu, 20 Nov 2008 07:27:02 +1100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <208dea58-540f-45b0-91c6-c865a3ffa739@g38g2000yqn.googlegroups.com> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20081118001602.GC1809@h216-235-12-168.host.egate.net> <3dbc6d1c0811171632t369eb208u5bebfd0f2a102af@mail.gmail.com> <20081118005024.GD1809@h216-235-12-168.host.egate.net> <3dbc6d1c0811171710m483e9ffbx35c8a154c370e05d@mail.gmail.com> <20081118011952.GE1809@h216-235-12-168.host.egate.net> <5ea453f90811171825g3345284ek7c2f31635fdf3b9c@mail.gmail.com> <4922692B.3030506@ericsson.com> <9b08084c0811180058x227977c6x2446aa3a99ed2112@mail.gmail.com> <208dea58-540f-45b0-91c6-c865a3ffa739@g38g2000yqn.googlegroups.com> Message-ID: <8092dc770811191227h5058121dkc25ab3927d98b080@mail.gmail.com> On Thu, Nov 20, 2008 at 7:12 AM, Tim Fletcher wrote: >> We need an infrastructure. The genius of the Wikipedia is that it is >> an organisational form that allows a lot of people to contribute by >> doing a little. Correcting a spelling mistake, asking a question, >> replying to a question has enormous power when done by hundreds or >> thousands of people. > > Agreed. I think using a distributed SCM such as git would be a good > alternative to a web-based code review tool. The forking and pulling > workflow supports code review as-is, albeit not explicitly (cf. > http://shifteleven.com/articles/2008/05/17/code-reviews-inherit-in-git). > Switching to an e-mail client, or some code review application is too > much work, particularly for smaller contributions. git is probably the most user unfriendly SCM tool I have come across. Is the SVN/CVS plus web-based browsing and code review using google code not acceptable? From kenneth.lundin@REDACTED Wed Nov 19 21:48:06 2008 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Wed, 19 Nov 2008 21:48:06 +0100 Subject: [erlang-questions] EUC 2008 slides In-Reply-To: <2c8d3c6d-109b-44f3-b733-160a58b9e1cb@g38g2000yqn.googlegroups.com> References: <2c8d3c6d-109b-44f3-b733-160a58b9e1cb@g38g2000yqn.googlegroups.com> Message-ID: All slides will soon (Thursday) be published at erlang.org. /Kenneth Erlang/OTP, Ericsson On Wed, Nov 19, 2008 at 9:16 PM, Tim Fletcher wrote: > Anyone published their slides from the EUC yet? > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From hokan.stenholm@REDACTED Wed Nov 19 22:34:38 2008 From: hokan.stenholm@REDACTED (=?ISO-8859-1?Q?H=E5kan_Stenholm?=) Date: Wed, 19 Nov 2008 22:34:38 +0100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20520907.post@talk.nabble.com> <3dbc6d1c0811151846v2454084dnc8830b6237ea6d6@mail.gmail.com> <87d4gvxryh.fsf@dixie.cronqvi.st> <8092dc770811161602u1ad9e09enf9e095af1e7a0df1@mail.gmail.com> <4920BE6A.5090709@bredband.net> Message-ID: <4924866E.40801@bredband.net> Richard O'Keefe wrote: > > On 17 Nov 2008, at 1:44 pm, H?kan Stenholm wrote: >> Conditionals that have more than 2 branches where none of them branch on >> patterns - e.g. something like the to_upper code below: >> >> to_upper_char(C) when is_integer(C) -> >> if >> $a =< C, C =< $z -> C - 32; >> 16#E0 =< C, C =< 16#F6 -> C - 32; >> 16#F8 =< C, C =< 16#FE -> C - 32; >> true -> C >> end. > > If this is supposed to convert ISO Latin 1 characters > to upper case, it's wrong. (In at least two different > ways, both of which are left as an exercise for the > reader.) Its a slightly modified (and less verbose) version of the code below, taken from string.erl in R12B-5. to_upper_char(C) when is_integer(C), $a =< C, C =< $z -> C - 32; to_upper_char(C) when is_integer(C), 16#E0 =< C, C =< 16#F6 -> C - 32; to_upper_char(C) when is_integer(C), 16#F8 =< C, C =< 16#FE -> C - 32; to_upper_char(C) -> C. I choose this function because it was a simple example of where a 'if' is nicer than a 'case' or a guard, not because of any merit (or lack thereof) of the purpose of the above code itself. Maybe we should get back to discussing Erlang 3000 in this thread? e.g. could 'if' be replaced by another construct ... , rather than discussing the nastiness of unicode and various other text encodings. > Code for such purposes simply shouldn't be > written by hand these days, but should be generated by > some sort of script from the (relevant portion of the) > Unicode data base. As such, whether it's written using > 'case', 'if', or embedded Intercal should be of no interest. > >> case .... of >> _ when ... -> ... >> _ when ... -> ... >> _ when ... -> ... >> ... >> end > > Did I write up a proposal for > case ... > of ... when ... -> ... > ; when ... -> ... > ; ... > ; ... when ... -> ... > ; when ... -> ... > ; ... > ; ....... > end > or did I just stick it into my radically incomplete micro-Erlang? > From erlang@REDACTED Wed Nov 19 22:35:58 2008 From: erlang@REDACTED (Joe Armstrong) Date: Wed, 19 Nov 2008 22:35:58 +0100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <208dea58-540f-45b0-91c6-c865a3ffa739@g38g2000yqn.googlegroups.com> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20081118001602.GC1809@h216-235-12-168.host.egate.net> <3dbc6d1c0811171632t369eb208u5bebfd0f2a102af@mail.gmail.com> <20081118005024.GD1809@h216-235-12-168.host.egate.net> <3dbc6d1c0811171710m483e9ffbx35c8a154c370e05d@mail.gmail.com> <20081118011952.GE1809@h216-235-12-168.host.egate.net> <5ea453f90811171825g3345284ek7c2f31635fdf3b9c@mail.gmail.com> <4922692B.3030506@ericsson.com> <9b08084c0811180058x227977c6x2446aa3a99ed2112@mail.gmail.com> <208dea58-540f-45b0-91c6-c865a3ffa739@g38g2000yqn.googlegroups.com> Message-ID: <9b08084c0811191335p631fb53ep5130152ab62bd421@mail.gmail.com> If we are going to write loads of code we need to answer a number of questions and try to define some kind of "best practice"? What is best practice for testing and and documenting code? Should modules contain test cases - or should these be in separate files? Should modules contain APIs or should these be in separate interface documents? What meta data should a module have? What is the best way to use: 1) edoc 2) type signatures 3) meta data 4) unit testing 5) cross ref 6) type analysis Note I say "best way" - not how to use these things ... and so on ... I have a feeling that the toolset is important here. There is no incentive to write inline tests in the code if this is not backed up with a good production system. There is no incentive to write in-line documentation if I can get better results with off-line LaTeX. I think we should try to define a minimal set of standards that define best practice - then make the tools to support the codeing style we adopt. Personally I don't like stuffing everything into one file - I'd like to see X.erl (the code) X.sig (the interface type signature and terse documentation) X.doc (verbose - high quality documentation) X.test (test cases) With tools to produce html, pdf, cross listings, indices, reports, ... etc. Also organisation of code is interesting - when projects are small I put all code in the same directory - as they grow the code gets split into directories - as they get huge no amount of directory organisation helps - well index'ed meta data is the only thing that helps. All modules should probably have a GUID with some kind of tracking software that can track all derivatives of a module. We can start with edoc and docbuilder and ... and see how things go ... /Joe On Wed, Nov 19, 2008 at 9:12 PM, Tim Fletcher wrote: >> We need methods for producing drop-dead-beautiful documentation >> (in PDF, HTML, ...) - think "book quality" > > What tools are used to generate the Erlang PDF manuals? Would they be > suitable? > > >> We need an infrastructure. The genius of the Wikipedia is that it is >> an organisational form that allows a lot of people to contribute by >> doing a little. Correcting a spelling mistake, asking a question, >> replying to a question has enormous power when done by hundreds or >> thousands of people. > > Agreed. I think using a distributed SCM such as git would be a good > alternative to a web-based code review tool. The forking and pulling > workflow supports code review as-is, albeit not explicitly (cf. > http://shifteleven.com/articles/2008/05/17/code-reviews-inherit-in-git). > Switching to an e-mail client, or some code review application is too > much work, particularly for smaller contributions. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From bqt@REDACTED Wed Nov 19 23:37:02 2008 From: bqt@REDACTED (Johnny Billquist) Date: Wed, 19 Nov 2008 23:37:02 +0100 Subject: [erlang-questions] Scharfes S (WAS: Erlang 3000?) In-Reply-To: <200811191757.51367.julian@svg4all.de> References: <200811191606.mAJG6oKn011499@mail.pharos-avantgard.com> <200811191757.51367.julian@svg4all.de> Message-ID: <4924950E.9070500@softjar.se> Intreresting. Thanks a lot. Can people now agree that it is not correct to just replace a ? with ss, and a correct capitalization of ? is not possible in Latin-1? Just as I would say it would not be correct to replace ? with oe, even though ? is sorted as oe in German. (? is a separate letter with it's own correlation in Swedish, by the way.) Johnny Julian B?ume skrev: > moin, > > On Wednesday 19 November 2008 17:08:02 Valentin Micic wrote: >> I was under impression that one may write a lowercase ss with the same >> meaning and that "?" just represents a short way of writing "ss". > No, in fact you change the pronunciation of the vowel right before "?" or > "ss". If you write "ss", the vowel before is spoken much shorter than with "?" > following. > >> As for pronunciation, I think that single s is indeed pronounced "sz", thus >> Suzuki in German sound quite contrary to what one would expect. I might be >> wrong, but scharfes s is used to eliminate "z" sound in "s", hence Strasse, >> I mean -- Stra?e. > Pronunciation of the "ss" or "?" in words is the same. One example here is: > "muss" and "Mu?". The difference in pronunciation is just that you speak a > short "u" in the first and a long one in the second case. > > Concerning the uppercase version of "?": There is quite no need for that. The > discussion about the need of an uppercase "?" is much older than computers.... > Since April this year there is a Unicode character that represents the capital > ?. > > This article in the English wikipedia gives a short overview about this topic: > http://en.wikipedia.org/wiki/Capital_? > > Some time ago I read a very interesting discussion in a German typography > forum about how this letter should look like. > http://www.typografie.info/typoforum/viewtopic.php?f=2&t=300&st=0&sk=t&sd=a > I guess, it was this one, but I'm not sure. > > just my 2ct.. > Julian > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From rvirding@REDACTED Wed Nov 19 23:39:34 2008 From: rvirding@REDACTED (Robert Virding) Date: Wed, 19 Nov 2008 23:39:34 +0100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <749239.48552.qm@web111413.mail.gq1.yahoo.com> References: <3dbc6d1c0811181840h729f33ecs3d8c0e4f6b3006cf@mail.gmail.com> <749239.48552.qm@web111413.mail.gq1.yahoo.com> Message-ID: <3dbc6d1c0811191439pe0db463y9432342fdffaeda7@mail.gmail.com> 2008/11/19 Thomas Lindgren > > Maybe Erlang/OTP needs, dare I say it, a chief architect? Or at least > someone with (sine qua non) good taste in APIs, a strong conviction, and the > raw hacking power to rewrite all submitted code to follow The One True Way > :-) Yes, something like that. Although he/she shouldn't have to do all the hacking, just enforce that the submitted code follow The One True Way. Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: From masse@REDACTED Wed Nov 19 23:45:23 2008 From: masse@REDACTED (mats cronqvist) Date: Wed, 19 Nov 2008 23:45:23 +0100 Subject: [erlang-questions] serializing functions In-Reply-To: <20081116221053.GA5751@contorpis.lisalinda.com> (Matthias Lang's message of "Sun\, 16 Nov 2008 23\:10\:54 +0100") References: <8092dc770811161321l341abef9x56d3923a7ffcd4d3@mail.gmail.com> <20081116221053.GA5751@contorpis.lisalinda.com> Message-ID: <87skpn9vy4.fsf@dixie.cronqvi.st> Matthias Lang writes: > On Monday, November 17, damien morton wrote: >> If I take the most basic of functions, e.g. fun()->0 end. and serialize it >> using term_to_binary(), it seems that this function is serialized to 650 >> bytes. > > I'd guess you concluded that after trying it in the shell, not a > module. IIRC, funs made in the shell are special, they carry around > a complete (?) representation of the fun. i can confirm this. From dmorton@REDACTED Wed Nov 19 23:45:29 2008 From: dmorton@REDACTED (damien morton) Date: Thu, 20 Nov 2008 09:45:29 +1100 Subject: [erlang-questions] next(Erlang): "Fix up records so that records are first-class citizens and not just syntax saccharine for tuples?" Message-ID: <8092dc770811191445ie3e8066qf226ddae04cdb3b3@mail.gmail.com> I ask "Have there be any proposals on how to implement this?: Robert Virding responds "Yes, at least two, one by Joe Armstrong and one by Richard O'Keefe which he calls frames. Richard's is more developed" http://www.cs.otago.ac.nz/staffpriv/ok/frames.pdf ------------------------------ Hmm, I see - these fixed-up records would be dictionary-like data structures, with a supporting syntax for dictionary literals and pattern matching. They would lose the very fast lookup access that records have, though they would gain the expandability that a dictionary-type (proplist,hashtable,tree) data structure offers. Richard mentions that the internal representation need not be exposed - and I think this is a good idea. To be able to switch from a (sorted?) list of key-value-pairs to some other internal representation is a necessary thing - once you add a dictionary data structure to the language (as opposed to the library), people will use it for all kinds of purposes - you cant bound its size. The only way I could see a tighter integration between records and frames is if the keys were stored separately from the values, with the keys being the "schema" and the values being the data. You might lose the extensibility aspects, but the the set of keys/slots would define the "class" of the record itself. There might be some value in looking at the V8 engine concept of hidden classes - the notion that many instances would share the same set of keys and that you could have a fast-path accessor for a given key and given "hidden class" - i.e. you would know exactly which hash bucket to look in. From johnswolter@REDACTED Wed Nov 19 23:49:36 2008 From: johnswolter@REDACTED (john s wolter) Date: Wed, 19 Nov 2008 17:49:36 -0500 Subject: [erlang-questions] 10,000 simultaneous connections Message-ID: <24bcf1860811191449s72a34cc7ofc1bf7d972cc47c@mail.gmail.com> Yes, 10,000 simultaneous connections to a server. Whew! I have to sit down for a moment, I'm a little faint. Is Erlang up to the task or threads? (Ah, Ah,). Imagine a server that has to run at that level of multitasking. Right now this is all blue sky thinking. How could I benchmark an individual server's capability to run child threads for a web service? Next I want to write some test programs that use the threads to judge application loading issues. I'm hoping to start to better understand applying the Erlang system. -- John S. Wolter President Wolter Works Mailto:johnswolter@REDACTED Desk 1-734-665-1263 Cell: 1-734-904-8433 -------------- next part -------------- An HTML attachment was scrubbed... URL: From harveyd@REDACTED Wed Nov 19 23:56:16 2008 From: harveyd@REDACTED (Dale Harvey) Date: Wed, 19 Nov 2008 22:56:16 +0000 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <3dbc6d1c0811191439pe0db463y9432342fdffaeda7@mail.gmail.com> References: <3dbc6d1c0811181840h729f33ecs3d8c0e4f6b3006cf@mail.gmail.com> <749239.48552.qm@web111413.mail.gq1.yahoo.com> <3dbc6d1c0811191439pe0db463y9432342fdffaeda7@mail.gmail.com> Message-ID: I think visibility is the main concern when looking at the maturity of non otp libraries, the lack of a central release repository is a hinderance, but a single repository is unlikely to breakthrough very soon. I think a good alternative would be to allow the code / project to exist anywhere, but have a central place to find and document these libraries. I have been planning to set up a public fork to the erlang docs once they were fully released. I originally planned it to sort out simple usability apects, like a function overview at the top of a module page, an as you type filter of libraries / modules. I also wanted feedback / comment options as with php / flex docs, (http://se2.php.net/manual/en/function.socket-set-option.php) But it sounds like setting up a global documentation repository would be a perfect extension. an interface can be built to standard repositories (faxien / github etc) that could be used to pull in documentation from to be included alongside the standard/otp docs, categorised (alpha / beta / stable) etc. users would then have a central source for finding user libraries, along side searching the otp documentation, search within versions, compare functionality, comment on libraries quirky features etc. I can start building the integration stuff now, but the site wont really be useful until the rest of the doc builder ala I can build everything up to http://www.erlang.org/doc/ is released, hopefully thats the stuff planned for R13 2008/11/19 Robert Virding > 2008/11/19 Thomas Lindgren > >> >> Maybe Erlang/OTP needs, dare I say it, a chief architect? Or at least >> someone with (sine qua non) good taste in APIs, a strong conviction, and the >> raw hacking power to rewrite all submitted code to follow The One True Way >> :-) > > > Yes, something like that. Although he/she shouldn't have to do all the > hacking, just enforce that the submitted code follow The One True Way. > > Robert > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob@REDACTED Wed Nov 19 23:58:20 2008 From: bob@REDACTED (Bob Ippolito) Date: Wed, 19 Nov 2008 14:58:20 -0800 Subject: [erlang-questions] 10,000 simultaneous connections In-Reply-To: <24bcf1860811191449s72a34cc7ofc1bf7d972cc47c@mail.gmail.com> References: <24bcf1860811191449s72a34cc7ofc1bf7d972cc47c@mail.gmail.com> Message-ID: <6a36e7290811191458x20baceah5255921ff2752664@mail.gmail.com> http://www.metabrew.com/article/a-million-user-comet-application-with-mochiweb-part-1/ 2008/11/19 john s wolter : > Yes, 10,000 simultaneous connections to a server. Whew! I have to sit down > for a moment, I'm a little faint. Is Erlang up to the task or threads? > (Ah, Ah,). > Imagine a server that has to run at that level of multitasking. Right now > this is all blue sky thinking. How could I benchmark an individual server's > capability to run child threads for a web service? Next I want to write > some test programs that use the threads to judge application loading issues. > I'm hoping to start to better understand applying the Erlang system. > > -- > John S. Wolter President > Wolter Works > Mailto:johnswolter@REDACTED > Desk 1-734-665-1263 > Cell: 1-734-904-8433 > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From wde@REDACTED Thu Nov 20 01:07:17 2008 From: wde@REDACTED (wde@REDACTED) Date: Thu, 20 Nov 2008 01:07:17 +0100 Subject: [erlang-questions] RAM memory preallocation for mnesia Message-ID: <200811200008.mAK080rD015905@morgoth.cslab.ericsson.net> Hello all, I would like to know if there is a feature in mnesia or Erlang to reserve or preallocate memory space in RAM for a given table. The objective is to be sure that the application could always access to a minimum available space in RAM (from the Erlang VM point of view, don't care of the underlying os). thank you for your help wde From ok@REDACTED Thu Nov 20 01:29:26 2008 From: ok@REDACTED (Richard O'Keefe) Date: Thu, 20 Nov 2008 13:29:26 +1300 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <4923DD73.5090903@softjar.se> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20520907.post@talk.nabble.com> <3dbc6d1c0811151846v2454084dnc8830b6237ea6d6@mail.gmail.com> <87d4gvxryh.fsf@dixie.cronqvi.st> <8092dc770811161602u1ad9e09enf9e095af1e7a0df1@mail.gmail.com> <4920BE6A.5090709@bredband.net> <4923DD73.5090903@softjar.se> Message-ID: On 19 Nov 2008, at 10:33 pm, Johnny Billquist wrote: > Richard O'Keefe wrote: >> On 17 Nov 2008, at 1:44 pm, H?kan Stenholm wrote: >>> Conditionals that have more than 2 branches where none of them >>> branch on >>> patterns - e.g. something like the to_upper code below: >>> >>> to_upper_char(C) when is_integer(C) -> >>> if >>> $a =< C, C =< $z -> C - 32; >>> 16#E0 =< C, C =< 16#F6 -> C - 32; >>> 16#F8 =< C, C =< 16#FE -> C - 32; >>> true -> C >>> end. >> If this is supposed to convert ISO Latin 1 characters >> to upper case, it's wrong. (In at least two different >> ways, both of which are left as an exercise for the >> reader.) Code for such purposes simply shouldn't be >> written by hand these days, but should be generated by >> some sort of script from the (relevant portion of the) >> Unicode data base. As such, whether it's written using >> 'case', 'if', or embedded Intercal should be of no interest. > > ??? That's a perfectly correct translation from lowercase to > uppercase for Latin-1. But it doesn't check that the input *is* Latin 1. (One of the two mistakes I thought I saw was a mistake on my part, but that one's real.) to_upper_char(-137) => -137, for example. The last clause would be better as 0 =< C, C =< 16#FF -> C As a matter of fact, I'd expect a fair bit of "Latin 1" these days to be really Latin 9 or Windows-whatsit, both of which have extra letters. Latin 9 has an upper case version of 16rFF (at 16rBE). My machine has oodles of 8859-15 locales... From julian@REDACTED Thu Nov 20 02:34:45 2008 From: julian@REDACTED (Julian =?iso-8859-1?q?B=E4ume?=) Date: Thu, 20 Nov 2008 02:34:45 +0100 Subject: [erlang-questions] Scharfes S (WAS: Erlang 3000?) In-Reply-To: <4924950E.9070500@softjar.se> References: <200811191606.mAJG6oKn011499@mail.pharos-avantgard.com> <200811191757.51367.julian@svg4all.de> <4924950E.9070500@softjar.se> Message-ID: <200811200234.48951.julian@svg4all.de> Hey, On Wednesday 19 November 2008 23:37:02 Johnny Billquist wrote: > Can people now agree that it is not correct to just replace a ? with ss, > and a correct capitalization of ? is not possible in Latin-1? That's true. IIRC the consensus in a discussion I read about this topic was to leave ? as-is in a capitalised words. It might look a bit strange, but it could change the meaning completely. The best example in German is: "Ma?en" vs. "Massen", where the first one means something like "moderate amount" and the second "masses", which is quite the opposite ;) > Just as I would say it would not be correct to replace ? with oe, even > though ? is sorted as oe in German. (? is a separate letter with it's > own correlation in Swedish, by the way.) IMHO it is rather a work-around to use oe instead of ? in German, invented by some industry-people that wanted to save money when printing their books ;). And from a typographers point of view (I'm not one, I just came across this topic some time ago and read some stuff.) you are of course right, that this is incorrect. Since there is no easy way (just think of all that rules, that need to be implemented for all that different languages out there..) the to_upper functions should IMO all stay as they are. Programmers know about this problem and all that typographers can stick to \LaTeX to set their types in a nice and correct way. All in all I don't think that this problem can be easily fixed by the programming-language and therefore shouldn't be considered here. bye Julian -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 489 bytes Desc: This is a digitally signed message part. URL: From dawsdesign@REDACTED Thu Nov 20 02:38:29 2008 From: dawsdesign@REDACTED (Matt Williamson) Date: Wed, 19 Nov 2008 20:38:29 -0500 Subject: [erlang-questions] otp.net In-Reply-To: <49223331.5060400@gmail.com> References: <49223331.5060400@gmail.com> Message-ID: Nice work, Serge! Looking forward to the changes. On Mon, Nov 17, 2008 at 10:14 PM, Serge Aleynikov wrote: > I made several bug fixes and enhancements to the otp.net project in > jungerl, and would like to find out if this project is being used by > others before I commit my updates as not all modifications are backward > compatible. We had a discussion with the author (Vlad) and he didn't > seem to have objections. > > The changes are: > > - More robust error handling > - Added delegates for connection state changes > - Support for pid monitors > - Support for short node names > - Optional disabling of local epmd registration > - Support for local processing of io_request's > - RPC API extended to supply the pid of a local io server mailbox. > - Support for IEEE 754 double encoding/decoding > > Serge > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ok@REDACTED Thu Nov 20 02:51:46 2008 From: ok@REDACTED (Richard O'Keefe) Date: Thu, 20 Nov 2008 14:51:46 +1300 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <4923F270.4070601@softjar.se> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20520907.post@talk.nabble.com> <3dbc6d1c0811151846v2454084dnc8830b6237ea6d6@mail.gmail.com> <87d4gvxryh.fsf@dixie.cronqvi.st> <8092dc770811161602u1ad9e09enf9e095af1e7a0df1@mail.gmail.com> <4920BE6A.5090709@bredband.net> <4923DD73.5090903@softjar.se> <403F51C9-0E16-4EF2-A58A-18AFCCC215B0@gmail.com> <4923F270.4070601@softjar.se> Message-ID: On 20 Nov 2008, at 12:03 am, Johnny Billquist wrote: >> "stra?e" - German for "street" - can be encoded in ISO Latin 1, but >> both >> your code and the one in the standard string module will fail to >> convert >> it to upper-case properly. > > Well, Latin-1 don't have an uppercase version of ?, so that letter > can't > be converted, if you want to stay in Latin-1. The rest will do just > fine. You are assume that case mapping always converts exactly one character into exactly one character. Even in Latin-1, thanks to $?, that isn't true: the upper case equivalent of that character is two characters, both of which are Latin-1. Back in the 1980s, when I was working on Quintus Prolog, this assumption had already broken down. I see the comment "This predicate does _not_ work well with languages like German" on a case conversion predicate in a file dated 1987 and a similar comment in a file dated 1988, and I'm pretty sure my awareness of the issue is related to studying the XNS 16-bit character set in about 1985. (The files in question do not have histories, so they may well be older.) If we want to get Erlang Unicode-ready, we'll have to purge our code of character-at-a-time case mapping and replace it by whole-string case mapping, but the problem already existed 20 years ago. From ok@REDACTED Thu Nov 20 03:49:06 2008 From: ok@REDACTED (Richard O'Keefe) Date: Thu, 20 Nov 2008 15:49:06 +1300 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <49241CFB.9000001@softjar.se> References: <200811191158.mAJBwVKn010183@mail.pharos-avantgard.com> <4924053D.9090509@ericsson.com> <49240A89.6040600@it.uu.se> <49241CFB.9000001@softjar.se> Message-ID: <307CDF7E-D402-4A60-933B-9272649D8E34@cs.otago.ac.nz> On 20 Nov 2008, at 3:04 am, Johnny Billquist wrote: > And I don't agree. You are mixing semantics with syntax, in my mind > (syntax is probably not the right word here, but I'm no typographer > so I > don't know the correct term, but I hope you understand what I mean). > There is no uppercase version of ?, so it can't be converted to > uppercase. > The fact that you write SS instead of ?, when you want it in uppercase > don't mean that it's the same letter, just that it has the same > meaning. I think you are asking the wrong question. The question I would ask is "If I had a string with a sharp s in it and I asked for the upper case version what would I expect to get?" I put it to you that anyone asking for a string to be converted to entirely upper case would be rather upset to find a lower case letter in the result. The whole idea of a 1-1 lower-upper case mapping is historically absurd. Even in English and French, we had the distinction between long s and final s in lower case (but not upper case), where it was impossible to convert a capital S to lower case without knowing what its context was. > Conversion of a string to uppercase can be regarded in two ways. > Either > you replace each character with it's uppercase version, and characters > that don't have an uppercase version you leave be. This is not the case conversion process needed for centuries' worth of European writing in Latin scripts, which is unabashedly contextual. It's purely and simply a computer-oriented HACK that worked in ASCII and some versions of EBCDIC simply because they had very few letters. ASCII didn't even provide a full repertoire for English. It's not something that was much wanted for its own sake. > > Or you can try to convert the string as such to an uppercase version, > where some letters might need to be replaced by sequences of other > characters. It's like comparison: human-oriented text comparison is *not* a lexicographical extension of character ordering, not even in English. (The way that strcmp() puts 'Boxers' before 'artists' has never made much sense to people not intimately familiar with ASCII.) It's always advisable to distinguish between operations performed for the *computer's* benefit (like sorting a bunch of strings in order to eliminate duplicates or build an index) and operations performed for some *human's* benefit (like sorting entries in a telephone directory). The second kind is much much harder. > I personally usually are satisfied with the previous, but I guess > that's > anyones choice. > > And I also believe that this is one of the more serious flaws of > Unicode. It mixes semantics with syntax. So you have, for instance > several A-ring characters, for use in different type of contexts, but > that is all artificial and unfortunate. > It's like in the old days, when you had several different minus > signs on > punched cards, for different uses. Eh? I did a lot of keypunching in the old days, using both 026 and 029 keypunches. Even a few cards with a hand punch. Oh yeah, and some 96-column cards; I don't remember what that punch was called. I assure you, each of them had exactly one minus sign. Which punched cards are you talking about? Bear in mind that early punched card codes had at most 64 characters, and that the 026 and 029 keypunches didn't even have lower case letters. PL/I (designed in the 60s) even got by with just 48 characters. The BCL 6-bit character set used by Burroughs machines had only one hyphen-minus character and that was not unusual. Heck, into the 90s people using COBOL in IBM shops sometimes didn't even have semicolons on their print chains. (Yes, I really did have to mark a large student assignment written in C but printed on just such a printer, in the early 90s.) > Hmm, looking at Unicode, I can see > that they have reintroduced this ambiguity. You have hyphen-minus > (U+002D), hyphen (U+2010) and minus (U+2212) and you also have a > number > of different dashes. > Try to figure out which one you want when you are writing. As a long-standing TeX user, it couldn't be easier: The thing that links the parts of multi-element words is a hyphen. It's short. The thing that links the ends of a range like a--z or 1--10 is an en-dash. It's longer. (It's Option-Minus on a Mac.) The thing that is sort of like an extra-fat comma---used for example in parentheses like this one---is an em-dash. It's longer still. (It's Option-Shift-Minus on a Mac.) The thing you use in a mathematical formula is a minus sign and in TeX you just use the minus key. But it's clearly distinct from the other three. It looks really horrible to see people using a hyphen when they mean a dash. > > (According to one myth this "problem" actually caused the Mariner 1 to > fail and self destruct, since the poor Fortran programmer hade used a > hyphen instead of a minus for a constant. Not sure if it's true or > not, > and the web don't give a sure answer.) That's not only a mistake, it's not even the RIGHT mistake. This is supposed to be a quote from the official report: NASA-JPL-USAF Mariner R-1 Post-Flight Review Board determined that the omission of a hyphen in coded computer instructions transmitted incorrect guidance signals to Mariner spacecraft boosted by two- stage Atlas-Agena from Cape Canaveral on July 21. Omission of hyphen in data editing caused computer to swing automatically into a series of unnecessary course correction signals which threw spacecraft off course so that it had to be destroyed. It wasn't using a hyphen instead of a minus, it was OMITTING a hyphen that caused the problem. (It took me 3 minutes to find that.) > There are more examples like this, where Unicode mess things up > because > it mix the visual impression of a character with semantic meaning of > the > character.) Well, no, not really. The root problem is the political requirement for round-trip compatibility with most previous national and international character set standards. Unicode had to be bug-compatible. > > > And when I learned German in school many years ago, I was taught > that ? > was more or less the equivalent of sz. :-) It was indeed an s-z ligature, but it stands for "ss" not "sz". (Other languages may of course use it for other purposes, which just adds to the "fun".) From ok@REDACTED Thu Nov 20 04:01:02 2008 From: ok@REDACTED (Richard O'Keefe) Date: Thu, 20 Nov 2008 16:01:02 +1300 Subject: [erlang-questions] conditional expressions In-Reply-To: <208E29EE88AA4D98B5517BBA98A78B34@SSI.CORP> References: <8092dc770811141638h2a1bee2av19c04e76ce535992@mail.gmail.com><66d1c98f0811141713n6961e091ndcaae79c5cea54f0@mail.gmail.com><5A0DCFB7-B080-4371-9766-1BB58F2FFB4D@cs.otago.ac.nz><492238C9.60900@gmail.com><86BD4040-5B68-44A3-A689-CE62AB0880CC@cs.otago.ac.nz> <18723.55184.62163.949537@harpo.it.uu.se> <208E29EE88AA4D98B5517BBA98A78B34@SSI.CORP> Message-ID: On 20 Nov 2008, at 4:10 am, David Mercer wrote: > Can someone please explain the tail recursion problem with andalso? SML: fun all(f, []) = true | all(f, x::xs) = f x andalso all(f, xs); The recursive call here is a tail call: when that recursive call is finished there is nothing to be done with the result except to return it. Erlang: all(_, []) -> true; all(F, [X|Xs]) -> F(X) andalso all(F, Xs). The recursive call here is NOT a tail call, because it is semantically the equivalent of all(_, []) -> true; all(F, [X|Xs]) -> case F(X) of false -> false ; true -> R = all(F, Xs), if R == true ; R == false -> R end end. Of course SML and Haskell don't need to check because the type system means that the code that gets past the compiler couldn't possibly fail such a check. But Lisp and Smalltalk and Python don't bother making any such check, even though it _might_ fail if it _were_ done. Skipping the check on R doesn't seem to be much of a problem in practice. Loss of tail recursion here IS a problem. From ok@REDACTED Thu Nov 20 04:14:30 2008 From: ok@REDACTED (Richard O'Keefe) Date: Thu, 20 Nov 2008 16:14:30 +1300 Subject: [erlang-questions] Scharfes S (WAS: Erlang 3000?) In-Reply-To: <084FB1A70BF74B63AF14466CF82A8C34@SSI.CORP> References: <49241CFB.9000001@softjar.se> <200811191606.mAJG6oKn011499@mail.pharos-avantgard.com> <084FB1A70BF74B63AF14466CF82A8C34@SSI.CORP> Message-ID: <17CB4A3E-F32C-4673-A5BB-32EFA7C64921@cs.otago.ac.nz> On 20 Nov 2008, at 6:21 am, David Mercer wrote: > There are two use cases of case-changing that I can think of. > The other, however, is normalization, probably for comparison > purposes??i.e., case-insensitive comparisons. In that case, being > correct > typographically isn't as important as consistency in how you > represent a > character. Ignoring the Unicode normalization approaches (regarding > accents > and combining characters, etc.), a simplistic up-casing algorithm > may be all > that is needed. (1) The Unicode standard strongly recommends (with rationale) that *DOWN*casing should be used for such normalisation. (2) If "stra?e" and "STRASSE" don't normalise to the same thing, for many millions of users, the normalisation is wrong. The point at issue is that this is not a one-to-one mapping on >characters<. (That is, there is no function F such that map(F, String) will give you an appropriately normalised result.) From ok@REDACTED Thu Nov 20 04:28:21 2008 From: ok@REDACTED (Richard O'Keefe) Date: Thu, 20 Nov 2008 16:28:21 +1300 Subject: [erlang-questions] next(Erlang): "Fix up records so that records are first-class citizens and not just syntax saccharine for tuples?" In-Reply-To: <8092dc770811191445ie3e8066qf226ddae04cdb3b3@mail.gmail.com> References: <8092dc770811191445ie3e8066qf226ddae04cdb3b3@mail.gmail.com> Message-ID: <0BA8E2A5-D145-43FF-9BD1-3DDECE09EAD7@cs.otago.ac.nz> On 20 Nov 2008, at 11:45 am, damien morton wrote: > Hmm, I see - these fixed-up records would be dictionary-like data > structures, with a supporting syntax for dictionary literals and > pattern matching. They would lose the very fast lookup access that > records have, though they would gain the expandability that a > dictionary-type (proplist,hashtable,tree) data structure offers. They could still be quite fast. Until they've been implemented, we shan't know for sure. One aspect of this is that one tends to write slightly different code with frames than with records. With records, it's quite common to see f(..., R, ...) -> ...R#foo.bar... ...R#foo.ugh... ...R#foo.zoo... With frames, you write f(..., R = <{bar ~ X, ugh ~ Y, zoo ~ Z}>, ...) -> ...X... ...Y... ...Z... or f(..., R = , ...) -> if you want the extra checking. You _could_ do this with records, but it's less common. And the combined form may well be faster than several separate field accesses. > The only way I could see a tighter integration between records and > frames is if the keys were stored separately from the values, with the > keys being the "schema" and the values being the data. My proposal comes with an implementation sketch that *does* store the keys and the values separately. Up to tagging, a frame is basically {{foo,bar,ugh,zoo},X,Y,Z} and the "descriptor" part would normally be shared. This in no way impairs extensibility; the descriptor doesn't *have* to be shared. From sgrady@REDACTED Thu Nov 20 03:45:13 2008 From: sgrady@REDACTED (Steven Grady) Date: Wed, 19 Nov 2008 18:45:13 -0800 Subject: [erlang-questions] Erlang random number generator weak? In-Reply-To: <3dbc6d1c0811121340h3f29bb4di99ad8f096b6ef02b@mail.gmail.com> References: <8d1798e90811121032p2d1b6dd4w93d02bbeac3733e4@mail.gmail.com> <3dbc6d1c0811121340h3f29bb4di99ad8f096b6ef02b@mail.gmail.com> Message-ID: <5F90DD5A-F977-471F-87D2-F597DC4C7311@hi5.com> On Nov 12, 2008, at 1:40 PM, Robert Virding wrote: > Note that the number sequence from random is in fact quite good, it > uses a good algorithm. *BUT* it is deterministic if you know one > number/seed, so while it is perfectly ok for simulation and such, it > is *NOT* safe to use for cryptographic purposes! Actually, as Bob Ippolito pointed out, it's not good. The suggested method for seeding the random # generator is with the output of now/0. But it doesn't do that great a job. For instance: 9> random:seed(1227,148109,510934). {10546,1383,21000} 10> random:uniform(). 0.7772113669872482 11> random:uniform(). 0.940382527663111 12> random:uniform(). 0.9099172311315766 13> random:uniform(). 0.4748388276068418 14> random:seed(1227,148109,450288). {10546,1383,21000} 15> random:uniform(). 0.7772113669872482 16> random:uniform(). 0.940382527663111 17> random:uniform(). 0.9099172311315766 18> random:uniform(). 0.4748388276068418 Note that lines 9 and 14 use _different_ seeds, as might come out of now/0. But the random generator still generates the same values. Instead, use crypto. Bonus: no seeding required. Steven From btolputt@REDACTED Thu Nov 20 01:38:18 2008 From: btolputt@REDACTED (Benjamin Tolputt) Date: Thu, 20 Nov 2008 11:38:18 +1100 Subject: [erlang-questions] Unicode/Latin 1 (Erlang 3000?) In-Reply-To: References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20520907.post@talk.nabble.com> <3dbc6d1c0811151846v2454084dnc8830b6237ea6d6@mail.gmail.com> <87d4gvxryh.fsf@dixie.cronqvi.st> <8092dc770811161602u1ad9e09enf9e095af1e7a0df1@mail.gmail.com> <4920BE6A.5090709@bredband.net> <4923DD73.5090903@softjar.se> Message-ID: <4924B17A.3010904@bigpond.net.au> Richard O'Keefe wrote: > But it doesn't check that the input *is* Latin 1. > (One of the two mistakes I thought I saw was a mistake > on my part, but that one's real.) > to_upper_char(-137) => -137, for example. > The last clause would be better as > > 0 =< C, C =< 16#FF -> C > > As a matter of fact, I'd expect a fair bit of "Latin 1" > these days to be really Latin 9 or Windows-whatsit, > both of which have extra letters. Latin 9 has an upper case > version of 16rFF (at 16rBE). My machine has oodles of 8859-15 > locales.. Whilst I understand this subject is important to many, can we continue it under a different subject name that "Erlang 3000?" please? I, personally, am not worried so much about Latin 1 / Unicode right now, but am trying to follow the suggestions and discussion on additions/changes to Erlang as a whole. -- Regards, Benjamin Tolputt Analyst Programmer This email and any files transmitted with it are confidential to the intended recipient and may be privileged. If you have received this email inadvertently or you are not the intended recipient, you may not disseminate, distribute, copy or in any way rely on it. Further, you should notify the sender immediately and delete the email from your computer. Whilst we have taken precautions to alert us to the presence of computer viruses, we cannot guarantee that this email and any files transmitted with it are free from such viruses. From johnswolter@REDACTED Thu Nov 20 06:45:29 2008 From: johnswolter@REDACTED (john s wolter) Date: Thu, 20 Nov 2008 00:45:29 -0500 Subject: [erlang-questions] 10,000 simultaneous connections In-Reply-To: <290b3ba10811191506h51dea9a5ubbf8eccf2a7151be@mail.gmail.com> References: <24bcf1860811191449s72a34cc7ofc1bf7d972cc47c@mail.gmail.com> <290b3ba10811191506h51dea9a5ubbf8eccf2a7151be@mail.gmail.com> Message-ID: <24bcf1860811192145n3c925d4dp8a775569c8c5d63c@mail.gmail.com> Bob, Dave, t, Thank you for your educational replies, they will get me started. Most interesting to see that Erlang has already demonstrated that level of capability. That gives me confidence to see how far I can push this. This could occupy December but maybe less time then that. The coming holiday may speed things up. Do you have any other insights that may be of use? On Wed, Nov 19, 2008 at 6:06 PM, t ty wrote: > http://tsung.erlang-projects.org/user_manual.html#htoc6 > > 2008/11/19 john s wolter : > > Yes, 10,000 simultaneous connections to a server. Whew! I have to sit > down > > for a moment, I'm a little faint. Is Erlang up to the task or threads? > > (Ah, Ah,). > > Imagine a server that has to run at that level of multitasking. Right > now > > this is all blue sky thinking. How could I benchmark an individual > server's > > capability to run child threads for a web service? Next I want to > write > > some test programs that use the threads to judge application loading > issues. > > I'm hoping to start to better understand applying the Erlang system. > > > > -- > > John S. Wolter President > > Wolter Works > > Mailto:johnswolter@REDACTED > > Desk 1-734-665-1263 > > Cell: 1-734-904-8433 > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > -- John S. Wolter President Wolter Works Mailto:johnswolter@REDACTED Desk 1-734-665-1263 Cell: 1-734-904-8433 -------------- next part -------------- An HTML attachment was scrubbed... URL: From kostis@REDACTED Thu Nov 20 08:50:02 2008 From: kostis@REDACTED (Kostis Sagonas) Date: Thu, 20 Nov 2008 09:50:02 +0200 Subject: [erlang-questions] next(Erlang): "Fix up records so that records are first-class citizens and not just syntax saccharine for tuples?" In-Reply-To: <0BA8E2A5-D145-43FF-9BD1-3DDECE09EAD7@cs.otago.ac.nz> References: <8092dc770811191445ie3e8066qf226ddae04cdb3b3@mail.gmail.com> <0BA8E2A5-D145-43FF-9BD1-3DDECE09EAD7@cs.otago.ac.nz> Message-ID: <492516AA.9070706@cs.ntua.gr> Richard O'Keefe wrote: > > They could still be quite fast. Until they've been implemented, > we shan't know for sure. One aspect of this is that one tends > to write slightly different code with frames than with records. > With records, it's quite common to see > > f(..., R, ...) -> > ...R#foo.bar... > ...R#foo.ugh... > ...R#foo.zoo... > > With frames, you write > > f(..., R = <{bar ~ X, ugh ~ Y, zoo ~ Z}>, ...) -> > ...X... > ...Y... > ...Z... > > or f(..., R = , ...) -> > > if you want the extra checking. You _could_ do this with records, > but it's less common. And the combined form may well be faster than > several separate field accesses. Unrelated to the topic of records vs. structs vs. frames, but very much related to the above: For quite some time now, we have been working on a tool (called 'tidier' -- in the spirit of 'dialyzer' and 'typer', I guess) that automatically cleans up Erlang code from various bad code smells and simplifies code fragments. One of the transformations it does is exactly the one above and a bit more: it completely eliminates the use of is_record/[2,3] and moves all field accesses to the point where the record is matched. For example, it transforms the following code: f(..., R, ...) when is_record(R, foo) -> ...R#foo.bar... ...R#foo.ugh... ...R#foo.zoo... to: f(..., R = #foo{bar = X, ugh = Y, zoo = Z}, ...) -> ...X... ...Y... ...Z... (and also eliminates the R variable if it is nowhere else used). In fact, that's one the simplest transformations that the tool performs. Stay tuned! Kostis From kdronnqvist@REDACTED Thu Nov 20 09:41:57 2008 From: kdronnqvist@REDACTED (kdronnqvist@REDACTED) Date: Thu, 20 Nov 2008 09:41:57 +0100 Subject: [erlang-questions] Erlang elseif Message-ID: <65691fa00811200041yfc7a219y97a11126e0cee535@mail.gmail.com> Hi everyone I just joined the list and tried to search for information about this but I could not find anything that answered my question. The thing is that I want a general way to branch the execution of my code based on the result on an expression. Very similar to how if works but I want to be able to test expressions and not only guards. If you're thinking "then you have case" now look below at function elseif2() and you'll see my point. I wrote a couple of examples how to solve this but none of them really feels right, the logic in what I'm trying to do is really REALLY not that complicated. The functions takes an argument and prints something based on what list the argument is a member of (if any). Like this: 42> e:elseif4($Q). Member of capital I would appreciate any input on this, even if it means you're bashing all my examples below :-) BR, Daniel R?nnqvist --- Source code for my test module: ---- -module(e). -export([elseif1/1,elseif2/1,elseif3/1,elseif4/1]). -define(CAPS, "QWERTY"). -define(SMALL, "qwerty"). -define(NUMS, "123456"). %% The wierd not-so-Erlang way elseif1(A) -> lists:member(A,?CAPS) andalso begin io:format("Member of capital\n"), true end orelse lists:member(A,?SMALL) andalso begin io:format("Member of small\n"), true end orelse lists:member(A,?NUMS) andalso begin io:format("Member of nums\n"), true end orelse io:format("Not a member"). %% The no-good nested case way elseif2(A) -> case lists:member(A,?CAPS) of true -> io:format("Member of capital\n"); false -> case lists:member(A,?SMALL) of true -> io:format("Member of small\n"); false -> case lists:member(A,?NUMS) of true -> io:format("Member of nums\n"); false -> io:format("Not a member\n") end end end. %% One utterly inefficient tuple way elseif3(A) -> case {lists:member(A,?CAPS), lists:member(A,?SMALL), lists:member(A,?NUMS)} of {true,false,false} -> io:format("Member of capital\n"); {false,true,false} -> io:format("Member of small\n"); {false,false,true} -> io:format("Member of nums\n"); _ -> io:format("Not a member\n") end. %% The list comprehension way elseif4(A) -> case [begin {Name,_} = X, Name end || X <- [{caps, ?CAPS}, {small, ?SMALL}, {nums, ?NUMS}], begin {_,List} = X, lists:member(A,List) end] of [caps] -> io:format("Member of capital\n"); [small] -> io:format("Member of small\n"); [nums] -> io:format("Member of nums\n"); _ -> io:format("Not a member\n") end. -------------- next part -------------- An HTML attachment was scrubbed... URL: From john.hughes@REDACTED Thu Nov 20 10:09:29 2008 From: john.hughes@REDACTED (John Hughes) Date: Thu, 20 Nov 2008 10:09:29 +0100 Subject: [erlang-questions] Erlang elseif References: Message-ID: <1B3D5D5AB410463C82263C07FE730475@JTablet2007> Here's another list-comprehension way elseif(A) -> [io:format("Member of capital\n") || lists:member(A,?CAPS)], [io:format("Member of small\n") || lists:member(A,?SMALL)], [io:format("Member of nums\n") || lists:member(A,?NUMS)], ok. OK, it's not else-if, rather a sequence of if-thens, but it does the same job and it's short and sweet. John Hughes > From: kdronnqvist@REDACTED > Subject: [erlang-questions] Erlang elseif > To: erlang-questions@REDACTED > Message-ID: > <65691fa00811200041yfc7a219y97a11126e0cee535@REDACTED> > Content-Type: text/plain; charset="iso-8859-1" > > Hi everyone I just joined the list and tried to search for information > about > this but I could not find anything that answered my question. The thing is > that I want a general way to branch the execution of my code based on the > result on an expression. Very similar to how if works but I want to be > able > to test expressions and not only guards. If you're thinking "then you have > case" now look below at function elseif2() and you'll see my point. > > I wrote a couple of examples how to solve this but none of them really > feels > right, the logic in what I'm trying to do is really REALLY not that > complicated. The functions takes an argument and prints something based on > what list the argument is a member of (if any). Like this: > > 42> e:elseif4($Q). > Member of capital > > > I would appreciate any input on this, even if it means you're bashing all > my > examples below :-) > > BR, > Daniel R?nnqvist From attila.rajmund.nohl@REDACTED Thu Nov 20 10:26:42 2008 From: attila.rajmund.nohl@REDACTED (attila.rajmund.nohl@REDACTED) Date: Thu, 20 Nov 2008 10:26:42 +0100 (CET) Subject: [erlang-questions] Erlang elseif In-Reply-To: <65691fa00811200041yfc7a219y97a11126e0cee535@mail.gmail.com> References: <65691fa00811200041yfc7a219y97a11126e0cee535@mail.gmail.com> Message-ID: On Thu, 20 Nov 2008, kdronnqvist@REDACTED wrote: > Hi everyone I just joined the list and tried to search for information about > this but I could not find anything that answered my question. The thing is > that I want a general way to branch the execution of my code based on the > result on an expression. Very similar to how if works but I want to be able > to test expressions and not only guards. If you're thinking "then you have > case" now look below at function elseif2() and you'll see my point. > > I wrote a couple of examples how to solve this but none of them really feels > right, the logic in what I'm trying to do is really REALLY not that > complicated. The functions takes an argument and prints something based on > what list the argument is a member of (if any). Like this: > > 42> e:elseif4($Q). > Member of capital > > I would appreciate any input on this, even if it means you're bashing all my > examples below :-) > > BR, > Daniel R?nnqvist > > --- Source code for my test module: ---- > > -module(e). > > -export([elseif1/1,elseif2/1,elseif3/1,elseif4/1]). > > -define(CAPS, "QWERTY"). > -define(SMALL, "qwerty"). > -define(NUMS, "123456"). > > %% The wierd not-so-Erlang way > elseif1(A) -> > lists:member(A,?CAPS) > andalso begin > io:format("Member of capital\n"), > true > end > orelse > lists:member(A,?SMALL) > andalso begin > io:format("Member of small\n"), > true > end > orelse > lists:member(A,?NUMS) > andalso begin > io:format("Member of nums\n"), > true > end > orelse > io:format("Not a member"). What I see in lots of code is this: elsif(A) -> maybe_caps(lists:member(A, ?CAPS), A). maybe_caps(true, _) -> io:format("Member of capital\n"); maybe_caps(false, A) -> maybe_small(lists:member(A, ?SMALL), A). maybe_small(true, _) -. io:format("Member of small\n"); maybe_small(false, A) -> maybe_num(lists:member(A, ?NUMS)). maybe_num(true) -> io:format("Member of nums\n"); maybe_num(false) -> io:format("Not a member"). Bye,NAR -- "Beware of bugs in the above code; I have only proved it correct, not tried it." From bengt.kleberg@REDACTED Thu Nov 20 10:28:43 2008 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Thu, 20 Nov 2008 10:28:43 +0100 Subject: [erlang-questions] Erlang elseif In-Reply-To: <65691fa00811200041yfc7a219y97a11126e0cee535@mail.gmail.com> References: <65691fa00811200041yfc7a219y97a11126e0cee535@mail.gmail.com> Message-ID: <49252DCB.3070004@ericsson.com> Greetings, Despite the inefficiency I would use elseif3/1 unless profiling shows that it is a problem. Then I would switch to elseif2/2, and move the lists:member/2 tests around until the normal workload got treated as efficiently as possible. 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." On 2008-11-20 09:41, kdronnqvist@REDACTED wrote: > Hi everyone I just joined the list and tried to search for information > about this but I could not find anything that answered my question. The > thing is that I want a general way to branch the execution of my code > based on the result on an expression. Very similar to how if works but I > want to be able to test expressions and not only guards. If you're > thinking "then you have case" now look below at function elseif2() and > you'll see my point. > > I wrote a couple of examples how to solve this but none of them really > feels right, the logic in what I'm trying to do is really REALLY not > that complicated. The functions takes an argument and prints something > based on what list the argument is a member of (if any). Like this: > > 42> e:elseif4($Q). > Member of capital > > > I would appreciate any input on this, even if it means you're bashing > all my examples below :-) > > BR, > Daniel R?nnqvist > > --- Source code for my test module: ---- > > -module(e). > > -export([elseif1/1,elseif2/1,elseif3/1,elseif4/1]). > > -define(CAPS, "QWERTY"). > -define(SMALL, "qwerty"). > -define(NUMS, "123456"). > > %% The wierd not-so-Erlang way > elseif1(A) -> > lists:member(A,?CAPS) > andalso begin > io:format("Member of capital\n"), > true > end > orelse > lists:member(A,?SMALL) > andalso begin > io:format("Member of small\n"), > true > end > orelse > lists:member(A,?NUMS) > andalso begin > io:format("Member of nums\n"), > true > end > orelse > io:format("Not a member"). > > %% The no-good nested case way > elseif2(A) -> > case lists:member(A,?CAPS) of > true -> > io:format("Member of capital\n"); > false -> > case lists:member(A,?SMALL) of > true -> > io:format("Member of small\n"); > false -> > case lists:member(A,?NUMS) of > true -> > io:format("Member of nums\n"); > false -> > io:format("Not a member\n") > end > end > end. > > %% One utterly inefficient tuple way > elseif3(A) -> > case {lists:member(A,?CAPS), > lists:member(A,?SMALL), > lists:member(A,?NUMS)} of > {true,false,false} -> > io:format("Member of capital\n"); > {false,true,false} -> > io:format("Member of small\n"); > {false,false,true} -> > io:format("Member of nums\n"); > _ -> > io:format("Not a member\n") > end. > > %% The list comprehension way > elseif4(A) -> > case [begin > {Name,_} = X, > Name > end > || X <- [{caps, ?CAPS}, > {small, ?SMALL}, > {nums, ?NUMS}], > begin > {_,List} = X, > lists:member(A,List) > end] of > [caps] -> > io:format("Member of capital\n"); > [small] -> > io:format("Member of small\n"); > [nums] -> > io:format("Member of nums\n"); > _ -> > io:format("Not a member\n") > end. > > > > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From attila.rajmund.nohl@REDACTED Thu Nov 20 10:30:05 2008 From: attila.rajmund.nohl@REDACTED (attila.rajmund.nohl@REDACTED) Date: Thu, 20 Nov 2008 10:30:05 +0100 (CET) Subject: [erlang-questions] next(Erlang): "Fix up records so that records are first-class citizens and not just syntax saccharine for tuples?" In-Reply-To: <492516AA.9070706@cs.ntua.gr> References: <8092dc770811191445ie3e8066qf226ddae04cdb3b3@mail.gmail.com> <0BA8E2A5-D145-43FF-9BD1-3DDECE09EAD7@cs.otago.ac.nz> <492516AA.9070706@cs.ntua.gr> Message-ID: On Thu, 20 Nov 2008, Kostis Sagonas wrote: [...] > f(..., R = #foo{bar = X, ugh = Y, zoo = Z}, ...) -> > ...X... > ...Y... > ...Z... I know that this is the right Erlang style, but it's so counter-intuitive that the variable which gets the value is on the right hand side... Bye,NAR -- "Beware of bugs in the above code; I have only proved it correct, not tried it." From huss01@REDACTED Thu Nov 20 10:55:29 2008 From: huss01@REDACTED (=?ISO-8859-1?Q?H=E5kan_Huss?=) Date: Thu, 20 Nov 2008 10:55:29 +0100 Subject: [erlang-questions] Erlang elseif In-Reply-To: <65691fa00811200041yfc7a219y97a11126e0cee535@mail.gmail.com> References: <65691fa00811200041yfc7a219y97a11126e0cee535@mail.gmail.com> Message-ID: 2008/11/20 : > Hi everyone I just joined the list and tried to search for information about > this but I could not find anything that answered my question. The thing is > that I want a general way to branch the execution of my code based on the > result on an expression. Very similar to how if works but I want to be able > to test expressions and not only guards. If you're thinking "then you have > case" now look below at function elseif2() and you'll see my point. > > I wrote a couple of examples how to solve this but none of them really feels > right, the logic in what I'm trying to do is really REALLY not that > complicated. The functions takes an argument and prints something based on > what list the argument is a member of (if any). Like this: > I might go for some variation of the function clause based version suggested by NAR in this case where the number of "branches" is small. Another way to handle this is to use a list to do the branching, e.g., elseif(A) -> Notin = fun ({Chars, _Desc}) -> not lists:member(A, Chars) end, Desclist = [{?CAPS, capital}, {?SMALL, small}, {?NUMS, nums}], case lists:dropwhile(Notin, Desclist) of [{_Chars, Desc} | _] -> io:format("Member of ~p\n", [Desc]); [] -> io:format("Not a member\n") end. Regards, /H?kan Huss From richardc@REDACTED Thu Nov 20 11:30:23 2008 From: richardc@REDACTED (Richard Carlsson) Date: Thu, 20 Nov 2008 11:30:23 +0100 Subject: [erlang-questions] Erlang elseif In-Reply-To: <65691fa00811200041yfc7a219y97a11126e0cee535@mail.gmail.com> References: <65691fa00811200041yfc7a219y97a11126e0cee535@mail.gmail.com> Message-ID: <49253C3F.6080305@it.uu.se> kdronnqvist@REDACTED wrote: > I wrote a couple of examples how to solve this but none of them really > feels right, the logic in what I'm trying to do is really REALLY not > that complicated. The functions takes an argument and prints something > based on what list the argument is a member of (if any). Like this: > > 42> e:elseif4($Q). > Member of capital > > I would appreciate any input on this, even if it means you're bashing > all my examples below :-) If you want a reusable pattern, rather than a one-off hack, the best thing is to start by separating the logic and the side effects (as in your 4th example). member_of(X, Lists) -> case lists:dropwhile(fun ({A,L}) -> not lists:member(X,L) end, Lists) of [{A,_}|_] -> A; [] -> none end. print_class(C) -> case member_of(C, [{caps, ?CAPS}, {small, ?SMALL}, {nums, ?NUMS}]) of caps -> io:format("Member of capital\n"); small -> ...; nums -> ...; none -> ... end. For one-off things, prefer the threaded functions solution if there are more than 2 levels. /Richard From dmorton@REDACTED Thu Nov 20 11:41:04 2008 From: dmorton@REDACTED (damien morton) Date: Thu, 20 Nov 2008 21:41:04 +1100 Subject: [erlang-questions] next(Erlang) In-Reply-To: <8092dc770811162007g6220c12bh4e7ac2973614fed2@mail.gmail.com> References: <8092dc770811162007g6220c12bh4e7ac2973614fed2@mail.gmail.com> Message-ID: <8092dc770811200241v33d80622vb10f0afc65386a34@mail.gmail.com> next(Erlang) -> go(" http://moderator.appspot.com/#16/e=bbc4 "). The above Google Moderator site allows you to make, discuss and vote on proposals for a notional future revision of Erlang. Feel free to drop by and add to the discussions. From thomasl_erlang@REDACTED Thu Nov 20 11:14:08 2008 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Thu, 20 Nov 2008 02:14:08 -0800 (PST) Subject: [erlang-questions] next(Erlang): "Fix up records so that records are first-class citizens and not just syntax saccharine for tuples?" In-Reply-To: Message-ID: <656289.73190.qm@web111406.mail.gq1.yahoo.com> --- On Thu, 11/20/08, attila.rajmund.nohl@REDACTED wrote: > On Thu, 20 Nov 2008, Kostis Sagonas wrote: > [...] > > f(..., R = #foo{bar = X, ugh = Y, zoo = Z}, ...) > -> > > ...X... > > ...Y... > > ...Z... > > I know that this is the right Erlang style, but it's so > counter-intuitive that > the variable which gets the value is on the right hand > side... The intuition is that terms (constants, tuples, records, lists, ...) look more or less the same when written in expressions or patterns. This idea is not fully carried through, however. The decision not to permit R#foo{...} in patterns (with the same meaning as R = #foo{...}, natch) tends to trip me up, for instance :-) Best, Thomas From john.hughes@REDACTED Thu Nov 20 12:40:04 2008 From: john.hughes@REDACTED (John Hughes) Date: Thu, 20 Nov 2008 12:40:04 +0100 Subject: [erlang-questions] Rational arithmetic library? References: Message-ID: Anyone have a good rational number arithmetic library? I can't be the first to need one, surely... The background is that I need to do some EXACT arithmetic on non-integer numbers, so floating point won't do. Of course, rational arithmetic is easy to implement--and I've done so--but I realise there are choices over where exactly to take gcds, that may have a big impact on performance once the numbers involved start getting large. It would be nice just to use a library that has already been tuned, rather than need to tune my own. I will say this for mine though: it's very thoroughly tested! If you're interested, it's at http://www.cs.chalmers.se/~rjmh/rational.erl John From rtrlists@REDACTED Thu Nov 20 12:58:23 2008 From: rtrlists@REDACTED (Robert Raschke) Date: Thu, 20 Nov 2008 11:58:23 +0000 Subject: [erlang-questions] Rational arithmetic library? In-Reply-To: References: Message-ID: <6a3ae47e0811200358t41375225if3427e92491e51f8@mail.gmail.com> On Thu, Nov 20, 2008 at 11:40 AM, John Hughes wrote: > Anyone have a good rational number arithmetic library? I can't be the first > to need one, surely... Might be worth considering using something like J. Don't think it would be too get J and Erlang communicating. J: http://www.jsoftware.com/ Robby From bob@REDACTED Thu Nov 20 12:59:26 2008 From: bob@REDACTED (Bob Ippolito) Date: Thu, 20 Nov 2008 03:59:26 -0800 Subject: [erlang-questions] next(Erlang): "Fix up records so that records are first-class citizens and not just syntax saccharine for tuples?" In-Reply-To: <656289.73190.qm@web111406.mail.gq1.yahoo.com> References: <656289.73190.qm@web111406.mail.gq1.yahoo.com> Message-ID: <6a36e7290811200359j3956fb30i544f4c0ac329319f@mail.gmail.com> On Thu, Nov 20, 2008 at 2:14 AM, Thomas Lindgren wrote: > > > > --- On Thu, 11/20/08, attila.rajmund.nohl@REDACTED wrote: >> On Thu, 20 Nov 2008, Kostis Sagonas wrote: >> [...] >> > f(..., R = #foo{bar = X, ugh = Y, zoo = Z}, ...) >> -> >> > ...X... >> > ...Y... >> > ...Z... >> >> I know that this is the right Erlang style, but it's so >> counter-intuitive that >> the variable which gets the value is on the right hand >> side... > > The intuition is that terms (constants, tuples, records, lists, ...) look more or less the same when written in expressions or patterns. > > This idea is not fully carried through, however. The decision not to permit R#foo{...} in patterns (with the same meaning as R = #foo{...}, natch) tends to trip me up, for instance :-) I constantly get tripped up by that, too. -bob From kdronnqvist@REDACTED Thu Nov 20 13:10:21 2008 From: kdronnqvist@REDACTED (kdronnqvist@REDACTED) Date: Thu, 20 Nov 2008 13:10:21 +0100 Subject: [erlang-questions] Erlang elseif In-Reply-To: <49253C3F.6080305@it.uu.se> References: <65691fa00811200041yfc7a219y97a11126e0cee535@mail.gmail.com> <49253C3F.6080305@it.uu.se> Message-ID: <65691fa00811200410k38326420t2a6fe93685345350@mail.gmail.com> Thanks for your solutions, they give me good insight in how the Erlang world would solve this. I have one more way of solving this that I think is kind of clean and it would be efficient because the lists:member() would need to be evaluated once a match is found. elseif5(A) -> try lists:member(A,?CAPS) andalso throw(caps), lists:member(A,?SMALL) andalso throw(small), lists:member(A,?NUMS) andalso throw(nums), throw(none) catch throw:caps -> io:format("Member of capital\n"); throw:small -> io:format("Member of small\n"); throw:nums -> io:format("Member of nums\n"); throw:none -> io:format("Not a member\n"); X:Y -> io:format("Bad exception ~p:~p\n",[X,Y]) end. However, some might think this is the wrong way of handling exceptions. What do you think? BR, Daniel R?nnqvist 2008/11/20 Richard Carlsson > kdronnqvist@REDACTED wrote: > > I wrote a couple of examples how to solve this but none of them really > > feels right, the logic in what I'm trying to do is really REALLY not > > that complicated. The functions takes an argument and prints something > > based on what list the argument is a member of (if any). Like this: > > > > 42> e:elseif4($Q). > > Member of capital > > > > I would appreciate any input on this, even if it means you're bashing > > all my examples below :-) > > If you want a reusable pattern, rather than a one-off hack, > the best thing is to start by separating the logic and the > side effects (as in your 4th example). > > member_of(X, Lists) -> > case lists:dropwhile(fun ({A,L}) -> not lists:member(X,L) end, Lists) of > [{A,_}|_] -> A; > [] -> none > end. > > print_class(C) -> > case member_of(C, [{caps, ?CAPS}, {small, ?SMALL}, {nums, ?NUMS}]) of > caps -> io:format("Member of capital\n"); > small -> ...; > nums -> ...; > none -> ... > end. > > > For one-off things, prefer the threaded functions solution if there > are more than 2 levels. > > /Richard > -------------- next part -------------- An HTML attachment was scrubbed... URL: From thomasl_erlang@REDACTED Thu Nov 20 13:17:27 2008 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Thu, 20 Nov 2008 04:17:27 -0800 (PST) Subject: [erlang-questions] Erlang 3000? In-Reply-To: <8092dc770811191227h5058121dkc25ab3927d98b080@mail.gmail.com> Message-ID: <513593.37413.qm@web111413.mail.gq1.yahoo.com> --- On Wed, 11/19/08, damien morton wrote: > git is probably the most user unfriendly SCM tool I have > come across. > > Is the SVN/CVS plus web-based browsing and code review > using google > code not acceptable? We switched to git some time ago, and it now seems unthinkable to go back to svn. I'll confess I'm just using a small selection of its bells and whistles though. (Maybe Mercurial or Bazaar have the same basic gains too, I haven't really checked. They seem less ornate at least.) Best, Thomas From dmorton@REDACTED Thu Nov 20 14:03:21 2008 From: dmorton@REDACTED (damien morton) Date: Fri, 21 Nov 2008 00:03:21 +1100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <513593.37413.qm@web111413.mail.gq1.yahoo.com> References: <8092dc770811191227h5058121dkc25ab3927d98b080@mail.gmail.com> <513593.37413.qm@web111413.mail.gq1.yahoo.com> Message-ID: <8092dc770811200503h2869c51lc4e79746e17064a1@mail.gmail.com> I guess the question is more about code review tools than SCM tools. I took a look at github, and they have a wiki feature, but not the detailed code review features of google-code. On Thu, Nov 20, 2008 at 11:17 PM, Thomas Lindgren wrote: > > --- On Wed, 11/19/08, damien morton wrote: >> git is probably the most user unfriendly SCM tool I have >> come across. >> >> Is the SVN/CVS plus web-based browsing and code review >> using google >> code not acceptable? > > We switched to git some time ago, and it now seems unthinkable to go back to svn. I'll confess I'm just using a small selection of its bells and whistles though. > > (Maybe Mercurial or Bazaar have the same basic gains too, I haven't really checked. They seem less ornate at least.) > > Best, > Thomas > > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From dmorton@REDACTED Thu Nov 20 14:08:24 2008 From: dmorton@REDACTED (damien morton) Date: Fri, 21 Nov 2008 00:08:24 +1100 Subject: [erlang-questions] Erlang elseif In-Reply-To: <65691fa00811200410k38326420t2a6fe93685345350@mail.gmail.com> References: <65691fa00811200041yfc7a219y97a11126e0cee535@mail.gmail.com> <49253C3F.6080305@it.uu.se> <65691fa00811200410k38326420t2a6fe93685345350@mail.gmail.com> Message-ID: <8092dc770811200508h5fb4585ctd2282adcda750c52@mail.gmail.com> traditionally, at least in C, this stuff is done with a bitvector, or rather a vector of bits. you would declare #define CAPS 1 #define SMALL 2 #define NUMS 4 const unsigned bits[256] = { ..., CAPS, CAPS, CAPS, ..., SMALL, SMALL, SMALL, ... } #define IS_CAPS(x) (bits[x] & CAPS) #define IS_ALPHANUM(x) (bits[x] | | CAPS | SMALL | NUMS) Cant see any reason why you wouldnt do the same in erlang, but perhaps you are only using characters as an example? 2008/11/20 : > Thanks for your solutions, they give me good insight in how the Erlang world > would solve this. I have one more way of solving this that I think is kind > of clean and it would be efficient because the lists:member() would need to > be evaluated once a match is found. > > elseif5(A) -> > try > lists:member(A,?CAPS) andalso throw(caps), > lists:member(A,?SMALL) andalso throw(small), > lists:member(A,?NUMS) andalso throw(nums), > throw(none) > catch > throw:caps -> io:format("Member of capital\n"); > throw:small -> io:format("Member of small\n"); > throw:nums -> io:format("Member of nums\n"); > throw:none -> io:format("Not a member\n"); > X:Y -> io:format("Bad exception ~p:~p\n",[X,Y]) > end. > > However, some might think this is the wrong way of handling exceptions. What > do you think? > > BR, > Daniel R?nnqvist > > > 2008/11/20 Richard Carlsson >> >> kdronnqvist@REDACTED wrote: >> > I wrote a couple of examples how to solve this but none of them really >> > feels right, the logic in what I'm trying to do is really REALLY not >> > that complicated. The functions takes an argument and prints something >> > based on what list the argument is a member of (if any). Like this: >> > >> > 42> e:elseif4($Q). >> > Member of capital >> > >> > I would appreciate any input on this, even if it means you're bashing >> > all my examples below :-) >> >> If you want a reusable pattern, rather than a one-off hack, >> the best thing is to start by separating the logic and the >> side effects (as in your 4th example). >> >> member_of(X, Lists) -> >> case lists:dropwhile(fun ({A,L}) -> not lists:member(X,L) end, Lists) of >> [{A,_}|_] -> A; >> [] -> none >> end. >> >> print_class(C) -> >> case member_of(C, [{caps, ?CAPS}, {small, ?SMALL}, {nums, ?NUMS}]) of >> caps -> io:format("Member of capital\n"); >> small -> ...; >> nums -> ...; >> none -> ... >> end. >> >> >> For one-off things, prefer the threaded functions solution if there >> are more than 2 levels. >> >> /Richard > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From richardc@REDACTED Thu Nov 20 14:13:52 2008 From: richardc@REDACTED (Richard Carlsson) Date: Thu, 20 Nov 2008 14:13:52 +0100 Subject: [erlang-questions] Erlang elseif In-Reply-To: <65691fa00811200410k38326420t2a6fe93685345350@mail.gmail.com> References: <65691fa00811200041yfc7a219y97a11126e0cee535@mail.gmail.com> <49253C3F.6080305@it.uu.se> <65691fa00811200410k38326420t2a6fe93685345350@mail.gmail.com> Message-ID: <49256290.8060100@it.uu.se> kdronnqvist@REDACTED wrote: > Thanks for your solutions, they give me good insight in how the Erlang > world would solve this. I have one more way of solving this that I think > is kind of clean and it would be efficient because the lists:member() > would need to be evaluated once a match is found. > > elseif5(A) -> > try > lists:member(A,?CAPS) andalso throw(caps), > lists:member(A,?SMALL) andalso throw(small), > lists:member(A,?NUMS) andalso throw(nums), > throw(none) > catch > throw:caps -> io:format("Member of capital\n"); > throw:small -> io:format("Member of small\n"); > throw:nums -> io:format("Member of nums\n"); > throw:none -> io:format("Not a member\n"); > X:Y -> io:format("Bad exception ~p:~p\n",[X,Y]) > end. > > However, some might think this is the wrong way of handling exceptions. > What do you think? It's not terrible. :-) Minor points: you don't have to write the 'throw:', since that is the default, and you should probably just skip the X:Y case altogether - let any other exceptions fall through. /Richard From rvirding@REDACTED Thu Nov 20 14:16:34 2008 From: rvirding@REDACTED (Robert Virding) Date: Thu, 20 Nov 2008 14:16:34 +0100 Subject: [erlang-questions] Erlang elseif In-Reply-To: <65691fa00811200410k38326420t2a6fe93685345350@mail.gmail.com> References: <65691fa00811200041yfc7a219y97a11126e0cee535@mail.gmail.com> <49253C3F.6080305@it.uu.se> <65691fa00811200410k38326420t2a6fe93685345350@mail.gmail.com> Message-ID: <3dbc6d1c0811200516h5067efeq7b40d15d45ebc9a4@mail.gmail.com> In one respect this is not too bad. We have always viewed throw/catch not as an exception but as a non-local return, so you are not really generating an exception. This is an unfortunate side effect of having a try which catches everything, catch has the same problem. I *know* that you can choose what to catch in try, but it does place it at the same "level" as exceptions. This is perhaps a suggestion for Erlang3000, try for exits/exceptions and throw/catch as a matching pair where catch only catches throws. And one extra suggestion I can't help but make is to use LFE and do: (cond ((: lists member a caps) (: io format '"Member of capitals\n")) ((: lists member a small) (: io format '"Member of smalls\n")) ((: lists member a nums) (: io format '"Member of nums\n")) (else (: io format '"Member of capitals\n"))) :-) Robert 2008/11/20 > Thanks for your solutions, they give me good insight in how the Erlang > world would solve this. I have one more way of solving this that I think is > kind of clean and it would be efficient because the lists:member() would > need to be evaluated once a match is found. > > elseif5(A) -> > try > lists:member(A,?CAPS) andalso throw(caps), > lists:member(A,?SMALL) andalso throw(small), > lists:member(A,?NUMS) andalso throw(nums), > throw(none) > catch > throw:caps -> io:format("Member of capital\n"); > throw:small -> io:format("Member of small\n"); > throw:nums -> io:format("Member of nums\n"); > throw:none -> io:format("Not a member\n"); > X:Y -> io:format("Bad exception ~p:~p\n",[X,Y]) > end. > > However, some might think this is the wrong way of handling exceptions. > What do you think? > > BR, > Daniel R?nnqvist > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kdronnqvist@REDACTED Thu Nov 20 14:19:29 2008 From: kdronnqvist@REDACTED (=?ISO-8859-1?Q?Daniel_R=F6nnqvist?=) Date: Thu, 20 Nov 2008 14:19:29 +0100 Subject: [erlang-questions] Erlang elseif In-Reply-To: <8092dc770811200508h5fb4585ctd2282adcda750c52@mail.gmail.com> References: <65691fa00811200041yfc7a219y97a11126e0cee535@mail.gmail.com> <49253C3F.6080305@it.uu.se> <65691fa00811200410k38326420t2a6fe93685345350@mail.gmail.com> <8092dc770811200508h5fb4585ctd2282adcda750c52@mail.gmail.com> Message-ID: <65691fa00811200519o11951ba8if1b370ef027507e4@mail.gmail.com> Yes the list:member is only an example of an expression I would like to be able to use. //Daniel 2008/11/20 damien morton > traditionally, at least in C, this stuff is done with a bitvector, or > rather a vector of bits. > > you would declare > > #define CAPS 1 > #define SMALL 2 > #define NUMS 4 > > const unsigned bits[256] = { ..., CAPS, CAPS, CAPS, ..., SMALL, SMALL, > SMALL, ... } > > #define IS_CAPS(x) (bits[x] & CAPS) > #define IS_ALPHANUM(x) (bits[x] | | CAPS | SMALL | NUMS) > > Cant see any reason why you wouldnt do the same in erlang, but perhaps > you are only using characters as an example? > > 2008/11/20 : > > Thanks for your solutions, they give me good insight in how the Erlang > world > > would solve this. I have one more way of solving this that I think is > kind > > of clean and it would be efficient because the lists:member() would need > to > > be evaluated once a match is found. > > > > elseif5(A) -> > > try > > lists:member(A,?CAPS) andalso throw(caps), > > lists:member(A,?SMALL) andalso throw(small), > > lists:member(A,?NUMS) andalso throw(nums), > > throw(none) > > catch > > throw:caps -> io:format("Member of capital\n"); > > throw:small -> io:format("Member of small\n"); > > throw:nums -> io:format("Member of nums\n"); > > throw:none -> io:format("Not a member\n"); > > X:Y -> io:format("Bad exception ~p:~p\n",[X,Y]) > > end. > > > > However, some might think this is the wrong way of handling exceptions. > What > > do you think? > > > > BR, > > Daniel R?nnqvist > > > > > > 2008/11/20 Richard Carlsson > >> > >> kdronnqvist@REDACTED wrote: > >> > I wrote a couple of examples how to solve this but none of them really > >> > feels right, the logic in what I'm trying to do is really REALLY not > >> > that complicated. The functions takes an argument and prints something > >> > based on what list the argument is a member of (if any). Like this: > >> > > >> > 42> e:elseif4($Q). > >> > Member of capital > >> > > >> > I would appreciate any input on this, even if it means you're bashing > >> > all my examples below :-) > >> > >> If you want a reusable pattern, rather than a one-off hack, > >> the best thing is to start by separating the logic and the > >> side effects (as in your 4th example). > >> > >> member_of(X, Lists) -> > >> case lists:dropwhile(fun ({A,L}) -> not lists:member(X,L) end, Lists) > of > >> [{A,_}|_] -> A; > >> [] -> none > >> end. > >> > >> print_class(C) -> > >> case member_of(C, [{caps, ?CAPS}, {small, ?SMALL}, {nums, ?NUMS}]) of > >> caps -> io:format("Member of capital\n"); > >> small -> ...; > >> nums -> ...; > >> none -> ... > >> end. > >> > >> > >> For one-off things, prefer the threaded functions solution if there > >> are more than 2 levels. > >> > >> /Richard > > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From vladdu55@REDACTED Thu Nov 20 14:22:34 2008 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Thu, 20 Nov 2008 14:22:34 +0100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <8092dc770811200503h2869c51lc4e79746e17064a1@mail.gmail.com> References: <8092dc770811191227h5058121dkc25ab3927d98b080@mail.gmail.com> <513593.37413.qm@web111413.mail.gq1.yahoo.com> <8092dc770811200503h2869c51lc4e79746e17064a1@mail.gmail.com> Message-ID: <95be1d3b0811200522u257de936n9c73ed6775a5c890@mail.gmail.com> Hi, On Thu, Nov 20, 2008 at 14:03, damien morton wrote: > I guess the question is more about code review tools than SCM tools. > I took a look at github, and they have a wiki feature, but not the > detailed code review features of google-code. One possible problem with google-code is that they only allow a limited selection of OSS licenses, and the Erlang license isn't amongst them. regards, Vlad From dmorton@REDACTED Thu Nov 20 14:40:30 2008 From: dmorton@REDACTED (damien morton) Date: Fri, 21 Nov 2008 00:40:30 +1100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <95be1d3b0811200522u257de936n9c73ed6775a5c890@mail.gmail.com> References: <8092dc770811191227h5058121dkc25ab3927d98b080@mail.gmail.com> <513593.37413.qm@web111413.mail.gq1.yahoo.com> <8092dc770811200503h2869c51lc4e79746e17064a1@mail.gmail.com> <95be1d3b0811200522u257de936n9c73ed6775a5c890@mail.gmail.com> Message-ID: <8092dc770811200540h2f8ca8faga069307c52670e28@mail.gmail.com> Youre right about the license issue - and they seem to have a go-slow on adding new licenses, for example there are requests from 2007 for a "Public Domain" license which havent been implemented yet. I think, in principle, the goal should be to find and use existing tools where possible. I found, on google-code, some review software which seems to have similar features to google-code itself: http://www.review-board.org/users.php - unfortunately, it doesnt appear to support git. On Fri, Nov 21, 2008 at 12:22 AM, Vlad Dumitrescu wrote: > Hi, > > On Thu, Nov 20, 2008 at 14:03, damien morton wrote: >> I guess the question is more about code review tools than SCM tools. >> I took a look at github, and they have a wiki feature, but not the >> detailed code review features of google-code. > > One possible problem with google-code is that they only allow a > limited selection of OSS licenses, and the Erlang license isn't > amongst them. > > regards, > Vlad > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From twoggle@REDACTED Thu Nov 20 15:03:15 2008 From: twoggle@REDACTED (Tim Fletcher) Date: Thu, 20 Nov 2008 06:03:15 -0800 (PST) Subject: [erlang-questions] Erlang 3000? In-Reply-To: <8092dc770811191227h5058121dkc25ab3927d98b080@mail.gmail.com> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20081118001602.GC1809@h216-235-12-168.host.egate.net> <3dbc6d1c0811171632t369eb208u5bebfd0f2a102af@mail.gmail.com> <20081118005024.GD1809@h216-235-12-168.host.egate.net> <3dbc6d1c0811171710m483e9ffbx35c8a154c370e05d@mail.gmail.com> <20081118011952.GE1809@h216-235-12-168.host.egate.net> <5ea453f90811171825g3345284ek7c2f31635fdf3b9c@mail.gmail.com> <4922692B.3030506@ericsson.com> <9b08084c0811180058x227977c6x2446aa3a99ed2112@mail.gmail.com> <208dea58-540f-45b0-91c6-c865a3ffa739@g38g2000yqn.googlegroups.com> <8092dc770811191227h5058121dkc25ab3927d98b080@mail.gmail.com> Message-ID: <539a09e7-4194-427b-bafd-83c06c504d07@v15g2000yqn.googlegroups.com> > git is probably the most user unfriendly SCM tool I have come across. I only used git as an example because that's what I'm familiar with. I don't have much experience with the other distributed SCMs, but I think the same would be true for them as well. > I guess the question is more about code review tools than SCM tools. Sure. My point was that with a distributed SCM you don't need a separate tool to review code. > Is the SVN/CVS plus web-based browsing and code review using google > code not acceptable? It's acceptable, but it raises the barrier to contribution. With the Google Code setup a contributor needs to have a Google account (not everyone does), and be given explicit access to the project (overhead for project admins). They would then have to participate in code review discussion, *in addition* to making the changes to the code (more work for everyone). With a distributed SCM, a contributor could make changes immediately. Publishing the changes requires a bit more effort, but I think the overall workflow is easier. From vychodil.hynek@REDACTED Thu Nov 20 15:11:52 2008 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Thu, 20 Nov 2008 15:11:52 +0100 Subject: [erlang-questions] Fwd: Report errors when using "-detached" option In-Reply-To: <49231BD3.6080507@hyber.org> References: <20081112224818.GE9968@delora.autosys.us> <491D7BA2.4000704@hyber.org> <491D8649.2020701@niclux.org> <3FD73867-982C-44AB-BD2D-3CAA07636040@gmail.com> <49231BD3.6080507@hyber.org> Message-ID: <20081120141153.C095E24065@relay.gooddata.com> No, it isn't. $ erl -eval 'halt(77).' Erlang (BEAM) emulator version 5.6.3 [source] [smp:2] [async-threads:0] [hipe] [kernel-poll:false] $ echo $? 77 $ erl -detached -eval 'halt(77).' $ echo $? 0 On Tue, Nov 18, 2008 at 8:47 PM, Claes Wikstrom wrote: > ERLANG wrote: > > Hi Nicolas, > > > >>>> This is indeed a real problem. If daemon startup fails, you > >>>> typically > >>>> want to indicate that through a call to exit(error_code) so that the > >>>> invoker can check $? > >>>> > >>> Hmmm. Calling "exit(error_code)" isn't reported to the invoker. > >>> So $? always equals to 0. > >>> > >>> Is this an expected behaviour of calling "exit(error_code)" when > >>> using > >>> "-detached" flag. > >>> > >> halt(error_code) works. > > > > No, It doesn't. > > > > Yes it does, > > [klacke@REDACTED]~ > erl > Erlang (BEAM) emulator version 5.6.5 [source] [smp:2] [async-threads:0] > [kernel-poll:false] > > Eshell V5.6.5 (abort with ^G) > 1> halt(77). > [klacke@REDACTED]~ > echo $? > 77 > > > But that's not the point. What's needed is to fork(), let the new code run > for a while and check config/whatever, if all is well it calls foo:bar(ok) > and the > invoker eventually gets a status code 0, whereas if the forked process > (beam) > calls foo:bar({error, Code}) the invoker of erl -detached2 ... gets Code > in the UNIX shell > > > /klacke > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- --Hynek (Pichi) Vychodil -------------- next part -------------- An HTML attachment was scrubbed... URL: From dmorton@REDACTED Thu Nov 20 15:11:55 2008 From: dmorton@REDACTED (damien morton) Date: Fri, 21 Nov 2008 01:11:55 +1100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <539a09e7-4194-427b-bafd-83c06c504d07@v15g2000yqn.googlegroups.com> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20081118005024.GD1809@h216-235-12-168.host.egate.net> <3dbc6d1c0811171710m483e9ffbx35c8a154c370e05d@mail.gmail.com> <20081118011952.GE1809@h216-235-12-168.host.egate.net> <5ea453f90811171825g3345284ek7c2f31635fdf3b9c@mail.gmail.com> <4922692B.3030506@ericsson.com> <9b08084c0811180058x227977c6x2446aa3a99ed2112@mail.gmail.com> <208dea58-540f-45b0-91c6-c865a3ffa739@g38g2000yqn.googlegroups.com> <8092dc770811191227h5058121dkc25ab3927d98b080@mail.gmail.com> <539a09e7-4194-427b-bafd-83c06c504d07@v15g2000yqn.googlegroups.com> Message-ID: <8092dc770811200611u7ff845bak172234fc47520ace@mail.gmail.com> On Fri, Nov 21, 2008 at 1:03 AM, Tim Fletcher wrote: >> I guess the question is more about code review tools than SCM tools. > > Sure. My point was that with a distributed SCM you don't need a > separate tool to review code. Im not sure that's true. Its not just a matter of reviewing checkins, but also of being able to make comment on existing code. An excellent feature of the google code tool and the other one I posted are the ability for reviewers to make line by line comments on code. As far as I know thats not possible with SCM alone (be it git, svn, cvs or whatever). From drcabana@REDACTED Thu Nov 20 15:18:24 2008 From: drcabana@REDACTED (David Cabana) Date: Thu, 20 Nov 2008 09:18:24 -0500 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <539a09e7-4194-427b-bafd-83c06c504d07@v15g2000yqn.googlegroups.com> References: <8092dc770811151054j5938d941gd4265585f1950314@mail.gmail.com> <20081118005024.GD1809@h216-235-12-168.host.egate.net> <3dbc6d1c0811171710m483e9ffbx35c8a154c370e05d@mail.gmail.com> <20081118011952.GE1809@h216-235-12-168.host.egate.net> <5ea453f90811171825g3345284ek7c2f31635fdf3b9c@mail.gmail.com> <4922692B.3030506@ericsson.com> <9b08084c0811180058x227977c6x2446aa3a99ed2112@mail.gmail.com> <208dea58-540f-45b0-91c6-c865a3ffa739@g38g2000yqn.googlegroups.com> <8092dc770811191227h5058121dkc25ab3927d98b080@mail.gmail.com> <539a09e7-4194-427b-bafd-83c06c504d07@v15g2000yqn.googlegroups.com> Message-ID: <44ed5e0f0811200618sff3fd9bkd7eee01e7ef3d59e@mail.gmail.com> > git is probably the most user unfriendly SCM tool I have come across. > > >>I only used git as an example because that's what I'm familiar with. I > >>don't have much experience with the other distributed SCMs, but I > >>think the same would be true for them as well. > > Not so. Mercurial is a fast, modern, distributed version tool that is not at all hard to learn. Spend twenty minutes on the tutorials and you'll be rocking. -------------- next part -------------- An HTML attachment was scrubbed... URL: From dave.smith.to@REDACTED Thu Nov 20 15:30:49 2008 From: dave.smith.to@REDACTED (Dave Smith) Date: Thu, 20 Nov 2008 09:30:49 -0500 Subject: [erlang-questions] Rational arithmetic library? In-Reply-To: <6a3ae47e0811200358t41375225if3427e92491e51f8@mail.gmail.com> References: <6a3ae47e0811200358t41375225if3427e92491e51f8@mail.gmail.com> Message-ID: <5ea453f90811200630ha0fc5b9h4a5c1c81df7adf8@mail.gmail.com> I have been working on a decimal application. This is a linked-in driver application backed by the decNumberhttp://speleotrove.com/decimal/ library. It's crude at this point, and I haven't decided on the interface format. I didn't plan to release it yet, but I'll do a little cleanup today and make the code available for review. This is not a rational library, but a decimal fixed-point (or decimal floating-point) library. If you really need rational arithmetic, consider creating a driver backed by gmp (http://gmplib.org/) D 2008/11/20 Robert Raschke > On Thu, Nov 20, 2008 at 11:40 AM, John Hughes > wrote: > > Anyone have a good rational number arithmetic library? I can't be the > first > > to need one, surely... > > Might be worth considering using something like J. Don't think it > would be too get J and Erlang communicating. > > J: http://www.jsoftware.com/ > > Robby > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From vychodil.hynek@REDACTED Thu Nov 20 15:59:50 2008 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Thu, 20 Nov 2008 15:59:50 +0100 Subject: [erlang-questions] Azul Systems - up to 864 cores "optimised for Java" In-Reply-To: <997C70E3-A2C7-49F6-A895-394E9E19B4B2@telegraphics.com.au> References: <997C70E3-A2C7-49F6-A895-394E9E19B4B2@telegraphics.com.au> Message-ID: <20081120145951.D437B24063@relay.gooddata.com> More interesting should be HW optimized for Erlang. I guess that should be simpler. On Wed, Nov 19, 2008 at 4:41 PM, Toby Thain wrote: > I wonder how Erlang would go. > > http://blogs.azulsystems.com/cliff/2008/11/a-brief-conversation-with- > david-moon.html > > Brought back memories of similar-sized Transputer systems, and many > echoes of the Transputer architecture. > > --Toby > > (Via wingolog, http://wingolog.org/archives/2008/11/19/dangling- > pointers ) > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- --Hynek (Pichi) Vychodil -------------- next part -------------- An HTML attachment was scrubbed... URL: From vances@REDACTED Thu Nov 20 16:09:10 2008 From: vances@REDACTED (Vance Shipley) Date: Thu, 20 Nov 2008 10:09:10 -0500 Subject: [erlang-questions] Pretty printing records Message-ID: <20081120150909.GD229@h216-235-12-168.host.egate.net> The shell now does a nice job of pretty printing records, once you've loaded them with rr(). Currently I'm writing test suites using common_test and would love the web page reports generated to pretty print the (record) return values. Is there any easy way to do that? -Vance From erlang-questions_efine@REDACTED Thu Nov 20 16:21:30 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Thu, 20 Nov 2008 10:21:30 -0500 Subject: [erlang-questions] Erlang elseif In-Reply-To: <8092dc770811200508h5fb4585ctd2282adcda750c52@mail.gmail.com> References: <65691fa00811200041yfc7a219y97a11126e0cee535@mail.gmail.com> <49253C3F.6080305@it.uu.se> <65691fa00811200410k38326420t2a6fe93685345350@mail.gmail.com> <8092dc770811200508h5fb4585ctd2282adcda750c52@mail.gmail.com> Message-ID: <6c2563b20811200721t17474d47wdddbf43d6d5b1f51@mail.gmail.com> On Thu, Nov 20, 2008 at 8:08 AM, damien morton wrote: > traditionally, at least in C, this stuff is done with a bitvector, or > rather a vector of bits. > > Here's my 'C-like' contribution. It's pretty quick, too (the time below excludes the time taken to read the file into a binary). 32> charclass:bm("/home/efine/erlang/otp_src_R12B-3.tar.gz"). File "/home/efine/erlang/otp_src_R12B-3.tar.gz" size is 42195557 bytes Speed = 23965801 bytes/sec -module(charclass). -define(CLS_CNTRL, 2#00000001). -define(CLS_UPPER, 2#00000010). -define(CLS_LOWER, 2#00000100). -define(CLS_DIGIT, 2#00001000). -define(CLS_PUNCT, 2#00010000). -define(CLS_BLANK, 2#00100000). -define(CLS_SPACE, 2#01000000). -define(CLS_8BIT, 2#10000000). -define(CLS_ALPHA, (?CLS_UPPER bor ?CLS_LOWER)). -define(CLS_ALNUM, (?CLS_UPPER bor ?CLS_LOWER bor ?CLS_DIGIT)). -define(CLS_PRINT, (bnot (?CLS_CNTRL bor ?CLS_8BIT))). -compile([export_all]). is_cntrl(Ch) -> class(Ch) band ?CLS_CNTRL /= 0. is_upper(Ch) -> class(Ch) band ?CLS_UPPER /= 0. is_lower(Ch) -> class(Ch) band ?CLS_LOWER /= 0. is_digit(Ch) -> class(Ch) band ?CLS_DIGIT /= 0. is_punct(Ch) -> class(Ch) band ?CLS_PUNCT /= 0. is_alpha(Ch) -> class(Ch) band ?CLS_ALPHA /= 0. is_alnum(Ch) -> class(Ch) band ?CLS_ALNUM /= 0. is_blank(Ch) -> class(Ch) band ?CLS_BLANK /= 0. is_space(Ch) -> class(Ch) band ?CLS_SPACE /= 0. is_print(Ch) -> class(Ch) band ?CLS_PRINT /= 0. is_8bit(Ch) -> class(Ch) band ?CLS_8BIT /= 0. class_names(Ch) -> Cls = class(Ch), Masks = [ ?CLS_UPPER, ?CLS_LOWER, ?CLS_DIGIT, ?CLS_PUNCT, ?CLS_PRINT, ?CLS_BLANK, ?CLS_SPACE, ?CLS_ALPHA, ?CLS_ALNUM, ?CLS_CNTRL, ?CLS_8BIT ], [class_name(Mask) || Mask <- Masks, Cls band Mask /= 0]. class_name(?CLS_CNTRL) -> cntrl; class_name(?CLS_UPPER) -> upper; class_name(?CLS_LOWER) -> lower; class_name(?CLS_DIGIT) -> digit; class_name(?CLS_PUNCT) -> punct; class_name(?CLS_SPACE) -> space; class_name(?CLS_BLANK) -> blank; class_name(?CLS_ALPHA) -> alpha; class_name(?CLS_ALNUM) -> alnum; class_name(?CLS_PRINT) -> print; class_name(?CLS_8BIT) -> '8bit'. class(Ch) -> element(Ch + 1, { % 0 1 2 3 4 5 6 7 8 9 A B C D E F 1, 1, 1, 1, 1, 1, 1, 1, 1, 97, 65, 65, 65, 65, 1, 1, % 1 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, % 1 96, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, % 2 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 16, 16, 16, 16, 16, 16, % 3 16, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, % 4 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 16, 16, 16, 16, 16, % 5 16, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, % 6 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 16, 16, 16, 16, 1, % 7 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, % 8 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, % 9 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, % A 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, % B 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, % C 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, % D 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, % E 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128 % F }). test() -> [{Ch, [Ch], class_names(Ch)}|| Ch <- lists:seq(0,255)]. bm(File) -> {ok, B} = file:read_file(File), Size = byte_size(B), io:format("File ~p size is ~B bytes~n", [File, Size]), {Micros,_} = timer:tc(?MODULE, classify_binary, [B]), io:format("Speed = ~b bytes/sec~n", [Size * 1000000 div Micros]). classify_binary(<<>>) -> ok; classify_binary(<>) -> class(Ch), classify_binary(Rest). -------------- next part -------------- An HTML attachment was scrubbed... URL: From Mathias.Picker@REDACTED Thu Nov 20 16:43:34 2008 From: Mathias.Picker@REDACTED (Mathias Picker) Date: Thu, 20 Nov 2008 16:43:34 +0100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <8092dc770811200540h2f8ca8faga069307c52670e28@mail.gmail.com> References: <8092dc770811191227h5058121dkc25ab3927d98b080@mail.gmail.com> <513593.37413.qm@web111413.mail.gq1.yahoo.com> <8092dc770811200503h2869c51lc4e79746e17064a1@mail.gmail.com> <95be1d3b0811200522u257de936n9c73ed6775a5c890@mail.gmail.com> <8092dc770811200540h2f8ca8faga069307c52670e28@mail.gmail.com> Message-ID: <1227195814.2060.44.camel@mp.virtual-earth.de> As for code review, I like the dvcs way way: create a branch for your bug or feature, and after you've fixed it commit it to a code host (launchpad, bitbucket, github) and send an email detailing your changes and ask for your branch to be merged. I do like launchpad, there the code review can use the web frontend with voting or the one-shot mini-mailing-list created around the merge. See https://edge.launchpad.net/+tour/code-review. or Launchpad also does bug, enhancement requests (blueprints) and question tracking, has mailing lists and faq-building tools and has features for team/role responsibilites. Main problem: speed of the web ui. Launchpad can also handle a project staying with svn for the main developers by importing the svn trunk once and then updating it every few hours, see https://code.launchpad.net/~vcs-imports/drupal/main for an example and https://help.launchpad.net/FeatureHighlights/BranchImports and https://help.launchpad.net/VcsImports for documentation. This way commiters who like to use bzr could it and launchpad for changes and code review and once approved their changes to the main bzr branch could be merged back to svn (see http://bazaar-vcs.org/BzrForeignBranches/Subversion) So, if we're to build a community around erlang, a more complete service like this seems the better solution to me than hosting our own code review tool. Regards, Mathias Am Freitag, den 21.11.2008, 00:40 +1100 schrieb damien morton: > Youre right about the license issue - and they seem to have a go-slow > on adding new licenses, for example there are requests from 2007 for a > "Public Domain" license which havent been implemented yet. > > I think, in principle, the goal should be to find and use existing > tools where possible. > > I found, on google-code, some review software which seems to have > similar features to google-code itself: > http://www.review-board.org/users.php - unfortunately, it doesnt > appear to support git. > > On Fri, Nov 21, 2008 at 12:22 AM, Vlad Dumitrescu wrote: > > Hi, > > > > On Thu, Nov 20, 2008 at 14:03, damien morton wrote: > >> I guess the question is more about code review tools than SCM tools. > >> I took a look at github, and they have a wiki feature, but not the > >> detailed code review features of google-code. > > > > One possible problem with google-code is that they only allow a > > limited selection of OSS licenses, and the Erlang license isn't > > amongst them. > > > > regards, > > Vlad > > _______________________________________________ > > 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 rvirding@REDACTED Thu Nov 20 16:54:30 2008 From: rvirding@REDACTED (Robert Virding) Date: Thu, 20 Nov 2008 16:54:30 +0100 Subject: [erlang-questions] next(Erlang): "Fix up records so that records are first-class citizens and not just syntax saccharine for tuples?" In-Reply-To: <0BA8E2A5-D145-43FF-9BD1-3DDECE09EAD7@cs.otago.ac.nz> References: <8092dc770811191445ie3e8066qf226ddae04cdb3b3@mail.gmail.com> <0BA8E2A5-D145-43FF-9BD1-3DDECE09EAD7@cs.otago.ac.nz> Message-ID: <3dbc6d1c0811200754m8ad91bdl213f833d72c85cdf@mail.gmail.com> 2008/11/20 Richard O'Keefe > > On 20 Nov 2008, at 11:45 am, damien morton wrote: > > Hmm, I see - these fixed-up records would be dictionary-like data > > structures, with a supporting syntax for dictionary literals and > > pattern matching. They would lose the very fast lookup access that > > records have, though they would gain the expandability that a > > dictionary-type (proplist,hashtable,tree) data structure offers. > ... > My proposal comes with an implementation sketch > that *does* store the keys and the values separately. > Up to tagging, a frame is basically > {{foo,bar,ugh,zoo},X,Y,Z} > and the "descriptor" part would normally be shared. > This in no way impairs extensibility; the descriptor > doesn't *have* to be shared. Richard, one question about implementations. In some discussions I have had with people about such an extension (all want it) is that many see it not only as a replacement for records but also as a replacement for dict/gb_trees/sometimes even ets. Do you think it is possible to have one data structure which would efficiently span such a large range of entries? >From 0 in frames to 100,000s in in dict/gb_trees? I personally don't think it is possible, without changing internal representation somewhere. But if we have two different packages, frames and dicts, then we get the problem of trying to explain to people the difference between them and when to use which. I am all for adding something like frames, but I also think it is best to leave records in the system as they are. While we are at it I would like to see a hash table data type which could be used as a basis for dict to make it more efficient. Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: From babo.online@REDACTED Thu Nov 20 17:15:09 2008 From: babo.online@REDACTED (Attila Babo) Date: Thu, 20 Nov 2008 17:15:09 +0100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <513593.37413.qm@web111413.mail.gq1.yahoo.com> References: <8092dc770811191227h5058121dkc25ab3927d98b080@mail.gmail.com> <513593.37413.qm@web111413.mail.gq1.yahoo.com> Message-ID: <597c69660811200815r426ba9e7g1189b5dca6e71e1a@mail.gmail.com> It's OK to use a subversion backend from git, a good code review tool worth the effort to learn git-svn. From kevin@REDACTED Thu Nov 20 17:18:12 2008 From: kevin@REDACTED (Kevin Scaldeferri) Date: Thu, 20 Nov 2008 08:18:12 -0800 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <8092dc770811200540h2f8ca8faga069307c52670e28@mail.gmail.com> References: <8092dc770811191227h5058121dkc25ab3927d98b080@mail.gmail.com> <513593.37413.qm@web111413.mail.gq1.yahoo.com> <8092dc770811200503h2869c51lc4e79746e17064a1@mail.gmail.com> <95be1d3b0811200522u257de936n9c73ed6775a5c890@mail.gmail.com> <8092dc770811200540h2f8ca8faga069307c52670e28@mail.gmail.com> Message-ID: <3BE068AE-36DF-465D-AAA4-5AA2C421C10D@scaldeferri.com> On Nov 20, 2008, at 5:40 AM, damien morton wrote: > Youre right about the license issue - and they seem to have a go-slow > on adding new licenses, for example there are requests from 2007 for a > "Public Domain" license which havent been implemented yet. It's more than a "go-slow" policy. The situation is that the people who run Google Code are open source activists and have specifically picked the licenses that they feel people should use. -kevin From alustenberg@REDACTED Thu Nov 20 17:38:06 2008 From: alustenberg@REDACTED (Alex) Date: Thu, 20 Nov 2008 11:38:06 -0500 Subject: [erlang-questions] Node communication over insecure links Message-ID: <915e7e1d0811200838u35f5833bl51ad245d62ee0639@mail.gmail.com> Hey all, Tried digging around the archives for this one, but didnt come up with much. Just started playing with Erlang a few weeks ago, and like it a lot. Nice breath of fresh air after spending years fighting with shared memory thread programming. :) Anyway, my question is in regard to communication between instances over insecure networks and/or nodes. The case example is a network of IRC servers. Having all nodes in the same Erlang instance would be nice, and would make cross server communication a snap. Only issue is that if someone intercepts the magic cookiee, they gain access to all nodes, Not a good thing. Is there any way to encrypt node communication over SSL in the default runtime, or is this something that would have to be handed off to user code in a port? Another thing that would be nice to have is the ability to authenticate remote nodes based on priv/pub key authentication, possible? or does it fall into roll you own terratory? thanks in advance, --Alex -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf@REDACTED Thu Nov 20 17:44:26 2008 From: ulf@REDACTED (Ulf Wiger) Date: Thu, 20 Nov 2008 17:44:26 +0100 Subject: [erlang-questions] Pretty printing records In-Reply-To: <20081120150909.GD229@h216-235-12-168.host.egate.net> References: <20081120150909.GD229@h216-235-12-168.host.egate.net> Message-ID: <8209f740811200844v4b8aeac3vb2f7cf1f5a0f8d49@mail.gmail.com> You can use the same function as the shell, namely: io_lib_pretty:print(Term, RecDefFun) where RecDefFun is a fun/2: fun(Tag, NoOfFields) -> [FieldTag] | no The RecDefFun can be somewhat generalized through use of the exprecs parse transform. This is (almost) described in: http://forum.trapexit.org/viewtopic.php?p=21790#21790 You could make a module that includes definitions of all relevant records, and "exports" them using exprecs. Then you could modify the code in the example so that it returns 'no' for terms that are not representations of some exported record. BR, Ulf W 2008/11/20 Vance Shipley : > The shell now does a nice job of pretty printing records, > once you've loaded them with rr(). Currently I'm writing > test suites using common_test and would love the web page > reports generated to pretty print the (record) return values. > > Is there any easy way to do that? > > -Vance > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From erlangy@REDACTED Thu Nov 20 17:52:57 2008 From: erlangy@REDACTED (Michael McDaniel) Date: Thu, 20 Nov 2008 08:52:57 -0800 Subject: [erlang-questions] Node communication over insecure links In-Reply-To: <915e7e1d0811200838u35f5833bl51ad245d62ee0639@mail.gmail.com> References: <915e7e1d0811200838u35f5833bl51ad245d62ee0639@mail.gmail.com> Message-ID: <20081120165257.GM10121@delora.autosys.us> old but may get you started ... http://trapexit.org/Distributed_erlang_using_ssl_through_firewalls ~Michael On Thu, Nov 20, 2008 at 11:38:06AM -0500, Alex wrote: > Hey all, > Tried digging around the archives for this one, but didnt come up with > much. > Just started playing with Erlang a few weeks ago, and like it a lot. > Nice breath of fresh air after spending years fighting with shared > memory thread programming. :) > Anyway, my question is in regard to communication between instances > over insecure networks and/or nodes. The case example is a network of > IRC servers. Having all nodes in the same Erlang instance would be > nice, and would make cross server communication a snap. Only issue is > that if someone intercepts the magic cookiee, they gain access to all > nodes, Not a good thing. > Is there any way to encrypt node communication over SSL in the default > runtime, or is this something that would have to be handed off to user > code in a port? Another thing that would be nice to have is the > ability to authenticate remote nodes based on priv/pub key > authentication, possible? or does it fall into roll you own terratory? > thanks in advance, > --Alex > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- Michael McDaniel Portland, Oregon, USA http://autosys.us From dennis.novikov@REDACTED Thu Nov 20 17:53:02 2008 From: dennis.novikov@REDACTED (Dennis Novikov) Date: Thu, 20 Nov 2008 18:53:02 +0200 Subject: [erlang-questions] asynchronous driver, ready_input Message-ID: <1283764718.20081120185302@gmail.com> Hi, all. Does ready_input callback of asynchronous erlang driver have to be thread-safe? typedef struct { ErlDrvPort port; int fd; char *rb; // result buffer } drv_data; I am allocating memory buffer in start callback like this static ErlDrvData drv_start(ErlDrvPort port, char *buff) { drv_data* d = (drv_data*)driver_alloc(sizeof(drv_data); d->port = port; d->rb = (char*) driver_alloc(BUF_SZ); set_port_control_flags(port, PORT_CONTROL_FLAG_BINARY); driver_select(d->port, (ErlDrvEvent)d->fd, DO_READ, 1); } And in ready_input callback: static void data_ready(ErlDrvData handle, ErlDrvEvent evt) { drv_data *d = (drv_data*)handle; char *rbuf = d->rb; int len = get_len(); put_some_data_into(rbuf); // // Is this safe? driver_output(d->port, rbuf, len); // } The code above is simplified. Be it real I would use driver_output_binary(). If I understand correctly, that happens behind the scene in driver_output() call, so I should be safe. Am I? -- Regards, Dennis From masklinn@REDACTED Thu Nov 20 18:10:38 2008 From: masklinn@REDACTED (Masklinn) Date: Thu, 20 Nov 2008 18:10:38 +0100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <8092dc770811200503h2869c51lc4e79746e17064a1@mail.gmail.com> References: <8092dc770811191227h5058121dkc25ab3927d98b080@mail.gmail.com> <513593.37413.qm@web111413.mail.gq1.yahoo.com> <8092dc770811200503h2869c51lc4e79746e17064a1@mail.gmail.com> Message-ID: <67B428FD-2ED5-484E-AF43-80715DFA3457@masklinn.net> On 20 Nov 2008, at 14:03 , damien morton wrote: > I guess the question is more about code review tools than SCM tools. > > I took a look at github, and they have a wiki feature, but not the > detailed code review features of google-code. That's probably because in the push-pull workflow github (strongly) suggests it a feature that make full-fledged code review tools unnecessary: commit comments (including line by line). Basically, the workflow with github is that person B forks person A's repository, does his thing, commits and pushes to his fork, then sends a pull request to A. Now A usually won't just pull, he'll use github (or straight git) to see what was modified and changed and whatever, and he can use github's commit comments to perform a review (add suggestions, add questions, whatever) and only pull to his (A) main branch when everything looks ok with him. Anyway re code review, I think Tim's both right and wrong. Code review are good and core review tools are very nice, but on the other hand depending on the workflow you implement (DVCS are much more flexible than CVCS on that point) you might be able to easily do code reviews without the need for a full-fledged code review tool. Now that's also possible with CVCS (Django's team uses the bug tracker to perform code reviews on user-provided patches) but DVCS usually make that easier, either using specific features or regular emails in a push/pull model, or using a mailing list of some sort in a patchbomb model (see mercurial), or through some other setup. In any case, you're right that DVCS themselves don't do code review (one might be able to cook up an extension for that e.g. on top of queues) From alustenberg@REDACTED Thu Nov 20 18:17:40 2008 From: alustenberg@REDACTED (Alex) Date: Thu, 20 Nov 2008 12:17:40 -0500 Subject: [erlang-questions] Node communication over insecure links In-Reply-To: <20081120165257.GM10121@delora.autosys.us> References: <915e7e1d0811200838u35f5833bl51ad245d62ee0639@mail.gmail.com> <20081120165257.GM10121@delora.autosys.us> Message-ID: <915e7e1d0811200917l3a37d201hf8cd8c81dd4c635d@mail.gmail.com> Thank you, that is a definite lead in the right direction. On Thu, Nov 20, 2008 at 11:52 AM, Michael McDaniel wrote: > > old but may get you started ... > > > http://trapexit.org/Distributed_erlang_using_ssl_through_firewalls > > > ~Michael > > > On Thu, Nov 20, 2008 at 11:38:06AM -0500, Alex wrote: > > Hey all, > > Tried digging around the archives for this one, but didnt come up with > > much. > > Just started playing with Erlang a few weeks ago, and like it a lot. > > Nice breath of fresh air after spending years fighting with shared > > memory thread programming. :) > > Anyway, my question is in regard to communication between instances > > over insecure networks and/or nodes. The case example is a network of > > IRC servers. Having all nodes in the same Erlang instance would be > > nice, and would make cross server communication a snap. Only issue is > > that if someone intercepts the magic cookiee, they gain access to all > > nodes, Not a good thing. > > Is there any way to encrypt node communication over SSL in the default > > runtime, or is this something that would have to be handed off to user > > code in a port? Another thing that would be nice to have is the > > ability to authenticate remote nodes based on priv/pub key > > authentication, possible? or does it fall into roll you own > terratory? > > thanks in advance, > > --Alex > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > -- > Michael McDaniel > Portland, Oregon, USA > http://autosys.us > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From habitue@REDACTED Thu Nov 20 19:13:16 2008 From: habitue@REDACTED (Josh Kuhn) Date: Thu, 20 Nov 2008 13:13:16 -0500 Subject: [erlang-questions] Question about foreach in Eunit Message-ID: <563e5bf50811201013r5ef60d51u34d35c91dfeedd40@mail.gmail.com> Hi, I'm new to eunit and I am trying to get a certain group of tests completed that require a setup and teardown. Specifically, I have an ets table that I would like to set up and then drop after each small test. The problem is, the eunit macro for this seems to be only performing the setup and teardown at the beginning of the series and at the end. I am using a "foreach", but it is acting like a "setup". I have some code below to illustrate what I am talking about: db_functions_test_() -> {foreach, fun()-> {ets:new(usertable,[set,public]), ets:new(addrtable,[set,public])} end, fun({Users,Addrs})-> ets:delete(Users), ets:delete(Addrs) end, [fun db_test_list_/1] }. db_test_list_(Tables) -> [{"Add user to empty table", ?_assertMatch(user_added,fastrets:add_user(Tables,"Test",{'localhost',4000}))}, {"Get all users from empty table", ?_assertMatch([],fastrets:get_all_users(Tables))}, <*Lots more tests here -snip-*> I am using this particular form since I need the ets table info for the functions in the fastrests module, so I need to be able to initialize each of the tests with the newly generated data. In this case, the behavior I am getting is that the second test is failing to find an empty list because the first test added a user and wasn't cleaned up. I understand that ets is not garbage collected, so could it be that it is simply not possible to do these tests in the manner I am attempting? Also, I am fairly new to unit testing in general (I am a student) and eunit in particular, so if there is a more idiomatic or reasonable way to do what I am trying to do, I am all ears. Thanks, Josh Kuhn -------------- next part -------------- An HTML attachment was scrubbed... URL: From kevin@REDACTED Thu Nov 20 19:37:50 2008 From: kevin@REDACTED (Kevin A. Smith) Date: Thu, 20 Nov 2008 13:37:50 -0500 Subject: [erlang-questions] Node communication over insecure links In-Reply-To: <915e7e1d0811200917l3a37d201hf8cd8c81dd4c635d@mail.gmail.com> References: <915e7e1d0811200838u35f5833bl51ad245d62ee0639@mail.gmail.com> <20081120165257.GM10121@delora.autosys.us> <915e7e1d0811200917l3a37d201hf8cd8c81dd4c635d@mail.gmail.com> Message-ID: <32A9FCE7-974D-4558-BA8C-43950A914051@hypotheticalabs.com> FWIW - I applied those changes to a reasonably recent version, R12B-2 or 3, I think, and experimented with it on EC2. Works just fine AFAICT. I see this question come up a few times a year on the list. Would the OTP team be interested in a patch implementing this? If so, I'd be willing to take it on. --Kevin On Nov 20, 2008, at 12:17 PM, Alex wrote: > Thank you, that is a definite lead in the right direction. > > On Thu, Nov 20, 2008 at 11:52 AM, Michael McDaniel > wrote: > > old but may get you started ... > > > http://trapexit.org/Distributed_erlang_using_ssl_through_firewalls > > > ~Michael > > > On Thu, Nov 20, 2008 at 11:38:06AM -0500, Alex wrote: > > Hey all, > > Tried digging around the archives for this one, but didnt come > up with > > much. > > Just started playing with Erlang a few weeks ago, and like it a > lot. > > Nice breath of fresh air after spending years fighting with > shared > > memory thread programming. :) > > Anyway, my question is in regard to communication between > instances > > over insecure networks and/or nodes. The case example is a > network of > > IRC servers. Having all nodes in the same Erlang instance > would be > > nice, and would make cross server communication a snap. Only > issue is > > that if someone intercepts the magic cookiee, they gain access > to all > > nodes, Not a good thing. > > Is there any way to encrypt node communication over SSL in the > default > > runtime, or is this something that would have to be handed off > to user > > code in a port? Another thing that would be nice to have is the > > ability to authenticate remote nodes based on priv/pub key > > authentication, possible? or does it fall into roll you own > terratory? > > thanks in advance, > > --Alex > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > -- > Michael McDaniel > Portland, Oregon, USA > http://autosys.us > > _______________________________________________ > 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 richardc@REDACTED Thu Nov 20 20:03:07 2008 From: richardc@REDACTED (Richard Carlsson) Date: Thu, 20 Nov 2008 20:03:07 +0100 Subject: [erlang-questions] Question about foreach in Eunit In-Reply-To: <563e5bf50811201013r5ef60d51u34d35c91dfeedd40@mail.gmail.com> References: <563e5bf50811201013r5ef60d51u34d35c91dfeedd40@mail.gmail.com> Message-ID: <4925B46B.30207@it.uu.se> Josh Kuhn wrote: > Hi, > > I'm new to eunit and I am trying to get a certain group of tests > completed that require a setup and teardown. Specifically, I have an ets > table that I would like to set up and then drop after each small test. > The problem is, the eunit macro for this seems to be only performing the > setup and teardown at the beginning of the series and at the end. I am > using a "foreach", but it is acting like a "setup". I have some code > below to illustrate what I am talking about: > > db_functions_test_() -> > {foreach, > fun()-> > {ets:new(usertable,[set,public]), > ets:new(addrtable,[set,public])} > end, > fun({Users,Addrs})-> > ets:delete(Users), > ets:delete(Addrs) > end, > [fun db_test_list_/1] > }. > > db_test_list_(Tables) -> > [{"Add user to empty table", > > ?_assertMatch(user_added,fastrets:add_user(Tables,"Test",{'localhost',4000}))}, > { , > <*Lots more tests here -snip-*> This is because the "body" contains only a single item (the instantiator fun db_test_list_/1). And if you think some more about it, you'll see that you have actually abstracted the entire list of tests in db_test_list_(Tables) over the _same_ value of Tables, i.e., there is no way you can get to that list without giving it a value for Tables, and then it will be the same for all of them. If you want to run each subtest separately for different Tables, you'll have to write each one so that it is individually parameterized, for example by writing them as 1-ary "abstract" test functions: db_test_add_to_empty(Tables) -> ?assertMatch(user_added,fastrets:add_user(Tables,"Test",{'localhost',4000})). db_test_get_all_from_empty(Tables) -> ?assertMatch([],fastrets:get_all_users(Tables)). (etc.), and to use these abstract tests, replace the body [fun db_test_list_/1] with this: {with, [db_test_add_to_empty/1, db_test_get_all_from_empty/1, ...]} or, you can inline the list of subtests as the body, but wrap each of them in a 1-ary anonymous instantiator fun: [fun (Tables) -> {"Add user to empty table", ?_assertMatch(user_added, fastrets:add_user(Tables,"Test",{'localhost',4000}))} end, fun (Tables) -> {"Get all users from empty table", ?_assertMatch([],fastrets:get_all_users(Tables))} end, ...] (Or you can write named functions for the instantiators, if you want to make them reusable.) Sometimes the hard part of setting up tests like this is figuring out what needs to be parameterized over what. /Richard From toby@REDACTED Thu Nov 20 21:02:33 2008 From: toby@REDACTED (Toby Thain) Date: Thu, 20 Nov 2008 15:02:33 -0500 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <307CDF7E-D402-4A60-933B-9272649D8E34@cs.otago.ac.nz> References: <200811191158.mAJBwVKn010183@mail.pharos-avantgard.com> <4924053D.9090509@ericsson.com> <49240A89.6040600@it.uu.se> <49241CFB.9000001@softjar.se> <307CDF7E-D402-4A60-933B-9272649D8E34@cs.otago.ac.nz> Message-ID: <46D06D77-6027-46C5-BDA7-116493B83047@telegraphics.com.au> On 19-Nov-08, at 9:49 PM, Richard O'Keefe wrote: > ... > The whole idea of a 1-1 lower-upper case mapping is historically > absurd. char toupper(char c){ return c & ~0x20; } The ASCII guys told me this would work everywhere, forever. Was I misled?? --Toby From toby@REDACTED Thu Nov 20 21:10:23 2008 From: toby@REDACTED (Toby Thain) Date: Thu, 20 Nov 2008 15:10:23 -0500 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <3BE068AE-36DF-465D-AAA4-5AA2C421C10D@scaldeferri.com> References: <8092dc770811191227h5058121dkc25ab3927d98b080@mail.gmail.com> <513593.37413.qm@web111413.mail.gq1.yahoo.com> <8092dc770811200503h2869c51lc4e79746e17064a1@mail.gmail.com> <95be1d3b0811200522u257de936n9c73ed6775a5c890@mail.gmail.com> <8092dc770811200540h2f8ca8faga069307c52670e28@mail.gmail.com> <3BE068AE-36DF-465D-AAA4-5AA2C421C10D@scaldeferri.com> Message-ID: <0E93623C-D3CD-49EB-AD06-6DD3E3767FC4@telegraphics.com.au> On 20-Nov-08, at 11:18 AM, Kevin Scaldeferri wrote: > > On Nov 20, 2008, at 5:40 AM, damien morton wrote: > >> Youre right about the license issue - and they seem to have a go-slow >> on adding new licenses, for example there are requests from 2007 >> for a >> "Public Domain" license which havent been implemented yet. > > It's more than a "go-slow" policy. The situation is that the people > who run Google Code are open source activists and have specifically > picked the licenses that they feel people should use. More charitably, possibly taking a stance against license proliferation. --Toby > > > -kevin > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From kevin@REDACTED Thu Nov 20 21:21:54 2008 From: kevin@REDACTED (Kevin Scaldeferri) Date: Thu, 20 Nov 2008 12:21:54 -0800 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <0E93623C-D3CD-49EB-AD06-6DD3E3767FC4@telegraphics.com.au> References: <8092dc770811191227h5058121dkc25ab3927d98b080@mail.gmail.com> <513593.37413.qm@web111413.mail.gq1.yahoo.com> <8092dc770811200503h2869c51lc4e79746e17064a1@mail.gmail.com> <95be1d3b0811200522u257de936n9c73ed6775a5c890@mail.gmail.com> <8092dc770811200540h2f8ca8faga069307c52670e28@mail.gmail.com> <3BE068AE-36DF-465D-AAA4-5AA2C421C10D@scaldeferri.com> <0E93623C-D3CD-49EB-AD06-6DD3E3767FC4@telegraphics.com.au> Message-ID: On Nov 20, 2008, at 12:10 PM, Toby Thain wrote: > > On 20-Nov-08, at 11:18 AM, Kevin Scaldeferri wrote: > >> >> On Nov 20, 2008, at 5:40 AM, damien morton wrote: >> >>> Youre right about the license issue - and they seem to have a go- >>> slow >>> on adding new licenses, for example there are requests from 2007 >>> for a >>> "Public Domain" license which havent been implemented yet. >> >> It's more than a "go-slow" policy. The situation is that the people >> who run Google Code are open source activists and have specifically >> picked the licenses that they feel people should use. > > More charitably, possibly taking a stance against license > proliferation. Oh, I didn't mean it critically at all. They are concerned both about license proliferation, and about whether or not licenses are complete (for example, include discussion of patent rights) and legally clear. -kevin From vances@REDACTED Thu Nov 20 21:25:32 2008 From: vances@REDACTED (Vance Shipley) Date: Thu, 20 Nov 2008 15:25:32 -0500 Subject: [erlang-questions] Pretty printing records In-Reply-To: <8209f740811200844v4b8aeac3vb2f7cf1f5a0f8d49@mail.gmail.com> References: <20081120150909.GD229@h216-235-12-168.host.egate.net> <8209f740811200844v4b8aeac3vb2f7cf1f5a0f8d49@mail.gmail.com> Message-ID: <20081120202532.GG229@h216-235-12-168.host.egate.net> On Thu, Nov 20, 2008 at 05:44:26PM +0100, Ulf Wiger wrote: } You can use the same function as the shell, namely: } } io_lib_pretty:print(Term, RecDefFun) That is indeed what I was looking for. The result is a deep list which when printed using the '~s' control sequence in io:fwrite/2 (or in my case ct:log/2) gets output nicely. ct:log("Foo = ~s", [pretty_print(Foo)]) } The RecDefFun can be somewhat generalized through use of } the exprecs parse transform. I just used a local fun with the records I was interested in seeing: pretty_print(Record) -> io_lib_pretty:print(Record, fun pretty_print/2). pretty_print(foo, N) -> N = record_info(size, foo) - 1, record_info(fields, foo); pretty_print(bar, N) -> N = record_info(size, bar) - 1, record_info(fields, bar); pretty_print(_, _) -> []. Thanks, -Vance From ulf@REDACTED Thu Nov 20 21:58:56 2008 From: ulf@REDACTED (Ulf Wiger) Date: Thu, 20 Nov 2008 21:58:56 +0100 Subject: [erlang-questions] Pretty printing records In-Reply-To: <20081120202532.GG229@h216-235-12-168.host.egate.net> References: <20081120150909.GD229@h216-235-12-168.host.egate.net> <8209f740811200844v4b8aeac3vb2f7cf1f5a0f8d49@mail.gmail.com> <20081120202532.GG229@h216-235-12-168.host.egate.net> Message-ID: <8209f740811201258o2b6dc2f2na620a5253a7a3d14@mail.gmail.com> But I believe the catch-all should be: pretty_print(_, _) -> no. BR, Ulf W 2008/11/20 Vance Shipley : > On Thu, Nov 20, 2008 at 05:44:26PM +0100, Ulf Wiger wrote: > } You can use the same function as the shell, namely: > } > } io_lib_pretty:print(Term, RecDefFun) > > That is indeed what I was looking for. The result is a deep > list which when printed using the '~s' control sequence in > io:fwrite/2 (or in my case ct:log/2) gets output nicely. > > ct:log("Foo = ~s", [pretty_print(Foo)]) > > } The RecDefFun can be somewhat generalized through use of > } the exprecs parse transform. > > I just used a local fun with the records I was interested in > seeing: > > pretty_print(Record) -> > io_lib_pretty:print(Record, fun pretty_print/2). > > pretty_print(foo, N) -> > N = record_info(size, foo) - 1, > record_info(fields, foo); > pretty_print(bar, N) -> > N = record_info(size, bar) - 1, > record_info(fields, bar); > pretty_print(_, _) -> > []. > > Thanks, > > -Vance > From adam@REDACTED Thu Nov 20 22:45:01 2008 From: adam@REDACTED (Adam Duston) Date: Thu, 20 Nov 2008 15:45:01 -0600 Subject: [erlang-questions] logging with email output Message-ID: <52220f230811201345i6f84c23bi299586a7dcfa9f4b@mail.gmail.com> In my Java application, I can use an email logging target with log4j and then, when an exception occurs, an email is politely delivered to my inbox. In my Erlang app, I'm logging info and errors using error_logger. I would like to be notified by email when one of my gen_servers trips badly enough to shutdown and get restarted by the supervisor. What is the idiomatic way to do this? Thanks, Adam -- Founder, 8 Planes adam@REDACTED Skype: aduston From gleber.p@REDACTED Thu Nov 20 22:54:55 2008 From: gleber.p@REDACTED (Gleb Peregud) Date: Thu, 20 Nov 2008 22:54:55 +0100 Subject: [erlang-questions] logging with email output In-Reply-To: <52220f230811201345i6f84c23bi299586a7dcfa9f4b@mail.gmail.com> References: <52220f230811201345i6f84c23bi299586a7dcfa9f4b@mail.gmail.com> Message-ID: <14f0e3620811201354kc2b5152te7791d8063a262b3@mail.gmail.com> There's a log4j clone for Erlang: http://code.google.com/p/log4erl/ But it seems it does not have a email logger, though it shouldn't be too hard to write one, BR On 11/20/08, Adam Duston wrote: > In my Java application, I can use an email logging target with log4j > and then, when an exception occurs, an email is politely delivered to > my inbox. In my Erlang app, I'm logging info and errors using > error_logger. I would like to be notified by email when one of my > gen_servers trips badly enough to shutdown and get restarted by the > supervisor. What is the idiomatic way to do this? > > Thanks, > Adam > > -- > Founder, 8 Planes > adam@REDACTED > Skype: aduston > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- Gleb Peregud http://gleber.pl/ Every minute is to be grasped. Time waits for nobody. -- Inscription on a Zen Gong From adam@REDACTED Thu Nov 20 23:02:27 2008 From: adam@REDACTED (Adam Duston) Date: Thu, 20 Nov 2008 16:02:27 -0600 Subject: [erlang-questions] logging with email output In-Reply-To: <14f0e3620811201354kc2b5152te7791d8063a262b3@mail.gmail.com> References: <52220f230811201345i6f84c23bi299586a7dcfa9f4b@mail.gmail.com> <14f0e3620811201354kc2b5152te7791d8063a262b3@mail.gmail.com> Message-ID: <52220f230811201402r470ebebdodd1ca24ee5c79d5b@mail.gmail.com> Thanks, I've seen this before. Allow me to ask the question in a different way. Suppose you deploy an application, and there is a bug that only appears under certain circumstances. The circumstances don't occur for the first few days, but then the number of users increases and a gen_server starts crashing every few minutes, each time getting restarted by the supervisor. This could happen, for example, if there is a situation that produces deadlock and gen_server calls start timing out. Of course, each time a message is written to the SASL log. Am I expected to use rb to read through the SASL log on a daily basis? I can't imagine that I'm the first one facing this problem. How have people dealt with this in the past? Thanks again, Adam On Thu, Nov 20, 2008 at 3:54 PM, Gleb Peregud wrote: > There's a log4j clone for Erlang: > > http://code.google.com/p/log4erl/ > > But it seems it does not have a email logger, though it shouldn't be > too hard to write one, > > BR > > On 11/20/08, Adam Duston wrote: >> In my Java application, I can use an email logging target with log4j >> and then, when an exception occurs, an email is politely delivered to >> my inbox. In my Erlang app, I'm logging info and errors using >> error_logger. I would like to be notified by email when one of my >> gen_servers trips badly enough to shutdown and get restarted by the >> supervisor. What is the idiomatic way to do this? >> >> Thanks, >> Adam >> >> -- >> Founder, 8 Planes >> adam@REDACTED >> Skype: aduston >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > > -- > Gleb Peregud > http://gleber.pl/ > > Every minute is to be grasped. > Time waits for nobody. > -- Inscription on a Zen Gong > -- Founder, 8 Planes adam@REDACTED Skype: aduston From erlangy@REDACTED Thu Nov 20 23:05:59 2008 From: erlangy@REDACTED (Michael McDaniel) Date: Thu, 20 Nov 2008 14:05:59 -0800 Subject: [erlang-questions] logging with email output In-Reply-To: <52220f230811201345i6f84c23bi299586a7dcfa9f4b@mail.gmail.com> References: <52220f230811201345i6f84c23bi299586a7dcfa9f4b@mail.gmail.com> Message-ID: <20081120220559.GV10121@delora.autosys.us> I add mail into my handler, e.g. handle_event({set_alarm, {died, Ver, Reason}}, N) -> Host = atom_to_list(node()) , D = io_lib:format("~w/~w/~w ", tuple_to_list(date())) , T = io_lib:format("~w:~w:~w ", tuple_to_list(time())) , DT = string:concat(D,T) , Subj = "die whatever_it_is_that_died "++Host++Ver++"\n("++Reason++")", Msg = DT++Subj , spawn(?MODULE, send, ["", "", Subj, Msg]), {ok, N+1} ; handle_event( another event ) -> &etc... . ?MODULE:send/4 being a wrapper around whatever email you want to use; see http://www.trapexit.org/Special:UserContributions for some choices. ~Michael On Thu, Nov 20, 2008 at 03:45:01PM -0600, Adam Duston wrote: > In my Java application, I can use an email logging target with log4j > and then, when an exception occurs, an email is politely delivered to > my inbox. In my Erlang app, I'm logging info and errors using > error_logger. I would like to be notified by email when one of my > gen_servers trips badly enough to shutdown and get restarted by the > supervisor. What is the idiomatic way to do this? > > Thanks, > Adam > > -- > Founder, 8 Planes > adam@REDACTED > Skype: aduston > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- Michael McDaniel Portland, Oregon, USA http://autosys.us From ulf@REDACTED Thu Nov 20 23:14:24 2008 From: ulf@REDACTED (Ulf Wiger) Date: Thu, 20 Nov 2008 23:14:24 +0100 Subject: [erlang-questions] logging with email output In-Reply-To: <52220f230811201345i6f84c23bi299586a7dcfa9f4b@mail.gmail.com> References: <52220f230811201345i6f84c23bi299586a7dcfa9f4b@mail.gmail.com> Message-ID: <8209f740811201414i7af92cb2ke3682801e1c4a8e8@mail.gmail.com> You can install a handler in error_logger. http://www.erlang.org/doc/man/error_logger.html I would suggest that your handler sends a message to a process that in its turn generates the email. For one thing, event handlers should do as little as possible, since they are called sequentially in the error_logger process, and you probably also want to be able to aggregate crash reports if you get many at the same time. How to send the actual email depends on what system you're running on. With a working sendmail daemon, it's easy enough to just generate an email and use os:cmd(). If your mail problem is more complex than that, perhaps erlmail has a solution. It seems to have IMAP, SMTP and POP clients, although I haven't tried it. http://code.google.com/p/erlmail/ BTW, you may want to install a supervised event handler. It can be pretty annoying if there's an exception in the handler code, and the handler is quietly removed. For that, you use gen_event:add_sup_handler/3 http://www.erlang.org/doc/man/gen_event.html It's not written in the ref manual, but the way to do it is to have a supervised process that installs the handler on startup, and dies if it receives a gen_event_EXIT message. This way, you get the same supervision strategy for your handler as for processes. BR, Ulf W 2008/11/20 Adam Duston : > In my Java application, I can use an email logging target with log4j > and then, when an exception occurs, an email is politely delivered to > my inbox. In my Erlang app, I'm logging info and errors using > error_logger. I would like to be notified by email when one of my > gen_servers trips badly enough to shutdown and get restarted by the > supervisor. What is the idiomatic way to do this? > > Thanks, > Adam > > -- > Founder, 8 Planes > adam@REDACTED > Skype: aduston > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From ulf@REDACTED Thu Nov 20 23:18:24 2008 From: ulf@REDACTED (Ulf Wiger) Date: Thu, 20 Nov 2008 23:18:24 +0100 Subject: [erlang-questions] logging with email output In-Reply-To: <52220f230811201402r470ebebdodd1ca24ee5c79d5b@mail.gmail.com> References: <52220f230811201345i6f84c23bi299586a7dcfa9f4b@mail.gmail.com> <14f0e3620811201354kc2b5152te7791d8063a262b3@mail.gmail.com> <52220f230811201402r470ebebdodd1ca24ee5c79d5b@mail.gmail.com> Message-ID: <8209f740811201418o5874a93ajb87f6fbec80ef597@mail.gmail.com> What we did in the AXD 301 in order to catch infrequent crashes, was to keep a process that correlated crashes based on registered name. Supervisors will trigger on rapidly restarting processes, but we also wanted a report on processes that restart only now and then. BR, Ulf W 2008/11/20 Adam Duston : > Thanks, I've seen this before. Allow me to ask the question in a > different way. Suppose you deploy an application, and there is a bug > that only appears under certain circumstances. The circumstances don't > occur for the first few days, but then the number of users increases > and a gen_server starts crashing every few minutes, each time getting > restarted by the supervisor. This could happen, for example, if there > is a situation that produces deadlock and gen_server calls start > timing out. Of course, each time a message is written to the SASL log. > Am I expected to use rb to read through the SASL log on a daily basis? > I can't imagine that I'm the first one facing this problem. How have > people dealt with this in the past? > > Thanks again, > Adam > > On Thu, Nov 20, 2008 at 3:54 PM, Gleb Peregud wrote: >> There's a log4j clone for Erlang: >> >> http://code.google.com/p/log4erl/ >> >> But it seems it does not have a email logger, though it shouldn't be >> too hard to write one, >> >> BR >> >> On 11/20/08, Adam Duston wrote: >>> In my Java application, I can use an email logging target with log4j >>> and then, when an exception occurs, an email is politely delivered to >>> my inbox. In my Erlang app, I'm logging info and errors using >>> error_logger. I would like to be notified by email when one of my >>> gen_servers trips badly enough to shutdown and get restarted by the >>> supervisor. What is the idiomatic way to do this? >>> >>> Thanks, >>> Adam >>> >>> -- >>> Founder, 8 Planes >>> adam@REDACTED >>> Skype: aduston >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://www.erlang.org/mailman/listinfo/erlang-questions >>> >> >> >> -- >> Gleb Peregud >> http://gleber.pl/ >> >> Every minute is to be grasped. >> Time waits for nobody. >> -- Inscription on a Zen Gong >> > > > > -- > Founder, 8 Planes > adam@REDACTED > Skype: aduston > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From adam@REDACTED Thu Nov 20 23:21:21 2008 From: adam@REDACTED (Adam Duston) Date: Thu, 20 Nov 2008 16:21:21 -0600 Subject: [erlang-questions] logging with email output In-Reply-To: <8209f740811201414i7af92cb2ke3682801e1c4a8e8@mail.gmail.com> References: <52220f230811201345i6f84c23bi299586a7dcfa9f4b@mail.gmail.com> <8209f740811201414i7af92cb2ke3682801e1c4a8e8@mail.gmail.com> Message-ID: <52220f230811201421r7d7c352tf04f9eaabdeb45f4@mail.gmail.com> Thanks very much for the great responses, guys. I will put together your advice and install a handler in error_logger that messages an email-generating process. Ulf, you are really awesome for explaining this stuff and providing the note about AXD 301. This is a great list. I'm happy I joined it; so far I've been typing my Erlang code in isolation! Thanks again, Adam On Thu, Nov 20, 2008 at 4:14 PM, Ulf Wiger wrote: > You can install a handler in error_logger. > > http://www.erlang.org/doc/man/error_logger.html > > I would suggest that your handler sends a message to a > process that in its turn generates the email. For one thing, > event handlers should do as little as possible, since they are > called sequentially in the error_logger process, and you probably > also want to be able to aggregate crash reports if you get many > at the same time. > > How to send the actual email depends on what system you're > running on. With a working sendmail daemon, it's easy enough > to just generate an email and use os:cmd(). > > If your mail problem is more complex than that, perhaps erlmail > has a solution. It seems to have IMAP, SMTP and POP clients, > although I haven't tried it. > > http://code.google.com/p/erlmail/ > > > BTW, you may want to install a supervised event handler. > It can be pretty annoying if there's an exception in the handler > code, and the handler is quietly removed. > > For that, you use gen_event:add_sup_handler/3 > > http://www.erlang.org/doc/man/gen_event.html > > It's not written in the ref manual, but the way to do it > is to have a supervised process that installs the handler > on startup, and dies if it receives a gen_event_EXIT message. > This way, you get the same supervision strategy for your > handler as for processes. > > BR, > Ulf W > > 2008/11/20 Adam Duston : >> In my Java application, I can use an email logging target with log4j >> and then, when an exception occurs, an email is politely delivered to >> my inbox. In my Erlang app, I'm logging info and errors using >> error_logger. I would like to be notified by email when one of my >> gen_servers trips badly enough to shutdown and get restarted by the >> supervisor. What is the idiomatic way to do this? >> >> Thanks, >> Adam >> >> -- >> Founder, 8 Planes >> adam@REDACTED >> Skype: aduston >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > -- Founder, 8 Planes adam@REDACTED Skype: aduston From erlang-questions_efine@REDACTED Thu Nov 20 23:47:29 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Thu, 20 Nov 2008 17:47:29 -0500 Subject: [erlang-questions] On a positive Erlang performance note... Message-ID: <6c2563b20811201447i5aa44d74rbe39f87ade8fc527@mail.gmail.com> I've previously expressed some disappointment in Erlang's worst-case scenario SMP performance (lots of messages, very little done with each message, communicating parallel SMP processes). Now, to balance that out, I want to praise Erlang (and HiPE) for a virtually linear SMP speedup in a character classification test I ran. Using sequential and parallelized code (rpc:pmap) and a HiPE-compiled module on an Intel Q6600/Ubuntu/8GB/R12B-4, which classified every byte of a 40MB file into character classes (e.g. punct, blank), the following results were achieved: Sequential: 18817812 bytes/second Parallelized: 74937454 bytes/second Speedup: 3.98 (on a 4-core system). That's extremely close to linear and is pretty impressive. I found HiPE gave about a 10x speedup over BEAM. The results are with HiPE and exclude the time taken to load the file into a binary. Kudos to Erlang and HiPE. I had to do a bit of ugly code to get this level of performance, though (using dicts and arrays to keep the counts was just too slow - I fell to using a separate parameter for each of the 12 counts). The outputs follow (ascsp is something I added - counts ASCII SP (32) chars, and the purpose of '8bit' is self-evident). The other character classes are defined as per http://en.wikipedia.org/wiki/Regular_expression . Regards, Ed PS In the unlikely event that someone wants the code, I will gladly post it if asked. ------------ 31> c(charclass,[native]). {ok,charclass} 32> charclass:bm("/home/efine/erlang/otp_src_R12B-3.tar.gz") 32> . *** Completed run using classify_binary *** File "/home/efine/erlang/otp_src_R12B-3.tar.gz" size is 42195557 bytes Classified 42195557 characters Breakdown: [{'8bit',21296511}, {alnum,10079032}, {alpha,8454737}, {ascsp,158524}, {blank,318577}, {cntrl,5379355}, {digit,1624295}, {lower,4269350}, {print,15519691}, {punct,5282135}, {space,963777}, {upper,4185387}] Speed = 18817812 bytes/sec (0.05314113995461655 us/byte) ok 33> charclass:bm_par("/home/efine/erlang/otp_src_R12B-3.tar.gz"). *** Completed run using par_classify_binary *** File "/home/efine/erlang/otp_src_R12B-3.tar.gz" size is 42195557 bytes Classified 42195557 characters Breakdown: [{'8bit',21296511}, {alnum,10079032}, {alpha,8454737}, {ascsp,158524}, {blank,318577}, {cntrl,5379355}, {digit,1624295}, {lower,4269350}, {print,15519691}, {punct,5282135}, {space,963777}, {upper,4185387}] Speed = 74937454 bytes/sec (0.013344461835164304 us/byte) -------------- next part -------------- An HTML attachment was scrubbed... URL: From babo.online@REDACTED Thu Nov 20 23:59:34 2008 From: babo.online@REDACTED (Attila Babo) Date: Thu, 20 Nov 2008 23:59:34 +0100 Subject: [erlang-questions] logging with email output In-Reply-To: <52220f230811201345i6f84c23bi299586a7dcfa9f4b@mail.gmail.com> References: <52220f230811201345i6f84c23bi299586a7dcfa9f4b@mail.gmail.com> Message-ID: <597c69660811201459m4257ab19j5a280fa6bc9ac0b6@mail.gmail.com> We are using this email module in production, a simple SMTP client. Works without a glitch after a few modifications, here you may find the latest version: http://www.trapexit.org/forum/viewtopic.php?p=44245 /Attila From kevin@REDACTED Fri Nov 21 00:12:59 2008 From: kevin@REDACTED (Kevin Scaldeferri) Date: Thu, 20 Nov 2008 15:12:59 -0800 Subject: [erlang-questions] On a positive Erlang performance note... In-Reply-To: <6c2563b20811201447i5aa44d74rbe39f87ade8fc527@mail.gmail.com> References: <6c2563b20811201447i5aa44d74rbe39f87ade8fc527@mail.gmail.com> Message-ID: <5315F099-1086-4F55-B793-2132DF64AF7A@scaldeferri.com> Pretty nice. I'm curious, how did you decide to parallelize the IO? -kevin On Nov 20, 2008, at 2:47 PM, Edwin Fine wrote: > I've previously expressed some disappointment in Erlang's worst-case > scenario SMP performance (lots of messages, very little done with > each message, communicating parallel SMP processes). > > Now, to balance that out, I want to praise Erlang (and HiPE) for a > virtually linear SMP speedup in a character classification test I ran. > > Using sequential and parallelized code (rpc:pmap) and a HiPE- > compiled module on an Intel Q6600/Ubuntu/8GB/R12B-4, which > classified every byte of a 40MB file into character classes (e.g. > punct, blank), the following results were achieved: > > Sequential: 18817812 bytes/second > Parallelized: 74937454 bytes/second > Speedup: 3.98 (on a 4-core system). > > That's extremely close to linear and is pretty impressive. I found > HiPE gave about a 10x speedup over BEAM. The results are with HiPE > and exclude the time taken to load the file into a binary. > > Kudos to Erlang and HiPE. > > I had to do a bit of ugly code to get this level of performance, > though (using dicts and arrays to keep the counts was just too slow > - I fell to using a separate parameter for each of the 12 counts). > > The outputs follow (ascsp is something I added - counts ASCII SP > (32) chars, and the purpose of '8bit' is self-evident). The other > character classes are defined as per http://en.wikipedia.org/wiki/Regular_expression > . > > Regards, > Ed > > PS In the unlikely event that someone wants the code, I will gladly > post it if asked. > ------------ > > 31> c(charclass,[native]). > {ok,charclass} > 32> charclass:bm("/home/efine/erlang/otp_src_R12B-3.tar.gz") > 32> . > *** Completed run using classify_binary *** > File "/home/efine/erlang/otp_src_R12B-3.tar.gz" size is 42195557 bytes > Classified 42195557 characters > Breakdown: > [{'8bit',21296511}, > {alnum,10079032}, > {alpha,8454737}, > {ascsp,158524}, > {blank,318577}, > {cntrl,5379355}, > {digit,1624295}, > {lower,4269350}, > {print,15519691}, > {punct,5282135}, > {space,963777}, > {upper,4185387}] > Speed = 18817812 bytes/sec (0.05314113995461655 us/byte) > ok > 33> charclass:bm_par("/home/efine/erlang/otp_src_R12B-3.tar.gz"). > *** Completed run using par_classify_binary *** > File "/home/efine/erlang/otp_src_R12B-3.tar.gz" size is 42195557 bytes > Classified 42195557 characters > Breakdown: > [{'8bit',21296511}, > {alnum,10079032}, > {alpha,8454737}, > {ascsp,158524}, > {blank,318577}, > {cntrl,5379355}, > {digit,1624295}, > {lower,4269350}, > {print,15519691}, > {punct,5282135}, > {space,963777}, > {upper,4185387}] > Speed = 74937454 bytes/sec (0.013344461835164304 us/byte) > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From erlang-questions_efine@REDACTED Fri Nov 21 00:34:55 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Thu, 20 Nov 2008 18:34:55 -0500 Subject: [erlang-questions] On a positive Erlang performance note... In-Reply-To: <5315F099-1086-4F55-B793-2132DF64AF7A@scaldeferri.com> References: <6c2563b20811201447i5aa44d74rbe39f87ade8fc527@mail.gmail.com> <5315F099-1086-4F55-B793-2132DF64AF7A@scaldeferri.com> Message-ID: <6c2563b20811201534h4bc42b2h4e8493ea2ebc937c@mail.gmail.com> On Thu, Nov 20, 2008 at 6:12 PM, Kevin Scaldeferri wrote: > Pretty nice. I'm curious, how did you decide to parallelize the IO? > I didn't parallelize the I/O. I loaded the whole file into a binary and then did the parallel ops by passing a sub-binary to each process based on offset and length. To be fair, I was trying to see how well the character classification routine would fare, so I deliberately left out the I/O. IMHO parallelizing I/O is a totally different kettle of fish that I'm not ready to take on right now :) Ed > > -kevin > > > On Nov 20, 2008, at 2:47 PM, Edwin Fine wrote: > > I've previously expressed some disappointment in Erlang's worst-case > scenario SMP performance (lots of messages, very little done with each > message, communicating parallel SMP processes). > > Now, to balance that out, I want to praise Erlang (and HiPE) for a > virtually linear SMP speedup in a character classification test I ran. > > Using sequential and parallelized code (rpc:pmap) and a HiPE-compiled > module on an Intel Q6600/Ubuntu/8GB/R12B-4, which classified every byte of a > 40MB file into character classes (e.g. punct, blank), the following results > were achieved: > > Sequential: 18817812 bytes/second > Parallelized: 74937454 bytes/second > Speedup: 3.98 (on a 4-core system). > > That's extremely close to linear and is pretty impressive. I found HiPE > gave about a 10x speedup over BEAM. The results are with HiPE and exclude > the time taken to load the file into a binary. > > Kudos to Erlang and HiPE. > > I had to do a bit of ugly code to get this level of performance, though > (using dicts and arrays to keep the counts was just too slow - I fell to > using a separate parameter for each of the 12 counts). > > The outputs follow (ascsp is something I added - counts ASCII SP (32) > chars, and the purpose of '8bit' is self-evident). The other character > classes are defined as per http://en.wikipedia.org/wiki/Regular_expression. > > Regards, > Ed > > PS In the unlikely event that someone wants the code, I will gladly post it > if asked. > ------------ > > 31> c(charclass,[native]). > {ok,charclass} > 32> charclass:bm("/home/efine/erlang/otp_src_R12B-3.tar.gz") > 32> . > *** Completed run using classify_binary *** > File "/home/efine/erlang/otp_src_R12B-3.tar.gz" size is 42195557 bytes > Classified 42195557 characters > Breakdown: > [{'8bit',21296511}, > {alnum,10079032}, > {alpha,8454737}, > {ascsp,158524}, > {blank,318577}, > {cntrl,5379355}, > {digit,1624295}, > {lower,4269350}, > {print,15519691}, > {punct,5282135}, > {space,963777}, > {upper,4185387}] > Speed = 18817812 bytes/sec (0.05314113995461655 us/byte) > ok > 33> charclass:bm_par("/home/efine/erlang/otp_src_R12B-3.tar.gz"). > *** Completed run using par_classify_binary *** > File "/home/efine/erlang/otp_src_R12B-3.tar.gz" size is 42195557 bytes > Classified 42195557 characters > Breakdown: > [{'8bit',21296511}, > {alnum,10079032}, > {alpha,8454737}, > {ascsp,158524}, > {blank,318577}, > {cntrl,5379355}, > {digit,1624295}, > {lower,4269350}, > {print,15519691}, > {punct,5282135}, > {space,963777}, > {upper,4185387}] > Speed = 74937454 bytes/sec (0.013344461835164304 us/byte) > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ok@REDACTED Fri Nov 21 03:15:58 2008 From: ok@REDACTED (Richard O'Keefe) Date: Fri, 21 Nov 2008 15:15:58 +1300 Subject: [erlang-questions] Erlang elseif In-Reply-To: References: <65691fa00811200041yfc7a219y97a11126e0cee535@mail.gmail.com> Message-ID: <78FFE0EB-DF1E-41E9-A802-A66B4F8066AF@cs.otago.ac.nz> >> this but I could not find anything that answered my question. The >> thing is >> that I want a general way to branch the execution of my code based >> on the >> result on an expression. Very similar to how if works but I want to >> be able >> to test expressions and not only guards. If you're thinking "then >> you have >> case" now look below at function elseif2() and you'll see my point. Given that we have length(List) in guards, which definitely breaks the "guards are fast" guideline, it would be tempting to allow member(Term, List) in guards as well. >> 42> e:elseif4($Q). >> Member of capital >> >> -define(CAPS, "QWERTY"). >> -define(SMALL, "qwerty"). >> -define(NUMS, "123456"). >> >> %% The wierd not-so-Erlang way >> elseif1(A) -> >> lists:member(A,?CAPS) >> andalso begin >> io:format("Member of capital\n"), >> true >> end >> orelse >> lists:member(A,?SMALL) >> andalso begin >> io:format("Member of small\n"), >> true >> end >> orelse >> lists:member(A,?NUMS) >> andalso begin >> io:format("Member of nums\n"), >> true >> end >> orelse >> io:format("Not a member"). ei(Letter) when is_integer(C) -> io:format(eic(Letter)). eic(C) when C == $Q ; C == $W ; C == $E ; C == $R ; C == $T ; C == $Y -> "Member of capital\n"; eic(C) when C == $q ; C == $w ; C == $e ; C == $r ; C == $t ; C == $y -> "Member of small\n"; eic(C) when C == $1 ; C == $2 ; C == $3 ; C == $4 ; C == $5 ; C == $6 -> "Member of nums\n"; eic(_) -> "Not a member\n". In fact, I'd probably do it with two tables: ei(Letter) -> io:format(eim(eic(Letter))). eic($Q) -> large; eic($W) -> large; eic($E) -> large; eic($R) -> large; eic($T) -> large; eic($Y) -> large; eic($q) -> small; eic($w) -> small; eic($e) -> small; eic($r) -> small; eic($t) -> small; eic($y) -> small; eic($0) -> digit; eic($1) -> digit; eic($2) -> digit; eic($3) -> digit; eic($4) -> digit; eic($5) -> digit; eic($6) -> digit; eic(_) -> other. eim(large) -> "Member of capital\n"; eim(small) -> "Member of small\n"; eim(digit) -> "Member of nums\n"; eim(other) -> "Not a member\n". I know the table is large, but if you want to classify this way here, you may well want to classify the same way somewhere else. I like this approach a lot: it's dead simple and it's fast. Let's look at the pure 'case' version: ei(A) -> M = case lists:member(A, ?CAPS) of true -> "Member of capital\n" ; false -> case lists:member(A, ?SMALL) of true -> "Member of small\n" ; false -> case lists:member(A, ?NUMS) of true -> "Member of nums" ; false -> "Not a member\n" end end end, io:format(M). Suppose the syntax were extended ever-so-slightly to include an equivalent of Algol 68's "ouse": ei(A) -> M = case lists:member(A, ?CAPS) of true -> "Member of capital\n"; or case lists:member(A, ?SMALL) of true -> "Member of small\n"; or case lists:member(A, ?NUMS) of true -> "Member of nums\n" ; false-> "Not a member" end, io:format(M). Here the sequence "; or case" is equivalent to "; _ -> case" PLUS an extra "end" at the end. Now do -define(IF, case). -define(THEN, of true ->). -define(ELIF, ; or case). -define(ELSE, ; false ->). -define(END, end). and ei(A) -> M = ?IF lists:member(A, ?CAPS) ?THEN "Member of capital\n" ?ELIF lists:member(A, ?SMALL) ?THEN "Member of small\n" ?ELIF lists:member(A, ?NUMS) ?THEN "Member of nums\n" ?ELSE "Not a member" ?END, io:format(M). I'm not actually advocating the use of ?IF, ?THEN, ?ELIF, ?ELSE, ?END; I mention them merely to clarify that the "ouse" approach gives you something structurally similar to if-then-elif-else. I _do_ think that something along the lines of "; or case" would be nice, but as it stands it would be far too error-prone. Every time something like this comes up I say the same thing: Show us some real code, not a toy example. With real code, there is almost always a better way. From ok@REDACTED Fri Nov 21 03:29:29 2008 From: ok@REDACTED (Richard O'Keefe) Date: Fri, 21 Nov 2008 15:29:29 +1300 Subject: [erlang-questions] Erlang elseif In-Reply-To: <49252DCB.3070004@ericsson.com> References: <65691fa00811200041yfc7a219y97a11126e0cee535@mail.gmail.com> <49252DCB.3070004@ericsson.com> Message-ID: <78DCBA34-C30B-49D2-9968-EF4DDB45293B@cs.otago.ac.nz> > On 2008-11-20 09:41, kdronnqvist@REDACTED wrote: >> %% The no-good nested case way Why do you call it "no-good"? Looks fine to me. >> >> elseif2(A) -> >> case lists:member(A,?CAPS) of >> true -> >> io:format("Member of capital\n"); >> false -> >> case lists:member(A,?SMALL) of >> true -> >> io:format("Member of small\n"); >> false -> >> case lists:member(A,?NUMS) of >> true -> >> io:format("Member of nums\n"); >> false -> >> io:format("Not a member\n") >> end >> end >> end. Let's do that with a macro: -define(If_Member(X, Xs, T, F), case lists:member(X, Xs) of true -> T ; false -> F end). ei(A) -> M = ?If_Member(A, ?CAPS, "Member of capital\n", ?If_Member(A, ?SMALL, "Member of small\n", ?If_Member(A, ?NUMS, "Member of nums\n", "Not a member\n"))), io:format(M). It's the same code, but it doesn't look like it. There's always the higher order approach: -compile(inline, {if_member/4}). if_member(X, Ys, T, F) -> case lists:member(X, Ys) of true -> T() ; false -> F() end. ei(A) -> io:format(if_member(A, ?CAPS, fun() -> "Member of capital\n" end, fun() -> if_member(A, ?SMALL, fun() -> "Member of small\n" end, fun() -> if_member(A, ?NUMS, fun() -> "Member of nums\n" end, fun() -> "Not a member\n" end) end) end)). It's a functional language, the compiler does do inlining, and while I'm usually a fan of legalistic indenting, readability trumps everything else. From ok@REDACTED Fri Nov 21 03:30:12 2008 From: ok@REDACTED (Richard O'Keefe) Date: Fri, 21 Nov 2008 15:30:12 +1300 Subject: [erlang-questions] next(Erlang): "Fix up records so that records are first-class citizens and not just syntax saccharine for tuples?" In-Reply-To: References: <8092dc770811191445ie3e8066qf226ddae04cdb3b3@mail.gmail.com> <0BA8E2A5-D145-43FF-9BD1-3DDECE09EAD7@cs.otago.ac.nz> <492516AA.9070706@cs.ntua.gr> Message-ID: On 20 Nov 2008, at 10:30 pm, wrote: > On Thu, 20 Nov 2008, Kostis Sagonas wrote: > [...] >> f(..., R = #foo{bar = X, ugh = Y, zoo = Z}, ...) -> >> ...X... >> ...Y... >> ...Z... > > I know that this is the right Erlang style, but it's so counter- > intuitive that > the variable which gets the value is on the right hand side... That's why the current version of my 'frames' design uses "~" instead of "=". From ok@REDACTED Fri Nov 21 03:37:39 2008 From: ok@REDACTED (Richard O'Keefe) Date: Fri, 21 Nov 2008 15:37:39 +1300 Subject: [erlang-questions] Erlang elseif In-Reply-To: <65691fa00811200410k38326420t2a6fe93685345350@mail.gmail.com> References: <65691fa00811200041yfc7a219y97a11126e0cee535@mail.gmail.com> <49253C3F.6080305@it.uu.se> <65691fa00811200410k38326420t2a6fe93685345350@mail.gmail.com> Message-ID: <3783005C-69D7-45D7-8437-B4C18DE209FE@cs.otago.ac.nz> On 21 Nov 2008, at 1:10 am, wrote: > Thanks for your solutions, they give me good insight in how the > Erlang world would solve this. I have one more way of solving this > that I think is kind of clean and it would be efficient because the > lists:member() would need to be evaluated once a match is found. > > elseif5(A) -> > try > lists:member(A,?CAPS) andalso throw(caps), > lists:member(A,?SMALL) andalso throw(small), > lists:member(A,?NUMS) andalso throw(nums), > throw(none) > catch > throw:caps -> io:format("Member of capital\n"); > throw:small -> io:format("Member of small\n"); > throw:nums -> io:format("Member of nums\n"); > throw:none -> io:format("Not a member\n"); > X:Y -> io:format("Bad exception ~p:~p\n",[X,Y]) > end. Until you *measure* it, you have no reason to believe that throwing and catching an exception is any cheaper than doing all the list:member/2 calls. Even C++ with its "zero-cost try blocks" doesn't promise zero-cost or even cheap throwing; C++ 'try' blocks are only cheap when it turns out you didn't need them. Speaking as always only for myself I consider this an abuse of exceptions, and an abuse of your readers. Exceptions are for EXCEPTIONAL circumstances, and finding what you were looking for surely doesn't count as exceptional. Note too that your code suddenly accreted an extra X:Y -> line that has nothing to do with your task. As always, we need to see a REAL example, because there is an excellent chance that the right answer for your real problem is "none of the above". From ok@REDACTED Fri Nov 21 03:52:50 2008 From: ok@REDACTED (Richard O'Keefe) Date: Fri, 21 Nov 2008 15:52:50 +1300 Subject: [erlang-questions] next(Erlang): "Fix up records so that records are first-class citizens and not just syntax saccharine for tuples?" In-Reply-To: <3dbc6d1c0811200754m8ad91bdl213f833d72c85cdf@mail.gmail.com> References: <8092dc770811191445ie3e8066qf226ddae04cdb3b3@mail.gmail.com> <0BA8E2A5-D145-43FF-9BD1-3DDECE09EAD7@cs.otago.ac.nz> <3dbc6d1c0811200754m8ad91bdl213f833d72c85cdf@mail.gmail.com> Message-ID: <0BE60804-E879-478C-9361-AC85225E3A4D@cs.otago.ac.nz> On 21 Nov 2008, at 4:54 am, Robert Virding wrote: > Richard, one question about implementations. In some discussions I > have had with people about such an extension (all want it) is that > many see it not only as a replacement for records but also as a > replacement for dict/gb_trees/sometimes even ets. Amongst other things, the 'frames' proposal insists that the keys may only be atoms. Not any other kind of Erlang value. There are many reasons for this. Readability is fairly high on the list. That makes them utterly unsuitable as replacements for anything but records. > Do you think it is possible to have one data structure which would > efficiently span such a large range of entries? From 0 in frames to > 100,000s in in dict/gb_trees? There's an American cartoon strip called Broomhilda (http://www.gocomics.com/broomhilda). One particular strip I almost remember has Broomhilda wandering into a saleroom where the salesman offers her some implausible combination gadget, and the punchline is something like "Then I guess you aren't interested in a combination pool table/washing machine either." Of course it is possible to have an abstract data structure (with several representations) that can cover a wide range of sizes. The problem is that checking what representation you have adds extra time. It's probably not measurable for the large collections, but it WOULD be measurable for the tiny ones. The thing is that 'frames' are designed for the record-like case where in any one clause body that looks at the thing at all, you typically want 10% or more of the fields. > I personally don't think it is possible, without changing internal > representation somewhere. But if we have two different packages, > frames and dicts, then we get the problem of trying to explain to > people the difference between them and when to use which. Simple: frames are for heterogeneous aggregates with slots identified by atomic labels known at compile time that you want to pattern-match against, dicts are for homogeneous collections with arbitrary keys determined at run time that you want to update a lot and iterate over. You usually don't want to pattern match against a dict because you have no idea what keys to write in your source code. > > > I am all for adding something like frames, but I also think it is > best to leave records in the system as they are. Backwards compatibility has long been an emphasis of Erlang/OTP. From ok@REDACTED Fri Nov 21 04:00:50 2008 From: ok@REDACTED (Richard O'Keefe) Date: Fri, 21 Nov 2008 16:00:50 +1300 Subject: [erlang-questions] Erlang 3000? In-Reply-To: <46D06D77-6027-46C5-BDA7-116493B83047@telegraphics.com.au> References: <200811191158.mAJBwVKn010183@mail.pharos-avantgard.com> <4924053D.9090509@ericsson.com> <49240A89.6040600@it.uu.se> <49241CFB.9000001@softjar.se> <307CDF7E-D402-4A60-933B-9272649D8E34@cs.otago.ac.nz> <46D06D77-6027-46C5-BDA7-116493B83047@telegraphics.com.au> Message-ID: On 21 Nov 2008, at 9:02 am, Toby Thain wrote: > > On 19-Nov-08, at 9:49 PM, Richard O'Keefe wrote: > >> ... >> The whole idea of a 1-1 lower-upper case mapping is historically >> absurd. > > > char toupper(char c){ return c & ~0x20; } > > The ASCII guys told me this would work everywhere, forever. Was I > misled?? Not even for ASCII. Consider this: '~' is not a lower case letter, so upcasing should leave it alone. But '~' &~ 0x20 is '^'. OOPS! (This is one of the things that C89 changed. Classic C only really defined toupper(x) on characters that satisfied tolower(x), but C89 defined it for _all_ characters.) It certainly doesn't work for Latin-1, where there are two lower case letters that have no (y-umlaut) or no single-character (sharp s) upper case version at all in Latin 1. It doesn't work in most members of the ISO 8859 family, including for example ISO Latin 9 (8859-15), which is the replacement for Latin-1 that has the Euro (a wallaby-like marsupial). From dbtleonia@REDACTED Fri Nov 21 04:36:04 2008 From: dbtleonia@REDACTED (David Tucker) Date: Thu, 20 Nov 2008 22:36:04 -0500 Subject: [erlang-questions] init terminating at do_boot () Message-ID: <77ac51d70811201936x5a794e08ocb6aaab9a1e82dac@mail.gmail.com> Hi folks, I get the error below after compiling a simple Erlang program on Mac OS. I didn't see anything in the archive -- any idea what's wrong? Thanks. Dave === dbtucker@REDACTED:~/Desktop/newerl$ l total 8 -rwxr-xr-x 1 dbtucker 5000 56 Nov 20 22:10 c.erl* dbtucker@REDACTED:~/Desktop/newerl$ erl Erlang (BEAM) emulator version 5.6.5 [source] [smp:2] [async-threads:0] [kernel-poll:false] Eshell V5.6.5 (abort with ^G) 1> q(). ok 2> dbtucker@REDACTED:~/Desktop/newerl$ cat c.erl -module(c). -compile(export_all). foo(X) -> X * X. dbtucker@REDACTED:~/Desktop/newerl$ erlc c.erl dbtucker@REDACTED:~/Desktop/newerl$ erl Erlang (BEAM) emulator version 5.6.5 [source] [smp:2] [async-threads:0] [kernel-poll:false] {"init terminating in do_boot",{undef,[{c,erlangrc,[]},{init,eval_script,8},{init,do_boot,3}]}} Crash dump was written to: erl_crash.dump init terminating in do_boot () -------------- next part -------------- An HTML attachment was scrubbed... URL: From dbtleonia@REDACTED Fri Nov 21 05:55:35 2008 From: dbtleonia@REDACTED (David Tucker) Date: Thu, 20 Nov 2008 23:55:35 -0500 Subject: [erlang-questions] init terminating at do_boot () In-Reply-To: <3D86E418-B983-4A31-B390-4DB71A7FEC39@gol.com> References: <77ac51d70811201936x5a794e08ocb6aaab9a1e82dac@mail.gmail.com> <3D86E418-B983-4A31-B390-4DB71A7FEC39@gol.com> Message-ID: <77ac51d70811202055h2a6c7859ma91202b154b49e09@mail.gmail.com> Yep, that was it. Thanks. Dave On Thu, Nov 20, 2008 at 11:29 PM, John Webb wrote: > Hi Dave > > c is the name of the command interface used by the shell ( > http://www.erlang.org/doc/man/c.html ) > > Try renaming your module (not forgetting to remove c.beam from your local > directory). > > John > > > On Nov 21, 2008, at 12:36 PM, David Tucker wrote: > > Hi folks, >> >> I get the error below after compiling a simple Erlang program on Mac OS. >> I didn't see anything in the archive -- any idea what's wrong? Thanks. >> >> Dave >> >> === >> >> dbtucker@REDACTED:~/Desktop/newerl$ l >> total 8 >> -rwxr-xr-x 1 dbtucker 5000 56 Nov 20 22:10 c.erl* >> dbtucker@REDACTED:~/Desktop/newerl$ erl >> Erlang (BEAM) emulator version 5.6.5 [source] [smp:2] [async-threads:0] >> [kernel-poll:false] >> >> Eshell V5.6.5 (abort with ^G) >> 1> q(). >> ok >> 2> dbtucker@REDACTED:~/Desktop/newerl$ cat c.erl >> -module(c). >> -compile(export_all). >> >> foo(X) -> X * X. >> dbtucker@REDACTED:~/Desktop/newerl$ erlc c.erl >> dbtucker@REDACTED:~/Desktop/newerl$ erl >> Erlang (BEAM) emulator version 5.6.5 [source] [smp:2] [async-threads:0] >> [kernel-poll:false] >> >> {"init terminating in >> do_boot",{undef,[{c,erlangrc,[]},{init,eval_script,8},{init,do_boot,3}]}} >> >> Crash dump was written to: erl_crash.dump >> init terminating in do_boot () >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kdronnqvist@REDACTED Fri Nov 21 08:37:59 2008 From: kdronnqvist@REDACTED (=?ISO-8859-1?Q?Daniel_R=F6nnqvist?=) Date: Fri, 21 Nov 2008 08:37:59 +0100 Subject: [erlang-questions] Erlang elseif In-Reply-To: <78FFE0EB-DF1E-41E9-A802-A66B4F8066AF@cs.otago.ac.nz> References: <65691fa00811200041yfc7a219y97a11126e0cee535@mail.gmail.com> <78FFE0EB-DF1E-41E9-A802-A66B4F8066AF@cs.otago.ac.nz> Message-ID: <65691fa00811202337w57f3f329m244abaa055f6fae8@mail.gmail.com> I am merely trying to figure out why this simple logical control structure don't exist; If == true then elseif then else I know I can get lots and lots of good ideas on how to do this if I were to give you my whole real example but that is not my point. I am narrowing it down to this because THIS is what I want to discuss. IMHO, it shouldn't be that hard for the compiler/precompiler to "rewrite" another control structure as nested case statements which would work as a general solution, be very fast with less and arguably more readable code. BR, Daniel R?nnqvist 2008/11/21 Richard O'Keefe > >> this but I could not find anything that answered my question. The > >> thing is > >> that I want a general way to branch the execution of my code based > >> on the > >> result on an expression. Very similar to how if works but I want to > >> be able > >> to test expressions and not only guards. If you're thinking "then > >> you have > >> case" now look below at function elseif2() and you'll see my point. > > Given that we have length(List) in guards, which definitely breaks > the "guards are fast" guideline, it would be tempting to allow > member(Term, List) in guards as well. > >> 42> e:elseif4($Q). > >> Member of capital > >> > >> -define(CAPS, "QWERTY"). > >> -define(SMALL, "qwerty"). > >> -define(NUMS, "123456"). > >> > >> %% The wierd not-so-Erlang way > >> elseif1(A) -> > >> lists:member(A,?CAPS) > >> andalso begin > >> io:format("Member of capital\n"), > >> true > >> end > >> orelse > >> lists:member(A,?SMALL) > >> andalso begin > >> io:format("Member of small\n"), > >> true > >> end > >> orelse > >> lists:member(A,?NUMS) > >> andalso begin > >> io:format("Member of nums\n"), > >> true > >> end > >> orelse > >> io:format("Not a member"). > > ei(Letter) when is_integer(C) -> > io:format(eic(Letter)). > > eic(C) when C == $Q ; C == $W ; C == $E > ; C == $R ; C == $T ; C == $Y > -> "Member of capital\n"; > eic(C) when C == $q ; C == $w ; C == $e > ; C == $r ; C == $t ; C == $y > -> "Member of small\n"; > eic(C) when C == $1 ; C == $2 ; C == $3 > ; C == $4 ; C == $5 ; C == $6 > -> "Member of nums\n"; > eic(_) > -> "Not a member\n". > > In fact, I'd probably do it with two tables: > > ei(Letter) -> io:format(eim(eic(Letter))). > > eic($Q) -> large; > eic($W) -> large; > eic($E) -> large; > eic($R) -> large; > eic($T) -> large; > eic($Y) -> large; > eic($q) -> small; > eic($w) -> small; > eic($e) -> small; > eic($r) -> small; > eic($t) -> small; > eic($y) -> small; > eic($0) -> digit; > eic($1) -> digit; > eic($2) -> digit; > eic($3) -> digit; > eic($4) -> digit; > eic($5) -> digit; > eic($6) -> digit; > eic(_) -> other. > > eim(large) -> "Member of capital\n"; > eim(small) -> "Member of small\n"; > eim(digit) -> "Member of nums\n"; > eim(other) -> "Not a member\n". > > I know the table is large, but if you want to classify this way > here, you may well want to classify the same way somewhere else. > I like this approach a lot: it's dead simple and it's fast. > > Let's look at the pure 'case' version: > > ei(A) -> > M = case lists:member(A, ?CAPS) > of true -> "Member of capital\n" > ; false -> > case lists:member(A, ?SMALL) > of true -> "Member of small\n" > ; false -> > case lists:member(A, ?NUMS) > of true -> "Member of nums" > ; false -> "Not a member\n" > end > end > end, > io:format(M). > > Suppose the syntax were extended ever-so-slightly to > include an equivalent of Algol 68's "ouse": > > ei(A) -> > M = case lists:member(A, ?CAPS) > of true -> "Member of capital\n"; > or case lists:member(A, ?SMALL) > of true -> "Member of small\n"; > or case lists:member(A, ?NUMS) > of true -> "Member of nums\n" > ; false-> "Not a member" > end, > io:format(M). > > Here the sequence "; or case" is equivalent to > "; _ -> case" PLUS an extra "end" at the end. > > Now do > -define(IF, case). > -define(THEN, of true ->). > -define(ELIF, ; or case). > -define(ELSE, ; false ->). > -define(END, end). > and > > ei(A) -> > M = ?IF lists:member(A, ?CAPS) ?THEN "Member of capital\n" > ?ELIF lists:member(A, ?SMALL) ?THEN "Member of small\n" > ?ELIF lists:member(A, ?NUMS) ?THEN "Member of nums\n" > ?ELSE "Not a member" > ?END, > io:format(M). > > I'm not actually advocating the use of ?IF, ?THEN, ?ELIF, ?ELSE, ?END; > I mention them merely to clarify that the "ouse" approach gives you > something structurally similar to if-then-elif-else. > I _do_ think that something along the lines of "; or case" would be > nice, but as it stands it would be far too error-prone. > > Every time something like this comes up I say the same thing: > > Show us some real code, not a toy example. > > With real code, there is almost always a better way. > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From norton@REDACTED Fri Nov 21 08:59:20 2008 From: norton@REDACTED (Joseph Wayne Norton) Date: Fri, 21 Nov 2008 16:59:20 +0900 Subject: [erlang-questions] Erlang elseif In-Reply-To: <65691fa00811202337w57f3f329m244abaa055f6fae8@mail.gmail.com> References: <65691fa00811200041yfc7a219y97a11126e0cee535@mail.gmail.com> <78FFE0EB-DF1E-41E9-A802-A66B4F8066AF@cs.otago.ac.nz> <65691fa00811202337w57f3f329m244abaa055f6fae8@mail.gmail.com> Message-ID: Daniel - You can implement If == true then elseif then else in erlang as follows if == true -> ; -> ; true -> end. On Fri, 21 Nov 2008 16:37:59 +0900, Daniel R?nnqvist wrote: > I am merely trying to figure out why this simple logical control > structure > don't exist; > > If == true then > elseif then > else > > I know I can get lots and lots of good ideas on how to do this if I were > to > give you my whole real example but that is not my point. I am narrowing > it > down to this because THIS is what I want to discuss. > > IMHO, it shouldn't be that hard for the compiler/precompiler to "rewrite" > another control structure as nested case statements which would work as a > general solution, be very fast with less and arguably more readable code. > > BR, > Daniel R?nnqvist > > 2008/11/21 Richard O'Keefe > >> >> this but I could not find anything that answered my question. The >> >> thing is >> >> that I want a general way to branch the execution of my code based >> >> on the >> >> result on an expression. Very similar to how if works but I want to >> >> be able >> >> to test expressions and not only guards. If you're thinking "then >> >> you have >> >> case" now look below at function elseif2() and you'll see my point. >> >> Given that we have length(List) in guards, which definitely breaks >> the "guards are fast" guideline, it would be tempting to allow >> member(Term, List) in guards as well. >> >> 42> e:elseif4($Q). >> >> Member of capital >> >> >> >> -define(CAPS, "QWERTY"). >> >> -define(SMALL, "qwerty"). >> >> -define(NUMS, "123456"). >> >> >> >> %% The wierd not-so-Erlang way >> >> elseif1(A) -> >> >> lists:member(A,?CAPS) >> >> andalso begin >> >> io:format("Member of capital\n"), >> >> true >> >> end >> >> orelse >> >> lists:member(A,?SMALL) >> >> andalso begin >> >> io:format("Member of small\n"), >> >> true >> >> end >> >> orelse >> >> lists:member(A,?NUMS) >> >> andalso begin >> >> io:format("Member of nums\n"), >> >> true >> >> end >> >> orelse >> >> io:format("Not a member"). >> >> ei(Letter) when is_integer(C) -> >> io:format(eic(Letter)). >> >> eic(C) when C == $Q ; C == $W ; C == $E >> ; C == $R ; C == $T ; C == $Y >> -> "Member of capital\n"; >> eic(C) when C == $q ; C == $w ; C == $e >> ; C == $r ; C == $t ; C == $y >> -> "Member of small\n"; >> eic(C) when C == $1 ; C == $2 ; C == $3 >> ; C == $4 ; C == $5 ; C == $6 >> -> "Member of nums\n"; >> eic(_) >> -> "Not a member\n". >> >> In fact, I'd probably do it with two tables: >> >> ei(Letter) -> io:format(eim(eic(Letter))). >> >> eic($Q) -> large; >> eic($W) -> large; >> eic($E) -> large; >> eic($R) -> large; >> eic($T) -> large; >> eic($Y) -> large; >> eic($q) -> small; >> eic($w) -> small; >> eic($e) -> small; >> eic($r) -> small; >> eic($t) -> small; >> eic($y) -> small; >> eic($0) -> digit; >> eic($1) -> digit; >> eic($2) -> digit; >> eic($3) -> digit; >> eic($4) -> digit; >> eic($5) -> digit; >> eic($6) -> digit; >> eic(_) -> other. >> >> eim(large) -> "Member of capital\n"; >> eim(small) -> "Member of small\n"; >> eim(digit) -> "Member of nums\n"; >> eim(other) -> "Not a member\n". >> >> I know the table is large, but if you want to classify this way >> here, you may well want to classify the same way somewhere else. >> I like this approach a lot: it's dead simple and it's fast. >> >> Let's look at the pure 'case' version: >> >> ei(A) -> >> M = case lists:member(A, ?CAPS) >> of true -> "Member of capital\n" >> ; false -> >> case lists:member(A, ?SMALL) >> of true -> "Member of small\n" >> ; false -> >> case lists:member(A, ?NUMS) >> of true -> "Member of nums" >> ; false -> "Not a member\n" >> end >> end >> end, >> io:format(M). >> >> Suppose the syntax were extended ever-so-slightly to >> include an equivalent of Algol 68's "ouse": >> >> ei(A) -> >> M = case lists:member(A, ?CAPS) >> of true -> "Member of capital\n"; >> or case lists:member(A, ?SMALL) >> of true -> "Member of small\n"; >> or case lists:member(A, ?NUMS) >> of true -> "Member of nums\n" >> ; false-> "Not a member" >> end, >> io:format(M). >> >> Here the sequence "; or case" is equivalent to >> "; _ -> case" PLUS an extra "end" at the end. >> >> Now do >> -define(IF, case). >> -define(THEN, of true ->). >> -define(ELIF, ; or case). >> -define(ELSE, ; false ->). >> -define(END, end). >> and >> >> ei(A) -> >> M = ?IF lists:member(A, ?CAPS) ?THEN "Member of capital\n" >> ?ELIF lists:member(A, ?SMALL) ?THEN "Member of small\n" >> ?ELIF lists:member(A, ?NUMS) ?THEN "Member of nums\n" >> ?ELSE "Not a member" >> ?END, >> io:format(M). >> >> I'm not actually advocating the use of ?IF, ?THEN, ?ELIF, ?ELSE, ?END; >> I mention them merely to clarify that the "ouse" approach gives you >> something structurally similar to if-then-elif-else. >> I _do_ think that something along the lines of "; or case" would be >> nice, but as it stands it would be far too error-prone. >> >> Every time something like this comes up I say the same thing: >> >> Show us some real code, not a toy example. >> >> With real code, there is almost always a better way. >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> -- norton@REDACTED From chsu79@REDACTED Fri Nov 21 10:37:54 2008 From: chsu79@REDACTED (Christian) Date: Fri, 21 Nov 2008 10:37:54 +0100 Subject: [erlang-questions] Erlang elseif In-Reply-To: References: <65691fa00811200041yfc7a219y97a11126e0cee535@mail.gmail.com> <78FFE0EB-DF1E-41E9-A802-A66B4F8066AF@cs.otago.ac.nz> <65691fa00811202337w57f3f329m244abaa055f6fae8@mail.gmail.com> Message-ID: > You can implement > > If == true then > elseif then > else > > in erlang as follows > > if == true -> > ; > -> > ; > true -> > > end. A very important limitation in erlang's "if" expression is that the tests needs to be guards. If it is okay to execute all tests, every time, then one can of course do E1 = , E2 = , if E1 -> ; E2 -> ; true -> end I've had a feeling that there is an if-else chain expression called "cond" just waiting to happen? cond Test1 -> Result1; Test2 -> Result2; Test... -> Result...; true -> yay end The cond would in be identical to case Test1 of true -> Result1; false -> case Test2 of true -> Result2; false -> case Test... of true -> Result... false -> yay end end end I dont know where I got this impression that "cond" was waiting to happen. Is it not? Does it need an EEP? Are there objections to it? Does it need a reference implementation? From dmorton@REDACTED Fri Nov 21 10:38:28 2008 From: dmorton@REDACTED (damien morton) Date: Fri, 21 Nov 2008 20:38:28 +1100 Subject: [erlang-questions] Erlang elseif In-Reply-To: References: <65691fa00811200041yfc7a219y97a11126e0cee535@mail.gmail.com> <78FFE0EB-DF1E-41E9-A802-A66B4F8066AF@cs.otago.ac.nz> <65691fa00811202337w57f3f329m244abaa055f6fae8@mail.gmail.com> Message-ID: <8092dc770811210138u1c0539d5y2582a280395bfc93@mail.gmail.com> expressionX are constrained to be guard expressions, not user defined functions. On Fri, Nov 21, 2008 at 6:59 PM, Joseph Wayne Norton wrote: > > Daniel - > > You can implement > > If == true then > elseif then > else > > in erlang as follows > > if == true -> > ; > -> > ; > true -> > > end. > > > > On Fri, 21 Nov 2008 16:37:59 +0900, Daniel R?nnqvist > wrote: > >> I am merely trying to figure out why this simple logical control >> structure >> don't exist; >> >> If == true then >> elseif then >> else >> >> I know I can get lots and lots of good ideas on how to do this if I were >> to >> give you my whole real example but that is not my point. I am narrowing >> it >> down to this because THIS is what I want to discuss. >> >> IMHO, it shouldn't be that hard for the compiler/precompiler to "rewrite" >> another control structure as nested case statements which would work as a >> general solution, be very fast with less and arguably more readable code. >> >> BR, >> Daniel R?nnqvist >> >> 2008/11/21 Richard O'Keefe >> >>> >> this but I could not find anything that answered my question. The >>> >> thing is >>> >> that I want a general way to branch the execution of my code based >>> >> on the >>> >> result on an expression. Very similar to how if works but I want to >>> >> be able >>> >> to test expressions and not only guards. If you're thinking "then >>> >> you have >>> >> case" now look below at function elseif2() and you'll see my point. >>> >>> Given that we have length(List) in guards, which definitely breaks >>> the "guards are fast" guideline, it would be tempting to allow >>> member(Term, List) in guards as well. >>> >> 42> e:elseif4($Q). >>> >> Member of capital >>> >> >>> >> -define(CAPS, "QWERTY"). >>> >> -define(SMALL, "qwerty"). >>> >> -define(NUMS, "123456"). >>> >> >>> >> %% The wierd not-so-Erlang way >>> >> elseif1(A) -> >>> >> lists:member(A,?CAPS) >>> >> andalso begin >>> >> io:format("Member of capital\n"), >>> >> true >>> >> end >>> >> orelse >>> >> lists:member(A,?SMALL) >>> >> andalso begin >>> >> io:format("Member of small\n"), >>> >> true >>> >> end >>> >> orelse >>> >> lists:member(A,?NUMS) >>> >> andalso begin >>> >> io:format("Member of nums\n"), >>> >> true >>> >> end >>> >> orelse >>> >> io:format("Not a member"). >>> >>> ei(Letter) when is_integer(C) -> >>> io:format(eic(Letter)). >>> >>> eic(C) when C == $Q ; C == $W ; C == $E >>> ; C == $R ; C == $T ; C == $Y >>> -> "Member of capital\n"; >>> eic(C) when C == $q ; C == $w ; C == $e >>> ; C == $r ; C == $t ; C == $y >>> -> "Member of small\n"; >>> eic(C) when C == $1 ; C == $2 ; C == $3 >>> ; C == $4 ; C == $5 ; C == $6 >>> -> "Member of nums\n"; >>> eic(_) >>> -> "Not a member\n". >>> >>> In fact, I'd probably do it with two tables: >>> >>> ei(Letter) -> io:format(eim(eic(Letter))). >>> >>> eic($Q) -> large; >>> eic($W) -> large; >>> eic($E) -> large; >>> eic($R) -> large; >>> eic($T) -> large; >>> eic($Y) -> large; >>> eic($q) -> small; >>> eic($w) -> small; >>> eic($e) -> small; >>> eic($r) -> small; >>> eic($t) -> small; >>> eic($y) -> small; >>> eic($0) -> digit; >>> eic($1) -> digit; >>> eic($2) -> digit; >>> eic($3) -> digit; >>> eic($4) -> digit; >>> eic($5) -> digit; >>> eic($6) -> digit; >>> eic(_) -> other. >>> >>> eim(large) -> "Member of capital\n"; >>> eim(small) -> "Member of small\n"; >>> eim(digit) -> "Member of nums\n"; >>> eim(other) -> "Not a member\n". >>> >>> I know the table is large, but if you want to classify this way >>> here, you may well want to classify the same way somewhere else. >>> I like this approach a lot: it's dead simple and it's fast. >>> >>> Let's look at the pure 'case' version: >>> >>> ei(A) -> >>> M = case lists:member(A, ?CAPS) >>> of true -> "Member of capital\n" >>> ; false -> >>> case lists:member(A, ?SMALL) >>> of true -> "Member of small\n" >>> ; false -> >>> case lists:member(A, ?NUMS) >>> of true -> "Member of nums" >>> ; false -> "Not a member\n" >>> end >>> end >>> end, >>> io:format(M). >>> >>> Suppose the syntax were extended ever-so-slightly to >>> include an equivalent of Algol 68's "ouse": >>> >>> ei(A) -> >>> M = case lists:member(A, ?CAPS) >>> of true -> "Member of capital\n"; >>> or case lists:member(A, ?SMALL) >>> of true -> "Member of small\n"; >>> or case lists:member(A, ?NUMS) >>> of true -> "Member of nums\n" >>> ; false-> "Not a member" >>> end, >>> io:format(M). >>> >>> Here the sequence "; or case" is equivalent to >>> "; _ -> case" PLUS an extra "end" at the end. >>> >>> Now do >>> -define(IF, case). >>> -define(THEN, of true ->). >>> -define(ELIF, ; or case). >>> -define(ELSE, ; false ->). >>> -define(END, end). >>> and >>> >>> ei(A) -> >>> M = ?IF lists:member(A, ?CAPS) ?THEN "Member of capital\n" >>> ?ELIF lists:member(A, ?SMALL) ?THEN "Member of small\n" >>> ?ELIF lists:member(A, ?NUMS) ?THEN "Member of nums\n" >>> ?ELSE "Not a member" >>> ?END, >>> io:format(M). >>> >>> I'm not actually advocating the use of ?IF, ?THEN, ?ELIF, ?ELSE, ?END; >>> I mention them merely to clarify that the "ouse" approach gives you >>> something structurally similar to if-then-elif-else. >>> I _do_ think that something along the lines of "; or case" would be >>> nice, but as it stands it would be far too error-prone. >>> >>> Every time something like this comes up I say the same thing: >>> >>> Show us some real code, not a toy example. >>> >>> With real code, there is almost always a better way. >>> >>> >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://www.erlang.org/mailman/listinfo/erlang-questions >>> > > > > -- > norton@REDACTED > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From thomasl_erlang@REDACTED Fri Nov 21 10:05:21 2008 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Fri, 21 Nov 2008 01:05:21 -0800 (PST) Subject: [erlang-questions] Erlang elseif In-Reply-To: <65691fa00811202337w57f3f329m244abaa055f6fae8@mail.gmail.com> Message-ID: <612054.32661.qm@web111413.mail.gq1.yahoo.com> --- On Fri, 11/21/08, Daniel R?nnqvist wrote: > I am merely trying to figure out why this simple logical > control structure > don't exist; > > If == true then > elseif then > else The clause to use is selected with pattern matching and guards. Guards do not permit general expressions, because of some technical issues (what to do about side-effects in a guard that fails?) and because guard operations "should be fast". If your expressions are restricted to guards, you can write the above with this scheme: if Guard1 -> Expr1; Guard2 -> Expr2; true -> Expr3 end If you need general expressions rather than guards, you probably will have to write it with nested case-expressions (or maybe abuse try). case Expr1 of true -> Expr2; _ -> case Expr3 of ... end end or perhaps refactor the whole test into a new function. There is a proposal to introduce 'cond', which looks like an 'if' with general expressions in the guard position, but it has remained on the bench for a couple of years now. I think the basic issue of contention there is variable scoping. Consider this example (which I hope is proper cond-syntax): cond {ok, X} = f(Y) -> g(X); %% clause 1 true -> h(X) %% clause 2 end Should the X bound in clause 1 be visible in clause 2? The current proposal says yes, because you then won't have to repeat some computations in multiple guards. Others (including me) say no, because Erlang scoping normally doesn't work that way. Also, another reason for not having cond already is that there has been, in practice, fairly low demand for it. Best, Thomas From steven.charles.davis@REDACTED Fri Nov 21 12:16:49 2008 From: steven.charles.davis@REDACTED (Steve Davis) Date: Fri, 21 Nov 2008 03:16:49 -0800 (PST) Subject: [erlang-questions] next(Erlang): "Fix up records so that records are first-class citizens and not just syntax saccharine for tuples?" In-Reply-To: <8092dc770811191445ie3e8066qf226ddae04cdb3b3@mail.gmail.com> References: <8092dc770811191445ie3e8066qf226ddae04cdb3b3@mail.gmail.com> Message-ID: <16f33854-7813-4ff2-8730-23653e726ffe@g38g2000yqn.googlegroups.com> If you are really serious about this - here are some considerations/ dogma from me: - Don't try to support inheritance (preferring decorators will save you untold issues later) - Consider how close/far JSON maps to record tuples - C.J. Date once said that the big issue with ORM was SQL's lack of support for relational domains - XML is a disaster for almost all purposes, so don't be tempted to use it for "configuration" or "communications" (it took me a while to finally understand Joe's view, but I am 110% there now) - The entire set of required modifiers is likely: required, unique, optional, readonly (and possibly "hidden") - The entire set of required fundamental types is likely: text, number, flag - Don't allow nulls in any shape or form /s On Nov 19, 4:45?pm, "damien morton" wrote: > I ask "Have there be any proposals on how to implement this?: From dmorton@REDACTED Fri Nov 21 13:15:56 2008 From: dmorton@REDACTED (damien morton) Date: Fri, 21 Nov 2008 23:15:56 +1100 Subject: [erlang-questions] next(Erlang): "Fix up records so that records are first-class citizens and not just syntax saccharine for tuples?" In-Reply-To: <16f33854-7813-4ff2-8730-23653e726ffe@g38g2000yqn.googlegroups.com> References: <8092dc770811191445ie3e8066qf226ddae04cdb3b3@mail.gmail.com> <16f33854-7813-4ff2-8730-23653e726ffe@g38g2000yqn.googlegroups.com> Message-ID: <8092dc770811210415k43823062k3794c3356c0943d4@mail.gmail.com> On Fri, Nov 21, 2008 at 10:16 PM, Steve Davis wrote: > If you are really serious about this - here are some considerations/ > dogma from me: > - Don't try to support inheritance (preferring decorators will save > you untold issues later) Heh. I dont think anyone is proposing that. > - Consider how close/far JSON maps to record tuples Richard's frames map very nicely to JSON and back. > - C.J. Date once said that the big issue with ORM was SQL's lack of > support for relational domains You're talking about enum equivalents? > - XML is a disaster for almost all purposes, so don't be tempted to > use it for "configuration" or "communications" (it took me a while to > finally understand Joe's view, but I am 110% there now) Do you have a link to Joe's view on XML? > - The entire set of required modifiers is likely: required, unique, > optional, readonly (and possibly "hidden") > > - The entire set of required fundamental types is likely: text, > number, flag > - Don't allow nulls in any shape or form Ahh - the "schema" I referred to was merely the set of keys - its just an implementation detail that the set of keys _can_ be shared between frame instances, though this is not necessary. Probably the wrong word to use. From dennis.novikov@REDACTED Thu Nov 20 17:53:02 2008 From: dennis.novikov@REDACTED (Dennis Novikov) Date: Thu, 20 Nov 2008 18:53:02 +0200 Subject: [erlang-questions] asynchronous driver, ready_input Message-ID: <1283764718.20081120185302@gmail.com> Hi, all. Does ready_input callback of asynchronous erlang driver have to be thread-safe? typedef struct { ErlDrvPort port; int fd; char *rb; // result buffer } drv_data; I am allocating memory buffer in start callback like this static ErlDrvData drv_start(ErlDrvPort port, char *buff) { drv_data* d = (drv_data*)driver_alloc(sizeof(drv_data); d->port = port; d->rb = (char*) driver_alloc(BUF_SZ); set_port_control_flags(port, PORT_CONTROL_FLAG_BINARY); driver_select(d->port, (ErlDrvEvent)d->fd, DO_READ, 1); } And in ready_input callback: static void data_ready(ErlDrvData handle, ErlDrvEvent evt) { drv_data *d = (drv_data*)handle; char *rbuf = d->rb; int len = get_len(); put_some_data_into(rbuf); // // Is this safe? driver_output(d->port, rbuf, len); // } The code above is simplified. Be it real I would use driver_output_binary(). If I understand correctly, that happens behind the scene in driver_output() call, so I should be safe. Am I? -- Regards, Dennis From mikpe@REDACTED Fri Nov 21 13:59:34 2008 From: mikpe@REDACTED (Mikael Pettersson) Date: Fri, 21 Nov 2008 13:59:34 +0100 Subject: [erlang-questions] On a positive Erlang performance note... In-Reply-To: <6c2563b20811201447i5aa44d74rbe39f87ade8fc527@mail.gmail.com> References: <6c2563b20811201447i5aa44d74rbe39f87ade8fc527@mail.gmail.com> Message-ID: <18726.45239.5621.276088@harpo.it.uu.se> Edwin Fine writes: > I've previously expressed some disappointment in Erlang's worst-case > scenario SMP performance (lots of messages, very little done with each > message, communicating parallel SMP processes). > > Now, to balance that out, I want to praise Erlang (and HiPE) for a virtually > linear SMP speedup in a character classification test I ran. > > Using sequential and parallelized code (rpc:pmap) and a HiPE-compiled module > on an Intel Q6600/Ubuntu/8GB/R12B-4, which classified every byte of a 40MB > file into character classes (e.g. punct, blank), the following results were > achieved: > > Sequential: 18817812 bytes/second > Parallelized: 74937454 bytes/second > Speedup: 3.98 (on a 4-core system). > > That's extremely close to linear and is pretty impressive. I found HiPE gave > about a 10x speedup over BEAM. The results are with HiPE and exclude the > time taken to load the file into a binary. > > Kudos to Erlang and HiPE. Thanks. > I had to do a bit of ugly code to get this level of performance, though > (using dicts and arrays to keep the counts was just too slow - I fell to > using a separate parameter for each of the 12 counts). > > The outputs follow (ascsp is something I added - counts ASCII SP (32) chars, > and the purpose of '8bit' is self-evident). The other character classes are > defined as per http://en.wikipedia.org/wiki/Regular_expression . > > Regards, > Ed > > PS In the unlikely event that someone wants the code, I will gladly post it > if asked. Please do. I'd like to include it in the benchmark section of HiPE's compiler test suite. The 10x speedup over BEAM really put a smile on my face :-) /Mikael From bqt@REDACTED Fri Nov 21 14:01:01 2008 From: bqt@REDACTED (Johnny Billquist) Date: Fri, 21 Nov 2008 14:01:01 +0100 Subject: [erlang-questions] Erlang 3000? In-Reply-To: References: <200811191158.mAJBwVKn010183@mail.pharos-avantgard.com> <4924053D.9090509@ericsson.com> <49240A89.6040600@it.uu.se> <49241CFB.9000001@softjar.se> <307CDF7E-D402-4A60-933B-9272649D8E34@cs.otago.ac.nz> <46D06D77-6027-46C5-BDA7-116493B83047@telegraphics.com.au> Message-ID: <4926B10D.9030801@softjar.se> Richard O'Keefe wrote: > On 21 Nov 2008, at 9:02 am, Toby Thain wrote: > >> On 19-Nov-08, at 9:49 PM, Richard O'Keefe wrote: >> >>> ... >>> The whole idea of a 1-1 lower-upper case mapping is historically >>> absurd. >> >> char toupper(char c){ return c & ~0x20; } >> >> The ASCII guys told me this would work everywhere, forever. Was I >> misled?? > > Not even for ASCII. Consider this: '~' is not a lower case letter, > so upcasing should leave it alone. But '~' &~ 0x20 is '^'. OOPS! You know, I think Toby was trying to be funny... Johnny From kostis@REDACTED Fri Nov 21 14:21:12 2008 From: kostis@REDACTED (Kostis Sagonas) Date: Fri, 21 Nov 2008 14:21:12 +0100 Subject: [erlang-questions] On a positive Erlang performance note... In-Reply-To: <18726.45239.5621.276088@harpo.it.uu.se> References: <6c2563b20811201447i5aa44d74rbe39f87ade8fc527@mail.gmail.com> <18726.45239.5621.276088@harpo.it.uu.se> Message-ID: <4926B5C8.8040608@cs.ntua.gr> Mikael Pettersson wrote: > Edwin Fine writes: > > > > That's extremely close to linear and is pretty impressive. I found HiPE gave > > about a 10x speedup over BEAM. The results are with HiPE and exclude the > > time taken to load the file into a binary. > > > > Kudos to Erlang and HiPE. > > Thanks. > > > PS In the unlikely event that someone wants the code, I will gladly post it > > if asked. > > Please do. I'd like to include it in the benchmark section > of HiPE's compiler test suite. > The 10x speedup over BEAM really put a smile on my face :-) It put a big smile on my face too, but I am not so surprised. In programs manipulating binaries, we've often experienced such speedups (typically 8x) over BEAM when using HiPE, and judging from Edwin's post, this appears to be a binary-intensive program. (Of course I _will_ be very surprised if the speedup is due to some reason other than binaries.) But having the program is a good thing nonetheless. Kostis From ulf.wiger@REDACTED Fri Nov 21 14:52:20 2008 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Fri, 21 Nov 2008 14:52:20 +0100 Subject: [erlang-questions] next(Erlang): "Fix up records so that records are first-class citizens and not just syntax saccharine for tuples?" In-Reply-To: <8092dc770811210415k43823062k3794c3356c0943d4@mail.gmail.com> References: <8092dc770811191445ie3e8066qf226ddae04cdb3b3@mail.gmail.com> <16f33854-7813-4ff2-8730-23653e726ffe@g38g2000yqn.googlegroups.com> <8092dc770811210415k43823062k3794c3356c0943d4@mail.gmail.com> Message-ID: <4926BD14.9070806@ericsson.com> damien morton skrev: > On Fri, Nov 21, 2008 at 10:16 PM, Steve Davis > wrote: >> >> - XML is a disaster for almost all purposes, so don't be tempted to >> use it for "configuration" or "communications" (it took me a while >> to finally understand Joe's view, but I am 110% there now) > > Do you have a link to Joe's view on XML? Here's one input: "Getting Erlang to talk to the outside world" Proceedings of the 2002 ACM SIGPLAN workshop on Erlang http://www.erlang.se/workshop/2002/Armstrong.pdf http://portal.acm.org/citation.cfm?id=592858 BR, Ulf W From jeedward@REDACTED Fri Nov 21 14:33:56 2008 From: jeedward@REDACTED (John Edward) Date: Fri, 21 Nov 2008 05:33:56 -0800 (PST) Subject: [erlang-questions] MULTICONF-09 call for papers Message-ID: <21890.14778.qm@web45907.mail.sp1.yahoo.com> MULTICONF-09 call for papers ? The 2009 Multi Conference in Computer Science, Information Technology and Control systems and Computational Science and Computer Engineering (MULTICONF-09) (website: http://www.PromoteResearch.org) will be held during July 13-16 2009 in Orlando, FL, USA. We invite draft paper submissions. The event consists of the following conferences: ????????? International Conference on Artificial Intelligence and Pattern Recognition (AIPR-09) ????????? International Conference on Automation, Robotics and Control Systems (ARCS-09) ????????? International Conference on Bioinformatics, Computational Biology, Genomics and Chemoinformatics (BCBGC-09) ????????? International Conference on Enterprise Information Systems and Web Technologies (EISWT-09) ????????? International Conference on High Performance Computing, Networking and Communication Systems (HPCNCS-09) ????????? International Conference on Information Security and Privacy (ISP-09) ????????? International Conference on Recent Advances in Information Technology and Applications (RAITA-09) ????????? International Conference on Software Engineering Theory and Practice (SETP-09) ????????? International Conference on Theory and Applications of Computational Science (TACS-09) ????????? International Conference on Theoretical and Mathematical Foundations of Computer Science (TMFCS-09) ? The website http://www.PromoteResearch.org? contains more details. ? Sincerely John Edward Publicity committee ? ? -------------- next part -------------- An HTML attachment was scrubbed... URL: From rklophaus@REDACTED Fri Nov 21 15:29:21 2008 From: rklophaus@REDACTED (Rusty Klophaus) Date: Fri, 21 Nov 2008 09:29:21 -0500 Subject: [erlang-questions] Reading records with file:consult/1 or erl_eval/2? Message-ID: Hi all, I'm working on a small utility that reads Erlang terms from a file, processes them, and spits out another file. I've hit an unanticipated snag on step one. I can read basic terms just fine, but I can't make file:consult/1 or erl_eval:expr/2 recognize records. Any suggestions? Is this just a known limitation? Output and code are below. Thanks, Rusty *** OUTPUT *** Eshell V5.6.5 (abort with ^G) 1> reader:read_with_consult(). {error,{1,erl_parse,"bad term"}} 2> reader:read_with_eval(). ** exception error: {undefined_record,document} Here is the code and supporting files: *** READER.ERL CONTAINS *** -module (reader). -include ("records.hrl"). -compile(export_all). read_with_consult() -> file:consult("terms.txt"). read_with_eval() -> {ok, B} = file:read_file("terms.txt"), S = binary_to_list(B), {ok, Tokens, _} = erl_scan:string(S), {ok, [Form]} = erl_parse:parse_exprs(Tokens), erl_eval:expr(Form, []). *** RECORDS.HRL CONTAINS *** -record(document, {title, description}). *** TERMS.TXT CONTAINS *** #document {}. From chsu79@REDACTED Fri Nov 21 15:41:31 2008 From: chsu79@REDACTED (Christian) Date: Fri, 21 Nov 2008 15:41:31 +0100 Subject: [erlang-questions] Reading records with file:consult/1 or erl_eval/2? In-Reply-To: References: Message-ID: On Fri, Nov 21, 2008 at 15:29, Rusty Klophaus wrote: > I've hit an unanticipated snag on step one. I can read basic terms > just fine, but I can't make file:consult/1 or erl_eval:expr/2 > recognize records. Any suggestions? Is this just a known limitation? It will not work, since records are macros and there is no information of how to create a record of a given name at runtime. You will have to specify the values of a document by tuple index, and have some kind of massage of the data as records and into your record fields. Think massage({document, X, Y, Z}) -> #document(x=X,y=Y,z=Z); From rklophaus@REDACTED Fri Nov 21 15:45:58 2008 From: rklophaus@REDACTED (Rusty Klophaus) Date: Fri, 21 Nov 2008 09:45:58 -0500 Subject: [erlang-questions] Reading records with file:consult/1 or erl_eval/2? In-Reply-To: References: Message-ID: Ah, that is unfortunate, but makes sense. Thanks! On Nov 21, 2008, at 9:41 AM, Christian wrote: > On Fri, Nov 21, 2008 at 15:29, Rusty Klophaus > wrote: >> I've hit an unanticipated snag on step one. I can read basic terms >> just fine, but I can't make file:consult/1 or erl_eval:expr/2 >> recognize records. Any suggestions? Is this just a known limitation? > > It will not work, since records are macros and there is no information > of how to create a record of a given name at runtime. You will have to > specify the values of a document by tuple index, and have some kind of > massage of the data as records and into your record fields. Think > > massage({document, X, Y, Z}) -> > #document(x=X,y=Y,z=Z); From devdoer2@REDACTED Fri Nov 21 16:53:11 2008 From: devdoer2@REDACTED (devdoer bird) Date: Fri, 21 Nov 2008 23:53:11 +0800 Subject: [erlang-questions] Is there a erlang version myspace API library? Message-ID: HI: Is there a erlang version myspace API library? Can someone share your codes? -------------- next part -------------- An HTML attachment was scrubbed... URL: From erlang-questions_efine@REDACTED Fri Nov 21 18:10:21 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Fri, 21 Nov 2008 12:10:21 -0500 Subject: [erlang-questions] On a positive Erlang performance note... In-Reply-To: <4926B5C8.8040608@cs.ntua.gr> References: <6c2563b20811201447i5aa44d74rbe39f87ade8fc527@mail.gmail.com> <18726.45239.5621.276088@harpo.it.uu.se> <4926B5C8.8040608@cs.ntua.gr> Message-ID: <6c2563b20811210910v650ab351p9f837fd211e2a0ff@mail.gmail.com> Ok, then, it's attached. I did a double check, and the HiPE-related speedup was a bit less than 10x; it was 7-8x, in line with your previous experiences. It's still a really good speedup (big difference between an hour of run-time and 8 minutes!) The really significant thing is the combination of HiPE and parallelism: a 29x speedup over sequential BEAM. If I had more processors ("only" 4), it would be even better. I'm sure you can find ways to improve the program; if so, I'd appreciate seeing the changes to learn better Erlang. Regards, Edwin Fine. PS Kostis, I see you have an email address in Greece. Do you perhaps know or know of my friend Diomidis Spinellis from the U of Athens? He's a very smart, great guy. PPS I ran the program on an approx. 600MB ISO, using BEAM, HiPE, and parallel HiPE. Results are below. *13> c(charclass). * {ok,charclass} 14> charclass:bm("/home/efine/downloads/railslive-0.2.1.iso"). *** Completed run using classify_binary *** File "/home/efine/downloads/railslive-0.2.1.iso" size is 616232960 bytes Classified 616232960 characters Breakdown: [{'8bit',313770058}, {alnum,145673634}, {alpha,122172907}, {ascsp,2129902}, {blank,4380198}, {cntrl,77553142}, {digit,23500727}, {lower,62169483}, {print,224909760}, {punct,77106224}, {space,13574043}, {upper,60003424}] *Speed = 2577047 bytes/sec (0.38804092367925275 us/byte)* ok *15> c(charclass,[native]). * {ok,charclass} 16> charclass:bm("/home/efine/downloads/railslive-0.2.1.iso"). *** Completed run using classify_binary *** File "/home/efine/downloads/railslive-0.2.1.iso" size is 616232960 bytes Classified 616232960 characters Breakdown: [{'8bit',313770058}, {alnum,145673634}, {alpha,122172907}, {ascsp,2129902}, {blank,4380198}, {cntrl,77553142}, {digit,23500727}, {lower,62169483}, {print,224909760}, {punct,77106224}, {space,13574043}, {upper,60003424}] *Speed = 19187638 bytes/sec (0.05211688774323269 us/byte)* ok 17> *charclass:bm_par("/home/efine/downloads/railslive-0.2.1.iso").* *** Completed run using par_classify_binary *** File "/home/efine/downloads/railslive-0.2.1.iso" size is 616232960 bytes Classified 616232960 characters Breakdown: [{'8bit',313770058}, {alnum,145673634}, {alpha,122172907}, {ascsp,2129902}, {blank,4380198}, {cntrl,77553142}, {digit,23500727}, {lower,62169483}, {print,224909760}, {punct,77106224}, {space,13574043}, {upper,60003424}] *Speed = 75454793 bytes/sec (0.013252968487761512 us/byte)* On Fri, Nov 21, 2008 at 8:21 AM, Kostis Sagonas wrote: > Mikael Pettersson wrote: > > Edwin Fine writes: > > > > > > That's extremely close to linear and is pretty impressive. I found > HiPE gave > > > about a 10x speedup over BEAM. The results are with HiPE and exclude > the > > > time taken to load the file into a binary. > > > > > > Kudos to Erlang and HiPE. > > > > Thanks. > > > > > PS In the unlikely event that someone wants the code, I will gladly > post it > > > if asked. > > > > Please do. I'd like to include it in the benchmark section > > of HiPE's compiler test suite. > > The 10x speedup over BEAM really put a smile on my face :-) > > It put a big smile on my face too, but I am not so surprised. > > In programs manipulating binaries, we've often experienced such speedups > (typically 8x) over BEAM when using HiPE, and judging from Edwin's post, > this appears to be a binary-intensive program. (Of course I _will_ be > very surprised if the speedup is due to some reason other than binaries.) > > But having the program is a good thing nonetheless. > > Kostis > > -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: charclass.erl Type: text/x-erlang Size: 8574 bytes Desc: not available URL: From dmercer@REDACTED Fri Nov 21 18:28:36 2008 From: dmercer@REDACTED (David Mercer) Date: Fri, 21 Nov 2008 11:28:36 -0600 Subject: [erlang-questions] Inlining Restrictions Message-ID: Are there any restrictions on when it is legal to do function inlining (with either the -compile(inline) directive or the compiler option)? Reason I ask is that I have code that compiles fine without inlining but crashes with an "internal error in kernel_module" error when I enable inlining. Am wondering if I could refactor my code and take out the offending statement and so allow function inlining. Please advise. Thank-you. David -------------- next part -------------- An HTML attachment was scrubbed... URL: From rtrlists@REDACTED Fri Nov 21 18:42:00 2008 From: rtrlists@REDACTED (Robert Raschke) Date: Fri, 21 Nov 2008 17:42:00 +0000 Subject: [erlang-questions] Starting and monitoring a Java Node Message-ID: <6a3ae47e0811210942u15a2836ck27dd041fdc1f78f8@mail.gmail.com> Hi, I am playing around with jinterface and was wondering if there is a standard way to kick off my jinterfaced program from within Erlang and get it monitored. My previous experience was with ei port programs. So, it's the port commands that start and monitor. Would it be reasonable to do the same thing for the Java node? That is, I start the Java program using port_open() and have a tiny bit of scaffolding that handles any crashes. The bulk of activity would then happen through normal message sending. Thanks for any pointers, Robby From kostis@REDACTED Fri Nov 21 19:14:46 2008 From: kostis@REDACTED (Kostis Sagonas) Date: Fri, 21 Nov 2008 20:14:46 +0200 Subject: [erlang-questions] On a positive Erlang performance note... In-Reply-To: <6c2563b20811210910v650ab351p9f837fd211e2a0ff@mail.gmail.com> References: <6c2563b20811201447i5aa44d74rbe39f87ade8fc527@mail.gmail.com> <18726.45239.5621.276088@harpo.it.uu.se> <4926B5C8.8040608@cs.ntua.gr> <6c2563b20811210910v650ab351p9f837fd211e2a0ff@mail.gmail.com> Message-ID: <4926FA96.4070200@cs.ntua.gr> Edwin Fine wrote: > Ok, then, it's attached. I did a double check, and the HiPE-related > speedup was a bit less than 10x; it was 7-8x, in line with your previous > experiences. It's still a really good speedup (big difference between an > hour of run-time and 8 minutes!) > > The really significant thing is the combination of HiPE and parallelism: > a 29x speedup over sequential BEAM. If I had more processors ("only" 4), > it would be even better. I might give it a try on a 16 core machine next week and see what happens. You may want to put the data file on the web somewhere. > I'm sure you can find ways to improve the > program; if so, I'd appreciate seeing the changes to learn better Erlang. > > Regards, > Edwin Fine. > > PS Kostis, I see you have an email address in Greece. Do you perhaps > know or know of my friend Diomidis Spinellis from the U of Athens? He's > a very smart, great guy. Yes, I know Diomidis (btw, he is from the Univ. of Economics & Business, not to be confused with the Univ. of Athens). And yes, Athens Greece is known for producing very smart, great guys ;-) Cheers, Kostis From richardc@REDACTED Fri Nov 21 19:20:13 2008 From: richardc@REDACTED (Richard Carlsson) Date: Fri, 21 Nov 2008 19:20:13 +0100 Subject: [erlang-questions] Inlining Restrictions In-Reply-To: References: Message-ID: <4926FBDD.5090404@it.uu.se> David Mercer wrote: > Are there any restrictions on when it is legal to do function inlining > (with either the ?compile(inline) directive or the compiler option)? > Reason I ask is that I have code that compiles fine without inlining but > crashes with an ?internal error in kernel_module? error when I enable > inlining. Am wondering if I could refactor my code and take out the > offending statement and so allow function inlining. Please advise. > Thank-you. If possible, please send me your code (or even better, a minimal example that displays this bug) so I can have a look. Inlining is supposed to work without any need for tweaking. /Richard From dmercer@REDACTED Fri Nov 21 20:58:47 2008 From: dmercer@REDACTED (David Mercer) Date: Fri, 21 Nov 2008 13:58:47 -0600 Subject: [erlang-questions] Inlining Restrictions In-Reply-To: <4926FBDD.5090404@it.uu.se> References: <4926FBDD.5090404@it.uu.se> Message-ID: Having stripped the whole thing down to a minimal example, the problem appears to be with using functions in guards. Here's my minimal example: ---------------------------------------------------------------------- -module(inline_test). -compile(inline). -export([exported_fun/0]). exported_fun() -> fun_with_guard(fun used_in_guard/0). fun_with_guard(GuardedFun) when is_function(GuardedFun) -> x. used_in_guard() -> x. ---------------------------------------------------------------------- > -----Original Message----- > From: Richard Carlsson [mailto:richardc@REDACTED] > Sent: Friday, November 21, 2008 12:20 > To: dmercer@REDACTED > Cc: 'Erlang Questions' > Subject: Re: [erlang-questions] Inlining Restrictions > > David Mercer wrote: > > Are there any restrictions on when it is legal to do function inlining > > (with either the -compile(inline) directive or the compiler option)? > > Reason I ask is that I have code that compiles fine without inlining but > > crashes with an "internal error in kernel_module" error when I enable > > inlining. Am wondering if I could refactor my code and take out the > > offending statement and so allow function inlining. Please advise. > > Thank-you. > > If possible, please send me your code (or even better, a minimal > example that displays this bug) so I can have a look. Inlining is > supposed to work without any need for tweaking. > > /Richard From erlangy@REDACTED Fri Nov 21 21:27:35 2008 From: erlangy@REDACTED (Michael McDaniel) Date: Fri, 21 Nov 2008 12:27:35 -0800 Subject: [erlang-questions] Reading records with file:consult/1 or erl_eval/2? In-Reply-To: References: Message-ID: <20081121202735.GF10121@delora.autosys.us> I know using a priori knowledge of record format is not long-term safe, sometimes I cannot help myself so do things like ... file.conf -------- % -record(buddies, { list = ["buddy", "buddy1", ... "buddyN"] } ) {buddies, [ member_one , member_two , member_three ] }. -------- and use it thusly ... -record(buddies, { list = [] }). %% From::atom() member(From) -> {ok, TermList} = file:consult( "file.conf" ) , {value, ConfRecBuddies} = lists:keysearch(buddies, 1, TermList) , Members = ConfRecBuddies#buddies.list , lists:member(From, Members) . %member/1 ~Michael On Fri, Nov 21, 2008 at 09:29:21AM -0500, Rusty Klophaus wrote: > Hi all, > > I'm working on a small utility that reads Erlang terms from a file, > processes them, and spits out another file. > > I've hit an unanticipated snag on step one. I can read basic terms > just fine, but I can't make file:consult/1 or erl_eval:expr/2 > recognize records. Any suggestions? Is this just a known limitation? > > Output and code are below. > > Thanks, > Rusty > > > *** OUTPUT *** > > Eshell V5.6.5 (abort with ^G) > 1> reader:read_with_consult(). > {error,{1,erl_parse,"bad term"}} > 2> reader:read_with_eval(). > ** exception error: {undefined_record,document} > > Here is the code and supporting files: > > *** READER.ERL CONTAINS *** > > -module (reader). > -include ("records.hrl"). > -compile(export_all). > > read_with_consult() -> > file:consult("terms.txt"). > > read_with_eval() -> > {ok, B} = file:read_file("terms.txt"), > S = binary_to_list(B), > {ok, Tokens, _} = erl_scan:string(S), > {ok, [Form]} = erl_parse:parse_exprs(Tokens), > erl_eval:expr(Form, []). > > > > *** RECORDS.HRL CONTAINS *** > > -record(document, {title, description}). > > > > *** TERMS.TXT CONTAINS *** > > #document {}. > > > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- Michael McDaniel Portland, Oregon, USA http://autosys.us From richardc@REDACTED Fri Nov 21 21:56:27 2008 From: richardc@REDACTED (Richard Carlsson) Date: Fri, 21 Nov 2008 21:56:27 +0100 Subject: [erlang-questions] Inlining Restrictions In-Reply-To: References: <4926FBDD.5090404@it.uu.se> Message-ID: <4927207B.2040202@it.uu.se> David Mercer wrote: > Having stripped the whole thing down to a minimal example, the problem > appears to be with using functions in guards. Here's my minimal example: > > ---------------------------------------------------------------------- > -module(inline_test). > -compile(inline). > -export([exported_fun/0]). > > exported_fun() -> fun_with_guard(fun used_in_guard/0). > > fun_with_guard(GuardedFun) when is_function(GuardedFun) -> x. > > used_in_guard() -> x. > ---------------------------------------------------------------------- Thank you for doing that. The bad news is that it's a known bug (to me), and I haven't had time to work on it. The good news is that at least it's not a new bug. The problem is really that the beam backend cannot handle fun-literals within guards, and the inliner can sneak such a literal past the "lint" stage which checks that the guards are valid, hence the crash. Of course, the limitation is mainly an artificial one and should be fixed. (And I'll have to find out why the inliner doesn't reduce the guard test to 'true'.) I'll have to raise the priority on this one, but meanwhile you need to find a way around it, perhaps by turning off inlining on this module. /Richard From vladdu55@REDACTED Fri Nov 21 22:46:34 2008 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Fri, 21 Nov 2008 22:46:34 +0100 Subject: [erlang-questions] [ANN] Erlide 0.4.0 was released Message-ID: <95be1d3b0811211346n2de6140btfb3ccd8821f8f7f8@mail.gmail.com> Hi all! Finally, the 0.4 release is here! We now have a functioning debugger, much better stability and a lot of smaller features that are waiting to be explored! Please check the documentation inside Eclipse or at http://erlide.sourceforge.net/erlide.html for more details. Please note that if you used older versions you might have to reinstall the Erlang runtime: go to "Window-> Preferences-> Erlang-> Installed runtimes" to check. If you encounter problems, please use the "Window-> Preferences-> Erlang-> Report problems" dialog. Enjoy! /Vlad and Jakob From steven.charles.davis@REDACTED Sat Nov 22 00:27:42 2008 From: steven.charles.davis@REDACTED (Steve Davis) Date: Fri, 21 Nov 2008 15:27:42 -0800 (PST) Subject: [erlang-questions] next(Erlang): "Fix up records so that records are first-class citizens and not just syntax saccharine for tuples?" In-Reply-To: <8092dc770811210415k43823062k3794c3356c0943d4@mail.gmail.com> References: <8092dc770811191445ie3e8066qf226ddae04cdb3b3@mail.gmail.com> <16f33854-7813-4ff2-8730-23653e726ffe@g38g2000yqn.googlegroups.com> <8092dc770811210415k43823062k3794c3356c0943d4@mail.gmail.com> Message-ID: <26b47693-c856-4f94-9857-f7365c94157a@g38g2000yqn.googlegroups.com> On Nov 21, 6:15?am, "damien morton" wrote: > On Fri, Nov 21, 2008 at 10:16 PM, Steve Davis > > wrote: > > If you are really serious about this - here are some considerations/ > > dogma from me: > > - Don't try to support inheritance (preferring decorators will save > > you untold issues later) > > Heh. I dont think anyone is proposing that. > Thank goodness! (Good call). > > - Consider how close/far JSON maps to record tuples > > Richard's frames map very nicely to JSON and back. > Hmm. JSON uses Strings for property names -- is it really an impedance mismatch that you should dismiss so easily? i.e. JSON: { "Object": {"name": "Damien", "location": "here" }} Erlang: -record(object {name, location}) which has a tuple representation { "Damien", "here" } (case differences emphasized for effect) > > - C.J. Date once said that the big issue with ORM was SQL's lack of > > support for relational domains > > You're talking about enum equivalents? I'm saying that objects should be representable in long-term storage without a high impedance mismatch, and should not be an afterthought. Pick a strategy now. (Erlang's strategy was tuple storage... As for enums, if you wonder why atoms are so powerful, then take a detailed look at Java's respresentation/implementation/use sometime. It's a picture of a struggle against its own rules. > > > - XML is a disaster for almost all purposes, so don't be tempted to > > use it for "configuration" or "communications" (it took me a while to > > finally understand Joe's view, but I am 110% there now) > > Do you have a link to Joe's view on XML? > Ulf gave the best link. XML (invented at Microsoft) is SGML for idiots, (HTML is SGML for complete idiots which is why it became so popular). Where XML went wrong is that everybody forgot that XML stands for extensible MARKUP language. i.e. the intention is to provide easy to read HINTS for DOCUMENT DISPLAY. Things like schema, relax-ng, and functional additions like xpath etc are bolt on's to improve the semantics of your hints, but mean that XML is not for idiots any more. That being so, and evaluated as it should be now as a data definition/transformation hybrid language, it's simply repetitive, unnecessarily hard to parse, transfer and simply bloats the codebase. It's so noisy that it's no longer easy to read or write which makes the whole machine-readable thing moot. Given only a developer can write it now, why not use some kind of universal binary format that's fast to transmit, easy to parse and saves both electricity, trees, and developer time -- oh wait... didn't Joe suggest that? :) IN THIS CONTEXT (yes there's a point) *reconsider* the relationship between json, tuples, and record/object representations. > > - The entire set of required modifiers is likely: required, unique, > > optional, readonly (and possibly "hidden") > > > - The entire set of required fundamental types is likely: text, > > number, flag > > - Don't allow nulls in any shape or form > > Ahh - the "schema" I referred to was merely the set of keys - its just > an implementation detail that the set of keys _can_ be shared between > frame instances, though this is not necessary. Probably the wrong word > to use. Actually my point was that you probably need constraints that make sense to long-term store and thin clients to make any object implementation truly useful and robust. Not everything is an object, but then not everything is a function either (even if one can be used to represent the other i.e. in OOP functions are second-class, in lambda - data structures are second class. There's definitely room for an equal partnership if you can devise one :) /s From joe@REDACTED Sat Nov 22 00:37:59 2008 From: joe@REDACTED (Joe Williams) Date: Fri, 21 Nov 2008 17:37:59 -0600 Subject: [erlang-questions] erlang port and C executable Message-ID: <49274657.3020202@joetify.com> Hello, I am having an issue when I attempt to send and receive messages to a C executable. I believe the task should be fairly trivial but I am getting hung up on sending messages to the port. Here's what I have so far: > Eshell V5.6.3 (abort with ^G) > 1> Cmd = "SOME_EXECUTABLE", > 1> Port = open_port({spawn, Cmd}, []). > #Port<0.93> > 2> receive > 2> {Port, {data, Data}} -> > 2> io:format("~p~n", [Data]); > 2> Error -> > 2> io:format("~p~n", [Error]) > 2> end. > "TEXT FROM THE EXECUTABLE" > ok > 3> Port ! <<"TEXT TO THE EXECUTABLE">>. > ** exception exit: badsig > 4> Port ! <<"TEXT TO THE EXECUTABLE">>. > <<"TEXT TO THE EXECUTABLE">> > 5> receive > 5> {Port, {data, Data}} -> > 5> io:format("~p~n", [Data]); > 5> Error -> > 5> io:format("~p~n", [Error]) > 5> end. After the last end my code just hangs and waits to receive a message rather than receiving the response from "TEXT TO THE EXECUTABLE". Since it received the first message properly I assume it would receive further responses in the same way. So I have two questions, the first is what does "exception exit: badsig" generally mean? The second how can I write this in such a way that I can send and receive strings until I have the program exit? Any guidance is appreciated. -Joe -- Name: Joseph A. Williams Email: joe@REDACTED From dmorton@REDACTED Sat Nov 22 01:07:35 2008 From: dmorton@REDACTED (damien morton) Date: Sat, 22 Nov 2008 11:07:35 +1100 Subject: [erlang-questions] next(Erlang): "Fix up records so that records are first-class citizens and not just syntax saccharine for tuples?" In-Reply-To: <26b47693-c856-4f94-9857-f7365c94157a@g38g2000yqn.googlegroups.com> References: <8092dc770811191445ie3e8066qf226ddae04cdb3b3@mail.gmail.com> <16f33854-7813-4ff2-8730-23653e726ffe@g38g2000yqn.googlegroups.com> <8092dc770811210415k43823062k3794c3356c0943d4@mail.gmail.com> <26b47693-c856-4f94-9857-f7365c94157a@g38g2000yqn.googlegroups.com> Message-ID: <8092dc770811211607m7b29ecc1kc532780d15ba5c9@mail.gmail.com> On Sat, Nov 22, 2008 at 10:27 AM, Steve Davis wrote: > >> > - Consider how close/far JSON maps to record tuples >> >> Richard's frames map very nicely to JSON and back. >> > > Hmm. JSON uses Strings for property names -- is it really an impedance > mismatch that you should dismiss so easily? > i.e. > JSON: { "Object": {"name": "Damien", "location": "here" }} > Erlang: -record(object {name, location}) which has a tuple > representation { "Damien", "here" } > (case differences emphasized for effect) Not dismissing it at all. Richard's frames proposal uses atoms for "property names". Every atom can be converted to a string, and every string can be converted to an atom. An atom is basically an interned string. Probably helpful to take a look at the frames proposal at http://www.cs.otago.ac.nz/staffpriv/ok/frames.pdf Essentially, what is being proposed is for frames to be dictionaries with atoms for keys. This is very similar to javascript dictionaries. There are a number of ways of implementing this. One way is to keep the list of keys separate from the list of values, which has the advantage that where you have many frames with the same keys but different data, you dont have to store the keys many times over - they keys can be shared between the frames. From bob@REDACTED Sat Nov 22 01:26:57 2008 From: bob@REDACTED (Bob Ippolito) Date: Fri, 21 Nov 2008 16:26:57 -0800 Subject: [erlang-questions] next(Erlang): "Fix up records so that records are first-class citizens and not just syntax saccharine for tuples?" In-Reply-To: <8092dc770811211607m7b29ecc1kc532780d15ba5c9@mail.gmail.com> References: <8092dc770811191445ie3e8066qf226ddae04cdb3b3@mail.gmail.com> <16f33854-7813-4ff2-8730-23653e726ffe@g38g2000yqn.googlegroups.com> <8092dc770811210415k43823062k3794c3356c0943d4@mail.gmail.com> <26b47693-c856-4f94-9857-f7365c94157a@g38g2000yqn.googlegroups.com> <8092dc770811211607m7b29ecc1kc532780d15ba5c9@mail.gmail.com> Message-ID: <6a36e7290811211626x7ecc71e2o138d478bcbecd5c6@mail.gmail.com> On Fri, Nov 21, 2008 at 4:07 PM, damien morton wrote: > On Sat, Nov 22, 2008 at 10:27 AM, Steve Davis > wrote: >> >>> > - Consider how close/far JSON maps to record tuples >>> >>> Richard's frames map very nicely to JSON and back. >>> >> >> Hmm. JSON uses Strings for property names -- is it really an impedance >> mismatch that you should dismiss so easily? >> i.e. >> JSON: { "Object": {"name": "Damien", "location": "here" }} >> Erlang: -record(object {name, location}) which has a tuple >> representation { "Damien", "here" } >> (case differences emphasized for effect) > > Not dismissing it at all. Richard's frames proposal uses atoms for > "property names". Every atom can be converted to a string, and every > string can be converted to an atom. An atom is basically an interned > string. That's not strictly true, atoms are limited to 255 characters I think. -bob From tali.wang@REDACTED Sat Nov 22 01:28:03 2008 From: tali.wang@REDACTED (Linan Wang) Date: Sat, 22 Nov 2008 00:28:03 +0000 Subject: [erlang-questions] mnesia question Message-ID: hi, I'm coding a simple queue application on top of mnesia. I found one strange thing that the last inserted row would lost if not referenced after restart. Is this a feature, bug, or my mistake? It has been troubling me for two days. I'm running R12 B5 on an iMac. Any suggestion is appreciated. ================================= My codes: ================================= -module(taskq). -export([start/0, db_put/1, db_get/0]). -record(oid, {name, id}). -record(task, {id, info}). start()-> %% start db or create; mnesia:start(), try mnesia:table_info(task, type) catch exit: _ -> utils:log("No db exists, create one."), mnesia:stop(), mnesia:create_schema([node()]), mnesia:start(), mnesia:create_table(oid, [{disc_copies, [node()]}, {type, set}, {attributes, record_info(fields, oid)}]), mnesia:create_table(task, [{disc_copies, [node()]}, {type, ordered_set}, {attributes, record_info(fields, task)}]), mnesia:transaction(fun()-> mnesia:s_write(#oid{name = task, id = 0}) end), utils:log("Taskdb created.") end. db_put(Info)-> mnesia:transaction(fun()-> Id = mnesia:dirty_update_counter({oid, task}, 1), mnesia:s_write(#task{id = Id, info = Info}) end). db_get()-> {atomic, R} = mnesia:transaction(fun()-> Id = mnesia:first(task), case Id of '$end_of_table' -> none; _ -> [Ret] = mnesia:wread({task, Id}), mnesia:s_delete({task, Id}), Ret#task.info end end), R. ================================== Execution session: ================================== Linan-iMac:~$ erl Erlang (BEAM) emulator version 5.6.5 [source] [async-threads:0] [kernel-poll:false] Eshell V5.6.5 (abort with ^G) 1> c(taskq). {ok,taskq} 2> c(utils). {ok,utils} 3> taskq:start(). 2008/11/22 0:23:17 No db exists, create one. =INFO REPORT==== 22-Nov-2008::00:23:17 === application: mnesia exited: stopped type: temporary 2008/11/22 0:23:18 Taskdb created. ok 4> taskq:put(abcde). {atomic,ok} 5> BREAK: (a)bort (c)ontinue (p)roc info (i)nfo (l)oaded (v)ersion (k)ill (D)b-tables (d)istribution q Linan-iMac:~$ erl Erlang (BEAM) emulator version 5.6.5 [source] [async-threads:0] [kernel-poll:false] Eshell V5.6.5 (abort with ^G) 1> taskq:start(). ordered_set 2> taskq:get(). none 3> Linan Wang -------------- next part -------------- An HTML attachment was scrubbed... URL: From erlangy@REDACTED Sat Nov 22 02:06:50 2008 From: erlangy@REDACTED (Michael McDaniel) Date: Fri, 21 Nov 2008 17:06:50 -0800 Subject: [erlang-questions] mnesia question In-Reply-To: <20081122010256.GH10121@delora.autosys.us> References: <20081122010256.GH10121@delora.autosys.us> Message-ID: <20081122010650.GI10121@delora.autosys.us> try 5> mnesia:stop(). 6> q(). instead of the CTRL-C, then restart and check - showed abcde for me. ~Michael P.S. of course, using db_put and db_get instead, and commenting out 'utils' lines On Sat, Nov 22, 2008 at 12:28:03AM +0000, Linan Wang wrote: > hi, > > I'm coding a simple queue application on top of mnesia. I found one > strange thing that the last inserted row would lost if not referenced > after restart. Is this a feature, bug, or my mistake? It has been > troubling me for two days. I'm running R12 B5 on an iMac. Any > suggestion is appreciated. > > ================================= > > My codes: > > ================================= > > > -module(taskq). > > -export([start/0, db_put/1, db_get/0]). > > > > -record(oid, {name, id}). > > -record(task, {id, info}). > > start()-> > > %% start db or create; > > mnesia:start(), > > try > > mnesia:table_info(task, type) > > catch > > exit: _ -> > > utils:log("No db exists, create one."), > > mnesia:stop(), > > mnesia:create_schema([node()]), > > > > mnesia:start(), > > mnesia:create_table(oid, [{disc_copies, [node()]}, {type, > > set}, {attributes, record_info(fields, oid)}]), > > mnesia:create_table(task, [{disc_copies, [node()]}, {type, > > ordered_set}, {attributes, record_info(fields, task)}]), > > > > mnesia:transaction(fun()-> > > mnesia:s_write(#oid{name = task, id = 0}) > > end), > > > > utils:log("Taskdb created.") > > end. > > > > db_put(Info)-> > > mnesia:transaction(fun()-> > > Id = mnesia:dirty_update_counter({oid, task}, 1), > > mnesia:s_write(#task{id = Id, info = Info}) > > end). > > db_get()-> > > {atomic, R} = mnesia:transaction(fun()-> > > Id = mnesia:first(task), > > case Id of > > '$end_of_table' -> > > none; > > _ -> > > [Ret] = mnesia:wread({task, Id}), > > mnesia:s_delete({task, Id}), > > Ret#[1]task.info > > end > > end), > > R. > > ================================== > > Execution session: > > ================================== > > Linan-iMac:~$ erl > > Erlang (BEAM) emulator version 5.6.5 [source] [async-threads:0] > > [kernel-poll:false] > > Eshell V5.6.5 (abort with ^G) > > 1> c(taskq). > > {ok,taskq} > > 2> c(utils). > > {ok,utils} > > 3> taskq:start(). > > 2008/11/22 0:23:17 No db exists, create one. > > =INFO REPORT==== 22-Nov-2008::00:23:17 === > > application: mnesia > > exited: stopped > > type: temporary > > 2008/11/22 0:23:18 Taskdb created. > > ok > > 4> taskq:put(abcde). > > {atomic,ok} > > 5> > > BREAK: (a)bort (c)ontinue (p)roc info (i)nfo (l)oaded > > (v)ersion (k)ill (D)b-tables (d)istribution > > q > > Linan-iMac:~$ erl > > Erlang (BEAM) emulator version 5.6.5 [source] [async-threads:0] > > [kernel-poll:false] > > Eshell V5.6.5 (abort with ^G) > > 1> taskq:start(). > > ordered_set > > 2> taskq:get(). > > none > > 3> > > Linan Wang > > > > References > > > > 1. http://task.info/ > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > -- > Michael McDaniel > Portland, Oregon, USA > http://autosys.us > From tali.wang@REDACTED Sat Nov 22 03:42:46 2008 From: tali.wang@REDACTED (Linan Wang) Date: Sat, 22 Nov 2008 02:42:46 +0000 Subject: [erlang-questions] mnesia question In-Reply-To: <20081122010650.GI10121@delora.autosys.us> References: <20081122010256.GH10121@delora.autosys.us> <20081122010650.GI10121@delora.autosys.us> Message-ID: thanks. it does the work. but what if the app crashes? will the last row lost? On Sat, Nov 22, 2008 at 1:06 AM, Michael McDaniel wrote: > try > > 5> mnesia:stop(). > 6> q(). > > > instead of the CTRL-C, > > then restart and check - showed abcde for me. > > ~Michael > P.S. of course, using db_put and db_get instead, and commenting out > 'utils' lines > > > On Sat, Nov 22, 2008 at 12:28:03AM +0000, Linan Wang wrote: > > hi, > > > > I'm coding a simple queue application on top of mnesia. I found one > > strange thing that the last inserted row would lost if not referenced > > after restart. Is this a feature, bug, or my mistake? It has been > > troubling me for two days. I'm running R12 B5 on an iMac. Any > > suggestion is appreciated. > > > > ================================= > > > > My codes: > > > > ================================= > > > > > -module(taskq). > > > -export([start/0, db_put/1, db_get/0]). > > > > > > -record(oid, {name, id}). > > > -record(task, {id, info}). > > > start()-> > > > %% start db or create; > > > mnesia:start(), > > > try > > > mnesia:table_info(task, type) > > > catch > > > exit: _ -> > > > utils:log("No db exists, create one."), > > > mnesia:stop(), > > > mnesia:create_schema([node()]), > > > > > > mnesia:start(), > > > mnesia:create_table(oid, [{disc_copies, [node()]}, > {type, > > > set}, {attributes, record_info(fields, oid)}]), > > > mnesia:create_table(task, [{disc_copies, [node()]}, > {type, > > > ordered_set}, {attributes, record_info(fields, task)}]), > > > > > > mnesia:transaction(fun()-> > > > mnesia:s_write(#oid{name = task, id = 0}) > > > end), > > > > > > utils:log("Taskdb created.") > > > end. > > > > > > db_put(Info)-> > > > mnesia:transaction(fun()-> > > > Id = mnesia:dirty_update_counter({oid, task}, 1), > > > mnesia:s_write(#task{id = Id, info = Info}) > > > end). > > > db_get()-> > > > {atomic, R} = mnesia:transaction(fun()-> > > > Id = mnesia:first(task), > > > case Id of > > > '$end_of_table' -> > > > none; > > > _ -> > > > [Ret] = mnesia:wread({task, Id}), > > > mnesia:s_delete({task, Id}), > > > Ret#[1]task.info > > > end > > > end), > > > R. > > > ================================== > > > Execution session: > > > ================================== > > > Linan-iMac:~$ erl > > > Erlang (BEAM) emulator version 5.6.5 [source] [async-threads:0] > > > [kernel-poll:false] > > > Eshell V5.6.5 (abort with ^G) > > > 1> c(taskq). > > > {ok,taskq} > > > 2> c(utils). > > > {ok,utils} > > > 3> taskq:start(). > > > 2008/11/22 0:23:17 No db exists, create one. > > > =INFO REPORT==== 22-Nov-2008::00:23:17 === > > > application: mnesia > > > exited: stopped > > > type: temporary > > > 2008/11/22 0:23:18 Taskdb created. > > > ok > > > 4> taskq:put(abcde). > > > {atomic,ok} > > > 5> > > > BREAK: (a)bort (c)ontinue (p)roc info (i)nfo (l)oaded > > > (v)ersion (k)ill (D)b-tables (d)istribution > > > q > > > Linan-iMac:~$ erl > > > Erlang (BEAM) emulator version 5.6.5 [source] [async-threads:0] > > > [kernel-poll:false] > > > Eshell V5.6.5 (abort with ^G) > > > 1> taskq:start(). > > > ordered_set > > > 2> taskq:get(). > > > none > > > 3> > > > Linan Wang > > > > > > References > > > > > > 1. http://task.info/ > > > > > _______________________________________________ > > > erlang-questions mailing list > > > erlang-questions@REDACTED > > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > -- > > Michael McDaniel > > Portland, Oregon, USA > > http://autosys.us > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- Best regards Linan Wang -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay@REDACTED Sat Nov 22 08:13:49 2008 From: jay@REDACTED (Jay Nelson) Date: Fri, 21 Nov 2008 23:13:49 -0800 Subject: [erlang-questions] Erlang elseif Message-ID: <44257A6E-1E2F-48E7-84D6-49F165D6DEDA@duomark.com> kdronnqvist wrote (I elided much of the original to focus on specific points): > The thing is that I want a general way to branch the execution > of my code based on the result on an expression. > the logic in what I'm trying to do is really REALLY not that > complicated. When I am writing C or Java or other procedural languages, I think in terms of if ... else and serial short-circuiting code. That is what the language family promotes. When I am writing functional code, I think in terms of whole sets or lists being filtered. A parallel set of tests is more akin to the mindset rather than a series of single steps, and branching is not a concept that I rely on. Instead I chain together functions in different orders depending on the pattern of the result that is returned. When I code in erlang, I think of 'case' as an exclusive set of options that are essentially considered in parallel and one is chosen as the path through the code. The other alternative that comes to mind is to run all tests and filter the results. These are just more natural ways which the language promotes. I don't worry about efficiency until I have working code which proves itself to be too slow. My first impression of your question is that you are thinking in terms of a procedural paradigm rather than a functional paradigm. My first inclination was a list comprehension, and reviewing your proposals I saw that your last option was on the right track, but a bit verbose: -------------------------------------------------- %% The list comprehension way elseif4(A) -> case [begin {Name,_} = X, Name end || X <- [{caps, ?CAPS}, {small, ?SMALL}, {nums, ?NUMS}], begin {_,List} = X, lists:member(A,List) end] of [caps] -> io:format("Member of capital\n"); [small] -> io:format("Member of small\n"); [nums] -> io:format("Member of nums\n"); _ -> io:format("Not a member\n") end. -------------------------------------------------- In my mind, you are combining two concepts: the tagging of a condition, and the printing of a result. You may need the tagged value for other reasons. Here's my approach: get_type(Char) -> TestPairs = [{"QWERTY", capitals}, {"qwerty", smalls}, {"123456", nums}], [Type || {CharSet, Type} <- TestPairs, lists:member(Char, CharSet)]. print_type(Char) -> [Type] = get_type(Char), io:format("Member of ~w~n", [Type]). get_type/1 is a tagging function which uses a list comprehension generator followed by lists:member/2 as a filter. The shorthand is to do a "destructuring bind" for each element passed out of the list. Filters can be any function or expression which returns true or false, skipping any elements which return false. This function can be used for disjoint tests or overlapping tests -- in either case you get a set of valid tags for the Char passed in (or [] if no tag applies). Here, I explicitly expect one matching tag type and specify that with the [Type] pattern. A case statement could be used instead: case get_type(Char) of [] -> io:format("Unknown char type"); [Type] -> io:format("Member of only one set: ~w~n", [Type]); MoreThanOneType -> io:format("Member of sets: ~w~n", [MoreThanOneType]) end. print_type/1 uses the result of tagging to print your desired result. The composition of tagging followed by tag analysis is a typical functional chaining of tasks. If you look at this code, the concept of branching on a condition is not represented. While what you wanted to do is conceptually simple, the serial branching technique does not occur to me as an approach when coding erlang. jay From rtrlists@REDACTED Sat Nov 22 13:26:02 2008 From: rtrlists@REDACTED (Robert Raschke) Date: Sat, 22 Nov 2008 12:26:02 +0000 Subject: [erlang-questions] erlang port and C executable In-Reply-To: <49274657.3020202@joetify.com> References: <49274657.3020202@joetify.com> Message-ID: <6a3ae47e0811220426g53c53d7m9fd3dd5e3678a2fa@mail.gmail.com> Hi Joe, On Fri, Nov 21, 2008 at 11:37 PM, Joe Williams wrote: > Hello, > > I am having an issue when I attempt to send and receive messages to a C > executable. I believe the task should be fairly trivial but I am getting > hung up on sending messages to the port. Here's what I have so far: > >> Eshell V5.6.3 (abort with ^G) >> 1> Cmd = "SOME_EXECUTABLE", >> 1> Port = open_port({spawn, Cmd}, []). >> #Port<0.93> >> 2> receive >> 2> {Port, {data, Data}} -> >> 2> io:format("~p~n", [Data]); >> 2> Error -> >> 2> io:format("~p~n", [Error]) >> 2> end. >> "TEXT FROM THE EXECUTABLE" >> ok >> 3> Port ! <<"TEXT TO THE EXECUTABLE">>. >> ** exception exit: badsig >> 4> Port ! <<"TEXT TO THE EXECUTABLE">>. >> <<"TEXT TO THE EXECUTABLE">> >> 5> receive >> 5> {Port, {data, Data}} -> >> 5> io:format("~p~n", [Data]); >> 5> Error -> >> 5> io:format("~p~n", [Error]) >> 5> end. > > After the last end my code just hangs and waits to receive a message > rather than receiving the response from "TEXT TO THE EXECUTABLE". Since > it received the first message properly I assume it would receive further > responses in the same way. So I have two questions, the first is what > does "exception exit: badsig" generally mean? The second how can I write > this in such a way that I can send and receive strings until I have the > program exit? > > Any guidance is appreciated. > I would suggest not using the shell for this, but to write a small module. For example, your second receive uses already bound names (e.g. Data) so that won't do what you expect. Have a look at the Documentation: Erlang Programming -> Interoperability Tutorial, Section 4 Ports (http://www.erlang.org/doc/tutorial/part_frame.html) where you can see a minimal port program wrapped by an Erlang process. Robby From vances@REDACTED Sat Nov 22 15:50:40 2008 From: vances@REDACTED (Vance Shipley) Date: Sat, 22 Nov 2008 09:50:40 -0500 Subject: [erlang-questions] Tim Bray: "better things on the horizon" Message-ID: <20081122145039.GC280@h216-235-12-173.host.egate.net> The Register are carrying a report on a keynote address by Tim Bray at QCon 2009 where he cites the CouchDB project as something which should be on attendee's radar. http://www.theregister.co.uk/2008/11/22/braykeynote/ -Vance From vances@REDACTED Sat Nov 22 15:29:33 2008 From: vances@REDACTED (Vance Shipley) Date: Sat, 22 Nov 2008 09:29:33 -0500 Subject: [erlang-questions] mnesia question In-Reply-To: References: Message-ID: <20081122142933.GB280@h216-235-12-173.host.egate.net> On Sat, Nov 22, 2008 at 12:28:03AM +0000, Linan Wang wrote: } I found one strange thing that the last inserted row would lost } if not referenced after restart. The problem is with the use of a sticky write lock: } mnesia:transaction(fun()-> } mnesia:s_write(#oid{name = task, id = 0}) } end), If you change this to not use a sticky write lock it works as you expect: mnesia:transaction(fun()-> mnesia:write(#oid{name = task, id = 0}) end), I can't help but offer the advice given in Erlang Programming Rules section 3.8: Don't optimize code. http://www.erlang.se/doc/programming_rules.shtml#HDR6 -Vance From tali.wang@REDACTED Sat Nov 22 17:32:52 2008 From: tali.wang@REDACTED (Linan Wang) Date: Sat, 22 Nov 2008 16:32:52 +0000 Subject: [erlang-questions] mnesia question In-Reply-To: <20081122142933.GB280@h216-235-12-173.host.egate.net> References: <20081122142933.GB280@h216-235-12-173.host.egate.net> Message-ID: thanks for the suggestion.I changed all s_write, wread, s_delete to straightforward write, read, delete. it does not help. On Sat, Nov 22, 2008 at 2:29 PM, Vance Shipley wrote: > On Sat, Nov 22, 2008 at 12:28:03AM +0000, Linan Wang wrote: > } I found one strange thing that the last inserted row would lost > } if not referenced after restart. > > The problem is with the use of a sticky write lock: > } mnesia:transaction(fun()-> > } mnesia:s_write(#oid{name = task, id = 0}) > } end), > > If you change this to not use a sticky write lock it works as you > expect: > > mnesia:transaction(fun()-> mnesia:write(#oid{name = task, id = 0}) end), > > I can't help but offer the advice given in Erlang Programming > Rules section 3.8: Don't optimize code. > > http://www.erlang.se/doc/programming_rules.shtml#HDR6 > > -Vance > -- Best regards Linan Wang -------------- next part -------------- An HTML attachment was scrubbed... URL: From vances@REDACTED Sat Nov 22 17:40:10 2008 From: vances@REDACTED (Vance Shipley) Date: Sat, 22 Nov 2008 11:40:10 -0500 Subject: [erlang-questions] mnesia question In-Reply-To: References: <20081122142933.GB280@h216-235-12-173.host.egate.net> Message-ID: <20081122164009.GE280@h216-235-12-173.host.egate.net> Linan, I tried your sample code and confirmed the behaviour you reported. Then I changed mnesia:s_write/1 to mnesia:write/1 and it worked as expected. -Vance On Sat, Nov 22, 2008 at 04:32:52PM +0000, Linan Wang wrote: } thanks for the suggestion.I changed all s_write, wread, s_delete to } straightforward write, read, delete. it does not help. From tali.wang@REDACTED Sat Nov 22 18:16:23 2008 From: tali.wang@REDACTED (Linan Wang) Date: Sat, 22 Nov 2008 17:16:23 +0000 Subject: [erlang-questions] mnesia question In-Reply-To: <20081122164009.GE280@h216-235-12-173.host.egate.net> References: <20081122142933.GB280@h216-235-12-173.host.egate.net> <20081122164009.GE280@h216-235-12-173.host.egate.net> Message-ID: Vance,Thank you very much. but it really not. ===================== = code ===================== -module(taskq). -export([start/0, db_put/1, db_get/0]). -record(oid, {name, id}). -record(task, {id, info}). start()-> mnesia:start(), try mnesia:table_info(task, type) catch exit: _ -> mnesia:stop(), mnesia:create_schema([node()]), mnesia:start(), mnesia:create_table(oid, [{disc_copies, [node()]}, {type, set}, {attributes, record_info(fields, oid)}]), mnesia:create_table(task, [{disc_copies, [node()]}, {type, ordered_set}, {attributes, record_info(fields, task)}]), mnesia:transaction(fun()-> mnesia:write(#oid{name = task, id = 0}) end) end. db_put(Info)-> mnesia:transaction(fun()-> Id = mnesia:dirty_update_counter({oid, task}, 1), mnesia:write(#task{id = Id, info = Info}) end). db_get()-> {atomic, R} = mnesia:transaction(fun()-> Id = mnesia:first(task), case Id of '$end_of_table' -> none; _ -> [Ret] = mnesia:wread({task, Id}), mnesia:delete({task, Id}), Ret#task.info end end), R. ===================== = exection ===================== Linan-iMac:~ wangii$ erl Erlang (BEAM) emulator version 5.6.5 [source] [async-threads:0] [kernel-poll:false] Eshell V5.6.5 (abort with ^G) 1> c(taskdb). error 2> c(taskq). {ok,taskq} 3> taskq:start(). =INFO REPORT==== 22-Nov-2008::17:07:20 === application: mnesia exited: stopped type: temporary {atomic,ok} 4> taskq:put(abcdefa). ** exception error: undefined function taskq:put/1 5> taskq:db_put(abcdefa). {atomic,ok} 6> BREAK: (a)bort (c)ontinue (p)roc info (i)nfo (l)oaded (v)ersion (k)ill (D)b-tables (d)istribution q Linan-iMac:~ wangii$ erl Erlang (BEAM) emulator version 5.6.5 [source] [async-threads:0] [kernel-poll:false] Eshell V5.6.5 (abort with ^G) 1> taskq:start(). ordered_set 2> taskq:db_get(). none 3> On Sat, Nov 22, 2008 at 4:40 PM, Vance Shipley wrote: > Linan, > > I tried your sample code and confirmed the behaviour you reported. > Then I changed mnesia:s_write/1 to mnesia:write/1 and it worked as > expected. > > -Vance > > On Sat, Nov 22, 2008 at 04:32:52PM +0000, Linan Wang wrote: > } thanks for the suggestion.I changed all s_write, wread, s_delete to > } straightforward write, read, delete. it does not help. > -- Best regards Linan Wang -------------- next part -------------- An HTML attachment was scrubbed... URL: From pfisher@REDACTED Fri Nov 21 16:11:53 2008 From: pfisher@REDACTED (Paul Fisher) Date: Fri, 21 Nov 2008 09:11:53 -0600 Subject: [erlang-questions] HiPE on .beam files? (was: Why can't HiPE inline functions across ...) Message-ID: <4926CFB9.1050900@alertlogic.net> Mikael Pettersson wrote: > > For better or worse, HiPE is not structured as a typical Java JIT, > > but more as a traditional ahead-of-time compiler (though it can be > > invoked at runtime in a running system). One of its current limitations > > is that it does not retain the native code's original Erlang/BEAM code > > at runtime, and that makes runtime recompilation of native code impossible. Tangentially, is it possible to take a .beam file w/o native code, run HiPE on it generating a new .beam file with native code? This would be wonderful as an install-time tool for people who want to always run everything with HiPE. -- paul From erlang-questions_efine@REDACTED Sun Nov 23 07:14:56 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Sun, 23 Nov 2008 01:14:56 -0500 Subject: [erlang-questions] erlang port and C executable In-Reply-To: <49274657.3020202@joetify.com> References: <49274657.3020202@joetify.com> Message-ID: <6c2563b20811222214u1fa7130ese1a2d4ed8ce94a3e@mail.gmail.com> Joe, I don't know if this is still a problem, but I didn't know the answer, so I was intrigued. Having never used C ports before, I thought it would be useful to learn about them. I looked at the C code for Erlang (io.c module) and it seems that this signal (badsig) is sent when bad port command is received. The port command was bad because you can't just send raw data to a port as in Port ! <<"Hello">>. It requires a specific format. You have to either send Port ! {self(), {command, <<"Hello">>}} or (which I like better) erlang:port_command(Port, <<"Hello">>). In terms of how you can send and receive strings, this whole port thing turned out to be much more difficult to figure than I anticipated (but easier when you know how). One of the most annoying aspects is that under circumstances that are not clear to me, the C program that is spawned sometimes does not seem to be sent a signal for end of file when you close the port, so if it is reading stdin, it's just going to sit there until killed manually. Worse, if it gets stuck doing something and is NOT reading stdin then you are out of luck. But what if the 'C' program is not under your control, say, it's part of Linux, and you need to make sure it's killed when you are done? Then I believe you need to write a wrapper around the 'C' program. I refer you to the following post for an interesting way to do this: http://www.erlang.org/pipermail/erlang-questions/2007-October/030377.html As for how to send and receive strings, assuming there is a way to terminate the 'C' program, I eventually came up with the following "demo" code (which does rely on newlines, and I know there are other ways; this is one of them). Hope this helps. Regards, Edwin Fine /* echo_svr.c: Simple C program to echo stdin to stdout */ #include int main() { char buf[4096]; while (fgets(buf, sizeof(buf), stdin) != NULL) { fputs(buf, stdout); fflush(stdout); } return 0; } echo_svr.erl: -module(test_echo_svr). -export([go/2]). go(EchoSvrExecFilePath, Iters) when is_list(EchoSvrExecFilePath), is_integer(Iters), Iters >= 0 -> process_flag(trap_exit, true), Port = erlang:open_port({spawn, EchoSvrExecFilePath}, [binary]), test(Port, <<>>, Iters, 1). test(Port, _Buf, 0, _N) -> erlang:port_close(Port), ok; test(Port, Buf, Iters, N) -> Out = list_to_binary([<<"Test message ">>, integer_to_list(N), $\n]), erlang:port_command(Port, Out), receive {Port, {data, In}} -> {Line, Rest} = parse(list_to_binary([Buf, In])), io:format("~p~n", [Line]), test(Port, Rest, Iters - 1, N + 1) after 3000 -> io:format("Receive timeout, stopping.~n") end. parse(Msg) -> parse(Msg, []). parse(<<>>, Acc) -> {lists:reverse(Acc), <<>>}; parse(<<$\n, Rest/binary>>, Acc) -> {lists:reverse(Acc), Rest}; % EOL parse(<>, Acc) -> parse(Rest, [Byte|Acc]). 113> test_echo_svr:go("/path/to/echo_svr", 3). "Test message 1" "Test message 2" "Test message 3" ok On Fri, Nov 21, 2008 at 6:37 PM, Joe Williams wrote: > Hello, > > I am having an issue when I attempt to send and receive messages to a C > executable. I believe the task should be fairly trivial but I am getting > hung up on sending messages to the port. Here's what I have so far: > > > Eshell V5.6.3 (abort with ^G) > > 1> Cmd = "SOME_EXECUTABLE", > > 1> Port = open_port({spawn, Cmd}, []). > > #Port<0.93> > > 2> receive > > 2> {Port, {data, Data}} -> > > 2> io:format("~p~n", [Data]); > > 2> Error -> > > 2> io:format("~p~n", [Error]) > > 2> end. > > "TEXT FROM THE EXECUTABLE" > > ok > > 3> Port ! <<"TEXT TO THE EXECUTABLE">>. > > ** exception exit: badsig > > 4> Port ! <<"TEXT TO THE EXECUTABLE">>. > > <<"TEXT TO THE EXECUTABLE">> > > 5> receive > > 5> {Port, {data, Data}} -> > > 5> io:format("~p~n", [Data]); > > 5> Error -> > > 5> io:format("~p~n", [Error]) > > 5> end. > > After the last end my code just hangs and waits to receive a message > rather than receiving the response from "TEXT TO THE EXECUTABLE". Since > it received the first message properly I assume it would receive further > responses in the same way. So I have two questions, the first is what > does "exception exit: badsig" generally mean? The second how can I write > this in such a way that I can send and receive strings until I have the > program exit? > > Any guidance is appreciated. > > -Joe > > -- > Name: Joseph A. Williams > Email: joe@REDACTED > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From joe@REDACTED Sun Nov 23 07:21:23 2008 From: joe@REDACTED (Joe Williams) Date: Sun, 23 Nov 2008 00:21:23 -0600 Subject: [erlang-questions] erlang port and C executable In-Reply-To: <6c2563b20811222214u1fa7130ese1a2d4ed8ce94a3e@mail.gmail.com> References: <49274657.3020202@joetify.com> <6c2563b20811222214u1fa7130ese1a2d4ed8ce94a3e@mail.gmail.com> Message-ID: <4928F663.2030809@joetify.com> Edwin/Robert, Thanks for the info, I will see what I can put together and if it's worthwhile report back my findings. -Joe Edwin Fine wrote: > Joe, > > I don't know if this is still a problem, but I didn't know the answer, > so I was intrigued. Having never used C ports before, I thought it > would be useful to learn about them. > > I looked at the C code for Erlang (io.c module) and it seems that this > signal (badsig) is sent when bad port command is received. The port > command was bad because you can't just send raw data to a port as in > Port ! <<"Hello">>. It requires a specific format. You have to either > send Port ! {self(), {command, <<"Hello">>}} or (which I like better) > erlang:port_command(Port, <<"Hello">>). > > In terms of how you can send and receive strings, this whole port > thing turned out to be much more difficult to figure than I > anticipated (but easier when you know how). One of the most annoying > aspects is that under circumstances that are not clear to me, the C > program that is spawned sometimes does not seem to be sent a signal > for end of file when you close the port, so if it is reading stdin, > it's just going to sit there until killed manually. Worse, if it gets > stuck doing something and is NOT reading stdin then you are out of luck. > > But what if the 'C' program is not under your control, say, it's part > of Linux, and you need to make sure it's killed when you are done? > Then I believe you need to write a wrapper around the 'C' program. I > refer you to the following post for an interesting way to do this: > > http://www.erlang.org/pipermail/erlang-questions/2007-October/030377.html > > As for how to send and receive strings, assuming there is a way to > terminate the 'C' program, I eventually came up with the following > "demo" code (which does rely on newlines, and I know there are other > ways; this is one of them). Hope this helps. > > Regards, > Edwin Fine > > /* echo_svr.c: Simple C program to echo stdin to stdout */ > #include > > int main() > { > char buf[4096]; > > while (fgets(buf, sizeof(buf), stdin) != NULL) > { > fputs(buf, stdout); > fflush(stdout); > } > > return 0; > } > > echo_svr.erl: > > -module(test_echo_svr). > -export([go/2]). > > go(EchoSvrExecFilePath, Iters) when is_list(EchoSvrExecFilePath), > is_integer(Iters), Iters >= 0 -> > process_flag(trap_exit, true), > Port = erlang:open_port({spawn, EchoSvrExecFilePath}, [binary]), > test(Port, <<>>, Iters, 1). > > test(Port, _Buf, 0, _N) -> > erlang:port_close(Port), ok; > test(Port, Buf, Iters, N) -> > Out = list_to_binary([<<"Test message ">>, integer_to_list(N), $\n]), > erlang:port_command(Port, Out), > receive > {Port, {data, In}} -> > {Line, Rest} = parse(list_to_binary([Buf, In])), > io:format("~p~n", [Line]), > test(Port, Rest, Iters - 1, N + 1) > after 3000 -> > io:format("Receive timeout, stopping.~n") > end. > > parse(Msg) -> parse(Msg, []). > > parse(<<>>, Acc) -> {lists:reverse(Acc), <<>>}; > parse(<<$\n, Rest/binary>>, Acc) -> {lists:reverse(Acc), Rest}; % EOL > parse(<>, Acc) -> parse(Rest, [Byte|Acc]). > > 113> test_echo_svr:go("/path/to/echo_svr", 3). > "Test message 1" > "Test message 2" > "Test message 3" > ok > > > On Fri, Nov 21, 2008 at 6:37 PM, Joe Williams > wrote: > > Hello, > > I am having an issue when I attempt to send and receive messages > to a C > executable. I believe the task should be fairly trivial but I am > getting > hung up on sending messages to the port. Here's what I have so far: > > > Eshell V5.6.3 (abort with ^G) > > 1> Cmd = "SOME_EXECUTABLE", > > 1> Port = open_port({spawn, Cmd}, []). > > #Port<0.93> > > 2> receive > > 2> {Port, {data, Data}} -> > > 2> io:format("~p~n", [Data]); > > 2> Error -> > > 2> io:format("~p~n", [Error]) > > 2> end. > > "TEXT FROM THE EXECUTABLE" > > ok > > 3> Port ! <<"TEXT TO THE EXECUTABLE">>. > > ** exception exit: badsig > > 4> Port ! <<"TEXT TO THE EXECUTABLE">>. > > <<"TEXT TO THE EXECUTABLE">> > > 5> receive > > 5> {Port, {data, Data}} -> > > 5> io:format("~p~n", [Data]); > > 5> Error -> > > 5> io:format("~p~n", [Error]) > > 5> end. > > After the last end my code just hangs and waits to receive a message > rather than receiving the response from "TEXT TO THE EXECUTABLE". > Since > it received the first message properly I assume it would receive > further > responses in the same way. So I have two questions, the first is what > does "exception exit: badsig" generally mean? The second how can I > write > this in such a way that I can send and receive strings until I > have the > program exit? > > Any guidance is appreciated. > > -Joe > > -- > Name: Joseph A. Williams > Email: joe@REDACTED > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > -- Name: Joseph A. Williams Email: joe@REDACTED From bgustavsson@REDACTED Sun Nov 23 09:21:22 2008 From: bgustavsson@REDACTED (Bjorn Gustavsson) Date: Sun, 23 Nov 2008 09:21:22 +0100 Subject: [erlang-questions] HiPE on .beam files? (was: Why can't HiPE inline functions across ...) In-Reply-To: <4926CFB9.1050900@alertlogic.net> References: <4926CFB9.1050900@alertlogic.net> Message-ID: <6672d0160811230021s5b80368difdfc7ceb35a1de1f@mail.gmail.com> On Fri, Nov 21, 2008 at 4:11 PM, Paul Fisher wrote: > Tangentially, is it possible to take a .beam file w/o native code, run > HiPE on it generating a new .beam file with native code? This would be > wonderful as an install-time tool for people who want to always run > everything with HiPE. > erlc +native .beam The native code will be added to the existing file. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From ali.yakout@REDACTED Sun Nov 23 10:26:21 2008 From: ali.yakout@REDACTED (Ali Yakout) Date: Sun, 23 Nov 2008 10:26:21 +0100 Subject: [erlang-questions] Edoc in Makefile Message-ID: Hi, Is there a way to build the index.html, overview-summary.html, etc without rebuilding the modules html, I want to do this in my Makefile. Currently I use the rule %.html: %.erl erl -noshell -run edoc_run file '"$<"' '[{dir,"../doc"}]' Then I want to add the index build to the doc rule doc: $(HTML) # rebuild index Thanks, Ali -------------- next part -------------- An HTML attachment was scrubbed... URL: From richardc@REDACTED Sun Nov 23 12:48:50 2008 From: richardc@REDACTED (Richard Carlsson) Date: Sun, 23 Nov 2008 12:48:50 +0100 Subject: [erlang-questions] Edoc in Makefile In-Reply-To: References: Message-ID: <49294322.8090809@it.uu.se> Ali Yakout wrote: > Hi, > > Is there a way to build the index.html, overview-summary.html, etc > without rebuilding the modules html, I want to do this in my Makefile. > > Currently I use the rule > > %.html: %.erl > erl -noshell -run edoc_run file '"$<"' '[{dir,"../doc"}]' > > Then I want to add the index build to the doc rule > > doc: $(HTML) > # rebuild index > No, sorry. But in general I recommend not using the 'file' function, but rather 'application'. I usually use a make-dependency on the doc/index.html or doc/edoc-info target (from all of the source files), rather than a one-to-one dependency from .erl to .html. Since the startup time is rather large, it is typically best to generate the entire docs even if just one file has changed, instead of running edoc once per source file. For example: doc/index.html: $(SOURCES) erl -noshell -eval "edoc:application($(APPNAME), \".\", \ [$(DOC_OPTS)])" -s init stop /Richard From dot@REDACTED Thu Nov 20 19:06:25 2008 From: dot@REDACTED (Tony Finch) Date: Thu, 20 Nov 2008 18:06:25 +0000 Subject: [erlang-questions] Azul Systems - up to 864 cores "optimised for Java" In-Reply-To: <997C70E3-A2C7-49F6-A895-394E9E19B4B2@telegraphics.com.au> References: <997C70E3-A2C7-49F6-A895-394E9E19B4B2@telegraphics.com.au> Message-ID: On Wed, 19 Nov 2008, Toby Thain wrote: > > Brought back memories of similar-sized Transputer systems, and many > echoes of the Transputer architecture. The Azul architecture is shared memory, so not that similar to transputers. A better comparison would be the SiCortex massively parallel message passing systems. However both the Azul and SiCortex systems have lots of MIPS but relatively little IO, so probably aren't such a great fit for typical Erlang applications. Tony. -- f.anthony.n.finch http://dotat.at/ FAIR ISLE FAEROES: NORTHWEST 6 TO GALE 8, BUT CYCLONIC 4 OR 5 FOR A TIME. ROUGH OR VERY ROUGH. SQUALLY SHOWERS, BECOMING WINTRY. MODERATE OR GOOD, OCCASIONALLY VERY POOR. From per@REDACTED Sun Nov 23 17:57:43 2008 From: per@REDACTED (Per Hedeland) Date: Sun, 23 Nov 2008 17:57:43 +0100 (CET) Subject: [erlang-questions] erlang port and C executable In-Reply-To: <6c2563b20811222214u1fa7130ese1a2d4ed8ce94a3e@mail.gmail.com> Message-ID: <200811231657.mANGvhg2023676@pluto.hedeland.org> "Edwin Fine" wrote: > > One of the most annoying aspects is that under >circumstances that are not clear to me, the C program that is spawned >sometimes does not seem to be sent a signal for end of file when you close >the port, so if it is reading stdin, it's just going to sit there until >killed manually. This should never happen - i.e. there is no "signal" for end of file, it's just the result of reading when there is nothing more to read - but a port program that actually reads its stdin should always get end of file when the port is closed (after having read what there is to read, if anything). "You're probably doing something wrong." > Worse, if it gets stuck doing something and is NOT reading >stdin then you are out of luck. This is expected, and can be considered a feature - it allows you to e.g. start a daemon that *should* keep running after you close the port. >But what if the 'C' program is not under your control, say, it's part of >Linux, and you need to make sure it's killed when you are done? Then I >believe you need to write a wrapper around the 'C' program. I refer you to >the following post for an interesting way to do this: > >http://www.erlang.org/pipermail/erlang-questions/2007-October/030377.html It may be "interesting":-), but I wouldn't really recommend that you use that "code", it was kind of a "I bet it can be done" thing, in particular implementing {packet, 2} protocol in 'awk' is not exactly ideal.:-) 2-3 lines of readable C code would be a better idea. --Per Hedeland From per@REDACTED Sun Nov 23 18:02:29 2008 From: per@REDACTED (Per Hedeland) Date: Sun, 23 Nov 2008 18:02:29 +0100 (CET) Subject: [erlang-questions] Node communication over insecure links In-Reply-To: <915e7e1d0811200838u35f5833bl51ad245d62ee0639@mail.gmail.com> Message-ID: <200811231702.mANH2Tk1023729@pluto.hedeland.org> Alex wrote: > >Anyway, my question is in regard to communication between instances over >insecure networks and/or nodes. The case example is a network of IRC >servers. Having all nodes in the same Erlang instance would be nice, and >would make cross server communication a snap. Only issue is that if someone >intercepts the magic cookiee, they gain access to all nodes, Not a good >thing. I think you already received a good answer, and I'm not suggesting that running the communication in cleartext across the Internet is OK - however the cookie is never sent on the wire, so it can't be "intercepted" *there*. --Per Hedeland From enrico.thierbach@REDACTED Sun Nov 23 18:04:07 2008 From: enrico.thierbach@REDACTED (Enrico Thierbach) Date: Sun, 23 Nov 2008 18:04:07 +0100 Subject: [erlang-questions] Jason Message-ID: Hi everyone, as CouchDb needs a more performant JSON implementation I volunteered for implementing EEP 0018 (http://www.erlang.org/eeps/eep-0018.html) during the next few weeks. That is, unless someone else is already on that task, that is :) /eno -- ==================================================================== A wee piece of ruby every monday: http://1rad.wordpress.com/ From jesper@REDACTED Sun Nov 23 18:26:04 2008 From: jesper@REDACTED (Jesper Eskilson) Date: Sun, 23 Nov 2008 18:26:04 +0100 Subject: [erlang-questions] Erlang performance on Windows Message-ID: Hi all, I was doing some Project Euler stuff on my Windows machine at home, and realized that there does not seem to be any Hipe support on Windows. I found some notes from a year or two back about why there was no Hipe support on Windows (I didn't delve into the technical details, though), but I was wondering what the status is now. (Since there is SMP support on Windows now, I assumed that there was at least some demand for running Erlang applications on Windows and still get some sort of performance.) -- /Jesper From n39052@REDACTED Sun Nov 23 18:33:07 2008 From: n39052@REDACTED (Sergey A.) Date: Sun, 23 Nov 2008 09:33:07 -0800 Subject: [erlang-questions] How to force kernel application will always be started before my app Message-ID: <3bff71aa0811230933m2737a234q3920b4a7d197b91c@mail.gmail.com> Hello. I've a tricky problem with starting my OTP application from escript interface. Here is what I do in escript to start my app: First I start a node for my application: RunNode = "erl -detached -sname foo@REDACTED -setcookie my_cookie -boot start_sasl -config log -pa /path/to/ebin", os:cmd(RunNode) Then my script waits until the node is actually started: wait_for(pong, foo@REDACTED), after that I do rpc:call to start my application and check if there was an error (that is why I don't use "erl -s foo start". I need to know in my escript whether app was started or not): case rpc:call(foo@REDACTED, foo, start, []) of ok -> ok; {error, Reason} -> erlang:error(internal_foo_error) end But at some computers such a rpc:call fails with {error, {not_started,kernel}} return value. This happens because kernel application doesn't have enough time between os:cmd and rpc:call calls to start. What I should do to avoid this error in a right manner? I think that using of timer:sleep(300) isn't the right way. I could use somethin like [rpc:call(foo@REDACTED, application, start, [App]) || App <- [kernel, sasl]] in escript before starting my application, but it looks like a hack (or not?). I beleive there should be the standard way to ensure that all the dependencies of my app were already started. It's my foo.app: {application, foo, [{description, "Foo"}, {vsn, "1.0"}, {modules, []}, {registered, [foo_storage, foo_sup, foo_web]}, {applications, [kernel, stdlib, sasl]}, {mod, {gin_app, []}} ]}. Thanks. -- Sergey. From mikpe@REDACTED Sun Nov 23 19:09:51 2008 From: mikpe@REDACTED (Mikael Pettersson) Date: Sun, 23 Nov 2008 19:09:51 +0100 Subject: [erlang-questions] Erlang performance on Windows In-Reply-To: References: Message-ID: <18729.40047.98781.974974@harpo.it.uu.se> Jesper Eskilson writes: > Hi all, > > I was doing some Project Euler stuff on my Windows machine at home, > and realized that there does not seem to be any Hipe support on > Windows. I found some notes from a year or two back about why there > was no Hipe support on Windows (I didn't delve into the technical > details, though), but I was wondering what the status is now. Still no HiPE support on Windows I'm afraid. I plan on implementing that, but it's not the highest priority item on my Erlang TODO list, and it's made problematic by the hackery in the Erlang build system for Windows. My initial goal is to make it work with mingw's gcc (as msvc doesn't support ISO C99). From bqt@REDACTED Sun Nov 23 19:14:20 2008 From: bqt@REDACTED (Johnny Billquist) Date: Sun, 23 Nov 2008 19:14:20 +0100 Subject: [erlang-questions] erlang port and C executable In-Reply-To: <200811231657.mANGvhg2023676@pluto.hedeland.org> References: <200811231657.mANGvhg2023676@pluto.hedeland.org> Message-ID: <49299D7C.30701@softjar.se> Per Hedeland wrote: > "Edwin Fine" wrote: >> One of the most annoying aspects is that under >> circumstances that are not clear to me, the C program that is spawned >> sometimes does not seem to be sent a signal for end of file when you close >> the port, so if it is reading stdin, it's just going to sit there until >> killed manually. > > This should never happen - i.e. there is no "signal" for end of file, > it's just the result of reading when there is nothing more to read - but > a port program that actually reads its stdin should always get end of > file when the port is closed (after having read what there is to read, > if anything). "You're probably doing something wrong." The most common "wrong" is that someone opens/creates a pipe/socket, forks, and then writes to the fd, and eventually closes it. The reader will not receive an eof, since another process still have the fd open as well. eof will only be signalled once *all* processes having the pipe/socket open for writing have closed it. It's a rather common error people do. :-) >> Worse, if it gets stuck doing something and is NOT reading >> stdin then you are out of luck. > > This is expected, and can be considered a feature - it allows you to > e.g. start a daemon that *should* keep running after you close the port. Yes, I agree. It's a good thing, not a bad one. It's a bad assumption that the receiver should stop just because you don't have any more data to feed it. Johnny From vladdu55@REDACTED Sun Nov 23 19:19:37 2008 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Sun, 23 Nov 2008 19:19:37 +0100 Subject: [erlang-questions] How to force kernel application will always be started before my app In-Reply-To: <3bff71aa0811230933m2737a234q3920b4a7d197b91c@mail.gmail.com> References: <3bff71aa0811230933m2737a234q3920b4a7d197b91c@mail.gmail.com> Message-ID: <95be1d3b0811231019r756d5b94yf88db81f62647a29@mail.gmail.com> On Sun, Nov 23, 2008 at 18:33, Sergey A. wrote: > I beleive there should be the standard way to ensure that > all the dependencies of my app were already started. Hi! One possible workaround in this case would be to wait until a process registered as 'kernel_sup' is running. I don't know if it's enough, but I do a similar thing with the code server. Unfortunately, not all applications have a registered process that one can wait for... What I would like to have is a system-wide event source that would let interested parties know when important events in the system take place, like "kernel started", "code server started", "mnesia started/stopped", but maybe also things like "node connected/disconnected". This would mean that this service would need to be started very early and other applications could register themselves as event producers and/or listeners. Quite a large mechanism to put in place, but maybe it's interesting to consider? best regards, Vlad From per@REDACTED Sun Nov 23 20:08:46 2008 From: per@REDACTED (Per Hedeland) Date: Sun, 23 Nov 2008 20:08:46 +0100 (CET) Subject: [erlang-questions] erlang port and C executable In-Reply-To: <49299D7C.30701@softjar.se> Message-ID: <200811231908.mANJ8kr8026782@pluto.hedeland.org> Johnny Billquist wrote: > >Per Hedeland wrote: >> "Edwin Fine" wrote: >>> One of the most annoying aspects is that under >>> circumstances that are not clear to me, the C program that is spawned >>> sometimes does not seem to be sent a signal for end of file when you close >>> the port, so if it is reading stdin, it's just going to sit there until >>> killed manually. >> >> This should never happen - i.e. there is no "signal" for end of file, >> it's just the result of reading when there is nothing more to read - but >> a port program that actually reads its stdin should always get end of >> file when the port is closed (after having read what there is to read, >> if anything). "You're probably doing something wrong." > >The most common "wrong" is that someone opens/creates a pipe/socket, >forks, and then writes to the fd, and eventually closes it. The reader >will not receive an eof, since another process still have the fd open as >well. eof will only be signalled once *all* processes having the >pipe/socket open for writing have closed it. You're talking about using pipes in general, but this is not relevant for the pipes set up by open_port/2, since it is done correctly.:-) Only the Erlang runtime has the relevant pipe open for writing, so the closing of the port is enough. Easy enough to verify that forking another process doesn't cause a problem: 1> Cmd = "sleep 100 & while read x; do : ; done; echo got EOF >&2". "sleep 100 & while read x; do : ; done; echo got EOF >&2" 2> Port = open_port({spawn, Cmd}, []). #Port<0.95> 3> port_close(Port). got EOF true (How's that for a weird return value btw.:-) --Per From erlang-questions_efine@REDACTED Sun Nov 23 20:10:54 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Sun, 23 Nov 2008 14:10:54 -0500 Subject: [erlang-questions] erlang port and C executable In-Reply-To: <200811231657.mANGvhg2023676@pluto.hedeland.org> References: <6c2563b20811222214u1fa7130ese1a2d4ed8ce94a3e@mail.gmail.com> <200811231657.mANGvhg2023676@pluto.hedeland.org> Message-ID: <6c2563b20811231110o174dd018kbabca6cb29200686@mail.gmail.com> On Sun, Nov 23, 2008 at 11:57 AM, Per Hedeland wrote: > "Edwin Fine" wrote: > > > > One of the most annoying aspects is that under > >circumstances that are not clear to me, the C program that is spawned > >sometimes does not seem to be sent a signal for end of file when you close > >the port, so if it is reading stdin, it's just going to sit there until > >killed manually. > > This should never happen - i.e. there is no "signal" for end of file, > it's just the result of reading when there is nothing more to read - but > a port program that actually reads its stdin should always get end of > file when the port is closed (after having read what there is to read, > if anything). "You're probably doing something wrong." You're probably right. But nothing wrong in the C program, I don't think. That's why I found it a bit frustrating to get the Erlang program working correctly. > > > > Worse, if it gets stuck doing something and is NOT reading > >stdin then you are out of luck. > > This is expected, and can be considered a feature - it allows you to > e.g. start a daemon that *should* keep running after you close the port. > There are well-known techniques to starting daemons that don't rely on open ports (e.g. fork a child, close all open files, fork another child, trap signals, open stdin/out etc). So I am not sure this such is a good feature because it makes it difficult to kill misbehaving OS programs that were spawned by Erlang. > >But what if the 'C' program is not under your control, say, it's part of > >Linux, and you need to make sure it's killed when you are done? Then I > >believe you need to write a wrapper around the 'C' program. I refer you to > >the following post for an interesting way to do this: > > > >http://www.erlang.org/pipermail/erlang-questions/2007-October/030377.html > > It may be "interesting":-), but I wouldn't really recommend that you use > that "code", it was kind of a "I bet it can be done" thing, in > particular implementing {packet, 2} protocol in 'awk' is not exactly > ideal.:-) 2-3 lines of readable C code would be a better idea. > I understand - I was pointing more to the idea than the implementation. I think Erlang/OTP should perhaps provide a standard wrapper C program that will run any program as a child, and has a back-channel that allows you to kill it (and its child) if the child becomes non-responsive. > --Per Hedeland > > Edwin Fine -------------- next part -------------- An HTML attachment was scrubbed... URL: From rvirding@REDACTED Sun Nov 23 20:15:44 2008 From: rvirding@REDACTED (Robert Virding) Date: Sun, 23 Nov 2008 20:15:44 +0100 Subject: [erlang-questions] Jason In-Reply-To: References: Message-ID: <3dbc6d1c0811231115y565a6670p173226976c5dd150@mail.gmail.com> I can assure you that no one will complain if you implement the EEP. :-) You are aware, however, that the EEP is still just a suggestion and may not be accepted in the form it is now? It might even never be accepted, although I think it unlikely that some JSON EEP is not accepted. Robert 2008/11/23 Enrico Thierbach > Hi everyone, > > as CouchDb needs a more performant JSON implementation I volunteered > for implementing EEP 0018 (http://www.erlang.org/eeps/eep-0018.html) > during the next few weeks. > > That is, unless someone else is already on that task, that is :) > > /eno > > -- > ==================================================================== > A wee piece of ruby every monday: http://1rad.wordpress.com/ > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From erlang-questions_efine@REDACTED Sun Nov 23 20:21:48 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Sun, 23 Nov 2008 14:21:48 -0500 Subject: [erlang-questions] erlang port and C executable In-Reply-To: <200811231908.mANJ8kr8026782@pluto.hedeland.org> References: <49299D7C.30701@softjar.se> <200811231908.mANJ8kr8026782@pluto.hedeland.org> Message-ID: <6c2563b20811231121v3e6d8b9dl273ec0e2d4ce9e9c@mail.gmail.com> On Sun, Nov 23, 2008 at 2:08 PM, Per Hedeland wrote: > Johnny Billquist wrote: > > > >Per Hedeland wrote: > >> "Edwin Fine" wrote: > >>> One of the most annoying aspects is that under > >>> circumstances that are not clear to me, the C program that is spawned > >>> sometimes does not seem to be sent a signal for end of file when you > close > >>> the port, so if it is reading stdin, it's just going to sit there until > >>> killed manually. > >> > >> This should never happen - i.e. there is no "signal" for end of file, > >> it's just the result of reading when there is nothing more to read - but > >> a port program that actually reads its stdin should always get end of > >> file when the port is closed (after having read what there is to read, > >> if anything). "You're probably doing something wrong." > > > I misspoke (miswrote :) about the signal. Of course closing a write pipe will make the reading program receive an EOF - everything's a file in Unix (except the things that aren't ;). Sorry. I should learn not to post at 2am. How about this for a suggestion: add an optional parameter to port_close: erlang:port_close(Port, Opts) Opts = [brutal_kill | polite_shutdown] Omitting the opts will give the same behavior as current; adding a [brutal_kill] will do the equivalent of a kill -9; polite shutdown just a "normal" kill. Regards, Edwin Fine -------------- next part -------------- An HTML attachment was scrubbed... URL: From per@REDACTED Sun Nov 23 20:31:42 2008 From: per@REDACTED (Per Hedeland) Date: Sun, 23 Nov 2008 20:31:42 +0100 (CET) Subject: [erlang-questions] erlang port and C executable In-Reply-To: <6c2563b20811231110o174dd018kbabca6cb29200686@mail.gmail.com> Message-ID: <200811231931.mANJVgXp027328@pluto.hedeland.org> "Edwin Fine" wrote: > >On Sun, Nov 23, 2008 at 11:57 AM, Per Hedeland wrote: > >> "Edwin Fine" wrote: >> > >> > One of the most annoying aspects is that under >> >circumstances that are not clear to me, the C program that is spawned >> >sometimes does not seem to be sent a signal for end of file when you close >> >the port, so if it is reading stdin, it's just going to sit there until >> >killed manually. >> >> This should never happen - i.e. there is no "signal" for end of file, >> it's just the result of reading when there is nothing more to read - but >> a port program that actually reads its stdin should always get end of >> file when the port is closed (after having read what there is to read, >> if anything). "You're probably doing something wrong." > > >You're probably right. But nothing wrong in the C program, I don't think. >That's why I found it a bit frustrating to get the Erlang program working >correctly. If you can provide code that doesn't get the EOF (and tell us what you do with it:-), we should be able to point out what you're doing wrong. >> > Worse, if it gets stuck doing something and is NOT reading >> >stdin then you are out of luck. >> >> This is expected, and can be considered a feature - it allows you to >> e.g. start a daemon that *should* keep running after you close the port. >> > >There are well-known techniques to starting daemons that don't rely on open >ports OK, s/daemon/long-running program/. Johnny's comment was to the point, closing the port just means "I don't want to talk to you anymore", it doesn't mean "die now". >I understand - I was pointing more to the idea than the implementation. I >think Erlang/OTP should perhaps provide a standard wrapper C program that >will run any program as a child, and has a back-channel that allows you to >kill it (and its child) if the child becomes non-responsive. Perhaps, but they can't do everything for you - it's a trivial program to write, except that there's a lot of little things that it should do in different ways depending on your needs, which means that it will become quite complex to use if it should cover everyone's needs. E.g. does it need to "proxy" input and/or output for the child program? Should it grab its stdio for this or use some other file descriptors? What "protocol" should it talk on the port pipes back to Erlang? Etc. --Per From erlang-questions_efine@REDACTED Sun Nov 23 20:44:21 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Sun, 23 Nov 2008 14:44:21 -0500 Subject: [erlang-questions] erlang port and C executable In-Reply-To: <200811231931.mANJVgXp027328@pluto.hedeland.org> References: <6c2563b20811231110o174dd018kbabca6cb29200686@mail.gmail.com> <200811231931.mANJVgXp027328@pluto.hedeland.org> Message-ID: <6c2563b20811231144v29a664b7g9ff27ff4b961f67a@mail.gmail.com> > > >You're probably right. But nothing wrong in the C program, I don't think. > >That's why I found it a bit frustrating to get the Erlang program working > >correctly. > > If you can provide code that doesn't get the EOF (and tell us what you > do with it:-), we should be able to point out what you're doing wrong. Thanks for the offer, but it's working correctly NOW. I did post the C and Erlang code (that is, the code that works) in this thread; if you are bored sometime and want to critique it, I'd appreciate it. The symptom was that the spawned echo program was not closing down. I now think that what happened is that it got input and was trying to write output, but the Erlang port closed before it could do that, so it was hung on the output pipe. When I did a flush() in the shell later I got more input than I expected, so maybe that was it. I was only whining a bit about how sometimes getting things to work in Erlang seems like "magic" to people like me who are not familiar with every corner of Erlang, and obvious to gurus like you and Johnny. Then I feel a bit stupid. > OK, s/daemon/long-running program/. Johnny's comment was to the point, > closing the port just means "I don't want to talk to you anymore", it > doesn't mean "die now". > I see the point now, thanks. > >I understand - I was pointing more to the idea than the implementation. I > >think Erlang/OTP should perhaps provide a standard wrapper C program that > >will run any program as a child, and has a back-channel that allows you to > >kill it (and its child) if the child becomes non-responsive. > > Perhaps, but they can't do everything for you - it's a trivial program > to write, except that there's a lot of little things that it should do > in different ways depending on your needs, which means that it will > become quite complex to use if it should cover everyone's needs. So it's not actually that trivial ;) > > E.g. does it need to "proxy" input and/or output for the child program? > Should it grab its stdio for this or use some other file descriptors? > What "protocol" should it talk on the port pipes back to Erlang? Etc. > Those are all excellent points. My desire would be for a wrapper that allows one to reliably start, stop, and exchange data via stdin and stdout with a Unix/Linux program such as gnuplot. I have done this in Ruby before to chart performance data (rrdtool did not fit my needs) and IMHO it is a heaven-sent ability. Maybe I should try to write such a wrapper myself and see what is involved. If it's any good, hey, maybe I can put it on trapexit.... Thanks for your help and advice. > --Per > Edwin -------------- next part -------------- An HTML attachment was scrubbed... URL: From erlangy@REDACTED Sun Nov 23 20:46:36 2008 From: erlangy@REDACTED (Michael McDaniel) Date: Sun, 23 Nov 2008 11:46:36 -0800 Subject: [erlang-questions] erlang port and C executable In-Reply-To: <200811231931.mANJVgXp027328@pluto.hedeland.org> References: <6c2563b20811231110o174dd018kbabca6cb29200686@mail.gmail.com> <200811231931.mANJVgXp027328@pluto.hedeland.org> Message-ID: <20081123194636.GO10121@delora.autosys.us> On Sun, Nov 23, 2008 at 08:31:42PM +0100, Per Hedeland wrote: > "Edwin Fine" wrote: > > > >On Sun, Nov 23, 2008 at 11:57 AM, Per Hedeland wrote: > > > >> "Edwin Fine" wrote: > >> > > >> > One of the most annoying aspects is that under > >> >circumstances that are not clear to me, the C program that is spawned > >> >sometimes does not seem to be sent a signal for end of file when you close > >> >the port, so if it is reading stdin, it's just going to sit there until > >> >killed manually. > >> > >> This should never happen - i.e. there is no "signal" for end of file, > >> it's just the result of reading when there is nothing more to read - but > >> a port program that actually reads its stdin should always get end of > >> file when the port is closed (after having read what there is to read, > >> if anything). "You're probably doing something wrong." > > > > > >You're probably right. But nothing wrong in the C program, I don't think. > >That's why I found it a bit frustrating to get the Erlang program working > >correctly. > > If you can provide code that doesn't get the EOF (and tell us what you > do with it:-), we should be able to point out what you're doing wrong. > > >> > Worse, if it gets stuck doing something and is NOT reading > >> >stdin then you are out of luck. > >> > >> This is expected, and can be considered a feature - it allows you to > >> e.g. start a daemon that *should* keep running after you close the port. > >> > > > >There are well-known techniques to starting daemons that don't rely on open > >ports > > OK, s/daemon/long-running program/. Johnny's comment was to the point, > closing the port just means "I don't want to talk to you anymore", it > doesn't mean "die now". > > >I understand - I was pointing more to the idea than the implementation. I > >think Erlang/OTP should perhaps provide a standard wrapper C program that > >will run any program as a child, and has a back-channel that allows you to > >kill it (and its child) if the child becomes non-responsive. > > Perhaps, but they can't do everything for you - it's a trivial program > to write, except that there's a lot of little things that it should do > in different ways depending on your needs, which means that it will > become quite complex to use if it should cover everyone's needs. > E.g. does it need to "proxy" input and/or output for the child program? > Should it grab its stdio for this or use some other file descriptors? > What "protocol" should it talk on the port pipes back to Erlang? Etc. > > --Per _______________________________________________ Though not addressing all the questions above, here's an old post from me regarding how I'm using open_port and killing the spawned process ... http://www.trapexit.org/forum/viewtopic.php?p=30762&highlight=&sid=0cce5d6ad7c14306754ec99249fe912f I use the technique to monitor a USB port. In the original post I forgot to include the command I use to echo back the PID; I get the PID using my port/0 command ... -define(IF, "/dev/ttyUSB0"). -define(DD, "/bin/dd if=" ++ ?IF ++ " bs=1 oflag=dsync& pid=$!; echo $pid"). port() -> Port = open_port({spawn, ?DD }, [eof, exit_status, use_stdio, binary]) , receive {Portb, {data, Pid_with_lf}} -> {ok, Pid_of_dd, 1} = regexp:gsub(binary_to_list(Pid_with_lf), "\n", "") end , io:fwrite('~p~n', [{Portb, {data, Pid_with_lf}}]) , {Port, Pid_of_dd} . ~Michael -- Michael McDaniel Portland, Oregon, USA http://autosys.us From erlang-questions_efine@REDACTED Sun Nov 23 20:53:56 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Sun, 23 Nov 2008 14:53:56 -0500 Subject: [erlang-questions] erlang port and C executable In-Reply-To: <20081123194636.GO10121@delora.autosys.us> References: <6c2563b20811231110o174dd018kbabca6cb29200686@mail.gmail.com> <200811231931.mANJVgXp027328@pluto.hedeland.org> <20081123194636.GO10121@delora.autosys.us> Message-ID: <6c2563b20811231153k2b5e8980s59dc49d871443efa@mail.gmail.com> > > > >I understand - I was pointing more to the idea than the implementation. > I > > >think Erlang/OTP should perhaps provide a standard wrapper C program > that > > >will run any program as a child, and has a back-channel that allows you > to > > >kill it (and its child) if the child becomes non-responsive. > > > > Perhaps, but they can't do everything for you - it's a trivial program > > to write, except that there's a lot of little things that it should do > > in different ways depending on your needs, which means that it will > > become quite complex to use if it should cover everyone's needs. > > E.g. does it need to "proxy" input and/or output for the child program? > > Should it grab its stdio for this or use some other file descriptors? > > What "protocol" should it talk on the port pipes back to Erlang? Etc. > > > > --Per > _______________________________________________ > > > Though not addressing all the questions above, here's an old > post from me regarding how I'm using open_port and killing the > spawned process ... > > > > http://www.trapexit.org/forum/viewtopic.php?p=30762&highlight=&sid=0cce5d6ad7c14306754ec99249fe912f > > > I use the technique to monitor a USB port. > > > In the original post I forgot to include the command I use to echo back > the PID; > > I get the PID using my port/0 command ... > > -define(IF, "/dev/ttyUSB0"). > -define(DD, "/bin/dd if=" ++ ?IF ++ " bs=1 oflag=dsync& pid=$!; echo > $pid"). > > port() -> > Port = open_port({spawn, ?DD }, > [eof, exit_status, use_stdio, binary]) , > > receive > {Portb, {data, Pid_with_lf}} -> > {ok, Pid_of_dd, 1} = regexp:gsub(binary_to_list(Pid_with_lf), "\n", "") > end , > > io:fwrite('~p~n', [{Portb, {data, Pid_with_lf}}]) , > > {Port, Pid_of_dd} > . > Thanks - I read the trapexit post, too, and that's very interesting!! The things you can do with dd! The mind boggles. Edwin > > ~Michael > > > -- > Michael McDaniel > Portland, Oregon, USA > http://autosys.us > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jesper@REDACTED Sun Nov 23 21:42:33 2008 From: jesper@REDACTED (Jesper Eskilson) Date: Sun, 23 Nov 2008 21:42:33 +0100 Subject: [erlang-questions] Erlang performance on Windows In-Reply-To: <18729.40047.98781.974974@harpo.it.uu.se> References: <18729.40047.98781.974974@harpo.it.uu.se> Message-ID: On Sun, Nov 23, 2008 at 7:09 PM, Mikael Pettersson wrote: > Jesper Eskilson writes: > > Hi all, > > > > I was doing some Project Euler stuff on my Windows machine at home, > > and realized that there does not seem to be any Hipe support on > > Windows. I found some notes from a year or two back about why there > > was no Hipe support on Windows (I didn't delve into the technical > > details, though), but I was wondering what the status is now. > > Still no HiPE support on Windows I'm afraid. > I plan on implementing that, but it's not the highest priority > item on my Erlang TODO list, and it's made problematic by the > hackery in the Erlang build system for Windows. My initial goal > is to make it work with mingw's gcc (as msvc doesn't support ISO C99). Did you ever consider moving away from autoconf? I've actually been in charge of maintaining exactly this kind of build system (cygwin + mingw/msvc + autoconf) on windows, and it is really not very fun. At my current job, we've successfully moved our previously windows-only build system to CMake (http://www.cmake.org) in order to get cross-platform support. Compared to autoconf, CMake is really nice to work with. -- /Jesper From per@REDACTED Sun Nov 23 22:11:10 2008 From: per@REDACTED (Per Hedeland) Date: Sun, 23 Nov 2008 22:11:10 +0100 (CET) Subject: [erlang-questions] erlang port and C executable In-Reply-To: <6c2563b20811231144v29a664b7g9ff27ff4b961f67a@mail.gmail.com> Message-ID: <200811232111.mANLBAOu029472@pluto.hedeland.org> "Edwin Fine" wrote: > >Thanks for the offer, but it's working correctly NOW. I did post the C and >Erlang code (that is, the code that works) in this thread; if you are bored >sometime and want to critique it, I'd appreciate it. It seemed fine - the C side did what a large variety of *nix programs do, read stdin until EOF and then exit - which works very well with the port mechanism as-is. > The symptom was that >the spawned echo program was not closing down. I now think that what >happened is that it got input and was trying to write output, but the Erlang >port closed before it could do that, so it was hung on the output pipe. That shouldn't happen either. The magic of *nix pipes does its job in that direction too - if there are no processes that have the read side of a pipe open (and there won't be if Erlang has closed the port), trying to write to it will deliver a SIGPIPE to the writer, which will promptly kill it unless it has taken steps to prevent that. > When >I did a flush() in the shell later I got more input than I expected, so >maybe that was it. Sounds more as if you didn't actually close the port when you thought that you did it. >> Perhaps, but they can't do everything for you - it's a trivial program >> to write, except that there's a lot of little things that it should do >> in different ways depending on your needs, which means that it will >> become quite complex to use if it should cover everyone's needs. > > >So it's not actually that trivial ;) If you only have a single need it is trivial.:-) >> E.g. does it need to "proxy" input and/or output for the child program? >> Should it grab its stdio for this or use some other file descriptors? >> What "protocol" should it talk on the port pipes back to Erlang? Etc. >> > >Those are all excellent points. My desire would be for a wrapper that allows >one to reliably start, stop, and exchange data via stdin and stdout with a >Unix/Linux program such as gnuplot. As far as I know gnuplot in interactive mode will exit as soon as it sees EOF on stdin - it shouldn't need a wrapper. Though I guess you might accidentally feed it some data that takes "forever" to plot. --Per From per@REDACTED Sun Nov 23 22:30:30 2008 From: per@REDACTED (Per Hedeland) Date: Sun, 23 Nov 2008 22:30:30 +0100 (CET) Subject: [erlang-questions] erlang port and C executable In-Reply-To: <20081123194636.GO10121@delora.autosys.us> Message-ID: <200811232130.mANLUUgG029896@pluto.hedeland.org> Michael McDaniel wrote: > > In the original post I forgot to include the command I use to echo back > the PID; > > I get the PID using my port/0 command ... > >-define(IF, "/dev/ttyUSB0"). >-define(DD, "/bin/dd if=" ++ ?IF ++ " bs=1 oflag=dsync& pid=$!; echo $pid"). That's generally fine, and actually pretty much exactly what I suggested earlier in the thread that Edwin pointed to (but it wasn't good enough *there*:-). There are a couple of gotchas though: 1. Since you are running the "real" program in the background, you won't get its exit status, i.e. this > Port = open_port({spawn, ?DD }, > [eof, exit_status, use_stdio, binary]) , will (eventually) give you the exit status of 'echo'. Could perhaps be handled by ending the commandline with 'wait'. 2. If the program starts producing output immediately, there's no guarantee that > receive > {Portb, {data, Pid_with_lf}} -> will have only the pid in Pid_with_lf - worst case it could have output from the program, and not include the pid at all. In your case I think neither of those is an actual problem, but it might be misleading for future readers of your code to include the exit_status option. --Per From mikpe@REDACTED Sun Nov 23 23:51:08 2008 From: mikpe@REDACTED (Mikael Pettersson) Date: Sun, 23 Nov 2008 23:51:08 +0100 Subject: [erlang-questions] Erlang performance on Windows In-Reply-To: References: <18729.40047.98781.974974@harpo.it.uu.se> Message-ID: <18729.56924.649110.369023@harpo.it.uu.se> Jesper Eskilson writes: > On Sun, Nov 23, 2008 at 7:09 PM, Mikael Pettersson wrote: > > Jesper Eskilson writes: > > > Hi all, > > > > > > I was doing some Project Euler stuff on my Windows machine at home, > > > and realized that there does not seem to be any Hipe support on > > > Windows. I found some notes from a year or two back about why there > > > was no Hipe support on Windows (I didn't delve into the technical > > > details, though), but I was wondering what the status is now. > > > > Still no HiPE support on Windows I'm afraid. > > I plan on implementing that, but it's not the highest priority > > item on my Erlang TODO list, and it's made problematic by the > > hackery in the Erlang build system for Windows. My initial goal > > is to make it work with mingw's gcc (as msvc doesn't support ISO C99). > > Did you ever consider moving away from autoconf? I've actually been in > charge of maintaining exactly this kind of build system (cygwin + > mingw/msvc + autoconf) on windows, and it is really not very fun. At > my current job, we've successfully moved our previously windows-only > build system to CMake (http://www.cmake.org) in order to get > cross-platform support. Compared to autoconf, CMake is really nice to > work with. Using autoconf or not is not my call, but the problems I had trying to build the system in cygwin with a cross-compiler to mingw had to do with various non-standard special case hacks the otp team has put in the configure files. The first thing I'll do on the Windows port is to make it possible to build the system with cygwin+mingw in a clean way. Once that's done a HiPE port should be easy. From erlangy@REDACTED Mon Nov 24 00:03:19 2008 From: erlangy@REDACTED (Michael McDaniel) Date: Sun, 23 Nov 2008 15:03:19 -0800 Subject: [erlang-questions] erlang port and C executable In-Reply-To: <200811232130.mANLUUgG029896@pluto.hedeland.org> References: <20081123194636.GO10121@delora.autosys.us> <200811232130.mANLUUgG029896@pluto.hedeland.org> Message-ID: <20081123230319.GS10121@delora.autosys.us> On Sun, Nov 23, 2008 at 10:30:30PM +0100, Per Hedeland wrote: > Michael McDaniel wrote: > > > > In the original post I forgot to include the command I use to echo back > > the PID; > > > > I get the PID using my port/0 command ... > > > >-define(IF, "/dev/ttyUSB0"). > >-define(DD, "/bin/dd if=" ++ ?IF ++ " bs=1 oflag=dsync& pid=$!; echo $pid"). > > That's generally fine, and actually pretty much exactly what I suggested > earlier in the thread that Edwin pointed to (but it wasn't good enough > *there*:-). There are a couple of gotchas though: > > 1. Since you are running the "real" program in the background, you won't > get its exit status, i.e. this > > > Port = open_port({spawn, ?DD }, > > [eof, exit_status, use_stdio, binary]) , > > will (eventually) give you the exit status of 'echo'. Could perhaps > be handled by ending the commandline with 'wait'. > > 2. If the program starts producing output immediately, there's no > guarantee that > > > receive > > {Portb, {data, Pid_with_lf}} -> > > will have only the pid in Pid_with_lf - worst case it could have > output from the program, and not include the pid at all. > > In your case I think neither of those is an actual problem, but it might > be misleading for future readers of your code to include the exit_status > option. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Good points - thanks, Per, for pointing these out. For '1.' I do not presently care though '2.' would be a problem in my existing application if I did not get the PID at all. ~Michael > > --Per From btolputt@REDACTED Mon Nov 24 00:18:12 2008 From: btolputt@REDACTED (Benjamin Tolputt) Date: Mon, 24 Nov 2008 10:18:12 +1100 Subject: [erlang-questions] Erlang performance on Windows In-Reply-To: <18729.56924.649110.369023@harpo.it.uu.se> References: <18729.40047.98781.974974@harpo.it.uu.se> <18729.56924.649110.369023@harpo.it.uu.se> Message-ID: <4929E4B4.4030307@bigpond.net.au> Mikael Pettersson wrote: > Using autoconf or not is not my call, but the problems I had > trying to build the system in cygwin with a cross-compiler to > mingw had to do with various non-standard special case hacks > the otp team has put in the configure files. > While I can't comment too much on the good/bad of the make system used for Erlang; it was my impression that at least one of the special cases was to use the Microsoft compiler (rather than gcc) for the compilation. I remember reading (either in the README or this list) that the speed difference between compiling with gcc & compiling with msvc is really noticeable - with the exception of one file where the gcc "address of label" extension helped speed up what would otherwise be a (very) large switch statement. While I've not compiled Erlang with gcc, I can attest to the fact that msvc tends to optimise code somewhat better than gcc (at least as far as the Win32 platform is concerned). > The first thing I'll do on the Windows port is to make it possible > to build the system with cygwin+mingw in a clean way. Once that's > done a HiPE port should be easy. > It was my impression from the technical discussions (RE: HiPE on Win32) that the problem was not one of difficulty but one of whether it was advisable to use a certain feature of windows relating to stacks & exception handling. Has this been resolved in a positive fashion (i.e. we're happy with the issue being negligible and/or have a different method)? I would very much like to hear the details & any progress on this as Win32-enabled HiPE has been something of a pet issue for me. I was the one that queried this last time, to which Mikael was able to give me a good run down of why it wasn't possible at the time. -- Regards, Benjamin Tolputt Analyst Programmer This email and any files transmitted with it are confidential to the intended recipient and may be privileged. If you have received this email inadvertently or you are not the intended recipient, you may not disseminate, distribute, copy or in any way rely on it. Further, you should notify the sender immediately and delete the email from your computer. Whilst we have taken precautions to alert us to the presence of computer viruses, we cannot guarantee that this email and any files transmitted with it are free from such viruses. From ok@REDACTED Mon Nov 24 02:52:57 2008 From: ok@REDACTED (Richard O'Keefe) Date: Mon, 24 Nov 2008 14:52:57 +1300 Subject: [erlang-questions] Erlang elseif In-Reply-To: <65691fa00811202337w57f3f329m244abaa055f6fae8@mail.gmail.com> References: <65691fa00811200041yfc7a219y97a11126e0cee535@mail.gmail.com> <78FFE0EB-DF1E-41E9-A802-A66B4F8066AF@cs.otago.ac.nz> <65691fa00811202337w57f3f329m244abaa055f6fae8@mail.gmail.com> Message-ID: <4CA10F5D-BA37-4952-AA59-4A63DC6632ED@cs.otago.ac.nz> On 21 Nov 2008, at 8:37 pm, Daniel R?nnqvist wrote: > I am merely trying to figure out why this simple logical control > structure don't exist; > > If == true then > elseif then > else Because Erlang does not have a Boolean data type. No, seriously. Erlang was and is based firmly on - function call - case Originally, type tests and comparisons were guards only, not expressions. They did not return 'true' or 'false', so there never were any expressions that _could_ be used to control 'if' expressions. 'if' was introduced as an abbreviation for a 'case' with trivial matching. Then the Great Blunder occurred: the type tests and comparisons were duplicated, and as well as the guard versions there were expression versions, returning 'true' and 'false'. This was compounded by the addition of far too many operators, both 'and' *and* 'andalso', both 'or' *and* 'orelse'. This immediately created pressure to make Erlang stop being Erlang and turn it into something else. In particular, some people want to allow arbitrary expressions as guards (with all the questions that raises about "what sense does it make to have a side effect that happened in a clause that wasn't selected") and that would have as a consequence that 'if' would be much closer to what you want. > > > I know I can get lots and lots of good ideas on how to do this if I > were to give you my whole real example but that is not my point. I > am narrowing it down to this because THIS is what I want to discuss. But you are now refusing to discuss a key reason why the present (or rather, the pre-Great Blunder) state of affairs is a Good Thing. It's not just "good ideas" you might get if we saw a real example, it's BETTER ideas than using a C-like 'if'. > > > IMHO, it shouldn't be that hard for the compiler/precompiler to > "rewrite" another control structure as nested case statements which > would work as a general solution, be very fast with less and > arguably more readable code. There is no reason to expect it to be 'very fast' compared with 'case'. Any situation that was faster as an 'if' than as a 'case' would count as a performance bug in the compilation of 'case'. "Arguably more readable code" evades the question of "readable to whom?" I don't know any reason why coding using C-like 'if' should be more readable to proficient Erlang programmers than other ways of writing the same thing. Past experience leads me strongly to doubt it. Note that I am not saying that C-like if is bad. Partly, I suppose that I am saying that insisting that everything be like everything else is no way to explore and learn and maybe learn better. The situation post Great Blunder is unstable. Having nibbled at the 'logical expression' forbidden fruit, Erlang should either vomit it out or gulp down the whole poisoned apple. For the micro-Erlang design I'm playing with, I chose the "vomit it out" route. Back to the future. Less is more. It's amazing how little 'logical expressions' are missed if you seriously try to think without them. For real Erlang/OTP, backwards compatibility puts backwards pointing spikes on the poisoned apple; it's hard to vomit it out without ripping out your throat. Erlang/OTP may have to gulp down the _whole_ thing and just hope that people don't do silly things, like CAML and SML. From alustenberg@REDACTED Mon Nov 24 04:53:37 2008 From: alustenberg@REDACTED (Alex) Date: Sun, 23 Nov 2008 22:53:37 -0500 Subject: [erlang-questions] Node communication over insecure links In-Reply-To: <200811231702.mANH2Tk1023729@pluto.hedeland.org> References: <915e7e1d0811200838u35f5833bl51ad245d62ee0639@mail.gmail.com> <200811231702.mANH2Tk1023729@pluto.hedeland.org> Message-ID: <915e7e1d0811231953x53dcb4cep88e36fef3a3560cc@mail.gmail.com> Yes, everyone's answers have been great. Interception was not the proper term for me to be use, I guess 'deducted' would be a better term to use for the scenario in question. On Sun, Nov 23, 2008 at 12:02 PM, Per Hedeland wrote: > Alex wrote: > > > >Anyway, my question is in regard to communication between instances over > >insecure networks and/or nodes. The case example is a network of IRC > >servers. Having all nodes in the same Erlang instance would be nice, and > >would make cross server communication a snap. Only issue is that if > someone > >intercepts the magic cookiee, they gain access to all nodes, Not a good > >thing. > > I think you already received a good answer, and I'm not suggesting that > running the communication in cleartext across the Internet is OK - > however the cookie is never sent on the wire, so it can't be > "intercepted" *there*. > > --Per Hedeland > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mikpe@REDACTED Mon Nov 24 08:38:24 2008 From: mikpe@REDACTED (Mikael Pettersson) Date: Mon, 24 Nov 2008 08:38:24 +0100 Subject: [erlang-questions] Erlang performance on Windows In-Reply-To: <4929E4B4.4030307@bigpond.net.au> References: <18729.40047.98781.974974@harpo.it.uu.se> <18729.56924.649110.369023@harpo.it.uu.se> <4929E4B4.4030307@bigpond.net.au> Message-ID: <18730.23024.703093.347521@harpo.it.uu.se> Benjamin Tolputt writes: > Mikael Pettersson wrote: > > Using autoconf or not is not my call, but the problems I had > > trying to build the system in cygwin with a cross-compiler to > > mingw had to do with various non-standard special case hacks > > the otp team has put in the configure files. > > > > While I can't comment too much on the good/bad of the make system used > for Erlang; it was my impression that at least one of the special cases > was to use the Microsoft compiler (rather than gcc) for the compilation. > I remember reading (either in the README or this list) that the speed > difference between compiling with gcc & compiling with msvc is really > noticeable - with the exception of one file where the gcc "address of > label" extension helped speed up what would otherwise be a (very) large > switch statement. > > While I've not compiled Erlang with gcc, I can attest to the fact that > msvc tends to optimise code somewhat better than gcc (at least as far as > the Win32 platform is concerned). gcc evolves. I doubt those comparisons were made using modern gcc-4.x versions. Besides, the ISO C99 issue is a strong argument for gcc in my book. (I think Intel's compiler also supports C99, but it isn't free.) > > The first thing I'll do on the Windows port is to make it possible > > to build the system with cygwin+mingw in a clean way. Once that's > > done a HiPE port should be easy. > > > > It was my impression from the technical discussions (RE: HiPE on Win32) > that the problem was not one of difficulty but one of whether it was > advisable to use a certain feature of windows relating to stacks & > exception handling. Has this been resolved in a positive fashion (i.e. > we're happy with the issue being negligible and/or have a different method)? The sigaltstack() issue still exists and is now known to be unsolvable (can't emulate the effect). Instead I'll go with the workaround of adding a page's worth of slack space at the bottom of the native stacks, and possibly also an inaccessible guard page. This makes native threads less light-weight, but so be it. Another issue probably not mentioned before is HiPE's desire to have the system enable floating-point exceptions as that improves the performance of floating-point code in Erlang and simplifies the compiler. The mechanisms for enabling FPEs are highly system-dependent, but I've recently worked out how to do that on Win32/x86, so that's no longer an obstacle. /Mikael From tony@REDACTED Mon Nov 24 09:23:20 2008 From: tony@REDACTED (Tony Arcieri) Date: Mon, 24 Nov 2008 01:23:20 -0700 Subject: [erlang-questions] Why can't HiPE inline functions across modules? In-Reply-To: <566389.37770.qm@web111407.mail.gq1.yahoo.com> References: <566389.37770.qm@web111407.mail.gq1.yahoo.com> Message-ID: On Wed, Nov 19, 2008 at 3:04 AM, Thomas Lindgren wrote: > The deoptimization approach has, as I understand it, been taken far in Java > after being proposed for Self. Unfortunately for a low-budget community, it > looks like a great deal of unglamorous, grotty engineering and testing to > get it working flawlessly :-) > I've just begun taking a look at what's actually involved with this, and wow, there be dragons. I'm sorry, but I don't think you'll be seeing any code contributions from me on this at any point in the near future. I will take a look at your papers, though... -- Tony Arcieri medioh.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From kenneth.lundin@REDACTED Mon Nov 24 09:53:17 2008 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Mon, 24 Nov 2008 09:53:17 +0100 Subject: [erlang-questions] Erlang performance on Windows In-Reply-To: References: Message-ID: Hi Jesper, It would be interesting to know you experiences regarding performance of real applications written in Erlang and specifically on Windows if that is your are or interest. I am asking since I know that most of the commercial products that I know the details about are not using native code generation at all. And they are doing fine when it comes to performance anyway. I also know that some of those applications have tested with native code generation without getting significant performance improvements. So I think you are drawing the wrong conclusion if you thing you need native code generateion in order to get adequate performance. The HiPE (native code generation and execution) is very good and can speed up sequential execution significantly (can be as good as a factor 10 better but normally less. A typical case when you can get a great performance boost with native code generation is when you have an algorithm that deals with binary matching and where the whole execution is done inside the native code without frequent calls to non native code. Note that compiling everything as native will not automatically mean improved performance. A system which is heavy on message passing (local and distributed), and ets-tables will not gain anything from executing native code since the execution inside the VM will be dominating and is the same both for native and interpreted code. In summary, HiPE (native code generation) is great, if you use it with care you can get outstanding performance. You don't need HiPE in order to get good or competitive performance with Erlang. /Kenneth Erlang/OTP Ericsson On Sun, Nov 23, 2008 at 6:26 PM, Jesper Eskilson wrote: > Hi all, > > I was doing some Project Euler stuff on my Windows machine at home, > and realized that there does not seem to be any Hipe support on > Windows. I found some notes from a year or two back about why there > was no Hipe support on Windows (I didn't delve into the technical > details, though), but I was wondering what the status is now. > > (Since there is SMP support on Windows now, I assumed that there was > at least some demand for running Erlang applications on Windows and > still get some sort of performance.) > > -- > /Jesper > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From jesper@REDACTED Mon Nov 24 11:16:05 2008 From: jesper@REDACTED (Jesper Eskilson) Date: Mon, 24 Nov 2008 11:16:05 +0100 Subject: [erlang-questions] Erlang performance on Windows In-Reply-To: References: Message-ID: On Mon, Nov 24, 2008 at 9:53 AM, Kenneth Lundin wrote: > Hi Jesper, > > It would be interesting to know you experiences regarding performance > of real applications written in Erlang > and specifically on Windows if that is your are or interest. > > I am asking since I know that most of the commercial products that I > know the details about are > not using native code generation at all. And they are doing fine when > it comes to performance anyway. > I also know that some of those applications have tested with native > code generation without getting > significant performance improvements. I'm mostly using Erlang to solve problems at projecteuler.net. I'm not sure if that qualifies as "real applications". :-) I think all of the problems I've solved so far have exclusively been sequential (calculating primes using Eratosthenes sieve, for example). I'm comparing the runtimes with what other people are getting with Java, Haskell, Php, Visual Basic, etc, and my Erlang code always seem to take 5-10 times longer time to run. Of course, it could just mean that I'm a lousy Erlang-programmer... ;-) > In summary, HiPE (native code generation) is great, if you use it with > care you can get outstanding performance. > You don't need HiPE in order to get good or competitive performance with Erlang. I'll run the corresponding program on my Linux-box and see what kind of performance difference we're really talking about. -- /Jesper From erlang@REDACTED Mon Nov 24 11:33:13 2008 From: erlang@REDACTED (Ben Fuhrmannek) Date: Mon, 24 Nov 2008 11:33:13 +0100 Subject: [erlang-questions] generating primes In-Reply-To: <3BE6DBA1F3BE9D4798255806113D56540F78C912D5@utx-exchange.utx.local> References: <3BE6DBA1F3BE9D4798255806113D56540F78C912D5@utx-exchange.utx.local> Message-ID: Another approach to prime number generation: http://en.wikipedia.org/wiki/Prime_number_formulas#Other_formulas prime(N, Nfac1) -> Nfac = Nfac1 * N, Prime = 2 + ((2 * Nfac) rem (N+1)), case Prime of 2 -> omit; _ -> io:format("~p~n", [Prime]) end, prime(N+1, Nfac). start: prime(1,1). From anton.krasovsky@REDACTED Mon Nov 24 11:44:57 2008 From: anton.krasovsky@REDACTED (Anton Krasovsky) Date: Mon, 24 Nov 2008 10:44:57 +0000 Subject: [erlang-questions] [ANN] Erlide 0.4.0 was released In-Reply-To: <95be1d3b0811211346n2de6140btfb3ccd8821f8f7f8@mail.gmail.com> References: <95be1d3b0811211346n2de6140btfb3ccd8821f8f7f8@mail.gmail.com> Message-ID: <46167e6a0811240244g3b31577dwe7208eb54f3de1e5@mail.gmail.com> Thanks for a new release, looking forward to try it out. I've been using Erlide for about a half-year now, but never had a chance to say thanks. anton On Fri, Nov 21, 2008 at 9:46 PM, Vlad Dumitrescu wrote: > Hi all! > > Finally, the 0.4 release is here! > > We now have a functioning debugger, much better stability and a lot of > smaller features that are waiting to be explored! > > Please check the documentation inside Eclipse or at > http://erlide.sourceforge.net/erlide.html for more details. > > Please note that if you used older versions you might have to > reinstall the Erlang runtime: go to "Window-> Preferences-> Erlang-> > Installed runtimes" to check. > > If you encounter problems, please use the "Window-> Preferences-> > Erlang-> Report problems" dialog. > > Enjoy! > /Vlad and Jakob > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From peter.mccarthy.0807@REDACTED Mon Nov 24 11:54:08 2008 From: peter.mccarthy.0807@REDACTED (Peter McCarthy) Date: Mon, 24 Nov 2008 10:54:08 +0000 Subject: [erlang-questions] Problem Loading Shared (.so) Library Within Linked-in Driver Message-ID: <57d241cf0811240254u30f5a84oa53575851295975f@mail.gmail.com> Dear all I've developed a linked-in driver which I load and unload using the functions erl_ddll:load_driver / open_port and port_close / erl_ddll:unload_driver respectively. In the driver's start function (called when a port is opened), I load a shared (.so) library using dlopen. Then, in the driver's command function, I call various functions in that shared library. Finally, in the driver's stop function (called when a port is closed), I use dlclose to unload the shared library. Now, everything works okay in general. However, I've noticed the following problem. If I repeatedly load and unload the linked-in driver within the same emulator instance, the dlopen function will eventually fail (always on the 29th call) with the following error: "cannot allocate memory in static TLS block" When this happen, a restart of the emulator is required. Does anyone know what's happening here? I notice that linked-in driver functions such as start, command and stop must be declared static. Is the fact that I'm working with shared libraries within static functions the cause of the problem in some way? Also, I've noticed that if I comment-out the call to dlclose, the problem 'goes away'. One final thing I've noticed is that erl_driver.h includes prototypes such as driver_dl_open and driver_dl_close. I've tried using these instead, but couldn't get them to work (they are undocumented, though). Any help would be gratefully received. Peter From mikpe@REDACTED Mon Nov 24 12:29:36 2008 From: mikpe@REDACTED (Mikael Pettersson) Date: Mon, 24 Nov 2008 12:29:36 +0100 Subject: [erlang-questions] Problem Loading Shared (.so) Library Within Linked-in Driver In-Reply-To: <57d241cf0811240254u30f5a84oa53575851295975f@mail.gmail.com> References: <57d241cf0811240254u30f5a84oa53575851295975f@mail.gmail.com> Message-ID: <18730.36896.366951.613079@harpo.it.uu.se> Peter McCarthy writes: > Dear all > > I've developed a linked-in driver which I load and unload using the > functions erl_ddll:load_driver / open_port and port_close / > erl_ddll:unload_driver respectively. > > In the driver's start function (called when a port is opened), I load > a shared (.so) library using dlopen. Then, in the driver's command > function, I call various functions in that shared library. Finally, in > the driver's stop function (called when a port is closed), I use > dlclose to unload the shared library. > > Now, everything works okay in general. However, I've noticed the > following problem. If I repeatedly load and unload the linked-in > driver within the same emulator instance, the dlopen function will > eventually fail (always on the 29th call) with the following error: > > "cannot allocate memory in static TLS block" > > When this happen, a restart of the emulator is required. Does anyone > know what's happening here? That message comes from glibc (so you're probably on Linux right?) when it runs out of slots in the static thread-local-storage array. This means that something leaks TLS slots. Could be Erlang, could be glibc, or it could be your driver. Unfortunately I know nothing about Erlang's driver interface or erl_ddll, so I can't offer any insights on that. I'd run it with gprof (and linked with gprof-enabled glibc) and look for whoever calls glibc's TLS allocation routines. From julien.sylvestre@REDACTED Mon Nov 24 12:24:15 2008 From: julien.sylvestre@REDACTED (julien.sylvestre@REDACTED) Date: Mon, 24 Nov 2008 12:24:15 +0100 Subject: [erlang-questions] FP Jobs Message-ID: <54585.1227525855@mlstate.com> MLstate - currently in stealth mode - is an IT company, whose functional programming approach to SaaS and cloud computing has been recently recognized by the French Ministry of Research Innovation Award. We are research-oriented, we value technical excellence and innovation and we believe our technology has a potential to dramatically change the way web applications are being built. MLstate opens several new permanent positions to meet this challenge: - Senior Developers: Outstanding PhDs with at least 3 years of research experience in functional languages and/or formal verification and the ability to manage a small technical team. - Developers: PhDs with strong FP skills. Applications from PhD students defending their thesis soon and who should not be reading the caml list right now... are welcome. Jobs are based in Paris and include a competitive compensation package. Please send a (link to your) CV to julien.sylvestre@REDACTED From oscar@REDACTED Mon Nov 24 13:58:48 2008 From: oscar@REDACTED (=?ISO-8859-1?Q?Oscar_Hellstr=F6m?=) Date: Mon, 24 Nov 2008 12:58:48 +0000 Subject: [erlang-questions] How to force kernel application will always be started before my app In-Reply-To: <3bff71aa0811230933m2737a234q3920b4a7d197b91c@mail.gmail.com> References: <3bff71aa0811230933m2737a234q3920b4a7d197b91c@mail.gmail.com> Message-ID: <492AA508.70102@erlang-consulting.com> Hi, You probably want to create a custom boot script for your application rather than using the start_sasl one. You could check out http://erlang.org/doc/design_principles/release_structure.html#10 and see how releases, start scripts and release packages can be built. Sergey A. wrote: > Hello. > > I've a tricky problem with starting my OTP application from escript interface. > > Here is what I do in escript to start my app: > > First I start a node for my application: > > RunNode = "erl -detached -sname foo@REDACTED -setcookie my_cookie > -boot start_sasl -config log -pa /path/to/ebin", > os:cmd(RunNode) > > Then my script waits until the node is actually started: > > wait_for(pong, foo@REDACTED), > > after that I do rpc:call to start my application and check if there > was an error (that is why I don't use "erl -s foo start". I need to > know in my escript whether app was started or not): > > case rpc:call(foo@REDACTED, foo, start, []) of > ok -> ok; > {error, Reason} -> > erlang:error(internal_foo_error) > end > > But at some computers such a rpc:call fails with {error, > {not_started,kernel}} return value. This happens because kernel > application doesn't have enough time between os:cmd and rpc:call calls > to start. > > What I should do to avoid this error in a right manner? > > I think that using of timer:sleep(300) isn't the right way. > > I could use somethin like > > [rpc:call(foo@REDACTED, application, start, [App]) || App <- [kernel, sasl]] > > in escript before starting my application, but it looks like a hack > (or not?). I beleive there should be the standard way to ensure that > all the dependencies of my app were already started. > > It's my foo.app: > > {application, foo, > [{description, "Foo"}, > {vsn, "1.0"}, > {modules, []}, > {registered, [foo_storage, foo_sup, foo_web]}, > {applications, [kernel, stdlib, sasl]}, > {mod, {gin_app, []}} > ]}. > > Thanks. > > -- > Sergey. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions Best regards -- Oscar Hellstr?m, oscar@REDACTED Office: +44 20 7655 0337 Mobile: +44 798 45 44 773 Erlang Training and Consulting http://www.erlang-consulting.com/ From dschaub@REDACTED Mon Nov 24 15:26:11 2008 From: dschaub@REDACTED (Duane Schaub) Date: Mon, 24 Nov 2008 08:26:11 -0600 Subject: [erlang-questions] generating primes In-Reply-To: References: <3BE6DBA1F3BE9D4798255806113D56540F78C912D5@utx-exchange.utx.local> Message-ID: <6328ACFA98F141C4B6D3D66737BE18E8@dskkadschaub> Given erlang's ability to handle arbitrary math - how much ram would be needed to calculate a 14million digit prime? I think that there was mention that each digit is 16 bits, so that would be 28MB per value and you would need to store that plus at least two other values half that size - of course, I could be totally off base here. If that is true, this is well within the limits of a PC.... perhaps an erlang grid machine to find the next prime would be in order. I think this would be a nice demonstration and could be made with an adaptation of the eJabber program or the Armstrong chat server demo from his book. A client subscribes and is given a "chunk" to process. The server just tracks chunks and if no result is returned after a period of time, the chunk is reassigned. Duane. From phvander@REDACTED Mon Nov 24 16:51:28 2008 From: phvander@REDACTED (philippe vanderstraeten) Date: Mon, 24 Nov 2008 16:51:28 +0100 Subject: [erlang-questions] beam_load.c error message Message-ID: <12d458770811240751h1c64fa6cv38740f9e1e0b3718@mail.gmail.com> Hi, I am running tsung 1.3.0 rev 884, and I get an error message from erlang: [admin@REDACTED scenarios]$ tsung -f test.xml start Starting Tsung =ERROR REPORT==== 24-Nov-2008::15:54:09 === Loading of /usr/local/lib/erlang/lib/tsung_controller-1.3.0/ebin/tsung_controller.beam failed: badfile =ERROR REPORT==== 24-Nov-2008::15:54:09 === beam/beam_load.c(1730): Error loading function tsung_controller:status/1: op int_div p x x r: please re-compile this module with an R12B compiler This error message told me to recompile Tsung with the R12B compiler. But it has been compiled with this compiler, since the only one compiler installed is R12B. What could be wrong ? Thanks =============================================== See computer information bellow: ============================= [admin@REDACTED otp_src_R12B-2]$ erl Erlang (BEAM) emulator version 5.6.2 [source] [smp:4] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.6.2 (abort with ^G) 1> ============================= The hardware platform is SMP: [root@REDACTED proc]# more cpuinfo processor : 0 cpu : POWER5 (gr) clock : 1902.096000MHz revision : 2.2 processor : 1 cpu : POWER5 (gr) clock : 1902.096000MHz revision : 2.2 processor : 2 cpu : POWER5 (gr) clock : 1902.096000MHz revision : 2.2 processor : 3 cpu : POWER5 (gr) clock : 1902.096000MHz revision : 2.2 timebase : 238063000 machine : CHRP IBM,9119-595 [root@REDACTED proc]# dmesg | grep -i smp Linux version 2.6.9-34.EL (bhcompile@REDACTED) (gcc version 3.4.5 20051201 (Red Hat 3.4.5-2)) #1 SMP Fri Feb 24 16:46:57 EST 2006 [root@REDACTED proc]# grep smp.init * kallsyms:c00000000000b574 t .pseries_secondary_smp_init kallsyms:c00000000000c4a0 t .do_pre_smp_initcalls kallsyms:c0000000003674d0 t .smp_init kallsyms:c000000000374298 t .smp_init_pSeries -------------- next part -------------- An HTML attachment was scrubbed... URL: From bgustavsson@REDACTED Mon Nov 24 17:19:19 2008 From: bgustavsson@REDACTED (Bjorn Gustavsson) Date: Mon, 24 Nov 2008 17:19:19 +0100 Subject: [erlang-questions] beam_load.c error message In-Reply-To: <12d458770811240751h1c64fa6cv38740f9e1e0b3718@mail.gmail.com> References: <12d458770811240751h1c64fa6cv38740f9e1e0b3718@mail.gmail.com> Message-ID: <6672d0160811240819v1cdecaey984bd580d4b25d46@mail.gmail.com> 2008/11/24 philippe vanderstraeten : > [admin@REDACTED scenarios]$ tsung -f test.xml start > Starting Tsung > > =ERROR REPORT==== 24-Nov-2008::15:54:09 === > Loading of > /usr/local/lib/erlang/lib/tsung_controller-1.3.0/ebin/tsung_controller.beam > failed: badfile > > =ERROR REPORT==== 24-Nov-2008::15:54:09 === > beam/beam_load.c(1730): Error loading function tsung_controller:status/1: op > int_div p x x r: > please re-compile this module with an R12B compiler > > This error message told me to recompile Tsung with the R12B compiler. But it > has been compiled with this compiler, since the only one compiler installed > is R12B. Please double-check that. Are you sure that all files were compiled with the R12B compiler? The int_div instruction can only be generated by the compiler in R10B or earlier. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From vances@REDACTED Mon Nov 24 19:08:32 2008 From: vances@REDACTED (Vance Shipley) Date: Mon, 24 Nov 2008 13:08:32 -0500 Subject: [erlang-questions] Binary pattern matching and optimization Message-ID: <20081124180828.GA8913@h216-235-12-166.host.egate.net> I would like to have a function like this: foo(<<_:Offset/binary, Foo:8, _/binary>>, Offset) -> bar(Bin, Foo). Unfortunately that doesn't work: Eshell V5.6.5 (abort with ^G) 1> compile:file(codec). ./codec.erl:15: variable 'Offset' is unbound error I don't understand why the first version can't work but neither do I understand much about writing compilers. So instead I do this: foo(Bin, Offset) -> <<_:Offset/binary, Foo:8, _/binary>> = Bin, bar(Bin, Foo). This works fine of course but now I am trying to understand the meaning of this (optional) compiler warning: Warning: INFO: using a matched out sub binary will prevent delayed sub binary optimization How should I interpret this warning? -Vance From rvirding@REDACTED Mon Nov 24 20:10:38 2008 From: rvirding@REDACTED (Robert Virding) Date: Mon, 24 Nov 2008 20:10:38 +0100 Subject: [erlang-questions] Binary pattern matching and optimization In-Reply-To: <20081124180828.GA8913@h216-235-12-166.host.egate.net> References: <20081124180828.GA8913@h216-235-12-166.host.egate.net> Message-ID: <3dbc6d1c0811241110m38d7b359gdb1c1f55ce119daf@mail.gmail.com> 2008/11/24 Vance Shipley > I would like to have a function like this: > > foo(<<_:Offset/binary, Foo:8, _/binary>>, Offset) -> > bar(Bin, Foo). > > Unfortunately that doesn't work: > > Eshell V5.6.5 (abort with ^G) > 1> compile:file(codec). > ./codec.erl:15: variable 'Offset' is unbound > error The order in which arguments are matched is not defined so there is no guarantee that Offset has a value when the binary is matched. I don't understand why the first version can't work but > neither do I understand much about writing compilers. > > So instead I do this: > > foo(Bin, Offset) -> > <<_:Offset/binary, Foo:8, _/binary>> = Bin, > bar(Bin, Foo). > > This works fine of course but now I am trying to understand > the meaning of this (optional) compiler warning: > > Warning: INFO: using a matched out sub binary will prevent > delayed sub binary optimization > > How should I interpret this warning? The compiler and VM is smart and optimises the matching of a binary where the last segment is a binary. This makes it more efficient to use a binary like a list and pick things off the front. *BUT* for this to work the reference to the whole binary, Bin your case, must not be used after the match, then the compiler can reuse that binary reference and save work. You reuse Bin and the compiler is warning you that when you do this it can't do a good a job as possible. Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: From vances@REDACTED Mon Nov 24 20:27:30 2008 From: vances@REDACTED (Vance Shipley) Date: Mon, 24 Nov 2008 14:27:30 -0500 Subject: [erlang-questions] Binary pattern matching and optimization In-Reply-To: <3dbc6d1c0811241110m38d7b359gdb1c1f55ce119daf@mail.gmail.com> References: <20081124180828.GA8913@h216-235-12-166.host.egate.net> <3dbc6d1c0811241110m38d7b359gdb1c1f55ce119daf@mail.gmail.com> Message-ID: <20081124192730.GC8913@h216-235-12-166.host.egate.net> Robert, My thinking was that reading a big binary and then passing it with offsets to various parsing functions would be easier on the emulator than creating a new binary for each one. Is it the case that the compiler will optimize away the creation of these binaries? -Vance On Mon, Nov 24, 2008 at 08:10:38PM +0100, Robert Virding wrote: } The compiler and VM is smart and optimises the matching of a binary where } the last segment is a binary. This makes it more efficient to use a binary } like a list and pick things off the front. } } *BUT* for this to work the reference to the whole binary, Bin your case, } must not be used after the match, then the compiler can reuse that binary } reference and save work. You reuse Bin and the compiler is warning you that } when you do this it can't do a good a job as possible. From pablo.platt@REDACTED Mon Nov 24 20:56:33 2008 From: pablo.platt@REDACTED (Pablo Platt) Date: Mon, 24 Nov 2008 11:56:33 -0800 (PST) Subject: [erlang-questions] Erlang for a measurement system? References: <708273.62594.qm@web110012.mail.gq1.yahoo.com> <492434EE.5050804@ericsson.com> Message-ID: <402114.55724.qm@web110013.mail.gq1.yahoo.com> I couldn't find an implemntation except for serial port with a c bridge: http://www.erlang.org/user.html#serial-1.0 Is it possible to communicate directly with hardware without using c code? I understand that on linux hardware is a file so is it possible to talk with the hardware with io erlang functions? Thanks ________________________________ From: Ulf Wiger (TN/EAB) To: Pablo Platt Cc: erlang-questions@REDACTED Sent: Wednesday, November 19, 2008 5:46:54 PM Subject: Re: [erlang-questions] Erlang for a measurement system? How precise do the measurements need to be? You write "resolution of ms". If by that you mean +-1 ms, then you're problably going to have to control the machine pretty tightly, make sure that there are no cpu-bound tasks that can prolong context switches, etc. If it's ok to be off by some milliseconds now and again, then it will probably work. You should use a multi-core machine and make sure that the load stays fairly low. >From a programming perspective, controlling different devices was one of Erlang's core requirements from the start. It's one of the things it does really, really well. BR, Ulf W Pablo Platt skrev: > Hi, > > We are considering erlang for building a controlled measurement system in our laboratory. > The erlang software will control several devices using VISA (GPIB, RS232, USB). > > Are there any advantages for using erlang for this implementation? > Will erlang be able to control two different devices in parallel in a reliable way because of its 'share nothing' principle? > Is synchronizing several process (resolution of ms) an advantage of erlang or is it mainly an hardware issue? > Is synchronizing several computers(resolution of ms) an advantage of erlang? > Are there know implementations of erlang for controlling measurement devices (VISA)? > Is there an advantage of using erlang compared to python (http://pypi.python.org/pypi/PyVISA/1.3). > > Appreciate your feedback, > Pablo > > > > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From rvirding@REDACTED Mon Nov 24 20:57:52 2008 From: rvirding@REDACTED (Robert Virding) Date: Mon, 24 Nov 2008 20:57:52 +0100 Subject: [erlang-questions] Binary pattern matching and optimization In-Reply-To: <20081124192730.GC8913@h216-235-12-166.host.egate.net> References: <20081124180828.GA8913@h216-235-12-166.host.egate.net> <3dbc6d1c0811241110m38d7b359gdb1c1f55ce119daf@mail.gmail.com> <20081124192730.GC8913@h216-235-12-166.host.egate.net> Message-ID: <3dbc6d1c0811241157n5a511c86xa4808787a84f22b@mail.gmail.com> 2008/11/24 Vance Shipley > Robert, > > My thinking was that reading a big binary and then passing it > with offsets to various parsing functions would be easier on > the emulator than creating a new binary for each one. Is it > the case that the compiler will optimize away the creation of > these binaries? > No, I don't think so. It optimises the following case: foo(<< ... , Rest/binary>>, ... ) -> ... bar(Rest, ...); The important thing is that the old reference to the binary is not used again and can be reused by the compiler. If you have a big binary and want to pass off chunks of it to different functions is a different problem. Then it is probably better to pass the whole binary and an offset. However, doing something like: foo(Offset, Bin, ...) -> << _:Offset/binary, Stuff, _/binary>> = Bin, ... foo(Offset + N, Bin, ...) and skipping over the beginning each time is most likely not the best way to step over bits of your chunk. I would do something like: foo(Offset, Bin, ...) -> << _:Offset/binary,TheGoodBit/binary >> = Bin, foo1(TheGoodBit, ...). and foo1 as my first example above which picks bit off the head of the bin. Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob@REDACTED Mon Nov 24 21:23:32 2008 From: bob@REDACTED (Bob Ippolito) Date: Mon, 24 Nov 2008 12:23:32 -0800 Subject: [erlang-questions] Binary pattern matching and optimization In-Reply-To: <20081124192730.GC8913@h216-235-12-166.host.egate.net> References: <20081124180828.GA8913@h216-235-12-166.host.egate.net> <3dbc6d1c0811241110m38d7b359gdb1c1f55ce119daf@mail.gmail.com> <20081124192730.GC8913@h216-235-12-166.host.egate.net> Message-ID: <6a36e7290811241223j1a68555am1cec61f9df03dfba@mail.gmail.com> That used to be true, but it's supposed to be faster in R12+ to do it in the "obvious" way. On Mon, Nov 24, 2008 at 11:27 AM, Vance Shipley wrote: > Robert, > > My thinking was that reading a big binary and then passing it > with offsets to various parsing functions would be easier on > the emulator than creating a new binary for each one. Is it > the case that the compiler will optimize away the creation of > these binaries? > > -Vance > > On Mon, Nov 24, 2008 at 08:10:38PM +0100, Robert Virding wrote: > } The compiler and VM is smart and optimises the matching of a binary where > } the last segment is a binary. This makes it more efficient to use a binary > } like a list and pick things off the front. > } > } *BUT* for this to work the reference to the whole binary, Bin your case, > } must not be used after the match, then the compiler can reuse that binary > } reference and save work. You reuse Bin and the compiler is warning you that > } when you do this it can't do a good a job as possible. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From puzza007@REDACTED Mon Nov 24 22:08:07 2008 From: puzza007@REDACTED (Paul Oliver) Date: Mon, 24 Nov 2008 21:08:07 +0000 Subject: [erlang-questions] inet_db:lookup_socket/1 failing for gen_tcp:controlling_process with mochiweb socket server Message-ID: Hi all, I have a curious bug that I've tracked down to a call to gen_tcp:controlling_process. From the stack trace (simple example reproduced below) it seems that the port in question definitely exists, but the call to inet_db:lookup fails. Has anyone seen this before or got any advice? Thanks! Paul. Erlang (BEAM) emulator version 5.6.5 [source] [async-threads:0] [kernel-poll:false] Eshell V5.6.5 (abort with ^G) 1> mochiweb_socket_server:start( [{ip, "127.0.0.1"}, {loop, {connection, start}}, {name, badger}, {port, 8888}]). {ok,<0.32.0>} 2> Sock = gen_tcp:connect('127.0.0.1', 8888, [binary, {packet, line}, {nodelay, true}], 3000000). {ok,#Port<0.496>} 3> gen_tcp:controlling_process(Sock, self()). =ERROR REPORT==== 24-Nov-2008::20:59:12 === ** Generic server badger terminating ** Last message in was {'EXIT',<0.30.0>, {function_clause, [{inet_db,lookup_socket,[{ok,#Port<0.496>}]}, {gen_tcp,controlling_process,2}, {erl_eval,do_apply,5}, {shell,exprs,6}, {shell,eval_exprs,6}, {shell,eval_loop,3}]}} ** When Server state == {mochiweb_socket_server,8888, {connection,start}, {local,badger}, 2047, {127,0,0,1}, #Port<0.488>,<0.37.0>,30} ** Reason for termination == ** {function_clause,[{inet_db,lookup_socket,[{ok,#Port<0.496>}]}, {gen_tcp,controlling_process,2}, {erl_eval,do_apply,5}, {shell,exprs,6}, {shell,eval_exprs,6}, {shell,eval_loop,3}]} ** exception exit: function_clause in function inet_db:lookup_socket/1 called as inet_db:lookup_socket({ok,#Port<0.496>}) in call from gen_tcp:controlling_process/2 4> -------------- next part -------------- An HTML attachment was scrubbed... URL: From matthias@REDACTED Mon Nov 24 22:30:24 2008 From: matthias@REDACTED (Matthias Lang) Date: Mon, 24 Nov 2008 22:30:24 +0100 Subject: [erlang-questions] Erlang for a measurement system? In-Reply-To: <402114.55724.qm@web110013.mail.gq1.yahoo.com> References: <708273.62594.qm@web110012.mail.gq1.yahoo.com> <492434EE.5050804@ericsson.com> <402114.55724.qm@web110013.mail.gq1.yahoo.com> Message-ID: <20081124213024.GA6491@contorpis.lisalinda.com> On Monday, November 24, Pablo Platt wrote: > Is it possible to communicate directly with hardware without using c code? No. > I understand that on linux hardware is a file so is it possible to > talk with the hardware with io erlang functions? Some, but far from all, hardware on linux is a file. Even the ones that are, e.g. serial ports, can't be controlled directly from Erlang because Erlang won't let you open non-regular files. And for other reasons. Most of the Erlang code I write controls proprietary hardware. It always does that through C code. The trick is to keep the C code simple and put the complexity up in Erlang. Matt From pablo.platt@REDACTED Mon Nov 24 22:47:39 2008 From: pablo.platt@REDACTED (Pablo Platt) Date: Mon, 24 Nov 2008 13:47:39 -0800 (PST) Subject: [erlang-questions] Erlang for a measurement system? References: <708273.62594.qm@web110012.mail.gq1.yahoo.com> <492434EE.5050804@ericsson.com> <402114.55724.qm@web110013.mail.gq1.yahoo.com> <20081124213024.GA6491@contorpis.lisalinda.com> Message-ID: <51120.33131.qm@web110016.mail.gq1.yahoo.com> That's exactly what I'm trying to do. I've found linux-gpib but it seems that all the logic is in the c files http://linux-gpib.sourceforge.net/ and I'm not sure I can take advantage of erlang goodies. I'll appreciate if anyone could give me a simple c interface for VISA/GPIB and a corresponding erlang code or any advice. ? Thanks ________________________________ From: Matthias Lang To: Pablo Platt Cc: erlang-questions@REDACTED Sent: Monday, November 24, 2008 11:30:24 PM Subject: Re: [erlang-questions] Erlang for a measurement system? On Monday, November 24, Pablo Platt wrote: > Is it possible to communicate directly with hardware without using c code? No. > I understand that on linux hardware is a file so is it possible to > talk with the hardware with io erlang functions? Some, but far from all, hardware on linux is a file. Even the ones that are, e.g. serial ports, can't be controlled directly from Erlang because Erlang won't let you open non-regular files. And for other reasons. Most of the Erlang code I write controls proprietary hardware. It always does that through C code. The trick is to keep the C code simple and put the complexity up in Erlang. Matt -------------- next part -------------- An HTML attachment was scrubbed... URL: From kostis@REDACTED Mon Nov 24 22:55:38 2008 From: kostis@REDACTED (Kostis Sagonas) Date: Mon, 24 Nov 2008 23:55:38 +0200 Subject: [erlang-questions] Erlang performance on Windows In-Reply-To: References: Message-ID: <492B22DA.4050508@cs.ntua.gr> Jesper, Some comments: > I'm mostly using Erlang to solve problems at projecteuler.net. I'm not > sure if that qualifies as "real applications". :-) I think all of the > problems I've solved so far have exclusively been sequential > (calculating primes using Eratosthenes sieve, for example). You are probably aware, I guess, that these are not the "typical" applications that Erlang is targeting and obviously Erlang is not the best language for this kind of tasks. > I'm comparing the runtimes with what other people are getting with > Java, Haskell, Php, Visual Basic, etc, and my Erlang code always seem > to take 5-10 times longer time to run. Of course, it could just mean > that I'm a lousy Erlang-programmer... ;-) It could :-) but I somehow doubt it. If your performance difference with these languages (esp. PHP and Visual Basic) is more or less constant when the size of the benchmark increases, it probably means that your Erlang programming skills are not the main culprit and you need to investigate somewhere else. >> In summary, HiPE (native code generation) is great, if you use it with >> care you can get outstanding performance. >> You don't need HiPE in order to get good or competitive performance with Erlang. > > I'll run the corresponding program on my Linux-box and see what kind > of performance difference we're really talking about. I would be interested to see the numbers. Especially since on that box you can factor out any possible "Windows surprises" and quantify the performance improvements that native code compilation provides for you. Best, Kostis From dmercer@REDACTED Mon Nov 24 23:04:26 2008 From: dmercer@REDACTED (David Mercer) Date: Mon, 24 Nov 2008 16:04:26 -0600 Subject: [erlang-questions] Binary pattern matching and optimization In-Reply-To: <3dbc6d1c0811241157n5a511c86xa4808787a84f22b@mail.gmail.com> References: <20081124180828.GA8913@h216-235-12-166.host.egate.net><3dbc6d1c0811241110m38d7b359gdb1c1f55ce119daf@mail.gmail.com><20081124192730.GC8913@h216-235-12-166.host.egate.net> <3dbc6d1c0811241157n5a511c86xa4808787a84f22b@mail.gmail.com> Message-ID: Follow-up question to the converse problem: assembling binaries. If binaries are best handled like lists while reading them, is it also true that binaries are best assembled back-to-front like lists, putting the new binary chunk onto the beginning of the binary instead of the end? _____ From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Robert Virding Sent: Monday, November 24, 2008 13:58 To: Vance Shipley; Robert Virding; Erlang Questions Subject: Re: [erlang-questions] Binary pattern matching and optimization 2008/11/24 Vance Shipley Robert, My thinking was that reading a big binary and then passing it with offsets to various parsing functions would be easier on the emulator than creating a new binary for each one. Is it the case that the compiler will optimize away the creation of these binaries? No, I don't think so. It optimises the following case: foo(<< ... , Rest/binary>>, ... ) -> ... bar(Rest, ...); The important thing is that the old reference to the binary is not used again and can be reused by the compiler. If you have a big binary and want to pass off chunks of it to different functions is a different problem. Then it is probably better to pass the whole binary and an offset. However, doing something like: foo(Offset, Bin, ...) -> << _:Offset/binary, Stuff, _/binary>> = Bin, ... foo(Offset + N, Bin, ...) and skipping over the beginning each time is most likely not the best way to step over bits of your chunk. I would do something like: foo(Offset, Bin, ...) -> << _:Offset/binary,TheGoodBit/binary >> = Bin, foo1(TheGoodBit, ...). and foo1 as my first example above which picks bit off the head of the bin. Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: From vances@REDACTED Mon Nov 24 23:10:49 2008 From: vances@REDACTED (Vance Shipley) Date: Mon, 24 Nov 2008 17:10:49 -0500 Subject: [erlang-questions] Binary pattern matching and optimization In-Reply-To: References: <3dbc6d1c0811241157n5a511c86xa4808787a84f22b@mail.gmail.com> Message-ID: <20081124221049.GD8913@h216-235-12-166.host.egate.net> David, That seems to be well documented in the efficiancy guide: http://erlang.org/doc/efficiency_guide/binaryhandling.html#4.2 In R12B appending to binaries is optimized. -Vance On Mon, Nov 24, 2008 at 04:04:26PM -0600, David Mercer wrote: } Follow-up question to the converse problem: assembling binaries. If } binaries are best handled like lists while reading them, is it also true } that binaries are best assembled back-to-front like lists, putting the new } binary chunk onto the beginning of the binary instead of the end? From puzza007@REDACTED Mon Nov 24 23:28:10 2008 From: puzza007@REDACTED (Paul Oliver) Date: Mon, 24 Nov 2008 22:28:10 +0000 Subject: [erlang-questions] inet_db:lookup_socket/1 failing for gen_tcp:controlling_process with mochiweb socket server In-Reply-To: <20081124221825.GA6732@contorpis.lisalinda.com> References: <20081124221825.GA6732@contorpis.lisalinda.com> Message-ID: On Mon, Nov 24, 2008 at 10:18 PM, Matthias Lang wrote: > On Monday, November 24, Paul Oliver wrote: > > Hi all, > > > > I have a curious bug that I've tracked down to a call to > > gen_tcp:controlling_process. From the stack trace (simple example > > reproduced below) it seems that the port in question definitely exists, > but > > the call to inet_db:lookup fails. Has anyone seen this before or got any > > advice? > > This seems too obvious to be your real problem, but just in case, > the second command isn't handling the return correctly. You probably > meant: > > {ok, Sock} = gen_tcp:connect(... > > Matt > Hi Matt, Ah yes. Thanks for pointing that out! Yes, seems fine now: 1> mochiweb_socket_server:start( [{ip, "127.0.0.1"}, {loop, {connection, start}}, {name, badger}, {port, 8888}]). {ok,<0.32.0>} 2> {ok, Sock} = gen_tcp:connect('127.0.0.1', 8888, [binary, {packet, line}, {nodelay, true}], 3000000). {ok,#Port<0.496>} 3> Sock. #Port<0.496> 4> gen_tcp:controlling_process(Sock, self()). ok 5> Back to the drawing board! Cheers, Paul. > > > > > Thanks! > > Paul. > > > > Erlang (BEAM) emulator version 5.6.5 [source] [async-threads:0] > > [kernel-poll:false] > > > > Eshell V5.6.5 (abort with ^G) > > 1> mochiweb_socket_server:start( [{ip, "127.0.0.1"}, {loop, {connection, > > start}}, {name, badger}, {port, 8888}]). > > {ok,<0.32.0>} > > 2> Sock = gen_tcp:connect('127.0.0.1', 8888, [binary, {packet, line}, > > {nodelay, true}], 3000000). > > {ok,#Port<0.496>} > > 3> gen_tcp:controlling_process(Sock, self()). > > > > =ERROR REPORT==== 24-Nov-2008::20:59:12 === > > ** Generic server badger terminating > > ** Last message in was {'EXIT',<0.30.0>, > > {function_clause, > > > [{inet_db,lookup_socket,[{ok,#Port<0.496>}]}, > > {gen_tcp,controlling_process,2}, > > {erl_eval,do_apply,5}, > > {shell,exprs,6}, > > {shell,eval_exprs,6}, > > {shell,eval_loop,3}]}} > > ** When Server state == {mochiweb_socket_server,8888, > > {connection,start}, > > {local,badger}, > > 2047, > > {127,0,0,1}, > > #Port<0.488>,<0.37.0>,30} > > ** Reason for termination == > > ** {function_clause,[{inet_db,lookup_socket,[{ok,#Port<0.496>}]}, > > {gen_tcp,controlling_process,2}, > > {erl_eval,do_apply,5}, > > {shell,exprs,6}, > > {shell,eval_exprs,6}, > > {shell,eval_loop,3}]} > > ** exception exit: function_clause > > in function inet_db:lookup_socket/1 > > called as inet_db:lookup_socket({ok,#Port<0.496>}) > > in call from gen_tcp:controlling_process/2 > > 4> > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dmercer@REDACTED Mon Nov 24 23:30:16 2008 From: dmercer@REDACTED (David Mercer) Date: Mon, 24 Nov 2008 16:30:16 -0600 Subject: [erlang-questions] Binary pattern matching and optimization In-Reply-To: <20081124221049.GD8913@h216-235-12-166.host.egate.net> References: <3dbc6d1c0811241157n5a511c86xa4808787a84f22b@mail.gmail.com> <20081124221049.GD8913@h216-235-12-166.host.egate.net> Message-ID: <55C8F632ED454F82B3445B040E4E403D@SSI.CORP> That is very good indeed. I kind of felt a pang of guilt in posting my questio, because I thought I should test before asking, so I could see for myself, but really, I ought to have looked in the docs. Thanks, Vance. David > -----Original Message----- > From: Vance Shipley [mailto:vances@REDACTED] > Sent: Monday, November 24, 2008 16:11 > To: dmercer@REDACTED > Cc: Erlang Questions > Subject: Re: [erlang-questions] Binary pattern matching and optimization > > David, > > That seems to be well documented in the efficiancy guide: > > http://erlang.org/doc/efficiency_guide/binaryhandling.html#4.2 > > In R12B appending to binaries is optimized. > > -Vance > > On Mon, Nov 24, 2008 at 04:04:26PM -0600, David Mercer wrote: > } Follow-up question to the converse problem: assembling binaries. If > } binaries are best handled like lists while reading them, is it also > true > } that binaries are best assembled back-to-front like lists, putting the > new > } binary chunk onto the beginning of the binary instead of the end? From ok@REDACTED Tue Nov 25 00:13:19 2008 From: ok@REDACTED (Richard O'Keefe) Date: Tue, 25 Nov 2008 12:13:19 +1300 Subject: [erlang-questions] next(Erlang): "Fix up records so that records are first-class citizens and not just syntax saccharine for tuples?" In-Reply-To: <26b47693-c856-4f94-9857-f7365c94157a@g38g2000yqn.googlegroups.com> References: <8092dc770811191445ie3e8066qf226ddae04cdb3b3@mail.gmail.com> <16f33854-7813-4ff2-8730-23653e726ffe@g38g2000yqn.googlegroups.com> <8092dc770811210415k43823062k3794c3356c0943d4@mail.gmail.com> <26b47693-c856-4f94-9857-f7365c94157a@g38g2000yqn.googlegroups.com> Message-ID: <7042373B-D68D-4B40-B1FB-8C03BAC6F076@cs.otago.ac.nz> On 22 Nov 2008, at 12:27 pm, Steve Davis wrote: > Hmm. JSON uses Strings for property names -- is it really an impedance > mismatch that you should dismiss so easily? > i.e. > JSON: { "Object": {"name": "Damien", "location": "here" }} > Erlang: -record(object {name, location}) which has a tuple > representation { "Damien", "here" } > (case differences emphasized for effect) Yes. Once Unicode is dealt with, any possible slot label in a JSON 'object' will have a corresponding atom usable in a frame, and conversely. JSON: {"Object": {"name": "Damien", "location": "here"}} Frame: <{'Object' ~ <{location ~ "here", name ~ "Damien"}>}> It's a little unfair to present an Erlang "equivalent" of the JSON term shown that simply throws away the outer layer, but if you want to do that, then <{location ~ "here", name ~ "Damien"}> is it. From ok@REDACTED Tue Nov 25 00:16:15 2008 From: ok@REDACTED (Richard O'Keefe) Date: Tue, 25 Nov 2008 12:16:15 +1300 Subject: [erlang-questions] next(Erlang): "Fix up records so that records are first-class citizens and not just syntax saccharine for tuples?" In-Reply-To: <6a36e7290811211626x7ecc71e2o138d478bcbecd5c6@mail.gmail.com> References: <8092dc770811191445ie3e8066qf226ddae04cdb3b3@mail.gmail.com> <16f33854-7813-4ff2-8730-23653e726ffe@g38g2000yqn.googlegroups.com> <8092dc770811210415k43823062k3794c3356c0943d4@mail.gmail.com> <26b47693-c856-4f94-9857-f7365c94157a@g38g2000yqn.googlegroups.com> <8092dc770811211607m7b29ecc1kc532780d15ba5c9@mail.gmail.com> <6a36e7290811211626x7ecc71e2o138d478bcbecd5c6@mail.gmail.com> Message-ID: On 22 Nov 2008, at 1:26 pm, Bob Ippolito wrote: >> Not dismissing it at all. Richard's frames proposal uses atoms for >> "property names". Every atom can be converted to a string, and every >> string can be converted to an atom. An atom is basically an interned >> string. > > That's not strictly true, atoms are limited to 255 characters I think. There is an EEP about that. As it happens, I wrote it (:-). To put it briefly, I propose having two representations for atoms, one of which is basically what we have now, and the other of which does not have any particular limit on size or numbers and does not use a centralised symbol table. In real life, I expect that the limited size symbol table is a more serious threat to JSON labels -> atom mapping; it is too easy to break. This applies to practically *any* use of atoms in data from sources you do not fully control, which is why regardless of whether frames/structs are ever adopted or not, we need better atoms. From matthias@REDACTED Mon Nov 24 23:18:25 2008 From: matthias@REDACTED (Matthias Lang) Date: Mon, 24 Nov 2008 23:18:25 +0100 Subject: [erlang-questions] inet_db:lookup_socket/1 failing for gen_tcp:controlling_process with mochiweb socket server In-Reply-To: References: Message-ID: <20081124221825.GA6732@contorpis.lisalinda.com> On Monday, November 24, Paul Oliver wrote: > Hi all, > > I have a curious bug that I've tracked down to a call to > gen_tcp:controlling_process. From the stack trace (simple example > reproduced below) it seems that the port in question definitely exists, but > the call to inet_db:lookup fails. Has anyone seen this before or got any > advice? This seems too obvious to be your real problem, but just in case, the second command isn't handling the return correctly. You probably meant: {ok, Sock} = gen_tcp:connect(... Matt > > Thanks! > Paul. > > Erlang (BEAM) emulator version 5.6.5 [source] [async-threads:0] > [kernel-poll:false] > > Eshell V5.6.5 (abort with ^G) > 1> mochiweb_socket_server:start( [{ip, "127.0.0.1"}, {loop, {connection, > start}}, {name, badger}, {port, 8888}]). > {ok,<0.32.0>} > 2> Sock = gen_tcp:connect('127.0.0.1', 8888, [binary, {packet, line}, > {nodelay, true}], 3000000). > {ok,#Port<0.496>} > 3> gen_tcp:controlling_process(Sock, self()). > > =ERROR REPORT==== 24-Nov-2008::20:59:12 === > ** Generic server badger terminating > ** Last message in was {'EXIT',<0.30.0>, > {function_clause, > [{inet_db,lookup_socket,[{ok,#Port<0.496>}]}, > {gen_tcp,controlling_process,2}, > {erl_eval,do_apply,5}, > {shell,exprs,6}, > {shell,eval_exprs,6}, > {shell,eval_loop,3}]}} > ** When Server state == {mochiweb_socket_server,8888, > {connection,start}, > {local,badger}, > 2047, > {127,0,0,1}, > #Port<0.488>,<0.37.0>,30} > ** Reason for termination == > ** {function_clause,[{inet_db,lookup_socket,[{ok,#Port<0.496>}]}, > {gen_tcp,controlling_process,2}, > {erl_eval,do_apply,5}, > {shell,exprs,6}, > {shell,eval_exprs,6}, > {shell,eval_loop,3}]} > ** exception exit: function_clause > in function inet_db:lookup_socket/1 > called as inet_db:lookup_socket({ok,#Port<0.496>}) > in call from gen_tcp:controlling_process/2 > 4> > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From ok@REDACTED Tue Nov 25 00:22:22 2008 From: ok@REDACTED (Richard O'Keefe) Date: Tue, 25 Nov 2008 12:22:22 +1300 Subject: [erlang-questions] Erlang elseif In-Reply-To: <44257A6E-1E2F-48E7-84D6-49F165D6DEDA@duomark.com> References: <44257A6E-1E2F-48E7-84D6-49F165D6DEDA@duomark.com> Message-ID: <0B7944CE-A520-41AB-A202-60401EAAD6D5@cs.otago.ac.nz> On 22 Nov 2008, at 8:13 pm, Jay Nelson wrote: a lot that I agree with, but there is a sad irony: > If you look at this code, the concept of branching on a condition > is not represented. Yes it is, and it's precisely branching on a full logical expression, not a guard. This is precisely the kind of sort-of sort-of-not havering which makes the present situation unstable: you CAN'T use a true/false-valued full expression as a test in 'if', but you CAN use one as a test in a list comprehension. I was flabbergasted when I realised that that had been smuggled in. It really is absurd to allow full Boolean-valued expressions in list comprehensions but not in something like 'if'. I have what I think are good reasons for finding the excess power in list comprehensions lamentable rather than the limited power of 'if', but it's hard to see how anybody could justify the current mish-mash. From jay@REDACTED Tue Nov 25 03:22:51 2008 From: jay@REDACTED (Jay Nelson) Date: Mon, 24 Nov 2008 18:22:51 -0800 Subject: [erlang-questions] Erlang elseif In-Reply-To: <0B7944CE-A520-41AB-A202-60401EAAD6D5@cs.otago.ac.nz> References: <44257A6E-1E2F-48E7-84D6-49F165D6DEDA@duomark.com> <0B7944CE-A520-41AB-A202-60401EAAD6D5@cs.otago.ac.nz> Message-ID: <27DC493B-1EFB-429B-B561-DDC473FAC3C3@duomark.com> > On 22 Nov 2008, at 8:13 pm, Jay Nelson wrote: > a lot that I agree with, but there is a sad irony: >> If you look at this code, the concept of branching on a condition >> is not represented. > > Yes it is, and it's precisely branching on a full logical expression, > not a guard. Conceptually for me it is a filter, rather than a branch. > > It really is absurd to allow full Boolean-valued expressions > in list comprehensions but not in something like 'if'. > I have what I think are good reasons for finding the excess > power in list comprehensions lamentable rather than the limited > power of 'if', but it's hard to see how anybody could justify > the current mish-mash. > I would do away with the 'if'. I almost never find myself using it. I would, however, enthusiastically embrace the 'cond' statement as an addition to 'case' and replacement for 'if'. jay From erlang-questions_efine@REDACTED Tue Nov 25 04:27:35 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Mon, 24 Nov 2008 22:27:35 -0500 Subject: [erlang-questions] Use of application environment Message-ID: <6c2563b20811241927t208e2d2dy27e710b61e6ca897@mail.gmail.com> Hi all, Is it considered bad practice to use application environment variables (i.e. application:get_env/2,3) in workers, as opposed to only passing config information via the start()/init() calls? I am finding it tedious as I add more configuration data to the sys.config file, to get_env() the data in a supervisor and then parcel it out to the workers. Also, it becomes a pain to change the values at runtime, whereas if I put a function like this in an affected worker my_foo_val() -> application:get_env(my_app, my_foo_val, ?SOME_SANE_DEFAULT). then runtime changes can be made immediately using set_env(), and it becomes much easier to add new config data, but I feel uneasy, almost as if I'm using global variables. From a load point of view, I only do this in places where the value is not used at a high rate. What is the preferred or recommended (or even most common) practice? Regards, Edwin Fine -------------- next part -------------- An HTML attachment was scrubbed... URL: From kdronnqvist@REDACTED Tue Nov 25 09:56:33 2008 From: kdronnqvist@REDACTED (=?ISO-8859-1?Q?Daniel_R=F6nnqvist?=) Date: Tue, 25 Nov 2008 09:56:33 +0100 Subject: [erlang-questions] Erlang elseif In-Reply-To: <4CA10F5D-BA37-4952-AA59-4A63DC6632ED@cs.otago.ac.nz> References: <65691fa00811200041yfc7a219y97a11126e0cee535@mail.gmail.com> <78FFE0EB-DF1E-41E9-A802-A66B4F8066AF@cs.otago.ac.nz> <65691fa00811202337w57f3f329m244abaa055f6fae8@mail.gmail.com> <4CA10F5D-BA37-4952-AA59-4A63DC6632ED@cs.otago.ac.nz> Message-ID: <65691fa00811250056x23d69561mcb0a91d17a4d8fea@mail.gmail.com> I mistakely sent my last answer privately, here it goes again (with additions): Richard, I understand and to a great extent agree with your will to stay in the functional language domain and don't adapt to much other paradigms. All I'm saying is that theoretically it can be inefficient to have to run _all_ tests (expressions), tag the results and then pattern match on this tag, especially when the tests take a long time. This seem to me to be one of the two general thoughts on how to do it the Erlang-way. The other one with pattern matching but that's sometimes not an option, or at least it takes a lot more code (I.E your example in a previous post). One last thing; how am I refusing to discuss "a key reason why the present (or rather, the pre-Great Blunder) state of affairs is a Good Thing." by not wanting to use full blown application as an example? Maybe you misunderstood me, what I wanted to know with my question was if there's a way to do this (elseif) in Erlang in a syntactically short and easy way without getting nested expressions. The simple answer seems to be no, and you and others have given me examples on holve to solve it the Erlang way. I appreciate this and I feel I gotten an answer to my question. I ran some benchmarks on the examples I provided with lists of 30 elements and there was no consistent efficiency winner in any of my examples but it seemed that elseif1 (andalso & orelse) and the elseif5 (using exceptions) was the slowest. I know micro-benchmarks is close to completely useless but I just couldn't help myself. BR, Daniel R?nnqvist 2008/11/24 Richard O'Keefe > > On 21 Nov 2008, at 8:37 pm, Daniel R?nnqvist wrote: > > I am merely trying to figure out why this simple logical control structure >> don't exist; >> >> If == true then >> elseif then >> else >> > > Because Erlang does not have a Boolean data type. > > No, seriously. > > Erlang was and is based firmly on > - function call > - case > Originally, type tests and comparisons were guards only, > not expressions. They did not return 'true' or 'false', > so there never were any expressions that _could_ be used > to control 'if' expressions. > > 'if' was introduced as an abbreviation for a 'case' > with trivial matching. > > Then the Great Blunder occurred: the type tests and comparisons > were duplicated, and as well as the guard versions there were > expression versions, returning 'true' and 'false'. This was > compounded by the addition of far too many operators, both > 'and' *and* 'andalso', both 'or' *and* 'orelse'. > > This immediately created pressure to make Erlang stop being > Erlang and turn it into something else. In particular, some > people want to allow arbitrary expressions as guards (with all > the questions that raises about "what sense does it make to > have a side effect that happened in a clause that wasn't selected") > and that would have as a consequence that 'if' would be much > closer to what you want. > >> >> >> I know I can get lots and lots of good ideas on how to do this if I were >> to give you my whole real example but that is not my point. I am narrowing >> it down to this because THIS is what I want to discuss. >> > > But you are now refusing to discuss a key reason why the > present (or rather, the pre-Great Blunder) state of affairs > is a Good Thing. > > It's not just "good ideas" you might get if we saw a real example, > it's BETTER ideas than using a C-like 'if'. > >> >> >> IMHO, it shouldn't be that hard for the compiler/precompiler to "rewrite" >> another control structure as nested case statements which would work as a >> general solution, be very fast with less and arguably more readable code. >> > > There is no reason to expect it to be 'very fast' compared with 'case'. > Any situation that was faster as an 'if' than as a 'case' would > count as a performance bug in the compilation of 'case'. > > "Arguably more readable code" evades the question of "readable to whom?" > I don't know any reason why coding using C-like 'if' should be > more readable to proficient Erlang programmers than other ways of > writing the same thing. Past experience leads me strongly to doubt it. > > > Note that I am not saying that C-like if is bad. > Partly, I suppose that I am saying that insisting that everything > be like everything else is no way to explore and learn and maybe > learn better. > > The situation post Great Blunder is unstable. > Having nibbled at the 'logical expression' forbidden fruit, > Erlang should either vomit it out or gulp down the whole > poisoned apple. > > For the micro-Erlang design I'm playing with, I chose the > "vomit it out" route. Back to the future. Less is more. > It's amazing how little 'logical expressions' are missed if > you seriously try to think without them. > > For real Erlang/OTP, backwards compatibility puts backwards > pointing spikes on the poisoned apple; it's hard to vomit it > out without ripping out your throat. Erlang/OTP may have to > gulp down the _whole_ thing and just hope that people don't > do silly things, like CAML and SML. -------------- next part -------------- An HTML attachment was scrubbed... URL: From wde@REDACTED Tue Nov 25 10:40:11 2008 From: wde@REDACTED (wde@REDACTED) Date: Tue, 25 Nov 2008 10:40:11 +0100 Subject: [erlang-questions] Use of application environment Message-ID: <200811250940.mAP9ervA014244@morgoth.cslab.ericsson.net> Hello, I asked myself the same question. I read the source code of the application_controller module, the get_env function use access to the local ETS table "ac_tab". >From a performance point of view, I don't think that it's a problem. wde Hi all, Is it considered bad practice to use application environment variables (i.e. application:get_env/2,3) in workers, as opposed to only passing config information via the start()/init() calls? I am finding it tedious as I add more configuration data to the sys.config file, to get_env() the data in a supervisor and then parcel it out to the workers. Also, it becomes a pain to change the values at runtime, whereas if I put a function like this in an affected worker my_foo_val() -> application:get_env(my_app, my_foo_val, ?SOME_SANE_DEFAULT). then runtime changes can be made immediately using set_env(), and it becomes much easier to add new config data, but I feel uneasy, almost as if I'm using global variables. From a load point of view, I only do this in places where the value is not used at a high rate. What is the preferred or recommended (or even most common) practice? Regards, Edwin Fine -------------- next part -------------- An HTML attachment was scrubbed... URL: From mazen.harake@REDACTED Tue Nov 25 10:57:21 2008 From: mazen.harake@REDACTED (Mazen Harake) Date: Tue, 25 Nov 2008 11:57:21 +0200 Subject: [erlang-questions] Use of application environment In-Reply-To: <492BA39D.7070107@erlang-consulting.com> References: <6c2563b20811241927t208e2d2dy27e710b61e6ca897@mail.gmail.com> <492BA39D.7070107@erlang-consulting.com> Message-ID: <492BCC01.60805@erlang-consulting.com> Resending... /Mazen Mazen Harake wrote: > Personally I think in terms of isolation and how long the worker is > going to live. > > If the worker is short lived and doesn't depend on that the app env is > the same in several places... then I tend to use application:get_env. > If the worker is a more heavy worker and depends on more rigid values > then I tend to copy the configuration to the state so that I can > control when a good time to update it is.. > > Magically updating all the workers is not always a good thing... and > yes, applicationg:get_env is the same as using global variables. > > /Mazen > > Edwin Fine wrote: >> Hi all, >> >> Is it considered bad practice to use application environment >> variables (i.e. application:get_env/2,3) in workers, as opposed to >> only passing config information via the start()/init() calls? I am >> finding it tedious as I add more configuration data to the sys.config >> file, to get_env() the data in a supervisor and then parcel it out to >> the workers. Also, it becomes a pain to change the values at runtime, >> whereas if I put a function like this in an affected worker >> >> my_foo_val() -> >> application:get_env(my_app, my_foo_val, ?SOME_SANE_DEFAULT). >> >> then runtime changes can be made immediately using set_env(), and it >> becomes much easier to add new config data, but I feel uneasy, almost >> as if I'm using global variables. From a load point of view, I only >> do this in places where the value is not used at a high rate. >> >> What is the preferred or recommended (or even most common) practice? >> >> Regards, >> Edwin Fine >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions > > From mrad-direct-erlang@REDACTED Tue Nov 25 19:29:07 2008 From: mrad-direct-erlang@REDACTED (Michael Radford) Date: Tue, 25 Nov 2008 10:29:07 -0800 Subject: [erlang-questions] Use of application environment In-Reply-To: <6c2563b20811241927t208e2d2dy27e710b61e6ca897@mail.gmail.com> References: <6c2563b20811241927t208e2d2dy27e710b61e6ca897@mail.gmail.com> Message-ID: <20081125182907.GA17403@herbie> A related question.... This is an issue that often makes me resort to stopping and starting my applictions on upgrade, even when it should be easy to avoid. It seems that release_handler:eval_appup_script/4 first evaluates the upgrade script directives (reloads modules, calls code_change handlers, etc.), and then afterward changes the application configuration and calls config_change. Perhaps there's a good reason for this order. But in any case, this means that if you add a new application environment variable controlling some new behavior of a server, it won't be available when the server's code_change hander is called. So the obvious way of doing things (in code_change, read the value of the new variable and use it to transform the state) will crash. Is there an easy way to work around this? My only idea was to have code_change put the server into a temporary state where it's waiting for the application's config_change handler to be called, and then Application:config_change somehow knows about a list of gen_servers (etc.) to call with the new configuration. Maybe this could be handled generically by an extension to gen_server. It would be nice to be able to write code_change (OldVersion, EnvChanged, EnvNew, EnvRemoved, State, Extra) and do all the transformations in one place. Mike Edwin Fine writes: > Hi all, > > Is it considered bad practice to use application environment variables (i.e. > application:get_env/2,3) in workers, as opposed to only passing config > information via the start()/init() calls? I am finding it tedious as I add > more configuration data to the sys.config file, to get_env() the data in a > supervisor and then parcel it out to the workers. Also, it becomes a pain to > change the values at runtime, whereas if I put a function like this in an > affected worker > > my_foo_val() -> > application:get_env(my_app, my_foo_val, ?SOME_SANE_DEFAULT). > > then runtime changes can be made immediately using set_env(), and it becomes > much easier to add new config data, but I feel uneasy, almost as if I'm > using global variables. From a load point of view, I only do this in places > where the value is not used at a high rate. > > What is the preferred or recommended (or even most common) practice? > > Regards, > Edwin Fine From richardc@REDACTED Tue Nov 25 19:32:30 2008 From: richardc@REDACTED (Richard Carlsson) Date: Tue, 25 Nov 2008 19:32:30 +0100 Subject: [erlang-questions] How to force kernel application will always be started before my app In-Reply-To: <95be1d3b0811231019r756d5b94yf88db81f62647a29@mail.gmail.com> References: <3bff71aa0811230933m2737a234q3920b4a7d197b91c@mail.gmail.com> <95be1d3b0811231019r756d5b94yf88db81f62647a29@mail.gmail.com> Message-ID: <492C44BE.3060802@it.uu.se> Vlad Dumitrescu wrote: > > What I would like to have is a system-wide event source that would let > interested parties know when important events in the system take > place, like "kernel started", "code server started", "mnesia > started/stopped", but maybe also things like "node > connected/disconnected". This would mean that this service would need > to be started very early and other applications could register > themselves as event producers and/or listeners. > > Quite a large mechanism to put in place, but maybe it's interesting to consider? I recently discussed precisely such a thing with the OTP guys, and it seems like something that could be done for R13. The main work lies in listing the events important enough. (Presumably, it should be rather low-traffic things, so e.g. opening/closing files might be too much.) Do post your ideas. Here's my list so far: - system services (and mnesia) started/stopped - boot sequence completed - node connect/disconnect - module loaded - any info reported by erlang:system_monitor(), unless the user has redirected it to some other process - (remote)shell started/terminated /Richard From rec@REDACTED Tue Nov 25 20:15:15 2008 From: rec@REDACTED (Roger Critchlow) Date: Tue, 25 Nov 2008 12:15:15 -0700 Subject: [erlang-questions] How to force kernel application will always be started before my app In-Reply-To: <492C44BE.3060802@it.uu.se> References: <3bff71aa0811230933m2737a234q3920b4a7d197b91c@mail.gmail.com> <95be1d3b0811231019r756d5b94yf88db81f62647a29@mail.gmail.com> <492C44BE.3060802@it.uu.se> Message-ID: <66d1c98f0811251115w22c8fd14j3e1dc34d5e71be9f@mail.gmail.com> I'd think that: an event that fired when Module:Function/Arity was called an event that fired when Module:Function/Arity returned an event that fired when Module:Function/Arity was aborted by an exception would cover a lot of cases. -- rec -- On Tue, Nov 25, 2008 at 11:32 AM, Richard Carlsson wrote: > Vlad Dumitrescu wrote: > > > > What I would like to have is a system-wide event source that would let > > interested parties know when important events in the system take > > place, like "kernel started", "code server started", "mnesia > > started/stopped", but maybe also things like "node > > connected/disconnected". This would mean that this service would need > > to be started very early and other applications could register > > themselves as event producers and/or listeners. > > > > Quite a large mechanism to put in place, but maybe it's interesting to > consider? > > I recently discussed precisely such a thing with the OTP guys, and it > seems like something that could be done for R13. The main work lies in > listing the events important enough. (Presumably, it should be rather > low-traffic things, so e.g. opening/closing files might be too much.) > > Do post your ideas. Here's my list so far: > > - system services (and mnesia) started/stopped > - boot sequence completed > - node connect/disconnect > - module loaded > - any info reported by erlang:system_monitor(), unless the > user has redirected it to some other process > - (remote)shell started/terminated > > /Richard > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From richardc@REDACTED Tue Nov 25 20:34:47 2008 From: richardc@REDACTED (Richard Carlsson) Date: Tue, 25 Nov 2008 20:34:47 +0100 Subject: [erlang-questions] How to force kernel application will always be started before my app In-Reply-To: <66d1c98f0811251115w22c8fd14j3e1dc34d5e71be9f@mail.gmail.com> References: <3bff71aa0811230933m2737a234q3920b4a7d197b91c@mail.gmail.com> <95be1d3b0811231019r756d5b94yf88db81f62647a29@mail.gmail.com> <492C44BE.3060802@it.uu.se> <66d1c98f0811251115w22c8fd14j3e1dc34d5e71be9f@mail.gmail.com> Message-ID: <492C5357.30408@it.uu.se> Roger Critchlow wrote: > I'd think that: > > an event that fired when Module:Function/Arity was called > an event that fired when Module:Function/Arity returned > an event that fired when Module:Function/Arity was aborted by an > exception > > would cover a lot of cases. That's the sort of thing tracing is for. What we're talking about would be a gen_event server that publishes relatively rarely occurring events. /Richard From taavi@REDACTED Tue Nov 25 21:09:01 2008 From: taavi@REDACTED (Taavi Talvik) Date: Tue, 25 Nov 2008 22:09:01 +0200 Subject: [erlang-questions] How to force kernel application will always be started before my app In-Reply-To: <66d1c98f0811251115w22c8fd14j3e1dc34d5e71be9f@mail.gmail.com> References: <3bff71aa0811230933m2737a234q3920b4a7d197b91c@mail.gmail.com> <95be1d3b0811231019r756d5b94yf88db81f62647a29@mail.gmail.com> <492C44BE.3060802@it.uu.se> <66d1c98f0811251115w22c8fd14j3e1dc34d5e71be9f@mail.gmail.com> Message-ID: <9C69AB97-8FCC-4081-A68E-BAFEE17DD770@uninet.ee> On Nov 25, 2008, at 9:15 PM, Roger Critchlow wrote: > I'd think that: > > an event that fired when Module:Function/Arity was called > an event that fired when Module:Function/Arity returned > an event that fired when Module:Function/Arity was aborted by an > exception Hmm, thats supported by tracing tools. > - system services (and mnesia) started/stopped > - boot sequence completed > - node connect/disconnect > - module loaded > - any info reported by erlang:system_monitor(), unless the > user has redirected it to some other process > - (remote)shell started/terminated - application started/stopped/upgraded? - port opened-closed i.e. notification for controlling external components lifecycle? - erl_dll:monitor messages? best regards, taavi From masse@REDACTED Tue Nov 25 21:33:41 2008 From: masse@REDACTED (mats cronqvist) Date: Tue, 25 Nov 2008 21:33:41 +0100 Subject: [erlang-questions] How to force kernel application will always be started before my app In-Reply-To: <492C5357.30408@it.uu.se> (Richard Carlsson's message of "Tue\, 25 Nov 2008 20\:34\:47 +0100") References: <3bff71aa0811230933m2737a234q3920b4a7d197b91c@mail.gmail.com> <95be1d3b0811231019r756d5b94yf88db81f62647a29@mail.gmail.com> <492C44BE.3060802@it.uu.se> <66d1c98f0811251115w22c8fd14j3e1dc34d5e71be9f@mail.gmail.com> <492C5357.30408@it.uu.se> Message-ID: <87r64z35qy.fsf@sterlett.hq.kred> Richard Carlsson writes: > Roger Critchlow wrote: >> I'd think that: >> >> an event that fired when Module:Function/Arity was called >> an event that fired when Module:Function/Arity returned >> an event that fired when Module:Function/Arity was aborted by an >> exception >> >> would cover a lot of cases. > > That's the sort of thing tracing is for. i.e. erlang:trace and erlang:trace_pattern. > What we're talking about would be a gen_event server that publishes > relatively rarely occurring events. enhancing erlang:system_monitor/2 might be a better solution. mats From richardc@REDACTED Tue Nov 25 22:10:06 2008 From: richardc@REDACTED (Richard Carlsson) Date: Tue, 25 Nov 2008 22:10:06 +0100 Subject: [erlang-questions] How to force kernel application will always be started before my app In-Reply-To: <87r64z35qy.fsf@sterlett.hq.kred> References: <3bff71aa0811230933m2737a234q3920b4a7d197b91c@mail.gmail.com> <95be1d3b0811231019r756d5b94yf88db81f62647a29@mail.gmail.com> <492C44BE.3060802@it.uu.se> <66d1c98f0811251115w22c8fd14j3e1dc34d5e71be9f@mail.gmail.com> <492C5357.30408@it.uu.se> <87r64z35qy.fsf@sterlett.hq.kred> Message-ID: <492C69AE.30409@it.uu.se> mats cronqvist wrote: > Richard Carlsson writes: >> What we're talking about would be a gen_event server that publishes >> relatively rarely occurring events. > > enhancing erlang:system_monitor/2 might be a better solution. I don't think it has the right structure for that. It is very much tied to the runtime system internals, so it will be hard (and rather unnatural) to publish software events like server start/stop through it. Likewise, it would be hard to extend its functionality so that it behaves like a gen_event server with multiple subscribers that come and go. (And it might even cause so much traffic that I'm not quite sure its events should be broadcast through our hypothetical system event server. Perhaps a subset of them?) /Richard From vladdu55@REDACTED Tue Nov 25 22:34:12 2008 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Tue, 25 Nov 2008 22:34:12 +0100 Subject: [erlang-questions] How to force kernel application will always be started before my app In-Reply-To: <492C69AE.30409@it.uu.se> References: <3bff71aa0811230933m2737a234q3920b4a7d197b91c@mail.gmail.com> <95be1d3b0811231019r756d5b94yf88db81f62647a29@mail.gmail.com> <492C44BE.3060802@it.uu.se> <66d1c98f0811251115w22c8fd14j3e1dc34d5e71be9f@mail.gmail.com> <492C5357.30408@it.uu.se> <87r64z35qy.fsf@sterlett.hq.kred> <492C69AE.30409@it.uu.se> Message-ID: <95be1d3b0811251334u77479018j76835f8fbfae63d8@mail.gmail.com> On Tue, Nov 25, 2008 at 22:10, Richard Carlsson wrote: > mats cronqvist wrote: >> Richard Carlsson writes: >>> What we're talking about would be a gen_event server that publishes >>> relatively rarely occurring events. >> >> enhancing erlang:system_monitor/2 might be a better solution. > > I don't think it has the right structure for that. It is very > much tied to the runtime system internals, so it will be hard > (and rather unnatural) to publish software events like server > start/stop through it. Likewise, it would be hard to extend its > functionality so that it behaves like a gen_event server with > multiple subscribers that come and go. (And it might even cause > so much traffic that I'm not quite sure its events should be > broadcast through our hypothetical system event server. Perhaps > a subset of them?) It feels like Mats is right and system_monitor could be a single API for all these notifications. Whether the implementation asks the runtime or sends the request to some server, that is a detail of no interest for the users. I think it's easier to have a single place where one has to look. It would be confusing to have to keep track that interest in event X has to be registered by calling function M1:F1, while event Y is accessed via M2:F2 and so on. We could even have an API for anyone to register their own event sources, so that the framework is all generic and system_monitor becomes just a dispatcher. best regards, Vlad From ok@REDACTED Tue Nov 25 23:23:40 2008 From: ok@REDACTED (Richard O'Keefe) Date: Wed, 26 Nov 2008 11:23:40 +1300 Subject: [erlang-questions] Erlang elseif In-Reply-To: <65691fa00811250056x23d69561mcb0a91d17a4d8fea@mail.gmail.com> References: <65691fa00811200041yfc7a219y97a11126e0cee535@mail.gmail.com> <78FFE0EB-DF1E-41E9-A802-A66B4F8066AF@cs.otago.ac.nz> <65691fa00811202337w57f3f329m244abaa055f6fae8@mail.gmail.com> <4CA10F5D-BA37-4952-AA59-4A63DC6632ED@cs.otago.ac.nz> <65691fa00811250056x23d69561mcb0a91d17a4d8fea@mail.gmail.com> Message-ID: <336AC7F4-4A18-447D-A5BF-549A8D15CBA5@cs.otago.ac.nz> On 25 Nov 2008, at 9:56 pm, Daniel R?nnqvist wrote: > Richard, I understand and to a great extent agree with your will to > stay in the functional language domain and don't adapt to much other > paradigms. That's not exactly what my attitude/will is. I've forgotten who said "A language that doesn't change the way you think isn't worth learning", but there's a lot of wisdom in it. Can you hear the sound of panting? That's me trying (and failing) to keep up with how the typeful FP crowd think. Clean and Haskell 98 I can get my head around, but dependent types are starting to enter what passes for the mainstream in FP, and while I know perfectly well what they are, I don't yet know how to use them effectively. The only way will be to find some time and *try*. Constraint logic programming: I know *what* it is and to a moderate extent how it works, what I don't know yet is how to use it effectively. The only way to really get my head around it will be to spend some time trying on realistic problems *without* all the time trying to pretend CLP is something else. I'm an enthusiastic Smalltalker. My own Smalltalk compiler has finally reached the point where I can run tests (finding bug of course) and benchmarks (which look pretty good actually, despite doing no optimisation at all). The way to master Smalltalk was to try very hard to do things in a Smalltalk style, and not try to pretend it's C. When I was in the happy position of being able to get a free copy of GNAT for my el cheapo and long off the market but still working just fine thank you SunBlade 1000, I used Ada, and the way to do that effectively is to stop trying to think like a C or Pascal or Fortran programmer and try to think like an Ada programmer and make really effective use of its type system. I would love to spend some time playing with APL again, but Haskell gives me a surprisingly similar programming style if I want it. But it was APL that taught me about *calculating* programs. In short, it's *always* a good idea to try to work a language for all it's worth *on its own terms* before trying to make it like some other language. (As witness the serious mess that exceptions have made of Haskell's semantics. Many obvious natural and useful equalities aren't, thanks to exceptions.) > All I'm saying is that theoretically it can be inefficient to have > to run _all_ tests (expressions), tag the results and then pattern > match on this tag, especially when the tests take a long time. So what? I for one have never proposed anything even remotely like that and am not proposing it now. The point at issue is this: The *precise* equivalent (linear source code expansion ratio, linear object code expansion ratio, linear run time expansion ratio, same semantics up to when types are checked) of if E1 then E2 else E3 in say SML is case E1 of true -> E2 ; false -> E3 end in Erlang. That is, Erlang *HAS* if-expressions, they are just *spelled* 'case'. The only significant difference is thussyntactic style. Three magic tokens are replaced by eight. This is admittedly clumsy. However, in well written Erlang code it should also be rare, so it should not matter that much. > This seem to me to be one of the two general thoughts on how to do > it the Erlang-way. The other one with pattern matching but that's > sometimes not an option, or at least it takes a lot more code (I.E > your example in a previous post). But "if-is-case" is done with pattern matching, so anything that can be done with "if _ then _ else _" in Algol 60 or SML or "_ ? _ : _" in C can be done with pattern matching in Erlang and so pattern matching is *always* an option. I have provided several examples. I cannot tell which you are referring to. > > > One last thing; how am I refusing to discuss "a key reason why the > present (or rather, the pre-Great Blunder) state of affairs is a > Good Thing." by not wanting to use full blown application as an > example? Because the question at issue is whether the (more apparent than real) lack of an analogue of if _ then _ else _ in Erlang is a good thing or a bad thing. If it stops people writing good code, it is a bad thing. If it encourages them to write better code, it is a good thing. The only way to tell is to try real examples where someone *thinks* that if _ then _ else would be appropriate. If we can readily find better code without it, then Erlang does not have a problem. By the way, nobody has asked for a "full blown application", only for *some* real code. In the absence of real code, all the debate amounts to is X. I think Erlang needs to be like C. Y. I don't. Stalemate. With a real example, we can make progress. > Maybe you misunderstood me, what I wanted to know with my question > was if there's a way to do this (elseif) in Erlang in a > syntactically short and easy way without getting nested expressions. You have two issues here: brevity and nesting. Brevity matters for frequent things, and in Erlang, this should not be a frequent problem. There's an important reason why it shouldn't be a frequent problem. Since not very long after Pascal came out, books and articles about how to be a good programmer started saying "DO NOT OVERUSE Boolean". Classic examples go something like this: function switch(S: SwitchNumber): Boolean; If switch(17) is true, does that mean switch 17 is on, or that it is off? Better to do type SwitchStatus = (Off, On); function switch(S: SwitchNumber): SwitchStatus; and then instead of if switch(17) then begin ... end else begin ... end do case switch(17) of On: ...; Off: ...; end The character classification example was a textbook instance of this design antipattern. Instead of a bunch of Boolean tests is_restricted_upper(C) -> true | false is_restricted_lower(C) -> true | false is_restricted_digit(C) -> true | false there should be a single classification function restricted_character_class(C) -> upper | lower | digit | other I repeat, this is a classic antipattern going back over 30 years. So much for the brevity of what should be rare. Now to nesting. Algol 60 (but not Algol 68), C, C++, Java, Haskell, Clean, and SML all require nested expressions if you want more than one 'if' in an expression. Let's just take determining the sign of an integer. Algol 60 if x < 0 then -1 else (if x > 0 then 1 else 0) Algol 68 if x < 0 then -1 elif x > 0 then 1 else 0 fi or (x < 0 | -1 |: x > 0 | 1 | 0) BCPL x < 0 -> -1, (x > 0 -> 1, 0) C x < 0 ? -1 : (x > 0 ? 1 : 0) Clean if (x < 0) -1 (if (x > 0) 1 0) Haskell if x < 0 then -1 else (if x > 0 then 1 else 0) Erlang case x < 0 of true -> -1 ; false -> case x > 0 of true -> 1 ; false -> 0 end end Lisp (if (< x 0) -1 (if (> x 0) 1 0)) or (cond ((< x 0) -1) ((> x 0) 1) (T 0)) The parentheses in the Algol 60, BCPL, C, and Haskell examples are there to point out that the expressions are in fact nested, you don't really need them. All other parentheses are required. Does it really matter that much that only Algol 68 and Lisp in this list off non-nested multi-armed if (cond)? Why? Again, how-to-be-a-good-programmer textbooks have been warning for decades that complex ifs are probably wrong. > > I ran some benchmarks on the examples I provided with lists of 30 > elements and there was no consistent efficiency winner in any of my > examples but it seemed that elseif1 (andalso & orelse) and the > elseif5 (using exceptions) was the slowest. I know micro-benchmarks > is close to completely useless but I just couldn't help myself. No, micro-benchmarks can tell you useful things. I'm not surprised by the exception handling approach coming last. I will say that on today's machines lists of 30 elements are probably far too short to get useful timings from, unless you are using hardware performance counters. From masse@REDACTED Wed Nov 26 00:06:58 2008 From: masse@REDACTED (mats cronqvist) Date: Wed, 26 Nov 2008 00:06:58 +0100 Subject: [erlang-questions] How to force kernel application will always be started before my app In-Reply-To: <95be1d3b0811251334u77479018j76835f8fbfae63d8@mail.gmail.com> (Vlad Dumitrescu's message of "Tue\, 25 Nov 2008 22\:34\:12 +0100") References: <3bff71aa0811230933m2737a234q3920b4a7d197b91c@mail.gmail.com> <95be1d3b0811231019r756d5b94yf88db81f62647a29@mail.gmail.com> <492C44BE.3060802@it.uu.se> <66d1c98f0811251115w22c8fd14j3e1dc34d5e71be9f@mail.gmail.com> <492C5357.30408@it.uu.se> <87r64z35qy.fsf@sterlett.hq.kred> <492C69AE.30409@it.uu.se> <95be1d3b0811251334u77479018j76835f8fbfae63d8@mail.gmail.com> Message-ID: <87myfn2ynh.fsf@sterlett.hq.kred> "Vlad Dumitrescu" writes: > On Tue, Nov 25, 2008 at 22:10, Richard Carlsson wrote: >> mats cronqvist wrote: >>> Richard Carlsson writes: >>>> What we're talking about would be a gen_event server that publishes >>>> relatively rarely occurring events. >>> >>> enhancing erlang:system_monitor/2 might be a better solution. >> >> I don't think it has the right structure for that. It is very >> much tied to the runtime system internals, so it will be hard >> (and rather unnatural) to publish software events like server >> start/stop through it. Likewise, it would be hard to extend its >> functionality so that it behaves like a gen_event server with >> multiple subscribers that come and go. (And it might even cause >> so much traffic that I'm not quite sure its events should be >> broadcast through our hypothetical system event server. Perhaps >> a subset of them?) > > It feels like Mats is right and system_monitor could be a single API > for all these notifications. perhaps an event server on top of system_monitor could do the trick? mats From Matthew_Williams@REDACTED Wed Nov 26 01:58:21 2008 From: Matthew_Williams@REDACTED (Matthew Williams) Date: Wed, 26 Nov 2008 00:58:21 -0000 Subject: [erlang-questions] Erlang introspection Message-ID: <7DB4D15C3409994FAADAB909FA63B6BDE6C431@XY01EX22.xy01.xyratex.com> I'm trying to find information about erlangs support for introspection. I've got a program that receives and function name and arguments through a socket and I'd like to use this information to make a function call on the module that receives it. Can anyone suggest a good starting point for finding out how to do this? Thanks Matt ______________________________________________________________________ This email may contain privileged or confidential information, which should only be used for the purpose for which it was sent by Xyratex. No further rights or licenses are granted to use such information. If you are not the intended recipient of this message, please notify the sender by return and delete it. You may not use, copy, disclose or rely on the information contained in it. Internet email is susceptible to data corruption, interception and unauthorised amendment for which Xyratex does not accept liability. While we have taken reasonable precautions to ensure that this email is free of viruses, Xyratex does not accept liability for the presence of any computer viruses in this email, nor for any losses caused as a result of viruses. Xyratex Technology Limited (03134912), Registered in England & Wales, Registered Office, Langstone Road, Havant, Hampshire, PO9 1SA. The Xyratex group of companies also includes, Xyratex Ltd, registered in Bermuda, Xyratex International Inc, registered in California, Xyratex (Malaysia) Sdn Bhd registered in Malaysia, Xyratex Technology (Wuxi) Co Ltd registered in The People's Republic of China and Xyratex Japan Limited registered in Japan. ______________________________________________________________________ -------------- next part -------------- An HTML attachment was scrubbed... URL: From pablo.polvorin@REDACTED Wed Nov 26 02:30:03 2008 From: pablo.polvorin@REDACTED (Pablo Polvorin) Date: Tue, 25 Nov 2008 23:30:03 -0200 Subject: [erlang-questions] Erlang introspection In-Reply-To: <7DB4D15C3409994FAADAB909FA63B6BDE6C431@XY01EX22.xy01.xyratex.com> References: <7DB4D15C3409994FAADAB909FA63B6BDE6C431@XY01EX22.xy01.xyratex.com> Message-ID: <1ffe809c0811251730s1c6ea850v17ed7efeb5b65604@mail.gmail.com> Hi, a simple example should be enough to get you started: Eshell V5.6.4 (abort with ^G) 1> M = string. string 2> F = to_lower. to_lower 3> R1 = apply(M,F,["HelLo"]). "hello" 4> R2 = M:F("HelLo"). "hello" 5> 2008/11/25 Matthew Williams : > I'm trying to find information about erlangs support for introspection. I've > got a program that receives and function name and arguments through a socket > and I'd like to use this information to make a function call on the module > that receives it. Can anyone suggest a good starting point for finding out > how to do this? > > Thanks > > Matt > ______________________________________________________________________ > This email may contain privileged or confidential information, which should > only be used for the purpose for which it was sent by Xyratex. No further > rights or licenses are granted to use such information. If you are not the > intended recipient of this message, please notify the sender by return and > delete it. You may not use, copy, disclose or rely on the information > contained in it. > > Internet email is susceptible to data corruption, interception and > unauthorised amendment for which Xyratex does not accept liability. While we > have taken reasonable precautions to ensure that this email is free of > viruses, Xyratex does not accept liability for the presence of any computer > viruses in this email, nor for any losses caused as a result of viruses. > > Xyratex Technology Limited (03134912), Registered in England & Wales, > Registered Office, Langstone Road, Havant, Hampshire, PO9 1SA. > > The Xyratex group of companies also includes, Xyratex Ltd, registered in > Bermuda, Xyratex International Inc, registered in California, Xyratex > (Malaysia) Sdn Bhd registered in Malaysia, Xyratex Technology (Wuxi) Co Ltd > registered in The People's Republic of China and Xyratex Japan Limited > registered in Japan. > ______________________________________________________________________ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From ok@REDACTED Wed Nov 26 02:31:55 2008 From: ok@REDACTED (Richard O'Keefe) Date: Wed, 26 Nov 2008 14:31:55 +1300 Subject: [erlang-questions] Erlang introspection In-Reply-To: <7DB4D15C3409994FAADAB909FA63B6BDE6C431@XY01EX22.xy01.xyratex.com> References: <7DB4D15C3409994FAADAB909FA63B6BDE6C431@XY01EX22.xy01.xyratex.com> Message-ID: On 26 Nov 2008, at 1:58 pm, Matthew Williams wrote: > I'm trying to find information about erlangs support for > introspection. I've got a program that receives and function name > and arguments through a socket and I'd like to use this information > to make a function call on the module that receives it. Can anyone > suggest a good starting point for finding out how to do this? Joe Armstrong's book. And then look up apply/3. But also, ask yourself "in an era where the majority of e-mail is spam, malware abounds, and antivirus software on the most popular operating system is never quite good enough, do I ***REALLY*** want to let some other guy call anything he wants to, or do I want to put in some kind of checks?" From stondage123@REDACTED Wed Nov 26 02:46:43 2008 From: stondage123@REDACTED (Andrew Stone) Date: Tue, 25 Nov 2008 17:46:43 -0800 (PST) Subject: [erlang-questions] Erlang introspection References: <7DB4D15C3409994FAADAB909FA63B6BDE6C431@XY01EX22.xy01.xyratex.com> Message-ID: <122090.31789.qm@web35901.mail.mud.yahoo.com> If both sides are erlang you can send the actual fun(), otherwise, on the receiving end you can do list_to_atom on the function name and then call the function with the arguments. For instance you could do something like this. you've received a string "fun_name", with arguments A, B, C. Func = list_to_atom("fun_name"), Func(A,B,C). Of course you need the actual function to exist and the parameters to be valid. And IMHO, you also really don't want to be doing stuff like this over a network unless you are VERY careful. -Andrew ________________________________ From: Matthew Williams To: erlang-questions@REDACTED Sent: Tuesday, November 25, 2008 7:58:21 PM Subject: [erlang-questions] Erlang introspection I'm trying to find information about erlangs support for introspection. I've got a program that receives and function name and arguments through a socket and I'd like to use this information to make a function call on the module that receives it. Can anyone suggest a good starting point for finding out how to do this? Thanks Matt ______________________________________________________________________ This email may contain privileged or confidential information, which should only be used for the purpose for which it was sent by Xyratex. No further rights or licenses are granted to use such information. If you are not the intended recipient of this message, please notify the sender by return and delete it. You may not use, copy, disclose or rely on the information contained in it. Internet email is susceptible to data corruption, interception and unauthorised amendment for which Xyratex does not accept liability. While we have taken reasonable precautions to ensure that this email is free of viruses, Xyratex does not accept liability for the presence of any computer viruses in this email, nor for any losses caused as a result of viruses. Xyratex Technology Limited (03134912), Registered in England & Wales, Registered Office, Langstone Road, Havant, Hampshire, PO9 1SA. The Xyratex group of companies also includes, Xyratex Ltd, registered in Bermuda, Xyratex International Inc, registered in California, Xyratex (Malaysia) Sdn Bhd registered in Malaysia, Xyratex Technology (Wuxi) Co Ltd registered in The People's Republic of China and Xyratex Japan Limited registered in Japan. ______________________________________________________________________ -------------- next part -------------- An HTML attachment was scrubbed... URL: From nexes300@REDACTED Wed Nov 26 04:33:14 2008 From: nexes300@REDACTED (Charles Ahn) Date: Tue, 25 Nov 2008 19:33:14 -0800 Subject: [erlang-questions] Erlang introspection In-Reply-To: <122090.31789.qm@web35901.mail.mud.yahoo.com> References: <7DB4D15C3409994FAADAB909FA63B6BDE6C431@XY01EX22.xy01.xyratex.com> <122090.31789.qm@web35901.mail.mud.yahoo.com> Message-ID: <83260F19-D2FE-45EB-91A3-A286F771A9B7@gmail.com> Isn't there also a problem about memory use in this case? Because atoms are never garbage collected, if this service runs too long you could completely run out of memory as people try all kinds of weird function names. Furthermore, you can get around having exactly 3 arguments by passing the arguments in a list to apply. Charles On Nov 25, 2008, at 5:46 PM, Andrew Stone wrote: > If both sides are erlang you can send the actual fun(), otherwise, > on the receiving end you can do list_to_atom on the function name > and then call the function with the arguments. For instance you > could do something like this. > > you've received a string "fun_name", with arguments A, B, C. > > Func = list_to_atom("fun_name"), > Func(A,B,C). > > Of course you need the actual function to exist and the parameters > to be valid. And IMHO, you also really don't want to be doing stuff > like this over a network unless you are VERY careful. > > -Andrew > > From: Matthew Williams > To: erlang-questions@REDACTED > Sent: Tuesday, November 25, 2008 7:58:21 PM > Subject: [erlang-questions] Erlang introspection > > I'm trying to find information about erlangs support for > introspection. I've got a program that receives and function name > and arguments through a socket and I'd like to use this information > to make a function call on the module that receives it. Can anyone > suggest a good starting point for finding out how to do this? > > Thanks > > Matt > > ______________________________________________________________________ > This email may contain privileged or confidential information, which > should only be used for the purpose for which it was sent by > Xyratex. No further rights or licenses are granted to use such > information. If you are not the intended recipient of this message, > please notify the sender by return and delete it. You may not use, > copy, disclose or rely on the information contained in it. > > Internet email is susceptible to data corruption, interception and > unauthorised amendment for which Xyratex does not accept liability. > While we have taken reasonable precautions to ensure that this email > is free of viruses, Xyratex does not accept liability for the > presence of any computer viruses in this email, nor for any losses > caused as a result of viruses. > > Xyratex Technology Limited (03134912), Registered in England & > Wales, Registered Office, Langstone Road, Havant, Hampshire, PO9 1SA. > > The Xyratex group of companies also includes, Xyratex Ltd, > registered in Bermuda, Xyratex International Inc, registered in > California, Xyratex (Malaysia) Sdn Bhd registered in Malaysia, > Xyratex Technology (Wuxi) Co Ltd registered in The People's Republic > of China and Xyratex Japan Limited registered in Japan. > ______________________________________________________________________ > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From chsu79@REDACTED Wed Nov 26 08:21:44 2008 From: chsu79@REDACTED (Christian) Date: Wed, 26 Nov 2008 08:21:44 +0100 Subject: [erlang-questions] Erlang introspection In-Reply-To: <83260F19-D2FE-45EB-91A3-A286F771A9B7@gmail.com> References: <7DB4D15C3409994FAADAB909FA63B6BDE6C431@XY01EX22.xy01.xyratex.com> <122090.31789.qm@web35901.mail.mud.yahoo.com> <83260F19-D2FE-45EB-91A3-A286F771A9B7@gmail.com> Message-ID: 2008/11/26 Charles Ahn : > Isn't there also a problem about memory use in this case? Because atoms are > never garbage collected, if this service runs too long you could completely > run out of memory as people try all kinds of weird function names. Isnt that the least of problems if you have malicious users able to call arbitrary functions in your node? From jesper@REDACTED Wed Nov 26 08:58:57 2008 From: jesper@REDACTED (Jesper Eskilson) Date: Wed, 26 Nov 2008 08:58:57 +0100 Subject: [erlang-questions] Erlang performance on Windows In-Reply-To: <492B22DA.4050508@cs.ntua.gr> References: <492B22DA.4050508@cs.ntua.gr> Message-ID: On Mon, Nov 24, 2008 at 10:55 PM, Kostis Sagonas wrote: > >>> In summary, HiPE (native code generation) is great, if you use it with >>> care you can get outstanding performance. >>> You don't need HiPE in order to get good or competitive performance with >>> Erlang. >> >> I'll run the corresponding program on my Linux-box and see what kind >> of performance difference we're really talking about. > > I would be interested to see the numbers. Especially since on that box you > can factor out any possible "Windows surprises" and quantify the performance > improvements that native code compilation provides for you. Well, here's a surprise I was not expecting. I tried running a slightly optimized (thanks to Richard C) version of my sieve-function on my laptop with hipe (Ubuntu 8.10 on a dual-core running at 2.2GHz) and compared it with my workstation (XP on a quad-core running at 2.4GHz), i.e. without hipe, and hipe did not give any speedup at all. The total runtime was lower on the Windows box (1700 msecs vs. 1900 msecs on the linux machine), but then it does run at a higher clock frequency. Yet again benchmarking proves to be an area where you should never assume *anything*. (BTW: is there a way to switch off hipe? I couldn't find anything in the erl man-page.) -- /Jesper (a little wiser) From kdronnqvist@REDACTED Wed Nov 26 09:07:27 2008 From: kdronnqvist@REDACTED (=?ISO-8859-1?Q?Daniel_R=F6nnqvist?=) Date: Wed, 26 Nov 2008 09:07:27 +0100 Subject: [erlang-questions] Erlang elseif In-Reply-To: <336AC7F4-4A18-447D-A5BF-549A8D15CBA5@cs.otago.ac.nz> References: <65691fa00811200041yfc7a219y97a11126e0cee535@mail.gmail.com> <78FFE0EB-DF1E-41E9-A802-A66B4F8066AF@cs.otago.ac.nz> <65691fa00811202337w57f3f329m244abaa055f6fae8@mail.gmail.com> <4CA10F5D-BA37-4952-AA59-4A63DC6632ED@cs.otago.ac.nz> <65691fa00811250056x23d69561mcb0a91d17a4d8fea@mail.gmail.com> <336AC7F4-4A18-447D-A5BF-549A8D15CBA5@cs.otago.ac.nz> Message-ID: <65691fa00811260007m1ac279dxf73c68676057cd7f@mail.gmail.com> To make it short; I don't want Erlang to be like C, it seems you got so tangled up in your own agenda so I don't think you care anymore what I am talking about. What I would like is Erlang to be able to do what it does with nested cases in a better and non-nested syntax, like the proposed "cond" that Jay is talking about. Then the programmer could decide for them selfs if they want to use it or not. BR, Daniel 2008/11/25 Richard O'Keefe > > On 25 Nov 2008, at 9:56 pm, Daniel R?nnqvist wrote: > >> Richard, I understand and to a great extent agree with your will to stay >> in the functional language domain and don't adapt to much other paradigms. >> > > That's not exactly what my attitude/will is. > I've forgotten who said "A language that doesn't change the way you > think isn't worth learning", but there's a lot of wisdom in it. > > Can you hear the sound of panting? That's me trying (and failing) > to keep up with how the typeful FP crowd think. Clean and Haskell 98 > I can get my head around, but dependent types are starting to enter > what passes for the mainstream in FP, and while I know perfectly well > what they are, I don't yet know how to use them effectively. The only > way will be to find some time and *try*. > > Constraint logic programming: I know *what* it is and to a moderate > extent how it works, what I don't know yet is how to use it effectively. > The only way to really get my head around it will be to spend some time > trying on realistic problems *without* all the time trying to pretend > CLP is something else. > > I'm an enthusiastic Smalltalker. My own Smalltalk compiler has > finally reached the point where I can run tests (finding bug of course) > and benchmarks (which look pretty good actually, despite doing no > optimisation at all). The way to master Smalltalk was to try very > hard to do things in a Smalltalk style, and not try to pretend it's C. > > When I was in the happy position of being able to get a free copy > of GNAT for my el cheapo and long off the market but still working > just fine thank you SunBlade 1000, I used Ada, and the way to do > that effectively is to stop trying to think like a C or Pascal or > Fortran programmer and try to think like an Ada programmer and make > really effective use of its type system. > > I would love to spend some time playing with APL again, but Haskell > gives me a surprisingly similar programming style if I want it. But > it was APL that taught me about *calculating* programs. > > In short, it's *always* a good idea to try to work a language for > all it's worth *on its own terms* before trying to make it like some > other language. (As witness the serious mess that exceptions have > made of Haskell's semantics. Many obvious natural and useful > equalities aren't, thanks to exceptions.) > > All I'm saying is that theoretically it can be inefficient to have to run >> _all_ tests (expressions), tag the results and then pattern match on this >> tag, especially when the tests take a long time. >> > > So what? I for one have never proposed anything even remotely like > that and am not proposing it now. > > The point at issue is this: > The *precise* equivalent (linear source code expansion ratio, > linear object code expansion ratio, linear run time expansion > ratio, same semantics up to when types are checked) of > if E1 then E2 else E3 > in say SML is > case E1 of true -> E2 ; false -> E3 end > in Erlang. > > That is, Erlang *HAS* if-expressions, they are just *spelled* 'case'. > The only significant difference is thussyntactic style. > Three magic tokens are replaced by eight. > This is admittedly clumsy. > However, in well written Erlang code it should also be rare, > so it should not matter that much. > > This seem to me to be one of the two general thoughts on how to do it the >> Erlang-way. The other one with pattern matching but that's sometimes not an >> option, or at least it takes a lot more code (I.E your example in a previous >> post). >> > > But "if-is-case" is done with pattern matching, so anything that > can be done with "if _ then _ else _" in Algol 60 or SML or "_ ? _ : _" > in C can be done with pattern matching in Erlang and so pattern > matching is *always* an option. > > I have provided several examples. I cannot tell which you are > referring to. > >> >> >> One last thing; how am I refusing to discuss "a key reason why the present >> (or rather, the pre-Great Blunder) state of affairs is a Good Thing." by not >> wanting to use full blown application as an example? >> > > Because the question at issue is whether the (more apparent than real) > lack of an analogue of if _ then _ else _ in Erlang is a good thing or > a bad thing. If it stops people writing good code, it is a bad thing. > If it encourages them to write better code, it is a good thing. The > only way to tell is to try real examples where someone *thinks* that > if _ then _ else would be appropriate. If we can readily find better > code without it, then Erlang does not have a problem. > > By the way, nobody has asked for a "full blown application", > only for *some* real code. In the absence of real code, all the > debate amounts to is > X. I think Erlang needs to be like C. > Y. I don't. > Stalemate. With a real example, we can make progress. > > > Maybe you misunderstood me, what I wanted to know with my question was if >> there's a way to do this (elseif) in Erlang in a syntactically short and >> easy way without getting nested expressions. >> > > You have two issues here: brevity and nesting. > Brevity matters for frequent things, and in Erlang, this should > not be a frequent problem. > > There's an important reason why it shouldn't be a frequent problem. > Since not very long after Pascal came out, books and articles about > how to be a good programmer started saying "DO NOT OVERUSE Boolean". > Classic examples go something like this: > > function switch(S: SwitchNumber): Boolean; > > If switch(17) is true, does that mean switch 17 is on, or that it is off? > Better to do > > type SwitchStatus = (Off, On); > function switch(S: SwitchNumber): SwitchStatus; > > and then instead of > > if switch(17) then begin > ... > end else begin > ... > end > > do > case switch(17) of > On: ...; > Off: ...; > end > > The character classification example was a textbook instance of this > design antipattern. Instead of a bunch of Boolean tests > is_restricted_upper(C) -> true | false > is_restricted_lower(C) -> true | false > is_restricted_digit(C) -> true | false > there should be a single classification function > restricted_character_class(C) -> upper | lower | digit | other > > I repeat, this is a classic antipattern going back over 30 years. > > So much for the brevity of what should be rare. > Now to nesting. > > Algol 60 (but not Algol 68), C, C++, Java, Haskell, Clean, and SML > all require nested expressions if you want more than one 'if' in > an expression. Let's just take determining the sign of an integer. > > Algol 60 if x < 0 then -1 else (if x > 0 then 1 else 0) > Algol 68 if x < 0 then -1 elif x > 0 then 1 else 0 fi > or (x < 0 | -1 |: x > 0 | 1 | 0) > BCPL x < 0 -> -1, (x > 0 -> 1, 0) > C x < 0 ? -1 : (x > 0 ? 1 : 0) > Clean if (x < 0) -1 (if (x > 0) 1 0) > Haskell if x < 0 then -1 else (if x > 0 then 1 else 0) > Erlang case x < 0 of true -> -1 ; false -> > case x > 0 of true -> 1 ; false -> 0 end end > Lisp (if (< x 0) -1 (if (> x 0) 1 0)) > or (cond ((< x 0) -1) ((> x 0) 1) (T 0)) > > The parentheses in the Algol 60, BCPL, C, and Haskell examples > are there to point out that the expressions are in fact nested, > you don't really need them. All other parentheses are required. > Does it really matter that much that only Algol 68 and Lisp in > this list off non-nested multi-armed if (cond)? Why? > > Again, how-to-be-a-good-programmer textbooks have been warning > for decades that complex ifs are probably wrong. > >> >> I ran some benchmarks on the examples I provided with lists of 30 elements >> and there was no consistent efficiency winner in any of my examples but it >> seemed that elseif1 (andalso & orelse) and the elseif5 (using exceptions) >> was the slowest. I know micro-benchmarks is close to completely useless but >> I just couldn't help myself. >> > > No, micro-benchmarks can tell you useful things. > I'm not surprised by the exception handling approach coming last. > > I will say that on today's machines lists of 30 elements are probably > far too short to get useful timings from, unless you are using hardware > performance counters. > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From richardc@REDACTED Wed Nov 26 09:31:15 2008 From: richardc@REDACTED (Richard Carlsson) Date: Wed, 26 Nov 2008 09:31:15 +0100 Subject: [erlang-questions] Erlang performance on Windows In-Reply-To: References: <492B22DA.4050508@cs.ntua.gr> Message-ID: <492D0953.20209@it.uu.se> Jesper Eskilson wrote: > Well, here's a surprise I was not expecting. I tried running a > slightly optimized (thanks to Richard C) version of my sieve-function > on my laptop with hipe (Ubuntu 8.10 on a dual-core running at 2.2GHz) > and compared it with my workstation (XP on a quad-core running at > 2.4GHz), i.e. without hipe, and hipe did not give any speedup at all. > The total runtime was lower on the Windows box (1700 msecs vs. 1900 > msecs on the linux machine), but then it does run at a higher clock > frequency. Did you also native-compile the array module? (I would guess not.) Since your program is spending significantly more of its time in array.erl than in your own module, you'd not see any real speedup from native-compiling only yours. (You'll have to "unstick" the stdlib directory, or at least the array module itself, to be able to recompile it.) > (BTW: is there a way to switch off hipe? I couldn't find anything in > the erl man-page.) If you don't provide a 'native' flag to the compiler, HiPE does not affect your performance either way, but the system can be configured to be built without HiPE-support. (The config script enables HiPE by default on supported platforms.) /Richard From matthias@REDACTED Wed Nov 26 11:08:17 2008 From: matthias@REDACTED (Matthias Lang) Date: Wed, 26 Nov 2008 11:08:17 +0100 Subject: [erlang-questions] Erlang introspection In-Reply-To: <83260F19-D2FE-45EB-91A3-A286F771A9B7@gmail.com> References: <7DB4D15C3409994FAADAB909FA63B6BDE6C431@XY01EX22.xy01.xyratex.com> <122090.31789.qm@web35901.mail.mud.yahoo.com> <83260F19-D2FE-45EB-91A3-A286F771A9B7@gmail.com> Message-ID: <20081126100817.GA3683@contorpis.lisalinda.com> On Tuesday, November 25, Charles Ahn wrote: > Isn't there also a problem about memory use in this case? Because atoms > are never garbage collected, if this service runs too long you could > completely run out of memory as people try all kinds of weird function > names. You can address that specific problem by using list_to_existing_atom/1 instead of list_to_atom/1. But there are so many such problems that you can't plug them one at a time. E.g. you can prevent people from calling os:cmd("rm -rf *") and you can also block lists:duplicate(9999999999999, 1), but there'll always be one more nasty case. (E.g. lists:seq, which not only eats RAM, but also has a last element which raises some people's blood pressure to dangerous levels) So you need to do something general. There's some (old) academic work on that, in the form of 'safe erlang' and Ulf Wiger presented some newer work in a similar direction at the 2006 EUC (http://erlhive.sourceforge.net/). A practical and general way to deal with the out-of-memory problem is to use the OS to limit memory the Erlang VM can grab and then use something, perhaps another Erlang VM, to restart the VM whenever it dies. Dumb and robust. Matt From mazen.harake@REDACTED Wed Nov 26 11:15:01 2008 From: mazen.harake@REDACTED (Mazen Harake) Date: Wed, 26 Nov 2008 12:15:01 +0200 Subject: [erlang-questions] Erlang introspection In-Reply-To: References: <7DB4D15C3409994FAADAB909FA63B6BDE6C431@XY01EX22.xy01.xyratex.com> <122090.31789.qm@web35901.mail.mud.yahoo.com> <83260F19-D2FE-45EB-91A3-A286F771A9B7@gmail.com> Message-ID: <492D21A5.6010405@erlang-consulting.com> Hint: Use a wildcard-kind-of whitelist which accepts M:F/N... Example: string:*/* OR short version: string or perhaps: *:module_info/* ... Whitelisting seems easy, configuring it may be a little harder :D /M Christian wrote: > 2008/11/26 Charles Ahn : > >> Isn't there also a problem about memory use in this case? Because atoms are >> never garbage collected, if this service runs too long you could completely >> run out of memory as people try all kinds of weird function names. >> > > Isnt that the least of problems if you have malicious users able to > call arbitrary functions in your node? > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From saleyn@REDACTED Wed Nov 26 14:08:09 2008 From: saleyn@REDACTED (Serge Aleynikov) Date: Wed, 26 Nov 2008 08:08:09 -0500 Subject: [erlang-questions] Additions to lists module Message-ID: <492D4A39.5050105@gmail.com> I'd like to propose addition of these two functions to the lists module. Very often I find the need for this functionality and feel that it belongs to the standard library. Serge %% @spec (List::list(), Ele) -> integer() %% @doc Returns the position of `Ele' in the `List'. 0 is returned %% when `Ele' is not found. %% @end pos(List, Ele) -> pos(List, Ele, 1). pos([Ele | Tail], Ele, Pos) -> Pos; pos([_ | Tail], Ele, Pos) -> pos(Tail, Ele, Pos+1); pos([], _Ele, _) -> 0. %% @spec (Pred, Acc, List::list()) -> Acc1 %% Pred = (Ele, Acc) -> Acc1 %% @doc A combination of foldl/3 and takewhile/2. Accumulate the result %% while the predicate function returns true. %% @end foldlwhile(Pred, Acc0, [H|T]) -> case Pred(H, Acc0) of {true, Acc} -> foldwhile(Fun, Acc, T); {false, Acc} -> Acc; end; foldlwhile(_Pred, Acc, []) -> Acc. From mazen.harake@REDACTED Wed Nov 26 14:18:05 2008 From: mazen.harake@REDACTED (Mazen Harake) Date: Wed, 26 Nov 2008 15:18:05 +0200 Subject: [erlang-questions] Additions to lists module In-Reply-To: <492D4A39.5050105@gmail.com> References: <492D4A39.5050105@gmail.com> Message-ID: <492D4C8D.801@erlang-consulting.com> What is the idea behind pos? Curious because I have never been in a situation where I need to know the actual position of an element since I always assume that the order in a list is always undefined. Perhaps I missed something... do you have a practical example? /M Serge Aleynikov wrote: > I'd like to propose addition of these two functions to the lists module. > Very often I find the need for this functionality and feel that it > belongs to the standard library. > > Serge > > > > %% @spec (List::list(), Ele) -> integer() > %% @doc Returns the position of `Ele' in the `List'. 0 is returned > %% when `Ele' is not found. > %% @end > pos(List, Ele) -> > pos(List, Ele, 1). > pos([Ele | Tail], Ele, Pos) -> > Pos; > pos([_ | Tail], Ele, Pos) -> > pos(Tail, Ele, Pos+1); > pos([], _Ele, _) -> > 0. > > %% @spec (Pred, Acc, List::list()) -> Acc1 > %% Pred = (Ele, Acc) -> Acc1 > %% @doc A combination of foldl/3 and takewhile/2. Accumulate the result > %% while the predicate function returns true. > %% @end > foldlwhile(Pred, Acc0, [H|T]) -> > case Pred(H, Acc0) of > {true, Acc} -> > foldwhile(Fun, Acc, T); > {false, Acc} -> > Acc; > end; > foldlwhile(_Pred, Acc, []) -> > Acc. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From saleyn@REDACTED Wed Nov 26 14:22:11 2008 From: saleyn@REDACTED (Serge Aleynikov) Date: Wed, 26 Nov 2008 08:22:11 -0500 Subject: [erlang-questions] Additions to lists module In-Reply-To: <492D4C8D.801@erlang-consulting.com> References: <492D4A39.5050105@gmail.com> <492D4C8D.801@erlang-consulting.com> Message-ID: <492D4D83.10202@gmail.com> Say you have a mnesia table with a structure being record_info(fields, myTable). The pos/2 function would help you find a position of a given field in the table. Mazen Harake wrote: > What is the idea behind pos? > > Curious because I have never been in a situation where I need to know > the actual position of an element since I always assume that the order > in a list is always undefined. Perhaps I missed something... do you have > a practical example? > > /M > > Serge Aleynikov wrote: >> I'd like to propose addition of these two functions to the lists >> module. Very often I find the need for this functionality and feel >> that it belongs to the standard library. >> >> Serge >> >> >> >> %% @spec (List::list(), Ele) -> integer() >> %% @doc Returns the position of `Ele' in the `List'. 0 is returned >> %% when `Ele' is not found. >> %% @end >> pos(List, Ele) -> >> pos(List, Ele, 1). >> pos([Ele | Tail], Ele, Pos) -> >> Pos; >> pos([_ | Tail], Ele, Pos) -> >> pos(Tail, Ele, Pos+1); >> pos([], _Ele, _) -> >> 0. >> >> %% @spec (Pred, Acc, List::list()) -> Acc1 >> %% Pred = (Ele, Acc) -> Acc1 >> %% @doc A combination of foldl/3 and takewhile/2. Accumulate the result >> %% while the predicate function returns true. >> %% @end >> foldlwhile(Pred, Acc0, [H|T]) -> >> case Pred(H, Acc0) of >> {true, Acc} -> >> foldwhile(Fun, Acc, T); >> {false, Acc} -> >> Acc; >> end; >> foldlwhile(_Pred, Acc, []) -> >> Acc. >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > From erlang@REDACTED Wed Nov 26 14:38:47 2008 From: erlang@REDACTED (Peter Lund) Date: Wed, 26 Nov 2008 14:38:47 +0100 Subject: [erlang-questions] Additions to lists module In-Reply-To: <492D4A39.5050105@gmail.com> References: <492D4A39.5050105@gmail.com> Message-ID: <492D5167.6050208@lundata.se> 1> string:str([x,y,s,my_arbitrary_erlang_term], [my_arbitrary_erlang_term]). 4 2> Serge Aleynikov skrev: > I'd like to propose addition of these two functions to the lists module. > Very often I find the need for this functionality and feel that it > belongs to the standard library. > > Serge > > > > %% @spec (List::list(), Ele) -> integer() > %% @doc Returns the position of `Ele' in the `List'. 0 is returned > %% when `Ele' is not found. > %% @end > pos(List, Ele) -> > pos(List, Ele, 1). > pos([Ele | Tail], Ele, Pos) -> > Pos; > pos([_ | Tail], Ele, Pos) -> > pos(Tail, Ele, Pos+1); > pos([], _Ele, _) -> > 0. > > %% @spec (Pred, Acc, List::list()) -> Acc1 > %% Pred = (Ele, Acc) -> Acc1 > %% @doc A combination of foldl/3 and takewhile/2. Accumulate the result > %% while the predicate function returns true. > %% @end > foldlwhile(Pred, Acc0, [H|T]) -> > case Pred(H, Acc0) of > {true, Acc} -> > foldwhile(Fun, Acc, T); > {false, Acc} -> > Acc; > end; > foldlwhile(_Pred, Acc, []) -> > Acc. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > From gleber.p@REDACTED Wed Nov 26 14:46:27 2008 From: gleber.p@REDACTED (Gleb Peregud) Date: Wed, 26 Nov 2008 14:46:27 +0100 Subject: [erlang-questions] Additions to lists module In-Reply-To: <492D4D83.10202@gmail.com> References: <492D4A39.5050105@gmail.com> <492D4C8D.801@erlang-consulting.com> <492D4D83.10202@gmail.com> Message-ID: <14f0e3620811260546y5bbc6a49o9618e00849ac645e@mail.gmail.com> Hi, Isn't #myTable.field_name enough to determine the position of the field in record's tuple? Have I understood this correctly? BR On 11/26/08, Serge Aleynikov wrote: > Say you have a mnesia table with a structure being record_info(fields, > myTable). The pos/2 function would help you find a position of a given > field in the table. > > Mazen Harake wrote: >> What is the idea behind pos? >> >> Curious because I have never been in a situation where I need to know >> the actual position of an element since I always assume that the order >> in a list is always undefined. Perhaps I missed something... do you have >> a practical example? >> >> /M >> >> Serge Aleynikov wrote: >>> I'd like to propose addition of these two functions to the lists >>> module. Very often I find the need for this functionality and feel >>> that it belongs to the standard library. >>> >>> Serge >>> >>> >>> >>> %% @spec (List::list(), Ele) -> integer() >>> %% @doc Returns the position of `Ele' in the `List'. 0 is returned >>> %% when `Ele' is not found. >>> %% @end >>> pos(List, Ele) -> >>> pos(List, Ele, 1). >>> pos([Ele | Tail], Ele, Pos) -> >>> Pos; >>> pos([_ | Tail], Ele, Pos) -> >>> pos(Tail, Ele, Pos+1); >>> pos([], _Ele, _) -> >>> 0. >>> >>> %% @spec (Pred, Acc, List::list()) -> Acc1 >>> %% Pred = (Ele, Acc) -> Acc1 >>> %% @doc A combination of foldl/3 and takewhile/2. Accumulate the result >>> %% while the predicate function returns true. >>> %% @end >>> foldlwhile(Pred, Acc0, [H|T]) -> >>> case Pred(H, Acc0) of >>> {true, Acc} -> >>> foldwhile(Fun, Acc, T); >>> {false, Acc} -> >>> Acc; >>> end; >>> foldlwhile(_Pred, Acc, []) -> >>> Acc. >>> _______________________________________________ >>> 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 > -- Gleb Peregud http://gleber.pl/ Every minute is to be grasped. Time waits for nobody. -- Inscription on a Zen Gong From saleyn@REDACTED Wed Nov 26 14:30:19 2008 From: saleyn@REDACTED (Serge Aleynikov) Date: Wed, 26 Nov 2008 08:30:19 -0500 Subject: [erlang-questions] Additions to lists module Message-ID: <492D4F6B.4090405@gmail.com> Fixed a typo in foldlwhile. %% @spec (List::list(), Ele) -> integer() %% @doc Returns the position of `Ele' in the `List'. 0 is returned %% when `Ele' is not found. %% @end pos(List, Ele) -> pos(List, Ele, 1). pos([Ele | Tail], Ele, Pos) -> Pos; pos([_ | Tail], Ele, Pos) -> pos(Tail, Ele, Pos+1); pos([], _Ele, _) -> 0. %% @spec (Pred, Acc, List::list()) -> Acc1 %% Pred = (Ele, Acc) -> {boolean(), Acc1} %% @doc A combination of foldl/3 and takewhile/2. Accumulate the result %% while the predicate function returns {true, _}. %% @end foldlwhile(Pred, Acc0, [H|T]) -> case Pred(H, Acc0) of {true, Acc} -> foldwhile(Pred, Acc, T); {false, Acc} -> Acc; end; foldlwhile(_Pred, Acc, []) -> Acc. From vladdu55@REDACTED Wed Nov 26 16:16:06 2008 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Wed, 26 Nov 2008 16:16:06 +0100 Subject: [erlang-questions] Dialyzer error Message-ID: <95be1d3b0811260716t67c7c0f2s6b12311fbabc5852@mail.gmail.com> Hi! I'm trying to use the latest dialyzer to analyze the R11 code. It looks like it doesn't work, is there anything I can do or is it not supported? best regards, Vlad C:\Apps\erlide>c:\apps\erl5.6.5\bin\dialyzer.exe --build_plt --plt std.plt -r c:\apps\erl5.5.5\lib\stdlib-1.14.5 c:\apps\erl5.5.5\lib\kernel-2.11.5 Creating PLT std.plt ... Analysis failed with error: Could not scan the following file(s): [{"c:/apps/erl5.5.5/lib/stdlib-1.14.5/ebin/io_lib_pretty.beam", " Could not get core for: c:/apps/erl5.5.5/lib/stdlib-1.14.5/ebin/io_lib_pretty.beam"}, {"c:/apps/erl5.5.5/lib/stdlib-1.14.5/ebin/io_lib.beam", " Could not get core for: c:/apps/erl5.5.5/lib/stdlib-1.14.5/ebin/io_lib.beam"}, {"c:/apps/erl5.5.5/lib/stdlib-1.14.5/ebin/eval_bits.beam", " Could not get core for: c:/apps/erl5.5.5/lib/stdlib-1.14.5/ebin/eval_bits.beam"}, {"c:/apps/erl5.5.5/lib/stdlib-1.14.5/ebin/ets.beam", " Could not get core for: c:/apps/erl5.5.5/lib/stdlib-1.14.5/ebin/ets.beam"}, {"c:/apps/erl5.5.5/lib/stdlib-1.14.5/ebin/erl_eval.beam", " Could not get core for: c:/apps/erl5.5.5/lib/stdlib-1.14.5/ebin/erl_eval.beam"}, {"c:/apps/erl5.5.5/lib/kernel-2.11.5/ebin/erlang.beam", " Could not get core for: c:/apps/erl5.5.5/lib/kernel-2.11.5/ebin/erlang.beam"}] Last messages in log cache: ["Reading files and computing callgraph... "] dialyzer: Internal problems were encountered in the analysis. From kostis@REDACTED Wed Nov 26 16:31:42 2008 From: kostis@REDACTED (Kostis Sagonas) Date: Wed, 26 Nov 2008 17:31:42 +0200 Subject: [erlang-questions] Dialyzer error In-Reply-To: <95be1d3b0811260716t67c7c0f2s6b12311fbabc5852@mail.gmail.com> References: <95be1d3b0811260716t67c7c0f2s6b12311fbabc5852@mail.gmail.com> Message-ID: <492D6BDE.1040809@cs.ntua.gr> Vlad Dumitrescu wrote: > Hi! > > I'm trying to use the latest dialyzer to analyze the R11 code. It > looks like it doesn't work, is there anything I can do or is it not > supported? It's not supported, but here is some support anyway ;-) > C:\Apps\erlide>c:\apps\erl5.6.5\bin\dialyzer.exe --build_plt --plt > std.plt -r c:\apps\erl5.5.5\lib\stdlib-1.14.5 > ... > Analysis failed with error: Could not scan the following file(s): > [{"c:/apps/erl5.5.5/lib/stdlib-1.14.5/ebin/io_lib_pretty.beam", > " Could not get core for: Looks like (though I might be wrong in this guess) that these .beam files do not contain debug_info in them. If that's the case, you need to re-create them with +debug_info and see what happens then. Kostis From exta7@REDACTED Wed Nov 26 17:18:43 2008 From: exta7@REDACTED (Zvi) Date: Wed, 26 Nov 2008 08:18:43 -0800 (PST) Subject: [erlang-questions] Additions to lists module In-Reply-To: <492D4A39.5050105@gmail.com> References: <492D4A39.5050105@gmail.com> Message-ID: <20704131.post@talk.nabble.com> Serge, I would call it "find_first" instead of "pos", with additional "find_last" and "find". find_first(L, E) -> pos(L, E). find_last(L, E) -> find_first(lists:reverse(L), E). % return indices of all list elements equal to E find(L), E -> find(L,E,1,[]). find([], _, _, A) -> lists:reverse(A); find([E|T], E, I, A) -> find(T, E, I+1, [I|A]); find([_|T], E, I, A) -> find(T, E, I+1, A). Zvi Serge Aleynikov-2 wrote: > > I'd like to propose addition of these two functions to the lists module. > Very often I find the need for this functionality and feel that it > belongs to the standard library. > > Serge > > > > %% @spec (List::list(), Ele) -> integer() > %% @doc Returns the position of `Ele' in the `List'. 0 is returned > %% when `Ele' is not found. > %% @end > pos(List, Ele) -> > pos(List, Ele, 1). > pos([Ele | Tail], Ele, Pos) -> > Pos; > pos([_ | Tail], Ele, Pos) -> > pos(Tail, Ele, Pos+1); > pos([], _Ele, _) -> > 0. > > %% @spec (Pred, Acc, List::list()) -> Acc1 > %% Pred = (Ele, Acc) -> Acc1 > %% @doc A combination of foldl/3 and takewhile/2. Accumulate the result > %% while the predicate function returns true. > %% @end > foldlwhile(Pred, Acc0, [H|T]) -> > case Pred(H, Acc0) of > {true, Acc} -> > foldwhile(Fun, Acc, T); > {false, Acc} -> > Acc; > end; > foldlwhile(_Pred, Acc, []) -> > Acc. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > -- View this message in context: http://www.nabble.com/Additions-to-lists-module-tp20700771p20704131.html Sent from the Erlang Questions mailing list archive at Nabble.com. From mlaster@REDACTED Wed Nov 26 17:50:09 2008 From: mlaster@REDACTED (Mike Laster) Date: Wed, 26 Nov 2008 08:50:09 -0800 Subject: [erlang-questions] LDAP server in Erlang? Message-ID: <28256e610811260850p3faf9930jdfa4ac30632ceeda@mail.gmail.com> Does anyone know of the existence of an LDAP server implemented in Erlang? I'm looking for a more scalable LDAP solution and it seems Erlang would be the ideal environment to implement one in. The only LDAP code that I have been able to find is eldap, which seems to only be an LDAP client. Thanks for any pointers, Mike -------------- next part -------------- An HTML attachment was scrubbed... URL: From jongretar@REDACTED Wed Nov 26 18:17:58 2008 From: jongretar@REDACTED (Jon Gretar Borgthorsson) Date: Wed, 26 Nov 2008 17:17:58 +0000 Subject: [erlang-questions] LDAP server in Erlang? In-Reply-To: <28256e610811260850p3faf9930jdfa4ac30632ceeda@mail.gmail.com> References: <28256e610811260850p3faf9930jdfa4ac30632ceeda@mail.gmail.com> Message-ID: <4ecde87b0811260917h93322f0m59916c9e6ffc2e4b@mail.gmail.com> No. ErlDir was supposed to include LDAP+DNS system but I think that is an abandoned project now. To my knowledge there is no other project out there. But there are some things available with the built in modules to ease the building of your own. As I understand it then the LDAP schemas are defined in ASN.1 which erlang has built in modules for. And LDAP is basically only a communication standard. 2008/11/26 Mike Laster : > Does anyone know of the existence of an LDAP server implemented in Erlang? > I'm looking for a more scalable LDAP solution and it seems Erlang would be > the ideal environment to implement one in. The only LDAP code that I have > been able to find is eldap, which seems to only be an LDAP client. > Thanks for any pointers, > Mike > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From n39052@REDACTED Wed Nov 26 21:45:11 2008 From: n39052@REDACTED (Sergey A.) Date: Wed, 26 Nov 2008 12:45:11 -0800 Subject: [erlang-questions] Why is setting socket options by setopts() better than by listen()? Message-ID: <3bff71aa0811261245r211c15eft979e7dbcefa68db9@mail.gmail.com> Hello. I've read the following in the "Programming Erlang": -------------------8<------------------- After we have accepted a connection, it's a good idea to explicitly set the required socket options, like this: {ok, Socket} = gen_tcp:accept(Listen), inet:setopts(Socket, [{packet,4},binary, {nodelay,true},{active, true}]), loop(Socket) -------------------8<------------------- And I have a small question. Why that is considered better solution than using the same options, but passed to gen_tcp:listen/2 function: gen_tcp:listen(2345, [{packet, 4}, binary, {nodelay, true}, {active, true}, {reuseaddr, true}]) As I know, all the sockets obtained by calling gen_tcp:accept/1 inherit options listed in gen_tcp:listen. Thanks. -- Sergey. From dave.smith.to@REDACTED Wed Nov 26 21:51:55 2008 From: dave.smith.to@REDACTED (Dave Smith) Date: Wed, 26 Nov 2008 15:51:55 -0500 Subject: [erlang-questions] Erlang elseif In-Reply-To: <65691fa00811260007m1ac279dxf73c68676057cd7f@mail.gmail.com> References: <65691fa00811200041yfc7a219y97a11126e0cee535@mail.gmail.com> <78FFE0EB-DF1E-41E9-A802-A66B4F8066AF@cs.otago.ac.nz> <65691fa00811202337w57f3f329m244abaa055f6fae8@mail.gmail.com> <4CA10F5D-BA37-4952-AA59-4A63DC6632ED@cs.otago.ac.nz> <65691fa00811250056x23d69561mcb0a91d17a4d8fea@mail.gmail.com> <336AC7F4-4A18-447D-A5BF-549A8D15CBA5@cs.otago.ac.nz> <65691fa00811260007m1ac279dxf73c68676057cd7f@mail.gmail.com> Message-ID: <5ea453f90811261251q69a3234dkd2380ae8d79d05e3@mail.gmail.com> 2008/11/26 Daniel R?nnqvist > To make it short; I don't want Erlang to be like C, it seems you got so > tangled up in your own agenda so I don't think you care anymore what I am > talking about. What I would like is Erlang to be able to do what it does > with nested cases in a better and non-nested syntax, like the proposed > "cond" that Jay is talking about. Then the programmer could decide for them > selfs if they want to use it or not. > > I don't like the argument "Then the programmer could decide for them selfs if they want to use it or not." Small concise languages are good; in general, the fewer constructs the better. This doesn't mean that I'm whole heartedly against a new conditional construct, but I just don't see myself using it a whole lot. Right now I use "case" quite a lot, and I find the vast majority of my conditions involve matching patterns. I use "if" rarely; only in cases where there is not pattern to match; for example, where I have a ranged comparison (X From dave.smith.to@REDACTED Wed Nov 26 22:29:20 2008 From: dave.smith.to@REDACTED (Dave Smith) Date: Wed, 26 Nov 2008 16:29:20 -0500 Subject: [erlang-questions] Erlang elseif In-Reply-To: <65691fa00811260007m1ac279dxf73c68676057cd7f@mail.gmail.com> References: <65691fa00811200041yfc7a219y97a11126e0cee535@mail.gmail.com> <78FFE0EB-DF1E-41E9-A802-A66B4F8066AF@cs.otago.ac.nz> <65691fa00811202337w57f3f329m244abaa055f6fae8@mail.gmail.com> <4CA10F5D-BA37-4952-AA59-4A63DC6632ED@cs.otago.ac.nz> <65691fa00811250056x23d69561mcb0a91d17a4d8fea@mail.gmail.com> <336AC7F4-4A18-447D-A5BF-549A8D15CBA5@cs.otago.ac.nz> <65691fa00811260007m1ac279dxf73c68676057cd7f@mail.gmail.com> Message-ID: <5ea453f90811261329x98a440fkcb2a1a82b7d2d3ae@mail.gmail.com> The other thing is that I don't understand what the proposal is. One post above states the the following would be identical. cond Test1 -> Result1; Test2 -> Result2; Test... -> Result...; true -> yay end case Test1 of true -> Result1; false -> case Test2 of true -> Result2; false -> case Test... of true -> Result... false -> yay end end end In the latter, each of the TestN conditions is a boolean expression; that is, it returns either the atom 'true' or the atom 'false', otherwise a bad match exception is thrown. In the proposed "cond" construct above, are the TestN expressions the same; the 'true' atom in the last conditions would suggest that this is the case. However, I saw an example in another post as follows: cond {ok, X} = f(Y) -> g(X); %% clause 1 true -> h(X) %% clause 2 end The expression {ok, X} = f(Y) does not evaluate to 'true' or 'false'; it evaluate to {ok, X}. And given the generalization above would be equivalent to be: case {ok, X} = f(Y) of true-> g(x); false-> h(x) end ... which would always result in a bad match exception. I'm assuming this example is erroneous. Perhaps what was meant was cond {ok, X} =:= f(Y) -> g(X); %% clause 1 true -> h(X) %% clause 2 end ... in which case X whould have to be bound prior to this expression being evaluated, otherwise an exception would be thrown. So perhaps someone could better explain the usage of this proposed 'cond' construct and give some examples. -------------- next part -------------- An HTML attachment was scrubbed... URL: From dave.smith.to@REDACTED Wed Nov 26 22:59:25 2008 From: dave.smith.to@REDACTED (Dave Smith) Date: Wed, 26 Nov 2008 16:59:25 -0500 Subject: [erlang-questions] Erlang elseif In-Reply-To: <5ea453f90811261329x98a440fkcb2a1a82b7d2d3ae@mail.gmail.com> References: <65691fa00811200041yfc7a219y97a11126e0cee535@mail.gmail.com> <78FFE0EB-DF1E-41E9-A802-A66B4F8066AF@cs.otago.ac.nz> <65691fa00811202337w57f3f329m244abaa055f6fae8@mail.gmail.com> <4CA10F5D-BA37-4952-AA59-4A63DC6632ED@cs.otago.ac.nz> <65691fa00811250056x23d69561mcb0a91d17a4d8fea@mail.gmail.com> <336AC7F4-4A18-447D-A5BF-549A8D15CBA5@cs.otago.ac.nz> <65691fa00811260007m1ac279dxf73c68676057cd7f@mail.gmail.com> <5ea453f90811261329x98a440fkcb2a1a82b7d2d3ae@mail.gmail.com> Message-ID: <5ea453f90811261359x6682dea8gb31faede39c30d4e@mail.gmail.com> 2008/11/26 Dave Smith > > > cond > {ok, X} =:= f(Y) -> g(X); > true -> h(X) > end > Again, this is exactly why I would like to avoid another conditional construct. People would do the above when the following would be appropriate: case f(Y) of {ok, X} -> g(X); _ -> h(X) %% X unbound ??? end -------------- next part -------------- An HTML attachment was scrubbed... URL: From dave.smith.to@REDACTED Thu Nov 27 00:17:36 2008 From: dave.smith.to@REDACTED (Dave Smith) Date: Wed, 26 Nov 2008 18:17:36 -0500 Subject: [erlang-questions] Additions to lists module In-Reply-To: <492D4C8D.801@erlang-consulting.com> References: <492D4A39.5050105@gmail.com> <492D4C8D.801@erlang-consulting.com> Message-ID: <5ea453f90811261517h63e55ac6i40d6f3217aa2da97@mail.gmail.com> 2008/11/26 Mazen Harake > What is the idea behind pos? > > Curious because I have never been in a situation where I need to know > the actual position of an element since I always assume that the order > in a list is always undefined. Perhaps I missed something... do you have > a practical example? > > /M > > I'm not following. Lists are ordered and in many cases order is meaningful. Otherwise you would never have reason to reverse a list. There are many functions in the lists module where the result is dependant on the lists order, and there is precedence for functions like foldlwhile; examples (takewhile/2, dropwhile/2, splitwith/2) -------------- next part -------------- An HTML attachment was scrubbed... URL: From dave.smith.to@REDACTED Thu Nov 27 00:31:11 2008 From: dave.smith.to@REDACTED (Dave Smith) Date: Wed, 26 Nov 2008 18:31:11 -0500 Subject: [erlang-questions] Additions to lists module In-Reply-To: <5ea453f90811261517h63e55ac6i40d6f3217aa2da97@mail.gmail.com> References: <492D4A39.5050105@gmail.com> <492D4C8D.801@erlang-consulting.com> <5ea453f90811261517h63e55ac6i40d6f3217aa2da97@mail.gmail.com> Message-ID: <5ea453f90811261531x2f60542cycaf98dedeea2e5ce@mail.gmail.com> But I do agree with you on the pos function. I don't think I would uses it. Presumably one would want to do something with the position after retrieving it, and this would probably mean using it in a function that traverses a list a second time. It would be more appropriate in a module like array. 2008/11/26 Dave Smith > > 2008/11/26 Mazen Harake > >> What is the idea behind pos? >> >> Curious because I have never been in a situation where I need to know >> the actual position of an element since I always assume that the order >> in a list is always undefined. Perhaps I missed something... do you have >> a practical example? >> >> /M >> >> > I'm not following. Lists are ordered and in many cases order is > meaningful. Otherwise you would never have reason to reverse a list. > > There are many functions in the lists module where the result is dependant > on the lists order, and there is precedence for functions like foldlwhile; > examples (takewhile/2, dropwhile/2, splitwith/2) > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From saleyn@REDACTED Thu Nov 27 00:33:41 2008 From: saleyn@REDACTED (Serge Aleynikov) Date: Wed, 26 Nov 2008 18:33:41 -0500 Subject: [erlang-questions] Additions to lists module In-Reply-To: <492D5167.6050208@lundata.se> References: <492D4A39.5050105@gmail.com> <492D5167.6050208@lundata.se> Message-ID: <492DDCD5.6060203@gmail.com> Don't you agree that this is a hack given documented definition of the function: str(String, SubString) -> Index rstr(String, SubString) -> Index Types: String = SubString = string() Serge Peter Lund wrote: > 1> string:str([x,y,s,my_arbitrary_erlang_term], > [my_arbitrary_erlang_term]). > 4 > 2> > > > Serge Aleynikov skrev: >> I'd like to propose addition of these two functions to the lists >> module. Very often I find the need for this functionality and feel >> that it belongs to the standard library. >> >> Serge >> >> >> >> %% @spec (List::list(), Ele) -> integer() >> %% @doc Returns the position of `Ele' in the `List'. 0 is returned >> %% when `Ele' is not found. >> %% @end >> pos(List, Ele) -> >> pos(List, Ele, 1). >> pos([Ele | Tail], Ele, Pos) -> >> Pos; >> pos([_ | Tail], Ele, Pos) -> >> pos(Tail, Ele, Pos+1); >> pos([], _Ele, _) -> >> 0. >> >> %% @spec (Pred, Acc, List::list()) -> Acc1 >> %% Pred = (Ele, Acc) -> Acc1 >> %% @doc A combination of foldl/3 and takewhile/2. Accumulate the result >> %% while the predicate function returns true. >> %% @end >> foldlwhile(Pred, Acc0, [H|T]) -> >> case Pred(H, Acc0) of >> {true, Acc} -> >> foldwhile(Fun, Acc, T); >> {false, Acc} -> >> Acc; >> end; >> foldlwhile(_Pred, Acc, []) -> >> Acc. >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> >> > > From saleyn@REDACTED Thu Nov 27 00:38:04 2008 From: saleyn@REDACTED (Serge Aleynikov) Date: Wed, 26 Nov 2008 18:38:04 -0500 Subject: [erlang-questions] Additions to lists module In-Reply-To: <14f0e3620811260546y5bbc6a49o9618e00849ac645e@mail.gmail.com> References: <492D4A39.5050105@gmail.com> <492D4C8D.801@erlang-consulting.com> <492D4D83.10202@gmail.com> <14f0e3620811260546y5bbc6a49o9618e00849ac645e@mail.gmail.com> Message-ID: <492DDDDC.6040002@gmail.com> That is if you know at compile time that the field your are interested in is #myTable.field_name. What if you need to get the value of the field X = 'field_name' in Table = myTable? Gleb Peregud wrote: > Hi, > > Isn't #myTable.field_name enough to determine the position of the > field in record's tuple? Have I understood this correctly? > > BR > > On 11/26/08, Serge Aleynikov wrote: >> Say you have a mnesia table with a structure being record_info(fields, >> myTable). The pos/2 function would help you find a position of a given >> field in the table. >> >> Mazen Harake wrote: >>> What is the idea behind pos? >>> >>> Curious because I have never been in a situation where I need to know >>> the actual position of an element since I always assume that the order >>> in a list is always undefined. Perhaps I missed something... do you have >>> a practical example? >>> >>> /M >>> >>> Serge Aleynikov wrote: >>>> I'd like to propose addition of these two functions to the lists >>>> module. Very often I find the need for this functionality and feel >>>> that it belongs to the standard library. >>>> >>>> Serge >>>> >>>> >>>> >>>> %% @spec (List::list(), Ele) -> integer() >>>> %% @doc Returns the position of `Ele' in the `List'. 0 is returned >>>> %% when `Ele' is not found. >>>> %% @end >>>> pos(List, Ele) -> >>>> pos(List, Ele, 1). >>>> pos([Ele | Tail], Ele, Pos) -> >>>> Pos; >>>> pos([_ | Tail], Ele, Pos) -> >>>> pos(Tail, Ele, Pos+1); >>>> pos([], _Ele, _) -> >>>> 0. >>>> >>>> %% @spec (Pred, Acc, List::list()) -> Acc1 >>>> %% Pred = (Ele, Acc) -> Acc1 >>>> %% @doc A combination of foldl/3 and takewhile/2. Accumulate the result >>>> %% while the predicate function returns true. >>>> %% @end >>>> foldlwhile(Pred, Acc0, [H|T]) -> >>>> case Pred(H, Acc0) of >>>> {true, Acc} -> >>>> foldwhile(Fun, Acc, T); >>>> {false, Acc} -> >>>> Acc; >>>> end; >>>> foldlwhile(_Pred, Acc, []) -> >>>> Acc. >>>> _______________________________________________ >>>> 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 erlangy@REDACTED Thu Nov 27 00:52:15 2008 From: erlangy@REDACTED (Michael McDaniel) Date: Wed, 26 Nov 2008 15:52:15 -0800 Subject: [erlang-questions] Additions to lists module In-Reply-To: <5ea453f90811261531x2f60542cycaf98dedeea2e5ce@mail.gmail.com> References: <492D4A39.5050105@gmail.com> <492D4C8D.801@erlang-consulting.com> <5ea453f90811261517h63e55ac6i40d6f3217aa2da97@mail.gmail.com> <5ea453f90811261531x2f60542cycaf98dedeea2e5ce@mail.gmail.com> Message-ID: <20081126235215.GG10121@delora.autosys.us> Everyone works on different kinds of problems and has their solutions. One immediate use I thought of follows. Note that html_tokenise is from Joe Armstrong's www_tools-1.0 on trapexit. {ok, H} = http:request("http://somewebsite.com") , Ht = html_tokenise:string2toks( element(3, H) ) , Pos = list_position:pos( Hal, {tagStart,"title"} ) , {_, Title} = lists:nth( Pos+1, Hal ). Likely there are other interesting items on a page for which I would have interest. ~Michael On Wed, Nov 26, 2008 at 06:31:11PM -0500, Dave Smith wrote: > But I do agree with you on the pos function. I don't think I would uses > it. Presumably one would want to do something with the position after > retrieving it, and this would probably mean using it in a function that > traverses a list a second time. > It would be more appropriate in a module like array. > > 2008/11/26 Dave Smith <[1]dave.smith.to@[2]gmail.com> > > 2008/11/26 Mazen Harake <[3]mazen.harake@REDACTED> > > What is the idea behind pos? > Curious because I have never been in a situation where I need to > know > the actual position of an element since I always assume that the > order > in a list is always undefined. Perhaps I missed something... do you > have > a practical example? > /M > > I'm not following. Lists are ordered and in many cases order is > meaningful. Otherwise you would never have reason to reverse a > list. > There are many functions in the lists module where the result is > dependant on the lists order, and there is precedence for functions > like foldlwhile; examples (takewhile/2, dropwhile/2, splitwith/2) > > References > > 1. http://dave.smith.to/ > 2. http://gmail.com/ > 3. mailto:mazen.harake@REDACTED > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- Michael McDaniel Portland, Oregon, USA http://autosys.us From erlangy@REDACTED Thu Nov 27 00:55:51 2008 From: erlangy@REDACTED (Michael McDaniel) Date: Wed, 26 Nov 2008 15:55:51 -0800 Subject: [erlang-questions] [correction] Re: Additions to lists module In-Reply-To: <20081126235215.GG10121@delora.autosys.us> References: <492D4A39.5050105@gmail.com> <492D4C8D.801@erlang-consulting.com> <5ea453f90811261517h63e55ac6i40d6f3217aa2da97@mail.gmail.com> <5ea453f90811261531x2f60542cycaf98dedeea2e5ce@mail.gmail.com> <20081126235215.GG10121@delora.autosys.us> Message-ID: <20081126235551.GH10121@delora.autosys.us> On Wed, Nov 26, 2008 at 03:52:15PM -0800, Michael McDaniel wrote: > > Everyone works on different kinds of problems and has their solutions. > One immediate use I thought of follows. > > Note that html_tokenise is from Joe Armstrong's www_tools-1.0 on trapexit. > > > {ok, H} = http:request("http://somewebsite.com") , > Ht = html_tokenise:string2toks( element(3, H) ) , > Pos = list_position:pos( Hal, {tagStart,"title"} ) , > > {_, Title} = lists:nth( Pos+1, Hal ). ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Pos = list_position:pos( Ht, {tagStart,"title"} ) , {_, Title} = lists:nth( Pos+1, Ht ). of course, should be Ht for these ~M > > Likely there are other interesting items on a page for which I > would have interest. > > > ~Michael > > > > On Wed, Nov 26, 2008 at 06:31:11PM -0500, Dave Smith wrote: > > But I do agree with you on the pos function. I don't think I would uses > > it. Presumably one would want to do something with the position after > > retrieving it, and this would probably mean using it in a function that > > traverses a list a second time. > > It would be more appropriate in a module like array. > > > > 2008/11/26 Dave Smith <[1]dave.smith.to@[2]gmail.com> > > > > 2008/11/26 Mazen Harake <[3]mazen.harake@REDACTED> > > > > What is the idea behind pos? > > Curious because I have never been in a situation where I need to > > know > > the actual position of an element since I always assume that the > > order > > in a list is always undefined. Perhaps I missed something... do you > > have > > a practical example? > > /M > > > > I'm not following. Lists are ordered and in many cases order is > > meaningful. Otherwise you would never have reason to reverse a > > list. > > There are many functions in the lists module where the result is > > dependant on the lists order, and there is precedence for functions > > like foldlwhile; examples (takewhile/2, dropwhile/2, splitwith/2) > > > > References > > > > 1. http://dave.smith.to/ > > 2. http://gmail.com/ > > 3. mailto:mazen.harake@REDACTED > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > -- > Michael McDaniel > Portland, Oregon, USA > http://autosys.us > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From saleyn@REDACTED Thu Nov 27 01:05:47 2008 From: saleyn@REDACTED (Serge Aleynikov) Date: Wed, 26 Nov 2008 19:05:47 -0500 Subject: [erlang-questions] [correction] Re: Additions to lists module In-Reply-To: <20081126235551.GH10121@delora.autosys.us> References: <492D4A39.5050105@gmail.com> <492D4C8D.801@erlang-consulting.com> <5ea453f90811261517h63e55ac6i40d6f3217aa2da97@mail.gmail.com> <5ea453f90811261531x2f60542cycaf98dedeea2e5ce@mail.gmail.com> <20081126235215.GG10121@delora.autosys.us> <20081126235551.GH10121@delora.autosys.us> Message-ID: <492DE45B.8040309@gmail.com> Actually for this problem lists:splitwith/2 would do a better job. Michael McDaniel wrote: > On Wed, Nov 26, 2008 at 03:52:15PM -0800, Michael McDaniel wrote: >> Everyone works on different kinds of problems and has their solutions. >> One immediate use I thought of follows. >> >> Note that html_tokenise is from Joe Armstrong's www_tools-1.0 on trapexit. >> >> >> {ok, H} = http:request("http://somewebsite.com") , >> Ht = html_tokenise:string2toks( element(3, H) ) , >> Pos = list_position:pos( Hal, {tagStart,"title"} ) , >> >> {_, Title} = lists:nth( Pos+1, Hal ). > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > > Pos = list_position:pos( Ht, {tagStart,"title"} ) , > {_, Title} = lists:nth( Pos+1, Ht ). > > > of course, should be Ht for these > > ~M > > >> Likely there are other interesting items on a page for which I >> would have interest. >> >> >> ~Michael >> >> >> >> On Wed, Nov 26, 2008 at 06:31:11PM -0500, Dave Smith wrote: >>> But I do agree with you on the pos function. I don't think I would uses >>> it. Presumably one would want to do something with the position after >>> retrieving it, and this would probably mean using it in a function that >>> traverses a list a second time. >>> It would be more appropriate in a module like array. >>> >>> 2008/11/26 Dave Smith <[1]dave.smith.to@[2]gmail.com> >>> >>> 2008/11/26 Mazen Harake <[3]mazen.harake@REDACTED> >>> >>> What is the idea behind pos? >>> Curious because I have never been in a situation where I need to >>> know >>> the actual position of an element since I always assume that the >>> order >>> in a list is always undefined. Perhaps I missed something... do you >>> have >>> a practical example? >>> /M >>> >>> I'm not following. Lists are ordered and in many cases order is >>> meaningful. Otherwise you would never have reason to reverse a >>> list. >>> There are many functions in the lists module where the result is >>> dependant on the lists order, and there is precedence for functions >>> like foldlwhile; examples (takewhile/2, dropwhile/2, splitwith/2) >>> >>> References >>> >>> 1. http://dave.smith.to/ >>> 2. http://gmail.com/ >>> 3. mailto:mazen.harake@REDACTED >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://www.erlang.org/mailman/listinfo/erlang-questions >> -- >> Michael McDaniel >> Portland, Oregon, USA >> http://autosys.us >> >> _______________________________________________ >> 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 ok@REDACTED Thu Nov 27 01:23:17 2008 From: ok@REDACTED (Richard O'Keefe) Date: Thu, 27 Nov 2008 13:23:17 +1300 Subject: [erlang-questions] Erlang elseif In-Reply-To: <65691fa00811260007m1ac279dxf73c68676057cd7f@mail.gmail.com> References: <65691fa00811200041yfc7a219y97a11126e0cee535@mail.gmail.com> <78FFE0EB-DF1E-41E9-A802-A66B4F8066AF@cs.otago.ac.nz> <65691fa00811202337w57f3f329m244abaa055f6fae8@mail.gmail.com> <4CA10F5D-BA37-4952-AA59-4A63DC6632ED@cs.otago.ac.nz> <65691fa00811250056x23d69561mcb0a91d17a4d8fea@mail.gmail.com> <336AC7F4-4A18-447D-A5BF-549A8D15CBA5@cs.otago.ac.nz> <65691fa00811260007m1ac279dxf73c68676057cd7f@mail.gmail.com> Message-ID: On 26 Nov 2008, at 9:07 pm, Daniel R?nnqvist wrote: > To make it short; I don't want Erlang to be like C, it seems you got > so tangled up in your own agenda so I don't think you care anymore > what I am talking about. What I would like is Erlang to be able to > do what it does with nested cases in a better and non-nested syntax, > like the proposed "cond" that Jay is talking about. Then the > programmer could decide for them selfs if they want to use it or not. Why is it that when people talk about other people's "agendas" it is always an insult? Of course I care what you are talking about; if I didn't, I would not have replied to it in detail, considering each of your points. Did you notice, or care, about my suggestion of an Algol 68-inspired "; or case" (modelled on Algol 68's "ouse" keyword) that you give you PRECISELY a non-nested syntax? That is far more capable than 'cond' because it is not restricted to Booleans. How does that fail to meet your needs? The continuing absence of a concrete case to discuss continues to render the argument for any new syntax dubious in the extreme. From ok@REDACTED Thu Nov 27 02:32:24 2008 From: ok@REDACTED (Richard O'Keefe) Date: Thu, 27 Nov 2008 14:32:24 +1300 Subject: [erlang-questions] Additions to lists module In-Reply-To: <492D4A39.5050105@gmail.com> References: <492D4A39.5050105@gmail.com> Message-ID: <0AF8FE8D-47DA-4C3E-8A79-99463D45986D@cs.otago.ac.nz> On 27 Nov 2008, at 2:08 am, Serge Aleynikov wrote: > I'd like to propose addition of these two functions to the lists > module. > Very often I find the need for this functionality and feel that it > belongs to the standard library. > > Serge > > > > %% @spec (List::list(), Ele) -> integer() > %% @doc Returns the position of `Ele' in the `List'. 0 is returned > %% when `Ele' is not found. > %% @end > pos(List, Ele) -> > pos(List, Ele, 1). > > pos([Ele | Tail], Ele, Pos) -> > Pos; > pos([_ | Tail], Ele, Pos) -> > pos(Tail, Ele, Pos+1); > pos([], _Ele, _) -> > 0. The main problem with this is its name; it's abbreviated to meaninglessness. If I may quote the Haskell List module: findIndex :: (a -> Bool) -> [a] -> Maybe Int elemIndex :: Eq a => a -> [a] -> Maybe Int Leaving aside the fact that Haskell uses 0 origin, the Erlang analogue would be find_index(P, Xs) -> find_index_loop(P, Xs, 1). find_index_loop(P, [X|Xs], Index) -> case P(X) of true -> Index ; false -> find_index_loop(P, Xs, Index + 1) end; find_index_loop(P, [], _) when is_function(P, 1) -> 0. elem_index(E, Xs) -> elem_index_loop(E, Xs, 1). elem_index_loop(E, [E|_], Index) -> Index; elem_index_loop(E, [_|Xs], Index) -> elem_index_loop(E, Xs, Index + 1); elem_index_loop(_, [], _) -> 0. This raises the question of what value should be returned when no element of the list satisfies the search criterion. 0 is a popular decision, going back to BASIC, but one that makes very little sense. The version that actually makes the most sense is length(Xs)+1, so that elem_index(E, Xs) -> find_index(fun (X) -> X =:= E end). find_index(P, Xs) -> 1 + length(drop_while(P, Xs)). because that makes reasoning about programs that use it noticeably freer of special cases. Returning something that isn't a number (my choice here would have been 'absent') has the advantage that failing to find something would be unlikely to go un-noticed. It's awkward with a type checker though. The only advantages of returning 0 seem to be "consistency with old fashioned BASIC" and "simplicity for the type checker". It makes reasoning about a program more awkward than it need be, and it makes it far too easy to fail to notice that something wasn't found. The Haskell versions *force* you to check whether something was found or not; I suppose the nearest Erlang analogue would be to return {present,Index} for something found and 'absent' for something not found. Summary: I recommend adopting/adapting the Haskell names, and there's a choice between Index|absent, Index|0, Index|length+1, {present,Index}|absent for the result. > > > %% @spec (Pred, Acc, List::list()) -> Acc1 > %% Pred = (Ele, Acc) -> Acc1 > %% @doc A combination of foldl/3 and takewhile/2. Accumulate the > result > %% while the predicate function returns true. > %% @end > foldlwhile(Pred, Acc0, [H|T]) -> > case Pred(H, Acc0) of > {true, Acc} -> > foldwhile(Fun, Acc, T); > {false, Acc} -> > Acc; > end; > foldlwhile(_Pred, Acc, []) -> > Acc. We would expect a combination of fold/3 and takewhile/2 to have the form foldl_while(Fun, Acc0, Pred, List) -> foldl(Fun, Acc0, takewhile(Pred, List)) or foldl_while(Fun, Acc0, Pred, [X|Xs]) -> case Pred(X) of true -> foldl_while(Fun, Fun(X, Acc0), Pred, Xs) ; false -> Acc0 end; foldl_while(Fun, Acc0, Pred, []) when is_function(Fun, 2), is_function(Pred, 1) -> Acc0. This is the kind of code that it's pointless to write in Haskell because the compiler will fuse the loops automagically. So there are two things about the name. The first one for me was that the "l" after the "d" was awfully hard to see. Separated_words_really_are_much_easier_to_read then runtogetherrunsofwordssuchasyouseebeforeyou. (My mail program likes them a lot more too. (:-) (:-)) The second one is that the name is a little misleading in that the parameters are not what you might expect them to be. This is, by the way, a *perfect* example of the Boolean antipattern I mentioned before. When you are writing the function, does 'true' mean 'keep going' or does it mean 'stop'? Here again the name of the function is confusing, because it _doesn't_ mean to keep on folding "while the predicate function returns true" because the function NEVER returns true. Something like foldl_prefix(Stepper, Acc0, [X|Xs]) -> case Stepper(X, Acc0) of {continue,Acc} -> foldl_prefix(Stepper, Acc, Xs) ; {stop,Result} -> Result end; foldl_prefix(S, Acc, []) when is_function(S, 2) -> Acc. which _does_ at least fold a prefix, might be less confusing. The function results are now completely unambiguous, there is no mention of any 'predicate' (because there is none), and while the name doesn't completely describe the function, everything it says is true. The Stepper function here is closer to being the Fun of a fold than the Pred of a takewhile. I'm sure someone else can think of a better name. I am rather concerned that the final value of a logically empty list (one for which it is not the case that the list has an element and the stepper function says to continue) has its result derived in two different ways: - if the list is physically empty ([]), Acc0 is the result - if the list is logically but not physically empty ([X|_]), Acc1 is the result where {stop,Acc1} = Stepper(X, Acc0). Somehow this just doesn't feel right. If you think about it, this is *really* a combination of foldl and an unfold. Recall that an unfold works with a function that takes a state and either says "we're at the end" or says "we are not at the end, here is an element and a new state". I very much like unfolder :: State -> [] | [Element|State] but some people do not. So let's take an unfolder to be unfolder :: State -> empty | {Element,State}. Now unfold is unfold(Unfolder, State) -> case Unfolder(State) of empty -> [] ; {Element,State1} -> [Element|unfold(Unfolder, State1)] end. Combine foldl and unfold. foldl_unfold(Fun, Acc0, Unfolder, State) -> case Unfolder(State) of empty -> Acc0 ; {Element,State1} -> foldl_unfold(Fun, Fun(Element,Acc0), Unfolder, State1) end. The interesting thing here is that nothing says that the State can't be a list in the first place. You can have while_unfolder(P) -> fun ([X|Xs]) -> case P(X) of true -> {X,Xs} ; false -> empty end ; ([]) -> empty end. Then foldl_while(Fun, Acc0, Pred, List) -> foldl_unfold(Fun, Acc0, while_unfolder(Pred), List) This suggests that combining things with unfold is strictly more powerful than combining them with takewhile, because the unfold version can do the takewhile version but not conversely. In particular, we can also do while_zip_unfolder(P) -> fun ({[X|Xs], [Y,Ys]}) -> case P(X, Y) of true -> {{X,Y}, {Xs,Ys}} ; false -> empty end ; (_) -> empty end. and combine takewhile with (lazy) zipping. The only limit here is our imagination. In Haskell, I'd have something like data Stepper a = Continue a | Stop a data Final a = Found a | Not_Found a foldl_prefix :: (x -> a -> Stepper a) -> a -> [x] -> Final a foldl_prefix _ a [] = Not_Found a foldl_prefix f a (x:xs) = case f x a of Continue a' -> foldl_prefix f a' xs Stop a' -> Found a' Something that *really* combines foldl and takewhile shouldn't be able to tell the difference between physical and logical end of list. So this just doesn't feel right yet. From ok@REDACTED Thu Nov 27 03:30:40 2008 From: ok@REDACTED (Richard O'Keefe) Date: Thu, 27 Nov 2008 15:30:40 +1300 Subject: [erlang-questions] Additions to lists module In-Reply-To: <20081126235215.GG10121@delora.autosys.us> References: <492D4A39.5050105@gmail.com> <492D4C8D.801@erlang-consulting.com> <5ea453f90811261517h63e55ac6i40d6f3217aa2da97@mail.gmail.com> <5ea453f90811261531x2f60542cycaf98dedeea2e5ce@mail.gmail.com> <20081126235215.GG10121@delora.autosys.us> Message-ID: On 27 Nov 2008, at 12:52 pm, Michael McDaniel wrote: > > Everyone works on different kinds of problems and has their solutions. > One immediate use I thought of follows. > > Note that html_tokenise is from Joe Armstrong's www_tools-1.0 on > trapexit. > > > {ok, H} = http:request("http://somewebsite.com") , > Ht = html_tokenise:string2toks( element(3, H) ) , > Pos = list_position:pos( Hal, {tagStart,"title"} ) , > > {_, Title} = lists:nth( Pos+1, Hal ). This is better as {_,Title} = lists:after({tagStart,"title"}, Hal) where after(X, [X,Y|_]) -> Y; after(X, [_|Ys]) -> after(X, Ys). which does the job in one pass. The *order* and *adjacency* of elements in a list often matters; the actual *positions* far less often. If we add before(X, [Y,X|_]) -> Y; before(X, [_|Ys]) -> before(X, Ys). then we've matched the #after: and #before: methods in ANSI Smalltalk's SequencedReadableCollection class. If we add after(X, [X,Y|_], _) -> Y; after(X, [_|Ys], D) -> after(X, Ys, D); after(_, [], D) -> D. before(X, [Y,X|_], _) -> Y; before(X, [_|Ys], D) -> before(X, Ys, D); before(_, [], D) -> D. then we've come close to matching the #after:ifAbsent: and #before:ifAbsent: methods (which actually take funs rather than default values). Even simpler than after would be to adapt Lisp's (MEMBER - -) function, and instead of returning false or true, return the empty list or the place where the match was found. (Funny how the Boolean anti-pattern keeps turning up, isn't it?) Define lmember(X, Xs = [X|_]) -> X; lmember(X, [_ | Xs]) -> lmember(X, Xs); lmember(_, []) -> []. Then [_,{_,Title}|_] = lmember({tagStart,"title"}, Hal) and if we wanted to pick up the next two elements it would be just as simple to do [_,{_,Title},Next|_] = lmember({tagStart,"title"}, Hal) From saleyn@REDACTED Thu Nov 27 04:08:18 2008 From: saleyn@REDACTED (Serge Aleynikov) Date: Wed, 26 Nov 2008 22:08:18 -0500 Subject: [erlang-questions] Additions to lists module In-Reply-To: <0AF8FE8D-47DA-4C3E-8A79-99463D45986D@cs.otago.ac.nz> References: <492D4A39.5050105@gmail.com> <0AF8FE8D-47DA-4C3E-8A79-99463D45986D@cs.otago.ac.nz> Message-ID: <492E0F22.6090800@gmail.com> Richard O'Keefe wrote: >> pos([Ele | Tail], Ele, Pos) -> >> Pos; >> pos([_ | Tail], Ele, Pos) -> >> pos(Tail, Ele, Pos+1); >> pos([], _Ele, _) -> >> 0. > > The main problem with this is its name; > it's abbreviated to meaninglessness. > > If I may quote the Haskell List module: > > findIndex :: (a -> Bool) -> [a] -> Maybe Int > elemIndex :: Eq a => a -> [a] -> Maybe Int > > Leaving aside the fact that Haskell uses 0 origin, > the Erlang analogue would be > > find_index(P, Xs) -> > find_index_loop(P, Xs, 1). I agree that find_index is a more clear name reflecting the purpose. > This raises the question of what value should be returned > when no element of the list satisfies the search criterion. > 0 is a popular decision, going back to BASIC, but one that > makes very little sense. The version that actually makes > the most sense is length(Xs)+1, so that > > elem_index(E, Xs) -> find_index(fun (X) -> X =:= E end). > find_index(P, Xs) -> 1 + length(drop_while(P, Xs)). > > because that makes reasoning about programs that use it > noticeably freer of special cases. > > Returning something that isn't a number (my choice here would > have been 'absent') has the advantage that failing to find > something would be unlikely to go un-noticed. It's awkward > with a type checker though. > > The only advantages of returning 0 seem to be "consistency > with old fashioned BASIC" and "simplicity for the type checker". > It makes reasoning about a program more awkward than it need > be, and it makes it far too easy to fail to notice that > something wasn't found. On the other hand returning a value of length(L)+1 means that you would need to traverse the list twice - once to figure out the "unsuccessful" return value, and the second one to find the actual index of an element. Doesn't it sound like an unnecessary piece of work to compute length(L)+1? > Summary: I recommend adopting/adapting the Haskell names, > and there's a choice between > Index|absent, Index|0, Index|length+1, {present,Index}|absent > for the result. My preference is Index|absent or Index|0. > So there are two things about the name. > The first one for me was that the "l" after the "d" was awfully > hard to see. Separated_words_really_are_much_easier_to_read > then runtogetherrunsofwordssuchasyouseebeforeyou. (My mail > program likes them a lot more too. (:-) (:-)) Though I agree with your reasoning, the only counter argument I can come up with is that all functions in the lists module don't have separators, so if we choose to respect the naming style in that module, we'd need to drop the underscore. On the other hand in the string module we find co-existing names like substr/2 and sub_string/2... > Something like > > foldl_prefix(Stepper, Acc0, [X|Xs]) -> > case Stepper(X, Acc0) > of {continue,Acc} -> foldl_prefix(Stepper, Acc, Xs) > ; {stop,Result} -> Result > end; > foldl_prefix(S, Acc, []) when is_function(S, 2) -> > Acc. > > which _does_ at least fold a prefix, might be less confusing. > The function results are now completely unambiguous, there > is no mention of any 'predicate' (because there is none), > and while the name doesn't completely describe the function, > everything it says is true. The Stepper function here is closer > to being the Fun of a fold than the Pred of a takewhile. > > I'm sure someone else can think of a better name. > > I am rather concerned that the final value of a logically > empty list (one for which it is not the case that the list > has an element and the stepper function says to continue) > has its result derived in two different ways: > - if the list is physically empty ([]), Acc0 is the result > - if the list is logically but not physically empty ([X|_]), > Acc1 is the result where {stop,Acc1} = Stepper(X, Acc0). > Somehow this just doesn't feel right. Why is the second case a concern? Wouldn't it be at the discretion of the Stepper function to make the determination of when to stop and return the accumulator whatever it wants one to be? Serge From dave.smith.to@REDACTED Thu Nov 27 04:22:40 2008 From: dave.smith.to@REDACTED (Dave Smith) Date: Wed, 26 Nov 2008 22:22:40 -0500 Subject: [erlang-questions] [correction] Re: Additions to lists module In-Reply-To: <492DE45B.8040309@gmail.com> References: <492D4A39.5050105@gmail.com> <492D4C8D.801@erlang-consulting.com> <5ea453f90811261517h63e55ac6i40d6f3217aa2da97@mail.gmail.com> <5ea453f90811261531x2f60542cycaf98dedeea2e5ce@mail.gmail.com> <20081126235215.GG10121@delora.autosys.us> <20081126235551.GH10121@delora.autosys.us> <492DE45B.8040309@gmail.com> Message-ID: <5ea453f90811261922y7f36cfedp3e5972386ccaf54c@mail.gmail.com> Yes, exactly. not only is splitwith/2 simpler, it only requires the list to be traversed once. 2008/11/26 Serge Aleynikov > Actually for this problem lists:splitwith/2 would do a better job. > > Michael McDaniel wrote: > > On Wed, Nov 26, 2008 at 03:52:15PM -0800, Michael McDaniel wrote: > >> Everyone works on different kinds of problems and has their solutions. > >> One immediate use I thought of follows. > >> > >> Note that html_tokenise is from Joe Armstrong's www_tools-1.0 on > trapexit. > >> > >> > >> {ok, H} = http:request("http://somewebsite.com") , > >> Ht = html_tokenise:string2toks( element(3, H) ) , > >> Pos = list_position:pos( Hal, {tagStart,"title"} ) , > >> > >> {_, Title} = lists:nth( Pos+1, Hal ). > > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > > > > Pos = list_position:pos( Ht, {tagStart,"title"} ) , > > {_, Title} = lists:nth( Pos+1, Ht ). > > > > > > of course, should be Ht for these > > > > ~M > > > > > >> Likely there are other interesting items on a page for which I > >> would have interest. > >> > >> > >> ~Michael > >> > >> > >> > >> On Wed, Nov 26, 2008 at 06:31:11PM -0500, Dave Smith wrote: > >>> But I do agree with you on the pos function. I don't think I would > uses > >>> it. Presumably one would want to do something with the position > after > >>> retrieving it, and this would probably mean using it in a function > that > >>> traverses a list a second time. > >>> It would be more appropriate in a module like array. > >>> > >>> 2008/11/26 Dave Smith <[1]dave.smith.to@[2]gmail.com> > >>> > >>> 2008/11/26 Mazen Harake <[3]mazen.harake@REDACTED> > >>> > >>> What is the idea behind pos? > >>> Curious because I have never been in a situation where I need to > >>> know > >>> the actual position of an element since I always assume that the > >>> order > >>> in a list is always undefined. Perhaps I missed something... do > you > >>> have > >>> a practical example? > >>> /M > >>> > >>> I'm not following. Lists are ordered and in many cases order is > >>> meaningful. Otherwise you would never have reason to reverse a > >>> list. > >>> There are many functions in the lists module where the result is > >>> dependant on the lists order, and there is precedence for > functions > >>> like foldlwhile; examples (takewhile/2, dropwhile/2, splitwith/2) > >>> > >>> References > >>> > >>> 1. http://dave.smith.to/ > >>> 2. http://gmail.com/ > >>> 3. mailto:mazen.harake@REDACTED > >>> _______________________________________________ > >>> erlang-questions mailing list > >>> erlang-questions@REDACTED > >>> http://www.erlang.org/mailman/listinfo/erlang-questions > >> -- > >> Michael McDaniel > >> Portland, Oregon, USA > >> http://autosys.us > >> > >> _______________________________________________ > >> erlang-questions mailing list > >> erlang-questions@REDACTED > >> http://www.erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ok@REDACTED Thu Nov 27 04:57:49 2008 From: ok@REDACTED (Richard O'Keefe) Date: Thu, 27 Nov 2008 16:57:49 +1300 Subject: [erlang-questions] Additions to lists module In-Reply-To: <492E0F22.6090800@gmail.com> References: <492D4A39.5050105@gmail.com> <0AF8FE8D-47DA-4C3E-8A79-99463D45986D@cs.otago.ac.nz> <492E0F22.6090800@gmail.com> Message-ID: On 27 Nov 2008, at 4:08 pm, Serge Aleynikov wrote: > On the other hand returning a value of length(L)+1 means that you > would need to traverse the list twice - once to figure out the > "unsuccessful" return value, and the second one to find the actual > index of an element. Doesn't it sound like an unnecessary piece of > work to compute length(L)+1? Um, no. Any time you are doing positional indexing into a list, you had _better_ be remembering how long the list is. More accurately, (1) it doesn't require any more effort to *compute* length(L)+1 in order to return it (you have it right there in an argument) (2) in *isolation* it *would* require two traversals, but (3) in most plausible contexts it would not. In particular, if you have things like "delete the nth element if there is one" or "insert this after n-1 elements", then length(L)+1 is _exactly_ what you want. I used this convention in a string library and it worked beautifully. (More precisely, I used "how many leading elements that do not match" as the definition, so length(L) was the failure result.) > > >> Summary: I recommend adopting/adapting the Haskell names, >> and there's a choice between >> Index|absent, Index|0, Index|length+1, {present,Index}|absent >> for the result. > > My preference is Index|absent or Index|0. I would hope that we could find a better reason for a choice than someone's preferences, mine included. >> > > Though I agree with your reasoning, the only counter argument I can > come up with is that all functions in the lists module don't have > separators, There has been a lot of chatter in this mailing list about revising the libraries. Consistent and readable naming conventions are obviously a goal of such a revision, if/when it happens. I for one do not find the names in the current lists module acceptable. separated_names_are_nice; baStudlyCapsNamesAreAlmostBearableAsLongAsYouDoNotMentionJSONOrNASA; butruntogethernamesareworstofall; WELLTHEREISONEWAYTHEYCOULDBEWORSEBUTWHOWOULDDOTHAT? > so if we choose to respect the naming style in that module, we'd > need to drop the underscore. > > On the other hand in the string module we find co-existing names > like substr/2 and sub_string/2... > >> Something like >> foldl_prefix(Stepper, Acc0, [X|Xs]) -> >> case Stepper(X, Acc0) >> of {continue,Acc} -> foldl_prefix(Stepper, Acc, Xs) >> ; {stop,Result} -> Result >> end; >> foldl_prefix(S, Acc, []) when is_function(S, 2) -> >> Acc. >> which _does_ at least fold a prefix, might be less confusing. >> The function results are now completely unambiguous, there >> is no mention of any 'predicate' (because there is none), >> and while the name doesn't completely describe the function, >> everything it says is true. The Stepper function here is closer >> to being the Fun of a fold than the Pred of a takewhile. >> I'm sure someone else can think of a better name. >> I am rather concerned that the final value of a logically >> empty list (one for which it is not the case that the list >> has an element and the stepper function says to continue) >> has its result derived in two different ways: >> - if the list is physically empty ([]), Acc0 is the result >> - if the list is logically but not physically empty ([X|_]), >> Acc1 is the result where {stop,Acc1} = Stepper(X, Acc0). >> Somehow this just doesn't feel right. > > Why is the second case a concern? Wouldn't it be at the discretion > of the Stepper function to make the determination of when to stop > and return the accumulator whatever it wants one to be? I don't understand your question. The point is that there are two *DIFFERENT* ways for a logically empty list to terminate and so the same logical situation gets two *DIFFERENT* ways to determine quite possibly different final results. Of course it's at the discretion of the Stepper to decide when to stop. That's what it's _for_. But not always! When the list comes to an end things stop without the Stepper being asked or even told. TWO ways to stop, both representing the same abstract situation ('while' has found all the elements we want) but TWO different final values. get t > > > Serge > From joe@REDACTED Thu Nov 27 05:05:30 2008 From: joe@REDACTED (Joe Williams) Date: Wed, 26 Nov 2008 22:05:30 -0600 Subject: [erlang-questions] erlang port and C executable In-Reply-To: <4928F663.2030809@joetify.com> References: <49274657.3020202@joetify.com> <6c2563b20811222214u1fa7130ese1a2d4ed8ce94a3e@mail.gmail.com> <4928F663.2030809@joetify.com> Message-ID: <492E1C8A.1080708@joetify.com> My solution to the problem ended up being fairly similar to the example on in the Interoperability Tutorial, Section 4 Ports (http://www.erlang.org/doc/tutorial/part_frame.html) as Robert suggested. I found that it was much simpler once I "got it", as Edwin said it's "easier when you know how". :) Thanks guys. -Joe Joe Williams wrote: > Edwin/Robert, > > Thanks for the info, I will see what I can put together and if it's > worthwhile report back my findings. > > -Joe > > > Edwin Fine wrote: > >> Joe, >> >> I don't know if this is still a problem, but I didn't know the answer, >> so I was intrigued. Having never used C ports before, I thought it >> would be useful to learn about them. >> >> I looked at the C code for Erlang (io.c module) and it seems that this >> signal (badsig) is sent when bad port command is received. The port >> command was bad because you can't just send raw data to a port as in >> Port ! <<"Hello">>. It requires a specific format. You have to either >> send Port ! {self(), {command, <<"Hello">>}} or (which I like better) >> erlang:port_command(Port, <<"Hello">>). >> >> In terms of how you can send and receive strings, this whole port >> thing turned out to be much more difficult to figure than I >> anticipated (but easier when you know how). One of the most annoying >> aspects is that under circumstances that are not clear to me, the C >> program that is spawned sometimes does not seem to be sent a signal >> for end of file when you close the port, so if it is reading stdin, >> it's just going to sit there until killed manually. Worse, if it gets >> stuck doing something and is NOT reading stdin then you are out of luck. >> >> But what if the 'C' program is not under your control, say, it's part >> of Linux, and you need to make sure it's killed when you are done? >> Then I believe you need to write a wrapper around the 'C' program. I >> refer you to the following post for an interesting way to do this: >> >> http://www.erlang.org/pipermail/erlang-questions/2007-October/030377.html >> >> As for how to send and receive strings, assuming there is a way to >> terminate the 'C' program, I eventually came up with the following >> "demo" code (which does rely on newlines, and I know there are other >> ways; this is one of them). Hope this helps. >> >> Regards, >> Edwin Fine >> >> /* echo_svr.c: Simple C program to echo stdin to stdout */ >> #include >> >> int main() >> { >> char buf[4096]; >> >> while (fgets(buf, sizeof(buf), stdin) != NULL) >> { >> fputs(buf, stdout); >> fflush(stdout); >> } >> >> return 0; >> } >> >> echo_svr.erl: >> >> -module(test_echo_svr). >> -export([go/2]). >> >> go(EchoSvrExecFilePath, Iters) when is_list(EchoSvrExecFilePath), >> is_integer(Iters), Iters >= 0 -> >> process_flag(trap_exit, true), >> Port = erlang:open_port({spawn, EchoSvrExecFilePath}, [binary]), >> test(Port, <<>>, Iters, 1). >> >> test(Port, _Buf, 0, _N) -> >> erlang:port_close(Port), ok; >> test(Port, Buf, Iters, N) -> >> Out = list_to_binary([<<"Test message ">>, integer_to_list(N), $\n]), >> erlang:port_command(Port, Out), >> receive >> {Port, {data, In}} -> >> {Line, Rest} = parse(list_to_binary([Buf, In])), >> io:format("~p~n", [Line]), >> test(Port, Rest, Iters - 1, N + 1) >> after 3000 -> >> io:format("Receive timeout, stopping.~n") >> end. >> >> parse(Msg) -> parse(Msg, []). >> >> parse(<<>>, Acc) -> {lists:reverse(Acc), <<>>}; >> parse(<<$\n, Rest/binary>>, Acc) -> {lists:reverse(Acc), Rest}; % EOL >> parse(<>, Acc) -> parse(Rest, [Byte|Acc]). >> >> 113> test_echo_svr:go("/path/to/echo_svr", 3). >> "Test message 1" >> "Test message 2" >> "Test message 3" >> ok >> >> >> On Fri, Nov 21, 2008 at 6:37 PM, Joe Williams > > wrote: >> >> Hello, >> >> I am having an issue when I attempt to send and receive messages >> to a C >> executable. I believe the task should be fairly trivial but I am >> getting >> hung up on sending messages to the port. Here's what I have so far: >> >> > Eshell V5.6.3 (abort with ^G) >> > 1> Cmd = "SOME_EXECUTABLE", >> > 1> Port = open_port({spawn, Cmd}, []). >> > #Port<0.93> >> > 2> receive >> > 2> {Port, {data, Data}} -> >> > 2> io:format("~p~n", [Data]); >> > 2> Error -> >> > 2> io:format("~p~n", [Error]) >> > 2> end. >> > "TEXT FROM THE EXECUTABLE" >> > ok >> > 3> Port ! <<"TEXT TO THE EXECUTABLE">>. >> > ** exception exit: badsig >> > 4> Port ! <<"TEXT TO THE EXECUTABLE">>. >> > <<"TEXT TO THE EXECUTABLE">> >> > 5> receive >> > 5> {Port, {data, Data}} -> >> > 5> io:format("~p~n", [Data]); >> > 5> Error -> >> > 5> io:format("~p~n", [Error]) >> > 5> end. >> >> After the last end my code just hangs and waits to receive a message >> rather than receiving the response from "TEXT TO THE EXECUTABLE". >> Since >> it received the first message properly I assume it would receive >> further >> responses in the same way. So I have two questions, the first is what >> does "exception exit: badsig" generally mean? The second how can I >> write >> this in such a way that I can send and receive strings until I >> have the >> program exit? >> >> Any guidance is appreciated. >> >> -Joe >> >> -- >> Name: Joseph A. Williams >> Email: joe@REDACTED >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> >> >> > > -- Name: Joseph A. Williams Email: joe@REDACTED From silvester.roessner@REDACTED Thu Nov 27 07:02:23 2008 From: silvester.roessner@REDACTED (Roessner, Silvester) Date: Thu, 27 Nov 2008 07:02:23 +0100 Subject: [erlang-questions] Additions to lists module In-Reply-To: <0AF8FE8D-47DA-4C3E-8A79-99463D45986D@cs.otago.ac.nz> References: <492D4A39.5050105@gmail.com> <0AF8FE8D-47DA-4C3E-8A79-99463D45986D@cs.otago.ac.nz> Message-ID: <2CEB6DA5040AED4F946351C85FAC87B50265D9D4@DEJENSAPP01V1.vision.zeiss.org> On 27. November 2008 02:32 Richard O'Keefe wrote > This raises the question of what value should be returned when no element of the list satisfies the search criterion. I would prefer a list. It is empty if there is no matching element or has exactly one member, the index. I also would join all of the mentioned funtions in only one, like > %% @spec (List::list(), Ele) -> [integer()] > %% @doc Returns the position of `Ele' in the `List'. [] is returned > %% when `Ele' is not found. > %% @end find_index(List, Element, Option) -> [Index] find_index(List, Element) = [Index] Option = only_first | only_last | [every] mit freundlichen Gr??en / with kind regards Silvester R??ner ------------------------------------------------------------------------------------------------------- This message is intended for a particular addressee only and may contain business or company secrets. If you have received this email in error, please contact the sender and delete the message immediately. Any use of this email, including saving, publishing, copying, replication or forwarding of the message or the contents is not permitted. -----Urspr?ngliche Nachricht----- Von: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] Im Auftrag von Richard O'Keefe Gesendet: Donnerstag, 27. November 2008 02:32 An: Serge Aleynikov Cc: Erlang Users' List Betreff: Re: [erlang-questions] Additions to lists module On 27 Nov 2008, at 2:08 am, Serge Aleynikov wrote: > I'd like to propose addition of these two functions to the lists > module. > Very often I find the need for this functionality and feel that it > belongs to the standard library. > > Serge > > > > %% @spec (List::list(), Ele) -> integer() %% @doc Returns the position > of `Ele' in the `List'. 0 is returned > %% when `Ele' is not found. > %% @end > pos(List, Ele) -> > pos(List, Ele, 1). > > pos([Ele | Tail], Ele, Pos) -> > Pos; > pos([_ | Tail], Ele, Pos) -> > pos(Tail, Ele, Pos+1); > pos([], _Ele, _) -> > 0. The main problem with this is its name; it's abbreviated to meaninglessness. If I may quote the Haskell List module: findIndex :: (a -> Bool) -> [a] -> Maybe Int elemIndex :: Eq a => a -> [a] -> Maybe Int Leaving aside the fact that Haskell uses 0 origin, the Erlang analogue would be find_index(P, Xs) -> find_index_loop(P, Xs, 1). find_index_loop(P, [X|Xs], Index) -> case P(X) of true -> Index ; false -> find_index_loop(P, Xs, Index + 1) end; find_index_loop(P, [], _) when is_function(P, 1) -> 0. elem_index(E, Xs) -> elem_index_loop(E, Xs, 1). elem_index_loop(E, [E|_], Index) -> Index; elem_index_loop(E, [_|Xs], Index) -> elem_index_loop(E, Xs, Index + 1); elem_index_loop(_, [], _) -> 0. This raises the question of what value should be returned when no element of the list satisfies the search criterion. 0 is a popular decision, going back to BASIC, but one that makes very little sense. The version that actually makes the most sense is length(Xs)+1, so that elem_index(E, Xs) -> find_index(fun (X) -> X =:= E end). find_index(P, Xs) -> 1 + length(drop_while(P, Xs)). because that makes reasoning about programs that use it noticeably freer of special cases. Returning something that isn't a number (my choice here would have been 'absent') has the advantage that failing to find something would be unlikely to go un-noticed. It's awkward with a type checker though. The only advantages of returning 0 seem to be "consistency with old fashioned BASIC" and "simplicity for the type checker". It makes reasoning about a program more awkward than it need be, and it makes it far too easy to fail to notice that something wasn't found. The Haskell versions *force* you to check whether something was found or not; I suppose the nearest Erlang analogue would be to return {present,Index} for something found and 'absent' for something not found. Summary: I recommend adopting/adapting the Haskell names, and there's a choice between Index|absent, Index|0, Index|length+1, {present,Index}|absent for the result. > > > %% @spec (Pred, Acc, List::list()) -> Acc1 > %% Pred = (Ele, Acc) -> Acc1 > %% @doc A combination of foldl/3 and takewhile/2. Accumulate the > result > %% while the predicate function returns true. > %% @end > foldlwhile(Pred, Acc0, [H|T]) -> > case Pred(H, Acc0) of > {true, Acc} -> > foldwhile(Fun, Acc, T); > {false, Acc} -> > Acc; > end; > foldlwhile(_Pred, Acc, []) -> > Acc. We would expect a combination of fold/3 and takewhile/2 to have the form foldl_while(Fun, Acc0, Pred, List) -> foldl(Fun, Acc0, takewhile(Pred, List)) or foldl_while(Fun, Acc0, Pred, [X|Xs]) -> case Pred(X) of true -> foldl_while(Fun, Fun(X, Acc0), Pred, Xs) ; false -> Acc0 end; foldl_while(Fun, Acc0, Pred, []) when is_function(Fun, 2), is_function(Pred, 1) -> Acc0. This is the kind of code that it's pointless to write in Haskell because the compiler will fuse the loops automagically. So there are two things about the name. The first one for me was that the "l" after the "d" was awfully hard to see. Separated_words_really_are_much_easier_to_read then runtogetherrunsofwordssuchasyouseebeforeyou. (My mail program likes them a lot more too. (:-) (:-)) The second one is that the name is a little misleading in that the parameters are not what you might expect them to be. This is, by the way, a *perfect* example of the Boolean antipattern I mentioned before. When you are writing the function, does 'true' mean 'keep going' or does it mean 'stop'? Here again the name of the function is confusing, because it _doesn't_ mean to keep on folding "while the predicate function returns true" because the function NEVER returns true. Something like foldl_prefix(Stepper, Acc0, [X|Xs]) -> case Stepper(X, Acc0) of {continue,Acc} -> foldl_prefix(Stepper, Acc, Xs) ; {stop,Result} -> Result end; foldl_prefix(S, Acc, []) when is_function(S, 2) -> Acc. which _does_ at least fold a prefix, might be less confusing. The function results are now completely unambiguous, there is no mention of any 'predicate' (because there is none), and while the name doesn't completely describe the function, everything it says is true. The Stepper function here is closer to being the Fun of a fold than the Pred of a takewhile. I'm sure someone else can think of a better name. I am rather concerned that the final value of a logically empty list (one for which it is not the case that the list has an element and the stepper function says to continue) has its result derived in two different ways: - if the list is physically empty ([]), Acc0 is the result - if the list is logically but not physically empty ([X|_]), Acc1 is the result where {stop,Acc1} = Stepper(X, Acc0). Somehow this just doesn't feel right. If you think about it, this is *really* a combination of foldl and an unfold. Recall that an unfold works with a function that takes a state and either says "we're at the end" or says "we are not at the end, here is an element and a new state". I very much like unfolder :: State -> [] | [Element|State] but some people do not. So let's take an unfolder to be unfolder :: State -> empty | {Element,State}. Now unfold is unfold(Unfolder, State) -> case Unfolder(State) of empty -> [] ; {Element,State1} -> [Element|unfold(Unfolder, State1)] end. Combine foldl and unfold. foldl_unfold(Fun, Acc0, Unfolder, State) -> case Unfolder(State) of empty -> Acc0 ; {Element,State1} -> foldl_unfold(Fun, Fun(Element,Acc0), Unfolder, State1) end. The interesting thing here is that nothing says that the State can't be a list in the first place. You can have while_unfolder(P) -> fun ([X|Xs]) -> case P(X) of true -> {X,Xs} ; false -> empty end ; ([]) -> empty end. Then foldl_while(Fun, Acc0, Pred, List) -> foldl_unfold(Fun, Acc0, while_unfolder(Pred), List) This suggests that combining things with unfold is strictly more powerful than combining them with takewhile, because the unfold version can do the takewhile version but not conversely. In particular, we can also do while_zip_unfolder(P) -> fun ({[X|Xs], [Y,Ys]}) -> case P(X, Y) of true -> {{X,Y}, {Xs,Ys}} ; false -> empty end ; (_) -> empty end. and combine takewhile with (lazy) zipping. The only limit here is our imagination. In Haskell, I'd have something like data Stepper a = Continue a | Stop a data Final a = Found a | Not_Found a foldl_prefix :: (x -> a -> Stepper a) -> a -> [x] -> Final a foldl_prefix _ a [] = Not_Found a foldl_prefix f a (x:xs) = case f x a of Continue a' -> foldl_prefix f a' xs Stop a' -> Found a' Something that *really* combines foldl and takewhile shouldn't be able to tell the difference between physical and logical end of list. So this just doesn't feel right yet. _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions From erlangy@REDACTED Thu Nov 27 07:40:35 2008 From: erlangy@REDACTED (Michael McDaniel) Date: Wed, 26 Nov 2008 22:40:35 -0800 Subject: [erlang-questions] Additions to lists module In-Reply-To: References: <492D4A39.5050105@gmail.com> <492D4C8D.801@erlang-consulting.com> <5ea453f90811261517h63e55ac6i40d6f3217aa2da97@mail.gmail.com> <5ea453f90811261531x2f60542cycaf98dedeea2e5ce@mail.gmail.com> <20081126235215.GG10121@delora.autosys.us> Message-ID: <20081127064034.GR10121@delora.autosys.us> Sweet - that gets more to how I'm interested in using it, also; thanks, Richard. ~Michael On Thu, Nov 27, 2008 at 03:30:40PM +1300, Richard O'Keefe wrote: > > On 27 Nov 2008, at 12:52 pm, Michael McDaniel wrote: > >> >> Everyone works on different kinds of problems and has their solutions. >> One immediate use I thought of follows. >> >> Note that html_tokenise is from Joe Armstrong's www_tools-1.0 on >> trapexit. >> >> >> {ok, H} = http:request("http://somewebsite.com") , >> Ht = html_tokenise:string2toks( element(3, H) ) , >> Pos = list_position:pos( Hal, {tagStart,"title"} ) , >> >> {_, Title} = lists:nth( Pos+1, Hal ). > > This is better as > > {_,Title} = lists:after({tagStart,"title"}, Hal) > > where > after(X, [X,Y|_]) -> Y; > after(X, [_|Ys]) -> after(X, Ys). > > > which does the job in one pass. The *order* and *adjacency* > of elements in a list often matters; the actual *positions* > far less often. > > If we add > > before(X, [Y,X|_]) -> Y; > before(X, [_|Ys]) -> before(X, Ys). > > then we've matched the #after: and #before: methods in > ANSI Smalltalk's SequencedReadableCollection class. > If we add > > after(X, [X,Y|_], _) -> Y; > after(X, [_|Ys], D) -> after(X, Ys, D); > after(_, [], D) -> D. > > before(X, [Y,X|_], _) -> Y; > before(X, [_|Ys], D) -> before(X, Ys, D); > before(_, [], D) -> D. > > then we've come close to matching the #after:ifAbsent: > and #before:ifAbsent: methods (which actually take funs > rather than default values). > > Even simpler than after would be to adapt Lisp's (MEMBER - -) > function, and instead of returning false or true, return the > empty list or the place where the match was found. (Funny > how the Boolean anti-pattern keeps turning up, isn't it?) > Define > > lmember(X, Xs = [X|_]) -> X; > lmember(X, [_ | Xs]) -> lmember(X, Xs); > lmember(_, []) -> []. > > Then > > [_,{_,Title}|_] = lmember({tagStart,"title"}, Hal) > > and if we wanted to pick up the next two elements it would > be just as simple to do > > [_,{_,Title},Next|_] = lmember({tagStart,"title"}, Hal) > > > -- Michael McDaniel Portland, Oregon, USA http://autosys.us From erlangy@REDACTED Thu Nov 27 07:43:57 2008 From: erlangy@REDACTED (Michael McDaniel) Date: Wed, 26 Nov 2008 22:43:57 -0800 Subject: [erlang-questions] [correction] Re: Additions to lists module In-Reply-To: <5ea453f90811261922y7f36cfedp3e5972386ccaf54c@mail.gmail.com> References: <492D4A39.5050105@gmail.com> <492D4C8D.801@erlang-consulting.com> <5ea453f90811261517h63e55ac6i40d6f3217aa2da97@mail.gmail.com> <5ea453f90811261531x2f60542cycaf98dedeea2e5ce@mail.gmail.com> <20081126235215.GG10121@delora.autosys.us> <20081126235551.GH10121@delora.autosys.us> <492DE45B.8040309@gmail.com> <5ea453f90811261922y7f36cfedp3e5972386ccaf54c@mail.gmail.com> Message-ID: <20081127064356.GS10121@delora.autosys.us> Thanks, Serge, for reminding me of lists:splitwith/2 - I had looked at it once and did not pursue using it but am again playing with it. ~Michael On Wed, Nov 26, 2008 at 10:22:40PM -0500, Dave Smith wrote: > Yes, exactly. not only is splitwith/2 simpler, it only requires the > list to be traversed once. > > 2008/11/26 Serge Aleynikov <[1]saleyn@REDACTED> > > Actually for this problem lists:splitwith/2 would do a better job. > > Michael McDaniel wrote: > > On Wed, Nov 26, 2008 at 03:52:15PM -0800, Michael McDaniel wrote: > >> Everyone works on different kinds of problems and has their > solutions. > >> One immediate use I thought of follows. > >> > >> Note that html_tokenise is from Joe Armstrong's www_tools-1.0 on > trapexit. > >> > >> > >> {ok, H} = http:request("[2]http://somewebsite.com") , > >> Ht = html_tokenise:string2toks( element(3, H) ) , > >> Pos = list_position:pos( Hal, {tagStart,"title"} ) , > >> > >> {_, Title} = lists:nth( Pos+1, Hal ). > > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > > > > Pos = list_position:pos( Ht, {tagStart,"title"} ) , > > {_, Title} = lists:nth( Pos+1, Ht ). > > > > > > of course, should be Ht for these > > > > ~M > > > > > >> Likely there are other interesting items on a page for which I > >> would have interest. > >> > >> > >> ~Michael > >> > >> > >> > >> On Wed, Nov 26, 2008 at 06:31:11PM -0500, Dave Smith wrote: > >>> But I do agree with you on the pos function. I don't think I > would uses > >>> it. Presumably one would want to do something with the position > after > >>> retrieving it, and this would probably mean using it in a > function that > >>> traverses a list a second time. > >>> It would be more appropriate in a module like array. > >>> > >>> 2008/11/26 Dave Smith <[1][3]dave.smith.to@[2][4]gmail.com> > >>> > >>> 2008/11/26 Mazen Harake > <[3][5]mazen.harake@REDACTED> > >>> > >>> What is the idea behind pos? > >>> Curious because I have never been in a situation where I need > to > >>> know > >>> the actual position of an element since I always assume that > the > >>> order > >>> in a list is always undefined. Perhaps I missed something... > do you > >>> have > >>> a practical example? > >>> /M > >>> > >>> I'm not following. Lists are ordered and in many cases order > is > >>> meaningful. Otherwise you would never have reason to reverse > a > >>> list. > >>> There are many functions in the lists module where the result > is > >>> dependant on the lists order, and there is precedence for > functions > >>> like foldlwhile; examples (takewhile/2, dropwhile/2, > splitwith/2) > >>> > >>> References > >>> > >>> 1. [6]http://dave.smith.to/ > >>> 2. [7]http://gmail.com/ > >>> 3. mailto:[8]mazen.harake@REDACTED > >>> _______________________________________________ > >>> erlang-questions mailing list > >>> [9]erlang-questions@REDACTED > >>> [10]http://www.erlang.org/mailman/listinfo/erlang-questions > >> -- > >> Michael McDaniel > >> Portland, Oregon, USA > >> [11]http://autosys.us > >> > >> _______________________________________________ > >> erlang-questions mailing list > >> [12]erlang-questions@REDACTED > >> [13]http://www.erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > > erlang-questions mailing list > > [14]erlang-questions@REDACTED > > [15]http://www.erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > [16]erlang-questions@REDACTED > [17]http://www.erlang.org/mailman/listinfo/erlang-questions > > References > > 1. mailto:saleyn@REDACTED > 2. http://somewebsite.com/ > 3. http://dave.smith.to/ > 4. http://gmail.com/ > 5. mailto:mazen.harake@REDACTED > 6. http://dave.smith.to/ > 7. http://gmail.com/ > 8. mailto:mazen.harake@REDACTED > 9. mailto:erlang-questions@REDACTED > 10. http://www.erlang.org/mailman/listinfo/erlang-questions > 11. http://autosys.us/ > 12. mailto:erlang-questions@REDACTED > 13. http://www.erlang.org/mailman/listinfo/erlang-questions > 14. mailto:erlang-questions@REDACTED > 15. http://www.erlang.org/mailman/listinfo/erlang-questions > 16. mailto:erlang-questions@REDACTED > 17. http://www.erlang.org/mailman/listinfo/erlang-questions > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- Michael McDaniel Portland, Oregon, USA http://autosys.us From bengt.kleberg@REDACTED Thu Nov 27 08:01:11 2008 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Thu, 27 Nov 2008 08:01:11 +0100 Subject: [erlang-questions] Additions to lists module In-Reply-To: <492DDDDC.6040002@gmail.com> References: <492D4A39.5050105@gmail.com> <492D4C8D.801@erlang-consulting.com> <492D4D83.10202@gmail.com> <14f0e3620811260546y5bbc6a49o9618e00849ac645e@mail.gmail.com> <492DDDDC.6040002@gmail.com> Message-ID: <1227769271.4629.1.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> Greetings, How about: case X of field_name -> #myTable.field_name end bengt On Wed, 2008-11-26 at 18:38 -0500, Serge Aleynikov wrote: > That is if you know at compile time that the field your are interested > in is #myTable.field_name. What if you need to get the value of the > field X = 'field_name' in Table = myTable? > > Gleb Peregud wrote: > > Hi, > > > > Isn't #myTable.field_name enough to determine the position of the > > field in record's tuple? Have I understood this correctly? > > > > BR > > > > On 11/26/08, Serge Aleynikov wrote: > >> Say you have a mnesia table with a structure being record_info(fields, > >> myTable). The pos/2 function would help you find a position of a given > >> field in the table. > >> > >> Mazen Harake wrote: > >>> What is the idea behind pos? > >>> > >>> Curious because I have never been in a situation where I need to know > >>> the actual position of an element since I always assume that the order > >>> in a list is always undefined. Perhaps I missed something... do you have > >>> a practical example? > >>> > >>> /M > >>> > >>> Serge Aleynikov wrote: > >>>> I'd like to propose addition of these two functions to the lists > >>>> module. Very often I find the need for this functionality and feel > >>>> that it belongs to the standard library. > >>>> > >>>> Serge > >>>> > >>>> > >>>> > >>>> %% @spec (List::list(), Ele) -> integer() > >>>> %% @doc Returns the position of `Ele' in the `List'. 0 is returned > >>>> %% when `Ele' is not found. > >>>> %% @end > >>>> pos(List, Ele) -> > >>>> pos(List, Ele, 1). > >>>> pos([Ele | Tail], Ele, Pos) -> > >>>> Pos; > >>>> pos([_ | Tail], Ele, Pos) -> > >>>> pos(Tail, Ele, Pos+1); > >>>> pos([], _Ele, _) -> > >>>> 0. > >>>> > >>>> %% @spec (Pred, Acc, List::list()) -> Acc1 > >>>> %% Pred = (Ele, Acc) -> Acc1 > >>>> %% @doc A combination of foldl/3 and takewhile/2. Accumulate the result > >>>> %% while the predicate function returns true. > >>>> %% @end > >>>> foldlwhile(Pred, Acc0, [H|T]) -> > >>>> case Pred(H, Acc0) of > >>>> {true, Acc} -> > >>>> foldwhile(Fun, Acc, T); > >>>> {false, Acc} -> > >>>> Acc; > >>>> end; > >>>> foldlwhile(_Pred, Acc, []) -> > >>>> Acc. > >>>> _______________________________________________ > >>>> erlang-questions mailing list > >>>> erlang-questions@REDACTED > >>>> http://www.erlang.org/mailman/listinfo/erlang-questions > >>>> > >>> > >> _______________________________________________ > >> erlang-questions mailing list > >> erlang-questions@REDACTED > >> http://www.erlang.org/mailman/listinfo/erlang-questions > >> > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From v@REDACTED Thu Nov 27 08:26:27 2008 From: v@REDACTED (Valentin Micic) Date: Thu, 27 Nov 2008 09:26:27 +0200 Subject: [erlang-questions] Why is setting socket options by setopts()better than by listen()? In-Reply-To: <3bff71aa0811261245r211c15eft979e7dbcefa68db9@mail.gmail.com> Message-ID: <200811270725.mAR7PAKn019141@mail.pharos-avantgard.com> I wouldn't say better... I think it is more a question of semantic: one is used to set/change default parameters, whilst another to inform driver about specific connection behavior. Relying on a (changed) default behavior may not be always desirable, as it may make program less readable - gen_tcp:listen/2 may be placed anywhere in a code, whereas the person that reads the code may want to know about the socket behavior right there, where the connection has been accepted. I would say that options related to gen_tcp:listen/2, therefore not influencing session socket directly, should be placed alongside listen, say: gen_tcp:listen(Port, [{reuseaddr, true}]) OTOH, options related to the socket should be explicitly mentioned after the connection has been accepted: inet:setopts(Socket, [binary, {active, once}]) IMO, one exception to this rule should be "active" flag, which I also use as a part of gen_tcp:listen/2 argument: gen_tcp:listen(Port, [{reuseaddr, true}, {active, false}]) in order to prevent socket receiving any traffic without solicitation. But I think this doesn't break the rule, as the call to inet:setopts/2 may change that the way particular process requires it. V. -----Original Message----- From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Sergey A. Sent: 26 November 2008 10:45 PM To: erlang-questions@REDACTED Subject: [erlang-questions] Why is setting socket options by setopts()better than by listen()? Hello. I've read the following in the "Programming Erlang": -------------------8<------------------- After we have accepted a connection, it's a good idea to explicitly set the required socket options, like this: {ok, Socket} = gen_tcp:accept(Listen), inet:setopts(Socket, [{packet,4},binary, {nodelay,true},{active, true}]), loop(Socket) -------------------8<------------------- And I have a small question. Why that is considered better solution than using the same options, but passed to gen_tcp:listen/2 function: gen_tcp:listen(2345, [{packet, 4}, binary, {nodelay, true}, {active, true}, {reuseaddr, true}]) As I know, all the sockets obtained by calling gen_tcp:accept/1 inherit options listed in gen_tcp:listen. Thanks. -- Sergey. _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions From mazen.harake@REDACTED Thu Nov 27 09:32:32 2008 From: mazen.harake@REDACTED (Mazen Harake) Date: Thu, 27 Nov 2008 10:32:32 +0200 Subject: [erlang-questions] Additions to lists module In-Reply-To: <5ea453f90811261517h63e55ac6i40d6f3217aa2da97@mail.gmail.com> References: <492D4A39.5050105@gmail.com> <492D4C8D.801@erlang-consulting.com> <5ea453f90811261517h63e55ac6i40d6f3217aa2da97@mail.gmail.com> Message-ID: <492E5B20.9010207@erlang-consulting.com> You are somewhat right but you have to differ between two concepts. Given a list of elements of arbitrary terms (I will assume we are not talking about strings now since they happen to be lists but should perhaps be seen differently) then you should never assume that the order of these elements are defined. Your functions operating on the list shouldn't/can't _depend_ on the order... A good example of this is an optionlist. It would be very naive to assume that a specific option comes first, and an other specific option after that one. The order *does* matter, but not in terms of your use of the list. E.g. if you would perform a set of actions based on atoms in a list and where one action affect the other... then the order of course matters... but it shouldn't matter in which order they are, you still have to perform the operations on the list in the same way. The reason to reverse a list is to effectivly build a list (this is the most used case probably) and then get back to the order that it was intended to have, but when I start using this reversed list I shouldn't care about the actual order in it (samw concept applies to e.g. sorted lists). Therefore, the position function proposed is probably not that useful... but maybe I'm the only one who sees it that way :D /M Dave Smith wrote: > > 2008/11/26 Mazen Harake > > > What is the idea behind pos? > > Curious because I have never been in a situation where I need to know > the actual position of an element since I always assume that the order > in a list is always undefined. Perhaps I missed something... do > you have > a practical example? > > /M > > > I'm not following. Lists are ordered and in many cases order is > meaningful. Otherwise you would never have reason to reverse a list. > > There are many functions in the lists module where the result is > dependant on the lists order, and there is precedence for functions > like foldlwhile; examples (takewhile/2, dropwhile/2, splitwith/2) > From erlang@REDACTED Thu Nov 27 10:23:13 2008 From: erlang@REDACTED (Peter Lund) Date: Thu, 27 Nov 2008 10:23:13 +0100 Subject: [erlang-questions] Additions to lists module In-Reply-To: <492DDCD5.6060203@gmail.com> References: <492D4A39.5050105@gmail.com> <492D5167.6050208@lundata.se> <492DDCD5.6060203@gmail.com> Message-ID: <492E6701.5040404@lundata.se> Yes I agree it is a bit of a "hack", but I think there are some people out there using it this way already and this means the function of string:str/2 should not change in the future since it should be backward compatible. Better would be to add in the OTP module 'lists' something like this: -module(lists). find(List, Elem) -> string:str(List,[Elem]). And document it properly for all new erlang users out there. It takes a while before newbies discover this "hack" way of using it and it then lessens the good impression of Erlang/OTP, so it would be much better to have this documented *properly* in the lists module. / Peter Serge Aleynikov skrev: > Don't you agree that this is a hack given documented definition of the > function: > > str(String, SubString) -> Index > rstr(String, SubString) -> Index > > Types: > String = SubString = string() > > Serge > > Peter Lund wrote: >> 1> string:str([x,y,s,my_arbitrary_erlang_term], >> [my_arbitrary_erlang_term]). >> 4 >> 2> >> >> >> Serge Aleynikov skrev: >>> I'd like to propose addition of these two functions to the lists >>> module. Very often I find the need for this functionality and feel >>> that it belongs to the standard library. >>> >>> Serge >>> >>> >>> >>> %% @spec (List::list(), Ele) -> integer() >>> %% @doc Returns the position of `Ele' in the `List'. 0 is returned >>> %% when `Ele' is not found. >>> %% @end >>> pos(List, Ele) -> >>> pos(List, Ele, 1). >>> pos([Ele | Tail], Ele, Pos) -> >>> Pos; >>> pos([_ | Tail], Ele, Pos) -> >>> pos(Tail, Ele, Pos+1); >>> pos([], _Ele, _) -> >>> 0. >>> >>> %% @spec (Pred, Acc, List::list()) -> Acc1 >>> %% Pred = (Ele, Acc) -> Acc1 >>> %% @doc A combination of foldl/3 and takewhile/2. Accumulate the result >>> %% while the predicate function returns true. >>> %% @end >>> foldlwhile(Pred, Acc0, [H|T]) -> >>> case Pred(H, Acc0) of >>> {true, Acc} -> >>> foldwhile(Fun, Acc, T); >>> {false, Acc} -> >>> Acc; >>> end; >>> foldlwhile(_Pred, Acc, []) -> >>> Acc. >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://www.erlang.org/mailman/listinfo/erlang-questions >>> >>> >> >> > From kdronnqvist@REDACTED Thu Nov 27 10:36:04 2008 From: kdronnqvist@REDACTED (=?ISO-8859-1?Q?Daniel_R=F6nnqvist?=) Date: Thu, 27 Nov 2008 10:36:04 +0100 Subject: [erlang-questions] Erlang elseif In-Reply-To: References: <65691fa00811200041yfc7a219y97a11126e0cee535@mail.gmail.com> <78FFE0EB-DF1E-41E9-A802-A66B4F8066AF@cs.otago.ac.nz> <65691fa00811202337w57f3f329m244abaa055f6fae8@mail.gmail.com> <4CA10F5D-BA37-4952-AA59-4A63DC6632ED@cs.otago.ac.nz> <65691fa00811250056x23d69561mcb0a91d17a4d8fea@mail.gmail.com> <336AC7F4-4A18-447D-A5BF-549A8D15CBA5@cs.otago.ac.nz> <65691fa00811260007m1ac279dxf73c68676057cd7f@mail.gmail.com> Message-ID: <65691fa00811270136m374f7d29n96970c9cbf7ffd47@mail.gmail.com> Yes I noticed, cared and I liked it. I was reffering to your simplification stating that the discussion is about: X. I think Erlang needs to be like C. Y. I don't. I think the case-or-case would be the best solution but I got the impression that cond was a real proposal and your case-or-case was just an idea of the top of your head. I don't think Erlang would be like C if this (or cond) was introduced, just my opinion :) BR, Daniel 2008/11/27 Richard O'Keefe > > On 26 Nov 2008, at 9:07 pm, Daniel R?nnqvist wrote: > > To make it short; I don't want Erlang to be like C, it seems you got so >> tangled up in your own agenda so I don't think you care anymore what I am >> talking about. What I would like is Erlang to be able to do what it does >> with nested cases in a better and non-nested syntax, like the proposed >> "cond" that Jay is talking about. Then the programmer could decide for them >> selfs if they want to use it or not. >> > > Why is it that when people talk about other people's "agendas" > it is always an insult? > > Of course I care what you are talking about; if I didn't, I would > not have replied to it in detail, considering each of your points. > > Did you notice, or care, about my suggestion of an > Algol 68-inspired "; or case" (modelled on Algol 68's "ouse" > keyword) that you give you PRECISELY a non-nested syntax? > That is far more capable than 'cond' because it is not restricted > to Booleans. How does that fail to meet your needs? > > The continuing absence of a concrete case to discuss > continues to render the argument for any new syntax dubious > in the extreme. > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rvirding@REDACTED Thu Nov 27 12:00:35 2008 From: rvirding@REDACTED (Robert Virding) Date: Thu, 27 Nov 2008 12:00:35 +0100 Subject: [erlang-questions] Additions to lists module In-Reply-To: <0AF8FE8D-47DA-4C3E-8A79-99463D45986D@cs.otago.ac.nz> References: <492D4A39.5050105@gmail.com> <0AF8FE8D-47DA-4C3E-8A79-99463D45986D@cs.otago.ac.nz> Message-ID: <3dbc6d1c0811270300m658a97b3i45f56983153a08a5@mail.gmail.com> I will just comment some of the many threads going in this discussion. Without making any concrete suggestions I want to say that I would have nothing against adding a find_index, elem_index and unfoldl to lists. 2008/11/27 Richard O'Keefe > > This raises the question of what value should be returned > when no element of the list satisfies the search criterion. > 0 is a popular decision, going back to BASIC, but one that > makes very little sense. The version that actually makes > the most sense is length(Xs)+1, so that > > elem_index(E, Xs) -> find_index(fun (X) -> X =:= E end). > find_index(P, Xs) -> 1 + length(drop_while(P, Xs)). > > because that makes reasoning about programs that use it > noticeably freer of special cases. > > Returning something that isn't a number (my choice here would > have been 'absent') has the advantage that failing to find > something would be unlikely to go un-noticed. It's awkward > with a type checker though. > > The only advantages of returning 0 seem to be "consistency > with old fashioned BASIC" and "simplicity for the type checker". > It makes reasoning about a program more awkward than it need > be, and it makes it far too easy to fail to notice that > something wasn't found. > > The Haskell versions *force* you to check whether something > was found or not; I suppose the nearest Erlang analogue > would be to return {present,Index} for something found and > 'absent' for something not found. > > Summary: I recommend adopting/adapting the Haskell names, > and there's a choice between > Index|absent, Index|0, Index|length+1, {present,Index}|absent > for the result. I would probably opt for something which resembles Haskell's Maybe Type and use: maybe(Type) = {yes,Type} | no. if I have understood Haskell's Maybe corectly, and Erlang type declarations. This is a return format I would like to use often, and we should have used it often too. I would not directly follow the conventions in string, they are very much taken from the libc equivalents and make much more sense in C than they do in Erlang. Re names of functions, lists is probably not an example of good naming conventions. Why there are no separated_names I can't remember, most likely it just happened and the local convention was just continued. The names for many of the higher order functions came from Haskell or similar and there they did not use separated_names. It is not a convention that need be followed. Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: From jlprasantha@REDACTED Thu Nov 27 14:07:40 2008 From: jlprasantha@REDACTED (prasantha kumara) Date: Thu, 27 Nov 2008 18:37:40 +0530 Subject: [erlang-questions] call erlang function from c Message-ID: i want to call the errlang functio via c funcion.can anybody tell me how to do it? thank -------------- next part -------------- An HTML attachment was scrubbed... URL: From ok@REDACTED Thu Nov 27 22:59:27 2008 From: ok@REDACTED (Richard O'Keefe) Date: Fri, 28 Nov 2008 10:59:27 +1300 Subject: [erlang-questions] Additions to lists module In-Reply-To: <2CEB6DA5040AED4F946351C85FAC87B50265D9D4@DEJENSAPP01V1.vision.zeiss.org> References: <492D4A39.5050105@gmail.com> <0AF8FE8D-47DA-4C3E-8A79-99463D45986D@cs.otago.ac.nz> <2CEB6DA5040AED4F946351C85FAC87B50265D9D4@DEJENSAPP01V1.vision.zeiss.org> Message-ID: <26BE4DBF-FC05-4845-AB68-C980C20207A5@cs.otago.ac.nz> On 27 Nov 2008, at 7:02 pm, Roessner, Silvester wrote: > On 27. November 2008 02:32 Richard O'Keefe wrote > >> This raises the question of what value should be returned when no >> element of the list satisfies the search criterion. > > I would prefer a list. It is empty if there is no matching element > or has exactly one member, the index. I didn't mention the other two members in the group of related Haskell functions: elemIndices :: Eq x => x -> [x] -> [Int] findIndices :: (x -> Bool) -> [x] -> [Int] So yes, lists make sense as a "poor man's Maybe". > > > I also would join all of the mentioned funtions in only one, like > >> %% @spec (List::list(), Ele) -> [integer()] >> %% @doc Returns the position of `Ele' in the `List'. [] is returned >> %% when `Ele' is not found. >> %% @end > > find_index(List, Element, Option) -> [Index] > find_index(List, Element) = [Index] > > Option = only_first | only_last | [every] The distinction between ELEM_index (seek an element) and FIND_index (seek anything satisfying a predicate) is important, so it would be a great pity to use the wrong name here. There doesn't seem to be any point in putting square brackets around 'every', and the option names might as well be single syllables: Option = first | last | all So we'd have find_index(Predicate, List, Wanted) -> [Index] find_index(Predicate, List) -> [Index] elem_index(Element, List, Wanted) -> [Index] elem_index(Element, List) -> [Index] The argument order would then be compatible both with the Haskell versions and, more importantly, with member/2: member(Element, List) -> elem_index(Element, List) =/= []. I like the fact that you can briefly get the index if you are certain that there is one using hd(elem_index(E, L)), with a runtime check happening in case you were wrong. As a general design principle, I'm not that thrilled with function arguments that say which of several functions you *really* meant to call. They have their place in languages with very weak modularisation, but in a language like Erlang, it just feels wrong. I always find myself wondering what other option values there might have been and then being annoyed that they don't exist. When implementing such a thing, I usually find myself writing all the special case functions anyway, and wondering why they weren't just exported in the first place. One reason is that the option might be computed at run time, but is that really a live issue here? I wonder if we might find some sort of intermediate place between "you are left to cope by yourself" and "here is everything you might possibly need in the library". Just a plain text file with a whole lot of example functions that people have noted as being useful, so that you don't have to invent them, but that are not part of the supported library, so the Erlang/OTP team don't have to document and maintain them? is an Erlang cook block functions you r From ok@REDACTED Fri Nov 28 00:02:39 2008 From: ok@REDACTED (Richard O'Keefe) Date: Fri, 28 Nov 2008 12:02:39 +1300 Subject: [erlang-questions] Additions to lists module In-Reply-To: <3dbc6d1c0811270300m658a97b3i45f56983153a08a5@mail.gmail.com> References: <492D4A39.5050105@gmail.com> <0AF8FE8D-47DA-4C3E-8A79-99463D45986D@cs.otago.ac.nz> <3dbc6d1c0811270300m658a97b3i45f56983153a08a5@mail.gmail.com> Message-ID: On 28 Nov 2008, at 12:00 am, Robert Virding wrote: > Re names of functions, lists is probably not an example of good > naming conventions. Why there are no separated_names I can't > remember, most likely it just happened and the local convention was > just continued. The names for many of the higher order functions > came from Haskell or similar and there they did not use > separated_names. It is not a convention that need be followed. Haskell usage is baStudlyCaps. So it is true that the Haskell models for some of these functions did not use separated_names, but it is not true that Haskell uses or ever used runonwords. For example, it's "takeWhile" in Haskell, not "takewhile". From n39052@REDACTED Fri Nov 28 01:01:11 2008 From: n39052@REDACTED (Sergey A.) Date: Thu, 27 Nov 2008 16:01:11 -0800 Subject: [erlang-questions] Why is setting socket options by setopts()better than by listen()? In-Reply-To: <200811270725.mAR7PAKn019141@mail.pharos-avantgard.com> References: <3bff71aa0811261245r211c15eft979e7dbcefa68db9@mail.gmail.com> <200811270725.mAR7PAKn019141@mail.pharos-avantgard.com> Message-ID: <3bff71aa0811271601s269a8022s9f50028ab276a62b@mail.gmail.com> Hello. 2008/11/26 Valentin Micic : > I wouldn't say better... I think it is more a question of semantic: one is > used to set/change default parameters, whilst another to inform driver about > specific connection behavior. > Thanks for your answer, Valentin. It was helpful to me =) -- Sergey. From jlprasantha@REDACTED Fri Nov 28 08:31:38 2008 From: jlprasantha@REDACTED (prasantha kumara) Date: Fri, 28 Nov 2008 13:01:38 +0530 Subject: [erlang-questions] how to call erlang function from c Message-ID: i tried to call erlang function and print the value sent from the c function.i could sent a massage from the c side. but in erland node oit prits as Got invalid data on distribution channel, offending packet is: <<112,131,104,4,97,6,103,100,0,5,46,78,61,246,5,0,0,0,3,0,0,29,152,1,100,0,0,100,0,8,190,158,5,8,40,14,244,183,38,159,5,8,0,0>> pl can any one help me to overcome this mattter. thanks prasantha -------------- next part -------------- An HTML attachment was scrubbed... URL: From jlprasantha@REDACTED Fri Nov 28 13:30:45 2008 From: jlprasantha@REDACTED (prasantha kumara) Date: Fri, 28 Nov 2008 18:00:45 +0530 Subject: [erlang-questions] bad rpc Message-ID: Hi all, i wrote a program in c to call the erlang functtion . my erlang program is sork fine when i runit seperately. but when i tried to get the vallue through the c programe it prits the foolowing statement which was the output tupple of the erl_rpc(). badrpc{badrpc,{'EXIT',{badarg,[{erlang,apply,[complexrpc,print,{cnode,7}]},{rpc,'-handle_call/3-fun-0-',5}]}}}?h my c programe is as follow /* cnode_c.c */ #include #include //#include #include #include "erl_interface.h" #include "ei.h" //#define BUFSIZE 1000 int main(int argc, char **argv) { int fd; erlang_msg massage; fd; int n = 0; ei_cnode ec; erl_init(NULL, 0); if (erl_connect_init(1, "secretcookie", 0) == -1) erl_err_quit("erl_connect_init"); if ((fd = erl_connect("e1@REDACTED")) < 0) erl_err_quit("erl_connect"); fprintf(stderr, "Connected to ei@REDACTED\n\r"); if (fd<0){ } else { printf("hi erlang world"); } char* server_name; server_name="e1@REDACTED"; ETERM *fromp, *tuplep, *fnp, *argp, *resp; char *mod, *fun; ETERM *args; mod="complexrpc"; fun="print"; args = erl_format("{cnode, ~i}", 7); fnp = erl_element(1,erl_rpc(fd,mod,fun , args)); erl_print_term(stderr,fnp); printf("hello"); erl_print_term(stderr,erl_rpc(fd,mod,fun , args)); } can anyone help me to fix this matter . thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From vladdu55@REDACTED Fri Nov 28 13:42:27 2008 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Fri, 28 Nov 2008 13:42:27 +0100 Subject: [erlang-questions] bad rpc In-Reply-To: References: Message-ID: <95be1d3b0811280442p57a93ff1x7ac69058fc6be6b@mail.gmail.com> Hi! 2008/11/28 prasantha kumara : > args = erl_format("{cnode, ~i}", 7); The documentation for erl_rpc says that args is an Erlang list, containing the arguments to be passed to the function. So in your case it should be args = erl_format("[{cnode, ~i}]", 7); regards, Vlad From zoltan.peter.toth@REDACTED Fri Nov 28 14:13:00 2008 From: zoltan.peter.toth@REDACTED (Zoltan Peter Toth) Date: Fri, 28 Nov 2008 14:13:00 +0100 Subject: [erlang-questions] clarify: multi-threaded make Message-ID: <492FEE5C.6010307@ericsson.com> Hi, Is the multithreaded make (i.e. make -j N) for the OTP source meant to work, or did it just happen to work for me ? (Difference with R12B-5: make -j 2: user 443.04 sys 25.94 make: user 1096.51 sys 62.72 ... on a single core machine.) Please someone from OTP, make a statement on this. Thx, /Zoltan From bgustavsson@REDACTED Fri Nov 28 15:45:16 2008 From: bgustavsson@REDACTED (Bjorn Gustavsson) Date: Fri, 28 Nov 2008 15:45:16 +0100 Subject: [erlang-questions] clarify: multi-threaded make In-Reply-To: <492FEE5C.6010307@ericsson.com> References: <492FEE5C.6010307@ericsson.com> Message-ID: <6672d0160811280645t375b4d8cga433a256a2ce3752@mail.gmail.com> On Fri, Nov 28, 2008 at 2:13 PM, Zoltan Peter Toth wrote: > Hi, > > Is the multithreaded make (i.e. make -j N) for the OTP source meant to work, > or did it just happen to work for me ? It probably just happened to work for you. :-) As far as I know, our Makefiles makes assumption about build order that in general are not safe with the -j option. We might fix this in the R13 release, as we plan to do some other major changes to our Makefiles. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From kostis@REDACTED Fri Nov 28 16:07:00 2008 From: kostis@REDACTED (Kostis Sagonas) Date: Fri, 28 Nov 2008 17:07:00 +0200 Subject: [erlang-questions] clarify: multi-threaded make In-Reply-To: <6672d0160811280645t375b4d8cga433a256a2ce3752@mail.gmail.com> References: <492FEE5C.6010307@ericsson.com> <6672d0160811280645t375b4d8cga433a256a2ce3752@mail.gmail.com> Message-ID: <49300914.5090408@cs.ntua.gr> Bjorn Gustavsson wrote: > On Fri, Nov 28, 2008 at 2:13 PM, Zoltan Peter Toth > wrote: >> Hi, >> >> Is the multithreaded make (i.e. make -j N) for the OTP source meant to work, >> or did it just happen to work for me ? > > It probably just happened to work for you. :-) Zoltan: consider yourself VERY lucky today. > As far as I know, our Makefiles makes assumption about build order > that in general are not safe with the -j option. My experience with "make -j" has generally been pretty bad. I would not recommend it to anyone at this point. Kostis From ahmed.nawras@REDACTED Fri Nov 28 16:09:50 2008 From: ahmed.nawras@REDACTED (Ahmed Ali) Date: Fri, 28 Nov 2008 19:09:50 +0400 Subject: [erlang-questions] logging with email output In-Reply-To: <52220f230811201402r470ebebdodd1ca24ee5c79d5b@mail.gmail.com> References: <52220f230811201345i6f84c23bi299586a7dcfa9f4b@mail.gmail.com> <14f0e3620811201354kc2b5152te7791d8063a262b3@mail.gmail.com> <52220f230811201402r470ebebdodd1ca24ee5c79d5b@mail.gmail.com> Message-ID: Hi Adam, Log4erl doesn't have an email logger yet. Currently, I'm working on producing a stable API and getting the basics right (e.g. log format, performance...etc) and multiple log_appenders are next. However, it's not hard to add email_appender to the 0.8 version of Log4erl. If you're currently using log4erl and interested in having this feature, I can speed the process up for you. Anyways, this will be added to features pipeline. If you implemented this using the standard erlang error_logger, please share the code with us. Best regards, Ahmed Al-Issaei. On Fri, Nov 21, 2008 at 2:02 AM, Adam Duston wrote: > Thanks, I've seen this before. Allow me to ask the question in a > different way. Suppose you deploy an application, and there is a bug > that only appears under certain circumstances. The circumstances don't > occur for the first few days, but then the number of users increases > and a gen_server starts crashing every few minutes, each time getting > restarted by the supervisor. This could happen, for example, if there > is a situation that produces deadlock and gen_server calls start > timing out. Of course, each time a message is written to the SASL log. > Am I expected to use rb to read through the SASL log on a daily basis? > I can't imagine that I'm the first one facing this problem. How have > people dealt with this in the past? > > Thanks again, > Adam > > On Thu, Nov 20, 2008 at 3:54 PM, Gleb Peregud wrote: >> There's a log4j clone for Erlang: >> >> http://code.google.com/p/log4erl/ >> >> But it seems it does not have a email logger, though it shouldn't be >> too hard to write one, >> >> BR >> >> On 11/20/08, Adam Duston wrote: >>> In my Java application, I can use an email logging target with log4j >>> and then, when an exception occurs, an email is politely delivered to >>> my inbox. In my Erlang app, I'm logging info and errors using >>> error_logger. I would like to be notified by email when one of my >>> gen_servers trips badly enough to shutdown and get restarted by the >>> supervisor. What is the idiomatic way to do this? >>> >>> Thanks, >>> Adam >>> >>> -- >>> Founder, 8 Planes >>> adam@REDACTED >>> Skype: aduston >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://www.erlang.org/mailman/listinfo/erlang-questions >>> >> >> >> -- >> Gleb Peregud >> http://gleber.pl/ >> >> Every minute is to be grasped. >> Time waits for nobody. >> -- Inscription on a Zen Gong >> > > > > -- > Founder, 8 Planes > adam@REDACTED > Skype: aduston > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From ahmed.nawras@REDACTED Fri Nov 28 16:13:41 2008 From: ahmed.nawras@REDACTED (Ahmed Ali) Date: Fri, 28 Nov 2008 19:13:41 +0400 Subject: [erlang-questions] logging with email output In-Reply-To: <597c69660811201459m4257ab19j5a280fa6bc9ac0b6@mail.gmail.com> References: <52220f230811201345i6f84c23bi299586a7dcfa9f4b@mail.gmail.com> <597c69660811201459m4257ab19j5a280fa6bc9ac0b6@mail.gmail.com> Message-ID: Hi Attila, Thanks for sharing. Just a question though, what's the license for this code? Can I use it on log4erl? Best regards, Ahmed On Fri, Nov 21, 2008 at 2:59 AM, Attila Babo wrote: > We are using this email module in production, a simple SMTP client. > Works without a glitch after a few modifications, here you may find > the latest version: > http://www.trapexit.org/forum/viewtopic.php?p=44245 > > /Attila > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From david.koch@REDACTED Fri Nov 28 16:26:09 2008 From: david.koch@REDACTED (=?iso-8859-1?Q?david.koch@libertysurf.fr?=) Date: Fri, 28 Nov 2008 16:26:09 +0100 Subject: [erlang-questions] =?iso-8859-1?q?REF=3A_DHCP_server_in_inets_=28?= =?iso-8859-1?q?URGENT=29?= Message-ID: When a full dhcp server will be available as part of the inets module, side to http and (t)ftp ? I am also working on a PXE server in erlang, yet the dhcp part is confusing... David KOCH ---------------------- ALICE N?1 de la RELATION CLIENT 2008*-------------------- D?couvrez vite l'offre exclusive ALICE BOX! En cliquant ici http://abonnement.aliceadsl.fr Offre soumise ? conditions.*Source : TNS SOFRES / BEARING POINT. Secteur Fournisseur d.Acc?s Internet From babo.online@REDACTED Fri Nov 28 16:54:24 2008 From: babo.online@REDACTED (Attila Babo) Date: Fri, 28 Nov 2008 16:54:24 +0100 Subject: [erlang-questions] logging with email output In-Reply-To: References: <52220f230811201345i6f84c23bi299586a7dcfa9f4b@mail.gmail.com> <597c69660811201459m4257ab19j5a280fa6bc9ac0b6@mail.gmail.com> Message-ID: <597c69660811280754g1f96256fj303b38578697cb0@mail.gmail.com> > Thanks for sharing. Just a question though, what's the license for > this code? Can I use it on log4erl? Good question! The original version is from http://www.erlang.org/user.html#smtp_client-1.1 without any explicit licensing attached. We published all of our changes for a fair play but I have no idea about the legal background, ask a lawyer if your uncertain. If you do please share the answer with us! /Attila From kevin@REDACTED Fri Nov 28 16:56:14 2008 From: kevin@REDACTED (Kevin Scaldeferri) Date: Fri, 28 Nov 2008 10:56:14 -0500 Subject: [erlang-questions] clarify: multi-threaded make In-Reply-To: <49300914.5090408@cs.ntua.gr> References: <492FEE5C.6010307@ericsson.com> <6672d0160811280645t375b4d8cga433a256a2ce3752@mail.gmail.com> <49300914.5090408@cs.ntua.gr> Message-ID: On Nov 28, 2008, at 10:07 AM, Kostis Sagonas wrote: > > >> As far as I know, our Makefiles makes assumption about build order >> that in general are not safe with the -j option. > > My experience with "make -j" has generally been pretty bad. > I would not recommend it to anyone at this point. If you're talking specifically about OTP, I'll defer to your experience. But, in general, "make -j" works if you have correctly declared your dependencies in your Makefiles. I'd have to say that it puzzles me why you could "make assumptions about build order" when make provides exactly a language for being explicit about such things. -kevin From rtrlists@REDACTED Fri Nov 28 18:33:33 2008 From: rtrlists@REDACTED (Robert Raschke) Date: Fri, 28 Nov 2008 17:33:33 +0000 Subject: [erlang-questions] question: How can I confirm existence of a registered mbox on a Java node? Message-ID: <6a3ae47e0811280933x677fa8adua10d0c21e1ad9e7d@mail.gmail.com> Hi, I am starting a node using jinterface. Is there any easy way for my Erlang process to test if the OtpMbox with a name is ready for business? I can start my Java node like this: OtpNode node = new OtpNode("my_node@REDACTED", "MyCookie"); OtpMbox mbox = node.createMbox("mbox"); So, I can now send messages in Erlang using {mbox, 'my_node@REDACTED'} ! {self(), message} and that works fine. But I have a problem when first starting up. I can ping the node to see if it has been created, that's ok. But I cannot seem to figure out how to establish that 'mbox' on that node is ready to accept messages. As far as I can see, I can try sending a message at any time, and if it's not ready yet, the message goes into the ether. Is the only way to do this, by doing: wait_for_mbox() -> {mbox, 'my_node@REDACTED'} ! {self(), my_hand}, receive your_hand -> ok; after 10 wait_for_mbox() end. and have the Java bit shake hands at the beginning? Any pointers greatly appreciated, Robby From toby@REDACTED Fri Nov 28 18:55:18 2008 From: toby@REDACTED (Toby Thain) Date: Fri, 28 Nov 2008 12:55:18 -0500 Subject: [erlang-questions] clarify: multi-threaded make In-Reply-To: References: <492FEE5C.6010307@ericsson.com> <6672d0160811280645t375b4d8cga433a256a2ce3752@mail.gmail.com> <49300914.5090408@cs.ntua.gr> Message-ID: <64A910DC-2A18-4B41-AA62-AE0BF91F6D0F@telegraphics.com.au> On 28-Nov-08, at 10:56 AM, Kevin Scaldeferri wrote: > > On Nov 28, 2008, at 10:07 AM, Kostis Sagonas wrote: >> >> >>> As far as I know, our Makefiles makes assumption about build order >>> that in general are not safe with the -j option. >> >> My experience with "make -j" has generally been pretty bad. >> I would not recommend it to anyone at this point. > > If you're talking specifically about OTP, I'll defer to your > experience. But, in general, "make -j" works if you have correctly > declared your dependencies in your Makefiles. Kevin Absolutely correct. 'make -j' works fine when dependencies are correctly declared. I guess Kostis meant 'OTP makefiles are broken'. > I'd have to say that it > puzzles me why you could "make assumptions about build order" when > make provides exactly a language for being explicit about such things. :) --Toby > > > -kevin > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From ahmed.nawras@REDACTED Fri Nov 28 19:33:59 2008 From: ahmed.nawras@REDACTED (Ahmed Ali) Date: Fri, 28 Nov 2008 22:33:59 +0400 Subject: [erlang-questions] logging with email output In-Reply-To: <597c69660811280754g1f96256fj303b38578697cb0@mail.gmail.com> References: <52220f230811201345i6f84c23bi299586a7dcfa9f4b@mail.gmail.com> <597c69660811201459m4257ab19j5a280fa6bc9ac0b6@mail.gmail.com> <597c69660811280754g1f96256fj303b38578697cb0@mail.gmail.com> Message-ID: Hi, I will if I knew the answer :). But I'll not use it until I know. Best regards, Ahmed On Fri, Nov 28, 2008 at 7:54 PM, Attila Babo wrote: >> Thanks for sharing. Just a question though, what's the license for >> this code? Can I use it on log4erl? > Good question! The original version is from > http://www.erlang.org/user.html#smtp_client-1.1 without any explicit > licensing attached. We published all of our changes for a fair play > but I have no idea about the legal background, ask a lawyer if your > uncertain. If you do please share the answer with us! > > /Attila > From shomodj@REDACTED Fri Nov 28 20:31:41 2008 From: shomodj@REDACTED (Boris Shomodjvarac) Date: Fri, 28 Nov 2008 20:31:41 +0100 Subject: [erlang-questions] REF: DHCP server in inets (URGENT) In-Reply-To: References: Message-ID: <4930471D.8050806@gmail.com> david.koch@REDACTED wrote: > When a full dhcp server will be available as part > of the inets module, side to http and (t)ftp ? I > am also working on a PXE server in erlang, yet > the dhcp part is confusing... There is an dhcp server in erlang, it needs some work, some IP4 functions are missing from newest OTP release, but I think most of basic RFC is implemented. http://code.google.com/p/erlang-dhcp-server/ -- "A language that doesn't affect the way you think about programming, is not worth knowing" - Alan Perlis From david.koch@REDACTED Fri Nov 28 21:38:26 2008 From: david.koch@REDACTED (=?iso-8859-1?Q?david.koch@libertysurf.fr?=) Date: Fri, 28 Nov 2008 21:38:26 +0100 Subject: [erlang-questions] =?iso-8859-1?q?_Re=3A__REF=3A_DHCP_server_in_i?= =?iso-8859-1?q?nets_=28URGENT=29?= Message-ID: I am aware of this version, but I meant about an official implementation that would follow the whole RFC. Would you like to work with Ericsson's internal staff to merge this project into inets and complete it ? Until then I'll give it a try, crossing my fingers it would work flawlessly ! David KOCH ---------- Initial Header ----------- From : Boris Shomodjvarac To : "david.koch@REDACTED" , erlang-questions@REDACTED Cc : Date : Fri, 28 Nov 2008 20:31:41 +0100 Subject : Re: [erlang-questions] REF: DHCP server in inets (URGENT) david.koch@REDACTED wrote: > When a full dhcp server will be available as part > of the inets module, side to http and (t)ftp ? I > am also working on a PXE server in erlang, yet > the dhcp part is confusing... There is an dhcp server in erlang, it needs some work, some IP4 functions are missing from newest OTP release, but I think most of basic RFC is implemented. http://code.google.com/p/erlang-dhcp-server/ -- "A language that doesn't affect the way you think about programming, is not worth knowing" - Alan Perlis ---------------------- ALICE N?1 de la RELATION CLIENT 2008*-------------------- D?couvrez vite l'offre exclusive ALICE BOX! En cliquant ici http://abonnement.aliceadsl.fr Offre soumise ? conditions.*Source : TNS SOFRES / BEARING POINT. Secteur Fournisseur d.Acc?s Internet From taavi@REDACTED Fri Nov 28 22:44:17 2008 From: taavi@REDACTED (Taavi Talvik) Date: Fri, 28 Nov 2008 23:44:17 +0200 Subject: [erlang-questions] REF: DHCP server in inets (URGENT) In-Reply-To: References: Message-ID: <760F509B-28E5-427C-A6D0-96F033B4A9F6@uninet.ee> On Nov 28, 2008, at 10:38 PM, david.koch@REDACTED wrote: > I am aware of this version, but I meant about an > official implementation that would follow the > whole RFC. Would you like to work with Ericsson's > internal staff to merge this project into inets > and complete it ? Until then I'll give it a try, > crossing my fingers it would work flawlessly ! There is no such thing as dhcp implementation, which follows whole RFC. It is just impossible task. DHCP specification is just so ambiguous. Little bit in http://bgp.potaroo.net/ietf/idref/draft-ietf-dhc-implementation/ Be prepared to adapt whatever available reference implementation to your specific requirements and specific clients. I have written fault tolerant erlang dhcp server for xDSL address assingnment serving ~10k clients and have been through the pain.. There are peculiar clients.. There are misbehaving clients not satisfied with perfectly standard compliant responses and flooding server.. Anyway.. Erlang was/is create tool for writing this stuff. Ca. 12kLOC vs. isc 117kLOC. best regards, taavi From ggaliens@REDACTED Fri Nov 28 20:54:41 2008 From: ggaliens@REDACTED (ggaliens@REDACTED) Date: Fri, 28 Nov 2008 14:54:41 -0500 Subject: [erlang-questions] When does ERLC provide minmal feedback? Message-ID: <20081128195442.PICVD.88524.root@cdptpa-web24-z02> When does ERLC provide minimal feedback? I am compiling parts of Wings3D graphical application. Sometimes ERLC seems to compile (no errors no warns) and no .beam generated. Sometimes a warning such as Error1 and Error2. Is there some way I can force the compiler to give me more instructive feedback ??? 'm afraid I'm getting these for some more gross reason such as bad line delimiters ... bad white-space or invisible character or something like that. Any helpful hints that can get me back to proper sleuthing techniques ???? Are there any know gotchas that I can watch out for ??? From richardc@REDACTED Sat Nov 29 13:00:46 2008 From: richardc@REDACTED (Richard Carlsson) Date: Sat, 29 Nov 2008 13:00:46 +0100 Subject: [erlang-questions] When does ERLC provide minmal feedback? In-Reply-To: <20081128195442.PICVD.88524.root@cdptpa-web24-z02> References: <20081128195442.PICVD.88524.root@cdptpa-web24-z02> Message-ID: <49312EEE.10905@it.uu.se> ggaliens@REDACTED wrote: > When does ERLC provide minimal feedback? > > I am compiling parts of Wings3D graphical application. > > Sometimes ERLC seems to compile (no errors no warns) and no .beam > generated. Sometimes a warning such as Error1 and Error2. > > Is there some way I can force the compiler to give me more > instructive feedback ??? > > 'm afraid I'm getting these for some more gross reason such as bad > line delimiters ... bad white-space or invisible character or > something like that. Some details would be nice, such as: - a specific source file that does not seem to work - the exact command line used to compile it - the exact text for the errors/warnings you are getting - Unix or Windows? - are you using a makefile or running the command manually? /Richard From bgustavsson@REDACTED Sat Nov 29 16:05:05 2008 From: bgustavsson@REDACTED (Bjorn Gustavsson) Date: Sat, 29 Nov 2008 16:05:05 +0100 Subject: [erlang-questions] When does ERLC provide minmal feedback? In-Reply-To: <20081128195442.PICVD.88524.root@cdptpa-web24-z02> References: <20081128195442.PICVD.88524.root@cdptpa-web24-z02> Message-ID: <6672d0160811290705r8179ef8s4009eb710676988@mail.gmail.com> On Fri, Nov 28, 2008 at 8:54 PM, wrote: > When does ERLC provide minimal feedback? > > I am compiling parts of Wings3D graphical application. > > Sometimes ERLC seems to compile (no errors no warns) and no .beam generated. > Sometimes a warning such as Error1 and Error2. > > Is there some way I can force the compiler to give me more instructive feedback ??? > > 'm afraid I'm getting these for some more gross reason such as bad line delimiters ... bad white-space or invisible character or something like that. > > Any helpful hints that can get me back to proper sleuthing techniques ???? > > Are there any know gotchas that I can watch out for ??? It is not a known problem to me. You can use the option +time to have the compiler print out a line for each compiler pass. The name of the last pass should be "save_binary" if everything works as it should. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From ggaliens@REDACTED Sat Nov 29 15:22:57 2008 From: ggaliens@REDACTED (ggaliens@REDACTED) Date: Sat, 29 Nov 2008 9:22:57 -0500 Subject: [erlang-questions] When does ERLC provide minmal feedback? In-Reply-To: <49312EEE.10905@it.uu.se> Message-ID: <20081129142257.2XMHQ.93203.root@cdptpa-web27-z01> OK ... here's the info I should have provided last time around. ERLC is crashing in odd ways when I run one of the main makefiles from a commandline as follows ... markw@REDACTED /cygdrive/c/WingsSVN/src $ make make TYPE=opt common make[1]: Entering directory `/cygdrive/c/WingsSVN/src' erlc -pa ../../esdl-0.96.0626/ebin -I ../../esdl-0.96.0626/esdl/include -I ../../esdl-0.96.0626 -I ../e3d -W +debug_info '-Dwi ngs_version="0.99.52"' -pa ../intl_tools -o../ebin wings_lang.erl erlc -pa ../../esdl-0.96.0626/ebin -I ../../esdl-0.96.0626/esdl/include -I ../../esdl-0.96.0626 -I ../e3d -W +debug_info '-Dwi ngs_version="0.99.52"' -pa ../intl_tools -o../ebin user_default.erl erlc -pa ../../esdl-0.96.0626/ebin -I ../../esdl-0.96.0626/esdl/include -I ../../esdl-0.96.0626 -I ../e3d -W +debug_info '-Dwi ngs_version="0.99.52"' -pa ../intl_tools -o../ebin wings.erl The odd thing is that this works in a slightly older code base tree (two years old). The compile appears to HANG when compiling wings.erl ---- Richard Carlsson wrote: > ggaliens@REDACTED wrote: > > When does ERLC provide minimal feedback? > > > > I am compiling parts of Wings3D graphical application. > > > > Sometimes ERLC seems to compile (no errors no warns) and no .beam > > generated. Sometimes a warning such as Error1 and Error2. > > > > Is there some way I can force the compiler to give me more > > instructive feedback ??? > > > > 'm afraid I'm getting these for some more gross reason such as bad > > line delimiters ... bad white-space or invisible character or > > something like that. > > Some details would be nice, such as: > - a specific source file that does not seem to work > - the exact command line used to compile it > - the exact text for the errors/warnings you are getting > - Unix or Windows? > - are you using a makefile or running the command manually? > > /Richard From erlang@REDACTED Sat Nov 29 18:12:13 2008 From: erlang@REDACTED (Dominic Williams) Date: Sat, 29 Nov 2008 18:12:13 +0100 Subject: [erlang-questions] Paris ErlLounge Message-ID: <493177ED.703@dominicwilliams.net> Hello, We are holding an ErlLounge in Paris on Monday 8th December, starting 7.30pm, at: L'Escalier 105, Rue du Faubourg Saint Denis 75010 Paris Everyone is welcome! Regards, Dominic Williams. From qiulang@REDACTED Sun Nov 30 16:50:48 2008 From: qiulang@REDACTED (lang qiu) Date: Sun, 30 Nov 2008 23:50:48 +0800 Subject: [erlang-questions] Why we need to use make_ref in pmap ? Message-ID: Hi all, Why we need to use make_ref/0 in pmap ? To be exact, why we need to use make_ref in the gather/2, gather([Pid|T], Ref) -> receive {Pid, Ref, Ret} -> [Ret|gather(T, Ref)] end; Can't we just use gather/1, gather([Pid|T]) -> receive {Pid, Ret} -> [Ret|gather(T)] end; Thanks ! Qiulang -------------- next part -------------- An HTML attachment was scrubbed... URL: From matthew@REDACTED Sun Nov 30 22:56:24 2008 From: matthew@REDACTED (Matthew Dempsky) Date: Sun, 30 Nov 2008 13:56:24 -0800 Subject: [erlang-questions] Why we need to use make_ref in pmap ? In-Reply-To: References: Message-ID: 2008/11/30 lang qiu : > Why we need to use make_ref/0 in pmap ? To be exact, why we need to use > make_ref in the gather/2, The process calling pmap might also receive messages of the form {Pid, Something} and then these could be mistaken for a pmap result message. References are "almost unique", so including one in the message format makes it almost impossible to make this mistake. From vances@REDACTED Sun Nov 30 23:24:49 2008 From: vances@REDACTED (Vance Shipley) Date: Sun, 30 Nov 2008 17:24:49 -0500 Subject: [erlang-questions] Why we need to use make_ref in pmap ? In-Reply-To: References: Message-ID: <20081130222448.GB8320@h216-235-12-168.host.egate.net> Qiulang, The reference() value is passed with the query to be included in the response so that you may distinguish the answers from each other and from other messages which might have the same pattern. -Vance On Sun, Nov 30, 2008 at 11:50:48PM +0800, lang qiu wrote: } Why we need to use make_ref/0 in pmap ? To be exact, why we need to use } make_ref in the gather/2, } } gather([Pid|T], Ref) -> } receive } {Pid, Ref, Ret} -> [Ret|gather(T, Ref)] } end; } } Can't we just use gather/1, } } gather([Pid|T]) -> } receive } {Pid, Ret} -> [Ret|gather(T)] } end;