From joelr1@REDACTED Fri Sep 1 00:46:45 2006 From: joelr1@REDACTED (Joel Reymont) Date: Thu, 31 Aug 2006 23:46:45 +0100 Subject: Parsing RSS In-Reply-To: References: Message-ID: There seems to be an issue with url:raw_get_url/2 from www_tools. It returns <<"1ff8\r\n> and the first 6 characters cause the error. On Aug 31, 2006, at 10:33 PM, Joel Reymont wrote: > Has anyone tried to parse RSS feeds using Erlang? > > I tried the example at http://wiki.trapexit.org/index.php/ > How_to_write_an_RSS_aggregator but xmerl_scan:string blows up. The > proper URL for the feed is http://rss.slashdot.org/Slashdot/slashdot. -- http://wagerlabs.com/ From hokan.stenholm@REDACTED Fri Sep 1 01:18:12 2006 From: hokan.stenholm@REDACTED (=?ISO-8859-1?Q?H=E5kan_Stenholm?=) Date: Fri, 01 Sep 2006 01:18:12 +0200 Subject: warn_unused_vars (Was: Re: Noob - Getting Started Infinte Loop?) In-Reply-To: <44F74FFE.4070904@it.uu.se> References: <6056733.post@talk.nabble.com> <0C554180-FD58-4069-9430-170213B71689@redstarling.com> <6069968.post@talk.nabble.com> <44F63559.7000806@bredband.net> <44F74236.3010803@telia.com> <44F74FFE.4070904@it.uu.se> Message-ID: <44F76E34.20005@bredband.net> Richard Carlsson wrote: >Robert Virding wrote: > > >>Actually this is simple way to get rid of the annoying whining by the >>compiler, just prepend every variable with _ and it keeps quiet. :-) >> >>Seriously I would prefer the default to be to keep quiet. >> >> > >Seriously, that would be a bad idea. It catches _way_ too many errors >(nasty, hard-to-find typo bugs) to be turned off by default. > > I agree, I'm all for compiler warnings like these - they are rather useful to find stupid mistakes, which I certainly make from time to time. The only problem is if it becomes tedious (e.g. involves lots of of typing or extra code) to tell the compiler that it found a false positive, or if it finds lots of stuff that isn't really wrong. >Oh, not in _your_ code, of course. Goes without saying. ;-) > > /Richard > > > From erlang@REDACTED Fri Sep 1 01:52:27 2006 From: erlang@REDACTED (erlang) Date: Thu, 31 Aug 2006 16:52:27 -0700 Subject: net_adm:ping not working -- still not answered Message-ID: The status of this is that a couple of people have tried to help me to no avail. None of you appear to use Windows(tm). Everything looks right, but the ping function just does not seem to be able to resolve the host name. I've simplified the test case down to 'a' and 'b' nodes on localhost. I can't ping from 'a' to 'b'. net_adm:ping('b@REDACTED'). from console 'a' always returns pang. There are no details, error messages or logs that I am aware of. inet:gethostbyname('my-server'). returns {error,timeout} epmd looks perfect. J:\Program Files\erl5.5.1\erts-5.5.1\bin>epmd -names epmd: up and running on port 4369 with data: name b at port 1443 name a at port 1439 Using erl with long paths results in a crash dump from the erlang console. I can inet:gethostname(). ok, but net_adm:dns_hostname('my-server'). fails. I am testing on Windows Server 2003 on localhost with no local DNS server, no domain controller, etc. Ordinarily my system can open sockets on localhost and do just about everything. Perhaps you can see what's going on. > > Sorry, this is indeed a typo in my email. Should be: > > (b@REDACTED)1> net_adm:ping('a@REDACTED'). > > > > > > > > Hi, is the colon ":" just a typo in your email? It should be > > > "@" as you can see from the node name in the Erlang shell prompt. > > > > > > Best Regards > > > Lennart > > > > > > > (b@REDACTED)1> net_adm:ping('a:my-server'). > > > > > > > I can't get the ping-pong distributed example to work, so I tried simply > > > > pinging another node. This doesn't work either. > > > > > > > > os: windows server 2003, machine name is my-server. > > > > EShell v5.5.1 > > > > > > > > command lines: erl -sname a > > > > erl -sname b > > > > > > > > (b@REDACTED)1> net_adm:ping('a:my-server'). > > > > > > > > always returns pang. The cookie file is being read, and the cookie is > > > > the same in both nodes. What to try next? > > > > > > > > > > > > > > > > > > > > > > From fbg111@REDACTED Fri Sep 1 04:25:00 2006 From: fbg111@REDACTED (fbg111) Date: Thu, 31 Aug 2006 19:25:00 -0700 (PDT) Subject: Erlang on Solaris x86 In-Reply-To: References: <03B8C790-1251-47E6-84C3-EF6232F1DC3E@gmail.com> <375AC5C7-2566-4803-A1CC-62F59ECF861B@redstarling.com> <6072315.post@talk.nabble.com> Message-ID: <6091846.post@talk.nabble.com> Cool. I'll keep an eye out for an update on your blog. Also, there's a lot of interest in Erlang and concurrent systems and software at http://programming.reddit.com/. A post about building Erlang on Minix would probably get pretty high in the rankings. Once I get my PC rebuilt with a mobo that better supports Linux, I'll give it a try too. Byron Chris Double wrote: > > On 8/31/06, fbg111 wrote: >> >> A bit offtopic, but is it possible to compile and run Erlang on Minix? >> That >> would be an interesting platform. > > I had a brief attempt at it and got most of it to compile but never > completed it. Quite a bit of work has gone on recently in Minix for > cross platform compilation support so it may be a bit easier now. I'll > have another go at it and see how it goes. > > Chris. > -- > http://www.bluishcoder.co.nz > > -- View this message in context: http://www.nabble.com/Erlang-on-Solaris-x86-tf2187264.html#a6091846 Sent from the Erlang Questions forum at Nabble.com. From fbg111@REDACTED Fri Sep 1 04:43:02 2006 From: fbg111@REDACTED (fbg111) Date: Thu, 31 Aug 2006 19:43:02 -0700 (PDT) Subject: Noob - Getting Started Infinte Loop? In-Reply-To: <44F6A50E.4020403@ericsson.com> References: <6056733.post@talk.nabble.com> <0C554180-FD58-4069-9430-170213B71689@redstarling.com> <6069923.post@talk.nabble.com> <5B0832B3-EB1B-4764-A4F1-65BA20C5A4DE@redstarling.com> <44F6A50E.4020403@ericsson.com> Message-ID: <6091960.post@talk.nabble.com> Mats Cronqvist wrote: > > here's an example. > > 24> A=<<"a">>. > ** 1: syntax error before: '<' ** > 24> A = <<"a">>. > <<97>> > 25> A=<<<"a">>. > true > Interesting, I just ran it in BEAM. That's proof. Thanks. -- View this message in context: http://www.nabble.com/Noob---Getting-Started-Infinte-Loop--tf2189189.html#a6091960 Sent from the Erlang Questions forum at Nabble.com. From ok@REDACTED Fri Sep 1 04:54:25 2006 From: ok@REDACTED (Richard A. O'Keefe) Date: Fri, 1 Sep 2006 14:54:25 +1200 (NZST) Subject: Noob - Getting Started Infinte Loop? Message-ID: <200609010254.k812sPG6318312@atlas.otago.ac.nz> Bengt Kleberg wrote: > It is more than my personal opinion since 100% of the people i have > asked say that NamesThatLookLikeThis are harder, or about as easy after > learning how to do it, to read than Names_that_look_like_this. > Nobody has ever claimed that they are easier to read. Garry Hodgson retorted: you must have asked the wrong people. IfThereReallyArePeopleWhoFindThisKindOfTextEasierToRead Then_Text_That_Looks_Like_This, then we have empirical evidence for the existence of more than one human species. (:-) The Ada Quality and Style Guidelines include the following section: 3.1.1 Use of Underscores Guideline - Use underscores to separate words in a compound name. Example Miles_Per_Hour Entry_Value Rationale When an identifier consists of more than one word, it is much easier to read if the words are separated by underscores. Indeed, there is precedent in English in which compound words are separated by a hyphen or a space. In addition to promoting readability of the code, if underscores are used in names, a code formatter has more control over altering capitalization. See Guideline 3.1.3. There's a reference later on to a book Empirical Studies of Programmers, edited by E. Soloway and S. Iyengar. Norwood, NJ: Ablex Publishing Corp 1986 I have never seen that. Anyone got a copy? There's an interesting paper What's in a Name? A Study of Identifiers by Dawn Lawrie, Christopher Morrell, Henry Feild, & David Binkley but that explores what the words should be like, not whether there should be underscores between them. Attila Feher pointed out that the baStudlyCaps convention doesn't work for identifiers like SMTPTCPIPConnection which would work just fine as SMTP_TCP_IP_Connection Hmm, you don't happen to know a language that's often used for programming networks, in which you often have to mention heavily acronymed stuff, do you? Bertrand Meyer has a chapter on style, http://archive.eiffel.com/doc/manuals/language/style/style.pdf One paragraph of that says For composite names, it is better to avoid the style, popularized by Smalltalk and also used in such libraries as the X Window System, of joining several words together and starting the internal ones with an upper-case letter, as in "yearlyPremium". Instead, separate components with underscores, as in "yearly_premium". The use of internal upper-case letters is ugly; it conflicts with the conventions of ordinary language; and it leads to cryptic names, hence to possible errors (compare "aLongAndRatherUnreadableIdentifier" with an_even_longer_but_perfectly_clear_choice_of_name). In Smalltalk's defence, I must point out that it was originally developed on machines that didn't *have* an underscore character on their keyboards or in their character set, and that the ANSI Smalltalk standard *does* include underscores, at least some modern Smalltalkers agreeing with Meyer. Me, I've written enough Smalltalk to be used to baStudlyCaps and to have written more code than I care to remember in that style, and what chiefly sticks in my mind is not how easy or hard it is to read, but how annoyingly hard it is to get readable class names. (Given a convention where a programmer's classes are prefixed with their initials, and the package is called OXUS, and I want to talk about an XML ID, RAOKOXUSXMLID is forced on me, but it's horrible. I desperately want RAOK_OXUS_XML_ID. The convention does *not* allow Raok, Oxus would be wrong, the notation is XML, not Xml, and the XML specification calls them ID, not Id, so RaokOxusXmlId would be wrong. (And on my screen, the "l" of Xml and the "I" of "Id" look pretty similar, so it's surprisingly hard to see where the dividing point is.) If you have PERL installed on your machine, try 'man perlstyle', where you'll find While short identifiers like $gotit are probably ok, use underscores to separate words. It is generally easier to read $var_names_like_this than $VarNamesLikeThis, especially for non-native speakers of English. It's also a simple rule that works consistently with VAR_NAMES_LIKE_THIS I've just spent nearly an hour searching for some experimental writeup about this. I guess it's one of those things, like "other things being equal, it is better if the default base for integers in a program is 10 rather than 8" (don't laugh, I've met languages where it really was 8) that are so obvious that nobody bothers to measure them. From sjn@REDACTED Fri Sep 1 05:25:45 2006 From: sjn@REDACTED (Sanjay Mehta) Date: Fri, 01 Sep 2006 08:55:45 +0530 Subject: The Erlang mailing list In-Reply-To: <2006083112331157041983@k2.sage.att.com> References: <2006083112331157041983@k2.sage.att.com> Message-ID: <44F7A839.5060406@cypress.com> On 31/08/2006 10:03 PM, Garry Hodgson wrote: > we could also add mailinglists to discuss the best ways to further fragment > the already small erlang community. Well, it might get a little larger given that this article showed on Digg yesterday: http://digg.com/programming/We_in_fact_require_that_programmers_of_multithreaded_systems_be_insane (BTW, the mailing list works fine for lurkers like me.) From ok@REDACTED Fri Sep 1 06:14:42 2006 From: ok@REDACTED (Richard A. O'Keefe) Date: Fri, 1 Sep 2006 16:14:42 +1200 (NZST) Subject: Noob - Getting Started Infinte Loop? Message-ID: <200609010414.k814Eg1U298084@atlas.otago.ac.nz> "Lennart Ohman" wrote: the _ (only an underscore) is never bound from efficiency reasons. For instance: f(foo,bar) -> ...; f(frotz,X) -> ...; f(_,X) -> .... One more time: this has NOTHING TO DO WITH EFFICIENCY. >From a formal point of view, ALL VARIABLES ARE ALIKE. This is true in ML, Haskell, Clean, Mercury, Prolog, and Erlang. Their spelling makes NO difference to the semantics (possible style check warnings aside) except that there can be any number of "anonymous" variables spelled "_", and they are all different. Your normal mental model of variables should treat them all alike. Spelling is about telling PEOPLE stuff. A good compiler will notice that a variable has a single occurrence WITHOUT CARING HOW IT IS SPELLED and will perform whatever optimisations are appropriate. Note, for example, that in f(X, Y) -> [ignore,X,and,Y], g(Y). X and Y are both used more than once. However, a compiler could (and I expect at least HiPE does) notice that [ignore,X,and,Y] doesn't actually do anything useful, and the code you get might be the same as that for f(_, Y) -> g(Y). My point here is that as far as optimisation is concerned, what counts is how many uses of a variable survive after *other* optimisations have been applied as well; any compiler that just relied on the spelling of the variable names would be too dumb to remember to breathe in as well as out. From ke.han@REDACTED Fri Sep 1 08:05:29 2006 From: ke.han@REDACTED (ke han) Date: Fri, 1 Sep 2006 14:05:29 +0800 Subject: Sun Niagara potential ?? Message-ID: <20152BC9-18E1-4C7F-BCA9-B61CC61F16DC@redstarling.com> I read with great interest Mr. Armstrong's initial experiences on the Niagara: http://www.erlang.org/ml-archive/erlang-questions/200606/msg00187.html I will be testing yaws on a T1000 in a week or so. One feature I need to test is the Solaris kernel SSL api paired with the Niagara on-core crypto acceleration. Has anyone played with this? If the openSSL lib yaws is indirectly using doesn't "magically" leverage the on-core acceleration, I will need to dig into the erlang https code to make it so...any pointers? thanks, ke han From bjorn@REDACTED Fri Sep 1 09:03:42 2006 From: bjorn@REDACTED (Bjorn Gustavsson) Date: 01 Sep 2006 09:03:42 +0200 Subject: Mailing list message size In-Reply-To: <44F74779.8020200@telia.com> References: <44F5EF3A.2020407@telia.com> <44F5F7DA.1060209@hyber.org> <44F74779.8020200@telia.com> Message-ID: There is no content filtering, only filtering on message size. /Bjorn Robert Virding writes: > Claes Wikstom wrote: > > Robert Virding wrote: > > > >> Is there any limitation to the size of a message in the mailing > >> list? I tried to publish the latest Erlog release (much improved) > >> and it quietly vanished into the bit-bucket. And the code is pretty > >> beautiful as well, so it wasn't that. :-) > >> > >> Robert > >> > > Maybe is disappeared due to the funky license you had > > attached to Erlog ? > > Ah, that's because I have been contaminated by the computer gaming > world where there is a shartp distinction between commercial and > non-commercial. Anyway asking them to notify me is not asking too > much, at I don't htink so. Just some common courtesy which is possible > as the Erlang world is not yet so very large. > > I would like to see the filter though. :-) > > Robert > -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From raimo+erlang-questions@REDACTED Fri Sep 1 09:42:44 2006 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Fri, 1 Sep 2006 09:42:44 +0200 Subject: : net_adm:ping not working -- still not answered In-Reply-To: <01d0eb76c8c04c57a117814044713637@cyberplasm.com> References: <01d0eb76c8c04c57a117814044713637@cyberplasm.com> Message-ID: <20060901074244.GA28143@erix.ericsson.se> Well, it should work. Try the following diagnosis: $ erl -sname a $ erl -sname b (a@REDACTED)> erl_epmd:names(). {ok,[{"a",43500},{"b",43505}]} (a@REDACTED)> inet:gethostbyname("my-server"). {ok,{hostent,"my-server",[],inet,4,[{192,168,0,100}]}} (a@REDACTED)> net_adm:ping('b@REDACTED'). pong (a@REDACTED)> nodes(). ['b@REDACTED'] And if that does not work as above try: $ erl -sname a@REDACTED $ erl -sname b@REDACTED (a@REDACTED)> inet:gethostbyname("localhost"). {ok,{hostent,"localhost",[],inet,4,[{127,0,0,1}]}} (a@REDACTED)> erl_epmd:names(). {ok,[{"b",43527},{"a",43530}]} (a@REDACTED)> net_adm:ping('b@REDACTED'). pong (a@REDACTED)> nodes(). ['b@REDACTED'] I am suspecting your machine may have misconfigured network. To make sure the cookie is the same, add the argument -setcookie my-cookie4711 to the command line of both nodes, but if you have the wrong cookie, the target node should print: =ERROR REPORT==== 1-Sep-2006::09:40:06 === ** Connection attempt from disallowed node b@REDACTED ** when net_adm:ping(a@REDACTED) fails. On Thu, Aug 31, 2006 at 09:29:48AM -0700, erlang wrote: > > > > Sorry, this is indeed a typo in my email. Should be: > > (b@REDACTED)1> net_adm:ping('a@REDACTED'). > > > > > > > > Hi, is the colon ":" just a typo in your email? It should be > > > "@" as you can see from the node name in the Erlang shell prompt. > > > > > > Best Regards > > > Lennart > > > > > > > (b@REDACTED)1> net_adm:ping('a:my-server'). > > > > > > > I can't get the ping-pong distributed example to work, so I tried simply > > > > pinging another node. This doesn't work either. > > > > > > > > os: windows server 2003, machine name is my-server. > > > > EShell v5.5.1 > > > > > > > > command lines: erl -sname a > > > > erl -sname b > > > > > > > > (b@REDACTED)1> net_adm:ping('a:my-server'). > > > > > > > > always returns pang. The cookie file is being read, and the cookie is > > > > the same in both nodes. What to try next? > > > > > > > > > > > > > > > > > > > > > > > > > > -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From bjorn@REDACTED Fri Sep 1 09:49:25 2006 From: bjorn@REDACTED (Bjorn Gustavsson) Date: 01 Sep 2006 09:49:25 +0200 Subject: Noob - Getting Started Infinte Loop? In-Reply-To: <200609010414.k814Eg1U298084@atlas.otago.ac.nz> References: <200609010414.k814Eg1U298084@atlas.otago.ac.nz> Message-ID: The old Jam compiler would generate more efficient code if the programmer wrote '_' for variables that were not used. (Variables just prefixed with a '_' were not handled specially.) The Beam compiler (at least from Erlang/OTP R6B) does not need any hints from the programmer about variable usage. In fact, '_' variables are just an annoying special case, so the compiler gets rid of them by giving each one of them a new, unique name. Later, just before code generation, variable life times are calculated. The code generator is guided by the life time information, and doesn't generate any code for assigning a variable that will never be used. /Bjorn "Richard A. O'Keefe" writes: [...] > Note, for example, that in > > f(X, Y) -> [ignore,X,and,Y], g(Y). > > X and Y are both used more than once. However, a compiler could (and I > expect at least HiPE does) notice that [ignore,X,and,Y] doesn't actually > do anything useful, and the code you get might be the same as that for > > f(_, Y) -> g(Y). The Beam compiler does that optimization too. If an expression's value is not used and the expression does not have any side effect, the expression will be removed. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From thomasl_erlang@REDACTED Fri Sep 1 09:57:58 2006 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Fri, 1 Sep 2006 00:57:58 -0700 (PDT) Subject: warn_unused_vars (Was: Re: Noob - Getting Started Infinte Loop?) In-Reply-To: <44F74FFE.4070904@it.uu.se> Message-ID: <20060901075758.22495.qmail@web38811.mail.mud.yahoo.com> --- Richard Carlsson wrote: > Robert Virding wrote: > > Actually this is simple way to get rid of the > annoying whining by the > > compiler, just prepend every variable with _ and > it keeps quiet. :-) > > > > Seriously I would prefer the default to be to keep > quiet. > > Seriously, that would be a bad idea. It catches > _way_ too many errors > (nasty, hard-to-find typo bugs) to be turned off by > default. > > Oh, not in _your_ code, of course. Goes without > saying. ;-) Not in my experience. I have it turned off in my makefiles and aren't having any problems worth mentioning. If we're talking microfeatures, implicit variable matching has been a larger source of bugs, likewise the bizarro-world scoping rules for BIFs. Anyway, since this particular one can be turned off with a compiler switch (+nowarn_unused_vars, Robert), it's not a big problem in my book. Best, Thomas __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From mbj@REDACTED Fri Sep 1 10:35:21 2006 From: mbj@REDACTED (Martin Bjorklund) Date: Fri, 01 Sep 2006 10:35:21 +0200 (CEST) Subject: warn_unused_vars In-Reply-To: <20060901075758.22495.qmail@web38811.mail.mud.yahoo.com> References: <44F74FFE.4070904@it.uu.se> <20060901075758.22495.qmail@web38811.mail.mud.yahoo.com> Message-ID: <20060901.103521.72499322.mbj@tail-f.com> Thomas Lindgren wrote: > > > --- Richard Carlsson wrote: > > > Robert Virding wrote: > > > Actually this is simple way to get rid of the > > annoying whining by the > > > compiler, just prepend every variable with _ and > > it keeps quiet. :-) > > > > > > Seriously I would prefer the default to be to keep > > quiet. > > > > Seriously, that would be a bad idea. It catches > > _way_ too many errors > > (nasty, hard-to-find typo bugs) to be turned off by > > default. > > > > Oh, not in _your_ code, of course. Goes without > > saying. ;-) > > Not in my experience. I have it turned off in my > makefiles and aren't having any problems worth > mentioning. In my experience, this warning catches some real bugs. As a completely arbitrarily, random, example, I'll give an example of some real code from our xpath implementation: eval_axis(attribute, NodeTest, _Preds, Ctx, S, F) -> case NodeTest of %% deleted code to make example smaller {namespace, NS} -> Succ = namespace_test(NS, S), ?ctx:attributes_of(Ctx, S, F); Other -> ?xp_exit(unknown_node_test, Other) end; Now, the compiler warns that the variable Succ is unused. Is this a bug? Probably, b/c the attributes_of/3 function takes a "Succ" as second parameter. /martin From robert.virding@REDACTED Fri Sep 1 10:54:19 2006 From: robert.virding@REDACTED (Robert Virding) Date: Fri, 01 Sep 2006 10:54:19 +0200 Subject: Leex Message-ID: <44F7F53B.5070808@telia.com> OK, here is the leex code. N.B. the generated code is pretty good but leex itself is not of "production quality". Robert -------------- next part -------------- A non-text attachment was scrubbed... Name: leex.zip Type: application/octet-stream Size: 15282 bytes Desc: not available URL: From robert.virding@REDACTED Fri Sep 1 11:03:34 2006 From: robert.virding@REDACTED (Robert Virding) Date: Fri, 01 Sep 2006 11:03:34 +0200 Subject: New release of Erlog - a prolog interpreter written in, and for, Erlang Message-ID: <44F7F766.8030900@telia.com> I have completed a new version of Erlog, and implementation of Prolog in, and for, Erlang. Compared to the old it has the following features: - much improved implementation with a speed-up of 2-10 depending on the application! - much better Prolog parser which is now very close to Standard Prolog. - better Erlang interface which now supports compiled code, though there is no compiler yet. - new continuation based interface as well as the process based one. For free I have also included: - Leex which is used for the Erlog scanner. No documentation but an Erlang scanner is also included as an extra example. It works, producing good code, but the packaging is not yet production quality. - an example efficient ETS interface. Backtracking over ETS wins! I will try to get the code out through the mailing list but it is too big. Leex has been sent separately. Please comment and report bugs, Robert From richardc@REDACTED Fri Sep 1 11:16:36 2006 From: richardc@REDACTED (Richard Carlsson) Date: Fri, 01 Sep 2006 11:16:36 +0200 Subject: warn_unused_vars (Was: Re: Noob - Getting Started Infinte Loop?) In-Reply-To: <20060901075758.22495.qmail@web38811.mail.mud.yahoo.com> References: <20060901075758.22495.qmail@web38811.mail.mud.yahoo.com> Message-ID: <44F7FA74.4010006@it.uu.se> Thomas Lindgren wrote: >> Seriously, that would be a bad idea. It catches _way_ too many >> errors (nasty, hard-to-find typo bugs) to be turned off by default. > > Not in my experience. I have it turned off in my makefiles and aren't > having any problems worth mentioning. Well, it could be because (again)* you're probably only representative of less than a percent of all Erlang programmers. (Well, you are.) Or because you're just not aware of some lurking bugs in your code. When warnings for unused variables were turned on by default a couple of years ago, it shook out a number of bugs that had been hiding in the standard libraries and OTP code for ages. /Richard *Note to newbs and anyone else with less than 10 years' Erlang experience: that Robert Virding and Thomas Lindgren don't find unused-variable warnings all that useful, does *not* mean that you too have a license to turn off the warnings. Really. (For comparison: http://en.wikipedia.org/wiki/Alain_Robert) From vladdu55@REDACTED Fri Sep 1 14:12:27 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Fri, 1 Sep 2006 14:12:27 +0200 Subject: Leex In-Reply-To: <44F7F53B.5070808@telia.com> References: <44F7F53B.5070808@telia.com> Message-ID: <95be1d3b0609010512t5c380b15kbf87d060a7b348b7@mail.gmail.com> On 9/1/06, Robert Virding wrote: > OK, here is the leex code. Cool! I wonder what is the current status of leex, i.e. you plan any major changes or just cleanup. I would like to be able to get more detailed information in the tokens returned (things like column number, offset from the beginning of the file and the full text of the token as it was found in the code). Would it be useful to include that in the main leex, or should I go the way I did for much of the thing I use in erlide: use my own hacked version? best regards, Vlad From jay@REDACTED Fri Sep 1 14:43:13 2006 From: jay@REDACTED (Jay Nelson) Date: Fri, 01 Sep 2006 05:43:13 -0700 Subject: Code generation (was NOOB) Message-ID: <44F82AE1.1080300@duomark.com> Bjorn wrote: > Later, just before code generation, variable life times are > calculated. The code generator is guided by the life time information, > and doesn't generate any code for assigning a variable that > will never be used. Can you describe what happens in the following two cases? foo(X) -> A = [do_something(E) || E <- X], % <1> [do_other(E) || E <- X], % <2> ok. do_something(E) -> E * 4. do_other(E) -> io:write("~w~n", [E]). In 1, does the function 'do_something' every get called? >From your description, A is thrown out and the fun has no side effect. In 2, does a list get created on the stack? If 1 were changed to call 'do_other' would the code be generated differently (because of the side effect)? jay From klacke@REDACTED Fri Sep 1 14:50:54 2006 From: klacke@REDACTED (Claes Wikstrom) Date: Fri, 01 Sep 2006 14:50:54 +0200 Subject: Sun Niagara potential ?? In-Reply-To: <20152BC9-18E1-4C7F-BCA9-B61CC61F16DC@redstarling.com> References: <20152BC9-18E1-4C7F-BCA9-B61CC61F16DC@redstarling.com> Message-ID: <44F82CAE.90400@hyber.org> ke han wrote: > > > If the openSSL lib yaws is indirectly using doesn't "magically" leverage > the on-core acceleration, I will need to dig into the erlang https code > to make it so...any pointers? Earlier crypto accelerators I've used were _sometimes_ directly useable from openssl, given that the right so called "engine" was initialized. See http://www.openssl.org/docs/crypto/engine.html So to get crypto acceleration, the following must be done. 1. make sure the accelerator is supported in openssl libs through --engine. If not, all bets are almost off. 2. Add engine support to otp/lib/ssl/c_src/esock_openssl.c and the ssl:start(). /klacke -- Claes Wikstrom -- Caps lock is nowhere and http://www.hyber.org -- everything is under control cellphone: +46 70 2097763 From bjorn@REDACTED Fri Sep 1 15:46:09 2006 From: bjorn@REDACTED (Bjorn Gustavsson) Date: 01 Sep 2006 15:46:09 +0200 Subject: Code generation (was NOOB) In-Reply-To: <44F82AE1.1080300@duomark.com> References: <44F82AE1.1080300@duomark.com> Message-ID: The compiler will not optimize away anything in this case, for several reasons. 1. The optimizations are fairly conservative. The compiler doesn't even try to optimize away list comprehensions. Earlier versions of the compiler tried to optimize bit syntax constructions that weren't used, but bitten by bugs we don't try that anymore. (The unoptimized version would cause a badarg, and the optimized version would not.) 2. In this case, do_something(E) will fail with a badarith exception if E is not an integer, so it would not be safe to remove the call, even if the compiler would attempt to look inside a list comprehension. Also, X might not be a list, in which case there should be an exception generated. 3. In the case of the do_other/1 function, it calls a function in another module, so the compiler has no idea whether is it is safe to remove the call. We have considered improving the optimization, so that no list would be built in case 2. /Bjorn Jay Nelson writes: > Bjorn wrote: > > > Later, just before code generation, variable life times are > > calculated. The code generator is guided by the life time information, > > and doesn't generate any code for assigning a variable that > > will never be used. > > Can you describe what happens in the following two cases? > > foo(X) -> > A = [do_something(E) || E <- X], % <1> > [do_other(E) || E <- X], % <2> > ok. > > do_something(E) -> E * 4. > > do_other(E) -> io:write("~w~n", [E]). > > > In 1, does the function 'do_something' every get called? > >From your description, A is thrown out and the fun has no > side effect. > > In 2, does a list get created on the stack? > > If 1 were changed to call 'do_other' would the code be > generated differently (because of the side effect)? > > jay > > -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From Martin.Logan@REDACTED Fri Sep 1 17:30:17 2006 From: Martin.Logan@REDACTED (Logan, Martin) Date: Fri, 1 Sep 2006 10:30:17 -0500 Subject: Tutorial Signup Sheet is now up Message-ID: <9CB79C836F98504C81BF082C4291E987792B5D@CHITDSEXC02.tds.corp.cendant.org> I have created a tutorial signup sheet which can be found at http://wiki.trapexit.org/index.php/Category:HowToSignup I have included all the tutorials collected over the last couple of weeks; all known erlang tutorials. It really is quite a lot of information. Please have a look and do 3 things: 1. If you wrote a tutorial indicate whether it is ok for someone besides yourself to put it into the trap exit format. Do this by putting a "Y" in the column labeled o+w 2. Sign up and transcribe one of the tutorials - either your own, or one of the publicly editable ones. 3. Rejoice at the sight of all the glorious erlang knowledge before you. Also, I have tried to include author information where ever possible, if you wrote one of the tutorials that is missing author information be sure to edit the page and give yourself the credit. See you all in Portland, Martin -------------- next part -------------- An HTML attachment was scrubbed... URL: From erlangist@REDACTED Fri Sep 1 17:37:50 2006 From: erlangist@REDACTED (lang er) Date: Fri, 1 Sep 2006 23:37:50 +0800 Subject: New release of Erlog - a prolog interpreter written in, and for, Erlang In-Reply-To: <44F7F766.8030900@telia.com> References: <44F7F766.8030900@telia.com> Message-ID: <230465c00609010837m37a5081fkbd7e2532cb5c809d@mail.gmail.com> cool! So why not setup a project on sourceforge or google? and for now how can I get the code? Best Regard! james 2006/9/1, Robert Virding : > > I have completed a new version of Erlog, and implementation of Prolog > in, and for, Erlang. Compared to the old it has the following features: > > - much improved implementation with a speed-up of 2-10 depending on the > application! > - much better Prolog parser which is now very close to Standard Prolog. > - better Erlang interface which now supports compiled code, though there > is no compiler yet. > - new continuation based interface as well as the process based one. > > For free I have also included: > > - Leex which is used for the Erlog scanner. No documentation but an > Erlang scanner is also included as an extra example. It works, > producing good code, but the packaging is not yet production quality. > - an example efficient ETS interface. Backtracking over ETS wins! > > I will try to get the code out through the mailing list but it is too > big. Leex has been sent separately. Please comment and report bugs, > > Robert > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dot@REDACTED Fri Sep 1 19:16:06 2006 From: dot@REDACTED (Tony Finch) Date: Fri, 1 Sep 2006 18:16:06 +0100 Subject: Erlang downsides? In-Reply-To: References: <44F1BB02.3080101@gmail.com> Message-ID: On Thu, 31 Aug 2006, James Hague wrote: > > Exactly. And other dynamic languages--including Ruby and > Python--simply link to the standard Perl regular expression library. There is no "standard" Perl regex library. There is PCRE, but that is an independent re-implementation of Perl's regexes because it isn't feasible to decouple perl's regex implementation from the rest of perl. AFAIK the only scripting languages that currently use PCRE are PHP and perl6 (where PCRE is used for perl5 backwards compatibility). Tony. -- f.a.n.finch http://dotat.at/ FISHER: WEST OR NORTHWEST 4 OR 5 BECOMING VARIABLE 3 OR 4. FAIR. MODERATE OR GOOD. From luke@REDACTED Fri Sep 1 19:31:21 2006 From: luke@REDACTED (Luke Gorrie) Date: Fri, 01 Sep 2006 19:31:21 +0200 Subject: Lisp-Python vs. Erlang References: <44EE5B07.30605@duomark.com> Message-ID: "James Hague" writes: > "I think in particular of Lisp, which is the most beautiful language > in the world, and every program in lisp is real ugly." Interesting! I find that Lisp programs are the only ones that I can usually enjoy printing and reading on a bus ride home. They tend to be written for reading. From erlang@REDACTED Fri Sep 1 19:54:35 2006 From: erlang@REDACTED (erlang) Date: Fri, 1 Sep 2006 10:54:35 -0700 Subject: : net_adm:ping not working -- still not answered Message-ID: <063c82fa71b2423c8d306271c0344b01@cyberplasm.com> Yes, you have shown the tests I am using, very simple cases. But I get pangs, and timeouts. I agree it is probably due to a misconfigured network. What I have is one Windows Server 2003 sp1 machine that is setup for a peer-to-peer workgroup, with no local dns server, domain controller, etc. I agree that my problem is most likely a network configuration that is not Erlang friendly. I couldn't find a prerequisites list for Erlang so I'm not sure what it needs. I have used many applications that have no problem opening ports on localhost. > > Well, it should work. > > Try the following diagnosis: > > $ erl -sname a > $ erl -sname b > > (a@REDACTED)> erl_epmd:names(). > {ok,[{"a",43500},{"b",43505}]} > (a@REDACTED)> inet:gethostbyname("my-server"). > {ok,{hostent,"my-server",[],inet,4,[{192,168,0,100}]}} > (a@REDACTED)> net_adm:ping('b@REDACTED'). > pong > (a@REDACTED)> nodes(). > ['b@REDACTED'] > > > And if that does not work as above try: > > $ erl -sname a@REDACTED > $ erl -sname b@REDACTED > > (a@REDACTED)> inet:gethostbyname("localhost"). > {ok,{hostent,"localhost",[],inet,4,[{127,0,0,1}]}} > (a@REDACTED)> erl_epmd:names(). > {ok,[{"b",43527},{"a",43530}]} > (a@REDACTED)> net_adm:ping('b@REDACTED'). > pong > (a@REDACTED)> nodes(). > ['b@REDACTED'] > > > I am suspecting your machine may have misconfigured network. > > To make sure the cookie is the same, add the argument > -setcookie my-cookie4711 > to the command line of both nodes, but if you have the wrong cookie, > the target node should print: > =ERROR REPORT==== 1-Sep-2006::09:40:06 === > ** Connection attempt from disallowed node b@REDACTED ** > when net_adm:ping(a@REDACTED) fails. > > > > On Thu, Aug 31, 2006 at 09:29:48AM -0700, erlang wrote: > > > > > > Sorry, this is indeed a typo in my email. Should be: > > > (b@REDACTED)1> net_adm:ping('a@REDACTED'). > > > > > > > > > > > Hi, is the colon ":" just a typo in your email? It should be > > > > "@ you can see from the node name in the Erlang shell prompt. > > > > > > > > Best Regards > > > > Lennart > > > > > > > > > (b@REDACTED)1> net_adm:ping('a:my-server'). > > > > > > > > > I can't get the ping-pong distributed example to work, so I tried simply > > > > > pinging another node. This doesn't work either. > > > > > > > > > > os: windows server 2003, machine name is my-server. > > > > > EShell v5.5.1 > > > > > > > > > > command lines: erl -sname a > > > > > erl -sname b > > > > > > > > > > (b@REDACTED)1> net_adm:ping('a:my-server'). > > > > > > > > > > always returns pang. The cookie file is being read, and the cookie is > > > > > the same in both nodes. What to try next? > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -- > > / Raimo Niskanen, Erlang/OTP, Ericsson AB From erlangX@REDACTED Fri Sep 1 20:27:33 2006 From: erlangX@REDACTED (Michael McDaniel) Date: Fri, 1 Sep 2006 11:27:33 -0700 Subject: : net_adm:ping not working -- still not answered In-Reply-To: <063c82fa71b2423c8d306271c0344b01@cyberplasm.com> References: <063c82fa71b2423c8d306271c0344b01@cyberplasm.com> Message-ID: <20060901182733.GF7054@delora.autosys.us> Does the following work? C:\> ping localhost C:\> ping my-server If no, get them working before delving into the erlang ping. If yes, hmmm. Not certain though maybe my-server hostname should be changed to myserver (possibly the dash is problematic). ~M On Fri, Sep 01, 2006 at 10:54:35AM -0700, erlang wrote: > Yes, you have shown the tests I am using, very simple cases. > But I get pangs, and timeouts. > > I agree it is probably due to a misconfigured network. What I have > is one Windows Server 2003 sp1 machine that is setup for a > peer-to-peer workgroup, with no local dns server, domain controller, > etc. I agree that my problem is most likely a network configuration > that is not Erlang friendly. I couldn't find a prerequisites list for Erlang > so I'm not sure what it needs. I have used many applications that have no > problem opening ports on localhost. > > > > > > Well, it should work. > > > > Try the following diagnosis: > > > > $ erl -sname a > > $ erl -sname b > > > > (a@REDACTED)> erl_epmd:names(). > > {ok,[{"a",43500},{"b",43505}]} > > (a@REDACTED)> inet:gethostbyname("my-server"). > > {ok,{hostent,"my-server",[],inet,4,[{192,168,0,100}]}} > > (a@REDACTED)> net_adm:ping('b@REDACTED'). > > pong > > (a@REDACTED)> nodes(). > > ['b@REDACTED'] > > > > > > And if that does not work as above try: > > > > $ erl -sname a@REDACTED > > $ erl -sname b@REDACTED > > > > (a@REDACTED)> inet:gethostbyname("localhost"). > > {ok,{hostent,"localhost",[],inet,4,[{127,0,0,1}]}} > > (a@REDACTED)> erl_epmd:names(). > > {ok,[{"b",43527},{"a",43530}]} > > (a@REDACTED)> net_adm:ping('b@REDACTED'). > > pong > > (a@REDACTED)> nodes(). > > ['b@REDACTED'] > > > > > > I am suspecting your machine may have misconfigured network. > > > > To make sure the cookie is the same, add the argument > > -setcookie my-cookie4711 > > to the command line of both nodes, but if you have the wrong cookie, > > the target node should print: > > =ERROR REPORT==== 1-Sep-2006::09:40:06 === > > ** Connection attempt from disallowed node b@REDACTED ** > > when net_adm:ping(a@REDACTED) fails. > > > > > > > > On Thu, Aug 31, 2006 at 09:29:48AM -0700, erlang wrote: > > > > > > > > Sorry, this is indeed a typo in my email. Should be: > > > > (b@REDACTED)1> net_adm:ping('a@REDACTED'). > > > > > > > > > > > > > > Hi, is the colon ":" just a typo in your email? It should be > > > > > "@ > you can see from the node name in the Erlang shell prompt. > > > > > > > > > > Best Regards > > > > > Lennart > > > > > > > > > > > (b@REDACTED)1> net_adm:ping('a:my-server'). > > > > > > > > > > > I can't get the ping-pong distributed example to work, so I tried simply > > > > > > pinging another node. This doesn't work either. > > > > > > > > > > > > os: windows server 2003, machine name is my-server. > > > > > > EShell v5.5.1 > > > > > > > > > > > > command lines: erl -sname a > > > > > > erl -sname b > > > > > > > > > > > > (b@REDACTED)1> net_adm:ping('a:my-server'). > > > > > > > > > > > > always returns pang. The cookie file is being read, and the cookie is > > > > > > the same in both nodes. What to try next? > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > > / Raimo Niskanen, Erlang/OTP, Ericsson AB > > > -- Michael McDaniel Portland, Oregon, USA http://autosys.us +1 503 283 5284 From joelr1@REDACTED Fri Sep 1 20:42:32 2006 From: joelr1@REDACTED (Joel Reymont) Date: Fri, 1 Sep 2006 19:42:32 +0100 Subject: Sun Niagara potential ?? In-Reply-To: <20152BC9-18E1-4C7F-BCA9-B61CC61F16DC@redstarling.com> References: <20152BC9-18E1-4C7F-BCA9-B61CC61F16DC@redstarling.com> Message-ID: On Sep 1, 2006, at 7:05 AM, ke han wrote: > I will be testing yaws on a T1000 in a week or so. I should be on the T1000 in a week or so as well. Then I will have a chance to see how my Erlang app app behaves on a T2100 and then compare against AMD. My goal would be to tune Erlang and my app to run on the Niagara. Joel -- http://wagerlabs.com/ From erlang@REDACTED Fri Sep 1 21:14:16 2006 From: erlang@REDACTED (erlang) Date: Fri, 1 Sep 2006 12:14:16 -0700 Subject: : net_adm:ping not working -- still not answered Message-ID: <56fb20fdeee2499ebb1a4b14578cfdd5@cyberplasm.com> pings work ok. My system runs everything I have ever thrown at it. cygwin, mysql, sql server, perl and php apps, anything that opens local ports for sommunication -- all perfect until now with Erlang. I tried taking out the dash in the computer name, it makes no difference. > Does the following work? > > C:\> ping localhost > C:\> ping my-server > > > If no, get them working before delving into the erlang ping. > If yes, hmmm. Not certain though maybe my-server hostname > should be changed to myserver (possibly the dash is problematic). > > > ~M > > On Fri, Sep 01, 2006 at 10:54:35AM -0700, erlang wrote: > > Yes, you have shown the tests I am using, very simple cases. > > But I get pangs, and timeouts. > > > > I agree it is probably due to a misconfigured network. What I have > > is one Windows Server 2003 sp1 machine that is setup for a > > peer-to-peer workgroup, with no local dns server, domain controller, > > etc. I agree that my problem is most likely a network configuration > > that is not Erlang friendly. I couldn't find a prerequisites list for Erlang > > so I'm not sure what it needs. I have used many applications that have no > > problem opening ports on localhost. > > > > > > > > > > Well, it should work. > > > > > > Try the following diagnosis: > > > > > > $ erl -sname a > > > $ erl -sname b > > > > > > (a@REDACTED)> erl_epmd:names(). > > > {ok,[{"a",43500},{"b",43505}]} > > > (a@REDACTED)> inet:gethostbyname("my-server"). > > > {ok,{hostent,"my-server",[],inet,4,[{192,168,0,100}]}} > > > (a@REDACTED)> net_adm:ping('b@REDACTED'). > > > pong > > > (a@REDACTED)> nodes(). > > > ['b@REDACTED'] > > > > > > > > > And if that does not work as above try: > > > > > > $ erl -sname a@REDACTED > > > $ erl -sname b@REDACTED > > > > > > (a@REDACTED)> inet:gethostbyname("localhost"). > > > {ok,{hostent,"localhost",[],inet,4,[{127,0,0,1}]}} > > > (a@REDACTED)> erl_epmd:names(). > > > {ok,[{"b",43527},{"a",43530}]} adm:ping('b@REDACTED'). > > > pong > > > (a@REDACTED)> nodes(). > > > ['b@REDACTED'] > > > > > > > > > I am suspecting your machine may have misconfigured network. > > > > > > To make sure the cookie is the same, add the argument > > > -setcookie my-cookie4711 > > > to the command line of both nodes, but if you have the wrong cookie, > > > the target node should print: > > > =ERROR REPORT==== 1-Sep-2006::09:40:06 === > > > ** Connection attempt from disallowed node b@REDACTED ** > > > when net_adm:ping(a@REDACTED) fails. > > > > > > > > > > > > On Thu, Aug 31, 2006 at 09:29:48AM -0700, erlang wrote: > > > > > > > > > > Sorry, this is indeed a typo in my email. Should be: > > > > > (b@REDACTED)1> net_adm:ping('a@REDACTED'). > > > > > > > > > > > > > > > > > Hi, is the colon ":" just a typo in your email? It should be > > > > > > "@ > > you can see from the node name in the Erlang shell prompt. > > > > > > > > > > > > Best Regards > > > > > > Lennart > > > > > > > > > > > > > (b@REDACTED)1> net_adm:ping('a:my-server'). > > > > > > > > > > > > > I can't get the ping-pong distributed example to work, so I tried simply > > > > > > > pinging another node. This doesn't work either. > > > > > > > > > > > > > > os: windows server 2003, machine name is my-server. > > > > > > > EShell v5.5.1 > > > > > > > > > > > > > > command lines: erl -sname a > > > > > > > erl -sname b > > > > > > > > > > > > > > (b@REDACTED)1> net_adm:ping('a:my-server'). > > > > > > > > > > > > > > always returns pang. The cookie file is being read, and the cookie is > > > > > > > the same in both nodes. What to try next? > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > > > > / Raimo Niskanen, Erlang/OTP, Ericsson AB > > > > > > > > -- > Michael McDaniel > Portland, Oregon, USA > http://autosys.us > +1 503 283 5284 From bob@REDACTED Fri Sep 1 21:39:54 2006 From: bob@REDACTED (Bob Ippolito) Date: Fri, 1 Sep 2006 12:39:54 -0700 Subject: Working with large binaries in the interpreter Message-ID: <6a36e7290609011239m7ae80b93o4ee152ad5bc43a13@mail.gmail.com> I'm writing an application that has a large (database) file that it keeps as a binary in memory (24.54M). Normally I would use something like mmap for this purpose, but I haven't found a similar facility in Erlang. The problem is whenever I get a traceback with that binary on the stack or otherwise end up with a printed representation of the binary at the interpreter, memory usage grows enormously and it doesn't go down. If this happens more than once, I start swapping. Is there anything I can do about this? It's really difficult to debug when I have to kill beam at any error. Also, the binary size seems suspiciously high. There should be exactly one 25737850 byte (24.54M) binary, but there's 16271355 bytes (15.5M) unaccounted for. It should not be a view on a larger binary, because that binary is the entire file uncompressed. (This is Erlang/OTP R11B-0 on Mac OS X 10.4 intel) Erlang (BEAM) emulator version 5.5 [source] [async-threads:0] Eshell V5.5 (abort with ^G) 1> erlang:memory(). [{total,2799855}, {processes,346118}, {processes_used,340190}, {system,2453737}, {atom,213345}, {atom_used,197118}, {binary,62460}, {code,1594800}, {ets,108032}] 2> {ok, D} = egeoip:new(), garbage_collect(). true 3> erlang:memory(). [{total,44853447}, {processes,315186}, {processes_used,309258}, {system,44538261}, {atom,216649}, {atom_used,201683}, {binary,42071665}, {code,1664475}, {ets,110372}] 4> 42071665 - 62460 - size(element(5, D)). 16271355 5> D. garbage_collect(). {geoipdb,2, 3, 3576103, <<1,0,0,107,0,0,2,0,0,60,0,0,3,0,0,30,0,0,4,0,0,18,0,...>>, "/Users/bob/src/egeoip/priv/GeoLiteCity.dat.gz"} 6> garbage_collect(). true 7> erlang:memory(). [{total,489893135}, {processes,445361822}, {processes_used,445355894}, {system,44531313}, {atom,216649}, {atom_used,201683}, {binary,42064717}, {code,1664475}, {ets,110372}] Why did processes grow by 445046636 bytes (424.43M) after printing that representation?! -bob From james.hague@REDACTED Fri Sep 1 21:48:03 2006 From: james.hague@REDACTED (James Hague) Date: Fri, 1 Sep 2006 14:48:03 -0500 Subject: Erlang downsides? In-Reply-To: References: <44F1BB02.3080101@gmail.com> Message-ID: > There is no "standard" Perl regex library. There is PCRE, but that is an > independent re-implementation of Perl's regexes because it isn't feasible > to decouple perl's regex implementation from the rest of perl. AFAIK the > only scripting languages that currently use PCRE are PHP and perl6 (where > PCRE is used for perl5 backwards compatibility). I meant PCRE. It's still used by Io, J, CMUCL, and Lua, to name a few, though it's an option in some of those languages (that is, there are multiple regex packages to choose from). And it was standard in Python for a while (but no more). In any case, I am glad that the regular expression module for Erlang isn't as over-the-top insane as regular expressions in Perl. James From serge@REDACTED Fri Sep 1 21:48:45 2006 From: serge@REDACTED (Serge Aleynikov) Date: Fri, 01 Sep 2006 15:48:45 -0400 Subject: : net_adm:ping not working -- still not answered In-Reply-To: <56fb20fdeee2499ebb1a4b14578cfdd5@cyberplasm.com> References: <56fb20fdeee2499ebb1a4b14578cfdd5@cyberplasm.com> Message-ID: <44F88E9D.2010500@hq.idt.net> Try to add IPs of these hosts to your hosts file in: C:\WINDOWS\system32\drivers\etc\ Serge erlang wrote: > pings work ok. My system runs everything I have ever thrown at > it. cygwin, mysql, sql server, perl and php apps, anything that > opens local ports for sommunication -- all perfect until now with Erlang. > > I tried taking out the dash in the computer name, > it makes no difference. > > >> Does the following work? >> >> C:\> ping localhost >> C:\> ping my-server >> >> >> If no, get them working before delving into the erlang ping. >> If yes, hmmm. Not certain though maybe my-server hostname >> should be changed to myserver (possibly the dash is problematic). >> >> >> ~M >> >> On Fri, Sep 01, 2006 at 10:54:35AM -0700, erlang wrote: >>> Yes, you have shown the tests I am using, very simple cases. >>> But I get pangs, and timeouts. >>> >>> I agree it is probably due to a misconfigured network. What I have >>> is one Windows Server 2003 sp1 machine that is setup for a >>> peer-to-peer workgroup, with no local dns server, domain controller, >>> etc. I agree that my problem is most likely a network configuration >>> that is not Erlang friendly. I couldn't find a prerequisites list for Erlang >>> so I'm not sure what it needs. I have used many applications that have no >>> problem opening ports on localhost. >>> >>> >>>> Well, it should work. >>>> >>>> Try the following diagnosis: >>>> >>>> $ erl -sname a >>>> $ erl -sname b >>>> >>>> (a@REDACTED)> erl_epmd:names(). >>>> {ok,[{"a",43500},{"b",43505}]} >>>> (a@REDACTED)> inet:gethostbyname("my-server"). >>>> {ok,{hostent,"my-server",[],inet,4,[{192,168,0,100}]}} >>>> (a@REDACTED)> net_adm:ping('b@REDACTED'). >>>> pong >>>> (a@REDACTED)> nodes(). >>>> ['b@REDACTED'] >>>> >>>> >>>> And if that does not work as above try: >>>> >>>> $ erl -sname a@REDACTED >>>> $ erl -sname b@REDACTED >>>> >>>> (a@REDACTED)> inet:gethostbyname("localhost"). >>>> {ok,{hostent,"localhost",[],inet,4,[{127,0,0,1}]}} >>>> (a@REDACTED)> erl_epmd:names(). >>>> {ok,[{"b",43527},{"a",43530}]} > adm:ping('b@REDACTED'). >>>> pong >>>> (a@REDACTED)> nodes(). >>>> ['b@REDACTED'] >>>> >>>> >>>> I am suspecting your machine may have misconfigured network. >>>> >>>> To make sure the cookie is the same, add the argument >>>> -setcookie my-cookie4711 >>>> to the command line of both nodes, but if you have the wrong cookie, >>>> the target node should print: >>>> =ERROR REPORT==== 1-Sep-2006::09:40:06 === >>>> ** Connection attempt from disallowed node b@REDACTED ** >>>> when net_adm:ping(a@REDACTED) fails. >>>> >>>> >>>> >>>> On Thu, Aug 31, 2006 at 09:29:48AM -0700, erlang wrote: >>>>>> Sorry, this is indeed a typo in my email. Should be: >>>>>> (b@REDACTED)1> net_adm:ping('a@REDACTED'). >>>>>> >>>>>>> Hi, is the colon ":" just a typo in your email? It should be >>>>>>> "@ >>> you can see from the node name in the Erlang shell prompt. >>>>>>> Best Regards >>>>>>> Lennart >>>>>>> >>>>>>>> (b@REDACTED)1> net_adm:ping('a:my-server'). >>>>>>>> I can't get the ping-pong distributed example to work, so I tried simply >>>>>>>> pinging another node. This doesn't work either. >>>>>>>> >>>>>>>> os: windows server 2003, machine name is my-server. >>>>>>>> EShell v5.5.1 >>>>>>>> >>>>>>>> command lines: erl -sname a >>>>>>>> erl -sname b >>>>>>>> >>>>>>>> (b@REDACTED)1> net_adm:ping('a:my-server'). >>>>>>>> >>>>>>>> always returns pang. The cookie file is being read, and the cookie is >>>>>>>> the same in both nodes. What to try next? From ulf@REDACTED Fri Sep 1 22:07:45 2006 From: ulf@REDACTED (Ulf Wiger) Date: Fri, 01 Sep 2006 22:07:45 +0200 Subject: New release of Erlog - a prolog interpreter written in, and for, Erlang In-Reply-To: <44F7F766.8030900@telia.com> References: <44F7F766.8030900@telia.com> Message-ID: Den 2006-09-01 11:03:34 skrev Robert Virding : > I have completed a new version of Erlog, and implementation of Prolog > in, and for, Erlang. Compared to the old it has the following features: > [...] > > I will try to get the code out through the mailing list but it is too > big. You could log into trap exit and upload it as a user contribution. http://forum.trapexit.org/viewforum.php?f=20 BR, Ulf W -- Ulf Wiger From erlang@REDACTED Fri Sep 1 22:13:06 2006 From: erlang@REDACTED (erlang) Date: Fri, 1 Sep 2006 13:13:06 -0700 Subject: : net_adm:ping not working -- resolved Message-ID: <8fece7a8edc745978aa7d7d00cadfa4e@cyberplasm.com> Thanks to all for replies. Fix was to turn on the windows service: DNS Client I had it disabled for some reason. > > Try to add IPs of these hosts to your hosts file in: > > C:\WINDOWS\system32\drivers\etc\ > > Serge > > erlang wrote: > > pings work ok. My system runs everything I have ever thrown at > > it. cygwin, mysql, sql server, perl and php apps, anything that > > opens local ports for sommunication -- all perfect until now with Erlang. > > > > I tried taking out the dash in the computer name, > > it makes no difference. > > > > > >> Does the following work? > >> > >> C:\> ping localhost > >> C:\> ping my-server > >> > >> > >> If no, get them working before delving into the erlang ping. > >> If yes, hmmm. Not certain though maybe my-server hostname > >> should be changed to myserver (possibly the dash is problematic). > >> > >> > >> ~M > >> > >> On Fri, Sep 01, 2006 at 10:54:35AM -0700, erlang wrote: > >>> Yes, you have shown the tests I am using, very simple cases. > >>> But I get pangs, and timeouts. > >>> > >>> I agree it is probably due to a misconfigured network. What I have > >>> is one Windows Server 2003 sp1 machine that is setup for a > >>> peer-to-peer workgroup, with no local dns server, domain controller, > >>> etc. I agree that my problem is most likely a network configuration > >>> that is not Erlang friendly. I couldn't find a prerequisites list for Erlang > >>> so I'm not sure what it needs. I have used many applications that have no > >>> problem opening ports on localhost. > >>> > >>> > >>>> Well, it should work. > >>>> > >>>> Try the following diagnosis: > >>>> > >>>> $ erl -sname a > >>>> $ erl -sname b > >>>> > >>>> (a@REDACTED)> erl_epmd:names(). > >>>> {ok,[{"a",43500},{"b",43505}]} > >>>> (a@REDACTED)> inet:gethostbyname("my-server"). > >>>> {ok,{hostent,"my-server",[],inet,4,[{192,168,0,100}]}} > >>>> (a@REDACTED)> net_adm:ping('b@REDACTED'). > >>>> pong > >>>> (a@REDACTED)> nodes(). > >>>> [' > > >>>> > >>>> And if that does not work as above try: > >>>> > >>>> $ erl -sname a@REDACTED > >>>> $ erl -sname b@REDACTED > >>>> > >>>> (a@REDACTED)> inet:gethostbyname("localhost"). > >>>> {ok,{hostent,"localhost",[],inet,4,[{127,0,0,1}]}} > >>>> (a@REDACTED)> erl_epmd:names(). > >>>> {ok,[{"b",43527},{"a",43530}]} > > adm:ping('b@REDACTED'). > >>>> pong > >>>> (a@REDACTED)> nodes(). > >>>> ['b@REDACTED'] > >>>> > >>>> > >>>> I am suspecting your machine may have misconfigured network. > >>>> > >>>> To make sure the cookie is the same, add the argument > >>>> -setcookie my-cookie4711 > >>>> to the command line of both nodes, but if you have the wrong cookie, > >>>> the target node should print: > >>>> =ERROR REPORT==== 1-Sep-2006::09:40:06 === > >>>> ** Connection attempt from disallowed node b@REDACTED ** > >>>> when net_adm:ping(a@REDACTED) fails. > >>>> > >>>> > >>>> > >>>> On Thu, Aug 31, 2006 at 09:29:48AM -0700, erlang wrote: > >>>>>> Sorry, this is indeed a typo in my email. Should be: > >>>>>> (b@REDACTED)1> net_adm:ping('a@REDACTED'). > >>>>>> > >>>>>>> Hi, is the colon ":" just a typo in your email? It should be > >>>>>>> "@ > >>> you can see from the node name in the Erlang shell prompt. > >>>>>>> Best Regards > >>>>>>> Lennart > >>>>>>> > >>>>>>>> (b@REDACTED)1> net_adm:ping('a:my-server'). > >>>>>>>> I can't get the ping-pong distributed example to work, so I tried simply > >>>>>>>> pinging another node. This doesn't work either. > >>>>>>>> > >>>>>>>> os: windows server 2003, machine name is my-server. > >>>>>>>> EShell v5.5.1 > >>>>>>>> > >>>>>>>> command lines: erl -sname a > >>>>>>>> erl -sname b > >>>>>>>> > >>>>>>>> (b@REDACTED)1> net_adm:ping('a:my-server'). > >>>>>>>> > >>>>>>>> always returns pang. The cookie file is being read, and the cookie is > >>>>>>>> the same in both nodes. What to try next? From bob@REDACTED Fri Sep 1 22:29:35 2006 From: bob@REDACTED (Bob Ippolito) Date: Fri, 1 Sep 2006 13:29:35 -0700 Subject: Working with large binaries in the interpreter In-Reply-To: <6a36e7290609011239m7ae80b93o4ee152ad5bc43a13@mail.gmail.com> References: <6a36e7290609011239m7ae80b93o4ee152ad5bc43a13@mail.gmail.com> Message-ID: <6a36e7290609011329j3829adcdud4fc3c3427ed5f86@mail.gmail.com> On 9/1/06, Bob Ippolito wrote: > I'm writing an application that has a large (database) file that it > keeps as a binary in memory (24.54M). Normally I would use something > like mmap for this purpose, but I haven't found a similar facility in > Erlang. > > The problem is whenever I get a traceback with that binary on the > stack or otherwise end up with a printed representation of the binary > at the interpreter, memory usage grows enormously and it doesn't go > down. If this happens more than once, I start swapping. Is there > anything I can do about this? It's really difficult to debug when I > have to kill beam at any error. > > Also, the binary size seems suspiciously high. There should be exactly > one 25737850 byte (24.54M) binary, but there's 16271355 bytes (15.5M) > unaccounted for. It should not be a view on a larger binary, because > that binary is the entire file uncompressed. > > (This is Erlang/OTP R11B-0 on Mac OS X 10.4 intel) > > Erlang (BEAM) emulator version 5.5 [source] [async-threads:0] > > Eshell V5.5 (abort with ^G) > 1> erlang:memory(). > [{total,2799855}, > {processes,346118}, > {processes_used,340190}, > {system,2453737}, > {atom,213345}, > {atom_used,197118}, > {binary,62460}, > {code,1594800}, > {ets,108032}] > 2> {ok, D} = egeoip:new(), garbage_collect(). > true > 3> erlang:memory(). > [{total,44853447}, > {processes,315186}, > {processes_used,309258}, > {system,44538261}, > {atom,216649}, > {atom_used,201683}, > {binary,42071665}, > {code,1664475}, > {ets,110372}] > 4> 42071665 - 62460 - size(element(5, D)). > 16271355 > 5> D. garbage_collect(). > {geoipdb,2, > 3, > 3576103, > <<1,0,0,107,0,0,2,0,0,60,0,0,3,0,0,30,0,0,4,0,0,18,0,...>>, > "/Users/bob/src/egeoip/priv/GeoLiteCity.dat.gz"} > 6> garbage_collect(). > true > 7> erlang:memory(). > [{total,489893135}, > {processes,445361822}, > {processes_used,445355894}, > {system,44531313}, > {atom,216649}, > {atom_used,201683}, > {binary,42064717}, > {code,1664475}, > {ets,110372}] > > Why did processes grow by 445046636 bytes (424.43M) after printing > that representation?! The leak can also be reproduced with io:fwrite("~P~n", [D, 24]). It appears to be a bug in io_lib_pretty, where it unconditionally decides to use binary_to_list(B) even when it is going to truncate. It should be using binary_to_list/3 if size(B) > D... so it ends up creating an enormous list. I'm not sure why this leaks memory, but that's where it appears to be going. Doing results(0) and forgetting the binding for D does not make any difference. It will free the 25M binary from the binaries table, but it doesn't affect the processes table nor does it get rid of the 16M in the binaries table that is unaccounted for... I will try upgrading to R11B-1 (because I want to try the HiPE patches for Mac OS X x86 anyway) and then put together a patch for the issue. -bob From chandrashekhar.mullaparthi@REDACTED Fri Sep 1 23:39:56 2006 From: chandrashekhar.mullaparthi@REDACTED (Chandru) Date: Fri, 1 Sep 2006 22:39:56 +0100 Subject: how to use a specific host alias for node name? In-Reply-To: <2006083112311157041905@k2.sage.att.com> References: <2006083112311157041905@k2.sage.att.com> Message-ID: On 31/08/06, Garry Hodgson wrote: > > in our application, a master server has a list of nodes > that it can use for computation. in principle, we'd like > the machines named node1, node2, ...nodeN, so the nodes > would be node@REDACTED@nodeN. but some of our > installations have their own naming conventions for machines. > adding aliases in /etc/hosts doesn't help. so we resort to a > config file, which seems kind of klunky. is there a way to cause the nodes to come up using a specific > host alias? You can do 'erl -sname node@REDACTED' on node1 or better yet, is there a better way for the master to find > out who's out there? the nodes check in when they come up, > but this won't help if they're already up when master starts. I guess you'd need some kind of discovery protocol. Maybe the slaves can broadcast a 'is there a master' message periodically until they find one? The master could also broadcast a message when it is up so that slaves receive it and register themselves. cheers Chandru -------------- next part -------------- An HTML attachment was scrubbed... URL: From jacobopolavieja@REDACTED Sat Sep 2 05:35:07 2006 From: jacobopolavieja@REDACTED (Jacobo G. Polavieja) Date: Sat, 02 Sep 2006 05:35:07 +0200 Subject: Why do OS not support erlang's lightweight process? In-Reply-To: References: <230465c00608281520m3b38c5efy20375f1f52ba3240@mail.gmail.com> Message-ID: <44F8FBEB.1080202@gmail.com> Tony Finch wrote: > On Tue, 29 Aug 2006, lang er wrote: > >> If OS support erlang's lightweight process in kernel, many programming >> languages could have erlang's concurrent capability.I think it is not >> impossible. > > The reason that Erlang processes are lightweight is that they do not > require a context switch from userland -> kernel -> userland in order to > schedule the next thread. Erlang can rely on the properties of the > language, specifically no shared mutable data, in order to isolate > processes from each other. The kernel must use the CPU's virtual memory > support to do this, because it cannot make assumptions about the languages > used to write userland processes, and switching pages tables is expensive. > > There have been some experiments with single-address-space operating > systems, which should in principle be able to context switch faster (they > only need to change the page table access rights, not the virtual -> real > address mapping) but current CPUs are not optimised for this kind of > design, so it isn't an advantage in practice. It also requires a 64 bit > address space to be practical. > > Tony. And wouldn't it be possible to implement a similar threading system in other VM like, say, CLR (Mono VM)? There lots of base differences from the Mono Framework to Erlang, but maybe it's easier to implement more effective ways of concurrency with VMs than with traditional languages. If so, MonoThreads, at present, map to POSIX Threads, and that's something I would like to see improved now that I'm starting to discover some of Erlang's benefits such as its lightweight threads. Right now there are some people making efforts such as MicroThreading (which I'll have to read further through), and Continuations (which seem to be similar also to MicroThreads). I just don't have any valuable information on performance compared to POSIX Threads (well, MicroThreads seem to be more efficient, but it's quite experimental), and neither any comparison to other concurrency systems such as Erlang's. Just in case someone is interested: http://secondlife.blogs.com/babbage/2006/05/microthreading_.html http://tirania.org/blog/archive/2006/Jun-07-1.html http://tirania.org/blog/archive/2006/Apr-19-2.html Sorry if I talked too much about Mono and this isn't the place to do it, but is another of my bigger interests in software and I can't help imagining new ways of improving it. I wish it had some of the benefits Erlang offers. But nothing is perfect! After this big chunk of speech, if anyone wants to bring up any information it would make enormously happy. Cheers! From fritchie@REDACTED Sat Sep 2 07:55:35 2006 From: fritchie@REDACTED (Scott Lystig Fritchie) Date: Sat, 02 Sep 2006 00:55:35 -0500 Subject: Mnesia patch, was: Re: Mnesia and partitioning big tables: Doc, it hurts when... In-Reply-To: Message of "Tue, 29 Aug 2006 11:59:25 CDT." <200608291659.k7TGxPlZ011285@snookles.snookles.com> Message-ID: <200609020555.k825tZN4036038@snookles.snookles.com> Following up on my earlier message... ... I'd mentioned that I'd had a Mnesia 'disc_copies' table with 800K entries in it. size(term_to_binary(Record)) = 308, on average. The inital attempt to add a fragment via: mnesia:change_table_frag('Profile', {add_frag, [node()]}) ... well, I aborted it after over an hour. The VM was unusable: each line of output by mnesia:info() took 15-20 seconds to appear. Using the patch below, the first mnesia:change_table_frag/2 call takes 24 seconds. Adding the 20th fragment takes 1.6 seconds. The patch is relative to the R10B-9 release. It patches R11B-1 with only a few "offset X lines" warnings, but I've only tested it with R10B-9. It would be really, really nice if: * Another set of eyes can find any bugs? * There's a possible table handle leak, I guess, if you're only 1 table away from the limit on # of ETS tables.... * If no bugs, inclusion into the Mnesia source distribution -Scott --- snip --- snip --- snip --- snip --- snip --- snip --- diff -ur ./mnesia.hrl /home/fritchie/src/mnesia-exp/src/mnesia.hrl --- ./mnesia.hrl 2006-01-09 13:48:16.000000000 -0600 +++ /home/fritchie/src/mnesia-exp/src/mnesia.hrl 2006-09-02 00:06:59.004182832 -0500 @@ -20,7 +20,7 @@ -define(ets_lookup(Tab, Key), ets:lookup(Tab, Key)). -define(ets_lookup_element(Tab, Key, Pos), ets:lookup_element(Tab, Key, Pos)). --define(ets_insert(Tab, Rec), ets:insert(Tab, Rec)). +-define(ets_insert(Tab, Rec), mnesia_lib:redirect_ets_insert(Rec, Tab)). -define(ets_delete(Tab, Key), ets:delete(Tab, Key)). -define(ets_match_delete(Tab, Pat), ets:match_delete(Tab, Pat)). -define(ets_match_object(Tab, Pat), ets:match_object(Tab, Pat)). @@ -33,8 +33,9 @@ -define(ets_prev(Tab, Key), ets:prev(Tab, Key)). -define(ets_slot(Tab, Pos), ets:slot(Tab, Pos)). -define(ets_new_table(Tab, Props), ets:new(Tab, Props)). --define(ets_delete_table(Tab), ets:delete(Tab)). +-define(ets_delete_table(Tab), mnesia_lib:redirect_ets_delete(Tab)). -define(ets_fixtable(Tab, Bool), ets:fixtable(Tab, Bool)). +-define(ets_tab2list(Tab), ets:tab2list(Tab)). -define(catch_val(Var), (catch ?ets_lookup_element(mnesia_gvar, Var, 2))). diff -ur ./mnesia_lib.erl /home/fritchie/src/mnesia-exp/src/mnesia_lib.erl --- ./mnesia_lib.erl 2006-01-09 13:48:16.000000000 -0600 +++ /home/fritchie/src/mnesia-exp/src/mnesia_lib.erl 2006-09-02 00:19:53.790397424 -0500 @@ -151,6 +151,9 @@ view/2, warning/2, + redirect_ets_insert/2, + redirect_ets_delete/1, + is_debug_compiled/0, activate_debug_fun/5, deactivate_debug_fun/3, @@ -1304,4 +1307,25 @@ is_debug_compiled() -> false. -endif. - +redirect_ets_insert(Rec, Tab) -> + TabName = ets:info(Tab, name), + if TabName == mnesia_trans_store, is_tuple(Rec), element(1, Rec) == op -> + [{etab_set, Etab_Set}] = ets:lookup(Tab, etab_set), + %% TODO: Is it worth a test if {op, look_elsewhere} is already + %% in Tab and insert only if it doesn't exist? + ets:insert(Tab, {op, look_elsewhere}), + %% Need a unique key, make_ref() is perfect. + ets:insert(Etab_Set, {make_ref(), Rec}); + true -> + ets:insert(Tab, Rec) + end. + +redirect_ets_delete(Tab) -> + TabName = ets:info(Tab, name), + if TabName == mnesia_trans_store -> + [{etab_set, Etab_Set}] = ?ets_lookup(Tab, etab_set), + ets:delete(Etab_Set); + true -> + ok + end, + ets:delete(Tab). diff -ur ./mnesia_tm.erl /home/fritchie/src/mnesia-exp/src/mnesia_tm.erl --- ./mnesia_tm.erl 2006-01-09 13:48:16.000000000 -0600 +++ /home/fritchie/src/mnesia-exp/src/mnesia_tm.erl 2006-09-02 00:19:43.331987344 -0500 @@ -219,15 +219,17 @@ end; {From, start_outer} -> %% Create and associate ets_tab with Tid - case catch ?ets_new_table(mnesia_trans_store, [bag, public]) of + case catch ({?ets_new_table(mnesia_trans_store, [bag, public]), + ?ets_new_table(mnesia_trans_store_Set, [ordered_set, public])}) of {'EXIT', Reason} -> %% system limit Msg = "Cannot create an ets table for the " "local transaction store", reply(From, {error, {system_limit, Msg, Reason}}, State); - Etab -> + {Etab, Etab_Set} -> tmlink(From), C = mnesia_recover:incr_trans_tid_serial(), ?ets_insert(Etab, {nodes, node()}), + ?ets_insert(Etab, {etab_set, Etab_Set}), Tid = #tid{pid = tmpid(From), counter = C}, A2 = [{Tid , [Etab]} | Coordinators], S2 = State#state{coordinators = A2}, @@ -334,12 +336,14 @@ end; {From, {add_store, Tid}} -> %% new store for nested transaction - case catch ?ets_new_table(mnesia_trans_store, [bag, public]) of + case catch ({?ets_new_table(mnesia_trans_store, [bag, public]), + ?ets_new_table(mnesia_trans_store_Set, [ordered_set, public])}) of {'EXIT', Reason} -> %% system limit Msg = "Cannot create an ets table for a nested " "local transaction store", reply(From, {error, {system_limit, Msg, Reason}}, State); - Etab -> + {Etab, Etab_Set} -> + ?ets_insert(Etab, {etab_set, Etab_Set}), A2 = add_coord_store(Coordinators, Tid, Etab), reply(From, {new_store, Etab}, State#state{coordinators = A2}) @@ -1187,7 +1191,10 @@ P2 = prepare_items(Tid, Tab, Key, Items, Prep), do_arrange(Tid, Store, ?ets_next(Store, Oid), P2, N + 1); do_arrange(Tid, Store, SchemaKey, Prep, N) when SchemaKey == op -> - Items = ?ets_lookup(Store, SchemaKey), %% Store is a bag + %% Get the list of 'op' tuples that used to be stored in the Store bag, + %% then strip off each 2-tuple wrapper. + [{etab_set, Etab_Set}] = ?ets_lookup(Store, etab_set), + Items = [Val || {_Ref, Val} <- ?ets_tab2list(Etab_Set)], P2 = prepare_schema_items(Tid, Items, Prep), do_arrange(Tid, Store, ?ets_next(Store, SchemaKey), P2, N + 1); do_arrange(Tid, Store, RestoreKey, Prep, N) when RestoreKey == restore_op -> From rvg@REDACTED Sat Sep 2 13:07:27 2006 From: rvg@REDACTED (Rudolph van Graan) Date: Sat, 2 Sep 2006 13:07:27 +0200 Subject: New Articles on Trap Exit Message-ID: <5723172F-F3BC-4EB8-9C27-7D4E09807BBC@patternmatched.com> Hi, I've added a bunch of my own articles to Trap Exit and created some more categories. Most important is the new HowTo on testing. Comments (and changes) welcome. Erlang Best Practices: http://wiki.trapexit.org/index.php/Hardcoding_Expectations Erlang Testing: (And HowTo) http://wiki.trapexit.org/index.php/Testing_with_Test_Helper Erlang and Other Languages: http://wiki.trapexit.org/index.php/Java_FSM_on_Erlang_FSM_Model http://wiki.trapexit.org/index.php/Erlang_Funs_and_C_Sharp Erlang Concepts: http://wiki.trapexit.org/index.php/Category:Concepts Rudolph From sharevon@REDACTED Sat Sep 2 14:21:21 2006 From: sharevon@REDACTED (=?GB2312?B?t+vLpw==?=) Date: Sat, 2 Sep 2006 20:21:21 +0800 Subject: Can I use Simple MGC and MG to construct a demonstration enviorment? Message-ID: I have some trouble in differing megaco_session_0.5 and Megaco 3.2.3 as part of Erlang/OTP R10B-9 from each other. Are they different? Or ,megaco_session_0.5 is just a previous version of Megaco 3.2.3. Another question is about examples in megaco 3.2.3. Can Simple MGC and Simple MG do other things ,besides Simple MG send ServiceChange command to 4 interfaces, as TCP/UDP 2944 and 2945, of Simple MGC? If not, how could I control the Simple MGC and MG to construct a test enviorment of one MGC and two MG, and make them to do some real works like adding, modifying, substracting some terminations to some context or making MG to observe some events? Thanks From jefcrane@REDACTED Sat Sep 2 18:49:49 2006 From: jefcrane@REDACTED (Jeff Crane) Date: Sat, 2 Sep 2006 09:49:49 -0700 (PDT) Subject: Tutorials (The list so far) In-Reply-To: <9CB79C836F98504C81BF082C4291E987792AF6@CHITDSEXC02.tds.corp.cendant.org> Message-ID: <20060902164949.57823.qmail@web31602.mail.mud.yahoo.com> This list of tutorials should probably include: http://wagerlabs.com/articles/category/erlang (the fixed low-pain mmo server article) http://www.kazmier.com/computer/port-howto http://www.matt-mcdonnell.com/code/code_erl/code_erl.html (see links at top of this one for additional pages, look through the site Map) I use http://www.matt-mcdonnell.com/code/code_erl/erl_course/erl_course.html a lot. https://support.process-one.net/doc/display/ERL/Erlang+Tutorials I'm not sure how many of these "qualify" for tutorial status, but I hope new people can learn from them as I did. --- "Logan, Martin" wrote: > > This is the list so far. > > http://www.sics.se/~joe/tutorials/robust_server/robust_server.html > > http://www.sics.se/~joe/tutorials/web_server/web_server.html > > http://www.sics.se/~joe/tutorials/client_server/client_server.html > > http://www.sics.se/~joe/tutorials/wiki/wiki.html > > http://www.kazmier.com/computer/port-howto/ > > http://yarivsblog.com/articles/2006/08/18/smerl-demo-easy-function-based > -record-access-in-erlang > > http://www.erlang.org/faq/quick_start.html > > http://www.erlang.org/doc/doc-5.5/doc/getting_started/part_frame.html > > http://www.erlang.org/course/course.html > > > > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From francesco@REDACTED Sat Sep 2 19:17:48 2006 From: francesco@REDACTED (Francesco Cesarini) Date: Sat, 02 Sep 2006 18:17:48 +0100 Subject: Tutorials (The list so far) In-Reply-To: <20060902164949.57823.qmail@web31602.mail.mud.yahoo.com> References: <20060902164949.57823.qmail@web31602.mail.mud.yahoo.com> Message-ID: <44F9BCBC.8030902@erlang-consulting.com> It would be great if anyone else who links to tutorials that have been missed out just add them to the wiki @ http://wiki.trapexit.org/index.php/Category:HowToSignup Francesco Jeff Crane wrote: >This list of tutorials should probably include: > >http://wagerlabs.com/articles/category/erlang (the >fixed low-pain mmo server article) > >http://www.kazmier.com/computer/port-howto > >http://www.matt-mcdonnell.com/code/code_erl/code_erl.html >(see links at top of this one for additional pages, >look through the site Map) >I use >http://www.matt-mcdonnell.com/code/code_erl/erl_course/erl_course.html >a lot. > >https://support.process-one.net/doc/display/ERL/Erlang+Tutorials > >I'm not sure how many of these "qualify" for tutorial >status, but I hope new people can learn from them as I >did. > >--- "Logan, Martin" wrote: > > > >>This is the list so far. >> >> >> >> >http://www.sics.se/~joe/tutorials/robust_server/robust_server.html > > >> >> >http://www.sics.se/~joe/tutorials/web_server/web_server.html > > >> >> >http://www.sics.se/~joe/tutorials/client_server/client_server.html > > >>http://www.sics.se/~joe/tutorials/wiki/wiki.html >> >>http://www.kazmier.com/computer/port-howto/ >> >> >> >> >http://yarivsblog.com/articles/2006/08/18/smerl-demo-easy-function-based > > >>-record-access-in-erlang >> >>http://www.erlang.org/faq/quick_start.html >> >> >> >> >http://www.erlang.org/doc/doc-5.5/doc/getting_started/part_frame.html > > >>http://www.erlang.org/course/course.html >> >> >> >> >> >> > > >__________________________________________________ >Do You Yahoo!? >Tired of spam? Yahoo! Mail has the best spam protection around >http://mail.yahoo.com > > > > From rvg@REDACTED Sat Sep 2 20:15:16 2006 From: rvg@REDACTED (Rudolph van Graan) Date: Sat, 2 Sep 2006 20:15:16 +0200 Subject: slaves and remote nodes... How do you start them? Message-ID: <8A811229-D8B8-4634-BA81-B19DBEEC1FDA@patternmatched.com> Suppose I have file system with lots of interdependent erlang applications. I need a couple of nodes that make up my system. So each type of node has a different boot script. I would like to have an ordered way of starting the system. For example: 1. Start the mnesia node(s) 2. Start the application server(s) 3. Start the web server(s) I would like to start all these from a single erlang VM as slave nodes. (So that I don't have to try and get them to start correctly from outside erlang in scripts). Looking at the documentation for slave: start(Host) start_link(Host, Name) start(Host, Name, Args) -> {ok, Node} | {error, ErrorInfo} etc None of these functions give me a way to start each node by specifying the boot script for the node type. How do other people do this? Or am I going to have to start this system the hard way? Rudolph van Graan Telecommunications Specialist Pattern Matched Technologies E-Mail: rvg@REDACTED Mobile: +27 83 390 7767 Fax: +27 12 667 5342 Web: www.patternmatched.com From thomasl_erlang@REDACTED Sat Sep 2 20:36:14 2006 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Sat, 2 Sep 2006 11:36:14 -0700 (PDT) Subject: warn_unused_vars (Was: Re: Noob - Getting Started Infinte Loop?) In-Reply-To: <44F7FA74.4010006@it.uu.se> Message-ID: <20060902183614.85612.qmail@web38803.mail.mud.yahoo.com> --- Richard Carlsson wrote: > Or > because you're just not aware of some lurking bugs > in your code. One can always fall prey to hubris, naturally, but, as I'm sure you realize, there are costs to having strict checking and lots of compiler noise too. I prefer the noise to be as relevant as possible. Best, Thomas __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From rvg@REDACTED Sat Sep 2 21:33:55 2006 From: rvg@REDACTED (Rudolph van Graan) Date: Sat, 2 Sep 2006 21:33:55 +0200 Subject: Theoretically Stuck Message-ID: <972C6E38-7253-49F8-AA24-91253F78E1FD@patternmatched.com> Reading Yariv's blog: http://yarivsblog.com/articles/2006/09/01/oo-fp- erlang-and-me In my experience I can sum up the difference between Functional Programming and Object Oriented programming in two sentences. In OO it is trivial to model data and more difficult to customize behaviour. In FP (erlang) behaviour modeling is trivial and data modeling becomes a challenge. You need both in one way or another in all languages. I've found it very easy to build systems where the behaviour of something can be customized, but really challenging (or impossible) to model data elegantly. How do you write code that wraps the concept/data of a person? A record with name and surname fields is the obvious answer: -record(person,{name,surname}). From now on until forever, a person is a 3-tuple. Now I want to make a version of person with an extra field, say telephone number. Not all records have this. Some have a work address as well. The first record type is already in mnesia and I cannot change it, nor do I want to. So I add a proplist into the #person record. And a type... simple_person, person_with_phone and then I add all the extra data into that proplist: -record(person,{name,surname,type=simple_person,stuff=[]}). I push all my extra data into stuff, because it is still a person. This is not elegant. In Java I would have had no issues whatsoever. PersonWithNumber inherits from Person etc. But I like erlang, I want a solution. I can think of tons of ways to fake this or work around it. But the language must help me and it doesn't. So I make "versioned" or "namespaced" records by parse transform. Now I cannot match anymore. Perhaps I can probably build a funky-macro-come-parse- transform that will solve this... Lisp have the concept of classes. It is a functional language... Less critical but nuisance anyways is that in Erlang that I cannot "inherit" or reuse code. I instinctively go into grrrrrr mode when I see two functions in different places that are the same. The same bug twice. In my world most gen_servers have the same code somewhere. A logging function. A common initialization routine to register with other components. The code is exactly the same. The only way to reuse it, is to move the code into another module and call it. But I still have to write the call in each and every gen_server. You can compare the fact that all gen_servers have a handle_call and a handle_cast function with an interface in OO. Erlang's work better for me, I can change things easily. How can I make my_special_gen_server have all the code automatically for a gen_server without me having to go lookup the callbacks every time and go into copy-and-paste mode? These are by far the biggest challenges for me with Erlang. You cannot inherit data. You cannot easily reuse code. But in the end there is no elegant solution in erlang. Or is there Joe and Ulf? HELP! Rudolph From ulf.wiger@REDACTED Sat Sep 2 22:01:29 2006 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Sat, 2 Sep 2006 22:01:29 +0200 Subject: Theoretically Stuck In-Reply-To: <972C6E38-7253-49F8-AA24-91253F78E1FD@patternmatched.com> Message-ID: Rudolph van Graan wrote: > > How do you write code that wraps the concept/data of a > person? A record with name and surname fields is the obvious answer: > > -record(person,{name,surname}). > > From now on until forever, a person is a 3-tuple. > > Now I want to make a version of person with an extra field, > say telephone number. Not all records have this. Some have a > work address as well. This seems to be leading towards wanting structs, right? A dynamically typed associative array. > The first record type is already in > mnesia and I cannot change it, nor do I want to. Of course, if you throw mnesia into the mix, you introduce the problem that most of the time you really _do_ want your data model to be strictly defined, all records having exactly the same fields. You can, of course, store {Key, Value} tuples, and have the Value structure vary between objects, but this will drastically reduce your ability to perform efficient searches on the data, not to mention the ability to index the stuff. (well - with 'rdbms', you _can_ still index it...;-) > I push all my extra data into stuff, because it is still > a person. This is not elegant. In Java I would have had > no issues whatsoever. Yes you would, if you maintain the assumption that your going to store it in a database. What database would that be? I know there are object-oriented databases, but they certainly have their problems too. > So I make "versioned" or "namespaced" records by > parse transform. Now I cannot match anymore. Did you do pattern matching in your Java program? (: This is part of the problem, I think. You want dynamically typed structs with efficient pattern matching, and of course, fast updates. And you want mnesia to support tables of such objects. ets:select(), mnesia:select() and QLC should have full support for them too, right? I assure you, I would love to have that too. (: > Less critical but nuisance anyways is that in Erlang that I > cannot "inherit" or reuse code. I instinctively go into > grrrrrr mode when I see two functions in different places > that are the same. The same bug twice. That should be reasonably easy to solve with a parse transform. Yariv's Smerl supports a form of inheritance too, if I'm not mistaken. I'm not sure I agree with the "cannot reuse code" part. I think there is a large degree of reuse in Erlang. I think that OO programs can be difficult to reuse because the inheritance introduces so many implicit dependencies - while you can achieve local reuse in your own program, making generally reusable code is not nearly as easy. > How can I make my_special_gen_server have all > the code automatically for a gen_server without me > having to go lookup the callbacks every time and go > into copy-and-paste mode? How about writing your own behaviour extending gen_server? BR, Ulf W From serge@REDACTED Sat Sep 2 22:21:41 2006 From: serge@REDACTED (Serge Aleynikov) Date: Sat, 02 Sep 2006 16:21:41 -0400 Subject: slaves and remote nodes... How do you start them? In-Reply-To: <8A811229-D8B8-4634-BA81-B19DBEEC1FDA@patternmatched.com> References: <8A811229-D8B8-4634-BA81-B19DBEEC1FDA@patternmatched.com> Message-ID: <44F9E7D5.9040307@hq.idt.net> slave:start/3 accepts Args as the third parameter where you could pass the startup arguments: Args = "-pa /path/to/the/boot/dir -boot bootfilename", slave:start(host1, node_name, Args). This will indeed start a slave node using the bootfilename. OTOH, perhaps you could start the nodes independently, and implement some synchronization protocol based on message passing, or pg2. Regards, Serge Rudolph van Graan wrote: > Suppose I have file system with lots of interdependent erlang applications. > I need a couple of nodes that make up my system. > So each type of node has a different boot script. > I would like to have an ordered way of starting the system. For example: > > 1. Start the mnesia node(s) > 2. Start the application server(s) > 3. Start the web server(s) > > I would like to start all these from a single erlang VM as slave nodes. > (So that I don't have to try and get them to start correctly from > outside erlang in scripts). > > Looking at the documentation for slave: > > start(Host) > start_link(Host, Name) > start(Host, Name, Args) -> {ok, Node} | {error, ErrorInfo} > etc > > None of these functions give me a way to start each node by specifying > the boot script for the node type. > > How do other people do this? Or am I going to have to start this system > the hard way? > > Rudolph van Graan > > Telecommunications Specialist > Pattern Matched Technologies > > E-Mail: rvg@REDACTED > Mobile: +27 83 390 7767 > Fax: +27 12 667 5342 > Web: www.patternmatched.com > > > From erlang@REDACTED Sat Sep 2 22:27:17 2006 From: erlang@REDACTED (erlang) Date: Sat, 2 Sep 2006 13:27:17 -0700 Subject: Problem with floats and rpc calls. Message-ID: Another beginner question. I'm using otp.net (jinterface ported to .net) that I attempted to update for the current erlang. In an rpc call this works, and returns the expected string: -module(rpctest). -export([double/1]). double(X) -> float_to_list(2.00 * X). But this always returns the float 0, I can't see the reason. -module(rpctest). -export([double/1]). double(X) -> 2.00 * X. Returns of strings, tuples, ints all seem to work ok. From rvg@REDACTED Sat Sep 2 22:30:10 2006 From: rvg@REDACTED (Rudolph van Graan) Date: Sat, 2 Sep 2006 22:30:10 +0200 Subject: Theoretically Stuck In-Reply-To: References: Message-ID: <47D78935-A7B5-4D86-86C0-4A71CB2EDE22@patternmatched.com> >> >> How do you write code that wraps the concept/data of a >> person? A record with name and surname fields is the obvious answer: >> >> -record(person,{name,surname}). >> >> From now on until forever, a person is a 3-tuple. >> >> Now I want to make a version of person with an extra field, >> say telephone number. Not all records have this. Some have a >> work address as well. > > This seems to be leading towards wanting structs, right? > A dynamically typed associative array. I'd be careful before I say yes because I have no clue what a DTAA is. In my mind a list can almost do what I want: Type Name Surname {[person], ["Smith","Victor]} {[person,with_phone],["Smith", "Victor","+332211123123"]} Both would match this pattern {[person|_],[Name,Surname|_]} and only the second one would match {[person,with_phone|_],[Name,Surname|_]} so we have a person-with-a-phone "inheriting" from person Maybe wrap it in a tuple so that we know this is a special,"inherited" type: {dynamic_record,{[person,with_phone|_],[Name,Surname|_]}} My biggest concern here is that you lose the implicit efficiency of tuples, but I haven't measured how slow it is yet and we've lost record syntax. From robert.virding@REDACTED Sat Sep 2 22:43:31 2006 From: robert.virding@REDACTED (Robert Virding) Date: Sat, 02 Sep 2006 22:43:31 +0200 Subject: Leex In-Reply-To: <95be1d3b0609010512t5c380b15kbf87d060a7b348b7@mail.gmail.com> References: <44F7F53B.5070808@telia.com> <95be1d3b0609010512t5c380b15kbf87d060a7b348b7@mail.gmail.com> Message-ID: <44F9ECF3.20105@telia.com> OK, I have now added leex to User Contributions section of trapexit.org; http://forum.trapexit.org/viewforum.php?f=20 Any future updates will go there as well. My plans are to first stabilise the syntax/semantics of .xrl files and then cleanup the leex.erl file so it is more easily usable. I would also like to experiment with implementing the DFA, having it as one single whopping great recursive function may not be the best way. You can get the full text of the token, its length and line number in the variables TokenChars, TokenLen and TokenLine. Concerning new features I don't know. It depends on what I can implement efficiently and there seems to be a need of. And what I can find the time for. How do you define the column number? Robert Vlad Dumitrescu wrote: > On 9/1/06, Robert Virding wrote: > >> OK, here is the leex code. > > > Cool! > > I wonder what is the current status of leex, i.e. you plan any major > changes or just cleanup. > > I would like to be able to get more detailed information in the tokens > returned (things like column number, offset from the beginning of the > file and the full text of the token as it was found in the code). > > Would it be useful to include that in the main leex, or should I go > the way I did for much of the thing I use in erlide: use my own hacked > version? > > best regards, > Vlad > From vladdu55@REDACTED Sat Sep 2 22:53:24 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Sat, 2 Sep 2006 21:53:24 +0100 Subject: Leex In-Reply-To: <44F9ECF3.20105@telia.com> References: <44F7F53B.5070808@telia.com> <95be1d3b0609010512t5c380b15kbf87d060a7b348b7@mail.gmail.com> <44F9ECF3.20105@telia.com> Message-ID: <95be1d3b0609021353n6d9c040ew3a3e6c4e81c4498@mail.gmail.com> On 9/2/06, Robert Virding wrote: > OK, I have now added leex to User Contributions section of trapexit.org; Great, thanks! BTW, there is a problem in the forum, the file is mentioned there but there is no link to it... > You can get the full text of the token, its length and line number in > the variables TokenChars, TokenLen and TokenLine. Ahaa, I missed that... Sorry for the noise! > Concerning new features I don't know. It depends on what I can implement > efficiently and there seems to be a need of. And what I can find the > time for. Very understandable :-) > How do you define the column number? That one is really not very important, but I define it as the number of chars from the latest line terminator. It gets a little tricky to make that platform independent. regards, Vlad From vladdu55@REDACTED Sat Sep 2 23:05:21 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Sat, 2 Sep 2006 22:05:21 +0100 Subject: Metaprogramming In-Reply-To: <95be1d3b0608250510q6b4b6cfeh64445a06d1992089@mail.gmail.com> References: <95be1d3b0608240155v170d256p7268ad47b89f95ec@mail.gmail.com> <20060825105627.31890.qmail@web38814.mail.mud.yahoo.com> <95be1d3b0608250510q6b4b6cfeh64445a06d1992089@mail.gmail.com> Message-ID: <95be1d3b0609021405n8b697d3w3f9a9fb9aece69e9@mail.gmail.com> Hi all, I've promised to return with some more info about how it is going with my efforts to implement some kind of metaprogramming facilities. The "problem" is that I didn't keep my original goal, but am now aiming a little higher. That meaning that instead of something like "Template Haskell" I'd like to implement something like "MetaML". Which isn't much more difficult, but needs integration into the compiler (as opposed to only affecting the scanner and parser). One also needs to be careful not to change the semantics of existing constructs. So it's going forward, but slowly. I'm also getting headaches from mentally jumping around between the meta-language levels :-) regards, Vlad From ulf.wiger@REDACTED Sat Sep 2 23:05:55 2006 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Sat, 2 Sep 2006 23:05:55 +0200 Subject: Theoretically Stuck In-Reply-To: <47D78935-A7B5-4D86-86C0-4A71CB2EDE22@patternmatched.com> Message-ID: When searching for some references, I came across this: http://www.erlang.org/ml-archive/erlang-questions/200603/msg00479.html (Richard O'Keefe's draft proposal on child modules.) But this was the one I was really after - ROK's dictionaries: http://www.erlang.org/ml-archive/erlang-questions/200309/msg00339.html BR, Ulf W > -----Original Message----- > From: Rudolph van Graan [mailto:rvg@REDACTED] > Sent: den 2 september 2006 22:30 > To: Ulf Wiger (TN/EAB) > Cc: Erlang List > Subject: Re: Theoretically Stuck > > >> > >> How do you write code that wraps the concept/data of a person? A > >> record with name and surname fields is the obvious answer: > >> > >> -record(person,{name,surname}). > >> > >> From now on until forever, a person is a 3-tuple. > >> > >> Now I want to make a version of person with an extra field, say > >> telephone number. Not all records have this. Some have a > work address > >> as well. > > > > This seems to be leading towards wanting structs, right? > > A dynamically typed associative array. > > I'd be careful before I say yes because I have no clue what a DTAA is. > > In my mind a list can almost do what I want: > > Type Name Surname > {[person], ["Smith","Victor]} > {[person,with_phone],["Smith", "Victor","+332211123123"]} > > Both would match this pattern > > {[person|_],[Name,Surname|_]} > > and only the second one would match > > {[person,with_phone|_],[Name,Surname|_]} > > so we have a person-with-a-phone "inheriting" from person > > Maybe wrap it in a tuple so that we know this is a > special,"inherited" type: > > {dynamic_record,{[person,with_phone|_],[Name,Surname|_]}} > > My biggest concern here is that you lose the implicit > efficiency of tuples, but I haven't measured how slow it is > yet and we've lost record syntax. > From roger.larsson@REDACTED Sat Sep 2 23:11:38 2006 From: roger.larsson@REDACTED (Roger Larsson) Date: Sat, 2 Sep 2006 23:11:38 +0200 Subject: Erlang using Linux native threads - a waste of space In-Reply-To: References: <230465c00608281520m3b38c5efy20375f1f52ba3240@mail.gmail.com> Message-ID: <200609022311.38912.roger.larsson@norran.net> On Tuesday 29 August 2006 15:47, you wrote: > On Tue, 29 Aug 2006, lang er wrote: > > If OS support erlang's lightweight process in kernel, many programming > > languages could have erlang's concurrent capability.I think it is not > > impossible. > > The reason that Erlang processes are lightweight is that they do not > require a context switch from userland -> kernel -> userland in order to > schedule the next thread. Erlang can rely on the properties of the > language, specifically no shared mutable data, in order to isolate > processes from each other. The kernel must use the CPU's virtual memory > support to do this, because it cannot make assumptions about the languages > used to write userland processes, and switching pages tables is expensive. Linux does not switch the page tables if the new process has the same memory map as the previous - i.e. an thread. But you still have the cost of checking that together with entering/leaving the kernel. In addition to this the kernel needs to store thread information and a (kernel) stack. The stack is a problem when executing in kernel, as all threads will do. - It can not be placed in user memory (another concurrently executing thread might modify it - by accident or not... Causing severe corruptions). - It needs to be big enough to store data from all possible kernel callchains including local variables - how big does it need to be??? - As an optimization it does hold the thread information for quick access Linux Kernel 2.4 uses 8 kB stacks, this has been optimized to 4 kB in 2.6 on i386 architectures, by using option CONFIG_4KSTACKS, possible since 2.6 has independent interrupt stack, exception stack..., x86-64 bit architecture could thus continue to use an 8 kB stack. The task description alone (stored in the stack) is about 1.7 kB Good information at (over one year old...) http://www.informit.com/articles/article.asp?p=370047&rl=1 More about threads http://www.informit.com/articles/article.asp?p=370047&seqNum=3&rl=1 In addition to this all threads needs a userspace stack too. Erlang Saw some Erlang numbers earlier but I can not find it. Note: nothing needs to be stored per Erlang process in kernel. /RogerL From erlang@REDACTED Sun Sep 3 03:57:18 2006 From: erlang@REDACTED (erlang) Date: Sat, 2 Sep 2006 18:57:18 -0700 Subject: Problem with floats and rpc calls -- resolved Message-ID: Nevermind it was just a bug in OtpInputStream.cs which is one of the files in the otp.net port of jinterface. Is there any interest in having an updated otp.net? I found it on sourceforge. From wfragg@REDACTED Sun Sep 3 07:52:56 2006 From: wfragg@REDACTED (Ivan Dubrov) Date: Sun, 03 Sep 2006 12:52:56 +0700 Subject: Supervisor as process registry Message-ID: <44FA6DB8.9060205@gmail.com> Hi, A theoretical question. Is it OK from the point of design to use supervisor process as a process registry (in other words, as a mapping between some ServiceId -> Service), so worker processes can lookup other workers from it? -- WBR, Ivan S. Dubrov -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: OpenPGP digital signature URL: From ryanobjc@REDACTED Sun Sep 3 08:10:02 2006 From: ryanobjc@REDACTED (Ryan Rawson) Date: Sat, 2 Sep 2006 23:10:02 -0700 Subject: Erlang using Linux native threads - a waste of space In-Reply-To: <200609022311.38912.roger.larsson@norran.net> References: <230465c00608281520m3b38c5efy20375f1f52ba3240@mail.gmail.com> <200609022311.38912.roger.larsson@norran.net> Message-ID: <78568af10609022310t36aedd76p22663a4c510242e9@mail.gmail.com> What about the cost of actually executing the context switch and the flushing of pipelines? A kernel call on i386 is executed via the software interrupt which is the equivalent of a long jump, thus your pipeline is invalidated. If you are trying to get huge performance, avoiding context switches should be on the list of top 10 issues, no? -ryan On 9/2/06, Roger Larsson wrote: > On Tuesday 29 August 2006 15:47, you wrote: > > On Tue, 29 Aug 2006, lang er wrote: > > > If OS support erlang's lightweight process in kernel, many programming > > > languages could have erlang's concurrent capability.I think it is not > > > impossible. > > > > The reason that Erlang processes are lightweight is that they do not > > require a context switch from userland -> kernel -> userland in order to > > schedule the next thread. Erlang can rely on the properties of the > > language, specifically no shared mutable data, in order to isolate > > processes from each other. The kernel must use the CPU's virtual memory > > support to do this, because it cannot make assumptions about the languages > > used to write userland processes, and switching pages tables is expensive. > > Linux does not switch the page tables if the new process has the same > memory map as the previous - i.e. an thread. > But you still have the cost of checking that together with entering/leaving > the kernel. In addition to this the kernel needs to store thread information > and a (kernel) stack. > > The stack is a problem when executing in kernel, as all threads will do. > - It can not be placed in user memory (another concurrently executing thread > might modify it - by accident or not... Causing severe corruptions). > - It needs to be big enough to store data from all possible kernel callchains > including local variables - how big does it need to be??? > - As an optimization it does hold the thread information for quick access > > Linux > Kernel 2.4 uses 8 kB stacks, > this has been optimized to 4 kB in 2.6 on i386 architectures, by > using option CONFIG_4KSTACKS, possible since 2.6 has independent > interrupt stack, exception stack..., x86-64 bit architecture could thus > continue to use an 8 kB stack. > The task description alone (stored in the stack) is about 1.7 kB > > Good information at (over one year old...) > http://www.informit.com/articles/article.asp?p=370047&rl=1 > > More about threads > http://www.informit.com/articles/article.asp?p=370047&seqNum=3&rl=1 > > In addition to this all threads needs a userspace stack too. > > Erlang > Saw some Erlang numbers earlier but I can not find it. > Note: nothing needs to be stored per Erlang process in kernel. > > /RogerL > > From ke.han@REDACTED Sun Sep 3 09:21:07 2006 From: ke.han@REDACTED (ke han) Date: Sun, 3 Sep 2006 15:21:07 +0800 Subject: Theoretically Stuck In-Reply-To: References: Message-ID: <3831FAAA-2A99-4E31-B5FA-57CE66DA5D56@redstarling.com> On Sep 3, 2006, at 5:05 AM, Ulf Wiger ((TN/EAB)) wrote: > > > > But this was the one I was really after - ROK's > dictionaries: > > http://www.erlang.org/ml-archive/erlang-questions/200309/msg00339.html Exceptional post!!!..thanks for digging that up. I sure wish that in the three years since this post was made some erlang master had managed to come up with an implementation of this ;-). In regards to Rudolph's issues, I am currently prototyping methods to alleviate the trouble with treating "records as an object": 1 - I need a simple way to create and manage attributes of an entity (either processes or some erlang term which I am careful to not violate encapsulation)..in OO languages you get encapsulation for free...in erlang you just need a little discipline to your coding style. Even with some discipline, you will end up with repetitive code for managing attribute values, events, changes to the collection of attributes (adding a office_phone to the existing Person model), etc... In an MVC approach to app design, both Controllers and Models have attributes...I need a simple approach which at least hides repetitive code. I am closely following the work done on smerl and erlyDB for methods to manage this. It would be nice if ROK's dictionary already existed. This might offer a lightweight and language transparent method for accomplishing some of this...but its not here for now... 2 - Once I get something I like from step 1, I'm hoping I can extrapolate to create general methods for mitigating otherwise repetitive code for common behaviors...I don't know what it looks like yet, but something along the lines of "-behavior" declarations that automate delegation to helper modules is maybe an acceptable approach. your thought? ke han > > BR, > Ulf W > From vladdu55@REDACTED Sun Sep 3 09:31:10 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Sun, 3 Sep 2006 08:31:10 +0100 Subject: Problem with floats and rpc calls -- resolved In-Reply-To: References: Message-ID: <95be1d3b0609030031o41772a40jc36dca130172b38f@mail.gmail.com> Hi, On 9/3/06, erlang wrote: > Nevermind it was just a bug in OtpInputStream.cs which is one > of the files in the otp.net port of jinterface. > > Is there any interest in having an updated otp.net? I found it on > sourceforge. If it is the one in jungerl, it is me who did the translation (mostly automatic, actually) and I don't know of anyone who used it... On the other hand, it wouldn't hurt to fix the bug. best regards, Vlad From oscar-erl@REDACTED Sun Sep 3 12:33:10 2006 From: oscar-erl@REDACTED (Oscar =?ISO-8859-1?Q?Hellstr=F6m?=) Date: Sun, 03 Sep 2006 12:33:10 +0200 Subject: Erlang for web-developers In-Reply-To: <17244f480608280547q1e387daas49ff939eba247d28@mail.gmail.com> References: <17244f480608280547q1e387daas49ff939eba247d28@mail.gmail.com> Message-ID: <1157279590.11848.3.camel@battlestar.oscarh.net> On Mon, 2006-08-28 at 08:47 -0400, Yariv Sadan wrote: > > Thanks for the response. Apparently Rails has reached its scalability > limits once my blog has reached a few thousand visitors, and now it > experiences intermittent errors that I'm at a loss to fix. Very > annoying. > > Sometimes even sudoing as root and killing all the OS processes that > Lighttpd spawns for handling the fastcgi requests and then restarting > Lighttpd doesn't help, and the only recourse is to physically reboot > the server. How do you handle sessions? If they are stored as files in /tmp they are not removed by rails and you will reach the maximum number of files in a directory after a while, and I guess these are removed on reboot. This is a known problem and examples of cron jobs are available in the Rails docs. Another approach is to store sessions in a database, but also these need to be cleaned up not to fill the database. > I didn't want to write about it in my blog because I didn't want > people to think I'm taking cheap shots at Rails, but after my > experience with typo, I'd be crazy to use Rails to rather than Yaws to > build a real app :) > Thanks, > Yariv Regards -- ?Oscar Hellstr?m, oscar@REDACTED web: personal.oscarh.net jid: oscar@REDACTED From david.nospam.hopwood@REDACTED Sun Sep 3 16:35:16 2006 From: david.nospam.hopwood@REDACTED (David Hopwood) Date: Sun, 03 Sep 2006 15:35:16 +0100 Subject: Erlang using Linux native threads - a waste of space In-Reply-To: <78568af10609022310t36aedd76p22663a4c510242e9@mail.gmail.com> References: <230465c00608281520m3b38c5efy20375f1f52ba3240@mail.gmail.com> <200609022311.38912.roger.larsson@norran.net> <78568af10609022310t36aedd76p22663a4c510242e9@mail.gmail.com> Message-ID: <44FAE824.2@blueyonder.co.uk> Ryan Rawson wrote: > What about the cost of actually executing the context switch and the > flushing of pipelines? A kernel call on i386 is executed via the > software interrupt which is the equivalent of a long jump, thus your > pipeline is invalidated. Invalidation of the pipeline is a minor effect compared to other costs, especially cache performance. See . This paper is a little old, but the main conclusion still holds: the cost of a context switch including cache effects is still "thousands of cycles". -- David Hopwood From lennart.ohman@REDACTED Sun Sep 3 21:24:23 2006 From: lennart.ohman@REDACTED (Lennart Ohman) Date: Sun, 3 Sep 2006 21:24:23 +0200 Subject: Supervisor as process registry In-Reply-To: <44FA6DB8.9060205@gmail.com> Message-ID: <002201c6cf8e$912c19d0$bf01650a@st.se> Hi Ivan, If your are "only" planning on using already existing functionality in the supervisors, I can't see any objective reason why not. But do not extend the supervisors to do other work. In the supervision model supervisors must be correct for it to work. Meaning that there can not be any errors in their code. If you modify their behaviour, you risk introducing faults. Best Regards, Lennart ------------------------------------------------------------- Lennart Ohman office : +46-8-587 623 27 Sjoland & Thyselius Telecom AB cellular: +46-70-552 67 35 Sehlstedtsgatan 6 fax : +46-8-667 82 30 SE-115 28, STOCKHOLM, SWEDEN email : lennart.ohman@REDACTED > -----Original Message----- > From: owner-erlang-questions@REDACTED [mailto:owner-erlang- > questions@REDACTED] On Behalf Of Ivan Dubrov > Sent: Sunday, September 03, 2006 7:53 AM > To: Erlang Questions > Subject: Supervisor as process registry > > Hi, > > A theoretical question. Is it OK from the point of design to use > supervisor process as a process registry (in other words, as a mapping > between some ServiceId -> Service), so worker processes can lookup other > workers from it? > > -- > WBR, > Ivan S. Dubrov From cyberdanx@REDACTED Sun Sep 3 22:53:39 2006 From: cyberdanx@REDACTED (Chris Campbell) Date: Sun, 3 Sep 2006 21:53:39 +0100 Subject: Disterl error: badrpc exit Message-ID: Hi, I get the following error with distel. The error occurs when I try to reload a module called store. Any ideas? I'm running R11-B0. nodeup: devug@REDACTED load: [badrpc [EXIT [badarg ([erlang list_to_atom (store)] [distel l2a 1] [distel reload_module 2] [rpc -handle_call/3-fun-0- 5])]]] Distel is in /opt/erlang/jungerl/lib/distel. In .emacs we have (add-to-list 'load-path "/opt/erlang/jungerl/lib/distel/elisp") (require 'distel) (distel-setup) and in .erlang we have code:add_pathz("/opt/erlang/jungerl/lib/distel/ebin"). The external node is started with "erl -name devug@REDACTED +R9". What have I done wrong? Cheers, Chris From robert.virding@REDACTED Sun Sep 3 23:12:09 2006 From: robert.virding@REDACTED (Robert Virding) Date: Sun, 03 Sep 2006 23:12:09 +0200 Subject: New release of Erlog - a prolog interpreter written in, and for, Erlang In-Reply-To: References: <44F7F766.8030900@telia.com> Message-ID: <44FB4529.8010201@telia.com> OK, I have now uploaded Erlog as a user contribution on trapexit.org. Same info as before: I have completed a new version of Erlog, and implementation of Prolog in, and for, Erlang. Compared to the old it has the following features: - much improved implementation with a speed-up of 2-10 depending on the application! - much better Prolog parser which is now very close to Standard Prolog. - better Erlang interface which now supports compiled code, though there is no compiler yet. - new continuation based interface as well as the process based one. For free I have also included: - Leex which is used for the Erlog scanner. No documentation but an Erlang scanner is also included as an extra example. It works, producing good code, but the packaging is not yet production quality. It is also on trapexit.org. - an example efficient ETS interface. Backtracking over ETS wins! Please comment and report bugs, Robert Ulf Wiger wrote: > Den 2006-09-01 11:03:34 skrev Robert Virding : > >> I have completed a new version of Erlog, and implementation of Prolog >> in, and for, Erlang. Compared to the old it has the following features: >> [...] >> >> I will try to get the code out through the mailing list but it is too >> big. > > > You could log into trap exit and upload it as a user contribution. > > http://forum.trapexit.org/viewforum.php?f=20 > > BR, > Ulf W From ok@REDACTED Mon Sep 4 00:46:15 2006 From: ok@REDACTED (Richard A. O'Keefe) Date: Mon, 4 Sep 2006 10:46:15 +1200 (NZST) Subject: Erlang downsides? Message-ID: <200609032246.k83MkFVt338820@atlas.otago.ac.nz> > Exactly. And other dynamic languages--including Ruby and > Python--simply link to the standard Perl regular expression library. For what it's worth, as part of the Mawk maintenance project this year, I had my 3rd-year students look at the possibility of replacing Mawk's own regexp code with PCRE. There were two major problems: (1) For GAWK-compatibility, and also because it seemed like the right thing to do, we've made Mawk allow \0 inside strings. The PCRE interface doesn't allow that. (2) The Perl semantics for regular expression matching is incompatible with the POSIX standard. From karol.skocik@REDACTED Mon Sep 4 01:40:15 2006 From: karol.skocik@REDACTED (karol skocik) Date: Mon, 4 Sep 2006 01:40:15 +0200 Subject: scope of variables Message-ID: Hi guys, do you know if there is some intelligent way to simulate scope in erlang? So far, I have found that list comprehensions can help : test() -> [begin X = 10 end || _X <- [dummy]], X. %% here is X unbound - as it should be or wrapping the score into function but : 1.) it is not very nice 2.) it costs a function call (this translated to core erlang makes 'lc-...' function which is called recursively - inlining does not help here 3.) collects dummy into list (in case of list comprehension, but compiler probably removes optimizes this) I want to play and create something like lisp layer over erlang syntax tree, which would allow macros similar to those in common lisp, but erlang's crazy scoping is standing in the way... Karol From bfulg@REDACTED Mon Sep 4 04:56:02 2006 From: bfulg@REDACTED (Brent Fulgham) Date: Sun, 3 Sep 2006 19:56:02 -0700 Subject: New Articles on Trap Exit In-Reply-To: <5723172F-F3BC-4EB8-9C27-7D4E09807BBC@patternmatched.com> References: <5723172F-F3BC-4EB8-9C27-7D4E09807BBC@patternmatched.com> Message-ID: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Sep 2, 2006, at 4:07 AM, Rudolph van Graan wrote: > I've added a bunch of my own articles to Trap Exit and created some > more categories. Most important is the new HowTo on testing. > > Comments (and changes) welcome. In the same vein, I've gone through and ported over the remaining pages in the Erlang Cookbook to TrapExit, as well as edited a few links and categories in the CookBook. I'll see about adding more info soon... One thing I really miss is the ability to do real syntax highlighting in MediaWiki. Compare, for example, the enscript-based highlighting in the original CookBook (http://schemecookbook.org/Erlang/ FileReadingLines) to the new version (http://wiki.trapexit.org/ index.php/Reading_Lines_from_a_File). Does anyone know if there are better options for syntax highlighting code in this Wiki? Thanks, - -Brent -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2.2 (Darwin) iD8DBQFE+5XDzGDdrzfvUpURAuwoAJ9dVnvse3HtWKxgkVyyTlQi0JgjiQCeIRG2 h4Q963ZuaZXa+q1rPQ3ut/8= =aDCo -----END PGP SIGNATURE----- From mats.cronqvist@REDACTED Mon Sep 4 09:06:14 2006 From: mats.cronqvist@REDACTED (Mats Cronqvist) Date: Mon, 04 Sep 2006 09:06:14 +0200 Subject: Disterl error: badrpc exit In-Reply-To: References: Message-ID: <44FBD066.2050209@ericsson.com> Chris Campbell wrote: > Hi, > > I get the following error with distel. The error occurs when I try to > reload a module called store. Any ideas? I'm running R11-B0. i fixed that a while back, forgot to check in... please update distel.erl and give it a shot. mats From vladdu55@REDACTED Mon Sep 4 09:09:15 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Mon, 4 Sep 2006 09:09:15 +0200 Subject: scope of variables In-Reply-To: References: Message-ID: <95be1d3b0609040009v65a6ae14ue4d07da5423a9189@mail.gmail.com> On 9/4/06, karol skocik wrote: > Hi guys, > do you know if there is some intelligent way to simulate scope in erlang? > > I want to play and create something like lisp layer over erlang syntax > tree, which would allow macros similar to those in common lisp, but > erlang's crazy scoping is standing in the way... Hi, I am working on a meta-programming facility for Erlang, that in the end will allow even Lisp-like macros, so I know exactly what you mean :-) This isn't really easy in Lisp either, if you look at the implementation. I mean, behind the scenes the variables are being renamed using gensym so as to avoid the problem. The only way I did find to be able to handle this is to make the parser and compiler aware of these issues and do the work there. I don't think it's possible to "just" add a layer above erl-core, but I'd love to be proved wrong ! best regards, Vlad From richardc@REDACTED Mon Sep 4 09:10:12 2006 From: richardc@REDACTED (Richard Carlsson) Date: Mon, 04 Sep 2006 09:10:12 +0200 Subject: scope of variables In-Reply-To: References: Message-ID: <44FBD154.1010103@it.uu.se> karol skocik wrote: > I want to play and create something like lisp layer over erlang syntax > tree, which would allow macros similar to those in common lisp, but > erlang's crazy scoping is standing in the way... You can use lambda expressions that you immediately apply, as in: (fun ()-> ... end)() and perhaps define macros that use such lambdas: -define(let(X, Y, Z), ((fun (X)-> Z end)(Y))). There is of course a small cost for the lambda application, but you might be able to get rid of most of that by using -compile(inline). /Richard From jay@REDACTED Sat Sep 2 01:52:40 2006 From: jay@REDACTED (Jay Nelson) Date: Fri, 01 Sep 2006 16:52:40 -0700 Subject: Code generation (was NOOB) Message-ID: <44F8C7C8.6050409@nelson.name> Bjorn clarified some optimization approaches: > We have considered improving the optimization, so that no list would > be built in case 2. Where case 2 was the line commented <2> below: > foo(X) -> > A = [do_something(E) || E <- X], % <1> > [do_other(E) || E <- X], % <2> > ok. There has been previous debates about use lists:foreach when only side-effects are desired and a list comprehension when the result list is needed. I used to subscribe to that approach, but the list comprehension is so much clearer that I always use it now unless there is reason to be concerned about generating the large list. To me, <1> and <2> have clearly marked intent that the first needs the result and the second is only for side effects because there is no left side pattern match. I would lobby for the compiler to not generate a list in this case. It allows me to code in the most consistent and clear style and not have to take a performance penalty for doing so. There are two other reasons why this optimization might be desirable: 1) When (or if) binary comprehensions are added, it would be possible to use a similar construct to visit all bytes and emit them via message send or io:format or write them to a file, without constructing and consuming new memory. Thus, binaries nearly the size of total available RAM could be received, transformed and re-emitted as below: {ok, BigBinary} = file:read_file("bigfile"), %% or from a receive << AmazonS3 ! convert_to_unicode(ByteChunk) || ByteChunk:1024 <- BigBinary >>. 2) List Comprehensions (and binary) could be used for infinite streams. Sort of the equivalent of tail recursion not using the stack. [ send_to_listeners(Publication) || Publication <- get_next_pub(Publisher) ] get_next_pub(Publisher) -> receive {Publisher, Pub} -> Pub after 5000 -> end_of_stream %% Hmmm, well some token to tell comprehension to end. %% Don't think [] would work. Worst case it could just exit. end. Half-baked idea, but if you spawn link the above code, the intent is to sit emitting published events to all subscribers until the publisher pauses for 5 seconds. I think the coding style makes it concise and clear what is going on. Instead of get_next_pub, the generator could be lazy_gen_all_natural_numbers or some other infinite stream. jay From info@REDACTED Sun Sep 3 08:58:40 2006 From: info@REDACTED (Alfons Mittelmeyer) Date: Sun, 3 Sep 2006 06:58:40 +0000 (UTC) Subject: LAPD protocol implementation available References: <20050102024233.GP42962@frogman.motivity.ca> Message-ID: Alfons Mittelmeyer alfons-mittelmeyer.de> writes: > Dear Vance, > > I am interested in your implementation of the LAPD protocol, but the URLs > > http://www.motivity.ca/lapd/index.html > http://www.motivity.ca/lapd-1.1.tar.gz > > don't exist anymore. > Can you offer an alternate internet address where your implementation may be > found? > > best regards > > - Alfons > > Hi all, my suggestion, that the internet address http://www.motivity.ca don't exist anymore was wrong. An error in the software for my ISDN modem and telecommunication system causes, that I don't get access to IP-addresses 192.xxx.xxx.xxx I would like to erase this comments from erlang.org, because they don't have really something to to with the lapd implementation of Vance Shipley. But reporting the comments as SPAM don't seem to be the correct way or? - Alfons From lefevrol@REDACTED Sun Sep 3 20:05:25 2006 From: lefevrol@REDACTED (Olivier Lefevre) Date: Sun, 03 Sep 2006 20:05:25 +0200 Subject: Erlang on Solaris x86 In-Reply-To: <6056379.post@talk.nabble.com> References: <03B8C790-1251-47E6-84C3-EF6232F1DC3E@gmail.com> <6056379.post@talk.nabble.com> Message-ID: Here's a third: mod3.co.uk; I think these 3 are the only companies selling Solaris zones at the moment. -- O.L. PS: "vps" has a strong Linux connotation, which is confusing in this context; better speak of zones or, if you want to remain generic, of containers. fbg111 wrote: > > Joel Reymont wrote: > >>Is anyone running Erlang on Solaris x86? > > > I'm not but have been looking for a vps to host the same software stack on. > Here's another I found: > > http://www.gridzones.com/gridzones_hosting.php > > Byron From vladdu55@REDACTED Mon Sep 4 10:14:44 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Mon, 4 Sep 2006 10:14:44 +0200 Subject: scope of variables In-Reply-To: <44FBD154.1010103@it.uu.se> References: <44FBD154.1010103@it.uu.se> Message-ID: <95be1d3b0609040114i255f0164qdc1998a9792ab3e5@mail.gmail.com> On 9/4/06, Richard Carlsson wrote: > and perhaps define macros that use such lambdas: > -define(let(X, Y, Z), ((fun (X)-> Z end)(Y))). Is it really that simple? This doesn't make for hygienic macros, and this will fail with a badmatch: foo() -> A = 2, ?let(X, 3, begin A=1, X+A end). > There is of course a small cost for the lambda application, but you > might be able to get rid of most of that by using -compile(inline). Oh, so even anonymous funs can be inlined? That's interesting! regards, Vlad From dgud@REDACTED Mon Sep 4 11:06:18 2006 From: dgud@REDACTED (Dan Gudmundsson) Date: Mon, 4 Sep 2006 11:06:18 +0200 Subject: Mnesia dB size limits In-Reply-To: <200608310214.k7V2EHX6055597@snookles.snookles.com> References: <200608310214.k7V2EHX6055597@snookles.snookles.com> Message-ID: <17659.60554.727713.376705@rian.du.uab.ericsson.se> I just want to point out that disc_copies don't use dets at all, only disc_only_copies do. disc_copies caches everything in ets though. /Dan Scott Lystig Fritchie writes: > >>>>> "pr" == Philip Robinson writes: > > pr> Damir asks: > > >> What are the upper limits where system can still be called > >> "production quality" in terms of dB speed? > > In a few months, a project I've been working on will go "live" with > approx 6GB total of data in about a half-dozen 'disc_copies' tables, > using both replication and fragmentation (though only on 2 machines, > but they have 16GB RAM each :-). > > pr> When I wanted to retrieve a specific event there was no noticable > pr> delay, but most of my queries were for a date/time range. > > It all depends on how the index(s) is defined and whether you were > using foldl/3 or index_match_object/3 or match_object/1 or > scary-but-works-quite-well-at-what-it-does select/2. > > pr> I think the mnesia issues being mentioned on this list were to do > pr> with database recovery across nodes after a node failure...? > > Step 0: Decide when to start the dead node. > Step 1: Start the dead node. > Step 2: There is no step 2. > > Overall throughput can take a hit when starting a dead node, because > all out-of-date tables will be copied as-is from a live node. So > doing Step 1 during your 1% or 5% peak usage time isn't a good idea. > > Dealing with network partitions is trickier. But if you're > clustering, then you've probably also got some kind of infrastructure > build for dealing with logging messages, events (of whatever sort, > including 'mnesia_down' events from Mnesia itself), alarms, etc > ... and all that makes it tricky enough to wuss out with an answer > like, "It depends." > > -Scott From abailly@REDACTED Mon Sep 4 11:08:27 2006 From: abailly@REDACTED (Arnaud Bailly) Date: Mon, 04 Sep 2006 11:08:27 +0200 Subject: Mock functions Message-ID: <87y7t0vw1g.fsf@oqube.com> Hello, For unit testing my java code, I use mock objects for all interfaces I need in the context of the OUT. This allows me to precisely control what's goinig in and out of my object. I could think of several ways to do this in Erlang but they all seem a bit contrived. Is there something "canonical" for doing this kind of tests ? thandks for helping, -- OQube < software engineering \ g?nie logiciel > Arnaud Bailly, Dr. \web> http://www.oqube.com From rasmussen.bryan@REDACTED Mon Sep 4 11:27:01 2006 From: rasmussen.bryan@REDACTED (bryan rasmussen) Date: Mon, 4 Sep 2006 11:27:01 +0200 Subject: Mnesia dB size limits In-Reply-To: References: <17244f480608301041y55d98712r453d80c2a0fd51a1@mail.gmail.com> <00cd01c6cc7c$175957e0$6401a8c0@moneymaker2> Message-ID: <3bb44c6e0609040227j78902caaw2815d53268f5a90f@mail.gmail.com> > > It does become interesting where you need the data "online" all the > time, i.e. requiring random access read/write to records. This > problem you solve by partitioning via whatever mechanism you choose. Any examples of partitioning mechanisms and benefits thereof, I am interested in this particular subject. Thanks, Bryan Rasmussen From raimo+erlang-questions@REDACTED Mon Sep 4 12:36:07 2006 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Mon, 4 Sep 2006 12:36:07 +0200 Subject: [erlang-questions] New mailing list Message-ID: <20060904103607.GA29294@erix.ericsson.se> Hello all. I have transferred all your mailing list accounts to a new machine and new (well) mailing list software: Mailman. Unfortunately the address in your welcome mail got wrong. It will be the same as before: erlang-questions@REDACTED, at least when I am done... -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From rasmussen.bryan@REDACTED Mon Sep 4 12:50:20 2006 From: rasmussen.bryan@REDACTED (bryan rasmussen) Date: Mon, 4 Sep 2006 12:50:20 +0200 Subject: [erlang-questions] Parsing RSS In-Reply-To: References: Message-ID: <3bb44c6e0609040350h418802a0w6594acc4dfc4b396@mail.gmail.com> Well if I understand what you're saying "1ff8\r\n wrote: > There seems to be an issue with url:raw_get_url/2 from www_tools. > > It returns <<"1ff8\r\n> and the first > 6 characters cause the error. > > On Aug 31, 2006, at 10:33 PM, Joel Reymont wrote: > > > Has anyone tried to parse RSS feeds using Erlang? > > > > I tried the example at http://wiki.trapexit.org/index.php/ > > How_to_write_an_RSS_aggregator but xmerl_scan:string blows up. The > > proper URL for the feed is http://rss.slashdot.org/Slashdot/slashdot. > > -- > http://wagerlabs.com/ > > > > > > From richardc@REDACTED Mon Sep 4 13:15:09 2006 From: richardc@REDACTED (Richard Carlsson) Date: Mon, 04 Sep 2006 13:15:09 +0200 Subject: [erlang-questions] scope of variables In-Reply-To: <95be1d3b0609040114i255f0164qdc1998a9792ab3e5@mail.gmail.com> References: <44FBD154.1010103@it.uu.se> <95be1d3b0609040114i255f0164qdc1998a9792ab3e5@mail.gmail.com> Message-ID: <44FC0ABD.7080309@it.uu.se> Vlad Dumitrescu wrote: > On 9/4/06, Richard Carlsson wrote: >> and perhaps define macros that use such lambdas: >> -define(let(X, Y, Z), ((fun (X)-> Z end)(Y))). > > Is it really that simple? This doesn't make for hygienic macros, and > this will fail with a badmatch: > > foo() -> > A = 2, > ?let(X, 3, begin A=1, X+A end). Yes, but that is not so strange. The macro does not create a completely blank scope (it would be pretty useless if you could not import any existing bindings). If you rewrite your example like this, there is no problem: foo() -> A = 2, ?LET(A, 1, ?LET(X, 3, X+A)). (which returns 4, not 5). So, how is that not hygienic? > Oh, so even anonymous funs can be inlined? That's interesting! Yes, the inliner does not really see a difference between normal functions and anonymous funs. In both cases, it's just a functional value bound to a name, and both can be inlined equally well. The Core Erlang code produced for the function foo() above, when using -compile(inline), is simply: 'foo'/0 = fun () -> 4 (This is Core Erlang syntax for "foo() -> 4" - it does not mean that a fun-object will be created.) /Richard From vladdu55@REDACTED Mon Sep 4 13:36:00 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Mon, 4 Sep 2006 13:36:00 +0200 Subject: [erlang-questions] scope of variables In-Reply-To: <44FC0ABD.7080309@it.uu.se> References: <44FBD154.1010103@it.uu.se> <95be1d3b0609040114i255f0164qdc1998a9792ab3e5@mail.gmail.com> <44FC0ABD.7080309@it.uu.se> Message-ID: <95be1d3b0609040436w2b067228y679c115f750b98d5@mail.gmail.com> On 9/4/06, Richard Carlsson wrote: > Vlad Dumitrescu wrote: > > On 9/4/06, Richard Carlsson wrote: > >> and perhaps define macros that use such lambdas: > >> -define(let(X, Y, Z), ((fun (X)-> Z end)(Y))). > > > > Is it really that simple? This doesn't make for hygienic macros, and > > this will fail with a badmatch: > > > > foo() -> > > A = 2, > > ?let(X, 3, begin A=1, X+A end). > > Yes, but that is not so strange. The macro does not create a completely > blank scope (it would be pretty useless if you could not import any > existing bindings). If you rewrite your example like this, there > is no problem: > > foo() -> > A = 2, > ?LET(A, 1, ?LET(X, 3, X+A)). > > (which returns 4, not 5). True, in this case it is easy to rewrite it, but it might be much more difficult in the general setting, where the variable A isn't top-level foo() -> A = 2, ?let(X, [3, 3], begin case X of [A|B] -> B+A; _ -> -1 end). This is simple to rephrase, but imagine there are 10-12 of those free variables. It's not worth rewriting everything just to be able to use ?let, right? It can be done, but it's work that the compiler should do, not the programmer, for a language to be able to claim it has proper macros. Anyway, scoping is just _one_ of the issues involved... *sigh* best regards, Vlad From joelr1@REDACTED Mon Sep 4 13:39:29 2006 From: joelr1@REDACTED (Joel Reymont) Date: Mon, 4 Sep 2006 12:39:29 +0100 Subject: [erlang-questions] Parsing RSS In-Reply-To: <3bb44c6e0609040350h418802a0w6594acc4dfc4b396@mail.gmail.com> References: <3bb44c6e0609040350h418802a0w6594acc4dfc4b396@mail.gmail.com> Message-ID: That's what I was getting. I just couldn't figure out why. On Sep 4, 2006, at 11:50 AM, bryan rasmussen wrote: > Well if I understand what you're saying "1ff8\r\n parsing error because there should not be anything before the XML > declaration in an XML file. -- http://wagerlabs.com/ From cyberdanx@REDACTED Mon Sep 4 14:39:29 2006 From: cyberdanx@REDACTED (Chris Campbell) Date: Mon, 4 Sep 2006 13:39:29 +0100 Subject: [erlang-questions] Disterl error: badrpc exit In-Reply-To: <44FBD066.2050209@ericsson.com> References: <44FBD066.2050209@ericsson.com> Message-ID: That works. Thanks! From richardc@REDACTED Mon Sep 4 15:04:16 2006 From: richardc@REDACTED (Richard Carlsson) Date: Mon, 04 Sep 2006 15:04:16 +0200 Subject: [erlang-questions] scope of variables In-Reply-To: <95be1d3b0609040436w2b067228y679c115f750b98d5@mail.gmail.com> References: <44FBD154.1010103@it.uu.se> <95be1d3b0609040114i255f0164qdc1998a9792ab3e5@mail.gmail.com> <44FC0ABD.7080309@it.uu.se> <95be1d3b0609040436w2b067228y679c115f750b98d5@mail.gmail.com> Message-ID: <44FC2450.60407@it.uu.se> Vlad Dumitrescu wrote: > True, in this case it is easy to rewrite it, but it might be much more > difficult in the general setting, where the variable A isn't top-level > > foo() -> > A = 2, > ?let(X, [3, 3], begin case X of [A|B] -> B+A; _ -> -1 end). > > This is simple to rephrase, but imagine there are 10-12 of those free > variables. It's not worth rewriting everything just to be able to use > ?let, right? It can be done, but it's work that the compiler should > do, not the programmer, for a language to be able to claim it has > proper macros. Ok, so it's not just a question of being able to use local bindings - i's also about being able to inject code (the macro body) into some arbitrary context and avoid accidental name capture of variables in the macro. But then the injected code (not the context) must be written with this in mind, or you will have to do renaming when you inject it. If you know that the macros will not be nested, the simplest solution is to use strange variable names in the macro bodies, for local variables that are bound in patterns, as in: -define(foo(X), case X of [__@REDACTED|__@REDACTED] -> __@REDACTED@a; _ -> -1 end). and you can be fairly sure that they won't capture an existing binding. (Or just don't use patterns at all in macro bodies, for extra safety - use explicit type tests, hd(), tl(), element(), etc., together with the let-macro for local bindings.) /Richard From vladdu55@REDACTED Mon Sep 4 15:17:38 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Mon, 4 Sep 2006 15:17:38 +0200 Subject: [erlang-questions] scope of variables In-Reply-To: <44FC2450.60407@it.uu.se> References: <44FBD154.1010103@it.uu.se> <95be1d3b0609040114i255f0164qdc1998a9792ab3e5@mail.gmail.com> <44FC0ABD.7080309@it.uu.se> <95be1d3b0609040436w2b067228y679c115f750b98d5@mail.gmail.com> <44FC2450.60407@it.uu.se> Message-ID: <95be1d3b0609040617o755f02fj224dddc80d9ca1c9@mail.gmail.com> On 9/4/06, Richard Carlsson wrote: > Ok, so it's not just a question of being able to use local bindings - > i's also about being able to inject code (the macro body) into some > arbitrary context and avoid accidental name capture of variables in the > macro. But then the injected code (not the context) must be written with > this in mind, or you will have to do renaming when you inject it. Yes, or better: have the compiler do it for me. Which is what I'm trying to do. If it will work as advertised, there are a lot of cool things that will become posible to do. Like for example optimizations. If I have to do a lot of math:pow(X, 72) with different X, I could write a powN/2 macro that produces an optimized powN/1 for any particular N (72 in this case). That would be Pow72 = fun(X) -> X2 = X*X, X4 = X2*X2, X8 = X4*X4, X16 = X8*X8, X32 = X16*X16, X64 = X32*X32, X64+X8. Maybe not so spectacular, but a similar example wouuld be to produce custom regexp-matching funs, that might be much more efficient than the current ones. I didn't take that example because it's not as simple to produce one by hand :-) regards, Vlad From erik.reitsma@REDACTED Mon Sep 4 15:35:44 2006 From: erik.reitsma@REDACTED (Erik Reitsma (RY/ETM)) Date: Mon, 4 Sep 2006 15:35:44 +0200 Subject: [erlang-questions] scope of variables In-Reply-To: <44FC2450.60407@it.uu.se> Message-ID: <110BA8ACEE682C479D0B008B6BE4AEB102ED8547@esealmw107.eemea.ericsson.se> > If you know that the macros will not be nested, the simplest > solution is to use strange variable names in the macro > bodies, for local variables that are bound in patterns, as in: > > -define(foo(X), case X of [__@REDACTED|__@REDACTED] -> __@REDACTED@a; _ -> -1 end). When I try to compile this, R10B says that ./t1.erl:10: variable '__@REDACTED' unsafe in 'case' (line 9) ./t1.erl:10: variable '__@REDACTED' unsafe in 'case' (line 9) and rightly so. Changing it to -define(foo(X), case X of [__@REDACTED,__@REDACTED] -> __@REDACTED@a end). gives only warnings, but you cannot use this macro twice in the same scope: -module(t1). -export([test/0]). -define(foo(X), case X of [__@REDACTED,__@REDACTED] -> __@REDACTED@a end). test() -> ?foo([1,2]), ?foo([2,3]). Here t1:test() results in an error, case_clause. So, strange variables will only help if you do not use the macro twice. I think this will lead to errors that are hard to trace. *Erik. From richardc@REDACTED Mon Sep 4 16:06:01 2006 From: richardc@REDACTED (Richard Carlsson) Date: Mon, 04 Sep 2006 16:06:01 +0200 Subject: [erlang-questions] scope of variables In-Reply-To: <110BA8ACEE682C479D0B008B6BE4AEB102ED8547@esealmw107.eemea.ericsson.se> References: <110BA8ACEE682C479D0B008B6BE4AEB102ED8547@esealmw107.eemea.ericsson.se> Message-ID: <44FC32C9.50804@it.uu.se> Erik Reitsma (RY/ETM) wrote: > Changing it to > > -define(foo(X), case X of [__@REDACTED,__@REDACTED] -> __@REDACTED@a end). > > gives only warnings, but you cannot use this macro twice in the same > scope: True. You actually need to wrap the body in a fun-application to prevent it from exporting its bindings: -define(wrap(Body), ((fun ()-> (Body) end)())). -define(foo(X), ?wrap( case X of [__@REDACTED,__@REDACTED] -> __@REDACTED@a end )). /Richard From joe.armstrong@REDACTED Mon Sep 4 16:41:12 2006 From: joe.armstrong@REDACTED (Joe Armstrong (TN/EAB)) Date: Mon, 4 Sep 2006 16:41:12 +0200 Subject: [erlang-questions] group leader blues Message-ID: I have two nodes foo and bar on the same host ws1234. From foo I want to output text in bar's shell. I tried this > P = rpc:call(foo@REDACTED, erlang, whereis, [user]). .. > io:format(P, "\nhello\n", []). Now if the shell in bar looked like this *before* the above command was executed: some text (bar@REDACTED)5> lists:rev Then I expected that I should see this: some text hello (bar@REDACTED)5> lists:revs But instead I see this: some text (bar@REDACTED)5> lists:rev hello Thus io:format does not work the same way that it does from a process spawned locally in the shell running on node bar. So when output from a remote node interrupts input in the local shell the command line is not erased and rewritten correctly. I tried various ways of getting hold of the group leader for shell on the node bar, but non of these seem to work. Does anybody know what's going on here? /Joe From david.nospam.hopwood@REDACTED Mon Sep 4 16:59:02 2006 From: david.nospam.hopwood@REDACTED (David Hopwood) Date: Mon, 04 Sep 2006 15:59:02 +0100 Subject: [erlang-questions] scope of variables In-Reply-To: <95be1d3b0609040617o755f02fj224dddc80d9ca1c9@mail.gmail.com> References: <44FBD154.1010103@it.uu.se> <95be1d3b0609040114i255f0164qdc1998a9792ab3e5@mail.gmail.com> <44FC0ABD.7080309@it.uu.se> <95be1d3b0609040436w2b067228y679c115f750b98d5@mail.gmail.com> <44FC2450.60407@it.uu.se> <95be1d3b0609040617o755f02fj224dddc80d9ca1c9@mail.gmail.com> Message-ID: <44FC3F36.50702@blueyonder.co.uk> Vlad Dumitrescu wrote: > On 9/4/06, Richard Carlsson wrote: > >>Ok, so it's not just a question of being able to use local bindings - >>i's also about being able to inject code (the macro body) into some >>arbitrary context and avoid accidental name capture of variables in the >>macro. But then the injected code (not the context) must be written with >>this in mind, or you will have to do renaming when you inject it. > > Yes, or better: have the compiler do it for me. Which is what I'm trying to do. > > If it will work as advertised, there are a lot of cool things that > will become posible to do. Like for example optimizations. If I have > to do a lot of math:pow(X, 72) with different X, I could write a > powN/2 macro that produces an optimized powN/1 for any particular N > (72 in this case). That would be > Pow72 = fun(X) -> > X2 = X*X, > X4 = X2*X2, > X8 = X4*X4, > X16 = X8*X8, > X32 = X16*X16, > X64 = X32*X32, > X64+X8. X64*X8. I'm also strongly of the opinion that hygiene should be an inherent property of a macro system, and not dependent on hacks like gensym or use of funky variable names. (It is OK to be able to *explicitly* declare that a variable should be captured; this is occasionally useful.) -- David Hopwood From ewan_higgs@REDACTED Mon Sep 4 17:01:43 2006 From: ewan_higgs@REDACTED (Ewan Higgs) Date: Mon, 4 Sep 2006 16:01:43 +0100 (BST) Subject: [erlang-questions] Parsing RSS In-Reply-To: Message-ID: <20060904150143.32259.qmail@web27001.mail.ukl.yahoo.com> > That's what I was getting. I just couldn't figure > out why. I'm not sure I understand you 100% but to be clear: having anything before the References: <20060904150143.32259.qmail@web27001.mail.ukl.yahoo.com> Message-ID: <1157383677.11048.25.camel@humm.localnet> Could it be that the characters before the > That's what I was getting. I just couldn't figure > > out why. > > I'm not sure I understand you 100% but to be clear: > having anything before the illegal. The parser is performing correctly when it > refuses to read the document. > > You may be interested to know about feedvalitator.org > to make sure the feed you're reading is correct. > > -Ewan > From abailly@REDACTED Mon Sep 4 17:45:35 2006 From: abailly@REDACTED (Arnaud Bailly) Date: Mon, 04 Sep 2006 17:45:35 +0200 Subject: [erlang-questions] Mock functions Message-ID: <87psebtz34.fsf@oqube.com> Just to be clear, is here is a decription of what I am trying to do. I want to implement a simple billing web application to evaluate erlang's potential as a tool for model driven engineering: I want to generate a functional skeleton of an application from a model. But before I can do this, I need to learn erlang and usage of OTP platform :-) I have written my model (ie. defined records structure) and now implementing business logic (ie. functions for computing values, retrieving stored data, updating ...). I want my code to be unit tested and I want to be somuwhat independent from the underlying storage used: I could store data in ets tables or in mnesia databases, depending on the usage context. So I am trying to define a generic Data accesse interface that can query record constructs, update, delete or create them in a standard way (BTW, there may already exists such things). In the Java world, I would use some object-relational mapping or direct SQL queries encoded into Data-access objects for insulating businees code from storage impl. So the question is: In erlang, how can I provide "virtual" functions ? I think the only way would be to "thread" a DB interface record containing functions as field into all my business methods. In Haskell, I could write a monad and encapsulate all my business logic in a DB Monad for abstracting away side-effects on the DB layer. In java, I create a reference to a DAO interface that is wired to business object at deploy or creation time. What is the Erlang way to do this ? Thx -- OQube < software engineering \ g?nie logiciel > Arnaud Bailly, Dr. \web> http://www.oqube.com From alex.arnon@REDACTED Mon Sep 4 18:11:38 2006 From: alex.arnon@REDACTED (Alex Arnon) Date: Mon, 4 Sep 2006 19:11:38 +0300 Subject: [erlang-questions] Code generation (was NOOB) In-Reply-To: <44F8C7C8.6050409@nelson.name> References: <44F8C7C8.6050409@nelson.name> Message-ID: <944da41d0609040911g540e882fv2ecc1f87d08aa95f@mail.gmail.com> On 9/2/06, Jay Nelson wrote: > > Bjorn clarified some optimization approaches: > > > We have considered improving the optimization, so that no list would > > > be built in case 2. > > Where case 2 was the line commented <2> below: > > > foo(X) -> > > A = [do_something(E) || E <- X], % <1> > > [do_other(E) || E <- X], % <2> > > ok. > > > > There has been previous debates about use lists:foreach when only > side-effects are desired > and a list comprehension when the result list is needed. I used to > subscribe to that > approach, but the list comprehension is so much clearer that I always use > it now unless > there is reason to be concerned about generating the large list. To me, > <1> and <2> have > clearly marked intent that the first needs the result and the second is > only for side > effects because there is no left side pattern match. > > I would lobby for the compiler to not generate a list in this case. It > allows me to > code in the most consistent and clear style and not have to take a > performance penalty > for doing so. > > There are two other reasons why this optimization might be desirable: > > 1) When (or if) binary comprehensions are added, it would be possible to > use a similar > construct to visit all bytes and emit them via message send or io:format > or write them > to a file, without constructing and consuming new memory. Thus, binaries > nearly the > size of total available RAM could be received, transformed and re-emitted > as below: > > {ok, BigBinary} = file:read_file("bigfile"), %% or from a receive > << AmazonS3 ! convert_to_unicode(ByteChunk) || ByteChunk:1024 <- BigBinary > >>. > > > 2) List Comprehensions (and binary) could be used for infinite streams. > Sort of the > equivalent of tail recursion not using the stack. > > > [ send_to_listeners(Publication) || Publication <- get_next_pub(Publisher) > ] > > get_next_pub(Publisher) -> > receive > {Publisher, Pub} -> Pub > after > 5000 -> end_of_stream %% Hmmm, well some token to tell comprehension > to end. > %% Don't think [] would work. Worst case it > could just exit. > end. > > > Half-baked idea, but if you spawn link the above code, the intent is to > sit emitting > published events to all subscribers until the publisher pauses for 5 > seconds. I think > the coding style makes it concise and clear what is going on. > > Instead of get_next_pub, the generator could be > lazy_gen_all_natural_numbers or some other > infinite stream. > > > jay > > Agreed 101%. Excellent use cases, too. -------------- next part -------------- An HTML attachment was scrubbed... URL: From alex.arnon@REDACTED Mon Sep 4 18:17:12 2006 From: alex.arnon@REDACTED (Alex Arnon) Date: Mon, 4 Sep 2006 19:17:12 +0300 Subject: [erlang-questions] Erlang on Solaris x86 In-Reply-To: References: <03B8C790-1251-47E6-84C3-EF6232F1DC3E@gmail.com> <6056379.post@talk.nabble.com> Message-ID: <944da41d0609040917j4e75fa8bg10988c0e07077a0@mail.gmail.com> Okay, 2 quid per CPU slice... where a single slice is equivalent to a P3 75Mhz. Interesting unit of performance, I'd say :) On 9/3/06, Olivier Lefevre wrote: > > Here's a third: mod3.co.uk; I think these 3 are the only companies > selling Solaris zones at the moment. > > -- O.L. > > PS: "vps" has a strong Linux connotation, which is confusing in this > context; better speak of zones or, if you want to remain generic, of > containers. > > fbg111 wrote: > > > > Joel Reymont wrote: > > > >>Is anyone running Erlang on Solaris x86? > > > > > > I'm not but have been looking for a vps to host the same software stack > on. > > Here's another I found: > > > > http://www.gridzones.com/gridzones_hosting.php > > > > Byron > -------------- next part -------------- An HTML attachment was scrubbed... URL: From david.nospam.hopwood@REDACTED Mon Sep 4 19:10:17 2006 From: david.nospam.hopwood@REDACTED (David Hopwood) Date: Mon, 04 Sep 2006 18:10:17 +0100 Subject: [erlang-questions] Parsing RSS In-Reply-To: <20060904150143.32259.qmail@web27001.mail.ukl.yahoo.com> References: <20060904150143.32259.qmail@web27001.mail.ukl.yahoo.com> Message-ID: <44FC5DF9.4050004@blueyonder.co.uk> Ewan Higgs wrote: >>That's what I was getting. I just couldn't figure >>out why. > > I'm not sure I understand you 100% but to be clear: > having anything before the makes the xml illegal. The parser is performing correctly > when it refuses to read the document. -- David Hopwood From joelr1@REDACTED Mon Sep 4 19:16:53 2006 From: joelr1@REDACTED (Joel Reymont) Date: Mon, 4 Sep 2006 18:16:53 +0100 Subject: [erlang-questions] Parsing RSS In-Reply-To: <1157383677.11048.25.camel@humm.localnet> References: <20060904150143.32259.qmail@web27001.mail.ukl.yahoo.com> <1157383677.11048.25.camel@humm.localnet> Message-ID: <3808667C-26FD-4DD6-9806-913D0DE6CD53@gmail.com> I was just using Joe's www_tools like this: fetch() -> {ok, B} = url:raw_get_url(?URL, ?MAX), B. I haven't looked deeply into it but there maybe a bug in raw_get_url/2. On Sep 4, 2006, at 4:27 PM, Alan Zimmerman wrote: > Could it be that the characters before the unicode byte order encoding? -- http://wagerlabs.com/ From joelr1@REDACTED Mon Sep 4 19:24:12 2006 From: joelr1@REDACTED (Joel Reymont) Date: Mon, 4 Sep 2006 18:24:12 +0100 Subject: [erlang-questions] Mock functions In-Reply-To: <87psebtz34.fsf@oqube.com> References: <87psebtz34.fsf@oqube.com> Message-ID: <8E0D890F-868C-445B-9E89-8B878AAF2D61@gmail.com> You don't have objects in Erlang but you do have processes. These can respond to any message you want since messages are standard Erlang terms (tuples, lists, etc.). There's nothing preventing you from creating two modules (OTP gen_serve) that respond to the same set of messages differently. One implementation is your mock implementation and the other is the real one. Just plug in one process instead of the other, depending on the circumstances, by passing it somewhere as an argument. On Sep 4, 2006, at 4:45 PM, Arnaud Bailly wrote: > So the question is: In erlang, how can I provide "virtual" functions ? > I think the only way would be to "thread" a DB interface record > containing functions as field into all my business methods. In > Haskell, I could write a monad and encapsulate all my business logic > in a DB Monad for abstracting away side-effects on the DB layer. In > java, I create a reference to a DAO interface that is wired to > business object at deploy or creation time. -- http://wagerlabs.com/ From vladdu55@REDACTED Mon Sep 4 20:35:03 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Mon, 4 Sep 2006 19:35:03 +0100 Subject: [erlang-questions] scope of variables In-Reply-To: <44FC3F36.50702@blueyonder.co.uk> References: <44FBD154.1010103@it.uu.se> <95be1d3b0609040114i255f0164qdc1998a9792ab3e5@mail.gmail.com> <44FC0ABD.7080309@it.uu.se> <95be1d3b0609040436w2b067228y679c115f750b98d5@mail.gmail.com> <44FC2450.60407@it.uu.se> <95be1d3b0609040617o755f02fj224dddc80d9ca1c9@mail.gmail.com> <44FC3F36.50702@blueyonder.co.uk> Message-ID: <95be1d3b0609041135m40827684y85c66ec218cec9be@mail.gmail.com> On 9/4/06, David Hopwood wrote: > I'm also strongly of the opinion that hygiene should be an inherent property > of a macro system, and not dependent on hacks like gensym or use of funky > variable names. (It is OK to be able to *explicitly* declare that a variable > should be captured; this is occasionally useful.) Hi, I'm not sure if it's possible to have a hygienic macro system that doesn't use gensym behind the scenes. I suppose you mean that the user shouldn't have to bother with it. And of course he/she shouldn't! regards, Vlad From david.nospam.hopwood@REDACTED Mon Sep 4 20:55:53 2006 From: david.nospam.hopwood@REDACTED (David Hopwood) Date: Mon, 04 Sep 2006 19:55:53 +0100 Subject: [erlang-questions] scope of variables In-Reply-To: <95be1d3b0609041135m40827684y85c66ec218cec9be@mail.gmail.com> References: <44FBD154.1010103@it.uu.se> <95be1d3b0609040114i255f0164qdc1998a9792ab3e5@mail.gmail.com> <44FC0ABD.7080309@it.uu.se> <95be1d3b0609040436w2b067228y679c115f750b98d5@mail.gmail.com> <44FC2450.60407@it.uu.se> <95be1d3b0609040617o755f02fj224dddc80d9ca1c9@mail.gmail.com> <44FC3F36.50702@blueyonder.co.uk> <95be1d3b0609041135m40827684y85c66ec218cec9be@mail.gmail.com> Message-ID: <44FC76B9.9080406@blueyonder.co.uk> Vlad Dumitrescu wrote: > On 9/4/06, David Hopwood wrote: > >> I'm also strongly of the opinion that hygiene should be an inherent >> property of a macro system, and not dependent on hacks like gensym or >> use of funky variable names. (It is OK to be able to *explicitly* >> declare that a variable should be captured; this is occasionally useful.) > > I'm not sure if it's possible to have a hygienic macro system that > doesn't use gensym behind the scenes. Well, it is not necessary for the implementation to generate a unique string as an identifier. It is simpler to accept unique tokens, as well as strings, in place of identifiers. > I suppose you mean that the user shouldn't have to bother with it. That's what I mean, yes. > And of course he/she shouldn't! "Of course", but many macro systems do require this. Also note that hygiene is orthogonal to whether you use a separate sublanguage to define macros (like Scheme syntax-rules) or the full language (like Common Lisp defmacro). -- David Hopwood From cyberlync@REDACTED Mon Sep 4 20:57:19 2006 From: cyberlync@REDACTED (Eric Merritt) Date: Mon, 4 Sep 2006 11:57:19 -0700 Subject: [erlang-questions] New Articles on Trap Exit In-Reply-To: References: <5723172F-F3BC-4EB8-9C27-7D4E09807BBC@patternmatched.com> Message-ID: Brent, I am glad you got around to this. It looked like I wasn't going to have time to do it for another week or so. This is great. On 9/3/06, Brent Fulgham wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > > On Sep 2, 2006, at 4:07 AM, Rudolph van Graan wrote: > > > I've added a bunch of my own articles to Trap Exit and created some > > more categories. Most important is the new HowTo on testing. > > > > Comments (and changes) welcome. > > In the same vein, I've gone through and ported over the remaining > pages in the Erlang Cookbook to TrapExit, as well as edited a few > links and categories in the CookBook. I'll see about adding more > info soon... > > One thing I really miss is the ability to do real syntax highlighting > in MediaWiki. Compare, for example, the enscript-based highlighting > in the original CookBook (http://schemecookbook.org/Erlang/ > FileReadingLines) to the new version (http://wiki.trapexit.org/ > index.php/Reading_Lines_from_a_File). > > Does anyone know if there are better options for syntax highlighting > code in this Wiki? > > Thanks, > > - -Brent > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.2.2 (Darwin) > > iD8DBQFE+5XDzGDdrzfvUpURAuwoAJ9dVnvse3HtWKxgkVyyTlQi0JgjiQCeIRG2 > h4Q963ZuaZXa+q1rPQ3ut/8= > =aDCo > -----END PGP SIGNATURE----- > From abailly@REDACTED Mon Sep 4 21:57:28 2006 From: abailly@REDACTED (Arnaud Bailly) Date: Mon, 04 Sep 2006 21:57:28 +0200 Subject: [erlang-questions] Mock functions In-Reply-To: <8E0D890F-868C-445B-9E89-8B878AAF2D61@gmail.com> (Joel Reymont's message of "Mon, 4 Sep 2006 18:24:12 +0100") References: <87psebtz34.fsf@oqube.com> <8E0D890F-868C-445B-9E89-8B878AAF2D61@gmail.com> Message-ID: <87d5abtnfb.fsf@oqube.com> Joel Reymont writes: > You don't have objects in Erlang but you do have processes. These can > respond to any message you want since messages are standard Erlang > terms (tuples, lists, etc.). I arrived to this conclusion too :-) Thanks for answering. -- OQube < software engineering \ g?nie logiciel > Arnaud Bailly, Dr. \web> http://www.oqube.com From xpdoka@REDACTED Mon Sep 4 22:39:06 2006 From: xpdoka@REDACTED (Dominic Williams) Date: Mon, 04 Sep 2006 22:39:06 +0200 Subject: [erlang-questions] Theoretically stuck Message-ID: <44FC8EEA.6070307@dominicwilliams.net> Rudolph van Graan wrote: > In OO it is trivial to model data and more difficult to > customize behaviour. Having been an OO biggot before discovering Erlang, I would point out that OO is supposed to be all about modelling behaviour, NOT data. Hence, trying to mimick OO features to get data modelling in Erlang might be barking up the wrong tree altogether Having said that... > In FP (erlang) behaviour modeling is trivial and data > modeling becomes a challenge. > > How do you write code that wraps the concept/data of a > person? A record with name and surname fields is the > obvious answer: > > -record(person,{name,surname}). Records are but one way, the shortcomings of which, given the current state of records, you have clearly pointed out. Another approach is to create an abstract data type (ADT): a module that provides all the functions needed to manipulate a type. Data gets passed in and out of these functions as opaque terms which should not be manipulated directly. The dict module in Erlang is an example of this. > Now I want to make a version of person with an extra > field, say telephone number. Not all records have this. > Some have a work address as well. Even in OO, this need not (and probably should not) be modelled with inheritance. In Java or Erlang, an ADT is quite capable of managing an optional (possibly undefined) field, as well as functions that can only be used given certain preconditions (initial state, including things like an optional field being defined). A more legitimate use of inheritance (and even then, many OO designers prefer delegation to inheritance in many cases) is to provide an ALTERNATIVE BEHAVIOUR in the event of the SAME function call. In OO, this is achieved by subclassing. In FP, this is achieved using higher-order functions: the common behaviour is in a function that needs to be passed one or several functions that perform the specific parts. Yet another possibility, not FP but Erlang, is to model objects with processes... The message passing protocol then becomes the interface, which can easily be extended by any other module which provides the original protocol. Regards, Dominic Williams http://www.dominicwilliams.net ---- From xpdoka@REDACTED Mon Sep 4 22:53:38 2006 From: xpdoka@REDACTED (Dominic Williams) Date: Mon, 04 Sep 2006 22:53:38 +0200 Subject: [erlang-questions] Mock functions Message-ID: <44FC9252.4090205@dominicwilliams.net> Arnaud Bailly wrote: > For unit testing my java code, I use mock objects for all > interfaces I need in the context of the OUT. This allows > me to precisely control what's goinig in and out of my > object. > > I could think of several ways to do this in Erlang but > they all seem a bit contrived. Is there something > "canonical" for doing this kind of tests ? In OO, mock objects are often used to verify that during a call, the OUT is pulling the right strings on other objects that it carries in its state. In functional programming, one aims to avoid such side effects: a function's return value should only depend on input parameters. Such functions are a lot easier to test, and don't require the complication of mocks at all. In OO, mock objects can also be used to verify that the OUT is delegating part of its behaviour to an interface: the mock or stub implements that interface to get used by the OUT. In functional programming, the "delegation" would happen by passing to the function another function that performs part of the work. In this case, lambda is the ultimate mock! In your test, you can provide the function under test with a dummy fun, a lot more easily than you would write a mock. I'd be happy to address a specific example if you have a problem at hand... Regards, Dominic Williams http://www.dominicwilliams.net ---- From bfulg@REDACTED Tue Sep 5 01:01:19 2006 From: bfulg@REDACTED (Brent Fulgham) Date: Mon, 4 Sep 2006 16:01:19 -0700 Subject: [erlang-questions] New Articles on Trap Exit In-Reply-To: References: <5723172F-F3BC-4EB8-9C27-7D4E09807BBC@patternmatched.com> Message-ID: <81DD93DF-B90A-4196-8FFA-223D3D759290@pacbell.net> On Sep 4, 2006, at 11:57 AM, Eric Merritt wrote: > Brent, > > I am glad you got around to this. It looked like I wasn't going to > have time to do it for another week or so. This is great. I rearranged a couple of pages to use the Categories feature in MediaWiki -- but I'm not sure how to remove pages once they exist. Is there a way to do so? Thanks, -Brent From headspin@REDACTED Tue Sep 5 03:23:53 2006 From: headspin@REDACTED (dda) Date: Tue, 5 Sep 2006 03:23:53 +0200 Subject: [erlang-questions] Parsing RSS In-Reply-To: <44FC5DF9.4050004@blueyonder.co.uk> References: <20060904150143.32259.qmail@web27001.mail.ukl.yahoo.com> <44FC5DF9.4050004@blueyonder.co.uk> Message-ID: Buf 1ff8\r\n doesn't look like any known BOM... http://en.wikipedia.org/wiki/Byte_Order_Mark -- Didier On 9/4/06, David Hopwood wrote: > Ewan Higgs wrote: > >>That's what I was getting. I just couldn't figure > >>out why. > > > > I'm not sure I understand you 100% but to be clear: > > having anything before the > ... except a Byte Order Mark ... > > > makes the xml illegal. The parser is performing correctly > > when it refuses to read the document. > > -- > David Hopwood > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- dda libcurl4RB, [S]FTP transfers made easy http://sungnyemun.org/?q=node/8 From bob@REDACTED Tue Sep 5 03:48:20 2006 From: bob@REDACTED (Bob Ippolito) Date: Mon, 4 Sep 2006 18:48:20 -0700 Subject: [erlang-questions] Parsing RSS In-Reply-To: References: <20060904150143.32259.qmail@web27001.mail.ukl.yahoo.com> <44FC5DF9.4050004@blueyonder.co.uk> Message-ID: <6a36e7290609041848u24dc9c0dj423c9d6ba543ab1d@mail.gmail.com> What it does look like is an incorrectly parsed HTTP/1.1 chunked encoding response. -bob On 9/4/06, dda wrote: > Buf 1ff8\r\n doesn't look like any known BOM... > > http://en.wikipedia.org/wiki/Byte_Order_Mark > > -- > Didier > > On 9/4/06, David Hopwood wrote: > > Ewan Higgs wrote: > > >>That's what I was getting. I just couldn't figure > > >>out why. > > > > > > I'm not sure I understand you 100% but to be clear: > > > having anything before the > > > ... except a Byte Order Mark ... > > > > > makes the xml illegal. The parser is performing correctly > > > when it refuses to read the document. > > > > -- > > David Hopwood > > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > -- > dda > libcurl4RB, [S]FTP transfers made easy > http://sungnyemun.org/?q=node/8 > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From yarivvv@REDACTED Tue Sep 5 06:42:04 2006 From: yarivvv@REDACTED (Yariv Sadan) Date: Tue, 5 Sep 2006 00:42:04 -0400 Subject: [erlang-questions] Theoretically Stuck In-Reply-To: References: <972C6E38-7253-49F8-AA24-91253F78E1FD@patternmatched.com> Message-ID: <17244f480609042142j65207e27jf10acbbf004bd68c@mail.gmail.com> > > That should be reasonably easy to solve with a parse transform. > Yariv's Smerl supports a form of inheritance too, if I'm not > mistaken. > (Moved all weekend to a new city so sorry for the late reply) Yes, Smerl does module extension. You can check this page out http://yarivsblog.com/articles/2006/08/22/new-module-extension-in-erlang-with-smerl for more information. Best, Yariv From abailly@REDACTED Tue Sep 5 10:20:51 2006 From: abailly@REDACTED (Arnaud Bailly) Date: Tue, 05 Sep 2006 10:20:51 +0200 Subject: [erlang-questions] Mock functions In-Reply-To: <44FC9252.4090205@dominicwilliams.net> (Dominic Williams's message of "Mon, 04 Sep 2006 22:53:38 +0200") References: <44FC9252.4090205@dominicwilliams.net> Message-ID: <87veo2sp0c.fsf@oqube.com> Dominic Williams writes: > In functional programming, the "delegation" would happen by > passing to the function another function that performs part > of the work. In this case, lambda is the ultimate mock! In > your test, you can provide the function under test with a > dummy fun, a lot more easily than you would write a mock. > That's the other option I was thinking of, but I feel this may rapidly grows unmanageable if you happen to use several "components" and interfaces. Or maybe I could use front end functions that delegates work to back end functions: The former with "data" parameters, the latter with "behavior" parameter. However, the message-passing apporch seems easier to implement and cleaner. > I'd be happy to address a specific example if you have a > problem at hand... Yes, I have one. To teach myself erlang and to stuby how FP can be used in a MDE approach, I am implementing a small web application to handle billing of customers account. No interesting feature in the application itself but that's the first example tha sprung to my mind. Clasically (at least in a Java EE setting), one has several layers: - a presentation layer that handles communication with client and ensures proper flow of operations of the application and input/output formatting - a business layer that offers functions to manipulate data passing back and forth from the presentation layer - a persistence layer that stores and retrieve data from some storage What I need is a way to abstract the persistence layer so that I can "plug" different data backend. Nothing really new under the sun. My post was motivated by the fact that, as I do test-driven development, I want to write tests for the business layer and so I need a way to plug a test backend. Here is the code, in bad shape and really sketchy. As I said before, I am just learning erlang and OTP. % Description of record structures for billing system -record(account , { id, % unique identification for account name, % string identifier address, currency = euro }). % accounts relationships: % account to projects: one to many -record(account_project , { account_id , % identification of account project_id % id of related project }). % Account to contact: many-to-many -record(account_contact, { account_id , contact_id , role }). % note: one-to-one relations are inlined % structure representing a project -record(project, {id, name, description, project_lead, % contact id for project leader account_id % related account id. may not be undefined }). -record(project_contact, { project_id , contact_id , role % a string }). % structure representing a contact: a physical individual that is related % to a project and account (commercial contact, technical,...) -record(contact, {id, name, phones = [] , % a list of phone numbers emails = [] % multiple emails per contact }). % a billable item -record(item, {id, description, unit_price = 1, % price per unit quantity = 1, % number of units unit = days, % base unit are days currency = euro, vat = 0.196, % project_id % may not be null }). % a bill -record(bill, { id, date, validated = false, account_id }). % bills relation to items: one to many -record(bill_items, { bill_id, item_id }). % currencies -record(currency, { id, date, % date for valution base = euro, % base: another currency's id value = 1.0 }). % list of all records with type of table model() -> [ {record_info(fields, account),set}, {record_info(fields, account_contact),bag}, {record_info(fields, account_project),bag}, {record_info(fields, project),set}, {record_info(fields, project_contact),bag}, {record_info(fields, contact),set}, {record_info(fields, item),set}, {record_info(fields, bill),set}, {record_info(fields, bill_items),bag}, {record_info(fields, currency),set} ]. %%%------------------------------------------------------------------- %%% File : billing_ops.erl %%% Author : Arnaud Bailly %%% Description : Contains the business operations %%% %%% Created : 4 Sep 2006 by Arnaud Bailly %%%------------------------------------------------------------------- -module(billing_ops). -author('abailly@REDACTED). %% defines common backend operations -import(db_ops). -include("billing_model.hrl"). %% @doc Create a new account and returns its id. account_create(Name,Address,Currency) -> % check currency exists case currency_lookup(#currency{id=Currency}) of {ok, X} when X > 0 -> % create id and insert record Id = next_id(account), dbcreate(#account{id=Id,name=Name,address=Address,currency=Currency}), {ok,Id}; {ko,Reason} = Fail -> Fail end. %% @doc lookup an account with values matching the given %% account tuple. account_lookup_byname(Name) -> dblookup(#account{id = '_',name=Name,address='_',currency ='_'}). account_lookup_by_contact_name(Name) -> % lookup contacts Contacts = dblookup(#contact{id='_', name=Name, phones='_', emails='_' }), % lookup account_contact Accts_Cts = lists:flatmap(fun (#contact{id=Id,name=_,phones=_,emails=_}) -> dblookup(#account_contact{account_id = '_', contact_id = Id, role ='_'}) end, Contacts), lists:flatmap(fun (#account_contact{account_id = Id, contact_id = _, role = _ }) -> dblookup(#account{id = Id,name='_',address='_',currency='_'}) end, Accts_Cts). account_lookup_by_project_name(Name) -> % lookup projects Projects = dblookup(#project{id='_', name=Name, description='_', project_lead='_', account_id='_'}), % lookup account_contact Accts = lists:flatmap(fun (#project{id=_, name=_, description=_, project_lead=_, account_id=Acct }) -> dblookup(#account{id = Acct, name='_', address='_', currency='_'}) end, Projects). % module for handling database operations for 'billing' application % provide: % - initialisation routines for the database, schema creation % - CRUD operations with some checking for each record -module(billing_data). -export([init_db/1]). -include("billing_model.hrl"). %% @doc This function initializes the database schema. It expects %% mnesia system to have been started. %% - initialize mnesia system on given nodes %% - create schema and tables %% @param Nodes list of Nodes to initialize init_db(Nodes) -> {ok,Tbls} = make_table(model(),Nodes,[]), mnesia:wait_for_tables(Tbls,0) . % create a table for given record type in nodes make_table([ { {RName, Flds }, Type} | T ], Nodes, Tbls) -> case mnesia:create_table(RName, [ {type, Type}, {ram_copies, Nodes}, {attributes, Flds }]) of {_,ok} -> make_table(T, Nodes,[RName|Tbls]); {aborted,Reason} -> {error,Reason} end; make_table([],_Nodes, Tbls) -> {ok,Tbls}. Thanks for helping -- OQube < software engineering \ g?nie logiciel > Arnaud Bailly, Dr. \web> http://www.oqube.com From S.J.Thompson@REDACTED Tue Sep 5 10:32:36 2006 From: S.J.Thompson@REDACTED (S.J.Thompson) Date: Tue, 5 Sep 2006 09:32:36 +0100 (BST) Subject: [erlang-questions] Erlang Book - again In-Reply-To: References: Message-ID: great idea! A related suggestion is that as well as making it freely available is also to make it available via a "print on demand" service, so that you can get a book-like copy if you wish. You can see an example of this at http://www.cafepress.com/buy/book/-/pv_design_prod/pg_4/p_storeid.11895795/pNo_11895795/id_4615872/opt_/fpt_________________H/c_0/ Kind regards, Simon On Tue, 29 Aug 2006, Dmitrii Dimandt wrote: > What are the chances of "Concurrent Programming in Erlang" book becoming > available online in its entirety? > > Why I'm asking this is that the book is clearly out of print (see Amazon > hereand > here). > The only available books are available at ridiculous > prices > . > > Practical Common Lisp has been online > forever, it seems. And the publisher gave the author perennial rights to > publish the book on the web. > Moreover, Paul Graham's "On Lisp" is now also available for > download > . > > May be Prentice Hall could be forced into giving the rights to the book back > to its authors? And may be the authors could be persuaded to create an > online copy of it? :) > > Or, better still, may be the authors could be persuaded to write a new book > :) > From joe.armstrong@REDACTED Tue Sep 5 10:38:59 2006 From: joe.armstrong@REDACTED (Joe Armstrong (TN/EAB)) Date: Tue, 5 Sep 2006 10:38:59 +0200 Subject: [erlang-questions] new blog postng In-Reply-To: <944da41d0609040917j4e75fa8bg10988c0e07077a0@mail.gmail.com> Message-ID: http://armstrongonsoftware.blogspot.com/2006/09/why-i-dont-like-shared-m emory.html /Joe -------------- next part -------------- An HTML attachment was scrubbed... URL: From xpdoka@REDACTED Tue Sep 5 10:44:40 2006 From: xpdoka@REDACTED (Dominic Williams) Date: Tue, 5 Sep 2006 10:44:40 +0200 (CEST) Subject: [erlang-questions] Mock functions Message-ID: <37558.81.249.1.7.1157445880.squirrel@www.geekisp.com> Arnaud Bailly wrote: > So the question is: In erlang, how can I provide "virtual" > functions ? I think the only way would be to "thread" a > DB interface record containing functions as field into all > my business methods. In Haskell, I could write a monad and > encapsulate all my business logic in a DB Monad for > abstracting away side-effects on the DB layer. In java, I > create a reference to a DAO interface that is wired to > business object at deploy or creation time. > > What is the Erlang way to do this ? I would create a server (Erlang process or gen_server) that acts as broker for all data access. It responds to Erlang messages from other processes. Then, for tests it becomes trivial to provide a fake implementation which returns predefined answers, or answers defined by the test cases themselves. You can either pass the Pid of this data server to all modules and functions that use it, or use a named (registered) process. Either way makes it easy to provide a fake server for tests, or to switch to a new implementation if the backend changes. Cheers, Dominic Williams http://www.dominicwilliams.net ---- From joelr1@REDACTED Tue Sep 5 11:02:05 2006 From: joelr1@REDACTED (Joel Reymont) Date: Tue, 5 Sep 2006 10:02:05 +0100 Subject: [erlang-questions] Shared memory and message passing In-Reply-To: References: Message-ID: <3A830CE5-64CA-4F65-90C6-4E418BA38AD9@gmail.com> Joe, What about using shared memory to optimize message passing and avoid copying memory? This does not involve locks or critical sections, right? Thanks, Joel -- http://wagerlabs.com/ From joe.armstrong@REDACTED Tue Sep 5 11:06:19 2006 From: joe.armstrong@REDACTED (Joe Armstrong (TN/EAB)) Date: Tue, 5 Sep 2006 11:06:19 +0200 Subject: [erlang-questions] Shared memory and message passing In-Reply-To: <3A830CE5-64CA-4F65-90C6-4E418BA38AD9@gmail.com> Message-ID: This kind of usage is, I guess OK, if it's hidden from the user as part of an language implementation, but it should definitely not be exposed to the application programmer. It's rather like garbage collection - or page table manipulation ok for a very small number of system programmers to use, but forbidden in regular applications /Joe > -----Original Message----- > From: Joel Reymont [mailto:joelr1@REDACTED] > Sent: den 5 september 2006 11:02 > To: Joe Armstrong (TN/EAB) > Cc: erlang-questions@REDACTED > Subject: Shared memory and message passing > > Joe, > > What about using shared memory to optimize message passing > and avoid copying memory? > > This does not involve locks or critical sections, right? > > Thanks, Joel > > -- > http://wagerlabs.com/ > > > > > > From matthias@REDACTED Tue Sep 5 11:50:22 2006 From: matthias@REDACTED (Matthias Lang) Date: Tue, 5 Sep 2006 11:50:22 +0200 Subject: [erlang-questions] was there a bugfix to {packet, line} mode between R10B and R11B? Message-ID: <17661.18526.972650.484663@antilipe.corelatus.se> Hi, I've attached a test program. It sends lines of data over a TCP socket, like this: AAAAAAAAAAAA\r\n BBBBBBBBBBBB\r\n CCCCCCCCCCCC\r\n DDDDDDDDDDDD\r\n and then receives them with the {packet, line} option. The odd thing is that, sometimes, one of the lines goes missing. Running the test for different combinations of OS and OTP release: Operating System R10B-10 R11B-0 ------------------------------------------------------------- Linux ok ok Windows XP fails ok To run the test program, compile it and win_fail:go(). The program loops forever on correct behaviour. It stops on failure. At the moment, I'm stuck: - I can't find any fixed ERTS bugs which match the symptoms I'm seeing - I can't see any differences between the inet driver in R10B-10 and R11B-0 which fix such a bug, i.e. I'm slightly worried that the bug is present in both, but masked in R11B. - I'm not doing anything dodgy - I don't know how to debug in windows; I don't even have a C compiler for Windows. Clues appreciated. Matthias -------------- next part -------------- A non-text attachment was scrubbed... Name: win_fail.erl Type: application/octet-stream Size: 1554 bytes Desc: not available URL: From joelr1@REDACTED Tue Sep 5 12:12:48 2006 From: joelr1@REDACTED (Joel Reymont) Date: Tue, 5 Sep 2006 11:12:48 +0100 Subject: [erlang-questions] xmerl.hrl Message-ID: Folks, What's an easy way to locate xmerl.hrl and include it? Do I give command line options to erl or should I reference the OTP installation using some internal variable? The reason is that including xmerl.hrl should let me avoid pattern matching like parse({{xmlElement, _, _, _, _, _, _, _Attrs, Content, _, _, _}, []}) -> ... and reference Rec#xmlElement.content instead. Thanks, Joel -- http://wagerlabs.com/ From ft@REDACTED Tue Sep 5 12:19:48 2006 From: ft@REDACTED (Fredrik Thulin) Date: Tue, 5 Sep 2006 12:19:48 +0200 Subject: [erlang-questions] xmerl.hrl In-Reply-To: References: Message-ID: <200609051219.48891.ft@it.su.se> On Tuesday 05 September 2006 12:12, Joel Reymont wrote: > Folks, > > What's an easy way to locate xmerl.hrl and include it? -include_lib("xmerl/include/xmerl.hrl"). /Fredrik From xpdoka@REDACTED Tue Sep 5 12:23:12 2006 From: xpdoka@REDACTED (Dominic Williams) Date: Tue, 5 Sep 2006 12:23:12 +0200 (CEST) Subject: [erlang-questions] xmerl.hrl Message-ID: <5984.81.249.1.7.1157451792.squirrel@www.geekisp.com> Joel Reymont wrote: > What's an easy way to locate xmerl.hrl and include it? -include_lib("xmerl/include/xmerl.hrl"). Cheers, Dominic Williams http://www.dominicwilliams.net ---- From raimo+erlang-questions@REDACTED Tue Sep 5 11:06:42 2006 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Tue, 5 Sep 2006 11:06:42 +0200 Subject: [erlang-questions] New mailing list In-Reply-To: <20060904103607.GA29294@erix.ericsson.se> References: <20060904103607.GA29294@erix.ericsson.se> Message-ID: <20060905090642.GA14099@erix.ericsson.se> More slight problems... The ones of you that were subscribed to both erlang-questions-posters and erlang-questions, will have the "nomail" flag set, and hence not get any mail... terefore not this one either. *Sigh* On Mon, Sep 04, 2006 at 12:36:07PM +0200, Raimo Niskanen wrote: > Hello all. > > I have transferred all your mailing list accounts to a new > machine and new (well) mailing list software: Mailman. > > Unfortunately the address in your welcome mail got wrong. > It will be the same as before: erlang-questions@REDACTED, > at least when I am done... > > -- > > / Raimo Niskanen, Erlang/OTP, Ericsson AB > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From sharevon@REDACTED Tue Sep 5 16:57:00 2006 From: sharevon@REDACTED (sharevon) Date: Tue, 5 Sep 2006 22:57:00 +0800 Subject: [erlang-questions] Questhion about Megaco stack Message-ID: I have posted this email, but no one answered. :-( So I post it again. I have some trouble in differing megaco_session_0.5 and Megaco 3.2.3 as part of Erlang/OTP R10B-9 from each other. Are they different? Or ,megaco_session_0.5 is just a previous version of Megaco 3.2.3. Another question is about examples in megaco 3.2.3. Can Simple MGC and Simple MG do other things ,besides Simple MG send ServiceChange command to 4 interfaces, as TCP/UDP 2944 and 2945, of Simple MGC? If not, how could I control the Simple MGC and MG to construct a test enviorment of one MGC and two MG, and make them to do some real works like adding, modifying, substracting some terminations to some context or making MG to observe some events? Thanks. Sharevon From juhani@REDACTED Tue Sep 5 19:35:18 2006 From: juhani@REDACTED (Juhani Rankimies) Date: Tue, 05 Sep 2006 10:35:18 -0700 Subject: [erlang-questions] erlrt windows distribution: incorrect paths Message-ID: <20060905103518.3d0f1a0d95efa21718d57d97bd95181c.e5cc1c83f8.wbe@email.secureserver.net> I don't know if this has been reported before. If so, sorry for the noise. There are incorrect paths in erlrt Windows distribution start.bat and erlang\erts-5.5\bin\erl.ini. start.bat: -cd erlang\erts-5.4.12\bin +cd erlang\erts-5.5\bin erlang\erts-5.5\bin\erl.ini assumes that erlang is installed in C:\Program Files\erl5.5 regards, juhani From robert.virding@REDACTED Tue Sep 5 23:32:10 2006 From: robert.virding@REDACTED (Robert Virding) Date: Tue, 05 Sep 2006 23:32:10 +0200 Subject: [erlang-questions] Code generation (was NOOB) In-Reply-To: <44F8C7C8.6050409@nelson.name> References: <44F8C7C8.6050409@nelson.name> Message-ID: <44FDECDA.4040905@telia.com> Jay Nelson wrote: > Bjorn clarified some optimization approaches: > > > We have considered improving the optimization, so that no list would > >> be built in case 2. > > > Where case 2 was the line commented <2> below: > >> foo(X) -> >> A = [do_something(E) || E <- X], % <1> >> [do_other(E) || E <- X], % <2> >> ok. You must clarify what you mean is the exact difference between <1> and <2>? Is it the explicit assignment to A? Or that the return value is never used? If it is the assignment then that is a very "sub-optimal" (to be nice) way of ascertaining whether the return value is used. The compiler has no difficult in finding out if the return value form the lc (the list) is actually used so checking for as assignment is useless. It should not cause any problems if the actual list was not built, just as long as the code to build the list elements is executed for each element-not-to-be. The code can contain side-effects or cause an error. Actually, the only difference between <1> and <2> is that <1> calls do_something on each element of X, while <2> calls do_other. Robert P.S. I think you should use code which builds a list when you want to build a list, not for side-effects! But then again I am a purist. From robert.virding@REDACTED Tue Sep 5 23:36:57 2006 From: robert.virding@REDACTED (Robert Virding) Date: Tue, 05 Sep 2006 23:36:57 +0200 Subject: [erlang-questions] Shared memory and message passing In-Reply-To: References: Message-ID: <44FDEDF9.700@telia.com> I agree with Joe, the Erlang implementation can use whatever mechanisms it likes just as long as the semantics are unchanged. Actually this is no problem as Erlang does not allow updating of data. Single heap memory models never copy data from one process to another, they just pass the reference. Sending messages is an O(1) operation. Robert Joe Armstrong (TN/EAB) wrote: > This kind of usage is, I guess OK, if it's hidden from the > user as part of an language implementation, but it should > definitely not be exposed to the application programmer. > > It's rather like garbage collection - or page table manipulation > ok for a very small number of system programmers to use, but > forbidden in regular applications > > /Joe > > >>-----Original Message----- >>From: Joel Reymont [mailto:joelr1@REDACTED] >>Sent: den 5 september 2006 11:02 >>To: Joe Armstrong (TN/EAB) >>Cc: erlang-questions@REDACTED >>Subject: Shared memory and message passing >> >>Joe, >> >>What about using shared memory to optimize message passing >>and avoid copying memory? >> >>This does not involve locks or critical sections, right? >> >> Thanks, Joel >> >>-- >>http://wagerlabs.com/ >> >> >> >> >> >> > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From joelr1@REDACTED Wed Sep 6 00:18:34 2006 From: joelr1@REDACTED (Joel Reymont) Date: Tue, 5 Sep 2006 23:18:34 +0100 Subject: [erlang-questions] Shared memory and message passing In-Reply-To: <44FDEDF9.700@telia.com> References: <44FDEDF9.700@telia.com> Message-ID: <5DD95444-85E2-4623-9FF9-B53C57C01E54@gmail.com> I thought Erlang as it is right now _does_ copy data. Am I mistaken? Why the talk about about copying binaries, etc. otherwise? On Sep 5, 2006, at 10:36 PM, Robert Virding wrote: > I agree with Joe, the Erlang implementation can use whatever > mechanisms it likes just as long as the semantics are unchanged. > Actually this is no problem as Erlang does not allow updating of > data. Single heap memory models never copy data from one process to > another, they just pass the reference. Sending messages is an O(1) > operation. -- http://wagerlabs.com/ From yarivvv@REDACTED Wed Sep 6 00:53:42 2006 From: yarivvv@REDACTED (Yariv Sadan) Date: Tue, 5 Sep 2006 18:53:42 -0400 Subject: [erlang-questions] will Erlang ever have currying? Message-ID: <17244f480609051553i1ba9c08ck3ab38cce1f969802@mail.gmail.com> Hi, I couple of my functional programmer friends have complained about Erlang's lack of currying. (One of them has even described currying as "more addictive than heroin without the nasty effects" :) ). I didn't get a "final" answer last time I asked this question, so I'd like to ask it again (at least so I have an intelligent answer to give to others): will Erlang ever have currying? This is the kind of currying I mean, in pseudo code: F = fun(A,B) -> A+B end. F1 = F(2). true = F1(3) == 5. Thanks in advance. Regards, Yariv From david.nospam.hopwood@REDACTED Wed Sep 6 01:44:08 2006 From: david.nospam.hopwood@REDACTED (David Hopwood) Date: Wed, 06 Sep 2006 00:44:08 +0100 Subject: [erlang-questions] Shared memory and message passing In-Reply-To: <3A830CE5-64CA-4F65-90C6-4E418BA38AD9@gmail.com> References: <3A830CE5-64CA-4F65-90C6-4E418BA38AD9@gmail.com> Message-ID: <44FE0BC8.4000500@blueyonder.co.uk> Joel Reymont wrote: > Joe, > > What about using shared memory to optimize message passing and avoid > copying memory? As long as these optimizations are transparent (which they should be), this isn't using shared memory at the application level. All of the disadvantages of shared state *do* apply when using it in the implementation of a language; it's just that these disadvantages may be worth dealing with at that level, because they are amortized over all applications that the language implementation can support. > This does not involve locks or critical sections, right? Mu. (It probably doesn't for efficiency reasons; message passing can be implemented in a lock-free way more efficiently than using locks. But that's up to the language implementor.) -- David Hopwood From robert.kenneth.smart@REDACTED Wed Sep 6 02:22:33 2006 From: robert.kenneth.smart@REDACTED (Robert Smart) Date: Wed, 6 Sep 2006 10:22:33 +1000 Subject: [erlang-questions] will Erlang ever have currying? In-Reply-To: <17244f480609051553i1ba9c08ck3ab38cce1f969802@mail.gmail.com> References: <17244f480609051553i1ba9c08ck3ab38cce1f969802@mail.gmail.com> Message-ID: <155f3edf0609051722p3df0dcbdv847331cbf30bdd0d@mail.gmail.com> > F = fun(A,B) -> A+B end. > F1 = F(2). As long as a language does closures right (erlang does) and has a notation for anonymous functions (erlang does) then we can do currying: F1 = fun(X) -> F(2,X) end. Which works whichever parameter we want to fix. Traditional left to right currying only makes sense for those languages where functional application is written (f a b) which actually means ((f a) b). Half the time the first parameter isn't the one you want to fix. Perl6 has kitchen sink currying. I doubt if we want to go there. You can do currying in scala if you define the function that way (http://scala.epfl.ch/intro/currying.html). But we can do that in erlang: F = fun(A) -> fun(B) -> A+B end end. The real problem is the heavyweight nature of the anonymous function syntax. Also the compilers might not be optimal for this mode of operation which is not normal erlang style. If we're going to fix syntax then having a nice way of handling hashes/dictionaries/namespaces is more important. Bob From bob@REDACTED Wed Sep 6 03:53:27 2006 From: bob@REDACTED (Bob Ippolito) Date: Tue, 5 Sep 2006 18:53:27 -0700 Subject: [erlang-questions] will Erlang ever have currying? In-Reply-To: <17244f480609051553i1ba9c08ck3ab38cce1f969802@mail.gmail.com> References: <17244f480609051553i1ba9c08ck3ab38cce1f969802@mail.gmail.com> Message-ID: <6a36e7290609051853l43955c96h95f145544bd1e09f@mail.gmail.com> On 9/5/06, Yariv Sadan wrote: > > I couple of my functional programmer friends have complained about > Erlang's lack of currying. (One of them has even described currying as > "more addictive than heroin without the nasty effects" :) ). I didn't > get a "final" answer last time I asked this question, so I'd like to > ask it again (at least so I have an intelligent answer to give to > others): will Erlang ever have currying? > > This is the kind of currying I mean, in pseudo code: > > F = fun(A,B) -> A+B end. > F1 = F(2). > true = F1(3) == 5. What do they actually use currying for? Do you have any examples of code that's better expressed via currying rather than just making a fun? Implicit currying in Erlang seems like a Really Bad Idea to me... It'd certainly be possible to implement explicit currying like this: curry(Fun, Arity) -> curry(Fun, Arity, []). curry(Fun, 0, Args) -> apply(Fun, lists:reverse(Args)); curry(Fun, Arity, Args) -> fun (Arg) -> curry(Fun, Arity - 1, [Arg | Args]) end. test() -> F0 = curry(fun (A, B, C, D) -> {A, B, C, D} end, 4), F1 = F0(1), F2 = F1(2), F3 = F2(3), {1, 2, 3, 4} = F3(4). I haven't been using Erlang all that long, but this isn't something I miss... -bob From jay@REDACTED Wed Sep 6 04:32:28 2006 From: jay@REDACTED (Jay Nelson) Date: Tue, 05 Sep 2006 19:32:28 -0700 Subject: [erlang-questions] Code generation (was NOOB) In-Reply-To: <44FDECDA.4040905@telia.com> References: <44F8C7C8.6050409@nelson.name> <44FDECDA.4040905@telia.com> Message-ID: <44FE333C.1080708@duomark.com> Robert Virding wrote: > Jay Nelson wrote: >>> foo(X) -> >>> A = [do_something(E) || E <- X], % <1> >>> [do_other(E) || E <- X], % <2> >>> ok. > > You must clarify what you mean is the exact difference between <1> and > <2>? Is it the explicit assignment to A? Or that the return value is > never used? I incorrectly used the example for two cases: asking Bjorn about compiler optimizations and demonstrating use cases for list comprehensions. Ideally the compiler should not generate a list in either case, since it knows in both cases the result is never used. The case of <1> is possibly a programmer error, so I would expect a warning of an unused variable (sorry, let's not open that discussion again) since the code indicates to a human reader to expect A to be used later. In the case of <2> the intent is clear mainly to the human, but incidentally to the compiler, that the result is not intended to be used and cannot be used. The statement clearly exists only for side effects. > Actually, the only difference between <1> and <2> is that <1> calls > do_something on each element of X, while <2> calls do_other. When I was talking about the difference between the two, I should have used a different example wherein A was actually referenced later. Change the above return value to {ok, A} for the sake of this discussion. > > P.S. I think you should use code which builds a list when you want to > build a list, not for side-effects! But then again I am a purist. I agree and am fairly pedantic about such things, but I find the foreach statement verbose and hard to read. I am proposing that the clarity and succinctness of list comprehensions wins out. I would throw out the foreach statement from the lists module and always use list comprehensions. Simplicitly and brevity of a single statement with two clear uses, versus two separate statements. The fact that list comprehensions always construct a list is an artifact of their genesis. I agree their syntax intentionally suggests you are creating a list, but I still prefer the readability even only for side effects. Using them and reading them clicks my mind into erlang mode. Just my opinion, though. I understand the other side is a reasonable position. jay From tty.erlang@REDACTED Wed Sep 6 04:37:48 2006 From: tty.erlang@REDACTED (t ty) Date: Tue, 5 Sep 2006 22:37:48 -0400 Subject: [erlang-questions] will Erlang ever have currying? In-Reply-To: <6a36e7290609051853l43955c96h95f145544bd1e09f@mail.gmail.com> References: <17244f480609051553i1ba9c08ck3ab38cce1f969802@mail.gmail.com> <6a36e7290609051853l43955c96h95f145544bd1e09f@mail.gmail.com> Message-ID: <290b3ba10609051937h24acb109n1366fb9f50576b7a@mail.gmail.com> I usually use currying for a cheap form of partial evaluation. One simple operation I have is to test that two list matches. One list is actually fix for a particular run, while I may have several hundred thousands of the second parameter in the run. Also my list matching is rather complicated, first element match, two consecutive elements matches, first and last element matches etc. With currying I personally find it easier to read/reason. I might also have a slight speed increase but haven't really tested for this scenerio. Yes, I am a funs fan. t > What do they actually use currying for? Do you have any examples of > code that's better expressed via currying rather than just making a > fun? Implicit currying in Erlang seems like a Really Bad Idea to me... > > It'd certainly be possible to implement explicit currying like this: > > curry(Fun, Arity) -> > curry(Fun, Arity, []). > > curry(Fun, 0, Args) -> > apply(Fun, lists:reverse(Args)); > curry(Fun, Arity, Args) -> > fun (Arg) -> curry(Fun, Arity - 1, [Arg | Args]) end. > > test() -> > F0 = curry(fun (A, B, C, D) -> {A, B, C, D} end, 4), > F1 = F0(1), > F2 = F1(2), > F3 = F2(3), > {1, 2, 3, 4} = F3(4). > > I haven't been using Erlang all that long, but this isn't something I miss... > > -bob > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From ke.han@REDACTED Wed Sep 6 05:09:34 2006 From: ke.han@REDACTED (ke han) Date: Wed, 6 Sep 2006 11:09:34 +0800 Subject: [erlang-questions] Shared memory and message passing In-Reply-To: References: Message-ID: <0F3D36BF-978D-4CFB-AC40-CB8C3118E4A9@redstarling.com> I think everyone can easily agree that Joe's position is correct...Smalltalk VMs have kept the "everything is an object" at the language level and optimized things at compile/runtime. The big difference between using erlang and Smalltalk, for me, is that in Smalltalk I knew what these under-the-hood optimizations were...I knew how characters, integers, symbols, etc... were represented internally and this knowledge allowed me to write more efficient/scalable code. I only know bits and pieces about how erlang does its "share nothing" but optimize internally magic... This sort of info would make a great chapter in an upcoming book or series of online posts. lists, tuples, large binaries, dictionaries, ets/dets...how do these things make efficient use of the underlying VM or how does the underlying VM/compiler optimize these structures and operations. ke han On Sep 5, 2006, at 5:06 PM, Joe Armstrong ((TN/EAB)) wrote: > > This kind of usage is, I guess OK, if it's hidden from the > user as part of an language implementation, but it should > definitely not be exposed to the application programmer. > > It's rather like garbage collection - or page table manipulation > ok for a very small number of system programmers to use, but > forbidden in regular applications > > /Joe > >> -----Original Message----- >> From: Joel Reymont [mailto:joelr1@REDACTED] >> Sent: den 5 september 2006 11:02 >> To: Joe Armstrong (TN/EAB) >> Cc: erlang-questions@REDACTED >> Subject: Shared memory and message passing >> >> Joe, >> >> What about using shared memory to optimize message passing >> and avoid copying memory? >> >> This does not involve locks or critical sections, right? >> >> Thanks, Joel >> >> -- >> http://wagerlabs.com/ >> >> >> >> >> >> > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From fritchie@REDACTED Wed Sep 6 05:17:41 2006 From: fritchie@REDACTED (Scott Lystig Fritchie) Date: Tue, 05 Sep 2006 22:17:41 -0500 Subject: [erlang-questions] HiPE/+native builds of OTP stuff? Message-ID: <200609060317.k863Hf2q048231@snookles.snookles.com> Howdy. I've asked this question before, but it was buried in the middle of another message. Has anyone done testing with HiPE/+native compilation of OTP libraries such as stdlib or Mnesia or fill-in-the-blank (heh, like 'cprof')? Are there any reasons why someone should/should not do such a thing? ... {evil grin} After all, the out-of-the-box OTP builds don't do it, nor is there a "--hipe-compile-everything" option for the "configure" script.... -Scott From ok@REDACTED Wed Sep 6 05:29:25 2006 From: ok@REDACTED (Richard A. O'Keefe) Date: Wed, 6 Sep 2006 15:29:25 +1200 (NZST) Subject: [erlang-questions] Code generation (was NOOB) Message-ID: <200609060329.k863TP2s353122@atlas.otago.ac.nz> Jay Nelson wrote: The fact that list comprehensions always construct a list is an artifact of their genesis. I agree their syntax intentionally suggests you are creating a list, but I still prefer the readability even only for side effects. Using them and reading them clicks my mind into erlang mode. I once experimented with a Haskell-like syntax for Erlang. To my pleased surprise "Herlang" code was usefully shorter than Erlang. One of the things I did was to generalise list comprehension syntax: [e1, e2, ... for p1 in l1 | g1 ... for pk in lk | gk] -- list comprehension {e1, e2, ... for p1 in l1 | g1 ... -- tuple comprehension (&& e1 for p1 in l1 | g1 ...) -- bounded universal quantification (|| e1 for p1 in l1 | g1 ...) -- bounded existential quantification (,, e1, e2, ... for p1 in l1 | g1 ...) -- "for loop" done for side effects I would have added syntax for max, min, and sum, but they weren't common enough in the Erlang code I was rewriting to bother. Note that Haskell doesn't need special syntax for 'any' (||...) and 'all' (&&...) because it is lazy; a strict language does need special syntax for these rather useful cases. I am *not* recommending this particular syntax, just noting that "generators with guards" CAN be liberated from "constructing a list" and that doing so would be even clearer than constructing a list which is "obviously" thrown away. I also note that precisely this liberation is part of the (let p1 = i1 then s1, .... [More Erlangish: let p1 = i1 then s1, ... for for in in ) end] syntax that I *have* proposed in this mailing list. As that was invented as a generalisation of folding, it doesn't handle 'foreach' particularly well. The point is that we *could* have generators in syntax other than list comprehension syntax, and it may be worth exploring _which_ other syntax would be useful. From jay@REDACTED Wed Sep 6 05:46:33 2006 From: jay@REDACTED (Jay Nelson) Date: Tue, 05 Sep 2006 20:46:33 -0700 Subject: [erlang-questions] Theoretically Stuck Message-ID: <44FE4499.1060102@duomark.com> Rudolph van Graan had questions about modeling data and erlang... I was a bit confused when I read your post because you have mixed several concepts together. The post title indicated to me you were interested in expressing a problem most closely to its description, while the body of the message indicated your were concerned with performance. > Restatement of some of the original message: The original problem posed involved database records which evolved over time. -record(person, {name, surname}). What happens when new fields are added to some records? > End restatement I would pose a few questions for you to consider so that you can decide what is your primary goal: 1) Suppose you had no programming language, just an SQL database. a) How would you model the original person table? b) What would you do when a new column is needed? c) Would you really create a separate table every time you added fields? 2) If you have three people who all have name, surname, but they each have different other attributes, will you use them interchangeably in some method invocations if you were using an OO language? 3) If you had 1M people, each of which had different attributes, would you expect to be able to use them interchangeably? 4) Would you expect performance to be the same in all three cases? There are several concepts intertwined: 1) How do I store data in a database that I know will migrate to a new schema? 2) What do I do when the schema changes? 3) How do I deal with statically typed languages when my data is dynamic? 4) Inheritance seems like an efficient way to avoid repeating code (DRY principle). How can I use it in erlang? 5) What whizzy language feature of erlang makes these problems go away? What are you more worried about? A) The problem is accurately modeled. B) Code clarity, lack of repetition and ease of modification. C) Performance and size of application. D) Ability to morph the data structures on a per instance basis. E) Migration of the architecture over the course of years. F) Database management and performance. G) Language specific constructs that make the code minimal and beautiful. Not all of these are orthogonal, but you need to constrain the problem. Designing and coding consists of a series of tradeoffs. You can't get all of A-E with a single best design or coding style. Your post title said to me, "Forget performance, what is the _correct_ way philosophically to overcome my problem" (read A is most important, although B could apply just as well). If the main problem is that the data model changes regularly and the instances can all be differently shaped (as in D), then: - Use proplists or dictionaries. You may want to store your objects in erlang terms file using dets or consult. Avoid using a structured database like SQL. If the data changes less frequently, but the attribute set changes when they do and you want efficient database management (as in F): - Use an OO database with schema and object versions. I know of no erlang adaptors, so pick a different language. If your case is E, don't worry so much about rigid data structures: - Use records "properly" (i.e., normalize the SQL tables and have corresponding records for each table), migrate all data in your schema. You could do this online or offline depending on your requirments (or node by node even). Just write the extra code every time it changes, code is less important than a clean database structure. For option C, speed of access, and reusable functions are more important. Code using separate modules for the additional features. Create your original records using a grouping record: -record(person, {std_attrs, moda_attrs, modb_attrs}). Then in each of std, module a and module b you can define a record that is consistent for the functions coded in the module. To extend, add a new module and a new field on the person record. -module(std). -record(std_attrs, {name, surname}). -record(moda_attrs, {type}). -record(modb_attrs, {stuff}). This can be mapped to an SQL database structure that changes periodically as in case E. Case F is probably best covered in this way if you don't want to use records/SQL "properly". Here you aren't stuck using slow proplists or hashtables, but can tune and structure the data for efficient functional access inside each module. ROK's dictionaries cover G. Right now they are not available. If you try one of the above techniques, maybe you will learn enough about the problem to be able to contribute to the effort to implement them, or at least will have specific examples of code savings and clarity that might help convince the OTP team to implement them. There are probably lots of other options available (e.g., implement ROK's dictionaries using the equivalent existing functions he describes). The limiting factor for implementation will always be the choice of data structure. I don't think your example of using OO inheritance is a good approach. You will eventually have a mess of the type system and will have to restructure everything once it is already spaghetti. If objects can be used interchangeably, they can be subclasses, but if you add or subtract methods you will have a heck of a time dealing with a collection of randomly related person objects, some of which have dispatch methods and some of which don't. (The approach you describe is what I would call implementing dynamic data by hacking a static typing system. A more philosophically correct way would be to implement schema versioning and a declarative attribute set using a hash and then encapsulate the version and the instance in a single object -- which could be done in erlang with ets or proplist and a record defining the version and the instance attributes at the expense of pattern matching on fields and values.) I would take these steps in architecting a new system: 1) Identify the key characteristics ranked in importance (as in a subset of A-G above) 2) Determine what features you really need from a database (can you use flat files, dets, or consult type term files?). 3) Don't worry about performance or efficiency until you have the code working. 4) Ok, if you know you need 1M objects in memory at once, you can think about performance, but really don't sweat it yet. 5) Measure and tweak performance Generally you want to start with goals of Clarity, Succinctness and then Performance. Maintainability will come along if you can achieve those. jay From ok@REDACTED Wed Sep 6 07:04:03 2006 From: ok@REDACTED (Richard A. O'Keefe) Date: Wed, 6 Sep 2006 17:04:03 +1200 (NZST) Subject: [erlang-questions] Theoretically Stuck Message-ID: <200609060504.k86543OZ355905@atlas.otago.ac.nz> Jay Nelson wrote: a LOVELY analysis of the problem. I'd just like to add one more empirical observation. The Smalltalk system I know best is Squeak. The Squeak GUI system (more precisely, one of the Squeak GUI systems, it still supports the old MVC system from Smalltalk-80) is called Morphic, and is modelled on the Morphic system in Self. Now in Self there are no such things as classes, objects inheriting "slots" from other objects, so there is no particular reason why each object couldn't have a _different_ collection of slots. And in Self an object may acquire new slots at any time without changing its identity. That resulted in a design where there were quite a few slots that most GUI objects had, but there were even more slots that *many* GUI objects had some subset of, and some objects might have completely unique slots. This isn't schema evolution, more like schema chaos, but in Morphic it all seems to work out. While Self is objects-and-inheritance-without-classes, Squeak is your classic single-inheritance class-based Smalltalk. So how can this kind of variability be modelled in such a system? Answer: the slots which every GUI object needs, are modelled as conventional instance variables, plus there is another instance variable holding a hash table. Whenever a Morph is given a non-default value for one of those slots, the hash table is created if necessary and the value put there. The occasional object-specific slot can go there too. My point? The dictionary-based approach that Jay Nelson described is not just something one would invent for Erlang, it's _used_ in more conventional OO languages. (The papers I read years ago about the DIANA notation for modelling Ada programs used an inside-out version of this which works better in strictly typed languages: instead of each object having its own hash table for non-default but rare slots, there was one hash table for each such slot going from objects to values. In a garbage collected language, which Ada needn't be, you need weak hash tables for that. The per-object hash table approach doesn't need weak tables.) From jay@REDACTED Wed Sep 6 08:46:34 2006 From: jay@REDACTED (Jay Nelson) Date: Tue, 05 Sep 2006 23:46:34 -0700 Subject: [erlang-questions] Theoretically Stuck Message-ID: <44FE6ECA.7040104@duomark.com> Richard O'Keefe wrote: > And in Self an object may acquire new slots at any time without changing its identity. Coming from Lisp, I always wondered why C and C++ required a storage location (variable) to have a type but the data or object had no sense of self. The old joke was "Why, if I take my laptop to the library, does it become a book?" It seemed natural to me that data have immutable identity and storage locations be just that: empty addresses that are references to where something (anything) is stored. Why is it hard to ask an object what type it is, and why should its type identity change just because someone moves it to a different location? I used to want to create an object system where objects are as Richard describes in self. They would have identity and that's it. There would be "bundles" of related functionality that could be added or removed from individual objects at any point of the execution or depending on who was accessing the object, so that things like security or concurrency would be trivial -- just take away all the write access bundles. I even toyed with creating Aspect-Oriented Erlang which was process per object with meta-messages to add and remove bundles (aspects). Bundles implemented methods as message handlers. (The biggest trick to a new OO paradigm is to avoid the existing terminology so that people don't get confused with the new twist on a term that they already have ingrained as a particular implementation and meaning.) Fortunately, I came to my senses and started thinking in the erlang way again. I have already done my stint in the OO world and solved the problems there, but found the code tedious and verbose. I am now back to functional (which I like more than any other type of code for most problems) and am trying to come up with succinct solutions to problems that previously seemed to be too complicated to solve clearly. I do believe that erlang would make a good platform for experimenting with implementations of other languages and for doing simulations, but I haven't ventured into any problems in those spaces. jay From jay@REDACTED Wed Sep 6 09:04:40 2006 From: jay@REDACTED (Jay Nelson) Date: Wed, 06 Sep 2006 00:04:40 -0700 Subject: [erlang-questions] Mock Functions Message-ID: <44FE7308.3080108@duomark.com> Arnaud Bailly wrote: > I am implementing a small web application to handle billing of customers account. See my paper from ICFP 2004 at http://www.duomark.com/erlang/ entitled "Structured Programming Using Processes ". I describe implementing a Quicken-like application. Processes are used in ways that make the code more structured and easier to do things like swap out the backend storage or frontend presentations. The use of processes is counter to the typical advice of "one process per real world activity", but I give historical background on how one decides to subdivide a system and then argue why processes afford a new approach to architecting systems. For the past couple years I've been pondering the currently accepted state-of-the-art in data structures and code organization. The premise is, "Given processes are as cheap as structures or objects, would you design things differently?". This year I will present an alternative approach for implementing traditional data caches. It seems that a lot of CS decisions were made in the 60s, like databases, structured programming, code sharing, concurrency, etc. The world has changed to where memory is cheap and storage is very fast and potentially endless for most problems. I believe alternate approaches are effective now to fundamental tradeoffs made when the costs were very different. The 2004 paper was my first attempt at articulating that message. I am working on a library that would clean up parts of the code from the 2004 paper dramatically. With luck it will be available in a couple months. > How do I mock out something? It is not even necessary for you to use processes. Put your swappable functions in a module. Write a replacement module with all the same signatures. Pass the module name to an initialization function that launches a process containing the modules you want to assemble for your system test or deployment. Think of mocked API as the "-behaviour" as you would specify in a gen_server implementation module. Mocking is still useful when you want to simulate time delays (e.g., to query a terabyte document index) and other external things that affect the code performance or to model an environment that you cannot reproduce on your test machines. jay From vladdu55@REDACTED Wed Sep 6 09:34:24 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Wed, 6 Sep 2006 09:34:24 +0200 Subject: [erlang-questions] will Erlang ever have currying? In-Reply-To: <290b3ba10609051937h24acb109n1366fb9f50576b7a@mail.gmail.com> References: <17244f480609051553i1ba9c08ck3ab38cce1f969802@mail.gmail.com> <6a36e7290609051853l43955c96h95f145544bd1e09f@mail.gmail.com> <290b3ba10609051937h24acb109n1366fb9f50576b7a@mail.gmail.com> Message-ID: <95be1d3b0609060034q533c043dk26f1dbb8623b72b@mail.gmail.com> Hi, On 9/6/06, t ty wrote: > I usually use currying for a cheap form of partial evaluation. One > simple operation I have is to test that two list matches. One list is > actually fix for a particular run, while I may have several hundred > thousands of the second parameter in the run. I would venture to guess that in this case simple currying won't help you very much. Taking as example a vector dot-product, where one of the vectors is static and sparse (many zeroes), simple currying will still let the code do many unnecessary multiplications by zero and additions of zero. What you really want is to be able to completely remove the code for that, and generate a fun that just multiplies and add the relevant values. best regards, Vlad From richardc@REDACTED Wed Sep 6 10:11:48 2006 From: richardc@REDACTED (Richard Carlsson) Date: Wed, 06 Sep 2006 10:11:48 +0200 Subject: [erlang-questions] Shared memory and message passing In-Reply-To: <5DD95444-85E2-4623-9FF9-B53C57C01E54@gmail.com> References: <44FDEDF9.700@telia.com> <5DD95444-85E2-4623-9FF9-B53C57C01E54@gmail.com> Message-ID: <44FE82C4.1080400@it.uu.se> Joel Reymont wrote: > I thought Erlang as it is right now _does_ copy data. Am I mistaken? > > Why the talk about about copying binaries, etc. otherwise? The _behaviour_ (the semantics) of message passing must always be as if each process has a separate copy (so that there is no observable difference in behaviour if the communicating processes are on the same node or on separate nodes). But if they _are_ on the same node, the message passing can be optimized by letting the processes share the data "under the hood", and just send a pointer instead of making a complete copy. As long as there are no destructive writes to data (and there aren't any in Erlang), it does not matter, because the difference cannot be observed (except in the amount of time it takes to send large messages). The default Erlang/OTP runtime system does _not_ currently do this sort of optimization, however. (It can be turned on by using an alternative build of the runtime system.) In the default system, each process has a separate memory area, and message passing will copy data from the area of the sender to that of the receiver. (The exception is large binary objects, which are handled specially by placing them outside the normal data areas and using reference counting to keep track of them. They are not copied when sent as messages between processes on the same node.) However, there has been an experimental version where all processes shared a single area (giving fast message passing, but causing problems with long garbage collection times). This "shared" runtime system is now discontinued, in favour of a "hybrid" version which tries to keep messages in a shared area and keep process-local data in per-process areas. It is still not the default, though: the old tried and true version with separate areas only is what you get out of the box, since it has very well known time/space properties. We'll see if the hybrid system will replace it in some possible future. /Richard PS. Shameless plug: see the July issue of TOPLAS (vol 28, issue 4) for all the gruelling details on the hybrid architecture. From joelr1@REDACTED Wed Sep 6 10:34:26 2006 From: joelr1@REDACTED (Joel Reymont) Date: Wed, 6 Sep 2006 09:34:26 +0100 Subject: [erlang-questions] Shared memory and message passing In-Reply-To: <44FE82C4.1080400@it.uu.se> References: <44FDEDF9.700@telia.com> <5DD95444-85E2-4623-9FF9-B53C57C01E54@gmail.com> <44FE82C4.1080400@it.uu.se> Message-ID: On Sep 6, 2006, at 9:11 AM, Richard Carlsson wrote: > We'll see if the > hybrid system will replace it in some possible future. Is anyone using the hybrid system in production? Actively using it? > PS. Shameless plug: see the July issue of TOPLAS (vol 28, issue 4) > for all the gruelling details on the hybrid architecture. Is this on the internet? Is there a PDF? Thanks, Joel -- http://wagerlabs.com/ From bmk@REDACTED Wed Sep 6 11:31:03 2006 From: bmk@REDACTED (Micael Karlberg) Date: Wed, 06 Sep 2006 11:31:03 +0200 Subject: [erlang-questions] Questhion about Megaco stack In-Reply-To: References: Message-ID: <44FE9557.4060400@erix.ericsson.se> Hi, _megaco_session_ was a tool to be used when you wanted to write your application in C rather then Erlang (I have *no* id? why anybody would *want* to do that :). It was basically a way to wrap the megaco application. megaco_session has not been updated for a long time... The _simple_ examples included in the megaco application is just to show the _very_ basic usage of the megaco application! Personally, I think that the simple examples are to basic to be used for anything as heavy duty as a to drive a test suite. Write your own! Included in the application is the test directory (see the open source release tarball). This includes the test suites for the megaco application. This stuff is not documented, and I am not going to explain how it works, but you may find something to help you here (e.g. megaco_test_mg and megaco_test_mgc) Regards, /BMK sharevon wrote: > I have posted this email, but no one answered. :-( > So I post it again. > > I have some trouble in differing megaco_session_0.5 and Megaco 3.2.3 > as part of Erlang/OTP R10B-9 from each other. Are they different? Or > ,megaco_session_0.5 is just a previous version of Megaco 3.2.3. > > Another question is about examples in megaco 3.2.3. Can Simple MGC and > Simple MG do other things ,besides Simple MG send ServiceChange > command to 4 interfaces, as TCP/UDP 2944 and 2945, of Simple MGC? If > not, how could I control the Simple MGC and MG to construct a test > enviorment of one MGC and two MG, and make them to do some real works > like adding, modifying, substracting some terminations to some context > or making MG to observe some events? > > Thanks. > Sharevon > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > From csanto@REDACTED Wed Sep 6 11:08:29 2006 From: csanto@REDACTED (Corrado Santoro) Date: Wed, 06 Sep 2006 11:08:29 +0200 Subject: [erlang-questions] Shared memory and message passing In-Reply-To: References: Message-ID: <44FE900D.6050003@diit.unict.it> Joe Armstrong (TN/EAB) wrote: > This kind of usage is, I guess OK, if it's hidden from the > user as part of an language implementation, but it should > definitely not be exposed to the application programmer. I agree! Think, for example, to two BIFs like: put_data (Key, Value) get_data (Key) --> Value that can be used to perform a *safe* access to a "shared location" named "Key". If these functions were BIFs, they could be fast and effective. I thought to the necessity of such a solution during the implementation of our Erlang-enabled robot: the issue was to obtain fresh data from sensors and positioning system; using message passing/rpc (together with some parts written in C + threads) I experienced some undesiderable delays. For this reason, instead of using rpc (or ets tables to hold shared data), I thought to the functions above. However, after a discussion at Erlang Training&Consulting, some people discouraged me strongy :-)) So I've rewritten the software for the robot, removing many parts in C and, above all, the C threads: now the latencies are quasi-acceptable, and the robot works well, but I'm sure that using shared-data-access BIFs could improve a lot my system. --Corrado -- ====================================================== Eng. Corrado Santoro, Ph.D. University of Catania - Engineering Faculty Department of Computer Science and Telecommunications Engineering Viale A. Doria, 6 - 95125 CATANIA (ITALY) Tel: +39 095 7382380 +39 095 7387035 +39 095 7382365 +39 095 7382364 VoIP: sip:7035@REDACTED Fax: +39 095 7382397 EMail: csanto@REDACTED Personal Home Page: http://www.diit.unict.it/users/csanto NUXI Home Page: http://nuxi.diit.unict.it ====================================================== From abailly@REDACTED Wed Sep 6 12:15:04 2006 From: abailly@REDACTED (Arnaud Bailly) Date: Wed, 06 Sep 2006 12:15:04 +0200 Subject: [erlang-questions] Mock Functions In-Reply-To: <44FE7308.3080108@duomark.com> (Jay Nelson's message of "Wed, 06 Sep 2006 00:04:40 -0700") References: <44FE7308.3080108@duomark.com> Message-ID: <877j0hl2s7.fsf@oqube.com> Thank you very much for your detailed answer. I have downloaded the paper and will read it as thoroughly as possible ! As I have already said, my recent interest in Erlang grew out of frustration dealing with such verbose and clumsy languages as Java. I am very interested by studying the potential of applying FP (and Concurrent FP) to mainstream business applications development, especially in the way those different paradigms can hepl us design and implement cleaner software. I was very impressed by Simon Peyton-Jones paper on "Experiments in financial engineering" which study how the combinator approach and haskell's laziness feature allows one to build a very elegant and flexible solution to financial derivatives evaluation problem. I also came to the conclusion that processes may be the right way to structure program in erlang, much likie what is done in architectural models and component engineering. Regards, -- OQube < software engineering \ g?nie logiciel > Arnaud Bailly, Dr. \web> http://www.oqube.com From cyberdanx@REDACTED Wed Sep 6 12:26:43 2006 From: cyberdanx@REDACTED (Chris Campbell) Date: Wed, 6 Sep 2006 11:26:43 +0100 Subject: [erlang-questions] will Erlang ever have currying? In-Reply-To: <6a36e7290609051853l43955c96h95f145544bd1e09f@mail.gmail.com> References: <17244f480609051553i1ba9c08ck3ab38cce1f969802@mail.gmail.com> <6a36e7290609051853l43955c96h95f145544bd1e09f@mail.gmail.com> Message-ID: On 06/09/06, Bob Ippolito wrote: > What do they actually use currying for? Do you have any examples of > code that's better expressed via currying rather than just making a > fun? Implicit currying in Erlang seems like a Really Bad Idea to me... It's useful for combinators (not implementing them, using them) but for Erlang you might do it with processes or fun wrappers explicitly; there's probably no major benefit from syntactic sugar. I tend to use partial application in OCaml to pass stuff that doesn't change around implicitly, but if you use it too much it tends to compromise readability of code. Like everything else it's a tradeoff. From jean.verger@REDACTED Wed Sep 6 14:12:18 2006 From: jean.verger@REDACTED (Jean Verger) Date: Wed, 6 Sep 2006 20:12:18 +0800 Subject: [erlang-questions] UI Debugger Message-ID: <856070080609060512q3f53dba8wc30645bb40a97cf0@mail.gmail.com> Hi all, I'm trying to debug an application that is running in our production and development servers. I would like to debug it remotely, from my own machine. I'm looking for a debugger, if possible with GUI ... if not, pure text, pure console :))))) I have tried debugger (debugger:start().) but it looks that it cann't debug remetely. I don't get to make TDB to work, I bet there are some usefull debuggers for remote servers. Any sugestions? Thanks, Jean From taavi@REDACTED Wed Sep 6 14:27:39 2006 From: taavi@REDACTED (Taavi Talvik) Date: Wed, 6 Sep 2006 15:27:39 +0300 Subject: [erlang-questions] UI Debugger In-Reply-To: <856070080609060512q3f53dba8wc30645bb40a97cf0@mail.gmail.com> References: <856070080609060512q3f53dba8wc30645bb40a97cf0@mail.gmail.com> Message-ID: <18e9d60a6b5ac0fa29cffd020895045a@uninet.ee> > Hi all, > I'm trying to debug an application that is running in our production > and development servers. I would like to debug it remotely, from my > own machine. I'm looking for a debugger, if possible with GUI ... if > not, pure text, pure console :))))) > > I have tried debugger (debugger:start().) but it looks that it cann't > debug remetely. > I don't get to make TDB to work, > > I bet there are some usefull debuggers for remote servers. Any > sugestions? Pure console: erl -name myworkstation@REDACTED -setcookie secret_cookie -remsh my_production_node@REDACTED Remember to use ^G and the q for exiting. Otherwize using halt() or q() stops production node. best regards, taavi From jean.verger@REDACTED Wed Sep 6 14:40:24 2006 From: jean.verger@REDACTED (Jean Verger) Date: Wed, 6 Sep 2006 20:40:24 +0800 Subject: [erlang-questions] UI Debugger In-Reply-To: <18e9d60a6b5ac0fa29cffd020895045a@uninet.ee> References: <856070080609060512q3f53dba8wc30645bb40a97cf0@mail.gmail.com> <18e9d60a6b5ac0fa29cffd020895045a@uninet.ee> Message-ID: <856070080609060540x10406426pc17e8eb72ff6374b@mail.gmail.com> Hi, thanks for your reply. I have already tried that. Following that approach, I can login remotely (similar as ssh I believe) ...After that .. what debugger can I run? debugger:start(). doesn't work since is remote ... :( I don't know how to make the X11 work remotely. Ah, thanks for your comment on q(). , ^G and halt, something new I learn today :) regards, jean On 9/6/06, Taavi Talvik wrote: > > > Hi all, > > I'm trying to debug an application that is running in our production > > and development servers. I would like to debug it remotely, from my > > own machine. I'm looking for a debugger, if possible with GUI ... if > > not, pure text, pure console :))))) > > > > I have tried debugger (debugger:start().) but it looks that it cann't > > debug remetely. > > I don't get to make TDB to work, > > > > I bet there are some usefull debuggers for remote servers. Any > > sugestions? > > Pure console: > > erl -name myworkstation@REDACTED -setcookie secret_cookie -remsh > my_production_node@REDACTED > > Remember to use ^G and the q for exiting. Otherwize using halt() or q() > stops production > node. > > best regards, > taavi > > From mats.cronqvist@REDACTED Wed Sep 6 14:48:48 2006 From: mats.cronqvist@REDACTED (Mats Cronqvist) Date: Wed, 06 Sep 2006 14:48:48 +0200 Subject: [erlang-questions] UI Debugger In-Reply-To: <856070080609060512q3f53dba8wc30645bb40a97cf0@mail.gmail.com> References: <856070080609060512q3f53dba8wc30645bb40a97cf0@mail.gmail.com> Message-ID: <44FEC3B0.8020805@ericsson.com> Jean Verger wrote: > I bet there are some usefull debuggers for remote servers. Any sugestions? distel (jungerl.sourceforge.net) can connect to a remote machine. allows you to use emacs as debugger GUI. not recommended for vi-users.... mats From vladdu55@REDACTED Wed Sep 6 14:51:15 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Wed, 6 Sep 2006 14:51:15 +0200 Subject: [erlang-questions] UI Debugger In-Reply-To: <856070080609060512q3f53dba8wc30645bb40a97cf0@mail.gmail.com> References: <856070080609060512q3f53dba8wc30645bb40a97cf0@mail.gmail.com> Message-ID: <95be1d3b0609060551l2af3b0c7g586088b41e25463d@mail.gmail.com> On 9/6/06, Jean Verger wrote: > I bet there are some usefull debuggers for remote servers. Any sugestions? Hi, >From the debugger's user guide (http://www.erlang.org/doc/doc-5.5.1/lib/debugger-3.1/doc/html/part_frame.html): 1.11 Debugging Remote Nodes By using debugger:start/1, it can be specified if Debugger should be started in local or global mode. debugger:start(local | global) If no argument is provided, Debugger is started in global mode. In local mode, code is interpreted only at the current node. In global mode, code is interpreted at all known nodes. Processes at other nodes executing interpreted code will automatically be shown in the Monitor window and can be attached to like any other debugged process. It is possible, but definitely not recommended to start Debugger in global mode on more than one node in a network, as they will interfer with each other leading to inconsistent behaviour. regards, Vlad From serge@REDACTED Wed Sep 6 15:11:03 2006 From: serge@REDACTED (Serge Aleynikov) Date: Wed, 06 Sep 2006 09:11:03 -0400 Subject: [erlang-questions] UI Debugger In-Reply-To: <856070080609060540x10406426pc17e8eb72ff6374b@mail.gmail.com> References: <856070080609060512q3f53dba8wc30645bb40a97cf0@mail.gmail.com> <18e9d60a6b5ac0fa29cffd020895045a@uninet.ee> <856070080609060540x10406426pc17e8eb72ff6374b@mail.gmail.com> Message-ID: <44FEC8E7.4060000@hq.idt.net> Jean Verger wrote: > Hi, > thanks for your reply. I have already tried that. Following that > approach, I can login remotely (similar as ssh I believe) ...After > that .. what debugger can I run? debugger:start(). doesn't work since > is remote ... :( I don't know how to make the X11 work remotely. > > Ah, thanks for your comment on q(). , ^G and halt, something new I > learn today :) > > regards, > > jean Aside from using the dubbuger interface, another way to debug a program on a production node is to use the dbg's tracing facility. Below you can find a sample user_default.erl file that you can load on a remote system using "~/.erlang" file: $ cat .erlang code:load_abs("/opt/erlang/usr/user_default"). It'll expand the shell with convenient tracing shortcuts. The tracing output will be printed to the screen. Run help() at the shell to ensure that the module is loaded: [serge@REDACTED: ~] $ erl Erlang (BEAM) emulator version 5.5 [source] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.5 (abort with ^G) 1> help(). ... ** user extended commands ** dbgtc(File) -- use dbg:trace_client() to read data from File dbgon(M) -- enable dbg tracer on all funs in module M dbgon(M,Fun) -- enable dbg tracer for module M and function F dbgon(M,File) -- enable dbg tracer for module M and log to File dbgadd(M) -- enable call tracer for module M dbgadd(M,F) -- enable call tracer for function M:F dbgdel(M) -- disable call tracer for module M dbgdel(M,F) -- disable call tracer for function M:F dbgoff() -- disable dbg tracer (calls dbg:stop/0) Note that tracing (as well as debugging) does slow down performance, and may have significant impact on performance of a production node unless you know what you are doing. Regards, Serge -------------------------------------------- -module(user_default). -author('serge@REDACTED'). -export([help/0,dbgtc/1, dbgon/1, dbgon/2, dbgadd/1, dbgadd/2, dbgdel/1, dbgdel/2, dbgoff/0]). -import(io, [format/1]). help() -> shell_default:help(), format("** user extended commands **~n"), format("dbgtc(File) -- use dbg:trace_client() to read data from File\n"), format("dbgon(M) -- enable dbg tracer on all funs in module M\n"), format("dbgon(M,Fun) -- enable dbg tracer for module M and function F\n"), format("dbgon(M,File) -- enable dbg tracer for module M and log to File\n"), format("dbgadd(M) -- enable call tracer for module M\n"), format("dbgadd(M,F) -- enable call tracer for function M:F\n"), format("dbgdel(M) -- disable call tracer for module M\n"), format("dbgdel(M,F) -- disable call tracer for function M:F\n"), format("dbgoff() -- disable dbg tracer (calls dbg:stop/0)\n"), format("l() -- load all changed modules\n"), format("nl() -- load all changed modules on all known nodes\n"), format("mm() -- list modified modules\n"), true. dbgtc(File) -> Fun = fun({trace,_,call,{M,F,A}}, _) -> io:format("call: ~w:~w~w~n", [M,F,A]); ({trace,_,return_from,{M,F,A},R}, _) -> io:format("retn: ~w:~w/~w -> ~w~n", [M,F,A,R]); (A,B) -> io:format("~w: ~w~n", [A,B]) end, dbg:trace_client(file, File, {Fun, []}). dbgon(Module) -> case dbg:tracer() of {ok,_} -> dbg:p(all,call), dbg:tpl(Module, [{'_',[],[{return_trace}]}]), ok; Else -> Else end. dbgon(Module, Fun) when is_atom(Fun) -> {ok,_} = dbg:tracer(), dbg:p(all,call), dbg:tpl(Module, Fun, [{'_',[],[{return_trace}]}]), ok; dbgon(Module, File) when is_list(File) -> {ok,_} = dbg:tracer(file, dbg:trace_port(file, File)), dbg:p(all,call), dbg:tpl(Module, [{'_',[],[{return_trace}]}]), ok. dbgadd(Module) -> dbg:tpl(Module, [{'_',[],[{return_trace}]}]), ok. dbgadd(Module, Fun) -> dbg:tpl(Module, Fun, [{'_',[],[{return_trace}]}]), ok. dbgdel(Module) -> dbg:ctpl(Module), ok. dbgdel(Module, Fun) -> dbg:ctpl(Module, Fun), ok. dbgoff() -> dbg:stop(). From vladdu55@REDACTED Wed Sep 6 15:51:37 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Wed, 6 Sep 2006 15:51:37 +0200 Subject: [erlang-questions] Lego Mindstorms NXT Message-ID: <95be1d3b0609060651r1e042deei5bf38874218c64d9@mail.gmail.com> Hi, There were several discussiona about Erlang and robotics, and in one of them (http://www.erlang.org/ml-archive/erlang-questions/200303/msg00187.html) there was a reference to Lego Mindstorms. Lego has just releaset its new Mindstorms platform, NXT, which runs an ARM7 processor and talks Bluetooth, which means that it is more probable that Erlang might run on it. (but only 64K memory makes it not so probable) I am the owner of a kit since yesterday :-) so I will give it a shot (in due time). Running Erlang on PC and talking via BT seems an easier approach. The main problem for me would be to create a platform-independent BT port program. I couldn't find many free libraries... Any pointers? Even skipping BT and talking via USB, the same problem remains (but there seem to be more libs). Or if i could get my hands on a Blackdog gizmo like the one Mickael Remond showed at EUC last year... hmmm! ;-) Or did anyone manage to run Erlang on Windows Mobile / PocketPC? best regards, Vlad From chandrashekhar.mullaparthi@REDACTED Wed Sep 6 16:05:21 2006 From: chandrashekhar.mullaparthi@REDACTED (Chandru) Date: Wed, 6 Sep 2006 15:05:21 +0100 Subject: [erlang-questions] Test server Message-ID: Hi, I downloaded the test_server from http://www.erlang.org/download/test_server/test_server-3.1.1.tar.gz and ran the emulator tests against R11B-1 and all of the tests either fail or are skipped. Same with the stdlib. Any idea what is going wrong? I've attached the log if it is of any help. cheers Chandru -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: suite.log Type: application/octet-stream Size: 14638 bytes Desc: not available URL: From tobbe@REDACTED Wed Sep 6 16:34:16 2006 From: tobbe@REDACTED (Torbjorn Tornkvist) Date: Wed, 06 Sep 2006 16:34:16 +0200 Subject: [erlang-questions] Test server In-Reply-To: References: Message-ID: JFYI: I've created an alternative to the standard test server: http://code.google.com/p/yatsy It is brand new and under development, but can run (almost) the same SUITE files, locally or remotely, and provides a Yaws interface for browsing the result. Cheers, Tobbe Chandru wrote: > Hi, > > I downloaded the test_server from > http://www.erlang.org/download/test_server/test_server-3.1.1.tar.gz and > ran the emulator tests against R11B-1 and all of the tests either fail > or are skipped. Same with the stdlib. Any idea what is going wrong? > > I've attached the log if it is of any help. > > cheers > Chandru > > > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From david.nospam.hopwood@REDACTED Wed Sep 6 16:41:19 2006 From: david.nospam.hopwood@REDACTED (David Hopwood) Date: Wed, 06 Sep 2006 15:41:19 +0100 Subject: [erlang-questions] Shared memory and message passing In-Reply-To: <44FE82C4.1080400@it.uu.se> References: <44FDEDF9.700@telia.com> <5DD95444-85E2-4623-9FF9-B53C57C01E54@gmail.com> <44FE82C4.1080400@it.uu.se> Message-ID: <44FEDE0F.50206@blueyonder.co.uk> Richard Carlsson wrote: > PS. Shameless plug: see the July issue of TOPLAS (vol 28, issue 4) > for all the gruelling details on the hybrid architecture. On-line at . -- David Hopwood From nm@REDACTED Wed Sep 6 20:29:22 2006 From: nm@REDACTED (Gaspar Chilingarov) Date: Wed, 06 Sep 2006 23:29:22 +0500 Subject: [erlang-questions] race candition in ssl_server leading to DoS? Message-ID: <44FF1382.3040602@web.am> Hello folks! I've started deploying our yaws based web application and faced strange problem in the one installation. Sometimes it completely stops to respond to SSL connections. netstat shows that it even not listening 443 port. In other hand 80 port is answering, all internal processes run smoothly, etc... After some investigation I've found that it fails in esock port program with "esock: Got connect request while PASSIVE" error, which comes from lib/ssl/c_src/esock.c, line 819 (R11B-0). This error does not occur on somehow slow connections (say, DSL), but shows up if people access web application via 100 MBit LAN. Because of nature of the application, after load it issues immediately several AJAX simultaneous connections to server, which start computations/fetching from db. I suspect, that Erlang VM establishes ssl connections a little bit slower, than they arrive. In that case user can try to connect between states when socket is really open and before erlang process tells driver to execute accept on it. What you mind - how this situation may be avoided? -- Gaspar Chilingarov System Administrator, Network security consulting t +37493 419763 (mob) i 63174784 e nm@REDACTED From slavomir.kaslev@REDACTED Thu Sep 7 00:31:17 2006 From: slavomir.kaslev@REDACTED (Slavomir Kaslev) Date: Thu, 7 Sep 2006 01:31:17 +0300 Subject: [erlang-questions] Using COM in Erlang Message-ID: <171dfd0a0609061531r7c2b1642ja1bf4e0782897744@mail.gmail.com> Can you give a clue how can I use COM from Erlang. I searched the web but couldn't find anything on the subject. Is there any library for doing this? Has anyone tried this before? Thank you in advance. -- Slavomir Kaslev From serge@REDACTED Thu Sep 7 00:49:37 2006 From: serge@REDACTED (Serge Aleynikov) Date: Wed, 06 Sep 2006 18:49:37 -0400 Subject: [erlang-questions] A how-to turorial is added Message-ID: <44FF5081.2010801@hq.idt.net> All, I added a new tutorial to the wiki on the subject of "Using ei to encode/decode binary terms in port programs": http://wiki.trapexit.org/index.php/Category:HowToUseEI One question though is that it got listed as a subcategory under the "HowTo" category. I can't seem to figure out how to get rid of the "Category:HowToUseEI" category, so that it would get merged with the rest of the "Category:HowTo" topics. Regards, Serge -- Serge Aleynikov R&D Telecom, MIS, IDT Corp Tel: +1 (973) 438-3436 Fax: +1 (973) 438-1464 From ewan_higgs@REDACTED Thu Sep 7 04:32:12 2006 From: ewan_higgs@REDACTED (Ewan Higgs) Date: Thu, 7 Sep 2006 03:32:12 +0100 (BST) Subject: [erlang-questions] Parsing RSS (quick fix) In-Reply-To: <6a36e7290609041848u24dc9c0dj423c9d6ba543ab1d@mail.gmail.com> Message-ID: <20060907023212.69755.qmail@web27014.mail.ukl.yahoo.com> --- Bob Ippolito wrote: > What it does look like is an incorrectly parsed > HTTP/1.1 chunked > encoding response. This is what's happening. I ran through the example and found the quickest fix was to make the request using HTTP/1.0 instead of HTTP/1.1. Currently, the response parsing in www_tools merely skims for "\r\n\r\n" and tosses that data away and returning the reamining message. HTTP/1.1 can have the chunked encoding response, that Bob mentioned, after the header and before the message. This will be an octal number followed by another "\r\n" and requires the parsing look for the string "Transfer-Encoding: chunked" in the header to determine if the chunk data will be present. Share and enjoy, Ewan ___________________________________________________________ All new Yahoo! Mail "The new Interface is stunning in its simplicity and ease of use." - PC Magazine http://uk.docs.yahoo.com/nowyoucan.html From bernardp@REDACTED Thu Sep 7 04:48:18 2006 From: bernardp@REDACTED (Pierpaolo BERNARDI) Date: Thu, 07 Sep 2006 04:48:18 +0200 Subject: [erlang-questions] Water to Erlang mill Message-ID: http://www.ddj.com/dept/64bit/192501977?cid=RSSfeed_DDJ_All "Tutorial on multi-core threading techniques such as OpenMP, and how to avoid problems like data races and cache conflicts." P. From jean.verger@REDACTED Thu Sep 7 05:30:42 2006 From: jean.verger@REDACTED (Jean Verger) Date: Thu, 7 Sep 2006 11:30:42 +0800 Subject: [erlang-questions] UI Debugger In-Reply-To: <95be1d3b0609060551l2af3b0c7g586088b41e25463d@mail.gmail.com> References: <856070080609060512q3f53dba8wc30645bb40a97cf0@mail.gmail.com> <95be1d3b0609060551l2af3b0c7g586088b41e25463d@mail.gmail.com> Message-ID: <856070080609062030r11e8348aj1ab3999321cb1a5b@mail.gmail.com> Hi all, thanks for your reply, now time to debug ... So far, i've been not able to see other nodes from my local machine, however, when I run the following command, i can connect remotely to others nodes "erl -n theName -rmsh theExistingNode@REDACTED" (I think there are some other parameters) thanks again, Jean On 9/6/06, Vlad Dumitrescu wrote: > On 9/6/06, Jean Verger wrote: > > I bet there are some usefull debuggers for remote servers. Any sugestions? > > Hi, > > From the debugger's user guide > (http://www.erlang.org/doc/doc-5.5.1/lib/debugger-3.1/doc/html/part_frame.html): > > 1.11 Debugging Remote Nodes > By using debugger:start/1, it can be specified if Debugger should be > started in local or global mode. > > debugger:start(local | global) > > If no argument is provided, Debugger is started in global mode. > > In local mode, code is interpreted only at the current node. In global > mode, code is interpreted at all known nodes. Processes at other nodes > executing interpreted code will automatically be shown in the Monitor > window and can be attached to like any other debugged process. > > It is possible, but definitely not recommended to start Debugger in > global mode on more than one node in a network, as they will interfer > with each other leading to inconsistent behaviour. > > regards, > Vlad > From fbg111@REDACTED Thu Sep 7 06:08:35 2006 From: fbg111@REDACTED (fbg111) Date: Wed, 6 Sep 2006 21:08:35 -0700 (PDT) Subject: [erlang-questions] Mod function that returns quotient remainder? Message-ID: <6183915.post@talk.nabble.com> Hello, is there a 'mod' that returns the remainder of a quotient? eg, mod(5/2) = 1? I know you can find out if there is a remainder by if trunc(Y / 2) * 2 == Y but is there a way to return the actual remainder? Thanks, Byron -- View this message in context: http://www.nabble.com/Mod-function-that-returns-quotient-remainder--tf2231023.html#a6183915 Sent from the Erlang Questions forum at Nabble.com. From ml.cyresse@REDACTED Thu Sep 7 06:30:35 2006 From: ml.cyresse@REDACTED (Liam Clarke) Date: Thu, 7 Sep 2006 16:30:35 +1200 Subject: [erlang-questions] Erlang newbie - quick critique? Message-ID: Hi all, Rather new to the FP paradigm (painful learning curve with an attempt at Common Lisp) so I just thought I'd run my first attempts at a recursive Erlang function past you. I'm not near an Erlang interpreter at the moment, unfortunately, so I can't test the code, I'm worried about one bit, which I'll highlight. I'm trying to replicate the string.join() method of Python i.e., ":".join(["a", "b", "c"]) resulting in "a:b:c" This is what I've drawn up on paper - my_join([H|T] Delimiter) -> myjoin(T, Delimiter, [H])). my_join([H|T], Delimiter, Acc) -> myjoin(T, Delimiter, lists:append([Acc, Delimiter, H]) ). my_join([], Delimiter, Acc) -> Acc. Usage: my_join(["a", "b", "c"], ":") What I'm concerned about is the [H] and the lists:append call with the arguments being inserted into two square brackets to make a new list. Would that work? It's a Python thing, or do I need to use a function to make it a list? I've decided to start small for now - I intend to use Erlang to write an MSN client as I think the asynchrous nature of Erlang (and I love the sockets returning messages) suits the problem perfectly. I had started in Python, but have hit a bunch of fiddliness with asynchrous sockets, so thought I'd give Erlang a go. In designing the actual architecture of an Erlang system, can anyone recommend some best practises? I'm working on the message interfaces between the socket handling process and it's controller at the moment. Regards, Liam Clarke From rpettit@REDACTED Thu Sep 7 06:32:37 2006 From: rpettit@REDACTED (Rick Pettit) Date: Wed, 6 Sep 2006 23:32:37 -0500 Subject: [erlang-questions] Mod function that returns quotient remainder? In-Reply-To: <6183915.post@talk.nabble.com> References: <6183915.post@talk.nabble.com> Message-ID: <20060907043237.GA17569@vailsys.com> On Wed, Sep 06, 2006 at 09:08:35PM -0700, fbg111 wrote: > > Hello, is there a 'mod' that returns the remainder of a quotient? eg, > > mod(5/2) = 1? 5 rem 2. > I know you can find out if there is a remainder by > > if trunc(Y / 2) * 2 == Y > > but is there a way to return the actual remainder? Thanks, Out of curiousity, how did you find out about trunc/1? FYI, a 5 minute google search could have gotten you an answer (re: rem) much faster than posting to the list (don't get me wrong, I don't mind helping when I can :-). -Rick From fbg111@REDACTED Thu Sep 7 06:58:33 2006 From: fbg111@REDACTED (fbg111) Date: Wed, 6 Sep 2006 21:58:33 -0700 (PDT) Subject: [erlang-questions] Mod function that returns quotient remainder? In-Reply-To: <20060907043237.GA17569@vailsys.com> References: <6183915.post@talk.nabble.com> <20060907043237.GA17569@vailsys.com> Message-ID: <6184239.post@talk.nabble.com> I came across it in the getting started guide, and saw that trunc was used in a way I've used mod before in other languages, so I wanted to try replacing it with mod. I tried searching the Erlang documentation (I always do b/f posting such questions), but it's not clear what to search for. It's not in the math module, and you have to know the spelling to find it in the glossary and index. But you're right, next time I'll Google it first. Thanks, Byron Rick Pettit wrote: > > On Wed, Sep 06, 2006 at 09:08:35PM -0700, fbg111 wrote: >> >> Hello, is there a 'mod' that returns the remainder of a quotient? eg, >> >> mod(5/2) = 1? > > 5 rem 2. > >> I know you can find out if there is a remainder by >> >> if trunc(Y / 2) * 2 == Y >> >> but is there a way to return the actual remainder? Thanks, > > Out of curiousity, how did you find out about trunc/1? FYI, a 5 minute > google > search could have gotten you an answer (re: rem) much faster than posting > to > the list (don't get me wrong, I don't mind helping when I can :-). > > -Rick > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > -- View this message in context: http://www.nabble.com/Mod-function-that-returns-quotient-remainder--tf2231023.html#a6184239 Sent from the Erlang Questions forum at Nabble.com. From fbg111@REDACTED Thu Sep 7 07:27:55 2006 From: fbg111@REDACTED (fbg111) Date: Wed, 6 Sep 2006 22:27:55 -0700 (PDT) Subject: [erlang-questions] Erlang Book - again In-Reply-To: <8ed733900608291148l4af1c01ete5799681aa213f4c@mail.gmail.com> References: <19037072-DD48-415D-A282-A51F91D780C6@citeulike.org> <8ed733900608291148l4af1c01ete5799681aa213f4c@mail.gmail.com> Message-ID: <6184444.post@talk.nabble.com> Agreed, it seems O'reilly drank a little too much http://gregluck.com/blog/archives/2006/07/report_from_osc.html Ruby Koolaid , though no harm in submitting the Erlang book for his consideration, while perhaps suggesting he check out programming.reddit.com for evidence of strong interest in concurrent programming. And I second both Apress and Pragmatic Programmers, both would be great possibilities for publishing an Erlang book. Simon Chappell wrote: > > Actually, I had gotten the impression that Apress was the forward > looking publisher these days. I'm not always as impressed with > O'Reilly as I used to be. > > Simon > > -- > www.simonpeter.org > -- View this message in context: http://www.nabble.com/Erlang-Book---again-tf2184476.html#a6184444 Sent from the Erlang Questions forum at Nabble.com. From ok@REDACTED Thu Sep 7 07:40:18 2006 From: ok@REDACTED (Richard A. O'Keefe) Date: Thu, 7 Sep 2006 17:40:18 +1200 (NZST) Subject: [erlang-questions] Erlang newbie - quick critique? Message-ID: <200609070540.k875eIj3367613@atlas.otago.ac.nz> This is what I've drawn up on paper - my_join([H|T] Delimiter) -> myjoin(T, Delimiter, [H])). Why "my_"? You have a missing comma, but it's clear that you know about commas in general. There's another slip: you are calling myjoin/3, but it's actually called my_join/3. Let's think about this. What should it mean to join no strings? It could be an error, but why not return the empty string? join(Strings) -> join(Strings, " "). join([], _) -> ""; join([H|T], Delimiter) -> H ++ join_loop(T, Delimiter). join_loop([], _) -> ""; join_loop([H|T], Delimiter) -> Delimiter ++ H ++ join_loop(T, Delimiter). my_join([H|T], Delimiter, Acc) -> myjoin(T, Delimiter, lists:append([Acc, Delimiter, H]) ). my_join([], Delimiter, Acc) -> Acc. In Prolog, each clause of a predicate is terminated by a full stop. In Erlang, the clauses of a function are separated by semicolons; only the last clause has a full stop. Apart from using lists:append([X,Y,Z]) when you could just do X++Y++Z, which isn't actually _wrong_, just awkward, there's only one serious problem with the way you are approaching this. You are writing this as a tail recursive loop, passing an accumulator. In general, that's an EXCELLENT thing to do. Unfortunately, list concatenation is not a constant time operation. The cost of A++B is O(length(A)), and your Acc keeps on getting bigger and bigger. Not only that, you keep on making a new Acc and throwing the old one entirely away, so you are creating a lot of garbage. In this particular case a body recursion is the right thing to do; join_loop/2 never makes a list cell that won't be part of the final result, and the total cost is linear in the size of the input. Well, it's proportional to sum(length(X) | X <- List) + length(List) * length(Delimiter). Put it this way, it is linear in the size of the output. What I'm concerned about is the [H] and the lists:append call with the arguments being inserted into two square brackets to make a new list. Would that work? It's a Python thing, or do I need to use a function to make it a list? Square brackets are how you make a list. From vladdu55@REDACTED Thu Sep 7 08:42:40 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Thu, 7 Sep 2006 08:42:40 +0200 Subject: [erlang-questions] Using COM in Erlang In-Reply-To: <171dfd0a0609061531r7c2b1642ja1bf4e0782897744@mail.gmail.com> References: <171dfd0a0609061531r7c2b1642ja1bf4e0782897744@mail.gmail.com> Message-ID: <95be1d3b0609062342g39dbd67brabe74d5c3109253d@mail.gmail.com> Hi, On 9/7/06, Slavomir Kaslev wrote: > Can you give a clue how can I use COM from Erlang. I searched the web > but couldn't find anything on the subject. > Is there any library for doing this? Has anyone tried this before? There was an OTP library named comet that allowed this, but it was discontinued. I think it was because of lack of users and difficulty of maintaining it. You could look for it in older releases (I think R8) best regards, Vlad From vladdu55@REDACTED Thu Sep 7 08:51:10 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Thu, 7 Sep 2006 08:51:10 +0200 Subject: [erlang-questions] will Erlang ever have currying? In-Reply-To: References: <17244f480609051553i1ba9c08ck3ab38cce1f969802@mail.gmail.com> <6a36e7290609051853l43955c96h95f145544bd1e09f@mail.gmail.com> Message-ID: <95be1d3b0609062351q290e8ac4mbc6767e206339ca6@mail.gmail.com> Hi all, regarding currying, I just stumbled across a language(*) that implements "currying on steroids" with a some syntactic sugar that would look perfect for Erlang too: some_fun(X, _, 3, _) would be syntactic sugar for fun(XX, YY) -> some_fun(X, XX, 3, YY) end I think it looks cool, eliminates the overhead of regular Erlang syntax and allows currying on selected arguments. I will include it in my upcoming metaprogramming extension. best regards, Vlad From raimo+erlang-questions@REDACTED Thu Sep 7 09:34:21 2006 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Thu, 7 Sep 2006 09:34:21 +0200 Subject: [erlang-questions] Erlang newbie - quick critique? In-Reply-To: References: Message-ID: <20060907073421.GA15146@erix.ericsson.se> On Thu, Sep 07, 2006 at 04:30:35PM +1200, Liam Clarke wrote: > Hi all, > > Rather new to the FP paradigm (painful learning curve with an attempt > at Common Lisp) so I just thought I'd run my first attempts at a > recursive Erlang function past you. > > I'm not near an Erlang interpreter at the moment, unfortunately, so I > can't test the code, I'm worried about one bit, which I'll highlight. > > I'm trying to replicate the string.join() method of Python i.e., > ":".join(["a", "b", "c"]) resulting in "a:b:c" > > This is what I've drawn up on paper - > You may have forgotten the corner case of: my_join([], _Delimiter) -> []; or maybe it should be an error case? In that case you will get a function clause error for my_join([], ":"), which maybe is what you desire. > my_join([H|T] Delimiter) -> > myjoin(T, Delimiter, [H])). > % To (probably) not get "a:b:c:" as a result: my_join([H], Delimiter, Acc) -> lists:append(Acc, H); > my_join([H|T], Delimiter, Acc) -> > myjoin(T, Delimiter, lists:append([Acc, Delimiter, H]) ). > > my_join([], Delimiter, Acc) -> > Acc. > > Usage: my_join(["a", "b", "c"], ":") > > What I'm concerned about is the [H] and the lists:append call with the > arguments being inserted into two square brackets to make a new list. Since the documentation of lists:append/1 says it takes a list of lists to append, it should work. > Would that work? It's a Python thing, or do I need to use a function > to make it a list? NoNo, that is how you create lists in erlang, just as simple as in Python. What is not good in your example is that you call lists:append/1 in a loop over the lists to join, and since lists:append has to append to an increasing accumulator list you get a function that is quadratic ( O(n*n) ) for execution time, and that is mostly a bad thing except for short lists. The Erlang way to do it would probably be either: %my_join([], _Delimiter) -> % []; my_join([H], _Delimiter) -> H; my_join([H|T], Delimiter) -> H ++ (Delimiter ++ my_join(T, Delimiter)). a forward list building variant which will do lists:append/2 (i.e ++) onto only the individual sublists, and therefore process all elements only once, or: my_join(ListOfLists, Delimiter) -> my_join(ListOfLists, Delimiter, []). %my_join([], _Delimiter, R) -> % lists:reverse(R); my_join([H], _Delimiter, R) -> lists:reverse(R, H); my_join([H|T], Delimiter, R) -> my_join(T, Delimiter, lists:reverse(Delimiter, lists:reverse(H, T))). a variant that build all lists backwards, that is on the list head therefore also process every element only once (except for the Delimiter elements, just like the first variant), and then reverses the result list at the end. It uses lists:reverse/2 that reverses the first argument and appends the second in one swift operation. A sub-variant would be to reverse Delimiter at the start, use DelimiterR in the loop and replace the first lists:reverse in the loop with a ++. If you want to know which one is the fastes you will have to benchmark. Which one is the shortest is obvious. Which one is easies to read is continously debated. Note: I have not tested them either... Note2: other people have other Erlang ways... > > I've decided to start small for now - I intend to use Erlang to write > an MSN client as I think the asynchrous nature of Erlang (and I love > the sockets returning messages) suits the problem perfectly. I had > started in Python, but have hit a bunch of fiddliness with asynchrous > sockets, so thought I'd give Erlang a go. > > In designing the actual architecture of an Erlang system, can anyone > recommend some best practises? I'm working on the message interfaces > between the socket handling process and it's controller at the moment. > > Regards, > > Liam Clarke > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From samuelrivas@REDACTED Thu Sep 7 09:30:25 2006 From: samuelrivas@REDACTED (Samuel Rivas) Date: Thu, 7 Sep 2006 09:30:25 +0200 Subject: [erlang-questions] Test server In-Reply-To: References: Message-ID: <20060907073025.GA28312@nodo2.lambdastream.com> Chandru wrote: > I downloaded the test_server from > [1]http://www.erlang.org/download/test_server/test_server-3.1.1.tar.gz and > ran the emulator tests against R11B-1 and all of the tests either fail or > are skipped. Same with the stdlib. Any idea what is going wrong? > > I've attached the log if it is of any help. Can't you see more information in the html logs? You should see the failure reason there. Regards -- Samuel From oscar-erl@REDACTED Thu Sep 7 12:42:19 2006 From: oscar-erl@REDACTED (Oscar =?ISO-8859-1?Q?Hellstr=F6m?=) Date: Thu, 07 Sep 2006 12:42:19 +0200 Subject: [erlang-questions] Erlang Book - again In-Reply-To: <6184444.post@talk.nabble.com> References: <19037072-DD48-415D-A282-A51F91D780C6@citeulike.org> <8ed733900608291148l4af1c01ete5799681aa213f4c@mail.gmail.com> <6184444.post@talk.nabble.com> Message-ID: <1157625739.30660.18.camel@battlestar.oscarh.net> Hi, It is possible to buy the Erlang-book at the Cremona bookshop at Lindholmen, Gothenburg, Sweden. It comes at a price of 600SEK, which is about 60EUR. The book has been listed as course literature for Software Engineering and Management at IT University of G?teborg, but as has been said, it's a bit out of date, so not many students buy it. SIDENOTE: Could the Reply-to field be set to the mailing list by the mailing list application, this would be very convenient. Regards -- ?Oscar Hellstr?m, oscar@REDACTED web: personal.oscarh.net jid: oscar@REDACTED From chandrashekhar.mullaparthi@REDACTED Thu Sep 7 12:46:17 2006 From: chandrashekhar.mullaparthi@REDACTED (Chandru) Date: Thu, 7 Sep 2006 11:46:17 +0100 Subject: [erlang-questions] Parsing RSS (quick fix) In-Reply-To: <20060907023212.69755.qmail@web27014.mail.ukl.yahoo.com> References: <6a36e7290609041848u24dc9c0dj423c9d6ba543ab1d@mail.gmail.com> <20060907023212.69755.qmail@web27014.mail.ukl.yahoo.com> Message-ID: On 07/09/06, Ewan Higgs wrote: > > > --- Bob Ippolito wrote: > > > What it does look like is an incorrectly parsed > > HTTP/1.1 chunked > > encoding response. > > This is what's happening. I ran through the example > and found the quickest fix was to make the request > using HTTP/1.0 instead of HTTP/1.1. > You shouldn't have to do that. You are obviously using a broken HTTP client. What you need is a proper one like ibrowse :-) -------------- next part -------------- An HTML attachment was scrubbed... URL: From raimo+erlang-questions@REDACTED Thu Sep 7 13:10:49 2006 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Thu, 7 Sep 2006 13:10:49 +0200 Subject: [erlang-questions] : Erlang Book - again In-Reply-To: <1157625739.30660.18.camel@battlestar.oscarh.net> References: <19037072-DD48-415D-A282-A51F91D780C6@citeulike.org> <8ed733900608291148l4af1c01ete5799681aa213f4c@mail.gmail.com> <6184444.post@talk.nabble.com> <1157625739.30660.18.camel@battlestar.oscarh.net> Message-ID: <20060907111049.GA24970@erix.ericsson.se> On Thu, Sep 07, 2006 at 12:42:19PM +0200, Oscar Hellstr?m wrote: > Hi, : :text deleted : > SIDENOTE: > Could the Reply-to field be set to the mailing list by the mailing list > application, this would be very convenient. > Well, this is the defaul setting for Mailman, and they "strongly recommend" it should be so. They also supply a link "`Reply-To' Munging Considered Harmful" http://www.unicom.com/pw/reply-to-harmful.html So, give me a good enough reason that beats those arguments. Unfortunately their contradicting link "Reply-To Munging Considered Useful" http://www.metasystema.org/essays/reply-to-useful.mhtml leads nowhere. > -- > ?Oscar Hellstr?m, oscar@REDACTED > web: personal.oscarh.net > jid: oscar@REDACTED > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From bengt.kleberg@REDACTED Thu Sep 7 13:30:10 2006 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Thu, 07 Sep 2006 13:30:10 +0200 Subject: [erlang-questions] was there a bugfix to {packet, line} mode between R10B and R11B? In-Reply-To: <17661.18526.972650.484663@antilipe.corelatus.se> References: <17661.18526.972650.484663@antilipe.corelatus.se> Message-ID: <450002C2.5080800@ericsson.com> On 2006-09-05 11:50, Matthias Lang wrote: > Hi, > > I've attached a test program. It sends lines of data over a TCP > socket, like this: > > AAAAAAAAAAAA\r\n > BBBBBBBBBBBB\r\n > CCCCCCCCCCCC\r\n > DDDDDDDDDDDD\r\n > > and then receives them with the {packet, line} option. The odd thing > is that, sometimes, one of the lines goes missing. Running the test > for different combinations of OS and OTP release: > > Operating System R10B-10 R11B-0 > ------------------------------------------------------------- > Linux ok ok > Windows XP fails ok could this be related to the (still existing?) problem with windows and reading from stdin that was reported both one and two years ago? the following program does not work on windows (reportedly). it is supposed to be run with stdin from a file. -module(tmp). -export([main/1]). main(_Args) -> echo_lines(io:get_line('')), erlang:halt(). echo_lines(eof) -> ok; echo_lines(Line) -> io:put_chars(Line), echo_lines(io:get_line('')). bengt -- EPO guidelines 1978: "If the contribution to the known art resides solely in a computer program then the subject matter is not patentable in whatever manner it may be presented in the claims." From dmitriid@REDACTED Thu Sep 7 13:41:34 2006 From: dmitriid@REDACTED (Dmitrii Dimandt) Date: Thu, 7 Sep 2006 14:41:34 +0300 Subject: [erlang-questions] : Erlang Book - again In-Reply-To: <20060907111049.GA24970@erix.ericsson.se> References: <19037072-DD48-415D-A282-A51F91D780C6@citeulike.org> <8ed733900608291148l4af1c01ete5799681aa213f4c@mail.gmail.com> <6184444.post@talk.nabble.com> <1157625739.30660.18.camel@battlestar.oscarh.net> <20060907111049.GA24970@erix.ericsson.se> Message-ID: On 9/7/06, Raimo Niskanen wrote: > > On Thu, Sep 07, 2006 at 12:42:19PM +0200, Oscar Hellstr?m wrote: > > Hi, > : > :text deleted > : > > SIDENOTE: > > Could the Reply-to field be set to the mailing list by the mailing list > > application, this would be very convenient. > > > > Well, this is the defaul setting for Mailman, and they > "strongly recommend" it should be so. They also supply a link > "`Reply-To' Munging Considered Harmful" > http://www.unicom.com/pw/reply-to-harmful.html > So, give me a good enough reason that beats those arguments. "Reply-To munging does not benefit the user with a reasonable mailer. People want to munge Reply-To headers to make "reply back to the list" easy. But it already is easy. Reasonable mail programs have two separate "reply" commands: one that replies directly to the author of a message, and another that replies to the author plus all of the list recipients. Even the lowly Berkeley Mail command has had this for about a decade." Now, I want to reply to the list, not to a hundred people this "reply-all" may contain. I also like pressing "Reply", not "Reply All", because sometimes I simply have no time for realising that I am actually replying the list, not the person. Life should be made easy, not hard :)) "Reply-To munging destroys the "reply-to-author" capability." Well, since it is a list, there is very little reason for a reply-to-author. If somebody eve needs to reply directly to the author, his/her email can be easily copied from the From: field. All responses should go directly to the list anyway." This is arrogant. You should allow *me* to decide exactly how I wish to respond to a message. If I feel a public response is justified, I'll hit the "g" key and tell Elm to do a group-reply. If I believe a private response is more appropriate, I'll use "r" to send one. Please allow me the freedom to decide how to handle a message. Well, I am arrogant :) But anyway. Since this _is_ a list, a _natural_ choice, imho, is to set reply-to to reply-to-group. If responses should return to the sender and not the original author, then the sender will insert a Reply-To header. Well, that's what we are doing :) We are sending messages to the list, not to the original author :)) A user saddled with such a brain-dead mailer can benefit from Reply-Tomunging. It makes it easier for him or her to send responses directly to the list. This change, however, penalizes the conscientious person that uses a reasonable mailer. This is a poor trade-off. As Internet list administrators, we should encourage people to run reasonable software. This is a lame excuse anyway, I think :) Compare and contrast: the work required for me (or any other Elm user)... When I hit the "r" key in Elm, it sends a response to the author of a message. When you munge the Reply-To header you change this action so that it does something entirely different from what I expect... Ehm. What's Elm? :) There are literally thousands of mail programs out there and each behaves differently. Oh. And there's web-based mail, too... Consider the damage when things go awry. If you do not munge the Reply-Toheader and a list subscriber accidentally sends a response via private email instead of to the list, he or she has to follow up with a message that says, "Ooops! I meant to send that to the list. Could you please forward a copy for me." That's a hassle, and it happens from time to time. More often, I think, there is a situation, when a private email is sent instead of an email to the list. My opinion is that the program (mailer in my case) should work or made to work in the way that is most expected of it. When I reply to the list, it should reply to the list. If I reply to a person, it should reply to a person. Preferably, with the same function, reply-to. IMHO, of course :) :))) Unfortunately their contradicting link > "Reply-To Munging Considered Useful" > http://www.metasystema.org/essays/reply-to-useful.mhtml > leads nowhere. > > > -- > > ?Oscar Hellstr?m, oscar@REDACTED > > web: personal.oscarh.net > > jid: oscar@REDACTED > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > -- > > / Raimo Niskanen, Erlang/OTP, Ericsson AB > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dmitriid@REDACTED Thu Sep 7 13:42:36 2006 From: dmitriid@REDACTED (Dmitrii Dimandt) Date: Thu, 7 Sep 2006 14:42:36 +0300 Subject: [erlang-questions] : Erlang Book - again In-Reply-To: <20060907111049.GA24970@erix.ericsson.se> References: <19037072-DD48-415D-A282-A51F91D780C6@citeulike.org> <8ed733900608291148l4af1c01ete5799681aa213f4c@mail.gmail.com> <6184444.post@talk.nabble.com> <1157625739.30660.18.camel@battlestar.oscarh.net> <20060907111049.GA24970@erix.ericsson.se> Message-ID: > > > Unfortunately their contradicting link > "Reply-To Munging Considered Useful" > http://www.metasystema.org/essays/reply-to-useful.mhtml > leads nowhere. Here's the link: http://www.metasystema.net/essays/reply-to.mhtml > -- > > ?Oscar Hellstr?m, oscar@REDACTED > > web: personal.oscarh.net > > jid: oscar@REDACTED > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > -- > > / Raimo Niskanen, Erlang/OTP, Ericsson AB > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kostis@REDACTED Thu Sep 7 14:03:46 2006 From: kostis@REDACTED (kostis@REDACTED) Date: Thu, 7 Sep 2006 14:03:46 +0200 (MEST) Subject: [erlang-questions] HiPE/+native builds of OTP stuff? Message-ID: <200609071203.k87C3kZE020800@spikklubban.it.uu.se> Scott Lystig Fritchie wrote: > > Has anyone done testing with HiPE/+native compilation of OTP libraries > such as stdlib or Mnesia or fill-in-the-blank (heh, like 'cprof')? I am not sure this qualifies as "testing", but as part of the HiPE testsuite, we are continuously (i.e. several times a day) testing the compilation of all OTP files to native code. We know of no problems in doing so, other than the fact that some 'megaco' files take forever to compile. > Are there any reasons why someone should/should not do such a thing? The main reason why this might not be a good idea is that it is very difficult (impossible?) to debug native compiled code and the crash dumps that one gets are not so detailed as the ones when running BEAM bytecode. > After all, the out-of-the-box OTP builds don't do it, nor is there > a "--hipe-compile-everything" option for the "configure" script.... Perhaps it is a good idea to add this option. Thanks for the (implicit) suggestion. Kostis From raimo+erlang-questions@REDACTED Thu Sep 7 14:41:02 2006 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Thu, 7 Sep 2006 14:41:02 +0200 Subject: [erlang-questions] : : Erlang Book - again In-Reply-To: References: <19037072-DD48-415D-A282-A51F91D780C6@citeulike.org> <8ed733900608291148l4af1c01ete5799681aa213f4c@mail.gmail.com> <6184444.post@talk.nabble.com> <1157625739.30660.18.camel@battlestar.oscarh.net> <20060907111049.GA24970@erix.ericsson.se> Message-ID: <20060907124101.GA28866@erix.ericsson.se> OK, I will join the "'Reply-to' considered useful" side and change the setting to start munging again. On Thu, Sep 07, 2006 at 02:42:36PM +0300, Dmitrii Dimandt wrote: > > > > > >Unfortunately their contradicting link > > "Reply-To Munging Considered Useful" > > http://www.metasystema.org/essays/reply-to-useful.mhtml > >leads nowhere. > > > Here's the link: > http://www.metasystema.net/essays/reply-to.mhtml > > > >-- > >> ?Oscar Hellstr?m, oscar@REDACTED > >> web: personal.oscarh.net > >> jid: oscar@REDACTED > >> > >> _______________________________________________ > >> erlang-questions mailing list > >> erlang-questions@REDACTED > >> http://www.erlang.org/mailman/listinfo/erlang-questions > > > >-- > > > >/ Raimo Niskanen, Erlang/OTP, Ericsson AB > > > >_______________________________________________ > >erlang-questions mailing list > >erlang-questions@REDACTED > >http://www.erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From Bob.Cowdery@REDACTED Thu Sep 7 14:51:17 2006 From: Bob.Cowdery@REDACTED (Bob Cowdery) Date: Thu, 7 Sep 2006 13:51:17 +0100 Subject: [erlang-questions] 'C' Driver Question Message-ID: <3A76756EED583B43A4AD704E29CCD07974115D@mail.aprsmartlogik.com> Hi I've just started to use Erlang and this is my first post. I have a requirement to communicate between two parts of a 'C' program. One part will be a C Port and the other a C Driver type implementation. The C Port side is working but I'm having trouble with the C Driver. I have been following the examples in the Interoperability Tutorial, so first off I just wantsed to roughly follow the examples. I have built the shared library but I can't load it. This is under Ubuntu Linux incidentally. I have a library called liber_driver.so and I try to load it with erl_ddll:load_driver(".", liber_driver). I know it's loading the file because it first gave me some unresolved errors. When I fixed those it now says {error,bad_driver_name} I have no idea what this means, any help appreciated. Regards Bob From serge@REDACTED Thu Sep 7 15:20:24 2006 From: serge@REDACTED (Serge Aleynikov) Date: Thu, 07 Sep 2006 09:20:24 -0400 Subject: [erlang-questions] 'C' Driver Question In-Reply-To: <3A76756EED583B43A4AD704E29CCD07974115D@mail.aprsmartlogik.com> References: <3A76756EED583B43A4AD704E29CCD07974115D@mail.aprsmartlogik.com> Message-ID: <45001C98.8060609@hq.idt.net> What this means is that the driver name doesn't match filename. Most likely you gave an inconsistent name to your driver in the ErlDrvEntry structure, it should be: ErlDrvEntry sample_driver_entry = { ... "liber_driver", /* char *driver_name, the argument to open_port */ ... }; Also you can make the error reason more verbose by using erl_ddll:format_error/1: case erl_ddll:load_driver(".", liber_driver) of ok -> ...; {error, Reason} -> {error, erl_ddll:format_error(Reason)} end. Regards, Serge Bob Cowdery wrote: > Hi > > I've just started to use Erlang and this is my first post. I have a requirement to communicate between two parts of a 'C' program. One part will be a C Port and the other a C Driver type implementation. The C Port side is working but I'm having trouble with the C Driver. I have been following the examples in the Interoperability Tutorial, so first off I just wantsed to roughly follow the examples. I have built the shared library but I can't load it. This is under Ubuntu Linux incidentally. I have a library called liber_driver.so and I try to load it with > > erl_ddll:load_driver(".", liber_driver). > > I know it's loading the file because it first gave me some unresolved errors. When I fixed those it now says > > {error,bad_driver_name} > > I have no idea what this means, any help appreciated. > > Regards > Bob > From jahakala@REDACTED Thu Sep 7 15:20:37 2006 From: jahakala@REDACTED (Jani Hakala) Date: Thu, 07 Sep 2006 16:20:37 +0300 Subject: [erlang-questions] 'C' Driver Question In-Reply-To: <3A76756EED583B43A4AD704E29CCD07974115D@mail.aprsmartlogik.com> (Bob Cowdery's message of "Thu, 7 Sep 2006 13:51:17 +0100") References: <3A76756EED583B43A4AD704E29CCD07974115D@mail.aprsmartlogik.com> Message-ID: <878xkvlsnu.fsf@pingviini.kortex.jyu.fi> "Bob Cowdery" writes: > Hi > > I've just started to use Erlang and this is my first post. I have a > requirement to communicate between two parts of a 'C' program. One > part will be a C Port and the other a C Driver type > implementation. The C Port side is working but I'm having trouble with > the C Driver. I have been following the examples in the > Interoperability Tutorial, so first off I just wantsed to roughly > follow the examples. I have built the shared library but I can't load > it. This is under Ubuntu Linux incidentally. I have a library called > liber_driver.so and I try to load it with > > erl_ddll:load_driver(".", liber_driver). > > I know it's loading the file because it first gave me some unresolved > errors. When I fixed those it now says > > {error,bad_driver_name} > > I have no idea what this means, any help appreciated. > Do you have DRIVER_INIT(liber_driver) in your C code? Jani Hakala From ulf.wiger@REDACTED Thu Sep 7 15:43:22 2006 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Thu, 7 Sep 2006 15:43:22 +0200 Subject: [erlang-questions] Shared memory and message passing In-Reply-To: <44FEDE0F.50206@blueyonder.co.uk> Message-ID: For those writing papers out there: it's ok to say that Erlang has been used to develop applications with more than a million lines of Erlang code. ("Several hundred thousand lines of code" sounds to me as "at least more than 200,000". That hardly even registers as "large" in my book anymore. ;-) Also, the number of processes can be way larger than 50,000. We consider 30-50,000 processes to be a fairly normal number. One could perhaps note while comparing erlang programs in different execution environments, that just about all erlang programs today are written with the assumption that message passing involves copying. Therefore, it should be expected that the amount of message passing - and the size of messages actually sent - be kept reasonably low. Another thought (apologies if I just missed it in my cursory read of the paper) is that program analysis would have difficulty handling common constructs like InterfaceModule:f(X) -> ImplementationModule:f(X,...) -> ... gen_server:call(..., y(X)) when doing module-local analysis. The hybrid model might reward more explicit use of message passing (a bit in line with Joe's !! syntax) and also encourage people to use processes and message passing much more than today. I can see already how lifting the limit on how many processes one may use (from the stifling 32000 to millions), and also optimizing the runtime so that spawning, linking and message passing are already quite cheap, is changing how people go about structuring their programs. BR, Ulf W > -----Original Message----- > From: erlang-questions-bounces@REDACTED > [mailto:erlang-questions-bounces@REDACTED] On Behalf Of > David Hopwood > Sent: den 6 september 2006 16:41 > To: Erlang/OTP discussions > Subject: Re: [erlang-questions] Shared memory and message passing > > Richard Carlsson wrote: > > PS. Shameless plug: see the July issue of TOPLAS (vol 28, > issue 4) for > > all the gruelling details on the hybrid architecture. > > On-line at . > > -- > David Hopwood > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From Bob.Cowdery@REDACTED Thu Sep 7 15:57:03 2006 From: Bob.Cowdery@REDACTED (Bob Cowdery) Date: Thu, 7 Sep 2006 14:57:03 +0100 Subject: [erlang-questions] 'C' Driver Question Message-ID: <3A76756EED583B43A4AD704E29CCD079715C80@mail.aprsmartlogik.com> Serge Thank you, that fixed it. It wasn't obvious to me the name had to be the filename. Nice to see this group looks fairly active, good to know when starting out. Regards Bob -----Original Message----- From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED]On Behalf Of Serge Aleynikov Sent: 07 September 2006 14:20 To: Erlang/OTP discussions Subject: Re: [erlang-questions] 'C' Driver Question What this means is that the driver name doesn't match filename. Most likely you gave an inconsistent name to your driver in the ErlDrvEntry structure, it should be: ErlDrvEntry sample_driver_entry = { ... "liber_driver", /* char *driver_name, the argument to open_port */ ... }; Also you can make the error reason more verbose by using erl_ddll:format_error/1: case erl_ddll:load_driver(".", liber_driver) of ok -> ...; {error, Reason} -> {error, erl_ddll:format_error(Reason)} end. Regards, Serge Bob Cowdery wrote: > Hi > > I've just started to use Erlang and this is my first post. I have a requirement to communicate between two parts of a 'C' program. One part will be a C Port and the other a C Driver type implementation. The C Port side is working but I'm having trouble with the C Driver. I have been following the examples in the Interoperability Tutorial, so first off I just wantsed to roughly follow the examples. I have built the shared library but I can't load it. This is under Ubuntu Linux incidentally. I have a library called liber_driver.so and I try to load it with > > erl_ddll:load_driver(".", liber_driver). > > I know it's loading the file because it first gave me some unresolved errors. When I fixed those it now says > > {error,bad_driver_name} > > I have no idea what this means, any help appreciated. > > Regards > Bob > _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions From huss01@REDACTED Thu Sep 7 16:13:25 2006 From: huss01@REDACTED (=?ISO-8859-1?Q?H=E5kan_Huss?=) Date: Thu, 7 Sep 2006 16:13:25 +0200 Subject: [erlang-questions] Erlang Book - again In-Reply-To: <1157625739.30660.18.camel@battlestar.oscarh.net> References: <19037072-DD48-415D-A282-A51F91D780C6@citeulike.org> <8ed733900608291148l4af1c01ete5799681aa213f4c@mail.gmail.com> <6184444.post@talk.nabble.com> <1157625739.30660.18.camel@battlestar.oscarh.net> Message-ID: On 9/7/06, Oscar Hellstr?m wrote: > SIDENOTE: > Could the Reply-to field be set to the mailing list by the mailing list > application, this would be very convenient. > http://www.unicom.com/pw/reply-to-harmful.html Regards, /H?kan From aho-erlang-questions@REDACTED Thu Sep 7 20:57:50 2006 From: aho-erlang-questions@REDACTED (Adrian Ho) Date: Fri, 8 Sep 2006 02:57:50 +0800 Subject: [erlang-questions] : Erlang Book - again In-Reply-To: References: <19037072-DD48-415D-A282-A51F91D780C6@citeulike.org> <8ed733900608291148l4af1c01ete5799681aa213f4c@mail.gmail.com> <6184444.post@talk.nabble.com> <1157625739.30660.18.camel@battlestar.oscarh.net> <20060907111049.GA24970@erix.ericsson.se> Message-ID: <20060907185750.GD13017@megapower.03s.net> On Thu, Sep 07, 2006 at 02:41:34PM +0300, Dmitrii Dimandt wrote: > (quoting the "Reply-To Munging Considered Useful" document): Consider > the damage when things go awry. If you do not munge the Reply-To header > and a list subscriber accidentally sends a response via private email > instead of to the list, he or she has to follow up with a message that > says, "Ooops! I meant to send that to the list. Could you please forward > a copy for me." That's a hassle, and it happens from time to time. There's another kind of "damage" that the document doesn't describe, but this one does: Mail loops aren't theoretical: A list I was subscribed to some years back (I forget which) had Reply-To-List set up, and everyone was happy. Then one day, someone went on vacation and turned on his/her b0rken autoresponder. Within an hour, everyone on the list had almost a thousand autoresponses in their inboxes. Another list had: * a mode that sent out list digests with Reply-To-List (which makes quite a lot of sense, on the surface), and * a digest subscriber with a seriously b0rken autoresponder, that not only did not limit its response rate, but also quoted the entire incoming message right back Within an hour, everyone[*] on the list had almost 200MB of list "mail" that consisted solely of digests of digests of...ad infinitum. Factor in the usual list archiving, and I think you can see where this is headed. The cleanup was, shall we say, painstaking -- and some folks probably deleted mail they shouldn't have in the process. The list admin, naturally, was not amused and promptly "kicked" the offender. [*] I lied: The lucky ones (like me) who had effectively unlimited mail space got the 200MB. The *unlucky* ones went over quota within minutes, and may have lost other incoming email because of the mail loop. Upshot: Reply-To-List works well 99.99% of the time, no argument there. The 0.01% of the time it facilitates a mail loop, *everyone* suffers, especially the list admin and his/her mail server. Note of interest: SourceForge (the origin of the above URL) used to *ban* Reply-To-List outright on all its lists because of the potential for disaster that I described above. It seems to have modified its stance since then, probably because truly b0rken autoresponders are quite rare nowadays. It just takes one, though... - Adrian From jefcrane@REDACTED Thu Sep 7 21:54:38 2006 From: jefcrane@REDACTED (Jeff Crane) Date: Thu, 7 Sep 2006 12:54:38 -0700 (PDT) Subject: [erlang-questions] 2D Map Arrays In-Reply-To: Message-ID: <20060907195438.53546.qmail@web31605.mail.mud.yahoo.com> I am trying to implement a 2d map in erlang where dynamic elements will be traversing it via reference. I have no other way to get the "locations" into memory other than using a large array, explicitly for reading. The bottom "terrain" layer is what the static array represents. Putting this in memory consists of reading from a text file in the example format: { % map tuple start { % row start {ID,{a1,a2}}, % column ... }, % row end ... } % map tuple end Question: read it into memory as a large tuple or list? I have heard of a "binary" format in erlang that is used for this kind of read-without-copy on large amounts of data. I assume that I should read out a map export then convert it to binary, then read it cheaply. I haven't located a good usage tutorial for the binary format and could use a guide if this is the preferred method. What do I do when I want to operate on a similarly sized dynamic layer that I want to read/write to? Tuple or List or Binary or something else? The idea of each "location" being a process might be a good idea for dynamic layers, but not for the base terrain layer, which has no behaviors IMO. __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From chandrashekhar.mullaparthi@REDACTED Thu Sep 7 22:56:30 2006 From: chandrashekhar.mullaparthi@REDACTED (Chandru) Date: Thu, 7 Sep 2006 21:56:30 +0100 Subject: [erlang-questions] 2D Map Arrays In-Reply-To: <20060907195438.53546.qmail@web31605.mail.mud.yahoo.com> References: <20060907195438.53546.qmail@web31605.mail.mud.yahoo.com> Message-ID: On 07/09/06, Jeff Crane wrote: > > I am trying to implement a 2d map in erlang where > dynamic elements will be traversing it via reference. > I have no other way to get the "locations" into memory > other than using a large array, explicitly for > reading. Umm...I don't quite understand your data structure but have you looked at ets? It is for storing tuples. You can then lookup rows/cells using either a key or a match pattern. http://www.erlang.org/doc/doc-5.5.1/lib/stdlib-1.14.1/doc/html/ets.html I have heard of a "binary" format in erlang that is > used for this kind of read-without-copy on large > amounts of data. Have you seen this? http://www.erlang.org/doc/doc-5.5.1/doc/programming_examples/bit_syntax.html#4 Binaries larger than 64 bytes (I think) are referenced to and not copied on read. Binaries smaller than 64 bytes are copied when exchanged between processes. cheers Chandru -------------- next part -------------- An HTML attachment was scrubbed... URL: From hokan.stenholm@REDACTED Fri Sep 8 00:06:30 2006 From: hokan.stenholm@REDACTED (=?ISO-8859-1?Q?H=E5kan_Stenholm?=) Date: Fri, 08 Sep 2006 00:06:30 +0200 Subject: [erlang-questions] 2D Map Arrays In-Reply-To: <20060907195438.53546.qmail@web31605.mail.mud.yahoo.com> References: <20060907195438.53546.qmail@web31605.mail.mud.yahoo.com> Message-ID: <450097E6.6070003@bredband.net> Jeff Crane wrote: >I am trying to implement a 2d map in erlang where >dynamic elements will be traversing it via reference. >I have no other way to get the "locations" into memory >other than using a large array, explicitly for >reading. > >The bottom "terrain" layer is what the static array >represents. Putting this in memory consists of reading >from a text file in the example format: >{ % map tuple start > { % row start > {ID,{a1,a2}}, % column > ... > }, % row end > ... >} % map tuple end > >Question: read it into memory as a large tuple or >list? > >I have heard of a "binary" format in erlang that is >used for this kind of read-without-copy on large >amounts of data. I assume that I should read out a map >export then convert it to binary, then read it >cheaply. I haven't located a good usage tutorial for >the binary format and could use a guide if this is the >preferred method. > > There are a number of fairly obvious choices to implement a 2D array (to for example be able to do efficient random access): * use a tuple of terms - this is probably the fastest way[1] to do random access (based on a positional index) in a fixed size array. O(1) read, O(N) update cost. 1: tuple reads have the same speed as reading from the head of a list. * use a binary - similar to using a tuple, but may be somewhat more complicated to access, but has the benefit to be able to store small elements (< 1 word length) compactly. Building new binaries (doing updates) may be costly. * ets tables have reasonably fast reads and writes and may also be a good way to model spares arrays. The drawback (mainly for fast reads) is that ets reads are several times slower than tuple accesses. Note: ets tables do destructive updates which introduce non-functional state concerns - the same ets table can't be passed to two functions, both which write in the ets tables without introducing execution dependencies between the two, they may for example break if run in parallel. Note: ets tables are only visible on a single erlang node - this may introduce additional work if they need to be distribute on several machines. Some of the above issues can be fixed by using mnesia or another transactional database. * various kinds of trees (e.g. binary ones) can be used - but read / write times for small trees are not noticeably better than ets tables and probably worse when the tree grows large - due to the log(N) factor (ets is O(1)). Note: trees suffer none of the issues mentioned in the notes for ets tables - this also makes it very simple to implement an undo function, simply keep a number of old trees around, only log(N) elements will differ between each write update, so storage will be = LevesOfUndo * log(N). I would therefore recommend using tuples or binaries for fixed sized read only arrays, and trees or ets tables for more dynamic "arrays", depending on your needs and your likelihood of wanting to turn the ets table into a real database like mnesia. >What do I do when I want to operate on a similarly >sized dynamic layer that I want to read/write to? > >Tuple or List or Binary or something else? > >The idea of each "location" being a process might be a >good idea for dynamic layers, but not for the base >terrain layer, which has no behaviors IMO. > > > > > >__________________________________________________ >Do You Yahoo!? >Tired of spam? Yahoo! Mail has the best spam protection around >http://mail.yahoo.com >_______________________________________________ >erlang-questions mailing list >erlang-questions@REDACTED >http://www.erlang.org/mailman/listinfo/erlang-questions > > > From klacke@REDACTED Fri Sep 8 01:06:59 2006 From: klacke@REDACTED (Claes Wikstom) Date: Fri, 08 Sep 2006 01:06:59 +0200 Subject: [erlang-questions] Parsing RSS (quick fix) In-Reply-To: References: <6a36e7290609041848u24dc9c0dj423c9d6ba543ab1d@mail.gmail.com> <20060907023212.69755.qmail@web27014.mail.ukl.yahoo.com> Message-ID: <4500A613.5040302@hyber.org> Chandru wrote: > You shouldn't have to do that. You are obviously using a broken HTTP > client. What you need is a proper one like ibrowse :-) > The smiley is the wrong way, It should be :-( There are quite a few broken HTTP clients in erlang and "ibrowse" is not one of them. Resorting to HTTP 1.0 seems like ... 2001 or something /klacke -- Claes Wikstrom -- Caps lock is nowhere and http://www.hyber.org -- everything is under control cellphone: +46 70 2097763 From wilbjor@REDACTED Fri Sep 8 01:59:30 2006 From: wilbjor@REDACTED (Jordan Wilberding) Date: Thu, 07 Sep 2006 18:59:30 -0500 Subject: [erlang-questions] Securing link between nodes Message-ID: <4500B262.6080507@iit.edu> Hello, I know this question has been asked before, but I have a few more questions about it. I am wanting to encrypt all communications between each node transparently(that is to say, without the erlang code knowing anything about it). It appears the best you can do now is use SSL for authentication, but it still doesn't encrypt the actual messages. My question is, whatever happened to this thesis that someone wrote about SafeErlang? It appears they implemented public key encryption between nodes. But I can't find any downloads or anything. Is anyone currently working on this problem? If not, I might be interested in trying it out. I just want to make sure no one else is already doing it. It definitely seems that this would be a great addition to Erlang. Thanks! Jordan Wilberding From fbg111@REDACTED Fri Sep 8 10:16:02 2006 From: fbg111@REDACTED (fbg111) Date: Fri, 8 Sep 2006 01:16:02 -0700 (PDT) Subject: [erlang-questions] Erlang Book - again In-Reply-To: <1157625739.30660.18.camel@battlestar.oscarh.net> References: <19037072-DD48-415D-A282-A51F91D780C6@citeulike.org> <8ed733900608291148l4af1c01ete5799681aa213f4c@mail.gmail.com> <6184444.post@talk.nabble.com> <1157625739.30660.18.camel@battlestar.oscarh.net> Message-ID: <6204746.post@talk.nabble.com> Oscar Hellstr?m wrote: > > Could the Reply-to field be set to the mailing list by the mailing list > application, this would be very convenient. > Here's a forum interface to the mailing list you might find helpful: http://www.nabble.com/Erlang-Questions-f14096.html -- View this message in context: http://www.nabble.com/Erlang-Book---again-tf2184476.html#a6204746 Sent from the Erlang Questions forum at Nabble.com. From klacke@REDACTED Fri Sep 8 10:27:41 2006 From: klacke@REDACTED (Claes Wikstrom) Date: Fri, 08 Sep 2006 10:27:41 +0200 Subject: [erlang-questions] Securing link between nodes In-Reply-To: <4500B262.6080507@iit.edu> References: <4500B262.6080507@iit.edu> Message-ID: <4501297D.3070300@hyber.org> Jordan Wilberding wrote: > Hello, > > I know this question has been asked before, but I have a few more > questions about it. > > I am wanting to encrypt all communications between each node > transparently(that is to say, without the erlang code knowing anything > about it). setup an IPSEC tunnel between the two machines. /klacke -- Claes Wikstrom -- Caps lock is nowhere and http://www.hyber.org -- everything is under control cellphone: +46 70 2097763 From chandrashekhar.mullaparthi@REDACTED Fri Sep 8 10:37:27 2006 From: chandrashekhar.mullaparthi@REDACTED (Chandru) Date: Fri, 8 Sep 2006 09:37:27 +0100 Subject: [erlang-questions] Parsing RSS (quick fix) In-Reply-To: <4500A613.5040302@hyber.org> References: <6a36e7290609041848u24dc9c0dj423c9d6ba543ab1d@mail.gmail.com> <20060907023212.69755.qmail@web27014.mail.ukl.yahoo.com> <4500A613.5040302@hyber.org> Message-ID: On 08/09/06, Claes Wikstom wrote: > > Chandru wrote: > > > You shouldn't have to do that. You are obviously using a broken HTTP > > client. What you need is a proper one like ibrowse :-) > > > > The smiley is the wrong way, It should be :-( No it isn't - I was recommending the client I wrote, hence the happy smiley. There are quite a few broken HTTP clients in erlang > and "ibrowse" is not one of them. Ofcourse - and thank you :-) cheers Chandru -------------- next part -------------- An HTML attachment was scrubbed... URL: From chandrashekhar.mullaparthi@REDACTED Fri Sep 8 10:43:53 2006 From: chandrashekhar.mullaparthi@REDACTED (Chandru) Date: Fri, 8 Sep 2006 09:43:53 +0100 Subject: [erlang-questions] Securing link between nodes In-Reply-To: <4500B262.6080507@iit.edu> References: <4500B262.6080507@iit.edu> Message-ID: On 08/09/06, Jordan Wilberding wrote: > > Hello, > > I know this question has been asked before, but I have a few more > questions about it. > > I am wanting to encrypt all communications between each node > transparently(that is to say, without the erlang code knowing anything > about it). It appears the best you can do now is use SSL for > authentication, but it still doesn't encrypt the actual messages. I have never tried it, but if you configured erlang distribution over SSL, all communication between the nodes should be encrypted. Not just authentication. See http://www.erlang.org/doc/doc-5.5/lib/ssl-3.0.12/doc/html/ssl_distribution.html#5 Chandru -------------- next part -------------- An HTML attachment was scrubbed... URL: From A.BETIS@REDACTED Fri Sep 8 11:49:21 2006 From: A.BETIS@REDACTED (BETIS Alexandre) Date: Fri, 8 Sep 2006 11:49:21 +0200 Subject: [erlang-questions] Erlang now in the railway industry Message-ID: <69433317F55792499C45450D56E31F0828B06B@LUC2K01VS.csee-transport.fr> Hi all, Just a note to let you know that I have completed final delivery (i.e. no more bugs and customer payment in full) of a 100% Erlang app to be deployed in the Lyons metro in France (lines A, B, C). This industrial app is responsible for computing train arrival times for all stations on the line in real time, taking perturbations into account. In a few months, it will be coupled with LCD screens on each platform to display the computed values to passengers. The customer was /very/ surprised with this new software that "never crashed once". I would like to thank everyone on the list for the support. Now repeat after me: "Erlang is > NOT < a telco-only thing!" Cheers, -- Alex Betis " Ce message et ses pieces jointes sont confidentiels et exclusivement reserves a leurs destinataires qui s'assureront de l'absence de virus. CSEE Transport n'assume aucune responsabilite au titre de ce message s'il est altere, deforme, falsifie, indument utilise par des tiers ou encore s'il a cause des dommages ou pertes de toute nature. This e-mail and any attached files are confidential and exclusively intended for its addressees who will conduct appropriate virus checks. CSEE Transport shall not be liable for the message if altered, changed, falsified, unduly used by third parties nor for any damage or loss." From Dietmar.Schaefer@REDACTED Fri Sep 8 12:02:54 2006 From: Dietmar.Schaefer@REDACTED (Dietmar.Schaefer@REDACTED) Date: Fri, 8 Sep 2006 12:02:54 +0200 Subject: [erlang-questions] erlang in Air Traffic Management ? Message-ID: Hi ! Since I know now that Erlang is in use in the railway industrie I really would like to know IF ANYONE is actually using erlang in AIR TRAFFIC MANAGEMENT ??? Please drop me a line ! reagrds Dietmar DFS Deutsche Flugsicherung GmbH Center Langen Am DFS-Campus 1 D - 63225 Langen Tel.: +49-(0)6103-707-0 Internet: http://www.dfs.de Public-Key der DFS: http://www.dfs.de/dfs/public_key.asc -------------- next part -------------- An HTML attachment was scrubbed... URL: From chsu79@REDACTED Fri Sep 8 12:21:19 2006 From: chsu79@REDACTED (Christian S) Date: Fri, 8 Sep 2006 12:21:19 +0200 Subject: [erlang-questions] Erlang now in the railway industry In-Reply-To: <69433317F55792499C45450D56E31F0828B06B@LUC2K01VS.csee-transport.fr> References: <69433317F55792499C45450D56E31F0828B06B@LUC2K01VS.csee-transport.fr> Message-ID: Thank you very much for sharing this with us! Can we collect erlang success stories somewhere? Or are we already? Suggestion: Trapexit wiki and categorize them as http://wiki.trapexit.org/index.php/Category:Success_Stories On 9/8/06, BETIS Alexandre wrote: > Hi all, > > Just a note to let you know that I have completed > final delivery (i.e. no more bugs and customer > payment in full) of a 100% Erlang app to be deployed > in the Lyons metro in France (lines A, B, C). > > This industrial app is responsible for computing > train arrival times for all stations on the line in > real time, taking perturbations into account. In a few > months, it will be coupled with LCD screens on each > platform to display the computed values to passengers. > The customer was /very/ surprised with this new software > that "never crashed once". > > I would like to thank everyone on the list for the > support. > > Now repeat after me: > > "Erlang > is > > NOT < > a telco-only thing!" > > Cheers, > > -- Alex Betis > > > > " Ce message et ses pieces jointes sont confidentiels et exclusivement reserves a leurs destinataires qui s'assureront de l'absence de virus. CSEE Transport n'assume aucune responsabilite au titre de ce message s'il est altere, deforme, falsifie, indument utilise par des tiers ou encore s'il a cause des dommages ou pertes de toute nature. > > This e-mail and any attached files are confidential and exclusively intended for its addressees who will conduct appropriate virus checks. CSEE Transport shall not be liable for the message if altered, changed, falsified, unduly used by third parties nor for any damage or loss." > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From Bob.Cowdery@REDACTED Fri Sep 8 13:06:12 2006 From: Bob.Cowdery@REDACTED (Bob Cowdery) Date: Fri, 8 Sep 2006 12:06:12 +0100 Subject: [erlang-questions] C Port Question Message-ID: <3A76756EED583B43A4AD704E29CCD07974115E@mail.aprsmartlogik.com> Hi I have a further problem now with C Ports. I can get this to work fine as a client but am having trouble as a server. Thinking I couldn't see my problem I copied the code out of the interoperability tutorial cnode_s.c verbatim, changed the cookie to the right value and added foo() and bar() which seem to be missing. It compiles ok but when run falls out on erl_publish(). I don't know the language very well yet so not sure how to get proper diagnostics. It just returns -1 which obviously is a failure. I don't know if there are any port restrictions or if I can use any free port. Again any help appreciated. Thanks Bob From jahakala@REDACTED Fri Sep 8 13:32:59 2006 From: jahakala@REDACTED (Jani Hakala) Date: Fri, 08 Sep 2006 14:32:59 +0300 Subject: [erlang-questions] C Port Question In-Reply-To: <3A76756EED583B43A4AD704E29CCD07974115E@mail.aprsmartlogik.com> (Bob Cowdery's message of "Fri, 8 Sep 2006 12:06:12 +0100") References: <3A76756EED583B43A4AD704E29CCD07974115E@mail.aprsmartlogik.com> Message-ID: <87ac5ah9uc.fsf@pingviini.kortex.jyu.fi> "Bob Cowdery" writes: > Hi > > I have a further problem now with C Ports. I can get this to work fine > as a client but am having trouble as a server. Thinking I couldn't see > my problem I copied the code out of the interoperability tutorial > cnode_s.c verbatim, changed the cookie to the right value and added > foo() and bar() which seem to be missing. It compiles ok but when run > falls out on erl_publish(). I don't know the language very well yet so > not sure how to get proper diagnostics. It just returns -1 which > obviously is a failure. I don't know if there are any port > restrictions or if I can use any free port. Again any help > appreciated. > You could check that epmd is running. strace program might give you more information about what is the problem. Jani Hakala From theepan@REDACTED Fri Sep 8 13:25:24 2006 From: theepan@REDACTED (theeepan) Date: Fri, 8 Sep 2006 17:25:24 +0600 Subject: [erlang-questions] Join equivalent Message-ID: <000001c6d339$7ca8c630$9b0a10ac@wavenet.lk> Hi, Is there an equivalent function in Erlang to "C pthreads join"? This can semantically be implemented with linked process with 'receive to exit', but what I want to know is whether there is a direct BIF to call after spawn? Thanks, N.Piriyatheepan -------------- next part -------------- An HTML attachment was scrubbed... URL: From bengt.kleberg@REDACTED Fri Sep 8 13:59:19 2006 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Fri, 08 Sep 2006 13:59:19 +0200 Subject: [erlang-questions] Join equivalent In-Reply-To: <000001c6d339$7ca8c630$9b0a10ac@wavenet.lk> References: <000001c6d339$7ca8c630$9b0a10ac@wavenet.lk> Message-ID: <45015B17.1090404@ericsson.com> On 2006-09-08 13:25, theeepan wrote: > Hi, > > > > Is there an equivalent function in Erlang to ?C pthreads join?? This can no, there is no such thing. bengt -- EPO guidelines 1978: "If the contribution to the known art resides solely in a computer program then the subject matter is not patentable in whatever manner it may be presented in the claims." From chsu79@REDACTED Fri Sep 8 14:12:51 2006 From: chsu79@REDACTED (Christian S) Date: Fri, 8 Sep 2006 14:12:51 +0200 Subject: [erlang-questions] Join equivalent In-Reply-To: <000001c6d339$7ca8c630$9b0a10ac@wavenet.lk> References: <000001c6d339$7ca8c630$9b0a10ac@wavenet.lk> Message-ID: On 9/8/06, theeepan wrote: > Hi, > > Is there an equivalent function in Erlang to "C pthreads join"? This can > semantically be implemented with linked process with 'receive to exit', but > what I want to know is whether there is a direct BIF to call after spawn? Short answer: No, not directly. Longer answer: You can use erlang:monitor/2 to follow the status of the process. See the manual for this. Different approach: By passing the spawned process your pid and having it report back with a message to you when it has completed its task is also an option. Psuedo-ish code: Pid = spawn_link(M, F, [self()), mystuff(), receive {done, Pid} -> phew() after 5000 -> ohnoes() end If the spawned process fails, it will crash and bring you down as well. This can be a good thing that moves error handling higher up in abstraction. PS. The function rpc:pmap/3 could be a better api for you, depending on what problem you are trying to solve. From vladdu55@REDACTED Fri Sep 8 14:15:35 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Fri, 8 Sep 2006 14:15:35 +0200 Subject: [erlang-questions] will Erlang ever have currying? In-Reply-To: <95be1d3b0609062351q290e8ac4mbc6767e206339ca6@mail.gmail.com> References: <17244f480609051553i1ba9c08ck3ab38cce1f969802@mail.gmail.com> <6a36e7290609051853l43955c96h95f145544bd1e09f@mail.gmail.com> <95be1d3b0609062351q290e8ac4mbc6767e206339ca6@mail.gmail.com> Message-ID: <95be1d3b0609080515s60007b12gfb022002158af0a0@mail.gmail.com> On 9/7/06, Vlad Dumitrescu wrote: > some_fun(X, _, 3, _) > > would be syntactic sugar for > > fun(XX, YY) -> some_fun(X, XX, 3, YY) end If anyone really wants to use this today, please go to http://forum.trapexit.org/viewtopic.php?p=21183, where I submitted a parse_transform that will let you use the above right away. (It has a funny gensym() implementation, so I'd not use it "as is" in a production environment) regards, Vlad From sean.hinde@REDACTED Fri Sep 8 14:30:58 2006 From: sean.hinde@REDACTED (Sean Hinde) Date: Fri, 8 Sep 2006 13:30:58 +0100 Subject: [erlang-questions] Join equivalent In-Reply-To: <000001c6d339$7ca8c630$9b0a10ac@wavenet.lk> References: <000001c6d339$7ca8c630$9b0a10ac@wavenet.lk> Message-ID: > Is there an equivalent function in Erlang to ?C pthreads join?? > This can semantically be implemented with linked process with > ?receive to exit?, but what I want to know is whether there is a > direct BIF to call after spawn? You are on the right track with "receive to exit". One nice trick you can do in erlang is to return the result of some short lived process in the exit message. This saves having to send a result message as well as handling the EXIT. Sketch of code here: spawn(fun() -> short_lived() end), receive {'EXIT', {ok, Result}} -> result_proc(Result); {'EXIT', Error} -> log_error(Error) end. short_lived() -> Res = do_work(), exit({ok, Res}). Sean > > > Thanks, > > N.Piriyatheepan > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From Bob.Cowdery@REDACTED Fri Sep 8 15:20:58 2006 From: Bob.Cowdery@REDACTED (Bob Cowdery) Date: Fri, 8 Sep 2006 14:20:58 +0100 Subject: [erlang-questions] C Port Question Message-ID: <3A76756EED583B43A4AD704E29CCD079715C82@mail.aprsmartlogik.com> Thank you, that was easy. I wondered how name serving was done, now I know. Regards Bob -----Original Message----- From: Jani Hakala [mailto:jahakala@REDACTED] Sent: 08 September 2006 12:33 To: Bob Cowdery Cc: erlang-questions@REDACTED Subject: Re: [erlang-questions] C Port Question "Bob Cowdery" writes: > Hi > > I have a further problem now with C Ports. I can get this to work fine > as a client but am having trouble as a server. Thinking I couldn't see > my problem I copied the code out of the interoperability tutorial > cnode_s.c verbatim, changed the cookie to the right value and added > foo() and bar() which seem to be missing. It compiles ok but when run > falls out on erl_publish(). I don't know the language very well yet so > not sure how to get proper diagnostics. It just returns -1 which > obviously is a failure. I don't know if there are any port > restrictions or if I can use any free port. Again any help > appreciated. > You could check that epmd is running. strace program might give you more information about what is the problem. Jani Hakala From garry@REDACTED Fri Sep 8 15:29:47 2006 From: garry@REDACTED (Garry Hodgson) Date: Fri, 8 Sep 2006 09:29:47 -0400 (EDT) Subject: [erlang-questions] Erlang now in the railway industry In-Reply-To: <69433317F55792499C45450D56E31F0828B06B@LUC2K01VS.csee-transport.fr> References: <69433317F55792499C45450D56E31F0828B06B@LUC2K01VS.csee-transport.fr> Message-ID: <2006090809291157722187@k2.sage.att.com> "BETIS Alexandre" wrote: > Just a note to let you know that I have completed > final delivery (i.e. no more bugs and customer > payment in full) of a 100% Erlang app to be deployed > in the Lyons metro in France (lines A, B, C). congratulations, that is excellent news. for all of us. > The customer was /very/ surprised with this new software > that "never crashed once". why am *i* not surprised? ---- Garry Hodgson, Senior Software Geek, AT&T CSO But I'm not giving in an inch to fear 'Cause I promised myself this year I feel like I owe it...to someone. From vladdu55@REDACTED Fri Sep 8 16:58:43 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Fri, 8 Sep 2006 15:58:43 +0100 Subject: [erlang-questions] GUI idea Message-ID: <95be1d3b0609080758t74ce6c50xf9a71b345df26d11@mail.gmail.com> Hi all, I just had an idea and thought I'd share it. It is about building Erlang GUIs. Currently the most used GUI kit is gs. Not very cool, but works and is good enough for simple apps. Now gs is build quite modularily, and one could write a different backend the would be more impressive looking. So far so good, nothing new. But... What if the new gs backend would actually start yaws and a browser, and build the actual GUI as yaws+ajax pages? Wouldn't that actually be better than Rails? ;-) After upgrading gs to use all cool Web2.0 controls, of course... This seems too good to be actually a new idea, but I'll check the net _after_ sending this :-) best regards, Vlad From dmitriid@REDACTED Fri Sep 8 17:08:10 2006 From: dmitriid@REDACTED (Dmitrii Dimandt) Date: Fri, 8 Sep 2006 18:08:10 +0300 Subject: [erlang-questions] GUI idea In-Reply-To: <95be1d3b0609080758t74ce6c50xf9a71b345df26d11@mail.gmail.com> References: <95be1d3b0609080758t74ce6c50xf9a71b345df26d11@mail.gmail.com> Message-ID: Well, I think it's better to hook with HTMLayout. However, there is a downside to HTMLayout - it's not opensource (though free for any use whatsoever) :( On 9/8/06, Vlad Dumitrescu wrote: > > Hi all, > > I just had an idea and thought I'd share it. It is about building Erlang > GUIs. > > Currently the most used GUI kit is gs. Not very cool, but works and is > good enough for simple apps. Now gs is build quite modularily, and one > could write a different backend the would be more impressive looking. > > So far so good, nothing new. But... > > What if the new gs backend would actually start yaws and a browser, > and build the actual GUI as yaws+ajax pages? Wouldn't that actually be > better than Rails? ;-) After upgrading gs to use all cool Web2.0 > controls, of course... > > This seems too good to be actually a new idea, but I'll check the net > _after_ sending this :-) > > best regards, > Vlad > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From vladdu55@REDACTED Fri Sep 8 17:15:10 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Fri, 8 Sep 2006 16:15:10 +0100 Subject: [erlang-questions] GUI idea In-Reply-To: References: <95be1d3b0609080758t74ce6c50xf9a71b345df26d11@mail.gmail.com> Message-ID: <95be1d3b0609080815o3cb458a6ge664ecdd9ba622d6@mail.gmail.com> On 9/8/06, Dmitrii Dimandt wrote: > Well, I think it's better to hook with HTMLayout. However, there is a > downside to HTMLayout - it's not opensource (though free for any use > whatsoever) :( Mmmm, it doesn't look like it's free... In any case, my point was that if there is an engine that generates dynamically the html & javascript required, then we can solve the gui problem. And also, since it's going to be in a browser, it will work remotely by default. Kind of an "X server in the browser" or something like that :-) /Vlad From vladdu55@REDACTED Fri Sep 8 17:22:08 2006 From: vladdu55@REDACTED (vladdu) Date: Fri, 08 Sep 2006 16:22:08 +0100 Subject: [erlang-questions] GUI idea References: Message-ID: <20060908152208.918B25A1F8@mail.erlangsystems.com> about HtmlLayout:: sorry, I didn't read till the end, the listed prices are for support. Well, yes, why not use that one as a backend too? Except it's Windows only (if I'm not too hasty again) /Vlad _________________________________________________________ Post sent from http://www.trapexit.org From dmitriid@REDACTED Fri Sep 8 17:30:13 2006 From: dmitriid@REDACTED (Dmitrii Dimandt) Date: Fri, 8 Sep 2006 18:30:13 +0300 Subject: [erlang-questions] GUI idea In-Reply-To: <95be1d3b0609080815o3cb458a6ge664ecdd9ba622d6@mail.gmail.com> References: <95be1d3b0609080758t74ce6c50xf9a71b345df26d11@mail.gmail.com> <95be1d3b0609080815o3cb458a6ge664ecdd9ba622d6@mail.gmail.com> Message-ID: On 9/8/06, Vlad Dumitrescu wrote: > > On 9/8/06, Dmitrii Dimandt wrote: > > Well, I think it's better to hook with HTMLayout. However, there is a > > downside to HTMLayout - it's not opensource (though free for any use > > whatsoever) :( > > Mmmm, it doesn't look like it's free... It is :) The author didn't state that quite correctly on the site, but it is (http://www.terrainformatica.com/htmlayout/prices.whtm): You may utilize HTMLayout Component Software Product free of charge in any manner you see fit (subject to the limitations outlined in this license) to build commercial or non-commercial applications and components. Your application shall include link to Terra Informatica site in "About" dialog or similar place in your application. Text of the link: This Application (or Component) uses HTMLayout Component, copyright Terra Informatica Software, Inc. (http://terrainformatica.com). Well. It's not too good of a license. And it's not opensource :( But it is currently the most mature of such framewroks anywhere (see demo applications) to see what I mean (and whatch the next line of the entire Norton product line to sport a HTMLayout interface, actually... :) ) AFAIK, the author is currently working on a Linux port (since he's a regular at www.rsdn.ru, he sometimes lets people in on some of the inside info) However, it's not opensource, so, I guess, it's end of story :( In any case, my point was that if there is an engine that generates > dynamically the html & javascript required, then we can solve the gui > problem. And also, since it's going to be in a browser, it will work > remotely by default. > > Kind of an "X server in the browser" or something like that :-) That's would definetely be great /Vlad > -------------- next part -------------- An HTML attachment was scrubbed... URL: From olivier.sambourg@REDACTED Fri Sep 8 17:43:16 2006 From: olivier.sambourg@REDACTED (Olivier Sambourg) Date: Fri, 8 Sep 2006 17:43:16 +0200 Subject: [erlang-questions] Erlang and Maven Message-ID: Hi everyone, I've recently had to use Maven (http://maven.apache.org) for a Java project, and I was quite impressed with how easy it is to create and maintain a project with this tool. Basically, it lets you create an empty project (with separate source and resources directories for main files, test files, web site files, etc.) and test, build, package or deploy it (among many other things, like web site generation). It takes care of your dependencies (updating them when necessary). It also integrates nicely with various IDEs such as Eclipse (it's just a CLI after all), with Subversion/CVS tools, bug trackers, continuous integration tools (like Continuum), etc. Just take a look at the Maven web site for a complete list of features anyway. Most importantly, you can extend it with plugins (written in Java), so I've been toying with the idea of an Erlang plugin, for well... Erlang projects. Things that such a plugin could provide : - "archetype" project creation (creates a typical OTP-like erlang project directory structure and basic files - a way to enforce good pratices in this area ?) - dependencies management (automatic update from a repository, transitive dependencies, etc.) - run the entire test suite (using EUnit) - generate various reports and the project web site (edoc, eunit results, changelogs, etc.) - project compilation - project deployment (beam files are packaged and deployed with scp, ftp or DAV) - dynamic code loading (typical Erlang feature of course. You could load the compiled code on one or more nodes, on your integration or production environment, etc.) - etc ? I wonder if there are other Maven users among us. Anyway feedback and ideas would be greatly appreciated (maybe something like this already exists, or maybe the entire idea is worthless...). And when (if ?) I find some time I'll work on it. Thanks Olivier -------------- next part -------------- An HTML attachment was scrubbed... URL: From yarivvv@REDACTED Fri Sep 8 17:50:31 2006 From: yarivvv@REDACTED (Yariv Sadan) Date: Fri, 8 Sep 2006 11:50:31 -0400 Subject: [erlang-questions] GUI idea In-Reply-To: <95be1d3b0609080815o3cb458a6ge664ecdd9ba622d6@mail.gmail.com> References: <95be1d3b0609080758t74ce6c50xf9a71b345df26d11@mail.gmail.com> <95be1d3b0609080815o3cb458a6ge664ecdd9ba622d6@mail.gmail.com> Message-ID: <17244f480609080850sf5999b4g8d803d6cd45f38ed@mail.gmail.com> FYI, ActionStep, an open source GUI framework for actionscript (Flash) based on NextStep, is being ported to haXe. With the haXe remoting adapter for Yaws, this will open some interesting possibilities for building GUIs for Erlang apps. It won't be pure Erlang, but it's an option. http://actionstep.org/pages/background Regards, Yariv > > In any case, my point was that if there is an engine that generates > dynamically the html & javascript required, then we can solve the gui > problem. And also, since it's going to be in a browser, it will work > remotely by default. > > Kind of an "X server in the browser" or something like that :-) From oscar-erl@REDACTED Fri Sep 8 18:25:53 2006 From: oscar-erl@REDACTED (Oscar =?ISO-8859-1?Q?Hellstr=F6m?=) Date: Fri, 08 Sep 2006 18:25:53 +0200 Subject: [erlang-questions] Reply-TO (was Erlang Book - again) In-Reply-To: References: <19037072-DD48-415D-A282-A51F91D780C6@citeulike.org> <8ed733900608291148l4af1c01ete5799681aa213f4c@mail.gmail.com> <6184444.post@talk.nabble.com> <1157625739.30660.18.camel@battlestar.oscarh.net> Message-ID: <1157732753.24417.6.camel@battlestar.oscarh.net> On Thu, 2006-09-07 at 16:13 +0200, H?kan Huss wrote: > On 9/7/06, Oscar Hellstr?m wrote: > > SIDENOTE: > > Could the Reply-to field be set to the mailing list by the mailing list > > application, this would be very convenient. > > > http://www.unicom.com/pw/reply-to-harmful.html > > Regards, > /H?kan Ok, I could agree with that. I guess it's just that I don't post very often and most other lists I post to use Reply-To-munging. Also, some users of this list seem to change the Reply-To themselves, so hitting Reply seems to work every now and then ;) However, if i hit "Reply to all", will the sender receive two emails, or will mailman be intelligent enough to omit the addresses listed in the To field in the list batch? Regards -- ?Oscar Hellstr?m, oscar@REDACTED web: personal.oscarh.net jid: oscar@REDACTED From ddurham@REDACTED Fri Sep 8 18:52:33 2006 From: ddurham@REDACTED (David Durham) Date: Fri, 08 Sep 2006 11:52:33 -0500 Subject: [erlang-questions] Erlang and Maven In-Reply-To: References: Message-ID: <45019FD1.9080601@vailsys.com> > Things that such a plugin could provide : > - "archetype" project creation (creates a typical OTP-like erlang > project directory structure and basic files - a way to enforce good > pratices in this area ?) > - dependencies management (automatic update from a repository, > transitive dependencies, etc.) > - run the entire test suite (using EUnit) > - generate various reports and the project web site (edoc, eunit > results, changelogs, etc.) > - project compilation > - project deployment (beam files are packaged and deployed with scp, ftp > or DAV) > - dynamic code loading (typical Erlang feature of course. You could load > the compiled code on one or more nodes, on your integration or > production environment, etc.) > - etc ? > > I wonder if there are other Maven users among us. Anyway feedback and > ideas would be greatly appreciated (maybe something like this already > exists, or maybe the entire idea is worthless...). And when (if ?) I > find some time I'll work on it. Have you considered writing a Maven plugin for Erlang? Probably most Erlang developers wouldn't use this, but it could be a nice compliment to Erlide. -Dave From olivier.sambourg@REDACTED Fri Sep 8 19:14:50 2006 From: olivier.sambourg@REDACTED (Olivier Sambourg) Date: Fri, 8 Sep 2006 19:14:50 +0200 Subject: [erlang-questions] Erlang and Maven In-Reply-To: <45019FD1.9080601@vailsys.com> References: <45019FD1.9080601@vailsys.com> Message-ID: <164BE88C-51DE-4001-9296-6C5333A47889@gmail.com> Sorry I've not made myself clear : that's the whole point actually, writing a Maven plugin for Erlang projects (and not reimplementing Maven in Erlang, which in my opinion would be a terrible waste of time) -- Olivier Le 8 sept. 06 ? 18:52, David Durham a ?crit : >> Things that such a plugin could provide : >> - "archetype" project creation (creates a typical OTP-like erlang >> project directory structure and basic files - a way to enforce >> good pratices in this area ?) >> - dependencies management (automatic update from a repository, >> transitive dependencies, etc.) >> - run the entire test suite (using EUnit) >> - generate various reports and the project web site (edoc, eunit >> results, changelogs, etc.) >> - project compilation >> - project deployment (beam files are packaged and deployed with >> scp, ftp or DAV) >> - dynamic code loading (typical Erlang feature of course. You >> could load the compiled code on one or more nodes, on your >> integration or production environment, etc.) >> - etc ? >> I wonder if there are other Maven users among us. Anyway feedback >> and ideas would be greatly appreciated (maybe something like this >> already exists, or maybe the entire idea is worthless...). And >> when (if ?) I find some time I'll work on it. > > Have you considered writing a Maven plugin for Erlang? Probably > most Erlang developers wouldn't use this, but it could be a nice > compliment to Erlide. > > > -Dave From jerome.blondon@REDACTED Fri Sep 8 19:22:03 2006 From: jerome.blondon@REDACTED (=?iso-8859-1?Q?J=E9r=F4me_Blondon?=) Date: Fri, 8 Sep 2006 19:22:03 +0200 Subject: [erlang-questions] Erlang now in the railway industry Message-ID: <20060908172204.D7AB81C000D5@mwinf1913.orange.fr> Congratulations, By the way, i am working on the same field as yours. Since 2005 i am doing lobbying in order to use erlang to manage the Lyons metro (ligne D & CAS (guess what is my company ; ?)) but without success. How did you convinced your hierarchy and your customer ? Cheers, J?r?me Blondon. -----Message d'origine----- De?: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] De la part de BETIS Alexandre Envoy??: vendredi 8 septembre 2006 11:49 ??: Erlang/OTP discussions Objet?: [erlang-questions] Erlang now in the railway industry Hi all, Just a note to let you know that I have completed final delivery (i.e. no more bugs and customer payment in full) of a 100% Erlang app to be deployed in the Lyons metro in France (lines A, B, C). This industrial app is responsible for computing train arrival times for all stations on the line in real time, taking perturbations into account. In a few months, it will be coupled with LCD screens on each platform to display the computed values to passengers. The customer was /very/ surprised with this new software that "never crashed once". I would like to thank everyone on the list for the support. Now repeat after me: "Erlang is > NOT < a telco-only thing!" Cheers, -- Alex Betis " Ce message et ses pieces jointes sont confidentiels et exclusivement reserves a leurs destinataires qui s'assureront de l'absence de virus. CSEE Transport n'assume aucune responsabilite au titre de ce message s'il est altere, deforme, falsifie, indument utilise par des tiers ou encore s'il a cause des dommages ou pertes de toute nature. This e-mail and any attached files are confidential and exclusively intended for its addressees who will conduct appropriate virus checks. CSEE Transport shall not be liable for the message if altered, changed, falsified, unduly used by third parties nor for any damage or loss." _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions From Martin.Logan@REDACTED Fri Sep 8 22:14:12 2006 From: Martin.Logan@REDACTED (Logan, Martin) Date: Fri, 8 Sep 2006 15:14:12 -0500 Subject: [erlang-questions] Erlang now in the railway industry In-Reply-To: Message-ID: <26AB42AB6A76E2419D26E66ECF1538462CF5E3@chiresexc02.resource.corp.lcl> Great idea -----Original Message----- From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Christian S Sent: Friday, September 08, 2006 5:21 AM To: Erlang/OTP discussions Subject: Re: [erlang-questions] Erlang now in the railway industry Thank you very much for sharing this with us! Can we collect erlang success stories somewhere? Or are we already? Suggestion: Trapexit wiki and categorize them as http://wiki.trapexit.org/index.php/Category:Success_Stories On 9/8/06, BETIS Alexandre wrote: > Hi all, > > Just a note to let you know that I have completed > final delivery (i.e. no more bugs and customer > payment in full) of a 100% Erlang app to be deployed > in the Lyons metro in France (lines A, B, C). > > This industrial app is responsible for computing > train arrival times for all stations on the line in > real time, taking perturbations into account. In a few > months, it will be coupled with LCD screens on each > platform to display the computed values to passengers. > The customer was /very/ surprised with this new software > that "never crashed once". > > I would like to thank everyone on the list for the > support. > > Now repeat after me: > > "Erlang > is > > NOT < > a telco-only thing!" > > Cheers, > > -- Alex Betis > > > > " Ce message et ses pieces jointes sont confidentiels et exclusivement reserves a leurs destinataires qui s'assureront de l'absence de virus. CSEE Transport n'assume aucune responsabilite au titre de ce message s'il est altere, deforme, falsifie, indument utilise par des tiers ou encore s'il a cause des dommages ou pertes de toute nature. > > This e-mail and any attached files are confidential and exclusively intended for its addressees who will conduct appropriate virus checks. CSEE Transport shall not be liable for the message if altered, changed, falsified, unduly used by third parties nor for any damage or loss." > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions From vladdu55@REDACTED Fri Sep 8 22:38:45 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Fri, 8 Sep 2006 21:38:45 +0100 Subject: [erlang-questions] GUI idea In-Reply-To: <17244f480609080850sf5999b4g8d803d6cd45f38ed@mail.gmail.com> References: <95be1d3b0609080758t74ce6c50xf9a71b345df26d11@mail.gmail.com> <95be1d3b0609080815o3cb458a6ge664ecdd9ba622d6@mail.gmail.com> <17244f480609080850sf5999b4g8d803d6cd45f38ed@mail.gmail.com> Message-ID: <95be1d3b0609081338q23228445nf35030fca24e902e@mail.gmail.com> Something like ZK (https://sourceforge.net/projects/zk1) looks like close to what I had in mind. Except that it should be just as simple for both client and server side. regards, Vlad From rsaccon@REDACTED Fri Sep 8 23:08:39 2006 From: rsaccon@REDACTED (Roberto Saccon) Date: Fri, 8 Sep 2006 18:08:39 -0300 Subject: [erlang-questions] GUI idea In-Reply-To: <95be1d3b0609081338q23228445nf35030fca24e902e@mail.gmail.com> References: <95be1d3b0609080758t74ce6c50xf9a71b345df26d11@mail.gmail.com> <95be1d3b0609080815o3cb458a6ge664ecdd9ba622d6@mail.gmail.com> <17244f480609080850sf5999b4g8d803d6cd45f38ed@mail.gmail.com> <95be1d3b0609081338q23228445nf35030fca24e902e@mail.gmail.com> Message-ID: Vlad, I do no not get your point. Isn't that just a normal web application ? The approach I am currently experimenting with is http://dojotoolkit.org (they also have widgets, similar to ZK) and JSON-based communication with yaws. regards -- Roberto Saccon From ulf@REDACTED Fri Sep 8 23:42:18 2006 From: ulf@REDACTED (Ulf Wiger) Date: Fri, 08 Sep 2006 23:42:18 +0200 Subject: [erlang-questions] GUI idea In-Reply-To: References: <95be1d3b0609080758t74ce6c50xf9a71b345df26d11@mail.gmail.com> <95be1d3b0609080815o3cb458a6ge664ecdd9ba622d6@mail.gmail.com> <17244f480609080850sf5999b4g8d803d6cd45f38ed@mail.gmail.com> <95be1d3b0609081338q23228445nf35030fca24e902e@mail.gmail.com> Message-ID: Den 2006-09-08 23:08:39 skrev Roberto Saccon : > Vlad, I do no not get your point. Isn't that just a normal web > application ? The approach I am currently experimenting with is > http://dojotoolkit.org (they also have widgets, similar to ZK) and > JSON-based communication with yaws. Nice, but the demos don't look at all good in Opera. :/ BR, Ulf W -- Ulf Wiger From abailly@REDACTED Sat Sep 9 00:41:34 2006 From: abailly@REDACTED (Arnaud Bailly) Date: Sat, 09 Sep 2006 00:41:34 +0200 Subject: [erlang-questions] Erlang and Maven In-Reply-To: (Olivier Sambourg's message of "Fri, 8 Sep 2006 17:43:16 +0200") References: Message-ID: <87bqpqx9pd.fsf@oqube.com> "Olivier Sambourg" writes: > Hi everyone, > > Most importantly, you can extend it with plugins (written in Java), so I've > been toying with the idea of an Erlang plugin, for well... Erlang > projects. That idea is indeed excellent ! I am a dedicated maven user and a novice erlang writer, so I would be more than happy to have such a tool. I have written couple of plugins and artifacts, and even a tutorial on maven. Development of plugins is quite easy if you dont have to delve too deeply in maven's API which is severely underdocumented. > > Things that such a plugin could provide : > - "archetype" project creation (creates a typical OTP-like erlang project > directory structure and basic files - a way to enforce good pratices in this > area ?) Easy to do once a common setup is agreed upon. AFAIK, OTP proposes such a framework with its applications ? > - dependencies management (automatic update from a repository, transitive > dependencies, etc.) Tricky as you need a central repository to work with for common artifacts. Easy for custom ones of course. > - run the entire test suite (using EUnit) > - generate various reports and the project web site (edoc, eunit results, > changelogs, etc.) THat's the real added value of maven > - project compilation > - project deployment (beam files are packaged and deployed with scp, ftp or > DAV) Standard. > - dynamic code loading (typical Erlang feature of course. You could load the > compiled code on one or more nodes, on your integration or production > environment, etc.) Maybe a plugin to (http://cargo.codehaus.org) Cargo ? > - etc ? > > I wonder if there are other Maven users among us. Anyway feedback > and ideas Here they are :-) > would be greatly appreciated (maybe something like this already > exists, or I have been told that some plugins exist for ruby and native code. have a look at codehaus. BTW, an added benefit I can see to this idea is the possibility that it could foster wider adoption of erlang in Java/j2ee environments and more generally in enterprise management systems. I am not a master of erlang but I am already amazed by the ease with which some tasks are done in erlang when compared to java or other similar settings. Of course, concurrency and distribution are known strengths of erlang but even data handling seem easier. May be something could be started ? I am ready for discussion a to throw some time in. regards, -- OQube < software engineering \ g?nie logiciel > Arnaud Bailly, Dr. \web> http://www.oqube.com From vladdu55@REDACTED Sat Sep 9 09:26:14 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Sat, 9 Sep 2006 08:26:14 +0100 Subject: [erlang-questions] GUI idea In-Reply-To: References: <95be1d3b0609080758t74ce6c50xf9a71b345df26d11@mail.gmail.com> <95be1d3b0609080815o3cb458a6ge664ecdd9ba622d6@mail.gmail.com> <17244f480609080850sf5999b4g8d803d6cd45f38ed@mail.gmail.com> <95be1d3b0609081338q23228445nf35030fca24e902e@mail.gmail.com> Message-ID: <95be1d3b0609090026l70b0798n95db18df4a9301aa@mail.gmail.com> On 9/8/06, Roberto Saccon wrote: > Vlad, I do no not get your point. Isn't that just a normal web > application ? The approach I am currently experimenting with is > http://dojotoolkit.org (they also have widgets, similar to ZK) and > JSON-based communication with yaws. Hi, Well, I didn't mean to imply it was a revolutuinary, never-before thought-of approach :-) What is a little new (at least to me) is that this web application would be built from the Erlang side using regular GUI commands (the example being the current gs interface). This way an Erlang application would not be aware it was in fact web-ified and it would probably look better then with the standard TclTk backend. regards, Vlad From vladdu55@REDACTED Sat Sep 9 09:27:59 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Sat, 9 Sep 2006 08:27:59 +0100 Subject: [erlang-questions] GUI idea In-Reply-To: References: <95be1d3b0609080758t74ce6c50xf9a71b345df26d11@mail.gmail.com> <95be1d3b0609080815o3cb458a6ge664ecdd9ba622d6@mail.gmail.com> <17244f480609080850sf5999b4g8d803d6cd45f38ed@mail.gmail.com> <95be1d3b0609081338q23228445nf35030fca24e902e@mail.gmail.com> Message-ID: <95be1d3b0609090027r472347a6g56aea8f68b0117f8@mail.gmail.com> On 9/8/06, Roberto Saccon wrote: > The approach I am currently experimenting with is > http://dojotoolkit.org (they also have widgets, similar to ZK) and > JSON-based communication with yaws. There's plenty of toolkits and frameworks. ZK is one of the few that don't require JavaScript programming, which I find interesting. /Vlad From claus.reinke@REDACTED Sat Sep 9 13:14:41 2006 From: claus.reinke@REDACTED (Claus Reinke) Date: Sat, 9 Sep 2006 12:14:41 +0100 Subject: [erlang-questions] GUI idea References: <95be1d3b0609080758t74ce6c50xf9a71b345df26d11@mail.gmail.com><95be1d3b0609080815o3cb458a6ge664ecdd9ba622d6@mail.gmail.com><17244f480609080850sf5999b4g8d803d6cd45f38ed@mail.gmail.com><95be1d3b0609081338q23228445nf35030fca24e902e@mail.gmail.com> Message-ID: > Isn't that just a normal web application ? yes, and no:-) it's a single-server-single-client-intraweb app. you can see and develop it as a normal web application, with the only unusual feature being that the client deploys the server code as well. but if you just see the browser as a potential portable GUI lib maintained by others, you might be able to avoid some of the nonfun of web applications: 1 you only need one browser that supports your code 2 you are free to use ridiculously tight interactions between browser and application, without having to worry about scaling up to many clients or slow networks by 1, I don't mean to suggest programming to specific browsers. but, if you're programming to standards, you'll find yourself limited to the browsers that support them. for instance, SVG (Scalable Vector Graphics) is supported fairly well in Opera, slightly less well in FireFox, and depends on Adobe's plugin (soon to be discontinued, as it seems) in IE. if you were doing a web application, you'd be stuck here already, not to mention other browsers in use, but if you're doing a local application that just happens to use a browser as a GUI, you can focus on programming to the SVG standard and suggest your clients install a browser that support that, since at least one exists. 2 is a matter of taste, perhaps. and it may be tempting to keep the interaction loop not quite as tight, so that you have a chance to scale up later, or to control your Erlang app from the browser on your phone someday.. btw, wouldn't a cooperation between Ericsson (Erlang apps) and Opera (browser GUIs) be very Scandinavian (please remember to send me an appropriate bonus if these companies decide to make good use of this suggestion;-)? cheers, claus ps. it is tempting to program to browsers, especially as many of them support their own widgets/standalone app extras. From dmitriid@REDACTED Sat Sep 9 15:01:16 2006 From: dmitriid@REDACTED (Dmitrii Dimandt) Date: Sat, 9 Sep 2006 16:01:16 +0300 Subject: [erlang-questions] GUI idea In-Reply-To: <95be1d3b0609090026l70b0798n95db18df4a9301aa@mail.gmail.com> References: <95be1d3b0609080758t74ce6c50xf9a71b345df26d11@mail.gmail.com> <95be1d3b0609080815o3cb458a6ge664ecdd9ba622d6@mail.gmail.com> <17244f480609080850sf5999b4g8d803d6cd45f38ed@mail.gmail.com> <95be1d3b0609081338q23228445nf35030fca24e902e@mail.gmail.com> <95be1d3b0609090026l70b0798n95db18df4a9301aa@mail.gmail.com> Message-ID: On 9/9/06, Vlad Dumitrescu wrote: > > On 9/8/06, Roberto Saccon wrote: > > Vlad, I do no not get your point. Isn't that just a normal web > > application ? The approach I am currently experimenting with is > > http://dojotoolkit.org (they also have widgets, similar to ZK) and > > JSON-based communication with yaws. > > Hi, > > Well, I didn't mean to imply it was a revolutuinary, never-before > thought-of approach :-) Why not? ;-) -------------- next part -------------- An HTML attachment was scrubbed... URL: From vladdu55@REDACTED Sat Sep 9 15:18:55 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Sat, 9 Sep 2006 14:18:55 +0100 Subject: [erlang-questions] GUI idea In-Reply-To: References: <95be1d3b0609080758t74ce6c50xf9a71b345df26d11@mail.gmail.com> <95be1d3b0609080815o3cb458a6ge664ecdd9ba622d6@mail.gmail.com> <17244f480609080850sf5999b4g8d803d6cd45f38ed@mail.gmail.com> <95be1d3b0609081338q23228445nf35030fca24e902e@mail.gmail.com> <95be1d3b0609090026l70b0798n95db18df4a9301aa@mail.gmail.com> Message-ID: <95be1d3b0609090618q4b9a0454u951a7f74ae4fdc49@mail.gmail.com> On 9/9/06, Dmitrii Dimandt wrote: > > Well, I didn't mean to imply it was a revolutuinary, never-before > > thought-of approach :-) > > Why not? ;-) Because I just had got the idea and didn't have time to check if something similar already exists. Experience says that it's very difficult to come up with an entirely new idea :-) /Vlad From wilbjor@REDACTED Sat Sep 9 16:40:56 2006 From: wilbjor@REDACTED (Jordan Wilberding) Date: Sat, 09 Sep 2006 09:40:56 -0500 Subject: [erlang-questions] Securing link between nodes In-Reply-To: References: <4500B262.6080507@iit.edu> Message-ID: <4502D278.1050008@iit.edu> Chandru wrote: > On 08/09/06, *Jordan Wilberding* > wrote: > > Hello, > > I know this question has been asked before, but I have a few more > questions about it. > > I am wanting to encrypt all communications between each node > transparently(that is to say, without the erlang code knowing anything > about it). It appears the best you can do now is use SSL for > authentication, but it still doesn't encrypt the actual messages. > > > I have never tried it, but if you configured erlang distribution over > SSL, all communication between the nodes should be encrypted. Not just > authentication. > > See > http://www.erlang.org/doc/doc-5.5/lib/ssl-3.0.12/doc/html/ssl_distribution.html#5 > > Chandru Actually I did this method and it doesn't encrypt all information, as I am able to pick up the text of messages with tcpdump. Thanks! Jordan Wilberding From wilbjor@REDACTED Sat Sep 9 16:42:05 2006 From: wilbjor@REDACTED (Jordan Wilberding) Date: Sat, 09 Sep 2006 09:42:05 -0500 Subject: [erlang-questions] Securing link between nodes In-Reply-To: <4501297D.3070300@hyber.org> References: <4500B262.6080507@iit.edu> <4501297D.3070300@hyber.org> Message-ID: <4502D2BD.8060404@iit.edu> Claes Wikstrom wrote: > Jordan Wilberding wrote: >> Hello, >> >> I know this question has been asked before, but I have a few more >> questions about it. >> >> I am wanting to encrypt all communications between each node >> transparently(that is to say, without the erlang code knowing anything >> about it). > > setup an IPSEC tunnel between the two machines. > > /klacke > That is a nice idea, which would be great if this was a closed system, but I am hoping to use this for an IRC-like clone I wrote; therefore, it would be nice to have something that users could do with minimal fuss. Thanks! Jordan Wilberding From jay@REDACTED Sat Sep 9 18:08:02 2006 From: jay@REDACTED (jay) Date: Sat, 09 Sep 2006 17:08:02 +0100 Subject: [erlang-questions] Reading heavily trafficked threaded maillists References: Message-ID: <20060909160802.302D35A1E5@mail.erlangsystems.com> Joe was concerned about the list growing too fast. Here are some tips for reading a large threaded maillist: http://www.kitenet.net/~joey/blog/entry/thread_patterns.html jay _________________________________________________________ Post sent from http://www.trapexit.org From fbg111@REDACTED Sat Sep 9 19:53:42 2006 From: fbg111@REDACTED (fbg111) Date: Sat, 9 Sep 2006 10:53:42 -0700 (PDT) Subject: [erlang-questions] Reading heavily trafficked threaded maillists In-Reply-To: <20060909160802.302D35A1E5@mail.erlangsystems.com> References: <20060909160802.302D35A1E5@mail.erlangsystems.com> Message-ID: <6226282.post@talk.nabble.com> Cool, and here's another option: http://www.nabble.com/Erlang-f14095.html http://www.nabble.com/Erlang-f14095.html Byron -- View this message in context: http://www.nabble.com/-erlang-questions--Reading-heavily-trafficked-threaded-maillists-tf2244546.html#a6226282 Sent from the Erlang Questions forum at Nabble.com. From fbg111@REDACTED Sat Sep 9 19:56:15 2006 From: fbg111@REDACTED (fbg111) Date: Sat, 9 Sep 2006 10:56:15 -0700 (PDT) Subject: [erlang-questions] Reading heavily trafficked threaded maillists In-Reply-To: <6226282.post@talk.nabble.com> References: <20060909160802.302D35A1E5@mail.erlangsystems.com> <6226282.post@talk.nabble.com> Message-ID: <6226305.post@talk.nabble.com> PS - unsubscribe from erlang-questions@REDACTED, then subscribe to erlang-questions-poster@REDACTED This allows you to post to the mailing list without receiving the daily traffic in your inbox. Use Nabble to manage alerts to specific threads instead. fbg111 wrote: > > Cool, and here's another option: > > http://www.nabble.com/Erlang-f14095.html > http://www.nabble.com/Erlang-f14095.html > > Byron > -- View this message in context: http://www.nabble.com/-erlang-questions--Reading-heavily-trafficked-threaded-maillists-tf2244546.html#a6226305 Sent from the Erlang Questions forum at Nabble.com. From per@REDACTED Sat Sep 9 21:25:00 2006 From: per@REDACTED (Per Hedeland) Date: Sat, 9 Sep 2006 21:25:00 +0200 (CEST) Subject: [erlang-questions] Securing link between nodes In-Reply-To: <4502D278.1050008@iit.edu> Message-ID: <200609091925.k89JP03r053966@pluto.hedeland.org> Jordan Wilberding wrote: > >Chandru wrote: >> On 08/09/06, *Jordan Wilberding* > > wrote: >> >> Hello, >> >> I know this question has been asked before, but I have a few more >> questions about it. >> >> I am wanting to encrypt all communications between each node >> transparently(that is to say, without the erlang code knowing anything >> about it). It appears the best you can do now is use SSL for >> authentication, but it still doesn't encrypt the actual messages. >> >> >> I have never tried it, but if you configured erlang distribution over >> SSL, all communication between the nodes should be encrypted. Not just >> authentication. >> >> See >> http://www.erlang.org/doc/doc-5.5/lib/ssl-3.0.12/doc/html/ssl_distribution.html#5 >> >> Chandru > >Actually I did this method and it doesn't encrypt all information, as I >am able to pick up the text of messages with tcpdump. Well, you probably did something wrong (or the SSL stuff is broken - I haven't tried it either) - SSL certainly offers transport encryption. While it's possible to have it use a NULL cipher for the transport, you'd really have to go out of your way to make that happen (e.g. I don't believe this possibility is enabled in a default OpenSSL build). Using SSL just for authentication in the context of distributed Erlang would be pretty pointless, as the default authentication mechanism is quite good (given a "good" cookie and safeguarding it as you would e.g. a SSL private key) - the cookie is never sent on the wire. --Per Hedeland From ml.cyresse@REDACTED Sun Sep 10 13:15:28 2006 From: ml.cyresse@REDACTED (Liam Clarke) Date: Sun, 10 Sep 2006 23:15:28 +1200 Subject: [erlang-questions] Good to know? Message-ID: Hi all, Forgive a very noobish question, but I ask because I am very new indeed to Erlang. Quite simply, what are the little tricks that are good to know but not immediately documented? I'm working on a Windows XP box so don't have the man pages available - I'm working off a combination of the manual, die.net's man pages and google. For an example, I only just found this - http://manpages.debian.net/cgi-bin/display_man.cgi?id=549920fb82936a3c20620f6376876bb9&format=plain the c module. Knowing how to change the working directory is immensely useful, but wasn't immediately obvious in the sources I had. So, if you can think of anything along the lines of "good to know but not apparent as such to a newbie" - please do fill me in. Much thanks, Liam Clarke From wilbjor@REDACTED Sun Sep 10 15:49:16 2006 From: wilbjor@REDACTED (Jordan Wilberding) Date: Sun, 10 Sep 2006 08:49:16 -0500 Subject: [erlang-questions] Securing link between nodes In-Reply-To: <200609091925.k89JP03r053966@pluto.hedeland.org> References: <200609091925.k89JP03r053966@pluto.hedeland.org> Message-ID: <450417DC.60808@iit.edu> Well I traced down my error for thinking I was using SSL, but actually wasn't anyways. I have come across an error now. When I do: erl -boot start_ssl -proto_dist inet_ssl Everything works just fine, but when I try setting a game with: erl -boot start_ssl -proto_dist inet_ssl -sname ssl_test Everything goes crazy with this error message: {error_logger,{{2006,9,10},{8,43,50}},'Protocol: ~p: register/listen error: ~p~n ',[inet_ssl,{'EXIT',{normal,{gen_server,call,[ssl_server_prim,{listen,<0.20.0>,{ 0,0,0,0},0,[],5},infinity]}}}]} {error_logger,{{2006,9,10},{8,43,50}},crash_report,[[{pid,<0.20.0>},{registered_ name,net_kernel},{error_info,{error,badarg}},{initial_call,{gen,init_it,[gen_ser ver,<0.16.0>,<0.16.0>,{local,net_kernel},net_kernel,{ssl_test,shortnames,15000}, []]}},{ancestors,[net_sup,kernel_sup,<0.8.0>]},{messages,[]},{links,[<0.16.0>]}, {dictionary,[{longnames,false}]},{trap_exit,true},{status,running},{heap_size,37 7},{stack_size,21},{reductions,295}],[]]} {error_logger,{{2006,9,10},{8,43,50}},supervisor_report,[{supervisor,{local,net_ sup}},{errorContext,start_error},{reason,{'EXIT',nodistribution}},{offender,[{pi d,undefined},{name,net_kernel},{mfa,{net_kernel,start_link,[[ssl_test,shortnames ]]}},{restart_type,permanent},{shutdown,2000},{child_type,worker}]}]} {error_logger,{{2006,9,10},{8,43,50}},supervisor_report,[{supervisor,{local,net_ sup}},{errorContext,shutdown_error},{reason,normal},{offender,[{pid,<0.17.0>},{n ame,ssl_server_prim},{mfa,{ssl_server,start_link_prim,[]}},{restart_type,permane nt},{shutdown,2000},{child_type,worker}]}]} {error_logger,{{2006,9,10},{8,43,50}},supervisor_report,[{supervisor,{local,kern el_sup}},{errorContext,start_error},{reason,shutdown},{offender,[{pid,undefined} ,{name,net_sup},{mfa,{erl_distribution,start_link,[]}},{restart_type,permanent}, {shutdown,infinity},{child_type,supervisor}]}]} {error_logger,{{2006,9,10},{8,43,50}},crash_report,[[{pid,<0.7.0>},{registered_n ame,[]},{error_info,{shutdown,{kernel,start,[normal,[]]}}},{initial_call,{applic ation_master,init,[<0.5.0>,<0.6.0>,{appl_data,kernel,[application_controller,erl _reply,auth,boot_server,code_server,disk_log_server,disk_log_sup,erl_prim_loader ,error_logger,file_server,file_server_2,fixtable_server,global_group,global_name _server,heart,init,kernel_config,kernel_sup,net_kernel,net_sup,rex,user,os_serve r,ddll_server,erl_epmd,inet_db,pg2],undefined,{kernel,[]},[application,applicati on_controller,application_master,application_starter,auth,code,code_aux,packages ,code_server,dist_util,erl_boot_server,erl_distribution,erl_prim_loader,erl_repl y,erlang,error_handler,error_logger,file,file_server,old_file_server,file_io_ser ver,prim_file,global,global_group,global_search,group,heart,hipe_unified_loader, hipe_sparc_loader,hipe_ppc_loader,hipe_ppc64_loader,hipe_x86_loader,hipe_amd64_l oader,inet6_tcp,inet6_tcp_dist,inet6_udp,inet_config,inet_hosts,inet_gethost_nat ive,inet_tcp_dist,init,kernel,kernel_config,net,net_adm,net_kernel,os,ram_file,r pc,user,user_drv,user_sup,disk_log,disk_log_1,disk_log_server,disk_log_sup,dist_ ac,erl_ddll,erl_epmd,erts_debug,gen_tcp,gen_udp,prim_inet,inet,inet_db,inet_dns, inet_parse,inet_res,inet_tcp,inet_udp,pg2,seq_trace,wrap_log_reader,zlib,otp_rin g0],[],infinity,infinity},normal]}},{ancestors,[<0.6.0>]},{messages,[{'EXIT',<0. 8.0>,normal}]},{links,[<0.6.0>,<0.5.0>]},{dictionary,[]},{trap_exit,true},{statu s,running},{heap_size,987},{stack_size,21},{reductions,1041}],[]]} {error_logger,{{2006,9,10},{8,43,50}},std_info,[{application,kernel},{exited,{sh utdown,{kernel,start,[normal,[]]}}},{type,permanent}]} {"Kernel pid terminated",application_controller,shutdown} Thanks! Jordan Wilberding From olivier.sambourg@REDACTED Sun Sep 10 16:00:55 2006 From: olivier.sambourg@REDACTED (Olivier Sambourg) Date: Sun, 10 Sep 2006 16:00:55 +0200 Subject: [erlang-questions] Erlang and Maven In-Reply-To: <87bqpqx9pd.fsf@oqube.com> References: <87bqpqx9pd.fsf@oqube.com> Message-ID: 2006/9/9, Arnaud Bailly : > > "Olivier Sambourg" writes: > > > Hi everyone, > > > > Most importantly, you can extend it with plugins (written in Java), so > I've > > been toying with the idea of an Erlang plugin, for well... Erlang > > projects. > > That idea is indeed excellent ! I am a dedicated maven user and a novice > erlang writer, so I would be more than happy to have such a tool. I > have written couple of plugins and artifacts, and even a tutorial on > maven. Development of plugins is quite easy if you dont have to delve > too deeply in maven's API which is severely underdocumented. I believe (and hope) such delving will not be necessary (maven's documentation does not necessarily lack, but is seldom easy to find) > > > Things that such a plugin could provide : > > - "archetype" project creation (creates a typical OTP-like erlang > project > > directory structure and basic files - a way to enforce good pratices in > this > > area ?) > > Easy to do once a common setup is agreed upon. AFAIK, OTP proposes > such a framework with its applications ? If we take a look at various OTP applications, the common directory structure seems to be : application/ |-> src/ (source files, flat) |-> include/ (include files...) |-> doc/ (documentation) |-> ebin/ (beam files) I don't know wheter to keep this structure intact (just adding a pom.xmlfile in the base directory, and directories for test files and website generation), or to have a more "mavenish" setup, such as : application/ |-> pom.xml (maven project descriptor) |-> src/ |-> main/ |-> erlang/ (erlang source files) |-> c/ (C code for ports, etc.) |-> include/ |-> test/ |-> erlang/ (erlang test files) |-> c/ (C test files) |-> site/ |-> site.xml (maven site descriptor) |-> etc. |-> target/ |-> ebin/ |-> test-ebin/ This last structure ***could*** be useful in a multi-language project, and has various other advantages from a maven point of view. And of course the application can be deployed using the standard OTP structure. Bottom line : I don't know what to choose :) > - dependencies management (automatic update from a repository, transitive > > dependencies, etc.) > > Tricky as you need a central repository to work with for common > artifacts. Easy for custom ones of course. I agree, though integration with REPOS should be possible and greatly ease things up. > - run the entire test suite (using EUnit) > > - generate various reports and the project web site (edoc, eunit > results, > > changelogs, etc.) > > THat's the real added value of maven > > > - project compilation > > - project deployment (beam files are packaged and deployed with scp, ftp > or > > DAV) > > Standard. > > > - dynamic code loading (typical Erlang feature of course. You could load > the > > compiled code on one or more nodes, on your integration or production > > environment, etc.) > > Maybe a plugin to ( http://cargo.codehaus.org) Cargo ? I was thinking more in the lines of an already running integration or production node, but Cargo seems to be a good idea, though. Of course, dynamic code loading would only work with applications which respect the OTP design guidelines (using supervisors and workers). > - etc ? > > > > I wonder if there are other Maven users among us. Anyway feedback > > and ideas > > Here they are :-) > > > would be greatly appreciated (maybe something like this already > > exists, or > > I have been told that some plugins exist for ruby and native > code. have a look at codehaus. Codehaus is indeed a good place to look at exemples :) Thanks. BTW, an added benefit I can see to this idea is the possibility that > it could foster wider adoption of erlang in Java/j2ee environments and > more generally in enterprise management systems. I am not a master of > erlang but I am already amazed by the ease with which some tasks are > done in erlang when compared to java or other similar settings. Of > course, concurrency and distribution are known strengths of erlang but > even data handling seem easier. > > May be something could be started ? I am ready for discussion a to > throw some time in. > > regards, > -- > OQube < software engineering \ g?nie logiciel > > Arnaud Bailly, Dr. > \web> http://www.oqube.com > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From wilbjor@REDACTED Sun Sep 10 18:53:37 2006 From: wilbjor@REDACTED (Jordan Wilberding) Date: Sun, 10 Sep 2006 11:53:37 -0500 Subject: [erlang-questions] Securing link between nodes In-Reply-To: <450417DC.60808@iit.edu> References: <200609091925.k89JP03r053966@pluto.hedeland.org> <450417DC.60808@iit.edu> Message-ID: <45044311.5040604@iit.edu> Jordan Wilberding wrote: > I have come across an error now. When I do: > > erl -boot start_ssl -proto_dist inet_ssl > > Everything works just fine, but when I try setting a game with: > > erl -boot start_ssl -proto_dist inet_ssl -sname ssl_test > > Everything goes crazy with this error message: Digging a little further, I have found I still get the error, even when I just do: the following: $ erl -boot start_ssl -name test {error_logger,{{2006,9,10},{11,52,20}},"Protocol: ~p: not supported~n",["blah"]} Is there a reason the protocol is not supported? Did I maybe miss a build option? Thanks! Jordan Wilberding From robert.virding@REDACTED Mon Sep 11 00:42:36 2006 From: robert.virding@REDACTED (Robert Virding) Date: Mon, 11 Sep 2006 00:42:36 +0200 Subject: [erlang-questions] Regular expressons again, an improved regexp module Message-ID: <450494DC.8030108@telia.com> After the discussions earlier on about the speed, or lack of, of the regexp module I have added a regular expression compiler. There is a new function regexp:compile(RegExp) which takes a regulare expression parses and compiles it and returns it in a form which can be used instead of regular expressions in all the matching functions. In the same way that the return from regexp:parse can. The new module is a drop-in replacement to the old with the exception of the new function. One caveat it is not yet possible to compile anchored expressions. I would appreciate it if someone could do some serious testing and see if there is a significant improvement with real regexps. I have just tested that it works. Another question is what people would like to apply the regexps on, lists or binaries? The module now works on lists but it would not be difficult to make it work on binaries as well. Robert -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: regexp.erl URL: From joelr1@REDACTED Mon Sep 11 02:14:26 2006 From: joelr1@REDACTED (Joel Reymont) Date: Mon, 11 Sep 2006 01:14:26 +0100 Subject: [erlang-questions] Regular expressons again, an improved regexp module In-Reply-To: <450494DC.8030108@telia.com> References: <450494DC.8030108@telia.com> Message-ID: On Sep 10, 2006, at 11:42 PM, Robert Virding wrote: > I would appreciate it if someone could do some serious testing and > see if there is a significant improvement with real regexps. I have > just tested that it works. I see myself doing a lot of "screen scraping" of web sites and regexps is what I use for this in Ruby. > Another question is what people would like to apply the regexps on, > lists or binaries? The module now works on lists but it would not > be difficult to make it work on binaries as well. Binaries would be swell. No need to convert to list unless absolutely necessary. Thanks, Joel -- http://wagerlabs.com/ From rlenglet@REDACTED Mon Sep 11 05:10:46 2006 From: rlenglet@REDACTED (Romain Lenglet) Date: Mon, 11 Sep 2006 12:10:46 +0900 Subject: [erlang-questions] Good to know? In-Reply-To: References: Message-ID: <200609111210.46472.rlenglet@users.forge.objectweb.org> Liam Clarke wrote: > Hi all, > > Forgive a very noobish question, but I ask because I am very > new indeed to Erlang. > Quite simply, what are the little tricks that are good to know > but not immediately documented? > > I'm working on a Windows XP box so don't have the man pages > available - I'm working off a combination of the manual, > die.net's man pages and google. [...] You can use GNU Emacs' "woman" command to read man pages on any platform. -- Romain LENGLET From ml.cyresse@REDACTED Mon Sep 11 05:45:58 2006 From: ml.cyresse@REDACTED (Liam Clarke) Date: Mon, 11 Sep 2006 15:45:58 +1200 Subject: [erlang-questions] Good to know? In-Reply-To: <200609111210.46472.rlenglet@users.forge.objectweb.org> References: <200609111210.46472.rlenglet@users.forge.objectweb.org> Message-ID: Ah, that is very good to know indeed. :) Might have to invest some time in learning Emacs. Regards, Liam Clarke On 9/11/06, Romain Lenglet wrote: > Liam Clarke wrote: > > Hi all, > > > > Forgive a very noobish question, but I ask because I am very > > new indeed to Erlang. > > Quite simply, what are the little tricks that are good to know > > but not immediately documented? > > > > I'm working on a Windows XP box so don't have the man pages > > available - I'm working off a combination of the manual, > > die.net's man pages and google. > [...] > > You can use GNU Emacs' "woman" command to read man pages on any > platform. > > -- > Romain LENGLET > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From ke.han@REDACTED Mon Sep 11 07:31:10 2006 From: ke.han@REDACTED (ke han) Date: Mon, 11 Sep 2006 13:31:10 +0800 Subject: [erlang-questions] Good to know? In-Reply-To: References: Message-ID: <6E5E5E8B-75D2-49A0-8B62-1FCAB02B0AFC@redstarling.com> Liam, erlang's man pages use erlang...so you type something like: erl -man erlc But this doesn't work on windows ;-( The erlang collection of erlang docs available in html and pdf form are very good. The installed docs collection for erlang Windows is well organized...go through the getting started areas first. If you are tripping over yourself trying to use the erlang shell under windows for the edit, compile, load cycle, you may want to try erlide.sourceforg.net. An experienced erlang-er may prefer the shell for these things, but like any CLI interface it takes time to learn all the tricks. have fun, ke han On Sep 10, 2006, at 7:15 PM, Liam Clarke wrote: > Hi all, > > Forgive a very noobish question, but I ask because I am very new > indeed to Erlang. > Quite simply, what are the little tricks that are good to know but not > immediately documented? > > I'm working on a Windows XP box so don't have the man pages available > - I'm working off a combination of the manual, die.net's man pages and > google. > > For an example, I only just found this - > http://manpages.debian.net/cgi-bin/display_man.cgi? > id=549920fb82936a3c20620f6376876bb9&format=plain > the c module. > > Knowing how to change the working directory is immensely useful, but > wasn't immediately obvious in the sources I had. So, if you can think > of anything along the lines of "good to know but not apparent as such > to a newbie" - please do fill me in. > > > Much thanks, > > Liam Clarke > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From ayrnieu@REDACTED Mon Sep 11 07:36:22 2006 From: ayrnieu@REDACTED (Julian Fondren) Date: Mon, 11 Sep 2006 00:36:22 -0500 Subject: [erlang-questions] will Erlang ever have currying? In-Reply-To: <95be1d3b0609080515s60007b12gfb022002158af0a0@mail.gmail.com> References: <17244f480609051553i1ba9c08ck3ab38cce1f969802@mail.gmail.com> <6a36e7290609051853l43955c96h95f145544bd1e09f@mail.gmail.com> <95be1d3b0609062351q290e8ac4mbc6767e206339ca6@mail.gmail.com> <95be1d3b0609080515s60007b12gfb022002158af0a0@mail.gmail.com> Message-ID: On 9/8/06, Vlad Dumitrescu wrote: > On 9/7/06, Vlad Dumitrescu wrote: > > some_fun(X, _, 3, _) > > > > would be syntactic sugar for > > > > fun(XX, YY) -> some_fun(X, XX, 3, YY) end > > If anyone really wants to use this today, please go to > http://forum.trapexit.org/viewtopic.php?p=21183, where I submitted a > parse_transform that will let you use the above right away. Neat! I'll definitely try that. I'd always taken it for granted that Erlang can't possibly have 'natural' currying in the sense of Haskell, due to the pairwise-incompatibles: automatic currying | n-ary functions | functions-named-by-arity , but this is a really comfortable syntax for explict currying in Erlang. From richardc@REDACTED Mon Sep 11 07:58:04 2006 From: richardc@REDACTED (Richard Carlsson) Date: Mon, 11 Sep 2006 07:58:04 +0200 Subject: [erlang-questions] 2D Map Arrays In-Reply-To: <20060907195438.53546.qmail@web31605.mail.mud.yahoo.com> References: <20060907195438.53546.qmail@web31605.mail.mud.yahoo.com> Message-ID: <4504FAEC.4070800@it.uu.se> Jeff Crane wrote: > What do I do when I want to operate on a similarly > sized dynamic layer that I want to read/write to? A while ago, Dan Gudmundsson posted an array datatype implementation to the list. Since then, I and Dan have been rewriting it with the intention of eventually making it a standard library component. Here is a preview; the interface should be pretty stable now: http://user.it.uu.se/~richardc/array/ It still uses a tree structure, but since it uses indices from 0 to N instead of arbitrary keys, it can be quite a lot more efficient in both time and space than gb_trees or dicts. /Richard PS. I tried to post this to the list with the code as an attachment just before the weekend, but apparently, it was eaten by a grue. -- "Having users is like optimization: the wise course is to delay it." -- Paul Graham From raimo+erlang-questions@REDACTED Mon Sep 11 09:08:54 2006 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Mon, 11 Sep 2006 09:08:54 +0200 Subject: [erlang-questions] : Reading heavily trafficked threaded maillists In-Reply-To: <6226305.post@talk.nabble.com> References: <20060909160802.302D35A1E5@mail.erlangsystems.com> <6226282.post@talk.nabble.com> <6226305.post@talk.nabble.com> Message-ID: <20060911070854.GA26779@erix.ericsson.se> On Sat, Sep 09, 2006 at 10:56:15AM -0700, fbg111 wrote: > > PS - unsubscribe from erlang-questions@REDACTED, then subscribe to > erlang-questions-poster@REDACTED This allows you to post to the mailing > list without receiving the daily traffic in your inbox. Use Nabble to > manage alerts to specific threads instead. > That was an old truth. Nowadays you use the web interface at http://www.erlang.org/mailman/listinfo/erlang-questions, click on "Unsubscribe or edit options". Fill in your e-mail address and password, and when you finally reach your personal options page, select "Mail delivery" -> Disabled. > > fbg111 wrote: > > > > Cool, and here's another option: > > > > http://www.nabble.com/Erlang-f14095.html > > http://www.nabble.com/Erlang-f14095.html > > > > Byron > > > > -- > View this message in context: http://www.nabble.com/-erlang-questions--Reading-heavily-trafficked-threaded-maillists-tf2244546.html#a6226305 > Sent from the Erlang Questions forum at Nabble.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 Mon Sep 11 09:16:10 2006 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Mon, 11 Sep 2006 09:16:10 +0200 Subject: [erlang-questions] : Reply-TO (was Erlang Book - again) In-Reply-To: <1157732753.24417.6.camel@battlestar.oscarh.net> References: <19037072-DD48-415D-A282-A51F91D780C6@citeulike.org> <8ed733900608291148l4af1c01ete5799681aa213f4c@mail.gmail.com> <6184444.post@talk.nabble.com> <1157625739.30660.18.camel@battlestar.oscarh.net> <1157732753.24417.6.camel@battlestar.oscarh.net> Message-ID: <20060911071610.GB26779@erix.ericsson.se> Well, this is a default option customizable by every member: Avoid duplicate copies of messages? When you are listed explicitly in the To: or Cc: headers of a list message, you can opt to not receive another copy from the mailing list. Select Yes to avoid receiving copies from the mailing list; select No to receive copies. and Yes is the default, so it appears to be intelligent enough. On Fri, Sep 08, 2006 at 06:25:53PM +0200, Oscar Hellstr?m wrote: > On Thu, 2006-09-07 at 16:13 +0200, H?kan Huss wrote: > > On 9/7/06, Oscar Hellstr?m wrote: > > > SIDENOTE: > > > Could the Reply-to field be set to the mailing list by the mailing list > > > application, this would be very convenient. > > > > > http://www.unicom.com/pw/reply-to-harmful.html > > > > Regards, > > /H?kan > > Ok, I could agree with that. I guess it's just that I don't post very > often and most other lists I post to use Reply-To-munging. Also, some > users of this list seem to change the Reply-To themselves, so hitting > Reply seems to work every now and then ;) > > However, if i hit "Reply to all", will the sender receive two emails, or > will mailman be intelligent enough to omit the addresses listed in the > To field in the list batch? > > Regards > -- > ?Oscar Hellstr?m, oscar@REDACTED > web: personal.oscarh.net > jid: oscar@REDACTED > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From chandrashekhar.mullaparthi@REDACTED Mon Sep 11 09:23:13 2006 From: chandrashekhar.mullaparthi@REDACTED (Chandru) Date: Mon, 11 Sep 2006 08:23:13 +0100 Subject: [erlang-questions] Erlang and Maven In-Reply-To: References: <87bqpqx9pd.fsf@oqube.com> Message-ID: On 10/09/06, Olivier Sambourg wrote: > > If we take a look at various OTP applications, the common directory > structure seems to be : > > application/ > |-> src/ (source files, flat) > |-> include/ (include files...) > |-> doc/ (documentation) > |-> ebin/ (beam files) > > I don't know wheter to keep this structure intact (just adding a pom.xmlfile in the base directory, and directories for test files and website > generation), or to have a more "mavenish" setup, such as : > application/ > |-> pom.xml (maven project descriptor) > |-> src/ > |-> main/ > |-> erlang/ (erlang source files) > |-> c/ (C code for ports, etc.) > |-> include/ > |-> test/ > |-> erlang/ (erlang test files) > |-> c/ (C test files) > |-> site/ > |-> site.xml (maven site descriptor) > |-> etc. > |-> target/ > |-> ebin/ > |-> test-ebin/ > > This last structure ***could*** be useful in a multi-language project, and > has various other advantages from a maven point of view. And of course the > application can be deployed using the standard OTP structure. > Bottom line : I don't know what to choose :) > I don't know anything about Maven, but maybe you can use the OTP structure for your system installation and the "mavenish" structure for your code repository? cheers Chandru -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf@REDACTED Mon Sep 11 09:38:00 2006 From: ulf@REDACTED (Ulf Wiger) Date: Mon, 11 Sep 2006 09:38:00 +0200 Subject: [erlang-questions] 2D Map Arrays In-Reply-To: <4504FAEC.4070800@it.uu.se> References: <20060907195438.53546.qmail@web31605.mail.mud.yahoo.com> <4504FAEC.4070800@it.uu.se> Message-ID: Den 2006-09-11 07:58:04 skrev Richard Carlsson : > A while ago, Dan Gudmundsson posted an array datatype implementation > to the list. Since then, I and Dan have been rewriting it with the > intention of eventually making it a standard library component. Here > is a preview; the interface should be pretty stable now: > > http://user.it.uu.se/~richardc/array/ > > It still uses a tree structure, but since it uses indices from 0 to N > instead of arbitrary keys, it can be quite a lot more efficient in both > time and space than gb_trees or dicts. This looks awfully similar to the 'lines' module in jungerl. Could you describe the main differences? BR, Ulf W -- Ulf Wiger From heinrich@REDACTED Mon Sep 11 09:43:47 2006 From: heinrich@REDACTED (Heinrich Venter) Date: Mon, 11 Sep 2006 09:43:47 +0200 Subject: [erlang-questions] 2D Map Arrays In-Reply-To: <000201c6d2b8$595c8990$0201a8c0@Cellfind.local> Message-ID: I tinkered around with a similar design a while ago. In the end I built some tests to compare different approaches. If you only need to read elements, you can probably get away with a tuple of tuples, or a large binary with some indexing logic. If you need to do writes too things change drastically. I wrote a binary based read only test and an ets based one. The binary outperformed the ets table by a factor of 3. However when writes were done, the ets solution outperformed the binary one by a factor of about 10 and also used less memory. I did not test a binary vs tuple solution tho. The drawback of the binary solution is that you have to know the size of your data element in bytes for the logic to work. Consider this: If you use a tuple based solution you have some options on how you partition it. Say you have a 10x10 array. You could store it as a single tuple with 100 elements and use I=(Row*10+Col) to get the correct index for element(I,Map). You could also make it a tuple of 10 row tuples so that the access becomes element(Col,element(Row,Map)) But why stop there, why not break it up further into regions for a quad-tree type structure? If you break it up fine enough you will end up with something that looks almost like an ets table where each element has the form {{X,Y},Data}. So in the end ets will probably give you the most bang for your buck. -]-[ From abailly@REDACTED Mon Sep 11 09:54:59 2006 From: abailly@REDACTED (Arnaud Bailly) Date: Mon, 11 Sep 2006 09:54:59 +0200 Subject: [erlang-questions] Erlang and Maven In-Reply-To: (chandrashekhar.mullaparthi@gmail.com's message of "Mon, 11 Sep 2006 08:23:13 +0100") References: <87bqpqx9pd.fsf@oqube.com> Message-ID: <87ac56q1m4.fsf@oqube.com> Chandru writes: >> > > I don't know anything about Maven, but maybe you can use the OTP structure > for your system installation and the "mavenish" structure for your code > repository? I agree. The OTP structure could be constructed from the maven standard layout using assembly plugin or even a custom artefact type. For simplicity's and consistency's sake, it is better to keep adhering to maven's structure. -- OQube < software engineering \ g?nie logiciel > Arnaud Bailly, Dr. \web> http://www.oqube.com From richardc@REDACTED Mon Sep 11 10:15:17 2006 From: richardc@REDACTED (Richard Carlsson) Date: Mon, 11 Sep 2006 10:15:17 +0200 Subject: [erlang-questions] 2D Map Arrays In-Reply-To: References: <20060907195438.53546.qmail@web31605.mail.mud.yahoo.com> <4504FAEC.4070800@it.uu.se> Message-ID: <45051B15.2080304@it.uu.se> Ulf Wiger wrote: > This looks awfully similar to the 'lines' module in jungerl. > Could you describe the main differences? Noticeably faster, according to Dan's measurements. (I haven't looked at the code for the lines module myself.) /Richard From richardc@REDACTED Mon Sep 11 10:51:43 2006 From: richardc@REDACTED (Richard Carlsson) Date: Mon, 11 Sep 2006 10:51:43 +0200 Subject: [erlang-questions] 2D Map Arrays In-Reply-To: References: Message-ID: <4505239F.8050903@it.uu.se> Heinrich Venter wrote: > If you need to do writes too things change drastically. Of course - and the whole point of the array.erl implementation is to support writes (and have a good balance between writes and lookups). For lookup only, you probably can't beat a big, flat tuple, but that does not scale when it comes to writing. We want to have reasonably efficient arrays of many millons of elements. > However when writes were > done, the ets solution outperformed the binary one by a factor of about > 10 and also used less memory. Well, binaries are not really a candidate for random-access writing, (even when you have fixed, known sizes for the elements), since it involves an awful amount of copying. > Consider this: If you use a tuple based solution you have some options > on how you partition it. > Say you have a 10x10 array. You could store it as a single tuple with > 100 elements and use I=(Row*10+Col) to get the correct index for > element(I,Map). > You could also make it a tuple of 10 row tuples so that the access > becomes element(Col,element(Row,Map)) > But why stop there, why not break it up further into regions for a > quad-tree type structure? > If you break it up fine enough you will end up with something that looks > almost like an ets table where each element has the form {{X,Y},Data}. > So in the end ets will probably give you the most bang for your buck. First, we do not try to optimize for extremely sparse arrays (in which case quad trees or plain binary trees would perform well - and we already have decent binary trees), but for fairly densely populated ones. Second, in order to get fast operations, you have to have as few and as cheap tests as possible, and a regular layout like the one we use (nested N-tuples, where N=10 has been measured to be a good choice) simply gives us the fastest code - about 2-3 times faster than gb_trees. (On the other hand, you can only use nonnegative integers as keys!) Ets tables would not be faster if they were implemented in Erlang, instead of in C, and functional arrays have a couple of important properties that ets tables do not have: - No copying when reading/writing data. Ets tables always copy the data in and out of the table (except for large binaries), and is thus not suitable for storing things like large lists or tree structures. - They are _functional_, not destructive, so they can be used in places where you want to keep older versions of the array around (e.g., in an "undo"-list). With ets tables, you overwrite the old version of the data. Also, since the arrays are tree-based, keeping several "copies" around does not cost a lot space-wise. /Richard From ulf.wiger@REDACTED Mon Sep 11 12:56:48 2006 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Mon, 11 Sep 2006 12:56:48 +0200 Subject: [erlang-questions] 2D Map Arrays In-Reply-To: <45051B15.2080304@it.uu.se> Message-ID: Richard Carlsson wrote: > > Ulf Wiger wrote: > > This looks awfully similar to the 'lines' module in jungerl. > > Could you describe the main differences? > > Noticeably faster, according to Dan's measurements. > (I haven't looked at the code for the lines module myself.) Hmm, yes, a 'replace' takes about 15 us in lines.erl compared to ca 8 us in array.erl, and for 'get', the numbers were 7/13. Interestingly, 'from_list' (measured on a list of 1000 elements) was noticeably faster in lines.erl than in array.erl. I think this is because I have an optimized function for creating a large tree, rather than growing the tree as I go. The figures were 238 us for 'lines' and 626 us for 'array'. But here's the main difference (now that I've spend more than 15 seconds looking at array.erl): The 'lines' module supports insert() and delete(), whereas array.erl doesn't. While it would have been possible to optimize lines.erl slightly for nth() and replace() (not quite reaching the speed of array.erl, but closing the gap somewhat) by using tuples instead of lists as leafs, this would make append(), insert() and delete() quite less appealing. BR, Ulf W From ulf.wiger@REDACTED Mon Sep 11 13:39:05 2006 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Mon, 11 Sep 2006 13:39:05 +0200 Subject: [erlang-questions] 2D Map Arrays In-Reply-To: Message-ID: I wrote: > Hmm, yes, a 'replace' takes about 15 us in lines.erl compared > to ca 8 us in array.erl, and for 'get', the numbers were 7/13. Sorry, that should have been 13/7 (i.e. in favour of array.erl) Sorry 'bout that. BR, Ulf W From xlcr@REDACTED Mon Sep 11 13:40:03 2006 From: xlcr@REDACTED (Nick Linker) Date: Mon, 11 Sep 2006 18:40:03 +0700 Subject: [erlang-questions] 2D Map Arrays In-Reply-To: <4505239F.8050903@it.uu.se> References: <4505239F.8050903@it.uu.se> Message-ID: <45054B13.6060804@mail.ru> Richard Carlsson wrote: > Ets tables would not be faster if they were implemented in Erlang, > instead of in C > Could you say have you seen an implementation of arrays using Erlang ports? If yes, how they fast? Best regards, Nick. From Bob.Cowdery@REDACTED Mon Sep 11 13:57:02 2006 From: Bob.Cowdery@REDACTED (Bob Cowdery) Date: Mon, 11 Sep 2006 12:57:02 +0100 Subject: [erlang-questions] C data encoding/decoding Message-ID: <3A76756EED583B43A4AD704E29CCD079715C85@mail.aprsmartlogik.com> Hi Having got a C Port client and server working I am now moving that into the real application. Now comes the question of sending and receiving real messages between C Nodes. The data that forms the interface between these two nodes is C structs. Some of these structs are arrays or may contain arrays of structs or other simple types. One particular struct also has unions in it. I started out just using erl_format() which got me so far. I really only found it suitable for simple parameters and fixed structures. I then read the Erlang Interface document. From this it definitely seems I should be using the ei module. The external format looks like its much more adept at dealing with dynamic data. It is quite a difficult read though and there arn't any examples. Before I write too much codeI want to be sure this is the right approach so a few questions to anyone kind enough to give guidence. 1. Is the ei module the right one to use for reasonably complex dynamic data or am I not getting the full milage out of erl_format(). 2. If I use the external format is that suitable for digestion by a pure Erlang node as I don't expect at least one end of this interface to stay in C. 3. I can see an ei_send() takes a message in binary format (i'm assuming this is the same as external format). However, the receive functions don't explicitly say what they expect. I assume ei_receive accepts a message in binary format. 4. I could really do with an example of packing and unpacking say an array of structs to/from binary format. Can anyone point me to such an example. All help appreciated. Thanks Bob From wilbjor@REDACTED Mon Sep 11 14:00:09 2006 From: wilbjor@REDACTED (Jordan Wilberding) Date: Mon, 11 Sep 2006 07:00:09 -0500 Subject: [erlang-questions] inet_ssl broken? In-Reply-To: <45054B13.6060804@mail.ru> References: <4505239F.8050903@it.uu.se> <45054B13.6060804@mail.ru> Message-ID: <45054FC9.40100@iit.edu> Hello, I have been fiddling with trying to setup inet_ssl via the guide on erlang.org, but have had no success. I have tried multiple platforms and versions of erlang, all the way to the latest release available. I have read on a few places that evidently inet_ssl was broken, but was supposed to be fixed by now. Is it possible that it is still broken? Thanks! Jordan Wilberding From richardc@REDACTED Mon Sep 11 14:18:16 2006 From: richardc@REDACTED (Richard Carlsson) Date: Mon, 11 Sep 2006 14:18:16 +0200 Subject: [erlang-questions] 2D Map Arrays In-Reply-To: <45054B13.6060804@mail.ru> References: <4505239F.8050903@it.uu.se> <45054B13.6060804@mail.ru> Message-ID: <45055408.2090201@it.uu.se> Nick Linker wrote: > Could you say have you seen an implementation of arrays using Erlang > ports? If yes, how they fast? That would probably only be useful for storing integers and atoms, otherwise you would have the same copy-in/out problem as ets tables. And, of course, there would be some overhead for message passing. It doesn't feel like a worthwhile exercise to implement it. /Richard From serge@REDACTED Mon Sep 11 14:53:06 2006 From: serge@REDACTED (Serge Aleynikov) Date: Mon, 11 Sep 2006 08:53:06 -0400 Subject: [erlang-questions] C data encoding/decoding In-Reply-To: <3A76756EED583B43A4AD704E29CCD079715C85@mail.aprsmartlogik.com> References: <3A76756EED583B43A4AD704E29CCD079715C85@mail.aprsmartlogik.com> Message-ID: <45055C32.7070009@hq.idt.net> Bob, You can look here for an example of how to use EI for marshaling terms: http://wiki.trapexit.org/index.php/HowToUseEI As far as the guidelines on how to represent C structs, you can declare records on the Erlang side, and encode C structs as tuples. Though to the best of my knowledge, there's no single recommendation on how to deal with complex structures, and you'll have to figure out the most suitable representation that fits your case. Regards, Serge Bob Cowdery wrote: > Hi > > Having got a C Port client and server working I am now moving that into the real application. Now comes the question of sending and receiving real messages between C Nodes. > > The data that forms the interface between these two nodes is C structs. Some of these structs are arrays or may contain arrays of structs or other simple types. One particular struct also has unions in it. > > I started out just using erl_format() which got me so far. I really only found it suitable for simple parameters and fixed structures. I then read the Erlang Interface document. From this it definitely seems I should be using the ei module. The external format looks like its much more adept at dealing with dynamic data. It is quite a difficult read though and there arn't any examples. Before I write too much codeI want to be sure this is the right approach so a few questions to anyone kind enough to give guidence. > > 1. Is the ei module the right one to use for reasonably complex dynamic data or am I not getting the full milage out of erl_format(). > 2. If I use the external format is that suitable for digestion by a pure Erlang node as I don't expect at least one end of this interface to stay in C. > 3. I can see an ei_send() takes a message in binary format (i'm assuming this is the same as external format). However, the receive functions don't explicitly say what they expect. I assume ei_receive accepts a message in binary format. > 4. I could really do with an example of packing and unpacking say an array of structs to/from binary format. Can anyone point me to such an example. > > All help appreciated. > > Thanks > Bob > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From ke.han@REDACTED Mon Sep 11 15:20:53 2006 From: ke.han@REDACTED (ke han) Date: Mon, 11 Sep 2006 21:20:53 +0800 Subject: [erlang-questions] maillist post "best practices" Message-ID: <22E0959C-07E4-4E9D-B1DE-E7797AAED06A@redstarling.com> I have noticed that, in the last month, there are quite a few posts where someone "creates a new thread" by responding to an existing post and changing the subject. Please understand that doing this is not the correct way to create a new thread. This behavior messes up many mail client's ability to organize posts by thread. There may be other reasons why my threading is being broken in my mail client, but this is usually the culprit. Please help keep this maillist a convenient place to live ;-) thanks, ke han From Bob.Cowdery@REDACTED Mon Sep 11 15:20:51 2006 From: Bob.Cowdery@REDACTED (Bob Cowdery) Date: Mon, 11 Sep 2006 14:20:51 +0100 Subject: [erlang-questions] C data encoding/decoding Message-ID: <3A76756EED583B43A4AD704E29CCD079715C87@mail.aprsmartlogik.com> Serge Thanks, that looks useful. I can see a little study will be required here. Bob -----Original Message----- From: Serge Aleynikov [mailto:serge@REDACTED] Sent: 11 September 2006 13:53 To: Bob Cowdery Cc: Erlang Users' List Subject: Re: [erlang-questions] C data encoding/decoding Bob, You can look here for an example of how to use EI for marshaling terms: http://wiki.trapexit.org/index.php/HowToUseEI As far as the guidelines on how to represent C structs, you can declare records on the Erlang side, and encode C structs as tuples. Though to the best of my knowledge, there's no single recommendation on how to deal with complex structures, and you'll have to figure out the most suitable representation that fits your case. Regards, Serge Bob Cowdery wrote: > Hi > > Having got a C Port client and server working I am now moving that into the real application. Now comes the question of sending and receiving real messages between C Nodes. > > The data that forms the interface between these two nodes is C structs. Some of these structs are arrays or may contain arrays of structs or other simple types. One particular struct also has unions in it. > > I started out just using erl_format() which got me so far. I really only found it suitable for simple parameters and fixed structures. I then read the Erlang Interface document. From this it definitely seems I should be using the ei module. The external format looks like its much more adept at dealing with dynamic data. It is quite a difficult read though and there arn't any examples. Before I write too much codeI want to be sure this is the right approach so a few questions to anyone kind enough to give guidence. > > 1. Is the ei module the right one to use for reasonably complex dynamic data or am I not getting the full milage out of erl_format(). > 2. If I use the external format is that suitable for digestion by a pure Erlang node as I don't expect at least one end of this interface to stay in C. > 3. I can see an ei_send() takes a message in binary format (i'm assuming this is the same as external format). However, the receive functions don't explicitly say what they expect. I assume ei_receive accepts a message in binary format. > 4. I could really do with an example of packing and unpacking say an array of structs to/from binary format. Can anyone point me to such an example. > > All help appreciated. > > Thanks > Bob > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From alex.arnon@REDACTED Mon Sep 11 16:04:13 2006 From: alex.arnon@REDACTED (Alex Arnon) Date: Mon, 11 Sep 2006 17:04:13 +0300 Subject: [erlang-questions] Time manipulation. Message-ID: <944da41d0609110704hb753d34n4877592f58a4d6e4@mail.gmail.com> Hi List, I would like to perform some operations that require manipulation of time (as represented in erlang:now()). I need to add/substract seconds/microseconds etc. Are there any standard library functions that do this? Also, how can one translate Erlang time to a system (Unix) date, and vice-versa? Cheers, Alex. -------------- next part -------------- An HTML attachment was scrubbed... URL: From chsu79@REDACTED Mon Sep 11 16:15:37 2006 From: chsu79@REDACTED (Christian S) Date: Mon, 11 Sep 2006 16:15:37 +0200 Subject: [erlang-questions] Time manipulation. In-Reply-To: <944da41d0609110704hb753d34n4877592f58a4d6e4@mail.gmail.com> References: <944da41d0609110704hb753d34n4877592f58a4d6e4@mail.gmail.com> Message-ID: I've found the gregorian days and/or gregorian seconds representations in the "calendar" module to be useful for what you describe. On 9/11/06, Alex Arnon wrote: > Hi List, > > I would like to perform some operations that require manipulation of time > (as represented in erlang:now()). I need to add/substract > seconds/microseconds etc. Are there any standard library functions that do > this? > Also, how can one translate Erlang time to a system (Unix) date, and > vice-versa? > > Cheers, > Alex. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > > From vances@REDACTED Mon Sep 11 16:34:53 2006 From: vances@REDACTED (Vance Shipley) Date: Mon, 11 Sep 2006 10:34:53 -0400 Subject: [erlang-questions] Erlang and Maven In-Reply-To: References: <87bqpqx9pd.fsf@oqube.com> Message-ID: <20060911143453.GA27039@frogman.motivity.ca> On 10/09/06, Olivier Sambourg wrote: > >If we take a look at various OTP applications, the common directory >structure seems to be : > >application/ >|-> src/ (source files, flat) >|-> include/ (include files...) >|-> doc/ (documentation) >|-> ebin/ (beam files) The convention in OTP when mixing languages is to have a "c_src" directory. For example: $ ls lib/erlang/lib/asn1-1.4.4.10 c_src ebin examples priv src In this case there is a ddll driver and the C source is in c_src. The library with the driver code is in: lib/erlang/lib/asn1-1.4.4.10/priv/lib/asn1_erl_drv.so Another example is the IC application which uses java: $ ls lib/erlang/lib/ic-4.2.11 c_src ebin examples include java_src priv src -Vance From jerome.sautret@REDACTED Mon Sep 11 16:39:42 2006 From: jerome.sautret@REDACTED (=?ISO-8859-1?Q?J=E9r=F4me?= Sautret) Date: Mon, 11 Sep 2006 16:39:42 +0200 Subject: [erlang-questions] How to get the mnesia master node ? Message-ID: <1157985206.24745.3.camel@zero> Hello all, How can I get the master node on a mnesia cluster ? Or how can I now if the current node is currently the master or not ? Thanks, J?r?me From alex.arnon@REDACTED Mon Sep 11 17:12:31 2006 From: alex.arnon@REDACTED (Alex Arnon) Date: Mon, 11 Sep 2006 18:12:31 +0300 Subject: [erlang-questions] Time manipulation. In-Reply-To: References: <944da41d0609110704hb753d34n4877592f58a4d6e4@mail.gmail.com> Message-ID: <944da41d0609110812n48eab056x605ed581a67b498b@mail.gmail.com> Thank you! On 9/11/06, Christian S wrote: > > I've found the gregorian days and/or gregorian seconds representations > in the "calendar" module to be useful for what you describe. > > On 9/11/06, Alex Arnon wrote: > > Hi List, > > > > I would like to perform some operations that require manipulation of > time > > (as represented in erlang:now()). I need to add/substract > > seconds/microseconds etc. Are there any standard library functions that > do > > this? > > Also, how can one translate Erlang time to a system (Unix) date, and > > vice-versa? > > > > Cheers, > > Alex. > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From A.BETIS@REDACTED Mon Sep 11 17:19:11 2006 From: A.BETIS@REDACTED (BETIS Alexandre) Date: Mon, 11 Sep 2006 17:19:11 +0200 Subject: [erlang-questions] RE : Erlang now in the railway industry Message-ID: <69433317F55792499C45450D56E31F0828B077@LUC2K01VS.csee-transport.fr> Hi, > > How did you convinced your hierarchy and your customer ? > This question pops up quite often. It is pivotal to the success of Erlang in the future, hence I will take some time to answer it. The short, ugly truth is that I didn't. I half-lied. I pretended Erlang was just a C library dedicated to the writing of high availability systems. In fact, this is partly true. As Mr Spock would say, "Why lie when you can just omit?". It was a calculated risk. It worked and proved profitable for everyone. Now, for the long story, Convincing your hierarchy ------------------------- I did not convince my hierarchy. My results did. Thanks to Erlang, my estimates were accurate. When I said this feature worked, it actually did! Consequently, virtually all change requests where specification-level stuff. Interestingly, this is something project managemenent rather liked. Such claims can be traded against other stuffs. Convincing your customer ------------------------ I did not convince my customer. The software did. A non-crashing software is something that turns your customer into your best friend. The trick is to deliver it quickly, and track requirements carefully. Agile techniques coupled with the Erlang architecture are a powerfull combination to achieve this (but this exceeds the scope of this answer). Convincing yourself ------------------- You did not ask, but the most important thing is to convince yourself that the risk is worth being taken. This is the hardest part because you're going to be jumping freefall with a new untested gear. There are three reasons that had me jump with the Erlang (c) parachute: 1/ I have a Comp Sci background. I was familiar with functional programming Languages and knew they were much much better for the programmer's mental health. 2/ The test_server. Erlang was the first platform that came with a regression test suite. After running it on the target platform repeatidly for a few days, I was much more confident in this technology (granted, it crashed after three days. The disk was full with test reports. Well, doh...) 3/ For various reasons, including past projects gone awry because of overhyped technology, I was /annoyed/ (I don't want to use the p word in a well kept forum). Wanting to kick butt can be a great motivation. Bottom line ----------- You cannot convince with just technology and talks. There is too much of marketing firepower in front of us to win a battle of words. Only demonstrated profitability will do that. Pick up one of your assigned project, not too big (e.g. a module), make it happen, and expand from there. It may take a while to find an opening window, but if the technology really fits the needs of the organization, it will pop up sooner or later. Grab it. But like all pioneers, you will be alone. Cheers, -- Alex " Ce message et ses pi?ces jointes sont confidentiels et exclusivement r?serv?s ? leurs destinataires qui s'assureront de l'absence de virus. CSEE Transport n'assume aucune responsabilit? au titre de ce message s'il est alt?r?, d?form?, falsifi?, ind?ment utilis? par des tiers ou encore s'il a caus? des dommages ou pertes de toute nature. This e-mail and any attached files are confidential and exclusively intended for its addressees who will conduct appropriate virus checks. CSEE Transport shall not be liable for the message if altered, changed, falsified, unduly used by third parties nor for any damage or loss." From ulf.wiger@REDACTED Mon Sep 11 17:48:04 2006 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Mon, 11 Sep 2006 17:48:04 +0200 Subject: [erlang-questions] How to get the mnesia master node ? In-Reply-To: <1157985206.24745.3.camel@zero> Message-ID: Read the Mnesia User's Guide - 6.7 Recovery from Communication Failure. http://www.erlang.org/doc/doc-5.5/lib/mnesia-4.3.1/doc/html/Mnesia_chap7.html#6.7 "The functions mnesia:system_info(master_node_tables) and mnesia:table_info(Tab, master_nodes) may be used to obtain information about the potential master nodes." Mnesia doesn't use master nodes in normal operation. If master nodes are set, it's because the user did so. The master node setting overrides the default behaviour of mnesia to select whichever copy appears most recent. But perhaps that's not the information you're after? If you want to know where mnesia intends to fetch data for a given table, this is perhaps more relevant: (ts2@REDACTED)16> mnesia:table_info(joe, where_to_write). [ts2@REDACTED] (ts2@REDACTED)17> mnesia:table_info(joe, where_to_read). ts2@REDACTED BR, Ulf W > -----Original Message----- > From: erlang-questions-bounces@REDACTED > [mailto:erlang-questions-bounces@REDACTED] On Behalf Of > J?r?me Sautret > Sent: den 11 september 2006 16:40 > To: erlang-questions-posters@REDACTED > Cc: jerome.sautret@REDACTED > Subject: [erlang-questions] How to get the mnesia master node ? > > > Hello all, > > How can I get the master node on a mnesia cluster ? Or how > can I now if the current node is currently the master or not ? > > Thanks, > J?r?me > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From chsu79@REDACTED Mon Sep 11 18:23:21 2006 From: chsu79@REDACTED (Christian S) Date: Mon, 11 Sep 2006 18:23:21 +0200 Subject: [erlang-questions] RE : Erlang now in the railway industry In-Reply-To: <69433317F55792499C45450D56E31F0828B077@LUC2K01VS.csee-transport.fr> References: <69433317F55792499C45450D56E31F0828B077@LUC2K01VS.csee-transport.fr> Message-ID: On 9/11/06, BETIS Alexandre wrote: > You did not ask, but the most important thing is > to convince yourself that the risk is worth being > taken. This is the hardest part because you're > going to be jumping freefall with a new untested > gear. The lesson I take from this is that one can not blame managment for not wanting to try something new. Take the risk on yourself instead. The risk of being fired or in other ways diciplined in case of failure is as real for managers as it is for you. Anyway, this is what is seems like you have done. It is your ass on the line if Erlang didnt work out. Of course, Erlang always works out. :) From jefcrane@REDACTED Mon Sep 11 18:51:46 2006 From: jefcrane@REDACTED (Jeff Crane) Date: Mon, 11 Sep 2006 09:51:46 -0700 (PDT) Subject: [erlang-questions] 2D Map Arrays In-Reply-To: <45055408.2090201@it.uu.se> Message-ID: <20060911165146.8993.qmail@web31606.mail.mud.yahoo.com> Can anyone post example usage for the Array implementation? I'd like to see proper usage. %% yes I imported the array module, after compiling test() -> MyArr = array:new(0,0), array:push(1,4,MyArr). This is about as far as I got. How do you identify individual arrays? New doesnt always return me a value. How do I push a value into the array? Does it dynamically resize? I cannot determine the answers to these questions by looking at the code/trying test args. __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From richardc@REDACTED Mon Sep 11 20:31:42 2006 From: richardc@REDACTED (Richard Carlsson) Date: Mon, 11 Sep 2006 20:31:42 +0200 Subject: [erlang-questions] 2D Map Arrays In-Reply-To: <20060911165146.8993.qmail@web31606.mail.mud.yahoo.com> References: <20060911165146.8993.qmail@web31606.mail.mud.yahoo.com> Message-ID: <4505AB8E.9000509@it.uu.se> Jeff Crane wrote: > Can anyone post example usage for the Array > implementation? > > I'd like to see proper usage. > > %% yes I imported the array module, after compiling > test() -> > MyArr = array:new(0,0), > array:push(1,4,MyArr). > > This is about as far as I got. 'push' is not an exported function, so don't even try to use it. It's just a help function that works on lists. Rule number one: if it's not exported and not documented, then it doesn't exist. On the other hand, there _is_ a heap of unit testing code inside the module, with plenty of usage examples. > How do you identify individual arrays? What do you mean by "identify"? > New doesnt always return me a value. That sounds awfully strange. Do you mean that the 'new' function loops forever? Can you show an example? > How do I push a value into the array? Use the 'set' function. I will probably add some extra functions such as 'append' later. > Does it dynamically resize? Yes. > I cannot determine the answers to these questions by looking at > the code/trying test args. Did you not see the html documentation (http://user.it.uu.se/~richardc/array/array.html)? /Richard From ulf.wiger@REDACTED Mon Sep 11 21:01:00 2006 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Mon, 11 Sep 2006 21:01:00 +0200 Subject: [erlang-questions] 2D Map Arrays In-Reply-To: <20060911165146.8993.qmail@web31606.mail.mud.yahoo.com> Message-ID: The array.erl module implements a functional data structure. It doesn't work like ets. array:set(I, Value, Array) returns a new Array with index I set to Value, for example. This is the same as for gb_trees, dict, queue, and, well, lists. BR, Ulf W > -----Original Message----- > From: erlang-questions-bounces@REDACTED > [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Jeff Crane > Sent: den 11 september 2006 18:52 > To: erlang-questions@REDACTED > Subject: Re: [erlang-questions] 2D Map Arrays > > Can anyone post example usage for the Array implementation? > > I'd like to see proper usage. > > %% yes I imported the array module, after compiling > test() -> > MyArr = array:new(0,0), > array:push(1,4,MyArr). > > This is about as far as I got. > > How do you identify individual arrays? New doesnt always > return me a value. How do I push a value into the array? Does > it dynamically resize? I cannot determine the answers to > these questions by looking at the code/trying test args. > > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection > around http://mail.yahoo.com > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From jefcrane@REDACTED Mon Sep 11 21:37:34 2006 From: jefcrane@REDACTED (Jeff Crane) Date: Mon, 11 Sep 2006 12:37:34 -0700 (PDT) Subject: [erlang-questions] 2D Map Arrays In-Reply-To: <4505AB8E.9000509@it.uu.se> Message-ID: <20060911193734.95964.qmail@web31615.mail.mud.yahoo.com> --- Richard Carlsson wrote: > Jeff Crane wrote: > > Can anyone post example usage for the Array > > implementation? > > > > I'd like to see proper usage. > > > On the other hand, there _is_ a heap of unit testing > code > inside the module, with plenty of usage examples. I dont see it. -ifdef(EUNIT). new_test_() -> N0 = ?LEAFSIZE, N01 = N0+1, N1 = ?NODESIZE*N0, N11 = N1+1, N2 = ?NODESIZE*N1, [?_assertMatch(#array{size=0,max=N0,default=undefined,elements=N0}, new(0)), ?_assertMatch(#array{size=N0,max=N0,elements=N0}, new(N0)), ?_assertMatch(#array{size=N01,max=N1,elements=N1}, new(N01)), ?_assertMatch(#array{size=N1,max=N1,elements=N1}, new(N1)), ?_assertMatch(#array{size=N11,max=N2,elements=N2}, new(N11)), ?_assertMatch(#array{size=N2, max=N2, default=42,elements=N2}, new(N2,42)), ?_assert(new() == new(0)), ?_assert(new(0) == new(0,undefined)), ?_assert(0 == array:size(new())), ?_assert(undefined == default(new())), ?_assert(new(10) == new(10,undefined)), ?_assert(17 == array:size(new(17))), ?_assert(4711 == default(new(0,4711))) ]. -endif. This doesn't have any real meaning to me. I'm sure it's because I don't have enough erlang experience to understand what that's supposed to do, but it's nearly incomprehensible compared to > Did you not see the html documentation > (http://user.it.uu.se/~richardc/array/array.html)? Which I had not seen. > > How do I push a value into the array? > > Use the 'set' function. I will probably add some > extra functions such as 'append' later. > > > Does it dynamically resize? > > Yes. test() -> MyNewArr = array:new(0,0), MyBiggerArr = array:set(1,4,MyNewArr), array:size(MyBiggerArr). That's an example I can understand. Arrays are identified by the tuples returned from array:new All functions are essentially read-only functions, but you cannot reassign variables so this requires reassignment to new Atoms as the array is processed. I now know more about how to use the Array module for temporary data storage than I know about ets ( http://www.google.com/search?hl=en&lr=&safe=off&q=usage+erlang+example+ets&btnG=Search - that's a lot of digging for not much in the way of examples). Yes, I'm not amazingly good at learning how to read and use erlang modules, but I am happy to be the newbie filter. __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From richardc@REDACTED Mon Sep 11 22:34:54 2006 From: richardc@REDACTED (Richard Carlsson) Date: Mon, 11 Sep 2006 22:34:54 +0200 Subject: [erlang-questions] 2D Map Arrays In-Reply-To: <20060911193734.95964.qmail@web31615.mail.mud.yahoo.com> References: <20060911193734.95964.qmail@web31615.mail.mud.yahoo.com> Message-ID: <4505C86E.70409@it.uu.se> Jeff Crane wrote: > I dont see it. > ... > [?_assertMatch(#array{size=0,max=N0,default=undefined,elements=N0}, > new(0)), Ignore the #array stuff - that's just checking that the internal representation is ok. > ?_assert(new() == new(0)), This checks that calling new() is the same thing as calling new(0). > ?_assert(0 == array:size(new())), This checks that the size of an array created with new() is zero. > ?_assert(17 == array:size(new(17))), This checks that if you ask for a new array with 17 elements, the size is indeed 17. Et cetera, et cetera. But there are also tests that check, for instance, that if you do 'set(N, X, new())', you will get an array with N+1 elements (from 0 to N) as a result. I thought those might help you. >>> Does it dynamically resize? >> Yes. > > test() -> > MyNewArr = array:new(0,0), > MyBiggerArr = array:set(1,4,MyNewArr), > array:size(MyBiggerArr). > > That's an example I can understand. Arrays are > identified by the tuples returned from array:new Yes. Erlang has no way to hide how the representation really looks (that is, it has no truly abstract data types), but by convention, if the representation isn't documented, you should never assume that it will stay the same, and you should only use the functions to access the data structure. > you cannot reassign variables so this requires > reassignment to new Atoms as the array is processed. Just don't confuse variables with atoms. Erlang has single-assignment variables, yes, so you must use another variable name for the new array after each "update" (well, at least within the same function clause). Atoms, however, are data objects, similar to strings. > Yes, I'm not amazingly good at learning how to read > and use erlang modules, but I am happy to be the > newbie filter. I confess that my "preview" of the array module was mostly aimed at seasoned Erlang programmers, who already are very familiar with the similar standard library modules 'dict', 'gb_trees', and 'ets'. Well, hang in there, and you too will soon be a seasoned functional programmer. (Cue the currying jokes!) /Richard From ok@REDACTED Tue Sep 12 01:41:00 2006 From: ok@REDACTED (Richard A. O'Keefe) Date: Tue, 12 Sep 2006 11:41:00 +1200 (NZST) Subject: [erlang-questions] RE : Erlang now in the railway industry Message-ID: <200609112341.k8BNf0Tl399253@atlas.otago.ac.nz> "BETIS Alexandre" wrote: I pretended Erlang was just a C library dedicated to the writing of high availability systems. In fact, this is partly true. As Mr Spock would say, "Why lie when you can just omit?". I'm reminded of a true Prolog story. Consultant C was to write a program for organisation O. Organisation O demanded that all such programs be written in language L. Consultant C was of the opinion that Prolog was the right language for the job, but alas, L wasn't Prolog. So Consultant C wrote a Prolog interpreter in L, and delivered that as "the program", while the "real" program was described as "configuration data". From david.nospam.hopwood@REDACTED Tue Sep 12 02:48:38 2006 From: david.nospam.hopwood@REDACTED (David Hopwood) Date: Tue, 12 Sep 2006 01:48:38 +0100 Subject: [erlang-questions] RE : Erlang now in the railway industry In-Reply-To: <200609112341.k8BNf0Tl399253@atlas.otago.ac.nz> References: <200609112341.k8BNf0Tl399253@atlas.otago.ac.nz> Message-ID: <450603E6.5090102@blueyonder.co.uk> Richard A. O'Keefe wrote: > "BETIS Alexandre" wrote: > I pretended Erlang was just a C library dedicated to the > writing of high availability systems. In fact, this is > partly true. As Mr Spock would say, "Why lie when you can > just omit?". > > I'm reminded of a true Prolog story. > Consultant C was to write a program for organisation O. > Organisation O demanded that all such programs be written in language L. > Consultant C was of the opinion that Prolog was the right language > for the job, but alas, L wasn't Prolog. > So Consultant C wrote a Prolog interpreter in L, and delivered that as > "the program", while the "real" program was described as > "configuration data". Customer handling is a learnable skill. Here is one technique that I've found very effective. When the customer gives you an initial specification, it will have some errors and omissions. (Safety considerations are often neglected, for example.) It will also specify some stuff that is not an error, but you think is a bad idea. Rewrite the spec fixing the errors, omissions, and bad ideas, and hand it back to the customer. Make sure that this is not presented as a criticism of what they originally wrote, but as *your understanding of what they wrote* (and oh, I've "just clarified some details..."). It is very important that you be able to provide a convincing technical explanation for any of the changes (customers will differ widely in how much of this explanation they need). If you can demonstrate by this that you know what you're doing, most customers will be sufficiently reassured that they'll back off from overspecifying the technical stuff, and just leave you to get on with it. Occasionally you will get a customer that doesn't respond well to this approach, doesn't listen to reasoned technical argument, and carries on overspecifying. If this is the case, it is important to find out before accepting the order, because this is when you have to ask yourself "Do I really want this contract?" As a consultant, I have only ever lost money or had other bad experiences on contracts with this type of customer. Seriously consider refusing the work. (You may consider directing them to another company, even if it is a competitor. Or for the really bad customers, *especially* if it is a competitor. ) -- David Hopwood From ke.han@REDACTED Tue Sep 12 05:12:42 2006 From: ke.han@REDACTED (ke han) Date: Tue, 12 Sep 2006 11:12:42 +0800 Subject: [erlang-questions] RE : Erlang now in the railway industry In-Reply-To: <69433317F55792499C45450D56E31F0828B077@LUC2K01VS.csee-transport.fr> References: <69433317F55792499C45450D56E31F0828B077@LUC2K01VS.csee-transport.fr> Message-ID: <67FEBFEE-AB4E-4563-81DD-4F660ADCDF33@redstarling.com> On Sep 11, 2006, at 11:19 PM, BETIS Alexandre wrote: > > I did not convince my customer. The software did. > A non-crashing software is something that turns > your customer into your best friend. > I built a web app earlier this year with yaws+mnesia...during prototyping and alpha phases, the customer was many times over my shoulder and wanting live access to the work in progress. It was a huge benefit, and the customer remarked on this, that the system _never_ crashed and mnesia _never_ ended up with invalid data. Sure, there were errors..but the erlang VM just kept chugging away and my app never accepted invalid input...non-defensive programming really does work!!! The customer in this case allowed me to make all the technology decisions..so it was completely my responsibility if my choices were inappropriate...turned out the customer was pleased and my bills were always paid on time ;-). ke han From xlcr@REDACTED Tue Sep 12 09:14:15 2006 From: xlcr@REDACTED (Nick Linker) Date: Tue, 12 Sep 2006 14:14:15 +0700 Subject: [erlang-questions] 2D Map Arrays In-Reply-To: <45055408.2090201@it.uu.se> References: <4505239F.8050903@it.uu.se> <45054B13.6060804@mail.ru> <45055408.2090201@it.uu.se> Message-ID: <45065E47.9080400@mail.ru> Richard Carlsson wrote: > That would probably only be useful for storing integers and atoms, > otherwise you would have the same copy-in/out problem as ets tables. > And, of course, there would be some overhead for message passing. > It doesn't feel like a worthwhile exercise to implement it. > > /Richard Thank you for the answer. From Bob.Cowdery@REDACTED Tue Sep 12 10:29:25 2006 From: Bob.Cowdery@REDACTED (Bob Cowdery) Date: Tue, 12 Sep 2006 09:29:25 +0100 Subject: [erlang-questions] C data encoding/decoding Message-ID: <3A76756EED583B43A4AD704E29CCD079741161@mail.aprsmartlogik.com> -----Original Message----- From: yerl@REDACTED [mailto:yerl@REDACTED] Sent: 11 September 2006 13:05 To: Bob Cowdery Subject: Re: [erlang-questions] C data encoding/decoding Hi Bob! Could you put your code somewhere we can help you? cheers Youn?s Well, I've looked at ei and I still can't really figure how to use it. Maybe I'm being dumb, it wouldn't be the first time. This may seem an odd way to proceed but what I have done is do what I want in JSON (http://www.json.org/) and put the string in a term. The code snippet does at least explain what I want to achieve and was very quick to write. Note, this is not necessarily complete code, its just compiled, not tested and is the first JSON I have written. The method populate_band_control() encodes one call to a remote proc. It adds this to the array of calls that are being encoded as a single message. The message is constructed by calling start_update(), then each call to be encoded and then finish_update() which returns an ETERM that says this is JSON encoded and carries the JSON string. What is being encoded in this case is an array of the following structs. This is by no means the most complex of the encodings. Would it be possible to do this in ei I guess is the question. Do you think what I am doing is a reasonable way to do things when C talks to C. My fear is that I am digging myself a hole should I now want one end of this to be pure Erlang as I would have to use the Erlang JSON module. Regards Bob /* The type RAD_B defines one radio band */ typedef struct radio_band { double home; // The default home frequency for this band char type[10]; // The type double low_edge; // Lower edge of band double high_edge; // Upper edge of band char label[10]; // Label displayed to the user } RAD_B; //////////////////////////////////////////////////////////////////////////////// void start_update() { update = json_object_new_array(); } //////////////////////////////////////////////////////////////////////////////// void add_to_update(struct json_object* item) { json_object_array_add(update, item); } //////////////////////////////////////////////////////////////////////////////// ETERM *finish_update() { return erl_format("{JSON, ~s}", json_object_to_json_string(update)); } //////////////////////////////////////////////////////////////////////////////// void populate_band_control(RAD_B bands[]) { // Construct the JSON message struct json_object *band_dt, *bands_dt, *jsonmsg; int i; bands = json_object_new_array(); for(i=0; i Hi there! I'm pleased announce very-alpha version of vim patch, which turns vim into erlang C-node. Thus -- we can do any rpc calls to erlang from vim and get results in a reasonable format (at least it's easily processed in vim). Just not to make too much noise on this list while it's alpha I've opened google group. Please see announcement and links to the patch in this message: http://groups.google.com/group/vim-erlang/browse_thread/thread/6683b4e3bbe141f7?fwc=1 All interested folks - please join :) I hope we can catch up emacs with this module - at least at intellisense and module compile/reload initiated from vim. -- Gaspar Chilingarov System Administrator, Network security consulting t +37493 419763 (mob) i 63174784 e nm@REDACTED From Bob.Cowdery@REDACTED Tue Sep 12 14:37:38 2006 From: Bob.Cowdery@REDACTED (Bob Cowdery) Date: Tue, 12 Sep 2006 13:37:38 +0100 Subject: [erlang-questions] C data encoding/decoding Message-ID: <3A76756EED583B43A4AD704E29CCD079741162@mail.aprsmartlogik.com> I had another look and it made a bit more sense. Would this be anywhere close to what I need to do. I haven't even tried to compile it as I'm on the wrong machine. I can probably get away without having to know the arity in start_update() but I know how many methods calls will be encoded so it seems easier. int index = 0; int *pindex = &index; ei_x_buff *buf; //////////////////////////////////////////////////////////////////////////////// void start_update(int arity) { index = 0; ei_x_encode_tuple_header(buf, &pindex, arity); } //////////////////////////////////////////////////////////////////////////////// ei_x_buf *finish_update() { return buf; } //////////////////////////////////////////////////////////////////////////////// void populate_band_control(RAD_B bands[]) { ei_x_encode_tuple_header(buf, &pindex, 2); ei x_encode string(buf, &index, "populate_band_control"); ei x_encode list header(buf, &index, BAND_NO); for(i=0; i References: <87bqpqx9pd.fsf@oqube.com> <87ac56q1m4.fsf@oqube.com> Message-ID: 2006/9/11, Arnaud Bailly : > > Chandru writes: > > >> > > > > I don't know anything about Maven, but maybe you can use the OTP > structure > > for your system installation and the "mavenish" structure for your code > > repository? > > I agree. The OTP structure could be constructed from the maven > standard layout using assembly plugin or even a custom artefact > type. For simplicity's and consistency's sake, it is better to keep > adhering to maven's structure. I also agree (it does seem obvious now...) 2006/9/11, Vance Shipley : > > On 10/09/06, Olivier Sambourg wrote: > > > >If we take a look at various OTP applications, the common directory > >structure seems to be : > > > >application/ > >|-> src/ (source files, flat) > >|-> include/ (include files...) > >|-> doc/ (documentation) > >|-> ebin/ (beam files) > > The convention in OTP when mixing languages is to have a "c_src" > directory. For example: > > $ ls lib/erlang/lib/asn1-1.4.4.10 > c_src ebin examples priv src > > In this case there is a ddll driver and the C source is in c_src. > The library with the driver code is in: > > lib/erlang/lib/asn1-1.4.4.10/priv/lib/asn1_erl_drv.so > > Another example is the IC application which uses java: > > $ ls lib/erlang/lib/ic-4.2.11 > c_src ebin examples include java_src priv src > Thank you for the information :) I've started working on the plugin, slowly at first as I'm still struggling with Maven's documentation... For the moment, it's capable of generating an Emakefile with various user defined options and use it to compile the source files. Quite dull actually :) Next step will be packaging, automatically running test cases and generating the edoc (not necessarily in this order). Then there'll be dynamic code loading (Cargo really seems a good idea...) and dependencies management (REPOS is still my only lead). I've also started an archetype plugin (a special breed of maven plugins used to set up a typical project, such as web apps, j2ee, etc.). It creates the project directory structure, along with exemple sources files and a basic POM file, so you can start coding right away... I'll let you know when I make significant progress. Thanks for the help -- Olivier -------------- next part -------------- An HTML attachment was scrubbed... URL: From mickael.remond@REDACTED Tue Sep 12 20:14:41 2006 From: mickael.remond@REDACTED (Mickael Remond) Date: Tue, 12 Sep 2006 20:14:41 +0200 Subject: [erlang-questions] Erlang in network mode on Windows XP Message-ID: <20060912181441.GA16962@memphis> Hello, Long time ago I have reported a problem on Windows XP with Erlang started in network mode. On some XP computer, erlang cannot start with -name or -sname whatever the name you use (crash at startup). I never managed to find a consistent rule of why some machine are working and some are not. I have checked the firewall (disable) and antivirus (disabled). On some machine it is working and on other not. Other network applications and servers software are working fine. This only happens on windows XP and not on windows 2000. Some others have faced the same problem: - http://www.erlang.org/ml-archive/erlang-questions/200308/msg00076.html - http://www.erlang.org/ml-archive/erlang-bugs/200603/msg00005.html - http://www.erlang.org/ml-archive/erlang-questions/200411/msg00120.html - http://www.erlang.org/ml-archive/erlang-questions/200404/msg00072.html - http://bc.whirlpool.net.au/forum-replies-archive.cfm/180880.html and even some more, but I think this is enough to understand the problem. So my question is the following: Has someone ever managed to understand what was happening and how to solve the problem ? I have to make a software work on a particular computer, and I am stuck with this problem. I tried with erlang R10b-10. Thank you ! -- Micka?l R?mond http://www.process-one.net/ From vladdu55@REDACTED Tue Sep 12 20:28:44 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Tue, 12 Sep 2006 19:28:44 +0100 Subject: [erlang-questions] Erlang in network mode on Windows XP In-Reply-To: <20060912181441.GA16962@memphis> References: <20060912181441.GA16962@memphis> Message-ID: <95be1d3b0609121128g5dd3f7acudac0e5a00bd075fc@mail.gmail.com> Hi! On 9/12/06, Mickael Remond wrote: > Long time ago I have reported a problem on Windows XP with Erlang > started in network mode. > On some XP computer, erlang cannot start with -name or -sname whatever > the name you use (crash at startup). Might it be the same problem as someone had recently, the the DNS service wasn't properly configured? best regards, Vlad From harley@REDACTED Wed Sep 13 08:27:22 2006 From: harley@REDACTED (Harley Gorrell) Date: Tue, 12 Sep 2006 23:27:22 -0700 (PDT) Subject: [erlang-questions] jungerl: lib/ssh patch... Message-ID: I just tried to compile jungerl with R11B-1 and got a compile error. Looking at it, it appears that "buf->refc" should be replaced with "driver_binary_get_refc(buf)". The jungerl list looks to be too quiet, so I am posting this here. ---8<---snip---8<---snip---8<---snip---8<---snip---8<--- Index: loop_drv.c =================================================================== RCS file: /cvsroot/jungerl/jungerl/lib/ssh/c_src/loop_drv.c,v retrieving revision 1.1 diff -u -r1.1 loop_drv.c --- loop_drv.c 19 Oct 2004 08:03:13 -0000 1.1 +++ loop_drv.c 13 Sep 2006 06:17:30 -0000 @@ -736,16 +736,16 @@ */ static void free_buffer(ErlDrvBinary* buf) { - DEBUGF(("free_buffer: %ld\r\n", (buf==NULL) ? 0 : buf->orig_size)); - - if (buf != NULL) { - if (buf->refc == 1) - release_buffer(buf); - else { + DEBUGF(("free_buffer: %ld\r\n", (buf==NULL) ? 0 : buf->orig_size)); + + if (buf != NULL) { + if (driver_binary_get_refc(buf) == 1) + release_buffer(buf); + else { COUNT_BUF_FREE(buf->orig_size); driver_free_binary(buf); - } } + } } ---8<---snip---8<---snip---8<---snip---8<---snip---8<--- harley. From xpdoka@REDACTED Wed Sep 13 14:47:59 2006 From: xpdoka@REDACTED (Dominic Williams) Date: Wed, 13 Sep 2006 14:47:59 +0200 (CEST) Subject: [erlang-questions] [erlang-bugs] localtime_to_universaltime(DistantFuture) Message-ID: <15152.83.204.226.145.1158151679.squirrel@www.geekisp.com> Ulf Wiger (TN/EAB) wrote: > It would seem as if the future for Erlang ends at > 3:14:7 MET, Jan 19 2038. Not just for Erlang, cf. http://www.2038bug.com/ Regards, Dominic Williams http://www.dominicwilliams.net ---- From mikpe@REDACTED Wed Sep 13 14:53:01 2006 From: mikpe@REDACTED (Mikael Pettersson) Date: Wed, 13 Sep 2006 14:53:01 +0200 Subject: [erlang-questions] 2D Map Arrays In-Reply-To: <4504FAEC.4070800@it.uu.se> References: <20060907195438.53546.qmail@web31605.mail.mud.yahoo.com> <4504FAEC.4070800@it.uu.se> Message-ID: <17671.65325.345118.705637@alkaid.it.uu.se> Richard Carlsson writes: > Jeff Crane wrote: > > What do I do when I want to operate on a similarly > > sized dynamic layer that I want to read/write to? > > A while ago, Dan Gudmundsson posted an array datatype implementation > to the list. Since then, I and Dan have been rewriting it with the > intention of eventually making it a standard library component. Here > is a preview; the interface should be pretty stable now: > > http://user.it.uu.se/~richardc/array/ > > It still uses a tree structure, but since it uses indices from 0 to N > instead of arbitrary keys, it can be quite a lot more efficient in both > time and space than gb_trees or dicts. The HiPE compiler heavily uses gb_trees for array-like objects, so I tested the array module in HiPE. The array module's interface is a close match to our own `hipe_vectors_wrapper' module, so the integration was easy. The array module works nicely but I haven't done any performance measurements yet. There are two things about the array module I don't quite like: 1. Doing a set on an index higher than the current maximum causes the array to grow, while doing a get on an index higher than the current maximum throws an exception. This makes sense for objects like partial mappings, but is quite strange for array-like objects. Perhaps a name change to "intmap" would capture its behaviour more accurately? 2. It has an extensible index range, but we only construct arrays of given sizes and then stay within those boundaries. So do we lose any performance due to the extensibility feature we don't use? /Mikael From richardc@REDACTED Wed Sep 13 15:18:45 2006 From: richardc@REDACTED (Richard Carlsson) Date: Wed, 13 Sep 2006 15:18:45 +0200 Subject: [erlang-questions] 2D Map Arrays In-Reply-To: <17671.65325.345118.705637@alkaid.it.uu.se> References: <20060907195438.53546.qmail@web31605.mail.mud.yahoo.com> <4504FAEC.4070800@it.uu.se> <17671.65325.345118.705637@alkaid.it.uu.se> Message-ID: <45080535.6090705@it.uu.se> Mikael Pettersson wrote: > 2. It has an extensible index range, but we only construct arrays of > given sizes and then stay within those boundaries. So do we lose > any performance due to the extensibility feature we don't use? No. For 'set', it just does a single test to check if you are within range or not (and that would be done even if you did not allow the range to be extended). Furthermore, the range extension is very cheap; most of the time, it does nothing except check that the current structure has room for the new maximum index. If that is not the case, an extra tuple level is added, which increases the maximum range by a factor 10. In other words, if you append one element at a time to an initially empty array, the actual array structure will only change at sizes 1, 11, 101, 1001, 10001, and so on. Since the representation is quite sparse, this does not waste space for the as-yet-unused part. /Richard From nm@REDACTED Wed Sep 13 15:37:15 2006 From: nm@REDACTED (Gaspar Chilingarov) Date: Wed, 13 Sep 2006 18:37:15 +0500 Subject: [erlang-questions] Update for vim-erlang patch Message-ID: <4508098B.1000500@web.am> Hi all! New patch is located here: http://zanazan.am/vim/vim-erl_interface-sep13.tgz Fixed keep-alive messages in console mode vim and getting large messages from clients. Instruction how to patch vim http://zanazan.am/vim/get_vim.txt Sample vim script to connect to erlang node, and create module reload shortcut located here: http://zanazan.am/vim/erlang-ext.vim I would like to listen feedback from the community - to know, in which direction to move. Your opinion is priceless ;) please let me know. /Gaspar -- Gaspar Chilingarov System Administrator, Network security consulting t +37493 419763 (mob) i 63174784 e nm@REDACTED From richardc@REDACTED Wed Sep 13 15:58:38 2006 From: richardc@REDACTED (Richard Carlsson) Date: Wed, 13 Sep 2006 15:58:38 +0200 Subject: [erlang-questions] 2D Map Arrays In-Reply-To: <17671.65325.345118.705637@alkaid.it.uu.se> References: <20060907195438.53546.qmail@web31605.mail.mud.yahoo.com> <4504FAEC.4070800@it.uu.se> <17671.65325.345118.705637@alkaid.it.uu.se> Message-ID: <45080E8E.3000105@it.uu.se> Mikael Pettersson wrote: > 1. Doing a set on an index higher than the current maximum causes the > array to grow, while doing a get on an index higher than the current > maximum throws an exception. This makes sense for objects like partial > mappings, but is quite strange for array-like objects. Perhaps a > name change to "intmap" would capture its behaviour more accurately? It depends on which arrays you use as a reference for your thinking. :-) (Maybe I've looked a little too much at Python, Ruby and Perl lately, but I quite like this behaviour.) Automatic growing can of course lead to an undetected error, if you happen to do a 'set' with an index that should have been out of bounds, but that is probably more than made up for in the cases where you would otherwise have to keep track of growing it yourself - and screwing up. Throwing exceptions if you access an uninitialized element within the current range would require a change in representation, wasting both space and time, and is therefore right out. An alternative to throwing an exception when accessing an index that is larger than the current maximum, is to return the default value. (For example, in Ruby you get a 'nil' if you do this.) But that gives you a mismatch between what the array claims to be its current size, and which indices you can access as if they contain a value. (And what about negative indices? Some languages interpret this as offsets from the end of the array, but I'm not sure that would very useful.) Note that in our arrays, if you can read from index I, then you can also read from index I-1, if I > 0. I think the name 'array' remains a good match. I suppose it would be possible to add a kind of locking to arrays, so that locked/fixed-size arrays are not allowed to grow automatically. Is this a much wanted feature, folks? /Richard From rath64@REDACTED Wed Sep 13 19:34:26 2006 From: rath64@REDACTED (Tim Rath) Date: Wed, 13 Sep 2006 12:34:26 -0500 (CDT) Subject: [erlang-questions] compiler bug not quite fixed? Message-ID: <13126057.530911158168866605.JavaMail.root@vms068.mailsrvcs.net> Hi, I saw a compiler bug posted to the list by Martin Bjorklund that appeared to be exactly the problem I'm seeing, and then noticed that this was fixed in R11B-1 (as per the release notes.) Unfortunately, though R11B-1 appears to fix the code submitted by Martin, it does not fix my case. Here's the output (looks the same as in Martin's case): %erlc a.erl Function -a/0-fun-0-/1 refers to undefined label 13 ./a.erl:none: internal error in beam_clean; crash reason: {{case_clause,{'EXIT',{undefined_label,13}}}, [{compile,'-select_passes/2-anonymous-2-',2}, {compile,'-internal_comp/4-anonymous-1-',2}, {compile,fold_comp,3}, {compile,internal_comp,4}, {compile,internal,3}]} ./a.erl:10: Warning: variable 'B' is unused And here's the smallest amount of code I could come up with that reproduces the problem: -module(a). -export([a/0]). a() -> A = {6}, try io:fwrite("") after fun () -> fun () -> {B} = A end end end. Edge case? -Tim From nm@REDACTED Wed Sep 13 23:17:23 2006 From: nm@REDACTED (Gaspar Chilingarov) Date: Thu, 14 Sep 2006 02:17:23 +0500 Subject: [erlang-questions] Vim and Erlang syntax files update [2006-09-14] Message-ID: <45087563.5030202@web.am> Hello all! New syntax package is ready, which includes small improvements over the previous version: o It does highlighting of list of the terms if you do not put spaces between commas and terms (like [foo,bar,baz], which is better to write as [foo, bar, baz]) -- think as a style enforcement. o It ignores now integer lists, so it's okay to write [1,2,3,4,5] -- which is more readable, than space separated number list. o Pair brackets and curly braces (i.e. lists and tuples) are highlighted now with some non-obtrusive color. If you see brace/bracket with black(or normal text color) -- it means that you have illegal brace nesting there. Some illegal nesting cases highlighted with red now. o Added back as a bonus simple testing server modeled after erlang's original test_server. Much more lightweight and quite easy to setup and run (see in bonus directory). Syntax and testing module interface is compatible with test_server. Download location: http://zanazan.am/vim/erlang-vim-syntax-2006sep14.tar.bz2 (I hope I've finnaly solved my problems with hosting and this link will be permanent, if not - please do not hesitate to contact me by e-mail). Please send your comments and ideas, please :) /Gaspar -- Gaspar Chilingarov System Administrator, Network security consulting t +37493 419763 (mob) i 63174784 e nm@REDACTED From yarivvv@REDACTED Thu Sep 14 00:50:51 2006 From: yarivvv@REDACTED (Yariv Sadan) Date: Wed, 13 Sep 2006 18:50:51 -0400 Subject: [erlang-questions] Revamped MySQL driver Message-ID: <17244f480609131550q26d8a67evc2fe513e9be96c4d@mail.gmail.com> Hi, I added a bunch of features and optimizations to the Yxa MySQL driver I got from Process One. The biggest new features are support for transactions and prepared statements. Here's the "official" announcement, with a short tutorial illustrating the new features: http://yarivsblog.com/articles/2006/09/13/erlang-mysql-driver-reloaded. You can get the revamped driver here: http://code.google.com/p/erlang-mysql-driver/. Cheers, Yariv From mickael.remond@REDACTED Thu Sep 14 01:12:41 2006 From: mickael.remond@REDACTED (Mickael Remond) Date: Thu, 14 Sep 2006 01:12:41 +0200 Subject: [erlang-questions] Erlang in network mode on Windows XP In-Reply-To: <95be1d3b0609121128g5dd3f7acudac0e5a00bd075fc@mail.gmail.com> References: <20060912181441.GA16962@memphis> <95be1d3b0609121128g5dd3f7acudac0e5a00bd075fc@mail.gmail.com> Message-ID: <20060913231241.GB8058@memphis.lan> Hello, * Vlad Dumitrescu [2006-09-12 19:28:44 +0100]: > Hi! > > On 9/12/06, Mickael Remond wrote: > > Long time ago I have reported a problem on Windows XP with Erlang > > started in network mode. > > On some XP computer, erlang cannot start with -name or -sname whatever > > the name you use (crash at startup). > > Might it be the same problem as someone had recently, the the DNS > service wasn't properly configured? I do not think so because I tried to plug the network cable to go on the net with this computer. The DNS was properly configured for that. Do you have any reference on the post you are mentionning ? The crash message is strange. It seems that socket access is refused... -- Micka?l R?mond http://www.process-one.net/ From serge@REDACTED Thu Sep 14 01:55:28 2006 From: serge@REDACTED (Serge Aleynikov) Date: Wed, 13 Sep 2006 19:55:28 -0400 Subject: [erlang-questions] Erlang in network mode on Windows XP In-Reply-To: <20060913231241.GB8058@memphis.lan> References: <20060912181441.GA16962@memphis> <95be1d3b0609121128g5dd3f7acudac0e5a00bd075fc@mail.gmail.com> <20060913231241.GB8058@memphis.lan> Message-ID: <45089A70.7090900@hq.idt.net> I recall that I managed to resolve the same issue on WinXP once by disabling firewall and all other services in Control Panel leaving just essential ones running, but I didn't figure out exactly which one was causing the issue. Serge Mickael Remond wrote: > Hello, > > * Vlad Dumitrescu [2006-09-12 19:28:44 +0100]: > >> Hi! >> >> On 9/12/06, Mickael Remond wrote: >>> Long time ago I have reported a problem on Windows XP with Erlang >>> started in network mode. >>> On some XP computer, erlang cannot start with -name or -sname whatever >>> the name you use (crash at startup). >> Might it be the same problem as someone had recently, the the DNS >> service wasn't properly configured? > > I do not think so because I tried to plug the network cable to go on the > net with this computer. The DNS was properly configured for that. > Do you have any reference on the post you are mentionning ? > > The crash message is strange. It seems that socket access is refused... From matt@REDACTED Thu Sep 14 03:56:14 2006 From: matt@REDACTED (Matthew Wilson) Date: Thu, 14 Sep 2006 01:56:14 +0000 (UTC) Subject: [erlang-questions] Need advice on how to design a tagging web service Message-ID: I want to learn erlang and I'm trying to figure out if this project idea might be a good one. I want to write a network service that applications can use to support user-supplied tags, like del.icio.us and flickr. I need the service to be able to process *lots* of transactions. clients of the service would do any of the following: * add a tag supplied by a user for a thing. * look up all pairs of (tags, things) that a given user has supplied. * look up all the tags supplied for any users for a given thing. I'm thinking that the erlang service would sit in front of a database, and the database would have this schema: tags table: (tagid, tagname) things table: (thingid, thingname) users table: (userid, username) gumbo table: (userid, thingid, tagid) And here's how I'm thinking about designing the service: One process periodically connects to the database and reads everything out to a local in-memory cache. Another process waits for client requests. Any client request to get data goes to the process with the in-memory cache to get results. Meanwhile, any request to add data goes to another process that accumulates these into a queue. Yet another process pops elements out of that queue and then writes them all to the database. All comments are welcome. Is this absurd? TIA Matt -- A better way of running series of SAS programs: http://overlook.homelinux.net/wilsonwiki/SasAndMakefiles From ft@REDACTED Thu Sep 14 08:03:31 2006 From: ft@REDACTED (Fredrik Thulin) Date: Thu, 14 Sep 2006 08:03:31 +0200 (CEST) Subject: [erlang-questions] Revamped MySQL driver In-Reply-To: <17244f480609131550q26d8a67evc2fe513e9be96c4d@mail.gmail.com> Message-ID: <11666425.39951158213811403.JavaMail.ft@it.su.se> On 2006-09-14, at 00:50, Yariv Sadan wrote: > Hi, > > I added a bunch of features and optimizations to the Yxa MySQL driver > I got from Process One. The biggest new features are support for > transactions and prepared statements. > > Here's the "official" announcement, with a short tutorial illustrating > the new features: > http://yarivsblog.com/articles/2006/09/13/erlang-mysql-driver-reloaded. > > You can get the revamped driver here: > http://code.google.com/p/erlang-mysql-driver/. Hi It is great to see that people actually want to use the YXA MySQL driver. As maintainer of the YXA source code, I would like to see all usefull features folded back into the original source code though. Mikael (of Process One) has shared this view, he just hasn't had time enough to complete updating YXA's own usage of the MySQL driver yet, but has said that he intends to. Without having looked at the improvements you have made, I would like to roll them too back into the YXA source repository. What do you think about this? I don't think it benefits the Erlang community to have lots of essentially forked versions of the MySQL driver. /Fredrik From vladdu55@REDACTED Thu Sep 14 08:37:19 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Thu, 14 Sep 2006 08:37:19 +0200 Subject: [erlang-questions] Erlang in network mode on Windows XP In-Reply-To: <20060913231241.GB8058@memphis.lan> References: <20060912181441.GA16962@memphis> <95be1d3b0609121128g5dd3f7acudac0e5a00bd075fc@mail.gmail.com> <20060913231241.GB8058@memphis.lan> Message-ID: <95be1d3b0609132337h84ccfcan9a5c68664a0c669b@mail.gmail.com> On 9/14/06, Mickael Remond wrote: > > Might it be the same problem as someone had recently, the the DNS > > service wasn't properly configured? > > I do not think so because I tried to plug the network cable to go on the > net with this computer. The DNS was properly configured for that. > Do you have any reference on the post you are mentionning ? http://www.erlang.org/ml-archive/erlang-questions/200609/msg00033.html > The crash message is strange. It seems that socket access is refused... Good luck! /Vlad From bjorn@REDACTED Thu Sep 14 10:28:20 2006 From: bjorn@REDACTED (Bjorn Gustavsson) Date: 14 Sep 2006 10:28:20 +0200 Subject: [erlang-questions] compiler bug not quite fixed? In-Reply-To: <13126057.530911158168866605.JavaMail.root@vms068.mailsrvcs.net> References: <13126057.530911158168866605.JavaMail.root@vms068.mailsrvcs.net> Message-ID: Thanks for the bug report. I forgot to handle nested funs in the after block. The following correction will be included in R11B-2: *** v3_core.erl@@/main/release/r11b_patch/1 Tue Aug 29 11:48:16 2006 --- v3_core.erl Thu Sep 14 10:14:32 2006 *************** *** 1386,1393 **** %% Kill the id annoations for any fun inside the expression. %% Necessary when duplicating code in try ... after. ! kill_id_anns(#ifun{}=Fun) -> ! Fun#ifun{id=[]}; kill_id_anns(#a{}=A) -> %% Optimization: Don't waste time searching for funs inside annotations. A; --- 1386,1395 ---- %% Kill the id annoations for any fun inside the expression. %% Necessary when duplicating code in try ... after. ! ! kill_id_anns(#ifun{clauses=Cs0}=Fun) -> ! Cs = kill_id_anns(Cs0), ! Fun#ifun{clauses=Cs,id=[]}; kill_id_anns(#a{}=A) -> %% Optimization: Don't waste time searching for funs inside annotations. A; /Bjorn Tim Rath writes: > Hi, > > I saw a compiler bug posted to the list by Martin Bjorklund that appeared to be exactly the problem I'm seeing, and then noticed that this was fixed in R11B-1 (as per the release notes.) Unfortunately, though R11B-1 appears to fix the code submitted by Martin, it does not fix my case. [...] -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From chsu79@REDACTED Thu Sep 14 10:29:55 2006 From: chsu79@REDACTED (Christian S) Date: Thu, 14 Sep 2006 10:29:55 +0200 Subject: [erlang-questions] Need advice on how to design a tagging web service In-Reply-To: References: Message-ID: Since you never mention what db to use I assume it is mnesia. You have to understand that mnesia doesnt contain a query planner for complex joins. Also, only sufficiently smart relative database managers know how to perform queries of the sort you described in an efficient way for the tables you listed. The result of this is that you have to maintain extra tables in mnesia for clever indexing of the data, and update them "manually" in your mnesia transactions. If you have a thingid and a userid, and want to get the tags it is registered under it is a good idea to have a {userid, thingsid}-tuple mapped to a list of tagids ( as in {user_thing_tags, {UserID, ThingId}, [TagId]} ) to find what the thing has been tagged as. by the user If you have a thingid and want to find the most frequent tags for it, then it might be good have a table that maps thingid to userids to find users that have the thing. (as in {thing_users, ThingId, [UserId]} ) This would involve a query to thing_users, then N queries to user_thing_tags (once for each user). A not all that efficient query if it is a thingid that 10000 users have tagged. You might want to keep this information precalculated and updated by a background batch job. The information would lag behind but this is acceptable for the application (del.icio.us does it, afaik). Hint: In mnesia a table supervisor is notified about table updates. This can be used to 'taint' a given thingid as in need of an updated tag frequency analysis. This is the place for queuing work as you described. You need a similar offline job to precalculate a mapping of tagid to thingids. To give relevant order in listing you should probably look into information retrieval methods, so you rank documents after how many users have given them a tag. I am confident that with these measures you will be able to support lots of transactions. As the application scales you can begin to add more mnesia nodes, and eventually begin to frag hash so write transactions do not need to synchronize with every mnesia node. Also try to make a single user's data end up in the same fragment. None of these measures will affect your original schema or application code. On 9/14/06, Matthew Wilson wrote: > > I want to learn erlang and I'm trying to figure out if this project idea > might be a good one. > > I want to write a network service that applications can use to support > user-supplied tags, like del.icio.us and flickr. > > I need the service to be able to process *lots* of transactions. > > clients of the service would do any of the following: > > * add a tag supplied by a user for a thing. > > * look up all pairs of (tags, things) that a given user has supplied. > > * look up all the tags supplied for any users for a given thing. > > I'm thinking that the erlang service would sit in front of a database, > and the database would have this schema: > > tags table: (tagid, tagname) > things table: (thingid, thingname) > users table: (userid, username) > gumbo table: (userid, thingid, tagid) > > And here's how I'm thinking about designing the service: > > One process periodically connects to the database and reads everything > out to a local in-memory cache. > > Another process waits for client requests. Any client request to get > data goes to the process with the in-memory cache to get results. > > Meanwhile, any request to add data goes to another process that > accumulates these into a queue. > > Yet another process pops elements out of that queue and then writes them > all to the database. > > All comments are welcome. > > Is this absurd? > > TIA > > Matt > > -- > A better way of running series of SAS programs: > http://overlook.homelinux.net/wilsonwiki/SasAndMakefiles > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From vladdu55@REDACTED Thu Sep 14 13:02:07 2006 From: vladdu55@REDACTED (vladdu) Date: Thu, 14 Sep 2006 12:02:07 +0100 Subject: [erlang-questions] Installing Erlang/OTP R11B-1 on Xubuntu laptop References: Message-ID: <20060914110207.AC23C5A1F6@mail.erlangsystems.com> Hi, There is an erlang distribution for Ubuntu, but I'm not sure how new it is (it may be R10). I think it's to be found in the 'universe' - just serch for erlang in synaptic. There is a private newer distribution, but last I checked it was only a Debian package (meaning it would need manual setup). In any case, I didn't have any problem compiling from source on an out-of-the-box Ubuntu 6.06. Good luck! best regards, Vlad _________________________________________________________ Post sent from http://www.trapexit.org From ulf@REDACTED Thu Sep 14 13:34:07 2006 From: ulf@REDACTED (Ulf Wiger) Date: Thu, 14 Sep 2006 13:34:07 +0200 Subject: [erlang-questions] Need advice on how to design a tagging web service In-Reply-To: References: Message-ID: Den 2006-09-14 10:29:55 skrev Christian S : > Since you never mention what db to use I assume it is mnesia. > > You have to understand that mnesia doesnt contain a query planner for > complex joins. Also, only sufficiently smart relative database > managers know how to perform queries of the sort you described in an > efficient way for the tables you listed. Actually, Mnemosyne does/did optimize queries. If you read the manual on Mnemosyne, there is a warning not to use Mnemosyne for performance-critical applications. The wording in the efficiency Guide is more to the point: "Mnesia supports complex queries through the query language Mnemosyne. This makes it possible to perform queries of any complexity on Mnesia tables. However for simple queries Mnemosyne is usually much more expensive than sensible handwritten functions doing the same thing." More information on Mnemosyne and it's current status can be found in this thread: http://www.erlang.org/ml-archive/erlang-questions/200502/msg00272.html > The result of this is that you have to maintain extra tables in mnesia > for clever indexing of the data, and update them "manually" in your > mnesia transactions. Well, mnesia is a bit limited in how you can index data, but it does support indexes (secondary key indexes), and they do not have to be maintained manually, of course. > If you have a thingid and a userid, and want to get the tags it is > registered under it is a good idea to have a {userid, thingsid}-tuple > mapped to a list of tagids > > ( as in {user_thing_tags, {UserID, ThingId}, [TagId]} ) > > to find what the thing has been tagged as. by the user > > If you have a thingid and want to find the most frequent tags for it, > then it might be good have a table that maps thingid to userids to > find users that have the thing. > > (as in {thing_users, ThingId, [UserId]} ) > > This would involve a query to thing_users, then N queries to > user_thing_tags (once for each user). A not all that efficient query > if it is a thingid that 10000 users have tagged. You might want to > keep this information precalculated and updated by a background batch > job. The information would lag behind but this is acceptable for the > application (del.icio.us does it, afaik). You can also have an ordered_set table with the key {UserId,ThingId,TagId} (*). If you occasionally want to find all occurrences of TagId, you can get it with a simple select operation. If you keep an attribute [TagId], select won't help - nor will indexing (unless you use 'rdbms', which is able to index on e.g. all elements of a list attribute.) (*) Unlike ets, mnesia requires at least one non-key attribute. If you have no more attributes, you must add a dummy attribute. > As the application scales you can begin to add > more mnesia nodes, and eventually begin to frag hash > so write transactions do not need to synchronize with > every mnesia node. Also try to make a single user's > data end up in the same fragment. ... and this can be done even if UserId is only part of the key. One way to keep grouped data in the same fragment is to write a mnesia_frag_hash callback module. All functions in mnesia_frag_hash can be reused (just call the originals), except two: key_to_frag_number(State, {UserId, _, _}) -> mnesia_frag_hash:key_to_frag_number(State, UserId). and match_spec_to_frag_numbers(State, MatchSpec) -> ... % left as an excercise for the reader. http://www.erlang.org/doc/doc-5.5.1/lib/mnesia-4.3.2/doc/html/mnesia_frag_hash.html I had this idea once to write an XML document database using mnesia, where I would keep the data in ordered sets, and use this technique to hash on the document id, co- locating all elements in a single fragment. I think it would have worked out too, but I ended up shelving the idea after a feeble attempt at adapting an implementation of XMLQuery (made in Erlang by Hans Nilsson). It turned out to be too much work for something that I actually didn't need myself. BR, Ulf W -- Ulf Wiger From joe.armstrong@REDACTED Thu Sep 14 13:35:42 2006 From: joe.armstrong@REDACTED (Joe Armstrong (TN/EAB)) Date: Thu, 14 Sep 2006 13:35:42 +0200 Subject: [erlang-questions] gen_tcp question In-Reply-To: <20060914110207.AC23C5A1F6@mail.erlangsystems.com> Message-ID: I have a question about gen_tcp A client does this: {ok, Port} = gen_tcp:connect(Host, Post, [binary,{packet,N}]) get_tcp:send(Port, <>) The server calls gen_tcp:listen(Port, [binary,{packet,N}]) Then goes into a receive loop to receive messages Questions: 1) is <> delivered as a single message to the server program? or is the packet fragmented. 2) Does fragmentation or not depend upon N (the packet size) must N be > 0 for the receiver to be able to reconstruct the fragments (if fragmented?) The behaviour appears not to be documented /Joe From yarivvv@REDACTED Thu Sep 14 13:50:08 2006 From: yarivvv@REDACTED (Yariv Sadan) Date: Thu, 14 Sep 2006 07:50:08 -0400 Subject: [erlang-questions] Revamped MySQL driver In-Reply-To: <11666425.39951158213811403.JavaMail.ft@it.su.se> References: <17244f480609131550q26d8a67evc2fe513e9be96c4d@mail.gmail.com> <11666425.39951158213811403.JavaMail.ft@it.su.se> Message-ID: <17244f480609140450n3ef16a60p1c922545b380aa7a@mail.gmail.com> Hi Fredrik! > Hi > > It is great to see that people actually want to use the YXA MySQL driver. As > maintainer of the YXA source code, I would like to see all usefull features > folded back into the original source code though. > > Mikael (of Process One) has shared this view, he just hasn't had time enough to > complete updating YXA's own usage of the MySQL driver yet, but has said that he > intends to. Without having looked at the improvements you have made, I would > like to roll them too back into the YXA source repository. What do you think > about this? I don't think it benefits the Erlang community to have lots of > essentially forked versions of the MySQL driver. I think it makes total sense! One of the reasons I created this new project is because my changes have broken a few features and I didn't know that this would fit the requirements of YXA. In addition, it was ok for ErlyDB's needs if the driver went back to "beta" version, but it probably wouldn't be ok for a mature product like YXA. Anyway, if you would like to roll these changes into the YXA source repository, I would support it. Let me know. Best regards, Yariv From vladdu55@REDACTED Thu Sep 14 14:08:37 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Thu, 14 Sep 2006 14:08:37 +0200 Subject: [erlang-questions] gen_tcp question In-Reply-To: References: <20060914110207.AC23C5A1F6@mail.erlangsystems.com> Message-ID: <95be1d3b0609140508s72256950n1b56b6bf2ed86b33@mail.gmail.com> On 9/14/06, Joe Armstrong (TN/EAB) wrote: > 1) is <> delivered as a single message to the server program? > or is the packet fragmented. > 2) Does fragmentation or not depend upon N (the packet size) > must N be > 0 for the receiver to be able to reconstruct the > fragments (if fragmented?) Hi, I think the behaviour isn't documented because it isn't dictated by Erlang, but is dictated by the TCP parameters of the socket. Any TCP packet may be fragmented (it certainly is if it is larger then the current MTU), but I think that even servers along the way (if it's a remote connection) may further fragment it. So to be sure, assume it's fragmented. If N=0 you will have to have your own way to be to reconstruct each message from the TCP stream. Relying on each message to be delivered separately isn't working. I know from personal experience :-) best regards, Vlad From sean.hinde@REDACTED Thu Sep 14 14:21:30 2006 From: sean.hinde@REDACTED (Sean Hinde) Date: Thu, 14 Sep 2006 13:21:30 +0100 Subject: [erlang-questions] gen_tcp question In-Reply-To: References: Message-ID: Hi Joe, I have used this technique with really quite large packets and it always seemed to do the right thing. I typically use {packet, 2} so that the other end cannot fill up my machine with DoS style packets. Sean On 14 Sep 2006, at 12:35, Joe Armstrong ((TN/EAB)) wrote: > > I have a question about gen_tcp > > A client does this: > > {ok, Port} = gen_tcp:connect(Host, Post, [binary,{packet,N}]) > get_tcp:send(Port, <>) > > The server > > calls gen_tcp:listen(Port, [binary,{packet,N}]) > > Then goes into a receive loop to receive messages > > Questions: > > 1) is <> delivered as a single message to the server > program? > or is the packet fragmented. > > 2) Does fragmentation or not depend upon N (the packet size) > must N be > 0 for the receiver to be able to reconstruct the > fragments (if fragmented?) > > The behaviour appears not to be documented > > /Joe > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From serge@REDACTED Thu Sep 14 14:26:15 2006 From: serge@REDACTED (Serge Aleynikov) Date: Thu, 14 Sep 2006 08:26:15 -0400 Subject: [erlang-questions] gen_tcp question In-Reply-To: References: Message-ID: <45094A67.6000200@hq.idt.net> Joe Armstrong (TN/EAB) wrote: > > I have a question about gen_tcp > > A client does this: > > {ok, Port} = gen_tcp:connect(Host, Post, [binary,{packet,N}]) > get_tcp:send(Port, <>) > > The server > > calls gen_tcp:listen(Port, [binary,{packet,N}]) > > Then goes into a receive loop to receive messages > > Questions: > > 1) is <> delivered as a single message to the server program? > or is the packet fragmented. I would say that since the tcp_recv call in inet_drv.c is aware of the {packet,N} option set on the socket, gen_tcp:recv(Sock, 0) will (memory permitting) deliver a complete packet of N bytes to the caller. However the packet may get fragmented in the transport layer because of the MTU size excess, though this should be transparent to the caller. > 2) Does fragmentation or not depend upon N (the packet size) > must N be > 0 for the receiver to be able to reconstruct the > fragments (if fragmented?) I think this depends on which socket option is set. For {packet,N} doing gen_tcp:recv(Sock, M), where M != 0 will return an einval (if memory serves) error. If you are using raw socket option, there is a 16M limit on the size of M. You'll get an enomem error in that case. > The behaviour appears not to be documented > > /Joe Regards, Serge From joe.armstrong@REDACTED Thu Sep 14 14:33:35 2006 From: joe.armstrong@REDACTED (Joe Armstrong (TN/EAB)) Date: Thu, 14 Sep 2006 14:33:35 +0200 Subject: [erlang-questions] gen_tcp question In-Reply-To: Message-ID: It might well be that it ... "seemed to do the right thing" ... But what I want to knwo is if the gen_tcp layer is *designed* and programmed to only deliver packets of exactly the right length. The fact that your packets are not fragmented might be accidental or by design Is this an accidental propery of do I have to add a layer of code that does the refragmentation - I could read the code, but that would be cheating. Reading the code will tell me what the program actually does, and NOT what it is supposed to do. I guess Tony knows if he's reading this :-) /Joe > -----Original Message----- > From: Sean Hinde [mailto:sean.hinde@REDACTED] > Sent: den 14 september 2006 14:22 > To: Joe Armstrong (TN/EAB) > Cc: erlang-questions@REDACTED > Subject: Re: [erlang-questions] gen_tcp question > > Hi Joe, > > I have used this technique with really quite large packets > and it always seemed to do the right thing. > > I typically use {packet, 2} so that the other end cannot fill > up my machine with DoS style packets. > > Sean > > > On 14 Sep 2006, at 12:35, Joe Armstrong ((TN/EAB)) wrote: > > > > > I have a question about gen_tcp > > > > A client does this: > > > > {ok, Port} = gen_tcp:connect(Host, Post, [binary,{packet,N}]) > > get_tcp:send(Port, <>) > > > > The server > > > > calls gen_tcp:listen(Port, [binary,{packet,N}]) > > > > Then goes into a receive loop to receive messages > > > > Questions: > > > > 1) is <> delivered as a single message to the server > > program? > > or is the packet fragmented. > > > > 2) Does fragmentation or not depend upon N (the packet size) > > must N be > 0 for the receiver to be able to > reconstruct the > > fragments (if fragmented?) > > > > The behaviour appears not to be documented > > > > /Joe > > > > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > From sean.hinde@REDACTED Thu Sep 14 14:45:44 2006 From: sean.hinde@REDACTED (Sean Hinde) Date: Thu, 14 Sep 2006 13:45:44 +0100 Subject: [erlang-questions] gen_tcp question In-Reply-To: References: Message-ID: On 14 Sep 2006, at 13:33, Joe Armstrong ((TN/EAB)) wrote: > > It might well be that it > > ... "seemed to do the right thing" ... Well, It did the right thing consistently for some years with messages much larger that can be carried in a single LAN packet. Personally I would take that as greater proof than reading it in the documentation. Others of a different persuasion would believe that if it was not written in the documentation then I had in fact created a timebomb guaranteed to fail at the worst possible moment in the future ! Only Ericsson can make any documented guarantees about the default system, not even Tony can provide anything other that a statement of his intent when he wrote it. Sean From joe.armstrong@REDACTED Thu Sep 14 14:53:10 2006 From: joe.armstrong@REDACTED (Joe Armstrong (TN/EAB)) Date: Thu, 14 Sep 2006 14:53:10 +0200 Subject: [erlang-questions] gen_tcp question In-Reply-To: Message-ID: I'm not interested in what is actually does - I'm interested in what it's supposed to do. The documentation is supposed to tell you what the program is supposed to do and I suppose that it is reasonable to suppose that people are supposed to send error messages if they suppose that the program does not do what might be supposed from the documentation. /Joe > -----Original Message----- > From: Sean Hinde [mailto:sean.hinde@REDACTED] > Sent: den 14 september 2006 14:46 > To: Joe Armstrong (TN/EAB) > Cc: erlang-questions@REDACTED; tony@REDACTED > Subject: Re: [erlang-questions] gen_tcp question > > > On 14 Sep 2006, at 13:33, Joe Armstrong ((TN/EAB)) wrote: > > > > > It might well be that it > > > > ... "seemed to do the right thing" ... > > Well, It did the right thing consistently for some years with > messages much larger that can be carried in a single LAN packet. > Personally I would take that as greater proof than reading it > in the documentation. > > Others of a different persuasion would believe that if it was > not written in the documentation then I had in fact created a > timebomb guaranteed to fail at the worst possible moment in > the future ! > > Only Ericsson can make any documented guarantees about the > default system, not even Tony can provide anything other that > a statement of his intent when he wrote it. > > > Sean > > From vladdu55@REDACTED Thu Sep 14 14:58:18 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Thu, 14 Sep 2006 14:58:18 +0200 Subject: [erlang-questions] gen_tcp question In-Reply-To: References: Message-ID: <95be1d3b0609140558ofbc806di642c05bc430d8619@mail.gmail.com> On 9/14/06, Sean Hinde wrote: > Well, It did the right thing consistently for some years with > messages much larger that can be carried in a single LAN packet. > Personally I would take that as greater proof than reading it in the > documentation. Then I suppose the problems I had (for some while ago, I think it was R7 or R8) were not caused by this issue or was fixed since. Good to know! regards, Vlad From sean.hinde@REDACTED Thu Sep 14 15:16:00 2006 From: sean.hinde@REDACTED (Sean Hinde) Date: Thu, 14 Sep 2006 14:16:00 +0100 Subject: [erlang-questions] gen_tcp question In-Reply-To: References: Message-ID: Joe, I was not disagreeing with you that it should be documented. I suppose I was making an observation on human (and corporate) behaviour. Personally I am happy to derive an intent from the combination of the existing documentation and my own testing. If it ended up not working as implied by the documentation then I would have had no hesitation to raise a trouble ticket using the commercial support option and blag it. Others are not happy to rely on this level of assumption so it should of course be documented. To the point in hand: I am sure Tony could make some statement of what it was supposed to do when he wrote it, but that is surely not enough. Ericsson might have a plan to change the undocumented behaviour so it only works for packets without an F in the length in an unspecified number base. So, only Ericsson can make any statement of what the program is supposed to do now and in the future. And that place is the documentation and any support contracts you might have with them. BR, Sean On 14 Sep 2006, at 13:53, Joe Armstrong ((TN/EAB)) wrote: > > I'm not interested in what is actually does - > I'm interested in what it's supposed to do. > > The documentation is supposed to tell you what the program is supposed > to do > and I suppose that it is reasonable to suppose that people are > supposed > to > send error messages if they suppose that the program does not > do what might be supposed from the documentation. > > > > /Joe > > >> -----Original Message----- >> From: Sean Hinde [mailto:sean.hinde@REDACTED] >> Sent: den 14 september 2006 14:46 >> To: Joe Armstrong (TN/EAB) >> Cc: erlang-questions@REDACTED; tony@REDACTED >> Subject: Re: [erlang-questions] gen_tcp question >> >> >> On 14 Sep 2006, at 13:33, Joe Armstrong ((TN/EAB)) wrote: >> >>> >>> It might well be that it >>> >>> ... "seemed to do the right thing" ... >> >> Well, It did the right thing consistently for some years with >> messages much larger that can be carried in a single LAN packet. >> Personally I would take that as greater proof than reading it >> in the documentation. >> >> Others of a different persuasion would believe that if it was >> not written in the documentation then I had in fact created a >> timebomb guaranteed to fail at the worst possible moment in >> the future ! >> >> Only Ericsson can make any documented guarantees about the >> default system, not even Tony can provide anything other that >> a statement of his intent when he wrote it. >> >> >> Sean >> >> From sean.hinde@REDACTED Thu Sep 14 15:16:31 2006 From: sean.hinde@REDACTED (Sean Hinde) Date: Thu, 14 Sep 2006 14:16:31 +0100 Subject: [erlang-questions] gen_tcp question In-Reply-To: <95be1d3b0609140558ofbc806di642c05bc430d8619@mail.gmail.com> References: <95be1d3b0609140558ofbc806di642c05bc430d8619@mail.gmail.com> Message-ID: On 14 Sep 2006, at 13:58, Vlad Dumitrescu wrote: > On 9/14/06, Sean Hinde wrote: >> Well, It did the right thing consistently for some years with >> messages much larger that can be carried in a single LAN packet. >> Personally I would take that as greater proof than reading it in the >> documentation. > > Then I suppose the problems I had (for some while ago, I think it was > R7 or R8) were not caused by this issue or was fixed since. Good to > know! Aha, but if it is not documented then YMMV! Sean From jahakala@REDACTED Thu Sep 14 15:32:49 2006 From: jahakala@REDACTED (Jani Hakala) Date: Thu, 14 Sep 2006 16:32:49 +0300 Subject: [erlang-questions] gen_tcp question In-Reply-To: (Joe Armstrong's message of "Thu\, 14 Sep 2006 13\:35\:42 +0200") References: Message-ID: <87psdya7zy.fsf@pingviini.kortex.jyu.fi> "Joe Armstrong (TN/EAB)" writes: > The behaviour appears not to be documented > Meaning of {packet,N} is explained in man inet, inet:setopts The behaviour of gen_tcp:recv is explained in man gen_tcp Jani Hakala From sean.hinde@REDACTED Thu Sep 14 15:46:07 2006 From: sean.hinde@REDACTED (Sean Hinde) Date: Thu, 14 Sep 2006 14:46:07 +0100 Subject: [erlang-questions] gen_tcp question In-Reply-To: <87psdya7zy.fsf@pingviini.kortex.jyu.fi> References: <87psdya7zy.fsf@pingviini.kortex.jyu.fi> Message-ID: On 14 Sep 2006, at 14:32, Jani Hakala wrote: > "Joe Armstrong (TN/EAB)" writes: > >> The behaviour appears not to be documented >> > Meaning of {packet,N} is explained in man inet, inet:setopts > The behaviour of gen_tcp:recv is explained in man gen_tcp Well observed! My assumption (there we go again) was that Joe must have read the documentation in order to have discover the existence of {packet, N}, but found it lacking. Reading the page more carefully now it is clear that it does specify the behaviour. Where you perchance peeking under the hood to discover this option Joe ? :-) Sean From matt@REDACTED Thu Sep 14 15:47:59 2006 From: matt@REDACTED (Matthew Wilson) Date: Thu, 14 Sep 2006 13:47:59 +0000 (UTC) Subject: [erlang-questions] Need advice on how to design a tagging web service References: Message-ID: On Thu 14 Sep 2006 04:29:55 AM EDT, Christian S wrote: > Since you never mention what db to use I assume it is mnesia. I was hoping to get some advice about backend db would be the best. What would I lose if I used SQLite or MySQL instead of mnesia? -- A better way of running series of SAS programs: http://overlook.homelinux.net/wilsonwiki/SasAndMakefiles From chsu79@REDACTED Thu Sep 14 15:56:37 2006 From: chsu79@REDACTED (Christian S) Date: Thu, 14 Sep 2006 15:56:37 +0200 Subject: [erlang-questions] Need advice on how to design a tagging web service In-Reply-To: References: Message-ID: No one-to-one mapping of erlang types to database types and no distribution of the database across several nodes (well, i hear mysql has (read only?) replication). On 9/14/06, Matthew Wilson wrote: > On Thu 14 Sep 2006 04:29:55 AM EDT, Christian S wrote: > > Since you never mention what db to use I assume it is mnesia. > > I was hoping to get some advice about backend db would be the best. > What would I lose if I used SQLite or MySQL instead of mnesia? > > From yarivvv@REDACTED Thu Sep 14 17:15:41 2006 From: yarivvv@REDACTED (Yariv Sadan) Date: Thu, 14 Sep 2006 11:15:41 -0400 Subject: [erlang-questions] Need advice on how to design a tagging web service In-Reply-To: References: Message-ID: <17244f480609140815i697617a5u778b1e1f39ae83d8@mail.gmail.com> Hi, As of version 5.0, MySQL supports full multi-master clustering, similar to Mnesia. In addition, since version 4.X, MySQL has supported master-slave replication. MySQL isn't as easy to use as Mnesia is from an Erlang application, and it imposes a semantic gap on Erlang programmers who now have to deal with a second language: SQL. ErlyDB does a pretty good job IMO at bridging this semantic gap, at least for commonly used queries. On the plus side, MySQL can handle very large data sets and it does optimize joins, but I think it doesn't do it as well as Postgres for queries that range a large number of tables. Regards, Yariv On 9/14/06, Christian S wrote: > No one-to-one mapping of erlang types to database types and no > distribution of the database across several nodes (well, i hear mysql has > (read only?) replication). > > On 9/14/06, Matthew Wilson wrote: > > On Thu 14 Sep 2006 04:29:55 AM EDT, Christian S wrote: > > > Since you never mention what db to use I assume it is mnesia. > > > > I was hoping to get some advice about backend db would be the best. > > What would I lose if I used SQLite or MySQL instead of mnesia? > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From ulf@REDACTED Thu Sep 14 17:24:05 2006 From: ulf@REDACTED (Ulf Wiger) Date: Thu, 14 Sep 2006 17:24:05 +0200 Subject: [erlang-questions] Need advice on how to design a tagging web service In-Reply-To: References: Message-ID: Den 2006-09-14 15:56:37 skrev Christian S : > No one-to-one mapping of erlang types to database types and no > distribution of the database across several nodes (well, ihear mysql has > (read only?) replication). MySQL Cluster has more than read-only replication. It may well be the fastest cluster database out there. I don't know of anyone who's used MySQL Cluster together with Erlang. It uses the standard MySQL Server front-end, so it shouldn't be _that_ difficult. The tight integration with Erlang is of course the main advantage with Mnesia. You can also get really fast access times with simple reads and writes on ram-based tables. Mnesia transactions start at around 2-300 usec on a modern machine. I can't imagine that you can get even close to that if you have to travel by socket or pipe through an SQL parser in order to get to an external database. Also, with mnesia, you can "cheat" and use dirty reads (and even 'ets' reads). This will give you access to data within tens of microseconds - which is impossible to match with any storage solution outside of erlang (at least in a UNIX or Win32 environment). Where an external DBMS beats mnesia hands-down is (1) really large datasets, (2) ad-hoc queries, (3) making the data available also to non-Erlang apps (like Excel), and (4) ubiquity. BR, Ulf W -- Ulf Wiger From shelton.ms@REDACTED Thu Sep 14 19:43:09 2006 From: shelton.ms@REDACTED (Shelton Tang) Date: Fri, 15 Sep 2006 01:43:09 +0800 Subject: [erlang-questions] Erlang in network mode on Windows XP In-Reply-To: <20060913231241.GB8058@memphis.lan> References: <20060912181441.GA16962@memphis> <95be1d3b0609121128g5dd3f7acudac0e5a00bd075fc@mail.gmail.com> <20060913231241.GB8058@memphis.lan> Message-ID: <27ccae8e0609141043s47170acbq78e0da55bd339cbb@mail.gmail.com> Can we try to enable Dr. Watson on WinXP so we can get a crash dump to track which module crash the VM? If my memory is right, the command is "drwtsn32 -i". On 9/14/06, Mickael Remond wrote: > Hello, > > * Vlad Dumitrescu [2006-09-12 19:28:44 +0100]: > > > Hi! > > > > On 9/12/06, Mickael Remond wrote: > > > Long time ago I have reported a problem on Windows XP with Erlang > > > started in network mode. > > > On some XP computer, erlang cannot start with -name or -sname whatever > > > the name you use (crash at startup). > > > > Might it be the same problem as someone had recently, the the DNS > > service wasn't properly configured? > > I do not think so because I tried to plug the network cable to go on the > net with this computer. The DNS was properly configured for that. > Do you have any reference on the post you are mentionning ? > > The crash message is strange. It seems that socket access is refused... > > -- > Micka?l R?mond > http://www.process-one.net/ > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From yarivvv@REDACTED Thu Sep 14 21:47:20 2006 From: yarivvv@REDACTED (Yariv Sadan) Date: Thu, 14 Sep 2006 15:47:20 -0400 Subject: [erlang-questions] constructing binaries question Message-ID: <17244f480609141247r6e281a90x574a25e929d90668@mail.gmail.com> hi, I'm writing some code to construct a binary SQL statement from some parameters (table name, field names, field values, etc). I'm not sure if I should iteratively add more chunks to a binary representing the statement, or if I should build the statement from a list of strings and then call list_to_binary at the end. What's the rule of thumb for working with binaries as opposed to lists in such a scenario? Thanks in advance, Yariv From yarivvv@REDACTED Thu Sep 14 21:58:32 2006 From: yarivvv@REDACTED (Yariv Sadan) Date: Thu, 14 Sep 2006 15:58:32 -0400 Subject: [erlang-questions] constructing binaries question In-Reply-To: <17244f480609141247r6e281a90x574a25e929d90668@mail.gmail.com> References: <17244f480609141247r6e281a90x574a25e929d90668@mail.gmail.com> Message-ID: <17244f480609141258u624397e2u5c5b162211882876@mail.gmail.com> Sorry, I also forgot to ask: is there a way of converting an atom to a binary without first converting it to a list? I noticed you can call term_to_binary and discard the first 4 bytes but that feels like cheating :) Yariv On 9/14/06, Yariv Sadan wrote: > hi, > > I'm writing some code to construct a binary SQL statement from some > parameters (table name, field names, field values, etc). I'm not sure > if I should iteratively add more chunks to a binary representing the > statement, or if I should build the statement from a list of strings > and then call list_to_binary at the end. What's the rule of thumb for > working with binaries as opposed to lists in such a scenario? > > Thanks in advance, > Yariv > From cyberlync@REDACTED Thu Sep 14 22:01:36 2006 From: cyberlync@REDACTED (Eric Merritt) Date: Thu, 14 Sep 2006 13:01:36 -0700 Subject: [erlang-questions] constructing binaries question In-Reply-To: <17244f480609141247r6e281a90x574a25e929d90668@mail.gmail.com> References: <17244f480609141247r6e281a90x574a25e929d90668@mail.gmail.com> Message-ID: > I'm writing some code to construct a binary SQL statement from some > parameters (table name, field names, field values, etc). I'm not sure > if I should iteratively add more chunks to a binary representing the > statement, or if I should build the statement from a list of strings > and then call list_to_binary at the end. What's the rule of thumb for > working with binaries as opposed to lists in such a scenario? It depends on what you want to do with it. Most of the io functions understands lists of binaries. That being the case I usually just build up a list of binaries and give it directly to the io function. If you are passing the binaries around in your function then a list of binaries may not be a good choice, because it makes pattern matching the binary much more difficult (you don't know where the boundaries of each piece are so you can't assume a contiguous binary for matching). From yarivvv@REDACTED Thu Sep 14 22:12:58 2006 From: yarivvv@REDACTED (Yariv Sadan) Date: Thu, 14 Sep 2006 16:12:58 -0400 Subject: [erlang-questions] constructing binaries question In-Reply-To: References: <17244f480609141247r6e281a90x574a25e929d90668@mail.gmail.com> Message-ID: <17244f480609141312w39713cf0ybe88d404d9417cf4@mail.gmail.com> I think your solution will work for me. The final goal is to send the query to a socket, so the structure doesn't matter for pattern matching. However, I do have to send the query after it's constructed to an intermediate gen_server, which then sends the query to a process that owns the socket. I know that sending binary messages involves less copying than sending other types of messages, so I'm tempted to construct the queries as binaries before sending them anywhere. What's the best approach in this scenario? Thanks Yariv > > It depends on what you want to do with it. Most of the io functions > understands lists of binaries. That being the case I usually just > build up a list of binaries and give it directly to the io function. > If you are passing the binaries around in your function then a list of > binaries may not be a good choice, because it makes pattern matching > the binary much more difficult (you don't know where the boundaries of > each piece are so you can't assume a contiguous binary for matching). > From cyberlync@REDACTED Thu Sep 14 22:23:09 2006 From: cyberlync@REDACTED (Eric Merritt) Date: Thu, 14 Sep 2006 13:23:09 -0700 Subject: [erlang-questions] constructing binaries question In-Reply-To: <17244f480609141312w39713cf0ybe88d404d9417cf4@mail.gmail.com> References: <17244f480609141247r6e281a90x574a25e929d90668@mail.gmail.com> <17244f480609141312w39713cf0ybe88d404d9417cf4@mail.gmail.com> Message-ID: If your pieces are already lists (strings) leave them as lists. You can still do the lists of lists thing, it works exactly like the list of binaries. Also the conversion will probably be more efficient in the io layer then up in you app. Weather or not this balances out the cost of coping is a good question, but not one that can be answered with out doing a bit of profiling in a running application. So just leave your individual parts in whatever format they are already in build them up into a list. On 9/14/06, Yariv Sadan wrote: > I think your solution will work for me. The final goal is to send the > query to a socket, so the structure doesn't matter for pattern > matching. However, I do have to send the query after it's constructed > to an intermediate gen_server, which then sends the query to a process > that owns the socket. I know that sending binary messages involves > less copying than sending other types of messages, so I'm tempted to > construct the queries as binaries before sending them anywhere. > > What's the best approach in this scenario? > > Thanks > Yariv > > > > > It depends on what you want to do with it. Most of the io functions > > understands lists of binaries. That being the case I usually just > > build up a list of binaries and give it directly to the io function. > > If you are passing the binaries around in your function then a list of > > binaries may not be a good choice, because it makes pattern matching > > the binary much more difficult (you don't know where the boundaries of > > each piece are so you can't assume a contiguous binary for matching). > > > From taavi@REDACTED Thu Sep 14 22:29:17 2006 From: taavi@REDACTED (Taavi Talvik) Date: Thu, 14 Sep 2006 23:29:17 +0300 Subject: [erlang-questions] constructing binaries question In-Reply-To: <17244f480609141312w39713cf0ybe88d404d9417cf4@mail.gmail.com> References: <17244f480609141247r6e281a90x574a25e929d90668@mail.gmail.com> <17244f480609141312w39713cf0ybe88d404d9417cf4@mail.gmail.com> Message-ID: <3f0f2eb10f64b8a17bcc46d818352bd1@uninet.ee> > I think your solution will work for me. The final goal is to send the > query to a socket, so the structure doesn't matter for pattern > matching. However, I do have to send the query after it's constructed > to an intermediate gen_server, which then sends the query to a process > that owns the socket. I know that sending binary messages involves > less copying than sending other types of messages, so I'm tempted to > construct the queries as binaries before sending them anywhere. > > What's the best approach in this scenario? As some gurus on this list have said: make it correct(working), optimize later When application is ready and performance is not acceptable, profile it. Quite likely you will find that time is spent somewhere else. best regards, taavi From bob@REDACTED Thu Sep 14 22:38:52 2006 From: bob@REDACTED (Bob Ippolito) Date: Thu, 14 Sep 2006 13:38:52 -0700 Subject: [erlang-questions] constructing binaries question In-Reply-To: <17244f480609141312w39713cf0ybe88d404d9417cf4@mail.gmail.com> References: <17244f480609141247r6e281a90x574a25e929d90668@mail.gmail.com> <17244f480609141312w39713cf0ybe88d404d9417cf4@mail.gmail.com> Message-ID: <6a36e7290609141338p2adfe034w11f65587bf8d3484@mail.gmail.com> On 9/14/06, Yariv Sadan wrote: > I think your solution will work for me. The final goal is to send the > query to a socket, so the structure doesn't matter for pattern > matching. However, I do have to send the query after it's constructed > to an intermediate gen_server, which then sends the query to a process > that owns the socket. I know that sending binary messages involves > less copying than sending other types of messages, so I'm tempted to > construct the queries as binaries before sending them anywhere. You could try using iolist_to_binary before sending the query to the gen_server, which will create a single binary from your heterogeneous list of lists and binaries. Profiling it first would make sense though. Sounds like you're worrying too much about problems that you don't have yet. -bob From yarivvv@REDACTED Thu Sep 14 22:41:58 2006 From: yarivvv@REDACTED (Yariv Sadan) Date: Thu, 14 Sep 2006 16:41:58 -0400 Subject: [erlang-questions] constructing binaries question In-Reply-To: <3f0f2eb10f64b8a17bcc46d818352bd1@uninet.ee> References: <17244f480609141247r6e281a90x574a25e929d90668@mail.gmail.com> <17244f480609141312w39713cf0ybe88d404d9417cf4@mail.gmail.com> <3f0f2eb10f64b8a17bcc46d818352bd1@uninet.ee> Message-ID: <17244f480609141341s13432828hc63ebb0b711a8ccd@mail.gmail.com> Hi Taavi, I totally agree with this rule :) I just wanted to know if there's a "rule of thumb" that the experts on this list are aware of that would save me the time spent on profiling and writing code that's a priori known to be inefficient :) (Btw, this code will go into ErlyDB, so if it's written pooly it would make many people's apps slower :) ) I think Eric's suggestions make a lot of sense, so I'll go with his solution. Thanks a lot! Best, Yariv From johan@REDACTED Fri Sep 15 07:48:29 2006 From: johan@REDACTED (jmT2) Date: Fri, 15 Sep 2006 07:48:29 +0200 Subject: [erlang-questions] Emacs and erlang shell arguments Message-ID: Something that I would probably find in an hour but if someone alread knows: How can I start the erlang shell under emacs with some arguments such as -name .. -cookie .. etc? I got as far as (set 'inferior-erlang-machine-options '("-name foo")) but it didn't quite work :-( johan ----------- Johan Montelius From raimo+erlang-questions@REDACTED Fri Sep 15 09:04:16 2006 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Fri, 15 Sep 2006 09:04:16 +0200 Subject: [erlang-questions] Emacs and erlang shell arguments In-Reply-To: References: Message-ID: <20060915070415.GA3779@erix.ericsson.se> You can set the enviroment variable ERL_FLAGS to "-name .. -cookie .. etc". On Fri, Sep 15, 2006 at 07:48:29AM +0200, jmT2 wrote: > > > Something that I would probably find in an hour but if someone alread > knows: > > How can I start the erlang shell under emacs with some arguments such as > -name .. -cookie .. etc? I got as far as (set > 'inferior-erlang-machine-options '("-name foo")) but it didn't quite work > :-( > > johan > > > > > ----------- > Johan Montelius > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From chsu79@REDACTED Fri Sep 15 13:41:13 2006 From: chsu79@REDACTED (Christian S) Date: Fri, 15 Sep 2006 13:41:13 +0200 Subject: [erlang-questions] The decreased list traffic Message-ID: What happened with the high list traffic? We just had 20 mails a day, now it seems like we have less than half. Did 90% of the subscribers change to daily digest subscriptions so there are less "impulse" replies in threads? From simonpeterchappell@REDACTED Fri Sep 15 14:25:11 2006 From: simonpeterchappell@REDACTED (Simon Chappell) Date: Fri, 15 Sep 2006 07:25:11 -0500 Subject: [erlang-questions] The decreased list traffic In-Reply-To: References: Message-ID: <8ed733900609150525i3005cbd6me985c4e8168ebd66@mail.gmail.com> On 9/15/06, Christian S wrote: > What happened with the high list traffic? > > We just had 20 mails a day, now it seems like we have less than half. > > Did 90% of the subscribers change to daily digest subscriptions so > there are less "impulse" replies in threads? I think some of us felt a little guilty asking our newbie questions. My reason is busyness, working on my photography stuff, but once that's up and running, expect me to be back with some more basic questions. Simon -- simonpeter.org | simonpeter.com | techbook.info From james.hague@REDACTED Fri Sep 15 15:41:15 2006 From: james.hague@REDACTED (James Hague) Date: Fri, 15 Sep 2006 08:41:15 -0500 Subject: [erlang-questions] The decreased list traffic In-Reply-To: References: Message-ID: On 9/15/06, Christian S wrote: > What happened with the high list traffic? > > We just had 20 mails a day, now it seems like we have less than half. For me, it coincided with the change in how the mail list is handled. I used to follow the mailing list via http://www.erlang.org/ml-archive/erlang-questions/, which I found simpler than gmail, but it's no longer updated. I'm sure there's a new archive, but I've been slow to switch over to it. James From dmitriid@REDACTED Fri Sep 15 17:11:47 2006 From: dmitriid@REDACTED (Dmitrii Dimandt) Date: Fri, 15 Sep 2006 18:11:47 +0300 Subject: [erlang-questions] The decreased list traffic In-Reply-To: <8ed733900609150525i3005cbd6me985c4e8168ebd66@mail.gmail.com> References: <8ed733900609150525i3005cbd6me985c4e8168ebd66@mail.gmail.com> Message-ID: Well, expect newbie questions from me in the following weeks, as I started my own project in Erlang, http://code.google.com/p/orcas/ :)) On 9/15/06, Simon Chappell wrote: > > On 9/15/06, Christian S wrote: > > What happened with the high list traffic? > > > > We just had 20 mails a day, now it seems like we have less than half. > > > > Did 90% of the subscribers change to daily digest subscriptions so > > there are less "impulse" replies in threads? > > I think some of us felt a little guilty asking our newbie questions. > My reason is busyness, working on my photography stuff, but once > that's up and running, expect me to be back with some more basic > questions. > > Simon > > -- > simonpeter.org | simonpeter.com | techbook.info > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From raimo+erlang-questions@REDACTED Fri Sep 15 17:26:58 2006 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Fri, 15 Sep 2006 17:26:58 +0200 Subject: [erlang-questions] : The decreased list traffic In-Reply-To: References: Message-ID: <20060915152658.GA25071@erix.ericsson.se> On Fri, Sep 15, 2006 at 08:41:15AM -0500, James Hague wrote: > On 9/15/06, Christian S wrote: > > What happened with the high list traffic? > > > > We just had 20 mails a day, now it seems like we have less than half. > > For me, it coincided with the change in how the mail list is handled. > I used to follow the mailing list via > http://www.erlang.org/ml-archive/erlang-questions/, which I found > simpler than gmail, but it's no longer updated. I'm sure there's a > new archive, but I've been slow to switch over to it. > http://www.erlang.org/pipermail/erlang-questions/index.html (there is a link from http://www.erlang.org/faq.html) > James > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From francesco@REDACTED Fri Sep 15 19:25:36 2006 From: francesco@REDACTED (Francesco Cesarini) Date: Fri, 15 Sep 2006 18:25:36 +0100 Subject: [erlang-questions] : The decreased list traffic In-Reply-To: <20060915152658.GA25071@erix.ericsson.se> References: <20060915152658.GA25071@erix.ericsson.se> Message-ID: <450AE210.6030906@erlang-consulting.com> >>> just had 20 mails a day, now it seems like we have less than half. >>> >>> >>For me, it coincided with the change in how the mail list is handled. >>I used to follow the mailing list via >>http://www.erlang.org/ml-archive/erlang-questions/, which I found >>simpler than gmail, but it's no longer updated. I'm sure there's a >>new archive, but I've been slow to switch over to it. >> >> Based on the traffic reports on trapexit, about 100 people are currently following the mailing list on http://forum.trapexit.org/viewforum.php?f=2 on a daily basis as returning visitors. Francesco -- http://www.erlang-consulting.com From darrinth@REDACTED Sat Sep 16 02:58:10 2006 From: darrinth@REDACTED (Darrin Thompson) Date: Fri, 15 Sep 2006 20:58:10 -0400 Subject: [erlang-questions] Design to Avoid Races Message-ID: I've been building a comet app with yaws, and I've run into a mental block trying to get something "right". Most of the examples in tutorials assume that an app is built out of a number of processes communicating. Suppose I have two users chatting, and my design calles for each user to have a process. The processes were spawned when users created sessions. The processes were linked when at some point the users chose to communicate. But suppose that one of the processes dies. If a supervisor restarts it, it no longer knows about it's counterpart in the chat. If the counterpart process was linked, presumably it has been killed and restarted too. But now two users have lost contact. Suppose the whole node is restarted. Now a bunch of users have lost their state and have to find each other again. Now suppose I keep the state of each process in an mnesia table. So far so good. But if one process starts before it's counterpart and the user starts chatting... or it dies before the counterpart is started... now I have a bunch of race conditions and my head explodes. Clearly I'm going down a mental rathole. With erlang this stuff is supposed to be easier right? Can one of you veterans clear up a n00b? -- Darrin From hev@REDACTED Sat Sep 16 04:46:38 2006 From: hev@REDACTED (Evgeniy Khramtsov) Date: Sat, 16 Sep 2006 12:46:38 +1000 Subject: [erlang-questions] Design to Avoid Races In-Reply-To: References: Message-ID: <450B658E.7070407@sbyt.amur.elektra.ru> Darrin Thompson wrote: > The processes were linked when at some point the users chose to communicate. I think that is not a good idea to link processes in this case. You better to create a master process called, let's say, "router" which will route chat messages between processes. Also you can put some other stuff in router - packet filtering, address rewriting etc. :) > Now suppose I keep the state of each process in an mnesia table. Yes, that's a good idea. Also this approach will be "cluster transparent" for the router. But don't forget to delete state on processes terminating. That is simple to do via terminate/3 if you use gen_fsm behaviour for client processes. From johan@REDACTED Sat Sep 16 07:51:03 2006 From: johan@REDACTED (jmT2) Date: Sat, 16 Sep 2006 07:51:03 +0200 Subject: [erlang-questions] Emacs and erlang shell arguments In-Reply-To: <20060915070415.GA3779@erix.ericsson.se> References: <20060915070415.GA3779@erix.ericsson.se> Message-ID: Thanks, but then I cant easily have multiple erlang shells with different names. The trick was to do: (set 'inferior-erlang-machine-options '("-name" "foo")) And now I'm only fighting the problems with running distributed on XP. Works on two machines of three, close but no cigar :-( Any hints are welcome. Johan Den 2006-09-15 09:04:16 skrev Raimo Niskanen : > You can set the enviroment variable ERL_FLAGS to > "-name .. -cookie .. etc". > > > > On Fri, Sep 15, 2006 at 07:48:29AM +0200, jmT2 wrote: >> >> >> Something that I would probably find in an hour but if someone alread >> knows: >> >> How can I start the erlang shell under emacs with some arguments such as >> -name .. -cookie .. etc? I got as far as (set >> 'inferior-erlang-machine-options '("-name foo")) but it didn't quite >> work >> :-( >> >> johan >> >> >> >> >> ----------- >> Johan Montelius >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions > -- ----------- Johan Montelius jmT2 From roger.larsson@REDACTED Sat Sep 16 08:16:39 2006 From: roger.larsson@REDACTED (Roger Larsson) Date: Sat, 16 Sep 2006 08:16:39 +0200 Subject: [erlang-questions] Design to Avoid Races In-Reply-To: References: Message-ID: <200609160816.39404.roger.larsson@norran.net> On Saturday 16 September 2006 02:58, Darrin Thompson wrote: > I've been building a comet app with yaws, and I've run into a mental > block trying to get something "right". > > Most of the examples in tutorials assume that an app is built out of a > number of processes communicating. > > Suppose I have two users chatting, and my design calles for each user > to have a process. The processes were spawned when users created > sessions. The processes were linked when at some point the users chose > to communicate. The user is interested in chatting with a real person - not a pid. So I would store the friends Nick (and a cookie) in my process. And have a name server where everyone register their pid, and link to them. When the friend process dies. Query the name process. Name process could delay answers for a while to give the peer time to restart. Connection reestablished! I would avoid to have a router process - it sounds like a bottleneck... Note that the user processes could be located on different nodes. And the name server could be distributed as well, store names, cookie in Mnesia. Other ideas? /RogerL From jahakala@REDACTED Sat Sep 16 20:36:52 2006 From: jahakala@REDACTED (Jani Hakala) Date: Sat, 16 Sep 2006 21:36:52 +0300 Subject: [erlang-questions] Emacs and erlang shell arguments In-Reply-To: (jmT2's message of "Sat\, 16 Sep 2006 07\:51\:03 +0200") References: <20060915070415.GA3779@erix.ericsson.se> Message-ID: <8764fnfykb.fsf@pingviini.kortex.jyu.fi> jmT2 writes: > Thanks, but then I cant easily have multiple erlang shells > with different names. The trick was to do: > > (set 'inferior-erlang-machine-options '("-name" "foo")) > > And now I'm only fighting the problems with running distributed on XP. > Works on two machines of three, close but no cigar :-( Any hints are > welcome. > I guess that there are not many hints available unless the problem is DNS or firewall related. Can you tell if there are any major differences in those windows XP computers? Like windows xp home vs pro, different firewall program or settings, different antivirus protection, different processor, etc. It's a pity that there seems to be no linux strace program equivalent for windows. Jani Hakala From vladdu55@REDACTED Sat Sep 16 21:02:38 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Sat, 16 Sep 2006 20:02:38 +0100 Subject: [erlang-questions] Emacs and erlang shell arguments In-Reply-To: <8764fnfykb.fsf@pingviini.kortex.jyu.fi> References: <20060915070415.GA3779@erix.ericsson.se> <8764fnfykb.fsf@pingviini.kortex.jyu.fi> Message-ID: <95be1d3b0609161202n608316cdve2a57a729593f3b7@mail.gmail.com> On 9/16/06, Jani Hakala wrote: > It's a pity that there seems to be no linux strace program equivalent > for windows. You mean like for example the one at http://www.softpedia.com/get/Programming/Debuggers-Decompilers-Dissasemblers/Strace%20NT.shtml or http://www.bindview.com/Services/RAZOR/Utilities/Windows/strace_readme.cfm ? ;-) best regards, Vlad From jahakala@REDACTED Sat Sep 16 22:26:45 2006 From: jahakala@REDACTED (Jani Hakala) Date: Sat, 16 Sep 2006 23:26:45 +0300 Subject: [erlang-questions] Emacs and erlang shell arguments In-Reply-To: <95be1d3b0609161202n608316cdve2a57a729593f3b7@mail.gmail.com> (Vlad Dumitrescu's message of "Sat\, 16 Sep 2006 20\:02\:38 +0100") References: <20060915070415.GA3779@erix.ericsson.se> <8764fnfykb.fsf@pingviini.kortex.jyu.fi> <95be1d3b0609161202n608316cdve2a57a729593f3b7@mail.gmail.com> Message-ID: <87y7sjeewq.fsf@pingviini.kortex.jyu.fi> "Vlad Dumitrescu" writes: > On 9/16/06, Jani Hakala wrote: >> It's a pity that there seems to be no linux strace program >> equivalent for windows. > > You mean like for example the one at > > http://www.softpedia.com/get/Programming/Debuggers-Decompilers-Dissasemblers/Strace%20NT.shtml > I now tested this one briefly. In documentation it is said that '- Does not trace child processes created by the traced process - Does not trace functions which are called by using GetProcAddress method' This could mean that device drivers can't be traced if +A is used. Windows port of erlang is built so that is uses GetProcAddress in the very beginning of erl.c in order to call win_erlexec. Also in the inet_drv.c GetProcAddress is used and some sort of jumptable way to call socket functions is used instead of direct calls. It would be nice to hear why this actually is necessary. I guess StraceNT program could work a little bit better otherwise so that it might be possible to see what socket related functions return. In any case StraceNT displays calls like LoadLibrary("beam.dll") "[T2644] LoadLibraryA(662b9830, 0, 24a758, 0, ...) = 71ab0000" This doesn't look so good, I would except to see LoadLibrary("beam.dll") I guess linux strace could also have some trouble if dlopen and dlsym are used. > or > > http://www.bindview.com/Services/RAZOR/Utilities/Windows/strace_readme.cfm > I found this one earlier and decided that I don't want to touch it. It requires changing HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\EnforceWriteProtection 'This disables the kernel from checking for errant memory overwrites...' Support for 'Windows XP' is said to be preliminary. Jani Hakala From vladdu55@REDACTED Sat Sep 16 22:46:06 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Sat, 16 Sep 2006 21:46:06 +0100 Subject: [erlang-questions] Emacs and erlang shell arguments In-Reply-To: <87y7sjeewq.fsf@pingviini.kortex.jyu.fi> References: <20060915070415.GA3779@erix.ericsson.se> <8764fnfykb.fsf@pingviini.kortex.jyu.fi> <95be1d3b0609161202n608316cdve2a57a729593f3b7@mail.gmail.com> <87y7sjeewq.fsf@pingviini.kortex.jyu.fi> Message-ID: <95be1d3b0609161346u24630ccbucbacc3b83fe3c8e5@mail.gmail.com> > >> It's a pity that there seems to be no linux strace program > >> equivalent for windows. > > > > You mean like for example the one at Well, if you had said "there seems to be no strace that works" I wouldn't have assumed you didn't found these. I haven't tested them, but I thought they might be useful (maybe the calls that are pertinent to the problem will be shown in the trace) regards, Vlad From yarivvv@REDACTED Sat Sep 16 22:59:27 2006 From: yarivvv@REDACTED (Yariv Sadan) Date: Sat, 16 Sep 2006 16:59:27 -0400 Subject: [erlang-questions] ErlSQL: easy expression and generation of SQL statements in Erlang Message-ID: <17244f480609161359w75a772eaua97b239c5f71e7c4@mail.gmail.com> Hi, I created a small library, called ErlSQL, for expressing and genering SQL statements in Erlang. ErlSQL makes it easy to dynamically generate SQL-injection free statements from Erlang. ErlSQL will be included in ErlyDB, but you can also use it independently if you're working with the MySQL or Postgres driver directly, for instance. You can grab it at http://code.google.com/p/erlsql For more information, visit http://yarivsblog.com/articles/2006/09/16/introducing-erlsql-easy-expression-and-generation-of-sql-statements-in-erlang. Best regards, Yariv From ugglan@REDACTED Sun Sep 17 00:39:08 2006 From: ugglan@REDACTED (=?ISO-8859-1?Q?Tobias_L=F6fgren?=) Date: Sun, 17 Sep 2006 00:39:08 +0200 Subject: [erlang-questions] Possible bug in inets http:request? Message-ID: <5c402a550609161539s44b8907bg6d04d7766455598c@mail.gmail.com> I'm using inets http:request to construct REST calls to a web service and noticed some odd behaviour which boiled down to this: When the response contains nothing, ie. complete headers, but a zero-length body, the function hangs for some time. To try it out: http:request("http://combubo.com/test.txt"). The call returns after ~ 15 seconds. Other servers take minutes to break the connection. I located this in httpc_response.erl: whole_body(Body, Length) -> case size(Body) of N when N < Length, N > 0-> {?MODULE, whole_body, [Body, Length]}; N when N >= Length, Length > 0 -> %% Potential trailing garbage will be thrown away in %% format_response/1 Some servers may send a 100-continue %% response without the client requesting it through an %% expect header in this case the trailing bytes may be %% part of the real response message. {ok, Body}; _ -> {?MODULE, whole_body, [Body, Length]} end. and it seems this code doesn't handle the case of Length == 0, so I simply changed it to: case size(Body) of N when N < Length, N >= 0-> {?MODULE, whole_body, [Body, Length]}; N when N >= Length, Length >= 0 -> which seems to work fine for me, empty body responses now return right away. Anyone know if I might have broken anything else by this patch, am I completely barking up the wrong tree? /Tobias -------------- next part -------------- An HTML attachment was scrubbed... URL: From ml.cyresse@REDACTED Sun Sep 17 10:08:06 2006 From: ml.cyresse@REDACTED (Liam Clarke) Date: Sun, 17 Sep 2006 20:08:06 +1200 Subject: [erlang-questions] Good Erlang style? Message-ID: Hi all, A quick question. From my Python background I'm mindful of a implied "right way" of doing things, and I'm wondering about the Zen of Erlang, as it were. Just contemplating error conditions currently. Is the use of catch and throw the usual style, or is evaluation of returned values? Also, would I be imposing if I posted links to my completed code for the evaluation of experienced Erlang developers? My code looks a tad kludgey , and I tend to agree with ESR on bad looking code being bad - so I'd value pointers on my style. When I started learning Lisp I found I was trying to impose Python styles and idioms upon it and it was resulting in quite a struggle with the code - when I started coding in a functional manner, Lisp started getting easier. I have a nagging suspicion I'm doing the same to Erlang at the moment. Regards, Liam Clarke From vladdu55@REDACTED Sun Sep 17 11:17:24 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Sun, 17 Sep 2006 10:17:24 +0100 Subject: [erlang-questions] ErlSQL: easy expression and generation of SQL statements in Erlang In-Reply-To: <17244f480609161359w75a772eaua97b239c5f71e7c4@mail.gmail.com> References: <17244f480609161359w75a772eaua97b239c5f71e7c4@mail.gmail.com> Message-ID: <95be1d3b0609170217v222edfbbgae641e55df37935b@mail.gmail.com> Hi, > I created a small library, called ErlSQL, for expressing and genering > SQL statements in Erlang. ErlSQL makes it easy to dynamically generate > SQL-injection free statements from Erlang. It looks cool, but feels like it could need some polishing. For example, why {delete,project,{a,'=',5}} -> "DELETE FROM project WHERE (a = 5)" and not {delete,project,{where, {a,'=',5}}} -> "DELETE FROM project WHERE (a = 5)" making it consistent with {select,{foo,as,bar},{from,{baz,as,blub}}} -> "SELECT foo AS bar FROM baz AS blub" Also, it also feels it's just sql with some {} added here and there... I mean that is I have to know the exact syntax of the sql statement, then I can just as well compose it directly. Building sql statements should be done only from the db layer, so regular application developers will be insulated from it anyway. That said, I think it's a good start and it opens interesting possibilities. best regards, Vlad From sanjaya@REDACTED Sun Sep 17 11:45:39 2006 From: sanjaya@REDACTED (Sanjaya Vitharana) Date: Sun, 17 Sep 2006 15:15:39 +0530 Subject: [erlang-questions] inets - traverse exit from apply ? Message-ID: <003201c6da3e$0eb37fb0$9a0a10ac@wavenet.lk> Hi ... all, After running the system for 6 months time inets begin to crash, Try to replace the original function with below 3 lines to make sure it is not other than the http call to inets httpd. read_prof(SessionID,Env,Input)-> io:fwrite("***blocked for testing***~n"), mod_esi:deliver(SessionID, "{error,blocked}"). %%-- for testing same result, so my doubt is the inet httpd. the error_log, error_disk_log.1 of inets show the below errors ? what those means ? Need quick fix. Anyone have experience with this error ? Please help. Sanjaya Vitharana ------------------------------------------------------ System Info: [root@REDACTED vm_profile]# erl -version Erlang (THREADS,HIPE) (BEAM) emulator version 5.4.10 [root@REDACTED vm_profile]# uname -a Linux prof 2.4.21-27.ELsmp #1 SMP Wed Dec 1 21:59:02 EST 2004 i686 i686 i386 GNU/Linux [root@REDACTED vm_profile]# date Sun Sep 17 14:49:32 IST 2006 ------------------------------------------------------ error_log -- inets [17/Sep/2006:09:20:23 +0530] reporting error: traverse exit from apply: mod_esi:do => {mod_esi_linked_process_died,<0.221.0>,normal} [17/Sep/2006:09:20:25 +0530] reporting error: traverse exit from apply: mod_esi:do => {mod_esi_linked_process_died,<0.225.0>,normal} [17/Sep/2006:10:05:56 +0530] server crash for 192.168.129.20, reason: "Error reading request: No request received on keep-alive connectionbefore server side timeout" [17/Sep/2006:12:50:08 +0530] reporting error: traverse exit from apply: mod_esi:do => {mod_esi_linked_process_died,<0.214.0>,normal} [17/Sep/2006:12:50:10 +0530] reporting error: traverse exit from apply: mod_esi:do => {mod_esi_linked_process_died,<0.218.0>,normal} ------------------------------------------------------ error_disk_log.1 -- inets {mod_esi_linked_process_died,<0.305.0>,normal}[17/Sep/2006:09:20:23 +0530] reporting error: traverse exit from apply: mod_esi:do => {mod_esi_linked_process_died,<0.221.0>,normal}[17/Sep/2006:09:20:25 +0530] reporting error: traverse exit from apply: mod_esi:do => {mod_esi_linked_process_died,<0.225.0>,normal}[17/Sep/2006:10:05:56 +0530] server crash for 192.168.129.20, reason: "Error reading request: No request received on keep-alive connectionbefore server side timeout" [17/Sep/2006:12:50:08 +0530] reporting error: traverse exit from apply: mod_esi:do => {mod_esi_linked_process_died,<0.214.0>,normal}[17/Sep/2006:12:50:10 +0530] reporting error: traverse exit from apply: mod_esi:do => {mod_esi_linked_process_died,<0.218.0>,normal} ------------------------------------------------------ -------------- next part -------------- An HTML attachment was scrubbed... URL: From chsu79@REDACTED Sun Sep 17 12:53:34 2006 From: chsu79@REDACTED (Christian S) Date: Sun, 17 Sep 2006 12:53:34 +0200 Subject: [erlang-questions] Good Erlang style? In-Reply-To: References: Message-ID: I suggest you look at section 4.3 "Error handling philosophy" and forward from Joe Armstrong's Ph.D. thesis: "Making reliable distributed systems in the presence of sodware errors" You can find the pdf at: http://www.sics.se/~joe/index.html Actually, read the whole thesis. On 9/17/06, Liam Clarke wrote: > Hi all, > > A quick question. From my Python background I'm mindful of a implied > "right way" of doing things, and I'm wondering about the Zen of > Erlang, as it were. > > Just contemplating error conditions currently. Is the use of catch and > throw the usual style, or is evaluation of returned values? From chsu79@REDACTED Sun Sep 17 12:58:19 2006 From: chsu79@REDACTED (Christian S) Date: Sun, 17 Sep 2006 12:58:19 +0200 Subject: [erlang-questions] Possible bug in inets http:request? In-Reply-To: <5c402a550609161539s44b8907bg6d04d7766455598c@mail.gmail.com> References: <5c402a550609161539s44b8907bg6d04d7766455598c@mail.gmail.com> Message-ID: Yes, the http client in OTP contains bugs. Nobody seem to care because you can use ibrowse instead, which is a very good http client. It is in jungerl. From ml.cyresse@REDACTED Sun Sep 17 12:58:27 2006 From: ml.cyresse@REDACTED (Liam Clarke) Date: Sun, 17 Sep 2006 22:58:27 +1200 Subject: [erlang-questions] Good Erlang style? In-Reply-To: References: Message-ID: Thank you, will do... admittedly, the word thesis scares me a little, but I'll give it a shot. On 9/17/06, Christian S wrote: > I suggest you look at section 4.3 "Error handling philosophy" and > forward from Joe Armstrong's Ph.D. thesis: "Making reliable > distributed systems in the presence of sodware errors" > > You can find the pdf at: > http://www.sics.se/~joe/index.html > > Actually, read the whole thesis. > > On 9/17/06, Liam Clarke wrote: > > Hi all, > > > > A quick question. From my Python background I'm mindful of a implied > > "right way" of doing things, and I'm wondering about the Zen of > > Erlang, as it were. > > > > Just contemplating error conditions currently. Is the use of catch and > > throw the usual style, or is evaluation of returned values? > From ulf.wiger@REDACTED Sun Sep 17 13:48:15 2006 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Sun, 17 Sep 2006 13:48:15 +0200 Subject: [erlang-questions] the semantics of dict:append/3 Message-ID: During a recent QuickCheck course, one of our guys (Johan Tj?der) started playing with applying QuickCheck to the dict.erl module. The following behaviour came as a surprise: 1> D0 = dict:new(). {dict,0, 16, 16, 8, 80, 48, {[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]}, {{[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]}}} 2> D1 = dict:append(a, 1, D0). {dict,1, 16, 16, 8, 80, 48, {[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]}, {{[],[[a,1]],[],[],[],[],[],[],[],[],[],[],[],[],[],[]}}} 3> dict:find(a,D1). {ok,[1]} The documentation has this to say about dict:append/3: "This function appends a new Value to the current list of values associated with Key. An exception is generated if the initial value associated with Key is not a list of values." (http://www.erlang.org/doc/doc-5.5.1/lib/stdlib-1.14.1/doc/html/dict.html#append/3) I would have thought that the initial value associated with a key not present in the dictionary is undefined - not the empty list. Shouldn't then the above experiment result in a badarg? BR, Ulf Wiger From ulf.wiger@REDACTED Sun Sep 17 14:01:57 2006 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Sun, 17 Sep 2006 14:01:57 +0200 Subject: [erlang-questions] ErlSQL: easy expression and generation of SQLstatements in Erlang In-Reply-To: <17244f480609161359w75a772eaua97b239c5f71e7c4@mail.gmail.com> Message-ID: Interesting, One thing to explore might be what Dialyzer can make of it. If the structure is regular enough, and the functions taking apart the erlSQL structure use explicit pattern matching, Dialyzer should be able to detect a reasonable number of malformed expressions already at compile-time, I think. This would certainly add some value over writing SQL as strings in your code. BR, Ulf W > -----Original Message----- > From: erlang-questions-bounces@REDACTED > [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Yariv Sadan > Sent: den 16 september 2006 22:59 > To: erlang-questions > Subject: [erlang-questions] ErlSQL: easy expression and > generation of SQLstatements in Erlang > > Hi, > > I created a small library, called ErlSQL, for expressing and > genering SQL statements in Erlang. ErlSQL makes it easy to > dynamically generate SQL-injection free statements from > Erlang. ErlSQL will be included in ErlyDB, but you can also > use it independently if you're working with the MySQL or > Postgres driver directly, for instance. > > You can grab it at http://code.google.com/p/erlsql > > For more information, visit > http://yarivsblog.com/articles/2006/09/16/introducing-erlsql-e > asy-expression-and-generation-of-sql-statements-in-erlang. > > Best regards, > Yariv > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From yarivvv@REDACTED Sun Sep 17 14:17:00 2006 From: yarivvv@REDACTED (Yariv Sadan) Date: Sun, 17 Sep 2006 08:17:00 -0400 Subject: [erlang-questions] ErlSQL: easy expression and generation of SQL statements in Erlang In-Reply-To: <95be1d3b0609170217v222edfbbgae641e55df37935b@mail.gmail.com> References: <17244f480609161359w75a772eaua97b239c5f71e7c4@mail.gmail.com> <95be1d3b0609170217v222edfbbgae641e55df37935b@mail.gmail.com> Message-ID: <17244f480609170517h13d5803cme396b0e504901d66@mail.gmail.com> On 9/17/06, Vlad Dumitrescu wrote: > Hi, > > > I created a small library, called ErlSQL, for expressing and genering > > SQL statements in Erlang. ErlSQL makes it easy to dynamically generate > > SQL-injection free statements from Erlang. > > It looks cool, but feels like it could need some polishing. > > For example, why > > {delete,project,{a,'=',5}} -> > "DELETE FROM project WHERE (a = 5)" > > and not > > {delete,project,{where, {a,'=',5}}} -> > "DELETE FROM project WHERE (a = 5)" > > making it consistent with > > {select,{foo,as,bar},{from,{baz,as,blub}}} -> > "SELECT foo AS bar FROM baz AS blub" Good point. I will make this change. > > Also, it also feels it's just sql with some {} added here and there... > I mean that is I have to know the exact syntax of the sql statement, > then I can just as well compose it directly. Building sql statements > should be done only from the db layer, so regular application > developers will be insulated from it anyway. It depends on your purporse. Although some SQL statements can be constructed automatically in ErlyDB by making certain assumptions about the user's intentions, there are always cases where users need more manual control. Making ErlSQL look like SQL was necessary to make it easy to learn and to make it extensible to cover more of the SQL language. The 'ideal' scenario would be for Erlang developers to never have to construct SQL statements from strings directly because ErlSQL statements are easier to build dynamically in Erlang and because they are much more resistent to SQL injection attacks. I see ErlSQL as a middle layer between ErlyDB and the database driver. You will find it helpful in scenarios that ErlyDB can't handle very well, yet it will give you a higher level of abstraction and a lesser semantic gap when working with your database driver directly. In fact, ErlyDB will use ErlSQL to faciliate compatibility with non-SQL drivers -- esp Mnesia -- without having to parse SQL strings. It's also convenient to have your IDE indent your statements and balance all your brackets and parentheses :) > > That said, I think it's a good start and it opens interesting possibilities. Thanks for the feedback! Let me know if you have any other suggestions! Best, Yariv From sanjaya@REDACTED Sun Sep 17 14:21:17 2006 From: sanjaya@REDACTED (Sanjaya Vitharana) Date: Sun, 17 Sep 2006 17:51:17 +0530 Subject: [erlang-questions] Fw: inets - traverse exit from apply ? Message-ID: <003501c6da53$c7689b20$9a0a10ac@wavenet.lk> Hi ... all, Problem was the file size of inets access_log 2,147,483,647 bytes (~2.00 GB) Are there any way to rotate it ? Thanks in advance. Sanjaya Vitharana ----- Original Message ----- From: Sanjaya Vitharana To: erlang-questions@REDACTED Sent: Sunday, 17 September 2006 03:15 pm Subject: [erlang-questions] inets - traverse exit from apply ? Hi ... all, After running the system for 6 months time inets begin to crash, Try to replace the original function with below 3 lines to make sure it is not other than the http call to inets httpd. read_prof(SessionID,Env,Input)-> io:fwrite("***blocked for testing***~n"), mod_esi:deliver(SessionID, "{error,blocked}"). %%-- for testing same result, so my doubt is the inet httpd. the error_log, error_disk_log.1 of inets show the below errors ? what those means ? Need quick fix. Anyone have experience with this error ? Please help. Sanjaya Vitharana ------------------------------------------------------ System Info: [root@REDACTED vm_profile]# erl -version Erlang (THREADS,HIPE) (BEAM) emulator version 5.4.10 [root@REDACTED vm_profile]# uname -a Linux prof 2.4.21-27.ELsmp #1 SMP Wed Dec 1 21:59:02 EST 2004 i686 i686 i386 GNU/Linux [root@REDACTED vm_profile]# date Sun Sep 17 14:49:32 IST 2006 ------------------------------------------------------ error_log -- inets [17/Sep/2006:09:20:23 +0530] reporting error: traverse exit from apply: mod_esi:do => {mod_esi_linked_process_died,<0.221.0>,normal} [17/Sep/2006:09:20:25 +0530] reporting error: traverse exit from apply: mod_esi:do => {mod_esi_linked_process_died,<0.225.0>,normal} [17/Sep/2006:10:05:56 +0530] server crash for 192.168.129.20, reason: "Error reading request: No request received on keep-alive connectionbefore server side timeout" [17/Sep/2006:12:50:08 +0530] reporting error: traverse exit from apply: mod_esi:do => {mod_esi_linked_process_died,<0.214.0>,normal} [17/Sep/2006:12:50:10 +0530] reporting error: traverse exit from apply: mod_esi:do => {mod_esi_linked_process_died,<0.218.0>,normal} ------------------------------------------------------ error_disk_log.1 -- inets {mod_esi_linked_process_died,<0.305.0>,normal}[17/Sep/2006:09:20:23 +0530] reporting error: traverse exit from apply: mod_esi:do => {mod_esi_linked_process_died,<0.221.0>,normal}[17/Sep/2006:09:20:25 +0530] reporting error: traverse exit from apply: mod_esi:do => {mod_esi_linked_process_died,<0.225.0>,normal}[17/Sep/2006:10:05:56 +0530] server crash for 192.168.129.20, reason: "Error reading request: No request received on keep-alive connectionbefore server side timeout" [17/Sep/2006:12:50:08 +0530] reporting error: traverse exit from apply: mod_esi:do => {mod_esi_linked_process_died,<0.214.0>,normal}[17/Sep/2006:12:50:10 +0530] reporting error: traverse exit from apply: mod_esi:do => {mod_esi_linked_process_died,<0.218.0>,normal} ------------------------------------------------------ -------------------------------------------------------------------------------- _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From yarivvv@REDACTED Sun Sep 17 14:32:35 2006 From: yarivvv@REDACTED (Yariv Sadan) Date: Sun, 17 Sep 2006 08:32:35 -0400 Subject: [erlang-questions] ErlSQL: easy expression and generation of SQLstatements in Erlang In-Reply-To: References: <17244f480609161359w75a772eaua97b239c5f71e7c4@mail.gmail.com> Message-ID: <17244f480609170532r6cd4659dp232f34ff0c5de0ad@mail.gmail.com> Hi, I think Dialyzer should be able to help here, at least to a degree. There's definitely a lot of pattern matching and regularity in the code. I'm not too familiar with Dialyzer's capabilities, though, so I don't know for certain. Yariv On 9/17/06, Ulf Wiger (TN/EAB) wrote: > > Interesting, > > One thing to explore might be what Dialyzer can make of it. > If the structure is regular enough, and the functions > taking apart the erlSQL structure use explicit pattern > matching, Dialyzer should be able to detect a reasonable > number of malformed expressions already at compile-time, > I think. This would certainly add some value over writing > SQL as strings in your code. > > BR, > Ulf W > > > -----Original Message----- > > From: erlang-questions-bounces@REDACTED > > [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Yariv Sadan > > Sent: den 16 september 2006 22:59 > > To: erlang-questions > > Subject: [erlang-questions] ErlSQL: easy expression and > > generation of SQLstatements in Erlang > > > > Hi, > > > > I created a small library, called ErlSQL, for expressing and > > genering SQL statements in Erlang. ErlSQL makes it easy to > > dynamically generate SQL-injection free statements from > > Erlang. ErlSQL will be included in ErlyDB, but you can also > > use it independently if you're working with the MySQL or > > Postgres driver directly, for instance. > > > > You can grab it at http://code.google.com/p/erlsql > > > > For more information, visit > > http://yarivsblog.com/articles/2006/09/16/introducing-erlsql-e > > asy-expression-and-generation-of-sql-statements-in-erlang. > > > > Best regards, > > Yariv > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From alex.arnon@REDACTED Sun Sep 17 15:22:54 2006 From: alex.arnon@REDACTED (Alex Arnon) Date: Sun, 17 Sep 2006 16:22:54 +0300 Subject: [erlang-questions] Extending PHP with Erlang/YAWS. Message-ID: <944da41d0609170622u32385585q2f0e3ab6a98c1a23@mail.gmail.com> Hi All, I need to extend a PHP application with some Erlang-based server functionality. More specifically, the Erlang app's role is to provide some services for which non-trivial state must be maintained, and which will be queried by an AJAX client periodically (the client is currently being written using PHP as the "primary" backend - there is a chance that YAWS could be accepted as the server for that part, but probably not at this time). So, my question is this: how should one perform such integration? The methods I've basically come up with are: 1) Open a socket from a PHP script and query the Erlang backend using a proprietary protocol (the queries are simple, but might return a couple KB). Is JSON generally more convenient for relatively flat datastructures? 2) As (1) above, but let the Erlang backend build the Javascript part (incl. JSON/other response data). 3) As (1) but extend the PHP interpreter so it opens a persistent connection. Does anyone know how hard this might be? AFAIK Apache threads are mapped to PHP threads, which "share nothing". Is this correct? 4) Somehow get Management to agree on moving the entire AJAX bit to YAWS (unlikely). In this case, I would open a separate socket for YAWS. Regards, Alex. -------------- next part -------------- An HTML attachment was scrubbed... URL: From robert.virding@REDACTED Sun Sep 17 13:13:50 2006 From: robert.virding@REDACTED (Robert Virding) Date: Sun, 17 Sep 2006 13:13:50 +0200 Subject: [erlang-questions] Good Erlang style? In-Reply-To: References: Message-ID: <450D2DEE.50307@telia.com> It is a very readable thesis and definitely not one to be scared of. :-) Robert Liam Clarke wrote: > Thank you, will do... admittedly, the word thesis scares me a little, > but I'll give it a shot. > > > On 9/17/06, Christian S wrote: > >>I suggest you look at section 4.3 "Error handling philosophy" and >>forward from Joe Armstrong's Ph.D. thesis: "Making reliable >>distributed systems in the presence of sodware errors" >> >>You can find the pdf at: >>http://www.sics.se/~joe/index.html >> >>Actually, read the whole thesis. >> >>On 9/17/06, Liam Clarke wrote: >> >>>Hi all, >>> >>>A quick question. From my Python background I'm mindful of a implied >>>"right way" of doing things, and I'm wondering about the Zen of >>>Erlang, as it were. >>> >>>Just contemplating error conditions currently. Is the use of catch and >>>throw the usual style, or is evaluation of returned values? >> > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From ml.cyresse@REDACTED Sun Sep 17 15:51:26 2006 From: ml.cyresse@REDACTED (Liam Clarke) Date: Mon, 18 Sep 2006 01:51:26 +1200 Subject: [erlang-questions] Good Erlang style? In-Reply-To: <450D2DEE.50307@telia.com> References: <450D2DEE.50307@telia.com> Message-ID: Thank you for the reassurances. :-) I've felt a bit daunted as I've dabbled into FP languages - it seems to be a field where a lot of academic research occurs (perhaps due to the lack of side effects?) and as I've had no CS formal education (yet) I sometimes have trouble following what's happening in some of the papers I read; ACM papers are a prime example. Having had a quick skim, Mr Armstrong's thesis does indeed look quite approachable, so I'll print it out tomorrow for perusal on my daily commute. Thanks again, Liam Clarke On 9/17/06, Robert Virding wrote: > It is a very readable thesis and definitely not one to be scared of. :-) > > Robert > > Liam Clarke wrote: > > Thank you, will do... admittedly, the word thesis scares me a little, > > but I'll give it a shot. > > > > > > On 9/17/06, Christian S wrote: > > > >>I suggest you look at section 4.3 "Error handling philosophy" and > >>forward from Joe Armstrong's Ph.D. thesis: "Making reliable > >>distributed systems in the presence of sodware errors" > >> > >>You can find the pdf at: > >>http://www.sics.se/~joe/index.html > >> > >>Actually, read the whole thesis. > >> > >>On 9/17/06, Liam Clarke wrote: > >> > >>>Hi all, > >>> > >>>A quick question. From my Python background I'm mindful of a implied > >>>"right way" of doing things, and I'm wondering about the Zen of > >>>Erlang, as it were. > >>> > >>>Just contemplating error conditions currently. Is the use of catch and > >>>throw the usual style, or is evaluation of returned values? > >> > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > From mccratch@REDACTED Sun Sep 17 16:02:01 2006 From: mccratch@REDACTED (Matthias Kretschmer) Date: Sun, 17 Sep 2006 16:02:01 +0200 Subject: [erlang-questions] ERTS; code-server; dynamically loading of code Message-ID: <20060917140200.GA597@euler.hoholz.local> Hello, I am searching for a way, to do my own code loading and wondered how Erlang/OTP handles it. To be precise: I want to use the Erlang-VM and adopt my own code for dynamically loading the code if for the first time a module is used. I was browsing the code and reading the documentation, but I don't find it. Maybe I am blind, but I would appreciate any hints how the standard Erlang Runtime System handles that and where to find the more information (like documentation, which modules/code-files are involved, etc.). -- Cheers and thank you in advance Matthias Kretschmer From ugglan@REDACTED Sun Sep 17 18:23:01 2006 From: ugglan@REDACTED (=?ISO-8859-1?Q?Tobias_L=F6fgren?=) Date: Sun, 17 Sep 2006 18:23:01 +0200 Subject: [erlang-questions] Possible bug in inets http:request? In-Reply-To: References: <5c402a550609161539s44b8907bg6d04d7766455598c@mail.gmail.com> Message-ID: <5c402a550609170923p3ed00990vba1d6ad0bfea6d43@mail.gmail.com> I'll take that as a vote for "barking up the wrong tree". I'll look into using ibrowse instead. On 9/17/06, Christian S wrote: > > Yes, the http client in OTP contains bugs. Nobody seem to care because > you can use ibrowse instead, which is a very good http client. It is > in jungerl. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lennart.ohman@REDACTED Sun Sep 17 19:00:40 2006 From: lennart.ohman@REDACTED (=?iso-8859-1?Q?Lennart_=D6hman?=) Date: Sun, 17 Sep 2006 19:00:40 +0200 Subject: [erlang-questions] ERTS; code-server; dynamically loading of code In-Reply-To: <20060917140200.GA597@euler.hoholz.local> Message-ID: Hi, hope you know what your are doing :-) When a function can not be found, a function in the module error_handler is called in the context of the process wishing to execute the non-existing function. The code in the error_handler communicated with the code_server process (implemeneted in code) which implements the dynamic code loading. Read those modules and you will understand. Further more it is possible as a process flag to set which module shall be error_handler. In this way one can actually make certain parts of a system load code differently. Good luck, Lennart -----Original Message----- From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Matthias Kretschmer Sent: den 17 september 2006 16:02 To: erlang-questions@REDACTED Subject: [erlang-questions] ERTS; code-server; dynamically loading of code Hello, I am searching for a way, to do my own code loading and wondered how Erlang/OTP handles it. To be precise: I want to use the Erlang-VM and adopt my own code for dynamically loading the code if for the first time a module is used. I was browsing the code and reading the documentation, but I don't find it. Maybe I am blind, but I would appreciate any hints how the standard Erlang Runtime System handles that and where to find the more information (like documentation, which modules/code-files are involved, etc.). -- Cheers and thank you in advance Matthias Kretschmer _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions From yarivvv@REDACTED Sun Sep 17 22:39:23 2006 From: yarivvv@REDACTED (Yariv Sadan) Date: Sun, 17 Sep 2006 16:39:23 -0400 Subject: [erlang-questions] ErlSQL: easy expression and generation of SQL statements in Erlang In-Reply-To: <95be1d3b0609170217v222edfbbgae641e55df37935b@mail.gmail.com> References: <17244f480609161359w75a772eaua97b239c5f71e7c4@mail.gmail.com> <95be1d3b0609170217v222edfbbgae641e55df37935b@mail.gmail.com> Message-ID: <17244f480609171339ga073be8ice3c106bfe5d2433@mail.gmail.com> Hi, > It looks cool, but feels like it could need some polishing. > > For example, why > > {delete,project,{a,'=',5}} -> > "DELETE FROM project WHERE (a = 5)" > > and not > > {delete,project,{where, {a,'=',5}}} -> > "DELETE FROM project WHERE (a = 5)" > > making it consistent with > > {select,{foo,as,bar},{from,{baz,as,blub}}} -> > "SELECT foo AS bar FROM baz AS blub" > I made it so now you can write {delete, {from, project}, {where, {a,'=',5}}}, and also {update, project, {a,'=',5}, {where, {b,'=',7}}} The 'from' and 'where' components are optional because they are implicit in the structure of DELETE and UPDATE statements, but not in the structure of SELECT statements. Regards, Yariv From robert.virding@REDACTED Mon Sep 18 02:54:32 2006 From: robert.virding@REDACTED (Robert Virding) Date: Mon, 18 Sep 2006 02:54:32 +0200 Subject: [erlang-questions] the semantics of dict:append/3 In-Reply-To: References: Message-ID: <450DEE48.2060908@telia.com> I would say that seeing there is no value then it cannot be not a list of values. Ergo it shouldn't generate an error! :-) Orddict behaves the same way. I was probably just being nice. Robert Ulf Wiger (TN/EAB) wrote: > During a recent QuickCheck course, one of our guys (Johan Tj?der) started playing with applying QuickCheck to the dict.erl module. The following behaviour came as a surprise: > > 1> D0 = dict:new(). > {dict,0, > 16, > 16, > 8, > 80, > 48, > {[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]}, > {{[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]}}} > 2> D1 = dict:append(a, 1, D0). > {dict,1, > 16, > 16, > 8, > 80, > 48, > {[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]}, > {{[],[[a,1]],[],[],[],[],[],[],[],[],[],[],[],[],[],[]}}} > 3> dict:find(a,D1). > {ok,[1]} > > > The documentation has this to say about dict:append/3: > > "This function appends a new Value to the current list > of values associated with Key. An exception is generated > if the initial value associated with Key is not a list > of values." > > (http://www.erlang.org/doc/doc-5.5.1/lib/stdlib-1.14.1/doc/html/dict.html#append/3) > > I would have thought that the initial value associated > with a key not present in the dictionary is undefined - > not the empty list. Shouldn't then the above experiment > result in a badarg? > > BR, > Ulf Wiger > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From sanjaya@REDACTED Mon Sep 18 08:36:57 2006 From: sanjaya@REDACTED (Sanjaya Vitharana) Date: Mon, 18 Sep 2006 12:06:57 +0530 Subject: [erlang-questions] Fw: Fw: inets - traverse exit from apply ? Message-ID: <029c01c6daec$da232070$9a0a10ac@wavenet.lk> Hi All, Is this a bug in Inets? OR Are there any way to automatically rotate the access_log ? (or the only solution is manual deletion/rename of the file) Regards, Sanjaya Vitharana ----- Original Message ----- From: Sanjaya Vitharana To: erlang-questions@REDACTED Sent: Sunday, 17 September 2006 05:51 pm Subject: [erlang-questions] Fw: inets - traverse exit from apply ? Hi ... all, Problem was the file size of inets access_log 2,147,483,647 bytes (~2.00 GB) Are there any way to rotate it ? Thanks in advance. Sanjaya Vitharana ----- Original Message ----- From: Sanjaya Vitharana To: erlang-questions@REDACTED Sent: Sunday, 17 September 2006 03:15 pm Subject: [erlang-questions] inets - traverse exit from apply ? Hi ... all, After running the system for 6 months time inets begin to crash, Try to replace the original function with below 3 lines to make sure it is not other than the http call to inets httpd. read_prof(SessionID,Env,Input)-> io:fwrite("***blocked for testing***~n"), mod_esi:deliver(SessionID, "{error,blocked}"). %%-- for testing same result, so my doubt is the inet httpd. the error_log, error_disk_log.1 of inets show the below errors ? what those means ? Need quick fix. Anyone have experience with this error ? Please help. Sanjaya Vitharana ------------------------------------------------------ System Info: [root@REDACTED vm_profile]# erl -version Erlang (THREADS,HIPE) (BEAM) emulator version 5.4.10 [root@REDACTED vm_profile]# uname -a Linux prof 2.4.21-27.ELsmp #1 SMP Wed Dec 1 21:59:02 EST 2004 i686 i686 i386 GNU/Linux [root@REDACTED vm_profile]# date Sun Sep 17 14:49:32 IST 2006 ------------------------------------------------------ error_log -- inets [17/Sep/2006:09:20:23 +0530] reporting error: traverse exit from apply: mod_esi:do => {mod_esi_linked_process_died,<0.221.0>,normal} [17/Sep/2006:09:20:25 +0530] reporting error: traverse exit from apply: mod_esi:do => {mod_esi_linked_process_died,<0.225.0>,normal} [17/Sep/2006:10:05:56 +0530] server crash for 192.168.129.20, reason: "Error reading request: No request received on keep-alive connectionbefore server side timeout" [17/Sep/2006:12:50:08 +0530] reporting error: traverse exit from apply: mod_esi:do => {mod_esi_linked_process_died,<0.214.0>,normal} [17/Sep/2006:12:50:10 +0530] reporting error: traverse exit from apply: mod_esi:do => {mod_esi_linked_process_died,<0.218.0>,normal} ------------------------------------------------------ error_disk_log.1 -- inets {mod_esi_linked_process_died,<0.305.0>,normal}[17/Sep/2006:09:20:23 +0530] reporting error: traverse exit from apply: mod_esi:do => {mod_esi_linked_process_died,<0.221.0>,normal}[17/Sep/2006:09:20:25 +0530] reporting error: traverse exit from apply: mod_esi:do => {mod_esi_linked_process_died,<0.225.0>,normal}[17/Sep/2006:10:05:56 +0530] server crash for 192.168.129.20, reason: "Error reading request: No request received on keep-alive connectionbefore server side timeout" [17/Sep/2006:12:50:08 +0530] reporting error: traverse exit from apply: mod_esi:do => {mod_esi_linked_process_died,<0.214.0>,normal}[17/Sep/2006:12:50:10 +0530] reporting error: traverse exit from apply: mod_esi:do => {mod_esi_linked_process_died,<0.218.0>,normal} ------------------------------------------------------ -------------------------------------------------------------------------------- _______________________________________________ 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 gefla@REDACTED Mon Sep 18 09:43:38 2006 From: gefla@REDACTED (Gerd Flaig) Date: Mon, 18 Sep 2006 09:43:38 +0200 Subject: [erlang-questions] Installing Erlang/OTP R11B-1 on Xubuntu laptop References: <20060914110207.AC23C5A1F6@mail.erlangsystems.com> Message-ID: <87slipr55h.fsf@kilo.pond.sub.org> Hi, "vladdu" writes: > There is an erlang distribution for Ubuntu, but I'm not sure how new > it is (it may be R10). I think it's to be found in the 'universe' - > just serch for erlang in synaptic. > > There is a private newer distribution, but last I checked it was only > a Debian package (meaning it would need manual setup). for those who like packages, it's also possible to compile the Debian sid Erlang source package. I did that in a clean Ubuntu 6.01.1 chroot and put the result in my private repository. The source.list line is: deb http://nxdomain.org/ubuntu dapper/ Contents right now: erlang-x11 erlang-nox erlang-src erlang-examples erlang-mode erlang erlang-base erlang-dev erlang-base-hipe erlang-doc-html erlang-manpages (all packages have version 11.b.1-1, i.e. Erlang/OTP version R11B-1) Goodbyte, Gerd. -- The last thing one knows in constructing a work is what to put first. -- Blaise Pascal From yerl@REDACTED Mon Sep 18 09:50:03 2006 From: yerl@REDACTED (yerl@REDACTED) Date: Mon, 18 Sep 2006 09:50:03 +0200 Subject: [erlang-questions] Fw: Fw: inets - traverse exit from apply ? Message-ID: An HTML attachment was scrubbed... URL: From surindar.shanthi@REDACTED Mon Sep 18 09:52:08 2006 From: surindar.shanthi@REDACTED (Surindar Sivanesan) Date: Mon, 18 Sep 2006 13:22:08 +0530 Subject: [erlang-questions] Finding IP addresses in a PC Message-ID: <42ea5fb60609180052s107ad322h78b66786cc45feca@mail.gmail.com> Dear all, If my PC has several IP addresses, is it possible to find the IP addresses in that PC? If so, please help me in getting those IP addresses. Thanks in advance. with regards, S.Surindar -------------- next part -------------- An HTML attachment was scrubbed... URL: From joe.armstrong@REDACTED Mon Sep 18 09:54:37 2006 From: joe.armstrong@REDACTED (Joe Armstrong (TN/EAB)) Date: Mon, 18 Sep 2006 09:54:37 +0200 Subject: [erlang-questions] gen_tcp question In-Reply-To: Message-ID: Hi Sean, Your assumption is correct - I did read the manual first and Jani answered a question that I had not asked. My origonal example opened the socket in active mode, and I'm not using gen_tcp:recv to receive data at all so the behaviour of recv is irrelevant. >From what's been said here, it seems I should be setting active=false and using recv, rather than doing things the way I was doing them. Why all the questions:? I'm writing THE book (at last) this means you'll just have to put up with loads of very detailed questions. This is because when I say in the book " so and so works like this ..." I want it to be correct /Joe > -----Original Message----- > From: erlang-questions-bounces@REDACTED > [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Sean Hinde > Sent: den 14 september 2006 15:46 > To: Erlang Questions > Subject: Re: [erlang-questions] gen_tcp question > > > On 14 Sep 2006, at 14:32, Jani Hakala wrote: > > > "Joe Armstrong (TN/EAB)" writes: > > > >> The behaviour appears not to be documented > >> > > Meaning of {packet,N} is explained in man inet, inet:setopts The > > behaviour of gen_tcp:recv is explained in man gen_tcp > > Well observed! > > My assumption (there we go again) was that Joe must have read > the documentation in order to have discover the existence of > {packet, N}, but found it lacking. Reading the page more > carefully now it is clear that it does specify the behaviour. > > Where you perchance peeking under the hood to discover this > option Joe ? :-) > > Sean > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From dmitriid@REDACTED Mon Sep 18 10:09:21 2006 From: dmitriid@REDACTED (Dmitrii Dimandt) Date: Mon, 18 Sep 2006 11:09:21 +0300 Subject: [erlang-questions] ErlSQL: easy expression and generation of SQL statements in Erlang In-Reply-To: <17244f480609171339ga073be8ice3c106bfe5d2433@mail.gmail.com> References: <17244f480609161359w75a772eaua97b239c5f71e7c4@mail.gmail.com> <95be1d3b0609170217v222edfbbgae641e55df37935b@mail.gmail.com> <17244f480609171339ga073be8ice3c106bfe5d2433@mail.gmail.com> Message-ID: On 9/17/06, Yariv Sadan wrote: > > Hi, > > > It looks cool, but feels like it could need some polishing. > > > > For example, why > > > > {delete,project,{a,'=',5}} -> > > "DELETE FROM project WHERE (a = 5)" > > > > and not > > > > {delete,project,{where, {a,'=',5}}} -> > > "DELETE FROM project WHERE (a = 5)" > > > > making it consistent with > > > > {select,{foo,as,bar},{from,{baz,as,blub}}} -> > > "SELECT foo AS bar FROM baz AS blub" > > > > I made it so now you can write {delete, {from, project}, {where, > {a,'=',5}}}, and also {update, project, {a,'=',5}, {where, {b,'=',7}}} > > The 'from' and 'where' components are optional because they are > implicit in the structure of DELETE and UPDATE statements, but not in > the structure of SELECT statements. Hmmm.... I wonder if this could be mapped to Mnesia. Somehow... By someone... :)) Regards, > Yariv > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From stefan.l.axelsson@REDACTED Mon Sep 18 10:13:05 2006 From: stefan.l.axelsson@REDACTED (Stefan Axelsson L (LN/EAB)) Date: Mon, 18 Sep 2006 10:13:05 +0200 Subject: [erlang-questions] Good Erlang style? In-Reply-To: Message-ID: <6D145AB0AF765D4988C49705263A1DBC045212B5@esealmw106.eemea.ericsson.se> >Liam Clarke: >Thank you, will do... admittedly, the word thesis scares me a little, but I'll give it a >shot. I can only second Christian's advice. And don't let the word "thesis" scare you, it's really quite a readable book, not at all like many (most?) other theses you might have come accross; trust me, I'm a doctor. :-) On 9/17/06, Christian S wrote: > I suggest you look at section 4.3 "Error handling philosophy" and > forward from Joe Armstrong's Ph.D. thesis: "Making reliable > distributed systems in the presence of sodware errors" > > You can find the pdf at: > http://www.sics.se/~joe/index.html > > Actually, read the whole thesis. Regards, -- Stefan Axelsson PhD, (ERVSTAX), tel: +46 31 747 3963 From sanjaya@REDACTED Mon Sep 18 10:13:36 2006 From: sanjaya@REDACTED (Sanjaya Vitharana) Date: Mon, 18 Sep 2006 13:43:36 +0530 Subject: [erlang-questions] Fw: Fw: inets - traverse exit from apply ? References: Message-ID: <02db01c6dafa$5d61fda0$9a0a10ac@wavenet.lk> Hi ...Youn?s & All Thanks for your quick reply. Yes that can be done in this way, but I just wanted to know that .... the internal support of access_log log rotation in inets ... which I don't no at the moment. If inets do not support that feature ... I might go with your suggestion. But IF inets don't support that .... I think it's better to show any error message .... rather than crashing after each http request. (B'cos I have wasted some hours to find this ... assumming as a problem in my code) So ... I will rais up my question again, Are there any way to automatically rotate the inets access_log ? Regards, Sanjaya Vitharana ----- Original Message ----- From: yerl@REDACTED To: sanjaya@REDACTED Cc: erlang-questions@REDACTED Sent: Monday, 18 September 2006 01:20 pm Subject: Re: [erlang-questions] Fw: Fw: inets - traverse exit from apply ? Hi Sanjaya! If you're using Unix or Unix like system, look to the logrotate in your system. A script you can use as a cron job to do the logs rotation automagically. cheers Youn?s ----Message d'origine---- >De: "Sanjaya Vitharana" >A: >Date: Mon, 18 Sep 2006 12:06:57 +0530 >Sujet: [erlang-questions] Fw: Fw: inets - traverse exit from apply ? > >Hi All, > >Is this a bug in Inets? > >OR > >Are there any way to automatically rotate the access_log ? (or the only solution is manual deletion/rename of the file) > >Regards, > >Sanjaya Vitharana > > >----- Original Message ----- >From: Sanjaya Vitharana >To: erlang-questions@REDACTED >Sent: Sunday, 17 September 2006 05:51 pm >Subject: [erlang-questions] Fw: inets - traverse exit from apply ? > > >Hi ... all, > >Problem was the file size of inets >access_log 2,147,483,647 bytes (~2.00 GB) > >Are there any way to rotate it ? > >Thanks in advance. > >Sanjaya Vitharana > > >----- Original Message ----- >From: Sanjaya Vitharana >To: erlang-questions@REDACTED >Sent: Sunday, 17 September 2006 03:15 pm >Subject: [erlang-questions] inets - traverse exit from apply ? > > >Hi ... all, > >After running the system for 6 months time inets begin to crash, > >Try to replace the original function with below 3 lines to make sure it is not other than the http call to inets httpd. > >read_prof(SessionID,Env,Input)-> > io:fwrite("***blocked for testing***~n"), > mod_esi:deliver(SessionID, "{error,blocked}"). %%-- for testing > >same result, so my doubt is the inet httpd. > >the error_log, error_disk_log.1 of inets show the below errors ? what those means ? > >Need quick fix. Anyone have experience with this error ? > >Please help. > >Sanjaya Vitharana > >------------------------------------------------------ >System Info: > >[root@REDACTED vm_profile]# erl -version >Erlang (THREADS,HIPE) (BEAM) emulator version 5.4.10 > >[root@REDACTED vm_profile]# uname -a >Linux prof 2.4.21-27.ELsmp #1 SMP Wed Dec 1 21:59:02 EST 2004 i686 i686 i386 GNU/Linux > >[root@REDACTED vm_profile]# date >Sun Sep 17 14:49:32 IST 2006 > >------------------------------------------------------ > error_log -- inets > >[17/Sep/2006:09:20:23 +0530] reporting error: traverse exit from apply: mod_esi:do => >{mod_esi_linked_process_died,<0.221.0>,normal} >[17/Sep/2006:09:20:25 +0530] reporting error: traverse exit from apply: mod_esi:do => >{mod_esi_linked_process_died,<0.225.0>,normal} >[17/Sep/2006:10:05:56 +0530] server crash for 192.168.129.20, reason: "Error reading request: No request received on keep-alive connectionbefore server side timeout" >[17/Sep/2006:12:50:08 +0530] reporting error: traverse exit from apply: mod_esi:do => >{mod_esi_linked_process_died,<0.214.0>,normal} >[17/Sep/2006:12:50:10 +0530] reporting error: traverse exit from apply: mod_esi:do => >{mod_esi_linked_process_died,<0.218.0>,normal} > >------------------------------------------------------ >error_disk_log.1 -- inets > >{mod_esi_linked_process_died,<0.305.0>, normal}[17/Sep/2006:09:20:23 +0530] reporting error: traverse exit from apply: mod_esi:do => >{mod_esi_linked_process_died,<0.221.0>,normal}[17/Sep/2006:09:20:25 +0530] reporting error: traverse exit from apply: mod_esi:do => >{mod_esi_linked_process_died,<0.225.0>,normal}[17/Sep/2006:10:05:56 +0530] server crash for 192.168.129.20, reason: "Error reading request: No request received on keep-alive connectionbefore server side timeout" >[17/Sep/2006:12:50:08 +0530] reporting error: traverse exit from apply: mod_esi:do => >{mod_esi_linked_process_died,<0.214.0>,normal}[17/Sep/2006:12:50:10 +0530] reporting error: traverse exit from apply: mod_esi:do => >{mod_esi_linked_process_died,<0.218.0>,normal} > >------------------------------------------------------ > > >-------------------------------------------------------------------------------- > > > _______________________________________________ >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 Bob.Cowdery@REDACTED Mon Sep 18 10:36:01 2006 From: Bob.Cowdery@REDACTED (Bob Cowdery) Date: Mon, 18 Sep 2006 09:36:01 +0100 Subject: [erlang-questions] multi-threaded woes Message-ID: <3A76756EED583B43A4AD704E29CCD079741166@mail.aprsmartlogik.com> I have come a long way with ei now but the last 10% is giving me some grief. I am having some trouble getting two C nodes which are both clients and servers to connect both ways and not sure of the rules here. They both start listen threads and sit on accept. Node 1 does a connect on node 2 which is successful and sends it a message which it receives. Node 2 does a connect on Node 1 as Node 1 is now guaranteed to be up, which is successful from the connect side except Node 1 never comes off the accept so it never sees it. The connects are done from the main thread on each side.I will give the clients their own threads but want to understand the issues before I proceed. I do need these nodes to be servers as multiple nodes will connect to them and I will need to spawn a thread for each. The only info I could find in the Erl_interface manual was to use -DREENTRANT and I am using pthreads package which should be the default. One thing I'm not sure about but probably isn't related. If I am using the ei module rather than the erl module from a multi-threaded C node do I still need to call erl_init() and if so does it matter which thread I call it from. At the moment I've just realized it gets called twice, once on each thread. I didn't get any response to my last post when I was stuggling with the binary format. Pleased to report that works a treat now and is very concise. I just hope someone uses this library in anger and can help me out here. Regards Bob From sean.hinde@REDACTED Mon Sep 18 10:38:03 2006 From: sean.hinde@REDACTED (Sean Hinde) Date: Mon, 18 Sep 2006 09:38:03 +0100 Subject: [erlang-questions] gen_tcp question In-Reply-To: References: Message-ID: <0D59F645-5389-49B5-9A43-535801545587@gmail.com> Hi Joe, If the document does not say that this can only be used in passive mode then I read it as saying it should be present and correct in active mode. The passage simply refers to "receiving", which should mean all receive modes. FWIW I was referring to active mode in my replies.. I also see that {active, once} is now properly documented which is great - it means that the book could describe the very smartest way to use sockets :-) It is truly exciting to see you are back on the book drive. I'm sure we are all here to help with your extremely welcome effort! Finally, for me the book should always refer to best "real world" practice. If Ericsson must be persuaded to fix the documentation in some areas then even better. BR, Sean On 18 Sep 2006, at 08:54, Joe Armstrong ((TN/EAB)) wrote: > Hi Sean, > > Your assumption is correct - I did read the manual first > and Jani answered a question that I had not asked. > > My origonal example opened the socket in active mode, > and I'm not using gen_tcp:recv to receive data at all > so the behaviour of recv is irrelevant. > > From what's been said here, it seems I should be setting > active=false and using recv, rather than doing things the way I was > doing > them. > > Why all the questions:? I'm writing THE book (at last) this > means you'll just have to put up with loads of very detailed > questions. This is because when I say in the book > > " so and so works like this ..." > > I want it to be correct > > /Joe > > > > >> -----Original Message----- >> From: erlang-questions-bounces@REDACTED >> [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Sean Hinde >> Sent: den 14 september 2006 15:46 >> To: Erlang Questions >> Subject: Re: [erlang-questions] gen_tcp question >> >> >> On 14 Sep 2006, at 14:32, Jani Hakala wrote: >> >>> "Joe Armstrong (TN/EAB)" writes: >>> >>>> The behaviour appears not to be documented >>>> >>> Meaning of {packet,N} is explained in man inet, inet:setopts The >>> behaviour of gen_tcp:recv is explained in man gen_tcp >> >> Well observed! >> >> My assumption (there we go again) was that Joe must have read >> the documentation in order to have discover the existence of >> {packet, N}, but found it lacking. Reading the page more >> carefully now it is clear that it does specify the behaviour. >> >> Where you perchance peeking under the hood to discover this >> option Joe ? :-) >> >> Sean >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> From Norbert.Klamann@REDACTED Mon Sep 18 10:42:13 2006 From: Norbert.Klamann@REDACTED (norbertk) Date: Mon, 18 Sep 2006 09:42:13 +0100 Subject: [erlang-questions] Good Erlang style? References: Message-ID: <20060918084213.610875A1F7@mail.erlangsystems.com> Guest wrote: I've felt a bit daunted as I've dabbled into FP languages - it seems to be a field where a lot of academic research occurs (perhaps due to the lack of side effects?) and as I've had no CS formal education (yet) I sometimes have trouble following what's happening in some of the papers I read; ACM papers are a prime example. (end of quote) Yes, that is a problem for me too. I have the feling that these languages have a lot of practical value, but is is hard to come by without the theoretical background. defmacro.rg is very valuable because it presents the thinking of FP in a language which is understandable for programmers in vonventional languages. Norbert _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions Post recived from mailinglist[/quote] _________________________________________________________ Post sent from http://www.trapexit.org From joe.armstrong@REDACTED Mon Sep 18 10:34:43 2006 From: joe.armstrong@REDACTED (Joe Armstrong (TN/EAB)) Date: Mon, 18 Sep 2006 10:34:43 +0200 Subject: [erlang-questions] Good Erlang style? In-Reply-To: <6D145AB0AF765D4988C49705263A1DBC045212B5@esealmw106.eemea.ericsson.se> Message-ID: Guaranteed no Greek /Joe > -----Original Message----- > From: erlang-questions-bounces@REDACTED > [mailto:erlang-questions-bounces@REDACTED] On Behalf Of > Stefan Axelsson L (LN/EAB) > Sent: den 18 september 2006 10:13 > To: Liam Clarke > Cc: erlang-questions@REDACTED > Subject: Re: [erlang-questions] Good Erlang style? > > >Liam Clarke: > >Thank you, will do... admittedly, the word thesis scares me a little, > but I'll give it a >shot. > > I can only second Christian's advice. And don't let the word "thesis" > scare you, it's really quite a readable book, not at all like many > (most?) other theses you might have come accross; trust me, > I'm a doctor. :-) > > On 9/17/06, Christian S wrote: > > I suggest you look at section 4.3 "Error handling philosophy" and > > forward from Joe Armstrong's Ph.D. thesis: "Making reliable > > distributed systems in the presence of sodware errors" > > > > You can find the pdf at: > > http://www.sics.se/~joe/index.html > > > > Actually, read the whole thesis. > > Regards, > -- > Stefan Axelsson PhD, (ERVSTAX), tel: +46 31 747 3963 > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From vladdu55@REDACTED Mon Sep 18 11:00:05 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Mon, 18 Sep 2006 11:00:05 +0200 Subject: [erlang-questions] multi-threaded woes In-Reply-To: <3A76756EED583B43A4AD704E29CCD079741166@mail.aprsmartlogik.com> References: <3A76756EED583B43A4AD704E29CCD079741166@mail.aprsmartlogik.com> Message-ID: <95be1d3b0609180200w2f716335hc2b0847a924427e5@mail.gmail.com> On 9/18/06, Bob Cowdery wrote: > I am having some trouble getting two C nodes which are both clients and servers to connect both ways and not sure of the rules here. ...snip... > I do need these nodes to be servers as multiple nodes will connect to them and I will need to spawn a thread for each. Hi, I don't know what kind of application you work on, so this may be way off. Also, I hope I understood your question. If you want to write C nodes that are multithreaded, you will have to fight the same problems any multithreaded C application has and that Erlang solves. C nodes are regular C programs, they can talk to Erlang nodes but have no inherent better multithreading capabilities. An alternative approach (a little more Erlang-ish) would be to move the connection handling to a proper Erlang node and let only that node talk to the C node. This way the C part will be single-threaded (but maybe will have to be able to handle several sessions) and the messy threaded stuff is handled on the Erlang side. Hope this helps. best regards, Vlad From ulf.wiger@REDACTED Mon Sep 18 11:05:02 2006 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Mon, 18 Sep 2006 11:05:02 +0200 Subject: [erlang-questions] ERTS; code-server; dynamically loading of code In-Reply-To: Message-ID: I second Lennart's opinion. Don't mess with the code loading unless you've become One with the Erlang environment. Re-reading your question, it sounds as if Erlang already does what you want. The first time a module is called, it is automatically loaded if it hadn't already been loaded during startup. You can control the initial code loading with the help of the -mode boot flag. erl -mode interactive tells erlang to load modules on-demand. The on-demand code loading is triggered by the error_handler, which you shouldn't mess with, as Lennart said. A few modules are preloaded, mainly in the kernel and stdlib. This is the default. erl -mode embedded says that all modules should be loaded at startup, and Erlang will never try to load code automatically from disk. This is typically what you want in a production system with high demands on responsiveness. Embedded mode also tends to speed up the boot phase slightly(*). erl -mode test loads all modules in the boot script at startup, but still does code loading on-demand. The main reason for this is (I believe) that it has the same timing characteristics as '-mode embedded' during startup, but still offers the convenience of being able to call any module in the path. (*) There is also a seldomly mentioned option, -code_path_cache, which caches the location of all modules in the path during startup. This can give significant speedup, since the code loader doesn't have to search the path for a module during on-demand code loading. http://www.erlang.org/doc/doc-5.5.1/lib/kernel-2.11.1/doc/html/code.html is your friend when trying to learn how code loading works. It pretty much describes all that I've written here, and then some. BR, Ulf W > -----Original Message----- > From: erlang-questions-bounces@REDACTED > [mailto:erlang-questions-bounces@REDACTED] On Behalf Of > Lennart ?hman > Sent: den 17 september 2006 19:01 > To: 'Matthias Kretschmer'; erlang-questions@REDACTED > Subject: Re: [erlang-questions] ERTS; code-server;dynamically > loading of code > > Hi, hope you know what your are doing :-) > > When a function can not be found, a function in the module > error_handler is called in the context of the process wishing > to execute the non-existing function. The code in the > error_handler communicated with the code_server process > (implemeneted in code) which implements the dynamic code > loading. Read those modules and you will understand. > > Further more it is possible as a process flag to set which > module shall be error_handler. In this way one can actually > make certain parts of a system load code differently. > > Good luck, > Lennart > > > -----Original Message----- > From: erlang-questions-bounces@REDACTED > [mailto:erlang-questions-bounces@REDACTED] On Behalf Of > Matthias Kretschmer > Sent: den 17 september 2006 16:02 > To: erlang-questions@REDACTED > Subject: [erlang-questions] ERTS; code-server; dynamically > loading of code > > Hello, > > I am searching for a way, to do my own code loading and > wondered how Erlang/OTP handles it. To be precise: I want to > use the Erlang-VM and adopt my own code for dynamically > loading the code if for the first time a module is used. I > was browsing the code and reading the documentation, but I > don't find it. Maybe I am blind, but I would appreciate any > hints how the standard Erlang Runtime System handles that and > where to find the more information (like documentation, which > modules/code-files are involved, etc.). > > -- > Cheers and thank you in advance > Matthias Kretschmer > _______________________________________________ > 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 joe.armstrong@REDACTED Mon Sep 18 11:19:27 2006 From: joe.armstrong@REDACTED (Joe Armstrong (TN/EAB)) Date: Mon, 18 Sep 2006 11:19:27 +0200 Subject: [erlang-questions] gen_tcp question In-Reply-To: <87psdya7zy.fsf@pingviini.kortex.jyu.fi> Message-ID: Hi Jani, My problem is that I am NOT using gen_tcp:recv at all - I need to open the socket in active mode, since I want to receive both messages from the socket and send messages to the socket at the same time. I want to write a middle-man that abstracts out the TCP transport layer so I write a process that understands TCP and converts terms to packets etc. The problem occurs in the following bit of code: (C is the Pid of a client) {ok, L} = gen_tcp:listen(Port, [{length,4},binary,{active,true}]), {ok, S} = gen_tcp:accept(L), loop(S, C). loop(S, C) -> receive {tcp, S, Bin} -> %% <----- Is Bin of length 4 here????????????? C ! binary_to_term(Bin), loop(S, C); {tcp_closed, S} -> C ! closed; {msg, Term} -> gen_tcp:send(S, term_to_binary(Term)), loop(S, C); close -> gen_tcp:close(S) end I need the active=true mode for this since loop has to handle messages from both C and S - so I don't want to block in gen_tcp:recv So my question is "is Bin" fragmented? - I can easily add an extra layer for packet recombination inside loop, it is really unclear to me what the purpose of saying {packet,4} is in the listen call if it is not to be used for recombination. Now if the answer to this question is in the documentation I can't seem to find it the setopts documentation says that a 4 byte header is appended to the TCP data - that's all. The behaviour together with recv *is* documented (as you say) but not when you don't call recv and process data in active mode /Joe > -----Original Message----- > From: Jani Hakala [mailto:jahakala@REDACTED] > Sent: den 14 september 2006 15:33 > To: erlang-questions@REDACTED > Cc: Joe Armstrong (TN/EAB) > Subject: Re: [erlang-questions] gen_tcp question > > "Joe Armstrong (TN/EAB)" writes: > > > The behaviour appears not to be documented > > > Meaning of {packet,N} is explained in man inet, inet:setopts > The behaviour of gen_tcp:recv is explained in man gen_tcp > > Jani Hakala > From hev@REDACTED Mon Sep 18 12:20:23 2006 From: hev@REDACTED (Evgeniy Khramtsov) Date: Mon, 18 Sep 2006 20:20:23 +1000 Subject: [erlang-questions] Finding IP addresses in a PC In-Reply-To: <42ea5fb60609180052s107ad322h78b66786cc45feca@mail.gmail.com> References: <42ea5fb60609180052s107ad322h78b66786cc45feca@mail.gmail.com> Message-ID: <450E72E7.1060504@sbyt.amur.elektra.ru> Surindar Sivanesan ?????: > Dear all, > If my PC has several IP addresses, is it possible to find the IP > addresses > in that PC? > If so, please help me in getting those IP addresses. > Thanks in advance. inet:getif(). inet:getiflist(). From surindar.shanthi@REDACTED Mon Sep 18 13:03:32 2006 From: surindar.shanthi@REDACTED (Surindar Sivanesan) Date: Mon, 18 Sep 2006 16:33:32 +0530 Subject: [erlang-questions] Finding IP addresses in a PC In-Reply-To: <450E72E7.1060504@sbyt.amur.elektra.ru> References: <42ea5fb60609180052s107ad322h78b66786cc45feca@mail.gmail.com> <450E72E7.1060504@sbyt.amur.elektra.ru> Message-ID: <42ea5fb60609180403n568992a1oe1118851f0fe5087@mail.gmail.com> Hi Thanks for your timely help. I'm able to get the IP addresses using inet:getiflist() but those IP address is reversed. Ex: 192.168.1.60 is displayed as 60.100.861.291. Is there any option to get the IP as such. This is just for info Thanks once again Best regards, S.Surindar. On 9/18/06, Evgeniy Khramtsov wrote: > > Surindar Sivanesan ?????: > > > Dear all, > > If my PC has several IP addresses, is it possible to find the IP > > addresses > > in that PC? > > If so, please help me in getting those IP addresses. > > Thanks in advance. > > inet:getif(). > inet:getiflist(). > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- with regards, S.Surindar -------------- next part -------------- An HTML attachment was scrubbed... URL: From Bob.Cowdery@REDACTED Mon Sep 18 13:46:51 2006 From: Bob.Cowdery@REDACTED (Bob Cowdery) Date: Mon, 18 Sep 2006 12:46:51 +0100 Subject: [erlang-questions] multi-threaded woes Message-ID: <3A76756EED583B43A4AD704E29CCD079741168@mail.aprsmartlogik.com> Vlad Sorry if this is a bit long and more information than you needed to know but I wnated to explain why I am doing what I am doing. Eventually, this will be a distributed software radio with which many other people are involved. At the moment I am just testing the Erlang waters to see what can be achieved. I have only two units of compilation at the moment, a thin front-end which is GTK+ and a middle tier state machine which controls all the application logic and at the moment calls out directly to the other components of the system. Right now just about everything is in C. Once this is proven I expect to start adding pure Erlang nodes. I should be able to completely replace the middle tier with Erlang as well. The interaction between these two nodes is quite like an Ajax style web app. The GTK+ side has to be a C node because it needs to be an executable C program. Arguable the middle tier could be a C Port (not sure that helps) but right now is a C Node. The UI receives interactions from the user and sends an event message (with a little pertinent data) to the state machine. The state machine goes through its process and as a result constructs a single response message which is UI updates. The most complex of these is the start-up response which can be 46 separate updates packaged into one message. Now , if I just send these as a response to the request rather than a separate async message it won't work because some of those updates in turn generate events which nave responses, which of course kick right into the last response which is only part processed. In addition the UI can receive updates spontaineously from the state machine because some other node kicked it in a kind of remote-control fashion. The UI then as far as I can see needs to be a C node and have separate client and server threads. The state machine is debatable but I really wanted to get it working as is as it will probably have some major re-engineering later. An alternative approach (a little more Erlang-ish) would be to move the connection handling to a proper Erlang node and let only that node talk to the C node. If you think this is feasible given the application can you give me a hint how it might operate because I'm having trouble visualizing the interactions. If I was using plain C with sockets and say JSON for encoding I don't think I would have trouble with the two way connection, but then it would kinda defeat the object. I'm not sure what's going on in the ei library is my issue. I probably need to do a controlled test with minimal code to see what works but if anyone has already been there and knows the issues that would be nice. Regards Bob -----Original Message----- From: Vlad Dumitrescu [mailto:vladdu55@REDACTED] Sent: 18 September 2006 10:00 To: Bob Cowdery Cc: Erlang-Questions (E-mail) Subject: Re: [erlang-questions] multi-threaded woes On 9/18/06, Bob Cowdery wrote: > I am having some trouble getting two C nodes which are both clients and servers to connect both ways and not sure of the rules here. ...snip... > I do need these nodes to be servers as multiple nodes will connect to them and I will need to spawn a thread for each. Hi, I don't know what kind of application you work on, so this may be way off. Also, I hope I understood your question. If you want to write C nodes that are multithreaded, you will have to fight the same problems any multithreaded C application has and that Erlang solves. C nodes are regular C programs, they can talk to Erlang nodes but have no inherent better multithreading capabilities. An alternative approach (a little more Erlang-ish) would be to move the connection handling to a proper Erlang node and let only that node talk to the C node. This way the C part will be single-threaded (but maybe will have to be able to handle several sessions) and the messy threaded stuff is handled on the Erlang side. Hope this helps. best regards, Vlad From vladdu55@REDACTED Mon Sep 18 14:16:55 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Mon, 18 Sep 2006 14:16:55 +0200 Subject: [erlang-questions] multi-threaded woes In-Reply-To: <3A76756EED583B43A4AD704E29CCD079741168@mail.aprsmartlogik.com> References: <3A76756EED583B43A4AD704E29CCD079741168@mail.aprsmartlogik.com> Message-ID: <95be1d3b0609180516h9701892oaa38fc047e054f78@mail.gmail.com> Hi, On 9/18/06, Bob Cowdery wrote: > Sorry if this is a bit long and more information than you needed to know but I wnated to explain why I am doing what I am doing. No problem :-) I don't have time right now to dig deeper, but the first impression is that you should implement your middle-tier in Erlang, as it is there you have paralellism and can harness the Erlang programming model. > The UI then as far as I can see needs to be a C node and have separate client and server threads. Yes, but those are only for handling the communications, right? And each client talks only with the middle tier, right? > The state machine is debatable but I really wanted to get it working as is as it will probably have some major re-engineering later. So you have a working app, right? If that is the case, the you should have the multithreading working already. I think the simple way to implement a C-only proof of concept is to go with regular sockets and Erlang-encoding of messages. C nodes are really "handicapped" node, they lack a lot of the features of Erlang nodes. Ei is just a communication layer, who lets a C program masquerade as an Erlang node, but that's it. If not, I think that it might be faster and easier to just do it in Erlang from the start. You will have no advantage from implementing it first in C. <[ the C implementation would possibly be an illustration of a paraphrase of the classic Lisp quote: "any sufficiently advanced multithreaded application contains a buggy implementation of an Erlang runtime" :-) ]> Or maybe I misunderstood something ;-) best regards, Vlad From christophe.romain@REDACTED Mon Sep 18 14:44:31 2006 From: christophe.romain@REDACTED (Christophe Romain) Date: Mon, 18 Sep 2006 14:44:31 +0200 Subject: [erlang-questions] ErlSQL: easy expression and generation of SQL statements in Erlang In-Reply-To: References: <17244f480609161359w75a772eaua97b239c5f71e7c4@mail.gmail.com> <95be1d3b0609170217v222edfbbgae641e55df37935b@mail.gmail.com> <17244f480609171339ga073be8ice3c106bfe5d2433@mail.gmail.com> Message-ID: <5f98128db67f912ce1caaf85f5552c6f@process-one.net> > Hmmm.... I wonder if this could be mapped to Mnesia. Somehow... By > someone... :)) > it can and it is already running it will be added soon to yariv's project. From mccratch@REDACTED Mon Sep 18 15:52:58 2006 From: mccratch@REDACTED (Matthias Kretschmer) Date: Mon, 18 Sep 2006 15:52:58 +0200 Subject: [erlang-questions] ERTS; code-server; dynamically loading of code In-Reply-To: References: Message-ID: <20060918135257.GA28633@server.hoholz.local> Hello, thank you two for the information. On Mon, Sep 18, 2006 at 11:05:02AM +0200, Ulf Wiger (TN/EAB) wrote: > I second Lennart's opinion. Don't mess with the code loading unless you've become One with the Erlang environment. > > [...] Don't worry, I at least think I know what I am doing and I am just toying around and experimenting a bit. So the next plane you use wouldn't crash because of me and toying around with code loading. Thank god! :-) Just had in mind doing some more stuff than just loading a module. I know, that modules are dynamically loaded. Anyway just toying around with the Erlang runtime. -- Cheers, Matthias Kretschmer From Bob.Cowdery@REDACTED Mon Sep 18 15:57:17 2006 From: Bob.Cowdery@REDACTED (Bob Cowdery) Date: Mon, 18 Sep 2006 14:57:17 +0100 Subject: [erlang-questions] multi-threaded woes Message-ID: <3A76756EED583B43A4AD704E29CCD07974116A@mail.aprsmartlogik.com> Vlad > you should implement your middle-tier in Erlang I should, but its not trivial and I don't at the moment see why the C version is not working. That is my aim, I just didn't want to do it right now. > So you have a working app, right? The original build was one executable which was built with separation in mind. I then ripped it into two builds and linked the second in as a library. At this point no multi-threading was required as everything was synchronous call level. I then put Erlang in the middle and so far have failed to get it operational again. > go with regular sockets and Erlang-encoding of messages I guess that's pretty close to what I have anyway except ei is abstacting the sockets layer a little. > I think that it might be faster and easier to just do it in Erlang from the start Erlang came along quite a way through the project. The intension is that the UI can be any language and might be fragmented across nodes and at the moment it seems that the UI needs to drive. I don't think there is a suitable Erlang binding to a GUI library such that Erlang can drive. <[ the C implementation would possibly be an illustration of a paraphrase of the classic Lisp quote: "any sufficiently advanced multithreaded application contains a buggy implementation of an Erlang runtime" :-) ]> Well, yes, that seems to be a reason to use ei, unless you are saying that ei is not part of the Erlang runtime and may therefore be buggy! Regards Bob -----Original Message----- From: Vlad Dumitrescu [mailto:vladdu55@REDACTED] Sent: 18 September 2006 13:17 To: Bob Cowdery Cc: Erlang-Questions (E-mail) Subject: Re: [erlang-questions] multi-threaded woes Hi, On 9/18/06, Bob Cowdery wrote: > Sorry if this is a bit long and more information than you needed to know but I wnated to explain why I am doing what I am doing. No problem :-) I don't have time right now to dig deeper, but the first impression is that you should implement your middle-tier in Erlang, as it is there you have paralellism and can harness the Erlang programming model. > The UI then as far as I can see needs to be a C node and have separate client and server threads. Yes, but those are only for handling the communications, right? And each client talks only with the middle tier, right? > The state machine is debatable but I really wanted to get it working as is as it will probably have some major re-engineering later. So you have a working app, right? If that is the case, the you should have the multithreading working already. I think the simple way to implement a C-only proof of concept is to go with regular sockets and Erlang-encoding of messages. C nodes are really "handicapped" node, they lack a lot of the features of Erlang nodes. Ei is just a communication layer, who lets a C program masquerade as an Erlang node, but that's it. If not, I think that it might be faster and easier to just do it in Erlang from the start. You will have no advantage from implementing it first in C. <[ the C implementation would possibly be an illustration of a paraphrase of the classic Lisp quote: "any sufficiently advanced multithreaded application contains a buggy implementation of an Erlang runtime" :-) ]> Or maybe I misunderstood something ;-) best regards, Vlad From erlangX@REDACTED Mon Sep 18 16:00:32 2006 From: erlangX@REDACTED (Michael McDaniel) Date: Mon, 18 Sep 2006 07:00:32 -0700 Subject: [erlang-questions] Fw: Fw: inets - traverse exit from apply ? In-Reply-To: <029c01c6daec$da232070$9a0a10ac@wavenet.lk> References: <029c01c6daec$da232070$9a0a10ac@wavenet.lk> Message-ID: <20060918140032.GD5853@delora.autosys.us> I suggest using your OS facility to rotate the log. On (some) Linux flavors you can use logrotate. Remember to use copytruncate in the configuration file for the (specific log file) so that you do not lose any open file descriptors. ~Michael On Mon, Sep 18, 2006 at 12:06:57PM +0530, Sanjaya Vitharana wrote: > Hi All, > > Is this a bug in Inets? > > OR > > Are there any way to automatically rotate the access_log ? (or the only > solution is manual deletion/rename of the file) > > Regards, > > Sanjaya Vitharana > > > ----- Original Message ----- > From: Sanjaya Vitharana > To: erlang-questions@REDACTED > Sent: Sunday, 17 September 2006 05:51 pm > Subject: [erlang-questions] Fw: inets - traverse exit from apply ? > > Hi ... all, > > Problem was the file size of inets > access_log 2,147,483,647 bytes (~2.00 GB) > > Are there any way to rotate it ? > > Thanks in advance. > > Sanjaya Vitharana > > > ----- Original Message ----- > From: Sanjaya Vitharana > To: erlang-questions@REDACTED > Sent: Sunday, 17 September 2006 03:15 pm > Subject: [erlang-questions] inets - traverse exit from apply ? > > Hi ... all, > > After running the system for 6 months time inets begin to crash, > > Try to replace the original function with below 3 lines to make sure it is not > other than the http call to inets httpd. > > read_prof(SessionID,Env,Input)-> > io:fwrite("***blocked for testing***~n"), > mod_esi:deliver(SessionID, "{error,blocked}"). %%-- for testing > > same result, so my doubt is the inet httpd. > > the error_log, error_disk_log.1 of inets show the below errors ? what those > means ? > > Need quick fix. Anyone have experience with this error ? > > Please help. > > Sanjaya Vitharana > > ------------------------------------------------------ > System Info: > > [root@REDACTED vm_profile]# erl -version > Erlang (THREADS,HIPE) (BEAM) emulator version 5.4.10 > > [root@REDACTED vm_profile]# uname -a > Linux prof 2.4.21-27.ELsmp #1 SMP Wed Dec 1 21:59:02 EST 2004 i686 i686 i386 > GNU/Linux > > [root@REDACTED vm_profile]# date > Sun Sep 17 14:49:32 IST 2006 > ------------------------------------------------------ > error_log -- inets > > [17/Sep/2006:09:20:23 +0530] reporting error: traverse exit from apply: > mod_esi:do => > {mod_esi_linked_process_died,<0.221.0>,normal} > [17/Sep/2006:09:20:25 +0530] reporting error: traverse exit from apply: > mod_esi:do => > {mod_esi_linked_process_died,<0.225.0>,normal} > [17/Sep/2006:10:05:56 +0530] server crash for 192.168.129.20, reason: "Error > reading request: No request received on keep-alive connectionbefore server side > timeout" > [17/Sep/2006:12:50:08 +0530] reporting error: traverse exit from apply: > mod_esi:do => > {mod_esi_linked_process_died,<0.214.0>,normal} > [17/Sep/2006:12:50:10 +0530] reporting error: traverse exit from apply: > mod_esi:do => > {mod_esi_linked_process_died,<0.218.0>,normal} > > ------------------------------------------------------ > error_disk_log.1 -- inets > > {mod_esi_linked_process_died,<0.305.0>,normal}[17/Sep/2006:09:20:23 +0530] > reporting error: traverse exit from apply: mod_esi:do => > {mod_esi_linked_process_died,<0.221.0>,normal}[17/Sep/2006:09:20:25 +0530] > reporting error: traverse exit from apply: mod_esi:do => > {mod_esi_linked_process_died,<0.225.0>,normal}[17/Sep/2006:10:05:56 +0530] > server crash for 192.168.129.20, reason: "Error reading request: No request > received on keep-alive connectionbefore server side timeout" > [17/Sep/2006:12:50:08 +0530] reporting error: traverse exit from apply: > mod_esi:do => > {mod_esi_linked_process_died,<0.214.0>,normal}[17/Sep/2006:12:50:10 +0530] > reporting error: traverse exit from apply: mod_esi:do => > {mod_esi_linked_process_died,<0.218.0>,normal} > > ------------------------------------------------------ > > ??????????????????????????????????????????????????????????????????????????????? > > _______________________________________________ > 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 -- Michael McDaniel Portland, Oregon, USA http://autosys.us +1 503 283 5284 From jahakala@REDACTED Mon Sep 18 16:17:08 2006 From: jahakala@REDACTED (Jani Hakala) Date: Mon, 18 Sep 2006 17:17:08 +0300 Subject: [erlang-questions] gen_tcp question In-Reply-To: (Joe Armstrong's message of "Mon\, 18 Sep 2006 11\:19\:27 +0200") References: Message-ID: <874pv5dztn.fsf@pingviini.kortex.jyu.fi> "Joe Armstrong (TN/EAB)" writes: > Hi Jani, > > My problem is that I am NOT using gen_tcp:recv at all - I need to open > the socket in active mode, since I want to receive both messages from > the socket and send messages to the socket at the same time. > I didn't notice that the value {active, true} was being used implicitly (it being a default value). > I want to write a middle-man that abstracts out the TCP transport > layer so I write a process that understands TCP and converts terms to > packets etc. > > The problem occurs in the following bit of code: > > > (C is the Pid of a client) > > {ok, L} = gen_tcp:listen(Port, > [{length,4},binary,{active,true}]), > I assume length is supposed to be packet > {ok, S} = gen_tcp:accept(L), > loop(S, C). > > loop(S, C) -> > receive > {tcp, S, Bin} -> %% <----- Is Bin of length 4 > here????????????? > Length of Bin can be something between 1 byte and several megabytes. The four extra bytes inserted by using {packet,4} option are silently removed by underlying inet_drv. > I need the active=true mode for this since loop has to handle messages > from both C and S - so I don't want to block in gen_tcp:recv > > So my question is "is Bin" fragmented? - I can easily add an extra > layer for packet recombination inside loop, it is really unclear to me > what the purpose of saying {packet,4} is in the listen call if it is > not to be used for recombination. > When using {packet,PacketType}, PacketType=1,2 or 4 inet_drv receives (sends) 1, 2 or 4 byte header before the message you are receiving (sending). Those bytes correspond to one 8bit, 16bit or 32bit integer numbers that tell how long the message is going to be. The C-code in inet_drv then receives (sends) the header and the message in one or fragments which should happen under the hood. > Now if the answer to this question is in the documentation I can't > seem to find it the setopts documentation says that a 4 byte header is > appended to the TCP data - that's all. > >From inet(3erl) manpage {packet, PacketType} (TCP/IP sockets): Defines the type of packets to use for a socket. The fol- lowing values are valid: raw | 0: No packaging is done. 1 | 2 | 4: Packets consist of a header specifying the number of bytes in the packet, followed by that number of bytes. The length of header can be one, two, or four bytes; the order of the bytes is big-endian. Each send operation will generate the header, and the header will be stripped off on each receive opera- tion. asn1 | cdr | sunrm | fcgi | tpkt | line: ... Jani Hakala From ulf.wiger@REDACTED Mon Sep 18 16:32:12 2006 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Mon, 18 Sep 2006 16:32:12 +0200 Subject: [erlang-questions] ERTS; code-server; dynamically loading of code In-Reply-To: <20060918135257.GA28633@server.hoholz.local> Message-ID: Of course, toying with dynamic code loading is great fun. In a current project, I do dynamic code loading from mnesia on demand. Rather than messing with the error handler, I do something like this: try_module(Who, UserStr, Mod, IsOwner) -> try list_to_existing_atom(Mod) of ActualName -> case erlang:module_loaded(ActualName) of true -> ...; false -> try_load(Who, UserStr, Mod) end catch ... end. try_load(Who, UserStr, Mod) -> ..., case mnesia:read({?CODE_TABLE, list_to_binary(Mod)}) of [] -> false; [#tups{value = #mod{bin = Bin}}] -> ..., case code:load_binary(ActualName, Fname, Bin) of {module, _} -> {true, ActualName}; ... end end. Prototype code, mind you, but it seems to work reasonably well. Points of interest are: - list_to_existing_atom/1 to avoid dynamically creating unknown atoms - erlang:module_loaded/1 - code:load_binary/3 BR, Ulf W > -----Original Message----- > From: erlang-questions-bounces@REDACTED > [mailto:erlang-questions-bounces@REDACTED] On Behalf Of > Matthias Kretschmer > Sent: den 18 september 2006 15:53 > To: erlang-questions@REDACTED > Subject: Re: [erlang-questions] ERTS; code-server;dynamically > loading of code > > Hello, > > thank you two for the information. > > On Mon, Sep 18, 2006 at 11:05:02AM +0200, Ulf Wiger (TN/EAB) wrote: > > I second Lennart's opinion. Don't mess with the code > loading unless you've become One with the Erlang environment. > > > > [...] > > Don't worry, I at least think I know what I am doing and I am > just toying around and experimenting a bit. So the next plane > you use wouldn't crash because of me and toying around with > code loading. Thank god! :-) > > Just had in mind doing some more stuff than just loading a > module. I know, that modules are dynamically loaded. Anyway > just toying around with the Erlang runtime. > > -- > Cheers, > Matthias Kretschmer > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From mel.boyce@REDACTED Mon Sep 18 16:35:51 2006 From: mel.boyce@REDACTED (Mel Boyce) Date: Tue, 19 Sep 2006 00:35:51 +1000 Subject: [erlang-questions] New to Erlang Message-ID: <450EAEC7.2030505@gmail.com> Hi, I've been working on getting Erlang into my head and am struggling to find documentation suitable for someone just getting into it. What are the recommendations? Thanks, -- Mel Boyce From serge@REDACTED Mon Sep 18 16:45:25 2006 From: serge@REDACTED (Serge Aleynikov) Date: Mon, 18 Sep 2006 10:45:25 -0400 Subject: [erlang-questions] gen_tcp question In-Reply-To: References: Message-ID: <450EB105.20404@hq.idt.net> Joe Armstrong (TN/EAB) wrote: > {ok, L} = gen_tcp:listen(Port, > [{length,4},binary,{active,true}]), I hope it is a typo, because there's no {length, N} socket option. Did you, perhaps, mean {packet, 4}? > loop(S, C) -> > receive > {tcp, S, Bin} -> %% <----- Is Bin of length 4 > here????????????? > C ! binary_to_term(Bin), > loop(S, C); > {tcp_closed, S} -> > C ! closed; > {msg, Term} -> > gen_tcp:send(S, term_to_binary(Term)), > loop(S, C); > close -> > gen_tcp:close(S) > end I wouldn't be able to say how this was *supposed* to work since this is unclear from the documentation. However, by knowing the details of the inet_drv C driver I can tell you that the difference in the driver behavior in presence of the {active, true} option is that in contrast to the gen_tcp:recv/2, when the driver is getting a command from the Erlang process to issue a socket read, the active option initiates a socket read upon detecting some data on the socket in exactly the same manner as if the gen_tcp:recv(Sock, 0) was called. In both cases you are guaranteed to get the *full non-fragmented* packet of length M (where M is read from the message header determined by the N bytes with respect to the {packet, N} option). Note that since gen_tcp:recv(Sock, M), where M > 0 is not a possible call for sockets with {packet, N} where N =/= 0, it would also be meaningless to have the {packet, N} option if it didn't guarantee non-fragmented delivery of packets. > I need the active=true mode for this since loop has to handle messages > from both C and S - so I don't want to block in gen_tcp:recv Since you are including this example in the book, I'd recommend additionally showing how to use active sockets and still preserve flow control without gen_tcp:recv, so that you can implement the server using the standard OTP gen_server behavior. This can be accomplished by using {active, once} option. > Now if the answer to this question is in the documentation I can't seem > to find it > the setopts documentation says that a 4 byte header is appended to the > TCP data - that's > all. I also don't believe this is documented. Regards, Serge >> -----Original Message----- >> From: Jani Hakala [mailto:jahakala@REDACTED] >> Sent: den 14 september 2006 15:33 >> To: erlang-questions@REDACTED >> Cc: Joe Armstrong (TN/EAB) >> Subject: Re: [erlang-questions] gen_tcp question >> >> "Joe Armstrong (TN/EAB)" writes: >> >>> The behaviour appears not to be documented >>> >> Meaning of {packet,N} is explained in man inet, inet:setopts >> The behaviour of gen_tcp:recv is explained in man gen_tcp >> >> Jani Hakala >> > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From bengt.kleberg@REDACTED Mon Sep 18 17:07:06 2006 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Mon, 18 Sep 2006 17:07:06 +0200 Subject: [erlang-questions] New to Erlang In-Reply-To: <450EAEC7.2030505@gmail.com> References: <450EAEC7.2030505@gmail.com> Message-ID: <450EB61A.9020201@ericsson.com> On 2006-09-18 16:35, Mel Boyce wrote: > Hi, > I've been working on getting Erlang into my head and am struggling to > find documentation suitable for someone just getting into it. What are > the recommendations? i would recommend the book: Erlang Programmation. Mika?l R?mond. Eyrolles, 2003, ISBN 2-212-11079-0 bengt -- EPO guidelines 1978: "If the contribution to the known art resides solely in a computer program then the subject matter is not patentable in whatever manner it may be presented in the claims." From mats.cronqvist@REDACTED Mon Sep 18 17:15:29 2006 From: mats.cronqvist@REDACTED (Mats Cronqvist) Date: Mon, 18 Sep 2006 17:15:29 +0200 Subject: [erlang-questions] multi-threaded woes In-Reply-To: <3A76756EED583B43A4AD704E29CCD07974116A@mail.aprsmartlogik.com> References: <3A76756EED583B43A4AD704E29CCD07974116A@mail.aprsmartlogik.com> Message-ID: <450EB811.8040208@ericsson.com> Bob Cowdery wrote: >I don't think there is a suitable Erlang binding to a GUI library such that Erlang can drive. gtknode (http://code.google.com/p/gtknode) is a c-node that implements libglade/GTK+2.8. From sean.hinde@REDACTED Mon Sep 18 17:29:36 2006 From: sean.hinde@REDACTED (Sean Hinde) Date: Mon, 18 Sep 2006 16:29:36 +0100 Subject: [erlang-questions] New to Erlang In-Reply-To: <450EAEC7.2030505@gmail.com> References: <450EAEC7.2030505@gmail.com> Message-ID: <3958CCA3-0A23-4827-832C-ABC686E480AF@gmail.com> Hi Mel, I learnt the basics from the old erlang book, part 1 of which is available online. It doesn't cover all the new features of the language, but it is very good for getting started. The URL of part 1 of the book is: http://www.erlang.org/download/ erlang-book-part1.pdf The online documentation does a pretty good job of providing the next level, and then there is a wealth of example code written by excellent erlang programmers in the libraries. These are all open source and well worth a look. lists.erl is a good place to start. The best way as ever is to have something small and useful to implement and learn as you go along Finally there is the mailing list. The archives contain a wealth of knowledge, and people here are always willing to help once you have demonstrated a good level of self-learning pain :-) Sean On 18 Sep 2006, at 15:35, Mel Boyce wrote: > Hi, > I've been working on getting Erlang into my head and am struggling to > find documentation suitable for someone just getting into it. What are > the recommendations? > > Thanks, > > -- > Mel Boyce > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From stefan.l.axelsson@REDACTED Mon Sep 18 17:33:10 2006 From: stefan.l.axelsson@REDACTED (Stefan Axelsson L (LN/EAB)) Date: Mon, 18 Sep 2006 17:33:10 +0200 Subject: [erlang-questions] Good Erlang style? In-Reply-To: <20060918084213.610875A1F7@mail.erlangsystems.com> Message-ID: <6D145AB0AF765D4988C49705263A1DBC04521A04@esealmw106.eemea.ericsson.se> >norbertk: > Yes, that is a problem for me too. I have the feling that these languages have a lot of > practical value, but is is hard to come by without the theoretical background. > defmacro.rg is very valuable because it presents the thinking of FP in a language which > is understandable for programmers in vonventional languages. Well, there are really two parts to this state of affairs IMHO. The first is that CS departments tend to be (at least half) full of people who are much to good at mathematics, if not for their own good, at least for the rest of us. So the way in which the material is presented is often obtuse to those who don't have the prerequisite background. That's not to say that the ideas are often that complex themselves, but the presentation can be dense (like say; being-hit-in-the-face-with-a-short-plank dense). (Quite a bit of the work is also completely and utterly useless, but that's another post, for another day). The second is that you *do* have to adjust your thinking when approaching a new paradigm of programming. However, Erlang is at the more (shall we say) practical end of the scale. You don't have to be too violent with yourself to wrap your head around the (fairly few) functional programming concepts you need to write useful systems, like an SGSN or an AXD 301 :-). So I'd say that given that you've learned to program at all (which is quite frankly an insurmountable hurdle for some, otherwise intelligent people) Erlang shouldn't be troublesome and the available documentation and material reflects that IMHO. There isn't too much obtuse stuff published about Erlang in particular. The same isn't necessarily true for other languages e.g. Haskell. Stefan, -- Stefan Axelsson PhD, (ERVSTAX), tel: +46 31 747 3963 From Bob.Cowdery@REDACTED Mon Sep 18 17:48:30 2006 From: Bob.Cowdery@REDACTED (Bob Cowdery) Date: Mon, 18 Sep 2006 16:48:30 +0100 Subject: [erlang-questions] multi-threaded woes Message-ID: <3A76756EED583B43A4AD704E29CCD07974116B@mail.aprsmartlogik.com> -----Original Message----- From: Mats Cronqvist [mailto:mats.cronqvist@REDACTED] Sent: 18 September 2006 16:15 To: Bob Cowdery Cc: Vlad Dumitrescu; Erlang-Questions (E-mail) Subject: Re: [erlang-questions] multi-threaded woes Bob Cowdery wrote: >I don't think there is a suitable Erlang binding to a GUI library such that Erlang can drive. >> gtknode (http://code.google.com/p/gtknode) is a c-node that implements libglade/GTK+2.8. It's interesting and at first glance looks a similar approach to mine. It's a C node though and not a C port so clearly its possible to do. It sends interactions as messages and receives back updates. I will have to look closer to see if it could cope with multiple updates per interaction and unsolicited updates. I think looking at the code will be instructive for me anyway so thanks for the pointer. Bob From yarivvv@REDACTED Mon Sep 18 17:56:26 2006 From: yarivvv@REDACTED (Yariv Sadan) Date: Mon, 18 Sep 2006 11:56:26 -0400 Subject: [erlang-questions] Good Erlang style? In-Reply-To: <20060918084213.610875A1F7@mail.erlangsystems.com> References: <20060918084213.610875A1F7@mail.erlangsystems.com> Message-ID: <17244f480609180856g51bd366r415ff7b14155fbe5@mail.gmail.com> Hi, > > > Guest wrote: > > I've felt a bit daunted as I've dabbled into FP languages - it seems > to be a field where a lot of academic research occurs (perhaps due to > the lack of side effects?) and as I've had no CS formal education > (yet) I sometimes have trouble following what's happening in some of > the papers I read; ACM papers are a prime example. > > (end of quote) > > Yes, that is a problem for me too. I have the feling that these languages have a lot of practical value, but is is hard to come by without the theoretical background. defmacro.rg is very valuable because it presents the thinking of FP in a language which is understandable for programmers in vonventional languages. > > > Norbert > I have come from the OO world as well, but once I became comfortable with functional semantics I realized that many functional languages are actually much simpler than OO langues (esp Erlang). It feels like functional programming lets you get straight to the problem solving without worrying too much about all the complexity of OO patterns. Erlang is a much simpler language to learn than Java, C++, C#, etc IMO (but that doesn't mean it's less powerful -- quite the opposite: with simplicity comes a lot of power). Best, Yariv From serge@REDACTED Mon Sep 18 18:51:23 2006 From: serge@REDACTED (Serge Aleynikov) Date: Mon, 18 Sep 2006 12:51:23 -0400 Subject: [erlang-questions] gen_tcp question In-Reply-To: References: Message-ID: <450ECE8B.8000502@hq.idt.net> Joe, See in-line comments. Joe Armstrong (TN/EAB) wrote: > Hi Serge, > > It seems to me that the program "does the right thing" (ie recombines > fragmented packets if packet>0) but that this fact is not documented. > > I can understand that {packet,4} adds a 4 byte header on transmission > so for example, a C program can read this and do whever it wants. > > But since the packet,4 header is silently removed in the Erlang case > (with an active socket) then it become invisible, so I have to add my > own private size(BIN) (as 4 bytes) in front of each Binary I send > and then do a re-entrant package reassembly in Erlang (not difficult, > but it seems a bit daft, since in this case I could just have used > packet,0 > and done the reassembly anyway) > > Sean, claims that packets are not fragmented, ie that the driver > reassembles the packets in the case when a packet length is > given, ie does the right thing Yes, I concur with Sean's claim. > Jani said in his last mail > > Jani> When using {packet,PacketType}, PacketType=1,2 or 4 inet_drv > receives > Jani> (sends) 1, 2 or 4 byte header before the message you are receiving > (sending). Those bytes > Jani> correspond to one 8bit, 16bit or 32bit integer numbers that tell > how long the message is going Jani> to be. The C-code in inet_drv then > receives (sends) the header and the message in one or > Jani> fragments which should happen under the hood. > > I think this is the opposite of what Sean says > > I'm not really sure what " .. and the message in one or two fragments > .." means. I am not clear about this sentence either, but I believe Jani meant the same thing as Sean. [...] > It seems to me that the logical behaviour if a packet size is given is > that the > Erlang messages are delivered from and to the driver in unfragmented > binaries > and that the messages on the line are preceded by a header and then > possible fragmented. Correct. It would be infeasible to assume that messages can be not fragmented on the transport layer, as it's beyond the control of the C driver used by the emulator, and is fully dependent on the underlying protocol. For instance, in case of SCTP the protocol preserves message boundaries, so a receive call on an SCTP socket would always guarantee that a message is either delivered in full, or an error is generated. > I gave up and started reading inet_drv.c - somewhere in 7071 lines of is > the answer ... > but it's not obvious to me where this is ... You can examine the following functions: tcp_recv() tcp_remain() tcp_deliver() > I didn't really understand this comment > >> Since you are including this example in the book, I'd >> recommend additionally showing how to use active sockets and >> still preserve flow control without gen_tcp:recv, so that you >> can implement the server using the standard OTP gen_server >> behavior. This can be accomplished by using {active, once} option. > > Can you expand on this with (possibly) an example? Surely! Let's say that we wanted to accomplish the following: 1. Implement a TCP server receiving client connection requests, and communicating over some custom protocol. 2. Ensure that there's flow control on the server side and that clients will not bring down the server by over-flooding its message queue. 3. Use standard OTP behaviors to implement the server process handling client transactions. Now, say we learn how to accomplish #1 by studying your tcp_server tutorial: http://www.sics.se/~joe/tutorials/web_server/tcp_server.erl #2 can be accomplished by ensuring that if too much traffic is being generated by clients, we have control over how that traffic is dispatched to the mailbox of the Erlang server process handling client's transactions. This is done by either: a. Using blocking gen_tcp:recv/2 socket calls. In this case the Erlang process actively reads data from the socket's buffer, and this data doesn't reach server process mailbox. The drawback of this approach is that it introduces a blocking behavior to the process, and we cannot use selective receive to respond to other messages coming to the process mailbox. b. Using the {active, once} server socket option, and not using the blocking gen_tcp:recv/2 call, but relying on the gen_tcp's ability to read and deliver *one* message to the mailbox of the server process. This is great because we no longer have to deal with blocking calls in the program, and can use standard gen_server behavior to implement the server. The trick is that after receiving and processing a message from the mailbox, the server needs to issue a call to inet:setopts(Sock, [{active, once}]) to allow the gen_tcp socket to deliver the next message. #3 is illustrated by the example below. Note that I am only including a few gen_server callbacks that illustrate this point. -module(custom_server). -behavior(gen_server). % Create a new process handling interactions with the client. If this % server was a part of an application with a supervisor, we could use % the simple_one_for_one restart strategy in the supervisor for these % server processes. In this case in a production system a crash of % such a server would automatically generate and log an error report by % the supervisor / SASL. The difference in server creation then would % that we'd call supervisor:start_child/2 instead of gen_server:start % to create the server process. new_client(Socket) -> {ok, Pid} = gen_server:start(?MODULE, [Socket], []), % Here we assume that the calling process had the ownership of the % socket. We need to delegate that ownership to the newly created % gen_server in order for the active socket to deliver messages to % the proper Pid. ok = gen_tcp:controlling_process(Socket, Pid), {ok, Pid}. ... % Let's assume that the socket is created by init([Socket]) -> inet:setopts(Socket, [{active, once}, {packet, 4}, binary]), ... {ok, State#state{sock = Socket}}. handle_info({tcp, Socket, Data}, #state{sock=Socket} = State) -> % Note that Data is delivered non-fragmented here NewState = do_handle_request(Socket, Data, State), inet:setopts(Socket, [{active, once}]), {noreply, NewState}; ... Please note the following: 1. It is not clear from documentation if the socket returned from the acceptor call inherits any options given to the listen socket. I.e. if the listen socket was opened with: {ok, ListenSocket} = listen(Port, [{packet, 4}]). would the server process accepting the client socket need to explicitly call inet:setopts(Socket, [{packet, 4}]) after the following statement? {ok, Socket} = accept(ListenSocket). Or is that option inherited from the listener socket? I don't think any options are inherited, and call that explicitly, but it would be nice if documentation mentioned something about it. 2. Is it possible to turn the socket acceptor process into a gen_server? The gen_tcp:accept/1 call is blocking by nature, and I don't see how this could be done. However, this server pattern is fairly generic, and it would be nice if it could be completely mapped to some OTP behavior. Regards, Serge > Thanks a lot > > /Joe > > >> -----Original Message----- >> From: Serge Aleynikov [mailto:serge@REDACTED] >> Sent: den 18 september 2006 16:45 >> To: Joe Armstrong (TN/EAB) >> Cc: erlang-questions@REDACTED >> Subject: Re: [erlang-questions] gen_tcp question >> >> Joe Armstrong (TN/EAB) wrote: >>> {ok, L} = gen_tcp:listen(Port, >>> [{length,4},binary,{active,true}]), >> I hope it is a typo, because there's no {length, N} socket >> option. Did you, perhaps, mean {packet, 4}? >> >>> loop(S, C) -> >>> receive >>> {tcp, S, Bin} -> %% <----- Is Bin of length 4 >>> here????????????? >>> C ! binary_to_term(Bin), >>> loop(S, C); >>> {tcp_closed, S} -> >>> C ! closed; >>> {msg, Term} -> >>> gen_tcp:send(S, term_to_binary(Term)), >>> loop(S, C); >>> close -> >>> gen_tcp:close(S) >>> end >> I wouldn't be able to say how this was *supposed* to work >> since this is unclear from the documentation. However, by >> knowing the details of the inet_drv C driver I can tell you >> that the difference in the driver behavior in presence of the >> {active, true} option is that in contrast to the >> gen_tcp:recv/2, when the driver is getting a command from the >> Erlang process to issue a socket read, the active option >> initiates a socket read upon detecting some data on the >> socket in exactly the same manner as if the >> gen_tcp:recv(Sock, 0) was called. In both cases you are >> guaranteed to get the *full non-fragmented* packet of length >> M (where M is read from the message header determined by the >> N bytes with respect to the {packet, N} option). >> >> Note that since gen_tcp:recv(Sock, M), where M > 0 is not a >> possible call for sockets with {packet, N} where N =/= 0, it >> would also be meaningless to have the {packet, N} option if >> it didn't guarantee non-fragmented delivery of packets. >> >>> I need the active=true mode for this since loop has to >> handle messages >>> from both C and S - so I don't want to block in gen_tcp:recv >> Since you are including this example in the book, I'd >> recommend additionally showing how to use active sockets and >> still preserve flow control without gen_tcp:recv, so that you >> can implement the server using the standard OTP gen_server >> behavior. This can be accomplished by using {active, once} option. >> >>> Now if the answer to this question is in the documentation I can't >>> seem to find it the setopts documentation says that a 4 >> byte header is >>> appended to the TCP data - that's all. >> I also don't believe this is documented. >> >> Regards, >> >> Serge >> >>>> -----Original Message----- >>>> From: Jani Hakala [mailto:jahakala@REDACTED] >>>> Sent: den 14 september 2006 15:33 >>>> To: erlang-questions@REDACTED >>>> Cc: Joe Armstrong (TN/EAB) >>>> Subject: Re: [erlang-questions] gen_tcp question >>>> >>>> "Joe Armstrong (TN/EAB)" writes: >>>> >>>>> The behaviour appears not to be documented >>>>> >>>> Meaning of {packet,N} is explained in man inet, inet:setopts The >>>> behaviour of gen_tcp:recv is explained in man gen_tcp >>>> >>>> Jani Hakala >>>> >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://www.erlang.org/mailman/listinfo/erlang-questions >>> >> > From serge@REDACTED Mon Sep 18 18:59:15 2006 From: serge@REDACTED (Serge Aleynikov) Date: Mon, 18 Sep 2006 12:59:15 -0400 Subject: [erlang-questions] gen_tcp question In-Reply-To: <450ECE8B.8000502@hq.idt.net> References: <450ECE8B.8000502@hq.idt.net> Message-ID: <450ED063.1050205@hq.idt.net> Note that the "Let's assume ..." comment in my previous email got only partially deleted. That comment line should be deleted completely: Serge Aleynikov wrote: > % Let's assume that the socket is created by > init([Socket]) -> > inet:setopts(Socket, [{active, once}, {packet, 4}, binary]), Serge From bob@REDACTED Mon Sep 18 19:29:58 2006 From: bob@REDACTED (Bob Ippolito) Date: Mon, 18 Sep 2006 10:29:58 -0700 Subject: [erlang-questions] New to Erlang In-Reply-To: <450EAEC7.2030505@gmail.com> References: <450EAEC7.2030505@gmail.com> Message-ID: <6a36e7290609181029m7648b1a5ud8c49d72752cb228@mail.gmail.com> On 9/18/06, Mel Boyce wrote: > Hi, > I've been working on getting Erlang into my head and am struggling to > find documentation suitable for someone just getting into it. What are > the recommendations? > The absolute best resource I came across when learning Erlang was Joe Armstrong's 2003 thesis [1]. It reads more like a good book on the history and usage of Erlang than a thesis, and there's no greek :) [1] http://www.sics.se/~joe/index.html - Making reliable systems in the presence of software errors -bob From jefcrane@REDACTED Mon Sep 18 20:00:37 2006 From: jefcrane@REDACTED (Jeff Crane) Date: Mon, 18 Sep 2006 11:00:37 -0700 (PDT) Subject: [erlang-questions] New to Erlang In-Reply-To: <450EAEC7.2030505@gmail.com> Message-ID: <20060918180037.74577.qmail@web31601.mail.mud.yahoo.com> I've been trying to learn erlang for the last year off and on in my free time. The online documentation hasn't been much help (to me) as a teaching aide, nor as a reference material given my lack of understanding of the language. A Javadoc style web reference would be something I could get behind. I've primarily taught myself from examples: http://www.matt-mcdonnell.com/code/code_erl/erl_course/erl_course.html http://www.erlang.org/examples/klacke_examples/index.html http://erlang.stacken.kth.se/examples/win95demo/win95demo.html http://www.erlang.org/examples/examples-2.0.html Joe's TCP Server examples, etc. >From this I've learned in a lopsided fashion, with a focus on networking and process parallelism, but I know some erlang! --- Mel Boyce wrote: > Hi, > I've been working on getting Erlang into my head and > am struggling to > find documentation suitable for someone just getting > into it. What are > the recommendations? > > Thanks, > > -- > Mel Boyce > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From erlangX@REDACTED Mon Sep 18 22:34:32 2006 From: erlangX@REDACTED (Michael McDaniel) Date: Mon, 18 Sep 2006 13:34:32 -0700 Subject: [erlang-questions] Good Erlang style? In-Reply-To: <20060918084213.610875A1F7@mail.erlangsystems.com> References: <20060918084213.610875A1F7@mail.erlangsystems.com> Message-ID: <20060918203432.GF5853@delora.autosys.us> There was some discussion about learning erlang last December. Here is a post I did back then http://article.gmane.org/gmane.comp.lang.erlang.general/13036 googling on learning erlang OR fp OR "functional programming" turns up more resources as well. ~Michael On Mon, Sep 18, 2006 at 09:42:13AM +0100, norbertk wrote: > > > Guest wrote: > > I've felt a bit daunted as I've dabbled into FP languages - it seems > to be a field where a lot of academic research occurs (perhaps due to > the lack of side effects?) and as I've had no CS formal education > (yet) I sometimes have trouble following what's happening in some of > the papers I read; ACM papers are a prime example. > > (end of quote) > > Yes, that is a problem for me too. I have the feling that these languages have a lot of practical value, but is is hard to come by without the theoretical background. defmacro.rg is very valuable because it presents the thinking of FP in a language which is understandable for programmers in vonventional languages. > > > Norbert > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > Post recived from mailinglist[/quote] > _________________________________________________________ > Post sent from http://www.trapexit.org > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- Michael McDaniel Portland, Oregon, USA http://autosys.us +1 503 283 5284 From ckerr@REDACTED Tue Sep 19 00:02:27 2006 From: ckerr@REDACTED (Cameron Kerr) Date: Tue, 19 Sep 2006 10:02:27 +1200 Subject: [erlang-questions] Finding IP addresses in a PC In-Reply-To: <42ea5fb60609180403n568992a1oe1118851f0fe5087@mail.gmail.com> References: <42ea5fb60609180052s107ad322h78b66786cc45feca@mail.gmail.com> <450E72E7.1060504@sbyt.amur.elektra.ru> <42ea5fb60609180403n568992a1oe1118851f0fe5087@mail.gmail.com> Message-ID: Hmm, looks like an endian issue. Works fine on my PPC Mac, and my x86 Linux machine. By "PC" I assume you mean some Windows machine, what version? Did you compile Erlang yourself, or get it from an official source, or other? On 18/09/2006, at 11:03 PM, Surindar Sivanesan wrote: > Hi > Thanks for your timely help. > I'm able to get the IP addresses using inet:getiflist() but those > IP address is reversed. > Ex: 192.168.1.60 is displayed as 60.100.861.291. > Is there any option to get the IP as such. > This is just for info > > Thanks once again > > Best regards, > S.Surindar. > > > On 9/18/06, Evgeniy Khramtsov wrote: > Surindar Sivanesan ?????: > > > Dear all, > > If my PC has several IP addresses, is it possible to find the IP > > addresses > > in that PC? > > If so, please help me in getting those IP addresses. > > Thanks in advance. > > inet:getif(). > inet:getiflist(). > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > -- > with regards, > S.Surindar > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- ? Cameron Kerr ? ? ckerr@REDACTED ? ? ? ? Telecommunications Teaching Fellow & SysAdmin ? ? ? http://humbledown.org/blog/ ? ? 021 02333294 NEW NUMBER ? -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob@REDACTED Tue Sep 19 00:18:26 2006 From: bob@REDACTED (Bob Ippolito) Date: Mon, 18 Sep 2006 15:18:26 -0700 Subject: [erlang-questions] Finding IP addresses in a PC In-Reply-To: <42ea5fb60609180403n568992a1oe1118851f0fe5087@mail.gmail.com> References: <42ea5fb60609180052s107ad322h78b66786cc45feca@mail.gmail.com> <450E72E7.1060504@sbyt.amur.elektra.ru> <42ea5fb60609180403n568992a1oe1118851f0fe5087@mail.gmail.com> Message-ID: <6a36e7290609181518s186cf51jd0edbd7b1c87fa8b@mail.gmail.com> That's not an endian issue, that's a backwards string. How about showing us what expression you actually evaluated? inet:getiflist() returns interface names, and inet:getif() returns address tuples; neither of them could've possibly produced that output... -bob On 9/18/06, Surindar Sivanesan wrote: > Hi > Thanks for your timely help. > I'm able to get the IP addresses using inet:getiflist() but those IP address > is reversed. > Ex: 192.168.1.60 is displayed as 60.100.861.291. > Is there any option to get the IP as such. > This is just for info > > Thanks once again > > Best regards, > S.Surindar. > > > > On 9/18/06, Evgeniy Khramtsov wrote: > > Surindar Sivanesan ?????: > > > > > Dear all, > > > If my PC has several IP addresses, is it possible to find the IP > > > addresses > > > in that PC? > > > If so, please help me in getting those IP addresses. > > > Thanks in advance. > > > > inet:getif(). > > inet:getiflist(). > > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > > -- > with regards, > S.Surindar > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > > From ulf@REDACTED Tue Sep 19 00:22:38 2006 From: ulf@REDACTED (Ulf Wiger) Date: Tue, 19 Sep 2006 00:22:38 +0200 Subject: [erlang-questions] New to Erlang In-Reply-To: <20060918180037.74577.qmail@web31601.mail.mud.yahoo.com> References: <20060918180037.74577.qmail@web31601.mail.mud.yahoo.com> Message-ID: Have these links not been helpful in giving a first introduction to the language? Den 2006-09-18 20:00:37 skrev Jeff Crane : > I've been trying to learn erlang for the last year off > and on in my free time. The online documentation > hasn't been much help (to me) as a teaching aide, nor > as a reference material given my lack of understanding > of the language. Getting started: http://www.erlang.org/doc/doc-5.5.1/doc/getting_started/part_frame.html Basic Erlang course: http://www.erlang.org/course/course.html Erlang Reference Manual: http://www.erlang.org/doc/doc-5.5.1/doc/reference_manual/part_frame.html Erlang in Real-Time by Maurice Castro: http://www.castro.aus.net/~maurice/serc/erlbk/ BR, Ulf Wiger -- Ulf Wiger From rath64@REDACTED Tue Sep 19 00:44:44 2006 From: rath64@REDACTED (Tim Rath) Date: Mon, 18 Sep 2006 17:44:44 -0500 (CDT) Subject: [erlang-questions] Finding IP addresses in a PC Message-ID: <71270.1998961158619485060.JavaMail.root@vms068.mailsrvcs.net> Someone else noticed this behavior on a windows machine during a similar thread discussion a while back: http://www.erlang.org/ml-archive/erlang-questions/200401/msg00264.html >That's not an endian issue, that's a backwards string. How about showing us what expression you actually evaluated? inet:getiflist() returns interface names, and inet:getif() returns address tuples; neither of them could've possibly produced that output... -bob On 9/18/06, Surindar Sivanesan wrote: > Hi > Thanks for your timely help. > I'm able to get the IP addresses using inet:getiflist() but those IP address > is reversed. > Ex: 192.168.1.60 is displayed as 60.100.861.291. > Is there any option to get the IP as such. > This is just for info > > Thanks once again > > Best regards, > S.Surindar. From surindar.shanthi@REDACTED Tue Sep 19 06:10:16 2006 From: surindar.shanthi@REDACTED (Surindar Sivanesan) Date: Tue, 19 Sep 2006 09:40:16 +0530 Subject: [erlang-questions] Finding IP addresses in a PC In-Reply-To: References: <42ea5fb60609180052s107ad322h78b66786cc45feca@mail.gmail.com> <450E72E7.1060504@sbyt.amur.elektra.ru> <42ea5fb60609180403n568992a1oe1118851f0fe5087@mail.gmail.com> Message-ID: <42ea5fb60609182110ob7b1c68y873515096a57a7bd@mail.gmail.com> Hi I'm using OS Windows XP service pack2 On 9/19/06, Cameron Kerr wrote: > > Hmm, looks like an endian issue. Works fine on my PPC Mac, and my x86 > Linux machine. By "PC" I assume you mean some Windows machine, what version? > > > Did you compile Erlang yourself, or get it from an official source, or > other? > > On 18/09/2006, at 11:03 PM, Surindar Sivanesan wrote: > > Hi > Thanks for your timely help. > I'm able to get the IP addresses using inet:getiflist() but those IP > address is reversed. > Ex: 192.168.1.60 is displayed as 60.100.861.291. > Is there any option to get the IP as such. > This is just for info > > Thanks once again > > Best regards, > S.Surindar. > > > On 9/18/06, Evgeniy Khramtsov wrote: > > > > Surindar Sivanesan ?????: > > > > > Dear all, > > > If my PC has several IP addresses, is it possible to find the IP > > > addresses > > > in that PC? > > > If so, please help me in getting those IP addresses. > > > Thanks in advance. > > > > inet:getif(). > > inet:getiflist(). > > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > > -- > with regards, > S.Surindar > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > > -- > > ? Cameron Kerr ? ? ckerr@REDACTED ? ? ? > > ? Telecommunications Teaching Fellow & SysAdmin ? > ? ? http://humbledown.org/blog/ ? ? 021 02333294 * NEW NUMBER *? > > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > > -- with regards, S.Surindar -------------- next part -------------- An HTML attachment was scrubbed... URL: From samuelrivas@REDACTED Tue Sep 19 08:28:56 2006 From: samuelrivas@REDACTED (Samuel Rivas) Date: Tue, 19 Sep 2006 08:28:56 +0200 Subject: [erlang-questions] Finding IP addresses in a PC In-Reply-To: <71270.1998961158619485060.JavaMail.root@vms068.mailsrvcs.net> References: <71270.1998961158619485060.JavaMail.root@vms068.mailsrvcs.net> Message-ID: <20060919062856.GA4222@nodo2.lambdastream.com> Tim Rath wrote: > Someone else noticed this behavior on a windows machine during a similar thread discussion a while back: > > http://www.erlang.org/ml-archive/erlang-questions/200401/msg00264.html > > > > That's not an endian issue, that's a backwards string. How about > > showing us what expression you actually evaluated? inet:getiflist() > > returns interface names, and inet:getif() returns address tuples; > > neither of them could've possibly produced that output... And those functions are still undocumented (along with several rather useful sockopts). I wonder if it is simply lack of time or if ther are any good reason for those functions not to be public? Regards. -- Samuel From vladdu55@REDACTED Tue Sep 19 08:49:12 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Tue, 19 Sep 2006 07:49:12 +0100 Subject: [erlang-questions] multi-threaded woes In-Reply-To: <3A76756EED583B43A4AD704E29CCD079741166@mail.aprsmartlogik.com> References: <3A76756EED583B43A4AD704E29CCD079741166@mail.aprsmartlogik.com> Message-ID: <95be1d3b0609182349x53b058a6x623d60deccf81e3f@mail.gmail.com> Hi again, On 9/18/06, Bob Cowdery wrote: >I am having some trouble getting two C nodes which are both clients and servers >to connect both ways and not sure of the rules here. They both start listen >threads and sit on accept. Node 1 does a connect on node 2 which is successful >and sends it a message which it receives. Node 2 does a connect on Node 1 as >Node 1 is now guaranteed to be up, which is successful from the connect side >except Node 1 never comes off the accept so it never sees it. IMHO erl_interface provides great support for building a single-threaded C node. If you want it to be multithreaded, then you're on your own (i.e. just as much as with any C application). I never tried to do a double connect like you do. It is sufficient to connect from one side and then you can send messages both ways. Another possible issue might be that C nodes are primarily meant to talk to Erlang nodes, not between themselves. So I'm not sure how well a network of C nodes will function together. Maybe someone who tried it can tell. Checking out gtkNode seems a very good idea, especially if it covers much of what your own gui nodes need to do. good luck! Vlad From joe.armstrong@REDACTED Tue Sep 19 10:10:07 2006 From: joe.armstrong@REDACTED (Joe Armstrong (TN/EAB)) Date: Tue, 19 Sep 2006 10:10:07 +0200 Subject: [erlang-questions] new blog on transaction memories In-Reply-To: <95be1d3b0609182349x53b058a6x623d60deccf81e3f@mail.gmail.com> Message-ID: http://armstrongonsoftware.blogspot.com/2006/09/pure-and-simple-transact ion-memories.html /Joe From Bob.Cowdery@REDACTED Tue Sep 19 10:14:01 2006 From: Bob.Cowdery@REDACTED (Bob Cowdery) Date: Tue, 19 Sep 2006 09:14:01 +0100 Subject: [erlang-questions] multi-threaded woes Message-ID: <3A76756EED583B43A4AD704E29CCD07974116C@mail.aprsmartlogik.com> Hi It's not in my nature to change direction until I understand why my current direction does not work. Last night it became painfully obvious what was wrong. Although ei is thread safe it's not itself threaded. In other words ei blocks on a number of operations such that it can't process any other requests regardless of what application thread they arrive on, therefore it can't be a client and server in the same node. This is a shame because everything else works great. I'm not even sure it could handle multiple connects, in fact I'm pretty sure it couldn't as that requires doing an accept for each connection in a separate thread and sitting on a read for each. I tried coming off the read by using the timeout calls so giving things a chance to get through but it worked very intermittantly making me think that any call made while it was blocked was ditched. Given these limitations I can't use ei for the connection management unless I adopt some kind of polling architecture. This pretty much rules out C nodes. I think I have to redesign around erlang nodes and where necessary C ports. Regards Bob -----Original Message----- From: Vlad Dumitrescu [mailto:vladdu55@REDACTED] Sent: 19 September 2006 07:49 To: Bob Cowdery Cc: Erlang-Questions (E-mail) Subject: Re: [erlang-questions] multi-threaded woes Hi again, On 9/18/06, Bob Cowdery wrote: >I am having some trouble getting two C nodes which are both clients and servers >to connect both ways and not sure of the rules here. They both start listen >threads and sit on accept. Node 1 does a connect on node 2 which is successful >and sends it a message which it receives. Node 2 does a connect on Node 1 as >Node 1 is now guaranteed to be up, which is successful from the connect side >except Node 1 never comes off the accept so it never sees it. IMHO erl_interface provides great support for building a single-threaded C node. If you want it to be multithreaded, then you're on your own (i.e. just as much as with any C application). I never tried to do a double connect like you do. It is sufficient to connect from one side and then you can send messages both ways. Another possible issue might be that C nodes are primarily meant to talk to Erlang nodes, not between themselves. So I'm not sure how well a network of C nodes will function together. Maybe someone who tried it can tell. Checking out gtkNode seems a very good idea, especially if it covers much of what your own gui nodes need to do. good luck! Vlad From sanjaya@REDACTED Tue Sep 19 10:11:50 2006 From: sanjaya@REDACTED (Sanjaya Vitharana) Date: Tue, 19 Sep 2006 13:41:50 +0530 Subject: [erlang-questions] gen_fsm - timeout ? Message-ID: <062701c6dbc3$44b5d230$9a0a10ac@wavenet.lk> Hi ... ALL, Behavior: Gen FSM Scenario: Want to be in state "open" (see below) for limited time (assume 5 sec) until some EXPECTED event (as_E) comes, have to move to some other state if the expected event not received in that time. All other events should be ignored in state "open". Problem: Below works fine if no events other than expected comes. But what happend if SOME un-expected events received before timeout? It always keep updating the timeout value to 5000. Removing the timeout value from {next_state, open, State,5000} for "OtherEvents" will cause to stuck in the "open" forever if the expected event not received. Question: How the time out value should be use in this case ? Are there any way to set the timeout value ONCE for all "OtherEvents". ------------------------------------------- Asume this as beginning point as(blah,blah), %%Calling Async Func {next_state, open, State,5000}; ------------------------------------------- open(timeout, State) -> do_something, {next_state, Any_Appropriat, State}. open(as_E, State) -> do_something, {next_state, Any_Appropriat, State}. open(OtherEvents, State) -> {next_state, open, State,5000}. Thanks in advance Sanjaya Vitharana -------------- next part -------------- An HTML attachment was scrubbed... URL: From chandrashekhar.mullaparthi@REDACTED Tue Sep 19 11:06:34 2006 From: chandrashekhar.mullaparthi@REDACTED (Chandru) Date: Tue, 19 Sep 2006 10:06:34 +0100 Subject: [erlang-questions] gen_fsm - timeout ? In-Reply-To: <062701c6dbc3$44b5d230$9a0a10ac@wavenet.lk> References: <062701c6dbc3$44b5d230$9a0a10ac@wavenet.lk> Message-ID: On 19/09/06, Sanjaya Vitharana wrote: > > Hi ... ALL, > > Behavior: Gen FSM > > Scenario: > Want to be in state "open" (see below) for limited time (assume 5 sec) > until some EXPECTED event (as_E) comes, have to move to some other state > if the expected event not received in that time. All other events should > be ignored in state "open". > One way around this is to not use the built-in timeout functionality i.edrop the timeout value from the return value of the callback function. You can use erlang:send_after/3 to send yourself a message 5 seconds later. cheers Chandru -------------- next part -------------- An HTML attachment was scrubbed... URL: From sean.hinde@REDACTED Tue Sep 19 11:47:05 2006 From: sean.hinde@REDACTED (Sean Hinde) Date: Tue, 19 Sep 2006 10:47:05 +0100 Subject: [erlang-questions] gen_fsm - timeout ? In-Reply-To: References: <062701c6dbc3$44b5d230$9a0a10ac@wavenet.lk> Message-ID: <6169ECC1-AE32-4B5C-9DA9-B8EA17B0DA51@gmail.com> On 19 Sep 2006, at 10:06, Chandru wrote: > On 19/09/06, Sanjaya Vitharana wrote: > Hi ... ALL, > > Behavior: Gen FSM > > Scenario: > Want to be in state "open" (see below) for limited time (assume 5 > sec) until some EXPECTED event (as_E) comes, have to move to some > other state if the expected event not received in that time. All > other events should be ignored in state "open". > > > One way around this is to not use the built-in timeout > functionality i.e drop the timeout value from the return value of > the callback function. You can use erlang:send_after/3 to send > yourself a message 5 seconds later. Or you could use gen_fsm:send_event_after/2 which is designed to work seamlessly with the gen_fsm state handling. The timeout message is delivered directly into the current state callback. If you need the original timer reference in the timeout message (Useful f you don't have another reference to the transaction that has timed out, and want to find it in e.g. a local ets table) then gen_fsm: start_timer/2 can be used. Sean From tty.erlang@REDACTED Tue Sep 19 17:03:40 2006 From: tty.erlang@REDACTED (t ty) Date: Tue, 19 Sep 2006 11:03:40 -0400 Subject: [erlang-questions] Good Erlang style? In-Reply-To: <20060918084213.610875A1F7@mail.erlangsystems.com> References: <20060918084213.610875A1F7@mail.erlangsystems.com> Message-ID: <290b3ba10609190803t36b735d8sd05f354c94db02b6@mail.gmail.com> The theory helps but is not needed. What is your actual background ? t On 9/18/06, norbertk wrote: > > > Guest wrote: > > I've felt a bit daunted as I've dabbled into FP languages - it seems > to be a field where a lot of academic research occurs (perhaps due to > the lack of side effects?) and as I've had no CS formal education > (yet) I sometimes have trouble following what's happening in some of > the papers I read; ACM papers are a prime example. > > (end of quote) > > Yes, that is a problem for me too. I have the feling that these languages have a lot of practical value, but is is hard to come by without the theoretical background. defmacro.rg is very valuable because it presents the thinking of FP in a language which is understandable for programmers in vonventional languages. > > > Norbert > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > Post recived from mailinglist[/quote] > _________________________________________________________ > Post sent from http://www.trapexit.org > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From yarivvv@REDACTED Tue Sep 19 19:34:54 2006 From: yarivvv@REDACTED (Yariv Sadan) Date: Tue, 19 Sep 2006 13:34:54 -0400 Subject: [erlang-questions] ErlSQL: easy expression and generation of SQL statements in Erlang In-Reply-To: <95be1d3b0609170217v222edfbbgae641e55df37935b@mail.gmail.com> References: <17244f480609161359w75a772eaua97b239c5f71e7c4@mail.gmail.com> <95be1d3b0609170217v222edfbbgae641e55df37935b@mail.gmail.com> Message-ID: <17244f480609191034q51275bddk7508cae2d6abb7ac@mail.gmail.com> > That said, I think it's a good start and it opens interesting possibilities. You are right :) I added Lisp-style operator expansion to ErlSQL to simplify writing a sequence of clauses with the same operator. Here are a few examples {select,'*',{from,foo}, {where,{a,'=',{'+',[1,2,3]}}}} -> "SELECT * FROM foo WHERE (a = 1 + 2 + 3)" {select,'*',{from,foo} {where,{'=',[{'+',[a,b,c]},{'+',[d,e,f]}]}}} -> "SELECT * FROM foo WHERE a + b + c = d + e + f" {select,'*',{from,foo}, {where, {'and',[{a,'=',b},{c,'=',d},{e,'=',f}]}}} -> "SELECT * FROM foo WHERE (a = b) AND (c = d) AND (e = f)" More information is here: http://yarivsblog.com/articles/2006/09/19/new-erlsql-feature-lisp-style-operator-expansion Cheers, Yariv From ege@REDACTED Tue Sep 19 19:37:27 2006 From: ege@REDACTED (Gerald Exner) Date: Tue, 19 Sep 2006 19:37:27 +0200 Subject: [erlang-questions] memory leak or not ? Message-ID: <45102AD7.1090201@my-lan.de> Hi, i use werl on windows for development. the memory usage for werl rises every time i will connect and disconnect to my erlang-server (taskmanager) but the >erlang:memory(total) value will not. After reading 'Efficiency Guide' i've found nothing. How can i detect a memory leak? gerald -- --OO--Ooo-< NetBSD+Tru64+VMS:IRIX ? alpha+vax+sparc+m68k:mips >-- Gerald Exner From matthew.reilly@REDACTED Tue Sep 19 20:15:42 2006 From: matthew.reilly@REDACTED (Matthew Reilly) Date: Tue, 19 Sep 2006 11:15:42 -0700 Subject: [erlang-questions] gen_fsm - timeout ? In-Reply-To: <062701c6dbc3$44b5d230$9a0a10ac@wavenet.lk> References: <062701c6dbc3$44b5d230$9a0a10ac@wavenet.lk> Message-ID: <1158689742.22219.68.camel@matt> One way to do this is to store an absolute timeout time in your FSM state and recalculate the relative timeout value everytime you chose the next state. %%%%%%%%%%%%%%%% Example %%%%%%%%%%%%%%%%%%%%%% %% This intializes a FSM with a timeout time in seconds -module(my_module). -behaviour(gen_fsm). -record(state, { stuff, timeout %% Stores the absolute timeout time in {Mega,Sec,Micro} %% format }). init(TimeOutSeconds) -> {Mega,Sec,Micro} = now(), %% Calculate a timestamp which is TimeOutSeconds from now. %% The new seconds may exceed 1,000,000, but that is OK. Timeout = {Mega,Sec+TimeOutSecs,Micro}, State = #state{ stuff = , timeout = Timeout}, {ok, next_state1, State, timeout(State)}. %% Always calculate the timeout w/ timeout(State): next_state1(Message, State) -> {next_state, next_state2, State, timeout(State)}. ... %% Returns the difference between now() and the timeout in the state in %% milliseconds. Note, timer:now_diff/2 returns the time difference %% between two {Mega,Sec,Micro} times (which is the format returned by %% erlang:now/0). The difference is in microseconds. timeout(State) -> case timer:now_diff(State#state.timeout,now()) of Diff when Diff < 0 -> 0; Diff -> Diff/1000 end. The advantage of this over creating a separate PID which sends a message at a certain time is that you can update the timeout time just by updating the timeout member of your state (as opposed to stopping the separate PID, clear any possible pending timeout messages, and starting a new one with a new timeout value). On Tue, 2006-09-19 at 13:41 +0530, Sanjaya Vitharana wrote: > Hi ... ALL, > > Behavior: Gen FSM > > Scenario: > Want to be in state "open" (see below) for limited time (assume 5 sec) > until some EXPECTED event (as_E) comes, have to move to some other > state if the expected event not received in that time. All other > events should be ignored in state "open". > > Problem: Below works fine if no events other than expected comes. But > what happend if SOME un-expected events received before timeout? It > always keep updating the timeout value to 5000. Removing the timeout > value from {next_state, open, State,5000} for "OtherEvents" will cause > to stuck in the "open" forever if the expected event not received. > > Question: How the time out value should be use in this case ? Are > there any way to set the timeout value ONCE for all "OtherEvents". > > ------------------------------------------- > Asume this as beginning point > > as(blah,blah), %%Calling Async Func > {next_state, open, State,5000}; > ------------------------------------------- > > open(timeout, State) -> > do_something, > {next_state, Any_Appropriat, State}. > > open(as_E, State) -> > do_something, > {next_state, Any_Appropriat, State}. > > open(OtherEvents, State) -> > {next_state, open, State,5000}. > > Thanks in advance > > Sanjaya Vitharana > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- Matthew Reilly matthew.reilly@REDACTED Gizmo Project name: matt From serge@REDACTED Tue Sep 19 20:29:28 2006 From: serge@REDACTED (Serge Aleynikov) Date: Tue, 19 Sep 2006 14:29:28 -0400 Subject: [erlang-questions] gen_fsm - timeout ? In-Reply-To: <062701c6dbc3$44b5d230$9a0a10ac@wavenet.lk> References: <062701c6dbc3$44b5d230$9a0a10ac@wavenet.lk> Message-ID: <45103708.9040509@hq.idt.net> Sanjaya, Aside from calling erlang:send_after/3, and gen_fsm:send_event_after/2, as mentioned by Chandru and Sean in prior replies, there's an undocumented trick for this already built into the OTP: % inet:start_timer/1 creates a new timer based on TimeOut interval Timer = inet:start_timer(TimeOut), % inet:timeout/1 returns the remaining time left given the % timer reference TimeOut = inet:timeout(Timer), % inet:stop_timer/1 cancels the timer inet:stop_timer(Timer), Example: 'open_state'(OtherEvent, #state{timer = Timer} = StateData) -> TimeOut = inet:timeout (Timer), .... {next_state, 'open', StateData, TimeOut}. Regards, Serge Sanjaya Vitharana wrote: > Hi ... ALL, > > Behavior: Gen FSM > > Scenario: > Want to be in state "open" (see below) for limited time (assume 5 sec) > until some EXPECTED event (as_E) comes, have to move to some other state > if the expected event not received in that time. All other events should > be ignored in state "open". > > Problem: Below works fine if no events other than expected comes. But > what happend if SOME un-expected events received before timeout? It > always keep updating the timeout value to 5000. Removing the timeout > value from {next_state, open, State,5000} for "OtherEvents" will cause > to stuck in the "open" forever if the expected event not received. > > Question: How the time out value should be use in this case ? Are there > any way to set the timeout value ONCE for all "OtherEvents". > > ------------------------------------------- > Asume this as beginning point > > as(blah,blah), %%Calling Async Func > {next_state, open, State,5000}; > ------------------------------------------- > > open(timeout, State) -> > do_something, > {next_state, Any_Appropriat, State}. > > open(as_E, State) -> > do_something, > {next_state, Any_Appropriat, State}. > > open(OtherEvents, State) -> > {next_state, open, State,5000}. > > Thanks in advance > > Sanjaya Vitharana > > > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- Serge Aleynikov R&D Telecom, MIS, IDT Corp Tel: +1 (973) 438-3436 Fax: +1 (973) 438-1464 From dirtyundies@REDACTED Tue Sep 19 21:03:33 2006 From: dirtyundies@REDACTED (Mikkel Jensen) Date: Tue, 19 Sep 2006 12:03:33 -0700 (PDT) Subject: [erlang-questions] Error compiling R11B-1 on Ubuntu Message-ID: <6394755.post@talk.nabble.com> Hi there, When I try to compile the latest release of Erlang/OTP on my Ubuntu Dapper Drake machine I get the following error: # make cd erts/emulator && ERL_TOP=/root/otp_src_R11B-1 make generate depend make[1]: Entering directory `/root/otp_src_R11B-1/erts/emulator' make -f i686-pc-linux-gnu/Makefile generate make[2]: Entering directory `/root/otp_src_R11B-1/erts/emulator' gcc -g -O3 -I/root/otp_src_R11B-1/erts/i686-pc-linux-gnu -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -DHAVE_CONFIG_H -Wall -Wstrict-prototypes -Wmissing-prototypes -DUSE_THREADS -D_THREAD_SAFE -D_REENTRANT -D_POSIX_THREAD_SAFE_FUNCTIONS -isystem /usr/include/nptl -Ibeam -Isys/unix -Isys/common -Ii686-pc-linux-gnu/opt/plain -Ii686-pc-linux-gnu -Izlib -Ihipe -I../include/internal -I../include/internal/i686-pc-linux-gnu -c hipe/hipe_mkliterals.c -o obj/i686-pc-linux-gnu/opt/plain/hipe_mkliterals.o hipe/hipe_mkliterals.c:349: error: 'X86_LEAF_WORDS' undeclared here (not in a function) hipe/hipe_mkliterals.c:350: error: 'X86_NR_ARG_REGS' undeclared here (not in a function) make[2]: *** [obj/i686-pc-linux-gnu/opt/plain/hipe_mkliterals.o] Error 1 make[2]: Leaving directory `/root/otp_src_R11B-1/erts/emulator' make[1]: *** [generate] Error 2 make[1]: Leaving directory `/root/otp_src_R11B-1/erts/emulator' make: *** [depend] Error 2 Has anybody else encountered this? - Mikkel -- View this message in context: http://www.nabble.com/Error-compiling-R11B-1-on-Ubuntu-tf2300899.html#a6394755 Sent from the Erlang Questions mailing list archive at Nabble.com. From moe@REDACTED Wed Sep 20 01:57:42 2006 From: moe@REDACTED (Moe Aboulkheir) Date: Wed, 20 Sep 2006 01:57:42 +0200 Subject: [erlang-questions] supervising applications In-Reply-To: 0 Message-ID: <20060919235742.1717.39578109.divmod.quotient.54397@ohm> Hi, I'm very new to this. I've written a trivial Erlang application, and i am trying to write a second one which provides a superset of the functionality of the first. The supervisor that is started from start/2 in the second application tries to start the first application by including an entry for it in the list returned from init/1. I tried the following two methods, but neither works: 1) Having StartFunc (in the init/1 term) as {application, start, [app1]}. This doesn't work because application:start/1 returns ok instead of {ok, Pid} like the supervisor interface wants. Ideally i'd have liked to be able to this, because app1:start/2 passes some stuff from its environment as the argument to app1_supervisor:start_link/1, but i guess i could move that stuff further into app1, though i saw an example that did the setup here, and it makes sense to me 2) Having StartFunc as {app1_supervisor, start_link, ...}. This doesn't work because some code inside app1 depends on things in the environment of app1's .app file - things that don't seem to be available when i start it like this. Again, i could move these variables into app2's environment, but i'd like to be able to use app1 without using app2, and would rather not maintain the information in two places. Any ideas? -- Moe Aboulkheir From bob@REDACTED Wed Sep 20 02:12:10 2006 From: bob@REDACTED (Bob Ippolito) Date: Tue, 19 Sep 2006 17:12:10 -0700 Subject: [erlang-questions] supervising applications In-Reply-To: <20060919235742.1717.39578109.divmod.quotient.54397@ohm> References: <20060919235742.1717.39578109.divmod.quotient.54397@ohm> Message-ID: <6a36e7290609191712u52b658cfnf4a6dcd9788d1aa1@mail.gmail.com> On 9/19/06, Moe Aboulkheir wrote: > Hi, > > I'm very new to this. I've written a trivial Erlang application, and i am trying to write a second one which provides a superset of the functionality of the first. The supervisor that is started from start/2 in the second application tries to start the first application by including an entry for it in the list returned from init/1. I tried the following two methods, but neither works: > > 1) Having StartFunc (in the init/1 term) as {application, start, [app1]}. This doesn't work because application:start/1 returns ok instead of {ok, Pid} like the supervisor interface wants. Ideally i'd have liked to be able to this, because app1:start/2 passes some stuff from its environment as the argument to app1_supervisor:start_link/1, but i guess i could move that stuff further into app1, though i saw an example that did the setup here, and it makes sense to me > > 2) Having StartFunc as {app1_supervisor, start_link, ...}. This doesn't work because some code inside app1 depends on things in the environment of app1's .app file - things that don't seem to be available when i start it like this. Again, i could move these variables into app2's environment, but i'd like to be able to use app1 without using app2, and would rather not maintain the information in two places. > > Any ideas? Isn't this what you'd use the {applications, [app1, ...]} list for in the .app file? -bob From moe@REDACTED Wed Sep 20 02:29:47 2006 From: moe@REDACTED (Moe Aboulkheir) Date: Wed, 20 Sep 2006 02:29:47 +0200 Subject: [erlang-questions] supervising applications In-Reply-To: <6a36e7290609191712u52b658cfnf4a6dcd9788d1aa1@mail.gmail.com> Message-ID: <20060920002947.1717.1156129229.divmod.quotient.54417@ohm> On Tue, 19 Sep 2006 17:12:10 -0700, Bob Ippolito wrote: >On 9/19/06, Moe Aboulkheir wrote: >>Hi, >> >>I'm very new to this. I've written a trivial Erlang application, and i am >>trying to write a second one which provides a superset of the functionality >>of the first. The supervisor that is started from start/2 in the second >>application tries to start the first application by including an entry for >>it in the list returned from init/1. I tried the following two methods, >>but neither works: >> >>1) Having StartFunc (in the init/1 term) as {application, start, [app1]}. >>This doesn't work because application:start/1 returns ok instead of {ok, >>Pid} like the supervisor interface wants. Ideally i'd have liked to be >>able to this, because app1:start/2 passes some stuff from its environment >>as the argument to app1_supervisor:start_link/1, but i guess i could move >>that stuff further into app1, though i saw an example that did the setup >>here, and it makes sense to me >> >>2) Having StartFunc as {app1_supervisor, start_link, ...}. This doesn't >>work because some code inside app1 depends on things in the environment of >>app1's .app file - things that don't seem to be available when i start it >>like this. Again, i could move these variables into app2's environment, >>but i'd like to be able to use app1 without using app2, and would rather >>not maintain the information in two places. >> >>Any ideas? > >Isn't this what you'd use the {applications, [app1, ...]} list for in >the .app file? > >-bob > I tried that before (putting app1 in app2's "applications" list and starting its supervisor directly from app2), but I get an {error,{not_started,app1}} when starting app2. the docs say: """ [when starting an application] The application controller checks the value of the application specification key applications, to ensure that all applications that should be started before this application are running. If not, {error,{not_started,App}} is returned, where App is the name of the missing application. """ Which seems to indicate that as long as app1 is in app2's applications list, it won't be possible to start it from app2's start() - and cursory examination (an erlang:display() in start()) indicates that it doesn't even get that far. -- Moe Aboulkheir From bob@REDACTED Wed Sep 20 02:43:56 2006 From: bob@REDACTED (Bob Ippolito) Date: Tue, 19 Sep 2006 17:43:56 -0700 Subject: [erlang-questions] supervising applications In-Reply-To: <20060920002947.1717.1156129229.divmod.quotient.54417@ohm> References: <6a36e7290609191712u52b658cfnf4a6dcd9788d1aa1@mail.gmail.com> <20060920002947.1717.1156129229.divmod.quotient.54417@ohm> Message-ID: <6a36e7290609191743h50a4767r34d233446c93e058@mail.gmail.com> On 9/19/06, Moe Aboulkheir wrote: > > > On Tue, 19 Sep 2006 17:12:10 -0700, Bob Ippolito wrote: > >On 9/19/06, Moe Aboulkheir wrote: > >>Hi, > >> > >>I'm very new to this. I've written a trivial Erlang application, and i am > >>trying to write a second one which provides a superset of the functionality > >>of the first. The supervisor that is started from start/2 in the second > >>application tries to start the first application by including an entry for > >>it in the list returned from init/1. I tried the following two methods, > >>but neither works: > >> > >>1) Having StartFunc (in the init/1 term) as {application, start, [app1]}. > >>This doesn't work because application:start/1 returns ok instead of {ok, > >>Pid} like the supervisor interface wants. Ideally i'd have liked to be > >>able to this, because app1:start/2 passes some stuff from its environment > >>as the argument to app1_supervisor:start_link/1, but i guess i could move > >>that stuff further into app1, though i saw an example that did the setup > >>here, and it makes sense to me > >> > >>2) Having StartFunc as {app1_supervisor, start_link, ...}. This doesn't > >>work because some code inside app1 depends on things in the environment of > >>app1's .app file - things that don't seem to be available when i start it > >>like this. Again, i could move these variables into app2's environment, > >>but i'd like to be able to use app1 without using app2, and would rather > >>not maintain the information in two places. > >> > >>Any ideas? > > > >Isn't this what you'd use the {applications, [app1, ...]} list for in > >the .app file? > > > >-bob > > > > I tried that before (putting app1 in app2's "applications" list and starting its supervisor directly from app2), but I get an {error,{not_started,app1}} when starting app2. the docs say: > > """ > [when starting an application] > The application controller checks the value of the application specification key applications, to ensure that all applications that should be started before this application are running. If not, {error,{not_started,App}} is returned, where App is the name of the missing application. > """ > > Which seems to indicate that as long as app1 is in app2's applications list, it won't be possible to start it from app2's start() - and cursory examination (an erlang:display() in start()) indicates that it doesn't even get that far. I think that's taken care of when you create a boot script from the .app, though... -bob From moe@REDACTED Wed Sep 20 03:10:01 2006 From: moe@REDACTED (Moe Aboulkheir) Date: Wed, 20 Sep 2006 03:10:01 +0200 Subject: [erlang-questions] supervising applications In-Reply-To: <6a36e7290609191743h50a4767r34d233446c93e058@mail.gmail.com> Message-ID: <20060920011001.1717.399248718.divmod.quotient.54456@ohm> On Tue, 19 Sep 2006 17:43:56 -0700, Bob Ippolito wrote: >On 9/19/06, Moe Aboulkheir wrote: >> >> >>On Tue, 19 Sep 2006 17:12:10 -0700, Bob Ippolito wrote: >> >On 9/19/06, Moe Aboulkheir wrote: >> >>Hi, >> >> >> >>I'm very new to this. I've written a trivial Erlang application, and i >>am >> >>trying to write a second one which provides a superset of the >>functionality >> >>of the first. The supervisor that is started from start/2 in the second >> >>application tries to start the first application by including an entry >>for >> >>it in the list returned from init/1. I tried the following two methods, >> >>but neither works: >> >> >> >>1) Having StartFunc (in the init/1 term) as {application, start, [app1]}. >> >>This doesn't work because application:start/1 returns ok instead of {ok, >> >>Pid} like the supervisor interface wants. Ideally i'd have liked to be >> >>able to this, because app1:start/2 passes some stuff from its environment >> >>as the argument to app1_supervisor:start_link/1, but i guess i could move >> >>that stuff further into app1, though i saw an example that did the setup >> >>here, and it makes sense to me >> >> >> >>2) Having StartFunc as {app1_supervisor, start_link, ...}. This doesn't >> >>work because some code inside app1 depends on things in the environment >>of >> >>app1's .app file - things that don't seem to be available when i start it >> >>like this. Again, i could move these variables into app2's environment, >> >>but i'd like to be able to use app1 without using app2, and would rather >> >>not maintain the information in two places. >> >> >> >>Any ideas? >> > >> >Isn't this what you'd use the {applications, [app1, ...]} list for in >> >the .app file? >> > >> >-bob >> > >> >>I tried that before (putting app1 in app2's "applications" list and >>starting its supervisor directly from app2), but I get an >>{error,{not_started,app1}} when starting app2. the docs say: >> >>""" >>[when starting an application] >>The application controller checks the value of the application >>specification key applications, to ensure that all applications that should >>be started before this application are running. If not, >>{error,{not_started,App}} is returned, where App is the name of the missing >>application. >>""" >> >>Which seems to indicate that as long as app1 is in app2's applications >>list, it won't be possible to start it from app2's start() - and cursory >>examination (an erlang:display() in start()) indicates that it doesn't even >>get that far. > >I think that's taken care of when you create a boot script from the >.app, though... > Thanks, I'll look into that further -- Moe Aboulkheir From Norbert.Klamann@REDACTED Wed Sep 20 07:33:12 2006 From: Norbert.Klamann@REDACTED (norbertk) Date: Wed, 20 Sep 2006 06:33:12 +0100 Subject: [erlang-questions] Good Erlang style? References: Message-ID: <20060920053312.DDB775A1F6@mail.erlangsystems.com> Guest wrote: The theory helps but is not needed. What is your actual background ? (end of quote) In a former life I studied history but since 20 years or so I work as a Software-Developer (contractor) at several customers sites. I work with (Oracle)-DBs, Web, python and this kind of stuff. I am always on the lookout for ways to make better software, so I am interested in FP. -- All the best Norbert _________________________________________________________ Post sent from http://www.trapexit.org From ke.han@REDACTED Wed Sep 20 08:03:34 2006 From: ke.han@REDACTED (ke han) Date: Wed, 20 Sep 2006 14:03:34 +0800 Subject: [erlang-questions] measuring OS context switches Message-ID: <3CD23375-2875-4928-80A7-A83094F8E8BF@redstarling.com> I am doing a comparative analysis of a webapp with Ruby on Rails vs. Yaws+mysql. The app being used is the "depot" app from the book Agile Programing in Rails (Pragmatic Programmer). This app is used in many Rails based tutorials and seems a good one to use since I already have the Rail version complete and it would be hard for the Rails community to say I "cheated" as its their app. There is little value in just measuring end-to-end page load times and overall stress testing as it doesn't explain "why" erlang is beating the pants off Rails (obviously I'm making assumptions about the results ;-)). I want to show ratios of "real work" vs. OS context switches + other internal communications between processes, etc... Can anyone give ideas for how to go about measuring such things?? I can litter Rails code with all sorts of wall clock logging and try to put this to use, but this also means I have to dig into lighttpd and mysql to log some of their times as well...there must be some tools or methods I don't know about. I was hoping to have access to a Solaris server for these tests and use DTrace and other profiling tools Sun crows about, but alas, no interest from Sun (or hosting partners) in providing a box to test on...So I'll be doing this initial analysis on my iMac dual core and maybe a dual proc FreeBSD server. If I do this correctly, I should have the sample code and scripts to allow others to try out variations on my tests. Such as: Rails: 1 lighttpd proc, 20 mongrel/ruby procs, 1 mysql proc (20 connections) on a single CPU vs, variations on multi-core. The erlang solution could be varied by multi-threaded erlang vs. single threaded and such. I'm not so interested in measuring context switches between procs within a multi-thread erlang vm as I think my results will be interesting enough to show how much overhead is in the Rails "runtime architecture". thanks, ke han BTW, Yariv, if you catch this email, I will be using your erlyDB along with some javascript and erlang prototypes I've been working on to make the front end work. From taj.khattra@REDACTED Wed Sep 20 08:13:27 2006 From: taj.khattra@REDACTED (Taj Khattra) Date: Tue, 19 Sep 2006 23:13:27 -0700 Subject: [erlang-questions] Error compiling R11B-1 on Ubuntu In-Reply-To: <6394755.post@talk.nabble.com> References: <6394755.post@talk.nabble.com> Message-ID: <57a21f730609192313l4283865fmdd1a5105bc90032b@mail.gmail.com> can't remember for sure, but i think i ran into this problem too. i had to run configure multiple times because of missing dependencies (java etc.) on my new ubuntu system, but then the build would fail even after re-running configure. i resolved it by untarring into a new folder and then re-running configure. From tty.erlang@REDACTED Wed Sep 20 09:05:44 2006 From: tty.erlang@REDACTED (t ty) Date: Wed, 20 Sep 2006 03:05:44 -0400 Subject: [erlang-questions] Good Erlang style? In-Reply-To: <20060920053312.DDB775A1F6@mail.erlangsystems.com> References: <20060920053312.DDB775A1F6@mail.erlangsystems.com> Message-ID: <290b3ba10609200005o4a900ca5j83ddc86e94da64f3@mail.gmail.com> Python will be your ticket to Erlang. If you are familiar with map/reduce/lambda you are more then half way there. You only need to add using recursion for loops and pattern matching for if/else. t On 9/20/06, norbertk wrote: > > > Guest wrote: > The theory helps but is not needed. What is your actual background ? > (end of quote) > > > In a former life I studied history but since 20 years or so I work as a Software-Developer (contractor) at several customers sites. I work with (Oracle)-DBs, Web, python and this kind of stuff. > > I am always on the lookout for ways to make better software, so I am interested in FP. > -- > All the best > > Norbert > _________________________________________________________ > Post sent from http://www.trapexit.org > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From dmitriid@REDACTED Wed Sep 20 09:46:35 2006 From: dmitriid@REDACTED (Dmitrii Dimandt) Date: Wed, 20 Sep 2006 10:46:35 +0300 Subject: [erlang-questions] Record information Message-ID: Is there a way to find information on a record? That is, what fields it contains, etc.? That is, if I have a record like this: -record( forumRequest, { userName, password } ). And I have A = #forumRequest(userName = "login", password = "pass"). I can find out the name of the record by doing element(1, A). Can I find out that "login" is a userName and "pass" is password? -------------- next part -------------- An HTML attachment was scrubbed... URL: From cyberdanx@REDACTED Wed Sep 20 11:11:19 2006 From: cyberdanx@REDACTED (Chris Campbell) Date: Wed, 20 Sep 2006 10:11:19 +0100 Subject: [erlang-questions] Error compiling R11B-1 on Ubuntu In-Reply-To: <57a21f730609192313l4283865fmdd1a5105bc90032b@mail.gmail.com> References: <6394755.post@talk.nabble.com> <57a21f730609192313l4283865fmdd1a5105bc90032b@mail.gmail.com> Message-ID: I didn't have any problem with R11B-1 (with hipe) but I had all the build dependencies from the previous install. Try "apt-get build-dep erlang erlang-base". Note, I also had to install unixodbc-dev to get odbc support. Removing configure.cache will cause configure to look for the dependancies again. Chris From jahakala@REDACTED Wed Sep 20 11:19:52 2006 From: jahakala@REDACTED (Jani Hakala) Date: Wed, 20 Sep 2006 12:19:52 +0300 Subject: [erlang-questions] Good Erlang style? In-Reply-To: <290b3ba10609200005o4a900ca5j83ddc86e94da64f3@mail.gmail.com> (t. ty's message of "Wed\, 20 Sep 2006 03\:05\:44 -0400") References: <20060920053312.DDB775A1F6@mail.erlangsystems.com> <290b3ba10609200005o4a900ca5j83ddc86e94da64f3@mail.gmail.com> Message-ID: <877izyzyh3.fsf@pingviini.kortex.jyu.fi> "t ty" writes: > Python will be your ticket to Erlang. If you are familiar with > map/reduce/lambda you are more then half way there. You only need to > add using recursion for loops and pattern matching for if/else. > My way of writing Python programs actually changed a little bit after learning Erlang. More foo(fun, list) kind of functions and more closures. Jani Hakala From thomasl_erlang@REDACTED Wed Sep 20 11:38:17 2006 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Wed, 20 Sep 2006 02:38:17 -0700 (PDT) Subject: [erlang-questions] Record information In-Reply-To: Message-ID: <20060920093817.92786.qmail@web38812.mail.mud.yahoo.com> (Sorry about top-posting, I'm trying out Yahoo's new mail system) When debugging, try rr and friends. Records disappear at compile-time, but have a look at record_info/2 as a tool for rolling your own. (E.g., good old record_info(fields, my_rec) is expanded to a list of the field names of my_rec.) (The preferrable approach would be to make records into first-class entities, but Erlang is locked into the "records = tuples" representation.) Best, Thomas ----- Original Message ---- From: Dmitrii Dimandt To: erlang-questions Sent: Wednesday, September 20, 2006 9:46:35 AM Subject: [erlang-questions] Record information Is there a way to find information on a record? That is, what fields it contains, etc.? That is, if I have a record like this: -record( forumRequest, { userName, password } ). And I have A = #forumRequest(userName = "login", password = "pass"). I can find out the name of the record by doing element(1, A). Can I find out that "login" is a userName and "pass" is password? _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From dirtyundies@REDACTED Wed Sep 20 12:00:57 2006 From: dirtyundies@REDACTED (Mikkel Jensen) Date: Wed, 20 Sep 2006 03:00:57 -0700 (PDT) Subject: [erlang-questions] Error compiling R11B-1 on Ubuntu In-Reply-To: References: <6394755.post@talk.nabble.com> <57a21f730609192313l4283865fmdd1a5105bc90032b@mail.gmail.com> Message-ID: <6404858.post@talk.nabble.com> Thanks alot guys, it was definitely a problem with the configure cache! I had been installing packages while running configure which led to the strange compile error. After untaring the source to a different directory and rerunning configure it no longer reported the error. Thanks again, - Mikkel -- View this message in context: http://www.nabble.com/Error-compiling-R11B-1-on-Ubuntu-tf2300899.html#a6404858 Sent from the Erlang Questions mailing list archive at Nabble.com. From vladdu55@REDACTED Wed Sep 20 12:17:00 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Wed, 20 Sep 2006 12:17:00 +0200 Subject: [erlang-questions] Record information In-Reply-To: <20060920093817.92786.qmail@web38812.mail.mud.yahoo.com> References: <20060920093817.92786.qmail@web38812.mail.mud.yahoo.com> Message-ID: <95be1d3b0609200317u10045974q3d442c0079db00b1@mail.gmail.com> > Is there a way to find information on a record? That is, what fields it > contains, etc.? There is also a simple module in jungerl, called rec_info (in the msc libarary), that tries to retrieve the record information from the beam file. This is possible if it was compiled with debug information. best regards, Vlad From dmitriid@REDACTED Wed Sep 20 12:55:41 2006 From: dmitriid@REDACTED (Dmitrii Dimandt) Date: Wed, 20 Sep 2006 13:55:41 +0300 Subject: [erlang-questions] Record information In-Reply-To: <95be1d3b0609200317u10045974q3d442c0079db00b1@mail.gmail.com> References: <20060920093817.92786.qmail@web38812.mail.mud.yahoo.com> <95be1d3b0609200317u10045974q3d442c0079db00b1@mail.gmail.com> Message-ID: Thank you! On 9/20/06, Vlad Dumitrescu wrote: > > > Is there a way to find information on a record? That is, what fields it > > contains, etc.? > > There is also a simple module in jungerl, called rec_info (in the msc > libarary), that tries to retrieve the record information from the beam > file. This is possible if it was compiled with debug information. > > best regards, > Vlad > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From hans.bolinder@REDACTED Wed Sep 20 13:41:02 2006 From: hans.bolinder@REDACTED (Hans Bolinder) Date: Wed, 20 Sep 2006 13:41:02 +0200 Subject: [erlang-questions] Working with large binaries in the interpreter In-Reply-To: <6a36e7290609011329j3829adcdud4fc3c3427ed5f86@mail.gmail.com> References: <6a36e7290609011239m7ae80b93o4ee152ad5bc43a13@mail.gmail.com> <6a36e7290609011329j3829adcdud4fc3c3427ed5f86@mail.gmail.com> Message-ID: <17681.10446.613021.228790@gargle.gargle.HOWL> [Bob Ippolito:] > It appears to be a bug in io_lib_pretty, where it unconditionally > decides to use binary_to_list(B) even when it is going to truncate. It > should be using binary_to_list/3 if size(B) > D... so it ends up > creating an enormous list. The bug will be fixed in R11B-2. Thanks for pointing it out. > Doing results(0) and forgetting the binding for D does not make any > difference. It will free the 25M binary from the binaries table, but > it doesn't affect the processes table nor does it get rid of the 16M > in the binaries table that is unaccounted for... This is probably due to the fact that the Erlang shell doesn't garbage collect the binary. There will be a fix in R11B-2 to overcome the deficiency. Best regards, Hans Bolinder, Erlang/OTP From Norbert.Klamann@REDACTED Wed Sep 20 14:21:32 2006 From: Norbert.Klamann@REDACTED (norbertk) Date: Wed, 20 Sep 2006 13:21:32 +0100 Subject: [erlang-questions] Process for Documentation enhancements ? References: Message-ID: <20060920122132.47E2C5A1F6@mail.erlangsystems.com> Hallo all, coming from the outside I try to find my way through the documentation. There are a lot of great ressources but sometimes I (or others) have a suggestion to make. It would be good to know that someone looks ofter these things. I don't think that mailing list archives are the right place for these kind of things. Is there a request tracking system or something like that ? Maybe even for other enhancements ? I can set up a little system on short notice if that helps. The important question is albeit an organisational one : what would be done with the input ? -- All the best Norbert _________________________________________________________ Post sent from http://www.trapexit.org From gunilla@REDACTED Wed Sep 20 14:35:11 2006 From: gunilla@REDACTED (Gunilla Arendt) Date: Wed, 20 Sep 2006 14:35:11 +0200 Subject: [erlang-questions] Process for Documentation enhancements ? In-Reply-To: <20060920122132.47E2C5A1F6@mail.erlangsystems.com> References: <20060920122132.47E2C5A1F6@mail.erlangsystems.com> Message-ID: <4511357F.6070401@erix.ericsson.se> Hi, You can use the erlang-bugs and erlang-patches mailing lists. We are always grateful to receive bug reports and suggestions for improvements, naturally this goes for the documentation as well. Best regards, Gunilla, Erlang/OTP team norbertk wrote: > Hallo all, > coming from the outside I try to find my way through the documentation. There are a lot of great ressources but sometimes I (or others) have a suggestion to make. > > It would be good to know that someone looks ofter these things. I don't think that mailing list archives are the right place for these kind of things. > > Is there a request tracking system or something like that ? Maybe even for other enhancements ? > > I can set up a little system on short notice if that helps. The important question is albeit an organisational one : what would be done with the input ? > -- > All the best > > Norbert > _________________________________________________________ > Post sent from http://www.trapexit.org > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > From mel.boyce@REDACTED Wed Sep 20 14:41:55 2006 From: mel.boyce@REDACTED (Mel Boyce) Date: Wed, 20 Sep 2006 22:41:55 +1000 Subject: [erlang-questions] Erlang-Fu Message-ID: <45113713.209@gmail.com> I have just registered the domain http://erlang-fu.com/ which will at some soon stage become my on-line Erlang presence (blog, docs, et al) and wanted to probe the mailing list for interest, suggestions, mail-forwarding requests ;), and the like. -- Mel Boyce From gefla@REDACTED Wed Sep 20 15:25:43 2006 From: gefla@REDACTED (Gerd Flaig) Date: Wed, 20 Sep 2006 15:25:43 +0200 Subject: [erlang-questions] measuring OS context switches References: <3CD23375-2875-4928-80A7-A83094F8E8BF@redstarling.com> Message-ID: <87zmcullew.fsf@kilo.pond.sub.org> ke han writes: > I want to show ratios of "real work" vs. OS context switches + other > internal communications between processes, etc... > > Can anyone give ideas for how to go about measuring such things?? you might want to give oprofile a try. Goodbyte, Gerd. -- The last thing one knows in constructing a work is what to put first. -- Blaise Pascal From yarivvv@REDACTED Wed Sep 20 16:17:30 2006 From: yarivvv@REDACTED (Yariv Sadan) Date: Wed, 20 Sep 2006 10:17:30 -0400 Subject: [erlang-questions] comma-less lists and tuples Message-ID: <17244f480609200717i1e137462pfff910d4777025f3@mail.gmail.com> Hi, When working with ErlSQL, I came to the opinion that in some cases, Erlang would benefit from allowing whitespace as a delimiter in lists and tuples in place of commas. Consider this small example: {select, [foo, bar, baz], {from, [table1, table2]}, {where, {xyz, '=', {'+', [1,2,3,4]}}}} If commas were optional, this example could be written as {select [foo, bar, baz] {from [table1, table2]} {where {xyz '=' {'+' [1 2 3 4]}}}} I think the second line is more readable, and it's also easier to write. In other DSELs, the difference may be even more substantial. What do you think? Am I missing something? Best regards, Yariv From qrilka@REDACTED Wed Sep 20 16:35:12 2006 From: qrilka@REDACTED (Kirill Zaborski) Date: Wed, 20 Sep 2006 18:35:12 +0400 Subject: [erlang-questions] comma-less lists and tuples In-Reply-To: <17244f480609200717i1e137462pfff910d4777025f3@mail.gmail.com> References: <17244f480609200717i1e137462pfff910d4777025f3@mail.gmail.com> Message-ID: <337538cb0609200735p14df5be6gc79c5182a3e3d9f4@mail.gmail.com> Welcome back to LISP? :) On 9/20/06, Yariv Sadan wrote: > > Hi, > > When working with ErlSQL, I came to the opinion that in some cases, > Erlang would benefit from allowing whitespace as a delimiter in lists > and tuples in place of commas. Consider this small example: > > {select, [foo, bar, baz], {from, [table1, table2]}, {where, {xyz, '=', > {'+', [1,2,3,4]}}}} > > If commas were optional, this example could be written as > > {select [foo, bar, baz] {from [table1, table2]} {where {xyz '=' {'+' > [1 2 3 4]}}}} > > I think the second line is more readable, and it's also easier to > write. In other DSELs, the difference may be even more substantial. > > What do you think? Am I missing something? > > Best regards, > Yariv > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bengt.kleberg@REDACTED Wed Sep 20 16:40:42 2006 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Wed, 20 Sep 2006 16:40:42 +0200 Subject: [erlang-questions] comma-less lists and tuples In-Reply-To: <17244f480609200717i1e137462pfff910d4777025f3@mail.gmail.com> References: <17244f480609200717i1e137462pfff910d4777025f3@mail.gmail.com> Message-ID: <451152EA.50603@ericsson.com> On 2006-09-20 16:17, Yariv Sadan wrote: > Hi, > > When working with ErlSQL, I came to the opinion that in some cases, > Erlang would benefit from allowing whitespace as a delimiter in lists > and tuples in place of commas. Consider this small example: would such a change create a problem when atoms look like this: 'atom with space'? bengt -- EPO guidelines 1978: "If the contribution to the known art resides solely in a computer program then the subject matter is not patentable in whatever manner it may be presented in the claims." From erik.reitsma@REDACTED Wed Sep 20 16:48:22 2006 From: erik.reitsma@REDACTED (Erik Reitsma (RY/ETM)) Date: Wed, 20 Sep 2006 16:48:22 +0200 Subject: [erlang-questions] comma-less lists and tuples In-Reply-To: <451152EA.50603@ericsson.com> Message-ID: <110BA8ACEE682C479D0B008B6BE4AEB102FF4354@esealmw107.eemea.ericsson.se> > > When working with ErlSQL, I came to the opinion that in some cases, > > Erlang would benefit from allowing whitespace as a > delimiter in lists > > and tuples in place of commas. Consider this small example: > > would such a change create a problem when atoms look like this: > 'atom with space'? I don't see why if we can have 'atom,with,commas' already. *Erik. From tobez@REDACTED Wed Sep 20 17:08:12 2006 From: tobez@REDACTED (Anton Berezin) Date: Wed, 20 Sep 2006 17:08:12 +0200 Subject: [erlang-questions] comma-less lists and tuples In-Reply-To: <110BA8ACEE682C479D0B008B6BE4AEB102FF4354@esealmw107.eemea.ericsson.se> References: <451152EA.50603@ericsson.com> <110BA8ACEE682C479D0B008B6BE4AEB102FF4354@esealmw107.eemea.ericsson.se> Message-ID: <20060920150812.GA96712@heechee.tobez.org> On Wed, Sep 20, 2006 at 04:48:22PM +0200, Erik Reitsma (RY/ETM) wrote: > > > > When working with ErlSQL, I came to the opinion that in some cases, > > > Erlang would benefit from allowing whitespace as a > > delimiter in lists > > > and tuples in place of commas. Consider this small example: > > > > would such a change create a problem when atoms look like this: > > 'atom with space'? > > I don't see why if we can have 'atom,with,commas' already. While we are discussing commas, it would be extremely nice to allow a trailing comma in lists and tuples: [1,2,3,] {1,2,3,} This is very useful during development, it provides for less source editing with no assumption that datastructures are cast in stone. Many languages support that already, including gcc variant of C. Pretty please? \Anton. -- We're going for 'working' here. 'clean' is for people with skills... -- Flemming Jacobsen From mogorman@REDACTED Wed Sep 20 17:12:12 2006 From: mogorman@REDACTED (Matthew O'Gorman) Date: Wed, 20 Sep 2006 10:12:12 -0500 Subject: [erlang-questions] comma-less lists and tuples In-Reply-To: <20060920150812.GA96712@heechee.tobez.org> References: <451152EA.50603@ericsson.com> <110BA8ACEE682C479D0B008B6BE4AEB102FF4354@esealmw107.eemea.ericsson.se> <20060920150812.GA96712@heechee.tobez.org> Message-ID: personally, i think it would just make the language more confusing if you added this, especially to beginners. Mog From erik.reitsma@REDACTED Wed Sep 20 17:19:59 2006 From: erik.reitsma@REDACTED (Erik Reitsma (RY/ETM)) Date: Wed, 20 Sep 2006 17:19:59 +0200 Subject: [erlang-questions] comma-less lists and tuples In-Reply-To: Message-ID: <110BA8ACEE682C479D0B008B6BE4AEB102FF438C@esealmw107.eemea.ericsson.se> Mog wrote: > personally, i think it would just make the language more > confusing if you added this, especially to beginners. I did not write that I was in favor of the comma-less lists and tuples, just that it would not be a problem for atoms, as suggested. I do not see it as an improvement either. *Erik. From ke.han@REDACTED Wed Sep 20 17:20:50 2006 From: ke.han@REDACTED (ke han) Date: Wed, 20 Sep 2006 23:20:50 +0800 Subject: [erlang-questions] comma-less lists and tuples In-Reply-To: <17244f480609200717i1e137462pfff910d4777025f3@mail.gmail.com> References: <17244f480609200717i1e137462pfff910d4777025f3@mail.gmail.com> Message-ID: I think you have been staring at your monitor too long ;-). I agree it does look a bit nicer. But relative to the rest of the term, its not a big gain. I have been thinking of DSEL stuff as well lately. I was looking at Joe's ML9 and trying to see whether using that or prettier term structure is the better choice for certain types of metadata. Boston is a nice town and its going to get cold soon...go outside and stretch your eyes for a few minutes ;-) BTW, I am enjoying erlyDB...great work!!! ke han On Sep 20, 2006, at 10:17 PM, Yariv Sadan wrote: > Hi, > > When working with ErlSQL, I came to the opinion that in some cases, > Erlang would benefit from allowing whitespace as a delimiter in lists > and tuples in place of commas. Consider this small example: > > {select, [foo, bar, baz], {from, [table1, table2]}, {where, {xyz, '=', > {'+', [1,2,3,4]}}}} > > If commas were optional, this example could be written as > > {select [foo, bar, baz] {from [table1, table2]} {where {xyz '=' {'+' > [1 2 3 4]}}}} > > I think the second line is more readable, and it's also easier to > write. In other DSELs, the difference may be even more substantial. > > What do you think? Am I missing something? > > Best regards, > Yariv > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From moe@REDACTED Wed Sep 20 17:35:26 2006 From: moe@REDACTED (Moe Aboulkheir) Date: Wed, 20 Sep 2006 17:35:26 +0200 Subject: [erlang-questions] supervising applications In-Reply-To: <6a36e7290609191712u52b658cfnf4a6dcd9788d1aa1@mail.gmail.com> Message-ID: <20060920153526.1717.219846568.divmod.quotient.55003@ohm> On Tue, 19 Sep 2006 17:12:10 -0700, Bob Ippolito wrote: >On 9/19/06, Moe Aboulkheir wrote: >>Hi, >> >>I'm very new to this. I've written a trivial Erlang application, and i am >>trying to write a second one which provides a superset of the functionality >>of the first. The supervisor that is started from start/2 in the second >>application tries to start the first application by including an entry for >>it in the list returned from init/1. I tried the following two methods, >>but neither works: >> >>1) Having StartFunc (in the init/1 term) as {application, start, [app1]}. >>This doesn't work because application:start/1 returns ok instead of {ok, >>Pid} like the supervisor interface wants. Ideally i'd have liked to be >>able to this, because app1:start/2 passes some stuff from its environment >>as the argument to app1_supervisor:start_link/1, but i guess i could move >>that stuff further into app1, though i saw an example that did the setup >>here, and it makes sense to me >> >>2) Having StartFunc as {app1_supervisor, start_link, ...}. This doesn't >>work because some code inside app1 depends on things in the environment of >>app1's .app file - things that don't seem to be available when i start it >>like this. Again, i could move these variables into app2's environment, >>but i'd like to be able to use app1 without using app2, and would rather >>not maintain the information in two places. >> >>Any ideas? > >Isn't this what you'd use the {applications, [app1, ...]} list for in >the .app file? Hooray, looks like {included_applications, [app1]} does the thing I want - loads the applications without expecting them to be started. Thanks -- Moe Aboulkheir From rpettit@REDACTED Wed Sep 20 17:42:48 2006 From: rpettit@REDACTED (Rick Pettit) Date: Wed, 20 Sep 2006 10:42:48 -0500 Subject: [erlang-questions] comma-less lists and tuples In-Reply-To: <20060920150812.GA96712@heechee.tobez.org> References: <451152EA.50603@ericsson.com> <110BA8ACEE682C479D0B008B6BE4AEB102FF4354@esealmw107.eemea.ericsson.se> <20060920150812.GA96712@heechee.tobez.org> Message-ID: <20060920154248.GB12827@vailsys.com> On Wed, Sep 20, 2006 at 05:08:12PM +0200, Anton Berezin wrote: > On Wed, Sep 20, 2006 at 04:48:22PM +0200, Erik Reitsma (RY/ETM) wrote: > > > > > > When working with ErlSQL, I came to the opinion that in some cases, > > > > Erlang would benefit from allowing whitespace as a > > > delimiter in lists > > > > and tuples in place of commas. Consider this small example: > > > > > > would such a change create a problem when atoms look like this: > > > 'atom with space'? > > > > I don't see why if we can have 'atom,with,commas' already. > > While we are discussing commas, it would be extremely nice to allow a > trailing comma in lists and tuples: > > [1,2,3,] > {1,2,3,} > > This is very useful during development, it provides for less source editing > with no assumption that datastructures are cast in stone. > > Many languages support that already, including gcc variant of C. > > Pretty please? Are these really features worth debating at this time? Aren't there more important considerations regarding erlang than the ability to omit (or add extra) commas in lists? I don't mean to rain on the parade but this seems somewhat unimportant to me. -Rick From yarivvv@REDACTED Wed Sep 20 17:46:54 2006 From: yarivvv@REDACTED (Yariv Sadan) Date: Wed, 20 Sep 2006 11:46:54 -0400 Subject: [erlang-questions] comma-less lists and tuples In-Reply-To: References: <17244f480609200717i1e137462pfff910d4777025f3@mail.gmail.com> Message-ID: <17244f480609200846n1836f869t6ec5f98a354057fa@mail.gmail.com> On 9/20/06, ke han wrote: > I think you have been staring at your monitor too long ;-). > I agree it does look a bit nicer. But relative to the rest of the > term, its not a big gain. I agree it's not a big gain, but in the Which Is A Better Language For DSEL pissing contest between Erlang and Lisp, it would at least score Erlang a couple of points :) > > I have been thinking of DSEL stuff as well lately. I was looking at > Joe's ML9 and trying to see whether using that or prettier term > structure is the better choice for certain types of metadata. I think the combination of atoms, tuples, lists and pattern matching makes Erlang a very good host language for DSELs. Maybe not as good as Lisp, but definitely better than most. Pattern matching especially makes the implementation of DSELs very intuitive, as I learned when implementing ErlSQL. It's funny, because initially ErlSQL was just a bunch of functions called 'select()', 'insert()', 'update(),' etc, that took a list of arguments for the body of the query. Only after I made enough functions, I realized that you can map them to an abstract description that looks very similar to SQL. Starting out, I didn't realize that SQL can be mapped so intuitively to Erlang, not to mention that Erlang is a good host for DSELs :) > > Boston is a nice town and its going to get cold soon...go outside and > stretch your eyes for a few minutes ;-) > BTW, I am enjoying erlyDB...great work!!! The first version was just a proof of concept. The "real" ErlyDB is coming soon :) Best, Yariv From thomasl_erlang@REDACTED Wed Sep 20 17:47:21 2006 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Wed, 20 Sep 2006 08:47:21 -0700 (PDT) Subject: [erlang-questions] comma-less lists and tuples In-Reply-To: <17244f480609200717i1e137462pfff910d4777025f3@mail.gmail.com> Message-ID: <20060920154721.72082.qmail@web38810.mail.mud.yahoo.com> (Sorry about top-posting, I'm trying out Yahoo's new email.) Smalltalk has a similar notation, something like "select: [foo bar baz] from: [tab1, tab2] where: [xyz '=' {'+', [1 2 3 4]}]"' which would invoke (in Erlang syntax): 'select:from:where'(A1, A2, A3) -> ... I thought that was a pretty neat idea, but I'm not sure how to integrate it with Erlang. However, to get back to the actual proposal: in Erlang as we know it, the comma-less notation is ambiguous, e.g. {X andalso Y} = {(X andalso Y)} or {X, 'andalso', Y}? So that would have to be fixed first. Anyway, those who are interested could have a go at erl_parse.yrl and see whether it can be done. Best, Thomas ----- Original Message ---- From: Yariv Sadan To: erlang-questions Sent: Wednesday, September 20, 2006 4:17:30 PM Subject: [erlang-questions] comma-less lists and tuples Hi, When working with ErlSQL, I came to the opinion that in some cases, Erlang would benefit from allowing whitespace as a delimiter in lists and tuples in place of commas. Consider this small example: {select, [foo, bar, baz], {from, [table1, table2]}, {where, {xyz, '=', {'+', [1,2,3,4]}}}} If commas were optional, this example could be written as {select [foo, bar, baz] {from [table1, table2]} {where {xyz '=' {'+' [1 2 3 4]}}}} I think the second line is more readable, and it's also easier to write. In other DSELs, the difference may be even more substantial. What do you think? Am I missing something? Best regards, Yariv _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions From yarivvv@REDACTED Wed Sep 20 17:53:33 2006 From: yarivvv@REDACTED (Yariv Sadan) Date: Wed, 20 Sep 2006 11:53:33 -0400 Subject: [erlang-questions] measuring OS context switches In-Reply-To: <3CD23375-2875-4928-80A7-A83094F8E8BF@redstarling.com> References: <3CD23375-2875-4928-80A7-A83094F8E8BF@redstarling.com> Message-ID: <17244f480609200853v66ee3c72g6f6802f2601e8825@mail.gmail.com> > > BTW, Yariv, if you catch this email, I will be using your erlyDB > along with some javascript and erlang prototypes I've been working on > to make the front end work. > Ke Han, I will soon switch most ErlyDB calls to prepared statements. This should give you a big performance boost over Rails, because ActiveRecord doesn't use prepared statements at all AFAIK. Without prepared statements, MySQL has to parse each query and then plan its execution, which is quite expensive. Prepared statements alone should give you a big scalability advantage because the database is often one of the main bottlenecks for a webapp. Cheers, Yariv From richardc@REDACTED Wed Sep 20 17:58:00 2006 From: richardc@REDACTED (Richard Carlsson) Date: Wed, 20 Sep 2006 17:58:00 +0200 Subject: [erlang-questions] comma-less lists and tuples In-Reply-To: <20060920154721.72082.qmail@web38810.mail.mud.yahoo.com> References: <20060920154721.72082.qmail@web38810.mail.mud.yahoo.com> Message-ID: <45116508.3080704@it.uu.se> Thomas Lindgren wrote: > in Erlang as we know it, the comma-less notation is > ambiguous, e.g. > > {X andalso Y} = {(X andalso Y)} or {X, 'andalso', Y}? > > So that would have to be fixed first. Anyway, those who are > interested could have a go at erl_parse.yrl and see whether it can be > done. I think you'll find this to be the main snag: {F (1+X) Y} = {F(1+X), Y} or {F, 1+X, Y} /Richard From yarivvv@REDACTED Wed Sep 20 18:21:08 2006 From: yarivvv@REDACTED (Yariv Sadan) Date: Wed, 20 Sep 2006 12:21:08 -0400 Subject: [erlang-questions] measuring OS context switches In-Reply-To: <17244f480609200853v66ee3c72g6f6802f2601e8825@mail.gmail.com> References: <3CD23375-2875-4928-80A7-A83094F8E8BF@redstarling.com> <17244f480609200853v66ee3c72g6f6802f2601e8825@mail.gmail.com> Message-ID: <17244f480609200921h728acb37he6f28837e255ca5a@mail.gmail.com> > Ke Han, I will soon switch most ErlyDB calls to prepared statements. > This should give you a big performance boost over Rails, because > ActiveRecord doesn't use prepared statements at all AFAIK. Without > prepared statements, MySQL has to parse each query and then plan its > execution, which is quite expensive. Prepared statements alone should > give you a big scalability advantage because the database is often one > of the main bottlenecks for a webapp. Update: it has been brought to my attention that sometimes prepared statements don't give you a real performance advantage, and sometimes even a disadvantage, because they don't use the query cache and because their execution planning is weaker than non-prepared statements (at least in MySQL). Given the uncertainty surrounding this issue, I will make prepared statements optional. Yariv From ke.han@REDACTED Wed Sep 20 18:34:48 2006 From: ke.han@REDACTED (ke han) Date: Thu, 21 Sep 2006 00:34:48 +0800 Subject: [erlang-questions] measuring OS context switches In-Reply-To: <17244f480609200853v66ee3c72g6f6802f2601e8825@mail.gmail.com> References: <3CD23375-2875-4928-80A7-A83094F8E8BF@redstarling.com> <17244f480609200853v66ee3c72g6f6802f2601e8825@mail.gmail.com> Message-ID: <28B4437B-99D8-4E20-B54E-45A4668128CC@redstarling.com> On Sep 20, 2006, at 11:53 PM, Yariv Sadan wrote: >> >> BTW, Yariv, if you catch this email, I will be using your erlyDB >> along with some javascript and erlang prototypes I've been working on >> to make the front end work. >> > > Ke Han, I will soon switch most ErlyDB calls to prepared statements. I agree that prepared statements are the way to go. I can tell from my experience with writing Java and Smalltalk ORMs (which always used prepared statements when allowed) and comparing them to what Rails has that Rails can pretty easily add prepared statements when they get around to it. My goal in the analysis work I'm doing is to show the intrinsic performance differences derived from the overall architecture. Rails has a large number of heterogeneous processes all relying on the OS for communications and context switching. A yaws based solution solving the same type of webapp would only have two OS processes: the erlang VM and MySQL. I want to show the overhead Rails creates by deferring all concurrency to the OS instead of subsuming most of it into a concurrency oriented language and vm. ke han > This should give you a big performance boost over Rails, because > ActiveRecord doesn't use prepared statements at all AFAIK. Without > prepared statements, MySQL has to parse each query and then plan its > execution, which is quite expensive. Prepared statements alone should > give you a big scalability advantage because the database is often one > of the main bottlenecks for a webapp. > > Cheers, > Yariv From ke.han@REDACTED Wed Sep 20 18:51:00 2006 From: ke.han@REDACTED (ke han) Date: Thu, 21 Sep 2006 00:51:00 +0800 Subject: [erlang-questions] measuring OS context switches In-Reply-To: <17244f480609200921h728acb37he6f28837e255ca5a@mail.gmail.com> References: <3CD23375-2875-4928-80A7-A83094F8E8BF@redstarling.com> <17244f480609200853v66ee3c72g6f6802f2601e8825@mail.gmail.com> <17244f480609200921h728acb37he6f28837e255ca5a@mail.gmail.com> Message-ID: <8FDE8785-3298-4576-9753-050F0B23EC6D@redstarling.com> On Sep 21, 2006, at 12:21 AM, Yariv Sadan wrote: >> Ke Han, I will soon switch most ErlyDB calls to prepared statements. >> This should give you a big performance boost over Rails, because >> ActiveRecord doesn't use prepared statements at all AFAIK. Without >> prepared statements, MySQL has to parse each query and then plan its >> execution, which is quite expensive. Prepared statements alone should >> give you a big scalability advantage because the database is often >> one >> of the main bottlenecks for a webapp. > > Update: it has been brought to my attention that sometimes prepared > statements don't give you a real performance advantage, and sometimes > even a disadvantage, because they don't use the query cache and > because their execution planning is weaker than non-prepared > statements (at least in MySQL). Given the uncertainty surrounding this > issue, I will make prepared statements optional. In all my ORMs, I found I had to have pluggable behaviors for each type of DB. This meant overridable or pluggable behaviors for connection pooling (you miultiplex over a single Oracle connection, not so with MySQL), when to use Prepared Statements...some DBs you set it to do so optimistically and some only when allowed or defined on a per-query basis, etc...I'm sure no matter what insight you have now, you will need to refactor later when you handle more DBs...thats the small stuff, don't sweat it. ;-) I think you're correct in focusing on the app programmer's experience, not the internal framework re-factoring. ke han > > Yariv From bob@REDACTED Wed Sep 20 19:05:30 2006 From: bob@REDACTED (Bob Ippolito) Date: Wed, 20 Sep 2006 10:05:30 -0700 Subject: [erlang-questions] comma-less lists and tuples In-Reply-To: <20060920154248.GB12827@vailsys.com> References: <451152EA.50603@ericsson.com> <110BA8ACEE682C479D0B008B6BE4AEB102FF4354@esealmw107.eemea.ericsson.se> <20060920150812.GA96712@heechee.tobez.org> <20060920154248.GB12827@vailsys.com> Message-ID: <6a36e7290609201005ybfe98a2ue00004a7a9df6c34@mail.gmail.com> On 9/20/06, Rick Pettit wrote: > On Wed, Sep 20, 2006 at 05:08:12PM +0200, Anton Berezin wrote: > > On Wed, Sep 20, 2006 at 04:48:22PM +0200, Erik Reitsma (RY/ETM) wrote: > > > > > > > > When working with ErlSQL, I came to the opinion that in some cases, > > > > > Erlang would benefit from allowing whitespace as a > > > > delimiter in lists > > > > > and tuples in place of commas. Consider this small example: > > > > > > > > would such a change create a problem when atoms look like this: > > > > 'atom with space'? > > > > > > I don't see why if we can have 'atom,with,commas' already. > > > > While we are discussing commas, it would be extremely nice to allow a > > trailing comma in lists and tuples: > > > > [1,2,3,] > > {1,2,3,} > > > > This is very useful during development, it provides for less source editing > > with no assumption that datastructures are cast in stone. > > > > Many languages support that already, including gcc variant of C. > > > > Pretty please? > > Are these really features worth debating at this time? Aren't there more > important considerations regarding erlang than the ability to omit (or add > extra) commas in lists? > > I don't mean to rain on the parade but this seems somewhat unimportant to me. > It certainly helps to have syntax features that make it easier to write correct code. Allowing extra commas in lists and tuples would be a small and easy win for usability. However, adding a feature like this encourages people to write code that isn't backwards compatible, so perhaps it's not worth doing. -bob From vladdu55@REDACTED Wed Sep 20 20:02:26 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Wed, 20 Sep 2006 19:02:26 +0100 Subject: [erlang-questions] comma-less lists and tuples In-Reply-To: <17244f480609200717i1e137462pfff910d4777025f3@mail.gmail.com> References: <17244f480609200717i1e137462pfff910d4777025f3@mail.gmail.com> Message-ID: <95be1d3b0609201102l6ce72ab9iecf27de35676f18c@mail.gmail.com> Hi, On 9/20/06, Yariv Sadan wrote: > When working with ErlSQL, I came to the opinion that in some cases, > Erlang would benefit from allowing whitespace as a delimiter in lists > and tuples in place of commas. Consider this small example: > > {select, [foo, bar, baz], {from, [table1, table2]}, {where, {xyz, '=', > {'+', [1,2,3,4]}}}} > > If commas were optional, this example could be written as > > {select [foo, bar, baz] {from [table1, table2]} {where {xyz '=' {'+' > [1 2 3 4]}}}} > > I think the second line is more readable, and it's also easier to > write. In other DSELs, the difference may be even more substantial. IMHO, this is a case for a real DSL - I mean, what's the point in contriving a DSL's syntax to follow Erlang's or extend Erlang syntax to match arbitrary DSLs? Maybe other DSLs will require lists delimited with {} and tuples with [], for example... Better to use a syntax that's matching the DSL and write a parser for it, I think. In this particuar case, I'd either go with full sql (it's at least standard, people already know it) or find an Erlang equivalent that isn't following sql that closely. Just my 2c. regards, Vlad From yarivvv@REDACTED Wed Sep 20 20:22:38 2006 From: yarivvv@REDACTED (Yariv Sadan) Date: Wed, 20 Sep 2006 14:22:38 -0400 Subject: [erlang-questions] comma-less lists and tuples In-Reply-To: <95be1d3b0609201102l6ce72ab9iecf27de35676f18c@mail.gmail.com> References: <17244f480609200717i1e137462pfff910d4777025f3@mail.gmail.com> <95be1d3b0609201102l6ce72ab9iecf27de35676f18c@mail.gmail.com> Message-ID: <17244f480609201122j540a7b63sadaf9bc3b2223857@mail.gmail.com> Hi Vlad, > > IMHO, this is a case for a real DSL - I mean, what's the point in > contriving a DSL's syntax to follow Erlang's or extend Erlang syntax > to match arbitrary DSLs? Maybe other DSLs will require lists delimited > with {} and tuples with [], for example... I don't think Erlang's syntax should be extended to match arbitrary DSLs... however, I do think that allowing whitespace to be treated as a delimiter (if it's possible and it wouldn't break any existing code) would make the existing Erlang syntax, which is already quite friendly for a variety of DSLs (of which ErlSQL is just one example), even more DSL-friendly. > > Better to use a syntax that's matching the DSL and write a parser for > it, I think. That's an option, but then your build process becomes more cumbersome. On the other hand, if you stay in Erlang, you are more limited by the constraints of Erlang's syntax, but this is probably good enough for a large number of DSLs. For the more advanced ones, a special parser may be required. > > In this particuar case, I'd either go with full sql (it's at least > standard, people already know it) or find an Erlang equivalent that > isn't following sql that closely. The main benefit of ErlSQL is that it makes programmatic generation of queries in Erlang easy because you work with the semantic elements of SQL directly in Erlang rather than doing string concatenation. The examples I've shown have a make a literal translation to SQL, which may not seem so impressive, but examples that involve more programmatic SQL generation look far better with ErlSQL than with string-concatenation. Regards, Yariv From vladdu55@REDACTED Wed Sep 20 20:58:04 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Wed, 20 Sep 2006 19:58:04 +0100 Subject: [erlang-questions] comma-less lists and tuples In-Reply-To: <17244f480609201122j540a7b63sadaf9bc3b2223857@mail.gmail.com> References: <17244f480609200717i1e137462pfff910d4777025f3@mail.gmail.com> <95be1d3b0609201102l6ce72ab9iecf27de35676f18c@mail.gmail.com> <17244f480609201122j540a7b63sadaf9bc3b2223857@mail.gmail.com> Message-ID: <95be1d3b0609201158p4f51c8a1nba8d4c423099af72@mail.gmail.com> On 9/20/06, Yariv Sadan wrote: > I don't think Erlang's syntax should be extended to match arbitrary > DSLs... however, I do think that allowing whitespace to be treated as > a delimiter (if it's possible and it wouldn't break any existing code) > would make the existing Erlang syntax, which is already quite friendly > for a variety of DSLs (of which ErlSQL is just one example), even more > DSL-friendly. Yes, maybe. What I meant was that there may be other varieties of DSLs that would benefit from other syntax changes. I agree the list/tuple example was not realistic, but once starting on that path it's hard to stop. > > In this particuar case, I'd either go with full sql (it's at least > > standard, people already know it) or find an Erlang equivalent that > > isn't following sql that closely. > > The main benefit of ErlSQL is that it makes programmatic generation of > queries in Erlang easy because you work with the semantic elements of > SQL directly in Erlang rather than doing string concatenation. Yes, I know, you are working with is the syntax tree of the sql statements. Syntax trees need not (and in practice aren't) bear any resemblance with the textual form of the original. I will argue that it is even counterproductive - if the syntax tree form is meant to be written by a human. Why write {select, [bob], {from, [person]}} instead of select bob from person ? If the tree form is just an internal form that only other programs will manipulate, then the syntax of the data representing the tree becomes irrelevant. Likewise the optimizations you started to introduce (prefix operators). > The examples I've shown have a make a literal translation to SQL, which > may not seem so impressive, but examples that involve more > programmatic SQL generation look far better with ErlSQL than with > string-concatenation. Wonderful. The question is then: is it meaningful to change Erlang syntax just so that a particular class of programs just _look far better_? If the goal is to make sql-building code more readable, there is nothing that beats writing sql code, IMHO. The metaprogramming syntax I am working on is still in the future (and is still a change to the Erlang language), but even today you can do something like Column = "bob", Table = "person", sql:statement("select $Column from $Table") where sql:statement() would be processed by an adequate parse transform to ["select ",sql:escape(Column)," from ", sql:escape(Table)] and if you need to, it could even parse it and return the syntax tree as above. I may be biased because I don't work that much with sql, but to me it is very readable and if I were a sql developer I wouldn't have to learn a new way to express sql statements. I hope I'm not sounding like I am putting you down, Yariv. I agree very much with the idea behind ErlSql, it is just the form that doesn't feel very comfortable to me. regards, Vlad From ok@REDACTED Thu Sep 21 03:33:29 2006 From: ok@REDACTED (Richard A. O'Keefe) Date: Thu, 21 Sep 2006 13:33:29 +1200 (NZST) Subject: [erlang-questions] comma-less lists and tuples Message-ID: <200609210133.k8L1XTJX468280@atlas.otago.ac.nz> "Yariv Sadan" wrote: When working with ErlSQL, I came to the opinion that in some cases, Erlang would benefit from allowing whitespace as a delimiter in lists and tuples in place of commas. Consider this small example: {select, [foo, bar, baz], {from, [table1, table2]}, {where, {xyz, '=', {'+', [1,2,3,4]}}}} The thing that strikes *me* most forcibly about that is the quantity of noise words. Coding something like this in Prolog, I would use select(Selection, Source[, Restriction[, Grouping]]) e.g. select([foo,bar,baz], table1 * table2, xyz = 1+2+3+4) and this would work rather nicely because Prolog predicate arguments are not (except in some very exceptional cases) evaluated (and even then, they are notionally evaluated by the callER, not the callEE). I note that in SQL 92, the "from" part is not a simple list of tables, but an expression, so I would be inclined to write {select, [foo,bar,baz], {cross,table1,table2}, {=,xyz,{'+',1,2,3,4}}} where the general form for an expression is expression ::= number | string | atom | '{' operator {',' expression}* '}' operator ::= atom and we have '{' 'select' ',' list(expression), expression [',' expression % where [',' list(expression) % group by [',' expression % having ]]] '}' If commas were optional, this example could be written as {select [foo, bar, baz] {from [table1, table2]} {where {xyz '=' {'+' [1 2 3 4]}}}} I think the second line is more readable, and it's also easier to write. Erlang syntax owes much to Strand88 (whatever happened to Strand88, anyway?) and Prolog. Prolog has user-defined operators, so this could not work in Prolog. Erlang doesn't have user-defined operators, but they would often be nice, and other functional languages like Haskell, Clean, SML, and CAML have them. It would be sad to adopt a feature which made user-defined operators unusable now and forever. One obvious question is whether the Lispy form (don't get me wrong, Lispy syntax is GREAT, but you have to be consistent about it, and Lisp, of course, _is_) is easier to write *correctly*. Maybe it is, but it _looks_ error-prone. In other DSELs, the difference may be even more substantial. We can confidently expect each new DSEL to stress *some* aspect of Erlang syntax; we *can't* expect them to all stress the *same* aspect. In particular, I would dumbfounded if there were no DSELs for which user-defined operators and unevaluated expressions were not extremely convenient. Come to think of it, SQL is one of them. By *far* the most readable and writable way to write SQL queries in Erlang would be something like @sql[ select foo, bar, baz from table1, table1 where xyz = 1+2+3+4 ] where '@' ::= (/) | [/] | {/} | <> would take a sequence of tokens and pass it off to _parser:parse(Tokens) Within the bracket-balanced token sequence, '@' '=' would let you embed Erlang expressions (which would be passed as some kind of token). Hmm. Wait. Let's add a new declaration -embedded_syntax( , ). to go near the top of a file, so you'd have -embedded_syntax(sql, my_sql_parser). and then you could have Query = @sql{ select foo, bar, ugh from @=Table1, @=Table2 where xyz = @=XYZ } What do you think? Am I missing something? Generality. From ok@REDACTED Thu Sep 21 03:45:27 2006 From: ok@REDACTED (Richard A. O'Keefe) Date: Thu, 21 Sep 2006 13:45:27 +1200 (NZST) Subject: [erlang-questions] comma-less lists and tuples Message-ID: <200609210145.k8L1jRLg468177@atlas.otago.ac.nz> Thomas Lindgren wrote: Smalltalk has a similar notation, something like "select: [foo bar baz] from: [tab1, tab2] where: [xyz '=' {'+', [1 2 3 4]}]"' As a Smalltalk user (still haven't finished my Smalltalk compiler; too busy supervising students) who frequently consults the standard and peers at the compiler's workings from time to time, I can tell you that Smalltalk has no such syntax. Smalltalk array LITERALS don't have commas, so SQL select: #(foo bar baz) from: #(tab1 tab2) where: #(= xyz (+ 1 2 3 4)) would be entirely possible. However, there is no Smalltalk equivalent of backquote. Suppose we wanted the name "bar", the name "tab2", and the number "3" to be replaced by the values of Smalltalk variables. In standard Smalltalk, you would have to write SQL select: (Array with: #foo with: bar with: #baz) from: (Array with: #tab1 with: tab2) where: (Array with: #= with: #xyz with: #(+ 1 2) , (Array with: three) , #(4)) where , is the infix concatenation operator. Squeak Smalltalk has an "array literal with all elements evaluated" syntax, using which we could write SQL select: {#foo. bar. #baz} from: {#tab1. tab2} where: {#=. #xyz. {#+. 1. 2. three. 4}} Squeak's '{' ... '.' ... '}' syntax is pretty much equivalent to Erlang's '{' ... ',' ... '}' syntax, except for using full stops instead of commas. Actually, *native* Smalltalk style for really querying a data base would be something like this: ((table1 cross: table2) select: [:tuple | 1+2+3+4 = tuple xyz]) collect: [:tuple | {tuple foo. tuple bar. tuple ugh}] The only languages in which this kind of thing is really easy are the Lisp-family languages. From cyberlync@REDACTED Thu Sep 21 04:26:09 2006 From: cyberlync@REDACTED (Eric Merritt) Date: Wed, 20 Sep 2006 19:26:09 -0700 Subject: [erlang-questions] Reintrant parsing of erlang terms Message-ID: Guys, I am working on a pipe driver that uses event system to handle multiple sources of input. One of those sources is a pipe from an erlang node. The ei_decode* stuff doesn't really handle chunking it seems, so I will probably need to handle it as part of the protocol. That being the case, are there ways to do that that are more favored then others by the general erlang population? Thanks, Eric From znmeb@REDACTED Thu Sep 21 06:39:32 2006 From: znmeb@REDACTED (M. Edward (Ed) Borasky) Date: Wed, 20 Sep 2006 21:39:32 -0700 Subject: [erlang-questions] measuring OS context switches In-Reply-To: <3CD23375-2875-4928-80A7-A83094F8E8BF@redstarling.com> References: <3CD23375-2875-4928-80A7-A83094F8E8BF@redstarling.com> Message-ID: <45121784.8080006@cesmail.net> ke han wrote: > I am doing a comparative analysis of a webapp with Ruby on Rails vs. > Yaws+mysql. The app being used is the "depot" app from the book > Agile Programing in Rails (Pragmatic Programmer). This app is used > in many Rails based tutorials and seems a good one to use since I > already have the Rail version complete and it would be hard for the > Rails community to say I "cheated" as its their app. > > There is little value in just measuring end-to-end page load times > and overall stress testing as it doesn't explain "why" erlang is > beating the pants off Rails (obviously I'm making assumptions about > the results ;-)). I want to show ratios of "real work" vs. OS > context switches + other internal communications between processes, > etc... > > Can anyone give ideas for how to go about measuring such things?? I > can litter Rails code with all sorts of wall clock logging and try to > put this to use, but this also means I have to dig into lighttpd and > mysql to log some of their times as well...there must be some tools > or methods I don't know about. I was hoping to have access to a > Solaris server for these tests and use DTrace and other profiling > tools Sun crows about, but alas, no interest from Sun (or hosting > partners) in providing a box to test on...So I'll be doing this > initial analysis on my iMac dual core and maybe a dual proc FreeBSD > server. > > If I do this correctly, I should have the sample code and scripts to > allow others to try out variations on my tests. Such as: Rails: 1 > lighttpd proc, 20 mongrel/ruby procs, 1 mysql proc (20 connections) > on a single CPU vs, variations on multi-core. The erlang solution > could be varied by multi-threaded erlang vs. single threaded and > such. I'm not so interested in measuring context switches between > procs within a multi-thread erlang vm as I think my results will be > interesting enough to show how much overhead is in the Rails "runtime > architecture". > > thanks, ke han > > BTW, Yariv, if you catch this email, I will be using your erlyDB > along with some javascript and erlang prototypes I've been working on > to make the front end work. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions First of all, you'll want some kind of load test driver. There are good ones for sale, but I think there are some open source ones that are at least usable. Second, you'll want some kind of performance data logging and capture on the server. I don't know anything about MacOS or BSD -- I do this for a living on Windows and Linux servers. :) I'm not sure context switches are necessarily something you should measure. The fundamental measurements you need to take are transaction response times and throughputs, and the number of seconds spent in physical processors, physical disks and on the network. > From vladdu55@REDACTED Thu Sep 21 08:56:43 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Thu, 21 Sep 2006 08:56:43 +0200 Subject: [erlang-questions] comma-less lists and tuples In-Reply-To: <200609210133.k8L1XTJX468280@atlas.otago.ac.nz> References: <200609210133.k8L1XTJX468280@atlas.otago.ac.nz> Message-ID: <95be1d3b0609202356u50646cfeodb616e7e51055fbb@mail.gmail.com> On 9/21/06, Richard A. O'Keefe wrote: > By *far* the most readable and writable way to write SQL queries > in Erlang would be something like > > @sql[ select foo, bar, baz > from table1, table1 > where xyz = 1+2+3+4 ] /snip/ Hey, this is exactly what I suggested a while ago and what I am working on (but it's not going forward as fast as I'd want) :-) Well, with a different syntax... I was preparing something for the EUC, but since I won't be able to attend I will make available my thoughts on the matter of metaprogramming in Erlang so that everybody can provide input. I feel there's a lot of potential here. >> What do you think? Am I missing something? > Generality. To put it another way, putting an Erlang syntax around sql statements (*) is just a way to make the programmer write extra code in order to make things easier for the compiler. Things should go the other way around, don't they? (*) especially if it's basically the same statement, but with added {} and commas and with some parts enclosed in single quotes best regards, Vlad From fritchie@REDACTED Thu Sep 21 09:10:22 2006 From: fritchie@REDACTED (Scott Lystig Fritchie) Date: Thu, 21 Sep 2006 02:10:22 -0500 Subject: [erlang-questions] mnesia:dirty_update_counter and replicated tables Message-ID: <200609210710.k8L7AMpp017104@snookles.snookles.com> There hasn't been any discussion of mnesia:dirty_update_counter here in quite a while. Looking through my archive, I didn't find a definite answer. Is mnesia:dirty_update_counter safe to use when the underlying 'set' table is replicated? If I use mnesia:dirty_update_counter on the same counter on two different Mnesia nodes, would I ever be unpleasantly surprised? The flow seems to go through the transaction manager, which bodes well for multi-node safety? Umrfl, it's too late to be reading Mnesia code. It will be a good learning exercise to continue my reading, but in the meantime ... is there a quick'ish answer from a kind soul? Or will a tormenting soul tell me to use tracing and the 'dbg' module to trace the path for myself? :-) -Scott From surindar.shanthi@REDACTED Thu Sep 21 09:15:59 2006 From: surindar.shanthi@REDACTED (Surindar Sivanesan) Date: Thu, 21 Sep 2006 12:45:59 +0530 Subject: [erlang-questions] Multi line commenting in erlang Message-ID: <42ea5fb60609210015t7f1d5a16j7f8692324518654c@mail.gmail.com> Hi all, Is there any multi line commenting option in erlang? -- with regards, S.Surindar -------------- next part -------------- An HTML attachment was scrubbed... URL: From Bob.Cowdery@REDACTED Thu Sep 21 09:32:06 2006 From: Bob.Cowdery@REDACTED (Bob Cowdery) Date: Thu, 21 Sep 2006 08:32:06 +0100 Subject: [erlang-questions] Basic question Message-ID: <3A76756EED583B43A4AD704E29CCD079741171@mail.aprsmartlogik.com> Hi Firstly, sorry if this is a really stupid question but I've not written any FP style programs yet. I am unsure how to handle data structures in Erlang. If I have say a process responsible for registrations, and that process is required to maintain a list of registrations how does it hold that list across calls. The only mention I can find of doing such things is the process dictionary. Is this the right way or am I completely mising some fundamental point here. Thanks Bob From vladdu55@REDACTED Thu Sep 21 09:41:21 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Thu, 21 Sep 2006 09:41:21 +0200 Subject: [erlang-questions] Basic question In-Reply-To: <3A76756EED583B43A4AD704E29CCD079741171@mail.aprsmartlogik.com> References: <3A76756EED583B43A4AD704E29CCD079741171@mail.aprsmartlogik.com> Message-ID: <95be1d3b0609210041i3abe8dedwf64ffa8d5ab790a1@mail.gmail.com> Hi Bob, On 9/21/06, Bob Cowdery wrote: > Firstly, sorry if this is a really stupid question but I've not written any FP style programs yet. I am unsure how to handle data structures in Erlang. If I have say a process responsible for registrations, and that process is required to maintain a list of registrations how does it hold that list across calls. The only mention I can find of doing such things is the process dictionary. Is this the right way or am I completely mising some fundamental point here. Simply put, a server's state is saved in the arguments of the server loop function. server_loop(State) -> receive stop -> ok; Msg -> NewState = do_something(State, Msg), server_loop(NewState) end. best regards, Vlad From rlenglet@REDACTED Thu Sep 21 09:43:23 2006 From: rlenglet@REDACTED (Romain Lenglet) Date: Thu, 21 Sep 2006 16:43:23 +0900 Subject: [erlang-questions] Multi line commenting in erlang In-Reply-To: <42ea5fb60609210015t7f1d5a16j7f8692324518654c@mail.gmail.com> References: <42ea5fb60609210015t7f1d5a16j7f8692324518654c@mail.gmail.com> Message-ID: <200609211643.24175.rlenglet@users.forge.objectweb.org> Surindar Sivanesan wrote: > Is there any multi line commenting option in erlang? No. "This isn't a bug in Erlang, it's a feature." Cf. this previous discussion: http://www.erlang.org/pipermail/erlang-questions/2006-March/019778.html -- Romain LENGLET Pr. Chiba Shigeru Group Dept. of Mathematical and Computing Sciences Tokyo Institute of Technology From xlcr@REDACTED Thu Sep 21 09:52:35 2006 From: xlcr@REDACTED (Nick Linker) Date: Thu, 21 Sep 2006 14:52:35 +0700 Subject: [erlang-questions] Erlang-Fu In-Reply-To: <45113713.209@gmail.com> References: <45113713.209@gmail.com> Message-ID: <451244C3.3020709@mail.ru> Hi! As for me, I'm interested in examples. A lot of. Something like http://www.java2s.com/ for Java. ps: good luck ;-) Best regards, Nick. Mel Boyce wrote: > I have just registered the domain http://erlang-fu.com/ which will at > some soon stage become my on-line Erlang presence (blog, docs, et al) > and wanted to probe the mailing list for interest, suggestions, > mail-forwarding requests ;), and the like. > From dmitriid@REDACTED Thu Sep 21 09:52:35 2006 From: dmitriid@REDACTED (Dmitrii Dimandt) Date: Thu, 21 Sep 2006 10:52:35 +0300 Subject: [erlang-questions] Erlide and console input Message-ID: Is tehre a way to read in console input from Erlide, i.e. use functions like get_line. When I try to use get_line, Erlide throws th? following error at me: =INFO REPORT==== 21-Sep-2006::10:41:32 === erlide_reshd:handle_io_request: Unexpected IORequest:{get_line,'Prompt'} Thank you -------------- next part -------------- An HTML attachment was scrubbed... URL: From vladdu55@REDACTED Thu Sep 21 10:07:19 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Thu, 21 Sep 2006 10:07:19 +0200 Subject: [erlang-questions] Erlide and console input In-Reply-To: References: Message-ID: <95be1d3b0609210107k7ee340b5y17bc62f0e31e826d@mail.gmail.com> On 9/21/06, Dmitrii Dimandt wrote: > Is tehre a way to read in console input from Erlide, i.e. use functions like > get_line. > > When I try to use get_line, Erlide throws th? following error at me: > =INFO REPORT==== 21-Sep-2006::10:41:32 === > erlide_reshd:handle_io_request: Unexpected IORequest:{get_line,'Prompt'} Hi, As you noticed, it doesn't work yet. I didn't even think about that aspect, so it's a good thing you noticed it. I will look at it. Reshd doesn't support all io requests, but hopefully it will be relatively easy to add get_line. regards, Vlad From thomasl_erlang@REDACTED Thu Sep 21 10:16:22 2006 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Thu, 21 Sep 2006 01:16:22 -0700 (PDT) Subject: [erlang-questions] comma-less lists and tuples In-Reply-To: <200609210145.k8L1jRLg468177@atlas.otago.ac.nz> Message-ID: <20060921081622.86142.qmail@web38815.mail.mud.yahoo.com> Yes; my example wasn't Smalltalk, just mildly "similar". The purpose was to sketch the "foo:bar:baz" notation; sorry if this was not clear. Best, Thomas ----- Original Message ---- From: Richard A. O'Keefe To: erlang-questions@REDACTED Sent: Thursday, September 21, 2006 3:45:27 AM Subject: Re: [erlang-questions] comma-less lists and tuples Thomas Lindgren wrote: Smalltalk has a similar notation, something like "select: [foo bar baz] from: [tab1, tab2] where: [xyz '=' {'+', [1 2 3 4]}]"' As a Smalltalk user (still haven't finished my Smalltalk compiler; too busy supervising students) who frequently consults the standard and peers at the compiler's workings from time to time, I can tell you that Smalltalk has no such syntax. /.../ From ulf.wiger@REDACTED Thu Sep 21 11:16:09 2006 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Thu, 21 Sep 2006 11:16:09 +0200 Subject: [erlang-questions] comma-less lists and tuples In-Reply-To: <95be1d3b0609202356u50646cfeodb616e7e51055fbb@mail.gmail.com> Message-ID: Vlad Dumitrescu wrote: > > On 9/21/06, Richard A. O'Keefe wrote: > >> What do you think? Am I missing something? > > Generality. > > To put it another way, putting an Erlang syntax around sql > statements (*) is just a way to make the programmer write > extra code in order to make things easier for the compiler. > Things should go the other way around, don't they? Do you mean teaching the compiler to parse SQL, or to leave it as is and letting the compiler remain ignorant? ;-) One purpose of making things easier for the compiler is of course that the compiler can then _help you_ get it right. This should then be a metric for evaluating any special syntax: do we actually gain something by forcing the programmer to write quasi-SQL rather than SQL directly? (Despite the obvious problem with SQL that it is by no means easy to parse - in part because it isn't case sensitive.) > (*) especially if it's basically the same statement, > but with added {} and commas and with some parts > enclosed in single quotes Enhanced readability is, I think, a secondary issue, but also very important. But inventing a new syntax may then confuse the reader unless it actually serves to make the statement more intuitive. BR, Ulf W From ulf.wiger@REDACTED Thu Sep 21 11:25:49 2006 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Thu, 21 Sep 2006 11:25:49 +0200 Subject: [erlang-questions] mnesia:dirty_update_counter and replicated tables In-Reply-To: <200609210710.k8L7AMpp017104@snookles.snookles.com> Message-ID: Hi Scott, I believe the quick'ish answer is "no". Dirty_update_counter() is not more safe than dirty_write(), and dirty_write() and dirty_write() is known to lead to inconsistencies in certain failure situations. This applies equally to dirty_update_counter() BR, Ulf W > -----Original Message----- > From: erlang-questions-bounces@REDACTED > [mailto:erlang-questions-bounces@REDACTED] On Behalf Of > Scott Lystig Fritchie > Sent: den 21 september 2006 09:10 > To: erlang-questions@REDACTED > Subject: [erlang-questions] mnesia:dirty_update_counter and > replicated tables > > There hasn't been any discussion of > mnesia:dirty_update_counter here in quite a while. > > Looking through my archive, I didn't find a definite answer. > Is mnesia:dirty_update_counter safe to use when the underlying 'set' > table is replicated? If I use mnesia:dirty_update_counter on > the same counter on two different Mnesia nodes, would I ever > be unpleasantly surprised? > > The flow seems to go through the transaction manager, which > bodes well for multi-node safety? Umrfl, it's too late to be > reading Mnesia code. It will be a good learning exercise to > continue my reading, but in the meantime ... is there a > quick'ish answer from a kind soul? > > Or will a tormenting soul tell me to use tracing and the > 'dbg' module to trace the path for myself? :-) > > -Scott > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From vladdu55@REDACTED Thu Sep 21 11:46:43 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Thu, 21 Sep 2006 11:46:43 +0200 Subject: [erlang-questions] comma-less lists and tuples In-Reply-To: References: <95be1d3b0609202356u50646cfeodb616e7e51055fbb@mail.gmail.com> Message-ID: <95be1d3b0609210246tea5ababp373c525216d7359e@mail.gmail.com> On 9/21/06, Ulf Wiger (TN/EAB) wrote: > Vlad Dumitrescu wrote: > > To put it another way, putting an Erlang syntax around sql > > statements (*) is just a way to make the programmer write > > extra code in order to make things easier for the compiler. > > Things should go the other way around, don't they? Hi, What I mean is that IMHO if one wants a structured representation of something in textual form, the best way is to use a parser. As the lazy programmer I am, I don't want to do manually do the parser's work, while at the same time making the representation harder to read and a nightmare to maintain... > Do you mean teaching the compiler to parse SQL, or to leave > it as is and letting the compiler remain ignorant? ;-) How could the Erlang compiler help me write better SQL statements? Yes, if I write quasi-SQL, I get some syntax checking, but I still can write stupid things like {select, {where, {x, '=', 3}}, foo, {from, [table]}} which is a correct Erlang term, but not correct quasi-SQL. In the particular case of SQL, we can also skip any parsing and do fine with strings - especially since sql is not only hard to parse, but there are many different dialects too. I'd rather let the database's parser take care of that. I don't really see what's wrong with concatenating strings :-) Escaping parts that come from outside needs to be done even with quasi-sql. Using a parse transform as per my previous example would make it even almost as readable as pure sql. > This should then be a metric for evaluating any > special syntax: do we actually gain something by forcing > the programmer to write quasi-SQL rather than SQL directly? Precisely. If it isn't obvious already, my opinion is that there is no gain in completely erlang-izing the sql language. But that's just me. best regards, Vlad From ulf.wiger@REDACTED Thu Sep 21 12:29:03 2006 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Thu, 21 Sep 2006 12:29:03 +0200 Subject: [erlang-questions] comma-less lists and tuples In-Reply-To: <95be1d3b0609210246tea5ababp373c525216d7359e@mail.gmail.com> Message-ID: Vlad Dumitrescu wrote: > > How could the Erlang compiler help me write better SQL > statements? Yes, if I write quasi-SQL, I get some syntax > checking, but I still can write stupid things like > {select, {where, {x, '=', 3}}, foo, {from, [table]}} > which is a correct Erlang term, but not correct quasi-SQL. Well, that would be the task of a domain-specific parser, or a parse_transform. Basically: - pure SQL in a string or binary + nothing can be decided at compile time, except perhaps that it is a string or a binary. - a record or list of atoms etc. mimicking SQL + syntactic checks can be made at compile time, but no semantic checks, like the one you describe - a very regular structure with a library doing lots of pattern matching + dialyzer can possibly, at "compile time", determine that your statement will not pass the pattern matching of the library, since it's not properly structured. - a domain-specific parser (either as ROK suggests, or perhaps by wrapping the query inside a pseudo function and checking it in a parse transform, much like with QLC and Mnemosyne) + extensive checks and optimizations can be made at compile-time. With the last option, one has to decide whether to stick to regular Erlang syntax, or depart from it. It doesn't preclude using plain SQL syntax, since you can call an SQL parser from the parse transform. If you want a yecc grammar for SQL, there is one, actually, which works at least for a significant subset of ANSI92 SQL. Departing from Erlang syntax is tricky in a parse transform, since the erlang tokenizer and parser will get hold of it before your parse transform. Using erlang syntax, but imposing your own semantics is likely to confuse the reader. I did that to some extent in plain_fsm, by wrapping a receive statement inside a pseudo function in order to handle OTP system messages. The obvious dilemma was that pattern matching can't be extended that way, so the parse transform had to turn it into something quite different. This has to be clearly explained, and the sought advantage is partly spoiled. What would be very nice, I think, would be to write a QLC generator for e.g. MySQL. Nice - if someone else decides to do it, and I wouldn't have to. (: A MSc student did write an SQL parser converting SQL to Mnemosyne queries. This worked quite well. Going from a QLC query to SQL should be doable, and - assuming I'm right - raises the argument that Erlang already _has_ quite a powerful syntax for database queries. So why invent a new one? BR, Ulf W From vladdu55@REDACTED Thu Sep 21 12:38:09 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Thu, 21 Sep 2006 12:38:09 +0200 Subject: [erlang-questions] comma-less lists and tuples In-Reply-To: References: <95be1d3b0609210246tea5ababp373c525216d7359e@mail.gmail.com> Message-ID: <95be1d3b0609210338j6ccab7cdn7aa6359dcebdcd02@mail.gmail.com> On 9/21/06, Ulf Wiger (TN/EAB) wrote: > Vlad Dumitrescu wrote: > > How could the Erlang compiler help me write better SQL > > statements? Yes, if I write quasi-SQL, I get some syntax > > checking, but I still can write stupid things like > > {select, {where, {x, '=', 3}}, foo, {from, [table]}} > > which is a correct Erlang term, but not correct quasi-SQL. > Well, that would be the task of a domain-specific parser, > or a parse_transform. Yes, of course. This is what I was trying to say too, but didn't manage to express my self as clearly. > Departing from Erlang syntax is tricky in a parse transform, > since the erlang tokenizer and parser will get hold of it > before your parse transform. This might get a solution, "Quite Soon (tm)"-ish. > A MSc student did write an SQL parser converting SQL > to Mnemosyne queries. This worked quite well. Going > from a QLC query to SQL should be doable, and - assuming > I'm right - raises the argument that Erlang already > _has_ quite a powerful syntax for database queries. > So why invent a new one? Very good point. But this wouldn't make the discussion obsolete because there might be other DSLs that one might want to use besides sql. best regards, Vlad From yarivvv@REDACTED Thu Sep 21 15:47:45 2006 From: yarivvv@REDACTED (Yariv Sadan) Date: Thu, 21 Sep 2006 09:47:45 -0400 Subject: [erlang-questions] comma-less lists and tuples In-Reply-To: <95be1d3b0609210246tea5ababp373c525216d7359e@mail.gmail.com> References: <95be1d3b0609202356u50646cfeodb616e7e51055fbb@mail.gmail.com> <95be1d3b0609210246tea5ababp373c525216d7359e@mail.gmail.com> Message-ID: <17244f480609210647t23a08661m32cb1db07efeecf8@mail.gmail.com> Hi, > > What I mean is that IMHO if one wants a structured representation of > something in textual form, the best way is to use a parser. As the > lazy programmer I am, I don't want to do manually do the parser's > work, while at the same time making the representation harder to read > and a nightmare to maintain... > > > Do you mean teaching the compiler to parse SQL, or to leave > > it as is and letting the compiler remain ignorant? ;-) > > How could the Erlang compiler help me write better SQL statements? > Yes, if I write quasi-SQL, I get some syntax checking, but I still can > write stupid things like > {select, {where, {x, '=', 3}}, foo, {from, [table]}} > which is a correct Erlang term, but not correct quasi-SQL. > > In the particular case of SQL, we can also skip any parsing and do > fine with strings - especially since sql is not only hard to parse, > but there are many different dialects too. I'd rather let the > database's parser take care of that. > > I don't really see what's wrong with concatenating strings :-) > Escaping parts that come from outside needs to be done even with > quasi-sql. Using a parse transform as per my previous example would > make it even almost as readable as pure sql. > > > This should then be a metric for evaluating any > > special syntax: do we actually gain something by forcing > > the programmer to write quasi-SQL rather than SQL directly? > > Precisely. If it isn't obvious already, my opinion is that there is no > gain in completely erlang-izing the sql language. But that's just me. > The first reason to use the "quasi-SQL" for is that it *guarantees* that you will not expose yourself to SQL injection attacks, whereas string contcatentation does not. It's like the difference between coding in a high level language and coding in C. Can you avoid buffer overflow attacks when writing in C? Sure. But for some reason many smart people have a hard time avoiding them, which is one reason that many projects avoid C/C++. Even if you're really smart and you were able to prevent 99.9% of all buffer overflows in a large codebase, that single one you didn't prevent can cost you a fortune. Plus, some programmers on your team may not be as skilled as you in avoiding such pitfalls. Using a tool that always prevents them can save you a lot of pain down the road. Users of ErlyDB and the MySQL driver have asked me, "Your examples use (some) SQL directly, which makes you volnerable to SQL injection attacks. How can I prevent them?" That's one of the primary reasons I made ErlSQL: I wanted to tell them -- "here, use this." And it had to be easy to use, to look like SQL, and to express a very large subset of SQL because otherwise they would (legitimately) complain that it's not intuitive to learn and/or that doesn't do everything they want it to do. For the second point: I have said a few times that ErlSQL code looks much better than string concatenation code when it does a little more than just literal translation. I'll try to drive the point home with an example taken from ErlyDB, which makes the query for getting related records in a many-to-many relation. Here's the string concatention way: make_get_related_many_to_many_query(OtherModule, JoinTable, Obj, WhereClause, ExtraClause) -> OtherTableStr = atom_to_list(OtherModule), ThisTableStr = get_module_str(Obj), JoinTableStr = atom_to_list(JoinTable), WhereClause1 = make_nested_where_clause(WhereClause), FieldStrs = make_str_for_fields(OtherModule), Query = lists:append( ["SELECT ", FieldStrs, " FROM ", OtherTableStr, ",", JoinTableStr, " WHERE (", OtherTableStr, ".id = ", JoinTableStr, ".", OtherTableStr, "_id AND ", JoinTableStr, ".", ThisTableStr, "_id=", get_id_str(Obj), ")", WhereClause1, ExtraClause]), Query. make_str_for_fields(Module) -> TableStr = atom_to_list(Module), {Result, _} = lists:foldl( fun(Field, {Str, IsFirst}) -> FieldName = TableStr ++ "." ++ atom_to_list(Field), Str1 = if IsFirst -> FieldName; true -> FieldName ++ "," end, {Str1 ++ Str, false} end, {"", true}, lists:reverse(Module:fields())), Result. make_nested_where_clause(WhereClause) -> case WhereClause of undefined -> " "; _ -> " AND (" ++ WhereClause ++ ") " end. Here's the ErlSQL way: make_get_related_many_to_many_query(OtherModule, JoinTable, Obj, WhereClause, ExtraClause) -> {select, OtherModule:shown_fields(), {from, [OtherModule:table(), JoinTable]}, {where, {{{OtherModule, id},'=', {JoinTable, get_id_field(OtherModule)}}, 'and', {{JoinTable, get_id_field(Obj)}, '=', get_id(Obj)}}, 'and', WhereClause)}, ExtraClause}. Which do you think is more readable? Which is more writable? Even putting readability aside, when the Mnesia driver is passed this structure, it doesn't have to parse anything. It can pattern-match on the queries that it knows it can handle and breaks on the rest. That's a big win in simplifying the code. Best regards, Yariv From dirtyundies@REDACTED Thu Sep 21 13:54:55 2006 From: dirtyundies@REDACTED (Mikkel Jensen) Date: Thu, 21 Sep 2006 04:54:55 -0700 (PDT) Subject: [erlang-questions] Missing ssl_esock directory Message-ID: <6426450.post@talk.nabble.com> Hi, I have managed to install R11B-1 on my Ubuntu machine including SSL and ODBC support (or so I thought) But while trying to launch a HTTPS site in Yaws I run into the following error: sh: /usr/local/lib/erlang/lib/ssl-3.0.12/priv/bin/ssl_esock: No such file or directory I guess I'm missing an SSL package (or perhaps a configuration flag) when I installed Erlang. Any ideas? - Mikkel -- View this message in context: http://www.nabble.com/Missing-ssl_esock-directory-tf2311402.html#a6426450 Sent from the Erlang Questions mailing list archive at Nabble.com. From serge@REDACTED Thu Sep 21 17:41:21 2006 From: serge@REDACTED (Serge Aleynikov) Date: Thu, 21 Sep 2006 11:41:21 -0400 Subject: [erlang-questions] mnesia:dirty_update_counter and replicated tables In-Reply-To: <200609210710.k8L7AMpp017104@snookles.snookles.com> References: <200609210710.k8L7AMpp017104@snookles.snookles.com> Message-ID: <4512B2A1.5090701@hq.idt.net> Scott, The answer is regretfully no. Let's consider an example to illustrate this point. You have two nodes A and B both running mnesia with a replicated table. 1. The content of a counter is 1. 2. Node A does a mnesia:dirty_update_counter call to increment the value of the counter by 2. 3. Very closely in time node B does mnesia:dirty_update_counter call to increment the counter by 3. After this the value of that field could be either one of: a) 3. b) 4. c) 6. No guarantees can be made as to which value the counter would hold without having cross-node locking involved by using transactions. Depending on the application you could use transactions to update data and dirty operations for read-only purposes. Regards, Serge Scott Lystig Fritchie wrote: > There hasn't been any discussion of mnesia:dirty_update_counter here > in quite a while. > > Looking through my archive, I didn't find a definite answer. Is > mnesia:dirty_update_counter safe to use when the underlying 'set' > table is replicated? If I use mnesia:dirty_update_counter on the same > counter on two different Mnesia nodes, would I ever be unpleasantly > surprised? > > The flow seems to go through the transaction manager, which bodes well > for multi-node safety? Umrfl, it's too late to be reading Mnesia > code. It will be a good learning exercise to continue my reading, but > in the meantime ... is there a quick'ish answer from a kind soul? > > Or will a tormenting soul tell me to use tracing and the 'dbg' module > to trace the path for myself? :-) > > -Scott > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- Serge Aleynikov R&D Telecom, MIS, IDT Corp Tel: +1 (973) 438-3436 Fax: +1 (973) 438-1464 From erlangX@REDACTED Thu Sep 21 18:07:19 2006 From: erlangX@REDACTED (Michael McDaniel) Date: Thu, 21 Sep 2006 09:07:19 -0700 Subject: [erlang-questions] Missing ssl_esock directory In-Reply-To: <6426450.post@talk.nabble.com> References: <6426450.post@talk.nabble.com> Message-ID: <20060921160719.GB5745@delora.autosys.us> On Thu, Sep 21, 2006 at 04:54:55AM -0700, Mikkel Jensen wrote: > > Hi, > > I have managed to install R11B-1 on my Ubuntu machine including SSL and ODBC > support (or so I thought) > But while trying to launch a HTTPS site in Yaws I run into the following > error: > > sh: /usr/local/lib/erlang/lib/ssl-3.0.12/priv/bin/ssl_esock: No such file or > directory > > I guess I'm missing an SSL package (or perhaps a configuration flag) when I > installed Erlang. > > Any ideas? > > - Mikkel > -- > View this message in context: http://www.nabble.com/Missing-ssl_esock-directory-tf2311402.html#a6426450 > 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 _____________________________________________________________________ I have Ubuntu 6.06 installed $ uname -a Linux delora 2.6.15-23-386 #1 PREEMPT Tue May 23 13:49:40 UTC 2006 i686 GNU/Linux Here's the configure switches I used for R11B-1 $ ./configure --with-odbc --x-includes=/usr/local/include --x-libraries=/usr/lib --with-ssl screen output from make commands deleted below... $ make $ cd /usr/local/lib $ sudo mv erlang erlang-R11-0 $ cd $ sudo make install $ which yaws /usr/local/bin/yaws $ yaws --version Yaws 1.65 $ excerpt from /etc/yaws.conf ... access_log = false port = 443 listen = 127.0.0.1 docroot = /var/yaws/expect dir_listings = false appmods = errormod_404 = m3m_404 errormod_crash = experror keyfile = /etc/yaws-key.pem certfile = /etc/yaws-cert.pem starting yaws thusly... sudu su -c "cd /var/yaws/ebin ; \ /usr/local/bin/yaws -sname yaws_autosys -heart \ --conf /etc/yaws.conf -D -x" $ echo y | w3m -dump https://localhost self signed certificate: accept? (y/n)Accept unsecure SSL session: unverified: self signed certificate Expect Media Server was expecting a POST. aa v1.23 al v1.8 d v1.71 er v1.4 ec v1.38 em v1.23 fi v1.25 mx v1.151 o v1.6 I do not think I added anything special to my Ubuntu install except probably the dev stuff for ssl ... $ dpkg --list | egrep -i libssl ii libssl-dev 0.9.8a-7build1 SSL development libraries, header files and ii libssl0.9.7 0.9.7g-5ubuntu1 SSL shared libraries ii libssl0.9.8 0.9.8a-7build1 SSL shared libraries Hopefully some item in the above will assist in troubleshooting your configuration. ~Michael From ulf.wiger@REDACTED Thu Sep 21 18:11:47 2006 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Thu, 21 Sep 2006 18:11:47 +0200 Subject: [erlang-questions] mnesia:dirty_update_counter and replicated tables In-Reply-To: <4512B2A1.5090701@hq.idt.net> Message-ID: Even though this problem would seem to be addressed by wrapping dirty_update_counter inside a transaction: mnesia:activity( transaction, fun() -> mnesia:write_lock_table(Tab), mnesia:dirty_update_counter({Tab, Key}, Incr) end). It _still_ wouldn't be safe, for the following reasons: - Dirty updates within a transaction are not recognized as updates per se. So there will be failure situations were the update may not propagate consistently to all replicas. - Since the dirty update cannot be undone, and mnesia reserves the right to re-run transactions in the name of deadlock prevention, you are not guaranteed that the update will happen only once. - If your transaction aborts, the update_counter will not be rolled back, if it had time to execute before the abort, which you have no way of knowing (unless you add some additional dirty stuff). BR, Ulf W Serge Aleynikov wrote: > > Scott, > > The answer is regretfully no. Let's consider an example to > illustrate this point. You have two nodes A and B both > running mnesia with a replicated table. > > 1. The content of a counter is 1. > 2. Node A does a mnesia:dirty_update_counter call to > increment the value of the counter by 2. > 3. Very closely in time node B does > mnesia:dirty_update_counter call to increment the counter by 3. > > After this the value of that field could be either one of: > > a) 3. > b) 4. > c) 6. > > No guarantees can be made as to which value the counter would > hold without having cross-node locking involved by using transactions. > > Depending on the application you could use transactions to > update data and dirty operations for read-only purposes. From erlangX@REDACTED Thu Sep 21 18:18:53 2006 From: erlangX@REDACTED (Michael McDaniel) Date: Thu, 21 Sep 2006 09:18:53 -0700 Subject: [erlang-questions] Missing ssl_esock directory In-Reply-To: <20060921160719.GB5745@delora.autosys.us> References: <6426450.post@talk.nabble.com> <20060921160719.GB5745@delora.autosys.us> Message-ID: <20060921161853.GD5745@delora.autosys.us> On Thu, Sep 21, 2006 at 09:07:19AM -0700, Michael McDaniel wrote: > > > On Thu, Sep 21, 2006 at 04:54:55AM -0700, Mikkel Jensen wrote: > > > > Hi, > > > > I have managed to install R11B-1 on my Ubuntu machine including SSL and ODBC > > support (or so I thought) > > But while trying to launch a HTTPS site in Yaws I run into the following > > error: > > > > sh: /usr/local/lib/erlang/lib/ssl-3.0.12/priv/bin/ssl_esock: No such file or > > directory > > > > I guess I'm missing an SSL package (or perhaps a configuration flag) when I > > installed Erlang. > > > > Any ideas? > > > > - Mikkel > > -- > > View this message in context: http://www.nabble.com/Missing-ssl_esock-directory-tf2311402.html#a6426450 > > 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 > _____________________________________________________________________ > > I have Ubuntu 6.06 installed > > $ uname -a > Linux delora 2.6.15-23-386 #1 PREEMPT Tue May 23 13:49:40 UTC 2006 i686 GNU/Linux > > Here's the configure switches I used for R11B-1 > > $ ./configure --with-odbc --x-includes=/usr/local/include --x-libraries=/usr/lib --with-ssl > > screen output from make commands deleted below... > > $ make > $ cd /usr/local/lib > $ sudo mv erlang erlang-R11-0 > $ cd > $ sudo make install > > $ which yaws > /usr/local/bin/yaws > $ yaws --version > Yaws 1.65 > $ > > excerpt from /etc/yaws.conf ... > > > access_log = false > > port = 443 > listen = 127.0.0.1 > docroot = /var/yaws/expect > dir_listings = false > > appmods = > > errormod_404 = m3m_404 > errormod_crash = experror > > > > keyfile = /etc/yaws-key.pem > certfile = /etc/yaws-cert.pem > > > > > > starting yaws thusly... > > sudu su -c "cd /var/yaws/ebin ; \ > /usr/local/bin/yaws -sname yaws_autosys -heart \ > --conf /etc/yaws.conf -D -x" > > > $ echo y | w3m -dump https://localhost > self signed certificate: accept? (y/n)Accept unsecure SSL session: unverified: self signed certificate > Expect Media Server was expecting a POST. > > aa v1.23 > > al v1.8 > > d v1.71 > > er v1.4 > > ec v1.38 > > em v1.23 > > fi v1.25 > > mx v1.151 > > o v1.6 > > > I do not think I added anything special to my Ubuntu install > except probably the dev stuff for ssl ... > > $ dpkg --list | egrep -i libssl > ii libssl-dev 0.9.8a-7build1 SSL development libraries, header files and > ii libssl0.9.7 0.9.7g-5ubuntu1 SSL shared libraries > ii libssl0.9.8 0.9.8a-7build1 SSL shared libraries > > > Hopefully some item in the above will assist in troubleshooting > your configuration. > > > ~Michael _______________________________________________ P.S. yes, I did recompile yaws using R11B-1 though I did not show it above ... From sami.vaisanen@REDACTED Thu Sep 21 18:21:20 2006 From: sami.vaisanen@REDACTED (=?ISO-8859-1?Q?Sami_V=E4is=E4nen?=) Date: Thu, 21 Sep 2006 19:21:20 +0300 Subject: [erlang-questions] erl interface Message-ID: <4512BC00.4030805@icecom.fi> Hello. Is the C interface for writing a C node (erl_interface) thread safe? Thank you. From serge@REDACTED Thu Sep 21 18:33:18 2006 From: serge@REDACTED (Serge Aleynikov) Date: Thu, 21 Sep 2006 12:33:18 -0400 Subject: [erlang-questions] mnesia:dirty_update_counter and replicated tables In-Reply-To: References: Message-ID: <4512BECE.9030900@hq.idt.net> Uffe, You highlighted an interesting point of wrapping "dirty" operations in transactions. I haven't thought of this possibility, always perceiving "dirty" operations being orthogonal to transaction-based operations. Is there ever a point of using "dirty" updates inside transactions? Serge Ulf Wiger (TN/EAB) wrote: > Even though this problem would seem to be addressed by > wrapping dirty_update_counter inside a transaction: > > mnesia:activity( > transaction, > fun() -> > mnesia:write_lock_table(Tab), > mnesia:dirty_update_counter({Tab, Key}, Incr) > end). > > It _still_ wouldn't be safe, for the following reasons: > > - Dirty updates within a transaction are not recognized > as updates per se. So there will be failure situations > were the update may not propagate consistently to all > replicas. > - Since the dirty update cannot be undone, and mnesia > reserves the right to re-run transactions in the name > of deadlock prevention, you are not guaranteed that > the update will happen only once. > - If your transaction aborts, the update_counter will > not be rolled back, if it had time to execute before > the abort, which you have no way of knowing (unless > you add some additional dirty stuff). > > BR, > Ulf W > > Serge Aleynikov wrote: >> Scott, >> >> The answer is regretfully no. Let's consider an example to >> illustrate this point. You have two nodes A and B both >> running mnesia with a replicated table. >> >> 1. The content of a counter is 1. >> 2. Node A does a mnesia:dirty_update_counter call to >> increment the value of the counter by 2. >> 3. Very closely in time node B does >> mnesia:dirty_update_counter call to increment the counter by 3. >> >> After this the value of that field could be either one of: >> >> a) 3. >> b) 4. >> c) 6. >> >> No guarantees can be made as to which value the counter would >> hold without having cross-node locking involved by using transactions. >> >> Depending on the application you could use transactions to >> update data and dirty operations for read-only purposes. -- Serge Aleynikov R&D Telecom, MIS, IDT Corp Tel: +1 (973) 438-3436 Fax: +1 (973) 438-1464 From richardc@REDACTED Thu Sep 21 18:47:24 2006 From: richardc@REDACTED (Richard Carlsson) Date: Thu, 21 Sep 2006 18:47:24 +0200 Subject: [erlang-questions] eunit examples In-Reply-To: <4511FAEE.9020500@duomark.com> References: <4511FAEE.9020500@duomark.com> Message-ID: <4512C21C.7090405@it.uu.se> Jay Nelson wrote: > Do you have examples of using eunit that you showed in your presentation > Saturday that are available for download anywhere? Here they are, slightly edited: http://user.it.uu.se/~richardc/eunit/ (For those who saw the presentation, or have previously tried the alpha version: there is now only the eunit.hrl header file to include; the rest is automatic.) /Richard PS. I removed the old alpha tarball, since it was getting too outdated. You can get eunit from https://svn.process-one.net/contribs/trunk/eunit but remember that it still has alpha status. From erlangX@REDACTED Thu Sep 21 19:09:01 2006 From: erlangX@REDACTED (Michael McDaniel) Date: Thu, 21 Sep 2006 10:09:01 -0700 Subject: [erlang-questions] eunit examples In-Reply-To: <4512C21C.7090405@it.uu.se> References: <4511FAEE.9020500@duomark.com> <4512C21C.7090405@it.uu.se> Message-ID: <20060921170901.GE5745@delora.autosys.us> On Thu, Sep 21, 2006 at 06:47:24PM +0200, Richard Carlsson wrote: > Jay Nelson wrote: > > Do you have examples of using eunit that you showed in your presentation > > Saturday that are available for download anywhere? > > Here they are, slightly edited: > > http://user.it.uu.se/~richardc/eunit/ > > (For those who saw the presentation, or have previously tried the alpha > version: there is now only the eunit.hrl header file to include; the > rest is automatic.) > > /Richard > > PS. I removed the old alpha tarball, since it was getting too outdated. > You can get eunit from https://svn.process-one.net/contribs/trunk/eunit > but remember that it still has alpha status. _______________________________________________ Thank you, and thank you for having open .odt format posted as well (at almost 1/10 the size of power-point). ~Michael From cyberlync@REDACTED Thu Sep 21 19:12:27 2006 From: cyberlync@REDACTED (Eric Merritt) Date: Thu, 21 Sep 2006 10:12:27 -0700 Subject: [erlang-questions] erl interface In-Reply-To: <4512BC00.4030805@icecom.fi> References: <4512BC00.4030805@icecom.fi> Message-ID: Sami, ei is thread safe. erl_interface is thread safe with a bit of work on your part. see -> http://www.erlang.org/doc/doc-5.5.1/lib/erl_interface-3.5.5.1/doc/html/application_ei_frame.html http://www.erlang.org/doc/doc-5.5.1/lib/erl_interface-3.5.5.1/doc/html/part_erl_interface_frame.html On 9/21/06, Sami V?is?nen wrote: > Hello. > > Is the C interface for writing a C node (erl_interface) thread safe? > > Thank you. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From vladdu55@REDACTED Thu Sep 21 20:54:39 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Thu, 21 Sep 2006 19:54:39 +0100 Subject: [erlang-questions] comma-less lists and tuples In-Reply-To: <17244f480609210647t23a08661m32cb1db07efeecf8@mail.gmail.com> References: <95be1d3b0609202356u50646cfeodb616e7e51055fbb@mail.gmail.com> <95be1d3b0609210246tea5ababp373c525216d7359e@mail.gmail.com> <17244f480609210647t23a08661m32cb1db07efeecf8@mail.gmail.com> Message-ID: <95be1d3b0609211154q7dab7eacgb744549f5b03792e@mail.gmail.com> Hi! On 9/21/06, Yariv Sadan wrote: > The first reason to use the "quasi-SQL" for is that it *guarantees* > that you will not expose yourself to SQL injection attacks, whereas > string contcatentation does not. Yes, naive string concatenation doesn't. But I guess I didn't express myself clearly enough: it is not this simple string concatenation that I compare with ErlSql, but a similar library with the single difference that the API uses string-sql instead of erlang-sql. The comparison you make is unfair, because for example make_str_for_fields/1 is a library function. I bet ten pints of beer that OtherModule:shown_fields() does something very similar. So how would this alternative library look like? Taking your example and without any parse transformations or other non-standard functionality, I would like to see something like make_get_related_many_to_many_query(OtherModule, JoinTable, Obj, WhereClause, ExtraClause) -> sql:build("select %L from %L " " where (%s.id=%s.%s " " and %s.%s= %s) " " and (%s) " " %s", [OtherModule:shown_fields(), [OtherModule:table(), JoinTable], OtherModule, JoinTable, get_id_field(OtherModule), JoinTable, get_id_field(Obj), get_id(Obj), WhereClause, ExtraClause]). This can be cleaned up a little (and your erlsql example too) by using some local variables. %L says the arg is a list of parameters. If we use a parse transform, the it may look even prettier (in my eyes, at least) make_get_related_many_to_many_query(OtherModule, JoinTable, Obj, WhereClause, ExtraClause) -> sql:build("select %%OtherModule:shown_fields() " " from %%[OtherModule:table(), JoinTable] " " where (%OtherModule.id=%JoinTable.%get_id_field(OtherModule) " " and %JoinTable.%get_id_field(Obj)=%get_id(Obj)) " " and (%WhereClause) " " %ExtraClause"). What sql:build does behind the scenes is an implementation detail. It may put together strings (like io:format) or it may parse the sql, build a quasi-sql representation and work with it. As a user I don't care, as long as it does what it is supposed to do. I don't have to keep counting nested {}s and []s and to learn what in fact is a new query language (you already want to introduce new ways to write things). BTW, how do you write 'join' statements? The natural way for an erlang data structure would be {join, {select,...}, {select,...}}, but that doesn't follow the way the sql looks like. Having a new query language isn't a bad thing, but then it's not sql. best regards, Vlad From vances@REDACTED Thu Sep 21 21:00:38 2006 From: vances@REDACTED (Vance Shipley) Date: Thu, 21 Sep 2006 15:00:38 -0400 Subject: [erlang-questions] mnesia:dirty_update_counter and replicated tables In-Reply-To: <200609210710.k8L7AMpp017104@snookles.snookles.com> References: <200609210710.k8L7AMpp017104@snookles.snookles.com> Message-ID: <20060921190037.GB98463@frogman.motivity.ca> On Thu, Sep 21, 2006 at 02:10:22AM -0500, Scott Lystig Fritchie wrote: } There hasn't been any discussion of mnesia:dirty_update_counter here } in quite a while. Well since you've brought it up ... In ETS update_counter/3 is implemented as: update_counter(Tab, Key, {Pos,Incr,Threshold,SetValue}) -> Result update_counter(Tab, Key, {Pos,Incr}) -> Result update_counter(Tab, Key, Incr) -> Result You can atomically update a wrap around counter. E.g.: ets:update_counter(tid, {2,1,16#ffffffff,0}) This maintains a 16 bit counter. In mnesia the wrap around functionality is missing: dirty_update_counter(Tab, Key, Incr) -> NewVal | exit({aborted, Reason}) So whereas I'd like to do: mnesia:dirty_update_counter(counters,transactionID,{2,1,16#ffffffff,0}) Instead I have to do: Fun = fun() -> [C] = mnesia:read(counters, transactionID, write), LocalTID = (C#counters.val + 1) rem 16#ffffffff, mnesia:write(counters, C#counters{val = LocalTID}, write), LocalTID end, {atomic, LocalTID} = mnesia:transaction(Fun), ... which may be safer but for a simple counter unecessary. -Vance From yarivvv@REDACTED Thu Sep 21 21:39:14 2006 From: yarivvv@REDACTED (Yariv Sadan) Date: Thu, 21 Sep 2006 15:39:14 -0400 Subject: [erlang-questions] comma-less lists and tuples In-Reply-To: <95be1d3b0609211154q7dab7eacgb744549f5b03792e@mail.gmail.com> References: <95be1d3b0609202356u50646cfeodb616e7e51055fbb@mail.gmail.com> <95be1d3b0609210246tea5ababp373c525216d7359e@mail.gmail.com> <17244f480609210647t23a08661m32cb1db07efeecf8@mail.gmail.com> <95be1d3b0609211154q7dab7eacgb744549f5b03792e@mail.gmail.com> Message-ID: <17244f480609211239m1a78b92dv34c0748ef6436aae@mail.gmail.com> (Vlad, sorry for sending this twice -- I forgot to CC the list) > Yes, naive string concatenation doesn't. But I guess I didn't express > myself clearly enough: it is not this simple string concatenation that > I compare with ErlSql, but a similar library with the single > difference that the API uses string-sql instead of erlang-sql. > > The comparison you make is unfair, because for example > make_str_for_fields/1 is a library function. I bet ten pints of beer > that OtherModule:shown_fields() does something very similar. You owe me ten pints -- that function returns a list of atoms :) - Show quoted text - > > So how would this alternative library look like? Taking your example > and without any parse transformations or other non-standard > functionality, I would like to see something like > > make_get_related_many_to_many_query(OtherModule, JoinTable, Obj, > WhereClause, ExtraClause) -> > sql:build("select %L from %L " > " where (%s.id=%s.%s " > " and %s.%s= %s) " > " and (%s) " > " %s", > [OtherModule:shown_fields(), [OtherModule:table(), JoinTable], > OtherModule, JoinTable, get_id_field(OtherModule), > JoinTable, get_id_field(Obj), get_id(Obj), > WhereClause, > ExtraClause]). > > This can be cleaned up a little (and your erlsql example too) by using > some local variables. %L says the arg is a list of parameters. > > If we use a parse transform, the it may look even prettier (in my > eyes, at least) > > make_get_related_many_to_many_query(OtherModule, JoinTable, Obj, > WhereClause, ExtraClause) -> > sql:build("select %%OtherModule:shown_fields() " > " from %%[OtherModule:table(), JoinTable] " > " where > (%OtherModule.id=%JoinTable.%get_id_field(OtherModule) " > " and %JoinTable.%get_id_field(Obj)=%get_id(Obj)) " > " and (%WhereClause) " > " %ExtraClause"). > > What sql:build does behind the scenes is an implementation detail. It > may put together strings (like io:format) or it may parse the sql, > build a quasi-sql representation and work with it. As a user I don't > care, as long as it does what it is supposed to do. I don't have to > keep counting nested {}s and []s and to learn what in fact is a new > query language (you already want to introduce new ways to write > things). Whether these examples look better or not than ErlSQL is in the eyes of the beholder. I, personally, don't find ErlSQL expressions any worse than the alternatives, but I would be happy to give the user both options and let them pick whichever they prefer :) To ErlSQL's advantage, I should say that emacs does a good job of indenting your clauses and helping you balance all the parens, and it has nice syntax colorization that make these expressions look better than they do in Email. Also, it's much cheaper to build ErlSQL in runtime than the first example because it doesn't require any parsing. Another benefit of ErlSQL is that when you pass an ErlSQL expression as a parameter to different functions, it's easy for them to extract information about its structure and values using pattern matching. In ErlyDB, this makes writing adapters for non-SQL drivers (e.g. Mnesia) much easier. > > BTW, how do you write 'join' statements? The natural way for an erlang > data structure would be {join, {select,...}, {select,...}}, but that > doesn't follow the way the sql looks like. Right now explicit joins aren't part of the language simply because I haven't needed them. Joins are implicitly expressed in FROM and WHERE clauses. > > Having a new query language isn't a bad thing, but then it's not sql. It's not SQL... it's an Erlangification of SQL :) Cheers, Yariv From dirtyundies@REDACTED Thu Sep 21 22:02:12 2006 From: dirtyundies@REDACTED (Mikkel Jensen) Date: Thu, 21 Sep 2006 13:02:12 -0700 (PDT) Subject: [erlang-questions] Missing ssl_esock directory In-Reply-To: <20060921161853.GD5745@delora.autosys.us> References: <6426450.post@talk.nabble.com> <20060921160719.GB5745@delora.autosys.us> <20060921161853.GD5745@delora.autosys.us> Message-ID: <6435465.post@talk.nabble.com> Michael McDaniel-2 wrote: > > On Thu, Sep 21, 2006 at 09:07:19AM -0700, Michael McDaniel wrote: >> >> >> On Thu, Sep 21, 2006 at 04:54:55AM -0700, Mikkel Jensen wrote: >> > >> > Hi, >> > >> > I have managed to install R11B-1 on my Ubuntu machine including SSL and >> ODBC >> > support (or so I thought) >> > But while trying to launch a HTTPS site in Yaws I run into the >> following >> > error: >> > >> > sh: /usr/local/lib/erlang/lib/ssl-3.0.12/priv/bin/ssl_esock: No such >> file or >> > directory >> > >> > I guess I'm missing an SSL package (or perhaps a configuration flag) >> when I >> > installed Erlang. >> > >> > Any ideas? >> > >> > - Mikkel >> > -- >> > View this message in context: >> http://www.nabble.com/Missing-ssl_esock-directory-tf2311402.html#a6426450 >> > 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 >> _____________________________________________________________________ >> >> I have Ubuntu 6.06 installed >> >> $ uname -a >> Linux delora 2.6.15-23-386 #1 PREEMPT Tue May 23 13:49:40 UTC 2006 i686 >> GNU/Linux >> >> Here's the configure switches I used for R11B-1 >> >> $ ./configure --with-odbc --x-includes=/usr/local/include >> --x-libraries=/usr/lib --with-ssl >> >> screen output from make commands deleted below... >> >> $ make >> $ cd /usr/local/lib >> $ sudo mv erlang erlang-R11-0 >> $ cd >> $ sudo make install >> >> $ which yaws >> /usr/local/bin/yaws >> $ yaws --version >> Yaws 1.65 >> $ >> >> excerpt from /etc/yaws.conf ... >> >> >> access_log = false >> >> port = 443 >> listen = 127.0.0.1 >> docroot = /var/yaws/expect >> dir_listings = false >> >> appmods = >> >> errormod_404 = m3m_404 >> errormod_crash = experror >> >> >> >> keyfile = /etc/yaws-key.pem >> certfile = /etc/yaws-cert.pem >> >> >> >> >> >> starting yaws thusly... >> >> sudu su -c "cd /var/yaws/ebin ; \ >> /usr/local/bin/yaws -sname yaws_autosys -heart \ >> --conf /etc/yaws.conf -D -x" >> >> >> $ echo y | w3m -dump https://localhost >> self signed certificate: accept? (y/n)Accept unsecure SSL session: >> unverified: self signed certificate >> Expect Media Server was expecting a POST. >> >> aa v1.23 >> >> al v1.8 >> >> d v1.71 >> >> er v1.4 >> >> ec v1.38 >> >> em v1.23 >> >> fi v1.25 >> >> mx v1.151 >> >> o v1.6 >> >> >> I do not think I added anything special to my Ubuntu install >> except probably the dev stuff for ssl ... >> >> $ dpkg --list | egrep -i libssl >> ii libssl-dev 0.9.8a-7build1 >> SSL development libraries, header files and >> ii libssl0.9.7 0.9.7g-5ubuntu1 >> SSL shared libraries >> ii libssl0.9.8 0.9.8a-7build1 >> SSL shared libraries >> >> >> Hopefully some item in the above will assist in troubleshooting >> your configuration. >> >> >> ~Michael > _______________________________________________ > > P.S. yes, I did recompile yaws using R11B-1 > though I did not show it above ... > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > Hi Michael, Thanks for the very thorough description! I'm not quite sure excactly what was missing in my configuration but following your description worked like a charm - I'm up and running! - Mikkel -- View this message in context: http://www.nabble.com/Missing-ssl_esock-directory-tf2311402.html#a6435465 Sent from the Erlang Questions mailing list archive at Nabble.com. From nm@REDACTED Thu Sep 21 22:07:08 2006 From: nm@REDACTED (Gaspar Chilingarov) Date: Fri, 22 Sep 2006 01:07:08 +0500 Subject: [erlang-questions] Speeding up string matching Message-ID: <4512F0EC.70901@web.am> Hi all! I wish to share an experience which I had today when writing code. I had a following function, which splits binary on enter character. I used it to split binaries to separate lines. Original code looked like this -- which is obvious dumb solution for that task. break_on_nl(B) -> break_on_nl(B, []). break_on_nl(<<"\n", Tail/binary>>, Res) -> {lists:reverse(Res), Tail}; break_on_nl(<<>>, Res) -> {lists:reverse(Res), <<>>}; break_on_nl(<>, Res) -> break_on_nl(Tail, [C|Res]). I.e. just cutting one character a time, checking that we reached \n and returning collected string and remaining tail if we reached it. After some occasional loon on this code I realized, that I can greatly improve it. Instead rebuilding binary to list and then reversing list I could just check every byte of binary, check if it is an Enter char, and then return binary splitted to 2 parts. Code like that: break_on_nl1(B) -> break_on_nl1(0, B). break_on_nl1(Len, Bin) when Len == size(Bin) -> {Bin, <<>>}; break_on_nl1(Len, Bin) -> <> = Bin, case Symb of $\n -> {Msg, Tail}; _ -> break_on_nl1(Len+1, Bin) end. Main advantage is that I do not modify original binary and it passed from one call to next one without copying. This little code rewrite gave me 2 times speed increase, which was quite essential, because I have strong timing constrains for that code. I think this trick will be useful for erlang starters. If not, gurus, please correct me :) -- Gaspar Chilingarov System Administrator, Network security consulting t +37493 419763 (mob) i 63174784 e nm@REDACTED From ulf@REDACTED Thu Sep 21 23:31:13 2006 From: ulf@REDACTED (Ulf Wiger) Date: Thu, 21 Sep 2006 23:31:13 +0200 Subject: [erlang-questions] mnesia:dirty_update_counter and replicated tables In-Reply-To: <4512BECE.9030900@hq.idt.net> References: <4512BECE.9030900@hq.idt.net> Message-ID: Den 2006-09-21 18:33:18 skrev Serge Aleynikov : > Uffe, > > You highlighted an interesting point of wrapping "dirty" operations in > transactions. I haven't thought of this possibility, always perceiving > "dirty" operations being orthogonal to transaction-based operations. > > Is there ever a point of using "dirty" updates inside transactions? No, I think it should be avoided at all times, since dirty updates constitute side-effects inside the transaction. I've had some perverted moments when I've tried to use ets or the process dictionary inside a transaction, but updating tables dirty from within a transaction is really asking for trouble, I think. Dirty reads may have their place sometimes in a transaction... maybe. One possible use is to specifically fetch the old value using a dirty op, and perhaps comparing with the value returned by the transaction-aware function. I seem to recall having done that too at times - but that's not to say that it's a good idea. (: BR, Ulf W -- Ulf Wiger From james.hague@REDACTED Fri Sep 22 00:32:20 2006 From: james.hague@REDACTED (James Hague) Date: Thu, 21 Sep 2006 17:32:20 -0500 Subject: [erlang-questions] Speeding up string matching In-Reply-To: <4512F0EC.70901@web.am> References: <4512F0EC.70901@web.am> Message-ID: > I think this trick will be useful for erlang starters. If not, gurus, > please correct me :) I discovered exactly the same trick in an XML parser I wrote earlier this year. Speed aside, it's much cleaner to separate the scanning and result building, too. At one time I had a fondness for the same style of code even with lists. Scan through the list, counting characters, then use list:sublist/2 or lists:split/2 to get the result. The nice thing about this approach is that there's the opportunity to move thost standard list functions to C code. Or at least I thought this was pretty at one time :) James From jefcrane@REDACTED Fri Sep 22 00:48:49 2006 From: jefcrane@REDACTED (Jeff Crane) Date: Thu, 21 Sep 2006 15:48:49 -0700 (PDT) Subject: [erlang-questions] Where is an ets guide? In-Reply-To: <6426450.post@talk.nabble.com> Message-ID: <20060921224849.25919.qmail@web31605.mail.mud.yahoo.com> I would like to find an ets usage guide? I had to type in "ets:new erlang" to Google just to come up with a half tutorial that just raises more questions. http://schemecookbook.org/Erlang/HashChapter --- dict provides a simple dictionary implementation, in which values (of any Erlang type) can be stored and accessed by keys (Erlang terms). ets has a similar interface, but is designed for dealing with vast quantities of data. --- What does that mean? They are the same, but not, and one is designed for dealing with lots of data, and dict is for something else entirely, like making toast? http://web.mit.edu/erlang_vR10B-10/arch/sun4x_510/lib/erlang/lib/stdlib-1.13.12/doc/html/ets.html look around and HOPE new/2 is the correct choice to start... ets:new(Name,Options) -> tid() so I type ets:new(mytable,[]). 16 % that's a tid! ets:insert(mytable,{1,"first"}). % Nope...wtf? MyTable2 = ets:new(mytable2,[]). 19 % that's a tid! ets:insert(MyTable2,{2,"second"}). % true? Um, I'm lost. What's the point of the name atom? Better yet, where's a halfway decent guide to ETS? __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From bob@REDACTED Fri Sep 22 01:21:26 2006 From: bob@REDACTED (Bob Ippolito) Date: Thu, 21 Sep 2006 16:21:26 -0700 Subject: [erlang-questions] Where is an ets guide? In-Reply-To: <20060921224849.25919.qmail@web31605.mail.mud.yahoo.com> References: <6426450.post@talk.nabble.com> <20060921224849.25919.qmail@web31605.mail.mud.yahoo.com> Message-ID: <6a36e7290609211621k2f6409d1n2f96a70bc251abb5@mail.gmail.com> On 9/21/06, Jeff Crane wrote: > I would like to find an ets usage guide? > > > I had to type in "ets:new erlang" to Google just to > come up with a half tutorial that just raises more > questions. > > http://schemecookbook.org/Erlang/HashChapter > --- > dict provides a simple dictionary implementation, in > which values (of any Erlang type) can be stored and > accessed by keys (Erlang terms). ets has a similar > interface, but is designed for dealing with vast > quantities of > data. > --- > What does that mean? They are the same, but not, and > one is designed for dealing with lots of data, and > dict is for something else entirely, like making > toast? I'm new to Erlang, but I didn't have any problems figuring it out from the documentation. I don't know why you're looking at older docs from somewhere other than erlang.org though? From erlang.org, click "documentation" on the left, then the first link "Erlang/OTP R11B documentation".. which takes you to the current docs here: http://erlang.org/doc/doc-5.5.1/doc/ To find docs for a module it'll be under one of the Applications on the menu bar in the left. It's anyone's guess which application a given module will be in, but I would look in stdlib first, then kernel. ets is in stdlib. > look around and HOPE new/2 is the correct choice to > start... > > ets:new(Name,Options) -> tid() > > so I type > > ets:new(mytable,[]). > 16 % that's a tid! Identifiers are supposed to be opaque.. just like the internal representation of dict, etc. > ets:insert(mytable,{1,"first"}). > % Nope...wtf? mytable isn't the Tid, and you didn't ask for a named table. > MyTable2 = ets:new(mytable2,[]). > 19 % that's a tid! > > ets:insert(MyTable2,{2,"second"}). > % true? Um, I'm lost. How lost could you be? It says very specifically that it always returns true. What else would you want it to return? > What's the point of the name atom? It helps to read *all* of the docs for a function. There's a named_table option, which lets you specify the Tid as an atom: * named_table If this option is present, the name Name is associated with the table identifier. The name can then be used instead of the table identifier in subsequent operations. > Better yet, where's a halfway decent guide to ETS? The docs are pretty sufficient, if you read them. -bob From erlangX@REDACTED Fri Sep 22 01:33:10 2006 From: erlangX@REDACTED (Michael McDaniel) Date: Thu, 21 Sep 2006 16:33:10 -0700 Subject: [erlang-questions] Where is an ets guide? In-Reply-To: <6a36e7290609211621k2f6409d1n2f96a70bc251abb5@mail.gmail.com> References: <6426450.post@talk.nabble.com> <20060921224849.25919.qmail@web31605.mail.mud.yahoo.com> <6a36e7290609211621k2f6409d1n2f96a70bc251abb5@mail.gmail.com> Message-ID: <20060921233310.GJ5745@delora.autosys.us> On Thu, Sep 21, 2006 at 04:21:26PM -0700, Bob Ippolito wrote: > On 9/21/06, Jeff Crane wrote: > > I would like to find an ets usage guide? > > > > > > I had to type in "ets:new erlang" to Google just to > > come up with a half tutorial that just raises more > > questions. > > > > http://schemecookbook.org/Erlang/HashChapter > > --- > > dict provides a simple dictionary implementation, in > > which values (of any Erlang type) can be stored and > > accessed by keys (Erlang terms). ets has a similar > > interface, but is designed for dealing with vast > > quantities of > > data. > > --- > > What does that mean? They are the same, but not, and > > one is designed for dealing with lots of data, and > > dict is for something else entirely, like making > > toast? > > I'm new to Erlang, but I didn't have any problems figuring it out from > the documentation. I don't know why you're looking at older docs from > somewhere other than erlang.org though? From erlang.org, click > "documentation" on the left, then the first link "Erlang/OTP R11B > documentation".. which takes you to the current docs here: > http://erlang.org/doc/doc-5.5.1/doc/ > > To find docs for a module it'll be under one of the Applications on > the menu bar in the left. It's anyone's guess which application a > given module will be in, but I would look in stdlib first, then > kernel. ets is in stdlib. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ May be easier to click 'Modules' on the left (at top) and then find the module ... ~M > > > look around and HOPE new/2 is the correct choice to > > start... > > > > ets:new(Name,Options) -> tid() > > > > so I type > > > > ets:new(mytable,[]). > > 16 % that's a tid! > > Identifiers are supposed to be opaque.. just like the internal > representation of dict, etc. > > > ets:insert(mytable,{1,"first"}). > > % Nope...wtf? > > mytable isn't the Tid, and you didn't ask for a named table. > > > MyTable2 = ets:new(mytable2,[]). > > 19 % that's a tid! > > > > ets:insert(MyTable2,{2,"second"}). > > % true? Um, I'm lost. > > How lost could you be? It says very specifically that it always > returns true. What else would you want it to return? > > > What's the point of the name atom? > > It helps to read *all* of the docs for a function. There's a > named_table option, which lets you specify the Tid as an atom: > > * named_table If this option is present, the name Name is associated > with the table identifier. The name can then be used instead of the > table identifier in subsequent operations. > > > Better yet, where's a halfway decent guide to ETS? > > The docs are pretty sufficient, if you read them. > > -bob > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- Michael McDaniel Portland, Oregon, USA http://autosys.us +1 503 283 5284 From ok@REDACTED Fri Sep 22 02:36:57 2006 From: ok@REDACTED (Richard A. O'Keefe) Date: Fri, 22 Sep 2006 12:36:57 +1200 (NZST) Subject: [erlang-questions] comma-less lists and tuples Message-ID: <200609220036.k8M0avew477016@atlas.otago.ac.nz> "Ulf Wiger \(TN/EAB\)" quoted: Do you mean teaching the compiler to parse SQL, or to leave it as is and letting the compiler remain ignorant? ;-) The approach I suggested, of having a declaration to associate an "embedded syntax" keyword with a new parser module, is, really, BOTH: - the Erlang compiler only knows about Erlang - but it can be extended with anything that can turn a token list into Erlang abstract syntax trees It's a parse transform at a somewhat lower level. From ulf@REDACTED Fri Sep 22 08:56:03 2006 From: ulf@REDACTED (Ulf Wiger) Date: Fri, 22 Sep 2006 08:56:03 +0200 Subject: [erlang-questions] comma-less lists and tuples In-Reply-To: <200609220036.k8M0avew477016@atlas.otago.ac.nz> References: <200609220036.k8M0avew477016@atlas.otago.ac.nz> Message-ID: Den 2006-09-22 02:36:57 skrev Richard A. O'Keefe : > "Ulf Wiger \(TN/EAB\)" quoted: > Do you mean teaching the compiler to parse SQL, or to leave > it as is and letting the compiler remain ignorant? ;-) > > The approach I suggested, of having a declaration to associate > an "embedded syntax" keyword with a new parser module, is, really, > BOTH: > - the Erlang compiler only knows about Erlang > - but it can be extended with anything that can turn a > token list into Erlang abstract syntax trees > > It's a parse transform at a somewhat lower level. Yes, and I started writing a reply to your post telling how much I liked your idea. I think it should be quite easy to implement, too. I've forgotten why I didn't send it. (: BR, Ulf W -- Ulf Wiger From vladdu55@REDACTED Fri Sep 22 09:11:38 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Fri, 22 Sep 2006 09:11:38 +0200 Subject: [erlang-questions] comma-less lists and tuples In-Reply-To: References: <200609220036.k8M0avew477016@atlas.otago.ac.nz> Message-ID: <95be1d3b0609220011w73490426gd43ade3ec71aba22@mail.gmail.com> On 9/22/06, Ulf Wiger wrote: > Den 2006-09-22 02:36:57 skrev Richard A. O'Keefe : > > The approach I suggested, of having a declaration to associate > > an "embedded syntax" keyword with a new parser module, is, really, > > BOTH: > > - the Erlang compiler only knows about Erlang > > - but it can be extended with anything that can turn a > > token list into Erlang abstract syntax trees > > > > It's a parse transform at a somewhat lower level. > > Yes, and I started writing a reply to your post > telling how much I liked your idea. I think it > should be quite easy to implement, too. It is easy. :-) The big problem is to decide on the syntax and then to convince the OTP team that it's a good idea to get it into the mainstream. With a little cooperation from the respective parser, it is also possible to use such expressions as patterns in a match. With provisional syntax = , Fields == [name, id] I will publish[*] a document about my attempts at metaprogramming in Erlang, where even more extensions are described. In the worst case, it would be possible to have the extensions only present in "metaerlang" files (suggested file extension: .mrl), so that we don't pollute the regular erlang language. [*] I will begin this weekend and have it on trapexit. regards, Vlad From bjorn@REDACTED Fri Sep 22 09:10:32 2006 From: bjorn@REDACTED (Bjorn Gustavsson) Date: 22 Sep 2006 09:10:32 +0200 Subject: [erlang-questions] Speeding up string matching In-Reply-To: <4512F0EC.70901@web.am> References: <4512F0EC.70901@web.am> Message-ID: I know that it isn't obvious, but the following version of your function should be faster: break_on_nl1(B) -> break_on_nl1(0, B). break_on_nl1(Len, Bin) when Len =:= size(Bin) -> {Bin, <<>>}; break_on_nl1(Len, Bin) -> case Bin of <<_:Len/binary, $\n, _/binary>> -> <> = Bin, {Msg, Tail}; _ -> break_on_nl1(Len+1, Bin) end. I haven't done any measurements on execution times, but I know that the revised version avoids creating two sub-binaries, which should make it faster. We hope to be able to add better optimization to a future version of the Erlang compiler, so that you will not have to write such contrived code to get the fastest possible bit syntax matching. /Bjorn Gaspar Chilingarov writes: > Hi all! > > I wish to share an experience which I had today when writing code. > [...] > > break_on_nl1(B) -> break_on_nl1(0, B). > break_on_nl1(Len, Bin) when Len == size(Bin) -> > {Bin, <<>>}; > break_on_nl1(Len, Bin) -> > <> = Bin, > case Symb of > $\n -> {Msg, Tail}; > _ -> break_on_nl1(Len+1, Bin) > end. -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From dmitriid@REDACTED Fri Sep 22 09:44:20 2006 From: dmitriid@REDACTED (Dmitrii Dimandt) Date: Fri, 22 Sep 2006 10:44:20 +0300 Subject: [erlang-questions] erlsoap-0.4.1 Message-ID: Hi all, I'm not sure if anyone noticed, but Anton Fedorov has released version 0.4and (after quite a lot of misunderstandings about and misgivings of a particular webservice) version 0.4.1 of erlsoap. The new version can be downloaded and discussed here: http://forum.trapexit.org/viewtopic.php?p=21614 I would like to ask you (on behalf of Anton, but without his consent, though :) ) to test this version in order to find any bugs or deficiencies. Make sure to read the existing discussion before you test, though. Thank you! -------------- next part -------------- An HTML attachment was scrubbed... URL: From olivier.sambourg@REDACTED Fri Sep 22 10:14:42 2006 From: olivier.sambourg@REDACTED (Olivier Sambourg) Date: Fri, 22 Sep 2006 10:14:42 +0200 Subject: [erlang-questions] Erlang and Maven In-Reply-To: References: <87bqpqx9pd.fsf@oqube.com> <87ac56q1m4.fsf@oqube.com> Message-ID: Hi everyone, For those interested in the Maven Erlang plugin I'm working on, I'm pleased to announce that the project is up and running at sourceforge (http:// maven-erlang.sourceforge.net). Please bear in mind that the documentation is still very incomplete. I haven't decided on the licence yet (I know, it's bad...) but I guess it'll be LGPL, Apache or BSD. Current features: - project setup (via the erlang-archetype plugin) - project compilation - compile and run test cases (implemented in the project lifecycle : tests will always be run when you package or deploy your project, for instance) - project packaging (OTP style and zipped, including documentation with edoc) - project deployment (via SCP, WebDAV, file copy, etc.) Plugin Installation: via SVN only for the moment. If you have maven installed, just type "mvn install" in both the plugins directories (erlang-plugin and erlang-archetype) Documentation (still very basic): http://maven-erlang.sourceforge.net/erlang-plugin/how-to.html A word about test cases: With JUnit, unit tests are separated from the rest of the code (in their own classes, obviously), and Maven mainains a separation between the corresponding .java files (src/test/java) from the rest of the code (src/main/java) I wanted to recreate this in Erlang as I don't like to put test code in my modules. So I came up with this: - during the "compile" phase, Maven-Erlang generates a "normal" Emakefile for the main .erl files then calls "erl -make" - after that, during the "test" phase, Maven-Erlang generates another Emakefile, which also compiles the test files (and adds the correct include paths). It also adds the compile_all flag. Basically, it lets you put all your test code in separate modules (and test every single function if you choose to). Finally, Maven-Erlang calls the test/0 function for every module ending with the "_test" suffix (the suffix can be changed in the POM file). I'd very much like your opinion on this design choice :) I think it works nicely with EUnit 2. Future features should include Erlang specific report generations and automatic deployment on an erlang node (including setting up the node if needed). I've also started to look into erlrt for transitive dependency management. Thanks for your feedback Olivier On 9/12/06, Olivier Sambourg wrote: > > 2006/9/11, Arnaud Bailly : > > > > Chandru < chandrashekhar.mullaparthi@REDACTED > writes: > > > > >> > > > > > > I don't know anything about Maven, but maybe you can use the OTP > > structure > > > for your system installation and the "mavenish" structure for your > > code > > > repository? > > > > I agree. The OTP structure could be constructed from the maven > > standard layout using assembly plugin or even a custom artefact > > type. For simplicity's and consistency's sake, it is better to keep > > adhering to maven's structure. > > > I also agree (it does seem obvious now...) > > > 2006/9/11, Vance Shipley < vances@REDACTED>: > > > > On 10/09/06, Olivier Sambourg < olivier.sambourg@REDACTED > wrote: > > > > > >If we take a look at various OTP applications, the common directory > > >structure seems to be : > > > > > >application/ > > >|-> src/ (source files, flat) > > >|-> include/ (include files...) > > >|-> doc/ (documentation) > > >|-> ebin/ (beam files) > > > > The convention in OTP when mixing languages is to have a "c_src" > > directory. For example: > > > > $ ls lib/erlang/lib/asn1- 1.4.4.10 > > c_src ebin examples priv src > > > > In this case there is a ddll driver and the C source is in c_src. > > The library with the driver code is in: > > > > lib/erlang/lib/asn1- 1.4.4.10/priv/lib/asn1_erl_drv.so > > > > Another example is the IC application which uses java: > > > > $ ls lib/erlang/lib/ic-4.2.11 > > c_src ebin examples include java_src priv src > > > > Thank you for the information :) > > > I've started working on the plugin, slowly at first as I'm still > struggling with Maven's documentation... For the moment, it's capable of > generating an Emakefile with various user defined options and use it to > compile the source files. Quite dull actually :) > Next step will be packaging, automatically running test cases and > generating the edoc (not necessarily in this order). Then there'll be > dynamic code loading (Cargo really seems a good idea...) and dependencies > management (REPOS is still my only lead). > > I've also started an archetype plugin (a special breed of maven plugins > used to set up a typical project, such as web apps, j2ee, etc.). It creates > the project directory structure, along with exemple sources files and a > basic POM file, so you can start coding right away... > > I'll let you know when I make significant progress. > > Thanks for the help > > > -- > Olivier > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dmitriid@REDACTED Fri Sep 22 15:58:21 2006 From: dmitriid@REDACTED (Dmitrii Dimandt) Date: Fri, 22 Sep 2006 16:58:21 +0300 Subject: [erlang-questions] Proxy authentication with inets Message-ID: Documentation show that http:set_options/1 allows only the following for proxy: {proxy, {HostName, Port}} where HostName = string(), Port = integer(). How can I force inets into accepting a username and a password for the proxy as well? If it is at all possible, of course. Thank you -------------- next part -------------- An HTML attachment was scrubbed... URL: From serge@REDACTED Fri Sep 22 16:19:34 2006 From: serge@REDACTED (Serge Aleynikov) Date: Fri, 22 Sep 2006 10:19:34 -0400 Subject: [erlang-questions] Proxy authentication with inets In-Reply-To: References: Message-ID: <4513F0F6.8020200@hq.idt.net> Though I haven't tried it, would the following work for the hostname? "username:password@REDACTED" Serge Dmitrii Dimandt wrote: > Documentation show that http:set_options/1 allows only the following for > proxy: > > {proxy, {HostName, Port}} where HostName = string(), Port = integer(). > > How can I force inets into accepting a username and a password for the > proxy as well? If it is at all possible, of course. > > Thank you From erlangX@REDACTED Fri Sep 22 16:43:20 2006 From: erlangX@REDACTED (Michael McDaniel) Date: Fri, 22 Sep 2006 07:43:20 -0700 Subject: [erlang-questions] Proxy authentication with inets In-Reply-To: <4513F0F6.8020200@hq.idt.net> References: <4513F0F6.8020200@hq.idt.net> Message-ID: <20060922144320.GN5745@delora.autosys.us> On Fri, Sep 22, 2006 at 10:19:34AM -0400, Serge Aleynikov wrote: > Though I haven't tried it, would the following work for the hostname? > > "username:password@REDACTED" > > > Serge > > Dmitrii Dimandt wrote: > > Documentation show that http:set_options/1 allows only the following for > > proxy: > > > > {proxy, {HostName, Port}} where HostName = string(), Port = integer(). > > > > How can I force inets into accepting a username and a password for the > > proxy as well? If it is at all possible, of course. > > > > Thank you > _______________________________________________ Or (also untested) perhaps the proxy will accept and pass the HTML Authorization header ? http://www.w3.org/Protocols/HTTP/HTRQ_Headers.html I do something like the following in one application ... ------- case (catch http:request(post, {"https://" ++ ServerName , [ {"Date", httpd_util:rfc1123_date()} , {"Host", ServerName} , {"REALM", "blah"} , {"API_VERSION", "ver:5.1"} , {"Authorization", "Basic " ++ http_base_64:encode(UPW)} , {"Accept", "text/xml/html"}, {"User-Agent", "custom blah client"} ] , "text/xml; charset=utf-8" , Body } , [{keepalive, false}, {nodelay,true}] , [])) of {ok, Result} -> {ok, Result} ; {error, Reason} -> ... etc. etc. ------- The application server (ServerName) in this case interprets the Authorization information. I am guessing the proxy (in original question) would pass the headers through (though, as mentioned, I have not tested this). ~M From erlangX@REDACTED Fri Sep 22 16:46:23 2006 From: erlangX@REDACTED (Michael McDaniel) Date: Fri, 22 Sep 2006 07:46:23 -0700 Subject: [erlang-questions] Proxy authentication with inets In-Reply-To: <20060922144320.GN5745@delora.autosys.us> References: <4513F0F6.8020200@hq.idt.net> <20060922144320.GN5745@delora.autosys.us> Message-ID: <20060922144623.GO5745@delora.autosys.us> On Fri, Sep 22, 2006 at 07:43:20AM -0700, Michael McDaniel wrote: > On Fri, Sep 22, 2006 at 10:19:34AM -0400, Serge Aleynikov wrote: > > Though I haven't tried it, would the following work for the hostname? > > > > "username:password@REDACTED" > > > > > > Serge > > > > Dmitrii Dimandt wrote: > > > Documentation show that http:set_options/1 allows only the following for > > > proxy: > > > > > > {proxy, {HostName, Port}} where HostName = string(), Port = integer(). > > > > > > How can I force inets into accepting a username and a password for the > > > proxy as well? If it is at all possible, of course. > > > > > > Thank you > > > _______________________________________________ > > Or (also untested) perhaps the proxy will accept and pass > the HTML Authorization header ? > > http://www.w3.org/Protocols/HTTP/HTRQ_Headers.html > > I do something like the following in one application ... > > ------- > case (catch http:request(post, > {"https://" ++ ServerName , > [ > {"Date", httpd_util:rfc1123_date()} , > {"Host", ServerName} , > {"REALM", "blah"} , > {"API_VERSION", "ver:5.1"} , > {"Authorization", "Basic " ++ http_base_64:encode(UPW)} , > {"Accept", "text/xml/html"}, > {"User-Agent", "custom blah client"} > ] , > "text/xml; charset=utf-8" , > Body > } , > [{keepalive, false}, {nodelay,true}] , > [])) of > > {ok, Result} -> > {ok, Result} ; > > {error, Reason} -> > > ... etc. etc. > ------- > > The application server (ServerName) in this case interprets the > Authorization information. > > I am guessing the proxy (in original question) would pass the > headers through (though, as mentioned, I have not tested this). > > ~M _______________________________________________ P.S. I mean maybe proxy will accept and use Authorization header; whether it passes it through maybe is irrelevant for original question From chandrashekhar.mullaparthi@REDACTED Fri Sep 22 17:10:03 2006 From: chandrashekhar.mullaparthi@REDACTED (Chandru) Date: Fri, 22 Sep 2006 16:10:03 +0100 Subject: [erlang-questions] Proxy authentication with inets In-Reply-To: References: Message-ID: On 22/09/06, Dmitrii Dimandt wrote: > > Documentation show that http:set_options/1 allows only the following for > proxy: > > {proxy, {HostName, Port}} where HostName = string(), Port = integer(). > > How can I force inets into accepting a username and a password for the > proxy as well? If it is at all possible, of course. ibrowse supports proxy authentication. cheers Chandru -------------- next part -------------- An HTML attachment was scrubbed... URL: From erlangX@REDACTED Fri Sep 22 17:40:21 2006 From: erlangX@REDACTED (Michael McDaniel) Date: Fri, 22 Sep 2006 08:40:21 -0700 Subject: [erlang-questions] Proxy authentication with inets In-Reply-To: References: Message-ID: <20060922154021.GP5745@delora.autosys.us> On Fri, Sep 22, 2006 at 04:10:03PM +0100, Chandru wrote: > On 22/09/06, Dmitrii Dimandt wrote: > > Documentation show that http:set_options/1 allows only the following for > proxy: > > {proxy, {HostName, Port}} where HostName = string(), Port = integer(). > > How can I force inets into accepting a username and a password for the > proxy as well? If it is at all possible, of course. > > > ibrowse supports proxy authentication. > > cheers > Chandru _______________________________________________ Chandru, do you think ibrowse will get included with Erlang distribution ? ~M From ulf@REDACTED Fri Sep 22 19:09:44 2006 From: ulf@REDACTED (Ulf Wiger) Date: Fri, 22 Sep 2006 19:09:44 +0200 (CEST) Subject: [erlang-questions] new gen_leader in jungerl Message-ID: <34973.81.233.251.65.1158944984.squirrel@webmail.wiger.net> I have checked in the new gen_leader in jungerl. The interface is the same, but the leader election algorithm is new. The new gen_leader will not be able to coexist with the old one. For more info about the "bug fix", see http://www.cs.chalmers.se/~hanssv/leader_election/ This version of gen_leader has been tested with model checking, abstract traces and quickcheck. If you still find a bug, ask Hans Svensson and Thomas Arts to buy you all the beer you can drink. ;-) (It's possible, however unlikely, that I introduced some bug when editing gen_leader.erl to eliminate compiler warnings and to reformat lines longer than 80 chars. If so, _I_ will buy the one who finds it a beer.) BR, Ulf W From jefcrane@REDACTED Fri Sep 22 19:12:15 2006 From: jefcrane@REDACTED (Jeff Crane) Date: Fri, 22 Sep 2006 10:12:15 -0700 (PDT) Subject: [erlang-questions] Where is an ets guide? In-Reply-To: <6a36e7290609211621k2f6409d1n2f96a70bc251abb5@mail.gmail.com> Message-ID: <20060922171215.25794.qmail@web31610.mail.mud.yahoo.com> > > ets:new(mytable,[]). > > 16 % that's a tid! > > Identifiers are supposed to be opaque.. just like > the internal > representation of dict, etc. I dont know anything about dict. that doesnt help me understand what mytable is for. > > ets:insert(mytable,{1,"first"}). > > % Nope...wtf? > > mytable isn't the Tid, and you didn't ask for a > named table. What are you talking about? I made a table with a name atom of mytable, what is that other than the table name? > > MyTable2 = ets:new(mytable2,[]). > > 19 % that's a tid! > > > > ets:insert(MyTable2,{2,"second"}). > > % true? Um, I'm lost. > > How lost could you be? > > What's the point of the name atom? What's the point of the name atom? You didn't answer the question, of course I'm lost. Why is MyTable2 the table reference, when mytable2 should be the correct reference? What's the point of mytable2 if it's not the named reference? Sheesh. > It helps to read *all* of the docs for a function. > There's a > named_table option, which lets you specify the Tid > as an atom: > > * named_table If this option is present, the name > Name is associated > with the table identifier. The name can then be used > instead of the > table identifier in subsequent operations. > The docs are pretty sufficient, if you read them. > > -bob I have read them. They aren't sufficient, when you're not already vetted in erlang. It's too bad you are unable to see it. Again, someone needs to present a decent ets guide. __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From ulf.wiger@REDACTED Fri Sep 22 19:52:39 2006 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Fri, 22 Sep 2006 19:52:39 +0200 Subject: [erlang-questions] Where is an ets guide? In-Reply-To: <20060922171215.25794.qmail@web31610.mail.mud.yahoo.com> Message-ID: Jeff Crane wrote: > Sent: den 22 september 2006 19:12 > To: erlang-questions@REDACTED > Subject: Re: [erlang-questions] Where is an ets guide? > > > > ets:new(mytable,[]). > > > 16 % that's a tid! > > > > Identifiers are supposed to be opaque.. just like the internal > > representation of dict, etc. > > I dont know anything about dict. that doesnt help me > understand what mytable is for. >From the ets reference manual (http://www.erlang.org/doc/doc-5.5/lib/stdlib-1.14/doc/html/ets.html) "new(Name, Options) -> tid() Types: Name = atom() Options = [Option] Option = Type | Access | named_table | {keypos,Pos} Type = set | ordered_set | bag | duplicate_bag Access = public | protected | private Pos = int()" In other words, the first argument is a name. Among the options is named_table. It is described thus: "named_table If this option is present, the name Name is associated with the table identifier. The name can then be used instead of the table identifier in subsequent operations." The reference manual doesn't explicitly state that Name per default _cannot_ be used to address the table. It might perhaps be helpful to add a paragraph in the introduction explaining the concept of named and "unnamed" tables. > > > ets:insert(mytable,{1,"first"}). > > > % Nope...wtf? > > > > mytable isn't the Tid, and you didn't ask for a named table. > > What are you talking about? I made a table with a name atom > of mytable, what is that other than the table name? If you haven't specified the named_table option, the name serves only as documentation. You can create several tables with the same name, as long as at most one of them has the 'named_table' option. > > > MyTable2 = ets:new(mytable2,[]). > > > 19 % that's a tid! > > > > > > ets:insert(MyTable2,{2,"second"}). > > > % true? Um, I'm lost. > > > > How lost could you be? > > > What's the point of the name atom? > What's the point of the name atom? > You didn't answer the question, of course I'm lost. > > Why is MyTable2 the table reference, when mytable2 should be > the correct reference? What's the point of > mytable2 if it's not the named reference? Sheesh. You can always use the table identifier to address the table. You can only use the name if you created the table with the 'named_table' option. > Again, someone needs to present a decent ets guide. You may be right. Ets is a pretty important module, and it has lots of functions that may elude even fairly experienced erlang programmers. BR, Ulf W From bob@REDACTED Fri Sep 22 19:58:50 2006 From: bob@REDACTED (Bob Ippolito) Date: Fri, 22 Sep 2006 10:58:50 -0700 Subject: [erlang-questions] Where is an ets guide? In-Reply-To: <20060922171215.25794.qmail@web31610.mail.mud.yahoo.com> References: <6a36e7290609211621k2f6409d1n2f96a70bc251abb5@mail.gmail.com> <20060922171215.25794.qmail@web31610.mail.mud.yahoo.com> Message-ID: <6a36e7290609221058r64f1fd72k307aecee5d2b2f67@mail.gmail.com> On 9/22/06, Jeff Crane wrote: > > > ets:new(mytable,[]). > > > 16 % that's a tid! > > > > Identifiers are supposed to be opaque.. just like > > the internal > > representation of dict, etc. > > I dont know anything about dict. that doesnt help me > understand what mytable is for. It has nothing to do with dict specifically. Table identifiers are opaque. You don't care what they look like, just like you shouldn't care what the internal representation of a record is or the internal representation of a dict or anything else. Just cause it happens to be an integer doesn't mean anything. > > > ets:insert(mytable,{1,"first"}). > > > % Nope...wtf? > > > > mytable isn't the Tid, and you didn't ask for a > > named table. > > What are you talking about? I made a table with a name > atom of mytable, what is that other than the table > name? It doesn't have a name because you didn't use the named_table option. Did you read the reply I sent? > > > MyTable2 = ets:new(mytable2,[]). > > > 19 % that's a tid! > > > > > > ets:insert(MyTable2,{2,"second"}). > > > % true? Um, I'm lost. > > > > How lost could you be? > > > What's the point of the name atom? > What's the point of the name atom? > You didn't answer the question, of course I'm lost. > > Why is MyTable2 the table reference, when mytable2 > should be the correct reference? What's the point of > mytable2 if it's not the named reference? Sheesh. I specifically pointed you to the named_table option, which gives tables a name. If you don't specify the named_table option, the name you give it is completely ignored and you have to use the tid. MyTable2 is a reference to the tid. > > It helps to read *all* of the docs for a function. > > There's a > > named_table option, which lets you specify the Tid > > as an atom: > > > > * named_table If this option is present, the name > > Name is associated > > with the table identifier. The name can then be used > > instead of the > > table identifier in subsequent operations. Why didn't you read this part of the reply? -bob From sean.hinde@REDACTED Fri Sep 22 20:00:33 2006 From: sean.hinde@REDACTED (Sean Hinde) Date: Fri, 22 Sep 2006 19:00:33 +0100 Subject: [erlang-questions] Where is an ets guide? In-Reply-To: <20060922171215.25794.qmail@web31610.mail.mud.yahoo.com> References: <20060922171215.25794.qmail@web31610.mail.mud.yahoo.com> Message-ID: <90DE8894-ADE1-4C03-AD03-2BD70D64B0AC@gmail.com> On 22 Sep 2006, at 18:12, Jeff Crane wrote: >>> ets:new(mytable,[]). >>> 16 % that's a tid! >> >> Identifiers are supposed to be opaque.. just like >> the internal >> representation of dict, etc. > > I dont know anything about dict. that doesnt help me > understand what mytable is for. That is the point - you don't need to know. > >>> ets:insert(mytable,{1,"first"}). >>> % Nope...wtf? >> >> mytable isn't the Tid, and you didn't ask for a >> named table. > > What are you talking about? I made a table with a name > atom of mytable, what is that other than the table > name? Actually you didn't. In order to get a globally named table you have to provide the option named_table. This is described under that option in the documentation. > >>> MyTable2 = ets:new(mytable2,[]). >>> 19 % that's a tid! >>> >>> ets:insert(MyTable2,{2,"second"}). >>> % true? Um, I'm lost. >> >> How lost could you be? >>> What's the point of the name atom? > What's the point of the name atom? > You didn't answer the question, of course I'm lost. > > Why is MyTable2 the table reference, when mytable2 > should be the correct reference? What's the point of > mytable2 if it's not the named reference? Sheesh. The point of the name atom is also a bit unclear to me I have to say. It is a bit useless unless the named table option is also given. It appears in some debug printouts somewhere. MyTable2 is the reference because of what the documentation for ets:new/2 says in the first line: "Creates a new table and returns a table identifier which can be used in subsequent operations" To get much further in your erlang studies you must understand the difference between a variable and an atom (Hint: Variables start with upper case letters). Your line of code has assigned the return value from the ets:new/2 function to the Variable MyTable2. MyTable2 holds the reference. > >> It helps to read *all* of the docs for a function. >> There's a >> named_table option, which lets you specify the Tid >> as an atom: >> >> * named_table If this option is present, the name >> Name is associated >> with the table identifier. The name can then be used >> instead of the >> table identifier in subsequent operations. > >> The docs are pretty sufficient, if you read them. >> >> -bob > > I have read them. They aren't sufficient, when you're > not already vetted in erlang. It's too bad you are > unable to see it. > > Again, someone needs to present a decent ets guide. The ets manual is actually very good. What it is not is a beginners guide to Erlang. It assumes you have some basic understanding of the language - it is a reference after all. Might I suggest a little more study of the language is in order at this point. Sean From dmitriid@REDACTED Sat Sep 23 13:31:45 2006 From: dmitriid@REDACTED (Dmitrii Dimandt) Date: Sat, 23 Sep 2006 14:31:45 +0300 Subject: [erlang-questions] erlsoap-0.4.1 In-Reply-To: References: Message-ID: On 9/22/06, Dmitrii Dimandt wrote: > > Hi all, > > I'm not sure if anyone noticed, but Anton Fedorov has released version 0.4and (after quite a lot of misunderstandings about and misgivings of a > particular webservice) version 0.4.1 of erlsoap. > > The new version can be downloaded and discussed here: > http://forum.trapexit.org/viewtopic.php?p=21614 Hi. I've patched erlsoap somewhat. http://forum.trapexit.org/viewtopic.php?p=21672#21672 -------------- next part -------------- An HTML attachment was scrubbed... URL: From nm@REDACTED Sat Sep 23 17:27:05 2006 From: nm@REDACTED (Gaspar Chilingarov) Date: Sat, 23 Sep 2006 20:27:05 +0500 Subject: [erlang-questions] Vim and Erlang syntax files update [2006-09-23] Message-ID: <45155249.6050607@web.am> Hi folks! New syntax/erlang support package is ready. In brief -- a lot of code stolen from distel :) In details: Omni-completion improved. Record name completion, local functions name, macros name completion. If you download and patch your vim to have erlang integration (UNIX only yet) you will get much more smart autocompletion: module names, external function names, their arguments and arity, record names, record field names, macros completion. Also ability to reload modules from vim. More functions coming :) Check this link: http://www.zanazan.am/vim/ for update page. Direct links to syntax files: Syntax files http://zanazan.am/vim/erlang-vim-syntax-2006sep23.tar.bz2 (read README.erl_interface.txt for new functinality) Vim-erlang integration patch & patching instructions. http://zanazan.am/vim/vim-erl_interface-sep23.tgz http://zanazan.am/vim/get_vim.txt A few bugs are improved. It works good in console and graphical interface now. -- Gaspar Chilingarov System Administrator, Network security consulting t +37493 419763 (mob) i 63174784 e nm@REDACTED From ml.cyresse@REDACTED Sun Sep 24 03:48:18 2006 From: ml.cyresse@REDACTED (Liam Clarke) Date: Sun, 24 Sep 2006 13:48:18 +1200 Subject: [erlang-questions] Sockets and linking processes Message-ID: Hi all, I have two processes (A and B to be totally original) - process B handles a socket, based on messages from A. A parses data received from B and responds accordingly. I've linked A and B, but what I'm wondering is if A fails, which will kill B also, if B's socket is still open, will it close it gracefully or will it leave the remote end hanging? If so, is there a way I can handle the exit signal so as to close the socket without making B a system process? I still want B to exit with A, just that I want B to tidy up before it does. Regards, Liam Clarke PS - I'm up to Chapter 3 of Mr Armstrong's thesis - whoever said it was the best introduction to Erlang is right. It's good to see the _why_ of certain implementation decisions, as it helps in comprehending the _how_. And, as far as dissertations that I've read go, it's the most readable by far, so kudos to Mr Armstrong for avoiding the sirens of academic short hand. From fritchie@REDACTED Sun Sep 24 08:34:40 2006 From: fritchie@REDACTED (Scott Lystig Fritchie) Date: Sun, 24 Sep 2006 01:34:40 -0500 Subject: [erlang-questions] Sockets and linking processes In-Reply-To: Message of "Sun, 24 Sep 2006 13:48:18 +1200." Message-ID: <200609240634.k8O6YemN042271@snookles.snookles.com> >>>>> "lc" == Liam Clarke writes: lc> I've linked A and B, but what I'm wondering is if A fails, which lc> will kill B also, if B's socket is still open, will it close it lc> gracefully or will it leave the remote end hanging? All driver ports owned by a process are automatically closed when the owning process exits. Gen_tcp and gen_udp use driver ports, too, so yes, B's sockets will be closed when B dies. -Scott From ml.cyresse@REDACTED Sun Sep 24 11:35:28 2006 From: ml.cyresse@REDACTED (Liam Clarke) Date: Sun, 24 Sep 2006 21:35:28 +1200 Subject: [erlang-questions] Sockets and linking processes In-Reply-To: <200609240634.k8O6YemN042271@snookles.snookles.com> References: <200609240634.k8O6YemN042271@snookles.snookles.com> Message-ID: Thanks to you both, that makes my error handling a lot easier. Regards, Liam Clarke On 9/24/06, Scott Lystig Fritchie wrote: > >>>>> "lc" == Liam Clarke writes: > > lc> I've linked A and B, but what I'm wondering is if A fails, which > lc> will kill B also, if B's socket is still open, will it close it > lc> gracefully or will it leave the remote end hanging? > > All driver ports owned by a process are automatically closed when the > owning process exits. Gen_tcp and gen_udp use driver ports, too, so > yes, B's sockets will be closed when B dies. > > -Scott > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From mickael.remond@REDACTED Sun Sep 24 14:33:56 2006 From: mickael.remond@REDACTED (Mickael Remond) Date: Sun, 24 Sep 2006 14:33:56 +0200 Subject: [erlang-questions] measuring OS context switches In-Reply-To: <3CD23375-2875-4928-80A7-A83094F8E8BF@redstarling.com> References: <3CD23375-2875-4928-80A7-A83094F8E8BF@redstarling.com> Message-ID: <20060924123356.GA7100@memphis> Hello, * ke han [2006-09-20 14:03:34 +0800]: > Can anyone give ideas for how to go about measuring such things?? To compare several version of the application, I would write a realistic Tsung benchmark, with several interesting scenarii. The end result of the Tsung can be found here: http://www.process-one.net/en/projects/tsung/ Its main strength is that it make it possible to generate very realistic benchmark that can show the behaviour of the application in a near to real life situation. I hope this helps, -- Micka?l R?mond http://www.process-one.net/ From jay@REDACTED Sun Sep 24 18:05:48 2006 From: jay@REDACTED (Jay Nelson) Date: Sun, 24 Sep 2006 09:05:48 -0700 Subject: [erlang-questions] F# and Nemerle Message-ID: <4516ACDC.5080900@duomark.com> Anyone had experience using either of these languages on .NET with Visual Studio? How about on mono? Are they stable enough for real work? Did you find any advantages or disadvantages in using them? jay From chandrashekhar.mullaparthi@REDACTED Mon Sep 25 10:30:45 2006 From: chandrashekhar.mullaparthi@REDACTED (Chandru) Date: Mon, 25 Sep 2006 09:30:45 +0100 Subject: [erlang-questions] Proxy authentication with inets In-Reply-To: <20060922154021.GP5745@delora.autosys.us> References: <20060922154021.GP5745@delora.autosys.us> Message-ID: On 22/09/06, Michael McDaniel wrote: > > On Fri, Sep 22, 2006 at 04:10:03PM +0100, Chandru wrote: > > On 22/09/06, Dmitrii Dimandt wrote: > > > > Documentation show that http:set_options/1 allows only the following > for > > proxy: > > > > {proxy, {HostName, Port}} where HostName = string(), Port = > integer(). > > > > How can I force inets into accepting a username and a password for > the > > proxy as well? If it is at all possible, of course. > > > > > > ibrowse supports proxy authentication. > > > > cheers > > Chandru > _______________________________________________ > > Chandru, do you think ibrowse will get included with Erlang > distribution ? Don't know. I think this question was asked before and the answer from the OTP team was "no". Chandru -------------- next part -------------- An HTML attachment was scrubbed... URL: From ke.han@REDACTED Mon Sep 25 10:35:47 2006 From: ke.han@REDACTED (ke han) Date: Mon, 25 Sep 2006 16:35:47 +0800 Subject: [erlang-questions] very large key lookup Message-ID: <549CAB49-2C65-4B0D-BC20-E7BDF31CC630@redstarling.com> I am providing software architecture advice to a company and have pointed them towards erlang in building their custom server. The server basically does one thing: take in a 32 byte key from client sockets and lookup for a match against an internal key table. If a match is found, it checks against the matched key's 128 byte key for secondary false-positive elimination. Sorry I can't provide the context of this app as the company is in stealth mode at the moment. Hopefully they will be a proud erlang supporter once they launch this in a few months. We will have hundreds of millions of these 32 byte keys in the the server's "DB" and each key's associated 128 byte key. I am looking for advice on the format for these keys along with which libraries to use for balance between memory and lookup performance. The current format is 0-9 + a-z character strings. We can change this since the lookup tables and the input from clients does not need to be human readable. thanks, ke han From ulf.wiger@REDACTED Mon Sep 25 12:12:13 2006 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Mon, 25 Sep 2006 12:12:13 +0200 Subject: [erlang-questions] very large key lookup In-Reply-To: <549CAB49-2C65-4B0D-BC20-E7BDF31CC630@redstarling.com> Message-ID: It sounds like a candidate for (a) 64-bit erlang, and (b) binary keys. (: ... but I fail to find how to efficiently match binaries in a match spec. This is a shame. BR, Ulf W > -----Original Message----- > From: erlang-questions-bounces@REDACTED > [mailto:erlang-questions-bounces@REDACTED] On Behalf Of ke han > Sent: den 25 september 2006 10:36 > To: Erlang/OTP discussions > Subject: [erlang-questions] very large key lookup > > I am providing software architecture advice to a company and > have pointed them towards erlang in building their custom server. > The server basically does one thing: take in a 32 byte key from > client sockets and lookup for a match against an internal key > table. > If a match is found, it checks against the matched key's 128 > byte key for secondary false-positive elimination. Sorry I > can't provide the > context of this app as the company is in stealth mode at the > moment. > Hopefully they will be a proud erlang supporter once they > launch this in a few months. > We will have hundreds of millions of these 32 byte keys in > the the server's "DB" and each key's associated 128 byte key. > I am looking for advice on the format for these keys along > with which > libraries to use for balance between memory and lookup > performance. > The current format is 0-9 + a-z character strings. We can > change this since the lookup tables and the input from > clients does not need to be human readable. > thanks, ke han > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From ke.han@REDACTED Mon Sep 25 13:26:52 2006 From: ke.han@REDACTED (ke han) Date: Mon, 25 Sep 2006 19:26:52 +0800 Subject: [erlang-questions] erlang in China Message-ID: <67B7A7B4-9569-42A2-818A-37A243994666@redstarling.com> FYI, we are seeing some growth for erlang in China. See the new google group. http://groups.google.com/group/erlang- china/browse_frm/thread/808ea8ce103221c6/e1213ef61015a580% 23e1213ef61015a580 I don't know who started this group, so there is more uptake than I have my hands around. I know of one Beijing company, two Shanghai companies and one Hangzhou company doing erlang work (real internal R&D not outsourced IT), This past Sunday, I gave a talk at barCamp Shanghai barcampshanghai.org. My topic was comparing software architecture tradeoffs. We talked about java and ruby based webapps in comparison to erlang. There were about 40 persons at the presentation. regards, ke han From gunilla@REDACTED Mon Sep 25 14:29:13 2006 From: gunilla@REDACTED (Gunilla Arendt) Date: Mon, 25 Sep 2006 14:29:13 +0200 Subject: [erlang-questions] os_mon memsup reporting memory consumption In-Reply-To: <44F478E4.4050905@hq.idt.net> References: <44F478E4.4050905@hq.idt.net> Message-ID: <4517CB99.9040605@erix.ericsson.se> Hi I see the point, but it would be a non-backward compatible change and as you know we're very hesitant about those. An alternative solution could be to add a new tag to the result of memsup:get_system_memory_data() for Linux systems, although that would not affect the setting/clearing of alarms. If anybody else has thoughts about this, please feel free to share. Regards, Gunilla, Erlang/OTP team Serge Aleynikov wrote: > We had a few high memory watermark alarms in a production system running > Linux reported by OS_MON whereas it seemed like the memory utilization > on the server wasn't bad. I looked at the implementation of the > memsup.erl module in OS_MON, and I believe the calculation of allocated > memory has a flow. > > Memsup's code (sited at the end) reveals that allocated memory doesn't > take in consideration cached memory. Since cached memory can be quickly > freed by the Linux memory manager if additional memory is needed by > applications, it looks to me that it should be: > > Allocated = MemTotal - (MemFree + Cached) > > or even: > > Allocated = MemTotal - (MemFree + Buffers + Cached) > > This would be consistent with what "free" is showing on the "-/+ > buffers/cache" line: > > drp@REDACTED: ~$ uname -a > Linux drpdb02.corp.idt.net 2.6.9-5.ELsmp #1 SMP Wed Jan 5 19:30:39 EST > 2005 i686 i686 i386 GNU/Linux > > drp@REDACTED: ~$ free > total used free shared buffers cached > Mem: 4150324 3416788 733536 0 282412 2621788 > -/+ buffers/cache: 512588 3637736 > Swap: 2048248 0 2048248 > > drp@REDACTED: ~$ head -4 /proc/meminfo > MemTotal: 4150324 kB > MemFree: 733536 kB > Buffers: 282412 kB > Cached: 2621788 kB > > > > %------------------------- > %% @spec get_memory_usage_linux() -> {Allocated, Total} > %------------------------- > get_memory_usage_linux() -> > Res = os:cmd("cat /proc/meminfo"), > case get_memory_usage_linux(Res, undef, undef) of > {MemTotal, MemFree} -> > {MemTotal-MemFree, MemTotal}; > error -> > timer:sleep(1000), > get_memory_usage_linux() > end. > > get_memory_usage_linux(_Str, Tot, Free) when is_integer(Tot), > is_integer(Free) -> > {Tot, Free}; > get_memory_usage_linux("MemTotal:"++T, _Tot0, Free0) -> > {ok, [N], Rest} = io_lib:fread("~d", T), > Tot = N*1024, > get_memory_usage_linux(skip_to_eol(Rest), Tot, Free0); > get_memory_usage_linux("MemFree:"++T, Tot0, _Free0) -> > {ok, [N], Rest} = io_lib:fread("~d", T), > Free = N*1024, > get_memory_usage_linux(skip_to_eol(Rest), Tot0, Free); > get_memory_usage_linux("", _Tot0, _Free0) -> > error; > get_memory_usage_linux(Str, Tot0, Free0) -> > get_memory_usage_linux(skip_to_eol(Str), Tot0, Free0). > %------------------------- > > Regards, > > Serge > From ulf.wiger@REDACTED Mon Sep 25 14:52:06 2006 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Mon, 25 Sep 2006 14:52:06 +0200 Subject: [erlang-questions] very large key lookup In-Reply-To: <4B19ED40-3118-4A5B-AC19-06629575101D@mac.com> Message-ID: > -----Original Message----- > From: Jon Hancock [mailto:ke.han@REDACTED] > Sent: den 25 september 2006 13:29 > To: Ulf Wiger (TN/EAB) > Cc: Erlang/OTP discussions > Subject: Re: [erlang-questions] very large key lookup > > The largest integer value in 64-bit erlang is what? 2^64? or > does erlang have some tricks for larger than this? I tried > to look up this info but can't seem to find it. > Any ideas on which tree or hash table to use for lookups? > thanks, ke han For hundreds of million keys, you might want to go with a mnesia cluster. See the mnesia User Manual on fragmented tables. http://www.erlang.org/doc/doc-5.5/lib/mnesia-4.3.1/doc/html/Mnesia_chap5 .html#5.3 (You can start with a non-fragmented table and grow into a fragmented one.) There is also some sample code in mnesia-xxxx/examples/bench/ That code actually implements a model of a HLR (Home Location Register) which is the subscriber database of a mobile phone network. It does subscriber management/lookup based on primary key access. Whether the key is of type binary or other doesn't matter. The application scales very well when more processors are added, and the problem lends itself perfectly to a cluster database. The 'bench' code uses several tricks, such as sticky locks. If you can work your way through that small application, I think you will have a good starting point for writing a very scalable application based on mnesia. BR, Ulf W From yarivvv@REDACTED Mon Sep 25 15:49:23 2006 From: yarivvv@REDACTED (Yariv Sadan) Date: Mon, 25 Sep 2006 09:49:23 -0400 Subject: [erlang-questions] erlang in China In-Reply-To: <67B7A7B4-9569-42A2-818A-37A243994666@redstarling.com> References: <67B7A7B4-9569-42A2-818A-37A243994666@redstarling.com> Message-ID: <17244f480609250649m106aa287xcd3a43024594e2f3@mail.gmail.com> Hi, According to the latest Google Analytics report for the last 500 visits to my blog, China is ranked 3rd in number of visitors after the US and UK. Here's the latest top ten: US 591 visits UK 109 China 92 France 81 Russia 66 Germany 60 Canada 57 Sweden 57 Denmark 55 Brazil 41 Regards, Yariv On 9/25/06, ke han wrote: > FYI, we are seeing some growth for erlang in China. > See the new google group. http://groups.google.com/group/erlang- > china/browse_frm/thread/808ea8ce103221c6/e1213ef61015a580% > 23e1213ef61015a580 > I don't know who started this group, so there is more uptake than I > have my hands around. > > I know of one Beijing company, two Shanghai companies and one > Hangzhou company doing erlang work (real internal R&D not outsourced > IT), > > This past Sunday, I gave a talk at barCamp Shanghai > barcampshanghai.org. My topic was comparing software architecture > tradeoffs. We talked about java and ruby based webapps in comparison > to erlang. There were about 40 persons at the presentation. > > regards, > ke han > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From yarivvv@REDACTED Mon Sep 25 15:51:00 2006 From: yarivvv@REDACTED (Yariv Sadan) Date: Mon, 25 Sep 2006 09:51:00 -0400 Subject: [erlang-questions] erlang in China In-Reply-To: <17244f480609250649m106aa287xcd3a43024594e2f3@mail.gmail.com> References: <67B7A7B4-9569-42A2-818A-37A243994666@redstarling.com> <17244f480609250649m106aa287xcd3a43024594e2f3@mail.gmail.com> Message-ID: <17244f480609250651u174e27f7haa3068fe9baca7fa@mail.gmail.com> > According to the latest Google Analytics report for the last 500 > visits to my blog, China is ranked 3rd in number of visitors after the > US and UK. Correction: obviously it's not 500 visits for this report :) From ke.han@REDACTED Mon Sep 25 16:25:14 2006 From: ke.han@REDACTED (ke han) Date: Mon, 25 Sep 2006 22:25:14 +0800 Subject: [erlang-questions] erlang in China In-Reply-To: <17244f480609250649m106aa287xcd3a43024594e2f3@mail.gmail.com> References: <67B7A7B4-9569-42A2-818A-37A243994666@redstarling.com> <17244f480609250649m106aa287xcd3a43024594e2f3@mail.gmail.com> Message-ID: <58E5D64B-E7C5-460B-AB89-159AB76103CD@redstarling.com> nice stats!!! I'm trying to spread the good word in China...apps that serve China really need concurrency....everything here is about high volume, low margins. I always point newcomers to the best docs to start with so as to hopefully minimize the newbie impact on this maililist. only time will tell ;-) ke han On Sep 25, 2006, at 9:49 PM, Yariv Sadan wrote: > Hi, > > According to the latest Google Analytics report for the last 500 > visits to my blog, China is ranked 3rd in number of visitors after the > US and UK. > > Here's the latest top ten: > > US 591 visits > UK 109 > China 92 > France 81 > Russia 66 > Germany 60 > Canada 57 > Sweden 57 > Denmark 55 > Brazil 41 > > Regards, > Yariv > > On 9/25/06, ke han wrote: >> FYI, we are seeing some growth for erlang in China. >> See the new google group. http://groups.google.com/group/erlang- >> china/browse_frm/thread/808ea8ce103221c6/e1213ef61015a580% >> 23e1213ef61015a580 >> I don't know who started this group, so there is more uptake than I >> have my hands around. >> >> I know of one Beijing company, two Shanghai companies and one >> Hangzhou company doing erlang work (real internal R&D not outsourced >> IT), >> >> This past Sunday, I gave a talk at barCamp Shanghai >> barcampshanghai.org. My topic was comparing software architecture >> tradeoffs. We talked about java and ruby based webapps in comparison >> to erlang. There were about 40 persons at the presentation. >> >> regards, >> ke han >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> From serge@REDACTED Mon Sep 25 16:51:48 2006 From: serge@REDACTED (Serge Aleynikov) Date: Mon, 25 Sep 2006 10:51:48 -0400 Subject: [erlang-questions] os_mon memsup reporting memory consumption In-Reply-To: <4517CB99.9040605@erix.ericsson.se> References: <44F478E4.4050905@hq.idt.net> <4517CB99.9040605@erix.ericsson.se> Message-ID: <4517ED04.5030907@hq.idt.net> Hi Gunilla, Gunilla Arendt wrote: > I see the point, but it would be a non-backward compatible change > and as you know we're very hesitant about those. I would imagine that if anyone used OS_MON & SASL on Linux in production they would quickly run into this issue, and if so, there would be some posts about it. Also, if this fix was available in a future version of OTP with appropriate compatibility note, I would assume that any user who would want to upgrade a production system from a prior OTP release to that one would read the compatibility notes... The only impact I would think of would be that if a production system running on Linux had the OS_MON's system_memory_high_watermark option set to something higher than default (say 95%) to compensate for false positive alarm behavior (when in reality memory consumption might be 50%), introduction of this fix without modifying the system_memory_high_watermark environment could potentially produce an alarm when the system's memory consumption is indeed at 95% that may be a too severe threshold for the system. I don't know what others on the list feel about this oddity, but setting an option to 95% in hope that it would indicate a 50% threshold is confusing to say the least. > An alternative solution could be to add a new tag to the result of > memsup:get_system_memory_data() for Linux systems, although that would > not affect the setting/clearing of alarms. I believe the real benefit of OS_MON comes when it produces meaningful O&M alarms. If it doesn't the value of the app diminishes by quite a bit. Regards, Serge > Serge Aleynikov wrote: >> We had a few high memory watermark alarms in a production system running >> Linux reported by OS_MON whereas it seemed like the memory utilization >> on the server wasn't bad. I looked at the implementation of the >> memsup.erl module in OS_MON, and I believe the calculation of allocated >> memory has a flow. >> >> Memsup's code (sited at the end) reveals that allocated memory doesn't >> take in consideration cached memory. Since cached memory can be quickly >> freed by the Linux memory manager if additional memory is needed by >> applications, it looks to me that it should be: >> >> Allocated = MemTotal - (MemFree + Cached) >> >> or even: >> >> Allocated = MemTotal - (MemFree + Buffers + Cached) >> >> This would be consistent with what "free" is showing on the "-/+ >> buffers/cache" line: >> >> drp@REDACTED: ~$ uname -a >> Linux drpdb02.corp.idt.net 2.6.9-5.ELsmp #1 SMP Wed Jan 5 19:30:39 EST >> 2005 i686 i686 i386 GNU/Linux >> >> drp@REDACTED: ~$ free >> total used free shared buffers cached >> Mem: 4150324 3416788 733536 0 282412 2621788 >> -/+ buffers/cache: 512588 3637736 >> Swap: 2048248 0 2048248 >> >> drp@REDACTED: ~$ head -4 /proc/meminfo >> MemTotal: 4150324 kB >> MemFree: 733536 kB >> Buffers: 282412 kB >> Cached: 2621788 kB >> >> >> >> %------------------------- >> %% @spec get_memory_usage_linux() -> {Allocated, Total} >> %------------------------- >> get_memory_usage_linux() -> >> Res = os:cmd("cat /proc/meminfo"), >> case get_memory_usage_linux(Res, undef, undef) of >> {MemTotal, MemFree} -> >> {MemTotal-MemFree, MemTotal}; >> error -> >> timer:sleep(1000), >> get_memory_usage_linux() >> end. >> >> get_memory_usage_linux(_Str, Tot, Free) when is_integer(Tot), >> is_integer(Free) -> >> {Tot, Free}; >> get_memory_usage_linux("MemTotal:"++T, _Tot0, Free0) -> >> {ok, [N], Rest} = io_lib:fread("~d", T), >> Tot = N*1024, >> get_memory_usage_linux(skip_to_eol(Rest), Tot, Free0); >> get_memory_usage_linux("MemFree:"++T, Tot0, _Free0) -> >> {ok, [N], Rest} = io_lib:fread("~d", T), >> Free = N*1024, >> get_memory_usage_linux(skip_to_eol(Rest), Tot0, Free); >> get_memory_usage_linux("", _Tot0, _Free0) -> >> error; >> get_memory_usage_linux(Str, Tot0, Free0) -> >> get_memory_usage_linux(skip_to_eol(Str), Tot0, Free0). >> %------------------------- >> >> Regards, >> >> Serge >> > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- Serge Aleynikov R&D Telecom, MIS, IDT Corp Tel: +1 (973) 438-3436 Fax: +1 (973) 438-1464 From dmitriid@REDACTED Mon Sep 25 17:08:59 2006 From: dmitriid@REDACTED (Dmitrii Dimandt) Date: Mon, 25 Sep 2006 18:08:59 +0300 Subject: [erlang-questions] erlang in China In-Reply-To: <17244f480609250649m106aa287xcd3a43024594e2f3@mail.gmail.com> References: <67B7A7B4-9569-42A2-818A-37A243994666@redstarling.com> <17244f480609250649m106aa287xcd3a43024594e2f3@mail.gmail.com> Message-ID: > > > According to the latest Google Analytics report for the last 500 > visits to my blog, China is ranked 3rd in number of visitors after the > US and UK. > > Here's the latest top ten: > > US 591 visits > UK 109 > China 92 > France 81 > Russia 66 It's nice to see Russia hanging in there :) -------------- next part -------------- An HTML attachment was scrubbed... URL: From ft@REDACTED Mon Sep 25 17:23:14 2006 From: ft@REDACTED (Fredrik Thulin) Date: Mon, 25 Sep 2006 17:23:14 +0200 Subject: [erlang-questions] erlang in China In-Reply-To: References: <67B7A7B4-9569-42A2-818A-37A243994666@redstarling.com> <17244f480609250649m106aa287xcd3a43024594e2f3@mail.gmail.com> Message-ID: <200609251723.14133.ft@it.su.se> On Monday 25 September 2006 17:08, Dmitrii Dimandt wrote: > > According to the latest Google Analytics report for the last 500 > > visits to my blog, China is ranked 3rd in number of visitors after > > the US and UK. > > > > Here's the latest top ten: > > > > US 591 visits > > UK 109 > > China 92 > > France 81 > > Russia 66 > > It's nice to see Russia hanging in there :) Is it just me or doesn't this list look remarkably much like the UN security council permanent members list? Hmmm, Erlang must be closer to world domination than we thought ;). /Fredrik From nicolas@REDACTED Mon Sep 25 17:32:04 2006 From: nicolas@REDACTED (Nicolas Niclausse) Date: Mon, 25 Sep 2006 17:32:04 +0200 Subject: [erlang-questions] os_mon memsup reporting memory consumption In-Reply-To: <4517CB99.9040605@erix.ericsson.se> References: <44F478E4.4050905@hq.idt.net> <4517CB99.9040605@erix.ericsson.se> Message-ID: <4517F674.10701@niclux.org> Gunilla Arendt ecrivait le 25.09.2006 14:29: > Hi > > I see the point, but it would be a non-backward compatible change > and as you know we're very hesitant about those. > > An alternative solution could be to add a new tag to the result of > memsup:get_system_memory_data() for Linux systems, although that would > not affect the setting/clearing of alarms. > > If anybody else has thoughts about this, please feel free to share. Hello, I agree with Serge; in the current implementation, memsup is useless on Linux. I vote for a non-backward compatible change (I already ask for this 2 years ago, but got no reponse) -- Nicolas Niclausse From yarivvv@REDACTED Mon Sep 25 18:36:25 2006 From: yarivvv@REDACTED (Yariv Sadan) Date: Mon, 25 Sep 2006 12:36:25 -0400 Subject: [erlang-questions] MySQL driver update Message-ID: <17244f480609250936y5451aea3l457a8a77f46730d8@mail.gmail.com> Hi, I simplified the MySQL transaction API to look like that of Mnesia. I also made a bunch of other improvements. Here's an example: mysql:prepare(insert_developer, <<"INSERT INTO person(name) VALUES (?)">>), mysql:transaction(conn_pool, fun() -> mysql:execute(insert_developer, ["Bob"]), {data, Res} = mysql:fetch(<<"SELECT last_insert_id()">>), [[Id]] = mysql:get_result_rows(Res), mysql:fetch( [<<"UPDATE person SET name='Jane' WHERE id=">>, integer_to_list(Id)]) end). The full story is here: http://yarivsblog.com/articles/2006/09/25/mnesia-mysql-its-the-same-transaction. You can get the latest version of the driver in brachers/v0.9. The old version is in branches/v0.8. Best regards, Yariv From erlangX@REDACTED Mon Sep 25 21:57:38 2006 From: erlangX@REDACTED (Michael McDaniel) Date: Mon, 25 Sep 2006 12:57:38 -0700 Subject: [erlang-questions] os_mon memsup reporting memory consumption In-Reply-To: <4517CB99.9040605@erix.ericsson.se> References: <44F478E4.4050905@hq.idt.net> <4517CB99.9040605@erix.ericsson.se> Message-ID: <20060925195738.GX5745@delora.autosys.us> I have been using os_mon,memsup for monitoring a few servers since last year. I went back into the code I am using and found my code comments ... % Used with module autosys_logger, this module does the following: % % application:starts sasl, os_mon, autosys_logger, and then sends % reports via email (using email.erl) every ?? minutes. % Uses autosys_alarm.conf % % -record(alarm, {report_subject ='REPORT delora' , % repeat_time = 14400000 , % mem_percent_alarm = 85 , % alarm when this percent mem used % emailList = ["a_reporting_account@REDACTED", ...] % }). % % to force a certain amount of unused memory (Linux) do % # /sbin/sysctl -w vm.min_free_kbytes=60000 % otherwise "all" the memory may get used in buffers/cached and a single % high_memory alarm will happen but never again (because when processes % want memory they'll take it from buffer/cache and I'll never know % if processes are going memory crazy). % % The 6000 above is nominal for a 1/2 GigByte system. Adjust it as % needed for amount of memory in system, and depending on what percent % the alarm is set in alarm record. % % # free -k (or -m) to watch free/buffers/cached change % Your mileage may vary regarding the vm.min_free_kbytes value and how it affects your application. A hack, of course, to make memsup useable in my (Linux) environment(s). I would rather not see backwards compatibility breakage. Perhaps os_mon,memsup could get a new system_memory_high_watermark_linux threshold which would trigger a different memory calculation ? Existing code using system_memory_high_watermark would be unaffected and new (Linux) code could use the new _linux threshold. ~Michael On Mon, Sep 25, 2006 at 02:29:13PM +0200, Gunilla Arendt wrote: > Hi > > I see the point, but it would be a non-backward compatible change > and as you know we're very hesitant about those. > > An alternative solution could be to add a new tag to the result of > memsup:get_system_memory_data() for Linux systems, although that would > not affect the setting/clearing of alarms. > > If anybody else has thoughts about this, please feel free to share. > > Regards, > Gunilla, Erlang/OTP team > > > > Serge Aleynikov wrote: > > We had a few high memory watermark alarms in a production system running > > Linux reported by OS_MON whereas it seemed like the memory utilization > > on the server wasn't bad. I looked at the implementation of the > > memsup.erl module in OS_MON, and I believe the calculation of allocated > > memory has a flow. > > > > Memsup's code (sited at the end) reveals that allocated memory doesn't > > take in consideration cached memory. Since cached memory can be quickly > > freed by the Linux memory manager if additional memory is needed by > > applications, it looks to me that it should be: > > > > Allocated = MemTotal - (MemFree + Cached) > > > > or even: > > > > Allocated = MemTotal - (MemFree + Buffers + Cached) > > > > This would be consistent with what "free" is showing on the "-/+ > > buffers/cache" line: > > > > drp@REDACTED: ~$ uname -a > > Linux drpdb02.corp.idt.net 2.6.9-5.ELsmp #1 SMP Wed Jan 5 19:30:39 EST > > 2005 i686 i686 i386 GNU/Linux > > > > drp@REDACTED: ~$ free > > total used free shared buffers cached > > Mem: 4150324 3416788 733536 0 282412 2621788 > > -/+ buffers/cache: 512588 3637736 > > Swap: 2048248 0 2048248 > > > > drp@REDACTED: ~$ head -4 /proc/meminfo > > MemTotal: 4150324 kB > > MemFree: 733536 kB > > Buffers: 282412 kB > > Cached: 2621788 kB > > > > > > > > %------------------------- > > %% @spec get_memory_usage_linux() -> {Allocated, Total} > > %------------------------- > > get_memory_usage_linux() -> > > Res = os:cmd("cat /proc/meminfo"), > > case get_memory_usage_linux(Res, undef, undef) of > > {MemTotal, MemFree} -> > > {MemTotal-MemFree, MemTotal}; > > error -> > > timer:sleep(1000), > > get_memory_usage_linux() > > end. > > > > get_memory_usage_linux(_Str, Tot, Free) when is_integer(Tot), > > is_integer(Free) -> > > {Tot, Free}; > > get_memory_usage_linux("MemTotal:"++T, _Tot0, Free0) -> > > {ok, [N], Rest} = io_lib:fread("~d", T), > > Tot = N*1024, > > get_memory_usage_linux(skip_to_eol(Rest), Tot, Free0); > > get_memory_usage_linux("MemFree:"++T, Tot0, _Free0) -> > > {ok, [N], Rest} = io_lib:fread("~d", T), > > Free = N*1024, > > get_memory_usage_linux(skip_to_eol(Rest), Tot0, Free); > > get_memory_usage_linux("", _Tot0, _Free0) -> > > error; > > get_memory_usage_linux(Str, Tot0, Free0) -> > > get_memory_usage_linux(skip_to_eol(Str), Tot0, Free0). > > %------------------------- > > > > Regards, > > > > Serge > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- Michael McDaniel Portland, Oregon, USA http://autosys.us +1 503 283 5284 From fritchie@REDACTED Mon Sep 25 22:16:20 2006 From: fritchie@REDACTED (Scott Lystig Fritchie) Date: Mon, 25 Sep 2006 15:16:20 -0500 Subject: [erlang-questions] very large key lookup In-Reply-To: Message of "Mon, 25 Sep 2006 12:12:13 +0200." Message-ID: <200609252016.k8PKGKHm019153@snookles.snookles.com> >>>>> "uw" == Ulf Wiger \(TN/EAB\) writes: uw> ... but I fail to find how to efficiently match binaries in a uw> match spec. This is a shame. I've looked for such a thing, too, but haven't found it. The only efficient match spec is an equality/inequality test of the entire binary. My only guess for the omission is that the ETS & Mnesia match spec stuff was implemented well before the introduction of the binary data type. Correct, or at least near the mark? I've been wanting something more than the ability to use hd() and tl() in the match spec. If you don't know exactly how long the list is, however, other options within the confines of the match spec language are hard/impossible? to find. I briefly contemplated a chain of boolean or clauses testing hd('$1'), hd(tl('$1')), hd(tl(tl('$1'))), ... etc. I confess that I didn't actually test doing that, but the mere thought of doing it 30 or 40 times seemed quite repulsive. (And my app doesn't always guarantee a max list length of 30 or 40, so I'd be vulnerable to a miss anyway.) I've seen conflicting results when using mnesia:select between the two constructs when the 'sec_attr' attribute has a secondary index defined on it. (This is off the top of my head, beware of typos.) match spec guard list #some_record{sec_attr = 42, _ = '_'} [] #some_record{sec_attr = '$1', _ = '_'} [{'=:=', '$1', 42}] I haven't found a pattern to this, and I've been pressed for time lately, so I'm ignoring it for now. If/when I get enough info to pester the list, I will. :-) In a 'set' table with 800K or so #some_record entries, and a secondary index on 'sec_attr'(*), the table load time is the killer: a 2.8GHz Opteron box takes over 5 minutes to load it. Without the index, 30-40 seconds. That load time is not a good thing. I could fragment the table, but that wouldn't change the overall load time much. :-( So, I'll be doing the indexing for that attribute myself. -Scott (*) There are about 100 unique value for that attribute, so an 800K entry table would have approx. 8K entries per 'bag' entry for the secondary index. So I'm not surprised it's slow. From ulf@REDACTED Mon Sep 25 22:53:30 2006 From: ulf@REDACTED (Ulf Wiger) Date: Mon, 25 Sep 2006 22:53:30 +0200 Subject: [erlang-questions] very large key lookup In-Reply-To: <200609252016.k8PKGKHm019153@snookles.snookles.com> References: <200609252016.k8PKGKHm019153@snookles.snookles.com> Message-ID: Den 2006-09-25 22:16:20 skrev Scott Lystig Fritchie : > however, other options within the confines of the match spec language > are hard/impossible? to find. > > I briefly contemplated a chain of boolean or clauses testing hd('$1'), > hd(tl('$1')), hd(tl(tl('$1'))), ... etc. I confess that I didn't > actually test doing that, but the mere thought of doing it 30 or 40 > times seemed quite repulsive. (And my app doesn't always guarantee a > max list length of 30 or 40, so I'd be vulnerable to a miss anyway.) Oh, a fellow pervert. (: I had a brief outburst of madness with match specs a while ago: http://www.erlang.org/ml-archive/erlang-questions/200601/msg00334.html I agree - the end result was quite repulsive, until I had a chat with John Hughes and added a form of controlled recursion to my own erlang-based match_spec evaluator. The suggestion: {'let', NewVar, Expr, In} and {subterm, StartingExpr, RecursiveOp, While, Until} (described in more detail in the above link) I stared at the match spec compiler inside the emulator until I got dizzy. I decided not to try to extend it with my new constructs, but I remain unconvinced that it wouldn't be possible. It surely was easy enough in Erlang. (: BR, Ulf W -- Ulf Wiger From serge@REDACTED Mon Sep 25 23:53:54 2006 From: serge@REDACTED (Serge Aleynikov) Date: Mon, 25 Sep 2006 17:53:54 -0400 Subject: [erlang-questions] SCTP support in Erlang/OTP Message-ID: <45184FF2.4090703@hq.idt.net> Hi, I have a question for the OTP team. We developed an extension of the inet driver used by the emulator to support an SCTP protocol. This protocol is available in Linux kernel 2.6.x and Solaris 10. Our gen_sctp implementation has very similar API found in gen_tcp and gen_udp, and we've been using it in a number of internal products. We would like to release these SCTP emulator patches to open source for potential inclusion in the OTP. I would like to find out how to pursue this as I am sure many developers would benefit from having support of this protocol in Erlang that offers features like: - Multi-homing - Preservation of message boundaries - Multi-streaming - Reduced head-of-line blocking - DoS prevention (four-way handshaking session setup) However, we do have a small development team and would not be able to release and maintain this project for an open source community by providing support for a large developer base, as answering questions may destruct my team from working on internal projects. We could, however, interface with a relatively small number of maintainers for troubleshooting needs. So, I would like to ask the OTP team for advice on if there's interest in evaluating this work, and if there is what are the guidelines for including this project in the OTP. Regards, Serge -- Serge Aleynikov R&D Telecom, IDT Corp Tel: +1 (973) 438-3436 Fax: +1 (973) 438-1464 From richardc@REDACTED Mon Sep 25 23:59:11 2006 From: richardc@REDACTED (Richard Carlsson) Date: Mon, 25 Sep 2006 23:59:11 +0200 Subject: [erlang-questions] scope of variables In-Reply-To: <95be1d3b0609040617o755f02fj224dddc80d9ca1c9@mail.gmail.com> References: <44FBD154.1010103@it.uu.se> <95be1d3b0609040114i255f0164qdc1998a9792ab3e5@mail.gmail.com> <44FC0ABD.7080309@it.uu.se> <95be1d3b0609040436w2b067228y679c115f750b98d5@mail.gmail.com> <44FC2450.60407@it.uu.se> <95be1d3b0609040617o755f02fj224dddc80d9ca1c9@mail.gmail.com> Message-ID: <4518512F.8090802@it.uu.se> Vlad Dumitrescu wrote: > If it will work as advertised, there are a lot of cool things that > will become posible to do. Like for example optimizations. If I have > to do a lot of math:pow(X, 72) with different X, I could write a > powN/2 macro that produces an optimized powN/1 for any particular N > (72 in this case). That would be > Pow72 = fun(X) -> > X2 = X*X, > X4 = X2*X2, > X8 = X4*X4, > X16 = X8*X8, > X32 = X16*X16, > X64 = X32*X32, > X64+X8. > Maybe not so spectacular, but a similar example wouuld be to produce > custom regexp-matching funs, that might be much more efficient than > the current ones. I didn't take that example because it's not as > simple to produce one by hand :-) Ok, it took a while before I had time to look at it, but the fact is that the normal inliner is technically able to do some of this stuff already - it's just not been enabled! (It was a long time since I wrote that thing, and I had an idea that there was some kind of error that prevented unrolling from working properly, but it seems that either I was wrong all the time, or the problem went away at some point and I just never tried it again.) So, I just made a patch to lib/compiler/src/cerl_inline.erl (attached) which adds a new option {inline_unroll, N} (default is 1 - it can't be lower than 1). This can unroll short recursive loops and help specialize function calls in general. Example: ---- -module(test). -compile(inline). -compile({inline_size, 100}). -compile({inline_effort, 1000}). -compile({inline_unroll, 2}). -export([e/1,f/1,g/1,h/1,i/1,j/1,k/1,l/1]). e(X) -> powN(X, 0). f(X) -> powN(X, 1). g(X) -> powN(X, 2). h(X) -> powN(X, 3). i(X) -> powN(X, 4). j(X) -> powN(X, 5). k(X) -> powN(X, 6). l(X) -> powN(X, 7). powN(X,1) -> X; powN(_,0) -> 1; powN(X,N) when (N band 1) =:= 1 -> X * powN(X*X, N bsr 1); powN(X,N) -> powN(X*X, N bsr 1). ---- generates the following core erlang code (cleaned up for readability): ---- module 'test' ['e'/1, 'f'/1, 'g'/1, 'h'/1, 'i'/1, 'j'/1, 'k'/1, 'l'/1, ...] attributes [] 'e'/1 = fun (_cor0) -> 1 'f'/1 = fun (_cor0) -> _cor0 'g'/1 = fun (_cor0) -> call 'erlang':'*'(_cor0, _cor0) 'h'/1 = fun (_cor0) -> let <_cor4> = call 'erlang':'*'(_cor0, _cor0) in call 'erlang':'*'(_cor0, _cor4) 'i'/1 = fun (_cor0) -> let <_cor7> = call 'erlang':'*'(_cor0, _cor0) in call 'erlang':'*'(_cor7, _cor7) 'j'/1 = fun (_cor0) -> let <_cor4> = call 'erlang':'*'(_cor0, _cor0) in let <_cor5> = call 'erlang':'*'(_cor4, _cor4) in call 'erlang':'*'(_cor0, _cor5) 'k'/1 = fun (_cor0) -> let <_cor7> = call 'erlang':'*'(_cor0, _cor0) in let <_cor4> = call 'erlang':'*'(_cor7, _cor7) in call 'erlang':'*'(_cor7, _cor4) 'l'/1 = fun (_cor0) -> let <_cor4> = call 'erlang':'*'(_cor0, _cor0) in let <_68> = call 'erlang':'*'(_cor4, _cor4) in let <_cor5> = call 'erlang':'*'(_cor4, _68) in call 'erlang':'*'(_cor0, _cor5) ... end ---- This should be in an upcoming release, if you don't feel like patching your own system. Note that just setting unroll=2 enables the elimination of all recursive calls to powN/1 in the examples e/1..l/1. On the other hand, it can be good to provide the inliner with higher size/effort settings than the default, if unrolling is turned on - this gives it more room for temporary expressions that may be optimized away later. /Richard -- "Having users is like optimization: the wise course is to delay it." -- Paul Graham -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: diff.inliner URL: From ok@REDACTED Tue Sep 26 03:05:24 2006 From: ok@REDACTED (Richard A. O'Keefe) Date: Tue, 26 Sep 2006 13:05:24 +1200 (NZST) Subject: [erlang-questions] very large key lookup Message-ID: <200609260105.k8Q15OxS499360@atlas.otago.ac.nz> ke han wrote: We will have hundreds of millions of these 32 byte keys in the the server's "DB" and each key's associated 128 byte key. I am looking for advice on the format for these keys along with which libraries to use for balance between memory and lookup performance. The current format is 0-9 + a-z character strings. I note that there are 36 characters in the 0-9 + a-z character set. This means that one can pack 3 of these characters into 2 bytes. So 32 of these characters can be packed easily in 22 bytes, not 32. To put it another way, a key space of /[0-9a-z]{32}/ is equivalent to a key space of about 166 bits. The internal form of these keys could well be Erlang binaries; there doesn't seem to be any reason why the external form should change. I do wonder, though, why 63,340,286,662,973,277,706,162,286,946,811,886,609,896,461,828,096 primary keys are needed; enough to give every human being now alive 10**40 different keys. Even if we consider every human being who has ever lived, and give each of them 3 million computers, that's still 10**32 each. This *looks* like far more extra bits than are needed for reliability (error detecting codes) and security. What am I missing? From bob@REDACTED Tue Sep 26 03:29:05 2006 From: bob@REDACTED (Bob Ippolito) Date: Mon, 25 Sep 2006 18:29:05 -0700 Subject: [erlang-questions] very large key lookup In-Reply-To: <200609260105.k8Q15OxS499360@atlas.otago.ac.nz> References: <200609260105.k8Q15OxS499360@atlas.otago.ac.nz> Message-ID: <6a36e7290609251829i4f8c7e9bjedb11a7cf6e4dff8@mail.gmail.com> On 9/25/06, Richard A. O'Keefe wrote: > ke han wrote: > We will have hundreds of millions of these 32 byte keys in the the > server's "DB" and each key's associated 128 byte key. > I am looking for advice on the format for these keys along with which > libraries to use for balance between memory and lookup performance. > The current format is 0-9 + a-z character strings. > > I note that there are 36 characters in the 0-9 + a-z character set. > This means that one can pack 3 of these characters into 2 bytes. > So 32 of these characters can be packed easily in 22 bytes, not 32. > To put it another way, a key space of /[0-9a-z]{32}/ is equivalent > to a key space of about 166 bits. > > The internal form of these keys could well be Erlang binaries; > there doesn't seem to be any reason why the external form should change. > > I do wonder, though, why > 63,340,286,662,973,277,706,162,286,946,811,886,609,896,461,828,096 > primary keys are needed; enough to give every human being now alive > 10**40 different keys. Even if we consider every human being who has > ever lived, and give each of them 3 million computers, that's still > 10**32 each. This *looks* like far more extra bits than are needed > for reliability (error detecting codes) and security. What am I missing? 1> math:log(math:pow(36, 32)) / math:log(2). 165.438 Sounds like a cryptographic hash function. SHA-1 fits in 160 bits. MD5 plus a 32-bit timestamp fits in 160 bits. I'm guessing the key space is going to be pretty sparse rather than serial. Probably easier to insert data into a table like that over a cluster since you can pretty much bet against collisions ever happening and you don't have to encode a node id into the key.. which lets the data can move around pretty freely as the cluster grows. -bob From ke.han@REDACTED Tue Sep 26 03:57:54 2006 From: ke.han@REDACTED (ke han) Date: Tue, 26 Sep 2006 09:57:54 +0800 Subject: [erlang-questions] very large key lookup In-Reply-To: <6a36e7290609251829i4f8c7e9bjedb11a7cf6e4dff8@mail.gmail.com> References: <200609260105.k8Q15OxS499360@atlas.otago.ac.nz> <6a36e7290609251829i4f8c7e9bjedb11a7cf6e4dff8@mail.gmail.com> Message-ID: <3047E48C-8134-43C1-ACD8-23CB24590B1D@redstarling.com> On Sep 26, 2006, at 9:29 AM, Bob Ippolito wrote: > On 9/25/06, Richard A. O'Keefe wrote: >> ke han wrote: >> We will have hundreds of millions of these 32 byte keys in >> the the >> server's "DB" and each key's associated 128 byte key. >> I am looking for advice on the format for these keys along >> with which >> libraries to use for balance between memory and lookup >> performance. >> The current format is 0-9 + a-z character strings. >> >> I note that there are 36 characters in the 0-9 + a-z character set. >> This means that one can pack 3 of these characters into 2 bytes. >> So 32 of these characters can be packed easily in 22 bytes, not 32. >> To put it another way, a key space of /[0-9a-z]{32}/ is equivalent >> to a key space of about 166 bits. >> >> The internal form of these keys could well be Erlang binaries; >> there doesn't seem to be any reason why the external form should >> change. >> >> I do wonder, though, why >> 63,340,286,662,973,277,706,162,286,946,811,886,609,896,461,828,096 >> primary keys are needed; enough to give every human being now alive >> 10**40 different keys. Even if we consider every human being who has >> ever lived, and give each of them 3 million computers, that's still >> 10**32 each. This *looks* like far more extra bits than are needed >> for reliability (error detecting codes) and security. What am I >> missing? > > 1> math:log(math:pow(36, 32)) / math:log(2). > 165.438 thanks for the erlang math tutorial !! I've yet to dig into the math libraries. > > Sounds like a cryptographic hash function. SHA-1 fits in 160 bits. MD5 > plus a 32-bit timestamp fits in 160 bits. > > I'm guessing the key space is going to be pretty sparse rather than > serial. Probably easier to insert data into a table like that over a > cluster since you can pretty much bet against collisions ever > happening and you don't have to encode a node id into the key.. which > lets the data can move around pretty freely as the cluster grows. yes,. these keys are not for your typical sequential numbering of records. They are generated by a new algorithm which I can't say much about at the moment. There is only one piece of data associated with each 32 byte key which is a 128 byte value which is used to filter out false positives. My need is for very scalable key lookup; I don't need atomic transactions for insert, update, etc... thanks, ke han > > -bob > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From rath64@REDACTED Tue Sep 26 04:25:16 2006 From: rath64@REDACTED (Tim Rath) Date: Mon, 25 Sep 2006 21:25:16 -0500 (CDT) Subject: [erlang-questions] Possible bug in process_info ? Message-ID: <18879336.3224131159237516278.JavaMail.root@vms169.mailsrvcs.net> Hi, I was playing around with a macro to log some additional detail along with a message, and found something peculiar with the arity that process_info reports. This is not a big deal as I was only intending to use this for simple debugging purposes, but I thought someone maintaining this code might be interested. Here's a test function that shows the behavior I found: -module(b). -compile(export_all). test() -> S = "Foo = ~p", P = [bar], %% Correctly reports arity %% {_, {Ma, Fa, Aa} } = process_info(self(), current_function), io:fwrite("~w:~w/~w : " ++ S ++ "~n", [Ma, Fa, Aa] ++ P), %% Correctly reports arity %% Fun = fun() -> {_, {M, F, A} } = process_info(self(), current_function), io:fwrite("~w:~w/~w~n", [M, F, A]) end, Fun(), %% Adds 2 to the arity ? %% Fun0 = fun() -> {_, {M, F, A} } = process_info(self(), current_function), io:fwrite("~w:~w/~w : " ++ S ++ "~n", [M, F, A] ++ P) end, Fun0(), %% Adds 2 to the arity ? %% Fun1 = fun(_, _, _) -> {_, {M, F, A} } = process_info(self(), current_function), io:fwrite("~w:~w/~w : " ++ S ++ "~n", [M, F, A] ++ P) end, Fun1(1, 2, 3). And here's the output: 50> b:test(). b:test/0 : Foo = bar b:'-test/0-fun-0-'/0 b:'-test/0-fun-1-'/2 : Foo = bar b:'-test/0-fun-2-'/5 : Foo = bar ok Strangely, it appears that changing the parameters to the io:fwrite function change the arity in the previous call to process_info (but only inside a fun) Note the effect of the following change to the code: -module(b). -compile(export_all). test() -> S = "Foo = ~p", SS = ", Nick = ~p", P = [bar, nack], %% Correctly reports arity %% {_, {Ma, Fa, Aa} } = process_info(self(), current_function), io:fwrite("~w:~w/~w : " ++ S ++ SS ++ "~n", [Ma, Fa, Aa] ++ P), %% Correctly reports arity %% Fun = fun() -> {_, {M, F, A} } = process_info(self(), current_function), io:fwrite("~w:~w/~w~n", [M, F, A]) end, Fun(), %% Adds 3 to the arity ? %% Fun0 = fun() -> {_, {M, F, A} } = process_info(self(), current_function), io:fwrite("~w:~w/~w~n", [M, F, A]), io:fwrite("~w:~w/~w : " ++ S ++ SS ++ "~n", [M, F, A] ++ P), io:fwrite("~w:~w/~w~n", [M, F, A]) end, Fun0(), %% Adds 3 to the arity ? %% Fun1 = fun(_, _, _) -> {_, {M, F, A} } = process_info(self(), current_function), io:fwrite("~w:~w/~w : " ++ S ++ SS ++ "~n", [M, F, A] ++ P) end, Fun1(1, 2, 3). Output: 61> b:test(). b:test/0 : Foo = bar, Nick = nack b:'-test/0-fun-0-'/0 b:'-test/0-fun-1-'/3 b:'-test/0-fun-1-'/3 : Foo = bar, Nick = nack b:'-test/0-fun-1-'/3 b:'-test/0-fun-2-'/6 : Foo = bar, Nick = nack ok Not really a problem for me, but I found it interesting anyway. -Tim From vladdu55@REDACTED Tue Sep 26 08:39:30 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Tue, 26 Sep 2006 08:39:30 +0200 Subject: [erlang-questions] Possible bug in process_info ? In-Reply-To: <18879336.3224131159237516278.JavaMail.root@vms169.mailsrvcs.net> References: <18879336.3224131159237516278.JavaMail.root@vms169.mailsrvcs.net> Message-ID: <95be1d3b0609252339u74428911p525b4278d21e397b@mail.gmail.com> Hi, On 9/26/06, Tim Rath wrote: > Strangely, it appears that changing the parameters to the io:fwrite function change the arity in the previous call to process_info (but only inside a fun) It seems that the fun's arity includes not only the actual parameters, but also the bindings of the free variables used inside it. In your example, S and P are also used; and in the second case S, SS and P. This would explain the numbers. best regards, Vlad From ulf.wiger@REDACTED Tue Sep 26 08:39:35 2006 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Tue, 26 Sep 2006 08:39:35 +0200 Subject: [erlang-questions] Possible bug in process_info ? In-Reply-To: <18879336.3224131159237516278.JavaMail.root@vms169.mailsrvcs.net> Message-ID: Tim Rath wrote: > > Hi, > > I was playing around with a macro to log some additional > detail along with a message, and found something peculiar > with the arity that process_info reports. I think the best way to illustrate what's going on is to run a call trace on the module b: Eshell V5.5.1 (abort with ^G) 1> dbg:tracer(). {ok,<0.42.0>} 2> dbg:tpl(b,[]). {ok,[{matched,nonode@REDACTED,6}]} 3> dbg:p(all,[c]). {ok,[{matched,nonode@REDACTED,33}]} 4> b:test(). b:test/0 : Foo = bar (<0.40.0>) call b:test() b:'-test/0-fun-0-'/0 (<0.40.0>) call b:'-test/0-fun-0-'() b:'-test/0-fun-1-'/2 : Foo = bar (<0.40.0>) call b:'-test/0-fun-1-'([bar],"Foo = ~p") b:'-test/0-fun-2-'/5 : Foo = bar (<0.40.0>) call b:'-test/0-fun-2-'(1,2,3,[bar],"Foo = ~p") ok Funs are converted into first class functions, with the variables inherited from the surrounding function passed on as arguments. When you changed the io:fwrite/2 call, you were adding references to variables declared outside the fun. As you can see in the above trace, those variables are passed to the fun as function arguments following the "official" arguments. BR, Ulf W From ml.cyresse@REDACTED Tue Sep 26 13:10:54 2006 From: ml.cyresse@REDACTED (Liam Clarke) Date: Tue, 26 Sep 2006 23:10:54 +1200 Subject: [erlang-questions] Erlangic-ness? Message-ID: Hi all, Erlangic - the Erlang equivalent of Pythonic. Don't think it'll take off though. I've been writing an MSN client in Erlang as a learning project, and I'm reasonably confident with the basic sequential language. It's the sticking it together part that I can feel my noobness in. What I've completed so far will authenticate me with the MSN notification servers, now I just want to get the architecture right before proceeding any further. My current architecture involves interacting directly with an authentication controller process which controls a socket process. The socket process's code is http://paste.lisp.org/display/26798 The authentication controller process codes is http://paste.lisp.org/display/26800 The authentication module also makes an HTTP POST request; I've decided not to create another process for this currently as the authentication process is sequential in nature. The code for the HTTP request is http://paste.lisp.org/display/26801 I'm currently implementing error handling - I'm going to shift overall control and user interaction into a supervisor process shortly. As every stage of the process requires that the previous stage complete successfully, I want the authentication controller and associated socket process to die and return useful debugging data if failure occurs. I'm trying to keep the error logic separate from the socket process - I hope to be able to use the same generic socket code with some slight modifcations. My ultimate aim is to have the my various bit so modularised so that swapping a GUI interface for console interaction or similar should not change anything. If it's possible, could someone please cast their eye over my code? I'm wondering if there's any obvious gotchas, or bad design patterns or just inefficiencies due to clumsy usage of Erlang. I thank anyone who does in advance for their time - Erlang is a different paradigm entirely, and I'm unsure as to good practise. I've been looking at the OTP design principles and Mr Armstrong's thesis, but I'm unsure as to how far I need to take it. Should I be using stuff like gen_event and supervisor()? Regards, Liam Clarke From Bob.Cowdery@REDACTED Tue Sep 26 13:40:10 2006 From: Bob.Cowdery@REDACTED (Bob Cowdery) Date: Tue, 26 Sep 2006 12:40:10 +0100 Subject: [erlang-questions] Binary/term format Message-ID: <3A76756EED583B43A4AD704E29CCD079741175@mail.aprsmartlogik.com> Hi all, If I have a mix of nodes, some C nodes using binary format (ei.lib) and other native erlang nodes using term format then... If I am sending a message between two C node that goes via an erlang node can I just pass the binary format message through without worrying about its format (it may also be transferred between two processes in the same erlang node as well, but neither needs to look inside it. Second, can I determine the format at run time so when I need to consume a message I know whether to do a conversion on it. Thanks Bob From rasmussen.bryan@REDACTED Tue Sep 26 13:58:01 2006 From: rasmussen.bryan@REDACTED (bryan rasmussen) Date: Tue, 26 Sep 2006 13:58:01 +0200 Subject: [erlang-questions] Erlangic-ness? In-Reply-To: References: Message-ID: <3bb44c6e0609260458u2864551fw946aeece9959a016@mail.gmail.com> Erlangish. On 9/26/06, Liam Clarke wrote: > Hi all, > > Erlangic - the Erlang equivalent of Pythonic. > > Don't think it'll take off though. > > I've been writing an MSN client in Erlang as a learning project, and > I'm reasonably confident with the basic sequential language. It's the > sticking it together part that I can feel my noobness in. > > What I've completed so far will authenticate me with the MSN > notification servers, now I just want to get the architecture right > before proceeding any further. > > My current architecture involves interacting directly with an > authentication controller process which controls a socket process. > > The socket process's code is http://paste.lisp.org/display/26798 > The authentication controller process codes is > http://paste.lisp.org/display/26800 > > The authentication module also makes an HTTP POST request; I've > decided not to create another process for this currently as the > authentication process is sequential in nature. The code for the HTTP > request is http://paste.lisp.org/display/26801 > > I'm currently implementing error handling - I'm going to shift overall > control and user interaction into a supervisor process shortly. As > every stage of the process requires that the previous stage complete > successfully, I want the authentication controller and associated > socket process to die and return useful debugging data if failure > occurs. > > I'm trying to keep the error logic separate from the socket process - > I hope to be able to use the same generic socket code with some slight > modifcations. > > My ultimate aim is to have the my various bit so modularised so that > swapping a GUI interface for console interaction or similar should not > change anything. > > If it's possible, could someone please cast their eye over my code? > I'm wondering if there's any obvious gotchas, or bad design patterns > or just inefficiencies due to clumsy usage of Erlang. > > I thank anyone who does in advance for their time - Erlang is a > different paradigm entirely, and I'm unsure as to good practise. I've > been looking at the OTP design principles and Mr Armstrong's thesis, > but I'm unsure as to how far I need to take it. > > Should I be using stuff like gen_event and supervisor()? > > Regards, > > Liam Clarke > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From thomasl_erlang@REDACTED Tue Sep 26 14:24:50 2006 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Tue, 26 Sep 2006 05:24:50 -0700 (PDT) Subject: [erlang-questions] SCTP support in Erlang/OTP In-Reply-To: <45184FF2.4090703@hq.idt.net> Message-ID: <20060926122450.59336.qmail@web38811.mail.mud.yahoo.com> --- Serge Aleynikov wrote: > Hi, > > I have a question for the OTP team. > > We developed an extension of the inet driver used by > the emulator to > support an SCTP protocol. This protocol is > available in Linux kernel > 2.6.x and Solaris 10. Our gen_sctp implementation > has very similar API > found in gen_tcp and gen_udp, and we've been using > it in a number of > internal products. > > We would like to release these SCTP emulator patches > to open source for > potential inclusion in the OTP. /.../ SCTP support would be very useful indeed. Huge, in fact! Best, Thomas __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From valentin@REDACTED Tue Sep 26 15:04:44 2006 From: valentin@REDACTED (Valentin Micic) Date: Tue, 26 Sep 2006 15:04:44 +0200 Subject: [erlang-questions] SCTP support in Erlang/OTP References: <45184FF2.4090703@hq.idt.net> Message-ID: <00a301c6e16c$59086dc0$6601a8c0@moneymaker2> This is soooo great!!! If you write a paper about it for the next user conference (November 9th, 2006), I shall overcome my fear of flying (and we're talking a serious effort here) and attend the conference. Valentin. ----- Original Message ----- From: "Serge Aleynikov" To: "Erlang Users' List" Sent: Monday, September 25, 2006 11:53 PM Subject: [erlang-questions] SCTP support in Erlang/OTP > Hi, > > I have a question for the OTP team. > > We developed an extension of the inet driver used by the emulator to > support an SCTP protocol. This protocol is available in Linux kernel > 2.6.x and Solaris 10. Our gen_sctp implementation has very similar API > found in gen_tcp and gen_udp, and we've been using it in a number of > internal products. > > We would like to release these SCTP emulator patches to open source for > potential inclusion in the OTP. I would like to find out how to pursue > this as I am sure many developers would benefit from having support of > this protocol in Erlang that offers features like: > > - Multi-homing > - Preservation of message boundaries > - Multi-streaming > - Reduced head-of-line blocking > - DoS prevention (four-way handshaking session setup) > > However, we do have a small development team and would not be able to > release and maintain this project for an open source community by > providing support for a large developer base, as answering questions may > destruct my team from working on internal projects. We could, however, > interface with a relatively small number of maintainers for > troubleshooting needs. > > So, I would like to ask the OTP team for advice on if there's interest > in evaluating this work, and if there is what are the guidelines for > including this project in the OTP. > > Regards, > > Serge > > -- > Serge Aleynikov > R&D Telecom, IDT Corp > Tel: +1 (973) 438-3436 > Fax: +1 (973) 438-1464 > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From serge@REDACTED Tue Sep 26 15:58:46 2006 From: serge@REDACTED (Serge Aleynikov) Date: Tue, 26 Sep 2006 09:58:46 -0400 Subject: [erlang-questions] SCTP support in Erlang/OTP In-Reply-To: <00a301c6e16c$59086dc0$6601a8c0@moneymaker2> References: <45184FF2.4090703@hq.idt.net> <00a301c6e16c$59086dc0$6601a8c0@moneymaker2> Message-ID: <45193216.6010608@hq.idt.net> Valentin, As much as I would like to attend this year's user conference, I might be on vacation that week in another part of the world (though I'll let you know if anything changes). I got some positive response from the OTP team regarding this offer, and I'll keep the list posted when there's some progress in this area. Regards, Serge Valentin Micic wrote: > This is soooo great!!! > If you write a paper about it for the next user conference (November > 9th, 2006), I shall overcome my fear of flying (and we're talking a > serious effort here) and attend the conference. > > Valentin. > > ----- Original Message ----- From: "Serge Aleynikov" > To: "Erlang Users' List" > Sent: Monday, September 25, 2006 11:53 PM > Subject: [erlang-questions] SCTP support in Erlang/OTP > > >> Hi, >> >> I have a question for the OTP team. >> >> We developed an extension of the inet driver used by the emulator to >> support an SCTP protocol. This protocol is available in Linux kernel >> 2.6.x and Solaris 10. Our gen_sctp implementation has very similar API >> found in gen_tcp and gen_udp, and we've been using it in a number of >> internal products. >> >> We would like to release these SCTP emulator patches to open source for >> potential inclusion in the OTP. I would like to find out how to pursue >> this as I am sure many developers would benefit from having support of >> this protocol in Erlang that offers features like: >> >> - Multi-homing >> - Preservation of message boundaries >> - Multi-streaming >> - Reduced head-of-line blocking >> - DoS prevention (four-way handshaking session setup) >> >> However, we do have a small development team and would not be able to >> release and maintain this project for an open source community by >> providing support for a large developer base, as answering questions may >> destruct my team from working on internal projects. We could, however, >> interface with a relatively small number of maintainers for >> troubleshooting needs. >> >> So, I would like to ask the OTP team for advice on if there's interest >> in evaluating this work, and if there is what are the guidelines for >> including this project in the OTP. >> >> Regards, >> >> Serge >> >> -- >> Serge Aleynikov >> R&D Telecom, IDT Corp >> Tel: +1 (973) 438-3436 >> Fax: +1 (973) 438-1464 >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > From rath64@REDACTED Tue Sep 26 19:41:24 2006 From: rath64@REDACTED (Tim Rath) Date: Tue, 26 Sep 2006 12:41:24 -0500 (CDT) Subject: [erlang-questions] Possible bug in process_info ? Message-ID: <17254016.5515921159292484892.JavaMail.root@vms074.mailsrvcs.net> >From: Vlad Dumitrescu >Date: 2006/09/26 Tue AM 01:39:30 CDT >To: Tim Rath >Cc: erlang-questions@REDACTED >Subject: Re: [erlang-questions] Possible bug in process_info ? >It seems that the fun's arity includes not only the actual parameters, >but also the bindings of the free variables used inside it. Yep, of course it is. My example shows this very well - not sure why I failed to make the connection. Thanks for helping me see it! > >In your example, S and P are also used; and in the second case S, SS >and P. This would explain the numbers. > >best regards, >Vlad From yan.guiborat@REDACTED Mon Sep 25 11:52:24 2006 From: yan.guiborat@REDACTED (netboz) Date: Mon, 25 Sep 2006 02:52:24 -0700 (PDT) Subject: [erlang-questions] Mnesia permission at process level Message-ID: <6483386.post@talk.nabble.com> Hi, Is there a convenient way to implement permissions on mnesia tables at the process level? I.e: If a remote node connect to a mnesia database at a local node, can we set different permissions to the different process on this remote node ? May be there is the possibility to add a callback at the transaction level to decide if yes or no we accept the transaction ? Hoping I was clear enougth, Thanks, to any advice -- View this message in context: http://www.nabble.com/Mnesia-permission-at-process-level-tf2330534.html#a6483386 Sent from the Erlang Questions mailing list archive at Nabble.com. From chsu79@REDACTED Wed Sep 27 10:04:56 2006 From: chsu79@REDACTED (Christian S) Date: Wed, 27 Sep 2006 10:04:56 +0200 Subject: [erlang-questions] Mnesia permission at process level In-Reply-To: <6483386.post@talk.nabble.com> References: <6483386.post@talk.nabble.com> Message-ID: What is the purpose? A remote process can spawn a process on the local node and have that process use mnesia. You just want sanity checks? In such case you can inspect the schema for what nodes replicate a table. On 9/25/06, netboz wrote: > > Hi, > > Is there a convenient way to implement permissions on mnesia tables at the > process level? > I.e: If a remote node connect to a mnesia database at a local node, can we > set different permissions > to the different process on this remote node ? > May be there is the possibility to add a callback at the transaction level > to decide if yes or no > we accept the transaction ? > Hoping I was clear enougth, > > Thanks, to any advice > -- > View this message in context: http://www.nabble.com/Mnesia-permission-at-process-level-tf2330534.html#a6483386 > Sent from the Erlang Questions mailing list archive at Nabble.com. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From ulf.wiger@REDACTED Wed Sep 27 10:56:35 2006 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Wed, 27 Sep 2006 10:56:35 +0200 Subject: [erlang-questions] Mnesia permission at process level In-Reply-To: <6483386.post@talk.nabble.com> Message-ID: 'Rdbms' has access control, but it can't be made completely safe, of course. It assumes that there is no malicious software running on the node. The way it works is that you can add a metadata declaration for a table, specifying a callback Mod:Fun(Tab, Mod, Record), where Mode = read | write | delete. If the function doesn't return 'true', the transaction aborts. BR, Ulf W > -----Original Message----- > From: erlang-questions-bounces@REDACTED > [mailto:erlang-questions-bounces@REDACTED] On Behalf Of netboz > Sent: den 25 september 2006 11:52 > To: erlang-questions@REDACTED > Subject: [erlang-questions] Mnesia permission at process level > > > Hi, > > Is there a convenient way to implement permissions on mnesia > tables at the process level? > I.e: If a remote node connect to a mnesia database at a local > node, can we set different permissions to the different > process on this remote node ? > May be there is the possibility to add a callback at the > transaction level to decide if yes or no we accept the transaction ? > Hoping I was clear enougth, > > Thanks, to any advice > -- > View this message in context: > http://www.nabble.com/Mnesia-permission-at-process-level-tf233 > 0534.html#a6483386 > Sent from the Erlang Questions mailing list archive at Nabble.com. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From Bob.Cowdery@REDACTED Wed Sep 27 11:01:09 2006 From: Bob.Cowdery@REDACTED (Bob Cowdery) Date: Wed, 27 Sep 2006 10:01:09 +0100 Subject: [erlang-questions] Binary/term format Message-ID: <3A76756EED583B43A4AD704E29CCD079741176@mail.aprsmartlogik.com> As I didn't get any responses I'm assuming this is pretty virgin ground. Having got a bit further maybe a couple of slightly more specific questions might help. Some of the messages from C node to Erlang are consumed by the Erlang node and others passed through to another C node. At the moment I am having trouble even with the Erlang bound messages. As I was having no luck with receiving binary messages I changed one to term format using ei_format() and this was then received. However when I tried to reply to the C node using '{regname, nodename} ! Msg' it never sees the mesage. The receive on the C node was in a timeout retry loop and it just kept looping. No errors so I have no clues. Just had a thought, the reply message is in term format (as I forgot to convert it) and the ei_receive_msg()- does that expect binary format? If I can get this working the next question is when receiving a binary message in an Erlang node what should the match pattern be in the receive, as at the moment I can't seem to match it? I hope someone can help out here. Thanks Bob -----Original Message----- From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED]On Behalf Of Bob Cowdery Sent: 26 September 2006 12:40 To: Erlang-Questions (E-mail) Subject: [erlang-questions] Binary/term format Hi all, If I have a mix of nodes, some C nodes using binary format (ei.lib) and other native erlang nodes using term format then... If I am sending a message between two C node that goes via an erlang node can I just pass the binary format message through without worrying about its format (it may also be transferred between two processes in the same erlang node as well, but neither needs to look inside it. Second, can I determine the format at run time so when I need to consume a message I know whether to do a conversion on it. Thanks Bob _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions From erlang@REDACTED Wed Sep 27 15:16:16 2006 From: erlang@REDACTED (Joe Armstrong) Date: Wed, 27 Sep 2006 15:16:16 +0200 Subject: [erlang-questions] Speeding up string matching In-Reply-To: References: <4512F0EC.70901@web.am> Message-ID: <9b08084c0609270616g6ff014ddp38263a0a4632ef39@mail.gmail.com> If you want to do faster line splitting you might like to use lists instead of binaries I timed 5 different ways of splitting a file into lines The list version was the fastest - see enclosure. /Joe On 22 Sep 2006 09:10:32 +0200, Bjorn Gustavsson wrote: > > I know that it isn't obvious, but the following version of your > function should be faster: > > break_on_nl1(B) -> break_on_nl1(0, B). > break_on_nl1(Len, Bin) when Len =:= size(Bin) -> > {Bin, <<>>}; > break_on_nl1(Len, Bin) -> > case Bin of > <<_:Len/binary, $\n, _/binary>> -> > <> = Bin, > {Msg, Tail}; > _ -> > break_on_nl1(Len+1, Bin) > end. > > I haven't done any measurements on execution times, but I know > that the revised version avoids creating two sub-binaries, which > should make it faster. > > We hope to be able to add better optimization to a future version > of the Erlang compiler, so that you will not have to write such > contrived code to get the fastest possible bit syntax matching. > > /Bjorn > > Gaspar Chilingarov writes: > > > Hi all! > > > > I wish to share an experience which I had today when writing code. > > > [...] > > > > break_on_nl1(B) -> break_on_nl1(0, B). > > break_on_nl1(Len, Bin) when Len == size(Bin) -> > > {Bin, <<>>}; > > break_on_nl1(Len, Bin) -> > > <> = Bin, > > case Symb of > > $\n -> {Msg, Tail}; > > _ -> break_on_nl1(Len+1, Bin) > > end. > > -- > Bj?rn Gustavsson, Erlang/OTP, Ericsson AB > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: cookbook.erl Type: application/octet-stream Size: 2133 bytes Desc: not available URL: From klacke@REDACTED Wed Sep 27 16:52:06 2006 From: klacke@REDACTED (Claes Wikstrom) Date: Wed, 27 Sep 2006 16:52:06 +0200 Subject: [erlang-questions] Speeding up string matching In-Reply-To: <9b08084c0609270616g6ff014ddp38263a0a4632ef39@mail.gmail.com> References: <4512F0EC.70901@web.am> <9b08084c0609270616g6ff014ddp38263a0a4632ef39@mail.gmail.com> Message-ID: <451A9016.1050409@hyber.org> Joe Armstrong wrote: > If you want to do faster line splitting you might like to use lists > instead of binaries > We really really should have been able to write f(Line/binary, "\n", Tail/binary) -> handle_line(Line), f(Tail) to extract the first line. /klacke From attila.rajmund.nohl@REDACTED Wed Sep 27 17:29:28 2006 From: attila.rajmund.nohl@REDACTED (Nohl Attila Rajmund) Date: Wed, 27 Sep 2006 17:29:28 +0200 (MEST) Subject: [erlang-questions] Erlang style question - input handling Message-ID: Hello! I have a couple of functions which follow this pattern: f(X, Y) -> % collect some data % do something with the collected data . I need to add some checks based on the collected data and if the data is wrong, the "do something" part should not happen and an error code should be returned. There are a set of checks, different functions need different set of checks. In C/C++/Java I'd insert a code like this between the collecting part and the "do something" part: if (!check1(data1)) { return ERROR_CODE1; } if (!check2(data2)) { return ERROR_CODE2; } if (!check3(data3)) { return ERROR_CODE3; } and then the rest of the function would be not touched. However, there is no return in Erlang so I can't do this. I've seen two approaches to implement it: case check1(Data1) of true -> case check2(Data2) of true -> case check3(Data3) of true -> % do something false -> ?ERROR_CODE3 end; false -> ?ERROR_CODE2 end; false -> ?ERROR_CODE1 end I really don't like this extra indentation, especially if "do something" also had a couple of indentations. The other approach is: f() -> % collect some data case check1(Data1) of true -> do_f(Lots_of_data); false -> ?ERROR_CODE1 end. do_f(Lots_of_data) -> case check2(Data2) of true -> really_do_f(Lots_of_data); false -> ?ERROR_CODE2 end. really_do_f(Lots_of_data) -> case check3(Data3) of true -> really_really_do_f(Lots_of_data); false -> ?ERROR_CODE3 end. really_really_do_f(Lots_of_data) -> %do something My problem is with this approach that I run out of meaningful function names pretty soon and might have to pass a lots of data around. Is there a more elegant solution to this kind of problem? Bye,NAR -- "Beware of bugs in the above code; I have only proved it correct, not tried it." From garry@REDACTED Wed Sep 27 18:00:46 2006 From: garry@REDACTED (Garry Hodgson) Date: Wed, 27 Sep 2006 12:00:46 -0400 (EDT) Subject: [erlang-questions] Erlangic-ness? In-Reply-To: References: Message-ID: <2006092712001159372846@k2.sage.att.com> "Liam Clarke" wrote: > I thank anyone who does in advance for their time - Erlang is a > different paradigm entirely, and I'm unsure as to good practise. I've > been looking at the OTP design principles and Mr Armstrong's thesis, > but I'm unsure as to how far I need to take it. > > Should I be using stuff like gen_event and supervisor()? my personal opinion is that you should jump on otp as soon as possible. when i built my first app, i didn't really "get" otp, and figured i wanted to learn erlang well, and that i'd learn better rolling my own. which was fine, for learning, until things got big, and then got deployed, and it got a lot harder to retrofit otp to take advantage of what it provides for a real production environment. otp provides a lot of the stuff for free that it takes to make your little app play with the big kids. you may not think you need it now, but if you're successful, you eventually will. ---- Garry Hodgson, Senior Software Geek, AT&T CSO But I'm not giving in an inch to fear 'Cause I promised myself this year I feel like I owe it...to someone. From richardc@REDACTED Wed Sep 27 18:05:55 2006 From: richardc@REDACTED (Richard Carlsson) Date: Wed, 27 Sep 2006 18:05:55 +0200 Subject: [erlang-questions] Erlang style question - input handling In-Reply-To: References: Message-ID: <451AA163.2070501@it.uu.se> Nohl Attila Rajmund wrote: > Is there a more elegant solution to this kind of problem? Yes. Use throw and try/catch. /Richard From chsu79@REDACTED Wed Sep 27 18:07:28 2006 From: chsu79@REDACTED (Christian S) Date: Wed, 27 Sep 2006 18:07:28 +0200 Subject: [erlang-questions] Erlang style question - input handling In-Reply-To: References: Message-ID: Hi, seems like you are still programming in Erlang like a C programmer. You want to return error codes. How about just failing if the input isnt correct? How complex is the error checking? Can you use ordinary pattern matching on the values to check that data is within range? On 9/27/06, Nohl Attila Rajmund wrote: > Hello! > > I have a couple of functions which follow this pattern: > f(X, Y) -> > % collect some data > % do something with the collected data From tty.erlang@REDACTED Wed Sep 27 18:10:05 2006 From: tty.erlang@REDACTED (t ty) Date: Wed, 27 Sep 2006 12:10:05 -0400 Subject: [erlang-questions] Erlang style question - input handling In-Reply-To: References: Message-ID: <290b3ba10609270910v528ed73dyfc084a327e6b16e8@mail.gmail.com> I'm going to assume you terminate on the first failed test. testAndDo(Data, [], Cont) -> Cont(Data); testAndDo(Data, [H | FuncList], Cont) -> {Func, ErrCode} = H, case Func(Data) of true -> testAndDo(Data, FuncList, Cont); _ -> ErrCode end. doSomething(D) -> D + 5. Data = 3, FuncList = [ {fun erlang:is_number/1, err1}, {fun erlang:is_port/1, err2}, {fun erlang:is_atom/1, err3}]. testAndDo(Data, FuncList, fun(D) -> doSomething(D) end) You still pass data around but I suspect the recursive call would be quite efficient in it. t On 9/27/06, Nohl Attila Rajmund wrote: > Hello! > > I have a couple of functions which follow this pattern: > f(X, Y) -> > % collect some data > % do something with the collected data > . > > I need to add some checks based on the collected data and if the data is > wrong, the "do something" part should not happen and an error code > should be returned. There are a set of checks, different functions need > different set of checks. In C/C++/Java I'd insert a code like this > between the collecting part and the "do something" part: > > if (!check1(data1)) { > return ERROR_CODE1; > } > if (!check2(data2)) { > return ERROR_CODE2; > } > if (!check3(data3)) { > return ERROR_CODE3; > } > > and then the rest of the function would be not touched. However, there > is no return in Erlang so I can't do this. I've seen two approaches to > implement it: > case check1(Data1) of > true -> > case check2(Data2) of > true -> > case check3(Data3) of > true -> > % do something > false -> > ?ERROR_CODE3 > end; > false -> > ?ERROR_CODE2 > end; > false -> > ?ERROR_CODE1 > end > > I really don't like this extra indentation, especially if "do something" > also had a couple of indentations. The other approach is: > f() -> > % collect some data > case check1(Data1) of > true -> > do_f(Lots_of_data); > false -> > ?ERROR_CODE1 > end. > > do_f(Lots_of_data) -> > case check2(Data2) of > true -> > really_do_f(Lots_of_data); > false -> > ?ERROR_CODE2 > end. > > really_do_f(Lots_of_data) -> > case check3(Data3) of > true -> > really_really_do_f(Lots_of_data); > false -> > ?ERROR_CODE3 > end. > > really_really_do_f(Lots_of_data) -> > %do something > > > My problem is with this approach that I run out of meaningful function > names pretty soon and might have to pass a lots of data around. Is > there a more elegant solution to this kind of problem? > > Bye,NAR > -- > "Beware of bugs in the above code; I have only proved it correct, not > tried it." > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From ml.cyresse@REDACTED Wed Sep 27 21:38:31 2006 From: ml.cyresse@REDACTED (Liam Clarke) Date: Thu, 28 Sep 2006 07:38:31 +1200 Subject: [erlang-questions] Erlangic-ness? In-Reply-To: <2006092712001159372846@k2.sage.att.com> References: <2006092712001159372846@k2.sage.att.com> Message-ID: Hi, Where would be a good place to find examples of OTP usage? I'm looking at gen_fsm at the moment, and that seems like a good fit, but I'd like to browse some examples of its being used, as I don't quite grok it at the moment. Regards, Liam Clarke On 9/28/06, Garry Hodgson wrote: > "Liam Clarke" wrote: > > > I thank anyone who does in advance for their time - Erlang is a > > different paradigm entirely, and I'm unsure as to good practise. I've > > been looking at the OTP design principles and Mr Armstrong's thesis, > > but I'm unsure as to how far I need to take it. > > > > Should I be using stuff like gen_event and supervisor()? > > my personal opinion is that you should jump on otp as soon as possible. > when i built my first app, i didn't really "get" otp, and figured i wanted to > learn erlang well, and that i'd learn better rolling my own. which was fine, > for learning, until things got big, and then got deployed, and it got a lot > harder to retrofit otp to take advantage of what it provides for a real > production environment. > > otp provides a lot of the stuff for free that it takes to make your little > app play with the big kids. you may not think you need it now, but > if you're successful, you eventually will. > > ---- > Garry Hodgson, Senior Software Geek, AT&T CSO > > But I'm not giving in an inch to fear > 'Cause I promised myself this year > I feel like I owe it...to someone. > > From bob@REDACTED Wed Sep 27 22:00:06 2006 From: bob@REDACTED (Bob Ippolito) Date: Wed, 27 Sep 2006 13:00:06 -0700 Subject: [erlang-questions] Erlangic-ness? In-Reply-To: References: <2006092712001159372846@k2.sage.att.com> Message-ID: <6a36e7290609271300v5eef4ccfu59562078234d6a44@mail.gmail.com> On 9/27/06, Liam Clarke wrote: > > Where would be a good place to find examples of OTP usage? I'm looking > at gen_fsm at the moment, and that seems like a good fit, but I'd like > to browse some examples of its being used, as I don't quite grok it at > the moment. Joe Armstrong's thesis has a good example: http://www.sics.se/~joe/thesis/armstrong_thesis_2003.pdf -bob From mickael.remond@REDACTED Wed Sep 27 23:52:04 2006 From: mickael.remond@REDACTED (Mickael Remond) Date: Wed, 27 Sep 2006 23:52:04 +0200 Subject: [erlang-questions] ejabberd 1.1.2 released Message-ID: <20060927215204.GC7458@memphis> Hello, A new major version of ejabberd has been released! The ejabberd development is proud to announce this release that adds numerous improvements to our high-performance instant messaging server. (Yes, in Erlang as the names implies). See http://www.process-one.net/en/projects/ejabberd/ for more details. The download page can be reached at: http://www.process-one.net/en/projects/ejabberd/download.html The complete changelog is available from: http://redir.process-one.net/ejabberd-1.1.2 Many thanks to all the contributors who took part to this release ! This version will be the last of the 1.1 branch and we will now concentrate on integrating many new features and experiments in the 1.2 branch. We have exciting times ahead. Have fun ! Specific details for this major release: -=-=-=- Release Notes ejabberd 1.1.2 27 September 2006 This document describes the main changes in ejabberd 1.1.2. This version is a major improvement over ejabberd 1.1.1, improving the overall behaviour of the server in many areas. Users of ejabberd 1.1.1 should upgrade to this new release for improved robustness and compliance. ejabberd can be downloaded from the Process-one website: http://www.process-one.net/en/projects/ejabberd/ Detailed information can be found in the Feature Sheet and in the Installation and Operation Guide which are both available on the Process-one website: http://www.process-one.net/en/projects/ejabberd/docs.html ejabberd includes 44 improvements. A complete list of changes can be retrieved from: http://redir.process-one.net/ejabberd-1.1.2 Recent changes include: LDAP Improvements - Major improvements have been made on the LDAP module. It is now more flexible and more robust. HTTP Polling Fixes - The HTTP polling modules have been fixed and improved: the connections are closed properly and polled messages cannot be lost anymore. Roster Management Improvement - Roster management improvements increase reliability, especially in cases where users are on different servers. - Shared rosters are more reliable. Improved Robustness - It is now possible to limit the number of opened connections for a single user. Relational databases - Database support: Microsoft SQL Server is now officially supported in ODBC mode. Publish-Subscribe Improvement - Restricting node creation with a dedicated ACL rule is now possible. Localization - A Czech translation has been added. - Translations have been updated. Binary Installer - New binary installer for Windows including all requirements. - Improved installers for Linux and MacOSX (PowerPC) XMPP Compliancy - Some protocol compliance fix have been added, after the Portland XMPP Interop Meeting in July. Miscelanous - MUC have been improved (logging rendering). - The command line tool ejabberdctl has been improved. - The build chain has been improved, including MacOSX support. - The documentation has been improved and updated to describe the new features. Bugfixes - Anonymous login bugfixes. - Please refer to the ChangeLog file supplied with this release regarding all improvements in ejabberd. Installation Notes Supported Erlang Version - You need at least Erlang/OTP R9C-2 to run ejabberd 1.1.2. - The recommanded version is Erlang/OTP R10B-10. - Erlang/OTP R11B has not yet been fully certified for ejabberd. Installation Installers are provided for Microsoft Windows, Linux/x86 and MacOSX/PPC. They can be retrieved from: http://www.process-one.net/en/projects/ejabberd/download.html Migration Notes - Before any migration, ejabberd system and database must be properly backed up. - The relational database schema has changed between version 1.1.1 and 1.1.2. An "askmessage" column needs to be added in the "rosterusers" table to perform the migration. References Contributed tutorials and documents of interest are: - Migration from other XMPP servers to ejabberd: http://ejabberd.jabber.ru/migrate-to-ejabberd - Transport configuration for connecting to other networks: http://ejabberd.jabber.ru/tutorials-transports - Frequently Asked Questions: http://ejabberd.jabber.ru/faq END From ok@REDACTED Thu Sep 28 06:47:17 2006 From: ok@REDACTED (Richard A. O'Keefe) Date: Thu, 28 Sep 2006 16:47:17 +1200 (NZST) Subject: [erlang-questions] Erlang style question - input handling Message-ID: <200609280447.k8S4lH6p517092@atlas.otago.ac.nz> Nohl Attila Rajmund wrote: I have a couple of functions which follow this pattern: f(X, Y) -> % collect some data % do something with the collected data . In C/C++/Java I'd insert a code like this between the collecting part and the "do something" part: if (!check1(data1)) return ERROR_CODE1; if (!check2(data2)) return ERROR_CODE2; if (!check3(data3)) return ERROR_CODE3; and then the rest of the function would be not touched. However, there is no return in Erlang so I can't do this. As a matter of fact, there IS something very similar, and someone who knows C++ and Java should be familiar with it: f(X, Y) -> try ... collect some data ... check1(data1), check2(data2), check3(data3), ... do something with the collected data catch check1 -> ERROR_CODE1; check2 -> ERROR_CODE2; check3 -> ERROR_CODE3 end. check1(Data) -> ... if all is well, answer true ... ... if something is wrong, throw(check1) ... similar for check2, check3. By the way, I have very serious doubts about the interface of this function. Why should the caller have to work so hard to figure out whether they got a good result or a bad one? The natural thing to do in C++ or Java is *NOT* to return an error code but to throw an error term, so the expected structure for f/2 would be f(X, Y) -> ... collect some data ... check1(data1), check2(data2), check3(data3), ... do something with the collected data ... and the way the caller finds out about a problem is by using a try/catch. From ml.cyresse@REDACTED Thu Sep 28 08:03:48 2006 From: ml.cyresse@REDACTED (Liam Clarke) Date: Thu, 28 Sep 2006 18:03:48 +1200 Subject: [erlang-questions] Erlangic-ness? In-Reply-To: <6a36e7290609271300v5eef4ccfu59562078234d6a44@mail.gmail.com> References: <2006092712001159372846@k2.sage.att.com> <6a36e7290609271300v5eef4ccfu59562078234d6a44@mail.gmail.com> Message-ID: Ah, I'm up to chapter 5 of it. :-) I'll keep reading. On 9/28/06, Bob Ippolito wrote: > On 9/27/06, Liam Clarke wrote: > > > > Where would be a good place to find examples of OTP usage? I'm looking > > at gen_fsm at the moment, and that seems like a good fit, but I'd like > > to browse some examples of its being used, as I don't quite grok it at > > the moment. > > Joe Armstrong's thesis has a good example: > http://www.sics.se/~joe/thesis/armstrong_thesis_2003.pdf > > -bob > From attila.rajmund.nohl@REDACTED Thu Sep 28 10:30:20 2006 From: attila.rajmund.nohl@REDACTED (Nohl Attila Rajmund) Date: Thu, 28 Sep 2006 10:30:20 +0200 (MEST) Subject: [erlang-questions] Erlang style question - input handling In-Reply-To: <200609280447.k8S4lH6p517092@atlas.otago.ac.nz> References: <200609280447.k8S4lH6p517092@atlas.otago.ac.nz> Message-ID: On Thu, 28 Sep 2006, Richard A. O'Keefe wrote: [...] > As a matter of fact, there IS something very similar, and someone who > knows C++ and Java should be familiar with it: > > f(X, Y) -> > try > ... collect some data ... > check1(data1), > check2(data2), > check3(data3), > ... do something with the collected data > catch > check1 -> ERROR_CODE1; > check2 -> ERROR_CODE2; > check3 -> ERROR_CODE3 > end. > > check1(Data) -> > ... if all is well, answer true ... > ... if something is wrong, throw(check1) ... > > similar for check2, check3. That looks good. > By the way, I have very serious doubts about the interface of this > function. Why should the caller have to work so hard to figure out > whether they got a good result or a bad one? The natural thing to do > in C++ or Java is *NOT* to return an error code but to throw an > error term, so the expected structure for f/2 would be > > f(X, Y) -> > ... collect some data ... > check1(data1), > check2(data2), > check3(data3), > ... do something with the collected data ... > > and the way the caller finds out about a problem is by using > a try/catch. Unfortunately I can't change the caller interface. Crashing would be also a bad solution, because it's a kind of user input validation and the user prefers a nice error dialog over an Erlang crash dump. Bye,NAR -- "Beware of bugs in the above code; I have only proved it correct, not tried it." From ben@REDACTED Thu Sep 28 11:30:29 2006 From: ben@REDACTED (Ben Butler-Cole) Date: Thu, 28 Sep 2006 02:30:29 -0700 (PDT) Subject: [erlang-questions] Erlang style question - input handling Message-ID: <20060928093029.51808.qmail@web30805.mail.mud.yahoo.com> > Nohl Attila Rajmund wrote: > > I have a couple of functions which follow this pattern: > > f(X, Y) -> > > % collect some data > > % do something with the collected data > > . > > > > In C/C++/Java I'd insert a code like this > > between the collecting part and the "do something" part: > > > > if (!check1(data1)) return ERROR_CODE1; > > if (!check2(data2)) return ERROR_CODE2; > > if (!check3(data3)) return ERROR_CODE3; Richard A. O'Keefe replied: > By the way, I have very serious doubts about the interface of this > function. Why should the caller have to work so hard to figure out > whether they got a good result or a bad one? The natural thing to do > in C++ or Java is *NOT* to return an error code but to throw an > error term If you're going to abandon the error codes why not go the whole hog and just blow up if the data is wrong: f(X, Y) -> data1 = collect_data1(X, Y), % etc ok = check1(data1), % etc do_stuff_with(data1), % etc . From chsu79@REDACTED Thu Sep 28 12:19:38 2006 From: chsu79@REDACTED (Christian S) Date: Thu, 28 Sep 2006 12:19:38 +0200 Subject: [erlang-questions] Erlang style question - input handling In-Reply-To: References: <200609280447.k8S4lH6p517092@atlas.otago.ac.nz> Message-ID: On 9/28/06, Nohl Attila Rajmund wrote: > Unfortunately I can't change the caller interface. Crashing would be > also a bad solution, because it's a kind of user input validation and > the user prefers a nice error dialog over an Erlang crash dump. This argument is as good as for someone programming in Java saying: "Using java exceptions for error handling would be a bad solution, because the user prefers a nice error dialog over an exception stack trace." Error handling in erlang is very focused around supervisor processes trapping crashed processes that it is monitoring/linked to. (The connection to java exceptions is that printing a stack trace is an explicit choice in the exception handler.) The idea with exceptions is that you only program for the situations that you expect, if you find something unexpected, stop doing things immediately. http://en.wikipedia.org/wiki/Crash-only_software When handling user input one often expect invalid input and want to give the user another chance to input it again correctly. For example, a submitted html form: if there is anything wrong then one typically want to output the form again with the user's previous inputs and with help text next to the erroneous fields. An expected error. If the user input is valid and one then try to store the data in mnesia but the mnesia transaction returns {aborted, node_on_fire} then that is an unexpected error. Let it crash. Yaws will trap the crash and serve the user with an internal server error http response. An unexpected error. Handling the unexpected error is easy to answer, just cause an exception. It is natural to program for this in erlang. A line like {atomic, Result} = mnesia:transaction(Fun) will cause a bad match exceptoin if the return value doesnt match. Handling the expected error is domain specific for how one want to proceed in the valid and invalid case. PS. Is your use of macros for error codes a C programmer-ism? Erlang has a perfectly fine data type for error codes: The atom. I know some people use macros to catch miss spelled names. PS2. Writing this, I realize there is a lot to write about errors in software engineering. Perhaps just to establish a well defined terminology. The case i describe as an expected error is a user mistake. The node on fire is really a system design error, lack of redundancy (im not accusing mnesia of that crime though :-). From erlang@REDACTED Thu Sep 28 15:30:07 2006 From: erlang@REDACTED (Joe Armstrong) Date: Thu, 28 Sep 2006 15:30:07 +0200 Subject: [erlang-questions] Pretty printing records from a program Message-ID: <9b08084c0609280630vb2623f6s12976a2002b3e5b7@mail.gmail.com> I have a record X in a program and all the .hrl files etc. How do I pretty print this from a program I know I can do it in the shell with > rr("*.hrl"), > rp(X). But I want to do this from my program I have read http://www.erlang.org/ml-archive/erlang-questions/200508/msg00140.html But was none the wiser /Joe -------------- next part -------------- An HTML attachment was scrubbed... URL: From Martin.Logan@REDACTED Thu Sep 28 18:37:36 2006 From: Martin.Logan@REDACTED (Logan, Martin) Date: Thu, 28 Sep 2006 11:37:36 -0500 Subject: [erlang-questions] Porting issues - need help!! Message-ID: <26AB42AB6A76E2419D26E66ECF1538462CF655@chiresexc02.resource.corp.lcl> Just to let everyone who is interested know, all the current Erlang tutorials not already present on Trap Exit are listed at: http://wiki.trapexit.org/index.php/Category:HowToSignup If you are the author of one of the tutorials you have the opportunity to: 1. Put your name on your tutorial if it is not already there. ? 2. Sign up to port your tutorial to the Trap Exit site so that all noobs and experts alike will have a one stop place to learn and subsequently spread our great language. 3. Indicate whether someone else can port your tutorial to the trap exit site and format. If you are not an author you can sign up to port a tutorial that the author has given permission to be ported. Cheers, Martin -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf.wiger@REDACTED Thu Sep 28 18:59:38 2006 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Thu, 28 Sep 2006 18:59:38 +0200 Subject: [erlang-questions] Pretty printing records from a program In-Reply-To: <9b08084c0609280630vb2623f6s12976a2002b3e5b7@mail.gmail.com> Message-ID: So how about this post then? http://www.erlang.org/ml-archive/erlang-questions/200605/msg00377.html I made a small modification and posted a new version in the User Contributions forum at trapexit.org. An example of a pretty-print function for your records would then be: pp(Rec) -> RF = fun(R,L) when R == element(1,Rec) -> Flds = '#info-'(Rec), true = (L == length(Flds)), Flds end, io:fwrite([io_lib_pretty:print(Rec, RF),"\n"]). The function '#info-'/1 is an introspective function returning a list of attribute names for the given record - provided that the argument is of one of the exported record types. BR, Ulf W (Next time, I hope to contribute something that _isn't_ a parse transform...) ________________________________ From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Joe Armstrong Sent: den 28 september 2006 15:30 To: erlang-questions@REDACTED Subject: [erlang-questions] Pretty printing records from a program I have a record X in a program and all the .hrl files etc. How do I pretty print this from a program I know I can do it in the shell with > rr("*.hrl"), > rp(X). But I want to do this from my program I have read http://www.erlang.org/ml-archive/erlang-questions/200508/msg00140.html But was none the wiser /Joe From garry@REDACTED Thu Sep 28 19:05:12 2006 From: garry@REDACTED (Garry Hodgson) Date: Thu, 28 Sep 2006 13:05:12 -0400 (EDT) Subject: [erlang-questions] Erlangic-ness? In-Reply-To: References: Message-ID: <2006092813051159463112@k2.sage.att.com> "Liam Clarke" wrote: > Where would be a good place to find examples of OTP usage? the aforementioned thesis is great. the erlang docs on otp cover much of the same material. ulf wiger wrote a nice tutorial "Writing an Erlang Port using OTP Principles", at: http://wiki.trapexit.org/index.php/Writing_an_Erlang_Port_using_OTP_Principles and i vaguely recall another such tutorial, but can't seem to find it. ---- Garry Hodgson, Senior Software Geek, AT&T CSO But I'm not giving in an inch to fear 'Cause I promised myself this year I feel like I owe it...to someone. From garry@REDACTED Thu Sep 28 19:11:27 2006 From: garry@REDACTED (Garry Hodgson) Date: Thu, 28 Sep 2006 13:11:27 -0400 (EDT) Subject: [erlang-questions] Erlangic-ness? In-Reply-To: <2006092813051159463112@k2.sage.att.com> References: <2006092813051159463112@k2.sage.att.com> Message-ID: <2006092813111159463487@k2.sage.att.com> Garry Hodgson wrote: > ulf wiger wrote a nice tutorial "Writing an Erlang > Port using OTP Principles", at: > http://wiki.trapexit.org/index.php/Writing_an_Erlang_Port_using_OTP_Principles > and i vaguely recall another such tutorial, but can't seem to find it. and then "Logan, Martin" wrote: > Just to let everyone who is interested know, all the current Erlang > tutorials not already present on Trap Exit are listed at: > > http://wiki.trapexit.org/index.php/Category:HowToSignup which made me realize that the aforementioned tutorial was written by Pete Kazmier, not ulf. my apologies. i think i had it confused with "Tutorial package: how to build an OTP system", at: http://www.erlang.org/ml-archive/erlang-questions/200212/msg00038.html which may be the other tutorial i was thinking of. ---- Garry Hodgson, Senior Software Geek, AT&T CSO But I'm not giving in an inch to fear 'Cause I promised myself this year I feel like I owe it...to someone. From cyberlync@REDACTED Fri Sep 29 02:22:35 2006 From: cyberlync@REDACTED (Eric Merritt) Date: Thu, 28 Sep 2006 17:22:35 -0700 Subject: [erlang-questions] gen_tcp, {packet, http}, and recieve buffer size Message-ID: Guys, I have a question about one of the undocumented features of gen_tcp. When using the http packet type in gen_tcp, parsing fails if data associated with the http get request is larger then the receive buffer. At least, after a bit of testing this looks like the problem we are seeing. Of course, this is just a prototype and not a production system so its no big deal, but it did kick in my curiosity. So is this a bug? Thanks, Eric From matthew.reilly@REDACTED Fri Sep 29 02:59:06 2006 From: matthew.reilly@REDACTED (Matthew Reilly) Date: Thu, 28 Sep 2006 17:59:06 -0700 Subject: [erlang-questions] gen_tcp, {packet, http}, and recieve buffer size In-Reply-To: References: Message-ID: <451C6FDA.9090005@sipphone.com> Eric Merritt wrote: > Guys, > > I have a question about one of the undocumented features of gen_tcp. > When using the http packet type in gen_tcp, parsing fails if data > associated with the http get request is larger then the receive > buffer. At least, after a bit of testing this looks like the problem > we are seeing. Of course, this is just a prototype and not a > production system so its no big deal, but it did kick in my curiosity. > So is this a bug? > > Thanks, > Eric > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > You can set the recbuf option when creating the TCP port to more than 1024 by including e.g. {recbuf, 8192} in the gen_tcp:connect options. This allows lines of up to 8K in the HTTP Headers. The problem you've seen not only affects the Request URI, but any long line in the HTTP header. (e.g. I've hit this limit with large cookies). Note: This doesn't work for SSL (since the ssl module dis-allows 'recbuf'). If you think this may be a problem, here is one fix: In the Erlang/OTP source directory, edit the file: ./erts/emulator/drivers/common/inet_drv.c Change #define INET_DEF_BUFFER 1024 /* default buffer size */ To: #define INET_DEF_BUFFER (1024*8) /* default buffer size */ Then recompile Erlang/OTP and re-install. Matt Reilly SIPphone Inc. From cyberlync@REDACTED Fri Sep 29 03:08:03 2006 From: cyberlync@REDACTED (Eric Merritt) Date: Thu, 28 Sep 2006 18:08:03 -0700 Subject: [erlang-questions] gen_tcp, {packet, http}, and recieve buffer size In-Reply-To: <451C6FDA.9090005@sipphone.com> References: <451C6FDA.9090005@sipphone.com> Message-ID: > > You can set the recbuf option when creating the TCP port to more than > 1024 by including e.g. {recbuf, 8192} in the gen_tcp:connect options. > This allows lines of up to 8K in the HTTP Headers. The problem you've > seen not only affects the Request URI, but any long line in the HTTP > header. (e.g. I've hit this limit with large cookies). > > Note: This doesn't work for SSL (since the ssl module dis-allows > 'recbuf'). If you think this may be a problem, here is one fix: > > In the Erlang/OTP source directory, edit the file: > ./erts/emulator/drivers/common/inet_drv.c > Change > #define INET_DEF_BUFFER 1024 /* default buffer size */ > To: > #define INET_DEF_BUFFER (1024*8) /* default buffer size */ > > Then recompile Erlang/OTP and re-install. Does it not seem problematic though that parsing should fail when you run out of data instead of simply attempting to get more data to parse. This seems pretty broken to me. From jay@REDACTED Fri Sep 29 07:15:22 2006 From: jay@REDACTED (Jay Nelson) Date: Thu, 28 Sep 2006 22:15:22 -0700 Subject: [erlang-questions] Intel and 80 cores Message-ID: <451CABEA.8010009@duomark.com> Intel announces an 80 core chip within 5 years. It will have 20GB of RAM and can perform at 1 TFLOP. http://news.com.com/Intel+pledges+80+cores+in+five+years/2100-1006_3-6119618.html?tag=nl http://news.com.com/Processor%2C+memory+may+marry+in+future+computers/2100-1006_3-6120547.html?tag=nefd.top Just imagine how fast Microsoft Word will be! jay From ulf@REDACTED Fri Sep 29 09:44:49 2006 From: ulf@REDACTED (Ulf Wiger) Date: Fri, 29 Sep 2006 09:44:49 +0200 Subject: [erlang-questions] gen_tcp, {packet, http}, and recieve buffer size In-Reply-To: References: Message-ID: Den 2006-09-29 02:22:35 skrev Eric Merritt : > Guys, > > I have a question about one of the undocumented features of gen_tcp. > When using the http packet type in gen_tcp, parsing fails if data > associated with the http get request is larger then the receive > buffer. At least, after a bit of testing this looks like the problem > we are seeing. Of course, this is just a prototype and not a > production system so its no big deal, but it did kick in my curiosity. > So is this a bug? I'm just speculating here, but... I guess that depends on how it fails. If it kills the whole VM, it's a bug, but if it simply drops the packet, I'd say it's a feature. The receive buffer is configurable, and one may well be able to impose that kind of protection, in order to stop people from sending huge packets as some sort of DoS attack (sending chunked data ought to be a much better way to handle very large data anyway.) BR, Ulf W -- Ulf Wiger From mats.cronqvist@REDACTED Fri Sep 29 11:25:49 2006 From: mats.cronqvist@REDACTED (Mats Cronqvist) Date: Fri, 29 Sep 2006 11:25:49 +0200 Subject: [erlang-questions] Pretty printing records from a program In-Reply-To: <9b08084c0609280630vb2623f6s12976a2002b3e5b7@mail.gmail.com> References: <9b08084c0609280630vb2623f6s12976a2002b3e5b7@mail.gmail.com> Message-ID: <451CE69D.6020007@ericsson.com> Joe Armstrong wrote: > I have a record X in a program and all the .hrl files etc. > How do I pretty print this from a program the real problem is of course that record_info/2 is a macro, and not a real function. IMO record_info should be generated by the compiler (just like module_info/0). now, if your module is debug compiled, you can use the fabled rec module (that i just wrote :> ). then this snippet; -define(PURTY(X),rec:pretty(?MODULE,X)). -record(sucky,{t=aT,u,v=aV,w=aDubU,x=anX,y=aY,z}). g() -> ?PURTY(#sucky{z=hello}). will produce this output; [{t,aT},{u,undefined},{v,aV},{w,aDubU},{x,anX},{y,aY},{z,hello}] which is probably what you want. mats %------------------------------------------------------------------- %%% File : rec.erl %%% Author : Mats Cronqvist %%% Description : %%% pretty(Mod,Rec) -> list({FieldName,Value}) %%% Mod = atom() - module name %%% Rec = record() %%% %%% Rec must declared in Mod. %%% works by getting debug_info from the beam file. caches the record %%% info in the process registry. checks compile times to see if cache %%% is out-of-date. %%% %%% Created : 29 Sep 2006 by Mats Cronqvist %%%------------------------------------------------------------------- -module(rec). -export([pretty/2]). pretty(Mod,Rec) when is_tuple(Rec) -> pretty(Mod,tuple_to_list(Rec)); pretty(Mod,[RecName|Vals]) -> lists:zip(get_recinfo(Mod,RecName),Vals). get_recinfo(Mod,RecName) -> Key = {rec_info,Mod,RecName}, case get(Key) of undefined -> try put_recinfo(Mod,RecName),get_recinfo(Mod,RecName) catch _:R -> exit({no_record_info,RecName,Mod,R}) end; {Ctime,Fields} -> case Ctime < ctime(Mod:module_info(compile)) of true -> erase(Key),get_recinfo(Mod,RecName); false -> Fields end end. put_recinfo(Mod,RecName) -> {_,C} = get_chunk(Mod,"Abst"), Fs = try [_Fs] = [X||{attribute,_,record,{R,X}} <- C, R=:=RecName], _Fs catch _:_ -> throw(no_such_record) end, F = fun({record_field,_,{atom,_,V},_})->V; ({record_field,_,{atom,_,V}})->V end, put({rec_info,Mod,RecName}, {ctime(get_chunk(Mod,"CInf")), lists:map(F,Fs)}). ctime(C) -> [X || X <- C, element(1,X)==time]. get_chunk(Mod,Chnk) -> F = try hd(_F = code:which(Mod)), _F catch _:_ -> throw(no_file) end, B = try {ok,{Mod,[{Chnk,_B}]}} = beam_lib:chunks(F,[Chnk]),_B catch _:_ -> throw(not_debug_compiled) end, binary_to_term(B). From ke.han@REDACTED Fri Sep 29 11:46:29 2006 From: ke.han@REDACTED (ke han) Date: Fri, 29 Sep 2006 17:46:29 +0800 Subject: [erlang-questions] Intel and 80 cores In-Reply-To: <451CABEA.8010009@duomark.com> References: <451CABEA.8010009@duomark.com> Message-ID: <9A806A57-3852-4400-8EA5-235A669873E9@redstarling.com> Two remarks: 1 - this puts Richard's argument to center stage that those who don't get concurrency will be out of business. 2 - Intel also slipped in info with these announcements that these new multi-core chips will require embedded memory and/or embedded memory controllers. Sounds like AMD is already about 4 years ahead of Intel on this front!!! ...and don't expect Word to get any faster, less bloated or more secure... ke han On Sep 29, 2006, at 1:15 PM, Jay Nelson wrote: > Intel announces an 80 core chip within 5 years. It will have 20GB of > RAM and can perform at 1 TFLOP. > > http://news.com.com/Intel+pledges+80+cores+in+five+years/ > 2100-1006_3-6119618.html?tag=nl > > http://news.com.com/Processor%2C+memory+may+marry+in+future > +computers/2100-1006_3-6120547.html?tag=nefd.top > > > > Just imagine how fast Microsoft Word will be! > > jay > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From xlcr@REDACTED Fri Sep 29 13:07:42 2006 From: xlcr@REDACTED (Nick Linker) Date: Fri, 29 Sep 2006 18:07:42 +0700 Subject: [erlang-questions] F# and Nemerle In-Reply-To: <4516ACDC.5080900@duomark.com> References: <4516ACDC.5080900@duomark.com> Message-ID: <451CFE7E.8050502@mail.ru> Jay Nelson wrote: > Anyone had experience using either of these languages on .NET with > Visual Studio? How about on mono? Are they stable enough for real > work? Did you find any advantages or disadvantages in using them? > > jay There is group of Nemerle users in Russian Software Developer Network. Accordingly to their words, Nemerle is the most advanced language ever. :-) There is significant progress in the work over the Nemerle plugin for Visual Studio. You can look at the small report about the plugin abilities at http://rsdn.ru/forum/Message.aspx?mid=2056038&only=1. The language is russian, but the page contains a number of screenshots, so I think you probably will not have problems with understanding. Otherwise, I could translate it to you, if you will need. Mono is primordial platform for the developers of Nemerle, so there shouldn't be any problems with it. The core is stable, but in standard macros there are number of little issues, although the issues are being fixed quite fast. Best regards, Nick. From vladdu55@REDACTED Fri Sep 29 13:39:37 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Fri, 29 Sep 2006 13:39:37 +0200 Subject: [erlang-questions] scope of variables In-Reply-To: <4518512F.8090802@it.uu.se> References: <44FBD154.1010103@it.uu.se> <95be1d3b0609040114i255f0164qdc1998a9792ab3e5@mail.gmail.com> <44FC0ABD.7080309@it.uu.se> <95be1d3b0609040436w2b067228y679c115f750b98d5@mail.gmail.com> <44FC2450.60407@it.uu.se> <95be1d3b0609040617o755f02fj224dddc80d9ca1c9@mail.gmail.com> <4518512F.8090802@it.uu.se> Message-ID: <95be1d3b0609290439k32b482a6v4cc0cd7f5e8629f3@mail.gmail.com> Hi, On 9/25/06, Richard Carlsson wrote: > Ok, it took a while before I had time to look at it, but the fact is > that the normal inliner is technically able to do some of this stuff > already - it's just not been enabled! That's cool to know! However, if one needs something less simple than just loop unrolling, then another approach is needed. A few other applications of this "compile a customized variant of this function given these static parameters" could be * sparse vector multiplication, where all zero elements would just eliminated from the calculation * regexps, where it is possible (but I'm not sure if it applies to the general case) to generate specializations of the generic algorithm that are very close to hand-crafted variants. best regards, Vlad From ft@REDACTED Fri Sep 29 14:15:45 2006 From: ft@REDACTED (Fredrik Thulin) Date: Fri, 29 Sep 2006 14:15:45 +0200 Subject: [erlang-questions] Mnesia inconsistency with R11B-1 Message-ID: <200609291415.45734.ft@it.su.se> Hi I upgraded from R10B-10 to R11B-1 about a week ago. Today I got a problem report that seems to be because I have inconsistencies in my Mnesia table 'phone'. On node #1, a record is present that is not present on node #2 : (root@REDACTED)49> rpc:call('appserver@REDACTED', phone, get_sipuser_locations, ["username"]). {ok,[{siplocationdb_e,{sipurl,"sip", ... 1159532776}]} (root@REDACTED)50> rpc:call('appserver@REDACTED', phone, get_sipuser_locations, ["username"]). {ok,[]} (root@REDACTED)51> This table is written to from at least four different nodes, but always using transactions and never with dirty writes. What should I do to figure out the cause of this? I will have to restart the nodes at the latest before Monday morning to get everything working again, but if you guys are quick I can do diagnostics on the running system =). It seems to me that there is no partitioned network (both nodes list the same nodes as 'running'). Another indicator of the differences, and also mnesia:info() output from the two nodes : (root@REDACTED)55> length( rpc:call('appserver@REDACTED', db_util, tab_to_list, [phone]) ). 63 (root@REDACTED)56> length( rpc:call('appserver@REDACTED', db_util, tab_to_list, [phone]) ). 58 (root@REDACTED)57> rpc:call('appserver@REDACTED', mnesia, info, []). ---> Processes holding locks <--- ---> Processes waiting for locks <--- ---> Participant transactions <--- ---> Coordinator transactions <--- ---> Uncertain transactions <--- ---> Active tables <--- schema : with 10 records occupying 1569 words of mem call : with 0 records occupying 279 words of mem ===> System info in version "4.3.2", debug level = none <=== opt_disc. Directory "/var/yxa/mnesia/appserver" is NOT used. use fallback at restart = false running db nodes = ['root@REDACTED','eventserver@REDACTED','incomingproxy@REDACTED','pstnproxy@REDACTED','appserver@REDACTED','outgoingproxy@REDACTED','outgoingproxy@REDACTED','incomingproxy@REDACTED','eventserver@REDACTED','pstnproxy@REDACTED','appserver@REDACTED'] stopped db nodes = ['root@REDACTED','pstnproxy@REDACTED'] master node tables = [] remote = [cpl_script_graph, eventdata, forward, gruu, numbers, phone, regexproute, user] ram_copies = [call,schema] disc_copies = [] disc_only_copies = [] [{'appserver@REDACTED',ram_copies}, {'appserver@REDACTED',ram_copies}] = [call] [{'appserver@REDACTED',ram_copies}, {'appserver@REDACTED',ram_copies}, {'eventserver@REDACTED',ram_copies}, {'eventserver@REDACTED',ram_copies}, {'incomingproxy@REDACTED',disc_copies}, {'incomingproxy@REDACTED',disc_copies}, {'outgoingproxy@REDACTED',ram_copies}, {'outgoingproxy@REDACTED',ram_copies}, {'pstnproxy@REDACTED',ram_copies}, {'pstnproxy@REDACTED',ram_copies}, {'root@REDACTED',ram_copies}] = [schema] [{'eventserver@REDACTED',ram_copies}, {'eventserver@REDACTED',ram_copies}, {'incomingproxy@REDACTED',disc_copies}, {'incomingproxy@REDACTED',disc_copies}] = [eventdata] [{'incomingproxy@REDACTED',disc_copies}, {'incomingproxy@REDACTED',disc_copies}] = [gruu, cpl_script_graph, regexproute, phone, forward, numbers, user] 93 transactions committed, 0 aborted, 9 restarted, 0 logged to disc 0 held locks, 0 in queue; 0 local transactions, 0 remote 0 transactions waits for other nodes: [] ok (root@REDACTED)58> rpc:call('appserver@REDACTED', mnesia, info, []). ---> Processes holding locks <--- ---> Processes waiting for locks <--- ---> Participant transactions <--- ---> Coordinator transactions <--- ---> Uncertain transactions <--- ---> Active tables <--- schema : with 10 records occupying 1569 words of mem call : with 0 records occupying 279 words of mem ===> System info in version "4.3.2", debug level = none <=== opt_disc. Directory "/var/yxa/mnesia/appserver" is NOT used. use fallback at restart = false running db nodes = ['root@REDACTED','appserver@REDACTED','eventserver@REDACTED','outgoingproxy@REDACTED','pstnproxy@REDACTED','incomingproxy@REDACTED','eventserver@REDACTED','pstnproxy@REDACTED','incomingproxy@REDACTED','outgoingproxy@REDACTED','appserver@REDACTED'] stopped db nodes = ['root@REDACTED','pstnproxy@REDACTED'] master node tables = [] remote = [cpl_script_graph, eventdata, forward, gruu, numbers, phone, regexproute, user] ram_copies = [call,schema] disc_copies = [] disc_only_copies = [] [{'appserver@REDACTED',ram_copies}, {'appserver@REDACTED',ram_copies}] = [call] [{'appserver@REDACTED',ram_copies}, {'appserver@REDACTED',ram_copies}, {'eventserver@REDACTED',ram_copies}, {'eventserver@REDACTED',ram_copies}, {'incomingproxy@REDACTED',disc_copies}, {'incomingproxy@REDACTED',disc_copies}, {'outgoingproxy@REDACTED',ram_copies}, {'outgoingproxy@REDACTED',ram_copies}, {'pstnproxy@REDACTED',ram_copies}, {'pstnproxy@REDACTED',ram_copies}, {'root@REDACTED',ram_copies}] = [schema] [{'eventserver@REDACTED',ram_copies}, {'eventserver@REDACTED',ram_copies}, {'incomingproxy@REDACTED',disc_copies}, {'incomingproxy@REDACTED',disc_copies}] = [eventdata] [{'incomingproxy@REDACTED',disc_copies}, {'incomingproxy@REDACTED',disc_copies}] = [gruu, cpl_script_graph, regexproute, phone, forward, numbers, user] 759 transactions committed, 0 aborted, 0 restarted, 0 logged to disc 0 held locks, 0 in queue; 0 local transactions, 0 remote 0 transactions waits for other nodes: [] ok (root@REDACTED)59> /Fredrik From ke.han@REDACTED Fri Sep 29 14:27:12 2006 From: ke.han@REDACTED (ke han) Date: Fri, 29 Sep 2006 20:27:12 +0800 Subject: [erlang-questions] F# and Nemerle In-Reply-To: <451CFE7E.8050502@mail.ru> References: <4516ACDC.5080900@duomark.com> <451CFE7E.8050502@mail.ru> Message-ID: <6A6EA07F-D5E1-4037-97B4-0C8A063B8DB7@redstarling.com> These language are interesting...nemerle is more like scala than erlang. I read the recent paper on scala attempts to handle erlang style concurrency. If they are successful, thats a big step. I haven't seen anything from nemerle on handling concurrency as a first class language _and_ VM behavior as done in erlang...nermerle and erlang are two very different animals so far as I can see. ke han On Sep 29, 2006, at 7:07 PM, Nick Linker wrote: > Jay Nelson wrote: >> Anyone had experience using either of these languages on .NET with >> Visual Studio? How about on mono? Are they stable enough for real >> work? Did you find any advantages or disadvantages in using them? >> >> jay > There is group of Nemerle users in Russian Software Developer Network. > Accordingly to their words, Nemerle is the most advanced language > ever. :-) > > There is significant progress in the work over the Nemerle plugin for > Visual Studio. You can look at the small report about the plugin > abilities at http://rsdn.ru/forum/Message.aspx?mid=2056038&only=1. The > language is russian, but the page contains a number of screenshots, > so I > think you probably will not have problems with understanding. > Otherwise, > I could translate it to you, if you will need. > > Mono is primordial platform for the developers of Nemerle, so there > shouldn't be any problems with it. > > The core is stable, but in standard macros there are number of little > issues, although the issues are being fixed quite fast. > > Best regards, > Nick. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From yan.guiborat@REDACTED Fri Sep 29 14:35:28 2006 From: yan.guiborat@REDACTED (netboz) Date: Fri, 29 Sep 2006 05:35:28 -0700 (PDT) Subject: [erlang-questions] Very small question about sserl Message-ID: <6564106.post@talk.nabble.com> Hi, This somehow follows my previous question about mnesia permissions and processes. I founded that the solution I was looking for has been implemented as a prototype named sserl. Sadly, there is no place to get it (I'm waiting for an answer from Dr Brown) I was wondering if anyone could give me more information about this prototype. I hope I am not waking up an old polemic, as this prototype represent a branch beside OTP. Wishing a nice day to everybody on this forum. -- View this message in context: http://www.nabble.com/Very-small-question-about-sserl-tf2356628.html#a6564106 Sent from the Erlang Questions mailing list archive at Nabble.com. From dgud@REDACTED Fri Sep 29 14:43:29 2006 From: dgud@REDACTED (Dan Gudmundsson) Date: Fri, 29 Sep 2006 14:43:29 +0200 Subject: [erlang-questions] Mnesia inconsistency with R11B-1 In-Reply-To: <200609291415.45734.ft@it.su.se> References: <200609291415.45734.ft@it.su.se> Message-ID: <17693.5361.875942.776861@rian.du.uab.ericsson.se> Ouch, how did you manage to do that... Call mnesia_lib:coredump() on both appservers. zip and email me privatly. Probably it's to late to find something but I will have a look at it. /Dan Fredrik Thulin writes: > Hi > > I upgraded from R10B-10 to R11B-1 about a week ago. Today I got a > problem report that seems to be because I have inconsistencies in my > Mnesia table 'phone'. > > On node #1, a record is present that is not present on node #2 : > > (root@REDACTED)49> rpc:call('appserver@REDACTED', phone, > get_sipuser_locations, ["username"]). > {ok,[{siplocationdb_e,{sipurl,"sip", > ... > 1159532776}]} > > (root@REDACTED)50> rpc:call('appserver@REDACTED', phone, > get_sipuser_locations, ["username"]). > {ok,[]} > (root@REDACTED)51> > > This table is written to from at least four different nodes, but always > using transactions and never with dirty writes. What should I do to > figure out the cause of this? I will have to restart the nodes at the > latest before Monday morning to get everything working again, but if > you guys are quick I can do diagnostics on the running system =). > > It seems to me that there is no partitioned network (both nodes list the > same nodes as 'running'). > > Another indicator of the differences, and also mnesia:info() output from > the two nodes : > > (root@REDACTED)55> length( rpc:call('appserver@REDACTED', db_util, > tab_to_list, [phone]) ). > 63 > (root@REDACTED)56> length( rpc:call('appserver@REDACTED', db_util, > tab_to_list, [phone]) ). > 58 > (root@REDACTED)57> rpc:call('appserver@REDACTED', mnesia, info, []). > ---> Processes holding locks <--- > ---> Processes waiting for locks <--- > ---> Participant transactions <--- > ---> Coordinator transactions <--- > ---> Uncertain transactions <--- > ---> Active tables <--- > schema : with 10 records occupying 1569 words of mem > call : with 0 records occupying 279 words of mem > ===> System info in version "4.3.2", debug level = none <=== > opt_disc. Directory "/var/yxa/mnesia/appserver" is NOT used. > use fallback at restart = false > running db nodes = > ['root@REDACTED','eventserver@REDACTED','incomingproxy@REDACTED','pstnproxy@REDACTED','appserver@REDACTED','outgoingproxy@REDACTED','outgoingproxy@REDACTED','incomingproxy@REDACTED','eventserver@REDACTED','pstnproxy@REDACTED','appserver@REDACTED'] > stopped db nodes = ['root@REDACTED','pstnproxy@REDACTED'] > master node tables = [] > remote = [cpl_script_graph, > eventdata, > forward, > gruu, > numbers, > phone, > regexproute, > user] > ram_copies = [call,schema] > disc_copies = [] > disc_only_copies = [] > [{'appserver@REDACTED',ram_copies}, > {'appserver@REDACTED',ram_copies}] = [call] > [{'appserver@REDACTED',ram_copies}, > {'appserver@REDACTED',ram_copies}, > {'eventserver@REDACTED',ram_copies}, > {'eventserver@REDACTED',ram_copies}, > {'incomingproxy@REDACTED',disc_copies}, > {'incomingproxy@REDACTED',disc_copies}, > {'outgoingproxy@REDACTED',ram_copies}, > {'outgoingproxy@REDACTED',ram_copies}, > {'pstnproxy@REDACTED',ram_copies}, > {'pstnproxy@REDACTED',ram_copies}, > {'root@REDACTED',ram_copies}] = [schema] > [{'eventserver@REDACTED',ram_copies}, > {'eventserver@REDACTED',ram_copies}, > {'incomingproxy@REDACTED',disc_copies}, > {'incomingproxy@REDACTED',disc_copies}] = [eventdata] > [{'incomingproxy@REDACTED',disc_copies}, > {'incomingproxy@REDACTED',disc_copies}] = [gruu, > cpl_script_graph, > regexproute, > phone, > forward, > numbers, > user] > 93 transactions committed, 0 aborted, 9 restarted, 0 logged to disc > 0 held locks, 0 in queue; 0 local transactions, 0 remote > 0 transactions waits for other nodes: [] > ok > (root@REDACTED)58> rpc:call('appserver@REDACTED', mnesia, info, []). > ---> Processes holding locks <--- > ---> Processes waiting for locks <--- > ---> Participant transactions <--- > ---> Coordinator transactions <--- > ---> Uncertain transactions <--- > ---> Active tables <--- > schema : with 10 records occupying 1569 words of mem > call : with 0 records occupying 279 words of mem > ===> System info in version "4.3.2", debug level = none <=== > opt_disc. Directory "/var/yxa/mnesia/appserver" is NOT used. > use fallback at restart = false > running db nodes = > ['root@REDACTED','appserver@REDACTED','eventserver@REDACTED','outgoingproxy@REDACTED','pstnproxy@REDACTED','incomingproxy@REDACTED','eventserver@REDACTED','pstnproxy@REDACTED','incomingproxy@REDACTED','outgoingproxy@REDACTED','appserver@REDACTED'] > stopped db nodes = ['root@REDACTED','pstnproxy@REDACTED'] > master node tables = [] > remote = [cpl_script_graph, > eventdata, > forward, > gruu, > numbers, > phone, > regexproute, > user] > ram_copies = [call,schema] > disc_copies = [] > disc_only_copies = [] > [{'appserver@REDACTED',ram_copies}, > {'appserver@REDACTED',ram_copies}] = [call] > [{'appserver@REDACTED',ram_copies}, > {'appserver@REDACTED',ram_copies}, > {'eventserver@REDACTED',ram_copies}, > {'eventserver@REDACTED',ram_copies}, > {'incomingproxy@REDACTED',disc_copies}, > {'incomingproxy@REDACTED',disc_copies}, > {'outgoingproxy@REDACTED',ram_copies}, > {'outgoingproxy@REDACTED',ram_copies}, > {'pstnproxy@REDACTED',ram_copies}, > {'pstnproxy@REDACTED',ram_copies}, > {'root@REDACTED',ram_copies}] = [schema] > [{'eventserver@REDACTED',ram_copies}, > {'eventserver@REDACTED',ram_copies}, > {'incomingproxy@REDACTED',disc_copies}, > {'incomingproxy@REDACTED',disc_copies}] = [eventdata] > [{'incomingproxy@REDACTED',disc_copies}, > {'incomingproxy@REDACTED',disc_copies}] = [gruu, > cpl_script_graph, > regexproute, > phone, > forward, > numbers, > user] > 759 transactions committed, 0 aborted, 0 restarted, 0 logged to disc > 0 held locks, 0 in queue; 0 local transactions, 0 remote > 0 transactions waits for other nodes: [] > ok > (root@REDACTED)59> > > /Fredrik > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From dmitriid@REDACTED Fri Sep 29 14:46:19 2006 From: dmitriid@REDACTED (Dmitrii Dimandt) Date: Fri, 29 Sep 2006 15:46:19 +0300 Subject: [erlang-questions] F# and Nemerle In-Reply-To: <6A6EA07F-D5E1-4037-97B4-0C8A063B8DB7@redstarling.com> References: <4516ACDC.5080900@duomark.com> <451CFE7E.8050502@mail.ru> <6A6EA07F-D5E1-4037-97B4-0C8A063B8DB7@redstarling.com> Message-ID: Also, the very active Russian group of Nemerle enthusiasts have said that they would like to introduce lightweight concurrency to Nemerle as well, probably in the form of active objects. See this message (in Russian). It says the following: Erlang is next on our agenda after integrating Nemerle into Visual Studio. That is, we are going to try and implement the idea of concurrency. However, it's a wiser to implement active objects in hybrid languages rather than processes. On 9/29/06, ke han wrote: > > These language are interesting...nemerle is more like scala than > erlang. I read the recent paper on scala attempts to handle erlang > style concurrency. If they are successful, thats a big step. I > haven't seen anything from nemerle on handling concurrency as a first > class language _and_ VM behavior as done in erlang...nermerle and > erlang are two very different animals so far as I can see. > > ke han > > On Sep 29, 2006, at 7:07 PM, Nick Linker wrote: > > > Jay Nelson wrote: > >> Anyone had experience using either of these languages on .NET with > >> Visual Studio? How about on mono? Are they stable enough for real > >> work? Did you find any advantages or disadvantages in using them? > >> > >> jay > > There is group of Nemerle users in Russian Software Developer Network. > > Accordingly to their words, Nemerle is the most advanced language > > ever. :-) > > > > There is significant progress in the work over the Nemerle plugin for > > Visual Studio. You can look at the small report about the plugin > > abilities at http://rsdn.ru/forum/Message.aspx?mid=2056038&only=1. The > > language is russian, but the page contains a number of screenshots, > > so I > > think you probably will not have problems with understanding. > > Otherwise, > > I could translate it to you, if you will need. > > > > Mono is primordial platform for the developers of Nemerle, so there > > shouldn't be any problems with it. > > > > The core is stable, but in standard macros there are number of little > > issues, although the issues are being fixed quite fast. > > > > Best regards, > > Nick. > > _______________________________________________ > > 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 goran.bage@REDACTED Fri Sep 29 15:13:34 2006 From: goran.bage@REDACTED (=?ISO-8859-1?Q?G=F6ran_B=E5ge?=) Date: Fri, 29 Sep 2006 15:13:34 +0200 Subject: [erlang-questions] Mnesia questions Message-ID: <451D1BFE.1060600@mobilearts.com> Hi, I have a couple of mnesia questions. The background is that I'm implementing a mechanism to recover a database that has been partitioned and then reconnected. To be able to recover, all relevant table events are recorded to file locally. When a table is recovered I want to lock the table for other modifications. This is no problem if the recovery is done in one transaction, but the number of recorded events may be large so it might be wise to do it in chunks, one transaction per chunk. So now to my questions: 1. What is a reasonable upper limit of number of table update events for one transaction? 2. Is it possible to lock a table outside transactions and if so how is it unlocked? 3. Any other advice or pointers? I guess this recovery problem has been addressed by others. PS. We are still running R9C. Regards -- -- Goran ------------------------- May the Snow be with you ---- Goran Bage, MobileArts, www.mobilearts.com Tjarhovsgatan 56, SE-116 28 Stockholm, Sweden email:goran.bage@REDACTED, phone: +46 733 358405 From tobbe@REDACTED Fri Sep 29 15:44:42 2006 From: tobbe@REDACTED (Torbjorn Tornkvist) Date: Fri, 29 Sep 2006 15:44:42 +0200 Subject: [erlang-questions] ejabberd 1.1.2 released In-Reply-To: <20060927215204.GC7458@memphis> References: <20060927215204.GC7458@memphis> Message-ID: Mickael Remond wrote: > Hello, > > A new major version of ejabberd has been released! Sounds great! > Recent changes include: > > LDAP Improvements > > - Major improvements have been made on the LDAP module. It is now more > flexible and more robust. I belive you are using the eldap code originally from jungerl. Would is be possible to feed back the improvements you have done into the jungerl code ? Cheers, Tobbe From simonpeterchappell@REDACTED Fri Sep 29 15:46:41 2006 From: simonpeterchappell@REDACTED (Simon Chappell) Date: Fri, 29 Sep 2006 08:46:41 -0500 Subject: [erlang-questions] Intel and 80 cores In-Reply-To: <9A806A57-3852-4400-8EA5-235A669873E9@redstarling.com> References: <451CABEA.8010009@duomark.com> <9A806A57-3852-4400-8EA5-235A669873E9@redstarling.com> Message-ID: <8ed733900609290646x76d83a07v1d7caa0ee4f35715@mail.gmail.com> On 9/29/06, ke han wrote: > ...and don't expect Word to get any faster, less bloated or more > secure... Yeah, it's bad when it can barely even keep up with my hunt and peck typing style. Just think how frustrated I'd be if I'd ever learned to touchtype! Simon -- simonpeter.org | simonpeter.com | techbook.info From mats.cronqvist@REDACTED Fri Sep 29 15:57:12 2006 From: mats.cronqvist@REDACTED (Mats Cronqvist) Date: Fri, 29 Sep 2006 15:57:12 +0200 Subject: [erlang-questions] Intel and 80 cores In-Reply-To: <451CABEA.8010009@duomark.com> References: <451CABEA.8010009@duomark.com> Message-ID: <451D2638.5070601@ericsson.com> Jay Nelson wrote: > Just imagine how fast Microsoft Word will be! blindingly fast as soon as MS figures out how to multithread it... what i'd like to know is how you cool a 80 core, 3 GHz chip... mats From simonpeterchappell@REDACTED Fri Sep 29 16:11:14 2006 From: simonpeterchappell@REDACTED (Simon Chappell) Date: Fri, 29 Sep 2006 09:11:14 -0500 Subject: [erlang-questions] Intel and 80 cores In-Reply-To: <451D2638.5070601@ericsson.com> References: <451CABEA.8010009@duomark.com> <451D2638.5070601@ericsson.com> Message-ID: <8ed733900609290711v645a5e9eue23d88148f4e954d@mail.gmail.com> On 9/29/06, Mats Cronqvist wrote: > what i'd like to know is how you cool a 80 core, 3 GHz chip... It ships with its own iceberg. Sadly, this product will not be available in equatorial regions. :-) Simon -- simonpeter.org | simonpeter.com | techbook.info From ulf.wiger@REDACTED Fri Sep 29 16:21:29 2006 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Fri, 29 Sep 2006 16:21:29 +0200 Subject: [erlang-questions] Mnesia questions In-Reply-To: <451D1BFE.1060600@mobilearts.com> Message-ID: G?ran B?ge wrote: > > 1. What is a reasonable upper limit of number of table update > events for one transaction? I'm not sure. The transaction store is an ets table, so it's not limited per se. Available memory will of course impose limits, and if the table is replicated, the commit record with all the updates is sent in one message.... > 2. Is it possible to lock a table outside transactions and if > so how is it unlocked? The only thing I know of is mnesia_controller:block_tab(Tab) and mnesia_controller:unblock_tab(Tab). This causes dirty ops to be queued until the table is unblocked. If you want to block a table spanning several transactions, I don't know how to do that easily. You could introduce a critical section of your own, e.g. through the use of global:trans(), but this would of course have to be honoured by all transactions, always. Doing it all in one transaction might be preferable, unless you start running out of memory. I know that mnesia:transform_table(), when used on very large tables, can use a great deal of memory. A dirty, dirty workaround is to start a transaction, lock the table, and roll in the updates through dirty ops. This is dangerous, of course, so your recourse might be to reload from backup, if things start failing. > 3. Any other advice or pointers? I guess this recovery > problem has been addressed by others. Use '-kernel dist_auto_connect once' This will keep the nodes from reconnecting spontaneously, giving you a better chance to resolve the situation in an orderly fashion. BR, Ulf W From hev@REDACTED Fri Sep 29 18:17:16 2006 From: hev@REDACTED (Evgeniy Khramtsov) Date: Sat, 30 Sep 2006 02:17:16 +1000 Subject: [erlang-questions] ejabberd 1.1.2 released In-Reply-To: References: <20060927215204.GC7458@memphis> Message-ID: <451D470C.3050000@sbyt.amur.elektra.ru> Torbjorn Tornkvist ?????: >I belive you are using the eldap code originally from jungerl. >Would is be possible to feed back the improvements you have done >into the jungerl code ? > There are no changes in eldap.erl. The main improvements are internally in ejabberd's code. From cyberlync@REDACTED Fri Sep 29 23:45:06 2006 From: cyberlync@REDACTED (Eric Merritt) Date: Fri, 29 Sep 2006 14:45:06 -0700 Subject: [erlang-questions] cdata in xmerl:export_simple Message-ID: Guys, Is there a way to specify a cdata section in xmerls export_simple format? Thanks, Eric From datacompboy@REDACTED Sat Sep 30 08:08:12 2006 From: datacompboy@REDACTED (datacompboy) Date: Sat, 30 Sep 2006 07:08:12 +0100 Subject: [erlang-questions] Mnesia: select random record References: Message-ID: <20060930060813.208885A1E9@mail.erlangsystems.com> Hello, all! I have asked @trapexit, but think there will wider discussion... How effective select an random record from mnesia table? I have table with user statuses: {us, id, status}. I have additional index on status field. And I need to get any random record with status=X. Any easy and fast way? Or only have tables for every status, and then: Table=list_to_atom("status"++"_"++X), X=mnesia:table_size(Table), record=mnesia_geti(Table, random:uniform(X)) ? There about 4-5 (and may be extended to 10-12 later) of statuses, and about 1000 IDs, that query called often (about 10-30 times per second), so I can left just read on whole table, but question intersting in general. -- --- suicide proc near\n call death\n suicide endp _________________________________________________________ Post sent from http://www.trapexit.org From datacompboy@REDACTED Sat Sep 30 08:13:32 2006 From: datacompboy@REDACTED (Anton Fedorov) Date: Sat, 30 Sep 2006 13:13:32 +0700 Subject: [erlang-questions] mnesia, log tables Message-ID: <1658220675.20060930131332@call2ru.com> Hello, erlang-questions. How to write effectively log of operations, so later I will able to effectively select part for some time and build some statistics? Mnesia doesn't have, as I see, compound indexes and read of range... May be just do compound fields? since in general I need in montly blocks, add to record key yearmonth (f.e. 200609) and add index for it? -- Best regards, Anton Call2Ru Service datacompboy@REDACTED -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 250 bytes Desc: not available URL: From xlcr@REDACTED Sat Sep 30 11:37:11 2006 From: xlcr@REDACTED (Nick Linker) Date: Sat, 30 Sep 2006 16:37:11 +0700 Subject: [erlang-questions] F# and Nemerle In-Reply-To: References: <4516ACDC.5080900@duomark.com> <451CFE7E.8050502@mail.ru> <6A6EA07F-D5E1-4037-97B4-0C8A063B8DB7@redstarling.com> Message-ID: <451E3AC7.5090808@mail.ru> Dmitrii Dimandt wrote: > Also, the very active Russian group of Nemerle enthusiasts have said > that they would like to introduce lightweight concurrency to Nemerle > as well, probably in the form of active objects. > > See this message > (in > Russian). It says the following: > Erlang is next on our agenda after integrating Nemerle into Visual > Studio. That is, we are going to try and implement the idea of > concurrency. However, it's a wiser to implement active objects in > hybrid languages rather than processes. Heh, Martin Odersky's team have done this already :-) Best regards, Nick From qrilka@REDACTED Sat Sep 30 11:47:51 2006 From: qrilka@REDACTED (Kirill Zaborski) Date: Sat, 30 Sep 2006 13:47:51 +0400 Subject: [erlang-questions] F# and Nemerle In-Reply-To: <451E3AC7.5090808@mail.ru> References: <4516ACDC.5080900@duomark.com> <451CFE7E.8050502@mail.ru> <6A6EA07F-D5E1-4037-97B4-0C8A063B8DB7@redstarling.com> <451E3AC7.5090808@mail.ru> Message-ID: <337538cb0609300247v3aeb52c7v7c6566976b3eddb9@mail.gmail.com> You mean their work in Scala? That was not Nemerle and thus not .Net but Java VM :) I've posted links to those works to RSDN.ru On 9/30/06, Nick Linker wrote: > > Dmitrii Dimandt wrote: > > Also, the very active Russian group of Nemerle enthusiasts have said > > that they would like to introduce lightweight concurrency to Nemerle > > as well, probably in the form of active objects. > > > > See this message > > (in > > Russian). It says the following: > > Erlang is next on our agenda after integrating Nemerle into Visual > > Studio. That is, we are going to try and implement the idea of > > concurrency. However, it's a wiser to implement active objects in > > hybrid languages rather than processes. > Heh, Martin Odersky's team have done this already :-) > > Best regards, > Nick > _______________________________________________ > 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 Sat Sep 30 12:26:06 2006 From: chsu79@REDACTED (Christian S) Date: Sat, 30 Sep 2006 12:26:06 +0200 Subject: [erlang-questions] Mnesia: select random record In-Reply-To: <20060930060813.208885A1E9@mail.erlangsystems.com> References: <20060930060813.208885A1E9@mail.erlangsystems.com> Message-ID: What are you really trying to accomplish? Maybe you could traverse the whole table for their primary keys, then permute that list to get a sequence of records in random order? Do you want some kind of fair scheduling? Then maybe you want to build a scheduler that subscribes to table events so it can remove and add records to the scheduler as the table change? On 9/30/06, datacompboy wrote: > > Hello, all! > > I have asked @trapexit, but think there will wider discussion... > > How effective select an random record from mnesia table? > I have table with user statuses: > {us, id, status}. > I have additional index on status field. > And I need to get any random record with status=X. > > Any easy and fast way? > Or only have tables for every status, and then: > Table=list_to_atom("status"++"_"++X), > X=mnesia:table_size(Table), > record=mnesia_geti(Table, random:uniform(X)) > ? > > There about 4-5 (and may be extended to 10-12 later) of statuses, and about 1000 IDs, that query called often (about 10-30 times per second), so I can left just read on whole table, but question intersting in general. > -- > --- suicide proc near\n call death\n suicide endp > _________________________________________________________ > Post sent from http://www.trapexit.org > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From datacompboy@REDACTED Sat Sep 30 12:35:10 2006 From: datacompboy@REDACTED (datacompboy) Date: Sat, 30 Sep 2006 11:35:10 +0100 Subject: [erlang-questions] Benchmark on arg matching References: Message-ID: <20060930103510.2223C5A1F4@mail.erlangsystems.com> For soap-message router, I have lot of soap(R) when is_record(R,'p:Req1') -> req1(R); code "Interest, will be faster, if I write soap(#'p:Req1'{} = R) -> req1(R) ?", so I get benchmark from efficiency_guide, and eval following tests: For benchmarking of only simple call rounter: foo(_T) -> ok. foo_unboundrec_l(#test{}=T) -> foo(T),ok; foo_unboundrec_l(_) -> io:format("error!"). foo_unboundrec_r(T=#test{}) -> foo(T),ok; foo_unboundrec_r(_) -> io:format("error!"). foo_parboundrec_l(#test{f1=_F1,f3=_F3}=T) -> foo(T),ok; foo_parboundrec_l(_) -> io:format("error!"). foo_parboundrec_r(T=#test{f1=_F1,f3=_F3}) -> foo(T),ok; foo_parboundrec_r(_) -> io:format("error!"). foo_allboundrec_l(#test{f1=_F1,f2=_F2,f3=_F3,f4=_F4}=T) -> foo(T),ok; foo_allboundrec_l(_) -> io:format("error!"). foo_allboundrec_r(T=#test{f1=_F1,f2=_F2,f3=_F3,f4=_F4}) -> foo(T),ok; foo_allboundrec_r(_) -> io:format("error!"). foo_allboundrec(#test{f1=F1,f2=F2,f3=F3,f4=F4}) -> foo(#test{f1=F1,f2=F2,f3=F3,f4=F4}),ok; foo_allboundrec(_) -> io:format("error!"). foo_whenisrec(T) when is_record(T, test) -> foo(T),ok; foo_whenisrec(_) -> io:format("error!"). Here is results: Test allboundrec_r 1.00 unboundrec_l 1.00 parboundrec_l 1.02 allboundrec_l 1.02 whenisrec 1.02 unboundrec_r 1.06 parboundrec_r 1.06 allboundrec 1.83 -- no difference, except of its expensive to build record from scratch. But if you needed in part of record here, in router: foo_unboundrec_l(#test{}=T) -> foo(T),T#test.f1,T#test.f3,ok; foo_unboundrec_l(_) -> io:format("error!"). foo_unboundrec_r(T=#test{}) -> foo(T),T#test.f1,T#test.f3,ok; foo_unboundrec_r(_) -> io:format("error!"). foo_parboundrec_l(#test{f1=F1,f3=F3}=T) -> foo(T),F1,F3,ok; foo_parboundrec_l(_) -> io:format("error!"). foo_parboundrec_r(T=#test{f1=F1,f3=F3}) -> foo(T),F1,F3,ok; foo_parboundrec_r(_) -> io:format("error!"). foo_allboundrec_l(#test{f1=F1,f2=_F2,f3=F3,f4=_F4}=T) -> foo(T),F1,F3,ok; foo_allboundrec_l(_) -> io:format("error!"). foo_allboundrec_r(T=#test{f1=F1,f2=_F2,f3=F3,f4=_F4}) -> foo(T),F1,F3,ok; foo_allboundrec_r(_) -> io:format("error!"). foo_allboundrec(#test{f1=F1,f2=F2,f3=F3,f4=F4}) -> foo(#test{f1=F1,f2=F2,f3=F3,f4=F4}),F1,F3,ok; foo_allboundrec(_) -> io:format("error!"). foo_whenisrec(T) when is_record(T, test) -> foo(T),T#test.f1,T#test.f3,ok; foo_whenisrec(_) -> io:format("error!"). foo_whenisrec_ml(T) when is_record(T, test) -> #test{f1=F1,f3=F3}=T,foo(T),F1,F3,ok; foo_whenisrec_ml(_) -> io:format("error!"). I'm got such result: parboundrec_l 1.00 allboundrec_r 1.00 allboundrec_l 1.02 unboundrec_l 1.25 whenisrec_ml 1.25 unboundrec_r 1.25 whenisrec 1.37 parboundrec_r 1.58 allboundrec 2.00 So, if you needed in part of result, better to match in header, than use "when is_record()". -- --- suicide proc near\n call death\n suicide endp _________________________________________________________ Post sent from http://www.trapexit.org From datacompboy@REDACTED Sat Sep 30 12:38:47 2006 From: datacompboy@REDACTED (datacompboy) Date: Sat, 30 Sep 2006 11:38:47 +0100 Subject: [erlang-questions] Mnesia: select random record References: Message-ID: <20060930103847.B4DA75A1F7@mail.erlangsystems.com> noss wrote: What are you really trying to accomplish? (end of quote) I have several group of advisers, and once got incoming call need to get random adviser from corresponding pool. -- --- suicide proc near\n call death\n suicide endp _________________________________________________________ Post sent from http://www.trapexit.org From richardc@REDACTED Sat Sep 30 13:12:03 2006 From: richardc@REDACTED (Richard Carlsson) Date: Sat, 30 Sep 2006 13:12:03 +0200 Subject: [erlang-questions] scope of variables In-Reply-To: <95be1d3b0609290439k32b482a6v4cc0cd7f5e8629f3@mail.gmail.com> References: <44FBD154.1010103@it.uu.se> <95be1d3b0609040114i255f0164qdc1998a9792ab3e5@mail.gmail.com> <44FC0ABD.7080309@it.uu.se> <95be1d3b0609040436w2b067228y679c115f750b98d5@mail.gmail.com> <44FC2450.60407@it.uu.se> <95be1d3b0609040617o755f02fj224dddc80d9ca1c9@mail.gmail.com> <4518512F.8090802@it.uu.se> <95be1d3b0609290439k32b482a6v4cc0cd7f5e8629f3@mail.gmail.com> Message-ID: <451E5103.20107@it.uu.se> Vlad Dumitrescu wrote: > That's cool to know! However, if one needs something less simple than > just loop unrolling, then another approach is needed. > > A few other applications of this "compile a customized variant of this > function given these static parameters" could be > > * sparse vector multiplication, where all zero elements would just > eliminated from the calculation > * regexps, where it is possible (but I'm not sure if it applies to the > general case) to generate specializations of the generic algorithm > that are very close to hand-crafted variants. Yes, the inliner is not a full partial evaluator. Still, it can do quite a lot of specialization on the code that it decides to inline. (It's a really cool algorithm, much better than traditional inliners.) /Richard From richardc@REDACTED Sat Sep 30 13:16:44 2006 From: richardc@REDACTED (Richard Carlsson) Date: Sat, 30 Sep 2006 13:16:44 +0200 Subject: [erlang-questions] cdata in xmerl:export_simple In-Reply-To: References: Message-ID: <451E521C.1090101@it.uu.se> Eric Merritt wrote: > Guys, > > Is there a way to specify a cdata section in xmerls export_simple format? Not that I can remember, but it's a pretty good idea. If you add such a capability and submit a patch, I'm sure it will be included. /Richard From chsu79@REDACTED Sat Sep 30 13:25:17 2006 From: chsu79@REDACTED (Christian S) Date: Sat, 30 Sep 2006 13:25:17 +0200 Subject: [erlang-questions] Fwd: mnesia, log tables In-Reply-To: References: <1658220675.20060930131332@call2ru.com> Message-ID: Seems like I accidently missed to reply to the list. ---------- Forwarded message ---------- From: Christian S Date: Sep 30, 2006 12:55 PM Subject: Re: [erlang-questions] mnesia, log tables To: Anton Fedorov I have a similar database structure. It is a log for product orders. I keep one table with orders: {OrderId, Status, LastSerial} and another table with log events on that order: {{OrderId, Serial}, LogData} To summarize all data logged about an order I query the OrderId to find out the LastSerial and then read each logged item {OrderId, 0} to {OrderId, LastSerial}. And yes, this is code that performs 1 + LastSerial mnesia:reads, no hidden query in the mnesia module that reads a range. You ask for how to find the logged items that happened in a given time period. This is simply a table that you have to update manually each time you add a new log item. Compound key as you guessed. The table would look something like {{OrderId, Period}, BeginSerial, EndSerial}. This way you can prune old processed periods to keep this "index" table small. This is something you couldnt do if you instead added an index on an additional compound column of {OrderId, Period} to each logg item. I have often wished for the ability to hook som kind of 'tail transaction handlers' that can inspect changes to tables and update these kind of compound indexes behind the curtains. Those are probably easy to get wrong though. I need to inspect 'rdbms' that Ulf Wiger keeps teasing about to see what it can offer. On 9/30/06, Anton Fedorov wrote: > Hello, erlang-questions. > > How to write effectively log of operations, so later I will able to > effectively select part for some time and build some statistics? > > Mnesia doesn't have, as I see, compound indexes and read of range... > > May be just do compound fields? since in general I need in montly > blocks, add to record key yearmonth (f.e. 200609) and add index for > it? > From chsu79@REDACTED Sat Sep 30 13:07:10 2006 From: chsu79@REDACTED (Christian S) Date: Sat, 30 Sep 2006 13:07:10 +0200 Subject: [erlang-questions] Mnesia: select random record In-Reply-To: <20060930103847.B4DA75A1F7@mail.erlangsystems.com> References: <20060930103847.B4DA75A1F7@mail.erlangsystems.com> Message-ID: There is something wrong with threading in your email client I think. It sounds to me like you want a fair scheduler among unoccupised advisers for each pool of advicer? The approach where you query a mnesia record at random is just one way to implement this fair scheduler. Can you revise this idea to try something different that will accomplish the same? On 9/30/06, datacompboy wrote: > > > noss wrote: > What are you really trying to accomplish? > (end of quote) > > > I have several group of advisers, and once got incoming call need to get random adviser from corresponding pool. > -- > --- suicide proc near\n call death\n suicide endp > _________________________________________________________ > Post sent from http://www.trapexit.org > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From datacompboy@REDACTED Sat Sep 30 14:19:49 2006 From: datacompboy@REDACTED (datacompboy) Date: Sat, 30 Sep 2006 13:19:49 +0100 Subject: [erlang-questions] Mnesia: select random record References: Message-ID: <20060930121949.51C615A1E9@mail.erlangsystems.com> noss wrote: There is something wrong with threading in your email client I think. (end of quote) I'm use forum interface to that maillist from trapexit.org noss wrote: It sounds to me like you want a fair scheduler among unoccupised advisers for each pool of advicer? (end of quote) Correct. All free for now advisers at current moments should have equal chances to pick call. As for me, the way is: * count all free advisers (=X) * generate integer uniform noss wrote: h record. When every pool stored in its own table that easy -- just table_info(size), uniform(X), fisrt-next for Ith record (since no way to get Ith record directly). If all pools in one table (better, since pools are can be created/dropped dynamically), there need to traverse WHOLE table TWICE (i.e. -- full list of all pools). May be use mnesia_frag, and spread pools over fragments, so every fragment contains several full pools, and add fragments if one of pool grow large? [quote="noss"]Can you revise this idea to try something different that will accomplish the same? (end of quote) Sorry, what do you mean? -- --- suicide proc near\n call death\n suicide endp _________________________________________________________ Post sent from http://www.trapexit.org From chsu79@REDACTED Sat Sep 30 15:15:38 2006 From: chsu79@REDACTED (Christian S) Date: Sat, 30 Sep 2006 15:15:38 +0200 Subject: [erlang-questions] Mnesia: select random record In-Reply-To: <20060930121949.51C615A1E9@mail.erlangsystems.com> References: <20060930121949.51C615A1E9@mail.erlangsystems.com> Message-ID: On 9/30/06, datacompboy wrote: > [quote="noss"]Can you revise this idea to try something different that will accomplish the same? > (end of quote) > > Sorry, what do you mean? I mean that perhaps you should consider other designs than scanning a table until you find the Nth record, where N is chosen at random. The problem you have has way more than one way to solve it, and it is difficult to sift through them to find optimal solutions without knowing estimates on various sizes (advisors in pools, number of pools, osv) and knowing what will have to scale. Storing {PoolId, [AdvisorId]} in one table, and having advisor data in another {AdvisorID, Data...} would allow you after only one query find all Advisors in a pool and pick one at random. Then one more query if you needed associated advisor data. Just take the advisor out of the pool the duration you're using it. From david.nospam.hopwood@REDACTED Sat Sep 30 20:05:32 2006 From: david.nospam.hopwood@REDACTED (David Hopwood) Date: Sat, 30 Sep 2006 19:05:32 +0100 Subject: [erlang-questions] Intel and 80 cores In-Reply-To: <451CABEA.8010009@duomark.com> References: <451CABEA.8010009@duomark.com> Message-ID: <451EB1EC.4030305@blueyonder.co.uk> Jay Nelson wrote: > Intel announces an 80 core chip within 5 years. It will have 20GB of > RAM and can perform at 1 TFLOP. > > http://news.com.com/Intel+pledges+80+cores+in+five+years/2100-1006_3-6119618.html?tag=nl > > http://news.com.com/Processor%2C+memory+may+marry+in+future+computers/2100-1006_3-6120547.html?tag=nefd.top > > Just imagine how fast Microsoft Word will be! Microsoft Word 2011 will be slower, of course ;-) More seriously, the effect will be to expose bottlenecks that are not dependent on raw processing throughput. Some applications' performance is already constrained by disk and network latency. -- David Hopwood From cyberlync@REDACTED Sat Sep 30 20:34:43 2006 From: cyberlync@REDACTED (Eric Merritt) Date: Sat, 30 Sep 2006 11:34:43 -0700 Subject: [erlang-questions] cdata in xmerl:export_simple In-Reply-To: <451E521C.1090101@it.uu.se> References: <451E521C.1090101@it.uu.se> Message-ID: I will take a look at doing that. For now you can just the cdata tags to the text of the element and it works fine. Its not elegant, but it works until we can get support for cdata in. On 9/30/06, Richard Carlsson wrote: > Eric Merritt wrote: > > Guys, > > > > Is there a way to specify a cdata section in xmerls export_simple format? > > Not that I can remember, but it's a pretty good idea. If you add such a > capability and submit a patch, I'm sure it will be included. > > /Richard > From yarivvv@REDACTED Sat Sep 30 22:46:47 2006 From: yarivvv@REDACTED (Yariv Sadan) Date: Sat, 30 Sep 2006 16:46:47 -0400 Subject: [erlang-questions] ErlyDB v0.7 Message-ID: <17244f480609301346l159160a7w6bcd95ec42d4abe0@mail.gmail.com> Hi, I released a new version of ErlyDB. It has a large number of new features and improvements. Here's the short list: - transactions - protection against SQL injection attacks - hooks - fine grained control on field visibility - user-defined table assignment - multiple modules per table - more auto-generated functions - aggregate functions - better error handling - multiple drivers per session, multiple databases per driver - efficient SQL generation The full story is here: http://yarivsblog.com/articles/2006/09/30/erlydb-0-7. Enjoy! And let me know if you find any bugs. Best regards, Yariv From cyberhigh@REDACTED Sat Sep 30 23:59:30 2006 From: cyberhigh@REDACTED (CyBerHigh) Date: Sat, 30 Sep 2006 15:59:30 -0600 Subject: [erlang-questions] Intel and 80 cores In-Reply-To: <451EB1EC.4030305@blueyonder.co.uk> References: <451CABEA.8010009@duomark.com> <451EB1EC.4030305@blueyonder.co.uk> Message-ID: <451EE8C2.4050501@gurusnetwork.org> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 David Hopwood wrote: > Jay Nelson wrote: >> Intel announces an 80 core chip within 5 years. It will have 20GB of >> RAM and can perform at 1 TFLOP. >> >> http://news.com.com/Intel+pledges+80+cores+in+five+years/2100-1006_3-6119618.html?tag=nl >> >> http://news.com.com/Processor%2C+memory+may+marry+in+future+computers/2100-1006_3-6120547.html?tag=nefd.top >> >> Just imagine how fast Microsoft Word will be! > > Microsoft Word 2011 will be slower, of course ;-) > > More seriously, the effect will be to expose bottlenecks that are not > dependent on raw processing throughput. Some applications' performance > is already constrained by disk and network latency. > Some applications... I would say most applications. I would be more impressed with a new hdd that allowed 3 G/s read and write speeds with 1 ms seek times. Sadly hdd are not the 'cool' thing people brag about. However as cpu and ram speeds get faster hdd will grow slightly. Hopefully there is a large leep in performance some day soon. However luckly languages like erlang would thrive in a world of 80 cpus. I imagine soon there will be a large push for languages to support concurrency the way erlang already does. CyBerHigh -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFFHujCi45r9jMsH7gRAlkJAJ0blvkqExX3UZR5I9yBvBDPLxpPIQCgmMdJ hP+V3gGDn10dbpjK+SspFRc= =nGBv -----END PGP SIGNATURE-----