From chaitanya.chalasani@REDACTED Sun Mar 1 02:44:23 2009 From: chaitanya.chalasani@REDACTED (CHAITANYA CHALASANI) Date: Sun, 1 Mar 2009 07:14:23 +0530 Subject: [erlang-questions] erlang flagship product In-Reply-To: <9b08084c0902250717i7212f33fj73c7a0cb8bad2e32@mail.gmail.com> References: <3e6f9520-f8cd-48f2-8ebf-1729538d1842@e24g2000vbe.googlegroups.com> <44ed5e0f0902240838h4707e91cnee4dce59485cbafe@mail.gmail.com> <87ocwrpyiv.fsf@sterlett.hq.kred> <4d08db370902240925u52d6f17cledb5416813c0fdc3@mail.gmail.com> <769685.50188.qm@web65512.mail.ac4.yahoo.com> <291863.53837.qm@web111416.mail.gq1.yahoo.com> <672672.39511.qm@web65516.mail.ac4.yahoo.com> <9b08084c0902250717i7212f33fj73c7a0cb8bad2e32@mail.gmail.com> Message-ID: In this contest, we have a telecom VAS solution for prepaid roaming which is built in Erlang. The product was developed by not more than 3 developers at any phase (development, sustain engineering, upgrades). The product is the technology enabler for the "One Network - the first borderless roaming solution that spawns across more than 18 countries in Africa and Middle east". A very successful product in use since last 5 years. Its sheer parallel processing and hot code loading capability that makes us have a buying from the management. On Wed, Feb 25, 2009 at 8:47 PM, Joe Armstrong wrote: > On Wed, Feb 25, 2009 at 1:24 PM, Richard Andrews wrote: >> >>> That said, I wouldn't mind other solid examples either. There are, of course, >>> successful projects and companies, > > So what do you mean by successful ?? > > Does successful "made $$$" using Erlang? > Does it mean "delivered on time" using Erlang? > Does it mean they have a big 100 man project using Erlang > Does it mean the project had thousands of lines of code and no errors? > > etc. > > If you mean $'s then at what value do you call something a success? > > We have loads of "successes" measured on these different scales - > brilliant work done by > small groups (ejabberd was a one-man project) - if you're looking for > the BIG projects > you won't find many because you don't need many Erlang programmers to > do a lot of > stuff. > > So a measure of success might even be "required very few programmers" > - but if this were the > case the success would not get much publicity. > > We have all these couchDB's and ejabberds and ?scalaris and yaws and > rabbit MQ all done by > small groups. > > Most successful projects are "do something" ... "get lucky" - we can > control the "do something" bit > but the rest is out of our control - if we get lots of people doing > Erlang then the probabily than > we can demonstrat esuccessful projects ?should increase > >>> ?but not as easy to reference. If you just >>> want a well-known, respected product/project to point at, how about ejabberd? >> >> Good example. >> It's medium size. Solid. Reasonably well known in software circles. >> >> IMO to get more people into FP we need to show its applicability to small to medium sized projects (like ejabberd). Most projects start off with modest ambitions. >> >> More examples? > > http://www.onscale.eu/scalaris.html > > Little know - prizewinning - brilliant - widely applicable - if every > erlang user put a scalaris node > on their machine we could build amazing systems! > > /Joe Armstrong > > >> >> >> ? ? ?Stay connected to the people that matter most with a smarter inbox. Take a look http://au.docs.yahoo.com/mail/smarterinbox >> _______________________________________________ >> 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 > -- Chaitanya Chalasani Linux User: 410931 From cktan@REDACTED Sun Mar 1 10:45:53 2009 From: cktan@REDACTED (C K Tan) Date: Sun, 1 Mar 2009 01:45:53 -0800 Subject: [erlang-questions] open_pipe({spawn, "cat"}) --- how to close stdin of cat? Message-ID: <550290900903010145gce0cfb1t1a035240c9719d42@mail.gmail.com> Hi all, I am tryinng to use port to open a program that reads until EOF from stdin, and then write results to stdout ... i.e. something like the unix wc command. I can't figure out how to close the stdin of the spawned process: wc(InputText) -> P = open_port({spawn, "wc"}, [stream, exit_status, use_stdio, stderr_to_stdout, in, out, eof]), P ! {self(), {command, "hello world"}}, P ! {self(), {eof}}, %% ERROR -- how to close stdin of the cat process? receive {P, X} -> X end. Also, where can I find detailed documentation on open_port? Appreciate any help. Thanks, -cktan From ahmed.nawras@REDACTED Sun Mar 1 10:56:58 2009 From: ahmed.nawras@REDACTED (Ahmed Ali) Date: Sun, 1 Mar 2009 13:56:58 +0400 Subject: [erlang-questions] logging with email output In-Reply-To: References: <52220f230811201345i6f84c23bi299586a7dcfa9f4b@mail.gmail.com> <597c69660811201459m4257ab19j5a280fa6bc9ac0b6@mail.gmail.com> <597c69660811280754g1f96256fj303b38578697cb0@mail.gmail.com> Message-ID: Hi, It's better to be late than never. The latest log4erl includes an smtp_appender which uses smtp_client written by Michael Bradford and updated by Attila Babo. The latest version (0.8.4) can be downloaded from github's (http://github.com/ahmednawras/log4erl) or google code (http://code.google.com/p/log4erl). Please send all feedbacks to me. Best regards, Ahmed Al-Issaei On Fri, Nov 28, 2008 at 10:33 PM, Ahmed Ali wrote: > 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 mjtruog@REDACTED Sun Mar 1 11:18:14 2009 From: mjtruog@REDACTED (Michael Truog) Date: Sun, 01 Mar 2009 02:18:14 -0800 Subject: [erlang-questions] open_pipe({spawn, "cat"}) --- how to close stdin of cat? In-Reply-To: <550290900903010145gce0cfb1t1a035240c9719d42@mail.gmail.com> References: <550290900903010145gce0cfb1t1a035240c9719d42@mail.gmail.com> Message-ID: <49AA60E6.3030604@gmail.com> You normally never try to close stdin on the port. You can close stdin on the port by calling erlang:port_close/1 but you won't be able to receive on the port after you close it. You should be able to use a read within the port program that does not depend on eof to terminate the data (see http://erlang.org/doc/tutorial/part_frame.html by the Ports section). The documentation for erlang:open_port/2 is at http://erlang.org/doc/man/erlang.html . The system commands without a module name are within the erlang module. Consider using erlang:port_command/2 rather than using ! directly, for better behavior. - Michael C K Tan wrote: > Hi all, > > I am tryinng to use port to open a program that reads until EOF from > stdin, and then write results to stdout ... i.e. something like the > unix wc command. I can't figure out how to close the stdin of the > spawned process: > > wc(InputText) -> > P = open_port({spawn, "wc"}, [stream, exit_status, use_stdio, > stderr_to_stdout, in, out, eof]), > P ! {self(), {command, "hello world"}}, > P ! {self(), {eof}}, %% ERROR -- how to close stdin of the cat process? > receive {P, X} -> X end. > > Also, where can I find detailed documentation on open_port? > > Appreciate any help. > > Thanks, > -cktan > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > From cktan@REDACTED Sun Mar 1 11:48:36 2009 From: cktan@REDACTED (C K Tan) Date: Sun, 1 Mar 2009 02:48:36 -0800 Subject: [erlang-questions] open_pipe({spawn, "cat"}) --- how to close stdin of cat? In-Reply-To: <49AA60E6.3030604@gmail.com> References: <550290900903010145gce0cfb1t1a035240c9719d42@mail.gmail.com> <49AA60E6.3030604@gmail.com> Message-ID: <550290900903010248t53457f6ala137a25a788e6626@mail.gmail.com> Michael, Without closing stdin of wc, wc never returns because it thought there are more data coming. wc(InputText) -> P = open_port({spawn, "wc"}, [stream, exit_status, use_stdio, stderr_to_stdout, in, out, eof]), port_command(P, InputText), %% P ! {self(), {eof}}, %% ERROR -- how to close stdin of the wc process? receive {P, X} -> X end, port_close(P). wc("hello world"). %% blocks forever. On Sun, Mar 1, 2009 at 2:18 AM, Michael Truog wrote: > You normally never try to close stdin on the port. ?You can close stdin on > the port by calling erlang:port_close/1 but you won't be able to receive on > the port after you close it. ?You should be able to use a read within the > port program that does not depend on eof to terminate the data (see > http://erlang.org/doc/tutorial/part_frame.html by the Ports section). > > The documentation for erlang:open_port/2 is at > http://erlang.org/doc/man/erlang.html . ?The system commands without a > module name are within the erlang module. ?Consider using > erlang:port_command/2 rather than using ! directly, for better behavior. > > - Michael > > C K Tan wrote: >> >> Hi all, >> >> I am tryinng to use port to open a program that reads until EOF from >> stdin, and then write results to stdout ... i.e. something like the >> unix wc command. I can't figure out how to close the stdin of the >> spawned process: >> >> wc(InputText) -> >> ? ?P = open_port({spawn, "wc"}, [stream, exit_status, use_stdio, >> ? ? ? ? ? ? ? ? ? ? ? ? ? ?stderr_to_stdout, in, out, eof]), >> ? ?P ! {self(), {command, "hello world"}}, >> ? ?P ! {self(), {eof}}, ? %% ERROR -- how to close stdin of the cat >> process? >> ? ?receive {P, X} -> X end. >> >> Also, where can I find detailed documentation on open_port? >> >> Appreciate any help. >> >> Thanks, >> -cktan >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> >> > > From als@REDACTED Sun Mar 1 14:49:28 2009 From: als@REDACTED (Anthony Shipman) Date: Mon, 2 Mar 2009 00:49:28 +1100 Subject: [erlang-questions] =?iso-8859-1?q?open=5Fpipe=28=7Bspawn=2C_=22ca?= =?iso-8859-1?q?t=22=7D=29_---_how_to_close_=09stdin_of_cat=3F?= In-Reply-To: <550290900903010248t53457f6ala137a25a788e6626@mail.gmail.com> References: <550290900903010145gce0cfb1t1a035240c9719d42@mail.gmail.com> <49AA60E6.3030604@gmail.com> <550290900903010248t53457f6ala137a25a788e6626@mail.gmail.com> Message-ID: <200903020049.28109.als@iinet.net.au> On Sun, 1 Mar 2009 09:48:36 pm C K Tan wrote: > Michael, > > Without closing stdin of wc, wc never returns because it thought there > are more data coming. > > wc(InputText) -> > ? ?P = open_port({spawn, "wc"}, [stream, exit_status, use_stdio, > ? ? ? ? ? ? ? ? ? ? ? ? ? ?stderr_to_stdout, in, out, eof]), > ? ?port_command(P, InputText), > ? ?%% P ! {self(), {eof}}, ? %% ERROR -- how to close stdin of the wc > process? receive {P, X} -> X end, > ? ?port_close(P). What I have done is use an intermediate shell script. I write EOF or some similar marker to the port and the shell script closes the stdin for the command it controls. -- Anthony Shipman Mamas don't let your babies als@REDACTED grow up to be outsourced. From jeedward@REDACTED Sun Mar 1 21:22:05 2009 From: jeedward@REDACTED (Ed) Date: Sun, 1 Mar 2009 12:22:05 -0800 (PST) Subject: [erlang-questions] IICAI-09 Call for papers Message-ID: <171944.15028.qm@web45902.mail.sp1.yahoo.com> IICAI-09 Call for papers ? The 4th Indian International Conference on Artificial Intelligence (IICAI-09) will be held in Tumkur (near Bangalore), India during December 16-18 2009. The conference consists of paper presentations, special workshops, sessions, invited talks and local tours, etc.? We invite draft paper submissions. Please see the website: http://www.iiconference.org ??for more details of the conference. ? Sincerely ? ? Edward Publicity Committee ? -------------- next part -------------- An HTML attachment was scrubbed... URL: From raould@REDACTED Mon Mar 2 01:49:33 2009 From: raould@REDACTED (Raoul Duke) Date: Sun, 1 Mar 2009 16:49:33 -0800 Subject: [erlang-questions] model checking concurrency? Message-ID: <91a2ba3e0903011649v1a8916b4rb39ae40448a929cf@mail.gmail.com> i'm just trying to get up to speed on what folks have done with model checking concurrency, with an eye to erlang in particular. the Opis paper is quite interesting. http://perso.eleves.bretagne.ens-cachan.fr/~dagand/opis/ -- i have to read up on McErlang and etomcrl and learn what they've done wrt concurrency in particular (e.g. showing deadlock freedom or what have-you). has anybody used concurrency skeletons in erlang? i haven't hit anything yet googling. sincerely. From ok@REDACTED Mon Mar 2 05:10:00 2009 From: ok@REDACTED (Richard O'Keefe) Date: Mon, 2 Mar 2009 17:10:00 +1300 Subject: [erlang-questions] The Beauty of Erlang Syntax In-Reply-To: References: <3e6f9520-f8cd-48f2-8ebf-1729538d1842@e24g2000vbe.googlegroups.com> <22226430.post@talk.nabble.com> <9b08084c0902260808hf9903b1yb0aa072e7e503160@mail.gmail.com> <22230905.post@talk.nabble.com> <57400D87-A249-43E9-A640-66C87A255EFB@scaldeferri.com> <22233815.post@talk.nabble.com> <22234312.post@talk.nabble.com> Message-ID: <03AC2453-CD01-4D15-A9A0-17C015F7F2AB@cs.otago.ac.nz> On 27 Feb 2009, at 3:50 pm, Steve Davis wrote: > Took a quick look at that link to "queue magazine", and they seemed to > be scratching around a bit to find reasons to pad out their list... My impression too. > > > First was... > > " Concurrency more appropriate to synchronized parallel execution" > > I guess that sounds good. But I'd need to see an example of what the > author actually means to understand and make any judgment as to > whether it's actually true. It probably means SSE instructions, or the kind of stuff you'd use CUDA for. > > > "? Code requiring an aggressive compiler (Erlang entries in language > benchmark shoot-outs are unimpressive ? except for process spawning > and message passing) " > > Does he mean "serial performance" here. If so see below, as this is at > the heart of most of the list items. > > "? Floating-point-intensive code" > > Most code (in any language) isn't particularly "performance sensitive" > you gotta measure measure measure. Also, I think the author > specifically means "serial/linear code performance"... ok, but in > those rare bottlenecks (and they are rare) where beam/hipe are not > enough, there's always (easy to make) C ports for your escape > hatches. It's really true that Erlang likes to put floats in boxes, and this really is bad for floating-point-intensive code. Erlang might well be a great language to write a *correct* Linear Program solver in, but it certainly wouldn't be the language of choice for writing a *fast* one. But then, it would make engineering sense to ship your problem out to an existing solver and receive the results back anyway; really good LP solvers are hard enough to write that one would rather not. > > > "? Code requiring nonportable instructions " > > Why would you want this? *REQUIRING* when does code (rather than > managers/architects) *require* non-portability. See above: I've seen a galaxy simulation done (mostly) on an nVIDIA graphics processor. Really impressive. And if you need that kind of speed, you're not going to care that it won't port to my SunBlade 100. Rather than galaxy simulation, that author may have had games in mind. > "? Projects to implement libraries that must run under > other execution environments, such as JVM (Java Vir- > tual Machine) or CLR (Common Language Runtime) " > > I've noticed that Java isn't too good on CLR/Mono or on BEAM, and that > C# isn't so good on the JVM or BEAM. To be fair to C#, it _was_ designed to support multiple languages and _was_ revised after feedback from several non-C# groups, and it _does_ support F#. > > All in all, I find this list pretty unconvincing. I suspect it's there to prevent accusations of bias, to show that's the author's given _some_ thought to the idea that Erlang might not be the perfect language. From adam@REDACTED Mon Mar 2 08:32:15 2009 From: adam@REDACTED (Adam Lindberg) Date: Mon, 2 Mar 2009 07:32:15 +0000 (GMT) Subject: [erlang-questions] Erlunch in Stockholm on March 16th? In-Reply-To: <200902281606.25764.romain.lenglet@berabera.info> Message-ID: <14008700.38981235979135557.JavaMail.root@zimbra> Hej! Evening dinners will probably interest more people. Why not have some mini-erlounge? You will be very cold in Sweden if you don't put your coat on, you know. :-) Cheers, Adam ----- "Romain Lenglet" wrote: > Hej! > > I will be on a trip to Stockholm, from Tokyo, from March 16th to March > 19th. > I am free for lunch on Monday, March 16th. So if you too are free for > lunch in > Stockholm, drop me a mail, and I will be happy to meet you! > > Alternatively, I am also free for dinner on evenings during that > week. > > I'm eager to use my recent Swedish speaking powers, like "Jag har inte > p? > n?gra rockar!" (yeah, I still can't discuss many topics... ;)) > -- > Romain Lenglet > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From steven.charles.davis@REDACTED Mon Mar 2 10:42:05 2009 From: steven.charles.davis@REDACTED (Steve Davis) Date: Mon, 2 Mar 2009 01:42:05 -0800 (PST) Subject: [erlang-questions] The Beauty of Erlang Syntax In-Reply-To: <03AC2453-CD01-4D15-A9A0-17C015F7F2AB@cs.otago.ac.nz> References: <3e6f9520-f8cd-48f2-8ebf-1729538d1842@e24g2000vbe.googlegroups.com> <22226430.post@talk.nabble.com> <9b08084c0902260808hf9903b1yb0aa072e7e503160@mail.gmail.com> <22230905.post@talk.nabble.com> <57400D87-A249-43E9-A640-66C87A255EFB@scaldeferri.com> <22233815.post@talk.nabble.com> <22234312.post@talk.nabble.com> <03AC2453-CD01-4D15-A9A0-17C015F7F2AB@cs.otago.ac.nz> Message-ID: <44a6f4c8-44d6-41c8-bee9-dfbdf141d002@r3g2000vbp.googlegroups.com> On Mar 1, 10:10?pm, "Richard O'Keefe" wrote: > It probably means SSE instructions, or the kind of > stuff you'd use CUDA for. Hmm. Love to see this same argument given when CUDA has to run on future hardware when multi-cores reach the 1000s. :) ..and it just struck me that it's somewhat ironic that we are driven to write C to speed up floating point calculations when expressing mathematics in Erlang is so much more natural syntactically. regs /sd From bbmaj7@REDACTED Mon Mar 2 11:17:09 2009 From: bbmaj7@REDACTED (Richard Andrews) Date: Mon, 2 Mar 2009 02:17:09 -0800 (PST) Subject: [erlang-questions] The Beauty of Erlang Syntax References: <3e6f9520-f8cd-48f2-8ebf-1729538d1842@e24g2000vbe.googlegroups.com> <22226430.post@talk.nabble.com> <9b08084c0902260808hf9903b1yb0aa072e7e503160@mail.gmail.com> <22230905.post@talk.nabble.com> <57400D87-A249-43E9-A640-66C87A255EFB@scaldeferri.com> <22233815.post@talk.nabble.com> <22234312.post@talk.nabble.com> <03AC2453-CD01-4D15-A9A0-17C015F7F2AB@cs.otago.ac.nz> <44a6f4c8-44d6-41c8-bee9-dfbdf141d002@r3g2000vbp.googlegroups.com> Message-ID: <537837.92438.qm@web65508.mail.ac4.yahoo.com> > ..and it just struck me that it's somewhat ironic that we are driven > to write C to speed up floating point calculations when expressing > mathematics in Erlang is so much more natural syntactically. What did Joe say last week? "I get erlang to write C for me." Presumably erlang can convert erlang into C. Stay connected to the people that matter most with a smarter inbox. Take a look http://au.docs.yahoo.com/mail/smarterinbox From zoltan.peter.toth@REDACTED Mon Mar 2 12:49:26 2009 From: zoltan.peter.toth@REDACTED (Zoltan Peter Toth) Date: Mon, 02 Mar 2009 12:49:26 +0100 Subject: [erlang-questions] [clarify] mnesia slowdown with extra indexes ??? Message-ID: <49ABC7C6.9010207@ericsson.com> Hi, I made some test on mnesia object matching on non-key attributes. Got a table like this: mnesia:table_info(tgccDevIdToTerminationTable,size). 27000 mnesia:table_info(tgccDevIdToTerminationTable,attribute.) [deviceId,terminationId,sessionId,mgId,deviceChar, deviceBitMask,chId] No extra index exists. A match on the mgId attrib gives: element(1,timer:tc(mnesia,dirty_match_object,[tgccDevIdToTerminationTable, {'_','_','_','_',200021,'_','_','_'}])). 5578 5612 5571 6064 5622 Now I added an index on the mgId: mnesia:add_table_index(tgccDevIdToTerminationTable, mgId). {atomic,ok} ...and the matches slowed down: 6542 6420 6302 6430 6519 This is determinitstic. If I remove the extra index, it becomes faster again. The same even if specifying the index explicitly with dirty_index_match_object(). This is a live system with all the mnesia nodes up. R12B on quad core. Any comment on this ? Or is a table with 27000 rows too little to take advantage of the extra index ??? Br, TZP. From rvirding@REDACTED Mon Mar 2 13:26:08 2009 From: rvirding@REDACTED (Robert Virding) Date: Mon, 2 Mar 2009 13:26:08 +0100 Subject: [erlang-questions] The Beauty of Erlang Syntax In-Reply-To: References: <3e6f9520-f8cd-48f2-8ebf-1729538d1842@e24g2000vbe.googlegroups.com> <22226430.post@talk.nabble.com> <9b08084c0902260808hf9903b1yb0aa072e7e503160@mail.gmail.com> <22230905.post@talk.nabble.com> <57400D87-A249-43E9-A640-66C87A255EFB@scaldeferri.com> <22233815.post@talk.nabble.com> <22234312.post@talk.nabble.com> Message-ID: <3dbc6d1c0903020426g38518c5dsd528c81fba0dc80a@mail.gmail.com> 2009/2/27 Steve Davis > On Feb 26, 3:40 pm, Zvi wrote: > > > > ...article "Erlang for Concurrent Programming" [1] there is a list of > things > > for which Erlang tends to be not good. > > > > [1]http://mags.acm.org/queue/200809/ > > Took a quick look at that link to "queue magazine", and they seemed to > be scratching around a bit to find reasons to pad out their list... Perhaps they just didn't want to seem too uncritically positive. "? Code requiring an aggressive compiler (Erlang entries in language > benchmark shoot-outs are unimpressive ? except for process spawning > and message passing) " > > Does he mean "serial performance" here. If so see below, as this is at > the heart of most of the list items. Well, the whole Erlang system is aggressively optimised, but for process spawning and message passing and not so much for serial performance. I suppose in some ways it depends on what you see as your priorities. As ours were concurrency and not arithmetic then it is not surprising it is that way. Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: From zoltan.peter.toth@REDACTED Mon Mar 2 14:02:03 2009 From: zoltan.peter.toth@REDACTED (Zoltan Peter Toth) Date: Mon, 02 Mar 2009 14:02:03 +0100 Subject: [erlang-questions] clarify: mnesia slowdown with extra indexes ??? In-Reply-To: <49ABC7C6.9010207@ericsson.com> References: <49ABC7C6.9010207@ericsson.com> Message-ID: <49ABD8CB.2010604@ericsson.com> (no change, just repost with correct tagging so that I'll get the tons of responses :) Zoltan Peter Toth wrote: > Hi, > > I made some test on mnesia object matching on non-key attributes. > > Got a table like this: > mnesia:table_info(tgccDevIdToTerminationTable,size). > 27000 > mnesia:table_info(tgccDevIdToTerminationTable,attribute.) > > [deviceId,terminationId,sessionId,mgId,deviceChar, deviceBitMask,chId] > > No extra index exists. > A match on the mgId attrib gives: > > element(1,timer:tc(mnesia,dirty_match_object,[tgccDevIdToTerminationTable, > {'_','_','_','_',200021,'_','_','_'}])). > 5578 > 5612 > 5571 > 6064 > 5622 > > Now I added an index on the mgId: > mnesia:add_table_index(tgccDevIdToTerminationTable, > mgId). {atomic,ok} > > ...and the matches slowed down: > 6542 > 6420 > 6302 > 6430 > 6519 > > This is determinitstic. If I remove the extra index, it becomes faster > again. > The same even if specifying the index explicitly with > dirty_index_match_object(). > This is a live system with all the mnesia nodes up. R12B on quad core. > > Any comment on this ? Or is a table with 27000 rows too little to take > advantage of the > extra index ??? > Br, > TZP. > > From chandrashekhar.mullaparthi@REDACTED Mon Mar 2 14:28:11 2009 From: chandrashekhar.mullaparthi@REDACTED (Chandru) Date: Mon, 2 Mar 2009 13:28:11 +0000 Subject: [erlang-questions] What database can I use with erlang to store 100M records and select single one in 0.1s In-Reply-To: <4535f6cd0902170943s12d15872t7c5a713fe5c1986e@mail.gmail.com> References: <4535f6cd0902170943s12d15872t7c5a713fe5c1986e@mail.gmail.com> Message-ID: Hi, 2009/2/17 Scott Zhang > Hi. > > I opened a question about mnesia days ago. Now I am facing another > question. > > I am going to scrape large amount of data and put them into database. > Previously, my program was written in .NET/C# and saved the records into > SqlServer, after 10 days running, I have 63M records in database which make > SqlServer really slow, select single record need more than 1 minute which is > unacceptable. > > And days ago, I tried to save 7M records in mnesia with table type= > disc_only_copies. I tested , select single one from that talbe need more > than 20 seconds which is unacceptable too. ( I don't want to conclude > mnesia's performance is worse than SqlServer.) > Have you tried to fragment the table? It is not clear from your question whether you are querying mnesia using the primary key, or matching using select statements. We currently have an mnesia database storing 40M+ records with lookup times in the order of a few milliseconds. cheers Chandru -------------- next part -------------- An HTML attachment was scrubbed... URL: From ssroy1979@REDACTED Mon Mar 2 15:53:11 2009 From: ssroy1979@REDACTED (Salonee Sinha Roy) Date: Mon, 2 Mar 2009 06:53:11 -0800 Subject: [erlang-questions] How to not cache a certain function in yaws Message-ID: I have a web app in yaws. A part the code is supposed to randomly generate a temp string using the following code. genname(0, L) -> L; genname(N, L) -> R = random:uniform(123), case isalphanum(R) of true -> genname(N-1, [R|L]); false -> genname(N, L) end. Each time I call genname(8,[]), I want to generate a different string. However because of the caching behavior of yaws ( I think ), each time I call genname(8,[]), it always returns the same string. Is there a way I can change this. Any help would be appreciated Thanks in advance Salonee. -------------- next part -------------- An HTML attachment was scrubbed... URL: From bgustavsson@REDACTED Mon Mar 2 16:16:32 2009 From: bgustavsson@REDACTED (Bjorn Gustavsson) Date: Mon, 2 Mar 2009 16:16:32 +0100 Subject: [erlang-questions] [erlang-patches] [PATCH] 64-bit solaris builds In-Reply-To: <49A5E200.9050008@alertlogic.net> References: <48B72DC8.4030507@alertlogic.net> <6672d0160810170249i1e331d1u2c8cd40db3d17297@mail.gmail.com> <49A5E200.9050008@alertlogic.net> Message-ID: <6672d0160903020716rccf1b75m917a2e4005291f3a@mail.gmail.com> On Thu, Feb 26, 2009 at 1:27 AM, Paul Fisher wrote: > Bjorn Gustavsson wrote: >> >> On Fri, Aug 29, 2008 at 12:59 AM, Paul Fisher > > wrote: >> >> This patch allows 64-bit builds when the target system supports both >> 32-bit and 64-bit in the same system environment. Specifically, this >> works on Solaris 10/Opensolaris, and adjusts the --enable-darwin-64-bit >> configure flag to be simply --enable-64bit so that it can be used for >> the same purpose on both darwin and solaris (building 64-bit target >> environment) without having to introduce another system specific >> configure flag. >> >> >> We will address this issue in a future release (not R12B-5) by making sure >> that CFLAGS will be properly propagated >> by all Makefiles. > > I was just checking out the 13A-0 snapshot, and this failure is still > present. Will this (please) make it into the first drop of R13? > > $ CC='gcc' LD='gcc' CFLAGS='-m64 -O2' LDFLAGS='-m64' LIBS='-lmtmalloc' > ./configure --enable-threads --enable-smp-support --enable-kernel-poll > --enable-hipe --disable-megaco-flex-scanner-drvlineno --without-unixodbc > ... > $ make > ... > > make[4]: Entering directory > `/export/home/pfisher/bld/otp_src_R13A-0/lib/asn1/c_src' > ld -G > -L/export/home/pfisher/bld/otp_src_R13A-0/lib/erl_interface/obj/i386-pc-solaris2.11 > -o > /export/home/pfisher/bld/otp_src_R13A-0/lib/asn1/priv/lib/i386-pc-solaris2.11/asn1_erl_drv.so > /export/home/pfisher/bld/otp_src_R13A-0/lib/asn1/priv/obj/i386-pc-solaris2.11/asn1_erl_drv.o > -lei -lc -ldl -lm -lmtmalloc -lsocket -lnsl > ld: skipping incompatible > /export/home/pfisher/bld/otp_src_R13A-0/lib/erl_interface/obj/i386-pc-solaris2.11/libei.a > when searching for -lei > ld: cannot find -lei > We'll try to fix it in the R13B release. (We will probably not have time to fix it in R13A.) /Bj?rn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From pfisher@REDACTED Mon Mar 2 16:35:54 2009 From: pfisher@REDACTED (Paul Fisher) Date: Mon, 02 Mar 2009 09:35:54 -0600 Subject: [erlang-questions] [erlang-patches] [PATCH] 64-bit solaris builds In-Reply-To: <6672d0160903020716rccf1b75m917a2e4005291f3a@mail.gmail.com> References: <48B72DC8.4030507@alertlogic.net> <6672d0160810170249i1e331d1u2c8cd40db3d17297@mail.gmail.com> <49A5E200.9050008@alertlogic.net> <6672d0160903020716rccf1b75m917a2e4005291f3a@mail.gmail.com> Message-ID: <49ABFCDA.8030303@alertlogic.net> Thank you very much! 13B is just great, as I am just checking out 13A for features and to see if the issue reported previously are likely to get into 13B. Bjorn Gustavsson wrote: > On Thu, Feb 26, 2009 at 1:27 AM, Paul Fisher wrote: >> Bjorn Gustavsson wrote: >>> On Fri, Aug 29, 2008 at 12:59 AM, Paul Fisher >> > wrote: >>> >>> This patch allows 64-bit builds when the target system supports both >>> 32-bit and 64-bit in the same system environment. Specifically, this >>> works on Solaris 10/Opensolaris, and adjusts the --enable-darwin-64-bit >>> configure flag to be simply --enable-64bit so that it can be used for >>> the same purpose on both darwin and solaris (building 64-bit target >>> environment) without having to introduce another system specific >>> configure flag. >>> >>> >>> We will address this issue in a future release (not R12B-5) by making sure >>> that CFLAGS will be properly propagated >>> by all Makefiles. >> I was just checking out the 13A-0 snapshot, and this failure is still >> present. Will this (please) make it into the first drop of R13? >> >> $ CC='gcc' LD='gcc' CFLAGS='-m64 -O2' LDFLAGS='-m64' LIBS='-lmtmalloc' >> ./configure --enable-threads --enable-smp-support --enable-kernel-poll >> --enable-hipe --disable-megaco-flex-scanner-drvlineno --without-unixodbc >> ... >> $ make >> ... >> >> make[4]: Entering directory >> `/export/home/pfisher/bld/otp_src_R13A-0/lib/asn1/c_src' >> ld -G >> -L/export/home/pfisher/bld/otp_src_R13A-0/lib/erl_interface/obj/i386-pc-solaris2.11 >> -o >> /export/home/pfisher/bld/otp_src_R13A-0/lib/asn1/priv/lib/i386-pc-solaris2.11/asn1_erl_drv.so >> /export/home/pfisher/bld/otp_src_R13A-0/lib/asn1/priv/obj/i386-pc-solaris2.11/asn1_erl_drv.o >> -lei -lc -ldl -lm -lmtmalloc -lsocket -lnsl >> ld: skipping incompatible >> /export/home/pfisher/bld/otp_src_R13A-0/lib/erl_interface/obj/i386-pc-solaris2.11/libei.a >> when searching for -lei >> ld: cannot find -lei >> > > We'll try to fix it in the R13B release. (We will probably not have > time to fix it in R13A.) > > /Bj?rn > From anders.nygren@REDACTED Mon Mar 2 17:11:32 2009 From: anders.nygren@REDACTED (Anders Nygren) Date: Mon, 2 Mar 2009 10:11:32 -0600 Subject: [erlang-questions] How to not cache a certain function in yaws In-Reply-To: References: Message-ID: 2009/3/2 Salonee Sinha Roy : > I have a web app in yaws. A part? the code is supposed to randomly generate > a temp string using the following code. > > genname(0, L) -> L; > genname(N, L) -> > ??? R = random:uniform(123), > ??? case isalphanum(R) of > ??? true -> genname(N-1, [R|L]); > ??? false -> genname(N, L) > end. > > Each time I call genname(8,[]), I want to generate a different string. > However because of the caching behavior of yaws ( I think ), each time I > call genname(8,[]), it always returns the same string. Is there a way I can > change this. > > Any help would be appreciated > Thanks in advance > Salonee. > The problem is that random is initailized with a default seed in each process. And since You dont seed it yourself it will generate the same sequence of numbers in each process. add something like this {A1,A2,A3} = now(), random:seed(A1, A2, A3) before the call random:uniform(123) /Anders From btolputt@REDACTED Mon Mar 2 12:38:05 2009 From: btolputt@REDACTED (Benjamin Tolputt) Date: Mon, 02 Mar 2009 22:38:05 +1100 Subject: [erlang-questions] Erlang-to-C Message-ID: <49ABC51D.7080107@bigpond.net.au> There has been quite a few mentions of an "Erlang-to-C" functionality in a recent thread on the list. I am curious to know more about this (possible?) feature / library. In particular, I think it would be very interesting to have an "Erlang-to-C" interface to C libraries allowing for more efficient (or at least, somewhat more interesting) ways of creating port drivers. Is there any such thing currently, or is this a "possibility" that developers have thought about but not actually implemented. -- Regards, Benjamin Tolputt Analyst Programmer From erlang@REDACTED Mon Mar 2 21:27:12 2009 From: erlang@REDACTED (Joe Armstrong) Date: Mon, 2 Mar 2009 21:27:12 +0100 Subject: [erlang-questions] Erlang-to-C In-Reply-To: <49ABC51D.7080107@bigpond.net.au> References: <49ABC51D.7080107@bigpond.net.au> Message-ID: <9b08084c0903021227k307bbf95o9e7face369561752@mail.gmail.com> I think I mentioned (in passing) using Erlang to generate C - this is very different to Erlang-to-C. I was thinking of using Erlang to transform a domain specific language and outputting C - the DSL could be quite simple and have nothing to do with either Erlang or c. /Joe On Mon, Mar 2, 2009 at 12:38 PM, Benjamin Tolputt wrote: > There has been quite a few mentions of an "Erlang-to-C" functionality in > a recent thread on the list. I am curious to know more about this > (possible?) feature / library. In particular, I think it would be very > interesting to have an "Erlang-to-C" interface to C libraries allowing > for more efficient (or at least, somewhat more interesting) ways of > creating port drivers. > > Is there any such thing currently, or is this a "possibility" that > developers have thought about but not actually implemented. > > -- > Regards, > > Benjamin Tolputt > Analyst Programmer > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From tsuraan@REDACTED Mon Mar 2 22:37:43 2009 From: tsuraan@REDACTED (tsuraan) Date: Mon, 2 Mar 2009 15:37:43 -0600 Subject: [erlang-questions] writing a delay loop without now() In-Reply-To: <200902281158.n1SBwPLc067580@pluto.hedeland.org> References: <84fb38e30902231442w166941eap9e62137d92decf6b@mail.gmail.com> <200902281158.n1SBwPLc067580@pluto.hedeland.org> Message-ID: <84fb38e30903021337g65f292e8ye369ccb0ffb1277e@mail.gmail.com> > The kernel is different though ("2.6.20-1.2320.fc5smp"), probably glibc > too, but I have a hard time believing that either of those is the cause. > I don't suppose that you run some primitive time-keeping app that keeps > whacking the system time around? (The above system runs NTP.) I'm running 2.6.28 (vanilla) and glibc 2.6.1. Ntp is running in the background, but I don't think it's constantly messing with the system clock, at least not so much that it would cause these sorts of results. It's a gentoo system; everything is compiled with arch=i686 and O2. I imagine that fedora uses at least O2 for everything, but are they still supporting pentium1 (arch=i586)? I think that could slow things down a little, maybe. > What number do you get with the loop-counting version I posted earlier > (time2/1 reposted below)? I get numbers like 4559687, which is > uncomfortably close to 1 call per microsecond but still just below - I > think it would have to be some 25% faster on your system to produce the > above result. I guess it's possible even if unlikely... Just doing time2 (no wall_clock) reliably gives me {4999999,5000000}. If I do wall_clock, I pretty reliably get 4200 elapsed ms. > > If you do get just about 5000000 (it can never be more), maybe you could > try the "twiddle" version (time3/1 below) too? That works really well, even with c(test, native): 20> erlang:statistics(wall_clock),test:time3(5000000),erlang:statistics(wall_clock). {112133,5001} 21> erlang:statistics(wall_clock),test:time3(5000000),erlang:statistics(wall_clock). {117927,5000} 22> erlang:statistics(wall_clock),test:time3(5000000),erlang:statistics(wall_clock). {123552,5001} Also, my raw numbers for time2 (without native compilation) are: 17> erlang:statistics(wall_clock),test:time2(5000000),erlang:statistics(wall_clock). {93637,4199} 18> erlang:statistics(wall_clock),test:time2(5000000),erlang:statistics(wall_clock). {98664,4158} 19> erlang:statistics(wall_clock),test:time2(5000000),erlang:statistics(wall_clock). {103691,4200} From erlangy@REDACTED Mon Mar 2 23:18:17 2009 From: erlangy@REDACTED (Michael McDaniel) Date: Mon, 2 Mar 2009 14:18:17 -0800 Subject: [erlang-questions] extended timer module to handle absolute time-of-day timers In-Reply-To: <496D5621.2070207@gmail.com> References: <496C1D1B.3050501@gmail.com> <20090113160339.GJ10545@delora.autosys.us> <496D5621.2070207@gmail.com> Message-ID: <20090302221817.GT22018@delora.autosys.us> Hi, Serge. I am not having any known problems with timed_supervisor. Still, I would like to upgrade when available. thanks, ~Michael On Tue, Jan 13, 2009 at 10:04:01PM -0500, Serge Aleynikov wrote: > Since you are using the timed_supervisor, I'll post an updated version > to trapexit that fixes some bugs within the week or so. > > Serge > > Michael McDaniel wrote: > > Thanks - I like it. Just as I like timed_supervisor.erl which I use > > everyday (strictly speaking, it's always running!). > > > > I think the new functions would be useful additions to the > > OTP included timer module. > > > > > > ~Michael > > > > > > On Mon, Jan 12, 2009 at 11:48:27PM -0500, Serge Aleynikov wrote: > >> Sorry - previous email had a wrong attachment. > >> > >> > >> I extended the timer module to handle absolute time specifications. > >> > >> With this implementation it's possible to have messages sent on given > >> days of week at a certain time of day. Five new functions are added: > >> apply_at_local_time/4, send_at_local_time/3, exit_at_local_time/3, > >> apply_daily_at_local_time/5, send_daily_at_local_time/4. > >> > >> > >> Example1: Send a shutdown message to Pid at 23:00:00 every Friday and > >> Sunday. > >> timer:send_daily_at_local_time([fri,sun], {23,0,0}, Pid, shutdown). > >> > >> Example2: Send a restart message to Pid at "6:00:00": > >> timer:send_at_local_time({6,0,0}, Pid, restart). > >> > >> Legacy timer_server's functionality is not affected. > >> > >> The rationale behind this extension is that I frequently needed > >> functionality to schedule some "cron-like" recurrent activities, and was > >> always relying either on cron+erl_call or coding that activity with help > >> of timer:send_after/3 or timer:send_interval/2. As I finally got sick > >> of dealing with shortcomings of the timer module, I put together this > >> extension. > >> > >> Let me know if you also find it useful, and in such case perhaps we can > >> get it included in the OTP. > >> > >> Serge > >> > > > >> %% ``The contents of this file are subject to the Erlang Public License, > >> %% Version 1.1, (the "License"); you may not use this file except in > >> %% compliance with the License. You should have received a copy of the > >> %% Erlang Public License along with this software. If not, it can be > >> %% retrieved via the world wide web at http://www.erlang.org/. > >> %% > >> %% Software distributed under the License is distributed on an "AS IS" > >> %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See > >> %% the License for the specific language governing rights and limitations > >> %% under the License. > >> %% > >> %% The Initial Developer of the Original Code is Ericsson Utvecklings AB. > >> %% Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings > >> %% AB. All Rights Reserved.'' > >> %% > >> %% Contributor: Serge Aleynikov > >> %% 12-Jan-2009 Added support for absolute time timers including: > >> %% apply_at_local_time/4, send_at_local_time/3, exit_at_local_time/3, > >> %% apply_daily_at_local_time/5, send_daily_at_local_time/4 > >> %% > >> %% $Id$ > >> %% > >> -module(timer). > >> > >> -export([apply_after/4, > >> send_after/3, send_after/2, > >> exit_after/3, exit_after/2, kill_after/2, kill_after/1, > >> apply_interval/4, send_interval/3, send_interval/2, > >> apply_at_local_time/4, send_at_local_time/3, > >> exit_at_local_time/3, kill_at_local_time/2, > >> apply_daily_at_local_time/5, send_daily_at_local_time/4, > >> cancel/1, sleep/1, tc/3, now_diff/2, > >> seconds/1, minutes/1, hours/1, hms/3]). > >> > >> -export([start_link/0, start/0, > >> handle_call/3, handle_info/2, > >> init/1, > >> code_change/3, handle_cast/2, terminate/2]). > >> > >> %% internal exports for test purposes only > >> -export([get_status/0]). > >> > >> %% Max > >> -define(MAX_TIMEOUT, 16#0800000). > >> -define(TIMER_TAB, timer_tab). > >> -define(INTERVAL_TAB, timer_interval_tab). > >> > >> %% > >> %% Interface functions > >> %% > >> %% Time is in milliseconds. > >> %% TimeOfDay is in time() format (e.g. {3,59,15} = "03:59:15") > >> %% > >> apply_at_local_time(TimeOfDay, M, F, A) -> > >> req(apply_at_local_time, {TimeOfDay, {M, F, A}}). > >> > >> apply_after(Time, M, F, A) -> > >> req(apply_after, {Time, {M, F, A}}). > >> > >> send_at_local_time(TimeOfDay, Pid, Message) -> > >> req(apply_at_local_time, {TimeOfDay, {?MODULE, send, [Pid, Message]}}). > >> > >> send_after(Time, Pid, Message) -> > >> req(apply_after, {Time, {?MODULE, send, [Pid, Message]}}). > >> > >> send_after(Time, Message) -> > >> send_after(Time, self(), Message). > >> > >> exit_at_local_time(TimeOfDay, Pid, Reason) -> > >> req(apply_at_local_time, {TimeOfDay, {erlang, exit, [Pid, Reason]}}). > >> > >> exit_after(Time, Pid, Reason) -> > >> req(apply_after, {Time, {erlang, exit, [Pid, Reason]}}). > >> > >> exit_after(Time, Reason) -> > >> exit_after(Time, self(), Reason). > >> > >> kill_at_local_time(TimeOfDay, Pid) -> > >> exit_at_local_time(TimeOfDay, Pid, kill). > >> > >> kill_after(Time, Pid) -> > >> exit_after(Time, Pid, kill). > >> > >> kill_after(Time) -> > >> exit_after(Time, self(), kill). > >> > >> %% @spec (DaysOfWeek, TimeOfDay::time(), M, F, A) -> > >> %% {ok, TRef::ref()} | {error, Reason} > >> %% DaysOfWeek = [DayOfWeek] > >> %% DayOfWeek = integer() | sun | mon | tue | wed | thu | fri | sat > >> apply_daily_at_local_time(DaysOfWeek, TimeOfDay, M, F, A) -> > >> req(apply_daily_at_local_time, {DaysOfWeek, TimeOfDay, self(), {M, F, A}}). > >> > >> apply_interval(Time, M, F, A) -> > >> req(apply_interval, {Time, self(), {M, F, A}}). > >> > >> %% @spec (DaysOfWeek, TimeOfDay::time(), Pid::pid(), M, F, A) -> > >> %% {ok, TRef::ref()} | {error, Reason} > >> %% DaysOfWeek = [DayOfWeek] > >> %% DayOfWeek = integer() | sun | mon | tue | wed | thu | fri | sat > >> send_daily_at_local_time(DaysOfWeek, TimeOfDay, Pid, Message) -> > >> Details = {?MODULE, send, [Pid, Message]}, > >> req(apply_daily_at_local_time, {DaysOfWeek, TimeOfDay, Pid, Details}). > >> > >> send_interval(Time, Pid, Message) -> > >> req(apply_interval, {Time, Pid, {?MODULE, send, [Pid, Message]}}). > >> > >> send_interval(Time, Message) -> > >> send_interval(Time, self(), Message). > >> > >> cancel(BRef) -> > >> req(cancel, BRef). > >> > >> sleep(T) -> > >> receive > >> after T -> ok > >> end. > >> > >> %% > >> %% Measure the execution time (in microseconds) for an MFA. > >> %% > >> tc(M, F, A) -> > >> Before = erlang:now(), > >> Val = (catch apply(M, F, A)), > >> After = erlang:now(), > >> {now_diff(After, Before), Val}. > >> > >> %% > >> %% Calculate the time difference (in microseconds) of two > >> %% erlang:now() timestamps, T2-T1. > >> %% > >> now_diff({A2, B2, C2}, {A1, B1, C1}) -> > >> ((A2-A1)*1000000 + B2-B1)*1000000 + C2-C1. > >> > >> %% > >> %% Convert seconds, minutes etc. to milliseconds. > >> %% > >> seconds(Seconds) -> > >> 1000*Seconds. > >> minutes(Minutes) -> > >> 1000*60*Minutes. > >> hours(Hours) -> > >> 1000*60*60*Hours. > >> hms(H, M, S) -> > >> hours(H) + minutes(M) + seconds(S). > >> > >> %% > >> %% Start/init functions > >> %% > >> > >> %% Start is only included because of backward compatibility! > >> start() -> > >> ensure_started(). > >> > >> start_link() -> > >> gen_server:start_link({local, timer_server}, ?MODULE, [], []). > >> > >> init([]) -> > >> process_flag(trap_exit, true), > >> ets:new(?TIMER_TAB,[named_table,ordered_set,protected]), > >> ets:new(?INTERVAL_TAB,[named_table,protected]), > >> {ok, [], infinity}. > >> > >> ensure_started() -> > >> case whereis(timer_server) of > >> undefined -> > >> C = {timer_server, {?MODULE, start_link, []}, permanent, 1000, > >> worker, [?MODULE]}, > >> supervisor:start_child(kernel_safe_sup, C), % kernel_safe_sup > >> ok; > >> _ -> ok > >> end. > >> > >> %% server calls > >> > >> req(Req, Arg) -> > >> SysTime = now(), > >> ensure_started(), > >> gen_server:call(timer_server, {Req, Arg, SysTime}, infinity). > >> > >> %% > >> %% handle_call(Request, From, Timers) -> > >> %% {reply, Response, Timers, Timeout} > >> %% > >> %% Time and Timeout is in milliseconds. WhenStarted is in now() format. > >> %% Started is in microseconds. > >> %% > >> handle_call({apply_after, {Time, Op}, WhenStarted}, _From, _Ts) > >> when is_integer(Time), Time >= 0 -> > >> Started = system_time(WhenStarted), > >> BRef = {Started + 1000*Time, make_ref()}, > >> Timer = {BRef, timeout, Op}, > >> ets:insert(?TIMER_TAB, Timer), > >> Timeout = timer_timeout(now()), > >> {reply, {ok, BRef}, [], Timeout}; > >> > >> handle_call({apply_at_local_time, {{H,M,S} = _Time, Op}, WhenStarted}, From, Ts) > >> when is_integer(H), H >= 0, H < 24 > >> , is_integer(M), M >= 0, M < 61 > >> , is_integer(S), S >= 0, S < 61 > >> -> > >> {_, {H1,M1,S1}} = calendar:now_to_local_time(WhenStarted), > >> Interval = hms(H-H1, M-M1, S-S1), > >> if Interval < 0 -> > >> {reply, {error, expired}, [], next_timeout()}; > >> true -> > >> handle_call({apply_after, {Interval, Op}, WhenStarted}, From, Ts) > >> end; > >> > >> handle_call({apply_daily_at_local_time, {DaysOfWeek, {H,M,S} = Time, To, MFA}, WhenStarted}, _From, _Ts) > >> when is_integer(H), H >= 0, H < 24 > >> , is_integer(M), M >= 0, M < 61 > >> , is_integer(S), S >= 0, S < 61 > >> , is_list(DaysOfWeek) > >> -> > >> try > >> DaysOfWeek =:= [] andalso throw(badarg), > >> %% Represent days of week > >> %% as a 7-element tuple with 1's being the days of week > >> %% when to fire the timer and 0's when not to fire. > >> DOWs = lists:foldl(fun(I, T) -> setelement(I, T, 1) end, > >> erlang:make_tuple(7, 0), [to_dow(D) || D <- DaysOfWeek]), > >> {Date, Started} = calendar:now_to_local_time(WhenStarted), > >> DOW = calendar:day_of_the_week(Date), > >> Interval = dow_interval(DOWs, DOW, Time, Started, 0), > >> %% To must be a pid or a registered name > >> Pid = get_pid(To), > >> is_pid(Pid) orelse throw(badarg), > >> catch link(Pid), > >> Ref = make_ref(), > >> BRef1 = {interval, Ref}, > >> BRef2 = {system_time(WhenStarted) + Interval*1000000, Ref}, > >> Timer = {BRef2, {daily_local_time, DOWs, Time, Pid}, MFA}, > >> ets:insert(?INTERVAL_TAB,{BRef1,BRef2,Pid}), > >> ets:insert(?TIMER_TAB, Timer), > >> Timeout = timer_timeout(now()), > >> {reply, {ok, BRef1}, [], Timeout} > >> catch throw:Reason -> > >> {reply, {error, Reason}, [], next_timeout()} > >> end; > >> > >> handle_call({apply_interval, {Time, To, MFA}, WhenStarted}, _From, _Ts) > >> when is_integer(Time), Time >= 0 -> > >> Started = system_time(WhenStarted), > >> %% To must be a pid or a registered name > >> case get_pid(To) of > >> Pid when is_pid(Pid) -> > >> catch link(Pid), > >> NowSysTime = now(), > >> Ref = make_ref(), > >> BRef1 = {interval, Ref}, > >> Interval = Time*1000, > >> BRef2 = {Started + Interval, Ref}, > >> Timer = {BRef2, {repeat, Interval, Pid}, MFA}, > >> ets:insert(?INTERVAL_TAB,{BRef1,BRef2,Pid}), > >> ets:insert(?TIMER_TAB, Timer), > >> Timeout = timer_timeout(NowSysTime), > >> {reply, {ok, BRef1}, [], Timeout}; > >> _ -> > >> {reply, {error, badarg}, [], next_timeout()} > >> end; > >> > >> handle_call({cancel, BRef = {_Time, Ref}, _}, _From, Ts) > >> when is_reference(Ref) -> > >> delete_ref(BRef), > >> {reply, {ok, cancel}, Ts, next_timeout()}; > >> handle_call({cancel, _BRef, _}, _From, Ts) -> > >> {reply, {error, badarg}, Ts, next_timeout()}; > >> handle_call({apply_after, _, _}, _From, Ts) -> > >> {reply, {error, badarg}, Ts, next_timeout()}; > >> handle_call({apply_at_local_time, {_, _Op}, _}, _From, Ts) -> > >> {reply, {error, badarg}, Ts, next_timeout()}; > >> handle_call({apply_interval, _, _}, _From, Ts) -> > >> {reply, {error, badarg}, Ts, next_timeout()}; > >> handle_call(_Else, _From, Ts) -> % Catch anything else > >> {noreply, Ts, next_timeout()}. > >> > >> handle_info(timeout, Ts) -> % Handle timeouts > >> Timeout = timer_timeout(now()), > >> {noreply, Ts, Timeout}; > >> handle_info({'EXIT', Pid, _Reason}, Ts) -> % Oops, someone died > >> pid_delete(Pid), > >> {noreply, Ts, next_timeout()}; > >> handle_info(_OtherMsg, Ts) -> % Other Msg's > >> {noreply, Ts, next_timeout()}. > >> > >> handle_cast(_Req, Ts) -> % Not predicted but handled > >> {noreply, Ts, next_timeout()}. > >> > >> terminate(_Reason, _State) -> > >> ok. > >> > >> code_change(_OldVsn, State, _Extra) -> > >> %% According to the man for gen server no timer can be set here. > >> {ok, State}. > >> > >> %% > >> %% timer_timeout(NowSysTime) > >> %% > >> %% Apply and remove already timed-out timers. A timer is a tuple > >> %% {Time, BRef, Op, MFA}, where Time is in microseconds. > >> %% Returns {Timeout, Timers}, where Timeout is in milliseconds. > >> %% > >> timer_timeout(NowSysTime) -> > >> SysTime = system_time(NowSysTime), > >> case ets:first(?TIMER_TAB) of > >> '$end_of_table' -> > >> infinity; > >> {Time, _Ref} when Time > SysTime -> > >> Timeout = (Time - SysTime) div 1000, > >> %% Returned timeout must fit in a small int > >> min(Timeout, ?MAX_TIMEOUT); > >> Key -> > >> case ets:lookup(?TIMER_TAB, Key) of > >> [{Key, timeout, MFA}] -> > >> ets:delete(?TIMER_TAB,Key), > >> do_apply(MFA), > >> timer_timeout(NowSysTime); > >> [{{Time, Ref}, Repeat = {repeat, Interv, To}, MFA}] -> > >> ets:delete(?TIMER_TAB,Key), > >> NewTime = Time + Interv, > >> %% Update the interval entry (last in table) > >> ets:insert(?INTERVAL_TAB,{{interval,Ref},{NewTime,Ref},To}), > >> do_apply(MFA), > >> ets:insert(?TIMER_TAB, {{NewTime, Ref}, Repeat, MFA}), > >> timer_timeout(NowSysTime); > >> [{{_Time, Ref}, Repeat = {daily_local_time, DOWs, TimeOfDay, Pid}, MFA}] -> > >> ets:delete(?TIMER_TAB,Key), > >> {Date, CurTime} = calendar:now_to_local_time(add_second(NowSysTime)), > >> DOW = calendar:day_of_the_week(Date), > >> Interval = dow_interval(DOWs, DOW, TimeOfDay, CurTime, 0), > >> NewTime = system_time(NowSysTime) + Interval*1000000, > >> %% Update the interval entry (last in table) > >> ets:insert(?INTERVAL_TAB,{{interval,Ref},{NewTime,Ref},Pid}), > >> do_apply(MFA), > >> ets:insert(?TIMER_TAB, {{NewTime, Ref}, Repeat, MFA}), > >> timer_timeout(NowSysTime) > >> end > >> end. > >> > >> %% > >> %% delete_ref > >> %% > >> > >> delete_ref(BRef = {interval, _}) -> > >> case ets:lookup(?INTERVAL_TAB, BRef) of > >> [{_, BRef2, _Pid}] -> > >> ets:delete(?INTERVAL_TAB, BRef), > >> ets:delete(?TIMER_TAB, BRef2); > >> _ -> % TimerReference does not exist, do nothing > >> ok > >> end; > >> delete_ref(BRef) -> > >> ets:delete(?TIMER_TAB,BRef). > >> > >> %% > >> %% pid_delete > >> %% > >> > >> pid_delete(Pid) -> > >> IntervalTimerList = > >> ets:select(?INTERVAL_TAB, > >> [{{'_', '_','$1'}, > >> [{'==','$1',Pid}], > >> ['$_']}]), > >> lists:foreach(fun({IntKey, TimerKey, _ }) -> > >> ets:delete(?INTERVAL_TAB,IntKey), > >> ets:delete(?TIMER_TAB,TimerKey) > >> end, IntervalTimerList). > >> > >> %% Calculate time to the next timeout. Returned timeout must fit in a > >> %% small int. > >> > >> next_timeout() -> > >> case ets:first(?TIMER_TAB) of > >> '$end_of_table' -> > >> infinity; > >> {Time, _ } -> > >> min(positive((Time - system_time()) div 1000), ?MAX_TIMEOUT) > >> end. > >> > >> %% Help functions > >> do_apply({M,F,A}) -> > >> case {M, F, A} of > >> {?MODULE, send, A} -> > >> %% If send op. send directly, (faster than spawn) > >> catch send(A); > >> {erlang, exit, [Name, Reason]} -> > >> catch exit(get_pid(Name), Reason); > >> _ -> > >> %% else spawn process with the operation > >> catch spawn(M,F,A) > >> end. > >> > >> max(X, Y) when X > Y -> > >> X; > >> max(_X, Y) -> > >> Y. > >> > >> min(X, Y) when X < Y -> > >> X; > >> min(_X, Y) -> > >> Y. > >> > >> positive(X) -> > >> max(X, 0). > >> > >> to_dow(mon) -> 1; > >> to_dow(tue) -> 2; > >> to_dow(wed) -> 3; > >> to_dow(thu) -> 4; > >> to_dow(fri) -> 5; > >> to_dow(sat) -> 6; > >> to_dow(sun) -> 7; > >> to_dow(I) when is_integer(I), I >= 1, I =< 7 -> I; > >> to_dow(_) -> throw(badarg). > >> > >> seconds_diff({H2,M2,S2}, {H1,M1,S1}) -> > >> (H2-H1)*3600 + (M2-M1)*60 + (S2-S1). > >> > >> add_second({M,S,U}) when S < 1000000 -> > >> {M,S+1,U}; > >> add_second({M,_,U}) -> > >> {M+1,0,U}. > >> > >> dow_interval(DOWs, Dow, Time, NowTime, 0) when element(Dow, DOWs) =:= 1 -> > >> case seconds_diff(Time, NowTime) of > >> TodayInterval when TodayInterval >= 0 -> > >> TodayInterval; > >> _ -> > >> % Current time passed target time for today. > >> % Find interval from NowTime to future Time. > >> dow_interval(DOWs, Dow, Time, NowTime, 1) > >> end; > >> dow_interval(DOWs, Dow, Time, NowTime, _) -> > >> % Current time is in another DayOfWeek. > >> % Find interval from NowTime to future Time. > >> NextDays = get_days(DOWs, (Dow rem 7) + 1, 0), > >> seconds_diff({24,0,0}, NowTime) % Seconds from now until end-of-day > >> + NextDays*86400 % Seconds in days until given day of week > >> + seconds_diff(Time, {0,0,0}). % Seconds from beginning of day to Time > >> > >> get_days(DOWs, Dow, N) when element(Dow, DOWs) =:= 1 -> > >> N; > >> get_days(DOWs, Dow, N) when N < 8 -> > >> get_days(DOWs, (Dow rem 7) + 1, N+1); > >> get_days(_, _, _) -> > >> throw(badarg). > >> > >> %% > >> %% system_time() -> time in microseconds > >> %% > >> system_time() -> > >> Now = erlang:now(), > >> system_time(Now). > >> system_time(Now) -> > >> {M,S,U} = Now, > >> 1000000*(M*1000000 + S) + U. > >> > >> send([Pid, Msg]) -> > >> Pid ! Msg. > >> > >> get_pid(Name) when is_pid(Name) -> > >> Name; > >> get_pid(undefined) -> > >> undefined; > >> get_pid(Name) when is_atom(Name) -> > >> get_pid(whereis(Name)); > >> get_pid(_) -> > >> undefined. > >> > >> %% > >> %% get_status() -> > >> %% {{TimerTabName,TotalNumTimers},{IntervalTabName,NumIntervalTimers}} > >> %% > >> %% This function is for test purposes only; it is used by the test suite. > >> %% There is a small possibility that there is a mismatch of one entry > >> %% between the 2 tables if this call is made when the timer server is > >> %% in the middle of a transaction > >> > >> get_status() -> > >> Info1 = ets:info(?TIMER_TAB), > >> {value,{size,TotalNumTimers}} = lists:keysearch(size, 1, Info1), > >> Info2 = ets:info(?INTERVAL_TAB), > >> {value,{size,NumIntervalTimers}} = lists:keysearch(size, 1, Info2), > >> {{?TIMER_TAB,TotalNumTimers},{?INTERVAL_TAB,NumIntervalTimers}}. > > > >> _______________________________________________ > >> 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 -- Michael McDaniel Portland, Oregon, USA http://trip.autosys.us http://mmcdaniel.com/erlview From per@REDACTED Tue Mar 3 00:13:09 2009 From: per@REDACTED (Per Hedeland) Date: Tue, 3 Mar 2009 00:13:09 +0100 (CET) Subject: [erlang-questions] writing a delay loop without now() In-Reply-To: <84fb38e30903021337g65f292e8ye369ccb0ffb1277e@mail.gmail.com> Message-ID: <200903022313.n22ND9sm066349@pluto.hedeland.org> tsuraan wrote: > >I'm running 2.6.28 (vanilla) and glibc 2.6.1. Ntp is running in the >background, but I don't think it's constantly messing with the system >clock, at least not so much that it would cause these sorts of >results. No, it's very careful to just (effectively) reduce or increase the clock frequency, won't step the time unless it's way off (i.e. 128 millisec:-). >It's a gentoo system; everything is compiled with arch=i686 and O2. I >imagine that fedora uses at least O2 for everything, but are they >still supporting pentium1 (arch=i586)? I think that could slow things >down a little, maybe. Perhaps - most likely is probably some manual optimization in the relevant kernel code. >Just doing time2 (no wall_clock) reliably gives me {4999999,5000000}. >If I do wall_clock, I pretty reliably get 4200 elapsed ms. OK, that agrees well with a now() that completes in some 0.84 microseconds on average - "bumping" will occur every ~ 7th call to fulfill the "increasing values" promise. >> If you do get just about 5000000 (it can never be more), maybe you could >> try the "twiddle" version (time3/1 below) too? > >That works really well, even with c(test, native): Great, thanks for your perseverance.:-) So, you've confirmed what I said way back: As long as the underlying OS returns sane results from gettimeofday() or the equivalent, doing a tight-loop with microsecond- level accuracy using now/1 works fine. The only problem is if your system completes the call in less than 1 microsecond on average - in which case you simply need to make sure that you don't call it so often, do something else in between the calls to make sure they're at least a microsecond apart. Maybe you can even find something more useful to do than multiplying bignums and throwing away the result.:-) And if you're really ambitious, you could make this thing auto-adapting to OS/CPU speed - increase the "twiddle time" until you start getting increments of 2 (or more) from now/1, then you know that some "real" time has elapsed between calls. --Per From norbu09@REDACTED Tue Mar 3 01:26:55 2009 From: norbu09@REDACTED (lenz) Date: Tue, 3 Mar 2009 13:26:55 +1300 Subject: [erlang-questions] REMINDER: erlounge wellington tomorrow Message-ID: hi, i just wanted to give a short heads up. we have our erlounge wellington tomorrow as usual at AltSpace at 18:00. I'll talk a bit about my ups and downs with nitrogen, a web framework written in erlang and there will be plenty of time for general chat about the language and related projects. there will be, of course, some CouchDB related things in this talk as well as in the discussion afterwards. everyone is welcome :-) cheers lenz -- iWantMyName.com painless domain registration (finally) -------------- next part -------------- An HTML attachment was scrubbed... URL: From patrickdlogan@REDACTED Tue Mar 3 02:12:38 2009 From: patrickdlogan@REDACTED (Patrick Logan) Date: Mon, 2 Mar 2009 17:12:38 -0800 Subject: [erlang-questions] Erlang-to-C Message-ID: "Is there any such thing currently, or is this a "possibility" that developers have thought about but not actually implemented." There is ETOS (http://www.iro.umontreal.ca/~etos/) I doubt ETOS has been worked on much in the last 10 years, but it at least serves as a reasonable proof-of-concept. ETOS compiles Erlang to Gambit Scheme, which itself is a Scheme to C compiler. Therefore by the transitive property of A-to-B and B-to-C, ETOS is an Erlang to C compiler. Gambit Scheme has process and message sending capabilities in the same neighborhood as Erlang. Gambit Scheme is not (yet) enabled for a single run-time using more than one core. Since it is a lot easier to write X-to-Scheme than X-to-C, this is a pretty reasonable approach to get to X-to-C in a fairly short amount of time. Moreover if you write X, Y, and Z to Scheme then you get a pretty good collection of languages that can all run together in the same, well, common, run-time. -Patrick From rvirding@REDACTED Tue Mar 3 02:42:43 2009 From: rvirding@REDACTED (Robert Virding) Date: Tue, 3 Mar 2009 02:42:43 +0100 Subject: [erlang-questions] LFE can now do parameterized modules Message-ID: <3dbc6d1c0903021742i1737183dx66bb008a1cf3dc12@mail.gmail.com> I have just added a first trial version of parameterized modules to LFE (Lisp Flavoured Erlang). It is not fully tested yet but most things seem to work. What does not work, however, is explicitly defining the functions 'new' and 'instance'. Parameterized modules are defined by: (defmodule (name par1 par2 ... ) ... ) It is downloadable from github: http://github.com/rvirding/lfe/tree/master Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: From ok@REDACTED Tue Mar 3 03:39:09 2009 From: ok@REDACTED (Richard O'Keefe) Date: Tue, 3 Mar 2009 15:39:09 +1300 Subject: [erlang-questions] On the usage of tests in guards Message-ID: <6765746A-42EE-4EE4-AFCA-31AF322674FA@cs.otago.ac.nz> Recently I was involved in an e-mail argument about whether it was true that 'when' was a design mistake in Erlang (I say NO) and whether it was true that most uses of 'when' could be replaced by type tests inside patterns (I say no, and even if they could be, they shouldn't be). It occurred to me to get some numbers to see what other people were doing, and I ran some fairly crude tools over the R12B-5 distribution, finding that about 50% of the tests in guards were _not_ type tests, and that this also seemed to be true of 'receive' guards. Wondering whether this would generalise, I just took a look at the MochiWeb sources. This looked at all 'when' guards (not at 'if', sadly, but then, we hadn't been arguing about 'if'). Here's the summary. 19 is_atom 26 is_binary 19 is_integer 7 is_float 38 is_list 3 is_number 1 is_pid 6 is_tuple --- -------- 119 Total type tests 58 =:= (really "member") 4 =/= 10 == 11 > 61 >= 20 < 48 =< --- --------- 212 Total comparisons So comparisons form about 2/3 of the guard tests in MochiWeb, an even higher proportion than OTP. A lot of the >= and =< tests were character ranges, and many of the =:= tests were in guards like X =:= c1 ; X =:= c2 ; X =:= c3 checking for specific characters (or occasionally other literals). From vikrant.patil@REDACTED Tue Mar 3 06:33:34 2009 From: vikrant.patil@REDACTED (Vikrant) Date: Tue, 3 Mar 2009 11:03:34 +0530 Subject: [erlang-questions] Executing concurrently Message-ID: Hi, I have a function Fun(). If Fun is called simultaneously by two processes, then it should fail for one process while should succeed for other. I wrote such function. Now I want to test it! How do I do that? How do I call a function exactly at same time from two different processes? Thanks in advance, Regards, Vikrant -------------- next part -------------- An HTML attachment was scrubbed... URL: From bengt.kleberg@REDACTED Tue Mar 3 07:55:09 2009 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Tue, 03 Mar 2009 07:55:09 +0100 Subject: [erlang-questions] Executing concurrently In-Reply-To: References: Message-ID: <1236063309.4558.1.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> Greetings, If you are willing to make a small change to Fun(), for the purpose of testing, you could add a call to timer:sleep/1 inside it. This to make sure that it takes sufficiently long time to execute. bengt On Tue, 2009-03-03 at 11:03 +0530, Vikrant wrote: > Hi, > I have a function Fun(). If Fun is called simultaneously by two > processes, then it should fail for one process while should succeed > for other. I wrote such function. Now I want to test it! How do I do > that? How do I call a function exactly at same time from two different > processes? > > Thanks in advance, > Regards, > Vikrant > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From r.b.lists@REDACTED Tue Mar 3 07:59:51 2009 From: r.b.lists@REDACTED (Roland Braito) Date: Tue, 03 Mar 2009 07:59:51 +0100 Subject: [erlang-questions] Erlang-to-C In-Reply-To: <49ABC51D.7080107@bigpond.net.au> References: <49ABC51D.7080107@bigpond.net.au> Message-ID: <20090303065951.270940@gmx.net> Hello. You might want to take a look at erlang FFI (Foreign Function Interface) and Dryverl maybe that's more in the direction you're searching? Best Regards, Roland -------- Original-Nachricht -------- > Datum: Mon, 02 Mar 2009 22:38:05 +1100 > Von: Benjamin Tolputt > An: Erlang Questions List > Betreff: [erlang-questions] Erlang-to-C > There has been quite a few mentions of an "Erlang-to-C" functionality in > a recent thread on the list. I am curious to know more about this > (possible?) feature / library. In particular, I think it would be very > interesting to have an "Erlang-to-C" interface to C libraries allowing > for more efficient (or at least, somewhat more interesting) ways of > creating port drivers. > > Is there any such thing currently, or is this a "possibility" that > developers have thought about but not actually implemented. > > -- > Regards, > > Benjamin Tolputt > Analyst Programmer > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- Psssst! Schon vom neuen GMX MultiMessenger geh?rt? Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger01 From bbmaj7@REDACTED Tue Mar 3 11:07:50 2009 From: bbmaj7@REDACTED (Richard Andrews) Date: Tue, 3 Mar 2009 02:07:50 -0800 (PST) Subject: [erlang-questions] Executing concurrently References: Message-ID: <357667.93050.qm@web65506.mail.ac4.yahoo.com> > I have a function Fun(). If Fun is called simultaneously > by two processes, then it should fail for one process > while should succeed for other. I wrote such function. Now > I want to test it! How do I do that? How do I call a > function exactly at same time from two different processes? You could make the function wait at receive. Stay connected to the people that matter most with a smarter inbox. Take a look http://au.docs.yahoo.com/mail/smarterinbox From bekesa@REDACTED Tue Mar 3 13:09:13 2009 From: bekesa@REDACTED (Andras Georgy Bekes) Date: Tue, 03 Mar 2009 13:09:13 +0100 Subject: [erlang-questions] Executing concurrently In-Reply-To: References: Message-ID: <200903031309.13179.bekesa@sch.bme.hu> > I have a function Fun(). If Fun is called simultaneously by two > processes, then it should fail for one process while should succeed > for other. I wrote such function. Now I want to test it! How do I do > that? How do I call a function exactly at same time from two > different processes? It depends on how you define "called simultaneously". What do you mean "called simultaneously"? What do you want to achieve? Georgy From ryeguy1@REDACTED Tue Mar 3 15:29:02 2009 From: ryeguy1@REDACTED (ryeguy) Date: Tue, 3 Mar 2009 06:29:02 -0800 (PST) Subject: [erlang-questions] How do you efficiently do this kind of mnesia schema? Message-ID: <10a0b334-2da8-47c3-b795-03546c4420b4@x29g2000prf.googlegroups.com> I'm trying to break free of the RDBMS thought process, but I can't wrap my head around how to efficiently implement this kind of schema. Say I have a User record, and he has many SubItemA records, which has many SubItem B records, so: User -SubItem A --SubItem B ... I need to run queries on SubItem B. Is it efficient to do it when it's this nested? Should I just normalize it so it will be quicker? I have heard of some people using data duplication so the data is both nested and separate, is this ridiculous or is this actually useful in some cases? From ryeguy1@REDACTED Tue Mar 3 15:33:54 2009 From: ryeguy1@REDACTED (ryeguy) Date: Tue, 3 Mar 2009 06:33:54 -0800 (PST) Subject: [erlang-questions] Executing concurrently In-Reply-To: <200903031309.13179.bekesa@sch.bme.hu> References: <200903031309.13179.bekesa@sch.bme.hu> Message-ID: He is saying that he only wants one process to be able to call his fun at a time. In the event that 2 processes attempt to execute the fun at the same time, one of them will fail while the other one works as normal. On Mar 3, 7:09?am, Andras Georgy Bekes wrote: > > ? ?I have a function Fun(). If Fun is called simultaneously by two > > processes, then it should fail for one process while should succeed > > for other. I wrote such function. Now I want to test it! How do I do > > that? How do I call a function exactly at same time from two > > different processes? > > It depends on how you define "called simultaneously". > > What do you mean "called simultaneously"? > What do you want to achieve? > > ? ? ? ? Georgy > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions From btolputt@REDACTED Tue Mar 3 13:24:06 2009 From: btolputt@REDACTED (Benjamin Tolputt) Date: Tue, 03 Mar 2009 23:24:06 +1100 Subject: [erlang-questions] Erlang-to-C In-Reply-To: <20090303065951.270940@gmx.net> References: <49ABC51D.7080107@bigpond.net.au> <20090303065951.270940@gmx.net> Message-ID: <49AD2166.50203@bigpond.net.au> Roland Braito wrote: > You might want to take a look at > > erlang FFI (Foreign Function Interface) > It was my impression that this was still an EEP, without an actual implementation > Dryverl > Thanks for putting me onto this one. I am well aware of EDTK, but hadn't heard of this further development. I will look into this and see how well it caters to my requirements. -- Regards, Benjamin Tolputt Analyst Programmer From erlang@REDACTED Tue Mar 3 17:41:51 2009 From: erlang@REDACTED (Joe Armstrong) Date: Tue, 3 Mar 2009 17:41:51 +0100 Subject: [erlang-questions] Executing concurrently In-Reply-To: References: <200903031309.13179.bekesa@sch.bme.hu> Message-ID: <9b08084c0903030841p48fbeed9v8a5807725f19becc@mail.gmail.com> On Tue, Mar 3, 2009 at 3:33 PM, ryeguy wrote: > He is saying that he only wants one process to be able to call his fun > at a time. In the event that 2 processes attempt to execute the fun at > the same time, one of them will fail while the other one works as > normal. Heres a fun: F = fun() -> 42 end. Evaluating F() returns 42 Now spawn two processes P1 = spawn(fun() -> p(F) end), P2 = spawn(fun() -> p(F) end). here's p(F) p(F) -> magic:magic(F). magic:magic(F) returns 42 or calls exit(ebadArg) if two processes call magic(F) "at the same time" To do this you need a global process called magic, which is started before you do any of this magic:start() -> register(magic, wait()). magic:magic(F) -> magic ! {eval, self(), F}, receive {magic, Ret} -> Ret end. wait() -> receive {eval, Pid, F} -> S = self(), spawn(fun() -> Pid ! {magic, F()}, Parent ! free end), busy() end. busy() -> receive {eval, Pid, F} -> exit(Pid, eNotSim), busy(); free -> wait() end. Or you could send a lock token and evaluate the function locally - all of this does not seem like good design. The Erlang way is to create servers for global operations and send a sequental stream of requests to the server, where they are handled in an orderly manner one at a time. Cheers /Joe > > On Mar 3, 7:09?am, Andras Georgy Bekes wrote: >> > ? ?I have a function Fun(). If Fun is called simultaneously by two >> > processes, then it should fail for one process while should succeed >> > for other. I wrote such function. Now I want to test it! How do I do >> > that? How do I call a function exactly at same time from two >> > different processes? >> >> It depends on how you define "called simultaneously". >> >> What do you mean "called simultaneously"? >> What do you want to achieve? >> >> ? ? ? ? Georgy >> _______________________________________________ >> erlang-questions mailing list >> erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From hakan@REDACTED Tue Mar 3 19:10:55 2009 From: hakan@REDACTED (Hakan Mattsson) Date: Tue, 3 Mar 2009 19:10:55 +0100 (CET) Subject: [erlang-questions] Executing concurrently In-Reply-To: <9b08084c0903030841p48fbeed9v8a5807725f19becc@mail.gmail.com> References: <200903031309.13179.bekesa@sch.bme.hu> <9b08084c0903030841p48fbeed9v8a5807725f19becc@mail.gmail.com> Message-ID: Of course you may implement your own lock manager as Joe suggests, but a simpler solution is to just call global:trans/4 with Retries set to 0. It will perform the syncronization you need. (Given that the performance of global is sufficient for your needs.) If you are using Mnesia transactions in your fun, you have the option of using global locks in Mnesia (see mnesia:lock/2). /H?kan --- H?kan Mattsson (uabhams) Erlang/OTP, Ericsson AB On Tue, 3 Mar 2009, Joe Armstrong wrote: > Date: Tue, 3 Mar 2009 17:41:51 +0100 > From: Joe Armstrong > To: ryeguy > Cc: erlang-questions > Subject: Re: [erlang-questions] Executing concurrently > > On Tue, Mar 3, 2009 at 3:33 PM, ryeguy wrote: > > He is saying that he only wants one process to be able to call his fun > > at a time. In the event that 2 processes attempt to execute the fun at > > the same time, one of them will fail while the other one works as > > normal. > > > > Heres a fun: > > F = fun() -> 42 end. > > Evaluating F() returns 42 > > Now spawn two processes > > P1 = spawn(fun() -> p(F) end), > P2 = spawn(fun() -> p(F) end). > > here's p(F) > > p(F) -> > magic:magic(F). > > magic:magic(F) returns 42 or calls exit(ebadArg) if two processes > call magic(F) "at the same time" > > To do this you need a global process called magic, which is started > before you do any of this > > magic:start() -> register(magic, wait()). > > magic:magic(F) -> > magic ! {eval, self(), F}, > receive > {magic, Ret} -> Ret > end. > > > wait() -> > receive > {eval, Pid, F} -> > S = self(), > spawn(fun() -> > Pid ! {magic, F()}, > Parent ! free > end), > busy() > end. > > busy() -> > receive > {eval, Pid, F} -> > exit(Pid, eNotSim), > busy(); > free -> > wait() > end. > > Or you could send a lock token and evaluate the function locally - all > of this does not seem like good design. > > The Erlang way is to create servers for global operations and send a > sequental stream of requests to the server, where they are handled in > an orderly manner one at a time. > > Cheers > > /Joe > > > > > On Mar 3, 7:09?am, Andras Georgy Bekes wrote: > >> > ? ?I have a function Fun(). If Fun is called simultaneously by two > >> > processes, then it should fail for one process while should succeed > >> > for other. I wrote such function. Now I want to test it! How do I do > >> > that? How do I call a function exactly at same time from two > >> > different processes? > >> > >> It depends on how you define "called simultaneously". > >> > >> What do you mean "called simultaneously"? > >> What do you want to achieve? > >> > >> ? ? ? ? Georgy From tsuraan@REDACTED Tue Mar 3 19:45:04 2009 From: tsuraan@REDACTED (tsuraan) Date: Tue, 3 Mar 2009 12:45:04 -0600 Subject: [erlang-questions] Documentation error? Why would file:open/2 binary also require raw? Message-ID: <84fb38e30903031045j50f3f33bt37bf36e0c4cc364b@mail.gmail.com> The current file documentation says that if you open a file in binary mode, you must also specify raw mode. This doesn't actually seem to be the case; in addition, why would it be that way? Is this just a typo, or obsolete? Also, the documentation for compressed should probably indicate that you must choose to open the file in read or write mode; attempting to give [ read, write, compressed ] to file:open reliably gives me { error, einval }. From koops.j@REDACTED Tue Mar 3 20:34:58 2009 From: koops.j@REDACTED (Jeroen Koops) Date: Tue, 3 Mar 2009 20:34:58 +0100 Subject: [erlang-questions] How do you efficiently do this kind of mnesia schema? In-Reply-To: <10a0b334-2da8-47c3-b795-03546c4420b4@x29g2000prf.googlegroups.com> References: <10a0b334-2da8-47c3-b795-03546c4420b4@x29g2000prf.googlegroups.com> Message-ID: <331a9abb0903031134j5c0c461eib61c2af997a4d538@mail.gmail.com> My first guess would be using three tables, one for users, one for subitem_a, one for subitem_b. Each table has its own primary key. In addition, subitem A records have an attribute containing the owning user's id, which is indexed. Subitem B records have two extra attributes, one containing the id if the subitem A it belongs to, one containing the owning user's id. Both are indexed. You can now efficiently query on subitems A belonging to a user, subitems B belonging to some subitem A, and subitems B belonging to a user under any subitem A. Do keep in mind that the extra indexes use RAM though. Of course, the only way to know for sure is to whip up a quick test, which is done easily enough. Maybe not relevant to this particular problem, but keep in mind that indexes can not only be applied to 'simple' attributes, such as integers or strings - you can also apply them to tuples. So suppose you have a table containing documents, identified by a document_id, and a table containing words, identified by a word_id. To indicate which words appear in which documents, you have a third table, containing the document_id and the word_id. If you would need to see quickly if a certain word appears in a document, you could add a third column, containing a { DocumentId, WordId } tuple, and put an index on it. Checking if some word appears in some document can than be done by a single index read. On Tue, Mar 3, 2009 at 3:29 PM, ryeguy wrote: > I'm trying to break free of the RDBMS thought process, but I can't > wrap my head around how to efficiently implement this kind of schema. > > Say I have a User record, and he has many SubItemA records, which has > many SubItem B records, so: > > User > -SubItem A > --SubItem B > ... > > I need to run queries on SubItem B. Is it efficient to do it when it's > this nested? Should I just normalize it so it will be quicker? > > I have heard of some people using data duplication so the data is both > nested and separate, is this ridiculous or is this actually useful in > some cases? > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From twoggle@REDACTED Tue Mar 3 20:52:19 2009 From: twoggle@REDACTED (Tim Fletcher) Date: Tue, 3 Mar 2009 11:52:19 -0800 (PST) Subject: [erlang-questions] extended timer module to handle absolute time-of-day timers In-Reply-To: <1c89b3a10901130111u7fec793dq1b5d29c9aeb0c619@mail.gmail.com> References: <496C1D1B.3050501@gmail.com> <1c89b3a10901130111u7fec793dq1b5d29c9aeb0c619@mail.gmail.com> Message-ID: <19df0917-eb82-4d51-b969-ee96f1c91001@q30g2000vbn.googlegroups.com> > By the way; is there any "full blown" scheduler for erlang out there ? Not sure if it's what you're after, but there is gencron: http://code.google.com/p/gencron/ From r.b.lists@REDACTED Tue Mar 3 23:02:55 2009 From: r.b.lists@REDACTED (Roland Braito) Date: Tue, 03 Mar 2009 23:02:55 +0100 Subject: [erlang-questions] Erlang-to-C In-Reply-To: <49AD2166.50203@bigpond.net.au> References: <49ABC51D.7080107@bigpond.net.au> <20090303065951.270940@gmx.net> <49AD2166.50203@bigpond.net.au> Message-ID: <20090303220255.19410@gmx.net> erlang FFI has been implemented as a patch for release 11B, AFAIK the eep has been opened after its implementation. it has been used for the "erlang for high performance technical computing" project http://erlang.org/workshop/2008/Sess23.pdf for the patches have a look at http://muvara.org/crs4/erlang/ffi/ Best regards, Roland -------- Original-Nachricht -------- > Datum: Tue, 03 Mar 2009 23:24:06 +1100 > Von: Benjamin Tolputt > An: Roland Braito > CC: erlang-questions@REDACTED > Betreff: Re: [erlang-questions] Erlang-to-C > Roland Braito wrote: > > You might want to take a look at > > > > erlang FFI (Foreign Function Interface) > > > > It was my impression that this was still an EEP, without an actual > implementation > > > Dryverl > > > > Thanks for putting me onto this one. I am well aware of EDTK, but hadn't > heard of this further development. I will look into this and see how > well it caters to my requirements. > > -- > Regards, > > Benjamin Tolputt > Analyst Programmer -- Computer Bild Tarifsieger! GMX FreeDSL - Telefonanschluss + DSL f?r nur 17,95 ?/mtl.!* http://dsl.gmx.de/?ac=OM.AD.PD003K11308T4569a From tony@REDACTED Tue Mar 3 23:51:19 2009 From: tony@REDACTED (Tony Arcieri) Date: Tue, 3 Mar 2009 15:51:19 -0700 Subject: [erlang-questions] The Beauty of Erlang Syntax In-Reply-To: <49A7F9D3.8020706@erlang-consulting.com> References: <3e6f9520-f8cd-48f2-8ebf-1729538d1842@e24g2000vbe.googlegroups.com> <22226430.post@talk.nabble.com> <9b08084c0902260808hf9903b1yb0aa072e7e503160@mail.gmail.com> <22230905.post@talk.nabble.com> <49A71F16.3080205@erlang-consulting.com> <22244249.post@talk.nabble.com> <49A7F9D3.8020706@erlang-consulting.com> Message-ID: On Fri, Feb 27, 2009 at 7:33 AM, Ulf Wiger wrote: > So as I understand it, reia makes a similar simplification > to gen_server (sans some of the boilerplate, perhaps), but > semantically, it will be limited in for complex fsm > programming the same way gen_server and gen_fsm are limited, > which was exactly the reason plain_fsm. Erlang gives you > some goodness while forcing you to add other things yourself. Reia also has a Process module which wraps proc_lib for cases where gen_server is inadequate. -- Tony Arcieri -------------- next part -------------- An HTML attachment was scrubbed... URL: From michael.truog@REDACTED Wed Mar 4 00:05:12 2009 From: michael.truog@REDACTED (michael.truog@REDACTED) Date: Wed, 4 Mar 2009 00:05:12 +0100 Subject: [erlang-questions] Erlang-to-C In-Reply-To: <49AD2166.50203@bigpond.net.au> References: <49ABC51D.7080107@bigpond.net.au> <20090303065951.270940@gmx.net> <49AD2166.50203@bigpond.net.au> Message-ID: <227455977C217E4C8E1B1E066A3C370D27EAB8FAAB@NOK-EUMSG-01.mgdnok.nokia.com> You might want to also check out the Generic Erlang Port [Driver] code too. It is rather new and still being developed, but might prove a bit easier to use than EDTK and a bit more flexible than Dryverl (it is not meant to be similar to FFI). http://forum.trapexit.org/viewtopic.php?p=44406#44406 -----Original Message----- From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of ext Benjamin Tolputt Sent: Tuesday, March 03, 2009 4:24 AM To: Roland Braito Cc: erlang-questions@REDACTED Subject: Re: [erlang-questions] Erlang-to-C Roland Braito wrote: > You might want to take a look at > > erlang FFI (Foreign Function Interface) > It was my impression that this was still an EEP, without an actual implementation > Dryverl > Thanks for putting me onto this one. I am well aware of EDTK, but hadn't heard of this further development. I will look into this and see how well it caters to my requirements. -- Regards, Benjamin Tolputt Analyst Programmer _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions Disclaimer: My opinions are my own and are not related to any company. From ok@REDACTED Wed Mar 4 00:44:13 2009 From: ok@REDACTED (Richard O'Keefe) Date: Wed, 4 Mar 2009 12:44:13 +1300 Subject: [erlang-questions] Executing concurrently In-Reply-To: <9b08084c0903030841p48fbeed9v8a5807725f19becc@mail.gmail.com> References: <200903031309.13179.bekesa@sch.bme.hu> <9b08084c0903030841p48fbeed9v8a5807725f19becc@mail.gmail.com> Message-ID: <0E8A329F-48FE-4264-AA5C-4AE26E851CAA@cs.otago.ac.nz> On 4 Mar 2009, at 5:41 am, Joe Armstrong wrote: [an implementation of the two-calls-to-one-function-lets-one- proceed-and-fails-the-other request.] Thanks to the existence of - the self() function and - the process dictionary it is possible for the behaviour of a function to depend on which process it is invoked within. Joe's solution has the function invoked in a new process. If that satisfies the original poster's need, then I wonder what that need might be. Another approach makes use of locks -- as Joe suggested in his message -- and goes roughly like f(...) -> magic:acquire() Result = guts_of_f(...), magic:release(), Result. where ignoring the stuff about starting and registering the magic process, acquire() -> magic!{acquire, self()}, receive {magic,Outcome} -> ok = Outcome end. release() -> magic!{release, self()}. magic_available() -> receive {acquire,Pid)) -> Pid!{magic,ok}, magic_held(Pid) ; {release,_} -> exit() end. magic_held(Owner) -> receive {release,Owner} -> magic_available() ; {release,_} -> exit() ; {acquire,Pid} -> Pid!{magic,fail} end. WARNING: this is not only untested code, it is incomplete. Also, instead of the magic process exiting, we really want the client process to get an exception, but I'm too lazy to bother. And of course you probably want to catch exceptions around the call to guts_of_f(...) so that the magic token is always released. In fact, what we have here is nothing other than a mutex using trylock() and unlock() instead of the usual lock() and unlock(), which makes me wonder why the process that doesn't get to run the function should be failed rather than just being told to try again later. Joe said "this does not seem like good design", and if he says it, you'd better believe it. From mcpherson@REDACTED Wed Mar 4 02:17:37 2009 From: mcpherson@REDACTED (Allen McPherson) Date: Tue, 3 Mar 2009 18:17:37 -0700 Subject: [erlang-questions] Question about order of matching Message-ID: <493D42DC-B5EE-4944-A9BC-EC20BBC076FB@lanl.gov> I have the following receive loop: getResults(0) -> 'getResults ok'; getResults(N) -> receive {Test, ET, N, Bytes, Pid} -> io:format("~p: ET: ~p~n", [Test, ET]), getResults(N-1); 'unknown test' -> io:format("unknown test~n"), getResults(N-1); Any -> io:format("~p~n", [Any]), getResults(N-1) end. When it is sent the following message: MasterPid ! {allpairs, timer(wall_clock), N, Bytes, self()}, ..the Any clause (which I put in for debugging purposes because nothing was matching and the receive was blocking) matches and prints the following: {allpairs,2346,100,1048576,<6083.48.0>} {allpairs,2109,100,1048576,<6084.38.0>} {allpairs,2152,100,1048576,<6041.48.0>} {allpairs,2159,100,1048576,<6082.48.0>} I would have thought the first clause should have matched? I tested in the shell: (foo@REDACTED)1> {Test, ET, N, Bytes, Pid} = {allpairs, 2346,100,1048576,<6083.48.0>}. 1: syntax error before: '<' The shell does not like the Pid syntax and I've Googled around to see why this is a problem even when using pid_to_list and list_to_pid. This works though: (foo@REDACTED)1> {Test, ET, N, Bytes, Pid} = {allpairs, 2346,100,1048576,self()}. {allpairs,2346,100,1048576,<0.37.0>} And, removing Pid in shell works too: (foo@REDACTED)1> {Test, ET, N, Bytes} = {allpairs,2346,100,1048576}. {allpairs,2346,100,1048576} The same tactic (removing Pid) in the code still matches the Any clause. Perhaps I'm not understanding something fundamental here? I suspect this is a dumb mistake on my part but I can't see it. -- Al From harveyd@REDACTED Wed Mar 4 02:31:30 2009 From: harveyd@REDACTED (Dale Harvey) Date: Wed, 4 Mar 2009 01:31:30 +0000 Subject: [erlang-questions] Question about order of matching In-Reply-To: <493D42DC-B5EE-4944-A9BC-EC20BBC076FB@lanl.gov> References: <493D42DC-B5EE-4944-A9BC-EC20BBC076FB@lanl.gov> Message-ID: getResults(N) -> receive {Test, ET, N, Bytes, Pid} -> N is already bound and the receive clause wont match unless its equal 2009/3/4 Allen McPherson > I have the following receive loop: > > getResults(0) -> > 'getResults ok'; > getResults(N) -> > receive > {Test, ET, N, Bytes, Pid} -> > io:format("~p: ET: ~p~n", [Test, ET]), > getResults(N-1); > 'unknown test' -> > io:format("unknown test~n"), > getResults(N-1); > Any -> > io:format("~p~n", [Any]), > getResults(N-1) > end. > > > When it is sent the following message: > > MasterPid ! {allpairs, timer(wall_clock), N, Bytes, self()}, > > ..the Any clause (which I put in for debugging purposes because nothing > was matching and the receive was blocking) matches and prints the > following: > > {allpairs,2346,100,1048576,<6083.48.0>} > {allpairs,2109,100,1048576,<6084.38.0>} > {allpairs,2152,100,1048576,<6041.48.0>} > {allpairs,2159,100,1048576,<6082.48.0>} > > I would have thought the first clause should have matched? > I tested in the shell: > > (foo@REDACTED)1> {Test, ET, N, Bytes, Pid} = {allpairs, > 2346,100,1048576,<6083.48.0>}. > 1: syntax error before: '<' > > The shell does not like the Pid syntax and I've Googled around to see > why this > is a problem even when using pid_to_list and list_to_pid. > This works though: > > (foo@REDACTED)1> {Test, ET, N, Bytes, Pid} = {allpairs, > 2346,100,1048576,self()}. > {allpairs,2346,100,1048576,<0.37.0>} > > And, removing Pid in shell works too: > > (foo@REDACTED)1> {Test, ET, N, Bytes} = {allpairs,2346,100,1048576}. > {allpairs,2346,100,1048576} > > The same tactic (removing Pid) in the code still matches the Any clause. > > Perhaps I'm not understanding something fundamental here? I suspect > this is > a dumb mistake on my part but I can't see it. > > -- > Al > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tony@REDACTED Wed Mar 4 06:05:48 2009 From: tony@REDACTED (Tony Arcieri) Date: Tue, 3 Mar 2009 22:05:48 -0700 Subject: [erlang-questions] STM Message-ID: Are there any cases of someone trying to build a software transactional memory system on/into Erlang? -- Tony Arcieri -------------- next part -------------- An HTML attachment was scrubbed... URL: From bgustavsson@REDACTED Wed Mar 4 07:21:48 2009 From: bgustavsson@REDACTED (Bjorn Gustavsson) Date: Wed, 4 Mar 2009 07:21:48 +0100 Subject: [erlang-questions] Documentation error? Why would file:open/2 binary also require raw? In-Reply-To: <84fb38e30903031045j50f3f33bt37bf36e0c4cc364b@mail.gmail.com> References: <84fb38e30903031045j50f3f33bt37bf36e0c4cc364b@mail.gmail.com> Message-ID: <6672d0160903032221r29da07b6lca6b9fc24fbfde80@mail.gmail.com> Thanks! On Tue, Mar 3, 2009 at 7:45 PM, tsuraan wrote: > The current file documentation says that if you open a file in binary > mode, you must also specify raw mode. ?This doesn't actually seem to > be the case; in addition, why would it be that way? ?Is this just a > typo, or obsolete? Obsolete, and already corrected in the documentation for the upcoming R13A release. > Also, the documentation for compressed should probably indicate that > you must choose to open the file in read or write mode; attempting to > give [ read, write, compressed ] to file:open reliably gives me { > error, einval }. I have now added note about that in the R13A documentation. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From xbmodder@REDACTED Wed Mar 4 07:33:22 2009 From: xbmodder@REDACTED (Sargun Dhillon) Date: Tue, 3 Mar 2009 22:33:22 -0800 Subject: [erlang-questions] STM In-Reply-To: References: Message-ID: <7c9d57ea0903032233u56592dv7750ba02c4fc2184@mail.gmail.com> You can just use ETS really... As said by our friend Yariv Sadan: http://yarivsblog.com/articles/2008/05/13/erlang-does-have-shared-memory/ 2009/3/3 Tony Arcieri : > Are there any cases of someone trying to build a software transactional > memory system on/into Erlang? > > -- > Tony Arcieri > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From erlang@REDACTED Wed Mar 4 08:59:43 2009 From: erlang@REDACTED (Joe Armstrong) Date: Wed, 4 Mar 2009 08:59:43 +0100 Subject: [erlang-questions] STM In-Reply-To: References: Message-ID: <9b08084c0903032359y78cd1809yb48229a36d50352f@mail.gmail.com> Implemented about 14 years ago :-) mnesia:transaction(fun() -> ... end). http://erlang.org/doc/apps/mnesia/Mnesia_chap4.html /Joe 2009/3/4 Tony Arcieri : > Are there any cases of someone trying to build a software transactional > memory system on/into Erlang? > > -- > Tony Arcieri > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From erlang@REDACTED Wed Mar 4 09:11:05 2009 From: erlang@REDACTED (Joe Armstrong) Date: Wed, 4 Mar 2009 09:11:05 +0100 Subject: [erlang-questions] Executing concurrently In-Reply-To: <0E8A329F-48FE-4264-AA5C-4AE26E851CAA@cs.otago.ac.nz> References: <200903031309.13179.bekesa@sch.bme.hu> <9b08084c0903030841p48fbeed9v8a5807725f19becc@mail.gmail.com> <0E8A329F-48FE-4264-AA5C-4AE26E851CAA@cs.otago.ac.nz> Message-ID: <9b08084c0903040011h6ca56904ia10d85adfe94946a@mail.gmail.com> On Wed, Mar 4, 2009 at 12:44 AM, Richard O'Keefe wrote: > > On 4 Mar 2009, at 5:41 am, Joe Armstrong wrote: > [an implementation of the two-calls-to-one-function-lets-one- > ?proceed-and-fails-the-other request.] > > Thanks to the existence of > ?- the self() function and > ?- the process dictionary > it is possible for the behaviour of a function to depend on > which process it is invoked within. > > Joe's solution has the function invoked in a new process. > If that satisfies the original poster's need, then I wonder > what that need might be. > > Another approach makes use of locks -- as Joe suggested in his > message -- and goes roughly like > > ? ? ? ?f(...) -> > ? ? ? ? ? magic:acquire() > ? ? ? ? ? Result = guts_of_f(...), > ? ? ? ? ? magic:release(), > ? ? ? ? ? Result. > > where ignoring the stuff about starting and registering > the magic process, > > ? ? ? ?acquire() -> > ? ? ? ? ? ?magic!{acquire, self()}, > ? ? ? ? ? ?receive {magic,Outcome} -> ok = Outcome end. > > ? ? ? ?release() -> > ? ? ? ? ? ?magic!{release, self()}. > > ? ? ? ?magic_available() -> > ? ? ? ? ? ?receive > ? ? ? ? ? ? ? ?{acquire,Pid)) -> Pid!{magic,ok}, magic_held(Pid) > ? ? ? ? ? ? ?; {release,_} ? ?-> exit() > ? ? ? ? ? ?end. > > ? ? ? ?magic_held(Owner) -> > ? ? ? ? ? ?receive > ? ? ? ? ? ? ? ?{release,Owner} -> magic_available() > ? ? ? ? ? ? ?; {release,_} ? ? -> exit() > ? ? ? ? ? ? ?; {acquire,Pid} ? -> Pid!{magic,fail} > ? ? ? ? ? ?end. > > WARNING: this is not only untested code, it is incomplete. > Also, instead of the magic process exiting, we really want > the client process to get an exception, but I'm too lazy > to bother. ?And of course you probably want to catch > exceptions around the call to guts_of_f(...) so that the > magic token is always released. > > In fact, what we have here is nothing other than a mutex > using trylock() and unlock() instead of the usual > lock() and unlock(), which makes me wonder why the process > that doesn't get to run the function should be failed > rather than just being told to try again later. > > Joe said "this does not seem like good design", > and if he says it, you'd better believe it. Thank you - in fact one of my predictions appears to be coming true. I predicted (due to Amdahls law) that sequential bottlenecks would be our next big problem - with 10% sequential code we can go at most 10 times faster (on an infinite number of cores) but we'd need at least 10 cores before this was a problem. If 10% is sequential and we have 20 cores then we should have problems and we won't see a times ten speedup - despite the cores if we have nasty sequential bottlenecks. So now I'm running on 24 cores and seeing what we think are nasty sequential bottlenecks. At a detailed level we must be thinking about ways to isolate things as much as possible - the rule I guess should be "as much sharing as is essential for the problem and no more" This is probably going to get messy - I can imaging logarithmic trees of processes where we had a gen_server - the good news is that the API to (say) thinks like gen_server can remain constant but the implementation might get a tag complex :-) /Joe Armstrong > > From francesco@REDACTED Wed Mar 4 09:12:13 2009 From: francesco@REDACTED (Francesco Cesarini (Erlang Training and Consulting)) Date: Wed, 04 Mar 2009 08:12:13 +0000 Subject: [erlang-questions] SF Bay Area Erlang Factory - Registration Now Open Message-ID: <49AE37DD.3000308@erlang-consulting.com> Hi All, For our Bay Area Erlang Factory conference, we have so far managed to line up well over 30 talks and speakers (More are in the pipeline) speaking in six concurrent tracks over two days. For those interested, we start the week with four 3-day University tracks (Coucb DB, Quick Check, Erlang and OTP). Without doubt, this will be the largest gathering of Erlang expertise since last year's Erlang eXchange in London. (London dates have been set to June 25th and 26th. We are collecting speaker Bios and Abstracts right now. Sign up to the mailing list or subscribe to the RSS feed for more info). Registration is now open. Up to the 15th of March, we are offering a very Early Bird discount based on the full price rates. More information is available at http://www.erlang-factory.com/conference/SFBayAreaErlangFactory2009 If you have any questions, let us know. We hope to see you either there or in London. Francesco -- http://www.erlang-consulting.com From xbmodder@REDACTED Wed Mar 4 09:13:00 2009 From: xbmodder@REDACTED (Sargun Dhillon) Date: Wed, 4 Mar 2009 00:13:00 -0800 Subject: [erlang-questions] STM In-Reply-To: <9b08084c0903032359y78cd1809yb48229a36d50352f@mail.gmail.com> References: <9b08084c0903032359y78cd1809yb48229a36d50352f@mail.gmail.com> Message-ID: <7c9d57ea0903040013k59924cbeo4a14be5965d3caca@mail.gmail.com> Ah, yeah, you'd want to use mnesia as ETS is not transactional. If you don't need transactions, and care about speed look then ETS is what you want. Otherwise the closest thing to STM in Erlang is Mnesia. Just make sure you set the table type to: ram_copies. On Tue, Mar 3, 2009 at 11:59 PM, Joe Armstrong wrote: > Implemented about 14 years ago :-) > > mnesia:transaction(fun() -> > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?... > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? end). > > http://erlang.org/doc/apps/mnesia/Mnesia_chap4.html > > /Joe > > > 2009/3/4 Tony Arcieri : >> Are there any cases of someone trying to build a software transactional >> memory system on/into Erlang? >> >> -- >> Tony Arcieri >> >> _______________________________________________ >> 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 vikrant.patil@REDACTED Wed Mar 4 10:23:16 2009 From: vikrant.patil@REDACTED (Vikrant) Date: Wed, 4 Mar 2009 14:53:16 +0530 Subject: [erlang-questions] Executing concurrently In-Reply-To: <0E8A329F-48FE-4264-AA5C-4AE26E851CAA@cs.otago.ac.nz> References: <200903031309.13179.bekesa@sch.bme.hu> <9b08084c0903030841p48fbeed9v8a5807725f19becc@mail.gmail.com> <0E8A329F-48FE-4264-AA5C-4AE26E851CAA@cs.otago.ac.nz> Message-ID: 2009/3/4 Richard O'Keefe > > Joe said "this does not seem like good design", > and if he says it, you'd better believe it. > Yes Richard, I believe it :-) Thanks to all for the discussion and suggestions. Vikrant -------------- next part -------------- An HTML attachment was scrubbed... URL: From bbmaj7@REDACTED Wed Mar 4 10:29:23 2009 From: bbmaj7@REDACTED (Richard Andrews) Date: Wed, 4 Mar 2009 01:29:23 -0800 (PST) Subject: [erlang-questions] How many erlang developers are there? Message-ID: <804415.42859.qm@web65503.mail.ac4.yahoo.com> I'm curious. Has anyone got an estimate of the number of erlang developers globally? How many downloads does an OTP release get? Stay connected to the people that matter most with a smarter inbox. Take a look http://au.docs.yahoo.com/mail/smarterinbox From kenneth.lundin@REDACTED Wed Mar 4 11:05:41 2009 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Wed, 4 Mar 2009 11:05:41 +0100 Subject: [erlang-questions] How many erlang developers are there? In-Reply-To: <804415.42859.qm@web65503.mail.ac4.yahoo.com> References: <804415.42859.qm@web65503.mail.ac4.yahoo.com> Message-ID: The statistics from erlang.org shows that there are 6 - 7000 downloads of the source package or the prebuilt binary package for Windows per month (the last year). I don't know how the number of users can be estimated from that. /Kenneth , Erlang/OTP Ericsson On Wed, Mar 4, 2009 at 10:29 AM, Richard Andrews wrote: > > I'm curious. Has anyone got an estimate of the number of erlang developers globally? > > How many downloads does an OTP release get? > > > ? ? ?Stay connected to the people that matter most with a smarter inbox. Take a look http://au.docs.yahoo.com/mail/smarterinbox > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From rvirding@REDACTED Wed Mar 4 11:23:21 2009 From: rvirding@REDACTED (Robert Virding) Date: Wed, 4 Mar 2009 11:23:21 +0100 Subject: [erlang-questions] Unix domain sockets Message-ID: <3dbc6d1c0903040223w5a079909j8e8851332521efa3@mail.gmail.com> I just saw a lament in twitter that Erlang doesn't support Unix domain sockets. Is that so? If not is there a nice link to some documentation explaining that we do and how to do it? Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: From masse@REDACTED Wed Mar 4 11:26:39 2009 From: masse@REDACTED (mats cronqvist) Date: Wed, 04 Mar 2009 11:26:39 +0100 Subject: [erlang-questions] How many erlang developers are there? In-Reply-To: <804415.42859.qm@web65503.mail.ac4.yahoo.com> (Richard Andrews's message of "Wed\, 4 Mar 2009 01\:29\:23 -0800 \(PST\)") References: <804415.42859.qm@web65503.mail.ac4.yahoo.com> Message-ID: <87r61dh9cw.fsf@sterlett.hq.kred> Richard Andrews writes: > I'm curious. Has anyone got an estimate of the number of erlang developers globally? according to the Debian poularity contest; http://qa.debian.org/popcon.php?package=erlang there are ~500 computers that have erlang-dev installed. corresponding for python2.5-dev is ~5000. so python is about 10 times more popular than erlang(*). mats (*) I estimate the error bars on that to be about 1000% From chsu79@REDACTED Wed Mar 4 11:55:49 2009 From: chsu79@REDACTED (Christian) Date: Wed, 4 Mar 2009 11:55:49 +0100 Subject: [erlang-questions] Unix domain sockets In-Reply-To: <3dbc6d1c0903040223w5a079909j8e8851332521efa3@mail.gmail.com> References: <3dbc6d1c0903040223w5a079909j8e8851332521efa3@mail.gmail.com> Message-ID: OTP does not include any gen_file_socket or hidden support (?) for these sockets. The best "documentation" available describing how to get around it is probably: http://github.com/gebi/jungerl/blob/master/lib/unixdom_drv/test/unixdom_test.erl 2009/3/4 Robert Virding : > I just saw a lament in twitter that Erlang doesn't support Unix domain > sockets. Is that so? If not is there a nice link to some documentation > explaining that we do and how to do it? From ulf@REDACTED Wed Mar 4 14:18:01 2009 From: ulf@REDACTED (Ulf Wiger) Date: Wed, 4 Mar 2009 14:18:01 +0100 Subject: [erlang-questions] Unix domain sockets In-Reply-To: References: <3dbc6d1c0903040223w5a079909j8e8851332521efa3@mail.gmail.com> Message-ID: <8209f740903040518y3b3cc4b1j3b06165f3da3f3c8@mail.gmail.com> There's an example driver for unix domain sockets under $OTP_ROOT/lib/kernel/examples/uds_dist/ (It's still there in R13A-0, BTW.) It used to be documented in the Interoperability Tutorial, but I think they've switched to a different example now. BR, Ulf W 2009/3/4 Christian : > OTP does not include any gen_file_socket or hidden support (?) for > these sockets. The best "documentation" available describing how to > get around it is probably: > > http://github.com/gebi/jungerl/blob/master/lib/unixdom_drv/test/unixdom_test.erl > > 2009/3/4 Robert Virding : >> I just saw a lament in twitter that Erlang doesn't support Unix domain >> sockets. Is that so? If not is there a nice link to some documentation >> explaining that we do and how to do it? > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From masse@REDACTED Wed Mar 4 14:38:27 2009 From: masse@REDACTED (mats cronqvist) Date: Wed, 04 Mar 2009 14:38:27 +0100 Subject: [erlang-questions] Unix domain sockets In-Reply-To: <8209f740903040518y3b3cc4b1j3b06165f3da3f3c8@mail.gmail.com> (Ulf Wiger's message of "Wed\, 4 Mar 2009 14\:18\:01 +0100") References: <3dbc6d1c0903040223w5a079909j8e8851332521efa3@mail.gmail.com> <8209f740903040518y3b3cc4b1j3b06165f3da3f3c8@mail.gmail.com> Message-ID: <87ab81h0h8.fsf@sterlett.hq.kred> Ulf Wiger writes: > There's an example driver for unix domain sockets under > $OTP_ROOT/lib/kernel/examples/uds_dist/ I've used that. It works fine. mats From mjtruog@REDACTED Wed Mar 4 07:03:41 2009 From: mjtruog@REDACTED (Michael Truog) Date: Tue, 03 Mar 2009 22:03:41 -0800 Subject: [erlang-questions] STM In-Reply-To: References: Message-ID: <49AE19BD.9070203@gmail.com> Doesn't mnesia qualify with its support for transactions? Tony Arcieri wrote: > Are there any cases of someone trying to build a software > transactional memory system on/into Erlang? > > -- > Tony Arcieri > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From frej@REDACTED Tue Mar 3 12:07:21 2009 From: frej@REDACTED (Frej Drejhammar) Date: Tue, 03 Mar 2009 12:07:21 +0100 Subject: [erlang-questions] How to not cache a certain function in yaws In-Reply-To: (Anders Nygren's message of "Mon\, 2 Mar 2009 10\:11\:32 -0600") References: Message-ID: > The problem is that random is initailized with a default seed in each > process. And since You dont seed it yourself it will generate the same > sequence of numbers in each process. > > add something like this > > {A1,A2,A3} = now(), > random:seed(A1, A2, A3) > > before the call random:uniform(123) Congratulations, you just made your random string (nearly) deterministic... :-) If your random string is used as for anything security related you should use crypto:rand_uniform/2 instead or perhaps crypto:rand_bytes/1 and hexify or encode the returned binary to your liking. Regards, --Frej From erlang@REDACTED Wed Mar 4 15:54:23 2009 From: erlang@REDACTED (Joe Armstrong) Date: Wed, 4 Mar 2009 15:54:23 +0100 Subject: [erlang-questions] importing sql data Message-ID: <9b08084c0903040654h4a2910a6q8d4747b8b16cdf64@mail.gmail.com> I have a file, which if run into sql builds a data base. It starts like this: # For updates to this file, see http://27.org/isocountrylist/ # Created by getisocountrylist.pl on Sun Nov 2 14:59:20 2003. # Wm. Rhodes CREATE TABLE IF NOT EXISTS country ( iso CHAR(2) NOT NULL PRIMARY KEY, name VARCHAR(80) NOT NULL, printable_name VARCHAR(80) NOT NULL, iso3 CHAR(3), numcode SMALLINT ); INSERT INTO country VALUES ('AF','AFGHANISTAN','Afghanistan','AFG','004'); INSERT INTO country VALUES ('AL','ALBANIA','Albania','ALB','008'); INSERT INTO country VALUES ('DZ','ALGERIA','Algeria','DZA','012'); Has anybody the *obvious* bit of code I want. It parses the table definition, then reads all the table entries, type checking them against the table definition and returns everything in a single term. Alternatively a "fold" version that folds a function over the parsed and type checked entries. Surely somebody must have written this ... /Joe Armstrong From rtrlists@REDACTED Wed Mar 4 17:12:50 2009 From: rtrlists@REDACTED (Robert Raschke) Date: Wed, 4 Mar 2009 16:12:50 +0000 Subject: [erlang-questions] importing sql data In-Reply-To: <9b08084c0903040654h4a2910a6q8d4747b8b16cdf64@mail.gmail.com> References: <9b08084c0903040654h4a2910a6q8d4747b8b16cdf64@mail.gmail.com> Message-ID: <6a3ae47e0903040812ifdc1548i7416cb8f8829ee17@mail.gmail.com> On Wed, Mar 4, 2009 at 2:54 PM, Joe Armstrong wrote: > I have a file, which if run into sql builds a data base. > > It starts like this: > > # For updates to this file, see http://27.org/isocountrylist/ > # Created by getisocountrylist.pl on Sun Nov ?2 14:59:20 2003. > # Wm. Rhodes > > CREATE TABLE IF NOT EXISTS country ( > ?iso CHAR(2) NOT NULL PRIMARY KEY, > ?name VARCHAR(80) NOT NULL, > ?printable_name VARCHAR(80) NOT NULL, > ?iso3 CHAR(3), > ?numcode SMALLINT > ); > > INSERT INTO country VALUES ('AF','AFGHANISTAN','Afghanistan','AFG','004'); > INSERT INTO country VALUES ('AL','ALBANIA','Albania','ALB','008'); > INSERT INTO country VALUES ('DZ','ALGERIA','Algeria','DZA','012'); > > Has anybody the *obvious* bit of code I want. > > It parses the table definition, then reads all the table entries, type > checking them > against the table definition and returns everything in a single term. > Alternatively a > "fold" version that folds a function over the parsed and type checked entries. > > Surely somebody must have written this ... > > /Joe Armstrong Parsing SQL takes real dedication. Especially if you want to be able to go beyond just MySQL. Are there any free libraries out there that are able to translate SQL text (especially the DDL bit, where vendors go out of their way to be non-standard) into a suitable abstract form for further processing? Hmm, actually, now thinking of it, the MySQL dump format is along the lines of Joe's example. Maybe it's possible to access the parsing of that somehow and use it in a port program? I'm not familiar with the code of MySQL, so this might be futile, but you never know. Robby From mcpherson@REDACTED Wed Mar 4 17:25:55 2009 From: mcpherson@REDACTED (Allen McPherson) Date: Wed, 4 Mar 2009 08:25:55 -0800 (PST) Subject: [erlang-questions] Question about order of matching In-Reply-To: References: <493D42DC-B5EE-4944-A9BC-EC20BBC076FB@lanl.gov> Message-ID: <22333467.post@talk.nabble.com> Ouch. That "silent" failure would have taken me a bunch of time to find. Add that to my slowly growing bag of Erlang experience. Next time I will try and test the ENTIRE code in the shell--simplified little tests like the one I did obviously don't cut it for problems like this. harveyd wrote: > > getResults(N) -> > receive > {Test, ET, N, Bytes, Pid} -> > > N is already bound and the receive clause > wont match unless its equal > > 2009/3/4 Allen McPherson > >> I have the following receive loop: >> >> getResults(0) -> >> 'getResults ok'; >> getResults(N) -> >> receive >> {Test, ET, N, Bytes, Pid} -> >> io:format("~p: ET: ~p~n", [Test, ET]), >> getResults(N-1); >> 'unknown test' -> >> io:format("unknown test~n"), >> getResults(N-1); >> Any -> >> io:format("~p~n", [Any]), >> getResults(N-1) >> end. >> >> >> When it is sent the following message: >> >> MasterPid ! {allpairs, timer(wall_clock), N, Bytes, self()}, >> >> ..the Any clause (which I put in for debugging purposes because nothing >> was matching and the receive was blocking) matches and prints the >> following: >> >> {allpairs,2346,100,1048576,<6083.48.0>} >> {allpairs,2109,100,1048576,<6084.38.0>} >> {allpairs,2152,100,1048576,<6041.48.0>} >> {allpairs,2159,100,1048576,<6082.48.0>} >> >> I would have thought the first clause should have matched? >> I tested in the shell: >> >> (foo@REDACTED)1> {Test, ET, N, Bytes, Pid} = {allpairs, >> 2346,100,1048576,<6083.48.0>}. >> 1: syntax error before: '<' >> >> The shell does not like the Pid syntax and I've Googled around to see >> why this >> is a problem even when using pid_to_list and list_to_pid. >> This works though: >> >> (foo@REDACTED)1> {Test, ET, N, Bytes, Pid} = {allpairs, >> 2346,100,1048576,self()}. >> {allpairs,2346,100,1048576,<0.37.0>} >> >> And, removing Pid in shell works too: >> >> (foo@REDACTED)1> {Test, ET, N, Bytes} = {allpairs,2346,100,1048576}. >> {allpairs,2346,100,1048576} >> >> The same tactic (removing Pid) in the code still matches the Any clause. >> >> Perhaps I'm not understanding something fundamental here? I suspect >> this is >> a dumb mistake on my part but I can't see it. >> >> -- >> Al >> >> >> _______________________________________________ >> 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/Question-about-order-of-matching-tp22321837p22333467.html Sent from the Erlang Questions mailing list archive at Nabble.com. From public-mail@REDACTED Thu Mar 5 00:06:45 2009 From: public-mail@REDACTED (alekciy) Date: Thu, 05 Mar 2009 02:06:45 +0300 Subject: [erlang-questions] unary bitwise not Message-ID: Why 1> bnot 153. -154 ? I think 153 in binary 10011001 and after inverse = 01100110 = 102 in decimal. Why in -154? 01100110+1? From pfisher@REDACTED Thu Mar 5 00:14:38 2009 From: pfisher@REDACTED (Paul Fisher) Date: Wed, 04 Mar 2009 17:14:38 -0600 Subject: [erlang-questions] Anything faster than file_sorter available? Message-ID: <49AF0B5E.9010805@alertlogic.net> Has anyone run into issue that the file_sorter module ends up not being fast enough and you found something else that was faster? We are finding that sorting using the file_sorter module (even with all related code compiled with {hipe,o3}) is many times slower (4-5 times) than native code, sorting even on a single file containing on the order of 300k records. I've poked at this for a bit and have only been able to optimize the code to this point and no better. We are using R12B-5 with the HiPE patch. Any help would be greatly appreciated. -- paul From tony@REDACTED Thu Mar 5 00:16:11 2009 From: tony@REDACTED (Tony Arcieri) Date: Wed, 4 Mar 2009 16:16:11 -0700 Subject: [erlang-questions] STM In-Reply-To: <49AE19BD.9070203@gmail.com> References: <49AE19BD.9070203@gmail.com> Message-ID: On Tue, Mar 3, 2009 at 11:03 PM, Michael Truog wrote: > Doesn't mnesia qualify with its support for transactions? > That seems to be the general sentiment of the replies I'm getting here. Mnesia is certainly a transactional approach to dealing with shared state but I don't think that really qualifies it as an STM system. I'm afraid if we try to delve any deeper it's just going to turn into a semantic argument about what STM actually means, so to those of you who think Mnesia is an STM system, I'm just going to say "Great!" -- Tony Arcieri -------------- next part -------------- An HTML attachment was scrubbed... URL: From yinso.chen@REDACTED Thu Mar 5 00:28:25 2009 From: yinso.chen@REDACTED (YC) Date: Wed, 4 Mar 2009 15:28:25 -0800 Subject: [erlang-questions] unary bitwise not In-Reply-To: References: Message-ID: <779bf2730903041528p3b8b6acbh80687471d48bf558@mail.gmail.com> On Wed, Mar 4, 2009 at 3:06 PM, alekciy wrote: > Why > 1> bnot 153. > -154 > ? > > I think 153 in binary 10011001 and after inverse = 01100110 = 102 in > decimal. Why in -154? > > 01100110+1? > http://en.wikipedia.org/wiki/Two's_complement Cheers, -------------- next part -------------- An HTML attachment was scrubbed... URL: From bernie@REDACTED Thu Mar 5 00:29:57 2009 From: bernie@REDACTED (Bernard Duggan) Date: Thu, 05 Mar 2009 10:29:57 +1100 Subject: [erlang-questions] unary bitwise not In-Reply-To: References: Message-ID: <49AF0EF5.5050701@m5net.com> alekciy wrote: > Why > 1> bnot 153. > -154 > ? > > I think 153 in binary 10011001 and after inverse = 01100110 = 102 in > decimal. Why in -154? > Actually, to start with, 153 in binary is Except it's not just 10011001, it's 0000000010011001. Probably more leading zeros, actually, depending on erlang's internal representation, but let's assume 16 bit to save typing - any more leading zeros still gives the same result) - after inverting: 1111111101100110 which is the 16-bit two's complement form of -154. Cheers, Bernard From ok@REDACTED Thu Mar 5 01:33:45 2009 From: ok@REDACTED (Richard O'Keefe) Date: Thu, 5 Mar 2009 13:33:45 +1300 Subject: [erlang-questions] Unix domain sockets In-Reply-To: <8209f740903040518y3b3cc4b1j3b06165f3da3f3c8@mail.gmail.com> References: <3dbc6d1c0903040223w5a079909j8e8851332521efa3@mail.gmail.com> <8209f740903040518y3b3cc4b1j3b06165f3da3f3c8@mail.gmail.com> Message-ID: <41545C31-E9D4-43C6-A826-A0804D2A3459@cs.otago.ac.nz> On 5 Mar 2009, at 2:18 am, Ulf Wiger wrote: > lib/kernel/examples/uds_dist/ I never knew about that before. Thanks. If this is about Unix Domain Sockets, why does uds_dist.app say {description, "SSL socket version 2"}? (That's in R12B-5.) From tony@REDACTED Thu Mar 5 01:48:39 2009 From: tony@REDACTED (Tony Arcieri) Date: Wed, 4 Mar 2009 17:48:39 -0700 Subject: [erlang-questions] STM In-Reply-To: <7c9d57ea0903041627n7e309b38m6240f75b8a9f40fd@mail.gmail.com> References: <49AE19BD.9070203@gmail.com> <7c9d57ea0903041627n7e309b38m6240f75b8a9f40fd@mail.gmail.com> Message-ID: On Wed, Mar 4, 2009 at 5:27 PM, Sargun Dhillon wrote: > How is it not? > When I asked the question I probably should've mentioned I had Clojure on the brain. Clojure has first-class support for STM and permits mutable state within "atomic" sections of code (where it has immutable state otherwise) I suppose I was wondering if someone had ever experimented with a system like that which permits transactional node-local mutable state. And I guess the answer is still Mnesia does that... to a degree. However Mnesia requires you configure tables/schema ahead of time and it certainly isn't a first-class language feature, not that that's a requirement of STM systems. -- Tony Arcieri medioh.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From public-mail@REDACTED Thu Mar 5 01:55:45 2009 From: public-mail@REDACTED (alekciy) Date: Thu, 05 Mar 2009 03:55:45 +0300 Subject: [erlang-questions] multi sending Message-ID: In doc write: " Expr1 ! Expr2 Sends the value of Expr2 as a message to the process specified by Expr1." How I can send one message to many process similar multicast in LAN? Only inside loop? From ok@REDACTED Thu Mar 5 01:57:30 2009 From: ok@REDACTED (Richard O'Keefe) Date: Thu, 5 Mar 2009 13:57:30 +1300 Subject: [erlang-questions] unary bitwise not In-Reply-To: <49AF0EF5.5050701@m5net.com> References: <49AF0EF5.5050701@m5net.com> Message-ID: Thinking about bitwise operations in terms of bytes is a good way to get confused. Binary numbers go *all* the way to the left. The bottom line is that bnot X = -1 -X, so I don't need to look at the bits to tell that bnot 153 *should* be -154. (Hint: -1 is an infinite number of 1 bits, going *all* the way to the left. Subtracting a binary number from that bit pattern doesn't involve any borrows. In each column, 1 - 1 => 0, 1 - 0 => 1, so this really does flip all the bits.) From tony@REDACTED Thu Mar 5 02:35:22 2009 From: tony@REDACTED (Tony Arcieri) Date: Wed, 4 Mar 2009 18:35:22 -0700 Subject: [erlang-questions] STM In-Reply-To: References: <49AE19BD.9070203@gmail.com> <7c9d57ea0903041627n7e309b38m6240f75b8a9f40fd@mail.gmail.com> Message-ID: And as a more general question, how could Erlang improve its performance on problems like chameneos-redux? http://shootout.alioth.debian.org/u32q/benchmark.php?test=chameneosredux&lang=hipe&id=1 This is a benchmark where Erlang's poor performance sticks out like a sore thumb. The frontrunners (on the quad-core benchmark) are Haskell, C++, Scala, C, and Java. Erlang comes in dead last. A school of thought seems to exist that because Erlang fares poorly on these sorts of problems that you shouldn't even try to use Erlang to address them, and that's not a school of thought I particularly like. -- Tony Arcieri medioh.com From kevin@REDACTED Thu Mar 5 03:48:31 2009 From: kevin@REDACTED (Kevin Scaldeferri) Date: Wed, 4 Mar 2009 21:48:31 -0500 Subject: [erlang-questions] STM In-Reply-To: References: <49AE19BD.9070203@gmail.com> <7c9d57ea0903041627n7e309b38m6240f75b8a9f40fd@mail.gmail.com> Message-ID: <6EAD6412-75F8-4A1E-8509-84037F32D6A9@scaldeferri.com> On Mar 4, 2009, at 8:35 PM, Tony Arcieri wrote: > And as a more general question, how could Erlang improve its > performance on problems like chameneos-redux? > > http://shootout.alioth.debian.org/u32q/benchmark.php?test=chameneosredux&lang=hipe&id=1 > > This is a benchmark where Erlang's poor performance sticks out like a > sore thumb. The frontrunners (on the quad-core benchmark) are > Haskell, C++, Scala, C, and Java. Erlang comes in dead last. > > A school of thought seems to exist that because Erlang fares poorly on > these sorts of problems that you shouldn't even try to use Erlang to > address them, and that's not a school of thought I particularly like. > It may be worth noting that the Haskell entrants have apparently also concluded that concurrency is of limited help to them in this benchmark: collect1 <- run 1 n [Blue ..] collect2 <- run 2 n [Blue, Red, Yellow, Red, Yellow, Blue, Red, Yellow, Red, Blue] The 1 and 2 are constraining the two computations to run on specific CPUs for their entire lifetimes. So, they don't experience the overhead of message passing between CPUs which the erlang solution does, although naively they appear to be quite similar solutions. The C++ entry is only able to get close by very carefully tuning their pthreads and the linux scheduler. On a different kernel version or a different number of CPUs, it might have decidedly different performance. On a different OS, the code won't even compile. Despite all this, they still can't quite beat Haskell on wall time, and chew up twice the CPU time doing it. No one else using concurrency is getting particularly close to Haskell on either wall or CPU time. I've said before, since this extreme level of tweaking is permitted on the shootout, the Erlang community should at least request that this benchmark be run with a only a single scheduler thread. It would at least stop being embarrassing then. -k From cliff@REDACTED Thu Mar 5 05:48:19 2009 From: cliff@REDACTED (Cliff Moon) Date: Wed, 04 Mar 2009 20:48:19 -0800 Subject: [erlang-questions] memsup gives weird values Message-ID: <49AF5993.4000500@moonpolysoft.com> Has anyone noticed that memsup gives ridiculous numbers on OS X? I have Mac OS X leopard and Erlang R12B-3 installed. In a straight erl shell with nothing loaded I get the following: application:load(sasl). application:start(sasl). application:load(os_mon). application:start(os_mon). 5> memsup:get_system_memory_data(). [{total_memory,3139076000}, {free_memory,569280000}, {system_total_memory,3139076000}] 6> memsup:get_memory_data(). {3139076000,2569796000,{<0.5.0>,229732}} Which is clearly wrong. ps reports: cliff 48425 0.0 0.2 89936 6428 s001 S+ 8:40PM 0:00.18 /p/lib/erlang//erts-5.6.3/bin/beam.smp So a resident set size of about 6k. Is this behavior fixed in later revisions of Erlang? Or is this only expected to work on linux? From jlprasantha@REDACTED Thu Mar 5 08:13:14 2009 From: jlprasantha@REDACTED (prasantha kumara) Date: Thu, 5 Mar 2009 12:43:14 +0530 Subject: [erlang-questions] how to decode octet to septets using erlang Message-ID: Hi all, I am strugling with decode octet to septet using erlang.Can anybody tell me how to decode octet to septet using erlang? thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf.wiger@REDACTED Thu Mar 5 08:29:09 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Thu, 05 Mar 2009 07:29:09 +0000 Subject: [erlang-questions] multi sending In-Reply-To: References: Message-ID: <49AF7F45.3030506@erlang-consulting.com> alekciy wrote: > In doc write: " > Expr1 ! Expr2 > Sends the value of Expr2 as a message to the process specified by Expr1." > > How I can send one message to many process similar multicast in LAN? Only > inside loop? The expression (Pid ! Msg) returns Msg, so if you know the pids or registered names of the recipients, you can write P1 ! P2 ! P3 ! ... ! Msg Otherwise, a loop, e.g. [ P ! Msg || P <- Pids] BR, Ulf W -- Ulf Wiger CTO, Erlang Training & Consulting Ltd http://www.erlang-consulting.com From erlang@REDACTED Thu Mar 5 09:07:24 2009 From: erlang@REDACTED (Joe Armstrong) Date: Thu, 5 Mar 2009 09:07:24 +0100 Subject: [erlang-questions] STM In-Reply-To: References: <49AE19BD.9070203@gmail.com> Message-ID: <9b08084c0903050007l6dbfd9fdy1ab2253f5e2ce2b9@mail.gmail.com> I wrote the following a while back - it's a very simple implementation of what I think is a transactional memory - as far as I can see this mirrors what the hardware guys thinks is a transactional memory. It's just a simple generalization of the good 'ol test and set. http://armstrongonsoftware.blogspot.com/2006/09/pure-and-simple-transaction-memories.html I actually think TMs are a bad idea - it's still shared state - and if the TM fails then everything gets screwed up. Adding a TM to a system changes the failure characteristics of the system. A good goal of systems design is to isolate things as much as possible - A better approach is a DHT with a fault-tolerant replicated store and transactions (like scalaris) - it has worse latency but is highly scalable and also offers transactions - what more could you want? (perhaps a TM cache in front of scalaris :-) /Joe Armstrong 2009/3/5 Tony Arcieri : > On Tue, Mar 3, 2009 at 11:03 PM, Michael Truog wrote: >> >> Doesn't mnesia qualify with its support for transactions? > > That seems to be the general sentiment of the replies I'm getting here. > Mnesia is certainly a transactional approach to dealing with shared state > but I don't think that really qualifies it as an STM system.? I'm afraid if > we try to delve any deeper it's just going to turn into a semantic argument > about what STM actually means, so to those of you who think Mnesia is an STM > system, I'm just going to say "Great!" > > -- > Tony Arcieri > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From ulf.wiger@REDACTED Thu Mar 5 09:43:51 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Thu, 05 Mar 2009 08:43:51 +0000 Subject: [erlang-questions] STM In-Reply-To: References: <49AE19BD.9070203@gmail.com> <7c9d57ea0903041627n7e309b38m6240f75b8a9f40fd@mail.gmail.com> Message-ID: <49AF90C7.6030707@erlang-consulting.com> Tony Arcieri wrote: > And as a more general question, how could Erlang improve its > performance on problems like chameneos-redux? > > http://shootout.alioth.debian.org/u32q/benchmark.php?test=chameneosredux&lang=hipe&id=1 > > This is a benchmark where Erlang's poor performance sticks out like a > sore thumb. The frontrunners (on the quad-core benchmark) are > Haskell, C++, Scala, C, and Java. Erlang comes in dead last. Interestingly, when I gave a presentation at DAMP* in February, and mentioned this benchmark particularly, Simon Marlow also gave a great talk about about the concurrency mechanisms in Haskell. He commented that MVars are great for building other concurrency constructs, but not very useful for application programming, as it's far too low-level. The Haskell version of chameneos_redux relies critically on MVars, and all the top entries use various forms of spin locks. * http://www.cse.unsw.edu.au/~pls/damp09/programme.html There are many things about chameneous_redux that cause problems for the Erlang VM, and it's used as one benchmark in the work to optimize it. Still, the expressed goal for the optimization work is to give speedup to typical Erlang programs without forcing programmers to rewrite their code for multicore. At the other end of the spectrum, I recently observed an erlang-based system under extreme load reach 350% CPU on a quad-core (i.e. max is 400%, and given that the cores must share memory and peripherals, I doubt that you can get much higher utilization than that), still maintaining good througput while handling the incoming burst gracefully. That's pretty amazing. > A school of thought seems to exist that because Erlang > fares poorly on these sorts of problems that you > shouldn't even try to use Erlang to address them, > and that's not a school of thought I particularly like. One particular trait about Erlang is that it ranks pretty high on conceptual integrity (IMHO) - a bit like SmallTalk and Haskell, it has a clear idea on how you should write programs. I won't claim that this concept absolutely precludes efficient solutions to problems like chameneos_redux, but at least I think that the maintainers of the Erlang VM have their priorities straight. ;-) BR, Ulf W -- Ulf Wiger CTO, Erlang Training & Consulting Ltd http://www.erlang-consulting.com From public-mail@REDACTED Thu Mar 5 10:12:34 2009 From: public-mail@REDACTED (alekciy) Date: Thu, 05 Mar 2009 12:12:34 +0300 Subject: [erlang-questions] unary bitwise not Message-ID: <51587d149bee33a9938df2bb1b9abf31@mail.vline.ru> Thank! I will think of it as X = -1 -X. From public-mail@REDACTED Thu Mar 5 10:15:40 2009 From: public-mail@REDACTED (alekciy) Date: Thu, 05 Mar 2009 12:15:40 +0300 Subject: [erlang-questions] multi sending Message-ID: <0f96da238e2bbadb45d1bf20d722ed27@mail.vline.ru> Thx! I'm happy. [ P ! Msg || P <- Pids] this is what I need. From ulf.wiger@REDACTED Thu Mar 5 10:20:41 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Thu, 05 Mar 2009 09:20:41 +0000 Subject: [erlang-questions] The Beauty of Erlang Syntax In-Reply-To: References: <3e6f9520-f8cd-48f2-8ebf-1729538d1842@e24g2000vbe.googlegroups.com> <22226430.post@talk.nabble.com> <9b08084c0902260808hf9903b1yb0aa072e7e503160@mail.gmail.com> <22230905.post@talk.nabble.com> <49A71F16.3080205@erlang-consulting.com> <22244249.post@talk.nabble.com> <49A7F9D3.8020706@erlang-consulting.com> Message-ID: <49AF9969.3030207@erlang-consulting.com> Tony Arcieri wrote: > On Fri, Feb 27, 2009 at 7:33 AM, Ulf Wiger > > wrote: > > So as I understand it, reia makes a similar simplification > to gen_server (sans some of the boilerplate, perhaps), but > semantically, it will be limited in for complex fsm > programming the same way gen_server and gen_fsm are limited, > which was exactly the reason plain_fsm. Erlang gives you > some goodness while forcing you to add other things yourself. > > > Reia also has a Process module which wraps proc_lib for cases where > gen_server is inadequate. Glad to hear it. I hope I'm not coming across as a Reia basher. I really haven't looked at it enough to have formed an independent opinion. In general, I'm very much in favour of attempts to build other languages on top of the Erlang VM - like LFE, STOE, Haskell on Rails and Reia. Whatever comes out of them, surely these are worthy pursuits. (: BR, Ulf W -- Ulf Wiger CTO, Erlang Training & Consulting Ltd http://www.erlang-consulting.com From fei@REDACTED Thu Mar 5 11:04:56 2009 From: fei@REDACTED (fei wang) Date: Thu, 5 Mar 2009 18:04:56 +0800 Subject: [erlang-questions] How many processes is suit to one service in OTP system Message-ID: In an OTP application, if a service module will be called for a large times in a short term. Should I make one or more copy of the process, let them do one same thing? -- -- --------------- ? ?? ?? -------------- next part -------------- An HTML attachment was scrubbed... URL: From rapsey@REDACTED Thu Mar 5 11:41:29 2009 From: rapsey@REDACTED (Rapsey) Date: Thu, 5 Mar 2009 11:41:29 +0100 Subject: [erlang-questions] How many processes is suit to one service in OTP system In-Reply-To: References: Message-ID: <97619b170903050241t43d33aacje9d9d9bd3234dc15@mail.gmail.com> If it makes sense, why not. Sergej 2009/3/5 fei wang > In an OTP application, if a service module will be called for a large > times in a short term. Should I make one or more copy of the process, let > them do one same thing? > > -- > -- > > --------------- > ? > ?? > > > ?? > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tony.seebregts@REDACTED Thu Mar 5 12:31:07 2009 From: tony.seebregts@REDACTED (Tony Seebregts) Date: Thu, 5 Mar 2009 13:31:07 +0200 Subject: [erlang-questions] Re. How to decode octet to septets using erlang (prasantha kumara) Message-ID: This is an extract from the code I use: > unpack(UD) -> > septets(list_to_binary([ flip(X) || X <- binary_to_list(UD) ])). > > septets(T) -> > [ flipx(X) || <> <= T]. > > % Flips the bits in an octet/septet for easy unpacking > > flip(Octet) -> > <> = <>, > <>. > There is probably a better way of doing it but I was in a rush at the time :-) -------------- next part -------------- An HTML attachment was scrubbed... URL: From egil@REDACTED Thu Mar 5 12:58:22 2009 From: egil@REDACTED (=?ISO-8859-1?Q?Bj=F6rn-Egil_Dahlberg?=) Date: Thu, 05 Mar 2009 12:58:22 +0100 Subject: [erlang-questions] memsup gives weird values In-Reply-To: <49AF5993.4000500@moonpolysoft.com> References: <49AF5993.4000500@moonpolysoft.com> Message-ID: <49AFBE5E.5050702@erix.ericsson.se> System memory and memory data states that you have about 3 GB of memory total and that the allocated memory system wide (including erlang, other os processes, io buffers, etc) has allocated about 2.5 GB of your total memory. Is that consistent with your system? If so this seems correct, or am I missing something? // Bj?rn-Egil Erlang/OTP Cliff Moon wrote: > Has anyone noticed that memsup gives ridiculous numbers on OS X? I have > Mac OS X leopard and Erlang R12B-3 installed. In a straight erl shell > with nothing loaded I get the following: > > application:load(sasl). > application:start(sasl). > application:load(os_mon). > application:start(os_mon). > 5> memsup:get_system_memory_data(). > > [{total_memory,3139076000}, > {free_memory,569280000}, > {system_total_memory,3139076000}] > > 6> memsup:get_memory_data(). > > {3139076000,2569796000,{<0.5.0>,229732}} > > > Which is clearly wrong. ps reports: > > cliff 48425 0.0 0.2 89936 6428 s001 S+ 8:40PM 0:00.18 > /p/lib/erlang//erts-5.6.3/bin/beam.smp > > So a resident set size of about 6k. Is this behavior fixed in later > revisions of Erlang? Or is this only expected to work on linux? > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From vychodil.hynek@REDACTED Thu Mar 5 13:08:39 2009 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Thu, 5 Mar 2009 13:08:39 +0100 Subject: [erlang-questions] Re. How to decode octet to septets using erlang (prasantha kumara) In-Reply-To: References: Message-ID: <4d08db370903050408u29550d9fmc157dea1f8757659@mail.gmail.com> Why not? unpack(UD) -> << <<0:1,X/bits>> || <> <= UD >>. 2009/3/5 Tony Seebregts > This is an extract from the code I use: > >> unpack(UD) -> >> septets(list_to_binary([ flip(X) || X <- binary_to_list(UD) ])). >> >> septets(T) -> >> [ flipx(X) || <> <= T]. >> >> % Flips the bits in an octet/septet for easy unpacking >> >> flip(Octet) -> >> <> = <>, >> <>. >> > > There is probably a better way of doing it but I was in a rush at the time > :-) > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- --Hynek (Pichi) Vychodil Analyze your data in minutes. Share your insights instantly. Thrill your boss. Be a data hero! Try Good Data now for free: www.gooddata.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From rapsey@REDACTED Thu Mar 5 13:14:26 2009 From: rapsey@REDACTED (Rapsey) Date: Thu, 5 Mar 2009 13:14:26 +0100 Subject: [erlang-questions] How many processes is suit to one service in OTP system In-Reply-To: References: <97619b170903050241t43d33aacje9d9d9bd3234dc15@mail.gmail.com> Message-ID: <97619b170903050414o43f425eaua75dede98f9cc9d2@mail.gmail.com> A process can receive and handle only one message at a time. Sergej On Thu, Mar 5, 2009 at 12:31 PM, fei wang wrote: > Problem is I don't know whether it is sense.... > In fact I thing this problem is due to I don't know the message receiving > in an erlang process is whether blocking or none-blocking. > If it is none-blocking, two processes will do the same works as one. > > 2009/3/5 Rapsey > > If it makes sense, why not. >> >> >> Sergej >> >> 2009/3/5 fei wang >> >>> In an OTP application, if a service module will be called for a large >>> times in a short term. Should I make one or more copy of the process, let >>> them do one same thing? >>> >>> -- >>> -- >>> >>> --------------- >>> ? >>> ?? >>> >>> >>> ?? >>> >>> _______________________________________________ >>> 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 tony.seebregts@REDACTED Thu Mar 5 13:36:06 2009 From: tony.seebregts@REDACTED (Tony Seebregts) Date: Thu, 5 Mar 2009 14:36:06 +0200 Subject: [erlang-questions] Re. How to decode octet to septets using erlang (prasantha kumara) In-Reply-To: <4d08db370903050408u29550d9fmc157dea1f8757659@mail.gmail.com> References: <4d08db370903050408u29550d9fmc157dea1f8757659@mail.gmail.com> Message-ID: Hmmm , the short answer is that the code I suggested is taken from a module to convert a GSM octet stream into a septet stream and it gives a different answer when using your more compact code :-) : UD: << 203,176,184,204,86,191,1 >> Mine: [75,97,98,101,108,106,111,0] Yours: << 101,108,23,12,98,90,126,1>> I remember the GSM octet-septet conversion being quite awkward to get right because the bytes were the 'wrong way round' which is probably why I ended up with the code I did i.e. having to use flip(...). 2009/3/5 Hynek Vychodil > Why not? > > unpack(UD) -> > << <<0:1,X/bits>> || <> <= UD >>. > > 2009/3/5 Tony Seebregts > >> This is an extract from the code I use: >> >>> unpack(UD) -> >>> septets(list_to_binary([ flip(X) || X <- binary_to_list(UD) ])). >>> >>> septets(T) -> >>> [ flipx(X) || <> <= T]. >>> >>> % Flips the bits in an octet/septet for easy unpacking >>> >>> flip(Octet) -> >>> <> = <>, >>> <>. >>> >> >> There is probably a better way of doing it but I was in a rush at the time >> :-) >> >> >> >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > > > -- > --Hynek (Pichi) Vychodil > > Analyze your data in minutes. Share your insights instantly. Thrill your > boss. Be a data hero! > Try Good Data now for free: www.gooddata.com > -------------- next part -------------- An HTML attachment was scrubbed... URL: From toby@REDACTED Thu Mar 5 14:16:50 2009 From: toby@REDACTED (Toby Thain) Date: Thu, 5 Mar 2009 08:16:50 -0500 Subject: [erlang-questions] importing sql data In-Reply-To: <6a3ae47e0903040812ifdc1548i7416cb8f8829ee17@mail.gmail.com> References: <9b08084c0903040654h4a2910a6q8d4747b8b16cdf64@mail.gmail.com> <6a3ae47e0903040812ifdc1548i7416cb8f8829ee17@mail.gmail.com> Message-ID: <22BC9DFC-B341-4FF2-9B35-280A710E2BD5@telegraphics.com.au> On 4-Mar-09, at 11:12 AM, Robert Raschke wrote: > On Wed, Mar 4, 2009 at 2:54 PM, Joe Armstrong > wrote: >> I have a file, which if run into sql builds a data base. >> >> It starts like this: >> >> # For updates to this file, see http://27.org/isocountrylist/ >> # Created by getisocountrylist.pl on Sun Nov 2 14:59:20 2003. >> # Wm. Rhodes >> >> CREATE TABLE IF NOT EXISTS country ( >> ... >> Surely somebody must have written this ... >> >> /Joe Armstrong > > Parsing SQL takes real dedication. Especially if you want to be able > to go beyond just MySQL. Especially since it comes in hundreds of flavours... > > Are there any free libraries out there that are able to translate SQL > text (especially the DDL bit, where vendors go out of their way to be > non-standard) into a suitable abstract form for further processing? > > Hmm, actually, now thinking of it, the MySQL dump format is along the > lines of Joe's example. Maybe it's possible to access the parsing of > that somehow and use it in a port program? I'm not familiar with the > code of MySQL, so this might be futile, but you never know. The quickest way to solve Joe's immediate problem is, I suspect, to simply load the SQL into MySQL and export it as tab-delimited or CSV text, or better yet write a simple SQL query to produce Erlang terms. Why write a SQL parser when you can use somebody else's?! The MySQL CLI client can easily be integrated into a batch build/import! mysql -B test < country_list.sql mysql -B -e "SELECT..." test | whatever --Toby > > Robby > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From vychodil.hynek@REDACTED Thu Mar 5 16:44:58 2009 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Thu, 5 Mar 2009 16:44:58 +0100 Subject: [erlang-questions] Re. How to decode octet to septets using erlang (prasantha kumara) In-Reply-To: References: <4d08db370903050408u29550d9fmc157dea1f8757659@mail.gmail.com> Message-ID: <4d08db370903050744y725cdaebha8043331c8d28234@mail.gmail.com> Well, GSM using weird coding. This similar to your solution is: unpack(UD) -> << <<0:1,A:1,B:1,C:1,D:1,E:1,F:1,G:1>> || <> <= << <> || <> <= UD >> >>. It is 2-10 times faster on my laptop (depend of GC hit) in byte code and 4 times in native. 2009/3/5 Tony Seebregts > Hmmm , the short answer is that the code I suggested is taken from a module > to convert a GSM octet stream into a septet stream and it gives a different > answer when using your more compact code :-) : > UD: << 203,176,184,204,86,191,1 >> > Mine: [75,97,98,101,108,106,111,0] > Yours: << 101,108,23,12,98,90,126,1>> > > I remember the GSM octet-septet conversion being quite awkward to get right > because the bytes were the 'wrong way round' which is probably why I ended > up with the code I did i.e. having to use flip(...). > > > 2009/3/5 Hynek Vychodil > >> Why not? >> >> >> unpack(UD) -> >> << <<0:1,X/bits>> || <> <= UD >>. >> >> 2009/3/5 Tony Seebregts >> >>> This is an extract from the code I use: >>> >>>> unpack(UD) -> >>>> septets(list_to_binary([ flip(X) || X <- binary_to_list(UD) ])). >>>> >>>> septets(T) -> >>>> [ flipx(X) || <> <= T]. >>>> >>>> % Flips the bits in an octet/septet for easy unpacking >>>> >>>> flip(Octet) -> >>>> <> = <>, >>>> <>. >>>> >>> >>> There is probably a better way of doing it but I was in a rush at the >>> time :-) >>> >>> >>> >>> >>> >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://www.erlang.org/mailman/listinfo/erlang-questions >>> >> >> >> >> -- >> --Hynek (Pichi) Vychodil >> >> Analyze your data in minutes. Share your insights instantly. Thrill your >> boss. Be a data hero! >> Try Good Data now for free: www.gooddata.com >> > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- --Hynek (Pichi) Vychodil Analyze your data in minutes. Share your insights instantly. Thrill your boss. Be a data hero! Try Good Data now for free: www.gooddata.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From vychodil.hynek@REDACTED Thu Mar 5 17:51:58 2009 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Thu, 5 Mar 2009 17:51:58 +0100 Subject: [erlang-questions] Re. How to decode octet to septets using erlang (prasantha kumara) In-Reply-To: <4d08db370903050744y725cdaebha8043331c8d28234@mail.gmail.com> References: <4d08db370903050408u29550d9fmc157dea1f8757659@mail.gmail.com> <4d08db370903050744y725cdaebha8043331c8d28234@mail.gmail.com> Message-ID: <4d08db370903050851s468cf45l60ef533717f53392@mail.gmail.com> Code below does more than 20MB/s (more than 14 times faster than yours) on my 2.2GHz notebook using native: unpack3(UD) -> unpack3(<<>>, UD, <<>>). unpack3(_, <<>>, Acc) -> Acc; % <-- implement your padding here if you want unpack3(<<>>, <>, Acc) -> unpack3(<<>>, Rest, <>); unpack3(<<>>, <>, Acc) -> unpack3(<>, Rest, <>); unpack3(<>, <>, Acc) -> unpack3(<>, Rest, <>); unpack3(<>, <>, Acc) -> unpack3(<>, Rest, <>); unpack3(<>, <>, Acc) -> unpack3(<>, Rest, <>); unpack3(<>, <>, Acc) -> unpack3(<>, Rest, <>); unpack3(<>, <>, Acc) -> unpack3(<>, Rest, <>); unpack3(<>, <>, Acc) -> unpack3(<<>>, Rest, <>). On Thu, Mar 5, 2009 at 4:44 PM, Hynek Vychodil wrote: > Well, GSM using weird coding. > This similar to your solution is: > > unpack(UD) -> > << <<0:1,A:1,B:1,C:1,D:1,E:1,F:1,G:1>> || > <> <= > << <> || > <> <= UD >> > >>. > > It is 2-10 times faster on my laptop (depend of GC hit) in byte code and 4 > times in native. > > > 2009/3/5 Tony Seebregts > >> Hmmm , the short answer is that the code I suggested is taken from a >> module to convert a GSM octet stream into a septet stream and it gives a >> different answer when using your more compact code :-) : >> UD: << 203,176,184,204,86,191,1 >> >> Mine: [75,97,98,101,108,106,111,0] >> Yours: << 101,108,23,12,98,90,126,1>> >> >> I remember the GSM octet-septet conversion being quite awkward to get >> right because the bytes were the 'wrong way round' which is probably why I >> ended up with the code I did i.e. having to use flip(...). >> >> >> 2009/3/5 Hynek Vychodil >> >>> Why not? >>> >>> >>> unpack(UD) -> >>> << <<0:1,X/bits>> || <> <= UD >>. >>> >>> 2009/3/5 Tony Seebregts >>> >>>> This is an extract from the code I use: >>>> >>>>> unpack(UD) -> >>>>> septets(list_to_binary([ flip(X) || X <- binary_to_list(UD) ])). >>>>> >>>>> septets(T) -> >>>>> [ flipx(X) || <> <= T]. >>>>> >>>>> % Flips the bits in an octet/septet for easy unpacking >>>>> >>>>> flip(Octet) -> >>>>> <> = <>, >>>>> <>. >>>>> >>>> >>>> There is probably a better way of doing it but I was in a rush at the >>>> time :-) >>>> >>>> >>>> >>>> >>>> >>>> _______________________________________________ >>>> erlang-questions mailing list >>>> erlang-questions@REDACTED >>>> http://www.erlang.org/mailman/listinfo/erlang-questions >>>> >>> >>> >>> >>> -- >>> --Hynek (Pichi) Vychodil >>> >>> Analyze your data in minutes. Share your insights instantly. Thrill your >>> boss. Be a data hero! >>> Try Good Data now for free: www.gooddata.com >>> >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > > > -- > --Hynek (Pichi) Vychodil > > Analyze your data in minutes. Share your insights instantly. Thrill your > boss. Be a data hero! > Try Good Data now for free: www.gooddata.com > -- --Hynek (Pichi) Vychodil Analyze your data in minutes. Share your insights instantly. Thrill your boss. Be a data hero! Try Good Data now for free: www.gooddata.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From tony@REDACTED Thu Mar 5 20:36:59 2009 From: tony@REDACTED (Tony Arcieri) Date: Thu, 5 Mar 2009 12:36:59 -0700 Subject: [erlang-questions] STM In-Reply-To: <9b08084c0903050007l6dbfd9fdy1ab2253f5e2ce2b9@mail.gmail.com> References: <49AE19BD.9070203@gmail.com> <9b08084c0903050007l6dbfd9fdy1ab2253f5e2ce2b9@mail.gmail.com> Message-ID: On Thu, Mar 5, 2009 at 1:07 AM, Joe Armstrong wrote: > I wrote the following a while back - it's a very simple implementation of > what I think is a transactional memory - as far as I can see this mirrors > what the hardware guys thinks is a transactional memory. It's just a simple > generalization of the good 'ol test and set. > > > http://armstrongonsoftware.blogspot.com/2006/09/pure-and-simple-transaction-memories.html > That was a very interesting read, thanks. -- Tony Arcieri medioh.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From jjhakala@REDACTED Thu Mar 5 21:10:55 2009 From: jjhakala@REDACTED (Jani Hakala) Date: Thu, 5 Mar 2009 22:10:55 +0200 Subject: [erlang-questions] Generating skeleton linked-in driver code using an IDL? Message-ID: I have written a small linked-in driver that fortunately has only a few different kind of messages passing between erlang code and driver (driver_entry outputv, ready_input+driver_output_binary). It also handles several operations issued by port_control() (decoding of data using ei_decode_*). A big portion of the code is related to decoding and encoding of the data although the messages are quite simple. I have looked at some of the code generation tools that are supposed to help developing linked-in drivers. They (ETDK, DryvErl and the proposed Foreign Function Interface) seem to focus on how to call C-functions. I would be more interested about a tool that could be used to define message structures and operations supported by a linked-in driver. Those operations would call C/C++ functions in a way that would not be visible outside the driver (facade pattern). An IDL compiler is included in OTP so I wrote a CORBA IDL file that could be a starting point for a new version of my linked-in driver (or C node perhaps) if it was possible to generate 1) C/C++ code that could be used to (de)serialize the messages, 2) C/C++ skeleton files for the driver, 3) Erlang code that would (de)serialize messages using CDR encoding or erlang external format (or other solution), and 4) Erlang skeleton files for the process that owns the port. 1) could be implemented using ei_decode/ei_encode functions. In the case of port_command (3) might be just call to term_to_binary after some sanity checks for the parameters. Most of the checking could be delayed until the C-code deserializes the data. ic - the erlang IDL compiler - generates several files that might be useful if a tool supporting this kind of scheme was developed or if ic was modified: - The output files include type codes that describe the data structures (:tc/0) and operations (:oe_get_interface/0). - Record definitions are also available for each defined structure and exception. - The names, in/inout/out information of the parameters are unfortunately not readily available (not without changing ic?). - No oneway-information for operations either. A attached two files to this email: CAN.idl (which is nowhere close to being a complete definition) and CAN.txt that contains some sort of use cases. Jani Hakala (Third attempt on sending this message... my other email address gets complaints about 'Your address 130.234.4.43 has mailed to spamtraps here'.) -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: CAN.txt URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: CAN.idl Type: application/octet-stream Size: 1355 bytes Desc: not available URL: From tony@REDACTED Thu Mar 5 22:40:28 2009 From: tony@REDACTED (Tony Arcieri) Date: Thu, 5 Mar 2009 14:40:28 -0700 Subject: [erlang-questions] The Beauty of Erlang Syntax In-Reply-To: <49AF9969.3030207@erlang-consulting.com> References: <3e6f9520-f8cd-48f2-8ebf-1729538d1842@e24g2000vbe.googlegroups.com> <22226430.post@talk.nabble.com> <9b08084c0902260808hf9903b1yb0aa072e7e503160@mail.gmail.com> <22230905.post@talk.nabble.com> <49A71F16.3080205@erlang-consulting.com> <22244249.post@talk.nabble.com> <49A7F9D3.8020706@erlang-consulting.com> <49AF9969.3030207@erlang-consulting.com> Message-ID: On Thu, Mar 5, 2009 at 2:20 AM, Ulf Wiger wrote: > Glad to hear it. I hope I'm not coming across as a > Reia basher. I really haven't looked at it enough to have > formed an independent opinion. In general, I'm very much in > favour of attempts to build other languages on top of the > Erlang VM - like LFE, STOE, Haskell on Rails and Reia. > > Whatever comes out of them, surely these are worthy pursuits. (: You're not coming across as a Reia basher :) And I'm glad to hear you like the idea of other languages on the Erlang VM. -- Tony Arcieri medioh.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From tony@REDACTED Thu Mar 5 22:51:55 2009 From: tony@REDACTED (Tony Arcieri) Date: Thu, 5 Mar 2009 14:51:55 -0700 Subject: [erlang-questions] STM In-Reply-To: <49AF90C7.6030707@erlang-consulting.com> References: <49AE19BD.9070203@gmail.com> <7c9d57ea0903041627n7e309b38m6240f75b8a9f40fd@mail.gmail.com> <49AF90C7.6030707@erlang-consulting.com> Message-ID: On Thu, Mar 5, 2009 at 1:43 AM, Ulf Wiger wrote: > > One particular trait about Erlang is that it ranks > pretty high on conceptual integrity (IMHO) - a bit like > SmallTalk and Haskell, it has a clear idea on how you > should write programs. I won't claim that this concept > absolutely precludes efficient solutions to problems > like chameneos_redux, but at least I think that the > maintainers of the Erlang VM have their priorities > straight. ;-) > Yes. I really appreciate all the recent work on the SMP scheduler and certainly wouldn't want to distract from that. -- Tony Arcieri medioh.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From ok@REDACTED Thu Mar 5 23:04:54 2009 From: ok@REDACTED (Richard O'Keefe) Date: Fri, 6 Mar 2009 11:04:54 +1300 Subject: [erlang-questions] STM In-Reply-To: <9b08084c0903050007l6dbfd9fdy1ab2253f5e2ce2b9@mail.gmail.com> References: <49AE19BD.9070203@gmail.com> <9b08084c0903050007l6dbfd9fdy1ab2253f5e2ce2b9@mail.gmail.com> Message-ID: <51B607F3-DB85-482A-B3BC-ECCB9276DBB1@cs.otago.ac.nz> On 5 Mar 2009, at 9:07 pm, Joe Armstrong wrote: > I actually think TMs are a bad idea - it's still shared state - and if > the TM fails > then everything gets screwed up. Long-term readers of this mailing list may recall that having read the "Beautiful Concurrency" paper, demonstrating STM in Haskell, I said "that's the very opposite of beautiful" and showed that you could do it much more clearly in Erlang. There's a paper The Transactional Memory/Garbage Collection Analogy Dan Grossman, OOPSLA'07. It's an interesting and balanced paper. For one thing, he makes the point that message passing is an alternative, but *IF* you want to program with shared memory, transactional memory helps. I particularly like this bit: it will lead us to the balanced and obvious-once-you- say-it conclusion that transactions make it easy to define critical sections (which is a huge help in writing and maintaining shared-memory programs) but provide no help in identifying where a critical section should begin or end (which remains an enormous challenge). That's the single most helpful thing I've ever read about TM. From fess-erlang@REDACTED Thu Mar 5 23:14:09 2009 From: fess-erlang@REDACTED (fess) Date: Thu, 5 Mar 2009 14:14:09 -0800 Subject: [erlang-questions] scanning a hrl file, for macros. Message-ID: <65925C85-CB10-451A-BF30-61F35956D7F9@fess.org> I have an hrl file with a bunch of macro's in it that are just a bunch of strings. [ The names of query vars used in urls ] I'd like to generate a javascript file from this which has the same mappings. I could simply write a function that explicitly uses each of the macros and outputs the javascript. [ which is what I'm doing. ] However It would be nice just to have the list in one place. So, I tried to erl_scan/erl_parse it. erl_scan returns tokens which includes the defines. I could go on from there and manually parse the defines. However, I thought that if I got a parsed form it would be easier to pick out the macros. so I moved on to erl_parse, however, I get errors with erl_parse:parse_form and erl_parse:parse_exprs, [ {1,erl_parse,"bad attribute"}, and {2,erl_parse,["syntax error before: ",["'-'"]]} respectively ], the file when included compiles so I'm guessing it's not an actual syntax problem. My tokens look like this: [{'-',1}, {atom,1,ifndef}, {'(',1}, {var,1,'MYHRL_HRL'}, {')',1}, {dot,1}, {'-',2}, {atom,2,define}, {'(',2}, {var,2,'MYHRL_HRL'}, {',',2}, {atom,2,true}, {')',2}, {dot,2}, ... ] So, then I thought, ok, maybe erl_parse needs this stuff to be pre processed? Next I tried out epp:parse_file/3 on it but that seemed to me to expect to apply macros, not necessarily show you that they were there. So, clearly I'm not getting things here. Any pointers would be appreciated. --fess From richardc@REDACTED Fri Mar 6 00:08:53 2009 From: richardc@REDACTED (Richard Carlsson) Date: Fri, 06 Mar 2009 00:08:53 +0100 Subject: [erlang-questions] scanning a hrl file, for macros. In-Reply-To: <65925C85-CB10-451A-BF30-61F35956D7F9@fess.org> References: <65925C85-CB10-451A-BF30-61F35956D7F9@fess.org> Message-ID: <49B05B85.6040606@it.uu.se> fess wrote: > I have an hrl file with a bunch of macro's in it that are just a bunch > of strings. [...] So, I tried to erl_scan/erl_parse it. > > erl_scan returns tokens which includes the defines. I could go on from > there and manually parse the defines. However, I thought that if I got > a parsed form it would be easier to pick out the macros. > > so I moved on to erl_parse, however, I get errors with > erl_parse:parse_form and erl_parse:parse_exprs, [ {1,erl_parse,"bad > attribute"}, and {2,erl_parse,["syntax error before: ",["'-'"]]} > respectively ], the file when included compiles so I'm guessing it's > not an actual syntax problem. > > My tokens look like this: > > [{'-',1}, {atom,1,ifndef}, {'(',1}, ... > > So, then I thought, ok, maybe erl_parse needs this stuff to be pre > processed? Next I tried out epp:parse_file/3 on it > but that seemed to me to expect to apply macros, not necessarily show > you that they were there. Your basic analysis is correct: to run the parser requires that there are no remains of preprocessor juju like -define(...), -ifdef, or ?MACRO in the token sequence. (This is natural: since preprocessor expansion can happen anywhere and result in arbitrary tokens being inserted, the poor parser has no chance of matching the unexpanded sequence against the expected grammar. C works the same way.) But getting rid of the macros means getting *rid* of the macros... You should try the epp_dodger module in syntax tools, which can read most "sane" preprocessor uses: the parse_file/2 function ought to get you started; you may want to run erl_syntax:revert/1 on the result, depending on what you want to do with it. The documentation for erl_syntax and erl_prettypr may be of help. http://www.erlang.org/doc/apps/syntax_tools/index.html /Richard From spyplane@REDACTED Fri Mar 6 02:11:38 2009 From: spyplane@REDACTED (Jared) Date: Thu, 5 Mar 2009 18:11:38 -0700 Subject: [erlang-questions] mDNS, zeroconf, bonjour Message-ID: I've been following this list for a while now, and I want to first thank you all for your insight and creativity, it is really inspiring. I'm trying to come up with my first erlang project that would actually be useful to the community and one of my ideas was a zeroconf library in erlang. I've searched this list archive, google, and github and there doesn't appear to be any erlang implementation of zeroconf (mdns, bonjour, avahi). It seems not only like a good fit for the capabilities of erlang, but also useful for distributed networks (the ability to discover and advertise services and servers). My first real question, does anything like this exist and I'm just missing it? Second, would this be interesting to anyone (is there some erlang/OTP built-in that I'm missing that does this already) ? Thanks again for all the help in getting started. -Jared -------------- next part -------------- An HTML attachment was scrubbed... URL: From sicfslist@REDACTED Fri Mar 6 03:22:13 2009 From: sicfslist@REDACTED (Shelby Ramsey) Date: Thu, 5 Mar 2009 20:22:13 -0600 Subject: [erlang-questions] Noob Question ... Message-ID: <35b355e90903051822s552258d4i7fda58ac02171c1d@mail.gmail.com> Hello! I'm trying to become an erlang convert (from Python) and I do mostly network programming. So I wrote up this little tidbit: -module(test). -export([client/1]). client([Port]) -> case gen_tcp:connect("127.0.0.1", Port, [list,{packet,0}]) of {ok, Socket} -> gen_tcp:send(Socket,"auth iltd!dy69?\r\n\r\n"), gen_tcp:send(Socket,"event plain text\r\n\r\n"), loop(Socket); {error, Reason} -> print_stuff([Reason]), ok end. loop(Socket) -> case gen_tcp:recv(Socket, 0) of {ok, Data} -> print_stuff([Data]), loop(Socket); {error, closed} -> ok end. print_stuff([Text]) -> io:format("~w", [Text]). It compiles ... but when I run ... well ... it spits this: =ERROR REPORT==== 5-Mar-2009::20:19:27 === Error in process <0.30.0> with exit value: {function_clause,[{test,client,[8021]},{erl_eval,do_apply,5},{shell,exprs,6},{shell,eval_loop,3}]} ** exited: {function_clause,[{test,client,[8021]}, {erl_eval,do_apply,5}, {shell,exprs,6}, {shell,eval_loop,3}]} ** So what did I hose up? And more importantly ... where is some documentation re: how to debug the "error report". Thanks for any assistance! SDR -------------- next part -------------- An HTML attachment was scrubbed... URL: From bbmaj7@REDACTED Fri Mar 6 03:24:55 2009 From: bbmaj7@REDACTED (Richard Andrews) Date: Thu, 5 Mar 2009 18:24:55 -0800 (PST) Subject: [erlang-questions] Unix domain sockets In-Reply-To: <8209f740903040518y3b3cc4b1j3b06165f3da3f3c8@mail.gmail.com> References: <3dbc6d1c0903040223w5a079909j8e8851332521efa3@mail.gmail.com> <8209f740903040518y3b3cc4b1j3b06165f3da3f3c8@mail.gmail.com> Message-ID: <358109.5796.qm@web65508.mail.ac4.yahoo.com> IIRC there was a UNIX socket project in jungerl too. > There's an example driver for unix domain sockets under > $OTP_ROOT/lib/kernel/examples/uds_dist/ > > (It's still there in R13A-0, BTW.) > > It used to be documented in the Interoperability Tutorial, but > I think they've switched to a different example now. Stay connected to the people that matter most with a smarter inbox. Take a look http://au.docs.yahoo.com/mail/smarterinbox From fess-erlang@REDACTED Fri Mar 6 03:38:01 2009 From: fess-erlang@REDACTED (fess) Date: Thu, 5 Mar 2009 18:38:01 -0800 Subject: [erlang-questions] Noob Question ... In-Reply-To: <35b355e90903051822s552258d4i7fda58ac02171c1d@mail.gmail.com> References: <35b355e90903051822s552258d4i7fda58ac02171c1d@mail.gmail.com> Message-ID: {function_clause,[{test,client,[8021]}, ... {function_clause,[{Module,Function,Args}, ... where Args is a list of arguments that was passed. it means you don't have a function that matches the call test:client(8021) your function definition: client([Port]) -> ... means client takes a list of one as it's only argument. [ so test:client([8021]) works, but test:client(8021) does not match. ] try this client(Port) -> ... which means take one argument. the magic is learning the syntax of function clause, case clause, badarg, etc, I don't have the answer where the good docs are on that. perhaps joe's book is best? I hope there's a good answer to get people past that bit quicker. hope that helps. --fess On Mar 5, 2009, at 6:22 PM, Shelby Ramsey wrote: > Hello! > > I'm trying to become an erlang convert (from Python) and I do mostly > network programming. > > So I wrote up this little tidbit: > > -module(test). > -export([client/1]). > > client([Port]) -> > case gen_tcp:connect("127.0.0.1", Port, [list,{packet,0}]) of > {ok, Socket} -> > gen_tcp:send(Socket,"auth iltd!dy69?\r\n\r\n"), > gen_tcp:send(Socket,"event plain text\r\n\r\n"), > loop(Socket); > {error, Reason} -> > print_stuff([Reason]), > ok > end. > > loop(Socket) -> > case gen_tcp:recv(Socket, 0) of > {ok, Data} -> > print_stuff([Data]), > loop(Socket); > {error, closed} -> > ok > end. > > print_stuff([Text]) -> > io:format("~w", [Text]). > > It compiles ... but when I run ... well ... it spits this: > > =ERROR REPORT==== 5-Mar-2009::20:19:27 === > Error in process <0.30.0> with exit value: {function_clause, > [{test,client,[8021]},{erl_eval,do_apply,5},{shell,exprs,6}, > {shell,eval_loop,3}]} > > ** exited: {function_clause,[{test,client,[8021]}, > {erl_eval,do_apply,5}, > {shell,exprs,6}, > {shell,eval_loop,3}]} ** > > > So what did I hose up? And more importantly ... where is some > documentation re: how to debug the "error report". > > Thanks for any assistance! > > SDR > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions --fess From colm.dougan@REDACTED Fri Mar 6 04:33:31 2009 From: colm.dougan@REDACTED (Colm Dougan) Date: Fri, 6 Mar 2009 03:33:31 +0000 Subject: [erlang-questions] Noob Question ... In-Reply-To: References: <35b355e90903051822s552258d4i7fda58ac02171c1d@mail.gmail.com> Message-ID: <24d4f39c0903051933hf24f9c9n5249bcc701250674@mail.gmail.com> On Fri, Mar 6, 2009 at 2:38 AM, fess wrote: > > means client takes a list of one as it's only argument. ? [ so > test:client([8021]) works, but test:client(8021) does not match. ] > > try this > > ? client(Port) -> > ? ? ... Also, have a look at the "active" socket option to gen_tcp:connect. You probably want to set it to false given the way your receive loop works. Colm From mjtruog@REDACTED Fri Mar 6 06:50:51 2009 From: mjtruog@REDACTED (Michael Truog) Date: Thu, 05 Mar 2009 21:50:51 -0800 Subject: [erlang-questions] Generating skeleton linked-in driver code using an IDL? In-Reply-To: References: Message-ID: <49B0B9BB.40107@gmail.com> Jani Hakala wrote: > ... > > I have looked at some of the code generation tools that are supposed > to help developing linked-in drivers. They (ETDK, DryvErl and the > proposed Foreign Function Interface) seem to focus on how to call > C-functions. I would be more interested about a tool that could be > used to define message structures and operations supported by a > linked-in driver. Those operations would call C/C++ functions in a way > that would not be visible outside the driver (facade pattern). > > ... I created the Generic Erlang Port Driver to have an easy way to automatically generate a port driver or port for C or C++. The code generation does not rely on an idl file but instead uses boost::preprocess to use macros. The code is still in development, but should provide another way of creating port drivers automatically. The port drivers are generated only with usage of outputv, for efficiency. The message structure is determined from basic types passed with the native byte order. A facade pattern could easily be added as an interface to the port driver. You can find the code here: http://forum.trapexit.org/viewtopic.php?p=44406#44406 -Michael From kenneth.lundin@REDACTED Fri Mar 6 09:27:46 2009 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Fri, 6 Mar 2009 09:27:46 +0100 Subject: [erlang-questions] Generating skeleton linked-in driver code using an IDL? In-Reply-To: References: Message-ID: Hi Jani, The IDL compiler (IC) in the Erlang/OTP release already has support for generating the Erlang side and the C side including serialization to the Erlang external format. This is used for communcation between Erlang-nodes and so called C-nodes implemnted with help of the erl_interface/ei libraries. When used like this there is absolutely no CORBA involved. Unfortunately it does not have support for generating the Erlang and C side of a driver but it would not be a very big job to add that as an additional backend. /Kenneth Erlang/OTP, Ericsson 2009/3/5 Jani Hakala : > I have written a small linked-in driver that fortunately has only a > few different kind of messages passing between erlang code and driver > (driver_entry outputv, ready_input+driver_output_binary). It also > handles several operations issued by port_control() (decoding of data > using ei_decode_*). A big portion of the code is related to decoding > and encoding of the data although the messages are quite simple. > > I have looked at some of the code generation tools that are supposed > to help developing linked-in drivers. They (ETDK, DryvErl and the > proposed Foreign Function Interface) seem to focus on how to call > C-functions. I would be more interested about a tool that could be > used to define message structures and operations supported by a > linked-in driver. Those operations would call C/C++ functions in a way > that would not be visible outside the driver (facade pattern). > > An IDL compiler is included in OTP so I wrote a CORBA IDL file that > could be a starting point for a new version of my linked-in driver (or > C node perhaps) if it was possible to generate > ?1) C/C++ code that could be used to (de)serialize the messages, > ?2) C/C++ skeleton files for the driver, > ?3) Erlang code that would (de)serialize messages using CDR encoding or > ? ? erlang external format (or other solution), and > ?4) Erlang skeleton files for the process that owns the port. > > 1) could be implemented using ei_decode/ei_encode functions. > In the case of port_command (3) might be just call to term_to_binary > after some sanity checks for the parameters. Most of the checking > could be delayed until the C-code deserializes the data. > > ic - the erlang IDL compiler - generates several files that might be > useful if a tool supporting this kind of scheme was developed or if ic > was modified: > ?- The output files include type codes that describe the data > ? ?structures (:tc/0) and operations (:oe_get_interface/0). > ?- Record definitions are also available for each defined structure > ? ?and exception. > ?- The names, in/inout/out information of the parameters are > ? ?unfortunately not readily available (not without changing ic?). > ?- No oneway-information for operations either. > > A attached two files to this email: CAN.idl (which is nowhere close to being a > complete definition) and CAN.txt that contains some sort of use cases. > > Jani Hakala > > (Third attempt on sending this message... my other email address gets > complaints about > 'Your address 130.234.4.43 has mailed to spamtraps here'.) > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From steven.charles.davis@REDACTED Fri Mar 6 09:30:47 2009 From: steven.charles.davis@REDACTED (Steve Davis) Date: Fri, 06 Mar 2009 02:30:47 -0600 Subject: [erlang-questions] wxErlang release Message-ID: <49B0DF37.8060007@gmail.com> *First* of all, nice job -- wxErlang seems to cover almost everything in wxWidgets and isn't too hard to figure out how to use it if you already know wx or MFC or Swing or another GUI framework (despite the documentation's current state) :) *Second* of all, there's a file missing from the build that will adversely affect Windows XP et seq. users. To get XP to fully use all its nice-modern-looking native UI elements it needs an ".rc" file in the dll build. All that file needs contain is the following couple of lines: --------resource.rc------------ aaaa ICON "wx/msw/std.ico" #include "wx/msw/wx.rc" -----------end----------------- The #include will do the magic on tabs, buttons etc, which will otherwise look like (and do currently) plain NT controls (YUK! :) Although I believe the ugly first declaration is (far) less important I believe that it will stop an "empty icon" appearing in the window frame decoration when the icon is not explicitly set. Third of all... GUI programming is super-laborious, verbose, and boring. Because wxErlang essentially wraps the CPP interface the programming style is very reminiscent of all the current frameworks and is very un-Erlang. When I first saw GS, I thought -- well HELL now that's how to do it! Seems that by adding a few more elements to the GS interface (i mean the *interface* not the implementation) it would be possible to create a facade API for wxErlang that you'd use like GS and still get all the benefits of all the work in wxErlang, -- I'm thinking of something a bit like the project "xgs" from erlgtk days. If that worked out then finally we would have a concise way (create_tree) to create nice native GUIs from Erlang that could be used in a much more Erlang-ish fashion... Not to mention the thousands of hours that could be saved by avoiding having to convert the horrifically dull wxWidgets documentation so it makes sense for the Erlang API presented by the wxErlang generated modules. I ask (Dan in particular, and anyone else who may have an opinion) -- do you see this as a feasible approach/project? -- is this approach being considered? -- if not, would you encourage me to have a go at it? regs /sd From richardc@REDACTED Fri Mar 6 09:31:06 2009 From: richardc@REDACTED (Richard Carlsson) Date: Fri, 06 Mar 2009 09:31:06 +0100 Subject: [erlang-questions] Noob Question ... In-Reply-To: <35b355e90903051822s552258d4i7fda58ac02171c1d@mail.gmail.com> References: <35b355e90903051822s552258d4i7fda58ac02171c1d@mail.gmail.com> Message-ID: <49B0DF4A.7030808@it.uu.se> Shelby Ramsey wrote: > It compiles ... but when I run ... well ... it spits this: > > =ERROR REPORT==== 5-Mar-2009::20:19:27 === > Error in process <0.30.0> with exit value: > {function_clause,[{test,client,[8021]},{erl_eval,do_apply,5},{shell,exprs,6},{shell,eval_loop,3}]} > > ** exited: {function_clause,[{test,client,[8021]}, > {erl_eval,do_apply,5}, > {shell,exprs,6}, > {shell,eval_loop,3}]} ** > > > So what did I hose up? And more importantly ... where is some > documentation re: how to debug the "error report". Looks like you are running a slightly older Erlang system; try upgrading and you'll get improved error reports. The above error will be shown as "no function clause matching test:client(8021)". /Richard From tobbe@REDACTED Fri Mar 6 09:58:07 2009 From: tobbe@REDACTED (Torbjorn Tornkvist) Date: Fri, 06 Mar 2009 09:58:07 +0100 Subject: [erlang-questions] Generating skeleton linked-in driver code using an IDL? References: <49B0B9BB.40107@gmail.com> Message-ID: <878wnjdo4g.fsf@sej.hq.kred> Michael Truog writes: > Jani Hakala wrote: >> ... >> >> I have looked at some of the code generation tools that are supposed >> to help developing linked-in drivers. They (ETDK, DryvErl and the >> proposed Foreign Function Interface) seem to focus on how to call >> C-functions. I would be more interested about a tool that could be >> used to define message structures and operations supported by a >> linked-in driver. Those operations would call C/C++ functions in a way >> that would not be visible outside the driver (facade pattern). >> >> ... > I created the Generic Erlang Port Driver to have an easy way to > automatically generate a port driver or port for C or C++. The code > generation does not rely on an idl file but instead uses > boost::preprocess to use macros. The code is still in development, but > should provide another way of creating port drivers automatically. The > port drivers are generated only with usage of outputv, for efficiency. > The message structure is determined from basic types passed with the > native byte order. A facade pattern could easily be added as an > interface to the port driver. You can find the code here: > > http://forum.trapexit.org/viewtopic.php?p=44406#44406 I think 'gepd' should live as a nice little project of its own (e.g at github.com). --Tobbe (Ps. it reminds me about old IG (may it rest in peace): http://www.tornkvist.org/gitweb?p=ig.git;a=summary ) From nick@REDACTED Fri Mar 6 10:18:28 2009 From: nick@REDACTED (Niclas Eklund) Date: Fri, 6 Mar 2009 10:18:28 +0100 (CET) Subject: [erlang-questions] Generating skeleton linked-in driver code using an IDL? In-Reply-To: References: Message-ID: Hello! Jani, it sounds like you're the wrong bacekend. IC re-use the OMG IDL C-mapping when generating code for Erlang-C-communication, which doesn't require using Orber and an external C/C++ ORB. Judging by your description, you didn't supply the correct back-end options. You should use erl_genserv and c_server. If no back-end option is defined, the default value erl_corba is used. Then you need another ORB. You can also try erl_template back-end. Its main purpose is to be used together with erl_corba, but shows how a call-back module for erl_genserv can be implemented (e.g. dealing with oneway, inout, out etc). Best regards, Niclas @ Erlang/OTP On Fri, 6 Mar 2009, Kenneth Lundin wrote: > Hi Jani, > > The IDL compiler (IC) in the Erlang/OTP release already has support > for generating the Erlang side and > the C side including serialization to the Erlang external format. > > > This is used for communcation between Erlang-nodes and so called > C-nodes implemnted with help of the erl_interface/ei libraries. > When used like this there is absolutely no CORBA involved. > > Unfortunately it does not have support for generating the Erlang and C > side of a driver but it would not be a very big job to add that as an > additional backend. > > /Kenneth Erlang/OTP, Ericsson > > 2009/3/5 Jani Hakala : >> I have written a small linked-in driver that fortunately has only a >> few different kind of messages passing between erlang code and driver >> (driver_entry outputv, ready_input+driver_output_binary). It also >> handles several operations issued by port_control() (decoding of data >> using ei_decode_*). A big portion of the code is related to decoding >> and encoding of the data although the messages are quite simple. >> >> I have looked at some of the code generation tools that are supposed >> to help developing linked-in drivers. They (ETDK, DryvErl and the >> proposed Foreign Function Interface) seem to focus on how to call >> C-functions. I would be more interested about a tool that could be >> used to define message structures and operations supported by a >> linked-in driver. Those operations would call C/C++ functions in a way >> that would not be visible outside the driver (facade pattern). >> >> An IDL compiler is included in OTP so I wrote a CORBA IDL file that >> could be a starting point for a new version of my linked-in driver (or >> C node perhaps) if it was possible to generate >> ?1) C/C++ code that could be used to (de)serialize the messages, >> ?2) C/C++ skeleton files for the driver, >> ?3) Erlang code that would (de)serialize messages using CDR encoding or >> ? ? erlang external format (or other solution), and >> ?4) Erlang skeleton files for the process that owns the port. >> >> 1) could be implemented using ei_decode/ei_encode functions. >> In the case of port_command (3) might be just call to term_to_binary >> after some sanity checks for the parameters. Most of the checking >> could be delayed until the C-code deserializes the data. >> >> ic - the erlang IDL compiler - generates several files that might be >> useful if a tool supporting this kind of scheme was developed or if ic >> was modified: >> ?- The output files include type codes that describe the data >> ? ?structures (:tc/0) and operations (:oe_get_interface/0). >> ?- Record definitions are also available for each defined structure >> ? ?and exception. >> ?- The names, in/inout/out information of the parameters are >> ? ?unfortunately not readily available (not without changing ic?). >> ?- No oneway-information for operations either. >> >> A attached two files to this email: CAN.idl (which is nowhere close to being a >> complete definition) and CAN.txt that contains some sort of use cases. >> >> Jani Hakala >> >> (Third attempt on sending this message... my other email address gets >> complaints about >> 'Your address 130.234.4.43 has mailed to spamtraps here'.) >> >> _______________________________________________ >> 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 dgud@REDACTED Fri Mar 6 10:47:56 2009 From: dgud@REDACTED (Dan Gudmundsson) Date: Fri, 06 Mar 2009 10:47:56 +0100 Subject: [erlang-questions] wxErlang release In-Reply-To: <49B0DF37.8060007@gmail.com> References: <49B0DF37.8060007@gmail.com> Message-ID: <49B0F14C.70301@erix.ericsson.se> Wow feedback :-) Steve Davis wrote: > *First* of all, nice job -- wxErlang seems to cover almost everything in > wxWidgets and isn't too hard to figure out how to use it if you already > know wx or MFC or Swing or another GUI framework (despite the > documentation's current state) :) Thanks. The documentation will continue to lack a lot in R13 :-) I will not have time to do something about it, in the future wxWidgets will switch over to use doxygen for it's doc so we will hopefully be able use the C++ documentation directly. Then a user guide needs to be written, at least a lot of examples. > *Second* of all, there's a file missing from the build that will > adversely affect Windows XP et seq. users. To get XP to fully use all > its nice-modern-looking native UI elements it needs an ".rc" file in the > dll build. All that file needs contain is the following couple of lines: > > --------resource.rc------------ > > aaaa ICON "wx/msw/std.ico" > #include "wx/msw/wx.rc" > > -----------end----------------- > > The #include will do the magic on tabs, buttons etc, which will > otherwise look like (and do currently) plain NT controls (YUK! :) > > Although I believe the ugly first declaration is (far) less important I > believe that it will stop an "empty icon" appearing in the window frame > decoration when the icon is not explicitly set. Thanks, I didn't know that and have wondered why my apps don't look so XP'ish, when wxWidgets examples does. Will get back to you if I need more help :-) Windows is not my strong side.. > Third of all... > > GUI programming is super-laborious, verbose, and boring. Because > wxErlang essentially wraps the CPP interface the programming style is > very reminiscent of all the current frameworks and is very un-Erlang. > > When I first saw GS, I thought -- well HELL now that's how to do it! > Seems that by adding a few more elements to the GS interface (i mean the > *interface* not the implementation) it would be possible to create a > facade API for wxErlang that you'd use like GS and still get all the > benefits of all the work in wxErlang, -- I'm thinking of something a bit > like the project "xgs" from erlgtk days. > > If that worked out then finally we would have a concise way > (create_tree) to create nice native GUIs from Erlang that could be used > in a much more Erlang-ish fashion... Not to mention the thousands of > hours that could be saved by avoiding having to convert the horrifically > dull wxWidgets documentation so it makes sense for the Erlang API > presented by the wxErlang generated modules. > > I ask (Dan in particular, and anyone else who may have an opinion) -- do > you see this as a feasible approach/project? -- is this approach being > considered? -- if not, would you encourage me to have a go at it? > I really don't have much experience with gui programming (except wings3D) but I agree with everything you said above, the problems I have with GS is: - Not so beautiful - Non native widgets - Very small widget set - No (easy) access to widgets that are not in the high level api. - The packer don't work, everything have hard coded sizes (in the debugger and erlang tools I have looked at) which is really bad for platform independent gui programming. - performance With wxWidgets we get, - Beautiful... (more native look and feel) - Native widgets i.e file browser, print dialog and so on. - large widgets set - The sizer (packer above) works a lot better and is building stone in wxWidgets. - Performance (should be better than GS) But we loose the high-level api and erlang crashes when we do something wrong (with a coredump if you are lucky which is pretty useless if you haven't spend a lot of time with the c++ wxWidgets). So a high-level abstraction like GS with access to the low level stuff would be great. Regards /Dan > > regs > /sd > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From steven.charles.davis@REDACTED Fri Mar 6 11:19:42 2009 From: steven.charles.davis@REDACTED (Steve Davis) Date: Fri, 06 Mar 2009 04:19:42 -0600 Subject: [erlang-questions] wxErlang release In-Reply-To: <49B0F14C.70301@erix.ericsson.se> References: <49B0DF37.8060007@gmail.com> <49B0F14C.70301@erix.ericsson.se> Message-ID: <49B0F8BE.6040708@gmail.com> Dan Gudmundsson wrote: > Wow feedback :-) Now that made me laugh. Not getting feedback generally means one of three things: 1) Nobody cares you did it 2) Nobody understands what you did 3) You got it pretty right Given the usefulness of being able to code up a cross-platform gui, and that a lot of people know wx quite well, I suspect that in this case it must be 3. :) > I really don't have much experience with gui programming (except wings3D) > but I agree with everything you said above, the problems I have with GS is: > - Not so beautiful > - Non native widgets > - Very small widget set > - No (easy) access to widgets that are not in the high level api. > - The packer don't work, everything have hard coded sizes > (in the debugger and erlang tools I have looked at) > which is really bad for platform independent gui programming. > - performance > > > With wxWidgets we get, > - Beautiful... (more native look and feel) > - Native widgets i.e file browser, print dialog and so on. > - large widgets set > - The sizer (packer above) works a lot better and is building stone in > wxWidgets. > - Performance (should be better than GS) > > But we loose the high-level api and erlang crashes when we do > something wrong (with a coredump if you are lucky which is pretty > useless if you haven't > spend a lot of time with the c++ wxWidgets). > > So a high-level abstraction like GS with access to the low level stuff > would be great. I think you may have misunderstood my idea. The GS implementation does have all those issues, and wxErlang does solve them. What I'm actually thinking of is a separate "facade" layer over the top of wxE that you code to like you would code to like you code to GS, and it transforms the calls into wxE calls. The GS-style facade can then add all the extra control goodness of wxE to the GS interface but would shield you from some (most?) of the labor. That way you get the best of both worlds. Another way of looking at it is an erlang-style XRC that is specified as a term and thus could be read by file:consult and just junked into a xxx:create_tree call. Given your answer - I guess this isn't being worked on, so I'll have a bash at a POC as I get time. Best, Steve From dgud@REDACTED Fri Mar 6 12:06:42 2009 From: dgud@REDACTED (Dan Gudmundsson) Date: Fri, 06 Mar 2009 12:06:42 +0100 Subject: [erlang-questions] wxErlang release In-Reply-To: <49B0F8BE.6040708@gmail.com> References: <49B0DF37.8060007@gmail.com> <49B0F14C.70301@erix.ericsson.se> <49B0F8BE.6040708@gmail.com> Message-ID: <49B103C2.2060709@erix.ericsson.se> Steve Davis wrote: > I think you may have misunderstood my idea. The GS implementation does > have all those issues, and wxErlang does solve them. What I'm actually > thinking of is a separate "facade" layer over the top of wxE that you > code to like you would code to like you code to GS, and it transforms > the calls into wxE calls. I guess I'm not expressing myself very well, I tried to motivate why I think this is a good idea, e.g. to build a GS like api on top of wx (which the haskell port have) that was actually the plan of the original master thesis author. I don't think I will have the time to do it. So please have a go at it. Regards /Dan > The GS-style facade can then add all the extra control goodness of wxE > to the GS interface but would shield you from some (most?) of the labor. > That way you get the best of both worlds. Another way of looking at it > is an erlang-style XRC that is specified as a term and thus could be > read by file:consult and just junked into a xxx:create_tree call. > > Given your answer - I guess this isn't being worked on, so I'll have a > bash at a POC as I get time. > > Best, > Steve > > From bbmaj7@REDACTED Fri Mar 6 12:50:13 2009 From: bbmaj7@REDACTED (Richard Andrews) Date: Fri, 6 Mar 2009 03:50:13 -0800 (PST) Subject: [erlang-questions] Noob Question ... In-Reply-To: <35b355e90903051822s552258d4i7fda58ac02171c1d@mail.gmail.com> References: <35b355e90903051822s552258d4i7fda58ac02171c1d@mail.gmail.com> Message-ID: <326744.79311.qm@web65514.mail.ac4.yahoo.com> The immediate thing that strikes me is that "127.0.0.1" should be {127,0,0,1}. In gen_tcp (erlang in general) the address is a tuple not a string. See man 3 inet for more info. Debugging becomes easier with experience. function_clause means you tried to call a function with the wrong argument type. Probably because you tried to pass a list (aka string) instead of a tuple to connect(). The rest of that section after function_clause is a stack trace. In this case it doesn't tell you much but it would be helpful if the failure occurred deeper into a call stack. ________________________________ client([Port]) -> case gen_tcp:connect("127.0.0.1", Port, [list,{packet,0}]) of {ok, Socket} -> gen_tcp:send(Socket,"auth iltd!dy69?\r\n\r\n"), gen_tcp:send(Socket,"event plain text\r\n\r\n"), loop(Socket); {error, Reason} -> print_stuff([Reason]), ok end. Stay connected to the people that matter most with a smarter inbox. Take a look http://au.docs.yahoo.com/mail/smarterinbox From cayle.spandon@REDACTED Fri Mar 6 14:01:36 2009 From: cayle.spandon@REDACTED (cayle.spandon@REDACTED) Date: Fri, 06 Mar 2009 13:01:36 +0000 Subject: [erlang-questions] Erlang module for command line interfaces? Message-ID: <0016e644cf328bfab0046472e249@google.com> Is there an Erlang module which allows me to implement an interactive command line interface (CLI) for a networking protocol? The CLI would be used both for configuration ("config commands") and status reporting ("show commands"). I guess am looking to something similar to what Tail-f Systems provides, except it needs to be free / open source and I don't need the netconf part of it for now, just the CLI part. If no such "CLI module" is available, what is the "Erlang way" of configuration and status reporting for stand-alone daemons written in Erlang? -------------- next part -------------- An HTML attachment was scrubbed... URL: From bgustavsson@REDACTED Fri Mar 6 14:42:01 2009 From: bgustavsson@REDACTED (Bjorn Gustavsson) Date: Fri, 6 Mar 2009 14:42:01 +0100 Subject: [erlang-questions] gen_[server|fsm|event]:format_status/2 no longer called In-Reply-To: <20090217015151.GA221@h216-235-12-174.host.egate.net> References: <20090217015151.GA221@h216-235-12-174.host.egate.net> Message-ID: <6672d0160903060542h20327c3fu99dd272cfcc53f05@mail.gmail.com> On Tue, Feb 17, 2009 at 2:51 AM, Vance Shipley wrote: > In R12B-5 I find that sys:get_status/1,2 no longer returns > status formatted for the type of process it is. > > I have long used the undocumented gen_server et. al. callback > to format the process state data. A call to sys:get_status/1,2 > would result in call to gen_server:format_status/2 which would > format the state data for a gen_server process. If you had > exported format_status/2 from your callback module it would be > called to format the state data for your application. > > This all seemed quite sensible to me and I used this often. > Now I will miss it. Which was the last version it did work in? I'll try to repair it in R13A (if possible), but so far I haven't been able to figure out from where the call to format_status/2 was made when the functionality last worked. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From v@REDACTED Fri Mar 6 14:43:52 2009 From: v@REDACTED (Valentin Micic) Date: Fri, 6 Mar 2009 15:43:52 +0200 Subject: [erlang-questions] Noob Question ... In-Reply-To: <326744.79311.qm@web65514.mail.ac4.yahoo.com> Message-ID: <200903061339.n26Dd2Rc018338@mail.pharos-avantgard.com> > The immediate thing that strikes me is that "127.0.0.1" should be {127,0,0,1}. In gen_tcp (erlang in general) the address is a tuple not a string. This is not correct -- gen_tcp supports string as well as tuple for dotted ip address specification V. From v@REDACTED Fri Mar 6 14:56:46 2009 From: v@REDACTED (Valentin Micic) Date: Fri, 6 Mar 2009 15:56:46 +0200 Subject: [erlang-questions] Noob Question ... In-Reply-To: <35b355e90903051822s552258d4i7fda58ac02171c1d@mail.gmail.com> Message-ID: <200903061352.n26DpvRc018419@mail.pharos-avantgard.com> There are three ways to receive data using gen_tcp, depending on which mode you've selected. The gen_tcp:recv may be used only if your socket has been opened with additional option flag {active, false} - which means that you do not want to receive unsolicited traffic. , thus, just change your line from: case gen_tcp:connect("127.0.0.1", Port, [list,{packet,0}]) of to case gen_tcp:connect("127.0.0.1", Port, [list,{packet,0}, {active, false}]) of and the code should work. The error message is a bit misleading, but if you call gen_tcp:recv on a socket that does not contain {active, fase}, gen_tcp:recv shall return {error,einval}, which will in turn cause function_clause error message. V. _____ From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Shelby Ramsey Sent: 06 March 2009 04:22 AM To: erlang-questions@REDACTED Subject: [erlang-questions] Noob Question ... Hello! I'm trying to become an erlang convert (from Python) and I do mostly network programming. So I wrote up this little tidbit: -module(test). -export([client/1]). client([Port]) -> case gen_tcp:connect("127.0.0.1", Port, [list,{packet,0}]) of {ok, Socket} -> gen_tcp:send(Socket,"auth iltd!dy69?\r\n\r\n"), gen_tcp:send(Socket,"event plain text\r\n\r\n"), loop(Socket); {error, Reason} -> print_stuff([Reason]), ok end. loop(Socket) -> case gen_tcp:recv(Socket, 0) of {ok, Data} -> print_stuff([Data]), loop(Socket); {error, closed} -> ok end. print_stuff([Text]) -> io:format("~w", [Text]). It compiles ... but when I run ... well ... it spits this: =ERROR REPORT==== 5-Mar-2009::20:19:27 === Error in process <0.30.0> with exit value: {function_clause,[{test,client,[8021]},{erl_eval,do_apply,5},{shell,exprs,6} ,{shell,eval_loop,3}]} ** exited: {function_clause,[{test,client,[8021]}, {erl_eval,do_apply,5}, {shell,exprs,6}, {shell,eval_loop,3}]} ** So what did I hose up? And more importantly ... where is some documentation re: how to debug the "error report". Thanks for any assistance! SDR -------------- next part -------------- An HTML attachment was scrubbed... URL: From fly@REDACTED Thu Mar 5 01:42:16 2009 From: fly@REDACTED (Fred Youhanaie) Date: Thu, 05 Mar 2009 00:42:16 +0000 Subject: [erlang-questions] Literate Erlang (eweb) Message-ID: <49AF1FE8.8090204@anydata.co.uk> Hi I started using eweb a few days ago, by downloading and working with eweb-1.0 [1] and then eweb-1.1 [2]. Is there a more recent version that I might have missed? Cheers f [1] http://www.sics.se/~joe/ericsson/literate/literate.html [2] http://www.erlang.org/contrib/eweb-1.1.tgz From bgustavsson@REDACTED Fri Mar 6 15:34:43 2009 From: bgustavsson@REDACTED (Bjorn Gustavsson) Date: Fri, 6 Mar 2009 15:34:43 +0100 Subject: [erlang-questions] max fds for epoll incorrectly reduced to FD_SETSIZE In-Reply-To: <65b2728e0902231441j740397b4h6ee845823343be8e@mail.gmail.com> References: <65b2728e0902211116i120c2b18oe29c5c9c9642f8e4@mail.gmail.com> <6672d0160902222358r32ad61dl749a64993534144@mail.gmail.com> <65b2728e0902230841k4abd0331w35f23292b76915f3@mail.gmail.com> <65b2728e0902231441j740397b4h6ee845823343be8e@mail.gmail.com> Message-ID: <6672d0160903060634l571bfc11peb560b6d707543e2@mail.gmail.com> On Mon, Feb 23, 2009 at 11:41 PM, Steve Vinoski wrote: > Yep, it's as plain as day once you know where to look. In the > configure script generated from erts/configure.in, the test for > working poll first checks to see if we're cross-compiling, and if so, > it unconditionally sets the "poll_works" variable to false. That's the > source of the problem I'm seeing. > > Given how critical this is to being able to cross-compile a scalable > runtime, I think there has to be a way to assert to configure that it > can just assume poll works. One way to do this is to allow for setting > a environment variable, let's call it ASSERT_WORKING_POLL, while > running configure. Here's a patch to erts/configure.in to allow that: > We plan to introduce basic support for cross-compilation in R13B (with improvements in subsequent releases), and it will allow you to specify whether poll works on the target platform. Therefore, we will not include your patch. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From vladdu55@REDACTED Fri Mar 6 15:39:05 2009 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Fri, 6 Mar 2009 15:39:05 +0100 Subject: [erlang-questions] [ANN] erlide 0.5.0 has been released Message-ID: <95be1d3b0903060639o13b98500ye8f048ceb20527a2@mail.gmail.com> Hello everybody! We have been working hard to fix bugs and add new functionality and today we are proud to be able to release version 0.5.0! Now you can do your Erlang development with less hassle, and the fun part is that there's a lot more to come in the pipeline (stay tuned! -- did someone just whispered "refactoring"? :-). The project's site is at http://erlide.org The Eclipse update site is at http://erlide.org/update (or the older http://erlide.sourceforge.net/update) For those that have been using out unstable releases, there are only few new things. For the others, a list of some of the new things can be found in the ChangeLog (below). IMPORTANT: Please note that this is the last release that targets Eclipse 3.3. The answers (or more exactly, lack of) to our previous questions about which versions we should target tell us that everybody is running 3.4 or newer. If you're still stuck with 3.3 and will need continued support, please contact us. Enjoy! /Vlad and Jakob List of user visible changes between 0.4.3 and 0.5.0 Added external include path settings file for erlang projects (just like external modules file) fixed bug when build backend was called "erlide" Indentation uses tabs, indents only affected functions, and is cleaned up a bit fixes around backend startup and ide backend Fixed autocompletion so that external modules can be completed Fixed a slight oversight when accessing external files (it should be created and have the erlang nature) Added error marker if a file could not be compiled at all (compiler crashed or no backend) Auto-completion didn't work when both default_external_modules and external_modules were specified (open did the right thing). http://www.assembla.com/spaces/erlide/tickets/230-Sorting-in-outline-should-not-affect-clauses http://www.assembla.com/spaces/erlide/tickets/167-Add-completion-of-variable-names http://www.assembla.com/spaces/erlide/tickets/233-Indent-breaks-when-constructing-binary-and-using-$-notation-to-get-ascii-code-for-character- http://www.assembla.com/spaces/erlide/tickets/236-Debugger---show-records-as-records-in-Variables-view http://www.assembla.com/spaces/erlide/tickets/214: updated jinterface to R12 optimized RPC performance by caching call signatures New, fancier, better, smarter reconciler! - Scans all changes after one delay - Parses after all changes, not for each one of them (no more shuffling after undo or find/replace) - Method to reconcile without delay and wait for it, so model is up-to-date, e.g. for model commands like Completion or Open Small improvement of dirty region handling, works better with backspace Autoindent now also uses tabs Honour the Preferences -> General / Editors / Text Editors / Insert spaces for tabs checkbox, when indenting, if it's checked, use only spaces. Restored reset handling in reconciler, so it doesn't reconcile during lengthy typing, but afterwards added runtimeVersion project preference, to allow not specifying a runtime name (that are user specific) http://www.assembla.com/spaces/erlide/tickets/127-Goto-variable-definition http://www.assembla.com/spaces/erlide/tickets/184-Show-parameter-names-for-code-completed-functions http://www.assembla.com/spaces/erlide/tickets/184-Show-parameter-names-for-code-completed-functions beautified edoc display and removed classes that were copied from jface http://www.assembla.com/spaces/erlide/tickets/197--go-to-definition--should-detect-even-M-F-N-constructs http://www.assembla.com/spaces/erlide/tickets/196-New-project-wizard---exception-if-include-field-is-empty http://www.assembla.com/spaces/erlide/tickets/122-Add-support-for-R12--type-and--spec-annotations Handles 'after' in 'try'. (Part of http://erlide.assembla.com/spaces/erlide/tickets/251-indent---more-bugs http://www.assembla.com/spaces/erlide/tickets/259-completion-problem http://www.assembla.com/spaces/erlide/tickets/251-indent---more-bugs http://www.assembla.com/spaces/erlide/tickets/246-completion-proposals-don-t-work-for-quoted-module-name- http://www.assembla.com/spaces/erlide/tickets/254-folding---preferences-don-t-work updated docs with installation instructions for eclipse 3.4 http://erlide.assembla.com/spaces/erlide/tickets/105-Allow-outline-for-external-erlang-files Type specs were ugly in outline http://www.assembla.com/spaces/erlide/tickets/167-Add-completion-of-variable-names http://www.assembla.com/spaces/erlide/tickets/260-navigation-problems http://www.assembla.com/spaces/erlide/tickets/262-folding---initial-folding-done-while-typing--annoying http://www.assembla.com/spaces/erlide/tickets/258-outline-disappearing-again http://www.assembla.com/spaces/erlide/tickets/86-Stopping-Erlang-launches http://www.assembla.com/spaces/erlide/tickets/266: make backend restart after crash http://www.assembla.com/spaces/erlide/tickets/267-indentation-error From masse@REDACTED Fri Mar 6 15:48:37 2009 From: masse@REDACTED (mats cronqvist) Date: Fri, 06 Mar 2009 15:48:37 +0100 Subject: [erlang-questions] Erlang module for command line interfaces? In-Reply-To: <0016e644cf328bfab0046472e249@google.com> (cayle spandon's message of "Fri\, 06 Mar 2009 13\:01\:36 +0000") References: <0016e644cf328bfab0046472e249@google.com> Message-ID: <87bpseg116.fsf@sterlett.hq.kred> cayle.spandon@REDACTED writes: > Is there an Erlang module which allows me to implement an interactive command > line interface (CLI) for a networking protocol? The CLI would be used both for > configuration ("config commands") and status reporting ("show commands"). OTP comes with a shell (the erlang shell.) It's not particularly difficult to write your own shell. I can state that with some degree of certainty because I've actually done it (for netconf, actually.) > I guess am looking to something similar to what Tail-f Systems provides, > except it needs to be free / open source and I don't need the netconf part of > it for now, just the CLI part. > > If no such "CLI module" is available, what is the "Erlang way" of > configuration and status reporting for stand-alone daemons written in Erlang? erl -remsh might do the trick. And SNMP is of course available. mats From anders.nygren@REDACTED Fri Mar 6 15:52:21 2009 From: anders.nygren@REDACTED (Anders Nygren) Date: Fri, 6 Mar 2009 08:52:21 -0600 Subject: [erlang-questions] Erlang module for command line interfaces? In-Reply-To: <87bpseg116.fsf@sterlett.hq.kred> References: <0016e644cf328bfab0046472e249@google.com> <87bpseg116.fsf@sterlett.hq.kred> Message-ID: On Fri, Mar 6, 2009 at 8:48 AM, mats cronqvist wrote: > cayle.spandon@REDACTED writes: > >> Is there an Erlang module which allows me to implement an interactive command >> line interface (CLI) for a networking protocol? The CLI would be used both for >> configuration ("config commands") and status reporting ("show commands"). > > ?OTP comes with a shell (the erlang shell.) It's not particularly > ?difficult to write your own shell. I can state that with some degree > ?of certainty because I've actually done it (for netconf, actually.) > >> I guess am looking to something similar to what Tail-f Systems provides, >> except it needs to be free / open source and I don't need the netconf part of >> it for now, just the CLI part. >> >> If no such "CLI module" is available, what is the "Erlang way" of >> configuration and status reporting for stand-alone daemons written in Erlang? > > erl -remsh might do the trick. And SNMP is of course available. > The ssh application has an example on how to make an ssh based CLI. /Anders From kenneth.lundin@REDACTED Fri Mar 6 15:54:02 2009 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Fri, 6 Mar 2009 15:54:02 +0100 Subject: [erlang-questions] Erlang module for command line interfaces? In-Reply-To: <87bpseg116.fsf@sterlett.hq.kred> References: <0016e644cf328bfab0046472e249@google.com> <87bpseg116.fsf@sterlett.hq.kred> Message-ID: With help of the SSH application in Erlang/OTP you can easily make your own taylormade CLI. You can then connect to it from any SSH client and use the CLI. /Kenneth Erlang/OTP Ericsson On Fri, Mar 6, 2009 at 3:48 PM, mats cronqvist wrote: > cayle.spandon@REDACTED writes: > >> Is there an Erlang module which allows me to implement an interactive command >> line interface (CLI) for a networking protocol? The CLI would be used both for >> configuration ("config commands") and status reporting ("show commands"). > > ?OTP comes with a shell (the erlang shell.) It's not particularly > ?difficult to write your own shell. I can state that with some degree > ?of certainty because I've actually done it (for netconf, actually.) > >> I guess am looking to something similar to what Tail-f Systems provides, >> except it needs to be free / open source and I don't need the netconf part of >> it for now, just the CLI part. >> >> If no such "CLI module" is available, what is the "Erlang way" of >> configuration and status reporting for stand-alone daemons written in Erlang? > > erl -remsh might do the trick. And SNMP is of course available. > > ?mats > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From richardc@REDACTED Fri Mar 6 15:57:51 2009 From: richardc@REDACTED (Richard Carlsson) Date: Fri, 06 Mar 2009 15:57:51 +0100 Subject: [erlang-questions] Literate Erlang (eweb) In-Reply-To: <49AF1FE8.8090204@anydata.co.uk> References: <49AF1FE8.8090204@anydata.co.uk> Message-ID: <49B139EF.8040801@it.uu.se> Fred Youhanaie wrote: > I started using eweb a few days ago, by downloading and working with > eweb-1.0 [1] and then eweb-1.1 [2]. > > Is there a more recent version that I might have missed? > > [1] http://www.sics.se/~joe/ericsson/literate/literate.html > [2] http://www.erlang.org/contrib/eweb-1.1.tgz No, I don't think anyone else has done any more work on it, at least not anything published. /Richard -- "Having users is like optimization: the wise course is to delay it." -- Paul Graham From jahakala@REDACTED Thu Mar 5 20:34:57 2009 From: jahakala@REDACTED (Jani Hakala) Date: Thu, 05 Mar 2009 21:34:57 +0200 Subject: [erlang-questions] Generating skeleton linked-in driver code using an IDL? Message-ID: <87r61bkbku.fsf@pingviini.kortex.jyu.fi> I have written a small linked-in driver that fortunately has only a few different kind of messages passing between erlang code and driver (driver_entry outputv, ready_input+driver_output_binary). It also handles several operations issued by port_control() (decoding of data using ei_decode_*). A big portion of the code is related to decoding and encoding of the data although the messages are quite simple. I have looked at some of the code generation tools that are supposed to help developing linked-in drivers. They (ETDK, DryvErl and the proposed Foreign Function Interface) seem to focus on how to call C-functions. I would be more interested about a tool that could be used to define message structures and operations supported by a linked-in driver. Those operations would call C/C++ functions in a way that would not be visible outside the driver (facade pattern). An IDL compiler is included in OTP so I wrote a CORBA IDL file that could be a starting point for a new version of my linked-in driver (or C node perhaps) if it was possible to generate 1) C/C++ code that could be used to (de)serialize the messages, 2) C/C++ skeleton files for the driver, 3) Erlang code that would (de)serialize messages using CDR encoding or erlang external format (or other solution), and 4) Erlang skeleton files for the process that owns the port. 1) could be implemented using ei_decode/ei_encode functions. In the case of port_command (3) might be just call to term_to_binary after some sanity checks for the parameters. Most of the checking could be delayed until the C-code deserializes the data. ic - the erlang IDL compiler - generates several files that might be useful if a tool supporting this kind of scheme was developed or if ic was modified: - The output files include type codes that describe the data structures (:tc/0) and operations (:oe_get_interface/0). - Record definitions are also available for each defined structure and exception. - The names, in/inout/out information of the parameters are unfortunately not readily available (not without changing ic?). - No oneway-information for operations either. Here is the IDL file (which is nowhere close to being complete) I wrote -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: CAN.idl URL: -------------- next part -------------- and some sort of use cases: -------------- next part -------------- - PortOwner is a C++ class in the following use cases. - In the case of C: can->port_owner->xxx(can, ...) instead of this->port_owner->xxx(...) - oneway calls: handled by erl_drv_entry->output() (sort of gen_server:cast) - twoway calls: handled by erl_drv_entry->control() (sort of gen_server:call) - 'magic' is here something that the programmer should not need to care about erlang -> driver Port = can_driver:init(...) - CAN and PortOwner instances created on C/C++ side CAN::init(...) { /* Start a thread for incoming messages */ /* call driver_select to register */ } {ok, {CAN_Ref}} = can_driver:open(Port, "CAN0") -> some erlang code and 'magic' in erl_drv_entry->control() -> CAN::open(const char * ifc, CAN_Ref_out ifc_ref) { CAN_Interface * interface = new CAN_Interface(ifc); CAN_Ref ifc_ref_(ifc); this->register(ifc_ref_, interface); ifc_ref = ifc_ref_; } /* Raising exception: port_owner->error() or throw */ -> 'magic' -> {ok, {CAN_Ref}} ok = can_driver:send_message(Port, CAN_Ref, 1, false, [1, 2, 3]) -> 'magic' -> CAN::send_message(CAN_Ref ifc_ref, uint32_t arbitration_id, bool remote, const OctetSeq & bytes) {?/* C++ code */ } -> 'magic' -> ok (if no errors) driver -> erlang void ready_input(ErlDrvData drv_data, ErlDrvEvent event) { CAN_ptr can(CAN_OBJECT(drv_data)); /* obtain CAN_Ref_out ifc_ref and Message_out msg somehow * (e.g. from a queue) */ can->port_owner->on_message(ifc_ref, msg); } -> 'magic' -> can_driver:on_message(MyData, {CAN_Ref, Message}) ... user defined erlang code -------------- next part -------------- Jani Hakala From vinoski@REDACTED Fri Mar 6 19:41:14 2009 From: vinoski@REDACTED (Steve Vinoski) Date: Fri, 6 Mar 2009 13:41:14 -0500 Subject: [erlang-questions] max fds for epoll incorrectly reduced to FD_SETSIZE In-Reply-To: <6672d0160903060634l571bfc11peb560b6d707543e2@mail.gmail.com> References: <65b2728e0902211116i120c2b18oe29c5c9c9642f8e4@mail.gmail.com> <6672d0160902222358r32ad61dl749a64993534144@mail.gmail.com> <65b2728e0902230841k4abd0331w35f23292b76915f3@mail.gmail.com> <65b2728e0902231441j740397b4h6ee845823343be8e@mail.gmail.com> <6672d0160903060634l571bfc11peb560b6d707543e2@mail.gmail.com> Message-ID: <65b2728e0903061041k158ccbe3uf04faaa12320ef7b@mail.gmail.com> On 3/6/09, Bjorn Gustavsson wrote: > > We plan to introduce basic support for cross-compilation in R13B > (with improvements in subsequent releases), and it will allow you to > specify whether poll works on the target platform. Therefore, we will > not include your patch. That's great news about the cross-compilation support. Once you get that cross-compilation poll capability into a snapshot, if you need someone to try it out, just let me know. thanks, --steve From bernie@REDACTED Fri Mar 6 23:32:34 2009 From: bernie@REDACTED (Bernard Duggan) Date: Sat, 07 Mar 2009 09:32:34 +1100 Subject: [erlang-questions] Noob Question ... In-Reply-To: <200903061339.n26Dd2Rc018338@mail.pharos-avantgard.com> References: <200903061339.n26Dd2Rc018338@mail.pharos-avantgard.com> Message-ID: <49B1A482.5020509@m5net.com> Valentin Micic wrote: >> The immediate thing that strikes me is that "127.0.0.1" should be > {127,0,0,1}. In gen_tcp (erlang in general) the address is a tuple not a > string. > > This is not correct -- gen_tcp supports string as well as tuple for dotted > ip address specification That's true, and for most cases it will work fine, however if you pass gen_udp a string address it will always call (from memory) gethostbyname - I presume the same probably applies to gen_tcp. This turns out to be a relatively slow operation - if you're only doing one (or even a hundred) lookups, it's not an issue - we started to strike performance problems, however, doing large amounts of gen_udp:send operations with an IP passed as a string. These went away when we changed it to a tuple. It's not going to be a problem here, but using the tuple form is probably a good habit to get into so that it doesn't bite you in the future. Cheers, B From sand@REDACTED Sat Mar 7 08:49:59 2009 From: sand@REDACTED (sand@REDACTED) Date: Fri, 6 Mar 2009 23:49:59 -0800 Subject: [erlang-questions] Why MAXCS? Message-ID: <18866.10023.850342.329893@priss.frightenedpiglet.com> Down in the guts of stdlib-1.15.3/src/io_lib_pretty.erl, there's a preprocessor definition: -define(MAXCS, 60). % Approx max number of characters on one line. It's used in various places in the file to detect "long" lines and split them when pretty-printing. For example, in io_lib_pretty:print/5, we do a one-line write if the term would exceed the provided line length (variable Ll), *or* of the term does not exceed MAXCS. print(Term, Col, Ll, D, RecDefFun) when is_tuple(Term); is_list(Term) -> If = {_S, Len} = print_length(Term, D, RecDefFun), if Len < Ll - Col, Len =< ?MAXCS -> write(If); true -> TInd = while_fail([-1, 4], fun(I) -> cind(If, Col, Ll, I, 0, 0) end, 1), pp(If, Col, Ll, TInd, indent(Col), 0, 0) end; print(<<_/bitstring>>=Term, Col, Ll, D, RecDefFun) -> If = {_S, Len} = print_length(Term, D, RecDefFun), if Len < Ll - Col, Len =< ?MAXCS -> write(If); true -> TInd = while_fail([-1, 4], fun(I) -> cind(If, Col, Ll, I, 0, 0) end, 1), pp(If, Col, Ll, TInd, indent(Col), 0, 0) end; This means that all you can realy do with the LineLength argument to io_lib:print/4 is drop it to something smaller than 60. Bumping it up to 1000000 (to try to get everything printed on one line) doesn't work. %% Standard 4> io:put_chars(io_lib:print(["foo", "foo", "foo", "foo", "foo", "foo", "foo", "foo", "foo", "foo", "foo", "foo", "foo", "foo", "foo", "foo", "foo", "foo", "foo", "foo", "foo"])). ["foo","foo","foo","foo","foo","foo","foo","foo","foo", "foo","foo","foo","foo","foo","foo","foo","foo","foo","foo", "foo","foo"]ok %% Small LineLength --- prints short lines 5> io:put_chars(io_lib:print(["foo", "foo", "foo", "foo", "foo", "foo", "foo", "foo", "foo", "foo", "foo", "foo", "foo", "foo", "foo", "foo", "foo", "foo", "foo", "foo", "foo"], 1, 20, -1)). ["foo","foo", "foo","foo", "foo","foo", "foo","foo", "foo","foo", "foo","foo", "foo","foo", "foo","foo", "foo","foo", "foo","foo", "foo"]ok %% Big LineLength --- doesn't print long lines 6> io:put_chars(io_lib:print(["foo", "foo", "foo", "foo", "foo", "foo", "foo", "foo", "foo", "foo", "foo", "foo", "foo", "foo", "foo", "foo", "foo", "foo", "foo", "foo", "foo"], 1, 200000, -1)). ["foo","foo","foo","foo","foo","foo","foo","foo","foo", "foo","foo","foo","foo","foo","foo","foo","foo","foo","foo", "foo","foo"]ok Is this behavior deliberate? If so, it should be documented that line lengths are locked to a maximum of 60 (in io_lib and io). Otherwise, it would be very helpful if we could get rid of MAXCS. Derek -- Derek Upham sand@REDACTED From steven.charles.davis@REDACTED Sat Mar 7 12:23:16 2009 From: steven.charles.davis@REDACTED (Steve Davis) Date: Sat, 07 Mar 2009 05:23:16 -0600 Subject: [erlang-questions] wxErlang release In-Reply-To: <49B0F8BE.6040708@gmail.com> References: <49B0DF37.8060007@gmail.com> <49B0F14C.70301@erix.ericsson.se> <49B0F8BE.6040708@gmail.com> Message-ID: <49B25924.6010308@gmail.com> Dan wrote: >I don't think I will have the time to do it. So please have a go at it. ...so I did a quick hack to see what the issues may be... git://github.com/komone/gx.git Creating UIs using gs-style trees seems as though it should be pretty straightforward. The biggest issue I found so far is that there is a huge "enum leak" back into the component ids and (worse) the event messages... i.e. the wx events and component ids are forced to be integers -- maybe an ets mapping would be the simplest answer to that. The code is raw as it possibly could be but I think it shows feasibility ;) /sd From steven.charles.davis@REDACTED Sun Mar 8 02:16:48 2009 From: steven.charles.davis@REDACTED (Steve Davis) Date: Sat, 7 Mar 2009 17:16:48 -0800 (PST) Subject: [erlang-questions] wxErlang release In-Reply-To: <49B25924.6010308@gmail.com> References: <49B0DF37.8060007@gmail.com> <49B0F14C.70301@erix.ericsson.se> <49B0F8BE.6040708@gmail.com> <49B25924.6010308@gmail.com> Message-ID: <90197390-9c4e-4195-90c6-5432535fc3ce@v39g2000yqm.googlegroups.com> It has struck me that as long as you can convert any data format into an appropriate erlang term (list/tuple/atom) then everything else becomes staggeringly simple. The most time-consuming issue of programming then becomes one of the impedance mismatch between the input format and the term format. ...to be continued... /sd From ssroy1979@REDACTED Sun Mar 8 02:45:39 2009 From: ssroy1979@REDACTED (Salonee Sinha Roy) Date: Sat, 7 Mar 2009 17:45:39 -0800 Subject: [erlang-questions] question about erlaws Message-ID: Hi All I have erlaws code which is as follows inets:start(). crypto:start(). S3=erlaws_s3:new(Aws_Key,Aws_secret_key,false), S3:list_buckets(), S3:list_contents("BucketName"). The call to list_contents returns the following error {error,{"SignatureDoesNotMatch", "The request signature we calculated does not match the signature you provided. Check your key and signing method.", "18AB3FF73AAFEECB"}} I also tried called S3:delete_bucket(BucketName) and I get the same error. Could someone help me with this. Any help would be appreciated. -------------- next part -------------- An HTML attachment was scrubbed... URL: From hubert.plociniczak@REDACTED Sun Mar 8 02:53:54 2009 From: hubert.plociniczak@REDACTED (Hubert Plociniczak) Date: Sun, 8 Mar 2009 01:53:54 +0000 Subject: [erlang-questions] examples for erlang with joins Message-ID: <310adeca0903071753x4caf9f4dta2f2d1e4509d666@mail.gmail.com> Hi All, I've been working recently on extending Erlang with constructs that allow for matching on multiple messages in the mailbox. The idea comes from Join-calculus, and its implementation in languages like Polyphonic C# or JoCaml. So, programmers should be able to write for example: receive {foo, One} and {bar, Two} when (One > Two) -> expr.....; .... end And I also added similar behaviour to gen_server. The problem now I have, is to actually find a good example to prove that such constructs could be useful to have in the language. I have already implemented solutions to Santa Claus or Wide Finder problem, but I am potentially looking for something bigger, like some already existing application, that could be more clear using this syntax. Any ideas? Another question relates to the implementation of the extension. I've got two versions, one uses standard Erlang and parse_transform and the other uses changes I made to the erts. I was wondering if there are any tests available for the runtime as there is nothing I can find in the source code? Thanks, hubert -------------- next part -------------- An HTML attachment was scrubbed... URL: From ssroy1979@REDACTED Sun Mar 8 05:51:21 2009 From: ssroy1979@REDACTED (ssroy) Date: Sat, 7 Mar 2009 20:51:21 -0800 (PST) Subject: [erlang-questions] question about erlaws In-Reply-To: References: Message-ID: <0dfc4902-57eb-403b-9b0e-c4963ff8e6ca@v39g2000yqm.googlegroups.com> I think I have figured out a solution for this. Having bucket names with upper case letters causes the SignatureDoesNotmatch error while doing a list_contents. I dont know why it is so, but I was able to get rid of these errors by using bucket names with lowe r case errors. On Mar 7, 5:45 pm, Salonee Sinha Roy wrote: > Hi All > I have erlaws code which is as follows > > inets:start(). > crypto:start(). > S3=erlaws_s3:new(Aws_Key,Aws_secret_key,false), > S3:list_buckets(), > S3:list_contents("BucketName"). > > The call to list_contents returns the following error > > {error,{"SignatureDoesNotMatch", > "The request signature we calculated does not match the signature > you provided. Check your key and signing method.", > "18AB3FF73AAFEECB"}} > > I also tried called S3:delete_bucket(BucketName) and I get the same error. > > Could someone help me with this. Any help would be appreciated. > > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions From vladdu55@REDACTED Sun Mar 8 11:42:28 2009 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Sun, 8 Mar 2009 11:42:28 +0100 Subject: [erlang-questions] examples for erlang with joins In-Reply-To: <310adeca0903071753x4caf9f4dta2f2d1e4509d666@mail.gmail.com> References: <310adeca0903071753x4caf9f4dta2f2d1e4509d666@mail.gmail.com> Message-ID: <95be1d3b0903080342l758af6bdx4bc85da986a08927@mail.gmail.com> Hi, 2009/3/8 Hubert Plociniczak : > I've been working recently on extending Erlang with constructs that allow > for matching on multiple messages in the mailbox. > The idea comes from Join-calculus, and its implementation in languages like > Polyphonic C# or JoCaml. > So, programmers should be able to write for example: > > receive > ? {foo, One} and {bar, Two} when (One > Two) -> > ??? expr.....; > ?.... > end Thiss looks interesting, but could you please describe the semantics of the above example? Does it match for the two messages in sequence, does one of them have to be the first in queue, is order important? best regards, Vlad From exta7@REDACTED Sun Mar 8 13:04:28 2009 From: exta7@REDACTED (Zvi) Date: Sun, 8 Mar 2009 05:04:28 -0700 (PDT) Subject: [erlang-questions] examples for erlang with joins In-Reply-To: <310adeca0903071753x4caf9f4dta2f2d1e4509d666@mail.gmail.com> References: <310adeca0903071753x4caf9f4dta2f2d1e4509d666@mail.gmail.com> Message-ID: <22397309.post@talk.nabble.com> Hi Hubert, nice work. Does it work only inside receive or for any pattern match? If it's supporting generic pattern matching, I would suggest, rewriting mochiweb HTML parser, using your join patterns. http://github.com/tswicegood/mochiweb/blob/a52f350406c69e24cc5f0aceda1d8dfef6a8fdd4/src/mochiweb_html.erl It has a lot of uggly code like this: -define(IS_WHITESPACE(C), (C =:= $\s orelse C =:= $\t orelse C =:= $\r orelse C =:= $\n)). f(C) when IS_WHITESPACE(C) -> ... using your join patterns you can rewrite it, like: f(C = ($\s and $\t and $\r and $\n) ) -> ... I would suggest some better syntax/operator instead of "and" keyword, like: f(C = ($\s ^ $\t ^ $\r ^ $\n) ) -> ... Also, I would like to test the parse transform version. BR, Zvi Hubert Plociniczak-3 wrote: > > Hi All, > > I've been working recently on extending Erlang with constructs that allow > for matching on multiple messages in the mailbox. > The idea comes from Join-calculus, and its implementation in languages > like > Polyphonic C# or JoCaml. > So, programmers should be able to write for example: > > receive > {foo, One} and {bar, Two} when (One > Two) -> > expr.....; > .... > end > > And I also added similar behaviour to gen_server. > > The problem now I have, is to actually find a good example to prove that > such constructs could be useful to have in the language. I have already > implemented solutions to Santa Claus or Wide Finder problem, but I am > potentially looking for something bigger, like some already existing > application, that could be more clear using this syntax. Any ideas? > > Another question relates to the implementation of the extension. I've got > two versions, one uses standard Erlang and parse_transform and the other > uses changes I made to the erts. I was wondering if there are any tests > available for the runtime as there is nothing I can find in the source > code? > > Thanks, > hubert > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- View this message in context: http://www.nabble.com/examples-for-erlang-with-joins-tp22394129p22397309.html Sent from the Erlang Questions mailing list archive at Nabble.com. From steven.charles.davis@REDACTED Sun Mar 8 14:39:38 2009 From: steven.charles.davis@REDACTED (Steve Davis) Date: Sun, 8 Mar 2009 06:39:38 -0700 (PDT) Subject: [erlang-questions] wxErlang release In-Reply-To: <90197390-9c4e-4195-90c6-5432535fc3ce@v39g2000yqm.googlegroups.com> References: <49B0DF37.8060007@gmail.com> <49B0F14C.70301@erix.ericsson.se> <49B0F8BE.6040708@gmail.com> <49B25924.6010308@gmail.com> <90197390-9c4e-4195-90c6-5432535fc3ce@v39g2000yqm.googlegroups.com> Message-ID: <1af2d448-5de4-4533-854a-71aa03241ee5@c11g2000yqj.googlegroups.com> For those interested... I added a module to allow definition of the UI in XML (a la XUL-ish) http://github.com/komone/gx/ Warning! This is all highly incomplete and purely *experimental* However it does show up the way enums and little hacks like using & to define accelerator keys in strings bleed right through from the cpp. Yep, there's work to be done! Any feedback/ideas would be most welcome. e.g. is the best way to deal with events to run gx as (yet another) gen_server that can preprocess events? Seems to me that if you go that far, you may as well talk directly to the port... regs, sd From prikrutil@REDACTED Sun Mar 8 18:47:17 2009 From: prikrutil@REDACTED (Sergey Samokhin) Date: Sun, 8 Mar 2009 10:47:17 -0700 Subject: [erlang-questions] Should I use wait_for_tables/2 right after creating tables? Message-ID: Hello. I often find myself using mnesia:wait_for_tables/2 to ensure that all newly created tables are ready to use: create_tables() -> % At this point mnesia is already started mnesia:create_table(foo, [{attributes, record_info(fields, foo)}]), mnesia:create_table(bar, [{attributes, record_info(fields, bar)}]), mnesia:wait_for_tables([foo, bar], 20000). Is it necessary to wait here? I started doubting this habbit after I had read that "all schema manipulation functions are implemented with normal transaction management system" in mnesia man. As I know, any function involving standard transaction mechanism returns when all things are completely done, so wait_for_tables can be (can it be?) safety removed here. -- Sergey Samokhin -------------- next part -------------- An HTML attachment was scrubbed... URL: From antoine.koener@REDACTED Sun Mar 8 18:47:14 2009 From: antoine.koener@REDACTED (Antoine Koener) Date: Sun, 8 Mar 2009 18:47:14 +0100 Subject: [erlang-questions] Unix domain sockets In-Reply-To: <358109.5796.qm@web65508.mail.ac4.yahoo.com> References: <3dbc6d1c0903040223w5a079909j8e8851332521efa3@mail.gmail.com> <8209f740903040518y3b3cc4b1j3b06165f3da3f3c8@mail.gmail.com> <358109.5796.qm@web65508.mail.ac4.yahoo.com> Message-ID: <1c89b3a10903081047me42b394q9ab43093b7847c8@mail.gmail.com> And what about the support for NamedPipes on windows ? Anyone with experience ? On Fri, Mar 6, 2009 at 3:24 AM, Richard Andrews wrote: > > IIRC there was a UNIX socket project in jungerl too. > > > > > > There's an example driver for unix domain sockets under > > $OTP_ROOT/lib/kernel/examples/uds_dist/ > > > > (It's still there in R13A-0, BTW.) > > > > It used to be documented in the Interoperability Tutorial, but > > I think they've switched to a different example now. > > > Stay connected to the people that matter most with a smarter inbox. > Take a look http://au.docs.yahoo.com/mail/smarterinbox > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- http://easyerl.blogspot.com/ http://www.open-tools.org/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From prikrutil@REDACTED Sun Mar 8 20:57:17 2009 From: prikrutil@REDACTED (Sergey Samokhin) Date: Sun, 8 Mar 2009 12:57:17 -0700 Subject: [erlang-questions] Should I use wait_for_tables/2 right after creating tables? In-Reply-To: References: Message-ID: Hello. Just a small question, I've forgotten to ask in the previous letter. Should I also use wait_for_tables for schema table right after mnesia:change_config(extra_db_nodes, [Node]) on ram-based nodes? Or schema will automatically be upgraded after change_config/2 returns? -- Sergey Samokhin -------------- next part -------------- An HTML attachment was scrubbed... URL: From ok@REDACTED Mon Mar 9 02:36:04 2009 From: ok@REDACTED (Richard O'Keefe) Date: Mon, 9 Mar 2009 14:36:04 +1300 Subject: [erlang-questions] examples for erlang with joins In-Reply-To: <22397309.post@talk.nabble.com> References: <310adeca0903071753x4caf9f4dta2f2d1e4509d666@mail.gmail.com> <22397309.post@talk.nabble.com> Message-ID: On 9 Mar 2009, at 1:04 am, Zvi wrote: {mochiweb has} > > -define(IS_WHITESPACE(C), > (C =:= $\s orelse C =:= $\t orelse C =:= $\r orelse C =:= $\n)). > > f(C) when IS_WHITESPACE(C) -> ... Given that we have '=:=' and 'orelse' and 'length', it wouldn't be much of a change to Erlang to allow member(C, " \t\r\n") in a guard. > > I would suggest some better syntax/operator instead of "and" > keyword, like: > > f(C = ($\s ^ $\t ^ $\r ^ $\n) ) -> ... Syntax we _already_ have would be even better. I looked at the Mochiweb code recently. My first reaction was to ask for member/2 in guards; my second reaction was that character classification predicates would probably be more to the point. But none of this really has anything to do with joins. From hubert.plociniczak@REDACTED Mon Mar 9 02:51:03 2009 From: hubert.plociniczak@REDACTED (Hubert Plociniczak) Date: Mon, 9 Mar 2009 01:51:03 +0000 Subject: [erlang-questions] examples for erlang with joins In-Reply-To: <95be1d3b0903080342l758af6bdx4bc85da986a08927@mail.gmail.com> References: <310adeca0903071753x4caf9f4dta2f2d1e4509d666@mail.gmail.com> <95be1d3b0903080342l758af6bdx4bc85da986a08927@mail.gmail.com> Message-ID: <310adeca0903081851g58ad9f18wc3cf86aa2cdfd09c@mail.gmail.com> 2009/3/8 Vlad Dumitrescu > Hi, > > > receive > > {foo, One} and {bar, Two} when (One > Two) -> > > expr.....; > > .... > > end > > Thiss looks interesting, but could you please describe the semantics > of the above example? Does it match for the two messages in sequence, > does one of them have to be the first in queue, is order important? > Let's assume that in the mailbox we have messages(from oldest to newest): [ {foo, 12}, {bar, 2} ] or [ {bar, 2}, {foo, 12} ] Then both will match because I check all the possible permutations. The order is important when we have more Joins and it works in a similar way as standard selective receive, i.e. the first valid permutation will match. Here is an extract from my test cases to give you an idea of what I want to achieve (should be self-explanatory): self() ! foo, self() ! foo, self() ! foo, self() ! foo, ok = receive foo and foo and foo and foo -> ok end, clear_mailbox(), %% purge all messages self() ! {one, 1}, self() ! {two, 3}, Z = 4, A = 1, ok = receive {two, 3} and {one, Z} -> error; {two, 3} and {one, A} -> ok end, self() ! {test, test1, test2}, self() ! foo, ok = receive _X and foo -> error; X -> {test, _, _} = X, ok end, self() ! {test1, 10}, self() ! {test2, 15}, self() ! {test3, 10}, ok = receive {C, X1} and {B, X1} -> try C = test1, B = test3, ok catch error:{badmatch, _} -> C = test3, B = test1, ok end end. I am also working on Operational Semantics for this extended version of Erlang with Joins, but it is still work in progress. Zvi, >nice work. Does it work only inside receive or for any pattern match? >If it's supporting generic pattern matching, I would suggest, rewriting >mochiweb HTML parser, using your join patterns. This is only designed for matching on the messages in the mailbox. hubert -------------- next part -------------- An HTML attachment was scrubbed... URL: From ok@REDACTED Mon Mar 9 03:03:53 2009 From: ok@REDACTED (Richard O'Keefe) Date: Mon, 9 Mar 2009 15:03:53 +1300 Subject: [erlang-questions] examples for erlang with joins In-Reply-To: <310adeca0903081851g58ad9f18wc3cf86aa2cdfd09c@mail.gmail.com> References: <310adeca0903071753x4caf9f4dta2f2d1e4509d666@mail.gmail.com> <95be1d3b0903080342l758af6bdx4bc85da986a08927@mail.gmail.com> <310adeca0903081851g58ad9f18wc3cf86aa2cdfd09c@mail.gmail.com> Message-ID: <001BA9CD-0747-49E7-9AE1-E3E5A3583E7F@cs.otago.ac.nz> This sounds like essentially the same problem as matching production rules (look for the RETE algorithm and its successors). There's one thing that troubles me, and doubtless it is addressed in the semantics, but when you are matching multiple messages, it's no longer clear which is the *first* match. From v@REDACTED Mon Mar 9 08:07:16 2009 From: v@REDACTED (Valentin Micic) Date: Mon, 9 Mar 2009 09:07:16 +0200 Subject: [erlang-questions] examples for erlang with joins In-Reply-To: <001BA9CD-0747-49E7-9AE1-E3E5A3583E7F@cs.otago.ac.nz> Message-ID: <200903090702.n2972ARc002139@mail.pharos-avantgard.com> I'd like to add one more concern: considering operational characteristics of Erlang VM, I think that adding support for join patterns at such a low level (i.e. receive...end construct) may cause performance degradation. It may be safer (at least at this point) to achieve this as a part of post-receive processing, by having some form of, say, correlation context, as hinted by Richard. Bad (or IMO good) news is that this would not be part of the language syntax. V. -----Original Message----- From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Richard O'Keefe Sent: 09 March 2009 04:04 AM To: Hubert Plociniczak Cc: erlang-questions@REDACTED Subject: Re: [erlang-questions] examples for erlang with joins This sounds like essentially the same problem as matching production rules (look for the RETE algorithm and its successors). There's one thing that troubles me, and doubtless it is addressed in the semantics, but when you are matching multiple messages, it's no longer clear which is the *first* match. _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions From exta7@REDACTED Mon Mar 9 09:40:18 2009 From: exta7@REDACTED (Zvi) Date: Mon, 9 Mar 2009 01:40:18 -0700 (PDT) Subject: [erlang-questions] examples for erlang with joins In-Reply-To: References: <310adeca0903071753x4caf9f4dta2f2d1e4509d666@mail.gmail.com> <22397309.post@talk.nabble.com> Message-ID: <22409049.post@talk.nabble.com> actualy I simplified my example from mochiweb. When I wrote the message was thinking about this: tokenize_script(Bin, S=#decoder{offset=O}, Start) -> case Bin of %% Just a look-ahead, we want the end_tag separately <<_:O/binary, $<, $/, SS, CC, RR, II, PP, TT, _/binary>> when (SS =:= $s orelse SS =:= $S) andalso (CC =:= $c orelse CC =:= $C) andalso (RR =:= $r orelse RR =:= $R) andalso (II =:= $i orelse II =:= $I) andalso (PP =:= $p orelse PP =:= $P) andalso (TT=:= $t orelse TT =:= $T) -> ... i.e. match ignoring case "> but off-course binaries do not allow nested patterns. Maybe special notation for matching character ignoring case. Off-course fully going in this direction will bridge Erlang pattern matching with regex. In my code I usualy just convert everyting to lower case before matching, but this is less efficient. Zvi Richard O'Keefe wrote: > > > On 9 Mar 2009, at 1:04 am, Zvi wrote: > {mochiweb has} >> > >> -define(IS_WHITESPACE(C), >> (C =:= $\s orelse C =:= $\t orelse C =:= $\r orelse C =:= $\n)). >> >> f(C) when IS_WHITESPACE(C) -> ... > > Given that we have '=:=' and 'orelse' and 'length', > it wouldn't be much of a change to Erlang to allow > member(C, " \t\r\n") in a guard. >> >> I would suggest some better syntax/operator instead of "and" >> keyword, like: >> >> f(C = ($\s ^ $\t ^ $\r ^ $\n) ) -> ... > > Syntax we _already_ have would be even better. > I looked at the Mochiweb code recently. My first reaction > was to ask for member/2 in guards; my second reaction was > that character classification predicates would probably be > more to the point. > > But none of this really has anything to do with joins. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > -- View this message in context: http://www.nabble.com/examples-for-erlang-with-joins-tp22394129p22409049.html Sent from the Erlang Questions mailing list archive at Nabble.com. From dgud@REDACTED Mon Mar 9 10:08:08 2009 From: dgud@REDACTED (Dan Gudmundsson) Date: Mon, 09 Mar 2009 10:08:08 +0100 Subject: [erlang-questions] Should I use wait_for_tables/2 right after creating tables? In-Reply-To: References: Message-ID: <49B4DC78.2050009@erix.ericsson.se> No you don't need to wait_for_tables after creating them. and no you don't need to wait for the schema table change_config. You have to wait for the other tables though. /Dan Sergey Samokhin wrote: > Hello. > > Just a small question, I've forgotten to ask in the previous letter. > > Should I also use wait_for_tables for schema table right after > mnesia:change_config(extra_db_nodes, [Node]) on ram-based nodes? Or > schema will automatically be upgraded after change_config/2 returns? > > -- > Sergey Samokhin > > > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From ingela@REDACTED Mon Mar 9 10:53:53 2009 From: ingela@REDACTED (Ingela Anderton Andin) Date: Mon, 09 Mar 2009 10:53:53 +0100 Subject: [erlang-questions] Erlang module for command line interfaces? In-Reply-To: References: Message-ID: <49B4E731.7040307@erix.ericsson.se> Hi! > The ssh application has an example on how to make an ssh based CLI. Note that this example still uses the deprecated API. The compiler will however help you to translate it to the new supported API. I recommend that you wait for R13 and base your implementation on ssh-1.1.1 which is better documented and better tested than previous versions. Regards Ingela Erlang/OTP - Ericsson From masse@REDACTED Mon Mar 9 11:08:33 2009 From: masse@REDACTED (mats cronqvist) Date: Mon, 09 Mar 2009 11:08:33 +0100 Subject: [erlang-questions] wxErlang release In-Reply-To: <1af2d448-5de4-4533-854a-71aa03241ee5@c11g2000yqj.googlegroups.com> (Steve Davis's message of "Sun\, 8 Mar 2009 06\:39\:38 -0700 \(PDT\)") References: <49B0DF37.8060007@gmail.com> <49B0F14C.70301@erix.ericsson.se> <49B0F8BE.6040708@gmail.com> <49B25924.6010308@gmail.com> <90197390-9c4e-4195-90c6-5432535fc3ce@v39g2000yqm.googlegroups.com> <1af2d448-5de4-4533-854a-71aa03241ee5@c11g2000yqj.googlegroups.com> Message-ID: <873adnf1pa.fsf@sterlett.hq.kred> Steve Davis writes: > For those interested... > > I added a module to allow definition of the UI in XML (a la XUL-ish) how does this relate to wxGlade? http://wxglade.sourceforge.net/ From devdoer2@REDACTED Mon Mar 9 12:48:07 2009 From: devdoer2@REDACTED (devdoer bird) Date: Mon, 9 Mar 2009 19:48:07 +0800 Subject: [erlang-questions] Is there a http reverse proxy patch for mochiweb or yaws? Message-ID: HI: Is there a http reverse proxy patch for mochiweb or yaws ?like mod_proxy ,mod_proxy_http in apache? Thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: From hubert.plociniczak@REDACTED Mon Mar 9 12:51:39 2009 From: hubert.plociniczak@REDACTED (Hubert Plociniczak) Date: Mon, 9 Mar 2009 11:51:39 +0000 Subject: [erlang-questions] examples for erlang with joins In-Reply-To: <200903090702.n2972ARc002139@mail.pharos-avantgard.com> References: <001BA9CD-0747-49E7-9AE1-E3E5A3583E7F@cs.otago.ac.nz> <200903090702.n2972ARc002139@mail.pharos-avantgard.com> Message-ID: <310adeca0903090451g35235264xe26d6070b70f44d8@mail.gmail.com> 2009/3/9 Valentin Micic > I'd like to add one more concern: considering operational characteristics > of > Erlang VM, I think that adding support for join patterns at such a low > level > (i.e. receive...end construct) may cause performance degradation. > It may be safer (at least at this point) to achieve this as a part of > post-receive processing, by having some form of, say, correlation context, > as hinted by Richard. Bad (or IMO good) news is that this would not be part > of the language syntax. > I tried to give it a go in implementing the joins directly in VM, but it would take me too much time to get through all the magic that goes in erts. Instead, I added primitives that allow me to manipulate the mailbox directly and do all the logic of joins directly in Erlang. I believe that you won't get performance degradation for standard receive constructs (i.e. joins with single pattern), or at least the drop should be marginal. However, at the end of the day, the users should have more freedom to do synchronization on messages (solutions should be more elegant). The implementation in VM would not be ready to go straight to the standard VM, it is more of a proof-of-concept that such that thing is useful and allows me to experiment with joins. It might be even better to leave the plain old receive construct, and add join construct that works similarly, but is more powerful. -------------- next part -------------- An HTML attachment was scrubbed... URL: From devdoer2@REDACTED Mon Mar 9 13:06:02 2009 From: devdoer2@REDACTED (devdoer bird) Date: Mon, 9 Mar 2009 20:06:02 +0800 Subject: [erlang-questions] Is there a http reverse proxy patch for mochiweb or yaws? In-Reply-To: References: Message-ID: Sorry, I found the reverse proxy for yaws. So is there a http proxy patch for mochiweb? :) 2009/3/9 devdoer bird > HI: > > Is there a http reverse proxy patch for mochiweb or yaws ?like mod_proxy > ,mod_proxy_http in apache? > > Thanks. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From fei@REDACTED Mon Mar 9 13:06:40 2009 From: fei@REDACTED (fei wang) Date: Mon, 9 Mar 2009 20:06:40 +0800 Subject: [erlang-questions] The red line in appmon Message-ID: When I start mnesia, and use the appmon to see the process tree of it, I saw a red line between the mnesia_event and another process. Can anybody tell me what does this line mean? -- -- --------------- ? ?? ?? -------------- next part -------------- An HTML attachment was scrubbed... URL: From steven.charles.davis@REDACTED Mon Mar 9 13:08:28 2009 From: steven.charles.davis@REDACTED (Steve Davis) Date: Mon, 9 Mar 2009 05:08:28 -0700 (PDT) Subject: [erlang-questions] wxErlang release In-Reply-To: <873adnf1pa.fsf@sterlett.hq.kred> References: <49B0DF37.8060007@gmail.com> <49B0F14C.70301@erix.ericsson.se> <49B0F8BE.6040708@gmail.com> <49B25924.6010308@gmail.com> <90197390-9c4e-4195-90c6-5432535fc3ce@v39g2000yqm.googlegroups.com> <1af2d448-5de4-4533-854a-71aa03241ee5@c11g2000yqj.googlegroups.com> <873adnf1pa.fsf@sterlett.hq.kred> Message-ID: <024a12ea-b62e-4976-aefc-96bfb2d8a573@q18g2000vbn.googlegroups.com> Hi Mats, This experiment with gx/gxml is to see how the ideas of the GS interface can be applied to building GUIs in Erlang without having to learn the entire and somewhat complex wxErlang API... ...from what I see wxGlade is a GUI designer (they say specifically it's not a builder) and also it runs on Python. I imagine when "gx/ gxml" settles down a bit it should be possible (and probably easier) to write a GUI designer that can spit out gui definitions as either xml or term files from the designer app. The question then I guess is should "gxml" really be XUL or XRC... for now it's still very early days. BR, /sd On Mar 9, 5:08?am, mats cronqvist wrote: > Steve Davis writes: > > For those interested... > > > I added a module to allow definition of the UI in XML (a la XUL-ish) > > ? how does this relate to wxGlade? > > http://wxglade.sourceforge.net/ > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions From vychodil.hynek@REDACTED Mon Mar 9 14:00:37 2009 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Mon, 9 Mar 2009 14:00:37 +0100 Subject: [erlang-questions] examples for erlang with joins In-Reply-To: <310adeca0903081851g58ad9f18wc3cf86aa2cdfd09c@mail.gmail.com> References: <310adeca0903071753x4caf9f4dta2f2d1e4509d666@mail.gmail.com> <95be1d3b0903080342l758af6bdx4bc85da986a08927@mail.gmail.com> <310adeca0903081851g58ad9f18wc3cf86aa2cdfd09c@mail.gmail.com> Message-ID: <4d08db370903090600g5c9d6ddckaf4df52016dfd734@mail.gmail.com> This test case is not clear for me: self() ! {test, test1, test2}, self() ! foo, ok = receive _X and foo -> error; X -> {test, _, _} = X, ok end, Can you describe more verbosely why first pattern should not match. 2009/3/9 Hubert Plociniczak > > > 2009/3/8 Vlad Dumitrescu > >> Hi, >> >> > receive >> > {foo, One} and {bar, Two} when (One > Two) -> >> > expr.....; >> > .... >> > end >> >> Thiss looks interesting, but could you please describe the semantics >> of the above example? Does it match for the two messages in sequence, >> does one of them have to be the first in queue, is order important? >> > > Let's assume that in the mailbox we have messages(from oldest to newest): > [ {foo, 12}, {bar, 2} ] > or > [ {bar, 2}, {foo, 12} ] > Then both will match because I check all the possible permutations. The > order is important when we have > more Joins and it works in a similar way as standard selective receive, > i.e. the first valid permutation will match. > > Here is an extract from my test cases to give you an idea of what I want to > achieve (should be self-explanatory): > > self() ! foo, > self() ! foo, > self() ! foo, > self() ! foo, > ok = receive > foo and foo and foo and foo -> > ok > end, > > clear_mailbox(), %% purge all messages > self() ! {one, 1}, > self() ! {two, 3}, > Z = 4, > A = 1, > ok = receive > {two, 3} and {one, Z} -> > error; > {two, 3} and {one, A} -> > ok > end, > self() ! {test, test1, test2}, > self() ! foo, > ok = receive > _X and foo -> > error; > X -> > {test, _, _} = X, > ok > end, > self() ! {test1, 10}, > self() ! {test2, 15}, > self() ! {test3, 10}, > ok = receive > {C, X1} and {B, X1} -> > try > C = test1, > B = test3, > ok > catch > error:{badmatch, _} -> > C = test3, > B = test1, > ok > end > end. > > I am also working on Operational Semantics for this extended version of > Erlang with Joins, but it is still work in progress. > > Zvi, > > >nice work. Does it work only inside receive or for any pattern match? > >If it's supporting generic pattern matching, I would suggest, rewriting > >mochiweb HTML parser, using your join patterns. > > This is only designed for matching on the messages in the mailbox. > > hubert > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- --Hynek (Pichi) Vychodil Analyze your data in minutes. Share your insights instantly. Thrill your boss. Be a data hero! Try Good Data now for free: www.gooddata.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From masse@REDACTED Mon Mar 9 14:02:28 2009 From: masse@REDACTED (mats cronqvist) Date: Mon, 09 Mar 2009 14:02:28 +0100 Subject: [erlang-questions] wxErlang release In-Reply-To: <024a12ea-b62e-4976-aefc-96bfb2d8a573@q18g2000vbn.googlegroups.com> (Steve Davis's message of "Mon\, 9 Mar 2009 05\:08\:28 -0700 \(PDT\)") References: <49B0DF37.8060007@gmail.com> <49B0F14C.70301@erix.ericsson.se> <49B0F8BE.6040708@gmail.com> <49B25924.6010308@gmail.com> <90197390-9c4e-4195-90c6-5432535fc3ce@v39g2000yqm.googlegroups.com> <1af2d448-5de4-4533-854a-71aa03241ee5@c11g2000yqj.googlegroups.com> <873adnf1pa.fsf@sterlett.hq.kred> <024a12ea-b62e-4976-aefc-96bfb2d8a573@q18g2000vbn.googlegroups.com> Message-ID: <87y6veetnf.fsf@sterlett.hq.kred> Steve Davis writes: > Hi Mats, > > This experiment with gx/gxml is to see how the ideas of the GS > interface can be applied to building GUIs in Erlang without having to > learn the entire and somewhat complex wxErlang API... > > ...from what I see wxGlade is a GUI designer (they say specifically > it's not a builder) and also it runs on Python. I imagine when "gx/ > gxml" settles down a bit it should be possible (and probably easier) > to write a GUI designer that can spit out gui definitions as either > xml or term files from the designer app. The question then I guess is > should "gxml" really be XUL or XRC... for now it's still very early > days. What I was getting at was that using the same XML form as the one wxGlade uses also for "gxml" might be a win. IIRC, there is direct support in wx for that format. mats From hubert.plociniczak@REDACTED Mon Mar 9 14:08:22 2009 From: hubert.plociniczak@REDACTED (Hubert Plociniczak) Date: Mon, 9 Mar 2009 13:08:22 +0000 Subject: [erlang-questions] examples for erlang with joins In-Reply-To: <4d08db370903090600g5c9d6ddckaf4df52016dfd734@mail.gmail.com> References: <310adeca0903071753x4caf9f4dta2f2d1e4509d666@mail.gmail.com> <95be1d3b0903080342l758af6bdx4bc85da986a08927@mail.gmail.com> <310adeca0903081851g58ad9f18wc3cf86aa2cdfd09c@mail.gmail.com> <4d08db370903090600g5c9d6ddckaf4df52016dfd734@mail.gmail.com> Message-ID: <310adeca0903090608q275c2f87oc1a8f8e52f42909a@mail.gmail.com> Message {test, test1, test2} is first in the message. foo is second. Similarly as in original receive I take the newest message and check if only with this message I can satisfy any of the joins. If that is not possible, then I go the next message and check if any of the joins can be satisfied using the new message (and all previous ones). Since {test, test1, test2} already satisfies one of the joins, then I fire it immediately and do not look at what else is in the message after {test, test1, test2} (though I might obviously look at it in the future, if I have any receive constructs afterwards). I hope that helps. 2009/3/9 Hynek Vychodil > This test case is not clear for me: > > self() ! {test, test1, test2}, > self() ! foo, > ok = receive > _X and foo -> > error; > X -> > {test, _, _} = X, > ok > end, > > Can you describe more verbosely why first pattern should not match. > > 2009/3/9 Hubert Plociniczak > >> >> >> 2009/3/8 Vlad Dumitrescu >> >>> Hi, >>> >>> > receive >>> > {foo, One} and {bar, Two} when (One > Two) -> >>> > expr.....; >>> > .... >>> > end >>> >>> Thiss looks interesting, but could you please describe the semantics >>> of the above example? Does it match for the two messages in sequence, >>> does one of them have to be the first in queue, is order important? >>> >> >> Let's assume that in the mailbox we have messages(from oldest to newest): >> [ {foo, 12}, {bar, 2} ] >> or >> [ {bar, 2}, {foo, 12} ] >> Then both will match because I check all the possible permutations. The >> order is important when we have >> more Joins and it works in a similar way as standard selective receive, >> i.e. the first valid permutation will match. >> >> Here is an extract from my test cases to give you an idea of what I want >> to achieve (should be self-explanatory): >> >> self() ! foo, >> self() ! foo, >> self() ! foo, >> self() ! foo, >> ok = receive >> foo and foo and foo and foo -> >> ok >> end, >> >> clear_mailbox(), %% purge all messages >> self() ! {one, 1}, >> self() ! {two, 3}, >> Z = 4, >> A = 1, >> ok = receive >> {two, 3} and {one, Z} -> >> error; >> {two, 3} and {one, A} -> >> ok >> end, >> self() ! {test, test1, test2}, >> self() ! foo, >> ok = receive >> _X and foo -> >> error; >> X -> >> {test, _, _} = X, >> ok >> end, >> self() ! {test1, 10}, >> self() ! {test2, 15}, >> self() ! {test3, 10}, >> ok = receive >> {C, X1} and {B, X1} -> >> try >> C = test1, >> B = test3, >> ok >> catch >> error:{badmatch, _} -> >> C = test3, >> B = test1, >> ok >> end >> end. >> >> I am also working on Operational Semantics for this extended version of >> Erlang with Joins, but it is still work in progress. >> >> Zvi, >> >> >nice work. Does it work only inside receive or for any pattern match? >> >If it's supporting generic pattern matching, I would suggest, rewriting >> >mochiweb HTML parser, using your join patterns. >> >> This is only designed for matching on the messages in the mailbox. >> >> hubert >> >> >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > > > -- > --Hynek (Pichi) Vychodil > > Analyze your data in minutes. Share your insights instantly. Thrill your > boss. Be a data hero! > Try Good Data now for free: www.gooddata.com > -------------- next part -------------- An HTML attachment was scrubbed... URL: From vychodil.hynek@REDACTED Mon Mar 9 14:25:31 2009 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Mon, 9 Mar 2009 14:25:31 +0100 Subject: [erlang-questions] examples for erlang with joins In-Reply-To: <310adeca0903090608q275c2f87oc1a8f8e52f42909a@mail.gmail.com> References: <310adeca0903071753x4caf9f4dta2f2d1e4509d666@mail.gmail.com> <95be1d3b0903080342l758af6bdx4bc85da986a08927@mail.gmail.com> <310adeca0903081851g58ad9f18wc3cf86aa2cdfd09c@mail.gmail.com> <4d08db370903090600g5c9d6ddckaf4df52016dfd734@mail.gmail.com> <310adeca0903090608q275c2f87oc1a8f8e52f42909a@mail.gmail.com> Message-ID: <4d08db370903090625v60f0baccmb10d4a0e83dfd205@mail.gmail.com> If I understand it now, message permutations are generated in outer loop and each one is matched against patterns. On Mon, Mar 9, 2009 at 2:08 PM, Hubert Plociniczak < hubert.plociniczak@REDACTED> wrote: > Message {test, test1, test2} is first in the message. foo is second. > Similarly as in original receive I take the newest message and check if > only with this message I can satisfy any of the joins. > If that is not possible, then I go the next message and check if any of the > joins can be satisfied using the new message (and all previous ones). > Since {test, test1, test2} already satisfies one of the joins, then I fire > it immediately and do not look at what else is in the message > after {test, test1, test2} (though I might obviously look at it in the > future, if I have any receive constructs afterwards). > > I hope that helps. > > > > 2009/3/9 Hynek Vychodil > > This test case is not clear for me: >> >> self() ! {test, test1, test2}, >> self() ! foo, >> ok = receive >> _X and foo -> >> error; >> X -> >> {test, _, _} = X, >> ok >> end, >> >> Can you describe more verbosely why first pattern should not match. >> >> 2009/3/9 Hubert Plociniczak >> >>> >>> >>> 2009/3/8 Vlad Dumitrescu >>> >>>> Hi, >>>> >>>> > receive >>>> > {foo, One} and {bar, Two} when (One > Two) -> >>>> > expr.....; >>>> > .... >>>> > end >>>> >>>> Thiss looks interesting, but could you please describe the semantics >>>> of the above example? Does it match for the two messages in sequence, >>>> does one of them have to be the first in queue, is order important? >>>> >>> >>> Let's assume that in the mailbox we have messages(from oldest to newest): >>> [ {foo, 12}, {bar, 2} ] >>> or >>> [ {bar, 2}, {foo, 12} ] >>> Then both will match because I check all the possible permutations. The >>> order is important when we have >>> more Joins and it works in a similar way as standard selective receive, >>> i.e. the first valid permutation will match. >>> >>> Here is an extract from my test cases to give you an idea of what I want >>> to achieve (should be self-explanatory): >>> >>> self() ! foo, >>> self() ! foo, >>> self() ! foo, >>> self() ! foo, >>> ok = receive >>> foo and foo and foo and foo -> >>> ok >>> end, >>> >>> clear_mailbox(), %% purge all messages >>> self() ! {one, 1}, >>> self() ! {two, 3}, >>> Z = 4, >>> A = 1, >>> ok = receive >>> {two, 3} and {one, Z} -> >>> error; >>> {two, 3} and {one, A} -> >>> ok >>> end, >>> self() ! {test, test1, test2}, >>> self() ! foo, >>> ok = receive >>> _X and foo -> >>> error; >>> X -> >>> {test, _, _} = X, >>> ok >>> end, >>> self() ! {test1, 10}, >>> self() ! {test2, 15}, >>> self() ! {test3, 10}, >>> ok = receive >>> {C, X1} and {B, X1} -> >>> try >>> C = test1, >>> B = test3, >>> ok >>> catch >>> error:{badmatch, _} -> >>> C = test3, >>> B = test1, >>> ok >>> end >>> end. >>> >>> I am also working on Operational Semantics for this extended version of >>> Erlang with Joins, but it is still work in progress. >>> >>> Zvi, >>> >>> >nice work. Does it work only inside receive or for any pattern match? >>> >If it's supporting generic pattern matching, I would suggest, rewriting >>> >mochiweb HTML parser, using your join patterns. >>> >>> This is only designed for matching on the messages in the mailbox. >>> >>> hubert >>> >>> >>> >>> >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://www.erlang.org/mailman/listinfo/erlang-questions >>> >> >> >> >> -- >> --Hynek (Pichi) Vychodil >> >> Analyze your data in minutes. Share your insights instantly. Thrill your >> boss. Be a data hero! >> Try Good Data now for free: www.gooddata.com >> > > -- --Hynek (Pichi) Vychodil Analyze your data in minutes. Share your insights instantly. Thrill your boss. Be a data hero! Try Good Data now for free: www.gooddata.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From Philip.Fennell@REDACTED Mon Mar 9 14:25:52 2009 From: Philip.Fennell@REDACTED (Philip Fennell) Date: Mon, 9 Mar 2009 13:25:52 -0000 Subject: [erlang-questions] New O'Reilly blog post about Erlang... Message-ID: I'm sure this is preaching to the converted, as far as this list is concerned, but I've just put-up a new blog post at O'Reilly about Erlang: Although I'm relatively new to Erlang I thought I'd do my bit to spread the word. Regards Philip Fennell http://www.bbc.co.uk/ This e-mail (and any attachments) is confidential and may contain personal views which are not the views of the BBC unless specifically stated. If you have received it in error, please delete it from your system. Do not use, copy or disclose the information in any way nor act in reliance on it and notify the sender immediately. Please note that the BBC monitors e-mails sent or received. Further communication will signify your consent to this. From exta7@REDACTED Mon Mar 9 14:32:28 2009 From: exta7@REDACTED (Zvi) Date: Mon, 9 Mar 2009 06:32:28 -0700 (PDT) Subject: [erlang-questions] New O'Reilly blog post about Erlang... In-Reply-To: References: Message-ID: <22413223.post@talk.nabble.com> the correct link is: http://broadcast.oreilly.com/2009/03/to-err-is-human-to-erlang-divi.html Philip Fennell-2 wrote: > > I'm sure this is preaching to the converted, as far as this list is > concerned, but I've just put-up a new blog post at O'Reilly about > Erlang: > > l> > > Although I'm relatively new to Erlang I thought I'd do my bit to spread > the word. > > > > Regards > > Philip Fennell > > http://www.bbc.co.uk/ > This e-mail (and any attachments) is confidential and may contain personal > views which are not the views of the BBC unless specifically stated. > If you have received it in error, please delete it from your system. > Do not use, copy or disclose the information in any way nor act in > reliance on it and notify the sender immediately. > Please note that the BBC monitors e-mails sent or received. > Further communication will signify your consent to this. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > -- View this message in context: http://www.nabble.com/New-O%27Reilly-blog-post-about-Erlang...-tp22413149p22413223.html Sent from the Erlang Questions mailing list archive at Nabble.com. From steven.charles.davis@REDACTED Mon Mar 9 14:37:57 2009 From: steven.charles.davis@REDACTED (Steve Davis) Date: Mon, 09 Mar 2009 08:37:57 -0500 Subject: [erlang-questions] wxErlang release In-Reply-To: <87y6veetnf.fsf@sterlett.hq.kred> References: <49B0DF37.8060007@gmail.com> <49B0F14C.70301@erix.ericsson.se> <49B0F8BE.6040708@gmail.com> <49B25924.6010308@gmail.com> <90197390-9c4e-4195-90c6-5432535fc3ce@v39g2000yqm.googlegroups.com> <1af2d448-5de4-4533-854a-71aa03241ee5@c11g2000yqj.googlegroups.com> <873adnf1pa.fsf@sterlett.hq.kred> <024a12ea-b62e-4976-aefc-96bfb2d8a573@q18g2000vbn.googlegroups.com> <87y6veetnf.fsf@sterlett.hq.kred> Message-ID: <49B51BB5.6020800@gmail.com> Hi Mats, Do you mean XRC? Yes, making a loader for XRC, XUL, XUI etc as well as the "gxml" I'm working with now should be possible. I have a bit of an issue with specifying element attributes as children which seems to be the current trend, but that won't stop me providing that kind of support when everything else is a bit more stable. regs, /sd mats cronqvist wrote: > Steve Davis writes: > >> Hi Mats, >> >> This experiment with gx/gxml is to see how the ideas of the GS >> interface can be applied to building GUIs in Erlang without having to >> learn the entire and somewhat complex wxErlang API... >> >> ...from what I see wxGlade is a GUI designer (they say specifically >> it's not a builder) and also it runs on Python. I imagine when "gx/ >> gxml" settles down a bit it should be possible (and probably easier) >> to write a GUI designer that can spit out gui definitions as either >> xml or term files from the designer app. The question then I guess is >> should "gxml" really be XUL or XRC... for now it's still very early >> days. > > What I was getting at was that using the same XML form as the one > wxGlade uses also for "gxml" might be a win. IIRC, there is direct > support in wx for that format. > > mats > From Philip.Fennell@REDACTED Mon Mar 9 14:47:59 2009 From: Philip.Fennell@REDACTED (Philip Fennell) Date: Mon, 9 Mar 2009 13:47:59 -0000 Subject: [erlang-questions] FW: New O'Reilly blog post about Erlang... Message-ID: Thanks Zvi. Yes, sorry, my fat fingers! -----Original Message----- From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Zvi Sent: 09 March 2009 13:32 To: erlang-questions@REDACTED Subject: Re: [erlang-questions] New O'Reilly blog post about Erlang... the correct link is: http://broadcast.oreilly.com/2009/03/to-err-is-human-to-erlang-divi.html Philip Fennell-2 wrote: > > I'm sure this is preaching to the converted, as far as this list is > concerned, but I've just put-up a new blog post at O'Reilly about > Erlang: > > tm > l> > > Although I'm relatively new to Erlang I thought I'd do my bit to > spread the word. > > > > Regards > > Philip Fennell > > http://www.bbc.co.uk/ > This e-mail (and any attachments) is confidential and may contain > personal views which are not the views of the BBC unless specifically stated. > If you have received it in error, please delete it from your system. > Do not use, copy or disclose the information in any way nor act in > reliance on it and notify the sender immediately. > Please note that the BBC monitors e-mails sent or received. > Further communication will signify your consent to this. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > -- View this message in context: http://www.nabble.com/New-O%27Reilly-blog-post-about-Erlang...-tp2241314 9p22413223.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 http://www.bbc.co.uk/ This e-mail (and any attachments) is confidential and may contain personal views which are not the views of the BBC unless specifically stated. If you have received it in error, please delete it from your system. Do not use, copy or disclose the information in any way nor act in reliance on it and notify the sender immediately. Please note that the BBC monitors e-mails sent or received. Further communication will signify your consent to this. From masse@REDACTED Mon Mar 9 14:49:29 2009 From: masse@REDACTED (mats cronqvist) Date: Mon, 09 Mar 2009 14:49:29 +0100 Subject: [erlang-questions] wxErlang release In-Reply-To: <49B51BB5.6020800@gmail.com> (Steve Davis's message of "Mon\, 09 Mar 2009 08\:37\:57 -0500") References: <49B0DF37.8060007@gmail.com> <49B0F14C.70301@erix.ericsson.se> <49B0F8BE.6040708@gmail.com> <49B25924.6010308@gmail.com> <90197390-9c4e-4195-90c6-5432535fc3ce@v39g2000yqm.googlegroups.com> <1af2d448-5de4-4533-854a-71aa03241ee5@c11g2000yqj.googlegroups.com> <873adnf1pa.fsf@sterlett.hq.kred> <024a12ea-b62e-4976-aefc-96bfb2d8a573@q18g2000vbn.googlegroups.com> <87y6veetnf.fsf@sterlett.hq.kred> <49B51BB5.6020800@gmail.com> Message-ID: <87tz62erh2.fsf@sterlett.hq.kred> Steve Davis writes: > Hi Mats, > > Do you mean XRC? I do. > Yes, making a loader for XRC, XUL, XUI etc as well as the "gxml" I'm > working with now should be possible. I have a bit of an issue with > specifying element attributes as children which seems to be the > current trend, but that won't stop me providing that kind of support > when everything else is a bit more stable. Sounds excellent. mats From bob@REDACTED Mon Mar 9 15:52:53 2009 From: bob@REDACTED (Bob Ippolito) Date: Mon, 9 Mar 2009 07:52:53 -0700 Subject: [erlang-questions] Is there a http reverse proxy patch for mochiweb or yaws? In-Reply-To: References: Message-ID: <6a36e7290903090752s3bb31ac4o482025567dd1b303@mail.gmail.com> Not that I'm aware of, but you could write one :) 2009/3/9 devdoer bird : > Sorry, I?found ?the reverse proxy for yaws. > > So is there a http proxy patch for mochiweb? :) > > 2009/3/9 devdoer bird >> >> HI: >> >> Is there a? http? reverse proxy patch for mochiweb or yaws ?like mod_proxy >> ,mod_proxy_http in apache? >> >> Thanks. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From devdoer2@REDACTED Mon Mar 9 16:10:14 2009 From: devdoer2@REDACTED (devdoer bird) Date: Mon, 9 Mar 2009 23:10:14 +0800 Subject: [erlang-questions] Is there a http reverse proxy patch for mochiweb or yaws? In-Reply-To: <2a67d3ff0903090509v6176fc18xe6be51f20f96dba@mail.gmail.com> References: <2a67d3ff0903090509v6176fc18xe6be51f20f96dba@mail.gmail.com> Message-ID: So ,where is pound you mentioned? 2009/3/9, G.S. : > > You should use Pound, since if you plan on using reverse proxy, you'll > probably eventually also want to use SSL for https, so might as well move > directly to reverse proxying through pound, feeding it into mochiweb or > yaws. > > 2009/3/9 devdoer bird > >> Sorry, I found the reverse proxy for yaws. >> >> So is there a http proxy patch for mochiweb? :) >> >> >> 2009/3/9 devdoer bird >> >>> HI: >>> >>> Is there a http reverse proxy patch for mochiweb or yaws ?like >>> mod_proxy ,mod_proxy_http in apache? >>> >>> Thanks. >>> >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From devdoer2@REDACTED Mon Mar 9 16:17:39 2009 From: devdoer2@REDACTED (devdoer bird) Date: Mon, 9 Mar 2009 23:17:39 +0800 Subject: [erlang-questions] smart_exceptions doesn't work on R12B Message-ID: HI: Is smart exceptions in jungerl still in developement? I tested it on R12B ,but got a exception. I try to add smart_exceptions when compiling mochiweb_response.erl , but got the exception: mochiweb/mochiweb_response.erl:none: error in parse transform 'smart_exceptions': {function_clause, [{smart_exceptions,forms, [{mochiweb_response, ['Request','Code', 'Headers']}, smart_exit, [{attribute,1,file, {"mochiweb/mochiweb_response.erl", 1}}, {attribute,6,module, {mochiweb_response, ['Request','Code', 'Headers']}}, {attribute,7,author, 'bob@REDACTED'}, {attribute,11,export, [{get_header_value,1}, {get,1}, {dump,0}]}, {attribute,12,export, [{send,1},{write_chunk,1}]}, {function,16, get_header_value,1, ........... So 1. Is the smart_exception still maintained? 2. How can I fix that exception ? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob@REDACTED Mon Mar 9 16:39:29 2009 From: bob@REDACTED (Bob Ippolito) Date: Mon, 9 Mar 2009 08:39:29 -0700 Subject: [erlang-questions] Is there a http reverse proxy patch for mochiweb or yaws? In-Reply-To: References: <2a67d3ff0903090509v6176fc18xe6be51f20f96dba@mail.gmail.com> Message-ID: <6a36e7290903090839k67949d18ibfabe8508a527850@mail.gmail.com> http://lmgtfy.com/?q=pound+proxy&l=1 Nginx is what we use for reverse proxy and load balancing across mochiweb instances. 2009/3/9 devdoer bird : > So ,where is pound you mentioned? > > 2009/3/9, G.S. : >> >> You should use Pound, since if you plan on using reverse proxy, you'll >> probably eventually also want to use SSL for https, so might as well move >> directly to reverse proxying through pound, feeding it into mochiweb or >> yaws. >> >> 2009/3/9 devdoer bird >>> >>> Sorry, I?found ?the reverse proxy for yaws. >>> >>> So is there a http proxy patch for mochiweb? :) >>> >>> >>> 2009/3/9 devdoer bird >>>> >>>> HI: >>>> >>>> Is there a? http? reverse proxy patch for mochiweb or yaws ?like >>>> mod_proxy ,mod_proxy_http in apache? >>>> >>>> Thanks. >>> >>> _______________________________________________ >>> 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 rapsey@REDACTED Mon Mar 9 16:52:36 2009 From: rapsey@REDACTED (Rapsey) Date: Mon, 9 Mar 2009 16:52:36 +0100 Subject: [erlang-questions] Is there a http reverse proxy patch for mochiweb or yaws? In-Reply-To: <6a36e7290903090839k67949d18ibfabe8508a527850@mail.gmail.com> References: <2a67d3ff0903090509v6176fc18xe6be51f20f96dba@mail.gmail.com> <6a36e7290903090839k67949d18ibfabe8508a527850@mail.gmail.com> Message-ID: <97619b170903090852o55deb945w71e89b3651656510@mail.gmail.com> nginx is a much better option and also significantly faster. Sergej On Mon, Mar 9, 2009 at 4:39 PM, Bob Ippolito wrote: > http://lmgtfy.com/?q=pound+proxy&l=1 > > Nginx is what we use for reverse proxy and load balancing across > mochiweb instances. > > 2009/3/9 devdoer bird : > > So ,where is pound you mentioned? > > > > 2009/3/9, G.S. : > >> > >> You should use Pound, since if you plan on using reverse proxy, you'll > >> probably eventually also want to use SSL for https, so might as well > move > >> directly to reverse proxying through pound, feeding it into mochiweb or > >> yaws. > >> > >> 2009/3/9 devdoer bird > >>> > >>> Sorry, I found the reverse proxy for yaws. > >>> > >>> So is there a http proxy patch for mochiweb? :) > >>> > >>> > >>> 2009/3/9 devdoer bird > >>>> > >>>> HI: > >>>> > >>>> Is there a http reverse proxy patch for mochiweb or yaws ?like > >>>> mod_proxy ,mod_proxy_http in apache? > >>>> > >>>> Thanks. > >>> > >>> _______________________________________________ > >>> 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 thomasl_erlang@REDACTED Mon Mar 9 17:17:59 2009 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Mon, 9 Mar 2009 09:17:59 -0700 (PDT) Subject: [erlang-questions] smart_exceptions doesn't work on R12B In-Reply-To: References: Message-ID: <417772.97898.qm@web111409.mail.gq1.yahoo.com> Hi, I think the problem is that you are using parametrized modules, which the current code does not expect. Sorry. Development: The jungerl version of smart_exceptions is being phased out but is "stable", in the sense that it has been unchanged for a long time and works as well, or as badly, as ever. The new repo is on github, though that version should be considered "experimental". It should be an improvement on the old version when finished, because it uses try instead of catch and has been simplified, but is basically untested at this time. (NB: you can also find the stable jungerl code there, currently under src/r9-src/*) http://github.com/thomasl/smart_exceptions/tree/master Best, Thomas ________________________________ From: devdoer bird To: erlang-questions@REDACTED Sent: Monday, March 9, 2009 4:17:39 PM Subject: [erlang-questions] smart_exceptions doesn't work on R12B HI: Is smart exceptions in jungerl still in developement? I tested it on R12B ,but got a exception. I try to add smart_exceptions when compiling mochiweb_response.erl , but got the exception: mochiweb/mochiweb_response.erl:none: error in parse transform 'smart_exceptions': {function_clause, [{smart_exceptions,forms, [{mochiweb_response, ['Request','Code', 'Headers']}, smart_exit, [{attribute,1,file, {"mochiweb/mochiweb_response.erl", 1}}, {attribute,6,module, {mochiweb_response, ['Request','Code', 'Headers']}}, {attribute,7,author, 'bob@REDACTED'}, {attribute,11,export, [{get_header_value,1}, {get,1}, {dump,0}]}, {attribute,12,export, [{send,1},{write_chunk,1}]}, {function,16, get_header_value,1, ........... So 1. Is the smart_exception still maintained? 2. How can I fix that exception ? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From Sebastien.Boisgerault@REDACTED Fri Mar 6 16:16:43 2009 From: Sebastien.Boisgerault@REDACTED (=?ISO-8859-1?Q?S=E9bastien_Boisg=E9rault?=) Date: Fri, 06 Mar 2009 16:16:43 +0100 Subject: [erlang-questions] Empty Atoms. Message-ID: <49B13E5B.4050209@ensmp.fr> Hi, AFAICT, empty atoms are allowed in erlang, right ? Is there any specific reason to disallow empty atoms in JInterface ? Cheers, SB From devdoer2@REDACTED Mon Mar 9 18:06:06 2009 From: devdoer2@REDACTED (devdoer bird) Date: Tue, 10 Mar 2009 01:06:06 +0800 Subject: [erlang-questions] smart_exceptions doesn't work on R12B In-Reply-To: <417772.97898.qm@web111409.mail.gq1.yahoo.com> References: <417772.97898.qm@web111409.mail.gq1.yahoo.com> Message-ID: Thanks. Is support for parametrized module in your developement schedule? 2009/3/10, Thomas Lindgren : > > Hi, I think the problem is that you are using parametrized modules, which > the current code does not expect. Sorry. > > > Development: The jungerl version of smart_exceptions is being phased out > but is "stable", in the sense that it has been unchanged for a long time and > works as well, or as badly, as ever. The new repo is on github, though that > version should be considered "experimental". It should be an improvement on > the old version when finished, because it uses try instead of catch and has > been simplified, but is basically untested at this time. (NB: you can also > find the stable jungerl code there, currently under src/r9-src/*) > > > http://github.com/thomasl/smart_exceptions/tree/master > > > Best, > Thomas > > ------------------------------ > *From:* devdoer bird > *To:* erlang-questions@REDACTED > *Sent:* Monday, March 9, 2009 4:17:39 PM > *Subject:* [erlang-questions] smart_exceptions doesn't work on R12B > > HI: > > Is smart exceptions in jungerl still in developement? I tested it on R12B > ,but got a exception. > I try to add smart_exceptions when compiling mochiweb_response.erl , but > got the exception: > mochiweb/mochiweb_response.erl:none: error in parse transform > 'smart_exceptions': {function_clause, > [{smart_exceptions,forms, > [{mochiweb_response, > ['Request','Code', > 'Headers']}, > smart_exit, > [{attribute,1,file, > > {"mochiweb/mochiweb_response.erl", > 1}}, > {attribute,6,module, > {mochiweb_response, > ['Request','Code', > 'Headers']}}, > {attribute,7,author, > 'bob@REDACTED'}, > {attribute,11,export, > [{get_header_value,1}, > {get,1}, > {dump,0}]}, > {attribute,12,export, > > [{send,1},{write_chunk,1}]}, > {function,16, > get_header_value,1, > ........... > > So > 1. Is the smart_exception still maintained? > 2. How can I fix that exception ? > > Thanks > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From thomasl_erlang@REDACTED Mon Mar 9 18:27:01 2009 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Mon, 9 Mar 2009 10:27:01 -0700 (PDT) Subject: [erlang-questions] smart_exceptions doesn't work on R12B In-Reply-To: References: <417772.97898.qm@web111409.mail.gq1.yahoo.com> Message-ID: <393308.41052.qm@web111416.mail.gq1.yahoo.com> Parametrized modules: Not at present, but it should be. Do note that progress is slow at the moment, so to patch the problem, you could try just removing the check 'atom(M)' on line 250 in smart_exceptions.erl and see if that helps. (It might or might not.) Best, Thomas ________________________________ From: devdoer bird To: Thomas Lindgren Cc: erlang-questions@REDACTED Sent: Monday, March 9, 2009 6:06:06 PM Subject: Re: [erlang-questions] smart_exceptions doesn't work on R12B Thanks. Is support for parametrized module in your developement schedule? -------------- next part -------------- An HTML attachment was scrubbed... URL: From tony@REDACTED Mon Mar 9 18:58:11 2009 From: tony@REDACTED (Tony Arcieri) Date: Mon, 9 Mar 2009 11:58:11 -0600 Subject: [erlang-questions] smart_exceptions doesn't work on R12B In-Reply-To: <417772.97898.qm@web111409.mail.gq1.yahoo.com> References: <417772.97898.qm@web111409.mail.gq1.yahoo.com> Message-ID: 2009/3/9 Thomas Lindgren > Development: The jungerl version of smart_exceptions is being phased out > but is "stable", in the sense that it has been unchanged for a long time and > works as well, or as badly, as ever. The new repo is on github, though that > version should be considered "experimental". It should be an improvement on > the old version when finished, because it uses try instead of catch and has > been simplified, but is basically untested at this time. (NB: you can also > find the stable jungerl code there, currently under src/r9-src/*) > > http://github.com/thomasl/smart_exceptions/tree/master > Really glad to see you're continuing work on this. I'm a big fan and started following it on github. -- Tony Arcieri -------------- next part -------------- An HTML attachment was scrubbed... URL: From florian.ebeling@REDACTED Mon Mar 9 22:04:13 2009 From: florian.ebeling@REDACTED (C. Florian Ebeling) Date: Mon, 9 Mar 2009 22:04:13 +0100 Subject: [erlang-questions] [ANN] Berlin Erlounge this Wednesday, Mar. 11 2009, 20:00 Message-ID: <5cbbe4ae0903091404t231e9010ua637133134b05411@mail.gmail.com> Hi, just a quick note about the Berlin Erlounge [1] this Wednesday, Mar. 11 2009, 20:00. Stefan Plantikow (Scalaris project, Twitter: @boggle) will talk about Scala and it's concurrency. The event will take place at the co-working space Box119 [2]. Join us for this promising talk and maybe a beer / ClubMate afterwards in one of the cosy Friedrichshain venues closeby! Florian [1] http://groups.google.com/group/erlang-berlin/browse_thread/thread/19443e5127613977 [2] http://boxhagener119.de/ -- Florian Ebeling Twitter: febeling florian.ebeling@REDACTED From ok@REDACTED Tue Mar 10 00:28:32 2009 From: ok@REDACTED (Richard O'Keefe) Date: Tue, 10 Mar 2009 12:28:32 +1300 Subject: [erlang-questions] examples for erlang with joins In-Reply-To: <22409049.post@talk.nabble.com> References: <310adeca0903071753x4caf9f4dta2f2d1e4509d666@mail.gmail.com> <22397309.post@talk.nabble.com> <22409049.post@talk.nabble.com> Message-ID: <19B7F806-7584-4E90-9366-6E7872402954@cs.otago.ac.nz> On 9 Mar 2009, at 9:40 pm, Zvi wrote: > > actualy I simplified my example from mochiweb. When I wrote the > message was > thinking about this: > > tokenize_script(Bin, S=#decoder{offset=O}, Start) -> > case Bin of > %% Just a look-ahead, we want the end_tag separately > <<_:O/binary, $<, $/, SS, CC, RR, II, PP, TT, _/binary>> > when (SS =:= $s orelse SS =:= $S) andalso > (CC =:= $c orelse CC =:= $C) andalso > (RR =:= $r orelse RR =:= $R) andalso > (II =:= $i orelse II =:= $I) andalso > (PP =:= $p orelse PP =:= $P) andalso > (TT=:= $t orelse TT =:= $T) -> ... > > i.e. match ignoring case " > <<_:O/binary, $<, $/, $s^$S, $c^$C, $r^$R, $i^$I, $p^$P, $t^$T, _/ > binary>> Please, _please_ do not use ^ to mean "or". We already have four ways to say "or" in Erlang (;, or, orelse, bor). We do not need a fifth. The problem before us is "recognise an HTML end-tag in a binary". An end-tag for "script" has the form "" using POSIX regular expression syntax. The most natural way to express this would be something like Script_End = "^", case eep9:match(Bin, Script_End, {O, byte_size(Bin)}) of 0 -> ...not matched... ; _ -> ...matched... end and then we could start worrying about some kind of parse transform to precompile the regular expression. We had a mail thread on disjunctive patterns, was it last year? Note that disjunctive patterns don't quite meet the need here. What if there is a "" end-tag? A really robust check does need to look for 0 or more white space characters followed by ">", and disjunctive patterns don't help with that. They are certainly a very heavy sledgehammer to crack the nut of either-case matching. (With reference to the title of this thread, this is an example of a pattern with "or" in it. Joins are all about patterns with "and".) > > In my code I usualy just convert everyting to lower case before > matching, > but this is less efficient. Is it? Have you measured it? Take this example again: case Bin of <<_:O/binary, $<, $/, S, C, R, I, P, T, _/binary>> when (S bor 32) =:= $s, (C bor 32) =:= $c, (R bor 32) =:= $r, (I bor 32) =:= $i, (P bor 32) =:= $p, (T bor 32) =:= $t -> ... I suspect this is faster than the version full of orelses; it is certainly shorter. Maybe a macro: -define(LC(X), ((X) bor 32)). % Use this only when X is known to be a Latin-1 cased % letter or is about to be tested for being one. case Bin of <<_:O/binary, $<, $/, S, C, R, I, P, T, _/binary>> when ?LC(S) =:= $s, ?LC(C) =:= $c, ?LC(R) =:= $r, ?LC(I) =:= $i, ?LC(P) =:= $p, ?LC(T) =:= $t -> ... Right now, without 'andalso' and 'orelse', that's probably about as good as the match is going to get, and it's not _too_ horrible to write. I haven't actually been able to compare the code, because the first version crashes erlc. Pleasantly, my simplified version does not. From ok@REDACTED Tue Mar 10 00:40:31 2009 From: ok@REDACTED (Richard O'Keefe) Date: Tue, 10 Mar 2009 12:40:31 +1300 Subject: [erlang-questions] examples for erlang with joins In-Reply-To: <310adeca0903090608q275c2f87oc1a8f8e52f42909a@mail.gmail.com> References: <310adeca0903071753x4caf9f4dta2f2d1e4509d666@mail.gmail.com> <95be1d3b0903080342l758af6bdx4bc85da986a08927@mail.gmail.com> <310adeca0903081851g58ad9f18wc3cf86aa2cdfd09c@mail.gmail.com> <4d08db370903090600g5c9d6ddckaf4df52016dfd734@mail.gmail.com> <310adeca0903090608q275c2f87oc1a8f8e52f42909a@mail.gmail.com> Message-ID: On 10 Mar 2009, at 2:08 am, Hubert Plociniczak wrote: > Message {test, test1, test2} is first in the message. foo is second. > Similarly as in original receive I take the newest message and check > if only with this message I can satisfy any of the joins. > If that is not possible, then I go the next message and check if any > of the joins can be satisfied using the new message (and all > previous ones). > Since {test, test1, test2} already satisfies one of the joins, then > I fire it immediately and do not look at what else is in the message > after {test, test1, test2} (though I might obviously look at it in > the future, if I have any receive constructs afterwards). > > I hope that helps. Actually, it helps to scare me off. It reminds me too much of XSLT. For one thing, the current receive construct (conceptually) always starts its search with the *OLDEST* message, not the newest one. So we have in the mailbox oldest = {test,test1,test2} newest = foo and in the matching process, the first thing we hit is _X and foo and _X does match the first message that we should look at (namely the oldest) and foo does then match the remaining message. From hubert.plociniczak@REDACTED Tue Mar 10 01:54:45 2009 From: hubert.plociniczak@REDACTED (Hubert Plociniczak) Date: Tue, 10 Mar 2009 00:54:45 +0000 Subject: [erlang-questions] examples for erlang with joins In-Reply-To: References: <310adeca0903071753x4caf9f4dta2f2d1e4509d666@mail.gmail.com> <95be1d3b0903080342l758af6bdx4bc85da986a08927@mail.gmail.com> <310adeca0903081851g58ad9f18wc3cf86aa2cdfd09c@mail.gmail.com> <4d08db370903090600g5c9d6ddckaf4df52016dfd734@mail.gmail.com> <310adeca0903090608q275c2f87oc1a8f8e52f42909a@mail.gmail.com> Message-ID: <310adeca0903091754h296562d2v7c3b85ab4a0b2835@mail.gmail.com> 2009/3/9 Richard O'Keefe > > On 10 Mar 2009, at 2:08 am, Hubert Plociniczak wrote: > > Message {test, test1, test2} is first in the message. foo is second. >> Similarly as in original receive I take the newest message and check if >> only with this message I can satisfy any of the joins. >> If that is not possible, then I go the next message and check if any of >> the joins can be satisfied using the new message (and all previous ones). >> Since {test, test1, test2} already satisfies one of the joins, then I fire >> it immediately and do not look at what else is in the message >> after {test, test1, test2} (though I might obviously look at it in the >> future, if I have any receive constructs afterwards). >> >> I hope that helps. >> > > Actually, it helps to scare me off. > It reminds me too much of XSLT. > For one thing, the current receive construct (conceptually) > always starts its search with the *OLDEST* message, not the > newest one. > > So we have in the mailbox > oldest = {test,test1,test2} > newest = foo > and in the matching process, the first thing we hit is > _X and foo > and _X does match the first message that we should look > at (namely the oldest) and foo does then match the > remaining message. > Ok, I agree I named newest for the oldest. When explaining I always get the naming the other way around ;) To satisfy the join I am trying to find the smallest, oldest set of messages in the mailbox. When designing the joins I took the same approach as receive, i.e. it takes the message and consecutively matches it against patterns, step by step. If it doesn't find any pattern that satisfied the message, then it moves to the next message and repeats. I didn't want to change this logic, because the other way would mean to have a look at *some* (possibly big) snapshot of the mailbox and check if the first patterns is satisfied. If not, then check another one etc. But then what happens when new messages arrive? There is no way to ensure (without limiting the size of the snapshot) that previous pattern (or in my case join) was not satisfied, as some new message that arrived in the meantime could satisfy it. This particular case is tricky, so thanks for pointing that out. But I think it still is correct, because in reality, without joins, it is the second case (namely _X) that would get satisfied (not _X and foo) - if you were to hard-code it using for example nested receives. hubert -------------- next part -------------- An HTML attachment was scrubbed... URL: From ok@REDACTED Tue Mar 10 02:55:23 2009 From: ok@REDACTED (Richard O'Keefe) Date: Tue, 10 Mar 2009 14:55:23 +1300 Subject: [erlang-questions] examples for erlang with joins In-Reply-To: <310adeca0903091754h296562d2v7c3b85ab4a0b2835@mail.gmail.com> References: <310adeca0903071753x4caf9f4dta2f2d1e4509d666@mail.gmail.com> <95be1d3b0903080342l758af6bdx4bc85da986a08927@mail.gmail.com> <310adeca0903081851g58ad9f18wc3cf86aa2cdfd09c@mail.gmail.com> <4d08db370903090600g5c9d6ddckaf4df52016dfd734@mail.gmail.com> <310adeca0903090608q275c2f87oc1a8f8e52f42909a@mail.gmail.com> <310adeca0903091754h296562d2v7c3b85ab4a0b2835@mail.gmail.com> Message-ID: <7C3DFD25-D16F-41DB-80C1-C8C0755870AE@cs.otago.ac.nz> On 10 Mar 2009, at 1:54 pm, Hubert Plociniczak wrote: leaving me more confused than before. There are all sorts of ways that one can approach something like this. Let me start by conceding that YES this increases the expressive power of Erlang receives and YES this increase may be very welcome for some problems and YES the Erlang canon is not closed, new ideas must not be rejected just because they are new (or because someone else thought of them) and YES the fact of an implementation with test cases creates a strong presumption in favour of the new feature. What worries me is that it depends on an intricate and as yet somewhat vaguely admubrated *procedural* semantics and that it somehow seems to run contrary to some basic assumptions about message passing in Erlang. Where's Joe Armstrong when you need him? Let me address the "basic assumptions" point. Message passing in Erlang is modelled on message passing in physical distributed systems. This is necessary because at least _some_ Erlang message passing really _is_ passing messages over physical communication channels between physically separated systems. So - messages may fail to arrive at all - messages from different sources may arrive out of order - message transport times from different processes may differ by several orders of magnitude. All of that makes something that relies on looking for messages from more than one process somewhat problematic. If process A sends a message to C before process B does, the messages could arrive in the order (A,B) or the order (B,A). It follows, does it not, that the matching process for receive P and Q ... must be just as willing to match P=newer, Q=older as to match P=older, Q=newer, and that such an "all ways around" match must be completed before looking at the next clause. So it's not just because it would be too hard to understand that (receive P and Q...) and (receive Q and P...) must have indistinguishable behaviour. However, if process A sends messages X then Y to process C, it -is- guaranteed that (if both arrive) X will arrive before Y. The messages in a mail box are ordered, and this ordering is consistent with the partial order of events. This means that Erlang's "try each message in turn from oldest to newest until one matches and then commit to that" does make some kind of sense. If A sent first X and then Y, and if either X or Y would match, then Y cannot overtake X. It appears to me that in the presence of join-receive, this is no longer true. Suppose we have oldest [Z, X, Y] newest and we have receive P and Q -> ping ; R -> pong end where P matches Z, Q matches Y, and R matches X. In this example, the oldest message of all is indeed chosen, but the *newer* message Y overtakes the *older* message X. But if the message queue were oldest [X, Z, Y] newest then X would have been chosen. So whether Y overtakes X or not depends on the relative order in which Z (from another process) was received, and that's not at all well defined. There's nothing much an implementation can do about this, because messages in a mailbox are not tagged with the pid of the originating process. Sometimes we *want* a newer (urgent) message to overtake an older (routine) message. Priority messages are one of the things that's often been asked for, and while we _can_ program that, it's not as immediate as PRI ALT in Occam. But even then, we don't want it to _maybe_ overtake or _maybe_ not. We already have people worried about the cost of scanning the mailbox. It's difficult to see how join-receive won't make this worse, at least not without elaborate indexing machinery like the RETE algorithm. (Such machinery might be merited _anyway_. That's another argument.) I would like to hear a lot more about the use cases for this proposal. From devdoer2@REDACTED Tue Mar 10 03:23:19 2009 From: devdoer2@REDACTED (devdoer bird) Date: Tue, 10 Mar 2009 10:23:19 +0800 Subject: [erlang-questions] smart_exceptions doesn't work on R12B In-Reply-To: <393308.41052.qm@web111416.mail.gq1.yahoo.com> References: <417772.97898.qm@web111409.mail.gq1.yahoo.com> <393308.41052.qm@web111416.mail.gq1.yahoo.com> Message-ID: Thanks. 2009/3/10 Thomas Lindgren > Parametrized modules: Not at present, but it should be. Do note that > progress is slow at the moment, so to patch the problem, you could try just > removing the check 'atom(M)' on line 250 in smart_exceptions.erl and see if > that helps. (It might or might not.) > > Best, > Thomas > > ------------------------------ > *From:* devdoer bird > *To:* Thomas Lindgren > *Cc:* erlang-questions@REDACTED > *Sent:* Monday, March 9, 2009 6:06:06 PM > *Subject:* Re: [erlang-questions] smart_exceptions doesn't work on R12B > > Thanks for your great work. Hope you continue working on it. > > Is support for parametrized module in your developement schedule? > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From devdoer2@REDACTED Tue Mar 10 03:23:41 2009 From: devdoer2@REDACTED (devdoer bird) Date: Tue, 10 Mar 2009 10:23:41 +0800 Subject: [erlang-questions] smart_exceptions doesn't work on R12B In-Reply-To: References: <417772.97898.qm@web111409.mail.gq1.yahoo.com> <393308.41052.qm@web111416.mail.gq1.yahoo.com> Message-ID: Thanks for your great work. Hope you continue working on it. > > > 2009/3/10 Thomas Lindgren > >> Parametrized modules: Not at present, but it should be. Do note that >> progress is slow at the moment, so to patch the problem, you could try just >> removing the check 'atom(M)' on line 250 in smart_exceptions.erl and see if >> that helps. (It might or might not.) >> >> Best, >> Thomas >> >> ------------------------------ >> *From:* devdoer bird >> *To:* Thomas Lindgren >> *Cc:* erlang-questions@REDACTED >> *Sent:* Monday, March 9, 2009 6:06:06 PM >> *Subject:* Re: [erlang-questions] smart_exceptions doesn't work on R12B >> >> >> >> Is support for parametrized module in your developement schedule? >> >> >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mjtruog@REDACTED Tue Mar 10 06:50:15 2009 From: mjtruog@REDACTED (Michael Truog) Date: Mon, 09 Mar 2009 22:50:15 -0700 Subject: [erlang-questions] Generating skeleton linked-in driver code using an IDL? In-Reply-To: <878wnjdo4g.fsf@sej.hq.kred> References: <49B0B9BB.40107@gmail.com> <878wnjdo4g.fsf@sej.hq.kred> Message-ID: <49B5FF97.9000603@gmail.com> Torbjorn Tornkvist wrote: > Michael Truog writes: > > >> Jani Hakala wrote: >> >>> ... >>> >>> I have looked at some of the code generation tools that are supposed >>> to help developing linked-in drivers. They (ETDK, DryvErl and the >>> proposed Foreign Function Interface) seem to focus on how to call >>> C-functions. I would be more interested about a tool that could be >>> used to define message structures and operations supported by a >>> linked-in driver. Those operations would call C/C++ functions in a way >>> that would not be visible outside the driver (facade pattern). >>> >>> ... >>> >> I created the Generic Erlang Port Driver to have an easy way to >> automatically generate a port driver or port for C or C++. The code >> generation does not rely on an idl file but instead uses >> boost::preprocess to use macros. The code is still in development, but >> should provide another way of creating port drivers automatically. The >> port drivers are generated only with usage of outputv, for efficiency. >> The message structure is determined from basic types passed with the >> native byte order. A facade pattern could easily be added as an >> interface to the port driver. You can find the code here: >> >> http://forum.trapexit.org/viewtopic.php?p=44406#44406 >> > > I think 'gepd' should live as a nice little project of its own (e.g at > github.com). > > --Tobbe > (Ps. it reminds me about old IG (may it rest in peace): > http://www.tornkvist.org/gitweb?p=ig.git;a=summary ) > My hope is that gepd can be: - An efficient and easy way to integrate between Erlang and C/C++ - Reusable code that supports hot code swapping for port drivers and ports So, I want gepd to do more than just generate interfaces, but grow to be generic integration code for any C and C++ code. The github address is: http://github.com/okeuday/generic-erlang-port--driver-/tree/master - Michael From raimo+erlang-questions@REDACTED Tue Mar 10 10:09:13 2009 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Tue, 10 Mar 2009 10:09:13 +0100 Subject: [erlang-questions] Empty Atoms. In-Reply-To: <49B13E5B.4050209@ensmp.fr> References: <49B13E5B.4050209@ensmp.fr> Message-ID: <20090310090913.GA16121@erix.ericsson.se> On Fri, Mar 06, 2009 at 04:16:43PM +0100, S?bastien Boisg?rault wrote: > > Hi, > > AFAICT, empty atoms are allowed in erlang, right ? > Is there any specific reason to disallow empty atoms in JInterface ? Nope. It is probably an oversight or overprotection from the original author of Jinterface. Non-proper lists were not allowed either but will be in R13. Jinterface is supposed to handle whatever Erlang can. Thank you for pointing this out. If anyone finds other discrepances please let us know. > > Cheers, > > SB > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From jpalley@REDACTED Tue Mar 10 11:35:15 2009 From: jpalley@REDACTED (Jonathan Palley) Date: Tue, 10 Mar 2009 18:35:15 +0800 Subject: [erlang-questions] OTP Design Pattern Question/gen_server with different parameters? Message-ID: <2d8777c00903100335r61a96059x8fc32980b0b534d0@mail.gmail.com> All - I've got this running in straight Erlang, but trying to understand how to apply to the OTP pattern. Wondering the best practice for a system like this: event comes in (external source) -> various event handlers get sent the event based on the event type. -> these event handlers will filter the event to determine if they should send it on (via an http request). The trick is this: there is an interface to add and delete event handlers with a filter. In straight erlang I: - Created a new process for each handler. The handler would be init with the filters. - A central event processor stored the PID of each handler and the event type it was subscribed to. As an event would come in it would re-broadcast to the different handlers. - Each handler would then use its custom filter to determine whether to send it on. Now, I would like all the robustness that comes with OTP. Perhaps I am approaching this incorrectly, but what I can't figure out is: - If I start multiple instances of gen_event (with different filters each) and add it to a supervisor tree, there doesn't seem to be a way to identify the one handler I want to delete (if I want to remove the handler) - If I create only one gen_event for each event type and make the event_handlers be gen_server, I run into a similar problem (how do I call all the gen_servers that I want). Thanks for any ideas! JP -------------- next part -------------- An HTML attachment was scrubbed... URL: From andreas.hillqvist@REDACTED Tue Mar 10 14:37:00 2009 From: andreas.hillqvist@REDACTED (Andreas Hillqvist) Date: Tue, 10 Mar 2009 14:37:00 +0100 Subject: [erlang-questions] clarify: Erlang eXchange London - June 2009 Message-ID: <8268eea30903100637i2a7d030cm84e5c2a54a650760@mail.gmail.com> Hi! Will there be an Erlang eXchange in London - June 2009 as stated on http://www.erlang-exchange.com? Erlang eXchange London - June 2009 The next Erlang eXchange in London will be held in June 2009. More information will follow soon, but if you would like us to keep you up to date, please sign up for our mailing list, and we'll send you monthly updates. It's time for me to plan my vacation time and it would help to know at least which week Erlang eXchange will be held in London. Kind regards Andreas Hillqvist P.S. What did you think about the Erlang eXchange last year, you who attend? Will you who attend this years Erlang eXchange? If not, why not? Because the economy? D.S. From franco.milicchio@REDACTED Tue Mar 10 15:56:23 2009 From: franco.milicchio@REDACTED (Franco Milicchio) Date: Tue, 10 Mar 2009 15:56:23 +0100 Subject: [erlang-questions] Second order function lists:map Message-ID: <4499200B-3ADF-49E1-BE6D-BA9A9FEAE457@gmail.com> Hi everyone! I am trying to write two small functions employing the lists package, and now I am wondering how to proceed. My functions are quite straightforward: I want two second-order functions that "abstract" lists:map. The first one is a function that applies a given function to a list of arguments. So, a first application gives me a function, and this applied to a list gives me the mapping of my function over the list. I have succeeded in doing this function and it seems to work: paa(F) -> fun(L) -> lists:map(F, L) end. 41> PP=p:paa(fun math:sin/1). #Fun 42> PP(lists:seq(0,100)). [0.0,0.8414709848078965,0.9092974268256817, 0.1411200080598672,-0.7568024953079282,-0.9589242746631385, -0.27941549819892586,0.6569865987187891,0.9893582466233818, 0.4121184852417566,-0.5440211108893699,-0.9999902065507035, -0.5365729180004349,0.4201670368266409,0.9906073556948704, 0.6502878401571169,-0.2879033166650653,-0.9613974918795568, -0.750987246771676,0.14987720966295234,0.9129452507276277, 0.836655638536056,-0.008851309290403876,-0.8462204041751706, -0.9055783620066239,-0.13235175009777303,0.7625584504796028, 0.956375928404503,0.27090578830786904|...] The second one is tricky to me (I am not an erlang guru!). I want its "dual", so given a list of functions, I'd like to map them to a single argument, writing a second-order function like the above p:paa/1. The only problem is that I am stopped by this problem, I know it's easy but I am not that good at functional programming :) Thanks for any help! -- Franco Milicchio DIA - Dept. of Computer Science and Engineering University Roma Tre http://plm.dia.uniroma3.it/milicchio/ -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2435 bytes Desc: not available URL: From franco.milicchio@REDACTED Tue Mar 10 16:44:57 2009 From: franco.milicchio@REDACTED (Franco Milicchio) Date: Tue, 10 Mar 2009 16:44:57 +0100 Subject: [erlang-questions] Second order function lists:map In-Reply-To: <49B6863F.2080409@savageminds.com> References: <4499200B-3ADF-49E1-BE6D-BA9A9FEAE457@gmail.com> <49B6863F.2080409@savageminds.com> Message-ID: <84B0849A-B39A-47F3-B8C1-F93F093770A3@gmail.com> On Mar 10, 2009, at 4:24pm, Rob Charlton wrote: > Is this what you are after? > > paa(A) -> > fun(L) -> > lists:map(fun(F)-> > F(A) > end, L) > end. > > 7> G = test:paa(42). > #Fun > 8> G([fun math:sin/1, fun math:cos/1, fun math:tan/1]). > [-0.916522,-0.399985,2.29139] > Rob, thanks for your answer! Actually, I was looking for the other way around: G = test:paa([fun math:sin/1, fun math:cos/1, fun math:tan/1]). G(0.5). Thanks! -- Franco Milicchio DIA - Dept. of Computer Science and Engineering University Roma Tre http://plm.dia.uniroma3.it/milicchio/ -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2435 bytes Desc: not available URL: From koops.j@REDACTED Tue Mar 10 16:54:30 2009 From: koops.j@REDACTED (Jeroen Koops) Date: Tue, 10 Mar 2009 16:54:30 +0100 Subject: [erlang-questions] Second order function lists:map In-Reply-To: <84B0849A-B39A-47F3-B8C1-F93F093770A3@gmail.com> References: <4499200B-3ADF-49E1-BE6D-BA9A9FEAE457@gmail.com> <49B6863F.2080409@savageminds.com> <84B0849A-B39A-47F3-B8C1-F93F093770A3@gmail.com> Message-ID: <331a9abb0903100854m24c631cavd2587d709a3093cb@mail.gmail.com> paa(Funs) -> fun(X) -> [ Fun(X) || Fun <- Funs] end. ?? 2009/3/10 Franco Milicchio > > On Mar 10, 2009, at 4:24pm, Rob Charlton wrote: > > Is this what you are after? >> >> paa(A) -> >> fun(L) -> >> lists:map(fun(F)-> >> F(A) >> end, L) >> end. >> >> 7> G = test:paa(42). >> #Fun >> 8> G([fun math:sin/1, fun math:cos/1, fun math:tan/1]). >> [-0.916522,-0.399985,2.29139] >> >> > > Rob, thanks for your answer! > > Actually, I was looking for the other way around: > > G = test:paa([fun math:sin/1, fun math:cos/1, fun math:tan/1]). > > G(0.5). > > > Thanks! > > -- > Franco Milicchio > > DIA - Dept. of Computer Science and Engineering > University Roma Tre > http://plm.dia.uniroma3.it/milicchio/ > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From franco.milicchio@REDACTED Tue Mar 10 17:03:00 2009 From: franco.milicchio@REDACTED (Franco Milicchio) Date: Tue, 10 Mar 2009 17:03:00 +0100 Subject: [erlang-questions] Second order function lists:map In-Reply-To: <84B0849A-B39A-47F3-B8C1-F93F093770A3@gmail.com> References: <4499200B-3ADF-49E1-BE6D-BA9A9FEAE457@gmail.com> <49B6863F.2080409@savageminds.com> <84B0849A-B39A-47F3-B8C1-F93F093770A3@gmail.com> Message-ID: On Mar 10, 2009, at 4:44pm, Franco Milicchio wrote: > > On Mar 10, 2009, at 4:24pm, Rob Charlton wrote: > >> Is this what you are after? >> >> paa(A) -> >> fun(L) -> >> lists:map(fun(F)-> >> F(A) >> end, L) >> end. >> >> 7> G = test:paa(42). >> #Fun >> 8> G([fun math:sin/1, fun math:cos/1, fun math:tan/1]). >> [-0.916522,-0.399985,2.29139] >> Rob, what do you think of this solution? paa(L) -> fun(X) -> lists:map(fun(F)->apply(F, [X]) end, L) end. Thanks for your pointers! -- Franco Milicchio DIA - Dept. of Computer Science and Engineering University Roma Tre http://plm.dia.uniroma3.it/milicchio/ -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2435 bytes Desc: not available URL: From rob.charlton@REDACTED Tue Mar 10 16:24:47 2009 From: rob.charlton@REDACTED (Rob Charlton) Date: Tue, 10 Mar 2009 15:24:47 +0000 Subject: [erlang-questions] Second order function lists:map In-Reply-To: <4499200B-3ADF-49E1-BE6D-BA9A9FEAE457@gmail.com> References: <4499200B-3ADF-49E1-BE6D-BA9A9FEAE457@gmail.com> Message-ID: <49B6863F.2080409@savageminds.com> Is this what you are after? paa(A) -> fun(L) -> lists:map(fun(F)-> F(A) end, L) end. 7> G = test:paa(42). #Fun 8> G([fun math:sin/1, fun math:cos/1, fun math:tan/1]). [-0.916522,-0.399985,2.29139] Cheers Rob Franco Milicchio wrote: > Hi everyone! > > I am trying to write two small functions employing the lists package, > and now I am wondering how to proceed. My functions are quite > straightforward: I want two second-order functions that "abstract" > lists:map. > > The first one is a function that applies a given function to a list of > arguments. So, a first application gives me a function, and this > applied to a list gives me the mapping of my function over the list. I > have succeeded in doing this function and it seems to work: > > paa(F) -> > fun(L) -> > lists:map(F, L) > end. > > 41> PP=p:paa(fun math:sin/1). > #Fun > > 42> PP(lists:seq(0,100)). > [0.0,0.8414709848078965,0.9092974268256817, > 0.1411200080598672,-0.7568024953079282,-0.9589242746631385, > -0.27941549819892586,0.6569865987187891,0.9893582466233818, > 0.4121184852417566,-0.5440211108893699,-0.9999902065507035, > -0.5365729180004349,0.4201670368266409,0.9906073556948704, > 0.6502878401571169,-0.2879033166650653,-0.9613974918795568, > -0.750987246771676,0.14987720966295234,0.9129452507276277, > 0.836655638536056,-0.008851309290403876,-0.8462204041751706, > -0.9055783620066239,-0.13235175009777303,0.7625584504796028, > 0.956375928404503,0.27090578830786904|...] > > > The second one is tricky to me (I am not an erlang guru!). I want its > "dual", so given a list of functions, I'd like to map them to a single > argument, writing a second-order function like the above p:paa/1. The > only problem is that I am stopped by this problem, I know it's easy > but I am not that good at functional programming :) > > Thanks for any help! > > > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- Rob Charlton Savage Minds Ltd From ulf.wiger@REDACTED Tue Mar 10 18:22:50 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Tue, 10 Mar 2009 18:22:50 +0100 Subject: [erlang-questions] clarify: Erlang eXchange London - June 2009 In-Reply-To: <8268eea30903100637i2a7d030cm84e5c2a54a650760@mail.gmail.com> References: <8268eea30903100637i2a7d030cm84e5c2a54a650760@mail.gmail.com> Message-ID: <49B6A1EA.80200@erlang-consulting.com> Andreas Hillqvist wrote: > Hi! > > Will there be an Erlang eXchange in London - June 2009 as stated on > http://www.erlang-exchange.com? > Erlang eXchange London - June 2009 > The next Erlang eXchange in London will be held in June 2009. > More information will follow soon, but if you would like us to > keep you up to date, > please sign up for our mailing list, and we'll send you monthly updates. > > It's time for me to plan my vacation time and it would help to know at > least which week Erlang eXchange will be held in London. Hi, The Erlang Exchange will be replaced by the Erlang Factory, and the dates for the London conference are: University: June 22nd - June 24th Conference: June 25th - June 26th Keep watching http://www.erlang-factory.com The details for the London conference will come up in a few days. Meanwhile, you can perhaps explore the details of the Bay Area Erlang Factory April 30 - May 1. BR, Ulf W -- Ulf Wiger CTO, Erlang Training & Consulting Ltd http://www.erlang-consulting.com From rob.charlton@REDACTED Tue Mar 10 17:46:19 2009 From: rob.charlton@REDACTED (Rob Charlton) Date: Tue, 10 Mar 2009 16:46:19 +0000 Subject: [erlang-questions] Second order function lists:map In-Reply-To: References: <4499200B-3ADF-49E1-BE6D-BA9A9FEAE457@gmail.com> <49B6863F.2080409@savageminds.com> <84B0849A-B39A-47F3-B8C1-F93F093770A3@gmail.com> Message-ID: <49B6995B.5030705@savageminds.com> Hi Franco, Well you could either swap the function parameters in my first answer (paa(L) -> fun(A) ->...) or you could go with Jeroen's solution using list comprehensions - which is arguably more elegant. Calling apply(F,[X]) is equivalent to F(X), but your solution below looks fine to me. Cheers Rob Franco Milicchio wrote: > Rob, what do you think of this solution? > > paa(L) -> > fun(X) -> > lists:map(fun(F)->apply(F, [X]) end, L) > end. > > > Thanks for your pointers! > > > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- Rob Charlton Savage Minds Ltd From francesco@REDACTED Tue Mar 10 18:47:24 2009 From: francesco@REDACTED (Francesco Cesarini (Erlang Training and Consulting)) Date: Tue, 10 Mar 2009 17:47:24 +0000 Subject: [erlang-questions] clarify: Erlang eXchange London - June 2009 In-Reply-To: <49B6A1EA.80200@erlang-consulting.com> References: <8268eea30903100637i2a7d030cm84e5c2a54a650760@mail.gmail.com> <49B6A1EA.80200@erlang-consulting.com> Message-ID: <49B6A7AC.7010401@erlang-consulting.com> We are working in the speaker list for London right now, and should open the pages with the preliminary talks by Friday. We will also have a section for talk proposals. Subscribe to the Erlang Factory mailing list to get weekly updates or the RSS feed on the site. We expect to have as many tracks as in Palo Alto, where we currently have 37 speakers from SAP, Nokia, Facebook, EA, Engine Yard and many other start-ups which one day will become the new blue chip companies, open source and research projects, all sharing 34 talks in 6 tracks. Robert Virding will have the keynote. All in all, even better and louder that last year's Erlang eXchange. A reminder that the early bird registration deadline to get the discounted fee is this Sunday, March 15th. You can register online at https://www.erlang-factory.com/conference/SFBayAreaErlangFactory2009/register Francesco Ulf Wiger wrote: > Andreas Hillqvist wrote: > >> Hi! >> >> Will there be an Erlang eXchange in London - June 2009 as stated on >> http://www.erlang-exchange.com? >> Erlang eXchange London - June 2009 >> The next Erlang eXchange in London will be held in June 2009. >> More information will follow soon, but if you would like us to >> keep you up to date, >> please sign up for our mailing list, and we'll send you monthly updates. >> >> It's time for me to plan my vacation time and it would help to know at >> least which week Erlang eXchange will be held in London. >> > > Hi, > > The Erlang Exchange will be replaced by the Erlang Factory, > and the dates for the London conference are: > > University: June 22nd - June 24th > Conference: June 25th - June 26th > > Keep watching http://www.erlang-factory.com > > The details for the London conference will come up in > a few days. Meanwhile, you can perhaps explore the > details of the Bay Area Erlang Factory April 30 - May 1. > > BR, > Ulf W > From daniel.goertzen@REDACTED Tue Mar 10 18:51:06 2009 From: daniel.goertzen@REDACTED (Daniel Goertzen) Date: Tue, 10 Mar 2009 12:51:06 -0500 Subject: [erlang-questions] OTP Design Pattern Question/gen_server with different parameters? In-Reply-To: <2d8777c00903100335r61a96059x8fc32980b0b534d0@mail.gmail.com> References: <2d8777c00903100335r61a96059x8fc32980b0b534d0@mail.gmail.com> Message-ID: I wonder if you are throwing too many processes and servers at the problem. Can the solution be implemented by plain old functions within a single process? Dan. 2009/3/10 Jonathan Palley > All - I've got this running in straight Erlang, but trying to understand > how to apply to the OTP pattern. > > Wondering the best practice for a system like this: > > > event comes in (external source) -> various event handlers get sent the > event based on the event type. -> these event handlers will filter the event > to determine if they should send it on (via an http request). > > The trick is this: there is an interface to add and delete event handlers > with a filter. > > In straight erlang I: > - Created a new process for each handler. The handler would be init with > the filters. > - A central event processor stored the PID of each handler and the event > type it was subscribed to. As an event would come in it would re-broadcast > to the different handlers. > - Each handler would then use its custom filter to determine whether to > send it on. > > > Now, I would like all the robustness that comes with OTP. Perhaps I am > approaching this incorrectly, but what I can't figure out is: > > - If I start multiple instances of gen_event (with different filters each) > and add it to a supervisor tree, there doesn't seem to be a way to identify > the one handler I want to delete (if I want to remove the handler) > - If I create only one gen_event for each event type and make the > event_handlers be gen_server, I run into a similar problem (how do I call > all the gen_servers that I want). > > Thanks for any ideas! > JP > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- Daniel Goertzen ----------------- work email: dang@REDACTED work phone: 1 443 303 8525 work sip: 945050@REDACTED ----------------- mobile: 1 204 470 8360 ----------------- home email: daniel.goertzen@REDACTED home phone: 1 204 272 6149 -------------- next part -------------- An HTML attachment was scrubbed... URL: From jahakala@REDACTED Mon Mar 9 17:32:02 2009 From: jahakala@REDACTED (Jani Hakala) Date: Mon, 09 Mar 2009 18:32:02 +0200 Subject: [erlang-questions] Generating skeleton linked-in driver code using an IDL? In-Reply-To: <49B0B9BB.40107@gmail.com> (Michael Truog's message of "Thu\, 05 Mar 2009 21\:50\:51 -0800") References: <49B0B9BB.40107@gmail.com> Message-ID: <87bpsairnh.fsf@pingviini.kortex.jyu.fi> Michael Truog writes: > I created the Generic Erlang Port Driver to have an easy way to > automatically generate a port driver or port for C or C++. The code > generation does not rely on an idl file but instead uses > boost::preprocess to use macros. The code is still in development, but > should provide another way of creating port drivers automatically. The > port drivers are generated only with usage of outputv, for efficiency. > The message structure is determined from basic types passed with the > native byte order. A facade pattern could easily be added as an > interface to the port driver. You can find the code here: > Are there any examples that demonstrate how to pass other than simple data types (like a C struct converted to an equivalent tuple) between erlang and driver (both directions)? Jani Hakala From xmlarchitect@REDACTED Tue Mar 10 23:39:34 2009 From: xmlarchitect@REDACTED (=Bill.Barnhill) Date: Tue, 10 Mar 2009 18:39:34 -0400 Subject: [erlang-questions] Request for help on creating BIF (or finding existing one) Message-ID: Hello all, I was recently asked how to have a process get its registered name. AFAIK there is no BIF for this. It can be accomplished via: [ N || N <- global:registered_names(), global:whereis_name(N) == self()] which will either return [] if it's not registered or [Name] if it is. A BIF along the lines of name() that returned the name would avoid the overhead of cycling through the process list in the above code. Roberto Ostinelli added that returning {global|local, Name} would be good, not sure how to do that. To that end I've started trying to put together a function to do that, but I don't have my head around the Erlang sources yet so I'd appreciate help on the following: 1) Is there a BIF already that does this? 2) Is this the correct way? 3) How do I return an Eterm value of 'none'? 4) How do I hook the function in as a BIF? 5) How would I make it so it returns {local|global, Name} instead of just Name? What I've got so far is: 1. Eterm erts_thr_self_name(void) { 2. struct process * self_info = erts_get_current_process(); 3. struct reg_proc * self_reg_info = self_info->reg; 4. if (self_reg_info != NULL) { /* ie if we're actually registered */ 5. Eterm name = self_reg_info->name; 6. return name; 7. } 8. else { 9. return /* Where to find 'none' Eterm value?? */ 10. } 11. } For convenience it's also at pastebin: http://pastebin.com/m2e5816e6 Any help much appreciated, =Bill.Barnhill -------------- next part -------------- An HTML attachment was scrubbed... URL: From ok@REDACTED Tue Mar 10 23:42:40 2009 From: ok@REDACTED (Richard O'Keefe) Date: Wed, 11 Mar 2009 11:42:40 +1300 Subject: [erlang-questions] Second order function lists:map In-Reply-To: <4499200B-3ADF-49E1-BE6D-BA9A9FEAE457@gmail.com> References: <4499200B-3ADF-49E1-BE6D-BA9A9FEAE457@gmail.com> Message-ID: <0FE278CB-1AA3-4ADD-B4B2-72233D914EEB@cs.otago.ac.nz> On 11 Mar 2009, at 3:56 am, Franco Milicchio wrote: > The second one is tricky to me (I am not an erlang guru!). I want > its "dual", so given a list of functions, I'd like to map them to a > single argument, writing a second-order function like the above > p:paa/1. The only problem is that I am stopped by this problem, I > know it's easy but I am not that good at functional programming :) 1. map(F, L) -> [F(X) | X <- L]. paa(F) -> fun (L) -> map(F, L) end. 2. pam(L, X) -> [F(X) | F <- L]. aap(L) -> fun (X) -> pam(L, X) end. See the parallels? From ulf.wiger@REDACTED Wed Mar 11 00:15:57 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Wed, 11 Mar 2009 00:15:57 +0100 Subject: [erlang-questions] Request for help on creating BIF (or finding existing one) In-Reply-To: References: Message-ID: <49B6F4AD.7020809@erlang-consulting.com> =Bill.Barnhill wrote: > > I was recently asked how to have a process get its registered name. > AFAIK there is no BIF for this. It can be accomplished via: > [ N || N <- global:registered_names(), global:whereis_name(N) == self()] > which will either return [] if it's not registered or [Name] if it is. Here's a way to do it without BIFs, and with some peeking in global's innards: names(Pid) when is_pid(Pid) -> Global = [{global,G} || {_, G} <- ets:lookup(global_pid_names, Pid)], case process_info(Pid, registered_name) of {registered_name, N} -> [{local, N}|Global]; [] -> Global end. BR, Ulf W -- Ulf Wiger CTO, Erlang Training & Consulting Ltd http://www.erlang-consulting.com From cayle.spandon@REDACTED Wed Mar 11 02:38:20 2009 From: cayle.spandon@REDACTED (Cayle Spandon) Date: Tue, 10 Mar 2009 21:38:20 -0400 Subject: [erlang-questions] erlang:trace: "bus error" and "failed to lock mutex". Message-ID: <71c13900903101838n25e754e6nc37c4308e38eda0e@mail.gmail.com> I was experimenting with erlang:trace and ran into some unexpected behavior. I got a "bus error" and a "failed to lock mutex". I have never used trace and I really don't (yet) know how it works, so maybe what I did does not make any sense. But still, it seems that Erlang crashing with a "bus error" or a "failed to lock mutex" is not the appropriate response no matter what I do. ~> erl Erlang (BEAM) emulator version 5.6.1 [source] [smp:2] [async-threads:0] [kernel-poll:false] Eshell V5.6.1 (abort with ^G) 1> 1> 1> erlang:trace(all,true,[all]). Bus error ~> erl Erlang (BEAM) emulator version 5.6.1 [source] [smp:2] [async-threads:0] [kernel-poll:false] Eshell V5.6.1 (abort with ^G) 1> erlang:trace(new,true,[all]). 0 2> Failed to lock mutex: Invalid argument (22) Abort trap -------------- next part -------------- An HTML attachment was scrubbed... URL: From gijsbert_de_haan@REDACTED Wed Mar 11 03:55:29 2009 From: gijsbert_de_haan@REDACTED (Gijsbert de Haan) Date: Tue, 10 Mar 2009 22:55:29 -0400 Subject: [erlang-questions] why call code:purge(Module) twice? Message-ID: <1236740129.15222.1304745449@webmail.messagingengine.com> Hi, To get started with my Erlang server I've scavenged some code from erlyvideo. So far it has been very helpful, but I am a bit confused about this code reload function: reload() -> reload([mod1,mod2,mod3]). reload(Module) when is_atom(Module) -> code:purge(Module), code:delete(Module), code:load_file(Module), true; reload([]) -> ok; reload([?MODULE | T]) -> reload(T); reload([H|T]) -> reload(H), reload(H), reload(T). It reloads the list of modules that make up my server. What I don't understand is why it calls reload(Module) twice. If I understand the Erlang documentation correctly calling code:purge() twice will kill all running erlang processes, making it pretty much a cold code start. What would be a reason to do this? I can imagine that sometimes old processes wouldn't be able to cope with processes running new code, in which a clean start would be needed. But in that case a graceful stop and start would be nicer. Cheers, Gijsbert From bbmaj7@REDACTED Wed Mar 11 05:55:43 2009 From: bbmaj7@REDACTED (Richard Andrews) Date: Tue, 10 Mar 2009 21:55:43 -0700 (PDT) Subject: [erlang-questions] why call code:purge(Module) twice? In-Reply-To: <1236740129.15222.1304745449@webmail.messagingengine.com> References: <1236740129.15222.1304745449@webmail.messagingengine.com> Message-ID: <128615.10765.qm@web65510.mail.ac4.yahoo.com> ----- Original Message ---- > reload() -> > reload([mod1,mod2,mod3]). > reload(Module) when is_atom(Module) -> > code:purge(Module), > code:delete(Module), > code:load_file(Module), > true; > reload([]) -> ok; > reload([?MODULE | T]) -> reload(T); > reload([H|T]) -> > reload(H), > reload(H), > reload(T). > > It reloads the list of modules that make up my server. What I don't > understand is why it calls reload(Module) twice. > If I understand the Erlang documentation correctly calling code:purge() > twice will kill all running erlang processes, making it pretty much a > cold code start. > What would be a reason to do this? I can imagine that sometimes old > processes wouldn't be able to cope with processes running new code, in > which a clean start would be needed. But in that case a graceful stop > and start would be nicer. It's not so much about purging twice, but loading twice. My understanding is that purge+load will load in the new code and any old version will go to the "old" space. Doing another purge+load will cause the originally running code to be dropped by the VM entirely ("old" is now the result of the first code:load_file) and so any processes using the original code will be forced to exit instead of continuing with "old" code. -- Rich Stay connected to the people that matter most with a smarter inbox. Take a look http://au.docs.yahoo.com/mail/smarterinbox From bgustavsson@REDACTED Wed Mar 11 08:44:16 2009 From: bgustavsson@REDACTED (Bjorn Gustavsson) Date: Wed, 11 Mar 2009 08:44:16 +0100 Subject: [erlang-questions] erlang:trace: "bus error" and "failed to lock mutex". In-Reply-To: <71c13900903101838n25e754e6nc37c4308e38eda0e@mail.gmail.com> References: <71c13900903101838n25e754e6nc37c4308e38eda0e@mail.gmail.com> Message-ID: <6672d0160903110044n51f07858w2042642797a04cd7@mail.gmail.com> 2009/3/11 Cayle Spandon : > I was experimenting with erlang:trace and ran into some unexpected behavior. > I got a "bus error" and a "failed to lock mutex". > > I have never used trace and I really don't (yet) know how it works, so maybe > what I did does not make any sense. But still, it seems that Erlang crashing > with a "bus error" or a "failed to lock mutex" is not the appropriate > response no matter what I do. You are right, of course. But you are using a very old version of Erlang/OTP. You should upgrade to R12B-5. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From xmlarchitect@REDACTED Wed Mar 11 12:07:03 2009 From: xmlarchitect@REDACTED (=Bill.Barnhill) Date: Wed, 11 Mar 2009 07:07:03 -0400 Subject: [erlang-questions] Request for help on creating BIF (or finding existing one) In-Reply-To: <49B6F4AD.7020809@erlang-consulting.com> References: <49B6F4AD.7020809@erlang-consulting.com> Message-ID: Thanks, the func you sent is interesting, and that solves the global|local issue (which seems to be a 'global and local', not 'global or local'). Given the process_info func, then is the C code I wrote the same as process_info(self(), registered_name)? Thanks, =Bill.Barnhill On Tue, Mar 10, 2009 at 7:15 PM, Ulf Wiger wrote: > =Bill.Barnhill wrote: > >> >> I was recently asked how to have a process get its registered name. AFAIK >> there is no BIF for this. It can be accomplished via: >> [ N || N <- global:registered_names(), global:whereis_name(N) == self()] >> which will either return [] if it's not registered or [Name] if it is. >> > > Here's a way to do it without BIFs, and with some peeking in > global's innards: > > names(Pid) when is_pid(Pid) -> > Global = [{global,G} || > {_, G} <- ets:lookup(global_pid_names, Pid)], > case process_info(Pid, registered_name) of > {registered_name, N} -> > [{local, N}|Global]; > [] -> > Global > end. > > > BR, > Ulf W > > > -- > Ulf Wiger > CTO, Erlang Training & Consulting Ltd > http://www.erlang-consulting.com > -------------- next part -------------- An HTML attachment was scrubbed... URL: From cayle.spandon@REDACTED Wed Mar 11 16:19:53 2009 From: cayle.spandon@REDACTED (Cayle Spandon) Date: Wed, 11 Mar 2009 11:19:53 -0400 Subject: [erlang-questions] Non-blocking sends in gen_tcp? Message-ID: <71c13900903110819v42fe2f85k85ed5361433f13fa@mail.gmail.com> Does gen_tcp provide a mechanism for non-blocking sends, similar to the traditional send and select/poll calls in Unix, in the following sense: -1- When you call gen_tcp:send() with N bytes and flow-control kicks in, gen_tcp:send()returns immediately (i.e. does not block, not even for some small time-out). The return value indicates that flow-control was invoked and gives some indication of what subset of bytes was accepted (e.g. by returning the remaining unsent binary). This is similar to Unix send() returning EAGAIN. -2- Some mechanism to inform the sending process that the socket is ready to send more data, e.g. an Erlang message. This is similar to Unix select() reporting that a socket is ready-to-send. I have considered the option of creating an Erlang process dedicated to sending messages over the socket and using blocking gen_tcp:send calls in that process. For various reasons (related to the fact that a send may have to be interruped by some other activity) this is not an option for me. I found some references to the prim_inet module on Google, but evidently that is not an officially documented module. PS - My apologies if this question has already been answered. I googled the topic and found many discussions but not quite the answer. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ville.silventoinen@REDACTED Wed Mar 11 17:43:49 2009 From: ville.silventoinen@REDACTED (Ville Silventoinen) Date: Wed, 11 Mar 2009 16:43:49 +0000 Subject: [erlang-questions] Request for enhancement: lchown Message-ID: <4f0695950903110943t537a875djc56b318a535e9c14@mail.gmail.com> Hi, I apologise if I'm asking on the wrong mailing list, I'm not sure what the protocol is (should I submit an EEP?). If possible, it would be great to have "write_link_info" in some future release. As far as I know, there is no way to set the owner of a symbolic link (write_file_info follows the symlink). I took a look at the otp_src_R12B-5 sources, it looks like this could be implemented in emulator/drivers/unix/unix_efile.c with a similar function to "efile_write_info", except that it would call lchown instead of chown. Thanks, Ville -------------- next part -------------- An HTML attachment was scrubbed... URL: From jebenitez@REDACTED Wed Mar 11 19:51:34 2009 From: jebenitez@REDACTED (Jose Enrique Benitez Jimenez) Date: Wed, 11 Mar 2009 14:51:34 -0400 Subject: [erlang-questions] eldap badmach Message-ID: hello everyone, I am try to use eldap but I get an error, I donwload these files form internet, eldap.erl eldap.hrl ELDAPv3.hrl ELDAPv3.asn README.example so i compile eldap.erl and get eldap.beam, in the shell i write: 7> {R,S1}=eldap:open(["10.0.0.3"],[]). {ok,<0.41.0>} 8> eldap:simple_bind(S1,"UID=sAMAccountName, CU=ad.search@REDACTED, DC=uci,DC=cu",uF2SODWAHiK0eJboFFQLAvVzJ). {error, {'EXIT', {{badmatch, {'EXIT', {undef, [{'ELDAPv3',encode, ['LDAPMessage', {'LDAPMessage',1, {bindRequest, {'BindRequest',3, "UID=sAMAccountName, CU=ad.search@REDACTED, DC=uci,DC=cu", {simple,uF2SODWAHiK0eJboFFQLAvVzJ}}}, asn1_NOVALUE}]}, {asn1rt,encode,3}, {eldap,send_request,4}, {eldap,request,4}, {eldap,exec_simple_bind,1}, {eldap,do_the_simple_bind,3}, {eldap,loop,2}]}}}, [{eldap,send_request,4}, {eldap,request,4}, {eldap,exec_simple_bind,1}, {eldap,do_the_simple_bind,3}, {eldap,loop,2}]}}} I dont know what does it mean, there are something wrong with the eldap module or my ldap configuration, this is very important for my thesis. Thanks a lot. From erlangy@REDACTED Wed Mar 11 20:16:54 2009 From: erlangy@REDACTED (Michael McDaniel) Date: Wed, 11 Mar 2009 12:16:54 -0700 Subject: [erlang-questions] eldap badmach In-Reply-To: References: Message-ID: <20090311191654.GR22018@delora.autosys.us> Looks like the arguments to eldap:simple_bind/3 are incorrect. I have used simple_bind with a dn = "o=bund, c=de" Try the simple_bind like eldap:simple_bind( S1, "o=uci, c=cu", uF2SODWAHiK0eJboFFQLAvVzJ ). ~M On Wed, Mar 11, 2009 at 02:51:34PM -0400, Jose Enrique Benitez Jimenez wrote: > hello everyone, > > I am try to use eldap but I get an error, I donwload these files form internet, > eldap.erl > eldap.hrl > ELDAPv3.hrl > ELDAPv3.asn > README.example > > so i compile eldap.erl and get eldap.beam, in the shell i write: > 7> {R,S1}=eldap:open(["10.0.0.3"],[]). > {ok,<0.41.0>} > 8> eldap:simple_bind(S1,"UID=sAMAccountName, CU=ad.search@REDACTED, DC=uci,DC=cu",uF2SODWAHiK0eJboFFQLAvVzJ). > {error, > {'EXIT', > {{badmatch, > {'EXIT', > {undef, > [{'ELDAPv3',encode, > ['LDAPMessage', > {'LDAPMessage',1, > {bindRequest, > {'BindRequest',3, > "UID=sAMAccountName, CU=ad.search@REDACTED, DC=uci,DC=cu", > {simple,uF2SODWAHiK0eJboFFQLAvVzJ}}}, > asn1_NOVALUE}]}, > {asn1rt,encode,3}, > {eldap,send_request,4}, > {eldap,request,4}, > {eldap,exec_simple_bind,1}, > {eldap,do_the_simple_bind,3}, > {eldap,loop,2}]}}}, > [{eldap,send_request,4}, > {eldap,request,4}, > {eldap,exec_simple_bind,1}, > {eldap,do_the_simple_bind,3}, > {eldap,loop,2}]}}} > I dont know what does it mean, there are something wrong with the eldap module or my ldap configuration, this is very important for my thesis. > Thanks a lot. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- Michael McDaniel Portland, Oregon, USA http://trip.autosys.us http://autosys.us http://mmcdaniel.com/erlview From baryluk@REDACTED Wed Mar 11 20:51:50 2009 From: baryluk@REDACTED (Witold Baryluk) Date: Wed, 11 Mar 2009 20:51:50 +0100 Subject: [erlang-questions] The red line in appmon In-Reply-To: References: Message-ID: <20090311195150.GA24554@smp.if.uj.edu.pl> On 03-09 20:06, fei wang wrote: > When I start mnesia, and use the appmon to see the process tree of it, I > saw a red line between the mnesia_event and another process. > Can anybody tell me what does this line mean? This link, created explicitly using link/1. If one of process will die second will receive 'EXIT' message (is trap_exit is set), or die (if not set). Processes can be unlinked using unlink/1. Mnesia is probably using it for transactions. -- Witold Baryluk JID: witold.baryluk // jabster.pl -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 197 bytes Desc: Digital signature URL: From vik@REDACTED Wed Mar 11 21:37:01 2009 From: vik@REDACTED (Vik Olliver) Date: Thu, 12 Mar 2009 09:37:01 +1300 Subject: [erlang-questions] Erlide experiences Message-ID: <49B820ED.6060508@catalyst.net.nz> It's worth a go. I fired up the latest Erlide and noticed that it couldn't open original declarations and crashed when I tried re-formatting. I left it for a couple of days, tried again, this time it worked beautifully. I dunno if this is a "first time" bug, but Erlide is worth persisting with if you experienced initial issues. Vik :v) From baryluk@REDACTED Wed Mar 11 21:39:29 2009 From: baryluk@REDACTED (Witold Baryluk) Date: Wed, 11 Mar 2009 21:39:29 +0100 Subject: [erlang-questions] Non-blocking sends in gen_tcp? In-Reply-To: <71c13900903110819v42fe2f85k85ed5361433f13fa@mail.gmail.com> References: <71c13900903110819v42fe2f85k85ed5361433f13fa@mail.gmail.com> Message-ID: <20090311203929.GA24991@smp.if.uj.edu.pl> On 03-11 11:19, Cayle Spandon wrote: > Does gen_tcp provide a mechanism for non-blocking sends, similar to the > traditional send and select/poll calls in Unix, in the following sense: > > -1- When you call gen_tcp:send() with N bytes and flow-control kicks in, > gen_tcp:send()returns immediately (i.e. does not block, not even for some > small time-out). The return value indicates that flow-control was invoked > and gives some indication of what subset of bytes was accepted (e.g. by > returning the remaining unsent binary). This is similar to Unix send() > returning EAGAIN. > > -2- Some mechanism to inform the sending process that the socket is ready to > send more data, e.g. an Erlang message. This is similar to Unix select() > reporting that a socket is ready-to-send. > > I have considered the option of creating an Erlang process dedicated to > sending messages over the socket and using blocking gen_tcp:send calls in > that process. For various reasons (related to the fact that a send may have > to be interruped by some other activity) this is not an option for me. > > I found some references to the prim_inet module on Google, but evidently > that is not an officially documented module. I'm currently using some magic functions from prim_inet directly, for asynchrounous recv and send. I will much more happy if this functions (like async_accept, async_read, port_command) will be officially supported and documented. Or better way for handling it should be presented. -- Witold Baryluk JID: witold.baryluk // jabster.pl -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 197 bytes Desc: Digital signature URL: From vladdu55@REDACTED Wed Mar 11 21:44:10 2009 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Wed, 11 Mar 2009 21:44:10 +0100 Subject: [erlang-questions] Erlide experiences In-Reply-To: <49B820ED.6060508@catalyst.net.nz> References: <49B820ED.6060508@catalyst.net.nz> Message-ID: <95be1d3b0903111344t78be02e7gf66919c7a3725fcb@mail.gmail.com> On Wed, Mar 11, 2009 at 21:37, Vik Olliver wrote: > It's worth a go. I fired up the latest Erlide and noticed that it > couldn't open original declarations and crashed when I tried re-formatting. > I left it for a couple of days, tried again, this time it worked > beautifully. I dunno if this is a "first time" bug, but Erlide is worth > persisting with if you experienced initial issues. Thanks! If you experience problems again, please go to window->erlang->report problems, create a report and send it to me. Also please note that the 0.5.1 releases are on the bleeding edge and sometimes they really earn that name :-) best regards, Vlad From mcpherson@REDACTED Wed Mar 11 23:31:55 2009 From: mcpherson@REDACTED (Allen McPherson) Date: Wed, 11 Mar 2009 16:31:55 -0600 Subject: [erlang-questions] A tad confused about function parameters Message-ID: <33052B61-455E-474A-B1D9-011AB07FDEE2@lanl.gov> Here's a snippet of code that I'm using: %% Once nodes have been started we launch the code to execute the %% benchmarks. launch(L) -> launch(L, []). launch([], Pids) -> Pids; launch([H|T], Pids) -> S = self(), % loop(self(), start) would evaluate self() inside loop() function launch(T, lists:append(Pids, [spawn(H, fun() -> loop(S, start) end)])). %% Main benchmark loop. Receives request for particular type of test. %% Spawns code to handle benchmark on its local node. loop(MasterPid, Mode) -> ... The line in question is: S = self(), -----> launch(T, lists:append(Pids, [spawn(H, fun() -> loop(S, start) end)])). I find that if I use: launch(T, lists:append(Pids, [spawn(H, fun() -> loop(self(), start) end)])). instead, self() is evaluated everywhere in loop() that MasterPid occurs. Intuitively I sort of get it, by formally I don't really understand what's going on here...why the delayed evaluation? I would think it would be evaluate before the spawn, but it's getting evaluated after the spawn on node 'H'. Probably another dumb question, but can someone shed some light this. It seems like a fundamental concept to understand. -- Al From tobbe@REDACTED Wed Mar 11 23:50:31 2009 From: tobbe@REDACTED (Torbjorn Tornkvist) Date: Wed, 11 Mar 2009 23:50:31 +0100 Subject: [erlang-questions] eldap badmach In-Reply-To: References: Message-ID: Jose Enrique Benitez Jimenez wrote: > hello everyone, > > I am try to use eldap but I get an error, I donwload these files form internet, > eldap.erl > eldap.hrl > ELDAPv3.hrl > ELDAPv3.asn > README.example > > so i compile eldap.erl and get eldap.beam, in the shell i write: Hm...have you compiled *all* the files? I suggest you download the code from github. 1. git clone git://github.com/etnt/eldap.git 2. cd eldap 3. make You should see something like this: -------------------------------- # make (cd src;make) make[1]: Entering directory `/home/tobbe/git/eldap/src' erlc ELDAPv3.asn Erlang ASN.1 version "1.6.2" compiling "/home/tobbe/git/eldap/src/ELDAPv3.asn" Compiler Options: [ber,report_errors, {cwd,"/home/tobbe/git/eldap/src"}, {outdir,"/home/tobbe/git/eldap/src"}, {i,"."}, {i,"/home/tobbe/git/eldap/src"}] --{generated,"/home/tobbe/git/eldap/src/ELDAPv3.asn1db"}-- --{generated,"/home/tobbe/git/eldap/src/ELDAPv3.hrl"}-- --{generated,"/home/tobbe/git/eldap/src/ELDAPv3.erl"}-- ok mv ELDAPv3.beam ../ebin erlc -I ./src -I ../include +debug_info -o ../ebin eldap.erl ./eldap.erl:411: Warning: variable 'From' is unused ./eldap.erl:764: Warning: function log1/3 is unused ./eldap.erl:883: Warning: variable 'Rest' is unused make[1]: Leaving directory `/home/tobbe/git/eldap/src' ----------------------- Look at the doc/README.example. Is it still not working ? --Tobbe > 7> {R,S1}=eldap:open(["10.0.0.3"],[]). > {ok,<0.41.0>} > 8> eldap:simple_bind(S1,"UID=sAMAccountName, CU=ad.search@REDACTED, DC=uci,DC=cu",uF2SODWAHiK0eJboFFQLAvVzJ). > {error, > {'EXIT', > {{badmatch, > {'EXIT', > {undef, > [{'ELDAPv3',encode, > ['LDAPMessage', > {'LDAPMessage',1, > {bindRequest, > {'BindRequest',3, > "UID=sAMAccountName, CU=ad.search@REDACTED, DC=uci,DC=cu", > {simple,uF2SODWAHiK0eJboFFQLAvVzJ}}}, > asn1_NOVALUE}]}, > {asn1rt,encode,3}, > {eldap,send_request,4}, > {eldap,request,4}, > {eldap,exec_simple_bind,1}, > {eldap,do_the_simple_bind,3}, > {eldap,loop,2}]}}}, > [{eldap,send_request,4}, > {eldap,request,4}, > {eldap,exec_simple_bind,1}, > {eldap,do_the_simple_bind,3}, > {eldap,loop,2}]}}} > I dont know what does it mean, there are something wrong with the eldap module or my ldap configuration, this is very important for my thesis. > Thanks a lot. From masse@REDACTED Thu Mar 12 00:01:07 2009 From: masse@REDACTED (masse@REDACTED) Date: Thu, 12 Mar 2009 00:01:07 +0100 Subject: [erlang-questions] Paul Graham uses Erlang to solve scaling problems!!! Message-ID: <878wnbpsuk.fsf@dixie.cronqvi.st> yes it's true; Paul Graham, lisp evangelist and IT millionaire, is using the awesome powers of Erlang to solve the scaling issues of Hacker News, his reddit clone. Read and rejoice! Or something. mats http://news.ycombinator.com/item?id=512145 Why HN is slow lately We've had a huge spike in traffic lately, from roughly 24k daily uniques to 33k. This is a result of being mentioned on more mainstream sites. I hope this spike will subside, like past ones have. In the meantime I may temporarily hack a few things to make the site faster, like putting fewer results on threads pages. You can help the spike subside by making HN look extra boring. For the next couple days it would be better to have posts about the innards of Erlang than women who create sites to get hired by Twitter. From vychodil.hynek@REDACTED Thu Mar 12 00:31:18 2009 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Thu, 12 Mar 2009 00:31:18 +0100 Subject: [erlang-questions] A tad confused about function parameters In-Reply-To: <33052B61-455E-474A-B1D9-011AB07FDEE2@lanl.gov> References: <33052B61-455E-474A-B1D9-011AB07FDEE2@lanl.gov> Message-ID: <4d08db370903111631s53fc421cga01816fa4ce3f743@mail.gmail.com> On Wed, Mar 11, 2009 at 11:31 PM, Allen McPherson wrote: > Here's a snippet of code that I'm using: > > %% Once nodes have been started we launch the code to execute the > %% benchmarks. > launch(L) -> > launch(L, []). > launch([], Pids) -> > Pids; > launch([H|T], Pids) -> > S = self(), % loop(self(), start) would evaluate > self() inside loop() function > launch(T, lists:append(Pids, [spawn(H, fun() -> loop(S, start) > end)])). > > %% Main benchmark loop. Receives request for particular type of test. > %% Spawns code to handle benchmark on its local node. > loop(MasterPid, Mode) -> > ... > > > The line in question is: > S = self(), > -----> launch(T, lists:append(Pids, [spawn(H, fun() -> loop(S, > start) end)])). > > I find that if I use: > > launch(T, lists:append(Pids, [spawn(H, fun() -> > loop(self(), start) end)])). You can read fun() -> loop(self(), start) end as make function which do loop(self(), start) and evaluate it in new process. It means self() is evaluated in this process not in master process. It not means that self() is evaluated in loop/2 but outside it even inside it's process which cause trouble. You can rewrite it using list comprehension launch(L)-> S=self(), [ spawn(N, fun()->loop(S, start) end) || N<-L ]. or in tail call manner (lists:append/2 or ++ is not often used especially in loop where first parameter is growing) launch(L) -> launch(L, []). launch([], Pids)->lists:reverse(Pids); % or just Pids if doesn't care Pids order launch([H|T], Pids)-> S=self(), launch(T, [pawn(N, fun()->loop(S, start) end)|Pids]). It's common idiom in Erlang ot avoid lists:append/2 misuse. > > instead, self() is evaluated everywhere in loop() that MasterPid occurs. > Intuitively I sort of get it, by formally I don't really understand > what's going on here...why the delayed evaluation? I would think it > would be > evaluate before the spawn, but it's getting evaluated after the spawn > on node > 'H'. > > Probably another dumb question, but can someone shed some light this. > It seems like a fundamental concept to understand. > > -- > Al > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- --Hynek (Pichi) Vychodil Analyze your data in minutes. Share your insights instantly. Thrill your boss. Be a data hero! Try Good Data now for free: www.gooddata.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From bbmaj7@REDACTED Thu Mar 12 00:43:43 2009 From: bbmaj7@REDACTED (Richard Andrews) Date: Wed, 11 Mar 2009 16:43:43 -0700 (PDT) Subject: [erlang-questions] A tad confused about function parameters In-Reply-To: <33052B61-455E-474A-B1D9-011AB07FDEE2@lanl.gov> References: <33052B61-455E-474A-B1D9-011AB07FDEE2@lanl.gov> Message-ID: <425131.67193.qm@web65515.mail.ac4.yahoo.com> > The line in question is: > S = self(), > -----> launch(T, lists:append(Pids, [spawn(H, fun() -> loop(S, > start) end)])). > > I find that if I use: > > launch(T, lists:append(Pids, [spawn(H, fun() -> > loop(self(), start) end)])). > > instead, self() is evaluated everywhere in loop() that MasterPid occurs. > Intuitively I sort of get it, by formally I don't really understand > what's going on here...why the delayed evaluation? I would think it > would be > evaluate before the spawn, but it's getting evaluated after the spawn > on node > 'H'. As I understand it, function calls in the body of a fun are executed when the fun is executed but bindings are copied from the local context when the fun is constructed. In the first case S is a binding made before launch() is called. S is copied into the fun object and will not change. In the second case the instructions in the fun say it must call self() when the fun is executed. -- Rich Stay connected to the people that matter most with a smarter inbox. Take a look http://au.docs.yahoo.com/mail/smarterinbox From richardc@REDACTED Thu Mar 12 07:59:39 2009 From: richardc@REDACTED (Richard Carlsson) Date: Thu, 12 Mar 2009 07:59:39 +0100 Subject: [erlang-questions] A tad confused about function parameters In-Reply-To: <33052B61-455E-474A-B1D9-011AB07FDEE2@lanl.gov> References: <33052B61-455E-474A-B1D9-011AB07FDEE2@lanl.gov> Message-ID: <49B8B2DB.2050800@it.uu.se> Allen McPherson wrote: > The line in question is: > S = self(), > -----> launch(T, lists:append(Pids, [spawn(H, fun() -> loop(S, > start) end)])). > > I find that if I use: > launch(T, lists:append(Pids, [spawn(H, fun() -> > loop(self(), start) end)])). > > instead, self() is evaluated everywhere in loop() that MasterPid occurs. > Intuitively I sort of get it, by formally I don't really understand > what's going on here...why the delayed evaluation? I would think it > would be evaluate before the spawn Well, the whole point of a lambda expression is to delay the evaluation of everything between fun...end. The call to self() is just another subexpression, so if you expect that to be evaluated immediately, then surely you'd also expect the call to loop(...) to run right after that? Of course not - that was why you used a fun to begin with. The trap is that it's easy to start thinking about self() (and some other builtins like node()) as "more primitive" - mere symbols - and expect them to work like variables. But they are just function calls. /Richard From raimo+erlang-questions@REDACTED Thu Mar 12 08:22:07 2009 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Thu, 12 Mar 2009 08:22:07 +0100 Subject: [erlang-questions] Request for enhancement: lchown In-Reply-To: <4f0695950903110943t537a875djc56b318a535e9c14@mail.gmail.com> References: <4f0695950903110943t537a875djc56b318a535e9c14@mail.gmail.com> Message-ID: <20090312072207.GA1381@erix.ericsson.se> On Wed, Mar 11, 2009 at 04:43:49PM +0000, Ville Silventoinen wrote: > Hi, > > I apologise if I'm asking on the wrong mailing list, I'm not sure what the > protocol is (should I submit an EEP?). This would be the right list. The EEPs are for language changes and very debateable library changes (a'la how should we do REs). Small library enhancements would go here or maybe erlang-patches if they are such. > > If possible, it would be great to have "write_link_info" in some future > release. As far as I know, there is no way to set the owner of a symbolic > link (write_file_info follows the symlink). I took a look at the > otp_src_R12B-5 sources, it looks like this could be implemented in > emulator/drivers/unix/unix_efile.c with a similar function to > "efile_write_info", except that it would call lchown instead of chown. Sounds like a important missing feature. We will try to get it in some day... > > Thanks, > Ville > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From franco.milicchio@REDACTED Thu Mar 12 09:59:12 2009 From: franco.milicchio@REDACTED (Franco Milicchio) Date: Thu, 12 Mar 2009 09:59:12 +0100 Subject: [erlang-questions] Second order function lists:map In-Reply-To: <0FE278CB-1AA3-4ADD-B4B2-72233D914EEB@cs.otago.ac.nz> References: <4499200B-3ADF-49E1-BE6D-BA9A9FEAE457@gmail.com> <0FE278CB-1AA3-4ADD-B4B2-72233D914EEB@cs.otago.ac.nz> Message-ID: On Mar 10, 2009, at 11:42pm, Richard O'Keefe wrote: > > On 11 Mar 2009, at 3:56 am, Franco Milicchio wrote: >> The second one is tricky to me (I am not an erlang guru!). I want >> its "dual", so given a list of functions, I'd like to map them to a >> single argument, writing a second-order function like the above >> p:paa/1. The only problem is that I am stopped by this problem, I >> know it's easy but I am not that good at functional programming :) > > 1. map(F, L) -> [F(X) | X <- L]. > paa(F) -> fun (L) -> map(F, L) end. > > 2. pam(L, X) -> [F(X) | F <- L]. > aap(L) -> fun (X) -> pam(L, X) end. > > See the parallels? Now I see! Thanks to all of you, you're really handy! Cheers! -- Franco Milicchio DIA - Dept. of Computer Science and Engineering University Roma Tre http://plm.dia.uniroma3.it/milicchio/ -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2435 bytes Desc: not available URL: From ville.silventoinen@REDACTED Thu Mar 12 10:10:23 2009 From: ville.silventoinen@REDACTED (Ville Silventoinen) Date: Thu, 12 Mar 2009 09:10:23 +0000 Subject: [erlang-questions] Request for enhancement: lchown In-Reply-To: <20090312072207.GA1381@erix.ericsson.se> References: <4f0695950903110943t537a875djc56b318a535e9c14@mail.gmail.com> <20090312072207.GA1381@erix.ericsson.se> Message-ID: <4f0695950903120210t537ef525lac676807559e90b9@mail.gmail.com> Thank you, Raimo! -------------- next part -------------- An HTML attachment was scrubbed... URL: From rvirding@REDACTED Thu Mar 12 12:00:09 2009 From: rvirding@REDACTED (Robert Virding) Date: Thu, 12 Mar 2009 12:00:09 +0100 Subject: [erlang-questions] Paul Graham uses Erlang to solve scaling problems!!! In-Reply-To: <878wnbpsuk.fsf@dixie.cronqvi.st> References: <878wnbpsuk.fsf@dixie.cronqvi.st> Message-ID: <3dbc6d1c0903120400o782acb9eh3328a03f5523943a@mail.gmail.com> Well, everyone didn't seem overjoyed at the deluge of Erlang postings. :-) But I do think we, the Erlang community, should be better at posting Erlang stuff on the Y-combinator. After all it *is* actually relevant for them, even if some don't realise it. The same holds for dzone and Reddit programming. Robert 2009/3/12 > > yes it's true; Paul Graham, lisp evangelist and IT millionaire, is > using the awesome powers of Erlang to solve the scaling issues of > Hacker News, his reddit clone. > > Read and rejoice! Or something. > > mats > > http://news.ycombinator.com/item?id=512145 > > Why HN is slow lately > > We've had a huge spike in traffic lately, from roughly 24k daily > uniques to 33k. This is a result of being mentioned on more mainstream > sites. I hope this spike will subside, like past ones have. In the > meantime I may temporarily hack a few things to make the site faster, > like putting fewer results on threads pages. > > You can help the spike subside by making HN look extra boring. For the > next couple days it would be better to have posts about the innards of > Erlang than women who create sites to get hired by Twitter. > > _______________________________________________ > 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 Thu Mar 12 12:18:33 2009 From: chsu79@REDACTED (Christian) Date: Thu, 12 Mar 2009 12:18:33 +0100 Subject: [erlang-questions] Paul Graham uses Erlang to solve scaling problems!!! In-Reply-To: <3dbc6d1c0903120400o782acb9eh3328a03f5523943a@mail.gmail.com> References: <878wnbpsuk.fsf@dixie.cronqvi.st> <3dbc6d1c0903120400o782acb9eh3328a03f5523943a@mail.gmail.com> Message-ID: Or to make things so cool that other people post links to these sites. :) 2009/3/12 Robert Virding : > Well, everyone didn't seem overjoyed at the deluge of Erlang postings. :-) > But I do think we, the Erlang community, should be better at posting Erlang > stuff on the Y-combinator. After all it *is* actually relevant for them, > even if some don't realise it. The same holds for dzone and Reddit > programming. From Roman@REDACTED Thu Mar 12 20:33:04 2009 From: Roman@REDACTED (Roman@REDACTED) Date: Thu, 12 Mar 2009 23:33:04 +0400 Subject: [erlang-questions] memory leak. Message-ID: Hi dear Team, A problem appeared with the memory leak. Function "erlang:memory()" shows that "total" parameter grows constantly and fast, during the day it increases from 60 Mb till 510 Mb. "System" parameter also grows constantly, not as much fast, reaching 400 Mb. "process" parameter although does not reach 100 Mb. Top FreeBSD utility?s "size" parameter also increases from 70 Mb till 600 Mb. System crashes on "mem_error" of the module "zlib.erl" or on the error "system_limit" while creating new process {erlang,open_port,[{spawn,zlib_drv},[binary]]}. "yaws", "error_logger" and some gen_server-s work on the computer. No database except "ets" is used during the functioning, but the used memory doesn?t exceed 1 Mb. Server receives messages each second. The memory releases after restarting erlang. Restarting individual gen_server-s gives nothing. What is the reason of appearing memory leak problem? -- Best regards, Roman Shuplov. From matthias@REDACTED Thu Mar 12 21:49:56 2009 From: matthias@REDACTED (Matthias Lang) Date: Thu, 12 Mar 2009 21:49:56 +0100 Subject: [erlang-questions] Non-blocking sends in gen_tcp? In-Reply-To: <71c13900903110819v42fe2f85k85ed5361433f13fa@mail.gmail.com> References: <71c13900903110819v42fe2f85k85ed5361433f13fa@mail.gmail.com> Message-ID: <20090312204956.GB5034@contorpis.lisalinda.com> On Wednesday, March 11, Cayle Spandon wrote: > Does gen_tcp provide a mechanism for non-blocking sends, similar to the > traditional send and select/poll calls in Unix, in the following sense: Short answer: "no". Your post almost boils down to "I want to do this the same way as I do it in C. I'm aware of some ways it could be done in Erlang, but I specifically don't want to use any of those for mostly unspecified reasons." I.e. you may be unnecessarily tying one hand behind your back. On the other hand, there are some things which Just Can't Be Done with gen_tcp:send(), for instance 1. You have two things you want to send 2. You give them both to gen_tcp:send(), which blocks (in C, you might have successfully sent the first, but gotten an EWOULDBLOCK or EAGAIN or whatever on the second and thus not sent it) 3. Something else happens, e.g. a timer expires, and you now want to send a third item but not the second. But you can't snatch the second back from gen_tcp:send() (in C, the second item was still under your control) and it could be that you want to do something like that. If that's so, I think you're SOL. It sounds like you already found this discussion: http://erlang.org/pipermail/erlang-questions/2008-November/039791.html which is pretty much everything I know about the subject. There are other people who know more, they may or may not find time to write something about it. If you want to dig, I think you'll need to go lower than prim_inet, i.e to the somewhat daunting erts/emulator/drivers/common/inet_drv.c It's possible I've missed something. Matt -------------------- > -1- When you call gen_tcp:send() with N bytes and flow-control kicks in, > gen_tcp:send()returns immediately (i.e. does not block, not even for some > small time-out). The return value indicates that flow-control was invoked > and gives some indication of what subset of bytes was accepted (e.g. by > returning the remaining unsent binary). This is similar to Unix send() > returning EAGAIN. > -2- Some mechanism to inform the sending process that the socket is ready to > send more data, e.g. an Erlang message. This is similar to Unix select() > reporting that a socket is ready-to-send. > > I have considered the option of creating an Erlang process dedicated to > sending messages over the socket and using blocking gen_tcp:send calls in > that process. For various reasons (related to the fact that a send may have > to be interruped by some other activity) this is not an option for me. > > I found some references to the prim_inet module on Google, but evidently > that is not an officially documented module. > > PS - My apologies if this question has already been answered. I googled the > topic and found many discussions but not quite the answer. From billrobertson42+erlang@REDACTED Fri Mar 13 00:26:20 2009 From: billrobertson42+erlang@REDACTED (bill robertson) Date: Thu, 12 Mar 2009 19:26:20 -0400 Subject: [erlang-questions] Please help me relate a past project to Erlang, I'm trying to understand... In-Reply-To: References: Message-ID: So I've been thinking more about Erlang lately, and I still haven't gotten over a conceptual hurdle. Where do you keep state? So I'd like to explain a previous project that I did, that would be a natural fit for Erlang, and then discuss how one might approach it in Erlang. I'm not trying to advocate for the way the project worked in the past, and I'm not trying to get free advice for working on it now. I no longer work at that company and haven't touch it in a long time. The project was a controller for a conference calling server. In the setup there was a server running on another box that took simple commands, e.g. dial a number (it used PRI), play a wav file to one or more lines, answer, and bridge multiple lines together, disconnect lines etc... The whole thing was pretty small potatoes, so there was no need to distribute the controller logic. It was a lot of fun to do. I have to say that its a great experence when you hit "go" in the debugger and your phone rings. :) The controller piece, which I implemented was in (please don't stop reading) Java. It would take commands from a web applicaiton, handle events from the telephony server and report on and manage the state of the conference calls. When it was dealing with messages from the telephony server it would first lock the conference call object and then forward the message to an object that represented the participant on the call. The participant object would interpret the message, update its internal state, and under some circumstances notify the conference call object of a major state change (e.g. the line hung up). Upon update from a participant, the conference call object might change its state e.g. the last person hung up, so call over. Once the call stack unwound, the conference call object became unlocked automatically (language mechanisms). Overall it worked pretty well. The locking wasn't automatic, so it was possble to forget to lock, which of course would cause havoc (it happened -- bad decision on my part to leave it to fallible human memory). The only possible bottleneck it presented was when 30 or so people were trying to jump on the call at the same time, although we never measured if the bottleneck was in the controller or in the telephony server. In the Erlang world, I can easily see how you would want a process for the conference call, and possible a process for each participant. I also understand that you don't want to use a process local map for storage. So would you use an ets or a dets table? Or would you track it in a completely different fashion. I would really appreciate your help. Thank you. From pfisher@REDACTED Fri Mar 13 00:42:18 2009 From: pfisher@REDACTED (Paul Fisher) Date: Thu, 12 Mar 2009 18:42:18 -0500 Subject: [erlang-questions] Please help me relate a past project to Erlang, I'm trying to understand... In-Reply-To: References: Message-ID: <49B99DDA.2040707@alertlogic.net> bill robertson wrote: > So I've been thinking more about Erlang lately, and I still haven't > gotten over a conceptual hurdle. Where do you keep state? The actual key is to remember that function calls in erlang are call-recursive, so a simple function that calls itself consumes only one level in stack no matter how many times it loops. This extends to sequences of calls too, as long as each call to recursive function is the return value of the calling function. A simple example: -record(state, { foo, boo, bar }). loop(#state{} = State) -> receive {some, Foo} -> %% do something here with Foo and anything else in State loop( State#state{ foo = Foo } ); {interesting, Boo} -> %% do something here with Boo and anything else in State loop( State#state{ boo = Boo } ); {messages, Foo} -> %% do something here with Bar and anything else in State loop( State#state{ bar = Bar } ) end. If you spawn loop/1 as a process, then it will simply keep going processing messages that it receives. Now OTP captures this in a pair of abstractions called gen_server and gen_fsm, which are a generalized server and generalized finite state machine, respectively. I encourage you to look into these as they make thing easier as you get further along in structuring larger solutions. These are documented in the stdlib application: http://www.erlang.org/doc/apps/stdlib/index.html -- paul From dbudworth@REDACTED Fri Mar 13 02:53:32 2009 From: dbudworth@REDACTED (David Budworth) Date: Thu, 12 Mar 2009 20:53:32 -0500 Subject: [erlang-questions] Hillarious(IMO) new "marketing" video for erlang...munctional programming Message-ID: <2e23d1d20903121853n47037cdek4db814ed786cfe83@mail.gmail.com> Didn't see this posted to the group yet, and maybe everyone has seen it. But I thought it awesome. http://www.youtube.com/watch?v=1yH_j8-VVLo (note: you need sound, and it's both quite and load at the same time) -------------- next part -------------- An HTML attachment was scrubbed... URL: From tony@REDACTED Fri Mar 13 04:08:39 2009 From: tony@REDACTED (Tony Arcieri) Date: Thu, 12 Mar 2009 21:08:39 -0600 Subject: [erlang-questions] Hillarious(IMO) new "marketing" video for erlang...munctional programming In-Reply-To: <2e23d1d20903121853n47037cdek4db814ed786cfe83@mail.gmail.com> References: <2e23d1d20903121853n47037cdek4db814ed786cfe83@mail.gmail.com> Message-ID: 2009/3/12 David Budworth > Didn't see this posted to the group yet, and maybe everyone has seen it. > But I thought it awesome. > > http://www.youtube.com/watch?v=1yH_j8-VVLo > Yeah, I pasted that to #erlang on freenode last night. While it appears the guy who made it didn't know a whole lot about Erlang it's still hilarious nonetheless. (It's a parody of the Powerthirst video for those who weren't aware) -- Tony Arcieri medioh.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From steven.charles.davis@REDACTED Fri Mar 13 14:03:20 2009 From: steven.charles.davis@REDACTED (Steve Davis) Date: Fri, 13 Mar 2009 06:03:20 -0700 (PDT) Subject: [erlang-questions] Please help me relate a past project to Erlang, I'm trying to understand... In-Reply-To: References: Message-ID: <6cc6cc13-7112-4b68-845f-bc7efe8ff706@v15g2000yqn.googlegroups.com> This may or may not help, but I do feel the pain you are facing. Without previous experience in functional programming, the issue you face is perhaps the biggest conceptual barrier to even getting started with Erlang. Remember that OO took a while to grasp? Well, the good news is that FP is easier but will also take a little bit of time. Write some small programs that do a small part of what you wish to do then build on those. Building on your foundations is far easier in Erlang than say Java or C++. The reason it's easier, as I'm sure you'll appreciate by writing some code, is that it's more logical and brings you closer to both the problem you face and to the metal you are working with. Passing data around in Erlang does take more planning than it does with an imperative language, but you gain enormously when you realize that you don't have to deal with side-effects that dominate imperative/ OO code. This enormously reduces the amount of code you have to write and does clarify your thinking about the "business logic" problem. If you think of your application as a big black box with inputs and outputs, split those out into which inputs and outputs you need so you end up with a bunch of smaller black boxes that you can approach. Each will have an input and and output (f(x) -> x'). This will clarify and you will find that it correlate to your use cases. The conceptual leap looks impossible perhaps, but I strongly encourage you to try a small part of the problem to experience the clarity and conciseness that Erlang can bring. The rewards you will receive will far outweigh the effort you put in, but it won't happen overnight. Best, /sd On Mar 12, 6:26?pm, bill robertson wrote: > So I've been thinking more about Erlang lately, and I still haven't > gotten over a conceptual hurdle. ?Where do you keep state? > > So I'd like to explain a previous project that I did, that would be a > natural fit for Erlang, and then discuss how one might approach it in > Erlang. ?I'm not trying to advocate for the way the project worked in > the past, and I'm not trying to get free advice for working on it now. > ?I no longer work at that company and haven't touch it in a long time. > > The project was a controller for a conference calling server. ?In the > setup there was a server running on another box that took simple > commands, e.g. dial a number (it used PRI), play a wav file to one or > more lines, answer, and bridge multiple lines together, disconnect > lines etc... ?The whole thing was pretty small potatoes, so there was > no need to distribute the controller logic. ?It was a lot of fun to > do. ?I have to say that its a great experence when you hit "go" in the > debugger and your phone rings. ?:) > > The controller piece, which I implemented was in (please don't stop > reading) Java. ?It would take commands from a web applicaiton, handle > events from the telephony server and report on and manage the state of > the conference calls. ?When it was dealing with messages from the > telephony server it would first lock the conference call object and > then forward the message to an object that represented the participant > on the call. ?The participant object would interpret the message, > update its internal state, and under some circumstances notify the > conference call object of a major state change (e.g. the line hung > up). ?Upon update from a participant, the conference call object might > change its state e.g. the last person hung up, so call over. > > Once the call stack unwound, the conference call object became > unlocked automatically (language mechanisms). ?Overall it worked > pretty well. ?The locking wasn't automatic, so it was possble to > forget to lock, which of course would cause havoc (it happened -- bad > decision on my part to leave it to fallible human memory). ?The only > possible bottleneck it presented was when 30 or so people were trying > to jump on the call at the same time, although we never measured if > the bottleneck was in the controller or in the telephony server. > > In the Erlang world, I can easily see how you would want a process for > the conference call, and possible a process for each participant. ?I > also understand that you don't want to use a process local map for > storage. ?So would you use an ets or a dets table? ?Or would you track > it in a completely different fashion. > > I would really appreciate your help. > > Thank you. > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions From erlang@REDACTED Fri Mar 13 14:43:28 2009 From: erlang@REDACTED (Peter Lund) Date: Fri, 13 Mar 2009 14:43:28 +0100 Subject: [erlang-questions] Hillarious(IMO) new "marketing" video for erlang...munctional programming In-Reply-To: References: <2e23d1d20903121853n47037cdek4db814ed786cfe83@mail.gmail.com> Message-ID: <49BA6300.3020906@lundata.se> I thought it was funny. :) I smelled quite a bit of envy in the video from someone that probably do not understand erlang completely, but that probably have heard quite a lot about erlang from others. Must be a good sign that there seems to be a lot of "talk" about erlang out there in the rest of the programming community. /Peter Tony Arcieri skrev: > 2009/3/12 David Budworth > > > Didn't see this posted to the group yet, and maybe everyone has > seen it. But I thought it awesome. > > http://www.youtube.com/watch?v=1yH_j8-VVLo > > > Yeah, I pasted that to #erlang on freenode last night. While it > appears the guy who made it didn't know a whole lot about Erlang it's > still hilarious nonetheless. (It's a parody of the Powerthirst video > for those who weren't aware) > > -- > Tony Arcieri > medioh.com > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From thomasl_erlang@REDACTED Fri Mar 13 15:13:21 2009 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Fri, 13 Mar 2009 07:13:21 -0700 (PDT) Subject: [erlang-questions] Please help me relate a past project to Erlang, I'm trying to understand... In-Reply-To: References: Message-ID: <61169.51377.qm@web111416.mail.gq1.yahoo.com> ----- Original Message ---- > From: bill robertson > To: erlang-questions@REDACTED > Sent: Friday, March 13, 2009 12:26:20 AM > Subject: Re: [erlang-questions] Please help me relate a past project to Erlang, I'm trying to understand... > > So I've been thinking more about Erlang lately, and I still haven't > gotten over a conceptual hurdle. Where do you keep state? > ... > In the Erlang world, I can easily see how you would want a process for > the conference call, and possible a process for each participant. I > also understand that you don't want to use a process local map for > storage. So would you use an ets or a dets table? Or would you track > it in a completely different fashion. > > I would really appreciate your help. As others have mentioned, the simplest way is to keep the data in a process. For instance, you can naively map an object to a process by a scheme like this: start() -> obj_loop(1, "hello", ...). %% initialize the process %% process one message: obj_loop(F1, F2, ..., Fn) -> receive {set_f1, NewValue} -> obj_loop(NewValue, F2, ..., Fn); {get_f1, Asker} -> Asker ! F1, obj_loop(F1, ..., Fn); {method_1, A1, ..., An} -> ... operate on fields, yielding New_F1, New_F2 say ... obj_loop(New_F1, New_F2, F3, ..., Fn); end. Each of the cases ends in a tail recursive call to obj_loop/N, which will be implemented as a loop. Method calls are implemented by sending and receiving messages. (In practice, you often want to pass along the sender's PID as well as do other stuff, but the general principle is the above.) And remember that this is naive; you probably shouldn't try to do it for all data structures, just for the "natural" processes of your problem. Moving on, you could also look at the gen_server module, which is a variation on the above approach that abstracts away some of the cruft. Using ets and dets for storage can be helpful for other reasons, such as reliability, but complicates things. I'd suggest you begin with one process per caller and a coordinator process and see where that ends up. For simplicity, register the coordinator process by name so that the callers easily can find it. Best, Thomas From erlang@REDACTED Fri Mar 13 16:03:28 2009 From: erlang@REDACTED (Dominic Williams) Date: Fri, 13 Mar 2009 11:03:28 -0400 (EDT) Subject: [erlang-questions] Paris Erlounge on Monday 16th March Message-ID: There is a guest star at Monday's Paris Erlounge! Jan Henry Nystrom, of Erlang Training and Consulting, will be joining us and has kindly offered to give a talk: "Productivity Gains with Erlang" Currently most distributed telecoms software is engineered using low- and mid-level distributed technologies, but there is a drive to use high-level distribution. This talk reports the first systematic comparison of a high-level distributed programming language in the context of substantial commercial products. The research clearly demonstrates that Erlang is not only a viable, but also a compelling choice when dealing with high availability systems. The Erlounge will be held at the usual time (Monday 16th March at 7.30pm) but in a special location, on Orange premises. N.B. For security reasons it is necessary to sign up for this event by contacting Bruno Thomas (thomasbam@REDACTED) before midday on Monday. The talk will be at the following address: 59bis rue des Archives 75003 Paris We will then go somewhere for food and drink afterwards. Regards, Dominic Williams http://dominicwilliams.net From dmercer@REDACTED Fri Mar 13 19:02:57 2009 From: dmercer@REDACTED (David Mercer) Date: Fri, 13 Mar 2009 13:02:57 -0500 Subject: [erlang-questions] Floor Function? Message-ID: While I notice there are round and trunc functions for converting floats to integers, I could not find a floor function. I can easily roll my own, just wondering if I my documentation-searching skills are lacking and whether I am missing something. Please advise. Thank-you. David Mercer -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob@REDACTED Fri Mar 13 19:17:56 2009 From: bob@REDACTED (Bob Ippolito) Date: Fri, 13 Mar 2009 11:17:56 -0700 Subject: [erlang-questions] Floor Function? In-Reply-To: References: Message-ID: <6a36e7290903131117q2e958422t4329dee19a3be7aa@mail.gmail.com> There is in implementation of ceil in mochiweb's mochinum module, floor is also trivial to write (especially given ceil as a template) but mochiweb doesn't include it. %% @spec int_ceil(F::float()) -> integer() %% @doc Return the ceiling of F as an integer. The ceiling is defined as %% F when F == trunc(F); %% trunc(F) when F < 0; %% trunc(F) + 1 when F > 0. int_ceil(X) -> T = trunc(X), case (X - T) of Neg when Neg < 0 -> T; Pos when Pos > 0 -> T + 1; _ -> T end. 2009/3/13 David Mercer : > While I notice there are round and trunc functions for converting floats to > integers, I could not find a floor function.? I can easily roll my own, just > wondering if I my documentation-searching skills are lacking and whether I > am missing something.? Please advise.? Thank-you. > > > > David Mercer > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From nym-erlang-q@REDACTED Fri Mar 13 19:36:43 2009 From: nym-erlang-q@REDACTED (Anthony Molinaro) Date: Fri, 13 Mar 2009 11:36:43 -0700 Subject: [erlang-questions] Bad warning when using short-circuit boolean expressions Message-ID: <20090313183643.GA440@n54.com> Hi, I have this code -module (is_dict). -include_lib ("eunit/include/eunit.hrl"). -define (is_dict (D), is_tuple (D) andalso element (1, D) =:= dict). is_dict_test () -> ?assertEqual (false, ?is_dict (a)), ?assertEqual (false, ?is_dict ({a, b})), ?assertEqual (false, ?is_dict ([{a, b}])), ?assertEqual (true, ?is_dict (dict:new())), ?assertEqual (true, ?is_dict (dict:from_list ([{a, b}]))). which gives Erlang (BEAM) emulator version 5.6.5 [source] [smp:2] [async-threads:0] [kernel-poll:false] Eshell V5.6.5 (abort with ^G) 1> c (is_dict). ./is_dict.erl:8: Warning: this expression will fail with a 'badarg' exception ./is_dict.erl:10: Warning: this expression will fail with a 'badarg' exception {ok,is_dict} 2> is_dict:test (). Test successful. ok 3> The warnings seem wrong as the expression does not fail (or maybe I'm just doing something wrong with this test?). -Anthony -- ------------------------------------------------------------------------ Anthony Molinaro From nym-erlang-q@REDACTED Fri Mar 13 22:02:27 2009 From: nym-erlang-q@REDACTED (Anthony Molinaro) Date: Fri, 13 Mar 2009 14:02:27 -0700 Subject: [erlang-questions] Bad warning when using short-circuit booleanexpressions In-Reply-To: <1AEC5A3A9A716A4E84B129198659D249010A54FD@harrison.il-fa.com> References: <20090313183643.GA440@n54.com> <1AEC5A3A9A716A4E84B129198659D249010A54FD@harrison.il-fa.com> Message-ID: <20090313210226.GB440@n54.com> I understand that element/2 is expecting a tuple, but the andalso is short circuiting when D is not a tuple, so element is always called with a tuple in this case. The warning is therefore misleading, since it states "this expression will fail" when it does not fail. This may just be impossible to detect because of the lack of types, in that case I would be curious how to achieve the same functionality (testing that an erlang term is a dict in a guard), without the warning. Thanks, -Anthony On Fri, Mar 13, 2009 at 03:06:45PM -0500, Sibley, Jamaal wrote: > Sorry, I didn't see the macro. Element/2 is expecting a tuple as the > second argument. > > -----Original Message----- > From: erlang-questions-bounces@REDACTED > [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Anthony > Molinaro > Sent: Friday, March 13, 2009 1:37 PM > To: erlang-questions@REDACTED > Subject: [erlang-questions] Bad warning when using short-circuit > booleanexpressions > > Hi, > > I have this code > > -module (is_dict). > > -include_lib ("eunit/include/eunit.hrl"). > > -define (is_dict (D), is_tuple (D) andalso element (1, D) =:= dict). > > is_dict_test () -> > ?assertEqual (false, ?is_dict (a)), > ?assertEqual (false, ?is_dict ({a, b})), > ?assertEqual (false, ?is_dict ([{a, b}])), > ?assertEqual (true, ?is_dict (dict:new())), > ?assertEqual (true, ?is_dict (dict:from_list ([{a, b}]))). > > which gives > > Erlang (BEAM) emulator version 5.6.5 [source] [smp:2] [async-threads:0] > [kernel-poll:false] > > Eshell V5.6.5 (abort with ^G) > 1> c (is_dict). > ./is_dict.erl:8: Warning: this expression will fail with a 'badarg' > exception > ./is_dict.erl:10: Warning: this expression will fail with a 'badarg' > exception {ok,is_dict} > 2> is_dict:test (). > Test successful. > ok > 3> > > The warnings seem wrong as the expression does not fail (or maybe I'm > just doing something wrong with this test?). > > -Anthony > > -- > ------------------------------------------------------------------------ > Anthony Molinaro > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > ------------------------------------------------------------------------------ > This communication, along with any documents, files or attachments, is intended only for the use of the addressee and may contain legally privileged and confidential information. If you are not the intended recipient, you are hereby notified that any dissemination, distribution or copying of any information contained in or attached to this communication is strictly prohibited. If you have received this message in error, please notify the sender immediately and destroy the original communication and its attachments without reading, printing or saving in any manner. Thank you. > > CIRCULAR 230 DISCLOSURE: Pursuant to regulations governing practice before the Internal Revenue Service, unless otherwise expressly indicated, any tax advice contained in this communication, including any attachments, is not intended or written by us to be used, and cannot be used, by anyone (i) for the purpose of avoiding tax penalties that may be imposed under the Internal Revenue Code or (ii) for promoting, marketing or recommending to another party any tax-related matters or programs addressed herein. > > -- ------------------------------------------------------------------------ Anthony Molinaro From erlangy@REDACTED Fri Mar 13 23:00:14 2009 From: erlangy@REDACTED (Michael McDaniel) Date: Fri, 13 Mar 2009 15:00:14 -0700 Subject: [erlang-questions] Bad warning when using short-circuit booleanexpressions In-Reply-To: <20090313210226.GB440@n54.com> References: <20090313183643.GA440@n54.com> <1AEC5A3A9A716A4E84B129198659D249010A54FD@harrison.il-fa.com> <20090313210226.GB440@n54.com> Message-ID: <20090313220014.GR22018@delora.autosys.us> On Fri, Mar 13, 2009 at 02:02:27PM -0700, Anthony Molinaro wrote: > I understand that element/2 is expecting a tuple, but the andalso > is short circuiting when D is not a tuple, so element is always called > with a tuple in this case. The warning is therefore misleading, since > it states "this expression will fail" when it does not fail. This may > just be impossible to detect because of the lack of types, in that case > I would be curious how to achieve the same functionality (testing that > an erlang term is a dict in a guard), without the warning. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ you could replace the macro ... -export([is_dict/1]). is_dict(D) -> is_tuple (D) andalso element (1, D) =:= dict . ~M > > Thanks, > > -Anthony > > On Fri, Mar 13, 2009 at 03:06:45PM -0500, Sibley, Jamaal wrote: > > Sorry, I didn't see the macro. Element/2 is expecting a tuple as the > > second argument. > > > > -----Original Message----- > > From: erlang-questions-bounces@REDACTED > > [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Anthony > > Molinaro > > Sent: Friday, March 13, 2009 1:37 PM > > To: erlang-questions@REDACTED > > Subject: [erlang-questions] Bad warning when using short-circuit > > booleanexpressions > > > > Hi, > > > > I have this code > > > > -module (is_dict). > > > > -include_lib ("eunit/include/eunit.hrl"). > > > > -define (is_dict (D), is_tuple (D) andalso element (1, D) =:= dict). > > > > is_dict_test () -> > > ?assertEqual (false, ?is_dict (a)), > > ?assertEqual (false, ?is_dict ({a, b})), > > ?assertEqual (false, ?is_dict ([{a, b}])), > > ?assertEqual (true, ?is_dict (dict:new())), > > ?assertEqual (true, ?is_dict (dict:from_list ([{a, b}]))). > > > > which gives > > > > Erlang (BEAM) emulator version 5.6.5 [source] [smp:2] [async-threads:0] > > [kernel-poll:false] > > > > Eshell V5.6.5 (abort with ^G) > > 1> c (is_dict). > > ./is_dict.erl:8: Warning: this expression will fail with a 'badarg' > > exception > > ./is_dict.erl:10: Warning: this expression will fail with a 'badarg' > > exception {ok,is_dict} > > 2> is_dict:test (). > > Test successful. > > ok > > 3> > > > > The warnings seem wrong as the expression does not fail (or maybe I'm > > just doing something wrong with this test?). > > > > -Anthony > > > > -- > > ------------------------------------------------------------------------ > > Anthony Molinaro > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > ------------------------------------------------------------------------------ > > This communication, along with any documents, files or attachments, is intended only for the use of the addressee and may contain legally privileged and confidential information. If you are not the intended recipient, you are hereby notified that any dissemination, distribution or copying of any information contained in or attached to this communication is strictly prohibited. If you have received this message in error, please notify the sender immediately and destroy the original communication and its attachments without reading, printing or saving in any manner. Thank you. > > > > CIRCULAR 230 DISCLOSURE: Pursuant to regulations governing practice before the Internal Revenue Service, unless otherwise expressly indicated, any tax advice contained in this communication, including any attachments, is not intended or written by us to be used, and cannot be used, by anyone (i) for the purpose of avoiding tax penalties that may be imposed under the Internal Revenue Code or (ii) for promoting, marketing or recommending to another party any tax-related matters or programs addressed herein. > > > > > > -- > ------------------------------------------------------------------------ > Anthony Molinaro > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- Michael McDaniel Portland, Oregon, USA http://autosys.us From fess-erlang@REDACTED Fri Mar 13 23:05:14 2009 From: fess-erlang@REDACTED (fess) Date: Fri, 13 Mar 2009 15:05:14 -0700 Subject: [erlang-questions] Bad warning when using short-circuit booleanexpressions In-Reply-To: <20090313220014.GR22018@delora.autosys.us> References: <20090313183643.GA440@n54.com> <1AEC5A3A9A716A4E84B129198659D249010A54FD@harrison.il-fa.com> <20090313210226.GB440@n54.com> <20090313220014.GR22018@delora.autosys.us> Message-ID: <136DCB0D-6A05-436E-93CE-9DE8E5B5EE3B@fess.org> hmm, Then he couldn't use it as a guard. On Mar 13, 2009, at 3:00 PM, Michael McDaniel wrote: > you could replace the macro ... > > > -export([is_dict/1]). > > is_dict(D) -> > is_tuple (D) andalso element (1, D) =:= dict > . --fess From fritchie@REDACTED Sat Mar 14 04:51:31 2009 From: fritchie@REDACTED (Scott Lystig Fritchie) Date: Fri, 13 Mar 2009 22:51:31 -0500 Subject: [erlang-questions] Newbie questions about file module In-Reply-To: Message of "Tue, 17 Feb 2009 09:30:04 +0100." <6672d0160902170030r1d0c0805k603e05fbd31dd03a@mail.gmail.com> Message-ID: <25564.1237002691@snookles.snookles.com> Bjorn Gustavsson wrote: >> How frequent is it to use a deep I/O list as a file name? [...] bg> Unfortunately, for historical reasons, filenames are allowed to bg> contain atoms and atoms are not allowed in I/O lists. At one time in bg> OTP's history, we wanted to disallowed atoms in filenames, but it bg> turned out that many applications used atoms in filenames. Sorry for picking up a thread that's a month old but ... {trying to understand what you're implying} ... those legacy/whatever apps are using filenames with deep lists *and* one or more list members may be atoms? Oi! Looking at one of Ville's followup messages ... 27% of his runtime spent sanity checking for that kind of rare oddity is ... enough to ... use a lot of ellipses. ... ... -Scott From steven.charles.davis@REDACTED Sat Mar 14 09:33:05 2009 From: steven.charles.davis@REDACTED (Steve Davis) Date: Sat, 14 Mar 2009 01:33:05 -0700 (PDT) Subject: [erlang-questions] Simple question about term file extension Message-ID: <2f491c55-c868-420b-9c4f-b6cd2c2788ed@y13g2000yqn.googlegroups.com> Of course this can be anything, but is there consensus over the "best" file extension for a term file (i.e. a file that can be read with file:consult)? From bgustavsson@REDACTED Sat Mar 14 10:01:57 2009 From: bgustavsson@REDACTED (Bjorn Gustavsson) Date: Sat, 14 Mar 2009 10:01:57 +0100 Subject: [erlang-questions] Bad warning when using short-circuit boolean expressions In-Reply-To: <20090313183643.GA440@n54.com> References: <20090313183643.GA440@n54.com> Message-ID: <6672d0160903140201s2db3a0beud900df2f04c89a94@mail.gmail.com> On Fri, Mar 13, 2009 at 7:36 PM, Anthony Molinaro wrote: > Hi, > > ?I have this code > > -module (is_dict). > > -include_lib ("eunit/include/eunit.hrl"). > > -define (is_dict (D), is_tuple (D) andalso element (1, D) =:= dict). > > is_dict_test () -> > ??assertEqual (false, ?is_dict (a)), > ??assertEqual (false, ?is_dict ({a, b})), > ??assertEqual (false, ?is_dict ([{a, b}])), > ??assertEqual (true, ?is_dict (dict:new())), > ??assertEqual (true, ?is_dict (dict:from_list ([{a, b}]))). > > which gives > > Erlang (BEAM) emulator version 5.6.5 [source] [smp:2] [async-threads:0] [kernel-poll:false] > > Eshell V5.6.5 ?(abort with ^G) > 1> c (is_dict). > ./is_dict.erl:8: Warning: this expression will fail with a 'badarg' exception > ./is_dict.erl:10: Warning: this expression will fail with a 'badarg' exception > {ok,is_dict} > 2> is_dict:test (). > ?Test successful. > ok > 3> > > The warnings seem wrong as the expression does not fail (or maybe I'm just > doing something wrong with this test?). I agree that the warnings should not occur. The reasons for the warnings is that is_tuple(a) andalso is_element(1, a) =:= dict will be translated to something similar to case is_tuple(a) of true -> element(1, a) =:= dict); false -> false end and that is the code that the optimizer will see and generate a warning for. We might fix the problem in a future release. (Not R13A and probably not R13B either.) /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From bgustavsson@REDACTED Sat Mar 14 10:14:07 2009 From: bgustavsson@REDACTED (Bjorn Gustavsson) Date: Sat, 14 Mar 2009 10:14:07 +0100 Subject: [erlang-questions] Newbie questions about file module In-Reply-To: <25564.1237002691@snookles.snookles.com> References: <6672d0160902170030r1d0c0805k603e05fbd31dd03a@mail.gmail.com> <25564.1237002691@snookles.snookles.com> Message-ID: <6672d0160903140214i18c52d12u1506e8ced9d45e34@mail.gmail.com> On Sat, Mar 14, 2009 at 4:51 AM, Scott Lystig Fritchie wrote: > Bjorn Gustavsson wrote: > >>> How frequent is it to use a deep I/O list as a file name? ?[...] > > bg> Unfortunately, for historical reasons, filenames are allowed to > bg> contain atoms and atoms are not allowed in I/O lists. At one time in > bg> OTP's history, we wanted to disallowed atoms in filenames, but it > bg> turned out that many applications used atoms in filenames. > > Sorry for picking up a thread that's a month old but ... {trying to > understand what you're implying} ... those legacy/whatever apps are > using filenames with deep lists *and* one or more list members may be > atoms? ?Oi! > > Looking at one of Ville's followup messages ... 27% of his runtime spent > sanity checking for that kind of rare oddity is ... enough to ... use a > lot of ellipses. ?... ? ? ?... > It was a long time ago (more than 10 years ago) that we gave up on getting rid in atoms in filenames. I am not sure whether the applications actually put atoms in deep lists or only used one atom as a filename. I also don't know how much of that old code is still used today. One way to get rid of atoms in filenames (if everyone agrees that is a good idea), would be have Dialyzer start warning for them, and then we could make the change in a future release. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From ulf.wiger@REDACTED Sat Mar 14 11:39:35 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Sat, 14 Mar 2009 11:39:35 +0100 Subject: [erlang-questions] Simple question about term file extension Message-ID: The "OTP way" is to name these files according to purpose (e.g. .rel, .app, .cfg). I'm not aware of any other convention. BR, Ulf W -- originalmedd. -- ?mne: [erlang-questions] Simple question about term file extension Fr?n: Steve Davis Datum: 2009.03.14 09.35 Of course this can be anything, but is there consensus over the "best" file extension for a term file (i.e. a file that can be read with file:consult)? _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions From richardc@REDACTED Sat Mar 14 11:50:53 2009 From: richardc@REDACTED (Richard Carlsson) Date: Sat, 14 Mar 2009 11:50:53 +0100 Subject: [erlang-questions] Newbie questions about file module In-Reply-To: <6672d0160903140214i18c52d12u1506e8ced9d45e34@mail.gmail.com> References: <6672d0160902170030r1d0c0805k603e05fbd31dd03a@mail.gmail.com> <25564.1237002691@snookles.snookles.com> <6672d0160903140214i18c52d12u1506e8ced9d45e34@mail.gmail.com> Message-ID: <49BB8C0D.1020305@it.uu.se> Bjorn Gustavsson wrote: > One way to get rid of atoms in filenames (if everyone agrees that is a > good idea), > would be have Dialyzer start warning for them, and then we could make the change > in a future release. Or maybe it would be possible to move in the other direction, and start allowing atoms in IO-lists. /Richard From pfisher@REDACTED Sat Mar 14 14:42:05 2009 From: pfisher@REDACTED (Paul Fisher) Date: Sat, 14 Mar 2009 08:42:05 -0500 Subject: [erlang-questions] How to examine binaries identified by erlang:memory/2? Message-ID: <49BBB42D.2060907@alertlogic.net> I'm trying to track down what appears to be a memory leak in our nodes, which appears to be concentrated in binaries: An earlier reading: > [garbage_collect(P) || P <- processes()]. > {calendar:local_time(),erlang:memory([processes,binary,ets])}. {{{2009,3,13},{17,19,45}}, [{processes,5351952},{binary,1058187944},{ets,49157456}]} then 3.5+ hours later: > [garbage_collect(P) || P <- processes()]. > {calendar:local_time(),erlang:memory([processes,binary,ets])}. {{{2009,3,13},{20,52,53}}, [{processes,1524704},{binary,1876295920},{ets,4634816}]} with the 'binary' number steadily increasing in between. Examining the memory associated with processes does not show anything near this amount of memory consumption, so it appears that we are keeping references to binaries from our linked-in drivers when we do not intend to. My question: Is there any way to identify the "leaked" binaries? If I could look at a few, it would probably be enough to figure out the culprit immediately. thanks, -- paul From ok@REDACTED Mon Mar 16 05:10:39 2009 From: ok@REDACTED (Richard O'Keefe) Date: Mon, 16 Mar 2009 17:10:39 +1300 Subject: [erlang-questions] Floor Function? In-Reply-To: <6a36e7290903131117q2e958422t4329dee19a3be7aa@mail.gmail.com> References: <6a36e7290903131117q2e958422t4329dee19a3be7aa@mail.gmail.com> Message-ID: On 14 Mar 2009, at 7:17 am, Bob Ippolito wrote: > int_ceil(X) -> > T = trunc(X), > case (X - T) of > Neg when Neg < 0 -> T; > Pos when Pos > 0 -> T + 1; > _ -> T > end. Why isn't this int_ceil(X) -> T = trunc(X), if X > T -> T + 1 ; true -> T end. int_floor(X) -> T = trunc(X), if X < T -> T - 1 ; true -> T end. There doesn't seem to be any reason to compute X-T. From bob@REDACTED Mon Mar 16 06:50:38 2009 From: bob@REDACTED (Bob Ippolito) Date: Sun, 15 Mar 2009 22:50:38 -0700 Subject: [erlang-questions] Floor Function? In-Reply-To: References: <6a36e7290903131117q2e958422t4329dee19a3be7aa@mail.gmail.com> Message-ID: <6a36e7290903152250y15fff979j13ccaa958130c9b7@mail.gmail.com> On Sun, Mar 15, 2009 at 9:10 PM, Richard O'Keefe wrote: > > On 14 Mar 2009, at 7:17 am, Bob Ippolito wrote: >> >> int_ceil(X) -> >> ? T = trunc(X), >> ? case (X - T) of >> ? ? ? Neg when Neg < 0 -> T; >> ? ? ? Pos when Pos > 0 -> T + 1; >> ? ? ? _ -> T >> ? end. > > Why isn't this > > int_ceil(X) -> > ? ?T = trunc(X), > ? ?if X > T -> T + 1 > ? ? ; true ?-> T > ? ?end. > > int_floor(X) -> > ? ?T = trunc(X), > ? ?if X < T -> T - 1 > ? ? ; true ?-> T > ? ?end. > > There doesn't seem to be any reason to compute X-T. I didn't say it was optimal, it's just an implementation. It isn't something we use very often, so we didn't spend much time on it besides verify that it was implemented correctly. -bob From vychodil.hynek@REDACTED Mon Mar 16 12:44:25 2009 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Mon, 16 Mar 2009 12:44:25 +0100 Subject: [erlang-questions] Floor Function? In-Reply-To: References: <6a36e7290903131117q2e958422t4329dee19a3be7aa@mail.gmail.com> Message-ID: <4d08db370903160444x199b79d9k8264eb12d94f5c2@mail.gmail.com> On Mon, Mar 16, 2009 at 5:10 AM, Richard O'Keefe wrote: > > On 14 Mar 2009, at 7:17 am, Bob Ippolito wrote: > > int_ceil(X) -> > > T = trunc(X), > > case (X - T) of > > Neg when Neg < 0 -> T; > > Pos when Pos > 0 -> T + 1; > > _ -> T > > end. > > Why isn't this > > int_ceil(X) -> > T = trunc(X), > if X > T -> T + 1 > ; true -> T > end. > > int_floor(X) -> > T = trunc(X), > if X < T -> T - 1 > ; true -> T > end. > > There doesn't seem to be any reason to compute X-T. > Are you sure that there is big difference between compute X-T and decide X > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- --Hynek (Pichi) Vychodil Analyze your data in minutes. Share your insights instantly. Thrill your boss. Be a data hero! Try Good Data now for free: www.gooddata.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From steven.charles.davis@REDACTED Mon Mar 16 12:51:15 2009 From: steven.charles.davis@REDACTED (Steve Davis) Date: Mon, 16 Mar 2009 04:51:15 -0700 (PDT) Subject: [erlang-questions] Floor Function? In-Reply-To: References: <6a36e7290903131117q2e958422t4329dee19a3be7aa@mail.gmail.com> Message-ID: <485c0788-4ba5-4e17-9c76-5e167726055b@h5g2000yqh.googlegroups.com> Why isn't that... int_ceil(X) -> T = trunc(X), if X > T -> T + 1; true -> T end. int_floor(X) -> T = trunc(X), if X < T -> T - 1; true -> T end. ;-P On Mar 15, 11:10?pm, "Richard O'Keefe" wrote: > On 14 Mar 2009, at 7:17 am, Bob Ippolito wrote: > > > int_ceil(X) -> > > ? ?T = trunc(X), > > ? ?case (X - T) of > > ? ? ? ?Neg when Neg < 0 -> T; > > ? ? ? ?Pos when Pos > 0 -> T + 1; > > ? ? ? ?_ -> T > > ? ?end. > > Why isn't this > > int_ceil(X) -> > ? ? ?T = trunc(X), > ? ? ?if X > T -> T + 1 > ? ? ? ; true ?-> T > ? ? ?end. > > int_floor(X) -> > ? ? ?T = trunc(X), > ? ? ?if X < T -> T - 1 > ? ? ? ; true ?-> T > ? ? ?end. > > There doesn't seem to be any reason to compute X-T. > > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions From ryeguy1@REDACTED Mon Mar 16 14:05:25 2009 From: ryeguy1@REDACTED (ryeguy) Date: Mon, 16 Mar 2009 06:05:25 -0700 (PDT) Subject: [erlang-questions] Why is this delete_object giving me an error? Message-ID: <8df32778-c495-45b9-9424-9a4fe0d14120@q9g2000yqc.googlegroups.com> I don't see what's wrong here, but I may just misunderstand the syntax. I'm trying to delete a "user" record from my "user" mnesia table who have the first name of "ryan" (there are multiples of them). Here is what I do: Delete=#user{first_name = "ryan", _ = '_'}, mnesia:dirty_delete_object(Delete) Here is my record definition: -record(user, {id, username, password, email, first_name, last_name, last_login, % Date/time user last logged in reg_date}). % Date/time user registered the account And here is the exception I'm getting: ** exception exit: {aborted, {bad_type,user, {user,'_','_','_','_',"ryan",'_','_','_'}}} in function mnesia:abort/1 in call from users:register/1 It seems like a perfect match. What could cause this problem? From koops.j@REDACTED Mon Mar 16 14:21:51 2009 From: koops.j@REDACTED (Jeroen Koops) Date: Mon, 16 Mar 2009 14:21:51 +0100 Subject: [erlang-questions] Why is this delete_object giving me an error? In-Reply-To: <8df32778-c495-45b9-9424-9a4fe0d14120@q9g2000yqc.googlegroups.com> References: <8df32778-c495-45b9-9424-9a4fe0d14120@q9g2000yqc.googlegroups.com> Message-ID: <331a9abb0903160621l721bc5b1nde2f8d81078dd1b1@mail.gmail.com> Hi, dirty_delete_object (and also delete_object) can only be used with a complete record - i.e. all fields must be filled in. It does not accept wildcard patterns. If you want to delete all user with a certain first name, you need an index on the first_name attribute, query for all users with that first name using mnesia:index_read or dirty_index_read, and finally manually delete all returned records with delete_object or delete. Regards, Jeroen On Mon, Mar 16, 2009 at 2:05 PM, ryeguy wrote: > I don't see what's wrong here, but I may just misunderstand the > syntax. I'm trying to delete a "user" record from my "user" mnesia > table who have the first name of "ryan" (there are multiples of them). > Here is what I do: > > Delete=#user{first_name = "ryan", _ = '_'}, > mnesia:dirty_delete_object(Delete) > > Here is my record definition: > -record(user, {id, > username, > password, > email, > first_name, > last_name, > last_login, % Date/time user last logged in > reg_date}). % Date/time user registered the > account > > And here is the exception I'm getting: > ** exception exit: {aborted, > {bad_type,user, > {user,'_','_','_','_',"ryan",'_','_','_'}}} > in function mnesia:abort/1 > in call from users:register/1 > > It seems like a perfect match. What could cause this problem? > > _______________________________________________ > 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 Mar 16 15:08:54 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Mon, 16 Mar 2009 15:08:54 +0100 Subject: [erlang-questions] Floor Function? In-Reply-To: <4d08db370903160444x199b79d9k8264eb12d94f5c2@mail.gmail.com> References: <6a36e7290903131117q2e958422t4329dee19a3be7aa@mail.gmail.com> <4d08db370903160444x199b79d9k8264eb12d94f5c2@mail.gmail.com> Message-ID: <49BE5D76.1080705@erlang-consulting.com> Hynek Vychodil wrote: > > Are you sure that there is big difference between compute > X-T and decide X I'm not! If you haven't measured ... Neither have I, but given ROK's track record of working on language implementations, it would surprise me if he didn't have a pretty good intuition on the subject. ;-) However, looking at the source: Compare (X-T): #define MY_IS_SSMALL(x) (((Uint) (((x) >> (SMALL_BITS-1)) + 1)) < 2) OpCase(i_minus_jId): { Eterm result; if (is_both_small(tmp_arg1, tmp_arg2)) { Sint i = signed_val(tmp_arg1) - signed_val(tmp_arg2); ASSERT(MY_IS_SSMALL(i) == IS_SSMALL(i)); if (MY_IS_SSMALL(i)) { result = make_small(i); STORE_ARITH_RESULT(result); } } arith_func = ARITH_FUNC(mixed_minus); goto do_big_arith2; } do_big_arith2: { Eterm result; Uint live = Arg(1); SWAPOUT; reg[0] = r(0); reg[live] = tmp_arg1; reg[live+1] = tmp_arg2; result = arith_func(c_p, reg, live); r(0) = reg[0]; SWAPIN; ERTS_HOLE_CHECK(c_p); if (is_value(result)) { STORE_ARITH_RESULT(result); } goto lb_Cl_error; } against (X References: <8df32778-c495-45b9-9424-9a4fe0d14120@q9g2000yqc.googlegroups.com> <331a9abb0903160621l721bc5b1nde2f8d81078dd1b1@mail.gmail.com> Message-ID: Oh, so is there no way to directly delete an object using a secondary index? ID would be my primary index, so I would have to either : A) Get the ID and delete by that with delete() or B) Get the whole record and delete by that with delete_object()? Do I understand this correctly? On Mar 16, 9:21?am, Jeroen Koops wrote: > Hi, > > dirty_delete_object (and also delete_object) can only be used with a > complete record - i.e. all fields must be filled in. It does not accept > wildcard patterns. > > If you want to delete all user with a certain first name, you need an index > on the first_name attribute, query for all users with that first name using > mnesia:index_read or dirty_index_read, and finally manually delete all > returned records with delete_object or delete. > > Regards, > > Jeroen > > On Mon, Mar 16, 2009 at 2:05 PM, ryeguy wrote: > > I don't see what's wrong here, but I may just misunderstand the > > syntax. I'm trying to delete a "user" record from my "user" mnesia > > table who have the first name of "ryan" (there are multiples of them). > > Here is what I do: > > > Delete=#user{first_name = "ryan", _ = '_'}, > > mnesia:dirty_delete_object(Delete) > > > Here is my record definition: > > -record(user, {id, > > ? ? ? ? ? ? ? ? ? ? ? ? ? username, > > ? ? ? ? ? ? ? ? ? ? ? ? ? password, > > ? ? ? ? ? ? ? ? ? ? ? ? ? email, > > ? ? ? ? ? ? ? ? ? ? ? ? ? first_name, > > ? ? ? ? ? ? ? ? ? ? ? ? ? last_name, > > ? ? ? ? ? ? ? ? ? ? ? ? ? last_login, % Date/time user last logged in > > ? ? ? ? ? ? ? ? ? ? ? ? ? reg_date}). % Date/time user registered the > > account > > > And here is the exception I'm getting: > > ** exception exit: {aborted, > > ? ? ? ? ? ? ? ? ? ? ? {bad_type,user, > > ? ? ? ? ? ? ? ? ? ? ? ? ? {user,'_','_','_','_',"ryan",'_','_','_'}}} > > ? ? in function ?mnesia:abort/1 > > ? ? in call from users:register/1 > > > It seems like a perfect match. What could cause this problem? > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questi...@REDACTED > >http://www.erlang.org/mailman/listinfo/erlang-questions > > > > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions From dmercer@REDACTED Mon Mar 16 16:11:22 2009 From: dmercer@REDACTED (David Mercer) Date: Mon, 16 Mar 2009 10:11:22 -0500 Subject: [erlang-questions] Floor Function? In-Reply-To: <4d08db370903160444x199b79d9k8264eb12d94f5c2@mail.gmail.com> References: <6a36e7290903131117q2e958422t4329dee19a3be7aa@mail.gmail.com> <4d08db370903160444x199b79d9k8264eb12d94f5c2@mail.gmail.com> Message-ID: <4BA354AE373847F796715DC8CEED7810@SSI.CORP> On 3/16, Hynek Vychodil wrote: Are you sure that there is big difference between compute X-T and decide X floor:test(10000000). [{ippolito,[{runtime,17766}, {wall_clock,17782}, {runtime_speed_vs_okeefe,0.6877181132500282}]}, {okeefe,[{runtime,12218}, {wall_clock,12218}, {runtime_speed_vs_ippolito,1.454084138156818}]}] -module(floor). -export([ippolito/1, okeefe/1]). -spec ippolito(float()) -> integer(). -spec okeefe (float()) -> integer(). -export([test/1]). -spec test(non_neg_integer()) -> term(). ippolito(X) -> T = trunc(X), case (X - T) of Neg when Neg < 0 -> T - 1; Pos when Pos > 0 -> T; _ -> T end. okeefe(X) -> T = trunc(X), if X < T -> T - 1 ; true -> T end. test(N) -> Tests = [{ippolito, fun ippolito/1}, {okeefe, fun okeefe/1}], Results = [ {Name, test(F, N)} || {Name, F} <- Tests ], _Report = lists:map(add_comparisons_to_others(Results), Results). test(F, N) -> Args = [-4.0, -2.75, -1.5, -0.1, 0.0, 1.1, 2.5, 3.75, 4.0], % Check to make sure results are accurate ResultsAreAccurate = lists:seq(-4, 4) == [F(X) || X <- Args], if ResultsAreAccurate -> ok end, Fun = fun() -> lists:foreach(F, Args) end, statistics(runtime), statistics(wall_clock), repeat(N, Fun), {_, RunTime} = statistics(runtime), {_, WallClockTime} = statistics(wall_clock), [ {runtime, RunTime}, {wall_clock, WallClockTime}]. repeat(0, _F) -> ok; repeat(N, F) -> F(), repeat(N - 1, F). filter_out(Name) -> fun ({OtherName, _}) when OtherName == Name -> false; (_) -> true end. filter_out(Name, List) -> lists:filter(filter_out(Name), List). add_comparisons_to_others(FullResults) -> fun({Name, Stats}) -> Others = filter_out(Name, FullResults), RunTime = proplists:get_value(runtime, Stats), Comparisons = [ {list_to_atom("runtime_speed_vs_" ++ atom_to_list(OtherName)), SpeedComparison} || {OtherName, OtherStats} <- Others , OtherRunTime <- [proplists:get_value(runtime, OtherStats)] , SpeedComparison <- [OtherRunTime / RunTime] ], {Name, Stats ++ Comparisons} end. Cheers, David -------------- next part -------------- An HTML attachment was scrubbed... URL: From koops.j@REDACTED Mon Mar 16 17:12:25 2009 From: koops.j@REDACTED (Jeroen Koops) Date: Mon, 16 Mar 2009 17:12:25 +0100 Subject: [erlang-questions] Why is this delete_object giving me an error? In-Reply-To: References: <8df32778-c495-45b9-9424-9a4fe0d14120@q9g2000yqc.googlegroups.com> <331a9abb0903160621l721bc5b1nde2f8d81078dd1b1@mail.gmail.com> Message-ID: <331a9abb0903160912n7480122fr5f9e9a0cef9561f2@mail.gmail.com> On Mon, Mar 16, 2009 at 3:18 PM, ryeguy wrote: > Oh, so is there no way to directly delete an object using a secondary > index? ID would be my primary index, so I would have to either : > A) Get the ID and delete by that with delete() or > B) Get the whole record and delete by that with delete_object()? > > Do I understand this correctly? You do - and typically, you would use delete_object only if your table is of type bag - otherwise, you'd always use delete. > > On Mar 16, 9:21 am, Jeroen Koops wrote: > > Hi, > > > > dirty_delete_object (and also delete_object) can only be used with a > > complete record - i.e. all fields must be filled in. It does not accept > > wildcard patterns. > > > > If you want to delete all user with a certain first name, you need an > index > > on the first_name attribute, query for all users with that first name > using > > mnesia:index_read or dirty_index_read, and finally manually delete all > > returned records with delete_object or delete. > > > > Regards, > > > > Jeroen > > > > On Mon, Mar 16, 2009 at 2:05 PM, ryeguy wrote: > > > I don't see what's wrong here, but I may just misunderstand the > > > syntax. I'm trying to delete a "user" record from my "user" mnesia > > > table who have the first name of "ryan" (there are multiples of them). > > > Here is what I do: > > > > > Delete=#user{first_name = "ryan", _ = '_'}, > > > mnesia:dirty_delete_object(Delete) > > > > > Here is my record definition: > > > -record(user, {id, > > > username, > > > password, > > > email, > > > first_name, > > > last_name, > > > last_login, % Date/time user last logged in > > > reg_date}). % Date/time user registered the > > > account > > > > > And here is the exception I'm getting: > > > ** exception exit: {aborted, > > > {bad_type,user, > > > {user,'_','_','_','_',"ryan",'_','_','_'}}} > > > in function mnesia:abort/1 > > > in call from users:register/1 > > > > > It seems like a perfect match. What could cause this problem? > > > > > _______________________________________________ > > > erlang-questions mailing list > > > erlang-questi...@REDACTED > > >http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questi...@REDACTED:// > 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 joe@REDACTED Mon Mar 16 17:14:45 2009 From: joe@REDACTED (Joe Williams) Date: Mon, 16 Mar 2009 09:14:45 -0700 Subject: [erlang-questions] Erlounge Seattle, Wednesday This Week. Message-ID: <49BE7AF5.7040406@joetify.com> *7pm, March 18th 2009 @ Fuel Coffee* 1705 N 45th St, Seattle, WA http://erloungeseattle.org/ See you there. -Joe -- Name: Joseph A. Williams Email: joe@REDACTED Blog: http://www.joeandmotorboat.com/ From brad@REDACTED Mon Mar 16 17:36:56 2009 From: brad@REDACTED (Brad Anderson) Date: Mon, 16 Mar 2009 12:36:56 -0400 Subject: [erlang-questions] Erlounge Atlanta, Wednesday March 25 Message-ID: <779B5797-4AA2-4776-AC37-157F818EA3AB@sankatygroup.com> Wednesday, March 25, 2009 7pm - Manuel's Tavern http://local.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=602+N+Highland+Ave+NE,+30307&sll=33.78571,-84.352684&sspn=0.338988,0.31208&ie=UTF8&ll=33.770729,-84.352598&spn=0.084762,0.07802&z=14&iwloc=addr Cheers, BA From erlang@REDACTED Mon Mar 16 20:38:23 2009 From: erlang@REDACTED (Joe Armstrong) Date: Mon, 16 Mar 2009 20:38:23 +0100 Subject: [erlang-questions] A tad confused about function parameters In-Reply-To: <33052B61-455E-474A-B1D9-011AB07FDEE2@lanl.gov> References: <33052B61-455E-474A-B1D9-011AB07FDEE2@lanl.gov> Message-ID: <9b08084c0903161238u65fe2ca6lf612c93f53c64b42@mail.gmail.com> Whenever you say F = fun() -> .... end. You create a closure (think of F as a pointer to a function, where the body of the function has not yet been evaluated). When you say F() you force evaluation of the function. spawn(F) creates a new process and then evaluates F() *within* the new process. so spawn(fun() -> ... self() .... end). means spawn a new process *then* evaluate ... self() ... *inside* the new process - thus self() is the Pid of the new process. S = self(), spawn(fun() -> ... S ... end) is different since S in evaluated in the parent process, then just passed as a variable into the closure. /Joe On Wed, Mar 11, 2009 at 11:31 PM, Allen McPherson wrote: > Here's a snippet of code that I'm using: > > %% ?Once nodes have been started we launch the code to execute the > %% ?benchmarks. > launch(L) -> > ? ? launch(L, []). > launch([], Pids) -> > ? ? Pids; > launch([H|T], Pids) -> > ? ? S = self(), ? ? ? ? ? ? % ?loop(self(), start) would evaluate > self() inside loop() function > ? ? launch(T, lists:append(Pids, [spawn(H, fun() -> loop(S, start) > end)])). > > %% ?Main benchmark loop. ?Receives request for particular type of test. > %% ?Spawns code to handle benchmark on its local node. > loop(MasterPid, Mode) -> > ? ? ... > > > The line in question is: > ? ? ? ? ? ?S = self(), > -----> ? ? launch(T, lists:append(Pids, [spawn(H, fun() -> loop(S, > start) end)])). > > I find that if I use: > > ? ? ? ? ? ?launch(T, lists:append(Pids, [spawn(H, fun() -> > loop(self(), start) end)])). > > instead, self() is evaluated everywhere in loop() that MasterPid occurs. > Intuitively I sort of get it, by formally I don't really understand > what's going on here...why the delayed evaluation? I would think it > would be > evaluate before the spawn, but it's getting evaluated after the spawn > on node > 'H'. > > Probably another dumb question, but can someone shed some light this. > It seems like a fundamental concept to understand. > > -- > Al > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From ok@REDACTED Tue Mar 17 00:15:28 2009 From: ok@REDACTED (Richard O'Keefe) Date: Tue, 17 Mar 2009 12:15:28 +1300 Subject: [erlang-questions] Floor Function? In-Reply-To: <4d08db370903160444x199b79d9k8264eb12d94f5c2@mail.gmail.com> References: <6a36e7290903131117q2e958422t4329dee19a3be7aa@mail.gmail.com> <4d08db370903160444x199b79d9k8264eb12d94f5c2@mail.gmail.com> Message-ID: <642498F1-4F6B-4451-B85A-C802C74A309E@cs.otago.ac.nz> I wrote: > There doesn't seem to be any reason to compute X-T. > On 17 Mar 2009, at 12:44 am, Hynek Vychodil wrote: > Are you sure that there is big difference between compute X-T and > decide X measured ... > This misses the point. The existing version requires 40 tokens, the simplified version requires 26. Never mind the computer, it's a heck of a lot easier for PEOPLE to think and to read. Again, the existing version does one subtraction and three comparisons, while the simplified version does one comparison. Never mind the computer, it's a heck of a lot easier for PEOPLE to think and to read. In general, there is a *correctness* issue in using X - Y when you really mean X Y. Just last week I had occasion to point out to someone that using static int intcmp(void const *x, void const *y) { return *(int const *)x - *(int const *)y; } as a comparison function in C's qsort() is *guaranteed* to give wrong answers. Thanks to bignums -- I don't know who decided that Erlang would have bignums but it was a really excellent decision -- Erlang doesn't have that particular problem, but there is a similar problem involving floats. That doesn't apply in this case either, but it _is_ enough of a problem that we do NOT want people to get into the habit of "comparing" numbers by subtracting them. It's FAR too error-prone. There are other reasons (simplicity, error-proneness) to prefer one approach to another than just machine efficiency. From tsuraan@REDACTED Tue Mar 17 04:05:54 2009 From: tsuraan@REDACTED (tsuraan) Date: Mon, 16 Mar 2009 22:05:54 -0500 Subject: [erlang-questions] Blocking send to port Message-ID: <84fb38e30903162005m2f0c62fbu195319e825a85954@mail.gmail.com> I have a program that wants to receive a constant stream of bytes on stdin so that it can forward them to an icecast server. Is there any way that the erlang process sending the data to that port program can block on writes (port_command calls), allowing me to write a really simple process that just gets data from its source and sends it to the port program at exactly the same rate that the port program consumes the data? From fritchie@REDACTED Tue Mar 17 06:50:06 2009 From: fritchie@REDACTED (Scott Lystig Fritchie) Date: Tue, 17 Mar 2009 00:50:06 -0500 Subject: [erlang-questions] How to examine binaries identified by erlang:memory/2? In-Reply-To: Message of "Sat, 14 Mar 2009 08:42:05 CDT." <49BBB42D.2060907@alertlogic.net> Message-ID: <44572.1237269006@snookles.snookles.com> Paul Fisher wrote: pf> My question: Is there any way to identify the "leaked" binaries? If pf> I could look at a few, it would probably be enough to figure out the pf> culprit immediately. Not that I'm aware of. However, I can suggest at least one place to start looking. (I've been bitten by this, very unpleasant, yes.) If I'm not wildly mistaken (and I could be, I really should be asleep right now), then doing this a few thousand times will "leak" a lot of memory, apparently in binaries. BigBin = list_to_binary(lists:duplicate(10*1024*1024, $x)), <<_:8777666/binary, Desired:90/binary, _/binary>> = BigBin, ets:insert(SomeTable, {SomeKey, ..., Desired, ...}), IIRC, according to section 4.1 of the Erlang Efficiency Guide, BigBin will be a reference counted binary. Desired will be a sub binary. Both will refer to the 10 MBytes in BigBin's blob area thingie handwaving really- ought-to-go-to-sleep. BigBin's ref count will be two and will drop to one after BigBin is GC'ed, but it won't drop to zero until the reference buried in the SomeTable ETS table goes away. If I've mangled the details, I hope a soul both enlightened and wide-awake can correct me. -Scott From fei@REDACTED Tue Mar 17 07:21:34 2009 From: fei@REDACTED (fei wang) Date: Tue, 17 Mar 2009 14:21:34 +0800 Subject: [erlang-questions] Mnesia create a table with a auto increase id? Message-ID: I am now using mnesia database, and I have a user table with record #users{ uid, username, password } Problem one is if a username is already in the table, it would not be inserted into the table. Should I first query the table to see if there is a same name in it? Any other good methods? Problem tow is the uid should be auto increased each insert time, I have no idea about this... Should I change the type of table to ordered-set, and query the last record's uid value, increase it by myself? If anyone have some good idea, or something about mnesia which I don't know, please tell me, thanks. Oizys -- -- --------------- ? ?? ?? -------------- next part -------------- An HTML attachment was scrubbed... URL: From jeffm@REDACTED Tue Mar 17 09:08:56 2009 From: jeffm@REDACTED (jm) Date: Tue, 17 Mar 2009 19:08:56 +1100 Subject: [erlang-questions] io:request/2 documentation? Message-ID: <49BF5A98.20005@ghostgun.com> Reading up on Leex and Yeec at http://hopper.squarespace.com/blog/2008/5/29/leex-and-yecc.html and it makes use of io:request/2 in one example. Yet there doesn't appear to any documentation for io:request/2. Is this another undocumented OTP function for insiders? Can this be used with a socket generated by gen_tcp? (I'm guessing not) and, if not, is there a suitable substitute for use with a tcp socket? Thanks, Jeff. From andreas.hillqvist@REDACTED Tue Mar 17 09:50:04 2009 From: andreas.hillqvist@REDACTED (Andreas Hillqvist) Date: Tue, 17 Mar 2009 09:50:04 +0100 Subject: [erlang-questions] Mnesia create a table with a auto increase id? In-Reply-To: References: Message-ID: <8268eea30903170150v239c400cu75466992c3df3a3e@mail.gmail.com> To auto increased uid you could use: mnesia:dirty_update_counter/3 (http://www.erlang.org/doc/man/mnesia.html#dirty_update_counter-3) Kind regards Andreas Hillqvist 2009/3/17 fei wang : > I am now using mnesia database, and I have a user table with record > #users{ > uid, > username, > password > } > Problem one is if a username is already in the table, it would not be > inserted into the table. Should I first query the table to see if there is a > same name in it? Any other good methods? > Problem tow is the uid should be auto increased each insert time, I have no > idea about this... Should I change the type of table to ordered-set, and > query the last record's uid value, increase it by myself? > If anyone have some good idea, or something about mnesia which I don't know, > please tell me, thanks. > > Oizys > -- > -- > > --------------- > ? > ?? > > > ?? > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From Justin.Pearson@REDACTED Tue Mar 17 10:17:48 2009 From: Justin.Pearson@REDACTED (Justin Pearson) Date: Tue, 17 Mar 2009 10:17:48 +0100 Subject: [erlang-questions] MacOSX 10.5, odbc, MySQL Message-ID: <18879.27324.607249.783658@yxan.it.uu.se> I am trying to use odbc to connect to a mysql database on Mac OSX 10.5. Here is what I did: 1) Installed the latest version of mysql community edition and 2) mysql odbc drivers. These I installed from the binary packages on mysql webpage. 3) I compiled erlang from source I ran ./configure --with-odbc before I compiled it. I've set up mysql added the users that I need. According to Mac OS's odbc browser I have a service myodbc which I can connect to using open office so it is alve. But when I try to use erlang I get the following: Eshell V5.6.5 (abort with ^G) 1> odbc:start(). ok 2> odbc:connect("DSN=myodbc;UID=justin;PWD=xxxxxx",[]). =ERROR REPORT==== 17-Mar-2009::10:09:02 === ODBC: received unexpected info: {tcp_closed,#Port<0.528>} =ERROR REPORT==== 17-Mar-2009::10:09:02 === ** Generic server <0.37.0> terminating ** Last message in was {#Port<0.526>,{exit_status,138}} ** When Server state == {state,#Port<0.526>, {<0.30.0>,#Ref<0.0.0.39>}, <0.30.0>,undefined,on,undefined,undefined,on, connecting,undefined,0, [#Port<0.524>,#Port<0.525>], #Port<0.527>,#Port<0.528>} ** Reason for termination == ** {port_exit,killed} {error,connection_closed} 3> I also get the same if I try odbc:connect("some_random_string",[]). So I suspect that I'm missing something fundamental? Thanks Justin Pearson From vychodil.hynek@REDACTED Tue Mar 17 10:23:37 2009 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Tue, 17 Mar 2009 10:23:37 +0100 Subject: [erlang-questions] Floor Function? In-Reply-To: <642498F1-4F6B-4451-B85A-C802C74A309E@cs.otago.ac.nz> References: <6a36e7290903131117q2e958422t4329dee19a3be7aa@mail.gmail.com> <4d08db370903160444x199b79d9k8264eb12d94f5c2@mail.gmail.com> <642498F1-4F6B-4451-B85A-C802C74A309E@cs.otago.ac.nz> Message-ID: <4d08db370903170223u5b080c32w87e948653e262dab@mail.gmail.com> You are right, computing X-T if you want know if X wrote: > I wrote: > >> There doesn't seem to be any reason to compute X-T. >> >> On 17 Mar 2009, at 12:44 am, Hynek Vychodil wrote: > >> Are you sure that there is big difference between compute X-T and decide >> X> >> This misses the point. > The existing version requires 40 tokens, > the simplified version requires 26. > Never mind the computer, it's a heck of a lot easier for PEOPLE > to think and to read. Again, the existing version does one > subtraction and three comparisons, while the simplified version > does one comparison. Never mind the computer, it's a heck of a > lot easier for PEOPLE to think and to read. > > In general, there is a *correctness* issue in using > X - Y when you really mean X Y. Just last week > I had occasion to point out to someone that using > static int intcmp(void const *x, void const *y) { > return *(int const *)x - *(int const *)y; > } > as a comparison function in C's qsort() is *guaranteed* to > give wrong answers. Thanks to bignums -- I don't know who > decided that Erlang would have bignums but it was a really > excellent decision -- Erlang doesn't have that particular > problem, but there is a similar problem involving floats. > That doesn't apply in this case either, but it _is_ enough > of a problem that we do NOT want people to get into the > habit of "comparing" numbers by subtracting them. It's FAR > too error-prone. > > There are other reasons (simplicity, error-proneness) to > prefer one approach to another than just machine efficiency. > > -- --Hynek (Pichi) Vychodil Analyze your data in minutes. Share your insights instantly. Thrill your boss. Be a data hero! Try Good Data now for free: www.gooddata.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From vychodil.hynek@REDACTED Tue Mar 17 10:28:18 2009 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Tue, 17 Mar 2009 10:28:18 +0100 Subject: [erlang-questions] How to examine binaries identified by erlang:memory/2? In-Reply-To: <44572.1237269006@snookles.snookles.com> References: <49BBB42D.2060907@alertlogic.net> <44572.1237269006@snookles.snookles.com> Message-ID: <4d08db370903170228oc336136v7aa9741865001a3d@mail.gmail.com> I have thought about same. It is unpleasant feature. On Tue, Mar 17, 2009 at 6:50 AM, Scott Lystig Fritchie < fritchie@REDACTED> wrote: > Paul Fisher wrote: > > pf> My question: Is there any way to identify the "leaked" binaries? If > pf> I could look at a few, it would probably be enough to figure out the > pf> culprit immediately. > > Not that I'm aware of. However, I can suggest at least one place to > start looking. (I've been bitten by this, very unpleasant, yes.) > > If I'm not wildly mistaken (and I could be, I really should be asleep > right now), then doing this a few thousand times will "leak" a lot of > memory, apparently in binaries. > > BigBin = list_to_binary(lists:duplicate(10*1024*1024, $x)), > <<_:8777666/binary, Desired:90/binary, _/binary>> = BigBin, > ets:insert(SomeTable, {SomeKey, ..., Desired, ...}), > > IIRC, according to section 4.1 of the Erlang Efficiency Guide, BigBin > will be a reference counted binary. Desired will be a sub binary. Both > will refer to the 10 MBytes in BigBin's blob area thingie handwaving > really- ought-to-go-to-sleep. BigBin's ref count will be two and will > drop to one after BigBin is GC'ed, but it won't drop to zero until the > reference buried in the SomeTable ETS table goes away. > > If I've mangled the details, I hope a soul both enlightened and > wide-awake can correct me. > > -Scott > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- --Hynek (Pichi) Vychodil Analyze your data in minutes. Share your insights instantly. Thrill your boss. Be a data hero! Try Good Data now for free: www.gooddata.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From rapsey@REDACTED Tue Mar 17 10:45:09 2009 From: rapsey@REDACTED (Rapsey) Date: Tue, 17 Mar 2009 10:45:09 +0100 Subject: [erlang-questions] MacOSX 10.5, odbc, MySQL In-Reply-To: <18879.27324.607249.783658@yxan.it.uu.se> References: <18879.27324.607249.783658@yxan.it.uu.se> Message-ID: <97619b170903170245l2c3de075h69b0002979aa5e72@mail.gmail.com> Are you sure you want to use odbc for this? I know there are a few erlang mysql libraries. They are probably faster. Sergej On Tue, Mar 17, 2009 at 10:17 AM, Justin Pearson wrote: > > I am trying to use odbc to connect to a mysql database on Mac OSX > 10.5. > > Here is what I did: > 1) Installed the latest version of mysql community edition and > 2) mysql odbc drivers. These I installed from the binary packages on > mysql webpage. > > 3) I compiled erlang from source I ran ./configure --with-odbc > before I compiled it. > > I've set up mysql added the users that I need. According to Mac OS's > odbc browser I have a service myodbc which I can connect to using open > office so it is alve. > > But when I try to use erlang I get the following: > > > Eshell V5.6.5 (abort with ^G) > 1> odbc:start(). > ok > 2> odbc:connect("DSN=myodbc;UID=justin;PWD=xxxxxx",[]). > > =ERROR REPORT==== 17-Mar-2009::10:09:02 === > ODBC: received unexpected info: {tcp_closed,#Port<0.528>} > > > =ERROR REPORT==== 17-Mar-2009::10:09:02 === > ** Generic server <0.37.0> terminating > ** Last message in was {#Port<0.526>,{exit_status,138}} > ** When Server state == {state,#Port<0.526>, > {<0.30.0>,#Ref<0.0.0.39>}, > <0.30.0>,undefined,on,undefined,undefined,on, > connecting,undefined,0, > [#Port<0.524>,#Port<0.525>], > #Port<0.527>,#Port<0.528>} > ** Reason for termination == > ** {port_exit,killed} > {error,connection_closed} > 3> > > > > > I also get the same if I try > odbc:connect("some_random_string",[]). > > So I suspect that I'm missing something fundamental? > > > Thanks > > Justin Pearson > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From freza@REDACTED Tue Mar 17 11:13:33 2009 From: freza@REDACTED (Jachym Holecek) Date: Tue, 17 Mar 2009 11:13:33 +0100 Subject: [erlang-questions] Blocking send to port In-Reply-To: <84fb38e30903162005m2f0c62fbu195319e825a85954@mail.gmail.com> References: <84fb38e30903162005m2f0c62fbu195319e825a85954@mail.gmail.com> Message-ID: <20090317101333.GA1425@hanele> # tsuraan 2009-03-17: > I have a program that wants to receive a constant stream of bytes on > stdin so that it can forward them to an icecast server. Is there any > way that the erlang process sending the data to that port program can > block on writes (port_command calls), allowing me to write a really > simple process that just gets data from its source and sends it to the > port program at exactly the same rate that the port program consumes > the data? Have the port program acknowledge incoming data via stdout after it has forwarded them to icecast server? HTH, -- Jachym From alex.arnon@REDACTED Tue Mar 17 12:52:11 2009 From: alex.arnon@REDACTED (Alex Arnon) Date: Tue, 17 Mar 2009 13:52:11 +0200 Subject: [erlang-questions] Solaris 10 build problems. Message-ID: <944da41d0903170452x654c0942wd1953cab767c925c@mail.gmail.com> Hi All, I'm trying to build R12B5 on an i386 Solaris 10, with no success. Uname -a is: SunOS teja 5.10 Generic_137138-09 i86pc i386 i86pc Solaris 1. Running ./configure with only -prefix will set it to use '/opt/SUNWspro/bin/cc' as the compiler, which then fails during compilation: ... "beam/beam_emu.c", line 5230: warning: operands have incompatible pointer types: op "!=" "beam/beam_emu.c", line 5893: warning: statement not reached cc: acomp failed for beam/beam_emu.c gmake[3]: *** [obj/i386-pc-solaris2.10/opt/plain/beam_emu.o] Error 2 gmake[3]: Leaving directory `/home/alex/devel/erlang/build/otp_src_R12B-5/erts/emulator' gmake[2]: *** [opt] Error 2 ... 2. Setting environment variable CC to 'gcc' or '/usr/sfw/bin/gcc' (ver. 3.4.3 or 3.4.5) cause configure to blow up with: alex@REDACTED:~/devel/erlang/build/otp_src_R12B-5% time ./configure --prefix=/home/alex/devel/erlang/r12b5 Ignoring the --cache-file argument since it can cause the system to be erroneously configured Disabling caching checking build system type... i386-pc-solaris2.10 checking host system type... i386-pc-solaris2.10 checking for gcc... gcc checking for C compiler default output file name... configure: error: C compiler cannot create executables See `config.log' for more details. ... config.log's tail is: ## confdefs.h. ## ## ----------- ## #define PACKAGE_BUGREPORT "" #define PACKAGE_NAME "" #define PACKAGE_STRING "" #define PACKAGE_TARNAME "" #define PACKAGE_VERSION "" configure: exit 77 I have tried to compile a small C program using gcc - it works. So, why does configure decide it's no good...? Regards, Alex. -------------- next part -------------- An HTML attachment was scrubbed... URL: From pfisher@REDACTED Tue Mar 17 13:31:38 2009 From: pfisher@REDACTED (Paul Fisher) Date: Tue, 17 Mar 2009 07:31:38 -0500 Subject: [erlang-questions] How to examine binaries identified by erlang:memory/2? In-Reply-To: <44572.1237269006@snookles.snookles.com> References: <44572.1237269006@snookles.snookles.com> Message-ID: <49BF982A.4060309@alertlogic.net> Scott Lystig Fritchie wrote: > Paul Fisher wrote: > > pf> My question: Is there any way to identify the "leaked" binaries? If > pf> I could look at a few, it would probably be enough to figure out the > pf> culprit immediately. > > Not that I'm aware of. However, I can suggest at least one place to > start looking. (I've been bitten by this, very unpleasant, yes.) > > If I'm not wildly mistaken (and I could be, I really should be asleep > right now), then doing this a few thousand times will "leak" a lot of > memory, apparently in binaries. > > BigBin = list_to_binary(lists:duplicate(10*1024*1024, $x)), > <<_:8777666/binary, Desired:90/binary, _/binary>> = BigBin, > ets:insert(SomeTable, {SomeKey, ..., Desired, ...}), Thank you for this suggestion. I will see if this is the cause of my issue and report back. -- paul From bgustavsson@REDACTED Tue Mar 17 16:57:54 2009 From: bgustavsson@REDACTED (Bjorn Gustavsson) Date: Tue, 17 Mar 2009 16:57:54 +0100 Subject: [erlang-questions] Erlang/OTP R13A has been released Message-ID: <6672d0160903170857y6c4435fctcdc4b0b9f6d67a5a@mail.gmail.com> Major relese : otp_src_R13A Build date : 2009-03-17 R13A is a beta release of the next R13B major release. We do not recommend it for use in live products. In the R13B release, there may be incompatibilities in new features that were introduced in this R13A release (for instance in the Unicode support). You can download the full source distribution from http://www.erlang.org/download/otp_src_R13A.tar.gz http://www.erlang.org/download/otp_src_R13A.readme (this file) Note: To unpack the TAR archive you need a GNU TAR compatible program. For installation instructions please read the README that is part of the distribution. The Windows binary distribution can be downloaded from http://www.erlang.org/download/otp_win32_R13A.exe On-line documentation can be found at http://www.erlang.org/doc/. You can also download the complete HTML documentation or the Unix manual files http://www.erlang.org/download/otp_doc_html_R13A.tar.gz http://www.erlang.org/download/otp_doc_man_R13A.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 rob.charlton@REDACTED Tue Mar 17 17:56:45 2009 From: rob.charlton@REDACTED (Rob Charlton) Date: Tue, 17 Mar 2009 16:56:45 +0000 Subject: [erlang-questions] Hang making https request Message-ID: <49BFD64D.2070308@savageminds.com> I have been using Erlang R11B for some time, but thought it was about time I moved up to R12B, so I pulled down the latest today and built it. Afterwards, I found that I could no longer make HTTPS requests: rob@REDACTED:~/work/erlang/svn/erlang/lcr$ erl Erlang (BEAM) emulator version 5.6.5 [source] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.6.5 (abort with ^G) 1> inets:start(). ok 2> http:request("https://www.cia.gov/"). The shell is now unresponsive and I have to do a CTRL C to get it back. I noticed that I had to now explicitly start inets (which used to start automatically) because an error message appeared when I did an http request without it started. What I didn't realise was that I also had to explicitly start the ssl application. I managed to work this out by using tracing on the http call. It won't catch me again, but will probably catch someone else. Would it be possible to make it do something more friendly than just hang? -- Rob Charlton Savage Minds Ltd From ferenc.holzhauser@REDACTED Tue Mar 17 18:07:00 2009 From: ferenc.holzhauser@REDACTED (Ferenc Holzhauser) Date: Tue, 17 Mar 2009 18:07:00 +0100 Subject: [erlang-questions] Hang making https request In-Reply-To: <49BFD64D.2070308@savageminds.com> References: <49BFD64D.2070308@savageminds.com> Message-ID: Rob, You'd need to start ssl too for HTTPS. Regards, Ferenc 2009/3/17 Rob Charlton > I have been using Erlang R11B for some time, but thought it was about > time I moved up to R12B, so I pulled down the latest today and built it. > > Afterwards, I found that I could no longer make HTTPS requests: > > rob@REDACTED:~/work/erlang/svn/erlang/lcr$ erl > Erlang (BEAM) emulator version 5.6.5 [source] [async-threads:0] [hipe] > [kernel-poll:false] > > Eshell V5.6.5 (abort with ^G) > 1> inets:start(). > ok > 2> http:request("https://www.cia.gov/"). > > The shell is now unresponsive and I have to do a CTRL C to get it back. > > I noticed that I had to now explicitly start inets (which used to start > automatically) because an error message appeared when I did an http > request without it started. What I didn't realise was that I also had to > explicitly start the ssl application. I managed to work this out by > using tracing on the http call. It won't catch me again, but will > probably catch someone else. Would it be possible to make it do > something more friendly than just hang? > > -- > Rob Charlton > Savage Minds Ltd > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From matthew@REDACTED Tue Mar 17 19:02:20 2009 From: matthew@REDACTED (Matthew Dempsky) Date: Tue, 17 Mar 2009 11:02:20 -0700 Subject: [erlang-questions] Reassigning variables Message-ID: I like pattern matching in the majority of cases, but I find I write enough code where I need to incrementally update a data structure, and maintaining that code is a pain when I have code like: X = foo(), X1 = bar(X), X2 = xyzzy(X1), blah(X2). and later want to change it to: X = foo(), X1 = whee(X), X2 = bar(X1), X3 = xyzzy(X2), blah(X3). This means having to change four lines of code, when really it's conceptually just one change. I'd like to suggest being able to do something like: X = foo(), r(X) = whee(X), r(X) = bar(X), r(X) = xyzzy(X), blah(X). where "r(?VAR) = ?EXPR" means to reassign ?VAR to ?EXPR, even if it previously has an assigned value. Thoughts? Does anyone have suggestions for better syntax? I think this can be handled with a parse transform, and I'm considering writing a parse transform to handle it. (I haven't checked if anyone else has proposed similar functionality in the past, but this is something that's been bugging me for a while, and I've finally had to rename variables manually enough times to propose this.) From harveyd@REDACTED Tue Mar 17 19:15:05 2009 From: harveyd@REDACTED (Dale Harvey) Date: Tue, 17 Mar 2009 18:15:05 +0000 Subject: [erlang-questions] Reassigning variables In-Reply-To: References: Message-ID: steve vinoski mentioned this solution in his reply to damien katz finding the same problem. http://steve.vinoski.net/blog/2008/03/10/damien-katz-criticizes-erlang/ f(X) -> lists:foldl(fun(F, Last) -> F(Last) end, foo(), [fun whee/1, fun bar/1, fun xyzzy/1]). 2009/3/17 Matthew Dempsky > I like pattern matching in the majority of cases, but I find I write > enough code where I need to incrementally update a data structure, and > maintaining that code is a pain when I have code like: > > X = foo(), > X1 = bar(X), > X2 = xyzzy(X1), > blah(X2). > > and later want to change it to: > > X = foo(), > X1 = whee(X), > X2 = bar(X1), > X3 = xyzzy(X2), > blah(X3). > > This means having to change four lines of code, when really it's > conceptually just one change. I'd like to suggest being able to do > something like: > > X = foo(), > r(X) = whee(X), > r(X) = bar(X), > r(X) = xyzzy(X), > blah(X). > > where "r(?VAR) = ?EXPR" means to reassign ?VAR to ?EXPR, even if it > previously has an assigned value. > > Thoughts? Does anyone have suggestions for better syntax? I think > this can be handled with a parse transform, and I'm considering > writing a parse transform to handle it. (I haven't checked if anyone > else has proposed similar functionality in the past, but this is > something that's been bugging me for a while, and I've finally had to > rename variables manually enough times to propose this.) > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From matthew@REDACTED Tue Mar 17 19:21:00 2009 From: matthew@REDACTED (Matthew Dempsky) Date: Tue, 17 Mar 2009 11:21:00 -0700 Subject: [erlang-questions] Reassigning variables In-Reply-To: References: Message-ID: On Tue, Mar 17, 2009 at 11:15 AM, Dale Harvey wrote: > f(X) -> > lists:foldl(fun(F, Last) -> F(Last) end, > foo(), [fun whee/1, fun bar/1, fun xyzzy/1]). I think this in an inadequate solution. Not all code is as simple as I described: some functions output multiple values, only one of which is the new value for X; some functions take arguments other than X; sometimes other functions need to be called in between the function calls that update X. From thomasl_erlang@REDACTED Tue Mar 17 20:51:50 2009 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Tue, 17 Mar 2009 12:51:50 -0700 (PDT) Subject: [erlang-questions] Reassigning variables In-Reply-To: References: Message-ID: <562945.51051.qm@web111402.mail.gq1.yahoo.com> ----- Original Message ---- > From: Matthew Dempsky > ... I'd like to suggest being able to do > something like: > > X = foo(), > r(X) = whee(X), > r(X) = bar(X), > r(X) = xyzzy(X), > blah(X). > > where "r(?VAR) = ?EXPR" means to reassign ?VAR to ?EXPR, even if it > previously has an assigned value. > > Thoughts? Does anyone have suggestions for better syntax? I think > this can be handled with a parse transform, and I'm considering > writing a parse transform to handle it. (I haven't checked if anyone > else has proposed similar functionality in the past, but this is > something that's been bugging me for a while, and I've finally had to > rename variables manually enough times to propose this.) The easy way out is -define(let(Pat, Val, Body), (fun(Pat) -> Body end)(Val)). and ?let(X, foo(), ?let(r(X), whee(X), ...)). Best, Thomas From rvirding@REDACTED Tue Mar 17 20:54:10 2009 From: rvirding@REDACTED (Robert Virding) Date: Tue, 17 Mar 2009 20:54:10 +0100 Subject: [erlang-questions] io:request/2 documentation? In-Reply-To: <49BF5A98.20005@ghostgun.com> References: <49BF5A98.20005@ghostgun.com> Message-ID: <3dbc6d1c0903171254x1be73b99w20aa8813a2d2c388@mail.gmail.com> Hi Jeff, No io:request/2 has not been documented yet. All it does is to send off a request to an io-server and wait for the reply. One reason for not having documented it is that up until very recently the io-server protocol has not been documented. This has now changed. In January I wrote a description of the older io-server protocol. This description was included in my Erlang Rationale document which you can find in the User Contributions section of trapexit.org. A truly brilliant piece of writing. .-) There is now also a freshly written description of the newer io-server protocol which is included in the documentation of the just released version R13-A in the user's guide section of stdlib. The newer protocol is very similar to the older one, the main change is providing for some extra parameters for handling unicode. You use io:request/2 in the same manner as it is shown in the leex and yecc blogg. A very good description by the way. It can *NOT* be directly used with a gen_tcp generated socket. An io-server is a process which obeys the io-server protocol. It would, however, not be very difficult to write an io-server which could directly read/write against a gen_tcp socket. If someone could show me a preferred way of setting up and talking to a socket I can fix the io-server. Hope this helps a little, Robert 2009/3/17 jm > Reading up on Leex and Yeec at > http://hopper.squarespace.com/blog/2008/5/29/leex-and-yecc.html and it > makes use of io:request/2 in one example. Yet there doesn't appear to > any documentation for io:request/2. Is this another undocumented OTP > function for insiders? Can this be used with a socket generated by > gen_tcp? (I'm guessing not) and, if not, is there a suitable substitute > for use with a tcp socket? > > Thanks, > Jeff. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tony@REDACTED Tue Mar 17 21:05:04 2009 From: tony@REDACTED (Tony Arcieri) Date: Tue, 17 Mar 2009 14:05:04 -0600 Subject: [erlang-questions] Reassigning variables In-Reply-To: References: Message-ID: On Tue, Mar 17, 2009 at 12:02 PM, Matthew Dempsky wrote: > I think this can be handled with a parse transform, and I'm considering > writing a parse transform to handle it. (I haven't checked if anyone > else has proposed similar functionality in the past, but this is > something that's been bugging me for a while, and I've finally had to > rename variables manually enough times to propose this.) > Reia (http://wiki.reia-lang.org/) certainly does something similar. It implements destructive assignment by transforming code into static single assignment form. All variables are versioned, and wherever variables are destructively assigned the version number is incremented. It works just fine, aside from the normal caveats associated with destructive assignment. -- Tony Arcieri medioh.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From masse@REDACTED Tue Mar 17 21:21:29 2009 From: masse@REDACTED (mats cronqvist) Date: Tue, 17 Mar 2009 21:21:29 +0100 Subject: [erlang-questions] Reassigning variables In-Reply-To: (Matthew Dempsky's message of "Tue\, 17 Mar 2009 11\:02\:20 -0700") References: Message-ID: <87prgfkiie.fsf@sterlett.hq.kred> Matthew Dempsky writes: > I like pattern matching in the majority of cases, but I find I write > enough code where I need to incrementally update a data structure, and > maintaining that code is a pain when I have code like: > > X = foo(), > X1 = bar(X), > X2 = xyzzy(X1), > blah(X2). > > and later want to change it to: > > X = foo(), > X1 = whee(X), > X2 = bar(X1), > X3 = xyzzy(X2), > blah(X3). Apologies in advance for calling you a noob. But in my experience, all beginners start off writing code like the above. Whereas seasoned Erlangers produce something more like this; x() -> blah_it(xyzzy(make_whee(foo()))). make_whee(X) -> case whee(X) of {A,B} -> bar(A); {A,B,C}-> bar(A) end. blah_it(X) when is_atom(X) -> blah(X); blah_it(X) when is_list(X) -> blah(list_to_atom(X)). I've added some stuff to your example to make it less trivial, but it's basically the same. So I think the X1 = f(X), X2 = f(X1) anti-pattern is not a weakness of the language; it's Erlang's way of telling you that you should use more functions. mats From matthew@REDACTED Tue Mar 17 21:32:00 2009 From: matthew@REDACTED (Matthew Dempsky) Date: Tue, 17 Mar 2009 13:32:00 -0700 Subject: [erlang-questions] Reassigning variables In-Reply-To: References: Message-ID: On Tue, Mar 17, 2009 at 11:02 AM, Matthew Dempsky wrote: > I think this can be handled with a parse transform, and I'm > considering writing a parse transform to handle it. Below is a proof of concept of this. I've only minimally tested this out, but here's a working example: -module(foo). -compile({parse_transform, reassign_pt}). -export([bar/0]). bar() -> X = 0, r(X) = X + 1, r(X) = X + 2, r(X) = X + 3, X. And running it: 1> c(reassign_pt). {ok,reassign_pt} 2> c(foo). {ok,foo} 3> foo:bar(). 6 -module(reassign_pt). -author("Matthew Dempsky "). -export([parse_transform/2]). -define(KEY, 'reassign_pt:gensym'). parse_transform(Forms, _Options) -> NewForms = erl_syntax:revert_forms( [transform(F) || F <- Forms]), erase(?KEY), NewForms. transform(Form) -> {NewForm, _Acc} = erl_syntax_lib:mapfold_subtrees(fun transform/2, ordsets:new(), Form), NewForm. transform(Form, Renames) -> try case erl_syntax:type(Form) of variable -> Name = erl_syntax:variable_name(Form), {ok, Value} = orddict:find(Name, Renames), {Value, Renames}; match_expr -> Pattern = erl_syntax:match_expr_pattern(Form), Body = erl_syntax:match_expr_body(Form), application = erl_syntax:type(Pattern), Operator = erl_syntax:application_operator(Pattern), atom = erl_syntax:type(Operator), r = erl_syntax:atom_value(Operator), [Var] = erl_syntax:application_arguments(Pattern), VarName = erl_syntax:variable_name(Var), {NewBody, NewRenames} = transform(Body, Renames), NewVar = erl_syntax:variable(atom_to_list(VarName) ++ "." ++ gensym()), NewAssign = erl_syntax:match_expr(NewVar, NewBody), {NewAssign, orddict:store(VarName, NewVar, NewRenames)} end catch error:{case_clause, _Expr} -> erl_syntax_lib:mapfold_subtrees(fun transform/2, Renames, Form); error:{badmatch, _Expr} -> erl_syntax_lib:mapfold_subtrees(fun transform/2, Renames, Form) end. gensym() -> N = case get(?KEY) of undefined -> 1; V -> V end, put(?KEY, N + 1), "reassign_pt:var_" ++ integer_to_list(N). From justin@REDACTED Tue Mar 17 21:38:15 2009 From: justin@REDACTED (Justin Sheehy) Date: Tue, 17 Mar 2009 15:38:15 -0500 Subject: [erlang-questions] Reassigning variables In-Reply-To: References: Message-ID: <879778450903171338j5f47e27fm6b6016906dff0159@mail.gmail.com> On Tue, Mar 17, 2009 at 1:02 PM, Matthew Dempsky wrote: > ?X = foo(), > ?X1 = bar(X), > ?X2 = xyzzy(X1), > ?blah(X2). > and later want to change it to: > > ?X = foo(), > ?X1 = whee(X), > ?X2 = bar(X1), > ?X3 = xyzzy(X2), > ?blah(X3). So, what you really wanted was to change: blah(xyzzy(bar(foo()))). to: blah(xyzzy(bar(whee(foo())))). What's the trouble, exactly? > This means having to change four lines of code, when really it's > conceptually just one change. Every time I've run into something like this, I've found that the real solution was to make the program use less intermediate variables. Single assignment is one of the biggest ways in which Erlang helps reduce bugs. Please don't try to introduce ways around it, as they will make programs worse. -Justin p.s. -- (just saw reply from mats) -- Agreed: even when you seem to need intermediate variables, you often can do even better with intermediating functions instead. From peter@REDACTED Tue Mar 17 22:11:51 2009 From: peter@REDACTED (Peter Sabaini) Date: Tue, 17 Mar 2009 22:11:51 +0100 Subject: [erlang-questions] Reassigning variables In-Reply-To: <87prgfkiie.fsf@sterlett.hq.kred> References: <87prgfkiie.fsf@sterlett.hq.kred> Message-ID: <200903172211.57830.peter@sabaini.at> On Tuesday 17 March 2009 21:21:29 mats cronqvist wrote: > Matthew Dempsky writes: > > I like pattern matching in the majority of cases, but I find I write > > enough code where I need to incrementally update a data structure, and > > maintaining that code is a pain when I have code like: > > > > X = foo(), > > X1 = bar(X), > > X2 = xyzzy(X1), > > blah(X2). > > > > and later want to change it to: > > > > X = foo(), > > X1 = whee(X), > > X2 = bar(X1), > > X3 = xyzzy(X2), > > blah(X3). > > Apologies in advance for calling you a noob. You can call me a noob, I don't mind ;-) > But in my experience, all beginners start off writing code like the > above. Whereas seasoned Erlangers produce something more like this; > > x() -> > blah_it(xyzzy(make_whee(foo()))). IMHO intermediate values are sometimes quite useful if not necessary -- I often find myself needing to break up some such nested function calls just for a temporary ?debugFmt() or logging call -- this is a bit of a nuisance. This is compounded by the fact that often the punctuation needs to change too in such cases. Note I'm not advocating mutable vars, I'm fine with hand-versioning my vars, but it *does* add a bit of typing. peter. > make_whee(X) -> > case whee(X) of > {A,B} -> bar(A); > {A,B,C}-> bar(A) > end. > > blah_it(X) when is_atom(X) -> blah(X); > blah_it(X) when is_list(X) -> blah(list_to_atom(X)). > > > I've added some stuff to your example to make it less trivial, but > it's basically the same. > > So I think the X1 = f(X), X2 = f(X1) anti-pattern is not a weakness > of the language; it's Erlang's way of telling you that you should > use more functions. > > mats -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 197 bytes Desc: This is a digitally signed message part. URL: From matthew@REDACTED Tue Mar 17 22:19:48 2009 From: matthew@REDACTED (Matthew Dempsky) Date: Tue, 17 Mar 2009 14:19:48 -0700 Subject: [erlang-questions] Reassigning variables In-Reply-To: <879778450903171338j5f47e27fm6b6016906dff0159@mail.gmail.com> References: <879778450903171338j5f47e27fm6b6016906dff0159@mail.gmail.com> Message-ID: On Tue, Mar 17, 2009 at 1:38 PM, Justin Sheehy wrote: > Single assignment is one of the biggest ways in which Erlang helps > reduce bugs. ?Please don't try to introduce ways around it, as they > will make programs worse. I disagree. There are ways that reassignment can make code easier to analyze, but I'm not suggesting people use reassignment in those cases. Similarly, Erlang doesn't support 'return', but our ad server has enough business logic where the code would be much simpler if it did. We had some code that was effectively: if requested ad size is bad: return {skip, bad_size} if the game has ads disabled: return {skip, disabled} if the game is filtering a domain: return {skip, domain_filtered} return choose_ad() I rewrote this code in 'Erlang style' with a list of funs to check, and to short-circuit on the first that returns a skip, when I last added to it, and so incrementally it's much less work to add new checks than the old code. But it's stupid. I'm not going to add 100 new checks, there's only a handful now, and there will almost certainly never be more than a handful more in the future. Rewriting 10 lines of code to be 60 lines of code (having to define a new function for each check, having to add code to handle the list of check funs, etc.) to deal with Erlang's language limitations does not help with readability. (In contrast, we similarly redesigned the per-campaign and per-ad filtering code to use this style, and they do update much more frequently, and it actually has been beneficial allowing us to dynamically change what lists of filters are applied in different situations. But not everything merits that complexity.) Programmers understand how variable reassignment and multiple function call returns work: every beginner programming language includes them. From vances@REDACTED Tue Mar 17 22:42:58 2009 From: vances@REDACTED (Vance Shipley) Date: Tue, 17 Mar 2009 17:42:58 -0400 Subject: [erlang-questions] Reassigning variables In-Reply-To: References: <879778450903171338j5f47e27fm6b6016906dff0159@mail.gmail.com> Message-ID: <20090317214258.GQ32606@h216-235-12-174.host.egate.net> On Tue, Mar 17, 2009 at 02:19:48PM -0700, Matthew Dempsky wrote: } Similarly, Erlang doesn't support 'return' Doesn't it? } if requested ad size is bad: } return {skip, bad_size} } if the game has ads disabled: } return {skip, disabled} } if the game is filtering a domain: } return {skip, domain_filtered} } return choose_ad() try begin case requested_ad_size(Size) of bad -> throw(bad_size); _ -> ok end, case has_ads() of true -> throw(disabled); false -> ok end, case is_filtering() of true -> throw(domain_filtered); false -> ok end end of ok -> yahoo catch Problem -> Problem end -- -Vance From tony@REDACTED Tue Mar 17 22:48:21 2009 From: tony@REDACTED (Tony Arcieri) Date: Tue, 17 Mar 2009 15:48:21 -0600 Subject: [erlang-questions] Reassigning variables In-Reply-To: <20090317214258.GQ32606@h216-235-12-174.host.egate.net> References: <879778450903171338j5f47e27fm6b6016906dff0159@mail.gmail.com> <20090317214258.GQ32606@h216-235-12-174.host.egate.net> Message-ID: On Tue, Mar 17, 2009 at 3:42 PM, Vance Shipley wrote: > try begin > case requested_ad_size(Size) of > bad -> > throw(bad_size); > _ -> > ok > end, > case has_ads() of > true -> > throw(disabled); > false -> > ok > end, > case is_filtering() of > true -> > throw(domain_filtered); > false -> > ok > end > end of > ok -> > yahoo > catch > Problem -> > Problem > end > Very cool. Thanks for this suggestion. -- Tony Arcieri medioh.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From bqt@REDACTED Tue Mar 17 22:53:21 2009 From: bqt@REDACTED (Johnny Billquist) Date: Tue, 17 Mar 2009 22:53:21 +0100 Subject: [erlang-questions] Reassigning variables In-Reply-To: References: <879778450903171338j5f47e27fm6b6016906dff0159@mail.gmail.com> Message-ID: <49C01BD1.4050305@softjar.se> Matthew Dempsky wrote: > On Tue, Mar 17, 2009 at 1:38 PM, Justin Sheehy wrote: >> Single assignment is one of the biggest ways in which Erlang helps >> reduce bugs. Please don't try to introduce ways around it, as they >> will make programs worse. > > I disagree. There are ways that reassignment can make code easier to > analyze, but I'm not suggesting people use reassignment in those > cases. > > Similarly, Erlang doesn't support 'return', but our ad server has > enough business logic where the code would be much simpler if it did. > We had some code that was effectively: > > if requested ad size is bad: > return {skip, bad_size} > if the game has ads disabled: > return {skip, disabled} > if the game is filtering a domain: > return {skip, domain_filtered} > return choose_ad() > > I rewrote this code in 'Erlang style' with a list of funs to check, > and to short-circuit on the first that returns a skip, when I last > added to it, and so incrementally it's much less work to add new > checks than the old code. Huh? What's wrong with coding that in Erlang as: foo() -> if requested ad size is bad -> {skip, bad_size}; the game has ads disabled -> {skip, disabled}; the game is filtering a domain -> {skip, domain_filtered}; _ -> choose_ad() end. Johnny -- Johnny Billquist || "I'm on a bus || on a psychedelic trip email: bqt@REDACTED || Reading murder books pdp is alive! || tryin' to stay hip" - B. Idol From taavi@REDACTED Tue Mar 17 22:54:04 2009 From: taavi@REDACTED (Taavi Talvik) Date: Tue, 17 Mar 2009 23:54:04 +0200 Subject: [erlang-questions] Reassigning variables In-Reply-To: References: <879778450903171338j5f47e27fm6b6016906dff0159@mail.gmail.com> Message-ID: <9C1ED692-50FA-4D45-B28C-4ADC066BD3F7@uninet.ee> On Mar 17, 2009, at 11:19 PM, Matthew Dempsky wrote: > On Tue, Mar 17, 2009 at 1:38 PM, Justin Sheehy > wrote: >> Single assignment is one of the biggest ways in which Erlang helps >> reduce bugs. Please don't try to introduce ways around it, as they >> will make programs worse. > > I disagree. There are ways that reassignment can make code easier to > analyze, but I'm not suggesting people use reassignment in those > cases. > > Similarly, Erlang doesn't support 'return', but our ad server has > enough business logic where the code would be much simpler if it did. > We had some code that was effectively: > > if requested ad size is bad: > return {skip, bad_size} > if the game has ads disabled: > return {skip, disabled} > if the game is filtering a domain: > return {skip, domain_filtered} > return choose_ad() Hmm.. if ad size is bad: throw {skip, bad_size} if disabled: throw {skip, disabled} {serve_ad, choose_ad()} best regards, taavi From tony@REDACTED Tue Mar 17 23:23:59 2009 From: tony@REDACTED (Tony Arcieri) Date: Tue, 17 Mar 2009 16:23:59 -0600 Subject: [erlang-questions] Reassigning variables In-Reply-To: <49C01BD1.4050305@softjar.se> References: <879778450903171338j5f47e27fm6b6016906dff0159@mail.gmail.com> <49C01BD1.4050305@softjar.se> Message-ID: On Tue, Mar 17, 2009 at 3:53 PM, Johnny Billquist wrote: > Huh? What's wrong with coding that in Erlang as: > > foo() -> > if > requested ad size is bad -> > {skip, bad_size}; > the game has ads disabled -> > {skip, disabled}; > the game is filtering a domain -> > {skip, domain_filtered}; > _ -> > choose_ad() > end. > > Johnny > It sounds from his description like the pseudocoded conditions are a bit more involved than just a guard. -- Tony Arcieri medioh.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From bqt@REDACTED Tue Mar 17 23:42:21 2009 From: bqt@REDACTED (Johnny Billquist) Date: Tue, 17 Mar 2009 23:42:21 +0100 Subject: [erlang-questions] Reassigning variables In-Reply-To: References: <879778450903171338j5f47e27fm6b6016906dff0159@mail.gmail.com> <49C01BD1.4050305@softjar.se> Message-ID: <49C0274D.5030508@softjar.se> Tony Arcieri wrote: > On Tue, Mar 17, 2009 at 3:53 PM, Johnny Billquist > wrote: > > Huh? What's wrong with coding that in Erlang as: > > foo() -> > if > requested ad size is bad -> > {skip, bad_size}; > the game has ads disabled -> > {skip, disabled}; > the game is filtering a domain -> > {skip, domain_filtered}; > _ -> > choose_ad() > end. > > Johnny > > > It sounds from his description like the pseudocoded conditions are a bit > more involved than just a guard. Well, you can achieve the same with nexted case statements, which removes the restrictions frmo guards, if that is needed. The value of a function is always the value of the last "statement", and that can be different things without problems. And executing a specific branch of code is not something magic. The multiple return stateents seems to me like a non-issue. There are not problems that I've ever seen that have come close to that. And using throw/catch seems to me like just some extra distance to go to for this simple problem. But maybe I'm missing something else/more here? Johnny -- Johnny Billquist || "I'm on a bus || on a psychedelic trip email: bqt@REDACTED || Reading murder books pdp is alive! || tryin' to stay hip" - B. Idol From matthew@REDACTED Tue Mar 17 23:45:06 2009 From: matthew@REDACTED (Matthew Dempsky) Date: Tue, 17 Mar 2009 15:45:06 -0700 Subject: [erlang-questions] Reassigning variables In-Reply-To: <20090317214258.GQ32606@h216-235-12-174.host.egate.net> References: <879778450903171338j5f47e27fm6b6016906dff0159@mail.gmail.com> <20090317214258.GQ32606@h216-235-12-174.host.egate.net> Message-ID: On Tue, Mar 17, 2009 at 2:42 PM, Vance Shipley wrote: > Doesn't it? No. Your example messes up if requested_ad_size, has_ads, or is_filtering throws an exception. I can do "throw {skip, Reason}", and match on just that, but that breaks when an underlying functions starts throwing exceptions of the form {skip, _}. From cthulahoops@REDACTED Wed Mar 18 00:51:49 2009 From: cthulahoops@REDACTED (Adam Kelly) Date: Tue, 17 Mar 2009 23:51:49 +0000 Subject: [erlang-questions] Reassigning variables In-Reply-To: References: <879778450903171338j5f47e27fm6b6016906dff0159@mail.gmail.com> <20090317214258.GQ32606@h216-235-12-174.host.egate.net> Message-ID: <8d1798e90903171651g793a33c4u5b12f14338112e02@mail.gmail.com> 2009/3/17 Matthew Dempsky : > I can do "throw {skip, Reason}", and match on just that, but that > breaks when an underlying functions starts throwing exceptions of the > form {skip, _}. As I understand it throw is reserved for exceptions that are expected to be caught. Ie, early returns from deeply nested functions and the like. That is exactly this pattern, so you should be able to call other bits of code without getting unexpected throws. Real errors should use error or exit. Looking through your parse transform code it strikes me how few functions you are using. This is a functional programming language and all the meat of your parse transform is in one function. I'm not surprised that you keep wanting to reassign variables in this case. This is my first refactoring pass and that transform_match_expr function is still too long. http://www.cthulahoops.org/reassign_pt.erl In 20,000 lines of Erlang, I think I've used numbered variables once. (And that needs refactoring!) Adam. From matthew@REDACTED Wed Mar 18 01:54:36 2009 From: matthew@REDACTED (Matthew Dempsky) Date: Tue, 17 Mar 2009 17:54:36 -0700 Subject: [erlang-questions] Reassigning variables In-Reply-To: <8d1798e90903171651g793a33c4u5b12f14338112e02@mail.gmail.com> References: <879778450903171338j5f47e27fm6b6016906dff0159@mail.gmail.com> <20090317214258.GQ32606@h216-235-12-174.host.egate.net> <8d1798e90903171651g793a33c4u5b12f14338112e02@mail.gmail.com> Message-ID: On Tue, Mar 17, 2009 at 4:51 PM, Adam Kelly wrote: > Looking through your parse transform code it strikes me how few > functions you are using. Like I said, it's proof of concept code. I wrote it during my lunch break while discussing open source licensing and health care instead of eating. From rvirding@REDACTED Wed Mar 18 03:01:14 2009 From: rvirding@REDACTED (Robert Virding) Date: Wed, 18 Mar 2009 03:01:14 +0100 Subject: [erlang-questions] Backtracking in Erlang, part 1 - control Message-ID: <3dbc6d1c0903171901j216536a0m61280c679383e6be@mail.gmail.com> Sometimes you need to be able to do search algorithms which can step back and try other alternate ways of finding a solution, "backtracking". Generally this is difficult to do in functional languages like Erlang (most other languages too for that matter). A classic example of this type of problem is parsing ambiguous grammars. Prolog syntax is like that, in some cases you need almost indefinite look-ahead before you can decide how input is to be parsed. When I implemented Erlog (a prolog in and for Erlang) I decided to do the parser in Erlang so that it could run stand-alone and so I ran straight into this problem. Here is *a* solution to the problem. It is in two parts, the first describing the control structures and the second (more difficult) describing handling of data. There may also be a third part discussing some problems with the solution to control, if anyone is still interested. The main problem we have to overcome is that normally when you choose a path you "commit" to it and can't go back and try an alternate path. For example in: case get_a_value() of Choice1 -> ... ; Choice2 -> ... ; ... end once you have chosen a path, say Choice1, there is no (simple) way to go back try Choice2 if you later decide that Choice1 was wrong. We can't backtrack. Another problem is that if we have: a() -> foo(), bar(), baz(). and once we have completed foo() then even if it gave an answer which later was shown to be wrong there is no way to step back into it, backtrack, and let it give a new answer. In this first section we will (almost) completely ignore arguments and return values. When looking at control we will (almost) completely ignore arguments and returning values. We will use the convention that functions return either '{succeed,Value}' when they succeed or 'fail' when they can't find a solution. The trick is to ensure that functions only return at all when they fail, otherwise they just continue by explicitly calling the next thing which should be done. We will do this by using a Continue Passing Style (CPS) where each function will have an argument which is the next function call to continue. (CPS is not new and is generally known) So functions will usually look like this: a(Next) -> , OurNext = fun () -> even_more_stuff(Next) end, more_stuff(OurNext). We will use the convention that when a function fails and cannot go on it will return 'fail'. When *the* solution has been found then the final test will return {succeed,Value}. So the top level function will look something like: top_call() -> Succeed = fun () -> {succeed,yes} end, %We have succeeded find_solution(Succeed). So now our program will keep going forwards until it finally calls the Succeed fun when it all returns back to the initial caller. The next problem is to introduce 'choice points' where we can choose one path but still allow the code to backtrack and make another choice. This is the done in the function cp/1 where the argument is a list functions which are separate paths to choose from: cp([fun () -> do_stuff_a(Next) end, fun () -> do_stuff_b(Next) end, fun () -> do_stuff_c(Next) end, ...]). Cp/1 will try the functions in order, if one succeeds then the choice point will succeed and return the same succeed value, if it fails then the next function in the list will be tried, until no more exist when the choice point will fail: The code for cp is simple: cp([G|Gs]) -> case G() of {succeed,Value} -> {succeed,Value}; fail -> cp(Gs) end; cp([]) -> fail. That's it, we're done. A lot of explanation for very little code. A slight variation is to not chain the continuation together as shown here but to have Next as a list of functions to call. Instead of directly calling Next you call next/1 with argument Next, next(Next), where next/1 is defined as: next([N|Ns]) -> N(Ns). There is no functional difference it just make writing some code a bit easier. For example the function defined above: a() -> foo(), bar(), baz(). would look like this in the normal way: a(Next) -> Next1 = fun () -> baz(Next) end, Next2 = fun () -> bar(Next1) end, foo(Next2). while using the list variant it would look like: a(Next) -> foo([fun (Ns) -> bar(Ns) end, fun (Ns) -> baz(Ns) end | Next]). which can be easier to read, especially if there many calls in the continuation. After I introduce handling data in the next installment I can give a proper example. I have also posted this to my blogg for those who prefer to read there, Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: From ok@REDACTED Wed Mar 18 03:02:32 2009 From: ok@REDACTED (Richard O'Keefe) Date: Wed, 18 Mar 2009 15:02:32 +1300 Subject: [erlang-questions] Reassigning variables In-Reply-To: References: Message-ID: <214D70B1-B485-4072-8D2F-1B7C87ABC24D@cs.otago.ac.nz> On 18 Mar 2009, at 7:02 am, Matthew Dempsky wrote: > I like pattern matching in the majority of cases, but I find I write > enough code where I need to incrementally update a data structure, and > maintaining that code is a pain when I have code like: > > X = foo(), > X1 = bar(X), > X2 = xyzzy(X1), > blah(X2). > > and later want to change it to: > > X = foo(), > X1 = whee(X), > X2 = bar(X1), > X3 = xyzzy(X2), > blah(X3). I immediately wondered just how common reassigning to the same variable was in an imperative language. I happen to have 33,826 SLOC of Smalltalk around that I wrote. 33826 SLOC 359 classes 94.2 SLOC/class 7182 method definitions 4.6 SLOC/method 5312 assignments 0.74 assignments/method I must say that these results come as something of a shock to me. I had been feeling guilty about having some fairly long methods. The 4.6 SLOC/method figure includes 1 SLOC for the header, so the average method *body* is 3.6 SLOC. I've definitely been using assignment statements freely. I expected there to be a lot. Paradoxically, it seems to be the very imperative nature of Smalltalk that reduces the number of (visible!) assignments. Take this definition: collect: collectBlock thenReject: rejectBlock |r| r := OrderedCollection new. self do: [:each | |c| c := collectBlock value: each. (rejectBlock value: c) ifFalse: [r addLast: c]]. ^self pvtAsSpecies: r With immutable data structures, "r addLast: c" would have had to be "r := r addLast: c". This method is, of course, basically a filter + a fold. Let's look at a method that does have a fair few assigments: detectMax: aBlock ifNone: noneBlock |unbegun maxElement maxValue| unbegun := true. self valuesDo: [:element| |value| value := aBlock value: element. (unbegun or: [maxValue < value]) ifTrue: [ maxElement := element. maxValue := value. unbegun := false]]. ^unbegun ifTrue: [noneBlock value] ifFalse: [maxElement] This is another fold. And it's a common pattern: what would be a fold in a functional language turns into a pair of assignments for each facet, one initialisation and one update. One method stood out. It had a record 48 assignments. Turned out it was a lexical analyser for JSON, written in a very C-like style (or at any rate, in the style I use when writing lexical analysers in C). One quick edit removed 14 assignments. (In fact, 15, because another assignment was there to work around a bug that simply didn't exist when a certain variable was no longer reassigned.) That's still the record-holder with 33 assignments. In a functional language like Erlang, the JSON tokeniser would be several functions. (At a rough guess, 12.) So the number of reassignments would be manageable. I analysed Smalltalk source code because I *can*; with a fairly simple lexical structure and no preprocessor, it's quite easy for a little AWK script to do some useful counting. Next I went fishing in some Java. Thankfully, it wasn't Java that I had written. The collection was 91502 SLOC in 281539 raw lines -- my SLOC counter doesn't count "{" or "}" as SLOC. 91502 SLOC 1248 classes 73.3 SLOC/class 9515 methods 9.6 SLOC/method 25077 assignments 2.64 assignments/method This is a much higher density of assignments than Smalltalk, but it's _still_ only 2.64 assignments per method, and this is *Java* we're talking about. Oh, and thanks to the crudeness of my tools, this counts initialisation as assignment (the same in Smalltalk, too). In this case the record-holder has an amazing 806 assignments, but three quarters of the methods have no more than 2. Fully 95% of the Java methods have no more than 10 assignments. The crudity of my tools doesn't let me distinguish between the number of assignments and the number of variables assigned to, so I don't have a measurement for how many assignments there are to the *same* variable. My feeling is that except for isolated monsters like my 48-assignment method and an XSLT processor's 806-assignment method, it's pretty low, maybe 2. So why should there be a much worse problem for Erlang? The answer is hinted at above. Erlang does not have mutable data structures (if you don't count the process dictionary or ETS tables or the process name registry or ...) so instead of x foo. x bar. x ugh. we have to do X1 = foo(X0), X2 = bar(X1), X3 = ugh(X2), ... Unless, of course, we do ugh(bar(foo(X0))). > This means having to change four lines of code, when really it's > conceptually just one change. I'd like to suggest being able to do > something like: > > X = foo(), > r(X) = whee(X), > r(X) = bar(X), > r(X) = xyzzy(X), > blah(X). > Yeek. Why pervert function call syntax? Why not just have assignments? X = foo(), X := whee(X), X := bar(X), X := xyzzy(X), blah(X) Something to a very similar effect is possible in most functional languages, using 'let': let x = foo () in let x = whee x in let x = bar x in let x = xyzzy x in blah x The only real awkwardness in adding this to Erlang is the fact that Erlang allows already-bound variables in patterns as well as bound ones. As an aside: parse transforms would be more useful if you were able to add new operators (like :=). What I would really like are some numbers and some examples. How *often* is this a problem? How *many* times is "the same variable" updated, typically? How often are there multiple-updates that don't fall into a pattern? Is it possible that a different coding style would eliminate or greatly reduce the problem? Please, before writing any parse transforms, show us two or three real, complete, functions taken from code you really want to use, where this problem occurs. From jeffm@REDACTED Wed Mar 18 03:27:11 2009 From: jeffm@REDACTED (jm) Date: Wed, 18 Mar 2009 13:27:11 +1100 Subject: [erlang-questions] io:request/2 documentation? In-Reply-To: <3dbc6d1c0903171254x1be73b99w20aa8813a2d2c388@mail.gmail.com> References: <49BF5A98.20005@ghostgun.com> <3dbc6d1c0903171254x1be73b99w20aa8813a2d2c388@mail.gmail.com> Message-ID: <49C05BFF.1000203@ghostgun.com> Robert Virding wrote: > Hi Jeff, > > No io:request/2 has not been documented yet. All it does is to send > off a request to an io-server and wait for the reply. One reason for > not having documented it is that up until very recently the io-server > protocol has not been documented. > > This has now changed. In January I wrote a description of the older > io-server protocol. This description was included in my Erlang > Rationale document which you can find in the User Contributions > section of trapexit.org . A truly brilliant piece > of writing. .-) There is now also a freshly written description of the > newer io-server protocol which is included in the documentation of the > just released version R13-A in the user's guide section of stdlib. The > newer protocol is very similar to the older one, the main change is > providing for some extra parameters for handling unicode. I've dug it up and managed to read some of it over lunch. Now, if I can just hide from customer complaints about our mail server being black list by hot mail long enough for it to be delisted I might be able finish it. > You use io:request/2 in the same manner as it is shown in the leex and > yecc blogg. A very good description by the way. Best overview I've seen ( I've been awaiting one) which actually shows how to use Leex and Yeec in practice. It's one thing to have manuals it's another to actually have a documented example which fills in the blanks. > It can *NOT* be directly used with a gen_tcp generated socket. An > io-server is a process which obeys the io-server protocol. It would, > however, not be very difficult to write an io-server which could > directly read/write against a gen_tcp socket. If someone could show me > a preferred way of setting up and talking to a socket I can fix the > io-server. Sounds like a good idea I can see it being useful in many an app. Thanks, Jeff. From tony@REDACTED Wed Mar 18 03:32:24 2009 From: tony@REDACTED (Tony Arcieri) Date: Tue, 17 Mar 2009 20:32:24 -0600 Subject: [erlang-questions] Reassigning variables In-Reply-To: <8d1798e90903171651g793a33c4u5b12f14338112e02@mail.gmail.com> References: <879778450903171338j5f47e27fm6b6016906dff0159@mail.gmail.com> <20090317214258.GQ32606@h216-235-12-174.host.egate.net> <8d1798e90903171651g793a33c4u5b12f14338112e02@mail.gmail.com> Message-ID: On Tue, Mar 17, 2009 at 5:51 PM, Adam Kelly wrote: > Looking through your parse transform code it strikes me how few > functions you are using. This is a functional programming language > and all the meat of your parse transform is in one function. I'm not > surprised that you keep wanting to reassign variables in this case. [...] > In 20,000 lines of Erlang, I think I've used numbered variables once. > (And that needs refactoring!) > If you like to scrutinize people who suggest destructive assignment is an "interesting feature" by the code they implement to support it on top of Erlang, I'd sure be interested in what you make of mine: http://github.com/tarcieri/reia/blob/master/src/compiler/reia_ssa.erl The main problems I see are: it's highly repetitive, and is also filled with lots of numbered variables. It's also not passing state around correctly as I tried to retrofit records into it after managing the transform state with tuples became too unwieldy. I'm sure there's probably a better general solution to statefully walking around trees and transforming them in general. Right now what I'm doing is pretty slow. Any suggestions (or patches :) are welcome. -- Tony Arcieri medioh.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From ok@REDACTED Wed Mar 18 03:38:19 2009 From: ok@REDACTED (Richard O'Keefe) Date: Wed, 18 Mar 2009 15:38:19 +1300 Subject: [erlang-questions] Reassigning variables In-Reply-To: References: <879778450903171338j5f47e27fm6b6016906dff0159@mail.gmail.com> Message-ID: <20AB5CF7-C396-42AB-AAD1-676FD2C8BC4C@cs.otago.ac.nz> On 18 Mar 2009, at 10:19 am, Matthew Dempsky wrote: > I disagree. There are ways that reassignment can make code easier to > analyze, but I'm not suggesting people use reassignment in those > cases. _Easier_ to analyse? I'd love to see an example. > > > Similarly, Erlang doesn't support 'return', but our ad server has > enough business logic where the code would be much simpler if it did. > We had some code that was effectively: > > if requested ad size is bad: > return {skip, bad_size} > if the game has ads disabled: > return {skip, disabled} > if the game is filtering a domain: > return {skip, domain_filtered} > return choose_ad() > This is a very familiar pattern from Smalltalk. But surely you don't need a 'return' for that. > I rewrote this code in 'Erlang style' with a list of funs to check, > and to short-circuit on the first that returns a skip, when I last > added to it, and so incrementally it's much less work to add new > checks than the old code. I wouldn't have called called that "Erlang style". There's an EEP to allow "un-nested" cases. This will allow case requested_ad_size(...) of bad -> {skip, bad_size} ; or case ad_status(...) of disabled -> {skip, disabled} ; or case game_filtering(...) of filtered -> {skip, domain_filtered} ; _ -> choose_ad() end Last I heard there was a good chance this would be adopted but with a different syntax (just dropping the 'or', I think, but don't quote me). Absent that, I'd probably do case { requested_ad_size(...) , ad_status(...) , game_filtering(...) } of {bad,_,_} -> {skip, bad_size} ; {_,disabled,_} -> [skip, disabled} ; {_,_,filtered} -> {skip, domain_filtered} ; _ -> choose_ad() end Admittedly, this evaluates all the criteria, but then, in what we are expecting to be the usual case, we're going to do that _anyway_. [If this example reminds you of a decision table, it should. Arguably a decision table is a 'case' of this kind, but lazily evaluated.] > But it's stupid. Yes, it is. The 'case' expression above is not, however. > > Programmers understand how variable reassignment and multiple function > call returns work: every beginner programming language includes them. Not so: Melbourne University used to use Miranda as their beginner programming language, and it doesn't include those things. For that matter, Monash Caulfield used Scheme as their introductory language (replacing 3 semesters of COBOL with 1 semester of Scheme followed by 1 semester of COBOL resulted in students learning *more* COBOL) and the subset of Scheme they were taught did not include call-with-current-continuation, so did not have multiple exits. (These were _not_ advanced CS students; Monash Caulfield used to be a technical college. These days they probably teach VB.) From matthew@REDACTED Wed Mar 18 03:40:05 2009 From: matthew@REDACTED (Matthew Dempsky) Date: Tue, 17 Mar 2009 19:40:05 -0700 Subject: [erlang-questions] Reassigning variables In-Reply-To: <214D70B1-B485-4072-8D2F-1B7C87ABC24D@cs.otago.ac.nz> References: <214D70B1-B485-4072-8D2F-1B7C87ABC24D@cs.otago.ac.nz> Message-ID: On Tue, Mar 17, 2009 at 7:02 PM, Richard O'Keefe wrote: > Yeek. ?Why pervert function call syntax? Because application expressions are invalid in pattern contexts, so it's something I could safely define using a parse transform without having to change the scanner/parser/compiler. > Why not just have assignments? > ? ? ? ?X = foo(), > ? ? ? ?X := whee(X), > ? ? ? ?X := bar(X), > ? ? ? ?X := xyzzy(X), > ? ? ? ?blah(X) I'd be generally content with that too. It just means more intrusive changes, and the peanut gallery will complain just the same. > The only real awkwardness in adding this to Erlang is the > fact that Erlang allows already-bound variables in patterns > as well as bound ones. Right, which is one of the benefits of my approach. Immediately after posting the first copy of reassign_pt.erl, I generalized it to allow expressions like "{r(X), Y} = foo(X)". > As an aside: parse transforms would be more useful if you were > able to add new operators (like :=). Agreed. > What I would really like are some numbers and some examples. > How *often* is this a problem? > How *many* times is "the same variable" updated, typically? > How often are there multiple-updates that don't fall into a > pattern? > Is it possible that a different coding style would eliminate > or greatly reduce the problem? In our our ad server, this happens a lot in the code that handles the different third-party ad providers that we integrate. There's a (relatively) lot of churn in this code as we add or drop providers, and every third-party has a different, retarded interface that we have to deal with. The code is dumb and hacky, and I'm not especially proud of it, but it'd be a waste of our time to try to improve it any more because right now it's only about 80 lines of relatively straight forward code. The only trouble in maintaining it is the variable renaming. > Please, before writing any parse transforms, show us two or > three real, complete, functions taken from code you really > want to use, where this problem occurs. Too late, I already wrote one. :) From matthew@REDACTED Wed Mar 18 03:52:45 2009 From: matthew@REDACTED (Matthew Dempsky) Date: Tue, 17 Mar 2009 19:52:45 -0700 Subject: [erlang-questions] Reassigning variables In-Reply-To: <20AB5CF7-C396-42AB-AAD1-676FD2C8BC4C@cs.otago.ac.nz> References: <879778450903171338j5f47e27fm6b6016906dff0159@mail.gmail.com> <20AB5CF7-C396-42AB-AAD1-676FD2C8BC4C@cs.otago.ac.nz> Message-ID: On Tue, Mar 17, 2009 at 7:38 PM, Richard O'Keefe wrote: > _Easier_ to analyse? ?I'd love to see an example. Sorry, by analyze, I meant review for correctness, and I was referring specifically to the diff. It's easier to review + r(X) = foo(X), than - X2 = bar(X1), - X3 = baz(X2), - xyzzy(X3). + X2 = foo(X1), + X3 = bar(X2), + X4 = baz(X3), + xyzzy(X4). > This is a very familiar pattern from Smalltalk. > But surely you don't need a 'return' for that. Of course I don't *need* it, it works currently without that. But I also don't *need* comments or variable and function names with vowels, but I find them handy in making the code more understandable sometimes. > There's an EEP to allow "un-nested" cases. ?This will allow > > ? ? ? ?case requested_ad_size(...) > ? ? ? ? ?of bad ? ? ?-> {skip, bad_size} > ? ? ? ?; or case ad_status(...) > ? ? ? ? ?of disabled -> {skip, disabled} > ? ? ? ?; or case game_filtering(...) > ? ? ? ? ?of filtered -> {skip, domain_filtered} > ? ? ? ? ? ; _ -> > ? ? ? ? ? ? choose_ad() > ? ? ? ?end > > Last I heard there was a good chance this would be adopted > but with a different syntax (just dropping the 'or', I think, > but don't quote me). Hm. It feels immediately ugly, but so did Erlang's syntax in general when I first used it. (I'm not a fan of putting the semicolons on the start of lines though.) > Absent that, I'd probably do > > ? ? ? ?case { requested_ad_size(...) > ? ? ? ? ? ? , ad_status(...) > ? ? ? ? ? ? , game_filtering(...) > ? ? ? ? ? ? } > ? ? ? ? ?of {bad,_,_} ? ? ?-> {skip, bad_size} > ? ? ? ? ? ; {_,disabled,_} -> [skip, disabled} > ? ? ? ? ? ; {_,_,filtered} -> {skip, domain_filtered} > ? ? ? ? ? ; _ -> > ? ? ? ? ? ? choose_ad() > ? ? ? ?end > > Admittedly, this evaluates all the criteria, but then, > in what we are expecting to be the usual case, we're > going to do that _anyway_. Sure, but in other use cases, the second or third checks being valid depend on the first or second checks passing. > Yes, it is. ?The 'case' expression above is not, however. There are other reasons I don't like the case expressions. From billrobertson42+erlang@REDACTED Wed Mar 18 03:59:07 2009 From: billrobertson42+erlang@REDACTED (bill robertson) Date: Tue, 17 Mar 2009 22:59:07 -0400 Subject: [erlang-questions] Please help me relate a past project to Erlang, I'm trying to understand... In-Reply-To: <449653.76030.qm@web111405.mail.gq1.yahoo.com> References: <61169.51377.qm@web111416.mail.gq1.yahoo.com> <449653.76030.qm@web111405.mail.gq1.yahoo.com> Message-ID: Thats good. Now, to make it *stateful* (and this is the heart of the question). Suppose you have the requirement to allow a web user to view the call as it is in progress and show them who is connected (telephone number), and how long they have been connected, and also who is disconnected and how long they were connected. To do this, you need to track three items for each participant. The telephone number. The start time, and a stop time. So network request comes in, we have to enumerate those pieces of information for it and send them back to the client. How would you implement this in a typical Erlang system? a) The process map for the participant (bad answer from what I can glean) b) An ets/dets table (there are private ets tables right? how is that different from the process map?) c) A database of some sort (mnesia, relational, whatever) d) Some sort OTP FSM construct? e) Other (please elaborate) If I'm being dense, and you need to use simple words, I won't mind. On Tue, Mar 17, 2009 at 4:21 PM, Thomas Lindgren wrote: > > > > > > ----- Original Message ---- >> From: bill robertson >> To: Thomas Lindgren >> Sent: Tuesday, March 17, 2009 5:24:32 AM >> Subject: Re: [erlang-questions] Please help me relate a past project to ?Erlang, I'm trying to understand... >> >> Thanks to all. >> >> In this hypothetical case though, the Erlang component must be >> stateful between requests. ?The C server which manages the telecom >> lines is dumb (which was its power!), and the webapp held no >> meaningful state (e.g. call duration). >> >> While a conference call was in progress, if there were no events, then >> there was no processing occurring in the conference call manager (the >> hypothetical Erlang piece). ?So when a request comes into the system, >> it must know its state, act accordingly, send messages etc. and then >> the request (and control flow and any stack for the request) leaves >> the system. ?In this case then, where would you keep the state? >> >> Are you saying that the FSM somehow exists as part of the process if >> you use the FSM management built into OTP? ?(If so then where? ?I'm >> sure it doesn't matter, but...) > > All the memory allocated by an erlang process is managed by the runtime system. (Well, as a first approximation...) > > How to structure your application? I'd do it like this: > > 1. One process per incoming call. This lives for the duration of the call. > 2. One process per conference call. This lives until the conference call ends. > 3. One process that starts new conference calls by spawning conference call processes. This process lives forever, the erlang equivalent of a daemon. > > Your incoming calls ask the "starter" if there is an ongoing call to join, which makes it either send back the pid of the existing call, or start a new one. > > Best, > Thomas > > > > From billrobertson42+erlang@REDACTED Wed Mar 18 04:20:59 2009 From: billrobertson42+erlang@REDACTED (bill robertson) Date: Tue, 17 Mar 2009 23:20:59 -0400 Subject: [erlang-questions] Reassigning variables In-Reply-To: <87prgfkiie.fsf@sterlett.hq.kred> References: <87prgfkiie.fsf@sterlett.hq.kred> Message-ID: > ?So I think the X1 = f(X), X2 = f(X1) anti-pattern is not a weakness > ?of the language; it's Erlang's way of telling you that you should > ?use more functions. > > ?mats This is an honest question. How is re-assignment of local variables bad? They have no life outside their stack frame. So there is no risk of side-effects. Is it a style issue or is there something else? From ok@REDACTED Wed Mar 18 04:36:53 2009 From: ok@REDACTED (Richard O'Keefe) Date: Wed, 18 Mar 2009 16:36:53 +1300 Subject: [erlang-questions] Reassigning variables In-Reply-To: References: <214D70B1-B485-4072-8D2F-1B7C87ABC24D@cs.otago.ac.nz> Message-ID: On 18 Mar 2009, at 3:40 pm, Matthew Dempsky wrote: > On Tue, Mar 17, 2009 at 7:02 PM, Richard O'Keefe > wrote: >> Yeek. Why pervert function call syntax? > > Because application expressions are invalid in pattern contexts, so > it's something I could safely define using a parse transform without > having to change the scanner/parser/compiler. "Safely" solely in the sense that one particular tool-set would let you do it. But not in the sense that the resulting syntax would win any prizes for readability. > > > I'd be generally content with that too. It just means more intrusive > changes, and the peanut gallery will complain just the same. Fairly trivial ones. > > >> The only real awkwardness in adding this to Erlang is the >> fact that Erlang allows already-bound variables in patterns >> as well as bound ones. > > Right, which is one of the benefits of my approach. Immediately after > posting the first copy of reassign_pt.erl, I generalized it to allow > expressions like "{r(X), Y} = foo(X)". So use a macro: -define(let(Lhs,Exp,Body), (fun (Lhs) -> Body end)(Exp)). X = foo(), ?let(X, bar(X), ( ?let(X, ugh(X), ( ack(X))) This exploits what is otherwise a nuisance, namely that the scope rules for 'fun' are inconsistent. (An outer variable that appears in the body of a fun is an old variable, but an outer variable that appears in the head is a new variable.) > >> What I would really like are some numbers and some examples. >> How *often* is this a problem? >> How *many* times is "the same variable" updated, typically? >> How often are there multiple-updates that don't fall into a >> pattern? >> Is it possible that a different coding style would eliminate >> or greatly reduce the problem? > > In our our ad server, this happens a lot in the code that handles the > different third-party ad providers that we integrate. Numbers? > There's a > (relatively) lot of churn in this code as we add or drop providers, > and every third-party has a different, retarded interface that we have > to deal with. This sounds like a textbook case for metaprogramming. > The code is dumb and hacky, and I'm not especially > proud of it, but it'd be a waste of our time to try to improve it any > more because right now it's only about 80 lines of relatively straight > forward code. The only trouble in maintaining it is the variable > renaming. Can we see this? Bending the language for the sake of "about 80 lines of relatively straight forward code"? This does really sound like a case for metaprogramming. From matthew@REDACTED Wed Mar 18 04:47:30 2009 From: matthew@REDACTED (Matthew Dempsky) Date: Tue, 17 Mar 2009 20:47:30 -0700 Subject: [erlang-questions] Reassigning variables In-Reply-To: References: <214D70B1-B485-4072-8D2F-1B7C87ABC24D@cs.otago.ac.nz> Message-ID: On Tue, Mar 17, 2009 at 8:36 PM, Richard O'Keefe wrote: > "Safely" solely in the sense that one particular tool-set would > let you do it. ?But not in the sense that the resulting syntax > would win any prizes for readability. "Safely" in the sense that there's no other pre-existing use of that syntax. From ok@REDACTED Wed Mar 18 04:26:18 2009 From: ok@REDACTED (Richard O'Keefe) Date: Wed, 18 Mar 2009 16:26:18 +1300 Subject: [erlang-questions] Reassigning variables In-Reply-To: References: <879778450903171338j5f47e27fm6b6016906dff0159@mail.gmail.com> <20090317214258.GQ32606@h216-235-12-174.host.egate.net> Message-ID: <1816EDB2-4359-48A3-81F2-EF1AF252CE80@cs.otago.ac.nz> On 18 Mar 2009, at 11:45 am, Matthew Dempsky wrote: > Your example messes up if requested_ad_size, has_ads, or is_filtering > throws an exception. > > I can do "throw {skip, Reason}", and match on just that, but that > breaks when an underlying functions starts throwing exceptions of the > form {skip, _}. I don't _like_ using exceptions for control structures, but that's another story. It _is_ possible to have an Erlang function that catches precisely the throws you want it to. You can create a reference, include that in the thrown terms, and -- thanks to Erlang letting you use bound variables in patterns -- also include it in the patterns. It's one more line of code. From ok@REDACTED Wed Mar 18 04:52:43 2009 From: ok@REDACTED (Richard O'Keefe) Date: Wed, 18 Mar 2009 16:52:43 +1300 Subject: [erlang-questions] Reassigning variables In-Reply-To: References: <879778450903171338j5f47e27fm6b6016906dff0159@mail.gmail.com> <20AB5CF7-C396-42AB-AAD1-676FD2C8BC4C@cs.otago.ac.nz> Message-ID: <6DA014AD-3091-4938-B159-496CF1D1A8BE@cs.otago.ac.nz> On 18 Mar 2009, at 3:52 pm, Matthew Dempsky wrote: > On Tue, Mar 17, 2009 at 7:38 PM, Richard O'Keefe > wrote: >> _Easier_ to analyse? I'd love to see an example. > > Sorry, by analyze, I meant review for correctness, and I was referring > specifically to the diff. It's easier to review > > + r(X) = foo(X), > > than > > - X2 = bar(X1), > - X3 = baz(X2), > - xyzzy(X3). > + X2 = foo(X1), > + X3 = bar(X2), > + X4 = baz(X3), > + xyzzy(X4). Fair enough. The ?let macro would have precisely the same advantage, with no parse transform required. > > >> This is a very familiar pattern from Smalltalk. >> But surely you don't need a 'return' for that. > > Of course I don't *need* it, it works currently without that. But I > also don't *need* comments or variable and function names with vowels, > but I find them handy in making the code more understandable > sometimes. I meant "but surely you do not need 'return' to do that READABLY." Yes you DO need function names with vowels and you DO need comments in order to write non-trivial working programs, let alone readable ones. But you don't need multiple returns. > > >> There's an EEP to allow "un-nested" cases. > > Hm. It feels immediately ugly, but so did Erlang's syntax in general > when I first used it. (I'm not a fan of putting the semicolons on the > start of lines though.) If you care about readability, you should be. I find non-trivial case expressions in Erlang almost totally unreadable with the semicolons on the right. In C/C++/Java/C#, you have 'case' at the beginning of a line to tell you when a new case begins. In Ada, you have 'when'. In PL/I, you have 'WHEN'. The same kind of thing applies in Fortran. Something on the left to tell you a new choice is beginning is enormously helpful. Erlang-with-semicolons-on-the- right completely lacks that visual cue. I developed this style in Prolog after reading Peter van Roy's thesis where he raged against Prolog for using both ',' and ';' which were very hard to tell apart at the end of a line. The obvious answer was "don't put them both at the ends of lines then". Even with better fonts, it is very very helpful. I grant you that it isn't *familiar*, and I even grant that a keyword would be a better cue than a semicolon. But it's a big step forward in readability while sticking within the language we have. As for un-nested cases, it's so very close to being the kind of if-then-elif-then-elif-then-else-fi that people have been asking for in Erlang for a long time, that it's really very amusing to have it called "immediately ugly". I guess that's a vote for the language we have. > > >> Absent that, I'd probably do >> >> case { requested_ad_size(...) >> , ad_status(...) >> , game_filtering(...) >> } >> of {bad,_,_} -> {skip, bad_size} >> ; {_,disabled,_} -> [skip, disabled} >> ; {_,_,filtered} -> {skip, domain_filtered} >> ; _ -> >> choose_ad() >> end >> >> Admittedly, this evaluates all the criteria, but then, >> in what we are expecting to be the usual case, we're >> going to do that _anyway_. > > Sure, but in other use cases, the second or third checks being valid > depend on the first or second checks passing. First, there is no reason to expect one code style to cover all possible cases. I was aware of that issue when I wrote this example. Second, it's actually not hard at all to work around that. But third, "Bombinating in a vacuum" is bootless. We need REAL code to discuss. For example, in cases where the second and/or third checks might depend on the first, it might be possible to fuse the checks so that this does not apply. > There are other reasons I don't like the case expressions. Reasons are what debate thrives on. > From tony@REDACTED Wed Mar 18 05:29:41 2009 From: tony@REDACTED (Tony Arcieri) Date: Tue, 17 Mar 2009 22:29:41 -0600 Subject: [erlang-questions] Reassigning variables In-Reply-To: <20AB5CF7-C396-42AB-AAD1-676FD2C8BC4C@cs.otago.ac.nz> References: <879778450903171338j5f47e27fm6b6016906dff0159@mail.gmail.com> <20AB5CF7-C396-42AB-AAD1-676FD2C8BC4C@cs.otago.ac.nz> Message-ID: On Tue, Mar 17, 2009 at 8:38 PM, Richard O'Keefe wrote: > > Programmers understand how variable reassignment and multiple function > > call returns work: every beginner programming language includes them. > > Not so: Melbourne University used to use Miranda as their beginner > programming language, and it doesn't include those things. > Perhaps a better way to phrase that argument is: most programmers today are not used to it, and a large number (perhaps irrationally) detest it. As to whether or not this group of programmers would make good Erlang programmers is another question... -- Tony Arcieri medioh.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From matthew@REDACTED Wed Mar 18 06:35:28 2009 From: matthew@REDACTED (Matthew Dempsky) Date: Tue, 17 Mar 2009 22:35:28 -0700 Subject: [erlang-questions] Reassigning variables In-Reply-To: <6DA014AD-3091-4938-B159-496CF1D1A8BE@cs.otago.ac.nz> References: <879778450903171338j5f47e27fm6b6016906dff0159@mail.gmail.com> <20AB5CF7-C396-42AB-AAD1-676FD2C8BC4C@cs.otago.ac.nz> <6DA014AD-3091-4938-B159-496CF1D1A8BE@cs.otago.ac.nz> Message-ID: On Tue, Mar 17, 2009 at 8:52 PM, Richard O'Keefe wrote: > Fair enough. ?The ?let macro would have precisely the same > advantage, with no parse transform required. Not entirely. The ?let macro requires adding an extra close parenthesis at the end of the block. It's still an improvement over having to modify a bunch of lines of code, but it's still extra lines of changes that I'd rather avoid. > If you care about readability, you should be. ?I find non-trivial > case expressions in Erlang almost totally unreadable with the > semicolons on the right. ?In C/C++/Java/C#, you have 'case' at the > beginning of a line to tell you when a new case begins. ?In Ada, > you have 'when'. ?In PL/I, you have 'WHEN'. ?The same kind of thing > applies in Fortran. ?Something on the left to tell you a new choice > is beginning is enormously helpful. ?Erlang-with-semicolons-on-the- > right completely lacks that visual cue. In Erlang, there's indentation to indicate where the start of each clause is. It mimics natural languages somewhat more of using white space to separate paragraphs and punctuation to end and separate paragraphs. However, I can appreciate your arguments. > ? ? ? ?"Bombinating in a vacuum" is bootless. > ? ? ? ?We need REAL code to discuss. I'd prefer not to post the actual code that motivated this discussion, but I will point out some code in OTP that uses numbered variables: the Erlang compiler. It uses them quite significantly, with some functions matthew@REDACTED:~/src/otp_src_R12B-5/lib/compiler/src$ for x in `jot 11 0`; do echo -n "St$x: "; cat *.erl | grep -c "[^a-zA-Z0-9_]St$x[^0-9]"; done St0: 811 St1: 612 St2: 300 St3: 120 St4: 47 St5: 29 St6: 14 St7: 10 St8: 6 St9: 2 St10: 2 v3_core.erl is especially heavy in numbered St variables. sys_core_dsetel.erl also likes to use numbered Env variables. Now, I'll concede that the Erlang compiler has been relatively stable, but looking at the diffs between releases, I do still see instances of changes necessitating non-local renumbering. I'm interested to know how you'd suggest rewriting v3_core:lc_tq/5 using metaprogramming. From matthew@REDACTED Wed Mar 18 07:07:55 2009 From: matthew@REDACTED (Matthew Dempsky) Date: Tue, 17 Mar 2009 23:07:55 -0700 Subject: [erlang-questions] Reassigning variables In-Reply-To: References: <879778450903171338j5f47e27fm6b6016906dff0159@mail.gmail.com> <20AB5CF7-C396-42AB-AAD1-676FD2C8BC4C@cs.otago.ac.nz> <6DA014AD-3091-4938-B159-496CF1D1A8BE@cs.otago.ac.nz> Message-ID: On Tue, Mar 17, 2009 at 10:35 PM, Matthew Dempsky wrote: > I'd prefer not to post the actual code that motivated this discussion, > but I will point out some code in OTP that uses numbered variables: > the Erlang compiler. ?It uses them quite significantly, with some > functions Sorry, this was supposed to read "with some functions going as high as St10". Also, here's a list of a few other functions in OTP that use numbered variables: - zip:put_z_files/6 - epp:predef_macros/1 - erl_lint:post_traversal_check/2 - global:resolved/5 - asn1ct_parser2:parse_Type/1 - mnesia_log:do_backup_master/1 - xmerl_scan:scan_document/1 - xmerl_xsd:element_content/3 - tftp_engine:server_init/2 Of course, this isn't a comprehensive listing of functions that do so (e.g., the asn1 and xmerl applications use them a ton, and I only quickly looked through a few apps and grabbed some concrete examples), but instead to show that it's not just a bad practice limited to my code. :P I'll also admit I've only quickly looked over the above examples, and there might be reasons why the numbered variables will *never* need to be renumbered (e.g., I found inet_dns:encode/1 uses numbered variables, but that's arguably excusable because DNS is never going to add more sections to the wire format), but I doubt that's generally the case. From exta7@REDACTED Wed Mar 18 07:51:06 2009 From: exta7@REDACTED (Zvi) Date: Tue, 17 Mar 2009 23:51:06 -0700 (PDT) Subject: [erlang-questions] Erlang/OTP R13A has been released In-Reply-To: <6672d0160903170857y6c4435fctcdc4b0b9f6d67a5a@mail.gmail.com> References: <6672d0160903170857y6c4435fctcdc4b0b9f6d67a5a@mail.gmail.com> Message-ID: <22573604.post@talk.nabble.com> Hi, "Erlang R13A (erts-5.7) [smp:2:2] [rq:2] [async-threads:0] Eshell V5.7 (abort with ^G) 1>" what's the meaning of "[smp:2:2]" and "[rq:2]" ? Does "[smp:2:2]" means two schedulers and two corresponding run queues? I guess "rq" is for "run queues" ? Thanks Zvi Bjorn Gustavsson-2 wrote: > > Major relese : otp_src_R13A > Build date : 2009-03-17 > > R13A is a beta release of the next R13B major release. > We do not recommend it for use in live products. > -- View this message in context: http://www.nabble.com/Erlang-OTP-R13A-has-been-released-tp22562608p22573604.html Sent from the Erlang Questions mailing list archive at Nabble.com. From btolputt@REDACTED Wed Mar 18 00:58:42 2009 From: btolputt@REDACTED (Benjamin Tolputt) Date: Wed, 18 Mar 2009 10:58:42 +1100 Subject: [erlang-questions] Reassigning variables In-Reply-To: <49C0274D.5030508@softjar.se> References: <879778450903171338j5f47e27fm6b6016906dff0159@mail.gmail.com> <49C01BD1.4050305@softjar.se> <49C0274D.5030508@softjar.se> Message-ID: <49C03932.6050300@bigpond.net.au> Johnny Billquist wrote: > And using throw/catch seems to me like just some extra distance to > go to for this simple problem. > Actually, I dislike the idea of using throw/catch in such a way. It ruins the "flow" of programming in much the same way as using a "goto" would. Given we're talking about "purity" & ease of code understanding as reasons against the use of multi-assignment variables - I would think throw/catch is a bad, bad thing to suggest, right? > But maybe I'm missing something else/more here You would not be the only one. I'm trying to understand a couple of things about this myself. -- Regards, Benjamin Tolputt Analyst Programmer From zambal@REDACTED Wed Mar 18 08:59:25 2009 From: zambal@REDACTED (zambal) Date: Wed, 18 Mar 2009 00:59:25 -0700 (PDT) Subject: [erlang-questions] Erlang/OTP R13A has been released In-Reply-To: <6672d0160903170857y6c4435fctcdc4b0b9f6d67a5a@mail.gmail.com> References: <6672d0160903170857y6c4435fctcdc4b0b9f6d67a5a@mail.gmail.com> Message-ID: Hi, I have a major issue with the Windows binary distribution of 13A, because I can't compile anything. For example, when trying to compile the following module: -module(test). -compile(export_all). hallo(X) -> "Hallo " ++ X ++ "!". The following error occured: ./test.erl:none: internal error in core_module; crash reason: {undef,[{cerl,c_tuple, [[{c_literal,[{name,{hallo, 1}}],function_clause}, {c_var,[],cor2}]]}, {v3_core,function_clause,2}, {v3_core,body,4}, {v3_core,function,5}, {v3_core,form,3}, {lists,foldl,3}, {v3_core,module,2}, {compile,core_module,1}]} error I'm running the 32bits version of WindowsXP SP3. --- vincent From ulf.wiger@REDACTED Wed Mar 18 09:11:42 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Wed, 18 Mar 2009 09:11:42 +0100 Subject: [erlang-questions] Erlang/OTP R13A has been released In-Reply-To: <22573604.post@talk.nabble.com> References: <6672d0160903170857y6c4435fctcdc4b0b9f6d67a5a@mail.gmail.com> <22573604.post@talk.nabble.com> Message-ID: <49C0ACBE.8050004@erlang-consulting.com> Zvi wrote: > Hi, > > "Erlang R13A (erts-5.7) [smp:2:2] [rq:2] [async-threads:0] > > Eshell V5.7 (abort with ^G) > 1>" > > > what's the meaning of "[smp:2:2]" and "[rq:2]" ? > Does "[smp:2:2]" means two schedulers and two corresponding run queues? > I guess "rq" is for "run queues" ? I believe I have figured out that it's [smp:Schedulers:SchedulersOnline], and "rq" indeed stands for run-queues (well, I'm guessing. Can't find it documented.) So with the +S Schedulers:SchedulersOnline, you can set how many schedulers you want to be able to play with. You can change the number of active schedulers, using erlang:system_flag(schedulers_online, N), setting it to a value between 1 and Schedulers (which can only be set at boot time.) Reading about this, I was a bit confused by one thing: On erlang:system_flag(scheduler_bind_type, T), it says "How schedulers are bound matters. For example, in low load situations, the runtime system tries to migrate processes to schedulers with low scheduler identifiers. The more the schedulers are spread over the hardware, the more resources will be available to the runtime system in low load situations. " Forgive me for being glib, but why does it matter at all how I can optimize CPU usage at low load? (: Ok, from an energy consumption POV, I guess it can make a difference, but I've mainly come to think that as long as there is excess CPU capacity, there is very little reason to optimize things. I would be much more interested in hearing how this can make a different during high load, or hear a more detailed explanation of why low-load optimizations are important to me. BR, Ulf W -- Ulf Wiger CTO, Erlang Training & Consulting Ltd http://www.erlang-consulting.com From vychodil.hynek@REDACTED Wed Mar 18 09:16:04 2009 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Wed, 18 Mar 2009 09:16:04 +0100 Subject: [erlang-questions] Backtracking in Erlang, part 1 - control In-Reply-To: <3dbc6d1c0903171901j216536a0m61280c679383e6be@mail.gmail.com> References: <3dbc6d1c0903171901j216536a0m61280c679383e6be@mail.gmail.com> Message-ID: <4d08db370903180116y3fa153ceqfc95f5cdc097af47@mail.gmail.com> Have you seen 2.6.3 Parsing http://www.erlang.org/doc/programming_examples/funs.html#2.6? I think higher order function elegantly solve this even it can be slower than straight forward approach. 2009/3/18 Robert Virding > Sometimes you need to be able to do search algorithms which can step back > and try other alternate ways of finding a solution, "backtracking". > Generally this is difficult to do in functional languages like Erlang (most > other languages too for that matter). A classic example of this type of > problem is parsing ambiguous grammars. > > Prolog syntax is like that, in some cases you need almost indefinite > look-ahead before you can decide how input is to be parsed. When I > implemented Erlog (a prolog in and for Erlang) I decided to do the parser in > Erlang so that it could run stand-alone and so I ran straight into this > problem. > > Here is *a* solution to the problem. It is in two parts, the first > describing the control structures and the second (more difficult) describing > handling of data. There may also be a third part discussing some problems > with the solution to control, if anyone is still interested. > > The main problem we have to overcome is that normally when you choose a > path you "commit" to it and can't go back and try an alternate path. For > example in: > > case get_a_value() of > Choice1 -> ... ; > Choice2 -> ... ; > ... > end > > once you have chosen a path, say Choice1, there is no (simple) way to go > back try Choice2 if you later decide that Choice1 was wrong. We can't > backtrack. > > Another problem is that if we have: > > a() -> foo(), bar(), baz(). > > and once we have completed foo() then even if it gave an answer which later > was shown to be wrong there is no way to step back into it, backtrack, and > let it give a new answer. > > In this first section we will (almost) completely ignore arguments and > return values. > > When looking at control we will (almost) completely ignore arguments and > returning values. We will use the convention that functions return either > '{succeed,Value}' when they succeed or 'fail' when they can't find a > solution. > > The trick is to ensure that functions only return at all when they fail, > otherwise they just continue by explicitly calling the next thing which > should be done. We will do this by using a Continue Passing Style (CPS) > where each function will have an argument which is the next function call to > continue. (CPS is not new and is generally known) So functions will usually > look like this: > > a(Next) -> > , > OurNext = fun () -> even_more_stuff(Next) end, > more_stuff(OurNext). > > We will use the convention that when a function fails and cannot go on it > will return 'fail'. When *the* solution has been found then the final test > will return {succeed,Value}. So the top level function will look something > like: > > top_call() -> > Succeed = fun () -> {succeed,yes} end, %We have succeeded > find_solution(Succeed). > > So now our program will keep going forwards until it finally calls the > Succeed fun when it all returns back to the initial caller. > > The next problem is to introduce 'choice points' where we can choose one > path but still allow the code to backtrack and make another choice. This is > the done in the function cp/1 where the argument is a list functions which > are separate paths to choose from: > > cp([fun () -> do_stuff_a(Next) end, > fun () -> do_stuff_b(Next) end, > fun () -> do_stuff_c(Next) end, > ...]). > > Cp/1 will try the functions in order, if one succeeds then the choice point > will succeed and return the same succeed value, if it fails then the next > function in the list will be tried, until no more exist when the choice > point will fail: The code for cp is simple: > > cp([G|Gs]) -> > case G() of > {succeed,Value} -> {succeed,Value}; > fail -> cp(Gs) > end; > cp([]) -> fail. > > That's it, we're done. A lot of explanation for very little code. > > A slight variation is to not chain the continuation together as shown here > but to have Next as a list of functions to call. Instead of directly calling > Next you call next/1 with argument Next, next(Next), where next/1 is defined > as: > > next([N|Ns]) -> N(Ns). > > There is no functional difference it just make writing some code a bit > easier. For example the function defined above: > > a() -> foo(), bar(), baz(). > > would look like this in the normal way: > > a(Next) -> > Next1 = fun () -> baz(Next) end, > Next2 = fun () -> bar(Next1) end, > foo(Next2). > > while using the list variant it would look like: > > a(Next) -> > foo([fun (Ns) -> bar(Ns) end, > fun (Ns) -> baz(Ns) end | Next]). > > which can be easier to read, especially if there many calls in the > continuation. > > After I introduce handling data in the next installment I can give a proper > example. > > I have also posted this to my blogg for those who prefer to read there, > > Robert > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- --Hynek (Pichi) Vychodil Analyze your data in minutes. Share your insights instantly. Thrill your boss. Be a data hero! Try Good Data now for free: www.gooddata.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From vychodil.hynek@REDACTED Wed Mar 18 09:19:09 2009 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Wed, 18 Mar 2009 09:19:09 +0100 Subject: [erlang-questions] Backtracking in Erlang, part 1 - control In-Reply-To: <4d08db370903180116y3fa153ceqfc95f5cdc097af47@mail.gmail.com> References: <3dbc6d1c0903171901j216536a0m61280c679383e6be@mail.gmail.com> <4d08db370903180116y3fa153ceqfc95f5cdc097af47@mail.gmail.com> Message-ID: <4d08db370903180119s4f7f59d5i8b8f11b50176cf1d@mail.gmail.com> Sorry, I did not read carefully your post. It is not question, it is answer ;-) On Wed, Mar 18, 2009 at 9:16 AM, Hynek Vychodil wrote: > Have you seen 2.6.3 Parsing > http://www.erlang.org/doc/programming_examples/funs.html#2.6? > > I think higher order function elegantly solve this even it can be slower > than straight forward approach. > > 2009/3/18 Robert Virding > >> Sometimes you need to be able to do search algorithms which can step back >> and try other alternate ways of finding a solution, "backtracking". >> Generally this is difficult to do in functional languages like Erlang (most >> other languages too for that matter). A classic example of this type of >> problem is parsing ambiguous grammars. >> >> Prolog syntax is like that, in some cases you need almost indefinite >> look-ahead before you can decide how input is to be parsed. When I >> implemented Erlog (a prolog in and for Erlang) I decided to do the parser in >> Erlang so that it could run stand-alone and so I ran straight into this >> problem. >> >> Here is *a* solution to the problem. It is in two parts, the first >> describing the control structures and the second (more difficult) describing >> handling of data. There may also be a third part discussing some problems >> with the solution to control, if anyone is still interested. >> >> The main problem we have to overcome is that normally when you choose a >> path you "commit" to it and can't go back and try an alternate path. For >> example in: >> >> case get_a_value() of >> Choice1 -> ... ; >> Choice2 -> ... ; >> ... >> end >> >> once you have chosen a path, say Choice1, there is no (simple) way to go >> back try Choice2 if you later decide that Choice1 was wrong. We can't >> backtrack. >> >> Another problem is that if we have: >> >> a() -> foo(), bar(), baz(). >> >> and once we have completed foo() then even if it gave an answer which >> later was shown to be wrong there is no way to step back into it, backtrack, >> and let it give a new answer. >> >> In this first section we will (almost) completely ignore arguments and >> return values. >> >> When looking at control we will (almost) completely ignore arguments and >> returning values. We will use the convention that functions return either >> '{succeed,Value}' when they succeed or 'fail' when they can't find a >> solution. >> >> The trick is to ensure that functions only return at all when they fail, >> otherwise they just continue by explicitly calling the next thing which >> should be done. We will do this by using a Continue Passing Style (CPS) >> where each function will have an argument which is the next function call to >> continue. (CPS is not new and is generally known) So functions will usually >> look like this: >> >> a(Next) -> >> , >> OurNext = fun () -> even_more_stuff(Next) end, >> more_stuff(OurNext). >> >> We will use the convention that when a function fails and cannot go on it >> will return 'fail'. When *the* solution has been found then the final test >> will return {succeed,Value}. So the top level function will look something >> like: >> >> top_call() -> >> Succeed = fun () -> {succeed,yes} end, %We have succeeded >> find_solution(Succeed). >> >> So now our program will keep going forwards until it finally calls the >> Succeed fun when it all returns back to the initial caller. >> >> The next problem is to introduce 'choice points' where we can choose one >> path but still allow the code to backtrack and make another choice. This is >> the done in the function cp/1 where the argument is a list functions which >> are separate paths to choose from: >> >> cp([fun () -> do_stuff_a(Next) end, >> fun () -> do_stuff_b(Next) end, >> fun () -> do_stuff_c(Next) end, >> ...]). >> >> Cp/1 will try the functions in order, if one succeeds then the choice >> point will succeed and return the same succeed value, if it fails then the >> next function in the list will be tried, until no more exist when the choice >> point will fail: The code for cp is simple: >> >> cp([G|Gs]) -> >> case G() of >> {succeed,Value} -> {succeed,Value}; >> fail -> cp(Gs) >> end; >> cp([]) -> fail. >> >> That's it, we're done. A lot of explanation for very little code. >> >> A slight variation is to not chain the continuation together as shown here >> but to have Next as a list of functions to call. Instead of directly calling >> Next you call next/1 with argument Next, next(Next), where next/1 is defined >> as: >> >> next([N|Ns]) -> N(Ns). >> >> There is no functional difference it just make writing some code a bit >> easier. For example the function defined above: >> >> a() -> foo(), bar(), baz(). >> >> would look like this in the normal way: >> >> a(Next) -> >> Next1 = fun () -> baz(Next) end, >> Next2 = fun () -> bar(Next1) end, >> foo(Next2). >> >> while using the list variant it would look like: >> >> a(Next) -> >> foo([fun (Ns) -> bar(Ns) end, >> fun (Ns) -> baz(Ns) end | Next]). >> >> which can be easier to read, especially if there many calls in the >> continuation. >> >> After I introduce handling data in the next installment I can give a >> proper example. >> >> I have also posted this to my blogg for those who prefer to read there, >> >> Robert >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > > > -- > --Hynek (Pichi) Vychodil > > Analyze your data in minutes. Share your insights instantly. Thrill your > boss. Be a data hero! > Try Good Data now for free: www.gooddata.com > -- --Hynek (Pichi) Vychodil Analyze your data in minutes. Share your insights instantly. Thrill your boss. Be a data hero! Try Good Data now for free: www.gooddata.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From bgustavsson@REDACTED Wed Mar 18 09:30:58 2009 From: bgustavsson@REDACTED (Bjorn Gustavsson) Date: Wed, 18 Mar 2009 09:30:58 +0100 Subject: [erlang-questions] Erlang/OTP R13A has been released In-Reply-To: References: <6672d0160903170857y6c4435fctcdc4b0b9f6d67a5a@mail.gmail.com> Message-ID: <6672d0160903180130jee98c2dlbe6f30f44d4e8a0c@mail.gmail.com> On Wed, Mar 18, 2009 at 8:59 AM, zambal wrote: > Hi, > > I have a major issue with the Windows binary distribution of 13A, > because I can't compile anything. > > For example, when trying to compile the following module: > > -module(test). > -compile(export_all). > > > hallo(X) -> > "Hallo " ++ X ++ "!". > > The following error occured: > > ./test.erl:none: internal error in core_module; > crash reason: {undef,[{cerl,c_tuple, > [[{c_literal,[{name,{hallo, > 1}}],function_clause}, > {c_var,[],cor2}]]}, > {v3_core,function_clause,2}, > {v3_core,body,4}, > {v3_core,function,5}, > {v3_core,form,3}, > {lists,foldl,3}, > {v3_core,module,2}, > {compile,core_module,1}]} > error > Works fine for me. Do you happen to have an Erlang module named 'cerl' in your current working directory? (The compiler in R13A always uses a module called 'cerl', while in previous releases the 'cerl' module was only used if you turned on inlining.) /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From zambal@REDACTED Wed Mar 18 09:41:13 2009 From: zambal@REDACTED (zambal) Date: Wed, 18 Mar 2009 01:41:13 -0700 (PDT) Subject: [erlang-questions] Erlang/OTP R13A has been released In-Reply-To: <6672d0160903180130jee98c2dlbe6f30f44d4e8a0c@mail.gmail.com> References: <6672d0160903170857y6c4435fctcdc4b0b9f6d67a5a@mail.gmail.com> <6672d0160903180130jee98c2dlbe6f30f44d4e8a0c@mail.gmail.com> Message-ID: <0ac93dac-b936-4f03-a5cd-4112d5fef17c@v19g2000yqn.googlegroups.com> Woops, I indeed had a module called 'cerl' in my working directory. Renaming this module fixed the error. Thanks, vincent On 18 mrt, 09:30, Bjorn Gustavsson wrote: > Works fine for me. > > Do you happen to have an Erlang module named 'cerl' in your current > working directory? > (The compiler in R13A always uses a module called 'cerl', while in > previous releases the > 'cerl' module was only used if you turned on inlining.) > > /Bjorn > > -- > Bj?rn Gustavsson, Erlang/OTP, Ericsson AB > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions From rtrlists@REDACTED Wed Mar 18 10:18:11 2009 From: rtrlists@REDACTED (Robert Raschke) Date: Wed, 18 Mar 2009 09:18:11 +0000 Subject: [erlang-questions] Reassigning variables In-Reply-To: References: Message-ID: <6a3ae47e0903180218s5d1a0f3fof94cb189d2f2b266@mail.gmail.com> On Tue, Mar 17, 2009 at 6:02 PM, Matthew Dempsky wrote: > I like pattern matching in the majority of cases, but I find I write > enough code where I need to incrementally update a data structure, and > maintaining that code is a pain when I have code like: > > ?X = foo(), > ?X1 = bar(X), > ?X2 = xyzzy(X1), > ?blah(X2). > > and later want to change it to: > > ?X = foo(), > ?X1 = whee(X), > ?X2 = bar(X1), > ?X3 = xyzzy(X2), > ?blah(X3). > > This means having to change four lines of code, when really it's > conceptually just one change. ?I'd like to suggest being able to do > something like: > > ?X = foo(), > ?r(X) = whee(X), > ?r(X) = bar(X), > ?r(X) = xyzzy(X), > ?blah(X). > > where "r(?VAR) = ?EXPR" means to reassign ?VAR to ?EXPR, even if it > previously has an assigned value. > > Thoughts? ?Does anyone have suggestions for better syntax? ?I think > this can be handled with a parse transform, and I'm considering > writing a parse transform to handle it. ?(I haven't checked if anyone > else has proposed similar functionality in the past, but this is > something that's been bugging me for a while, and I've finally had to > rename variables manually enough times to propose this.) Usually, this kind of "problem" comes about not because of the sequence you write above. I find much more common is something along the lines of {value X} = foo(), {ok, X1} = bar(X), {ok, X2} = xyzzy(X1), blah(X2). I haven't read the whole of this long thread, so maybe some ideas cover this kind of sequence. But I have to admit, that I find code like that extremely lazy. Potentially excusable for a throw away program, but even then ... It is soooo much better to give intermediate results proper names. That way you might actually spot potential reuse of values in subsequent code expansion. Never mind noticing potential misuse of values, which using generic X or X1 won't help you with. Robby From schuett@REDACTED Wed Mar 18 10:51:46 2009 From: schuett@REDACTED (Thorsten Schuett) Date: Wed, 18 Mar 2009 10:51:46 +0100 Subject: [erlang-questions] Erlang/OTP R13A has been released In-Reply-To: <6672d0160903170857y6c4435fctcdc4b0b9f6d67a5a@mail.gmail.com> References: <6672d0160903170857y6c4435fctcdc4b0b9f6d67a5a@mail.gmail.com> Message-ID: <200903181051.47003.schuett@zib.de> Hi all, I have two comments on dialyzer in the beta version: - The opaqueness checks are great. Already found a mix up with gb_sets and gb_trees. However, the change also effects type-declarations: R13: -type(db()::gb_tree()). R12: -type(db()::gb_trees:gb_tree()). You are not allowed to specify the module of opaque types anymore. We had to add an autoconf test because there seems to be no version which works with both. This behavior doesn't seem to be documented in the ChangeLog. - To solve the problem above, our configure now adds a define for the preprocessor ({d, types_are_builtin}) for R13. And we have to do the same for dialyzer. According to the docs, dialyzer supports two versions for specifying defines "-Dname (or -Dname=value)". Unfortunately only the latter seems to work: ~/apps/otp-R13A/bin/dialyzer -Dtypes_are_builtin --src -c util.erl dialyzer: Malformed define: {defines,[types_are_builtin]} Whereas the following is fine: ~/apps/otp-R13A/bin/dialyzer -Dtypes_are_builtin=1 --src -c util.erl Thorsten On Tuesday 17 March 2009, Bjorn Gustavsson wrote: > Major relese : otp_src_R13A > Build date : 2009-03-17 > > R13A is a beta release of the next R13B major release. > We do not recommend it for use in live products. > > In the R13B release, there may be incompatibilities > in new features that were introduced in this R13A release > (for instance in the Unicode support). > > You can download the full source distribution from > > http://www.erlang.org/download/otp_src_R13A.tar.gz > http://www.erlang.org/download/otp_src_R13A.readme (this file) > > Note: To unpack the TAR archive you need a GNU TAR compatible program. > > For installation instructions please read the README that is part of > the distribution. > > The Windows binary distribution can be downloaded from > > http://www.erlang.org/download/otp_win32_R13A.exe > > > On-line documentation can be found at http://www.erlang.org/doc/. > You can also download the complete HTML documentation or the Unix manual > files > > http://www.erlang.org/download/otp_doc_html_R13A.tar.gz > http://www.erlang.org/download/otp_doc_man_R13A.tar.gz > > We also want to thank those that sent us patches, suggestions and bug > reports, > > The OTP Team From rob.charlton@REDACTED Wed Mar 18 11:14:13 2009 From: rob.charlton@REDACTED (Rob Charlton) Date: Wed, 18 Mar 2009 10:14:13 +0000 Subject: [erlang-questions] Hang making https request In-Reply-To: References: <49BFD64D.2070308@savageminds.com> Message-ID: <49C0C975.4060906@savageminds.com> Hi Ferenc, Thanks, yes, I managed to work it out in the end after doing this: http:set_options([{verbose, trace}]). ...then guessing the meaning of the messages in the trace, but it took a long time to get to that point, especially as the hang I was experiencing first showed itself as a hang in yaws_soap_lib. I was also thrown because it all "just worked" in R11. My main purpose of posting this was to ask if there could be some error printed under these circumstances, rather than the call just blocking. http:request causes some error to be printed if inets isn't started, so why shouldn't an https request cause some error to be printed if ssl isn't started? I couldn't find anything on this in the inets user guide nor in the http module reference page. A one line example in the http reference showing http:request("https://..") needing an ssl:start() would have done just as well. Many thanks, Rob Ferenc Holzhauser wrote: > Rob, > > You'd need to start ssl too for HTTPS. > > Regards, > Ferenc > > 2009/3/17 Rob Charlton > > > I have been using Erlang R11B for some time, but thought it was about > time I moved up to R12B, so I pulled down the latest today and > built it. > > Afterwards, I found that I could no longer make HTTPS requests: > > rob@REDACTED:~/work/erlang/svn/erlang/lcr$ erl > Erlang (BEAM) emulator version 5.6.5 [source] [async-threads:0] [hipe] > [kernel-poll:false] > > Eshell V5.6.5 (abort with ^G) > 1> inets:start(). > ok > 2> http:request("https://www.cia.gov/"). > > The shell is now unresponsive and I have to do a CTRL C to get it > back. > > I noticed that I had to now explicitly start inets (which used to > start > automatically) because an error message appeared when I did an http > request without it started. What I didn't realise was that I also > had to > explicitly start the ssl application. I managed to work this out by > using tracing on the http call. It won't catch me again, but will > probably catch someone else. Would it be possible to make it do > something more friendly than just hang? > > -- > Rob Charlton > Savage Minds Ltd > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > -- Rob Charlton Savage Minds Ltd From rob.lally@REDACTED Wed Mar 18 11:25:14 2009 From: rob.lally@REDACTED (Robert Lally) Date: Wed, 18 Mar 2009 10:25:14 +0000 Subject: [erlang-questions] JInterface Message-ID: Hi folks, I've just run the JInterface 1.4.2 code through the IDEA code analyser and it reports quite a few issues. Some of these are trivial - javadoc that doesn't match the function. Some are a little more significant - variables that are never read, parameters that are never used, named labels that no code ever jumps to, private constructors that are never called, declared exceptions that are never thrown. There are also a few that look quite significant - overriding finalize without calling super.finalize(). Is there a specific place to talk about JInterface issues? Or is this list the appropriate forum? -- Blog : http://robertlally.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From ferenc.holzhauser@REDACTED Wed Mar 18 11:26:53 2009 From: ferenc.holzhauser@REDACTED (Ferenc Holzhauser) Date: Wed, 18 Mar 2009 11:26:53 +0100 Subject: [erlang-questions] Hang making https request In-Reply-To: <49C0C975.4060906@savageminds.com> References: <49BFD64D.2070308@savageminds.com> <49C0C975.4060906@savageminds.com> Message-ID: Hi Rob, I fully agree with you. I'd also consider this behaviour as a bug in the http client. btw: thanks for the trace option tip. Regards, Ferenc 2009/3/18 Rob Charlton > Hi Ferenc, > > Thanks, yes, I managed to work it out in the end after doing this: > > http:set_options([{verbose, trace}]). > > ...then guessing the meaning of the messages in the trace, but it took a > long time to get to that point, especially as the hang I was experiencing > first showed itself as a hang in yaws_soap_lib. I was also thrown because it > all "just worked" in R11. > > My main purpose of posting this was to ask if there could be some error > printed under these circumstances, rather than the call just blocking. > http:request causes some error to be printed if inets isn't started, so why > shouldn't an https request cause some error to be printed if ssl isn't > started? I couldn't find anything on this in the inets user guide nor in the > http module reference page. A one line example in the http reference showing > http:request("https://..") needing an ssl:start() would have done just as > well. > > Many thanks, > > Rob > > Ferenc Holzhauser wrote: > >> Rob, >> >> You'd need to start ssl too for HTTPS. >> >> Regards, >> Ferenc >> >> 2009/3/17 Rob Charlton > rob.charlton@REDACTED>> >> >> >> I have been using Erlang R11B for some time, but thought it was about >> time I moved up to R12B, so I pulled down the latest today and >> built it. >> >> Afterwards, I found that I could no longer make HTTPS requests: >> >> rob@REDACTED:~/work/erlang/svn/erlang/lcr$ erl >> Erlang (BEAM) emulator version 5.6.5 [source] [async-threads:0] [hipe] >> [kernel-poll:false] >> >> Eshell V5.6.5 (abort with ^G) >> 1> inets:start(). >> ok >> 2> http:request("https://www.cia.gov/"). >> >> The shell is now unresponsive and I have to do a CTRL C to get it >> back. >> >> I noticed that I had to now explicitly start inets (which used to >> start >> automatically) because an error message appeared when I did an http >> request without it started. What I didn't realise was that I also >> had to >> explicitly start the ssl application. I managed to work this out by >> using tracing on the http call. It won't catch me again, but will >> probably catch someone else. Would it be possible to make it do >> something more friendly than just hang? >> >> -- >> Rob Charlton >> Savage Minds Ltd >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> >> >> > > -- > Rob Charlton > Savage Minds Ltd > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From hans.bolinder@REDACTED Wed Mar 18 10:45:44 2009 From: hans.bolinder@REDACTED (Hans Bolinder) Date: Wed, 18 Mar 2009 10:45:44 +0100 Subject: [erlang-questions] Reassigning variables In-Reply-To: References: Message-ID: <18880.49864.505762.419689@ornendil.du.uab.ericsson.se> [Matthew Dempsky:] > I like pattern matching in the majority of cases, but I find I write > enough code where I need to incrementally update a data structure, and > maintaining that code is a pain when I have code like: > > X = foo(), > X1 = bar(X), > X2 = xyzzy(X1), > blah(X2). > > and later want to change it to: > > X = foo(), > X1 = whee(X), > X2 = bar(X1), > X3 = xyzzy(X2), > blah(X3). > > This means having to change four lines of code, when really it's > conceptually just one change. Maybe I'm missing the point, but wouldn't a BASIC way of numbering variables be useful here? It would let you maintain an increasing sequence of variable names while doing just one change: X = foo(), X10 = bar(X), X20 = xyzzy(X10), blah(X20). and X = foo(), X5 = whee(X), X10 = bar(X5), X20 = xyzzy(X10), blah(X20). Best regards, Hans Bolinder, Erlang/OTP team, Ericsson From masse@REDACTED Wed Mar 18 11:32:31 2009 From: masse@REDACTED (mats cronqvist) Date: Wed, 18 Mar 2009 11:32:31 +0100 Subject: [erlang-questions] Reassigning variables In-Reply-To: (bill robertson's message of "Tue\, 17 Mar 2009 23\:20\:59 -0400") References: <87prgfkiie.fsf@sterlett.hq.kred> Message-ID: <87eiwvjf40.fsf@sterlett.hq.kred> bill robertson writes: >> ?So I think the X1 = f(X), X2 = f(X1) anti-pattern is not a weakness >> ?of the language; it's Erlang's way of telling you that you should >> ?use more functions. >> >> ?mats > > This is an honest question. How is re-assignment of local variables > bad? Because it's difficult to read, and therefore to maintain. From kostis@REDACTED Wed Mar 18 11:42:12 2009 From: kostis@REDACTED (Kostis Sagonas) Date: Wed, 18 Mar 2009 12:42:12 +0200 Subject: [erlang-questions] Erlang/OTP R13A has been released In-Reply-To: <200903181051.47003.schuett@zib.de> References: <6672d0160903170857y6c4435fctcdc4b0b9f6d67a5a@mail.gmail.com> <200903181051.47003.schuett@zib.de> Message-ID: <49C0D004.50507@cs.ntua.gr> Thorsten Schuett wrote: > Hi all, > > I have two comments on dialyzer in the beta version: > > - The opaqueness checks are great. Thanks! I also think so ;-) > Already found a mix up with gb_sets and > gb_trees. However, the change also effects type-declarations: > R13: > -type(db()::gb_tree()). > R12: > -type(db()::gb_trees:gb_tree()). > You are not allowed to specify the module of opaque types anymore. This is not an accurate description of the issue. What has happened is that R13 comes with some more built-in types (some opaque types are just a subset of these built-ins, but there are more of them e.g. timeout()). The reader/linter (note: not dialyzer) prefers that these are not module-qualified -- otherwise you would have to write erlang:timeout() and gb_trees:gb_tree() all over the place. But you are right that this has not been documented anywhere and it's a bit of a pain if you want to use different Erlang/OTP versions to compile the same source file. > We had to > add an autoconf test because there seems to be no version which works with > both. This behavior doesn't seem to be documented in the ChangeLog. > > - To solve the problem above, our configure now adds a define for the > preprocessor ({d, types_are_builtin}) for R13. And we have to do the same for > dialyzer. According to the docs, dialyzer supports two versions for specifying > defines "-Dname (or -Dname=value)". Unfortunately only the latter seems to > work: I was not aware that this got broken. It will be fixed for R13B. Thanks for your report! Kostis From thomasl_erlang@REDACTED Wed Mar 18 11:15:20 2009 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Wed, 18 Mar 2009 03:15:20 -0700 (PDT) Subject: [erlang-questions] Backtracking in Erlang, part 1 - control In-Reply-To: <3dbc6d1c0903171901j216536a0m61280c679383e6be@mail.gmail.com> References: <3dbc6d1c0903171901j216536a0m61280c679383e6be@mail.gmail.com> Message-ID: <3309.57829.qm@web111402.mail.gq1.yahoo.com> As an alternative to the "stack of funs" in cp/1, you can encode the failure continuation in CPS too. (Someone proposed the name "double-barreled CPS" for this, which I thought was pretty good). There are some advantages to doing it that way, less space used, short-circuiting comes naturally and so on. In my Prolog days, I wrote a couple of papers on that topic, which as it happens also reference some work on encoding Prolog in Lisp that may be of interest. A Continuation-Passing Style for Prolog - Lindgren (ResearchIndex) Control flow analysis of Prolog (extended remix) (ResearchIndex) Best, Thomas ________________________________ From: Robert Virding To: erlang-questions Sent: Wednesday, March 18, 2009 3:01:14 AM Subject: [erlang-questions] Backtracking in Erlang, part 1 - control Sometimes you need to be able to do search algorithms which can step back and try other alternate ways of finding a solution, "backtracking". Generally this is difficult to do in functional languages like Erlang (most other languages too for that matter). A classic example of this type of problem is parsing ambiguous grammars. Prolog syntax is like that, in some cases you need almost indefinite look-ahead before you can decide how input is to be parsed. When I implemented Erlog (a prolog in and for Erlang) I decided to do the parser in Erlang so that it could run stand-alone and so I ran straight into this problem. Here is *a* solution to the problem. It is in two parts, the first describing the control structures and the second (more difficult) describing handling of data. There may also be a third part discussing some problems with the solution to control, if anyone is still interested. The main problem we have to overcome is that normally when you choose a path you "commit" to it and can't go back and try an alternate path. For example in: case get_a_value() of Choice1 -> ... ; Choice2 -> ... ; ... end once you have chosen a path, say Choice1, there is no (simple) way to go back try Choice2 if you later decide that Choice1 was wrong. We can't backtrack. Another problem is that if we have: a() -> foo(), bar(), baz(). and once we have completed foo() then even if it gave an answer which later was shown to be wrong there is no way to step back into it, backtrack, and let it give a new answer. In this first section we will (almost) completely ignore arguments and return values. When looking at control we will (almost) completely ignore arguments and returning values. We will use the convention that functions return either '{succeed,Value}' when they succeed or 'fail' when they can't find a solution. The trick is to ensure that functions only return at all when they fail, otherwise they just continue by explicitly calling the next thing which should be done. We will do this by using a Continue Passing Style (CPS) where each function will have an argument which is the next function call to continue. (CPS is not new and is generally known) So functions will usually look like this: a(Next) -> , OurNext = fun () -> even_more_stuff(Next) end, more_stuff(OurNext). We will use the convention that when a function fails and cannot go on it will return 'fail'. When *the* solution has been found then the final test will return {succeed,Value}. So the top level function will look something like: top_call() -> Succeed = fun () -> {succeed,yes} end, %We have succeeded find_solution(Succeed). So now our program will keep going forwards until it finally calls the Succeed fun when it all returns back to the initial caller.. The next problem is to introduce 'choice points' where we can choose one path but still allow the code to backtrack and make another choice. This is the done in the function cp/1 where the argument is a list functions which are separate paths to choose from: cp([fun () -> do_stuff_a(Next) end, fun () -> do_stuff_b(Next) end, fun () -> do_stuff_c(Next) end, ...]). Cp/1 will try the functions in order, if one succeeds then the choice point will succeed and return the same succeed value, if it fails then the next function in the list will be tried, until no more exist when the choice point will fail: The code for cp is simple: cp([G|Gs]) -> case G() of {succeed,Value} -> {succeed,Value}; fail -> cp(Gs) end; cp([]) -> fail. That's it, we're done. A lot of explanation for very little code. A slight variation is to not chain the continuation together as shown here but to have Next as a list of functions to call. Instead of directly calling Next you call next/1 with argument Next, next(Next), where next/1 is defined as: next([N|Ns]) -> N(Ns). There is no functional difference it just make writing some code a bit easier. For example the function defined above: a() -> foo(), bar(), baz(). would look like this in the normal way: a(Next) -> Next1 = fun () -> baz(Next) end, Next2 = fun () -> bar(Next1) end, foo(Next2). while using the list variant it would look like: a(Next) -> foo([fun (Ns) -> bar(Ns) end, fun (Ns) -> baz(Ns) end | Next]). which can be easier to read, especially if there many calls in the continuation. After I introduce handling data in the next installment I can give a proper example. I have also posted this to my blogg for those who prefer to read there, Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: From masse@REDACTED Wed Mar 18 11:44:54 2009 From: masse@REDACTED (mats cronqvist) Date: Wed, 18 Mar 2009 11:44:54 +0100 Subject: [erlang-questions] Reassigning variables In-Reply-To: (bill robertson's message of "Tue\, 17 Mar 2009 23\:20\:59 -0400") References: <87prgfkiie.fsf@sterlett.hq.kred> Message-ID: <87ab7jjejd.fsf@sterlett.hq.kred> bill robertson writes: >> ?So I think the X1 = f(X), X2 = f(X1) anti-pattern is not a weakness >> ?of the language; it's Erlang's way of telling you that you should >> ?use more functions. >> >> ?mats > > This is an honest question. How is re-assignment of local variables > bad? it is also easier to debug code with many small functions, because of the trace functionality. E.g. using redbug, a small wrapper around erlang:trace/trace_pattern; 105> redbug:start(10000,20,{erlang,now}). 11:38:51 {erlang,now,[]} 11:38:51 {erlang,now,[]} 11:38:51 {erlang,now,[]} 11:38:52 <{yaws_server,gserv,3}> {erlang,now,[]} 11:38:52 <{yaws_server,gserv,3}> {erlang,now,[]} Basically, it's like having a printf at every function head. The trace function alone is reason enough never to number variables, nest cases or anything else that promotes large functions. mats From attila.r.nohl@REDACTED Wed Mar 18 11:48:34 2009 From: attila.r.nohl@REDACTED (Attila Rajmund Nohl) Date: Wed, 18 Mar 2009 11:48:34 +0100 Subject: [erlang-questions] Reassigning variables In-Reply-To: <20090317214258.GQ32606@h216-235-12-174.host.egate.net> References: <879778450903171338j5f47e27fm6b6016906dff0159@mail.gmail.com> <20090317214258.GQ32606@h216-235-12-174.host.egate.net> Message-ID: <401d3ba30903180348r287019d0l75ea8bb383ff6e@mail.gmail.com> 2009/3/17, Vance Shipley : > On Tue, Mar 17, 2009 at 02:19:48PM -0700, Matthew Dempsky wrote: > } Similarly, Erlang doesn't support 'return' > > Doesn't it? > > } if requested ad size is bad: > } return {skip, bad_size} > } if the game has ads disabled: > } return {skip, disabled} > } if the game is filtering a domain: > } return {skip, domain_filtered} > } return choose_ad() > > try begin > case requested_ad_size(Size) of > bad -> > throw(bad_size); > _ -> > ok > end, > case has_ads() of > true -> > throw(disabled); > false -> > ok > end, > case is_filtering() of > true -> > throw(domain_filtered); > false -> > ok > end > end of > ok -> > yahoo > catch > Problem -> > Problem > end 7 lines (easily fit into one screen) vs 25 lines (probably not much other than this code is shown on the screen) full of no-ops like "_ -> ok" - a really bad idea in my opinion. From thomasl_erlang@REDACTED Wed Mar 18 10:59:29 2009 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Wed, 18 Mar 2009 02:59:29 -0700 (PDT) Subject: [erlang-questions] Please help me relate a past project to Erlang, I'm trying to understand... In-Reply-To: References: <61169.51377.qm@web111416.mail.gq1.yahoo.com> <449653.76030.qm@web111405.mail.gq1.yahoo.com> Message-ID: <721392.80151.qm@web111410.mail.gq1.yahoo.com> ----- Original Message ---- > From: bill robertson > To: erlang-questions@REDACTED > Sent: Wednesday, March 18, 2009 3:59:07 AM > Subject: Re: [erlang-questions] Please help me relate a past project to Erlang, I'm trying to understand... > > Thats good. Now, to make it *stateful* (and this is the heart of the > question). Suppose you have the requirement to allow a web user to > view the call as it is in progress and show them who is connected > (telephone number), and how long they have been connected, and also > who is disconnected and how long they were connected. > > To do this, you need to track three items for each participant. The > telephone number. The start time, and a stop time. > > So network request comes in, we have to enumerate those pieces of > information for it and send them back to the client. > > How would you implement this in a typical Erlang system? The simplest approach is to use plain erlang and message passing. Something like: start_conference_call(Name) -> spawn_link( fun() -> register(Name, self()), Empty_state = [], conf_call_loop(Empty_state) end). conf_call_loop(Callers) -> receive {join, Caller} -> Time = erlang:now(), conf_call_loop([{Caller, Time}|Callers]); %% add a new caller {leave, Caller} -> conf_call_loop(delete_caller(Caller, Callers)); %% delete a caller {message, From, Msg} -> %% send message to all participants send_to_all(Callers, Msg), conf_call_loop(Callers); {status, Asker} -> %% send status to asking process Asker ! {status, Callers}, conf_call_loop(Callers); stop -> ok end. %% Client API status(ConfCall) -> ConfCall ! {status, self()}, receive {status, Callers} -> {status, Callers} end. ... (code for some left-out functions) ... So, the conference call process keeps its state as a list passed arounf in conf_call_loop/1. Callers can join and leave and send messages to each other, all by sending messages to this process. You can also ask for status (which here just returns the list of callers and their join time) and stop the process. So, the conference call process itself is just a tail recursive function conf_call_loop/1 that processes messages forever (or until stopped). The state = list of callers lives as long as the conference call process. (Each caller would then itself be an erlang process, passing messages to/from the telephony driver and conference call process and any others involved.) Now, this is of course just a sketch, since the code is sloppy and you'd want to handle more cases in practice, _but_ it demonstrates the very simplest way to keep state. Best, Thomas From rob.lally@REDACTED Wed Mar 18 12:11:45 2009 From: rob.lally@REDACTED (Robert Lally) Date: Wed, 18 Mar 2009 11:11:45 +0000 Subject: [erlang-questions] Please help me relate a past project to Erlang, I'm trying to understand... In-Reply-To: <721392.80151.qm@web111410.mail.gq1.yahoo.com> References: <61169.51377.qm@web111416.mail.gq1.yahoo.com> <449653.76030.qm@web111405.mail.gq1.yahoo.com> <721392.80151.qm@web111410.mail.gq1.yahoo.com> Message-ID: As I've been learning Erlang, this has been the hardest thing to get to grips with. The fact that I often don't need to explicitly store my state anywhere, it will hang out in a receive block waiting for me to get back to it seems counter-intuitive. I crave a neat, labelled pigeon hole to store my state in .. but I don't need it. Rob Lally. 2009/3/18 Thomas Lindgren > > ----- Original Message ---- > > From: bill robertson > > > > To: erlang-questions@REDACTED > > Sent: Wednesday, March 18, 2009 3:59:07 AM > > Subject: Re: [erlang-questions] Please help me relate a past project to > Erlang, I'm trying to understand... > > > > Thats good. Now, to make it *stateful* (and this is the heart of the > > question). Suppose you have the requirement to allow a web user to > > view the call as it is in progress and show them who is connected > > (telephone number), and how long they have been connected, and also > > who is disconnected and how long they were connected. > > > > To do this, you need to track three items for each participant. The > > telephone number. The start time, and a stop time. > > > > So network request comes in, we have to enumerate those pieces of > > information for it and send them back to the client. > > > > How would you implement this in a typical Erlang system? > > > The simplest approach is to use plain erlang and message passing. Something > like: > > start_conference_call(Name) -> > spawn_link( > fun() -> > register(Name, self()), > Empty_state = [], > conf_call_loop(Empty_state) > end). > > conf_call_loop(Callers) -> > receive > {join, Caller} -> > Time = erlang:now(), > conf_call_loop([{Caller, Time}|Callers]); %% add a new caller > {leave, Caller} -> > conf_call_loop(delete_caller(Caller, Callers)); %% delete a caller > {message, From, Msg} -> %% send message to all participants > send_to_all(Callers, Msg), > conf_call_loop(Callers); > {status, Asker} -> %% send status to asking process > Asker ! {status, Callers}, > conf_call_loop(Callers); > stop -> > ok > end. > > %% Client API > status(ConfCall) -> > ConfCall ! {status, self()}, > receive > {status, Callers} -> {status, Callers} > end. > > ... (code for some left-out functions) ... > > So, the conference call process keeps its state as a list passed arounf in > conf_call_loop/1. Callers can join and leave and send messages to each > other, all by sending messages to this process. You can also ask for status > (which here just returns the list of callers and their join time) and stop > the process. So, the conference call process itself is just a tail recursive > function conf_call_loop/1 that processes messages forever (or until > stopped). The state = list of callers lives as long as the conference call > process. > > (Each caller would then itself be an erlang process, passing messages > to/from the telephony driver and conference call process and any others > involved.) > > Now, this is of course just a sketch, since the code is sloppy and you'd > want to handle more cases in practice, _but_ it demonstrates the very > simplest way to keep state. > > Best, > Thomas > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- Blog : http://robertlally.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From pguyot@REDACTED Wed Mar 18 12:16:14 2009 From: pguyot@REDACTED (Paul Guyot) Date: Wed, 18 Mar 2009 12:16:14 +0100 Subject: [erlang-questions] JInterface In-Reply-To: References: Message-ID: <84E4C36B-AC00-483E-BCCF-0840B835CE5D@kallisys.net> > Date: Wed, 18 Mar 2009 10:25:14 +0000 > From: Robert Lally > Subject: [erlang-questions] JInterface > To: erlang-questions@REDACTED > Message-ID: > > Content-Type: text/plain; charset="iso-8859-1" > > Hi folks, > I've just run the JInterface 1.4.2 code through the IDEA code > analyser and > it reports quite a few issues. Some of these are trivial - javadoc > that > doesn't match the function. Some are a little more significant - > variables > that are never read, parameters that are never used, named labels > that no > code ever jumps to, private constructors that are never called, > declared > exceptions that are never thrown. There are also a few that look quite > significant - overriding finalize without calling super.finalize(). > > Is there a specific place to talk about JInterface issues? Or is > this list > the appropriate forum? I'd also like to know. Several months ago, I reported to erlang-bugs@ a bad flaw of JInterface 1.4.2 (OtpErlangRef.equals() is overridden, but not hashCode(), making refs useless in most Java collections), and while a fix is trivial, the problem is still present in JInterface 1.5. Fortunately, Erlang/OTP is open source. This makes bug fixing and patching very easy. As a result, we apply many (20+) patches on production servers. We submitted patches for bugs we fixed, so other users won't have to go through the burden of identifying the bugs, making sure they are in Erlang/OTP and fixing them. I'd like to insist that bugs in what might be considered as obscure parts of OTP definitely affect several users, for example one can find several workarounds in open source projects (e.g. tcerl) for bugs we fixed in erl_interface. Some of our patches have even been included in MacPorts and FreeBSD ports distributions. Yet, I wish more patches were included upstream and related bugs were fixed. Paul From oscar@REDACTED Wed Mar 18 12:41:43 2009 From: oscar@REDACTED (=?ISO-8859-1?Q?Oscar_Hellstr=F6m?=) Date: Wed, 18 Mar 2009 11:41:43 +0000 Subject: [erlang-questions] Reassigning variables In-Reply-To: <200903172211.57830.peter@sabaini.at> References: <87prgfkiie.fsf@sterlett.hq.kred> <200903172211.57830.peter@sabaini.at> Message-ID: <49C0DDF7.7000406@erlang-consulting.com> Hi, Peter Sabaini wrote: > On Tuesday 17 March 2009 21:21:29 mats cronqvist wrote: > >> Matthew Dempsky writes: >> >>> I like pattern matching in the majority of cases, but I find I write >>> enough code where I need to incrementally update a data structure, and >>> maintaining that code is a pain when I have code like: >>> >>> X = foo(), >>> X1 = bar(X), >>> X2 = xyzzy(X1), >>> blah(X2). >>> >>> and later want to change it to: >>> >>> X = foo(), >>> X1 = whee(X), >>> X2 = bar(X1), >>> X3 = xyzzy(X2), >>> blah(X3). >>> >> Apologies in advance for calling you a noob. >> > > You can call me a noob, I don't mind ;-) > > >> But in my experience, all beginners start off writing code like the >> above. Whereas seasoned Erlangers produce something more like this; >> >> x() -> >> blah_it(xyzzy(make_whee(foo()))). >> > > IMHO intermediate values are sometimes quite useful if not necessary -- I > often find myself needing to break up some such nested function calls just for > a temporary ?debugFmt() or logging call -- this is a bit of a nuisance. This > is compounded by the fact that often the punctuation needs to change too in > such cases. > > For the logging yes, but for ?debugFmt() you should probably be looking at something like the dbg module, or the trace bif, and avoid having debug macros in your code completely. But if you look at intermediate variables such as X1, X2, X3 etc, how often do you log all of them and not just the final result? > Note I'm not advocating mutable vars, I'm fine with hand-versioning my vars, > but it *does* add a bit of typing. > > peter. > > > >> make_whee(X) -> >> case whee(X) of >> {A,B} -> bar(A); >> {A,B,C}-> bar(A) >> end. >> >> blah_it(X) when is_atom(X) -> blah(X); >> blah_it(X) when is_list(X) -> blah(list_to_atom(X)). >> >> >> I've added some stuff to your example to make it less trivial, but >> it's basically the same. >> >> So I think the X1 = f(X), X2 = f(X1) anti-pattern is not a weakness >> of the language; it's Erlang's way of telling you that you should >> use more functions. >> >> mats >> > > > ------------------------------------------------------------------------ > > _______________________________________________ > 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 Ltd http://www.erlang-consulting.com/ From bbmaj7@REDACTED Wed Mar 18 12:49:31 2009 From: bbmaj7@REDACTED (Richard Andrews) Date: Wed, 18 Mar 2009 04:49:31 -0700 (PDT) Subject: [erlang-questions] erlang BGP? Message-ID: <44542.83536.qm@web65514.mail.ac4.yahoo.com> Is there a BGP module for erlang? Stay connected to the people that matter most with a smarter inbox. Take a look http://au.docs.yahoo.com/mail/smarterinbox From chsu79@REDACTED Wed Mar 18 13:02:17 2009 From: chsu79@REDACTED (Christian) Date: Wed, 18 Mar 2009 13:02:17 +0100 Subject: [erlang-questions] Reassigning variables In-Reply-To: <18880.49864.505762.419689@ornendil.du.uab.ericsson.se> References: <18880.49864.505762.419689@ornendil.du.uab.ericsson.se> Message-ID: I dont find these helpful-suggestion-threads for erlang improvement for erlang to become a more popular language to be all that interesting anymore (erlang seems to be doing very well on actual technical merits already). And spokespeople for OTP have already made it clear that rebinding is not a feature that will ever be added to Erlang. There is Reia and such approaches for those so inclined. (Not that Hans is suggesting that feature) But I think Hans is very close to the real approach: To stop using silly numbered variables, as they are the real issue. What is a X1 or a X2 ? Rather than X1 = binary_to_list(Bin), X2 = lists:reverse(X1) do String = binary_to_list(Bin), RevString = lists:reverse(String), or use lists:reverse(binary_to_list(Bin)) And when the number of variables grow large, decompose into functions. PS. And NO. Rebinding variables is not a good idea. It makes you have to think about what the value is of a variable now, instead of the much simpler "what was this variable bound to". The later makes it easier to understand real code. It is similar to how even the best humans at multitasking can only do tops 7 things at once. The problem is that when programming the brain just covers up that it is failing to understand something, just like none of us are actively aware of the huge blind spot near the middle of our vision field. http://en.wikipedia.org/wiki/Blind_spot_(vision). From nm@REDACTED Wed Mar 18 13:38:19 2009 From: nm@REDACTED (Gaspar Chilingarov) Date: Wed, 18 Mar 2009 16:38:19 +0400 Subject: [erlang-questions] Reassigning variables In-Reply-To: <214D70B1-B485-4072-8D2F-1B7C87ABC24D@cs.otago.ac.nz> References: <214D70B1-B485-4072-8D2F-1B7C87ABC24D@cs.otago.ac.nz> Message-ID: <49C0EB3B.1020300@web.am> I'm totally agree with you, Richard! Even in complex project I had practically no need of reassignment. 1. There is a nested calls which is possible to format nicely f1( f2( f3( Args ) ) ); 2. If you need complex and very flexible solution - implement simple stack machine - you pass to the interpreter 2 lists - list of functions to be called, the initial stack (well, I've beed passing there also application/process global state variable) As a single processing function result you get: {continue, NewStack, NewState} - continue applying next command in a command list {error, ErrorMsg, NewState} - stop processing and throw a message (we got an error) {ok, Result, NewState} - stop processing and return some value to calling function. It's rather easy to write/debug such kind of interpreter and then describe ALL necessary logic in that interpreter. (We had an interpreter for web-based application - form generation/validation/submit processing and etc). We also described all the periodic tasks occurring in the system as a such command list (btw closures+mnesia rule in term of keeping application state intact for further processing). Well :) It took 2 software revisions to get there :) Using positional/named registers was too hard and messing all the things up. Tip: for easier processing attach to variables in stack their type - which will make finding errors in your processing chains easier. -- Gaspar Chilingarov tel +37493 419763 (mobile - leave voice mail message) icq 63174784 skype://gasparch e mailto:nm@REDACTED mailto:gasparch@REDACTED w http://gasparchilingarov.com/ From steven.charles.davis@REDACTED Wed Mar 18 13:39:36 2009 From: steven.charles.davis@REDACTED (Steve Davis) Date: Wed, 18 Mar 2009 05:39:36 -0700 (PDT) Subject: [erlang-questions] erlang BGP? In-Reply-To: <44542.83536.qm@web65514.mail.ac4.yahoo.com> References: <44542.83536.qm@web65514.mail.ac4.yahoo.com> Message-ID: This may be helpful... http://habetsppse.blogspot.com/2008/07/erlang-bgp-daemon.html On Mar 18, 6:49?am, Richard Andrews wrote: > Is there a BGP module for erlang? > > ? ? ? Stay connected to the people that matter most with a smarter inbox. Take a lookhttp://au.docs.yahoo.com/mail/smarterinbox > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions From rickard.s.green@REDACTED Wed Mar 18 13:17:46 2009 From: rickard.s.green@REDACTED (Rickard Green) Date: Wed, 18 Mar 2009 13:17:46 +0100 Subject: [erlang-questions] Erlang/OTP R13A has been released Message-ID: <49C0E66A.3050703@ericsson.com> Ulf Wiger wrote: > Zvi wrote: >> Hi, >> >> "Erlang R13A (erts-5.7) [smp:2:2] [rq:2] [async-threads:0] >> >> Eshell V5.7 (abort with ^G) >> 1>" >> >> >> what's the meaning of "[smp:2:2]" and "[rq:2]" ? >> Does "[smp:2:2]" means two schedulers and two corresponding run queues? >> I guess "rq" is for "run queues" ? > > I believe I have figured out that it's > [smp:Schedulers:SchedulersOnline], and "rq" indeed stands > for run-queues (well, I'm guessing. Can't find it documented.) > Correct. > So with the +S Schedulers:SchedulersOnline, you can set > how many schedulers you want to be able to play with. > You can change the number of active schedulers, using > erlang:system_flag(schedulers_online, N), setting it to > a value between 1 and Schedulers (which can only be set > at boot time.) > > Reading about this, I was a bit confused by one thing: > On erlang:system_flag(scheduler_bind_type, T), it says > > "How schedulers are bound matters. For example, in low > load situations, the runtime system tries to migrate > processes to schedulers with low scheduler identifiers. > The more the schedulers are spread over the hardware, > the more resources will be available to the runtime > system in low load situations. " > > Forgive me for being glib, but why does it matter at > all how I can optimize CPU usage at low load? (: > Ok, from an energy consumption POV, I guess it can make > a difference, but I've mainly come to think that as > long as there is excess CPU capacity, there is very > little reason to optimize things. > > I would be much more interested in hearing how this > can make a different during high load, or hear a > more detailed explanation of why low-load optimizations > are important to me. > What is meant by low load situations here is maybe not clear. Low load situations here are situations with fewer running processes than schedulers, and high load situations here are situations with more runnable and running processes than schedulers. The external load on the system might be high even in internal low load situations. In a high load situation the bind order currently doesn't matter. However, this might change in the future. But it does matter in low load situations, also from a performance point of view. An example from a performance point of view: If you have two running processes, it is better if they execute on different cores than on different hyperthreads of the same core. > BR, > Ulf W > -- > Ulf Wiger > CTO, Erlang Training & Consulting Ltd > http://www.erlang-consulting.com Regards, Rickard -- Rickard Green, Erlang/OTP, Ericsson AB. From masse@REDACTED Wed Mar 18 14:28:15 2009 From: masse@REDACTED (mats cronqvist) Date: Wed, 18 Mar 2009 14:28:15 +0100 Subject: [erlang-questions] wx + debian Message-ID: <87wsanhseo.fsf@sterlett.hq.kred> Just a note to help people trying to build wx on Debian and derivatives (such as ubuntu.) I've found the minimal requirements to be; apt-get install freeglut3-dev libwxgtk2.8-dev g++ Also, there seems to be a caching problem; if these packages are not installed when configure runs, subsequent configures will also fail. Deleting the build directory and re-unpacking the tarball works. There's probably a better method that I'm unaware of. mats From kostis@REDACTED Wed Mar 18 14:29:22 2009 From: kostis@REDACTED (Kostis Sagonas) Date: Wed, 18 Mar 2009 15:29:22 +0200 Subject: [erlang-questions] Erlang/OTP R13A has been released In-Reply-To: <200903181051.47003.schuett@zib.de> References: <6672d0160903170857y6c4435fctcdc4b0b9f6d67a5a@mail.gmail.com> <200903181051.47003.schuett@zib.de> Message-ID: <49C0F732.1090309@cs.ntua.gr> Thorsten Schuett wrote: > ... According to the docs, dialyzer supports two versions for specifying > defines "-Dname (or -Dname=value)". Unfortunately only the latter seems to > work: > ~/apps/otp-R13A/bin/dialyzer -Dtypes_are_builtin --src -c util.erl > > dialyzer: Malformed define: {defines,[types_are_builtin]} Just in case anybody wants a fix for the above, the following patch fixes the issue: Kostis Index: lib/dialyzer/src/dialyzer_cl_parse.erl =================================================================== RCS file: /hipe/otp/lib/dialyzer/src/dialyzer_cl_parse.erl,v retrieving revision 1.57 diff -u -w -r1.57 dialyzer_cl_parse.erl --- lib/dialyzer/src/dialyzer_cl_parse.erl 10 Mar 2009 09:28:26 -0000 1 .57 +++ lib/dialyzer/src/dialyzer_cl_parse.erl 18 Mar 2009 13:26:32 -0000 @@ -238,7 +238,7 @@ {ok, ErlVal} = erl_parse:parse_term(Tokens), append_var(dialyzer_options_defines, [{list_to_atom(Def), ErlVal}]); append_defines([Def]) -> - append_var(dialyzer_options_defines, [list_to_atom(Def)]). + append_var(dialyzer_options_defines, [{list_to_atom(Def), true}]). append_include(Dir) -> append_var(dialyzer_include, [Dir]). From masse@REDACTED Tue Mar 17 21:21:29 2009 From: masse@REDACTED (mats cronqvist) Date: Tue, 17 Mar 2009 21:21:29 +0100 Subject: [erlang-questions] Reassigning variables In-Reply-To: (Matthew Dempsky's message of "Tue\, 17 Mar 2009 11\:02\:20 -0700") References: Message-ID: <87prgfkiie.fsf@sterlett.hq.kred> Matthew Dempsky writes: > I like pattern matching in the majority of cases, but I find I write > enough code where I need to incrementally update a data structure, and > maintaining that code is a pain when I have code like: > > X = foo(), > X1 = bar(X), > X2 = xyzzy(X1), > blah(X2). > > and later want to change it to: > > X = foo(), > X1 = whee(X), > X2 = bar(X1), > X3 = xyzzy(X2), > blah(X3). Apologies in advance for calling you a noob. But in my experience, all beginners start off writing code like the above. Whereas seasoned Erlangers produce something more like this; x() -> blah_it(xyzzy(make_whee(foo()))). make_whee(X) -> case whee(X) of {A,B} -> bar(A); {A,B,C}-> bar(A) end. blah_it(X) when is_atom(X) -> blah(X); blah_it(X) when is_list(X) -> blah(list_to_atom(X)). I've added some stuff to your example to make it less trivial, but it's basically the same. So I think the X1 = f(X), X2 = f(X1) anti-pattern is not a weakness of the language; it's Erlang's way of telling you that you should use more functions. mats From leon@REDACTED Wed Mar 18 13:43:45 2009 From: leon@REDACTED (Leon de Rooij) Date: Wed, 18 Mar 2009 13:43:45 +0100 Subject: [erlang-questions] erlang BGP? In-Reply-To: <44542.83536.qm@web65514.mail.ac4.yahoo.com> References: <44542.83536.qm@web65514.mail.ac4.yahoo.com> Message-ID: <7AA8C948-4845-44E3-99C3-73FD8EF2E955@toyos.nl> Here's a link that I found a while ago: http://habetsppse.blogspot.com/2008/07/erlang-bgp-daemon.html I didn't try it though.. regards, Leon On Mar 18, 2009, at 12:49 PM, Richard Andrews wrote: > > Is there a BGP module for erlang? > > > Stay connected to the people that matter most with a smarter > inbox. Take a look http://au.docs.yahoo.com/mail/smarterinbox > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From ulf.wiger@REDACTED Wed Mar 18 15:29:01 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Wed, 18 Mar 2009 15:29:01 +0100 Subject: [erlang-questions] Erlang/OTP R13A has been released In-Reply-To: <49C0E66A.3050703@ericsson.com> References: <49C0E66A.3050703@ericsson.com> Message-ID: <49C1052D.80906@erlang-consulting.com> Rickard Green wrote: > > What is meant by low load situations here is maybe not clear. Low > load situations here are situations with fewer running processes than > schedulers, and high load situations here are situations with more > runnable and running processes than schedulers. The external load on > the system might be high even in internal low load situations. > > In a high load situation the bind order currently doesn't matter. > However, this might change in the future. But it does matter in low > load situations, also from a performance point of view. > > An example from a performance point of view: If you have two running > processes, it is better if they execute on different cores than on > different hyperthreads of the same core. Ah, then I understand much better. Thanks. (: BR, Ulf W -- Ulf Wiger CTO, Erlang Training & Consulting Ltd http://www.erlang-consulting.com From daveb@REDACTED Wed Mar 18 15:47:23 2009 From: daveb@REDACTED (Dave Bryson) Date: Wed, 18 Mar 2009 09:47:23 -0500 Subject: [erlang-questions] Restore state on supervisor restart Message-ID: I have a gen_server that's linked to a supervisor. When the gen_server is started it uses some arguments passed on the command line to erl to setup its state. If the gen_server dies, I want the supervisor to use the gen_server's last state to restart it. How can I pass the last state of the dying gen_server to the supervisor for restart? Is this possible without persisting the state to disk? Thanks, Dave From cthulahoops@REDACTED Wed Mar 18 16:13:10 2009 From: cthulahoops@REDACTED (Adam Kelly) Date: Wed, 18 Mar 2009 15:13:10 +0000 Subject: [erlang-questions] Current function is undefined? Message-ID: <8d1798e90903180813j18bb5d33l2630e92804581083@mail.gmail.com> Hi, Under what circumstances would the current function of a process be undefined? > erlang:process_info(Pid, current_function). {current_function,undefined} I had a process which seemed to be just stuck doing nothing leading to {message_queue_len,2781388}. Thanks, Adam. From rhythm.mail@REDACTED Wed Mar 18 16:16:26 2009 From: rhythm.mail@REDACTED (=?gb18030?Q?=C1=AC=B3=C7?=) Date: Wed, 18 Mar 2009 23:16:26 +0800 Subject: [erlang-questions] [translation] Concurrent Programming in Erlang Chinese version Message-ID: <49C1104A.8020001@gmail.com> An HTML attachment was scrubbed... URL: From masse@REDACTED Wed Mar 18 14:28:15 2009 From: masse@REDACTED (mats cronqvist) Date: Wed, 18 Mar 2009 14:28:15 +0100 Subject: [erlang-questions] wx + debian Message-ID: <87wsanhseo.fsf@sterlett.hq.kred> Just a note to help people trying to build wx on Debian and derivatives (such as ubuntu.) I've found the minimal requirements to be; apt-get install freeglut3-dev libwxgtk2.8-dev g++ Also, there seems to be a caching problem; if these packages are not installed when configure runs, subsequent configures will also fail. Deleting the build directory and re-unpacking the tarball works. There's probably a better method that I'm unaware of. mats From billrobertson42+erlang@REDACTED Wed Mar 18 04:20:59 2009 From: billrobertson42+erlang@REDACTED (bill robertson) Date: Tue, 17 Mar 2009 23:20:59 -0400 Subject: [erlang-questions] Reassigning variables In-Reply-To: <87prgfkiie.fsf@sterlett.hq.kred> References: <87prgfkiie.fsf@sterlett.hq.kred> Message-ID: > ?So I think the X1 = f(X), X2 = f(X1) anti-pattern is not a weakness > ?of the language; it's Erlang's way of telling you that you should > ?use more functions. > > ?mats This is an honest question. How is re-assignment of local variables bad? They have no life outside their stack frame. So there is no risk of side-effects. Is it a style issue or is there something else? From ulf.wiger@REDACTED Wed Mar 18 17:19:29 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Wed, 18 Mar 2009 17:19:29 +0100 Subject: [erlang-questions] Restore state on supervisor restart Message-ID: The supervisor will always start the child with the same arguments, for better or for worse. A common trick is to create an ets table in the supervisor (e.g. in the supervisor init() callback, or in the child start function before spawning the process, taking care not to try to create it more than once.) This way, your server can store data in the ets table that survives a process crash (but not an escalate restart.) Using a mnesia ram_copy table is also possible. BR, Ulf W -- originalmedd. -- ?mne: [erlang-questions] Restore state on supervisor restart Fr?n: Dave Bryson Datum: 2009.03.18 15.48 I have a gen_server that's linked to a supervisor. When the gen_server is started it uses some arguments passed on the command line to erl to setup its state. If the gen_server dies, I want the supervisor to use the gen_server's last state to restart it. How can I pass the last state of the dying gen_server to the supervisor for restart? Is this possible without persisting the state to disk? Thanks, Dave _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions From dmercer@REDACTED Wed Mar 18 17:27:08 2009 From: dmercer@REDACTED (David Mercer) Date: Wed, 18 Mar 2009 11:27:08 -0500 Subject: [erlang-questions] Reassigning variables In-Reply-To: References: <214D70B1-B485-4072-8D2F-1B7C87ABC24D@cs.otago.ac.nz> Message-ID: On March 17, 2009, Richard O'Keefe wrote: > So use a macro: > -define(let(Lhs,Exp,Body), > (fun (Lhs) -> Body end)(Exp)). > > X = foo(), > ?let(X, bar(X), ( > ?let(X, ugh(X), ( > ack(X))) Isn't "let" a reserved word? Anyone know what "let" is used for? Darn annoying, if you ask me, since I always have to write this macro in all-caps to get around that limitation.... Cheers, DBM From raimo+erlang-questions@REDACTED Wed Mar 18 16:13:36 2009 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Wed, 18 Mar 2009 16:13:36 +0100 Subject: [erlang-questions] JInterface In-Reply-To: References: Message-ID: <20090318151336.GC12258@erix.ericsson.se> On Wed, Mar 18, 2009 at 10:25:14AM +0000, Robert Lally wrote: > Hi folks, > I've just run the JInterface 1.4.2 code through the IDEA code analyser and > it reports quite a few issues. Some of these are trivial - javadoc that > doesn't match the function. Some are a little more significant - variables > that are never read, parameters that are never used, named labels that no > code ever jumps to, private constructors that are never called, declared > exceptions that are never thrown. There are also a few that look quite > significant - overriding finalize without calling super.finalize(). > > Is there a specific place to talk about JInterface issues? Or is this list > the appropriate forum? There is no specific place other than this. Many of your findings are probable bugs, though, so they should go to the erlang-bugs@REDACTED mailing list. > > > -- > Blog : http://robertlally.com > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From raimo+erlang-questions@REDACTED Wed Mar 18 16:15:45 2009 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Wed, 18 Mar 2009 16:15:45 +0100 Subject: [erlang-questions] : JInterface In-Reply-To: <84E4C36B-AC00-483E-BCCF-0840B835CE5D@kallisys.net> References: <84E4C36B-AC00-483E-BCCF-0840B835CE5D@kallisys.net> Message-ID: <20090318151545.GD12258@erix.ericsson.se> On Wed, Mar 18, 2009 at 12:16:14PM +0100, Paul Guyot wrote: > > Date: Wed, 18 Mar 2009 10:25:14 +0000 > > From: Robert Lally > > Subject: [erlang-questions] JInterface > > To: erlang-questions@REDACTED > > Message-ID: > > > > Content-Type: text/plain; charset="iso-8859-1" > > > > Hi folks, > > I've just run the JInterface 1.4.2 code through the IDEA code > > analyser and > > it reports quite a few issues. Some of these are trivial - javadoc > > that > > doesn't match the function. Some are a little more significant - > > variables > > that are never read, parameters that are never used, named labels > > that no > > code ever jumps to, private constructors that are never called, > > declared > > exceptions that are never thrown. There are also a few that look quite > > significant - overriding finalize without calling super.finalize(). > > > > Is there a specific place to talk about JInterface issues? Or is > > this list > > the appropriate forum? > > I'd also like to know. Several months ago, I reported to erlang-bugs@ > a bad flaw of JInterface 1.4.2 (OtpErlangRef.equals() is overridden, > but not hashCode(), making refs useless in most Java collections), and > while a fix is trivial, the problem is still present in JInterface 1.5. Yes, I marked it as interesting in my mail reader, but never got round to creating a problem Ticket... Now I have. > > Fortunately, Erlang/OTP is open source. This makes bug fixing and > patching very easy. As a result, we apply many (20+) patches on > production servers. We submitted patches for bugs we fixed, so other > users won't have to go through the burden of identifying the bugs, > making sure they are in Erlang/OTP and fixing them. I'd like to insist > that bugs in what might be considered as obscure parts of OTP > definitely affect several users, for example one can find several > workarounds in open source projects (e.g. tcerl) for bugs we fixed in > erl_interface. Some of our patches have even been included in MacPorts > and FreeBSD ports distributions. Yet, I wish more patches were > included upstream and related bugs were fixed. Keep posting patches. We will try to keep up. > > Paul > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From matthew@REDACTED Wed Mar 18 18:25:12 2009 From: matthew@REDACTED (Matthew Dempsky) Date: Wed, 18 Mar 2009 10:25:12 -0700 Subject: [erlang-questions] Reassigning variables In-Reply-To: <18880.49864.505762.419689@ornendil.du.uab.ericsson.se> References: <18880.49864.505762.419689@ornendil.du.uab.ericsson.se> Message-ID: On Wed, Mar 18, 2009 at 2:45 AM, Hans Bolinder wrote: > Maybe I'm missing the point, but wouldn't a BASIC way of numbering > variables be useful here? Yeah, but that feels less aesthetically pleasing than allowing selective variable reassignment. From matthew@REDACTED Wed Mar 18 18:33:25 2009 From: matthew@REDACTED (Matthew Dempsky) Date: Wed, 18 Mar 2009 10:33:25 -0700 Subject: [erlang-questions] Reassigning variables In-Reply-To: References: <18880.49864.505762.419689@ornendil.du.uab.ericsson.se> Message-ID: On Wed, Mar 18, 2009 at 5:02 AM, Christian wrote: > Rather than > > X1 = binary_to_list(Bin), > X2 = lists:reverse(X1) > > do > > String = binary_to_list(Bin), > RevString = lists:reverse(String), Here's an actual block of code from the Erlang compiler: lc_tq(Line, E, [{generate,Lg,P,G}|Qs0], Mc, St0) -> {Gs,Qs1} = splitwith(fun is_guard_test/1, Qs0), {Name,St1} = new_fun_name("lc", St0), {Head,St2} = new_var(St1), {Tname,St3} = new_var_name(St2), LA = lineno_anno(Line, St2), LAnno = #a{anno=LA}, Tail = #c_var{anno=LA,name=Tname}, {Arg,St4} = new_var(St3), {Nc,[],St5} = expr({call,Lg,{atom,Lg,Name},[{var,Lg,Tname}]}, St4), {Guardc,St6} = lc_guard_tests(Gs, St5), %These are always flat! {Lc,Lps,St7} = lc_tq(Line, E, Qs1, Nc, St6), {Pc,St8} = list_gen_pattern(P, Line, St7), {Gc,Gps,St9} = safe(G, St8), %Will be a function argument! Fc = function_clause([Arg], LA, {Name,1}), .... What would you suggest renaming the St0 through St9 variables to? ("St" is short for "State".) Would you think it easier to read and maintain this code: lc_tq(Line, E, [{generate,Lg,P,G}|Qs0], Mc, InitialState) -> {Gs,Qs1} = splitwith(fun is_guard_test/1, Qs0), {Name,StateAfterNewFunName} = new_fun_name("lc", InitialState), {Head,StateAfterFirstNewVar} = new_var(StateAfterNewFunName), {Tname,StateAfterNewVarName} = new_var_name(StateAfterFirstNewVar), LA = lineno_anno(Line, StateAfterNewVarName), .... Because I think the current code is much easier to read. There's no value to keeping around old state variables, and it just introduces the possibility of bugs if you add a new line of code somewhere and forget to renumber all of the later lines. But, please, show me how you would write v3_core:lc_tq/5 without numbered state variables without losing any readability. From matthew@REDACTED Wed Mar 18 18:56:15 2009 From: matthew@REDACTED (Matthew Dempsky) Date: Wed, 18 Mar 2009 10:56:15 -0700 Subject: [erlang-questions] Reassigning variables In-Reply-To: <87eiwvjf40.fsf@sterlett.hq.kred> References: <87prgfkiie.fsf@sterlett.hq.kred> <87eiwvjf40.fsf@sterlett.hq.kred> Message-ID: On Wed, Mar 18, 2009 at 3:32 AM, mats cronqvist wrote: > ?Because it's difficult to read, and therefore to maintain. Here's an actual block of code from the Erlang compiler's v3_core source: lc_tq(Line, E, [{generate,Lg,P,G}|Qs0], Mc, St0) -> {Gs,Qs1} = splitwith(fun is_guard_test/1, Qs0), {Name,St1} = new_fun_name("lc", St0), {Head,St2} = new_var(St1), {Tname,St3} = new_var_name(St2), LA = lineno_anno(Line, St2), LAnno = #a{anno=LA}, Tail = #c_var{anno=LA,name=Tname}, {Arg,St4} = new_var(St3), {Nc,[],St5} = expr({call,Lg,{atom,Lg,Name},[{var,Lg,Tname}]}, St4), {Guardc,St6} = lc_guard_tests(Gs, St5), %These are always flat! {Lc,Lps,St7} = lc_tq(Line, E, Qs1, Nc, St6), {Pc,St8} = list_gen_pattern(P, Line, St7), {Gc,Gps,St9} = safe(G, St8), %Will be a function argument! Fc = function_clause([Arg], LA, {Name,1}), .... Here's what it would look like with variable reassignment using the syntax I initially suggested (only replacing St): lc_tq(Line, E, [{generate,Lg,P,G}|Qs0], Mc, St) -> {Gs,Qs1} = splitwith(fun is_guard_test/1, Qs0), {Name,r(St)} = new_fun_name("lc", St), {Head,r(St)} = new_var(St), {Tname,r(St)} = new_var_name(St), LA = lineno_anno(Line, St), LAnno = #a{anno=LA}, Tail = #c_var{anno=LA,name=Tname}, {Arg,r(St)} = new_var(St), {Nc,[],r(St)} = expr({call,Lg,{atom,Lg,Name},[{var,Lg,Tname}]}, St), {Guardc,r(St)} = lc_guard_tests(Gs, St), %These are always flat! {Lc,Lps,r(St)} = lc_tq(Line, E, Qs1, Nc, St), {Pc,r(St)} = list_gen_pattern(P, Line, St), {Gc,Gps,r(St)} = safe(G, St), %Will be a function argument! Fc = function_clause([Arg], LA, {Name,1}), .... I don't think this is any more difficult to read or maintain than the current code. There's no extra information imparted by "St7" than just "St"; the reader doesn't care that it's the result from the seventh state-mutating function call, just that it's the most recent state variable. Also, this code has the benefit that if an extra state-mutating function needs to be introduced, it doesn't necessitate renumbering a dozen variables: it could be disasterous if (e.g.) a later use of St5 isn't updated to St6. Actually, I just noticed that the above two blocks of code aren't identical, because "LA = lineno_anno(Line, St2)" happens after St3 has been defined. I doubt this is intentional and rather just a (in this case harmless) bug along the lines of mis-renumbering like I've been warning about. From ulf.wiger@REDACTED Wed Mar 18 19:37:01 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Wed, 18 Mar 2009 19:37:01 +0100 Subject: [erlang-questions] Reassigning variables In-Reply-To: References: <18880.49864.505762.419689@ornendil.du.uab.ericsson.se> Message-ID: <49C13F4D.9020208@erlang-consulting.com> Matthew Dempsky wrote: > > Here's an actual block of code from the Erlang compiler: > > lc_tq(Line, E, [{generate,Lg,P,G}|Qs0], Mc, St0) -> > {Gs,Qs1} = splitwith(fun is_guard_test/1, Qs0), > {Name,St1} = new_fun_name("lc", St0), > {Head,St2} = new_var(St1), > {Tname,St3} = new_var_name(St2), > LA = lineno_anno(Line, St2), > LAnno = #a{anno=LA}, > Tail = #c_var{anno=LA,name=Tname}, > {Arg,St4} = new_var(St3), > {Nc,[],St5} = expr({call,Lg,{atom,Lg,Name},[{var,Lg,Tname}]}, St4), > {Guardc,St6} = lc_guard_tests(Gs, St5), %These are always flat! > {Lc,Lps,St7} = lc_tq(Line, E, Qs1, Nc, St6), > {Pc,St8} = list_gen_pattern(P, Line, St7), > {Gc,Gps,St9} = safe(G, St8), %Will be a > function argument! > Fc = function_clause([Arg], LA, {Name,1}), > .... [...] > But, please, show me how you would write v3_core:lc_tq/5 without > numbered state variables without losing any readability. So there's a pattern there, and there's actually a library function that might help to eliminate most of the numbered variable names. thread(Fs, St) -> lists:mapfoldl(fun(F,St1) -> F(St) end, St, Fs). lc_tq(Line, E, [{generate,Lg,P,G}|Qs0], Mc, St0) -> {Gs,Qs1} = splitwith(fun is_guard_test/1, Qs0), {[Name, Head, Tname], St1} = thread([fun(St) -> new_fun_name("lc", St) end, fun new_var/1, fun new_var_name/1], St0), ... Whether it's more readable is perhaps a matter of taste. It ought to be easier to maintain though. BR, Ulf W -- Ulf Wiger CTO, Erlang Training & Consulting Ltd http://www.erlang-consulting.com From ryeguy1@REDACTED Wed Mar 18 20:18:38 2009 From: ryeguy1@REDACTED (ryeguy) Date: Wed, 18 Mar 2009 12:18:38 -0700 (PDT) Subject: [erlang-questions] How should I distribute load amongst a cluster? Message-ID: I was looking at the slave/pool modules and it seems similar to what I want, but it also seems like I have a single point of failure in my application (if the master node goes down). The client has a list of gateways (for the sake of fallback - all do the same thing) which accept connections, and one is chosen from randomly by the client. When the client connects all nodes are examined to see which has the least load and then the IP of the least- loaded server is forwarded back to the client. The client then connects to this server and everything is executed there. In summary, I want all nodes to act as both gateways and to actually process client requests. The load balancing is only done when the client initially connects - all of the actual packets and processed on the client's "home" node. How would I do this? From olivier.boudeville@REDACTED Wed Mar 18 20:35:35 2009 From: olivier.boudeville@REDACTED (Olivier Boudeville) Date: Wed, 18 Mar 2009 20:35:35 +0100 Subject: [erlang-questions] Update on sharing constant data locally by reference rather than by copy? Message-ID: <49C14D07.9000808@online.fr> Hi, would it be possible to have an update regarding how an immutable data structure (which is not a binary) could be shared between several processes on the same Erlang node, without having one copy of that data structure per process? I know that the Erlang semantics allows processes to access that constant data as if there was only one copy of it, but, as I understand, in practice, currently, they do not access to that data through a const pointer but still rely on a private copy of it instead (http://www.erlang.org/pipermail/erlang-questions/2006-September/022739.html) Is it planned to implement a more efficient sharing which would not involve a copy? More precisely, I would need that a large number of processes created on a node are able to access very frequently to the same set of associative tables, as efficiently as possible. Having specific process(es) owning the shared tables and answering to look-up requests is not an option, due to the message overhead. I know ETS could be a solution, but I would like to compare it with the performances that could be obtained in pure Erlang, supposing that, for small tables (up to, say, ~30 entries), a smart pure Erlang hashtable implementation might outperform ETS? (CPU and/or memory-wise) Thanks in advance for any piece of advice, Olivier. From matt.handler@REDACTED Wed Mar 18 22:32:46 2009 From: matt.handler@REDACTED (Matt Handler) Date: Wed, 18 Mar 2009 17:32:46 -0400 Subject: [erlang-questions] process and closure memory usage Message-ID: <49427c610903181432w537259dcn43d8eb3921cfe7e4@mail.gmail.com> I'm trying to cut down on the process memory usage for a non-relational database i'm working on. essentially there are 10,000 processes (setup as gen_servers) that send information to each other in various ways. i have several questions: 1. how much of an overhead does using the gen_server model assert? if i'm not as worried about dynamic code loading, supervising, etc... am i wasting memory and processing using the gen_server? 2. how/where can i find out more information about the memory usage of a process? i've used process_info/2 heavily to gather some of this information, but my problem is that if i look at the rough size of the state of a process (using erlang:iolist_size/1), it's significantly less than the size of the process as reported by process_info/2. i want to know where the rest of the memory is being eaten up (initially the processes are only 1k), on average, the process size is about 4x the state size. 3. i am passing around many closures between the nodes of the database, and they are getting to be quite large (start out as 100bytes, end up as 40kbytes). these are what is taking up most of the memory of the state, and so i'm wondering if there is some inner workings of the erlang system that make this a bad way of programming in terms of memory usage. it seems like there are certain situations that make closures take up a lot of memory, but i'm having trouble pinpointing when. 4. is there a good tool out there for profiling the memory usage rather than executiontime usage? thanks for the help, -matt handler -------------- next part -------------- An HTML attachment was scrubbed... URL: From bergstro@REDACTED Tue Mar 17 19:36:03 2009 From: bergstro@REDACTED (Pete Bergstrom) Date: Tue, 17 Mar 2009 13:36:03 -0500 Subject: [erlang-questions] Reassigning variables Message-ID: <196NcqsjD6128S08.1237314963@cmsweb08.cms.usa.net> http://www.erlang.org/faq/faq.html "FAQ 5.6 ...destructively update data, like in C Not being able to do this is considered a feature of Erlang. The Erlang book explains this in chapter 1. Having said that, there are common methods to achieve effects similar to destructive update: store the data in a process (use messages to manipulate it), store the data in ETS or use a data structure designed for relatively cheap updates (the dict library module is one common solution). " ------ Original Message ------ Received: Tue, 17 Mar 2009 01:13:56 PM CDT From: Matthew Dempsky To: Erlang Questions Subject: [erlang-questions] Reassigning variables I like pattern matching in the majority of cases, but I find I write enough code where I need to incrementally update a data structure, and maintaining that code is a pain when I have code like: X = foo(), X1 = bar(X), X2 = xyzzy(X1), blah(X2). and later want to change it to: X = foo(), X1 = whee(X), X2 = bar(X1), X3 = xyzzy(X2), blah(X3). This means having to change four lines of code, when really it's conceptually just one change. I'd like to suggest being able to do something like: X = foo(), r(X) = whee(X), r(X) = bar(X), r(X) = xyzzy(X), blah(X). where "r(?VAR) = ?EXPR" means to reassign ?VAR to ?EXPR, even if it previously has an assigned value. Thoughts? Does anyone have suggestions for better syntax? I think this can be handled with a parse transform, and I'm considering writing a parse transform to handle it. (I haven't checked if anyone else has proposed similar functionality in the past, but this is something that's been bugging me for a while, and I've finally had to rename variables manually enough times to propose this.) _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions From matthew@REDACTED Wed Mar 18 23:18:59 2009 From: matthew@REDACTED (Matthew Dempsky) Date: Wed, 18 Mar 2009 15:18:59 -0700 Subject: [erlang-questions] Reassigning variables In-Reply-To: <196NcqsjD6128S08.1237314963@cmsweb08.cms.usa.net> References: <196NcqsjD6128S08.1237314963@cmsweb08.cms.usa.net> Message-ID: On Tue, Mar 17, 2009 at 11:36 AM, Pete Bergstrom wrote: > "FAQ 5.6 ...destructively update data, like in C I'm not trying to destructively update data. This FAQ entry doesn't apply. From matthew@REDACTED Wed Mar 18 23:44:09 2009 From: matthew@REDACTED (Matthew Dempsky) Date: Wed, 18 Mar 2009 15:44:09 -0700 Subject: [erlang-questions] Reassigning variables In-Reply-To: <49C13F4D.9020208@erlang-consulting.com> References: <18880.49864.505762.419689@ornendil.du.uab.ericsson.se> <49C13F4D.9020208@erlang-consulting.com> Message-ID: On Wed, Mar 18, 2009 at 11:37 AM, Ulf Wiger wrote: > Whether it's more readable is perhaps a matter of > taste. It ought to be easier to maintain though. That only eliminates three of the St updates. The snippet of code I posted has nine St updates. Not all of them output data in the same format (i.e., a tuple with the result and a new state) and some of them take previous outputs as their own arguments, but even ignoring that, if you were to put all nine updates in your format, that requires maintaining a list of 9 variable outputs and making sure that they're in the same order as the 9 state-mutating function calls. I don't think that's easier to maintain than being able to selectively rebind a single St variable. From ulf.wiger@REDACTED Thu Mar 19 01:21:39 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Thu, 19 Mar 2009 01:21:39 +0100 Subject: [erlang-questions] Reassigning variables In-Reply-To: References: <18880.49864.505762.419689@ornendil.du.uab.ericsson.se> <49C13F4D.9020208@erlang-consulting.com> Message-ID: <49C19013.7060807@erlang-consulting.com> Matthew Dempsky wrote: > On Wed, Mar 18, 2009 at 11:37 AM, Ulf Wiger > wrote: >> Whether it's more readable is perhaps a matter of >> taste. It ought to be easier to maintain though. > > That only eliminates three of the St updates. ...because I stopped there. It would have been possible to reduce more with some minor rewrites, but I thought that I had made the point already. It reduces the amount of numbered variables. It doesn't eliminate them entirely, and I didn't claim that it was more readable in this particular case. In fact, I'd say it's slightly less readable, but I've been bitten by numbered variables enough times that I'm now willing to sacrifice some time and convenience in order to avoid them. They can be the cause of some very subtle bugs. In this particular case, though, the code is pretty symmetric to begin with, so even doing some slight re-formatting... lc_tq(Line, E, [{generate,Lg,P,G}|Qs0], Mc, St0) -> {Gs,Qs1} = splitwith(fun is_guard_test/1, Qs0), {Name ,St1} = new_fun_name("lc", St0), {Head ,St2} = new_var(St1), {Tname,St3} = new_var_name(St2), LA = lineno_anno(Line, St2), LAnno = #a{anno=LA}, Tail = #c_var{anno=LA,name=Tname}, {Arg ,St4} = new_var(St3), {Nc,[] ,St5} = expr({call,Lg,...}, St4), {Guardc,St6} = lc_guard_tests(Gs, St5), {Lc,Lps,St7} = lc_tq(Line, E, Qs1, Nc, St6), {Pc ,St8} = list_gen_pattern(P, Line, St7), {Gc,Gps,St9} = safe(G, St8), ... ...will improve readability and make it easier to make sure that at least the numbered variables in the LHS aren't messed up. But the uses of numbered state variables in the actual calls are harder to spot, and often, this is where the bugs are - we use an older instance of the state in a call and overlook some recent change. > The snippet of code I posted has nine St updates. > Not all of them output data in the same format > (i.e., a tuple with the result and a new state) Actually, they pretty much did. Some functions returned {A, B, St} instead of {A, St}, but this is obviously easy to fix, either by modifying the called function so that it returns {{A,B},St}. I don't think it's uncommon to have to re-think return values etc when you make a change like this. > and some of them take previous outputs as their own > arguments, Sure, so you'd need to do it in multiple stages. > but even ignoring that, if you were to put all > nine updates in your format, that requires > maintaining a list of 9 variable outputs and > making sure that they're in the same order as > the 9 state-mutating function calls. Right, it's not a panacea. Sometimes it makes for more readable code, but if you go overboard with it, it won't. ;-) > I don't think that's easier to maintain than > being able to selectively rebind a single > St variable. In my opinion, numbered variables are sometimes an acceptable cop-out because alternatives are less practical (or at least defy your imagination.) But I think that folding over funs is an under- appreciated technique. Possibly because there isn't (directly) a library function for it, but also surely because the fun(...) -> ... end syntax is a bit bulky. BR, Ulf W -- Ulf Wiger CTO, Erlang Training & Consulting Ltd http://www.erlang-consulting.com From rvirding@REDACTED Thu Mar 19 01:51:18 2009 From: rvirding@REDACTED (Robert Virding) Date: Thu, 19 Mar 2009 01:51:18 +0100 Subject: [erlang-questions] Reassigning variables In-Reply-To: References: <18880.49864.505762.419689@ornendil.du.uab.ericsson.se> Message-ID: <3dbc6d1c0903181751l1a67c3dcj90883d07e6f92860@mail.gmail.com> 2009/3/18 Matthew Dempsky > > Here's an actual block of code from the Erlang compiler: > > lc_tq(Line, E, [{generate,Lg,P,G}|Qs0], Mc, St0) -> > {Gs,Qs1} = splitwith(fun is_guard_test/1, Qs0), > {Name,St1} = new_fun_name("lc", St0), > {Head,St2} = new_var(St1), > {Tname,St3} = new_var_name(St2), > LA = lineno_anno(Line, St2), > LAnno = #a{anno=LA}, > Tail = #c_var{anno=LA,name=Tname}, > {Arg,St4} = new_var(St3), > {Nc,[],St5} = expr({call,Lg,{atom,Lg,Name},[{var,Lg,Tname}]}, St4), > {Guardc,St6} = lc_guard_tests(Gs, St5), %These are always flat! > {Lc,Lps,St7} = lc_tq(Line, E, Qs1, Nc, St6), > {Pc,St8} = list_gen_pattern(P, Line, St7), > {Gc,Gps,St9} = safe(G, St8), %Will be a > function argument! > Fc = function_clause([Arg], LA, {Name,1}), > .... As the one who wrote the original version of that code (it transforms list comprehensions to nested recursive functions) I must say I don't really see the problem. To me it seems more like a theoretical problem, when coding I just do it. That is not where the problems lay when coding, not for me at least. Then maybe I am totally milj?f?rst?rd, ruined by my programming environment. Robert P.S. Of course if you were to use LFE then the problem would go away for free as you have let*. :-) -------------- next part -------------- An HTML attachment was scrubbed... URL: From ok@REDACTED Thu Mar 19 02:06:42 2009 From: ok@REDACTED (Richard O'Keefe) Date: Thu, 19 Mar 2009 14:06:42 +1300 Subject: [erlang-questions] Reassigning variables In-Reply-To: <20AB5CF7-C396-42AB-AAD1-676FD2C8BC4C@cs.otago.ac.nz> References: <879778450903171338j5f47e27fm6b6016906dff0159@mail.gmail.com> <20AB5CF7-C396-42AB-AAD1-676FD2C8BC4C@cs.otago.ac.nz> Message-ID: Just on the subject of multiple returns, and using a name swiped from a possibly defective memory of VLisp, escape(Body) -> Unique = make_ref(), try Body(fun (Result) -> throw({escape,Unique,Result}) end) catch throw:{escape,Unique,Result} -> Result end. Use this as escape(fun (Return) -> ... Return(this) ... Return(that) ... or_just_return_as_usual end) As I remarked before, I don't like using exceptions _as_ control structures, but using them in a hidden way to _implement_ sensible control structures is another thing. I'm old enough to think of the value that Return is bound to as a "J-function", rather like the 'jumpout' functions in Pop-2. These days it may be more useful to describe it as (mimicking) a single-use continuation. From billrobertson42+erlang@REDACTED Thu Mar 19 02:19:45 2009 From: billrobertson42+erlang@REDACTED (bill robertson) Date: Wed, 18 Mar 2009 21:19:45 -0400 Subject: [erlang-questions] Please help me relate a past project to Erlang, I'm trying to understand... In-Reply-To: References: <61169.51377.qm@web111416.mail.gq1.yahoo.com> <449653.76030.qm@web111405.mail.gq1.yahoo.com> <721392.80151.qm@web111410.mail.gq1.yahoo.com> Message-ID: So that is the deal. I guess that makes sense, because when you're waiting on a receive to return, you still have a stack frame don't you? I think I finally get it. Thanks all! 2009/3/18 Robert Lally : > As I've been learning Erlang, this has been the hardest thing to get to > grips with. The fact that I often don't need to explicitly store my state > anywhere, it will hang out in a receive block waiting for me to get back to > it seems counter-intuitive. I crave a neat, labelled pigeon hole to store my > state in .. but I don't need it. > > Rob Lally. > > > 2009/3/18 Thomas Lindgren >> >> ----- Original Message ---- >> > From: bill robertson >> > To: erlang-questions@REDACTED >> > Sent: Wednesday, March 18, 2009 3:59:07 AM >> > Subject: Re: [erlang-questions] Please help me relate a past project to >> > Erlang, I'm trying to understand... >> > >> > Thats good. ?Now, to make it *stateful* (and this is the heart of the >> > question). ?Suppose you have the requirement to allow a web user to >> > view the call as it is in progress and show them who is connected >> > (telephone number), and how long they have been connected, and also >> > who is disconnected and how long they were connected. >> > >> > To do this, you need to track three items for each participant. ?The >> > telephone number. ?The start time, and a stop time. >> > >> > So network request comes in, we have to enumerate those pieces of >> > information for it and send them back to the client. >> > >> > How would you implement this in a typical Erlang system? >> >> >> The simplest approach is to use plain erlang and message passing. >> Something like: >> >> start_conference_call(Name) -> >> ? spawn_link( >> ? ? fun() -> >> ? ? ? register(Name, self()), >> ? ? ? Empty_state = [], >> ? ? ? conf_call_loop(Empty_state) >> ? ?end). >> >> conf_call_loop(Callers) -> >> ? receive >> ? ? ?{join, Caller} -> >> ? ? ? ? Time = erlang:now(), >> ? ? ? ? conf_call_loop([{Caller, Time}|Callers]); ? %% add a new caller >> ? ? ?{leave, Caller} -> >> ? ? ? ? conf_call_loop(delete_caller(Caller, Callers)); ?%% delete a >> caller >> ? ? {message, From, Msg} -> ? ? %% send message to all participants >> ? ? ? ? send_to_all(Callers, Msg), >> ? ? ? ? conf_call_loop(Callers); >> ? ? {status, Asker} -> ? %% send status to asking process >> ? ? ? ? Asker ! {status, Callers}, >> ? ? ? ? conf_call_loop(Callers); >> ? ? stop -> >> ? ? ? ? ok >> ? end. >> >> %% Client API >> status(ConfCall) -> >> ? ConfCall ! {status, self()}, >> ? receive >> ? ? ?{status, Callers} -> {status, Callers} >> ? end. >> >> ... (code for some left-out functions) ... >> >> So, the conference call process keeps its state as a list passed arounf in >> conf_call_loop/1. Callers can join and leave and send messages to each >> other, all by sending messages to this process. You can also ask for status >> (which here just returns the list of callers and their join time) and stop >> the process. So, the conference call process itself is just a tail recursive >> function conf_call_loop/1 that processes messages forever (or until >> stopped). The state = list of callers lives as long as the conference call >> process. >> >> (Each caller would then itself be an erlang process, passing messages >> to/from the telephony driver and conference call process and any others >> involved.) >> >> Now, this is of course just a sketch, since the code is sloppy and you'd >> want to handle more cases in practice, _but_ it demonstrates the very >> simplest way to keep state. >> >> Best, >> Thomas >> >> >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions > > > > -- > Blog : http://robertlally.com > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From public-mail@REDACTED Thu Mar 19 02:37:36 2009 From: public-mail@REDACTED (alekciy) Date: Thu, 19 Mar 2009 04:37:36 +0300 Subject: [erlang-questions] =?utf-8?q?How_change_port_in_http_module=3F?= Message-ID: <312d1a031281544f958bea6cefc80dd9@mail.vline.ru> I use http module: Eshell V5.6.5 (abort with ^G) 1> inets:start(). ok 2> http:request(get, {"http://samehost.ru", []}, [], []). but web server samehost.ru bind to 8080 port, not 80. How I can send request to another port? From erlangy@REDACTED Thu Mar 19 03:07:55 2009 From: erlangy@REDACTED (Michael McDaniel) Date: Wed, 18 Mar 2009 19:07:55 -0700 Subject: [erlang-questions] How change port in http module? In-Reply-To: <312d1a031281544f958bea6cefc80dd9@mail.vline.ru> References: <312d1a031281544f958bea6cefc80dd9@mail.vline.ru> Message-ID: <20090319020755.GV18122@delora.autosys.us> On Thu, Mar 19, 2009 at 04:37:36AM +0300, alekciy wrote: > I use http module: > Eshell V5.6.5 (abort with ^G) > 1> inets:start(). > ok > 2> http:request(get, {"http://samehost.ru", []}, [], []). ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2> http:request(get, {"http://samehost.ru:8080", []}, [], []). ~M > > but web server samehost.ru bind to 8080 port, not 80. How I can send > request to another port? > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- Michael McDaniel Portland, Oregon, USA http://trip.autosys.us http://mmcdaniel.com/erlview From public-mail@REDACTED Thu Mar 19 03:34:53 2009 From: public-mail@REDACTED (alekciy) Date: Thu, 19 Mar 2009 05:34:53 +0300 Subject: [erlang-questions] =?utf-8?q?How_change_port_in_http_module=3F?= In-Reply-To: <20090319020755.GV18122@delora.autosys.us> References: <312d1a031281544f958bea6cefc80dd9@mail.vline.ru> <20090319020755.GV18122@delora.autosys.us> Message-ID: <8736e359000e82e14651f89e1d85bef2@mail.vline.ru> On Wed, 18 Mar 2009 19:07:55 -0700, Michael McDaniel wrote: > On Thu, Mar 19, 2009 at 04:37:36AM +0300, alekciy wrote: >> I use http module: >> Eshell V5.6.5 (abort with ^G) >> 1> inets:start(). >> ok >> 2> http:request(get, {"http://samehost.ru", []}, [], []). > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > > 2> http:request(get, {"http://samehost.ru:8080", []}, [], []). Thank, it's work. From ok@REDACTED Thu Mar 19 04:57:09 2009 From: ok@REDACTED (Richard O'Keefe) Date: Thu, 19 Mar 2009 16:57:09 +1300 Subject: [erlang-questions] Reassigning variables In-Reply-To: References: <879778450903171338j5f47e27fm6b6016906dff0159@mail.gmail.com> <20AB5CF7-C396-42AB-AAD1-676FD2C8BC4C@cs.otago.ac.nz> <6DA014AD-3091-4938-B159-496CF1D1A8BE@cs.otago.ac.nz> Message-ID: <5BCB710A-EA81-41E2-97FF-F32B9D788F35@cs.otago.ac.nz> On 18 Mar 2009, at 6:35 pm, Matthew Dempsky wrote: > > I'd prefer not to post the actual code that motivated this discussion, Sigh. I'm _sure_ this would be more use. > > but I will point out some code in OTP that uses numbered variables: > the Erlang compiler. It uses them quite significantly, with some > functions > > matthew@REDACTED:~/src/otp_src_R12B-5/lib/compiler/src$ for x in `jot 11 > 0`; do echo -n "St$x: "; cat *.erl | grep -c > "[^a-zA-Z0-9_]St$x[^0-9]"; done > St0: 811 > St1: 612 > St2: 300 > St3: 120 > St4: 47 > St5: 29 > St6: 14 > St7: 10 > St8: 6 > St9: 2 > St10: 2 > Great! Numbers! I love numbers! The thing that strikes me here is that although numbered variables are common, variables with *high* numbers are rare. Once you get past St0, it's very nearly an exponential decay. > I'm interested to know how you'd suggest rewriting v3_core:lc_tq/5 > using metaprogramming. I never said anything about the Erlang compiler. I said that *YOUR* problem sounded like a case for metaprogramming. There's a big difference. Let's look at that function and see what we find. lc_tq(Line, E, [{generate,Lg,P,G}|Qs0], Mc, St0) -> {Gs,Qs1} = splitwith(fun is_guard_test/1, Qs0), {Name,St1} = new_fun_name("lc", St0), {Head,St2} = new_var(St1), {Tname,St3} = new_var_name(St2), LA = lineno_anno(Line, St2), LAnno = #a{anno=LA}, Tail = #c_var{anno=LA,name=Tname}, {Arg,St4} = new_var(St3), {Nc,[],St5} = expr({call,Lg,{atom,Lg,Name},[{var,Lg,Tname}]}, St4), {Guardc,St6} = lc_guard_tests(Gs, St5), {Lc,Lps,St7} = lc_tq(Line, E, Qs1, Nc, St6), {Pc,St8} = list_gen_pattern(P, Line, St7), {Gc,Gps,St9} = safe(G, St8), Fc = function_clause([Arg], LA, {Name,1}), case {Guardc, Pc} of {[], #c_var{}} -> Cs0 = [#iclause{anno=LAnno, pats=[#c_literal{anno=LA,val=[]}],guard=[], body=[Mc]}]; _ -> Cs0 = [#iclause{anno=#a{anno=[compiler_generated|LA]}, pats=[#c_cons{anno=LA,hd=Head,tl=Tail}], guard=[], body=[Nc]}, #iclause{anno=LAnno, pats=[#c_literal{anno=LA,val=[]}],guard=[], body=[Mc]}] end, Cs = case Pc of nomatch -> Cs0; _ -> [#iclause{anno=LAnno, pats=[#c_cons{anno=LA,hd=Pc,tl=Tail}], guard=Guardc, body=Lps ++ [Lc]}|Cs0] end, Fun = #ifun{anno=LAnno,id=[],vars=[Arg],clauses=Cs,fc=Fc}, {#iletrec{anno=LAnno,defs=[{{Name,1},Fun}], body=Gps ++ [#iapply{anno=LAnno, op=#c_fname{anno=LA,id=Name,arity=1}, args=[Gc]}]}, [],St9}; I'll look at just the first clause, that's more than enough. The first thing I notice is that this is the kind of code that makes me wonder whether I really like Erlang after all. It took a bit of head-scratching to figure out that the name means something like "List Comprehension Translate Qualifier". Now let's look at the first few state updates. {Name, St1} = new_fun_name("lc", St0), {Head, St2} = new_var(St1), {Tname,St3} = new_var_name(St2), {Arg, St4} = new_var(St3), -record(core, { vcount = 0, %Variable counter fcount = 0, %Function counter in_guard = false, %In guard or not. opts, %Options. es = [], %Errors. ws = [], %Warnings. file = [{file,""}] %File }). new_fun_name(Type, #core{fcount=C}=St) -> {list_to_atom(Type ++ "$^" ++ integer_to_list(C)),St#core{fcount=C +1}}. new_var_name(#core{vcount=C}=St) -> {list_to_atom("cor" ++ integer_to_list(C)),St#core{vcount=C + 1}}. new_var(St0) -> % simplified {New,St} = new_var_name(St0), {#c_var{anno=[],name=New},St}. I'm immediately struck by the fact that these three updates could be done in any order. We could imagine a "combo method" st_new(Ops, St) -> st_new(Ops, [], St). st_new([], R, St) -> {reverse(R),St}; st_new([{fun_name,Type}|Ops], R, St0 = #core{fcount=C}) -> F = list_to_atom(Type ++ "$^" ++ integer_to_list(C)), St1 = St0#core{fcount = C+1}, st_new(Ops, [F|R], St1); st_new([var|Ops], R, St0 = #core{vcount = C}) -> V = list_to_atom("core" ++ integer_to_list(C), I = #c_var{anno = [], name = V}, St1 = St0#core{vcount = C+1}, st_new(Ops, [I|R], St1); st_new([var_name|Ops], St0) -> V = list_to_atom("core" ++ integer_to_list(C), St1 = St0#core{vcount = C+1}, st_new(Ops, [V|R], St1); ... instead of all the little methods, and then ... {[Name,Head,TName,Arg],St4} = st_new([{fun_name,"lc"},var,var_name,var], St), Not a big step, but - it makes clear which sequences of "operations" don't really need to be done in any particular sequence - it does save 3 of the state variables. But that misses the point too. What I'm really itching to do is to rewrite in Haskell using a State monad: -changer(core, [lc_tq/4, new_fun_name/0, new_var/0, new_var_name/0, expr/2, lc_guard_tets/1, list_gen_pattern/2, safe/1 -reader( core, [lineno_anno/1]). lc_tq(Line, E, [{generate,Lg,P,G}|Qs0], Mc) -> {Gs,Qs1} = splitwith(fun is_guard_test/1, Qs0), Name = new_fun_name("lc"), Head = new_var(), Tname = new_var_name(), LA = lineno_anno(Line), LAnno = #a{anno=LA}, Tail = #c_var{anno=LA,name=Tname}, Arg = new_var(), {Nc,[]} = expr({call,Lg,{atom,Lg,Name},[{var,Lg,Tname}]}), Guardc = lc_guard_tests(Gs), {Lc,Lps} = lc_tq(Line, E, Qs1, Nc), {c = list_gen_pattern(P, Line), {Gc,Gps} = safe(G), Fc = function_clause([Arg], LA, {Name,1}), Cs0 = if Guardc == [], is_record(Pc, c_var) -> [#iclause{anno = LAnno, pats = [#c_literal{anno=LA,val=[]}], guard= [], body = [Mc]}] ; true -> [#iclause{anno = #a{anno=[compiler_generated|LA]}, pats = [#c_cons{anno=LA,hd=Head,tl=Tail}], guard= [], body = [Nc]}, #iclause{anno = LAnno, pats = [#c_literal{anno=LA,val=[]}], guard= [], body = [Mc]}] end, Cs = if Pc == nomatch -> Cs0 ; true -> [#iclause{anno = LAnno, pats = [#c_cons{anno=LA,hd=Pc,tl=Tail}], guard= Guardc, body = Lps ++ [Lc]}|Cs0] end, Fun = #ifun{anno=LAnno,id=[],vars=[Arg],clauses=Cs,fc=Fc}, {#iletrec{anno=LAnno,defs=[{{Name,1},Fun}], body=Gps ++ [#iapply{anno=LAnno, op=#c_fname{anno=LA,id=Name,arity=1}, args=[Gc]}]}, []}; where a declaration like -changer(Type, [...F/N...]). means that a call P = F(E1,...,EN) really stands for {P,S1} = F(E1,...,EN,S0) and a declaration like -reader(Type, [...F/N...]). means that a call P = F(E1,...,EN) really stands for P = F(E1,...,EN,S0) with the Si being threaded through automatically. This is just like, indeed in all important essentials, it _is_ the DCG rule to ordinary clause translation of Prolog. Just as metaprogramming turns p(X, Y) --> q(X), r(Y). into p(X, Y, S0, S) :- q(X, S0, S1), r(Y, S1, S) in Prolog, so it could turn f(X) -> Y = g(X), h(X, Y) into f(X, S0) -> {Y,S1} = g(X, S0), h(X, Y, S1) in Erlang. It's not _trivial_ (as I know to my cost), but it's not rocket science either. So, much to my surprise, the answer seems to be yes, metaprogramming _would_ help this a lot. From ok@REDACTED Thu Mar 19 05:19:33 2009 From: ok@REDACTED (Richard O'Keefe) Date: Thu, 19 Mar 2009 17:19:33 +1300 Subject: [erlang-questions] Reassigning variables In-Reply-To: <401d3ba30903180348r287019d0l75ea8bb383ff6e@mail.gmail.com> References: <879778450903171338j5f47e27fm6b6016906dff0159@mail.gmail.com> <20090317214258.GQ32606@h216-235-12-174.host.egate.net> <401d3ba30903180348r287019d0l75ea8bb383ff6e@mail.gmail.com> Message-ID: On 18 Mar 2009, at 11:48 pm, Attila Rajmund Nohl wrote: >> } if requested ad size is bad: >> } return {skip, bad_size} >> } if the game has ads disabled: >> } return {skip, disabled} >> } if the game is filtering a domain: >> } return {skip, domain_filtered} >> } return choose_ad() > 7 lines (easily fit into one screen) vs 25 lines (probably not much > other than this code is shown on the screen) full of no-ops like "_ -> > ok" - a really bad idea in my opinion. Here it is using the escape/1 function I posted earlier today. -define(when(Clause), if Clause ; true -> ok end). escape(fun (Return) -> ?when(requested_ad_size_is_bad() -> Return({skip,bad_size})), ?when(the_game_has_ads_disabled() -> Return({skip,disabled})), ?when(it_is_filtering_a_domain() -> Return({skip,domain_filtered})), choose_ad() end) Not that I endorse this, but + exceptions + higher order functions + macros is an amazing combination. From ok@REDACTED Thu Mar 19 05:33:27 2009 From: ok@REDACTED (Richard O'Keefe) Date: Thu, 19 Mar 2009 17:33:27 +1300 Subject: [erlang-questions] Reassigning variables In-Reply-To: References: <214D70B1-B485-4072-8D2F-1B7C87ABC24D@cs.otago.ac.nz> Message-ID: > > Isn't "let" a reserved word? Anyone know what "let" is used for? > Darn > annoying, if you ask me, since I always have to write this macro in > all-caps to get around that limitation.... Drat! I checked the parser to see if 'let' was a reserved word, but not the lexical analyser. As it happens, parse1.yrl doesn't mention 'let' anywhere. It's even worse than 'cond', because at least parse1.yrl mentions that and hints at what it might once have been going to become some day. OK, ?Let it is then. From ok@REDACTED Thu Mar 19 05:38:45 2009 From: ok@REDACTED (Richard O'Keefe) Date: Thu, 19 Mar 2009 17:38:45 +1300 Subject: [erlang-questions] Reassigning variables In-Reply-To: References: <18880.49864.505762.419689@ornendil.du.uab.ericsson.se> <49C13F4D.9020208@erlang-consulting.com> Message-ID: There is one thing that is better than reassigning a variable, and that is hiding the variable *completely* from sight. This is what DCGs do for Prolog and Mercury and what State monads do for Haskell. As Dempsky points out, the compiler uses "St" a *lot*. The best thing to do would be to hide *all* of those variables so that you wouldn't even have to name "it" let alone "them". From adam@REDACTED Thu Mar 19 08:55:28 2009 From: adam@REDACTED (Adam Lindberg) Date: Thu, 19 Mar 2009 07:55:28 +0000 (GMT) Subject: [erlang-questions] Compiler and tautologies Message-ID: <27701352.84731237449328119.JavaMail.root@zimbra> Hi! Does the Erlang compiler optimize code such as: f() -> case true of true -> ok end. To this? f() -> ok. I'm working with Erlang code generation in a customer's product and I wonder if I need to optimize away such code myself or not. Cheers, Adam From michal.ptaszek@REDACTED Thu Mar 19 09:09:22 2009 From: michal.ptaszek@REDACTED (Michal Ptaszek) Date: Thu, 19 Mar 2009 08:09:22 +0000 (GMT) Subject: [erlang-questions] Compiler and tautologies In-Reply-To: <27701352.84731237449328119.JavaMail.root@zimbra> Message-ID: <18429128.84781237450162418.JavaMail.root@zimbra> Hi! I suppose it does so. Let's check it out: f() -> case test of test -> ok end. f2() -> ok. Then try to compile it to the assembler code: compile:file("test", ['S']). {ok,test} And check out the test.S file: {function, f, 0, 2}. {label,1}. {func_info,{atom,test},{atom,f},0}. {label,2}. {move,{atom,ok},{x,0}}. return. {function, f2, 0, 4}. {label,3}. {func_info,{atom,test},{atom,f2},0}. {label,4}. {move,{atom,ok},{x,0}}. return. The functions' bodies are exactly the same. ----- "Adam Lindberg" wrote: > Hi! > > Does the Erlang compiler optimize code such as: > > f() -> case true of true -> ok end. > > To this? > > f() -> ok. > > > I'm working with Erlang code generation in a customer's product and I > wonder if I need to optimize away such code myself or not. > > > Cheers, > Adam Regards, -- Michal Ptaszek www.erlang-consulting.com From erik.stenman@REDACTED Thu Mar 19 09:22:26 2009 From: erik.stenman@REDACTED (Erik Stenman) Date: Thu, 19 Mar 2009 09:22:26 +0100 Subject: [erlang-questions] Compiler and tautologies In-Reply-To: <27701352.84731237449328119.JavaMail.root@zimbra> References: <27701352.84731237449328119.JavaMail.root@zimbra> Message-ID: <2B21A242-F3FE-43AC-B041-B1E6ACCC45CF@kreditor.se> On 19 mar 2009, at 08.55, Adam Lindberg wrote: > Hi! > > Does the Erlang compiler optimize code such as: > > f() -> case true of true -> ok end. > > To this? > > f() -> ok. When in doubt try erlc -S Which will give you an .S file: e.g. --- -module(f). -export([f/0]). f() -> case true of true -> ok end. --- makrill> erlc -S f.erl makrill> cat f.S {module, f}. %% version = 0 {exports, [{f,0},{module_info,0},{module_info,1}]}. {attributes, []}. {labels, 7}. {function, f, 0, 2}. {label,1}. {func_info,{atom,f},{atom,f},0}. {label,2}. {move,{atom,ok},{x,0}}. return. {function, module_info, 0, 4}. {label,3}. {func_info,{atom,f},{atom,module_info},0}. {label,4}. {move,{atom,f},{x,0}}. {call_ext_only,1,{extfunc,erlang,get_module_info,1}}. {function, module_info, 1, 6}. {label,5}. {func_info,{atom,f},{atom,module_info},1}. {label,6}. {move,{x,0},{x,1}}. {move,{atom,f},{x,0}}. {call_ext_only,2,{extfunc,erlang,get_module_info,2}}. > > > I'm working with Erlang code generation in a customer's product and > I wonder if I need to optimize away such code myself or not. The compiler does this for you. /Erik From adam@REDACTED Thu Mar 19 09:22:58 2009 From: adam@REDACTED (Adam Lindberg) Date: Thu, 19 Mar 2009 08:22:58 +0000 (GMT) Subject: [erlang-questions] Compiler and tautologies In-Reply-To: <2B21A242-F3FE-43AC-B041-B1E6ACCC45CF@kreditor.se> Message-ID: <7421132.84861237450978558.JavaMail.root@zimbra> Nice tip, thanks guys! Cheers, Adam ----- "Erik Stenman" wrote: > On 19 mar 2009, at 08.55, Adam Lindberg wrote: > > > Hi! > > > > Does the Erlang compiler optimize code such as: > > > > f() -> case true of true -> ok end. > > > > To this? > > > > f() -> ok. > > When in doubt try > erlc -S > Which will give you an .S file: > e.g. > --- > -module(f). > -export([f/0]). > > f() -> case true of true -> ok end. > --- > makrill> erlc -S f.erl > makrill> cat f.S > {module, f}. %% version = 0 > {exports, [{f,0},{module_info,0},{module_info,1}]}. > {attributes, []}. > {labels, 7}. > > {function, f, 0, 2}. > {label,1}. > {func_info,{atom,f},{atom,f},0}. > {label,2}. > {move,{atom,ok},{x,0}}. > return. > > {function, module_info, 0, 4}. > {label,3}. > {func_info,{atom,f},{atom,module_info},0}. > {label,4}. > {move,{atom,f},{x,0}}. > {call_ext_only,1,{extfunc,erlang,get_module_info,1}}. > > {function, module_info, 1, 6}. > {label,5}. > {func_info,{atom,f},{atom,module_info},1}. > {label,6}. > {move,{x,0},{x,1}}. > {move,{atom,f},{x,0}}. > {call_ext_only,2,{extfunc,erlang,get_module_info,2}}. > > > > > > > > I'm working with Erlang code generation in a customer's product and > > > I wonder if I need to optimize away such code myself or not. > > The compiler does this for you. > > /Erik From lenartlad@REDACTED Thu Mar 19 10:42:18 2009 From: lenartlad@REDACTED (Ladislav Lenart) Date: Thu, 19 Mar 2009 10:42:18 +0100 Subject: [erlang-questions] process and closure memory usage In-Reply-To: <49427c610903181432w537259dcn43d8eb3921cfe7e4@mail.gmail.com> References: <49427c610903181432w537259dcn43d8eb3921cfe7e4@mail.gmail.com> Message-ID: <49C2137A.9030508@volny.cz> Hi, here are my thought vut I am by no means an Erlang expert... 1. I'd say that using gen_server has no visible memory or performance overhead compared to raw Erlang processes. It is more a question of whether gen_server way of handling incoming messages in order as they come suits your needs. Also you can make a raw Erlang process into an OTP-aware process using proc_lib. 2. I think that process_info reports all memory allocated by the process. From my experience a process roughly uses twice as much memory as it needs. This can be quite a lot for a large number of processes. If only a handful of processes are active in any given time, you could use erlang:hibernate/3 for a raw Erlang process or specify hibernate instead of timeout in gen_server return tuple. 3. This is the most interesting part. Just to clarify, by closure I mean fun (...) -> ... end. If you are sending funs between processes then things can get interesting because beside the code pointer also the lexical scope of the function is sent over the wire. And in order to be sent it has to be serialized first. During this serialization, the "data identity" is not preserved. So if you use complex structure that contains multiple identical parts the scope will be larger after the serialization. This is true for any Erlang term. Example: [A, A, A, A] where A is bound to some tuple. If you send this as a message, the receiver will get [A1, A2, A3, A4, A5] where all received As are equal but no longer point to the same memory location. 4. None that I know of. HTH, Ladislav Lenart Matt Handler wrote: > I'm trying to cut down on the process memory usage for a non-relational > database i'm working on. essentially there are 10,000 processes (setup > as gen_servers) that send information to each other in various ways. i > have several questions: > > 1. how much of an overhead does using the gen_server model assert? > if i'm not as worried about dynamic code loading, supervising, > etc... am i wasting memory and processing using the gen_server? > 2. how/where can i find out more information about the memory usage > of a process? i've used process_info/2 heavily to gather some of > this information, but my problem is that if i look at the rough > size of the state of a process (using erlang:iolist_size/1), it's > significantly less than the size of the process as reported by > process_info/2. i want to know where the rest of the memory is > being eaten up (initially the processes are only 1k), on average, > the process size is about 4x the state size. > 3. i am passing around many closures between the nodes of the > database, and they are getting to be quite large (start out as > 100bytes, end up as 40kbytes). these are what is taking up most > of the memory of the state, and so i'm wondering if there is some > inner workings of the erlang system that make this a bad way of > programming in terms of memory usage. it seems like there are > certain situations that make closures take up a lot of memory, but > i'm having trouble pinpointing when. > 4. is there a good tool out there for profiling the memory usage > rather than executiontime usage? > > thanks for the help, > -matt handler > > > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From richardc@REDACTED Thu Mar 19 11:13:36 2009 From: richardc@REDACTED (Richard Carlsson) Date: Thu, 19 Mar 2009 11:13:36 +0100 Subject: [erlang-questions] Update on sharing constant data locally by reference rather than by copy? In-Reply-To: <49C14D07.9000808@online.fr> References: <49C14D07.9000808@online.fr> Message-ID: <49C21AD0.2050600@it.uu.se> Olivier Boudeville wrote: > would it be possible to have an update regarding how an immutable data > structure (which is not a binary) could be shared between several > processes on the same Erlang node, without having one copy of that data > structure per process? > > I know that the Erlang semantics allows processes to access that > constant data as if there was only one copy of it, but, as I understand, > in practice, currently, they do not access to that data through a const > pointer but still rely on a private copy of it instead > (http://www.erlang.org/pipermail/erlang-questions/2006-September/022739.html) If the entire tables are constant over a long time, you could generate them as modules. Nowadays, compile-time constants (even complex ones) are placed in a constant pool associated with the module. So, you could generate something like this: -module(autogen_table). -export([find/1]). find(0) -> {some_struct, "hello", ...}; ... find(99) -> {some_other_struct, <<"hi!">>} find(X) -> throw({not_found, X}). As far as I know, these constants will not be copied to the private heaps of the processes. The generated code will also give you the fastest possible lookup. /Richard From exta7@REDACTED Thu Mar 19 11:18:15 2009 From: exta7@REDACTED (Zvi) Date: Thu, 19 Mar 2009 03:18:15 -0700 (PDT) Subject: [erlang-questions] Re assigning variables In-Reply-To: References: <879778450903171338j5f47e27fm6b6016906dff0159@mail.gmail.com> <20090317214258.GQ32606@h216-235-12-174.host.egate.net> Message-ID: <22597115.post@talk.nabble.com> Tony Arcieri wrote: > > On Tue, Mar 17, 2009 at 3:42 PM, Vance Shipley wrote: > >> try begin >> case requested_ad_size(Size) of >> bad -> >> throw(bad_size); >> _ -> >> ok >> end, >> case has_ads() of >> true -> >> throw(disabled); >> false -> >> ok >> end, >> case is_filtering() of >> true -> >> throw(domain_filtered); >> false -> >> ok >> end >> end of >> ok -> >> yahoo >> catch >> Problem -> >> Problem >> end >> > > Very cool. Thanks for this suggestion. > > -- > Tony Arcieri > medioh.com > Tony, you kidding right? :) As I said before: "Hard thing are easy to implement in Erlang, but some simple things are hard!". Programmers are not compilers - compilers are compilers. Suggesting to code manually such basic operator, like if-then-else-elsif using exceptions, higher-order-functions and macros is #$%^& (I have no words) . The LISP's cond function was invented 50 years ago. The cond even reserved word in Erlang. BTW: I think RoK's ?when macros will not work, b/c if only works with guards (also aren't when reserved word too?) -- View this message in context: http://www.nabble.com/Reassigning-variables-tp22564802p22597115.html Sent from the Erlang Questions mailing list archive at Nabble.com. From exta7@REDACTED Thu Mar 19 11:18:52 2009 From: exta7@REDACTED (Zvi) Date: Thu, 19 Mar 2009 03:18:52 -0700 (PDT) Subject: [erlang-questions] Re assigning variables In-Reply-To: References: <879778450903171338j5f47e27fm6b6016906dff0159@mail.gmail.com> <20090317214258.GQ32606@h216-235-12-174.host.egate.net> Message-ID: <22597126.post@talk.nabble.com> Tony Arcieri wrote: > > On Tue, Mar 17, 2009 at 3:42 PM, Vance Shipley wrote: > >> try begin >> case requested_ad_size(Size) of >> bad -> >> throw(bad_size); >> _ -> >> ok >> end, >> case has_ads() of >> true -> >> throw(disabled); >> false -> >> ok >> end, >> case is_filtering() of >> true -> >> throw(domain_filtered); >> false -> >> ok >> end >> end of >> ok -> >> yahoo >> catch >> Problem -> >> Problem >> end >> > > Very cool. Thanks for this suggestion. > > -- > Tony Arcieri > medioh.com > Tony, you kidding right? :) As I said before: "Hard thing are easy to implement in Erlang, but some simple things are hard!". Programmers are not compilers - compilers are compilers. Suggesting to code manually such basic operator, like if-then-else-elsif using exceptions, higher-order-functions and macros is #$%^& (I have no words) . The LISP's cond function was invented 50 years ago. The cond even reserved word in Erlang. BTW: I think RoK's ?when macros will not work, b/c if only works with guards (also aren't when reserved word too?) -- View this message in context: http://www.nabble.com/Reassigning-variables-tp22564802p22597126.html Sent from the Erlang Questions mailing list archive at Nabble.com. From masse@REDACTED Thu Mar 19 13:22:31 2009 From: masse@REDACTED (mats cronqvist) Date: Thu, 19 Mar 2009 13:22:31 +0100 Subject: [erlang-questions] Reassigning variables In-Reply-To: (Matthew Dempsky's message of "Wed\, 18 Mar 2009 10\:33\:25 -0700") References: <18880.49864.505762.419689@ornendil.du.uab.ericsson.se> Message-ID: <87eiwtitx4.fsf@sterlett.hq.kred> Matthew Dempsky writes: > Here's an actual block of code from the Erlang compiler: > > lc_tq(Line, E, [{generate,Lg,P,G}|Qs0], Mc, St0) -> > {Gs,Qs1} = splitwith(fun is_guard_test/1, Qs0), > {Name,St1} = new_fun_name("lc", St0), > {Head,St2} = new_var(St1), > {Tname,St3} = new_var_name(St2), > LA = lineno_anno(Line, St2), > LAnno = #a{anno=LA}, > Tail = #c_var{anno=LA,name=Tname}, > {Arg,St4} = new_var(St3), > {Nc,[],St5} = expr({call,Lg,{atom,Lg,Name},[{var,Lg,Tname}]}, St4), > {Guardc,St6} = lc_guard_tests(Gs, St5), %These are always flat! > {Lc,Lps,St7} = lc_tq(Line, E, Qs1, Nc, St6), > {Pc,St8} = list_gen_pattern(P, Line, St7), > {Gc,Gps,St9} = safe(G, St8), %Will be a > function argument! > Fc = function_clause([Arg], LA, {Name,1}), > .... how about this then. my_expr(Lg,Name,Tname,St) -> expr({call,Lg,{atom,Lg,Name},[{var,Lg,Tname}]},St). my_lanno(Line,Tname,St) -> LA = lineno_anno(Line,St), {LA,#a{anno=LA},#c_var{anno=LA,name=Tname}}. my_lc_tq(Line, E, [{generate,Lg,P,G}|Qs], Mc, St) -> all(s(qs,st,{Qs,St}), [fun(X)->s(X,gs,qs1, splitwith(fun is_guard_test/1,f(X,qs)))end ,fun(X)->s(X,name,st, new_fun_name("lc", f(X,St)))end ,fun(X)->s(X,head,st, new_var(f(X,st)))end ,fun(X)->s(X,tname,st, new_var_name(f(X,st)))end ,fun(X)->s(X,la,lanno,tail,my_lanno(Line,f(X,tname),f(X,st)))end ,fun(X)->s(X,arg,st, new_var(f(X,st)))end ,fun(X)->s(X,nc,'',st, my_expr(Lg,f(X,name),f(X,tname),f(X,st)))end ,fun(X)->s(X,guardc,st, lc_guard_tests(f(X,gs),f(X,st)))end ,fun(X)->s(X,lc,lps,st, lc_tq(Line,E,f(X,qs),f(X,nc),f(X,st)))end ,fun(X)->s(X,pc,st, list_gen_pattern(P,Line,f(X,st)))end ,fun(X)->s(X,gc,gps,st, safe(G,f(X,st)))end ,fun(X)->s(X,fc,function_clause([f(X,arg)],f(X,la),{f(X,name),1}))end]). slightly longer (15 vs. 19 lines) and it needs the (trivial) helper functions s(tore), f(etch) and all. But a heck of a lot easier to maintain and extend(*). I guess you could turn the fun(X)->s(X,...)end boilerplate into a macro(**), but I'm not sure that actually improves things. mats (*) At least I think so. Of course, I also think the original is an abomination. Shows what I know. (**) like this; -define(S(X,Ts,Xp), fun(X)->s(X,Ts,Xp)end). my_lc_tq(Line, E, [{generate,Lg,P,G}|Qs], Mc, St) -> all(s(qs,st,{Qs,St}), [?S(X,{gs,qs1}, splitwith(fun is_guard_test/1,f(X,qs))) ,?S(X,{name,st}, new_fun_name("lc", f(X,St))) ,?S(X,{head,st}, new_var(f(X,st))) ,?S(X,{tname,st}, new_var_name(f(X,st))) ,?S(X,{la,lan,tail},my_lanno(Line,f(X,tname),f(X,st))) ,?S(X,{arg,st}, new_var(f(X,st))) ,?S(X,{nc,'',st}, my_expr(Lg,f(X,name),f(X,tname),f(X,st))) ,?S(X,{guardc,st}, lc_guard_tests(f(X,gs),f(X,st))) ,?S(X,{lc,lps,st}, lc_tq(Line,E,f(X,qs),f(X,nc),f(X,st))) ,?S(X,{pc,st}, list_gen_pattern(P,Line,f(X,st))) ,?S(X,{gc,gps,st}, safe(G,f(X,st))) ,?S(X,{fc}, function_clause([f(X,arg)],f(X,la),{f(X,name),1}))]). From tuscland@REDACTED Thu Mar 19 13:54:39 2009 From: tuscland@REDACTED (Camille Troillard) Date: Thu, 19 Mar 2009 13:54:39 +0100 Subject: [erlang-questions] Reassigning variables In-Reply-To: <87eiwtitx4.fsf@sterlett.hq.kred> References: <18880.49864.505762.419689@ornendil.du.uab.ericsson.se> <87eiwtitx4.fsf@sterlett.hq.kred> Message-ID: Hi everyone, On Thu, Mar 19, 2009 at 1:22 PM, mats cronqvist wrote: > my_lc_tq(Line, E, [{generate,Lg,P,G}|Qs], Mc, St) -> > all(s(qs,st,{Qs,St}), > [fun(X)->s(X,gs,qs1, splitwith(fun is_guard_test/1,f(X,qs)))end > ,fun(X)->s(X,name,st, new_fun_name("lc", f(X,St)))end > ,fun(X)->s(X,head,st, new_var(f(X,st)))end > ,fun(X)->s(X,tname,st, new_var_name(f(X,st)))end > ,fun(X)->s(X,la,lanno,tail,my_lanno(Line,f(X,tname),f(X,st)))end > ,fun(X)->s(X,arg,st, new_var(f(X,st)))end > ,fun(X)->s(X,nc,'',st, > my_expr(Lg,f(X,name),f(X,tname),f(X,st)))end > ,fun(X)->s(X,guardc,st, lc_guard_tests(f(X,gs),f(X,st)))end > ,fun(X)->s(X,lc,lps,st, lc_tq(Line,E,f(X,qs),f(X,nc),f(X,st)))end > ,fun(X)->s(X,pc,st, list_gen_pattern(P,Line,f(X,st)))end > ,fun(X)->s(X,gc,gps,st, safe(G,f(X,st)))end > > ,fun(X)->s(X,fc,function_clause([f(X,arg)],f(X,la),{f(X,name),1}))end]). [...] > -define(S(X,Ts,Xp), fun(X)->s(X,Ts,Xp)end). > > my_lc_tq(Line, E, [{generate,Lg,P,G}|Qs], Mc, St) -> > all(s(qs,st,{Qs,St}), > [?S(X,{gs,qs1}, splitwith(fun is_guard_test/1,f(X,qs))) > ,?S(X,{name,st}, new_fun_name("lc", f(X,St))) > ,?S(X,{head,st}, new_var(f(X,st))) > ,?S(X,{tname,st}, new_var_name(f(X,st))) > ,?S(X,{la,lan,tail},my_lanno(Line,f(X,tname),f(X,st))) > ,?S(X,{arg,st}, new_var(f(X,st))) > ,?S(X,{nc,'',st}, my_expr(Lg,f(X,name),f(X,tname),f(X,st))) > ,?S(X,{guardc,st}, lc_guard_tests(f(X,gs),f(X,st))) > ,?S(X,{lc,lps,st}, lc_tq(Line,E,f(X,qs),f(X,nc),f(X,st))) > ,?S(X,{pc,st}, list_gen_pattern(P,Line,f(X,st))) > ,?S(X,{gc,gps,st}, safe(G,f(X,st))) > ,?S(X,{fc}, > function_clause([f(X,arg)],f(X,la),{f(X,name),1}))]). I find interesting (or curious) how people want to reach aesthetically pleasant code to read. No offense, really, it's just that I don't think it leads anywhere useful. We saw from Richard O'Keefe at the beginning of the discussion that assignments were not that common in Erlang, and that destructive ones were even less common. In my opinion, while this is interesting in a "code beauty" aspect, it serves no useful purpose to overload the code with macros, helper functions, and other language candies that just try to solve a specific problem. Just my two cents ? Best, Cam -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf.wiger@REDACTED Thu Mar 19 13:57:59 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Thu, 19 Mar 2009 13:57:59 +0100 Subject: [erlang-questions] Reassigning variables In-Reply-To: <87eiwtitx4.fsf@sterlett.hq.kred> References: <18880.49864.505762.419689@ornendil.du.uab.ericsson.se> <87eiwtitx4.fsf@sterlett.hq.kred> Message-ID: <49C24157.4080904@erlang-consulting.com> mats cronqvist wrote: > > (*) At least I think so. Of course, I also think the > original is an abomination. Shows what I know. Quod licet Jovi non licet Bovi. One can trust compiler writers to use all sorts of dirty tricks and still get the job done. If memory serves, you have worked in projects where not /every/ programmer was a rocket scientist. That tends to affect your judgement a bit. ;-) BR, Ulf W -- Ulf Wiger CTO, Erlang Training & Consulting Ltd http://www.erlang-consulting.com From ulf.wiger@REDACTED Thu Mar 19 14:08:44 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Thu, 19 Mar 2009 14:08:44 +0100 Subject: [erlang-questions] Reassigning variables In-Reply-To: References: <18880.49864.505762.419689@ornendil.du.uab.ericsson.se> <87eiwtitx4.fsf@sterlett.hq.kred> Message-ID: <49C243DC.7010706@erlang-consulting.com> Camille Troillard wrote: > I find interesting (or curious) how people want to > reach aesthetically pleasant code to read. No > offense, really, it's just that I don't think > it leads anywhere useful. Let me quote Richard O'Keefe, so he won't have to repeat himself: Elegance is not optional I think making the code aesthetically pleasing is extremely important. To paraphrase Sir Tony Hoare, who spoke at QCon last week, software tends to live much longer than we would like. Reading other people's programs is difficult to begin with, even if they have made an effort to make the code readable. In many cases, no such effort is apparent to the reader. > In my opinion, while this is interesting in > a "code beauty" aspect, it serves no useful purpose > to overload the code with macros, helper functions, > and other language candies that just try to solve > a specific problem. Overloading with macros seldomly helps readability. Helper functions can, if carefully chosen. And I think this problem is common enough that it deserves some effort. BR, Ulf W -- Ulf Wiger CTO, Erlang Training & Consulting Ltd http://www.erlang-consulting.com From adam@REDACTED Thu Mar 19 14:30:58 2009 From: adam@REDACTED (Adam Lindberg) Date: Thu, 19 Mar 2009 13:30:58 +0000 (GMT) Subject: [erlang-questions] Reassigning variables In-Reply-To: <1371397.85931237469128785.JavaMail.root@zimbra> Message-ID: <15956026.85981237469458354.JavaMail.root@zimbra> You can even see a greater pattern here. There is a state that is passed from function to function. Thus you have a series of functions transforming a data structure as they go. f() -> foo(bar(baz(St0))) It is then simple to insert new transformations in between. Just add another function call. If you need debugging in between, just debug the function calls. If you can't because they are too general, they're probably too general. BUT, there is also another thing happening here. Each transformation can also return one or several variables saved for later use by later transformation. This can also be passed around by using a dictionary or a key-value list. f() -> lists:foldl(fun(F, Acc) -> ?MODULE:F(Acc) end, {St0, []}, [foo, bar, baz]). foo({St, Vars}) -> % Do stuff with state and vars {StNew, Vars ++ [{my_saved_var, Var}]}. bar({St, Vars}) -> ... Something = proplists:get_value(my_saved_var, Vars, default) ... It is then trivial to add another transformation function in the series, at any position. Just add another function name in the correct position in the function list and implement it in the module. It is also easier to test each transformation independently from one another. Just my two cents... Cheers, Adam ----- "Ulf Wiger" wrote: > Matthew Dempsky wrote: > > > > Here's an actual block of code from the Erlang compiler: > > > > lc_tq(Line, E, [{generate,Lg,P,G}|Qs0], Mc, St0) -> > > {Gs,Qs1} = splitwith(fun is_guard_test/1, Qs0), > > {Name,St1} = new_fun_name("lc", St0), > > {Head,St2} = new_var(St1), > > {Tname,St3} = new_var_name(St2), > > LA = lineno_anno(Line, St2), > > LAnno = #a{anno=LA}, > > Tail = #c_var{anno=LA,name=Tname}, > > {Arg,St4} = new_var(St3), > > {Nc,[],St5} = > expr({call,Lg,{atom,Lg,Name},[{var,Lg,Tname}]}, St4), > > {Guardc,St6} = lc_guard_tests(Gs, St5), %These are > always flat! > > {Lc,Lps,St7} = lc_tq(Line, E, Qs1, Nc, St6), > > {Pc,St8} = list_gen_pattern(P, Line, St7), > > {Gc,Gps,St9} = safe(G, St8), %Will be a > > function argument! > > Fc = function_clause([Arg], LA, {Name,1}), > > .... > [...] > > But, please, show me how you would write v3_core:lc_tq/5 without > > numbered state variables without losing any readability. > > So there's a pattern there, and there's actually a library > function that might help to eliminate most of the numbered > variable names. > > thread(Fs, St) -> > lists:mapfoldl(fun(F,St1) -> F(St) end, St, Fs). > > lc_tq(Line, E, [{generate,Lg,P,G}|Qs0], Mc, St0) -> > {Gs,Qs1} = splitwith(fun is_guard_test/1, Qs0), > {[Name, Head, Tname], St1} = > thread([fun(St) -> new_fun_name("lc", St) end, > fun new_var/1, > fun new_var_name/1], St0), > ... > > Whether it's more readable is perhaps a matter of > taste. It ought to be easier to maintain though. > > BR, > Ulf W > -- > Ulf Wiger > CTO, Erlang Training & Consulting Ltd > http://www.erlang-consulting.com > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From vychodil.hynek@REDACTED Thu Mar 19 14:38:57 2009 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Thu, 19 Mar 2009 14:38:57 +0100 Subject: [erlang-questions] process and closure memory usage In-Reply-To: <49C2137A.9030508@volny.cz> References: <49427c610903181432w537259dcn43d8eb3921cfe7e4@mail.gmail.com> <49C2137A.9030508@volny.cz> Message-ID: <4d08db370903190638v7eecf451y93b53575013729f5@mail.gmail.com> On Thu, Mar 19, 2009 at 10:42 AM, Ladislav Lenart wrote: > Hi, > > here are my thought vut I am by no means an Erlang expert... > > 1. I'd say that using gen_server has no visible memory or performance > overhead compared to raw Erlang processes. It is more a question of > whether gen_server way of handling incoming messages in order as they > come suits your needs. Also you can make a raw Erlang process into an > OTP-aware process using proc_lib. > > 2. I think that process_info reports all memory allocated by the > process. From my experience a process roughly uses twice as much > memory as it needs. Doubling memory footprint depends in way how Erlang GC works. It is trade-off between scalability and soft real-time characteristics and memory footprint. This can be quite a lot for a large number of > processes. If only a handful of processes are active in any given > time, you could use erlang:hibernate/3 for a raw Erlang process > or specify hibernate instead of timeout in gen_server return tuple. > > 3. This is the most interesting part. Just to clarify, by closure I > mean fun (...) -> ... end. If you are sending funs between processes > then things can get interesting because beside the code pointer also > the lexical scope of the function is sent over the wire. And in order > to be sent it has to be serialized first. During this serialization, > the "data identity" is not preserved. So if you use complex structure > that contains multiple identical parts the scope will be larger after > the serialization. This is true for any Erlang term. Example: [A, A, > A, A] where A is bound to some tuple. If you send this as a message, > the receiver will get [A1, A2, A3, A4, A5] where all received As are > equal but no longer point to the same memory location. > > 4. None that I know of. > > > HTH, > > Ladislav Lenart > > > Matt Handler wrote: > > I'm trying to cut down on the process memory usage for a non-relational > > database i'm working on. essentially there are 10,000 processes (setup > > as gen_servers) that send information to each other in various ways. i > > have several questions: > > > > 1. how much of an overhead does using the gen_server model assert? > > if i'm not as worried about dynamic code loading, supervising, > > etc... am i wasting memory and processing using the gen_server? > > 2. how/where can i find out more information about the memory usage > > of a process? i've used process_info/2 heavily to gather some of > > this information, but my problem is that if i look at the rough > > size of the state of a process (using erlang:iolist_size/1), it's > > significantly less than the size of the process as reported by > > process_info/2. i want to know where the rest of the memory is > > being eaten up (initially the processes are only 1k), on average, > > the process size is about 4x the state size. > > 3. i am passing around many closures between the nodes of the > > database, and they are getting to be quite large (start out as > > 100bytes, end up as 40kbytes). these are what is taking up most > > of the memory of the state, and so i'm wondering if there is some > > inner workings of the erlang system that make this a bad way of > > programming in terms of memory usage. it seems like there are > > certain situations that make closures take up a lot of memory, but > > i'm having trouble pinpointing when. > > 4. is there a good tool out there for profiling the memory usage > > rather than executiontime usage? > > > > thanks for the help, > > -matt handler > > > > > > ------------------------------------------------------------------------ > > > > _______________________________________________ > > 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 Analyze your data in minutes. Share your insights instantly. Thrill your boss. Be a data hero! Try Good Data now for free: www.gooddata.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From elias@REDACTED Thu Mar 19 15:04:26 2009 From: elias@REDACTED (Elias Torres) Date: Thu, 19 Mar 2009 10:04:26 -0400 Subject: [erlang-questions] An Erlang robots.txt parser Message-ID: Hi Everyone, I did a quick search on google for a robots.txt parser but unfortunately nothing concrete surfaced. Does anybody know of one before I write it? -Elias From adam@REDACTED Thu Mar 19 15:05:19 2009 From: adam@REDACTED (Adam Lindberg) Date: Thu, 19 Mar 2009 14:05:19 +0000 (GMT) Subject: [erlang-questions] Please help me relate a past project to Erlang, I'm trying to understand... In-Reply-To: Message-ID: <10187912.86171237471519622.JavaMail.root@zimbra> ----- "bill robertson" wrote: > So that is the deal. I guess that makes sense, because when you're > waiting on a receive to return, you still have a stack frame don't > you? > > I think I finally get it. > > Thanks all! Wonderful thread! Cheers, Adam From dmercer@REDACTED Thu Mar 19 15:09:02 2009 From: dmercer@REDACTED (David Mercer) Date: Thu, 19 Mar 2009 09:09:02 -0500 Subject: [erlang-questions] Reassigning variables In-Reply-To: <15956026.85981237469458354.JavaMail.root@zimbra> References: <1371397.85931237469128785.JavaMail.root@zimbra> <15956026.85981237469458354.JavaMail.root@zimbra> Message-ID: <17B2BF546D3B4F699FA081A0AF6CAE02@SSI.CORP> On March 19, 2009, Adam Lindberg wrote: > BUT, there is also another thing happening here. Each transformation can > also return one or several variables saved for later use by later > transformation. This can also be passed around by using a dictionary or a > key-value list. You're on to something here... > f() -> > lists:foldl(fun(F, Acc) -> ?MODULE:F(Acc) end, {St0, []}, [foo, bar, > baz]). > > foo({St, Vars}) -> > % Do stuff with state and vars > {StNew, Vars ++ [{my_saved_var, Var}]}. > bar({St, Vars}) -> > ... > Something = proplists:get_value(my_saved_var, Vars, default) > ... Shouldn't the last line in foo/1 be: {StNew, [{my_saved_var, Var} | Vars]}. That would ensure that the most recent assignment is pulled out by proplists:get_value rather than the first assignment. Using this approach, we wouldn't even have to keep the state separately; just store it in the proplist as 'state': f() -> lists:foldl(fun(F, Acc) -> ?MODULE:F(Acc) end, [{state, InitialState}], [ foo , bar , baz ]). foo(Vars) -> OldState = proplists:get_value(state, Vars), % Do stuff with state and vars [{state, NewState}, {my_saved_var, Var} | Vars]. bar(Vars) -> ... Something = proplists:get_value(my_saved_var, Vars, default) ... Cheers, DBM From chsu79@REDACTED Thu Mar 19 15:09:41 2009 From: chsu79@REDACTED (Christian) Date: Thu, 19 Mar 2009 15:09:41 +0100 Subject: [erlang-questions] Update on sharing constant data locally by reference rather than by copy? In-Reply-To: <49C14D07.9000808@online.fr> References: <49C14D07.9000808@online.fr> Message-ID: > Is it planned to implement a more efficient sharing which would not > involve a copy? Do you know about the hybrid heap experiment? It experiments with shared heaps so that processes can message pass references to data values rather than creating copies. From vychodil.hynek@REDACTED Thu Mar 19 16:05:55 2009 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Thu, 19 Mar 2009 16:05:55 +0100 Subject: [erlang-questions] Update on sharing constant data locally by reference rather than by copy? In-Reply-To: References: <49C14D07.9000808@online.fr> Message-ID: <4d08db370903190805l674a1747oa7794d986bebd21f@mail.gmail.com> It will obviously broke current Erlang GC. There is experimental implementation Termite http://code.google.com/p/termite/ (Gambit-C) which uses this approach. Note that this feature you sacrifice GC soft real time characteristics and reliability for performance. On Thu, Mar 19, 2009 at 3:09 PM, Christian wrote: > > Is it planned to implement a more efficient sharing which would not > > involve a copy? > > Do you know about the hybrid heap experiment? It experiments with > shared heaps so that processes can message pass references to data > values rather than creating copies. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- --Hynek (Pichi) Vychodil Analyze your data in minutes. Share your insights instantly. Thrill your boss. Be a data hero! Try Good Data now for free: www.gooddata.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From masse@REDACTED Thu Mar 19 16:31:27 2009 From: masse@REDACTED (mats cronqvist) Date: Thu, 19 Mar 2009 16:31:27 +0100 Subject: [erlang-questions] Reassigning variables In-Reply-To: (Camille Troillard's message of "Thu\, 19 Mar 2009 13\:54\:39 +0100") References: <18880.49864.505762.419689@ornendil.du.uab.ericsson.se> <87eiwtitx4.fsf@sterlett.hq.kred> Message-ID: <8763i5il68.fsf@sterlett.hq.kred> Camille Troillard writes: > I find interesting (or curious) how people want to reach aesthetically > pleasant code to read. No offense, really, it's just that I don't think it > leads anywhere useful. I find it interesting that readability is regarded as something only pointy-headed academics are interested in, and uninteresting in the real world of commercial software. In my experience, code that is not "aesthetically pleasant" is guaranteed to have this property; only its author can find the bugs. This is of course not a problem for a hobbyist, or perhaps even a compiler writer. But it is the mother of bad software products. mats From rob.lally@REDACTED Thu Mar 19 17:19:39 2009 From: rob.lally@REDACTED (Robert Lally) Date: Thu, 19 Mar 2009 16:19:39 +0000 Subject: [erlang-questions] Reassigning variables In-Reply-To: <8763i5il68.fsf@sterlett.hq.kred> References: <18880.49864.505762.419689@ornendil.du.uab.ericsson.se> <87eiwtitx4.fsf@sterlett.hq.kred> <8763i5il68.fsf@sterlett.hq.kred> Message-ID: I subscribe to the school of thought that code is written primarily for people to read. It also has to compile, but that's a secondary consideration. Readability is directly proportional to the cost of maintaining software. In a commercial environment readability is vital. In fact, only those with no commercial constraints can afford to support read-only software. I'm not suggesting that all commercial companies live up to this ideal. But those that don't pay a premium for their mistake. Rob Lally. 2009/3/19 mats cronqvist > Camille Troillard writes: > > > I find interesting (or curious) how people want to reach aesthetically > > pleasant code to read. No offense, really, it's just that I don't think > it > > leads anywhere useful. > > I find it interesting that readability is regarded as something only > pointy-headed academics are interested in, and uninteresting in the > real world of commercial software. > > In my experience, code that is not "aesthetically pleasant" is > guaranteed to have this property; only its author can find the bugs. > > This is of course not a problem for a hobbyist, or perhaps even a > compiler writer. But it is the mother of bad software products. > > mats > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- Blog : http://robertlally.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From tuscland@REDACTED Thu Mar 19 17:26:30 2009 From: tuscland@REDACTED (Camille Troillard) Date: Thu, 19 Mar 2009 17:26:30 +0100 Subject: [erlang-questions] Reassigning variables In-Reply-To: <8763i5il68.fsf@sterlett.hq.kred> References: <18880.49864.505762.419689@ornendil.du.uab.ericsson.se> <87eiwtitx4.fsf@sterlett.hq.kred> <8763i5il68.fsf@sterlett.hq.kred> Message-ID: On Thu, Mar 19, 2009 at 4:31 PM, mats cronqvist wrote: > I find it interesting that readability is regarded as something only > pointy-headed academics are interested in, and uninteresting in the > real world of commercial software. > > In my experience, code that is not "aesthetically pleasant" is > guaranteed to have this property; only its author can find the bugs. Alright, let's put it that way: I'm not saying that one should be content with hard to read code. Remember the purpose of this thread is to discuss destructive assignments? Erlang is born with pattern matching, and non destructive assignments. I don't understand why it is a quality to pass around this very quality, that makes the language better at the price of readability. I've spent myself lots of time design macros and 'elegant' stuff to please my eyes. In the end I eventually found that it was even more code to maintain and understand. This is of course not a problem for a hobbyist, or perhaps even a > compiler writer. I'm sorry Mat, but this assertion is very closed minded. But it is the mother of bad software products. I agree that easy to read code is better for maintainability. But this thread has yet to prove that the very solutions being searched for readability have actually a interest in maintainability. Best, Camille -------------- next part -------------- An HTML attachment was scrubbed... URL: From vances@REDACTED Thu Mar 19 17:36:10 2009 From: vances@REDACTED (Vance Shipley) Date: Thu, 19 Mar 2009 12:36:10 -0400 Subject: [erlang-questions] Reassigning variables In-Reply-To: <401d3ba30903180348r287019d0l75ea8bb383ff6e@mail.gmail.com> References: <879778450903171338j5f47e27fm6b6016906dff0159@mail.gmail.com> <20090317214258.GQ32606@h216-235-12-174.host.egate.net> <401d3ba30903180348r287019d0l75ea8bb383ff6e@mail.gmail.com> Message-ID: <20090319163610.GT32606@h216-235-12-174.host.egate.net> On Wed, Mar 18, 2009 at 11:48:34AM +0100, Attila Rajmund Nohl wrote: } 7 lines (easily fit into one screen) vs 25 lines (probably not much } other than this code is shown on the screen) full of no-ops like "_ -> } ok" - a really bad idea in my opinion. OK, here it is on one line: try begin case requested_ad_size(Size) of bad -> throw(bad_size); _ -> ok end, case has_ads() of true -> throw(disabled); false -> ok end, case is_filtering() of true -> throw(domain_filtered); false -> ok end end of ok -> yahoo catch Problem -> Problem end. The point is that if you want to program sequential there is a clear way to do it. I use that paradigm quite often in the init/1 functions of gen_server/gen_fsm. Your criticism about line counts is quite the opposite of the readability topic this thread has taken. You can complain about Erlang's case statements being too verbose but they are certainly clear. -- -Vance From mrad-direct-erlang@REDACTED Thu Mar 19 17:38:21 2009 From: mrad-direct-erlang@REDACTED (Michael Radford) Date: Thu, 19 Mar 2009 09:38:21 -0700 Subject: [erlang-questions] Reassigning variables In-Reply-To: References: <18880.49864.505762.419689@ornendil.du.uab.ericsson.se> <87eiwtitx4.fsf@sterlett.hq.kred> <8763i5il68.fsf@sterlett.hq.kred> Message-ID: <20090319163821.GA28516@herbie> I totally agree about readability, but I think we need to distinguish "readable" code from "elegant" (or aesthetically pleasing) code. It's similar to the difference between newspaper writing vs. writing a novel, or poetry. Most of the time, commercial software should be more like the former -- state the facts in a way that most people can understand easily, and get out of the way. Occasionally, this sort of code might turn out to be elegant, but that's not the primary goal. I think that might have been what Camille was getting at. Mike Robert Lally writes: > I subscribe to the school of thought that code is written primarily for > people to read. It also has to compile, but that's a secondary > consideration. > Readability is directly proportional to the cost of maintaining software. In > a commercial environment readability is vital. In fact, only those with no > commercial constraints can afford to support read-only software. > > I'm not suggesting that all commercial companies live up to this ideal. But > those that don't pay a premium for their mistake. > > > Rob Lally. > > > 2009/3/19 mats cronqvist > > > Camille Troillard writes: > > > > > I find interesting (or curious) how people want to reach aesthetically > > > pleasant code to read. No offense, really, it's just that I don't think > > it > > > leads anywhere useful. > > > > I find it interesting that readability is regarded as something only > > pointy-headed academics are interested in, and uninteresting in the > > real world of commercial software. > > > > In my experience, code that is not "aesthetically pleasant" is > > guaranteed to have this property; only its author can find the bugs. > > > > This is of course not a problem for a hobbyist, or perhaps even a > > compiler writer. But it is the mother of bad software products. > > > > mats > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > > -- > Blog : http://robertlally.com > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From rtrlists@REDACTED Thu Mar 19 17:40:29 2009 From: rtrlists@REDACTED (Robert Raschke) Date: Thu, 19 Mar 2009 16:40:29 +0000 Subject: [erlang-questions] Monads in Erlang? Message-ID: <6a3ae47e0903190940o798d06cbvd85ec2a60b52fb98@mail.gmail.com> Hi, all this very interesting discussion about patterns and state carrying from one expression to the next makes me think a lot of state monads. I've never really delved into Haskell all too deeply (it's on my list of things to learn much more of), but would some of the objections and issues to do with numbered "state patterns" be addressed by something similar to state monads? I'm guessing that tuple patterns involving atoms as signifiers for results make this tricky, but maybe someone has thought about this in more detail? Robby From ulf@REDACTED Thu Mar 19 18:14:34 2009 From: ulf@REDACTED (Ulf Wiger) Date: Thu, 19 Mar 2009 18:14:34 +0100 Subject: [erlang-questions] Reassigning variables In-Reply-To: <20090319163821.GA28516@herbie> References: <18880.49864.505762.419689@ornendil.du.uab.ericsson.se> <87eiwtitx4.fsf@sterlett.hq.kred> <8763i5il68.fsf@sterlett.hq.kred> <20090319163821.GA28516@herbie> Message-ID: <8209f740903191014h13154767j435c3244a7197a24@mail.gmail.com> 2009/3/19 Michael Radford : > I totally agree about readability, but I think we need to distinguish > "readable" code from "elegant" (or aesthetically pleasing) code. > > It's similar to the difference between newspaper writing vs. writing a > novel, or poetry. ?Most of the time, commercial software should be more > like the former -- state the facts in a way that most people can > understand easily, and get out of the way. ?Occasionally, this sort of > code might turn out to be elegant, but that's not the primary goal. The primary goal of commercial is always to do its job well enough. Elegance is seldomly achieved, but in my experience, if you try to implant the /idea/ of elegance in the minds of commercial software teams, readability might be achieved, at least some of the time. Then of course, there's the question of what one finds elegant. The most aesthetically pleasing Erlang program I've seen was probably Urban Boquist's Soduku solver, which won 2nd prize in the 2005 Obfuscated Erlang competition, but as a program, it was largely unreadable. http://www.erlang-consulting.com/obfuscatederlang2005.html#secondPrize So for clarity's sake, let's define as elegance in the realm of software as a program satisfying the first of Sir Tony Hoare's alternatives below: ?There are two ways of constructing a software design; one way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.? I used to use this quote when discussing coding style in my previous job. Whether it had any effect, I will let remain a closely guarded secret. BR, Ulf W From james.hague@REDACTED Thu Mar 19 18:18:08 2009 From: james.hague@REDACTED (James Hague) Date: Thu, 19 Mar 2009 12:18:08 -0500 Subject: [erlang-questions] Reassigning variables In-Reply-To: References: Message-ID: I'm not surprised to see the storm that this has started. But after having taken the deep dive into Erlang for decidedly non-traditional FP applications (see http://prog21.dadgum.com), here's what I've decided: For some types of programs, it takes significantly less effort to write code if you can re-use names within the same function. I'm not saying it's the most elegant solution or the the easiest to reason about, but it's hands-down the most straightforward to write. Quite often I find I could bang-out code quickly given the ability to "destructively update variables," but trying to craft it without such an ability results in code that takes extra time to write and is usually much more sensitive to slight changes in the problem definition. I don't think that flatly denying this does any good. All it does is make Python and Ruby look very attractive in some situations. You can ALREADY simulate imperative updates using function calls (see http://prog21.dadgum.com/5.html). Adding some syntactic sugar to make this easiest is a good thing. Now remember, there's still NO need to add "for" loops and "while" loops to Erlang. But re-using names within the same function? Yes please, providing it can be done in a clean way; I realize it can conflict with pattern matching if not done correctly. James From masse@REDACTED Thu Mar 19 21:12:57 2009 From: masse@REDACTED (mats cronqvist) Date: Thu, 19 Mar 2009 21:12:57 +0100 Subject: [erlang-questions] Reassigning variables In-Reply-To: <20090319163821.GA28516@herbie> (Michael Radford's message of "Thu\, 19 Mar 2009 09\:38\:21 -0700") References: <18880.49864.505762.419689@ornendil.du.uab.ericsson.se> <87eiwtitx4.fsf@sterlett.hq.kred> <8763i5il68.fsf@sterlett.hq.kred> <20090319163821.GA28516@herbie> Message-ID: <87ab7h2rw6.fsf@dixie.cronqvi.st> Michael Radford writes: > I totally agree about readability, but I think we need to distinguish > "readable" code from "elegant" (or aesthetically pleasing) code. > > It's similar to the difference between newspaper writing vs. writing a > novel, or poetry. Most of the time, commercial software should be more > like the former -- state the facts in a way that most people can > understand easily, and get out of the way. Occasionally, this sort of > code might turn out to be elegant, but that's not the primary goal. Well put. I believe I err on the side of (striving for) elegance, possibly because of all the horrible stuff I had to read at a previous job. mats From masse@REDACTED Thu Mar 19 21:24:16 2009 From: masse@REDACTED (mats cronqvist) Date: Thu, 19 Mar 2009 21:24:16 +0100 Subject: [erlang-questions] Reassigning variables In-Reply-To: (Camille Troillard's message of "Thu\, 19 Mar 2009 17\:26\:30 +0100") References: <18880.49864.505762.419689@ornendil.du.uab.ericsson.se> <87eiwtitx4.fsf@sterlett.hq.kred> <8763i5il68.fsf@sterlett.hq.kred> Message-ID: <8763i52rdb.fsf@dixie.cronqvi.st> Camille Troillard writes: > On Thu, Mar 19, 2009 at 4:31 PM, mats cronqvist wrote: > > ?I find it interesting that readability is regarded as something only > pointy-headed academics are interested in, and uninteresting in the > real world of commercial software. > > ?In my experience, code that is not "aesthetically pleasant" is > guaranteed to have this property; only its author can find the bugs. > > Alright, let's put it that way: > I'm not saying that one should be content with hard to read code. > > Remember the purpose of this thread is to discuss destructive assignments? > ?Erlang is born with pattern matching, and non destructive assignments. ?I > don't understand why it is a quality to pass around this very quality, that > makes the language better at the price of readability. You lost me here. I consider non destructive assignments a huge asset. > I've spent?myself?lots of time design macros and 'elegant' stuff to please my > eyes. ?In the end I eventually found that it was even more code to maintain > and understand. My code wasn't supposed to be elegant. It was upposed to put the focus on the essence of that function; that we're threading a dictionary (X) through a bunch of functions. > ?This is of course not a problem for a hobbyist, or perhaps even a > compiler writer. > > I'm sorry Mat, but this assertion is very closed minded. Not so well put, I guess. I just meant that the readability of the code becomes more important the more people are involved in the project. > But it is the mother of bad software products. > > I agree that easy to read code is better for maintainability. > But this thread has yet to prove that the very solutions being searched for > readability have actually a interest in maintainability. I'm not sure what you're getting at here. mats From masse@REDACTED Thu Mar 19 21:28:18 2009 From: masse@REDACTED (mats cronqvist) Date: Thu, 19 Mar 2009 21:28:18 +0100 Subject: [erlang-questions] Reassigning variables In-Reply-To: (James Hague's message of "Thu\, 19 Mar 2009 12\:18\:08 -0500") References: Message-ID: <871vst2r6l.fsf@dixie.cronqvi.st> James Hague writes: > I'm not surprised to see the storm that this has started. But after > having taken the deep dive into Erlang for decidedly non-traditional > FP applications (see http://prog21.dadgum.com), here's what I've > decided: > > For some types of programs, it takes significantly less effort to > write code if you can re-use names within the same function. This is of course true. But the discussion was about how easy it is to *read* such code. Or at least that's what I think should be about. mats From ok@REDACTED Thu Mar 19 22:37:27 2009 From: ok@REDACTED (Richard O'Keefe) Date: Fri, 20 Mar 2009 10:37:27 +1300 Subject: [erlang-questions] Re assigning variables In-Reply-To: <22597126.post@talk.nabble.com> References: <879778450903171338j5f47e27fm6b6016906dff0159@mail.gmail.com> <20090317214258.GQ32606@h216-235-12-174.host.egate.net> <22597126.post@talk.nabble.com> Message-ID: <5A460D52-59A2-4868-BC64-5E81C7671A20@cs.otago.ac.nz> On 19 Mar 2009, at 11:18 pm, Zvi wrote: > BTW: I think RoK's ?when macros will not work, b/c if only works > with guards > (also aren't when reserved word too?) (a) My ?when macro was only *intended* to work with guards. (b) Since every macro invocation begins with a question mark, and since macro names already ignore a major lexical distinction in Erlang (namely the difference between atoms and variable names) it had never occurred to me that keywords would be unusable as macro names. I regard this as a bug in the current implementation of the preprocessor. If macro invocations did *not* begin with '?', then it would be important to disallow the use of keywords as macros, but really, there's no good reason to forbid ?band as a macro just because band is reserved. That'd be rather like forbidding ribband as an atom because band is reserved. From tony@REDACTED Thu Mar 19 22:57:06 2009 From: tony@REDACTED (Tony Arcieri) Date: Thu, 19 Mar 2009 15:57:06 -0600 Subject: [erlang-questions] Reassigning variables In-Reply-To: References: Message-ID: On Thu, Mar 19, 2009 at 11:18 AM, James Hague wrote: > You can ALREADY simulate imperative updates using function calls (see > http://prog21.dadgum.com/5.html). Adding some syntactic sugar to make > this easiest is a good thing. You can also implement destructive assignments with a parse transform by adding version numbers to variables and incrementing the version number whenever they are used in match expressions, which is how Reia works. This approach is a bit trickier than it sounds as there are various scopes (e.g. lambdas, list comprehensions) where your transform needs to act differently than it would otherwise. Again, I would not recommend using this to add destructive updates to Erlang. In my totally unbiased opinion, if someone really has a hankering for doing destructive assignments I suggest you point them at Reia. -- Tony Arcieri medioh.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From ok@REDACTED Thu Mar 19 23:21:59 2009 From: ok@REDACTED (Richard O'Keefe) Date: Fri, 20 Mar 2009 11:21:59 +1300 Subject: [erlang-questions] Monads in Erlang? In-Reply-To: <6a3ae47e0903190940o798d06cbvd85ec2a60b52fb98@mail.gmail.com> References: <6a3ae47e0903190940o798d06cbvd85ec2a60b52fb98@mail.gmail.com> Message-ID: <67C57711-7030-4918-B789-29E77B326C15@cs.otago.ac.nz> On 20 Mar 2009, at 5:40 am, Robert Raschke wrote: > all this very interesting discussion about patterns and state carrying > from one expression to the next makes me think a lot of state monads. As has already been remarked. > I've never really delved into Haskell all too deeply (it's on my list > of things to learn much more of), but would some of the objections and > issues to do with numbered "state patterns" be addressed by something > similar to state monads? Perfectly. The idea of writing and using combinator libraries in Haskell is not to "simplify" the plumbing (as the suggestion to allow reassignment of local variables would have it) but to remove the plumbing *completely* from view. > I'm guessing that tuple patterns involving > atoms as signifiers for results make this tricky, No. From mononcqc@REDACTED Fri Mar 20 02:06:35 2009 From: mononcqc@REDACTED (Frederic T-H) Date: Thu, 19 Mar 2009 21:06:35 -0400 Subject: [erlang-questions] Python Generators In Erlang and constant memory usage Message-ID: <49C2EC1B.4040309@gmail.com> First time posting here, I've been reading this mailing lists for a few months now, programming Erlang for a few months too. Python and its most functionnal parts is what eventually brought me to Erlang. One feature that I loved in Python and instantly noticed was not available in Erlang was generators. Generators are basically normal functions, except they return an iterator, letting you fetch each result one by one, effectively letting you work with constant memory. An example of the way Python does it: def gen(n): i = 0 while i [1]; t_fib(2) -> [1,1]; t_fib(L) -> t_fib(3,L,[1,1]). t_fib(L,L,[N1,N2|_]=F) -> lists:reverse([N1+N2|F]); t_fib(C, L, [N1,N2|_]=F) -> t_fib(C+1,L,[N1+N2|F]). That's not the prettiest function in the world, but it still does the job. Here's how it would be as a generator (with the macros I have defined in the file): y_fib(L) -> y_fib(1, L, 1, 0). y_fib(L, L, N1 ,N2) -> ?last_yield(N1+N2); y_fib(C, L, N1, N2) -> N = N1+N2, ?yield(N), y_fib(C+1, L, N2, N). The code overhead one gets writing it that way is minimal and denies the need to use a list as an accumulator. The generator sum function is written the following way: sum({M,Gen,Args}) -> Pid = spawn(M, Gen, Args), sum(Pid,0). sum(Pid,S) -> Pid ! {self(), next}, receive {Pid, N} -> sum(Pid, S+N); {Pid, N, done} -> S+N end. Called with the custom sum function in the generators module (This could be made better, I agree): > generators:sum({generators,y_fib,[100]}). 927372692193078999175 Now for performance, I've tested it with Erlang R13A. My computer: AMD phenom 9950 quad-core 2.6ghz processor, 4gb RAM, Windows 7 Beta build 7000 (32 bits). batch_test/3 will compare both versions with a sequence/list of Fibonacci numbers of length 10000 and 50000, 20 times each, and round the results showing how much faster the generator is (1.0 is equal). 26> generators:batch_test(sum, 10000, 20). 0.9438942747654998 27> generators:batch_test(sum, 50000, 20). 2.406425935803285 28> generators:batch_test(fold, 10000, 20). 0.6706634763086374 29> generators:batch_test(fold, 50000, 20). 1.3918125332818239 This seems to show that using a generator scales much better, while becoming faster as the list grows and becomes expansive to generate and carry around. The real advantage, though, is the fact that using a function that won't accumulate lots of data (sum, folds, foreach, all, any, nth, etc.) will be done with constant memory. This is especially good for small systems or scaling as a whole. The testing I've done is minimal, and while I don't expect the Erlang community to jump on the idea and adopt it, I'm one of these people who'd like to eventually use this in production code. What kind of stuff would you see missing, or likely to cause trouble in the current implementation? What ways would I have to test this giving better results? Any other comments, tips? Thanks in advance! (Have a nice day also.) -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: generators.erl URL: From ok@REDACTED Fri Mar 20 04:33:00 2009 From: ok@REDACTED (Richard O'Keefe) Date: Fri, 20 Mar 2009 16:33:00 +1300 Subject: [erlang-questions] Reassigning variables In-Reply-To: References: Message-ID: <831AB6AE-FFC1-4633-9204-926EC52564DB@cs.otago.ac.nz> So far we have one concrete example where reassignment would be useful, plus several allegations that this is not unusual. > > Now remember, there's still NO need to add "for" loops and "while" > loops to Erlang. But re-using names within the same function? Yes > please, providing it can be done in a clean way; I realize it can > conflict with pattern matching if not done correctly. That's throwing roses at it. Let's recall the approaches on the table at the moment: (1) f(....., St0) -> {...,St1} = g(....,St0), {...,St2} = h(....,St1), {...,St3} = u(....,St2), {...,St3}. (2) f(....., St) -> {...,r(St)} = g(....,St), {...,r(St)} = h(....,St), {...,r(St)} = u(....,St), {...,St}. What this saves over (1) is the need for new names. Presumably someone who likes this doesn't _want_ to refer to any but the most recent state, so the loss of the opportunity to do so counts as a gain. But there is a heavy cost: if this is mixed with much other code and you want to see where "St" came from you cannot easily find "it", because "it" is really "them". It takes _more_ keyboard activity to type (2) than (1). StX...StY becomes St...r(St) for an extra character per update. It also hurts that something that looks like a function call isn't one. A different syntax, maybe "*St", could fix both of those issues. However, (2) and (1) both share the same fundamental problem, so that I have to regard (2) as not really being usefully different. The state threading is still explicit. And just as it is possible to mistakenly re-use a numbered version of a state variable, {...,St5} = p(...,St5), so it is possible to mistakenly omit the "reassign" marker {...,St} = p(...,St) when {...,r(St)} or {...,*St} or whatever syntax was meant. (3) -changer(core, [f/..,g/..,h/..,u/..]). f(....) -> ... = g(....), ... = h(....), ... = u(....), ... For each -changer(T) declaration a function is subject to, it gets an extra argument, and if there is at least one, the changer results are tupled with the original result. The threading is now the responsibility of the translator, not of the programmer. It is now *impossible* for the programmer to get the threading wrong. But there's another thought. The need for "state updates" scattered all through the compiler source code is caused at least as much by the decision to _have_ a separate "state" data structure as it is by limitations of the language. In Prolog, when you are building a data structure to represent some kind of intermediate language, you often put variables in it. So I might generate [push_local(X),push_integer(1),add,pop_local(X),...] where X represents an as-yet unchosen location. Then a later pass can come along and fill in the numbers. I can create a new representation of a run-time variable just by mentioning a new logical variable and leave the filling in until later. You can't do that in Erlang, but you *could* have an intermediate language that included some kind of 'let' construct. And given a tokeniser that tags each token with its source location, you can use source locations to make things unique. For example, if I were translating for (Init; Test; Step) { Body } to goto L L1 Body L2 Step Test [true->L1, false->L3] L3 so that continue->L2 and break->L3, I could do this by code something like L1 = {l,Pos}, L2 = {c,Pos}, L3 = {b,Pos}, {let_label,[L1,L2,L3], [{place,L1}, statement(Body, [{continue,L2},{break,L3}|Context]), {place,L2}, statement(Step, Context), test(Test, L1, L3), {place,L3} ]} And then a separate pass over this data structure would thread the appropriate state through. One thing about this that commends itself to me is that it doesn't rely on creating atoms, of which Erlang has a limited stock. It had never occurred to me that compiling an Erlang file might use up atoms that did not occur in the source code. From now on I shall be using erlc more and c(...) less. So (2) eliminated the *numbers* but left everything else there, (3) eliminated the *appearence* of the state but it still existed, while (4) is to eliminate the state *entirely* from the main functions by putting "variable-binding" operations in the data structure that's being built. From matthew@REDACTED Fri Mar 20 05:25:59 2009 From: matthew@REDACTED (Matthew Dempsky) Date: Thu, 19 Mar 2009 21:25:59 -0700 Subject: [erlang-questions] Reassigning variables In-Reply-To: <831AB6AE-FFC1-4633-9204-926EC52564DB@cs.otago.ac.nz> References: <831AB6AE-FFC1-4633-9204-926EC52564DB@cs.otago.ac.nz> Message-ID: On Thu, Mar 19, 2009 at 8:33 PM, Richard O'Keefe wrote: > So far we have one concrete example where reassignment would > be useful, plus several allegations that this is not unusual. In a previous email I listed several concrete examples of code from different OTP applications where I thought reassignment could be useful. > ? ? ?But there is a heavy cost: ?if this is mixed with > ? ? ?much other code and you want to see where "St" came > ? ? ?from you cannot easily find "it", because "it" is > ? ? ?really "them". In Emacs, if I want to see where a variable is bound, I do a reverse search for the variable name. Generally, I go back to the first place where it's used in a pattern. With reassignment, I just have to short-circuit this search when I find a pattern that reassigned it. It doesn't seem that much more difficult to me to cope with variable reassignment. > ? ? ?It takes _more_ keyboard activity to type (2) than (1). > ? ? ?StX...StY becomes St...r(St) for an extra character per update. Yes, but it still takes far less typing than most of the other convoluted ideas that have been suggested in this thread. (David Reid, inspired by the suggestions of BASIC-style numbering, humorously suggested another solution: instead of trying to maintain any notion of ordering in the numbers, just use a UUID for each variable instance. E.g., {Head,St_64D2F1A2_AE6B_425B_BD2F_A466350CF548} = new_var(St_50C531DB_E503_4ACC_83BB_A2CABF531399).) > ? ? ?It also hurts that something that looks like a function call > ? ? ?isn't one. ?A different syntax, maybe "*St", could fix both of > ? ? ?those issues. "+St" or "-St" would be possible right now using a parse transform since + and - are unary operators that are illegal within a pattern. (I can see a disadvantage to using these, however, that someone might first expect "-X = 3" to bind X to -3.) However, I don't feel like r() is an overly cumbersome syntax for this. I'm inclined to stay away from adding too many weird special operators, and I chose r() based on the shell's existing forget syntax f(). > ? ? ?However, (2) and (1) both share the same fundamental problem, > ? ? ?so that I have to regard (2) as not really being usefully > ? ? ?different. ?The state threading is still explicit. ?And just > ? ? ?as it is possible to mistakenly re-use a numbered version of > ? ? ?a state variable, {...,St5} = p(...,St5), so it is possible > ? ? ?to mistakenly omit the "reassign" marker {...,St} = p(...,St) > ? ? ?when {...,r(St)} or {...,*St} or whatever syntax was meant. I agree that being able to automatically thread St would be preferable over having to remember to reassign St, but in lieu of a *usable* way to do that, I still think variable reassignment is better than manually numbered variables. > (3) ?-changer(core, [f/..,g/..,h/..,u/..]). > > ? ? ?f(....) -> > ? ? ? ? ... = g(....), > ? ? ? ? ... = h(....), > ? ? ? ? ... = u(....), > ? ? ? ? ... > > ? ? For each -changer(T) declaration a function is subject to, > ? ? it gets an extra argument, and if there is at least one, > ? ? the changer results are tupled with the original result. > ? ? The threading is now the responsibility of the translator, > ? ? not of the programmer. ?It is now *impossible* for the > ? ? programmer to get the threading wrong. I can somewhat imagine how this would work, but if you're able to write a basic example and the equivalent Erlang code to compare with, it would help. > So (2) eliminated the *numbers* but left everything else there, > (3) eliminated the *appearence* of the state but it still existed, > while (4) is to eliminate the state *entirely* from the main > functions by putting "variable-binding" operations in the data > structure that's being built. I'm going to avoid commenting on (4) for now. (2) was satisfactorily achievable using a parse transform written in about half an hour. I can appreciate that (3) might be an improvement, and it still feels feasible with a parse transform of reasonable complexity. However, (4) feels far more intrusive and beyond the scope of just solving a (minor) annoyance that has been bugging me for a while, and I don't have the time to really consider it right now. From ulf.wiger@REDACTED Fri Mar 20 08:56:53 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Fri, 20 Mar 2009 08:56:53 +0100 Subject: [erlang-questions] Python Generators In Erlang and constant memory usage In-Reply-To: <49C2EC1B.4040309@gmail.com> References: <49C2EC1B.4040309@gmail.com> Message-ID: <49C34C45.1050108@erlang-consulting.com> Frederic T-H wrote: > First time posting here, I've been reading this mailing lists for a few > months now, programming Erlang for a few months too. > > Python and its most functionnal parts is what eventually brought me to > Erlang. One feature that I loved in Python and instantly noticed was not > available in Erlang was generators. Generators are basically normal > functions, except they return an iterator, letting you fetch each result > one by one, effectively letting you work with constant memory. An > example of the way Python does it: > > def gen(n): > i = 0 > while i yield i > i+=1 > return > > x = gen(2) > x.next() # returns 0 > x.next() # returns 1 > x.next() # throws an exception This feels a bit reminiscent of lazy lists, which were discussed at some length on the erlang list quite recently (the year 2000, in fact): http://erlang.org/pipermail/erlang-questions/2000-October/001875.html BR, Ulf W -- Ulf Wiger CTO, Erlang Training & Consulting Ltd http://www.erlang-consulting.com From magnus@REDACTED Fri Mar 20 11:03:44 2009 From: magnus@REDACTED (Magnus Henoch) Date: Fri, 20 Mar 2009 10:03:44 +0000 Subject: [erlang-questions] queue() vs queue(A) Message-ID: <84wsakik8v.fsf@linux-b2a3.site> Hi, I read queue.erl in R13A and saw the new type definition: -opaque queue() :: {list(),list()}. Is there any reason why this is not: -opaque queue(A) :: {list(A),list(A)}. or did my thoughts just wander too far into That Other Language again? :) -- Magnus Henoch, magnus@REDACTED Erlang Training and Consulting http://www.erlang-consulting.com/ From btolputt@REDACTED Fri Mar 20 09:16:23 2009 From: btolputt@REDACTED (Benjamin Tolputt) Date: Fri, 20 Mar 2009 19:16:23 +1100 Subject: [erlang-questions] Python Generators In Erlang and constant memory usage In-Reply-To: <49C34C45.1050108@erlang-consulting.com> References: <49C2EC1B.4040309@gmail.com> <49C34C45.1050108@erlang-consulting.com> Message-ID: <49C350D7.106@bigpond.net.au> Ulf Wiger wrote: > This feels a bit reminiscent of lazy lists, which were > discussed at some length on the erlang list quite > recently (the year 2000, in fact): > > http://erlang.org/pipermail/erlang-questions/2000-October/001875.html Quite "recently"? I have four children and not a one of them was born then! *laugh* Thanks for the link though. Shows how little of Erlang's history I've seen! -- Regards, Benjamin Tolputt Analyst Programmer From masklinn@REDACTED Fri Mar 20 11:19:43 2009 From: masklinn@REDACTED (Masklinn) Date: Fri, 20 Mar 2009 11:19:43 +0100 Subject: [erlang-questions] Python Generators In Erlang and constant memory usage In-Reply-To: <49C34C45.1050108@erlang-consulting.com> References: <49C2EC1B.4040309@gmail.com> <49C34C45.1050108@erlang-consulting.com> Message-ID: On 20 Mar 2009, at 08:56 , Ulf Wiger wrote: > Frederic T-H wrote: > This feels a bit reminiscent of lazy lists, which were > discussed at some length on the erlang list quite > recently (the year 2000, in fact): > > http://erlang.org/pipermail/erlang-questions/2000-October/001875.html > > BR, > Ulf W > -- That's pretty much what they are yes, see the initial generator PEP [http://www.python.org/dev/peps/pep-0255/ ] and the generator comprehensions/expressions PEP [http://www.python.org/dev/peps/pep-0289/ ] (a lazy list comprehension) for more infos. From launoja@REDACTED Fri Mar 20 09:21:31 2009 From: launoja@REDACTED (Jani Launonen) Date: Fri, 20 Mar 2009 10:21:31 +0200 Subject: [erlang-questions] Python Generators In Erlang and constant memory usage In-Reply-To: <49C2EC1B.4040309@gmail.com> References: <49C2EC1B.4040309@gmail.com> Message-ID: I admit not read throughfully your post, but I think you're looking for continuations. I've done continuous based fibonacci iterator in Python and Erlang so it should be working solution. But your generator in continuations: -module(continuation). -export([gen/1]). gen(N) -> {0, fun() -> gen_cont(0, N) end}. gen_cont(I, N) -> case I < N of true -> {I + 1, fun() -> gen_cont(I + 1, N) end}; false -> ok end. How it works... 7> {_, Fun1} = continuation:gen(3). {0,#Fun} 8> {_, Fun2} = Fun1(). {1,#Fun} 9> {_, Fun3} = Fun2(). {2,#Fun} 10> {_, Fun4} = Fun3(). {3,#Fun} 11> {_, Fun5} = Fun4(). ----- Alkuper?inen viesti ----- L?hett?j?: Frederic T-H P?iv?ys: perjantai, maaliskuu 20, 2009 3:28 am Aihe: [erlang-questions] Python Generators In Erlang and constant memory usage Vastaanottaja: erlang-questions@REDACTED > First time posting here, I've been reading this mailing lists > for a few > months now, programming Erlang for a few months too. > > Python and its most functionnal parts is what eventually brought > me to > Erlang. One feature that I loved in Python and instantly noticed > was not > available in Erlang was generators. Generators are basically > normal > functions, except they return an iterator, letting you fetch > each result > one by one, effectively letting you work with constant memory. > An > example of the way Python does it: > > ??? def gen(n): > ??????? i = 0 > ??????? while i ??????????? yield i > ??????????? i+=1 > ??????? return > > ??? x = gen(2) > ??? x.next() # returns 0 > ??? x.next() # returns 1 > ??? x.next()? # throws an exception > > In python, using yield creates a 'next' method, which is > automatically > called by most functions that can iterate over text, lists, > tuples, > dictionaries, etc. > > The idea is to not load all the results from a function at once > and pass > it around, but to send each part individually. > > As an example, say I have a result set consisting of 1000x5kb > tuples > (whatever they contain) which I want to map a function over. The > way > Erlang works, you'd need to have a list that is 5000kb in size > in memory > and manipulate it every single time the mapped function iterates > over it. > > The end goal is to attempt to bypass having to evaluate the > whole result > set at once (heavy) and instead get each element individually > (lighter). > This is especially good for smaller systems like phones, web > tablets > (Nokia) or really anything with limited amounts of RAM. > > While possible to implement in Erlang, generators are quite > problematic > because every list BIF at the moment only operates on complete > lists. > This means adding generators in Erlang would require one to do > something > like duplicate the lists module. > > This may not be the first time this whole idea is discussed, but > fast > googling didn't reveal much so I've let myself write a small > naive and > simple prototype of what the implementation could be. > > The idea is quite simple: Have a recursive function as a > different > spawned process waiting to receive {Pid, next} before returning > data. > I've attached the file demonstrating the implementation, but in > case I > got it wrong, I also copy/pasted it there: > http://pastebin.com/f31ae9731 > What the implementation does: > > ??? - define tail-recursive fibonacci functions, > a normal one and a > ??? generator version > ??? - define mockups for the sum and fold (foldl) > functions from the > ??? list module adapted to generators > ??? - short unscientific tests to compare performances. > > What it doesn't do: > > ??? - consider any kind of safety in case there > is an error in a generator > ??? - contain anything past what you'd do for a > proof of concept. > > > The way it works, a normal tail-recursive way to get all the > fibonacci > numbers until the nth one could be done the following way: > > ??? t_fib(1) -> [1]; > ??? t_fib(2) -> [1,1]; > ??? t_fib(L) -> t_fib(3,L,[1,1]). > > ??? t_fib(L,L,[N1,N2|_]=F) -> > ??????? lists:reverse([N1+N2|F]); > ??? t_fib(C, L, [N1,N2|_]=F) -> > ??????? t_fib(C+1,L,[N1+N2|F]). > > That's not the prettiest function in the world, but it still > does the > job. Here's how it would be as a generator (with the macros I > have > defined in the file): > > ??? y_fib(L) -> > ??????? y_fib(1, L, 1, 0). > ??? y_fib(L, L, N1 ,N2) -> > ??????? ?last_yield(N1+N2); > ??? y_fib(C, L, N1, N2) -> > ??????? N = N1+N2, > ??????? ?yield(N), > ??????? y_fib(C+1, L, N2, N). > > The code overhead one gets writing it that way is minimal and > denies the > need to use a list as an accumulator. > > The generator sum function is written the following way: > > ??? sum({M,Gen,Args}) -> > ??????? Pid = spawn(M, Gen, Args), > ??????? sum(Pid,0). > ??? sum(Pid,S) -> > ??????? Pid ! {self(), next}, > ??????? receive > ??????????? {Pid, N} -> sum(Pid, S+N); > ??????????? {Pid, N, done} -> S+N > ??????? end. > > Called with the custom sum function in the generators module > (This could > be made better, I agree): > > ???? > > generators:sum({generators,y_fib,[100]}).? > ??? 927372692193078999175 > > Now for performance, I've tested it? with Erlang R13A. My > computer:??? AMD phenom 9950 quad-core 2.6ghz > processor, 4gb RAM, Windows 7 Beta > build 7000 (32 bits). > batch_test/3 will compare both versions with a sequence/list of > Fibonacci numbers of length 10000 and 50000, 20 times each, and > round > the results showing how much faster the generator is (1.0 is equal). > > ??? 26> generators:batch_test(sum, 10000, 20). > ??? 0.9438942747654998 > ??? 27> generators:batch_test(sum, 50000, 20). > ??? 2.406425935803285 > ??? 28> generators:batch_test(fold, 10000, 20). > ??? 0.6706634763086374 > ??? 29> generators:batch_test(fold, 50000, 20). > ??? 1.3918125332818239 > > This seems to show that using a generator scales much better, > while > becoming faster as the list grows and becomes expansive to > generate and > carry around. > > The real advantage, though, is the fact that using a function > that won't > accumulate lots of data (sum, folds, foreach, all, any, nth, > etc.) will > be done with constant memory. This is especially good for small > systems > or scaling as a whole. > > The testing I've done is minimal, and while I don't expect the > Erlang > community to jump on the idea and adopt it, I'm one of these > people > who'd like to eventually use this in production code. What kind > of stuff > would you see missing, or likely to cause trouble in the current > implementation? > What ways would I have to test this giving better results? > > Any other comments, tips? Thanks in advance! (Have a nice day also.) > From buricchio@REDACTED Fri Mar 20 13:02:06 2009 From: buricchio@REDACTED (Andrey) Date: Fri, 20 Mar 2009 14:02:06 +0200 Subject: [erlang-questions] Released: ABNF parser generator In-Reply-To: References: Message-ID: <49C385BE.9080800@gmail.com> Helllo All. Has anyone managed to run parser generated by abnfc? For example, there is generated uri parrser with module name "rfc3986". How to parse something with that rfc3986 vodule? Andrew > Hi > Finally I have managed to release the ABNF Parser Generator for Erlang. > It can be found on http://github.com/nygge/abnfc/tree/master > > An almost correct description can be found in the EUC presentation > http://www.erlang.se/euc/08/1500Nygren2.pdf > > /Anders > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From r.b.lists@REDACTED Fri Mar 20 13:11:50 2009 From: r.b.lists@REDACTED (Roland Braito) Date: Fri, 20 Mar 2009 13:11:50 +0100 Subject: [erlang-questions] relative path? in inets httpd.conf Message-ID: <20090320121150.64780@gmx.net> Hello All, sorry if this is a FAQ, but i didn't find it anywhere... is there a way to specify a path relative to the erlang/lib directory in the inets httpd.conf file? I'm trying to make a config file which can be relocated, specifically through building a new target system for a webserver based app, which i can give to my client so they can run it with minimal fuss... Thanks, Roland -- Aufgepasst: Sind Ihre Daten beim Online-Banking auch optimal gesch?tzt? Jetzt absichern: https://homebanking.gmx.net/?mc=mail@REDACTED From masse@REDACTED Fri Mar 20 13:44:58 2009 From: masse@REDACTED (mats cronqvist) Date: Fri, 20 Mar 2009 13:44:58 +0100 Subject: [erlang-questions] Python Generators In Erlang and constant memory usage In-Reply-To: <49C350D7.106@bigpond.net.au> (Benjamin Tolputt's message of "Fri\, 20 Mar 2009 19\:16\:23 +1100") References: <49C2EC1B.4040309@gmail.com> <49C34C45.1050108@erlang-consulting.com> <49C350D7.106@bigpond.net.au> Message-ID: <87k56kgy7p.fsf@sterlett.hq.kred> Benjamin Tolputt writes: > Ulf Wiger wrote: >> This feels a bit reminiscent of lazy lists, which were >> discussed at some length on the erlang list quite >> recently (the year 2000, in fact): >> >> http://erlang.org/pipermail/erlang-questions/2000-October/001875.html > > Quite "recently"? I have four children and not a one of them was born > then! *laugh* You have to realize that Ulf is well over 400 years old. mats From mononcqc@REDACTED Fri Mar 20 13:55:09 2009 From: mononcqc@REDACTED (Fred Hebert (MononcQc)) Date: Fri, 20 Mar 2009 08:55:09 -0400 Subject: [erlang-questions] Python Generators In Erlang and constant memory usage In-Reply-To: <49C34C45.1050108@erlang-consulting.com> References: <49C2EC1B.4040309@gmail.com> <49C34C45.1050108@erlang-consulting.com> Message-ID: <8b9ee55b0903200555u627a2ae7jc132b2a26cf47c9f@mail.gmail.com> Yes, the lazy list implementation discussed there (and suggested by Jani Launonen in this very thread) seem to be the best way to do it. Much better than my way, given it would be subject to all kinds of weird behaviors when hanging, being called by two functions, etc. No idea why I hadn't thought of returning other functions, that's clearly the right (safe) way. I've read the old discussion, and nothing really struck me as to why lazy lists never were implemented (or even the lazy list comprehensions). Of course there were a few valid objections formulated, but it looks like the discussion was forgotten as it evolved on to other subjects. Without replacing the lists module, a lazylists (or streams, to follow what was told back in 2000) module right next to it wouldn't do much harm. While you don't gain a flawless integration of both concepts in the language, the separate module leaves a standard way to do it if one ever comes to need it. Was there any specific reason as to why it wasn't developed? On Fri, Mar 20, 2009 at 3:56 AM, Ulf Wiger wrote: > Frederic T-H wrote: > >> First time posting here, I've been reading this mailing lists for a few >> months now, programming Erlang for a few months too. >> >> Python and its most functionnal parts is what eventually brought me to >> Erlang. One feature that I loved in Python and instantly noticed was not >> available in Erlang was generators. Generators are basically normal >> functions, except they return an iterator, letting you fetch each result one >> by one, effectively letting you work with constant memory. An example of the >> way Python does it: >> >> def gen(n): >> i = 0 >> while i> yield i >> i+=1 >> return >> >> x = gen(2) >> x.next() # returns 0 >> x.next() # returns 1 >> x.next() # throws an exception >> > > This feels a bit reminiscent of lazy lists, which were > discussed at some length on the erlang list quite > recently (the year 2000, in fact): > > http://erlang.org/pipermail/erlang-questions/2000-October/001875.html > > BR, > Ulf W > -- > Ulf Wiger > CTO, Erlang Training & Consulting Ltd > http://www.erlang-consulting.com > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ryeguy1@REDACTED Fri Mar 20 14:20:03 2009 From: ryeguy1@REDACTED (ryeguy) Date: Fri, 20 Mar 2009 06:20:03 -0700 (PDT) Subject: [erlang-questions] How do I elegantly check many conditions? Message-ID: <769240e8-b6ed-4f41-bfd0-a970f483a083@h5g2000yqh.googlegroups.com> So when a user sends a request to register an account, they send their username, password, email, and other info. The registration function must verify all of their data. An example would be: - verify email not in use - verify username not in use - verify username is alphanumeric - verify all fields are above X characters long - verify all fields are less than Y characters long Now I don't want to have a 5 level deep if or case statement, but what other options do I have? Splitting it into separate functions sounds like a good idea, but then I just have to check the return value of the functions in some sort of conditional and it's back to the original problem. I could separate them into functions and then call an if statement with all of the conditionals OR'd together, but that wouldn't give me what I want because I need to be able to tell the user the specific error if there was one. How does one handle this kind of situation in erlang? From bgustavsson@REDACTED Fri Mar 20 14:25:05 2009 From: bgustavsson@REDACTED (Bjorn Gustavsson) Date: Fri, 20 Mar 2009 14:25:05 +0100 Subject: [erlang-questions] [erlang-patches] [PATCH] 64-bit solaris builds In-Reply-To: <49ABFCDA.8030303@alertlogic.net> References: <48B72DC8.4030507@alertlogic.net> <6672d0160810170249i1e331d1u2c8cd40db3d17297@mail.gmail.com> <49A5E200.9050008@alertlogic.net> <6672d0160903020716rccf1b75m917a2e4005291f3a@mail.gmail.com> <49ABFCDA.8030303@alertlogic.net> Message-ID: <6672d0160903200625j38065167p46d65b9ad4ddc855@mail.gmail.com> On Mon, Mar 2, 2009 at 4:35 PM, Paul Fisher wrote: > Thank you very much! 13B is just great, as I am just checking out 13A for > features and to see if the issue reported previously are likely to get into > 13B. > We still want to properly propagate CFLAGS in some future release, but in the meantime we have added a configure option --enable-m64-build to enable 64-bits builds in R13A. Please try it out. If there are any problems with the option, we'll try to correct them in R13B. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From gordon@REDACTED Fri Mar 20 14:30:12 2009 From: gordon@REDACTED (Gordon Guthrie) Date: Fri, 20 Mar 2009 13:30:12 +0000 Subject: [erlang-questions] How do I elegantly check many conditions? In-Reply-To: <769240e8-b6ed-4f41-bfd0-a970f483a083@h5g2000yqh.googlegroups.com> References: <769240e8-b6ed-4f41-bfd0-a970f483a083@h5g2000yqh.googlegroups.com> Message-ID: Ryegug How about a single conditional on a tuple? check(Email, Username, Password) -> InUseE = check_in_use_email(Email), AlphaNum = check_is_alphanumeric(Username), InUseU = check_in_use_username(Username), StrongEnough = check_password(password), case {InUseE, AlphaNum, InUseU, StrongEnough} of {true, true, true, true} -> true; _ -> false end. On Fri, Mar 20, 2009 at 1:20 PM, ryeguy wrote: > So when a user sends a request to register an account, they send their > username, password, email, and other info. The registration function > must verify all of their data. An example would be: > > - verify email not in use > - verify username not in use > - verify username is alphanumeric > - verify all fields are above X characters long > - verify all fields are less than Y characters long > > Now I don't want to have a 5 level deep if or case statement, but what > other options do I have? Splitting it into separate functions sounds > like a good idea, but then I just have to check the return value of > the functions in some sort of conditional and it's back to the > original problem. > > I could separate them into functions and then call an if statement > with all of the conditionals OR'd together, but that wouldn't give me > what I want because I need to be able to tell the user the specific > error if there was one. > > How does one handle this kind of situation in erlang? > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From gordon@REDACTED Fri Mar 20 14:31:34 2009 From: gordon@REDACTED (Gordon Guthrie) Date: Fri, 20 Mar 2009 13:31:34 +0000 Subject: [erlang-questions] How do I elegantly check many conditions? In-Reply-To: References: <769240e8-b6ed-4f41-bfd0-a970f483a083@h5g2000yqh.googlegroups.com> Message-ID: Sorry, pressed send too soon by mistake - this doesn't answer your question... On Fri, Mar 20, 2009 at 1:30 PM, Gordon Guthrie wrote: > Ryegug > How about a single conditional on a tuple? > > check(Email, Username, Password) -> > InUseE = check_in_use_email(Email), > AlphaNum = check_is_alphanumeric(Username), > InUseU = check_in_use_username(Username), > StrongEnough = check_password(password), > > case {InUseE, AlphaNum, InUseU, StrongEnough} of > {true, true, true, true} -> true; > _ -> false > end. > > > On Fri, Mar 20, 2009 at 1:20 PM, ryeguy wrote: > >> So when a user sends a request to register an account, they send their >> username, password, email, and other info. The registration function >> must verify all of their data. An example would be: >> >> - verify email not in use >> - verify username not in use >> - verify username is alphanumeric >> - verify all fields are above X characters long >> - verify all fields are less than Y characters long >> >> Now I don't want to have a 5 level deep if or case statement, but what >> other options do I have? Splitting it into separate functions sounds >> like a good idea, but then I just have to check the return value of >> the functions in some sort of conditional and it's back to the >> original problem. >> >> I could separate them into functions and then call an if statement >> with all of the conditionals OR'd together, but that wouldn't give me >> what I want because I need to be able to tell the user the specific >> error if there was one. >> >> How does one handle this kind of situation in erlang? >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From gordon@REDACTED Fri Mar 20 14:40:04 2009 From: gordon@REDACTED (Gordon Guthrie) Date: Fri, 20 Mar 2009 13:40:04 +0000 Subject: [erlang-questions] How do I elegantly check many conditions? In-Reply-To: References: <769240e8-b6ed-4f41-bfd0-a970f483a083@h5g2000yqh.googlegroups.com> Message-ID: Once more with feeling :( check(UName, Email, Pwd) -> Fun = f({_, _, X}) -> X end, List = [{email, in_use, is_in_use_e(Email}, {UName, not_valid, not_valid(UName)}, {UName, in_use, is_in_use_u(UName)}, {Pwd, not_suitable, is_not_strong(Pwd)}], lists:filter(Fun, List). Gordon On Fri, Mar 20, 2009 at 1:31 PM, Gordon Guthrie wrote: > Sorry, pressed send too soon by mistake - this doesn't answer your > question... > > > On Fri, Mar 20, 2009 at 1:30 PM, Gordon Guthrie wrote: > >> Ryegug >> How about a single conditional on a tuple? >> >> check(Email, Username, Password) -> >> InUseE = check_in_use_email(Email), >> AlphaNum = check_is_alphanumeric(Username), >> InUseU = check_in_use_username(Username), >> StrongEnough = check_password(password), >> >> case {InUseE, AlphaNum, InUseU, StrongEnough} of >> {true, true, true, true} -> true; >> _ -> false >> end. >> >> >> On Fri, Mar 20, 2009 at 1:20 PM, ryeguy wrote: >> >>> So when a user sends a request to register an account, they send their >>> username, password, email, and other info. The registration function >>> must verify all of their data. An example would be: >>> >>> - verify email not in use >>> - verify username not in use >>> - verify username is alphanumeric >>> - verify all fields are above X characters long >>> - verify all fields are less than Y characters long >>> >>> Now I don't want to have a 5 level deep if or case statement, but what >>> other options do I have? Splitting it into separate functions sounds >>> like a good idea, but then I just have to check the return value of >>> the functions in some sort of conditional and it's back to the >>> original problem. >>> >>> I could separate them into functions and then call an if statement >>> with all of the conditionals OR'd together, but that wouldn't give me >>> what I want because I need to be able to tell the user the specific >>> error if there was one. >>> >>> How does one handle this kind of situation in erlang? >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://www.erlang.org/mailman/listinfo/erlang-questions >>> >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From nick@REDACTED Fri Mar 20 15:13:34 2009 From: nick@REDACTED (Nick Gerakines) Date: Fri, 20 Mar 2009 07:13:34 -0700 Subject: [erlang-questions] How do I elegantly check many conditions? In-Reply-To: <769240e8-b6ed-4f41-bfd0-a970f483a083@h5g2000yqh.googlegroups.com> References: <769240e8-b6ed-4f41-bfd0-a970f483a083@h5g2000yqh.googlegroups.com> Message-ID: In the past, I've done things like this: [untested pseudo-code] ... create_user(Name, Email, ...) -> case validate_user({Name, Email, ...}, [user_name, user_email, user_password, ...]) of true -> do_it(); {error, X} -> expose_error(); _ -> oh_no() end. validate_data(UserDetails, []) -> true; validate_data(UserDetails, [user_name | Rules]) -> case fcall_to_assert_name_is_ok(UserDetails) of true -> validate_data(UserDetails, Rules); _ -> {error, name_taken} end; validate_data(...) -> ... It's clean and gives you a quick way to determine which rules to use for a given data validation block. # Nick Gerakines On Fri, Mar 20, 2009 at 6:20 AM, ryeguy wrote: > So when a user sends a request to register an account, they send their > username, password, email, and other info. The registration function > must verify all of their data. An example would be: > > ?- verify email not in use > ?- verify username not in use > ?- verify username is alphanumeric > ?- verify all fields are above X characters long > ?- verify all fields are less than Y characters long > > Now I don't want to have a 5 level deep if or case statement, but what > other options do I have? Splitting it into separate functions sounds > like a good idea, but then I just have to check the return value of > the functions in some sort of conditional and it's back to the > original problem. > > I could separate them into functions and then call an if statement > with all of the conditionals OR'd together, but that wouldn't give me > what I want because I need to be able to tell the user the specific > error if there was one. > > How does one handle this kind of situation in erlang? > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From vychodil.hynek@REDACTED Fri Mar 20 15:17:22 2009 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Fri, 20 Mar 2009 15:17:22 +0100 Subject: [erlang-questions] How do I elegantly check many conditions? In-Reply-To: <769240e8-b6ed-4f41-bfd0-a970f483a083@h5g2000yqh.googlegroups.com> References: <769240e8-b6ed-4f41-bfd0-a970f483a083@h5g2000yqh.googlegroups.com> Message-ID: <4d08db370903200717o3a925df7k67e5ebb54c479aeb@mail.gmail.com> One of Joe's suggestion: program success case code separated from error handling. You can make it in this way create_user(Email, UserName, Password) -> try ok = new_email(Email), ok = valid_user_name(UserName), ok = new_user(UserName), ok = strong_password(Password), ... _create_user(Email, UserName, Password) catch error:{badmatch, email_in_use} -> do_something(); error:{badmatch, invalid_user_name} -> do_something(); error:{badmatch, user_exists} -> do_something(); error:{badmatch, weak_password} -> do_something(); ... end. note that you can do all errors catches out of create_user function which is better. create_user(Email, UserName, Password) -> ok = new_email(Email), ok = valid_user_name(UserName), ok = new_user(UserName), ok = strong_password(Password), ... _create_user(Email, UserName, Password). main() -> try ... some_function_where_create_user_is_called(), ... catch ... error:{badmatch, email_in_use} -> do_something(); error:{badmatch, invalid_user_name} -> do_something(); error:{badmatch, user_exists} -> do_something(); error:{badmatch, weak_password} -> do_something(); ... end. On Fri, Mar 20, 2009 at 2:20 PM, ryeguy wrote: > So when a user sends a request to register an account, they send their > username, password, email, and other info. The registration function > must verify all of their data. An example would be: > > - verify email not in use > - verify username not in use > - verify username is alphanumeric > - verify all fields are above X characters long > - verify all fields are less than Y characters long > > Now I don't want to have a 5 level deep if or case statement, but what > other options do I have? Splitting it into separate functions sounds > like a good idea, but then I just have to check the return value of > the functions in some sort of conditional and it's back to the > original problem. > > I could separate them into functions and then call an if statement > with all of the conditionals OR'd together, but that wouldn't give me > what I want because I need to be able to tell the user the specific > error if there was one. > > How does one handle this kind of situation in erlang? > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- --Hynek (Pichi) Vychodil Analyze your data in minutes. Share your insights instantly. Thrill your boss. Be a data hero! Try Good Data now for free: www.gooddata.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From taavi@REDACTED Fri Mar 20 15:18:55 2009 From: taavi@REDACTED (Taavi Talvik) Date: Fri, 20 Mar 2009 16:18:55 +0200 Subject: [erlang-questions] How do I elegantly check many conditions? In-Reply-To: <769240e8-b6ed-4f41-bfd0-a970f483a083@h5g2000yqh.googlegroups.com> References: <769240e8-b6ed-4f41-bfd0-a970f483a083@h5g2000yqh.googlegroups.com> Message-ID: On Mar 20, 2009, at 3:20 PM, ryeguy wrote: > So when a user sends a request to register an account, they send their > username, password, email, and other info. The registration function > must verify all of their data. An example would be: > > - verify email not in use > - verify username not in use > - verify username is alphanumeric > - verify all fields are above X characters long > - verify all fields are less than Y characters long > > Now I don't want to have a 5 level deep if or case statement, but what > other options do I have? Splitting it into separate functions sounds > like a good idea, but then I just have to check the return value of > the functions in some sort of conditional and it's back to the > original problem. > > I could separate them into functions and then call an if statement > with all of the conditionals OR'd together, but that wouldn't give me > what I want because I need to be able to tell the user the specific > error if there was one. > > How does one handle this kind of situation in erlang? Something lake following:? check_everything(..) -> try ok = do_tests(Data, [fun email_not_in_use/1, fun username_not_in_use/1, ..]) catch throw:{bad_user, ErrorString} -> show_error_to_user(...) end. do_tests(Data, []) -> ok; do_tests(Data, [F|T]) -> ok = F(Data), do_tests(Data, T). % and tests here... email_not_in_use({Username, _,_,_.....}) -> case ... of in_use -> throw({bad_user, "Username allready in use"}); _ -> ok end. best regards, taavi From anders@REDACTED Fri Mar 20 14:57:54 2009 From: anders@REDACTED (Anders Dahlin) Date: Fri, 20 Mar 2009 14:57:54 +0100 Subject: [erlang-questions] How do I elegantly check many conditions? In-Reply-To: <769240e8-b6ed-4f41-bfd0-a970f483a083@h5g2000yqh.googlegroups.com> References: <769240e8-b6ed-4f41-bfd0-a970f483a083@h5g2000yqh.googlegroups.com> Message-ID: <49C3A0E2.8010309@dahlinenergy.se> ryeguy wrote: > So when a user sends a request to register an account, they send their > username, password, email, and other info. The registration function > must verify all of their data. An example would be: > > - verify email not in use > - verify username not in use > - verify username is alphanumeric > - verify all fields are above X characters long > - verify all fields are less than Y characters long > > Now I don't want to have a 5 level deep if or case statement, but what > other options do I have? Splitting it into separate functions sounds > like a good idea, but then I just have to check the return value of > the functions in some sort of conditional and it's back to the > original problem. > > I could separate them into functions and then call an if statement > with all of the conditionals OR'd together, but that wouldn't give me > what I want because I need to be able to tell the user the specific > error if there was one. > > How does one handle this kind of situation in erlang? Two alternatives that I've used. Both make it easy to extend the checks without having to change a thing at the top level. I've also used versions that updates the data at the same time and with more levels than valid, invalid. Depending on the problem you may also want to continue doing all checks and collecting the invalid stuff as you find it so that everything that's not valid are returned at once. /A handle_input(Data) -> case validate(Data) of valid -> foo(); {invalid, Reason} -> bar() end. Alt1: Looping over funs validate(InData) -> Validators = [fun validate_email/1, fun validate_username/1], validate(Validators, InData). validate([Validator| Validators], Data) -> case Validator(Data) of valid -> validate(Validators, Data); {invalid, Reason} -> {invalid, Reason} end; validate([], _) -> valid. validate_email(Data) -> valid. validate_username(Data) -> valid. Alt2: Looping over tags, used as first arg to validator/2 validate(Data) -> WhatToValidate = [email, username], validate(WhatToValidate, InData). validate([Thing| Rest], Data) -> case validator(Thing, Data) of valid -> validate(Rest, Data); {invalid, Reason} -> {invalid, Reason} end; validate([], _) -> valid. validator(email, Data) -> valid; validator(username, Data) -> valid. From freza@REDACTED Fri Mar 20 15:30:32 2009 From: freza@REDACTED (Jachym Holecek) Date: Fri, 20 Mar 2009 15:30:32 +0100 Subject: [erlang-questions] How do I elegantly check many conditions? In-Reply-To: <769240e8-b6ed-4f41-bfd0-a970f483a083@h5g2000yqh.googlegroups.com> References: <769240e8-b6ed-4f41-bfd0-a970f483a083@h5g2000yqh.googlegroups.com> Message-ID: <20090320143032.GA3327@hanele> Hello, # ryeguy 2009-03-20: > So when a user sends a request to register an account, they send their > username, password, email, and other info. The registration function > must verify all of their data. An example would be: BTW observe that your tests are of two different kinds: > - verify username is alphanumeric > - verify all fields are above X characters long > - verify all fields are less than Y characters long These check the shape of incoming data, that is they decide if the incoming request makes any sense at all. > - verify email not in use > - verify username not in use These have a valid request at hand and decide if the system is able to fulfill it given current state of the world. It seems like a good idea to keep the two separate in some way. It might also make some amount of sense to merge the second kind of check with the actual registration procedure. > Now I don't want to have a 5 level deep if or case statement, but what > other options do I have? Splitting it into separate functions sounds > like a good idea, but then I just have to check the return value of > the functions in some sort of conditional and it's back to the > original problem. I can't see the problem of using nested 'case' expressions, as long as the resulting code is clear and simple. > I could separate them into functions and then call an if statement > with all of the conditionals OR'd together, but that wouldn't give me > what I want because I need to be able to tell the user the specific > error if there was one. > > How does one handle this kind of situation in erlang? I'd probably go with something like the below. But in general, I find writing partial solutions an extremely confusing task. So, depending on how the rest of your code works, I might actually go with something completely different. ;-) HTH, -- Jachym %% Handle user registration request. request(Username, Password, Email) -> case lists:all(fun in_bounds/1, [Username, Password, Email]) of true -> case is_alpha(Username) of true -> add_user(Username, Password, Email); false -> error end; false -> error end. %% Add new user unless his details conflict with existing user. Return 'ok' on success, 'error' on collision. add_user(Username, Password, Email) -> %% XXX If you store users in Mnesia, you'd probably want to write %% XXX a check-and-insert function and run that as transaction %% XXX instead. It would return a boolean indicating success. If %% XXX you're not using Mnesia, you need to deal with the obvious %% XXX race condition lurking here yourself :-). case is_available(Username, Email) of true -> whatever_it_takes_to_add_user(Username, Password, Email), ok; false -> error end. %% Decide if string has acceptable length. in_bounds(String) when length(String) > 3, length(String) < 10 -> true; in_bounds(_) -> false. %% Decide if string is composed of alphanumeric characters. is_alpha([Char | Rest]) when Char >= $a, Char =< $z -> is_alpha(Rest); is_alpha([Char | Rest]) when Char >= $A, Char =< $Z -> is_alpha(Rest); is_alpha([Char | Rest]) when Char >= $0, Char =< $9 -> is_alpha(Rest); is_alpha([]) -> true; is_alpha(_) -> false. From cthulahoops@REDACTED Fri Mar 20 15:33:33 2009 From: cthulahoops@REDACTED (Adam Kelly) Date: Fri, 20 Mar 2009 14:33:33 +0000 Subject: [erlang-questions] How do I elegantly check many conditions? In-Reply-To: <769240e8-b6ed-4f41-bfd0-a970f483a083@h5g2000yqh.googlegroups.com> References: <769240e8-b6ed-4f41-bfd0-a970f483a083@h5g2000yqh.googlegroups.com> Message-ID: <8d1798e90903200733x8144f58rb8aad0d1ae7b48a4@mail.gmail.com> 2009/3/20 ryeguy : > Now I don't want to have a 5 level deep if or case statement, but what > other options do I have? Splitting it into separate functions sounds > like a good idea, but then I just have to check the return value of > the functions in some sort of conditional and it's back to the > original problem. I've added this function to my libraries: run_checks([]) -> ok; run_checks([H|T]) when is_function(H, 0) -> case H() of ok -> run_checks(T); Error -> Error end. at which point the problem is simply case run_checks([ fun() ->check_email(Email) end, fun() ->check_username(Username) end, ... ]) of ok -> ...; {error, Reason} -> ... end. Adam. From pfisher@REDACTED Fri Mar 20 15:34:15 2009 From: pfisher@REDACTED (Paul Fisher) Date: Fri, 20 Mar 2009 09:34:15 -0500 Subject: [erlang-questions] How do I elegantly check many conditions? In-Reply-To: <4d08db370903200717o3a925df7k67e5ebb54c479aeb@mail.gmail.com> References: <769240e8-b6ed-4f41-bfd0-a970f483a083@h5g2000yqh.googlegroups.com> <4d08db370903200717o3a925df7k67e5ebb54c479aeb@mail.gmail.com> Message-ID: <49C3A967.5040507@alertlogic.net> Hynek Vychodil wrote: > One of Joe's suggestion: program success case code separated from error > handling. You can make it in this way > > create_user(Email, UserName, Password) -> > try > ok = new_email(Email), > ok = valid_user_name(UserName), > ok = new_user(UserName), > ok = strong_password(Password), > ... > _create_user(Email, UserName, Password) > catch > error:{badmatch, email_in_use} -> do_something(); > error:{badmatch, invalid_user_name} -> do_something(); > error:{badmatch, user_exists} -> do_something(); > error:{badmatch, weak_password} -> do_something(); > ... > end. +1 Bravo! -- paul From vychodil.hynek@REDACTED Fri Mar 20 15:43:30 2009 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Fri, 20 Mar 2009 15:43:30 +0100 Subject: [erlang-questions] How do I elegantly check many conditions? In-Reply-To: <49C3A967.5040507@alertlogic.net> References: <769240e8-b6ed-4f41-bfd0-a970f483a083@h5g2000yqh.googlegroups.com> <4d08db370903200717o3a925df7k67e5ebb54c479aeb@mail.gmail.com> <49C3A967.5040507@alertlogic.net> Message-ID: <4d08db370903200743m45228eb4h249f4a4c22d80e80@mail.gmail.com> Pattern match is one of coolest things in Erlang. Note that you can involve your tag to badmatch error {my_tag, ok} = {my_tag, my_call(X)} and custom data too {my_tag, ok, X} = {my_tag, my_call(X), X} cool, isn't it? On Fri, Mar 20, 2009 at 3:34 PM, Paul Fisher wrote: > Hynek Vychodil wrote: > >> One of Joe's suggestion: program success case code separated from error >> handling. You can make it in this way >> >> create_user(Email, UserName, Password) -> >> try >> ok = new_email(Email), >> ok = valid_user_name(UserName), >> ok = new_user(UserName), >> ok = strong_password(Password), >> ... >> _create_user(Email, UserName, Password) >> catch >> error:{badmatch, email_in_use} -> do_something(); >> error:{badmatch, invalid_user_name} -> do_something(); >> error:{badmatch, user_exists} -> do_something(); >> error:{badmatch, weak_password} -> do_something(); >> ... >> end. >> > > +1 Bravo! > > > -- > paul > > -- --Hynek (Pichi) Vychodil Analyze your data in minutes. Share your insights instantly. Thrill your boss. Be a data hero! Try Good Data now for free: www.gooddata.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From ryeguy1@REDACTED Fri Mar 20 15:43:38 2009 From: ryeguy1@REDACTED (ryeguy) Date: Fri, 20 Mar 2009 07:43:38 -0700 (PDT) Subject: [erlang-questions] How do I elegantly check many conditions? In-Reply-To: <49C3A967.5040507@alertlogic.net> References: <769240e8-b6ed-4f41-bfd0-a970f483a083@h5g2000yqh.googlegroups.com> <4d08db370903200717o3a925df7k67e5ebb54c479aeb@mail.gmail.com> <49C3A967.5040507@alertlogic.net> Message-ID: I actually like that one the best. It's cleanest, and simplest. I actually thought about something like this, but my mind is still clouded from other evil languages, where exceptions should be used for "exceptional" situations (exluding Python). Is exception handling cheap in Erlang? On Mar 20, 10:34?am, Paul Fisher wrote: > Hynek Vychodil wrote: > > One of Joe's suggestion: program success case code separated from error > > handling. You can make it in this way > > > create_user(Email, UserName, Password) -> > > ? try > > ? ? ok = new_email(Email), > > ? ? ok = valid_user_name(UserName), > > ? ? ok = new_user(UserName), > > ? ? ok = strong_password(Password), > > ? ? ... > > ? ? _create_user(Email, UserName, Password) > > ? catch > > ? ? error:{badmatch, email_in_use} -> do_something(); > > ? ? error:{badmatch, invalid_user_name} -> do_something(); > > ? ? error:{badmatch, user_exists} -> do_something(); > > ? ? error:{badmatch, weak_password} -> do_something(); > > ? ? ... > > ? end. > > +1 Bravo! > > -- > paul > > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions From malcolm@REDACTED Fri Mar 20 16:19:56 2009 From: malcolm@REDACTED (Malcolm Dowse) Date: Fri, 20 Mar 2009 15:19:56 +0000 Subject: [erlang-questions] Monads in Erlang? In-Reply-To: <6a3ae47e0903190940o798d06cbvd85ec2a60b52fb98@mail.gmail.com> References: <6a3ae47e0903190940o798d06cbvd85ec2a60b52fb98@mail.gmail.com> Message-ID: <707529930903200819n285e8f7chdcfa47f3282fd5b6@mail.gmail.com> On Thu, Mar 19, 2009 at 4:40 PM, Robert Raschke wrote: > Hi, > > all this very interesting discussion about patterns and state carrying > from one expression to the next makes me think a lot of state monads. > > I've never really delved into Haskell all too deeply (it's on my list > of things to learn much more of), but would some of the objections and > issues to do with numbered "state patterns" be addressed by something > similar to state monads? I'm guessing that tuple patterns involving > atoms as signifiers for results make this tricky, but maybe someone > has thought about this in more detail? I haven't thought that hard about it, but it I do know a bit about Haskell. Unlike Richard, I personally don't think that there is a very strong case for trying to add monads to Erlang, because Erlang is such a different language to Haskell. Haskell is a language very much concerned about elegant semantics, but the upshot of that is that understanding efficiency issues become very hard. Monads were introduced to solve many of these problems. The ST monad allows you to manage large datastructures destructively, ensuring that they will be garbage collected - if computers had limitless CPU and RAM, it wouldn't be needed. The IO monad handles all I/O, non-determinism, concurrency; all the more messy, unpredictable areas of language behaviour are confined to the IO monad. So, in my opinion, monads were not really added into Haskell to make it more elegant. They were instead added to make it much more practical, without poisoning the elegance of the rest of the language. But Erlang is totally different. It is already, at its heart, a really practical language. With a strict reduction order, managing datastructures efficiently is straighforward enough, and side-effecting is everywhere, so you're not trying to protect the rest of the language from "impure" features. Much of the discussion about state handling was about syntax. But although there is a special imperative-like syntax for monadic programming in Haskell, that's not really the point of monads. The internal state variable *has* to be hidden for reasons related to Haskell's static type system, as is the case for I/O. (The Clean language, closely related to Haskell, uses a different type system, where there's actually a variable usually called "World" which is explicitly passed around when doing I/O) So, in my opinion, if you were to add monads into Erlang, you would just get a monad-like syntax, without any other benefits. And it's debatable whether this is really an improvement - it's more concise, but at the same time, more is hidden from view. kind regards, malcolm > > > Robby > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > ______________________________________________________________________ > This email has been scanned by the MessageLabs Email Security System. > For more information please visit http://www.messagelabs.com/email > ______________________________________________________________________ > -------------- next part -------------- An HTML attachment was scrubbed... URL: From cthulahoops@REDACTED Fri Mar 20 17:47:23 2009 From: cthulahoops@REDACTED (Adam Kelly) Date: Fri, 20 Mar 2009 16:47:23 +0000 Subject: [erlang-questions] How do I elegantly check many conditions? In-Reply-To: <401d3ba30903200918v17706132w70043b59148f99f6@mail.gmail.com> References: <769240e8-b6ed-4f41-bfd0-a970f483a083@h5g2000yqh.googlegroups.com> <8d1798e90903200733x8144f58rb8aad0d1ae7b48a4@mail.gmail.com> <401d3ba30903200918v17706132w70043b59148f99f6@mail.gmail.com> Message-ID: <8d1798e90903200947i43443cdv2c00ce2a1d2b0bc8@mail.gmail.com> 2009/3/20 Attila Rajmund Nohl : > 2009/3/20, Adam Kelly : >> 2009/3/20 ryeguy : >>> Now I don't want to have a 5 level deep if or case statement, but what >>> other options do I have? Splitting it into separate functions sounds >>> like a good idea, but then I just have to check the return value of >>> the functions in some sort of conditional and it's back to the >>> original problem. >> >> I've added this function to my libraries: >> >> run_checks([]) -> ok; >> run_checks([H|T]) when is_function(H, 0) -> >> ? ? ? case H() of >> ? ? ? ? ? ? ? ok ? ?-> run_checks(T); >> ? ? ? ? ? ? ? Error -> Error >> ? ? ? end. > > Something like this is badly missing from the lists module... I'm not sure I'd put it in the lists module, maybe an additional control structure module would be good. I have a collection of higher order functions for these sorts of tasks. On the other hand I'm partially convinced that the try -> catch badmatch solution is neater anyway. (I presume your response was intended for the list.) Adam. From nm@REDACTED Fri Mar 20 18:29:25 2009 From: nm@REDACTED (Gaspar Chilingarov) Date: Fri, 20 Mar 2009 21:29:25 +0400 Subject: [erlang-questions] How do I elegantly check many conditions? In-Reply-To: <8d1798e90903200733x8144f58rb8aad0d1ae7b48a4@mail.gmail.com> References: <769240e8-b6ed-4f41-bfd0-a970f483a083@h5g2000yqh.googlegroups.com> <8d1798e90903200733x8144f58rb8aad0d1ae7b48a4@mail.gmail.com> Message-ID: <49C3D275.1010701@web.am> Practically agree with previous speaker, but I will do it a little bit in other way ;) % % store all necessary data to pass between validators in % #validator_state struct % run_checks(FunList, Data) -> run_checks(FunList, Data, #validator_state{}). % % evaluate validation chain % run_checks([], Data, State) -> {valid, Data, State}; run_checks([F | FunList], Data, State) -> case ?MODULE:F(Data, State) of {valid, NewData, NewState} -> run_checks(FunList, NewData, NewState); Error = {error, _ErrorMsg, _NewState} -> % you can add to error reporting in WHICH % validator it failed % like % {error, F, _ErrorMsg, _NewState} Error % for ease of programming validators I would add also % shortcut return codes like % valid -> run_checks(FunList, Data, State); % and % {error, Error} -> {error, Error, State}; end. And I will end up with functions like % check functions check_email(PropList, State) -> do something and return values .... check_name(PropList, State) -> do something and return values .... and checking will be as easy as % InputData is better to be a proplist - much more easier to work with % or it may be a record of some type % just tuple will reduce code flexibility in a long run run_checks([check_email, check_name, check_valid_password], InputData) So changing order of validation or adding new validator is as easy as just writing one more functions and adding it to run_checks call. And it's also very readable - looking on run_checks invocation you can easily determine which checks are run and in which order. I do not hesitate to make check_* functions global - because this will also ease writing tests for them (if you use test driver environment). Disclaimer - I wrote this code out of my head and do not test it, thou it should compile with minimal changes, I think :) /Gaspar PS. BTW with minimal changes this approach also solves a problem with destructive variable update, which generated great flame here in a last days. Just extend Data variable to something flexible (in my case I user FIFO stack there) and you will get powerful interpretator of "meta commands" (like check_email, check_name and so on). Adam Kelly wrote: > 2009/3/20 ryeguy : >> Now I don't want to have a 5 level deep if or case statement, but what >> other options do I have? Splitting it into separate functions sounds >> like a good idea, but then I just have to check the return value of >> the functions in some sort of conditional and it's back to the >> original problem. > > I've added this function to my libraries: > > run_checks([]) -> ok; > run_checks([H|T]) when is_function(H, 0) -> > case H() of > ok -> run_checks(T); > Error -> Error > end. > > at which point the problem is simply > > case run_checks([ > fun() ->check_email(Email) end, > fun() ->check_username(Username) end, > ... ]) of > ok -> ...; > {error, Reason} -> ... > end. > > Adam. -- Gaspar Chilingarov tel +37493 419763 (mobile - leave voice mail message) icq 63174784 skype://gasparch e mailto:nm@REDACTED mailto:gasparch@REDACTED w http://gasparchilingarov.com/ From vychodil.hynek@REDACTED Fri Mar 20 18:33:37 2009 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Fri, 20 Mar 2009 18:33:37 +0100 Subject: [erlang-questions] How do I elegantly check many conditions? In-Reply-To: References: <769240e8-b6ed-4f41-bfd0-a970f483a083@h5g2000yqh.googlegroups.com> <4d08db370903200717o3a925df7k67e5ebb54c479aeb@mail.gmail.com> <49C3A967.5040507@alertlogic.net> Message-ID: <4d08db370903201033m56c33607r6a2fa20418475b4a@mail.gmail.com> One benchmark is worth of thousand questions ;-) -module(exceptiontest). -export([test/2, success/0, fail/0]). test(0, _)-> ok; test(N, F)-> try ok = ?MODULE:F() catch error:{badmatch, fail} -> fail end, test(N-1, F). success()->ok. fail()->fail. Byte code: 9> timer:tc(exceptiontest,test,[1000000, fail]). {469954,ok} 10> timer:tc(exceptiontest,test,[1000000, success]). {164390,ok} Native: 11> c(exceptiontest, native). {ok,exceptiontest} 12> timer:tc(exceptiontest,test,[1000000, fail]). {146526,ok} 13> timer:tc(exceptiontest,test,[1000000, success]). {21573,ok} It means about roughly 2 millions exceptions in one second (0.47us) compared to 6 millions success (external) function calls (0.146us) - one can guess that exception handling takes about 0.32us. In native code it is 6.8 vs 47 millions per second and handling can take about 0.125us. There can be some additional cost for try-catch construct which I haven't measured this way. (Is very low how I remember from past.) On Fri, Mar 20, 2009 at 3:43 PM, ryeguy wrote: > I actually like that one the best. It's cleanest, and simplest. I > actually thought about something like this, but my mind is still > clouded from other evil languages, where exceptions should be used for > "exceptional" situations (exluding Python). > > Is exception handling cheap in Erlang? > > On Mar 20, 10:34 am, Paul Fisher wrote: > > Hynek Vychodil wrote: > > > One of Joe's suggestion: program success case code separated from error > > > handling. You can make it in this way > > > > > create_user(Email, UserName, Password) -> > > > try > > > ok = new_email(Email), > > > ok = valid_user_name(UserName), > > > ok = new_user(UserName), > > > ok = strong_password(Password), > > > ... > > > _create_user(Email, UserName, Password) > > > catch > > > error:{badmatch, email_in_use} -> do_something(); > > > error:{badmatch, invalid_user_name} -> do_something(); > > > error:{badmatch, user_exists} -> do_something(); > > > error:{badmatch, weak_password} -> do_something(); > > > ... > > > end. > > > > +1 Bravo! > > > > -- > > paul > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questi...@REDACTED:// > 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 Analyze your data in minutes. Share your insights instantly. Thrill your boss. Be a data hero! Try Good Data now for free: www.gooddata.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From pfisher@REDACTED Fri Mar 20 18:36:21 2009 From: pfisher@REDACTED (Paul Fisher) Date: Fri, 20 Mar 2009 12:36:21 -0500 Subject: [erlang-questions] How do I elegantly check many conditions? In-Reply-To: References: <769240e8-b6ed-4f41-bfd0-a970f483a083@h5g2000yqh.googlegroups.com> <4d08db370903200717o3a925df7k67e5ebb54c479aeb@mail.gmail.com> <49C3A967.5040507@alertlogic.net> Message-ID: <49C3D415.2080502@alertlogic.net> Gordon Guthrie wrote: > > > On Fri, Mar 20, 2009 at 2:34 PM, Paul Fisher > wrote: > > Hynek Vychodil wrote: > > One of Joe's suggestion: program success case code separated from > error > > handling. You can make it in this way > > > > create_user(Email, UserName, Password) -> > > try > > ok = new_email(Email), > > ok = valid_user_name(UserName), > > ok = new_user(UserName), > > ok = strong_password(Password), > > ... > > _create_user(Email, UserName, Password) > > catch > > error:{badmatch, email_in_use} -> do_something(); > > error:{badmatch, invalid_user_name} -> do_something(); > > error:{badmatch, user_exists} -> do_something(); > > error:{badmatch, weak_password} -> do_something(); > > ... > > end. > > +1 Bravo! > > > > This solution is not good for the user though... > > It throws an error on first failure, and if (say on a web form) the user > has made many errors they get caught in a fix/fail cycle which drives > them (<--- read me here) mad! Then do this with failures returning the same atom values as above: create_user(Email, UserName, Password) -> case lists:usort( [new_email(Email), valid_user_name(UserName), new_user(UserName), strong_password(Password)] ) of [ok] -> _create_user(Email, UserName, Password); Failures -> _notify_failures( Failures ) end. -- paul From vychodil.hynek@REDACTED Fri Mar 20 18:40:21 2009 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Fri, 20 Mar 2009 18:40:21 +0100 Subject: [erlang-questions] How do I elegantly check many conditions? In-Reply-To: <4d08db370903201033m56c33607r6a2fa20418475b4a@mail.gmail.com> References: <769240e8-b6ed-4f41-bfd0-a970f483a083@h5g2000yqh.googlegroups.com> <4d08db370903200717o3a925df7k67e5ebb54c479aeb@mail.gmail.com> <49C3A967.5040507@alertlogic.net> <4d08db370903201033m56c33607r6a2fa20418475b4a@mail.gmail.com> Message-ID: <4d08db370903201040g337ba9ffl3afac86f86c5f727@mail.gmail.com> I forgot, it is on 2.2GHz Intel Core2 Duo CPU - it means exception handling takes less than thousand CPU cycles in byte-code and less than 300 in native code. On Fri, Mar 20, 2009 at 6:33 PM, Hynek Vychodil wrote: > One benchmark is worth of thousand questions ;-) > > -module(exceptiontest). > > -export([test/2, success/0, fail/0]). > > test(0, _)-> ok; > test(N, F)-> > try > ok = ?MODULE:F() > catch > error:{badmatch, fail} -> fail > end, > test(N-1, F). > > success()->ok. > > fail()->fail. > > Byte code: > > 9> timer:tc(exceptiontest,test,[1000000, fail]). > {469954,ok} > 10> timer:tc(exceptiontest,test,[1000000, success]). > {164390,ok} > > Native: > > 11> c(exceptiontest, native). > {ok,exceptiontest} > 12> timer:tc(exceptiontest,test,[1000000, fail]). > {146526,ok} > 13> timer:tc(exceptiontest,test,[1000000, success]). > {21573,ok} > > It means about roughly 2 millions exceptions in one second (0.47us) > compared to 6 millions success (external) function calls (0.146us) - one can > guess that exception handling takes about 0.32us. > In native code it is 6.8 vs 47 millions per second and handling can take > about 0.125us. There can be some additional cost for try-catch construct > which I haven't measured this way. (Is very low how I remember from past.) > > > On Fri, Mar 20, 2009 at 3:43 PM, ryeguy wrote: > >> I actually like that one the best. It's cleanest, and simplest. I >> actually thought about something like this, but my mind is still >> clouded from other evil languages, where exceptions should be used for >> "exceptional" situations (exluding Python). >> >> Is exception handling cheap in Erlang? >> >> On Mar 20, 10:34 am, Paul Fisher wrote: >> > Hynek Vychodil wrote: >> > > One of Joe's suggestion: program success case code separated from >> error >> > > handling. You can make it in this way >> > >> > > create_user(Email, UserName, Password) -> >> > > try >> > > ok = new_email(Email), >> > > ok = valid_user_name(UserName), >> > > ok = new_user(UserName), >> > > ok = strong_password(Password), >> > > ... >> > > _create_user(Email, UserName, Password) >> > > catch >> > > error:{badmatch, email_in_use} -> do_something(); >> > > error:{badmatch, invalid_user_name} -> do_something(); >> > > error:{badmatch, user_exists} -> do_something(); >> > > error:{badmatch, weak_password} -> do_something(); >> > > ... >> > > end. >> > >> > +1 Bravo! >> > >> > -- >> > paul >> > >> > _______________________________________________ >> > erlang-questions mailing list >> > erlang-questi...@REDACTED:// >> 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 > > Analyze your data in minutes. Share your insights instantly. Thrill your > boss. Be a data hero! > Try Good Data now for free: www.gooddata.com > -- --Hynek (Pichi) Vychodil Analyze your data in minutes. Share your insights instantly. Thrill your boss. Be a data hero! Try Good Data now for free: www.gooddata.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From nm@REDACTED Fri Mar 20 19:32:26 2009 From: nm@REDACTED (Gaspar Chilingarov) Date: Fri, 20 Mar 2009 22:32:26 +0400 Subject: [erlang-questions] How do I elegantly check many conditions? In-Reply-To: <49C3D275.1010701@web.am> References: <769240e8-b6ed-4f41-bfd0-a970f483a083@h5g2000yqh.googlegroups.com> <8d1798e90903200733x8144f58rb8aad0d1ae7b48a4@mail.gmail.com> <49C3D275.1010701@web.am> Message-ID: <49C3E13A.301@web.am> Hi all! Just wanted to add that I'm against of using funs in this case if you can avoid it - just to keep module syntax as clean as possible. comment to code in prev. message - you should wrap validator invocation in try/catch and catch validator crashes - sometimes it's not necessary to give a explanation to the user and general error message will be ok. In this cases you can validator just fail, if it cannot validate the data For example check_passwords(Fields, _) -> Fields#fields.password = Fields#fields.password_confirm. It will crash on match, if user entered different values in the fields. With a little magic you create nested command chains, 'if' statements in command chains, 'case' and so on. If some validation procedures take a long time (for example require network calls and so on) - you can add syntax to specify which commands in chain is possible to run in parallel. If one of them fail (or succeed) you can immediately kill another validation processes and return a processing result. Such programming style gives you a _GREAT_ level of flexibility to _what login _ are you programming. In other this approach is very consistent and have very readable syntax. So :) Go and create your small interpreter in Erlang - it's fun and it works! /Gaspar -- Gaspar Chilingarov tel +37493 419763 (mobile - leave voice mail message) icq 63174784 skype://gasparch e mailto:nm@REDACTED mailto:gasparch@REDACTED w http://gasparchilingarov.com/ From steve.e.123@REDACTED Fri Mar 20 20:42:24 2009 From: steve.e.123@REDACTED (steve ellis) Date: Fri, 20 Mar 2009 15:42:24 -0400 Subject: [erlang-questions] to supervise or not to supervise Message-ID: <4cb4a7bf0903201242t2166af30rbba7fe44ee8800a1@mail.gmail.com> New to supervision trees and trying to figure out when to use them (and when not to)... I have bunch of spawned processes created through spawn_link. Want these processes to say running indefinitely. If one exits in an error state, we want to restart it N times. After N, we want to error log it, and stop trying to restart it. Perfect job for a one_to_one supervisor right? Well sort of. The problem is that when the max restarts for the error process is reached, the supervisor terminates all its children and itself. Ouch! (At least in our case). We'd rather that the supervisor just keep supervising all the children that are ok and not swallow everything up. The Design Principles appear to be saying that swallowing everything up is what supervisors are supposed to do when max restarts is reached which leaves me a little puzzled. Why would you want to kill the supervisor just because a child process is causing trouble? Seems a little harsh. Is this a case of me thinking supervisors are good for too many things? Is it that our case is better handled by simply spawning these processes and trapping exits on them, and restarting/error logging in the trap exit? Thanks! Steve -------------- next part -------------- An HTML attachment was scrubbed... URL: From mihai@REDACTED Fri Mar 20 22:31:27 2009 From: mihai@REDACTED (Mihai Balea) Date: Fri, 20 Mar 2009 17:31:27 -0400 Subject: [erlang-questions] to supervise or not to supervise In-Reply-To: <4cb4a7bf0903201242t2166af30rbba7fe44ee8800a1@mail.gmail.com> References: <4cb4a7bf0903201242t2166af30rbba7fe44ee8800a1@mail.gmail.com> Message-ID: <40A95F1F-B078-4A00-B7D4-013D015785D8@hates.ms> On Mar 20, 2009, at 3:42 PM, steve ellis wrote: > New to supervision trees and trying to figure out when to use them > (and when not to)... > > I have bunch of spawned processes created through spawn_link. Want > these processes to say running indefinitely. If one exits in an > error state, we want to restart it N times. After N, we want to > error log it, and stop trying to restart it. Perfect job for a > one_to_one supervisor right? > > Well sort of. The problem is that when the max restarts for the > error process is reached, the supervisor terminates all its children > and itself. Ouch! (At least in our case). We'd rather that the > supervisor just keep supervising all the children that are ok and > not swallow everything up. > > The Design Principles appear to be saying that swallowing everything > up is what supervisors are supposed to do when max restarts is > reached which leaves me a little puzzled. Why would you want to kill > the supervisor just because a child process is causing trouble? > Seems a little harsh. > > Is this a case of me thinking supervisors are good for too many > things? Is it that our case is better handled by simply spawning > these processes and trapping exits on them, and restarting/error > logging in the trap exit? As far as I know, the standard supervisor cannot behave the way you want it to. So, at least until this type of behavior is added to the standard supervisor, you can work around it with double layers of supervision. Basically have one dedicated supervisor for each process you want to supervise and, in turn, each dedicated supervisor is set up as a transient child to one big supervisor. Mihai From Lennart.Ohman@REDACTED Fri Mar 20 22:23:16 2009 From: Lennart.Ohman@REDACTED (=?iso-8859-1?Q?Lennart_=D6hman?=) Date: Fri, 20 Mar 2009 22:23:16 +0100 Subject: [erlang-questions] to supervise or not to supervise In-Reply-To: <4cb4a7bf0903201242t2166af30rbba7fe44ee8800a1@mail.gmail.com> References: <4cb4a7bf0903201242t2166af30rbba7fe44ee8800a1@mail.gmail.com> Message-ID: Hi, as you have discovered there are a few different restart strategies available when designing a supervisor (e.g: one_for_one, one_for all). One can of course come up with more or less an infinite number of such strategies, each one with its own twist. The main idea and problem at the time when the supervisor behaviour was constructed was that you have a set of more or less permanent processes that implements a subsystem. There should not be any 'illegal' terminations (such that causes the supervisor to act) amongst the children. But, as we know, no non trivial system is completely correct, hence an occasional failure and following restart must be allowed. If we have repeated failures it may indicate that the problem concerns more than this subsystem, therefore the need to eventually escalate the restarts (or as you have discovered kill all children and itself). If you really want to achieve a situation where failures never escalates above a certain supervisor you can bump up the max-restart threshold and at the same time shorten the sliding window. It is a not uncommon mistake (in normal usage of supervisors :) ) to have a too high max-restart-intensity in combination with a too short sliding window at a higher level supervisor. It may then be too long between escalation attempts by lower level supervisor for the same error, making a higher level supervisor not consider two failures amongst its children being the same error, and therefore not eventually escalate to its superior supervisor. Best Regards Lennart ------------------------------------------------------------- Lennart ?hman direct : +46 8 587 623 27 Sj?land & Thyselius Telecom AB cellular: +46 70 552 6735 H?lsingegatan 43, 10 th floor fax : +46 8 667 82 30 SE-113 31 STOCKHOLM, SWEDEN email : lennart.ohman@REDACTED From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of steve ellis Sent: den 20 mars 2009 20:42 To: erlang-questions@REDACTED Subject: [erlang-questions] to supervise or not to supervise New to supervision trees and trying to figure out when to use them (and when not to)... I have bunch of spawned processes created through spawn_link. Want these processes to say running indefinitely. If one exits in an error state, we want to restart it N times. After N, we want to error log it, and stop trying to restart it. Perfect job for a one_to_one supervisor right? Well sort of. The problem is that when the max restarts for the error process is reached, the supervisor terminates all its children and itself. Ouch! (At least in our case). We'd rather that the supervisor just keep supervising all the children that are ok and not swallow everything up. The Design Principles appear to be saying that swallowing everything up is what supervisors are supposed to do when max restarts is reached which leaves me a little puzzled. Why would you want to kill the supervisor just because a child process is causing trouble? Seems a little harsh. Is this a case of me thinking supervisors are good for too many things? Is it that our case is better handled by simply spawning these processes and trapping exits on them, and restarting/error logging in the trap exit? Thanks! Steve -------------- next part -------------- An HTML attachment was scrubbed... URL: From raison@REDACTED Fri Mar 20 23:33:10 2009 From: raison@REDACTED (raison) Date: Fri, 20 Mar 2009 15:33:10 -0700 (PDT) Subject: [erlang-questions] Fwd: sl module from jungerl/CEAN In-Reply-To: <337538cb0802270135j23d0a5ccnffa916c3a57713f@mail.gmail.com> References: <337538cb0802262241v7a40ae9ayf5912342b44d62d3@mail.gmail.com> <15709314.post@talk.nabble.com> <337538cb0802270135j23d0a5ccnffa916c3a57713f@mail.gmail.com> Message-ID: <22629655.post@talk.nabble.com> I am facing the same issue. I took a look at the C code (sl_drv.c), and it appears that there are some minor issues that a win32 expert could probably fix with ease. Unfortunately, I am not that guy. It looks like the struct "sl_t" relies on a "stat" field (only under Windows), while the definition of that struct does not contain a "stat" line with a type definition. Are there any win32 experts out there who might know what this mysterious stat field is all about? There are a couple of other compile errors, which I have included below. Thanks in advance for any assistance. $ mingw32-make -f Makefile.win32 gcc -c -o sl_drv.obj sl_drv.c -I"c:/Program Files/erl5.6.5"/usr/include -mno-cygwin -D__WIN32__ sl_drv.c: In function `do_open': sl_drv.c:1044: error: structure has no member named `stat' sl_drv.c:1048: error: structure has no member named `stat' sl_drv.c: In function `sl_ready_input': sl_drv.c:1239: error: structure has no member named `stat' sl_drv.c:1242: error: `mask' undeclared (first use in this function) sl_drv.c:1242: error: (Each undeclared identifier is reported only once sl_drv.c:1242: error: for each function it appears in.) sl_drv.c:1242: error: structure has no member named `stat' sl_drv.c: In function `sl_ready_output': sl_drv.c:1273: error: `n' undeclared (first use in this function) sl_drv.c: In function `sl_ctl': sl_drv.c:1544: error: structure has no member named `stat' mingw32-make: *** [sl_drv.obj] Error 1 Cheers. Kevin Raison Kirill Zaborski wrote: > > > > Recently I've sumbled on task of getting connection to serial port > > > from Erlang. I have found sl module from jungerl (and in CEAN) which > > > should do the task. But I could not compile it using MSYS+MinGW. It > > > looks like there are some bugs in source code (e.g. undeclared field > > > in struct). > > > Has anyone get it compiled on Windows? Or maybe author (Tony > Rogvall) > > > is on the list? > > -- View this message in context: http://www.nabble.com/sl-module-from-jungerl-CEAN-tp15707101p22629655.html Sent from the Erlang Questions mailing list archive at Nabble.com. From raison@REDACTED Fri Mar 20 23:35:46 2009 From: raison@REDACTED (Kevin Raison) Date: Fri, 20 Mar 2009 15:35:46 -0700 Subject: [erlang-questions] Fwd: sl module from jungerl/CEAN Message-ID: <49C41A42.6010200@chatsubo.net> I am facing the same issue. I took a look at the C code (sl_drv.c), and it appears that there are some minor issues that a win32 expert could probably fix with ease. Unfortunately, I am not that guy. It looks like the struct "sl_t" relies on a "stat" field (only under Windows), while the definition of that struct does not contain a "stat" line with a type definition. Are there any win32 experts out there who might know what this mysterious stat field is all about? There are a couple of other compile errors, which I have included below. Thanks in advance for any assistance. $ mingw32-make -f Makefile.win32 gcc -c -o sl_drv.obj sl_drv.c -I"c:/Program Files/erl5.6.5"/usr/include -mno-cygwin -D__WIN32__ sl_drv.c: In function `do_open': sl_drv.c:1044: error: structure has no member named `stat' sl_drv.c:1048: error: structure has no member named `stat' sl_drv.c: In function `sl_ready_input': sl_drv.c:1239: error: structure has no member named `stat' sl_drv.c:1242: error: `mask' undeclared (first use in this function) sl_drv.c:1242: error: (Each undeclared identifier is reported only once sl_drv.c:1242: error: for each function it appears in.) sl_drv.c:1242: error: structure has no member named `stat' sl_drv.c: In function `sl_ready_output': sl_drv.c:1273: error: `n' undeclared (first use in this function) sl_drv.c: In function `sl_ctl': sl_drv.c:1544: error: structure has no member named `stat' mingw32-make: *** [sl_drv.obj] Error 1 Cheers. Kevin Raison Recently I've sumbled on task of getting connection to serial port from Erlang. I have found sl module from jungerl (and in CEAN) which should do the task. But I could not compile it using MSYS+MinGW. It looks like there are some bugs in source code (e.g. undeclared field in struct). Has anyone get it compiled on Windows? Or maybe author (Tony Rogvall) is on the list? From clist@REDACTED Sat Mar 21 00:11:05 2009 From: clist@REDACTED (Angel Alvarez) Date: Sat, 21 Mar 2009 00:11:05 +0100 Subject: [erlang-questions] Reassigning variables In-Reply-To: References: <879778450903171338j5f47e27fm6b6016906dff0159@mail.gmail.com> Message-ID: <200903210011.05865.clist@uah.es> Hi all El Martes, 17 de Marzo de 2009 Matthew Dempsky escribi?: > On Tue, Mar 17, 2009 at 1:38 PM, Justin Sheehy wrote: > > Single assignment is one of the biggest ways in which Erlang helps > > reduce bugs. ?Please don't try to introduce ways around it, as they > > will make programs worse. > > I disagree. There are ways that reassignment can make code easier to > analyze, but I'm not suggesting people use reassignment in those > cases. > > Similarly, Erlang doesn't support 'return', but our ad server has > enough business logic where the code would be much simpler if it did. > We had some code that was effectively: > > if requested ad size is bad: > return {skip, bad_size} > if the game has ads disabled: > return {skip, disabled} > if the game is filtering a domain: > return {skip, domain_filtered} > return choose_ad() > > I rewrote this code in 'Erlang style' with a list of funs to check, > and to short-circuit on the first that returns a skip, when I last > added to it, and so incrementally it's much less work to add new > checks than the old code. > > But it's stupid. I'm not going to add 100 new checks, there's only a > handful now, and there will almost certainly never be more than a > handful more in the future. Rewriting 10 lines of code to be 60 lines > of code (having to define a new function for each check, having to add > code to handle the list of check funs, etc.) to deal with Erlang's > language limitations does not help with readability. ?Maybe it can be acomplished using a list of funs? The averall return code can be seen as a fold over the list of Funs for any given argument... being newbie on erlang issues, i cant show you such code but all you can imagine what im trying to say.. Regards , Angel > > (In contrast, we similarly redesigned the per-campaign and per-ad > filtering code to use this style, and they do update much more > frequently, and it actually has been beneficial allowing us to > dynamically change what lists of filters are applied in different > situations. But not everything merits that complexity.) > > Programmers understand how variable reassignment and multiple function > call returns work: every beginner programming language includes them. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- Este correo no tiene dibujos. Las formas extra?as en la pantalla son letras. ->>----------------------------------------------- Clist UAH a.k.a Angel ---------------------------------[www.uah.es]-<<-- No le dar?a Cocacola Zero, ni a mi peor enemigo. Para eso est? el gas Mostaza que es mas piadoso. From tony@REDACTED Sat Mar 21 00:24:52 2009 From: tony@REDACTED (Tony Arcieri) Date: Fri, 20 Mar 2009 17:24:52 -0600 Subject: [erlang-questions] Memory allocator Message-ID: I noticed in Ulf Wiger's presentation Erlang Programming for Multicore: http://ulf.wiger.net/weblog/2009/01/23/erlang-programming-for-multicore/ ...that the main contention point in R13A is now the memory allocator. Are there any plans for addressing this, such as moving to a different memory allocator, maybe: tcmalloc: http://goog-perftools.sourceforge.net/doc/tcmalloc.html hoard: http://www.hoard.org I'm curious how much something like this would improve Erlang's performance. Perhaps I'll try benchmarking Erlang with these allocators versus plain vanilla libc. -- Tony Arcieri medioh.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From vychodil.hynek@REDACTED Sat Mar 21 00:47:46 2009 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Sat, 21 Mar 2009 00:47:46 +0100 Subject: [erlang-questions] Memory allocator In-Reply-To: References: Message-ID: <4d08db370903201647y24e5636dt2212dbcd75370f99@mail.gmail.com> tcmalloc have good idea. What about memory cache per scheduler? 2009/3/21 Tony Arcieri > I noticed in Ulf Wiger's presentation Erlang Programming for Multicore: > > http://ulf.wiger.net/weblog/2009/01/23/erlang-programming-for-multicore/ > > ...that the main contention point in R13A is now the memory allocator. > > Are there any plans for addressing this, such as moving to a different > memory allocator, maybe: > > tcmalloc: http://goog-perftools.sourceforge.net/doc/tcmalloc.html > hoard: http://www.hoard.org > > I'm curious how much something like this would improve Erlang's > performance. Perhaps I'll try benchmarking Erlang with these allocators > versus plain vanilla libc. > > -- > Tony Arcieri > medioh.com > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- --Hynek (Pichi) Vychodil Analyze your data in minutes. Share your insights instantly. Thrill your boss. Be a data hero! Try Good Data now for free: www.gooddata.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From geoff.cant@REDACTED Sat Mar 21 06:37:42 2009 From: geoff.cant@REDACTED (Geoff Cant) Date: Sat, 21 Mar 2009 18:37:42 +1300 Subject: [erlang-questions] How do I elegantly check many conditions? In-Reply-To: <769240e8-b6ed-4f41-bfd0-a970f483a083@h5g2000yqh.googlegroups.com> (ryeguy's message of "Fri, 20 Mar 2009 06:20:03 -0700 (PDT)") References: <769240e8-b6ed-4f41-bfd0-a970f483a083@h5g2000yqh.googlegroups.com> Message-ID: ryeguy writes: > So when a user sends a request to register an account, they send their > username, password, email, and other info. The registration function > must verify all of their data. An example would be: > > - verify email not in use > - verify username not in use > - verify username is alphanumeric > - verify all fields are above X characters long > - verify all fields are less than Y characters long > > Now I don't want to have a 5 level deep if or case statement, but what > other options do I have? Splitting it into separate functions sounds > like a good idea, but then I just have to check the return value of > the functions in some sort of conditional and it's back to the > original problem. > > I could separate them into functions and then call an if statement > with all of the conditionals OR'd together, but that wouldn't give me > what I want because I need to be able to tell the user the specific > error if there was one. > > How does one handle this kind of situation in erlang? I ran into this when building a website recently and ended up building a form validation library. (http://github.com/archaelus/ejango/tree/master - the form validation checking engine is located here, http://github.com/archaelus/ejango/blob/1d76e5c230e99725b815d258e889d8d8ae355ed4/src/ejango/form_validator.erl) You can see examples of almost all the validation rules you gave above in the unit tests for the form_validator module. There's some documentation on how to specify them around line 109 in the form_validator file. I was trying to create a DSL for declaratively specifying forms and the rules for validating particular fields. E.g. {"user_email", [email_address, not_empty, {predicate, fun yourcode:check_email_in_use/1}]} Checks that the value of the form field "user_email" is not the empty string, matches the regex for email address validation and calling yourcode:check_email_in_use() returns true. The validation engine will report errors for each rule given for a field so that you can give meaningul error messages such as "Email address in use" and localise them if necessary. The library has patchy edoc and some eunit test coverage - the validator itself has edoc, but unfortunately the high level declarative form API isn't documented well yet. It's on my todo list, but if someone beats me to it I'd be happy to apply any patches. The library works well enough that it has been used in a website I'm about to unveil soon. Cheers, -- Geoff Cant From dmitriid@REDACTED Sat Mar 21 08:24:08 2009 From: dmitriid@REDACTED (Dmitrii Dimandt) Date: Sat, 21 Mar 2009 09:24:08 +0200 Subject: [erlang-questions] erldoc and i18n Message-ID: Hi all, Is htere a way to generate internationalized version of documentation using erldoc or any other documentation tool (if such exists)? Thank you From bgustavsson@REDACTED Sat Mar 21 09:40:28 2009 From: bgustavsson@REDACTED (Bjorn Gustavsson) Date: Sat, 21 Mar 2009 09:40:28 +0100 Subject: [erlang-questions] Memory allocator In-Reply-To: References: Message-ID: <6672d0160903210140m1682c753ydf20de9623a12327@mail.gmail.com> 2009/3/21 Tony Arcieri : > I noticed in Ulf Wiger's presentation Erlang Programming for Multicore: > > http://ulf.wiger.net/weblog/2009/01/23/erlang-programming-for-multicore/ > > ...that the main contention point in R13A is now the memory allocator. > > Are there any plans for addressing this, such as moving to a different > memory allocator, maybe: > > tcmalloc: http://goog-perftools.sourceforge.net/doc/tcmalloc.html > hoard: http://www.hoard.org > > I'm curious how much something like this would improve Erlang's > performance.? Perhaps I'll try benchmarking Erlang with these allocators > versus plain vanilla libc. Yes, we have plans for addressing this issue, but not by switching to another allocator. The Erlang emulator by default already uses its own memory allocator. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From pstapley@REDACTED Sat Mar 21 20:52:22 2009 From: pstapley@REDACTED (Pete Stapley) Date: Sat, 21 Mar 2009 13:52:22 -0600 Subject: [erlang-questions] Binary Parsing Message-ID: <49C54576.5010602@rapidnet.com> I am attempting to parse some Radius attributes with Erlang and I have run into a bit of a problem. I pass some binary data to parseAttributes and I want to start peeling off the attributes one by one. I first peel off Type which is one byte, then Length which is also one byte. Next I want to peel off the Attribute. The Length variable is the length of the attribute plus the Type and Length byte, so I have to subtract 2 bytes from the Length variable before peeling off the attribute. I have tried the method below without any luck. Is there a way to do this? Thanks, -define(BYTE, 8/unsigned-big-integer). parseAttributes(Bin) -> parseAttributes(Bin, []). parseAttributes(<<>>, Atts) -> {ok, Atts}; %%problem is here, Length - 2 does not seem to work parseAttributes( <>, Atts) -> io:format("Type: ~p Length: ~p Att:~p Length: ~p~n", [Type, Length, Att, size(Rest)]), parseAttributes(Rest, Atts). From pstapley@REDACTED Sat Mar 21 22:01:38 2009 From: pstapley@REDACTED (Pete Stapley) Date: Sat, 21 Mar 2009 15:01:38 -0600 Subject: [erlang-questions] Binary Parsing In-Reply-To: <49C54576.5010602@rapidnet.com> References: <49C54576.5010602@rapidnet.com> Message-ID: <49C555B2.5050108@rapidnet.com> Nevermind I found the answer in the mailing list archives. http://www.erlang.org/pipermail/erlang-questions/2007-November/031091.html Pete Stapley wrote: > I am attempting to parse some Radius attributes with Erlang and I have > run into a bit of a problem. I pass some binary data to parseAttributes > and I want to start peeling off the attributes one by one. I first peel > off Type which is one byte, then Length which is also one byte. Next I > want to peel off the Attribute. The Length variable is the length of the > attribute plus the Type and Length byte, so I have to subtract 2 bytes > from the Length variable before peeling off the attribute. I have tried > the method below without any luck. Is there a way to do this? > > Thanks, > > -define(BYTE, 8/unsigned-big-integer). > > parseAttributes(Bin) -> > parseAttributes(Bin, []). > > parseAttributes(<<>>, Atts) -> > {ok, Atts}; > %%problem is here, Length - 2 does not seem to work > parseAttributes( < Rest/binary>>, Atts) -> > io:format("Type: ~p Length: ~p Att:~p Length: ~p~n", [Type, Length, > Att, size(Rest)]), > parseAttributes(Rest, Atts). > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From torben.lehoff@REDACTED Sat Mar 21 22:14:31 2009 From: torben.lehoff@REDACTED (Torben Hoffmann) Date: Sat, 21 Mar 2009 22:14:31 +0100 Subject: [erlang-questions] Binary Parsing In-Reply-To: <49C54576.5010602@rapidnet.com> References: <49C54576.5010602@rapidnet.com> Message-ID: A classical problem! My preferred solution to this is to do it in steps: parse(<>) -> Length = FullLength - 2, << Value:Length/binary,Rest/binary >> = TempRest, {Value,Rest}. This approach has served us well, but I would have liked to be able to do this more directly but the language does not allow it. Cheers, Torben On Sat, Mar 21, 2009 at 8:52 PM, Pete Stapley wrote: > I am attempting to parse some Radius attributes with Erlang and I have > run into a bit of a problem. I pass some binary data to parseAttributes > and I want to start peeling off the attributes one by one. I first peel > off Type which is one byte, then Length which is also one byte. Next I > want to peel off the Attribute. The Length variable is the length of the > attribute plus the Type and Length byte, so I have to subtract 2 bytes > from the Length variable before peeling off the attribute. I have tried > the method below without any luck. Is there a way to do this? > > Thanks, > > -define(BYTE, 8/unsigned-big-integer). > > parseAttributes(Bin) -> > parseAttributes(Bin, []). > > parseAttributes(<<>>, Atts) -> > {ok, Atts}; > %%problem is here, Length - 2 does not seem to work > parseAttributes( < Rest/binary>>, Atts) -> > io:format("Type: ~p Length: ~p Att:~p Length: ~p~n", [Type, Length, > Att, size(Rest)]), > parseAttributes(Rest, Atts). > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kaiduanx@REDACTED Sat Mar 21 23:55:05 2009 From: kaiduanx@REDACTED (Kaiduan Xie) Date: Sat, 21 Mar 2009 18:55:05 -0400 Subject: [erlang-questions] Binary Parsing In-Reply-To: <49C54576.5010602@rapidnet.com> References: <49C54576.5010602@rapidnet.com> Message-ID: Here Length is an un-bound variable, you can not use un-bound variable in Att:Length-2/binary, try to get Length first, then do another matching. parseAttributes(Bin, Atts) -> %% You get the Length first, then do another match <> = Bin, Len2 = Length -2, <> = Bin, .... On Sat, Mar 21, 2009 at 3:52 PM, Pete Stapley wrote: > I am attempting to parse some Radius attributes with Erlang and I have > run into a bit of a problem. I pass some binary data to parseAttributes > and I want to start peeling off the attributes one by one. I first peel > off Type which is one byte, then Length which is also one byte. Next I > want to peel off the Attribute. The Length variable is the length of the > attribute plus the Type and Length byte, so I have to subtract 2 bytes > from the Length variable before peeling off the attribute. I have tried > the method below without any luck. Is there a way to do this? > > Thanks, > > -define(BYTE, 8/unsigned-big-integer). > > parseAttributes(Bin) -> > parseAttributes(Bin, []). > > parseAttributes(<<>>, Atts) -> > {ok, Atts}; > %%problem is here, Length - 2 does not seem to work > parseAttributes( < Rest/binary>>, Atts) -> > io:format("Type: ~p Length: ~p Att:~p Length: ~p~n", [Type, Length, > Att, size(Rest)]), > parseAttributes(Rest, Atts). > _______________________________________________ > 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 Mar 22 03:51:59 2009 From: joe@REDACTED (Joe Williams) Date: Sat, 21 Mar 2009 19:51:59 -0700 Subject: [erlang-questions] inets:httpd in 13a Message-ID: <49C5A7CF.8020804@joetify.com> I seem to be having a couple issues with inets:httpd in 13a. Here's what I am seeing: > {ok, Pid} = inets:start(httpd, [{port, 4000}, {server_name, > "httpd_test"}, {server_root, "/tmp"}, {document_root, > "/opt/inets/htdocs"}, {bind_address, "0.0.0.0"}]). > ** exception error: no match of right hand side value {error,nxdomain} Putting a real address in the bind_address property or "localhost" does not work either. However using {bind_address, any} works properly in 13a. In 12b-5 the above works properly. Is this a bug or has there been a change to the API? Thanks. -Joe -- Name: Joseph A. Williams Email: joe@REDACTED Blog: http://www.joeandmotorboat.com/ From wolfmanjm@REDACTED Sun Mar 22 04:35:48 2009 From: wolfmanjm@REDACTED (wolfmanjm) Date: Sat, 21 Mar 2009 20:35:48 -0700 (PDT) Subject: [erlang-questions] Binary Parsing In-Reply-To: <49C54576.5010602@rapidnet.com> References: <49C54576.5010602@rapidnet.com> Message-ID: Actually Length is bound as it is bound in the preceding Expression, so what you are doing is valid I do it all the time, I think what you need to do is put parenthesis around... (Att:Length - 2)/binary as mentioned in the docs... "Used in a bit string construction, Value is an expression which should evaluate to an integer, float or bit string. If the expression is something else than a single literal or variable, it should be enclosed in parenthesis." On Mar 21, 12:52?pm, Pete Stapley wrote: > I am attempting to parse some Radius attributes with Erlang and I have > run into a bit of a problem. I pass some binary data to parseAttributes > and I want to start peeling off the attributes one by one. I first peel > off Type which is one byte, then Length which is also one byte. Next I > want to peel off the Attribute. The Length variable is the length of the > attribute plus the Type and Length byte, so I have to subtract 2 bytes > from the Length variable before peeling off the attribute. I have tried > the method below without any luck. Is there a way to do this? > > Thanks, > > -define(BYTE, 8/unsigned-big-integer). > > parseAttributes(Bin) -> > ? ? ?parseAttributes(Bin, []). > > parseAttributes(<<>>, Atts) -> > ? ? ?{ok, Atts}; > %%problem is here, Length - 2 does not seem to work > parseAttributes( < Rest/binary>>, Atts) -> > ? ? ?io:format("Type: ~p Length: ~p Att:~p Length: ~p~n", [Type, Length, > Att, size(Rest)]), > ? ? ?parseAttributes(Rest, Atts). > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions From wolfmanjm@REDACTED Sun Mar 22 04:52:30 2009 From: wolfmanjm@REDACTED (wolfmanjm) Date: Sat, 21 Mar 2009 20:52:30 -0700 (PDT) Subject: [erlang-questions] Binary Parsing In-Reply-To: References: <49C54576.5010602@rapidnet.com> Message-ID: Oops my bad the other posts didn't show up in the google mirror, I only saw the one that said the problem was Length being unbound, which it is, as I do that, however I have never tried using an expression and that apparently is not allowed, kind of a pity. On Mar 21, 8:35?pm, wolfmanjm wrote: > Actually Length is bound as it is bound in the preceding Expression, > so what you are doing is valid I do it all the time, I think what you > need to do is put parenthesis around... > > (Att:Length - 2)/binary > > as mentioned in the docs... > > "Used in a bit string construction, Value is an expression which > should evaluate to an integer, float or bit string. If the expression > is something else than a single literal or variable, it should be > enclosed in parenthesis." > > On Mar 21, 12:52?pm, Pete Stapley wrote: > > > I am attempting to parse some Radius attributes with Erlang and I have > > run into a bit of a problem. I pass some binary data to parseAttributes > > and I want to start peeling off the attributes one by one. I first peel > > off Type which is one byte, then Length which is also one byte. Next I > > want to peel off the Attribute. The Length variable is the length of the > > attribute plus the Type and Length byte, so I have to subtract 2 bytes > > from the Length variable before peeling off the attribute. I have tried > > the method below without any luck. Is there a way to do this? > > > Thanks, > > > -define(BYTE, 8/unsigned-big-integer). > > > parseAttributes(Bin) -> > > ? ? ?parseAttributes(Bin, []). > > > parseAttributes(<<>>, Atts) -> > > ? ? ?{ok, Atts}; > > %%problem is here, Length - 2 does not seem to work > > parseAttributes( < > Rest/binary>>, Atts) -> > > ? ? ?io:format("Type: ~p Length: ~p Att:~p Length: ~p~n", [Type, Length, > > Att, size(Rest)]), > > ? ? ?parseAttributes(Rest, Atts). > > _______________________________________________ > > erlang-questions mailing list > > erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions From tony@REDACTED Sun Mar 22 07:26:52 2009 From: tony@REDACTED (Tony Arcieri) Date: Sun, 22 Mar 2009 00:26:52 -0600 Subject: [erlang-questions] Python Generators In Erlang and constant memory usage In-Reply-To: <49C2EC1B.4040309@gmail.com> References: <49C2EC1B.4040309@gmail.com> Message-ID: I'd certainly love having this functionality in Reia 2009/3/19 Frederic T-H > First time posting here, I've been reading this mailing lists for a few > months now, programming Erlang for a few months too. > > Python and its most functionnal parts is what eventually brought me to > Erlang. One feature that I loved in Python and instantly noticed was not > available in Erlang was generators. Generators are basically normal > functions, except they return an iterator, letting you fetch each result one > by one, effectively letting you work with constant memory. An example of the > way Python does it: > > def gen(n): > i = 0 > while i yield i > i+=1 > return > > x = gen(2) > x.next() # returns 0 > x.next() # returns 1 > x.next() # throws an exception > > In python, using yield creates a 'next' method, which is automatically > called by most functions that can iterate over text, lists, tuples, > dictionaries, etc. > > The idea is to not load all the results from a function at once and pass it > around, but to send each part individually. > > As an example, say I have a result set consisting of 1000x5kb tuples > (whatever they contain) which I want to map a function over. The way Erlang > works, you'd need to have a list that is 5000kb in size in memory and > manipulate it every single time the mapped function iterates over it. > > The end goal is to attempt to bypass having to evaluate the whole result > set at once (heavy) and instead get each element individually (lighter). > This is especially good for smaller systems like phones, web tablets (Nokia) > or really anything with limited amounts of RAM. > > While possible to implement in Erlang, generators are quite problematic > because every list BIF at the moment only operates on complete lists. This > means adding generators in Erlang would require one to do something like > duplicate the lists module. > > This may not be the first time this whole idea is discussed, but fast > googling didn't reveal much so I've let myself write a small naive and > simple prototype of what the implementation could be. > > The idea is quite simple: Have a recursive function as a different spawned > process waiting to receive {Pid, next} before returning data. I've attached > the file demonstrating the implementation, but in case I got it wrong, I > also copy/pasted it there: http://pastebin.com/f31ae9731 > > What the implementation does: > > - define tail-recursive fibonacci functions, a normal one and a > generator version > - define mockups for the sum and fold (foldl) functions from the > list module adapted to generators > - short unscientific tests to compare performances. > > What it doesn't do: > > - consider any kind of safety in case there is an error in a generator > - contain anything past what you'd do for a proof of concept. > > > The way it works, a normal tail-recursive way to get all the fibonacci > numbers until the nth one could be done the following way: > > t_fib(1) -> [1]; > t_fib(2) -> [1,1]; > t_fib(L) -> t_fib(3,L,[1,1]). > > t_fib(L,L,[N1,N2|_]=F) -> > lists:reverse([N1+N2|F]); > t_fib(C, L, [N1,N2|_]=F) -> > t_fib(C+1,L,[N1+N2|F]). > > That's not the prettiest function in the world, but it still does the job. > Here's how it would be as a generator (with the macros I have defined in the > file): > > y_fib(L) -> > y_fib(1, L, 1, 0). > y_fib(L, L, N1 ,N2) -> > ?last_yield(N1+N2); > y_fib(C, L, N1, N2) -> > N = N1+N2, > ?yield(N), > y_fib(C+1, L, N2, N). > > The code overhead one gets writing it that way is minimal and denies the > need to use a list as an accumulator. > > The generator sum function is written the following way: > > sum({M,Gen,Args}) -> > Pid = spawn(M, Gen, Args), > sum(Pid,0). > sum(Pid,S) -> > Pid ! {self(), next}, > receive > {Pid, N} -> sum(Pid, S+N); > {Pid, N, done} -> S+N > end. > > Called with the custom sum function in the generators module (This could be > made better, I agree): > > > generators:sum({generators,y_fib,[100]}). 927372692193078999175 > > Now for performance, I've tested it with Erlang R13A. My computer: > AMD phenom 9950 quad-core 2.6ghz processor, 4gb RAM, Windows 7 Beta build > 7000 (32 bits). > batch_test/3 will compare both versions with a sequence/list of Fibonacci > numbers of length 10000 and 50000, 20 times each, and round the results > showing how much faster the generator is (1.0 is equal). > > 26> generators:batch_test(sum, 10000, 20). > 0.9438942747654998 > 27> generators:batch_test(sum, 50000, 20). > 2.406425935803285 > 28> generators:batch_test(fold, 10000, 20). > 0.6706634763086374 > 29> generators:batch_test(fold, 50000, 20). > 1.3918125332818239 > > This seems to show that using a generator scales much better, while > becoming faster as the list grows and becomes expansive to generate and > carry around. > > The real advantage, though, is the fact that using a function that won't > accumulate lots of data (sum, folds, foreach, all, any, nth, etc.) will be > done with constant memory. This is especially good for small systems or > scaling as a whole. > > The testing I've done is minimal, and while I don't expect the Erlang > community to jump on the idea and adopt it, I'm one of these people who'd > like to eventually use this in production code. What kind of stuff would you > see missing, or likely to cause trouble in the current implementation? > What ways would I have to test this giving better results? > > Any other comments, tips? Thanks in advance! (Have a nice day also.) > > -module(generators). > -author([{name,"Fred T-H"},{email, "mononcqc@REDACTED"}]). > -description("An example of generators implemented in erlang, > allowing to generate the equivalent of lists with constant memory."). > -vsn(0.0). > -export([t_fib/1, y_fib/1, sum/1, fold/3, test/2, batch_test/3]). > > % macros to make the creation of generators a tad more user-friendly. > -define(yield(X), receive {Pid, next} -> Pid ! {self(), X} end). > -define(last_yield(X), receive {Pid, next} -> Pid ! {self(), X, done} end). > %-compile(export_all). > > %% Tail-recursive fibonacci function. > t_fib(1) -> [1]; > t_fib(2) -> [1,1]; > t_fib(L) -> t_fib(3,L,[1,1]). > > t_fib(L,L,[N1,N2|_]=F) -> > lists:reverse([N1+N2|F]); > t_fib(C, L, [N1,N2|_]=F) -> > t_fib(C+1,L,[N1+N2|F]). > > %% Generator-like tail-recursive fibonacci function. > y_fib(L) -> > y_fib(1,L,1,0). > > y_fib(L,L,N1,N2) -> > ?last_yield(N1+N2); > y_fib(C, L, N1,N2) -> > N = N1+N2, > ?yield(N), > y_fib(C+1,L,N2,N). > > %% what the lists:sum version for generators could look like > sum({M,Gen,Args}) -> > Pid = spawn(M, Gen, Args), > sum(Pid,0). > sum(Pid,S) -> > Pid ! {self(), next}, > receive > {Pid, N} -> sum(Pid, S+N); > {Pid, N, done} -> S+N > end. > > %% ... and lists:foldl/3 (no foldr possible with generators). > fold(F, Acc,{M,Gen,Args}) when is_function(F,2) -> > Pid = spawn(M,Gen,Args), > fold(F, Acc, Pid); > fold(F, Acc, Pid) -> > Pid ! {self(), next}, > receive > {Pid, N} -> fold(F, F(N,Acc), Pid); > {Pid, N, done} -> F(N,Acc) > end. > > %% Comparing execution times of lists vs generators > test(fold,N) -> > erlang:statistics(wall_clock), > F = fun(X, Acc) -> > if X rem 2 == 0 -> Acc+1; > true -> Acc > end > end, > ?MODULE:fold(F, 0, {?MODULE, y_fib, [N]}), > io:format("generator ok~n"), > {_, T1} = erlang:statistics(wall_clock), > lists:foldl(F, 0, t_fib(N)), > io:format("list ok~n"), > {_, T2} = erlang:statistics(wall_clock), > if T1>0 -> {T1,T2, T2/T1}; > T2 == T1, T1 == 0 -> {T1,T2,1}; > true -> {T1,T2, '?'} > end; > test(sum, N) -> > erlang:statistics(wall_clock), > ?MODULE:sum({?MODULE, y_fib, [N]}), > io:format("generator ok~n"), > {_, T1} = erlang:statistics(wall_clock), > lists:sum(t_fib(N)), > io:format("list ok~n"), > {_, T2} = erlang:statistics(wall_clock), > if T1>0 -> {T1,T2, T2/T1}; > T2 == T1, T1 == 0 -> {T1,T2,1}; > true -> {T1,T2, '?'} > end. > > %% Testing lists vs generators many times. > batch_test(Type, N, Lim) -> > batch_test(Type, N, 0, Lim, 0). > batch_test(_Type,_N,Lim,Lim,Acc) -> > Acc/Lim; > batch_test(Type,N,Ct,Lim,Acc) -> > {_,_,X} = test(Type,N), > batch_test(Type,N,Ct+1,Lim,Acc+X). > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- Tony Arcieri medioh.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve.e.123@REDACTED Sun Mar 22 15:58:11 2009 From: steve.e.123@REDACTED (steve ellis) Date: Sun, 22 Mar 2009 10:58:11 -0400 Subject: [erlang-questions] to supervise or not to supervise In-Reply-To: References: <4cb4a7bf0903201242t2166af30rbba7fe44ee8800a1@mail.gmail.com> Message-ID: <4cb4a7bf0903220758t6f05e058g645385571d14c2c9@mail.gmail.com> Thanks Lennart and Mihai! Very helpful information. Lennart it's good to know about the intent behind supervisor's orignial design. I like Mihai's suggestion of having one supervisor supervise each process. This would get us most of the way there and it would be easy to implement. But is there any way in OTP to see when a supervisor reaches its max restarts? I know this is logged by the sasl error logger. But how would I trap/detect this event in my code to do something with it? It doesn't look like supervisor has a function like gen_server's handy terminate/2. Maybe it would make more sense in our case to have one gen_server process monitor a child gen_server process. The child could call a function in the parent when it terminates. This way we'd have access to the terminate function of the monitoring/supervising gen_server. The problem with this though is that we'd have to implement our own restart strategy behavior, which is what is so great about supervisor. This might be related to something more general that I've been wondering about (which I should post as a question in a new thread). How to tap into the sasl error logger so my system can do stuff with those events. For example I'd like to send these events to another machine via tcp. Thanks! Steve On Fri, Mar 20, 2009 at 5:29 PM, Mihai Balea wrote: > > On Mar 20, 2009, at 3:42 PM, steve ellis wrote: > > New to supervision trees and trying to figure out when to use them (and >> when not to)... >> >> I have bunch of spawned processes created through spawn_link. Want these >> processes to say running indefinitely. If one exits in an error state, we >> want to restart it N times. After N, we want to error log it, and stop >> trying to restart it. Perfect job for a one_to_one supervisor right? >> >> Well sort of. The problem is that when the max restarts for the error >> process is reached, the supervisor terminates all its children and itself. >> Ouch! (At least in our case). We'd rather that the supervisor just keep >> supervising all the children that are ok and not swallow everything up. >> >> The Design Principles appear to be saying that swallowing everything up is >> what supervisors are supposed to do when max restarts is reached which >> leaves me a little puzzled. Why would you want to kill the supervisor just >> because a child process is causing trouble? Seems a little harsh. >> >> Is this a case of me thinking supervisors are good for too many things? Is >> it that our case is better handled by simply spawning these processes and >> trapping exits on them, and restarting/error logging in the trap exit? >> > > As far as I know, the standard supervisor cannot behave the way you want it > to. > > So, at least until this type of behavior is added to the standard > supervisor, you can work around it with double layers of supervision. > Basically have one dedicated supervisor for each process you want to > supervise and, in turn, each dedicated supervisor is set up as a transient > child to one big supervisor. > > Mihai > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve.e.123@REDACTED Sun Mar 22 17:24:44 2009 From: steve.e.123@REDACTED (steve ellis) Date: Sun, 22 Mar 2009 12:24:44 -0400 Subject: [erlang-questions] to supervise or not to supervise In-Reply-To: <4cb4a7bf0903220758t6f05e058g645385571d14c2c9@mail.gmail.com> References: <4cb4a7bf0903201242t2166af30rbba7fe44ee8800a1@mail.gmail.com> <4cb4a7bf0903220758t6f05e058g645385571d14c2c9@mail.gmail.com> Message-ID: <4cb4a7bf0903220924g356b6d9atfb4a0d13e13d407f@mail.gmail.com> I just realized that the process that spawns my standalone supervisors would linked by default to the supervisors through its call to start_link to start the supervisors in the first place. So when a supervisor dies because it has reached its max restarts, the calling gen_server process will get an exit signal in its handle_info callback of {'EXIT', DeadSupervisorPid, reached_max_restart_intensity}. This is basic error handling stuff and it is where i would write my code to do something with the error. And now as I read the docs on handle_info/2 i see that that is where all system messages get sent which seems to answer my other question. So I think I'm on the right track. Please someone let me know if I'm missing something. Thanks! Steve On Sun, Mar 22, 2009 at 10:58 AM, steve ellis wrote: > Thanks Lennart and Mihai! Very helpful information. Lennart it's good to > know about the intent behind supervisor's orignial design. > > I like Mihai's suggestion of having one supervisor supervise each process. > This would get us most of the way there and it would be easy to implement. > > But is there any way in OTP to see when a supervisor reaches its max > restarts? I know this is logged by the sasl error logger. But how would I > trap/detect this event in my code to do something with it? > > It doesn't look like supervisor has a function like gen_server's handy > terminate/2. > > Maybe it would make more sense in our case to have one gen_server process > monitor a child gen_server process. The child could call a function in the > parent when it terminates. This way we'd have access to the terminate > function of the monitoring/supervising gen_server. The problem with this > though is that we'd have to implement our own restart strategy behavior, > which is what is so great about supervisor. > > This might be related to something more general that I've been wondering > about (which I should post as a question in a new thread). How to tap into > the sasl error logger so my system can do stuff with those events. For > example I'd like to send these events to another machine via tcp. > > Thanks! > > Steve > > > On Fri, Mar 20, 2009 at 5:29 PM, Mihai Balea wrote: > >> >> On Mar 20, 2009, at 3:42 PM, steve ellis wrote: >> >> New to supervision trees and trying to figure out when to use them (and >>> when not to)... >>> >>> I have bunch of spawned processes created through spawn_link. Want these >>> processes to say running indefinitely. If one exits in an error state, we >>> want to restart it N times. After N, we want to error log it, and stop >>> trying to restart it. Perfect job for a one_to_one supervisor right? >>> >>> Well sort of. The problem is that when the max restarts for the error >>> process is reached, the supervisor terminates all its children and itself. >>> Ouch! (At least in our case). We'd rather that the supervisor just keep >>> supervising all the children that are ok and not swallow everything up. >>> >>> The Design Principles appear to be saying that swallowing everything up >>> is what supervisors are supposed to do when max restarts is reached which >>> leaves me a little puzzled. Why would you want to kill the supervisor just >>> because a child process is causing trouble? Seems a little harsh. >>> >>> Is this a case of me thinking supervisors are good for too many things? >>> Is it that our case is better handled by simply spawning these processes and >>> trapping exits on them, and restarting/error logging in the trap exit? >>> >> >> As far as I know, the standard supervisor cannot behave the way you want >> it to. >> >> So, at least until this type of behavior is added to the standard >> supervisor, you can work around it with double layers of supervision. >> Basically have one dedicated supervisor for each process you want to >> supervise and, in turn, each dedicated supervisor is set up as a transient >> child to one big supervisor. >> >> Mihai >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tony@REDACTED Sun Mar 22 23:01:10 2009 From: tony@REDACTED (Tony Arcieri) Date: Sun, 22 Mar 2009 16:01:10 -0600 Subject: [erlang-questions] Memory allocator In-Reply-To: <6672d0160903210140m1682c753ydf20de9623a12327@mail.gmail.com> References: <6672d0160903210140m1682c753ydf20de9623a12327@mail.gmail.com> Message-ID: On Sat, Mar 21, 2009 at 2:40 AM, Bjorn Gustavsson wrote: > Yes, we have plans for addressing this issue, but not by switching > to another allocator. The Erlang emulator by default already uses its > own memory allocator. > Cool, glad to hear the problem is being worked on. -- Tony Arcieri medioh.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From mihai@REDACTED Sun Mar 22 23:11:38 2009 From: mihai@REDACTED (Mihai Balea) Date: Sun, 22 Mar 2009 18:11:38 -0400 Subject: [erlang-questions] to supervise or not to supervise In-Reply-To: <4cb4a7bf0903220924g356b6d9atfb4a0d13e13d407f@mail.gmail.com> References: <4cb4a7bf0903201242t2166af30rbba7fe44ee8800a1@mail.gmail.com> <4cb4a7bf0903220758t6f05e058g645385571d14c2c9@mail.gmail.com> <4cb4a7bf0903220924g356b6d9atfb4a0d13e13d407f@mail.gmail.com> Message-ID: <932C4B85-5919-4A98-A2BE-FC2412964A5B@hates.ms> On Mar 22, 2009, at 12:24 PM, steve ellis wrote: > I just realized that the process that spawns my standalone > supervisors would linked by default to the supervisors through its > call to start_link to start the supervisors in the first place. So > when a supervisor dies because it has reached its max restarts, the > calling gen_server process will get an exit signal in its > handle_info callback of {'EXIT', DeadSupervisorPid, > reached_max_restart_intensity}. This is basic error handling stuff > and it is where i would write my code to do something with the error. > > And now as I read the docs on handle_info/2 i see that that is where > all system messages get sent which seems to answer my other question. > > So I think I'm on the right track. Please someone let me know if I'm > missing something. Thanks! You are on the right track. However, keep in mind a few things: - You need to do this only if you need some sort of special handling of that error condition. If you don't need to do anything with it, except maybe some reporting, then a standard supervisor will do the trick. Personally, I would attempt to use standard OTP behaviours whenever I could, simply because the code was extensively tested and can be considered error-free for all intents and purposes. However, sometimes that is not always possible. - If you do end up writing code to supervise your own supervisors, make sure you handle all error conditions and shutdown sequences. Basically, I guess what I'm trying to say is, unless you know exactly what you're doing, it's a good idea to let OTP do its job. Cheers, Mihai From ulf@REDACTED Sun Mar 22 23:28:39 2009 From: ulf@REDACTED (Ulf Wiger) Date: Sun, 22 Mar 2009 23:28:39 +0100 Subject: [erlang-questions] to supervise or not to supervise In-Reply-To: <4cb4a7bf0903220758t6f05e058g645385571d14c2c9@mail.gmail.com> References: <4cb4a7bf0903201242t2166af30rbba7fe44ee8800a1@mail.gmail.com> <4cb4a7bf0903220758t6f05e058g645385571d14c2c9@mail.gmail.com> Message-ID: <8209f740903221528v653de63j7bdea0995896756c@mail.gmail.com> So when this question comes up it is customary for me to mention my extension of the supervisor behavior to allow tracking the number of restarts... (: http://erlang.org/pipermail/erlang-questions/2003-November/010763.html The way restart escalation currently works, I think it's wise in most cases to escalate all the way up as soon as the nearest supervisor is unable to resolve the situation. I've rarely seen an escalated issue resolve itself in the middle management layer. You either solve it close to the problem itself, or you solve it at the top - and try to expedite the work in the middle. (We're of course only talking Erlang supervisors here.) BR, Ulf W 2009/3/22 steve ellis : > Thanks Lennart and Mihai! Very helpful information. Lennart it's good to > know about the intent behind supervisor's orignial design. > > I like Mihai's suggestion of having one supervisor supervise each process. > This would get us most of the way there and it would be easy to implement. > > But is there any way in OTP to see when a supervisor reaches its max > restarts? I know this is logged by the sasl error logger. But how would I > trap/detect this event in my code to do something with it? > > It doesn't look like supervisor has a function like gen_server's handy > terminate/2. > > Maybe it would make more sense in our case to have one gen_server process > monitor a child gen_server process. The child could call a function in the > parent when it terminates. This way we'd have access to the terminate > function of the monitoring/supervising gen_server. The problem with this > though is that we'd have to implement our own restart strategy behavior, > which is what is so great about supervisor. > > This might be related to something more general that I've been wondering > about (which I should post as a question in a new thread). How to tap into > the sasl error logger so my system can do stuff with those events. For > example I'd like to send these events to another machine via tcp. > > Thanks! > > Steve > > On Fri, Mar 20, 2009 at 5:29 PM, Mihai Balea wrote: >> >> On Mar 20, 2009, at 3:42 PM, steve ellis wrote: >> >>> New to supervision trees and trying to figure out when to use them (and >>> when not to)... >>> >>> I have bunch of spawned processes created through spawn_link. Want these >>> processes to say running indefinitely. If one exits in an error state, we >>> want to restart it N times. After N, we want to error log it, and stop >>> trying to restart it. Perfect job for a one_to_one supervisor right? >>> >>> Well sort of. The problem is that when the max restarts for the error >>> process is reached, the supervisor terminates all its children and itself. >>> Ouch! (At least in our case). We'd rather that the supervisor just keep >>> supervising all the children that are ok and not swallow everything up. >>> >>> The Design Principles appear to be saying that swallowing everything up >>> is what supervisors are supposed to do when max restarts is reached which >>> leaves me a little puzzled. Why would you want to kill the supervisor just >>> because a child process is causing trouble? Seems a little harsh. >>> >>> Is this a case of me thinking supervisors are good for too many things? >>> Is it that our case is better handled by simply spawning these processes and >>> trapping exits on them, and restarting/error logging in the trap exit? >> >> As far as I know, the standard supervisor cannot behave the way you want >> it to. >> >> So, at least until this type of behavior is added to the standard >> supervisor, you can work around it with double layers of supervision. >> ?Basically have one dedicated supervisor for each process you want to >> supervise and, in turn, each dedicated supervisor is set up as a transient >> child to one big supervisor. >> >> Mihai >> > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From ok@REDACTED Mon Mar 23 02:49:07 2009 From: ok@REDACTED (Richard O'Keefe) Date: Mon, 23 Mar 2009 14:49:07 +1300 Subject: [erlang-questions] Reassigning variables In-Reply-To: References: <879778450903171338j5f47e27fm6b6016906dff0159@mail.gmail.com> <20AB5CF7-C396-42AB-AAD1-676FD2C8BC4C@cs.otago.ac.nz> <6DA014AD-3091-4938-B159-496CF1D1A8BE@cs.otago.ac.nz> Message-ID: <4D7E8724-4D69-402B-B056-C6AA8F7529BC@cs.otago.ac.nz> On 18 Mar 2009, at 7:07 pm, Matthew Dempsky wrote: > Also, here's a list of a few other functions in OTP that use numbered > variables: > > - zip:put_z_files/6 Looking at that one in a little more detail, the key numbered variable is Out0..Out6, and a trivial rewrite eliminates three of its versions. It's tracking the result of an Output function. Since Erlang processes are lightweight, I would be very tempted to replace the Output *function* with an Output *process*, which could eliminate the updates entirely. This is Joe Armstrong's well known "object = Erlang process" equivalence. Typically, in an OO language we would have had obj = new Thingy(...); ... obj.mutateOne(...); ... obj.mutateTwo(...); ... ans = obj.summary(); In a pure functional language we have State0 = new_Thingy_State(...), ... State1 = mutate_One(State0, ...), ... State2 = mutate_Two(State1, ...), ... Ans = summary(State2) In Erlang, we can do Origin = self(), Pid = spawn(fun () -> ... Origin ... end), ... Pid!{mutate_One, ...}, ... Pid!{mutate_Two, ...}, ... Pid!Summary, receive {summary,Pid,Ans} -> ok end This transformation would _work_ for the zip: module and it would definitely simplify the code. Not having tried it, I have no idea what it would do to performance. But it's already going through enough layers of function calls that it might be OK. From ok@REDACTED Mon Mar 23 03:13:21 2009 From: ok@REDACTED (Richard O'Keefe) Date: Mon, 23 Mar 2009 15:13:21 +1300 Subject: [erlang-questions] Reassigning variables In-Reply-To: References: <879778450903171338j5f47e27fm6b6016906dff0159@mail.gmail.com> <20AB5CF7-C396-42AB-AAD1-676FD2C8BC4C@cs.otago.ac.nz> <6DA014AD-3091-4938-B159-496CF1D1A8BE@cs.otago.ac.nz> Message-ID: <065B0337-6D57-403E-BECE-DEA72CA0579F@cs.otago.ac.nz> On 18 Mar 2009, at 7:07 pm, Matthew Dempsky wrote: > Also, here's a list of a few other functions in OTP that use numbered > variables: > > - zip:put_z_files/6 > - epp:predef_macros/1 predef_macros(File) -> Ms0 = dict:new(), Ms1 = dict:store({atom,'FILE'}, {none,[{string,1,File}]}, Ms0), Ms2 = dict:store({atom,'LINE'}, {none,[{integer,1,1}]}, Ms1), Ms3 = dict:store({atom,'MODULE'}, undefined, Ms2), Ms4 = dict:store({atom,'MODULE_STRING'}, undefined, Ms3), Ms5 = dict:store({atom,'BASE_MODULE'}, undefined, Ms4), Ms6 = dict:store({atom,'BASE_MODULE_STRING'}, undefined, Ms5), Machine = list_to_atom(erlang:system_info(machine)), Ms7 = dict:store({atom,'MACHINE'}, {none,[{atom,1,Machine}]}, Ms6), dict:store({atom,Machine}, {none,[{atom,1,true}]}, Ms7). This really doesn't need them. It would be better as predef_macros(File) -> Machine = list_to_atom(erlang:system_info(machine)), dict:from_list([ {{atom,'FILE'}, {none,[{string,1,File}]}}, {{atom,'LINE'}, {none,[{integer,1,1}]}}, {{atom,'MODULE'}, undefined}, {{atom,'MODULE_STRING'}, undefined}, {{atom,'BASE_MODULE'}, undefined}, {{atom,'BASE_MODULE_STRING'}, undefined}, {{atom,'MACHINE'}, {none,[{atom,1,Machine}]}}. {{atom,Machine}, {none,[{atom,1,true}]} ]). There's a tiny performance loss, but since it's done once per file, it's not worth worrying about. From steve.e.123@REDACTED Mon Mar 23 03:20:07 2009 From: steve.e.123@REDACTED (steve ellis) Date: Sun, 22 Mar 2009 22:20:07 -0400 Subject: [erlang-questions] to supervise or not to supervise In-Reply-To: <8209f740903221528v653de63j7bdea0995896756c@mail.gmail.com> References: <4cb4a7bf0903201242t2166af30rbba7fe44ee8800a1@mail.gmail.com> <4cb4a7bf0903220758t6f05e058g645385571d14c2c9@mail.gmail.com> <8209f740903221528v653de63j7bdea0995896756c@mail.gmail.com> Message-ID: <4cb4a7bf0903221920n227176bbn523a2c2c6dea0dbc@mail.gmail.com> Thanks Ulf and Mihai! Interesting stuff! Mihai I share your trust in OTP and am weary of extending it or using it in a way that's not conventional.I can see the rationale behind Ulf's tweak. I'm hoping our needs don't require doing anything outside of OTP (let me know what you think). Let my clarify what we're doing to try and test this assumption/hope. Here is the pattern we have: 1. A need to spawn a series of processes that stay running unless they exit abnormally more than N times. 2. The spawned processes aren't used/relied on by other processes for the system as a whole to function properly. They are autonomous (writing results to a central data store). 3. If one of these processes goes down we want to know about it, but it shouldn't bring the whole system down by cascading down a supervision tree. 4. If one of these processes dies, it shouldn't bring down a sibling process. 5. All of these spawned processes have the same restart strategy. To do this each process has its own supervisor (per Mihai'ssuggestion). This means we write two modules, one implementing the supervisor behavior and one implementing the gen_server behavior. We start our autonomous/standalone processes by starting a link to a "standalone" child supervisor (from a gen_server parent) and add a dynamic child gen_server process to the child supervisor. The children do their work. If one fails, we try to restart it a few times per the supervision strategy. If the max restarts are reached, the autonomous/standalone supervisor automatically sends an {'EXIT', DeadSupervisorPid, reached_max_restart_intensity} message to the gen_server parent that started it (this is the default behavior of any linked process; we don't write any code for it). We get the message in the parent gen_server's handle_info function and do something with it. I'm thinking this is all standard OTP stuff and that we're not doing anything that is a "bad idea". Am I right about this? Thanks! Steve Forwarded conversation Subject: to supervise or not to supervise ------------------------ From: *steve ellis* Date: Fri, Mar 20, 2009 at 3:42 PM To: erlang-questions@REDACTED New to supervision trees and trying to figure out when to use them (and when not to)... I have bunch of spawned processes created through spawn_link. Want these processes to say running indefinitely. If one exits in an error state, we want to restart it N times. After N, we want to error log it, and stop trying to restart it. Perfect job for a one_to_one supervisor right? Well sort of. The problem is that when the max restarts for the error process is reached, the supervisor terminates all its children and itself. Ouch! (At least in our case). We'd rather that the supervisor just keep supervising all the children that are ok and not swallow everything up. The Design Principles appear to be saying that swallowing everything up is what supervisors are supposed to do when max restarts is reached which leaves me a little puzzled. Why would you want to kill the supervisor just because a child process is causing trouble? Seems a little harsh. Is this a case of me thinking supervisors are good for too many things? Is it that our case is better handled by simply spawning these processes and trapping exits on them, and restarting/error logging in the trap exit? Thanks! Steve ---------- From: *Lennart ?hman* Date: Fri, Mar 20, 2009 at 5:23 PM To: steve ellis , "erlang-questions@REDACTED" < erlang-questions@REDACTED> Hi, as you have discovered there are a few different restart strategies available when designing a supervisor (e.g: one_for_one, one_for all). One can of course come up with more or less an infinite number of such strategies, each one with its own twist. The main idea and problem at the time when the supervisor behaviour was constructed was that you have a set of more or less permanent processes that implements a subsystem. There should not be any ?illegal? terminations (such that causes the supervisor to act) amongst the children. But, as we know, no non trivial system is completely correct, hence an occasional failure and following restart must be allowed. If we have repeated failures it may indicate that the problem concerns more than this subsystem, therefore the need to eventually escalate the restarts (or as you have discovered kill all children and itself). If you really want to achieve a situation where failures never escalates above a certain supervisor you can bump up the max-restart threshold and at the same time shorten the sliding window. It is a not uncommon mistake (in normal usage of supervisors J ) to have a too high max-restart-intensity in combination with a too short sliding window at a higher level supervisor. It may then be too long between escalation attempts by lower level supervisor for the same error, making a higher level supervisor not consider two failures amongst its children being the same error, and therefore not eventually escalate to its superior supervisor. Best Regards Lennart ------------------------------------------------------------- Lennart ?hman direct : +46 8 587 623 27 Sj?land & Thyselius Telecom AB cellular: +46 70 552 6735 H?lsingegatan 43, 10 th floor fax : +46 8 667 82 30 SE-113 31 STOCKHOLM, SWEDEN email : lennart.ohman@REDACTED *From:* erlang-questions-bounces@REDACTED [mailto: erlang-questions-bounces@REDACTED] *On Behalf Of *steve ellis *Sent:* den 20 mars 2009 20:42 *To:* erlang-questions@REDACTED *Subject:* [erlang-questions] to supervise or not to supervise ---------- From: *Mihai Balea* Date: Fri, Mar 20, 2009 at 5:29 PM To: steve ellis As far as I know, the standard supervisor cannot behave the way you want it to. So, at least until this type of behavior is added to the standard supervisor, you can work around it with double layers of supervision. Basically have one dedicated supervisor for each process you want to supervise and, in turn, each dedicated supervisor is set up as a transient child to one big supervisor. Mihai ---------- From: *steve ellis* Date: Sun, Mar 22, 2009 at 10:58 AM To: Mihai Balea , erlang-questions@REDACTED Thanks Lennart and Mihai! Very helpful information. Lennart it's good to know about the intent behind supervisor's orignial design. I like Mihai's suggestion of having one supervisor supervise each process. This would get us most of the way there and it would be easy to implement. But is there any way in OTP to see when a supervisor reaches its max restarts? I know this is logged by the sasl error logger. But how would I trap/detect this event in my code to do something with it? It doesn't look like supervisor has a function like gen_server's handy terminate/2. Maybe it would make more sense in our case to have one gen_server process monitor a child gen_server process. The child could call a function in the parent when it terminates. This way we'd have access to the terminate function of the monitoring/supervising gen_server. The problem with this though is that we'd have to implement our own restart strategy behavior, which is what is so great about supervisor. This might be related to something more general that I've been wondering about (which I should post as a question in a new thread). How to tap into the sasl error logger so my system can do stuff with those events. For example I'd like to send these events to another machine via tcp. Thanks! Steve ---------- From: *steve ellis* Date: Sun, Mar 22, 2009 at 12:24 PM To: erlang-questions@REDACTED I just realized that the process that spawns my standalone supervisors would linked by default to the supervisors through its call to start_link to start the supervisors in the first place. So when a supervisor dies because it has reached its max restarts, the calling gen_server process will get an exit signal in its handle_info callback of {'EXIT', DeadSupervisorPid, reached_max_restart_intensity}. This is basic error handling stuff and it is where i would write my code to do something with the error. And now as I read the docs on handle_info/2 i see that that is where all system messages get sent which seems to answer my other question. So I think I'm on the right track. Please someone let me know if I'm missing something. Thanks! Steve ---------- From: *Mihai Balea* Date: Sun, Mar 22, 2009 at 6:11 PM To: steve ellis Cc: erlang-questions@REDACTED You are on the right track. However, keep in mind a few things: - You need to do this only if you need some sort of special handling of that error condition. If you don't need to do anything with it, except maybe some reporting, then a standard supervisor will do the trick. Personally, I would attempt to use standard OTP behaviours whenever I could, simply because the code was extensively tested and can be considered error-free for all intents and purposes. However, sometimes that is not always possible. - If you do end up writing code to supervise your own supervisors, make sure you handle all error conditions and shutdown sequences. Basically, I guess what I'm trying to say is, unless you know exactly what you're doing, it's a good idea to let OTP do its job. Cheers, Mihai ---------- From: *Ulf Wiger* Date: Sun, Mar 22, 2009 at 6:28 PM To: steve ellis Cc: erlang-questions@REDACTED So when this question comes up it is customary for me to mention my extension of the supervisor behavior to allow tracking the number of restarts... (: http://erlang.org/pipermail/erlang-questions/2003-November/010763.html The way restart escalation currently works, I think it's wise in most cases to escalate all the way up as soon as the nearest supervisor is unable to resolve the situation. I've rarely seen an escalated issue resolve itself in the middle management layer. You either solve it close to the problem itself, or you solve it at the top - and try to expedite the work in the middle. (We're of course only talking Erlang supervisors here.) BR, Ulf W 2009/3/22 steve ellis : > _______________________________________________ > 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 Mon Mar 23 03:17:49 2009 From: ok@REDACTED (Richard O'Keefe) Date: Mon, 23 Mar 2009 15:17:49 +1300 Subject: [erlang-questions] Reassigning variables In-Reply-To: References: <879778450903171338j5f47e27fm6b6016906dff0159@mail.gmail.com> <20AB5CF7-C396-42AB-AAD1-676FD2C8BC4C@cs.otago.ac.nz> <6DA014AD-3091-4938-B159-496CF1D1A8BE@cs.otago.ac.nz> Message-ID: On 18 Mar 2009, at 7:07 pm, Matthew Dempsky wrote: > Also, here's a list of a few other functions in OTP that use numbered > variables: > > - erl_lint:post_traversal_check/2 This one is post_traversal_check(Forms, St0) -> St1 = check_behaviour(St0), St2 = check_deprecated(Forms, St1), St3 = check_imports(Forms, St2), St4 = check_inlines(Forms, St3), St5 = check_undefined_functions(St4), St6 = check_unused_functions(Forms, St5), St7 = check_bif_clashes(Forms, St6), St8 = check_specs_without_function(St7), St9 = check_functions_without_spec(Forms, St8), StA = check_unused_types(Forms, St9), StB = check_untyped_records(Forms, StA), check_unused_records(Forms, StB). which would be easier maintained as post_traversal_check(Forms, St) -> check_unused_records(Forms, check_untyped_records(Forms, check_unused_types(Forms, check_functions_without_spec(Forms, check_specs_without_function( check_bif_clashes(Forms, check_unused_functions(Forms, check_undefined_functions( check_inlines(Forms, check_imports(Forms, check_deprecated(Forms, check_behaviour( St)))))))))))). It would be even better if all the check_* functions had the same (Forms, St) -> St' interface, and we could do the fold-over-function-list trick. From ok@REDACTED Mon Mar 23 03:52:18 2009 From: ok@REDACTED (Richard O'Keefe) Date: Mon, 23 Mar 2009 15:52:18 +1300 Subject: [erlang-questions] Reassigning variables In-Reply-To: References: <879778450903171338j5f47e27fm6b6016906dff0159@mail.gmail.com> <20AB5CF7-C396-42AB-AAD1-676FD2C8BC4C@cs.otago.ac.nz> <6DA014AD-3091-4938-B159-496CF1D1A8BE@cs.otago.ac.nz> Message-ID: <4FD24DFF-9216-43D6-874F-02E30243D418@cs.otago.ac.nz> On 18 Mar 2009, at 7:07 pm, Matthew Dempsky wrote: > - global:resolved/5 This one is a little difficult to follow. Here's an excerpt: S3 = lists:foldl(fun(Node1, S1) -> cancel_resolved_locker(Node1, fun (Tag) -> cancel_locker(Node, S1, Tag) end), end, S, HisKnown), This computes S3 from S. It appears that it's only updating _part_ of the state, a list of 'resolvers'. As someone reading the code, I have to say that the numbered variables are very much the least of my worries. Indeed, to me they are a _help_, and if the numbering were consistent (which it isn't: S0 -> S -> S3) it would be more of a help. > > but instead to show that it's not just a bad practice limited to my > code. :P It's not limited to Dempsky's code. In *some* cases it is a bad practice and in others it is not. In no case is it a major or even to me a noticeable problem for readability. The examples I've checked so far fall into three groups: (A) cases where the numbered variables can be trivially eliminated; (B) cases where Haskell might use a Writer or State monad, and some support (-reader(T, ...) and -writer(T, ...) declarations) *might* help; (C) cases where some other data structure (such as a separate process or a 'smart' intermediate language) might completely eliminate the perceived need for state threading. However, the main impression I've got from this survey is that code that relies heavily on state threading in Erlang tends to be difficult to follow for reasons *other than* the numbered state variables. From ok@REDACTED Mon Mar 23 04:13:35 2009 From: ok@REDACTED (Richard O'Keefe) Date: Mon, 23 Mar 2009 16:13:35 +1300 Subject: [erlang-questions] How do I elegantly check many conditions? In-Reply-To: <769240e8-b6ed-4f41-bfd0-a970f483a083@h5g2000yqh.googlegroups.com> References: <769240e8-b6ed-4f41-bfd0-a970f483a083@h5g2000yqh.googlegroups.com> Message-ID: <955E4793-F015-4E4F-B4C2-B2CC845E2218@cs.otago.ac.nz> On 21 Mar 2009, at 2:20 am, ryeguy wrote: > So when a user sends a request to register an account, they send their > username, password, email, and other info. The registration function > must verify all of their data. An example would be: > > - verify email not in use > - verify username not in use > - verify username is alphanumeric > - verify all fields are above X characters long > - verify all fields are less than Y characters long > > Now I don't want to have a 5 level deep if or case statement, but what > other options do I have? For concreteness, let's suppose we have email_is_available(Info) -> ok | {no,Reason} user_syntax_ok(Info) -> ok | {no,Reason} user_is_available(Info) -> ok | {no,Reason} all_fields_long_enough(Info) -> ok | {no,Reason} all_fields_short_enough(Info) -> ok | {no,Reason} I'm assuming here that (a) the field size and syntax checks should be done first, as they just involve the data to hand (b) the availability checks should only be done with verified data (c) when a check fails you want the reason. In short, we want to compose checkers. So let's try that. compose_check(F1, F2) -> fun (Info) -> case F1(Info) of ok -> F2(Info) ; Failure -> Failure end end. Now we can do compose_check_list(Check_Funs) -> lists:foldl(fun compose_check/2, fun (_) -> ok end, Check_Funs). and compose_check_list([ fun all_fields_long_enough/1, fun all_fields_short_enough/1, fun user_syntax_ok/1, fun email_is_ available/1, fun user_is_available/1 ])(Info) Or we can avoid creating the intermediate functions and write check_all(_, []) -> ok; check_all(Info, [F|Fs]) -> case F(Info) of ok -> check_all(Info, Fs) ; Failure -> Failure end. ... check_all(Info, [ fun all_fields_long_enough/1, fun all_fields_short_enough/1, fun user_syntax_ok/1, fun email_is_available/1, fun user_is_available/1]) Or you could arrange your checkers to either return ok or to throw {check_failed,Reason}, and do try all_fields_long_enough(Info), all_fields_short_enough(Info), user_syntax_ok(Info), email_is_available(Info), user_is_available(Info) catch throw:{check_failed,Reason} -> {no,Reason} end From ok@REDACTED Mon Mar 23 04:20:50 2009 From: ok@REDACTED (Richard O'Keefe) Date: Mon, 23 Mar 2009 16:20:50 +1300 Subject: [erlang-questions] Monads in Erlang? In-Reply-To: <707529930903200819n285e8f7chdcfa47f3282fd5b6@mail.gmail.com> References: <6a3ae47e0903190940o798d06cbvd85ec2a60b52fb98@mail.gmail.com> <707529930903200819n285e8f7chdcfa47f3282fd5b6@mail.gmail.com> Message-ID: <2465CCD6-A7CE-450F-AC82-C60F8CD8AF2C@cs.otago.ac.nz> On 21 Mar 2009, at 4:19 am, Malcolm Dowse wrote: > Unlike Richard, I personally don't think that there is a very strong > case for trying to add monads to Erlang, because Erlang is such a > different language to Haskell. If you meant _this_ Richard, I don't believe I've ever said "there is a very strong case". I thought I've been saying that a desire for lots of numbered variables in Erlang is generally an indication that it's time for a redesign. I _do_ think it's interesting fun to think about what reader/writer support might look like, but if I though there was a very strong case for actually doing it, I'd write an EEP. Do I need to point out that Erlang already _has_ an assignment operation? That all of this updating of a state can already be done by putting the state in the process dictionary, if necessary creating a new process to ensure that it's safe? > So, in my opinion, if you were to add monads into Erlang, you would > just get a monad-like syntax, without any other benefits. And it's > debatable whether this is really an improvement - it's more concise, > but at the same time, more is hidden from view. "More is hidden from view" is *precisely* the improvement of interest. It's like saying "if you put salt on your food, all you'll do is make it more salty." If I wanted to see everything that was going on, I'd be programming in assembly code. From jeffm@REDACTED Mon Mar 23 07:12:06 2009 From: jeffm@REDACTED (jm) Date: Mon, 23 Mar 2009 17:12:06 +1100 Subject: [erlang-questions] leex and yecc spotting double newline Message-ID: <49C72836.4020402@ghostgun.com> Say the lexer definition contains, among other things, Definitions. W = [^=\s\r\n] WS = \s CR = \r NL = \n EQ = = Rules. {W}+ : {token, {word, TokenLine, TokenChars}}. {EQ} : {token, {eq, TokenLine, TokenChars}}. {WS}+ : {token, {ws, TokenLine, TokenChars}}. ({CR}|{NL}|{CR}{NL}) : {token, {nl, TokenLine, TokenChars}}. At the moment, the yecc definition file contains, Nonterminals request lines line lhs rhs words. Terminals eq word ws nl. Rootsymbol request. request -> lines : '$1'. lines -> line nl : ['$1']. lines -> line lines nl : ['$1'] ++ '$3'. line -> lhs eq rhs nl : {line, '$1', '$3'}. lhs -> word : {lhs, '$1'}. rhs -> words : {rhs, '$1'}. words -> word : ['$1']. words -> word ws words : ['$1', '$2'] ++ '$3'. and is designed to parse the postfix policy request (see http://www.postfix.org/SMTPD_POLICY_README.html) A couple of questions: 1) What do I put in the yecc file so the it can spot a double newline which is used to terminate a request? 2) When parsing the example at the above URL (minus the postfix version comments) it seems to have problems with the "sender=foo@REDACTED". Why? code used to parse example (based on code from http://hopper.squarespace.com/blog/2008/5/29/leex-and-yecc.html ): parse(Filename) -> {ok, InFile} = file:open(Filename, [read]), Acc = loop(InFile, []), file:close(InFile), postfix_policy_parser:parse(Acc). loop(InFile, Acc) -> case io:request(InFile, {get_until, prompt, postfix_policy_lexer, token, [1]}) of {ok, Token, EndLine} -> io:format("Token: ~p EndLine: ~p~n", [Token, EndLine]), loop(InFile, Acc ++ [Token]); {error, token} -> exit(scanning_error); {eof,_} -> Acc end. Of course any other pointers are welcomed. Jeff. From Lennart.Ohman@REDACTED Mon Mar 23 08:46:10 2009 From: Lennart.Ohman@REDACTED (=?iso-8859-1?Q?Lennart_=D6hman?=) Date: Mon, 23 Mar 2009 08:46:10 +0100 Subject: [erlang-questions] to supervise or not to supervise In-Reply-To: <4cb4a7bf0903220758t6f05e058g645385571d14c2c9@mail.gmail.com> References: <4cb4a7bf0903201242t2166af30rbba7fe44ee8800a1@mail.gmail.com> <4cb4a7bf0903220758t6f05e058g645385571d14c2c9@mail.gmail.com> Message-ID: Hi, there is a reason why there is no terminate function in a supervisor. For the supervisor recovery schem to be correct (seen from the over all systems perpective) supervisors *must* be free of errors. That is why the programmer is not given the chance of writing code that shall be executed in its context. (In the beginning, before someone destroyed it :-) the supervisor was written completely in its own module. Where there actually was a big part of copied code from the gen_server and general gen code. The reason for copying the code was of course to make sure that not something got "improved" when some other feature in OTP was inteed improved). But to your question, no there is no regular way of asking about the current intensity. But once again as I hinted in the previous mail. There is nothing that prevents you from adjusting the sliding window to make the supervisor never escalate restarts. Best Regards Lennart ------------------------------------------------------------------------------- Lennart ?hman phone: +46 8 587 623 27 Sj?land & Thyselius Telecom AB cell : +46 70 552 6735 H?lsingegatan 43, 10th floor fax : +46 8 667 8230 SE-113 31 STOCKHOLM, SWEDEN email: lennart.ohman@REDACTED ________________________________ From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of steve ellis Sent: den 22 mars 2009 15:58 To: Mihai Balea; erlang-questions@REDACTED Subject: Re: [erlang-questions] to supervise or not to supervise Thanks Lennart and Mihai! Very helpful information. Lennart it's good to know about the intent behind supervisor's orignial design. I like Mihai's suggestion of having one supervisor supervise each process. This would get us most of the way there and it would be easy to implement. But is there any way in OTP to see when a supervisor reaches its max restarts? I know this is logged by the sasl error logger. But how would I trap/detect this event in my code to do something with it? It doesn't look like supervisor has a function like gen_server's handy terminate/2. Maybe it would make more sense in our case to have one gen_server process monitor a child gen_server process. The child could call a function in the parent when it terminates. This way we'd have access to the terminate function of the monitoring/supervising gen_server. The problem with this though is that we'd have to implement our own restart strategy behavior, which is what is so great about supervisor. This might be related to something more general that I've been wondering about (which I should post as a question in a new thread). How to tap into the sasl error logger so my system can do stuff with those events. For example I'd like to send these events to another machine via tcp. Thanks! Steve On Fri, Mar 20, 2009 at 5:29 PM, Mihai Balea > wrote: On Mar 20, 2009, at 3:42 PM, steve ellis wrote: New to supervision trees and trying to figure out when to use them (and when not to)... I have bunch of spawned processes created through spawn_link. Want these processes to say running indefinitely. If one exits in an error state, we want to restart it N times. After N, we want to error log it, and stop trying to restart it. Perfect job for a one_to_one supervisor right? Well sort of. The problem is that when the max restarts for the error process is reached, the supervisor terminates all its children and itself. Ouch! (At least in our case). We'd rather that the supervisor just keep supervising all the children that are ok and not swallow everything up. The Design Principles appear to be saying that swallowing everything up is what supervisors are supposed to do when max restarts is reached which leaves me a little puzzled. Why would you want to kill the supervisor just because a child process is causing trouble? Seems a little harsh. Is this a case of me thinking supervisors are good for too many things? Is it that our case is better handled by simply spawning these processes and trapping exits on them, and restarting/error logging in the trap exit? As far as I know, the standard supervisor cannot behave the way you want it to. So, at least until this type of behavior is added to the standard supervisor, you can work around it with double layers of supervision. Basically have one dedicated supervisor for each process you want to supervise and, in turn, each dedicated supervisor is set up as a transient child to one big supervisor. Mihai -------------- next part -------------- An HTML attachment was scrubbed... URL: From zambal@REDACTED Mon Mar 23 11:02:42 2009 From: zambal@REDACTED (zambal) Date: Mon, 23 Mar 2009 03:02:42 -0700 (PDT) Subject: [erlang-questions] Thoughts about server abstraction and process management Message-ID: <4a2836ab-c55f-4d6e-ad04-659dac962cac@c11g2000yqj.googlegroups.com> Dear Community, Lately I have been thinking about different server abstractions in Erlang that could complement gen_server and it's cousins, because I regularly stumble up on these two issues with gen_server: 1. gen_server makes it easy to create robust servers, but it still needs quite some boiler plate code to get it working. Mostly because of code like: do_something(X) -> gen_server:call(?MODULE, {do_something, X}). Although the code above is not strictly needed when coding a gen_server, I'll find myself writing this kind of code a lot. 2. gen_servers don't seem to be suited very well for situations where you need to easily create multiple instances of a particular server. I should add to the above that I don't work professionally with Erlang (my workweek languages are C#, C++ and recently Objective C too) and that my knowledge of OTP is limited, so I realize that my concerns with gen_server might be because of lack of experience. If so, please let me know :-) However, assuming that my concerns are valid, lets continue with just the minimal code needed to get an alternative generic server running without worrying about error handling, timeouts, etc.: First, the generic server code %% begin yasa.erl (yet another server abstraction) -module(yasa). -export([new/2, client/1]). -export([behaviour_info/1]). behaviour_info(callbacks) -> [{init, 1}, {handler, 2}, {terminate, 1}]; behaviour_info(_Other) -> undefined. new(Mod, State) -> client(spawn(fun()-> server(Mod, Mod:init(State)) end)). client(Pid) -> fun(X) -> Pid ! {self(), X}, receive {Pid, Reply} -> Reply end end. server(Mod, State) -> receive {Pid, {stop}} -> Reply = Mod:terminate(State), Pid ! {self(), Reply}; {Pid, X} -> {Reply, NewState} = Mod:handler(X, State), Pid ! {self(), Reply}, server(Mod, NewState); _ -> server(Mod, State) end. %% end yasa.erl And here's an example using this generic server: %% begin stack.erl -module(stack). -export([new/0, init/1, handler/2, terminate/1]). -behaviour(yasa). new() -> yasa:new(?MODULE, []). init(S) -> io:format("stack server ~p started.~n", [self()]), S. handler({push, X}, S) -> {ok, [X|S]}; handler({pop}, [X|Xs]) -> {X, Xs}; handler({peek}, [X|Xs]) -> {X, [X|Xs]}; handler({map_to, AnotherStack, Fun}, [X|Xs]) -> R = AnotherStack({push, Fun(X)}), {R, Xs}; handler({size}, S) -> {length(S), S}. terminate({_}) -> goodbye. %% end stack.erl Now you can use this stack server like this: Eshell V5.6.5 (abort with ^G) 1> S1 = stack:new(). stack server <0.39.0> started. #Fun 2> S2 = stack:new(). stack server <0.41.0> started. #Fun 3> S1({push, 1}). ok 4> S2({push, 10}). ok 6> S2({peek}). 10 7> S1({map_to, S2, fun(X)-> X * 42 end}). ok 8> S1({size}). 0 10> S2({peek}). 42 11> S2({size}). 2 12> S1({stop}). goodbye The juicy bit in all this code here is the client/1 function in the yasa module. It returns a fun with the Pid of the spawned process encapsulated in it and it sends whatever term you pass to the spawned process. In my example, the fun's argument is always a tuple, even if the argument is a single atom, but that's just a personal preference in order to keep syntax consistent. I realize the resulting syntax looks a lot like invoking a method on an object in a OO language, but that's as far as I'm concerned just a side effect of having a compact syntax for sending messages to a particular process and waiting for a reply. I'm pretty happy with the result of all this and I can see myself using this solution in small Erlang projects, however I'm very curious what other people think of this generic server solution. To (hopefully) start off with some discussion, I'd like to add my own main concern with this solution: It's quite easy for processes to become orphaned the same way as it's easy to leak memory in languages with manual memory management. All you have to do is start a new server in a function without returning/ storing the server's client function or stopping the server. As soon as the function goes out of scope, there's no (sane) way to have access to this server anymore, just like you can't access memory anymore in a C program if a function allocates memory without freeing it or storing the pointer somewhere. Of course this problem is not unique to my generic server solution in Erlang, but I guess it's easier to make this error, since you normally don't have to think about clearing things up after having used a fun. So I was wondering if there ever have been any ideas about process management like how memory is managed in garbage collected languages? I don't know anything about the internals of garbage collectors, but I can imagine that something like reference counted Pids could work: as soon as the last reference to a Pid in an Erlang node is cleared by the garbage collector and there's still a process active with that Pid, it should be pretty safe to kill it. So let me summarize this for my standards unusually long e-mail with the question I had in my mind before starting to type all this: what do you think of my generic server solution and do you think my concerns about process management are valid? thanks for your time, vincent From adam@REDACTED Mon Mar 23 13:39:40 2009 From: adam@REDACTED (Adam Lindberg) Date: Mon, 23 Mar 2009 12:39:40 +0000 (GMT) Subject: [erlang-questions] How do I elegantly check many conditions? In-Reply-To: <3881703.90711237811859482.JavaMail.root@zimbra> Message-ID: <6588370.90731237811980293.JavaMail.root@zimbra> ----- "Hynek Vychodil" wrote: > One of Joe's suggestion: program success case code separated from > error > handling. You can make it in this way > > create_user(Email, UserName, Password) -> > try > ok = new_email(Email), > ok = valid_user_name(UserName), > ok = new_user(UserName), > ok = strong_password(Password), > ... > _create_user(Email, UserName, Password) > catch > error:{badmatch, email_in_use} -> do_something(); > error:{badmatch, invalid_user_name} -> do_something(); > error:{badmatch, user_exists} -> do_something(); > error:{badmatch, weak_password} -> do_something(); > ... > end. Why use badmatch? create_user(Email, UserName, Password) -> try is_new_email(Email), is_valid_user_name(UserName), is_new_user(UserName), is_strong_password(Password), ... _create_user(Email, UserName, Password) catch email_in_use -> do_something(); invalid_user_name -> do_something(); user_exists -> do_something(); weak_password -> do_something(); ... end. Validation functions can use throw: is_new_email(Email) -> case mnesia:dirty_read(email, Email) of [] -> ok; _Else -> throw(email_in_use) end. Cheers, Adam From adam@REDACTED Mon Mar 23 19:58:31 2009 From: adam@REDACTED (Adam Lindberg) Date: Mon, 23 Mar 2009 18:58:31 +0000 (GMT) Subject: [erlang-questions] How do I elegantly check many conditions? In-Reply-To: <9352626.91151237834160643.JavaMail.root@zimbra> Message-ID: <16509086.91171237834711723.JavaMail.root@zimbra> ----- "Hynek Vychodil" wrote: > If I have function like > > is_new_email(Email) -> > case mnesia:dirty_read(email, Email) of > [] -> ok; > _Else -> email_in_use > end. > > I can choose if use it as > > case is_new_email(Email) of > ok -> do_something(); > email_in_use -> do_something_other() > end This could be rewritten with a try and a throw (as I previously showed), so the developer is still able to choose. It is about the same amount of code as a case statement. The try statement also have the benefit of being able to fit more lines of code in a single statement than catch can. > > or as > > ok = is_new_email(Email); This will still throw a badmatch when the email address is in use. I don't see how that is so much better than a throw. Both will go uncatched if you don't do anything. > When You trow exception, I can't choose. > Don't make assumptions about what the caller will do with the results > of a > function (http://www.erlang.se/doc/programming_rules.shtml#HDR3) Like I said, there is no big difference. I just like throw since it allows for bigger flexibility when combining several statements. In the end, I guess it is a matter of taste and style. Cheers, Adam From vychodil.hynek@REDACTED Mon Mar 23 14:22:39 2009 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Mon, 23 Mar 2009 14:22:39 +0100 Subject: [erlang-questions] How do I elegantly check many conditions? In-Reply-To: <6588370.90731237811980293.JavaMail.root@zimbra> References: <3881703.90711237811859482.JavaMail.root@zimbra> <6588370.90731237811980293.JavaMail.root@zimbra> Message-ID: <4d08db370903230622w67a28822qe61740197b154e63@mail.gmail.com> On Mon, Mar 23, 2009 at 1:39 PM, Adam Lindberg wrote: > ----- "Hynek Vychodil" wrote: > > > One of Joe's suggestion: program success case code separated from > > error > > handling. You can make it in this way > > > > create_user(Email, UserName, Password) -> > > try > > ok = new_email(Email), > > ok = valid_user_name(UserName), > > ok = new_user(UserName), > > ok = strong_password(Password), > > ... > > _create_user(Email, UserName, Password) > > catch > > error:{badmatch, email_in_use} -> do_something(); > > error:{badmatch, invalid_user_name} -> do_something(); > > error:{badmatch, user_exists} -> do_something(); > > error:{badmatch, weak_password} -> do_something(); > > ... > > end. > > Why use badmatch? > > create_user(Email, UserName, Password) -> > try > is_new_email(Email), > is_valid_user_name(UserName), > is_new_user(UserName), > is_strong_password(Password), > ... > _create_user(Email, UserName, Password) > catch > email_in_use -> do_something(); > invalid_user_name -> do_something(); > user_exists -> do_something(); > weak_password -> do_something(); > ... > end. > > > Validation functions can use throw: > > is_new_email(Email) -> > case mnesia:dirty_read(email, Email) of > [] -> ok; > _Else -> throw(email_in_use) > end. > > Cheers, > Adam > If I have function like is_new_email(Email) -> case mnesia:dirty_read(email, Email) of [] -> ok; _Else -> email_in_use end. I can choose if use it as case is_new_email(Email) of ok -> do_something(); email_in_use -> do_something_other() end or as ok = is_new_email(Email); When You trow exception, I can't choose. Don't make assumptions about what the caller will do with the results of a function (http://www.erlang.se/doc/programming_rules.shtml#HDR3) -- --Hynek (Pichi) Vychodil Analyze your data in minutes. Share your insights instantly. Thrill your boss. Be a data hero! Try Good Data now for free: www.gooddata.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From tuscland@REDACTED Mon Mar 23 20:27:39 2009 From: tuscland@REDACTED (Camille Troillard) Date: Mon, 23 Mar 2009 20:27:39 +0100 Subject: [erlang-questions] Erlang/OTP 13A and Darwin Message-ID: Hello, Out of curiosity, can someone give us some details on the erlang VM and darwin 64 bits? Outside a much larger address space, which are the benefits of a 64bits VM? Best Regards, Camille -------------- next part -------------- An HTML attachment was scrubbed... URL: From bekesa@REDACTED Mon Mar 23 17:02:11 2009 From: bekesa@REDACTED (Andras Georgy Bekes) Date: Mon, 23 Mar 2009 17:02:11 +0100 Subject: [erlang-questions] Python Generators In Erlang and constant memory usage In-Reply-To: <49C34C45.1050108@erlang-consulting.com> References: <49C2EC1B.4040309@gmail.com> <49C34C45.1050108@erlang-consulting.com> Message-ID: <200903231702.11448.bekesa@sch.bme.hu> > This feels a bit reminiscent of lazy lists, which were > discussed at some length on the erlang list quite > recently (the year 2000, in fact): > http://erlang.org/pipermail/erlang-questions/2000-October/001875.html It is actually introduced (very shortly) in the documentation as well, in Programming Examples/Funs/Funs Which Return Funs/Infinite Lists. Georgy From ryeguy1@REDACTED Mon Mar 23 21:31:43 2009 From: ryeguy1@REDACTED (ryeguy) Date: Mon, 23 Mar 2009 13:31:43 -0700 (PDT) Subject: [erlang-questions] wread like functionality with an index read? Message-ID: It is best to use wread in the event that you read a record, modify it, and write it. Is there a way to get similar functionality (avoiding obtaining a read lock, then having to upgrade to a write lock) with a secondary index read? From kris_prieb@REDACTED Mon Mar 23 22:35:51 2009 From: kris_prieb@REDACTED (Kris Prieb) Date: Mon, 23 Mar 2009 16:35:51 -0500 Subject: [erlang-questions] where to find correct documentation for erlang distribution over SSL? Message-ID: <4537c3580903231435j507400ffn77b6eafe2e27e580@mail.gmail.com> I have been trying to start erlang distribution over SSL using SSL 3.10 in OTP R12-B5 by following Section 5 of the SSL User's Guide (http://www.erlang.org/doc/apps/ssl/usersguide_frame.html). ?I have gotten two nodes up, but I cannot get them to successfully net_adm:ping/1 each other.?(I get a pang not a pong). I only just read that the documentation for distribution over SSL is in fact not entirely correct. As noted in the release notes for SSL 3.10: "1.1.3 Known Bugs and Problems Running erlang distribution over ssl don't work as described in the documentation. Own Id: OTP-7536" Does anyone know where I might find correct documentation on erlang distribution over SSL, or alternatively, what parts of the current documentation are incorrect and how? Thanks in advance! Kris From vychodil.hynek@REDACTED Mon Mar 23 23:51:29 2009 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Mon, 23 Mar 2009 23:51:29 +0100 Subject: [erlang-questions] How do I elegantly check many conditions? In-Reply-To: <16509086.91171237834711723.JavaMail.root@zimbra> References: <9352626.91151237834160643.JavaMail.root@zimbra> <16509086.91171237834711723.JavaMail.root@zimbra> Message-ID: <4d08db370903231551k5bdadd4ex5a67e3657424e45@mail.gmail.com> On Mon, Mar 23, 2009 at 7:58 PM, Adam Lindberg wrote: > > ----- "Hynek Vychodil" wrote: > > If I have function like > > > > is_new_email(Email) -> > > case mnesia:dirty_read(email, Email) of > > [] -> ok; > > _Else -> email_in_use > > end. > > > > I can choose if use it as > > > > case is_new_email(Email) of > > ok -> do_something(); > > email_in_use -> do_something_other() > > end > > This could be rewritten with a try and a throw (as I previously showed), so > the developer is still able to choose. It is about the same amount of code > as a case statement. The try statement also have the benefit of being able > to fit more lines of code in a single statement than catch can. > > > > > or as > > > > ok = is_new_email(Email); > > This will still throw a badmatch when the email address is in use. I don't > see how that is so much better than a throw. Both will go uncatched if you > don't do anything. > > > When You trow exception, I can't choose. > > Don't make assumptions about what the caller will do with the results > > of a > > function (http://www.erlang.se/doc/programming_rules.shtml#HDR3) > > Like I said, there is no big difference. I just like throw since it allows > for bigger flexibility when combining several statements. > > In the end, I guess it is a matter of taste and style. > > Cheers, > Adam > 1/ Exception costs more than checking return value. In most cases it will not be issues but you can't assume that it will not be. When it happen, your code is less flexible. 2/ Flexibility is throw out when I want code like: is_new_email(Email1), is_new_email(Email2). Now I can't distinguish which one Email is wrong without catching throw in each statement. With my code it is easy: {ok, first_one} = {is_new_email(Email1), first_one}, {ok, second_one} = {is_new_email(Email2), second_one}. Again, your code is less flexible. Throwing exception when it is not necessary is less flexible. I can easily turn return value to exception but opposite way is harder. Explicit throwing exception *is* slower and less flexible! -- --Hynek (Pichi) Vychodil Analyze your data in minutes. Share your insights instantly. Thrill your boss. Be a data hero! Try Good Data now for free: www.gooddata.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From erlangy@REDACTED Tue Mar 24 00:01:58 2009 From: erlangy@REDACTED (Michael McDaniel) Date: Mon, 23 Mar 2009 16:01:58 -0700 Subject: [erlang-questions] where to find correct documentation for erlang distribution over SSL? In-Reply-To: <4537c3580903231435j507400ffn77b6eafe2e27e580@mail.gmail.com> References: <4537c3580903231435j507400ffn77b6eafe2e27e580@mail.gmail.com> Message-ID: <20090323230157.GO18122@delora.autosys.us> old, but possibly will assist ... http://trapexit.org/Distributed_erlang_using_ssl_through_firewalls ~M On Mon, Mar 23, 2009 at 04:35:51PM -0500, Kris Prieb wrote: > I have been trying to start erlang distribution over SSL using SSL > 3.10 in OTP R12-B5 by following Section 5 of the SSL User's Guide > (http://www.erlang.org/doc/apps/ssl/usersguide_frame.html). ?I have > gotten two nodes up, but I cannot get them to successfully > net_adm:ping/1 each other.?(I get a pang not a pong). I only just > read that the documentation for distribution over SSL is in fact not > entirely correct. As noted in the release notes for SSL 3.10: > > "1.1.3 Known Bugs and Problems > Running erlang distribution over ssl don't work as described in the > documentation. > Own Id: OTP-7536" > > Does anyone know where I might find correct documentation on erlang > distribution over SSL, or alternatively, what parts of the current > documentation are incorrect and how? > > Thanks in advance! > Kris > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- Michael McDaniel Portland, Oregon, USA http://autosys.us http://mmcdaniel.com/erlview From ryeguy1@REDACTED Mon Mar 23 15:17:50 2009 From: ryeguy1@REDACTED (ryeguy) Date: Mon, 23 Mar 2009 07:17:50 -0700 (PDT) Subject: [erlang-questions] How do I elegantly check many conditions? In-Reply-To: References: <769240e8-b6ed-4f41-bfd0-a970f483a083@h5g2000yqh.googlegroups.com> Message-ID: <297343f2-4293-45e1-8759-8de07e15b681@z9g2000yqi.googlegroups.com> Here is how I ended up doing it. I am mostly satisfied with it. register(#packet{data=[Username, Password, Email]}) -> User=#user{id = {node(), now()}, username = Username, password = Password, email = Email, reg_date = erlang:localtime()}, try ok=validate_username(Username), ok=validate_email(Email), ok=validate_password(Password), {atomic, _}=mnesia:transaction(fun() -> %check if username and email are unique {username, []}={username, mnesia:index_read(user, Username, #user.username)}, {email, []}={email, mnesia:index_read(user, Email, #user.email)}, mnesia:write(User) end), ok catch error:{badmatch,{password, false}} -> {error, ?E_PASSWORD_FORMAT}; error:{badmatch,{username, _, _}} -> {error, ?E_USRNAME_FORMAT}; error:{badmatch,{email, _, _, _}} -> {error, ?E_EMAIL_FORMAT}; error:{badmatch,{email, false}} -> {error, ?E_EMAIL_FORMAT}; error:{badmatch, {aborted, {{badmatch, {username, _}}, _}}} -> {error, ?E_USRNAME_IN_USE}; error:{badmatch, {aborted, {{badmatch, {email, _}}, _}}} -> {error, ? E_EMAIL_IN_USE} end. The only thing I kinda dislike is the badmatch catching for possible errors inside of the mnesia transaction. They're just sloppy looking. I know that I could use if or cases with mnesia:abort, but that would just further nest my transaction, give it more code, and be inconsistent with the pre-transaction checking (since I use pattern matching there, and I'd be using if/case in the transaction). Any suggestions at all? Or is this fine? On Mar 21, 1:37?am, Geoff Cant wrote: > ryeguy writes: > > So when a user sends a request to register an account, they send their > > username, password, email, and other info. The registration function > > must verify all of their data. An example would be: > > > ?- verify email not in use > > ?- verify username not in use > > ?- verify username is alphanumeric > > ?- verify all fields are above X characters long > > ?- verify all fields are less than Y characters long > > > Now I don't want to have a 5 level deep if or case statement, but what > > other options do I have? Splitting it into separate functions sounds > > like a good idea, but then I just have to check the return value of > > the functions in some sort of conditional and it's back to the > > original problem. > > > I could separate them into functions and then call an if statement > > with all of the conditionals OR'd together, but that wouldn't give me > > what I want because I need to be able to tell the user the specific > > error if there was one. > > > How does one handle this kind of situation in erlang? > > I ran into this when building a website recently and ended up building a > form validation > library. (http://github.com/archaelus/ejango/tree/master- the form > validation checking engine is located here,http://github.com/archaelus/ejango/blob/1d76e5c230e99725b815d258e889d...) > You can see examples of almost all the validation rules you gave above > in the unit tests for the form_validator module. There's some > documentation on how to specify them around line 109 in the > form_validator file. > > I was trying to create a DSL for declaratively specifying forms and the > rules for validating particular fields. E.g. {"user_email", > [email_address, not_empty, {predicate, fun > yourcode:check_email_in_use/1}]} Checks that the value of the form field > "user_email" is not the empty string, matches the regex for email > address validation and calling yourcode:check_email_in_use( "user_email" field>) returns true. The validation engine will report > errors for each rule given for a field so that you can give meaningul > error messages such as "Email address in use" and localise them if > necessary. > > The library has patchy edoc and some eunit test coverage - the validator > itself has edoc, but unfortunately the high level declarative form API > isn't documented well yet. It's on my todo list, but if someone beats me > to it I'd be happy to apply any patches. The library works well > enough that it has been used in a website I'm about to unveil soon. > > Cheers, > -- > Geoff Cant > > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions From chris.newcombe@REDACTED Tue Mar 24 01:20:33 2009 From: chris.newcombe@REDACTED (Chris Newcombe) Date: Mon, 23 Mar 2009 17:20:33 -0700 Subject: [erlang-questions] Enhancement to erlang:system_info ? Message-ID: <781dd98c0903231720r4c3d5041p4ec9dc4171316c1e@mail.gmail.com> Hello OTP team, I'm writing a memory-bounds feature for my system. (Erlang is fantastic in this regard -- it's wonderful to be able to examine memory-usage stats for individual or groups of processes, and perhaps force them to garbage-collect or even kill them, causing the minimum transitive restart via supervisors. I'm using Ulf's gproc library to classify processes by type, and prioritize them, so I can mimimize intrusiveness when choosing which processes to kill.) Part of this mechanism uses erlang:system_info with the 'large_heap' option -- that's a great facility. But I'm really missing a similar facility for detecting runaway creation of binaries. Please would you consider adding a 'large_binaries' option to erlang:system_info? This would send a message if a process allocates more than a total of N bytes of binaries. Of course, one issue with that is what does "allocate" mean when multiple processes can have references to the same binary? As erlang:system_info seems best for coarse-grain alarms, I think it would work fine if the event was triggered when a process was simply holding references to more than N bytes of binary data, even if other processes had references to some of that data. (The threshold should include the 'buffer' at the end of each binary -- e.g. the Efficiency Guide mentions that most short binaries actually allocate 256 bytes, incase they grow.) If such a feature is not acceptable/possible, would you consider adding a 'large_total_binaries' option? This would send a message if the total size of all binaries in the VM crossed a threshold. (I know I can poll for that via erlang:memory(binary), but binaries can be created very rapidly and I don't want to poll at some sub-second interval.) Many thanks, Chris (And congratulations on the R13A beta -- it looks fantastic!) -------------- next part -------------- An HTML attachment was scrubbed... URL: From stonecypher@REDACTED Tue Mar 24 02:12:25 2009 From: stonecypher@REDACTED (John Haugeland) Date: Mon, 23 Mar 2009 19:12:25 -0600 Subject: [erlang-questions] Installing a module from code? Message-ID: <8f24f4b10903231812v42237862wb404eebeb9b63424@mail.gmail.com> I've got a problem I don't fully understand. I keep wanting to call it a bug, but it may be that I'm handling this wrongly. During my attempt to compile and install a module from code, it seems I've managed to break the Erlang VMs I'm installing into. My gut instinct is that my namespaced module sc.file is somehow conflicting with the real module file. This is frustrating, because after my compile process it appears to work as expected; sc.file is treated differently than file, all package calls are resolved appropriately, etc. But, on next start, one gets the following error: Erlang (BEAM) emulator version 5.6.4 [smp:2] [async-threads:0] {"init terminating in do_boot",{undef, [{file,path_eval,[[".","C:\Users\John Haugeland"],".erlang"]}, {c,f_p_e,2},{init,eval_script,7},{init,do_boot,3}]}} Crash dump was written to: erl_crash.dump init terminating in do_boot () Abnormal termination (Formatted that a little to make it fit email) And I mean, that kind of looks like that's the Erlang VM saying "I have no function path_eval in module file", and as stupid as it sounds, the back of my mind is screaming "it's because sc.file overrides real .file". I have replicated this on Windows Vista HP-32 5.6.4, Windows Vista HP-32 5.5.5 and Centos4-32 5.6.4. All I have to do is run my install process, where everything appears to go kosher, then restart the Erlang VM. So, my method of "installing" is to take the source root directory and call .compile:file() progressively on each source file. Then I use .code:get_object_code() to get the binary and the filename, which I pass with the module name as an atom to .code:load_binary() to load the actual code (since :load.module() doesn't seem to understand package names). I'm actually going to show my install process twice, because there's a much shorter version and a much longer version. The shorter version is used to compile my string module, which contains utilities that the installer uses, so that it can turn around and install everything else. As such, it's a single special case and shows my expectation of The Right Way to do this in a very short space; that way if I'm just taking a numbskulled approach someone can point out my fool fault with little effort. Then I'm posting the long version, in case it's somehow importantly different than the string special case. But frankly, here's how this seems to me: I think the packaged modules are conflicting at boot time with the real thing. I can't imagine any other reason for do_boot to complain that a function that's part of the standard library is unavailable. If for whatever reason this code is unreadable, it can be gotten at http://scutil.com/ from /src/sc/installer.erl . I would recommend installing it on an isolated VM; calling the installer will prevent that VM from booting again. The short one (note that get_object_code seems only to work with the "un-packaged" name, which I worry is part of the problem): .compile:file(From++"/src/sc/string.erl"), {_, Bin, FileName} = .code:get_object_code(string), .code:load_binary('sc.string', FileName, Bin), The long one: compile_all(From, Options) -> ReportOnCompile = fun ( Module, error) -> { error, Module }; ( Module, {error, ErrorList, WarningList}) -> { error, Module, ErrorList, WarningList }; (_Module, {ok,AtomName}) -> AtomName; (_Module, {ok,AtomName, Warnings}) -> { AtomName, Warnings } end, IsFailureCase = fun ({ error,_Module }) -> true; ({ error,_Module,_ErrorList,_WarningList }) -> true; (_) -> false end, IsWarningCase = fun ({_ModuleAtom, [] }) -> false; ({_ModuleAtom,_Warnings }) -> true end, ToFilename = fun (List) when is_list(List) -> .sc.string:implode("/", [ atom_to_list(Item) || Item <- List ]) ++ ".erl"; (Atom) when is_atom(Atom) -> atom_to_list(Atom) ++ ".erl" end, Report = [ ReportOnCompile(From ++ ToFilename(File), .compile:file(From ++ ToFilename(File), Options)) || File <- contained_modules() ], { Fail, PassWarn } = .lists:partition(IsFailureCase, Report), { Warn, Pass } = .lists:partition(IsWarningCase, PassWarn), LoadFile = fun(Passed) -> [LastPiece|_] = .lists:reverse(.sc.string:explode(".", atom_to_list(Passed))), {_, Bin, FileName} = .code:get_object_code(list_to_atom(LastPiece)), .code:load_binary(Passed, FileName, Bin) end, [ LoadFile(Passed) || {Passed,[]} <- Pass ], { { pass, Pass }, { warn, Warn }, { fail, Fail } }. I know it's a lot to ask, but I could use some help sorting this out; these parts of the standard library aren't well documented, and I wouldn't want to think one could break an erlang install by compiling and loading modules containing correct code under a name which should not but does conflict. I really want there to be a stupid mistake on my part here. Any help would be greatly appreciated. -------------- next part -------------- An HTML attachment was scrubbed... URL: From stonecypher@REDACTED Tue Mar 24 02:25:19 2009 From: stonecypher@REDACTED (John Haugeland) Date: Mon, 23 Mar 2009 19:25:19 -0600 Subject: [erlang-questions] Er, one more detail, sorry Message-ID: <8f24f4b10903231825y2ea5f759hb33f4b4453f3547a@mail.gmail.com> I should have mentioned this in the previous mail; my bad. I'm pretty sure my compile options aren't involved, but for the sake of being complete, here's what I'm using: [debug_info, return, warn_export_all, warn_export_vars, warn_obsolete_guard, warn_unused_import] -------------- next part -------------- An HTML attachment was scrubbed... URL: From kris_prieb@REDACTED Tue Mar 24 04:29:53 2009 From: kris_prieb@REDACTED (Kris Prieb) Date: Mon, 23 Mar 2009 22:29:53 -0500 Subject: [erlang-questions] where to find correct documentation for erlang distribution over SSL? In-Reply-To: <4537c3580903231435j507400ffn77b6eafe2e27e580@mail.gmail.com> References: <4537c3580903231435j507400ffn77b6eafe2e27e580@mail.gmail.com> Message-ID: <4537c3580903232029m2a6e3275ocec4d69ebdead924@mail.gmail.com> Michael, I'm already familiar with the contents at the link you mentioned through a lot of googling, but thanks anyway. After some further noodling around I've been able to establish an SSL connection to a single node where I've created the initiating (non-erlang node) end point myself using the SSL application. I still am unable get the full erlang distribution running on SSL, however, so I remain open to suggestions. Kris ------------------------------------------------------------------------------------------------------------- Date: Mon, 23 Mar 2009 16:01:58 -0700 From: Michael McDaniel Subject: Re: [erlang-questions] where to find correct documentation for erlang distribution over SSL? To: erlang-questions@REDACTED Message-ID: <20090323230157.GO18122@REDACTED> Content-Type: text/plain; charset=iso-8859-1 old, but possibly will assist ... http://trapexit.org/Distributed_erlang_using_ssl_through_firewalls ~M On Mon, Mar 23, 2009 at 04:35:51PM -0500, Kris Prieb wrote: > I have been trying to start erlang distribution over SSL using SSL > 3.10 in OTP R12-B5 by following Section 5 of the SSL User's Guide > (http://www.erlang.org/doc/apps/ssl/usersguide_frame.html). ?I have > gotten two nodes up, but I cannot get them to successfully > net_adm:ping/1 each other.?(I get a pang not a pong). I only just > read that the documentation for distribution over SSL is in fact not > entirely correct. As noted in the release notes for SSL 3.10: > > "1.1.3 Known Bugs and Problems > Running erlang distribution over ssl don't work as described in the > documentation. > Own Id: OTP-7536" > > Does anyone know where I might find correct documentation on erlang > distribution over SSL, or alternatively, what parts of the current > documentation are incorrect and how? > > Thanks in advance! > Kris > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- Michael McDaniel Portland, Oregon, USA http://autosys.us http://mmcdaniel.com/erlview From ryeguy1@REDACTED Tue Mar 24 04:18:33 2009 From: ryeguy1@REDACTED (ryeguy) Date: Mon, 23 Mar 2009 20:18:33 -0700 (PDT) Subject: [erlang-questions] How do you transform a record properly? Message-ID: How would you add a field to a table using mnesia:table_transform? I got it to work by just using a raw tuple in the function header, but how do you match the old record, then output the new record with just the new field added/changed? From erlangy@REDACTED Tue Mar 24 06:01:34 2009 From: erlangy@REDACTED (Michael McDaniel) Date: Mon, 23 Mar 2009 22:01:34 -0700 Subject: [erlang-questions] where to find correct documentation for erlang distribution over SSL? In-Reply-To: <4537c3580903232029m2a6e3275ocec4d69ebdead924@mail.gmail.com> References: <4537c3580903231435j507400ffn77b6eafe2e27e580@mail.gmail.com> <4537c3580903232029m2a6e3275ocec4d69ebdead924@mail.gmail.com> Message-ID: <20090324050133.GQ18122@delora.autosys.us> Hey, Kris - a couple things ... * /home/.erlang.cookie is same on both nodes ? or from erl shell, 1> erlang:set_cookie(node(), some_secret_cookie). 2> erlang:get_cookie(). 'some_secret_cookie' 3> * do they 'pong' without SSL ? * probably you already checked your firewall ports On Mon, Mar 23, 2009 at 10:29:53PM -0500, Kris Prieb wrote: > Michael, I'm already familiar with the contents at the link you > mentioned through a lot of googling, but thanks anyway. > > After some further noodling around I've been able to establish an SSL > connection to a single node where I've created the initiating > (non-erlang node) end point myself using the SSL application. I still > am unable get the full erlang distribution running on SSL, however, so > I remain open to suggestions. > > Kris > > ------------------------------------------------------------------------------------------------------------- > Date: Mon, 23 Mar 2009 16:01:58 -0700 > From: Michael McDaniel > Subject: Re: [erlang-questions] where to find correct documentation > for erlang distribution over SSL? > To: erlang-questions@REDACTED > Message-ID: <20090323230157.GO18122@REDACTED> > Content-Type: text/plain; charset=iso-8859-1 > > > old, but possibly will assist ... > > > http://trapexit.org/Distributed_erlang_using_ssl_through_firewalls > > > ~M > > > On Mon, Mar 23, 2009 at 04:35:51PM -0500, Kris Prieb wrote: > > I have been trying to start erlang distribution over SSL using SSL > > 3.10 in OTP R12-B5 by following Section 5 of the SSL User's Guide > > (http://www.erlang.org/doc/apps/ssl/usersguide_frame.html). ?I have > > gotten two nodes up, but I cannot get them to successfully > > net_adm:ping/1 each other.?(I get a pang not a pong). I only just > > read that the documentation for distribution over SSL is in fact not > > entirely correct. As noted in the release notes for SSL 3.10: > > > > "1.1.3 Known Bugs and Problems > > Running erlang distribution over ssl don't work as described in the > > documentation. > > Own Id: OTP-7536" > > > > Does anyone know where I might find correct documentation on erlang > > distribution over SSL, or alternatively, what parts of the current > > documentation are incorrect and how? > > > > Thanks in advance! > > Kris > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > -- > Michael McDaniel > Portland, Oregon, USA > http://autosys.us > http://mmcdaniel.com/erlview > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From ulf.wiger@REDACTED Tue Mar 24 08:43:24 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Tue, 24 Mar 2009 08:43:24 +0100 Subject: [erlang-questions] Installing a module from code? In-Reply-To: <8f24f4b10903231812v42237862wb404eebeb9b63424@mail.gmail.com> References: <8f24f4b10903231812v42237862wb404eebeb9b63424@mail.gmail.com> Message-ID: <49C88F1C.90509@erlang-consulting.com> John Haugeland wrote: > My gut instinct is that my namespaced module sc.file is somehow > conflicting with the real module file. A loong time ago, when I played around with packages, I noticed that dotted file names didn't go well with embedded boot code loading. It was the erl_prim_loader module, I think. Even if you're not using embedded code loading, the kernel and stdlib modules are always pre-loaded. I have no idea if this issue was ever addressed. http://erlang.org/pipermail/erlang-questions/2003-November/010741.html BR, Ulf W -- Ulf Wiger CTO, Erlang Training & Consulting Ltd http://www.erlang-consulting.com From steven.charles.davis@REDACTED Tue Mar 24 10:04:25 2009 From: steven.charles.davis@REDACTED (Steve Davis) Date: Tue, 24 Mar 2009 02:04:25 -0700 (PDT) Subject: [erlang-questions] where to find correct documentation for erlang distribution over SSL? In-Reply-To: <4537c3580903232029m2a6e3275ocec4d69ebdead924@mail.gmail.com> References: <4537c3580903231435j507400ffn77b6eafe2e27e580@mail.gmail.com> <4537c3580903232029m2a6e3275ocec4d69ebdead924@mail.gmail.com> Message-ID: I have also not yet convinced Inets SSL to work. I spent a good while on it in R12B, and tried again briefly with R13A with no luck... ...but maybe it's redundant in any case as you'd likely be fronting your inets with NginX or something in production. So, for me it's just a development phase irritation. /s On Mar 23, 10:29?pm, Kris Prieb wrote: > Michael, I'm already familiar with the contents at the link you > mentioned through a lot of googling, but thanks anyway. > > After some further noodling around I've been able to establish an SSL > connection to a single node where I've created the initiating > (non-erlang node) end point myself using the SSL application. ?I still > am unable get the full erlang distribution running on SSL, however, so > I remain open to suggestions. > > Kris > > --------------------------------------------------------------------------- ---------------------------------- > Date: Mon, 23 Mar 2009 16:01:58 -0700 > From: Michael McDaniel > Subject: Re: [erlang-questions] where to find correct documentation > ? ? ? ?for ? ? erlang distribution over SSL? > To: erlang-questi...@REDACTED > Message-ID: <20090323230157.GO18122@REDACTED> > Content-Type: text/plain; charset=iso-8859-1 > > ?old, but possibly will assist ... > > ?http://trapexit.org/Distributed_erlang_using_ssl_through_firewalls > > ~M > > > > > > On Mon, Mar 23, 2009 at 04:35:51PM -0500, Kris Prieb wrote: > > I have been trying to start erlang distribution over SSL using SSL > > 3.10 in OTP R12-B5 by following Section 5 of the SSL User's Guide > > (http://www.erlang.org/doc/apps/ssl/usersguide_frame.html). ?I have > > gotten two nodes up, but I cannot get them to successfully > > net_adm:ping/1 each other.?(I get a pang not a pong). ?I only just > > read that the documentation for distribution over SSL is in fact not > > entirely correct. ?As noted in the release notes for SSL 3.10: > > > "1.1.3 Known Bugs and Problems > > Running erlang distribution over ssl don't work as described in the > > documentation. > > Own Id: OTP-7536" > > > Does anyone know where I might find correct documentation on erlang > > distribution over SSL, or alternatively, what parts of the current > > documentation are incorrect and how? > > > Thanks in advance! > > Kris > > _______________________________________________ > > erlang-questions mailing list > > erlang-questi...@REDACTED > >http://www.erlang.org/mailman/listinfo/erlang-questions > > -- > Michael McDaniel > Portland, Oregon, USAhttp://autosys.ushttp://mmcdaniel.com/erlview > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions From dmitriid@REDACTED Tue Mar 24 11:18:19 2009 From: dmitriid@REDACTED (Dmitrii Dimandt) Date: Tue, 24 Mar 2009 12:18:19 +0200 Subject: [erlang-questions] minilight benchmark Message-ID: <1C5199B5-C3FF-4FD1-836B-14E0AE3B9D87@gmail.com> http://www.hxa.name/minilight/ Is anyone doing an Erlang version? -------------- next part -------------- An HTML attachment was scrubbed... URL: From adam@REDACTED Tue Mar 24 14:48:37 2009 From: adam@REDACTED (Adam Lindberg) Date: Tue, 24 Mar 2009 13:48:37 +0000 (GMT) Subject: [erlang-questions] How do I elegantly check many conditions? In-Reply-To: <27110039.92561237902320511.JavaMail.root@zimbra> Message-ID: <18897457.92581237902517556.JavaMail.root@zimbra> ----- "Hynek Vychodil" wrote: > 1/ Exception costs more than checking return value. In most cases it > will > not be issues but you can't assume that it will not be. When it > happen, your > code is less flexible. > 2/ Flexibility is throw out when I want code like: > is_new_email(Email1), > is_new_email(Email2). > Now I can't distinguish which one Email is wrong without catching > throw in > each statement. With my code it is easy: > {ok, first_one} = {is_new_email(Email1), first_one}, > {ok, second_one} = {is_new_email(Email2), second_one}. > Again, your code is less flexible. Well, just throw {email_in_use, Email} then? Using tagged tuples just for pattern matching (and really just to make the badmatch error more informative) isn't very readable. It just adds a lot of clutter. With the try statement, you CAN have several expression in the same block. You can't have that with a case statement. Unless you accept executing them both to know if either one failed, like in case {a(), b() of {true, true} or something. > Throwing exception when it is not necessary is less flexible. I can > easily > turn return value to exception but opposite way is harder. Explicit > throwing > exception *is* slower and less flexible! Performance is rarely an issue in real life code with these kind of constructs. If it is, you probably have bigger problems than changing all your try statements to catch statements. It is not harder to change throw to a return value, than a return value to a throw. Either way you're doing it, it is the same amount of code. Exceptions are used for exceptional things, like for example when a user tries to register with an email already in use. Probably the same user or another user who misspelled, not really that common to be a performance bottleneck. It is also nice to use throw since it is a developer intended exception and is very visible when it is not catched. If you get a badmatch somewhere high up in your code then you probably have a bug somewher. If you get an uncatched throw, then you know you haven't implement the necessary code to handle the exception. Cheers, Adam From masse@REDACTED Tue Mar 24 16:27:37 2009 From: masse@REDACTED (mats cronqvist) Date: Tue, 24 Mar 2009 16:27:37 +0100 Subject: [erlang-questions] How do I elegantly check many conditions? In-Reply-To: <4d08db370903231551k5bdadd4ex5a67e3657424e45@mail.gmail.com> (Hynek Vychodil's message of "Mon\, 23 Mar 2009 23\:51\:29 +0100") References: <9352626.91151237834160643.JavaMail.root@zimbra> <16509086.91171237834711723.JavaMail.root@zimbra> <4d08db370903231551k5bdadd4ex5a67e3657424e45@mail.gmail.com> Message-ID: <87k56fdjpy.fsf@sterlett.hq.kred> Hynek Vychodil writes: > On Mon, Mar 23, 2009 at 7:58 PM, Adam Lindberg > wrote: > > ----- "Hynek Vychodil" wrote: > > If I have function like > > > > is_new_email(Email) -> > > ?case mnesia:dirty_read(email, Email) of > > ? ?[] ? ?-> ok; > > ? ?_Else -> email_in_use > > ?end. > > > > I can choose if use it as > > > > case is_new_email(Email) of > > ? ok -> do_something(); > > ? email_in_use -> do_something_other() > > end > > This could be rewritten with a try and a throw (as I previously showed), > so the developer is still able to choose. It is about the same amount of > code as a case statement. The try statement also have the benefit of being > able to fit more lines of code in a single statement than catch can. > > > > > or as > > > > ok = is_new_email(Email); > > This will still throw a badmatch when the email address is in use. I don't > see how that is so much better than a throw. Both will go uncatched if you > don't do anything. > > > When You trow exception, I can't choose. > > Don't make assumptions about what the caller will do with the results > > of a > > function (http://www.erlang.se/doc/programming_rules.shtml#HDR3) > > Like I said, there is no big difference. I just like throw since it allows > for bigger flexibility when combining several statements. > > In the end, I guess it is a matter of taste and style. > > Cheers, > Adam > > 1/ Exception costs more than checking return value. In most cases it will not > be issues but you can't assume that it will not be. When it happen, your code > is less flexible. If the exception is generated. Presumably, the exception is only thrown relatively rarely, in which case you win. > Throwing exception when it is not necessary is less flexible. I can easily > turn return value to exception but opposite way is harder. Explicit throwing > exception *is* slower and less flexible! Well, no. mats From devdoer2@REDACTED Tue Mar 24 18:31:54 2009 From: devdoer2@REDACTED (devdoer bird) Date: Wed, 25 Mar 2009 01:31:54 +0800 Subject: [erlang-questions] Is there a mature xmpp cllient for erlang? Message-ID: HI: Is there a mature xmpp client for erlang? I tried jabberlang( https://support.process-one.net/doc/display/CONTRIBS/Jabberlang),bug it failed to work with recent ejabberd because it use old ejabberd package's xml stream function . I found exmpp would replace the jabberlang ,but I found it nowhere. So anyone can give a mature xmpp client? -------------- next part -------------- An HTML attachment was scrubbed... URL: From stonecypher@REDACTED Tue Mar 24 17:52:37 2009 From: stonecypher@REDACTED (John Haugeland) Date: Tue, 24 Mar 2009 10:52:37 -0600 Subject: [erlang-questions] Installing a module from code? In-Reply-To: <49C88F1C.90509@erlang-consulting.com> References: <8f24f4b10903231812v42237862wb404eebeb9b63424@mail.gmail.com> <49C88F1C.90509@erlang-consulting.com> Message-ID: <8f24f4b10903240952g1ad822f0r1b0177d3d0f26aab@mail.gmail.com> Well it's good to know it isn't my imagination, at least, though it's rather concerning that this has been known since 2003. There's actually another looming problem. Package names aren't resolved correctly during conflict after a boot. My current assumption is that the only reason they work correctly before a boot is because they're loaded after compiling into the runtime. ----------------------- -module(a.foo). -export([shared/0, unique_a/0]). shared() -> "I am a.foo". unique_a() -> "I am a.foo's unique.". ----------------------- -module(b.foo). -export([shared/0, unique_b/0]). shared() -> "I am b.foo". unique_b() -> "I am b.foo's unique.". ----------------------- -module(c.foo). -export([shared/0, unique_c/0]). shared() -> "I am c.foo". unique_c() -> "I am c.foo's unique.". ----------------------- If you compile each of those, they will all work as expected until you reboot the VM. 7> c("/scratch/a/foo.erl"). {ok,'a.foo'} 8> c("/scratch/b/foo.erl"). {ok,'b.foo'} 9> c("/scratch/c/foo.erl"). {ok,'c.foo'} 10> a.foo:shared(). "I am a.foo" 11> b.foo:shared(). "I am b.foo" 12> c.foo:shared(). "I am c.foo" After you reboot the VM, you will no longer be able to call any of them directly. 2> a.foo:shared(). ** exception error: undefined function 'a.foo':shared/0 3> b.foo:shared(). ** exception error: undefined function 'b.foo':shared/0 4> c.foo:shared(). ** exception error: undefined function 'c.foo':shared/0 If you pretend there's no namespace, Erlang will clearly expose that the binary is the last one compiled. 5> foo:shared(). ** exception error: undefined function foo:shared/0 =ERROR REPORT==== 24-Mar-2009::10:42:03 === beam/beam_load.c(1035): Error loading module foo: module name in object code is c.foo I suspect that the problem is that the .beam naming structure doesn't indicate package structure; x.y.z.quux is stored on disk as quux.beam, which is ambiguous. The two natural solutions seem to me to be either to make the /lib directory structure reflect the package structure (which is sensible given that source is required to do the same) or to make the filenames something like x.y.z.quux.beam. In both cases, backwards compatability is slightly broken, in that someone will have to recompile their stuff or suffer lots of missing errors, but if they're in the middle of upgrading the VM they probably have to do that anyway (I don't know the toolchain very well, so for all I know .beams are migrated or something.) That packages/namespaces can collide in naming kind of defeats the purpose of packages/namespaces, and makes them relatively dangerous in that they can apparently take out the standard library. This really should, IMO, be fixed before r13 stable. On Tue, Mar 24, 2009 at 1:43 AM, Ulf Wiger wrote: > John Haugeland wrote: > >> My gut instinct is that my namespaced module sc.file is somehow >> > > conflicting with the real module file. > > A loong time ago, when I played around with packages, I noticed > that dotted file names didn't go well with embedded boot code > loading. It was the erl_prim_loader module, I think. > > Even if you're not using embedded code loading, the kernel > and stdlib modules are always pre-loaded. I have no idea > if this issue was ever addressed. > > http://erlang.org/pipermail/erlang-questions/2003-November/010741.html > > BR, > Ulf W > > -- > Ulf Wiger > CTO, Erlang Training & Consulting Ltd > http://www.erlang-consulting.com > -- --- GuaranteedVPS.com - bandwidth commitments and root starting from $12.98/mo -------------- next part -------------- An HTML attachment was scrubbed... URL: From corticalcomputer@REDACTED Tue Mar 24 15:22:46 2009 From: corticalcomputer@REDACTED (G.S.) Date: Tue, 24 Mar 2009 07:22:46 -0700 Subject: [erlang-questions] Standard modern salary for an Erlang programmer? Message-ID: <2a67d3ff0903240722x14203c54j693bb1d12fd92953@mail.gmail.com> Hello everyone, What's a standard, good average salary for the Erlang programmer with a few years of experience, based in USA? Java is 70-90k, and I read online that since us Erlangers, being a less known, and essential for writing software that scales, and will scale into the future, is much higher. I seem to find various blogs that state the salary in 2008 was anywhere from 99k to 180k. Can anyone throw a few numbers at me that are currently working in the industry using Erlang? Thanks, -Gene -------------- next part -------------- An HTML attachment was scrubbed... URL: From vychodil.hynek@REDACTED Tue Mar 24 16:49:22 2009 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Tue, 24 Mar 2009 16:49:22 +0100 Subject: [erlang-questions] How do I elegantly check many conditions? In-Reply-To: <18897457.92581237902517556.JavaMail.root@zimbra> References: <27110039.92561237902320511.JavaMail.root@zimbra> <18897457.92581237902517556.JavaMail.root@zimbra> Message-ID: <4d08db370903240849v47f3823ak22c4a2a6363d5c88@mail.gmail.com> On Tue, Mar 24, 2009 at 2:48 PM, Adam Lindberg wrote: > ----- "Hynek Vychodil" wrote: > > 1/ Exception costs more than checking return value. In most cases it > > will > > not be issues but you can't assume that it will not be. When it > > happen, your > > code is less flexible. > > 2/ Flexibility is throw out when I want code like: > > is_new_email(Email1), > > is_new_email(Email2). > > Now I can't distinguish which one Email is wrong without catching > > throw in > > each statement. With my code it is easy: > > {ok, first_one} = {is_new_email(Email1), first_one}, > > {ok, second_one} = {is_new_email(Email2), second_one}. > > Again, your code is less flexible. > > Well, just throw {email_in_use, Email} then? > > Using tagged tuples just for pattern matching (and really just to make the > badmatch error more informative) isn't very readable. It just adds a lot of > clutter. > > With the try statement, you CAN have several expression in the same block. > You can't have that with a case statement. Unless you accept executing them > both to know if either one failed, like in case {a(), b() of {true, true} or > something. > > > Throwing exception when it is not necessary is less flexible. I can > > easily > > turn return value to exception but opposite way is harder. Explicit > > throwing > > exception *is* slower and less flexible! > > Performance is rarely an issue in real life code with these kind of > constructs. If it is, you probably have bigger problems than changing all > your try statements to catch statements. > > It is not harder to change throw to a return value, than a return value to > a throw. Either way you're doing it, it is the same amount of code. code ok = is_new_email1(Email). doesn't looks like same amount of code try is_new_email2(Email) catch throw:email_in_use -> email_in_use end. First one turns return value to exception, second one turns exception to return value. Second one seems more code, does not? Even code is_new_email1(Email) -> case mnesia:dirty_read(email, Email) of [] -> ok; _ -> email_in_use end. seems less than is_new_email2(Email) -> case mnesia:dirty_read(email, Email) of [] -> ok; _ -> throw(email_in_use) end. You did not show even one example where explicit exception throw is more flexible. > > Exceptions are used for exceptional things, like for example when a user > tries to register with an email already in use. Probably the same user or > another user who misspelled, not really that common to be a performance > bottleneck. > > It is also nice to use throw since it is a developer intended exception and > is very visible when it is not catched. If you get a badmatch somewhere high > up in your code then you probably have a bug somewher. If you get an > uncatched throw, then you know you haven't implement the necessary code to > handle the exception. > > Cheers, > Adam > -- --Hynek (Pichi) Vychodil Analyze your data in minutes. Share your insights instantly. Thrill your boss. Be a data hero! Try Good Data now for free: www.gooddata.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From kenneth.lundin@REDACTED Tue Mar 24 21:53:56 2009 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Tue, 24 Mar 2009 21:53:56 +0100 Subject: [erlang-questions] Installing a module from code? In-Reply-To: <8f24f4b10903240952g1ad822f0r1b0177d3d0f26aab@mail.gmail.com> References: <8f24f4b10903231812v42237862wb404eebeb9b63424@mail.gmail.com> <49C88F1C.90509@erlang-consulting.com> <8f24f4b10903240952g1ad822f0r1b0177d3d0f26aab@mail.gmail.com> Message-ID: Packages was introduced many years ago as an experimental feature. Already from the beginning we where aware of that some functions/features would not work together with packages. We have not decided if and when packages will be more than experimental. If we decide to support packages some day it will most probably not work exactly as today's solution. another alternative could be to remove the half -hearted implementation from the distribution in order to avoid confusion. We strongly discourage the use of packages in professional projects. We have no plans to do anything regarding packages until the R13B release. /Kenneth Erlang/OTP Ericsson But packages don't work as bad as you think and the problems described below are actually not caused by a bug, it works just as it is intended to do. Embedded commnets below. 2009/3/24 John Haugeland : > Well it's good to know it isn't my imagination, at least, though it's rather > concerning that this has been known since 2003. > > There's actually another looming problem.? Package names aren't resolved > correctly during conflict after a boot.? My current assumption is that the > only reason they work correctly before a boot is because they're loaded > after compiling into the runtime. > > ----------------------- > > -module(a.foo). > -export([shared/0, unique_a/0]). > > shared()?? -> "I am a.foo". > unique_a() -> "I am a.foo's unique.". > > ----------------------- > > -module(b.foo). > -export([shared/0, unique_b/0]). > > shared()?? -> "I am b.foo". > unique_b() -> "I am b.foo's unique.". > > ----------------------- > > -module(c.foo). > -export([shared/0, unique_c/0]). > > shared()?? -> "I am c.foo". > unique_c() -> "I am c.foo's unique.". > > ----------------------- > > > > If you compile each of those, they will all work as expected until you > reboot the VM. > > ??? 7> c("/scratch/a/foo.erl"). > ??? {ok,'a.foo'} The c/1 function compiles and loads the module. The module is given with full path. > ??? 8> c("/scratch/b/foo.erl"). > ??? {ok,'b.foo'} > ??? 9> c("/scratch/c/foo.erl"). > ??? {ok,'c.foo'} > ??? 10> a.foo:shared(). a.foo is already loaded and the call succeeds > ??? "I am a.foo" > ??? 11> b.foo:shared(). > ??? "I am b.foo" > ??? 12> c.foo:shared(). > ??? "I am c.foo" > > > > After you reboot the VM, you will no longer be able to call any of them > directly. I assume that reboot means starting a new instance of the VM and this time the modules a.foo, b.foo and c.foo are not loaded. > > ??? 2> a.foo:shared(). The module a.foo is not loaded and the code path is searched for a matching module this means that for each element E in the code path "E/a/foo.beam" is tried If you started the new VM with the same working directory as the first one you will have only one file foo.beam in the working directory and that will not match, so the module a.foo will not be loaded and thus can not be called. > ??? ** exception error: undefined function 'a.foo':shared/0 > ??? 3> b.foo:shared(). > ??? ** exception error: undefined function 'b.foo':shared/0 > ??? 4> c.foo:shared(). > ??? ** exception error: undefined function 'c.foo':shared/0 > > > > If you pretend there's no namespace, Erlang will clearly expose that the > binary is the last one compiled. > > ??? 5> foo:shared(). > ??? ** exception error: undefined function foo:shared/0 > > ??? =ERROR REPORT==== 24-Mar-2009::10:42:03 === > ??? beam/beam_load.c(1035): Error loading module foo: > ????? module name in object code is c.foo > > > > I suspect that the problem is that the .beam naming structure doesn't > indicate package structure; x.y.z.quux is stored on disk as quux.beam, which > is ambiguous.? The two natural solutions seem to me to be either to make the > /lib directory structure reflect the package structure (which is sensible > given that source is required to do the same) or to make the filenames > something like x.y.z.quux.beam.? In both cases, backwards compatability is > slightly broken, in that someone will have to recompile their stuff or > suffer lots of missing errors, but if they're in the middle of upgrading the > VM they probably have to do that anyway (I don't know the toolchain very > well, so for all I know .beams are migrated or something.) > > That packages/namespaces can collide in naming kind of defeats the purpose > of packages/namespaces, and makes them relatively dangerous in that they can > apparently take out the standard library. > > This really should, IMO, be fixed before r13 stable. > > > > > > On Tue, Mar 24, 2009 at 1:43 AM, Ulf Wiger > wrote: >> >> John Haugeland wrote: >>> >>> My gut instinct is that my namespaced module sc.file is somehow >> >> > conflicting with the real module file. >> >> A loong time ago, when I played around with packages, I noticed >> that dotted file names didn't go well with embedded boot code >> loading. It was the erl_prim_loader module, I think. >> >> Even if you're not using embedded code loading, the kernel >> and stdlib modules are always pre-loaded. I have no idea >> if this issue was ever addressed. >> >> http://erlang.org/pipermail/erlang-questions/2003-November/010741.html >> >> BR, >> Ulf W >> >> -- >> Ulf Wiger >> CTO, Erlang Training & Consulting Ltd >> http://www.erlang-consulting.com > > > > -- > --- > GuaranteedVPS.com - bandwidth commitments and root starting from $12.98/mo > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From kris_prieb@REDACTED Tue Mar 24 22:38:06 2009 From: kris_prieb@REDACTED (Kris Prieb) Date: Tue, 24 Mar 2009 16:38:06 -0500 Subject: [erlang-questions] where to find correct documentation for erlang distribution over SSL? Message-ID: <4537c3580903241438t641b52d8qb8d81d86e200476d@mail.gmail.com> Hi Michael, Yes, the cookies are identical, and I was able to get a pong without SSL. All my testing so far is within the firewall so that is not an issue. I may try again with OTP R12B4 if it turns out that SSL distribution is broken in R12B5. Kris -------------------------------------------------------------------------------------- Hey, Kris - a couple things ... * /home/.erlang.cookie is same on both nodes ? or from erl shell, 1> erlang:set_cookie(node(), some_secret_cookie). 2> erlang:get_cookie(). 'some_secret_cookie' 3> * do they 'pong' without SSL ? * probably you already checked your firewall ports On Mon, Mar 23, 2009 at 10:29:53PM -0500, Kris Prieb wrote: > Michael, I'm already familiar with the contents at the link you > mentioned through a lot of googling, but thanks anyway. > > After some further noodling around I've been able to establish an SSL > connection to a single node where I've created the initiating > (non-erlang node) end point myself using the SSL application. I still > am unable get the full erlang distribution running on SSL, however, so > I remain open to suggestions. > > Kris > > ------------------------------------------------------------------------------------------------------------- > Date: Mon, 23 Mar 2009 16:01:58 -0700 > From: Michael McDaniel <> > Subject: Re: [erlang-questions] where to find correct documentation > for erlang distribution over SSL? > To: > Message-ID: <> > Content-Type: text/plain; charset=iso-8859-1 > > > old, but possibly will assist ... > > > http://trapexit.org/Distributed_erlang_using_ssl_through_firewalls > > > ~M > > > On Mon, Mar 23, 2009 at 04:35:51PM -0500, Kris Prieb wrote: > > I have been trying to start erlang distribution over SSL using SSL > > 3.10 in OTP R12-B5 by following Section 5 of the SSL User's Guide > > (http://www.erlang.org/doc/apps/ssl/usersguide_frame.html). ?I have > > gotten two nodes up, but I cannot get them to successfully > > net_adm:ping/1 each other.?(I get a pang not a pong). I only just > > read that the documentation for distribution over SSL is in fact not > > entirely correct. As noted in the release notes for SSL 3.10: > > > > "1.1.3 Known Bugs and Problems > > Running erlang distribution over ssl don't work as described in the > > documentation. > > Own Id: OTP-7536" > > > > Does anyone know where I might find correct documentation on erlang > > distribution over SSL, or alternatively, what parts of the current > > documentation are incorrect and how? > > > > Thanks in advance! > > Kris > > _______________________________________________ > > erlang-questions mailing list > > > > http://www.erlang.org/mailman/listinfo/erlang-questions > > -- > Michael McDaniel > Portland, Oregon, USA > http://autosys.us > http://mmcdaniel.com/erlview > _______________________________________________ > erlang-questions mailing list > > http://www.erlang.org/mailman/listinfo/erlang-questions From kris_prieb@REDACTED Tue Mar 24 22:48:47 2009 From: kris_prieb@REDACTED (Kris Prieb) Date: Tue, 24 Mar 2009 16:48:47 -0500 Subject: [erlang-questions] where to find correct documentation for erlang distribution over SSL? Message-ID: <4537c3580903241448s366a2aa6xed2bb0da740e2171@mail.gmail.com> Hi Steve, In my case, it would actually be quite useful to have distribution over SSL in production. Kris -------------------------------------------------------------------------------------------- Steve Davis <> Tue Mar 24 10:04:25 CET 2009 Previous message: [erlang-questions] where to find correct documentation for erlang distribution over SSL? Next message: [erlang-questions] Enhancement to erlang:system_info ? Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] I have also not yet convinced Inets SSL to work. I spent a good while on it in R12B, and tried again briefly with R13A with no luck... ...but maybe it's redundant in any case as you'd likely be fronting your inets with NginX or something in production. So, for me it's just a development phase irritation. /s From masse@REDACTED Tue Mar 24 21:24:03 2009 From: masse@REDACTED (mats cronqvist) Date: Tue, 24 Mar 2009 21:24:03 +0100 Subject: [erlang-questions] How do I elegantly check many conditions? In-Reply-To: <4d08db370903240849v47f3823ak22c4a2a6363d5c88@mail.gmail.com> (Hynek Vychodil's message of "Tue\, 24 Mar 2009 16\:49\:22 +0100") References: <27110039.92561237902320511.JavaMail.root@zimbra> <18897457.92581237902517556.JavaMail.root@zimbra> <4d08db370903240849v47f3823ak22c4a2a6363d5c88@mail.gmail.com> Message-ID: <87zlfad5zw.fsf@sterlett.hq.kred> Hynek Vychodil writes: > code > > ok = is_new_email1(Email). > > doesn't looks like same amount of code > > try is_new_email2(Email) catch throw:email_in_use -> email_in_use end. > > First one turns return value to exception, second one turns exception to > return value. Second one seems more code, does not? but the exception generated in example 1 is a worthless 'badmatch'. > Even code > > is_new_email1(Email) -> > ? case mnesia:dirty_read(email, Email) of > ??? [] ? ?-> ok; > ??? _ -> email_in_use > ? end. > > seems less than > > is_new_email2(Email) -> > ? case mnesia:dirty_read(email, Email) of > ??? [] ? ?-> ok; > ??? _ -> throw(email_in_use) > ? end. I think it should be written like this; is_new_email2(Email) -> try [] = mnesia:dirty_read(email, Email) catch _:_ -> throw({email_in_use,Email}) end. This is how your example 1 above has to be written too, if it is to give a helpful error message. mats From vychodil.hynek@REDACTED Tue Mar 24 22:58:38 2009 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Tue, 24 Mar 2009 22:58:38 +0100 Subject: [erlang-questions] How do I elegantly check many conditions? In-Reply-To: <401d3ba30903241408o5ac962dare13c9d70c5b1464b@mail.gmail.com> References: <27110039.92561237902320511.JavaMail.root@zimbra> <18897457.92581237902517556.JavaMail.root@zimbra> <4d08db370903240849v47f3823ak22c4a2a6363d5c88@mail.gmail.com> <401d3ba30903241408o5ac962dare13c9d70c5b1464b@mail.gmail.com> Message-ID: <4d08db370903241458r5f7b0956sbda77bd4081b9f7b@mail.gmail.com> On Tue, Mar 24, 2009 at 10:08 PM, Attila Rajmund Nohl < attila.r.nohl@REDACTED> wrote: > 2009/3/24, Hynek Vychodil : > [...] > > > > code > > > > ok = is_new_email1(Email). > > > > doesn't looks like same amount of code > > > > try is_new_email2(Email) catch throw:email_in_use -> email_in_use end. > > > > First one turns return value to exception, second one turns exception to > > return value. Second one seems more code, does not? > > The beauty of execption handling is that you don't have to handle the > exception where it was thrown. So in real code the second would be > something like > > checks() -> > foo(), > is_new_email(Email), > bar(). > > And the catch would be at the call of checks(). > And again, you assume how I will use your function. It's wrong! You avoid me to make case when I know what to do. -- --Hynek (Pichi) Vychodil Analyze your data in minutes. Share your insights instantly. Thrill your boss. Be a data hero! Try Good Data now for free: www.gooddata.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From attila.r.nohl@REDACTED Tue Mar 24 22:08:36 2009 From: attila.r.nohl@REDACTED (Attila Rajmund Nohl) Date: Tue, 24 Mar 2009 22:08:36 +0100 Subject: [erlang-questions] =?iso-8859-1?q?V=E1=3A__How_do_I_elegantly_che?= =?iso-8859-1?q?ck_many_conditions=3F?= In-Reply-To: <4d08db370903240849v47f3823ak22c4a2a6363d5c88@mail.gmail.com> References: <27110039.92561237902320511.JavaMail.root@zimbra> <18897457.92581237902517556.JavaMail.root@zimbra> <4d08db370903240849v47f3823ak22c4a2a6363d5c88@mail.gmail.com> Message-ID: <401d3ba30903241408o5ac962dare13c9d70c5b1464b@mail.gmail.com> 2009/3/24, Hynek Vychodil : [...] > > code > > ok = is_new_email1(Email). > > doesn't looks like same amount of code > > try is_new_email2(Email) catch throw:email_in_use -> email_in_use end. > > First one turns return value to exception, second one turns exception to > return value. Second one seems more code, does not? The beauty of execption handling is that you don't have to handle the exception where it was thrown. So in real code the second would be something like checks() -> foo(), is_new_email(Email), bar(). And the catch would be at the call of checks(). From vychodil.hynek@REDACTED Tue Mar 24 23:06:18 2009 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Tue, 24 Mar 2009 23:06:18 +0100 Subject: [erlang-questions] How do I elegantly check many conditions? In-Reply-To: <87zlfad5zw.fsf@sterlett.hq.kred> References: <27110039.92561237902320511.JavaMail.root@zimbra> <18897457.92581237902517556.JavaMail.root@zimbra> <4d08db370903240849v47f3823ak22c4a2a6363d5c88@mail.gmail.com> <87zlfad5zw.fsf@sterlett.hq.kred> Message-ID: <4d08db370903241506m197a6a5cs9b3d967cfdacf0f4@mail.gmail.com> On Tue, Mar 24, 2009 at 9:24 PM, mats cronqvist wrote: > Hynek Vychodil writes: > > > code > > > > ok = is_new_email1(Email). > > > > doesn't looks like same amount of code > > > > try is_new_email2(Email) catch throw:email_in_use -> email_in_use end. > > > > First one turns return value to exception, second one turns exception to > > return value. Second one seems more code, does not? > > but the exception generated in example 1 is a worthless 'badmatch'. > I can flexible choose which worth-full 'badmatch' will be generated just using {ok, Email} = {is_new_email1(Email), Email}. It all up to me. It is meaning of word 'flexible'. > > Even code > > > > is_new_email1(Email) -> > > case mnesia:dirty_read(email, Email) of > > [] -> ok; > > _ -> email_in_use > > end. > > > > seems less than > > > > is_new_email2(Email) -> > > case mnesia:dirty_read(email, Email) of > > [] -> ok; > > _ -> throw(email_in_use) > > end. > > I think it should be written like this; > > is_new_email2(Email) -> > try [] = mnesia:dirty_read(email, Email) > catch _:_ -> throw({email_in_use,Email}) > end. > > This is how your example 1 above has to be written too, if it is to > give a helpful error message. > Yes, but what prevent me is_new_email1(Email) -> case mnesia:dirty_read(email, Email) of [] -> ok; _ -> {email_in_use,Email} end. and again, less code and more flexible. Each variant with throw can be written without throw in far flexible way. > mats > -- --Hynek (Pichi) Vychodil Analyze your data in minutes. Share your insights instantly. Thrill your boss. Be a data hero! Try Good Data now for free: www.gooddata.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From bruce@REDACTED Tue Mar 24 21:25:05 2009 From: bruce@REDACTED (Bruce Fitzsimons) Date: Wed, 25 Mar 2009 09:25:05 +1300 Subject: [erlang-questions] where to find correct documentation for erlang distribution over SSL? In-Reply-To: <4537c3580903232029m2a6e3275ocec4d69ebdead924@mail.gmail.com> References: <4537c3580903231435j507400ffn77b6eafe2e27e580@mail.gmail.com> <4537c3580903232029m2a6e3275ocec4d69ebdead924@mail.gmail.com> Message-ID: <49C941A1.2040700@fitzsimons.org> Hi Kris, list, Is OTP-7536 actually fixed? I can't see any reference to it moving from "known" to "fixed". Was it really just documentation? I've not revisted or retested SSL distribution since I created the patch to make it work and then lost interest in the proto-project that required it for Front End to Back End communcation across the internet. That was on R11B-5. I don't know if it has been reworked to work out of the box in later releases, or if my convoluted patch was accepted in some form, and I've not had a chance to look. Can anyone from OTP comment? I know the Erlang SSL infrastructure has evolved, and SSL distribution wasn't overly loved/used by customers (apparently) but it is great functionality. Cheers, Bruce Kris Prieb wrote: > Michael, I'm already familiar with the contents at the link you > mentioned through a lot of googling, but thanks anyway. > > After some further noodling around I've been able to establish an SSL > connection to a single node where I've created the initiating > (non-erlang node) end point myself using the SSL application. I still > am unable get the full erlang distribution running on SSL, however, so > I remain open to suggestions. > > Kris > > ------------------------------------------------------------------------------------------------------------- > Date: Mon, 23 Mar 2009 16:01:58 -0700 > From: Michael McDaniel > Subject: Re: [erlang-questions] where to find correct documentation > for erlang distribution over SSL? > To: erlang-questions@REDACTED > Message-ID: <20090323230157.GO18122@REDACTED> > Content-Type: text/plain; charset=iso-8859-1 > > > old, but possibly will assist ... > > > http://trapexit.org/Distributed_erlang_using_ssl_through_firewalls > > > ~M > > > On Mon, Mar 23, 2009 at 04:35:51PM -0500, Kris Prieb wrote: > >> I have been trying to start erlang distribution over SSL using SSL >> 3.10 in OTP R12-B5 by following Section 5 of the SSL User's Guide >> (http://www.erlang.org/doc/apps/ssl/usersguide_frame.html). ?I have >> gotten two nodes up, but I cannot get them to successfully >> net_adm:ping/1 each other.?(I get a pang not a pong). I only just >> read that the documentation for distribution over SSL is in fact not >> entirely correct. As noted in the release notes for SSL 3.10: >> >> "1.1.3 Known Bugs and Problems >> Running erlang distribution over ssl don't work as described in the >> documentation. >> Own Id: OTP-7536" >> >> Does anyone know where I might find correct documentation on erlang >> distribution over SSL, or alternatively, what parts of the current >> documentation are incorrect and how? >> >> Thanks in advance! >> Kris >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > -- > Michael McDaniel > Portland, Oregon, USA > http://autosys.us > http://mmcdaniel.com/erlview > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From kris_prieb@REDACTED Tue Mar 24 22:30:32 2009 From: kris_prieb@REDACTED (Kris Prieb) Date: Tue, 24 Mar 2009 16:30:32 -0500 Subject: [erlang-questions] where to find correct documentation for erlang distribution over SSL? In-Reply-To: <49C941A1.2040700@fitzsimons.org> References: <4537c3580903231435j507400ffn77b6eafe2e27e580@mail.gmail.com> <4537c3580903232029m2a6e3275ocec4d69ebdead924@mail.gmail.com> <49C941A1.2040700@fitzsimons.org> Message-ID: <4537c3580903241430l298e63c0ka795ccf6d37aac12@mail.gmail.com> Hi Bruce, list, Yes, you might be right: I may have misinterpreted the release note to mean only that the documentation was wrong. Perhaps distribution over SSL is in fact broken in SSL 3.10 (OTP R12B5). I just assumed that it was working because the release just prior, SSL 3.9 (OTP R12B4), has the following release note: "Erlang distribution over ssl was broken after R11B-0, this has now been fixed. Own Id: OTP-7004" I second the request for comment from someone from OTP. I also agree that distribution over SSL is *great* functionality. If it has been broken I hope it gets fixed again for R13. Kris On Tue, Mar 24, 2009 at 3:25 PM, Bruce Fitzsimons wrote: > Hi Kris, list, > > Is OTP-7536 actually fixed? I can't see any reference to it moving from > "known" to "fixed". Was it really just documentation? > > I've not revisted or retested SSL distribution since I created the patch to > make it work and then lost interest in the proto-project that required it > for Front End to Back End communcation across the internet. That was on > R11B-5. I don't know if it has been reworked to work out of the box in later > releases, or if my convoluted patch was accepted in some form, and I've not > had a chance to look. Can anyone from OTP comment? > > I know the Erlang SSL infrastructure has evolved, and SSL distribution > wasn't overly loved/used by customers (apparently) but it is great > functionality. > > Cheers, > Bruce > > Kris Prieb wrote: >> >> Michael, I'm already familiar with the contents at the link you >> mentioned through a lot of googling, but thanks anyway. >> >> After some further noodling around I've been able to establish an SSL >> connection to a single node where I've created the initiating >> (non-erlang node) end point myself using the SSL application. ?I still >> am unable get the full erlang distribution running on SSL, however, so >> I remain open to suggestions. >> >> Kris >> >> >> ------------------------------------------------------------------------------------------------------------- >> Date: Mon, 23 Mar 2009 16:01:58 -0700 >> From: Michael McDaniel >> Subject: Re: [erlang-questions] where to find correct documentation >> ? ? ? for ? ? erlang distribution over SSL? >> To: erlang-questions@REDACTED >> Message-ID: <20090323230157.GO18122@REDACTED> >> Content-Type: text/plain; charset=iso-8859-1 >> >> >> ?old, but possibly will assist ... >> >> >> ?http://trapexit.org/Distributed_erlang_using_ssl_through_firewalls >> >> >> ~M >> >> >> On Mon, Mar 23, 2009 at 04:35:51PM -0500, Kris Prieb wrote: >> >>> >>> I have been trying to start erlang distribution over SSL using SSL >>> 3.10 in OTP R12-B5 by following Section 5 of the SSL User's Guide >>> (http://www.erlang.org/doc/apps/ssl/usersguide_frame.html). ?I have >>> gotten two nodes up, but I cannot get them to successfully >>> net_adm:ping/1 each other.?(I get a pang not a pong). ?I only just >>> read that the documentation for distribution over SSL is in fact not >>> entirely correct. ?As noted in the release notes for SSL 3.10: >>> >>> "1.1.3 Known Bugs and Problems >>> Running erlang distribution over ssl don't work as described in the >>> documentation. >>> Own Id: OTP-7536" >>> >>> Does anyone know where I might find correct documentation on erlang >>> distribution over SSL, or alternatively, what parts of the current >>> documentation are incorrect and how? >>> >>> Thanks in advance! >>> Kris >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://www.erlang.org/mailman/listinfo/erlang-questions >>> >> >> -- >> Michael McDaniel >> Portland, Oregon, USA >> http://autosys.us >> http://mmcdaniel.com/erlview >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > From bruce@REDACTED Tue Mar 24 23:46:42 2009 From: bruce@REDACTED (Bruce Fitzsimons) Date: Wed, 25 Mar 2009 11:46:42 +1300 Subject: [erlang-questions] where to find correct documentation for erlang distribution over SSL? In-Reply-To: <4537c3580903241430l298e63c0ka795ccf6d37aac12@mail.gmail.com> References: <4537c3580903231435j507400ffn77b6eafe2e27e580@mail.gmail.com> <4537c3580903232029m2a6e3275ocec4d69ebdead924@mail.gmail.com> <49C941A1.2040700@fitzsimons.org> <4537c3580903241430l298e63c0ka795ccf6d37aac12@mail.gmail.com> Message-ID: <49C962D2.8000208@fitzsimons.org> Hi Kris, I hadn't seen that release note. Excellent. So it is supposed to work. Thanks OTP peoples :-) So, have you tcpdump'd the communications? Is anything happening? You've done all the normal cookie stuff that you need for non-SSL distribution or in other words can you get non-SSL distribution working (perhaps locally...)? What does epmd say about the nodes it knows about? I think you can run it in debug or console mode, or otherwise get it to dump the known nodes. Cheers, Bruce Kris Prieb wrote: > Hi Bruce, list, > > Yes, you might be right: I may have misinterpreted the release note to > mean only that the documentation was wrong. Perhaps distribution over > SSL is in fact broken in SSL 3.10 (OTP R12B5). I just assumed that it > was working because the release just prior, SSL 3.9 (OTP R12B4), has > the following release note: > > "Erlang distribution over ssl was broken after R11B-0, this has now been fixed. > Own Id: OTP-7004" > > I second the request for comment from someone from OTP. > > I also agree that distribution over SSL is *great* functionality. If > it has been broken I hope it gets fixed again for R13. > > Kris > > On Tue, Mar 24, 2009 at 3:25 PM, Bruce Fitzsimons wrote: > >> Hi Kris, list, >> >> Is OTP-7536 actually fixed? I can't see any reference to it moving from >> "known" to "fixed". Was it really just documentation? >> >> I've not revisted or retested SSL distribution since I created the patch to >> make it work and then lost interest in the proto-project that required it >> for Front End to Back End communcation across the internet. That was on >> R11B-5. I don't know if it has been reworked to work out of the box in later >> releases, or if my convoluted patch was accepted in some form, and I've not >> had a chance to look. Can anyone from OTP comment? >> >> I know the Erlang SSL infrastructure has evolved, and SSL distribution >> wasn't overly loved/used by customers (apparently) but it is great >> functionality. >> >> Cheers, >> Bruce >> >> Kris Prieb wrote: >> >>> Michael, I'm already familiar with the contents at the link you >>> mentioned through a lot of googling, but thanks anyway. >>> >>> After some further noodling around I've been able to establish an SSL >>> connection to a single node where I've created the initiating >>> (non-erlang node) end point myself using the SSL application. I still >>> am unable get the full erlang distribution running on SSL, however, so >>> I remain open to suggestions. >>> >>> Kris >>> >>> >>> ------------------------------------------------------------------------------------------------------------- >>> Date: Mon, 23 Mar 2009 16:01:58 -0700 >>> From: Michael McDaniel >>> Subject: Re: [erlang-questions] where to find correct documentation >>> for erlang distribution over SSL? >>> To: erlang-questions@REDACTED >>> Message-ID: <20090323230157.GO18122@REDACTED> >>> Content-Type: text/plain; charset=iso-8859-1 >>> >>> >>> old, but possibly will assist ... >>> >>> >>> http://trapexit.org/Distributed_erlang_using_ssl_through_firewalls >>> >>> >>> ~M >>> >>> >>> On Mon, Mar 23, 2009 at 04:35:51PM -0500, Kris Prieb wrote: >>> >>> >>>> I have been trying to start erlang distribution over SSL using SSL >>>> 3.10 in OTP R12-B5 by following Section 5 of the SSL User's Guide >>>> (http://www.erlang.org/doc/apps/ssl/usersguide_frame.html). ?I have >>>> gotten two nodes up, but I cannot get them to successfully >>>> net_adm:ping/1 each other.?(I get a pang not a pong). I only just >>>> read that the documentation for distribution over SSL is in fact not >>>> entirely correct. As noted in the release notes for SSL 3.10: >>>> >>>> "1.1.3 Known Bugs and Problems >>>> Running erlang distribution over ssl don't work as described in the >>>> documentation. >>>> Own Id: OTP-7536" >>>> >>>> Does anyone know where I might find correct documentation on erlang >>>> distribution over SSL, or alternatively, what parts of the current >>>> documentation are incorrect and how? >>>> >>>> Thanks in advance! >>>> Kris >>>> _______________________________________________ >>>> erlang-questions mailing list >>>> erlang-questions@REDACTED >>>> http://www.erlang.org/mailman/listinfo/erlang-questions >>>> >>>> >>> -- >>> Michael McDaniel >>> Portland, Oregon, USA >>> http://autosys.us >>> http://mmcdaniel.com/erlview >>> _______________________________________________ >>> 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 yoursurrogategod@REDACTED Wed Mar 25 03:17:58 2009 From: yoursurrogategod@REDACTED (Yves S. Garret) Date: Tue, 24 Mar 2009 19:17:58 -0700 (PDT) Subject: [erlang-questions] Possible projects to improve my knowledge of Erlang Message-ID: <47293517-7bdb-4a3f-9506-1b4cade92406@j8g2000yql.googlegroups.com> Anyone know of any? Essentially problems (preferrably parallel processing ones) that someone who wants to improve their skill at Erlang can work on. From ryeguy1@REDACTED Wed Mar 25 03:59:07 2009 From: ryeguy1@REDACTED (ryeguy) Date: Tue, 24 Mar 2009 19:59:07 -0700 (PDT) Subject: [erlang-questions] Is binary_to_term() safe for non trusted sources? Message-ID: <33c0ef3c-591a-4dd4-907d-89f3884f4f51@z15g2000yqm.googlegroups.com> Is it safe to decode a binary directly into an erlang term from an uncontrolled client? My instinct says it's unsafe, but it doesn't say so in the docs (maybe because it's obvious). Is there anyway to really do harm if what is done with the decoded terms in erlang is controlled? From dgud@REDACTED Wed Mar 25 08:15:08 2009 From: dgud@REDACTED (Dan Gudmundsson) Date: Wed, 25 Mar 2009 08:15:08 +0100 Subject: [erlang-questions] where to find correct documentation for erlang distribution over SSL? In-Reply-To: <4537c3580903241430l298e63c0ka795ccf6d37aac12@mail.gmail.com> References: <4537c3580903231435j507400ffn77b6eafe2e27e580@mail.gmail.com> <4537c3580903232029m2a6e3275ocec4d69ebdead924@mail.gmail.com> <49C941A1.2040700@fitzsimons.org> <4537c3580903241430l298e63c0ka795ccf6d37aac12@mail.gmail.com> Message-ID: <49C9D9FC.8050707@erix.ericsson.se> Yes it was broken in at least R12B-5, it is fixed again in R13A. And I worded the OTP-7536 like that because I thought but didn't know (and had no time to investigate) if it only was the documentation that was the problem, turns out the code was broken. I guess the docs still need work, but the code works now :-) /Dan Kris Prieb wrote: > Hi Bruce, list, > > Yes, you might be right: I may have misinterpreted the release note to > mean only that the documentation was wrong. Perhaps distribution over > SSL is in fact broken in SSL 3.10 (OTP R12B5). I just assumed that it > was working because the release just prior, SSL 3.9 (OTP R12B4), has > the following release note: > > "Erlang distribution over ssl was broken after R11B-0, this has now been fixed. > Own Id: OTP-7004" > > I second the request for comment from someone from OTP. > > I also agree that distribution over SSL is *great* functionality. If > it has been broken I hope it gets fixed again for R13. > > Kris > > On Tue, Mar 24, 2009 at 3:25 PM, Bruce Fitzsimons wrote: >> Hi Kris, list, >> >> Is OTP-7536 actually fixed? I can't see any reference to it moving from >> "known" to "fixed". Was it really just documentation? >> >> I've not revisted or retested SSL distribution since I created the patch to >> make it work and then lost interest in the proto-project that required it >> for Front End to Back End communcation across the internet. That was on >> R11B-5. I don't know if it has been reworked to work out of the box in later >> releases, or if my convoluted patch was accepted in some form, and I've not >> had a chance to look. Can anyone from OTP comment? >> >> I know the Erlang SSL infrastructure has evolved, and SSL distribution >> wasn't overly loved/used by customers (apparently) but it is great >> functionality. >> >> Cheers, >> Bruce >> >> Kris Prieb wrote: >>> Michael, I'm already familiar with the contents at the link you >>> mentioned through a lot of googling, but thanks anyway. >>> >>> After some further noodling around I've been able to establish an SSL >>> connection to a single node where I've created the initiating >>> (non-erlang node) end point myself using the SSL application. I still >>> am unable get the full erlang distribution running on SSL, however, so >>> I remain open to suggestions. >>> >>> Kris >>> >>> >>> ------------------------------------------------------------------------------------------------------------- >>> Date: Mon, 23 Mar 2009 16:01:58 -0700 >>> From: Michael McDaniel >>> Subject: Re: [erlang-questions] where to find correct documentation >>> for erlang distribution over SSL? >>> To: erlang-questions@REDACTED >>> Message-ID: <20090323230157.GO18122@REDACTED> >>> Content-Type: text/plain; charset=iso-8859-1 >>> >>> >>> old, but possibly will assist ... >>> >>> >>> http://trapexit.org/Distributed_erlang_using_ssl_through_firewalls >>> >>> >>> ~M >>> >>> >>> On Mon, Mar 23, 2009 at 04:35:51PM -0500, Kris Prieb wrote: >>> >>>> I have been trying to start erlang distribution over SSL using SSL >>>> 3.10 in OTP R12-B5 by following Section 5 of the SSL User's Guide >>>> (http://www.erlang.org/doc/apps/ssl/usersguide_frame.html). ?I have >>>> gotten two nodes up, but I cannot get them to successfully >>>> net_adm:ping/1 each other.?(I get a pang not a pong). I only just >>>> read that the documentation for distribution over SSL is in fact not >>>> entirely correct. As noted in the release notes for SSL 3.10: >>>> >>>> "1.1.3 Known Bugs and Problems >>>> Running erlang distribution over ssl don't work as described in the >>>> documentation. >>>> Own Id: OTP-7536" >>>> >>>> Does anyone know where I might find correct documentation on erlang >>>> distribution over SSL, or alternatively, what parts of the current >>>> documentation are incorrect and how? >>>> >>>> Thanks in advance! >>>> Kris >>>> _______________________________________________ >>>> erlang-questions mailing list >>>> erlang-questions@REDACTED >>>> http://www.erlang.org/mailman/listinfo/erlang-questions >>>> >>> -- >>> Michael McDaniel >>> Portland, Oregon, USA >>> http://autosys.us >>> http://mmcdaniel.com/erlview >>> _______________________________________________ >>> 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 bruce@REDACTED Wed Mar 25 10:02:45 2009 From: bruce@REDACTED (Bruce Fitzsimons) Date: Wed, 25 Mar 2009 22:02:45 +1300 Subject: [erlang-questions] where to find correct documentation for erlang distribution over SSL? In-Reply-To: <49C9D9FC.8050707@erix.ericsson.se> References: <4537c3580903231435j507400ffn77b6eafe2e27e580@mail.gmail.com> <4537c3580903232029m2a6e3275ocec4d69ebdead924@mail.gmail.com> <49C941A1.2040700@fitzsimons.org> <4537c3580903241430l298e63c0ka795ccf6d37aac12@mail.gmail.com> <49C9D9FC.8050707@erix.ericsson.se> Message-ID: <51834A08-00C9-483F-8529-40D648EE62A7@fitzsimons.org> Great work Dan, thanks for the reply and the not-insignificant-work of making SSL distribution work again. Cheers, Bruce On 25/03/2009, at 8:15 PM, Dan Gudmundsson wrote: > > Yes it was broken in at least R12B-5, it is fixed again in R13A. > > And I worded the OTP-7536 like that because I thought but didn't > know (and had no time to > investigate) if it only was the documentation that was the problem, > turns out the code was > broken. > > I guess the docs still need work, but the code works now :-) > > /Dan > > Kris Prieb wrote: >> Hi Bruce, list, >> >> Yes, you might be right: I may have misinterpreted the release note >> to >> mean only that the documentation was wrong. Perhaps distribution >> over >> SSL is in fact broken in SSL 3.10 (OTP R12B5). I just assumed that >> it >> was working because the release just prior, SSL 3.9 (OTP R12B4), has >> the following release note: >> >> "Erlang distribution over ssl was broken after R11B-0, this has now >> been fixed. >> Own Id: OTP-7004" >> >> I second the request for comment from someone from OTP. >> >> I also agree that distribution over SSL is *great* functionality. If >> it has been broken I hope it gets fixed again for R13. >> >> Kris >> >> On Tue, Mar 24, 2009 at 3:25 PM, Bruce Fitzsimons > > wrote: >>> Hi Kris, list, >>> >>> Is OTP-7536 actually fixed? I can't see any reference to it moving >>> from >>> "known" to "fixed". Was it really just documentation? >>> >>> I've not revisted or retested SSL distribution since I created the >>> patch to >>> make it work and then lost interest in the proto-project that >>> required it >>> for Front End to Back End communcation across the internet. That >>> was on >>> R11B-5. I don't know if it has been reworked to work out of the >>> box in later >>> releases, or if my convoluted patch was accepted in some form, and >>> I've not >>> had a chance to look. Can anyone from OTP comment? >>> >>> I know the Erlang SSL infrastructure has evolved, and SSL >>> distribution >>> wasn't overly loved/used by customers (apparently) but it is great >>> functionality. >>> >>> Cheers, >>> Bruce >>> >>> Kris Prieb wrote: >>>> Michael, I'm already familiar with the contents at the link you >>>> mentioned through a lot of googling, but thanks anyway. >>>> >>>> After some further noodling around I've been able to establish an >>>> SSL >>>> connection to a single node where I've created the initiating >>>> (non-erlang node) end point myself using the SSL application. I >>>> still >>>> am unable get the full erlang distribution running on SSL, >>>> however, so >>>> I remain open to suggestions. >>>> >>>> Kris >>>> >>>> >>>> ------------------------------------------------------------------------------------------------------------- >>>> Date: Mon, 23 Mar 2009 16:01:58 -0700 >>>> From: Michael McDaniel >>>> Subject: Re: [erlang-questions] where to find correct documentation >>>> for erlang distribution over SSL? >>>> To: erlang-questions@REDACTED >>>> Message-ID: <20090323230157.GO18122@REDACTED> >>>> Content-Type: text/plain; charset=iso-8859-1 >>>> >>>> >>>> old, but possibly will assist ... >>>> >>>> >>>> http://trapexit.org/Distributed_erlang_using_ssl_through_firewalls >>>> >>>> >>>> ~M >>>> >>>> >>>> On Mon, Mar 23, 2009 at 04:35:51PM -0500, Kris Prieb wrote: >>>> >>>>> I have been trying to start erlang distribution over SSL using SSL >>>>> 3.10 in OTP R12-B5 by following Section 5 of the SSL User's Guide >>>>> (http://www.erlang.org/doc/apps/ssl/usersguide_frame.html). ?I >>>>> have >>>>> gotten two nodes up, but I cannot get them to successfully >>>>> net_adm:ping/1 each other.?(I get a pang not a pong). I only just >>>>> read that the documentation for distribution over SSL is in fact >>>>> not >>>>> entirely correct. As noted in the release notes for SSL 3.10: >>>>> >>>>> "1.1.3 Known Bugs and Problems >>>>> Running erlang distribution over ssl don't work as described in >>>>> the >>>>> documentation. >>>>> Own Id: OTP-7536" >>>>> >>>>> Does anyone know where I might find correct documentation on >>>>> erlang >>>>> distribution over SSL, or alternatively, what parts of the current >>>>> documentation are incorrect and how? >>>>> >>>>> Thanks in advance! >>>>> Kris >>>>> _______________________________________________ >>>>> erlang-questions mailing list >>>>> erlang-questions@REDACTED >>>>> http://www.erlang.org/mailman/listinfo/erlang-questions >>>>> >>>> -- >>>> Michael McDaniel >>>> Portland, Oregon, USA >>>> http://autosys.us >>>> http://mmcdaniel.com/erlview >>>> _______________________________________________ >>>> 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 Wed Mar 25 10:27:35 2009 From: ulf@REDACTED (Ulf Wiger) Date: Wed, 25 Mar 2009 10:27:35 +0100 Subject: [erlang-questions] Erlang/OTP 13A and Darwin In-Reply-To: References: Message-ID: <8209f740903250227i6ea8f857o1c15aee11ac0ba14@mail.gmail.com> 2009/3/23 Camille Troillard : > > Outside a much larger address space, which are the benefits of a 64bits VM? Well, as 64-bit architectures become more widespread, using a VM that's optimized for 64-bit is likely to be more efficient than using one that relies on the backward compatibility with 32-bit. Read e.g. "HiPE on AMD64" http://user.it.uu.se/~kostis/Papers/amd64.pdf Otherwise, enabling a much larger address space /is/ by far the most compelling argument for 64-bit Erlang. BR, Ulf W From adam@REDACTED Wed Mar 25 10:30:14 2009 From: adam@REDACTED (Adam Lindberg) Date: Wed, 25 Mar 2009 09:30:14 +0000 (GMT) Subject: [erlang-questions] How do I elegantly check many conditions? In-Reply-To: <4d08db370903241506m197a6a5cs9b3d967cfdacf0f4@mail.gmail.com> Message-ID: <24637104.93981237973414684.JavaMail.root@zimbra> I'm sorry, but you aren't making much sense here... :-/ I still think you're misusing the badmatch exception. Cheers, Adam ----- "Hynek Vychodil" wrote: > On Tue, Mar 24, 2009 at 9:24 PM, mats cronqvist > wrote: > > > Hynek Vychodil writes: > > > > > code > > > > > > ok = is_new_email1(Email). > > > > > > doesn't looks like same amount of code > > > > > > try is_new_email2(Email) catch throw:email_in_use -> email_in_use > end. > > > > > > First one turns return value to exception, second one turns > exception to > > > return value. Second one seems more code, does not? > > > > but the exception generated in example 1 is a worthless > 'badmatch'. > > > > I can flexible choose which worth-full 'badmatch' will be generated > just > using {ok, Email} = {is_new_email1(Email), Email}. It all up to me. It > is > meaning of word 'flexible'. > > > > > Even code > > > > > > is_new_email1(Email) -> > > > case mnesia:dirty_read(email, Email) of > > > [] -> ok; > > > _ -> email_in_use > > > end. > > > > > > seems less than > > > > > > is_new_email2(Email) -> > > > case mnesia:dirty_read(email, Email) of > > > [] -> ok; > > > _ -> throw(email_in_use) > > > end. > > > > I think it should be written like this; > > > > is_new_email2(Email) -> > > try [] = mnesia:dirty_read(email, Email) > > catch _:_ -> throw({email_in_use,Email}) > > end. > > > > This is how your example 1 above has to be written too, if it is > to > > give a helpful error message. > > > > Yes, but what prevent me > > is_new_email1(Email) -> > case mnesia:dirty_read(email, Email) of > [] -> ok; > _ -> {email_in_use,Email} > end. > > and again, less code and more flexible. Each variant with throw can > be > written without throw in far flexible way. > > > > mats > > > > > > -- > --Hynek (Pichi) Vychodil > > Analyze your data in minutes. Share your insights instantly. Thrill > your > boss. Be a data hero! > Try Good Data now for free: www.gooddata.com From tuscland@REDACTED Wed Mar 25 11:59:00 2009 From: tuscland@REDACTED (Camille Troillard) Date: Wed, 25 Mar 2009 11:59:00 +0100 Subject: [erlang-questions] Erlang/OTP 13A and Darwin In-Reply-To: References: <8209f740903250227i6ea8f857o1c15aee11ac0ba14@mail.gmail.com> Message-ID: Thanks Ulf and Per, On Wed, Mar 25, 2009 at 11:42 AM, Per Gustafsson wrote: > A type of calculation that becomes much more efficient on 64-bit machines > are 32-bit fixed integer calculations, That is very interesting, would that mean that we could have faster arithmetic in Erlang without too much effort? I was looking for better math performance. What about 32 bits builds? Are there some possible (planned?) optimisations regarding this domain? Cam -------------- next part -------------- An HTML attachment was scrubbed... URL: From bekesa@REDACTED Wed Mar 25 12:39:29 2009 From: bekesa@REDACTED (Andras Georgy Bekes) Date: Wed, 25 Mar 2009 12:39:29 +0100 Subject: [erlang-questions] Is binary_to_term() safe for non trusted sources? In-Reply-To: <33c0ef3c-591a-4dd4-907d-89f3884f4f51@z15g2000yqm.googlegroups.com> References: <33c0ef3c-591a-4dd4-907d-89f3884f4f51@z15g2000yqm.googlegroups.com> Message-ID: <200903251239.29447.bekesa@sch.bme.hu> > Is it safe to decode a binary directly into an erlang term from an > uncontrolled client? My instinct says it's unsafe, but it doesn't say > so in the docs (maybe because it's obvious). Is there anyway to > really do harm if what is done with the decoded terms in erlang is > controlled? I can mention a possible DOS attack: an evil client can send you terms containing thousands of new atoms, and fill your atom table, causing a VM crash. Georgy From clist@REDACTED Wed Mar 25 12:52:08 2009 From: clist@REDACTED (Angel) Date: Wed, 25 Mar 2009 12:52:08 +0100 Subject: [erlang-questions] On Joe's micro-lightweight-unit-testing Message-ID: <200903251252.08482.clist@uah.es> Hi list Im very new to erlang, just still astonished about erlang and all, you guys, say here Still im trying every day going deeper and deeper on erlang and functional programing. Got recently very please reading Joe's introcction to TTD and Unit test on erlang shttp://armstrongonsoftware.blogspot.com/2009/01/micro-lightweight-unit-testing.html some where in the article Joe says.. step 4) Add unit tests for fastfib test/0 looks like this: test() -> 0 = fib(0), 1 = fib(1), 1 = fib(2), 6765 = fib(20), 0 = fastfib(0), 1 = fastfib(1), 1 = fastfib(2), 2 = fastfib(3), K = fib(25), K = fastfib(25), ok. Here I check that fastfib returns the same value as fib with the lines K = fib(25), K = fastfib(25). But K=fib(25) binds K to the value fib(25) so, K= fastbib(25) must be wrong as K was previously bound to fib(25) ?isnt it? so, What im missing here ? Thanks -- No imprima este correo si no es necesario. El medio ambiente est? en nuestras manos. __________________________________________ Clist UAH a.k.a Angel __________________________________________ ...being the second biggest search engine in the world is good enough for us. Peter @ Pirate Bay. From daniel.goertzen@REDACTED Wed Mar 25 12:57:47 2009 From: daniel.goertzen@REDACTED (Daniel Goertzen) Date: Wed, 25 Mar 2009 06:57:47 -0500 Subject: [erlang-questions] On Joe's micro-lightweight-unit-testing In-Reply-To: <200903251252.08482.clist@uah.es> References: <200903251252.08482.clist@uah.es> Message-ID: Since K is already bound in K=fastfib(25), that expression becomes a comparison instead of a bind. What the code really means is... fib(25) = fastfib(25), Dan. On Wed, Mar 25, 2009 at 6:52 AM, Angel wrote: > Hi list > > Im very new to erlang, just still astonished about erlang and all, you > guys, say here > > Still im trying every day going deeper and deeper on erlang and functional > programing. > > Got recently very please reading Joe's introcction to TTD and Unit test on > erlang > > shttp:// > armstrongonsoftware.blogspot.com/2009/01/micro-lightweight-unit-testing.html > > some where in the article Joe says.. > > step 4) Add unit tests for fastfib > > test/0 looks like this: > > test() -> > 0 = fib(0), > 1 = fib(1), > 1 = fib(2), > 6765 = fib(20), > 0 = fastfib(0), > 1 = fastfib(1), > 1 = fastfib(2), > 2 = fastfib(3), > K = fib(25), > K = fastfib(25), > ok. > > Here I check that fastfib returns the same value as fib with the lines > K = fib(25), > K = fastfib(25). > > But K=fib(25) binds K to the value fib(25) so, K= fastbib(25) must be wrong > as K was previously bound to fib(25) ?isnt it? > > so, What im missing here ? > > Thanks > > -- > No imprima este correo si no es necesario. El medio ambiente est? en > nuestras manos. > __________________________________________ > > Clist UAH a.k.a Angel > __________________________________________ > ...being the second biggest search engine in the world is good enough for > us. Peter @ Pirate Bay. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- Daniel Goertzen ----------------- work email: dang@REDACTED work phone: 1 443 303 8525 work sip: 945050@REDACTED ----------------- mobile: 1 204 470 8360 ----------------- home email: daniel.goertzen@REDACTED home phone: 1 204 272 6149 -------------- next part -------------- An HTML attachment was scrubbed... URL: From thomasl_erlang@REDACTED Wed Mar 25 12:42:09 2009 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Wed, 25 Mar 2009 04:42:09 -0700 (PDT) Subject: [erlang-questions] Erlang/OTP 13A and Darwin In-Reply-To: References: <8209f740903250227i6ea8f857o1c15aee11ac0ba14@mail.gmail.com> Message-ID: <154184.71024.qm@web111403.mail.gq1.yahoo.com> I assume what they are getting at is an emulator data representation issue. Too large integers overflow the fixnum format (28 bits on a 32-bit host, I believe), which means falling back to a less efficient representation and more complex arithmetic. 64-bit words mean you can represent about 60 bits or so as "immediates", so operations on 32-bit quantities, in particular, go faster and can be represented more compactly. This should, at a guess, be handled fairly well by just an appropriate port. Best, Thomas ________________________________ From: Camille Troillard To: Per Gustafsson Cc: erlang-questions@REDACTED Sent: Wednesday, March 25, 2009 11:59:00 AM Subject: Re: [erlang-questions] Erlang/OTP 13A and Darwin Thanks Ulf and Per, On Wed, Mar 25, 2009 at 11:42 AM, Per Gustafsson wrote: A type of calculation that becomes much more efficient on 64-bit machines are 32-bit fixed integer calculations, That is very interesting, would that mean that we could have faster arithmetic in Erlang without too much effort? I was looking for better math performance. What about 32 bits builds? Are there some possible (planned?) optimisations regarding this domain? Cam -------------- next part -------------- An HTML attachment was scrubbed... URL: From clist@REDACTED Wed Mar 25 13:09:44 2009 From: clist@REDACTED (Angel) Date: Wed, 25 Mar 2009 13:09:44 +0100 Subject: [erlang-questions] On Joe's micro-lightweight-unit-testing In-Reply-To: References: <200903251252.08482.clist@uah.es> Message-ID: <200903251309.44776.clist@uah.es> El Mi?rcoles, 25 de Marzo de 2009 12:57:47 Daniel Goertzen escribi?: > Since K is already bound in K=fastfib(25), that expression becomes a > comparison instead of a bind. > > What the code really means is... > > fib(25) = fastfib(25), Wow!! I see, just prolog syntax again!! Thats why all attemps to rebind variables to new values fail ?correct? the bind becomes a comparison that only success on equal values? K=2 K1=2 K=3 %% Fail!! K=K1 %% Correct Thanks! > > Dan. > > On Wed, Mar 25, 2009 at 6:52 AM, Angel wrote: > > > Hi list > > > > Im very new to erlang, just still astonished about erlang and all, you > > guys, say here > > > > Still im trying every day going deeper and deeper on erlang and functional > > programing. > > > > Got recently very please reading Joe's introcction to TTD and Unit test on > > erlang > > > > shttp:// > > armstrongonsoftware.blogspot.com/2009/01/micro-lightweight-unit-testing.html > > > > some where in the article Joe says.. > > > > step 4) Add unit tests for fastfib > > > > test/0 looks like this: > > > > test() -> > > 0 = fib(0), > > 1 = fib(1), > > 1 = fib(2), > > 6765 = fib(20), > > 0 = fastfib(0), > > 1 = fastfib(1), > > 1 = fastfib(2), > > 2 = fastfib(3), > > K = fib(25), > > K = fastfib(25), > > ok. > > > > Here I check that fastfib returns the same value as fib with the lines > > K = fib(25), > > K = fastfib(25). > > > > But K=fib(25) binds K to the value fib(25) so, K= fastbib(25) must be wrong > > as K was previously bound to fib(25) ?isnt it? > > > > so, What im missing here ? > > > > Thanks > > > > -- > > No imprima este correo si no es necesario. El medio ambiente est? en > > nuestras manos. > > __________________________________________ > > > > Clist UAH a.k.a Angel > > __________________________________________ > > ...being the second biggest search engine in the world is good enough for > > us. Peter @ Pirate Bay. > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > -- Este correo no tiene dibujos. Las formas extra?as en la pantalla son letras. __________________________________________ Clist UAH a.k.a Angel __________________________________________ Money is a good standard. Micro$oft. From ext@REDACTED Wed Mar 25 13:40:42 2009 From: ext@REDACTED (David Sveningsson) Date: Wed, 25 Mar 2009 13:40:42 +0100 Subject: [erlang-questions] Dialyzer warning: variable can never match since previous clauses completely covered the type Message-ID: <49CA264A.4040109@sidvind.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, I have an issue with a dialyzer warning, see the test-case below. I don't know if I'm doing something wrong or not but I cant fix the warning. Any ideas? - -module(test). - -export([start/0]). - -spec foo() -> ok | {error, reason}. foo() -> case random:uniform(10) of N when N > 5 -> ok; _ -> {error, foobar} end. start() -> {A,B,C} = now(), random:seed(A,B,C), R = case foo() of ok -> ok; Error -> Error end, io:format("R: ~p~n", [R]), init:stop(0). # dialyzer -c test.erl --src Checking whether the PLT /Users/ext/.dialyzer_plt is up-to-date... yes Proceeding with analysis... test.erl:18: The variable Error can never match since previous clauses completely covered the type 'ok' Unknown functions: init:stop/1 done in 0m0.26s done (warnings were emitted) -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.11 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAknKJkoACgkQ6pa1H/H5pqXzmQCfRfFxQjY1XwF8xV5RiU6RNHtA d70An29l0rqiLMQLIaiBt1HSu1O6U5WK =rWIu -----END PGP SIGNATURE----- From masse@REDACTED Wed Mar 25 14:40:01 2009 From: masse@REDACTED (mats cronqvist) Date: Wed, 25 Mar 2009 14:40:01 +0100 Subject: [erlang-questions] How do I elegantly check many conditions? In-Reply-To: <4d08db370903241506m197a6a5cs9b3d967cfdacf0f4@mail.gmail.com> (Hynek Vychodil's message of "Tue\, 24 Mar 2009 23\:06\:18 +0100") References: <27110039.92561237902320511.JavaMail.root@zimbra> <18897457.92581237902517556.JavaMail.root@zimbra> <4d08db370903240849v47f3823ak22c4a2a6363d5c88@mail.gmail.com> <87zlfad5zw.fsf@sterlett.hq.kred> <4d08db370903241506m197a6a5cs9b3d967cfdacf0f4@mail.gmail.com> Message-ID: <87myb9d8lq.fsf@sterlett.hq.kred> Hynek Vychodil writes: > On Tue, Mar 24, 2009 at 9:24 PM, mats cronqvist wrote: > > Hynek Vychodil writes: > > > code > > > > ok = is_new_email1(Email). > > > > doesn't looks like same amount of code > > > > try is_new_email2(Email) catch throw:email_in_use -> email_in_use end. > > > > First one turns return value to exception, second one turns exception to > > return value. Second one seems more code, does not? > > ?but the exception generated in example 1 is a worthless 'badmatch'. > > I can flexible choose which worth-full 'badmatch'? will be generated just > using {ok, Email} = {is_new_email1(Email), Email}. That's just a stupid hack. Anyway, I don't understand what you're getting so worked up about. Basically all OTP functions return {ok,Val}, and that's not likely to change anytime soon, regardless of how dumb or smart it is. mats From magnus@REDACTED Wed Mar 25 14:45:53 2009 From: magnus@REDACTED (Magnus Henoch) Date: Wed, 25 Mar 2009 13:45:53 +0000 Subject: [erlang-questions] Dialyzer warning: variable can never match since previous clauses completely covered the type References: <49CA264A.4040109@sidvind.com> Message-ID: <84iqlx4sxa.fsf@linux-b2a3.site> David Sveningsson writes: > -spec foo() -> ok | {error, reason}. This is not what you meant to write. You declare that foo returns either the atom 'ok', or a tuple of two atoms, 'error' and 'reason'. > foo() -> > case random:uniform(10) of > N when N > 5 -> ok; > _ -> {error, foobar} > end. Dialyzer believes your spec, and finds that your code can not possibly return {error, reason}. Therefore, the only remaining possibility is 'ok'. You could write the spec as {error, foobar}, {error, atom()} or {error, Reason::atom()}. -- Magnus Henoch, magnus@REDACTED Erlang Training and Consulting http://www.erlang-consulting.com/ From bengt.kleberg@REDACTED Wed Mar 25 15:03:18 2009 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Wed, 25 Mar 2009 15:03:18 +0100 Subject: [erlang-questions] How do you transform a record properly? In-Reply-To: References: Message-ID: <1237989798.4731.64.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> Greetings, You are doing it the right way. Unless you change the name of the tuple when you change the contents. But that would perhaps be a problem for mnesia. bengt On Mon, 2009-03-23 at 20:18 -0700, ryeguy wrote: > How would you add a field to a table using mnesia:table_transform? I > got it to work by just using a raw tuple in the function header, but > how do you match the old record, then output the new record with just > the new field added/changed? > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From kris_prieb@REDACTED Wed Mar 25 15:16:47 2009 From: kris_prieb@REDACTED (Kris Prieb) Date: Wed, 25 Mar 2009 09:16:47 -0500 Subject: [erlang-questions] where to find correct documentation for erlang distribution over SSL? In-Reply-To: <51834A08-00C9-483F-8529-40D648EE62A7@fitzsimons.org> References: <4537c3580903231435j507400ffn77b6eafe2e27e580@mail.gmail.com> <4537c3580903232029m2a6e3275ocec4d69ebdead924@mail.gmail.com> <49C941A1.2040700@fitzsimons.org> <4537c3580903241430l298e63c0ka795ccf6d37aac12@mail.gmail.com> <49C9D9FC.8050707@erix.ericsson.se> <51834A08-00C9-483F-8529-40D648EE62A7@fitzsimons.org> Message-ID: <4537c3580903250716t315701actcdfe46b7380d67bf@mail.gmail.com> Yes, Dan, thank you for your reply and for your work. SSL distribution is a terrific feature. Kris On Wed, Mar 25, 2009 at 4:02 AM, Bruce Fitzsimons wrote: > Great work Dan, thanks for the reply and the not-insignificant-work of > making SSL distribution work again. > > Cheers, > Bruce > > > On 25/03/2009, at 8:15 PM, Dan Gudmundsson wrote: > >> >> Yes it was broken in at least R12B-5, it is fixed again in R13A. >> >> And I worded the OTP-7536 like that because I thought but didn't know (and >> had no time to >> investigate) if it only was the documentation that was the problem, turns >> out the code was >> broken. >> >> I guess the docs still need work, but the code works now :-) >> >> /Dan >> >> Kris Prieb wrote: >>> >>> Hi Bruce, list, >>> >>> Yes, you might be right: I may have misinterpreted the release note to >>> mean only that the documentation was wrong. ?Perhaps distribution over >>> SSL is in fact broken in SSL 3.10 (OTP R12B5). ?I just assumed that it >>> was working because the release just prior, SSL 3.9 (OTP R12B4), has >>> the following release note: >>> >>> "Erlang distribution over ssl was broken after R11B-0, this has now been >>> fixed. >>> Own Id: OTP-7004" >>> >>> I second the request for comment from someone from OTP. >>> >>> I also agree that distribution over SSL is *great* functionality. ?If >>> it has been broken I hope it gets fixed again for R13. >>> >>> Kris >>> >>> On Tue, Mar 24, 2009 at 3:25 PM, Bruce Fitzsimons >>> wrote: >>>> >>>> Hi Kris, list, >>>> >>>> Is OTP-7536 actually fixed? I can't see any reference to it moving from >>>> "known" to "fixed". Was it really just documentation? >>>> >>>> I've not revisted or retested SSL distribution since I created the patch >>>> to >>>> make it work and then lost interest in the proto-project that required >>>> it >>>> for Front End to Back End communcation across the internet. That was on >>>> R11B-5. I don't know if it has been reworked to work out of the box in >>>> later >>>> releases, or if my convoluted patch was accepted in some form, and I've >>>> not >>>> had a chance to look. Can anyone from OTP comment? >>>> >>>> I know the Erlang SSL infrastructure has evolved, and SSL distribution >>>> wasn't overly loved/used by customers (apparently) but it is great >>>> functionality. >>>> >>>> Cheers, >>>> Bruce >>>> >>>> Kris Prieb wrote: >>>>> >>>>> Michael, I'm already familiar with the contents at the link you >>>>> mentioned through a lot of googling, but thanks anyway. >>>>> >>>>> After some further noodling around I've been able to establish an SSL >>>>> connection to a single node where I've created the initiating >>>>> (non-erlang node) end point myself using the SSL application. ?I still >>>>> am unable get the full erlang distribution running on SSL, however, so >>>>> I remain open to suggestions. >>>>> >>>>> Kris >>>>> >>>>> >>>>> >>>>> ------------------------------------------------------------------------------------------------------------- >>>>> Date: Mon, 23 Mar 2009 16:01:58 -0700 >>>>> From: Michael McDaniel >>>>> Subject: Re: [erlang-questions] where to find correct documentation >>>>> ? ? for ? ? erlang distribution over SSL? >>>>> To: erlang-questions@REDACTED >>>>> Message-ID: <20090323230157.GO18122@REDACTED> >>>>> Content-Type: text/plain; charset=iso-8859-1 >>>>> >>>>> >>>>> old, but possibly will assist ... >>>>> >>>>> >>>>> http://trapexit.org/Distributed_erlang_using_ssl_through_firewalls >>>>> >>>>> >>>>> ~M >>>>> >>>>> >>>>> On Mon, Mar 23, 2009 at 04:35:51PM -0500, Kris Prieb wrote: >>>>> >>>>>> I have been trying to start erlang distribution over SSL using SSL >>>>>> 3.10 in OTP R12-B5 by following Section 5 of the SSL User's Guide >>>>>> (http://www.erlang.org/doc/apps/ssl/usersguide_frame.html). ?I have >>>>>> gotten two nodes up, but I cannot get them to successfully >>>>>> net_adm:ping/1 each other.?(I get a pang not a pong). ?I only just >>>>>> read that the documentation for distribution over SSL is in fact not >>>>>> entirely correct. ?As noted in the release notes for SSL 3.10: >>>>>> >>>>>> "1.1.3 Known Bugs and Problems >>>>>> Running erlang distribution over ssl don't work as described in the >>>>>> documentation. >>>>>> Own Id: OTP-7536" >>>>>> >>>>>> Does anyone know where I might find correct documentation on erlang >>>>>> distribution over SSL, or alternatively, what parts of the current >>>>>> documentation are incorrect and how? >>>>>> >>>>>> Thanks in advance! >>>>>> Kris >>>>>> _______________________________________________ >>>>>> erlang-questions mailing list >>>>>> erlang-questions@REDACTED >>>>>> http://www.erlang.org/mailman/listinfo/erlang-questions >>>>>> >>>>> -- >>>>> Michael McDaniel >>>>> Portland, Oregon, USA >>>>> http://autosys.us >>>>> http://mmcdaniel.com/erlview >>>>> _______________________________________________ >>>>> 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 richardc@REDACTED Wed Mar 25 15:35:09 2009 From: richardc@REDACTED (Richard Carlsson) Date: Wed, 25 Mar 2009 15:35:09 +0100 Subject: [erlang-questions] How do I elegantly check many conditions? In-Reply-To: <4d08db370903230622w67a28822qe61740197b154e63@mail.gmail.com> References: <3881703.90711237811859482.JavaMail.root@zimbra> <6588370.90731237811980293.JavaMail.root@zimbra> <4d08db370903230622w67a28822qe61740197b154e63@mail.gmail.com> Message-ID: <49CA411D.4040300@it.uu.se> Hynek Vychodil wrote: > If I have function like > > is_new_email(Email) -> > case mnesia:dirty_read(email, Email) of > [] -> ok; > _Else -> email_in_use > end. > > I can choose if use it as > > case is_new_email(Email) of > ok -> do_something(); > email_in_use -> do_something_other() > end > > or as > > ok = is_new_email(Email); > > When You trow exception, I can't choose. Of course you can choose. If you have: check_new_email(Email) -> case mnesia:dirty_read(email, Email) of [] -> ok; _Else -> throw(email_in_use) end. you can use it as try check_new_email(Email) of ok -> do_something() catch email_in_use -> do_something_other() end or as check_new_email(Email) One advantage of this variant is that if the exception falls through, you can find out that it was thrown from new_email() rather than just seeing a badmatch in the calling function. That doesn't mean that I'd use exceptions for the OP's original question. Maybe, but not necessarily. /Richard From erlang@REDACTED Wed Mar 25 15:39:10 2009 From: erlang@REDACTED (Joe Armstrong) Date: Wed, 25 Mar 2009 15:39:10 +0100 Subject: [erlang-questions] On Joe's micro-lightweight-unit-testing In-Reply-To: <200903251252.08482.clist@uah.es> References: <200903251252.08482.clist@uah.es> Message-ID: <9b08084c0903250739u2c59fc99gc2ae8022b2f0f5a1@mail.gmail.com> On Wed, Mar 25, 2009 at 12:52 PM, Angel wrote: > Hi list > > Im very new to erlang, just still astonished about erlang and all, you guys, say here > > Still im trying every day going deeper and deeper on erlang and functional programing. > > Got recently very please reading Joe's introcction to TTD and Unit test on erlang > > shttp://armstrongonsoftware.blogspot.com/2009/01/micro-lightweight-unit-testing.html > > some where in the article Joe says.. > > step 4) Add unit tests for fastfib > > test/0 looks like this: > > test() -> > 0 = fib(0), > 1 = fib(1), > 1 = fib(2), > 6765 = fib(20), > 0 = fastfib(0), > 1 = fastfib(1), > 1 = fastfib(2), > 2 = fastfib(3), > K = fib(25), > K = fastfib(25), > ok. > > Here I check that fastfib returns the same value as fib with the lines > ?K = fib(25), > K = fastfib(25). > > But K=fib(25) binds K to the value fib(25) so, K= fastbib(25) must be wrong > as K was previously bound to fib(25) ?isnt it? Take the argument in small steps: K = 10, K = 10, succeeds (unsurprisingly), but K = 10, K = 11, fails (K can't be both 10 and 11) Now change the right hand side of '=' to a function call K = 10, K = f2(..) This means evaluate f2(...), and test if it is 10 - just like the above K = f1(), K = f2() means evalate f1() then evalute f2() and test if it has the same value as f1() . When you look at a code fragment containing a variable in a pattern you should mentally think "is this the first time I've seen this variable" if the answer is yes, then the variable will become bound if the pattern match succeeds. If no then the pattern match acts as a test, which will succeed or fail depending upon the value of the variable. /Joe /Joe > > so, What im missing here ? > > Thanks > > -- > No imprima este correo si no es necesario. El medio ambiente est? en nuestras manos. > __________________________________________ > > Clist UAH a.k.a Angel > __________________________________________ > ...being the second biggest search engine in the world is good enough for us. Peter @ Pirate Bay. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From rob.charlton@REDACTED Wed Mar 25 16:19:44 2009 From: rob.charlton@REDACTED (Rob Charlton) Date: Wed, 25 Mar 2009 15:19:44 +0000 Subject: [erlang-questions] How do you transform a record properly? In-Reply-To: <49CA3F20.1040102@savageminds.com> References: <1237989798.4731.64.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> <49CA3F20.1040102@savageminds.com> Message-ID: <49CA4B90.3060009@savageminds.com> Actually, disregard that - I ended up with a table full of #rate_dest_new records, so I had to do another transform back to #rate_dest! I agree with Bengt - you're doing it the right way :) Cheers Rob Rob Charlton wrote: > Hi, > > I don't think mnesia minds, because it treats the table name > differently from the record name used to access it. I just added a new > field using the example from here: > http://erlang.org/doc/apps/mnesia/Mnesia_chap3.html#3.1.1 > > In my own example, the table name and original record name was > "rate_dest". The new record name was "rate_dest_new" which was > identical apart from one extra field. After running the transform, I > just added the new field to record rate_dest and deleted the > definition of rate_dest_new. > > Cheers > > Rob > > Bengt Kleberg wrote: >> Greetings, >> >> You are doing it the right way. >> >> Unless you change the name of the tuple when you change the contents. >> But that would perhaps be a problem for mnesia. >> >> >> bengt >> >> On Mon, 2009-03-23 at 20:18 -0700, ryeguy wrote: >> >>> How would you add a field to a table using mnesia:table_transform? I >>> got it to work by just using a raw tuple in the function header, but >>> how do you match the old record, then output the new record with just >>> the new field added/changed? >>> _______________________________________________ >>> 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 >> > > -- Rob Charlton Savage Minds Ltd +44 20 79210521 rob.charlton@REDACTED skype: chocolatetpot www.savageminds.com From ext@REDACTED Wed Mar 25 16:31:06 2009 From: ext@REDACTED (David Sveningsson) Date: Wed, 25 Mar 2009 16:31:06 +0100 Subject: [erlang-questions] Dialyzer warning: variable can never match since previous clauses completely covered the type In-Reply-To: <84iqlx4sxa.fsf@linux-b2a3.site> References: <49CA264A.4040109@sidvind.com> <84iqlx4sxa.fsf@linux-b2a3.site> Message-ID: <49CA4E3A.20908@sidvind.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Magnus Henoch wrote: > David Sveningsson writes: > >> -spec foo() -> ok | {error, reason}. > > This is not what you meant to write. You declare that foo returns > either the atom 'ok', or a tuple of two atoms, 'error' and 'reason'. Right, I meant {error, atom()}. I did however have a similar issue in my code. >> foo() -> >> case random:uniform(10) of >> N when N > 5 -> ok; >> _ -> {error, foobar} >> end. > > Dialyzer believes your spec, and finds that your code can not possibly > return {error, reason}. Therefore, the only remaining possibility is > 'ok'. > > You could write the spec as {error, foobar}, {error, atom()} or {error, > Reason::atom()}. Lets say that foo looks like this: - -spec foo() -> ok | {error, atom()}. foo() -> ok. I get the same error. It is true that the function will only return ok, but I would like to reserve that it may return {error, atom()} in the future. It that possible? -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.11 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAknKTjoACgkQ6pa1H/H5pqWrKwCglz8a5i7qEG7DvLUq+fT1ThP7 mroAn3fgvCiIHilB6WJqulrmQaqCkGZD =dHTW -----END PGP SIGNATURE----- From rob.charlton@REDACTED Wed Mar 25 15:26:40 2009 From: rob.charlton@REDACTED (Rob Charlton) Date: Wed, 25 Mar 2009 14:26:40 +0000 Subject: [erlang-questions] How do you transform a record properly? In-Reply-To: <1237989798.4731.64.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> References: <1237989798.4731.64.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> Message-ID: <49CA3F20.1040102@savageminds.com> Hi, I don't think mnesia minds, because it treats the table name differently from the record name used to access it. I just added a new field using the example from here: http://erlang.org/doc/apps/mnesia/Mnesia_chap3.html#3.1.1 In my own example, the table name and original record name was "rate_dest". The new record name was "rate_dest_new" which was identical apart from one extra field. After running the transform, I just added the new field to record rate_dest and deleted the definition of rate_dest_new. Cheers Rob Bengt Kleberg wrote: > Greetings, > > You are doing it the right way. > > Unless you change the name of the tuple when you change the contents. > But that would perhaps be a problem for mnesia. > > > bengt > > On Mon, 2009-03-23 at 20:18 -0700, ryeguy wrote: > >> How would you add a field to a table using mnesia:table_transform? I >> got it to work by just using a raw tuple in the function header, but >> how do you match the old record, then output the new record with just >> the new field added/changed? >> _______________________________________________ >> 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 > -- Rob Charlton Savage Minds Ltd +44 20 79210521 rob.charlton@REDACTED skype: chocolatetpot www.savageminds.com From gleber.p@REDACTED Wed Mar 25 16:43:59 2009 From: gleber.p@REDACTED (Gleb Peregud) Date: Wed, 25 Mar 2009 16:43:59 +0100 Subject: [erlang-questions] Is there a mature xmpp cllient for erlang? In-Reply-To: References: Message-ID: <14f0e3620903250843k67ee7e3flf24dc5718b07922@mail.gmail.com> There's a natter - a XMPP client in Erlang by EngineYard. Haven't tested it myself. It is still pre 1.0 version. http://github.com/engineyard/natter/ On 2009-03-24, devdoer bird wrote: > HI: > > Is there a mature xmpp client for erlang? > > I tried jabberlang( > https://support.process-one.net/doc/display/CONTRIBS/Jabberlang),bug it > failed to work with recent ejabberd because it use old ejabberd package's > xml stream function . > > I found exmpp would replace the jabberlang ,but I found it nowhere. > > So anyone can give a mature xmpp client? > -- Gleb Peregud http://gleber.pl/ Every minute is to be grasped. Time waits for nobody. -- Inscription on a Zen Gong From ulf.wiger@REDACTED Wed Mar 25 17:34:44 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Wed, 25 Mar 2009 17:34:44 +0100 Subject: [erlang-questions] Thoughts about server abstraction and process management In-Reply-To: <4a2836ab-c55f-4d6e-ad04-659dac962cac@c11g2000yqj.googlegroups.com> References: <4a2836ab-c55f-4d6e-ad04-659dac962cac@c11g2000yqj.googlegroups.com> Message-ID: <49CA5D24.3060408@erlang-consulting.com> zambal wrote: > > However, assuming that my concerns are valid, lets > continue with just the minimal code needed to get > an alternative generic server running without > worrying about error handling, timeouts, etc.: You can implement the exact same abstractions on top of gen_server. See below. > First, the generic server code > > %% begin yasa.erl (yet another server abstraction) > -module(yasa). > -export([new/2, client/1]). > -export([behaviour_info/1]). > > behaviour_info(callbacks) -> > [{init, 1}, {handler, 2}, {terminate, 1}]; > behaviour_info(_Other) -> > undefined. > > new(Mod, State) -> > client(spawn(fun()-> server(Mod, Mod:init(State)) end)). new(Mod, State) -> client(gen_server:start(?MODULE, {Mod, State}, [])) > > client(Pid) -> > fun(X) -> > Pid ! {self(), X}, > receive {Pid, Reply} -> Reply end > end. client({ok, Pid}) -> fun(X) -> gen_server:call(Pid, X) end. > server(Mod, State) -> > receive > {Pid, {stop}} -> > Reply = Mod:terminate(State), > Pid ! {self(), Reply}; > {Pid, X} -> > {Reply, NewState} = Mod:handler(X, State), > Pid ! {self(), Reply}, > server(Mod, NewState); > _ -> > server(Mod, State) > end. > %% end yasa.erl init({Mod, State}) -> S = Mod:init(State), {ok, S}. handle_call({stop}, _From, S) -> Reply = Mod:terminate(S), {stop, Reply, normal, S}; handle_call(X, _From, S) -> Mod:handler(X, S). terminate(_, _) -> ok. > I'm pretty happy with the result of all this and > I can see myself using this solution in small > Erlang projects, however I'm very curious > what other people think of this generic server > solution. I think it's fine, but I would use the gen_server module in the implementation, as sketched above. > It's quite easy for processes to become orphaned > the same way as it's easy to leak memory in languages > with manual memory management. You can have the server monitor the client, or start it with a link. > So I was wondering if there ever have been any ideas > about process management like how memory is managed in > garbage collected languages? > I don't know anything about the internals of garbage > collectors, but I can imagine that something like > reference counted Pids could work: as soon as the last > reference to a Pid in an Erlang node is cleared by > the garbage collector and there's still a process > active with that Pid, it should be pretty safe to kill it. I can recall that the idea has been discussed in the past, but for better or for worse, it's rather too late for that. It would probably break existing code in gruesome ways. BR, Ulf W -- Ulf Wiger CTO, Erlang Training & Consulting Ltd http://www.erlang-consulting.com From kirk.bateman@REDACTED Wed Mar 25 17:56:52 2009 From: kirk.bateman@REDACTED (Kirk Bateman) Date: Wed, 25 Mar 2009 16:56:52 +0000 Subject: [erlang-questions] Is there a mature xmpp cllient for erlang? Message-ID: <2bee4fc40903250956v7bda74b9hf8a67be891ebace3@mail.gmail.com> As far as I remember it was only a matter of grabbing the newer xmlstream code from an ejabberd source distro and rebuilding jabberlang using that. I think I had it working with 2.0.1 Hope that is partially helpful Cheers Kirk ---------- Forwarded message ---------- > From: Gleb Peregud > To: devdoer bird > Date: Wed, 25 Mar 2009 16:43:59 +0100 > Subject: Re: [erlang-questions] Is there a mature xmpp cllient for erlang? > There's a natter - a XMPP client in Erlang by EngineYard. Haven't > tested it myself. It is still pre 1.0 version. > > http://github.com/engineyard/natter/ > > On 2009-03-24, devdoer bird wrote: > > HI: > > > > Is there a mature xmpp client for erlang? > > > > I tried jabberlang( > > https://support.process-one.net/doc/display/CONTRIBS/Jabberlang),bug it > > failed to work with recent ejabberd because it use old ejabberd package's > > xml stream function . > > > > I found exmpp would replace the jabberlang ,but I found it nowhere. > > > > So anyone can give a mature xmpp client? > > > > > -- > 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tobias.lindahl@REDACTED Wed Mar 25 17:59:48 2009 From: tobias.lindahl@REDACTED (Tobias Lindahl) Date: Wed, 25 Mar 2009 17:59:48 +0100 Subject: [erlang-questions] Dialyzer warning: variable can never match since previous clauses completely covered the type In-Reply-To: <49CA4E3A.20908@sidvind.com> References: <49CA264A.4040109@sidvind.com> <84iqlx4sxa.fsf@linux-b2a3.site> <49CA4E3A.20908@sidvind.com> Message-ID: <49CA6304.6020702@kreditor.se> David Sveningsson wrote: > Lets say that foo looks like this: > > - -spec foo() -> ok | {error, atom()}. > foo() -> > ok. > > I get the same error. It is true that the function will only return ok, > but I would like to reserve that it may return {error, atom()} in the > future. It that possible? To add the spec and have Dialyzer accept it: Yes. To make Dialyzer be quiet about the dead code: No. Dialyzer uses both the spec and the type it finds in the analysis. It finds that your function returns 'ok', which is ok since it does not contradict your spec. However, it will not widen the return type to the one in the spec, but use the more precise type that it has found in the analysis. A -spec can never make your types less precise. Tobias From dietmar-s@REDACTED Wed Mar 25 20:05:50 2009 From: dietmar-s@REDACTED (Dietmar Schaefer) Date: Wed, 25 Mar 2009 20:05:50 +0100 Subject: [erlang-questions] Is there a mature xmpp cllient for erlang? In-Reply-To: References: Message-ID: <49CA808E.3020703@online.de> Hi ! I was looking for one too - and couldn't find one either ! Dietmar From rvirding@REDACTED Wed Mar 25 22:16:31 2009 From: rvirding@REDACTED (Robert Virding) Date: Wed, 25 Mar 2009 22:16:31 +0100 Subject: [erlang-questions] leex and yecc spotting double newline In-Reply-To: <49C72836.4020402@ghostgun.com> References: <49C72836.4020402@ghostgun.com> Message-ID: <3dbc6d1c0903251416j1f18eafej717fe36e2d725390@mail.gmail.com> Hi Jeff, 2009/3/23 jm > Say the lexer definition contains, among other things, > > Definitions. > W = [^=\s\r\n] > WS = \s > CR = \r > NL = \n > EQ = = > > Rules. > {W}+ : {token, {word, TokenLine, TokenChars}}. > {EQ} : {token, {eq, TokenLine, TokenChars}}. > {WS}+ : {token, {ws, TokenLine, TokenChars}}. > ({CR}|{NL}|{CR}{NL}) : {token, {nl, TokenLine, TokenChars}}. > > > At the moment, the yecc definition file contains, > > Nonterminals > request lines line lhs rhs words. > > Terminals > eq word ws nl. > > Rootsymbol request. > request -> lines : '$1'. > > lines -> line nl : ['$1']. > lines -> line lines nl : ['$1'] ++ '$3'. > > line -> lhs eq rhs nl : {line, '$1', '$3'}. > > lhs -> word : {lhs, '$1'}. > > rhs -> words : {rhs, '$1'}. > > words -> word : ['$1']. > words -> word ws words : ['$1', '$2'] ++ '$3'. > > > and is designed to parse the postfix policy request (see > http://www.postfix.org/SMTPD_POLICY_README.html) > > A couple of questions: > > 1) What do I put in the yecc file so the it can spot a double newline > which is used to terminate a request? Just of the top of my head I think you could do it by defining: request -> lines nl : {request,'$1'}. lines -> line : ['$1']. lines -> lines line : '$1' ++ ['$2']. line -> lhs eq rhs nl : {line, '$1', '$3'}. I think this will do it assuming you only allow one blank line between requests and you always have one blank line after a request, even after the last one. Sitting at a conference now so I will try it later tonight. Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: From mcpherson@REDACTED Wed Mar 25 23:58:50 2009 From: mcpherson@REDACTED (Allen McPherson) Date: Wed, 25 Mar 2009 16:58:50 -0600 Subject: [erlang-questions] Messaging mechanisms between Erlang runtimes? Message-ID: <073BA22E-FDA8-42B8-BEFE-7C1417A8127E@lanl.gov> I'm running network performance tests on clusters with distributed Erlang. I'm trying to analyze what I'm seeing without asking a bunch of questions here (or digging through the source). When I get most of it wrung out I'll attempt to post code and results, but for now I am seeing some strange stuff...like similar messaging bandwidth regardless of whether the endpoints are on the same node or different nodes. There are all kinds of variables I need to work my way through, but one quick question I have is this: Does Erlang implement any optimizations for messaging between runtimes on the same node? My code is pretty simple: slave:start_link to local (localhost) or remote nodes, spawn a bunch of tasks on these nodes, and time large message traffic between them in various patterns (ping-pong, all-to-all, etc.). Note that on the local node this is not messaging between processes (Erlang "threads") but between different instances of the Erlang runtime. Obviously, messaging within a single runtime blazes (especially with term_to_binary). Thanks -- Al From ok@REDACTED Thu Mar 26 01:45:59 2009 From: ok@REDACTED (Richard O'Keefe) Date: Thu, 26 Mar 2009 13:45:59 +1300 Subject: [erlang-questions] Standard modern salary for an Erlang programmer? In-Reply-To: <2a67d3ff0903240722x14203c54j693bb1d12fd92953@mail.gmail.com> References: <2a67d3ff0903240722x14203c54j693bb1d12fd92953@mail.gmail.com> Message-ID: On 25 Mar 2009, at 3:22 am, G.S. wrote: > What's a standard, good average salary for the Erlang programmer > with a few years of experience, based in USA? > Java is 70-90k, Wow. That's about double what I make as a university lecturer. > and I read online that since us Erlangers, being a less known, and > essential for writing software that scales, and will scale into the > future, is much higher. I seem to find various blogs that state the > salary in 2008 was anywhere from 99k to 180k. Double wow. That's _unimaginable_ wealth. Do we seriously expect pay rates like these to continue in the global depression? We're seeing a lot of big companies telling their consultants and employees to take 10% pay cuts, and I don't suppose the pay cuts have stopped yet. From billrobertson42+erlang@REDACTED Thu Mar 26 04:09:55 2009 From: billrobertson42+erlang@REDACTED (bill robertson) Date: Wed, 25 Mar 2009 23:09:55 -0400 Subject: [erlang-questions] Mnesia and Berkely DB Message-ID: I remember reading about the possible combination of using Berkely DB as a baking store for Mnesia. Did anything ever come of that? I can't seem to find much information. Thanks From ossareh@REDACTED Thu Mar 26 04:43:47 2009 From: ossareh@REDACTED (Michael Ossareh) Date: Wed, 25 Mar 2009 20:43:47 -0700 Subject: [erlang-questions] Standard modern salary for an Erlang programmer? In-Reply-To: <2a67d3ff0903240722x14203c54j693bb1d12fd92953@mail.gmail.com> References: <2a67d3ff0903240722x14203c54j693bb1d12fd92953@mail.gmail.com> Message-ID: 2009/3/24 G.S. : > Hello everyone, > > What's a standard, good average salary for the Erlang programmer with a few > years of experience, based in USA? > Java is 70-90k, and I read online that since us Erlangers, being a less > known, and essential for writing software that scales, and will scale into > the future, is much higher. I seem to find various blogs that state the > salary in 2008 was anywhere from 99k to 180k. As far as I've managed to work out salary is dependent on the industry first, the tools second, the company third. In the accounting/banking industry you're likely to get paid more to code server side java in a well established company than doing the same in a web site creation industry. I know a system admin who wrote everything in perl and worked for a huge mobile content distribution company that got paid far in excess of me as a java coder. Simply the company he worked for had more money coming in. For a lot of industries you'll, unfortunately, find it hard to find erlang accepted commonly. Smaller companies are more likely, in the near term, to accept erlang - and as such you'll probably find it harder to get bigger salaries. Clearly there are going to be exceptions to this so limit the flames :) I often find myself wondering if learning dying languages is a better way to get paid more than learning new languages that gain popularity. Cobol in banking anyone? =) > > Can anyone throw a few numbers at me that are currently working in the > industry using Erlang? > > Thanks, > -Gene > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- god loves atheists, Fact: http://www.mrwiggleslovesyou.com/comics/rehab477.jpg From ossareh@REDACTED Thu Mar 26 04:46:42 2009 From: ossareh@REDACTED (Michael Ossareh) Date: Wed, 25 Mar 2009 20:46:42 -0700 Subject: [erlang-questions] Is there a mature xmpp cllient for erlang? In-Reply-To: <49CA808E.3020703@online.de> References: <49CA808E.3020703@online.de> Message-ID: Definitely a few in the works that I know of. A co-worker of mine is building one - I don't know if he intends to opensource it. process-one have one (exmpp) that I understand their close to releasing. Good to hear people looking for this stuff, definitely sucks that the landscape is so barren. On Wed, Mar 25, 2009 at 12:05 PM, Dietmar Schaefer wrote: > Hi ! > > > I was looking for one too - and couldn't find one either ! > > Dietmar > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- god loves atheists, Fact: http://www.mrwiggleslovesyou.com/comics/rehab477.jpg From ryeguy1@REDACTED Thu Mar 26 04:47:12 2009 From: ryeguy1@REDACTED (ryeguy) Date: Wed, 25 Mar 2009 20:47:12 -0700 (PDT) Subject: [erlang-questions] Dedicated mnesia nodes or fragmented nodes? Message-ID: I have 2 cluster layouts in mind, and was wondering what the pros and cons are for each: 1) Nodes are either worker nodes, or mnesia nodes. Mnesia nodes contain only tables and do nothing else; worker nodes do all the heavy lifting. 2) All hybrid nodes - all nodes do heavy lifting, and each node has a mnesia table fragment on it. From nesrait@REDACTED Thu Mar 26 04:55:03 2009 From: nesrait@REDACTED (=?ISO-8859-1?Q?Davide_Marqu=EAs?=) Date: Thu, 26 Mar 2009 03:55:03 +0000 Subject: [erlang-questions] Mnesia and Berkely DB In-Reply-To: References: Message-ID: <523869a70903252055l25b776c1n57fec3151a8fc3ae@mail.gmail.com> Hi, These might help: http://dukesoferl.blogspot.com/2008/06/tokyocabinet-and-mnesia.html http://groups.google.com/group/thinkerlang/msg/329198523c8c2246 Cheers, Davide On Thu, Mar 26, 2009 at 3:09 AM, bill robertson < billrobertson42+erlang@REDACTED >wrote: > I remember reading about the possible combination of using Berkely DB > as a baking store for Mnesia. Did anything ever come of that? I > can't seem to find much information. > > Thanks > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jeffm@REDACTED Thu Mar 26 05:04:03 2009 From: jeffm@REDACTED (jm) Date: Thu, 26 Mar 2009 15:04:03 +1100 Subject: [erlang-questions] Standard modern salary for an Erlang programmer? In-Reply-To: References: <2a67d3ff0903240722x14203c54j693bb1d12fd92953@mail.gmail.com> Message-ID: <49CAFEB3.7030609@ghostgun.com> Michael Ossareh wrote: > I often find myself wondering if learning dying languages is a better > way to get paid more than learning new languages that gain popularity. > Cobol in banking anyone? =) > > I've heard the samething. And it's not just banking there's at least one organisation in town that has its payroll system on something in written Cobol of all things. To get back on topic. It'd be interested in any info on peoples experiences salary wise even from past jobs. I think that the original poster in dreaming and what a nice dream a salary like that would be. Almost enough to make me move to the US...almost. You right about the industry being the determining factor in salaries, but the industry will quite often have an excepted list of languages which you can use. If it's not explicitly stated it's at least implied. So if you wish to use a cool language you may be limiting yourself in your industry choice. They have to make you suffer to justify paying you, it's important to be seen to be busy not to be productive :-). Jeff. From chandrashekhar.mullaparthi@REDACTED Thu Mar 26 06:47:45 2009 From: chandrashekhar.mullaparthi@REDACTED (Chandru) Date: Thu, 26 Mar 2009 05:47:45 +0000 Subject: [erlang-questions] Dedicated mnesia nodes or fragmented nodes? In-Reply-To: References: Message-ID: 2009/3/26 ryeguy > I have 2 cluster layouts in mind, and was wondering what the pros and > cons are for each: > 1) Nodes are either worker nodes, or mnesia nodes. Mnesia nodes > contain only tables and do nothing else; worker nodes do all the heavy > lifting. Pros: You have more flexibility. You can take database nodes in/out without any impact to your processing capacity (upto a point). Database upgrades are less stressful. Cons: You have more nodes to manage. Every database lookup is an RPC call. > 2) All hybrid nodes - all nodes do heavy lifting, and each node has a > mnesia table fragment on it. > Pros: Lesser management overhead. Even if there are partitioned networks, the worker might be able to service requests for which it holds data locally. Not all database lookups are RPC calls. Cons: You lose a bit of flexbility and upgrades become more complex. If you have a very large database, I would recommend (1). It works for me. cheers Chandru -------------- next part -------------- An HTML attachment was scrubbed... URL: From rvirding@REDACTED Thu Mar 26 07:38:26 2009 From: rvirding@REDACTED (Robert Virding) Date: Thu, 26 Mar 2009 07:38:26 +0100 Subject: [erlang-questions] Thoughts about server abstraction and process management In-Reply-To: <49CA5D24.3060408@erlang-consulting.com> References: <4a2836ab-c55f-4d6e-ad04-659dac962cac@c11g2000yqj.googlegroups.com> <49CA5D24.3060408@erlang-consulting.com> Message-ID: <3dbc6d1c0903252338m439b22ebvced62f081805251c@mail.gmail.com> 2009/3/25 Ulf Wiger > zambal wrote: > > > > So I was wondering if there ever have been any ideas > > about process management like how memory is managed in > > garbage collected languages? > > I don't know anything about the internals of garbage > > collectors, but I can imagine that something like > > reference counted Pids could work: as soon as the last > > reference to a Pid in an Erlang node is cleared by > > the garbage collector and there's still a process > > active with that Pid, it should be pretty safe to kill it. > > I can recall that the idea has been discussed in the past, > but for better or for worse, it's rather too late for that. > It would probably break existing code in gruesome ways. One difficult problem to solve if you do something like this is handling references to pids from other nodes. As they can more or less be freely passed around amongst external nodes there is no possibility to keep track of them, or to keep track of which processes may, or may not, be referenced. Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: From Mike.French@REDACTED Thu Mar 26 08:36:04 2009 From: Mike.French@REDACTED (French, Mike) Date: Thu, 26 Mar 2009 07:36:04 -0000 Subject: [erlang-questions] Is there a mature xmpp cllient for erlang? Message-ID: > -----Original Message----- > From: erlang-questions-bounces@REDACTED > [mailto:erlang-questions-bounces@REDACTED]On Behalf Of > Michael Ossareh > Sent: 26 March 2009 03:47 > To: erlang-questions@REDACTED > Subject: Re: [erlang-questions] Is there a mature xmpp cllient for > erlang? > process-one have one (exmpp) that I understand they're close to releasing. Yes, first mentioned in Dec 2006 http://erlang.org/pipermail/erlang-questions/2006-December/024324.html should be real soon now :) Mike Thales UK Ltd (Wells) DISCLAIMER: The information contained in this e-mail is confidential. It may also be legally privileged. It is intended only for the stated addressee(s) and access to it by any other person is unauthorised. If you are not an addressee, you must not disclose, copy, circulate or in any other way use or rely on the information contained in this e-mail. Such unauthorised use may be unlawful. We may monitor all e-mail communications through our networks. If you have received this e-mail in error, please inform us immediately on sender's telephone number above and delete it and all copies from your system. We accept no responsibility for changes to any e-mail which occur after it has been sent. Attachments to this e-mail may contain software viruses which could damage your system. We therefore recommend you virus-check all attachments before opening. Thales UK Ltd. Registered Office: 2 Dashwood Lang Road, The Bourne Business Park, Addlestone, Weybridge, Surrey KT15 2NX Registered in England No. 868273 From nick@REDACTED Thu Mar 26 09:07:51 2009 From: nick@REDACTED (Nick Conrad) Date: Thu, 26 Mar 2009 01:07:51 -0700 Subject: [erlang-questions] dialyzer orelse filter slowness Message-ID: Hello, I've got a module that dialyzer takes more than 15 minutes to analyze, and I've narrowed down the cause to a fairly long orelse expression that is being used as a filter in a list comprehension. If I replace the orelse expression with a function call and make each individual test it's own function, dialyzer is much happier and completes within seconds. Does anyone have an explanation for why dialyzer might take so long on the orelse's when used as a filter? Here's a bit of code that demonstrates the issue, which I've seen using both R11B and R12B. -- -module (test). -export ([ foo/1 ]). -ifdef (USE_ORELSE). -define (bar (F), ((F) =:= a orelse (F) =:= b orelse (F) =:= c orelse (F) =:= d orelse (F) =:= e orelse (F) =:= f orelse (F) =:= g orelse (F) =:= h orelse (F) =:= i orelse (F) =:= j orelse (F) =:= k)). -else. -define (bar, bar_f). bar_f (a) -> true; bar_f (b) -> true; bar_f (c) -> true; bar_f (d) -> true; bar_f (e) -> true; bar_f (f) -> true; bar_f (g) -> true; bar_f (h) -> true; bar_f (i) -> true; bar_f (j) -> true; bar_f (k) -> true; bar_f (_) -> false. -endif. foo (List) -> [ F || F <- List, ?bar (F)]. -- % dialyzer --no_check_plt --src -c . Proceeding with analysis... done in 0m0.23s done (passed successfully) % dialyzer -DUSE_ORELSE=1 --no_check_plt --src -c . Proceeding with analysis... done in 0m32.24s done (passed successfully) Thanks! - n From richardc@REDACTED Thu Mar 26 09:07:53 2009 From: richardc@REDACTED (Richard Carlsson) Date: Thu, 26 Mar 2009 09:07:53 +0100 Subject: [erlang-questions] Thoughts about server abstraction and process management In-Reply-To: <3dbc6d1c0903252338m439b22ebvced62f081805251c@mail.gmail.com> References: <4a2836ab-c55f-4d6e-ad04-659dac962cac@c11g2000yqj.googlegroups.com> <49CA5D24.3060408@erlang-consulting.com> <3dbc6d1c0903252338m439b22ebvced62f081805251c@mail.gmail.com> Message-ID: <49CB37D9.9030403@it.uu.se> Robert Virding wrote: > 2009/3/25 Ulf Wiger zambal wrote: > > So I was wondering if there ever have been any ideas > > about process management like how memory is managed in > > garbage collected languages? > > I don't know anything about the internals of garbage > > collectors, but I can imagine that something like > > reference counted Pids could work: as soon as the last > > reference to a Pid in an Erlang node is cleared by > > the garbage collector and there's still a process > > active with that Pid, it should be pretty safe to kill it. > > I can recall that the idea has been discussed in the past, > but for better or for worse, it's rather too late for that. > It would probably break existing code in gruesome ways. > > One difficult problem to solve if you do something like this is handling > references to pids from other nodes. As they can more or less be freely > passed around amongst external nodes there is no possibility to keep > track of them, or to keep track of which processes may, or may not, be > referenced. One approach to distributed garbage collection is to use a lease-based system. The idea is that an object/process will only stay alive as long as some client still holds a valid lease. Once the last lease expires, the object can be garbage collected. Clients will have to renew their leases on a regular basis if they want to keep using the object. What the default time for a lease should be depends on the problem; anything between 100 milliseconds and 100 days could be reasonable. With processes, you could make this a direct negotiation between the process and its clients, but then the process needs to be explicitly written to handle the lease system. You could also have a distinguished service that manages leases on processes, and which will simply kill off processes when their leases expire, by sending them an exit signal. /Richard From ext@REDACTED Thu Mar 26 09:26:16 2009 From: ext@REDACTED (David Sveningsson) Date: Thu, 26 Mar 2009 09:26:16 +0100 Subject: [erlang-questions] Dialyzer warning: variable can never match since previous clauses completely covered the type In-Reply-To: <49CA6304.6020702@kreditor.se> References: <49CA264A.4040109@sidvind.com> <84iqlx4sxa.fsf@linux-b2a3.site> <49CA4E3A.20908@sidvind.com> <49CA6304.6020702@kreditor.se> Message-ID: <49CB3C28.1000703@sidvind.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Tobias Lindahl wrote: > David Sveningsson wrote: >> Lets say that foo looks like this: >> >> - -spec foo() -> ok | {error, atom()}. >> foo() -> >> ok. >> >> I get the same error. It is true that the function will only return ok, >> but I would like to reserve that it may return {error, atom()} in the >> future. It that possible? > > To add the spec and have Dialyzer accept it: Yes. > To make Dialyzer be quiet about the dead code: No. > > Dialyzer uses both the spec and the type it finds in the analysis. It > finds that your function returns 'ok', which is ok since it does not > contradict your spec. > > However, it will not widen the return type to the one in the spec, but > use the more precise type that it has found in the analysis. > > A -spec can never make your types less precise. > > Tobias Ok, thanks. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.11 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAknLPCgACgkQ6pa1H/H5pqWNlwCgnvSZaNGfJZyTQ7PxbFLlMrji cvsAn1/XruMU5S9T0ciItTKkRVQE4LZ3 =UMPO -----END PGP SIGNATURE----- From kostis@REDACTED Thu Mar 26 09:30:26 2009 From: kostis@REDACTED (Kostis Sagonas) Date: Thu, 26 Mar 2009 10:30:26 +0200 Subject: [erlang-questions] dialyzer orelse filter slowness In-Reply-To: References: Message-ID: <49CB3D22.4080902@cs.ntua.gr> Nick Conrad wrote: > Hello, > > I've got a module that dialyzer takes more than 15 minutes to analyze, > and I've narrowed down the cause to a fairly long orelse expression > that is being used as a filter in a list comprehension. If I replace > the orelse expression with a function call and make each individual > test it's own function, dialyzer is much happier and completes within > seconds. Does anyone have an explanation for why dialyzer might take > so long on the orelse's when used as a filter? > > Here's a bit of code that demonstrates the issue, which I've seen > using both R11B and R12B. > [CODE SNIPPED] > > % dialyzer --no_check_plt --src -c . > Proceeding with analysis... done in 0m0.23s > done (passed successfully) > > % dialyzer -DUSE_ORELSE=1 --no_check_plt --src -c . > Proceeding with analysis... done in 0m32.24s > done (passed successfully) In all probability, this has to do with the convoluted translation of orelse in R11B and R12B. In R13* orelse's (and andalso's) translation has changed and is much more sane. I suggest that you switch to R13A (there are many other reasons to). % dialyzer -v Dialyzer version v1.9.0 % dialyzer -n -c or_else.erl Proceeding with analysis... done in 0m0.68s done (passed successfully) % dialyzer -DUSE_ORELSE=1 -n -c or_else.erl Proceeding with analysis... done in 0m0.91s done (passed successfully) Kostis From richardc@REDACTED Thu Mar 26 09:40:25 2009 From: richardc@REDACTED (Richard Carlsson) Date: Thu, 26 Mar 2009 09:40:25 +0100 Subject: [erlang-questions] Standard modern salary for an Erlang programmer? In-Reply-To: References: <2a67d3ff0903240722x14203c54j693bb1d12fd92953@mail.gmail.com> Message-ID: <49CB3F79.9030107@it.uu.se> Richard O'Keefe wrote: > On 25 Mar 2009, at 3:22 am, G.S. wrote: >> What's a standard, good average salary for the Erlang programmer >> with a few years of experience, based in USA? >> Java is 70-90k, > > Wow. That's about double what I make as a university lecturer. Are you sure about that calculation? That would mean a lecturer in NZ makes just a little more than a Swedish graduate student, which seems... weird. Anyway, it's hard to compare income in different countries, and doubly so if one of them is the US. About ten years ago, I (then a graduate student) visited an old friend who had moved to the US, got a Master's degree, and was living in the Bay Area. Working with user interface design, she (then) made something like 60-65k$/year, which was almost twice what I made at home. But once I had picked up my jaw and looked at her standard of living, it was apparent that I was not much worse off. The taxes in the US are low (a mere rounding error, by Swedish standards), but once she had paid the extortionate housing costs, and 17 kinds of insurance, there was not much left of that salary. /Richard Carlsson From tobias.lindahl@REDACTED Thu Mar 26 09:53:04 2009 From: tobias.lindahl@REDACTED (Tobias Lindahl) Date: Thu, 26 Mar 2009 09:53:04 +0100 Subject: [erlang-questions] dialyzer orelse filter slowness In-Reply-To: References: Message-ID: <49CB4270.6060305@it.uu.se> Nick Conrad wrote: > Hello, > > I've got a module that dialyzer takes more than 15 minutes to analyze, > and I've narrowed down the cause to a fairly long orelse expression > that is being used as a filter in a list comprehension. If I replace > the orelse expression with a function call and make each individual > test it's own function, dialyzer is much happier and completes within > seconds. Does anyone have an explanation for why dialyzer might take > so long on the orelse's when used as a filter? orelse is expanded by the compiler to a case expression, so basically your long line of orelses becomes deeply nested cases. Dialyzer analyses each function (or rather each strongly connected component of functions) in isolation, and abstracts the types at the function borders, so when you break your tests into different functions it is just a matter of analyzing a bunch of very simple functions which explains why Dialyzer is fast there. In contrast, the function with the deeply nested case is analyzed without abstraction, and the relatively complicated control structure makes the analysis pretty slow. I hope that this will be faster in R13 because of an improvement in the compilation of orelses. Tobias > > Here's a bit of code that demonstrates the issue, which I've seen > using both R11B and R12B. > > -- > -module (test). > -export ([ foo/1 ]). > > -ifdef (USE_ORELSE). > -define (bar (F), > ((F) =:= a orelse > (F) =:= b orelse > (F) =:= c orelse > (F) =:= d orelse > (F) =:= e orelse > (F) =:= f orelse > (F) =:= g orelse > (F) =:= h orelse > (F) =:= i orelse > (F) =:= j orelse > (F) =:= k)). > -else. > -define (bar, bar_f). > bar_f (a) -> true; > bar_f (b) -> true; > bar_f (c) -> true; > bar_f (d) -> true; > bar_f (e) -> true; > bar_f (f) -> true; > bar_f (g) -> true; > bar_f (h) -> true; > bar_f (i) -> true; > bar_f (j) -> true; > bar_f (k) -> true; > bar_f (_) -> false. > -endif. > > foo (List) -> > [ F || F <- List, ?bar (F)]. > -- > > > % dialyzer --no_check_plt --src -c . > Proceeding with analysis... done in 0m0.23s > done (passed successfully) > > % dialyzer -DUSE_ORELSE=1 --no_check_plt --src -c . > Proceeding with analysis... done in 0m32.24s > done (passed successfully) > > Thanks! > - n > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From zambal@REDACTED Thu Mar 26 10:38:22 2009 From: zambal@REDACTED (zambal) Date: Thu, 26 Mar 2009 02:38:22 -0700 (PDT) Subject: [erlang-questions] Thoughts about server abstraction and process management In-Reply-To: <3dbc6d1c0903252338m439b22ebvced62f081805251c@mail.gmail.com> References: <4a2836ab-c55f-4d6e-ad04-659dac962cac@c11g2000yqj.googlegroups.com> <49CA5D24.3060408@erlang-consulting.com> <3dbc6d1c0903252338m439b22ebvced62f081805251c@mail.gmail.com> Message-ID: <508a260c-3882-4629-9e97-618a641dea91@v19g2000yqn.googlegroups.com> On 26 mrt, 07:38, Robert Virding wrote: > One difficult problem to solve if you do something like this is handling > references to pids from other nodes. As they can more or less be freely > passed around amongst external nodes there is no possibility to keep track > of them, or to keep track of which processes may, or may not, be referenced. Maybe every node could have a central process running that keeps track of all Pid references and this process can query other nodes about their Pid references too. But that would probably be very bad for performance and the fact that you have to take the possibility of network failure into account makes things complex, so I doubt this would be a good solution. --- vincent From zambal@REDACTED Thu Mar 26 10:39:06 2009 From: zambal@REDACTED (zambal) Date: Thu, 26 Mar 2009 02:39:06 -0700 (PDT) Subject: [erlang-questions] Thoughts about server abstraction and process management In-Reply-To: <49CA5D24.3060408@erlang-consulting.com> References: <4a2836ab-c55f-4d6e-ad04-659dac962cac@c11g2000yqj.googlegroups.com> <49CA5D24.3060408@erlang-consulting.com> Message-ID: <26e93f38-9a75-450a-8413-31f4dc966f68@z9g2000yqi.googlegroups.com> On Wed, Mar 25, 2009 at 5:34 PM, Ulf Wiger wrote: zambal wrote: > You can implement the exact same abstractions > on top of gen_server. See below. Yes, I have done that myself too after I realized that I was essentially trying to rebuild gen_server with a slightly different interface. The thing is I never knew that you could start a gen_server without a registered name, because all tutorials I read about gen_server used registered names. However, later on I realized that a big disadvantage of using a closure as the interface to a server is that as far as I can see you can't use type specifications. So for the fun of it I have been experimenting with a different idiom too, by putting all api functions of a gen_server callback module (like do(X, S)-> gen_server:call(S, {do, X}). etc.) in a separate parametrized module. The callback module can instantiate this api module with it's Pid as parameter, so that you can create and call a particular instance of a server like this: S = server:new(), S:do(X). It's not much different from the typical S = server:start(), server:do(X, S), but the syntax for calling server instance is IMO a bit more clean. >> So I was wondering if there ever have been any ideas >> about process management like how memory is managed in >> garbage collected languages? > > I can recall that the idea has been discussed in the past, > but for better or for worse, it's rather too late for that. > It would probably break existing code in gruesome ways. I can imagine that, but I wasn't suggesting to actually implement something like this in Erlang, just wondering if their ever has been any discussion about this, because googling for garbage collected process management returned no results. --- vincent From zambal@REDACTED Thu Mar 26 10:39:57 2009 From: zambal@REDACTED (zambal) Date: Thu, 26 Mar 2009 02:39:57 -0700 (PDT) Subject: [erlang-questions] Thoughts about server abstraction and process management In-Reply-To: <49CB37D9.9030403@it.uu.se> References: <4a2836ab-c55f-4d6e-ad04-659dac962cac@c11g2000yqj.googlegroups.com> <49CA5D24.3060408@erlang-consulting.com> <3dbc6d1c0903252338m439b22ebvced62f081805251c@mail.gmail.com> <49CB37D9.9030403@it.uu.se> Message-ID: <1f3f231f-bdf2-4a75-81e5-a71645279a99@e35g2000yqc.googlegroups.com> On 26 mrt, 09:07, Richard Carlsson wrote: > One approach to distributed garbage collection is to use a lease-based > system. The idea is that an object/process will only stay alive as long > as some client still holds a valid lease. Once the last lease expires, > the object can be garbage collected. Clients will have to renew their > leases on a regular basis if they want to keep using the object. What > the default time for a lease should be depends on the problem; anything > between 100 milliseconds and 100 days could be reasonable. > > With processes, you could make this a direct negotiation between the > process and its clients, but then the process needs to be explicitly > written to handle the lease system. You could also have a distinguished > service that manages leases on processes, and which will simply kill off > processes when their leases expire, by sending them an exit signal. Interesting idea, but I'm not sure if managing leases would be less error prone than managing the life cycle of a process from the perspective of a programmer. ---vincent From bekesa@REDACTED Thu Mar 26 12:22:47 2009 From: bekesa@REDACTED (Andras Georgy Bekes) Date: Thu, 26 Mar 2009 12:22:47 +0100 Subject: [erlang-questions] =?iso-8859-1?q?Standard_modern_salary_for_an?= =?iso-8859-1?q?=09Erlang=09programmer=3F?= In-Reply-To: <49CB3F79.9030107@it.uu.se> References: <2a67d3ff0903240722x14203c54j693bb1d12fd92953@mail.gmail.com> <49CB3F79.9030107@it.uu.se> Message-ID: <200903261222.47251.bekesa@sch.bme.hu> > >> What's a standard, good average salary for the Erlang programmer > >> with a few years of experience, based in USA? > >> Java is 70-90k, > > > > Wow. That's about double what I make as a university lecturer. > > Are you sure about that calculation? That would mean a lecturer > in NZ makes just a little more than a Swedish graduate student, > which seems... weird. And that means that a Swedish graduate student makes 1.5-2 times more than a software developer at a big company (like Ericsson) in Hungary, and 2-4 times more than a Hungarian university lecturer. Oh, and these numbers are gross, and the net salary you have in Hungary is ~ 50% of your gross. Of course, the above ratios are results of very imprecise approximations. We're talking about the "more than" the "about half" of "70-90k" USD, but still, the NZ university lecturer's salary is believable. There are huge differences between countries, and you can not compare salaries because the living costs are also way different. If you also compare the salaries in India or China or other countries in Asia to Sweden or the US, you can easily find 10x differences or more. Georgy From jlprasantha@REDACTED Thu Mar 26 14:32:58 2009 From: jlprasantha@REDACTED (prasantha kumara) Date: Thu, 26 Mar 2009 19:02:58 +0530 Subject: [erlang-questions] how to fire the handle_operation in oserl Message-ID: hi all i am currently working on erlang implementation on smpp.and i went trought the and went trough the code.but in example test_sms.erl i coudnt find how to call the handle_operation/3. becuase there is no place to call that function. but it is calling when a message is recieved to the test_smsc. can anybody help me to figure this out. regards prasantha -------------- next part -------------- An HTML attachment was scrubbed... URL: From richardc@REDACTED Thu Mar 26 14:41:54 2009 From: richardc@REDACTED (Richard Carlsson) Date: Thu, 26 Mar 2009 14:41:54 +0100 Subject: [erlang-questions] Standard modern salary for an Erlang programmer? In-Reply-To: <200903261222.47251.bekesa@sch.bme.hu> References: <2a67d3ff0903240722x14203c54j693bb1d12fd92953@mail.gmail.com> <49CB3F79.9030107@it.uu.se> <200903261222.47251.bekesa@sch.bme.hu> Message-ID: <49CB8622.5060102@it.uu.se> Andras Georgy Bekes wrote: >>>> What's a standard, good average salary for the Erlang programmer >>>> with a few years of experience, based in USA? Java is 70-90k, >>> Wow. That's about double what I make as a university lecturer. >> Are you sure about that calculation? That would mean a lecturer >> in NZ makes just a little more than a Swedish graduate student, >> which seems... weird. > And that means that a Swedish graduate student makes 1.5-2 times more > than a software developer at a big company (like Ericsson) in Hungary, > and 2-4 times more than a Hungarian university lecturer. Sure; it's just that I could expect that for Hungary, given the recent history of eastern Europe. I thought NZ would be more similar to UK, Australia, or Sweden, in which case a decent lecturer salary would be around 35-40k GBP (50-60k USD) per year (and probably more in Oz), but that was apparently wrong. ...Digging up some statistics, I see that a top teaching salary in NZ would be 70k NZD, i.e., around 40k USD/year. Maybe it's a good time to do some travelling... /Richard From saleyn@REDACTED Thu Mar 26 13:21:08 2009 From: saleyn@REDACTED (Serge Aleynikov) Date: Thu, 26 Mar 2009 08:21:08 -0400 Subject: [erlang-questions] to supervise or not to supervise In-Reply-To: <8209f740903221528v653de63j7bdea0995896756c@mail.gmail.com> References: <4cb4a7bf0903201242t2166af30rbba7fe44ee8800a1@mail.gmail.com> <4cb4a7bf0903220758t6f05e058g645385571d14c2c9@mail.gmail.com> <8209f740903221528v653de63j7bdea0995896756c@mail.gmail.com> Message-ID: <49CB7334.5070205@gmail.com> Could you point me to a link with implementation of that alternative supervisor? The link below didn't have an attachment. I've been considering to rewrite the timed_supervisor [*] I wrote some time ago so that instead of being modeled after gen_server-like supervisor_bridge it would be a more native supervisor replacement. Perhaps I should use a subset of your supervisor's child specification configuration. [*] http://forum.trapexit.org/viewtopic.php?p=44147#44147 Serge Ulf Wiger wrote: > So when this question comes up it is customary for me to mention > my extension of the supervisor behavior to allow tracking the number > of restarts... (: > > http://erlang.org/pipermail/erlang-questions/2003-November/010763.html > > The way restart escalation currently works, I think it's wise in most cases > to escalate all the way up as soon as the nearest supervisor is unable > to resolve the situation. I've rarely seen an escalated issue resolve itself > in the middle management layer. You either solve it close to the problem > itself, or you solve it at the top - and try to expedite the work in the > middle. > > (We're of course only talking Erlang supervisors here.) > > BR, > Ulf W > > > 2009/3/22 steve ellis : >> Thanks Lennart and Mihai! Very helpful information. Lennart it's good to >> know about the intent behind supervisor's orignial design. >> >> I like Mihai's suggestion of having one supervisor supervise each process. >> This would get us most of the way there and it would be easy to implement. >> >> But is there any way in OTP to see when a supervisor reaches its max >> restarts? I know this is logged by the sasl error logger. But how would I >> trap/detect this event in my code to do something with it? >> >> It doesn't look like supervisor has a function like gen_server's handy >> terminate/2. >> >> Maybe it would make more sense in our case to have one gen_server process >> monitor a child gen_server process. The child could call a function in the >> parent when it terminates. This way we'd have access to the terminate >> function of the monitoring/supervising gen_server. The problem with this >> though is that we'd have to implement our own restart strategy behavior, >> which is what is so great about supervisor. >> >> This might be related to something more general that I've been wondering >> about (which I should post as a question in a new thread). How to tap into >> the sasl error logger so my system can do stuff with those events. For >> example I'd like to send these events to another machine via tcp. >> >> Thanks! >> >> Steve >> >> On Fri, Mar 20, 2009 at 5:29 PM, Mihai Balea wrote: >>> On Mar 20, 2009, at 3:42 PM, steve ellis wrote: >>> >>>> New to supervision trees and trying to figure out when to use them (and >>>> when not to)... >>>> >>>> I have bunch of spawned processes created through spawn_link. Want these >>>> processes to say running indefinitely. If one exits in an error state, we >>>> want to restart it N times. After N, we want to error log it, and stop >>>> trying to restart it. Perfect job for a one_to_one supervisor right? >>>> >>>> Well sort of. The problem is that when the max restarts for the error >>>> process is reached, the supervisor terminates all its children and itself. >>>> Ouch! (At least in our case). We'd rather that the supervisor just keep >>>> supervising all the children that are ok and not swallow everything up. >>>> >>>> The Design Principles appear to be saying that swallowing everything up >>>> is what supervisors are supposed to do when max restarts is reached which >>>> leaves me a little puzzled. Why would you want to kill the supervisor just >>>> because a child process is causing trouble? Seems a little harsh. >>>> >>>> Is this a case of me thinking supervisors are good for too many things? >>>> Is it that our case is better handled by simply spawning these processes and >>>> trapping exits on them, and restarting/error logging in the trap exit? >>> As far as I know, the standard supervisor cannot behave the way you want >>> it to. >>> >>> So, at least until this type of behavior is added to the standard >>> supervisor, you can work around it with double layers of supervision. >>> Basically have one dedicated supervisor for each process you want to >>> supervise and, in turn, each dedicated supervisor is set up as a transient >>> child to one big supervisor. >>> >>> Mihai >>> >> >> _______________________________________________ >> 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 steven.charles.davis@REDACTED Thu Mar 26 15:15:40 2009 From: steven.charles.davis@REDACTED (Steve Davis) Date: Thu, 26 Mar 2009 07:15:40 -0700 (PDT) Subject: [erlang-questions] A couple of design questions Message-ID: <4a15e2a1-183a-4851-95be-b2608f3f82a8@z8g2000prd.googlegroups.com> Hi all, I am working on a gs-style interface to wx, and was hoping someone may have an opinion on a couple of design issues: 1) I've been maintaining an ets table to cope with naming/references and command events. In order to keep the references unique across multiple UI instances (processes), I've used a key format that is basically {self(), name}/{reference, data}. I've had problems convincing myself that these tables are safe as they must be marked "public". However, I'm now thinking that these references would be better off in the process dictionary (something I am usually cautious of doing) as these stored references are, or should be (a) private to the process, (b) "transient" with the process, and (c) irrelevant outside the process. So my question here is: in this case, is it as valid as it seems to me now to the use of the process dictionary to store a fair amount of data, and if so what limitations should I watch out for? 2) Starting the UI instance process merely uses spawn (and returns the pid to the calling process). It's troubled me that perhaps the GUI process should be more "OTP". However, given that this is a framework that builds on wxe (with the graphics server already there), my thinking is that the ownership (and supervision) of the UI process would be better implemented by the calling application, since it can link and supervise the UI. Making the UI run off a gen_server seems an unnecessary complexity in the design of the framework. My question here is: Simple though this is, is my thinking correct? Thanks! /s From jongretar@REDACTED Thu Mar 26 16:04:26 2009 From: jongretar@REDACTED (Jon Gretar Borgthorsson) Date: Thu, 26 Mar 2009 15:04:26 +0000 Subject: [erlang-questions] Standard modern salary for an Erlang programmer? In-Reply-To: References: <2a67d3ff0903240722x14203c54j693bb1d12fd92953@mail.gmail.com> Message-ID: <4ecde87b0903260804p6272c65ft2a62729789be790f@mail.gmail.com> On Thu, Mar 26, 2009 at 3:43 AM, Michael Ossareh wrote: > I often find myself wondering if learning dying languages is a better > way to get paid more than learning new languages that gain popularity. > Cobol in banking anyone? =) Yup... My feelings excactly. You can either focus on Java and have a 50% chance of having to write at least 4 different CMS's in your life..... Or you can focus on ADA and program the Space Shuttle. Pick. - Jon Gretar From adam@REDACTED Thu Mar 26 16:30:11 2009 From: adam@REDACTED (Adam Lindberg) Date: Thu, 26 Mar 2009 15:30:11 +0000 (GMT) Subject: [erlang-questions] Standard modern salary for an Erlang programmer? In-Reply-To: <4ecde87b0903260804p6272c65ft2a62729789be790f@mail.gmail.com> Message-ID: <31117710.95821238081411376.JavaMail.root@zimbra> ----- "Jon Gretar Borgthorsson" wrote: > Or you can focus on ADA and program the Space Shuttle. > > Pick. I'd love to get bug reports from space. Cheers, Adam From kevin@REDACTED Thu Mar 26 04:47:21 2009 From: kevin@REDACTED (Kevin Scaldeferri) Date: Wed, 25 Mar 2009 21:47:21 -0600 Subject: [erlang-questions] Standard modern salary for an Erlang programmer? In-Reply-To: References: <2a67d3ff0903240722x14203c54j693bb1d12fd92953@mail.gmail.com> Message-ID: <37070477-C214-4219-B049-0E1CD81B6954@scaldeferri.com> On Mar 25, 2009, at 6:45 PM, Richard O'Keefe wrote: > > On 25 Mar 2009, at 3:22 am, G.S. wrote: >> What's a standard, good average salary for the Erlang programmer >> with a few years of experience, based in USA? >> Java is 70-90k, > > Wow. That's about double what I make as a university lecturer. No one has ever claimed that teaching at university was the road to riches. FWIW, I was offered about double that recently for a Java position, but in an industry and for a company which made the money not worth it for me. (Oh, and, ugh, Java) > > >> and I read online that since us Erlangers, being a less known, and >> essential for writing software that scales, and will scale into the >> future, is much higher. I seem to find various blogs that state the >> salary in 2008 was anywhere from 99k to 180k. > From what I can tell, salary depends much less on the programming language, and much more on the programmer and the company. Some programmers will never be worth that much to any company. Some companies will never be able to afford to pay that much to any programmer. Also, networking and contacts matter a lot. You are likely worth more to people who know you already than to people who only have a couple hours of interactions on which to judge you. -kevin From mihai@REDACTED Thu Mar 26 17:01:31 2009 From: mihai@REDACTED (Mihai Balea) Date: Thu, 26 Mar 2009 12:01:31 -0400 Subject: [erlang-questions] Standard modern salary for an Erlang programmer? In-Reply-To: <4ecde87b0903260804p6272c65ft2a62729789be790f@mail.gmail.com> References: <2a67d3ff0903240722x14203c54j693bb1d12fd92953@mail.gmail.com> <4ecde87b0903260804p6272c65ft2a62729789be790f@mail.gmail.com> Message-ID: <296572F0-0327-4E10-8C93-C0BEE4E088B7@hates.ms> On Mar 26, 2009, at 11:04 AM, Jon Gretar Borgthorsson wrote: > > Yup... My feelings excactly. You can either focus on Java and have a > 50% chance of having to write at least 4 different CMS's in your > life..... > Or you can focus on ADA and program the Space Shuttle. > > Pick. Actually the Space Shuttle code is written in a specialized language called HAL/S (http://en.wikipedia.org/wiki/HAL/S) I'm sure you could write some nuclear ICBM control code in ADA... But we diverge :) From ptr.wang@REDACTED Thu Mar 26 17:43:04 2009 From: ptr.wang@REDACTED (Peter Wang) Date: Fri, 27 Mar 2009 00:43:04 +0800 Subject: [erlang-questions] beginner: Build R12B-5 failed on Slackware 10.1.0 Message-ID: <727b43340903260943g26634c71n7184747c3daecac5@mail.gmail.com> I try to build R12B-5 on my linux box. (otp_src_R12B-5.tar.gz with the patch otp_src_R12B-5_OTP-7738.patch applied.) $cat /etc/slackware-version Slackware 10.1.0 $ uname -a;/lib/libc.so.6; Linux darkstar 2.6.11.6 #2 SMP Mon May 16 17:46:39 CST 2005 i686 unknown unknown GNU/Linux GNU C Library stable release version 2.3.4, by Roland McGrath et al. Copyright (C) 2004 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Compiled by GNU CC version 3.3.4. Compiled on a Linux 2.4.29 system on 2005-01-28. Available extensions: GNU libio by Per Bothner crypt add-on version 2.1 by Michael Glad and others GNU Libidn by Simon Josefsson linuxthreads-0.10 by Xavier Leroy BIND-8.2.3-T5B libthread_db work sponsored by Alpha Processor Inc NIS(YP)/NIS+ NSS modules 0.19 by Thorsten Kukuk For bug reporting instructions, please see: . above is the kernel version and glibc version. since clock_gettime() only supports CLOCK_MONOTONIC after kernel version 2.6.16, I guess. ( http://lwn.net/Articles/167897/) so i modify file: otp_src_R12B-5/erts/emulator/sys/unix/sys.c, replace CLOCK_MONOTONIC to CLOCK_REALTIME, and build with: LDFLAGS="-lrt -lepoll -lcrypto" ./configure --enable-threads --enable-smp-support --enable-kernel-poll --enable-hipe --without-ssl --without-gs then, run make,got error as follows: === Leaving application hipe make[2]: Leaving directory `/data/tgz/otp_src_R12B-5/lib/hipe' make[1]: Leaving directory `/data/tgz/otp_src_R12B-5/lib' make[1]: Entering directory `/data/tgz/otp_src_R12B-5/erts' make[2]: Entering directory `/data/tgz/otp_src_R12B-5/erts/start_scripts' /usr/bin/ginstall -c -d /home/peterwang/tgz/otp_src_R12B-5/erts/start_scripts/tmp ( cd /home/peterwang/tgz/otp_src_R12B-5/erts/start_scripts/tmp && \ erl -boot start_clean -noinput +B -eval 'release_handler:create_RELEASES("%ERL_ROOT%", "/home/peterwang/tgz/otp_src_R12B-5/erts/start_scripts", "/home/peterwang/tgz/otp_src_R12B-5/erts/start_scripts/start_sasl.rel", []), halt()') /bin/sh: line 1: 12275 Killed erl -boot start_clean -noinput +B -eval 'release_handler:create_RELEASES("%ERL_ROOT%", "/home/peterwang/tgz/otp_src_R12B-5/erts/start_scripts", "/home/peterwang/tgz/otp_src_R12B-5/erts/start_scripts/start_sasl.rel", []), halt()' make[2]: *** [RELEASES.src] Error 137 make[2]: Leaving directory `/data/tgz/otp_src_R12B-5/erts/start_scripts' make[1]: *** [local_setup] Error 2 make[1]: Leaving directory `/data/tgz/otp_src_R12B-5/erts' make: *** [local_setup] Error 2 can anyone give some advices on that? thanks. -peter -------------- next part -------------- An HTML attachment was scrubbed... URL: From rvirding@REDACTED Thu Mar 26 18:03:20 2009 From: rvirding@REDACTED (Robert Virding) Date: Thu, 26 Mar 2009 18:03:20 +0100 Subject: [erlang-questions] leex and yecc spotting double newline In-Reply-To: <49C72836.4020402@ghostgun.com> References: <49C72836.4020402@ghostgun.com> Message-ID: <3dbc6d1c0903261003t79c712e1wba2937283b6ae3c9@mail.gmail.com> Hello again, I have done a quick test and the suggestion I made seems to work. It does however demand that even the final request end with a double newline. I have some comments and questions: - Do you really want to keep the whitespace tokens in your output? (in words) - If you want to get all the tokens until the end of file you can do io:request(InFile, {get_until, prompt, postfix_policy_lexer,tokens, [1]}) - Yecc is very picky and demands that you give it all the tokens it needs and only the tokens it needs, so you would probably have to add a rule requests -> request : ['$1']. requests -> requests request : '$1' ++ ['$2']. Hope this helps. Get back to me if it doesn't or you have more questions. Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: From ossareh@REDACTED Thu Mar 26 19:02:51 2009 From: ossareh@REDACTED (Michael Ossareh) Date: Thu, 26 Mar 2009 11:02:51 -0700 Subject: [erlang-questions] Standard modern salary for an Erlang programmer? In-Reply-To: <37070477-C214-4219-B049-0E1CD81B6954@scaldeferri.com> References: <2a67d3ff0903240722x14203c54j693bb1d12fd92953@mail.gmail.com> <37070477-C214-4219-B049-0E1CD81B6954@scaldeferri.com> Message-ID: On Wed, Mar 25, 2009 at 8:47 PM, Kevin Scaldeferri wrote: > > On Mar 25, 2009, at 6:45 PM, Richard O'Keefe wrote: > >> >> On 25 Mar 2009, at 3:22 am, G.S. wrote: >>> What's a standard, good average salary for the Erlang programmer >>> with a few years of experience, based in USA? >>> Java is 70-90k, >> >> Wow. ?That's about double what I make as a university lecturer. > > No one has ever claimed that teaching at university was the road to > riches. ?FWIW, I was offered about double that recently for a Java > position, but in an industry and for a company which made the money > not worth it for me. (Oh, and, ugh, Java) > > > >> >> >>> and I read online that since us Erlangers, being a less known, and >>> essential for writing software that scales, and will scale into the >>> future, is much higher. I seem to find various blogs that state the >>> salary in 2008 was anywhere from 99k to 180k. >> > > > ?From what I can tell, salary depends much less on the programming > language, and much more on the programmer and the company. ?Some > programmers will never be worth that much to any company. ?Some > companies will never be able to afford to pay that much to any > programmer. I've found the opposite to be true in my experience. I have certainly earned 50% more than a *much* better programmer in my past simply because I had the balls to ask for a lot more. This is an example of the third variable in my OP. The company was a fairly large startup that had raised too much VC and needed to spend it - I did my company due diligence before starting the interview process and knew how much I could ask for. In another case I was pretty much running every single campaign from a tech impl POV and reporting angle for a small SMS-marketing firm, and I was one of the lowest paid. The company 100% depended on me for every day operations and I was on the slightly-better-than-intern-salary I'd joined on 12 months previous. > Also, networking and contacts matter a lot. ?You are > likely worth more to people who know you already than to people who > only have a couple hours of interactions on which to judge you. This is so very true! > > > -kevin > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- god loves atheists, Fact: http://www.mrwiggleslovesyou.com/comics/rehab477.jpg From q2h46uw02@REDACTED Thu Mar 26 19:36:06 2009 From: q2h46uw02@REDACTED (Kevin) Date: Thu, 26 Mar 2009 14:36:06 -0400 Subject: [erlang-questions] does shell:catch_exception(true) actually work? Message-ID: <12953-26787@sneakemail.com> I've done all the googleing I could and still can't find an answer to this. This is making working with the shell very difficult since one slip up and my history is gone. Am I missing something here? Erlang R13A (erts-5.7) [source] [smp:4:4] [rq:4] [async-threads:0] [kernel-poll:false] Eshell V5.7 (abort with ^G) 1> catch_exception(true). false 2> bogus(). *** ERROR: Shell process terminated! *** =ERROR REPORT==== 26-Mar-2009::14:31:32 === Error in process <0.26.0> with exit value: {undef,[{lib,format_exception,[3,error,{shell_undef,bogus,0},[{shell,shell_undef,2},{erl_eval,local_func,5},{shell,exprs,6},{shell,eval_exprs,6},{shell,eval_loop,3}],#Fun,#Fun]},{shell,report_exception,4},{shell,shell_rep,4},{shell... Eshell V5.7 (abort with ^G) 1> From erlangy@REDACTED Thu Mar 26 20:04:09 2009 From: erlangy@REDACTED (Michael McDaniel) Date: Thu, 26 Mar 2009 12:04:09 -0700 Subject: [erlang-questions] does shell:catch_exception(true) actually work? In-Reply-To: <12953-26787@sneakemail.com> References: <12953-26787@sneakemail.com> Message-ID: <20090326190408.GZ18122@delora.autosys.us> Linux delora 2.6.24-23-386 #1 Thu Nov 27 18:10:58 UTC 2008 i686 GNU/Linux Erlang R13A (erts-5.7) [rq:1] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.7 (abort with ^G) 1> catch_exception(true). false 2> bogus(). * exception error: undefined shell command bogus/0 3> h(). 1: catch_exception(true) -> false 2: bogus() -> {'EXIT',{{shell_undef,bogus,0}, [{shell,shell_undef,2}, {erl_eval,local_func,5}, {shell,exprs,6}, {shell,eval_exprs,6}, {shell,eval_loop,3}]}} ok 4> hmmm, works for me on my Linux box ~M On Thu, Mar 26, 2009 at 02:36:06PM -0400, Kevin wrote: > > I've done all the googleing I could and still can't find an answer to > this. This is making working with the shell > very difficult since one slip up and my history is gone. Am I missing > something here? > > > > Erlang R13A (erts-5.7) [source] [smp:4:4] [rq:4] [async-threads:0] > [kernel-poll:false] > > Eshell V5.7 (abort with ^G) > 1> catch_exception(true). > false > 2> bogus(). > *** ERROR: Shell process terminated! *** > > =ERROR REPORT==== 26-Mar-2009::14:31:32 === > Error in process <0.26.0> with exit value: > {undef,[{lib,format_exception,[3,error,{shell_undef,bogus,0},[{shell,shell_undef,2},{erl_eval,local_func,5},{shell,exprs,6},{shell,eval_exprs,6},{shell,eval_loop,3}],#Fun,#Fun]},{shell,report_exception,4},{shell,shell_rep,4},{shell... > > > Eshell V5.7 (abort with ^G) > 1> > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- Michael McDaniel Portland, Oregon, USA http://autosys.us From btolputt@REDACTED Thu Mar 26 08:09:31 2009 From: btolputt@REDACTED (Benjamin Tolputt) Date: Thu, 26 Mar 2009 18:09:31 +1100 Subject: [erlang-questions] Mnesia, Persistence, & Memory Message-ID: <49CB2A2B.4070908@bigpond.net.au> I am looking at putting together a distributed database back-end together for a project designed to show the scalability of Erlang and am looking at using Mnesia. However, I have heard that there is only memory usage two choices available - fully loaded into RAM or loaded on-demand from disk (with no caching). Is this assumption correct? I'd like to use Mnesia (for a variety of reasons), but if the only choice of operations are RAM-bound and disk-bound (with no compromise between the two) it seems like it is designed for the wrong use case for me. -- Regards, Benjamin Tolputt Analyst Programmer From ryeguy1@REDACTED Thu Mar 26 20:18:31 2009 From: ryeguy1@REDACTED (ryeguy) Date: Thu, 26 Mar 2009 12:18:31 -0700 (PDT) Subject: [erlang-questions] does shell:catch_exception(true) actually work? In-Reply-To: <12953-26787@sneakemail.com> References: <12953-26787@sneakemail.com> Message-ID: <8682fbf2-ae75-4b7c-8e78-eaa52e62937a@v1g2000prd.googlegroups.com> This might sound stupid, but since when does the shell terminate when there's an exception? Here's what happens with mine: Erlang R13A (erts-5.7) [source] [smp:4:4] [rq:4] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.7 (abort with ^G) 1> bogus(). ** exception error: undefined shell command bogus/0 2> Am I missing something? On Mar 26, 2:36?pm, "Kevin" wrote: > I've done all the googleing I could and still can't find an answer to > this. ?This is making working with the shell > very difficult since one slip up and my history is gone. ?Am I missing > something here? > > Erlang R13A (erts-5.7) [source] [smp:4:4] [rq:4] [async-threads:0] > [kernel-poll:false] > > Eshell V5.7 ?(abort with ^G) > 1> catch_exception(true). > false > 2> bogus(). > *** ERROR: Shell process terminated! *** > > =ERROR REPORT==== 26-Mar-2009::14:31:32 === > Error in process <0.26.0> with exit value: > {undef,[{lib,format_exception,[3,error,{shell_undef,bogus,0},[{shell,shell_undef,2},{erl_eval,local_func,5},{shell,exprs,6},{shell,eval_exprs,6},{shell,eval_loop,3}],#Fun,#Fun]},{shell,report_exception,4},{shell,shell_rep,4},{shell... > > Eshell V5.7 ?(abort with ^G) > 1> > > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions From vladdu55@REDACTED Thu Mar 26 20:25:36 2009 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Thu, 26 Mar 2009 20:25:36 +0100 Subject: [erlang-questions] does shell:catch_exception(true) actually work? In-Reply-To: <8682fbf2-ae75-4b7c-8e78-eaa52e62937a@v1g2000prd.googlegroups.com> References: <12953-26787@sneakemail.com> <8682fbf2-ae75-4b7c-8e78-eaa52e62937a@v1g2000prd.googlegroups.com> Message-ID: <95be1d3b0903261225gaaa9551te15cca3852f4a412@mail.gmail.com> On Thu, Mar 26, 2009 at 20:18, ryeguy wrote: > This might sound stupid, but since when does the shell terminate when > there's an exception? Here's what happens with mine: > > Erlang R13A (erts-5.7) [source] [smp:4:4] [rq:4] [async-threads:0] > [hipe] [kernel-poll:false] > > Eshell V5.7 ?(abort with ^G) > 1> bogus(). > ** exception error: undefined shell command bogus/0 > 2> The process running the shell dies and is restarted. See here: 1> self(). <0.32.0> 2> bogus(). ** exception error: undefined shell command bogus/0 3> self(). <0.35.0> 4> catch_exception(true). false 5> bogus(). * exception error: undefined shell command bogus/0 6> self(). <0.35.0> The first time, the process dies and another one is created to drive the shell. The second time, the process is the same. regards, Vlad From q2h46uw02@REDACTED Thu Mar 26 20:34:28 2009 From: q2h46uw02@REDACTED (Kevin) Date: Thu, 26 Mar 2009 15:34:28 -0400 Subject: [erlang-questions] does shell:catch_exception(true) actually work? In-Reply-To: <20090326190408.GZ18122@delora.autosys.us> References: <12953-26787@sneakemail.com> <20090326190408.GZ18122@delora.autosys.us> Message-ID: <12953-84123@sneakemail.com> Forgot to mention I'm on OS X, guess its a mac bug, lucky me. -ks Michael McDaniel erlangy-at-autosys.us |erlang| wrote: > Linux delora 2.6.24-23-386 #1 Thu Nov 27 18:10:58 UTC 2008 i686 GNU/Linux > Erlang R13A (erts-5.7) [rq:1] [async-threads:0] [hipe] [kernel-poll:false] > > Eshell V5.7 (abort with ^G) > 1> catch_exception(true). > false > 2> bogus(). > * exception error: undefined shell command bogus/0 > 3> h(). > 1: catch_exception(true) > -> false > 2: bogus() > -> {'EXIT',{{shell_undef,bogus,0}, > [{shell,shell_undef,2}, > {erl_eval,local_func,5}, > {shell,exprs,6}, > {shell,eval_exprs,6}, > {shell,eval_loop,3}]}} > ok > 4> > > > hmmm, works for me on my Linux box > > ~M > > > On Thu, Mar 26, 2009 at 02:36:06PM -0400, Kevin wrote: > >> I've done all the googleing I could and still can't find an answer to >> this. This is making working with the shell >> very difficult since one slip up and my history is gone. Am I missing >> something here? >> >> >> >> Erlang R13A (erts-5.7) [source] [smp:4:4] [rq:4] [async-threads:0] >> [kernel-poll:false] >> >> Eshell V5.7 (abort with ^G) >> 1> catch_exception(true). >> false >> 2> bogus(). >> *** ERROR: Shell process terminated! *** >> >> =ERROR REPORT==== 26-Mar-2009::14:31:32 === >> Error in process <0.26.0> with exit value: >> {undef,[{lib,format_exception,[3,error,{shell_undef,bogus,0},[{shell,shell_undef,2},{erl_eval,local_func,5},{shell,exprs,6},{shell,eval_exprs,6},{shell,eval_loop,3}],#Fun,#Fun]},{shell,report_exception,4},{shell,shell_rep,4},{shell... >> >> >> Eshell V5.7 (abort with ^G) >> 1> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > From ryeguy1@REDACTED Thu Mar 26 20:50:35 2009 From: ryeguy1@REDACTED (ryeguy) Date: Thu, 26 Mar 2009 12:50:35 -0700 (PDT) Subject: [erlang-questions] Mnesia, Persistence, & Memory In-Reply-To: <49CB2A2B.4070908@bigpond.net.au> References: <49CB2A2B.4070908@bigpond.net.au> Message-ID: You have the option of them being held in both memory and on disc at the same time. Or, you could always periodically dump a ram table to disk. On Mar 26, 3:09?am, Benjamin Tolputt wrote: > I am looking at putting together a distributed database back-end > together for a project designed to show the scalability of Erlang and am > looking at using Mnesia. > > However, I have heard that there is only memory usage two choices > available - fully loaded into RAM or loaded on-demand from disk (with no > caching). Is this assumption correct? > > I'd like to use Mnesia (for a variety of reasons), but if the only > choice of operations are RAM-bound and disk-bound (with no compromise > between the two) it seems like it is designed for the wrong use case for me. > > -- > Regards, > > Benjamin Tolputt > Analyst Programmer > > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions From richardc@REDACTED Thu Mar 26 20:53:50 2009 From: richardc@REDACTED (Richard Carlsson) Date: Thu, 26 Mar 2009 20:53:50 +0100 Subject: [erlang-questions] does shell:catch_exception(true) actually work? In-Reply-To: <12953-26787@sneakemail.com> References: <12953-26787@sneakemail.com> Message-ID: <49CBDD4E.2060906@it.uu.se> Kevin wrote: > I've done all the googleing I could and still can't find an answer to > this. This is making working with the shell > very difficult since one slip up and my history is gone. Am I missing > something here? > > 2> bogus(). > *** ERROR: Shell process terminated! *** > > =ERROR REPORT==== 26-Mar-2009::14:31:32 === > Error in process <0.26.0> with exit value: > {undef,[{lib,format_exception,[3,error,{shell_undef,bogus,0},[{shell,shell_undef,2},{erl_eval,local_func,5},{shell,exprs,6},{shell,eval_exprs,6},{shell,eval_loop,3}],#Fun,#Fun]},{shell,report_exception,4},{shell,shell_rep,4},{shell... Have you perchance named a module 'lib'? That could be why the shell fails to call the library function lib:format_exception(), and dies. /Richard From ryeguy1@REDACTED Thu Mar 26 21:07:04 2009 From: ryeguy1@REDACTED (ryeguy) Date: Thu, 26 Mar 2009 13:07:04 -0700 (PDT) Subject: [erlang-questions] Why are arrays faster than tuples? Message-ID: <50640d4b-ec6f-49cb-b289-008bc9c3d2d6@s12g2000prc.googlegroups.com> I was looking at the benchmark at http://thinkerlang.com/2008/08/25/optimizing-erlang-a-death-match-of-arrays-and-tuples.html and it looks like arrays are many many times faster than tuples. Why is this? I understand that arrays are preallocated while tuples must be resized, but I thought that in erlang all arguments are copied when they are passed to a function? Am I mistaken or are there just some exceptions as to what types of terms are [not] copied? From steven.charles.davis@REDACTED Thu Mar 26 21:28:15 2009 From: steven.charles.davis@REDACTED (Steve Davis) Date: Thu, 26 Mar 2009 13:28:15 -0700 (PDT) Subject: [erlang-questions] does shell:catch_exception(true) actually work? In-Reply-To: <8682fbf2-ae75-4b7c-8e78-eaa52e62937a@v1g2000prd.googlegroups.com> References: <12953-26787@sneakemail.com> <8682fbf2-ae75-4b7c-8e78-eaa52e62937a@v1g2000prd.googlegroups.com> Message-ID: <7fdd88c8-175f-4586-8931-547a66d3cfe3@y34g2000prb.googlegroups.com> On Mar 26, 2:18 pm, ryeguy wrote: > This might sound stupid, but since when does the shell terminate when > there's an exception? Here's what happens with mine: This may be more explanatory... 6> self(). ??<0.43.0> 7> bogus(). ** exception error: undefined shell command bogus/0 8> self(). <0.86.0> From freza@REDACTED Thu Mar 26 22:30:26 2009 From: freza@REDACTED (Jachym Holecek) Date: Thu, 26 Mar 2009 22:30:26 +0100 Subject: [erlang-questions] Why are arrays faster than tuples? In-Reply-To: <50640d4b-ec6f-49cb-b289-008bc9c3d2d6@s12g2000prc.googlegroups.com> References: <50640d4b-ec6f-49cb-b289-008bc9c3d2d6@s12g2000prc.googlegroups.com> Message-ID: <20090326213025.GA12257@hanele> # ryeguy 2009-03-26: > I was looking at the benchmark at > http://thinkerlang.com/2008/08/25/optimizing-erlang-a-death-match-of-arrays-and-tuples.html > and it looks like arrays are many many times faster than tuples. Why > is this? You mean "faster WRT modification time", right? Because tuples are a clear winner for access time in that benchmark. > I understand that arrays are preallocated while tuples must > be resized, but I thought that in erlang all arguments are copied when > they are passed to a function? No, they're passed by reference and only copied when crossing process boundary. That's fine because all values are immutable at language level. > Am I mistaken or are there just some > exceptions as to what types of terms are [not] copied? The explanation is probably that setelement/3 is slow for large tuples because the whole tuple needs to be copied when doing so (the exact value of "large" would depend on CPU type and cache size and kind of memory chips used, I guess). The other containers tested need to modify lesser amount of much smaller terms compared to plain setelement/3 on a huge tuple. I didn't look closely, really, but I'm sure someone will correct me if I'm wrong. ;-) HTH, -- Jachym From dawsdesign@REDACTED Thu Mar 26 23:25:09 2009 From: dawsdesign@REDACTED (Matt Williamson) Date: Thu, 26 Mar 2009 18:25:09 -0400 Subject: [erlang-questions] How do I remove pcre from my src? Message-ID: I'm trying to install erlang on the iPhone using the build tools on it. I can run configure successfully with a little hacking, but when it goes to compile pcre_exec.c, it sucks up all the memory and the iPhone reboots. I tried a freebsd trick where you hack the makefile to look at include dirs first, but it didn't work (maybe I don't have the correct version of pcre already installed). Any suggestions on how to make pcre work or remove it from the build? I can live without regex in erl. Thanks! Matt -------------- next part -------------- An HTML attachment was scrubbed... URL: From richardc@REDACTED Thu Mar 26 23:25:19 2009 From: richardc@REDACTED (Richard Carlsson) Date: Thu, 26 Mar 2009 23:25:19 +0100 Subject: [erlang-questions] Why are arrays faster than tuples? In-Reply-To: <50640d4b-ec6f-49cb-b289-008bc9c3d2d6@s12g2000prc.googlegroups.com> References: <50640d4b-ec6f-49cb-b289-008bc9c3d2d6@s12g2000prc.googlegroups.com> Message-ID: <49CC00CF.4000809@it.uu.se> ryeguy wrote: > I was looking at the benchmark at > http://thinkerlang.com/2008/08/25/optimizing-erlang-a-death-match-of-arrays-and-tuples.html > and it looks like arrays are many many times faster than tuples. Why > is this? Note that the arrays are implemented using tuples. It's just that instead of using a single huge tuple (which has fast read access but very slow updates since the entire tuple needs to be copied), it uses nested tuples of around 10 elements each. This allows the array representation to have a good balance between read and update performance, and also lets it represent sparse arrays efficiently. It's still a functional data structure: updating an entry gives you a reference to a conceptually "new" array (although most of the data is reused and shared with the previous version). (Note that there is no performance difference between "fixed" and "extensible" arrays; it's just a flag that specifies the behaviour in the event of accesses outside the current range: grow or fail.) Function calls do not cause copying of heap data. Message passing does, in general. /Richard From q2h46uw02@REDACTED Thu Mar 26 23:27:01 2009 From: q2h46uw02@REDACTED (Kevin) Date: Thu, 26 Mar 2009 18:27:01 -0400 Subject: [erlang-questions] does shell:catch_exception(true) actually work? In-Reply-To: <49CBDD4E.2060906@it.uu.se> References: <12953-26787@sneakemail.com> <49CBDD4E.2060906@it.uu.se> Message-ID: <9775-22030@sneakemail.com> Richard Carlsson richardc-at-it.uu.se |erlang| wrote: > Kevin wrote: >> I've done all the googleing I could and still can't find an answer to >> this. This is making working with the shell >> very difficult since one slip up and my history is gone. Am I >> missing something here? >> >> 2> bogus(). >> *** ERROR: Shell process terminated! *** >> >> =ERROR REPORT==== 26-Mar-2009::14:31:32 === >> Error in process <0.26.0> with exit value: >> {undef,[{lib,format_exception,[3,error,{shell_undef,bogus,0},[{shell,shell_undef,2},{erl_eval,local_func,5},{shell,exprs,6},{shell,eval_exprs,6},{shell,eval_loop,3}],#Fun,#Fun]},{shell,report_exception,4},{shell,shell_rep,4},{shell... > > > Have you perchance named a module 'lib'? That could be why the shell > fails to call the library function lib:format_exception(), and dies. > > /Richard > Thats it. Thought I checked for a lib, but I guess I blew it. Thanks From ok@REDACTED Fri Mar 27 00:44:45 2009 From: ok@REDACTED (Richard O'Keefe) Date: Fri, 27 Mar 2009 12:44:45 +1300 Subject: [erlang-questions] Standard modern salary for an Erlang programmer? In-Reply-To: <49CB8622.5060102@it.uu.se> References: <2a67d3ff0903240722x14203c54j693bb1d12fd92953@mail.gmail.com> <49CB3F79.9030107@it.uu.se> <200903261222.47251.bekesa@sch.bme.hu> <49CB8622.5060102@it.uu.se> Message-ID: What this really means, of course, is that if you want well-educated English-speaking programmers for less money, get your programming done in New Zealand! From xmlarchitect@REDACTED Fri Mar 27 00:57:24 2009 From: xmlarchitect@REDACTED (=Bill.Barnhill) Date: Thu, 26 Mar 2009 19:57:24 -0400 Subject: [erlang-questions] Is there a mature xmpp cllient for erlang? In-Reply-To: References: Message-ID: Hadn't known about natter, will give it a try. The ones I've heard of are Exmpp (not avail yet), Stropherl (nice, but not usable yet), ezxmpp (Mine, also not usable yet but close [as is everyones ;)]), and Jabberlang. =Bill.Barnhill On Thu, Mar 26, 2009 at 3:36 AM, French, Mike < Mike.French@REDACTED> wrote: > > > -----Original Message----- > > From: erlang-questions-bounces@REDACTED > > [mailto:erlang-questions-bounces@REDACTED]On Behalf Of > > Michael Ossareh > > Sent: 26 March 2009 03:47 > > To: erlang-questions@REDACTED > > Subject: Re: [erlang-questions] Is there a mature xmpp cllient for > > erlang? > > > process-one have one (exmpp) that I understand they're close to > releasing. > > Yes, first mentioned in Dec 2006 > > http://erlang.org/pipermail/erlang-questions/2006-December/024324.html > > should be real soon now :) > > Mike > > > Thales UK Ltd (Wells) DISCLAIMER: The information contained in this e-mail > is confidential. It may also be legally privileged. It is intended only for > the stated addressee(s) and access to it by any other person is > unauthorised. If you are not an addressee, you must not disclose, copy, > circulate or in any other way use or rely on the information contained in > this e-mail. Such unauthorised use may be unlawful. We may monitor all > e-mail communications through our networks. If you have received this > e-mail > in error, please inform us immediately on sender's telephone number above > and delete it and all copies from your system. We accept no responsibility > for changes to any e-mail which occur after it has been sent. Attachments > to this e-mail may contain software viruses which could damage your system. > We therefore recommend you virus-check all attachments before opening. > Thales UK Ltd. Registered Office: 2 Dashwood Lang Road, The Bourne Business > Park, Addlestone, Weybridge, Surrey KT15 2NX Registered in England No. > 868273 > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From yoursurrogategod@REDACTED Fri Mar 27 02:12:25 2009 From: yoursurrogategod@REDACTED (Yves S. Garret) Date: Thu, 26 Mar 2009 18:12:25 -0700 (PDT) Subject: [erlang-questions] Standard modern salary for an Erlang programmer? In-Reply-To: References: <2a67d3ff0903240722x14203c54j693bb1d12fd92953@mail.gmail.com> <49CB3F79.9030107@it.uu.se> <200903261222.47251.bekesa@sch.bme.hu> <49CB8622.5060102@it.uu.se> Message-ID: This seems like a silly suggestion, but why not roll your own business? Facebook with Yaws? A proprietary middle-ware library for IPC? From jeffm@REDACTED Fri Mar 27 02:58:43 2009 From: jeffm@REDACTED (jm) Date: Fri, 27 Mar 2009 12:58:43 +1100 Subject: [erlang-questions] open project ideas (was Standard modern salary for an Erlang programmer?) In-Reply-To: References: <2a67d3ff0903240722x14203c54j693bb1d12fd92953@mail.gmail.com> <49CB3F79.9030107@it.uu.se> <200903261222.47251.bekesa@sch.bme.hu> <49CB8622.5060102@it.uu.se> Message-ID: <49CC32D3.8040803@ghostgun.com> I've been thinking for the we should keep a public list of project that we would be interested in seeing done in Erlang. Some examples I've been thinking of, * wiki * CMS * ticketing system similar to request tracker (aka rt) * anti spam tools. Can never have enough good anti-spam tools these days. * a module for handling configuration files and reloading them. I was going to ask about this in a seperate email as I keep stumbling at this point was wondering how others handle this. * Tool for intergration with sysv init.d script, debian and redhat package building and management, in short tools to integrate with the OS more fully * continuing the last point: interface to sytem calls. eg, my own erlang_inotify, or a port/module for iptables. just imagine being about to point to a home gateways/routers and being able to say you wrote some of the code that runs on that. * protocol implementations * secure messaging for Erlang messages * hardened Erlang (wonder what this would look like). * anything mentioned about 5 times that no-one ever seem to get around to doing :-) There are many others. Now most of these aren't something to build a start-up around, but these will develope your erlang skills and build your reputation as a reliable and serious Erlang developer which in turn will help you land the next erlang job you see and command a higher salary. It will also help Erlangs wider adoption. One final point: if you publish a clean API to some of these project, eg the CMS and ticketing system, it would then be a trival matter for the person or team deploying to seemlessly integrate two or more project as subsystems to a larger system even if these subsystem run on different nodes. To continue the CMS/ticketing integration example, if your company had a policy policy to review any wiki edits you could trigger the creation of a ticket fro the task with out going via some other system which is not well suited to the task, eg email. Jeff. Yves S. Garret wrote: > This seems like a silly suggestion, but why not roll your own > business? Facebook with Yaws? A proprietary middle-ware library for > IPC? > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From ryeguy1@REDACTED Fri Mar 27 04:45:09 2009 From: ryeguy1@REDACTED (ryeguy) Date: Thu, 26 Mar 2009 20:45:09 -0700 (PDT) Subject: [erlang-questions] Why use test generators? Message-ID: <40a44e27-56d3-4f8d-82c8-092f09e2f84d@e18g2000yqo.googlegroups.com> As the title says, what situation would you be in when you would use test generators? The example the docs give is this: fib_test_() -> [?_assert(fib(0) == 1), ?_assert(fib(1) == 1), ?_assert(fib(2) == 2), ?_assert(fib(3) == 3), ?_assert(fib(4) == 5), ?_assert(fib(5) == 8), ?_assertException(error, function_clause, fib(-1)), ?_assert(fib(31) == 2178309) ]. Why would you use a list of tests instead of just singlely evaluating each one on its own linein the fib_test() method? From wglozer@REDACTED Fri Mar 27 07:00:32 2009 From: wglozer@REDACTED (Will) Date: Thu, 26 Mar 2009 23:00:32 -0700 Subject: [erlang-questions] announce: epgsql-1.1 Message-ID: Hello, I've released version 1.1 of epgsql, a pure Erlang database driver for PostgreSQL. The code can be found in mercurial repositories at: http://glozer.net/src/epgsql http://bitbucket.org/will/epgsql This release includes support for 64-bit integer datetimes, which are enabled by default in PostgreSQL 8.4, SSL session encryption, and SSL client certificate authentication. SSL support requires the new SSL application in Erlang/OTP R13A+. -Will -------------- next part -------------- An HTML attachment was scrubbed... URL: From richardc@REDACTED Fri Mar 27 08:15:35 2009 From: richardc@REDACTED (Richard Carlsson) Date: Fri, 27 Mar 2009 08:15:35 +0100 Subject: [erlang-questions] Why use test generators? In-Reply-To: <40a44e27-56d3-4f8d-82c8-092f09e2f84d@e18g2000yqo.googlegroups.com> References: <40a44e27-56d3-4f8d-82c8-092f09e2f84d@e18g2000yqo.googlegroups.com> Message-ID: <49CC7D17.4050708@it.uu.se> ryeguy wrote: > As the title says, what situation would you be in when you would use > test generators? The example the docs give is this: > > fib_test_() -> > [?_assert(fib(0) == 1), > ?_assert(fib(1) == 1), > ?_assert(fib(2) == 2), > ?_assert(fib(3) == 3), > ?_assert(fib(4) == 5), > ?_assert(fib(5) == 8), > ?_assertException(error, function_clause, fib(-1)), > ?_assert(fib(31) == 2178309) > ]. > > Why would you use a list of tests instead of just singlely evaluating > each one on its own linein the fib_test() method? Sure, you can do that. The difference would mainly be that eunit would report it as a single test that either succeeded entirely or failed at some particular line (and the asserts following the failed one would not be executed). The generator version will be reported as 8 individual tests, and even if one or more of them fails, all tests will be executed. /Richard From richardc@REDACTED Fri Mar 27 08:44:09 2009 From: richardc@REDACTED (Richard Carlsson) Date: Fri, 27 Mar 2009 08:44:09 +0100 Subject: [erlang-questions] Update on sharing constant data locally by reference rather than by copy? In-Reply-To: <49CAA362.9090901@online.fr> References: <49C14D07.9000808@online.fr> <49C21AD0.2050600@it.uu.se> <49CAA362.9090901@online.fr> Message-ID: <49CC83C9.9000502@it.uu.se> Olivier Boudeville wrote: > Richard Carlsson a ?crit : >> If the entire tables are constant over a long time, you could generate >> them as modules. Nowadays, compile-time constants (even complex ones) >> are placed in a constant pool associated with the module. So, you could >> generate something like this: >> >> -module(autogen_table). >> -export([find/1]). >> find(0) -> {some_struct, "hello", ...}; >> ... >> find(99) -> {some_other_struct, <<"hi!">>} >> find(X) -> throw({not_found, X}). >> >> As far as I know, these constants will not be copied to the private >> heaps of the processes. The generated code will also give you the >> fastest possible lookup. >> > Looks tempting, even if generating the modules sounds a bit complicated; > I may give it a try to reduce the memory footprint. I was also thinking > to using an ETS public table, as it seems to make sense in my particular > use case. Generating a module as a text file, and then compiling and loading it directly from within Erlang is the easiest approach, and is usually pretty easy (depending on how complicated code you need to generate, but simple tables should be trivial to generate with io:format.) If you want to avoid going to file, there are some different ways of doing that, but I suggest you start by generating plain source code. > More generally I would have imagined that the reference counting used > for large blobs could be used for most if not all data? This must be the > hybrid system Christian mentioned. Hope that some time it will be > integrated. Large heap binaries are always reference counted; this has nothing to do with the hybrid memory architecture. But it's only for binaries. What the hybrid system does is keep a separate, shared heap for all data that has been passed as messages. On the first send, the data is copied from the sender to the shared area, and from then on, it will be shared by all processes. This allows sharing, but also preserves the property that each process allocates its non-shared data on its own personal heap, that doesn't require locking, and that can be garbage collected without stopping any other process. /Richard From masse@REDACTED Fri Mar 27 09:07:48 2009 From: masse@REDACTED (mats cronqvist) Date: Fri, 27 Mar 2009 09:07:48 +0100 Subject: [erlang-questions] A couple of design questions In-Reply-To: <4a15e2a1-183a-4851-95be-b2608f3f82a8@z8g2000prd.googlegroups.com> (Steve Davis's message of "Thu\, 26 Mar 2009 07\:15\:40 -0700 \(PDT\)") References: <4a15e2a1-183a-4851-95be-b2608f3f82a8@z8g2000prd.googlegroups.com> Message-ID: <87eiwjcrsb.fsf@sterlett.hq.kred> Steve Davis writes: > Hi all, > > I am working on a gs-style interface to wx, and was hoping someone may > have an opinion on a couple of design issues: > > 1) I've been maintaining an ets table to cope with naming/references > and command events. In order to keep the references unique across > multiple UI instances (processes), I've used a key format that is > basically {self(), name}/{reference, data}. I've had problems > convincing myself that these tables are safe as they must be marked > "public". However, I'm now thinking that these references would be > better off in the process dictionary (something I am usually cautious > of doing) as these stored references are, or should be (a) private to > the process, (b) "transient" with the process, and (c) irrelevant > outside the process. So my question here is: in this case, is it as > valid as it seems to me now to the use of the process dictionary to > store a fair amount of data, and if so what limitations should I watch > out for? Oldtimers avoid the process dict because it used to be slow. "Real" functional programmers avoid both ets and the dict for religious reasons. AFAIK, there's no real reason to avoid the process dict in favor of ets. > 2) Starting the UI instance process merely uses spawn (and returns the > pid to the calling process). It's troubled me that perhaps the GUI > process should be more "OTP". However, given that this is a framework > that builds on wxe (with the graphics server already there), my > thinking is that the ownership (and supervision) of the UI process > would be better implemented by the calling application, since it can > link and supervise the UI. Making the UI run off a gen_server seems an > unnecessary complexity in the design of the framework. My question > here is: Simple though this is, is my thinking correct? In my experience, it pays off to use gen_server right from the start. Otherwise, once the state machine starts to grow, you'll either refactor to a gen_server or wish you had. gen_server has no noticeable performance penalty, but you do need to write a bunch of boilerplate. You might want to check out this(*) code for an example of how to abstract away the boilerplate. mats (*) gen_serv implements a gen_server callback. It will delegate to its own callback if possible (it's some sort of inheritance). E.g. given this module; -module('foo'). -author('Mats Cronqvist'). -export([handle_call/3]). handle_call(Msg,From,State) -> io:fwrite("~p~n",[{Msg,From,State}]), {ok,State}. you can do this; 1> gen_serv:start(foo). 2> gen_server:call(foo,bla). {bla,{<0.28519.2>,#Ref<0.0.12.74776>},undefined} http://code.google.com/p/eper/source/browse/trunk/src/gen_serv.erl From masse@REDACTED Fri Mar 27 09:10:58 2009 From: masse@REDACTED (mats cronqvist) Date: Fri, 27 Mar 2009 09:10:58 +0100 Subject: [erlang-questions] Standard modern salary for an Erlang programmer? In-Reply-To: <4ecde87b0903260804p6272c65ft2a62729789be790f@mail.gmail.com> (Jon Gretar Borgthorsson's message of "Thu\, 26 Mar 2009 15\:04\:26 +0000") References: <2a67d3ff0903240722x14203c54j693bb1d12fd92953@mail.gmail.com> <4ecde87b0903260804p6272c65ft2a62729789be790f@mail.gmail.com> Message-ID: <87ab77crn1.fsf@sterlett.hq.kred> Jon Gretar Borgthorsson writes: > On Thu, Mar 26, 2009 at 3:43 AM, Michael Ossareh wrote: >> I often find myself wondering if learning dying languages is a better >> way to get paid more than learning new languages that gain popularity. >> Cobol in banking anyone? =) > > Yup... My feelings excactly. You can either focus on Java and have a > 50% chance of having to write at least 4 different CMS's in your > life..... > Or you can focus on ADA and program the Space Shuttle. Although I agree with the sentiment here, it seems you're calling Java "a new language that's gaining popularity." Surely Java is the Cobol of the '00s? Maybe it's time to put FORTRAN77 back on the CV. mats From ulf.wiger@REDACTED Fri Mar 27 11:22:31 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Fri, 27 Mar 2009 11:22:31 +0100 Subject: [erlang-questions] A couple of design questions In-Reply-To: <87eiwjcrsb.fsf@sterlett.hq.kred> References: <4a15e2a1-183a-4851-95be-b2608f3f82a8@z8g2000prd.googlegroups.com> <87eiwjcrsb.fsf@sterlett.hq.kred> Message-ID: <49CCA8E7.9060006@erlang-consulting.com> mats cronqvist wrote: > > Oldtimers avoid the process dict because it used to be slow. > "Real" functional programmers avoid both ets and the dict > for religious reasons. AFAIK, there's no real reason to > avoid the process dict in favor of ets. I agree, sort of. I've argued before that the process dictionary is better than its reputation suggests. (: There are some different tradeoffs, though: - No GC on ets data, but data in the process dict will be subject to GC. Good or bad depending on how you look at it. - Objects in the process dict will be included in a crash report, while objects in ets will simply go away silently. Good or bad depending on your needs. - No copying when accessing the PD, while ETS accesses always copy (except large binaries, of course). The fact that the PD is GC:d will to some degree cancel out this advantage. - No lock contention when accessing the PD. Not sure exactly how this looks when other processes try to peek at your PD, but please don't use that for anything but debugging. (: In Steve's case, I guess there are no significant disadvantages in using the PD over ETS. BR, Ulf W -- Ulf Wiger CTO, Erlang Training & Consulting Ltd http://www.erlang-consulting.com From steven.charles.davis@REDACTED Fri Mar 27 11:27:26 2009 From: steven.charles.davis@REDACTED (Steve Davis) Date: Fri, 27 Mar 2009 05:27:26 -0500 Subject: [erlang-questions] A couple of design questions In-Reply-To: <87eiwjcrsb.fsf@sterlett.hq.kred> References: <4a15e2a1-183a-4851-95be-b2608f3f82a8@z8g2000prd.googlegroups.com> <87eiwjcrsb.fsf@sterlett.hq.kred> Message-ID: <49CCAA0E.8000107@gmail.com> Mats, Thanks for the assistance and guidance. re: 1) process dictionary - I've done this refactor and it has improved the code clarity a great deal. My only rule with this was to make the process dictionary entries "write only" as advised by Mr Armstrong in his excellent book. The code looks a good deal more sane, and indeed is considerably safer because it's not using the public ets that was apparently necessary before. re: 2) gen_server - I did notice that I had already begun implementing some remote calls for the more experimental features, so your answer here rings very, very true. I'm doing the gen_server refactor now rather than later. Thanks again :) Regards, Steve mats cronqvist wrote: > Steve Davis writes: > >> Hi all, >> >> I am working on a gs-style interface to wx, and was hoping someone may >> have an opinion on a couple of design issues: >> >> 1) I've been maintaining an ets table to cope with naming/references >> and command events. In order to keep the references unique across >> multiple UI instances (processes), I've used a key format that is >> basically {self(), name}/{reference, data}. I've had problems >> convincing myself that these tables are safe as they must be marked >> "public". However, I'm now thinking that these references would be >> better off in the process dictionary (something I am usually cautious >> of doing) as these stored references are, or should be (a) private to >> the process, (b) "transient" with the process, and (c) irrelevant >> outside the process. So my question here is: in this case, is it as >> valid as it seems to me now to the use of the process dictionary to >> store a fair amount of data, and if so what limitations should I watch >> out for? > > Oldtimers avoid the process dict because it used to be slow. "Real" > functional programmers avoid both ets and the dict for religious > reasons. AFAIK, there's no real reason to avoid the process dict in > favor of ets. > >> 2) Starting the UI instance process merely uses spawn (and returns the >> pid to the calling process). It's troubled me that perhaps the GUI >> process should be more "OTP". However, given that this is a framework >> that builds on wxe (with the graphics server already there), my >> thinking is that the ownership (and supervision) of the UI process >> would be better implemented by the calling application, since it can >> link and supervise the UI. Making the UI run off a gen_server seems an >> unnecessary complexity in the design of the framework. My question >> here is: Simple though this is, is my thinking correct? > > In my experience, it pays off to use gen_server right from the > start. Otherwise, once the state machine starts to grow, you'll > either refactor to a gen_server or wish you had. > > gen_server has no noticeable performance penalty, but you do need to > write a bunch of boilerplate. You might want to check out this(*) > code for an example of how to abstract away the boilerplate. > > mats > > (*) gen_serv implements a gen_server callback. It will delegate to its > own callback if possible (it's some sort of inheritance). E.g. given > this module; > > -module('foo'). > -author('Mats Cronqvist'). > -export([handle_call/3]). > > handle_call(Msg,From,State) -> > io:fwrite("~p~n",[{Msg,From,State}]), > {ok,State}. > > you can do this; > 1> gen_serv:start(foo). > 2> gen_server:call(foo,bla). > {bla,{<0.28519.2>,#Ref<0.0.12.74776>},undefined} > > http://code.google.com/p/eper/source/browse/trunk/src/gen_serv.erl > > From erlang@REDACTED Fri Mar 27 12:43:48 2009 From: erlang@REDACTED (Joe Armstrong) Date: Fri, 27 Mar 2009 12:43:48 +0100 Subject: [erlang-questions] make_ref bug or feature? Message-ID: <9b08084c0903270443m1cff61f3lb06aad51cfe5bf11@mail.gmail.com> I got a question from Ivo Danihelka about make_ref(). Isn't make_ref() supposed to generate "an almost unique reference" the manual says "Returns an almost unique reference. The returned reference will re-occur after approximately 2^82 calls; therefore it is unique enough for practical purposes." If I start two erlang shells and evaluate the following in both shells: 1> io:format("~p~n",[term_to_binary(make_ref())]). <<131,114,0,3,100,0,13,110,111,110,111,100,101,64,110,111,104,111,115,116,0,0, 0,0,34,0,0,0,0,0,0,0,0>> They *both* print the same thing - this violates the principle of least astonishment. (I thought I'd have to start 2^82 shells :-) Is this a bug or a feature? /Joe From kenneth.lundin@REDACTED Fri Mar 27 12:52:25 2009 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Fri, 27 Mar 2009 12:52:25 +0100 Subject: [erlang-questions] make_ref bug or feature? In-Reply-To: <9b08084c0903270443m1cff61f3lb06aad51cfe5bf11@mail.gmail.com> References: <9b08084c0903270443m1cff61f3lb06aad51cfe5bf11@mail.gmail.com> Message-ID: The reference is unique within one Erlang VM. I don't think you started 2 shells towards the same VM. /Kenneth On Fri, Mar 27, 2009 at 12:43 PM, Joe Armstrong wrote: > I got a question from Ivo Danihelka about make_ref(). > > Isn't make_ref() supposed to generate "an almost unique reference" the > manual says > > ? ?"Returns an almost unique reference. > ? ? The returned reference will re-occur after approximately 2^82 > calls; therefore it is unique enough for practical purposes." > > If I start two erlang shells and evaluate the following in both shells: > > 1> io:format("~p~n",[term_to_binary(make_ref())]). > <<131,114,0,3,100,0,13,110,111,110,111,100,101,64,110,111,104,111,115,116,0,0, > ?0,0,34,0,0,0,0,0,0,0,0>> > > They *both* print the same thing - this violates the principle of > least astonishment. > (I thought I'd have to start 2^82 shells :-) > > Is this a bug or a feature? > > /Joe > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From kenneth.lundin@REDACTED Fri Mar 27 13:18:43 2009 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Fri, 27 Mar 2009 13:18:43 +0100 Subject: [erlang-questions] make_ref bug or feature? In-Reply-To: References: <9b08084c0903270443m1cff61f3lb06aad51cfe5bf11@mail.gmail.com> Message-ID: The node name is included in the encoding of a ref so if you have 2 unnamed nodes they will be able to create the same values with make_ref. If you have node a and node b they will create different values with make_ref. /Kenneth On Fri, Mar 27, 2009 at 12:52 PM, Kenneth Lundin wrote: > The reference is unique within one Erlang VM. > > I don't think you started 2 shells towards the same VM. > > /Kenneth > > On Fri, Mar 27, 2009 at 12:43 PM, Joe Armstrong wrote: >> I got a question from Ivo Danihelka about make_ref(). >> >> Isn't make_ref() supposed to generate "an almost unique reference" the >> manual says >> >> ? ?"Returns an almost unique reference. >> ? ? The returned reference will re-occur after approximately 2^82 >> calls; therefore it is unique enough for practical purposes." >> >> If I start two erlang shells and evaluate the following in both shells: >> >> 1> io:format("~p~n",[term_to_binary(make_ref())]). >> <<131,114,0,3,100,0,13,110,111,110,111,100,101,64,110,111,104,111,115,116,0,0, >> ?0,0,34,0,0,0,0,0,0,0,0>> >> >> They *both* print the same thing - this violates the principle of >> least astonishment. >> (I thought I'd have to start 2^82 shells :-) >> >> Is this a bug or a feature? >> >> /Joe >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > From erlang@REDACTED Fri Mar 27 13:19:30 2009 From: erlang@REDACTED (Joe Armstrong) Date: Fri, 27 Mar 2009 13:19:30 +0100 Subject: [erlang-questions] make_ref bug or feature? In-Reply-To: <49CCBF35.4030000@gmail.com> References: <9b08084c0903270443m1cff61f3lb06aad51cfe5bf11@mail.gmail.com> <49CCBF35.4030000@gmail.com> Message-ID: <9b08084c0903270519q4913e3a7ga0abd6c990d8fe00@mail.gmail.com> I was putting Refs into a term and then serializing them with term_to_binary and sending them into a socket to another independent Erlang system (ie not using distributed Erlang) - so yes it was a problem since I'd assumed these were unique. /Joe On Fri, Mar 27, 2009 at 12:57 PM, Serge Aleynikov wrote: > Since a reference contains a node name, it's considered unique in a > distributed setup when nodes have different names (or within a single > non-distributed node). ?When two shells are started this way, since they are > not aware of each other and can't see each other's references, is it a > problem that their values are identical? > > Serge > > Joe Armstrong wrote: >> >> I got a question from Ivo Danihelka about make_ref(). >> >> Isn't make_ref() supposed to generate "an almost unique reference" the >> manual says >> >> ? ?"Returns an almost unique reference. >> ? ? The returned reference will re-occur after approximately 2^82 >> calls; therefore it is unique enough for practical purposes." >> >> If I start two erlang shells and evaluate the following in both shells: >> >> 1> io:format("~p~n",[term_to_binary(make_ref())]). >> >> <<131,114,0,3,100,0,13,110,111,110,111,100,101,64,110,111,104,111,115,116,0,0, >> ?0,0,34,0,0,0,0,0,0,0,0>> >> >> They *both* print the same thing - this violates the principle of >> least astonishment. >> (I thought I'd have to start 2^82 shells :-) >> >> Is this a bug or a feature? >> >> /Joe >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > From richardc@REDACTED Fri Mar 27 13:21:05 2009 From: richardc@REDACTED (Richard Carlsson) Date: Fri, 27 Mar 2009 13:21:05 +0100 Subject: [erlang-questions] make_ref bug or feature? In-Reply-To: <9b08084c0903270443m1cff61f3lb06aad51cfe5bf11@mail.gmail.com> References: <9b08084c0903270443m1cff61f3lb06aad51cfe5bf11@mail.gmail.com> Message-ID: <49CCC4B1.3000907@it.uu.se> Joe Armstrong wrote: > If I start two erlang shells and evaluate the following in both shells: > > 1> io:format("~p~n",[term_to_binary(make_ref())]). > <<131,114,0,3,100,0,13,110,111,110,111,100,101,64,110,111,104,111,115,116,0,0, > 0,0,34,0,0,0,0,0,0,0,0>> > > They *both* print the same thing - this violates the principle of > least astonishment. > (I thought I'd have to start 2^82 shells :-) > > Is this a bug or a feature? You didn't start two different distributed nodes, just two VM:s in non-distributed mode. The node name is included in the representation, which you can see if you extract a part of the byte sequence above: 2> [110,111,110,111,100,101,64,110,111,104,111,115,116]. "nonode@REDACTED" So you got the same name (and everything else the same too) in both VM:s, i.e., the default name. /Richard From saleyn@REDACTED Fri Mar 27 12:57:41 2009 From: saleyn@REDACTED (Serge Aleynikov) Date: Fri, 27 Mar 2009 07:57:41 -0400 Subject: [erlang-questions] make_ref bug or feature? In-Reply-To: <9b08084c0903270443m1cff61f3lb06aad51cfe5bf11@mail.gmail.com> References: <9b08084c0903270443m1cff61f3lb06aad51cfe5bf11@mail.gmail.com> Message-ID: <49CCBF35.4030000@gmail.com> Since a reference contains a node name, it's considered unique in a distributed setup when nodes have different names (or within a single non-distributed node). When two shells are started this way, since they are not aware of each other and can't see each other's references, is it a problem that their values are identical? Serge Joe Armstrong wrote: > I got a question from Ivo Danihelka about make_ref(). > > Isn't make_ref() supposed to generate "an almost unique reference" the > manual says > > "Returns an almost unique reference. > The returned reference will re-occur after approximately 2^82 > calls; therefore it is unique enough for practical purposes." > > If I start two erlang shells and evaluate the following in both shells: > > 1> io:format("~p~n",[term_to_binary(make_ref())]). > <<131,114,0,3,100,0,13,110,111,110,111,100,101,64,110,111,104,111,115,116,0,0, > 0,0,34,0,0,0,0,0,0,0,0>> > > They *both* print the same thing - this violates the principle of > least astonishment. > (I thought I'd have to start 2^82 shells :-) > > Is this a bug or a feature? > > /Joe > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From steven.charles.davis@REDACTED Fri Mar 27 14:53:22 2009 From: steven.charles.davis@REDACTED (Steve Davis) Date: Fri, 27 Mar 2009 06:53:22 -0700 (PDT) Subject: [erlang-questions] A couple of design questions In-Reply-To: <49CCA8E7.9060006@erlang-consulting.com> References: <4a15e2a1-183a-4851-95be-b2608f3f82a8@z8g2000prd.googlegroups.com> <87eiwjcrsb.fsf@sterlett.hq.kred> <49CCA8E7.9060006@erlang-consulting.com> Message-ID: <68b35b01-9e17-4692-b3f8-54d586416019@o11g2000yql.googlegroups.com> Ulf, Thanks for confirming that the PD was the right way to go. There's some very useful insights in your post that I'm sure are useful for others as well as me personally!) I'll let everyone know how I get on, and perhaps try this interface when it's stable and sufficiently documented. If you are interested in peeking at my current successes and disasters with this, it's all on github at http://github.com/komone/gx Regards, Steve On Mar 27, 5:22?am, Ulf Wiger wrote: > In Steve's case, I guess there are no significant > disadvantages in using the PD over ETS. > > BR, > Ulf W > -- > Ulf Wiger > CTO, Erlang Training & Consulting Ltdhttp://www.erlang-consulting.com > _______________________________________________ From dawsdesign@REDACTED Fri Mar 27 15:41:08 2009 From: dawsdesign@REDACTED (Matt Williamson) Date: Fri, 27 Mar 2009 10:41:08 -0400 Subject: [erlang-questions] Need help dynamically linking in pcre or removing it Message-ID: I'm trying to compile erlang on the iPhone using the build tools from apt-get. I can run configure successfully with a little hacking, but when it goes to compile pcre_exec.c, it sucks up all the memory on the iPhone and then it reboots. Any suggestions on how to make pcre work or remove it from the build? I can definitely live without regex in erl. Thanks! Matt -------------- next part -------------- An HTML attachment was scrubbed... URL: From per@REDACTED Fri Mar 27 17:22:25 2009 From: per@REDACTED (Per Hedeland) Date: Fri, 27 Mar 2009 17:22:25 +0100 (CET) Subject: [erlang-questions] IPv6 Message-ID: <200903271622.n2RGMPQm071931@pluto.hedeland.org> Hi, Is there some good reason for gen_tcp/gen_udp not auto-recognizing an 8-tuple as an IPv6 address? gen_tcp:listen/2 and gen_udp:open/2 don't even fail if you give them one w/o explicit 'inet6' option, but (OS stack permitting) interprets "the first 4 bytes" as an IPv4 address - shocking behaviour for an Erlang module! Erlang R13A (erts-5.7) [source] [rq:1] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.7 (abort with ^G) 1> gen_tcp:listen(1234, [{ip,{1,43981,4660,0,0,0,0,5}}]). {ok,#Port<0.439>} 2> gen_udp:open(1234, [{ip,{1,43981,4660,0,0,0,0,5}}]). {ok,#Port<0.449>} $ netstat -an | grep 1234 tcp 0 0 0.1.171.205:1234 0.0.0.0:* LISTEN udp 0 0 0.1.171.205:1234 0.0.0.0:* 'inet' may be a reasonable default (though it isn't actually documented as such as far as I can see), but blindly "applying" it in the face of obvious evidence to the contrary can't be right. gen_tcp:connect/3 and gen_udp:send/4 also have "interesting" behaviour: 4> gen_tcp:connect({1,43981,4660,0,0,0,0,5}, 1234, []). {error,nxdomain} 5> gen_udp:send(S, {1,43981,4660,0,0,0,0,5}, 1234, <<"hello">>). {error,nxdomain} Yeah, I can imagine that the name server had trouble finding that "domain"... (no, it didn't actually try a DNS lookup). --Per Hedeland From kevin@REDACTED Thu Mar 26 13:58:50 2009 From: kevin@REDACTED (Kevin A. Smith) Date: Thu, 26 Mar 2009 08:58:50 -0400 Subject: [erlang-questions] Is there a mature xmpp cllient for erlang? In-Reply-To: References: Message-ID: This is the primary reason why I started writing natter while I was at Engine Yard. There's no good XMPP client library for Erlang ATM. There's a lot of work still to be done -- natter doesn't have presence support for example -- but I'm interested in collaborating with interested folks to bring it up to speed. --Kevin On Mar 26, 2009, at 3:36 AM, French, Mike wrote: > >> -----Original Message----- >> From: erlang-questions-bounces@REDACTED >> [mailto:erlang-questions-bounces@REDACTED]On Behalf Of >> Michael Ossareh >> Sent: 26 March 2009 03:47 >> To: erlang-questions@REDACTED >> Subject: Re: [erlang-questions] Is there a mature xmpp cllient for >> erlang? > >> process-one have one (exmpp) that I understand they're close to >> releasing. > > Yes, first mentioned in Dec 2006 > > http://erlang.org/pipermail/erlang-questions/2006-December/024324.html > > should be real soon now :) > > Mike > > > Thales UK Ltd (Wells) DISCLAIMER: The information contained in this > e-mail > is confidential. It may also be legally privileged. It is intended > only for > the stated addressee(s) and access to it by any other person is > unauthorised. If you are not an addressee, you must not disclose, > copy, > circulate or in any other way use or rely on the information > contained in > this e-mail. Such unauthorised use may be unlawful. We may monitor all > e-mail communications through our networks. If you have received > this e-mail > in error, please inform us immediately on sender's telephone number > above > and delete it and all copies from your system. We accept no > responsibility > for changes to any e-mail which occur after it has been sent. > Attachments > to this e-mail may contain software viruses which could damage your > system. > We therefore recommend you virus-check all attachments before opening. > Thales UK Ltd. Registered Office: 2 Dashwood Lang Road, The Bourne > Business > Park, Addlestone, Weybridge, Surrey KT15 2NX Registered in England No. > 868273 > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From ryeguy1@REDACTED Fri Mar 27 20:23:28 2009 From: ryeguy1@REDACTED (ryeguy) Date: Fri, 27 Mar 2009 12:23:28 -0700 (PDT) Subject: [erlang-questions] Eunit fixtures - can someone show an example? Message-ID: Can someone show me an example of a test fixture with a setup and teardown function? The docs are sparse in this area, and don't have any examples of it. I can't figure it out. From hasan.veldstra@REDACTED Fri Mar 27 20:50:30 2009 From: hasan.veldstra@REDACTED (Hasan Veldstra) Date: Fri, 27 Mar 2009 19:50:30 +0000 Subject: [erlang-questions] Eunit fixtures - can someone show an example? In-Reply-To: References: Message-ID: <832086BF-3D24-4CB9-8D78-31562CAF814F@gmail.com> Here's a basic example: simple_test_() -> {setup, local, fun setup/0, %% This is called before the tests are run (to set up things). fun cleanup/1, %% This is called after the tests have been run (to clean up). fun(List) -> %% The argument to this is the return value of setup(). [ ?_assert(2*2 == 4), ?_assert(not(true) == false) ] end}. I haven't tried to run it but it should work. -- http://12monkeys.co.uk On 27 Mar 2009, at 19:23PM, ryeguy wrote: > Can someone show me an example of a test fixture with a setup and > teardown function? The docs are sparse in this area, and don't have > any examples of it. I can't figure it out. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From richardc@REDACTED Fri Mar 27 20:52:42 2009 From: richardc@REDACTED (Richard Carlsson) Date: Fri, 27 Mar 2009 20:52:42 +0100 Subject: [erlang-questions] Eunit fixtures - can someone show an example? In-Reply-To: References: Message-ID: <49CD2E8A.7090701@it.uu.se> ryeguy wrote: > Can someone show me an example of a test fixture with a setup and > teardown function? The docs are sparse in this area, and don't have > any examples of it. I can't figure it out. If the tests need some data from the setup function in order to run, you can write like this (with an "instantiator" for the body of tests): my_test_() -> {setup, fun () -> file:open(...) end, fun (FD) -> file:close(FD) end, fun (FD) -> [?_test(...FD...), ?_test(...FD...), ?_test(...FD...)] end } or if the tests don't need that data (FD above and P below), you can list them directly without an instantiator: my_test_() -> {setup, fun () -> P = spawn(...), register(foo, P), P end, fun (P) -> exit(P, kill) end, [?_test(...foo ! hello...), ?_test(...foo ! bonjour...), ?_test(...foo ! hola...)] } /Richard From tsuraan@REDACTED Fri Mar 27 21:00:39 2009 From: tsuraan@REDACTED (tsuraan) Date: Fri, 27 Mar 2009 15:00:39 -0500 Subject: [erlang-questions] gen_server call "failure" Message-ID: <84fb38e30903271300o6d53c4b8m1057a50ac07369f5@mail.gmail.com> According to the documentation, a gen_server call function may fail if the process in question exits before the call returns. What exactly does fail mean in this context? Does gen_server:call raise an exception? If so, is the format of that exception documented anywhere? From jeffm@REDACTED Sat Mar 28 02:11:05 2009 From: jeffm@REDACTED (jm) Date: Sat, 28 Mar 2009 12:11:05 +1100 Subject: [erlang-questions] Standard modern salary for an Erlang programmer? In-Reply-To: <87ab77crn1.fsf@sterlett.hq.kred> References: <2a67d3ff0903240722x14203c54j693bb1d12fd92953@mail.gmail.com> <4ecde87b0903260804p6272c65ft2a62729789be790f@mail.gmail.com> <87ab77crn1.fsf@sterlett.hq.kred> Message-ID: <49CD7929.1050408@ghostgun.com> Knowing dead languages seems to pay well. At least in computing. Here's a recent ad for a Cobol job in ACT, Australia. Telon Coolgen Cobol Specialist Salary: $180,000 12 month contract http://www.seek.com.au/users/apply/index.ascx?Sequence=94&PageNumber=1&JobID=15166601 Jeff. mats cronqvist wrote: > > Although I agree with the sentiment here, it seems you're calling > Java "a new language that's gaining popularity." Surely Java is > the Cobol of the '00s? > > Maybe it's time to put FORTRAN77 back on the CV. > > mats > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From matthew@REDACTED Sat Mar 28 04:08:28 2009 From: matthew@REDACTED (Matthew Dempsky) Date: Fri, 27 Mar 2009 20:08:28 -0700 Subject: [erlang-questions] Update on sharing constant data locally by reference rather than by copy? In-Reply-To: <49C21AD0.2050600@it.uu.se> References: <49C14D07.9000808@online.fr> <49C21AD0.2050600@it.uu.se> Message-ID: On Thu, Mar 19, 2009 at 3:13 AM, Richard Carlsson wrote: > As far as I know, these constants will not be copied to the private > heaps of the processes. You're talking about current Erlang releases, right? How does that work with module reloading? E.g., if foo:bar/0 returns a constant complex data structure and the result is not copied into the calling process's private heap, what happens when a module is purged while a process is still holding onto a reference to the data structure? From rschonberger@REDACTED Sat Mar 28 07:36:33 2009 From: rschonberger@REDACTED (Robert Schonberger) Date: Sat, 28 Mar 2009 17:36:33 +1100 Subject: [erlang-questions] Reservoir sampling gen_server Message-ID: hi everyone,I wanted to give my brain a bit of an exercise this morning, and so I wrote a gen_server that, given an arbitrary number of inputs, can provide a statistically random sample of those inputs. The inputs are passed via handle_cast, and a retrieval via handle_call. If you're interested in keeping a sample of a large amount of data, this could be interesting for you. Any comments would be appreciated, and patches / advice more so, http://schonberger.org/2009/03/28/reservoir-sampling-gen-server-in-erlang.html Thanks, Robert -- Robert Schonberger rschonberger@REDACTED -------------- next part -------------- An HTML attachment was scrubbed... URL: From bgustavsson@REDACTED Sat Mar 28 08:21:20 2009 From: bgustavsson@REDACTED (Bjorn Gustavsson) Date: Sat, 28 Mar 2009 08:21:20 +0100 Subject: [erlang-questions] Update on sharing constant data locally by reference rather than by copy? In-Reply-To: References: <49C14D07.9000808@online.fr> <49C21AD0.2050600@it.uu.se> Message-ID: <6672d0160903280021s4814ef48yc2e5b019c500456f@mail.gmail.com> On Sat, Mar 28, 2009 at 4:08 AM, Matthew Dempsky wrote: > On Thu, Mar 19, 2009 at 3:13 AM, Richard Carlsson wrote: >> As far as I know, these constants will not be copied to the private >> heaps of the processes. > > You're talking about current Erlang releases, right? ?How does that > work with module reloading? ?E.g., if foo:bar/0 returns a constant > complex data structure and the result is not copied into the calling > process's private heap, what happens when a module is purged while a > process is still holding onto a reference to the data structure? The data will be copied to the heap of each process that has a reference to the data before the module is purged. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From bengt.kleberg@REDACTED Sat Mar 28 09:13:39 2009 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Sat, 28 Mar 2009 09:13:39 +0100 Subject: [erlang-questions] link: 1000s of threads and blocking IO Message-ID: <1238228019.4605.13.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> Greetings, This is a paper from someone who measured Java application performance. Comparing few threads and non-blocking IO vs many threads and blocking IO. http://www.classhat.com/tymaPaulMultithread.pdf It seems as if Erlang programs are getting the concept right. The Erlang VM is another mattererl. Given +A it seems to be possible to do it right there, too. Or I might be missing something. bengt From kiderlang@REDACTED Sat Mar 28 10:39:23 2009 From: kiderlang@REDACTED (Kid Erlang) Date: Sat, 28 Mar 2009 03:39:23 -0600 Subject: [erlang-questions] questions about ERLANG! Message-ID: hi everybody. I have just discovered Erlang! it is very exciting. I have been making scripts with perl that call each other so I have hundreds of scripts running at once. my friend told me Erlang has processes so I thought I could replace my scripts with Erlang! I had bought the book programming Erlang. very good book and fun to read, but I still have questions about Erlang! it is my first functinal language and so far that has been pretty confusing! I am still reading the book too. recursive blew my mind! I have tried forever on this code and I finally have it working. there are no for loops in erlang so I had to write my own into recursive. here is the program what I came up with: -module(adder). -compile(export_all). add_up_list(List)->LengthOfList=erlang:length(List)-1,for_loop(0,LengthOfList,List). for_loop(CurrentLocationInList,LengthOfList,List)->if CurrentLocationInList==LengthOfList true->0;false->lists:nth(CurrentLocationInList+1,List)+for_loop(CurrentLocationInList+1,LengthOfList,List). the goal of this program is to take all the numbers of the list and add them together. but it will not compile! here is the error: ~$ erlc adder.erl ./adder.erl:5: syntax error before: true ./adder.erl:4: function for_loop/3 undefined where is my program wrong? I have written programs before this and they compiled. but this one really stumps me. I cannot figure out what is wrong. I have not got to the paralell part of Erlang yet but I hear it lets you automagically scale into the cloud! that is my goal with Erlang! - Kid Erlang -------------- next part -------------- An HTML attachment was scrubbed... URL: From vychodil.hynek@REDACTED Sat Mar 28 11:40:26 2009 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Sat, 28 Mar 2009 11:40:26 +0100 Subject: [erlang-questions] questions about ERLANG! In-Reply-To: References: Message-ID: <4d08db370903280340xd783b03l7f2bd5e3dd2ed79f@mail.gmail.com> If you want sum up list you can do it simply in this way: add_up_list([]) -> 0; add_up_list([H|T]) -> H + add_up_list(T). or in tail call manner add_up_list(L) -> add_up_list(L, 0). add_up_list([], X) -> X; add_up_list([H|T], X) -> add_up_list(T, H+X). What is wrong with your program? It is prelish ;-) I'm used to write thousands of SLOC in Perl professionally, but in Erlang you should write programs in differnet way. Firs think: make short statements and functions. Wrap to lines: add_up_list(List)-> LengthOfList=erlang:length(List)-1, for_loop(0,LengthOfList,List). for_loop(CurrentLocationInList,LengthOfList,List)-> if CurrentLocationInList==LengthOfList true->0; false->lists:nth(CurrentLocationInList+1,List)+for_loop(CurrentLocationInList+1,LengthOfList,List). Your 'if' satement is wrong. If statement in Erlang is very different. It should be if CurrentLocationInList==LengthOfList ->0; true->lists:nth(CurrentLocationInList+1,List)+for_loop(CurrentLocationInList+1,LengthOfList,List) end. or use case statement which seems more like what you have written: case CurrentLocationInList==LengthOfList of true ->0; false ->lists:nth(CurrentLocationInList+1,List)+for_loop(CurrentLocationInList+1,LengthOfList,List) end. Your program is not efficient. My first version is O(N) in time and O(N) in memory. Second one (tail call) is O(N) in time and O(1) in memory. Your vesrion is O(N^2) in time and O(N) in memory. For perl developer is confusing that Erlang doesn't have array! List is List e.g. conected list. Each call lists:nth case inner loop. Decoupling lists by head cut ([_|_]) is far better. In Erlang you should use pattern matching a lot and than your programs become elegant. 2009/3/28 Kid Erlang > hi everybody. I have just discovered Erlang! it is very exciting. I have > been making scripts with perl that call each other so I have hundreds of > scripts running at once. my friend told me Erlang has processes so I > thought I could replace my scripts with Erlang! I had bought the book > programming Erlang. very good book and fun to read, but I still have > questions about Erlang! it is my first functinal language and so far that > has been pretty confusing! I am still reading the book too. > > recursive blew my mind! I have tried forever on this code and I finally > have it working. there are no for loops in erlang so I had to write my own > into recursive. here is the program what I came up with: > > -module(adder). > -compile(export_all). > > > add_up_list(List)->LengthOfList=erlang:length(List)-1,for_loop(0,LengthOfList,List). > for_loop(CurrentLocationInList,LengthOfList,List)->if > CurrentLocationInList==LengthOfList > true->0;false->lists:nth(CurrentLocationInList+1,List)+for_loop(CurrentLocationInList+1,LengthOfList,List). > > the goal of this program is to take all the numbers of the list and add > them together. but it will not compile! here is the error: > > ~$ erlc adder.erl > ./adder.erl:5: syntax error before: true > ./adder.erl:4: function for_loop/3 undefined > > where is my program wrong? I have written programs before this and they > compiled. but this one really stumps me. I cannot figure out what is > wrong. > > I have not got to the paralell part of Erlang yet but I hear it lets you > automagically scale into the cloud! that is my goal with Erlang! > > - Kid Erlang > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- --Hynek (Pichi) Vychodil Analyze your data in minutes. Share your insights instantly. Thrill your boss. Be a data hero! Try Good Data now for free: www.gooddata.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From saleyn@REDACTED Sat Mar 28 13:14:31 2009 From: saleyn@REDACTED (Serge Aleynikov) Date: Sat, 28 Mar 2009 08:14:31 -0400 Subject: [erlang-questions] questions about ERLANG! In-Reply-To: References: Message-ID: <49CE14A7.9060503@gmail.com> Little addition to Hynek's advice - once you master the recursive solution, you can search through the lists module and find this helpful lists:sum/1 function: 1> lists:sum(lists:seq(1,10)). 55 Kid Erlang wrote: > hi everybody. I have just discovered Erlang! it is very exciting. I > have been making scripts with perl that call each other so I have > hundreds of scripts running at once. my friend told me Erlang has > processes so I thought I could replace my scripts with Erlang! I had > bought the book programming Erlang. very good book and fun to read, but > I still have questions about Erlang! it is my first functinal language > and so far that has been pretty confusing! I am still reading the book too. > > recursive blew my mind! I have tried forever on this code and I finally > have it working. there are no for loops in erlang so I had to write my > own into recursive. here is the program what I came up with: > > -module(adder). > -compile(export_all). > > add_up_list(List)->LengthOfList=erlang:length(List)-1,for_loop(0,LengthOfList,List). > for_loop(CurrentLocationInList,LengthOfList,List)->if > CurrentLocationInList==LengthOfList > true->0;false->lists:nth(CurrentLocationInList+1,List)+for_loop(CurrentLocationInList+1,LengthOfList,List). > > the goal of this program is to take all the numbers of the list and add > them together. but it will not compile! here is the error: > > ~$ erlc adder.erl > ./adder.erl:5: syntax error before: true > ./adder.erl:4: function for_loop/3 undefined > > where is my program wrong? I have written programs before this and they > compiled. but this one really stumps me. I cannot figure out what is > wrong. > > I have not got to the paralell part of Erlang yet but I hear it lets you > automagically scale into the cloud! that is my goal with Erlang! > > - Kid Erlang > > > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From steven.charles.davis@REDACTED Sat Mar 28 17:16:31 2009 From: steven.charles.davis@REDACTED (Steve Davis) Date: Sat, 28 Mar 2009 09:16:31 -0700 (PDT) Subject: [erlang-questions] A couple of design questions In-Reply-To: <68b35b01-9e17-4692-b3f8-54d586416019@o11g2000yql.googlegroups.com> References: <4a15e2a1-183a-4851-95be-b2608f3f82a8@z8g2000prd.googlegroups.com> <87eiwjcrsb.fsf@sterlett.hq.kred> <49CCA8E7.9060006@erlang-consulting.com> <68b35b01-9e17-4692-b3f8-54d586416019@o11g2000yql.googlegroups.com> Message-ID: <40968fa0-9a2e-40f9-afb6-94273cf25e13@w9g2000yqa.googlegroups.com> The gen_server refactor went pretty smoothly. I has again improved the sanity of my code (and pushed up to github). Right now, gx is down to one UI instance per module temporarily, as I've chosen to use ?MODULE to register the server, but that's just a wrinkle. What was a surprise to me was that the WX events appeared in handle_info rather than handle_cast. You learn something new every day :) Thanks, to both Mats and Ulf for the timely and very useful input on this. Regards, Steve From ryeguy1@REDACTED Sat Mar 28 18:39:31 2009 From: ryeguy1@REDACTED (ryeguy) Date: Sat, 28 Mar 2009 10:39:31 -0700 (PDT) Subject: [erlang-questions] Eunit fixtures - can someone show an example? In-Reply-To: <832086BF-3D24-4CB9-8D78-31562CAF814F@gmail.com> References: <832086BF-3D24-4CB9-8D78-31562CAF814F@gmail.com> Message-ID: <1e5e83aa-a9bd-4db2-808a-2183c323baf3@y13g2000yqn.googlegroups.com> Ok, what am I doing wrong here? How do I pass what the setup function returned on to the tests? %randomly generate a username and email address register_setup() -> {u:random_str(10), list_to_binary([u:random_str(3), <<"@">>, u:random_str(3), <<".com">>])}. register_teardown({Username,_}) -> mnesia:dirty_delete(hd(mnesia:dirty_index_read(user, Username, #user.username))). register_test_() -> {setup, fun register_setup/0, fun register_teardown/1, fun(User) -> [ ?_test(fun register_normal/1) ] end}. instantiate_test(Fun) -> fun(Fixture) -> ?_test(Fun(Fixture)) end. register_normal({Username, Email}) -> ?debugMsg(asdasd), ?_assert(ok == users:register([Username, Email, <<"abc123">>])). My register_normal function is not even being called. Why? On Mar 27, 3:50?pm, Hasan Veldstra wrote: > Here's a basic example: > > simple_test_() -> > ? ? ?{setup, local, > ? ? ? fun setup/0, ? %% This is called before the tests are run (to ? > set up things). > ? ? ? fun cleanup/1, %% This is called after the tests have been run ? > (to clean up). > ? ? ? fun(List) -> ? %% The argument to this is the return value of ? > setup(). > ? ? ? ? ? ? ? [ > ? ? ? ? ? ? ? ??_assert(2*2 == 4), > ? ? ? ? ? ? ? ??_assert(not(true) == false) > ? ? ? ? ? ? ? ] > ? ? ? end}. > > I haven't tried to run it but it should work. > > --http://12monkeys.co.uk > > On 27 Mar 2009, at 19:23PM, ryeguy wrote: > > > Can someone show me an example of a test fixture with a setup and > > teardown function? The docs are sparse in this area, and don't have > > any examples of it. I can't figure it out. > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questi...@REDACTED > >http://www.erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions From richardc@REDACTED Sat Mar 28 22:41:18 2009 From: richardc@REDACTED (Richard Carlsson) Date: Sat, 28 Mar 2009 22:41:18 +0100 Subject: [erlang-questions] Eunit fixtures - can someone show an example? In-Reply-To: <1e5e83aa-a9bd-4db2-808a-2183c323baf3@y13g2000yqn.googlegroups.com> References: <832086BF-3D24-4CB9-8D78-31562CAF814F@gmail.com> <1e5e83aa-a9bd-4db2-808a-2183c323baf3@y13g2000yqn.googlegroups.com> Message-ID: <49CE997E.1020502@it.uu.se> ryeguy wrote: > Ok, what am I doing wrong here? How do I pass what the setup function > returned on to the tests? > > ... > > ?_test(fun register_normal/1) There's your problem. This is like writing ?_test(42) or ?_test("hello"), i.e., it simply tests that it can create the fun-value (and if it goes through the compiler, then it should). You can either write like this: register_test_() -> {setup, fun register_setup/0, fun register_teardown/1, fun(User) -> [ ?_test(register_normal(User)) ] end}. or, using the special "with"-construct: register_test_() -> {setup, fun register_setup/0, fun register_teardown/1, {with, [ fun register_normal/1 ] end}. (Your register_normal/1 function is what the eunit documentation calls an "abstract test", i.e., like a normal test function but missing some data in order to run.) /Richard From dawsdesign@REDACTED Sat Mar 28 22:38:19 2009 From: dawsdesign@REDACTED (Matt Williamson) Date: Sat, 28 Mar 2009 17:38:19 -0400 Subject: [erlang-questions] Compiling Erlang for the iPhone In-Reply-To: References: <5A017A52-FFE7-4DE7-A9AD-64183CF8DBDD@dauernheim.net> <41A4BCB4-B60E-4009-AFDB-1C06C5A6254A@andygross.org> <6a36e7290809171758s2ea4ad25v7c98a1b8b377b6b@mail.gmail.com> Message-ID: I've gotten past the CPP fails error by setting it to the correct version (iPhone SDK) and have gotten it to configure correctly: - nano erts/configure - Search (Ctrl+W for nano) for "checking whether getaddrinfo accepts enough flags" without the quotes and then remove the entire line a couple lines down which contains the command "{ (exit 1); exit 1; }; }" and replace the whole line with a single "}" without the quotes. export CC=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin9-gcc-4.0.1 export CPP=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/cpp export LD="/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ld" export RANLIB=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ranlib export AR=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ar export CXXPP=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/cpp export CXX=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/g++ export NM=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/nm export CFLAGS="-arch armv6-I/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.2.1.sdk/usr/include/ -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.2.1.sdk" export CXXFLAGS=$CFLAGS export LDFLAGS=$CFLAGS ./configure --host=arm-apple-darwin --target=arm-apple-darwin --prefix=/usr/local/iphone --target=arm-apple-darwin --disable-smp-support ********************************************************************* ********************** APPLICATIONS DISABLED ********************** ********************************************************************* crypto : No usable OpenSSL found odbc : ODBC library - link check failed ssh : No usable OpenSSL found ssl : No usable OpenSSL found ********************************************************************* But then when I run make, I get pretty far, but I run into an error at: erl_memory.c:2620: warning: pointer targets in passing argument 3 of ?accept? differ in signedness /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin9-gcc-4.0.1 -DUSE_THREADS -D_THREAD_SAFE -D_REENTRANT -arch armv6-I/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.2.1.sdk/usr/include/ -I/Users/dawsdesign/Projects/otp_src_R12B-5/erts/emulator/arm-apple-darwin/opt/smp/ -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.2.1.sdk -I/Users/dawsdesign/Projects/otp_src_R12B-5/erts/arm-apple-darwin -no-cpp-precomp -I/Users/dawsdesign/Projects/otp_src_R12B-5/erts/include -I/Users/dawsdesign/Projects/otp_src_R12B-5/erts/include/arm-apple-darwin -I/Users/dawsdesign/Projects/otp_src_R12B-5/erts/include/internal -I/Users/dawsdesign/Projects/otp_src_R12B-5/erts/include/internal/arm-apple-darwin -o ../obj/arm-apple-darwin/opt/emem/erl_memory_trace_block_table.o -c erl_memory_trace_block_table.c /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin9-gcc-4.0.1 -arch armv6-I/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.2.1.sdk/usr/include/ -I/Users/dawsdesign/Projects/otp_src_R12B-5/erts/emulator/arm-apple-darwin/opt/smp/ -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.2.1.sdk -o ../bin/arm-apple-darwin/emem ../obj/arm-apple-darwin/opt/emem/erl_memory.o ../obj/arm-apple-darwin/opt/emem/erl_memory_trace_block_table.o -lutil -ldl -lm -L/Users/dawsdesign/Projects/otp_src_R12B-5/erts/lib/arm-apple-darwin -L/Users/dawsdesign/Projects/otp_src_R12B-5/erts/lib/internal/arm-apple-darwin -lerts_r -lethread -lpthread ld warning: in /Users/dawsdesign/Projects/otp_src_R12B-5/erts/lib/arm-apple-darwin/liberts_r.a, file is not of required architecture Undefined symbols: "_emtp_get_info", referenced from: _complete_state in erl_memory.o "_emtp_state_new", referenced from: _new_state in erl_memory.o "_emtp_parse", referenced from: _process_trace in erl_memory.o _process_trace in erl_memory.o "_emtp_error_string", referenced from: _error_string in erl_memory.o "_emtp_state_destroy", referenced from: _destroy_state in erl_memory.o _new_state in erl_memory.o ld: symbol(s) not found collect2: ld returned 1 exit status make[4]: *** [../bin/arm-apple-darwin/emem] Error 1 make[3]: *** [opt] Error 2 make[2]: *** [opt] Error 2 make[1]: *** [opt] Error 2 make: *** [libs] Error 2 I get even further compiling directly on the iPhone, but when it goes to compile pcre, it runs out of memory and reboots. Anyone have any ideas. On Thu, Sep 18, 2008 at 4:59 AM, Tony Rogvall wrote: > There are alternatives. > > You do not have to go the apple way if you use Pawnage tool. Then you > can build packages > for the Cydia installer. > The cross compiler can be found at Mac Ports. It require that you do > have a copy of the root file system on > the build machine. > > /Tony > > > > On 18 sep 2008, at 02.58, Bob Ippolito wrote: > > > I think it might actually say that you can't have a VM or interpreter > > that will run code over the network, I think you can use one as long > > as the code it's executing is static. > > > > (I haven't read the SDK agreement, but I did hear people talking at > > length about iPhone stuff at C4[2] recently) > > > > On Wed, Sep 17, 2008 at 11:56 AM, Andy Gross > > wrote: > >> > >> Uwe, > >> > >> Unfortunately, the iPhone SDK Agreement forbids installation of non- > >> Apple VMs or interpreters. :( > >> > >> Andy > >> > >> > >> On Sep 14, 2008, at 12:49 PM, Uwe Dauernheim wrote: > >> > >>> Hej Chris, > >>> > >>> of course I'll do so, if I can deliver a benefit to the community. > >>> > >>> By the way: Anyone expierenced in the error message >>"lib/cpp" > >>> fails > >>> sanity check< >>> > >>> Regards, > >>> Uwe > >>> > >>> -- > >>> > >>> Am 14.09.2008 um 18:22 schrieb Chris Anderson: > >>> > >>>> On Sun, Sep 14, 2008 at 9:16 AM, Uwe Dauernheim > >>>> > >>>> wrote: > >>>>> I'd like to compile Erlang for the iPhone. > >>>> > >>>> Uwe, > >>>> > >>>> I'm sorry I can't be helpful with an answer to your question, but I > >>>> am > >>>> very interested in your result. Please keep us posted on this > >>>> list if > >>>> you have success! > >>>> > >>>> Thanks, > >>>> Chris > >>>> > >>>> -- > >>>> Chris Anderson > >>>> http://jchris.mfdz.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 > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dawsdesign@REDACTED Sat Mar 28 23:14:24 2009 From: dawsdesign@REDACTED (Matt Williamson) Date: Sat, 28 Mar 2009 18:14:24 -0400 Subject: [erlang-questions] Compiling Erlang for the iPhone In-Reply-To: References: <5A017A52-FFE7-4DE7-A9AD-64183CF8DBDD@dauernheim.net> <41A4BCB4-B60E-4009-AFDB-1C06C5A6254A@andygross.org> <6a36e7290809171758s2ea4ad25v7c98a1b8b377b6b@mail.gmail.com> Message-ID: I made a little more progess with R13, but it seems even though I am specifying make *noboot* erlc is still trying to run. IT will not run as I am compiling for a different architecture!: === Entering application stdlib erlc -W +debug_info -I../include -I../../kernel/include -o../ebin array.erl ./array.erl:156: bad attribute ./array.erl:177: type array() undefined ./array.erl:221: type array() undefined ./array.erl:242: type array() undefined ./array.erl:309: type array() undefined ./array.erl:320: type array() undefined ./array.erl:404: type array() undefined ./array.erl:404: type array() undefined ./array.erl:415: type array() undefined ./array.erl:454: type array() undefined ./array.erl:454: type array() undefined ./array.erl:480: type array() undefined ./array.erl:480: type array() undefined ./array.erl:513: type array() undefined ./array.erl:513: type array() undefined ./array.erl:564: type array() undefined ./array.erl:564: type array() undefined ./array.erl:628: type array() undefined ./array.erl:669: type array() undefined ./array.erl:669: type array() undefined ./array.erl:727: type array() undefined ./array.erl:801: type array() undefined ./array.erl:869: type array() undefined ./array.erl:882: type array() undefined ./array.erl:980: type array() undefined ./array.erl:1073: type array() undefined ./array.erl:1154: type array() undefined ./array.erl:1169: type array() undefined ./array.erl:1256: type array() undefined ./array.erl:1256: type array() undefined ./array.erl:1348: type array() undefined ./array.erl:1348: type array() undefined ./array.erl:1446: type array() undefined ./array.erl:1521: type array() undefined ./array.erl:1600: type array() undefined ./array.erl:1681: type array() undefined ./array.erl:1732: type array() undefined make[4]: *** [../ebin/array.beam] Error 1 make[3]: *** [opt] Error 2 make[2]: *** [opt] Error 2 make[1]: *** [libs] Error 2 make: *** [noboot] Error 2 On Sat, Mar 28, 2009 at 5:38 PM, Matt Williamson wrote: > I've gotten past the CPP fails error by setting it to the correct version > (iPhone SDK) and have gotten it to configure correctly: > > > - nano erts/configure > - Search (Ctrl+W for nano) for "checking whether getaddrinfo accepts > enough flags" without the quotes and then remove the entire line a couple > lines down which contains the command "{ (exit 1); exit 1; }; }" and replace > the whole line with a single "}" without the quotes. > > > > export > CC=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin9-gcc-4.0.1 > export CPP=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/cpp > export LD="/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ld" > export > RANLIB=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ranlib > export AR=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ar > export CXXPP=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/cpp > export CXX=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/g++ > export NM=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/nm > > export CFLAGS="-arch > armv6-I/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.2.1.sdk/usr/include/ > -isysroot > /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.2.1.sdk" > export CXXFLAGS=$CFLAGS > export LDFLAGS=$CFLAGS > > ./configure --host=arm-apple-darwin --target=arm-apple-darwin > --prefix=/usr/local/iphone --target=arm-apple-darwin --disable-smp-support > > ********************************************************************* > ********************** APPLICATIONS DISABLED ********************** > ********************************************************************* > > crypto : No usable OpenSSL found > odbc : ODBC library - link check failed > ssh : No usable OpenSSL found > ssl : No usable OpenSSL found > > ********************************************************************* > > > But then when I run make, I get pretty far, but I run into an error at: > > erl_memory.c:2620: warning: pointer targets in passing argument 3 of > ?accept? differ in signedness > /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin9-gcc-4.0.1 > -DUSE_THREADS -D_THREAD_SAFE -D_REENTRANT -arch > armv6-I/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.2.1.sdk/usr/include/ > -I/Users/dawsdesign/Projects/otp_src_R12B-5/erts/emulator/arm-apple-darwin/opt/smp/ > -isysroot > /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.2.1.sdk > -I/Users/dawsdesign/Projects/otp_src_R12B-5/erts/arm-apple-darwin > -no-cpp-precomp -I/Users/dawsdesign/Projects/otp_src_R12B-5/erts/include > -I/Users/dawsdesign/Projects/otp_src_R12B-5/erts/include/arm-apple-darwin > -I/Users/dawsdesign/Projects/otp_src_R12B-5/erts/include/internal > -I/Users/dawsdesign/Projects/otp_src_R12B-5/erts/include/internal/arm-apple-darwin > -o ../obj/arm-apple-darwin/opt/emem/erl_memory_trace_block_table.o -c > erl_memory_trace_block_table.c > /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin9-gcc-4.0.1 > -arch > armv6-I/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.2.1.sdk/usr/include/ > -I/Users/dawsdesign/Projects/otp_src_R12B-5/erts/emulator/arm-apple-darwin/opt/smp/ > -isysroot > /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.2.1.sdk -o > ../bin/arm-apple-darwin/emem ../obj/arm-apple-darwin/opt/emem/erl_memory.o > ../obj/arm-apple-darwin/opt/emem/erl_memory_trace_block_table.o -lutil -ldl > -lm -L/Users/dawsdesign/Projects/otp_src_R12B-5/erts/lib/arm-apple-darwin > -L/Users/dawsdesign/Projects/otp_src_R12B-5/erts/lib/internal/arm-apple-darwin > -lerts_r -lethread -lpthread > ld warning: in > /Users/dawsdesign/Projects/otp_src_R12B-5/erts/lib/arm-apple-darwin/liberts_r.a, > file is not of required architecture > Undefined symbols: > "_emtp_get_info", referenced from: > _complete_state in erl_memory.o > "_emtp_state_new", referenced from: > _new_state in erl_memory.o > "_emtp_parse", referenced from: > _process_trace in erl_memory.o > _process_trace in erl_memory.o > "_emtp_error_string", referenced from: > _error_string in erl_memory.o > "_emtp_state_destroy", referenced from: > _destroy_state in erl_memory.o > _new_state in erl_memory.o > ld: symbol(s) not found > collect2: ld returned 1 exit status > make[4]: *** [../bin/arm-apple-darwin/emem] Error 1 > make[3]: *** [opt] Error 2 > make[2]: *** [opt] Error 2 > make[1]: *** [opt] Error 2 > make: *** [libs] Error 2 > > > I get even further compiling directly on the iPhone, but when it goes to > compile pcre, it runs out of memory and reboots. Anyone have any ideas. > > > > On Thu, Sep 18, 2008 at 4:59 AM, Tony Rogvall wrote: > >> There are alternatives. >> >> You do not have to go the apple way if you use Pawnage tool. Then you >> can build packages >> for the Cydia installer. >> The cross compiler can be found at Mac Ports. It require that you do >> have a copy of the root file system on >> the build machine. >> >> /Tony >> >> >> >> On 18 sep 2008, at 02.58, Bob Ippolito wrote: >> >> > I think it might actually say that you can't have a VM or interpreter >> > that will run code over the network, I think you can use one as long >> > as the code it's executing is static. >> > >> > (I haven't read the SDK agreement, but I did hear people talking at >> > length about iPhone stuff at C4[2] recently) >> > >> > On Wed, Sep 17, 2008 at 11:56 AM, Andy Gross >> > wrote: >> >> >> >> Uwe, >> >> >> >> Unfortunately, the iPhone SDK Agreement forbids installation of non- >> >> Apple VMs or interpreters. :( >> >> >> >> Andy >> >> >> >> >> >> On Sep 14, 2008, at 12:49 PM, Uwe Dauernheim wrote: >> >> >> >>> Hej Chris, >> >>> >> >>> of course I'll do so, if I can deliver a benefit to the community. >> >>> >> >>> By the way: Anyone expierenced in the error message >>"lib/cpp" >> >>> fails >> >>> sanity check<> >>> >> >>> Regards, >> >>> Uwe >> >>> >> >>> -- >> >>> >> >>> Am 14.09.2008 um 18:22 schrieb Chris Anderson: >> >>> >> >>>> On Sun, Sep 14, 2008 at 9:16 AM, Uwe Dauernheim >> >>>> >> >>>> wrote: >> >>>>> I'd like to compile Erlang for the iPhone. >> >>>> >> >>>> Uwe, >> >>>> >> >>>> I'm sorry I can't be helpful with an answer to your question, but I >> >>>> am >> >>>> very interested in your result. Please keep us posted on this >> >>>> list if >> >>>> you have success! >> >>>> >> >>>> Thanks, >> >>>> Chris >> >>>> >> >>>> -- >> >>>> Chris Anderson >> >>>> http://jchris.mfdz.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 >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From MARTIN.LOGAN@REDACTED Wed Mar 25 17:12:23 2009 From: MARTIN.LOGAN@REDACTED (Logan, Martin) Date: Wed, 25 Mar 2009 11:12:23 -0500 Subject: [erlang-questions] Standard modern salary for an Erlang programmer? In-Reply-To: <2a67d3ff0903240722x14203c54j693bb1d12fd92953@mail.gmail.com> References: <2a67d3ff0903240722x14203c54j693bb1d12fd92953@mail.gmail.com> Message-ID: <77C1226CCC2F7C41B022662F4775DABC56EF2A1460@EGEXCMB01.oww.root.lcl> I don't think there is an average salary yet. Erlang usage in my experience here in the US is still limited to first time projects at most companies. The language has not yet been incorporated on a broad scale as a standard part of operations for most companies. Therefore it depends largely on the varying business values that individual Erlang projects present to the companies that have decided to use it. Very senior people that are coming in to architect and provide guidance can pull in over 6 figure equivalent contracts or even salaries, less senior people or those that are just learning, less. My point is, that don't count on a salary of this or that range. Erlang should not be your bread and butter at this point. If you are one of the few of us lucky enough to do a long full time Erlang stint then good for you - but have a backup and base your salary expectations of other factors besides what other Erlang programmers have managed to make. ________________________________ From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of G.S. Sent: Tuesday, March 24, 2009 9:23 AM To: erlang-questions@REDACTED Subject: [erlang-questions] Standard modern salary for an Erlang programmer? Hello everyone, What's a standard, good average salary for the Erlang programmer with a few years of experience, based in USA? Java is 70-90k, and I read online that since us Erlangers, being a less known, and essential for writing software that scales, and will scale into the future, is much higher. I seem to find various blogs that state the salary in 2008 was anywhere from 99k to 180k. Can anyone throw a few numbers at me that are currently working in the industry using Erlang? Thanks, -Gene -------------- next part -------------- An HTML attachment was scrubbed... URL: From ro4tub@REDACTED Sun Mar 29 07:27:29 2009 From: ro4tub@REDACTED (Oscar) Date: Sun, 29 Mar 2009 13:27:29 +0800 Subject: [erlang-questions] Can't start TV Message-ID: <9a77767b0903282227t4321745aib2c03a7e4aff29b1@mail.gmail.com> mangos@REDACTED:~/work/openpoker$ erl Erlang (BEAM) emulator version 5.6.5 [source] [smp:2] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.6.5 (abort with ^G) 1> tv:start(). <0.33.0> 2> mangos@REDACTED:~/work/openpoker$ uname -a Linux mangos-laptop 2.6.27-13-generic #1 SMP Thu Feb 26 07:26:43 UTC 2009 i686 GNU/Linux After I run the command 'tv:start().', no GUI windows pop-out. Where can I find the start-up log? Thanks, -Oscar -------------- next part -------------- An HTML attachment was scrubbed... URL: From ahmed.diaa@REDACTED Sun Mar 29 10:08:16 2009 From: ahmed.diaa@REDACTED (Ahmed Diaa) Date: Sun, 29 Mar 2009 10:08:16 +0200 Subject: [erlang-questions] Dialyzer and apply Message-ID: Hello there , I started using Dialyzer lately , and found it really usefull. But , I had a case that I expected dialyzer to discover but it didn't. The case occurs when using erlang:apply/3 or timer:apply_after/4 Here's the example -module(dtest). -export([foo/0]). foo()-> timer:apply_after(100,?MODULE, bar, [ ]), erlang:apply(?MODULE,bar,[ ]). When running the dialyzer for this module , it didn't discover the call to a missing function. Wouldn't it be nice if dialyzer could discover such cases? Best Regards Ahmed Diaa -------------- next part -------------- An HTML attachment was scrubbed... URL: From kostis@REDACTED Sun Mar 29 10:58:26 2009 From: kostis@REDACTED (Kostis Sagonas) Date: Sun, 29 Mar 2009 11:58:26 +0300 Subject: [erlang-questions] Dialyzer and apply In-Reply-To: References: Message-ID: <49CF3832.70703@cs.ntua.gr> Ahmed Diaa wrote: > Hello there , > I started using Dialyzer lately , and found it really usefull. But , I > had a case that I expected dialyzer to discover but it didn't. > > The case occurs when using erlang:apply/3 or timer:apply_after/4 > Here's the example > > -module(dtest). > > -export([foo/0]). > > foo()-> > timer:apply_after(100,?MODULE, bar, [ ]), > erlang:apply(?MODULE,bar,[ ]). > > When running the dialyzer for this module , it didn't discover the call > to a missing function. > > Wouldn't it be nice if dialyzer could discover such cases? Yes, it would be but: - there is very little reason to use erlang:apply/3 when the module name, function name and the number of arguments are known (like in your example, where you should really use ?MODULE:bar() instead) - detecting the timer:apply_after/4 missing functions would mean that dialyzer has hard-coded information about the timer module and in Erlang there is nothing that prevents you from using your own 'timer' module in your application - detecting missing funcyions is not dialyzer's main objective (there are other tools like xref that are supposed to be used for such purposes -- although I am not sure whether even that one detects that bar/0 is a missing function when used in timer:apply_after/4). Kostis From vikrant.patil@REDACTED Sun Mar 29 11:33:41 2009 From: vikrant.patil@REDACTED (Vikrant) Date: Sun, 29 Mar 2009 15:03:41 +0530 Subject: [erlang-questions] how much time required to pass messages. Message-ID: Hi, I have a program which creates N processes. Assume that processes are arranged in a circular fashion. First process pases a token to neighboring process and that process in turn passes it further. This is continued till the token comes back to first process. I can choose to do this process M times (i.e the message is passed around complete circle M times). I have written a function tokenring(N,M) which creates N processes and circulates the message M times. Now consider instances where I chose N =10000, 20000, 30000 respectively with M keeping constant to 1. I counted time required to do this. and stats looks like this. 26> tokenring:tokenring(10000,1). Time required to pass message 10000 times=3.00000 (4.40000) microsecond .ok 27> tokenring:tokenring(20000,1). Time required to pass message 20000 times=3.00000 (4.65000) microsecond .ok 28> tokenring:tokenring(30000,1). Time required to pass message 30000 times=3.33333 (4.63333) microsecond .ok (time in bracket is system time and time outside bracket is user time in microseconds.) This is surprising to me! I expected that time required to pass token along N processes should be proportional to N! because with N increasing, number messages passed increase in proportion to N. But it seems to take same time irrespective of number of processes. But then look at the timings when I vary M keeping N constant. 29> tokenring:tokenring(30000,1). Time required to pass message 30000 times=3.33333 (4.63333) microsecond .ok 30> tokenring:tokenring(30000,2). Time required to pass message 60000 times=7.00000 (8.93333) microsecond .ok 31> tokenring:tokenring(30000,3). Time required to pass message 90000 times=11.0000 (14.6667) microsecond .ok 32> tokenring:tokenring(30000,4). Time required to pass message 120000 times=13.6667 (20.9667) microsecond .ok this seems to be proportional to M ..i.e to number of times message is passes around. This case seems to match with my expectations. can somebody explain me this discrepancy? why this time is proportional to M but not proportional to N? code for above program is as given below %%%------------------------------------------------------------------- %%% File : tokenring.erl %%% Author : vikrant %%% Description : this module implements token ring protocol for benchmarking %%% %%% Created : 28 Mar 2009 by vikrant %%%------------------------------------------------------------------- -module(tokenring). -export([tokenring/2]). tokenring(N,M)-> [Head | Tail] = for(1,N, fun()-> spawn(fun()-> wait() end) end), TransposeByOne = lists:append(Tail,[Head]), Pairs = lists:zip([Head | Tail], TransposeByOne), lists:map(fun({To, Arg})-> To! {token, Arg, M*N} end, Pairs), statistics(runtime), statistics(wall_clock), Head ! {token, self(), 0}, receive done -> void end, {_,Time1} = statistics(runtime), {_,Time2} = statistics(wall_clock), U1 = Time1*1000/N, U2 = Time2*1000/N, lists:foreach(fun(Pid)-> Pid!die end, [Head | Tail]), io:format("Time required to pass message ~p times=~p (~p) microsecond~n.", [M*N,U1,U2]). loop(To, MaxCount) -> receive {token,Parent,Count} when Count < MaxCount -> %io:format("Token passing from ~p to ~p~n",[self(), To]), To! {token, Parent, Count+1}, loop(To, MaxCount); {token,Parent, MaxCount} -> Parent ! done, loop(To, MaxCount); die -> void end. wait() -> receive {token, To, MaxCount} -> loop(To, MaxCount) end. for(N,N,F) -> [F()]; for(I,N,F) -> [F() | for(I+1,N,F)]. Thanks and Regards, (Vikrant) -------------- next part -------------- An HTML attachment was scrubbed... URL: From rvirding@REDACTED Sun Mar 29 11:37:19 2009 From: rvirding@REDACTED (Robert Virding) Date: Sun, 29 Mar 2009 11:37:19 +0200 Subject: [erlang-questions] Leex bug fixed Message-ID: <3dbc6d1c0903290237jae81f5l9fc09bb7cfb1ec8c@mail.gmail.com> A small, but critical, bug in leex has been fixed. Get the patch from github: http://github.com/rvirding/leex/tree Sorry, for this. The only extenuating circumstance for this is that no one has found it earlier. Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: From ahmed.diaa@REDACTED Sun Mar 29 11:39:47 2009 From: ahmed.diaa@REDACTED (Ahmed Diaa) Date: Sun, 29 Mar 2009 11:39:47 +0200 Subject: [erlang-questions] Dialyzer and apply In-Reply-To: <49CF3832.70703@cs.ntua.gr> References: <49CF3832.70703@cs.ntua.gr> Message-ID: Hello Kostis , Thanks for your reply , - Well ,as the dialyzer use guide says, it "identifies software discrepancies" and it's already discovering calls to missing functions , that's why I expected that behaviour - I used apply in the example just to include that case , but I agree that it's rarely used when M,F,A are known. - I understand your concern about hard-coded information - Thanks for pointing out xref , it did discover the case of erlang:apply/3 , but didn't discover the timer:apply_after/4 one. -----Original Message----- From: Kostis Sagonas [mailto:kostis@REDACTED] Sent: Sunday, March 29, 2009 10:58 AM To: erlang-questions@REDACTED Cc: Ahmed Diaa Subject: Re: [erlang-questions] Dialyzer and apply Ahmed Diaa wrote: > Hello there , > I started using Dialyzer lately , and found it really usefull. But , I > had a case that I expected dialyzer to discover but it didn't. > > The case occurs when using erlang:apply/3 or timer:apply_after/4 > Here's the example > > -module(dtest). > > -export([foo/0]). > > foo()-> > timer:apply_after(100,?MODULE, bar, [ ]), > erlang:apply(?MODULE,bar,[ ]). > > When running the dialyzer for this module , it didn't discover the > call to a missing function. > > Wouldn't it be nice if dialyzer could discover such cases? Yes, it would be but: - there is very little reason to use erlang:apply/3 when the module name, function name and the number of arguments are known (like in your example, where you should really use ?MODULE:bar() instead) - detecting the timer:apply_after/4 missing functions would mean that dialyzer has hard-coded information about the timer module and in Erlang there is nothing that prevents you from using your own 'timer' module in your application - detecting missing funcyions is not dialyzer's main objective (there are other tools like xref that are supposed to be used for such purposes -- although I am not sure whether even that one detects that bar/0 is a missing function when used in timer:apply_after/4). Kostis From ralf.wolter@REDACTED Sun Mar 29 12:00:47 2009 From: ralf.wolter@REDACTED (Ralf Wolter) Date: Sun, 29 Mar 2009 12:00:47 +0200 Subject: [erlang-questions] Restrictions on records Message-ID: <32fc84230903290300m3eab8f79le5489eb7c77050e8@mail.gmail.com> Hello, While working with records I ran into some unexpected restrictions. I'm still learning Erlang so unexpected errors are to be expected, but this time I really expected it to work. I tried to access the return of a function as a record but Erlang responded with a syntax error before '#'. The test code: -module(test). -export([ % do/3 do1/3, do2/3]). -record(rec, {last_change, name=bla, value=0.0}). update(Rec) -> Rec#rec{last_change=erlang:universaltime()}. %do(Rec, Name, Setting) -> update(Rec)#rec{name=Name, value=value(Setting)}. do1(Rec, Name, Setting) -> R = update(Rec), R#rec{name=Name, value=value(Setting)}. do2(Rec, Name, Setting) -> update(Rec#rec{name=Name, value=value(Setting)}). value(high) -> 0.9; value(moderate) -> 0.5; value(low) -> 0.01. The do function doesn't seem to work, while do1 and do2 have no problem. I'm aware records are removed at compile time, but I guess I expected it to work by replacing "update(Rec)#rec{name=Name, value=value(Setting)}" with something like "{rec, C, N, V} = update(Rec), {rec, C, Name, value(Setting)}". Obviously it does something else. This sort of leads me to the question of how records actually work so I could make better predictions on what is possible and what isn't. How are they translated in to valid code by the compiler? Ralf -------------- next part -------------- An HTML attachment was scrubbed... URL: From carsten@REDACTED Sun Mar 29 12:48:32 2009 From: carsten@REDACTED (Carsten Schultz) Date: Sun, 29 Mar 2009 12:48:32 +0200 Subject: [erlang-questions] how much time required to pass messages. In-Reply-To: References: Message-ID: <49CF5200.1080702@codimi.de> Vikrant schrieb: > > 26> tokenring:tokenring(10000,1). > Time required to pass message 10000 times=3.00000 (4.40000) microsecond > .ok > 27> tokenring:tokenring(20000,1). > Time required to pass message 20000 times=3.00000 (4.65000) microsecond > .ok > 28> tokenring:tokenring(30000,1). > Time required to pass message 30000 times=3.33333 (4.63333) microsecond > .ok > > (time in bracket is system time and time outside bracket is user time in > microseconds.) > > This is surprising to me! I expected that time required to pass token > along N processes should be proportional to N! My guess here is that the resultion of the timer is 1/3. So your results are 9, 9, 10. Considering that these are rounded and that your function will have a constant term, these numbers are just to small to allow you to deduce much about your runtime function. Change the second parameter into, say, 1000000 in all cases and see what happens. -- 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 rapsey@REDACTED Sun Mar 29 12:53:43 2009 From: rapsey@REDACTED (Rapsey) Date: Sun, 29 Mar 2009 12:53:43 +0200 Subject: [erlang-questions] Restrictions on records In-Reply-To: <32fc84230903290300m3eab8f79le5489eb7c77050e8@mail.gmail.com> References: <32fc84230903290300m3eab8f79le5489eb7c77050e8@mail.gmail.com> Message-ID: <97619b170903290353j14eef1d1u77196dc0588607c9@mail.gmail.com> Try: do(Rec, Name, Setting) -> (update(Rec))#rec{name=Name, value=value(Setting)}. Sergej 2009/3/29 Ralf Wolter > Hello, > > While working with records I ran into some unexpected restrictions. I'm > still learning Erlang so unexpected errors are to be expected, but this time > I really expected it to work. I tried to access the return of a function as > a record but Erlang responded with a syntax error before '#'. > > The test code: > > -module(test). > -export([ > % do/3 > do1/3, > do2/3]). > > -record(rec, {last_change, name=bla, value=0.0}). > > update(Rec) -> Rec#rec{last_change=erlang:universaltime()}. > > %do(Rec, Name, Setting) -> update(Rec)#rec{name=Name, > value=value(Setting)}. > do1(Rec, Name, Setting) -> R = update(Rec), R#rec{name=Name, > value=value(Setting)}. > do2(Rec, Name, Setting) -> update(Rec#rec{name=Name, > value=value(Setting)}). > > value(high) -> 0.9; > value(moderate) -> 0.5; > value(low) -> 0.01. > > The do function doesn't seem to work, while do1 and do2 have no problem. > I'm aware records are removed at compile time, but I guess I expected it to > work by replacing "update(Rec)#rec{name=Name, value=value(Setting)}" with > something like "{rec, C, N, V} = update(Rec), {rec, C, Name, > value(Setting)}". Obviously it does something else. > > This sort of leads me to the question of how records actually work so I > could make better predictions on what is possible and what isn't. How are > they translated in to valid code by the compiler? > > Ralf > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From zajdamichal@REDACTED Sun Mar 29 13:56:35 2009 From: zajdamichal@REDACTED (Michal Zajda) Date: Sun, 29 Mar 2009 13:56:35 +0200 Subject: [erlang-questions] Restrictions on records In-Reply-To: <32fc84230903290300m3eab8f79le5489eb7c77050e8@mail.gmail.com> References: <32fc84230903290300m3eab8f79le5489eb7c77050e8@mail.gmail.com> Message-ID: <3fd73c480903290456i45ed0f7fn18e3d44e143cbc0f@mail.gmail.com> try the following code: -module(l). -export([ start/0, do/3, do1/3, do2/3]). -record(rec, {last_change, name=bla, value=0.0}). update(Rec) -> Rec#rec{last_change=erlang:universaltime()}. start() -> X = #rec{}, do(X,"xx",high). do(Rec, Name, Setting) -> (update(Rec))#rec{name=Name, value=value(Setting)}. do1(Rec, Name, Setting) -> R = update(Rec), R#rec{name=Name, value=value(Setting)}. do2(Rec, Name, Setting) -> update(Rec#rec{name=Name, value=value(Setting)}). value(high) -> 0.9; value(moderate) -> 0.5; value(low) -> 0.01. 2009/3/29 Ralf Wolter > Hello, > > While working with records I ran into some unexpected restrictions. I'm > still learning Erlang so unexpected errors are to be expected, but this time > I really expected it to work. I tried to access the return of a function as > a record but Erlang responded with a syntax error before '#'. > > The test code: > > -module(test). > -export([ > % do/3 > do1/3, > do2/3]). > > -record(rec, {last_change, name=bla, value=0.0}). > > update(Rec) -> Rec#rec{last_change=erlang:universaltime()}. > > %do(Rec, Name, Setting) -> update(Rec)#rec{name=Name, > value=value(Setting)}. > do1(Rec, Name, Setting) -> R = update(Rec), R#rec{name=Name, > value=value(Setting)}. > do2(Rec, Name, Setting) -> update(Rec#rec{name=Name, > value=value(Setting)}). > > value(high) -> 0.9; > value(moderate) -> 0.5; > value(low) -> 0.01. > > The do function doesn't seem to work, while do1 and do2 have no problem. > I'm aware records are removed at compile time, but I guess I expected it to > work by replacing "update(Rec)#rec{name=Name, value=value(Setting)}" with > something like "{rec, C, N, V} = update(Rec), {rec, C, Name, > value(Setting)}". Obviously it does something else. > > This sort of leads me to the question of how records actually work so I > could make better predictions on what is possible and what isn't. How are > they translated in to valid code by the compiler? > > Ralf > > _______________________________________________ > 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 Mar 29 16:29:32 2009 From: exta7@REDACTED (Zvi) Date: Sun, 29 Mar 2009 07:29:32 -0700 (PDT) Subject: [erlang-questions] EEP7 FFI patch for R11B-5 Message-ID: <22768184.post@talk.nabble.com> Hi, I trying to build R11B-5 with EEP 7 ffi patch from http://muvara.org/crs4/erlang/ffi/ I applied this patch to otp_src_R11B-5 and build erlang on coLinux (UBUNTU 7.x) using these commands: wget http://www.erlang.org/download/otp_src_R11B-5.tar.gz tar -xzf otp_src_R11B-5.tar.gz cd otp_src_R11B-5 wget http://muvara.org/crs4/erlang/ffi/ffi.diff patch -p1 < ffi.diff apt-get install autoconf libffi4-dev ./otp_build autoconf ./configure make sudo make install When testing ffi from the BEAM shell: 1> ffi:sizeof(uint). 4 2> ffi:max(uint). 4294967295 3>erl_ddll:load_library("/usr/lib/libc.so", mylib, [{preload, [{malloc, {void, pointer}},{free, {void, nonnull}}]}]). {error,{open_error,-13}} but ffi still doesn't work. Do you know if ffi supposed to work on coLinux ? Any ideas? Anybody was able to build and test this? Thanks in Advance, Zvi -- View this message in context: http://www.nabble.com/EEP7-FFI-patch-for-R11B-5-tp22768184p22768184.html Sent from the Erlang Questions mailing list archive at Nabble.com. From matthew@REDACTED Sun Mar 29 19:41:42 2009 From: matthew@REDACTED (Matthew Dempsky) Date: Sun, 29 Mar 2009 10:41:42 -0700 Subject: [erlang-questions] Update on sharing constant data locally by reference rather than by copy? In-Reply-To: <6672d0160903280021s4814ef48yc2e5b019c500456f@mail.gmail.com> References: <49C14D07.9000808@online.fr> <49C21AD0.2050600@it.uu.se> <6672d0160903280021s4814ef48yc2e5b019c500456f@mail.gmail.com> Message-ID: On Sat, Mar 28, 2009 at 12:21 AM, Bjorn Gustavsson wrote: > On Sat, Mar 28, 2009 at 4:08 AM, Matthew Dempsky wrote: >> You're talking about current Erlang releases, right? ?How does that >> work with module reloading? ?E.g., if foo:bar/0 returns a constant >> complex data structure and the result is not copied into the calling >> process's private heap, what happens when a module is purged while a >> process is still holding onto a reference to the data structure? > > The data will be copied to the heap of each process that has a reference > to the data before the module is purged. Awesome, I just experimentally confirmed this is the resulting behavior too. Thanks! From kode@REDACTED Mon Mar 30 00:47:59 2009 From: kode@REDACTED (Bhasker Kode) Date: Mon, 30 Mar 2009 04:17:59 +0530 Subject: [erlang-questions] startup experiences from R12, our highlights of R13A Message-ID: <3935b63b0903291547n19730b79kdb7949b4d722022f@mail.gmail.com> oye! I thought i'd let you all know about the progress of our startup based in India ( first got introduced to erlang late '07 ). We've just launched a developer blog, and our first post deals with new R13A release and looking back at a 1 1/2 years of R11/12, and look to post regularly on all things erlang & the LYME stack. it includes notes,comments on : - smp , concurrent list maps with some comparison tests - unicode support - disk log/ error logger - mnesia - etc http://developers.hover.in/blog/2009/somethings-to-rejoice-about/ ~ Cheers, Bhasker V Kode , aka bosky101 Co-Founder / CTO - hover.in http://developers.hover.in From bbmaj7@REDACTED Mon Mar 30 00:18:28 2009 From: bbmaj7@REDACTED (Richard Andrews) Date: Sun, 29 Mar 2009 15:18:28 -0700 (PDT) Subject: [erlang-questions] Can't start TV In-Reply-To: <9a77767b0903282227t4321745aib2c03a7e4aff29b1@mail.gmail.com> References: <9a77767b0903282227t4321745aib2c03a7e4aff29b1@mail.gmail.com> Message-ID: <605506.98939.qm@web65504.mail.ac4.yahoo.com> Make sure you have tcl/tk installed. ________________________________ After I run the command 'tv:start().', no GUI windows pop-out. Enjoy a better web experience. Upgrade to the new Internet Explorer 8 optimised for Yahoo!7. Get it now. -------------- next part -------------- An HTML attachment was scrubbed... URL: From monch1962@REDACTED Mon Mar 30 02:25:32 2009 From: monch1962@REDACTED (David Mitchell) Date: Mon, 30 Mar 2009 11:25:32 +1100 Subject: [erlang-questions] Standard modern salary for an Erlang programmer? In-Reply-To: <49CD7929.1050408@ghostgun.com> References: <2a67d3ff0903240722x14203c54j693bb1d12fd92953@mail.gmail.com> <4ecde87b0903260804p6272c65ft2a62729789be790f@mail.gmail.com> <87ab77crn1.fsf@sterlett.hq.kred> <49CD7929.1050408@ghostgun.com> Message-ID: You need to understand that this is a role that (a) not many people will be qualified to fill, (b) most who could fill it will have been coding for 20+ years, (c) it's a contract rate, so no holiday pay, paid sick leave, health insurance, etc. - you have to foot these out of your own pocket, (d) it probably involves relocating to Canberra, which is not something to take lightly, (e) a lot of those who would be qualified technically would not be interested in it, and (f) it's almost certainly going to primarily maintaining code written many years ago, by people who either left or retired years ago. I'm sure the last horse-and-buggy manufacturer enjoyed a long lucrative career maintaining stuff made by his former competitors. He would've been the last one left with a skill that hadn't quite died, and therefore had a monopoly position servicing demand from the remaining few who hadn't yet switched to cars. Hopefully he had enough pride in his work and the near-complete lack of ambition that would've been required to make it enjoyable; I know I couldn't have done it. I'm so old that I have not-particularly-fond memories of doing support coding in COBOL back in the early 80s. It would take considerably more than this rate to have me interested in reliving those times, in Canberra of all places. Dave M. 2009/3/28 jm > Knowing dead languages seems to pay well. At least in computing. > > Here's a recent ad for a Cobol job in ACT, Australia. > > Telon Coolgen Cobol Specialist > Salary: $180,000 > 12 month contract > > > http://www.seek.com.au/users/apply/index.ascx?Sequence=94&PageNumber=1&JobID=15166601 > > > Jeff. > > > mats cronqvist wrote: > > > > Although I agree with the sentiment here, it seems you're calling > > Java "a new language that's gaining popularity." Surely Java is > > the Cobol of the '00s? > > > > Maybe it's time to put FORTRAN77 back on the CV. > > > > 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From yogishb@REDACTED Mon Mar 30 01:49:31 2009 From: yogishb@REDACTED (Yogish Baliga) Date: Sun, 29 Mar 2009 16:49:31 -0700 (PDT) Subject: [erlang-questions] Sharing data by reference Message-ID: <614052.92568.qm@web31804.mail.mud.yahoo.com> I read in this post http://www.erlang.org/pipermail/erlang-questions/2009-March/042503.html that compile time constants are in constant pool and are used by reference in each process. This works well for compile time constants. What about the the run-time constant, for example configuration read from the file. This configuration remains constant through-out the life time of the VM. Is it possible to put that in the constant pool and have a reference to it in each process instead of copying around? Thanx, -- baliga "The quality of programmers is a decreasing function of the density of GOTO statements in the programs they produce." - Edsger W. Dijkstra http://dudefrommangalore.blogspot.com From ok@REDACTED Mon Mar 30 03:14:17 2009 From: ok@REDACTED (Richard O'Keefe) Date: Mon, 30 Mar 2009 14:14:17 +1300 Subject: [erlang-questions] make_ref bug or feature? In-Reply-To: <9b08084c0903270519q4913e3a7ga0abd6c990d8fe00@mail.gmail.com> References: <9b08084c0903270443m1cff61f3lb06aad51cfe5bf11@mail.gmail.com> <49CCBF35.4030000@gmail.com> <9b08084c0903270519q4913e3a7ga0abd6c990d8fe00@mail.gmail.com> Message-ID: The external term format document says that the format for a reference is 1 byte 114 NEW_REFERENCE_EXT 2 bytes Len Size of ID in words N bytes Node the Node on which the reference was created, as an encoded atom 1 byte Creation a 2-bit node generation number so that a node that crashes and restarts looks different; I don't understand why 2 bits was though to be enough N'bytes ID uninterpreted bytes of data; N' = 4*Len, and we are told that it should be no more than 12, so N' = 4, 8, or 12. In the first word, there are only 18 significant bits, so presumably 82 = 18 + 32 + 32 bits are _available_. So that should be (18 to 82 bits worth) WITHIN a node; it shouldn't be possible for a reference created on one node to match a reference created on another even if they have the same 82-bit ID. However, if two Erlang nodes have the same (presumably short) name, then there could be trouble. From monch1962@REDACTED Mon Mar 30 05:19:28 2009 From: monch1962@REDACTED (David Mitchell) Date: Mon, 30 Mar 2009 14:19:28 +1100 Subject: [erlang-questions] Why is it necessary to "double-escape" [ characters in regular expressions? Message-ID: Hello group, Running 5.6.5 under Windows... I've got a bunch of code that's "almost but not quite syntactically correct" XML, and I'm trying to convert it to valid XML. Part of this process involves removing some invalid CDATA tags. My code fragment: re:replace("abc123", " From jeffm@REDACTED Mon Mar 30 05:46:30 2009 From: jeffm@REDACTED (jm) Date: Mon, 30 Mar 2009 14:46:30 +1100 Subject: [erlang-questions] leex and yecc spotting double newline In-Reply-To: <3dbc6d1c0903261003t79c712e1wba2937283b6ae3c9@mail.gmail.com> References: <49C72836.4020402@ghostgun.com> <3dbc6d1c0903261003t79c712e1wba2937283b6ae3c9@mail.gmail.com> Message-ID: <49D04096.9000205@ghostgun.com> Thanks for taking the time to look at this. This is more of a learning exercise for me at the moment for some of the things I wish to do further down the track. Though related to my current project of a postfix policy daemon. The current method of parsing requests is a hand written parser which works for this task, but my ability to write such parsers doesn't scale as well as leex and yecc. The postfix policy daemon one of those projects I've tried to start about three or four times previously but never seem to finish. Robert Virding wrote: > Hello again, > > I have done a quick test and the suggestion I made seems to work. It > does however demand that even the final request end with a double > newline. I have some comments and questions: > > - Do you really want to keep the whitespace tokens in your output? (in > words) I'm not sure how significant the whitespace is. I've only ever seen it used in the replies from the policy server, eg "action=REJECT Don't spam me buddy" > - If you want to get all the tokens until the end of file you can do > io:request(InFile, {get_until, prompt, > postfix_policy_lexer,tokens, [1]}) see comments below. > - Yecc is very picky and demands that you give it all the tokens it > needs and only the tokens it needs, so you would probably have to add > a rule > > requests -> request : ['$1']. > requests -> requests request : '$1' ++ ['$2']. Another question to add to the list: How do I get the line numbers to increment or do I have to track these manually? Doing at the erl prompt ('>') > {ok, ExRequestBin} = file:read_file("src/postfix_policy_example.txt"). > ExRequest = binary_to_list(ExRequestBin). > {ok, Toks, _} = postfix_policy_lexer:string(ExRequest). > postfix_policy_parser:parse(ExRequest). ** exception error: bad argument in function postfix_policy_parser:yeccpars1/5 gives the above error. Toks seems to be a valid list of tokens with the expected values. How do I work out what is causing this error? calling play:parse("src/postfix_policy_example.txt"). gives Token: {word,1,"recipient"} EndLine: 1 Token: {eq,1,"="} EndLine: 1 ** exception exit: scanning_error in function play:loop/2 in call from play:parse/1 yet the previous attempt at the erl prompt got further. Changing token to tokens as suggested above gives, ... {eq,24,"="}, {nl,24,"\n"}, {nl,25,"\n"}] EndLine: 26 ** exception error: bad argument in function postfix_policy_parser:yeccpars1/5 so it gets further, but gives the same error as the first example. > Hope this helps. Get back to me if it doesn't or you have more questions. Oh, many questions :-). I've attached the source files to avoid a case of "chinese wispers". Jeff. -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: postfix_policy_lexer.xrl URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: postfix_policy_parser.yrl URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: play.erl URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: postfix_policy_example.txt URL: From nm@REDACTED Mon Mar 30 08:57:40 2009 From: nm@REDACTED (Gaspar Chilingarov) Date: Mon, 30 Mar 2009 11:57:40 +0500 Subject: [erlang-questions] Why is it necessary to "double-escape" [ characters in regular expressions? In-Reply-To: References: Message-ID: <49D06D64.20302@web.am> Hello! Let's try on the simple example 2> "\q". "q" 3> "\\q". "\\q" But do really "\\q" means 3 symbols or 2 ? 6> lists:map(fun(X) -> erlang:display(X) end, "\\q"). 92 113 [true,true] Well. So it's in your regular expression you put exactly 2 characters - \ and [ which is required by a regexp to interpret [ as a character and not as class start symbol. So it works quite predictable ;) /Gaspar -- Gaspar Chilingarov tel +37493 419763 (mobile - leave voice mail message) icq 63174784 skype://gasparch e mailto:nm@REDACTED mailto:gasparch@REDACTED w http://gasparchilingarov.com/ From freza@REDACTED Mon Mar 30 09:21:18 2009 From: freza@REDACTED (Jachym Holecek) Date: Mon, 30 Mar 2009 09:21:18 +0200 Subject: [erlang-questions] Why is it necessary to "double-escape" [ characters in regular expressions? In-Reply-To: References: Message-ID: <20090330072118.GA970@hanele> # David Mitchell 2009-03-30: > However, "double-escaping" the [ characters (by adding a second \ prior to > the [ character) does exactly what I want: > re:replace("abc123 list}]) > returns "abc123 < abc123", which is the result I'm after. Backslash is an escape character within string syntax, like in C. So if you want your literal string to contain a backslash (you do, in order to remove the special meaning '[' has in REs), you need to write "\\" as you discovered. See section 2.14 of Erlang Reference Manual for more details. HTH, -- Jachym From alceste@REDACTED Mon Mar 30 12:41:00 2009 From: alceste@REDACTED (Alceste Scalas) Date: Mon, 30 Mar 2009 12:41:00 +0200 Subject: [erlang-questions] EEP7 FFI patch for R11B-5 In-Reply-To: <22768184.post@talk.nabble.com> References: <22768184.post@talk.nabble.com> Message-ID: <20090330124100.eyq6091ascwo80cg@webmail.crs4.it> Quoting Zvi : > 3> erl_ddll:load_library("/usr/lib/libc.so", mylib, [{preload, > [{malloc, {void, pointer}},{free, {void, nonnull}}]}]). > {error,{open_error,-13}} There are three problems here. First of all, erl_ddll:load_library/3 expects a path as first argument, and a filename (excluding the .so extension) as second argument (just like erl_ddll:load/2). You should, thus, call something like this: erl_ddll:load_library("/usr/lib", libc, [{preload, [{malloc, {void, pointer}},{free, {void, nonnull}}]}]). Another problem is that /usr/lib/libc.so is not a regular .so file as one might expect. Here are its contents on my laptop (Ubuntu 8.10): [alceste@REDACTED ~]$ cat /usr/lib/libc.so /* GNU ld script Use the shared library, but some functions are only in the static library, so try that secondarily. */ OUTPUT_FORMAT(elf32-i386) GROUP ( /lib/libc.so.6 /usr/lib/libc_nonshared.a AS_NEEDED ( /lib/ld-linux.so.2 ) ) The real file you should open is /lib/libc.so.6. And here comes the final problem: erl_ddll:load_library/3, just like other erl_ddll functions, expects the file to end with .so. And since /lib/libc.so.6 does not respect this requirement, you should create a symlink with the proper name, for example: ln -s /lib/libc.so.6 /tmp/libc.so After that, you can simply execute: erl_ddll:load_library("/tmp", libc, [{preload, [{malloc, {void, pointer}},{free, {void, nonnull}}]}]). And it should work as expected. Note, however, that all .so files are (usually) automatically linked to libc: you can open any regular .so file and just use it to call libc functions through the FFI (thus avoiding the symlink cruft above). Regards, -- Alceste Scalas ---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging Program. From exta7@REDACTED Mon Mar 30 12:21:13 2009 From: exta7@REDACTED (Zvi) Date: Mon, 30 Mar 2009 03:21:13 -0700 (PDT) Subject: [erlang-questions] Why is it necessary to "double-escape" [ characters in regular expressions? In-Reply-To: <49D06D64.20302@web.am> References: <49D06D64.20302@web.am> Message-ID: <22780162.post@talk.nabble.com> Why type sp many characters, when in doubt about escaping rules try something like this: 1> [[C]||C<-"\\q"]. ["\\","q"] 2> [{C}||C<-"\\q"]. [{92},{113}] Zvi Gaspar Chilingarov wrote: > > 6> lists:map(fun(X) -> erlang:display(X) end, "\\q"). > 92 > 113 > [true,true] > -- View this message in context: http://www.nabble.com/Re%3A-Why-is-it-necessary-to-%22double-escape%22--%09characters-in-regular-expressions--tp22777475p22780162.html Sent from the Erlang Questions mailing list archive at Nabble.com. From exta7@REDACTED Mon Mar 30 12:18:46 2009 From: exta7@REDACTED (Zvi) Date: Mon, 30 Mar 2009 03:18:46 -0700 (PDT) Subject: [erlang-questions] Why is it necessary to "double-escape" [ characters in regular expressions? In-Reply-To: <49D06D64.20302@web.am> References: <49D06D64.20302@web.am> Message-ID: <22780122.post@talk.nabble.com> why type so many characters: [{C}||C<-"\\q"]. output: [{92},{113}] Zvi Gaspar Chilingarov wrote: > > 6> lists:map(fun(X) -> erlang:display(X) end, "\\q"). > 92 > 113 > [true,true] > -- View this message in context: http://www.nabble.com/Re%3A-Why-is-it-necessary-to-%22double-escape%22--%09characters-in-regular-expressions--tp22777475p22780122.html Sent from the Erlang Questions mailing list archive at Nabble.com. From exta7@REDACTED Mon Mar 30 12:53:57 2009 From: exta7@REDACTED (Zvi) Date: Mon, 30 Mar 2009 03:53:57 -0700 (PDT) Subject: [erlang-questions] Why is it necessary to "double-escape" [ characters in regular expressions? Message-ID: <22780162.post@talk.nabble.com> Why type so many characters? when in doubt about escaping rules, try something like this: 1> [[C]||C<-"\\q"]. ["\\","q"] 2> [{C}||C<-"\\q"]. [{92},{113}] Zvi Gaspar Chilingarov wrote: > > 6> lists:map(fun(X) -> erlang:display(X) end, "\\q"). > 92 > 113 > [true,true] > -- View this message in context: http://www.nabble.com/Re%3A-Why-is-it-necessary-to-%22double-escape%22--%09characters-in-regular-expressions--tp22777475p22780162.html Sent from the Erlang Questions mailing list archive at Nabble.com. From bbmaj7@REDACTED Mon Mar 30 12:01:57 2009 From: bbmaj7@REDACTED (Richard Andrews) Date: Mon, 30 Mar 2009 03:01:57 -0700 (PDT) Subject: [erlang-questions] Why is it necessary to "double-escape" [ characters in regular expressions? In-Reply-To: References: Message-ID: <837618.69848.qm@web65504.mail.ac4.yahoo.com> IIRC the way to escape [ in regular expressions is [[] not \[. Similarly []] not \]. Never tried with erlang re application though. ________________________________ From: David Mitchell To: erlang-questions Questions Sent: Monday, 30 March, 2009 2:19:28 PM Subject: [erlang-questions] Why is it necessary to "double-escape" [ characters in regular expressions? Hello group, Running 5.6.5 under Windows... I've got a bunch of code that's "almost but not quite syntactically correct" XML, and I'm trying to convert it to valid XML. Part of this process involves removing some invalid CDATA tags. My code fragment: re:replace("abc123", " From bbmaj7@REDACTED Mon Mar 30 11:55:20 2009 From: bbmaj7@REDACTED (Richard Andrews) Date: Mon, 30 Mar 2009 02:55:20 -0700 (PDT) Subject: [erlang-questions] Sharing data by reference In-Reply-To: <614052.92568.qm@web31804.mail.mud.yahoo.com> References: <614052.92568.qm@web31804.mail.mud.yahoo.com> Message-ID: <583694.43021.qm@web65511.mail.ac4.yahoo.com> > I read in this post > > http://www.erlang.org/pipermail/erlang-questions/2009-March/042503.html > > that compile time constants are in constant pool and are used by reference in > each process. This works well for compile time constants. What about the the > run-time constant, for example configuration read from the file. This > configuration remains constant through-out the life time of the VM. Is it > possible to put that in the constant pool and have a reference to it in each > process instead of copying around? I believe binaries are treated this way. If you keep references to the binary (read from file) then all of the state objects with a "copy" of the binary refer to the same immutable data. One copy. Enjoy a better web experience. Upgrade to the new Internet Explorer 8 optimised for Yahoo!7. Get it now. From ralf.wolter@REDACTED Mon Mar 30 10:53:38 2009 From: ralf.wolter@REDACTED (Ralf Wolter) Date: Mon, 30 Mar 2009 10:53:38 +0200 Subject: [erlang-questions] Restrictions on records In-Reply-To: <3fd73c480903290456i45ed0f7fn18e3d44e143cbc0f@mail.gmail.com> References: <32fc84230903290300m3eab8f79le5489eb7c77050e8@mail.gmail.com> <3fd73c480903290456i45ed0f7fn18e3d44e143cbc0f@mail.gmail.com> Message-ID: <32fc84230903300153r20a7c8c2w1a9d65baeb6caba2@mail.gmail.com> Thank you, That works. It didn?t occur to me that the record structure might have a higher priority than a function call. Ralf On Sun, Mar 29, 2009 at 1:56 PM, Michal Zajda wrote: > try the following code: > > -module(l). > -export([ > start/0, > do/3, > do1/3, > do2/3]). > > -record(rec, {last_change, name=bla, value=0.0}). > > update(Rec) -> Rec#rec{last_change=erlang:universaltime()}. > > start() -> > X = #rec{}, > do(X,"xx",high). > > > do(Rec, Name, Setting) -> (update(Rec))#rec{name=Name, > value=value(Setting)}. > do1(Rec, Name, Setting) -> R = update(Rec), R#rec{name=Name, > value=value(Setting)}. > do2(Rec, Name, Setting) -> update(Rec#rec{name=Name, > value=value(Setting)}). > > value(high) -> 0.9; > value(moderate) -> 0.5; > value(low) -> 0.01. > > > 2009/3/29 Ralf Wolter > >> Hello, >> >> >> While working with records I ran into some unexpected restrictions. I'm >> still learning Erlang so unexpected errors are to be expected, but this time >> I really expected it to work. I tried to access the return of a function as >> a record but Erlang responded with a syntax error before '#'. >> >> The test code: >> >> -module(test). >> -export([ >> % do/3 >> do1/3, >> do2/3]). >> >> -record(rec, {last_change, name=bla, value=0.0}). >> >> update(Rec) -> Rec#rec{last_change=erlang:universaltime()}. >> >> %do(Rec, Name, Setting) -> update(Rec)#rec{name=Name, >> value=value(Setting)}. >> do1(Rec, Name, Setting) -> R = update(Rec), R#rec{name=Name, >> value=value(Setting)}. >> do2(Rec, Name, Setting) -> update(Rec#rec{name=Name, >> value=value(Setting)}). >> >> value(high) -> 0.9; >> value(moderate) -> 0.5; >> value(low) -> 0.01. >> >> The do function doesn't seem to work, while do1 and do2 have no problem. >> I'm aware records are removed at compile time, but I guess I expected it to >> work by replacing "update(Rec)#rec{name=Name, value=value(Setting)}" with >> something like "{rec, C, N, V} = update(Rec), {rec, C, Name, >> value(Setting)}". Obviously it does something else. >> >> This sort of leads me to the question of how records actually work so I >> could make better predictions on what is possible and what isn't. How are >> they translated in to valid code by the compiler? >> >> Ralf >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From Jouni.Ryno@REDACTED Mon Mar 30 11:46:42 2009 From: Jouni.Ryno@REDACTED (Jouni Ryno) Date: Mon, 30 Mar 2009 12:46:42 +0300 Subject: [erlang-questions] Standard modern salary for an Erlang programmer? In-Reply-To: <31117710.95821238081411376.JavaMail.root@zimbra> References: <31117710.95821238081411376.JavaMail.root@zimbra> Message-ID: <1238406402.23744.38.camel@adic> On Thu, 2009-03-26 at 15:30 +0000, Adam Lindberg wrote: > ----- "Jon Gretar Borgthorsson" wrote: > > Or you can focus on ADA and program the Space Shuttle. > > > > Pick. > > I'd love to get bug reports from space. > No, you don't ... And Shuttle is human! space flight ... I would not like to do medical software either ... But programming for space is indeed fun :) Jouni > Cheers, > Adam > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- Jouni Ryn? mailto://Jouni.Ryno@REDACTED/ http://space.fmi.fi/~ryno/ Finnish Meteorological Institute http://www.fmi.fi/ P.O.BOX 503 Tel (+358)-9-19294656 FIN-00101 Helsinki FAX (+358)-9-19294603 Finland priv-GSM (+358)-50-5302903 "It's just zeros and ones, it cannot be hard" From per@REDACTED Mon Mar 30 14:19:20 2009 From: per@REDACTED (Per Hedeland) Date: Mon, 30 Mar 2009 14:19:20 +0200 (CEST) Subject: [erlang-questions] IPv6 In-Reply-To: <200903271622.n2RGMPQm071931@pluto.hedeland.org> Message-ID: <200903301219.n2UCJKlZ002391@pluto.hedeland.org> Per Hedeland wrote: > >Is there some good reason for gen_tcp/gen_udp not auto-recognizing an >8-tuple as an IPv6 address? And if there isn't, perhaps the trivial patches below could be considered for inclusion? --Per --- otp_src_R13A/lib/kernel/src/gen_tcp.erl.ORIG 2009-03-12 13:19:00.000000000 +0100 +++ otp_src_R13A/lib/kernel/src/gen_tcp.erl 2009-03-27 17:59:12.000000000 +0100 @@ -46,7 +46,7 @@ end. connect1(Address,Port,Opts,Timer) -> - Mod = mod(Opts), + Mod = mod(Opts ++ [{ip, Address}]), case Mod:getaddrs(Address,Timer) of {ok,IPs} -> case Mod:getserv(Port) of @@ -179,13 +179,17 @@ %% Get the tcp_module mod() -> inet_db:tcp_module(). -%% Get the tcp_module, but option tcp_module|inet|inet6 overrides +%% Get the tcp_module, but option tcp_module|inet|inet6|{ip,tuple()} overrides mod([{tcp_module,Mod}|_]) -> Mod; mod([inet|_]) -> inet_tcp; mod([inet6|_]) -> inet6_tcp; +mod([{ip, {_,_,_,_}}|_]) -> + inet_tcp; +mod([{ip, {_,_,_,_,_,_,_,_}}|_]) -> + inet6_tcp; mod([_|Opts]) -> mod(Opts); mod([]) -> --- otp_src_R13A/lib/kernel/src/gen_udp.erl.ORIG 2009-03-12 13:19:00.000000000 +0100 +++ otp_src_R13A/lib/kernel/src/gen_udp.erl 2009-03-27 18:05:02.000000000 +0100 @@ -104,13 +104,17 @@ %% Get the udp_module mod() -> inet_db:udp_module(). -%% Get the udp_module, but option udp_module|inet|inet6 overrides +%% Get the udp_module, but option tcp_module|inet|inet6|{ip,tuple()} overrides mod([{udp_module,Mod}|_]) -> Mod; mod([inet|_]) -> inet_udp; mod([inet6|_]) -> inet6_udp; +mod([{ip, {_,_,_,_}}|_]) -> + inet_udp; +mod([{ip, {_,_,_,_,_,_,_,_}}|_]) -> + inet6_udp; mod([_|Opts]) -> mod(Opts); mod([]) -> Original message---------------------------------------------------- >From: Per Hedeland >To: erlang-questions@REDACTED >Subject: [erlang-questions] IPv6 > >Hi, > >Is there some good reason for gen_tcp/gen_udp not auto-recognizing an >8-tuple as an IPv6 address? gen_tcp:listen/2 and gen_udp:open/2 don't >even fail if you give them one w/o explicit 'inet6' option, but (OS >stack permitting) interprets "the first 4 bytes" as an IPv4 address - >shocking behaviour for an Erlang module! > >Erlang R13A (erts-5.7) [source] [rq:1] [async-threads:0] [hipe] [kernel-poll:false] >Eshell V5.7 (abort with ^G) >1> gen_tcp:listen(1234, [{ip,{1,43981,4660,0,0,0,0,5}}]). >{ok,#Port<0.439>} >2> gen_udp:open(1234, [{ip,{1,43981,4660,0,0,0,0,5}}]). >{ok,#Port<0.449>} > >$ netstat -an | grep 1234 >tcp 0 0 0.1.171.205:1234 0.0.0.0:* LISTEN >udp 0 0 0.1.171.205:1234 0.0.0.0:* > >'inet' may be a reasonable default (though it isn't actually documented >as such as far as I can see), but blindly "applying" it in the face of >obvious evidence to the contrary can't be right. gen_tcp:connect/3 and >gen_udp:send/4 also have "interesting" behaviour: > >4> gen_tcp:connect({1,43981,4660,0,0,0,0,5}, 1234, []). >{error,nxdomain} >5> gen_udp:send(S, {1,43981,4660,0,0,0,0,5}, 1234, <<"hello">>). >{error,nxdomain} > >Yeah, I can imagine that the name server had trouble finding that >"domain"... (no, it didn't actually try a DNS lookup). > >--Per Hedeland >_______________________________________________ >erlang-questions mailing list >erlang-questions@REDACTED >http://www.erlang.org/mailman/listinfo/erlang-questions > From buricchio@REDACTED Mon Mar 30 14:39:58 2009 From: buricchio@REDACTED (Andrey) Date: Mon, 30 Mar 2009 15:39:58 +0300 Subject: [erlang-questions] Leex bug fixed In-Reply-To: <3dbc6d1c0903290237jae81f5l9fc09bb7cfb1ec8c@mail.gmail.com> References: <3dbc6d1c0903290237jae81f5l9fc09bb7cfb1ec8c@mail.gmail.com> Message-ID: <49D0BD9E.5020409@gmail.com> Great work! Thanks for the leex, and keep up the awesome work. Andrew. > A small, but critical, bug in leex has been fixed. Get the patch from > github: > > http://github.com/rvirding/leex/tree > > Sorry, for this. The only extenuating circumstance for this is that no > one has found it earlier. > > Robert > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From tony@REDACTED Mon Mar 30 09:53:22 2009 From: tony@REDACTED (Tony Rogvall) Date: Mon, 30 Mar 2009 09:53:22 +0200 Subject: [erlang-questions] Sharing data by reference In-Reply-To: <614052.92568.qm@web31804.mail.mud.yahoo.com> References: <614052.92568.qm@web31804.mail.mud.yahoo.com> Message-ID: <9E4DE1B6-C5A9-4B1F-BC9C-32900481BE85@rogvall.se> On 30 mar 2009, at 01.49, Yogish Baliga wrote: > > I read in this post > > http://www.erlang.org/pipermail/erlang-questions/2009-March/ > 042503.html > > that compile time constants are in constant pool and are used by > reference in each process. This works well for compile time > constants. What about the the run-time constant, for example > configuration read from the file. This configuration remains > constant through-out the life time of the VM. Is it possible to put > that in the constant pool and have a reference to it in each process > instead of copying around? A couple of years ago I implement a (yet an other) configuration system that generated a module for some of the constants on the fly. At that time the reason was to have a faster access to constants. With the latest development using shared module constants this approach may be even better. Since compilation is a bit slow (compared to accessing the constants) The rate the constants are updated should be slow :-) The idea is basically: - System change it's configuration. - Generate some part of the configuration to a module. - Compile and load that module. If the configuration change is done asynchronously in a live system, some code may require a consistent view of constants in the generated module (The constants are related somehow). Then a access function reference may come in handy, since it will be connected to the module version that it was created with. Example: -module(my_globs). -export([name/0, version/0, value1/0, value2/0]). name() -> "System name". version() -> "1.1". value1() -> 100. value2() -> 200. %-- Assume that value1 MUST be less than value2. Then we MAY have a problem when if this module is reloaded while executing the following code: true = my_globs:value1() < my_globs:value2(). Since the configuration may be reloaded between the calls to my_globs! If we add an access function to my_globs: -module(my_globs). -export([name/0, version/0, value1/0, value2/0]). -export([access/0]). name() -> "System name". version() -> "1.2". value1() -> 50. value2() -> 100. access() -> fun(value1) -> value1(); (value2) -> value2() end. % - We can now use a transaction like test like: Access = my_globs:access(), true = (Access(value1) < Access(value2)) This will work as long the code is not reloaded twice during the evaluation of the 'Access' function. In which case I guess the code would be killed anyway ;-) Hope this may be useful idea. /Tony > > Thanx, > -- baliga > > > "The quality of programmers is a decreasing function of the density > of GOTO statements in the programs they produce." - Edsger W. Dijkstra > > http://dudefrommangalore.blogspot.com > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From sverker@REDACTED Mon Mar 30 14:06:15 2009 From: sverker@REDACTED (Sverker Eriksson) Date: Mon, 30 Mar 2009 14:06:15 +0200 Subject: [erlang-questions] Why is it necessary to "double-escape" [ characters in regular expressions? In-Reply-To: References: Message-ID: <49D0B5B7.7000105@erix.ericsson.se> David Mitchell wrote: > However, I didn't expect that "double escaping" it would be the solution to > my problem. > > From http://erlang.org/doc/man/re.html: Note The Erlang literal syntax for strings give special meaning to the "\" (backslash) character. To literally write a regular expression or a replacement string containing a backslash in your code or in the shell, two backslashes have to be written: "\\". /Sverker, Erlang/OTP Ericsson From dot@REDACTED Mon Mar 30 17:06:49 2009 From: dot@REDACTED (Tony Finch) Date: Mon, 30 Mar 2009 16:06:49 +0100 Subject: [erlang-questions] Why is it necessary to "double-escape" [ characters in regular expressions? In-Reply-To: References: Message-ID: On Mon, 30 Mar 2009, David Mitchell wrote: > > However, "double-escaping" the [ characters (by adding a second \ prior to > the [ character) does exactly what I want: > re:replace("abc123 returns "abc123 < abc123", which is the result I'm after. There are two levels of backslash escaping here, one for string literals and one for regular expressions. The \\ in the string literal becomes \ in the run-time string, which the regex implementation treats as an escape character for the following [. If you only write \[ in the string literal then this becomes [ in the run-time string which the regex implementation treats as the start of a character class specifier, and since there's no closing ] it throws a syntax error. Tony. -- f.anthony.n.finch http://dotat.at/ GERMAN BIGHT HUMBER: SOUTHWEST 5 TO 7. MODERATE OR ROUGH. SQUALLY SHOWERS. MODERATE OR GOOD. From George.Wright@REDACTED Mon Mar 30 20:01:48 2009 From: George.Wright@REDACTED (Wright, George) Date: Mon, 30 Mar 2009 13:01:48 -0500 Subject: [erlang-questions] moving data to/from mnesia Message-ID: <51548D6D5BEB57468163194A8C1A0E980161AF10@MAGPTCPEXC02.na.mag-ias.net> What is the simplest way to migrate data from a database like PostgeSQL or MySQL to Mnesia and vice versa if there is a lot of data (several hundred MBs or more)? -------------- next part -------------- An HTML attachment was scrubbed... URL: From yogishb@REDACTED Mon Mar 30 23:37:36 2009 From: yogishb@REDACTED (Yogish Baliga) Date: Mon, 30 Mar 2009 14:37:36 -0700 (PDT) Subject: [erlang-questions] Sharing data by reference In-Reply-To: <9E4DE1B6-C5A9-4B1F-BC9C-32900481BE85@rogvall.se> References: <614052.92568.qm@web31804.mail.mud.yahoo.com> <9E4DE1B6-C5A9-4B1F-BC9C-32900481BE85@rogvall.se> Message-ID: <24463.2050.qm@web31811.mail.mud.yahoo.com> Thanx a lot.. This worked like a charm.. Performance boost is 50x. Earlier I could get 11k fetches per second, now I can get 550k per second. -- baliga "The quality of programmers is a decreasing function of the density of GOTO statements in the programs they produce." - Edsger W. Dijkstra http://dudefrommangalore.blogspot.com/ ________________________________ From: Tony Rogvall To: Yogish Baliga Cc: erlang-questions@REDACTED Sent: Monday, March 30, 2009 12:53:22 AM Subject: Re: [erlang-questions] Sharing data by reference On 30 mar 2009, at 01.49, Yogish Baliga wrote: > > I read in this post > > http://www.erlang.org/pipermail/erlang-questions/2009-March/042503.html > > that compile time constants are in constant pool and are used by reference in each process. This works well for compile time constants. What about the the run-time constant, for example configuration read from the file. This configuration remains constant through-out the life time of the VM. Is it possible to put that in the constant pool and have a reference to it in each process instead of copying around? A couple of years ago I implement a (yet an other) configuration system that generated a module for some of the constants on the fly. At that time the reason was to have a faster access to constants. With the latest development using shared module constants this approach may be even better. Since compilation is a bit slow (compared to accessing the constants) The rate the constants are updated should be slow :-) The idea is basically: - System change it's configuration. - Generate some part of the configuration to a module. - Compile and load that module. If the configuration change is done asynchronously in a live system, some code may require a consistent view of constants in the generated module (The constants are related somehow). Then a access function reference may come in handy, since it will be connected to the module version that it was created with. Example: -module(my_globs). -export([name/0, version/0, value1/0, value2/0]). name() -> "System name". version() -> "1.1". value1() -> 100. value2() -> 200. %-- Assume that value1 MUST be less than value2. Then we MAY have a problem when if this module is reloaded while executing the following code: true = my_globs:value1() < my_globs:value2(). Since the configuration may be reloaded between the calls to my_globs! If we add an access function to my_globs: -module(my_globs). -export([name/0, version/0, value1/0, value2/0]). -export([access/0]). name() -> "System name". version() -> "1.2". value1() -> 50. value2() -> 100. access() -> fun(value1) -> value1(); (value2) -> value2() end. % - We can now use a transaction like test like: Access = my_globs:access(), true = (Access(value1) < Access(value2)) This will work as long the code is not reloaded twice during the evaluation of the 'Access' function. In which case I guess the code would be killed anyway ;-) Hope this may be useful idea. /Tony > > Thanx, > -- baliga > > > "The quality of programmers is a decreasing function of the density of GOTO statements in the programs they produce." - Edsger W. Dijkstra > > http://dudefrommangalore.blogspot.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 xbmodder@REDACTED Tue Mar 31 02:04:59 2009 From: xbmodder@REDACTED (Sargun Dhillon) Date: Mon, 30 Mar 2009 17:04:59 -0700 Subject: [erlang-questions] Unix domain sockets In-Reply-To: <1c89b3a10903081047me42b394q9ab43093b7847c8@mail.gmail.com> References: <3dbc6d1c0903040223w5a079909j8e8851332521efa3@mail.gmail.com> <8209f740903040518y3b3cc4b1j3b06165f3da3f3c8@mail.gmail.com> <358109.5796.qm@web65508.mail.ac4.yahoo.com> <1c89b3a10903081047me42b394q9ab43093b7847c8@mail.gmail.com> Message-ID: <7c9d57ea0903301704h339c0830x82e14b9316288ea4@mail.gmail.com> Apparently this doesn't work for character or block devices, see here: [running beam as root] 1> FOut = file:open("/dev/net/tun", [read, write]). {error,eisdir} 2> FOut1 = file:open("/dev/net/tun", [read, write, raw]). {error,eisdir} 3> FOut3 = file:open("/dev/sda", [read, write, raw]). {error,eisdir} 4> FOut3 = file:open("/dev/sda", [read, write]). {error,eisdir} lucifer ~ # ls -l /dev/net/tun crw-rw-rw- 1 root root 10, 200 Mar 30 16:51 /dev/net/tun lucifer ~ # ls -l /dev/sda brw-r----- 1 root disk 8, 0 Mar 30 09:27 /dev/sda Any ideas on how to read this? Do I need to break out a port driver? 2009/3/8 Antoine Koener : > And what about the support for NamedPipes on windows ? > Anyone with experience ? > On Fri, Mar 6, 2009 at 3:24 AM, Richard Andrews wrote: >> >> IIRC there was a UNIX socket project in jungerl too. >> >> >> >> >> > There's an example driver for unix domain sockets under >> > $OTP_ROOT/lib/kernel/examples/uds_dist/ >> > >> > (It's still there in R13A-0, BTW.) >> > >> > It used to be documented in the Interoperability Tutorial, but >> > I think they've switched to a different example now. >> >> >> ? ? ?Stay connected to the people that matter most with a smarter inbox. >> Take a look http://au.docs.yahoo.com/mail/smarterinbox >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions > > > > -- > > http://easyerl.blogspot.com/ > http://www.open-tools.org/ > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From erlang-questions_efine@REDACTED Tue Mar 31 02:20:54 2009 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Mon, 30 Mar 2009 20:20:54 -0400 Subject: [erlang-questions] gen_server call "failure" In-Reply-To: <84fb38e30903271300o6d53c4b8m1057a50ac07369f5@mail.gmail.com> References: <84fb38e30903271300o6d53c4b8m1057a50ac07369f5@mail.gmail.com> Message-ID: <6c2563b20903301720x6cef42ffv8c6e40bde6e729a3@mail.gmail.com> On Fri, Mar 27, 2009 at 4:00 PM, tsuraan wrote: > According to the documentation, a gen_server call function may fail if > the process in question exits before the call returns. What exactly > does fail mean in this context? Does gen_server:call raise an > exception? If so, is the format of that exception documented > anywhere? I assume you mean the sentence in the gen_server ref man that states, "The call may fail for several reasons, including timeout and the called gen_server dying before or during the call. " The answer seems to be that if the gen_server dies before the call is complete, the calling function receives an exit: {'EXIT', {Reason, {gen_server, call, [Module, Function]}}} I played around with some throwaway code to get the above results. It's attached if you're interested. (ed17404@REDACTED)26> gscaller:run(). [gscaller:<0.133.0>:{1238,457700,76877}] Calling slow_call(). <0.134.0> [gsfail:<0.131.0>:{1238,457700,76951}] Received slow call, starting wait. [gscaller:<0.134.0>:{1238,457701,78177}] Killing <0.131.0>. [gscaller:<0.133.0>:{1238,457701,78274}] slow_call() returned, result = {'EXIT', {killed, {gen_server, call, [gsfail, slow_call]}}} ** exception error: killed Ed > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: gsfail.erl Type: text/x-erlang Size: 4204 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: gscaller.erl Type: text/x-erlang Size: 673 bytes Desc: not available URL: From matthew@REDACTED Tue Mar 31 03:19:17 2009 From: matthew@REDACTED (Matthew Dempsky) Date: Mon, 30 Mar 2009 18:19:17 -0700 Subject: [erlang-questions] Extending term external format to support shared substructures Message-ID: Does anyone have opinions on extending the external term format to support shared substructures? I think a simple way to implement this is to add two new tags: DICTIONARY and WORD. DICTIONARY is a special top-level-only tag (like COMPRESSED) that indicates the term uses shared substructures. Its encoding is: DICTIONARY: <<$D, Arity:32, Elements/bytes>>. Elements is a sequence of Arity + 1 encoded terms; the first Arity terms are stored in a dictionary for subsequent terms to reference, and the entire binary decodes to the same as the last term in the sequence. WORD is a new general tag that references a term previously defined in the dictionary. Its encoding is: WORD: <<$w, Index:32>>. Index is an offset into the dictionary; when a WORD tag is decoded, it is replaced by a reference to the appropriate term already built in the dictionary. A WORD tag is not allowed to reference a term that has not been fully built yet (to prevent circular data structures); i.e., the nth term in the dictionary can be referenced by the (n+1)th term in the sequence and any after it, but not within the nth term itself or any early terms. I'm inclined to also say it's an error to define a term in the dictionary that is never referenced, but I can imagine reasons to allow it, and I don't have a strong opinion either way. I haven't thought of a good way to extend term_to_binary to support generating such tags yet. My best idea currently is to add an option like {dictionary, Escape, ListOfTerms}, and then encode terms in ListOfTerms in order as the dictionary, and to detect when encoding {Escape, Index} and create a WORD tag instead of a tuple tag. (I imagine Escape would generally be a reference.) Unless anyone is strongly opposed to the idea, I'll work on a proof-of-concept patch. From ryeguy1@REDACTED Tue Mar 31 04:29:43 2009 From: ryeguy1@REDACTED (ryeguy) Date: Mon, 30 Mar 2009 19:29:43 -0700 (PDT) Subject: [erlang-questions] Where can I use gen_server? Message-ID: I'm making a game server, and I just can't see where I would want to use a gen_server. I'm not set on using one, but I don't want to skimp on using one where it would make it easier to program this app. What I have per node is this: I have 1 process accepting new connections, which spawns a new process for each new client. For each packet that comes in, a new process is spawned to handle it and then it sends the result back to the listening process and terminates. It sounds like a good candidate for gen_server, but per the docs it seems you want to use them when there is some shared resource that you want to manage, and I don't see one. If I gave each client their own gen_server, it wouldn't be good because if an erroneous packet was sent that caused an exception, it would terminate their connection and any other packets being processed for this client (since a gen_server takes all of its spawned processes down with it, right?). Is there any advantage to using gen_server in my situation? From erlangy@REDACTED Tue Mar 31 04:32:07 2009 From: erlangy@REDACTED (Michael McDaniel) Date: Mon, 30 Mar 2009 19:32:07 -0700 Subject: [erlang-questions] Unix domain sockets In-Reply-To: <7c9d57ea0903301704h339c0830x82e14b9316288ea4@mail.gmail.com> References: <3dbc6d1c0903040223w5a079909j8e8851332521efa3@mail.gmail.com> <8209f740903040518y3b3cc4b1j3b06165f3da3f3c8@mail.gmail.com> <358109.5796.qm@web65508.mail.ac4.yahoo.com> <1c89b3a10903081047me42b394q9ab43093b7847c8@mail.gmail.com> <7c9d57ea0903301704h339c0830x82e14b9316288ea4@mail.gmail.com> Message-ID: <20090331023206.GV24282@delora.autosys.us> http://www.nabble.com/erlang-port-and-C-executable-td20631442.html On Mon, Mar 30, 2009 at 05:04:59PM -0700, Sargun Dhillon wrote: > Apparently this doesn't work for character or block devices, see here: > [running beam as root] > 1> FOut = file:open("/dev/net/tun", [read, write]). > {error,eisdir} > 2> FOut1 = file:open("/dev/net/tun", [read, write, raw]). > {error,eisdir} > 3> FOut3 = file:open("/dev/sda", [read, write, raw]). > {error,eisdir} > 4> FOut3 = file:open("/dev/sda", [read, write]). > {error,eisdir} > > lucifer ~ # ls -l /dev/net/tun > crw-rw-rw- 1 root root 10, 200 Mar 30 16:51 /dev/net/tun > lucifer ~ # ls -l /dev/sda > brw-r----- 1 root disk 8, 0 Mar 30 09:27 /dev/sda > > Any ideas on how to read this? Do I need to break out a port driver? > > 2009/3/8 Antoine Koener : > > And what about the support for NamedPipes on windows ? > > Anyone with experience ? > > On Fri, Mar 6, 2009 at 3:24 AM, Richard Andrews wrote: > >> > >> IIRC there was a UNIX socket project in jungerl too. > >> > >> > >> > >> > >> > There's an example driver for unix domain sockets under > >> > $OTP_ROOT/lib/kernel/examples/uds_dist/ > >> > > >> > (It's still there in R13A-0, BTW.) > >> > > >> > It used to be documented in the Interoperability Tutorial, but > >> > I think they've switched to a different example now. > >> > >> > >> ? ? ?Stay connected to the people that matter most with a smarter inbox. > >> Take a look http://au.docs.yahoo.com/mail/smarterinbox > >> _______________________________________________ > >> erlang-questions mailing list > >> erlang-questions@REDACTED > >> http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > > > > -- > > > > http://easyerl.blogspot.com/ > > http://www.open-tools.org/ > > -- Michael McDaniel Portland, Oregon, USA http://trip.autosys.us http://autosys.us http://mmcdaniel.com/erlview From ok@REDACTED Tue Mar 31 04:57:27 2009 From: ok@REDACTED (Richard O'Keefe) Date: Tue, 31 Mar 2009 15:57:27 +1300 Subject: [erlang-questions] Extending term external format to support shared substructures In-Reply-To: References: Message-ID: On 31 Mar 2009, at 2:19 pm, Matthew Dempsky wrote: > Does anyone have opinions on extending the external term format to > support shared substructures? It already does this for atoms, so it would not be alien to the spirit of the external term format. What's more, so does UBF have provision for this. One naturally wonders: what would it be like to unify the external term format and UBF, and would there be any point in it? -- The external term format could be a lot more compact than it currently is, but UBF would move somewhat in the other direction. The issue is how much does it cost and how much does it gain. Encoding with a reuse dictionary requires a minimum of two passes over the term. *IF* this reduces the size of the output, it's a win; if it doesn't, it's a loss. I've wondered whether it would be a good idea to have - one decoder, which is always ready to deal with shared substructure - two encoders, one that looks for shared substructure and one that doesn't. Oddly enough, I have no firm opinions as yet, other than thinking it would be a really good idea to have some figures on what NOT looking for shared structure is costing us. > > From vikrant.patil@REDACTED Tue Mar 31 06:40:08 2009 From: vikrant.patil@REDACTED (Vikrant) Date: Tue, 31 Mar 2009 10:10:08 +0530 Subject: [erlang-questions] how much time required to pass messages. In-Reply-To: <49CF5200.1080702@codimi.de> References: <49CF5200.1080702@codimi.de> Message-ID: even if timer resolution is the reason why we don't see the change in time, question remains same. why the change in time scales with M(number of messages) and NOT with N (number of processes + number of messages)! 2009/3/29 Carsten Schultz > Vikrant schrieb: > > > > 26> tokenring:tokenring(10000,1). > > Time required to pass message 10000 times=3.00000 (4.40000) microsecond > > .ok > > 27> tokenring:tokenring(20000,1). > > Time required to pass message 20000 times=3.00000 (4.65000) microsecond > > .ok > > 28> tokenring:tokenring(30000,1). > > Time required to pass message 30000 times=3.33333 (4.63333) microsecond > > .ok > > > > (time in bracket is system time and time outside bracket is user time in > > microseconds.) > > > > This is surprising to me! I expected that time required to pass token > > along N processes should be proportional to N! > > My guess here is that the resultion of the timer is 1/3. So your > results are 9, 9, 10. Considering that these are rounded and that your > function will have a constant term, these numbers are just to small to > allow you to deduce much about your runtime function. Change the second > parameter into, say, 1000000 in all cases and see what happens. > > -- > Carsten Schultz (2:38, 33:47) > http://carsten.codimi.de/ > PGP/GPG key on the pgp.net key > servers, > fingerprint on my home page. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From matthew@REDACTED Tue Mar 31 06:37:08 2009 From: matthew@REDACTED (Matthew Dempsky) Date: Mon, 30 Mar 2009 21:37:08 -0700 Subject: [erlang-questions] Extending term external format to support shared substructures In-Reply-To: References: Message-ID: On Mon, Mar 30, 2009 at 6:19 PM, Matthew Dempsky wrote: > Unless anyone is strongly opposed to the idea, I'll work on a > proof-of-concept patch. Applying the patch below to R13A extends binary_to_term to support the 'D' and 'w' type tags as I described above. For example: 1> binary_to_term(<<131,$D,3:32, $k,5:16,"hello", $k,5:16,"world", $h,2,$w,0:32,$w,1:32, $l,4:32,$w,2:32,$w,2:32,$w,2:32,$w,2:32,$j>>). [{"hello","world"}, {"hello","world"}, {"hello","world"}, {"hello","world"}] (This example uses a three element dictionary: the strings "hello" and "world" are the first two words, the tuple {"hello", "world"} is the third, using references to the dictionary instances; finally, the term value is a length-4 list using 4 references to the dictionary tuple.) The patch isn't entirely minimal; it also fixes a decoding problem for zero length LIST_EXT structures, avoids allocating extra heap cells for list structures, and refactors some of the integer unpacking to use get_int16 and get_int32. On a related note, I don't really understand why decoded_size keeps a stack of values for 'terms'. It seems like it should just be possible to keep a running grand-total rather than pushing and popping from a stack. --- erts/emulator/beam/external.h.orig 2009-03-30 19:35:43.000000000 -0700 +++ erts/emulator/beam/external.h 2009-03-30 19:37:30.000000000 -0700 @@ -50,6 +50,9 @@ #define NEW_CACHE 'N' #define CACHED_ATOM 'C' +#define DICTIONARY 'D' +#define WORD_EXT 'w' + #define COMPRESSED 'P' #define VERSION_MAGIC 131 /* 130 in erlang 4.2 */ --- erts/emulator/beam/external.c.orig 2009-03-30 19:35:39.000000000 -0700 +++ erts/emulator/beam/external.c 2009-03-30 21:26:33.000000000 -0700 @@ -76,6 +76,7 @@ static byte* enc_atom(DistEntry*, Eterm, byte*); static byte* enc_pid(DistEntry*, Eterm, byte*); static byte* dec_term(DistEntry*, Eterm**, byte*, ErlOffHeap*, Eterm*); +static byte* dec_term1(DistEntry*, Eterm**, byte*, ErlOffHeap*, Eterm*, Eterm*, Uint32); static byte* dec_atom(DistEntry*, byte*, Eterm*); static byte* dec_pid(DistEntry*, Eterm**, byte*, ErlOffHeap*, Eterm*); static byte* dec_hashed_atom(DistEntry*, byte*, Eterm*); @@ -988,6 +989,32 @@ static byte* dec_term(DistEntry *dep, Eterm** hpp, byte* ep, ErlOffHeap* off_heap, Eterm* objp) { + Uint32 i, n; + Eterm *dict; + + if (*ep != DICTIONARY) { + return dec_term1(dep, hpp, ep, off_heap, objp, NULL, 0); + } + + ++ep; + n = get_int32(ep); + ep += 4; + dict = erts_alloc(ERTS_ALC_T_TMP, sizeof(*dict) * n); + for (i = 0; i < n; ++i) { + if ((ep = dec_term1(dep, hpp, ep, off_heap, &dict[i], dict, i)) == NULL) { + break; + } + } + if (ep != NULL) { + ep = dec_term1(dep, hpp, ep, off_heap, objp, dict, n); + } + erts_free(ERTS_ALC_T_TMP, dict); + return ep; +} + +static byte* +dec_term1(DistEntry *dep, Eterm** hpp, byte* ep, ErlOffHeap* off_heap, Eterm* objp, Eterm *dict, Uint32 dictsize) +{ int n; register Eterm* hp = *hpp; /* Please don't take the address of hp */ Eterm* next = objp; @@ -1099,7 +1126,7 @@ n = get_int32(ep); ep += 4; if (n == 0) { - *objp = NIL; + next = objp; break; } *objp = make_list(hp); @@ -1407,7 +1434,7 @@ goto error; } *hpp = hp; - ep = dec_term(dep, hpp, ep, off_heap, &temp); + ep = dec_term1(dep, hpp, ep, off_heap, &temp, dict, dictsize); hp = *hpp; if (ep == NULL) { return NULL; @@ -1467,7 +1494,7 @@ module = temp; /* Index */ - if ((ep = dec_term(dep, hpp, ep, off_heap, &temp)) == NULL) { + if ((ep = dec_term1(dep, hpp, ep, off_heap, &temp, dict, dictsize)) == NULL) { goto error; } if (!is_small(temp)) { @@ -1476,7 +1503,7 @@ old_index = unsigned_val(temp); /* Uniq */ - if ((ep = dec_term(dep, hpp, ep, off_heap, &temp)) == NULL) { + if ((ep = dec_term1(dep, hpp, ep, off_heap, &temp, dict, dictsize)) == NULL) { goto error; } if (!is_small(temp)) { @@ -1559,7 +1586,7 @@ module = temp; /* Index */ - if ((ep = dec_term(dep, hpp, ep, off_heap, &temp)) == NULL) { + if ((ep = dec_term1(dep, hpp, ep, off_heap, &temp, dict, dictsize)) == NULL) { goto error; } if (!is_small(temp)) { @@ -1568,7 +1595,7 @@ old_index = unsigned_val(temp); /* Uniq */ - if ((ep = dec_term(dep, hpp, ep, off_heap, &temp)) == NULL) { + if ((ep = dec_term1(dep, hpp, ep, off_heap, &temp, dict, dictsize)) == NULL) { goto error; } if (!is_small(temp)) { @@ -1600,6 +1627,14 @@ } break; } + case WORD_EXT: + n = get_int32(ep); + ep += 4; + if (n < 0 || n >= dictsize) { + goto error; + } + *objp = dict[n]; + break; default: error: /* @@ -1770,6 +1805,7 @@ int heap_size = 0; int terms = 1; int atom_extra_skip = 0; + int first = 1; Uint n; DECLARE_ESTACK(s); @@ -1815,13 +1851,13 @@ break; case LARGE_BIG_EXT: CHKSIZE(4); - n = (ep[0] << 24) | (ep[1] << 16) | (ep[2] << 8) | ep[3]; + n = get_int32(ep); SKIP2(n,4+1); /* skip, size,sign,digits */ heap_size += 1+1+(n+sizeof(Eterm)-1)/sizeof(Eterm); /* XXX: 1 too much? */ break; case ATOM_EXT: CHKSIZE(2); - n = (ep[0] << 8) | ep[1]; + n = get_int16(ep); if (n > MAX_ATOM_LENGTH) { return -1; } @@ -1885,10 +1921,10 @@ case LIST_EXT: CHKSIZE(4); ESTACK_PUSH(s, terms); - terms = (ep[0] << 24) | (ep[1] << 16) | (ep[2] << 8) | ep[3]; - terms++; + terms = get_int32(ep); ep += 4; heap_size += 2 * terms; + terms++; break; case SMALL_TUPLE_EXT: CHKSIZE(1); @@ -1899,13 +1935,13 @@ case LARGE_TUPLE_EXT: CHKSIZE(4); ESTACK_PUSH(s, terms); - terms = (ep[0] << 24) | (ep[1] << 16) | (ep[2] << 8) | ep[3]; + terms = get_int32(ep); ep += 4; heap_size += terms + 1; break; case STRING_EXT: CHKSIZE(2); - n = (ep[0] << 8) | ep[1]; + n = get_int16(ep); SKIP(n+2); heap_size += 2 * n; break; @@ -1919,7 +1955,7 @@ break; case BINARY_EXT: CHKSIZE(4); - n = (ep[0] << 24) | (ep[1] << 16) | (ep[2] << 8) | ep[3]; + n = get_int32(ep); SKIP2(n, 4); if (n <= ERL_ONHEAP_BIN_LIMIT || no_refc_bins) { heap_size += heap_bin_size(n); @@ -1930,7 +1966,7 @@ case BIT_BINARY_EXT: { CHKSIZE(5); - n = (ep[0] << 24) | (ep[1] << 16) | (ep[2] << 8) | ep[3]; + n = get_int32(ep); SKIP2(n, 5); if (n <= ERL_ONHEAP_BIN_LIMIT || no_refc_bins) { heap_size += heap_bin_size(n) + ERL_SUB_BIN_SIZE; @@ -1965,9 +2001,23 @@ heap_size += ERL_FUN_SIZE + num_free; break; } + case DICTIONARY: + if (!first) { + return -1; + } + CHKSIZE(4); + ESTACK_PUSH(s, terms); + terms = get_int32(ep) + 1; + ep += 4; + break; + case WORD_EXT: + SKIP(4); + break; default: return -1; } + + first = 0; } if (ESTACK_ISEMPTY(s)) { DESTROY_ESTACK(s); From freza@REDACTED Tue Mar 31 10:43:20 2009 From: freza@REDACTED (Jachym Holecek) Date: Tue, 31 Mar 2009 10:43:20 +0200 Subject: [erlang-questions] Extending term external format to support shared substructures In-Reply-To: References: Message-ID: <20090331084320.GA848@hanele> Hello, # Matthew Dempsky 2009-03-31: > Does anyone have opinions on extending the external term format to > support shared substructures? I was thinking it would be a good idea to have such option. > I think a simple way to implement this is to add two new tags: > DICTIONARY and WORD. > > DICTIONARY is a special top-level-only tag (like COMPRESSED) that > indicates the term uses shared substructures. Its encoding is: > > DICTIONARY: <<$D, Arity:32, Elements/bytes>>. > > Elements is a sequence of Arity + 1 encoded terms; the first Arity > terms are stored in a dictionary for subsequent terms to reference, > and the entire binary decodes to the same as the last term in the > sequence. > > WORD is a new general tag that references a term previously defined in > the dictionary. Its encoding is: > > WORD: <<$w, Index:32>>. Take a look at Apple binary plist encoding for inspiration -- rather similar to what you propose, except there's no need for 'Arity' and that compound objects encoded this way are only allowed to reference WORD subterms. It is then up to the encoder to decide how much effort he puts into subterm uniquification. For plists it was a good idea to uniquify basic types (atoms, strings, numbers, booleans) but not compound types (array, dictionary) as that would be too costly. > Index is an offset into the dictionary; when a WORD tag is decoded, it > is replaced by a reference to the appropriate term already built in > the dictionary. A WORD tag is not allowed to reference a term that > has not been fully built yet (to prevent circular data structures); > i.e., the nth term in the dictionary can be referenced by the (n+1)th > term in the sequence and any after it, but not within the nth term > itself or any early terms. > > I'm inclined to also say it's an error to define a term in the > dictionary that is never referenced, but I can imagine reasons to > allow it, and I don't have a strong opinion either way. What would be the reasons to support it? No strong opinion either, just curious. > I haven't thought of a good way to extend term_to_binary to support > generating such tags yet. My best idea currently is to add an option > like {dictionary, Escape, ListOfTerms}, and then encode terms in > ListOfTerms in order as the dictionary, and to detect when encoding > {Escape, Index} and create a WORD tag instead of a tuple tag. (I > imagine Escape would generally be a reference.) I must be missing something. What prevents you from making this simply term_to_binary(Term, [dictionary]) ? Also, the name 'dictionary' is somewhat confusing IMO, something like 'unique' would perhaps be more clear. Maybe '{unique, Types}' so that you can control which of basic types you want uniquified. Regards, -- Jachym From erik.reitsma@REDACTED Tue Mar 31 08:51:51 2009 From: erik.reitsma@REDACTED (Erik Reitsma) Date: Tue, 31 Mar 2009 08:51:51 +0200 Subject: [erlang-questions] Getting {error, eisdir} when opening devices/pipes/etc, was RE: Unix domain sockets In-Reply-To: <7c9d57ea0903301704h339c0830x82e14b9316288ea4@mail.gmail.com> References: <3dbc6d1c0903040223w5a079909j8e8851332521efa3@mail.gmail.com><8209f740903040518y3b3cc4b1j3b06165f3da3f3c8@mail.gmail.com><358109.5796.qm@web65508.mail.ac4.yahoo.com><1c89b3a10903081047me42b394q9ab43093b7847c8@mail.gmail.com> <7c9d57ea0903301704h339c0830x82e14b9316288ea4@mail.gmail.com> Message-ID: <110BA8ACEE682C479D0B008B6BE4AEB1084B7543@esealmw107.eemea.ericsson.se> I've been struggling with this issue too, trying to read from Linux devices. I have written a port driver to open files (and do ioctl calls on them if they are actually devices), returning a file descriptor. Then I can read from the file using erlang:open_port({fd, In, Out}, []). In this case, In and Out would both be the file descriptor I got from the driver. Another possibility is erlang:open_port({command, "cat /dev/net/tun"}, []), but that is not very pretty or efficient either. | Apparently this doesn't work for character or block devices, see here: | [running beam as root] | 1> FOut = file:open("/dev/net/tun", [read, write]). | {error,eisdir} | 2> FOut1 = file:open("/dev/net/tun", [read, write, raw]). | {error,eisdir} | 3> FOut3 = file:open("/dev/sda", [read, write, raw]). | {error,eisdir} | 4> FOut3 = file:open("/dev/sda", [read, write]). | {error,eisdir} | | lucifer ~ # ls -l /dev/net/tun | crw-rw-rw- 1 root root 10, 200 Mar 30 16:51 /dev/net/tun | lucifer ~ # ls -l /dev/sda | brw-r----- 1 root disk 8, 0 Mar 30 09:27 /dev/sda | | Any ideas on how to read this? Do I need to break out a port driver? | Regards, *Erik. From bgustavsson@REDACTED Tue Mar 31 11:27:11 2009 From: bgustavsson@REDACTED (Bjorn Gustavsson) Date: Tue, 31 Mar 2009 11:27:11 +0200 Subject: [erlang-questions] Extending term external format to support shared substructures In-Reply-To: References: Message-ID: <6672d0160903310227j54cb695dp8f9bdb0a5cfb8592@mail.gmail.com> On Tue, Mar 31, 2009 at 3:19 AM, Matthew Dempsky wrote: > > I haven't thought of a good way to extend term_to_binary to support > generating such tags yet. My best idea currently is to add an option > like {dictionary, Escape, ListOfTerms}, and then encode terms in > ListOfTerms in order as the dictionary, and to detect when encoding > {Escape, Index} and create a WORD tag instead of a tuple tag. (I > imagine Escape would generally be a reference.) What everybody wants and expects is: term_to_binary(Term, [preserve_sharing]) where sub-terms (even parts of lists) are automatically detected and preserved. It can be implemented with a hash table, with a mapping from a tagged pointer to the index in the term dictionary. The hash table would be created and filled in by the same routine that calculates the size of the external format, and used when encoding the term. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From matthew@REDACTED Tue Mar 31 12:07:50 2009 From: matthew@REDACTED (Matthew Dempsky) Date: Tue, 31 Mar 2009 03:07:50 -0700 Subject: [erlang-questions] Extending term external format to support shared substructures In-Reply-To: References: <6672d0160903310246h71719f81ha7827e032037df13@mail.gmail.com> Message-ID: On Tue, Mar 31, 2009 at 3:00 AM, Matthew Dempsky wrote: > Also, now that I look at it again, it looks like there's a memory leak > when SKIP, SKIP2, or CHKSIZE fail (and also the 'first' check that I > added in the DICTIONARY clause in my patch, because I based it on > these), because they return without calling DESTROY_ESTACK. Nevermind, I just downloaded the R13B snapshot and see this is now fixed. From bgustavsson@REDACTED Tue Mar 31 11:46:12 2009 From: bgustavsson@REDACTED (Bjorn Gustavsson) Date: Tue, 31 Mar 2009 11:46:12 +0200 Subject: [erlang-questions] Extending term external format to support shared substructures In-Reply-To: References: Message-ID: <6672d0160903310246h71719f81ha7827e032037df13@mail.gmail.com> On Tue, Mar 31, 2009 at 6:37 AM, Matthew Dempsky wrote: > On Mon, Mar 30, 2009 at 6:19 PM, Matthew Dempsky wrote: >> Unless anyone is strongly opposed to the idea, I'll work on a >> proof-of-concept patch. > > Applying the patch below to R13A extends binary_to_term to support the > 'D' and 'w' type tags as I described above. For example: > > 1> binary_to_term(<<131,$D,3:32, $k,5:16,"hello", $k,5:16,"world", > $h,2,$w,0:32,$w,1:32, $l,4:32,$w,2:32,$w,2:32,$w,2:32,$w,2:32,$j>>). > [{"hello","world"}, > {"hello","world"}, > {"hello","world"}, > {"hello","world"}] > > (This example uses a three element dictionary: the strings "hello" and > "world" are the first two words, the tuple {"hello", "world"} is the > third, using references to the dictionary instances; finally, the term > value is a length-4 list using 4 references to the dictionary tuple.) Thanks for the patch. Even though it looks fine, we will not include until the code for encoding a term has been written. > The patch isn't entirely minimal; it also fixes a decoding problem for > zero length LIST_EXT structures, avoids allocating extra heap cells > for list structures, and refactors some of the integer unpacking to > use get_int16 and get_int32. Thanks for pointing out those issues. I will include the use of the macros and the correction of the number of heap words needed for lists in R13B. Your fix for a zero length LIST_EXT doesn't seem to be correct, though. Have you tried: binary_to_term(<<131,104,2,108,0,0,0,0,106,100,0,1,97>>). My correction for this problem will appear in the next R13B snapshot (hopefully tomorrow) at: http://www.erlang.org/download/snapshots/ (It is also good idea to use a snapshot as a base for further patches, as I have eliminated the deep recursion in term_to_binary/1.) > On a related note, I don't really understand why decoded_size keeps a > stack of values for 'terms'. It seems like it should just be possible > to keep a running grand-total rather than pushing and popping from a > stack. > To make sure that all terms are properly nested. We try to do as much error checking as possible while calculating the size. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From matthew@REDACTED Tue Mar 31 12:00:14 2009 From: matthew@REDACTED (Matthew Dempsky) Date: Tue, 31 Mar 2009 03:00:14 -0700 Subject: [erlang-questions] Extending term external format to support shared substructures In-Reply-To: <6672d0160903310246h71719f81ha7827e032037df13@mail.gmail.com> References: <6672d0160903310246h71719f81ha7827e032037df13@mail.gmail.com> Message-ID: On Tue, Mar 31, 2009 at 2:46 AM, Bjorn Gustavsson wrote: > Thanks for the patch. Even though it looks fine, we will not include until > the code for encoding a term has been written. That's reasonable. > Your fix for a zero length LIST_EXT doesn't seem to be correct, though. > Have you tried: > > binary_to_term(<<131,104,2,108,0,0,0,0,106,100,0,1,97>>). Here's what I get with my patched R13A: > binary_to_term(<<131,104,2,108,0,0,0,0,106,100,0,1,97>>). {[],a} Do you get something different? Is this not what you think it should be? > My correction for this problem will appear in the next R13B > snapshot (hopefully tomorrow) at: Great. > (It is also good idea to use a snapshot as a base for further patches, > as I have eliminated the deep recursion in term_to_binary/1.) Got it. > To make sure that all terms are properly nested. We try to do as much error > checking as possible while calculating the size. Sorry, I still don't see the benefit. E.g., what better error checking do you have right now than if in the clause for SMALL_TUPLE_EXT you were to replace ESTACK_PUSH(s, terms); terms = *ep++; heap_size += terms + 1; with n = *ep++; terms += n; heap_size += n + 1; ? With the exception of overflowing the 'terms' counter (which can be easily resolved by changing it to a 64-bit integer), I don't see how the former ends up being any stricter than the latter. Also, now that I look at it again, it looks like there's a memory leak when SKIP, SKIP2, or CHKSIZE fail (and also the 'first' check that I added in the DICTIONARY clause in my patch, because I based it on these), because they return without calling DESTROY_ESTACK. From gamoto@REDACTED Tue Mar 31 11:37:04 2009 From: gamoto@REDACTED (Gamoto) Date: Tue, 31 Mar 2009 11:37:04 +0200 Subject: [erlang-questions] tokenize function Message-ID: <200903311137038798567@bluewin.ch> Hi, I read in one erlang program the following statement: Tokens=tokenize(Rest) Does tokenize an erlang function or a user function ? I didn't find documentation on it. I suppose that this function extracts segments from a bit stream. Marc Bertaud From bgustavsson@REDACTED Tue Mar 31 12:41:13 2009 From: bgustavsson@REDACTED (Bjorn Gustavsson) Date: Tue, 31 Mar 2009 12:41:13 +0200 Subject: [erlang-questions] Extending term external format to support shared substructures In-Reply-To: References: <6672d0160903310246h71719f81ha7827e032037df13@mail.gmail.com> Message-ID: <6672d0160903310341v183eba7fr6500f72ad56b36fb@mail.gmail.com> On Tue, Mar 31, 2009 at 12:00 PM, Matthew Dempsky wrote: > > Here's what I get with my patched R13A: > > > binary_to_term(<<131,104,2,108,0,0,0,0,106,100,0,1,97>>). > {[],a} > > Do you get something different? Is this not what you think it should be? My fault. I did not apply the patch correctly (I manually applied only the correction for this issue, because I didn't want the rest of the patch). Your correction works fine and I will use your correction (my correction used a goto). > >> To make sure that all terms are properly nested. We try to do as much error >> checking as possible while calculating the size. > > Sorry, I still don't see the benefit. E.g., what better error > checking do you have right now than if in the clause for > SMALL_TUPLE_EXT you were to replace > > ESTACK_PUSH(s, terms); > terms = *ep++; > heap_size += terms + 1; > > with > > n = *ep++; > terms += n; > heap_size += n + 1; > > > ? With the exception of overflowing the 'terms' counter (which can be > easily resolved by changing it to a 64-bit integer), I don't see how > the former ends up being any stricter than the latter. You are probably right. I applied your change and ran a test suite with contains many examples of corrupt external format. It did not fail. I will have to think more about it. If I can't find any reason for the pushing and popping, I will change it in R13B. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From daniel.goertzen@REDACTED Tue Mar 31 15:34:46 2009 From: daniel.goertzen@REDACTED (Daniel Goertzen) Date: Tue, 31 Mar 2009 08:34:46 -0500 Subject: [erlang-questions] Unix domain sockets In-Reply-To: <7c9d57ea0903301704h339c0830x82e14b9316288ea4@mail.gmail.com> References: <3dbc6d1c0903040223w5a079909j8e8851332521efa3@mail.gmail.com> <8209f740903040518y3b3cc4b1j3b06165f3da3f3c8@mail.gmail.com> <358109.5796.qm@web65508.mail.ac4.yahoo.com> <1c89b3a10903081047me42b394q9ab43093b7847c8@mail.gmail.com> <7c9d57ea0903301704h339c0830x82e14b9316288ea4@mail.gmail.com> Message-ID: Unfortunately, the documentation implies that this is not allowed: eisdir The named file is not a regular file. It may be a directory, a fifo, or a device. I'm a little dismayed at this; I was planning on using a char driver soon by opening it as a file and then attaching a port to it with open_port({fd,...). I guess I will be doing it a different way... Likely a whole port program. Dan. On Mon, Mar 30, 2009 at 7:04 PM, Sargun Dhillon wrote: > Apparently this doesn't work for character or block devices, see here: > [running beam as root] > 1> FOut = file:open("/dev/net/tun", [read, write]). > {error,eisdir} > 2> FOut1 = file:open("/dev/net/tun", [read, write, raw]). > {error,eisdir} > 3> FOut3 = file:open("/dev/sda", [read, write, raw]). > {error,eisdir} > 4> FOut3 = file:open("/dev/sda", [read, write]). > {error,eisdir} > > lucifer ~ # ls -l /dev/net/tun > crw-rw-rw- 1 root root 10, 200 Mar 30 16:51 /dev/net/tun > lucifer ~ # ls -l /dev/sda > brw-r----- 1 root disk 8, 0 Mar 30 09:27 /dev/sda > > Any ideas on how to read this? Do I need to break out a port driver? > > 2009/3/8 Antoine Koener : > > And what about the support for NamedPipes on windows ? > > Anyone with experience ? > > On Fri, Mar 6, 2009 at 3:24 AM, Richard Andrews > wrote: > >> > >> IIRC there was a UNIX socket project in jungerl too. > >> > >> > >> > >> > >> > There's an example driver for unix domain sockets under > >> > $OTP_ROOT/lib/kernel/examples/uds_dist/ > >> > > >> > (It's still there in R13A-0, BTW.) > >> > > >> > It used to be documented in the Interoperability Tutorial, but > >> > I think they've switched to a different example now. > >> > >> > >> Stay connected to the people that matter most with a smarter inbox. > >> Take a look http://au.docs.yahoo.com/mail/smarterinbox > >> _______________________________________________ > >> erlang-questions mailing list > >> erlang-questions@REDACTED > >> http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > > > > -- > > > > http://easyerl.blogspot.com/ > > http://www.open-tools.org/ > > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- Daniel Goertzen ----------------- work email: dang@REDACTED work phone: 1 443 303 8525 work sip: 945050@REDACTED ----------------- mobile: 1 204 470 8360 ----------------- home email: daniel.goertzen@REDACTED home phone: 1 204 272 6149 -------------- next part -------------- An HTML attachment was scrubbed... URL: From mcpherson@REDACTED Tue Mar 31 16:56:47 2009 From: mcpherson@REDACTED (Allen McPherson) Date: Tue, 31 Mar 2009 08:56:47 -0600 Subject: [erlang-questions] Debugging timeout on slave:start_link? Message-ID: <834C7F53-6E8F-4951-A31E-064CFB12B0D2@lanl.gov> Built R13A on two Linux nodes (using different version of gcc). Both installed in same location. My start_link fails with timeout from one node to the other (but not the reverse direction). Manual says it could be cookies (they are the same), file system (just where Erlang is installed?), or installation (it's installed). Also rolled back to R12B-5. Same problem. Can anyone provide hints on debugging this? Looks like an erl_crash.dump file is getting generated but, for reasons to obscure to explain, I can't use a web browser to get at these systems. Any other way to detect the cause of the failure? Thanks -- Al From cbenac@REDACTED Tue Mar 31 15:37:08 2009 From: cbenac@REDACTED (Clara Benac Earle) Date: Tue, 31 Mar 2009 15:37:08 +0200 Subject: [erlang-questions] McErlang first public release Message-ID: <49D21C84.6080701@fi.upm.es> Dear all, We are happy to announce the first public release of McErlang, a model checking tool for Erlang. Please take a look at https://babel.ls.fi.upm.es/trac/McErlang/ try the tool and send us your questions, comments, bug reports, etc. Best regards, Clara and Lars-Ake Fredlund From attila.r.nohl@REDACTED Tue Mar 31 18:43:11 2009 From: attila.r.nohl@REDACTED (Attila Rajmund Nohl) Date: Tue, 31 Mar 2009 18:43:11 +0200 Subject: [erlang-questions] =?iso-8859-1?q?V=E1=3A__Erlang/OTP_R13A_has_be?= =?iso-8859-1?q?en_released?= In-Reply-To: <6672d0160903170857y6c4435fctcdc4b0b9f6d67a5a@mail.gmail.com> References: <6672d0160903170857y6c4435fctcdc4b0b9f6d67a5a@mail.gmail.com> Message-ID: <401d3ba30903310943j60ecf76j557e914c5df42330@mail.gmail.com> Hello! I see that the atom/1, pid/1, etc. guards are obsolated a couple of releases ago, but the R13A compiler started to produce warnings about them. Has anyone implemented a conversion tool that replaces the old style guards to is_atom/1, is_pid/1, etc. guards? Also a regexp -> re converter would be useful :-) 2009/3/17, Bjorn Gustavsson : > Major relese : otp_src_R13A > Build date : 2009-03-17 > > R13A is a beta release of the next R13B major release. > We do not recommend it for use in live products. > > In the R13B release, there may be incompatibilities > in new features that were introduced in this R13A release > (for instance in the Unicode support). > > You can download the full source distribution from > > http://www.erlang.org/download/otp_src_R13A.tar.gz > http://www.erlang.org/download/otp_src_R13A.readme (this file) > > Note: To unpack the TAR archive you need a GNU TAR compatible program. > > For installation instructions please read the README that is part of > the distribution. > > The Windows binary distribution can be downloaded from > > http://www.erlang.org/download/otp_win32_R13A.exe > > > On-line documentation can be found at http://www.erlang.org/doc/. > You can also download the complete HTML documentation or the Unix manual > files > > http://www.erlang.org/download/otp_doc_html_R13A.tar.gz > http://www.erlang.org/download/otp_doc_man_R13A.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 yogishb@REDACTED Tue Mar 31 20:13:41 2009 From: yogishb@REDACTED (Yogish Baliga) Date: Tue, 31 Mar 2009 11:13:41 -0700 (PDT) Subject: [erlang-questions] RPC from linkedin driver Message-ID: <722837.22586.qm@web31810.mail.mud.yahoo.com> I am currently working on developing a linkedin driver (c language) for XML parser (xmerl is too slow). This is a SAX parser is given the following input: 1. XML to be parsed 2. Call back functions (MFA) for start of node, end of node and for text elements I found C APIs to do RPC calls from c-node (ei_rpc). This require ei_cnode and fd parameters. That means I need to run the port as a c-node. Is it possible to do RPC from linkedin driver without converting linkedin driver as a c-node? Thanx, -- baliga "The quality of programmers is a decreasing function of the density of GOTO statements in the programs they produce." - Edsger W. Dijkstra From olivier.boudeville@REDACTED Tue Mar 31 22:11:54 2009 From: olivier.boudeville@REDACTED (Olivier Boudeville) Date: Tue, 31 Mar 2009 22:11:54 +0200 Subject: [erlang-questions] WOOPER 0.3 released, for OOP with Erlang Message-ID: <49D2790A.70501@online.fr> Hi, A new version (0.3) of WOOPER (Wrapper for OOP in Erlang) has just been released. It should be more convenient to develop with, and more robust. The WOOPER documentation has also experienced a major update. WOOPER is an open source lightweight layer on top of the Erlang language offering constructs dedicated to Object-Oriented Programming, including classes, instances, methods (requests or oneways), life-cycle management (new/new_link/delete), multiple inheritance, polymorphism, state management, etc. All documentation, sources and full examples are available at http://ceylan.sourceforge.net/main/documentation/wooper/ Any constructive feedback would be appreciated! Best regards, Olivier Boudeville. PS: I had to post the message again, previous one apparently did not reach the list after 5 days. From kris_prieb@REDACTED Tue Mar 31 21:50:09 2009 From: kris_prieb@REDACTED (Kris Prieb) Date: Tue, 31 Mar 2009 14:50:09 -0500 Subject: [erlang-questions] problem running escript upon linux startup Message-ID: <4537c3580903311250l1a8ccd79i99f0e87eac01755a@mail.gmail.com> Hello list, The following escript fails when run upon linux (ubuntu) startup: #!/usr/bin/escript %% -*- erlang -*- %%! -env HOME /root main(_) -> file:write_file("/root/simple_start_output", "bunch of text"). The program should create a file called "simple_start_output," under the root directory, but no such file appears when I log into the system. A look at /var/logsyslog/ reveals a "erlexec: HOME must be set" message resulting from the execution of the script. The strange thing is that the script works fine when I run it after logging in. I've tried variations of the script such as: 1. using "/root" instead of /root when setting the HOME environment variable in the 3rd line of the script 2. excluding the 3rd line of the script entirely 3. using "/usr/bin/env escript" instead of calling "/usr/bin/escript" All scripts result in the same error, "erlexec: HOME must be set," when run at startup. However, they all work when run after logging in. Does anyone have an idea of how to get an escript to run at startup?? Any thoughts would be greatly appreciated. Thanks! Kris Prieb (I should also mention that I am actually running the script at the launch of an Amazon EC2 virtual server, not on a machine that is physically in front of me. Not sure if that matters one way or another.) From fmilicchio@REDACTED Tue Mar 31 19:46:01 2009 From: fmilicchio@REDACTED (Franco Milicchio) Date: Tue, 31 Mar 2009 19:46:01 +0200 Subject: [erlang-questions] State of the Union: FFI Message-ID: <34E60AA2-F1F5-4C05-86B5-B86C3041857D@me.com> Dear all, Is there someone that knowns the inner working of FFI standardization? I am trying to use it, but it's really not a piece of cake when I must remain with older versions of Erlang/OTP. By the way, is there someone I can talk with regarding FFI? (in production, of course!) Thanks! PS. I know this is a recurring topic, but I didn't find any post newer than six month, so... this is just a reminder :) -- Franco Milicchio DIA - Dept. of Computer Science and Engineering University Roma Tre http://plm.dia.uniroma3.it/milicchio/ -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2417 bytes Desc: not available URL: