From dizzyd@REDACTED Fri Apr 1 02:44:03 2011 From: dizzyd@REDACTED (Dave Smith) Date: Thu, 31 Mar 2011 18:44:03 -0600 Subject: [erlang-questions] Re: file operations on zipped files (Re: how to add a module to preLoaded?) In-Reply-To: <4BEEE64D-1FA3-41B9-B97B-1AFB0304BD9E@erlang-solutions.com> References: <4BEEE64D-1FA3-41B9-B97B-1AFB0304BD9E@erlang-solutions.com> Message-ID: On Thu, Mar 31, 2011 at 12:04 PM, Ulf Wiger wrote: > > Note that the compiler fetched proper.hrl et al from the run_proper.ez zip file, which contains PropEr as a single zip file. The idea (see http://github.com/esl/run_eqc) was that it should be possible to deliver an application as a single archive, supporting command-line operations, interactive code loading, and compilation including hrl files, parse_transforms etc., without having to unpack the archive. +1 on this feature -- it opens some very interesting doors. It's unfortunate that .so's require a file name (versus handle). I suppose one could work around this in individual libraries by copying the .so into /tmp before opening it. D. From corticalcomputer@REDACTED Fri Apr 1 06:21:01 2011 From: corticalcomputer@REDACTED (G.S.) Date: Thu, 31 Mar 2011 21:21:01 -0700 Subject: [erlang-questions] gs in R14B02 Message-ID: Hello, Can anyone confirm if gs was dropped in R14B02? Regards, -Gene -------------- next part -------------- An HTML attachment was scrubbed... URL: From boris.muehmer@REDACTED Fri Apr 1 06:44:06 2011 From: boris.muehmer@REDACTED (=?UTF-8?Q?Boris_M=C3=BChmer?=) Date: Fri, 1 Apr 2011 06:44:06 +0200 Subject: [erlang-questions] Re: gs in R14B02 In-Reply-To: References: Message-ID: Looking at "toolbar", "tv", "pman" I would say gs is still around. - boris 2011/4/1 G.S. : > Hello, > > Can anyone confirm if gs was dropped in R14B02? > > Regards, > -Gene > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > From xueyu32@REDACTED Fri Apr 1 09:35:17 2011 From: xueyu32@REDACTED (yu xue) Date: Fri, 1 Apr 2011 15:35:17 +0800 Subject: [erlang-questions] hi all, how to write the reltool config file to exclude .svn directory when making target system Message-ID: I made a project with erlang, now, I am using reltool to make target system. I am using svn to control the project version, so, there is a .svn directory in then priv directory, I want to exclude the .svn directory when makeing target system, the partial config rule I wrote as below, but it does not work, I wish anyone could help me ,thanks very much. {app,stress,[{incl_cond,include}, > {incl_app_filters,["^ebin/","^priv/"]}, > {incl_archive_filters,["^priv/"]}, > {excl_archive_filters,["\.svn"]} > ]} > -------------- next part -------------- An HTML attachment was scrubbed... URL: From olivier.boudeville@REDACTED Fri Apr 1 10:00:30 2011 From: olivier.boudeville@REDACTED (Olivier BOUDEVILLE) Date: Fri, 1 Apr 2011 10:00:30 +0200 Subject: [erlang-questions] Re: List comprehension questions In-Reply-To: <818442741.49161301593209500.JavaMail.root@zimbra> Message-ID: Hello Robert, Thanks for your explanation. I guess that the reversal (to restore the original list order after a first "if selected by filter then apply" traversal) is done then in the list:map/2 counterpart! My concern was that, for long lists which do not happen to have to respect any particular order in their elements, two traversals would be done with list comprehensions whereas just one could be sufficient. Well, a minor concern as for such cases we can write our own functions to do so in one pass. Thanks again, Best regards, Olivier Boudeville. --------------------------- Olivier Boudeville EDF R&D : 1, avenue du G?n?ral de Gaulle, 92140 Clamart, France D?partement SINETICS, groupe ASICS (I2A), bureau B-226 Office : +33 1 47 65 59 58 / Mobile : +33 6 16 83 37 22 / Fax : +33 1 47 65 27 13 robert.virding@REDACTED 31/03/2011 19:40 A olivier.boudeville@REDACTED cc erlang-questions@REDACTED Objet Re: [erlang-questions] List comprehension questions List comprehensions work as a combined lists:map and lists:filter. So you map over a list filtering out elements you don't want in the output list. They have the added functionality that they can handle this for nested lists. The expanded code is in fact quite simple and is close to what you probably write yourself. So order is preserved and their is no call to lists:reverse when generating the output list. Robert ----- "Olivier BOUDEVILLE" wrote: > > Hi, > > Reading http://www.erlang.org/doc/reference_manual/expressions.html#id77052 it is not obvious that the order induced by a single generator is necessarily preserved by the comprehension, as nevertheless suggested by all experiments like: > > 1> [ X || X <- [1,2,3] ]. > [1,2,3] > > I suppose this order preservation is true. Then, I imagine that, internally, list comprehensions are translated to code very similar to the one that would be produced if the developer had written an appropriate accumulator-based tail-recursive function? > > If so, does it imply that using a list comprehension on a semantically unordered set of elements will involve a useless reversal (like lists:reverse/1) of the resulting list? > > Thanks in advance for any answer, > Best regards, > > Olivier Boudeville. > --------------------------- > Olivier Boudeville > > EDF R&D : 1, avenue du G?n?ral de Gaulle, 92140 Clamart, France > D?partement SINETICS, groupe ASICS (I2A), bureau B-226 > Office : +33 1 47 65 59 58 / Mobile : +33 6 16 83 37 22 / Fax : +33 1 47 65 27 13 > > > Ce message et toutes les pi?ces jointes (ci-apr?s le 'Message') sont ?tablis ? l'intention exclusive des destinataires et les informations qui y figurent sont strictement confidentielles. Toute utilisation de ce Message non conforme ? sa destination, toute diffusion ou toute publication totale ou partielle, est interdite sauf autorisation expresse. > > Si vous n'?tes pas le destinataire de ce Message, il vous est interdit de le copier, de le faire suivre, de le divulguer ou d'en utiliser tout ou partie. Si vous avez re?u ce Message par erreur, merci de le supprimer de votre syst?me, ainsi que toutes ses copies, et de n'en garder aucune trace sur quelque support que ce soit. Nous vous remercions ?galement d'en avertir imm?diatement l'exp?diteur par retour du message. > > Il est impossible de garantir que les communications par messagerie ?lectronique arrivent en temps utile, sont s?curis?es ou d?nu?es de toute erreur ou virus. > ____________________________________________________ > > This message and any attachments (the 'Message') are intended solely for the addressees. The information contained in this Message is confidential. Any use of information contained in this Message not in accord with its purpose, any dissemination or disclosure, either whole or partial, is prohibited except formal approval. > > If you are not the addressee, you may not copy, forward, disclose or use any part of it. If you have received this message in error, please delete it and all copies from your system and notify the sender immediately by return message. > > E-mail communication cannot be guaranteed to be timely secure, error or virus-free. > _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://erlang.org/mailman/listinfo/erlang-questions Ce message et toutes les pi?ces jointes (ci-apr?s le 'Message') sont ?tablis ? l'intention exclusive des destinataires et les informations qui y figurent sont strictement confidentielles. Toute utilisation de ce Message non conforme ? sa destination, toute diffusion ou toute publication totale ou partielle, est interdite sauf autorisation expresse. Si vous n'?tes pas le destinataire de ce Message, il vous est interdit de le copier, de le faire suivre, de le divulguer ou d'en utiliser tout ou partie. Si vous avez re?u ce Message par erreur, merci de le supprimer de votre syst?me, ainsi que toutes ses copies, et de n'en garder aucune trace sur quelque support que ce soit. Nous vous remercions ?galement d'en avertir imm?diatement l'exp?diteur par retour du message. Il est impossible de garantir que les communications par messagerie ?lectronique arrivent en temps utile, sont s?curis?es ou d?nu?es de toute erreur ou virus. ____________________________________________________ This message and any attachments (the 'Message') are intended solely for the addressees. The information contained in this Message is confidential. Any use of information contained in this Message not in accord with its purpose, any dissemination or disclosure, either whole or partial, is prohibited except formal approval. If you are not the addressee, you may not copy, forward, disclose or use any part of it. If you have received this message in error, please delete it and all copies from your system and notify the sender immediately by return message. E-mail communication cannot be guaranteed to be timely secure, error or virus-free. -------------- next part -------------- An HTML attachment was scrubbed... URL: From erlangsiri@REDACTED Fri Apr 1 11:48:59 2011 From: erlangsiri@REDACTED (Siri Hansen) Date: Fri, 1 Apr 2011 11:48:59 +0200 Subject: [erlang-questions] Re: supervisors In-Reply-To: References: Message-ID: Attached you can find my small sample. Please have a look and let me know what differs. Just to add some confusion, my a_sup corresponds to your eapp_sup and my a_sup_2 corresponds to your a_sup.... ;) /siri 2011/3/31 Wes James > Siri, > > The code is from last weeks training part of the Erlang Factory in San > Francisco. I don't know if Erlang Solutions would like me sending all > the code to people or not. I'd send it to you off-list if it was ok > with them. > > Or maybe you could send me a sample of your code to compare with what I > have. > > thx, > > -wes > > On Thu, Mar 31, 2011 at 2:16 AM, Siri Hansen wrote: > > Hi Wes, > > It should be possible to do exactly what you want. I have tried to > recreate > > your problem, but I did not succeed. If you want to you may post the code > > for the two supervisors and I will have a look at it to see what I'm > doing > > different. > > Regards > > /siri > > > > > > 2011/3/30 Wes James > >> > >> when I start and app that works fine: > >> > >> =PROGRESS REPORT==== 30-Mar-2011::11:28:05 === > >> supervisor: {local,eapp_sup} > >> started: [{pid,<0.70.0>}, > >> {name,{a_sup,a1}}, > >> {mfargs,{a_sup,start_link,[a1]}}, > >> {restart_type,permanent}, > >> {shutdown,brutal_kill}, > >> {child_type,supervisor}] > >> > >> In eapp_sup I have: > >> > >> start_a(Module, Name) -> > >> supervisor:start_child(?MODULE, child(Module, Name)). > >> > >> > >> child(Module, Name) -> > >> {{Module, Name}, {Module, start_link, [Name]}, permanent, > >> brutal_kill, supervisor, [Name]}. > >> > >> > >> from starting above it would seem that a_sup has the name a1, but if > >> you run appmon it shows just as a_sup. > >> > >> When I then run > >> > >> eapp:start_a(a_sup,a2). I would assume that a_sup could load as a > >> second supervisor process with name a2, but this is what I get: > >> > >> eapp_sup:start_a(a_sup,a2). > >> {error,{already_started,<0.70.0>}} > >> > >> I then create a_sup2 and eapp_sup:start_a(a_sup2, a1) and that loads > >> fine, since the module "name" is not the same in the system as a_sup. > >> But it seems like a name should be assigned to these to make them > >> unique by name and be able to use the same supervisor code to > >> supervise some more children. > >> > >> Is that possible? > >> > >> thx, > >> > >> -wes > >> _______________________________________________ > >> erlang-questions mailing list > >> erlang-questions@REDACTED > >> http://erlang.org/mailman/listinfo/erlang-questions > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: siris_a.tgz Type: application/x-gzip Size: 1126 bytes Desc: not available URL: From alexey.v.romanov@REDACTED Fri Apr 1 12:58:50 2011 From: alexey.v.romanov@REDACTED (Alexey Romanov) Date: Fri, 1 Apr 2011 14:58:50 +0400 Subject: [erlang-questions] Re: Do gen_tcp sockets support recv_timeout option? In-Reply-To: <20110331150541.GA11652@ecn.lan> References: <20110331150541.GA11652@ecn.lan> Message-ID: I see, thanks. Yours, Alexey Romanov On Thu, Mar 31, 2011 at 7:05 PM, Michael Santos wrote: > On Thu, Mar 31, 2011 at 01:54:19PM +0400, Alexey Romanov wrote: >> It isn't listed in http://www.erlang.org/doc/man/inet.html#setopts-2, >> but Googling finds some uses: >> >> e.g. https://bitbucket.org/basho/casbench/src/7bba90cbf3e9/src/thrift_socket_server.erl > > This code is using recv_timeout as the timeout parameter for a > gen_tcp:recv/3 ({active,false} socket). > > See: > > https://bitbucket.org/basho/casbench/src/4265a37d2200/src/thrift_socket_transport.erl#cl-51 > > From olivier.boudeville@REDACTED Fri Apr 1 13:15:14 2011 From: olivier.boudeville@REDACTED (Olivier BOUDEVILLE) Date: Fri, 1 Apr 2011 13:15:14 +0200 Subject: [erlang-questions] Re: List comprehension questions In-Reply-To: <4D9590D7.9020203@gmail.com> Message-ID: Hello Richard, First of all, sorry, I had indeed missed your answer. Actually I did not see it neither at work nor at home, and I wonder whether there is not a mailing-list problem as it does not seem to appear either in gmane or in the thread as shown (at least at the time of this writing) by google groups (http://groups.google.com/group/erlang-programming/browse_thread/thread/8d339e24ed090311). Back on topic: as I understand now (I am not too familiar with Core Erlang), list comprehensions generate local functions that are body-recursive, i.e. involve actually a direct recursion, not using an accumulator. I just happened to find http://www.erlang.org/doc/efficiency_guide/listHandling.html#id61285 which gives a similar explanation (maybe a link from the reference manual to the efficiency guide could be made, to associate these two list comprehension topics). I was wondering if this body-recursiveness did not imply that a list comprehension operating on a longer list, whose result would be kept, could eat a lot of stack space/take longer to execute than a tail-recursive version? Apparently according to http://www.erlang.org/doc/efficiency_guide/myths.html#id58884 this will probably not be the case, so using list comprehension does not involve much trade-off. Thanks again, Best regards, Olivier Boudeville. --------------------------- Olivier Boudeville EDF R&D : 1, avenue du G?n?ral de Gaulle, 92140 Clamart, France D?partement SINETICS, groupe ASICS (I2A), bureau B-226 Office : +33 1 47 65 59 58 / Mobile : +33 6 16 83 37 22 / Fax : +33 1 47 65 27 13 carlsson.richard@REDACTED 01/04/2011 10:46 A erlang-questions@REDACTED, olivier.boudeville@REDACTED cc Objet Re: [erlang-questions] Re: List comprehension questions On 04/01/2011 10:00 AM, Olivier BOUDEVILLE wrote: > > Hello Robert, > > Thanks for your explanation. I guess that the reversal (to restore the > original list order after a first "if selected by filter then apply" > traversal) is done then in the list:map/2 counterpart! > > My concern was that, for long lists which do not happen to have to > respect any particular order in their elements, two traversals would be > done with list comprehensions whereas just one could be sufficient. > Well, a minor concern as for such cases we can write our own functions > to do so in one pass. Perhaps you didn't see my reply to your original mail (repeated below). The point that both Robert and I are trying to make is that there is no reversal involved in the code, and it only does one traversal, so you don't need to worry about this. /Richard On 03/30/2011 01:29 PM, Olivier BOUDEVILLE wrote: > Reading > http://www.erlang.org/doc/reference_manual/expressions.html#id77052 it > is not obvious that the order induced by a single generator is > necessarily preserved by the comprehension, as nevertheless suggested by > all experiments like: > > 1> [ X || X <- [1,2,3] ]. > [1,2,3] > > I suppose this order preservation is true. Then, I imagine that, > internally, list comprehensions are translated to code very similar to > the one that would be produced if the developer had written an > appropriate accumulator-based tail-recursive function? > > If so, does it imply that using a list comprehension on a semantically > unordered set of elements will involve a useless reversal (like > lists:reverse/1) of the resulting list? No, the translation does a straightforward recursion over the list without accumulator, automatically preserving order. To see what happens, take for example the following module: -module(lc). -export([f/1]). f(Input) -> [N + 1 || N <- Input]. and compile it to Core Erlang with c(lc,[to_core]) or erlc +to_core lc.erl. The resulting file lc.core contains the following code: 'f'/1 = fun (_cor0) -> letrec 'lc$^0'/1 = fun (_cor3) -> case _cor3 of <[N|_cor2]> when 'true' -> let <_cor4> = call 'erlang':'+' (N, 1) in let <_cor5> = apply 'lc$^0'/1 (_cor2) in ( [_cor4|_cor5] -| ['compiler_generated'] ) <[]> when 'true' -> [] ( <_cor3> when 'true' -> primop 'match_fail' ({( 'function_clause' -| [{'name',{'lc$^0',1}}] ),_cor3}) -| ['compiler_generated'] ) end in apply 'lc$^0'/1 (_cor0) (The annotations ( Expr -| 'compiler_generated') on some subexpressions are mostly needed to suppress certain compilation warnings that might otherwise be triggered, such as for unused results of expressions.) /Richard Ce message et toutes les pi?ces jointes (ci-apr?s le 'Message') sont ?tablis ? l'intention exclusive des destinataires et les informations qui y figurent sont strictement confidentielles. Toute utilisation de ce Message non conforme ? sa destination, toute diffusion ou toute publication totale ou partielle, est interdite sauf autorisation expresse. Si vous n'?tes pas le destinataire de ce Message, il vous est interdit de le copier, de le faire suivre, de le divulguer ou d'en utiliser tout ou partie. Si vous avez re?u ce Message par erreur, merci de le supprimer de votre syst?me, ainsi que toutes ses copies, et de n'en garder aucune trace sur quelque support que ce soit. Nous vous remercions ?galement d'en avertir imm?diatement l'exp?diteur par retour du message. Il est impossible de garantir que les communications par messagerie ?lectronique arrivent en temps utile, sont s?curis?es ou d?nu?es de toute erreur ou virus. ____________________________________________________ This message and any attachments (the 'Message') are intended solely for the addressees. The information contained in this Message is confidential. Any use of information contained in this Message not in accord with its purpose, any dissemination or disclosure, either whole or partial, is prohibited except formal approval. If you are not the addressee, you may not copy, forward, disclose or use any part of it. If you have received this message in error, please delete it and all copies from your system and notify the sender immediately by return message. E-mail communication cannot be guaranteed to be timely secure, error or virus-free. -------------- next part -------------- An HTML attachment was scrubbed... URL: From hm@REDACTED Fri Apr 1 14:26:55 2011 From: hm@REDACTED (=?ISO-8859-1?Q?H=E5kan_Mattsson?=) Date: Fri, 1 Apr 2011 14:26:55 +0200 Subject: [erlang-questions] Re: [erlang-questions 71] Erlang release generation In-Reply-To: References: <4D902590.8060409@m5net.com> Message-ID: 2011/3/29 Per Melin : > While we're on the subject, here are a couple of minor gotchas that > could possibly be improved in future versions of reltool: > > 1. Where the .rel is placed. > A release named "foo" with version "001" created with > reltool:create_target/2 in target directory "foo_001" will get this > .rel file: foo_001/releases/001/foo.rel > > But that is not what release_handler expects. So you need to move > and possibly rename the file to: > foo_001/foo_001.rel This has never been properly tested. You are probably the first one that ever tried to upgrade a target system generated by reltool. It would be really nice if someone could contribute a test case for this, including target generation and upgrade... /H?kan From michael.eugene.turner@REDACTED Fri Apr 1 15:28:52 2011 From: michael.eugene.turner@REDACTED (Michael Turner) Date: Fri, 1 Apr 2011 22:28:52 +0900 Subject: [erlang-questions] wxFrame:new() -- i.e. no arguments -- does what, exactly? Message-ID: The WxWidgets API permits a wxFrame:new() call, and wxWidgets seems to offer reasonable defaults in this case, at least according to the C++ API documentation. But when I do a wxFrame:show on the return value of wxFrame:new(), nothing shows up. At the very least, I think there should be a frame without a title. Is this a bug in the Erlang API or does it just reflect some foible of wxWidgets I don't know about and that isn't clearly documented? -michael turner -------------- next part -------------- An HTML attachment was scrubbed... URL: From andre@REDACTED Fri Apr 1 16:04:46 2011 From: andre@REDACTED (Andre Nathan) Date: Fri, 01 Apr 2011 11:04:46 -0300 Subject: [erlang-questions] [ANN] Postfix-Erlang Message-ID: <1301666686.16792.11.camel@andre.mz.digirati.com.br> Hello I'm pleased to announce the Postfix-Erlang project. It adds a new "erlang" dictionary type to Postfix, allowing Erlang functions to be called during Postfix's lookup table process. https://github.com/andrenth/postfix-erlang With Postfix-Erlang, you can store acess control information, address rewriting maps and everything else that you can do with Postfix's traditional lookup tables in an Erlang application, using, for example, Mnesia or DETS to keep this data. Configuration is pretty simple. In the Postfix side, you just have to specify the node information and which function should be called: nodes = mynode@REDACTED, mynode@REDACTED cookie = chocolate module = alias_db function = get_aliases The function will receive the query key from Postfix as a bitstring, and it should return {ok, ListOfBitstrings} or not_found. More details can be found at the project home page on GitHub. Thanks, Andre From raimo+erlang-questions@REDACTED Fri Apr 1 16:04:46 2011 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Fri, 1 Apr 2011 16:04:46 +0200 Subject: [erlang-questions] Re: fun with the new erlang.org! In-Reply-To: <20110331072509.GA12516@erix.ericsson.se> References: <20110325185008.GA32567@ecn.lan> <4D8D799E.7020603@eonblast.com> <87527205-E4AB-482D-8436-D01EFD809676@gmail.com> <20110330114139.GA28211@erix.ericsson.se> <20110331072509.GA12516@erix.ericsson.se> Message-ID: <20110401140446.GA13217@erix.ericsson.se> On Thu, Mar 31, 2011 at 09:25:09AM +0200, Raimo Niskanen wrote: > On Thu, Mar 31, 2011 at 12:07:55AM +0200, Antoine Koener wrote: > > > > On Mar 30, 2011, at 13:50 , Steve Vinoski wrote: > > : : > > Raimo, > > > > Here's a simple method to determine how 'caching' is handled by the > > webserver: > > http://www.ircache.net/cgi-bin/cacheability.py?query=http%3A%2F%2Fwww.erlang.org%2Fimages%2Fsearch_bar.jpg&descend=on > > > > It seems that inets isn't really ideal for serving real web content, > > because [extracted from the web page]: > > Last-Modified 70 weeks 5 days ago (Fri, 20 Nov 2009 11:37:29 GMT) > > validation returned same object > > > > If-Modified-Since are HTTP headers means: > > me (web browser talking) please web server give me only content that > > has changed since this "date", because I don't need to > > retrieve the same content since I already have it... > > > > Unfortunately inets sends the same content every time a HTTP GET is > > done, regardless of HTTP headers. > > > > I hope that this explanation will clarify a bit more. > > It seems so, thank you very much. Now I have something to dig into. > Part of the reason why we run Inets on the site is to find out what > problems it has. We supposedly can change web server to Yaws or even > maybe Mochiweb (I do not remember), but would preferably take the > opportunity to fix Inets. I am not on the Inets team so I will take > this to them... > Now the site replies correctly to If-Modified-Since. There is an Inets module mod_responsecontrol to handle this, which is now activated. > > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > -- > > / Raimo Niskanen, Erlang/OTP, Ericsson AB > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From raimo+erlang-questions@REDACTED Fri Apr 1 16:46:15 2011 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Fri, 1 Apr 2011 16:46:15 +0200 Subject: [erlang-questions] Re: [erlang-questions 29] Re: fun with the new erlang.org! In-Reply-To: References: <20110325185008.GA32567@ecn.lan> <4D8D799E.7020603@eonblast.com> <87527205-E4AB-482D-8436-D01EFD809676@gmail.com> <20110330114139.GA28211@erix.ericsson.se> <20110331072509.GA12516@erix.ericsson.se> Message-ID: <20110401144615.GA15234@erix.ericsson.se> On Thu, Mar 31, 2011 at 10:15:29AM -0400, Steve Vinoski wrote: : > Also a bit unusual is the website's failure to respond to HEAD > requests, as this verbose output from curl shows: > > $ curl -Iv http://www.erlang.org/ > * About to connect() to www.erlang.org port 80 (#0) > * Trying 192.121.151.107... connected > * Connected to www.erlang.org (192.121.151.107) port 80 (#0) > > HEAD / HTTP/1.1 > > User-Agent: curl/7.19.7 (universal-apple-darwin10.0) libcurl/7.19.7 OpenSSL/0.9.8l zlib/1.2.3 > > Host: www.erlang.org > > Accept: */* > > > * Empty reply from server > * Connection #0 to host www.erlang.org left intact > curl: (52) Empty reply from server > * Closing connection #0 > > A website technically doesn't need to respond to HEAD requests but for > purposes of cache coherency it's common for caches to use both > conditional GETs (which is why supporting ETag and cache control > headers is important) and HEAD requests for checking for updates on > origin servers. > > --steve According to the Inets documentation mod_head should be after mod_get, but that did not work. Now I have mod_head mod_responsecontrol mod_get. That works for the static content. But the dynamic content served by ErlangWeb before passing it to Inets does not support HEAD, as it seems. Try curl on http://www.erlang.org/images/banner.jpg now. I will have to look into If-Modified-Since and HEAD for dynamic content sometime later... -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From kostis@REDACTED Fri Apr 1 16:48:51 2011 From: kostis@REDACTED (Kostis Sagonas) Date: Fri, 01 Apr 2011 17:48:51 +0300 Subject: [erlang-questions] Re: [erlang-questions 53] Re: HiPE or native....good results, but confused... In-Reply-To: <4D8F6E94.80607@cs.ntua.gr> References: <4D8F6E94.80607@cs.ntua.gr> Message-ID: <4D95E5D3.8080606@cs.ntua.gr> Kostis Sagonas wrote: > > The HiPE compiler is pretty stable; the only bug I am aware of is an off > by one error in binary pattern matching which has already been fixed and > the fix will appear on 'dev' soon. (For comparison, incidentally the > R14B02 BEAM compiler also had a bug in binary pattern matching which has > been fixed two days ago.) Such is life, I guess... The only thing to do > about it is to hope that the Erlang community will help by reporting > whatever issues they run across because both the BEAM and the HiPE > compiler developers are currently committed to fixing them. Just for the list archive, I guess, I am replying to my own mail... Since about one hour ago a fix for the hipe bug in OTP R14B02 I mentioned in my mail is part of OTP's 'dev' version available on github. For those interested in trying it, here is the relevant link: https://github.com/erlang/otp/commit/745c4af40595c8b029c2d61ddbe22c6d12950236 Thanks to Sverker Eriksson for identifying and fixing this! Please do report any problem you experience related to execution of native code. At the time of this writing, I am not aware of any other outstanding bugs. Kostis From peralta.alejandro@REDACTED Fri Apr 1 16:58:14 2011 From: peralta.alejandro@REDACTED (Ale) Date: Fri, 1 Apr 2011 11:58:14 -0300 Subject: [erlang-questions] Re: wxFrame:new() -- i.e. no arguments -- does what, exactly? In-Reply-To: References: Message-ID: 2011/4/1 Michael Turner : > > The WxWidgets API permits a wxFrame:new() call, and wxWidgets seems to offer > reasonable defaults in this case, at least according to the C++ API > documentation. ?But when I do a wxFrame:show on the return value of > wxFrame:new(), nothing shows up. ?At the very least, I think there should be > a frame without a title. ?Is this a bug in the Erlang API or does it just > reflect some foible of wxWidgets I don't know about and that isn't clearly > documented? I'm not sure when you would use it (probably so you can pass references to callbacks) but I think the idea is so you can have a two step construction of the frame (which the original wx in C++ allows) Something like that: 20> wx:new(). {wx_ref,0,wx,[]} 21> Frame5 = wxFrame:new(). {wx_ref,35,wxFrame,[]} 22> wxFrame:create(Frame5, wx:null(), 1042, "blah"). true 23> wxFrame:show(Frame5). and that should display the frame cheers, see: http://docs.wxwidgets.org/2.8/wx_wxframe.html#wxframecreate > -michael turner > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -- Ale. From comptekki@REDACTED Fri Apr 1 18:39:48 2011 From: comptekki@REDACTED (Wes James) Date: Fri, 1 Apr 2011 10:39:48 -0600 Subject: [erlang-questions] Re: supervisors In-Reply-To: References: Message-ID: Siri, The same thing happens: Erlang R14B02 (erts-5.8.3) [source] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.8.3 (abort with ^G) 1> make:all([load]). Recompile: a_sup Recompile: a_sup_2 up_to_date 2> application:start(a). a1 ok 3> appmon:start(). {ok,<0.49.0>} 4> a_sup:start(a_sup_2,a2). {error,{already_started,<0.46.0>}} looking at appmon, there is an a_sup process supervising process <0.47.0> which I'm guessing is the a_sup_2. What I'm trying to do is run a_sup_2 with say name a1, then run a second a_sup_2, with say name a2 as if you were running a_sup_2 then then running register("a_sup_2 process", a1) and then run a second a_sup_2 and get a second <0.xx.0> process to do register(<0.xx.0>, a2) and so forth so several a_sup_2's can be running but with a different registered name. Can that be done? thx, -wes On Fri, Apr 1, 2011 at 3:48 AM, Siri Hansen wrote: > Attached you can find my small sample. ?Please have a look and let me know > what differs. > Just to add some confusion, my a_sup corresponds to your eapp_sup and my > a_sup_2 corresponds to your a_sup.... ;) > /siri > > 2011/3/31 Wes James >> >> Siri, >> >> The code is from last weeks training part of the Erlang Factory in San >> Francisco. ?I don't know if Erlang Solutions would like me sending all >> the code to people or not. ?I'd send it to you off-list if it was ok >> with them. >> >> Or maybe you could send me a sample of your code to compare with what I >> have. >> >> thx, >> >> -wes >> >> On Thu, Mar 31, 2011 at 2:16 AM, Siri Hansen wrote: >> > Hi Wes, >> > It should be possible to do exactly what you want.?I have tried to >> > recreate >> > your problem, but I did not succeed. If you want to you may post the >> > code >> > for the two supervisors and I will have a look at it to see what I'm >> > doing >> > different. >> > Regards >> > /siri >> > >> > >> > 2011/3/30 Wes James >> >> >> >> when I start and app that works fine: >> >> >> >> =PROGRESS REPORT==== 30-Mar-2011::11:28:05 === >> >> ? ? ? ? ?supervisor: {local,eapp_sup} >> >> ? ? ? ? ? ? started: [{pid,<0.70.0>}, >> >> ? ? ? ? ? ? ? ? ? ? ? {name,{a_sup,a1}}, >> >> ? ? ? ? ? ? ? ? ? ? ? {mfargs,{a_sup,start_link,[a1]}}, >> >> ? ? ? ? ? ? ? ? ? ? ? {restart_type,permanent}, >> >> ? ? ? ? ? ? ? ? ? ? ? {shutdown,brutal_kill}, >> >> ? ? ? ? ? ? ? ? ? ? ? {child_type,supervisor}] >> >> >> >> In eapp_sup I have: >> >> >> >> start_a(Module, Name) -> >> >> ? ? ? ?supervisor:start_child(?MODULE, child(Module, Name)). >> >> >> >> >> >> child(Module, Name) -> >> >> ?{{Module, Name}, {Module, start_link, [Name]}, permanent, >> >> brutal_kill, supervisor, [Name]}. >> >> >> >> >> >> from starting above it would seem that a_sup has the name a1, but if >> >> you run appmon it shows just as a_sup. >> >> >> >> When I then run >> >> >> >> eapp:start_a(a_sup,a2). ?I would assume that a_sup could load as a >> >> second supervisor process with name a2, but this is what I get: >> >> >> >> eapp_sup:start_a(a_sup,a2). >> >> {error,{already_started,<0.70.0>}} >> >> >> >> I then create a_sup2 ?and eapp_sup:start_a(a_sup2, a1) and that loads >> >> fine, since the module "name" is not the same in the system as a_sup. >> >> But it seems like a name should be assigned to these to make them >> >> unique by name and be able to use the same supervisor code to >> >> supervise some more children. >> >> >> >> Is that possible? >> >> >> >> thx, >> >> >> >> -wes >> >> _______________________________________________ >> >> erlang-questions mailing list >> >> erlang-questions@REDACTED >> >> http://erlang.org/mailman/listinfo/erlang-questions >> > >> > > > From jameschurchman@REDACTED Fri Apr 1 19:24:22 2011 From: jameschurchman@REDACTED (James Churchman) Date: Fri, 1 Apr 2011 18:24:22 +0100 Subject: [erlang-questions] Re: List comprehension questions In-Reply-To: References: Message-ID: <00D36D35-A52D-42EC-8CD9-8236183C98E9@gmail.com> So if (from the docs) list comprehension become : 'lc^0'([E|Tail], Expr) -> [Expr(E)|'lc^0'(Tail, Expr)]; 'lc^0'([], _Expr) -> []. then, what happens when Expr contains references to other variables in the original scope? (eg not E ) it says Expr used to be a Fun, but now it's not, so in this case is it a Fun, or does it increase the arty of the generated lc^0 function for each of the extra referenced vars? Also keen to know the body recursive "cost", and why it avoids using list reverse in the case when a list is required to be returned :-) james On 1 Apr 2011, at 12:15, Olivier BOUDEVILLE wrote: > > Hello Richard, > > First of all, sorry, I had indeed missed your answer. Actually I did not see it neither at work nor at home, and I wonder whether there is not a mailing-list problem as it does not seem to appear either in gmane or in the thread as shown (at least at the time of this writing) by google groups (http://groups.google.com/group/erlang-programming/browse_thread/thread/8d339e24ed090311). > > Back on topic: as I understand now (I am not too familiar with Core Erlang), list comprehensions generate local functions that are body-recursive, i.e. involve actually a direct recursion, not using an accumulator. > > I just happened to find http://www.erlang.org/doc/efficiency_guide/listHandling.html#id61285 which gives a similar explanation (maybe a link from the reference manual to the efficiency guide could be made, to associate these two list comprehension topics). > > I was wondering if this body-recursiveness did not imply that a list comprehension operating on a longer list, whose result would be kept, could eat a lot of stack space/take longer to execute than a tail-recursive version? > > Apparently according to http://www.erlang.org/doc/efficiency_guide/myths.html#id58884 this will probably not be the case, so using list comprehension does not involve much trade-off. > > Thanks again, > Best regards, > > Olivier Boudeville. > --------------------------- > Olivier Boudeville > > EDF R&D : 1, avenue du G?n?ral de Gaulle, 92140 Clamart, France > D?partement SINETICS, groupe ASICS (I2A), bureau B-226 > Office : +33 1 47 65 59 58 / Mobile : +33 6 16 83 37 22 / Fax : +33 1 47 65 27 13 > > > carlsson.richard@REDACTED > 01/04/2011 10:46 > > A > erlang-questions@REDACTED, olivier.boudeville@REDACTED > cc > Objet > Re: [erlang-questions] Re: List comprehension questions > > > > > > On 04/01/2011 10:00 AM, Olivier BOUDEVILLE wrote: > > > > Hello Robert, > > > > Thanks for your explanation. I guess that the reversal (to restore the > > original list order after a first "if selected by filter then apply" > > traversal) is done then in the list:map/2 counterpart! > > > > My concern was that, for long lists which do not happen to have to > > respect any particular order in their elements, two traversals would be > > done with list comprehensions whereas just one could be sufficient. > > Well, a minor concern as for such cases we can write our own functions > > to do so in one pass. > > Perhaps you didn't see my reply to your original mail (repeated below). > The point that both Robert and I are trying to make is that there is no > reversal involved in the code, and it only does one traversal, so you > don't need to worry about this. > > /Richard > > > On 03/30/2011 01:29 PM, Olivier BOUDEVILLE wrote: > > Reading > > http://www.erlang.org/doc/reference_manual/expressions.html#id77052 it > > is not obvious that the order induced by a single generator is > > necessarily preserved by the comprehension, as nevertheless suggested by > > all experiments like: > > > > 1> [ X || X <- [1,2,3] ]. > > [1,2,3] > > > > I suppose this order preservation is true. Then, I imagine that, > > internally, list comprehensions are translated to code very similar to > > the one that would be produced if the developer had written an > > appropriate accumulator-based tail-recursive function? > > > > If so, does it imply that using a list comprehension on a semantically > > unordered set of elements will involve a useless reversal (like > > lists:reverse/1) of the resulting list? > > No, the translation does a straightforward recursion over the list > without accumulator, automatically preserving order. To see what > happens, take for example the following module: > > -module(lc). > -export([f/1]). > f(Input) -> > [N + 1 || N <- Input]. > > and compile it to Core Erlang with c(lc,[to_core]) or erlc +to_core > lc.erl. The resulting file lc.core contains the following code: > > 'f'/1 = > fun (_cor0) -> > letrec > 'lc$^0'/1 = > fun (_cor3) -> > case _cor3 of > <[N|_cor2]> when 'true' -> > let <_cor4> = > call 'erlang':'+' > (N, 1) > in let <_cor5> = > apply 'lc$^0'/1 > (_cor2) > in ( [_cor4|_cor5] > -| ['compiler_generated'] ) > <[]> when 'true' -> > [] > ( <_cor3> when 'true' -> > primop 'match_fail' > ({( 'function_clause' > -| [{'name',{'lc$^0',1}}] ),_cor3}) > -| ['compiler_generated'] ) > end > in apply 'lc$^0'/1 > (_cor0) > > (The annotations ( Expr -| 'compiler_generated') on some subexpressions > are mostly needed to suppress certain compilation warnings that might > otherwise be triggered, such as for unused results of expressions.) > > /Richard > > > > > Ce message et toutes les pi?ces jointes (ci-apr?s le 'Message') sont ?tablis ? l'intention exclusive des destinataires et les informations qui y figurent sont strictement confidentielles. Toute utilisation de ce Message non conforme ? sa destination, toute diffusion ou toute publication totale ou partielle, est interdite sauf autorisation expresse. > > Si vous n'?tes pas le destinataire de ce Message, il vous est interdit de le copier, de le faire suivre, de le divulguer ou d'en utiliser tout ou partie. Si vous avez re?u ce Message par erreur, merci de le supprimer de votre syst?me, ainsi que toutes ses copies, et de n'en garder aucune trace sur quelque support que ce soit. Nous vous remercions ?galement d'en avertir imm?diatement l'exp?diteur par retour du message. > > Il est impossible de garantir que les communications par messagerie ?lectronique arrivent en temps utile, sont s?curis?es ou d?nu?es de toute erreur ou virus. > ____________________________________________________ > > This message and any attachments (the 'Message') are intended solely for the addressees. The information contained in this Message is confidential. Any use of information contained in this Message not in accord with its purpose, any dissemination or disclosure, either whole or partial, is prohibited except formal approval. > > If you are not the addressee, you may not copy, forward, disclose or use any part of it. If you have received this message in error, please delete it and all copies from your system and notify the sender immediately by return message. > > E-mail communication cannot be guaranteed to be timely secure, error or virus-free._______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From chris.williams@REDACTED Fri Apr 1 19:52:19 2011 From: chris.williams@REDACTED (Christopher Williams) Date: Fri, 1 Apr 2011 10:52:19 -0700 Subject: [erlang-questions] Implementation of Amazon Web Services (AWS) EC2 API in erlang?. Message-ID: Hi Does any one know if there exists a Erlang implementation of the Amazon Web Services EC2 API. If it exists where can one find it? //Chris

_______________________________________________________________
Hitta ditt dr?mjobb - Klicka h?r!
-------------- next part -------------- An HTML attachment was scrubbed... URL: From erlangsiri@REDACTED Fri Apr 1 20:28:43 2011 From: erlangsiri@REDACTED (Siri Hansen) Date: Fri, 1 Apr 2011 20:28:43 +0200 Subject: [erlang-questions] Re: supervisors In-Reply-To: References: Message-ID: Hi Wes - you should call a_sup:start_a instead of a_sup:start when trying to start a2. Regards /siri 2011/4/1 Wes James > Siri, > > The same thing happens: > > Erlang R14B02 (erts-5.8.3) [source] [smp:2:2] [rq:2] [async-threads:0] > [hipe] [kernel-poll:false] > > Eshell V5.8.3 (abort with ^G) > 1> make:all([load]). > Recompile: a_sup > Recompile: a_sup_2 > up_to_date > 2> application:start(a). > a1 > ok > 3> appmon:start(). > {ok,<0.49.0>} > 4> a_sup:start(a_sup_2,a2). > {error,{already_started,<0.46.0>}} > > looking at appmon, there is an a_sup process supervising process > <0.47.0> which I'm guessing is the a_sup_2. What I'm trying to do is > run a_sup_2 with say name a1, then run a second a_sup_2, with say name > a2 as if you were running a_sup_2 then then running register("a_sup_2 > process", a1) and then run a second a_sup_2 and get a second <0.xx.0> > process to do register(<0.xx.0>, a2) and so forth so several a_sup_2's > can be running but with a different registered name. Can that be > done? > > thx, > > -wes > > On Fri, Apr 1, 2011 at 3:48 AM, Siri Hansen wrote: > > Attached you can find my small sample. Please have a look and let me > know > > what differs. > > Just to add some confusion, my a_sup corresponds to your eapp_sup and my > > a_sup_2 corresponds to your a_sup.... ;) > > /siri > > > > 2011/3/31 Wes James > >> > >> Siri, > >> > >> The code is from last weeks training part of the Erlang Factory in San > >> Francisco. I don't know if Erlang Solutions would like me sending all > >> the code to people or not. I'd send it to you off-list if it was ok > >> with them. > >> > >> Or maybe you could send me a sample of your code to compare with what I > >> have. > >> > >> thx, > >> > >> -wes > >> > >> On Thu, Mar 31, 2011 at 2:16 AM, Siri Hansen > wrote: > >> > Hi Wes, > >> > It should be possible to do exactly what you want. I have tried to > >> > recreate > >> > your problem, but I did not succeed. If you want to you may post the > >> > code > >> > for the two supervisors and I will have a look at it to see what I'm > >> > doing > >> > different. > >> > Regards > >> > /siri > >> > > >> > > >> > 2011/3/30 Wes James > >> >> > >> >> when I start and app that works fine: > >> >> > >> >> =PROGRESS REPORT==== 30-Mar-2011::11:28:05 === > >> >> supervisor: {local,eapp_sup} > >> >> started: [{pid,<0.70.0>}, > >> >> {name,{a_sup,a1}}, > >> >> {mfargs,{a_sup,start_link,[a1]}}, > >> >> {restart_type,permanent}, > >> >> {shutdown,brutal_kill}, > >> >> {child_type,supervisor}] > >> >> > >> >> In eapp_sup I have: > >> >> > >> >> start_a(Module, Name) -> > >> >> supervisor:start_child(?MODULE, child(Module, Name)). > >> >> > >> >> > >> >> child(Module, Name) -> > >> >> {{Module, Name}, {Module, start_link, [Name]}, permanent, > >> >> brutal_kill, supervisor, [Name]}. > >> >> > >> >> > >> >> from starting above it would seem that a_sup has the name a1, but if > >> >> you run appmon it shows just as a_sup. > >> >> > >> >> When I then run > >> >> > >> >> eapp:start_a(a_sup,a2). I would assume that a_sup could load as a > >> >> second supervisor process with name a2, but this is what I get: > >> >> > >> >> eapp_sup:start_a(a_sup,a2). > >> >> {error,{already_started,<0.70.0>}} > >> >> > >> >> I then create a_sup2 and eapp_sup:start_a(a_sup2, a1) and that loads > >> >> fine, since the module "name" is not the same in the system as a_sup. > >> >> But it seems like a name should be assigned to these to make them > >> >> unique by name and be able to use the same supervisor code to > >> >> supervise some more children. > >> >> > >> >> Is that possible? > >> >> > >> >> thx, > >> >> > >> >> -wes > >> >> _______________________________________________ > >> >> erlang-questions mailing list > >> >> erlang-questions@REDACTED > >> >> http://erlang.org/mailman/listinfo/erlang-questions > >> > > >> > > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From comptekki@REDACTED Fri Apr 1 20:32:34 2011 From: comptekki@REDACTED (Wes James) Date: Fri, 1 Apr 2011 12:32:34 -0600 Subject: [erlang-questions] Re: supervisors In-Reply-To: References: Message-ID: I go this figured out. I tried to add register(name(?MODULE, Name), self()), in the supervisor init() -> but it failed. I looked back in the supervisor docs http://www.erlang.org/doc/man/supervisor.html and found: If SupName={local,Name} the supervisor is registered locally as Name using register/2. If SupName={global,Name} the supervisor is registered globally as Name using global:register_name/2. If no name is provided, the supervisor is not registered. so I change start_link(Name) -> supervisor:start_link({local, ?MODULE}, ?MODULE, Name). to start_link(Name) -> supervisor:start_link({local, name(?MODULE,Name)}, ?MODULE, Name). name() is a fun to combine ?MODULE ++ "-" ++ Name it now all it works to run eapp_sup:start_a(a_sup,a2). and it get's registered to a_sup_a2. -wes From comptekki@REDACTED Fri Apr 1 20:38:46 2011 From: comptekki@REDACTED (Wes James) Date: Fri, 1 Apr 2011 12:38:46 -0600 Subject: [erlang-questions] Re: supervisors In-Reply-To: References: Message-ID: What this boils down to is being able to use the same supervisor code to load several processes, since they can be named different and won't cause a name clash. application:start(eapp) bascially does eapp_sup:start(a_sup,a1) will start the supervisor named a_sup_a1 by default, then you can run eapp_sup:start(a_sup,a2) and use the a_sup code again but name the process a2, etc. -wes From vances@REDACTED Fri Apr 1 21:22:50 2011 From: vances@REDACTED (Vance Shipley) Date: Fri, 1 Apr 2011 15:22:50 -0400 Subject: [erlang-questions] Re: Programatically Starting Erlang Nodes In-Reply-To: References: Message-ID: <20110401192250.GO6861@h216-235-12-173.host.egate.net> Are you aware of the slave module? http://www.erlang.org/doc/man/slave.html On Wed, Mar 30, 2011 at 07:47:04PM +0100, Dale Harvey wrote: } How do people manage programatically starting and stopping seperate } erlang distributed nodes? -- -Vance From comptekki@REDACTED Sat Apr 2 00:34:04 2011 From: comptekki@REDACTED (Wes James) Date: Fri, 1 Apr 2011 16:34:04 -0600 Subject: [erlang-questions] Re: gs in R14B02 In-Reply-To: References: Message-ID: Last week at the Erlang Factory we ran an application that had a tcl/tk interface and when you looked at appmon:start() you could see a gs_ named process in the tree. I'm new to the graphical stuff, but I'm guessing gs_ was the gs interface for the app. I was running R14B02 during the training. just for my future notes: toolbar:start() has a toolbar that you can click instead of doing these on the command line: table visualizer (mnesia and dets tables): tv:start(). process manager: pman:start(). debugger: c(module,[debug_info]). im(). ii(module). iaa([init]). application monitor: appmon:start(). -wes On Thu, Mar 31, 2011 at 10:21 PM, G.S. wrote: > Hello, > > Can anyone confirm if gs was dropped in R14B02? > > Regards, > -Gene > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > From yg@REDACTED Sat Apr 2 01:06:26 2011 From: yg@REDACTED (Yuri Ginsburg) Date: Fri, 1 Apr 2011 16:06:26 -0700 Subject: [erlang-questions] Re: Implementation of Amazon Web Services (AWS) EC2 API in erlang?. In-Reply-To: References: Message-ID: The only one that I know about is erlawys http://code.google.com/p/erlawys/ The project was not updated since 2007. --yg On Fri, Apr 1, 2011 at 10:52 AM, Christopher Williams < chris.williams@REDACTED> wrote: > Hi > Does any one know if there exists a Erlang implementation of the Amazon > Web Services EC2 API. If it exists where can one find it? > //Chris > > _______________________________________________________________ > Hitta ditt dr?mjobb - *Klicka h?r! > * > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From xueyu32@REDACTED Sat Apr 2 04:06:32 2011 From: xueyu32@REDACTED (xueyu) Date: Fri, 1 Apr 2011 19:06:32 -0700 (PDT) Subject: [erlang-questions] Re: hi all, how to write the reltool config file to exclude .svn directory when making target system In-Reply-To: References: Message-ID: I resolved the problem finally : {app,stress,[{incl_cond,include}, {incl_app_filters,["^ebin/","^priv/"]}, {excl_app_filters,["\.svn"]}, %% the important line {incl_archive_filters,["^priv/"]}, {excl_archive_filters,["\.svn"]} ]} On 4?1?, ??3?35?, yu xue wrote: > I made a project with erlang, now, I am using reltool to make target system. > > I am using svn to control the project version, so, there is a .svn directory > in then priv directory, > > I want to exclude the .svn directory when makeing target system, the partial > config rule I wrote as below, but it does not work, > > I wish anyone could help me ,thanks very much. > > {app,stress,[{incl_cond,include}, > > > > > > > > > {incl_app_filters,["^ebin/","^priv/"]}, > > {incl_archive_filters,["^priv/"]}, > > {excl_archive_filters,["\.svn"]} > > ]} > > > > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://erlang.org/mailman/listinfo/erlang-questions From toby@REDACTED Sat Apr 2 04:38:49 2011 From: toby@REDACTED (Toby Thain) Date: Fri, 01 Apr 2011 22:38:49 -0400 Subject: [erlang-questions] Re: hi all, how to write the reltool config file to exclude .svn directory when making target system In-Reply-To: References: Message-ID: <4D968C39.6040003@telegraphics.com.au> On 01/04/11 10:06 PM, xueyu wrote: > I resolved the problem finally : > > {app,stress,[{incl_cond,include}, > {incl_app_filters,["^ebin/","^priv/"]}, > {excl_app_filters,["\.svn"]}, %% the > important line > {incl_archive_filters,["^priv/"]}, > {excl_archive_filters,["\.svn"]} > ]} > > > > On 4?1?, ??3?35?, yu xue wrote: >> I made a project with erlang, now, I am using reltool to make target system. >> >> I am using svn to control the project version, so, there is a .svn directory >> in then priv directory, >> >> I want to exclude the .svn directory when makeing target system, the partial >> config rule I wrote as below, but it does not work, >> It's usually best to use the svn export command to get a clean file tree, if that's possible in your flow. --Toby >> I wish anyone could help me ,thanks very much. >> >> {app,stress,[{incl_cond,include}, >> >> >> >> >> >> >> >>> {incl_app_filters,["^ebin/","^priv/"]}, >>> {incl_archive_filters,["^priv/"]}, >>> {excl_archive_filters,["\.svn"]} >>> ]} >> >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questi...@REDACTED://erlang.org/mailman/listinfo/erlang-questions > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From steve@REDACTED Sat Apr 2 07:30:01 2011 From: steve@REDACTED (Steve Strong) Date: Sat, 2 Apr 2011 07:30:01 +0200 Subject: [erlang-questions] Fwd: Re: Implementation of Amazon Web Services (AWS) EC2 API in erlang?. In-Reply-To: <30AC8BD9F4754924B5C89B847835BA9E@srstrong.com> References: <30AC8BD9F4754924B5C89B847835BA9E@srstrong.com> Message-ID: Forgot to reply-all... :) ---------- Forwarded message ---------- From: "Steve Strong" Date: 1 Apr 2011 19:54 Subject: Re: [erlang-questions] Implementation of Amazon Web Services (AWS) EC2 API in erlang?. To: "Christopher Williams" I've got a fork of erlawys here https://github.com/srstrong/erlawys with a couple of minor tweaks from the original -- Steve Strong, Director, id3as twitter.com/srstrong On Friday, 1 April 2011 at 19:52, Christopher Williams wrote: Hi Does any one know if there exists a Erlang implementation of the Amazon Web Services EC2 API. If it exists where can one find it? //Chris _______________________________________________________________ Hitta ditt dr?mjobb - *Klicka h?r! * _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From jameschurchman@REDACTED Sat Apr 2 13:25:39 2011 From: jameschurchman@REDACTED (James Churchman) Date: Sat, 2 Apr 2011 12:25:39 +0100 Subject: [erlang-questions] Re: List comprehension questions In-Reply-To: <4D9622C5.7010606@gmail.com> References: <00D36D35-A52D-42EC-8CD9-8236183C98E9@gmail.com> <4D9622C5.7010606@gmail.com> Message-ID: <641ABB5A-8287-4AC8-89CE-ABFDF7A29E89@gmail.com> Hi Richard Thanks for your reply. The following part of the docs actually shows that it does do the non-return optimisation:-) tho you answer also make me question all my carefully crafted non-body recursive functions with reverses too ! James On 1 Apr 2011, at 20:08, Richard Carlsson wrote: > On 2011-04-01 19:24, James Churchman wrote: >> So if (from the docs) list comprehension become : >> >> 'lc^0'([E|Tail], Expr) -> [Expr(E)|'lc^0'(Tail, Expr)]; >> 'lc^0'([], _Expr) -> []. >> >> then, what happens when Expr contains references to other variables in >> the original scope? (eg not E ) it says Expr used to be a Fun, but now >> it's not, so in this case is it a Fun, or does it increase the arty of >> the generated lc^0 function for each of the extra referenced vars? > > Essentially, yes, it increases the arity. First, the list comprehension becomes a local function in Core Erlang (with access to the variables in scope). The local function is then lifted out to become a normal function with additional parameters before it gets translated to BEAM. > >> Also keen to know the body recursive "cost", and why it avoids using >> list reverse in the case when a list is required to be returned :-) > > A body recursive translation is simpler, and is generally faster for short lists (the majority of list comprehensions runs on lists shorter than 100 elements, in my experience at least, and the break-even point for tail recursion plus reverse is somewhere above 100 elements). > > Even for quite long lists, a body recursive function is typically not much worse than a tail recursive solution with a reverse at the end, so there's no reason to change the behaviour and make it worse for short lists. Hence, the current implementation never produces a list in reverse order, and it never needs to reverse anything at the end. > > If the compiler knows that the result (which is always a list) won't be used at all, it could generate code more similar to lists:foreach() instead, but I don't think that's done currently. > > /Richard From bgustavsson@REDACTED Sun Apr 3 08:30:06 2011 From: bgustavsson@REDACTED (=?UTF-8?Q?Bj=C3=B6rn_Gustavsson?=) Date: Sun, 3 Apr 2011 08:30:06 +0200 Subject: [erlang-questions] Re: List comprehension questions In-Reply-To: <641ABB5A-8287-4AC8-89CE-ABFDF7A29E89@gmail.com> References: <00D36D35-A52D-42EC-8CD9-8236183C98E9@gmail.com> <4D9622C5.7010606@gmail.com> <641ABB5A-8287-4AC8-89CE-ABFDF7A29E89@gmail.com> Message-ID: > On 1 Apr 2011, at 20:08, Richard Carlsson wrote: > >> On 2011-04-01 19:24, James Churchman wrote: [...] >>> Also keen to know the body recursive "cost", and why it avoids using >>> list reverse in the case when a list is required to be returned :-) >> >> A body recursive translation is simpler, and is generally faster for short lists (the majority of list comprehensions runs on lists shorter than 100 elements, in my experience at least, and the break-even point for tail recursion plus reverse is somewhere above 100 elements). >> >> Even for quite long lists, a body recursive function is typically not much worse than a tail recursive solution with a reverse at the end, so there's no reason to change the behaviour and make it worse for short lists. Hence, the current implementation never produces a list in reverse order, and it never needs to reverse anything at the end. There used to be a more noticeable difference between body recursion and tail recursion before the R12B release, because body recursion would usually use more memory. In R12B and later releases, the tail-recursive and body-recursive variants of a function generally use the same amount of memory and executes roughly in the same time. See: http://www.erlang.org/doc/efficiency_guide/myths.html#id58884 >> If the compiler knows that the result (which is always a list) won't be used at all, it could generate code more similar to lists:foreach() instead, but I don't think that's done currently. It's done. See: http://www.erlang.org/doc/efficiency_guide/listHandling.html#id61285 -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From aronisstav@REDACTED Sun Apr 3 11:48:51 2011 From: aronisstav@REDACTED (Stavros Aronis) Date: Sun, 3 Apr 2011 12:48:51 +0300 Subject: [erlang-questions] Using the -M dependencies generator of erlc In-Reply-To: References: Message-ID: Hi! I've been trying to make Dialyzer's makefile use the new functionality added in R14B02 to erlc: "Dependency generation for Makefiles has been added to the compiler and erlc. See the manual pages for compile and erlc." What I've already done can be checked here: https://github.com/aronisstav/otp/commit/67e07a What troubles me is whether this "heavy pollution" of the ebin directory with .Pbeam files is really required for this to work. Is there somewhere an example of how one can properly use this? If this is the correct way, should I move the Pbeam exclusion rule to the root .gitignore file? Stavros Aronis From matthew@REDACTED Sun Apr 3 11:59:18 2011 From: matthew@REDACTED (Matthew Sackman) Date: Sun, 3 Apr 2011 10:59:18 +0100 Subject: [erlang-questions] Re: Using the -M dependencies generator of erlc In-Reply-To: References: Message-ID: <20110403095918.GA23931@wellquite.org> On Sun, Apr 03, 2011 at 12:48:51PM +0300, Stavros Aronis wrote: > I've been trying to make Dialyzer's makefile use the new functionality > added in R14B02 to erlc: "Dependency generation for Makefiles has been > added to the compiler and erlc. See the manual pages for compile and > erlc." (Apologies for potentially hijacking this thread.) As the man page says, this is only for tracking header dependencies, which, IME, is at best only part of the story. Tracking behaviours and parse_transformers are just as, if not more, important. Eg, file state_t.erl: -module(state_t, [InnerMonad]). -compile({parse_transform, erlando}). -behaviour(monad). > erlc -pa ebin -M src/state_t.erl state_t.beam: src/state_t.erl I don't think so! Our generate_deps script correctly spits out: ebin/state_t.beam: src/state_t.erl ebin/monad.beam ebin/erlando.beam You may like to have a look at http://hg.rabbitmq.com/erlando/file/default/Makefile and http://hg.rabbitmq.com/erlando/file/default/generate_deps (and yes, generate_deps also copes with headers, and you get just one file of additional dependencies which you can then -include into your Makefile). Matthew From kostis@REDACTED Sun Apr 3 14:32:27 2011 From: kostis@REDACTED (Kostis Sagonas) Date: Sun, 03 Apr 2011 15:32:27 +0300 Subject: [erlang-questions] Specifying 'erts' as an application Message-ID: <4D9868DB.5010602@cs.ntua.gr> The Erlang/OTP documentation specifies 'erts' as an application: http://erlang.org/doc/applications.html In a project we are working on, we have an application resource file that reads: {application, APP_NAME, [{description, ...}, ... {applications, [erts, kernel, stdlib, ...] ... ]}. A user informed us that "erts isn't actually an application that can be dependent upon and that having it in the applications list breaks releases". I personally consider this a bug, of Erlang/OTP that is, but I will gladly be enlightened why 'erts' is listed as an OTP application but cannot be listed in the application resource file and releases break miserably when one does so. Kostis From per.melin@REDACTED Sun Apr 3 18:40:57 2011 From: per.melin@REDACTED (Per Melin) Date: Sun, 3 Apr 2011 18:40:57 +0200 Subject: [erlang-questions] False negatives in EUnit Message-ID: Below are five EUnit tests that all pass without so much as a warning. If you're an experienced EUnit user you will tell me that they are all illegal tests, which they are. But is it obvious? If you are less experienced with EUnit, or maybe just a little clumsy, or go too fast when you refactor a test you could write something like this, and you may never know. All it takes is that you fail to spot the missing or extra underscore. To silently hide errors is the last thing I want in a testing framework. Is there a way to fix this? a_test() -> ?_assertEqual(1, 2). b_test() -> ?_test(?assertEqual(1, 2)). c_test_() -> ?_test(fun() -> 1 = 2 end). d_test_() -> [fun() -> ?_assertEqual(1, 2) end]. e_test() -> {setup, fun() -> ok end, [?_assertEqual(1, 2)]}. ======================== EUnit ======================== module 'oops' oops:12: c_test_...ok oops: a_test...ok oops: b_test...ok oops: d_test_...ok oops: e_test...ok [done in 0.017 s] ======================================================= All 5 tests passed. From s.j.thompson@REDACTED Sun Apr 3 19:12:01 2011 From: s.j.thompson@REDACTED (Simon Thompson) Date: Sun, 3 Apr 2011 18:12:01 +0100 Subject: [erlang-questions] Re: False negatives in EUnit In-Reply-To: References: Message-ID: <6C610BC9-27D9-4EC6-B165-B67ECC5CA22B@kent.ac.uk> Per - yes, I have been looking at EUnit tests / refactoring - together with Thomas Arts and Huiqing Li - and one option that we discussed was to indicate potential errors of this sort: things like this are not strictly "illegal" but probably worth checking in more detail. Of course, it's difficult to spot all cases, but the mismatches here make plain that something untoward is probably happening. I guess they are in fact false *positives* - tests that pass which shouldn't: the worst kind of erroneous test. Regards Simon On 3 Apr 2011, at 17:40, Per Melin wrote: > Below are five EUnit tests that all pass without so much as a warning. > If you're an experienced EUnit user you will tell me that they are all > illegal tests, which they are. But is it obvious? If you are less > experienced with EUnit, or maybe just a little clumsy, or go too fast > when you refactor a test you could write something like this, and you > may never know. All it takes is that you fail to spot the missing or > extra underscore. > > To silently hide errors is the last thing I want in a testing > framework. Is there a way to fix this? > > a_test() -> > ?_assertEqual(1, 2). > > b_test() -> > ?_test(?assertEqual(1, 2)). > > c_test_() -> > ?_test(fun() -> 1 = 2 end). > > d_test_() -> > [fun() -> ?_assertEqual(1, 2) end]. > > e_test() -> > {setup, > fun() -> ok end, > [?_assertEqual(1, 2)]}. > > > ======================== EUnit ======================== > module 'oops' > oops:12: c_test_...ok > oops: a_test...ok > oops: b_test...ok > oops: d_test_...ok > oops: e_test...ok > [done in 0.017 s] > ======================================================= > All 5 tests passed. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From per.melin@REDACTED Sun Apr 3 20:34:45 2011 From: per.melin@REDACTED (Per Melin) Date: Sun, 3 Apr 2011 20:34:45 +0200 Subject: [erlang-questions] Re: False negatives in EUnit In-Reply-To: <6C610BC9-27D9-4EC6-B165-B67ECC5CA22B@kent.ac.uk> References: <6C610BC9-27D9-4EC6-B165-B67ECC5CA22B@kent.ac.uk> Message-ID: On Sun, Apr 3, 2011 at 7:12 PM, Simon Thompson wrote: > Per - yes, I have been looking at EUnit tests / refactoring - together with Thomas Arts and Huiqing Li - ?and one option that we discussed was to indicate potential errors of this sort: things like this are not strictly "illegal" but probably worth checking in more detail. Of course, it's difficult to spot all cases, but the mismatches here make plain that something untoward is probably happening. I assume this is something you are doing as a part of Wrangler? > I guess they are in fact false *positives* - tests that pass which shouldn't: the worst kind of erroneous test. If you want to call them positives or negatives depend on how you frame it. :) When I wrote the subject line I was thinking that the role of EUnit is to detect errors, and failure to do so would be a false negative. From s.j.thompson@REDACTED Sun Apr 3 21:17:33 2011 From: s.j.thompson@REDACTED (Simon Thompson) Date: Sun, 3 Apr 2011 20:17:33 +0100 Subject: [erlang-questions] Re: False negatives in EUnit In-Reply-To: References: <6C610BC9-27D9-4EC6-B165-B67ECC5CA22B@kent.ac.uk> Message-ID: On 3 Apr 2011, at 19:34, Per Melin wrote: > On Sun, Apr 3, 2011 at 7:12 PM, Simon Thompson wrote: >> Per - yes, I have been looking at EUnit tests / refactoring - together with Thomas Arts and Huiqing Li - and one option that we discussed was to indicate potential errors of this sort: things like this are not strictly "illegal" but probably worth checking in more detail. Of course, it's difficult to spot all cases, but the mismatches here make plain that something untoward is probably happening. > > I assume this is something you are doing as a part of Wrangler? Yes, that's right. > > >> I guess they are in fact false *positives* - tests that pass which shouldn't: the worst kind of erroneous test. > > If you want to call them positives or negatives depend on how you > frame it. :) When I wrote the subject line I was thinking that the > role of EUnit is to detect errors, and failure to do so would be a > false negative. Indeed. Problems whatever! Regards Simon From erlangsiri@REDACTED Mon Apr 4 11:41:48 2011 From: erlangsiri@REDACTED (Siri Hansen) Date: Mon, 4 Apr 2011 11:41:48 +0200 Subject: [erlang-questions] Re: Configuring sasl to write rb-compatible logs In-Reply-To: References: Message-ID: Hi Gleb - I don't know if you have already sorted this out by yourself - but anyway... You just have an underscore too much in your config file. 'error_logger_mf_max_files' should be 'error_logger_mf_maxfiles'! I will have a look at the error reason - I think it should be pointing closer to the real error... Regards /siri@REDACTED 2011/3/31 Gleb Peregud > Hi > > I'm digging into using rb for log viewing. As far as I understood from > documentation, some blogs and other emails here it is enough to define > the following parameters in the sasl application's config: > > error_logger_mf_dir > error_logger_mf_maxbytes > error_logger_mf_max_files > > Here's an output of my test: > > ============================================ > gleber@REDACTED:~/tmp/test$ ls > rb.config test.sh > > gleber@REDACTED:~/tmp/test$ cat rb.config > [ > {sasl, [ > {error_logger_mf_dir, "."}, > {error_logger_mf_maxbytes, 1024}, > {error_logger_mf_max_files, 10} > ] > } > ]. > > gleber@REDACTED:~/tmp/test$ cat test.sh > #!/bin/sh > > exec erl -sname test \ > -config rb \ > -boot start_sasl > > gleber@REDACTED:~/tmp/test$ ./test.sh > Erlang R14A (erts-5.8) [source] [smp:2:2] [rq:2] [async-threads:0] > [kernel-poll:false] > > > =PROGRESS REPORT==== 31-Mar-2011::20:36:09 === > supervisor: {local,sasl_safe_sup} > started: [{pid,<0.41.0>}, > {name,alarm_handler}, > {mfargs,{alarm_handler,start_link,[]}}, > {restart_type,permanent}, > {shutdown,2000}, > {child_type,worker}] > > =PROGRESS REPORT==== 31-Mar-2011::20:36:09 === > supervisor: {local,sasl_safe_sup} > started: [{pid,<0.42.0>}, > {name,overload}, > {mfargs,{overload,start_link,[]}}, > {restart_type,permanent}, > {shutdown,2000}, > {child_type,worker}] > > =PROGRESS REPORT==== 31-Mar-2011::20:36:09 === > supervisor: {local,sasl_sup} > started: [{pid,<0.40.0>}, > {name,sasl_safe_sup}, > {mfargs, > {supervisor,start_link, > [{local,sasl_safe_sup},sasl,safe]}}, > {restart_type,permanent}, > {shutdown,infinity}, > {child_type,supervisor}] > > =PROGRESS REPORT==== 31-Mar-2011::20:36:09 === > supervisor: {local,sasl_sup} > started: [{pid,<0.43.0>}, > {name,release_handler}, > {mfargs,{release_handler,start_link,[]}}, > {restart_type,permanent}, > {shutdown,2000}, > {child_type,worker}] > > =PROGRESS REPORT==== 31-Mar-2011::20:36:09 === > application: sasl > started_at: test@REDACTED > Eshell V5.8 (abort with ^G) > (test@REDACTED)1> rb:start(). > {error,{"cannot read the index file", > {child,undefined,rb_server, > {rb,start_link,[[]]}, > temporary,brutal_kill,worker, > [rb]}}} > (test@REDACTED)2> > =CRASH REPORT==== 31-Mar-2011::20:36:11 === > crasher: > initial call: rb:init/1 > pid: <0.49.0> > registered_name: [] > exception exit: "cannot read the index file" > in function gen_server:init_it/6 > ancestors: [sasl_sup,<0.38.0>] > messages: [] > links: [<0.39.0>] > dictionary: [] > trap_exit: true > status: running > heap_size: 233 > stack_size: 24 > reductions: 266 > neighbours: > > (test@REDACTED)2> q(). > ok > (test@REDACTED)3> > > gleber@REDACTED:~/tmp/test$ ls > rb.config test.sh > ============================================ > > Am I missing something in the configuration of sasl or is there > anything else I have to do to make sasl attach error_logger_mf_h to > error logger? > > Best, > Gleb Peregud > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From gleber.p@REDACTED Mon Apr 4 11:54:54 2011 From: gleber.p@REDACTED (Gleb Peregud) Date: Mon, 4 Apr 2011 11:54:54 +0200 Subject: [erlang-questions] Re: Configuring sasl to write rb-compatible logs In-Reply-To: References: Message-ID: On Mon, Apr 4, 2011 at 11:41, Siri Hansen wrote: > Hi Gleb - I don't know if you have already sorted this out by yourself - but > anyway... You just have an underscore too much in your config file. > 'error_logger_mf_max_files' should be 'error_logger_mf_maxfiles'! > I will have a look at the error reason - I think it should be pointing > closer to the real error... > Regards > /siri@REDACTED This fixes the issue. Siri, thank you a lot! Best, Gleb From jean-sebastien.pedron@REDACTED Mon Apr 4 11:59:54 2011 From: jean-sebastien.pedron@REDACTED (=?ISO-8859-1?Q?Jean-S=E9bastien_P=E9dron?=) Date: Mon, 04 Apr 2011 11:59:54 +0200 Subject: [erlang-questions] Re: Using the -M dependencies generator of erlc In-Reply-To: <20110403095918.GA23931@wellquite.org> References: <20110403095918.GA23931@wellquite.org> Message-ID: <4D99969A.3050109@dumbbell.fr> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi! On 03.04.2011 11:59, Matthew Sackman wrote: > As the man page says, this is only for tracking header dependencies, > which, IME, is at best only part of the story. Tracking behaviours and > parse_transformers are just as, if not more, important. You're completly right. When I made the patch to add dependencies tracking (2007), I didn't knew about parse transform and totally forget the behaviours. I'll fix this when I have some spare time. > (...) you get just one file of additional dependencies which you can > then -include into your Makefile). Concerning the "Pbeam pollution", I kept GCC's behaviour, because my goal was to add Erlang support to automake and I didn't want to mess up too much with automake's code. I'll fix the -MF option to be able to write all rules to one Makefile (or add another option). Thanks for your feedbacks to both of you! - -- Jean-S?bastien P?dron -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.17 (FreeBSD) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk2ZlpoACgkQa+xGJsFYOlNLwwCg0joG+rnyLNKrYGHnqt25UGO6 kFoAn2UiwBQqXTY32atT2IUfUs4AJfjJ =d0Zt -----END PGP SIGNATURE----- From erlangsiri@REDACTED Mon Apr 4 12:10:14 2011 From: erlangsiri@REDACTED (Siri Hansen) Date: Mon, 4 Apr 2011 12:10:14 +0200 Subject: [erlang-questions] Re: Configuring sasl to write rb-compatible logs In-Reply-To: References: Message-ID: Having had a closer look at this, I think that the error reason from rb is ok. From rb's point of view the problem is actually that it can not read the index file. However, as it is now, the sasl application will - successfully start, and add the log_mf_h report handler, if all three environment variables are given with valid values - successfully start, but not add the log_mf_h report handler, if some or all of the three environment variables are missing - fail to start if any of the three environment variables are given with an invalid value I actually think that the startup of sasl should fail also in the case when some *but not all* of the three environment variables are given. I will correct that. Regards /siri 2011/4/4 Siri Hansen > Hi Gleb - I don't know if you have already sorted this out by yourself - > but anyway... You just have an underscore too much in your config file. > 'error_logger_mf_max_files' should be 'error_logger_mf_maxfiles'! > > I will have a look at the error reason - I think it should be pointing > closer to the real error... > > Regards > /siri@REDACTED > > > 2011/3/31 Gleb Peregud > >> Hi >> >> I'm digging into using rb for log viewing. As far as I understood from >> documentation, some blogs and other emails here it is enough to define >> the following parameters in the sasl application's config: >> >> error_logger_mf_dir >> error_logger_mf_maxbytes >> error_logger_mf_max_files >> >> Here's an output of my test: >> >> ============================================ >> gleber@REDACTED:~/tmp/test$ ls >> rb.config test.sh >> >> gleber@REDACTED:~/tmp/test$ cat rb.config >> [ >> {sasl, [ >> {error_logger_mf_dir, "."}, >> {error_logger_mf_maxbytes, 1024}, >> {error_logger_mf_max_files, 10} >> ] >> } >> ]. >> >> gleber@REDACTED:~/tmp/test$ cat test.sh >> #!/bin/sh >> >> exec erl -sname test \ >> -config rb \ >> -boot start_sasl >> >> gleber@REDACTED:~/tmp/test$ ./test.sh >> Erlang R14A (erts-5.8) [source] [smp:2:2] [rq:2] [async-threads:0] >> [kernel-poll:false] >> >> >> =PROGRESS REPORT==== 31-Mar-2011::20:36:09 === >> supervisor: {local,sasl_safe_sup} >> started: [{pid,<0.41.0>}, >> {name,alarm_handler}, >> {mfargs,{alarm_handler,start_link,[]}}, >> {restart_type,permanent}, >> {shutdown,2000}, >> {child_type,worker}] >> >> =PROGRESS REPORT==== 31-Mar-2011::20:36:09 === >> supervisor: {local,sasl_safe_sup} >> started: [{pid,<0.42.0>}, >> {name,overload}, >> {mfargs,{overload,start_link,[]}}, >> {restart_type,permanent}, >> {shutdown,2000}, >> {child_type,worker}] >> >> =PROGRESS REPORT==== 31-Mar-2011::20:36:09 === >> supervisor: {local,sasl_sup} >> started: [{pid,<0.40.0>}, >> {name,sasl_safe_sup}, >> {mfargs, >> {supervisor,start_link, >> [{local,sasl_safe_sup},sasl,safe]}}, >> {restart_type,permanent}, >> {shutdown,infinity}, >> {child_type,supervisor}] >> >> =PROGRESS REPORT==== 31-Mar-2011::20:36:09 === >> supervisor: {local,sasl_sup} >> started: [{pid,<0.43.0>}, >> {name,release_handler}, >> {mfargs,{release_handler,start_link,[]}}, >> {restart_type,permanent}, >> {shutdown,2000}, >> {child_type,worker}] >> >> =PROGRESS REPORT==== 31-Mar-2011::20:36:09 === >> application: sasl >> started_at: test@REDACTED >> Eshell V5.8 (abort with ^G) >> (test@REDACTED)1> rb:start(). >> {error,{"cannot read the index file", >> {child,undefined,rb_server, >> {rb,start_link,[[]]}, >> temporary,brutal_kill,worker, >> [rb]}}} >> (test@REDACTED)2> >> =CRASH REPORT==== 31-Mar-2011::20:36:11 === >> crasher: >> initial call: rb:init/1 >> pid: <0.49.0> >> registered_name: [] >> exception exit: "cannot read the index file" >> in function gen_server:init_it/6 >> ancestors: [sasl_sup,<0.38.0>] >> messages: [] >> links: [<0.39.0>] >> dictionary: [] >> trap_exit: true >> status: running >> heap_size: 233 >> stack_size: 24 >> reductions: 266 >> neighbours: >> >> (test@REDACTED)2> q(). >> ok >> (test@REDACTED)3> >> >> gleber@REDACTED:~/tmp/test$ ls >> rb.config test.sh >> ============================================ >> >> Am I missing something in the configuration of sasl or is there >> anything else I have to do to make sasl attach error_logger_mf_h to >> error logger? >> >> Best, >> Gleb Peregud >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From matthew@REDACTED Mon Apr 4 12:14:50 2011 From: matthew@REDACTED (Matthew Sackman) Date: Mon, 4 Apr 2011 11:14:50 +0100 Subject: [erlang-questions] Re: Using the -M dependencies generator of erlc In-Reply-To: <4D99969A.3050109@dumbbell.fr> References: <20110403095918.GA23931@wellquite.org> <4D99969A.3050109@dumbbell.fr> Message-ID: <20110404101449.GA20008@rabbitmq.com> On Mon, Apr 04, 2011 at 11:59:54AM +0200, Jean-S?bastien P?dron wrote: > You're completly right. When I made the patch to add dependencies > tracking (2007), I didn't knew about parse transform and totally forget > the behaviours. I'll fix this when I have some spare time. Cool. However, be very careful: some simple testing of mine over the weekend shows that erlc -M needs the AST to get through the linter (and other steps). If the source file depends on a parse transformer then there's the possibility that whilst the AST of the source is formable, it's entirely possible that without the parse transformer being run on the AST, it won't get through subsequent stages of the compiler and make it to the -M steps. Thus I suspect the -M bits are in the wrong place and need to be move much much higher up the chain, to a point pre any parse transformers or anything like that has been run. Best wishes, Matthew From matthias@REDACTED Mon Apr 4 15:12:00 2011 From: matthias@REDACTED (Matthias Lang) Date: Mon, 4 Apr 2011 15:12:00 +0200 Subject: [erlang-questions] how do I get escript to emit all output before exiting? Message-ID: <20110404131200.GA3724@corelatus.se> Hi, I'm using R14B02, locally compiled, on an x86-64. I have this escript: #!/usr/bin/env escript main(_) -> Line = "This is a string which is not quite eighty characters long.\n", Log = [lists:duplicate(600, Line), "last line\n"], file:write_file("/tmp/syslog", Log), {ok, Bin} = file:read_file("/tmp/syslog"), io:put_chars([Bin, "\n"]), init:stop(). I expect the last two lines of output to be: This is a string which is not quite eighty characters long. last line But this is what running the program actually looks like: ~ >./truncated_io This is a string which is not quite eighty characters long. [about 100 lines removed by me when writing this mail] This is a string which is not quite eighty characters long.~ > Running the same code as a module works as expected, i.e. I see every line of output. How do I get escript to reliably print everything? Up until today, I thought init:stop() was enough. Matt From matthias@REDACTED Mon Apr 4 15:32:49 2011 From: matthias@REDACTED (Matthias Lang) Date: Mon, 4 Apr 2011 15:32:49 +0200 Subject: [erlang-questions] how do I get the actual list of arguments passed to an escript? Message-ID: <20110404133249.GA3964@corelatus.se> Hi, This escript: #!/usr/bin/env escript main(Args) -> io:fwrite("Args=~p\n", [Args]). looks like this when it runs (from bash, on *nix, using R14B02): ~ >./args one two "three and four are one argument" Args=["one","two","three","and","four","are","one","argument"] The escript manpage (e.g. http://www.erlang.org/doc/man/escript.html) claims the main/1 function will be called with a list of strings representing the arguments given to the script (not changed or interpreted in any way). which is why I was expecting Args=["one","two","three and four are one argument"] How can I get the arguments without Erlang changing and interpreting them? Matt From roberto@REDACTED Mon Apr 4 15:41:28 2011 From: roberto@REDACTED (Roberto Ostinelli) Date: Mon, 4 Apr 2011 15:41:28 +0200 Subject: [erlang-questions] Re: how do I get the actual list of arguments passed to an escript? In-Reply-To: <20110404133249.GA3964@corelatus.se> References: <20110404133249.GA3964@corelatus.se> Message-ID: > > ~ >./args one two "three and four are one argument" > Args=["one","two","three","and","four","are","one","argument"] > > The escript manpage (e.g. http://www.erlang.org/doc/man/escript.html) > claims > > the main/1 function will be called with a list of strings > representing the arguments given to the script (not changed or > interpreted in any way). > > which is why I was expecting > > Args=["one","two","three and four are one argument"] > > How can I get the arguments without Erlang changing and interpreting them? > > Matt > ./args one two 'three and four are one argument' r. -------------- next part -------------- An HTML attachment was scrubbed... URL: From qwertymaniac@REDACTED Mon Apr 4 15:45:04 2011 From: qwertymaniac@REDACTED (Harsh J) Date: Mon, 4 Apr 2011 19:15:04 +0530 Subject: [erlang-questions] Re: how do I get the actual list of arguments passed to an escript? In-Reply-To: <20110404133249.GA3964@corelatus.se> References: <20110404133249.GA3964@corelatus.se> Message-ID: I'm unable to reproduce your problem on R14B02. Here's my log: http://paste.pocoo.org/show/365354/ What's your bash version? Single quotes work normally for me as well. On Mon, Apr 4, 2011 at 7:02 PM, Matthias Lang wrote: > Hi, > > This escript: > > ?#!/usr/bin/env escript > > ?main(Args) -> > ? ?io:fwrite("Args=~p\n", [Args]). > > looks like this when it runs (from bash, on *nix, using R14B02): > > ?~ >./args one two "three ?and four are one argument" > ?Args=["one","two","three","and","four","are","one","argument"] > > The escript manpage (e.g. http://www.erlang.org/doc/man/escript.html) claims > > ?the main/1 function will be called with a list of strings > ?representing the arguments given to the script (not changed or > ?interpreted in any way). > > which is why I was expecting > > ?Args=["one","two","three ?and four are one argument"] > > How can I get the arguments without Erlang changing and interpreting them? > > Matt > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -- Harsh J http://harshj.com From bengt.kleberg@REDACTED Mon Apr 4 15:46:36 2011 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Mon, 4 Apr 2011 15:46:36 +0200 Subject: [erlang-questions] Re: how do I get the actual list of arguments passed to an escript? In-Reply-To: References: <20110404133249.GA3964@corelatus.se> Message-ID: <1301924796.7995.30.camel@seasc1137> Greetings, It could be that it is the unix shell that is interpreting your arguments for you, before calling erlang. Please try: ~ >./args one two 'three and four are one argument' bengt On Mon, 2011-04-04 at 15:41 +0200, Roberto Ostinelli wrote: > ~ >./args one two "three and four are one argument" > Args=["one","two","three","and","four","are","one","argument"] > > The escript manpage (e.g. > http://www.erlang.org/doc/man/escript.html) claims > > the main/1 function will be called with a list of strings > representing the arguments given to the script (not changed > or > interpreted in any way). > > which is why I was expecting > > Args=["one","two","three and four are one argument"] > > How can I get the arguments without Erlang changing and > interpreting them? > > Matt > > ./args one two 'three and four are one argument' > > r. > From matthias@REDACTED Mon Apr 4 15:55:18 2011 From: matthias@REDACTED (Matthias Lang) Date: Mon, 4 Apr 2011 15:55:18 +0200 Subject: [erlang-questions] Re: how do I get the actual list of arguments passed to an escript? In-Reply-To: References: <20110404133249.GA3964@corelatus.se> Message-ID: <20110404135518.GA4120@corelatus.se> On Monday, April 04, Harsh J wrote: > I'm unable to reproduce your problem on R14B02. Here's my log: > http://paste.pocoo.org/show/365354/ > What's your bash version? Single quotes work normally for me as well. 4.1.5(1)-release Thanks for trying. That made me look a bit closer: tmp >/usr/local/src/otp_src_R14B02/bin/escript args "one two" Args=["one two"] tmp >ln -s /usr/local/src/otp_src_R14B02/bin/escript . tmp >./escript args "one two" Args=["one","two"] There's something odd going on. Matt From hm@REDACTED Mon Apr 4 15:56:51 2011 From: hm@REDACTED (=?ISO-8859-1?Q?H=E5kan_Mattsson?=) Date: Mon, 4 Apr 2011 15:56:51 +0200 Subject: [erlang-questions] Re: how do I get escript to emit all output before exiting? In-Reply-To: <20110404131200.GA3724@corelatus.se> References: <20110404131200.GA3724@corelatus.se> Message-ID: On Mon, Apr 4, 2011 at 3:12 PM, Matthias Lang wrote: > Hi, > > I'm using R14B02, locally compiled, on an x86-64. I have this escript: > > ? ?#!/usr/bin/env escript > > ? ?main(_) -> > ? ? ? ?Line = "This is a string which is not quite eighty characters long.\n", > ? ? ? ?Log = [lists:duplicate(600, Line), "last line\n"], > ? ? ? ?file:write_file("/tmp/syslog", Log), > ? ? ? ?{ok, Bin} = file:read_file("/tmp/syslog"), > ? ? ? ?io:put_chars([Bin, "\n"]), > ? ? ? ?init:stop(). > > I expect the last two lines of output to be: > > ? This is a string which is not quite eighty characters long. > ? last line > > But this is what running the program actually looks like: > > ? ~ >./truncated_io > ? This is a string which is not quite eighty characters long. > ? [about 100 lines removed by me when writing this mail] > ? This is a string which is not quite eighty characters long.~ > > > Running the same code as a module works as expected, i.e. I see > every line of output. > > How do I get escript to reliably print everything? Up until today, > I thought init:stop() was enough. The problem is probably that init:stop() returns before all output has been emitted. Try: init:stop(), receive after infinity -> ok end. /H?kan From lemenkov@REDACTED Mon Apr 4 16:20:44 2011 From: lemenkov@REDACTED (Peter Lemenkov) Date: Mon, 4 Apr 2011 18:20:44 +0400 Subject: [erlang-questions] Fedora GSoC 2011 and Erlang-related proposal Message-ID: Hello All! Fist of all sorry if you received multiple copies of this message. I'm participating as a mentor from Fedora Community in the Google Summer of Code 2011. My proposal is to integrate further Erlang with RPM (automatic provides/requires generation, live upgrades within init-script's reload/restart commands, creating RPM package directly from the rebar and perhaps something else). Unfortunately the deadline is near (08-04-2011) and nobody has volunteered so far. In order to achieve the desired goals the participant - *must* be a Fedora user. Fedora 15 is preferred (alpha version was released few weeks ago). Actually you don't need to install it on bare metal - you may use any virtualization software you want. - *should* be familiar with RPM packaging - *must* have at least superficial Erlang experience (I mean you should be able to create something more sophisticated than ping-pong example - you have only few days to learn!) - *should* be familiar with Git - *must* be eligible to participate in GSoC (in short - you're student or postgraduate) This is a one-person position. It won't require full-time participation (i think this will require ~5-10 hours per week or even less). If you're interested then please drop me a line *immediately* (our time is short). And under "line" I mean very informal CV^W self-introduction - with brief description of your skills, desired goals and motivation, GitHub account, whatever else you think is relevant. Please don't be shy if you think you're not a Great Rock Star Developer - the main goal of GSoC is to teach you something new, not to examine you. If you know a person who might be interested - forward him this message, please. Also please note that I *cannot* guarantee that this proposal will be finally approved - there are many other competing proposals (you may chose one of them instead of mine one) and some of them are very interesting indeed: https://fedoraproject.org/wiki/Summer_coding_ideas_for_2011 Anyway we should try. -- With best regards, Peter Lemenkov. From coa@REDACTED Mon Apr 4 16:41:52 2011 From: coa@REDACTED (=?ISO-8859-1?Q?Cl=E1udio_Amaral?=) Date: Mon, 04 Apr 2011 16:41:52 +0200 Subject: [erlang-questions] dialyzer --build_plt Message-ID: <4D99D8B0.4090804@dcc.fc.up.pt> Hello all! I wanted to check out dialyzer but I got some errors when trying to build the initial plt with --apps sdtlib syntax_tools kernel After some googling, I found this http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=532757 I am using ubuntu and it looks I have this problem (erlang: Installed: 1:13.b.3-dfsg-2ubuntu2.1). Anyone knows the workaround? Couldn't find that... Thanks, Cl?udio. From kostis@REDACTED Mon Apr 4 16:46:02 2011 From: kostis@REDACTED (Kostis Sagonas) Date: Mon, 04 Apr 2011 17:46:02 +0300 Subject: [erlang-questions] Re: dialyzer --build_plt In-Reply-To: <4D99D8B0.4090804@dcc.fc.up.pt> References: <4D99D8B0.4090804@dcc.fc.up.pt> Message-ID: <4D99D9AA.6000403@cs.ntua.gr> Cl?udio Amaral wrote: > Hello all! > > I wanted to check out dialyzer but I got some errors when trying to > build the initial plt with --apps sdtlib syntax_tools kernel > > After some googling, I found this > > http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=532757 > > I am using ubuntu and it looks I have this problem (erlang: Installed: > 1:13.b.3-dfsg-2ubuntu2.1). > > Anyone knows the workaround? Couldn't find that... Use the source version from www.erlang.org? Kostis From coa@REDACTED Mon Apr 4 16:51:48 2011 From: coa@REDACTED (=?ISO-8859-1?Q?Cl=E1udio_Amaral?=) Date: Mon, 04 Apr 2011 16:51:48 +0200 Subject: [erlang-questions] Re: dialyzer --build_plt In-Reply-To: <4D99D9AA.6000403@cs.ntua.gr> References: <4D99D8B0.4090804@dcc.fc.up.pt> <4D99D9AA.6000403@cs.ntua.gr> Message-ID: <4D99DB04.4060101@dcc.fc.up.pt> On 04/04/2011 04:46 PM, Kostis Sagonas wrote: > Cl?udio Amaral wrote: >> Hello all! >> >> I wanted to check out dialyzer but I got some errors when trying to >> build the initial plt with --apps sdtlib syntax_tools kernel >> >> After some googling, I found this >> >> http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=532757 >> >> I am using ubuntu and it looks I have this problem (erlang: >> Installed: 1:13.b.3-dfsg-2ubuntu2.1). >> >> Anyone knows the workaround? Couldn't find that... > > Use the source version from www.erlang.org? > > Kostis I was hoping for something that would be easier (a package somewhere), but I guess that is just wishfull thinking. By the way, why is the debug information striped out everywhere (opposed to have it like that for the systems that need it)? Cl?udio From vinoski@REDACTED Mon Apr 4 16:53:20 2011 From: vinoski@REDACTED (Steve Vinoski) Date: Mon, 4 Apr 2011 10:53:20 -0400 Subject: [erlang-questions] Re: how do I get the actual list of arguments passed to an escript? In-Reply-To: References: <20110404133249.GA3964@corelatus.se> Message-ID: On Mon, Apr 4, 2011 at 9:41 AM, Roberto Ostinelli wrote: >> ? ~ >./args one two "three ?and four are one argument" >> ?Args=["one","two","three","and","four","are","one","argument"] >> >> The escript manpage (e.g. http://www.erlang.org/doc/man/escript.html) >> claims >> >> ?the main/1 function will be called with a list of strings >> ?representing the arguments given to the script (not changed or >> ?interpreted in any way). >> >> which is why I was expecting >> >> ?Args=["one","two","three ?and four are one argument"] >> >> How can I get the arguments without Erlang changing and interpreting them? >> >> Matt > > ./args one two 'three and four are one argument' For the purposes of this issue, there's no difference between using double quotes and single quotes to enclose that final argument. The primary difference between the quote types has to do with interpretation of the $ special character -- it's interpreted within double quotes but not within single quotes. Since that special character does not appear here, each should work equally well, and on my machines with R14B02 and bash versions 3.2.48(1)-release and 4.1.5(1)-release, that's exactly the case. Csh does some weird stuff with quoting when compared to Bourne-derived shells, but for me this case even works with csh. The usual cause of this problem is a script that fails to use "$@", exactly like that, to pass arguments to a secondary program. For example, save this to /tmp/foo: #!/bin/sh echo '$*:' awk 'BEGIN { for (i = 1; i < ARGC; i++) print ARGV[i] }' Message-ID: <610593488.57271301929297842.JavaMail.root@zimbra> You can fetch R14B as a ubuntu compatible package here: http://www.erlang-solutions.com/section/72/packages I don't know if the debug info is compiled into that package, but might be worth checking out anyways. Lukas ----- Original Message ----- From: "Cl?udio Amaral" To: "Kostis Sagonas" Cc: erlang-questions@REDACTED Sent: Monday, 4 April, 2011 16:51:48 GMT +01:00 Amsterdam / Berlin / Bern / Rome / Stockholm / Vienna Subject: [erlang-questions] Re: dialyzer --build_plt On 04/04/2011 04:46 PM, Kostis Sagonas wrote: > Cl?udio Amaral wrote: >> Hello all! >> >> I wanted to check out dialyzer but I got some errors when trying to >> build the initial plt with --apps sdtlib syntax_tools kernel >> >> After some googling, I found this >> >> http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=532757 >> >> I am using ubuntu and it looks I have this problem (erlang: >> Installed: 1:13.b.3-dfsg-2ubuntu2.1). >> >> Anyone knows the workaround? Couldn't find that... > > Use the source version from www.erlang.org? > > Kostis I was hoping for something that would be easier (a package somewhere), but I guess that is just wishfull thinking. By the way, why is the debug information striped out everywhere (opposed to have it like that for the systems that need it)? Cl?udio _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://erlang.org/mailman/listinfo/erlang-questions From kostis@REDACTED Mon Apr 4 17:01:47 2011 From: kostis@REDACTED (Kostis Sagonas) Date: Mon, 04 Apr 2011 18:01:47 +0300 Subject: [erlang-questions] Re: dialyzer --build_plt In-Reply-To: <4D99DB04.4060101@dcc.fc.up.pt> References: <4D99D8B0.4090804@dcc.fc.up.pt> <4D99D9AA.6000403@cs.ntua.gr> <4D99DB04.4060101@dcc.fc.up.pt> Message-ID: <4D99DD5B.4060806@cs.ntua.gr> Cl?udio Amaral wrote: > On 04/04/2011 04:46 PM, Kostis Sagonas wrote: >> Cl?udio Amaral wrote: >>> Hello all! >>> >>> I wanted to check out dialyzer but I got some errors when trying to >>> build the initial plt with --apps sdtlib syntax_tools kernel >>> >>> After some googling, I found this >>> >>> http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=532757 >>> >>> I am using ubuntu and it looks I have this problem (erlang: >>> Installed: 1:13.b.3-dfsg-2ubuntu2.1). >>> >>> Anyone knows the workaround? Couldn't find that... >> >> Use the source version from www.erlang.org? >> >> Kostis > I was hoping for something that would be easier (a package somewhere), > but I guess that is just wishfull thinking. > > By the way, why is the debug information striped out everywhere (opposed > to have it like that for the systems that need it)? Because the Ubuntu people do not understand the full consequences of their action (striping this information) and there aren't enough Ubuntu Erlang users who have protested loud enough to be heard. Kostis From matthias@REDACTED Mon Apr 4 17:27:34 2011 From: matthias@REDACTED (Matthias Lang) Date: Mon, 4 Apr 2011 17:27:34 +0200 Subject: [erlang-questions] Re: how do I get the actual list of arguments passed to an escript? In-Reply-To: References: <20110404133249.GA3964@corelatus.se> Message-ID: <20110404152734.GA12365@corelatus.se> Problem solved. TLDR: I outsmarted myself with a collection of symlinks and a broken shell script. Long version: here's what was happening 1. escript is a C program (part of the Erlang/OTP distribution) 2. escript shuffles arguments around and then actually runs 'erl', after figuring out which 'erl' to run. Unless you have the environment variable ESCRIPT_EMULATOR set, which you normally don't, then 'escript' tries to run 'erl' in the same directory as 'escript'. If 'escript' is a symlink, which it normally isn't, but is in my case, then the answer is a bare 'erl', i.e. "whatever's in the path". 3. The first 'erl' in my path is a shell script to an older Erlang: #! /usr/local/src/otp_src_R14B01/bin/erl $@ That's probably a left-over from some debugging effort. 4. The $@ variable in BASH is subject to "word splitting", but that can be disabled by writing "$@", which is equivalent to "$1" "$2" "$3" ... It feels like #3 and #4 ganged up to trick me... Without having thought it through much, I can't see why $@ doesn't always behave like "$@" (why would you want to word expand all arguments? By default?!). I thought about how to improve escript so that it doesn't end up running the wrong Erlang in situations like mine. I had two ideas: - The escript functionality could be rolled into 'erl', i.e. by having the 'erl' shell script do different things deending on the value of $0, like busybox or hd/hexdump. But that won't work on Windows (not that I care...) and involves writing more shell scripts which I tend to screw up. - escript.c could check if progname is a symlink and follow that link, recursively. That feels like a better idea. Or is there a gotcha? Thanks to "Harsh J" for putting me on the right track by showing that this problem is specific to my setup. And, just before posting this, I see that Steve Vinoski figured out #3 without even seeing my setup. Matt From raimo+erlang-questions@REDACTED Mon Apr 4 17:37:08 2011 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Mon, 4 Apr 2011 17:37:08 +0200 Subject: [erlang-questions] Re: how do I get the actual list of arguments passed to an escript? In-Reply-To: <20110404135518.GA4120@corelatus.se> References: <20110404133249.GA3964@corelatus.se> <20110404135518.GA4120@corelatus.se> Message-ID: <20110404153708.GA22190@erix.ericsson.se> On Mon, Apr 04, 2011 at 03:55:18PM +0200, Matthias Lang wrote: > On Monday, April 04, Harsh J wrote: > > > I'm unable to reproduce your problem on R14B02. Here's my log: > > http://paste.pocoo.org/show/365354/ > > > What's your bash version? Single quotes work normally for me as well. > > 4.1.5(1)-release > > Thanks for trying. That made me look a bit closer: > > tmp >/usr/local/src/otp_src_R14B02/bin/escript args "one two" > Args=["one two"] > tmp >ln -s /usr/local/src/otp_src_R14B02/bin/escript . > tmp >./escript args "one two" > Args=["one","two"] > > There's something odd going on. Indeed. I have tried that on our R14B02, with your escript, and the symlink both bash, csh and tcsh, and can not reproduce it. SLES 10 SP2 x86_64 $ ls -l ./escript lrwxrwxrwx 1 raimo users 37 2011-04-04 17:31 ./escript -> /opt/local/pgm/otp-r14b02/bin/escript $ tcsh raimo/tmp> ./escript ./args.esp "one and two" Args=["one and two"] > > Matt > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From matthias@REDACTED Mon Apr 4 18:21:52 2011 From: matthias@REDACTED (Matthias Lang) Date: Mon, 4 Apr 2011 18:21:52 +0200 Subject: [erlang-questions] Re: how do I get escript to emit all output before exiting? In-Reply-To: References: <20110404131200.GA3724@corelatus.se> Message-ID: <20110404162152.GA12787@corelatus.se> On Monday, April 04, H?kan Mattsson wrote: > The problem is probably that init:stop() returns before all output has > been emitted. Yes, that's right. Thanks. But it's not how I expect escript to behave, i.e. I expect escript to shut down cleanly by default. Looking at escript.erl: | my_halt(Reason) -> | case process_info(group_leader(), status) of | {_,waiting} -> | %% Now all output data is down in the driver. | %% Give the driver some extra time before halting. | receive after 1 -> ok end, | halt(Reason); | _ -> | %% Probably still processing I/O requests. | erlang:yield(), | my_halt(Reason) | end. the comments sort-of suggest that it's trying to cleanly shut down. What IO situation is the code above trying to take care of? Why not just my_halt(Reason) -> init:stop(Reason), receive after infinity -> ok end. Not sure if this is a bug or if I'm just expecting too much, but tossing output by default doesn't seem nice because it leads to code that seems to work except when it doesn't. Matthias From fritchie@REDACTED Mon Apr 4 19:24:39 2011 From: fritchie@REDACTED (Scott Lystig Fritchie) Date: Mon, 04 Apr 2011 12:24:39 -0500 Subject: [erlang-questions] Re: how do I get escript to emit all output before exiting? In-Reply-To: Message of "Mon, 04 Apr 2011 18:21:52 +0200." <20110404162152.GA12787@corelatus.se> Message-ID: <12524.1301937879@snookles.snookles.com> Matthias Lang wrote: ml> What IO situation is the code above trying to take care of? Why not ml> just ml> my_halt(Reason) -> ml> init:stop(Reason), ml> receive after infinity -> ok ml> end. ml> Not sure if this is a bug or if I'm just expecting too much, but ml> tossing output by default doesn't seem nice because it leads to code ml> that seems to work except when it doesn't. IIRC the stuff scribbled to the console via io:format() is actually done by sending messages to the group leader process. You're at the scheduler's whim to decide whether the group leader gets executed & processes the I/O requests before the VM halts. Having said that, I've been bitten by this same concurrency feature. C/Ruby/Python folks don't expect the feature. Even never-touched- another-language Erlang hackers may not expect it. But short of having a function like like escript:halt/1 to take the place of your my_halt() function ... and a whole lot of doc additions to point out that calling io:format() is **not** a thin wrapper around the syscall/stdlib calls: write(1, str, strlen(str)); /* OR */ fwrite(str, strlen(str), 1, stdout); ... I can't think of an easier fix. (Perhaps I simply need more coffee?) -Scott From moxford@REDACTED Mon Apr 4 20:06:18 2011 From: moxford@REDACTED (Mike Oxford) Date: Mon, 4 Apr 2011 11:06:18 -0700 Subject: [erlang-questions] Re: how do I get escript to emit all output before exiting? In-Reply-To: <12524.1301937879@snookles.snookles.com> References: <20110404162152.GA12787@corelatus.se> <12524.1301937879@snookles.snookles.com> Message-ID: What about having init:halt() send a sync'd message to the group leader to shut down? Once the group leader shuts down and returns then init:halt() will exit. Even without a group-leader shutdown, even having the group-leader return a ping-type message could unblock the init:halt() and ensure that you've processed the messages at least that far, thus "flushing the buffer." -mox On Mon, Apr 4, 2011 at 10:24 AM, Scott Lystig Fritchie < fritchie@REDACTED> wrote: > Matthias Lang wrote: > > ml> What IO situation is the code above trying to take care of? Why not > ml> just > > ml> my_halt(Reason) -> > ml> init:stop(Reason), > ml> receive after infinity -> ok > ml> end. > > ml> Not sure if this is a bug or if I'm just expecting too much, but > ml> tossing output by default doesn't seem nice because it leads to code > ml> that seems to work except when it doesn't. > > IIRC the stuff scribbled to the console via io:format() is actually done > by sending messages to the group leader process. You're at the > scheduler's whim to decide whether the group leader gets executed & > processes the I/O requests before the VM halts. > > Having said that, I've been bitten by this same concurrency feature. > C/Ruby/Python folks don't expect the feature. Even never-touched- > another-language Erlang hackers may not expect it. But short of having > a function like like escript:halt/1 to take the place of your my_halt() > function ... and a whole lot of doc additions to point out that calling > io:format() is **not** a thin wrapper around the syscall/stdlib calls: > > write(1, str, strlen(str)); > /* OR */ > fwrite(str, strlen(str), 1, stdout); > > ... I can't think of an easier fix. (Perhaps I simply need more > coffee?) > > -Scott > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From comptekki@REDACTED Mon Apr 4 21:28:09 2011 From: comptekki@REDACTED (Wes James) Date: Mon, 4 Apr 2011 13:28:09 -0600 Subject: [erlang-questions] application resource file Message-ID: The docs here: http://www.erlang.org/doc/design_principles/applications.html say: for the application part of the file: applications All applications which must be started before this application is started. .... but when I do application:start(myapp) with sasl in the applications section of the arf then I get an error {error,{not_started,sasl}}. If I manually start sasl, application:start(sasl), then run application:start(myapp), then I don't get this error. The docs say that items in this section will be started up before myapp starts. It doesn't seem to be that way. -wes From ulf.wiger@REDACTED Mon Apr 4 21:45:25 2011 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Mon, 4 Apr 2011 21:45:25 +0200 Subject: [erlang-questions] Re: application resource file In-Reply-To: References: Message-ID: <15B67307-553A-42F7-9AFD-C4767D77ACF6@erlang-solutions.com> The docs say "All applications which *must* be started?". It doesn't say that they will be started for you. If you start your applications manually, you must ensure that they are started in the right order. Note that an application dependency can be fulfilled by an app started on another node. If you generate a release, either using reltool, or simply building a bootscript either by hand, or by e.g. http://github.com/esl/setup, then systools will ensure that the applications are started in the right order. BR, Ulf W On 4 Apr 2011, at 21:28, Wes James wrote: > The docs here: > > http://www.erlang.org/doc/design_principles/applications.html > > say: > > for the application part of the file: > > applications > All applications which must be started before this application is started. .... > > but when I do application:start(myapp) with sasl in the applications > section of the arf then I get an error {error,{not_started,sasl}}. If > I manually start sasl, application:start(sasl), then run > application:start(myapp), then I don't get this error. The docs say > that items in this section will be started up before myapp starts. It > doesn't seem to be that way. > > -wes > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions Ulf Wiger, CTO, Erlang Solutions, Ltd. http://erlang-solutions.com From comptekki@REDACTED Mon Apr 4 21:54:46 2011 From: comptekki@REDACTED (Wes James) Date: Mon, 4 Apr 2011 13:54:46 -0600 Subject: [erlang-questions] Re: application resource file In-Reply-To: <15B67307-553A-42F7-9AFD-C4767D77ACF6@erlang-solutions.com> References: <15B67307-553A-42F7-9AFD-C4767D77ACF6@erlang-solutions.com> Message-ID: ok - I read it to mean "all these apps will be started before your app is started". thx, -wes On Mon, Apr 4, 2011 at 1:45 PM, Ulf Wiger wrote: > The docs say "All applications which *must* be started?". > It doesn't say that they will be started for you. > > If you start your applications manually, you must ensure that they are started in the right order. Note that an application dependency can be fulfilled by an app started on another node. > > If you generate a release, either using reltool, or simply building a bootscript either by hand, or by e.g. http://github.com/esl/setup, then systools will ensure that the applications are started in the right order. > > BR, > Ulf W > > On 4 Apr 2011, at 21:28, Wes James wrote: > >> The docs here: >> >> http://www.erlang.org/doc/design_principles/applications.html >> >> say: >> >> for the application part of the file: >> >> applications >> All applications which must be started before this application is started. .... >> >> but when I do application:start(myapp) with sasl in the applications >> section of the arf then I get an error {error,{not_started,sasl}}. ?If >> I manually start sasl, application:start(sasl), then run >> application:start(myapp), then I don't get this error. ?The docs say >> that items in this section will be started up before myapp starts. ?It >> doesn't seem to be that way. >> >> -wes >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions > > Ulf Wiger, CTO, Erlang Solutions, Ltd. > http://erlang-solutions.com > > > > From ericbmerritt@REDACTED Mon Apr 4 22:15:02 2011 From: ericbmerritt@REDACTED (Eric Merritt) Date: Mon, 4 Apr 2011 15:15:02 -0500 Subject: [erlang-questions] Re: Specifying 'erts' as an application In-Reply-To: <4D9868DB.5010602@cs.ntua.gr> References: <4D9868DB.5010602@cs.ntua.gr> Message-ID: I would really love it if someone with explicit knowledge of this chimes in. It actually matters quite a bit to sinan. As quick test I did the following. 2> application:start(erts). {error,{"no such file or directory","erts.app"}} That seems to confirm that the system does not consider it an application, but then again it could be an idiosyncrasy of the application module. Eric On Sun, Apr 3, 2011 at 7:32 AM, Kostis Sagonas wrote: > The Erlang/OTP documentation specifies 'erts' as an application: > > ?http://erlang.org/doc/applications.html > > In a project we are working on, we have an application resource file that > reads: > > ?{application, APP_NAME, > ? [{description, ...}, > ? ?... > ? ?{applications, [erts, kernel, stdlib, ...] > ? ?... > ? ]}. > > A user informed us that "erts isn't actually an application that can be > dependent upon and that having it in the applications list breaks releases". > > I personally consider this a bug, of Erlang/OTP that is, but I will gladly > be enlightened why 'erts' is listed as an OTP application but cannot be > listed in the application resource file and releases break miserably when > one does so. > > Kostis > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > From vances@REDACTED Tue Apr 5 02:19:42 2011 From: vances@REDACTED (Vance Shipley) Date: Mon, 4 Apr 2011 20:19:42 -0400 Subject: [erlang-questions] Running OTP Test Suites Message-ID: <20110405001933.GA4859@h216-235-12-174.host.egate.net> Could someone tell me the simple steps to run the test suites in OTP? -- -Vance From vinoski@REDACTED Tue Apr 5 03:03:20 2011 From: vinoski@REDACTED (Steve Vinoski) Date: Mon, 4 Apr 2011 21:03:20 -0400 Subject: [erlang-questions] Re: Running OTP Test Suites In-Reply-To: <20110405001933.GA4859@h216-235-12-174.host.egate.net> References: <20110405001933.GA4859@h216-235-12-174.host.egate.net> Message-ID: On Mon, Apr 4, 2011 at 8:19 PM, Vance Shipley wrote: > Could someone tell me the simple steps to run the test suites in OTP? https://github.com/erlang/otp/wiki/Running-tests --steve From piotr.dorobisz@REDACTED Tue Apr 5 09:09:22 2011 From: piotr.dorobisz@REDACTED (Piotr Dorobisz) Date: Tue, 5 Apr 2011 07:09:22 +0000 (GMT) Subject: [erlang-questions] Re: Running OTP Test Suites In-Reply-To: Message-ID: <813280730.58671301987362107.JavaMail.root@zimbra> ----- "Steve Vinoski" napisa?: > On Mon, Apr 4, 2011 at 8:19 PM, Vance Shipley > wrote: > > Could someone tell me the simple steps to run the test suites in > OTP? > > https://github.com/erlang/otp/wiki/Running-tests > > --steve I didn't manage to build tests using "make release_tests " as specified on wiki. I think that you should use otp_build script instead (at least it works for me): otp_build tests -- Piotr From watson.timothy@REDACTED Tue Apr 5 11:05:42 2011 From: watson.timothy@REDACTED (Tim Watson) Date: Tue, 5 Apr 2011 10:05:42 +0100 Subject: [erlang-questions] Re: application resource file In-Reply-To: References: <15B67307-553A-42F7-9AFD-C4767D77ACF6@erlang-solutions.com> Message-ID: On 4 April 2011 20:54, Wes James wrote: > ok - I read it to mean "all these apps will be started before your app > is started". > You might like to try this: https://github.com/hyperthunk/appstart From als@REDACTED Tue Apr 5 12:35:54 2011 From: als@REDACTED (Anthony Shipman) Date: Tue, 5 Apr 2011 21:35:54 +1100 Subject: [erlang-questions] Re: how do I get escript to emit all output before exiting? In-Reply-To: References: <20110404162152.GA12787@corelatus.se> <12524.1301937879@snookles.snookles.com> Message-ID: <201104052035.54445.als@iinet.net.au> On Tue, 5 Apr 2011 04:06:18 am Mike Oxford wrote: > What about having init:halt() send a sync'd message to the group leader to > shut down? > Once the group leader shuts down and returns then init:halt() will exit. > Even without a group-leader shutdown, even having the group-leader return a > ping-type message could unblock the init:halt() and ensure that you've > processed the messages at least that far, thus "flushing the buffer." > > -mox I find a 100ms delay solves the problem. -- Anthony Shipman Mamas don't let your babies als@REDACTED grow up to be outsourced. From alexey.v.romanov@REDACTED Tue Apr 5 13:17:41 2011 From: alexey.v.romanov@REDACTED (Alexey Romanov) Date: Tue, 5 Apr 2011 15:17:41 +0400 Subject: [erlang-questions] Changing heartbeat timeout while the system is running Message-ID: >From http://www.erlang.org/doc/man/heart.html I expect that heart only checks the value of HEART_BEAT_TIMEOUT on startup and it can't be changed while the program runs. Is this correct (I hope not)? Yours, Alexey Romanov From michael.santos@REDACTED Tue Apr 5 13:59:32 2011 From: michael.santos@REDACTED (Michael Santos) Date: Tue, 5 Apr 2011 07:59:32 -0400 Subject: [erlang-questions] Re: Changing heartbeat timeout while the system is running In-Reply-To: References: Message-ID: <20110405115932.GA23900@ecn.lan> On Tue, Apr 05, 2011 at 03:17:41PM +0400, Alexey Romanov wrote: > From http://www.erlang.org/doc/man/heart.html I expect that heart only > checks the value of HEART_BEAT_TIMEOUT on startup and it can't be > changed while the program runs. Is this correct (I hope not)? Yes, the value is only checked on startup. heart is a port, the timeout environment variable is passed as a command switch. heart already supports changing the reboot command on the fly (using heart:set_cmd/1), so adding support for HEART_BEAT_TIMEOUT and HEART_BEAT_BOOT_DELAY (maybe heart:set_timeout/1, heart:set_delay/1) looks simple. I can look into making a patch, if it'd be helpful. From hm@REDACTED Tue Apr 5 15:43:33 2011 From: hm@REDACTED (=?ISO-8859-1?Q?H=E5kan_Mattsson?=) Date: Tue, 5 Apr 2011 15:43:33 +0200 Subject: [erlang-questions] Re: file operations on zipped files (Re: how to add a module to preLoaded?) In-Reply-To: <4BEEE64D-1FA3-41B9-B97B-1AFB0304BD9E@erlang-solutions.com> References: <4BEEE64D-1FA3-41B9-B97B-1AFB0304BD9E@erlang-solutions.com> Message-ID: On Thu, Mar 31, 2011 at 8:04 PM, Ulf Wiger wrote: > The change in prim_file gives no overhead in the normal case, > except for an extra pattern-match on the error value, and - if > {error, enotdir}, a scan of the file name to see if there is a > .ez file in the path. If so, the corresponding action is mapped > on the archive. If the file is to be opened, as with epp, > a "read_file()" is done, and the contents moved into a > ram_file, which allows the same operations as prim_file. > > For this last case, I needed prim_ram_file in preloaded? Is erl_prim_loader:get_file(File) too slow for your needs? > A minor quirk is that code:lib_dir/1 has been defined to return > a path *outside* the zip archive, presumably because you cannot > load DLLs from an archive. Epp uses code:lib_dir/1 too, so even > with the above changes, epp would fail to find the .hrl > files. I solved this by having epp call code:where_is_file(Lib > ++ ".app") and then finding the include from there. If that > fails, it calls code:lib_dir/1 as before. Would it not be better if epp used code:lib_dir(App, include) instead? > I've not written a proper commit message (or actually sent this > to erlang-patches), nor have I updated documentation or written > test suites. If this approach is rejected on principle, I'd > rather not waste the time, so, feedback first, please. /H?kan From ulf.wiger@REDACTED Tue Apr 5 16:09:06 2011 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Tue, 5 Apr 2011 16:09:06 +0200 Subject: [erlang-questions] Re: file operations on zipped files (Re: how to add a module to preLoaded?) In-Reply-To: References: <4BEEE64D-1FA3-41B9-B97B-1AFB0304BD9E@erlang-solutions.com> Message-ID: On 5 Apr 2011, at 15:43, H?kan Mattsson wrote: > On Thu, Mar 31, 2011 at 8:04 PM, Ulf Wiger > wrote: > >> The change in prim_file gives no overhead in the normal case, >> except for an extra pattern-match on the error value, and - if >> {error, enotdir}, a scan of the file name to see if there is a >> .ez file in the path. If so, the corresponding action is mapped >> on the archive. If the file is to be opened, as with epp, >> a "read_file()" is done, and the contents moved into a >> ram_file, which allows the same operations as prim_file. >> >> For this last case, I needed prim_ram_file in preloaded? > > Is erl_prim_loader:get_file(File) too slow for your needs? Surely not, but how does that help in this case? I assume you mean that I could have used that function rather than implementing my own read_file_from_archive()? I definitely would if I had known about it. Since it's even documented, I can only blame my own ignorance. (: So is your suggestion to call erl_prim_loader:get_file/1 instead of the prim_file:try_zip_read_file/2 that I wrote? (https://github.com/uwiger/otp/blob/uw-prim_file-reads-zip/erts/preloaded/src/prim_file.erl#L577) or did you have something else in mind? I suspect you are among the few who can claim any depth of knowledge in this area. > >> A minor quirk is that code:lib_dir/1 has been defined to return >> a path *outside* the zip archive, presumably because you cannot >> load DLLs from an archive. Epp uses code:lib_dir/1 too, so even >> with the above changes, epp would fail to find the .hrl >> files. I solved this by having epp call code:where_is_file(Lib >> ++ ".app") and then finding the include from there. If that >> fails, it calls code:lib_dir/1 as before. > > Would it not be better if epp used code:lib_dir(App, include) instead? That function suffers from the same "problem" as code:lib_dir(App) - in the case of a zip archive, it actually returns what I assume would be the path of the unpacked archive, whereas code:where_is_file(F) actually points to the location inside the archive. $ erl -pa run_proper.ez/proper/ebin Erlang R14B03 (erts-5.8.4) [source] [smp:4:4] [rq:4] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.8.4 (abort with ^G) 1> application:load(proper). ok 2> code:lib_dir(proper,include). "./run_proper/include" 3> code:where_is_file("proper.app"). "run_proper.ez/proper/ebin/proper.app" BR, Ulf W Ulf Wiger, CTO, Erlang Solutions, Ltd. http://erlang-solutions.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From raimo+erlang-questions@REDACTED Tue Apr 5 16:45:57 2011 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Tue, 5 Apr 2011 16:45:57 +0200 Subject: [erlang-questions] Re: how do I get the actual list of arguments passed to an escript? In-Reply-To: <20110404152734.GA12365@corelatus.se> References: <20110404133249.GA3964@corelatus.se> <20110404152734.GA12365@corelatus.se> Message-ID: <20110405144557.GC13405@erix.ericsson.se> On Mon, Apr 04, 2011 at 05:27:34PM +0200, Matthias Lang wrote: > Problem solved. > > TLDR: I outsmarted myself with a collection of symlinks and a broken > shell script. : > 3. The first 'erl' in my path is a shell script to an older Erlang: > > #! > /usr/local/src/otp_src_R14B01/bin/erl $@ > > That's probably a left-over from some debugging effort. > > 4. The $@ variable in BASH is subject to "word splitting", but that > can be disabled by writing "$@", which is equivalent to "$1" "$2" "$3" ... > > It feels like #3 and #4 ganged up to trick me... Without having thought > it through much, I can't see why $@ doesn't always behave like "$@" > (why would you want to word expand all arguments? By default?!). What you acually want is ${1+"@"} since "$@" when there are no arguments expands to "" i.e one empty argument. ${1+"$@"} expands "$@" iff there is at least one argument, empty or not. -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From ulf.wiger@REDACTED Tue Apr 5 17:13:05 2011 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Tue, 5 Apr 2011 17:13:05 +0200 Subject: [erlang-questions] Re: file operations on zipped files (Re: how to add a module to preLoaded?) In-Reply-To: <4D9B2CB5.2070102@tail-f.com> References: <4BEEE64D-1FA3-41B9-B97B-1AFB0304BD9E@erlang-solutions.com> <4D9B2CB5.2070102@tail-f.com> Message-ID: <48FE1048-533E-4EF2-ABEF-0F3ADC49A41A@erlang-solutions.com> On 5 Apr 2011, at 16:52, H?kan Mattsson wrote: > > > Eshell V5.8.4 (abort with ^G) > > 1> application:load(proper). > > ok > > 2> code:lib_dir(proper,include). > > "./run_proper/include" > > 3> code:where_is_file("proper.app"). > > "run_proper.ez/proper/ebin/proper.app" > > code:lib_dir(proper,include) should handle this. It will return > "run_proper.ez/proper/include" if the setup is correct. But it > requires that there is no "run_proper/include" directory AND > that the directory "run_proper.ez/proper/include" really exists. I'm happy to hear that it should, however... $ ls run_proper.ez $ erl -pa ./run_proper.ez/proper/ebin Erlang R14B03 (erts-5.8.4) [source] [smp:4:4] [rq:4] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.8.4 (abort with ^G) 1> code:lib_dir(proper,include). "./run_proper/include" 2> erl_prim_loader:get_file("run_proper.ez/proper/include/proper.hrl"). {ok,<<"%%% Copyright 2010 Manolis Papadakis (manopapad@REDACTED)\n%%% and Kostis Sagonas (kostis@REDACTED"...>>, "run_proper.ez/proper/include/proper.hrl"} 3> BREAK: (a)bort (c)ontinue (p)roc info (i)nfo (l)oaded (v)ersion (k)ill (D)b-tables (d)istribution a $ ls run_proper.ez At the very least, I am convinced that "./run_proper/include" does *not* exist in this case. BR, Ulf W Ulf Wiger, CTO, Erlang Solutions, Ltd. http://erlang-solutions.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf.wiger@REDACTED Tue Apr 5 17:18:42 2011 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Tue, 5 Apr 2011 17:18:42 +0200 Subject: [erlang-questions] Re: file operations on zipped files (Re: how to add a module to preLoaded?) In-Reply-To: <4D9B2CB5.2070102@tail-f.com> References: <4BEEE64D-1FA3-41B9-B97B-1AFB0304BD9E@erlang-solutions.com> <4D9B2CB5.2070102@tail-f.com> Message-ID: <6A67A5DF-A0B3-426D-A364-050C3FAA1CE5@erlang-solutions.com> On 5 Apr 2011, at 16:52, H?kan Mattsson wrote: > > So is your suggestion to call erl_prim_loader:get_file/1 > > instead of the prim_file:try_zip_read_file/2 that I wrote? > > Yes, either that or modify epp to read via erl_prim_loader My concern about the latter option is that any tool or application that is not aware of the special demands when dealing with zip archives are likely to break. This is why I wanted file.erl to have *reasonable* support for archives, where reasonable here would be (anything that would work on a read-only file system should work here too). BR, Ulf W Ulf Wiger, CTO, Erlang Solutions, Ltd. http://erlang-solutions.com From ulf.wiger@REDACTED Tue Apr 5 17:43:11 2011 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Tue, 5 Apr 2011 17:43:11 +0200 Subject: [erlang-questions] Re: file operations on zipped files (Re: how to add a module to preLoaded?) In-Reply-To: <4D9B3667.10908@tail-f.com> References: <4BEEE64D-1FA3-41B9-B97B-1AFB0304BD9E@erlang-solutions.com> <4D9B2CB5.2070102@tail-f.com> <48FE1048-533E-4EF2-ABEF-0F3ADC49A41A@erlang-solutions.com> <4D9B3667.10908@tail-f.com> Message-ID: On 5 Apr 2011, at 17:33, H?kan Mattsson wrote: > > At the very least, I am convinced that "./run_proper/include" does > > *not* exist in this case. > > It works for me. ;-) > > I suspect that the problem vanishes if you rename run_proper.ez to proper.ez. It sure did. So, that is a secret third condition? What if the archive contains more than one app? Or am I not allowed to have underscores in the name? :) BR, Ulf W Ulf Wiger, CTO, Erlang Solutions, Ltd. http://erlang-solutions.com From per.melin@REDACTED Tue Apr 5 17:44:28 2011 From: per.melin@REDACTED (Per Melin) Date: Tue, 5 Apr 2011 17:44:28 +0200 Subject: [erlang-questions] Re: how do I get the actual list of arguments passed to an escript? In-Reply-To: <20110405144557.GC13405@erix.ericsson.se> References: <20110404133249.GA3964@corelatus.se> <20110404152734.GA12365@corelatus.se> <20110405144557.GC13405@erix.ericsson.se> Message-ID: On Tue, Apr 5, 2011 at 4:45 PM, Raimo Niskanen wrote: > What you acually want is ${1+"@"} since "$@" when there are no arguments > expands to "" i.e one empty argument. ${1+"$@"} expands "$@" iff > there is at least one argument, empty or not. I've wondered about that. My manpage for bash says: 'When there are no positional parameters, "$@" and $@ expand to nothing (i.e., they are removed).' And I think it's been like that for quite some time. In which shell is ${1+"@"} required? From ulf.wiger@REDACTED Tue Apr 5 17:50:05 2011 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Tue, 5 Apr 2011 17:50:05 +0200 Subject: [erlang-questions] Re: file operations on zipped files (Re: how to add a module to preLoaded?) In-Reply-To: <4D9B2CB5.2070102@tail-f.com> References: <4BEEE64D-1FA3-41B9-B97B-1AFB0304BD9E@erlang-solutions.com> <4D9B2CB5.2070102@tail-f.com> Message-ID: <7AAF9A4A-AAF8-4120-907F-17A31206C4C8@erlang-solutions.com> On 5 Apr 2011, at 16:52, H?kan Mattsson wrote: > Yes, either that or modify epp to read via erl_prim_loader. Oh, the other - bigger - objection to that is that epp uses file:open/2 and then the file_io_server functionality* to fetch parsed forms from the file. The reason why I mentioned read_file in this case was just because I used that to fetch the file and put it into a ram_file, and then making prim_file "ram_file-aware". BR, Ulf W * Actually, the call is: scan_toks(From, St) -> case io:scan_erl_form(St#epp.file, '', St#epp.location) of ?. end. where io:scan_erl_form/2 becomes an io_request to the file_io_server. Ulf Wiger, CTO, Erlang Solutions, Ltd. http://erlang-solutions.com From ulf.wiger@REDACTED Tue Apr 5 17:57:59 2011 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Tue, 5 Apr 2011 17:57:59 +0200 Subject: [erlang-questions] Re: file operations on zipped files (Re: how to add a module to preLoaded?) In-Reply-To: <4D9B3B4C.2090108@tail-f.com> References: <4BEEE64D-1FA3-41B9-B97B-1AFB0304BD9E@erlang-solutions.com> <4D9B2CB5.2070102@tail-f.com> <7AAF9A4A-AAF8-4120-907F-17A31206C4C8@erlang-solutions.com> <4D9B3B4C.2090108@tail-f.com> Message-ID: <8702338B-8411-4E0D-BDC7-E39932A897C8@erlang-solutions.com> On 5 Apr 2011, at 17:54, H?kan Mattsson wrote: > This just raises the difficulty level a bit from what you > expected. But that have never stopped you before. ;-) > > /H?kan Sure, that's where the fun starts. :) However, I did solve that already. What I should do now is to use the relevant erl_prim_file functions rather than my special functions in prim_file. I should also change the epp hack to use code:lib_dir(App, include) and comply with the zip file naming restriction. BR, Ulf W Ulf Wiger, CTO, Erlang Solutions, Ltd. http://erlang-solutions.com From galea.melania@REDACTED Tue Apr 5 18:11:48 2011 From: galea.melania@REDACTED (Melania Galea) Date: Tue, 5 Apr 2011 19:11:48 +0300 Subject: [erlang-questions] Promoting Erlang Message-ID: I have posted the message on the eeps mailing list as well and i was advised to post it on the erlang questions, too. here it is (: I am a computer science student and i have recently discovered Erlang at QCon, in London. I have very much enjoyed the initial tutorial and the presentations i have attended to, therefore i decided to promote Erlang in my country, Romania. I believe Erlang is becoming powerful and it deserves to be well-known. There is a small website that i have created so far in order to spread the word about it. I hope others to be inspired and do the same. http://www.scs.ubbcluj.ro/~gmir0391/erlang.html Melania -------------- next part -------------- An HTML attachment was scrubbed... URL: From krab@REDACTED Tue Apr 5 18:29:35 2011 From: krab@REDACTED (Kresten Krab Thorup) Date: Tue, 5 Apr 2011 18:29:35 +0200 Subject: [erlang-questions] Re: file operations on zipped files (Re: how to add a module to preLoaded?) In-Reply-To: References: <4BEEE64D-1FA3-41B9-B97B-1AFB0304BD9E@erlang-solutions.com> Message-ID: <649FEA09-4C82-4C17-B3C8-434D076F1326@trifork.com> Can one easily wrap up all of the OTP beams in an ez, and boot from there? That would be perfect for erjang. (erjang doesn't need any of the native binaries, but do need access to various data files in priv folders). Kresten On 05/04/2011, at 16.09, "Ulf Wiger" > wrote: On 5 Apr 2011, at 15:43, H?kan Mattsson wrote: On Thu, Mar 31, 2011 at 8:04 PM, Ulf Wiger <ulf.wiger@REDACTED> wrote: The change in prim_file gives no overhead in the normal case, except for an extra pattern-match on the error value, and - if {error, enotdir}, a scan of the file name to see if there is a .ez file in the path. If so, the corresponding action is mapped on the archive. If the file is to be opened, as with epp, a "read_file()" is done, and the contents moved into a ram_file, which allows the same operations as prim_file. For this last case, I needed prim_ram_file in preloaded? Is erl_prim_loader:get_file(File) too slow for your needs? Surely not, but how does that help in this case? I assume you mean that I could have used that function rather than implementing my own read_file_from_archive()? I definitely would if I had known about it. Since it's even documented, I can only blame my own ignorance. (: So is your suggestion to call erl_prim_loader:get_file/1 instead of the prim_file:try_zip_read_file/2 that I wrote? (https://github.com/uwiger/otp/blob/uw-prim_file-reads-zip/erts/preloaded/src/prim_file.erl#L577) or did you have something else in mind? I suspect you are among the few who can claim any depth of knowledge in this area. A minor quirk is that code:lib_dir/1 has been defined to return a path *outside* the zip archive, presumably because you cannot load DLLs from an archive. Epp uses code:lib_dir/1 too, so even with the above changes, epp would fail to find the .hrl files. I solved this by having epp call code:where_is_file(Lib ++ ".app") and then finding the include from there. If that fails, it calls code:lib_dir/1 as before. Would it not be better if epp used code:lib_dir(App, include) instead? That function suffers from the same "problem" as code:lib_dir(App) - in the case of a zip archive, it actually returns what I assume would be the path of the unpacked archive, whereas code:where_is_file(F) actually points to the location inside the archive. $ erl -pa run_proper.ez/proper/ebin Erlang R14B03 (erts-5.8.4) [source] [smp:4:4] [rq:4] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.8.4 (abort with ^G) 1> application:load(proper). ok 2> code:lib_dir(proper,include). "./run_proper/include" 3> code:where_is_file("proper.app"). "run_proper.ez/proper/ebin/proper.app" BR, Ulf W Ulf Wiger, CTO, Erlang Solutions, Ltd. http://erlang-solutions.com _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://erlang.org/mailman/listinfo/erlang-questions From fritchie@REDACTED Tue Apr 5 19:30:20 2011 From: fritchie@REDACTED (Scott Lystig Fritchie) Date: Tue, 05 Apr 2011 12:30:20 -0500 Subject: [erlang-questions] Re: how do I get escript to emit all output before exiting? In-Reply-To: Message of "Mon, 04 Apr 2011 11:06:18 PDT." Message-ID: <89614.1302024620@snookles.snookles.com> Mike Oxford wrote: mo> What about having init:halt() send a sync'd message to the group mo> leader to shut down? mo> Once the group leader shuts down and returns then init:halt() will mo> exit. Hm. There may be multiple group leader processes in a VM, so then the problem becomes how to identify all of them (without false positives) and notice when they're all dead (assuming that you can indeed make them stop nicely) and deal somehow with the ones that refuse to die promptly (whatever promptly means). I haven't peeked into how difficult it'd be, but it's likely more than 2-lines-of-code difficult. :-) -Scott From hm@REDACTED Tue Apr 5 21:03:14 2011 From: hm@REDACTED (=?ISO-8859-1?Q?H=E5kan_Mattsson?=) Date: Tue, 5 Apr 2011 21:03:14 +0200 Subject: [erlang-questions] Re: file operations on zipped files (Re: how to add a module to preLoaded?) In-Reply-To: <649FEA09-4C82-4C17-B3C8-434D076F1326@trifork.com> References: <4BEEE64D-1FA3-41B9-B97B-1AFB0304BD9E@erlang-solutions.com> <649FEA09-4C82-4C17-B3C8-434D076F1326@trifork.com> Message-ID: On Tue, Apr 5, 2011 at 6:29 PM, Kresten Krab Thorup wrote: > Can one easily wrap up all of the OTP beams in an ez, and boot from there? > That would be perfect for erjang. (erjang doesn't need any of the native binaries, > but do need access to various data files in priv folders). You can use reltool to build a target system with an ez-file per application. It can handle that some sub directories reside, such as ebin, in the archive while others, such as priv, reside outside the archive as normal directories. If you want to have one single archive containing all OTP beams there is no public support for that. You need to create the ez-file yourself (perhaps with a little support of the zip module). But for the code loading part, there are some internal support that you can use as a starting point. The function code:set_primary_archive(FileName, Binary, FileInfo) will probably do most of the work for you. You need to invoke it in the early startup before any code is dynamically loaded. escript uses it to load beams from multi application archives. /H?kan From per@REDACTED Tue Apr 5 21:46:40 2011 From: per@REDACTED (Per Hedeland) Date: Tue, 5 Apr 2011 21:46:40 +0200 (CEST) Subject: [erlang-questions] Re: how do I get the actual list of arguments passed to an escript? In-Reply-To: Message-ID: <201104051946.p35Jkeg7083246@pluto.hedeland.org> Per Melin wrote: > >On Tue, Apr 5, 2011 at 4:45 PM, Raimo Niskanen > wrote: >> What you acually want is ${1+"@"} since "$@" when there are no arguments >> expands to "" i.e one empty argument. ${1+"$@"} expands "$@" iff >> there is at least one argument, empty or not. > >I've wondered about that. My manpage for bash says: 'When there are no >positional parameters, "$@" and $@ expand to nothing (i.e., they are >removed).' > >And I think it's been like that for quite some time. In which shell is >${1+"@"} required? One that is so old that it has this particular bug, which in all likelihood means that you'll have a very hard time finding it these days. I just now tried the Solaris (10) /bin/sh which doesn't seem to have gotten any updates in the last 25 years or so - and it does do the right thing with "$@". --Per Hedeland From moxford@REDACTED Tue Apr 5 23:35:13 2011 From: moxford@REDACTED (Mike Oxford) Date: Tue, 5 Apr 2011 14:35:13 -0700 Subject: [erlang-questions] Re: how do I get escript to emit all output before exiting? In-Reply-To: <201104052035.54445.als@iinet.net.au> References: <20110404162152.GA12787@corelatus.se> <12524.1301937879@snookles.snookles.com> <201104052035.54445.als@iinet.net.au> Message-ID: On Tue, Apr 5, 2011 at 3:35 AM, Anthony Shipman wrote: > > I find a 100ms delay solves the problem. > > "Works around" != "solves" And no, I don't have a better idea than 100ms. :) -Mike -------------- next part -------------- An HTML attachment was scrubbed... URL: From moxford@REDACTED Wed Apr 6 01:30:16 2011 From: moxford@REDACTED (Mike Oxford) Date: Tue, 5 Apr 2011 16:30:16 -0700 Subject: [erlang-questions] escript question Message-ID: This simple escript (teaching myself) works for some things, and not for others. https://gist.github.com/899768 Can anyone figure out why? I'm at a loss. Thanks in advance! -mox -------------- next part -------------- An HTML attachment was scrubbed... URL: From michael.santos@REDACTED Wed Apr 6 02:55:50 2011 From: michael.santos@REDACTED (Michael Santos) Date: Tue, 5 Apr 2011 20:55:50 -0400 Subject: [erlang-questions] Re: Changing heartbeat timeout while the system is running In-Reply-To: <20110405115932.GA23900@ecn.lan> References: <20110405115932.GA23900@ecn.lan> Message-ID: <20110406005550.GA25208@ecn.lan> On Tue, Apr 05, 2011 at 07:59:32AM -0400, Michael Santos wrote: > On Tue, Apr 05, 2011 at 03:17:41PM +0400, Alexey Romanov wrote: > > From http://www.erlang.org/doc/man/heart.html I expect that heart only > > checks the value of HEART_BEAT_TIMEOUT on startup and it can't be > > changed while the program runs. Is this correct (I hope not)? > > Yes, the value is only checked on startup. heart is a port, the timeout > environment variable is passed as a command switch. > > heart already supports changing the reboot command on the fly > (using heart:set_cmd/1), so adding support for HEART_BEAT_TIMEOUT and > HEART_BEAT_BOOT_DELAY (maybe heart:set_timeout/1, heart:set_delay/1) > looks simple. I can look into making a patch, if it'd be helpful. Attached is a patch adding heart:set_timeout/1 and heart:set_boot_delay/1 which seems to work ok. I'll add tests and update the docs later. diff --git a/erts/etc/common/Makefile.in b/erts/etc/common/Makefile.in index 4754328..f617dfb 100644 --- a/erts/etc/common/Makefile.in +++ b/erts/etc/common/Makefile.in @@ -449,7 +449,8 @@ endif ifeq ($(findstring vxworks,$(TARGET)), vxworks) $(BINDIR)/heart: $(OBJDIR)/heart.o $(OBJDIR)/heart_config.o - $(LD) $(LDFLAGS) -o $@ $(OBJDIR)/heart.o $(OBJDIR)/heart_config.o + $(LD) $(LDFLAGS) -o $@ $(OBJDIR)/heart.o $(OBJDIR)/heart_config.o \ + $(ERTS_INTERNAL_LIBS) $(OBJDIR)/heart_config.o: $(VXETC)/heart_config.c $(CC) $(CFLAGS) -o $@ -c $(VXETC)/heart_config.c @@ -467,7 +468,7 @@ else $(BINDIR)/heart@REDACTED@: $(OBJDIR)/heart.o $(ENTRY_OBJ) $(LD) $(LDFLAGS) $(ENTRY_LDFLAGS) -o $@ $(OBJDIR)/heart.o \ - $(ENTRY_OBJ) $(WINDSOCK) + $(ENTRY_OBJ) $(WINDSOCK) $(ERTS_INTERNAL_LIBS) $(OBJDIR)/heart.o: heart.c $(CC) $(CFLAGS) -o $@ -c heart.c diff --git a/erts/etc/common/heart.c b/erts/etc/common/heart.c index 778b356..88b9f0a 100644 --- a/erts/etc/common/heart.c +++ b/erts/etc/common/heart.c @@ -163,6 +163,12 @@ struct msg { #define CLEAR_CMD 5 #define GET_CMD 6 #define HEART_CMD 7 +#define SET_TIMEOUT 8 +#define GET_TIMEOUT 9 +#define HEART_TIMEOUT 10 +#define SET_BOOT_DELAY 11 +#define GET_BOOT_DELAY 12 +#define HEART_BOOT_DELAY 13 /* Maybe interesting to change */ @@ -207,6 +213,7 @@ static int message_loop(int,int); static void do_terminate(int); static int notify_ack(int); static int heart_cmd_reply(int, char *); +static int heart_val_reply(int, int, int); static int write_message(int, struct msg *); static int read_message(int, struct msg *); static int read_skip(int, char *, int, int); @@ -506,6 +513,38 @@ message_loop(erlin_fd, erlout_fd) free_env_val(env); } break; + case SET_TIMEOUT: + /* override the HEART_BEAT_TIMEOUT command */ + { + char buf[10]; + memcpy(&buf, &(mp->fill[0]), + tlen-MSG_HDR_PLUS_OP_SIZE); + buf[tlen-MSG_HDR_PLUS_OP_SIZE] = '\0'; + heart_beat_timeout = atoi(buf); + notify_ack(erlout_fd); + } + break; + case GET_TIMEOUT: + /* send back timeout value */ + heart_val_reply(erlout_fd, HEART_TIMEOUT, + heart_beat_timeout); + break; + case SET_BOOT_DELAY: + /* override the HEART_BEAT_DELAY command */ + { + char buf[10]; + memcpy(&buf, &(mp->fill[0]), + tlen-MSG_HDR_PLUS_OP_SIZE); + buf[tlen-MSG_HDR_PLUS_OP_SIZE] = '\0'; + heart_beat_boot_delay = atoi(buf); + notify_ack(erlout_fd); + } + break; + case GET_BOOT_DELAY: + /* send back delay value */ + heart_val_reply(erlout_fd, HEART_BOOT_DELAY, + heart_beat_boot_delay); + break; default: /* ignore all other messages */ break; @@ -744,6 +783,23 @@ heart_cmd_reply(int fd, char *s) /* + * sends back an ascii representation of an integer value + * + */ +static int +heart_val_reply(int fd, int op, int val) +{ + struct msg m; + + erts_snprintf(m.fill, sizeof(m.fill), "%d", val); + m.op = op; + m.len = htons(strlen(m.fill) + 1); /* Include Op */ + + return write_message(fd, &m); +} + + +/* * write_message * * Writes a message to a blocking file descriptor. Returns the total diff --git a/lib/kernel/src/heart.erl b/lib/kernel/src/heart.erl index e78acfc..3bf7325 100644 --- a/lib/kernel/src/heart.erl +++ b/lib/kernel/src/heart.erl @@ -29,7 +29,8 @@ %%% %%% It recognizes the flag '-heart' %%%-------------------------------------------------------------------- --export([start/0, init/2, set_cmd/1, clear_cmd/0, get_cmd/0, cycle/0]). +-export([start/0, init/2, set_cmd/1, clear_cmd/0, get_cmd/0, cycle/0, + set_timeout/1, get_timeout/0, set_boot_delay/1, get_boot_delay/0]). -define(START_ACK, 1). -define(HEART_BEAT, 2). @@ -38,6 +39,12 @@ -define(CLEAR_CMD, 5). -define(GET_CMD, 6). -define(HEART_CMD, 7). +-define(SET_TIMEOUT, 8). +-define(GET_TIMEOUT, 9). +-define(HEART_TIMEOUT, 10). +-define(SET_DELAY, 11). +-define(GET_DELAY, 12). +-define(HEART_BOOT_DELAY, 13). -define(TIMEOUT, 5000). -define(CYCLE_TIMEOUT, 10000). @@ -103,6 +110,29 @@ clear_cmd() -> heart ! {self(), clear_cmd}, wait(). +-spec set_timeout(string()) -> 'ok' | {'error', {'bad_timeout', non_neg_integer()}}. + +set_timeout(Timeout) -> + heart ! {self(), set_timeout, Timeout}, + wait(). + +-spec get_timeout() -> 'ok'. + +get_timeout() -> + heart ! {self(), get_timeout}, + wait(). + +-spec set_boot_delay(string()) -> 'ok' | {'error', {'bad_boot_delay', non_neg_integer()}}. + +set_boot_delay(Delay) -> + heart ! {self(), set_boot_delay, Delay}, + wait(). + +-spec get_boot_delay() -> 'ok'. + +get_boot_delay() -> + heart ! {self(), get_boot_delay}, + wait(). %%% Should be used solely by the release handler!!!!!!! -spec cycle() -> 'ok' | {'error', term()}. @@ -190,6 +220,28 @@ loop(Parent, Port, Cmd) -> {From, get_cmd} -> From ! {heart, get_heart_cmd(Port)}, loop(Parent, Port, Cmd); + {From, set_timeout, NewTimeout} when NewTimeout > 10, NewTimeout =< 65535 -> + send_heart_timeout(Port, NewTimeout), + wait_ack(Port), + From ! {heart, ok}, + loop(Parent, Port, Cmd); + {From, set_timeout, NewTimeout} -> + From ! {heart, {error, {bad_timeout, NewTimeout}}}, + loop(Parent, Port, Cmd); + {From, get_timeout} -> + From ! {heart, get_heart_timeout(Port)}, + loop(Parent, Port, Cmd); + {From, set_boot_delay, NewDelay} when NewDelay > 10, NewDelay =< 65535 -> + send_heart_boot_delay(Port, NewDelay), + wait_ack(Port), + From ! {heart, ok}, + loop(Parent, Port, Cmd); + {From, set_boot_delay, NewDelay} -> + From ! {heart, {error, {bad_boot_delay, NewDelay}}}, + loop(Parent, Port, Cmd); + {From, get_boot_delay} -> + From ! {heart, get_heart_boot_delay(Port)}, + loop(Parent, Port, Cmd); {From, cycle} -> %% Calls back to loop do_cycle_port_program(From, Parent, Port, Cmd); @@ -245,7 +297,7 @@ do_cycle_port_program(Caller, Parent, Port, Cmd) -> end. -%% "Beates" the heart once. +%% "Beats" the heart once. send_heart_beat(Port) -> Port ! {self(), {command, [?HEART_BEAT]}}. %% Set a new HEART_COMMAND. @@ -261,6 +313,28 @@ get_heart_cmd(Port) -> {ok, Cmd} end. +%% Set a new HEART_BEAT_TIMEOUT. +send_heart_timeout(Port, Timeout) -> + Port ! {self(), {command, [?SET_TIMEOUT|integer_to_list(Timeout)]}}. + +get_heart_timeout(Port) -> + Port ! {self(), {command, [?GET_TIMEOUT]}}, + receive + {Port, {data, [?HEART_TIMEOUT | Timeout]}} -> + {ok, list_to_integer(Timeout)} + end. + +%% Set a new HEART_BEAT_BOOT_DELAY. +send_heart_boot_delay(Port, Delay) -> + Port ! {self(), {command, [?SET_DELAY|integer_to_list(Delay)]}}. + +get_heart_boot_delay(Port) -> + Port ! {self(), {command, [?GET_DELAY]}}, + receive + {Port, {data, [?HEART_BOOT_DELAY | Delay]}} -> + {ok, list_to_integer(Delay)} + end. + %% Sends shutdown command to the port. send_shutdown(Port) -> Port ! {self(), {command, [?SHUT_DOWN]}}. From mapandfold@REDACTED Wed Apr 6 08:23:23 2011 From: mapandfold@REDACTED (moi) Date: Tue, 5 Apr 2011 23:23:23 -0700 (PDT) Subject: [erlang-questions] Re: UTF-8 problem ? In-Reply-To: <1302047905704-3429523.post@n4.nabble.com> References: <1302047905704-3429523.post@n4.nabble.com> Message-ID: <1302071003500-3429982.post@n4.nabble.com> The list from os:cmd is a byte list of UTF-8 string. You can use "~ts" to print it properly. 1> io:format("~ts~n", [unicode:characters_to_list(erlang:iolist_to_binary([50,48,49,49,229,185,180,32,52,230,156,136,32,54,230,151,165]))]). 2011? 4? 6? ok -- View this message in context: http://erlang.2086793.n4.nabble.com/UTF-8-problem-tp3429523p3429982.html Sent from the Erlang Questions mailing list archive at Nabble.com. From alexey.v.romanov@REDACTED Wed Apr 6 08:38:42 2011 From: alexey.v.romanov@REDACTED (Alexey Romanov) Date: Wed, 6 Apr 2011 10:38:42 +0400 Subject: [erlang-questions] Re: Changing heartbeat timeout while the system is running In-Reply-To: <20110406005550.GA25208@ecn.lan> References: <20110405115932.GA23900@ecn.lan> <20110406005550.GA25208@ecn.lan> Message-ID: Great, thanks! Yours, Alexey Romanov On Wed, Apr 6, 2011 at 4:55 AM, Michael Santos wrote: > On Tue, Apr 05, 2011 at 07:59:32AM -0400, Michael Santos wrote: >> On Tue, Apr 05, 2011 at 03:17:41PM +0400, Alexey Romanov wrote: >> > From http://www.erlang.org/doc/man/heart.html I expect that heart only >> > checks the value of HEART_BEAT_TIMEOUT on startup and it can't be >> > changed while the program runs. Is this correct (I hope not)? >> >> Yes, the value is only checked on startup. heart is a port, the timeout >> environment variable is passed as a command switch. >> >> heart already supports changing the reboot command on the fly >> (using heart:set_cmd/1), so adding support for HEART_BEAT_TIMEOUT and >> HEART_BEAT_BOOT_DELAY (maybe heart:set_timeout/1, heart:set_delay/1) >> looks simple. I can look into making a patch, if it'd be helpful. > > Attached is a patch adding heart:set_timeout/1 and heart:set_boot_delay/1 > which seems to work ok. I'll add tests and update the docs later. > > diff --git a/erts/etc/common/Makefile.in b/erts/etc/common/Makefile.in > index 4754328..f617dfb 100644 > --- a/erts/etc/common/Makefile.in > +++ b/erts/etc/common/Makefile.in > @@ -449,7 +449,8 @@ endif > > ?ifeq ($(findstring vxworks,$(TARGET)), vxworks) > ?$(BINDIR)/heart: $(OBJDIR)/heart.o $(OBJDIR)/heart_config.o > - ? ? ? $(LD) $(LDFLAGS) -o $@ $(OBJDIR)/heart.o $(OBJDIR)/heart_config.o > + ? ? ? $(LD) $(LDFLAGS) -o $@ $(OBJDIR)/heart.o $(OBJDIR)/heart_config.o \ > + ? ? ? ? ? ? ? $(ERTS_INTERNAL_LIBS) > > ?$(OBJDIR)/heart_config.o: $(VXETC)/heart_config.c > ? ? ? ?$(CC) $(CFLAGS) -o $@ -c $(VXETC)/heart_config.c > @@ -467,7 +468,7 @@ else > > ?$(BINDIR)/heart@REDACTED@: $(OBJDIR)/heart.o $(ENTRY_OBJ) > ? ? ? ?$(LD) $(LDFLAGS) $(ENTRY_LDFLAGS) -o $@ $(OBJDIR)/heart.o \ > - ? ? ? ? ? ? ? $(ENTRY_OBJ) $(WINDSOCK) > + ? ? ? ? ? ? ? $(ENTRY_OBJ) $(WINDSOCK) $(ERTS_INTERNAL_LIBS) > > ?$(OBJDIR)/heart.o: heart.c > ? ? ? ?$(CC) $(CFLAGS) -o $@ -c heart.c > diff --git a/erts/etc/common/heart.c b/erts/etc/common/heart.c > index 778b356..88b9f0a 100644 > --- a/erts/etc/common/heart.c > +++ b/erts/etc/common/heart.c > @@ -163,6 +163,12 @@ struct msg { > ?#define ?CLEAR_CMD ? ?5 > ?#define ?GET_CMD ? ? ?6 > ?#define ?HEART_CMD ? ?7 > +#define ?SET_TIMEOUT ?8 > +#define ?GET_TIMEOUT ?9 > +#define ?HEART_TIMEOUT 10 > +#define ?SET_BOOT_DELAY ? ?11 > +#define ?GET_BOOT_DELAY ? ?12 > +#define ?HEART_BOOT_DELAY ?13 > > > ?/* ?Maybe interesting to change */ > @@ -207,6 +213,7 @@ static int message_loop(int,int); > ?static void do_terminate(int); > ?static int notify_ack(int); > ?static int heart_cmd_reply(int, char *); > +static int heart_val_reply(int, int, int); > ?static int write_message(int, struct msg *); > ?static int read_message(int, struct msg *); > ?static int read_skip(int, char *, int, int); > @@ -506,6 +513,38 @@ message_loop(erlin_fd, erlout_fd) > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?free_env_val(env); > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?} > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?break; > + ? ? ? ? ? ? ? ? ? ? ? case SET_TIMEOUT: > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? /* override the HEART_BEAT_TIMEOUT command */ > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? { > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? char buf[10]; > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? memcpy(&buf, &(mp->fill[0]), > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?tlen-MSG_HDR_PLUS_OP_SIZE); > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? buf[tlen-MSG_HDR_PLUS_OP_SIZE] = '\0'; > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? heart_beat_timeout = atoi(buf); > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? notify_ack(erlout_fd); > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? } > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? break; > + ? ? ? ? ? ? ? ? ? ? ? case GET_TIMEOUT: > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? /* send back timeout value */ > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? heart_val_reply(erlout_fd, HEART_TIMEOUT, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?heart_beat_timeout); > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? break; > + ? ? ? ? ? ? ? ? ? ? ? case SET_BOOT_DELAY: > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? /* override the HEART_BEAT_DELAY command */ > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? { > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? char buf[10]; > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? memcpy(&buf, &(mp->fill[0]), > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?tlen-MSG_HDR_PLUS_OP_SIZE); > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? buf[tlen-MSG_HDR_PLUS_OP_SIZE] = '\0'; > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? heart_beat_boot_delay = atoi(buf); > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? notify_ack(erlout_fd); > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? } > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? break; > + ? ? ? ? ? ? ? ? ? ? ? case GET_BOOT_DELAY: > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? /* send back delay value */ > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? heart_val_reply(erlout_fd, HEART_BOOT_DELAY, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?heart_beat_boot_delay); > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? break; > ? ? ? ? ? ? ? ? ? ? ? ?default: > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?/* ignore all other messages */ > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?break; > @@ -744,6 +783,23 @@ heart_cmd_reply(int fd, char *s) > > > ?/* > + * sends back an ascii representation of an integer value > + * > + */ > +static int > +heart_val_reply(int fd, int op, int val) > +{ > + ?struct msg m; > + > + ?erts_snprintf(m.fill, sizeof(m.fill), "%d", val); > + ?m.op = op; > + ?m.len = htons(strlen(m.fill) + 1); ? /* Include Op */ > + > + ?return write_message(fd, &m); > +} > + > + > +/* > ?* ?write_message > ?* > ?* ?Writes a message to a blocking file descriptor. Returns the total > diff --git a/lib/kernel/src/heart.erl b/lib/kernel/src/heart.erl > index e78acfc..3bf7325 100644 > --- a/lib/kernel/src/heart.erl > +++ b/lib/kernel/src/heart.erl > @@ -29,7 +29,8 @@ > ?%%% > ?%%% It recognizes the flag '-heart' > ?%%%-------------------------------------------------------------------- > --export([start/0, init/2, set_cmd/1, clear_cmd/0, get_cmd/0, cycle/0]). > +-export([start/0, init/2, set_cmd/1, clear_cmd/0, get_cmd/0, cycle/0, > + ? ? ? ?set_timeout/1, get_timeout/0, set_boot_delay/1, get_boot_delay/0]). > > ?-define(START_ACK, 1). > ?-define(HEART_BEAT, 2). > @@ -38,6 +39,12 @@ > ?-define(CLEAR_CMD, 5). > ?-define(GET_CMD, 6). > ?-define(HEART_CMD, 7). > +-define(SET_TIMEOUT, 8). > +-define(GET_TIMEOUT, 9). > +-define(HEART_TIMEOUT, 10). > +-define(SET_DELAY, 11). > +-define(GET_DELAY, 12). > +-define(HEART_BOOT_DELAY, 13). > > ?-define(TIMEOUT, 5000). > ?-define(CYCLE_TIMEOUT, 10000). > @@ -103,6 +110,29 @@ clear_cmd() -> > ? ? heart ! {self(), clear_cmd}, > ? ? wait(). > > +-spec set_timeout(string()) -> 'ok' | {'error', {'bad_timeout', non_neg_integer()}}. > + > +set_timeout(Timeout) -> > + ? ?heart ! {self(), set_timeout, Timeout}, > + ? ?wait(). > + > +-spec get_timeout() -> 'ok'. > + > +get_timeout() -> > + ? ?heart ! {self(), get_timeout}, > + ? ?wait(). > + > +-spec set_boot_delay(string()) -> 'ok' | {'error', {'bad_boot_delay', non_neg_integer()}}. > + > +set_boot_delay(Delay) -> > + ? ?heart ! {self(), set_boot_delay, Delay}, > + ? ?wait(). > + > +-spec get_boot_delay() -> 'ok'. > + > +get_boot_delay() -> > + ? ?heart ! {self(), get_boot_delay}, > + ? ?wait(). > > ?%%% Should be used solely by the release handler!!!!!!! > ?-spec cycle() -> 'ok' | {'error', term()}. > @@ -190,6 +220,28 @@ loop(Parent, Port, Cmd) -> > ? ? ? ?{From, get_cmd} -> > ? ? ? ? ? ?From ! {heart, get_heart_cmd(Port)}, > ? ? ? ? ? ?loop(Parent, Port, Cmd); > + ? ? ? {From, set_timeout, NewTimeout} when NewTimeout > 10, NewTimeout =< 65535 -> > + ? ? ? ? ? send_heart_timeout(Port, NewTimeout), > + ? ? ? ? ? wait_ack(Port), > + ? ? ? ? ? From ! {heart, ok}, > + ? ? ? ? ? loop(Parent, Port, Cmd); > + ? ? ? {From, set_timeout, NewTimeout} -> > + ? ? ? ? ? From ! {heart, {error, {bad_timeout, NewTimeout}}}, > + ? ? ? ? ? loop(Parent, Port, Cmd); > + ? ? ? {From, get_timeout} -> > + ? ? ? ? ? From ! {heart, get_heart_timeout(Port)}, > + ? ? ? ? ? loop(Parent, Port, Cmd); > + ? ? ? {From, set_boot_delay, NewDelay} when NewDelay > 10, NewDelay =< 65535 -> > + ? ? ? ? ? send_heart_boot_delay(Port, NewDelay), > + ? ? ? ? ? wait_ack(Port), > + ? ? ? ? ? From ! {heart, ok}, > + ? ? ? ? ? loop(Parent, Port, Cmd); > + ? ? ? {From, set_boot_delay, NewDelay} -> > + ? ? ? ? ? From ! {heart, {error, {bad_boot_delay, NewDelay}}}, > + ? ? ? ? ? loop(Parent, Port, Cmd); > + ? ? ? {From, get_boot_delay} -> > + ? ? ? ? ? From ! {heart, get_heart_boot_delay(Port)}, > + ? ? ? ? ? loop(Parent, Port, Cmd); > ? ? ? ?{From, cycle} -> > ? ? ? ? ? ?%% Calls back to loop > ? ? ? ? ? ?do_cycle_port_program(From, Parent, Port, Cmd); > @@ -245,7 +297,7 @@ do_cycle_port_program(Caller, Parent, Port, Cmd) -> > ? ? end. > > > -%% "Beates" the heart once. > +%% "Beats" the heart once. > ?send_heart_beat(Port) -> Port ! {self(), {command, [?HEART_BEAT]}}. > > ?%% Set a new HEART_COMMAND. > @@ -261,6 +313,28 @@ get_heart_cmd(Port) -> > ? ? ? ? ? ?{ok, Cmd} > ? ? end. > > +%% Set a new HEART_BEAT_TIMEOUT. > +send_heart_timeout(Port, Timeout) -> > + ? ?Port ! {self(), {command, [?SET_TIMEOUT|integer_to_list(Timeout)]}}. > + > +get_heart_timeout(Port) -> > + ? ?Port ! {self(), {command, [?GET_TIMEOUT]}}, > + ? ?receive > + ? ? ? {Port, {data, [?HEART_TIMEOUT | Timeout]}} -> > + ? ? ? ? ? {ok, list_to_integer(Timeout)} > + ? ?end. > + > +%% Set a new HEART_BEAT_BOOT_DELAY. > +send_heart_boot_delay(Port, Delay) -> > + ? ?Port ! {self(), {command, [?SET_DELAY|integer_to_list(Delay)]}}. > + > +get_heart_boot_delay(Port) -> > + ? ?Port ! {self(), {command, [?GET_DELAY]}}, > + ? ?receive > + ? ? ? {Port, {data, [?HEART_BOOT_DELAY | Delay]}} -> > + ? ? ? ? ? {ok, list_to_integer(Delay)} > + ? ?end. > + > ?%% Sends shutdown command to the port. > ?send_shutdown(Port) -> Port ! {self(), {command, [?SHUT_DOWN]}}. > > From bengt.kleberg@REDACTED Wed Apr 6 08:46:25 2011 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Wed, 6 Apr 2011 08:46:25 +0200 Subject: [erlang-questions] Re: escript question In-Reply-To: References: Message-ID: <1302072385.5133.22.camel@seasc1137> Greetings, I have not solved your problem. For instance, I do not understand what works and what does not work. However, I did notice that your code looks different from what I would write. So if you are interested, this is how I would do main/1: main(ParamList) -> case ParamList of [AppID, NodeID] -> generate_files(AppID, NodeID) ; _Else -> show_usage(), erlang:halt(1) end. bengt On Wed, 2011-04-06 at 01:30 +0200, Mike Oxford wrote: > This simple escript (teaching myself) works for some things, and not > for others. > > > https://gist.github.com/899768 > > > Can anyone figure out why? I'm at a loss. > > > Thanks in advance! > > > -mox > > > > From hm@REDACTED Wed Apr 6 11:22:07 2011 From: hm@REDACTED (=?ISO-8859-1?Q?H=E5kan_Mattsson?=) Date: Wed, 6 Apr 2011 11:22:07 +0200 Subject: [erlang-questions] Re: escript question In-Reply-To: <1302072385.5133.22.camel@seasc1137> References: <1302072385.5133.22.camel@seasc1137> Message-ID: On Wed, Apr 6, 2011 at 8:46 AM, Bengt Kleberg wrote: > However, I did notice that your code looks different from what I would write. Doesn't your code look different from almost everybody elses? ;-) I like Mikes indentation style better. /H?kan > main(ParamList) -> > case ParamList > of [AppID, NodeID] -> > generate_files(AppID, NodeID) > ; _Else -> > show_usage(), > erlang:halt(1) > end. From bengt.kleberg@REDACTED Wed Apr 6 12:41:26 2011 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Wed, 6 Apr 2011 12:41:26 +0200 Subject: [erlang-questions] Re: escript question In-Reply-To: References: <1302072385.5133.22.camel@seasc1137> Message-ID: <1302086486.5133.34.camel@seasc1137> I was thinking about the use of 'if' and erlang:length/1. If possible, try to ignore the indention. bengt On Wed, 2011-04-06 at 11:22 +0200, H?kan Mattsson wrote: > On Wed, Apr 6, 2011 at 8:46 AM, Bengt Kleberg > wrote: > > However, I did notice that your code looks different from what I would write. > > Doesn't your code look different from almost everybody elses? ;-) > I like Mikes indentation style better. > > /H?kan > > > main(ParamList) -> > > case ParamList > > of [AppID, NodeID] -> > > generate_files(AppID, NodeID) > > ; _Else -> > > show_usage(), > > erlang:halt(1) > > end. From koops.j@REDACTED Wed Apr 6 14:00:57 2011 From: koops.j@REDACTED (Jeroen Koops) Date: Wed, 6 Apr 2011 14:00:57 +0200 Subject: [erlang-questions] Re: Distributed application takeover In-Reply-To: <61A1080E-B2E8-4CE1-9A47-2401761169BA@erlang-solutions.com> References: <0DBAD7AB-FE6B-4A54-A07B-C8ABAB6E8ACF@erlang-solutions.com> <61A1080E-B2E8-4CE1-9A47-2401761169BA@erlang-solutions.com> Message-ID: Hi Ulf, I just encountered some unexpected behaviour in application failover. When a distributed application stops because its top-level supervisor exits with a reached_max_restart_intensity error, it will not be restarted on the other node. This, I guess, is consistent with the documentation, which says that the application will be restarted only if the node currently running the application goes down, not if the application stops with an error. However, if the application is installed as a permanent application, the whole Erlang node will be terminated as soon as the application stops. But even in this case, the application will not be restarted on the other node. In fact, calling application:info() on the other node claims that the application is still running as { distributed, OriginalNode }, even though OriginalNode no longer exists. Is this the intended behaviour? I had hoped that, by installing an application as permanent, I could make it failover to a standby node in case of an unrecoverable software-error *), but apparently that doesn't work. *) Of course, failing over in case of a pure software error does not make a lot of sense since the application would crash on the other node as well. But quite a few errors are causes by unexpected changes in the environment that are handled badly by the software, and those are the ones I'm looking at. On Thu, Mar 31, 2011 at 9:15 PM, Ulf Wiger wrote: > > Hi Jeroen, > > What we used to do was to use start phases and global:re_register_name/2 > > Application start phases can be used to do e.g. global name registration in > an ordered fashion. > > We had, for historical reasons, the following start phases at AXD 301: > > - start: processes started, basic initialisation > - takeover: ignored unless application start type was {takeover, FromNode} > - go: to register global names, do other forms of complex initialisation, > etc. > > In the takeover phase, the takeover callback would typically do gen_server > calls to the application processes. These could in their turn do a > gen_server call to their counterpart on the other side, fetching state, > telling the other side to start forwarding requests, etc. A good order of > doing things would be to first re_register the global name, then call the > other process to fetch state. > > See: > http://www.erlang.org/doc/man/app.html > http://www.erlang.org/doc/apps/kernel/application.html#Module:start_phase-3 > http://www.erlang.org/doc/man/global.html#re_register_name-2 > > BR, > Ulf W > > On 31 Mar 2011, at 14:36, Jeroen Koops wrote: > > Hi Ulf, > > Thanks for the explanation, the message-flow is now pretty clear. > > Actually, the reason I was looking into it was to see if I could come up > with a patch that makes it possible to configure an alternative takeover > behaviour, since I find it inconvenient that during a takeover the > application is running on two nodes at the same time for a while, which > leads to clashes with globally registered names, and problems with processes > that assume they have exclusive access to data. It would be nice to be able > to configure takeover behaviour in such a way that the application is only > started on the node that is taking over *after *it has been stopped on the > original node. > > However, I've come to the conclusion that the whole application > distribution is way too complex to start poking around, so instead I now use > a mechanism where, whenever an application is started with { takeover, > OtherNode } as StartType, it simply terminates all the children of the > application's top-level supervisor on OtherNode before proceeding with the > startup. This is a bit clunky, and a feel a bit sorry for the application on > OtherNode being left behind as an empty shell, with all its children killed, > waiting for the application controller to put it out of its misery, but it > gets the job done... > > > On Wed, Mar 30, 2011 at 4:00 PM, Ulf Wiger > wrote: > >> >> Hi Jeroen, >> >> This is a bit tricky, and can be very confusing for someone trying to >> build their own cluster controller. :) >> >> The stopping of the application is done by the local >> application_controller when it is told that the application is running >> somewhere else. In other words, dist_ac kindly forwards the information to >> the local AC, and it is the local AC that in this particular case takes >> responsibility for 'knowing' that the local instance should be stopped. >> >> See application_controller:handle_application_started/3 >> >> >> https://github.com/erlang/otp/blob/OTP_R14B02/lib/kernel/src/application_controller.erl#L913 >> >> (The dirty deed actually happens on line 946). >> >> The reason I know this, is that in the AXD 301, we ran multiple instances >> of some applications, distributed across several mated pairs - each instance >> having its own standby node. This can be done by writing an own distributed >> AC, but it has to be smart enough to know _when_ to forward the {started, >> Node} status to the local AC; if an instance was running locally - and _was >> supposed to_ do so (i.e. not involved in a takeover), the distributed AC had >> to suppress this message. >> >> BR, >> Ulf W >> >> On 30 Mar 2011, at 14:11, Jeroen Koops wrote: >> >> Hi, >> >> I'm trying to find out how the distributed application controller works >> internally. I'm especially interested in the implementation of an >> application takeover. >> >> In case an application runs on node A, and is taken over by node B, what >> should happen is that it is first started on node B, so that there are two >> instances of the application running simultaneously for a brief period of >> time, and then stopped on node A. >> >> However, I cannot figure out where this stopping happens in dist_ac.erl. >> If I understand correctly, this should happen in response to a >> ac_application_run message from the application_controller. This message >> is received by the dist_ac on node B, and a dist_ac_app_started message >> is then broadcast to the dist_acs on all connected nodes. The dist_ac of >> node A receives this message, notices that the application is still running >> locally, and decides to shut down the application on its own node -- at >> least that is what the comments say (dist_ac.erl, line 529): >> >> %% Another node tookover from me; stop my application >> %% and update the running list. >> >> But all I can see is that the dist_ac's list of applications is updated >> to indicate that the application is no longer running locally -- I cannot >> find where the application_controller is instructed to actually shutdown the >> application. >> >> Can anyone point me in the right direction? >> >> Thanks, >> >> Jeroen _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> >> Ulf Wiger, CTO, Erlang Solutions, Ltd. >> http://erlang-solutions.com >> >> >> >> > > Ulf Wiger, CTO, Erlang Solutions, Ltd. > http://erlang-solutions.com > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From Stephane.Pamelard@REDACTED Wed Apr 6 14:16:47 2011 From: Stephane.Pamelard@REDACTED (Stephane Pamelard) Date: Wed, 6 Apr 2011 14:16:47 +0200 Subject: [erlang-questions] JOB opportunity Message-ID: <4D9C59AF.6060900@myriadgroup.com> My company, Myriad Group, is seeking for an experienced Software Developer (~7-10 years). You will work in a Scrum team of 8 members Required skills are: - Linux - Erlang/OTP - Ruby, C, Shell - MySQL5, NoSQL databases knowledge is a plus - Agile methodology principles: continuous integration, TDD, Pair programming... - SS7 protocols and other telecom protocols like SMPP, HTTP would be greatly appreciated Company: Myriad Group is Europe?s largest mobile software company, serving all of the major phone manufacturers and more than 35 of the world?s leading mobile network operators This position would be for Mobile Services Division, which is based in La Defense, France. This division is one of two business units within Myriad which is the world?s leading provider of on-device self-care services. More than 35 network operators (including Orange, Telefonica and T-Mobile) now use this Myriad solution to enable mobile users to check their account balance, recharge their prepaid subscription, purchase ringtones and WiFi access codes, and access other interactive services. More information available in http://www.myriadgroup.com/ Contract type: permanent Location: Paris, La D?fense If you are interested in distributed storage systems and data structures, please send your CV directly to me, to Sebastien.Becuwe@REDACTED or to hr@REDACTED Pamelard St?phane This message, including attachments, is intended solely for the addressee indicated in this message and is strictly confidential or otherwise privileged. If you are not the intended recipient (or responsible for delivery of the message to such person) : - (1) please immediately (i) notify the sender by reply email and (ii) delete this message and attachments, - (2) any use, copy or dissemination of this transmission is strictly prohibited. If you or your employer does not consent to Internet email messages of this kind, please advise Myriad Group AG by reply e-mail immediately. Opinions, conclusions and other information expressed in this message are not given or endorsed by Myriad Group AG unless otherwise indicated by an authorized representative independent of this message. From coa@REDACTED Wed Apr 6 14:25:57 2011 From: coa@REDACTED (=?ISO-8859-1?Q?Cl=E1udio_Amaral?=) Date: Wed, 06 Apr 2011 14:25:57 +0200 Subject: [erlang-questions] good dialyzer docs? Message-ID: <4D9C5BD5.2000701@dcc.fc.up.pt> Good afternoon! I am looking for a good dialyzer manual (other than the one in the Erlang man pages) It is hard to get a good understanding of what the tool actually is doing without looking at the code or something and sometimes a weird error message appears. On this subject, I got something like "function f is used but no type information about it is given" although I had it defined and the 'problem' was that (product of refactoring) I was calling the local function with the module name, which is perfectly legal but dialyzer seems to deslike it. Any particular reason? Sorry about the mix of questions, but they looked related enough. Cl?udio. From xapwing@REDACTED Wed Apr 6 14:40:29 2011 From: xapwing@REDACTED (Arie van Wingerden) Date: Wed, 6 Apr 2011 14:40:29 +0200 Subject: [erlang-questions] Question about register/2 Message-ID: Hi, when I issue register(id, spawn aFun) and id already is associated with some process, the function fails. What disturbs me is that the check of id already being taken for another pid, might take place *after* the spawn has been executed. Hence a "ghost" process is running. Is this the way it works? And how is this mostly solved? Regards, Arie -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf.wiger@REDACTED Wed Apr 6 14:44:39 2011 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Wed, 6 Apr 2011 14:44:39 +0200 Subject: [erlang-questions] Re: Question about register/2 In-Reply-To: References: Message-ID: <0FDC99A7-4BF7-4F1D-9624-E5C473284FD4@erlang-solutions.com> Any time you call a function, the input arguments are evaluated before the function is executed, so the spawn should *always* execute in this case. This is characteristic of a language with eager (as opposed to lazy) evaluation. BR, Ulf W On 6 Apr 2011, at 14:40, Arie van Wingerden wrote: > Hi, > > when I issue register(id, spawn aFun) and id already is associated with some process, the function fails. > > What disturbs me is that the check of id already being taken for another pid, might take place *after* the spawn has been executed. > Hence a "ghost" process is running. > > Is this the way it works? And how is this mostly solved? > > Regards, > Arie > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions Ulf Wiger, CTO, Erlang Solutions, Ltd. http://erlang-solutions.com From jodie.burch@REDACTED Wed Apr 6 14:50:57 2011 From: jodie.burch@REDACTED (Jodie Burch) Date: Wed, 06 Apr 2011 13:50:57 +0100 Subject: [erlang-questions] Erlang Factory London - Talk Submission Message-ID: Hi Everyone There is still time to submit your talk proposal for Erlang Factory London, June 6th-10th. The deadline for submissions in Monday 11th April. We are already over subscribed so the earlier you submit your talk the better! You can submit your proposal, find out more information about the conference and see who is already confirmed to speak here: http://erlang-factory.com/conference/London2011 I look forward to hearing from you. Thanks Jodie -------------- next part -------------- An HTML attachment was scrubbed... URL: From vladdu55@REDACTED Wed Apr 6 14:53:59 2011 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Wed, 6 Apr 2011 14:53:59 +0200 Subject: [erlang-questions] Re: Question about register/2 In-Reply-To: References: Message-ID: Hi, On Wed, Apr 6, 2011 at 14:40, Arie van Wingerden wrote: > when I issue register(id, spawn aFun) and id already is associated with > some process, the function fails. > > What disturbs me is that the check of id already being taken for another > pid, might take place *after* the spawn has been executed. > Hence a "ghost" process is running. > > Is this the way it works? And how is this mostly solved? > The solution is to let the spawned process register itself right after starting. If that fails, just let it die and theres is no ghost-process anymore. regards, Vlad -------------- next part -------------- An HTML attachment was scrubbed... URL: From kostis@REDACTED Wed Apr 6 15:13:10 2011 From: kostis@REDACTED (Kostis Sagonas) Date: Wed, 06 Apr 2011 16:13:10 +0300 Subject: [erlang-questions] Re: good dialyzer docs? In-Reply-To: <4D9C5BD5.2000701@dcc.fc.up.pt> References: <4D9C5BD5.2000701@dcc.fc.up.pt> Message-ID: <4D9C66E6.3000403@cs.ntua.gr> Cl?udio Amaral wrote: > Good afternoon! > > I am looking for a good dialyzer manual (other than the one in the > Erlang man pages) > > It is hard to get a good understanding of what the tool actually is > doing without looking at the code or something and sometimes a weird > error message appears. In dialyzer's homepage there are various papers that describe what the tool is actually doing without having to look at its actual code. http://www.it.uu.se/research/group/hipe/dialyzer Of course, in order to understand what the warning messages that dialyzer produces you really *have* to look at your code also... > On this subject, I got something like "function f is used but no type > information about it is given" although I had it defined and the > 'problem' was that (product of refactoring) I was calling the local > function with the module name, which is perfectly legal but dialyzer > seems to deslike it. Any particular reason? You are sufficiently vague in your mail that it's very difficult to give an answer to you in what you are asking. In particular, there is no warning that reads "no type information is given for a function"; all type information is actually optional. If you want help understanding some dialyzer warning please provide the exact warning and the code that exhibits it. Kostis From jesper.louis.andersen@REDACTED Wed Apr 6 15:26:53 2011 From: jesper.louis.andersen@REDACTED (Jesper Louis Andersen) Date: Wed, 6 Apr 2011 15:26:53 +0200 Subject: [erlang-questions] Re: good dialyzer docs? In-Reply-To: <4D9C66E6.3000403@cs.ntua.gr> References: <4D9C5BD5.2000701@dcc.fc.up.pt> <4D9C66E6.3000403@cs.ntua.gr> Message-ID: 2011/4/6 Kostis Sagonas : > > You are sufficiently vague in your mail that it's very difficult to give an > answer to you in what you are asking. In particular, there is no warning > that reads "no type information is given for a function"; all type > information is actually optional. > This is correct, but you can still supply an option, warn_missing_spec, to the compiler which will make it print out warnings for functions with missing specs. I have been contemplating enabling it on my projects. Of course, not supplying a -spec means the dialyzer will just infer the type to the best of its ability. -- J. From kostis@REDACTED Wed Apr 6 15:39:39 2011 From: kostis@REDACTED (Kostis Sagonas) Date: Wed, 06 Apr 2011 16:39:39 +0300 Subject: [erlang-questions] Re: good dialyzer docs? In-Reply-To: References: <4D9C5BD5.2000701@dcc.fc.up.pt> <4D9C66E6.3000403@cs.ntua.gr> Message-ID: <4D9C6D1B.6060806@cs.ntua.gr> Jesper Louis Andersen wrote: > 2011/4/6 Kostis Sagonas : >> You are sufficiently vague in your mail that it's very difficult to give an >> answer to you in what you are asking. In particular, there is no warning >> that reads "no type information is given for a function"; all type >> information is actually optional. >> > > This is correct, but you can still supply an option, > warn_missing_spec, to the compiler which will make it print out > warnings for functions with missing specs. I have been contemplating > enabling it on my projects. You are right and this option is good to enable and highly recommended (by the way, it warns for missing specs for exported functions only) but just to make things clear, this is *not* a dialyzer option. It's a compiler option. Kostis From demeshchuk@REDACTED Wed Apr 6 15:44:05 2011 From: demeshchuk@REDACTED (Dmitry Demeshchuk) Date: Wed, 6 Apr 2011 17:44:05 +0400 Subject: [erlang-questions] Erlang manuals problem when installing from Homebrew Message-ID: Greetings. I've installed the R14B02 to a fresh machine with no previous versions using Homebrew. Everything works good, but "erl -man" seems to be broken. Hombrew is default-configured, so the structure of /usr/local/Cellar/erlang/R14B02 is the following: AUTHORS README.md bin/ lib/ share/ So, the binary files are placed into /usr/local/Cellar/erlang/R14B02/bin and the man pages ? into /usr/local/Cellar/erlang/R14B02/share/man As far as I understand, when I call "erl -man", it tries to search at some other location, not at the one I provided. I tried to add this location to MANPATH, but result was the same. Where does Erlang search for the manuals and is there a way to configure these locations? -- Best regards, Dmitry Demeshchuk From coa@REDACTED Wed Apr 6 15:46:36 2011 From: coa@REDACTED (=?ISO-8859-1?Q?Cl=E1udio_Amaral?=) Date: Wed, 06 Apr 2011 15:46:36 +0200 Subject: [erlang-questions] Re: good dialyzer docs? In-Reply-To: <4D9C66E6.3000403@cs.ntua.gr> References: <4D9C5BD5.2000701@dcc.fc.up.pt> <4D9C66E6.3000403@cs.ntua.gr> Message-ID: <4D9C6EBC.5090407@dcc.fc.up.pt> On 04/06/2011 03:13 PM, Kostis Sagonas wrote: > Of course, in order to understand what the warning messages that > dialyzer produces you really *have* to look at your code also... This is a given... >> On this subject, I got something like "function f is used but no type >> information about it is given" although I had it defined and the >> 'problem' was that (product of refactoring) I was calling the local >> function with the module name, which is perfectly legal but dialyzer >> seems to deslike it. Any particular reason? > > You are sufficiently vague in your mail that it's very difficult to > give an answer to you in what you are asking. In particular, there is > no warning that reads "no type information is given for a function"; > all type information is actually optional. > > If you want help understanding some dialyzer warning please provide > the exact warning and the code that exhibits it. > > Kostis I was going to do just that, but apparently I could not reproduce the error. I must have had a typo somewhere. Thanks! Cl?udio. From demeshchuk@REDACTED Wed Apr 6 16:33:15 2011 From: demeshchuk@REDACTED (Dmitry Demeshchuk) Date: Wed, 6 Apr 2011 18:33:15 +0400 Subject: [erlang-questions] Re: Erlang manuals problem when installing from Homebrew In-Reply-To: References: Message-ID: Apparently, /usr/local/Cellar/erlang/R14B02/bin/erl was a symlink to /usr/local/Cellar/erlang/R14B02/lib/erlang/bin/erl I added a symlink /usr/local/Cellar/erlang/R14B02/lib/erlang/man leading to the man pages dir and it started working. The question is: is there the more right way to point Erlang to the right manuals directory? On Wed, Apr 6, 2011 at 5:44 PM, Dmitry Demeshchuk wrote: > Greetings. > > I've installed the R14B02 to a fresh machine with no previous versions > using Homebrew. Everything works good, but "erl -man" seems to be > broken. > > Hombrew is default-configured, so the structure of > /usr/local/Cellar/erlang/R14B02 is the following: > > AUTHORS ? ?README.md ?bin/ ? ? ? lib/ ? ? ? share/ > > So, the binary files are placed into > /usr/local/Cellar/erlang/R14B02/bin and the man pages ? into > /usr/local/Cellar/erlang/R14B02/share/man > > As far as I understand, when I call "erl -man", it tries to search at > some other location, not at the one I provided. I tried to add this > location to MANPATH, but result was the same. > > Where does Erlang search for the manuals and is there a way to > configure these locations? > > -- > Best regards, > Dmitry Demeshchuk > -- Best regards, Dmitry Demeshchuk From kvs@REDACTED Wed Apr 6 16:33:40 2011 From: kvs@REDACTED (Konstantin Sorokin) Date: Wed, 6 Apr 2011 18:33:40 +0400 Subject: [erlang-questions] Processing huge binaries in NIFs Message-ID: Hello! I want to process huge binaries in NIFs and in order not to screw up VM's scheduler I want to move time consuming jobs into a separate thread. Do I really need to make an internal copy of the binary before passing it to a thread for processing or it'll be OK just to set pointers to raw data in a task structure and then submit that task to the worker thread ? -- Konstantin Sorokin -------------- next part -------------- An HTML attachment was scrubbed... URL: From jack@REDACTED Wed Apr 6 17:03:39 2011 From: jack@REDACTED (Jack Moffitt) Date: Wed, 6 Apr 2011 09:03:39 -0600 Subject: [erlang-questions] Re: Erlang manuals problem when installing from Homebrew In-Reply-To: References: Message-ID: > The question is: is there the more right way to point Erlang to the > right manuals directory? The more right way would be to fix the brew recipe. Thanks for finding that workaround though; I was having the same problem but was too lazy to fix it. jack. From demeshchuk@REDACTED Wed Apr 6 17:26:00 2011 From: demeshchuk@REDACTED (Dmitry Demeshchuk) Date: Wed, 6 Apr 2011 19:26:00 +0400 Subject: [erlang-questions] Re: Erlang manuals problem when installing from Homebrew In-Reply-To: References: Message-ID: Fixing the recipe is obvious. But maybe the problem can be solved in a more proper way, like using some undocumented env variable, or something? Actually, the fact that Erlang doesn't understand $MANPATH seems odd to me. Also, there are no proper manuals locations at the documentation, so the user will have to find them out himself. On Wed, Apr 6, 2011 at 7:03 PM, Jack Moffitt wrote: >> The question is: is there the more right way to point Erlang to the >> right manuals directory? > > The more right way would be to fix the brew recipe. > > Thanks for finding that workaround though; I was having the same > problem but was too lazy to fix it. > > jack. > -- Best regards, Dmitry Demeshchuk From muhammad.yousaf@REDACTED Wed Apr 6 17:51:02 2011 From: muhammad.yousaf@REDACTED (Muhammad Yousaf) Date: Wed, 6 Apr 2011 20:51:02 +0500 Subject: [erlang-questions] How to remove \ from string Message-ID: Hi,I have a string "{get,\"user\",\"wilson\",\"lname\"}"i want to remove all " \" from the above string how can i do that ??i tried re:replace but is not working any help will be appreciatedthanks Regards, Muhammad Yousaf -------------- next part -------------- An HTML attachment was scrubbed... URL: From magnus.henoch@REDACTED Wed Apr 6 17:51:46 2011 From: magnus.henoch@REDACTED (Magnus Henoch) Date: Wed, 6 Apr 2011 15:51:46 +0000 (GMT) Subject: [erlang-questions] Dialyzer vs funs with unknown arity In-Reply-To: <1480161098.69171302104742118.JavaMail.root@zimbra> Message-ID: <2144874837.69211302105106008.JavaMail.root@zimbra> Hi all, I'm trying to get Dialyzer to accept a type spec containing a fun of unknown arity. According to the manual (http://www.erlang.org/doc/reference_manual/typespec.html) that should be fun((...) -> ReturnType), but when I run Dialyzer, it gives me an error. I'm probably missing something obvious but I really can't see it... Does anyone have an idea? I'm running Erlang/OTP R14B02, Dialyzer 2.4.2. Here is my module: -module(foo). -export([my_apply/2]). -spec my_apply(fun((...) -> X), [_]) -> X. my_apply(Fun, Args) -> apply(Fun, Args). And here is the output: $ dialyzer --src foo.erl Checking whether the PLT /home/magnus/.dialyzer_plt is up-to-date... yes Proceeding with analysis... dialyzer: Analysis failed with error: Unable to find type 'fun' Last messages in the log cache: Reading files and computing callgraph... done in 0.06 secs Removing edges... done in 0.01 secs Regards, Magnus From kostis@REDACTED Wed Apr 6 17:58:17 2011 From: kostis@REDACTED (Kostis Sagonas) Date: Wed, 06 Apr 2011 18:58:17 +0300 Subject: [erlang-questions] Re: Dialyzer vs funs with unknown arity In-Reply-To: <2144874837.69211302105106008.JavaMail.root@zimbra> References: <2144874837.69211302105106008.JavaMail.root@zimbra> Message-ID: <4D9C8D99.5010507@cs.ntua.gr> Magnus Henoch wrote: > Hi all, > > I'm trying to get Dialyzer to accept a type spec containing a fun of > unknown arity. According to the manual > (http://www.erlang.org/doc/reference_manual/typespec.html) that should > be fun((...) -> ReturnType), but when I run Dialyzer, it gives me an error. > > I'm probably missing something obvious but I really can't see > it... You are not missing anything. I've submitted a patch about this which is currently cooking in 'pu'. Hopefully it will be ready soon. See: https://github.com/erlang/otp/commit/b92234d1b1b527bb56e5b66d206ea50fcb82c381 Kostis From comptekki@REDACTED Wed Apr 6 18:04:11 2011 From: comptekki@REDACTED (Wes James) Date: Wed, 6 Apr 2011 10:04:11 -0600 Subject: [erlang-questions] Re: How to remove \ from string In-Reply-To: References: Message-ID: On Wed, Apr 6, 2011 at 9:51 AM, Muhammad Yousaf wrote: > Hi, > I have a string > "{get,\"user\",\"wilson\",\"lname\"}" > i want to remove all " \" from the above string how can i do that ?? > i tried re:replace but is not working any help will be appreciated > thanks > Regards, > Muhammad Yousaf Just one of probably many ways: 1> A="{get,\"user\",\"wilson\",\"lname\"}". "{get,\"user\",\"wilson\",\"lname\"}" 2> A--"\"\"\"\"\"\"". "{get,user,wilson,lname}" -wes From magnus.henoch@REDACTED Wed Apr 6 18:07:07 2011 From: magnus.henoch@REDACTED (Magnus Henoch) Date: Wed, 6 Apr 2011 16:07:07 +0000 (GMT) Subject: [erlang-questions] Re: Dialyzer vs funs with unknown arity In-Reply-To: <4D9C8D99.5010507@cs.ntua.gr> Message-ID: <1218946064.69311302106027846.JavaMail.root@zimbra> ----- "Kostis Sagonas" wrote: > You are not missing anything. I've submitted a patch about this which > is currently cooking in 'pu'. Hopefully it will be ready soon. See: > https://github.com/erlang/otp/commit/b92234d1b1b527bb56e5b66d206ea50fcb82c381 Ah, it makes more sense now :) Thanks! Magnus From raimo+erlang-questions@REDACTED Wed Apr 6 18:07:28 2011 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Wed, 6 Apr 2011 18:07:28 +0200 Subject: [erlang-questions] Re: Question about register/2 In-Reply-To: <0FDC99A7-4BF7-4F1D-9624-E5C473284FD4@erlang-solutions.com> References: <0FDC99A7-4BF7-4F1D-9624-E5C473284FD4@erlang-solutions.com> Message-ID: <20110406160728.GA14895@erix.ericsson.se> On Wed, Apr 06, 2011 at 02:44:39PM +0200, Ulf Wiger wrote: > > Any time you call a function, the input arguments are evaluated before the function is executed, so the spawn should *always* execute in this case. > > This is characteristic of a language with eager (as opposed to lazy) evaluation. > > BR, > Ulf W > > On 6 Apr 2011, at 14:40, Arie van Wingerden wrote: > > > Hi, > > > > when I issue register(id, spawn aFun) and id already is associated with some process, the function fails. > > > > What disturbs me is that the check of id already being taken for another pid, might take place *after* the spawn has been executed. > > Hence a "ghost" process is running. > > > > Is this the way it works? And how is this mostly solved? Pid = spawn_link(fun () -> register(id, self()), my:loop() end), > > > > Regards, > > Arie > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > Ulf Wiger, CTO, Erlang Solutions, Ltd. > http://erlang-solutions.com > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From gianfranco.alongi@REDACTED Wed Apr 6 18:07:41 2011 From: gianfranco.alongi@REDACTED (Gianfranco Alongi) Date: Wed, 6 Apr 2011 16:07:41 +0000 (GMT) Subject: [erlang-questions] Re: How to remove \ from string In-Reply-To: Message-ID: <193767626.69341302106061359.JavaMail.root@zimbra> [X||X<-"{get,\"user\",\"wilson\",\"lname\"}",X=/=$\\,X=/=$"]. "{get,user,wilson,lname}" ----- Original Message ----- From: "Wes James" To: "Muhammad Yousaf" Cc: erlang-questions@REDACTED Sent: Wednesday, 6 April, 2011 17:04:11 GMT +00:00 GMT Britain, Ireland, Portugal Subject: [erlang-questions] Re: How to remove \ from string On Wed, Apr 6, 2011 at 9:51 AM, Muhammad Yousaf wrote: > Hi, > I have a string > "{get,\"user\",\"wilson\",\"lname\"}" > i want to remove all " \" from the above string how can i do that ?? > i tried re:replace but is not working any help will be appreciated > thanks > Regards, > Muhammad Yousaf Just one of probably many ways: 1> A="{get,\"user\",\"wilson\",\"lname\"}". "{get,\"user\",\"wilson\",\"lname\"}" 2> A--"\"\"\"\"\"\"". "{get,user,wilson,lname}" -wes _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://erlang.org/mailman/listinfo/erlang-questions From raimo+erlang-questions@REDACTED Wed Apr 6 18:08:46 2011 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Wed, 6 Apr 2011 18:08:46 +0200 Subject: [erlang-questions] Re: How to remove \ from string In-Reply-To: References: Message-ID: <20110406160846.GB14895@erix.ericsson.se> On Wed, Apr 06, 2011 at 08:51:02PM +0500, Muhammad Yousaf wrote: > > Hi,I have a string "{get,\"user\",\"wilson\",\"lname\"}"i want to remove all " \" from the above string how can i do that ??i tried re:replace but is not working any help will be appreciatedthanks Post your re:replace attempt and someone will gladly help. > Regards, > Muhammad Yousaf > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From wallentin.dahlberg@REDACTED Wed Apr 6 18:12:11 2011 From: wallentin.dahlberg@REDACTED (=?ISO-8859-1?Q?Bj=F6rn=2DEgil_Dahlberg?=) Date: Wed, 6 Apr 2011 18:12:11 +0200 Subject: [erlang-questions] Re: How to remove \ from string In-Reply-To: References: Message-ID: 1> [X || X <- "{get,\"user\",\"wilson\",\"lname\"}", X =/= $\"]. "{get,user,wilson,lname}" // Bj?rn-Egil 2011/4/6 Muhammad Yousaf > Hi, > > I have a string > > "{get,\"user\",\"wilson\",\"lname\"}" > > i want to remove all " \" from the above string how can i do that ?? > > i tried re:replace but is not working any help will be appreciated > > thanks > > Regards, > > Muhammad Yousaf > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From spawn.think@REDACTED Wed Apr 6 18:16:13 2011 From: spawn.think@REDACTED (Ahmed Omar) Date: Wed, 6 Apr 2011 18:16:13 +0200 Subject: [erlang-questions] Re: How to remove \ from string In-Reply-To: <193767626.69341302106061359.JavaMail.root@zimbra> References: <193767626.69341302106061359.JavaMail.root@zimbra> Message-ID: re:replace(S,["\""],"",[global, {return,list}]). "{get,user,wilson,lname}" On Wed, Apr 6, 2011 at 6:07 PM, Gianfranco Alongi < gianfranco.alongi@REDACTED> wrote: > > [X||X<-"{get,\"user\",\"wilson\",\"lname\"}",X=/=$\\,X=/=$"]. > > "{get,user,wilson,lname}" > > > ----- Original Message ----- > From: "Wes James" > To: "Muhammad Yousaf" > Cc: erlang-questions@REDACTED > Sent: Wednesday, 6 April, 2011 17:04:11 GMT +00:00 GMT Britain, Ireland, > Portugal > Subject: [erlang-questions] Re: How to remove \ from string > > On Wed, Apr 6, 2011 at 9:51 AM, Muhammad Yousaf > wrote: > > Hi, > > I have a string > > "{get,\"user\",\"wilson\",\"lname\"}" > > i want to remove all " \" from the above string how can i do that ?? > > i tried re:replace but is not working any help will be appreciated > > thanks > > Regards, > > Muhammad Yousaf > > Just one of probably many ways: > > 1> A="{get,\"user\",\"wilson\",\"lname\"}". > "{get,\"user\",\"wilson\",\"lname\"}" > 2> A--"\"\"\"\"\"\"". > "{get,user,wilson,lname}" > > -wes > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -- Best Regards, - Ahmed Omar http://nl.linkedin.com/in/adiaa Follow me on twitter @spawn_think -------------- next part -------------- An HTML attachment was scrubbed... URL: From boris.muehmer@REDACTED Wed Apr 6 18:21:30 2011 From: boris.muehmer@REDACTED (=?UTF-8?Q?Boris_M=C3=BChmer?=) Date: Wed, 6 Apr 2011 18:21:30 +0200 Subject: [erlang-questions] Re: Erlang manuals problem when installing from Homebrew In-Reply-To: References: Message-ID: I only use "homebrew" installations, and never had those problems You describe (so far... lucky me). Actually I have different Erlang/OTP versions on a single machine. I supply different "prefixes" to configure and "erl" always finds the corresponding man page version under "/lib/erlang/man". The systems I use at work and home are always Ubuntu systems with versions 10.04 and 10.10 (and very few 09.x ones). The only thing I have to complain about is when running "make install-docs" (using an unpatched R14BX source) that "env" doesn't properly evaluate escript calls. But I start to believe this may be an "env" problem. I didn't have time to have a closer look at this problem, because fixing the makefile is much faster. Just one questions why should "erl" "understand" the MANPATH variable? To quote the "erl" man page: -man Module : Displays the manual page for the Erlang module Module . Only supported on Unix. Evaluating the MANPATH would lead to possible wrong versions, especially on systems with multiple erlang installations. When I really want the "man" command to include the erlang-man-pages, I would add "/lib/erlang/man" to the MANPATH environment variable. IMHO it doesn't make any sense to use "erl -man ls", instead of "man ls". Just my 2 cents, no offense meant... - boris 2011/4/6 Dmitry Demeshchuk : > Fixing the recipe is obvious. But maybe the problem can be solved in a > more proper way, like using some undocumented env variable, or > something? > > Actually, the fact that Erlang doesn't understand $MANPATH seems odd > to me. Also, there are no proper manuals locations at the > documentation, so the user will have to find them out himself. > > On Wed, Apr 6, 2011 at 7:03 PM, Jack Moffitt wrote: >>> The question is: is there the more right way to point Erlang to the >>> right manuals directory? >> >> The more right way would be to fix the brew recipe. >> >> Thanks for finding that workaround though; I was having the same >> problem but was too lazy to fix it. >> >> jack. >> > > > > -- > Best regards, > Dmitry Demeshchuk > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > From daniel.goertzen@REDACTED Wed Apr 6 18:46:34 2011 From: daniel.goertzen@REDACTED (Daniel Goertzen) Date: Wed, 6 Apr 2011 11:46:34 -0500 Subject: [erlang-questions] callback module without behavior definition? Message-ID: One thing that has bothered me about implementing gen_servers is that I have to create empty stubs for the callbacks that I don't need. Today I made a gen_server that only needs init/1, so instead of creating all those stubs I just commented out the behavior definition "-behavior(gen_server)." It seems to work fine, and the compiler doesn't complain. Are there any consequences to not having a behavior definition that I am overlooking? My whole module looks something like... -module(mymod). %-behavior(gen_server). -export([start_link/0, init/1]). start_link() -> gen_server:start_link(?MODULE, [], []). init(_) -> do_stuff... {ok, []}. My actual use-case here is to have a gen_server that "holds" a named, read-only ets table for other processes to read. init/1 creates the table and loads data, and process termination makes the table go away. Thanks, Dan. -------------- next part -------------- An HTML attachment was scrubbed... URL: From fred.hebert@REDACTED Wed Apr 6 18:50:17 2011 From: fred.hebert@REDACTED (=?iso-8859-1?Q?Fr=E9d=E9ric_Trottier-H=E9bert?=) Date: Wed, 6 Apr 2011 12:50:17 -0400 Subject: [erlang-questions] Re: callback module without behavior definition? In-Reply-To: References: Message-ID: <45FA8174-2785-49F3-8C98-398EC4385AF8@erlang-solutions.com> You could alternatively just give the table (either with a heir or just giving it with ets:give_away/3) to a supervisor or some system process that should never die. On 2011-04-06, at 12:46 PM, Daniel Goertzen wrote: > One thing that has bothered me about implementing gen_servers is that I have to create empty stubs for the callbacks that I don't need. Today I made a gen_server that only needs init/1, so instead of creating all those stubs I just commented out the behavior definition "-behavior(gen_server)." > > It seems to work fine, and the compiler doesn't complain. Are there any consequences to not having a behavior definition that I am overlooking? My whole module looks something like... > > > -module(mymod). > %-behavior(gen_server). > -export([start_link/0, init/1]). > > start_link() -> > gen_server:start_link(?MODULE, [], []). > > init(_) -> > do_stuff... > {ok, []}. > > > My actual use-case here is to have a gen_server that "holds" a named, read-only ets table for other processes to read. init/1 creates the table and loads data, and process termination makes the table go away. > > Thanks, > Dan. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -- Fred H?bert http://www.erlang-solutions.com From moxford@REDACTED Wed Apr 6 18:53:28 2011 From: moxford@REDACTED (Mike Oxford) Date: Wed, 6 Apr 2011 09:53:28 -0700 Subject: [erlang-questions] Re: escript question In-Reply-To: References: Message-ID: Thank you to everyone who pointed out the if vs case style; not only on-list but off-list as well. As mentioned I'm still "a n00b" and teaching myself and with too many years of C/C++ behind me I'm not fluent in pattern-matching. My brain just doesn't work like that (yet - am working on it.) The script works for 'ls', but I get no output and a simple shell return code of "1" for the rebar scripts. I may need to investigate the rebar source more, as it seems to be the only thing I feed this script that fails. Thanks! -mox On Tue, Apr 5, 2011 at 4:30 PM, Mike Oxford wrote: > This simple escript (teaching myself) works for some things, and not for > others. > > https://gist.github.com/899768 > > Can anyone figure out why? I'm at a loss. > > Thanks in advance! > > -mox > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From demeshchuk@REDACTED Wed Apr 6 18:58:28 2011 From: demeshchuk@REDACTED (Dmitry Demeshchuk) Date: Wed, 6 Apr 2011 20:58:28 +0400 Subject: [erlang-questions] Re: Erlang manuals problem when installing from Homebrew In-Reply-To: References: Message-ID: "homebrew" doesn't mean actually homebrew, right? apt-get really installs Erlang with proper manuals location, but homebrew doesn't. By the way, as far as I remember, the directory structure that apt-get generates differs much from the one generated by homebrew. I agree with the point about possible versions conflicts. But I don't believe anyone would often call Erlang manual pages like "/some/long/path/erl -man lists", he'll just use "erl -man lists" in most cases. And this way he'll use some particular Erlang version, most actual to him. If reading several manuals' versions is required, it's easy to use simple custom scripts. Also, it's possible to make erl look for the manuals at the default locations first, and only if the manuals aren't found there, look them up using $MANPATH. But my main concern is not this $MANPATH thing. It's rather the uncertainty of the possible mans locations and being unable to configure them in any way. On Wed, Apr 6, 2011 at 8:21 PM, Boris M?hmer wrote: > I only use "homebrew" installations, and never had those problems You > describe (so far... lucky me). Actually I have different Erlang/OTP > versions on a single machine. I supply different "prefixes" to > configure and "erl" always finds the corresponding man page version > under "/lib/erlang/man". > > The systems I use at work and home are always Ubuntu systems with > versions 10.04 and 10.10 (and very few 09.x ones). The only thing I > have to complain about is when running "make install-docs" (using an > unpatched R14BX source) that "env" doesn't properly evaluate escript > calls. But I start to believe this may be an "env" problem. I didn't > have time to have a closer look at this problem, because fixing the > makefile is much faster. > > Just one questions why should "erl" "understand" the MANPATH variable? > > To quote the "erl" man page: > ? ?-man Module : > ? ? ? ?Displays the manual page for the Erlang module Module . Only > supported on Unix. > > Evaluating the MANPATH would lead to possible wrong versions, > especially on systems with multiple erlang installations. > > When I really want the "man" command to include the erlang-man-pages, > I would add "/lib/erlang/man" to the MANPATH environment variable. > > IMHO it doesn't make any sense to use "erl -man ls", instead of "man ls". > > > Just my 2 cents, no offense meant... > > ?- boris > > > > 2011/4/6 Dmitry Demeshchuk : >> Fixing the recipe is obvious. But maybe the problem can be solved in a >> more proper way, like using some undocumented env variable, or >> something? >> >> Actually, the fact that Erlang doesn't understand $MANPATH seems odd >> to me. Also, there are no proper manuals locations at the >> documentation, so the user will have to find them out himself. >> >> On Wed, Apr 6, 2011 at 7:03 PM, Jack Moffitt wrote: >>>> The question is: is there the more right way to point Erlang to the >>>> right manuals directory? >>> >>> The more right way would be to fix the brew recipe. >>> >>> Thanks for finding that workaround though; I was having the same >>> problem but was too lazy to fix it. >>> >>> jack. >>> >> >> >> >> -- >> Best regards, >> Dmitry Demeshchuk >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> > -- Best regards, Dmitry Demeshchuk From attila.r.nohl@REDACTED Wed Apr 6 19:23:20 2011 From: attila.r.nohl@REDACTED (Attila Rajmund Nohl) Date: Wed, 6 Apr 2011 19:23:20 +0200 Subject: [erlang-questions] Re: callback module without behavior definition? In-Reply-To: References: Message-ID: 2011/4/6, Daniel Goertzen : > One thing that has bothered me about implementing gen_servers is that I have > to create empty stubs for the callbacks that I don't need. Today I made a > gen_server that only needs init/1, so instead of creating all those stubs I > just commented out the behavior definition "-behavior(gen_server)." Then why bother with gen_server, why not use erlang:spawn_link or proc_lib:spawn_link (if you want fancy crash reports)? From dmercer@REDACTED Wed Apr 6 19:35:49 2011 From: dmercer@REDACTED (David Mercer) Date: Wed, 6 Apr 2011 12:35:49 -0500 Subject: [erlang-questions] Re: callback module without behavior definition? In-Reply-To: References: Message-ID: <002d01cbf481$129b0960$37d11c20$@com> On Wednesday, April 06, 2011, Attila Rajmund Nohl wrote: > 2011/4/6, Daniel Goertzen : > > One thing that has bothered me about implementing gen_servers is that > I have > > to create empty stubs for the callbacks that I don't need. Today I > made a > > gen_server that only needs init/1, so instead of creating all those > stubs I > > just commented out the behavior definition "-behavior(gen_server)." > > Then why bother with gen_server, why not use erlang:spawn_link or > proc_lib:spawn_link (if you want fancy crash reports)? Isn't a gen_server the OTP thing to do? Hook it into a supervisor and all that, too... From muhammad.yousaf@REDACTED Wed Apr 6 19:36:46 2011 From: muhammad.yousaf@REDACTED (Muhammad Yousaf) Date: Wed, 6 Apr 2011 22:36:46 +0500 Subject: [erlang-questions] Re: How to remove \ from string In-Reply-To: References: , <193767626.69341302106061359.JavaMail.root@zimbra>, Message-ID: Thanks a lot but i only want to remove backslash not double quotes for example Val = <<"{get,\"user\",\"wilson\",\"lname\"}">> , i need Val= <<"{get,"user","wilson","lname"}">> what i am doing with your help re:replace(Val,["\\"],"",[global, {return,list}]). getting error[X||X<-"{get,\"user\",\"wilson\",\"lname\"}",X=/=$\\]. also dont work on backslash any idea how can i remove only backslashes from string or binary thanks in advance Regards, Muhammad Yousaf -------------- next part -------------- An HTML attachment was scrubbed... URL: From comptekki@REDACTED Wed Apr 6 19:44:35 2011 From: comptekki@REDACTED (Wes James) Date: Wed, 6 Apr 2011 11:44:35 -0600 Subject: [erlang-questions] Re: How to remove \ from string In-Reply-To: References: <193767626.69341302106061359.JavaMail.root@zimbra> Message-ID: On Wed, Apr 6, 2011 at 11:36 AM, Muhammad Yousaf wrote: > > Thanks a lot but i only want to remove backslash not double quotes > for example > Val = <<"{get,\"user\",\"wilson\",\"lname\"}">> , > i need Val= <<"{get,"user","wilson","lname"}">> > what i am doing with your help You can't remove the \ from the string if you have " in the string. the \ is the escape charactor so the " can be viewed. \ is not in the internal representation, only when viewing it. -wes From anders.nygren@REDACTED Wed Apr 6 19:46:21 2011 From: anders.nygren@REDACTED (Anders Nygren) Date: Wed, 6 Apr 2011 12:46:21 -0500 Subject: [erlang-questions] Re: How to remove \ from string In-Reply-To: References: <193767626.69341302106061359.JavaMail.root@zimbra> Message-ID: The backslash is not really part of the string, it is just an effect of how the shell presents data. 4> erlang:byte_size(<<"a\"">>). 2 6> io:format("~s~n",[<<"a\"">>]). a" ok /Anders On Wed, Apr 6, 2011 at 12:36 PM, Muhammad Yousaf wrote: > > Thanks a lot but i only want to remove backslash not double quotes > for example > Val = <<"{get,\"user\",\"wilson\",\"lname\"}">> , > i need Val= <<"{get,"user","wilson","lname"}">> > what i am doing with your help > > re:replace(Val,["\\"],"",[global, {return,list}]). getting error > > [X||X<-"{get,\"user\",\"wilson\",\"lname\"}",X=/=$\\]. > > also dont work on backslash any idea how can i remove only backslashes from > string or binary > > thanks in advance > > Regards, > Muhammad Yousaf > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > From jesper.louis.andersen@REDACTED Wed Apr 6 19:46:45 2011 From: jesper.louis.andersen@REDACTED (Jesper Louis Andersen) Date: Wed, 6 Apr 2011 19:46:45 +0200 Subject: [erlang-questions] Re: How to remove \ from string In-Reply-To: References: <193767626.69341302106061359.JavaMail.root@zimbra> Message-ID: On Wed, Apr 6, 2011 at 19:36, Muhammad Yousaf wrote: > > Thanks a lot but i only want to remove backslash not double quotes > for example > Val = <<"{get,\"user\",\"wilson\",\"lname\"}">> , > i need Val= <<"{get,"user","wilson","lname"}">> > what i am doing with your help Oh, then it is because you have a misconception of what \" actually means. The problem is that to encode a string, we enclose it in quotes, like "Hello". But when we want to encode a "-character by itself, we need some way to tell the parser that this is actually the "-character and not something that marks the end-of-string. So, we adopt a convention: When we prefix by a backslash, \", the parser treats it as an " rather than the end-of-string. Eshell V5.8.4 (abort with ^G) 1> Val = <<"{get,\"user\",\"wilson\",\"lname\"}">>. <<"{get,\"user\",\"wilson\",\"lname\"}">> 2> io:format("~s~n", [Val]). {get,"user","wilson","lname"} ok As you can see, the quotes are just prefixed by a backslash for its internal representation, and in the output, we get the string you actually want to output. In conclusion: It is a parser-technicality that we need some way to distinguish the "-char from the "-end-of-string and we have adopted a convention in order to carry out the discrimination. -- J. From dang@REDACTED Wed Apr 6 20:03:40 2011 From: dang@REDACTED (Daniel Goertzen) Date: Wed, 6 Apr 2011 13:03:40 -0500 Subject: [erlang-questions] Re: callback module without behavior definition? In-Reply-To: <002d01cbf481$129b0960$37d11c20$@com> References: <002d01cbf481$129b0960$37d11c20$@com> Message-ID: I do want to hook it into a supervisor. If I use a proc_lib process, it looks like I would have to implement a message loop and some other callbacks. I guess my original question is more about what behavior statements actually do. Do they just add compile-time "type" checking, or do they have some real runtime impact? Dan. On Wed, Apr 6, 2011 at 12:35 PM, David Mercer wrote: > On Wednesday, April 06, 2011, Attila Rajmund Nohl wrote: > > > 2011/4/6, Daniel Goertzen : > > > One thing that has bothered me about implementing gen_servers is that > > I have > > > to create empty stubs for the callbacks that I don't need. Today I > > made a > > > gen_server that only needs init/1, so instead of creating all those > > stubs I > > > just commented out the behavior definition "-behavior(gen_server)." > > > > Then why bother with gen_server, why not use erlang:spawn_link or > > proc_lib:spawn_link (if you want fancy crash reports)? > > Isn't a gen_server the OTP thing to do? Hook it into a supervisor and all > that, too... > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From andrew@REDACTED Wed Apr 6 20:08:59 2011 From: andrew@REDACTED (Andrew Thompson) Date: Wed, 6 Apr 2011 14:08:59 -0400 Subject: [erlang-questions] Re: callback module without behavior definition? In-Reply-To: References: <002d01cbf481$129b0960$37d11c20$@com> Message-ID: <20110406180859.GG24843@hijacked.us> On Wed, Apr 06, 2011 at 01:03:40PM -0500, Daniel Goertzen wrote: > I do want to hook it into a supervisor. If I use a proc_lib process, it > looks like I would have to implement a message loop and some other > callbacks. > > I guess my original question is more about what behavior statements actually > do. Do they just add compile-time "type" checking, or do they have some > real runtime impact? > They're only compile-time to my knowledge. However, if you omit the methods the behaviour expects, you will get runtime crashes that won't be pretty. Andrew From comptekki@REDACTED Wed Apr 6 20:44:29 2011 From: comptekki@REDACTED (Wes James) Date: Wed, 6 Apr 2011 12:44:29 -0600 Subject: [erlang-questions] Re: How to remove \ from string In-Reply-To: References: <193767626.69341302106061359.JavaMail.root@zimbra> Message-ID: On Wed, Apr 6, 2011 at 11:36 AM, Muhammad Yousaf wrote: > > Thanks a lot but i only want to remove backslash not double quotes > for example > Val = <<"{get,\"user\",\"wilson\",\"lname\"}">> , > i need Val= <<"{get,"user","wilson","lname"}">> > what i am doing with your help > > re:replace(Val,["\\"],"",[global, {return,list}]). getting error > > [X||X<-"{get,\"user\",\"wilson\",\"lname\"}",X=/=$\\]. > Another way to see what is going on is do this: Y=binary_to_list(<<"{get,\"user\",\"wilson\",\"lname\"}">>). [io_lib:format("~c~w",[X, X])||X <- Y]. You'll see \" in the output, but the ascii numeric value for that character is 34. Then if you go and look and see what 34 is on the ascii table below, you'll see it is ". http://www.asciitable.com/ -wes From robert.virding@REDACTED Wed Apr 6 20:50:27 2011 From: robert.virding@REDACTED (Robert Virding) Date: Wed, 6 Apr 2011 18:50:27 +0000 (GMT) Subject: [erlang-questions] Re: callback module without behavior definition? In-Reply-To: <307232141.69751302115765384.JavaMail.root@zimbra> Message-ID: <1656451741.69771302115827169.JavaMail.root@zimbra> Yes, it is just a compile-time check and if the undefined callbacks are never called then no errors will occur. Using a gen_server for this case may seem like a bit of an overkill but it does save a bit of programming if you want the process to be "OTP-compliant". Starting it using proc_lib and doing it all yourself is not that difficult and is quite well explained in the Erlang documentation: http://www.erlang.org/doc/design_principles/spec_proc.html. Robert ----- "Andrew Thompson" wrote: > On Wed, Apr 06, 2011 at 01:03:40PM -0500, Daniel Goertzen wrote: > > I do want to hook it into a supervisor. If I use a proc_lib > process, it > > looks like I would have to implement a message loop and some other > > callbacks. > > > > I guess my original question is more about what behavior statements > actually > > do. Do they just add compile-time "type" checking, or do they have > some > > real runtime impact? > > > > They're only compile-time to my knowledge. However, if you omit the > methods the behaviour expects, you will get runtime crashes that > won't > be pretty. > > Andrew > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From michael.santos@REDACTED Wed Apr 6 21:22:08 2011 From: michael.santos@REDACTED (Michael Santos) Date: Wed, 6 Apr 2011 15:22:08 -0400 Subject: [erlang-questions] Re: Erlang manuals problem when installing from Homebrew In-Reply-To: References: Message-ID: <20110406192208.GB26462@ecn.lan> On Wed, Apr 06, 2011 at 07:26:00PM +0400, Dmitry Demeshchuk wrote: > Fixing the recipe is obvious. But maybe the problem can be solved in a > more proper way, like using some undocumented env variable, or > something? > > Actually, the fact that Erlang doesn't understand $MANPATH seems odd > to me. Also, there are no proper manuals locations at the > documentation, so the user will have to find them out himself. erl reads the man pages like this: erts_snprintf(tmpStr, sizeof(tmpStr), "%s/man", rootdir); set_env("MANPATH", tmpStr); execvp("man", argv+i); So it uses the location of the erlang install (e.g., /usr/local/lib/erlang), appends the "man" directory then overwrites whatever is in your MANPATH environment variable. The MANPATH variable still works: $ man inets No manual entry for inets $ export MANPATH=/usr/local/lib/erlang/man $ man inets inets(3) ... > On Wed, Apr 6, 2011 at 7:03 PM, Jack Moffitt wrote: > >> The question is: is there the more right way to point Erlang to the > >> right manuals directory? > > > > The more right way would be to fix the brew recipe. > > > > Thanks for finding that workaround though; I was having the same > > problem but was too lazy to fix it. > > > > jack. > > > > > > -- > Best regards, > Dmitry Demeshchuk > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From muhammad.yousaf@REDACTED Wed Apr 6 22:07:08 2011 From: muhammad.yousaf@REDACTED (Muhammad Yousaf) Date: Thu, 7 Apr 2011 01:07:08 +0500 Subject: [erlang-questions] Re: How to remove \ from string In-Reply-To: References: , <193767626.69341302106061359.JavaMail.root@zimbra>, , , Message-ID: Thank you i got your point but what i am trying to do is , remote computer is sending me a data via socket like {get,"user","wilson","lname"}but for some reason i cannot match it in case statement my output is im in none recieve Data from socket:[255,251,31,255,251,32,255,251,24,255,251,39,255,253, 1,255,251,3,255,253,3]im in none recieve Data from socket:"{get,\"user\",\"wilson\",\"lname\"}"im in none recieve Data from socket:"\r\n" Code is as fellow do_echo(Socket) -> case gen_tcp:recv(Socket, 0) of {ok, Data} -> D = binary_to_list(Data), case D of {get,_,_,_} -> io:format("im innnnnnn~n");%gen_tcp:send(Socket,erl_api:search()); _Else -> io:format("im in none ~n") end, io:format("recieve Data from socket:~p~n",[D]), do_echo(Socket); {error, closed} -> ok end. Any idea what i am doing wrong ?? Regards, Muhammad Yousaf > Date: Wed, 6 Apr 2011 12:44:29 -0600 > Subject: Re: [erlang-questions] Re: How to remove \ from string > From: comptekki@REDACTED > To: muhammad.yousaf@REDACTED > CC: erlang-questions@REDACTED > > On Wed, Apr 6, 2011 at 11:36 AM, Muhammad Yousaf > wrote: > > > > Thanks a lot but i only want to remove backslash not double quotes > > for example > > Val = <<"{get,\"user\",\"wilson\",\"lname\"}">> , > > i need Val= <<"{get,"user","wilson","lname"}">> > > what i am doing with your help > > > > re:replace(Val,["\\"],"",[global, {return,list}]). getting error > > > > [X||X<-"{get,\"user\",\"wilson\",\"lname\"}",X=/=$\\]. > > > > > > > Another way to see what is going on is do this: > > Y=binary_to_list(<<"{get,\"user\",\"wilson\",\"lname\"}">>). > [io_lib:format("~c~w",[X, X])||X <- Y]. > > You'll see \" in the output, but the ascii numeric value for that > character is 34. > > Then if you go and look and see what 34 is on the ascii table below, > you'll see it is ". > > http://www.asciitable.com/ > > -wes -------------- next part -------------- An HTML attachment was scrubbed... URL: From xapwing@REDACTED Wed Apr 6 22:07:54 2011 From: xapwing@REDACTED (Arie van Wingerden) Date: Wed, 6 Apr 2011 22:07:54 +0200 Subject: [erlang-questions] Re: Question about register/2 In-Reply-To: <20110406160728.GA14895@erix.ericsson.se> References: <0FDC99A7-4BF7-4F1D-9624-E5C473284FD4@erlang-solutions.com> <20110406160728.GA14895@erix.ericsson.se> Message-ID: thx Raimo! Arie 2011/4/6 Raimo Niskanen > On Wed, Apr 06, 2011 at 02:44:39PM +0200, Ulf Wiger wrote: > > > > Any time you call a function, the input arguments are evaluated before > the function is executed, so the spawn should *always* execute in this case. > > > > This is characteristic of a language with eager (as opposed to lazy) > evaluation. > > > > BR, > > Ulf W > > > > On 6 Apr 2011, at 14:40, Arie van Wingerden wrote: > > > > > Hi, > > > > > > when I issue register(id, spawn aFun) and id already is associated with > some process, the function fails. > > > > > > What disturbs me is that the check of id already being taken for > another pid, might take place *after* the spawn has been executed. > > > Hence a "ghost" process is running. > > > > > > Is this the way it works? And how is this mostly solved? > > Pid = spawn_link(fun () -> register(id, self()), my:loop() end), > > > > > > > Regards, > > > Arie > > > _______________________________________________ > > > erlang-questions mailing list > > > erlang-questions@REDACTED > > > http://erlang.org/mailman/listinfo/erlang-questions > > > > Ulf Wiger, CTO, Erlang Solutions, Ltd. > > http://erlang-solutions.com > > > > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > -- > > / Raimo Niskanen, Erlang/OTP, Ericsson AB > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From comptekki@REDACTED Wed Apr 6 22:20:41 2011 From: comptekki@REDACTED (Wes James) Date: Wed, 6 Apr 2011 14:20:41 -0600 Subject: [erlang-questions] Re: How to remove \ from string In-Reply-To: References: <193767626.69341302106061359.JavaMail.root@zimbra> Message-ID: Probably because D is a list and {get,_....} is a tuple. Try D=list_to_tuple(binary_to_list(Data)). I didn't see binary_to_tuple.... -wes On Wed, Apr 6, 2011 at 2:07 PM, Muhammad Yousaf wrote: > > Thank you i got your point but what i am trying to do is , ?remote computer > is sending me a data via socket like?{get,"user","wilson","lname"} > but for some reason i cannot match it in case statement my output is > im in none > recieve Data from > socket:[255,251,31,255,251,32,255,251,24,255,251,39,255,253, > ?? ? ? ? ? ? ? ? ? ? ? ? ?1,255,251,3,255,253,3] From max.lapshin@REDACTED Wed Apr 6 22:52:09 2011 From: max.lapshin@REDACTED (Max Lapshin) Date: Thu, 7 Apr 2011 00:52:09 +0400 Subject: [erlang-questions] path_consult for records Message-ID: We have path_consult for tuples and we can read config files. Is there any simple way to load records from txt files? I.e.: record_consult(Path, [video_frame, media_info]). Or it is not hard to write with some existing parsers? I want to read file of following structure: #video_frame{content = video, codec = h264, flavor = config, dts = 0, pts = 0}. #video_frame{content = audio, codec = aac, flavor = config, dts = 0, pts = 0}. From comptekki@REDACTED Wed Apr 6 23:01:45 2011 From: comptekki@REDACTED (Wes James) Date: Wed, 6 Apr 2011 15:01:45 -0600 Subject: [erlang-questions] Re: How to remove \ from string In-Reply-To: References: <193767626.69341302106061359.JavaMail.root@zimbra> Message-ID: On Wed, Apr 6, 2011 at 2:07 PM, Muhammad Yousaf wrote: > > Thank you i got your point but what i am trying to do is , ?remote computer > is sending me a data via socket like?{get,"user","wilson","lname"} > but for some reason i cannot match it in case statement my output is > im in none > recieve Data from > socket:[255,251,31,255,251,32,255,251,24,255,251,39,255,253, > ?? ? ? ? ? ? ? ? ? ? ? ? ?1,255,251,3,255,253,3] > im in none > recieve Data from socket:"{get,\"user\",\"wilson\",\"lname\"}" > im in none > recieve Data from socket:"\r\n" > > Code is as fellow > do_echo(Socket) -> > ?? ?case gen_tcp:recv(Socket, 0) of > ?? ? ? ?{ok, Data} -> > ?? ? ? ? ? ?D = binary_to_list(Data), > ?? ? ? ? ? ?case D of > ?? ? ? ? ? ? ? ?{get,_,_,_} -> io:format("im > innnnnnn~n");%gen_tcp:send(Socket,erl_api:search()); > ?? ? ? ? ? ? ? ?_Else -> io:format("im in none ~n") > ?? ? ? ? ? ?end, > ?? ? ? ? ? ?io:format("recieve Data from socket:~p~n",[D]), Or you could use something like this: ... D = binary_to_list(Data), ?? ? ? ? ? ?case D of ? ? ? ? ? ? ? ?"{get"++_ -> io:format("im innnnnnn~n"); ... using matching. -wes From comptekki@REDACTED Wed Apr 6 23:50:04 2011 From: comptekki@REDACTED (Wes James) Date: Wed, 6 Apr 2011 15:50:04 -0600 Subject: [erlang-questions] Re: How to remove \ from string In-Reply-To: References: <193767626.69341302106061359.JavaMail.root@zimbra> Message-ID: On Wed, Apr 6, 2011 at 2:07 PM, Muhammad Yousaf wrote: > > Thank you i got your point but what i am trying to do is , ?remote computer > is sending me a data via socket like?{get,"user","wilson","lname"} > but for some reason i cannot match it in case statement my output is > > Code is as fellow > do_echo(Socket) -> > ?? ?case gen_tcp:recv(Socket, 0) of > ?? ? ? ?{ok, Data} -> > ?? ? ? ? ? ?D = binary_to_list(Data), > ?? ? ? ? ? ?case D of > ?? ? ? ? ? ? ? ?{get,_,_,_} -> io:format("im > innnnnnn~n");%gen_tcp:send(Socket,erl_api:search()); > ?? ? ? ? ? ? ? ?_Else -> io:format("im in none ~n") > ?? ? ? ? ? ?end, > ?? ? ? ? ? ?io:format("recieve Data from socket:~p~n",[D]), > ?? ? ? ? ? ?do_echo(Socket); > ?? ? ? ?{error, closed} -> > ?? ? ? ? ? ?ok > ?? ?end. Another option. Skip the binary_to_list and do pattern matching like this: ... <<"{","g","e","t",_/binary>> -> io:format("im innnnnnn~n");%gen_tcp:send(Socket,erl_api:search()); ... -wes From ok@REDACTED Thu Apr 7 03:08:33 2011 From: ok@REDACTED (Richard O'Keefe) Date: Thu, 7 Apr 2011 13:08:33 +1200 Subject: [erlang-questions] Re: How to remove \ from string In-Reply-To: References: , <193767626.69341302106061359.JavaMail.root@zimbra>, Message-ID: <54E6EFBE-D311-49A1-9A56-42F2AC0D1C74@cs.otago.ac.nz> On 7/04/2011, at 5:36 AM, Muhammad Yousaf wrote: > > Thanks a lot but i only want to remove backslash not double quotes > for example > > Val = <<"{get,\"user\",\"wilson\",\"lname\"}">> , The backslashes are in the printout but not in the data. 1> length(binary_to_list(<<"a\"b\"c">>)). 5 2> [A,B,C,D,E] = binary_to_list(<<"a\"b\"c">>). "a\"b\"c" 3> {A,B,C,D,E}. {97,34,98,34,99} (Backslash is ASCII 92. You see none of them here.) > > i need Val= <<"{get,"user","wilson","lname"}">> That's what you *have*; the backslashes are there in the display (or the input) so that you don't mistake the data quotes for terminator quotes. > > what i am doing with your help > > re:replace(Val,["\\"],"",[global, {return,list}]). getting error > [X||X<-"{get,\"user\",\"wilson\",\"lname\"}",X=/=$\\]. Try this. 4> [X || X <- "{get,\"user\",\"wilson\",\"lname\"}", X =:= $\\]. [] The answer is an empty list because there aren't any backslash character codes in the string to start with. From ok@REDACTED Thu Apr 7 03:22:26 2011 From: ok@REDACTED (Richard O'Keefe) Date: Thu, 7 Apr 2011 13:22:26 +1200 Subject: [erlang-questions] Re: How to remove \ from string In-Reply-To: References: , <193767626.69341302106061359.JavaMail.root@zimbra>, , , Message-ID: <6BC34640-87E7-4CFE-B630-78BFED67EA3E@cs.otago.ac.nz> On 7/04/2011, at 8:07 AM, Muhammad Yousaf wrote: > > Thank you i got your point but what i am trying to do is , remote computer is sending me a data via socket like {get,"user","wilson","lname"} > but for some reason i cannot match it in case statement my output is > > im in none > recieve Data from socket:[255,251,31,255,251,32,255,251,24,255,251,39,255,253, > 1,255,251,3,255,253,3] > im in none > recieve Data from socket:"{get,\"user\",\"wilson\",\"lname\"}" > im in none > recieve Data from socket:"\r\n" > > > Code is as fellow > > do_echo(Socket) -> > case gen_tcp:recv(Socket, 0) of > {ok, Data} -> > D = binary_to_list(Data), > case D of > {get,_,_,_} -> io:format("im innnnnnn~n");%gen_tcp:send(Socket,erl_api:search()); ^^^^ Binary to list gives you a *list* whose elements are *character codes* (integers). {get,_,_,_} is a tuple pattern, not a list pattern. get is an atom, not a character code. If you want Erlang terms, why isn't the remote computer sending you the binary representation of a term? > _Else -> io:format("im in none ~n") > end, > io:format("recieve Data from socket:~p~n",[D]), > do_echo(Socket); > {error, closed} -> > ok > end. > > Any idea what i am doing wrong ?? > > > > > Regards, > > Muhammad Yousaf > > > > > > Date: Wed, 6 Apr 2011 12:44:29 -0600 > > Subject: Re: [erlang-questions] Re: How to remove \ from string > > From: comptekki@REDACTED > > To: muhammad.yousaf@REDACTED > > CC: erlang-questions@REDACTED > > > > On Wed, Apr 6, 2011 at 11:36 AM, Muhammad Yousaf > > wrote: > > > > > > Thanks a lot but i only want to remove backslash not double quotes > > > for example > > > Val = <<"{get,\"user\",\"wilson\",\"lname\"}">> , > > > i need Val= <<"{get,"user","wilson","lname"}">> > > > what i am doing with your help > > > > > > re:replace(Val,["\\"],"",[global, {return,list}]). getting error > > > > > > [X||X<-"{get,\"user\",\"wilson\",\"lname\"}",X=/=$\\]. > > > > > > > > > > > > > Another way to see what is going on is do this: > > > > Y=binary_to_list(<<"{get,\"user\",\"wilson\",\"lname\"}">>). > > [io_lib:format("~c~w",[X, X])||X <- Y]. > > > > You'll see \" in the output, but the ascii numeric value for that > > character is 34. > > > > Then if you go and look and see what 34 is on the ascii table below, > > you'll see it is ". > > > > http://www.asciitable.com/ > > > > -wes > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From demeshchuk@REDACTED Thu Apr 7 05:23:11 2011 From: demeshchuk@REDACTED (Dmitry Demeshchuk) Date: Thu, 7 Apr 2011 07:23:11 +0400 Subject: [erlang-questions] Re: Erlang manuals problem when installing from Homebrew In-Reply-To: <20110406192208.GB26462@ecn.lan> References: <20110406192208.GB26462@ecn.lan> Message-ID: Thanks, Michael, that's exactly what I was asking about. On Wed, Apr 6, 2011 at 11:22 PM, Michael Santos wrote: > On Wed, Apr 06, 2011 at 07:26:00PM +0400, Dmitry Demeshchuk wrote: >> Fixing the recipe is obvious. But maybe the problem can be solved in a >> more proper way, like using some undocumented env variable, or >> something? >> >> Actually, the fact that Erlang doesn't understand $MANPATH seems odd >> to me. Also, there are no proper manuals locations at the >> documentation, so the user will have to find them out himself. > > erl reads the man pages like this: > > ? ?erts_snprintf(tmpStr, sizeof(tmpStr), "%s/man", rootdir); > ? ?set_env("MANPATH", tmpStr); > ? ?execvp("man", argv+i); > > So it uses the location of the erlang install (e.g., > /usr/local/lib/erlang), appends the "man" directory then overwrites > whatever is in your MANPATH environment variable. > > The MANPATH variable still works: > > $ man inets > No manual entry for inets > $ export MANPATH=/usr/local/lib/erlang/man > $ man inets > inets(3) ... > > >> On Wed, Apr 6, 2011 at 7:03 PM, Jack Moffitt wrote: >> >> The question is: is there the more right way to point Erlang to the >> >> right manuals directory? >> > >> > The more right way would be to fix the brew recipe. >> > >> > Thanks for finding that workaround though; I was having the same >> > problem but was too lazy to fix it. >> > >> > jack. >> > >> >> >> >> -- >> Best regards, >> Dmitry Demeshchuk >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions > -- Best regards, Dmitry Demeshchuk From comptekki@REDACTED Thu Apr 7 05:39:33 2011 From: comptekki@REDACTED (Wes James) Date: Wed, 6 Apr 2011 21:39:33 -0600 Subject: [erlang-questions] Re: How to remove \ from string In-Reply-To: References: <193767626.69341302106061359.JavaMail.root@zimbra> Message-ID: On Wed, Apr 6, 2011 at 2:07 PM, Muhammad Yousaf wrote: one more way: > Code is as fellow > do_echo(Socket) -> > ?? ?case gen_tcp:recv(Socket, 0) of > ?? ? ? ?{ok, Data} -> % ?? ? ? ? ? ?D = binary_to_list(Data), <> = Data, ?? ? ? ? ? ?case D of ?? ? ? ? ? ? ? ?<<"{get">> -> io:format("im innnnnnn~n");%gen_tcp:send(Socket,erl_api:search()); > ?? ? ? ? ? ? ? ?_Else -> io:format("im in none ~n") > ?? ? ? ? ? ?end, > ?? ? ? ? ? ?io:format("recieve Data from socket:~p~n",[D]), > ?? ? ? ? ? ?do_echo(Socket); > ?? ? ? ?{error, closed} -> > ?? ? ? ? ? ?ok > ?? ?end. < = Data means get 4 bytes of Data and put in D (each character is a byte, so grab first four and try a match in "case of" statement) -wes From comptekki@REDACTED Thu Apr 7 06:58:12 2011 From: comptekki@REDACTED (Wes James) Date: Wed, 6 Apr 2011 22:58:12 -0600 Subject: [erlang-questions] tuple looking string/list to tuple Message-ID: I'm not sure why Muhammad's (from previous email) is using gen_tcp:recv(Socket, 0) to receive what looks like a tuple instead of just sending a message with the tuple, (maybe that is they way it is). Here is how I changed the Data in to a tuple of atoms or strings/lists: Z is what Data looks like from his gen_tcp:recv 1> Z= <<"{get,\"user\",\"wilson\",\"lname\"}">>. <<"{get,\"user\",\"wilson\",\"lname\"}">> 2> Y=binary_to_list(Z). "{get,\"user\",\"wilson\",\"lname\"}" 3> X=[X || X <- Y, X =/= $\", X=/=${, X=/=$}]. "get,user,wilson,lname" 4> W=string:tokens(X, ","). ["get","user","wilson","lname"] 5> V=list_to_tuple(W). {"get","user","wilson","lname"} 6> 6> f(X). ok 7> X=[list_to_atom(X) || X <- W]. [get,user,wilson,lname] 8> 8> f(V). ok one liner for binary to tuple of strings 9> V=list_to_tuple(string:tokens([X || X <- Y, X =/= $\", X=/=${, X=/=$}], ",")). {"get","user","wilson","lname"} 10> 10> f(V). ok one liner for binary to tuple of atoms 11> V=list_to_tuple([list_to_atom(T) || T <- string:tokens([X || X <- Y, X =/= $\", X=/=${, X=/=$}], ",")]). {get,user,wilson,lname} I'd did all this because I wondered what it would take to get a string/list (or binary in this case) that looked like a tuple in to a tuple. -wes From alexey.v.romanov@REDACTED Thu Apr 7 07:54:33 2011 From: alexey.v.romanov@REDACTED (Alexey Romanov) Date: Thu, 7 Apr 2011 09:54:33 +0400 Subject: [erlang-questions] Reasons not to enable kernel poll Message-ID: >From reading, e.g. http://developer.sipphone.com/ejabberd/erlang_epoll_patch/, it seems supposed to be a performance improvement which only some applications can benefit from, but with no downsides. Presumably it's now considered stable (after inclusion into OTP and 3 major versions). Rebar enables it by default (see https://github.com/basho/rebar/blob/master/priv/templates/simplenode.vm.args). But why is it required to enable it and "+K true" isn't the default? Are there circumstances when it's a bad idea to enable it? Yours, Alexey Romanov From erlang@REDACTED Thu Apr 7 08:04:43 2011 From: erlang@REDACTED (Joe Armstrong) Date: Thu, 7 Apr 2011 08:04:43 +0200 Subject: [erlang-questions] Re: How to remove \ from string In-Reply-To: References: <193767626.69341302106061359.JavaMail.root@zimbra> Message-ID: On Wed, Apr 6, 2011 at 11:50 PM, Wes James wrote: > On Wed, Apr 6, 2011 at 2:07 PM, Muhammad Yousaf > wrote: > > > > Thank you i got your point but what i am trying to do is , remote > computer > > is sending me a data via socket like {get,"user","wilson","lname"} > > but for some reason i cannot match it in case statement my output is > > Is the remote computer also running erlang? If so there is a much simpler way of doing things /Joe > > > > > > Code is as fellow > > do_echo(Socket) -> > > case gen_tcp:recv(Socket, 0) of > > {ok, Data} -> > > D = binary_to_list(Data), > > case D of > > {get,_,_,_} -> io:format("im > > innnnnnn~n");%gen_tcp:send(Socket,erl_api:search()); > > _Else -> io:format("im in none ~n") > > end, > > io:format("recieve Data from socket:~p~n",[D]), > > do_echo(Socket); > > {error, closed} -> > > ok > > end. > > Another option. Skip the binary_to_list and do pattern matching like this: > > ... > > <<"{","g","e","t",_/binary>> -> io:format("im > innnnnnn~n");%gen_tcp:send(Socket,erl_api:search()); > > ... > > -wes > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From alex.arnon@REDACTED Thu Apr 7 09:39:43 2011 From: alex.arnon@REDACTED (Alex Arnon) Date: Thu, 7 Apr 2011 10:39:43 +0300 Subject: [erlang-questions] QR Code generation library. Message-ID: Hi All, Does any of you know of a QR Code generation library for Erlang? If not, can you recommend a fast one that I could plonk on a port? Another alternative would be to write one myself - in that case, is there a reference implementation I could test against? Regards, Alex. -------------- next part -------------- An HTML attachment was scrubbed... URL: From sverker@REDACTED Thu Apr 7 10:53:09 2011 From: sverker@REDACTED (Sverker Eriksson) Date: Thu, 7 Apr 2011 10:53:09 +0200 Subject: [erlang-questions] Re: Processing huge binaries in NIFs In-Reply-To: References: Message-ID: <4D9D7B75.8010906@erix.ericsson.se> Konstantin Sorokin wrote: > Hello! > > I want to process huge binaries in NIFs and in order not to screw up VM's > scheduler I want to move time consuming jobs into a separate thread. Do I > really need to make an internal copy of the binary before passing it to a > thread for processing or it'll be OK just to set pointers to raw data in a > task structure and then submit that task to the worker thread ? > You don't have to copy the binary. Solution 1. Use enif_alloc_env() and enif_make_copy() to create a process independent binary term that you then can pass to your worker thread. enif_make_copy() will not copy the data if the binary is big, but rather increase a reference counter. Then use enif_free_env() to release your logical copy of the binary. Solution 2. Implement enif_keep_binary() which is on the ToDo list for the NIF API. enif_keep_binary() would just increase the reference counter of the ErlNifBinary without the hassle of having to create environment and Erlang term. /Sverker, Erlang/OTP From czinkos@REDACTED Thu Apr 7 13:47:42 2011 From: czinkos@REDACTED (Zsolt Czinkos) Date: Thu, 7 Apr 2011 13:47:42 +0200 Subject: [erlang-questions] extract and parsing megaco message from pcap file Message-ID: Hello Anyone has ever done something similar to this? I'd like to process pcap files containing megaco messages (among others). I'd like to filter and extract and parse megaco messages from this file and produce some human readable format. Best, Zsolt From freza@REDACTED Thu Apr 7 13:55:53 2011 From: freza@REDACTED (Jachym Holecek) Date: Thu, 7 Apr 2011 12:55:53 +0100 Subject: [erlang-questions] Re: extract and parsing megaco message from pcap file In-Reply-To: References: Message-ID: <20110407115553.GA557@hanele> Hello, # Zsolt Czinkos 2011-04-07: > Anyone has ever done something similar to this? > > I'd like to process pcap files containing megaco messages (among > others). I'd like to filter and extract and parse megaco messages from > this file and produce some human readable format. Wireshark is an excellent tool for general packet dissection and seems to support megaco: http://wiki.wireshark.org/H248/MEGACO Don't know if it can dump text representation on you, never had the need to do so... HTH, -- Jachym From hm@REDACTED Thu Apr 7 14:12:08 2011 From: hm@REDACTED (=?ISO-8859-1?Q?H=E5kan_Mattsson?=) Date: Thu, 7 Apr 2011 14:12:08 +0200 Subject: [erlang-questions] Re: extract and parsing megaco message from pcap file In-Reply-To: References: Message-ID: On Thu, Apr 7, 2011 at 1:47 PM, Zsolt Czinkos wrote: > Hello > > Anyone has ever done something similar to this? > > I'd like to process pcap files containing megaco messages (among > others). I'd like to filter and extract and parse megaco messages from > this file and produce some human readable format. The 'megaco' app in Erlang/OTP provides both parsing and pretty printing of Megaco messages. It can even convert messages in ASN.1 format to text format and vice versa. Together with the 'et' app and its 'megaco_filter' plugin, it can also filter Megaco messages and display different views of them. On the first Megaco/H.248 interop event, people found it so useful that they wanted to buy our open source debug tool. :-) One piece that is missing though is reading of messages from a file, so that functionality needs to be added. This should however be easy to do as you have all building blocks (scanner, parser, pretty printer, filtering mechanism etc.) /H?kan From matthias@REDACTED Thu Apr 7 14:49:33 2011 From: matthias@REDACTED (Matthias Lang) Date: Thu, 7 Apr 2011 14:49:33 +0200 Subject: [erlang-questions] Re: how do I get escript to emit all output before exiting? In-Reply-To: <12524.1301937879@snookles.snookles.com> References: <20110404162152.GA12787@corelatus.se> <12524.1301937879@snookles.snookles.com> Message-ID: <20110407124933.GC4273@corelatus.se> On Monday, April 04, Scott Lystig Fritchie wrote: > IIRC the stuff scribbled to the console via io:format() is actually done > by sending messages to the group leader process. You're at the > scheduler's whim to decide whether the group leader gets executed & > processes the I/O requests before the VM halts. > Having said that, I've been bitten by this same concurrency feature. > C/Ruby/Python folks don't expect the feature. Even never-touched- > another-language Erlang hackers may not expect it. ... > io:format() is **not** a thin wrapper around the syscall/stdlib calls: I'm still not sure whether there's something I'm missing. Currently, I can't see how to implement, say, 'cat' in Erlang (and Escript). I know no way to make sure that all output gets emitted. I know some ways which don't work: - calling halt() loses output more often than not - calling init:stop() loses output, but not as often (my idea) - calling init:stop(), receive after infinity -> ok end, also loses output, but even less often (H?kan's idea) - timer:sleep(500), pretty much always works, but no guarantee, obviously There are some kludges that can make it work, e.g. doing IO via TCP and using netcat to display it, or writing to a file in /tmp and wrapping the escript invocation in a shell script which 'cat's the temporary file. There are some ambitious ideas to make it work, such as modifying 'init' to treat group-leaders specially. (Mike suggested it, Scott pointed out that it trickier than it seems at first.) I had a less ambitious idea: give a process a way to wait, with an optional timeout, until its output has been flushed, i.e. an io:flush(Timeout) function. I think that lets me write 'cat' and also behaves sensibly at least for non-distributed erlang. (Do it by adding 'flush' message to the IO protocol, say {flush, pid(), ref()}. The 'receive' loop in user (or is it the one in user_drv? I can't remember) replies, so then we know that no requests are still in the message queue. Is that sufficient? Can the emulator shut down cleanly with data still buffered in a port? I haven't investigated.) Comments? Robert must have something to add here. Matthias From anders.nygren@REDACTED Thu Apr 7 14:56:18 2011 From: anders.nygren@REDACTED (Anders Nygren) Date: Thu, 7 Apr 2011 07:56:18 -0500 Subject: [erlang-questions] Re: extract and parsing megaco message from pcap file In-Reply-To: References: Message-ID: Hi There are two erlang projects on github that works with pcap. Michael Santos' epcap https://github.com/msantos/epcap and my pran https://github.com/nygge/pran neither currently support megaco but at least pran is made to make it easy to add new protocols. Pran reads pcap files and decodes the records. Currently it handles ethernet, IP, TCP, UDP, SIP, SDP, MTP2, MTP3, SCCP, TCAP, MAP It has a VERY simple filter function that allows for quick search in pcap files. Wireshark is normally an excellent tool but searching is very slow. One reason I started pran was that we had a lot of pcap files, 10 MB only covered 10 minutes, we needed to search. With wireshark it took > 30 s to open a file and >30s to filter. (I don't remember the exact times but it was somewhere 30-60 s for each step) With pran if takes much less than 1 s. So take a look and let me know if You need any help. /Anders On Thu, Apr 7, 2011 at 6:47 AM, Zsolt Czinkos wrote: > Hello > > Anyone has ever done something similar to this? > > I'd like to process pcap files containing megaco messages (among > others). I'd like to filter and extract and parse megaco messages from > this file and produce some human readable format. > > > Best, > > Zsolt > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > From michael.santos@REDACTED Thu Apr 7 14:58:51 2011 From: michael.santos@REDACTED (Michael Santos) Date: Thu, 7 Apr 2011 08:58:51 -0400 Subject: [erlang-questions] Re: extract and parsing megaco message from pcap file In-Reply-To: References: Message-ID: <20110407125851.GB28752@ecn.lan> On Thu, Apr 07, 2011 at 01:47:42PM +0200, Zsolt Czinkos wrote: > Hello > > Anyone has ever done something similar to this? > > I'd like to process pcap files containing megaco messages (among > others). I'd like to filter and extract and parse megaco messages from > this file and produce some human readable format. For reading the pcap files, you could use epcap (which uses libpcap) or Anders Nygren's pran (which reads the pcap file using Erlang): https://github.com/msantos/epcap https://github.com/nygge/pran For fun, I've used epcap to dump HTTP responses, doing the parsing with httpc (httpc is awesome!): https://github.com/msantos/perv You might be able to do something similar and pass off the data to the Erlang megaco module but I don't know anything about megaco. From antoine.koener@REDACTED Thu Apr 7 15:01:42 2011 From: antoine.koener@REDACTED (Antoine Koener) Date: Thu, 7 Apr 2011 15:01:42 +0200 Subject: [erlang-questions] Re: QR Code generation library. In-Reply-To: References: Message-ID: On Apr 7, 2011, at 09:39 , Alex Arnon wrote: > Hi All, > > Does any of you know of a QR Code generation library for Erlang? > If not, can you recommend a fast one that I could plonk on a port? I've written some thing using Ghostscript to display DataMatrix code, the idea was to feed gs with some part of the data matrix and let him do the png image. (using a port) But today you may use : http://www.terryburton.co.uk/barcodewriter/ which is able to do every barcode you need, and more ! Also look at this page which a wrote a long time ago about using ghostscript: http://easyerl.blogspot.com/search/label/ghostscript which will help you in using Ghostscript as a port... > Another alternative would be to write one myself - in that case, is > there a reference implementation I could test against? > > Regards, > Alex. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From wiener.guy@REDACTED Thu Apr 7 15:38:16 2011 From: wiener.guy@REDACTED (Guy Wiener) Date: Thu, 7 Apr 2011 16:38:16 +0300 Subject: [erlang-questions] How to get Erlang/OTP with WX running on Linux 64bit? Message-ID: Hi all, I recall running into some trouble with that, so I'll ask if anyone had a successful experience: I need to get Erlang with the WX graphical toolkit installed on a Linux (Ubuntu) machine, 64 bit. What is the best way to do so? If I recall correctly, the standard Ubuntu package is R13 and does not come with WX. I don't mind building from source, but I remember having some troubles with WX crashing last time I tried. Has anyone tried this successfully? Guy. -------------- next part -------------- An HTML attachment was scrubbed... URL: From lukas.larsson@REDACTED Thu Apr 7 15:48:50 2011 From: lukas.larsson@REDACTED (Lukas Larsson) Date: Thu, 7 Apr 2011 13:48:50 +0000 (GMT) Subject: [erlang-questions] Re: How to get Erlang/OTP with WX running on Linux 64bit? In-Reply-To: <191165978.72781302184010866.JavaMail.root@zimbra> Message-ID: <1166144748.72851302184130398.JavaMail.root@zimbra> Hi, I've built the vm from the sources on github multiple times and from http://www.erlang.org/download.html with WX and I've not had any problems with it yet. Lukas ----- Original Message ----- From: "Guy Wiener" To: "Erlang Questions" Sent: Thursday, 7 April, 2011 15:38:16 GMT +01:00 Amsterdam / Berlin / Bern / Rome / Stockholm / Vienna Subject: [erlang-questions] How to get Erlang/OTP with WX running on Linux 64bit? Hi all, I recall running into some trouble with that, so I'll ask if anyone had a successful experience: I need to get Erlang with the WX graphical toolkit installed on a Linux (Ubuntu) machine, 64 bit. What is the best way to do so? If I recall correctly, the standard Ubuntu package is R13 and does not come with WX. I don't mind building from source, but I remember having some troubles with WX crashing last time I tried. Has anyone tried this successfully? Guy. _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://erlang.org/mailman/listinfo/erlang-questions From corticalcomputer@REDACTED Thu Apr 7 15:55:56 2011 From: corticalcomputer@REDACTED (G.S.) Date: Thu, 7 Apr 2011 06:55:56 -0700 Subject: [erlang-questions] Re: How to get Erlang/OTP with WX running on Linux 64bit? In-Reply-To: <1166144748.72851302184130398.JavaMail.root@zimbra> References: <191165978.72781302184010866.JavaMail.root@zimbra> <1166144748.72851302184130398.JavaMail.root@zimbra> Message-ID: Hello Guy, You will need to apt-get or yum the following packages for wx: freeglut3-dev libwxgtk2.8-dev wx2.8-headers wx-common The versions might have changed. Regards, -Gene On Thu, Apr 7, 2011 at 6:48 AM, Lukas Larsson < lukas.larsson@REDACTED> wrote: > Hi, > > I've built the vm from the sources on github multiple times and from > http://www.erlang.org/download.html with WX and I've not had any problems > with it yet. > > Lukas > > ----- Original Message ----- > From: "Guy Wiener" > To: "Erlang Questions" > Sent: Thursday, 7 April, 2011 15:38:16 GMT +01:00 Amsterdam / Berlin / Bern > / Rome / Stockholm / Vienna > Subject: [erlang-questions] How to get Erlang/OTP with WX running on Linux > 64bit? > > > > Hi all, > I recall running into some trouble with that, so I'll ask if anyone had a > successful experience: I need to get Erlang with the WX graphical toolkit > installed on a Linux (Ubuntu) machine, 64 bit. What is the best way to do > so? If I recall correctly, the standard Ubuntu package is R13 and does not > come with WX. I don't mind building from source, but I remember having some > troubles with WX crashing last time I tried. Has anyone tried this > successfully? > > > Guy. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mojitotech@REDACTED Thu Apr 7 16:09:25 2011 From: mojitotech@REDACTED (Mojito Sorbet) Date: Thu, 07 Apr 2011 10:09:25 -0400 Subject: [erlang-questions] Re: How to get Erlang/OTP with WX running on Linux 64bit? In-Reply-To: References: Message-ID: <4D9DC595.1040708@gmail.com> I have not done it with 64-bit, but I did get Erlang with WX working on Ubuntu. You do need to compile OTP to get it, but that part is simple. The hard part is chasing down all the prerequisites. Check the output of ./configure to make sure that WX will work - there are messages at the end if any package will not be used. On 4/7/2011 9:38 AM, Guy Wiener wrote: > Hi all, > I recall running into some trouble with that, so I'll ask if anyone had > a successful experience: I need to get Erlang with the WX graphical > toolkit installed on a Linux (Ubuntu) machine, 64 bit. What is the best > way to do so? If I recall correctly, the standard Ubuntu package is R13 > and does not come with WX. I don't mind building from source, but I > remember having some troubles with WX crashing last time I tried. Has > anyone tried this successfully? > > Guy. From stefan.hudelmaier@REDACTED Thu Apr 7 16:09:28 2011 From: stefan.hudelmaier@REDACTED (Stefan Hudelmaier) Date: Thu, 07 Apr 2011 16:09:28 +0200 Subject: [erlang-questions] Floating point conversion problem on big endian architecture Message-ID: <4D9DC598.5020204@device-insight.com> Hi, we're cross compiling Erlang/OTP on a x86 PC for ARM. On the resulting runtime on ARM we have the following strange problem: Converting float to binary seems to work fine, exactly as on x86: > B = <<3.2:32/big-float>>. > io:format("~w~n", [B]). <<64,76,204,205>> But converting back to float from this binary, yields the wrong result on ARM: > <> = B. > R. -428443648.0 While on x86, it works as expected: > <> = B. > R. 3.200000047683716 When compiling for ARM, we have set erl_xcomp_bigendian=yes. hipe is disabled. We have tried R14A and R14B02. Please let me know, if there is any more information we need to provide. Kind regards, Stefan -- Device Insight GmbH Stefan Hudelmaier, Dipl. Inf. Willy-Brandt-Platz 3 D-81829 M?nchen Tel.: 089 45 45 448 - 34 Email: stefan.hudelmaier@REDACTED http://www.device-insight.com From dmercer@REDACTED Thu Apr 7 16:42:45 2011 From: dmercer@REDACTED (David Mercer) Date: Thu, 7 Apr 2011 09:42:45 -0500 Subject: [erlang-questions] Re: How to remove \ from string In-Reply-To: References: , <193767626.69341302106061359.JavaMail.root@zimbra>, , , Message-ID: <000a01cbf532$10084b20$3018e160$@com> Input: You have a binary with the text of an Erlang term in it: Data = <<"{get,\"user\",\"wilson\",\"lname\"}">>. Output: The Erlang term represented by the binary: D = binary_to_list(Data), {ok, Tokens, _} = erl_scan:string(D ++ "."), {ok, Term} = erl_parse:parse_term(Tokens), Term. From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Muhammad Yousaf Sent: Wednesday, April 06, 2011 3:07 PM To: comptekki@REDACTED; erlang-questions@REDACTED Subject: [erlang-questions] Re: How to remove \ from string Thank you i got your point but what i am trying to do is , remote computer is sending me a data via socket like {get,"user","wilson","lname"} but for some reason i cannot match it in case statement my output is im in none recieve Data from socket:[255,251,31,255,251,32,255,251,24,255,251,39,255,253, 1,255,251,3,255,253,3] im in none recieve Data from socket:"{get,\"user\",\"wilson\",\"lname\"}" im in none recieve Data from socket:"\r\n" Code is as fellow do_echo(Socket) -> case gen_tcp:recv(Socket, 0) of {ok, Data} -> D = binary_to_list(Data), case D of {get,_,_,_} -> io:format("im innnnnnn~n");%gen_tcp:send(Socket,erl_api:search()); _Else -> io:format("im in none ~n") end, io:format("recieve Data from socket:~p~n",[D]), do_echo(Socket); {error, closed} -> ok end. Any idea what i am doing wrong ?? Regards, Muhammad Yousaf > Date: Wed, 6 Apr 2011 12:44:29 -0600 > Subject: Re: [erlang-questions] Re: How to remove \ from string > From: comptekki@REDACTED > To: muhammad.yousaf@REDACTED > CC: erlang-questions@REDACTED > > On Wed, Apr 6, 2011 at 11:36 AM, Muhammad Yousaf > wrote: > > > > Thanks a lot but i only want to remove backslash not double quotes > > for example > > Val = <<"{get,\"user\",\"wilson\",\"lname\"}">> , > > i need Val= <<"{get,"user","wilson","lname"}">> > > what i am doing with your help > > > > re:replace(Val,["\\"],"",[global, {return,list}]). getting error > > > > [X||X<-"{get,\"user\",\"wilson\",\"lname\"}",X=/=$\\]. > > > > > > > Another way to see what is going on is do this: > > Y=binary_to_list(<<"{get,\"user\",\"wilson\",\"lname\"}">>). > [io_lib:format("~c~w",[X, X])||X <- Y]. > > You'll see \" in the output, but the ascii numeric value for that > character is 34. > > Then if you go and look and see what 34 is on the ascii table below, > you'll see it is ". > > http://www.asciitable.com/ > > -wes -------------- next part -------------- An HTML attachment was scrubbed... URL: From mikpe@REDACTED Thu Apr 7 18:31:58 2011 From: mikpe@REDACTED (Mikael Pettersson) Date: Thu, 7 Apr 2011 18:31:58 +0200 Subject: [erlang-questions] Re: Floating point conversion problem on big endian architecture In-Reply-To: <4D9DC598.5020204@device-insight.com> References: <4D9DC598.5020204@device-insight.com> Message-ID: <19869.59134.990041.931123@pilspetsen.it.uu.se> Stefan Hudelmaier writes: > Hi, > > we're cross compiling Erlang/OTP on a x86 PC for ARM. On the resulting > runtime on ARM we have the following strange problem: Converting float > to binary seems to work fine, exactly as on x86: > > > B = <<3.2:32/big-float>>. > > io:format("~w~n", [B]). > <<64,76,204,205>> > > But converting back to float from this binary, yields the wrong result > on ARM: > > > <> = B. > > R. > -428443648.0 > > While on x86, it works as expected: > > > <> = B. > > R. > 3.200000047683716 > > When compiling for ARM, we have set erl_xcomp_bigendian=yes. hipe is > disabled. We have tried R14A and R14B02. > > Please let me know, if there is any more information we need to provide. What's the target platform? OABI or EABI? v5? v7? Thumb? Linux? gcc version? Hard or soft FP? Floating-point on OABI with its default FPA format is horribly broken by design and won't work (I've forgotten if it's big or little endian that breaks). Don't go there. EABI should work. From comptekki@REDACTED Thu Apr 7 18:32:26 2011 From: comptekki@REDACTED (Wes James) Date: Thu, 7 Apr 2011 10:32:26 -0600 Subject: [erlang-questions] secunia advisory for erlang R9B - R14B01 Message-ID: I get weekly advisories from secunia.com and for the first time noticed erlang was in there. http://secunia.com/advisories/43898/ upgrading to R14B02 fixes the problem (if it even affects you). -wes From ulf.wiger@REDACTED Thu Apr 7 19:24:21 2011 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Thu, 7 Apr 2011 19:24:21 +0200 Subject: [erlang-questions] Re: how do I get escript to emit all output before exiting? In-Reply-To: <20110407124933.GC4273@corelatus.se> References: <20110404162152.GA12787@corelatus.se> <12524.1301937879@snookles.snookles.com> <20110407124933.GC4273@corelatus.se> Message-ID: <4A7AAB32-1DBE-4435-BC9B-C674891F8EB4@erlang-solutions.com> On 7 Apr 2011, at 14:49, Matthias Lang wrote: > - calling init:stop(), receive after infinity -> ok end, also loses > output, but even less often (H?kan's idea) Init:stop() will in fact attempt an orderly shutdown first. Once all applications have been properly stopped, init will proceed to find all remaining processes and call exit(P, kill). This means your receive after infinity will only last you until that kill arrives. This should mean that if you are in an application tree, you will be given the chance to complete (e.g. delaying the shutdown by trapping exits), However, if you are outside the application tree, you are given no such quarter. Now, in an escript, the group_leader is the user server, which is a process in 'kernel', which actually does trap exits. This means that the problem isn't that init kills the group leader before it's finished, and the io:fwrite/2 request returns only after the group leader has pushed the output to the port. Rather, I suspect that the group leader pushes the output to the io driver and then happily terminates, in fact - looking at the code - since the user_drv port dies*. What I suspect is actually happening is that your output is in the port buffer, which isn't explicitly flushed during halt or shutdown. With a sufficient timer:sleep(), it will be, but no other amount of trickery will suffice. BR, Ulf * The code is quite intricate, so I may have missed something. Ulf Wiger, CTO, Erlang Solutions, Ltd. http://erlang-solutions.com From moxford@REDACTED Thu Apr 7 19:57:34 2011 From: moxford@REDACTED (Mike Oxford) Date: Thu, 7 Apr 2011 10:57:34 -0700 Subject: [erlang-questions] Re: QR Code generation library. In-Reply-To: References: Message-ID: +1 on barcodewriter. I used MySQL/PHP to generate postscript+barcodewriter to generate the barcodes for a resale site. Works beautifully, and learning to program in postscript was a fun exercise. -mox On Thu, Apr 7, 2011 at 6:01 AM, Antoine Koener wrote: > > On Apr 7, 2011, at 09:39 , Alex Arnon wrote: > > Hi All, >> >> Does any of you know of a QR Code generation library for Erlang? >> If not, can you recommend a fast one that I could plonk on a port? >> > > I've written some thing using Ghostscript to display DataMatrix code, the > idea was to feed gs with some > part of the data matrix and let him do the png image. (using a port) > > But today you may use : > http://www.terryburton.co.uk/barcodewriter/ > > which is able to do every barcode you need, and more ! > > Also look at this page which a wrote a long time ago about using > ghostscript: > http://easyerl.blogspot.com/search/label/ghostscript > which will help you in using Ghostscript as a port... > > > Another alternative would be to write one myself - in that case, is there >> a reference implementation I could test against? >> >> Regards, >> Alex. >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From muhammad.yousaf@REDACTED Thu Apr 7 21:07:18 2011 From: muhammad.yousaf@REDACTED (Muhammad Yousaf) Date: Fri, 8 Apr 2011 00:07:18 +0500 Subject: [erlang-questions] Re: How to remove \ from string In-Reply-To: <000a01cbf532$10084b20$3018e160$@com> References: , <193767626.69341302106061359.JavaMail.root@zimbra>, , , , <000a01cbf532$10084b20$3018e160$@com> Message-ID: Thanks a lot it solves my problem. Thanks a lot Regards, Muhammad Yousaf From: dmercer@REDACTED To: muhammad.yousaf@REDACTED; comptekki@REDACTED; erlang-questions@REDACTED Subject: RE: [erlang-questions] Re: How to remove \ from string Date: Thu, 7 Apr 2011 09:42:45 -0500 Input: You have a binary with the text of an Erlang term in it: Data = <<"{get,\"user\",\"wilson\",\"lname\"}">>. Output: The Erlang term represented by the binary: D = binary_to_list(Data),{ok, Tokens, _} = erl_scan:string(D ++ "."),{ok, Term} = erl_parse:parse_term(Tokens),Term. From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Muhammad Yousaf Sent: Wednesday, April 06, 2011 3:07 PM To: comptekki@REDACTED; erlang-questions@REDACTED Subject: [erlang-questions] Re: How to remove \ from string Thank you i got your point but what i am trying to do is , remote computer is sending me a data via socket like {get,"user","wilson","lname"}but for some reason i cannot match it in case statement my output is im in none recieve Data from socket:[255,251,31,255,251,32,255,251,24,255,251,39,255,253, 1,255,251,3,255,253,3]im in none recieve Data from socket:"{get,\"user\",\"wilson\",\"lname\"}"im in none recieve Data from socket:"\r\n" Code is as fellow do_echo(Socket) -> case gen_tcp:recv(Socket, 0) of {ok, Data} -> D = binary_to_list(Data), case D of {get,_,_,_} -> io:format("im innnnnnn~n");%gen_tcp:send(Socket,erl_api:search()); _Else -> io:format("im in none ~n") end, io:format("recieve Data from socket:~p~n",[D]), do_echo(Socket); {error, closed} -> ok end. Any idea what i am doing wrong ?? Regards, Muhammad Yousaf > Date: Wed, 6 Apr 2011 12:44:29 -0600 > Subject: Re: [erlang-questions] Re: How to remove \ from string > From: comptekki@REDACTED > To: muhammad.yousaf@REDACTED > CC: erlang-questions@REDACTED > > On Wed, Apr 6, 2011 at 11:36 AM, Muhammad Yousaf > wrote: > > > > Thanks a lot but i only want to remove backslash not double quotes > > for example > > Val = <<"{get,\"user\",\"wilson\",\"lname\"}">> , > > i need Val= <<"{get,"user","wilson","lname"}">> > > what i am doing with your help > > > > re:replace(Val,["\\"],"",[global, {return,list}]). getting error > > > > [X||X<-"{get,\"user\",\"wilson\",\"lname\"}",X=/=$\\]. > > > > > > > Another way to see what is going on is do this: > > Y=binary_to_list(<<"{get,\"user\",\"wilson\",\"lname\"}">>). > [io_lib:format("~c~w",[X, X])||X <- Y]. > > You'll see \" in the output, but the ascii numeric value for that > character is 34. > > Then if you go and look and see what 34 is on the ascii table below, > you'll see it is ". > > http://www.asciitable.com/ > > -wes -------------- next part -------------- An HTML attachment was scrubbed... URL: From steven.charles.davis@REDACTED Fri Apr 8 02:06:26 2011 From: steven.charles.davis@REDACTED (Steve Davis) Date: Thu, 7 Apr 2011 17:06:26 -0700 (PDT) Subject: [erlang-questions] Re: QR Code generation library. In-Reply-To: References: Message-ID: <1965ca40-9792-4e4d-8a03-cf11ef47b59a@l6g2000vbn.googlegroups.com> Curious. Must be the zeitgeist. I recently finished a qrcode implementation in Erlang, to enable 2- factor authentication using the Google Authenticator mobile app on a phone. I wasn't planning to, but I guess I could be convinced to open source it on GitHub... though right now, although it's sufficient for our needs, I'm making no big claims over performance ;) I can tell you that if you decide to write an implementation yourself, google's zxing java/cpp code is a good reference. /s On Apr 7, 2:39?am, Alex Arnon wrote: > Hi All, > > Does any of you know of a QR Code generation library for Erlang? > If not, can you recommend a fast one that I could plonk on a port? > Another alternative would be to write one myself - in that case, is there a > reference implementation I could test against? > > Regards, > Alex. > > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://erlang.org/mailman/listinfo/erlang-questions From vik@REDACTED Fri Apr 8 02:17:31 2011 From: vik@REDACTED (Vik Olliver) Date: Fri, 08 Apr 2011 12:17:31 +1200 Subject: [erlang-questions] Re: QR Code generation library. In-Reply-To: <1965ca40-9792-4e4d-8a03-cf11ef47b59a@l6g2000vbn.googlegroups.com> References: <1965ca40-9792-4e4d-8a03-cf11ef47b59a@l6g2000vbn.googlegroups.com> Message-ID: <4D9E541B.4010803@catalyst.net.nz> On 08/04/11 12:06, Steve Davis wrote: > I wasn't planning to, but I guess I could be convinced to open source > it on GitHub... though right now, although it's sufficient for our > needs, I'm making no big claims over performance ;) > Sounds worth releasing to me. Vik :v) From raimo+erlang-questions@REDACTED Fri Apr 8 09:36:30 2011 From: raimo+erlang-questions@REDACTED ('Raimo Niskanen') Date: Fri, 8 Apr 2011 09:36:30 +0200 Subject: [erlang-questions] [erlang-questions 76] New Mailing list software In-Reply-To: <000601cbf52a$3b88be40$b29a3ac0$@com> References: <9688EB4F-9F34-4486-9E3B-FE60A47B99B1@gmail.com> <4D8D0A5E.3000208@telegraphics.com.au> <20110328073551.GB13069@erix.ericsson.se> <001201cbed53$1e0bcf30$5a236d90$@com> <000601cbf52a$3b88be40$b29a3ac0$@com> Message-ID: <20110408073630.GA13852@erix.ericsson.se> On Thu, Apr 07, 2011 at 08:46:42AM -0500, David Mercer wrote: > Hi, Raimo. The new software appears to mess with reply subjects. Usually > when you reply, the subject is changed from "" to "Re: " > unless the subject already begins with "Re:". This means replies to > erlang-questions would have the form "Re: [erlang-questions] ", and > this is how it worked prior to the changeover. However, the new software > appears to move the "Re:" to between the "[erlang-questions]" and the > subject, resulting in a subject line of "[erlang-questions] Re: ". > I'm not sure about other email clients, but Outlook 2007 will not, > therefore, thread the replies with the original; all replies will be > threaded correctly, but the original will stand alone in its own > conversation. Any chance we could have the functionality modified to retain > the original format? Yes. Done. I hope, will have to check if it is cached somewhere... That was a knob that came with the [erlang-questions %d] behaviour I tried to use. Now it should be back to old and normal again. > > Thank-you for your attention. > > Cheers, > > David > > > -----Original Message----- > > From: David Mercer [mailto:dmercer@REDACTED] > > Sent: Monday, March 28, 2011 9:19 AM > > To: 'Raimo Niskanen' > > Subject: RE: [erlang-questions 76] Re: New Mailing list software > > > > Yes, please. The numbering has caused Outlook to no longer be able to > > thread conversations. Thank-you! > > > > Cheers, > > > > DBM > > > > > -----Original Message----- > > > From: erlang-questions-bounces@REDACTED [mailto:erlang-questions- > > > bounces@REDACTED] On Behalf Of Raimo Niskanen > > > Sent: Monday, March 28, 2011 2:36 AM > > > To: erlang-questions@REDACTED > > > Subject: [erlang-questions 76] Re: New Mailing list software > > > > > > On Fri, Mar 25, 2011 at 02:44:54PM -0700, Simon Thompson wrote: > > > > Something peculiar happening with header padding for me: getting > > ints > > > in headers so my automated filing is not spotting them ... (this > > filing > > > done before hitting client) > > > > > > Yes. It is auto numbering of posts. I thought it would be something > > to > > > facilitate threading in the clients, but seems to cause confusion. > > > I think I will shut it off. > > > > > > > > > > > Simon > > > > > > > > Sent from my iPhone > > > > > > > > On 25 Mar 2011, at 14:34, Toby Thain > > > wrote: > > > > > > > > > On 25/03/11 5:18 PM, Koener Antoine wrote: > > > > >> Hi, > > > > >> > > > > >> Every single mail seems to be seen as Junk now in Apple Mail. > > > > >> > > > > >> Is this just me ? :) > > > > > > > > > > Yes, it's just you; that is a client side function. > > > > > > > > > > --T > > > > > > > > > > > > > > >> > > > > >> > > > > >> PS: I know that there's many other imap clients out there :-) > > > > >> _______________________________________________ > > > > >> erlang-questions mailing list > > > > >> erlang-questions@REDACTED > > > > >> http://erlang.org/mailman/listinfo/erlang-questions > > > > >> > > > > > > > > > > _______________________________________________ > > > > > erlang-questions mailing list > > > > > erlang-questions@REDACTED > > > > > http://erlang.org/mailman/listinfo/erlang-questions > > > > _______________________________________________ > > > > erlang-questions mailing list > > > > erlang-questions@REDACTED > > > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > > -- > > > > > > / Raimo Niskanen, Erlang/OTP, Ericsson AB > > > _______________________________________________ > > > erlang-questions mailing list > > > erlang-questions@REDACTED > > > http://erlang.org/mailman/listinfo/erlang-questions > -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From czinkos@REDACTED Fri Apr 8 09:39:02 2011 From: czinkos@REDACTED (Zsolt Czinkos) Date: Fri, 8 Apr 2011 09:39:02 +0200 Subject: [erlang-questions] extract and parsing megaco message from pcap file In-Reply-To: <20110407125851.GB28752@ecn.lan> References: <20110407125851.GB28752@ecn.lan> Message-ID: Thank you guys, they look promising. czinkos On Thu, Apr 7, 2011 at 2:58 PM, Michael Santos wrote: > On Thu, Apr 07, 2011 at 01:47:42PM +0200, Zsolt Czinkos wrote: >> Hello >> >> Anyone has ever done something similar to this? >> >> I'd like to process pcap files containing megaco messages (among >> others). I'd like to filter and extract and parse megaco messages from >> this file and produce some human readable format. > > For reading the pcap files, you could use epcap (which uses libpcap) > or Anders Nygren's pran (which reads the pcap file using Erlang): > > https://github.com/msantos/epcap > https://github.com/nygge/pran > > For fun, I've used epcap to dump HTTP responses, doing the parsing with > httpc (httpc is awesome!): > > https://github.com/msantos/perv > > You might be able to do something similar and pass off the data to the > Erlang megaco module but I don't know anything about megaco. > From yaohui1984@REDACTED Fri Apr 8 12:26:59 2011 From: yaohui1984@REDACTED (=?ISO-8859-1?B?eWFvaHVp?=) Date: Fri, 8 Apr 2011 18:26:59 +0800 Subject: [erlang-questions] Problem: ll_alloc: Cannot reallocate 10830000 bytes of memory (of type "driver_event_state"). Message-ID: we want a tcp server that can accpet 500k concurrent connections, the server run on 64bit linux with 16G memory, each client send a message per 30s, the server receive message and nothing to do. but reach about 450k connections, the server crashed, Crash dump was written to: erl_crash.dump ll_alloc: Cannot reallocate 10830000 bytes of memory (of type "driver_event_state"). Aborted here is a part of erl_crash.dump =erl_crash_dump:0.1 Wed Apr 6 19:02:29 2011 Slogan: ll_alloc: Cannot reallocate 10888824 bytes of memory (of type "driver_event_state"). System version: Erlang R14B02 (erts-5.8.3) [source] [64-bit halfword] [smp:8:8] [rq:8] [async-threads:0] [kernel-poll:true] Compiled: Wed Apr 6 09:44:31 2011 Taints: Atoms: 6628 =memory total: 2056754272 processes: 749739128 processes_used: 749736512 system: 1307015144 atom: 462593 atom_used: 437166 binary: 685882200 code: 3536547 ets: 195800 =allocated_areas sys_misc: 55011874 static: 222822400 atom_space: 98328 73381 atom_table: 95961 module_table: 9084 export_table: 50316 register_table: 276 fun_table: 3266 module_refs: 2048 loaded_code: 3166041 dist_table: 523 node_table: 219 bits_bufs_size: 0 bif_timer: 80184 link_lh: 0 proc: 275970288 275969680 atom_entry: 268304 267824 export_entry: 262256 261776 module_entry: 8088 7688 reg_proc: 1664 904 monitor_sh: 1176 168 nlink_sh: 36651736 36651496 fun_entry: 37696 36328 driver_event_data_state: 48 48 db_tab: 5976 5384 driver_select_data_state: 11067400 11066992 =allocator:sys_alloc option e: true option m: libc option tt: 131072 option tp: 0 anynoe can analyze this error? thx -------------- next part -------------- An HTML attachment was scrubbed... URL: From knut.nesheim@REDACTED Fri Apr 8 15:55:58 2011 From: knut.nesheim@REDACTED (Knut Nesheim) Date: Fri, 8 Apr 2011 15:55:58 +0200 Subject: [erlang-questions] [ANN] Eredis, Erlang Redis client Message-ID: We're pleased to announce the first public release of eredis v0.1.0. - Homepage: https://github.com/wooga/eredis - Code: https://github.com/wooga/eredis.git Eredis is an open source MIT License Redis client devoped at wooga (http://wooga.com). It is a lightweight client designed to meet the following goals: * consistent performance under heavy load * performance comparable to clients written in other high-level languages * synchronous API exposed to users * asynchronous internal response processing * support for AUTH and SELECT The main reason to develop a new client was that the current clients available were showing unsatisfactory performance,when compared to clients written in other high-level languages. Please report any issues on https://github.com/wooga/eredis/issues More information can be found in the projects README, https://github.com/wooga/eredis/blob/master/README.md Thanks, Knut Nesheim & Paolo Negri -- Engineering http://www.wooga.com | fax +49-30-8964 9064 wooga GmbH | Saarbruecker Str. 38 | 10405 Berlin | Germany Sitz der Gesellschaft: Berlin; HRB 117846 B Registergericht Berlin-Charlottenburg Geschaeftsfuehrung: Jens Begemann, Philipp Moeser From sverker@REDACTED Fri Apr 8 16:11:20 2011 From: sverker@REDACTED (Sverker Eriksson) Date: Fri, 8 Apr 2011 16:11:20 +0200 Subject: [erlang-questions] Problem: ll_alloc: Cannot reallocate 10830000 bytes of memory (of type "driver_event_state"). In-Reply-To: References: Message-ID: <4D9F1788.1070308@erix.ericsson.se> This is a current shortcoming of the halfword emulator. In halfword emulator some memory must be allocated within the first 4Gb ("low" memory) and other allocations can use any memory. However, in R14B02, not all allocations that could use "high" memory does so. "driver_event_state" is an example of such memory that could make use of high memory but doesn't. I will try to fix that for R14B03. /Sverker, Erlang/OTP, Ericsson yaohui wrote: > we want a tcp server that can accpet 500k concurrent connections, the server run on 64bit linux with 16G memory, each client send a message per 30s, the server receive message and nothing to do. but reach about 450k connections, the server crashed, > Crash dump was written to: erl_crash.dump > ll_alloc: Cannot reallocate 10830000 bytes of memory (of type "driver_event_state"). > Aborted > > here is a part of erl_crash.dump > =erl_crash_dump:0.1 > Wed Apr 6 19:02:29 2011 > Slogan: ll_alloc: Cannot reallocate 10888824 bytes of memory (of type "driver_event_state"). > System version: Erlang R14B02 (erts-5.8.3) [source] [64-bit halfword] [smp:8:8] [rq:8] [async-threads:0] [kernel-poll:true] > Compiled: Wed Apr 6 09:44:31 2011 > Taints: > Atoms: 6628 > =memory > total: 2056754272 > processes: 749739128 > processes_used: 749736512 > system: 1307015144 > atom: 462593 > atom_used: 437166 > binary: 685882200 > code: 3536547 > ets: 195800 > > =allocated_areas > sys_misc: 55011874 > static: 222822400 > atom_space: 98328 73381 > atom_table: 95961 > module_table: 9084 > export_table: 50316 > register_table: 276 > fun_table: 3266 > module_refs: 2048 > loaded_code: 3166041 > dist_table: 523 > node_table: 219 > bits_bufs_size: 0 > bif_timer: 80184 > link_lh: 0 > proc: 275970288 275969680 > atom_entry: 268304 267824 > export_entry: 262256 261776 > module_entry: 8088 7688 > reg_proc: 1664 904 > monitor_sh: 1176 168 > nlink_sh: 36651736 36651496 > fun_entry: 37696 36328 > driver_event_data_state: 48 48 > db_tab: 5976 5384 > driver_select_data_state: 11067400 11066992 > =allocator:sys_alloc > option e: true > option m: libc > option tt: 131072 > option tp: 0 > > anynoe can analyze this error? > thx > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > From sysop@REDACTED Fri Apr 8 17:49:19 2011 From: sysop@REDACTED (Matt Stancliff) Date: Fri, 8 Apr 2011 08:49:19 -0700 Subject: [erlang-questions] [ANN] Eredis, Erlang Redis client In-Reply-To: References: Message-ID: Hey Knut, On Apr 8, 2011, at 6:55 AM, Knut Nesheim wrote: > The main reason to develop a new client was that the current clients > available were showing unsatisfactory performance,when compared to > clients written in other high-level languages. Did you check out my erlang redis library https://github.com/mattsta/er? er should achieve all your goals except AUTH/SELECT (because multiple DBs are going away eventually [1] and plain text AUTH gives people a false sense of security). I'll get basho_bench running on er so we can compare numbers. [1]: http://twitter.com/antirez/status/27362335330 -Matt -- Matt Stancliff San Jose, CA @mattsta iPhone: 678-591-9337 "The best way to predict the future is to invent it." --Alan Kay From alessandro.sivieri@REDACTED Fri Apr 8 17:52:03 2011 From: alessandro.sivieri@REDACTED (Alessandro Sivieri) Date: Fri, 8 Apr 2011 17:52:03 +0200 Subject: [erlang-questions] Erlang R14B02 in Ubuntu 10.10 Message-ID: I am announcing here the availability of Erlang R14B02 in my PPA [1], as someone requested me to report here some time ago. Please, read the blog post before installing any of those packages (which, I remind you, are *not* the ones from the official repositories, but a backport from Debian Unstable). [1] http://sivieri.wordpress.com/2011/04/08/erlang-r14b02-in-ppa/ -- Sivieri Alessandro alessandro.sivieri@REDACTED http://sivieri.wordpress.com/ http://www.poul.org/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From gleber.p@REDACTED Fri Apr 8 18:00:28 2011 From: gleber.p@REDACTED (Gleb Peregud) Date: Fri, 8 Apr 2011 18:00:28 +0200 Subject: [erlang-questions] Is eXAT used by anyone? Message-ID: Hello Erlangers! I'm about to choose a technology for a Multiagent Systems course at my university. Since I'm a eager user of Erlang I wanted to use eXAT. But unfortunately course teacher wants everyone to use some actively developed system. I need to provide to them some proofs that eXAT matches this requirement. I can see that last papers about eXAT were published in 2004 year. Is anyone working on this project? Or is anyone using this project? I will be glad for any pointers in this area Best regards, Gleb Peregud From robert.virding@REDACTED Fri Apr 8 19:01:16 2011 From: robert.virding@REDACTED (Robert Virding) Date: Fri, 8 Apr 2011 17:01:16 +0000 (GMT) Subject: [erlang-questions] how do I get escript to emit all output before exiting? In-Reply-To: <636899246.80021302282052535.JavaMail.root@zimbra> Message-ID: <745933376.80061302282076908.JavaMail.root@zimbra> I haven't looked at this in a long time but my first initial reaction is surprise that would have to do init:stop() at all in main(), I would have expected the escript "wrapping" to handle that cleanly for you. And ensure that all io is complete. Doing an io:format/put_chars does ensure that the characters have been sent to the io-server and been processed there. With terminal and file output they will also have been sent to the port, though depending on type of io-server this is no guarantee. If the output is still "stuck" in the driver then I don't know what happens. I would have expected them to be flushed if they have been closed "normally". Robert -- Robert Virding, Erlang Solutions Ltd. From gleber.p@REDACTED Fri Apr 8 19:34:59 2011 From: gleber.p@REDACTED (Gleb Peregud) Date: Fri, 8 Apr 2011 19:34:59 +0200 Subject: [erlang-questions] Is eXAT used by anyone? In-Reply-To: References: Message-ID: On Fri, Apr 8, 2011 at 18:00, Gleb Peregud wrote: > I'm about to choose a technology for a Multiagent Systems course at my > university. Since I'm a eager user of Erlang I wanted to use eXAT. But > unfortunately course teacher wants everyone to use some actively > developed system. I need to provide to them some proofs that eXAT > matches this requirement. We misunderstood each other with the teacher :) So after clearing up confusion, I got green light to use eXAT for the project. > I can see that last papers about eXAT were > published in 2004 year. Is anyone working on this project? Or is > anyone using this project? I will be glad for any pointers in this > area Though this question still holds. Are there any works on this system? Is it used for any project academia or commercial project? Is version of Eresye included in version 1.3 of eXAT the latest version of Eresye? Best regards, Gleb Peregud From kaiduanx@REDACTED Fri Apr 8 20:12:16 2011 From: kaiduanx@REDACTED (Kaiduan Xie) Date: Fri, 8 Apr 2011 14:12:16 -0400 Subject: [erlang-questions] Reasons not to enable kernel poll In-Reply-To: References: Message-ID: Some OS, for example, Windows, does not have kernel poll support. So it is not enabled by default. On Linux, it uses ePoll and is quite stable. It improves the performance dramatically if you have a lot of concurrent open sockets. /Kaiduan On Thu, Apr 7, 2011 at 1:54 AM, Alexey Romanov wrote: > From reading, e.g. > http://developer.sipphone.com/ejabberd/erlang_epoll_patch/, it seems > supposed to be a performance improvement which only some applications > can benefit from, but with no downsides. Presumably it's now > considered stable (after inclusion into OTP and 3 major versions). > Rebar enables it by default (see > https://github.com/basho/rebar/blob/master/priv/templates/simplenode.vm.args). > But why is it required to enable it and "+K true" isn't the default? > Are there circumstances when it's a bad idea to enable it? > > Yours, Alexey Romanov > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > From thatpythonguy@REDACTED Fri Apr 8 21:12:52 2011 From: thatpythonguy@REDACTED (Ahmed Al-Saadi) Date: Fri, 08 Apr 2011 15:12:52 -0400 Subject: [erlang-questions] Erlang manuals problem when installing from Homebrew In-Reply-To: References: Message-ID: <4D9F5E34.6030906@gmail.com> I have had a problem with missing wx-related files when I installed with Homebrew. I installed from source and all is well. I recommend that path for anyone who doesn't wanna muck around with brew. -signed(ahmed). On 4/6/11 9:44 AM, Dmitry Demeshchuk wrote: > Greetings. > > I've installed the R14B02 to a fresh machine with no previous versions > using Homebrew. Everything works good, but "erl -man" seems to be > broken. > > Hombrew is default-configured, so the structure of > /usr/local/Cellar/erlang/R14B02 is the following: > > AUTHORS README.md bin/ lib/ share/ > > So, the binary files are placed into > /usr/local/Cellar/erlang/R14B02/bin and the man pages ? into > /usr/local/Cellar/erlang/R14B02/share/man > > As far as I understand, when I call "erl -man", it tries to search at > some other location, not at the one I provided. I tried to add this > location to MANPATH, but result was the same. > > Where does Erlang search for the manuals and is there a way to > configure these locations? > From pmorreale@REDACTED Sat Apr 9 00:44:46 2011 From: pmorreale@REDACTED (Peter W. Morreale) Date: Fri, 08 Apr 2011 16:44:46 -0600 Subject: [erlang-questions] integer-string conversions. Message-ID: <1302302686.2170.140.camel@hermosa.morreale.net> I bet this has come up a lot, however I can't find anything on the web that is appropriate... (Nor am I seeing it in the erlang doc...) Need to convert an integer to a string, with a field width and precision, such that: 2 --> "02" ie: right-justified and padded with a leading zeros, depending upon field width. How do I do this? THanks, -PWM From wallentin.dahlberg@REDACTED Sat Apr 9 00:54:22 2011 From: wallentin.dahlberg@REDACTED (=?ISO-8859-1?Q?Bj=F6rn=2DEgil_Dahlberg?=) Date: Sat, 9 Apr 2011 00:54:22 +0200 Subject: [erlang-questions] integer-string conversions. In-Reply-To: <1302302686.2170.140.camel@hermosa.morreale.net> References: <1302302686.2170.140.camel@hermosa.morreale.net> Message-ID: lists:flatten(io_lib:format("~2.2.0w", [2])) -> "02". See, http://www.erlang.org/doc/man/io.html#fwrite-1 for more information. // Bj?rn-Egil 2011/4/9 Peter W. Morreale > > I bet this has come up a lot, however I can't find anything on the web > that is appropriate... (Nor am I seeing it in the erlang doc...) > > Need to convert an integer to a string, with a field width and > precision, such that: > > 2 --> "02" > > ie: right-justified and padded with a leading zeros, depending upon > field width. > > How do I do this? > > THanks, > -PWM > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mihai@REDACTED Sat Apr 9 00:55:19 2011 From: mihai@REDACTED (Mihai Balea) Date: Fri, 8 Apr 2011 18:55:19 -0400 Subject: [erlang-questions] integer-string conversions. In-Reply-To: <1302302686.2170.140.camel@hermosa.morreale.net> References: <1302302686.2170.140.camel@hermosa.morreale.net> Message-ID: On Apr 8, 2011, at 6:44 PM, Peter W. Morreale wrote: > > I bet this has come up a lot, however I can't find anything on the web > that is appropriate... (Nor am I seeing it in the erlang doc...) > > Need to convert an integer to a string, with a field width and > precision, such that: > > 2 --> "02" > > ie: right-justified and padded with a leading zeros, depending upon > field width. > > How do I do this? 2> io:format("~3..0B\n", [2]). 002 ok 3> Be careful though: 3> io:format("~3..0B\n", [2345]). *** ok 4> Hope this helps Mihai From pmorreale@REDACTED Sat Apr 9 00:58:51 2011 From: pmorreale@REDACTED (Peter W. Morreale) Date: Fri, 08 Apr 2011 16:58:51 -0600 Subject: [erlang-questions] Ignore please Re: integer-string conversions. In-Reply-To: <1302302686.2170.140.camel@hermosa.morreale.net> References: <1302302686.2170.140.camel@hermosa.morreale.net> Message-ID: <1302303531.2170.141.camel@hermosa.morreale.net> Never mind, I found it. I just needed to look a little harder... Thx -PWM On Fri, 2011-04-08 at 16:44 -0600, Peter W. Morreale wrote: > I bet this has come up a lot, however I can't find anything on the web > that is appropriate... (Nor am I seeing it in the erlang doc...) > > Need to convert an integer to a string, with a field width and > precision, such that: > > 2 --> "02" > > ie: right-justified and padded with a leading zeros, depending upon > field width. > > How do I do this? > > THanks, > -PWM > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From co7eb@REDACTED Sat Apr 9 01:10:23 2011 From: co7eb@REDACTED (=?iso-8859-1?Q?Gilberio_Carmenates_Garc=EDa?=) Date: Fri, 8 Apr 2011 19:10:23 -0400 Subject: [erlang-questions] The Music and Erlang. Message-ID: <001501cbf642$25e59b30$71b0d190$@co.cu> Hi all, I think Erlang community is a brotherhood, so, I would like to ask if any on you Erlangers like music, I mean in a professional way. I?m a music compositor, so if any of you would like to make some money selling music, please let me know. Sorry about any disturb, but I think the music has no time or place to talk about, it?s what make us happy in many ways, I bet that you all like to listen music while programming in Erlang lol. NOTE: My English is improving :) Best, Ivan Garc?a ======================================================================= Este mensaje ha sido enviado mediante el servicio de correo electr?nico que ofrece la Federaci?n de Radioaficionados de Cuba a sus miembros para respaldar el cumplimiento de los objetivos de la organizaci?n y su pol?tica informativa. La persona que env?a este correo asume el compromiso de usar el servicio a tales fines y cumplir con las regulaciones establecidas. -------------- next part -------------- An HTML attachment was scrubbed... URL: From alex.arnon@REDACTED Sat Apr 9 01:14:14 2011 From: alex.arnon@REDACTED (Alex Arnon) Date: Sat, 9 Apr 2011 02:14:14 +0300 Subject: [erlang-questions] QR Code generation library. In-Reply-To: <1965ca40-9792-4e4d-8a03-cf11ef47b59a@l6g2000vbn.googlegroups.com> References: <1965ca40-9792-4e4d-8a03-cf11ef47b59a@l6g2000vbn.googlegroups.com> Message-ID: Steve: I'd echo Vik by saying it certainly sounds like something worth open sourcing! :) I was planning on falling back on zxing as a port program. Antoine and Mike: I've read some good things on Barcodewriter. However, some flexibility in the output is required here, and if we're going for several kinds of image generation then ghostscript and PS output are extra components on the chain that we have no "use" for. In any case, thanks for pointing us to a cool solution. On Fri, Apr 8, 2011 at 3:06 AM, Steve Davis wrote: > Curious. Must be the zeitgeist. > > I recently finished a qrcode implementation in Erlang, to enable 2- > factor authentication using the Google Authenticator mobile app on a > phone. > > I wasn't planning to, but I guess I could be convinced to open source > it on GitHub... though right now, although it's sufficient for our > needs, I'm making no big claims over performance ;) > > I can tell you that if you decide to write an implementation yourself, > google's zxing java/cpp code is a good reference. > > /s > > > > On Apr 7, 2:39 am, Alex Arnon wrote: > > Hi All, > > > > Does any of you know of a QR Code generation library for Erlang? > > If not, can you recommend a fast one that I could plonk on a port? > > Another alternative would be to write one myself - in that case, is there > a > > reference implementation I could test against? > > > > Regards, > > Alex. > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questi...@REDACTED:// > erlang.org/mailman/listinfo/erlang-questions > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From freza@REDACTED Sat Apr 9 01:21:07 2011 From: freza@REDACTED (Jachym Holecek) Date: Sat, 9 Apr 2011 00:21:07 +0100 Subject: [erlang-questions] integer-string conversions. In-Reply-To: <1302302686.2170.140.camel@hermosa.morreale.net> References: <1302302686.2170.140.camel@hermosa.morreale.net> Message-ID: <20110408232107.GA3390@hanele.lan> # Peter W. Morreale 2011-04-08: > I bet this has come up a lot, however I can't find anything on the web > that is appropriate... (Nor am I seeing it in the erlang doc...) > > Need to convert an integer to a string, with a field width and > precision, such that: > > 2 --> "02" > > ie: right-justified and padded with a leading zeros, depending upon > field width. > > How do I do this? Thusly: 17> io_lib:format("~2.10.0B~n", [2]). [["0","2"]] %% Flatten me if you have to (which is very rarely). Personally, I prefer to use a utility function like this: make_two(N) when N < 10 -> %% [1] [$0 | integer_to_list(N)]; make_two(N) -> integer_to_list(N). just because resulting code is clearer than esoteric formatting syntax IMO. Similar functions are defined for other field widths that are needed, it's only a few of them really. HTH, -- Jachym [1] Yeah, that guard isn't quite exhaustive, you can make it more paranoid if you like. From bernie@REDACTED Sat Apr 9 01:52:59 2011 From: bernie@REDACTED (Bernie Duggan) Date: Sat, 9 Apr 2011 09:52:59 +1000 Subject: [erlang-questions] Reasons not to enable kernel poll In-Reply-To: References: Message-ID: It's worth noting that there are certain (relatively unusual) cases where epoll() has significantly worse performance than poll(). The particular case i'm thinking of is where you have a high number of open sockets and, each time (e)poll is called, a significant majority have data waiting on them. This is, as I said, a pretty unusual use pattern, and not something 95% of people will ever strike. But it's worth keeping in mind that the blanket statement "epoll is always faster/better" is not /always/ true. Of course, in the case I just described, it would be well worth asking whether you need poll/epoll at all, but that's beside my point. All I'm really saying is that, in the vast majority of cases enabling kernel polling will indeed improve matters, sometimes drastically, but if your application does anything even slightly interesting network-wise then it's well worth measuring rather than assuming. Cheers, B On 9 April 2011 04:12, Kaiduan Xie wrote: > Some OS, for example, Windows, does not have kernel poll support. So > it is not enabled by default. > > On Linux, it uses ePoll and is quite stable. It improves the > performance dramatically if you have a lot of concurrent open sockets. > > /Kaiduan > > On Thu, Apr 7, 2011 at 1:54 AM, Alexey Romanov > wrote: > > From reading, e.g. > > http://developer.sipphone.com/ejabberd/erlang_epoll_patch/, it seems > > supposed to be a performance improvement which only some applications > > can benefit from, but with no downsides. Presumably it's now > > considered stable (after inclusion into OTP and 3 major versions). > > Rebar enables it by default (see > > > https://github.com/basho/rebar/blob/master/priv/templates/simplenode.vm.args > ). > > But why is it required to enable it and "+K true" isn't the default? > > Are there circumstances when it's a bad idea to enable it? > > > > Yours, Alexey Romanov > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From moxford@REDACTED Sat Apr 9 02:05:23 2011 From: moxford@REDACTED (Mike Oxford) Date: Fri, 8 Apr 2011 17:05:23 -0700 Subject: [erlang-questions] Logic in the supervisor? Message-ID: I have a pool of resources, say 10k children(FSMs) each holding a resource. If I want to remove a resource from the pool, of which they may be duplicates, I have two options. 1) Walk the list of children and tell each one "hey, if this is you, close up shop." 2) Maintain a dict/ETS of all resources, which has more run-time overhead and a higher likelyhood of "something happening." If the supervisor dies, all resources are shut down as they're children, so having the supervisor maintain the dict/ETS is an option. Having another FSM outside the call-tree maintaining that status is an option but, in the case of that FSM going down then all resources are "lost" and should be released....which minics the case of a supervisor going down.. So... Do I maintain state external to the supervisor or.. Have the supervisor maintain state or... Just deal with the message-storm on resource removal? Thanks! -mox -------------- next part -------------- An HTML attachment was scrubbed... URL: From moxford@REDACTED Sat Apr 9 02:08:31 2011 From: moxford@REDACTED (Mike Oxford) Date: Fri, 8 Apr 2011 17:08:31 -0700 Subject: [erlang-questions] QR Code generation library. In-Reply-To: References: <1965ca40-9792-4e4d-8a03-cf11ef47b59a@l6g2000vbn.googlegroups.com> Message-ID: Well, ghostscript is a postscript interpreter, and postscript is just a stack-based language. I'd take a look at the Barcodewriter stuff anyways. He did a good job abstracting it out and it supports a lot of different barcodes. Basically you set up the parameter, and say "go generate it!" When it comes back to give it a cookie and a pat on the head. Even if you don't use it initially it's always nice to have options... :) Good luck! -mox On Fri, Apr 8, 2011 at 4:14 PM, Alex Arnon wrote: > Steve: I'd echo Vik by saying it certainly sounds like something worth open > sourcing! :) > > I was planning on falling back on zxing as a port program. > > Antoine and Mike: I've read some good things on Barcodewriter. However, > some flexibility in the output is required here, and if we're going for > several kinds of image generation then ghostscript and PS output are extra > components on the chain that we have no "use" for. In any case, thanks for > pointing us to a cool solution. > > > On Fri, Apr 8, 2011 at 3:06 AM, Steve Davis < > steven.charles.davis@REDACTED> wrote: > >> Curious. Must be the zeitgeist. >> >> I recently finished a qrcode implementation in Erlang, to enable 2- >> factor authentication using the Google Authenticator mobile app on a >> phone. >> >> I wasn't planning to, but I guess I could be convinced to open source >> it on GitHub... though right now, although it's sufficient for our >> needs, I'm making no big claims over performance ;) >> >> I can tell you that if you decide to write an implementation yourself, >> google's zxing java/cpp code is a good reference. >> >> /s >> >> >> >> On Apr 7, 2:39 am, Alex Arnon wrote: >> > Hi All, >> > >> > Does any of you know of a QR Code generation library for Erlang? >> > If not, can you recommend a fast one that I could plonk on a port? >> > Another alternative would be to write one myself - in that case, is >> there a >> > reference implementation I could test against? >> > >> > Regards, >> > Alex. >> > >> > _______________________________________________ >> > erlang-questions mailing list >> > erlang-questi...@REDACTED:// >> erlang.org/mailman/listinfo/erlang-questions >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From moxford@REDACTED Sat Apr 9 02:14:42 2011 From: moxford@REDACTED (Mike Oxford) Date: Fri, 8 Apr 2011 17:14:42 -0700 Subject: [erlang-questions] Reasons not to enable kernel poll In-Reply-To: References: Message-ID: Slight expansion: epoll generates events, callbacks, which say that data is waiting. poll just iterates the whole list every time If you have a lot of "quiet" sockets then epoll wins. If you have tens of thousands of very active sockets, well, you're going to be "hitting those anyways" so the overhead on poll's wasted checking of quiet sockets is mitigated by the eventing system's overhead with epoll. At some point those lines do cross. That said, most people (>95%?) should use epoll, and when in doubt, measure with each since it's trivial to toggle it on/off. -mox On Fri, Apr 8, 2011 at 4:52 PM, Bernie Duggan wrote: > It's worth noting that there are certain (relatively unusual) cases where > epoll() has significantly worse performance than poll(). The particular case > i'm thinking of is where you have a high number of open sockets and, each > time (e)poll is called, a significant majority have data waiting on them. > This is, as I said, a pretty unusual use pattern, and not something 95% of > people will ever strike. But it's worth keeping in mind that the blanket > statement "epoll is always faster/better" is not /always/ true. Of course, > in the case I just described, it would be well worth asking whether you need > poll/epoll at all, but that's beside my point. > All I'm really saying is that, in the vast majority of cases enabling > kernel polling will indeed improve matters, sometimes drastically, but if > your application does anything even slightly interesting network-wise then > it's well worth measuring rather than assuming. > > Cheers, > > B > > On 9 April 2011 04:12, Kaiduan Xie wrote: > >> Some OS, for example, Windows, does not have kernel poll support. So >> it is not enabled by default. >> >> On Linux, it uses ePoll and is quite stable. It improves the >> performance dramatically if you have a lot of concurrent open sockets. >> >> /Kaiduan >> >> On Thu, Apr 7, 2011 at 1:54 AM, Alexey Romanov >> wrote: >> > From reading, e.g. >> > http://developer.sipphone.com/ejabberd/erlang_epoll_patch/, it seems >> > supposed to be a performance improvement which only some applications >> > can benefit from, but with no downsides. Presumably it's now >> > considered stable (after inclusion into OTP and 3 major versions). >> > Rebar enables it by default (see >> > >> https://github.com/basho/rebar/blob/master/priv/templates/simplenode.vm.args >> ). >> > But why is it required to enable it and "+K true" isn't the default? >> > Are there circumstances when it's a bad idea to enable it? >> > >> > Yours, Alexey Romanov >> > _______________________________________________ >> > erlang-questions mailing list >> > erlang-questions@REDACTED >> > http://erlang.org/mailman/listinfo/erlang-questions >> > >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From comptekki@REDACTED Sat Apr 9 04:55:15 2011 From: comptekki@REDACTED (Wes James) Date: Fri, 8 Apr 2011 20:55:15 -0600 Subject: [erlang-questions] timing ++ operation Message-ID: I have this to produce some data: -module(rep). -export([s/2]). s(Str, Cnt) when (Cnt == 0) -> [Str++"0"]; s(Str, Cnt) -> [Str++integer_to_list(Cnt)|s(Str, Cnt-1)]. It is run like this: rep:s("a",10). ["a10","a9","a8","a7","a6","a5","a4","a3","a2","a1","a0"] I then run this to create a test erl file which has a 10000 long A="a1" ++ "a2" ..... "a10000": -module(wf). -export([s/0]). s() -> FileName = "plus.erl", {ok, Stream} = file:open(FileName, [write]), %append io:format(Stream, "-module(plus). -export([s/0]). s() -> statistics(runtime), statistics(wall_clock), A=\"0\" ", []), R=rep:s("a",10000), [io:format(Stream, " ++ ~p", [X])|| X <- R], io:format(Stream, ", {_, Time1} = statistics(runtime), {_, Time2} = statistics(wall_clock), U1 = Time1 * 1000, U2 = Time2 * 1000, io:format(\"Process time=~~p (~~p) microseconds~~n\", [U1, U2]). ", []), file:close(Stream). I then c(plus) and then plus:s(). and the process time and microseconds are 0. Is that because the string of ++ items is compile in to one big string and all the operation does is assign it to A? -wes From freza@REDACTED Sat Apr 9 11:30:14 2011 From: freza@REDACTED (Jachym Holecek) Date: Sat, 9 Apr 2011 10:30:14 +0100 Subject: [erlang-questions] timing ++ operation In-Reply-To: References: Message-ID: <20110409093014.GA1539@hanele.lan> # Wes James 2011-04-09: > [...] > > I then run this to create a test erl file which has a 10000 long > A="a1" ++ "a2" ..... "a10000": > > [...] > > I then c(plus) and then plus:s(). and the process time and > microseconds are 0. Is that because the string of ++ items is compile > in to one big string and all the operation does is assign it to A? Yes. BTW 'erlc +to_asm foo.erl' is very useful for discovering what gets compiled to what. Regards, -- Jachym From mihai@REDACTED Sat Apr 9 14:14:14 2011 From: mihai@REDACTED (Mihai Balea) Date: Sat, 9 Apr 2011 08:14:14 -0400 Subject: [erlang-questions] Logic in the supervisor? In-Reply-To: References: Message-ID: <1B0A630A-923A-4E5A-BFA2-4E86A36A45BE@hates.ms> On Apr 8, 2011, at 8:05 PM, Mike Oxford wrote: > I have a pool of resources, say 10k children(FSMs) each holding a resource. > > If I want to remove a resource from the pool, of which they may be duplicates, I have two options. > > 1) Walk the list of children and tell each one "hey, if this is you, close up shop." > 2) Maintain a dict/ETS of all resources, which has more run-time overhead and a higher likelyhood > of "something happening." > > If the supervisor dies, all resources are shut down as they're children, so having the supervisor maintain > the dict/ETS is an option. > > Having another FSM outside the call-tree maintaining that status is an option but, in the case of that > FSM going down then all resources are "lost" and should be released....which minics the case of > a supervisor going down.. > > So... > Do I maintain state external to the supervisor or.. > Have the supervisor maintain state or... > Just deal with the message-storm on resource removal? Have you looked at proc / gproc? If your children can be identified by some sort of name or tag, then it might be a good fit for you. Mihai From roberto@REDACTED Sat Apr 9 14:27:47 2011 From: roberto@REDACTED (Roberto Ostinelli) Date: Sat, 9 Apr 2011 14:27:47 +0200 Subject: [erlang-questions] gen_server & trap_exit Message-ID: Dear list, I start a gen_server and in the initialization i set process_flag(trap_exit, true), obviously to allow the gen_server to catch child processes crashes. Whenever i start this gen_server from the shell and then issue an error in the shell, the gen_server exits too: 12>abc(). ** exception error: undefined shell command abc/0 =ERROR REPORT==== 9-Apr-2011::14:16:51 === ** Generic server testserver terminating ** Last message in was {'EXIT',<0.272.0>, {{shell_undef,abc,0}, [{shell,shell_undef,2}, {erl_eval,local_func,5}, {shell,exprs,7}, {shell,eval_exprs,7}, {shell,eval_loop,3}]}} I believe that this behavior of the server exiting because its parent exits is supposed to happen, since trap_exit doesn't let the gen_server trap its parent process exiting. What I believe happens is that the shell 'crashes' and so does the child process 'testserver'. Am I correct in my assumptions, or am I missing a fundamental point here? Thank you, r. -------------- next part -------------- An HTML attachment was scrubbed... URL: From roberto@REDACTED Sat Apr 9 14:52:11 2011 From: roberto@REDACTED (Roberto Ostinelli) Date: Sat, 9 Apr 2011 14:52:11 +0200 Subject: [erlang-questions] [ANN] misultin v0.7 Message-ID: dear list, misultin v0.7 is now out. changelog is: - added max_connections options parameter, which specifies maximum concurrent open connections accepted by the server - added post_max_size options parameter, which sets the maximum size of POST data - added get_url_max_size options parameter, which sets the maximum length of URI - added CHUNKED support, both for incoming requests and outgoing responses [thanks to yrashk suggestion] - added trapping of client closing a browser in Comet applications [thanks to yrashk] - added SSL support for websockets [enhancement track #25, thanks to viplifes] - Misultin can now be started without a registered name or with a different name, so that multiple versions of misultin can be started on a single node - added support for IP address specified in tuple format [thanks to okeuday suggestion] - added support to extract plain uri unquoted as a list() [thanks to okeuday] - added Comet Long Polling example - added Comet iFrame example - added the killing of alive processes on server shutdown - the GET uri parameters are now also available on POST requests - added custom headers on file sending to browser [thanks to josevalim] - additional minor adjustments https://github.com/ostinelli/misultin cheers, r. -------------- next part -------------- An HTML attachment was scrubbed... URL: From per.melin@REDACTED Sat Apr 9 15:18:14 2011 From: per.melin@REDACTED (Per Melin) Date: Sat, 9 Apr 2011 15:18:14 +0200 Subject: [erlang-questions] gen_server & trap_exit In-Reply-To: References: Message-ID: On Sat, Apr 9, 2011 at 2:27 PM, Roberto Ostinelli wrote: > 12>abc(). > ** exception error: undefined shell command abc/0 > > =ERROR REPORT==== 9-Apr-2011::14:16:51 === > ** Generic server testserver terminating > ** Last message in was {'EXIT',<0.272.0>, > ?????????????????????????????? {{shell_undef,abc,0}, > ??????????????????????????????? [{shell,shell_undef,2}, > ???????????????????????????????? {erl_eval,local_func,5}, > ???????????????????????????????? {shell,exprs,7}, > ???????????????????????????????? {shell,eval_exprs,7}, > ???????????????????????????????? {shell,eval_loop,3}]}} > > I believe that this behavior of the server exiting because its parent exits > is supposed to happen, since trap_exit doesn't let the gen_server trap its > parent process exiting. What I believe happens is that the shell 'crashes' > and so does the child process 'testserver'. 1> self(). <0.31.0> 2> 1 = 2. ** exception error: no match of right hand side value 2 3> self(). <0.34.0> So, yes, the process for your shell session dies, and since that is the process that started your server, it goes down too. You can change this behavior of the shell: 1> self(). <0.31.0> 2> catch_exception(true). false 3> 1 = 2. * exception error: no match of right hand side value 2 4> self(). <0.31.0> From moxford@REDACTED Sat Apr 9 18:51:22 2011 From: moxford@REDACTED (Mike Oxford) Date: Sat, 9 Apr 2011 09:51:22 -0700 Subject: [erlang-questions] Logic in the supervisor? In-Reply-To: <1B0A630A-923A-4E5A-BFA2-4E86A36A45BE@hates.ms> References: <1B0A630A-923A-4E5A-BFA2-4E86A36A45BE@hates.ms> Message-ID: It's more than a 'good fit' and it's almost exactly what I was looking at building myself. Thank you! -mox On Sat, Apr 9, 2011 at 5:14 AM, Mihai Balea wrote: > > On Apr 8, 2011, at 8:05 PM, Mike Oxford wrote: > > > I have a pool of resources, say 10k children(FSMs) each holding a > resource. > > > > If I want to remove a resource from the pool, of which they may be > duplicates, I have two options. > > > > 1) Walk the list of children and tell each one "hey, if this is you, > close up shop." > > 2) Maintain a dict/ETS of all resources, which has more run-time > overhead and a higher likelyhood > > of "something happening." > > > > If the supervisor dies, all resources are shut down as they're children, > so having the supervisor maintain > > the dict/ETS is an option. > > > > Having another FSM outside the call-tree maintaining that status is an > option but, in the case of that > > FSM going down then all resources are "lost" and should be > released....which minics the case of > > a supervisor going down.. > > > > So... > > Do I maintain state external to the supervisor or.. > > Have the supervisor maintain state or... > > Just deal with the message-storm on resource removal? > > Have you looked at proc / gproc? > If your children can be identified by some sort of name or tag, then it > might be a good fit for you. > > Mihai -------------- next part -------------- An HTML attachment was scrubbed... URL: From victor.sovetov@REDACTED Sat Apr 9 22:40:22 2011 From: victor.sovetov@REDACTED (Viktor Sovietov) Date: Sat, 9 Apr 2011 13:40:22 -0700 (PDT) Subject: [erlang-questions] Is eXAT used by anyone? In-Reply-To: References: Message-ID: <680fe093-45a6-4486-91dd-543f25acea73@p16g2000vbi.googlegroups.com> Eresye was updated 6 month ago. I was trying to use it for automated decision-making in our real-time system monitoring app, but it never left experiment... Sincerely, --Victor On Apr 8, 8:34?pm, Gleb Peregud wrote: > On Fri, Apr 8, 2011 at 18:00, Gleb Peregud wrote: > > I'm about to choose a technology for a Multiagent Systems course at my > > university. Since I'm a eager user of Erlang I wanted to use eXAT. But > > unfortunately course teacher wants everyone to use some actively > > developed system. I need to provide to them some proofs that eXAT > > matches this requirement. > > We misunderstood each other with the teacher :) So after clearing up > confusion, I got green light to use eXAT for the project. > > > I can see that last papers about eXAT were > > published in 2004 year. Is anyone working on this project? Or is > > anyone using this project? I will be glad for any pointers in this > > area > > Though this question still holds. Are there any works on this system? > Is it used for any project academia or commercial project? > > Is version of Eresye included in version 1.3 of eXAT the latest > version of Eresye? > > Best regards, > Gleb Peregud > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://erlang.org/mailman/listinfo/erlang-questions From alex.arnon@REDACTED Sun Apr 10 00:04:59 2011 From: alex.arnon@REDACTED (Alex Arnon) Date: Sun, 10 Apr 2011 01:04:59 +0300 Subject: [erlang-questions] QR Code generation library. In-Reply-To: References: <1965ca40-9792-4e4d-8a03-cf11ef47b59a@l6g2000vbn.googlegroups.com> Message-ID: Thank you! On Sat, Apr 9, 2011 at 3:08 AM, Mike Oxford wrote: > Well, ghostscript is a postscript interpreter, and postscript is just a > stack-based language. > I'd take a look at the Barcodewriter stuff anyways. He did a good job > abstracting it out and it supports a lot of different barcodes. > Basically you set up the parameter, and say "go generate it!" When it > comes back to give it a cookie and a pat on the head. > Even if you don't use it initially it's always nice to have options... :) > > Good luck! > > -mox > > On Fri, Apr 8, 2011 at 4:14 PM, Alex Arnon wrote: > >> Steve: I'd echo Vik by saying it certainly sounds like something worth >> open sourcing! :) >> >> I was planning on falling back on zxing as a port program. >> >> Antoine and Mike: I've read some good things on Barcodewriter. However, >> some flexibility in the output is required here, and if we're going for >> several kinds of image generation then ghostscript and PS output are extra >> components on the chain that we have no "use" for. In any case, thanks for >> pointing us to a cool solution. >> >> >> On Fri, Apr 8, 2011 at 3:06 AM, Steve Davis < >> steven.charles.davis@REDACTED> wrote: >> >>> Curious. Must be the zeitgeist. >>> >>> I recently finished a qrcode implementation in Erlang, to enable 2- >>> factor authentication using the Google Authenticator mobile app on a >>> phone. >>> >>> I wasn't planning to, but I guess I could be convinced to open source >>> it on GitHub... though right now, although it's sufficient for our >>> needs, I'm making no big claims over performance ;) >>> >>> I can tell you that if you decide to write an implementation yourself, >>> google's zxing java/cpp code is a good reference. >>> >>> /s >>> >>> >>> >>> On Apr 7, 2:39 am, Alex Arnon wrote: >>> > Hi All, >>> > >>> > Does any of you know of a QR Code generation library for Erlang? >>> > If not, can you recommend a fast one that I could plonk on a port? >>> > Another alternative would be to write one myself - in that case, is >>> there a >>> > reference implementation I could test against? >>> > >>> > Regards, >>> > Alex. >>> > >>> > _______________________________________________ >>> > erlang-questions mailing list >>> > erlang-questi...@REDACTED:// >>> erlang.org/mailman/listinfo/erlang-questions >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://erlang.org/mailman/listinfo/erlang-questions >>> >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kostis@REDACTED Sun Apr 10 11:54:06 2011 From: kostis@REDACTED (Kostis Sagonas) Date: Sun, 10 Apr 2011 12:54:06 +0300 Subject: [erlang-questions] Dialyzer site @ NTUA Message-ID: <4DA17E3E.30401@cs.ntua.gr> We are happy to announce the availability of one more site for Dialyzer: http://dialyzer.softlab.ntua.gr The main reason for the existence of the new site is to offer the Erlang open source community the possibility to have a sneak preview of the effectiveness of some new analyses of Dialyzer, which have not been included in Erlang/OTP yet, so as to allow developers to possibly take some action with respect to the new warnings that the analyses produce and for us to receive the community's feedback on them. For that purpose we have gathered over 150 Erlang projects, run Dialyzer on them and put the results on the relevant pages of the site. There are currently separate sections for: - the version included in Erlang/OTP's 'dev' branch - an experimental version that focuses on some kinds of possible concurrency errors (races, deadlocks, etc.) - an experimental version that employs a stronger type inference which tracks argument-result dependencies The site is designed to be easily and regularly updated with new versions of the projects; it's quite possible that for some projects we are not using the official/latest code base. The application list page located at http://dialyzer.softlab.ntua.gr/apps is designed to reflect actions taken by the developers of the projects to eliminate Dialyzer's warnings. We have also set up a new mail alias (see the "contact" page) to collect feedback for both the site and for Dialyzer in general. Feel free to send comments/feedback there instead of this mailing list, if more appropriate. Kostis Sagonas (for the NTUA dialyzer team) From jesper.louis.andersen@REDACTED Sun Apr 10 12:05:52 2011 From: jesper.louis.andersen@REDACTED (Jesper Louis Andersen) Date: Sun, 10 Apr 2011 12:05:52 +0200 Subject: [erlang-questions] Dialyzer site @ NTUA In-Reply-To: <4DA17E3E.30401@cs.ntua.gr> References: <4DA17E3E.30401@cs.ntua.gr> Message-ID: On Sun, Apr 10, 2011 at 11:54, Kostis Sagonas wrote: > We are happy to announce the availability of one more site for Dialyzer: > > ? http://dialyzer.softlab.ntua.gr > > The main reason for the existence of the new site is to offer the > Erlang open source community the possibility to have a sneak preview > of the effectiveness of some new analyses of Dialyzer, which have not > been included in Erlang/OTP yet, so as to allow developers to possibly > take some action with respect to the new warnings that the analyses > produce and for us to receive the community's feedback on them. This is cool work! I can see we have some cleaning up/evaluation to look at in etorrent. I'll try to get back to you on this if some of the warnings are what I consider spurious. I'll also recommend other people do the same. ... and people say type systems doesn't give you anything... -- J. From zvi.avraham@REDACTED Sun Apr 10 14:52:51 2011 From: zvi.avraham@REDACTED (Zvi) Date: Sun, 10 Apr 2011 05:52:51 -0700 (PDT) Subject: [erlang-questions] [ANN] misultin v0.7 In-Reply-To: References: Message-ID: <8714b1d0-bdca-44da-a079-657c1a113dd6@c26g2000vbq.googlegroups.com> Hi, Can Roberto or somebody else compare Misultin vs. Mochiweb? What's the pros and cons of each of them? Thanks, Zvi On Apr 9, 3:52?pm, Roberto Ostinelli wrote: > dear list, > > misultin v0.7 is now out. changelog is: > > - added max_connections options parameter, which specifies maximum > concurrent open connections > ? accepted by the server > - added post_max_size options parameter, which sets the maximum size of POST > data > - added get_url_max_size options parameter, which sets the maximum length of > URI > - added CHUNKED support, both for incoming requests and outgoing responses > [thanks to yrashk > ? suggestion] > - added trapping of client closing a browser in Comet applications [thanks > to yrashk] > - added SSL support for websockets [enhancement track #25, thanks to > viplifes] > - Misultin can now be started without a registered name or with a different > name, so that multiple > ? versions of misultin can be started on a single node > - added support for IP address specified in tuple format [thanks to okeuday > suggestion] > - added support to extract plain uri unquoted as a list() [thanks to > okeuday] > - added Comet Long Polling example > - added Comet iFrame example > - added the killing of alive processes on server shutdown > - the GET uri parameters are now also available on POST requests > - added custom headers on file sending to browser [thanks to josevalim] > - additional minor adjustments > > https://github.com/ostinelli/misultin > > cheers, > > r. > > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://erlang.org/mailman/listinfo/erlang-questions From demeshchuk@REDACTED Sun Apr 10 15:13:53 2011 From: demeshchuk@REDACTED (Dmitry Demeshchuk) Date: Sun, 10 Apr 2011 17:13:53 +0400 Subject: [erlang-questions] [ANN] misultin v0.7 In-Reply-To: <8714b1d0-bdca-44da-a079-657c1a113dd6@c26g2000vbq.googlegroups.com> References: <8714b1d0-bdca-44da-a079-657c1a113dd6@c26g2000vbq.googlegroups.com> Message-ID: Basically, mochiweb provides more functionality (2 JSON modules, global namespace module, and so on) but is less performant than misultin in many cases (at least, it was some time ago, and I believe that misultin is still the same light and fast). Also, they have a bit different philosophy. Mochiweb uses parametrized modules for processing HTTP requests and misultin uses standard modules. On Sun, Apr 10, 2011 at 4:52 PM, Zvi wrote: > Hi, > > Can Roberto or somebody else compare Misultin vs. Mochiweb? > What's the pros and cons of each of them? > > Thanks, > Zvi > > On Apr 9, 3:52?pm, Roberto Ostinelli wrote: >> dear list, >> >> misultin v0.7 is now out. changelog is: >> >> - added max_connections options parameter, which specifies maximum >> concurrent open connections >> ? accepted by the server >> - added post_max_size options parameter, which sets the maximum size of POST >> data >> - added get_url_max_size options parameter, which sets the maximum length of >> URI >> - added CHUNKED support, both for incoming requests and outgoing responses >> [thanks to yrashk >> ? suggestion] >> - added trapping of client closing a browser in Comet applications [thanks >> to yrashk] >> - added SSL support for websockets [enhancement track #25, thanks to >> viplifes] >> - Misultin can now be started without a registered name or with a different >> name, so that multiple >> ? versions of misultin can be started on a single node >> - added support for IP address specified in tuple format [thanks to okeuday >> suggestion] >> - added support to extract plain uri unquoted as a list() [thanks to >> okeuday] >> - added Comet Long Polling example >> - added Comet iFrame example >> - added the killing of alive processes on server shutdown >> - the GET uri parameters are now also available on POST requests >> - added custom headers on file sending to browser [thanks to josevalim] >> - additional minor adjustments >> >> https://github.com/ostinelli/misultin >> >> cheers, >> >> r. >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questi...@REDACTED://erlang.org/mailman/listinfo/erlang-questions > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -- Best regards, Dmitry Demeshchuk From essen@REDACTED Sun Apr 10 15:28:27 2011 From: essen@REDACTED (=?ISO-8859-1?Q?Lo=EFc_Hoguin?=) Date: Sun, 10 Apr 2011 15:28:27 +0200 Subject: [erlang-questions] [ANN] misultin v0.7 In-Reply-To: References: <8714b1d0-bdca-44da-a079-657c1a113dd6@c26g2000vbq.googlegroups.com> Message-ID: <4DA1B07B.1000303@dev-extend.eu> misultin_req and misultin_ws are parameterized modules. Misultin does less than mochiweb, handling only GET and POST methods (and websockets). But it does it a little faster than mochiweb, and it's catching up in the number of features. If you need performance or hate parameterized modules I'd advise to look at the alternative I am working on, cowboy: https://github.com/extend/cowboy - it's a work in progress and hasn't been used in production yet but this should happen in a month or two. It can process 1.5 times as many requests as misultin right now. Websocket and fast-cgi support are getting worked on and should be coming soon. On 04/10/2011 03:13 PM, Dmitry Demeshchuk wrote: > Basically, mochiweb provides more functionality (2 JSON modules, > global namespace module, and so on) but is less performant than > misultin in many cases (at least, it was some time ago, and I believe > that misultin is still the same light and fast). > > Also, they have a bit different philosophy. Mochiweb uses parametrized > modules for processing HTTP requests and misultin uses standard > modules. > > On Sun, Apr 10, 2011 at 4:52 PM, Zvi wrote: >> Hi, >> >> Can Roberto or somebody else compare Misultin vs. Mochiweb? >> What's the pros and cons of each of them? >> >> Thanks, >> Zvi >> >> On Apr 9, 3:52 pm, Roberto Ostinelli wrote: >>> dear list, >>> >>> misultin v0.7 is now out. changelog is: >>> >>> - added max_connections options parameter, which specifies maximum >>> concurrent open connections >>> accepted by the server >>> - added post_max_size options parameter, which sets the maximum size of POST >>> data >>> - added get_url_max_size options parameter, which sets the maximum length of >>> URI >>> - added CHUNKED support, both for incoming requests and outgoing responses >>> [thanks to yrashk >>> suggestion] >>> - added trapping of client closing a browser in Comet applications [thanks >>> to yrashk] >>> - added SSL support for websockets [enhancement track #25, thanks to >>> viplifes] >>> - Misultin can now be started without a registered name or with a different >>> name, so that multiple >>> versions of misultin can be started on a single node >>> - added support for IP address specified in tuple format [thanks to okeuday >>> suggestion] >>> - added support to extract plain uri unquoted as a list() [thanks to >>> okeuday] >>> - added Comet Long Polling example >>> - added Comet iFrame example >>> - added the killing of alive processes on server shutdown >>> - the GET uri parameters are now also available on POST requests >>> - added custom headers on file sending to browser [thanks to josevalim] >>> - additional minor adjustments >>> >>> https://github.com/ostinelli/misultin >>> >>> cheers, >>> >>> r. >>> >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questi...@REDACTED://erlang.org/mailman/listinfo/erlang-questions >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> > > > -- Lo?c Hoguin Dev:Extend From max.lapshin@REDACTED Sun Apr 10 18:47:50 2011 From: max.lapshin@REDACTED (Max Lapshin) Date: Sun, 10 Apr 2011 20:47:50 +0400 Subject: [erlang-questions] [ANN] misultin v0.7 In-Reply-To: <4DA1B07B.1000303@dev-extend.eu> References: <8714b1d0-bdca-44da-a079-657c1a113dd6@c26g2000vbq.googlegroups.com> <4DA1B07B.1000303@dev-extend.eu> Message-ID: It seems to be an eternal process: new webserver which takes not 50 microseconds, but 10 of them per request and is 5 times faster becomes the same mochiweb when it reaches it by functionality. I've included misultin into erlyvideo very long ago and hadn't updated it from upstream. I had to make a lot of changes by myself and many of them will never be included in upstream. And now I can tell, that there are some features, that are much more important that exact number of _micro_seconds per request: it is memory leakage. If erlang library is built without supervisors, if there are spawn_link's, you should know: 99% that it leaks memory. Stability is much more important than synthetic tests. And much, much more important is to include patches to upstream into erlang library so, that anyone will be able to say: erlang has excelent production-ready webserver out-of-the-box. From essen@REDACTED Sun Apr 10 19:20:19 2011 From: essen@REDACTED (=?UTF-8?B?TG/Dr2MgSG9ndWlu?=) Date: Sun, 10 Apr 2011 19:20:19 +0200 Subject: [erlang-questions] [ANN] misultin v0.7 In-Reply-To: References: <8714b1d0-bdca-44da-a079-657c1a113dd6@c26g2000vbq.googlegroups.com> <4DA1B07B.1000303@dev-extend.eu> Message-ID: <4DA1E6D3.1070506@dev-extend.eu> On 04/10/2011 06:47 PM, Max Lapshin wrote: > It seems to be an eternal process: new webserver which takes not 50 > microseconds, but 10 of them per request and is 5 times faster becomes > the same mochiweb when it reaches it by functionality. I disagree. Mochiweb is slower because of design issues, not because it has more functionality. Most of the functionality in mochiweb that hasn't been done in misultin or cowboy so far is either irrelevant (json, globals, reloader) or aren't related to the GET method, which is the prime target of benchmarks since it's the most used method by far. This is of course not important for requests that will read from a database, but it is very important for requests serving static or cached content, since the data in memory can be sent directly to the client. > And now I can tell, that there are some features, that are much more > important that exact number of _micro_seconds per request: it is > memory leakage. > If erlang library is built without supervisors, if there are > spawn_link's, you should know: 99% that it leaks memory. That's why cowboy has an application supervisor handling listeners, each of which count 3 supervisors: one for acceptors, one for requests, and the third one supervising the supervisors. > Stability is much more important than synthetic tests. And much, much > more important is to include patches to upstream into erlang library > so, that anyone will be able to say: erlang has excelent > production-ready webserver out-of-the-box. Stability is easy in Erlang, almost natural. Performance and design are much more important to consider. Cowboy and the application stack that we'll build on it will run on small clusters of commodity hardware, allowing us to experiment with building various services without the usual cost associated with clusters. The cheapest dedicated servers will do (15 euros/month here). We also want a clean API (no pmods). And of course, cowboy isn't really an HTTP server, it's a generic socket server masquerading as an HTTP server. I'm sure misultin and mochiweb also have good reasons for rolling their own instead of using httpd or yaws. -- Lo?c Hoguin Dev:Extend From max.lapshin@REDACTED Sun Apr 10 19:35:18 2011 From: max.lapshin@REDACTED (Max Lapshin) Date: Sun, 10 Apr 2011 21:35:18 +0400 Subject: [erlang-questions] [ANN] misultin v0.7 In-Reply-To: <4DA1E6D3.1070506@dev-extend.eu> References: <8714b1d0-bdca-44da-a079-657c1a113dd6@c26g2000vbq.googlegroups.com> <4DA1B07B.1000303@dev-extend.eu> <4DA1E6D3.1070506@dev-extend.eu> Message-ID: > > I disagree. Mochiweb is slower because of design issues, not because it > has more functionality. Most of the functionality in mochiweb that You are speaking about stability and use blocking, unstable technique of listening and reading sockets: https://github.com/extend/cowboy/blob/master/src/cowboy_acceptor.erl#L34 I advise to read this: http://www.trapexit.org/Building_a_Non-blocking_TCP_server_using_OTP_principles From bob@REDACTED Sun Apr 10 19:36:53 2011 From: bob@REDACTED (Bob Ippolito) Date: Sun, 10 Apr 2011 10:36:53 -0700 Subject: [erlang-questions] [ANN] misultin v0.7 In-Reply-To: <4DA1E6D3.1070506@dev-extend.eu> References: <8714b1d0-bdca-44da-a079-657c1a113dd6@c26g2000vbq.googlegroups.com> <4DA1B07B.1000303@dev-extend.eu> <4DA1E6D3.1070506@dev-extend.eu> Message-ID: On Sun, Apr 10, 2011 at 10:20 AM, Lo?c Hoguin wrote: > On 04/10/2011 06:47 PM, Max Lapshin wrote: >> It seems to be an eternal process: new webserver which takes not 50 >> microseconds, but 10 of them per request and is 5 times faster becomes >> the same mochiweb when it reaches it by functionality. > > I disagree. Mochiweb is slower because of design issues, not because it > has more functionality. Most of the functionality in mochiweb that > hasn't been done in misultin or cowboy so far is either irrelevant > (json, globals, reloader) or aren't related to the GET method, which is > the prime target of benchmarks since it's the most used method by far. This is true, mochiweb is slightly slower than other solutions for two main reasons: * It hasn't made the backwards incompatible change to switch everything to binaries (wasn't a sensible thing to do four years ago when I wrote it) * It spends time doing header parsing and normalization when it probably shouldn't (if it was trying to compete on synthetic benchmarks) I say slightly slower because the last time I benchmarked it against misultin, it only differed by a few percent. For most purposes, this is an irrelevant difference. I haven't looked at cowboy, but it probably does what mochiweb would've done if I had written it today for modern Erlang. The independent functionality in mochiweb is there because Erlang had no suitable dependency management solution at the time. > I'm sure misultin and mochiweb also have good reasons for rolling their > own instead of using httpd or yaws. Well, yaws had a memory leak and was more complicated than what I actually wanted, and httpd had this terrible idea that everything should be managed with apache style config files/request phases and wasn't easy to embed at the time. Both of them also suffer from a lot more legacy pain than mochiweb does. -bob From essen@REDACTED Sun Apr 10 19:56:10 2011 From: essen@REDACTED (=?ISO-8859-1?Q?Lo=EFc_Hoguin?=) Date: Sun, 10 Apr 2011 19:56:10 +0200 Subject: [erlang-questions] [ANN] misultin v0.7 In-Reply-To: References: <8714b1d0-bdca-44da-a079-657c1a113dd6@c26g2000vbq.googlegroups.com> <4DA1B07B.1000303@dev-extend.eu> <4DA1E6D3.1070506@dev-extend.eu> Message-ID: <4DA1EF3A.1060003@dev-extend.eu> On 04/10/2011 07:35 PM, Max Lapshin wrote: >> >> I disagree. Mochiweb is slower because of design issues, not because it >> has more functionality. Most of the functionality in mochiweb that > > You are speaking about stability and use blocking, unstable technique > of listening and reading sockets: > > https://github.com/extend/cowboy/blob/master/src/cowboy_acceptor.erl#L34 > > > I advise to read this: > > http://www.trapexit.org/Building_a_Non-blocking_TCP_server_using_OTP_principles An acceptor process only accepts, it can be killed and restarted without any fear of losing anything, which is why their supervisor uses brutal_kill in the child spec. The listened socket is controlled by a different process which makes killing acceptors a complete non-issue. Nothing in your link indicates that blocking is unstable. I have an application that's been up and running for many months that hasn't had any issue with blocking. No crash has occured on this part of the code or in the VM so far, and it's not running heartbeat either. Note that all the erlang http servers I've looked at so far use blocking. On the other hand the technique in your link is undocumented in OTP and I want no such thing in cowboy. The code must stay clean from all the evils that are pmods, pdicts and undocumented features. -- Lo?c Hoguin Dev:Extend From bob@REDACTED Sun Apr 10 20:08:23 2011 From: bob@REDACTED (Bob Ippolito) Date: Sun, 10 Apr 2011 11:08:23 -0700 Subject: [erlang-questions] [ANN] misultin v0.7 In-Reply-To: <4DA1EF3A.1060003@dev-extend.eu> References: <8714b1d0-bdca-44da-a079-657c1a113dd6@c26g2000vbq.googlegroups.com> <4DA1B07B.1000303@dev-extend.eu> <4DA1E6D3.1070506@dev-extend.eu> <4DA1EF3A.1060003@dev-extend.eu> Message-ID: On Sun, Apr 10, 2011 at 10:56 AM, Lo?c Hoguin wrote: > On 04/10/2011 07:35 PM, Max Lapshin wrote: >>> >>> I disagree. Mochiweb is slower because of design issues, not because it >>> has more functionality. Most of the functionality in mochiweb that >> >> You are speaking about stability and use blocking, unstable technique >> of listening and reading sockets: >> >> https://github.com/extend/cowboy/blob/master/src/cowboy_acceptor.erl#L34 >> >> >> I advise to read this: >> >> http://www.trapexit.org/Building_a_Non-blocking_TCP_server_using_OTP_principles > > An acceptor process only accepts, it can be killed and restarted > without any fear of losing anything, which is why their supervisor > uses brutal_kill in the child spec. The listened socket is controlled > by a different process which makes killing acceptors a complete > non-issue. > > Nothing in your link indicates that blocking is unstable. I have an > application that's been up and running for many months that hasn't had > any issue with blocking. No crash has occured on this part of the code > or in the VM so far, and it's not running heartbeat either. > > Note that all the erlang http servers I've looked at so far use blocking. mochiweb does accept in multiple processes in order to minimize latency. After doing this I found that our worst case times got better, but we were only able to observe this effect in production and did not try too hard to reproduce it with a synthetic benchmark. -bob From essen@REDACTED Sun Apr 10 20:16:46 2011 From: essen@REDACTED (=?UTF-8?B?TG/Dr2MgSG9ndWlu?=) Date: Sun, 10 Apr 2011 20:16:46 +0200 Subject: [erlang-questions] [ANN] misultin v0.7 In-Reply-To: References: <8714b1d0-bdca-44da-a079-657c1a113dd6@c26g2000vbq.googlegroups.com> <4DA1B07B.1000303@dev-extend.eu> <4DA1E6D3.1070506@dev-extend.eu> Message-ID: <4DA1F40E.6080409@dev-extend.eu> On 04/10/2011 07:36 PM, Bob Ippolito wrote: > On Sun, Apr 10, 2011 at 10:20 AM, Lo?c Hoguin wrote: >> On 04/10/2011 06:47 PM, Max Lapshin wrote: >>> It seems to be an eternal process: new webserver which takes not 50 >>> microseconds, but 10 of them per request and is 5 times faster becomes >>> the same mochiweb when it reaches it by functionality. >> >> I disagree. Mochiweb is slower because of design issues, not because it >> has more functionality. Most of the functionality in mochiweb that >> hasn't been done in misultin or cowboy so far is either irrelevant >> (json, globals, reloader) or aren't related to the GET method, which is >> the prime target of benchmarks since it's the most used method by far. > > This is true, mochiweb is slightly slower than other solutions for two > main reasons: > * It hasn't made the backwards incompatible change to switch > everything to binaries (wasn't a sensible thing to do four years ago > when I wrote it) Did you benchmark this yet? In my case, binaries for headers is both slower and uses more memory than plain lists. Why, I do not know. :( > * It spends time doing header parsing and normalization when it > probably shouldn't (if it was trying to compete on synthetic > benchmarks) Yes, that's one part where I've been focusing my effort (or lack of efforts), by only caring about the request-line, Host and Connection headers and lazy-evaluating everything else. Another issue though is that timers are slow, and you use a lot of timers (implicitly). Misultin is also a culprit there. Basically, everytime you do a 'receive ... after N -> ... end', a timer is started to handle the 'after' clause. This is awfully slow, especially considering you do it many times per request (one for the request-line, one per header, maybe more?). On the other hand you don't have a speed penalty using gen_tcp:recv/3 with a timeout. We didn't investigate the gen_tcp code enough to know the exact reasons for this though, afaik. To reiterate, 'receive ... end' is fast, 'receive ... after N -> ... end' is slow. Right now we are wondering whether using {packet, raw} and calling erlang:decode_packet ourselves would be faster than {packet, http}. It could, since many requests are received in a single TCP packet (default MTU is 1460 on most systems). That means a single recv sent directly to decode_packet and processed instead of many recv. You can also directly receive the binary data from the socket in which case it's probably much faster than lists. But this is all just ideas to explore atm. -- Lo?c Hoguin Dev:Extend From essen@REDACTED Sun Apr 10 20:18:42 2011 From: essen@REDACTED (=?UTF-8?B?TG/Dr2MgSG9ndWlu?=) Date: Sun, 10 Apr 2011 20:18:42 +0200 Subject: [erlang-questions] [ANN] misultin v0.7 In-Reply-To: References: <8714b1d0-bdca-44da-a079-657c1a113dd6@c26g2000vbq.googlegroups.com> <4DA1B07B.1000303@dev-extend.eu> <4DA1E6D3.1070506@dev-extend.eu> <4DA1EF3A.1060003@dev-extend.eu> Message-ID: <4DA1F482.7050701@dev-extend.eu> On 04/10/2011 08:08 PM, Bob Ippolito wrote: > On Sun, Apr 10, 2011 at 10:56 AM, Lo?c Hoguin wrote: >> On 04/10/2011 07:35 PM, Max Lapshin wrote: >>>> >>>> I disagree. Mochiweb is slower because of design issues, not because it >>>> has more functionality. Most of the functionality in mochiweb that >>> >>> You are speaking about stability and use blocking, unstable technique >>> of listening and reading sockets: >>> >>> https://github.com/extend/cowboy/blob/master/src/cowboy_acceptor.erl#L34 >>> >>> >>> I advise to read this: >>> >>> http://www.trapexit.org/Building_a_Non-blocking_TCP_server_using_OTP_principles >> >> An acceptor process only accepts, it can be killed and restarted >> without any fear of losing anything, which is why their supervisor >> uses brutal_kill in the child spec. The listened socket is controlled >> by a different process which makes killing acceptors a complete >> non-issue. >> >> Nothing in your link indicates that blocking is unstable. I have an >> application that's been up and running for many months that hasn't had >> any issue with blocking. No crash has occured on this part of the code >> or in the VM so far, and it's not running heartbeat either. >> >> Note that all the erlang http servers I've looked at so far use blocking. > > mochiweb does accept in multiple processes in order to minimize > latency. After doing this I found that our worst case times got > better, but we were only able to observe this effect in production and > did not try too hard to reproduce it with a synthetic benchmark. Agree. In my tests I found that 100 acceptors give the best performance, but that's probably dependent on the hardware. -- Lo?c Hoguin Dev:Extend From tristan.sloughter@REDACTED Sun Apr 10 20:43:43 2011 From: tristan.sloughter@REDACTED (Tristan Sloughter) Date: Sun, 10 Apr 2011 13:43:43 -0500 Subject: [erlang-questions] [Announcement] PubNub Erlang API Message-ID: First version 0.0.1: https://github.com/tsloughter/epubnub Tutorial: http://blog.erlware.org/2011/04/10/erlang-pubnub-client-and-chat/ PubNub: http://www.pubnub.com/ Tristan -------------- next part -------------- An HTML attachment was scrubbed... URL: From roberto@REDACTED Sun Apr 10 21:10:48 2011 From: roberto@REDACTED (Roberto Ostinelli) Date: Sun, 10 Apr 2011 21:10:48 +0200 Subject: [erlang-questions] [ANN] misultin v0.7 In-Reply-To: <4DA1F482.7050701@dev-extend.eu> References: <8714b1d0-bdca-44da-a079-657c1a113dd6@c26g2000vbq.googlegroups.com> <4DA1B07B.1000303@dev-extend.eu> <4DA1E6D3.1070506@dev-extend.eu> <4DA1EF3A.1060003@dev-extend.eu> <4DA1F482.7050701@dev-extend.eu> Message-ID: On Apr 10, 2011, at 6:47 PM, Max Lapshin wrote: It seems to be an eternal process: new webserver which takes not 50 microseconds, but 10 of them per request and is 5 times faster becomes the same mochiweb when it reaches it by functionality. [...] And now I can tell, that there are some features, that are much more important that exact number of _micro_seconds per request: it is memory leakage. i can only agree to that. stability and functionalities [the ones you need!] are the most important part of all. it is quite normal that a library slows down as features get added, such as limiting the data that malicious client can send, etc. On Apr 10, 2011, at 7:36 PM, Bob Ippolito wrote: I say slightly slower because the last time I benchmarked it against misultin, it only differed by a few percent. For most purposes, this is an irrelevant difference. i slightly disagree on this, since these are my latest tests with jmeter comparing mochiweb 1.5.2 tag with misultin master tree [convention is name of library / concurrent threads], over a simple echoing of a variable passed in GET: library & threads # samples Avg (ms) Min (ms) Max (ms) StdDev Error Throughput /sec KB/sec Avg. Bytes Mochi 1 100000 0 0 330 1.11 0 1129.80 54.06 49 Mochi 10 100000 4 0 36 1.30 0 2221.83 106.32 49 Mochi 50 100000 20 0 148 4.97 0 2393.49 114.53 49 Mochi 100 100000 39 1 335 10.04 0 2436.41 116.59 49 Mochi 200 100000 83 1 381 23.27 0 2321.53 111.09 49 Misultin 1 100000 0 0 38 0.53 0 1545.26 73.94 49 Misultin 10 100000 2 0 318 1.33 0 3548.24 169.79 49 Misultin 50 100000 12 0 46 3.68 0 3899.70 186.60 49 Misultin 100 100000 24 0 110 7.36 0 3928.66 187.99 49 Misultin 200 100000 55 1 223 18.58 0 3477.29 166.39 49 however, as i've always said, mochiweb is a wonderful library which as a proven and successful history in running in production. misultin is used in production too, but i wouldn't be surprised that it is less stable. i've spent much less time in optimizing speed than in putting efforts to functionalities and such. there's a perfectly good reason for that. :) r. -------------- next part -------------- An HTML attachment was scrubbed... URL: From per.melin@REDACTED Sun Apr 10 21:26:07 2011 From: per.melin@REDACTED (Per Melin) Date: Sun, 10 Apr 2011 21:26:07 +0200 Subject: [erlang-questions] [ANN] misultin v0.7 In-Reply-To: <4DA1EF3A.1060003@dev-extend.eu> References: <8714b1d0-bdca-44da-a079-657c1a113dd6@c26g2000vbq.googlegroups.com> <4DA1B07B.1000303@dev-extend.eu> <4DA1E6D3.1070506@dev-extend.eu> <4DA1EF3A.1060003@dev-extend.eu> Message-ID: On Sun, Apr 10, 2011 at 7:56 PM, Lo?c Hoguin wrote: > On 04/10/2011 07:35 PM, Max Lapshin wrote: >> You are speaking about stability and use blocking, unstable technique >> of listening and reading sockets: >> >> https://github.com/extend/cowboy/blob/master/src/cowboy_acceptor.erl#L34 >> >> >> I advise to read this: >> >> http://www.trapexit.org/Building_a_Non-blocking_TCP_server_using_OTP_principles > > An acceptor process only accepts, it can be killed and restarted > without any fear of losing anything, which is why their supervisor > uses brutal_kill in the child spec. The listened socket is controlled > by a different process which makes killing acceptors a complete > non-issue. I have a web server I wrote before Mochiweb* was open sourced, and it's been running in production since. It handles accept in a fashion very similar to Cowboy. It is doing 30-40 million requests per day and has been through many live code updates and I've yet to have a problem with it. Though what has caused problems in other applications with high throughput is gen_tcp:send/2 blocking. So there are places we go directly to erlang:port_command/2 instead. Once you get a {inet_reply, Socket, ok} message back from the driver you know you're safe to push more data on the port without blocking. * I've thought about switching to Mochiweb a few times since, but I have an irrational fear of bloat, and all the arbitrary modules plus the kitchen sink you get with it have put me off. From co7eb@REDACTED Sun Apr 10 23:33:12 2011 From: co7eb@REDACTED (=?iso-8859-1?Q?Gilberio_Carmenates_Garc=EDa?=) Date: Sun, 10 Apr 2011 17:33:12 -0400 Subject: [erlang-questions] Mnesia how to change the database node Message-ID: <001201cbf7c6$e86b9120$b942b360$@co.cu> Hi all I have a Little problem, guest that I have an installed database, but later I want to change the node where the database is running and all the information it contain to be passed to the other new node without losing any data. How could I do it, of the more easy way, I have some idea but I don?t know it is the best, to export the data as script file and so once I create the other database in the other node import the script file. But well you tell me how is the best way. Regards, Ivan. ======================================================================= Este mensaje ha sido enviado mediante el servicio de correo electr?nico que ofrece la Federaci?n de Radioaficionados de Cuba a sus miembros para respaldar el cumplimiento de los objetivos de la organizaci?n y su pol?tica informativa. La persona que env?a este correo asume el compromiso de usar el servicio a tales fines y cumplir con las regulaciones establecidas. -------------- next part -------------- An HTML attachment was scrubbed... URL: From spawn.think@REDACTED Sun Apr 10 23:46:41 2011 From: spawn.think@REDACTED (Ahmed Omar) Date: Sun, 10 Apr 2011 23:46:41 +0200 Subject: [erlang-questions] Mnesia how to change the database node In-Reply-To: <001201cbf7c6$e86b9120$b942b360$@co.cu> References: <001201cbf7c6$e86b9120$b942b360$@co.cu> Message-ID: You might wanna have a look at http://www.erlang.org/doc/apps/mnesia/Mnesia_chap7.html#id76585 It contains an example of changing node name 2011/4/10 Gilberio Carmenates Garc?a > Hi all > > > > I have a Little problem, guest that I have an installed database, but later > I want to change the node where the database is running and all the > information it contain to be passed to the other new node without losing any > data. > > > > How could I do it, of the more easy way, I have some idea but I don?t know > it is the best, to export the data as script file and so once I create the > other database in the other node import the script file. But well you tell > me how is the best way. > > > > > > Regards, > > > > Ivan. > > > > ======================================================================= > Este mensaje ha sido enviado mediante el servicio de correo electr?nico que > ofrece la Federaci?n de Radioaficionados de Cuba a sus miembros para > respaldar el cumplimiento de los objetivos de la organizaci?n y su pol?tica > informativa. La persona que env?a este correo asume el compromiso de usar el > servicio a tales fines y cumplir con las regulaciones establecidas. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -- Best Regards, - Ahmed Omar http://nl.linkedin.com/in/adiaa Follow me on twitter @spawn_think -------------- next part -------------- An HTML attachment was scrubbed... URL: From nick.sfx.1@REDACTED Mon Apr 11 00:08:37 2011 From: nick.sfx.1@REDACTED (Nick S) Date: Mon, 11 Apr 2011 01:08:37 +0300 Subject: [erlang-questions] Cross compiling basic question Message-ID: I am running Erlang R14B02 (erts-5.8.3) under 32-bit Linux. Is cross compilation possible, so that I can distribute (beam) my software directly for users of 32/64-bit Windows and other Linux distributions? -------------- next part -------------- An HTML attachment was scrubbed... URL: From kostis@REDACTED Mon Apr 11 00:11:33 2011 From: kostis@REDACTED (Kostis Sagonas) Date: Mon, 11 Apr 2011 01:11:33 +0300 Subject: [erlang-questions] Cross compiling basic question In-Reply-To: References: Message-ID: <4DA22B15.7090705@cs.ntua.gr> Nick S wrote: > I am running Erlang R14B02 (erts-5.8.3) under 32-bit Linux. > > Is cross compilation possible, so that I can distribute (beam) my > software directly for users of 32/64-bit Windows and other Linux > distributions? Beam files containing byte code only are platform and OS independent, so the answer to your question is yes. They are not platform independent if you include native code in them. Kostis From alexey.v.romanov@REDACTED Mon Apr 11 00:13:00 2011 From: alexey.v.romanov@REDACTED (Alexey Romanov) Date: Mon, 11 Apr 2011 02:13:00 +0400 Subject: [erlang-questions] Cross compiling basic question In-Reply-To: References: Message-ID: .beam files are portable between architectures (just as Java's .class files, and for the same reason) without need for cross-compilation. And of course you can cross-compile any NIFs, linked-in drivers, or other C code as usual. Yours, Alexey Romanov On Mon, Apr 11, 2011 at 2:08 AM, Nick S wrote: > I am running Erlang R14B02 (erts-5.8.3) under 32-bit Linux. > > Is cross compilation possible, so that I can distribute (beam) my software > directly for users of 32/64-bit Windows and other Linux distributions? > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > From yaohui1984@REDACTED Mon Apr 11 04:30:21 2011 From: yaohui1984@REDACTED (=?ISO-8859-1?B?eWFvaHVp?=) Date: Mon, 11 Apr 2011 10:30:21 +0800 Subject: [erlang-questions] Tcp server for a high concurrency? Message-ID: Hi, Is there any instance of 500k or higher 1000k concurrent tcp connections? Can someone give me any configuration of hardware, software or system kernel for a high concurrency? Thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: From kaiduanx@REDACTED Mon Apr 11 04:43:39 2011 From: kaiduanx@REDACTED (Kaiduan Xie) Date: Sun, 10 Apr 2011 22:43:39 -0400 Subject: [erlang-questions] Tcp server for a high concurrency? In-Reply-To: References: Message-ID: Yaohui, Please see the following link http://www.metabrew.com/article/a-million-user-comet-application-with-mochiweb-part-1 /Kaiduan On Sun, Apr 10, 2011 at 10:30 PM, yaohui wrote: > Hi, > > Is there any instance of 500k or higher 1000k concurrent tcp connections? > Can someone give me any configuration of hardware, software or system kernel > for a high concurrency? > > Thanks. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > From steven.charles.davis@REDACTED Mon Apr 11 06:25:35 2011 From: steven.charles.davis@REDACTED (Steve Davis) Date: Sun, 10 Apr 2011 21:25:35 -0700 (PDT) Subject: [erlang-questions] QR Code generation library. In-Reply-To: References: <1965ca40-9792-4e4d-8a03-cf11ef47b59a@l6g2000vbn.googlegroups.com> Message-ID: A rather basic open-source execution, but it's apache 2 license and provides enough of our image/crypto support to allow a full-cycle demo with a phone... https://github.com/komone/qrcode Enjoy! /s From matthias@REDACTED Mon Apr 11 07:00:58 2011 From: matthias@REDACTED (Matthias Lang) Date: Mon, 11 Apr 2011 07:00:58 +0200 Subject: [erlang-questions] Floating point conversion problem on big endian architecture In-Reply-To: <4D9DC598.5020204@device-insight.com> References: <4D9DC598.5020204@device-insight.com> Message-ID: <20110411050058.GA2380@corelatus.se> Hi, Mikael has already answered in general terms. I want to add a specific counter-example. I cross-compile on x86 to arm, here's what I get: # uname -a Linux gth 2.6.36-07957-gb1adc07 #10 Mon Mar 21 14:27:41 CET 2011 armv5tejl GNU/Linux # erl Erlang R14B01 (erts-5.8.2) [source] [rq:1] [async-threads:0] [kernel-poll:false] Eshell V5.8.2 (abort with ^G) 1> B = <<3.2:32/big-float>>, io:format("~w~n", [B]). <<64,76,204,205>> ok 2> <> = B, R. 3.200000047683716 The erl-xcomp-armle-linux-gnu.conf I use is the same as the MIPS one included with R14B01, apart from one line: erl_xcomp_host=arm-linux Matt ---------------------------------------------------------------------- On Thursday, April 07, Stefan Hudelmaier wrote: > Hi, > > we're cross compiling Erlang/OTP on a x86 PC for ARM. On the > resulting runtime on ARM we have the following strange problem: > Converting float to binary seems to work fine, exactly as on x86: > > > B = <<3.2:32/big-float>>. > > io:format("~w~n", [B]). > <<64,76,204,205>> > > But converting back to float from this binary, yields the wrong > result on ARM: > > > <> = B. > > R. > -428443648.0 > > While on x86, it works as expected: > > > <> = B. > > R. > 3.200000047683716 > > When compiling for ARM, we have set erl_xcomp_bigendian=yes. hipe is > disabled. We have tried R14A and R14B02. > > Please let me know, if there is any more information we need to provide. > > Kind regards, > Stefan From maxtqm@REDACTED Mon Apr 11 07:54:04 2011 From: maxtqm@REDACTED (max tan) Date: Mon, 11 Apr 2011 13:54:04 +0800 Subject: [erlang-questions] mnesia cluster of p2p style? Message-ID: Hi all, Is it possible to setup a Mnesia cluster consisting hundreds (or more) nodes, wherein each table is replicated by 3-4 nodes? I think the problem may be concerning Mnesia schema, which is shared by the whole cluster, and tables are dynamically created, deleted and moved. So I worry about the schema_transaction overhead. Best regards. Tan Qingming. -------------- next part -------------- An HTML attachment was scrubbed... URL: From mjtruog@REDACTED Mon Apr 11 09:04:55 2011 From: mjtruog@REDACTED (Michael Truog) Date: Mon, 11 Apr 2011 00:04:55 -0700 Subject: [erlang-questions] mnesia cluster of p2p style? In-Reply-To: References: Message-ID: <4DA2A817.8060308@gmail.com> That seems like a very complex situation, that is not straight-forward, mainly because of the node count. Erlang by default creates a fully connected network topology when using the distributed Erlang. That generally means that Erlang clusters using distributed Erlang should be limited to roughly a hundred nodes unless some type of hierarchy (tree) of nodes is used. To do a hierarchical setup seems like it would be more difficult than with other systems, and I have not seen a good example or research in this area, as it relates to Erlang. If you got a hierarchy working, then you could use hundreds of nodes, and try to get mnesia replication working with updates propagating the network. This task sounds like it might be a better fit for something like Riak or Scalaris. On 04/10/2011 10:54 PM, max tan wrote: > Hi all, > > Is it possible to setup a Mnesia cluster consisting hundreds (or more) nodes, wherein each table is replicated by 3-4 nodes? I think the problem may be concerning Mnesia schema, which is shared by the whole cluster, and tables are dynamically created, deleted and moved. So I worry about the schema_transaction overhead. > > Best regards. > > Tan Qingming. > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From gleber.p@REDACTED Mon Apr 11 09:55:24 2011 From: gleber.p@REDACTED (Gleb Peregud) Date: Mon, 11 Apr 2011 09:55:24 +0200 Subject: [erlang-questions] Tcp server for a high concurrency? Message-ID: At the project I'm working on we have managed to connect 850k clients to a single erlang server on m2.4xlarge EC2 instance. Please note that in fact there is no limitation of 64k connections per IP address mentioned in the link provided by previous respondent, since TCP/IP connection uniqueness is determined by 4-element tuple {srcip, srcport, dstip, dstport} not by 2-element tuple as suggested in linked article Best regards, Gleb Peregud On 11 Apr 2011 04:43, "Kaiduan Xie" wrote: -------------- next part -------------- An HTML attachment was scrubbed... URL: From knut.nesheim@REDACTED Mon Apr 11 10:29:20 2011 From: knut.nesheim@REDACTED (Knut Nesheim) Date: Mon, 11 Apr 2011 10:29:20 +0200 Subject: [erlang-questions] [ANN] Eredis, Erlang Redis client In-Reply-To: References: Message-ID: Hey Matt, On Fri, Apr 8, 2011 at 5:49 PM, Matt Stancliff wrote: > ?Did you check out my erlang redis library https://github.com/mattsta/er? No, this is the first time I've seen this library. I read the source and noticed that you take the same approach to parsing responses as redis-erl and redis_pool. When parsing big multibulk responses, we found that this was slower than clients in many other high level languages. The approach in eredis is to continuously receive data and parse it as we get it, rather than using gen_tcp:recv/2 to get every bulk in a multibulk response. > ?I'll get basho_bench running on er so we can compare numbers. This would be very interesting. Please feel free to use the drivers and configuration available in eredis as a starting point. It would also be very interesting if you try benchmarking the multibulk responses, see https://github.com/wooga/eredis/blob/master/src/basho_bench_driver_eredis.erl#L18 for an example of what we did. > > [1]: http://twitter.com/antirez/status/27362335330 > > > -Matt > -- > Matt Stancliff ? ? ? ? ? ? ? ? ? ?San Jose, CA > @mattsta ? ? ? ? ? ? ? ? ?iPhone: 678-591-9337 > "The best way to predict the future is to invent it." --Alan Kay > > -- Engineering http://www.wooga.com | fax +49-30-8964 9064 wooga GmbH | Saarbruecker Str. 38 | 10405 Berlin | Germany Sitz der Gesellschaft: Berlin; HRB 117846 B Registergericht Berlin-Charlottenburg Geschaeftsfuehrung: Jens Begemann, Philipp Moeser From michael.eugene.turner@REDACTED Mon Apr 11 13:41:48 2011 From: michael.eugene.turner@REDACTED (Michael Turner) Date: Mon, 11 Apr 2011 20:41:48 +0900 Subject: [erlang-questions] Mysterious wxDialog:showModal/1 return value Message-ID: The documentation for wxDialog:showModal/1 promises (indirectly, anyway) that "The return value is the value set with wxDialog::SetReturnCode ." See http://docs.wxwidgets.org/stable/wx_wxdialog.html#wxdialogshowmodal But wxWidgets (at least as of R14B on Windows) doesn't seem to keep that promise. I put these lines into the shell: Wx= wx:new(). F = wxFrame:new(Wx, -1, "A frame"). wxFrame:show(F). D = wxMessageDialog:new (F, "Let's talk."). When I asked for this: wxDialog:getReturnCode(D). I got 0 (zero). When I set it to 1 wxDialog:setReturnCode(D,1). I got "ok". When I asked to see the value I'd set wxDialog:getReturnCode(D). I got back 1 -- as I'd asked. But when I did wxDialog:showModal(D). and hit the OK button, the return value was 5100. Why? Is there some reason for this? For my wxWidgets tutorial http://www.idiom.com/~turner/wxtut/wxwidgets.html even if I'm stuck with 5100, I'd like, at the very least, to be able to explain why it's 5100. Does anybody know? -michael turner -------------- next part -------------- An HTML attachment was scrubbed... URL: From dgud@REDACTED Mon Apr 11 14:30:40 2011 From: dgud@REDACTED (Dan Gudmundsson) Date: Mon, 11 Apr 2011 14:30:40 +0200 Subject: [erlang-questions] Mysterious wxDialog:showModal/1 return value In-Reply-To: References: Message-ID: I don't know how it's supposed to work but from wx.hrl -define(wxID_OK, 5100). /Dan On Mon, Apr 11, 2011 at 1:41 PM, Michael Turner wrote: > The documentation for wxDialog:showModal/1 promises (indirectly, anyway) > that > ??"The return value is the value set with?wxDialog::SetReturnCode." > > See?http://docs.wxwidgets.org/stable/wx_wxdialog.html#wxdialogshowmodal > > But wxWidgets (at least as of R14B on Windows) doesn't seem to keep that > promise. > I put these lines into the shell: > ??Wx= wx:new(). > ??F = wxFrame:new(Wx, -1, "A frame"). > ??wxFrame:show(F). > ??D = wxMessageDialog:new (F, "Let's talk."). > When I asked for this: > ??wxDialog:getReturnCode(D). > I got 0 (zero). ?When I set it to 1 > ??wxDialog:setReturnCode(D,1). > I got "ok". ?When I asked to see the value I'd set > ??wxDialog:getReturnCode(D). > I got back 1 -- as I'd asked. ?But when I did > ???wxDialog:showModal(D). > and hit the OK button, the return value was 5100. > Why? ?Is there some reason for this? ?For my wxWidgets tutorial > ??http://www.idiom.com/~turner/wxtut/wxwidgets.html > even if I'm stuck with 5100, I'd like, at the very least, to be able to > explain why it's 5100. ?Does anybody know? > -michael turner > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > From michael.eugene.turner@REDACTED Mon Apr 11 15:35:58 2011 From: michael.eugene.turner@REDACTED (Michael Turner) Date: Mon, 11 Apr 2011 22:35:58 +0900 Subject: [erlang-questions] Mysterious wxDialog:showModal/1 return value In-Reply-To: References: Message-ID: Ah, thanks. I should have guessed. Now I'll see if there's a way I might have figured it out from the documentation. :-( I suppose it's a minor miracle that there was even *one* way to derive a reasonably coherent API for wxWidgets, but it would have been nice if the return value in this case could somehow have been *atom* wxID_OK rather than macro value ?wxID_OK (which the Erlang shell can't see.) One of these days I'll have to write a broadside, "Graphics as if Erlang mattered". I have this feeling that a really cool API is possible, one that makes GUI-writing easier than in most languages, but just hasn't happened yet. -michael turner On Mon, Apr 11, 2011 at 9:30 PM, Dan Gudmundsson wrote: > I don't know how it's supposed to work but from wx.hrl > -define(wxID_OK, 5100). > > /Dan > > On Mon, Apr 11, 2011 at 1:41 PM, Michael Turner > wrote: > > The documentation for wxDialog:showModal/1 promises (indirectly, anyway) > > that > > "The return value is the value set with wxDialog::SetReturnCode." > > > > See http://docs.wxwidgets.org/stable/wx_wxdialog.html#wxdialogshowmodal > > > > But wxWidgets (at least as of R14B on Windows) doesn't seem to keep that > > promise. > > I put these lines into the shell: > > Wx= wx:new(). > > F = wxFrame:new(Wx, -1, "A frame"). > > wxFrame:show(F). > > D = wxMessageDialog:new (F, "Let's talk."). > > When I asked for this: > > wxDialog:getReturnCode(D). > > I got 0 (zero). When I set it to 1 > > wxDialog:setReturnCode(D,1). > > I got "ok". When I asked to see the value I'd set > > wxDialog:getReturnCode(D). > > I got back 1 -- as I'd asked. But when I did > > wxDialog:showModal(D). > > and hit the OK button, the return value was 5100. > > Why? Is there some reason for this? For my wxWidgets tutorial > > http://www.idiom.com/~turner/wxtut/wxwidgets.html > > even if I'm stuck with 5100, I'd like, at the very least, to be able to > > explain why it's 5100. Does anybody know? > > -michael turner > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf.wiger@REDACTED Mon Apr 11 17:46:55 2011 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Mon, 11 Apr 2011 17:46:55 +0200 Subject: [erlang-questions] Logic in the supervisor? In-Reply-To: References: <1B0A630A-923A-4E5A-BFA2-4E86A36A45BE@hates.ms> Message-ID: <863EE1C7-63EE-4B5B-997F-AFD157AD9CD5@erlang-solutions.com> On 9 Apr 2011, at 18:51, Mike Oxford wrote: > It's more than a 'good fit' and it's almost exactly what I was looking at building myself. > > Thank you! Just to be safe: http://github.com/esl/gproc is the place to get it. I do not maintain any other version, although http://github.com/uwiger/gproc usually happens to be in sync. :) BR, Ulf W Ulf Wiger, CTO, Erlang Solutions, Ltd. http://erlang-solutions.com From moxford@REDACTED Tue Apr 12 00:09:59 2011 From: moxford@REDACTED (Mike Oxford) Date: Mon, 11 Apr 2011 15:09:59 -0700 Subject: [erlang-questions] Couple of questions ... Message-ID: Unused function warning ===================================== data_conn_make_inet_link(SrcIP, SrcPort, DstIP, DstPort) -> #inet_link{ src=#inet_src{ip=SrcIP, port=SrcPort}, dst=#inet_dst{ip=DstIP, port=DstPort}}. I want to put this in a "common header," but not every single file which uses the header will use this particular call. It's old getting spammed with warnings about this. It's poor to have to turn off warnings at a global level. May I propose prepending something to suppress warning about it not being used? Maybe using a leading "-"? or %ifdef/#ifdef#pragma-style preprocessor controls? -quiet-include("file"). ? -method()-> %% ignore "unused" warnings I see some discussion of this back around 2008, but I don't see any traction on it since. Anyone know if this was ever implemented in any form? "void" ===================================== If I do not care about the return value of a method, can I do something to tell that to the compiler? No reason to allocate return storage on the frame if I don't care about it anyway? Or is this too trivial in the scope of "Erlang copies everything everywhere" to be of consideration? _method()-> %% don't allocate storage or worry about returns Thanks! -mox -------------- next part -------------- An HTML attachment was scrubbed... URL: From jameschurchman@REDACTED Tue Apr 12 00:27:02 2011 From: jameschurchman@REDACTED (James Churchman) Date: Mon, 11 Apr 2011 23:27:02 +0100 Subject: [erlang-questions] Couple of questions ... In-Reply-To: References: Message-ID: <15DC8CCE-160D-4E54-99EB-3E508E5209DE@gmail.com> > Unused function warning : As a dirty hack, you could export the function that it's complaining about. That will solve the problem. The other option I can think of is to make a parse transform that removes the function. You could set an attribute like -remove([{ data_conn_make_inet_link,4 }), read it in a config file, hard code the fun/arity into the PT etc.. and then filter the AST before it gets parsed into the config file so thats its removed before the final compile. I assume that will remove the warning. I could code it for you if you like.. > "void" As far as my understanding, just placing 'ok' atom at the end of the function it the standard. I think that the overhead of doing this is so minuscule you will never notice. Altho having a void may sound a neat idea it would break erlang. Erlang always has defined behaviour under all circumstances, with this "void" under a buggy piece of code, that accidentally sets a var from your void function, there would either need to be a new type of error thrown, or worse still erlang would behave in an unpredictable manor. Erlang is designed to have predictable behaviour even under faulty erlang code :-) James On 11 Apr 2011, at 23:09, Mike Oxford wrote: > Unused function warning > ===================================== > data_conn_make_inet_link(SrcIP, SrcPort, DstIP, DstPort) -> > #inet_link{ src=#inet_src{ip=SrcIP, port=SrcPort}, dst=#inet_dst{ip=DstIP, port=DstPort}}. > > I want to put this in a "common header," but not every single file which uses the header will use > this particular call. > > It's old getting spammed with warnings about this. > It's poor to have to turn off warnings at a global level. > > May I propose prepending something to suppress warning about it not being used? Maybe > using a leading "-"? or %ifdef/#ifdef#pragma-style preprocessor controls? -quiet-include("file"). ? > > -method()-> %% ignore "unused" warnings > > I see some discussion of this back around 2008, but I don't see any traction on it since. Anyone > know if this was ever implemented in any form? > > > > "void" > ===================================== > If I do not care about the return value of a method, can I do something to tell that to the compiler? > No reason to allocate return storage on the frame if I don't care about it anyway? Or is this too trivial > in the scope of "Erlang copies everything everywhere" to be of consideration? > > _method()-> %% don't allocate storage or worry about returns > > > Thanks! > > -mox > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From moxford@REDACTED Tue Apr 12 00:29:50 2011 From: moxford@REDACTED (Mike Oxford) Date: Mon, 11 Apr 2011 15:29:50 -0700 Subject: [erlang-questions] Couple of questions ... In-Reply-To: <15DC8CCE-160D-4E54-99EB-3E508E5209DE@gmail.com> References: <15DC8CCE-160D-4E54-99EB-3E508E5209DE@gmail.com> Message-ID: Yep, but exporting it all over is just code-cruft. I'd like to avoid it if possible. On Mon, Apr 11, 2011 at 3:27 PM, James Churchman wrote: > > Unused function warning : > > > As a dirty hack, you could export the function that it's complaining about. > That will solve the problem. > > The other option I can think of is to make a parse transform that removes > the function. You could set an attribute like -remove([{ > data_conn_make_inet_link,4 }), read it in a config file, hard code the > fun/arity into the PT etc.. and then filter the AST before it gets parsed > into the config file so thats its removed before the final compile. I assume > that will remove the warning. I could code it for you if you like.. > > > "void" > > As far as my understanding, just placing 'ok' atom at the end of the > function it the standard. I think that the overhead of doing this is so > minuscule you will never notice. Altho having a void may sound a neat idea > it would break erlang. Erlang always has defined behaviour under all > circumstances, with this "void" under a buggy piece of code, that > accidentally sets a var from your void function, there would either need to > be a new type of error thrown, or worse still erlang would behave in an > unpredictable manor. Erlang is designed to have predictable behaviour even > under faulty erlang code :-) > > > James > > > On 11 Apr 2011, at 23:09, Mike Oxford wrote: > > > Unused function warning > > ===================================== > > data_conn_make_inet_link(SrcIP, SrcPort, DstIP, DstPort) -> > > #inet_link{ src=#inet_src{ip=SrcIP, port=SrcPort}, > dst=#inet_dst{ip=DstIP, port=DstPort}}. > > > > I want to put this in a "common header," but not every single file which > uses the header will use > > this particular call. > > > > It's old getting spammed with warnings about this. > > It's poor to have to turn off warnings at a global level. > > > > May I propose prepending something to suppress warning about it not being > used? Maybe > > using a leading "-"? or %ifdef/#ifdef#pragma-style preprocessor > controls? -quiet-include("file"). ? > > > > -method()-> %% ignore "unused" warnings > > > > I see some discussion of this back around 2008, but I don't see any > traction on it since. Anyone > > know if this was ever implemented in any form? > > > > > > > > "void" > > ===================================== > > If I do not care about the return value of a method, can I do something > to tell that to the compiler? > > No reason to allocate return storage on the frame if I don't care about > it anyway? Or is this too trivial > > in the scope of "Erlang copies everything everywhere" to be of > consideration? > > > > _method()-> %% don't allocate storage or worry about returns > > > > > > Thanks! > > > > -mox > > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jameschurchman@REDACTED Tue Apr 12 00:37:05 2011 From: jameschurchman@REDACTED (James Churchman) Date: Mon, 11 Apr 2011 23:37:05 +0100 Subject: [erlang-questions] Couple of questions ... In-Reply-To: References: <15DC8CCE-160D-4E54-99EB-3E508E5209DE@gmail.com> Message-ID: <67F2E24D-2A3C-4298-B1AC-8722636B73FB@gmail.com> well the norm would be to do the usual import() in just the modules you need it then :-) its not that much extra typing & keeps the code more understandable also how are you importing the code? if its an "include()" or "extends()" then can you specify the export in there? ( i have never tried ) On 11 Apr 2011, at 23:29, Mike Oxford wrote: > Yep, but exporting it all over is just code-cruft. I'd like to avoid it if possible. > > > On Mon, Apr 11, 2011 at 3:27 PM, James Churchman wrote: > > Unused function warning : > > > As a dirty hack, you could export the function that it's complaining about. That will solve the problem. > > The other option I can think of is to make a parse transform that removes the function. You could set an attribute like -remove([{ data_conn_make_inet_link,4 }), read it in a config file, hard code the fun/arity into the PT etc.. and then filter the AST before it gets parsed into the config file so thats its removed before the final compile. I assume that will remove the warning. I could code it for you if you like.. > > > "void" > > As far as my understanding, just placing 'ok' atom at the end of the function it the standard. I think that the overhead of doing this is so minuscule you will never notice. Altho having a void may sound a neat idea it would break erlang. Erlang always has defined behaviour under all circumstances, with this "void" under a buggy piece of code, that accidentally sets a var from your void function, there would either need to be a new type of error thrown, or worse still erlang would behave in an unpredictable manor. Erlang is designed to have predictable behaviour even under faulty erlang code :-) > > > James > > > On 11 Apr 2011, at 23:09, Mike Oxford wrote: > > > Unused function warning > > ===================================== > > data_conn_make_inet_link(SrcIP, SrcPort, DstIP, DstPort) -> > > #inet_link{ src=#inet_src{ip=SrcIP, port=SrcPort}, dst=#inet_dst{ip=DstIP, port=DstPort}}. > > > > I want to put this in a "common header," but not every single file which uses the header will use > > this particular call. > > > > It's old getting spammed with warnings about this. > > It's poor to have to turn off warnings at a global level. > > > > May I propose prepending something to suppress warning about it not being used? Maybe > > using a leading "-"? or %ifdef/#ifdef#pragma-style preprocessor controls? -quiet-include("file"). ? > > > > -method()-> %% ignore "unused" warnings > > > > I see some discussion of this back around 2008, but I don't see any traction on it since. Anyone > > know if this was ever implemented in any form? > > > > > > > > "void" > > ===================================== > > If I do not care about the return value of a method, can I do something to tell that to the compiler? > > No reason to allocate return storage on the frame if I don't care about it anyway? Or is this too trivial > > in the scope of "Erlang copies everything everywhere" to be of consideration? > > > > _method()-> %% don't allocate storage or worry about returns > > > > > > Thanks! > > > > -mox > > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From seanj@REDACTED Tue Apr 12 02:54:37 2011 From: seanj@REDACTED (seanj@REDACTED) Date: Mon, 11 Apr 2011 17:54:37 -0700 Subject: [erlang-questions] erlounging in seattle tomorrow @ Cortona Cafe Message-ID: When: April 12th 5-7pm @ Corona Cafe (upstairs) http://www.cortonacafe.com/ We will be talking over Erlang Factory SF 2011, Rebar and general Erlanging. Come one come all. Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: From yrashk@REDACTED Tue Apr 12 02:55:43 2011 From: yrashk@REDACTED (Yurii Rashkovskii) Date: Mon, 11 Apr 2011 17:55:43 -0700 Subject: [erlang-questions] Spawnfest: a 48 hour programming contest featuring Erlang Message-ID: Hi everybody, We're happy to announce that first Spawnfest (48 hour programming contest for Erlang, much like Rails Rumble and Node Knockout) is scheduled for 9th and 10th of July 2011. Our committee is currently working on competition rules and sponsors/prizes. We've secured some of the big names in the Erlang community as judges and planning to involve more judges so that every team gets fair review. We're very excited about this opportunity to show the world what Erlang/OTP is capable of! The contest is not limiting entrants to web applications, in fact, we'll be having nominees in different categories. You can register your team at http://spawnfest.com/ Feel free to post any question on the mailing list, we will be happy to address those. If you're interested in becoming a sponsor, please email me at yrashk at gmail.com; it could be a tremendous opportunity to expose your business. From moxford@REDACTED Tue Apr 12 03:06:23 2011 From: moxford@REDACTED (Mike Oxford) Date: Mon, 11 Apr 2011 18:06:23 -0700 Subject: [erlang-questions] gproc integration Message-ID: Is it better to run grpoc alongside or inside of an application? I don't know how they interact (re: VMs) and are there serious performance implications to just starting gproc app instead of having a supervisor inside my application start the gproc supervisor? Thanks! -mox -------------- next part -------------- An HTML attachment was scrubbed... URL: From mihai@REDACTED Tue Apr 12 05:39:33 2011 From: mihai@REDACTED (Mihai Balea) Date: Mon, 11 Apr 2011 23:39:33 -0400 Subject: [erlang-questions] gproc integration In-Reply-To: References: Message-ID: <69D79EB2-EA3B-4CF4-AF15-FC83198B9F22@hates.ms> On Apr 11, 2011, at 9:06 PM, Mike Oxford wrote: > Is it better to run grpoc alongside or inside of an application? > > I don't know how they interact (re: VMs) and are there serious performance implications to just starting gproc app instead of having a supervisor inside my application start the gproc supervisor? I'm not quite sure why you would consider starting gproc from inside your app... I don't believe there are any benefits to it and it certainly goes against the customary way of doing things. Mihai From kenrobinsonster@REDACTED Tue Apr 12 06:24:58 2011 From: kenrobinsonster@REDACTED (Ken Robinson) Date: Tue, 12 Apr 2011 14:24:58 +1000 Subject: [erlang-questions] Type and Opaque - Defining size for a type Message-ID: Hi All, I was wondering if one can define a type to be a certain size, say an integer() to be an unsigned byte (16 bits). This is all I have -opaque u16int():: bitstring() -export_type([u16int/0]). Any help would be greatly appreciated. -- regards, Ken Robinson Mob +61438681120 Home +61738523767 From ulf.wiger@REDACTED Tue Apr 12 09:21:41 2011 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Tue, 12 Apr 2011 09:21:41 +0200 Subject: [erlang-questions] gproc integration In-Reply-To: References: Message-ID: <241B6E0E-E0E7-4A25-9153-7AD73618EB6C@erlang-solutions.com> There are no performance implications, and if you want to run gproc as an included application, I believe that you can. One thing to keep in mind, though, is that the current version checks for the gproc_dist environment variable in the "current application", which would not be gproc if it is included inside another application. One could consider this a bug, or alternatively a 'feature' which ought to be documented. :) If you don't use global gproc, I don't think this matters, as the default is to run local-only. Having said this, I see no benefit of including gproc, as it is meant to run on each node and regarded as a "system component". I recommend keeping it as a top application. BR, Ulf W On 12 Apr 2011, at 03:06, Mike Oxford wrote: > Is it better to run grpoc alongside or inside of an application? > > I don't know how they interact (re: VMs) and are there serious performance implications to just starting gproc app instead of having a supervisor inside my application start the gproc supervisor? > > Thanks! > > -mox > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions Ulf Wiger, CTO, Erlang Solutions, Ltd. http://erlang-solutions.com From ulf.wiger@REDACTED Tue Apr 12 09:27:31 2011 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Tue, 12 Apr 2011 09:27:31 +0200 Subject: [erlang-questions] gen_server & trap_exit In-Reply-To: References: Message-ID: <5C10913C-98AB-4870-B22E-B598987D00E4@erlang-solutions.com> Hi Roberto, You are correct, and you're definitely not the first to be stumped by this. Gen_server handles exits from the parent in a special way, assuming that the parent is a supervisor. If the server does *not* trap exits, obviously it doesn't matter, but even when trapping exits, the gen_server will unconditionally exit if it gets an exit from the parent. In the special case of starting gen_servers from the shell, the shell process is of course more likely to crash than the server itself, and that's exactly what's happening here. If the module supports a start() function without linking, you might want to use that, or calling unlink/1 after starting the server. BR, Ulf W On 9 Apr 2011, at 14:27, Roberto Ostinelli wrote: > Dear list, > > I start a gen_server and in the initialization i set process_flag(trap_exit, true), obviously to allow the gen_server to catch child processes crashes. > > Whenever i start this gen_server from the shell and then issue an error in the shell, the gen_server exits too: > > 12>abc(). > ** exception error: undefined shell command abc/0 > > =ERROR REPORT==== 9-Apr-2011::14:16:51 === > ** Generic server testserver terminating > ** Last message in was {'EXIT',<0.272.0>, > {{shell_undef,abc,0}, > [{shell,shell_undef,2}, > {erl_eval,local_func,5}, > {shell,exprs,7}, > {shell,eval_exprs,7}, > {shell,eval_loop,3}]}} > > I believe that this behavior of the server exiting because its parent exits is supposed to happen, since trap_exit doesn't let the gen_server trap its parent process exiting. What I believe happens is that the shell 'crashes' and so does the child process 'testserver'. > > Am I correct in my assumptions, or am I missing a fundamental point here? > > Thank you, > > r. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions Ulf Wiger, CTO, Erlang Solutions, Ltd. http://erlang-solutions.com From alavrik@REDACTED Tue Apr 12 09:30:19 2011 From: alavrik@REDACTED (Anton Lavrik) Date: Tue, 12 Apr 2011 02:30:19 -0500 Subject: [erlang-questions] [ANN] Piqi-0.5.5 release: Multi-format data serialization and calling Erlang functions over HTTP Message-ID: Hello all, It is my pleasure to announce several new Piqi features: With this release, Piqi adds the ability to serialize/deserialize data in JSON, XML, Protocol Buffers and Piq data formats. It provides a universal serialization interface for each user-defined data type and an additional parameter controls which format to use. This is how it looks like: https://github.com/alavrik/piqi/blob/master/examples/erlang/io_json_xml_pb.erl Of course, it is unlikely that in practice one needs that many formats at once. But even if we look at JSON serialization, any other approach that I'm aware of involves writing additional code (sometimes, a lot of code!) to convert JSON AST into Erlang records and the other way around. In contrast, Piqi does all that automatically and in addition performs data validation. Another new piece is called Piqi-RPC. It gives Erlang developers a convenient and reliable way to connect services written in Erlang with non-Erlang clients using JSON, XML and Protocol Buffers over plain HTTP. In addition to HTTP interface, it includes a command-line client for calling remote Erlang functions using idiomatic command-line interface (still over HTTP). The client even prints command-line help about remote functions! Basically, Piqi-RPC acts as an HTTP gateway for Erlang functions, taking care of parsing and validating input, generating output in requested format, communicating over HTTP, parsing and validating command-line options, etc. When Erlang implementation function is called, it doesn't have to deal with all that stuff. Even more, -- it doesn't know anything about what's happening under the hood and always works with input and output represented as native Erlang data structures. You can find more information about the project and the recent additions here: http://piqi.org/blog/2011/04/12/piqi-0-5-5-released/ Comments, suggestions and pull requests are very welcome! Thanks, Anton -------------- next part -------------- An HTML attachment was scrubbed... URL: From attila.r.nohl@REDACTED Tue Apr 12 10:44:36 2011 From: attila.r.nohl@REDACTED (Attila Rajmund Nohl) Date: Tue, 12 Apr 2011 10:44:36 +0200 Subject: [erlang-questions] Couple of questions ... In-Reply-To: References: Message-ID: 2011/4/12, Mike Oxford : > Unused function warning > ===================================== > data_conn_make_inet_link(SrcIP, SrcPort, DstIP, DstPort) -> > #inet_link{ src=#inet_src{ip=SrcIP, port=SrcPort}, > dst=#inet_dst{ip=DstIP, port=DstPort}}. > > I want to put this in a "common header," but not every single file which > uses the header will use > this particular call. Why do you want to put a function definition into header file? Either put it into a library module or write a macro instead of a function. From nox@REDACTED Tue Apr 12 12:16:00 2011 From: nox@REDACTED (Anthony Ramine) Date: Tue, 12 Apr 2011 12:16:00 +0200 Subject: [erlang-questions] Type and Opaque - Defining size for a type In-Reply-To: References: Message-ID: <1263EB78-BE54-4AA5-8A93-E4EFAAD7A97C@dev-extend.eu> -opaque u16int() :: 1..(1 bsl 16 - 1). Le 12 avr. 2011 ? 06:24, Ken Robinson a ?crit : > Hi All, > I was wondering if one can define a type to be a certain size, say an > integer() to be an unsigned byte (16 bits). > > This is all I have > -opaque u16int():: bitstring() > -export_type([u16int/0]). > > Any help would be greatly appreciated. > > -- > regards, > Ken Robinson > Mob +61438681120 > Home +61738523767 > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -- Anthony Ramine Dev:Extend http://dev-extend.eu From kenrobinsonster@REDACTED Tue Apr 12 15:12:56 2011 From: kenrobinsonster@REDACTED (Ken Robinson) Date: Tue, 12 Apr 2011 23:12:56 +1000 Subject: [erlang-questions] Type and Opaque - Defining size for a type In-Reply-To: <1263EB78-BE54-4AA5-8A93-E4EFAAD7A97C@dev-extend.eu> References: <1263EB78-BE54-4AA5-8A93-E4EFAAD7A97C@dev-extend.eu> Message-ID: Ah ha. I see it now in the doco Integer :: integer() | Erlang_Integer %% ..., -1, 0, 1, ... 42 ... | Erlang_Integer..Erlang_Integer %% specifies an integer range many thanks. Ken. On Tue, Apr 12, 2011 at 8:16 PM, Anthony Ramine wrote: > -opaque u16int() :: 1..(1 bsl 16 - 1). > > Le 12 avr. 2011 ? 06:24, Ken Robinson a ?crit : > >> Hi All, >> I was wondering if one can define a type to be a certain size, say an >> integer() to be an unsigned byte (16 bits). >> >> This is all I have >> -opaque u16int():: bitstring() >> -export_type([u16int/0]). >> >> Any help would be greatly appreciated. >> >> -- >> regards, >> Ken Robinson >> Mob +61438681120 >> Home +61738523767 >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions > > -- > Anthony Ramine > Dev:Extend > http://dev-extend.eu > > > > > -- regards, Ken Robinson Mob +61438681120 Home +61738523767 From james.hague@REDACTED Tue Apr 12 16:11:51 2011 From: james.hague@REDACTED (James Hague) Date: Tue, 12 Apr 2011 09:11:51 -0500 Subject: [erlang-questions] Couple of questions ... In-Reply-To: References: Message-ID: > It's old getting spammed with warnings about this. > It's poor to have to turn off warnings at a global level. > May I propose prepending something to suppress warning about it not being > used? Quoting from the compiler manual, there's an option to suppress this warning for individual functions: {nowarn_unused_function, FAs} Turns off warnings for unused local functions as nowarn_unused_function but only for the mentioned local functions. FAs is a tuple {Name,Arity} or a list of such tuples. So you can just put lines like this in your included header: -compile({nowarn_unused_function, data_conn_make_inet_link/4}). From contact@REDACTED Tue Apr 12 17:49:16 2011 From: contact@REDACTED (Evax Software) Date: Tue, 12 Apr 2011 17:49:16 +0200 Subject: [erlang-questions] [ANN] kerl Erlang/OTP installation management script Message-ID: <1302623356.3302.114.camel@thomas-laptop> Hi all, kerl is a script allowing the easy management of sandboxed Erlang/OTP installations on Unix systems. Among the features: * shell agnostic * fetches and builds Erlang/OTP from the official releases or from git * native agner support * easy and fast sandbox creation * easy switching between different sandboxes (similar to Python's virtualenv) Check the project page: https://github.com/evax/kerl Feedback is welcome ! Evax From robert.virding@REDACTED Tue Apr 12 18:43:15 2011 From: robert.virding@REDACTED (Robert Virding) Date: Tue, 12 Apr 2011 16:43:15 +0000 (GMT) Subject: [erlang-questions] [ANN] misultin v0.7 In-Reply-To: Message-ID: <910603547.89251302626595428.JavaMail.root@zimbra> Roberto, I am only a casual writer of webservers and Misultin has worked well so far. It has been easy to use and has had sufficient features for what I need. BUT couldn't you make a misultin-- without parametrized modules using only standard erlang for us users who prefer classic Erlang? :-) Robert ----- "Roberto Ostinelli" wrote: > dear list, > > misultin v0.7 is now out. changelog is: > > - added max_connections options parameter, which specifies maximum concurrent open connections > accepted by the server > - added post_max_size options parameter, which sets the maximum size of POST data > - added get_url_max_size options parameter, which sets the maximum length of URI > - added CHUNKED support, both for incoming requests and outgoing responses [thanks to yrashk > suggestion] > - added trapping of client closing a browser in Comet applications [thanks to yrashk] > - added SSL support for websockets [enhancement track #25, thanks to viplifes] > - Misultin can now be started without a registered name or with a different name, so that multiple > versions of misultin can be started on a single node > - added support for IP address specified in tuple format [thanks to okeuday suggestion] > - added support to extract plain uri unquoted as a list() [thanks to okeuday] > - added Comet Long Polling example > - added Comet iFrame example > - added the killing of alive processes on server shutdown > - the GET uri parameters are now also available on POST requests > - added custom headers on file sending to browser [thanks to josevalim] > - additional minor adjustments > > https://github.com/ostinelli/misultin > > cheers, > > r. > > _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From roberto@REDACTED Tue Apr 12 18:53:24 2011 From: roberto@REDACTED (Roberto Ostinelli) Date: Tue, 12 Apr 2011 18:53:24 +0200 Subject: [erlang-questions] [ANN] misultin v0.7 In-Reply-To: <910603547.89251302626595428.JavaMail.root@zimbra> References: <910603547.89251302626595428.JavaMail.root@zimbra> Message-ID: hello robert, i've had similar requests on #erlang and this is definitely on the todo list. i will of course need to support backwards compatibility and i need to spend some time in figuring out what is the best way to do so. if you feel like sharing any pointers, i'll obviously be very glad to read from you :) r. 2011/4/12 Robert Virding > Roberto, > > I am only a casual writer of webservers and Misultin has worked well so > far. It has been easy to use and has had sufficient features for what I > need. BUT couldn't you make a misultin-- without parametrized modules using > only standard erlang for us users who prefer classic Erlang? :-) > > Robert > -------------- next part -------------- An HTML attachment was scrubbed... URL: From spawn.think@REDACTED Tue Apr 12 19:12:24 2011 From: spawn.think@REDACTED (Ahmed Omar) Date: Tue, 12 Apr 2011 19:12:24 +0200 Subject: [erlang-questions] [ANN] kerl Erlang/OTP installation management script In-Reply-To: <1302623356.3302.114.camel@thomas-laptop> References: <1302623356.3302.114.camel@thomas-laptop> Message-ID: very nice! Will give it a try! On Tue, Apr 12, 2011 at 5:49 PM, Evax Software wrote: > Hi all, > > kerl is a script allowing the easy management of sandboxed Erlang/OTP > installations on Unix systems. > > Among the features: > * shell agnostic > * fetches and builds Erlang/OTP from the official releases or from git > * native agner support > * easy and fast sandbox creation > * easy switching between different sandboxes (similar to Python's > virtualenv) > > Check the project page: > https://github.com/evax/kerl > > Feedback is welcome ! > > Evax > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -- Best Regards, - Ahmed Omar http://nl.linkedin.com/in/adiaa Follow me on twitter @spawn_think -------------- next part -------------- An HTML attachment was scrubbed... URL: From yrashk@REDACTED Tue Apr 12 19:35:27 2011 From: yrashk@REDACTED (Yurii Rashkovskii) Date: Tue, 12 Apr 2011 10:35:27 -0700 (PDT) Subject: [erlang-questions] [ANN] misultin v0.7 In-Reply-To: References: <910603547.89251302626595428.JavaMail.root@zimbra> Message-ID: <15b5c7ec-ad56-4090-92b5-ed6f27cc9ea1@l14g2000pre.googlegroups.com> Roberto, $ cat misultin_req.erl -module(misultin_req). -export([ok/1]). -record(misultin_req, {req,socket_pid}). ok(#misultin_req{req = Req}) -> io:format("got req: ~p~n",[Req]). $ erl Erlang R14B02 (erts-5.8.3) [source] [64-bit] [smp:2:2] [rq:2] [async- threads:0] [hipe] [kernel-poll:false] Eshell V5.8.3 (abort with ^G) 1> Req = {misultin_req, request_stuff, self()}. {misultin_req,request_stuff,<0.31.0>} 2> misultin_req:ok(Req). got req: request_stuff ok 3> Req:ok(). got req: request_stuff ok Roberto Ostinelli wrote: > hello robert, > > i've had similar requests on #erlang and this is definitely on the todo > list. > > i will of course need to support backwards compatibility and i need to spend > some time in figuring out what is the best way to do so. if you feel like > sharing any pointers, i'll obviously be very glad to read from you :) > > r. > > > 2011/4/12 Robert Virding > > > Roberto, > > > > I am only a casual writer of webservers and Misultin has worked well so > > far. It has been easy to use and has had sufficient features for what I > > need. BUT couldn't you make a misultin-- without parametrized modules using > > only standard erlang for us users who prefer classic Erlang? :-) > > > > Robert > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From jwest@REDACTED Tue Apr 12 19:49:03 2011 From: jwest@REDACTED (Jordan West) Date: Tue, 12 Apr 2011 10:49:03 -0700 Subject: [erlang-questions] [ANN] kerl Erlang/OTP installation management script In-Reply-To: References: <1302623356.3302.114.camel@thomas-laptop> Message-ID: Really nice stuff. Reminds me of Ruby Version Manager, which is something I was hoping for in Erlang. I would suggest looking into some of RVMs features. Dependency sets (like RVMs gemsets) would be a nice touch on top of the ability to sandbox agner per OTP build. Jordan On Tue, Apr 12, 2011 at 10:12 AM, Ahmed Omar wrote: > very nice! Will give it a try! > > > On Tue, Apr 12, 2011 at 5:49 PM, Evax Software wrote: > >> Hi all, >> >> kerl is a script allowing the easy management of sandboxed Erlang/OTP >> installations on Unix systems. >> >> Among the features: >> * shell agnostic >> * fetches and builds Erlang/OTP from the official releases or from git >> * native agner support >> * easy and fast sandbox creation >> * easy switching between different sandboxes (similar to Python's >> virtualenv) >> >> Check the project page: >> https://github.com/evax/kerl >> >> Feedback is welcome ! >> >> Evax >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> > > > > -- > Best Regards, > - Ahmed Omar > http://nl.linkedin.com/in/adiaa > Follow me on twitter > @spawn_think > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From roberto@REDACTED Tue Apr 12 20:10:06 2011 From: roberto@REDACTED (Roberto Ostinelli) Date: Tue, 12 Apr 2011 20:10:06 +0200 Subject: [erlang-questions] [ANN] misultin v0.7 In-Reply-To: <15b5c7ec-ad56-4090-92b5-ed6f27cc9ea1@l14g2000pre.googlegroups.com> References: <910603547.89251302626595428.JavaMail.root@zimbra> <15b5c7ec-ad56-4090-92b5-ed6f27cc9ea1@l14g2000pre.googlegroups.com> Message-ID: hi yurii, robert, i confirm that misultin 0.7.1 will have: . support for both pmods and pure erlang; . support for HEAD, PUT and DELETE methods. r. 2011/4/12 Yurii Rashkovskii > Roberto, > > $ cat misultin_req.erl > -module(misultin_req). > -export([ok/1]). > -record(misultin_req, {req,socket_pid}). > > ok(#misultin_req{req = Req}) -> > io:format("got req: ~p~n",[Req]). > > $ erl > Erlang R14B02 (erts-5.8.3) [source] [64-bit] [smp:2:2] [rq:2] [async- > threads:0] [hipe] [kernel-poll:false] > > Eshell V5.8.3 (abort with ^G) > 1> Req = {misultin_req, request_stuff, self()}. > {misultin_req,request_stuff,<0.31.0>} > 2> misultin_req:ok(Req). > got req: request_stuff > ok > 3> Req:ok(). > got req: request_stuff > ok > > Roberto Ostinelli wrote: > > hello robert, > > > > i've had similar requests on #erlang and this is definitely on the todo > > list. > > > > i will of course need to support backwards compatibility and i need to > spend > > some time in figuring out what is the best way to do so. if you feel like > > sharing any pointers, i'll obviously be very glad to read from you :) > > > > r. > > > > > > 2011/4/12 Robert Virding > > > > > Roberto, > > > > > > I am only a casual writer of webservers and Misultin has worked well so > > > far. It has been easy to use and has had sufficient features for what I > > > need. BUT couldn't you make a misultin-- without parametrized modules > using > > > only standard erlang for us users who prefer classic Erlang? :-) > > > > > > Robert > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From roberto@REDACTED Tue Apr 12 21:06:40 2011 From: roberto@REDACTED (Roberto Ostinelli) Date: Tue, 12 Apr 2011 21:06:40 +0200 Subject: [erlang-questions] [ANN] misultin v0.7 In-Reply-To: <910603547.89251302626595428.JavaMail.root@zimbra> References: <910603547.89251302626595428.JavaMail.root@zimbra> Message-ID: 2011/4/12 Robert Virding > Roberto, > > I am only a casual writer of webservers and Misultin has worked well so > far. It has been easy to use and has had sufficient features for what I > need. BUT couldn't you make a misultin-- without parametrized modules using > only standard erlang for us users who prefer classic Erlang? :-) > > Robert > Hi all, you may now decide whether you use parametrized modules in Misultin or not. If you decide to use them, you simply go by the current examples. If you decide not to use them, you can refer to the modules 'misultin_req' and 'misultin_ws' for request and websockets respectively. For example, the hello world callback function for parametrized modules is: handle_http(Req) -> Req:ok("Hello World."). The same without parametrized modules will go: handle_http(Req) -> misultin_req:ok("Hello World.", Req). Hopefully this will please more than one (Robert, I'm looking at you :) ). It is currently up in master, which is 0.7.1-dev: https://github.com/ostinelli/misultin thank you to yrashk, nox and essen. Any comments welcome. r. -------------- next part -------------- An HTML attachment was scrubbed... URL: From essen@REDACTED Tue Apr 12 22:02:55 2011 From: essen@REDACTED (=?ISO-8859-1?Q?Lo=EFc_Hoguin?=) Date: Tue, 12 Apr 2011 22:02:55 +0200 Subject: [erlang-questions] [ANN] misultin v0.7 In-Reply-To: References: <910603547.89251302626595428.JavaMail.root@zimbra> Message-ID: <4DA4AFEF.7060506@dev-extend.eu> On 04/12/2011 09:06 PM, Roberto Ostinelli wrote: > you may now decide whether you use parametrized modules in Misultin or not. > [...] > > thank you to yrashk, nox and essen. our team 1 - pmods 0 Congratulations on leaving the dark side. ;) -- Lo?c Hoguin Dev:Extend From James@REDACTED Wed Apr 13 04:22:27 2011 From: James@REDACTED (Mode7James) Date: Tue, 12 Apr 2011 19:22:27 -0700 (PDT) Subject: [erlang-questions] Erlang beginner questions Message-ID: <1302661347349-3446106.post@n4.nabble.com> I'm just learning Erlang, so please bear with me. I've read Erlang & OTP in Action, and am currently reading through Joe Armstrong's book right now. That said, I am currently a Sr. Flash developer, so my background is still a little fresh concerning programming concepts that I'm sure most of you are already well-versed in. I want to build a server for mobile & flash multiplayer games that utilizes a secure TCP connection to authenticate people, but then opens a UDP port to send/receive information. I decided to post here because all I need is a little kick in the right direction. I figured my first goal would be to set up a simple server that is able to send/receive from a very simple client, written in Objective-C. This would allow the user to drag a ball around the screen, essentially sending the coordinates of the user's input to the server, it checks with the basic mechanics, and sends back so many frames per second the location of an on-screen ball. My goal is to incorporate simple physics, but I really want to start small and get off on the right foot. Would someone please walk me through doing this the proper way, using OTP standards? I want to make sure that I don't create any bad habits, and so far I have understood the books I've read. Reading and creating a fully working example is two completely different things though. Thanks so much in advance! -- View this message in context: http://erlang.2086793.n4.nabble.com/Erlang-beginner-questions-tp3446106p3446106.html Sent from the Erlang Questions mailing list archive at Nabble.com. From moxford@REDACTED Wed Apr 13 05:53:41 2011 From: moxford@REDACTED (Mike Oxford) Date: Tue, 12 Apr 2011 20:53:41 -0700 Subject: [erlang-questions] Erlang beginner questions In-Reply-To: <1302661347349-3446106.post@n4.nabble.com> References: <1302661347349-3446106.post@n4.nabble.com> Message-ID: http://erlagner.org/ There's a few projects in there which might be of help to you. If you search for "gen_tcp" you'll get some good information as well. http://20bits.com/articles/erlang-a-generalized-tcp-server/ Also, http://learnyousomeerlang.com/ is a very good resource as well. Gluck! -mox On Tue, Apr 12, 2011 at 7:22 PM, Mode7James wrote: > I'm just learning Erlang, so please bear with me. I've read Erlang & OTP > in > Action, and am currently reading through Joe Armstrong's book right now. > That said, I am currently a Sr. Flash developer, so my background is still > a > little fresh concerning programming concepts that I'm sure most of you are > already well-versed in. > > I want to build a server for mobile & flash multiplayer games that utilizes > a secure TCP connection to authenticate people, but then opens a UDP port > to > send/receive information. > > I decided to post here because all I need is a little kick in the right > direction. I figured my first goal would be to set up a simple server that > is able to send/receive from a very simple client, written in Objective-C. > This would allow the user to drag a ball around the screen, essentially > sending the coordinates of the user's input to the server, it checks with > the basic mechanics, and sends back so many frames per second the location > of an on-screen ball. > > My goal is to incorporate simple physics, but I really want to start small > and get off on the right foot. Would someone please walk me through doing > this the proper way, using OTP standards? I want to make sure that I don't > create any bad habits, and so far I have understood the books I've read. > Reading and creating a fully working example is two completely different > things though. > > Thanks so much in advance! > > -- > View this message in context: > http://erlang.2086793.n4.nabble.com/Erlang-beginner-questions-tp3446106p3446106.html > Sent from the Erlang Questions mailing list archive at Nabble.com. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From James@REDACTED Wed Apr 13 09:17:46 2011 From: James@REDACTED (Mode7James) Date: Wed, 13 Apr 2011 00:17:46 -0700 (PDT) Subject: [erlang-questions] Erlang beginner questions In-Reply-To: References: <1302661347349-3446106.post@n4.nabble.com> Message-ID: <1302679066266-3446453.post@n4.nabble.com> Thanks Mike! I discovered learnyousomeerlang.com today at work and have been reading through it. That TCP tutorial is also good. I guess it's just a bit overwhelming, trying to put it all together. I read through the TCP tutorial by 20bits tonight and will try to get it working tomorrow after work. Please bear with me - these are all questions I've had while reading and researching Erlang in my spare time the last couple months. 1) gen_server is a behavior. It's a little confusing that gen_udp and gen_tcp are both modules, but use the same naming conventions. I've seen quite a few documents on how one uses "gen_server" as a behavior - is there any that actually show what the text file looks like? Can I create my own behaviors? I come from a flash background (Java) so I'm very familiar with interfaces. Can one module implement multiple behaviors, or is it only one-to-one direct relationship? Is there somewhere that I can see the complete master list of built-in OTP behaviors and what they do? 2) In the 20bits article, how is the port number generated? Are port numbers unique to an application, or are there different port numbers for different protocols? Is this secure? How do Erlang services deal with DDOS attacks? Are there any tried-and-true methods that are used? 3) Can someone log in via TCP connection, authenticate credentials upgrading to SSL, and then also open a UDP connection for the gameplay mechanics? 4) I've read that distributed Erlang is using "all or nothing" security, ie nodes with access can essentially do whatever they want. Is there a way to keep a service running on a dedicated server, and remotely hotswap code via my macbook? Any examples of this being done? Thanks for putting up with my questions. :) -- View this message in context: http://erlang.2086793.n4.nabble.com/Erlang-beginner-questions-tp3446106p3446453.html Sent from the Erlang Questions mailing list archive at Nabble.com. From ekeroth.christoffer@REDACTED Wed Apr 13 11:08:45 2011 From: ekeroth.christoffer@REDACTED (JohnyTex) Date: Wed, 13 Apr 2011 02:08:45 -0700 (PDT) Subject: [erlang-questions] Trouble with Erlang's lenient comparisons Message-ID: <8c056228-a280-41e9-a6b0-20dd10f4b71f@gu8g2000vbb.googlegroups.com> Hello! :) I'm a newbie Erlang programmer, and I've really liked my experience so far. However, I've made mistakes related to Erlang's type system a couple of times now, more specifically the fact that you can compare different types with each other without Erlang complaining. I've inherited someone else's code base; sometimes I forget that a function returns a tuple and I up comparing it with an integer or similar, and get weird behaviour and hard-to-find bugs as a result. What's the best way to prevent this? I will try writing some unit tests later today with EUnit, and I'm generating PLTs for Dialyzer as I write this, but I was wondering if there are any other tools or "best practices" that could help me to write more "type safe" code? Thanks in advance! :) From spawn.think@REDACTED Wed Apr 13 11:17:09 2011 From: spawn.think@REDACTED (Ahmed Omar) Date: Wed, 13 Apr 2011 11:17:09 +0200 Subject: [erlang-questions] Trouble with Erlang's lenient comparisons In-Reply-To: <8c056228-a280-41e9-a6b0-20dd10f4b71f@gu8g2000vbb.googlegroups.com> References: <8c056228-a280-41e9-a6b0-20dd10f4b71f@gu8g2000vbb.googlegroups.com> Message-ID: Using Typer and Dialyzer is usually what you u need http://www.erlang.org/doc/reference_manual/typespec.html#id72693 On Wed, Apr 13, 2011 at 11:08 AM, JohnyTex wrote: > Hello! :) > I'm a newbie Erlang programmer, and I've really liked my experience so > far. However, I've made mistakes related to Erlang's type system a > couple of times now, more specifically the fact that you can compare > different types with each other without Erlang complaining. > > I've inherited someone else's code base; sometimes I forget that a > function returns a tuple and I up comparing it with an integer or > similar, and get weird behaviour and hard-to-find bugs as a result. > > What's the best way to prevent this? I will try writing some unit > tests later today with EUnit, and I'm generating PLTs for Dialyzer as > I write this, but I was wondering if there are any other tools or > "best practices" that could help me to write more "type safe" code? > > Thanks in advance! :) > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -- Best Regards, - Ahmed Omar http://nl.linkedin.com/in/adiaa Follow me on twitter @spawn_think -------------- next part -------------- An HTML attachment was scrubbed... URL: From gordon@REDACTED Wed Apr 13 12:27:34 2011 From: gordon@REDACTED (Gordon Guthrie) Date: Wed, 13 Apr 2011 11:27:34 +0100 Subject: [erlang-questions] Trouble with Erlang's lenient comparisons In-Reply-To: <8c056228-a280-41e9-a6b0-20dd10f4b71f@gu8g2000vbb.googlegroups.com> References: <8c056228-a280-41e9-a6b0-20dd10f4b71f@gu8g2000vbb.googlegroups.com> Message-ID: > I've inherited someone else's code base; sometimes I forget that a > function returns a tuple and I up comparing it with an integer or > similar, and get weird behaviour and hard-to-find bugs as a result. The key here is always to check return types whenever you call a function. You should be thinking 'if there is an error how do I make it appear as quickly as possible?'. So with function returns you don't want to pass them round in a mush of generic variables until the error surfaces 20 fn calls from when it appeared. Also check for bad input to functions by using guards like: fun(A, B, C) when is_list(A), is_integer(B), is_record(C, recC) -> This will force errors to appear quicker if you do have a mushy untyped variable error. Always code the happy path and make everything else an error. If a fn is designed as the second paramter should be an integer and not a float then use pattern matching/guards to make it so... Use the dialyzer to pick up cases when you have let this sort of thing happen, and write specs to tell dialyzer, yourself and your co-workers you intentions with functions: http://www.erlang.org/doc/reference_manual/typespec.html Gordon On 13 April 2011 10:08, JohnyTex wrote: > Hello! :) > I'm a newbie Erlang programmer, and I've really liked my experience so > far. However, I've made mistakes related to Erlang's type system a > couple of times now, more specifically the fact that you can compare > different types with each other without Erlang complaining. > > I've inherited someone else's code base; sometimes I forget that a > function returns a tuple and I up comparing it with an integer or > similar, and get weird behaviour and hard-to-find bugs as a result. > > What's the best way to prevent this? I will try writing some unit > tests later today with EUnit, and I'm generating PLTs for Dialyzer as > I write this, but I was wondering if there are any other tools or > "best practices" that could help me to write more "type safe" code? > > Thanks in advance! :) > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -- Gordon Guthrie CEO hypernumbers http://hypernumbers.com t: hypernumbers +44 7776 251669 From kostis@REDACTED Wed Apr 13 12:36:38 2011 From: kostis@REDACTED (Kostis Sagonas) Date: Wed, 13 Apr 2011 13:36:38 +0300 Subject: [erlang-questions] Trouble with Erlang's lenient comparisons In-Reply-To: References: <8c056228-a280-41e9-a6b0-20dd10f4b71f@gu8g2000vbb.googlegroups.com> Message-ID: <4DA57CB6.7030100@cs.ntua.gr> Gordon Guthrie wrote: >... > > Also check for bad input to functions by using guards like: > > fun(A, B, C) when is_list(A), is_integer(B), is_record(C, recC) -> The following is a bit pedantic, but please do not offer use of the is_record guard (esp. the one with arity two instead of three) as advice to newcomers. I suggest that you try to forget about this guard's existence; the only place where this guard is possibly needed is in or/orelse contexts. The above code is written better using pattern matching, as in: fun(A, B, #recC{} = C) when is_list(A), is_integer(B) -> Kostis From hm@REDACTED Wed Apr 13 13:16:21 2011 From: hm@REDACTED (=?ISO-8859-1?Q?H=E5kan_Mattsson?=) Date: Wed, 13 Apr 2011 13:16:21 +0200 Subject: [erlang-questions] Trouble with Erlang's lenient comparisons In-Reply-To: <4DA57CB6.7030100@cs.ntua.gr> References: <8c056228-a280-41e9-a6b0-20dd10f4b71f@gu8g2000vbb.googlegroups.com> <4DA57CB6.7030100@cs.ntua.gr> Message-ID: When you discourage one way of writing code and claim that another way is better you ought to motivate why. /H?kan On Wed, Apr 13, 2011 at 12:36 PM, Kostis Sagonas wrote: > Gordon Guthrie wrote: >> >> ... >> >> Also check for bad input to functions by using guards like: >> >> fun(A, B, C) when is_list(A), is_integer(B), is_record(C, recC) -> > > The following is a bit pedantic, but please do not offer use of the > is_record guard (esp. the one with arity two instead of three) as advice to > newcomers. ?I suggest that you try to forget about this guard's existence; > the only place where this guard is possibly needed is in or/orelse contexts. > > The above code is written better using pattern matching, as in: > > ?fun(A, B, #recC{} = C) when is_list(A), is_integer(B) -> From torben.lehoff@REDACTED Wed Apr 13 13:26:58 2011 From: torben.lehoff@REDACTED (Torben Hoffmann) Date: Wed, 13 Apr 2011 13:26:58 +0200 Subject: [erlang-questions] Trouble with Erlang's lenient comparisons In-Reply-To: References: <8c056228-a280-41e9-a6b0-20dd10f4b71f@gu8g2000vbb.googlegroups.com> <4DA57CB6.7030100@cs.ntua.gr> Message-ID: >From a practical stand point I agree with Kostis. When we started doing Erlang we used a lot of is_record/2 guards - that generally makes the code a lot harder to understand, so we dropped that as we threw away our imperative inheritance. And the minute you need to take a parameter out of the record it will be done with the pattern matching anyway, which makes it easier to make changes in the code. One learning here: try to do the pattern matching on fields only in the cases where it is used to pick between different function clauses. It makes it easier to figure out what is controlling the flow of execution and what is merely taken out of the parameters to be used as input elsewhere. We had a lot of functions that pattern matched a lot of fields in a record, but only one of the fields were used to control the flow of execution. It was more clear to do a R#rec.field1 in the function code for the other fields. But it is a matter of style, of course... Cheers, Torben 2011/4/13 H?kan Mattsson > When you discourage one way of writing code and claim that another way > is better you ought to motivate why. > > /H?kan > > On Wed, Apr 13, 2011 at 12:36 PM, Kostis Sagonas > wrote: > > Gordon Guthrie wrote: > >> > >> ... > >> > >> Also check for bad input to functions by using guards like: > >> > >> fun(A, B, C) when is_list(A), is_integer(B), is_record(C, recC) -> > > > > The following is a bit pedantic, but please do not offer use of the > > is_record guard (esp. the one with arity two instead of three) as advice > to > > newcomers. I suggest that you try to forget about this guard's > existence; > > the only place where this guard is possibly needed is in or/orelse > contexts. > > > > The above code is written better using pattern matching, as in: > > > > fun(A, B, #recC{} = C) when is_list(A), is_integer(B) -> > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -- http://www.linkedin.com/in/torbenhoffmann -------------- next part -------------- An HTML attachment was scrubbed... URL: From dsc@REDACTED Wed Apr 13 13:44:50 2011 From: dsc@REDACTED (Dave Challis) Date: Wed, 13 Apr 2011 12:44:50 +0100 Subject: [erlang-questions] Pattern matching in function calls References: <4DA58CB2.9070508@ecs.soton.ac.uk> Message-ID: Does the order of patterns in a function call matter? Are they all tested, or will erlang stop trying to match them once a mismatch has been found? As an example, if I've got: foo(<>, a) -> a; foo(<>, b) -> b. will the above be any slower than defining: foo(a, <>) -> a; foo(b, <>) -> b. Will the <> attempt to be matched in every case? Is it something worth thinking about, or will the compiler optimise this? Thanks, -- Dave Challis dsc@REDACTED From attila.r.nohl@REDACTED Wed Apr 13 13:57:02 2011 From: attila.r.nohl@REDACTED (Attila Rajmund Nohl) Date: Wed, 13 Apr 2011 13:57:02 +0200 Subject: [erlang-questions] Erlang beginner questions In-Reply-To: <1302679066266-3446453.post@n4.nabble.com> References: <1302661347349-3446106.post@n4.nabble.com> <1302679066266-3446453.post@n4.nabble.com> Message-ID: 2011/4/13, Mode7James : [...] > 1) gen_server is a behavior. It's a little confusing that gen_udp and > gen_tcp are both modules, but use the same naming conventions. I've seen > quite a few documents on how one uses "gen_server" as a behavior - is there > any that actually show what the text file looks like? Very very simple example: -module(s). -behaviour(gen_server). -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3, start/1]). init(Args) -> {ok, Args}. handle_call(stop, _, _) -> {stop, stopped, empty}; handle_call(Request, _From, State) -> io:format("~p ~n", [Request]), timer:sleep(10000), io:format("slept ~p ~n", [Request]), {reply, Request, State}. handle_cast(_Request, State) -> {noreply, State}. handle_info(Request, State) -> io:format("info: ~p ~n", [Request]), {noreply, State}. terminate(_, _) -> ok. code_change(_, _, _) -> {ok, nostate}. start(Args) -> gen_server:start(s, ?MODULE, Args, []). > Can I create my own > behaviors? Yes, just export a behaviour_info/1 function from your module which returns the expected functions: behaviour_info(callbacks) -> [{foo, 1}, {bar, 2}]. > I come from a flash background (Java) so I'm very familiar with > interfaces. Can one module implement multiple behaviors, or is it only > one-to-one direct relationship? You can implement multiple behaviours. > Is there somewhere that I can see the > complete master list of built-in OTP behaviors and what they do? Well, the generally useful are gen_server, gen_fsm, supervisor and maybe gen_event, they are documented. There are some application-specific behaviours like snmpa_discovery_handler or ssh_sftpd_file_api. They are documented with the applications (mostly). [...] > 3) Can someone log in via TCP connection, authenticate credentials upgrading > to SSL, As far as I know, this is possible. > and then also open a UDP connection for the gameplay mechanics? UDP is stateless, so I'm not quite sure what do you mean by "UDP connection". Of course, you can send UDP packets whenever you want, but you have to devise a clever authentication method that makes e.g. replay attacks impossible. From chandrashekhar.mullaparthi@REDACTED Wed Apr 13 14:21:22 2011 From: chandrashekhar.mullaparthi@REDACTED (Chandru) Date: Wed, 13 Apr 2011 13:21:22 +0100 Subject: [erlang-questions] Erlang beginner questions In-Reply-To: References: <1302661347349-3446106.post@n4.nabble.com> <1302679066266-3446453.post@n4.nabble.com> Message-ID: On 13 April 2011 12:57, Attila Rajmund Nohl wrote: > 2011/4/13, Mode7James : > [...] > > 1) gen_server is a behavior. It's a little confusing that gen_udp and > > gen_tcp are both modules, but use the same naming conventions. I've > seen > > quite a few documents on how one uses "gen_server" as a behavior - is > there > > any that actually show what the text file looks like? > > > 3) Can someone log in via TCP connection, authenticate credentials > upgrading > > to SSL, > > As far as I know, this is possible. > > http://www.erlang.org/doc/man/ssl.html#connect-3 cheers Chandru -------------- next part -------------- An HTML attachment was scrubbed... URL: From antoine.koener@REDACTED Wed Apr 13 14:46:08 2011 From: antoine.koener@REDACTED (Antoine Koener) Date: Wed, 13 Apr 2011 14:46:08 +0200 Subject: [erlang-questions] Pattern matching in function calls In-Reply-To: References: <4DA58CB2.9070508@ecs.soton.ac.uk> Message-ID: On Apr 13, 2011, at 13:44 , Dave Challis wrote: > Does the order of patterns in a function call matter? Are they all > tested, or will erlang stop trying to match them once a mismatch has > been found? > > As an example, if I've got: > > foo(<>, a) -> a; > foo(<>, b) -> b. > > will the above be any slower than defining: > > foo(a, <>) -> a; > foo(b, <>) -> b. > > Will the <> attempt to be matched in every case? > Is it something worth thinking about, or will the compiler optimise > this? If the content of <> is irrelevant, you can use the '_' notation: foo(a, _Bin) -> a; foo(b, _Bin) -> b; Then this is explicit for the reader that you don't want to check _Bin. From dsc@REDACTED Wed Apr 13 15:12:36 2011 From: dsc@REDACTED (Dave Challis) Date: Wed, 13 Apr 2011 14:12:36 +0100 Subject: [erlang-questions] Pattern matching in function calls In-Reply-To: References: <4DA58CB2.9070508@ecs.soton.ac.uk> <4DA5A144.5070800@ecs.soton.ac.uk> Message-ID: On 13/04/11 13:46, Antoine Koener wrote: > > On Apr 13, 2011, at 13:44 , Dave Challis wrote: > >> Does the order of patterns in a function call matter? Are they all >> tested, or will erlang stop trying to match them once a mismatch has >> been found? >> >> As an example, if I've got: >> >> foo(<>, a) -> a; >> foo(<>, b) -> b. >> >> will the above be any slower than defining: >> >> foo(a, <>) -> a; >> foo(b, <>) -> b. >> >> Will the <> attempt to be matched in every case? Is >> it something worth thinking about, or will the compiler optimise this? > > If the content of <> is irrelevant, you can use the '_' > notation: > > foo(a, _Bin) -> a; > foo(b, _Bin) -> b; > > Then this is explicit for the reader that you don't want to check _Bin. Sorry, my example wasn't great, I was more wondering about the cases when the binary data is relevant. So a better example might be: foo(<<$x,_Rest/binary>>, a) -> a1; foo(<<$y,_Rest/binary>>, a) -> a2; foo(<<$z,_Rest/binary>>, a) -> a3; foo(<<$x,_Rest/binary>>, b) -> b. If I then called: foo(<<"x">>, b). Would erlang perform 4 binary pattern matches until it got to the last clause? Or would it optimise things and only perform a single binary match by matching on the atoms first? Or will it always test all arguments in all cases? -- Dave Challis dsc@REDACTED From mihai@REDACTED Wed Apr 13 15:12:22 2011 From: mihai@REDACTED (Mihai Balea) Date: Wed, 13 Apr 2011 09:12:22 -0400 Subject: [erlang-questions] Erlang beginner questions In-Reply-To: <1302679066266-3446453.post@n4.nabble.com> References: <1302661347349-3446106.post@n4.nabble.com> <1302679066266-3446453.post@n4.nabble.com> Message-ID: <827F5437-D9E7-4E55-8E5C-7BCB9240A2F8@hates.ms> On Apr 13, 2011, at 3:17 AM, Mode7James wrote: > 1) gen_server is a behavior. It's a little confusing that gen_udp and > gen_tcp are both modules, but use the same naming conventions. I've seen > quite a few documents on how one uses "gen_server" as a behavior - is there > any that actually show what the text file looks like? Can I create my own > behaviors? I come from a flash background (Java) so I'm very familiar with > interfaces. Can one module implement multiple behaviors, or is it only > one-to-one direct relationship? Is there somewhere that I can see the > complete master list of built-in OTP behaviors and what they do? Think of behaviours as interfaces, although they are not strictly enforced. You can define your own, here's an example: http://www.trapexit.org/Defining_Your_Own_Behaviour gen_udp and gen_tcp (and gen_sctp) are not, strictly speaking, behaviours. I've always wondered why they are named that way. The big 5 are gen_server, gen_fsm, gen_event, supervisor and application. The vast majority of OTP compliant code that I've seen is built on these five. You can have a module implement multiple behaviours, just be careful about callback clashes > 2) In the 20bits article, how is the port number generated? Are port > numbers unique to an application, or are there different port numbers for > different protocols? Is this secure? How do Erlang services deal with DDOS > attacks? Are there any tried-and-true methods that are used? The 20bits article is pretty good, but I'd recommend using gen_nb_server for building tcp servers. You can find it here: https://github.com/kevsmith/gen_nb_server It is a 3rd party behaviour for building performant, non-blocking tcp servers > 3) Can someone log in via TCP connection, authenticate credentials upgrading > to SSL, and then also open a UDP connection for the gameplay mechanics? Yes, that's probably doable, but you'd have to be more specific as to what exactly want to do. For example, there's not such thing as a "udp connection". You can fire off UDP packets to anywhere, if there's someone listening, they'll get them, otherwise they'll be dropped. Do you want to open one UDP port for each authenticated user or have all of them send data to a single, common UDP port? > 4) I've read that distributed Erlang is using "all or nothing" security, ie > nodes with access can essentially do whatever they want. Is there a way to > keep a service running on a dedicated server, and remotely hotswap code via > my macbook? Any examples of this being done? As long as you have shell access to your remote server, you can certainly do hot updates Mihai From contact@REDACTED Wed Apr 13 15:13:26 2011 From: contact@REDACTED (Evax Software) Date: Wed, 13 Apr 2011 15:13:26 +0200 Subject: [erlang-questions] [ANN] kerl Erlang/OTP installation management script In-Reply-To: References: <1302623356.3302.114.camel@thomas-laptop> Message-ID: <1302700406.3279.16.camel@thomas-laptop> Thanks to both of you for this very positive feedback ! Agner is sandboxed per installation and not per build, so I guess you can already do what you want with kerl. Let's say you want to test drive two misultin versions. First create a named build: $ kerl build R14B02 r14b02 Then create two installations (sandboxes): $ kerl install r14b02 /path/to/r14b02_misultin_0.6.2 $ kerl install r14b02 /path/to/r14b02_misultin_0.7 And finaly install different versions of the same package in each one: $ . /path/to/r14b02_misultin_0.6.2/activate $ agner install misultin -v 0.6.2 $ . /path/to/r14b02_misultin_0.7/activate $ agner install misultin -v 0.7 Evax Le mardi 12 avril 2011 ? 10:49 -0700, Jordan West a ?crit : > > Really nice stuff. Reminds me of Ruby Version Manager, which is > something I > was hoping for in Erlang. I would suggest looking into some of RVMs > features. Dependency sets (like RVMs gemsets) would be a nice touch on > top > of the ability to sandbox agner per OTP build. > > Jordan > > On Tue, Apr 12, 2011 at 10:12 AM, Ahmed Omar > wrote: > > > very nice! Will give it a try! > > > > > > On Tue, Apr 12, 2011 at 5:49 PM, Evax Software > wrote: > > > >> Hi all, > >> > >> kerl is a script allowing the easy management of sandboxed > Erlang/OTP > >> installations on Unix systems. > >> > >> Among the features: > >> * shell agnostic > >> * fetches and builds Erlang/OTP from the official releases or from > git > >> * native agner support > >> * easy and fast sandbox creation > >> * easy switching between different sandboxes (similar to Python's > >> virtualenv) > >> > >> Check the project page: > >> https://github.com/evax/kerl > >> > >> Feedback is welcome ! > >> > >> Evax > >> > >> > >> _______________________________________________ > >> erlang-questions mailing list > >> erlang-questions@REDACTED > >> http://erlang.org/mailman/listinfo/erlang-questions > >> > > > > > > > > -- > > Best Regards, > > - Ahmed Omar > > http://nl.linkedin.com/in/adiaa > > Follow me on twitter > > @spawn_think > > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > > > From fred.hebert@REDACTED Wed Apr 13 15:17:28 2011 From: fred.hebert@REDACTED (=?iso-8859-1?Q?Fr=E9d=E9ric_Trottier-H=E9bert?=) Date: Wed, 13 Apr 2011 09:17:28 -0400 Subject: [erlang-questions] Erlang beginner questions In-Reply-To: <827F5437-D9E7-4E55-8E5C-7BCB9240A2F8@hates.ms> References: <1302661347349-3446106.post@n4.nabble.com> <1302679066266-3446453.post@n4.nabble.com> <827F5437-D9E7-4E55-8E5C-7BCB9240A2F8@hates.ms> Message-ID: <8EBC1BF4-25C8-4EA5-944E-46A7AB6813E5@erlang-solutions.com> As far as I know, behaviours are more than interfaces; they imply that divide between a generic and a specific bit of code, with the generic one being well-behaved and the specific one being relatively unsafe. Moreover, it also implies giving up the control of the flow to the behaviour module, restraining the callback module to specific details. An Interface is much more generic and only has a meaning in terms of contracts in this particular case. I might be taking a purist approach, but I think the distinction is important. I think behaviours are a rather poor tool to determine an interface itself compared to real contracts that could be enforced by the compiler or Dialyzer. On 2011-04-13, at 09:12 AM, Mihai Balea wrote: > > Think of behaviours as interfaces, although they are not strictly enforced. > You can define your own, here's an example: http://www.trapexit.org/Defining_Your_Own_Behaviour > > gen_udp and gen_tcp (and gen_sctp) are not, strictly speaking, behaviours. I've always wondered why they are named that way. > > The big 5 are gen_server, gen_fsm, gen_event, supervisor and application. The vast majority of OTP compliant code that I've seen is built on these five. > > You can have a module implement multiple behaviours, just be careful about callback clashes > > Mihai > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -- Fred H?bert http://www.erlang-solutions.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From mihai@REDACTED Wed Apr 13 15:27:04 2011 From: mihai@REDACTED (Mihai Balea) Date: Wed, 13 Apr 2011 09:27:04 -0400 Subject: [erlang-questions] Erlang beginner questions In-Reply-To: <8EBC1BF4-25C8-4EA5-944E-46A7AB6813E5@erlang-solutions.com> References: <1302661347349-3446106.post@n4.nabble.com> <1302679066266-3446453.post@n4.nabble.com> <827F5437-D9E7-4E55-8E5C-7BCB9240A2F8@hates.ms> <8EBC1BF4-25C8-4EA5-944E-46A7AB6813E5@erlang-solutions.com> Message-ID: <971BDCFA-6980-4768-B872-4B3335C3FF2A@hates.ms> On Apr 13, 2011, at 9:17 AM, Fr?d?ric Trottier-H?bert wrote: > As far as I know, behaviours are more than interfaces; they imply that divide between a generic and a specific bit of code, with the generic one being well-behaved and the specific one being relatively unsafe. Moreover, it also implies giving up the control of the flow to the behaviour module, restraining the callback module to specific details. > > An Interface is much more generic and only has a meaning in terms of contracts in this particular case. > > I might be taking a purist approach, but I think the distinction is important. I think behaviours are a rather poor tool to determine an interface itself compared to real contracts that could be enforced by the compiler or Dialyzer. True, but I wouldn't go that far with someone who's just starting to learn about this stuff... Mihai From ekeroth.christoffer@REDACTED Wed Apr 13 15:42:41 2011 From: ekeroth.christoffer@REDACTED (JohnyTex) Date: Wed, 13 Apr 2011 06:42:41 -0700 (PDT) Subject: [erlang-questions] Trouble with Erlang's lenient comparisons In-Reply-To: References: <8c056228-a280-41e9-a6b0-20dd10f4b71f@gu8g2000vbb.googlegroups.com> <4DA57CB6.7030100@cs.ntua.gr> Message-ID: <4dd5be11-1dbf-4484-bce4-84e46845e441@l6g2000vbn.googlegroups.com> Thanks for the advice guys! I managed to get Dialyzer running and it worked very nicely; it managed to spot some unreachable code right off the bat :) However, it doesn't seem to get the more insidious errors that arise from comparing other types than was intended, i.e. accidentaly comparing a string to an integer... but since it's completely valid Erlang I guess it's not supposed to complain? I will heed your advice and insert some type checking where appropriate, thanks :) The code is written in a very imperative style and I will try to rewrite it to look more like Erlang as well, which I hope will solve a lot of my problems. Kind of off topic, but does anyone have experience with Haskell and its type system? I keep hearing claims like "if it compiles, it works!", and so on, which does sound quite nice... if it's true ;) On 13 Apr, 13:26, Torben Hoffmann wrote: > From a practical stand point I agree with Kostis. > > When we started doing Erlang we used a lot of is_record/2 guards - that > generally makes the code a lot harder to understand, so we dropped that as > we threw away our imperative inheritance. > > And the minute you need to take a parameter out of the record it will be > done with the pattern matching anyway, which makes it easier to make changes > in the code. > > One learning here: try to do the pattern matching on fields only in the > cases where it is used to pick between different function clauses. It makes > it easier to figure out what is controlling the flow of execution and what > is merely taken out of the parameters to be used as input elsewhere. ?We had > a lot of functions that pattern matched a lot of fields in a record, but > only one of the fields were used to control the flow of execution. It was > more clear to do a R#rec.field1 in the function code for the other fields. > But it is a matter of style, of course... > > Cheers, > Torben > > 2011/4/13 H?kan Mattsson > > > > > > > > > > > When you discourage one way of writing code and claim that another way > > is better you ought to motivate why. > > > /H?kan > > > On Wed, Apr 13, 2011 at 12:36 PM, Kostis Sagonas > > wrote: > > > Gordon Guthrie wrote: > > > >> ... > > > >> Also check for bad input to functions by using guards like: > > > >> fun(A, B, C) when is_list(A), is_integer(B), is_record(C, recC) -> > > > > The following is a bit pedantic, but please do not offer use of the > > > is_record guard (esp. the one with arity two instead of three) as advice > > to > > > newcomers. ?I suggest that you try to forget about this guard's > > existence; > > > the only place where this guard is possibly needed is in or/orelse > > contexts. > > > > The above code is written better using pattern matching, as in: > > > > ?fun(A, B, #recC{} = C) when is_list(A), is_integer(B) -> > > _______________________________________________ > > erlang-questions mailing list > > erlang-questi...@REDACTED > >http://erlang.org/mailman/listinfo/erlang-questions > > --http://www.linkedin.com/in/torbenhoffmann > > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://erlang.org/mailman/listinfo/erlang-questions From lukas.larsson@REDACTED Wed Apr 13 15:45:56 2011 From: lukas.larsson@REDACTED (Lukas Larsson) Date: Wed, 13 Apr 2011 13:45:56 +0000 (GMT) Subject: [erlang-questions] Erlang beginner questions In-Reply-To: <75767596.96801302702174142.JavaMail.root@zimbra> Message-ID: <488049720.96821302702356174.JavaMail.root@zimbra> For a generic tcp server library I would also recommend looking at http://github.com/oscarh/gen_tcpd. It (IMO) solves the tcp server problem beautifully and does not force you into a gen_server. It also support multiple acceptors and ssl connections. Lukas ----- Original Message ----- From: "Mihai Balea" To: "Mode7James" Cc: erlang-questions@REDACTED Sent: Wednesday, April 13, 2011 3:12:22 PM GMT +01:00 Amsterdam / Berlin / Bern / Rome / Stockholm / Vienna Subject: Re: [erlang-questions] Erlang beginner questions On Apr 13, 2011, at 3:17 AM, Mode7James wrote: > 1) gen_server is a behavior. It's a little confusing that gen_udp and > gen_tcp are both modules, but use the same naming conventions. I've seen > quite a few documents on how one uses "gen_server" as a behavior - is there > any that actually show what the text file looks like? Can I create my own > behaviors? I come from a flash background (Java) so I'm very familiar with > interfaces. Can one module implement multiple behaviors, or is it only > one-to-one direct relationship? Is there somewhere that I can see the > complete master list of built-in OTP behaviors and what they do? Think of behaviours as interfaces, although they are not strictly enforced. You can define your own, here's an example: http://www.trapexit.org/Defining_Your_Own_Behaviour gen_udp and gen_tcp (and gen_sctp) are not, strictly speaking, behaviours. I've always wondered why they are named that way. The big 5 are gen_server, gen_fsm, gen_event, supervisor and application. The vast majority of OTP compliant code that I've seen is built on these five. You can have a module implement multiple behaviours, just be careful about callback clashes > 2) In the 20bits article, how is the port number generated? Are port > numbers unique to an application, or are there different port numbers for > different protocols? Is this secure? How do Erlang services deal with DDOS > attacks? Are there any tried-and-true methods that are used? The 20bits article is pretty good, but I'd recommend using gen_nb_server for building tcp servers. You can find it here: https://github.com/kevsmith/gen_nb_server It is a 3rd party behaviour for building performant, non-blocking tcp servers > 3) Can someone log in via TCP connection, authenticate credentials upgrading > to SSL, and then also open a UDP connection for the gameplay mechanics? Yes, that's probably doable, but you'd have to be more specific as to what exactly want to do. For example, there's not such thing as a "udp connection". You can fire off UDP packets to anywhere, if there's someone listening, they'll get them, otherwise they'll be dropped. Do you want to open one UDP port for each authenticated user or have all of them send data to a single, common UDP port? > 4) I've read that distributed Erlang is using "all or nothing" security, ie > nodes with access can essentially do whatever they want. Is there a way to > keep a service running on a dedicated server, and remotely hotswap code via > my macbook? Any examples of this being done? As long as you have shell access to your remote server, you can certainly do hot updates Mihai _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://erlang.org/mailman/listinfo/erlang-questions From kostis@REDACTED Wed Apr 13 15:54:24 2011 From: kostis@REDACTED (Kostis Sagonas) Date: Wed, 13 Apr 2011 16:54:24 +0300 Subject: [erlang-questions] Trouble with Erlang's lenient comparisons In-Reply-To: <4dd5be11-1dbf-4484-bce4-84e46845e441@l6g2000vbn.googlegroups.com> References: <8c056228-a280-41e9-a6b0-20dd10f4b71f@gu8g2000vbb.googlegroups.com> <4DA57CB6.7030100@cs.ntua.gr> <4dd5be11-1dbf-4484-bce4-84e46845e441@l6g2000vbn.googlegroups.com> Message-ID: <4DA5AB10.1000601@cs.ntua.gr> JohnyTex wrote: > Thanks for the advice guys! I managed to get Dialyzer running and it > worked very nicely; it managed to spot some unreachable code right off > the bat :) > > However, it doesn't seem to get the more insidious errors that arise > from comparing other types than was intended, i.e. accidentaly > comparing a string to an integer... but since it's completely valid > Erlang I guess it's not supposed to complain? The answer depends on the kind of comparison that is used. If by comparison you mean case expressions or direct matching as in case String of Integer -> ... end or String = Integer then dialyzer will report these to you as impossible matches. If by comparison you mean uses of =/=, <, ... then of course these are allowed in Erlang and of course dialyzer will not warn you that you are doing something wrong there. (*) Kostis (*) Though it will warn you that e.g. the 'false' clause is unreachable in something like: case String =\= Integer of true -> ... false -> ... end From peralta.alejandro@REDACTED Wed Apr 13 16:19:06 2011 From: peralta.alejandro@REDACTED (Ale) Date: Wed, 13 Apr 2011 11:19:06 -0300 Subject: [erlang-questions] [Newbie] [wxErlang] Request for comments Message-ID: Hola Erlanguistas, I'm working on small project to teach myself Erlang. It's a small IRC client with a wxErlang GUI. (Which actually started as IRC robot, but anyway). I've been trying to hide the IRC protocol behind an instance of a gen_event behaviour. I've noticed that Erlang strong is the backend, but I didn't have any better ideas and I usually can only spend very few hours per week with Erlang, so I decided to stick with it. Plus I wanted to try wxErlang, which I find very interesting, the API really mirrors the C++ API. The code: https://github.com/alep/Ditto I have 4 modules: - conn.erl: Hides socket and connection logic. You pass a function to a process which handles the socket, when data arrives, the socket calls the function with the data it received. - ircmsg.erl: Bunch of functions to parse IRC messages, for example to retrieve prefix, command and arguments from lines like ":Wiz!@some.host.net PRIVMSG #erlang : hello world!" (prefix = Wiz!@some.host.net, command=PRIVMSG, arguments = ["#erlang", "hello world"] - dittoui.erl: wxErlang GUI, very simple and incomplete user interface. After going into File -> Connect and giving host, port, nick and user (example: chat.freenode.net, 6667, thewizardoferl, JonErlanguista), it creates a socket (and a process which controls it with conn:open(...)) then it starts gen_event, next it notifies gen_event of the events {pass ...}, {nick "thewizardoferl"} and {user "JonErlanguista"}. - ircclient.erl: gen_event behaviour which tries to hide IRC protocol. It has 4 states disconnected, nick, user, connected. I was looking for any encouraging criticism, plain criticism is ok too :-), or any comments to know if I just delete the repository or if I'm on good track. Thanks in advance. Erlang is fun. :-) Regards, -- Ale. From bob@REDACTED Wed Apr 13 16:28:41 2011 From: bob@REDACTED (Bob Cowdery) Date: Wed, 13 Apr 2011 15:28:41 +0100 Subject: [erlang-questions] wx-erlang question Message-ID: <4DA5B319.9010108@bobcowdery.plus.com> Hi I'm having a fair bit of trouble with the syntax of wx-erlang. Having failed to get mouse wheel events from a wxStaticText (still my first choice but I think it's a wx limitation and I'm not sure how to work round it with Erlang) I thought I would try to make a wxTextCtrl behave like a wxStaticText. One of the first things I wanted to do is turn off the caret. T = wxTextCtrl:new(Panel, 1, [{value, "0"}]), C = wxTextCtrl:getCaret(T), wxCaret:hide(C), gives me: ** exception exit: {{badarg,0},{wxCaret,hide,0}} but if I create a new caret I can call hide() on it. io:format("~p, ~p", [C, wxCaret:new(T, {1,1})]), {wx_ref,0,wxCaret,[]}, {wx_ref,51,wxCaret,[]} Is it to do with fact that wx-erlang did not create it so has no object reference as it seems to object to the id = 0. Bob From gordon@REDACTED Wed Apr 13 16:36:46 2011 From: gordon@REDACTED (Gordon Guthrie) Date: Wed, 13 Apr 2011 15:36:46 +0100 Subject: [erlang-questions] Trouble with Erlang's lenient comparisons In-Reply-To: <4DA57CB6.7030100@cs.ntua.gr> References: <8c056228-a280-41e9-a6b0-20dd10f4b71f@gu8g2000vbb.googlegroups.com> <4DA57CB6.7030100@cs.ntua.gr> Message-ID: Kostis I have never read the documentation on is_record/2 before (didn't even know there was is_record/3) I *assumed* that the is_record guard checked that it indeed was a record - it would appear it doesn't. The documentation also explictly says to use is_record/2 > Note! > This BIF is documented for completeness. In most cases is_record/2 should be used. If you shouldn't use it then the documentation should probably say so. I presume you are saying that using #rec{} in the function call is correctly expanded by the preprocessor to {rec, _, _, } and is therefore a better specification of the contract than is_record/2 which just says 'it is a tuple with first element of this atom' Gordon On 13 April 2011 11:36, Kostis Sagonas wrote: > Gordon Guthrie wrote: >> >> ... >> >> Also check for bad input to functions by using guards like: >> >> fun(A, B, C) when is_list(A), is_integer(B), is_record(C, recC) -> > > The following is a bit pedantic, but please do not offer use of the > is_record guard (esp. the one with arity two instead of three) as advice to > newcomers. ?I suggest that you try to forget about this guard's existence; > the only place where this guard is possibly needed is in or/orelse contexts. > > The above code is written better using pattern matching, as in: > > ?fun(A, B, #recC{} = C) when is_list(A), is_integer(B) -> > > Kostis > -- Gordon Guthrie CEO hypernumbers http://hypernumbers.com t: hypernumbers +44 7776 251669 From ekeroth.christoffer@REDACTED Wed Apr 13 16:50:37 2011 From: ekeroth.christoffer@REDACTED (JohnyTex) Date: Wed, 13 Apr 2011 07:50:37 -0700 (PDT) Subject: [erlang-questions] Trouble with Erlang's lenient comparisons In-Reply-To: <4DA5AB10.1000601@cs.ntua.gr> References: <8c056228-a280-41e9-a6b0-20dd10f4b71f@gu8g2000vbb.googlegroups.com> <4DA57CB6.7030100@cs.ntua.gr> <4dd5be11-1dbf-4484-bce4-84e46845e441@l6g2000vbn.googlegroups.com> <4DA5AB10.1000601@cs.ntua.gr> Message-ID: <5b4fa7b1-6e29-47a2-b23a-2e202df9079b@l6g2000vbn.googlegroups.com> What I meant was when you use lesser/greater than on two different types, i.e. checking if a tuple is greater than an integer - sorry for being unclear :) Thanks again for your advice! On 13 Apr, 15:54, Kostis Sagonas wrote: > JohnyTex wrote: > > Thanks for the advice guys! I managed to get Dialyzer running and it > > worked very nicely; it managed to spot some unreachable code right off > > the bat :) > > > However, it doesn't seem to get the more insidious errors that arise > > from comparing other types than was intended, i.e. accidentaly > > comparing a string to an integer... but since it's completely valid > > Erlang I guess it's not supposed to complain? > > The answer depends on the kind of comparison that is used. > > If by comparison you mean case expressions or direct matching as in > > ? ? case String of > ? ? ? Integer -> ... > ? ? end > > or > > ? ? String = Integer > > then dialyzer will report these to you as impossible matches. > > If by comparison you mean uses of =/=, <, ... then of course these are > allowed in Erlang and of course dialyzer will not warn you that you are > doing something wrong there. (*) > > Kostis > > (*) Though it will warn you that e.g. the 'false' clause is unreachable > in something like: > > ? ? case String =\= Integer of > ? ? ? true -> ... > ? ? ? false -> ... > ? ? end > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://erlang.org/mailman/listinfo/erlang-questions From robert.virding@REDACTED Wed Apr 13 17:52:18 2011 From: robert.virding@REDACTED (Robert Virding) Date: Wed, 13 Apr 2011 15:52:18 +0000 (GMT) Subject: [erlang-questions] Trouble with Erlang's lenient comparisons In-Reply-To: <1399735314.97511302709808323.JavaMail.root@zimbra> Message-ID: <631833685.97531302709938931.JavaMail.root@zimbra> The comparison operators as they are now were a mistake, almost a bad mistake. IMAO what we should have done was to have had two different sets of operators, one set of numeric comparisons (without type conversion) and one set of gerneral term comparisons (without type conversion). So for example: == /= =< < >= > would only work on numbers @== @/= @=< @< @>= @> would work on all terms Note that the existing =:= =/= are the same as @== @/= in my scheme above. We could add the full set of term comparison operators, but not change the existing operators to be only numeric comparison. The reaction if we did would be "interesting". :-) Old sins cast long shadows. Robert ----- "JohnyTex" wrote: > What I meant was when you use lesser/greater than on two different > types, i.e. checking if a tuple is greater than an integer - sorry > for > being unclear :) > > Thanks again for your advice! > > > On 13 Apr, 15:54, Kostis Sagonas wrote: > > JohnyTex wrote: > > > Thanks for the advice guys! I managed to get Dialyzer running and > it > > > worked very nicely; it managed to spot some unreachable code right > off > > > the bat :) > > > > > However, it doesn't seem to get the more insidious errors that > arise > > > from comparing other types than was intended, i.e. accidentaly > > > comparing a string to an integer... but since it's completely > valid > > > Erlang I guess it's not supposed to complain? > > > > The answer depends on the kind of comparison that is used. > > > > If by comparison you mean case expressions or direct matching as in > > > > ? ? case String of > > ? ? ? Integer -> ... > > ? ? end > > > > or > > > > ? ? String = Integer > > > > then dialyzer will report these to you as impossible matches. > > > > If by comparison you mean uses of =/=, <, ... then of course these > are > > allowed in Erlang and of course dialyzer will not warn you that you > are > > doing something wrong there. (*) > > > > Kostis > > > > (*) Though it will warn you that e.g. the 'false' clause is > unreachable > > in something like: > > > > ? ? case String =\= Integer of > > ? ? ? true -> ... > > ? ? ? false -> ... > > ? ? end > > _______________________________________________ > > erlang-questions mailing list > > > erlang-questi...@REDACTED://erlang.org/mailman/listinfo/erlang-questions > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From hd2010@REDACTED Wed Apr 13 18:04:13 2011 From: hd2010@REDACTED (H. Diedrich) Date: Wed, 13 Apr 2011 18:04:13 +0200 Subject: [erlang-questions] Trouble with Erlang's lenient comparisons In-Reply-To: <631833685.97531302709938931.JavaMail.root@zimbra> References: <631833685.97531302709938931.JavaMail.root@zimbra> Message-ID: <4DA5C97D.6090206@eonblast.com> Robert Virding schrieb: > The comparison operators as they are now were a mistake, almost a bad > mistake. IMAO what we should have done was to have had two different > sets of operators, one set of numeric comparisons (without type > conversion) and one set of gerneral term comparisons (without type > conversion). So for example: > > == /= =< < >= > would only work on numbers > @== @/= @=< @< @>= @> would work on all terms > > Note that the existing =:= =/= are the same as @== @/= in my scheme > above. > > We could add the full set of term comparison operators, but not change > the existing operators So you could introduce the @ variants for numbers only instead. How about a triple sign notation for "strictness", as ===, /==, ==< ... !? Well ... <=< ... :-< Henning -------------- next part -------------- An HTML attachment was scrubbed... URL: From therevoltingx@REDACTED Wed Apr 13 18:18:52 2011 From: therevoltingx@REDACTED (Miguel Morales) Date: Wed, 13 Apr 2011 09:18:52 -0700 Subject: [erlang-questions] Erlang beginner questions In-Reply-To: <1302661347349-3446106.post@n4.nabble.com> References: <1302661347349-3446106.post@n4.nabble.com> Message-ID: Also, keep in mind that on mobile devices you can have a very severe lag when the user is not on wi-fi so simply sending the location of the on-screen ball will cause sync issues, specially if it's a multiplayer game. Like you said, they'll be a fair amount of physics involved. Even though it is best practice to use some of the gen_* modules, when I was starting (still a bit of a noob) I decided to make my own tcp and state machines using the erlang basics. Although I haven't done this yet, from a bit of research it really shouldn't be a big issue upgrading that basic erlang code to say something like gen_tcp. At the same time, you get a better understanding of the basics. At this level, you can prototype your architecture a little more freely, like adding authentication at the socket/tcp level. Sleeping before disconnecting users, switching to ssl, send udp packets at certain events, etc. On Tue, Apr 12, 2011 at 7:22 PM, Mode7James wrote: > I'm just learning Erlang, so please bear with me. I've read Erlang & OTP > in > Action, and am currently reading through Joe Armstrong's book right now. > That said, I am currently a Sr. Flash developer, so my background is still > a > little fresh concerning programming concepts that I'm sure most of you are > already well-versed in. > > I want to build a server for mobile & flash multiplayer games that utilizes > a secure TCP connection to authenticate people, but then opens a UDP port > to > send/receive information. > > I decided to post here because all I need is a little kick in the right > direction. I figured my first goal would be to set up a simple server that > is able to send/receive from a very simple client, written in Objective-C. > This would allow the user to drag a ball around the screen, essentially > sending the coordinates of the user's input to the server, it checks with > the basic mechanics, and sends back so many frames per second the location > of an on-screen ball. > > My goal is to incorporate simple physics, but I really want to start small > and get off on the right foot. Would someone please walk me through doing > this the proper way, using OTP standards? I want to make sure that I don't > create any bad habits, and so far I have understood the books I've read. > Reading and creating a fully working example is two completely different > things though. > > Thanks so much in advance! > > -- > View this message in context: > http://erlang.2086793.n4.nabble.com/Erlang-beginner-questions-tp3446106p3446106.html > Sent from the Erlang Questions mailing list archive at Nabble.com. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -- ~ Jeremiah:9:23-24 Android 2D MMORPG: http://solrpg.com/, http://www.youtube.com/user/revoltingx -------------- next part -------------- An HTML attachment was scrubbed... URL: From James@REDACTED Wed Apr 13 18:26:05 2011 From: James@REDACTED (Mode7James) Date: Wed, 13 Apr 2011 09:26:05 -0700 (PDT) Subject: [erlang-questions] Erlang beginner questions In-Reply-To: <971BDCFA-6980-4768-B872-4B3335C3FF2A@hates.ms> References: <1302661347349-3446106.post@n4.nabble.com> <1302679066266-3446453.post@n4.nabble.com> <827F5437-D9E7-4E55-8E5C-7BCB9240A2F8@hates.ms> <8EBC1BF4-25C8-4EA5-944E-46A7AB6813E5@erlang-solutions.com> <971BDCFA-6980-4768-B872-4B3335C3FF2A@hates.ms> Message-ID: <1302711965491-3447649.post@n4.nabble.com> Hey thanks guys, these are great responses! After reading and researching this language a couple months on my own, it's nice to finally meet a few people that know Erlang and are nice enough to answer my questions! I half expected a bunch of "google it" answers. :) Yes, I agree and completely understand "re-learning" what I have already learned. Flash (Java) is completely different from Erlang, however learning Erlang it's really amazing what you can do with it with just a few lines of code. Pattern-matching is the shit, I'm surprised it isn't used more for search algorithms. Regular Expressions are a pain compared to Erlang! And don't get me started on the bit syntax. There's quite a bit that I still need to learn about servers in general, ie how they actually work. It wasn't until a few days ago that I learned that an HTTP server essentially is a TCP server, receiving requests, and then sending the data over the TCP connection. :) I will need UDP so that I can send fast unreliable packets for user input and the state of the game. A couple people have asked what my goal is: To start, my goal is to create a server that allows secure authentication from a client written in another language, and then my erlang server receives UDP packets which have the x, y, radius coordinates of a "ball" on the client, written in Objective-C. Essentially my first test will be the ability to open up the program on my iPad, log in, and then be able to move a red 2d circle around the screen, simply sending the position coordinates via unreliable UDP, and receiving the current state of all on screen objects on an interval. It's pretty straightforward from there - adding limited 2d physics, which I would like to implement as a linked-in driver, and the ability to add users with a load bearing algorithm. Speaking of load bearing, is there a way for Erlang to read the cpu load of a machine or machine that a node is run on? Also, regarding linked-in drivers: I hear that if they crash, then it brings the entire VM down. Is this just in case there is a bad piece of code? If they are this unstable, then why are they used in production environments? For something like an MMO server, I'll want extremely low latency between the Erlang side and my math & physics side - but I also need it to be stable so if something messes up or crashes, it doesn't bring the entire system down. Thanks again - I just want to make sure I'm developing proper habits, and building this thing the right way ;) -- View this message in context: http://erlang.2086793.n4.nabble.com/Erlang-beginner-questions-tp3446106p3447649.html Sent from the Erlang Questions mailing list archive at Nabble.com. From jwest@REDACTED Wed Apr 13 18:33:03 2011 From: jwest@REDACTED (Jordan West) Date: Wed, 13 Apr 2011 09:33:03 -0700 Subject: [erlang-questions] [ANN] kerl Erlang/OTP installation management script In-Reply-To: <1302700406.3279.16.camel@thomas-laptop> References: <1302623356.3302.114.camel@thomas-laptop> <1302700406.3279.16.camel@thomas-laptop> Message-ID: That definitely works in the interim but gemsets in RVM have a couple more features on top of them. For example, one I use frequently is the global gemset, which lets me install gems that are then available to all gemsets. So say I always use Proper for testing, then I could put that in my global gemset but only install misultin or riak_core or a per project basis. More on RVM gemsets: https://rvm.beginrescueend.com/gemsets/ Another nice addition would be .kerl files (like .rvmrc files). This would specify what build (and if something like gemset were implemented what gemset), on a per directory basis. Changing into a directory with a .kerl file would cause the current build to switch to the one specified in the file (here is RVMs .rvmrc docs for reference https://rvm.beginrescueend.com/workflow/rvmrc/). Again, really awesome stuff. Just making some suggestions based on my needs. Maybe I'll have some extra time to read the code & submit a patch. Cheers, Jordan On Wed, Apr 13, 2011 at 6:13 AM, Evax Software wrote: > Thanks to both of you for this very positive feedback ! > > Agner is sandboxed per installation and not per build, so I guess you > can already do what you want with kerl. > > Let's say you want to test drive two misultin versions. > > First create a named build: > $ kerl build R14B02 r14b02 > > Then create two installations (sandboxes): > $ kerl install r14b02 /path/to/r14b02_misultin_0.6.2 > $ kerl install r14b02 /path/to/r14b02_misultin_0.7 > > And finaly install different versions of the same package in each one: > $ . /path/to/r14b02_misultin_0.6.2/activate > $ agner install misultin -v 0.6.2 > > $ . /path/to/r14b02_misultin_0.7/activate > $ agner install misultin -v 0.7 > > Evax > > Le mardi 12 avril 2011 ? 10:49 -0700, Jordan West a ?crit : > > > > Really nice stuff. Reminds me of Ruby Version Manager, which is > > something I > > was hoping for in Erlang. I would suggest looking into some of RVMs > > features. Dependency sets (like RVMs gemsets) would be a nice touch on > > top > > of the ability to sandbox agner per OTP build. > > > > Jordan > > > > On Tue, Apr 12, 2011 at 10:12 AM, Ahmed Omar > > wrote: > > > > > very nice! Will give it a try! > > > > > > > > > On Tue, Apr 12, 2011 at 5:49 PM, Evax Software > > wrote: > > > > > >> Hi all, > > >> > > >> kerl is a script allowing the easy management of sandboxed > > Erlang/OTP > > >> installations on Unix systems. > > >> > > >> Among the features: > > >> * shell agnostic > > >> * fetches and builds Erlang/OTP from the official releases or from > > git > > >> * native agner support > > >> * easy and fast sandbox creation > > >> * easy switching between different sandboxes (similar to Python's > > >> virtualenv) > > >> > > >> Check the project page: > > >> https://github.com/evax/kerl > > >> > > >> Feedback is welcome ! > > >> > > >> Evax > > >> > > >> > > >> _______________________________________________ > > >> erlang-questions mailing list > > >> erlang-questions@REDACTED > > >> http://erlang.org/mailman/listinfo/erlang-questions > > >> > > > > > > > > > > > > -- > > > Best Regards, > > > - Ahmed Omar > > > http://nl.linkedin.com/in/adiaa > > > Follow me on twitter > > > @spawn_think > > > > > > > > > _______________________________________________ > > > erlang-questions mailing list > > > erlang-questions@REDACTED > > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > > > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From James@REDACTED Wed Apr 13 18:33:08 2011 From: James@REDACTED (Mode7James) Date: Wed, 13 Apr 2011 09:33:08 -0700 (PDT) Subject: [erlang-questions] Erlang beginner questions In-Reply-To: References: <1302661347349-3446106.post@n4.nabble.com> Message-ID: <1302712388923-3447667.post@n4.nabble.com> Thanks Miguel - you touched on a couple of my questions as I was writing them! Yes - for 3G the latency is pretty bad. Even Wi-Fi I want to build for the lowest common denominator, and then it can be tweaked for each project. There will be a fair amount of predictiveness in the client engine to account for the lag, which is something we have to do for flash multiplayer games as well. Also, flash is TCP only, so there's an added side effect of all network traffic stopping on the flash end until the packets are confirmed delivered. -- View this message in context: http://erlang.2086793.n4.nabble.com/Erlang-beginner-questions-tp3446106p3447667.html Sent from the Erlang Questions mailing list archive at Nabble.com. From robert.virding@REDACTED Wed Apr 13 18:43:37 2011 From: robert.virding@REDACTED (Robert Virding) Date: Wed, 13 Apr 2011 16:43:37 +0000 (GMT) Subject: [erlang-questions] Trouble with Erlang's lenient comparisons In-Reply-To: <1361446046.97761302712881828.JavaMail.root@zimbra> Message-ID: <1107345912.97781302713017847.JavaMail.root@zimbra> You could, but then we would be getting way too many operators. In many ways the pure term comparison operators maybe be more needed as they would clean up issues with ordering terms (you can have two terms in which one is not greater or less than the other but they are not equal). If we wish to have specific operators then we could have two different prefixes for whether they are term or numeric comparisons, for example @ for term and : for numeric: @== @/= @=< @< @>= @> :== :/= :=< :< :>= :> Then phase out the old ones completely. This is the only way without causing too much grief. The question is, of course, how many problems do the existing operators actually cause, and is it worth trying to fix it? Robert ----- "H. Diedrich" wrote: > > Robert Virding schrieb: > The comparison operators as they are now were a mistake, almost a bad mistake. IMAO what we should have done was to have had two different sets of operators, one set of numeric comparisons (without type conversion) and one set of gerneral term comparisons (without type conversion). So for example: > > == /= =< < >= > would only work on numbers > @== @/= @=< @< @>= @> would work on all terms > > Note that the existing =:= =/= are the same as @== @/= in my scheme above. > > We could add the full set of term comparison operators, but not change the existing operators > So you could introduce the @ variants for numbers only instead. How about a triple sign notation for "strictness", as ===, /==, ==< ... !? Well ... <=< ... :-< > > > Henning > _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From mihai@REDACTED Wed Apr 13 18:46:38 2011 From: mihai@REDACTED (Mihai Balea) Date: Wed, 13 Apr 2011 12:46:38 -0400 Subject: [erlang-questions] Erlang beginner questions In-Reply-To: <1302711965491-3447649.post@n4.nabble.com> References: <1302661347349-3446106.post@n4.nabble.com> <1302679066266-3446453.post@n4.nabble.com> <827F5437-D9E7-4E55-8E5C-7BCB9240A2F8@hates.ms> <8EBC1BF4-25C8-4EA5-944E-46A7AB6813E5@erlang-solutions.com> <971BDCFA-6980-4768-B872-4B3335C3FF2A@hates.ms> <1302711965491-3447649.post@n4.nabble.com> Message-ID: <6531F569-DB33-4DA3-BB8D-BA2DFFE3767C@hates.ms> On Apr 13, 2011, at 12:26 PM, Mode7James wrote: > > Speaking of load bearing, is there a way for Erlang to read the cpu load of > a machine or machine that a node is run on? Take a look at the cpu_sup module. > Also, regarding linked-in drivers: I hear that if they crash, then it > brings the entire VM down. Is this just in case there is a bad piece of > code? If they are this unstable, then why are they used in production > environments? For something like an MMO server, I'll want extremely low > latency between the Erlang side and my math & physics side - but I also need > it to be stable so if something messes up or crashes, it doesn't bring the > entire system down. Yes, a linked in driver runs in your VM's process space, so if it crashes it can bring the entire VM down. They're not inherently unstable, its just that you're running (possibly buggy) native code inside your VM I would suggest you implement your logic in Erlang first, and only if it turns out you need better performance, think of native code. In many cases you won't need to. Also, in many cases tweaking the algorithm will bring you a whole lot more performance gains than going native. Mihai -------------- next part -------------- An HTML attachment was scrubbed... URL: From dangud@REDACTED Wed Apr 13 19:22:44 2011 From: dangud@REDACTED (Dan Gudmundsson) Date: Wed, 13 Apr 2011 19:22:44 +0200 Subject: [erlang-questions] wx-erlang question In-Reply-To: <4DA5B319.9010108@bobcowdery.plus.com> References: <4DA5B319.9010108@bobcowdery.plus.com> Message-ID: Hi Obj id 0 is null, so I guess getCaret returns NULL, you can check if something returns NULL with wx:is_null(Caret). But from the docs it looks like it always should return a caret, so it's a bit strange. I will take a closer look tomorrow so it's a not a wxerlang bug, but it might be a wxWidgets bug or just bad documentation. /Dan On Wed, Apr 13, 2011 at 4:28 PM, Bob Cowdery wrote: > Hi > > I'm having a fair bit of trouble with the syntax of wx-erlang. > > Having failed to get mouse wheel events from a wxStaticText (still my > first choice but I think it's a wx limitation and I'm not sure how to > work round it with Erlang) I thought I would try to make a wxTextCtrl > behave like a wxStaticText. One of the first things I wanted to do is > turn off the caret. > > T = wxTextCtrl:new(Panel, 1, [{value, "0"}]), > C = wxTextCtrl:getCaret(T), > wxCaret:hide(C), > > gives me: > ** exception exit: {{badarg,0},{wxCaret,hide,0}} > > but if I create a new caret I can call hide() on it. > > io:format("~p, ~p", [C, wxCaret:new(T, {1,1})]), > {wx_ref,0,wxCaret,[]}, {wx_ref,51,wxCaret,[]} > > Is it to do with fact that wx-erlang did not create it so has no object > reference as it seems to object to the id = 0. > > Bob > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > From James@REDACTED Wed Apr 13 19:59:10 2011 From: James@REDACTED (Mode7James) Date: Wed, 13 Apr 2011 10:59:10 -0700 (PDT) Subject: [erlang-questions] Erlang beginner questions In-Reply-To: <6531F569-DB33-4DA3-BB8D-BA2DFFE3767C@hates.ms> References: <1302661347349-3446106.post@n4.nabble.com> <1302679066266-3446453.post@n4.nabble.com> <827F5437-D9E7-4E55-8E5C-7BCB9240A2F8@hates.ms> <8EBC1BF4-25C8-4EA5-944E-46A7AB6813E5@erlang-solutions.com> <971BDCFA-6980-4768-B872-4B3335C3FF2A@hates.ms> <1302711965491-3447649.post@n4.nabble.com> <6531F569-DB33-4DA3-BB8D-BA2DFFE3767C@hates.ms> Message-ID: <1302717550649-3447862.post@n4.nabble.com> I read through this thread which sheds a little light on the subject: http://erlang.2086793.n4.nabble.com/NIF-vs-Linked-in-Drivers-td2103764.html Perhaps I'm not understanding this concept correctly. Are you saying that a linked-in driver is stable as long as there are no bugs in the native library, ie if the native library has been tested, then it should be fine and run with no issues? Or, if say my physics library gets a billion things all at once and decides to implode, so it crashes - does the whole computer running this process crash as well? Is there a way to segment it so that it doesn't crash the whole system? By "beam process" does it crash just the process that is currently running the linked-in driver or the entire system? >From what I thought, it would crash the entire system, ie the machine that is running the Virtual Machine. Is there a better way to keep latency extremely low, sending and receiving millions of variables on the same machine many times per second? I'm thinking of it like a box - the Physics box gets the current state & velocities, figures out the new state, and returns the state back to Erlang, which then takes things from there and delivers them to the appropriate parties. I understand and will be implementing things in Erlang at the start for testing purposes, however I want to make my physics system modular and use a library that can be installed both on the server and on the client, so what is ultimately used for the various math-intensive things will need to be written in a language like C++. I've been planing on using Box2d and Bullet, which can both be implemented on iOS, Android, Mac & PC, as well as server-side. Am I approaching this correctly? -- View this message in context: http://erlang.2086793.n4.nabble.com/Erlang-beginner-questions-tp3446106p3447862.html Sent from the Erlang Questions mailing list archive at Nabble.com. From james@REDACTED Wed Apr 13 20:13:28 2011 From: james@REDACTED (James Aimonetti) Date: Wed, 13 Apr 2011 11:13:28 -0700 Subject: [erlang-questions] iolist type not found by PropEr Message-ID: <4DA5E7C8.1030900@2600hz.com> I'm starting to add PropEr testing into my source code and ran into a small issue. When testing with the iolist() type, proper:quickcheck/1 complains: 1> proper:quickcheck(iolist_t:prop_iolist_t()). Error: The typeserver encountered an error: {missing_type,iolist_t,{type,iolist,0}}. {error,{typeserver,{missing_type,iolist_t,{type,iolist,0}}}} 2> The code: -module(iolist_t). -export([]). -include_lib("proper/include/proper.hrl"). prop_iolist_t() -> ?FORALL(IO, iolist(), is_binary(iolist_to_binary(IO))). This is on R14B01 and the latest PropEr from Github. If I copy/paste the typespec from the docs for iolist(), the compiler rightfully complains that iolist is already defined. Aside from this, I'm really enjoying adding PropEr testing. Thanks to Kostis & team for all the tools making my Erlang better. -- James Aimonetti Distributed Systems Engineer 2600hz | http://2600hz.com sip:james@REDACTED tel: 415.886.7905 From hd2010@REDACTED Wed Apr 13 20:36:47 2011 From: hd2010@REDACTED (H. Diedrich) Date: Wed, 13 Apr 2011 20:36:47 +0200 Subject: [erlang-questions] Erlang beginner questions In-Reply-To: <1302717550649-3447862.post@n4.nabble.com> References: <1302661347349-3446106.post@n4.nabble.com> <1302679066266-3446453.post@n4.nabble.com> <827F5437-D9E7-4E55-8E5C-7BCB9240A2F8@hates.ms> <8EBC1BF4-25C8-4EA5-944E-46A7AB6813E5@erlang-solutions.com> <971BDCFA-6980-4768-B872-4B3335C3FF2A@hates.ms> <1302711965491-3447649.post@n4.nabble.com> <6531F569-DB33-4DA3-BB8D-BA2DFFE3767C@hates.ms> <1302717550649-3447862.post@n4.nabble.com> Message-ID: <4DA5ED3F.7080407@eonblast.com> Hi James, "Let it crash" is the Erlang way of doing things, but it does NOT mean, let the VM crash, but Erlang processes. The VM is the saint cow in this context that absolutely must not crash. > Are you saying that a > linked-in driver is stable as long as there are no bugs in the native > library, ie if the native library has been tested, then it should be fine > and run with no issues? You mean library = driver I guess. Yes, when it is as stable as Erlang proper. > Or, if say my physics library gets a billion things > all at once and decides to implode, so it crashes - does the whole computer > running this process crash as well? No but the Erlang VM, if it's linked-in. Which is something you could otherwise almost completely rely upon to keep running and keep restarting and redoing whatever the uncompleted tasks had been when an Erlang-process crashed (which, again, is a different level of crashing). > Is there a better way to keep latency extremely low, sending and receiving > millions of variables on the same machine many times per second? It is. Not quite as fast as a function call but close. > I'm > thinking of it like a box - the Physics box gets the current state & > velocities, figures out the new state, and returns the state back to Erlang, > which then takes things from there and delivers them to the appropriate > parties. > > I understand and will be implementing things in Erlang at the start for > testing purposes, however I want to make my physics system modular and use a > library that can be installed both on the server and on the client, so what > is ultimately used for the various math-intensive things will need to be > written in a language like C++. I've been planing on using Box2d and > Bullet, which can both be implemented on iOS, Android, Mac & PC, as well as > server-side. Am I approaching this correctly? > You have to figure out how many calls / messages are needed. But in general it sounds very much like what you want is NOT a linked-in driver but a port to a separate Erlang VM, that resides on the same machine. I think this is an example of how you'd want to do it: http://gitorious.org/erlua/erlua/blobs/2fa39a954df8a6a5d7318dac7dc5728a830dab77/README Just you wouldn't embed Lua but your physics. Best, Henning From rtrlists@REDACTED Wed Apr 13 20:44:44 2011 From: rtrlists@REDACTED (Robert Raschke) Date: Wed, 13 Apr 2011 20:44:44 +0200 Subject: [erlang-questions] Pattern matching in function calls In-Reply-To: References: <4DA58CB2.9070508@ecs.soton.ac.uk> <4DA5A144.5070800@ecs.soton.ac.uk> Message-ID: Hi Dave, probably not quite the answer you were looking for, but aim for readability first (that's usually already hard enough :-). Only compromise that if something is measurably too slow. In the example you give, it doesn't appear to make any big difference for readability, but I assume your real code is a bit more "interesting"? Robby On 4/13/11, Dave Challis wrote: > On 13/04/11 13:46, Antoine Koener wrote: >> >> On Apr 13, 2011, at 13:44 , Dave Challis wrote: >> >>> Does the order of patterns in a function call matter? Are they all >>> tested, or will erlang stop trying to match them once a mismatch has >>> been found? >>> >>> As an example, if I've got: >>> >>> foo(<>, a) -> a; >>> foo(<>, b) -> b. >>> >>> will the above be any slower than defining: >>> >>> foo(a, <>) -> a; >>> foo(b, <>) -> b. >>> >>> Will the <> attempt to be matched in every case? Is >>> it something worth thinking about, or will the compiler optimise this? >> >> If the content of <> is irrelevant, you can use the '_' >> notation: >> >> foo(a, _Bin) -> a; >> foo(b, _Bin) -> b; >> >> Then this is explicit for the reader that you don't want to check _Bin. > > Sorry, my example wasn't great, I was more wondering about the cases > when the binary data is relevant. > > So a better example might be: > > foo(<<$x,_Rest/binary>>, a) -> a1; > foo(<<$y,_Rest/binary>>, a) -> a2; > foo(<<$z,_Rest/binary>>, a) -> a3; > foo(<<$x,_Rest/binary>>, b) -> b. > > If I then called: > foo(<<"x">>, b). > > Would erlang perform 4 binary pattern matches until it got to the last > clause? > > Or would it optimise things and only perform a single binary match by > matching on the atoms first? > > Or will it always test all arguments in all cases? > > > -- > Dave Challis > dsc@REDACTED > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > From James@REDACTED Wed Apr 13 20:50:57 2011 From: James@REDACTED (Mode7James) Date: Wed, 13 Apr 2011 11:50:57 -0700 (PDT) Subject: [erlang-questions] Erlang beginner questions In-Reply-To: <4DA5ED3F.7080407@eonblast.com> References: <1302661347349-3446106.post@n4.nabble.com> <1302679066266-3446453.post@n4.nabble.com> <827F5437-D9E7-4E55-8E5C-7BCB9240A2F8@hates.ms> <8EBC1BF4-25C8-4EA5-944E-46A7AB6813E5@erlang-solutions.com> <971BDCFA-6980-4768-B872-4B3335C3FF2A@hates.ms> <1302711965491-3447649.post@n4.nabble.com> <6531F569-DB33-4DA3-BB8D-BA2DFFE3767C@hates.ms> <1302717550649-3447862.post@n4.nabble.com> <4DA5ED3F.7080407@eonblast.com> Message-ID: <1302720657453-3447953.post@n4.nabble.com> This is exactly they type of example I'm looking for, thanks Henning! And I've been thinking I should embed a scripting language like Lua for developers extending things without modifying underlying code, so this is a really great find, thanks. So, just so I understand you correctly on the whole linked-in vs port driver thing: Each computer has one instance of the Erlang VM running. Each VM can have many processes. Using a linked-in driver essentially treats that C module as an extension of the Erlang VM itself, so if it crashes, so do all of the processes that are running in that VM on the individual machine. Does the VM restart automagically, or does it require a manual restart? Say it crashes at 3a.m. does it require someone to come out and restart it and start all of the nodes? A port driver, on the other hand, is treated as a separate node. If it crashes, it is contained within that node. It is slightly slower than a linked-in driver though. Is it fast enough to implement many messages per second back & forth? By saying it's not quite as fast as a function call I'm assuming you mean a linked-in driver call, right? Essentially a port driver is probably best for implementing hardcore math many times per second, right? This is really cool by the way. All of these questions I've had for quite a while, searching Google for examples & such. Thanks! -James -- View this message in context: http://erlang.2086793.n4.nabble.com/Erlang-beginner-questions-tp3446106p3447953.html Sent from the Erlang Questions mailing list archive at Nabble.com. From bob@REDACTED Wed Apr 13 21:04:03 2011 From: bob@REDACTED (Bob Cowdery) Date: Wed, 13 Apr 2011 20:04:03 +0100 Subject: [erlang-questions] wx-erlang question In-Reply-To: References: <4DA5B319.9010108@bobcowdery.plus.com> Message-ID: <4DA5F3A3.6030502@bobcowdery.plus.com> Dan Thanks. I thought was was just an integer id. Will look out for that in the future. Just had a play in python. It does the same, returns None. I tried creating a new caret, setting it on the text control and then hiding it. No complaints but it didn't do anything so I guess caret handling is all buggy. Found one mention on wxPython-users which indicates that GetCaret will only return a caret on 'some' platforms. I'm on Win 7. Looks like I need to think of another work round. Bob On 13/04/2011 18:22, Dan Gudmundsson wrote: > Hi > > Obj id 0 is null, so I guess getCaret returns NULL, > you can check if something returns NULL with wx:is_null(Caret). > > But from the docs it looks like it always should return a caret, so > it's a bit strange. > I will take a closer look tomorrow so it's a not a wxerlang bug, but > it might be a wxWidgets bug > or just bad documentation. > > /Dan > > On Wed, Apr 13, 2011 at 4:28 PM, Bob Cowdery wrote: >> Hi >> >> I'm having a fair bit of trouble with the syntax of wx-erlang. >> >> Having failed to get mouse wheel events from a wxStaticText (still my >> first choice but I think it's a wx limitation and I'm not sure how to >> work round it with Erlang) I thought I would try to make a wxTextCtrl >> behave like a wxStaticText. One of the first things I wanted to do is >> turn off the caret. >> >> T = wxTextCtrl:new(Panel, 1, [{value, "0"}]), >> C = wxTextCtrl:getCaret(T), >> wxCaret:hide(C), >> >> gives me: >> ** exception exit: {{badarg,0},{wxCaret,hide,0}} >> >> but if I create a new caret I can call hide() on it. >> >> io:format("~p, ~p", [C, wxCaret:new(T, {1,1})]), >> {wx_ref,0,wxCaret,[]}, {wx_ref,51,wxCaret,[]} >> >> Is it to do with fact that wx-erlang did not create it so has no object >> reference as it seems to object to the id = 0. >> >> Bob >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> From hd2010@REDACTED Wed Apr 13 21:06:52 2011 From: hd2010@REDACTED (H. Diedrich) Date: Wed, 13 Apr 2011 21:06:52 +0200 Subject: [erlang-questions] Erlang beginner questions In-Reply-To: <1302720657453-3447953.post@n4.nabble.com> References: <1302661347349-3446106.post@n4.nabble.com> <1302679066266-3446453.post@n4.nabble.com> <827F5437-D9E7-4E55-8E5C-7BCB9240A2F8@hates.ms> <8EBC1BF4-25C8-4EA5-944E-46A7AB6813E5@erlang-solutions.com> <971BDCFA-6980-4768-B872-4B3335C3FF2A@hates.ms> <1302711965491-3447649.post@n4.nabble.com> <6531F569-DB33-4DA3-BB8D-BA2DFFE3767C@hates.ms> <1302717550649-3447862.post@n4.nabble.com> <4DA5ED3F.7080407@eonblast.com> <1302720657453-3447953.post@n4.nabble.com> Message-ID: <4DA5F44C.70403@eonblast.com> Welcome! > This is exactly they type of example I'm looking for, thanks Henning! And > I've been thinking I should embed a scripting language like Lua for > developers extending things without modifying underlying code, so this is a > really great find, thanks. > Be sure to check out other projects re Lua. This was really referred to as an example of architecture. > Each computer has one instance of the Erlang VM running. You can have more, in fact, 2 might make sense and that's what I think might be what you want. > Each VM can have > many processes. Using a linked-in driver essentially treats that C module > as an extension of the Erlang VM itself, so if it crashes, so do all of the > processes that are running in that VM on the individual machine. Right. > Does the > VM restart automagically, or does it require a manual restart? Erlang is made for the VM never to crash and it has an elaborate structure on how processes inside the VM restart each other and supervise each other. That architecture can span multiple 'nodes'. But when crashing, dying, exiting is talked about, in general you want it all to happen 'gracefully' and not have to restart the entire VM. BUT you could decide to have your C library linked-in to one Erlang VM, with very thin Erlang code on top, that talks to another VM (node) and of that first one you make sure comes up automatically if the whole VM crashes, e.g. due to the C stuff, while the second is your main Erlang node. > A port driver, on the other hand, is treated as a separate node. If it > crashes, it is contained within that node. It is slightly slower than a > linked-in driver though. Is it fast enough to implement many messages per > second back & forth? Absolutely. > By saying it's not quite as fast as a function call > I'm assuming you mean a linked-in driver call, right? Yes. But also in Erlang proper, sending messages is a tad slower than function calls. > Essentially a port > driver is probably best for implementing hardcore math many times per > second, right? > Many times per second would be "low frequency" and so, especially if you must realistically expect crashes, yes. Henning From dangud@REDACTED Wed Apr 13 21:07:08 2011 From: dangud@REDACTED (Dan Gudmundsson) Date: Wed, 13 Apr 2011 21:07:08 +0200 Subject: [erlang-questions] wx-erlang question In-Reply-To: <4DA5F3A3.6030502@bobcowdery.plus.com> References: <4DA5B319.9010108@bobcowdery.plus.com> <4DA5F3A3.6030502@bobcowdery.plus.com> Message-ID: Ok Just for the record it is just an integer id, with id 0 has the special meaning NULL. /Dan On Wed, Apr 13, 2011 at 9:04 PM, Bob Cowdery wrote: > Dan > > Thanks. I thought was was just an integer id. Will look out for that in > the future. > Just had a play in python. It does the same, returns None. I tried > creating a new caret, setting it on the text control and then hiding it. > No complaints but it didn't do anything so I guess caret handling is all > buggy. > > Found one mention on wxPython-users which indicates that GetCaret will > only return a caret on 'some' platforms. I'm on Win 7. Looks like I need > to think of another work round. > > Bob > > On 13/04/2011 18:22, Dan Gudmundsson wrote: >> Hi >> >> Obj id 0 is null, so I guess getCaret returns NULL, >> you can check if something returns NULL with wx:is_null(Caret). >> >> But from the docs it looks like it always should return a caret, so >> it's a bit strange. >> I will take a closer look tomorrow so it's a not a wxerlang bug, but >> it might be a wxWidgets bug >> or just bad documentation. >> >> /Dan >> >> On Wed, Apr 13, 2011 at 4:28 PM, Bob Cowdery wrote: >>> Hi >>> >>> I'm having a fair bit of trouble with the syntax of wx-erlang. >>> >>> Having failed to get mouse wheel events from a wxStaticText (still my >>> first choice but I think it's a wx limitation and I'm not sure how to >>> work round it with Erlang) I thought I would try to make a wxTextCtrl >>> behave like a wxStaticText. One of the first things I wanted to do is >>> turn off the caret. >>> >>> T = wxTextCtrl:new(Panel, 1, [{value, "0"}]), >>> C = wxTextCtrl:getCaret(T), >>> wxCaret:hide(C), >>> >>> gives me: >>> ** exception exit: {{badarg,0},{wxCaret,hide,0}} >>> >>> but if I create a new caret I can call hide() on it. >>> >>> io:format("~p, ~p", [C, wxCaret:new(T, {1,1})]), >>> {wx_ref,0,wxCaret,[]}, {wx_ref,51,wxCaret,[]} >>> >>> Is it to do with fact that wx-erlang did not create it so has no object >>> reference as it seems to object to the id = 0. >>> >>> Bob >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://erlang.org/mailman/listinfo/erlang-questions >>> > > From dangud@REDACTED Wed Apr 13 21:13:07 2011 From: dangud@REDACTED (Dan Gudmundsson) Date: Wed, 13 Apr 2011 21:13:07 +0200 Subject: [erlang-questions] Erlang beginner questions In-Reply-To: <4DA5F44C.70403@eonblast.com> References: <1302661347349-3446106.post@n4.nabble.com> <1302679066266-3446453.post@n4.nabble.com> <827F5437-D9E7-4E55-8E5C-7BCB9240A2F8@hates.ms> <8EBC1BF4-25C8-4EA5-944E-46A7AB6813E5@erlang-solutions.com> <971BDCFA-6980-4768-B872-4B3335C3FF2A@hates.ms> <1302711965491-3447649.post@n4.nabble.com> <6531F569-DB33-4DA3-BB8D-BA2DFFE3767C@hates.ms> <1302717550649-3447862.post@n4.nabble.com> <4DA5ED3F.7080407@eonblast.com> <1302720657453-3447953.post@n4.nabble.com> <4DA5F44C.70403@eonblast.com> Message-ID: Depending on the problem, but if you want more raw math power, physics can be calculated with OpenCL, and by using that you don't have to write a driver (or nif lib) yourself. But as always write it in erlang first then go the driver/OpenCL route, and you have a nice debugged reference implementation as well. /Dan On Wed, Apr 13, 2011 at 9:06 PM, H. Diedrich wrote: > Welcome! >> >> This is exactly they type of example I'm looking for, thanks Henning! ?And >> I've been thinking I should embed a scripting language like Lua for >> developers extending things without modifying underlying code, so this is >> a >> really great find, thanks. >> > > Be sure to check out other projects re Lua. This was really referred to as > an example of architecture. >> >> Each computer has one instance of the Erlang VM running. > > You can have more, in fact, 2 might make sense and that's what I think might > be what you want. >> >> Each VM can have >> many processes. ?Using a linked-in driver essentially treats that C module >> as an extension of the Erlang VM itself, so if it crashes, so do all of >> the >> processes that are running in that VM on the individual machine. > > Right. >> >> Does the >> VM restart automagically, or does it require a manual restart? > > Erlang is made for the VM never to crash and it has an elaborate structure > on how processes inside the VM restart each other and supervise each other. > That architecture can span multiple 'nodes'. But when crashing, dying, > exiting is talked about, in general you want it all to happen 'gracefully' > and not have to restart the entire VM. > > BUT you could decide to have your C library linked-in to one Erlang VM, with > very thin Erlang code on top, that talks to another VM (node) and of that > first one you make sure comes up automatically if the whole VM crashes, e.g. > due to the C stuff, while the second is your main Erlang node. >> >> A port driver, on the other hand, is treated as a separate node. ?If it >> crashes, it is contained within that node. ?It is slightly slower than a >> linked-in driver though. ?Is it fast enough to implement many messages per >> second back & forth? > > Absolutely. >> >> By saying it's not quite as fast as a function call >> I'm assuming you mean a linked-in driver call, right? > > Yes. But also in Erlang proper, sending messages is a tad slower than > function calls. >> >> ?Essentially a port >> driver is probably best for implementing hardcore math many times per >> second, right? >> > > Many times per second would be "low frequency" and so, especially if you > must realistically expect crashes, yes. > > Henning > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > From James@REDACTED Wed Apr 13 21:14:08 2011 From: James@REDACTED (Mode7James) Date: Wed, 13 Apr 2011 12:14:08 -0700 (PDT) Subject: [erlang-questions] Erlang beginner questions In-Reply-To: <4DA5F44C.70403@eonblast.com> References: <1302679066266-3446453.post@n4.nabble.com> <827F5437-D9E7-4E55-8E5C-7BCB9240A2F8@hates.ms> <8EBC1BF4-25C8-4EA5-944E-46A7AB6813E5@erlang-solutions.com> <971BDCFA-6980-4768-B872-4B3335C3FF2A@hates.ms> <1302711965491-3447649.post@n4.nabble.com> <6531F569-DB33-4DA3-BB8D-BA2DFFE3767C@hates.ms> <1302717550649-3447862.post@n4.nabble.com> <4DA5ED3F.7080407@eonblast.com> <1302720657453-3447953.post@n4.nabble.com> <4DA5F44C.70403@eonblast.com> Message-ID: <1302722048203-3448005.post@n4.nabble.com> I'm starting to get it now. Essentially creating a thin wrapper VM for a linked-in library is pretty much the same thing as a port driver, right? It basically creates a new node, so functions are called by passing messages, which then we go back to messages vs function calls. Why re-create the wheel? Is there a speed difference between the two do you think, or should I stick with a port driver? If my physics node, using a port driver, crashes, is there an automated way to bring it back and restart it without manually restarting it? If not through Erlang itself, has anyone developed an underlying C-based application that runs as an overall supervisor? Keeping track of VM's that crash, and restarting as necessary? -- View this message in context: http://erlang.2086793.n4.nabble.com/Erlang-beginner-questions-tp3446106p3448005.html Sent from the Erlang Questions mailing list archive at Nabble.com. From James@REDACTED Wed Apr 13 21:16:10 2011 From: James@REDACTED (Mode7James) Date: Wed, 13 Apr 2011 12:16:10 -0700 (PDT) Subject: [erlang-questions] Erlang beginner questions In-Reply-To: References: <827F5437-D9E7-4E55-8E5C-7BCB9240A2F8@hates.ms> <8EBC1BF4-25C8-4EA5-944E-46A7AB6813E5@erlang-solutions.com> <971BDCFA-6980-4768-B872-4B3335C3FF2A@hates.ms> <1302711965491-3447649.post@n4.nabble.com> <6531F569-DB33-4DA3-BB8D-BA2DFFE3767C@hates.ms> <1302717550649-3447862.post@n4.nabble.com> <4DA5ED3F.7080407@eonblast.com> <1302720657453-3447953.post@n4.nabble.com> <4DA5F44C.70403@eonblast.com> Message-ID: <1302722170441-3448012.post@n4.nabble.com> Is OpenCL available on a server? I won't be running Erlang in the client, but rather the server-side only. This is something I never thought of. -- View this message in context: http://erlang.2086793.n4.nabble.com/Erlang-beginner-questions-tp3446106p3448012.html Sent from the Erlang Questions mailing list archive at Nabble.com. From t.greenwoodgeer@REDACTED Wed Apr 13 21:44:23 2011 From: t.greenwoodgeer@REDACTED (Todd Greenwood-Geer) Date: Wed, 13 Apr 2011 12:44:23 -0700 Subject: [erlang-questions] Beginner Question: Spring-like IOC in erlang In-Reply-To: <1302720657453-3447953.post@n4.nabble.com> References: <1302661347349-3446106.post@n4.nabble.com> <1302679066266-3446453.post@n4.nabble.com> <827F5437-D9E7-4E55-8E5C-7BCB9240A2F8@hates.ms> <8EBC1BF4-25C8-4EA5-944E-46A7AB6813E5@erlang-solutions.com> <971BDCFA-6980-4768-B872-4B3335C3FF2A@hates.ms> <1302711965491-3447649.post@n4.nabble.com> <6531F569-DB33-4DA3-BB8D-BA2DFFE3767C@hates.ms> <1302717550649-3447862.post@n4.nabble.com> <4DA5ED3F.7080407@eonblast.com> <1302720657453-3447953.post@n4.nabble.com> Message-ID: <4DA5FD17.9040608@gmail.com> 1. Is there an idiomatic way to use dependency injection in erlang? Most of my use of Spring DI has been to facilitate injection of test classes into a stack for functional testing. Is this sort of thing done in erlang? 2. How about AOP style join-points for before and after execution around a method? As an example, wouldn't it be cool to dynamically enable debug or trace level logging for an application when a certain error threshold is reached? Then, when the system returns to a normal state, the error logging could be turned back down... I think I might start doing this in the Java stacks I'm currently working with (log4j). 3. Is there a way to intercept messages to a process? This is the real question... Say a process dies unexpectedly and OTP restarts it... it would be cool to be able to dynamically proxy messages to a process that has exceeded some error threshold. The proxy could log them, or perform more intensive error analysis... Then, once the system is back in a normal state, the proxy could be removed from the message loop chain. -Todd From dangud@REDACTED Wed Apr 13 21:58:18 2011 From: dangud@REDACTED (Dan Gudmundsson) Date: Wed, 13 Apr 2011 21:58:18 +0200 Subject: [erlang-questions] Erlang beginner questions In-Reply-To: <1302722170441-3448012.post@n4.nabble.com> References: <827F5437-D9E7-4E55-8E5C-7BCB9240A2F8@hates.ms> <8EBC1BF4-25C8-4EA5-944E-46A7AB6813E5@erlang-solutions.com> <971BDCFA-6980-4768-B872-4B3335C3FF2A@hates.ms> <1302711965491-3447649.post@n4.nabble.com> <6531F569-DB33-4DA3-BB8D-BA2DFFE3767C@hates.ms> <1302717550649-3447862.post@n4.nabble.com> <4DA5ED3F.7080407@eonblast.com> <1302720657453-3447953.post@n4.nabble.com> <4DA5F44C.70403@eonblast.com> <1302722170441-3448012.post@n4.nabble.com> Message-ID: On Wed, Apr 13, 2011 at 9:16 PM, Mode7James wrote: > Is OpenCL available on a server? ?I won't be running Erlang in the client, > but rather the server-side only. ?This is something I never thought of. > OpenCL depends on OS and graphics drivers, but Snow Leopard comes with excellent drivers, if that is what you are using on the server. On the other OS'es it depends on graphics card. But ATI supplies an OpenCL driver/reference implementation for X86 architecture in the SDK for both linux and Windows. I guess intel is developing it's own drivers but I haven't seen it yet (haven't looked). But it might be even worse bugs in OpenCL code/drivers may crash the server, instead of the erlang-wm :-) /Dan From kostis@REDACTED Wed Apr 13 21:59:45 2011 From: kostis@REDACTED (Kostis Sagonas) Date: Wed, 13 Apr 2011 22:59:45 +0300 Subject: [erlang-questions] iolist type not found by PropEr In-Reply-To: <4DA5E7C8.1030900@2600hz.com> References: <4DA5E7C8.1030900@2600hz.com> Message-ID: <4DA600B1.7080300@cs.ntua.gr> James Aimonetti wrote: > I'm starting to add PropEr testing into my source code and ran into a > small issue. When testing with the iolist() type, proper:quickcheck/1 > complains: > > 1> proper:quickcheck(iolist_t:prop_iolist_t()). > > Error: The typeserver encountered an error: > {missing_type,iolist_t,{type,iolist,0}}. > {error,{typeserver,{missing_type,iolist_t,{type,iolist,0}}}} > 2> > > The code: > > -module(iolist_t). > > -export([]). > > -include_lib("proper/include/proper.hrl"). > > prop_iolist_t() -> > ?FORALL(IO, iolist(), is_binary(iolist_to_binary(IO))). > > This is on R14B01 and the latest PropEr from Github. If I copy/paste the > typespec from the docs for iolist(), the compiler rightfully complains > that iolist is already defined. We are aware of the issue; it's on our TODO list. We are trying to find the proper way of also generating improper lists --- for some reason we find it... well, probably not the PropEr thing to do ;-) > Aside from this, I'm really enjoying adding PropEr testing. Thanks to > Kostis & team for all the tools making my Erlang better. Thanks a lot for your comments and for liking even the tools we have not properly released yet! Kostis From mihai@REDACTED Wed Apr 13 22:18:47 2011 From: mihai@REDACTED (Mihai Balea) Date: Wed, 13 Apr 2011 16:18:47 -0400 Subject: [erlang-questions] Erlang beginner questions In-Reply-To: <1302722048203-3448005.post@n4.nabble.com> References: <1302679066266-3446453.post@n4.nabble.com> <827F5437-D9E7-4E55-8E5C-7BCB9240A2F8@hates.ms> <8EBC1BF4-25C8-4EA5-944E-46A7AB6813E5@erlang-solutions.com> <971BDCFA-6980-4768-B872-4B3335C3FF2A@hates.ms> <1302711965491-3447649.post@n4.nabble.com> <6531F569-DB33-4DA3-BB8D-BA2DFFE3767C@hates.ms> <1302717550649-3447862.post@n4.nabble.com> <4DA5ED3F.7080407@eonblast.com> <1302720657453-3447953.post@n4.nabble.com> <4DA5F44C.70403@eonblast.com> <1302722048203-3448005.post@n4.nabble.com> Message-ID: On Apr 13, 2011, at 3:14 PM, Mode7James wrote: > I'm starting to get it now. > > Essentially creating a thin wrapper VM for a linked-in library is pretty > much the same thing as a port driver, right? It basically creates a new > node, so functions are called by passing messages, which then we go back to > messages vs function calls. Why re-create the wheel? Is there a speed > difference between the two do you think, or should I stick with a port > driver? > > If my physics node, using a port driver, crashes, is there an automated way > to bring it back and restart it without manually restarting it? If not > through Erlang itself, has anyone developed an underlying C-based > application that runs as an overall supervisor? Keeping track of VM's that > crash, and restarting as necessary? Not entirely correct. You have a number of ways to mesh native code with Erlang: - Port: runs in a separate system process and communicates with the VM using the process stdin and stdout. If the driver crashes, the VM survives and can restart the port. - Linked-in driver: runs in the VM's process space. If it crashes, it will bring down the entire VM (but not the machine running the VM) - Separate node. You can actually write a pseudo-node in a different language. Look at the ei and ei_connect modules. From the point of view of your Erlang VM, this appears as a normal Erlang node that can send and receive messages. Obviously, if your pseudo-node goes down, nothing bad happens to your VM. - Recent Erlang releases offer a new mechanism called NIF that allows even tighter integration than a linked-in driver. I'm not very familiar with it, but I suppose the same caveats as for linked in drivers apply With tighter integration comes increased performance, but also increased risk. You would need to do a cost benefit analysis and figure out what would work best for you. Finally, if you start your VM with the -heart parameter, you'll get an external heart process that monitors your VM and restarts it if it crashes or hangs Mihai From James@REDACTED Wed Apr 13 22:34:56 2011 From: James@REDACTED (Mode7James) Date: Wed, 13 Apr 2011 13:34:56 -0700 (PDT) Subject: [erlang-questions] Erlang beginner questions In-Reply-To: References: <8EBC1BF4-25C8-4EA5-944E-46A7AB6813E5@erlang-solutions.com> <971BDCFA-6980-4768-B872-4B3335C3FF2A@hates.ms> <1302711965491-3447649.post@n4.nabble.com> <6531F569-DB33-4DA3-BB8D-BA2DFFE3767C@hates.ms> <1302717550649-3447862.post@n4.nabble.com> <4DA5ED3F.7080407@eonblast.com> <1302720657453-3447953.post@n4.nabble.com> <4DA5F44C.70403@eonblast.com> <1302722048203-3448005.post@n4.nabble.com> Message-ID: <1302726896463-3448167.post@n4.nabble.com> @Dan - yeah I will be building this and updating from a macbook, but ultimately I plan on deploying to a blade. That's another whole bag of worms that I'll sort out when I come to it :) @Mihai Ahh, this makes sense. I'll start by building my initial TCP and UDP tests, but when I want to add a physics library I'll probably start by using a port, which can be restarted, and then if I still need it to be faster I can write a wrapper over linked-in driver, using the -heart tag. This way, I can deploy by starting the initial simulation, which can run independently of the physics engine, which can be in another VM. I love that -heart tag by the way! First task I need to accomplish is to get a ball moving around the screen. Hello World! I know this is off topic, but I've been reading about Rift's server tech: http://www.develop-online.net/news/35960/Trion-has-built-a-server-equivalent-to-Sonys-Cell It seems to me they could've used Erlang and saved quite a few years of developing their own proprietary system? I know, I know - showing my ignorance here :) -- View this message in context: http://erlang.2086793.n4.nabble.com/Erlang-beginner-questions-tp3446106p3448167.html Sent from the Erlang Questions mailing list archive at Nabble.com. From bob@REDACTED Wed Apr 13 23:51:38 2011 From: bob@REDACTED (Bob Ippolito) Date: Wed, 13 Apr 2011 14:51:38 -0700 Subject: [erlang-questions] Spawnfest: a 48 hour programming contest featuring Erlang In-Reply-To: References: Message-ID: On Mon, Apr 11, 2011 at 5:55 PM, Yurii Rashkovskii wrote: > Hi everybody, > > We're happy to announce that first Spawnfest (48 hour programming > contest for Erlang, much like Rails Rumble and Node Knockout) is > scheduled for 9th and 10th of July 2011. Our committee is currently > working on competition rules and sponsors/prizes. We've secured some > of the big names in the Erlang community as judges and planning to > involve more judges so that every team gets fair review. > > We're very excited about this opportunity to show the world what > Erlang/OTP is capable of! The contest is not limiting entrants to web > applications, in fact, we'll be having nominees in different > categories. > > You can register your team at http://spawnfest.com/ > > Feel free to post any question on the mailing list, we will be happy > to address those. > > If you're interested in becoming a sponsor, please email me at yrashk > at ?gmail.com; it could be a tremendous opportunity to expose your > business. If you haven't seen it yet, there's a great video about Spawnfest here: http://vimeo.com/22360540 -bob From vinoski@REDACTED Wed Apr 13 23:52:53 2011 From: vinoski@REDACTED (Steve Vinoski) Date: Wed, 13 Apr 2011 17:52:53 -0400 Subject: [erlang-questions] Beginner Question: Spring-like IOC in erlang In-Reply-To: <4DA5FD17.9040608@gmail.com> References: <1302661347349-3446106.post@n4.nabble.com> <1302679066266-3446453.post@n4.nabble.com> <827F5437-D9E7-4E55-8E5C-7BCB9240A2F8@hates.ms> <8EBC1BF4-25C8-4EA5-944E-46A7AB6813E5@erlang-solutions.com> <971BDCFA-6980-4768-B872-4B3335C3FF2A@hates.ms> <1302711965491-3447649.post@n4.nabble.com> <6531F569-DB33-4DA3-BB8D-BA2DFFE3767C@hates.ms> <1302717550649-3447862.post@n4.nabble.com> <4DA5ED3F.7080407@eonblast.com> <1302720657453-3447953.post@n4.nabble.com> <4DA5FD17.9040608@gmail.com> Message-ID: On Wed, Apr 13, 2011 at 3:44 PM, Todd Greenwood-Geer wrote: > 1. Is there an idiomatic way to use dependency injection in erlang? > > Most of my use of Spring DI has been to facilitate injection of test classes > into a stack for functional testing. Is this sort of thing done in erlang? I guess it depends on the type of dependency you're injecting. Is it a module, a function, a process? You can inject module dependencies by passing their names, or using still-marked-as-experimental parameterized modules, or even dynamically loading them under names already known to the code using them (you can even go so far as to generate and load modules on the fly). You can inject functions by passing them. You can inject processes by passing pids or by registering them under names already known to the code using them using the standard registry, pg2, or (see especially) gproc. > 2. How about AOP style join-points for before and after execution around a > method? > > As an example, wouldn't it be cool to dynamically enable debug or trace > level logging for an application when a certain error threshold is reached? > Then, when the system returns to a normal state, the error logging could be > turned back down... I think I might start doing this in the Java stacks I'm > currently working with (log4j). You don't need AOP to do that, since you can monitor the error threshold with a separate process and have it enable debug or trace logging on the problematic module when appropriate. > 3. Is there a way to intercept messages to a process? This is the real > question... Say a process dies unexpectedly and OTP restarts it... it would > be cool to be able to dynamically proxy messages to a process that has > exceeded some error threshold. The proxy could log them, or perform more > intensive error analysis... Then, once the system is back in a normal state, > the proxy could be removed from the message loop chain. Strict interception can be done by registering a proxy in place of the real process, but if you just want to see the messages without requiring them to hop through an extra process, debug tracing can do that. See Chapter 17 of Francesco's and Simon's book: http://oreilly.com/catalog/9780596518189 Erlang's tracing facilities are incredibly powerful. --steve From moxford@REDACTED Thu Apr 14 00:15:14 2011 From: moxford@REDACTED (Mike Oxford) Date: Wed, 13 Apr 2011 15:15:14 -0700 Subject: [erlang-questions] Supervisor "spin rates" Message-ID: Theory: I create a socket_sup which supervises a listener socket. Socket tries to bind, fails .. let it crash...super restarts. Tries to bind, fails, let it crash... Repeat ad nauseam until every supervisor all the way up is dead. I don't see a way for the supervisor to check the child return code to say "whoa, I know I'm supposed to restart this but my child just told me it's simply not doable." Is the "right way" to set it to simple_one_for_one transient, fail the bind, log the error and then terminate "successfully" so the child doesn't get restarted? Set it to simple_one_for_one and "never restart," throw an error to the caller and forget about supervision ...? Yeah, I know it "should never happen" but once it's in production and out of dev-hands...who knows what'll happen in a given configuration file (or during a restart/move.) Thanks! -mox -------------- next part -------------- An HTML attachment was scrubbed... URL: From vances@REDACTED Thu Apr 14 00:19:44 2011 From: vances@REDACTED (Vance Shipley) Date: Wed, 13 Apr 2011 18:19:44 -0400 Subject: [erlang-questions] Supervisor "spin rates" In-Reply-To: References: Message-ID: <20110413221944.GL4859@h216-235-12-174.host.egate.net> If you are binding during initialization you could return 'ignore'. On Wed, Apr 13, 2011 at 03:15:14PM -0700, Mike Oxford wrote: } I don't see a way for the supervisor to check the child return code to say } "whoa, I know I'm supposed to restart this but } my child just told me it's simply not doable." -- -Vance From moxford@REDACTED Thu Apr 14 00:26:30 2011 From: moxford@REDACTED (Mike Oxford) Date: Wed, 13 Apr 2011 15:26:30 -0700 Subject: [erlang-questions] Supervisor "spin rates" In-Reply-To: <20110413221944.GL4859@h216-235-12-174.host.egate.net> References: <20110413221944.GL4859@h216-235-12-174.host.egate.net> Message-ID: That will terminate the supervisor as well, which is then restarted.... -mox On Wed, Apr 13, 2011 at 3:19 PM, Vance Shipley wrote: > If you are binding during initialization you could return 'ignore'. > > On Wed, Apr 13, 2011 at 03:15:14PM -0700, Mike Oxford wrote: > } I don't see a way for the supervisor to check the child return code to > say > } "whoa, I know I'm supposed to restart this but > } my child just told me it's simply not doable." > > -- > -Vance > -------------- next part -------------- An HTML attachment was scrubbed... URL: From vances@REDACTED Thu Apr 14 01:05:30 2011 From: vances@REDACTED (Vance Shipley) Date: Wed, 13 Apr 2011 19:05:30 -0400 Subject: [erlang-questions] Supervisor "spin rates" In-Reply-To: References: <20110413221944.GL4859@h216-235-12-174.host.egate.net> Message-ID: <20110413230530.GM4859@h216-235-12-174.host.egate.net> On Wed, Apr 13, 2011 at 03:26:30PM -0700, Mike Oxford wrote: } That will terminate the supervisor as well, which is then restarted.... The supervisor will ignore the child. supervisor:start_child/2 will return {ok, undefined}. Start the supervisor: 2> {ok, Sup} = supervisor:start_link(ignore_sup, []). {ok,<0.43.0>} It has no children: 3> supervisor:which_children(Sup). [] Starting the child: 4> supervisor:start_child(Sup, []). =ERROR REPORT==== 13-Apr-2011::18:59:01 === Ignoring: <0.46.0> {ok,undefined} The child specification is installed: 5> supervisor:which_children(Sup). [{undefined,undefined,worker,[ignore_server]}] But the child process reported above is not alive: 6> is_process_alive(list_to_pid("<0.46.0>")). false -- -Vance -------------- next part -------------- -module(ignore_server). -behaviour(gen_server). -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]). init(_) -> error_logger:warning_msg("Ignoring: ~w~n", [self()]), ignore. handle_cast(_, State) -> {noreply, State}. handle_call(_, _, State) -> {noreply, State}. handle_info(_, State) -> {noreply, State}. terminate(_, _) -> ok. code_change(_, State, _) -> {ok, State}. -------------- next part -------------- -module(ignore_sup). -export([init/1]). -behaviour(supervisor). init(_StartArgs) -> StartMod = ignore_server, StartFunc = {gen_server, start_link, [StartMod, [], []]}, ChildSpec = {StartMod, StartFunc, transient, 4000, worker, [StartMod]}, {ok,{{simple_one_for_one, 10, 60}, [ChildSpec]}}. From ulf.wiger@REDACTED Thu Apr 14 01:13:04 2011 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Thu, 14 Apr 2011 00:13:04 +0100 Subject: [erlang-questions] iolist type not found by PropEr In-Reply-To: <4DA600B1.7080300@cs.ntua.gr> References: <4DA5E7C8.1030900@2600hz.com> <4DA600B1.7080300@cs.ntua.gr> Message-ID: On 13 Apr 2011, at 20:59, Kostis Sagonas wrote: > We are aware of the issue; it's on our TODO list. We are trying to find the proper way of also generating improper lists --- for some reason we find it... well, probably not the PropEr thing to do ;-) FWIW, I had to implement a generator for non-proper lists in the EQC tests for my 'sext' library: https://github.com/esl/sext/blob/master/test/sext_eqc.erl#L283 I'm not suggesting that this is the best way to do it, but at least it *does* generate non-proper lists. BR, Ulf Ulf Wiger, CTO, Erlang Solutions, Ltd. http://erlang-solutions.com From moxford@REDACTED Thu Apr 14 01:43:19 2011 From: moxford@REDACTED (Mike Oxford) Date: Wed, 13 Apr 2011 16:43:19 -0700 Subject: [erlang-questions] Supervisor "spin rates" In-Reply-To: <20110413230530.GM4859@h216-235-12-174.host.egate.net> References: <20110413221944.GL4859@h216-235-12-174.host.egate.net> <20110413230530.GM4859@h216-235-12-174.host.egate.net> Message-ID: Somehow I misread that section to mean that 'ignore' would be treated as a non-success and would cause supervisor shutdown. Thank you! -mox On Wed, Apr 13, 2011 at 4:05 PM, Vance Shipley wrote: > On Wed, Apr 13, 2011 at 03:26:30PM -0700, Mike Oxford wrote: > } That will terminate the supervisor as well, which is then restarted.... > > The supervisor will ignore the child. supervisor:start_child/2 > will return {ok, undefined}. > > Start the supervisor: > > 2> {ok, Sup} = supervisor:start_link(ignore_sup, []). > {ok,<0.43.0>} > > It has no children: > > 3> supervisor:which_children(Sup). > [] > > Starting the child: > > 4> supervisor:start_child(Sup, []). > > =ERROR REPORT==== 13-Apr-2011::18:59:01 === > Ignoring: <0.46.0> > {ok,undefined} > > The child specification is installed: > > 5> supervisor:which_children(Sup). > [{undefined,undefined,worker,[ignore_server]}] > > But the child process reported above is not alive: > > 6> is_process_alive(list_to_pid("<0.46.0>")). > false > > > -- > -Vance > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ok@REDACTED Thu Apr 14 02:10:24 2011 From: ok@REDACTED (Richard O'Keefe) Date: Thu, 14 Apr 2011 12:10:24 +1200 Subject: [erlang-questions] Trouble with Erlang's lenient comparisons In-Reply-To: <8c056228-a280-41e9-a6b0-20dd10f4b71f@gu8g2000vbb.googlegroups.com> References: <8c056228-a280-41e9-a6b0-20dd10f4b71f@gu8g2000vbb.googlegroups.com> Message-ID: On 13/04/2011, at 9:08 PM, JohnyTex wrote: > I've inherited someone else's code base; sometimes I forget that a > function returns a tuple and I up comparing it with an integer or > similar, and get weird behaviour and hard-to-find bugs as a result. > > What's the best way to prevent this? There are two somewhat different questions lurking here. - what's the best way to ensure that such mistakes are caught? You've mentioned EUnit and Dialyzer, and they are excellent for this. - what's the best way to avoid making such mistakes in the first place? Clear, consistent, informative naming conventions. Consistent "algebraic" interface design. Well thought out policy on when to return "oops" as a result and when to raise an exception -- this is still contentious, the point here is that you want to *know* the choice a function made without having to think too much about it. Perhaps you could provide an example of a function that returns a tuple that you want to compare with an integer. From steven.charles.davis@REDACTED Thu Apr 14 02:38:04 2011 From: steven.charles.davis@REDACTED (Steve Davis) Date: Wed, 13 Apr 2011 17:38:04 -0700 (PDT) Subject: [erlang-questions] Beginner Question: Spring-like IOC in erlang In-Reply-To: <4DA5FD17.9040608@gmail.com> References: <1302661347349-3446106.post@n4.nabble.com> <1302679066266-3446453.post@n4.nabble.com> <827F5437-D9E7-4E55-8E5C-7BCB9240A2F8@hates.ms> <8EBC1BF4-25C8-4EA5-944E-46A7AB6813E5@erlang-solutions.com> <971BDCFA-6980-4768-B872-4B3335C3FF2A@hates.ms> <1302711965491-3447649.post@n4.nabble.com> <6531F569-DB33-4DA3-BB8D-BA2DFFE3767C@hates.ms> <1302717550649-3447862.post@n4.nabble.com> <4DA5ED3F.7080407@eonblast.com> <1302720657453-3447953.post@n4.nabble.com> <4DA5FD17.9040608@gmail.com> Message-ID: To put it as cleanly as I can state it, and IMHO, "dependency injection" is a solution to a problem that Erlang/OTP does not have. Best regards, /s On Apr 13, 2:44?pm, Todd Greenwood-Geer wrote: > 1. Is there an idiomatic way to use dependency injection in erlang? > > Most of my use of Spring DI has been to facilitate injection of test > classes into a stack for functional testing. Is this sort of thing done > in erlang? > > 2. How about AOP style join-points for before and after execution around > a method? > > As an example, wouldn't it be cool to dynamically enable debug or trace > level logging for an application when a certain error threshold is > reached? Then, when the system returns to a normal state, the error > logging could be turned back down... I think I might start doing this in > the Java stacks I'm currently working with (log4j). > > 3. Is there a way to intercept messages to a process? This is the real > question... Say a process dies unexpectedly and OTP restarts it... it > would be cool to be able to dynamically proxy messages to a process that > has exceeded some error threshold. The proxy could log them, or perform > more intensive error analysis... Then, once the system is back in a > normal state, the proxy could be removed from the message loop chain. > > -Todd > > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://erlang.org/mailman/listinfo/erlang-questions From ok@REDACTED Thu Apr 14 03:35:25 2011 From: ok@REDACTED (Richard O'Keefe) Date: Thu, 14 Apr 2011 13:35:25 +1200 Subject: [erlang-questions] Trouble with Erlang's lenient comparisons In-Reply-To: <631833685.97531302709938931.JavaMail.root@zimbra> References: <631833685.97531302709938931.JavaMail.root@zimbra> Message-ID: On 14/04/2011, at 3:52 AM, Robert Virding wrote: > The comparison operators as they are now were a mistake, almost a bad mistake. IMAO what we should have done was to have had two different sets of operators, one set of numeric comparisons (without type conversion) and one set of gerneral term comparisons (without type conversion). So for example: > > == /= =< < >= > would only work on numbers > @== @/= @=< @< @>= @> would work on all terms Just like Erlang's predecessor Prolog! Since the term/number distinction _was_ borrowed for equality and inequality (although with the symbols switched around, which still confuses me), I've often wondered why it wasn't borrowed for ordering. From James@REDACTED Thu Apr 14 04:39:01 2011 From: James@REDACTED (Mode7James) Date: Wed, 13 Apr 2011 19:39:01 -0700 (PDT) Subject: [erlang-questions] Beginner Question: Spring-like IOC in erlang In-Reply-To: References: <827F5437-D9E7-4E55-8E5C-7BCB9240A2F8@hates.ms> <8EBC1BF4-25C8-4EA5-944E-46A7AB6813E5@erlang-solutions.com> <971BDCFA-6980-4768-B872-4B3335C3FF2A@hates.ms> <1302711965491-3447649.post@n4.nabble.com> <6531F569-DB33-4DA3-BB8D-BA2DFFE3767C@hates.ms> <1302717550649-3447862.post@n4.nabble.com> <4DA5ED3F.7080407@eonblast.com> <1302720657453-3447953.post@n4.nabble.com> <4DA5FD17.9040608@gmail.com> Message-ID: <1302748741387-3448637.post@n4.nabble.com> I must be missing something. But it all sounds interesting I guess. Thanks guys for your input. Tonight I have a couple hours, I'll try to create a secure login for my first test, to get my feet wet. Just to make sure I understand the correct steps to take: 1) client (NOT Erlang) calls the IP address of my server 2) my server is listening for incoming TCP requests, and sends the client a reply with a login 3) server upgrades the TCP connection to SSL (is there a way to just start with SSL??) 4) client sends username & password over SSL 5) server authenticates 6) client is happy next step tomorrow (or tonight)-> 1) client selects the "game" 2) server sets up an open UDP port, sends client UDP packet for sync 3) client places red circle on stage based on coordinates received from server 4) pass movements back & forth 5) client closes connection. Is all this secure? Am I correct in my flow here? gen_nb_server was a module suggested that I use, so I'll be trying to set something up with that first this evening. I would think this is something that has been done a few times before, but I haven't found any solid examples of what I would think is a very simple and common process. Thanks again for all your help, I really have learned so much the last couple days! -James Steve Davis wrote: > > To put it as cleanly as I can state it, and IMHO, "dependency > injection" is a solution to a problem that Erlang/OTP does not have. > > Best regards, > > /s > > On Apr 13, 2:44?pm, Todd Greenwood-Geer <t.greenwoodg...@REDACTED> > wrote: >> 1. Is there an idiomatic way to use dependency injection in erlang? >> >> Most of my use of Spring DI has been to facilitate injection of test >> classes into a stack for functional testing. Is this sort of thing done >> in erlang? >> >> 2. How about AOP style join-points for before and after execution around >> a method? >> >> As an example, wouldn't it be cool to dynamically enable debug or trace >> level logging for an application when a certain error threshold is >> reached? Then, when the system returns to a normal state, the error >> logging could be turned back down... I think I might start doing this in >> the Java stacks I'm currently working with (log4j). >> >> 3. Is there a way to intercept messages to a process? This is the real >> question... Say a process dies unexpectedly and OTP restarts it... it >> would be cool to be able to dynamically proxy messages to a process that >> has exceeded some error threshold. The proxy could log them, or perform >> more intensive error analysis... Then, once the system is back in a >> normal state, the proxy could be removed from the message loop chain. >> >> -Todd >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questi...@REDACTED://erlang.org/mailman/listinfo/erlang-questions > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -- View this message in context: http://erlang.2086793.n4.nabble.com/Erlang-beginner-questions-tp3446106p3448637.html Sent from the Erlang Questions mailing list archive at Nabble.com. From mazen.harake@REDACTED Thu Apr 14 09:09:44 2011 From: mazen.harake@REDACTED (Mazen Harake) Date: Thu, 14 Apr 2011 09:09:44 +0200 Subject: [erlang-questions] Trouble with Erlang's lenient comparisons In-Reply-To: References: <8c056228-a280-41e9-a6b0-20dd10f4b71f@gu8g2000vbb.googlegroups.com> <4DA57CB6.7030100@cs.ntua.gr> Message-ID: Actually they end up being essentially the same thing. Check out Number 6 in this list: http://mazenharake.wordpress.com/2010/10/31/9-erlang-pitfalls-you-should-know-about/ I believe the #rec{} notation is preferred for clarity and I agree but in my opinion is_record/2 is just as correct (literally) /M On 13 April 2011 16:36, Gordon Guthrie wrote: > Kostis > > I have never read the documentation on is_record/2 before (didn't even > know there was is_record/3) > > I *assumed* that the is_record guard checked that it indeed was a > record - it would appear it doesn't. > > The documentation also explictly says to use is_record/2 > >> Note! >> This BIF is documented for completeness. In most cases is_record/2 should be used. > > If you shouldn't use it then the documentation should probably say so. > > I presume you are saying that using #rec{} in the function call is > correctly expanded by the preprocessor to {rec, _, _, } and is > therefore a better specification of the contract than is_record/2 > which just says 'it is a tuple with first element of this atom' > > Gordon > > > On 13 April 2011 11:36, Kostis Sagonas wrote: >> Gordon Guthrie wrote: >>> >>> ... >>> >>> Also check for bad input to functions by using guards like: >>> >>> fun(A, B, C) when is_list(A), is_integer(B), is_record(C, recC) -> >> >> The following is a bit pedantic, but please do not offer use of the >> is_record guard (esp. the one with arity two instead of three) as advice to >> newcomers. ?I suggest that you try to forget about this guard's existence; >> the only place where this guard is possibly needed is in or/orelse contexts. >> >> The above code is written better using pattern matching, as in: >> >> ?fun(A, B, #recC{} = C) when is_list(A), is_integer(B) -> >> >> Kostis >> > > > > -- > Gordon Guthrie > CEO hypernumbers > > http://hypernumbers.com > t: hypernumbers > +44 7776 251669 > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > From bgustavsson@REDACTED Thu Apr 14 09:27:23 2011 From: bgustavsson@REDACTED (=?UTF-8?Q?Bj=C3=B6rn_Gustavsson?=) Date: Thu, 14 Apr 2011 09:27:23 +0200 Subject: [erlang-questions] Trouble with Erlang's lenient comparisons In-Reply-To: References: <8c056228-a280-41e9-a6b0-20dd10f4b71f@gu8g2000vbb.googlegroups.com> <4DA57CB6.7030100@cs.ntua.gr> Message-ID: On Wed, Apr 13, 2011 at 4:36 PM, Gordon Guthrie wrote: > Kostis > > I have never read the documentation on is_record/2 before (didn't even > know there was is_record/3) > > I *assumed* that the is_record guard checked that it indeed was a > record - it would appear it doesn't. > > The documentation also explictly says to use is_record/2 > >> Note! >> This BIF is documented for completeness. In most cases is_record/2 should be used. > > If you shouldn't use it then the documentation should probably say so. > > I presume you are saying that using #rec{} in the function call is > correctly expanded by the preprocessor to {rec, _, _, } and is > therefore a better specification of the contract than is_record/2 > which just says 'it is a tuple with first element of this atom' Did you read the note in the documentation for is_record/2? As long as the RecordTag argument is a literal atom, the compiler will essentially rewrite it to a call to is_record/3, which will check the size too. Therefore, we still recommend that you use is_record/2, if you are going to use is_record() at all. Historically, only is_record/2 existed and it was not a BIF, but specially treated by the compiler. We added the BIF versions so that it would be possible to use apply on them, and for consistency with match specs. In most circumstances, the BIFs will not be called as the compiler tries to convert calls to is_record/{2,3} to pattern matching and inline most of the remaining calls. -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From gordon@REDACTED Thu Apr 14 11:20:29 2011 From: gordon@REDACTED (Gordon Guthrie) Date: Thu, 14 Apr 2011 10:20:29 +0100 Subject: [erlang-questions] Trouble with Erlang's lenient comparisons In-Reply-To: References: <8c056228-a280-41e9-a6b0-20dd10f4b71f@gu8g2000vbb.googlegroups.com> <4DA57CB6.7030100@cs.ntua.gr> Message-ID: Bj?rn > Did you read the note in the documentation for is_record/2? I did, but in my defence I was confused by Kostis and in a fluster :( I have re-read it now understand it properly. is_record/2 does what I always assumed it did (without reading the documentation) and I stand by my suggestion at the top of this thread. Gordon 2011/4/14 Bj?rn Gustavsson : > On Wed, Apr 13, 2011 at 4:36 PM, Gordon Guthrie wrote: >> Kostis >> >> I have never read the documentation on is_record/2 before (didn't even >> know there was is_record/3) >> >> I *assumed* that the is_record guard checked that it indeed was a >> record - it would appear it doesn't. >> >> The documentation also explictly says to use is_record/2 >> >>> Note! >>> This BIF is documented for completeness. In most cases is_record/2 should be used. >> >> If you shouldn't use it then the documentation should probably say so. >> >> I presume you are saying that using #rec{} in the function call is >> correctly expanded by the preprocessor to {rec, _, _, } and is >> therefore a better specification of the contract than is_record/2 >> which just says 'it is a tuple with first element of this atom' > > Did you read the note in the documentation for is_record/2? > As long as the RecordTag argument is a literal atom, the > compiler will essentially rewrite it to a call to is_record/3, > which will check the size too. > > Therefore, we still recommend that you use is_record/2, > if you are going to use is_record() at all. > > Historically, only is_record/2 existed and it was not a > BIF, but specially treated by the compiler. We added the > BIF versions so that it would be possible to use apply on > them, and for consistency with match specs. In most > circumstances, the BIFs will not be called as the compiler > tries to convert calls to is_record/{2,3} to pattern matching > and inline most of the remaining calls. > > -- > Bj?rn Gustavsson, Erlang/OTP, Ericsson AB > -- Gordon Guthrie CEO hypernumbers http://hypernumbers.com t: hypernumbers +44 7776 251669 From jodie.burch@REDACTED Thu Apr 14 12:42:45 2011 From: jodie.burch@REDACTED (Jodie Burch) Date: Thu, 14 Apr 2011 10:42:45 +0000 (GMT) Subject: [erlang-questions] London Erlang User Group Meeting - 20th April In-Reply-To: <1582987189.99551302777618438.JavaMail.root@zimbra> Message-ID: <381483679.99571302777765029.JavaMail.root@zimbra> Hi Everyone Just to let you know, the next London Erlang User Group meeting will be on the 20th April at 18:30 at the offices of Forward's in Camden, London. It will feature six 10 minute lightning talks. Let me know if you would like to give one. Register here . A map for the location is here . We look forward to seeing you there. Thanks Jodie -------------- next part -------------- An HTML attachment was scrubbed... URL: From dsc@REDACTED Thu Apr 14 12:48:59 2011 From: dsc@REDACTED (Dave Challis) Date: Thu, 14 Apr 2011 11:48:59 +0100 Subject: [erlang-questions] Pattern matching in function calls In-Reply-To: References: <4DA58CB2.9070508@ecs.soton.ac.uk> <4DA5A144.5070800@ecs.soton.ac.uk> <4DA6D11B.40504@ecs.soton.ac.uk> Message-ID: Hi Robby, Yup, I agree completely :) My question was mostly prompted by a blog post (http://ppolv.wordpress.com/2008/02/25/parsing-csv-in-erlang/) on parsing CSV in erlang. The do_parse function there has a dozen items which search binaries and check state, which made me wonder whether swapping the argument order round would make any difference at all. Cheers, Dave On 13/04/11 19:44, Robert Raschke wrote: > Hi Dave, > > probably not quite the answer you were looking for, but aim for > readability first (that's usually already hard enough :-). Only > compromise that if something is measurably too slow. > > In the example you give, it doesn't appear to make any big difference > for readability, but I assume your real code is a bit more > "interesting"? > > Robby > > > On 4/13/11, Dave Challis wrote: >> On 13/04/11 13:46, Antoine Koener wrote: >>> >>> On Apr 13, 2011, at 13:44 , Dave Challis wrote: >>> >>>> Does the order of patterns in a function call matter? Are they all >>>> tested, or will erlang stop trying to match them once a mismatch has >>>> been found? >>>> >>>> As an example, if I've got: >>>> >>>> foo(<>, a) -> a; >>>> foo(<>, b) -> b. >>>> >>>> will the above be any slower than defining: >>>> >>>> foo(a,<>) -> a; >>>> foo(b,<>) -> b. >>>> >>>> Will the<> attempt to be matched in every case? Is >>>> it something worth thinking about, or will the compiler optimise this? >>> >>> If the content of<> is irrelevant, you can use the '_' >>> notation: >>> >>> foo(a, _Bin) -> a; >>> foo(b, _Bin) -> b; >>> >>> Then this is explicit for the reader that you don't want to check _Bin. >> >> Sorry, my example wasn't great, I was more wondering about the cases >> when the binary data is relevant. >> >> So a better example might be: >> >> foo(<<$x,_Rest/binary>>, a) -> a1; >> foo(<<$y,_Rest/binary>>, a) -> a2; >> foo(<<$z,_Rest/binary>>, a) -> a3; >> foo(<<$x,_Rest/binary>>, b) -> b. >> >> If I then called: >> foo(<<"x">>, b). >> >> Would erlang perform 4 binary pattern matches until it got to the last >> clause? >> >> Or would it optimise things and only perform a single binary match by >> matching on the atoms first? >> >> Or will it always test all arguments in all cases? >> >> >> -- >> Dave Challis >> dsc@REDACTED >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> -- Dave Challis dsc@REDACTED From robert.virding@REDACTED Thu Apr 14 16:23:02 2011 From: robert.virding@REDACTED (Robert Virding) Date: Thu, 14 Apr 2011 14:23:02 +0000 (GMT) Subject: [erlang-questions] Trouble with Erlang's lenient comparisons In-Reply-To: Message-ID: <1054113527.101041302790982393.JavaMail.root@zimbra> ----- "Richard O'Keefe" wrote: > On 14/04/2011, at 3:52 AM, Robert Virding wrote: > > > The comparison operators as they are now were a mistake, almost a > bad mistake. IMAO what we should have done was to have had two > different sets of operators, one set of numeric comparisons (without > type conversion) and one set of gerneral term comparisons (without > type conversion). So for example: > > > > == /= =< < >= > would only work on numbers > > @== @/= @=< @< @>= @> would work on all terms > > Just like Erlang's predecessor Prolog! > Since the term/number distinction _was_ borrowed for equality and > inequality (although with the symbols switched around, which still > confuses me), I've often wondered why it wasn't borrowed for ordering. Yes, my suggestion is taken directly from the Prolog operator names. I don't have a problem with that. :-) Originally there was no problem as we did not have floating point numbers. It was only when they were added and we decided to do implicit type conversions that the problem arose. We needed an exact equality check for pattern matching so =:= was added (yes it was a bad name choice) and =/= just tagged along and slipped in. I suppose I will have to make an eep which suggests the complete range of term comparison operators without type conversions. The problem is whether it is worth effort to add pure numeric comparisons as well. Robert From jesper.louis.andersen@REDACTED Thu Apr 14 16:36:38 2011 From: jesper.louis.andersen@REDACTED (Jesper Louis Andersen) Date: Thu, 14 Apr 2011 16:36:38 +0200 Subject: [erlang-questions] Beginner Question: Spring-like IOC in erlang In-Reply-To: <4DA5FD17.9040608@gmail.com> References: <1302661347349-3446106.post@n4.nabble.com> <1302679066266-3446453.post@n4.nabble.com> <827F5437-D9E7-4E55-8E5C-7BCB9240A2F8@hates.ms> <8EBC1BF4-25C8-4EA5-944E-46A7AB6813E5@erlang-solutions.com> <971BDCFA-6980-4768-B872-4B3335C3FF2A@hates.ms> <1302711965491-3447649.post@n4.nabble.com> <6531F569-DB33-4DA3-BB8D-BA2DFFE3767C@hates.ms> <1302717550649-3447862.post@n4.nabble.com> <4DA5ED3F.7080407@eonblast.com> <1302720657453-3447953.post@n4.nabble.com> <4DA5FD17.9040608@gmail.com> Message-ID: On Wed, Apr 13, 2011 at 21:44, Todd Greenwood-Geer wrote: > 1. Is there an idiomatic way to use dependency injection in erlang? > > Most of my use of Spring DI has been to facilitate injection of test classes > into a stack for functional testing. Is this sort of thing done in erlang? Not very much, but it is possible. A module is just a term like anything else, so you can do it either dynamically or by static configuration in the test. Parameterized modules used as ML-style functors can also provide you with the equivalent of dependency injection. > 2. How about AOP style join-points for before and after execution around a > method? There are much better tracing facilities in Erlang. Dynamic debugging and tracing are built-in and you can also get something like "redbug" from the eper suite which is particularly powerful. The ability to carry out tracing on any production system is pretty cool. > 3. Is there a way to intercept messages to a process? This is the real > question... Say a process dies unexpectedly and OTP restarts it... it would > be cool to be able to dynamically proxy messages to a process that has > exceeded some error threshold. The proxy could log them, or perform more > intensive error analysis... Then, once the system is back in a normal state, > the proxy could be removed from the message loop chain. The problem is that as soon as your code crashes or dies, you can't really trust the messages that are residing in the queue at all. There are tools which will give you a dynamic view of what is going on inside the queue if you want, but it is usually more used in in the debugging phase. In general, the error-logging in Erlang will tell you the message *and* the state that crashed the process. The reason we can tell you the state is because data in Erlang is persistent. We just keep a reference to the original state before we begin processing and then we can report back to you if the process fails. It makes a lot of tracking down why a given error happen much easier. -- J. From pmorreale@REDACTED Thu Apr 14 16:55:28 2011 From: pmorreale@REDACTED (Peter W. Morreale) Date: Thu, 14 Apr 2011 08:55:28 -0600 Subject: [erlang-questions] Crypto and public_key usage.... Message-ID: <1302792928.20935.234.camel@hermosa.morreale.net> Hi all, I'm attempting to use the crypto and public key modules to decrypt an encrypted response I get in a server. I found this http://erlang.2086793.n4.nabble.com/rsa-encryption-decryption-example-code-doesn-t-work-td2114965.html example on the web, however in my case, I already have the public key as a string. How do I manipulate the key string to decrypt the msg? I'm quite confused since the above (and some other) examples I have found refer to exports (pem_to_der() and decode_private_key()) that are not documented in the public key online manual. Thanks, -PWM From seth@REDACTED Thu Apr 14 17:49:14 2011 From: seth@REDACTED (Seth Falcon) Date: Thu, 14 Apr 2011 08:49:14 -0700 Subject: [erlang-questions] Crypto and public_key usage.... In-Reply-To: <1302792928.20935.234.camel@hermosa.morreale.net> References: <1302792928.20935.234.camel@hermosa.morreale.net> Message-ID: Hi Peter, On Thu, Apr 14, 2011 at 7:55 AM, Peter W. Morreale wrote: > I'm attempting to use the crypto and public key modules to decrypt > an encrypted response I get in a server. > > I found this > http://erlang.2086793.n4.nabble.com/rsa-encryption-decryption-example-code-doesn-t-work-td2114965.html > > example on the web, however in my case, I already have the public key as > a string. If your string represents an RSA public key in SubjectPublicKeyInfo PEM format and you are using the latest Erlang release, I think you can obtain the key record that you can use in the encrypt/decrpyt functions in the public_key module as follows: {ok, RSAPubPem} = file:read_file("rsa_pub.pem"), PemEntries = public_key:pem_decode(RSAPubPem), RSAPubKey = public_key:pem_entry_decode(hd(PemEntries)), % now use RSAPubKey to decrypt/encrypt You will have a few more hoops to jump through for older versions of Erlang. Here's one way: read_rsa_public_key(Key) -> Bin = erlang:iolist_to_binary(public_key_lines(re:split(Key, "\n"), [])), Spki = public_key:der_decode('SubjectPublicKeyInfo', base64:mime_decode(Bin)), {_, _, {0, KeyDer}} = Spki, public_key:der_decode('RSAPublicKey', KeyDer). public_key_lines([<<"-----BEGIN PUBLIC KEY-----">>|Rest], Acc) -> public_key_lines(Rest, Acc); public_key_lines([<<"-----END PUBLIC KEY-----">>|_Rest], Acc) -> lists:reverse(Acc); public_key_lines([Line|Rest], Acc) -> public_key_lines(Rest, [Line|Acc]). If this isn't what you are looking for, it would be helpful to provide more detail on the type of key you have and what you want to do with it. + seth -- Seth Falcon | @sfalcon | http://userprimary.net/ From dmercer@REDACTED Thu Apr 14 17:52:20 2011 From: dmercer@REDACTED (David Mercer) Date: Thu, 14 Apr 2011 10:52:20 -0500 Subject: [erlang-questions] Trouble with Erlang's lenient comparisons In-Reply-To: <1054113527.101041302790982393.JavaMail.root@zimbra> References: <1054113527.101041302790982393.JavaMail.root@zimbra> Message-ID: <000f01cbfabb$f15cf2e0$d416d8a0$@com> On Thursday, April 14, 2011, Robert Virding wrote: > I suppose I will have to make an eep which suggests the complete range > of term comparison operators without type conversions. The problem is > whether it is worth effort to add pure numeric comparisons as well. Not meaning to be an ass, but is it really worth it? Is it *that* big a problem? Thinking about both in terms of your time and effort and the time and effort of everyone else who has to change their code to use the new operators, and also in the added complexity to the language and the confusion caused by adding the new @ operators. DBM From pmorreale@REDACTED Thu Apr 14 19:11:42 2011 From: pmorreale@REDACTED (Peter W. Morreale) Date: Thu, 14 Apr 2011 11:11:42 -0600 Subject: [erlang-questions] Crypto and public_key usage.... In-Reply-To: References: <1302792928.20935.234.camel@hermosa.morreale.net> Message-ID: <1302801102.20935.241.camel@hermosa.morreale.net> On Thu, 2011-04-14 at 08:49 -0700, Seth Falcon wrote: > Hi Peter, > > On Thu, Apr 14, 2011 at 7:55 AM, Peter W. Morreale wrote: > > I'm attempting to use the crypto and public key modules to decrypt > > an encrypted response I get in a server. > > > > I found this > > http://erlang.2086793.n4.nabble.com/rsa-encryption-decryption-example-code-doesn-t-work-td2114965.html > > > > example on the web, however in my case, I already have the public key as > > a string. > > If your string represents an RSA public key in SubjectPublicKeyInfo > PEM format and you are using the latest Erlang release, I think you > can obtain the key record that you can use in the encrypt/decrpyt > functions in the public_key module as follows: > > {ok, RSAPubPem} = file:read_file("rsa_pub.pem"), > PemEntries = public_key:pem_decode(RSAPubPem), > RSAPubKey = public_key:pem_entry_decode(hd(PemEntries)), > % now use RSAPubKey to decrypt/encrypt > I *think* this is what I need. I'm new to dealing with encryption from a programmatic sense. Almost as new as I am to Erlang. :-) I will try and see how far I can get. This is for decrypting a SAML response obtained from a SAML IdP. I have the key from the IdP metadata. Thank you for this insight. Best, -PWM > You will have a few more hoops to jump through for older versions of > Erlang. Here's one way: > > read_rsa_public_key(Key) -> > Bin = erlang:iolist_to_binary(public_key_lines(re:split(Key, > "\n"), [])), > Spki = public_key:der_decode('SubjectPublicKeyInfo', > base64:mime_decode(Bin)), > {_, _, {0, KeyDer}} = Spki, > public_key:der_decode('RSAPublicKey', KeyDer). > > public_key_lines([<<"-----BEGIN PUBLIC KEY-----">>|Rest], Acc) -> > public_key_lines(Rest, Acc); > public_key_lines([<<"-----END PUBLIC KEY-----">>|_Rest], Acc) -> > lists:reverse(Acc); > public_key_lines([Line|Rest], Acc) -> > public_key_lines(Rest, [Line|Acc]). > > If this isn't what you are looking for, it would be helpful to provide > more detail on the type of key you have and what you want to do with > it. > > + seth > > > From James@REDACTED Thu Apr 14 21:40:49 2011 From: James@REDACTED (Mode7James) Date: Thu, 14 Apr 2011 12:40:49 -0700 (PDT) Subject: [erlang-questions] Beginner Question: Spring-like IOC in erlang In-Reply-To: References: <827F5437-D9E7-4E55-8E5C-7BCB9240A2F8@hates.ms> <8EBC1BF4-25C8-4EA5-944E-46A7AB6813E5@erlang-solutions.com> <971BDCFA-6980-4768-B872-4B3335C3FF2A@hates.ms> <1302711965491-3447649.post@n4.nabble.com> <6531F569-DB33-4DA3-BB8D-BA2DFFE3767C@hates.ms> <1302717550649-3447862.post@n4.nabble.com> <4DA5ED3F.7080407@eonblast.com> <1302720657453-3447953.post@n4.nabble.com> <4DA5FD17.9040608@gmail.com> Message-ID: <1302810049346-3450532.post@n4.nabble.com> I think my thread was hijacked... -- View this message in context: http://erlang.2086793.n4.nabble.com/Erlang-beginner-questions-tp3446106p3450532.html Sent from the Erlang Questions mailing list archive at Nabble.com. From ingela.andin@REDACTED Fri Apr 15 09:35:22 2011 From: ingela.andin@REDACTED (Ingela Andin) Date: Fri, 15 Apr 2011 09:35:22 +0200 Subject: [erlang-questions] Crypto and public_key usage.... In-Reply-To: <1302792928.20935.234.camel@hermosa.morreale.net> References: <1302792928.20935.234.camel@hermosa.morreale.net> Message-ID: Hi! The functions pem_to_der and decode_private_key have been deprecated, they where part of our original API design for the public_key-application but we then decided that approach would not work out to make a small general and flexible API so we changed it. Peter did a good job of explaining how to use the new API, it is fairly straight forward if you know a little about the public_key infrastructure. We will strive to make some examples for the user guide. Regards Ingela - Erlang/OTP team - Ericsson AB 2011/4/14 Peter W. Morreale : > Hi all, > > I'm attempting to use the crypto and public key modules to decrypt an > encrypted response I get in a server. > > I found this > http://erlang.2086793.n4.nabble.com/rsa-encryption-decryption-example-code-doesn-t-work-td2114965.html > > example on the web, however in my case, I already have the public key as > a string. > > How do I manipulate the key string to decrypt the msg? > > I'm quite confused since the above (and some other) examples I have > found refer to exports (pem_to_der() and decode_private_key()) that are > not documented in the public key online manual. > > Thanks, > -PWM > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > From ingela@REDACTED Fri Apr 15 09:42:56 2011 From: ingela@REDACTED (Ingela Andin) Date: Fri, 15 Apr 2011 09:42:56 +0200 Subject: [erlang-questions] Crypto and public_key usage.... In-Reply-To: References: <1302792928.20935.234.camel@hermosa.morreale.net> Message-ID: Oh, sorry mixed up names here, it should have been Seth that did the good job explaining ;) Regards Ingela 2011/4/15 Ingela Andin : > Hi! > > The functions pem_to_der and decode_private_key have been deprecated, > they where part of our original API design for the > public_key-application but we then decided that approach would not > work out to make a small general and flexible API so we changed it. > Peter did a good job of explaining how to use the new API, it is > fairly straight forward if you know a little about the public_key > infrastructure. We will strive to make some examples for the user > guide. > > Regards Ingela - Erlang/OTP team - Ericsson AB > > > 2011/4/14 Peter W. Morreale : >> Hi all, >> >> I'm attempting to use the crypto and public key modules to decrypt an >> encrypted response I get in a server. >> >> I found this >> http://erlang.2086793.n4.nabble.com/rsa-encryption-decryption-example-code-doesn-t-work-td2114965.html >> >> example on the web, however in my case, I already have the public key as >> a string. >> >> How do I manipulate the key string to decrypt the msg? >> >> I'm quite confused since the above (and some other) examples I have >> found refer to exports (pem_to_der() and decode_private_key()) that are >> not documented in the public key online manual. >> >> Thanks, >> -PWM >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> > From dsc@REDACTED Fri Apr 15 12:06:01 2011 From: dsc@REDACTED (Dave Challis) Date: Fri, 15 Apr 2011 11:06:01 +0100 Subject: [erlang-questions] Quick question about resetting shells References: <4DA81889.4020605@ecs.soton.ac.uk> Message-ID: I'm fairly new to erlang, so when I'm working on something, my development cycle usually goes something like: 1. Write/change code 2. Compile using rebar / erlc 3. Start a shell using erl -pa ebin 4. Paste in commands to test changes 5. Quit shell, go to 1 Steps 3-5 usually take the longest, so I'm wondering, is there any way to stay in a shell, but to reset it to the default state? I.e. the equivalent of calling l(module_name) to load the latest version of the compiled module, calling f() to clear all variables, and also destroying any ETS tables that might have been created. Or is there some better way to test code changes from the shell after .beam files have been recompiled while it's running? Any tips appreciated! Thanks, -- Dave Challis dsc@REDACTED From vladdu55@REDACTED Fri Apr 15 12:18:32 2011 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Fri, 15 Apr 2011 12:18:32 +0200 Subject: [erlang-questions] Quick question about resetting shells In-Reply-To: References: <4DA81889.4020605@ecs.soton.ac.uk> Message-ID: Hi! On Fri, Apr 15, 2011 at 12:06, Dave Challis wrote: > I'm fairly new to erlang, so when I'm working on something, my development > cycle usually goes something like: > > 1. Write/change code > 2. Compile using rebar / erlc > 3. Start a shell using erl -pa ebin > 4. Paste in commands to test changes > 5. Quit shell, go to 1 > > Steps 3-5 usually take the longest, so I'm wondering, is there any way to > stay in a shell, but to reset it to the default state? I.e. the equivalent > of calling l(module_name) to load the latest version of the compiled module, > calling f() to clear all variables, and also destroying any ETS tables that > might have been created. > > Or is there some better way to test code changes from the shell after .beam > files have been recompiled while it's running? > > I would strongly recommend to start using a test server - eunit or common_test are included in OTP. It really does wonders with the length of the development cycle :-) Plus it's much more reproducible and all the other advantages of having automated tests. regards, Vlad -------------- next part -------------- An HTML attachment was scrubbed... URL: From overminddl1@REDACTED Fri Apr 15 12:49:15 2011 From: overminddl1@REDACTED (OvermindDL1) Date: Fri, 15 Apr 2011 04:49:15 -0600 Subject: [erlang-questions] Quick question about resetting shells In-Reply-To: References: <4DA81889.4020605@ecs.soton.ac.uk> Message-ID: Please excuse top posting, on phone. What are the differences and pros/cons between eunit and common_test, and any good tutorials for setting up such a server as you describe? I usually just use distel or ErlIDE. Oh how I would love KDevelop integration to lessen swapping with my cpp work... On Apr 15, 2011 4:19 AM, "Vlad Dumitrescu" wrote: > Hi! > > On Fri, Apr 15, 2011 at 12:06, Dave Challis wrote: > >> I'm fairly new to erlang, so when I'm working on something, my development >> cycle usually goes something like: >> >> 1. Write/change code >> 2. Compile using rebar / erlc >> 3. Start a shell using erl -pa ebin >> 4. Paste in commands to test changes >> 5. Quit shell, go to 1 >> >> Steps 3-5 usually take the longest, so I'm wondering, is there any way to >> stay in a shell, but to reset it to the default state? I.e. the equivalent >> of calling l(module_name) to load the latest version of the compiled module, >> calling f() to clear all variables, and also destroying any ETS tables that >> might have been created. >> >> Or is there some better way to test code changes from the shell after .beam >> files have been recompiled while it's running? >> >> > I would strongly recommend to start using a test server - eunit or > common_test are included in OTP. It really does wonders with the length of > the development cycle :-) Plus it's much more reproducible and all the other > advantages of having automated tests. > > regards, > Vlad -------------- next part -------------- An HTML attachment was scrubbed... URL: From kostis@REDACTED Fri Apr 15 15:00:15 2011 From: kostis@REDACTED (Kostis Sagonas) Date: Fri, 15 Apr 2011 16:00:15 +0300 Subject: [erlang-questions] iolist type not found by PropEr In-Reply-To: <4DA5E7C8.1030900@2600hz.com> References: <4DA5E7C8.1030900@2600hz.com> Message-ID: <4DA8415F.2020703@cs.ntua.gr> James Aimonetti wrote: > I'm starting to add PropEr testing into my source code and ran into a > small issue. When testing with the iolist() type, proper:quickcheck/1 > complains: > > 1> proper:quickcheck(iolist_t:prop_iolist_t()). > > Error: The typeserver encountered an error: > {missing_type,iolist_t,{type,iolist,0}}. PropEr support for iolist() and iodata() has been added on github. Kostis From spawn.think@REDACTED Fri Apr 15 15:56:22 2011 From: spawn.think@REDACTED (Ahmed Omar) Date: Fri, 15 Apr 2011 15:56:22 +0200 Subject: [erlang-questions] Erlang libraries wish list? Message-ID: What's on top of your Erlang libraries wish list? (i'm talking more about libraries than core of the language) http://t.co/LQWCxFK -- Best Regards, - Ahmed Omar http://nl.linkedin.com/in/adiaa Follow me on twitter @spawn_think -------------- next part -------------- An HTML attachment was scrubbed... URL: From pmorreale@REDACTED Fri Apr 15 16:17:12 2011 From: pmorreale@REDACTED (Peter W. Morreale) Date: Fri, 15 Apr 2011 08:17:12 -0600 Subject: [erlang-questions] Crypto and public_key usage.... In-Reply-To: References: <1302792928.20935.234.camel@hermosa.morreale.net> Message-ID: <1302877032.23309.12.camel@hermosa.morreale.net> On Fri, 2011-04-15 at 09:35 +0200, Ingela Andin wrote: > Hi! > > The functions pem_to_der and decode_private_key have been deprecated, > they where part of our original API design for the > public_key-application but we then decided that approach would not > work out to make a small general and flexible API so we changed it. > Peter did a good job of explaining how to use the new API, it is > fairly straight forward if you know a little about the public_key > infrastructure. We will strive to make some examples for the user > guide. > > Regards Ingela - Erlang/OTP team - Ericsson AB > Hi Ingela, Adding examples for the user guide(s) would be most welcome. As an experienced programmer very new to Erlang, seeing example code is crucial to the learning process. This is especially true when programming objectives span multiple Erlang modules of code. It can be near impossible to decipher reference-only documentation for dependencies between parts of any system. This work would be most welcome indeed. Best Regards, -PWM > > 2011/4/14 Peter W. Morreale : > > Hi all, > > > > I'm attempting to use the crypto and public key modules to decrypt an > > encrypted response I get in a server. > > > > I found this > > http://erlang.2086793.n4.nabble.com/rsa-encryption-decryption-example-code-doesn-t-work-td2114965.html > > > > example on the web, however in my case, I already have the public key as > > a string. > > > > How do I manipulate the key string to decrypt the msg? > > > > I'm quite confused since the above (and some other) examples I have > > found refer to exports (pem_to_der() and decode_private_key()) that are > > not documented in the public key online manual. > > > > Thanks, > > -PWM > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > From dfkettle@REDACTED Fri Apr 15 16:36:51 2011 From: dfkettle@REDACTED (David) Date: Fri, 15 Apr 2011 10:36:51 -0400 Subject: [erlang-questions] wxErlang documentation Message-ID: Hi! Don't know if this is the most appropriate list, but the link to the PDF file for wxErlang appears to be broken. I'm getting this error message: Object Not Found The requested URL %2Fdoc%2Fapps%2FwxErlang%2FwxErlang.pdf was not found on this server. Does anyone know if the document is really missing, or if it's just a typo in the hot link? The URL displayed when you hover the mouse is: http://www.erlang.org/doc/apps/wxErlang/wxErlang.pdf Thanks. From lukas@REDACTED Fri Apr 15 16:49:23 2011 From: lukas@REDACTED (Lukas Larsson) Date: Fri, 15 Apr 2011 16:49:23 +0200 Subject: [erlang-questions] wxErlang documentation In-Reply-To: References: Message-ID: <1302878963.23083.1.camel@bilbo> It's here: http://www.erlang.org/doc/apps/wx/wxErlang.pdf Strange that the extra Erlang is added onto the path... probably something wrong with the documentation build. Lukas On Fri, 2011-04-15 at 10:36 -0400, David wrote: > Hi! > > Don't know if this is the most appropriate list, but the link to the > PDF file for wxErlang appears to be broken. I'm getting this error > message: > > Object Not Found > The requested URL %2Fdoc%2Fapps%2FwxErlang%2FwxErlang.pdf was not > found on this server. > > Does anyone know if the document is really missing, or if it's just a > typo in the hot link? The URL displayed when you hover the mouse is: > > http://www.erlang.org/doc/apps/wxErlang/wxErlang.pdf > > Thanks. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From rtrlists@REDACTED Fri Apr 15 19:25:38 2011 From: rtrlists@REDACTED (Robert Raschke) Date: Fri, 15 Apr 2011 18:25:38 +0100 Subject: [erlang-questions] Pattern matching in function calls In-Reply-To: References: <4DA58CB2.9070508@ecs.soton.ac.uk> <4DA5A144.5070800@ecs.soton.ac.uk> <4DA6D11B.40504@ecs.soton.ac.uk> Message-ID: That code makes me wonder if it could be rewritten using gen_fsm. Never used gen_fsm myself, so I'm not really sure. Robby On Thu, Apr 14, 2011 at 11:48 AM, Dave Challis wrote: > Hi Robby, > Yup, I agree completely :) > > My question was mostly prompted by a blog post ( > http://ppolv.wordpress.com/2008/02/25/parsing-csv-in-erlang/) on parsing > CSV in erlang. > > The do_parse function there has a dozen items which search binaries and > check state, which made me wonder whether swapping the argument order round > would make any difference at all. > > Cheers, > Dave > > > On 13/04/11 19:44, Robert Raschke wrote: > >> Hi Dave, >> >> probably not quite the answer you were looking for, but aim for >> readability first (that's usually already hard enough :-). Only >> compromise that if something is measurably too slow. >> >> In the example you give, it doesn't appear to make any big difference >> for readability, but I assume your real code is a bit more >> "interesting"? >> >> Robby >> >> >> On 4/13/11, Dave Challis wrote: >> >>> On 13/04/11 13:46, Antoine Koener wrote: >>> >>>> >>>> On Apr 13, 2011, at 13:44 , Dave Challis wrote: >>>> >>>> Does the order of patterns in a function call matter? Are they all >>>>> tested, or will erlang stop trying to match them once a mismatch has >>>>> been found? >>>>> >>>>> As an example, if I've got: >>>>> >>>>> foo(<>, a) -> a; >>>>> foo(<>, b) -> b. >>>>> >>>>> will the above be any slower than defining: >>>>> >>>>> foo(a,<>) -> a; >>>>> foo(b,<>) -> b. >>>>> >>>>> Will the<> attempt to be matched in every case? Is >>>>> it something worth thinking about, or will the compiler optimise this? >>>>> >>>> >>>> If the content of<> is irrelevant, you can use the '_' >>>> notation: >>>> >>>> foo(a, _Bin) -> a; >>>> foo(b, _Bin) -> b; >>>> >>>> Then this is explicit for the reader that you don't want to check _Bin. >>>> >>> >>> Sorry, my example wasn't great, I was more wondering about the cases >>> when the binary data is relevant. >>> >>> So a better example might be: >>> >>> foo(<<$x,_Rest/binary>>, a) -> a1; >>> foo(<<$y,_Rest/binary>>, a) -> a2; >>> foo(<<$z,_Rest/binary>>, a) -> a3; >>> foo(<<$x,_Rest/binary>>, b) -> b. >>> >>> If I then called: >>> foo(<<"x">>, b). >>> >>> Would erlang perform 4 binary pattern matches until it got to the last >>> clause? >>> >>> Or would it optimise things and only perform a single binary match by >>> matching on the atoms first? >>> >>> Or will it always test all arguments in all cases? >>> >>> >>> -- >>> Dave Challis >>> dsc@REDACTED >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://erlang.org/mailman/listinfo/erlang-questions >>> >>> > > -- > Dave Challis > dsc@REDACTED > -------------- next part -------------- An HTML attachment was scrubbed... URL: From gregory.haskins@REDACTED Fri Apr 15 20:24:48 2011 From: gregory.haskins@REDACTED (Gregory Haskins) Date: Fri, 15 Apr 2011 14:24:48 -0400 Subject: [erlang-questions] Confusing about gproc with global properties Message-ID: <4DA88D70.1050501@gmail.com> Hi Ulf, all, I am playing around with adding gproc to my edist framework. I plan on using it for both a pubsub fabric as well as for end-point management. I ran into a snag during the integration that I _swear_ worked when I did some small proof-of-concept work with gproc as stand alone. That is, it seems any global properties that are registered never end up showing up. Consider this: (controller@REDACTED)2> gproc:reg({p, l, foo}, bar). true (controller@REDACTED)3> gproc:reg({p, g, foo}, bar). true (controller@REDACTED)4> (controller@REDACTED)4> (controller@REDACTED)4> gproc:select([{'_', [], ['$$']}]). [[{p,l,foo},<0.131.0>,bar]] I do not understand why it appears that all global registrations meet a /dev/null fate. Any pointers are greatly appreciated. Note that if I trace gproc_dist, I can see activity during the {p, g, _} registration, as you would expect. I started erl with "-gproc gproc_dist 'all'". I am using the v0.1.2 branch of esl/gproc (https://github.com/esl/gproc/tree/v0.1.2), which, IIUC, is the tree Ulf recommends we use (though now I cannot seem to remember where I got that impression). Kind Regards, -Greg -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 267 bytes Desc: OpenPGP digital signature URL: From moxford@REDACTED Fri Apr 15 21:37:43 2011 From: moxford@REDACTED (Mike Oxford) Date: Fri, 15 Apr 2011 12:37:43 -0700 Subject: [erlang-questions] Behavio(u)r guard? Message-ID: I do not see any way to specify a behavior as a guard. For a callback module, I cannot then say "if it's this kind of handler, ship it over this way." This is not critical or anything, but from a pure curiosity standpoint is there an underlying reason, like there is for not having is_string()? Is the behavior/interface too soft to check as a guard? Thanks!! -mox -------------- next part -------------- An HTML attachment was scrubbed... URL: From moxford@REDACTED Fri Apr 15 21:37:43 2011 From: moxford@REDACTED (Mike Oxford) Date: Fri, 15 Apr 2011 12:37:43 -0700 Subject: [erlang-questions] Behavio(u)r guard? Message-ID: I do not see any way to specify a behavior as a guard. For a callback module, I cannot then say "if it's this kind of handler, ship it over this way." This is not critical or anything, but from a pure curiosity standpoint is there an underlying reason, like there is for not having is_string()? Is the behavior/interface too soft to check as a guard? Thanks!! -mox -------------- next part -------------- An HTML attachment was scrubbed... URL: From andrew@REDACTED Fri Apr 15 22:02:56 2011 From: andrew@REDACTED (Andrew Thompson) Date: Fri, 15 Apr 2011 16:02:56 -0400 Subject: [erlang-questions] Behavio(u)r guard? In-Reply-To: References: Message-ID: <20110415200255.GD4695@hijacked.us> On Fri, Apr 15, 2011 at 12:37:43PM -0700, Mike Oxford wrote: > I do not see any way to specify a behavior as a guard. > For a callback module, I cannot then say "if it's this kind of handler, ship > it over this way." > > This is not critical or anything, but from a pure curiosity standpoint is > there an underlying reason, like there > is for not having is_string()? Is the behavior/interface too soft to check > as a guard? > This is because behaviours are compile-time, not run-time. The compiler just asks the behaviour that the module claims it implements what functions must be exported and checks that against the export list (and warns on any missing ones). At runtime you can erlang:function_exported(M, F, A) to check if a function is exported from a particular module. This is useful for optional callbacks that a behaviour *may* implement (eg. gen_server:format_status). Andrew From dgud@REDACTED Fri Apr 15 22:29:59 2011 From: dgud@REDACTED (Dan Gudmundsson) Date: Fri, 15 Apr 2011 22:29:59 +0200 Subject: [erlang-questions] wxErlang documentation In-Reply-To: <1302878963.23083.1.camel@bilbo> References: <1302878963.23083.1.camel@bilbo> Message-ID: Originally we scrapped the idea of a wx pdf doc, since it is pretty useless as it only contains links to the wxWidgets website. So it is not supposed to there at all... /Dan On Fri, Apr 15, 2011 at 4:49 PM, Lukas Larsson wrote: > It's here: http://www.erlang.org/doc/apps/wx/wxErlang.pdf > > Strange that the extra Erlang is added onto the path... probably > something wrong with the documentation build. > > Lukas > > On Fri, 2011-04-15 at 10:36 -0400, David wrote: >> Hi! >> >> Don't know if this is the most appropriate list, but the link to the >> PDF file for wxErlang appears to be broken. I'm getting this error >> message: >> >> Object Not Found >> The requested URL %2Fdoc%2Fapps%2FwxErlang%2FwxErlang.pdf was not >> found on this server. >> >> Does anyone know if the document is really missing, or if it's just a >> typo in the hot link? The URL displayed when you hover the mouse is: >> >> http://www.erlang.org/doc/apps/wxErlang/wxErlang.pdf >> >> Thanks. >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > From freza@REDACTED Fri Apr 15 22:44:18 2011 From: freza@REDACTED (Jachym Holecek) Date: Fri, 15 Apr 2011 21:44:18 +0100 Subject: [erlang-questions] Pattern matching in function calls In-Reply-To: References: <4DA58CB2.9070508@ecs.soton.ac.uk> <4DA5A144.5070800@ecs.soton.ac.uk> <4DA6D11B.40504@ecs.soton.ac.uk> Message-ID: <20110415204418.GA1057@hanele.lan> Hi, [I didn't read the rest of the thread, so hopefully I'm not terribly offtopic. Also, I got rid of top-posting and unlimited context quoting as both are seen as bad taste where I come from.] # Robert Raschke 2011-04-15: >> On Thu, Apr 14, 2011 at 11:48 AM, Dave Challis wrote: >> Yup, I agree completely :) >> >> My question was mostly prompted by a blog post (http://ppolv.wordpress.com/2008/02/25/ >> parsing-csv-in-erlang/) on parsing CSV in erlang. >> >> The do_parse function there has a dozen items which search binaries and check state, which made >> me wonder whether swapping the argument order round would make any difference at all. >> >> That code makes me wonder if it could be rewritten using gen_fsm. Never used gen_fsm myself, so I'm >> not really sure. I don't think so; gen_fsm is brilliant for purely event-driven automata but would be very ugly for a task like this. What the CSV guy needs to do is: 1) Get rid of #ecsv{} record, that's overkill for such a trivial purpose. 2) Break the parser into a bunch of tiny functions, pass all necessary data in arguments. IIRC LFE's scanner/parser code is a neat example of how to get it right. Regards, -- Jachym From gleber.p@REDACTED Fri Apr 15 22:55:25 2011 From: gleber.p@REDACTED (Gleb Peregud) Date: Fri, 15 Apr 2011 22:55:25 +0200 Subject: [erlang-questions] Pattern matching in function calls In-Reply-To: <20110415204418.GA1057@hanele.lan> References: <4DA58CB2.9070508@ecs.soton.ac.uk> <4DA5A144.5070800@ecs.soton.ac.uk> <4DA6D11B.40504@ecs.soton.ac.uk> <20110415204418.GA1057@hanele.lan> Message-ID: On Fri, Apr 15, 2011 at 22:44, Jachym Holecek wrote: > I don't think so; gen_fsm is brilliant for purely event-driven automata but > would be very ugly for a task like this. What the CSV guy needs to do is: > > ?1) Get rid of #ecsv{} record, that's overkill for such a trivial purpose. > > ?2) Break the parser into a bunch of tiny functions, pass all necessary > ? ? data in arguments. Here's a csv parser which I got somewhere from the internet and modified a bit (it does some dumb heuristic to handle badly formatted csv files), which is implemented exactly this way -------------- next part -------------- A non-text attachment was scrubbed... Name: csv.erl Type: text/x-erlang Size: 1837 bytes Desc: not available URL: From moxford@REDACTED Fri Apr 15 22:59:52 2011 From: moxford@REDACTED (Mike Oxford) Date: Fri, 15 Apr 2011 13:59:52 -0700 Subject: [erlang-questions] Pattern matching in function calls In-Reply-To: <20110415204418.GA1057@hanele.lan> References: <4DA58CB2.9070508@ecs.soton.ac.uk> <4DA5A144.5070800@ecs.soton.ac.uk> <4DA6D11B.40504@ecs.soton.ac.uk> <20110415204418.GA1057@hanele.lan> Message-ID: Just to be obnoxious.... Why not split on ',' and check last chars? If you find an escape char then build a single term out of it. Hello Foo\, it's me\, Mike,Hi Mike\, good to meet you! lists returns [Hello Foo\, it's me\, Mike,Hi Mike\, good to meet you!] You then check for '\' (and optionally, \\) and concat as needed, replacing '\' with ',' when not itself escaped. You'll have to iterate "N" terms a complete second time which may be a killer for performance but with smaller data sets it would work, and would lend itself to parallelization via distributed Map->Reduce on pairs of terms for really big sets. -mox On Fri, Apr 15, 2011 at 1:44 PM, Jachym Holecek wrote: > Hi, > > [I didn't read the rest of the thread, so hopefully I'm not terribly > offtopic. > Also, I got rid of top-posting and unlimited context quoting as both are > seen > as bad taste where I come from.] > > # Robert Raschke 2011-04-15: > >> On Thu, Apr 14, 2011 at 11:48 AM, Dave Challis > wrote: > >> Yup, I agree completely :) > >> > >> My question was mostly prompted by a blog post ( > http://ppolv.wordpress.com/2008/02/25/ > >> parsing-csv-in-erlang/) on parsing CSV in erlang. > >> > >> The do_parse function there has a dozen items which search binaries and > check state, which made > >> me wonder whether swapping the argument order round would make any > difference at all. > >> > >> That code makes me wonder if it could be rewritten using gen_fsm. Never > used gen_fsm myself, so I'm > >> not really sure. > > I don't think so; gen_fsm is brilliant for purely event-driven automata but > would be very ugly for a task like this. What the CSV guy needs to do is: > > 1) Get rid of #ecsv{} record, that's overkill for such a trivial purpose. > > 2) Break the parser into a bunch of tiny functions, pass all necessary > data in arguments. > > IIRC LFE's scanner/parser code is a neat example of how to get it right. > > Regards, > -- Jachym > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf.wiger@REDACTED Fri Apr 15 23:25:19 2011 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Fri, 15 Apr 2011 23:25:19 +0200 Subject: [erlang-questions] Confusing about gproc with global properties In-Reply-To: <4DA88D70.1050501@gmail.com> References: <4DA88D70.1050501@gmail.com> Message-ID: Hi Greg, Yeah, gproc:select/1 is a bit confusing. It is actually equivalent to gproc:select(all, Pat), where the first argument is the type (names, properties, etc.) - not the scope. Not that you'd know this from reading the docs, but you can do this: (n1@REDACTED)21> gproc:select({global,all},[{'_',[],['$$']}]). [[{p,g,foo},<0.37.0>,bar]] (n1@REDACTED)22> gproc:select({local,all},[{'_',[],['$$']}]). [[{p,l,foo},<0.37.0>,bar]] (n1@REDACTED)23> gproc:select({all,all},[{'_',[],['$$']}]). [[{p,g,foo},<0.37.0>,bar],[{p,l,foo},<0.37.0>,bar]] The {Scope, Type} tuple is, I think wholly undocumented. I'll go over the type specs and the documentation on that one. Thanks for highlighting it. BR, Ulf W On 15 Apr 2011, at 20:24, Gregory Haskins wrote: > Hi Ulf, all, > > I am playing around with adding gproc to my edist framework. I plan on > using it for both a pubsub fabric as well as for end-point management. > I ran into a snag during the integration that I _swear_ worked when I > did some small proof-of-concept work with gproc as stand alone. > > That is, it seems any global properties that are registered never end up > showing up. Consider this: > > (controller@REDACTED)2> gproc:reg({p, l, foo}, bar). > true > (controller@REDACTED)3> gproc:reg({p, g, foo}, bar). > true > (controller@REDACTED)4> > (controller@REDACTED)4> > (controller@REDACTED)4> gproc:select([{'_', [], ['$$']}]). > [[{p,l,foo},<0.131.0>,bar]] > > I do not understand why it appears that all global registrations meet a > /dev/null fate. Any pointers are greatly appreciated. > > Note that if I trace gproc_dist, I can see activity during the {p, g, _} > registration, as you would expect. I started erl with "-gproc > gproc_dist 'all'". I am using the v0.1.2 branch of esl/gproc > (https://github.com/esl/gproc/tree/v0.1.2), which, IIUC, is the tree Ulf > recommends we use (though now I cannot seem to remember where I got that > impression). > > Kind Regards, > -Greg > > Ulf Wiger, CTO, Erlang Solutions, Ltd. http://erlang-solutions.com From pmorreale@REDACTED Sat Apr 16 00:13:31 2011 From: pmorreale@REDACTED (Peter W. Morreale) Date: Fri, 15 Apr 2011 16:13:31 -0600 Subject: [erlang-questions] timestamp conversion Message-ID: <1302905611.23309.92.camel@hermosa.morreale.net> This may be embarrassingly simple, but I am struggling with it... I need compare string timestamps for dealing with expiration. In some cases it may another string timestamp, in others it will be against the current time. The string timestamps will always have the format: Year-Month-DayTHour:Min:SecZ" I think I want to convert to integer seconds, however even then its not clear to me how to perform the comparison, although I think this is a case for using the "if" expression. Please be gentle, I'm still new to Erlang. Thanks much -PWM From juanjo@REDACTED Sat Apr 16 00:47:56 2011 From: juanjo@REDACTED (Juan Jose Comellas) Date: Fri, 15 Apr 2011 19:47:56 -0300 Subject: [erlang-questions] timestamp conversion In-Reply-To: <1302905611.23309.92.camel@hermosa.morreale.net> References: <1302905611.23309.92.camel@hermosa.morreale.net> Message-ID: This function should help you convert a string timestamp into the elapsed seconds since January 1, year 0: timestamp_to_gregorian_seconds(Timestamp) -> %% Divide the string into its different datetime components Tokens = string:tokens(Timestamp, "-T:Z"), %% Convert each string into an integer [Year, Month, Day, Hour, Min, Sec] = [list_to_integer(N) || N <- Tokens], %% Convert the datetime to seconds calendar:datetime_to_gregorian_seconds({{Year, Month, Day}, {Hour, Min, Sec}}). I haven't even compiled it, but it should give you and idea of how to convert the timestamps. Juanjo On Fri, Apr 15, 2011 at 7:13 PM, Peter W. Morreale wrote: > > This may be embarrassingly simple, but I am struggling with it... > > I need compare string timestamps for dealing with expiration. ? In some > cases it may another string timestamp, in others it will be against the > current time. > > The string timestamps will always have the format: > > Year-Month-DayTHour:Min:SecZ" > > I think I want to convert to integer seconds, however even then its not > clear to me how to perform the comparison, although I think this is a > case for using the "if" expression. > > Please be gentle, I'm still new to Erlang. > > Thanks much > -PWM > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > From freza@REDACTED Sat Apr 16 00:53:49 2011 From: freza@REDACTED (Jachym Holecek) Date: Fri, 15 Apr 2011 23:53:49 +0100 Subject: [erlang-questions] timestamp conversion In-Reply-To: <1302905611.23309.92.camel@hermosa.morreale.net> References: <1302905611.23309.92.camel@hermosa.morreale.net> Message-ID: <20110415225349.GA5819@hanele.lan> # Peter W. Morreale 2011-04-15: > This may be embarrassingly simple, but I am struggling with it... > > I need compare string timestamps for dealing with expiration. In some > cases it may another string timestamp, in others it will be against the > current time. > > The string timestamps will always have the format: > > Year-Month-DayTHour:Min:SecZ" > > I think I want to convert to integer seconds, however even then its not > clear to me how to perform the comparison, although I think this is a > case for using the "if" expression. > > Please be gentle, I'm still new to Erlang. Well, if all the fields are fixed width and taking final 'Z' to mean UTC [1], you can just compare the strings, it will happen to work just the way you want. :-) Try it in the shell to convince yourself. More generally, you can easily [2] parse the string into datetime, which has the form {{Year, Month, Day}, {Hour, Min, Sec}}, and then use functions in calendar module (erl -man calendar) to convert that to gregorian seconds; that's a simple (and large) integer suitable for comparisons and distance calculations. For obtaining current timestamp you can use erlang:universaltime() or now(), depends if on the resolution you need. As to performing the comparison itself, you can do: case T2 >= T1 of true -> expire(Thing); _ -> keep(Thing) end or if T2 >= T1 -> expire(Thing); true -> keep(Thing) end or maybe_expire(T2, T1, Thing) where maybe_expire(T2, T1, Thing) when T2 >= T1 -> expire(Thing); maybe_expire(_, _, Thing) -> keep(Thing). In all of these, T1 and T2 are timestamps and their representation depends on the conditions above. 'Thing', expire/1 and keep/1 have just intuitive meaning. HTH, -- Jachym [1] For nitpicks: and assuming characters codes for 0-9 sort in natural order. [2] Assuming fixed fields widths, this goes like (completely untested): string_to_datetime([Y1, Y2, Y3, Y4, $-, M1, M2, $-, D1, D2, $T, H1, H2, $:, N1, N2, $:, S1, S2, $Z]) -> Date = {list_to_integer([Y1, Y2, Y3, Y4]), list_to_integer([M1, M2]), list_to_integer([D1, D2])}, Time = {list_to_integer([H1, H2]), list_to_integer([N1, N2]), list_to_integer([S1, S2])}, {Date, Time}. If field widths aren't fixed, it's still simple but a bit tedious -- ask if you need it (and don't forget to subject the person feeding you dodgy timestamps to great pain in that case!). From steven.charles.davis@REDACTED Sat Apr 16 01:15:30 2011 From: steven.charles.davis@REDACTED (Steve Davis) Date: Fri, 15 Apr 2011 16:15:30 -0700 (PDT) Subject: [erlang-questions] timestamp conversion In-Reply-To: <1302905611.23309.92.camel@hermosa.morreale.net> References: <1302905611.23309.92.camel@hermosa.morreale.net> Message-ID: I've not exhaustively tested this but a direct comparison of the list (though I prefer binary text representations for a whole raft of reasons)... should work for you. e.g. given the string format (esp. length) is known to be exactly the same: L1 = "2011-04-15T23:00:48Z" L2 = "2011-04-15T23:00:53Z" 4> L1 < L2. true 5> L1 > L2. false etc. On Apr 15, 5:13?pm, "Peter W. Morreale" wrote: > This may be embarrassingly simple, but I am struggling with it... > > I need compare string timestamps for dealing with expiration. ? In some > cases it may another string timestamp, in others it will be against the > current time. > > The string timestamps will always have the format: > > Year-Month-DayTHour:Min:SecZ" > > I think I want to convert to integer seconds, however even then its not > clear to me how to perform the comparison, although I think this is a > case for using the "if" expression. ? > > Please be gentle, I'm still new to Erlang. > > Thanks much > -PWM > > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://erlang.org/mailman/listinfo/erlang-questions From pmorreale@REDACTED Sat Apr 16 01:35:03 2011 From: pmorreale@REDACTED (Peter W. Morreale) Date: Fri, 15 Apr 2011 17:35:03 -0600 Subject: [erlang-questions] timestamp conversion (Spam Message) In-Reply-To: References: <1302905611.23309.92.camel@hermosa.morreale.net> Message-ID: <1302910503.23309.97.camel@hermosa.morreale.net> On Fri, 2011-04-15 at 16:15 -0700, Steve Davis wrote: > I've not exhaustively tested this but a direct comparison of the list > (though I prefer binary text representations for a whole raft of > reasons)... should work for you. > > e.g. given the string format (esp. length) is known to be exactly the > same: > L1 = "2011-04-15T23:00:48Z" > L2 = "2011-04-15T23:00:53Z" > > 4> L1 < L2. > true > 5> L1 > L2. > false > > etc. > Oh my. I get it. Thank you to all who responded. Best -PWM > On Apr 15, 5:13 pm, "Peter W. Morreale" wrote: > > This may be embarrassingly simple, but I am struggling with it... > > > > I need compare string timestamps for dealing with expiration. In some > > cases it may another string timestamp, in others it will be against the > > current time. > > > > The string timestamps will always have the format: > > > > Year-Month-DayTHour:Min:SecZ" > > > > I think I want to convert to integer seconds, however even then its not > > clear to me how to perform the comparison, although I think this is a > > case for using the "if" expression. > > > > Please be gentle, I'm still new to Erlang. > > > > Thanks much > > -PWM > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questi...@REDACTED://erlang.org/mailman/listinfo/erlang-questions > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From gregory.haskins@REDACTED Sat Apr 16 02:52:32 2011 From: gregory.haskins@REDACTED (Gregory Haskins) Date: Fri, 15 Apr 2011 20:52:32 -0400 Subject: [erlang-questions] Confusing about gproc with global properties In-Reply-To: References: <4DA88D70.1050501@gmail.com> Message-ID: <4DA8E850.1070407@gmail.com> On 4/15/11 5:25 PM, Ulf Wiger wrote: > > Hi Greg, > > Yeah, gproc:select/1 is a bit confusing. > > It is actually equivalent to gproc:select(all, Pat), where the first argument is the type (names, properties, etc.) - not the scope. > > Not that you'd know this from reading the docs, but you can do this: > > (n1@REDACTED)21> gproc:select({global,all},[{'_',[],['$$']}]). > [[{p,g,foo},<0.37.0>,bar]] > (n1@REDACTED)22> gproc:select({local,all},[{'_',[],['$$']}]). > [[{p,l,foo},<0.37.0>,bar]] > (n1@REDACTED)23> gproc:select({all,all},[{'_',[],['$$']}]). > [[{p,g,foo},<0.37.0>,bar],[{p,l,foo},<0.37.0>,bar]] > > The {Scope, Type} tuple is, I think wholly undocumented. > > I'll go over the type specs and the documentation on that one. Thanks for highlighting it. > Thanks Ulf, worked like a champ! And the schema translates to the QLC interface, too, I see. I have now officially converted over to using gproc: https://github.com/ghaskins/edist/commit/e8c080de766b23a801d3865442fac72c9045b453 Thanks for the help, and the great library. Kind Regards, -Greg -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 267 bytes Desc: OpenPGP digital signature URL: From kaiduanx@REDACTED Sat Apr 16 05:14:24 2011 From: kaiduanx@REDACTED (Kaiduan Xie) Date: Fri, 15 Apr 2011 23:14:24 -0400 Subject: [erlang-questions] RNG (Random Number Generator) used in Erlang SSL module Message-ID: Hi, I am wondering what is the RNG used in Erlang SSL module. What is the performance? I am investigating to see if a server can accept 1M TLS connections in 15 minutes. Someone reminded me that RNG may be the issue. What do you think? Please share your experience, and idea. Thanks, /Kaiduan From rdamodharan@REDACTED Sat Apr 16 06:54:04 2011 From: rdamodharan@REDACTED (Damodharan R) Date: Sat, 16 Apr 2011 10:24:04 +0530 Subject: [erlang-questions] RNG (Random Number Generator) used in Erlang SSL module In-Reply-To: References: Message-ID: This talk may give you the details you require. http://erlang-factory.com/conference/SFBay2011/speakers/kenjirikitake -- Damu On 16 April 2011 08:44, Kaiduan Xie wrote: > Hi, > > I am wondering what is the RNG used in Erlang SSL module. What is the > performance? I am investigating to see if a server can accept 1M TLS > connections in 15 minutes. Someone reminded me that RNG may be the > issue. What do you think? Please share your experience, and idea. > > Thanks, > > /Kaiduan > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From max.lapshin@REDACTED Sat Apr 16 08:58:31 2011 From: max.lapshin@REDACTED (Max Lapshin) Date: Sat, 16 Apr 2011 10:58:31 +0400 Subject: [erlang-questions] Opensourcing rtp in erlyvideo (and many other things) Message-ID: I've opensourced our RTSP/RTP implementation in erlyvideo. Now it is possible to read RTP streams and to send them to client. Also we have opened some other code, which was earlier only in closed commercial code. So, currently I have implemented and opensourced following implementations in erlang: RTMP in and out MPEG-TS in and out RTSP/SDP/RTP in and out Shoutcast in and out with following file formats: mp4 in and out flv in and out. From zabrane3@REDACTED Sat Apr 16 11:41:30 2011 From: zabrane3@REDACTED (Zabrane Mickael) Date: Sat, 16 Apr 2011 11:41:30 +0200 Subject: [erlang-questions] Opensourcing rtp in erlyvideo (and many other things) In-Reply-To: References: Message-ID: Hi Max, Thousand thanks from the community. Keep up the good work. Regards, Zab Le 16 avr. 2011 ? 08:58, Max Lapshin a ?crit : > I've opensourced our RTSP/RTP implementation in erlyvideo. Now it is > possible to read RTP streams and to send them to client. > > Also we have opened some other code, which was earlier only in closed > commercial code. > > So, currently I have implemented and opensourced following > implementations in erlang: > > RTMP in and out > MPEG-TS in and out > RTSP/SDP/RTP in and out > Shoutcast in and out > > with following file formats: > > mp4 in and out > flv in and out. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From max.lapshin@REDACTED Sat Apr 16 12:40:52 2011 From: max.lapshin@REDACTED (Max Lapshin) Date: Sat, 16 Apr 2011 14:40:52 +0400 Subject: [erlang-questions] Opensourcing rtp in erlyvideo (and many other things) In-Reply-To: <96E998C2-1709-4EC3-80B5-18BD98345C48@gmail.com> References: <96E998C2-1709-4EC3-80B5-18BD98345C48@gmail.com> Message-ID: On Sat, Apr 16, 2011 at 2:05 PM, erlang wrote: > Hi Max, > > Which license did you choosed for this opensourcing? > Hope not too restrictive as GPL/GPL2 or GPL3. > > An advice to attract more people (and professionals in my case) > to use "erlyvideo" and its underlying supported protocols is > Apache2, MIT or BSD. > I distribute all my code under GPL. To receive source under other license, contact info@REDACTED From ulf.wiger@REDACTED Sat Apr 16 21:39:13 2011 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Sat, 16 Apr 2011 21:39:13 +0200 Subject: [erlang-questions] Confusing about gproc with global properties In-Reply-To: <4DA8E850.1070407@gmail.com> References: <4DA88D70.1050501@gmail.com> <4DA8E850.1070407@gmail.com> Message-ID: <98693174-AC75-40D3-A501-D91425F030B6@erlang-solutions.com> Thinking about it, I'd like to change gproc:select/1 to also include global objects, in other words: select(Pat) -> select({all, all}, Pat). This is a backwards incompatible change, but I am guessing that not too many people use the global gproc functionality yet, so this should be the time to do it. Any objections? BR, Ulf W On 16 Apr 2011, at 02:52, Gregory Haskins wrote: > On 4/15/11 5:25 PM, Ulf Wiger wrote: >> >> Hi Greg, >> >> Yeah, gproc:select/1 is a bit confusing. >> >> It is actually equivalent to gproc:select(all, Pat), where the first argument is the type (names, properties, etc.) - not the scope. >> >> Not that you'd know this from reading the docs, but you can do this: >> >> (n1@REDACTED)21> gproc:select({global,all},[{'_',[],['$$']}]). >> [[{p,g,foo},<0.37.0>,bar]] >> (n1@REDACTED)22> gproc:select({local,all},[{'_',[],['$$']}]). >> [[{p,l,foo},<0.37.0>,bar]] >> (n1@REDACTED)23> gproc:select({all,all},[{'_',[],['$$']}]). >> [[{p,g,foo},<0.37.0>,bar],[{p,l,foo},<0.37.0>,bar]] >> >> The {Scope, Type} tuple is, I think wholly undocumented. >> >> I'll go over the type specs and the documentation on that one. Thanks for highlighting it. >> > > Thanks Ulf, worked like a champ! And the schema translates to the QLC > interface, too, I see. I have now officially converted over to using gproc: > > https://github.com/ghaskins/edist/commit/e8c080de766b23a801d3865442fac72c9045b453 > > Thanks for the help, and the great library. > > Kind Regards, > -Greg > Ulf Wiger, CTO, Erlang Solutions, Ltd. http://erlang-solutions.com From jesper.louis.andersen@REDACTED Sun Apr 17 14:26:25 2011 From: jesper.louis.andersen@REDACTED (Jesper Louis Andersen) Date: Sun, 17 Apr 2011 14:26:25 +0200 Subject: [erlang-questions] Quick question about resetting shells In-Reply-To: References: <4DA81889.4020605@ecs.soton.ac.uk> Message-ID: On Fri, Apr 15, 2011 at 12:49, OvermindDL1 wrote: > What are the differences and pros/cons between eunit and common_test, and > any good tutorials for setting up such a server as you describe? eunit has lighter weight and is mostly designed to facilitate internal testing of the programs at hand. That is, a single unit (usually a module). Common Test on the other hand is designed for large-scale testing of software systems, not necessarily Erlang. It supports distribution and parallel testing. The downside however, is that common test is tougher to get going initailly. As a consequence, common test is usually employed for external testing. In the etorrent project (a bittorrent client), we use eunit for a lot of the internal stuff to make sure it works like it is supposed to. But we also employ common_test to spawn alternative bittorrent clients - written by other people - and make sure we can communicate back and forth with them. -- J. From jesper.louis.andersen@REDACTED Sun Apr 17 14:29:53 2011 From: jesper.louis.andersen@REDACTED (Jesper Louis Andersen) Date: Sun, 17 Apr 2011 14:29:53 +0200 Subject: [erlang-questions] Quick question about resetting shells In-Reply-To: References: <4DA81889.4020605@ecs.soton.ac.uk> Message-ID: On Fri, Apr 15, 2011 at 12:06, Dave Challis wrote: > 5. Quit shell, go to 1 I tend to run the program and then recompile the code with rebar when I fix things. Then a single l(Mod) is enough to make Erlang hot-deploy the new code into the running system (ah, OTP is nice here). Because the code is already running, I can usually see straight away if it went well or not based on input to the system from the outside. The trick is to get rid of exploratory testing in the erlang shell for more than small simple things and then concentrate on automating the test process, as Vlad suggests in another mail. -- J. From jameschurchman@REDACTED Sun Apr 17 14:52:30 2011 From: jameschurchman@REDACTED (James Churchman) Date: Sun, 17 Apr 2011 13:52:30 +0100 Subject: [erlang-questions] "what do the erlang emulator info statements mean" Message-ID: I was wondering, so after a bit of googling came across this. Not sure if its just a rehash of what the docs say but i found it very informative : http://stackoverflow.com/questions/1182025/what-do-the-erlang-emulator-info-statements-mean (options like hybrid-heap look very interesting) kind of thing that's worth knowing! James -------------- next part -------------- An HTML attachment was scrubbed... URL: From kenrobinsonster@REDACTED Sun Apr 17 17:11:30 2011 From: kenrobinsonster@REDACTED (Ken Robinson) Date: Mon, 18 Apr 2011 01:11:30 +1000 Subject: [erlang-questions] Runtime checking for types Message-ID: I know this sounds crazy but I was wondering if there was some runtime check for types. I've created an abstract data type in an .erl (see below). I want to now pattern match -opaque u16int() :: 0..(1 bsl 16 - 1). -export_type([u16int/0]). ... -record(headerrec, {message_id :: u16int()}). -opaque headerrec() :: #headerrec{}. -export_type([headerrec/0]). I can do a runtime test like so: foo(#headerrec{} = HeaderRec) -> ... What I would like to do is test for the new type similar to the gaurds is_record() and the like. Any ideas? I realize I can put this all in a .hrl file but this would break the encapsualtion. regards, Ken Robinson Mob +61438681120 Home +61738523767 From laforge@REDACTED Sun Apr 17 19:54:54 2011 From: laforge@REDACTED (Harald Welte) Date: Sun, 17 Apr 2011 19:54:54 +0200 Subject: [erlang-questions] asn1ct/asn1rt EXTERNAL 1990/1994 conversion information loss Message-ID: <20110417175454.GI9379@prithivi.gnumonks.org> Hi! I'm working on a variety of (Free Software) projects related to mobile communications (http://cgit.osmocom.org/). One of them is dealing with the GSM MAP protocol (TS 09.02, TS 29.002) which is specified in ASN.1 I'm using the Erlang asn1ct/asn1rt to parse incoming MAP messages from the worldwide SS7 backbone, filtering + patching some of the data contained in it and re-transmit the MAP messages. It's like an application-level-gateway / proxy that can modify some of the data. MAP itself uses TCAP (Q.773). TCAP messages have a dialogue and a component portion. The dialogue portion is specified as an EXTERNAL type: DialoguePortion ::= [APPLICATION 11] EXPLICIT EXTERNAL Note: The MAP sender are (normally?) using the 1990 representation of EXTERNAL, not the 1994 version. Erlangs asn1ct-generated dec_EXTERNAL code first internally generates along those lines: #'EXTERNAL'{ 'direct-reference' = {0,0,17,773,1,1,1}, 'indirect-reference' = asn1_NOVALUE, 'data-value-descriptor' = asn1_NOVALUE, encoding = {'single-ASN1-type', [96,15,128,2,7,128,161,9,6,7,4,0,0,1,0,1,3]}} However, the asn1ct generated code automatically converts this #'EXTERNAL'{} record into a tuple of the following structure (using transform_to_EXTERNAL1994/1): {'EXTERNAL', {syntax,{0,0,17,773,1,1,1}}, asn1_NOVALUE, [96,15,128,2,7,128,161,9,6,7,4,0,0,1,0,1,3]} The problem is, when you pass this tuple into the asn1ct-generated encoder, the 'single-ASN1-type' information has been lost, and it will be replaced with 'octet-aligned'. The result is that instead of {tag,'CONTEXT',0,'EXPLICIT',32} we now use {tag,'CONTEXT',1,'IMPLICIT',0} for encoding the data. This is not valid within the scope of MAP, and both the wireshark MAP dissector as well as all MAP implementations I've seen reject or ignore the resulting message. The problem fundamentally can be summarized as: * EXTERNAL can contain inner data in either 'Single-ASN1-type' or 'octet-aligned' * the OTP asn1ct (at least in ber_bin mode) looses this information and does not pass it back to the caller when decoding * if the resulting data is passed through the encoder, the encoded data semantically differs from the original undecoded BER data. I think this is probably not the intended behaviour. It would be weird if decoding and re-encoding the same unmodified data leads to different BER tags in the tree. What is wrong in passing the 1990 or 1994 EXTERNAL types from the decoder into the user program? Why should the user not know which of the two formats was being used? I believe at the very least, this automatic conversion should be something that can be configured as a compiler option. Any comments/ideas/suggestions? Regards, Harald -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From zabrane3@REDACTED Sun Apr 17 23:23:11 2011 From: zabrane3@REDACTED (zabrane Mikael) Date: Sun, 17 Apr 2011 23:23:11 +0200 Subject: [erlang-questions] Yaws's "sendfile" linked-in driver : "stealing control of fd" error Message-ID: Hi OTP team & Steve, I'm using the "sendfile" (thanks to Steve Vinoski) linked-in driver borrowed from "Yaws" in one of my pet project. Today, I noticed this strange error: =ERROR REPORT==== 17-Apr-2011::20:49:18 === driver_select(0x0000000000000c31, 24, ERL_DRV_WRITE, 1) by sendfile_drv driver #Port<0.3121> stealing control of fd=24 from output driver tcp_inet #Port<0.10029> Searching "stealing control of fd=" in the "otp_src_R14B02" source code returns this: otp_src_R14B02> find . -type "f" | xargs grep -n "stealing control of" | head -1 ./erts/emulator/sys/common/erl_check_io.c:883: The C function printing out this error line is: static void steal(erts_dsprintf_buf_t *dsbufp, ErtsDrvEventState *state, int mode) { erts_dsprintf(dsbufp, "stealing control of fd=%d from ", (int) state->fd); switch (state->type) { case ERTS_EV_TYPE_DRV_SEL: { int deselect_mode = 0; Eterm iid = state->driver.select->inport; Eterm oid = state->driver.select->outport; if ((mode & ERL_DRV_READ) && (is_not_nil(iid))) { erts_dsprintf(dsbufp, "input driver "); print_driver_name(dsbufp, iid); erts_dsprintf(dsbufp, "%T ", iid); deselect_mode |= ERL_DRV_READ; } Could someone please tell me what's the aim of this C function? Should I consider this as an error or can I forget about it? Regards, Zab From robert.virding@REDACTED Mon Apr 18 00:51:50 2011 From: robert.virding@REDACTED (Robert Virding) Date: Sun, 17 Apr 2011 22:51:50 +0000 (GMT) Subject: [erlang-questions] Runtime checking for types In-Reply-To: <1930911379.107501303080619591.JavaMail.root@zimbra> Message-ID: <945465586.107521303080710089.JavaMail.root@zimbra> I think the thing to remember is that records are not separate data types. At run-time a record is just a tuple which is large enough to contain all the fields (and only the field values) and the first element of the tuple is an atom which is the name of the record. As such records only exist at compile-time and the compiler converts ALL record operations to the corresponding tuple operations. Your headerrec record just becomes the tuple {headerrec,MessageId}. So actually Erlang does not really have proper abstract data types. Robert ----- "Ken Robinson" wrote: > I know this sounds crazy but I was wondering if there was some > runtime > check for types. I've created an abstract data type in an .erl (see > below). I want to now pattern match > > -opaque u16int() :: 0..(1 bsl 16 - 1). > -export_type([u16int/0]). > ... > -record(headerrec, {message_id :: u16int()}). > -opaque headerrec() :: #headerrec{}. > -export_type([headerrec/0]). > > I can do a runtime test like so: > foo(#headerrec{} = HeaderRec) -> > ... > > What I would like to do is test for the new type similar to the > gaurds > is_record() and the like. Any ideas? I realize I can put this all in > a > .hrl file but this would break the encapsualtion. > > regards, > Ken Robinson > Mob +61438681120 > Home +61738523767 > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From steven.charles.davis@REDACTED Mon Apr 18 01:04:01 2011 From: steven.charles.davis@REDACTED (Steve Davis) Date: Sun, 17 Apr 2011 16:04:01 -0700 (PDT) Subject: [erlang-questions] Quick question about resetting shells In-Reply-To: References: <4DA81889.4020605@ecs.soton.ac.uk> Message-ID: <33f8199b-0254-4e87-a12d-a3f7d985219f@x10g2000vbn.googlegroups.com> My development cycle is: 1) start app in shell 2) change code 3) type make() into the shell 4) test the new code How? Take a look at the docs for user_default in the OTP docs. I have a few useful simple "comfort" calls like this added to my user_default module (which on my ERL_LIBS path). e.g. -module(user_default). -compile(export_all). ....other useful commands make() -> {ok, WorkingDir} = file:get_cwd(), case file:read_file_info("Emakefile") of {ok, _} -> io:format("Emake ~p~n", [WorkingDir]); {error, _} -> io:format("~p~n", [WorkingDir]) end, make:all([load]). hth, /s On Apr 17, 7:29?am, Jesper Louis Andersen wrote: > On Fri, Apr 15, 2011 at 12:06, Dave Challis wrote: > > 5. Quit shell, go to 1 > > I tend to run the program and then recompile the code with rebar when > I fix things. Then a single l(Mod) is enough to make Erlang hot-deploy > the new code into the running system (ah, OTP is nice here). Because > the code is already running, I can usually see straight away if it > went well or not based on input to the system from the outside. The > trick is to get rid of exploratory testing in the erlang shell for > more than small simple things and then concentrate on automating the > test process, as Vlad suggests in another mail. > > -- > J. > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://erlang.org/mailman/listinfo/erlang-questions From steven.charles.davis@REDACTED Mon Apr 18 01:07:00 2011 From: steven.charles.davis@REDACTED (Steve Davis) Date: Sun, 17 Apr 2011 16:07:00 -0700 (PDT) Subject: [erlang-questions] Runtime checking for types In-Reply-To: <945465586.107521303080710089.JavaMail.root@zimbra> References: <945465586.107521303080710089.JavaMail.root@zimbra> Message-ID: <07054f02-aee1-4baf-85b8-6870782e9e18@dr5g2000vbb.googlegroups.com> IMHO, a focus on type-safety can lose you a truly *massive* amount of time that could be spent doing something useful. ;-P /s From vinoski@REDACTED Mon Apr 18 02:45:29 2011 From: vinoski@REDACTED (Steve Vinoski) Date: Sun, 17 Apr 2011 20:45:29 -0400 Subject: [erlang-questions] Yaws's "sendfile" linked-in driver : "stealing control of fd" error In-Reply-To: References: Message-ID: On Sun, Apr 17, 2011 at 5:23 PM, zabrane Mikael wrote: > Hi OTP team & Steve, > > I'm using the "sendfile" (thanks to Steve Vinoski) linked-in driver > borrowed from "Yaws" > in one of my pet project. > > Today, I noticed this strange error: > =ERROR REPORT==== 17-Apr-2011::20:49:18 === > driver_select(0x0000000000000c31, 24, ERL_DRV_WRITE, 1) by > sendfile_drv driver #Port<0.3121> stealing control of fd=24 from > output driver tcp_inet #Port<0.10029> I can't speak authoritatively about exactly what causes this, but I can say that most of the times I've seen this were when serious problems were occurring -- most often prior to a fatal VM crash, but I think it's also occasionally occurred when the VM was shutting down normally. It's been awhile since I've seen it at all, though. > Could someone please tell me what's the aim of this C function? > Should I consider this as an error or can I forget about it? Someone familiar with the "steal" code should correct me if I'm wrong (please!), but I would recommend treating this as an error. Can you provide details about what your app is doing when it causes this error report? --steve From elecpaoao@REDACTED Mon Apr 18 05:05:07 2011 From: elecpaoao@REDACTED (Chi Zhang) Date: Mon, 18 Apr 2011 11:05:07 +0800 Subject: [erlang-questions] error_logger not outputting anything Message-ID: Hi I added an event handler to redirect error_logger reports to syslog. The handler looks like this: handle_event({info_msg, _Gleader, {_Pid, Format, Data}}, #state{info_logger=Logger}=State) -> syslog_write("I", Logger, Format, Data), {ok, State}; handle_event({error, _Gleader, {_Pid, Format, Data}}, #state{error_logger=Logger}=State) -> syslog_write("E", Logger, Format, Data), {ok, State}; handle_event(_Event, State) -> {ok, State}. syslog_write(Prefix, Facility, Format, Data) -> Cmd = try Message = lists:flatten(io_lib:format(Format, Data)), lists:flatten(io_lib:format("logger -t essmsd -p ~s.Debug \'<~s> ~s\'", [Facility, Prefix, Message])) catch _:_ -> lists:flatten(io_lib:format("logger -t essmsd -p ~s.Debug \'~p\'", [Facility, [Prefix, Format, Data]])) end, os:cmd(Cmd). I used logger command to write to syslog files. It works at first, but after running for one or two days, the error_logger stopped working. It outputs nothing (when I invoke error_logger:info_msg("test") on the console, it only returns an ok) no matter what the input, neither to the log file, nor to the console. I tried to put trace on the function syslog_write and error:logger:info_msg and it gave me the following result: (essmsd@REDACTED)11> dbg:tracer(), dbg:p(all, c), dbg:tpl(error_logger, info_msg, x). {ok,[{matched,'essmsd@REDACTED',2},{saved,x}]} (essmsd@REDACTED)12> error_logger:info_msg("xx"). ok (<0.1735.0>) call error_logger:info_msg("xx") (essmsd@REDACTED)13> (<0.1735.0>) call error_logger:info_msg("xx",[]) (<0.1735.0>) returned from error_logger:info_msg/2 -> ok (<0.1735.0>) returned from error_logger:info_msg/1 -> ok Which means the error_logger:info_msg is being called, but it never output anything but returned an ok! -- Sincerely Yours, Chi Zhang elecpaoao@REDACTED College of Computer Science and Technology, Zhejiang University From zabrane3@REDACTED Mon Apr 18 09:43:48 2011 From: zabrane3@REDACTED (Zabrane Mickael) Date: Mon, 18 Apr 2011 09:43:48 +0200 Subject: [erlang-questions] sendfile stolen fd In-Reply-To: References: <657FB9E9-854F-46A0-B659-8B406C13AE10@gmail.com> <737E0150-B222-4FBA-B4F3-615CCD8C7E6A@gmail.com> Message-ID: <814B86AE-9CAA-4CD1-83AB-B620902751B1@gmail.com> Hi Steve, Le 18 avr. 2011 ? 03:43, Steve Vinoski a ?crit : > Just curious: do you ever set the socket into {active, once} or > {active, true} mode? That's correct Steve. I the server side, the socket is set to {active, false} in the beginning. > I'm guessing the "stealing" is the result of a > socket select event invoking callbacks within multiple drivers, so if > tcp_inet is interested in read events concurrently with sendfile being > interested in write events, and the socket becomes both readable and > writeable, I think a "steal" could occur. But when HTTP headers parsing is done, I change it to {active, true} by calling: ok = inet:setopts(Socket, [{active, true}, {packet, raw}, {delay_send, true}, {keepalive, true}]), Regards Zab From erlangsiri@REDACTED Mon Apr 18 09:46:49 2011 From: erlangsiri@REDACTED (Siri Hansen) Date: Mon, 18 Apr 2011 09:46:49 +0200 Subject: [erlang-questions] error_logger not outputting anything In-Reply-To: References: Message-ID: Hi Chi Zhang! Can you see if there are any outputs from the error_logger from any other handlers? Can you check if your handler is still known to the error_logger: gen_event:which_handlers(error_logger). You could also check the state of the error logger: sys:get_status(error_logger) - which will (amongst others) show all handlers and their State variable. If all seems ok - you could try tracing you own module to see if your msg for some reason ends up in the "catch all" clause of handle_event. I hope this gives some indication of what might be the problem. Regards /siri@REDACTED 2011/4/18 Chi Zhang > Hi > > I added an event handler to redirect error_logger reports to syslog. > The handler looks like this: > > handle_event({info_msg, _Gleader, {_Pid, Format, Data}}, > #state{info_logger=Logger}=State) -> > syslog_write("I", Logger, Format, Data), > {ok, State}; > handle_event({error, _Gleader, {_Pid, Format, Data}}, > #state{error_logger=Logger}=State) -> > syslog_write("E", Logger, Format, Data), > {ok, State}; > handle_event(_Event, State) -> > {ok, State}. > > syslog_write(Prefix, Facility, Format, Data) -> > Cmd = try > Message = lists:flatten(io_lib:format(Format, Data)), > lists:flatten(io_lib:format("logger -t essmsd -p > ~s.Debug \'<~s> ~s\'", > [Facility, Prefix, Message])) > catch > _:_ -> > lists:flatten(io_lib:format("logger -t essmsd -p > ~s.Debug \'~p\'", > [Facility, [Prefix, > Format, Data]])) > end, > os:cmd(Cmd). > > I used logger command to write to syslog files. It works at first, but > after running for one or two days, > the error_logger stopped working. It outputs nothing (when I invoke > error_logger:info_msg("test") on the console, > it only returns an ok) no matter what the input, neither to the log > file, nor to the console. > > I tried to put trace on the function syslog_write and > error:logger:info_msg and it gave me the following result: > > (essmsd@REDACTED)11> dbg:tracer(), dbg:p(all, c), > dbg:tpl(error_logger, info_msg, x). > {ok,[{matched,'essmsd@REDACTED',2},{saved,x}]} > > (essmsd@REDACTED)12> error_logger:info_msg("xx"). > ok > (<0.1735.0>) call error_logger:info_msg("xx") > > (essmsd@REDACTED)13> > (<0.1735.0>) call error_logger:info_msg("xx",[]) > (<0.1735.0>) returned from error_logger:info_msg/2 -> ok > (<0.1735.0>) returned from error_logger:info_msg/1 -> ok > > Which means the error_logger:info_msg is being called, but it never > output anything but returned an ok! > > -- > Sincerely Yours, > Chi Zhang > > elecpaoao@REDACTED > College of Computer Science and Technology, Zhejiang University > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dsc@REDACTED Mon Apr 18 10:29:05 2011 From: dsc@REDACTED (Dave Challis) Date: Mon, 18 Apr 2011 09:29:05 +0100 Subject: [erlang-questions] Quick question about resetting shells In-Reply-To: References: <4DA81889.4020605@ecs.soton.ac.uk> <4DABF651.7020204@ecs.soton.ac.uk> Message-ID: On 15/04/11 11:18, Vlad Dumitrescu wrote: > Hi! > > On Fri, Apr 15, 2011 at 12:06, Dave Challis > wrote: > > I'm fairly new to erlang, so when I'm working on something, my > development cycle usually goes something like: > > 1. Write/change code > 2. Compile using rebar / erlc > 3. Start a shell using erl -pa ebin > 4. Paste in commands to test changes > 5. Quit shell, go to 1 > > Steps 3-5 usually take the longest, so I'm wondering, is there any > way to stay in a shell, but to reset it to the default state? I.e. > the equivalent of calling l(module_name) to load the latest version > of the compiled module, calling f() to clear all variables, and also > destroying any ETS tables that might have been created. > > Or is there some better way to test code changes from the shell > after .beam files have been recompiled while it's running? > > > I would strongly recommend to start using a test server - eunit or > common_test are included in OTP. It really does wonders with the length > of the development cycle :-) Plus it's much more reproducible and all > the other advantages of having automated tests. Thanks, I'll take a look into eunit (having read the comparison of the two!). It saves me asking about testing frameworks here too :) -- Dave Challis dsc@REDACTED From sverker@REDACTED Mon Apr 18 12:02:18 2011 From: sverker@REDACTED (Sverker Eriksson) Date: Mon, 18 Apr 2011 12:02:18 +0200 Subject: [erlang-questions] Yaws's "sendfile" linked-in driver : "stealing control of fd" error In-Reply-To: References: Message-ID: <4DAC0C2A.5060705@erix.ericsson.se> On Sun, Apr 17, 2011 at 5:23 PM, zabrane Mikael wrote: >> Hi OTP team & Steve, >> >> I'm using the "sendfile" (thanks to Steve Vinoski) linked-in driver >> borrowed from "Yaws" >> in one of my pet project. >> >> Today, I noticed this strange error: >> =ERROR REPORT==== 17-Apr-2011::20:49:18 === >> driver_select(0x0000000000000c31, 24, ERL_DRV_WRITE, 1) by >> sendfile_drv driver #Port<0.3121> stealing control of fd=24 from >> output driver tcp_inet #Port<0.10029> >> > > The error message kind of says it all: The driver "sendfile_drv" is calling driver_select() to subscribe for output events on file descriptor 24. BUT, driver "tcp_inet" is already subscribing to output events on that very same file descriptor 24. Driver "sendfile_drv" thus steals the file descriptor from "tcp_inet" as only one port at a time can subscribe to a particular file descriptor event. I think you should consider this as an error. Drivers are not supposed to act like this. The normal cause of this is a driver that forgets to deselect a file descriptor before closing it. Despite that I would regard sendfile_drv as the primary suspect here as the new kid on the block. /Sverker, Erlang/OTP From zabrane3@REDACTED Mon Apr 18 12:09:01 2011 From: zabrane3@REDACTED (Zabrane Mickael) Date: Mon, 18 Apr 2011 12:09:01 +0200 Subject: [erlang-questions] Yaws's "sendfile" linked-in driver : "stealing control of fd" error In-Reply-To: <4DAC0C2A.5060705@erix.ericsson.se> References: <4DAC0C2A.5060705@erix.ericsson.se> Message-ID: <0941A1BE-EFA1-4135-8056-A5AB8B92CAD8@gmail.com> Hi Sverker, Thanks a lot for these explanations. Hope that Steve (and Tuncer with his "sendfile" version) can fix that very soon. Regards Zab Le 18 avr. 2011 ? 12:02, Sverker Eriksson a ?crit : > On Sun, Apr 17, 2011 at 5:23 PM, zabrane Mikael wrote: >>> Hi OTP team & Steve, >>> >>> I'm using the "sendfile" (thanks to Steve Vinoski) linked-in driver >>> borrowed from "Yaws" >>> in one of my pet project. >>> >>> Today, I noticed this strange error: >>> =ERROR REPORT==== 17-Apr-2011::20:49:18 === >>> driver_select(0x0000000000000c31, 24, ERL_DRV_WRITE, 1) by >>> sendfile_drv driver #Port<0.3121> stealing control of fd=24 from >>> output driver tcp_inet #Port<0.10029> >>> >> >> > The error message kind of says it all: > The driver "sendfile_drv" is calling driver_select() to subscribe for output events on file descriptor 24. BUT, driver "tcp_inet" is already subscribing to output events on that very same file descriptor 24. Driver "sendfile_drv" thus steals the file descriptor from "tcp_inet" as only one port at a time can subscribe to a particular file descriptor event. > > I think you should consider this as an error. Drivers are not supposed to act like this. The normal cause of this is a driver that forgets to deselect a file descriptor before closing it. Despite that I would regard sendfile_drv as the primary suspect here as the new kid on the block. > > /Sverker, Erlang/OTP > From jesper.louis.andersen@REDACTED Mon Apr 18 12:58:34 2011 From: jesper.louis.andersen@REDACTED (Jesper Louis Andersen) Date: Mon, 18 Apr 2011 12:58:34 +0200 Subject: [erlang-questions] Runtime checking for types In-Reply-To: <07054f02-aee1-4baf-85b8-6870782e9e18@dr5g2000vbb.googlegroups.com> References: <945465586.107521303080710089.JavaMail.root@zimbra> <07054f02-aee1-4baf-85b8-6870782e9e18@dr5g2000vbb.googlegroups.com> Message-ID: On Mon, Apr 18, 2011 at 01:07, Steve Davis wrote: > IMHO, a focus on type-safety can lose you a truly *massive* amount of > time that could be spent doing something useful. There are many intricate dependencies which you can't simply resolve in a few moments of thought on that one. The point of type safety is to trade a short-term added specification for a long-term benefit. You write down a precise expression of intent with the type, and being precise takes more time. But it is extremely helpful over the course of larger programs, provides (checkable!) documentation, yields more effective execution trivially and so on. The initial ignorance of static types in Erlang is understandable. Other things were more important to get right and history was such that we did not understand certain parts of the intermingling of types with distribution etc.. But today, I feel there is no excuse. Should I design a modern Erlang, I would start with a statically typed world in which communicaiton use polymorphic variants. Essentially: An internal process is statically typed, but communicate in a dynamically typed setting. Thus, I have lost *nothing* compared to Erlang, but I can compile processes to be an order of magnitude faster, trivially. From there, I can probably define a channel-primitive between processes with static type constraint such that processes can intercommunicate in a type-safe way. Perhaps even with a shared-persistent-heap semantics. Remember, dynamic typing is a straitjacket, in which you cannot fully express yourself, whereas static typing give you a rich language for doing so. -- J. From essen@REDACTED Mon Apr 18 13:03:53 2011 From: essen@REDACTED (=?ISO-8859-1?Q?Lo=EFc_Hoguin?=) Date: Mon, 18 Apr 2011 13:03:53 +0200 Subject: [erlang-questions] Typespecs export not working as intended? Message-ID: <4DAC1A99.4090206@dev-extend.eu> Hello, I have ran into a weird issue while refactoring the type specs in a project. It seems types in a module can be used even if they are not exported using export_type. Neither of the compiler or dialyzer are complaining about it. For example, module a declares a type my_type(), module b uses it with a:my_type(), no export_type in module, yet it still works. Is that normal? The documentation clearly states that types should be exported. -- Lo?c Hoguin Dev:Extend From mikhail.sobolev@REDACTED Mon Apr 18 14:37:35 2011 From: mikhail.sobolev@REDACTED (Mikhail Sobolev) Date: Mon, 18 Apr 2011 15:37:35 +0300 Subject: [erlang-questions] Web Frameworks: which to choose? Message-ID: Hi, We (a few friends of mine and I) are considering to learn some Erlang. We would like to create a web base application. So far we've been implementing various apps using Django/Python, but we want to try something completely different. A quick search showed that there're quite a few frameworks available, but being beginners in the area, we do not know what we should be looking at. Any suggestions? :) Kind Regards, -- Misha From corticalcomputer@REDACTED Mon Apr 18 14:43:30 2011 From: corticalcomputer@REDACTED (G.S.) Date: Mon, 18 Apr 2011 05:43:30 -0700 Subject: [erlang-questions] Web Frameworks: which to choose? In-Reply-To: References: Message-ID: Hey Mikhail, I'd recommend Nitrogen, it's very solid. Regards, -Gene On Mon, Apr 18, 2011 at 5:37 AM, Mikhail Sobolev wrote: > Hi, > > We (a few friends of mine and I) are considering to learn some Erlang. > > We would like to create a web base application. So far we've been > implementing various apps using Django/Python, but we want to try > something completely different. > > A quick search showed that there're quite a few frameworks available, > but being beginners in the area, we do not know what we should be > looking at. > > Any suggestions? :) > > Kind Regards, > > -- > Misha > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From erlangy@REDACTED Mon Apr 18 14:50:32 2011 From: erlangy@REDACTED (erlang) Date: Mon, 18 Apr 2011 14:50:32 +0200 Subject: [erlang-questions] Web Frameworks: which to choose? In-Reply-To: References: Message-ID: From an old post: -----Mensaje original----- De: erlang-questions@REDACTED [mailto:erlang-questions@REDACTED] En nombre de zabrane Mikael Enviado el: Jueves, 25 de Noviembre de 2010 09:50 a.m. Para: Jesper Louis Andersen CC: Dmitry Demeshchuk; Steve Vinoski; Gilberio Carmenates Garc?a; erlang-questions@REDACTED Asunto: Re: [erlang-questions] The most better Erlang web server! For Erlang Web development: - MochiWeb (very stable, for production): http://code.google.com/p/mochiweb/ - BeepBeep (based on MochiWeb): https://github.com/davebryson/beepbeep - Nitrogen: http://nitrogenproject.com/ - ElangWeb: http://www.erlang-web.org/ - Misultin (speedy): http://code.google.com/p/misultin/ - Chicago Boss : http://www.chicagoboss.org/ - Cowboy (a newcomer, speedy): https://github.com/extend/cowboy -- Regards Zabrane Le 18 avr. 2011 ? 14:43, G.S. a ?crit : > Hey Mikhail, > > I'd recommend Nitrogen, it's very solid. > > Regards, > -Gene > > On Mon, Apr 18, 2011 at 5:37 AM, Mikhail Sobolev wrote: > Hi, > > We (a few friends of mine and I) are considering to learn some Erlang. > > We would like to create a web base application. So far we've been > implementing various apps using Django/Python, but we want to try > something completely different. > > A quick search showed that there're quite a few frameworks available, > but being beginners in the area, we do not know what we should be > looking at. > > Any suggestions? :) > > Kind Regards, > > -- > Misha > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From russell.brown@REDACTED Mon Apr 18 14:51:57 2011 From: russell.brown@REDACTED (Russell Brown) Date: Mon, 18 Apr 2011 13:51:57 +0100 Subject: [erlang-questions] Web Frameworks: which to choose? In-Reply-To: References: Message-ID: On 18 Apr 2011, at 13:37, Mikhail Sobolev wrote: > Hi, > > We (a few friends of mine and I) are considering to learn some Erlang. > > We would like to create a web base application. So far we've been > implementing various apps using Django/Python, but we want to try > something completely different. > > A quick search showed that there're quite a few frameworks available, > but being beginners in the area, we do not know what we should be > looking at. > > Any suggestions? :) REST? Webmachine http://webmachine.basho.com/ Webapp, AJAX, jQuery? Nitrogen http://nitrogenproject.com/ Build it yourself from the ground up? Mochiweb https://github.com/mochi/mochiweb Rails/django-esque? Chicago Boss http://www.chicagoboss.org/ Don't forget Yaws, too, which is web server that makes it easy to serve dynamic content http://yaws.hyber.org/ I can't really speak for the others (ErlyWeb, Misultin etc) as I haven't used them. Underneath you'll often find Mochiweb. I can't recommend Nitrogen highly enough, I found myself productive in it very quickly and the mailing list is excellent. That would be my first port of call for a new web app. Cheers Russell > > Kind Regards, > > -- > Misha > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From marc@REDACTED Mon Apr 18 14:56:55 2011 From: marc@REDACTED (Marc Worrell) Date: Mon, 18 Apr 2011 14:56:55 +0200 Subject: [erlang-questions] Web Frameworks: which to choose? In-Reply-To: References: Message-ID: <6FB20E36-FABB-4CCD-B171-E40CA4458D5F@worrell.nl> Missing from the list: - Zotonic : http://zotonic.com/ Framework and CMS, uses Django Templates and Nitrogen style events. - Marc On Apr 18, 2011, at 14:50 , erlang wrote: > From an old post: > > -----Mensaje original----- > De: erlang-questions@REDACTED [mailto:erlang-questions@REDACTED] En > nombre de zabrane Mikael > Enviado el: Jueves, 25 de Noviembre de 2010 09:50 a.m. > Para: Jesper Louis Andersen > CC: Dmitry Demeshchuk; Steve Vinoski; Gilberio Carmenates Garc?a; > erlang-questions@REDACTED > Asunto: Re: [erlang-questions] The most better Erlang web server! > > For Erlang Web development: > - MochiWeb (very stable, for production): http://code.google.com/p/mochiweb/ > - BeepBeep (based on MochiWeb): https://github.com/davebryson/beepbeep > - Nitrogen: http://nitrogenproject.com/ > - ElangWeb: http://www.erlang-web.org/ > - Misultin (speedy): http://code.google.com/p/misultin/ > - Chicago Boss : http://www.chicagoboss.org/ > - Cowboy (a newcomer, speedy): https://github.com/extend/cowboy > > > -- > Regards > Zabrane > > Le 18 avr. 2011 ? 14:43, G.S. a ?crit : > >> Hey Mikhail, >> >> I'd recommend Nitrogen, it's very solid. >> >> Regards, >> -Gene >> >> On Mon, Apr 18, 2011 at 5:37 AM, Mikhail Sobolev wrote: >> Hi, >> >> We (a few friends of mine and I) are considering to learn some Erlang. >> >> We would like to create a web base application. So far we've been >> implementing various apps using Django/Python, but we want to try >> something completely different. >> >> A quick search showed that there're quite a few frameworks available, >> but being beginners in the area, we do not know what we should be >> looking at. >> >> Any suggestions? :) >> >> Kind Regards, >> >> -- >> Misha >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From rapsey@REDACTED Mon Apr 18 15:04:37 2011 From: rapsey@REDACTED (Rapsey) Date: Mon, 18 Apr 2011 15:04:37 +0200 Subject: [erlang-questions] Web Frameworks: which to choose? In-Reply-To: <6FB20E36-FABB-4CCD-B171-E40CA4458D5F@worrell.nl> References: <6FB20E36-FABB-4CCD-B171-E40CA4458D5F@worrell.nl> Message-ID: And if you don't like any of them, just create your own. Mochiweb and erlydtl do all the heavy lifting anyway. With a bit of glue code you can have something that's really simple and easy to use. It's what I did and it worked out great. Sergej On Mon, Apr 18, 2011 at 2:56 PM, Marc Worrell wrote: > Missing from the list: > > - Zotonic : http://zotonic.com/ > > Framework and CMS, uses Django Templates and Nitrogen style events. > > > - Marc > > > On Apr 18, 2011, at 14:50 , erlang wrote: > > From an old post: > > -----Mensaje original----- > De: erlang-questions@REDACTED [mailto:erlang-questions@REDACTED] En > nombre de zabrane Mikael > Enviado el: Jueves, 25 de Noviembre de 2010 09:50 a.m. > Para: Jesper Louis Andersen > CC: Dmitry Demeshchuk; Steve Vinoski; Gilberio Carmenates Garc?a; > erlang-questions@REDACTED > Asunto: Re: [erlang-questions] The most better Erlang web server! > > For Erlang Web development: > - MochiWeb (very stable, for production): > http://code.google.com/p/mochiweb/ > - BeepBeep (based on MochiWeb): https://github.com/davebryson/beepbeep > - Nitrogen: http://nitrogenproject.com/ > - ElangWeb: http://www.erlang-web.org/ > - Misultin (speedy): http://code.google.com/p/misultin/ > - Chicago Boss : http://www.chicagoboss.org/ > - Cowboy (a newcomer, speedy): https://github.com/extend/cowboy > > > -- > Regards > Zabrane > > Le 18 avr. 2011 ? 14:43, G.S. a ?crit : > > Hey Mikhail, > > I'd recommend Nitrogen, it's very solid. > > Regards, > -Gene > > On Mon, Apr 18, 2011 at 5:37 AM, Mikhail Sobolev < > mikhail.sobolev@REDACTED> wrote: > >> Hi, >> >> We (a few friends of mine and I) are considering to learn some Erlang. >> >> We would like to create a web base application. So far we've been >> implementing various apps using Django/Python, but we want to try >> something completely different. >> >> A quick search showed that there're quite a few frameworks available, >> but being beginners in the area, we do not know what we should be >> looking at. >> >> Any suggestions? :) >> >> Kind Regards, >> >> -- >> Misha >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ericbmerritt@REDACTED Mon Apr 18 15:31:26 2011 From: ericbmerritt@REDACTED (Eric Merritt) Date: Mon, 18 Apr 2011 08:31:26 -0500 Subject: [erlang-questions] Typespecs export not working as intended? In-Reply-To: <4DAC1A99.4090206@dev-extend.eu> References: <4DAC1A99.4090206@dev-extend.eu> Message-ID: Lo?c, This is expected behaviour. You get the exact same behaviour with function calls. Basically, the remote types are not checked until evaluation time. In this case, that is when dialyzer or some other tool goes through and makes use of the specs. Erlang is a late binding language, both in function call and type references. Eric On Mon, Apr 18, 2011 at 6:03 AM, Lo?c Hoguin wrote: > Hello, > > I have ran into a weird issue while refactoring the type specs in a project. > > It seems types in a module can be used even if they are not exported > using export_type. Neither of the compiler or dialyzer are complaining > about it. > > For example, module a declares a type my_type(), module b uses it with > a:my_type(), no export_type in module, yet it still works. > > Is that normal? The documentation clearly states that types should be > exported. > > -- > Lo?c Hoguin > Dev:Extend > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > From essen@REDACTED Mon Apr 18 15:56:03 2011 From: essen@REDACTED (=?ISO-8859-1?Q?Lo=EFc_Hoguin?=) Date: Mon, 18 Apr 2011 15:56:03 +0200 Subject: [erlang-questions] Typespecs export not working as intended? In-Reply-To: References: <4DAC1A99.4090206@dev-extend.eu> Message-ID: <4DAC42F3.1000804@dev-extend.eu> Thanks. In this case I am running dialyzer on the source and it isn't complaining. Is there a difference between source and compiled code checking for dialyzer maybe? I'd really like to get dialyzer to complain some more. ;) On 04/18/2011 03:31 PM, Eric Merritt wrote: > Lo?c, > > This is expected behaviour. You get the exact same behaviour with > function calls. Basically, the remote types are not checked until > evaluation time. In this case, that is when dialyzer or some other > tool goes through and makes use of the specs. Erlang is a late binding > language, both in function call and type references. > > Eric > > On Mon, Apr 18, 2011 at 6:03 AM, Lo?c Hoguin wrote: >> Hello, >> >> I have ran into a weird issue while refactoring the type specs in a project. >> >> It seems types in a module can be used even if they are not exported >> using export_type. Neither of the compiler or dialyzer are complaining >> about it. >> >> For example, module a declares a type my_type(), module b uses it with >> a:my_type(), no export_type in module, yet it still works. >> >> Is that normal? The documentation clearly states that types should be >> exported. >> >> -- >> Lo?c Hoguin >> Dev:Extend >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> -- Lo?c Hoguin Dev:Extend From ericbmerritt@REDACTED Mon Apr 18 16:06:20 2011 From: ericbmerritt@REDACTED (Eric Merritt) Date: Mon, 18 Apr 2011 09:06:20 -0500 Subject: [erlang-questions] Typespecs export not working as intended? In-Reply-To: <4DAC42F3.1000804@dev-extend.eu> References: <4DAC1A99.4090206@dev-extend.eu> <4DAC42F3.1000804@dev-extend.eu> Message-ID: I am actually surprised that dialyzer isn't complaining. For this particular topic I don' think there should be a difference between compiled and source. However, my knowledge there is low. One of the dialyzer folks will have to chime in to give you a definitive answer. On Mon, Apr 18, 2011 at 8:56 AM, Lo?c Hoguin wrote: > Thanks. > > In this case I am running dialyzer on the source and it isn't > complaining. Is there a difference between source and compiled code > checking for dialyzer maybe? > > I'd really like to get dialyzer to complain some more. ;) > > On 04/18/2011 03:31 PM, Eric Merritt wrote: >> Lo?c, >> >> This is expected behaviour. You get the exact same behaviour with >> function calls. Basically, the remote types are not checked until >> evaluation time. In this case, that is when dialyzer or some other >> tool goes through and makes use of the specs. Erlang is a late binding >> language, both in function call and type references. >> >> Eric >> >> On Mon, Apr 18, 2011 at 6:03 AM, Lo?c Hoguin wrote: >>> Hello, >>> >>> I have ran into a weird issue while refactoring the type specs in a project. >>> >>> It seems types in a module can be used even if they are not exported >>> using export_type. Neither of the compiler or dialyzer are complaining >>> about it. >>> >>> For example, module a declares a type my_type(), module b uses it with >>> a:my_type(), no export_type in module, yet it still works. >>> >>> Is that normal? The documentation clearly states that types should be >>> exported. >>> >>> -- >>> Lo?c Hoguin >>> Dev:Extend >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://erlang.org/mailman/listinfo/erlang-questions >>> > > > -- > Lo?c Hoguin > Dev:Extend > From kenneth.lundin@REDACTED Mon Apr 18 16:15:09 2011 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Mon, 18 Apr 2011 16:15:09 +0200 Subject: [erlang-questions] asn1ct/asn1rt EXTERNAL 1990/1994 conversion information loss In-Reply-To: <20110417175454.GI9379@prithivi.gnumonks.org> References: <20110417175454.GI9379@prithivi.gnumonks.org> Message-ID: Hi Harald I agree with you that the current solution is not appropriate if you decode something encoded as EXTERNAL 1990 and then convert it to 1994 format. This conversion will loose info and you will not get back the same if you encode again. The documentation (users guide) does mention that the decoding always returns EXTERNAL 1994. I will look into this. /Kenneth Erlang/OTP, Ericsson On Sun, Apr 17, 2011 at 7:54 PM, Harald Welte wrote: > Hi! > > I'm working on a variety of (Free Software) projects related to mobile > communications (http://cgit.osmocom.org/). ?One of them is dealing with the GSM > MAP protocol (TS 09.02, TS 29.002) which is specified in ASN.1 > > I'm using the Erlang asn1ct/asn1rt to parse incoming MAP messages from the > worldwide SS7 backbone, filtering + patching some of the data contained in > it and re-transmit the MAP messages. ?It's like an application-level-gateway / > proxy that can modify some of the data. > > MAP itself uses TCAP (Q.773). ?TCAP messages have a dialogue and a component > portion. ?The dialogue portion is specified as an EXTERNAL type: > > DialoguePortion ::= [APPLICATION 11] EXPLICIT EXTERNAL > > Note: The MAP sender are (normally?) using the 1990 representation of EXTERNAL, > not the 1994 version. > > Erlangs asn1ct-generated dec_EXTERNAL code first internally generates along those > lines: > > #'EXTERNAL'{ > ? ? ? ? ? ?'direct-reference' = {0,0,17,773,1,1,1}, > ? ? ? ? ? ?'indirect-reference' = asn1_NOVALUE, > ? ? ? ? ? ?'data-value-descriptor' = asn1_NOVALUE, > ? ? ? ? ? ?encoding = > ? ? ? ? ? ? ? ?{'single-ASN1-type', > ? ? ? ? ? ? ? ? ? ?[96,15,128,2,7,128,161,9,6,7,4,0,0,1,0,1,3]}} > > However, the asn1ct generated code automatically converts this #'EXTERNAL'{} > record into a tuple of the following structure (using > transform_to_EXTERNAL1994/1): > > {'EXTERNAL', {syntax,{0,0,17,773,1,1,1}}, > ? ? ? ? ? ? asn1_NOVALUE, > ? ? ? ? ? ? [96,15,128,2,7,128,161,9,6,7,4,0,0,1,0,1,3]} > > The problem is, when you pass this tuple into the asn1ct-generated encoder, > the 'single-ASN1-type' information has been lost, and it will be replaced with > 'octet-aligned'. > > The result is that instead of {tag,'CONTEXT',0,'EXPLICIT',32} we now use > {tag,'CONTEXT',1,'IMPLICIT',0} for encoding the data. ?This is not valid within > the scope of MAP, and both the wireshark MAP dissector as well as all MAP > implementations I've seen reject or ignore the resulting message. > > The problem fundamentally can be summarized as: > * EXTERNAL can contain inner data in either 'Single-ASN1-type' or > ?'octet-aligned' > * the OTP asn1ct (at least in ber_bin mode) looses this information and > ?does not pass it back to the caller when decoding > * if the resulting data is passed through the encoder, the encoded data > ?semantically differs from the original undecoded BER data. > > I think this is probably not the intended behaviour. ?It would be weird if > decoding and re-encoding the same unmodified data leads to different BER tags > in the tree. > > What is wrong in passing the 1990 or 1994 EXTERNAL types from the decoder into > the user program? ?Why should the user not know which of the two formats was > being used? ?I believe at the very least, this automatic conversion should be > something that can be configured as a compiler option. > > Any comments/ideas/suggestions? > > Regards, > ? ? ? ?Harald > -- > - Harald Welte ? ? ? ? ? http://laforge.gnumonks.org/ > ============================================================================ > "Privacy in residential applications is a desirable marketing option." > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?(ETSI EN 300 175-7 Ch. A6) > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > From gregory.haskins@REDACTED Mon Apr 18 17:29:40 2011 From: gregory.haskins@REDACTED (Gregory Haskins) Date: Mon, 18 Apr 2011 11:29:40 -0400 Subject: [erlang-questions] Confusing about gproc with global properties In-Reply-To: <98693174-AC75-40D3-A501-D91425F030B6@erlang-solutions.com> References: <4DA88D70.1050501@gmail.com> <4DA8E850.1070407@gmail.com> <98693174-AC75-40D3-A501-D91425F030B6@erlang-solutions.com> Message-ID: <4DAC58E4.9050109@gmail.com> On 4/16/11 3:39 PM, Ulf Wiger wrote: > > Thinking about it, I'd like to change gproc:select/1 to also include global objects, in other words: > > select(Pat) -> select({all, all}, Pat). > > This is a backwards incompatible change, but I am guessing that not too many people use the global gproc functionality yet, so this should be the time to do it. > > Any objections? Sounds good to me (of course, I am biased given I do not have any legacy gproc code ;) FYI: While investigating this problem I noticed there is an inconsistency in the QLC interface. That is: P <- gproc:table(props) returns both [g,l] matches, whereas {{p, '_', Key}, Pid, Val} <- gproc:table(props) OR {{p, Scope, Key}, Pid, Val} <- gproc:table(props) return only local scope matches (as I would expect given my new understanding of "props =:= {local, props}" in the current code base). I would expect all three forms to return a consistent set ([l] based in this case, [g,l] after your proposed change). FWIW: The latter two invoke https://github.com/esl/gproc/blob/v0.1.2/src/gproc.erl#L1150, whereas the first form takes a different path due to the way the QLC code builds the matchhead as an is_var(). I'll take a crack at fixing it and send you a patch, unless this is considered FAD? Kind Regards, -Greg -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 267 bytes Desc: OpenPGP digital signature URL: From t.greenwoodgeer@REDACTED Mon Apr 18 17:38:37 2011 From: t.greenwoodgeer@REDACTED (Todd) Date: Mon, 18 Apr 2011 08:38:37 -0700 Subject: [erlang-questions] Web Frameworks: which to choose? In-Reply-To: References: Message-ID: <4DAC5AFD.4040709@gmail.com> I've had problems creating pages w/ the latest nitrogen (2.0.4). However nitrogen 2.0.2 has worked fine for me. sync the latest nitrogen from github, and then do a $ git reset --hard v2.0.2 -t On 4/18/11 5:43 AM, G.S. wrote: > Hey Mikhail, > > I'd recommend Nitrogen, it's very solid. > > Regards, > -Gene > > On Mon, Apr 18, 2011 at 5:37 AM, Mikhail Sobolev > > wrote: > > Hi, > > We (a few friends of mine and I) are considering to learn some Erlang. > > We would like to create a web base application. So far we've been > implementing various apps using Django/Python, but we want to try > something completely different. > > A quick search showed that there're quite a few frameworks available, > but being beginners in the area, we do not know what we should be > looking at. > > Any suggestions? :) > > Kind Regards, > > -- > Misha > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From kennethstone@REDACTED Mon Apr 18 17:59:38 2011 From: kennethstone@REDACTED (Kenny Stone) Date: Mon, 18 Apr 2011 10:59:38 -0500 Subject: [erlang-questions] Web Frameworks: which to choose? In-Reply-To: <4DAC5AFD.4040709@gmail.com> References: <4DAC5AFD.4040709@gmail.com> Message-ID: Zotonic bills itself as a CMS, which has always seemed pretty different from a web framework to me. Kenny -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf.wiger@REDACTED Mon Apr 18 18:01:34 2011 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Mon, 18 Apr 2011 18:01:34 +0200 Subject: [erlang-questions] Confusing about gproc with global properties In-Reply-To: <4DAC58E4.9050109@gmail.com> References: <4DA88D70.1050501@gmail.com> <4DA8E850.1070407@gmail.com> <98693174-AC75-40D3-A501-D91425F030B6@erlang-solutions.com> <4DAC58E4.9050109@gmail.com> Message-ID: Hi Greg, Thanks for noticing. I was about to push a new version anyway, so I fixed that issue as well. Try the latest version: https://github.com/esl/gproc/tree/v0.2.0 (A slightly bigger version update, since the change in default is BW-incompatible). BR, Ulf W On 18 Apr 2011, at 17:29, Gregory Haskins wrote: > On 4/16/11 3:39 PM, Ulf Wiger wrote: >> >> Thinking about it, I'd like to change gproc:select/1 to also include global objects, in other words: >> >> select(Pat) -> select({all, all}, Pat). >> >> This is a backwards incompatible change, but I am guessing that not too many people use the global gproc functionality yet, so this should be the time to do it. >> >> Any objections? > > Sounds good to me (of course, I am biased given I do not have any legacy > gproc code ;) > > FYI: While investigating this problem I noticed there is an > inconsistency in the QLC interface. That is: > > P <- gproc:table(props) returns both [g,l] matches, whereas > > {{p, '_', Key}, Pid, Val} <- gproc:table(props) > > OR > > {{p, Scope, Key}, Pid, Val} <- gproc:table(props) > > return only local scope matches (as I would expect given my new > understanding of "props =:= {local, props}" in the current code base). > I would expect all three forms to return a consistent set ([l] based in > this case, [g,l] after your proposed change). > > FWIW: The latter two invoke > https://github.com/esl/gproc/blob/v0.1.2/src/gproc.erl#L1150, whereas > the first form takes a different path due to the way the QLC code builds > the matchhead as an is_var(). > > I'll take a crack at fixing it and send you a patch, unless this is > considered FAD? > > Kind Regards, > -Greg > Ulf Wiger, CTO, Erlang Solutions, Ltd. http://erlang-solutions.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From gregory.haskins@REDACTED Mon Apr 18 18:17:24 2011 From: gregory.haskins@REDACTED (Gregory Haskins) Date: Mon, 18 Apr 2011 12:17:24 -0400 Subject: [erlang-questions] Confusing about gproc with global properties In-Reply-To: References: <4DA88D70.1050501@gmail.com> <4DA8E850.1070407@gmail.com> <98693174-AC75-40D3-A501-D91425F030B6@erlang-solutions.com> <4DAC58E4.9050109@gmail.com> Message-ID: <4DAC6414.3060802@gmail.com> On 4/18/11 12:01 PM, Ulf Wiger wrote: > Hi Greg, > > Thanks for noticing. I was about to push a new version anyway, so I > fixed that issue as well. Cool, thanks! > > Try the latest version: https://github.com/esl/gproc/tree/v0.2.0 > I confirmed that it does appear to now use [g,l] by default. Note I am also seeing this issue: (gproctest@REDACTED)3> gproc:reg({p, g, foo}, bar). true (gproctest@REDACTED)4> gproc:reg({p, l, foo}, bar). true (gproctest@REDACTED)5> qlc:e(qlc:q([P || P <- gproc:table(props)])). ** exception error: no function clause matching gproc:type({'_',p}) in function gproc:pattern/2 in call from gproc:select/3 in call from gproc:'-table/2-fun-2-'/3 in call from qlc:collect/1 in call from qlc:eval/2 (gproctest@REDACTED)6> qlc:e(qlc:q([P || P <- gproc:table({all, props})])). ** exception error: no function clause matching gproc:type({'_',p}) in function gproc:pattern/2 in call from gproc:select/3 in call from gproc:'-table/2-fun-2-'/3 in call from qlc:collect/1 in call from qlc:eval/2 Could be "pilot error", too ;) Am I doing something unsupported? -Greg -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 267 bytes Desc: OpenPGP digital signature URL: From ulf.wiger@REDACTED Mon Apr 18 18:56:24 2011 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Mon, 18 Apr 2011 18:56:24 +0200 Subject: [erlang-questions] Confusing about gproc with global properties In-Reply-To: <4DAC6414.3060802@gmail.com> References: <4DA88D70.1050501@gmail.com> <4DA8E850.1070407@gmail.com> <98693174-AC75-40D3-A501-D91425F030B6@erlang-solutions.com> <4DAC58E4.9050109@gmail.com> <4DAC6414.3060802@gmail.com> Message-ID: <824BD29E-8F1C-4084-B777-E45F3EC64D2E@erlang-solutions.com> Hmpf! Thanks. Corrected, and some eunit tests added for good measure. :) v0.2.1 pushed. BR, Ulf On 18 Apr 2011, at 18:17, Gregory Haskins wrote: > On 4/18/11 12:01 PM, Ulf Wiger wrote: >> Hi Greg, >> >> Thanks for noticing. I was about to push a new version anyway, so I >> fixed that issue as well. > > Cool, thanks! > >> >> Try the latest version: https://github.com/esl/gproc/tree/v0.2.0 >> > > I confirmed that it does appear to now use [g,l] by default. Note I am > also seeing this issue: > > (gproctest@REDACTED)3> gproc:reg({p, g, foo}, bar). > true > (gproctest@REDACTED)4> gproc:reg({p, l, foo}, bar). > true > (gproctest@REDACTED)5> qlc:e(qlc:q([P || P <- gproc:table(props)])). > ** exception error: no function clause matching gproc:type({'_',p}) > in function gproc:pattern/2 > in call from gproc:select/3 > in call from gproc:'-table/2-fun-2-'/3 > in call from qlc:collect/1 > in call from qlc:eval/2 > (gproctest@REDACTED)6> qlc:e(qlc:q([P || P <- gproc:table({all, props})])). > ** exception error: no function clause matching gproc:type({'_',p}) > in function gproc:pattern/2 > in call from gproc:select/3 > in call from gproc:'-table/2-fun-2-'/3 > in call from qlc:collect/1 > in call from qlc:eval/2 > > Could be "pilot error", too ;) Am I doing something unsupported? > > -Greg > Ulf Wiger, CTO, Erlang Solutions, Ltd. http://erlang-solutions.com From essen@REDACTED Mon Apr 18 19:09:48 2011 From: essen@REDACTED (=?ISO-8859-1?Q?Lo=EFc_Hoguin?=) Date: Mon, 18 Apr 2011 19:09:48 +0200 Subject: [erlang-questions] Web Frameworks: which to choose? In-Reply-To: References: Message-ID: <4DAC705C.9010605@dev-extend.eu> On 04/18/2011 02:50 PM, erlang wrote: > For Erlang Web development: > - MochiWeb (very stable, for production): http://code.google.com/p/mochiweb/ > - BeepBeep (based on MochiWeb): https://github.com/davebryson/beepbeep > - Nitrogen: http://nitrogenproject.com/ > - ElangWeb: http://www.erlang-web.org/ > - Misultin (speedy): http://code.google.com/p/misultin/ > - Chicago Boss : http://www.chicagoboss.org/ > - Cowboy (a newcomer, speedy): https://github.com/extend/cowboy To be clearer: mochiweb, misultin and cowboy are just servers and provide no framework (although cowboy will provide a REST interface later). Others are web frameworks and use an existing HTTP server, most often mochiweb but sometimes you can choose which underlying server you want to use. Nitrogen is probably the most used in the Erlang world. Yaws is part HTTP server part framework, going so far as to provide embedding erlang in html files a la php, optionally of course. There's been work on a bridge interface to seamlessly switch HTTP servers. Not sure which project is most up to date on that. -- Lo?c Hoguin Dev:Extend From steven.charles.davis@REDACTED Mon Apr 18 19:09:57 2011 From: steven.charles.davis@REDACTED (Steve Davis) Date: Mon, 18 Apr 2011 12:09:57 -0500 Subject: [erlang-questions] Runtime checking for types Message-ID: <4DAC7065.1070304@gmail.com> Interesting response. Actually, I find myself in disagreement here. Let me explain further. There's two precepts at the heart of my personal Erlang journey and experience that are somewhat in opposition to your statements (and appear to me to be in direct opposition!): 1) Let it crash! 2) Checks are only required at the boundary of the system. For "type safety" I find pattern matching and guards quite adequate, even as a codebase grows. Also, the BEAM VM seems pretty good at optimizing such dynamic checks. Of the other approaches in Erlang that attempt to enhance type checking, the only one that appeared _to me_ to have any true elegance was UBF Contracts. I rather suspect that the lack of further static type checking in Erlang wasn't because the creators didn't have time, but rather that, given the precepts above, it wasn't considered *useful* or necessary. ...that's my take on things of course, and I'd be interested in how far that is true. Perhaps Joe or Robert may weigh in with a comment on that. Also, I'm wondering whether your (amazing!) work with erjang and the JVM hasn't influenced your response, here. Especially with regard to the apparent "richness" and efficiency? Contrarily, I have found dynamic typing a blessed relief from the verbosity that occludes the value of languages with greater levels of static type-checking. With the greatest respect, if Erlang (+OTP) had taken the path you suggest, I suspect I would find it far less attractive as a platform. Best regards, /s On 4/18/2011 5:58 AM, Jesper Louis Andersen wrote: > On Mon, Apr 18, 2011 at 01:07, Steve Davis > wrote: >> IMHO, a focus on type-safety can lose you a truly *massive* amount of >> time that could be spent doing something useful. > > There are many intricate dependencies which you can't simply resolve > in a few moments of thought on that one. The point of type safety is > to trade a short-term added specification for a long-term benefit. You > write down a precise expression of intent with the type, and being > precise takes more time. But it is extremely helpful over the course > of larger programs, provides (checkable!) documentation, yields more > effective execution trivially and so on. > > The initial ignorance of static types in Erlang is understandable. > Other things were more important to get right and history was such > that we did not understand certain parts of the intermingling of types > with distribution etc.. But today, I feel there is no excuse. Should I > design a modern Erlang, I would start with a statically typed world in > which communicaiton use polymorphic variants. Essentially: An internal > process is statically typed, but communicate in a dynamically typed > setting. Thus, I have lost *nothing* compared to Erlang, but I can > compile processes to be an order of magnitude faster, trivially. From > there, I can probably define a channel-primitive between processes > with static type constraint such that processes can intercommunicate > in a type-safe way. Perhaps even with a shared-persistent-heap > semantics. > > Remember, dynamic typing is a straitjacket, in which you cannot fully > express yourself, whereas static typing give you a rich language for > doing so. > > From rtsome@REDACTED Mon Apr 18 19:11:08 2011 From: rtsome@REDACTED (rtsome) Date: Mon, 18 Apr 2011 23:11:08 +0600 Subject: [erlang-questions] https request certificate validation Message-ID: Hi. So I want request to fail if server certificate is self-signed. I tried different options but no luck. -module(tst). -compile(export_all). get(Url, Opt)-> case http:request(get, {Url, []}, Opt,[]) of {ok, {H,_Headers,_Response}} -> {ok , H}; O -> O end. g()-> inets:start(), ssl:start(), http:set_options([{max_ sessions, 0} ,{max_keep_alive_length, 0} % ,{verbose, verbose} ]), Opts = [[{ssl,[{verify, verify_peer}]}] ,[{ssl,[{verify, verify_peer}]}] ,[{ssl,[{verify, 2}]}] ,[{ssl,[{verify, 1}]}] ,[{ssl,[{verify, 0}]}] ,[{ssl,[{verify, verify_peer}]}] ], io:format("~p~n",[[get("https://localhost", O) || O <- Opts]]), io:format("~p~n",[[get("https://mail.google.com/mail/ ", O) || O <- Opts]]), init:stop(). Typical output: [{error,{connect_failed,eoptions}}, {error,{connect_failed,eoptions}}, {ok,{"HTTP/1.1",200,"OK"}}, {ok,{"HTTP/1.1",200,"OK"}}, {ok,{"HTTP/1.1",200,"OK"}}, {error,{connect_failed,eoptions}}] [{error,{connect_failed,eoptions}}, {error,{connect_failed,eoptions}}, {ok,{"HTTP/1.1",200,"OK"}}, {ok,{"HTTP/1.1",200,"OK"}}, {ok,{"HTTP/1.1",200,"OK"}}, {ok,{"HTTP/1.1",200,"OK"}}] Note the 'verify_peer' variant. It fails unregularly independ?ntly of certificate validity. Erlang versions under consideration: R13B03@REDACTED ubuntu R14B02@REDACTED -------------- next part -------------- An HTML attachment was scrubbed... URL: From banibrata.dutta@REDACTED Mon Apr 18 19:25:55 2011 From: banibrata.dutta@REDACTED (Banibrata Dutta) Date: Mon, 18 Apr 2011 22:55:55 +0530 Subject: [erlang-questions] Web Frameworks: which to choose? In-Reply-To: <4DAC705C.9010605@dev-extend.eu> References: <4DAC705C.9010605@dev-extend.eu> Message-ID: Here's a well written comparison of some of the frameworks, which provides a good starting point -- http://www.chicagoboss.org/projects/chicagoboss/wiki/Comparison_of_Erlang_Web_Frameworks However, since Zotonic is in fairly active development, and so is Chicagoboss, and I guess Nitrogen as well, not sure how current the comparisons are. Best is to go by the above comparison, and then confirm in the respective community list, if some of the desired features are indeed not there in the latest repos. On Mon, Apr 18, 2011 at 10:39 PM, Lo?c Hoguin wrote: > On 04/18/2011 02:50 PM, erlang wrote: > > For Erlang Web development: > > - MochiWeb (very stable, for production): > http://code.google.com/p/mochiweb/ > > - BeepBeep (based on MochiWeb): https://github.com/davebryson/beepbeep > > - Nitrogen: http://nitrogenproject.com/ > > - ElangWeb: http://www.erlang-web.org/ > > - Misultin (speedy): http://code.google.com/p/misultin/ > > - Chicago Boss : http://www.chicagoboss.org/ > > - Cowboy (a newcomer, speedy): https://github.com/extend/cowboy > > To be clearer: mochiweb, misultin and cowboy are just servers and > provide no framework (although cowboy will provide a REST interface later). > > Others are web frameworks and use an existing HTTP server, most often > mochiweb but sometimes you can choose which underlying server you want > to use. Nitrogen is probably the most used in the Erlang world. > > Yaws is part HTTP server part framework, going so far as to provide > embedding erlang in html files a la php, optionally of course. > > There's been work on a bridge interface to seamlessly switch HTTP > servers. Not sure which project is most up to date on that. > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From zabrane3@REDACTED Mon Apr 18 19:43:52 2011 From: zabrane3@REDACTED (Zabrane Mickael) Date: Mon, 18 Apr 2011 19:43:52 +0200 Subject: [erlang-questions] Yaws's "sendfile" linked-in driver : "stealing control of fd" error In-Reply-To: <4DAC0C2A.5060705@erix.ericsson.se> References: <4DAC0C2A.5060705@erix.ericsson.se> Message-ID: Hi guys, I can confirm that using "sendfile:compat_send/4" worked perfectly in my case without any error message. Culprit found ;-) Regards, Zabrane Le 18 avr. 2011 ? 12:02, Sverker Eriksson a ?crit : > On Sun, Apr 17, 2011 at 5:23 PM, zabrane Mikael wrote: >>> Hi OTP team & Steve, >>> >>> I'm using the "sendfile" (thanks to Steve Vinoski) linked-in driver >>> borrowed from "Yaws" >>> in one of my pet project. >>> >>> Today, I noticed this strange error: >>> =ERROR REPORT==== 17-Apr-2011::20:49:18 === >>> driver_select(0x0000000000000c31, 24, ERL_DRV_WRITE, 1) by >>> sendfile_drv driver #Port<0.3121> stealing control of fd=24 from >>> output driver tcp_inet #Port<0.10029> >>> >> >> > The error message kind of says it all: > The driver "sendfile_drv" is calling driver_select() to subscribe for output events on file descriptor 24. BUT, driver "tcp_inet" is already subscribing to output events on that very same file descriptor 24. Driver "sendfile_drv" thus steals the file descriptor from "tcp_inet" as only one port at a time can subscribe to a particular file descriptor event. > > I think you should consider this as an error. Drivers are not supposed to act like this. The normal cause of this is a driver that forgets to deselect a file descriptor before closing it. Despite that I would regard sendfile_drv as the primary suspect here as the new kid on the block. > > /Sverker, Erlang/OTP > From marc@REDACTED Mon Apr 18 19:49:48 2011 From: marc@REDACTED (Marc Worrell) Date: Mon, 18 Apr 2011 19:49:48 +0200 Subject: [erlang-questions] Web Frameworks: which to choose? In-Reply-To: References: <4DAC5AFD.4040709@gmail.com> Message-ID: We call Zotonic a CMS because you can have a full fledged with 'only' template work. We call it a framework because it is easy to extend, overrule and change behaviour, templates etc. At the start we just wanted a framework, but as almost everybody needs news, agenda, homepage and an editorial interface we ended up with a framework that includes a CMS to handle such things. You can still skip most of it and just use the framework parts when you don't like the word 'CMS'. - Marc On Apr 18, 2011, at 17:59 , Kenny Stone wrote: > Zotonic bills itself as a CMS, which has always seemed pretty different from a web framework to me. > > Kenny > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From kennethstone@REDACTED Mon Apr 18 19:53:06 2011 From: kennethstone@REDACTED (Kenny Stone) Date: Mon, 18 Apr 2011 12:53:06 -0500 Subject: [erlang-questions] Web Frameworks: which to choose? In-Reply-To: References: <4DAC5AFD.4040709@gmail.com> Message-ID: Why not fold in the enhancements from zotonic the framework into nitrogen and keep zotonic just the CMS part? I'm not criticizing, just curious :) Kenny On Mon, Apr 18, 2011 at 12:49 PM, Marc Worrell wrote: > We call Zotonic a CMS because you can have a full fledged with 'only' > template work. > We call it a framework because it is easy to extend, overrule and change > behaviour, templates etc. > > At the start we just wanted a framework, but as almost everybody needs > news, agenda, homepage and an editorial interface we ended up with a > framework that includes a CMS to handle such things. > > You can still skip most of it and just use the framework parts when you > don't like the word 'CMS'. > > - Marc > > > On Apr 18, 2011, at 17:59 , Kenny Stone wrote: > > Zotonic bills itself as a CMS, which has always seemed pretty different > from a web framework to me. > > Kenny > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jilani@REDACTED Mon Apr 18 20:06:57 2011 From: jilani@REDACTED (Jilani Khaldi) Date: Mon, 18 Apr 2011 20:06:57 +0200 Subject: [erlang-questions] Web Frameworks: which to choose? In-Reply-To: <4DAC705C.9010605@dev-extend.eu> References: <4DAC705C.9010605@dev-extend.eu> Message-ID: <4DAC7DC1.1050704@cheapnet.it> > Yaws is part HTTP server part framework, going so far as to provide > embedding erlang in html files a la php, optionally of course. In fact I find Yaws very flexible, fast and easy to use as you can use plain Erlang code inside HTML page. You have everything you need inside the web server. -- Jilani KHALDI --------------------- *** Architecura Vindex http://www.vindexa.org From sigmastar@REDACTED Mon Apr 18 20:16:19 2011 From: sigmastar@REDACTED (Jesse Gumm) Date: Mon, 18 Apr 2011 13:16:19 -0500 Subject: [erlang-questions] Web Frameworks: which to choose? In-Reply-To: References: <4DAC5AFD.4040709@gmail.com> Message-ID: Here's my vote for Nitrogen. I've been working with Nitrogen for close to two years now, and I quite enjoy it. And Webmachine support was recently added to Nitrogen, so as far as I know, you can indeed add some REST-type stuff there, but I haven't ever tinkered with Webmachine so I can't speak at all about it. I gave a talk a few months ago about Nitrogen. Here are the slides (they should work for Nitrogen 2.0.2, but things changed in 2.0.4): https://docs.google.com/present/view?id=dc37wnrq_7hqpqc6gv -Jesse On Mon, Apr 18, 2011 at 12:53 PM, Kenny Stone wrote: > Why not fold in the enhancements from zotonic the framework into nitrogen > and keep zotonic just the CMS part? ?I'm not?criticizing, just curious :) > Kenny > > On Mon, Apr 18, 2011 at 12:49 PM, Marc Worrell wrote: >> >> We call Zotonic a CMS because you can have a full fledged with 'only' >> template work. >> We call it a framework because it is easy to extend, overrule and change >> behaviour, templates etc. >> At the start we just wanted a framework, but as almost everybody needs >> news, agenda, homepage and an editorial interface we ended up with a >> framework that includes a CMS to handle such things. >> You can still skip most of it and just use the framework parts when you >> don't like the word 'CMS'. >> - Marc >> >> On Apr 18, 2011, at 17:59 , Kenny Stone wrote: >> >> Zotonic bills itself as a CMS, which has always seemed pretty different >> from a web framework to me. >> Kenny >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -- Jesse Gumm Sigma Star Systems 414.940.4866 gumm@REDACTED http://www.sigma-star.com From marc@REDACTED Mon Apr 18 20:32:28 2011 From: marc@REDACTED (Marc Worrell) Date: Mon, 18 Apr 2011 20:32:28 +0200 Subject: [erlang-questions] Web Frameworks: which to choose? In-Reply-To: References: <4DAC5AFD.4040709@gmail.com> Message-ID: <7A50AC3D-B2C1-4B01-9B32-9210C223613C@worrell.nl> On Apr 18, 2011, at 20:16 , Jesse Gumm wrote: > Here's my vote for Nitrogen. I've been working with Nitrogen for > close to two years now, and I quite enjoy it. > > And Webmachine support was recently added to Nitrogen, so as far as I > know, you can indeed add some REST-type stuff there, but I haven't > ever tinkered with Webmachine so I can't speak at all about it. Didn't mention it, but Zotonic is also based on Webmachine. Webmachine is the best HTTP protocol handler ever. > I gave a talk a few months ago about Nitrogen. Here are the slides > (they should work for Nitrogen 2.0.2, but things changed in 2.0.4): > https://docs.google.com/present/view?id=dc37wnrq_7hqpqc6gv > > -Jesse > > On Mon, Apr 18, 2011 at 12:53 PM, Kenny Stone wrote: >> Why not fold in the enhancements from zotonic the framework into nitrogen >> and keep zotonic just the CMS part? I'm not criticizing, just curious :) >> Kenny Not doable, Zotonic drifted too far from Nitrogen. For starters we removed the use of the process dictionary and then added templates (enhanced ErlyDTL), modules, WebSockets, e-mail (gen_smtp), database (epgsql), xmpp pubsub, template selectors, virtual hosts, etc. etc. And everything HTTP is built on top of Webmachine. The people working with Zotonic are not only programmers but also frontenders. There are some frontenders building websites without even touching the Erlang code. See http://timbenniks.nl/ who made multiple Zotonic sites. An example of a website where programming was involved is http://www.maxclass.com/ In Zotonic all Nitrogen actions, validators, postbacks etc can be specified in the template by the template builder. There is even a signal/slot module (mod_signal by Maas-Maarten Zeeman) to let web pages send messages to each other without programming. But... it is a choice. Do you want to make your templates in Erlang? Then use Nitrogen. Do you want a frontender to make your templates? Then you need something like Zotonic or another framework with a template engine. - Marc From marc@REDACTED Mon Apr 18 20:48:28 2011 From: marc@REDACTED (Marc Worrell) Date: Mon, 18 Apr 2011 20:48:28 +0200 Subject: [erlang-questions] How do code change system messages work? Message-ID: Hello, For Zotonic I would like to know when a module is reloaded, so that I can re-check its dependencies. For this I need to receive the code change system message for another module than my other (OTP based) module. How can I receive those messages? Best, Marc From gregory.haskins@REDACTED Mon Apr 18 21:18:09 2011 From: gregory.haskins@REDACTED (Gregory Haskins) Date: Mon, 18 Apr 2011 15:18:09 -0400 Subject: [erlang-questions] Confusing about gproc with global properties In-Reply-To: <824BD29E-8F1C-4084-B777-E45F3EC64D2E@erlang-solutions.com> References: <4DA88D70.1050501@gmail.com> <4DA8E850.1070407@gmail.com> <98693174-AC75-40D3-A501-D91425F030B6@erlang-solutions.com> <4DAC58E4.9050109@gmail.com> <4DAC6414.3060802@gmail.com> <824BD29E-8F1C-4084-B777-E45F3EC64D2E@erlang-solutions.com> Message-ID: <4DAC8E71.8090101@gmail.com> On 4/18/11 12:56 PM, Ulf Wiger wrote: > > Hmpf! Thanks. Corrected, and some eunit tests added for good measure. :) > > v0.2.1 pushed. (gproctest@REDACTED)3> gproc:reg({p, g, foo}, bar). true (gproctest@REDACTED)4> gproc:reg({p, l, foo}, bar). true (gproctest@REDACTED)5> (gproctest@REDACTED)5> qlc:e(qlc:q([P || P <- gproc:table(props)])). [{{p,g,foo},<0.38.0>,bar},{{p,l,foo},<0.38.0>,bar}] Fix confirmed ;) Thanks Ulf, -Greg -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 267 bytes Desc: OpenPGP digital signature URL: From spawn.think@REDACTED Mon Apr 18 21:23:12 2011 From: spawn.think@REDACTED (Ahmed Omar) Date: Mon, 18 Apr 2011 21:23:12 +0200 Subject: [erlang-questions] How do code change system messages work? In-Reply-To: References: Message-ID: You might wanna take a look at sys module http://www.erlang.org/doc/man/sys.html On Mon, Apr 18, 2011 at 8:48 PM, Marc Worrell wrote: > Hello, > > For Zotonic I would like to know when a module is reloaded, so that I can > re-check its dependencies. > > For this I need to receive the code change system message for another > module than my other (OTP based) module. > > How can I receive those messages? > > Best, Marc > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -- Best Regards, - Ahmed Omar http://nl.linkedin.com/in/adiaa Follow me on twitter @spawn_think -------------- next part -------------- An HTML attachment was scrubbed... URL: From garazdawi@REDACTED Mon Apr 18 21:28:28 2011 From: garazdawi@REDACTED (Lukas Larsson) Date: Mon, 18 Apr 2011 21:28:28 +0200 Subject: [erlang-questions] How do code change system messages work? In-Reply-To: References: Message-ID: Those messages will be sent to OTP processes when a release upgrade is done using the sasl release handling mechanisms. On Apr 18, 2011 8:48 PM, "Marc Worrell" wrote: > Hello, > > For Zotonic I would like to know when a module is reloaded, so that I can re-check its dependencies. > > For this I need to receive the code change system message for another module than my other (OTP based) module. > > How can I receive those messages? > > Best, Marc > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From erlang@REDACTED Mon Apr 18 21:30:32 2011 From: erlang@REDACTED (Joe Armstrong) Date: Mon, 18 Apr 2011 21:30:32 +0200 Subject: [erlang-questions] Runtime checking for types In-Reply-To: <4DAC7065.1070304@gmail.com> References: <4DAC7065.1070304@gmail.com> Message-ID: On Mon, Apr 18, 2011 at 7:09 PM, Steve Davis wrote: > Interesting response. Actually, I find myself in disagreement here. Let > me explain further. > > There's two precepts at the heart of my personal Erlang journey and > experience that are somewhat in opposition to your statements (and > appear to me to be in direct opposition!): > > 1) Let it crash! > 2) Checks are only required at the boundary of the system. > > For "type safety" I find pattern matching and guards quite adequate, > even as a codebase grows. Also, the BEAM VM seems pretty good at > optimizing such dynamic checks. > > Of the other approaches in Erlang that attempt to enhance type checking, > the only one that appeared _to me_ to have any true elegance was UBF > Contracts. > > I rather suspect that the lack of further static type checking in Erlang > wasn't because the creators didn't have time, but rather that, given the > precepts above, it wasn't considered *useful* or necessary. ...that's my > take on things of course, and I'd be interested in how far that is true. > Perhaps Joe or Robert may weigh in with a comment on that. > Erlang evolved from Prolog. The first Erlang was just a meta-interpreter written in Prolog to add processes and message passing to Prolog. Prolog had dynamic types therefore Erlang had dynamic types - no thinking was involved. Nothing to do with lack of time. As the language evolved we were more interested in things like error recovery than static type checking. The stuff that we really thought long and hard about was not type checking but error checking. The link mechanism, for example, is something that I think is unique to Erlang. Processes communicate errors "out of band" this means you can write your regular inter-process message passing using regular RPCs and the RPC like code does not need to check errors caused by out-of-band behavior (exceptions). Exceptions propagate over links and are handled elsewhere. The exception mechanism works just like a traditional try-catch where exceptions are thrown up the call stack to an enclosing catch, but if there is no enclosing catch the exception propagates out of the processes and is sent as a single to any linked processes. The particuar combinations of links/spawn_link/process_flag(trap_exit, ...) etc were arrived at after much though, discussion and experimentation. These are the sort of questions we were worrying about - not type systems. Why these problems? Easy - because we wanted to build real-world fault tolerant systems. Getting this right was essential. Systems we built using these techniques have been operational for many years now, switching millions to billions of users sessions/day. When people say "language X has Erlang like semantics" they virtually always mean "language X has processes, mailboxes and message passing" and non of the fun stuff (links, exit signals, linked process groups). Erlang is pretty good at what it was designed to be good at - namely building fault tolerant systems. It was not designed with static type checking in mind. /Joe > > Also, I'm wondering whether your (amazing!) work with erjang and the JVM > hasn't influenced your response, here. Especially with regard to the > apparent "richness" and efficiency? Contrarily, I have found dynamic > typing a blessed relief from the verbosity that occludes the value of > languages with greater levels of static type-checking. > > With the greatest respect, if Erlang (+OTP) had taken the path you > suggest, I suspect I would find it far less attractive as a platform. > > Best regards, > /s > > > On 4/18/2011 5:58 AM, Jesper Louis Andersen wrote: > >> On Mon, Apr 18, 2011 at 01:07, Steve Davis >> wrote: >> >>> IMHO, a focus on type-safety can lose you a truly *massive* amount of >>> time that could be spent doing something useful. >>> >> >> There are many intricate dependencies which you can't simply resolve >> in a few moments of thought on that one. The point of type safety is >> to trade a short-term added specification for a long-term benefit. You >> write down a precise expression of intent with the type, and being >> precise takes more time. But it is extremely helpful over the course >> of larger programs, provides (checkable!) documentation, yields more >> effective execution trivially and so on. >> >> The initial ignorance of static types in Erlang is understandable. >> Other things were more important to get right and history was such >> that we did not understand certain parts of the intermingling of types >> with distribution etc.. But today, I feel there is no excuse. Should I >> design a modern Erlang, I would start with a statically typed world in >> which communicaiton use polymorphic variants. Essentially: An internal >> process is statically typed, but communicate in a dynamically typed >> setting. Thus, I have lost *nothing* compared to Erlang, but I can >> compile processes to be an order of magnitude faster, trivially. From >> there, I can probably define a channel-primitive between processes >> with static type constraint such that processes can intercommunicate >> in a type-safe way. Perhaps even with a shared-persistent-heap >> semantics. >> >> Remember, dynamic typing is a straitjacket, in which you cannot fully >> express yourself, whereas static typing give you a rich language for >> doing so. >> >> >> > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ok@REDACTED Tue Apr 19 02:57:04 2011 From: ok@REDACTED (Richard O'Keefe) Date: Tue, 19 Apr 2011 12:57:04 +1200 Subject: [erlang-questions] Runtime checking for types In-Reply-To: References: <945465586.107521303080710089.JavaMail.root@zimbra> <07054f02-aee1-4baf-85b8-6870782e9e18@dr5g2000vbb.googlegroups.com> Message-ID: <25B0968E-BB32-4107-93FA-61D58EC4130E@cs.otago.ac.nz> On 18/04/2011, at 10:58 PM, Jesper Louis Andersen wrote: > The initial ignorance of static types in Erlang is understandable. Joe Armstrong and the others weren't _ignorant_ of static types; they just didn't bother using them. Their time was of course limited; they had other maddened grizzly bears to stun; and there was no suitable type system available off the shelf. In a language like Occam or Go it is feasible to have types on channels, because there is one program. In a *distributed* world, where X!Y may send Erlang term Y to a machine anywhere in the world, there doesn't seem to be any reason why process X should *believe* the type checker that allowed the original send. > Thus, I have lost *nothing* compared to Erlang, but I can > compile processes to be an order of magnitude faster, trivially. It is not immediately clear that this is true. Yes, Erlang could be faster. But you would *still* need some kind of run time tag checking for integer arithmetic, or else sacrifice Erlang's ability to generate correct answers (as for example Java so cheerfully and annoyingly did). You would *still* have to have some kind of dynamic type checking when values are communicated from the past to the future (for example, Dynamic in Clean has to do this, and of course so does Java serialisation). You would still have to compile code in such a way that it can easily be removed and replaced. There *are* techniques that could be used to make a "modern" Erlang faster, but they mostly come from other dynamic languages, like Self (and even from dear old Spitbol). > Remember, dynamic typing is a straitjacket, in which you cannot fully > express yourself, whereas static typing give you a rich language for > doing so. This sounds very much like a crab telling humans how limited they are by the absence of a shell. Think of the problems of moulting. Erlang is about building *reliable* distributed programs, not fast ones. In many applications it is more important to manage the flow of messages across the network than to shave a few cycles off an add. It is important to know that version skew won't cause fatal system integrity problems (and yes, I *have* experienced total insanity of a Java program due to version skew). The type system used by the Dialyzer, what is it? Is it the third type system developed for Erlang or the fourth? Or have I missed some? It took *years* to figure out what a type system for Erlang should be like, and to my mind it is still missing some major features. If the CSLab people had waited until they got the type system right before releasing Erlang, we'd still be waiting. From vinoski@REDACTED Tue Apr 19 04:21:53 2011 From: vinoski@REDACTED (Steve Vinoski) Date: Mon, 18 Apr 2011 22:21:53 -0400 Subject: [erlang-questions] Yaws's "sendfile" linked-in driver : "stealing control of fd" error In-Reply-To: <4DAC0C2A.5060705@erix.ericsson.se> References: <4DAC0C2A.5060705@erix.ericsson.se> Message-ID: On Mon, Apr 18, 2011 at 6:02 AM, Sverker Eriksson wrote: > On Sun, Apr 17, 2011 at 5:23 PM, zabrane Mikael wrote: >>> >>> Hi OTP team & Steve, >>> >>> I'm using the "sendfile" (thanks to Steve Vinoski) linked-in driver >>> borrowed from "Yaws" >>> in one of my pet project. >>> >>> Today, I noticed this strange error: >>> =ERROR REPORT==== 17-Apr-2011::20:49:18 === >>> driver_select(0x0000000000000c31, 24, ERL_DRV_WRITE, 1) by >>> sendfile_drv driver #Port<0.3121> stealing control of fd=24 from >>> output driver tcp_inet #Port<0.10029> >>> >> >> > > The error message kind of says it all: > The driver "sendfile_drv" is calling driver_select() to subscribe for output > events on file descriptor 24. BUT, driver "tcp_inet" is already subscribing > to output events on that very same file descriptor 24. Driver "sendfile_drv" > thus steals the file descriptor from "tcp_inet" as only one port at a time > can subscribe to a particular file descriptor event. > > I think you should consider this as an error. Drivers are not supposed to > act like this. The normal cause of this is a driver that forgets to deselect > a file descriptor before closing it. Despite that I would regard > sendfile_drv as the primary suspect here as the new kid on the block. Hi Sverker, I agree it's an error in the sendfile driver, but so far we have no evidence that it results in erroneous transfers or incorrect data. As I explained earlier, I've only ever seen it under catastrophic circumstances, but the fatal errors I saw weren't caused by this issue; rather, this issue was a side effect of the fatal errors. What Mikael is seeing, though, has nothing to do with fatal errors, so I think for cases like his it's just a rare and innocuous error report. I suspect it occurs due to the tcp driver closing the socket before the sendfile driver has dropped interest in it but that's only a guess. I'll see if I can't come up with a way to reliably reproduce this, but either way it might not be fixable in the current code since the sendfile driver can't know if or when the tcp driver is also registered for the socket being writeable. Maybe this can be handled correctly as part of Tuncer's effort to add the sendfile functionality directly into Erlang/OTP. thanks, --steve From mikhail.sobolev@REDACTED Tue Apr 19 08:09:42 2011 From: mikhail.sobolev@REDACTED (Mikhail Sobolev) Date: Tue, 19 Apr 2011 09:09:42 +0300 Subject: [erlang-questions] Web Frameworks: which to choose? In-Reply-To: <7A50AC3D-B2C1-4B01-9B32-9210C223613C@worrell.nl> References: <4DAC5AFD.4040709@gmail.com> <7A50AC3D-B2C1-4B01-9B32-9210C223613C@worrell.nl> Message-ID: Hi, Thanks everyone for the suggestions. It seems that Nitrogen is a bit more popular than others. So we'll start there. Thanks again, -- Misha From dsc@REDACTED Tue Apr 19 10:58:47 2011 From: dsc@REDACTED (Dave Challis) Date: Tue, 19 Apr 2011 09:58:47 +0100 Subject: [erlang-questions] Server which spawns an additional server for each call References: <4DAD4EC7.3070607@ecs.soton.ac.uk> Message-ID: Hi, I'm trying to work out the structure for a small bit of functionality in erlang. I've got a feeling there's an obvious solution, but I'm not experienced enough with the language sure what pattern to best follow... So far, I've got a server which implements the gen_server behaviour, a supervisor for it, and a module containing an API for interacting with it (using gen_server:call mostly). The server does a lot of work though, so blocks for a while until the call is finished. What I'd like to do, is create a new server process each time gen_server:call is invoked by a client, with each server terminating when it's done processing (but always leaving 1 server running). This means that clients using the API will have their request processes straight away, without having to wait for all the other calls to the server to finish. I can't quite figure out where to place the logic for doing this though. * Should the API module ask the supervisor to spawn a new child, then send the client's call to this? * Should API calls go to the supervisor, and have it decide whether to spawn new servers or send the call to an existing one? * Or should each server take care of telling the supervisor to spawn a new child, and pass the call request to the newly spawned one? Is this a sensible approach in general, or is there an obvious pattern or some functionality I've missed? Thanks, -- Dave Challis dsc@REDACTED From kostis@REDACTED Tue Apr 19 11:18:51 2011 From: kostis@REDACTED (Kostis Sagonas) Date: Tue, 19 Apr 2011 12:18:51 +0300 Subject: [erlang-questions] Typespecs export not working as intended? In-Reply-To: <4DAC1A99.4090206@dev-extend.eu> References: <4DAC1A99.4090206@dev-extend.eu> Message-ID: <4DAD537B.2030004@cs.ntua.gr> Lo?c Hoguin wrote: > Hello, > > I have ran into a weird issue while refactoring the type specs in a project. > > It seems types in a module can be used even if they are not exported > using export_type. Neither of the compiler or dialyzer are complaining > about it. As others have explained the compiler does not complain when using a type from another module because: 1) this would require that it looks at the code of the other module and 2) it would be inconsistent with what the compiler does with remote calls to functions that are not exported. But dialyzer *does* complain when you analyze both modules at the same time -- though perhaps not loudly enough. > For example, module a declares a type my_type(), module b uses it with > a:my_type(), no export_type in module, yet it still works. > > Is that normal? The documentation clearly states that types should be > exported. Can you please be a bit more specific about the behavior you are experiencing? A concrete example and information about the version of OTP you are using will help a lot to understand what you are talking about. Also please send the dialyzer command you are using. I cannot reproduce what you claim you are experiencing. An example below: %%-------------- MODULE a ---------------- -module(a). -export([foo/1]). -spec foo(b:b()) -> string(). foo(A) when is_atom(A) -> atom_to_list(A). %%-------------- MODULE b ----------------- -module(b). -export([bar/1]). -type b() :: integer(). % NOT EXPORTED -spec bar(b()) -> b(). bar(X) when is_integer(X) -> X + 42. %%----------------------------------------- $ dialyzer a.erl b.erl Checking whether the PLT /home/kostis/.dialyzer_plt is up-to-date... yes Proceeding with analysis... Unknown types: b:b/0 done in 0m1.16s done (passed successfully) The b:b() type is mentioned as unknown to the analysis. Perhaps the message should explicitly say that this type is not exported, but do you get a different behavior when you run dialyzer? Kostis From zabrane3@REDACTED Tue Apr 19 11:51:58 2011 From: zabrane3@REDACTED (Zabrane Mickael) Date: Tue, 19 Apr 2011 11:51:58 +0200 Subject: [erlang-questions] Yaws's "sendfile" linked-in driver : "stealing control of fd" error In-Reply-To: References: <4DAC0C2A.5060705@erix.ericsson.se> Message-ID: <236AF39A-54F7-40C1-8E21-82F52D6FD892@gmail.com> Hi Steve, > Hi Sverker, I agree it's an error in the sendfile driver, but so far > we have no evidence that it results in erroneous transfers or > incorrect data. As I explained earlier, I've only ever seen it under > catastrophic circumstances, but the fatal errors I saw weren't caused > by this issue; rather, this issue was a side effect of the fatal > errors. What Mikael is seeing, though, has nothing to do with fatal > errors, so I think for cases like his it's just a rare and innocuous > error report. I suspect it occurs due to the tcp driver closing the > socket before the sendfile driver has dropped interest in it but > that's only a guess. That's correct. I confirm that in my case, the error occurs only when the Socket is closed. > I'll see if I can't come up with a way to reliably reproduce this, but > either way it might not be fixable in the current code since the > sendfile driver can't know if or when the tcp driver is also > registered for the socket being writeable. Maybe this can be handled > correctly as part of Tuncer's effort to add the sendfile functionality > directly into Erlang/OTP. If you need help, don't hesitate. Regards, Zab From ingela@REDACTED Tue Apr 19 12:15:25 2011 From: ingela@REDACTED (Ingela Andin) Date: Tue, 19 Apr 2011 12:15:25 +0200 Subject: [erlang-questions] https request certificate validation In-Reply-To: References: Message-ID: Hello, in r13 our new ssl implementation was being introduced and was experimental so the API and default behavior may wobble a bit in R13*. in R14B02 you should get the wanted behavior by using the {verify, verify_peer} and {cacertfile, "File.pem"} option. ({verify, Number} is deprecated) . If you want to verify peer-certs you must have some known root-cacerts to verify the root of the peer-cert chain. That is why you get the eoptions "error in options list" (legacy return value). Regards Ingela Erlang/OTP team - Ericsson AB >2011/4/18 rtsome : > Hi. > So I want request to fail if server certificate is self-signed. > I tried different options but no luck. > > -module(tst). > -compile(export_all). > > get(Url, Opt)-> > ??? case http:request(get, {Url, []}, Opt,[]) of > ??? ??? {ok, {H,_Headers,_Response}} -> > ??? ??? ??? {ok , H}; > ??? ??? O -> O > ??? end. > > g()-> > ??? inets:start(), > ??? ssl:start(), > ??? http:set_options([{max_ > sessions, 0} > ??? ??? ??? ??? ??? ? ,{max_keep_alive_length, 0} > %??? ??? ??? ??? ??? ? ,{verbose, verbose} > ??? ??? ??? ??? ??? ? ]), > ??? Opts = [[{ssl,[{verify, verify_peer}]}] > ??? ??? ??? ,[{ssl,[{verify, verify_peer}]}] > ??? ??? ??? ,[{ssl,[{verify, 2}]}] > ??? ??? ??? ,[{ssl,[{verify, 1}]}] > ??? ??? ??? ,[{ssl,[{verify, 0}]}] > ??? ??? ??? ,[{ssl,[{verify, verify_peer}]}] > ??? ??? ??? ], > ??? io:format("~p~n",[[get("https://localhost", O) || O <- Opts]]), > ??? io:format("~p~n",[[get("https://mail.google.com/mail/", O) || O <- > Opts]]), > ??? init:stop(). > > Typical output: > [{error,{connect_failed,eoptions}}, > ?{error,{connect_failed,eoptions}}, > ?{ok,{"HTTP/1.1",200,"OK"}}, > ?{ok,{"HTTP/1.1",200,"OK"}}, > ?{ok,{"HTTP/1.1",200,"OK"}}, > ?{error,{connect_failed,eoptions}}] > [{error,{connect_failed,eoptions}}, > ?{error,{connect_failed,eoptions}}, > ?{ok,{"HTTP/1.1",200,"OK"}}, > ?{ok,{"HTTP/1.1",200,"OK"}}, > ?{ok,{"HTTP/1.1",200,"OK"}}, > ?{ok,{"HTTP/1.1",200,"OK"}}] > > Note the 'verify_peer' variant. It fails unregularly independ?ntly of > certificate validity. > Erlang versions under consideration: > R13B03@REDACTED ubuntu > R14B02@REDACTED > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > From jodie.burch@REDACTED Tue Apr 19 13:18:54 2011 From: jodie.burch@REDACTED (Jodie Burch) Date: Tue, 19 Apr 2011 12:18:54 +0100 Subject: [erlang-questions] London Erlang User Group Meeting Message-ID: Hi There is still time to register for the Erlang User Group in London tomorrow. If you want to submit a talk for the 10 minute lightning talks let us know! You can find all the details and register here: http://www.erlang-solutions.com/events/2/entry/1233 I look forward to seeing you tomorrow. Thanks Jodie -------------- next part -------------- An HTML attachment was scrubbed... URL: From richardprideauxevans@REDACTED Tue Apr 19 13:34:35 2011 From: richardprideauxevans@REDACTED (Richard Evans) Date: Tue, 19 Apr 2011 12:34:35 +0100 Subject: [erlang-questions] How to share record definitions between modules Message-ID: I have a record defined in one erlang file, and I want it to be available in another module. Is there a way to share the record between the two files without copying/pasting the record definition? Is there a similar way to share -type info between files? thanks in advance, Richard -------------- next part -------------- An HTML attachment was scrubbed... URL: From tino.breddin@REDACTED Tue Apr 19 13:40:58 2011 From: tino.breddin@REDACTED (Tino Breddin) Date: Tue, 19 Apr 2011 13:40:58 +0200 Subject: [erlang-questions] How to share record definitions between modules In-Reply-To: References: Message-ID: You can define records in header files '.hrl' just like macros and thus include these in multiple files. See http://www.erlang.org/doc/reference_manual/macros.html Cheers, Tino On Tue, Apr 19, 2011 at 1:34 PM, Richard Evans < richardprideauxevans@REDACTED> wrote: > I have a record defined in one erlang file, and I want it to be available > in another module. > > Is there a way to share the record between the two files without > copying/pasting the record definition? > > Is there a similar way to share -type info between files? > > thanks in advance, > > Richard > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kenrobinsonster@REDACTED Tue Apr 19 14:01:15 2011 From: kenrobinsonster@REDACTED (Ken Robinson) Date: Tue, 19 Apr 2011 22:01:15 +1000 Subject: [erlang-questions] How to share record definitions between modules In-Reply-To: References: Message-ID: Hi Richard, I believe to share types one does the following: -export_type([func1/1, func2/5]). Ken. On Tue, Apr 19, 2011 at 9:34 PM, Richard Evans wrote: > I have a record defined in one erlang file, and I want it to be available in > another module. > Is there a way to share the record between the two files without > copying/pasting the record definition? > Is there a similar way to share -type info between files? > thanks in advance, > Richard > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -- regards, Ken Robinson Mob +61438681120 Home +61738523767 From mihai@REDACTED Tue Apr 19 14:27:36 2011 From: mihai@REDACTED (Mihai Balea) Date: Tue, 19 Apr 2011 08:27:36 -0400 Subject: [erlang-questions] Server which spawns an additional server for each call In-Reply-To: References: <4DAD4EC7.3070607@ecs.soton.ac.uk> Message-ID: <18566AA3-E8A9-457C-AA0D-7719A37D9DA8@hates.ms> On Apr 19, 2011, at 4:58 AM, Dave Challis wrote: > Hi, > I'm trying to work out the structure for a small bit of functionality in erlang. I've got a feeling there's an obvious solution, but I'm not experienced enough with the language sure what pattern to best follow... > > So far, I've got a server which implements the gen_server behaviour, a supervisor for it, and a module containing an API for interacting with it (using gen_server:call mostly). > > The server does a lot of work though, so blocks for a while until the call is finished. > > What I'd like to do, is create a new server process each time gen_server:call is invoked by a client, with each server terminating when it's done processing (but always leaving 1 server running). > > This means that clients using the API will have their request processes straight away, without having to wait for all the other calls to the server to finish. > > I can't quite figure out where to place the logic for doing this though. > > * Should the API module ask the supervisor to spawn a new child, then send the client's call to this? > * Should API calls go to the supervisor, and have it decide whether to spawn new servers or send the call to an existing one? > * Or should each server take care of telling the supervisor to spawn a new child, and pass the call request to the newly spawned one? > > Is this a sensible approach in general, or is there an obvious pattern or some functionality I've missed? What I would do in this situation: - have a main gen_server module that implements management tasks, and also provides the API to work with the system. This would be supervised by your main app supervisor - have a bunch of worker gen_servers that implement actual functionality, These would be launched and supervised by a secondary, simple_one_to_one supervisor, that, in turn, would live under the main app supervisor. - Your manager server would ask your worker supervisor to launch workers on demand and would possibly monitor them Things can get significantly more complicated if you want to limit the number of spawned workers or you want to have a pool of pre-spawned workers. You could also consider reusing your workers, in order to save process spawning and teardown overhead. It seems to me that this is a pretty common pattern. I am wondering whether maybe there are already some libraries / generic behaviours out there that implement worker pool functionality. Maybe somebody on this list could point you to something already existing that might save you some work. Hope this helps, Mihai From bengt.kleberg@REDACTED Tue Apr 19 15:30:25 2011 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Tue, 19 Apr 2011 15:30:25 +0200 Subject: [erlang-questions] beginner: How should regexp:split/2 be replaced? Message-ID: <1303219825.5178.41.camel@seasc1137> Greetings, I have inherited some code without a test directory. I get the following compiler warnings: ./compile_funcs.erl:603: Warning: regexp:split/2: the regexp module is deprecated (will be removed in R15A); use the re module instead ./compile_funcs.erl:645: Warning: regexp:matches/2: the regexp module is deprecated (will be removed in R15A); use the re module instead The lines are: {ok, Class} = regexp:split(Class0, "[ ]*,[ ]*"), and {match,A}=regexp:matches(String,"\n"), I thought "[ ]*,[ ]*" would mean: the character class of " " (space), 0 or many times, followed by literal "," followed by the character class of " " (space), 0 or many times. This is not the case and I am not having any luck with randomly constructing strings to find one that triggers a Class that is different from Class0. Perhaps someone knows what "[ ]*,[ ]*" really means, and what to replace these with when using the re module. bengt From kenrobinsonster@REDACTED Tue Apr 19 16:04:21 2011 From: kenrobinsonster@REDACTED (Ken Robinson) Date: Wed, 20 Apr 2011 00:04:21 +1000 Subject: [erlang-questions] Runtime checking for types In-Reply-To: <945465586.107521303080710089.JavaMail.root@zimbra> References: <1930911379.107501303080619591.JavaMail.root@zimbra> <945465586.107521303080710089.JavaMail.root@zimbra> Message-ID: For built in types like integer, list, atom, etc I can do a guard test like when is_list(MyValue). For types that I create it would be good to have a guard test like is_type(mytype, MyValue). It looks like I can't test for my created types at runtime. I'll use a hrl file containing my record or the pattern matching. Is it the case the types I create are only for the benefit of dialyzer? Ken. On Mon, Apr 18, 2011 at 8:51 AM, Robert Virding wrote: > I think the thing to remember is that records are not separate data types. At run-time a record is just a tuple which is large enough to contain all the fields (and only the field values) and the first element of the tuple is an atom which is the name of the record. As such records only exist at compile-time and the compiler converts ALL record operations to the corresponding tuple operations. > > Your headerrec record just becomes the tuple {headerrec,MessageId}. > > So actually Erlang does not really have proper abstract data types. > > Robert > > ----- "Ken Robinson" wrote: > >> I know this sounds crazy but I was wondering if there was some >> runtime >> check for types. I've created an abstract data type in an .erl (see >> below). I want to now pattern match >> >> -opaque u16int() :: 0..(1 bsl 16 - 1). >> -export_type([u16int/0]). >> ... >> -record(headerrec, {message_id :: u16int()}). >> -opaque headerrec() :: #headerrec{}. >> -export_type([headerrec/0]). >> >> I can do a runtime test like so: >> foo(#headerrec{} = HeaderRec) -> >> ? ? ... >> >> What I would like to do is test for the new type similar to the >> gaurds >> is_record() and the like. Any ideas? I realize I can put this all in >> a >> .hrl file but this would break the encapsualtion. >> >> regards, >> Ken Robinson >> Mob +61438681120 >> Home +61738523767 >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions > -- regards, Ken Robinson Mob +61438681120 Home +61738523767 From spawn.think@REDACTED Tue Apr 19 16:18:16 2011 From: spawn.think@REDACTED (Ahmed Omar) Date: Tue, 19 Apr 2011 16:18:16 +0200 Subject: [erlang-questions] beginner: How should regexp:split/2 be replaced? In-Reply-To: <1303219825.5178.41.camel@seasc1137> References: <1303219825.5178.41.camel@seasc1137> Message-ID: regexp:split("Hello world, Hello", "[ ]*,[ ]*"). {ok,["Hello world","Hello"]} re:split("Hello world, Hello", "[ ]*,[ ]*",[{return, list}]). ["Hello world","Hello"] regexp:matches("Hello \n","\n"). {match,[{7,1}]} re:run("Hello \n","\n"). {match,[{6,1}]} but i'm not sure why the start position is different here On Tue, Apr 19, 2011 at 3:30 PM, Bengt Kleberg wrote: > Greetings, > > I have inherited some code without a test directory. I get the following > compiler warnings: > ./compile_funcs.erl:603: Warning: regexp:split/2: the regexp module is > deprecated (will be removed in R15A); use the re module instead > ./compile_funcs.erl:645: Warning: regexp:matches/2: the regexp module is > deprecated (will be removed in R15A); use the re module instead > > The lines are: > {ok, Class} = regexp:split(Class0, "[ ]*,[ ]*"), > and > {match,A}=regexp:matches(String,"\n"), > > I thought "[ ]*,[ ]*" would mean: > the character class of " " (space), 0 or many times, followed by literal > "," followed by the character class of " " (space), 0 or many times. > > This is not the case and I am not having any luck with randomly > constructing strings to find one that triggers a Class that is different > from Class0. > > Perhaps someone knows what "[ ]*,[ ]*" really means, and what to replace > these with when using the re module. > > > bengt > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -- Best Regards, - Ahmed Omar http://nl.linkedin.com/in/adiaa Follow me on twitter @spawn_think -------------- next part -------------- An HTML attachment was scrubbed... URL: From spawn.think@REDACTED Tue Apr 19 16:21:20 2011 From: spawn.think@REDACTED (Ahmed Omar) Date: Tue, 19 Apr 2011 16:21:20 +0200 Subject: [erlang-questions] beginner: How should regexp:split/2 be replaced? In-Reply-To: References: <1303219825.5178.41.camel@seasc1137> Message-ID: I mean i understand it's different indexing, but was there specific reason to change that? On Tue, Apr 19, 2011 at 4:18 PM, Ahmed Omar wrote: > regexp:split("Hello world, Hello", "[ ]*,[ ]*"). > {ok,["Hello world","Hello"]} > > re:split("Hello world, Hello", "[ ]*,[ ]*",[{return, list}]). > ["Hello world","Hello"] > > regexp:matches("Hello \n","\n"). > {match,[{7,1}]} > > re:run("Hello \n","\n"). > {match,[{6,1}]} > > but i'm not sure why the start position is different here > > On Tue, Apr 19, 2011 at 3:30 PM, Bengt Kleberg > wrote: > >> Greetings, >> >> I have inherited some code without a test directory. I get the following >> compiler warnings: >> ./compile_funcs.erl:603: Warning: regexp:split/2: the regexp module is >> deprecated (will be removed in R15A); use the re module instead >> ./compile_funcs.erl:645: Warning: regexp:matches/2: the regexp module is >> deprecated (will be removed in R15A); use the re module instead >> >> The lines are: >> {ok, Class} = regexp:split(Class0, "[ ]*,[ ]*"), >> and >> {match,A}=regexp:matches(String,"\n"), >> >> I thought "[ ]*,[ ]*" would mean: >> the character class of " " (space), 0 or many times, followed by literal >> "," followed by the character class of " " (space), 0 or many times. >> >> This is not the case and I am not having any luck with randomly >> constructing strings to find one that triggers a Class that is different >> from Class0. >> >> Perhaps someone knows what "[ ]*,[ ]*" really means, and what to replace >> these with when using the re module. >> >> >> bengt >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> > > > > -- > Best Regards, > - Ahmed Omar > http://nl.linkedin.com/in/adiaa > Follow me on twitter > @spawn_think > > -- Best Regards, - Ahmed Omar http://nl.linkedin.com/in/adiaa Follow me on twitter @spawn_think -------------- next part -------------- An HTML attachment was scrubbed... URL: From spawn.think@REDACTED Tue Apr 19 16:26:57 2011 From: spawn.think@REDACTED (Ahmed Omar) Date: Tue, 19 Apr 2011 16:26:57 +0200 Subject: [erlang-questions] beginner: How should regexp:split/2 be replaced? In-Reply-To: References: <1303219825.5178.41.camel@seasc1137> Message-ID: Well the documentation already state it so i believe no need to reply that side question :) The default return type is (zero-based) indexes of the captured parts of the string, given as {Offset,Length} pairs (the index Type of capturing). On Tue, Apr 19, 2011 at 4:21 PM, Ahmed Omar wrote: > I mean i understand it's different indexing, but was there specific reason > to change that? > > > On Tue, Apr 19, 2011 at 4:18 PM, Ahmed Omar wrote: > >> regexp:split("Hello world, Hello", "[ ]*,[ ]*"). >> {ok,["Hello world","Hello"]} >> >> re:split("Hello world, Hello", "[ ]*,[ ]*",[{return, list}]). >> ["Hello world","Hello"] >> >> regexp:matches("Hello \n","\n"). >> {match,[{7,1}]} >> >> re:run("Hello \n","\n"). >> {match,[{6,1}]} >> >> but i'm not sure why the start position is different here >> >> On Tue, Apr 19, 2011 at 3:30 PM, Bengt Kleberg < >> bengt.kleberg@REDACTED> wrote: >> >>> Greetings, >>> >>> I have inherited some code without a test directory. I get the following >>> compiler warnings: >>> ./compile_funcs.erl:603: Warning: regexp:split/2: the regexp module is >>> deprecated (will be removed in R15A); use the re module instead >>> ./compile_funcs.erl:645: Warning: regexp:matches/2: the regexp module is >>> deprecated (will be removed in R15A); use the re module instead >>> >>> The lines are: >>> {ok, Class} = regexp:split(Class0, "[ ]*,[ ]*"), >>> and >>> {match,A}=regexp:matches(String,"\n"), >>> >>> I thought "[ ]*,[ ]*" would mean: >>> the character class of " " (space), 0 or many times, followed by literal >>> "," followed by the character class of " " (space), 0 or many times. >>> >>> This is not the case and I am not having any luck with randomly >>> constructing strings to find one that triggers a Class that is different >>> from Class0. >>> >>> Perhaps someone knows what "[ ]*,[ ]*" really means, and what to replace >>> these with when using the re module. >>> >>> >>> bengt >>> >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://erlang.org/mailman/listinfo/erlang-questions >>> >> >> >> >> -- >> Best Regards, >> - Ahmed Omar >> http://nl.linkedin.com/in/adiaa >> Follow me on twitter >> @spawn_think >> >> > > > -- > Best Regards, > - Ahmed Omar > http://nl.linkedin.com/in/adiaa > Follow me on twitter > @spawn_think > > -- Best Regards, - Ahmed Omar http://nl.linkedin.com/in/adiaa Follow me on twitter @spawn_think -------------- next part -------------- An HTML attachment was scrubbed... URL: From shomodj@REDACTED Tue Apr 19 16:35:40 2011 From: shomodj@REDACTED (Boris Shomodjvarac) Date: Tue, 19 Apr 2011 16:35:40 +0200 Subject: [erlang-questions] beginner: How should regexp:split/2 be replaced? In-Reply-To: References: <1303219825.5178.41.camel@seasc1137> Message-ID: <4DAD9DBC.6030100@gmail.com> On 04/19/2011 04:21 PM, Ahmed Omar wrote: > I mean i understand it's different indexing, but was there specific > reason to change that? I would guess it has to do with a switch from erlang regex implementation to PCRE implementation. HTH, Boris. From erlang@REDACTED Tue Apr 19 17:11:36 2011 From: erlang@REDACTED (Joe Armstrong) Date: Tue, 19 Apr 2011 17:11:36 +0200 Subject: [erlang-questions] Server which spawns an additional server for each call In-Reply-To: References: <4DAD4EC7.3070607@ecs.soton.ac.uk> Message-ID: It's not entirely clear to me what you want to do. I never understand why people use gen_servers for everything, pure Erlang is often easier :-) I assume you want to delegate the response in the server (ie get some other process than the gen server to do the work, since this takes a long time) One way to do this is like this: Write a client stub like this: foo(X) -> gen_server:call(?Mod, {foo, X}). Write a gen_server handle call method like this: handle_call({foo, X}, From, State) -> State1 = func1(X, State), State2 = func2(X, State), spawn_link(fun() -> do_something(State1, X, From) end), {noreply, State2}. do_something(State, X, From) -> Reply = func3(X, State), gen_server:reply(From, Reply). here I've assumed func1 returns State1 and that State1 is some subset of State needed in your computation. State2 (returned by func2) is the continuation state of the server. ie the state the server will have after it has received the foo request, but before the delegated function has replied. You'll have to write func1 and func2 yourself. do_something is the delegated function that might take a long time. The four lines of code which define handle_call should return quickly, ie don't do much here, do the work in do_something. handle call returns {noreply, State2} which means "don't reply to the client but continue with state State2. do_something works in parallel with the server and when it has finished calls gen_server:reply/2 and at this point the client stub routine foo/1 will return. This is only one way of doing this. You could do the complex calculation inside the client and request the data you need from the server, the server can spawn a deligate (as above). You can use a shared ets table and so on. if you were to do this in pure erlang it might be easier to see what's going on Define promise and yield thusly: promise(Fun) -> S = self(), %% this self() is evaluated *inside* the current function spawn(fun() -> S ! {self(), Fun()} %% this self() is evaluated *inside* the spawned function end). yield(Promise) -> receive {Promise, Result} -> Result end. promise takes a Fun argument and returns a promise. The promise is a promise to compute the value. The promise can be redeemed by calling yield. So we can write code like this: P = promise(fun() -> fib(40) end), .... do some other stuff that takes a while ... Val = yield(Promise) So we compute fib(40) which takes a long time in parallel with some other stuff. The gen_server stuff above has just hidden what is essentially a promise and yield and a bit of state trickery in a framework module - nothing tricky about about it at all. Given promise and yield and a dash of list comprehensions we can write fun stuff like: parmap(F, L) -> Promises = [promise(fun() -> F(I) end || I <- L], [yield(I) || I <- Promises]. which is a parallel mapping function. Hope this helps /Joe On Tue, Apr 19, 2011 at 10:58 AM, Dave Challis wrote: > Hi, > I'm trying to work out the structure for a small bit of functionality in > erlang. I've got a feeling there's an obvious solution, but I'm not > experienced enough with the language sure what pattern to best follow... > > So far, I've got a server which implements the gen_server behaviour, a > supervisor for it, and a module containing an API for interacting with it > (using gen_server:call mostly). > > The server does a lot of work though, so blocks for a while until the call > is finished. > > What I'd like to do, is create a new server process each time > gen_server:call is invoked by a client, with each server terminating when > it's done processing (but always leaving 1 server running). > > This means that clients using the API will have their request processes > straight away, without having to wait for all the other calls to the server > to finish. > > I can't quite figure out where to place the logic for doing this though. > > * Should the API module ask the supervisor to spawn a new child, then send > the client's call to this? > * Should API calls go to the supervisor, and have it decide whether to > spawn new servers or send the call to an existing one? > * Or should each server take care of telling the supervisor to spawn a new > child, and pass the call request to the newly spawned one? > > Is this a sensible approach in general, or is there an obvious pattern or > some functionality I've missed? > > Thanks, > > -- > Dave Challis > dsc@REDACTED > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kostis@REDACTED Tue Apr 19 17:15:37 2011 From: kostis@REDACTED (Kostis Sagonas) Date: Tue, 19 Apr 2011 18:15:37 +0300 Subject: [erlang-questions] Runtime checking for types In-Reply-To: References: Message-ID: <4DADA719.2080507@cs.ntua.gr> Ken Robinson wrote: > I know this sounds crazy but I was wondering if there was some runtime > check for types. I've created an abstract data type in an .erl (see > below). I want to now pattern match > > -opaque u16int() :: 0..(1 bsl 16 - 1). > -export_type([u16int/0]). > ... > -record(headerrec, {message_id :: u16int()}). > -opaque headerrec() :: #headerrec{}. > -export_type([headerrec/0]). > > I can do a runtime test like so: > foo(#headerrec{} = HeaderRec) -> > ... > > What I would like to do is test for the new type similar to the guards > is_record() and the like. Any ideas? I realize I can put this all in a > .hrl file but this would break the encapsulation. You asked an interesting question and IMO the thread you started got responses that are not related to what you want to do, do not help you much, and actually show a bit of ignorance about what modern Erlang is capable of doing. I find this a pity... First of all, you've not told us why you would like to pattern match. Perhaps the proper answer to your question is that you should not. Then you can preserve encapsulation and make sure things work as you expect them to. Here is what you can do. You can define your opaque data type in a module, say 'header', which looks as follows: %%------------------------------------------------------------------- -module(header). -export([new/0, new/1, get_message_id/1, set_message_id/2]). -export_type([headerrec/0]). -record(headerrec, {message_id :: u16int()}). -opaque headerrec() :: #headerrec{}. %% You can actually declare the following opaque if you want, but %% it really does not make any difference for what you want to do -type u16int() :: 0..(1 bsl 16 - 1). new() -> new(42). % put some sensible default here new(Id) when is_integer(Id), 0 =< Id, Id =< (1 bsl 16 - 1) -> #headerrec{message_id = Id}. get_message_id(#headerrec{message_id = Id}) -> Id. set_message_id(#headerrec{} = R, Id) when is_integer(Id), 0 =< Id, Id =< (1 bsl 16 - 1) -> R#headerrec{message_id = Id}; set_message_id(_R, _Id) -> error("SOME APPROPRIATE ERROR MESSAGE/TERM HERE"). %---------------------------------------------------------------------- This module declares an abstract data type and functions to create, access and update its elements. At least as far as dialyzer is concerned, this data type is *unforgeable*. Dialyzer will actually find and point out each and every attempt to create some term that looks like the abstract data type but is not created by this module. It will also flag every attempt (outside this module) to deconstruct a #headerrec{} record created by the new/[0,1] functions. Don't just believe me; tesy this for yourself and try to break it if you can. What you now do is create such terms and pass them around in other modules and you can be rest assured that the types are correct as long as dialyzer does not complain about it. So, I strongly suspect that the above does what you want to do. The only reason I can think of (but perhaps I lack imagination here) that you may want to do a runtime test for the type outside the module that defines it is if you want to have a function that expects either a #headerrec{} or something else. Currently, there is no way to do this in Erlang. But stay tuned for user-defined guards which will give you this ability. So, IMO, you should NOT expose the record definition in a header file. Kostis From richardprideauxevans@REDACTED Tue Apr 19 17:37:19 2011 From: richardprideauxevans@REDACTED (Richard Evans) Date: Tue, 19 Apr 2011 16:37:19 +0100 Subject: [erlang-questions] Dialyzer generating spurious warnings when using the ?assert macro Message-ID: Hi guys, I am going through adding typing to my functions and getting dialyzer to verify everything, which is all working very nicely, apart from one minor grievance: There are two places where I use the ?assert macro, and I believe dialyzer is giving me spurious warnings on these lines: interpretAction({implies, A, C, true}) -> ?assert(xl_string:impliesString(A,C)); interpretAction({implies, A, C, false}) -> ?assert(not xl_string:impliesString(A,C)); These generate the warnings: xl.erl:286: The variable _ can never match since previous clauses completely covered the type 'false' xl.erl:287: The variable _ can never match since previous clauses completely covered the type 'false' I think these are problems with the macro and not with my code. Does anybody have any info on this? I also found this post on the internet, where somebody else seems to have a similar problem: http://erlang.2086793.n4.nabble.com/Eunit-assert-causes-Dialyzer-warning-td2252010.html Any help much appreciated thanks, Richard -------------- next part -------------- An HTML attachment was scrubbed... URL: From raphael.korsoski@REDACTED Tue Apr 19 17:55:06 2011 From: raphael.korsoski@REDACTED (Raphael Korsoski) Date: Tue, 19 Apr 2011 17:55:06 +0200 Subject: [erlang-questions] Dialyzer generating spurious warnings when using the ?assert macro In-Reply-To: References: Message-ID: Hi! I ran 'erlc -P' on the example in the post you found on the internet, with the following result: ... foo(X) -> ?assert(is_list(X)), ... becomes ... foo(X) -> fun() -> case is_list(X) of true -> ok; __V -> .erlang:error({assertion_failed, [{module,foo}, {line,8}, {expression,"is_list ( X )"}, {expected,true}, {value, case __V of false -> __V; _ -> {not_a_boolean,__V} end}]}) end end(), ... Indeed, the '_' case in the nested statement cannot occur, since __V is always 'false' in that branch. I'm guessing that if you run 'erlc -P' on your own example, you will find something similar in the pre-processed code. BR, Raphael Korsoski ________________________________ From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Richard Evans Sent: den 19 april 2011 17:37 To: Erlang Questions Subject: [erlang-questions] Dialyzer generating spurious warnings when using the ?assert macro Hi guys, I am going through adding typing to my functions and getting dialyzer to verify everything, which is all working very nicely, apart from one minor grievance: There are two places where I use the ?assert macro, and I believe dialyzer is giving me spurious warnings on these lines: interpretAction({implies, A, C, true}) -> ?assert(xl_string:impliesString(A,C)); interpretAction({implies, A, C, false}) -> ?assert(not xl_string:impliesString(A,C)); These generate the warnings: xl.erl:286: The variable _ can never match since previous clauses completely covered the type 'false' xl.erl:287: The variable _ can never match since previous clauses completely covered the type 'false' I think these are problems with the macro and not with my code. Does anybody have any info on this? I also found this post on the internet, where somebody else seems to have a similar problem: http://erlang.2086793.n4.nabble.com/Eunit-assert-causes-Dialyzer-warning-td2252010.html Any help much appreciated thanks, Richard -------------- next part -------------- An HTML attachment was scrubbed... URL: From dsc@REDACTED Tue Apr 19 18:19:18 2011 From: dsc@REDACTED (Dave Challis) Date: Tue, 19 Apr 2011 17:19:18 +0100 Subject: [erlang-questions] Server which spawns an additional server for each call In-Reply-To: References: <4DAD4EC7.3070607@ecs.soton.ac.uk> <4DADB606.2060009@ecs.soton.ac.uk> Message-ID: Hi Joe, Fantastic, that's pretty much exactly what I was after. I didn't realise I could send a {noreply, X} from a handle_call, and defer the actual reply from a spawned process. The pure erlang version makes it clear what's going on too - gen_server is still a bit of a black box to me I'm afraid. The gen_server I'm using is a wrapper around a C utility which does some parsing (using erlang's port mechanism), and then returns the parsed data to the original function caller. I figured that by having the port initialised when the gen_server process is started, it could respond to client requests right away, rather than being spawned upon request. I was also thinking that by having the C program and port set up at server start time, then any startup errors from it would be caught then, rather than everything appearing to be ok until a client request was made. Thanks, Dave On 19/04/11 16:11, Joe Armstrong wrote: > It's not entirely clear to me what you want to do. I never understand > why people use gen_servers > for everything, pure Erlang is often easier :-) > > I assume you want to delegate the response in the server (ie get some > other process than the > gen server to do the work, since this takes a long time) > > One way to do this is like this: > > Write a client stub like this: > > foo(X) -> > gen_server:call(?Mod, {foo, X}). > > > Write a gen_server handle call method like this: > > handle_call({foo, X}, From, State) -> > State1 = func1(X, State), > State2 = func2(X, State), > spawn_link(fun() -> do_something(State1, X, From) end), > {noreply, State2}. > > do_something(State, X, From) -> > Reply = func3(X, State), > gen_server:reply(From, Reply). > > here I've assumed func1 returns State1 and that State1 is some subset of > State > needed in your computation. State2 (returned by func2) is the > continuation state of the server. > ie the state the server will have after it has received the foo request, > but before the delegated function > has replied. You'll have to write func1 and func2 yourself. > > do_something is the delegated function that might take a long time. The > four lines of > code which define handle_call should return quickly, ie don't do much > here, do the work in > do_something. handle call returns {noreply, State2} which means "don't > reply to the client > but continue with state State2. > > do_something works in parallel with the server and when it has finished > calls gen_server:reply/2 > and at this point the client stub routine foo/1 will return. > > This is only one way of doing this. You could do the complex calculation > inside the client > and request the data you need from the server, the server can spawn a > deligate (as above). > You can use a shared ets table and so on. > > if you were to do this in pure erlang it might be easier to see what's > going on > > Define promise and yield thusly: > > promise(Fun) -> > S = self(), %% this self() is > evaluated *inside* the current function > spawn(fun() -> > S ! {self(), Fun()} %% this self() is evaluated > *inside* the spawned function > end). > > yield(Promise) -> > receive > {Promise, Result} -> Result > end. > > promise takes a Fun argument and returns a promise. The promise is a > promise to > compute the value. The promise can be redeemed by calling yield. So we > can write code like this: > > P = promise(fun() -> fib(40) end), > .... do some other stuff that takes a while ... > Val = yield(Promise) > > So we compute fib(40) which takes a long time in parallel with some > other stuff. > > > The gen_server stuff above has just hidden what is essentially a promise > and yield and > a bit of state trickery in a framework module - nothing tricky about > about it at all. > > Given promise and yield and a dash of list comprehensions we can write > fun stuff like: > > parmap(F, L) -> > Promises = [promise(fun() -> F(I) end || I <- L], > [yield(I) || I <- Promises]. > > which is a parallel mapping function. > > Hope this helps > > /Joe > > > > On Tue, Apr 19, 2011 at 10:58 AM, Dave Challis > wrote: > > Hi, > I'm trying to work out the structure for a small bit of > functionality in erlang. I've got a feeling there's an obvious > solution, but I'm not experienced enough with the language sure what > pattern to best follow... > > So far, I've got a server which implements the gen_server behaviour, > a supervisor for it, and a module containing an API for interacting > with it (using gen_server:call mostly). > > The server does a lot of work though, so blocks for a while until > the call is finished. > > What I'd like to do, is create a new server process each time > gen_server:call is invoked by a client, with each server terminating > when it's done processing (but always leaving 1 server running). > > This means that clients using the API will have their request > processes straight away, without having to wait for all the other > calls to the server to finish. > > I can't quite figure out where to place the logic for doing this though. > > * Should the API module ask the supervisor to spawn a new child, > then send the client's call to this? > * Should API calls go to the supervisor, and have it decide whether > to spawn new servers or send the call to an existing one? > * Or should each server take care of telling the supervisor to spawn > a new child, and pass the call request to the newly spawned one? > > Is this a sensible approach in general, or is there an obvious > pattern or some functionality I've missed? > > Thanks, > > -- > Dave Challis > dsc@REDACTED > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -- Dave Challis dsc@REDACTED From cmcknight@REDACTED Tue Apr 19 19:44:20 2011 From: cmcknight@REDACTED (cmcknight@REDACTED) Date: Tue, 19 Apr 2011 10:44:20 -0700 Subject: [erlang-questions] Defect list Message-ID: <70FCE4C4-2B24-4079-91CE-6586E31BCE5C@pheonic.com> Is there a publicly available view of the Erlang/OTP defect list? Chuck McKnight cmcknight@REDACTED "It's cold outside, there's no kind of atmosphere, I'm all alone, more or less, let me fly far away from here, fun, fun, fun, in the sun, sun, sun" --- Theme Song, Red Dwarf From tuncer.ayaz@REDACTED Tue Apr 19 20:52:18 2011 From: tuncer.ayaz@REDACTED (Tuncer Ayaz) Date: Tue, 19 Apr 2011 20:52:18 +0200 Subject: [erlang-questions] Yaws's "sendfile" linked-in driver : "stealing control of fd" error In-Reply-To: References: <4DAC0C2A.5060705@erix.ericsson.se> Message-ID: To test yaws with sendfile_drv instead of yaws_sendfile_drv get the temporary 'sendfile_drv' branch from my yaws fork and run: $ rebar get-deps compile or $ rebar g-d co $ bin/yaws --conf etc/yaws.conf --pa deps/sendfile/ebin From gregory.haskins@REDACTED Tue Apr 19 22:26:17 2011 From: gregory.haskins@REDACTED (Gregory Haskins) Date: Tue, 19 Apr 2011 16:26:17 -0400 Subject: [erlang-questions] Question about configuring gproc candidate nodes Message-ID: <4DADEFE9.8030005@gmail.com> Hi Ulf, all, I am still struggling to understand perhaps the best practices for managing distributed gproc. Ultimately what I want is to have 1->N controller nodes and an arbitrary number of subordinate nodes that are all part of the same {, g, } gproc namespace. All nodes are booted with an -boot script and therefore automatically load gproc and its dependencies as the system comes up. What I was trying to do was use something like "-gproc gproc_dist "['controller@REDACTED', 'controller@REDACTED']". The problem that I run into is, of course, that on boot, a subordinate node has not yet connected to something like 'controller@REDACTED' yet. Therefore, using that config causes gproc_dist to fallback to local_only mode and thus all {,g,} calls to blow up. I have also tried booting all nodes with 'all', which only steals a snapshot of the current node membership at startup (ala ['localhost']). This allows gproc to enable global mode, but effectively creates disjoint namespaces from the other members and is thus equally breaks my app. So far, the only thing that seems to work is to defer initializing the gproc application until I manually connect to at least one controller in the shell. If I then application:start(gproc), the gproc distribution comes up with a unified namespace, as I would expect. Is there a better way to do this? Kind Regards, -Greg -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 267 bytes Desc: OpenPGP digital signature URL: From gregory.haskins@REDACTED Tue Apr 19 22:51:40 2011 From: gregory.haskins@REDACTED (Gregory Haskins) Date: Tue, 19 Apr 2011 16:51:40 -0400 Subject: [erlang-questions] Question about configuring gproc candidate nodes In-Reply-To: <4DADEFE9.8030005@gmail.com> References: <4DADEFE9.8030005@gmail.com> Message-ID: <4DADF5DC.2000001@gmail.com> On 4/19/11 4:26 PM, Gregory Haskins wrote: > > Is there a better way to do this? > Ok, I think I figured it out after digging through the code. The trick is using the {seed, Node} option, such as: -gproc gproc_dist "{['controller@REDACTED', 'controller@REDACTED'], [{seed, 'controller@REDACTED'}]}". FYI, the ./example/skeleton.erl has a typo: It uses "seed_node" instead of "seed". Kind Regards, -Greg -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 267 bytes Desc: OpenPGP digital signature URL: From robert.virding@REDACTED Tue Apr 19 23:14:04 2011 From: robert.virding@REDACTED (Robert Virding) Date: Tue, 19 Apr 2011 21:14:04 +0000 (GMT) Subject: [erlang-questions] beginner: How should regexp:split/2 be replaced? In-Reply-To: Message-ID: <1107948901.116341303247644721.JavaMail.root@zimbra> Perhaps its because they think that adding/subtracting one is too difficult. Or perhaps it is because they want to adhere to the convention that indexing starts at 0 in spite of that most other erlang things index from 1. Robert ----- "Ahmed Omar" wrote: > I mean i understand it's different indexing, but was there specific reason to change that? > > > On Tue, Apr 19, 2011 at 4:18 PM, Ahmed Omar < spawn.think@REDACTED > wrote: > regexp:split("Hello world, Hello", "[ ]*,[ ]*"). {ok,["Hello world","Hello"]} > re:split("Hello world, Hello", "[ ]*,[ ]*",[{return, list}]). ["Hello world","Hello"] > regexp:matches("Hello \n","\n"). {match,[{7,1}]} > re:run("Hello \n","\n"). {match,[{6,1}]} > but i'm not sure why the start position is different here > > > On Tue, Apr 19, 2011 at 3:30 PM, Bengt Kleberg < bengt.kleberg@REDACTED > wrote: > Greetings, > > I have inherited some code without a test directory. I get the following > compiler warnings: > ./compile_funcs.erl:603: Warning: regexp:split/2: the regexp module is > deprecated (will be removed in R15A); use the re module instead > ./compile_funcs.erl:645: Warning: regexp:matches/2: the regexp module is > deprecated (will be removed in R15A); use the re module instead > > The lines are: > {ok, Class} = regexp:split(Class0, "[ ]*,[ ]*"), > and > {match,A}=regexp:matches(String,"\n"), > > I thought "[ ]*,[ ]*" would mean: > the character class of " " (space), 0 or many times, followed by literal > "," followed by the character class of " " (space), 0 or many times. > > This is not the case and I am not having any luck with randomly > constructing strings to find one that triggers a Class that is different > from Class0. > > Perhaps someone knows what "[ ]*,[ ]*" really means, and what to replace > these with when using the re module. > > > bengt > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > > -- > Best Regards, > - Ahmed Omar http://nl.linkedin.com/in/adiaa Follow me on twitter @spawn_think > > > -- > Best Regards, > - Ahmed Omar http://nl.linkedin.com/in/adiaa Follow me on twitter @spawn_think > > _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From gregory.haskins@REDACTED Tue Apr 19 23:18:20 2011 From: gregory.haskins@REDACTED (Gregory Haskins) Date: Tue, 19 Apr 2011 17:18:20 -0400 Subject: [erlang-questions] Gproc synchronization primitives? Message-ID: <4DADFC1C.9030303@gmail.com> Does any mechanism exist to synchronize with the distribution protocol in gproc? Heres what I am running into at the moment: I have an FSM which runs out at an arbitrary end-point that registers a bunch of {p, g, } properties: https://github.com/ghaskins/edist/blob/6f2ab65114c9f92586d3fed17e463eec5742a070/agent/app/src/main/erlang/session_fsm.erl#L23 Later, that FSM might receive an async event that the "controller" service is now available which compels the FSM process to communicate with that remote process: https://github.com/ghaskins/edist/blob/6f2ab65114c9f92586d3fed17e463eec5742a070/agent/app/src/main/erlang/session_fsm.erl#L30 The problem with my current design is the controller_api:join() RPC is expecting to have visibility to the properties registered in the gproc namespace. Given that the FSM in question and the gproc distribution mechanism are independent entities, I have thus introduced a race condition (and one that almost always loses, I am finding). Here are some possible ways to fix it: 1) some kind of gproc:sync() primitive, or even gproc:sync(Node). Not sure if this already exists, could be easily invented if not, or would be frowned upon? 2) use gproc:await() (and friends) to discover the controller, with the premise being that "if I can see you, you can presumably see me". Not sure if this assumption is true? 3) Stop trying to use gproc in a timing sensitive way? (FWIW: I used to pass the property-list as a parameter in the RPC before I switched over the gproc, which of course did not have the race issue). Any other suggestions? Kind Regards, -Greg -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 267 bytes Desc: OpenPGP digital signature URL: From ulf.wiger@REDACTED Tue Apr 19 23:52:53 2011 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Tue, 19 Apr 2011 23:52:53 +0200 Subject: [erlang-questions] Gproc synchronization primitives? In-Reply-To: <4DADFC1C.9030303@gmail.com> References: <4DADFC1C.9030303@gmail.com> Message-ID: <8DA8B046-E517-41A7-A57E-E3A218D6B88B@erlang-solutions.com> Hi Greg, I've been thinking about adding such a function, so? Try the new version I just pushed (v0.2.3), and see if it helps. gproc_dist:sync() is the function to call. As a general comment, at least gen_leader ensures that replication happens before the reply is delivered to a leader_call(). This is so that the caller should not be surprised by the newly written data not being there when the call returns. BR, Ulf W On 19 Apr 2011, at 23:18, Gregory Haskins wrote: > Does any mechanism exist to synchronize with the distribution protocol > in gproc? Heres what I am running into at the moment: > > I have an FSM which runs out at an arbitrary end-point that registers a > bunch of {p, g, } properties: > > https://github.com/ghaskins/edist/blob/6f2ab65114c9f92586d3fed17e463eec5742a070/agent/app/src/main/erlang/session_fsm.erl#L23 > > Later, that FSM might receive an async event that the "controller" > service is now available which compels the FSM process to communicate > with that remote process: > > https://github.com/ghaskins/edist/blob/6f2ab65114c9f92586d3fed17e463eec5742a070/agent/app/src/main/erlang/session_fsm.erl#L30 > > The problem with my current design is the controller_api:join() RPC is > expecting to have visibility to the properties registered in the gproc > namespace. Given that the FSM in question and the gproc distribution > mechanism are independent entities, I have thus introduced a race > condition (and one that almost always loses, I am finding). > > Here are some possible ways to fix it: > > 1) some kind of gproc:sync() primitive, or even gproc:sync(Node). Not > sure if this already exists, could be easily invented if not, or would > be frowned upon? > > 2) use gproc:await() (and friends) to discover the controller, with the > premise being that "if I can see you, you can presumably see me". Not > sure if this assumption is true? > > 3) Stop trying to use gproc in a timing sensitive way? (FWIW: I used to > pass the property-list as a parameter in the RPC before I switched over > the gproc, which of course did not have the race issue). > > Any other suggestions? > > Kind Regards, > -Greg > Ulf Wiger, CTO, Erlang Solutions, Ltd. http://erlang-solutions.com From sigmastar@REDACTED Wed Apr 20 02:01:10 2011 From: sigmastar@REDACTED (Jesse Gumm) Date: Tue, 19 Apr 2011 19:01:10 -0500 Subject: [erlang-questions] Web Frameworks: which to choose? In-Reply-To: <7A50AC3D-B2C1-4B01-9B32-9210C223613C@worrell.nl> References: <4DAC5AFD.4040709@gmail.com> <7A50AC3D-B2C1-4B01-9B32-9210C223613C@worrell.nl> Message-ID: Thanks Marc, I have one quick question about Zotonic. To what extent is Zotonic kept up to date with respect to Nitrogen? Do you regularly port new things in, or since Zotonic has so many other things in it that aren't Nitrogen that it's more of a fork of Nitrogen as it was in 1.0? Forgive my ignorance of this. I've known about Zotonic for a while, I've just never sat down and tinkered with it beyond looking at some of the code once or twice. -Jesse On Mon, Apr 18, 2011 at 1:32 PM, Marc Worrell wrote: > > On Apr 18, 2011, at 20:16 , Jesse Gumm wrote: > >> Here's my vote for Nitrogen. ?I've been working with Nitrogen for >> close to two years now, and I quite enjoy it. >> >> And Webmachine support was recently added to Nitrogen, so as far as I >> know, you can indeed add some REST-type stuff there, but I haven't >> ever tinkered with Webmachine so I can't speak at all about it. > > Didn't mention it, but Zotonic is also based on Webmachine. > Webmachine is the best HTTP protocol handler ever. > >> I gave a talk a few months ago about Nitrogen. ?Here are the slides >> (they should work for Nitrogen 2.0.2, but things changed in 2.0.4): >> https://docs.google.com/present/view?id=dc37wnrq_7hqpqc6gv >> >> -Jesse >> >> On Mon, Apr 18, 2011 at 12:53 PM, Kenny Stone wrote: >>> Why not fold in the enhancements from zotonic the framework into nitrogen >>> and keep zotonic just the CMS part? ?I'm not criticizing, just curious :) >>> Kenny > > Not doable, Zotonic drifted too far from Nitrogen. > > For starters we removed the use of the process dictionary and then added templates (enhanced ErlyDTL), modules, WebSockets, e-mail (gen_smtp), database (epgsql), xmpp pubsub, template selectors, virtual hosts, etc. etc. ?And everything HTTP is built on top of Webmachine. > > The people working with Zotonic are not only programmers but also frontenders. There are some frontenders building websites without even touching the Erlang code. ?See http://timbenniks.nl/ who made multiple Zotonic sites. ?An example of a website where programming was involved is http://www.maxclass.com/ > > In Zotonic all Nitrogen actions, validators, postbacks etc can be specified in the template by the template builder. ?There is even a signal/slot module (mod_signal by Maas-Maarten Zeeman) to let web pages send messages to each other without programming. > > But... it is a choice. ?Do you want to make your templates in Erlang? ?Then use Nitrogen. ?Do you want a frontender to make your templates? ?Then you need something like Zotonic or another framework with a template engine. > > - Marc > > -- Jesse Gumm Sigma Star Systems 414.940.4866 gumm@REDACTED http://www.sigma-star.com From gregory.haskins@REDACTED Wed Apr 20 02:21:20 2011 From: gregory.haskins@REDACTED (Gregory Haskins) Date: Tue, 19 Apr 2011 20:21:20 -0400 Subject: [erlang-questions] Gproc synchronization primitives? In-Reply-To: <8DA8B046-E517-41A7-A57E-E3A218D6B88B@erlang-solutions.com> References: <4DADFC1C.9030303@gmail.com> <8DA8B046-E517-41A7-A57E-E3A218D6B88B@erlang-solutions.com> Message-ID: <92140519-FF88-4A8C-B73F-91F741900607@gmail.com> On Apr 19, 2011, at 5:52 PM, Ulf Wiger wrote: > > Hi Greg, > > I've been thinking about adding such a function, so? > > Try the new version I just pushed (v0.2.3), and see if it helps. > Cool, thanks for your super responsiveness on all this! > gproc_dist:sync() is the function to call. I updated and added the code, but I ran into a potentially unrelated snag before I could verify if this fixed the issue. That is: (agent@REDACTED)23> Pid. <0.73.0> (agent@REDACTED)24> qlc:e(qlc:q([{P, K, V} || {{p, g, {edist_fact, K}}, P, V} <- gproc:table(props), K =:= "hostname"])). [{<0.73.0>,"hostname","linux-mp"}] (agent@REDACTED)25> qlc:e(qlc:q([{P, K, V} || {{p, g, {edist_fact, K}}, P, V} <- gproc:table(props), P =:= Pid])). [] I would have expected the last run to return quite a few matches, but I got 0. I haven't traced the gproc code yet to see if I can figure out what is happening, but it appears as though my guard expression against the PID is not working. Do you spy anything I am doing wrong in the QLC, or would you expect this to work? (As an aside, I may have mis-diagnosed the sync() problem since I _thought_ the empty set was being returned because of (lack of) sync. In retrospect, it was probably this guard problem instead. That said, I think the sync() feature is a good one in general, so im glad it was implemented. Thanks again for all the help and fast turn around on the code/questions. Appreciated! -Greg > > As a general comment, at least gen_leader ensures that replication happens before the reply is delivered to a leader_call(). This is so that the caller should not be surprised by the newly written data not being there when the call returns. > > BR, > Ulf W > > On 19 Apr 2011, at 23:18, Gregory Haskins wrote: > >> Does any mechanism exist to synchronize with the distribution protocol >> in gproc? Heres what I am running into at the moment: >> >> I have an FSM which runs out at an arbitrary end-point that registers a >> bunch of {p, g, } properties: >> >> https://github.com/ghaskins/edist/blob/6f2ab65114c9f92586d3fed17e463eec5742a070/agent/app/src/main/erlang/session_fsm.erl#L23 >> >> Later, that FSM might receive an async event that the "controller" >> service is now available which compels the FSM process to communicate >> with that remote process: >> >> https://github.com/ghaskins/edist/blob/6f2ab65114c9f92586d3fed17e463eec5742a070/agent/app/src/main/erlang/session_fsm.erl#L30 >> >> The problem with my current design is the controller_api:join() RPC is >> expecting to have visibility to the properties registered in the gproc >> namespace. Given that the FSM in question and the gproc distribution >> mechanism are independent entities, I have thus introduced a race >> condition (and one that almost always loses, I am finding). >> >> Here are some possible ways to fix it: >> >> 1) some kind of gproc:sync() primitive, or even gproc:sync(Node). Not >> sure if this already exists, could be easily invented if not, or would >> be frowned upon? >> >> 2) use gproc:await() (and friends) to discover the controller, with the >> premise being that "if I can see you, you can presumably see me". Not >> sure if this assumption is true? >> >> 3) Stop trying to use gproc in a timing sensitive way? (FWIW: I used to >> pass the property-list as a parameter in the RPC before I switched over >> the gproc, which of course did not have the race issue). >> >> Any other suggestions? >> >> Kind Regards, >> -Greg >> > > Ulf Wiger, CTO, Erlang Solutions, Ltd. > http://erlang-solutions.com > > > From gregory.haskins@REDACTED Wed Apr 20 03:30:47 2011 From: gregory.haskins@REDACTED (Gregory Haskins) Date: Tue, 19 Apr 2011 21:30:47 -0400 Subject: [erlang-questions] Gproc synchronization primitives? In-Reply-To: <92140519-FF88-4A8C-B73F-91F741900607@gmail.com> References: <4DADFC1C.9030303@gmail.com> <8DA8B046-E517-41A7-A57E-E3A218D6B88B@erlang-solutions.com> <92140519-FF88-4A8C-B73F-91F741900607@gmail.com> Message-ID: <1C6F6874-B663-4C98-98F2-A59711222540@gmail.com> On Apr 19, 2011, at 8:21 PM, Gregory Haskins wrote: >> > > I updated and added the code, but I ran into a potentially unrelated snag before I could verify if this fixed the issue. That is: > > (agent@REDACTED)23> Pid. > <0.73.0> > (agent@REDACTED)24> qlc:e(qlc:q([{P, K, V} || {{p, g, {edist_fact, K}}, P, V} <- gproc:table(props), K =:= "hostname"])). > [{<0.73.0>,"hostname","linux-mp"}] > (agent@REDACTED)25> qlc:e(qlc:q([{P, K, V} || {{p, g, {edist_fact, K}}, P, V} <- gproc:table(props), P =:= Pid])). > [] It looks like "P == Pid" does in fact work. I am not clear if the problem with using =:= is gproc, erlang/qlc, or "pilot error" specific, but that does seem the be the problem in this case. BTW: I did in fact confirm that the sync() in v0.2.3 seems to be working fine, thanks! -Greg -------------- next part -------------- An HTML attachment was scrubbed... URL: From kuleshovmail@REDACTED Wed Apr 20 09:06:40 2011 From: kuleshovmail@REDACTED (Alexander Kuleshov) Date: Wed, 20 Apr 2011 07:06:40 +0000 Subject: [erlang-questions] globaal gen_server stop Message-ID: Hello, I have gen_server: .... start(User) when is_atom(User) -> case gen_server:start({global, User}, server, [], []) of {ok, _} -> io:format(User ++ " started"); {error, Error} -> Error end. ..... My stop function: stop(User) -> gen_server:cast(User, stop). handle_cast(stop, State) -> {stop, normal, State}; handle_cast(_Msg, State) -> {noreply, State}. I run it: (emacs@REDACTED)199> server:start(asd). asd started (emacs@REDACTED)200> server:stop(asd). ok (emacs@REDACTED)201> server:start(asd). {already_started,<0.688.0>} How can i stop global gen_server by User parameter? Thank you. From raimo+erlang-questions@REDACTED Wed Apr 20 09:08:37 2011 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Wed, 20 Apr 2011 09:08:37 +0200 Subject: [erlang-questions] beginner: How should regexp:split/2 be replaced? In-Reply-To: <1107948901.116341303247644721.JavaMail.root@zimbra> References: <1107948901.116341303247644721.JavaMail.root@zimbra> Message-ID: <20110420070837.GA5590@erix.ericsson.se> On Tue, Apr 19, 2011 at 09:14:04PM +0000, Robert Virding wrote: > Perhaps its because they think that adding/subtracting one is too difficult. Or perhaps it is because they want to adhere to the convention that indexing starts at 0 in spite of that most other erlang things index from 1. > > Robert > It was zero-based in EEP 11 http://www.erlang.org/eeps/eep-0011.html and there was no discussion about that EEP. This also surfaced in a diskussion about EEP 31: http://erlang.org/pipermail/eeps/2009-December/000278.html Patrik Nyblom wrote: > > Robert Virding wrote: > > > > - It seems like 'binary' indexes binaries from 0. Is this wise? While > > indexing them from 1 may not have been a good choice having two different > > standards must surely be much worse and be a source of future confusion. I > > know that 're' does this but I think that was a bad mistake! > > We (OTP), reluctantly, made the decision to have zero-based indices as a > rule for binary-oriented modules although Erlang is traditionally > one-based. The reason beeing foremost the hassle of > using one-based indices in bit syntax (the only thing you can make with a > one based index is to make it zero based, it's useless in bit-syntax until > that is done). Having different bases in different binary-oriented modules > would add to the confusion (and make for a less convenient interface). > So, the design relu is now that all indices in binaries are zero-based. I > obviously won't make this module an exception. > End of quote Patrik Nyblom. The array module is also zero based. http://www.erlang.org/doc/man/array.html / Raimo Niskanen > ----- "Ahmed Omar" wrote: > > I mean i understand it's different indexing, but was there specific reason to change that? > > > > > > On Tue, Apr 19, 2011 at 4:18 PM, Ahmed Omar < spawn.think@REDACTED > wrote: > > > > > > regexp:split("Hello world, Hello", "[ ]*,[ ]*"). > {ok,["Hello world","Hello"]} > > > > re:split("Hello world, Hello", "[ ]*,[ ]*",[{return, list}]). > ["Hello world","Hello"] > > > > > regexp:matches("Hello \n","\n"). > {match,[{7,1}]} > > > > re:run("Hello \n","\n"). > {match,[{6,1}]} > > > > but i'm not sure why the start position is different here > > > > > > > > On Tue, Apr 19, 2011 at 3:30 PM, Bengt Kleberg < bengt.kleberg@REDACTED > wrote: > > > > Greetings, > > > > I have inherited some code without a test directory. I get the following > > compiler warnings: > > ./compile_funcs.erl:603: Warning: regexp:split/2: the regexp module is > > deprecated (will be removed in R15A); use the re module instead > > ./compile_funcs.erl:645: Warning: regexp:matches/2: the regexp module is > > deprecated (will be removed in R15A); use the re module instead > > > > The lines are: > > {ok, Class} = regexp:split(Class0, "[ ]*,[ ]*"), > > and > > {match,A}=regexp:matches(String,"\n"), > > > > I thought "[ ]*,[ ]*" would mean: > > the character class of " " (space), 0 or many times, followed by literal > > "," followed by the character class of " " (space), 0 or many times. > > > > This is not the case and I am not having any luck with randomly > > constructing strings to find one that triggers a Class that is different > > from Class0. > > > > Perhaps someone knows what "[ ]*,[ ]*" really means, and what to replace > > these with when using the re module. > > > > > > bengt > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > > > -- > > Best Regards, > > - Ahmed Omar > http://nl.linkedin.com/in/adiaa > Follow me on twitter > @spawn_think > > > > > > > -- > > Best Regards, > > - Ahmed Omar > http://nl.linkedin.com/in/adiaa > Follow me on twitter > @spawn_think > > > > _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://erlang.org/mailman/listinfo/erlang-questions > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From essiene@REDACTED Wed Apr 20 09:16:13 2011 From: essiene@REDACTED (Essien Essien) Date: Wed, 20 Apr 2011 08:16:13 +0100 Subject: [erlang-questions] globaal gen_server stop In-Reply-To: References: Message-ID: On Wed, Apr 20, 2011 at 8:06 AM, Alexander Kuleshov wrote: > Hello, > > I have gen_server: > > .... > start(User) when is_atom(User) -> > ? ?case gen_server:start({global, User}, server, [], []) of > ? ? ? ?{ok, _} -> > ? ? ? ? ? ?io:format(User ++ " started"); > ? ? ? ?{error, Error} -> > ? ? ? ? ? ?Error > ? ?end. > ..... > > My stop function: > > stop(User) -> > ? ?gen_server:cast(User, stop). >From the man page, when calling global gen_server, server ref must be {global, Name}, so: gen_server:cast({global, User}, stop). > > handle_cast(stop, State) -> > ? ?{stop, normal, State}; > handle_cast(_Msg, State) -> > ? ?{noreply, State}. > > I run it: > > (emacs@REDACTED)199> server:start(asd). > asd started > (emacs@REDACTED)200> server:stop(asd). > ok > (emacs@REDACTED)201> server:start(asd). > {already_started,<0.688.0>} > > How can i stop global gen_server by User parameter? > > Thank you. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > From erlang@REDACTED Wed Apr 20 10:05:52 2011 From: erlang@REDACTED (Joe Armstrong) Date: Wed, 20 Apr 2011 10:05:52 +0200 Subject: [erlang-questions] The gen server simplified (how it works) Message-ID: Many users seem to use the gen_server for absolutely everything and often force their problems to fit the gen_sever even though the gen_server is not appropriate for their problems. The gen_server is an extremely simple bit of code which can be easily changed to fit other problems, though people don't often do this. In this posting I'll explain the basic idea of how the gen_server works. To illustrate this I've written mini_gs.erl - this is a mini gen_server if you understand mini_gs.erl you'll have understood 98% of how the real gen_server works. The real gen_server just adds a load of "bells and whistles" to mini_gs.erl. mini_gs.erl has a compatible interface to gen_server.erl (for a subset of the gen_server API) -module(mini_gs). -export([start_link/4, call/2]). %% this module behaves just like the gen-server for a sub-set of the gen_server %% commands start_link({local,Name}, Mod, Args, _Opts) -> register(Name, spawn(fun() -> start(Mod, Args) end)). call(Name, X) -> Name ! {self(), Ref = make_ref(), X}, receive {Ref, Reply} -> Reply end. start(Mod, Args) -> {ok, State} = Mod:init(Args), loop(Mod, State). loop(Mod, State) -> receive {From, Tag, X} -> case Mod:handle_call(X, From, State) of {reply, R, State1} -> From ! {Tag, R}, loop(Mod, State1) end end. There. That wasn't so painful. The client starts by calling min_gs:start_link({local,Name}, Mod, Args, Opts) I've ignored Opts in mini_gs, also frozen the name of the server to be of the form {local, Name} (gen_server has more general arguments for the name of the server) What happens? mini_gs calls Mod:init(Args) to initialize the server, this must return {ok, State} and State becomes the initial state of the server. Now mini_gs calls loop(Mod, State.) When mini_gs receives a message {From, Tag, X} it calls Mod:handle_call(X, From, State) which returns {repy, R, State1}. R1 is sent back to the client, and the server calls loop/2 with the new state State1. That's it. call/2 is an interface routine to abstract out the interface between the client and the sever. Now we can write a simple client application. -module(kv). %% These define the client API -export([start/0, store/2,lookup/1]). %% these must be defined because they are called by gs -export([init/1, handle_call/3]). -define(GS, mini_gs). %% -define(GS, gen_server). %% define the client API start() -> ?GS:start_link({local,someatom}, kv, foo, []). store(Key,Val) -> ?GS:call(someatom, {putval,Key,Val}). lookup(Key) -> ?GS:call(someatom, {getval,Key}). %% define the internal routines init(foo) -> {ok, dict:new()}. handle_call({putval, Key, Val}, _From, Dict) -> {reply, ok, dict:store(Key, Val, Dict)}; handle_call({getval,Key}, _From, Dict) -> {reply, dict:find(Key, Dict), Dict}. This module can call either gen_server or mini_gs (just change the define statement) So now we have turned a single process key-value store (using dict) into a global key-value store. Note that kv.erl never uses the primitives spawn_link, send, receive or do on. ie kv.erl is written with pure *sequential* code. This is *why* we made the gen_server abstraction. You can write well-typed sequential code (the handle_call and init functions) to parametrize a concurrent behavior, ie you need to know nothing about concurrency to get the job done. We've "abstracted out" the concurrency. Things become problematic when you do not entirely understand the abstraction. Maybe the abstraction is inappropriate for your needs. I have seen many examples of code where the gen_server *is* inappropriate. The acid test is "does the gen_sever code look like spaghetti" if the answer is yes then all you have done is shoe horn the applications into an inappropriate form. In this case you should ditch the gen_server and roll-your own. /Joe -------------- next part -------------- An HTML attachment was scrubbed... URL: From erlang@REDACTED Wed Apr 20 10:11:49 2011 From: erlang@REDACTED (Joe Armstrong) Date: Wed, 20 Apr 2011 10:11:49 +0200 Subject: [erlang-questions] Server which spawns an additional server for each call In-Reply-To: References: <4DAD4EC7.3070607@ecs.soton.ac.uk> <4DADB606.2060009@ecs.soton.ac.uk> Message-ID: On Tue, Apr 19, 2011 at 6:19 PM, Dave Challis wrote: > Hi Joe, > Fantastic, that's pretty much exactly what I was after. I didn't realise I > could send a {noreply, X} from a handle_call, and defer the actual reply > from a spawned process. > > The pure erlang version makes it clear what's going on too - gen_server is > still a bit of a black box to me I'm afraid. > Oh dear - this frightens me - I've started a new thread to explain just exactly how simple the gen_server is - pleas read it > > The gen_server I'm using is a wrapper around a C utility which does some > parsing (using erlang's port mechanism), and then returns the parsed data to > the original function caller. > > Just to satisfy my curiosity, why C? did you try this in pure Erlang first? /Joe > I figured that by having the port initialised when the gen_server process > is started, it could respond to client requests right away, rather than > being spawned upon request. > > I was also thinking that by having the C program and port set up at server > start time, then any startup errors from it would be caught then, rather > than everything appearing to be ok until a client request was made. > > Thanks, > Dave > > > On 19/04/11 16:11, Joe Armstrong wrote: > >> It's not entirely clear to me what you want to do. I never understand >> why people use gen_servers >> for everything, pure Erlang is often easier :-) >> >> I assume you want to delegate the response in the server (ie get some >> other process than the >> gen server to do the work, since this takes a long time) >> >> One way to do this is like this: >> >> Write a client stub like this: >> >> foo(X) -> >> gen_server:call(?Mod, {foo, X}). >> >> >> Write a gen_server handle call method like this: >> >> handle_call({foo, X}, From, State) -> >> State1 = func1(X, State), >> State2 = func2(X, State), >> spawn_link(fun() -> do_something(State1, X, From) end), >> {noreply, State2}. >> >> do_something(State, X, From) -> >> Reply = func3(X, State), >> gen_server:reply(From, Reply). >> >> here I've assumed func1 returns State1 and that State1 is some subset of >> State >> needed in your computation. State2 (returned by func2) is the >> continuation state of the server. >> ie the state the server will have after it has received the foo request, >> but before the delegated function >> has replied. You'll have to write func1 and func2 yourself. >> >> do_something is the delegated function that might take a long time. The >> four lines of >> code which define handle_call should return quickly, ie don't do much >> here, do the work in >> do_something. handle call returns {noreply, State2} which means "don't >> reply to the client >> but continue with state State2. >> >> do_something works in parallel with the server and when it has finished >> calls gen_server:reply/2 >> and at this point the client stub routine foo/1 will return. >> >> This is only one way of doing this. You could do the complex calculation >> inside the client >> and request the data you need from the server, the server can spawn a >> deligate (as above). >> You can use a shared ets table and so on. >> >> if you were to do this in pure erlang it might be easier to see what's >> going on >> >> Define promise and yield thusly: >> >> promise(Fun) -> >> S = self(), %% this self() is >> evaluated *inside* the current function >> spawn(fun() -> >> S ! {self(), Fun()} %% this self() is evaluated >> *inside* the spawned function >> end). >> >> yield(Promise) -> >> receive >> {Promise, Result} -> Result >> end. >> >> promise takes a Fun argument and returns a promise. The promise is a >> promise to >> compute the value. The promise can be redeemed by calling yield. So we >> can write code like this: >> >> P = promise(fun() -> fib(40) end), >> .... do some other stuff that takes a while ... >> Val = yield(Promise) >> >> So we compute fib(40) which takes a long time in parallel with some >> other stuff. >> >> >> The gen_server stuff above has just hidden what is essentially a promise >> and yield and >> a bit of state trickery in a framework module - nothing tricky about >> about it at all. >> >> Given promise and yield and a dash of list comprehensions we can write >> fun stuff like: >> >> parmap(F, L) -> >> Promises = [promise(fun() -> F(I) end || I <- L], >> [yield(I) || I <- Promises]. >> >> which is a parallel mapping function. >> >> Hope this helps >> >> /Joe >> >> >> >> On Tue, Apr 19, 2011 at 10:58 AM, Dave Challis > > wrote: >> >> Hi, >> I'm trying to work out the structure for a small bit of >> functionality in erlang. I've got a feeling there's an obvious >> solution, but I'm not experienced enough with the language sure what >> pattern to best follow... >> >> So far, I've got a server which implements the gen_server behaviour, >> a supervisor for it, and a module containing an API for interacting >> with it (using gen_server:call mostly). >> >> The server does a lot of work though, so blocks for a while until >> the call is finished. >> >> What I'd like to do, is create a new server process each time >> gen_server:call is invoked by a client, with each server terminating >> when it's done processing (but always leaving 1 server running). >> >> This means that clients using the API will have their request >> processes straight away, without having to wait for all the other >> calls to the server to finish. >> >> I can't quite figure out where to place the logic for doing this >> though. >> >> * Should the API module ask the supervisor to spawn a new child, >> then send the client's call to this? >> * Should API calls go to the supervisor, and have it decide whether >> to spawn new servers or send the call to an existing one? >> * Or should each server take care of telling the supervisor to spawn >> a new child, and pass the call request to the newly spawned one? >> >> Is this a sensible approach in general, or is there an obvious >> pattern or some functionality I've missed? >> >> Thanks, >> >> -- >> Dave Challis >> dsc@REDACTED >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> >> http://erlang.org/mailman/listinfo/erlang-questions >> >> >> > > -- > Dave Challis > dsc@REDACTED > -------------- next part -------------- An HTML attachment was scrubbed... URL: From yuchao1@REDACTED Wed Apr 20 10:14:19 2011 From: yuchao1@REDACTED (=?UTF-8?B?5L2Z6LaF?=) Date: Wed, 20 Apr 2011 16:14:19 +0800 Subject: [erlang-questions] Server which spawns an additional server for each call In-Reply-To: References: <4DAD4EC7.3070607@ecs.soton.ac.uk> <4DADB606.2060009@ecs.soton.ac.uk> Message-ID: <4DAE95DB.7020608@staff.sina.com.cn> Hi Joe: I have some question in my work now . this letter so quick!! ? 2011/4/20 16:11, Joe Armstrong ??: > > > On Tue, Apr 19, 2011 at 6:19 PM, Dave Challis > wrote: > > Hi Joe, > Fantastic, that's pretty much exactly what I was after. I didn't > realise I could send a {noreply, X} from a handle_call, and defer > the actual reply from a spawned process. > > The pure erlang version makes it clear what's going on too - > gen_server is still a bit of a black box to me I'm afraid. > > > Oh dear - this frightens me - I've started a new thread to explain > just exactly how simple the > gen_server is - pleas read it > > > The gen_server I'm using is a wrapper around a C utility which > does some parsing (using erlang's port mechanism), and then > returns the parsed data to the original function caller. > > > Just to satisfy my curiosity, why C? did you try this in pure Erlang > first? > > > /Joe > > I figured that by having the port initialised when the gen_server > process is started, it could respond to client requests right > away, rather than being spawned upon request. > > I was also thinking that by having the C program and port set up > at server start time, then any startup errors from it would be > caught then, rather than everything appearing to be ok until a > client request was made. > > Thanks, > Dave > > > On 19/04/11 16:11, Joe Armstrong wrote: > > It's not entirely clear to me what you want to do. I never > understand > why people use gen_servers > for everything, pure Erlang is often easier :-) > > I assume you want to delegate the response in the server (ie > get some > other process than the > gen server to do the work, since this takes a long time) > > One way to do this is like this: > > Write a client stub like this: > > foo(X) -> > gen_server:call(?Mod, {foo, X}). > > > Write a gen_server handle call method like this: > > handle_call({foo, X}, From, State) -> > State1 = func1(X, State), > State2 = func2(X, State), > spawn_link(fun() -> do_something(State1, X, From) end), > {noreply, State2}. > > do_something(State, X, From) -> > Reply = func3(X, State), > gen_server:reply(From, Reply). > > here I've assumed func1 returns State1 and that State1 is some > subset of > State > needed in your computation. State2 (returned by func2) is the > continuation state of the server. > ie the state the server will have after it has received the > foo request, > but before the delegated function > has replied. You'll have to write func1 and func2 yourself. > > do_something is the delegated function that might take a long > time. The > four lines of > code which define handle_call should return quickly, ie don't > do much > here, do the work in > do_something. handle call returns {noreply, State2} which > means "don't > reply to the client > but continue with state State2. > > do_something works in parallel with the server and when it has > finished > calls gen_server:reply/2 > and at this point the client stub routine foo/1 will return. > > This is only one way of doing this. You could do the complex > calculation > inside the client > and request the data you need from the server, the server can > spawn a > deligate (as above). > You can use a shared ets table and so on. > > if you were to do this in pure erlang it might be easier to > see what's > going on > > Define promise and yield thusly: > > promise(Fun) -> > S = self(), %% this self() is > evaluated *inside* the current function > spawn(fun() -> > S ! {self(), Fun()} %% this self() is > evaluated > *inside* the spawned function > end). > > yield(Promise) -> > receive > {Promise, Result} -> Result > end. > > promise takes a Fun argument and returns a promise. The > promise is a > promise to > compute the value. The promise can be redeemed by calling > yield. So we > can write code like this: > > P = promise(fun() -> fib(40) end), > .... do some other stuff that takes a while ... > Val = yield(Promise) > > So we compute fib(40) which takes a long time in parallel with > some > other stuff. > > > The gen_server stuff above has just hidden what is essentially > a promise > and yield and > a bit of state trickery in a framework module - nothing tricky > about > about it at all. > > Given promise and yield and a dash of list comprehensions we > can write > fun stuff like: > > parmap(F, L) -> > Promises = [promise(fun() -> F(I) end || I <- L], > [yield(I) || I <- Promises]. > > which is a parallel mapping function. > > Hope this helps > > /Joe > > > > On Tue, Apr 19, 2011 at 10:58 AM, Dave Challis > > >> wrote: > > Hi, > I'm trying to work out the structure for a small bit of > functionality in erlang. I've got a feeling there's an obvious > solution, but I'm not experienced enough with the language > sure what > pattern to best follow... > > So far, I've got a server which implements the gen_server > behaviour, > a supervisor for it, and a module containing an API for > interacting > with it (using gen_server:call mostly). > > The server does a lot of work though, so blocks for a while > until > the call is finished. > > What I'd like to do, is create a new server process each time > gen_server:call is invoked by a client, with each server > terminating > when it's done processing (but always leaving 1 server > running). > > This means that clients using the API will have their request > processes straight away, without having to wait for all the > other > calls to the server to finish. > > I can't quite figure out where to place the logic for doing > this though. > > * Should the API module ask the supervisor to spawn a new > child, > then send the client's call to this? > * Should API calls go to the supervisor, and have it decide > whether > to spawn new servers or send the call to an existing one? > * Or should each server take care of telling the supervisor > to spawn > a new child, and pass the call request to the newly spawned > one? > > Is this a sensible approach in general, or is there an obvious > pattern or some functionality I've missed? > > Thanks, > > -- > Dave Challis > dsc@REDACTED > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > > > > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > -- > Dave Challis > dsc@REDACTED > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -- Best Regards, ?? YuChao UC:yuchao86@REDACTED ????? ?????? ????8610?62676661 ???13466539920 MSN:yuchao86@REDACTED ??????????????58???????15?22-2 ___________________________________________ http://www.sina.com.cn You're the one ??.?? ?????? -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf.wiger@REDACTED Wed Apr 20 10:27:33 2011 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Wed, 20 Apr 2011 10:27:33 +0200 Subject: [erlang-questions] Gproc synchronization primitives? In-Reply-To: <1C6F6874-B663-4C98-98F2-A59711222540@gmail.com> References: <4DADFC1C.9030303@gmail.com> <8DA8B046-E517-41A7-A57E-E3A218D6B88B@erlang-solutions.com> <92140519-FF88-4A8C-B73F-91F741900607@gmail.com> <1C6F6874-B663-4C98-98F2-A59711222540@gmail.com> Message-ID: <7A573079-5929-4364-8AF3-C1EAC0C845F7@erlang-solutions.com> Hi Greg, This is interesting - it looks as if QLC doesn't give gproc the chance to rewrite the match specification when there is a '=:=' instead of a '==' in the guard. Perhaps there is some subtle option in QLC which could save the day? It would require some digging into manuals, or a helpful tip from Hans Bolinder. BR, Ulf W On 20 Apr 2011, at 03:30, Gregory Haskins wrote: > > On Apr 19, 2011, at 8:21 PM, Gregory Haskins wrote: >>> >> >> I updated and added the code, but I ran into a potentially unrelated snag before I could verify if this fixed the issue. That is: >> >> (agent@REDACTED)23> Pid. >> <0.73.0> >> (agent@REDACTED)24> qlc:e(qlc:q([{P, K, V} || {{p, g, {edist_fact, K}}, P, V} <- gproc:table(props), K =:= "hostname"])). >> [{<0.73.0>,"hostname","linux-mp"}] >> (agent@REDACTED)25> qlc:e(qlc:q([{P, K, V} || {{p, g, {edist_fact, K}}, P, V} <- gproc:table(props), P =:= Pid])). >> [] > > It looks like "P == Pid" does in fact work. I am not clear if the problem with using =:= is gproc, erlang/qlc, or "pilot error" specific, but that does seem the be the problem in this case. > > BTW: I did in fact confirm that the sync() in v0.2.3 seems to be working fine, thanks! > > -Greg Ulf Wiger, CTO, Erlang Solutions, Ltd. http://erlang-solutions.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf.wiger@REDACTED Wed Apr 20 11:03:45 2011 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Wed, 20 Apr 2011 11:03:45 +0200 Subject: [erlang-questions] Gproc synchronization primitives? In-Reply-To: <7A573079-5929-4364-8AF3-C1EAC0C845F7@erlang-solutions.com> References: <4DADFC1C.9030303@gmail.com> <8DA8B046-E517-41A7-A57E-E3A218D6B88B@erlang-solutions.com> <92140519-FF88-4A8C-B73F-91F741900607@gmail.com> <1C6F6874-B663-4C98-98F2-A59711222540@gmail.com> <7A573079-5929-4364-8AF3-C1EAC0C845F7@erlang-solutions.com> Message-ID: <31E495B1-083D-428E-9B34-B73C9C33D5B5@erlang-solutions.com> Never mind, but thank you Hans for offering to help. When matching on pid, with the first part of the key unbound, gproc rewrites it to a match on the reverse mapping instead, followed by explicit lookups on the actual objects in the found set. A while ago, I changed the representation of the reverse mapping, but forgot to rewrite the qlc query. The newly pushed version should fix the problem. I'll remove the compilation warning later. :) BR, Ulf W On 20 Apr 2011, at 10:27, Ulf Wiger wrote: > > Hi Greg, > > This is interesting - it looks as if QLC doesn't give gproc the chance to rewrite the match specification when there is a '=:=' instead of a '==' in the guard. > > Perhaps there is some subtle option in QLC which could save the day? It would require some digging into manuals, or a helpful tip from Hans Bolinder. > > BR, > Ulf W > > On 20 Apr 2011, at 03:30, Gregory Haskins wrote: > >> >> On Apr 19, 2011, at 8:21 PM, Gregory Haskins wrote: >>>> >>> >>> I updated and added the code, but I ran into a potentially unrelated snag before I could verify if this fixed the issue. That is: >>> >>> (agent@REDACTED)23> Pid. >>> <0.73.0> >>> (agent@REDACTED)24> qlc:e(qlc:q([{P, K, V} || {{p, g, {edist_fact, K}}, P, V} <- gproc:table(props), K =:= "hostname"])). >>> [{<0.73.0>,"hostname","linux-mp"}] >>> (agent@REDACTED)25> qlc:e(qlc:q([{P, K, V} || {{p, g, {edist_fact, K}}, P, V} <- gproc:table(props), P =:= Pid])). >>> [] >> >> It looks like "P == Pid" does in fact work. I am not clear if the problem with using =:= is gproc, erlang/qlc, or "pilot error" specific, but that does seem the be the problem in this case. >> >> BTW: I did in fact confirm that the sync() in v0.2.3 seems to be working fine, thanks! >> >> -Greg > > Ulf Wiger, CTO, Erlang Solutions, Ltd. > http://erlang-solutions.com > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions Ulf Wiger, CTO, Erlang Solutions, Ltd. http://erlang-solutions.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From erlang@REDACTED Wed Apr 20 12:16:26 2011 From: erlang@REDACTED (Joe Armstrong) Date: Wed, 20 Apr 2011 12:16:26 +0200 Subject: [erlang-questions] The gen server simplified (how it works) In-Reply-To: References: Message-ID: On Wed, Apr 20, 2011 at 10:59 AM, Samuel Rivas wrote: > > Things become problematic when you do not entirely understand the > > abstraction. > > Maybe the abstraction is inappropriate for your needs. I have seen many > > examples > > of code where the gen_server *is* inappropriate. The acid test is "does > the > > gen_sever code look like spaghetti" if the answer is yes then all you > have > > done > > is shoe horn the applications into an inappropriate form. In this case > > you should ditch the gen_server and roll-your own. > > Another problem I often see is that newbies tend to regard gen_server > as something that does magic, and fail to understand how the code runs > in the server and the clients (since that code lives in the same > module, usually). > > They end up in solutions with parts of the gen server sending messages > back and forth, putting receives that spoil the abstraction > intercepting messages that gen_server code should be handling, > throwing exits in server code and attempting to catch them in the > client code, blocking servers with heavyweight operations, ... > > I really consider advising against using gen_server (or any other > abstraction) until one is able to write a client-server and a > supervisor tree without them so that you can understand what's > happening under the hood of gen_server (which, as you say, it's not > rocket science). > Absolutely. > > I think the problem stems from the use of IDEs - in eclipse/Xcode etc you > click on > a "new project" button and the system automatically generates a load of > crap files > full of incomprehensible undocumented nonsense. This leads to a mentality > of "using stuff without understanding it" - All I ever use is emacs, make > and a shell. > Usually I put all the files in one directory. I want to understand > *everything* > > As IDEs get more and more complex and help you more and more > it gets harder and harder to understand what's really going on. > > Graphics programming used to be easy - anybody remember Borlands turbo > graphics? > - but now it's far more difficult since you have to fight with all the > tools and > frameworks that get in the way and make life difficult. > > /joe > > > > Cheers > -- > Samuel > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dsc@REDACTED Wed Apr 20 12:52:58 2011 From: dsc@REDACTED (Dave Challis) Date: Wed, 20 Apr 2011 11:52:58 +0100 Subject: [erlang-questions] Server which spawns an additional server for each call In-Reply-To: References: <4DAD4EC7.3070607@ecs.soton.ac.uk> <4DADB606.2060009@ecs.soton.ac.uk> <4DAEBB0A.4060209@ecs.soton.ac.uk> Message-ID: On 20/04/2011 09:11, Joe Armstrong wrote: > > > On Tue, Apr 19, 2011 at 6:19 PM, Dave Challis > wrote: > > Hi Joe, > Fantastic, that's pretty much exactly what I was after. I didn't > realise I could send a {noreply, X} from a handle_call, and defer > the actual reply from a spawned process. > > The pure erlang version makes it clear what's going on too - > gen_server is still a bit of a black box to me I'm afraid. > > > Oh dear - this frightens me - I've started a new thread to explain just > exactly how simple the > gen_server is - pleas read it Thanks Joe, that's helped clear things up for me. I've had a play round with the code, and managed to trace exactly what's going on now. I'd only seen examples of code that used gen_server, so its actual behaviour was implied (and sometimes explained), but seeing exactly what its functions do makes such a difference (I'd somehow assumed it was a vastly complex piece of code - probably due to experience of servers in other languages!). To be honest, the main examples of non-trivial erlang code that I've seen have come from the Erlang and OTP in Action book. It frequently uses gen_server as a base for applications or functionality, so I assumed that it was good practice to do so. A resource containing common design patterns for erlang would be ideal, but I'm not sure if such a thing exists yet! > The gen_server I'm using is a wrapper around a C utility which does > some parsing (using erlang's port mechanism), and then returns the > parsed data to the original function caller. > > Just to satisfy my curiosity, why C? did you try this in pure Erlang first? The main reason was so that I could re-use a fairly mature and fully featured 3rd party parsing library. I'm just interested in working with the parsed data structures in erlang, the actual parsing itself isn't really what I'm focusing on. It also seemed like a good learning opportunity to try out erlang ports with real code. Dave > > /Joe > > I figured that by having the port initialised when the gen_server > process is started, it could respond to client requests right away, > rather than being spawned upon request. > > I was also thinking that by having the C program and port set up at > server start time, then any startup errors from it would be caught > then, rather than everything appearing to be ok until a client > request was made. > > Thanks, > Dave > > > On 19/04/11 16:11, Joe Armstrong wrote: > > It's not entirely clear to me what you want to do. I never > understand > why people use gen_servers > for everything, pure Erlang is often easier :-) > > I assume you want to delegate the response in the server (ie get > some > other process than the > gen server to do the work, since this takes a long time) > > One way to do this is like this: > > Write a client stub like this: > > foo(X) -> > gen_server:call(?Mod, {foo, X}). > > > Write a gen_server handle call method like this: > > handle_call({foo, X}, From, State) -> > State1 = func1(X, State), > State2 = func2(X, State), > spawn_link(fun() -> do_something(State1, X, From) end), > {noreply, State2}. > > do_something(State, X, From) -> > Reply = func3(X, State), > gen_server:reply(From, Reply). > > here I've assumed func1 returns State1 and that State1 is some > subset of > State > needed in your computation. State2 (returned by func2) is the > continuation state of the server. > ie the state the server will have after it has received the foo > request, > but before the delegated function > has replied. You'll have to write func1 and func2 yourself. > > do_something is the delegated function that might take a long > time. The > four lines of > code which define handle_call should return quickly, ie don't do > much > here, do the work in > do_something. handle call returns {noreply, State2} which means > "don't > reply to the client > but continue with state State2. > > do_something works in parallel with the server and when it has > finished > calls gen_server:reply/2 > and at this point the client stub routine foo/1 will return. > > This is only one way of doing this. You could do the complex > calculation > inside the client > and request the data you need from the server, the server can > spawn a > deligate (as above). > You can use a shared ets table and so on. > > if you were to do this in pure erlang it might be easier to see > what's > going on > > Define promise and yield thusly: > > promise(Fun) -> > S = self(), %% this self() is > evaluated *inside* the current function > spawn(fun() -> > S ! {self(), Fun()} %% this self() is > evaluated > *inside* the spawned function > end). > > yield(Promise) -> > receive > {Promise, Result} -> Result > end. > > promise takes a Fun argument and returns a promise. The promise is a > promise to > compute the value. The promise can be redeemed by calling yield. > So we > can write code like this: > > P = promise(fun() -> fib(40) end), > .... do some other stuff that takes a while ... > Val = yield(Promise) > > So we compute fib(40) which takes a long time in parallel with some > other stuff. > > > The gen_server stuff above has just hidden what is essentially a > promise > and yield and > a bit of state trickery in a framework module - nothing tricky about > about it at all. > > Given promise and yield and a dash of list comprehensions we can > write > fun stuff like: > > parmap(F, L) -> > Promises = [promise(fun() -> F(I) end || I <- L], > [yield(I) || I <- Promises]. > > which is a parallel mapping function. > > Hope this helps > > /Joe > > > > On Tue, Apr 19, 2011 at 10:58 AM, Dave Challis > > >> wrote: > > Hi, > I'm trying to work out the structure for a small bit of > functionality in erlang. I've got a feeling there's an obvious > solution, but I'm not experienced enough with the language > sure what > pattern to best follow... > > So far, I've got a server which implements the gen_server > behaviour, > a supervisor for it, and a module containing an API for > interacting > with it (using gen_server:call mostly). > > The server does a lot of work though, so blocks for a while > until > the call is finished. > > What I'd like to do, is create a new server process each time > gen_server:call is invoked by a client, with each server > terminating > when it's done processing (but always leaving 1 server running). > > This means that clients using the API will have their request > processes straight away, without having to wait for all the > other > calls to the server to finish. > > I can't quite figure out where to place the logic for doing > this though. > > * Should the API module ask the supervisor to spawn a new child, > then send the client's call to this? > * Should API calls go to the supervisor, and have it decide > whether > to spawn new servers or send the call to an existing one? > * Or should each server take care of telling the supervisor > to spawn > a new child, and pass the call request to the newly spawned one? > > Is this a sensible approach in general, or is there an obvious > pattern or some functionality I've missed? > > Thanks, > > -- > Dave Challis > dsc@REDACTED > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > > > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > -- > Dave Challis > dsc@REDACTED > > From attila.r.nohl@REDACTED Wed Apr 20 14:51:39 2011 From: attila.r.nohl@REDACTED (Attila Rajmund Nohl) Date: Wed, 20 Apr 2011 14:51:39 +0200 Subject: [erlang-questions] The gen server simplified (how it works) In-Reply-To: References: Message-ID: 2011/4/20, Joe Armstrong : > On Wed, Apr 20, 2011 at 10:59 AM, Samuel Rivas > wrote: > >> > Things become problematic when you do not entirely understand the >> > abstraction. >> > Maybe the abstraction is inappropriate for your needs. I have seen many >> > examples >> > of code where the gen_server *is* inappropriate. The acid test is "does >> the >> > gen_sever code look like spaghetti" if the answer is yes then all you >> have >> > done >> > is shoe horn the applications into an inappropriate form. In this case >> > you should ditch the gen_server and roll-your own. >> >> Another problem I often see is that newbies tend to regard gen_server >> as something that does magic, and fail to understand how the code runs >> in the server and the clients (since that code lives in the same >> module, usually). I think this is the most confusing design pattern in Erlang: send(x,y) -> gen_server:call(?NAME, {send, x, y}). handle_call({send, x, y}, State) -> i_send(x, y). i_send(x,y) -> ... One always have to keep in mind that actual code he's looking at is in the client process (send) or server (i_send). Obviously calling send from i_send in the above example would just lead to a deadlock. Maybe it would be a nice tool that I could run on a huge codebase and split these modules into a client and server part... From mihai@REDACTED Wed Apr 20 14:52:11 2011 From: mihai@REDACTED (Mihai Balea) Date: Wed, 20 Apr 2011 08:52:11 -0400 Subject: [erlang-questions] The gen server simplified (how it works) In-Reply-To: References: Message-ID: <70CD76DB-0CB6-4934-8AD7-1F04BC71691D@hates.ms> On Apr 20, 2011, at 4:05 AM, Joe Armstrong wrote: > > This is *why* we made the gen_server abstraction. You can write well-typed > sequential code (the handle_call and init functions) to parametrize > a concurrent behavior, ie you need to know nothing about concurrency to > get the job done. We've "abstracted out" the concurrency. I believe saying that we have "abstracted out concurrency" is a bit dangerous. A better description would be gen_server builds a function call, rpc-like if you will, abstraction on top of a message passing communication protocol, while at the same time synchronizing access to a resource by serializing requests. A bit pedantic, but, in my opinion, an important nuance to understand, since it has significant performance implications. > Things become problematic when you do not entirely understand the abstraction. > Maybe the abstraction is inappropriate for your needs. I have seen many examples > of code where the gen_server *is* inappropriate. The acid test is "does the > gen_sever code look like spaghetti" if the answer is yes then all you have done > is shoe horn the applications into an inappropriate form. In this case > you should ditch the gen_server and roll-your own. The most common form of gen _server abuse I have seen (and I plead guilty of it myself) is attempting to turn it into something akin to a state machine. My rule of thumb is if your state record contains a field called state or something like it and you take different actions based on it, then it's time to re-factor into a gen_fsm. It's easy to get into this situation since things usually start simple and build up once more functionality is piled on. Mihai -------------- next part -------------- An HTML attachment was scrubbed... URL: From koops.j@REDACTED Wed Apr 20 15:09:03 2011 From: koops.j@REDACTED (Jeroen Koops) Date: Wed, 20 Apr 2011 15:09:03 +0200 Subject: [erlang-questions] The gen server simplified (how it works) In-Reply-To: <70CD76DB-0CB6-4934-8AD7-1F04BC71691D@hates.ms> References: <70CD76DB-0CB6-4934-8AD7-1F04BC71691D@hates.ms> Message-ID: > > > The most common form of gen _server abuse I have seen (and I plead guilty > of it myself) is attempting to turn it into something akin to a state > machine. My rule of thumb is if your state record contains a field called > state or something like it and you take different actions based on it, then > it's time to re-factor into a gen_fsm. It's easy to get into this situation > since things usually start simple and build up once more functionality is > piled on. > > I don't know about this -- I have written numerous gen_servers whose state-record include a state-field (although I usually call it 'current'), and events (calls, casts, infos) are handled differently depending on its value. The reason for not using a gen_fsm is that very often, an event should be handled in one way in one particular state, and in another way in _all_ other states. This is easy to do using pattern-matching when using a gen_server, but when using a gen_fsm you have no choice but to write out every state/event combination, which can become pretty cumbersome. On a related note, I have been moving away from using gen_servers all the time. The reason for this is that in a gen_server, the state consists of just the state term. In an arbitrary process, the state actually consists of the process' entire call-stack, and it makes the flow in code such as the almost proverbial: idle() -> receive { Number, incoming } -> start_ringing(), ringing(Number); off_hook -> start_tone(), dial() end. ... much easier to follow than when using a gen_server or gen_fsm. -------------- next part -------------- An HTML attachment was scrubbed... URL: From mihai@REDACTED Wed Apr 20 15:30:29 2011 From: mihai@REDACTED (Mihai Balea) Date: Wed, 20 Apr 2011 09:30:29 -0400 Subject: [erlang-questions] Server which spawns an additional server for each call In-Reply-To: References: <4DAD4EC7.3070607@ecs.soton.ac.uk> <4DADB606.2060009@ecs.soton.ac.uk> <4DAEBB0A.4060209@ecs.soton.ac.uk> Message-ID: <0C73437A-6877-410A-B26B-3456E910010F@hates.ms> On Apr 20, 2011, at 6:52 AM, Dave Challis wrote: > > To be honest, the main examples of non-trivial erlang code that I've seen have come from the Erlang and OTP in Action book. It frequently uses gen_server as a base for applications or functionality, so I assumed that it was good practice to do so. It is good practice to have your app structured according to OTP principles and using standard OTP behaviours is an easy way to do it. You'll get a solid, time-tested scaffolding, other people will have an easier time understanding your code and various tools depend on things being set up in a certain way. That being said, it pays to be aware of what's going on under the hood and what the limitations are. You can find a large selection of non-trivial Erlang code in the wild, of various degrees of quality. Search Github for RIak, it's just one example of well designed, OTP compliant codebase. > A resource containing common design patterns for erlang would be ideal, but I'm not sure if such a thing exists yet! The OTP behaviours encapsulate common patterns, but I suspect you're referring to higher level design. I am not aware of any such resource, but it would be a Good Thing! Mihai From sedrik@REDACTED Wed Apr 20 16:00:51 2011 From: sedrik@REDACTED (Fredrik Andersson) Date: Wed, 20 Apr 2011 16:00:51 +0200 Subject: [erlang-questions] Erlang Windows otp_ded.mk no such file Message-ID: Hi all I am trying to build Erlang for Windows and want to generate the tests cases to run them too. I have gotten the installer to work and pointed my ERL_TOP to the install directory under Program Files but when I try to run ./otp_build tests -a I get an error stating that mk/otp_ded.mk is not found. How can I generate that make file from the otp_ded.mk.in file? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From jesper.louis.andersen@REDACTED Wed Apr 20 16:35:48 2011 From: jesper.louis.andersen@REDACTED (Jesper Louis Andersen) Date: Wed, 20 Apr 2011 16:35:48 +0200 Subject: [erlang-questions] Runtime checking for types In-Reply-To: References: <945465586.107521303080710089.JavaMail.root@zimbra> <07054f02-aee1-4baf-85b8-6870782e9e18@dr5g2000vbb.googlegroups.com> <25B0968E-BB32-4107-93FA-61D58EC4130E@cs.otago.ac.nz> Message-ID: On Wed, Apr 20, 2011 at 16:21, Tony Finch wrote: > Richard O'Keefe wrote: >> On 18/04/2011, at 10:58 PM, Jesper Louis Andersen wrote: >> > >> > Remember, dynamic typing is a straitjacket, in which you cannot fully >> > express yourself, whereas static typing give you a rich language for >> > doing so. >> >> This sounds very much like a crab telling humans how limited they >> are by the absence of a shell. ?Think of the problems of moulting. > > Sounds like Robert Harper. > > http://existentialtype.wordpress.com/2011/03/19/dynamic-languages-are-static-languages/ Indeed. There are, more or less, two opposing views to take: You can go from a statically typed world to a dynamically typed one by erasure of the types. Just ignore them. The other way is what Harper advocates in which you create a single type which you then proceed to assign to any term. To understand why you in the world would want to have static knowledge of a type you need something which is at least as expressive as SML or Ocaml though. Otherwise static type systems are usually not giving anything worthwhile back. The Erlang approach with the dialyzer is an extremely interesting middle-ground in my opinion. It is not types in the usual sense, but it allows for gradually explaining more and more about the program in specifications. I believe that for any language to succeed in the long run, you need to approach both disciplines - static and dynamic - and provide some support for both worlds. -- J. From attila.r.nohl@REDACTED Wed Apr 20 20:23:16 2011 From: attila.r.nohl@REDACTED (Attila Rajmund Nohl) Date: Wed, 20 Apr 2011 20:23:16 +0200 Subject: [erlang-questions] The gen server simplified (how it works) In-Reply-To: References: <70CD76DB-0CB6-4934-8AD7-1F04BC71691D@hates.ms> Message-ID: 2011/4/20, Jeroen Koops : [...] > On a related note, I have been moving away from using gen_servers all the > time. The reason for this is that in a gen_server, the state consists of > just the state term. In an arbitrary process, the state actually consists of > the process' entire call-stack, and it makes the flow in code such as the > almost proverbial: > > idle() -> > receive > { Number, incoming } -> > start_ringing(), > ringing(Number); > off_hook -> > start_tone(), > dial() > end. > > ... much easier to follow than when using a gen_server or gen_fsm. On the other hand it's far from the functionality of a gen_server, because e.g. it doesn't send back data to the caller. When you add this functionality, you essentially reinvent the gen_server. In other words: gen_server is great to provide safe access to shared data, maybe it's not so great to control stuff. There's one more great point in using the gen_* behaviours - they provide usually useful and detailed crash reports when something goes wrong. From kevin@REDACTED Wed Apr 20 21:24:00 2011 From: kevin@REDACTED (Kevin A. Smith) Date: Wed, 20 Apr 2011 15:24:00 -0400 Subject: [erlang-questions] The gen server simplified (how it works) In-Reply-To: References: Message-ID: Strong agreement with everything stated. When I teach an "Intro To Erlang" class I spend a lot of time (lecture and labs) working on the basics before we tackle gen_server. In fact, one of the last labs before getting to gen_server requires the class to write their own server very similar to Joe's code. Abstractions aren't very helpful if you don't understand what they're abstracting. --Kevin On Apr 20, 2011, at 6:16 AM, Joe Armstrong wrote: > > > On Wed, Apr 20, 2011 at 10:59 AM, Samuel Rivas wrote: > > Things become problematic when you do not entirely understand the > > abstraction. > > Maybe the abstraction is inappropriate for your needs. I have seen many > > examples > > of code where the gen_server *is* inappropriate. The acid test is "does the > > gen_sever code look like spaghetti" if the answer is yes then all you have > > done > > is shoe horn the applications into an inappropriate form. In this case > > you should ditch the gen_server and roll-your own. > > Another problem I often see is that newbies tend to regard gen_server > as something that does magic, and fail to understand how the code runs > in the server and the clients (since that code lives in the same > module, usually). > > They end up in solutions with parts of the gen server sending messages > back and forth, putting receives that spoil the abstraction > intercepting messages that gen_server code should be handling, > throwing exits in server code and attempting to catch them in the > client code, blocking servers with heavyweight operations, ... > > I really consider advising against using gen_server (or any other > abstraction) until one is able to write a client-server and a > supervisor tree without them so that you can understand what's > happening under the hood of gen_server (which, as you say, it's not > rocket science). > > > Absolutely. > > I think the problem stems from the use of IDEs - in eclipse/Xcode etc you click on > a "new project" button and the system automatically generates a load of crap files > full of incomprehensible undocumented nonsense. This leads to a mentality > of "using stuff without understanding it" - All I ever use is emacs, make and a shell. > Usually I put all the files in one directory. I want to understand *everything* > > As IDEs get more and more complex and help you more and more > it gets harder and harder to understand what's really going on. > > Graphics programming used to be easy - anybody remember Borlands turbo graphics? > - but now it's far more difficult since you have to fight with all the tools and > frameworks that get in the way and make life difficult. > > /joe > > > > Cheers > -- > Samuel > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From torben.lehoff@REDACTED Wed Apr 20 23:44:48 2011 From: torben.lehoff@REDACTED (Torben Hoffmann) Date: Wed, 20 Apr 2011 23:44:48 +0200 Subject: [erlang-questions] The gen server simplified (how it works) In-Reply-To: References: <70CD76DB-0CB6-4934-8AD7-1F04BC71691D@hates.ms> Message-ID: On Wed, Apr 20, 2011 at 15:09, Jeroen Koops wrote: > >> The most common form of gen _server abuse I have seen (and I plead guilty >> of it myself) is attempting to turn it into something akin to a state >> machine. My rule of thumb is if your state record contains a field called >> state or something like it and you take different actions based on it, then >> it's time to re-factor into a gen_fsm. It's easy to get into this situation >> since things usually start simple and build up once more functionality is >> piled on. >> >> > I don't know about this -- I have written numerous gen_servers whose > state-record include a state-field (although I usually call it 'current'), > and events (calls, casts, infos) are handled differently depending on its > value. The reason for not using a gen_fsm is that very often, an event > should be handled in one way in one particular state, and in another way in > _all_ other states. This is easy to do using pattern-matching when using a > gen_server, but when using a gen_fsm you have no choice but to write out > every state/event combination, which can become pretty cumbersome. > Then one can use an gen_fsm:send_all_state_event/2 and pattern match on both state and state date that in the modules handle_event/3 function. I have done that many times and it works rather well. Cheers, Torben > > On a related note, I have been moving away from using gen_servers all the > time. The reason for this is that in a gen_server, the state consists of > just the state term. In an arbitrary process, the state actually consists of > the process' entire call-stack, and it makes the flow in code such as the > almost proverbial: > > idle() -> > receive > { Number, incoming } -> > start_ringing(), > ringing(Number); > off_hook -> > start_tone(), > dial() > end. > > ... much easier to follow than when using a gen_server or gen_fsm. > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -- http://www.linkedin.com/in/torbenhoffmann -------------- next part -------------- An HTML attachment was scrubbed... URL: From robert.virding@REDACTED Thu Apr 21 00:32:41 2011 From: robert.virding@REDACTED (Robert Virding) Date: Wed, 20 Apr 2011 22:32:41 +0000 (GMT) Subject: [erlang-questions] beginner: How should regexp:split/2 be replaced? In-Reply-To: <247013287.118951303338728916.JavaMail.root@zimbra> Message-ID: <1717760404.118971303338761128.JavaMail.root@zimbra> In both cases there was no real room for discussion as the decision had already been made by the OTP group. As your quote shows. That the array module chose to index from 0 does not make the re/binary decisions more right. We are still stuck with two different indexing standards. Robert ----- "Raimo Niskanen" wrote: > On Tue, Apr 19, 2011 at 09:14:04PM +0000, Robert Virding wrote: > > Perhaps its because they think that adding/subtracting one is too > difficult. Or perhaps it is because they want to adhere to the > convention that indexing starts at 0 in spite of that most other > erlang things index from 1. > > > > Robert > > > > It was zero-based in EEP 11 > http://www.erlang.org/eeps/eep-0011.html > and there was no discussion about that EEP. > > This also surfaced in a diskussion about EEP 31: > http://erlang.org/pipermail/eeps/2009-December/000278.html > > Patrik Nyblom wrote: > > > > Robert Virding wrote: > > > > > > - It seems like 'binary' indexes binaries from 0. Is this wise? > While > > > indexing them from 1 may not have been a good choice having two > different > > > standards must surely be much worse and be a source of future > confusion. I > > > know that 're' does this but I think that was a bad mistake! > > > > We (OTP), reluctantly, made the decision to have zero-based indices > as a > > rule for binary-oriented modules although Erlang is traditionally > > one-based. The reason beeing foremost the hassle of > > using one-based indices in bit syntax (the only thing you can make > with a > > one based index is to make it zero based, it's useless in bit-syntax > until > > that is done). Having different bases in different binary-oriented > modules > > would add to the confusion (and make for a less convenient > interface). > > So, the design relu is now that all indices in binaries are > zero-based. I > > obviously won't make this module an exception. > > > End of quote Patrik Nyblom. > > The array module is also zero based. > http://www.erlang.org/doc/man/array.html > > / Raimo Niskanen > > > > > > ----- "Ahmed Omar" wrote: > > > I mean i understand it's different indexing, but was there > specific reason to change that? > > > > > > > > > On Tue, Apr 19, 2011 at 4:18 PM, Ahmed Omar < > spawn.think@REDACTED > wrote: > > > > > > > > > > > regexp:split("Hello world, Hello", "[ ]*,[ ]*"). > > {ok,["Hello world","Hello"]} > > > > > > > re:split("Hello world, Hello", "[ ]*,[ ]*",[{return, list}]). > > ["Hello world","Hello"] > > > > > > > > > regexp:matches("Hello \n","\n"). > > {match,[{7,1}]} > > > > > > > re:run("Hello \n","\n"). > > {match,[{6,1}]} > > > > > > > but i'm not sure why the start position is different here > > > > > > > > > > > > > On Tue, Apr 19, 2011 at 3:30 PM, Bengt Kleberg < > bengt.kleberg@REDACTED > wrote: > > > > > > > Greetings, > > > > > > I have inherited some code without a test directory. I get the > following > > > compiler warnings: > > > ./compile_funcs.erl:603: Warning: regexp:split/2: the regexp > module is > > > deprecated (will be removed in R15A); use the re module instead > > > ./compile_funcs.erl:645: Warning: regexp:matches/2: the regexp > module is > > > deprecated (will be removed in R15A); use the re module instead > > > > > > The lines are: > > > {ok, Class} = regexp:split(Class0, "[ ]*,[ ]*"), > > > and > > > {match,A}=regexp:matches(String,"\n"), > > > > > > I thought "[ ]*,[ ]*" would mean: > > > the character class of " " (space), 0 or many times, followed by > literal > > > "," followed by the character class of " " (space), 0 or many > times. > > > > > > This is not the case and I am not having any luck with randomly > > > constructing strings to find one that triggers a Class that is > different > > > from Class0. > > > > > > Perhaps someone knows what "[ ]*,[ ]*" really means, and what to > replace > > > these with when using the re module. > > > > > > > > > bengt > > > > > > _______________________________________________ > > > erlang-questions mailing list > > > erlang-questions@REDACTED > > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > > > > > > > -- > > > Best Regards, > > > - Ahmed Omar > > http://nl.linkedin.com/in/adiaa > > Follow me on twitter > > @spawn_think > > > > > > > > > > > -- > > > Best Regards, > > > - Ahmed Omar > > http://nl.linkedin.com/in/adiaa > > Follow me on twitter > > @spawn_think > > > > > > _______________________________________________ erlang-questions > mailing list erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > > -- > > / Raimo Niskanen, Erlang/OTP, Ericsson AB > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From moxford@REDACTED Thu Apr 21 00:37:31 2011 From: moxford@REDACTED (Mike Oxford) Date: Wed, 20 Apr 2011 15:37:31 -0700 Subject: [erlang-questions] OTP style packaging of custom driver Message-ID: I am using rebar for the compilation/node generation, front-ended with a Makefile. What is the "correct" distribution method of custom drivers? Put it in priv/lib and have it packaged under rel///priv/lib? Or put it directly into rel//lib All of the examples I can find online are "one off" examples. Doable, sure, but what is the "right way?" Thanks! -mox -------------- next part -------------- An HTML attachment was scrubbed... URL: From yrashk@REDACTED Thu Apr 21 01:37:38 2011 From: yrashk@REDACTED (Yurii Rashkovskii) Date: Wed, 20 Apr 2011 16:37:38 -0700 Subject: [erlang-questions] Vancouver Erlang Meetup in May Message-ID: Where: iQmetrix 250 Howe Street - Suite 1210 Vancouver, BC How to find us: This meetup will be at the iQmetrix HQ. Please be punctual, as we will need to shuttle people upstairs to the space As a warmup, Yurii will give a brief overview of interesting talks that were given at the Erlang Factory SF 2011. Talk #1: Agner Libraries distribution mechanisms are key to the creation of a thriving ecosystem for any programming language. Agner is a new lightweight package index/manager partially inspired by Homebrew and Clojars that is designed to bring simplicity and elegance to the way dependencies are managed. Talk #2: Beam.js An edited version of the talk that was given at the Factory. With rising popularity of JavaScript as server-side programming language, wouldn't it be interesting to use potential of both Erlang and JavaScript? Beam.js is a modular JavaScript platform built on top of V8 that connects two powerful languages ? JavaScript and Erlang at a very low level by embedding V8 into Erlang VM. With Beam.js JavaScript lovers can piggy back on Erlang?s solid distributed networking infrastructure as well as other powerful components. For Erlang users, it can provide a powerful way to describe top level business logic on top of their robust architectures. There's another talk pending confirmation ("Erlang's Dos and Don'ts"). After that we can discuss other subjects of interest and move to a pub. Planned run time for the event is 3-4hrs or so. If you want to give a talk, please let the organizer know. ================================================== RSVP at http://www.meetup.com/erlang-vancouver/events/17378547/ ================================================== From ok@REDACTED Thu Apr 21 02:08:32 2011 From: ok@REDACTED (Richard O'Keefe) Date: Thu, 21 Apr 2011 12:08:32 +1200 Subject: [erlang-questions] Runtime checking for types In-Reply-To: References: <945465586.107521303080710089.JavaMail.root@zimbra> <07054f02-aee1-4baf-85b8-6870782e9e18@dr5g2000vbb.googlegroups.com> <25B0968E-BB32-4107-93FA-61D58EC4130E@cs.otago.ac.nz> Message-ID: <56A7B5DB-C790-4687-A9CF-92C8452E2D8B@cs.otago.ac.nz> On 21/04/2011, at 2:21 AM, Tony Finch wrote: > > Sounds like Robert Harper. > > http://existentialtype.wordpress.com/2011/03/19/dynamic-languages-are-static-languages/ The question Harper tries very hard to evade there is "Are there any usable type systems that are sufficiently expressive?" The only type systems he blesses are the ones in ML and Haskell. As a Haskell programmer, I find ML's type system crippling. (No type classes? Relying on ad hoc overloading to deal with + and < ? Feh!) And there are enough people who find the Haskell type system limiting that Epigram, Cayenne, and Agda exist. Make no mistake, a *good* type system *can* do wonders for you. See the whole "generic programming" stuff, such as Template Haskell, and contrast the elegance of QuickCheck in Haskell (driven by the types) with the clunkier version for Erlang. At the high end, type systems trail off into things like PVS, where proving that a specification is type-correct is a non-trivial exercise. (If anyone reading this knows PVS and would give me a bit of hand-holding, I'd _really_ like to be able to use it; the language is clear enough, but driving the theorem prover is very far from obvious.) When it comes to writing programs, few things are as straitjackety as a language that isn't finished yet (Epigram) or one where persuading the compiler your program makes sense requires manual guidance of a theorem prover. From steven.charles.davis@REDACTED Thu Apr 21 04:18:45 2011 From: steven.charles.davis@REDACTED (Steve Davis) Date: Wed, 20 Apr 2011 19:18:45 -0700 (PDT) Subject: [erlang-questions] Runtime checking for types In-Reply-To: <56A7B5DB-C790-4687-A9CF-92C8452E2D8B@cs.otago.ac.nz> References: <945465586.107521303080710089.JavaMail.root@zimbra> <07054f02-aee1-4baf-85b8-6870782e9e18@dr5g2000vbb.googlegroups.com> <25B0968E-BB32-4107-93FA-61D58EC4130E@cs.otago.ac.nz> <56A7B5DB-C790-4687-A9CF-92C8452E2D8B@cs.otago.ac.nz> Message-ID: <27061ed1-9ede-45c7-974f-7273f4f0a3ba@dr5g2000vbb.googlegroups.com> I'd like to inject that it's important (at least for me) to distinguish between "static types" and static type checking. It doesn't take a genius to observe that "types" are platonic. The issue here (at least for me) is between static type *checking* and dynamic type checks. I think Robert Harper almost willfully missed that point in that posting. What's more, I'm not even sure there is such a thing as a "dynamic type". I've not seen an example... unless you mean VB "variant" which ....isn't a well-defined type at all, right? /s From demeshchuk@REDACTED Thu Apr 21 07:15:02 2011 From: demeshchuk@REDACTED (Dmitry Demeshchuk) Date: Thu, 21 Apr 2011 09:15:02 +0400 Subject: [erlang-questions] Replacing a module with another module Message-ID: Actually, this task is very similar to how meck, effigy and similar stuff work. So, there's a module named foo that is working. And there's a module foo_mock, we want to mock a lot of stuff from the module foo here. Of course, we could just use 'start_mocking' function where we declare standard meck rules, like meck:new(foo), meck:expect(foo, bar, 0, fun() -> stuff end). meck:expect(foo, bar2, 0, fun() -> stuff2 end). ... But this is obviously ugly. So, the more general way of solving this is to get abstract code of the module foo using beam_lib, map through it, replacing the module atoms, and compiling it back again. My questions are: 1. Is there an easier way? (Besides loading a module with the same name from another path, the circumstances don't allow me that) 2. Hasn't anyone already done that? Maybe I'm trying to re-invent something obvious here. -- Best regards, Dmitry Demeshchuk From norton@REDACTED Thu Apr 21 07:26:20 2011 From: norton@REDACTED (Joseph Wayne Norton) Date: Thu, 21 Apr 2011 14:26:20 +0900 Subject: [erlang-questions] Replacing a module with another module In-Reply-To: References: Message-ID: Dmitry - Hi. The meck module recently exported some of it's internal utility functions. The recipe below works quite well for my purposes. thanks, -module(mocking_module). -define(MOCK_MOD, module_to_be_mocked). : : : install_module() -> ok = uinstall_module(), Forms = meck:abstract_code(meck:beam_file(?MODULE)), ok = meck:compile_forms(meck:rename_module(Forms, ?MOCK_MOD), meck:compile_options(?MODULE)), ok. uninstall_module() -> code:purge(?MOCK_MOD), code:delete(?MOCK_MOD), ok. On Thu, 21 Apr 2011 14:15:02 +0900, Dmitry Demeshchuk wrote: > Actually, this task is very similar to how meck, effigy and similar > stuff work. > > So, there's a module named foo that is working. And there's a module > foo_mock, we want to mock a lot of stuff from the module foo here. Of > course, we could just use 'start_mocking' function where we declare > standard meck rules, like > > meck:new(foo), > meck:expect(foo, bar, 0, fun() -> stuff end). > meck:expect(foo, bar2, 0, fun() -> stuff2 end). > ... > > But this is obviously ugly. > > So, the more general way of solving this is to get abstract code of > the module foo using beam_lib, map through it, replacing the module > atoms, and compiling it back again. > > My questions are: > 1. Is there an easier way? (Besides loading a module with the same > name from another path, the circumstances don't allow me that) > 2. Hasn't anyone already done that? Maybe I'm trying to re-invent > something obvious here. > -- norton@REDACTED From demeshchuk@REDACTED Thu Apr 21 07:29:14 2011 From: demeshchuk@REDACTED (Dmitry Demeshchuk) Date: Thu, 21 Apr 2011 09:29:14 +0400 Subject: [erlang-questions] Replacing a module with another module In-Reply-To: References: Message-ID: Hi, Joseph. Thanks, that's exactly what I was looking for! On Thu, Apr 21, 2011 at 9:26 AM, Joseph Wayne Norton wrote: > > Dmitry - > > Hi. ?The meck module recently exported some of it's internal utility > functions. > > The recipe below works quite well for my purposes. > > thanks, > > > > > -module(mocking_module). > > -define(MOCK_MOD, module_to_be_mocked). > > ?: > ?: > ?: > > install_module() -> > ? ?ok = uinstall_module(), > ? ?Forms = meck:abstract_code(meck:beam_file(?MODULE)), > ? ?ok = meck:compile_forms(meck:rename_module(Forms, ?MOCK_MOD), > meck:compile_options(?MODULE)), > ? ?ok. > > uninstall_module() -> > ? ?code:purge(?MOCK_MOD), > ? ?code:delete(?MOCK_MOD), > ? ?ok. > > > On Thu, 21 Apr 2011 14:15:02 +0900, Dmitry Demeshchuk > wrote: > >> Actually, this task is very similar to how meck, effigy and similar stuff >> work. >> >> So, there's a module named foo that is working. And there's a module >> foo_mock, we want to mock a lot of stuff from the module foo here. Of >> course, we could just use 'start_mocking' function where we declare >> standard meck rules, like >> >> meck:new(foo), >> meck:expect(foo, bar, 0, fun() -> stuff end). >> meck:expect(foo, bar2, 0, fun() -> stuff2 end). >> ... >> >> But this is obviously ugly. >> >> So, the more general way of solving this is to get abstract code of >> the module foo using beam_lib, map through it, replacing the module >> atoms, and compiling it back again. >> >> My questions are: >> 1. Is there an easier way? (Besides loading a module with the same >> name from another path, the circumstances don't allow me that) >> 2. Hasn't anyone already done that? Maybe I'm trying to re-invent >> something obvious here. >> > > > -- > norton@REDACTED > -- Best regards, Dmitry Demeshchuk From demeshchuk@REDACTED Thu Apr 21 07:36:49 2011 From: demeshchuk@REDACTED (Dmitry Demeshchuk) Date: Thu, 21 Apr 2011 09:36:49 +0400 Subject: [erlang-questions] Replacing a module with another module In-Reply-To: References: Message-ID: Just to mention, looks like at the original meck the function rename_module still remains internal. Nevertheless, it's very simple, so no big deal. On Thu, Apr 21, 2011 at 9:29 AM, Dmitry Demeshchuk wrote: > Hi, Joseph. > > Thanks, that's exactly what I was looking for! > > On Thu, Apr 21, 2011 at 9:26 AM, Joseph Wayne Norton > wrote: >> >> Dmitry - >> >> Hi. ?The meck module recently exported some of it's internal utility >> functions. >> >> The recipe below works quite well for my purposes. >> >> thanks, >> >> >> >> >> -module(mocking_module). >> >> -define(MOCK_MOD, module_to_be_mocked). >> >> ?: >> ?: >> ?: >> >> install_module() -> >> ? ?ok = uinstall_module(), >> ? ?Forms = meck:abstract_code(meck:beam_file(?MODULE)), >> ? ?ok = meck:compile_forms(meck:rename_module(Forms, ?MOCK_MOD), >> meck:compile_options(?MODULE)), >> ? ?ok. >> >> uninstall_module() -> >> ? ?code:purge(?MOCK_MOD), >> ? ?code:delete(?MOCK_MOD), >> ? ?ok. >> >> >> On Thu, 21 Apr 2011 14:15:02 +0900, Dmitry Demeshchuk >> wrote: >> >>> Actually, this task is very similar to how meck, effigy and similar stuff >>> work. >>> >>> So, there's a module named foo that is working. And there's a module >>> foo_mock, we want to mock a lot of stuff from the module foo here. Of >>> course, we could just use 'start_mocking' function where we declare >>> standard meck rules, like >>> >>> meck:new(foo), >>> meck:expect(foo, bar, 0, fun() -> stuff end). >>> meck:expect(foo, bar2, 0, fun() -> stuff2 end). >>> ... >>> >>> But this is obviously ugly. >>> >>> So, the more general way of solving this is to get abstract code of >>> the module foo using beam_lib, map through it, replacing the module >>> atoms, and compiling it back again. >>> >>> My questions are: >>> 1. Is there an easier way? (Besides loading a module with the same >>> name from another path, the circumstances don't allow me that) >>> 2. Hasn't anyone already done that? Maybe I'm trying to re-invent >>> something obvious here. >>> >> >> >> -- >> norton@REDACTED >> > > > > -- > Best regards, > Dmitry Demeshchuk > -- Best regards, Dmitry Demeshchuk From norton@REDACTED Thu Apr 21 07:39:54 2011 From: norton@REDACTED (Joseph Wayne Norton) Date: Thu, 21 Apr 2011 14:39:54 +0900 Subject: [erlang-questions] Replacing a module with another module In-Reply-To: References: Message-ID: Oh yes, sorry! This patch is in my own repository. https://github.com/norton/meck/commit/8ea00f438695838f4cee4e2b13928abcac17f9b3 thanks, On Thu, 21 Apr 2011 14:36:49 +0900, Dmitry Demeshchuk wrote: > Just to mention, looks like at the original meck the function > rename_module still remains internal. > Nevertheless, it's very simple, so no big deal. > > On Thu, Apr 21, 2011 at 9:29 AM, Dmitry Demeshchuk > wrote: >> Hi, Joseph. >> >> Thanks, that's exactly what I was looking for! >> >> On Thu, Apr 21, 2011 at 9:26 AM, Joseph Wayne Norton >> wrote: >>> >>> Dmitry - >>> >>> Hi. The meck module recently exported some of it's internal utility >>> functions. >>> >>> The recipe below works quite well for my purposes. >>> >>> thanks, >>> >>> >>> >>> >>> -module(mocking_module). >>> >>> -define(MOCK_MOD, module_to_be_mocked). >>> >>> : >>> : >>> : >>> >>> install_module() -> >>> ok = uinstall_module(), >>> Forms = meck:abstract_code(meck:beam_file(?MODULE)), >>> ok = meck:compile_forms(meck:rename_module(Forms, ?MOCK_MOD), >>> meck:compile_options(?MODULE)), >>> ok. >>> >>> uninstall_module() -> >>> code:purge(?MOCK_MOD), >>> code:delete(?MOCK_MOD), >>> ok. >>> >>> >>> On Thu, 21 Apr 2011 14:15:02 +0900, Dmitry Demeshchuk >>> >>> wrote: >>> >>>> Actually, this task is very similar to how meck, effigy and similar >>>> stuff >>>> work. >>>> >>>> So, there's a module named foo that is working. And there's a module >>>> foo_mock, we want to mock a lot of stuff from the module foo here. Of >>>> course, we could just use 'start_mocking' function where we declare >>>> standard meck rules, like >>>> >>>> meck:new(foo), >>>> meck:expect(foo, bar, 0, fun() -> stuff end). >>>> meck:expect(foo, bar2, 0, fun() -> stuff2 end). >>>> ... >>>> >>>> But this is obviously ugly. >>>> >>>> So, the more general way of solving this is to get abstract code of >>>> the module foo using beam_lib, map through it, replacing the module >>>> atoms, and compiling it back again. >>>> >>>> My questions are: >>>> 1. Is there an easier way? (Besides loading a module with the same >>>> name from another path, the circumstances don't allow me that) >>>> 2. Hasn't anyone already done that? Maybe I'm trying to re-invent >>>> something obvious here. >>>> >>> >>> >>> -- >>> norton@REDACTED >>> >> >> >> >> -- >> Best regards, >> Dmitry Demeshchuk >> > > > -- norton@REDACTED From spawn.think@REDACTED Thu Apr 21 09:46:52 2011 From: spawn.think@REDACTED (Ahmed Omar) Date: Thu, 21 Apr 2011 09:46:52 +0200 Subject: [erlang-questions] Vancouver Erlang Meetup in May In-Reply-To: References: Message-ID: Maybe you will also like to post it here Erlang Users' Group Canada http://www.linkedin.com/groups?mostPopular=&gid=3838220 On Thu, Apr 21, 2011 at 1:37 AM, Yurii Rashkovskii wrote: > Where: > > iQmetrix > 250 Howe Street - Suite 1210 Vancouver, BC > > How to find us: This meetup will be at the iQmetrix HQ. Please be > punctual, as we will need to shuttle people upstairs to the space > > As a warmup, Yurii will give a brief overview of interesting talks > that were given at the Erlang Factory SF 2011. > > Talk #1: Agner > > Libraries distribution mechanisms are key to the creation of a > thriving ecosystem for any programming language. Agner is a new > lightweight package index/manager partially inspired by Homebrew and > Clojars that is designed to bring simplicity and elegance to the way > dependencies are managed. > > Talk #2: Beam.js > > An edited version of the talk that was given at the Factory. > > With rising popularity of JavaScript as server-side programming > language, wouldn't it be interesting to use potential of both Erlang > and JavaScript? Beam.js is a modular JavaScript platform built on top > of V8 that connects two powerful languages ? JavaScript and Erlang at > a very low level by embedding V8 into Erlang VM. With Beam.js > JavaScript lovers can piggy back on Erlang?s solid distributed > networking infrastructure as well as other powerful components. For > Erlang users, it can provide a powerful way to describe top level > business logic on top of their robust architectures. > > > > There's another talk pending confirmation ("Erlang's Dos and Don'ts"). > > > > After that we can discuss other subjects of interest and move to a > pub. Planned run time for the event is 3-4hrs or so. > > If you want to give a talk, please let the organizer know. > > ================================================== > RSVP at http://www.meetup.com/erlang-vancouver/events/17378547/ > ================================================== > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -- Best Regards, - Ahmed Omar http://nl.linkedin.com/in/adiaa Follow me on twitter @spawn_think -------------- next part -------------- An HTML attachment was scrubbed... URL: From sir.sedrik@REDACTED Thu Apr 21 10:57:19 2011 From: sir.sedrik@REDACTED (Fredrik Andersson) Date: Thu, 21 Apr 2011 10:57:19 +0200 Subject: [erlang-questions] Errors when generating tests for CosNotifications on windows. Message-ID: Hi all I want to run the test suites on my windows build but I am running into trouble when generating the tests for CosNotification. I can reproduce the error by building the tests inside of otp/lib/CosNotification/test using make tests. Can anyone help? The following is the error I get. I have verified that the idl files are present in the src directory. erlc +debug_info -pa /home/ESLbingen/bingen/tmp/otp/lib/cosNotification/ebin -pa /home/ESLbingen/bingen/tmp/otp/lib/cosNotification/src -pa /home/ESLbingen/bingen/tmp/otp/lib/cosTime/ebin -pa /home/ESLbingen/bingen/tmp/otp/lib/cosTime/include -pa /home/ESLbingen/bingen/tmp/otp/lib/orber/ebin -pa /home/ESLbingen/bingen/tmp/otp/lib/ic/ebin -pa /home/ESLbingen/bingen/tmp/otp/lib/cosNotification/include -I/home/ESLbingen/bingen/tmp/otp/lib/cosEvent/src -I/home/ESLbingen/bingen/tmp/otp/lib/cosNotification/include -pa /home/ESLbingen/bingen/tmp/otp/lib/orber/include -pa /home/ESLbingen/bingen/tmp/otp/internal_tools/test_server/ebin -pa /home/ESLbingen/bingen/tmp/otp/lib/cosNotification/ebin -pa /home/ESLbingen/bingen/tmp/otp/lib/cosNotification/test/idl_output -pa /home/ESLbingen/bingen/tmp/otp/lib/cosTime/ebin -pa /home/ESLbingen/bingen/tmp/otp/lib/cosTime/include -pa /home/ESLbingen/bingen/tmp/otp/lib/cosNotification/include -pa /home/ESLbingen/bingen/tmp/otp/lib/ic/ebin -I/home/ESLbingen/bingen/tmp/otp/lib/cosTime/ebin -I/home/ESLbingen/bingen/tmp/otp/lib/cosTime/include -I/home/ESLbingen/bingen/tmp/otp/lib/orber/include -I/home/ESLbingen/bingen/tmp/otp/lib/cosNotification/src -I/home/ESLbingen/bingen/tmp/otp/lib/cosNotification/include -I/home/ESLbingen/bingen/tmp/otp/lib/cosNotification -I/home/ESLbingen/bingen/tmp/otp/lib/cosNotification/test/idl_output -I/home/ESLbingen/bingen/tmp/otp/lib/test_server/include -oidl_output \ +'{cfgfile,"notify_test_server.cfg"}' notify_test_server.idl []: warning: unrecognised option: debug_info Erlang IDL compiler version 4.2.26 "c:/cygwin/home/ESLBIN~1/bingen/tmp/otp/lib/COSNOT~1/test/notify_test_server.idl": preprocessor error: c:/cygwin/home/ESLBIN~1/bingen/tmp/otp/lib/COSNOT~1/test/notify_test_server.idl:23: CosNotification.idl: No such file or directory "c:/cygwin/home/ESLBIN~1/bingen/tmp/otp/lib/COSNOT~1/test/notify_test_server.idl": preprocessor error: c:/cygwin/home/ESLBIN~1/bingen/tmp/otp/lib/COSNOT~1/test/notify_test_server.idl:24: CosNotifyComm.idl: No such file or directory "c:/cygwin/home/ESLBIN~1/bingen/tmp/otp/lib/COSNOT~1/test/notify_test_server.idl": 2 errors found -------------- next part -------------- An HTML attachment was scrubbed... URL: From sir.sedrik@REDACTED Thu Apr 21 11:35:14 2011 From: sir.sedrik@REDACTED (Fredrik Andersson) Date: Thu, 21 Apr 2011 11:35:14 +0200 Subject: [erlang-questions] Errors when generating tests for CosNotifications on windows. In-Reply-To: References: Message-ID: On Thu, Apr 21, 2011 at 11:04 AM, Alexander Krasnukhin < the.malkolm@REDACTED> wrote: > Hi, > > It is just a guess and probably sounds stupid but could you try to compile > within the folder with smaller path length? > I tried moving the otp folder to / and it had no difference, I can make them all compile if I cp the idl files to the test folder of cosNotification but that seems to be a suboptimal way of doing things. > > On Thu, Apr 21, 2011 at 10:57 AM, Fredrik Andersson wrote: > >> Hi all >> >> I want to run the test suites on my windows build but I am running into >> trouble when generating the tests for CosNotification. I can reproduce the >> error by building the tests inside of otp/lib/CosNotification/test using >> make tests. >> >> Can anyone help? >> >> The following is the error I get. I have verified that the idl files are >> present in the src directory. >> >> erlc +debug_info -pa >> /home/ESLbingen/bingen/tmp/otp/lib/cosNotification/ebin -pa >> /home/ESLbingen/bingen/tmp/otp/lib/cosNotification/src -pa >> /home/ESLbingen/bingen/tmp/otp/lib/cosTime/ebin -pa >> /home/ESLbingen/bingen/tmp/otp/lib/cosTime/include -pa >> /home/ESLbingen/bingen/tmp/otp/lib/orber/ebin -pa >> /home/ESLbingen/bingen/tmp/otp/lib/ic/ebin -pa >> /home/ESLbingen/bingen/tmp/otp/lib/cosNotification/include >> -I/home/ESLbingen/bingen/tmp/otp/lib/cosEvent/src >> -I/home/ESLbingen/bingen/tmp/otp/lib/cosNotification/include -pa >> /home/ESLbingen/bingen/tmp/otp/lib/orber/include -pa >> /home/ESLbingen/bingen/tmp/otp/internal_tools/test_server/ebin -pa >> /home/ESLbingen/bingen/tmp/otp/lib/cosNotification/ebin -pa >> /home/ESLbingen/bingen/tmp/otp/lib/cosNotification/test/idl_output -pa >> /home/ESLbingen/bingen/tmp/otp/lib/cosTime/ebin -pa >> /home/ESLbingen/bingen/tmp/otp/lib/cosTime/include -pa >> /home/ESLbingen/bingen/tmp/otp/lib/cosNotification/include -pa >> /home/ESLbingen/bingen/tmp/otp/lib/ic/ebin >> -I/home/ESLbingen/bingen/tmp/otp/lib/cosTime/ebin >> -I/home/ESLbingen/bingen/tmp/otp/lib/cosTime/include >> -I/home/ESLbingen/bingen/tmp/otp/lib/orber/include >> -I/home/ESLbingen/bingen/tmp/otp/lib/cosNotification/src >> -I/home/ESLbingen/bingen/tmp/otp/lib/cosNotification/include >> -I/home/ESLbingen/bingen/tmp/otp/lib/cosNotification >> -I/home/ESLbingen/bingen/tmp/otp/lib/cosNotification/test/idl_output >> -I/home/ESLbingen/bingen/tmp/otp/lib/test_server/include -oidl_output \ >> +'{cfgfile,"notify_test_server.cfg"}' >> notify_test_server.idl >> []: warning: unrecognised option: debug_info >> Erlang IDL compiler version 4.2.26 >> "c:/cygwin/home/ESLBIN~1/bingen/tmp/otp/lib/COSNOT~1/test/notify_test_server.idl": >> preprocessor error: >> c:/cygwin/home/ESLBIN~1/bingen/tmp/otp/lib/COSNOT~1/test/notify_test_server.idl:23: >> CosNotification.idl: No such file or directory >> "c:/cygwin/home/ESLBIN~1/bingen/tmp/otp/lib/COSNOT~1/test/notify_test_server.idl": >> preprocessor error: >> c:/cygwin/home/ESLBIN~1/bingen/tmp/otp/lib/COSNOT~1/test/notify_test_server.idl:24: >> CosNotifyComm.idl: No such file or directory >> "c:/cygwin/home/ESLBIN~1/bingen/tmp/otp/lib/COSNOT~1/test/notify_test_server.idl": >> 2 errors found >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> > > > -- > Regards, > Alexander > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From erlang@REDACTED Thu Apr 21 11:39:05 2011 From: erlang@REDACTED (Joe Armstrong) Date: Thu, 21 Apr 2011 11:39:05 +0200 Subject: [erlang-questions] The gen server simplified (how it works) In-Reply-To: References: Message-ID: On Wed, Apr 20, 2011 at 9:24 PM, Kevin A. Smith wrote: > Strong agreement with everything stated. When I teach an "Intro To Erlang" > class I spend a lot of time (lecture and labs) working on the basics before > we tackle gen_server. In fact, one of the last labs before getting to > gen_server requires the class to write their own server very similar to > Joe's code. > xcellent > > Abstractions aren't very helpful if you don't understand what they're > abstracting. > Well said ! One other point - years ago I taught programming (still do occasionally) and at the time I thought "all I have to do is explain the abstractions" and that the student would immediately understand all the consequences of the abstractions (good programmers do, which is why it it's nice talking to them, you tell the story and they fill in the details) but many programmers don't. I explained translative closures in Prolog (the good old related(A,B) :- ...) later one of the students was answering the question "what's Prolog good for" they replied "figuring out genealogical relationships" they were completely oblivious to the fact that the solution to a problem in genealogy was isomorphic to the solutions to a large class of problems in unrelated problem areas. I then made up loads of examples. The point is, you can show people the generalization - but many will not understand the broad applicability of the technique. The best way is to ask people what their particular problem is and solve it for them using the technique you have just outlined (if it is appropriate) /Joe > > --Kevin > On Apr 20, 2011, at 6:16 AM, Joe Armstrong wrote: > > > > > > > On Wed, Apr 20, 2011 at 10:59 AM, Samuel Rivas < > samuel.rivas@REDACTED> wrote: > > > Things become problematic when you do not entirely understand the > > > abstraction. > > > Maybe the abstraction is inappropriate for your needs. I have seen many > > > examples > > > of code where the gen_server *is* inappropriate. The acid test is "does > the > > > gen_sever code look like spaghetti" if the answer is yes then all you > have > > > done > > > is shoe horn the applications into an inappropriate form. In this case > > > you should ditch the gen_server and roll-your own. > > > > Another problem I often see is that newbies tend to regard gen_server > > as something that does magic, and fail to understand how the code runs > > in the server and the clients (since that code lives in the same > > module, usually). > > > > They end up in solutions with parts of the gen server sending messages > > back and forth, putting receives that spoil the abstraction > > intercepting messages that gen_server code should be handling, > > throwing exits in server code and attempting to catch them in the > > client code, blocking servers with heavyweight operations, ... > > > > I really consider advising against using gen_server (or any other > > abstraction) until one is able to write a client-server and a > > supervisor tree without them so that you can understand what's > > happening under the hood of gen_server (which, as you say, it's not > > rocket science). > > > > > > Absolutely. > > > > I think the problem stems from the use of IDEs - in eclipse/Xcode etc you > click on > > a "new project" button and the system automatically generates a load of > crap files > > full of incomprehensible undocumented nonsense. This leads to a mentality > > of "using stuff without understanding it" - All I ever use is emacs, make > and a shell. > > Usually I put all the files in one directory. I want to understand > *everything* > > > > As IDEs get more and more complex and help you more and more > > it gets harder and harder to understand what's really going on. > > > > Graphics programming used to be easy - anybody remember Borlands turbo > graphics? > > - but now it's far more difficult since you have to fight with all the > tools and > > frameworks that get in the way and make life difficult. > > > > /joe > > > > > > > > Cheers > > -- > > Samuel > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From koops.j@REDACTED Thu Apr 21 12:08:58 2011 From: koops.j@REDACTED (Jeroen Koops) Date: Thu, 21 Apr 2011 12:08:58 +0200 Subject: [erlang-questions] The gen server simplified (how it works) In-Reply-To: References: <70CD76DB-0CB6-4934-8AD7-1F04BC71691D@hates.ms> Message-ID: On Wed, Apr 20, 2011 at 11:44 PM, Torben Hoffmann wrote: > > > On Wed, Apr 20, 2011 at 15:09, Jeroen Koops wrote: > >> >>> The most common form of gen _server abuse I have seen (and I plead guilty >>> of it myself) is attempting to turn it into something akin to a state >>> machine. My rule of thumb is if your state record contains a field called >>> state or something like it and you take different actions based on it, then >>> it's time to re-factor into a gen_fsm. It's easy to get into this situation >>> since things usually start simple and build up once more functionality is >>> piled on. >>> >>> >> I don't know about this -- I have written numerous gen_servers whose >> state-record include a state-field (although I usually call it 'current'), >> and events (calls, casts, infos) are handled differently depending on its >> value. The reason for not using a gen_fsm is that very often, an event >> should be handled in one way in one particular state, and in another way in >> _all_ other states. This is easy to do using pattern-matching when using a >> gen_server, but when using a gen_fsm you have no choice but to write out >> every state/event combination, which can become pretty cumbersome. >> > > Then one can use an gen_fsm:send_all_state_event/2 and pattern match on > both state and state date that in the modules handle_event/3 function. > I have done that many times and it works rather well. > > Of course, but when you do that for the majority of the events it amounts to the same as using a gen_server with a 'state'-field, doesn't it? -------------- next part -------------- An HTML attachment was scrubbed... URL: From bpdp.erlang@REDACTED Thu Apr 21 12:52:34 2011 From: bpdp.erlang@REDACTED (Bambang Purnomosidi D. P.) Date: Thu, 21 Apr 2011 17:52:34 +0700 Subject: [erlang-questions] Reinstall wxErlang Message-ID: Hi. I recently got a problem in wxErlang installation: 1> wx:demo(). =ERROR REPORT==== 21-Apr-2011::17:05:21 === WX Failed loading "wxe_driver"@"/opt/erlang/otp/lib/erlang/lib/wx-0.98.9/priv" {error,{{load_driver,"symbol _ZN16wxStyledTextCtrl7SendMsgEill, version WXU_2.8 not defined in file libwx_gtk2u_stc-2.8.so.0 with link time reference"}, [{wxe_server,start,0}, {wx,new,1}, {demo,init,1}, {wx_object,init_it,6}, {proc_lib,init_p_do_apply,3}]}} 2> At first, after installation, I can do wx:demo(). That problem exist after I updated wxWidgets. So, my question here is, how do I reinstall wxErlang without reinstall fully Erlang installation? I am using Linux. Thanks! -- bpdp -------------- next part -------------- An HTML attachment was scrubbed... URL: From mazen.harake@REDACTED Thu Apr 21 13:19:33 2011 From: mazen.harake@REDACTED (Mazen Harake) Date: Thu, 21 Apr 2011 13:19:33 +0200 Subject: [erlang-questions] The gen server simplified (how it works) In-Reply-To: References: <70CD76DB-0CB6-4934-8AD7-1F04BC71691D@hates.ms> Message-ID: On 21 April 2011 12:08, Jeroen Koops wrote: > Of course, but when you do that for the majority of the events it amounts > to the same as using a gen_server with a 'state'-field, doesn't it? > When you say "an event should be handled in one way in one particular state, and in another way in _all_ other states" you are essentially talking about a state flag. That flag is a substate of a larger state and it is wrong to compare a state you are in (e.g. as in a gen_fsm state) and a state which you carry to each state (namely the substate or the "State" variable in the gen_fsm if you will). This mix of states (where you use the "State" variable in a gen_server as a variant of gen_fsm's "nextstate") is not recommended but I have seen it a lot. I think this boils down to design firstly and laziness secondly; Developers don't want (as you say) to implement 9 other states that handle a specific message just because 1 state should do it in a special way. What we should have is a gen_fsm which takes "Mod:handle_state(State::atom( ), ...)" rather than "Mod:State(...)" so that we can match on the state in the function header.... but then again... we would be reinventing the wheel because that is what most of us (including me) are already doing sometimes in gen_servers (by moving this state into a substate). Moral of the story, they are not the same and if you end up in a situation that requires a lot of these "state flags" then perhaps a gen_server is not the solution, but also if you have too many "general" states with very few exceptions then perhaps a state flag is more appropriate. /M -------------- next part -------------- An HTML attachment was scrubbed... URL: From pmacgown@REDACTED Thu Apr 21 15:17:53 2011 From: pmacgown@REDACTED (pmacgown@REDACTED) Date: Thu, 21 Apr 2011 13:17:53 +0000 (UTC) Subject: [erlang-questions] Ubuntu, Erlang, and Laptop Questions In-Reply-To: Message-ID: <1581724946.1474175.1303391873389.JavaMail.root@sz0166a.westchester.pa.mail.comcast.net> Hi, I am saving up for a new laptop to run Erlang.? Can't?drag my tower around.? Two questions: 1 - I want to run Ubuntu.? Will Erlang work well with this? (Assuming Ubuntu v10/11) 2 - What's a decent laptop manufacturer/model to run this on?? I've always bought Dell in the past, but I am not wed to this manufacturer. --Peter -------------- next part -------------- An HTML attachment was scrubbed... URL: From rapsey@REDACTED Thu Apr 21 15:32:05 2011 From: rapsey@REDACTED (Rapsey) Date: Thu, 21 Apr 2011 15:32:05 +0200 Subject: [erlang-questions] Ubuntu, Erlang, and Laptop Questions In-Reply-To: <1581724946.1474175.1303391873389.JavaMail.root@sz0166a.westchester.pa.mail.comcast.net> References: <1581724946.1474175.1303391873389.JavaMail.root@sz0166a.westchester.pa.mail.comcast.net> Message-ID: 1. Of course. Erlang pretty much works best on linux since it's the primary development platform as far as I know. Sergej On Thu, Apr 21, 2011 at 3:17 PM, wrote: > Hi, > > I am saving up for a new laptop to run Erlang. Can't drag my tower > around. Two questions: > > > > 1 - I want to run Ubuntu. Will Erlang work well with this? (Assuming > Ubuntu v10/11) > > 2 - What's a decent laptop manufacturer/model to run this on? I've always > bought Dell in the past, but I am not wed to this manufacturer. > > > > --Peter > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dave@REDACTED Thu Apr 21 16:16:44 2011 From: dave@REDACTED (David Goehrig) Date: Thu, 21 Apr 2011 10:16:44 -0400 Subject: [erlang-questions] Say it's not so! Message-ID: So a co-worker of mine sent me a link to a talk by Josh Berkus, http://highscalability.com/blog/2011/4/18/6-ways-not-to-scale-that-will-make-you-hip-popular-and-loved.html in which he issues one of the most horrific attacks ever: [image: Screen shot 2011-04-19 at 11.42.21 AM.png] (for those of you who won't download images, it is a picture of Joe with the words "NOT SEXY" in bright red letters across it). I mean come on, that's really not nice. I felt so bad for Joe, who is such a charming and handsome man. We should, as a community, commission a sculpture of Joe as an Olympian God doing battle with a Hydra to display our appreciation. Dave -- -=-=-=-=-=-=-=-=-=-=- http://blog.dloh.org/ -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: Screen shot 2011-04-19 at 11.42.21 AM.png Type: image/png Size: 100951 bytes Desc: not available URL: From spawn.think@REDACTED Thu Apr 21 16:28:02 2011 From: spawn.think@REDACTED (Ahmed Omar) Date: Thu, 21 Apr 2011 16:28:02 +0200 Subject: [erlang-questions] Say it's not so! In-Reply-To: References: Message-ID: To be fair, the guy had it in a sarcastic way which actually praise Joe :) On Thu, Apr 21, 2011 at 4:16 PM, David Goehrig wrote: > So a co-worker of mine sent me a link to a talk by Josh Berkus, > > > http://highscalability.com/blog/2011/4/18/6-ways-not-to-scale-that-will-make-you-hip-popular-and-loved.html > > in which he issues one of the most horrific attacks ever: > [image: Screen shot 2011-04-19 at 11.42.21 AM.png] > > (for those of you who won't download images, it is a picture of Joe with > the words "NOT SEXY" in bright red letters across it). > > I mean come on, that's really not nice. I felt so bad for Joe, who is such > a charming and handsome man. > > We should, as a community, commission a sculpture of Joe as an Olympian God > doing battle with a Hydra to > display our appreciation. > > Dave > > -- > -=-=-=-=-=-=-=-=-=-=- http://blog.dloh.org/ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -- Best Regards, - Ahmed Omar http://nl.linkedin.com/in/adiaa Follow me on twitter @spawn_think -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: Screen shot 2011-04-19 at 11.42.21 AM.png Type: image/png Size: 100951 bytes Desc: not available URL: From ericbmerritt@REDACTED Thu Apr 21 16:28:52 2011 From: ericbmerritt@REDACTED (Eric Merritt) Date: Thu, 21 Apr 2011 09:28:52 -0500 Subject: [erlang-questions] Ubuntu, Erlang, and Laptop Questions In-Reply-To: <1581724946.1474175.1303391873389.JavaMail.root@sz0166a.westchester.pa.mail.comcast.net> References: <1581724946.1474175.1303391873389.JavaMail.root@sz0166a.westchester.pa.mail.comcast.net> Message-ID: Any laptop just about will work. I would suggest you go with something that has multiple cores so you get true concurrency off the bat. Just about every laptop has that now though. On Thu, Apr 21, 2011 at 8:17 AM, wrote: > Hi, > > I am saving up for a new laptop to run Erlang.? Can't?drag my tower around. > Two questions: > > > > 1 - I want to run Ubuntu.? Will Erlang work well with this? (Assuming Ubuntu > v10/11) > > 2 - What's a decent laptop manufacturer/model to run this on?? I've always > bought Dell in the past, but I am not wed to this manufacturer. > > > > --Peter > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > From hm@REDACTED Thu Apr 21 16:32:40 2011 From: hm@REDACTED (=?ISO-8859-1?Q?H=E5kan_Mattsson?=) Date: Thu, 21 Apr 2011 16:32:40 +0200 Subject: [erlang-questions] The gen server simplified (how it works) In-Reply-To: References: Message-ID: On Wed, Apr 20, 2011 at 10:05 AM, Joe Armstrong wrote: > Many users seem to use the gen_server for absolutely everything > and often force their problems to fit the gen_sever even though the > gen_server is not appropriate for their problems. > > The gen_server is an extremely simple bit of code which can > be easily changed to fit other problems, though people don't > often do this. > > In this posting I'll explain the basic idea of how the gen_server works. > > To illustrate this I've written mini_gs.erl - this is a mini gen_server > if you understand mini_gs.erl you'll have understood 98% of how the > real gen_server works. The real gen_server just adds a load of "bells > and whistles" to mini_gs.erl. I tend to use proc_lib (spawn_link, start_link, init_ack) and sys (handle_system_msg) a lot. They gives you almost all the bells and whistles that gen_server has, but it enables you to have the same simple code structure that you have in your very pedagogic code snippet below. /H?kan PS. By the way, it seems more appropriate to use spawn_link in a function called start_link. > mini_gs.erl has a compatible interface to gen_server.erl (for a subset of > the gen_server API) > > ? -module(mini_gs). > ? -export([start_link/4, call/2]). > > ? %% this module behaves just like the gen-server for a sub-set of the > gen_server > ? %% commands > > ? start_link({local,Name}, Mod, Args, _Opts) -> > ????? register(Name, spawn(fun() -> start(Mod, Args) end)). > > ? call(Name, X) -> > ????? Name ! {self(), Ref = make_ref(), X}, > ????? receive > ?? ??? {Ref, Reply} -> Reply > ????? end. > > ? start(Mod, Args) -> > ???? {ok, State} = Mod:init(Args), > ???? loop(Mod, State). > > ? loop(Mod, State) -> > ???? receive > ???? {From, Tag, X} -> > ??? ??? case Mod:handle_call(X, From, State) of > ??? ??? {reply, R, State1} -> > ??? ??? ??? From ! {Tag, R}, > ??? ??? ??? loop(Mod, State1) > ??? ??? end > ??? end. > > There. That wasn't so painful. The client starts by calling > > ?? min_gs:start_link({local,Name}, Mod, Args, Opts) > > I've ignored Opts in mini_gs, also frozen the name of the server to be of > the form {local, Name} (gen_server has more general arguments for the > name of the server) > > What happens? > > mini_gs calls Mod:init(Args) to initialize the server, this must return > {ok, State} and State becomes the initial state of the server. > > Now mini_gs calls loop(Mod, State.) When mini_gs receives a messag > {From, Tag, X} > it calls Mod:handle_call(X, From, State) which returns {repy, R, State1}. > R1 is sent back to the client, and the server calls loop/2 with the new > state State1. > > That's it. call/2 is an interface routine to abstract out the interface > between the client and the sever. > > Now we can write a simple client application. > > ? -module(kv). > > ? %% These define the client API > ? -export([start/0, store/2,lookup/1]). > > ? %% these must be defined because they are called by gs > ? -export([init/1, handle_call/3]). > > ? -define(GS, mini_gs). > ? %% -define(GS, gen_server). > > ? %% define the client API > > ? start()??????? -> ?GS:start_link({local,someatom}, kv, foo, []). > ? store(Key,Val) -> ?GS:call(someatom, {putval,Key,Val}). > ? lookup(Key)??? -> ?GS:call(someatom, {getval,Key}). > > ? %% define the internal routines > ? init(foo) -> {ok, dict:new()}. > > ? handle_call({putval, Key, Val}, _From, Dict) -> > ???? {reply, ok, dict:store(Key, Val, Dict)}; > ? handle_call({getval,Key}, _From, Dict) -> > ??? {reply, dict:find(Key, Dict), Dict}. > > This module can call either gen_server or mini_gs (just change the > define statement) > > So now we have turned a single process key-value store (using dict) > into a global key-value store.? Note that kv.erl never uses the primitives > spawn_link, send, receive or do on. ie kv.erl is written with pure > *sequential* code. > > This is *why* we made the gen_server abstraction. You can write > well-typed sequential code (the handle_call and init functions) to > parametrize > a concurrent behavior, ie you need to know nothing about concurrency > to get the job done. We've "abstracted out" the concurrency. > > Things become problematic when you do not entirely understand the > abstraction. Maybe the abstraction is inappropriate for your needs. I > have seen many examples of code where the gen_server *is* inappropriate. > The acid test is "does the gen_sever code look like spaghetti" if the > answer is yes then all you have done is shoe horn the applications into > an inappropriate form. In this case you should ditch the gen_server and > roll-your own. > > /Joe From qwertymaniac@REDACTED Thu Apr 21 16:33:17 2011 From: qwertymaniac@REDACTED (Harsh J) Date: Thu, 21 Apr 2011 20:03:17 +0530 Subject: [erlang-questions] Say it's not so! In-Reply-To: References: Message-ID: I believe the OP knows that :P On Apr 21, 2011 7:58 PM, "Ahmed Omar" wrote: > > To be fair, the guy had it in a sarcastic way which actually praise Joe :) > > > On Thu, Apr 21, 2011 at 4:16 PM, David Goehrig wrote: >> >> So a co-worker of mine sent me a link to a talk by Josh Berkus, >> >> http://highscalability.com/blog/2011/4/18/6-ways-not-to-scale-that-will-make-you-hip-popular-and-loved.html >> >> in which he issues one of the most horrific attacks ever: >> >> (for those of you who won't download images, it is a picture of Joe with the words "NOT SEXY" in bright red letters across it). >> >> I mean come on, that's really not nice. I felt so bad for Joe, who is such a charming and handsome man. >> >> We should, as a community, commission a sculpture of Joe as an Olympian God doing battle with a Hydra to >> display our appreciation. >> >> Dave >> >> -- >> -=-=-=-=-=-=-=-=-=-=- http://blog.dloh.org/ >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> > > > > -- > Best Regards, > - Ahmed Omar > http://nl.linkedin.com/in/adiaa > Follow me on twitter > @spawn_think > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From erlang@REDACTED Thu Apr 21 17:02:43 2011 From: erlang@REDACTED (Joe Armstrong) Date: Thu, 21 Apr 2011 17:02:43 +0200 Subject: [erlang-questions] float to ieee -754 single and double representation Message-ID: Has anybody some Erlang code to convert an erlang float to an ieee-754 32 and 64 bit hex representation? For 64-bit <> appears to do the job, what about 32 bit? /Joe -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf.wiger@REDACTED Thu Apr 21 17:06:03 2011 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Thu, 21 Apr 2011 17:06:03 +0200 Subject: [erlang-questions] The gen server simplified (how it works) In-Reply-To: References: Message-ID: <6791C5AD-9588-42D0-9F96-51DC6CDBCE07@erlang-solutions.com> Personally, I like to use plain_fsm, so I don't have to worry about writing that boring code to handle system messages. https://github.com/esl/plain_fsm It doesn't force you to use the parse transformery and pseudo functions; you can e.g. use https://github.com/esl/plain_fsm/blob/master/doc/plain_fsm.md#handle_system_msg-4 and simply have plain_fsm as a library for those system message handlers. BR, Ulf W On 21 Apr 2011, at 16:32, H?kan Mattsson wrote: > I tend to use proc_lib (spawn_link, start_link, init_ack) and sys > (handle_system_msg) a lot. They gives you almost all the bells and > whistles that gen_server has, but it enables you to have the same > simple code structure that you have in your very pedagogic code > snippet below. Ulf Wiger, CTO, Erlang Solutions, Ltd. http://erlang-solutions.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From carlo.bertoldi@REDACTED Thu Apr 21 17:10:46 2011 From: carlo.bertoldi@REDACTED (Carlo Bertoldi) Date: Thu, 21 Apr 2011 17:10:46 +0200 Subject: [erlang-questions] http:request Message-ID: <4DB048F6.9000704@ubiquity.it> Good afternoon, I have a problem with http:request. The system in use is Erlang R13B03 (erts-5.7.4) [source] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false] I'm also able to reproduce the problem on: Erlang R14A (erts-5.8) [source] [64-bit] [smp:4:4] [rq:4] [async-threads:0] [kernel-poll:false] I'm doing a simple HTTP GET to a webserver, here is the code, url omitted: Result = http:request(get, {CompleteUrl, [{"User-Agent", "Erl-bot"}]}, [], []), io:format("Result = ~p~n", [Result]). Occasionally I don't see Result printed, but a nice error: ** Reason for termination == ** {{badmatch,{16,6,18}}, [{handle_probe,start_probe,2}, {handle_probe,handle_cast,2}, {gen_server,handle_msg,5}, {proc_lib,init_p_do_apply,3}]} I ran Wireshark to capture the requests made, both the badmatch one and the correct one. I can't spot any relevant differences, excluding the timestamp. Can someone help me? Thank you, Carlo Bertoldi From tony@REDACTED Thu Apr 21 18:18:25 2011 From: tony@REDACTED (Tony Rogvall) Date: Thu, 21 Apr 2011 18:18:25 +0200 Subject: [erlang-questions] float to ieee -754 single and double representation In-Reply-To: References: Message-ID: <7179BEFF-191F-485B-82E4-ABF460151F21@rogvall.se> On 21 apr 2011, at 17.02, Joe Armstrong wrote: > Has anybody some Erlang code to convert an erlang float > to an ieee-754 32 and 64 bit hex representation? > > For 64-bit <> appears to do the job, what about 32 bit? > <<1.0:32/float>>. <<63,128,0,0>> 3> <<1.0:64/float>>. <<63,240,0,0,0,0,0,0>> /Tony > /Joe > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions "Have run Make so many times I dunno what's installed anymore" -------------- next part -------------- An HTML attachment was scrubbed... URL: From mazen.harake@REDACTED Thu Apr 21 18:25:37 2011 From: mazen.harake@REDACTED (Mazen Harake) Date: Thu, 21 Apr 2011 18:25:37 +0200 Subject: [erlang-questions] Say it's not so! In-Reply-To: References: Message-ID: Sarcasm on sarcasm... Interesting On 21 April 2011 16:33, Harsh J wrote: > I believe the OP knows that :P > > On Apr 21, 2011 7:58 PM, "Ahmed Omar" wrote: > > > > To be fair, the guy had it in a sarcastic way which actually praise Joe > :) > > > > > > On Thu, Apr 21, 2011 at 4:16 PM, David Goehrig > wrote: > >> > >> So a co-worker of mine sent me a link to a talk by Josh Berkus, > >> > >> > http://highscalability.com/blog/2011/4/18/6-ways-not-to-scale-that-will-make-you-hip-popular-and-loved.html > >> > >> in which he issues one of the most horrific attacks ever: > >> > >> (for those of you who won't download images, it is a picture of Joe with > the words "NOT SEXY" in bright red letters across it). > >> > >> I mean come on, that's really not nice. I felt so bad for Joe, who is > such a charming and handsome man. > >> > >> We should, as a community, commission a sculpture of Joe as an Olympian > God doing battle with a Hydra to > >> display our appreciation. > >> > >> Dave > >> > >> -- > >> -=-=-=-=-=-=-=-=-=-=- http://blog.dloh.org/ > >> > >> _______________________________________________ > >> erlang-questions mailing list > >> erlang-questions@REDACTED > >> http://erlang.org/mailman/listinfo/erlang-questions > >> > > > > > > > > -- > > Best Regards, > > - Ahmed Omar > > http://nl.linkedin.com/in/adiaa > > Follow me on twitter > > @spawn_think > > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf.wiger@REDACTED Thu Apr 21 18:30:20 2011 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Thu, 21 Apr 2011 18:30:20 +0200 Subject: [erlang-questions] The gen server simplified (how it works) In-Reply-To: <1a4a4bf0-0b0a-4a01-b872-1351c50aa307@email.android.com> References: <6791C5AD-9588-42D0-9F96-51DC6CDBCE07@erlang-solutions.com> <1a4a4bf0-0b0a-4a01-b872-1351c50aa307@email.android.com> Message-ID: <62C957E1-0075-44BF-A87B-93063FE80627@erlang-solutions.com> I'd love to see how you handle system messages in two lines of code, without reusing some library. :) Usually, it involves writing your own versions of system_continue/3, system_terminate/4, system_code_change/4, and format_status/2. BR, Ulf W On 21 Apr 2011, at 18:14, H?kan Mattsson wrote: > I gladly write two lines of code to handle system > messages, if that enables me to avoid a boring > template. I really like the simplicity of Joe's code > snippet. It is easy to understand and does not > imply any black magic. It is just proc_lib that is > missing... > > /H?kan > > PS. You did also have two "boring" lines in your > template to handle code change. > > > "Ulf Wiger" wrote: > >> >> Personally, I like to use plain_fsm, so I don't have to worry about >> writing that boring code to handle system messages. >> >> https://github.com/esl/plain_fsm >> >> It doesn't force you to use the parse transformery and pseudo >> functions; you can e.g. use >> >> https://github.com/esl/plain_fsm/blob/master/doc/plain_fsm.md#handle_system_msg-4 >> >> and simply have plain_fsm as a library for those system message >> handlers. >> >> BR, >> Ulf W >> >> On 21 Apr 2011, at 16:32, H?kan Mattsson wrote: >> >>> I tend to use proc_lib (spawn_link, start_link, init_ack) and sys >>> (handle_system_msg) a lot. They gives you almost all the bells and >>> whistles that gen_server has, but it enables you to have the same >>> simple code structure that you have in your very pedagogic code >>> snippet below. >> >> Ulf Wiger, CTO, Erlang Solutions, Ltd. >> http://erlang-solutions.com > > -- > Sent from my Android phone with K-9 Mail. Please excuse my brevity. Ulf Wiger, CTO, Erlang Solutions, Ltd. http://erlang-solutions.com From juanjo@REDACTED Thu Apr 21 18:49:24 2011 From: juanjo@REDACTED (Juan Jose Comellas) Date: Thu, 21 Apr 2011 13:49:24 -0300 Subject: [erlang-questions] Ubuntu, Erlang, and Laptop Questions In-Reply-To: <1581724946.1474175.1303391873389.JavaMail.root@sz0166a.westchester.pa.mail.comcast.net> References: <1581724946.1474175.1303391873389.JavaMail.root@sz0166a.westchester.pa.mail.comcast.net> Message-ID: Erlang will run on practically any laptop you can buy nowadays. I would focus more on buying a laptop where Ubuntu runs without any problems. Beware of the ones with NVIDIA Optimus video cards, as they aren't supported on Linux. Also, you should probably choose one with an Atheros WiFi chipset or anything else that you know runs without any trouble. On Thu, Apr 21, 2011 at 10:17 AM, wrote: > Hi, > > I am saving up for a new laptop to run Erlang.? Can't?drag my tower around. > Two questions: > > > > 1 - I want to run Ubuntu.? Will Erlang work well with this? (Assuming Ubuntu > v10/11) > > 2 - What's a decent laptop manufacturer/model to run this on?? I've always > bought Dell in the past, but I am not wed to this manufacturer. > > > > --Peter > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > From essen@REDACTED Thu Apr 21 19:03:48 2011 From: essen@REDACTED (=?ISO-8859-1?Q?Lo=EFc_Hoguin?=) Date: Thu, 21 Apr 2011 19:03:48 +0200 Subject: [erlang-questions] Say it's not so! In-Reply-To: References: Message-ID: <4DB06374.4050804@dev-extend.eu> On 04/21/2011 04:16 PM, David Goehrig wrote: > We should, as a community, commission a sculpture of Joe as an Olympian > God doing battle with a Hydra to > display our appreciation. Count us in as sponsors. -- Lo?c Hoguin Dev:Extend From davis@REDACTED Thu Apr 21 19:28:35 2011 From: davis@REDACTED (Scott Davis) Date: Thu, 21 Apr 2011 10:28:35 -0700 Subject: [erlang-questions] Say it's not so! In-Reply-To: <4DB06374.4050804@dev-extend.eu> References: <4DB06374.4050804@dev-extend.eu> Message-ID: How about Joe *harnessing* Hydra? S.D. On 04/21/2011 04:16 PM, David Goehrig wrote: > We should, as a community, commission a sculpture of Joe as an > Olympian > God doing battle with a Hydra to > display our appreciation. From dan@REDACTED Thu Apr 21 20:54:18 2011 From: dan@REDACTED (Daniel Dormont) Date: Thu, 21 Apr 2011 14:54:18 -0400 Subject: [erlang-questions] Module config data and functional programming Message-ID: Hi, I have been learning Erlang for about two months and I'm just now building my first real module, and I'm running into this question. The module is for Ejabberd, but I think that's incidental to my main question. Ejabberd offers a behavior called gen_mod which calls for two functions, start/2 and stop/1, which in my example look kind of like this: start(Host, Opts) -> ejabberd_hooks:add(some_hook, global, ?MODULE, some_function). stop(Host) -> ejabberd_hooks:delete(some_hook, global, ?MODULE, some_function). some_function(List) -> lists:filter(fun my_filter/1, List). my_filter(Value) -> %complex logic here% The idea being that the module can be initialized with some options that were passed from a config file. FYI, ejabberd_hooks is used to register and unregister callbacks for certain events. What I have above works fine, but now I'm in a situation where my_filter needs access to data that came from Opts. I could convert the module to gen_server and store the Opts as my initial state, have some_function use gen_server:call, and inside my handle_call pass the appropriate elements from my StateData to the filter function my_filter. But I'm hesitant to do this for two reasons: - the StateData will never change because there really is no mutable state in this module. This seems like a misuse of gen_server. - because there's no state, I'd like to allow multiple simultaneous calls to some_function for speed reasons, and have the module stay as a library module. Am I wrong about these? Is this a perfectly normal use of gen_server? Is forcing all calls into a single process not actually a bottleneck? Or is there another way of doing this? Would ETS be useful, or would that eliminate the supposed advantages I'm trying to gain? FWIW, ejabberd_hooks does allow an actual function to be passed instead of an atom containing a function name. thanks, Dan From pablo.platt@REDACTED Thu Apr 21 21:42:03 2011 From: pablo.platt@REDACTED (Pablo Platt) Date: Thu, 21 Apr 2011 12:42:03 -0700 (PDT) Subject: [erlang-questions] use only parts of a release Message-ID: <496034.29700.qm@web112619.mail.gq1.yahoo.com> Hi How does release_handler get the info of the current release? Is it possible to copy only parts of a release and use it on another machine with an erlang installation but still be able to use hot code upgrades? I'm creating a deb package from a release generated with rebar. I copy myapp, the releases folder and a modified start script to /usr/lib/ in the install file of the deb package: ../../myapp/rel/myapp/lib/myapp* /usr/lib/myapp/lib ../../myapp/rel/myapp/releases /usr/lib/myapp usr/lib/myapp/bin The myapp/bin/myapp script is updated with the new paths. I'm able to install and run myapp but release_handler:which_releases() show the info of the default erlang runtime instead of my release. How can I fix it? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From olivier.girondel@REDACTED Fri Apr 22 03:56:59 2011 From: olivier.girondel@REDACTED (Olivier Girondel) Date: Fri, 22 Apr 2011 03:56:59 +0200 Subject: [erlang-questions] Ubuntu, Erlang, and Laptop Questions In-Reply-To: References: <1581724946.1474175.1303391873389.JavaMail.root@sz0166a.westchester.pa.mail.comcast.net> Message-ID: ASUS laptops work just fine, both in 32 or 64 bits -- Olivier / http://biniou.net From bo.zhang86@REDACTED Fri Apr 22 05:36:55 2011 From: bo.zhang86@REDACTED (zhangbo) Date: Fri, 22 Apr 2011 11:36:55 +0800 Subject: [erlang-questions] some questions about epmd and inet_dist_listen_min/max Message-ID: <88D3CBED-F955-450B-9D3A-B3E54850A794@gmail.com> Hi Could someone tell me the function of inet_dist_listen_min/max in distributed env ? Another, I guess there is a relation between epmd and ports of inet_dist_listen_min/max, if it's true, could somebody tell me the detail about the relation? Thanks. Bob email: bo.zhang86@REDACTED MSN: zb_861986@REDACTED From banibrata.dutta@REDACTED Fri Apr 22 06:42:27 2011 From: banibrata.dutta@REDACTED (Banibrata Dutta) Date: Fri, 22 Apr 2011 10:12:27 +0530 Subject: [erlang-questions] Ubuntu, Erlang, and Laptop Questions In-Reply-To: References: <1581724946.1474175.1303391873389.JavaMail.root@sz0166a.westchester.pa.mail.comcast.net> Message-ID: On Fri, Apr 22, 2011 at 7:26 AM, Olivier Girondel < olivier.girondel@REDACTED> wrote: > ASUS laptops work just fine, both in 32 or 64 bits > > now, I guess this is OT :-) : As noted by others, the most usual sources of worry for Linux are: Wireless (WiFi) chipsets, graphics accelerator, and sound chipset, so the best approach is to first shortlist a bunch of models, figure out the details for those 3 worrysome parts, check the forums for compatibility issues for your target, and if you don't find any, figure out the HW compatibility list, for the specific version(s) of your favourtie Linux distros. The biggest source of pain is usually the devices which are the lowest end of the market, typically the ones which rely too much on host-CPU's computation power, and themselves do only limited necessary yet light-weight things that CPU can't. Coming back to Erlang, my initial experience with Erlang with Ubuntu was bit different compared to my experience with Erlang on Windows. My installation of Erlang on Ubuntu 9.04 took a bit more of knowledge of Ubuntu's Erlang packaging, what might be needed (or not), so it is not (or was not) as dumbed-down as it is on Windows. In the end however, the flexibility of package choices was handy when I was trying to minimize disk footprint of installed software, and could get away with much lesser that it might have been otherwise. -------------- next part -------------- An HTML attachment was scrubbed... URL: From small@REDACTED Fri Apr 22 08:14:20 2011 From: small@REDACTED (Des Small) Date: Fri, 22 Apr 2011 08:14:20 +0200 (CEST) Subject: [erlang-questions] Ubuntu, Erlang, and Laptop Questions In-Reply-To: References: <1581724946.1474175.1303391873389.JavaMail.root@sz0166a.westchester.pa.mail.comcast.net> Message-ID: On Thu, 21 Apr 2011, Eric Merritt wrote: > Any laptop just about will work. I would suggest you go with something > that has multiple cores so you get true concurrency off the bat. Just > about every laptop has that now though. At the bottom end, I have had occasion to use Erlang on my Asus eee netbook with 1 Gb of RAM and a single-core Atom processor. (You can get these for under EUR 200 these days.) It isn't very fast and I'm very glad it isn't my main development environment, but it does work OK and it fits neatly into my handluggage for flights. Cheers, Des -- Des Small, Scientific Programmer, JIVE Contact details on http://www.jive.nl/~small From carlo.bertoldi@REDACTED Fri Apr 22 09:37:50 2011 From: carlo.bertoldi@REDACTED (Carlo Bertoldi) Date: Fri, 22 Apr 2011 09:37:50 +0200 Subject: [erlang-questions] http:request In-Reply-To: <4DB048F6.9000704@ubiquity.it> References: <4DB048F6.9000704@ubiquity.it> Message-ID: <4DB1304E.8080904@ubiquity.it> Il 21/04/2011 17:10, Carlo Bertoldi ha scritto: > Good afternoon, > I have a problem with http:request. > > > Result = http:request(get, {CompleteUrl, [{"User-Agent", "Erl-bot"}]}, > [], []), > io:format("Result = ~p~n", [Result]). > > Occasionally I don't see Result printed, but a nice error: > ** Reason for termination == > ** {{badmatch,{16,6,18}}, Hello, I discovered the cause of the badmatch: it was due to the debug macro I've defined. Here it is: -define(DBG(Str, Args), {Year, Month, Day} = date(), {Hour, Min, Sec} = time(), io:format("~2.10.0B/~2.10.0B/~4B ~2.10.0B:~2.10.0B:~2.10.0B [~p:~p] - ", [Day, Month, Year, Hour, Min, Sec, ?MODULE, ?LINE]), io:format(Str, Args)). Can someone explain me what I did wrong here? Why should I obtain a badmatch on {Hour, Min, Sec} = time() ? Thank you, Carlo From max.lapshin@REDACTED Fri Apr 22 09:45:17 2011 From: max.lapshin@REDACTED (Max Lapshin) Date: Fri, 22 Apr 2011 11:45:17 +0400 Subject: [erlang-questions] Is it possible to compile crypto app with _static_ libcrypto Message-ID: I've downloaded debian source package and decided to rebuild it with --disable-dynamic-ssl-lib As a result, I've finished with: x86_64-linux-gnu-gcc -c -o ../priv/obj/x86_64-pc-linux-gnu/crypto.o -Wall -Wstrict-prototypes -Wmissing-prototypes -Wdeclaration-after-statement -DUSE_THREADS -D_THREAD_SAFE -D_REENTRANT -DPOSIX_THREADS -D_POSIX_THREAD_SAFE_FUNCTIONS -g -O2 -fno-strict-aliasing -I/var/tmp/erlang/erlang-14.b.2-dfsg/erts/x86_64-pc-linux-gnu -fno-tree-copyrename -D_GNU_SOURCE -fPIC -I/usr/include -I/var/tmp/erlang/erlang-14.b.2-dfsg/erts/emulator/beam -I/var/tmp/erlang/erlang-14.b.2-dfsg/erts/include -I/var/tmp/erlang/erlang-14.b.2-dfsg/erts/include/x86_64-pc-linux-gnu -I/var/tmp/erlang/erlang-14.b.2-dfsg/erts/include/internal -I/var/tmp/erlang/erlang-14.b.2-dfsg/erts/include/internal/x86_64-pc-linux-gnu -I/var/tmp/erlang/erlang-14.b.2-dfsg/erts/emulator/sys/unix crypto.c /usr/bin/install -c -d ../priv/lib/x86_64-pc-linux-gnu x86_64-linux-gnu-gcc -shared -Wl,-Bsymbolic -o ../priv/lib/x86_64-pc-linux-gnu/crypto.so ../priv/obj/x86_64-pc-linux-gnu/crypto.o /usr/lib64/libcrypto.a /usr/bin/ld: /usr/lib64/libcrypto.a(cryptlib.o): relocation R_X86_64_32 against `OPENSSL_ia32cap_P' can not be used when making a shared object; recompile with -fPIC /usr/lib64/libcrypto.a: could not read symbols: Bad value I want to do it because I want to make release that has no dependencies on system packages and libcrypto seems to be the only one. Or it would be better to copy libcrypto.so to release folder? From kostis@REDACTED Fri Apr 22 09:49:14 2011 From: kostis@REDACTED (Kostis Sagonas) Date: Fri, 22 Apr 2011 10:49:14 +0300 Subject: [erlang-questions] http:request In-Reply-To: <4DB1304E.8080904@ubiquity.it> References: <4DB048F6.9000704@ubiquity.it> <4DB1304E.8080904@ubiquity.it> Message-ID: <4DB132FA.7010802@cs.ntua.gr> Carlo Bertoldi wrote: > Il 21/04/2011 17:10, Carlo Bertoldi ha scritto: >> Good afternoon, >> I have a problem with http:request. >> > >> >> Result = http:request(get, {CompleteUrl, [{"User-Agent", "Erl-bot"}]}, >> [], []), >> io:format("Result = ~p~n", [Result]). >> >> Occasionally I don't see Result printed, but a nice error: >> ** Reason for termination == >> ** {{badmatch,{16,6,18}}, > > Hello, I discovered the cause of the badmatch: it was due to the debug > macro I've defined. > Here it is: > > -define(DBG(Str, Args), > {Year, Month, Day} = date(), > {Hour, Min, Sec} = time(), > io:format("~2.10.0B/~2.10.0B/~4B ~2.10.0B:~2.10.0B:~2.10.0B [~p:~p] - > ", [Day, Month, > Year, Hour, Min, Sec, ?MODULE, ?LINE]), io:format(Str, Args)). > > Can someone explain me what I did wrong here? Why should I obtain a > badmatch on {Hour, Min, Sec} = time() ? A typical reason for this is if you used the macro in some context where variables named Hour, Min, and Sec already existed. This is called name capture and is a typical problem of macros. You should carefully examine all places in the code where this macro is used. Alternatively, you can try to minimize the risk of name capture by changing the macro to e.g.: -define(DBG(Str, Args), {Year__, Month__, Day__} = date(), {Hour__, Min__, Sec__} = time(), io:format("~2.10.0B/~2.10.0B/~4B ~2.10.0B:~2.10.0B:~2.10.0B [~p:~p] - ", [Day__, Month__, Year__, Hour__, Min__, Sec__, ?MODULE, ?LINE]), io:format(Str, Args)). Kostis From klas.johansson@REDACTED Fri Apr 22 10:17:53 2011 From: klas.johansson@REDACTED (Klas Johansson) Date: Fri, 22 Apr 2011 10:17:53 +0200 Subject: [erlang-questions] http:request In-Reply-To: <4DB132FA.7010802@cs.ntua.gr> References: <4DB048F6.9000704@ubiquity.it> <4DB1304E.8080904@ubiquity.it> <4DB132FA.7010802@cs.ntua.gr> Message-ID: On Fri, Apr 22, 2011 at 9:49 AM, Kostis Sagonas wrote: > Carlo Bertoldi wrote: >> >> Il 21/04/2011 17:10, Carlo Bertoldi ha scritto: >>> >>> Good afternoon, >>> ?I have a problem with http:request. >>> >> >>> >>> Result = http:request(get, {CompleteUrl, [{"User-Agent", "Erl-bot"}]}, >>> [], []), >>> io:format("Result = ~p~n", [Result]). >>> >>> Occasionally I don't see Result printed, but a nice error: >>> ** Reason for termination == >>> ** {{badmatch,{16,6,18}}, >> >> Hello, I discovered the cause of the badmatch: it was due to the debug >> macro I've defined. >> Here it is: >> >> -define(DBG(Str, Args), >> ?{Year, Month, Day} = date(), >> ?{Hour, Min, Sec} = time(), >> ?io:format("~2.10.0B/~2.10.0B/~4B ~2.10.0B:~2.10.0B:~2.10.0B [~p:~p] - ", >> [Day, Month, >> ? ? ? Year, Hour, Min, Sec, ?MODULE, ?LINE]), io:format(Str, Args)). >> >> Can someone explain me what I did wrong here? Why should I obtain a >> badmatch on {Hour, Min, Sec} = time() ? > > A typical reason for this is if you used the macro in some context where > variables named Hour, Min, and Sec already existed. ?This is called name > capture and is a typical problem of macros. You should carefully examine all > places in the code where this macro is used. ?Alternatively, you can try to > minimize the risk of name capture by changing the macro to e.g.: > > -define(DBG(Str, Args), > ? ? ? ?{Year__, Month__, Day__} = date(), > ? ? ? ?{Hour__, Min__, Sec__} = time(), > ? io:format("~2.10.0B/~2.10.0B/~4B ~2.10.0B:~2.10.0B:~2.10.0B [~p:~p] - ?", > [Day__, Month__, Year__, Hour__, Min__, Sec__, ?MODULE, ?LINE]), > io:format(Str, Args)). Perhaps you're using the same macro in multiple places in the same scope (for example on two consecutive lines)? Like this: some_function(...) -> ... ?DBG("foo ~p", [SomeVal1]), ... ?DBG("bar ~p", [SomeVal2]), ... Now, the macro will be expanded during preprocessing: some_function(...) -> ... {Year__, Month__, Day__} = date(), {Hour__, Min__, Sec__} = time(), ... {Year__, Month__, Day__} = date(), {Hour__, Min__, Sec__} = time(), ... Since time flies, seconds etc. change and will no longer match ==> badmatch. I guess you could either write a function which prints the timestamp (and takes ?LINE as a parameter) or use a trick like eunit uses for its assert macros to bind variables in a new scope (it looks a bit funny and you still need to take care to use unique variable names like Kostis suggested): (fun() -> {Year__, Month__, Day__} = date(), ... end)() https://github.com/erlang/otp/blob/dev/lib/eunit/include/eunit.hrl#L141 Cheers, Klas From lenartlad@REDACTED Fri Apr 22 10:33:23 2011 From: lenartlad@REDACTED (Ladislav Lenart) Date: Fri, 22 Apr 2011 10:33:23 +0200 Subject: [erlang-questions] http:request In-Reply-To: <4DB132FA.7010802@cs.ntua.gr> References: <4DB048F6.9000704@ubiquity.it> <4DB1304E.8080904@ubiquity.it> <4DB132FA.7010802@cs.ntua.gr> Message-ID: <4DB13D53.3020205@volny.cz> Hello, see my answer below. On 22.4.2011 09:49, Kostis Sagonas wrote: > Carlo Bertoldi wrote: >> Il 21/04/2011 17:10, Carlo Bertoldi ha scritto: >>> Good afternoon, >>> I have a problem with http:request. >>> >> >>> >>> Result = http:request(get, {CompleteUrl, [{"User-Agent", "Erl-bot"}]}, [], []), >>> io:format("Result = ~p~n", [Result]). >>> >>> Occasionally I don't see Result printed, but a nice error: >>> ** Reason for termination == >>> ** {{badmatch,{16,6,18}}, >> >> Hello, I discovered the cause of the badmatch: it was due to the debug macro I've defined. >> Here it is: >> >> -define(DBG(Str, Args), >> {Year, Month, Day} = date(), >> {Hour, Min, Sec} = time(), >> io:format("~2.10.0B/~2.10.0B/~4B ~2.10.0B:~2.10.0B:~2.10.0B [~p:~p] - ", [Day, Month, >> Year, Hour, Min, Sec, ?MODULE, ?LINE]), io:format(Str, Args)). >> >> Can someone explain me what I did wrong here? Why should I obtain a badmatch on {Hour, Min, Sec} = time() ? > > A typical reason for this is if you used the macro in some context where variables named Hour, Min, and Sec already existed. This is called name capture and is a typical problem of macros. You should > carefully examine all places in the code where this macro is used. Alternatively, you can try to minimize the risk of name capture by changing the macro to e.g.: > > -define(DBG(Str, Args), > {Year__, Month__, Day__} = date(), > {Hour__, Min__, Sec__} = time(), > io:format("~2.10.0B/~2.10.0B/~4B ~2.10.0B:~2.10.0B:~2.10.0B [~p:~p] - ", [Day__, Month__, Year__, Hour__, Min__, Sec__, ?MODULE, ?LINE]), io:format(Str, Args)). If you plan to use ?DBG macro more than once in the same function, you might want to wrap it in an anonymous fun to prevent its variables from leaking to the function where the macro is used: -define(DBG(Str, Args), fun () -> {Year__, Month__, Day__} = date(), {Hour__, Min__, Sec__} = time(), io:format("~2.10.0B/~2.10.0B/~4B ~2.10.0B:~2.10.0B:~2.10.0B [~p:~p] - ", [Day__, Month__, Year__, Hour__, Min__, Sec__, ?MODULE, ?LINE]), io:format(Str, Args), ok end()). With this modification, the following should be possible: some_fun() -> ?DBG("foo", []), ?DBG("bar", []), ok. However, as Kostis said, the following will still raise a badmatch error: some_other_fun(Year__) -> ?DBG("foo", []), ok. HTH, Ladislav Lenart From zerthurd@REDACTED Fri Apr 22 11:06:37 2011 From: zerthurd@REDACTED (Maxim Treskin) Date: Fri, 22 Apr 2011 16:06:37 +0700 Subject: [erlang-questions] Is it possible to compile crypto app with _static_ libcrypto In-Reply-To: References: Message-ID: Seems option --disable-dynamic-ssl-lib has no effect for crypto application in OTP. Bug? On 22 April 2011 14:45, Max Lapshin wrote: > I've downloaded debian source package and decided to rebuild it with > --disable-dynamic-ssl-lib > > As a result, I've finished with: > > x86_64-linux-gnu-gcc -c -o ../priv/obj/x86_64-pc-linux-gnu/crypto.o > -Wall -Wstrict-prototypes -Wmissing-prototypes > -Wdeclaration-after-statement -DUSE_THREADS -D_THREAD_SAFE > -D_REENTRANT -DPOSIX_THREADS -D_POSIX_THREAD_SAFE_FUNCTIONS -g -O2 > -fno-strict-aliasing > -I/var/tmp/erlang/erlang-14.b.2-dfsg/erts/x86_64-pc-linux-gnu > -fno-tree-copyrename -D_GNU_SOURCE -fPIC -I/usr/include > -I/var/tmp/erlang/erlang-14.b.2-dfsg/erts/emulator/beam > -I/var/tmp/erlang/erlang-14.b.2-dfsg/erts/include > -I/var/tmp/erlang/erlang-14.b.2-dfsg/erts/include/x86_64-pc-linux-gnu > -I/var/tmp/erlang/erlang-14.b.2-dfsg/erts/include/internal > > -I/var/tmp/erlang/erlang-14.b.2-dfsg/erts/include/internal/x86_64-pc-linux-gnu > -I/var/tmp/erlang/erlang-14.b.2-dfsg/erts/emulator/sys/unix crypto.c > /usr/bin/install -c -d ../priv/lib/x86_64-pc-linux-gnu > x86_64-linux-gnu-gcc -shared -Wl,-Bsymbolic -o > ../priv/lib/x86_64-pc-linux-gnu/crypto.so > ../priv/obj/x86_64-pc-linux-gnu/crypto.o /usr/lib64/libcrypto.a > /usr/bin/ld: /usr/lib64/libcrypto.a(cryptlib.o): relocation > R_X86_64_32 against `OPENSSL_ia32cap_P' can not be used when making a > shared object; recompile with -fPIC > /usr/lib64/libcrypto.a: could not read symbols: Bad value > > > > I want to do it because I want to make release that has no > dependencies on system packages and libcrypto seems to be the only > one. > Or it would be better to copy libcrypto.so to release folder? > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -- Maxim Treskin -------------- next part -------------- An HTML attachment was scrubbed... URL: From per.melin@REDACTED Fri Apr 22 11:34:21 2011 From: per.melin@REDACTED (Per Melin) Date: Fri, 22 Apr 2011 11:34:21 +0200 Subject: [erlang-questions] Module config data and functional programming In-Reply-To: References: Message-ID: On Thu, Apr 21, 2011 at 8:54 PM, Daniel Dormont wrote: > start(Host, Opts) -> ejabberd_hooks:add(some_hook, global, ?MODULE, some_function). > stop(Host) -> ejabberd_hooks:delete(some_hook, global, ?MODULE, some_function). > > some_function(List) -> lists:filter(fun my_filter/1, List). > > my_filter(Value) -> %complex logic here% > > The idea being that the module can be initialized with some options that were passed from a config file. FYI, ejabberd_hooks is used to register and unregister callbacks for certain events. > > What I have above works fine, but now I'm in a situation where my_filter needs access to data that came from Opts. I've never used ejabberd but I peeked at the documentation for ejabberd_hooks:add/3,4,5 and it looks like you can also give it a fun. So a closure could carry the value of Opts for you: start(_Host, Opts) -> ejabberd_hooks:add(some_hook, make_hook_fun(Opts), 1). make_hook_fun(Opts) -> fun(List) -> lists:filter(fun(Value) -> my_filter(Value, Opts) end, List) end. my_filter(Value, Opts) -> %complex logic here% The problem then becomes your stop function since ejabberd_hooks:delete/3,4,5 needs to be passed the exact same fun it seems. You would need to either hold on to the return value of make_hook_fun(Opts) or the Opts themselves and pass that to the stop function. There is also the issue of code updates. If ejabberd stores your fun in an ETS table and you reload your module with a different version of make_hook_fun/1 then the fun in ETS will crash the next time it is invoked. From barcojie@REDACTED Fri Apr 22 12:02:46 2011 From: barcojie@REDACTED (Barco You) Date: Fri, 22 Apr 2011 18:02:46 +0800 Subject: [erlang-questions] What's the difference between spawn(Node, Module, Fun, Args) and rpc:call(Node, Module, Fun, Args)? Message-ID: I'm baffled to distinguish these two usages of RPC and don't know when should use which. I appreciate your explanations! Best regards, Barco -------------- next part -------------- An HTML attachment was scrubbed... URL: From jesper.louis.andersen@REDACTED Fri Apr 22 12:08:58 2011 From: jesper.louis.andersen@REDACTED (Jesper Louis Andersen) Date: Fri, 22 Apr 2011 12:08:58 +0200 Subject: [erlang-questions] What's the difference between spawn(Node, Module, Fun, Args) and rpc:call(Node, Module, Fun, Args)? In-Reply-To: References: Message-ID: On Fri, Apr 22, 2011 at 12:02, Barco You wrote: > I'm baffled to distinguish these two usages of RPC and don't know when > should use which. I appreciate your explanations! spawn starts off another process that then acts on its own. rpc:call/4 evaluates a function on another node, but afterwards it returns the result of that function. There is no new process afterwards. If you look at the return from rpc:call/4, you see: call(Node, Module, Function, Args) -> Res | {badrpc, Reason} where 'Res' is a term() - the result of apply(Module, Function, Args). Spawn: spawn(Node, Module, Function, Args) -> pid() returns a process identifier for the newly spawned function. rpc:call/4 is implemented with spawn however, so that might be what is confusing you. -- J. From attila.r.nohl@REDACTED Fri Apr 22 12:15:14 2011 From: attila.r.nohl@REDACTED (Attila Rajmund Nohl) Date: Fri, 22 Apr 2011 12:15:14 +0200 Subject: [erlang-questions] What's the difference between spawn(Node, Module, Fun, Args) and rpc:call(Node, Module, Fun, Args)? In-Reply-To: References: Message-ID: 2011/4/22, Barco You : > I'm baffled to distinguish these two usages of RPC and don't know when > should use which. I appreciate your explanations! erlang:spawn will start a new process on the remote node executing Module:Fun(Args). rpc:call will start a new process on the remote node executing Module:Fun(Args), will wait until that process finishes and will return the result from that function. From per.melin@REDACTED Fri Apr 22 12:32:52 2011 From: per.melin@REDACTED (Per Melin) Date: Fri, 22 Apr 2011 12:32:52 +0200 Subject: [erlang-questions] use only parts of a release In-Reply-To: <496034.29700.qm@web112619.mail.gq1.yahoo.com> References: <496034.29700.qm@web112619.mail.gq1.yahoo.com> Message-ID: On Thu, Apr 21, 2011 at 9:42 PM, Pablo Platt wrote: > Is it possible to copy only parts of a release and use it on another machine > with an erlang installation > but still be able to use hot code upgrades? Included in the release is a .boot-file. It loads all the modules in the release and starts your applications. If you don't copy all the modules I would assume the boot script will crash. Even if that doesn't happen I can think of serveral problems you will have along the way, like how to make a release update script (relup) for your partial release. > I'm able to install and run myapp but release_handler:which_releases() show > the info of the default erlang runtime instead of my release. release_handler reads the file releases/RELEASES. See http://www.erlang.org/doc/man/release_handler.html#create_RELEASES-4 But I don't think you should see the default Erlang release either way. Does init:get_argument(root) give your release directory or your standard Erlang installation? From robert.virding@REDACTED Fri Apr 22 12:46:30 2011 From: robert.virding@REDACTED (Robert Virding) Date: Fri, 22 Apr 2011 10:46:30 +0000 (GMT) Subject: [erlang-questions] beginner: How should regexp:split/2 be replaced? In-Reply-To: <20110420070837.GA5590@erix.ericsson.se> Message-ID: <1676150342.124081303469190135.JavaMail.root@zimbra> In both cases there was no real room for discussion as the decision had already been made by the OTP group. As your quote shows. That the array module chose to index from 0 does not make the re/binary decisions more right. We are still stuck with two different indexing standards. Robert ----- "Raimo Niskanen" wrote: > On Tue, Apr 19, 2011 at 09:14:04PM +0000, Robert Virding wrote: > > Perhaps its because they think that adding/subtracting one is too > difficult. Or perhaps it is because they want to adhere to the > convention that indexing starts at 0 in spite of that most other > erlang things index from 1. > > > > Robert > > > > It was zero-based in EEP 11 > http://www.erlang.org/eeps/eep-0011.html > and there was no discussion about that EEP. > > This also surfaced in a diskussion about EEP 31: > http://erlang.org/pipermail/eeps/2009-December/000278.html > > Patrik Nyblom wrote: > > > > Robert Virding wrote: > > > > > > - It seems like 'binary' indexes binaries from 0. Is this wise? > While > > > indexing them from 1 may not have been a good choice having two > different > > > standards must surely be much worse and be a source of future > confusion. I > > > know that 're' does this but I think that was a bad mistake! > > > > We (OTP), reluctantly, made the decision to have zero-based indices > as a > > rule for binary-oriented modules although Erlang is traditionally > > one-based. The reason beeing foremost the hassle of > > using one-based indices in bit syntax (the only thing you can make > with a > > one based index is to make it zero based, it's useless in bit-syntax > until > > that is done). Having different bases in different binary-oriented > modules > > would add to the confusion (and make for a less convenient > interface). > > So, the design relu is now that all indices in binaries are > zero-based. I > > obviously won't make this module an exception. > > > End of quote Patrik Nyblom. > > The array module is also zero based. > http://www.erlang.org/doc/man/array.html > > / Raimo Niskanen > > > > > > ----- "Ahmed Omar" wrote: > > > I mean i understand it's different indexing, but was there > specific reason to change that? > > > > > > > > > On Tue, Apr 19, 2011 at 4:18 PM, Ahmed Omar < > spawn.think@REDACTED > wrote: > > > > > > > > > > > regexp:split("Hello world, Hello", "[ ]*,[ ]*"). > > {ok,["Hello world","Hello"]} > > > > > > > re:split("Hello world, Hello", "[ ]*,[ ]*",[{return, list}]). > > ["Hello world","Hello"] > > > > > > > > > regexp:matches("Hello \n","\n"). > > {match,[{7,1}]} > > > > > > > re:run("Hello \n","\n"). > > {match,[{6,1}]} > > > > > > > but i'm not sure why the start position is different here > > > > > > > > > > > > > On Tue, Apr 19, 2011 at 3:30 PM, Bengt Kleberg < > bengt.kleberg@REDACTED > wrote: > > > > > > > Greetings, > > > > > > I have inherited some code without a test directory. I get the > following > > > compiler warnings: > > > ./compile_funcs.erl:603: Warning: regexp:split/2: the regexp > module is > > > deprecated (will be removed in R15A); use the re module instead > > > ./compile_funcs.erl:645: Warning: regexp:matches/2: the regexp > module is > > > deprecated (will be removed in R15A); use the re module instead > > > > > > The lines are: > > > {ok, Class} = regexp:split(Class0, "[ ]*,[ ]*"), > > > and > > > {match,A}=regexp:matches(String,"\n"), > > > > > > I thought "[ ]*,[ ]*" would mean: > > > the character class of " " (space), 0 or many times, followed by > literal > > > "," followed by the character class of " " (space), 0 or many > times. > > > > > > This is not the case and I am not having any luck with randomly > > > constructing strings to find one that triggers a Class that is > different > > > from Class0. > > > > > > Perhaps someone knows what "[ ]*,[ ]*" really means, and what to > replace > > > these with when using the re module. > > > > > > > > > bengt > > > > > > _______________________________________________ > > > erlang-questions mailing list > > > erlang-questions@REDACTED > > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > > > > > > > -- > > > Best Regards, > > > - Ahmed Omar > > http://nl.linkedin.com/in/adiaa > > Follow me on twitter > > @spawn_think > > > > > > > > > > > -- > > > Best Regards, > > > - Ahmed Omar > > http://nl.linkedin.com/in/adiaa > > Follow me on twitter > > @spawn_think > > > > > > _______________________________________________ erlang-questions > mailing list erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > > -- > > / Raimo Niskanen, Erlang/OTP, Ericsson AB > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From pablo.platt@REDACTED Fri Apr 22 13:25:25 2011 From: pablo.platt@REDACTED (Pablo Platt) Date: Fri, 22 Apr 2011 04:25:25 -0700 (PDT) Subject: [erlang-questions] use only parts of a release In-Reply-To: References: <496034.29700.qm@web112619.mail.gq1.yahoo.com> Message-ID: <202013.91646.qm@web112606.mail.gq1.yahoo.com> I've removed some of the apps because I didn't understand why the release includes apps such as mnesia and wx although I don't use them. To prevent issues I'm including all the lib folder now. init:get_argument(root) when running the generated release gives me {ok,[["/home/user/myserver/rel/myserver"]]} after installing the deb package on the second machine I'm getting: {ok,[["/usr/local/lib/erlang"]]} ________________________________ From: Per Melin To: Pablo Platt Cc: erlang-questions Sent: Friday, April 22, 2011 1:32 PM Subject: Re: [erlang-questions] use only parts of a release On Thu, Apr 21, 2011 at 9:42 PM, Pablo Platt wrote: > Is it possible to copy only parts of a release and use it on another machine > with an erlang installation > but still be able to use hot code upgrades? Included in the release is a .boot-file. It loads all the modules in the release and starts your applications. If you don't copy all the modules I would assume the boot script will crash. Even if that doesn't happen I can think of serveral problems you will have along the way, like how to make a release update script (relup) for your partial release. > I'm able to install and run myapp but release_handler:which_releases() show > the info of the default erlang runtime instead of my release. release_handler reads the file releases/RELEASES. See http://www.erlang.org/doc/man/release_handler.html#create_RELEASES-4 But I don't think you should see the default Erlang release either way. Does init:get_argument(root) give your release directory or your standard Erlang installation? -------------- next part -------------- An HTML attachment was scrubbed... URL: From spawn.think@REDACTED Fri Apr 22 13:33:28 2011 From: spawn.think@REDACTED (Ahmed Omar) Date: Fri, 22 Apr 2011 13:33:28 +0200 Subject: [erlang-questions] use only parts of a release In-Reply-To: <202013.91646.qm@web112606.mail.gq1.yahoo.com> References: <496034.29700.qm@web112619.mail.gq1.yahoo.com> <202013.91646.qm@web112606.mail.gq1.yahoo.com> Message-ID: If you want to control the applications you wanna include, you should do that using the .rel file. (you should find it under releases/version dir) On Fri, Apr 22, 2011 at 1:25 PM, Pablo Platt wrote: > I've removed some of the apps because I didn't understand why the release > includes apps such as mnesia and wx although I don't use them. > To prevent issues I'm including all the lib folder now. > > init:get_argument(root) when running the generated release gives me > {ok,[["/home/user/myserver/rel/myserver"]]} > after installing the deb package on the second machine I'm getting: > {ok,[["/usr/local/lib/erlang"]]} > > > ------------------------------ > *From:* Per Melin > *To:* Pablo Platt > *Cc:* erlang-questions > *Sent:* Friday, April 22, 2011 1:32 PM > *Subject:* Re: [erlang-questions] use only parts of a release > > On Thu, Apr 21, 2011 at 9:42 PM, Pablo Platt > wrote: > > Is it possible to copy only parts of a release and use it on another > machine > > with an erlang installation > > but still be able to use hot code upgrades? > > Included in the release is a .boot-file. It loads all the modules in > the release and starts your applications. If you don't copy all the > modules I would assume the boot script will crash. Even if that > doesn't happen I can think of serveral problems you will have along > the way, like how to make a release update script (relup) for your > partial release. > > > I'm able to install and run myapp but release_handler:which_releases() > show > > the info of the default erlang runtime instead of my release. > > release_handler reads the file releases/RELEASES. > > See http://www.erlang.org/doc/man/release_handler.html#create_RELEASES-4 > > But I don't think you should see the default Erlang release either > way. Does init:get_argument(root) give your release directory or your > standard Erlang installation? > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -- Best Regards, - Ahmed Omar http://nl.linkedin.com/in/adiaa Follow me on twitter @spawn_think -------------- next part -------------- An HTML attachment was scrubbed... URL: From per.melin@REDACTED Fri Apr 22 13:50:42 2011 From: per.melin@REDACTED (Per Melin) Date: Fri, 22 Apr 2011 13:50:42 +0200 Subject: [erlang-questions] use only parts of a release In-Reply-To: <202013.91646.qm@web112606.mail.gq1.yahoo.com> References: <496034.29700.qm@web112619.mail.gq1.yahoo.com> <202013.91646.qm@web112606.mail.gq1.yahoo.com> Message-ID: On Fri, Apr 22, 2011 at 1:25 PM, Pablo Platt wrote: > I've removed some of the apps because I didn't understand why the release > includes apps such as mnesia and wx although I don't use them. OK, then I misunderstood you. I though you were excluding some of your own apps, not OTP apps. Mnesia, wx etc are included because rebar uses reltool, and reltool tries to figure out which modules you need. It sees that you use stdlib, and somewhere in stdlib there is a call to e.g. mnesia. So it has to include mnesia unless you tell it different. You can specify apps that you don't want in rel/reltool.config. Inside the list of {sys, [?]} add {app, mnesia, [{incl_cond, exclude} to leave it out of the release. > init:get_argument(root) when running the generated release gives me > {ok,[["/home/user/myserver/rel/myserver"]]} > after installing the deb package on the second machine I'm getting: > {ok,[["/usr/local/lib/erlang"]]} So there is something wrong with your start script. You are not actually running your release at all. I assume init:get_argument(boot) (note, "boot" not "root" this time) returns an error? That would mean that your release's boot file was not given as an argument when the VM was started. From pablo.platt@REDACTED Fri Apr 22 14:02:30 2011 From: pablo.platt@REDACTED (Pablo Platt) Date: Fri, 22 Apr 2011 05:02:30 -0700 (PDT) Subject: [erlang-questions] use only parts of a release In-Reply-To: References: <496034.29700.qm@web112619.mail.gq1.yahoo.com> <202013.91646.qm@web112606.mail.gq1.yahoo.com> Message-ID: <202628.39280.qm@web112601.mail.gq1.yahoo.com> Maybe rebar shouldn't include apps in the release that the release doesn't really need? It could be insignificant. init:get_argument(boot) gives me: {ok,[["/usr/lib/myserver/releases/1/myserver"]]} I've created the file releases/RELEASES with relative paths with: release_handler:create_RELEASES(".", "./releases", "./releases/1/myserver.rel", []). and now release_handler:which_releases() show reasonable output. I'll try to create a new release, install it with the package and see if I can upgrade. There will probably be problems like upstart trying to restart the erlang server instead of letting the release_handler take care of it. ________________________________ From: Per Melin To: Pablo Platt Cc: erlang-questions Sent: Friday, April 22, 2011 2:50 PM Subject: Re: [erlang-questions] use only parts of a release On Fri, Apr 22, 2011 at 1:25 PM, Pablo Platt wrote: > I've removed some of the apps because I didn't understand why the release > includes apps such as mnesia and wx although I don't use them. OK, then I misunderstood you. I though you were excluding some of your own apps, not OTP apps. Mnesia, wx etc are included because rebar uses reltool, and reltool tries to figure out which modules you need. It sees that you use stdlib, and somewhere in stdlib there is a call to e.g. mnesia. So it has to include mnesia unless you tell it different. You can specify apps that you don't want in rel/reltool.config. Inside the list of {sys, [?]} add {app, mnesia, [{incl_cond, exclude} to leave it out of the release. > init:get_argument(root) when running the generated release gives me > {ok,[["/home/user/myserver/rel/myserver"]]} > after installing the deb package on the second machine I'm getting: > {ok,[["/usr/local/lib/erlang"]]} So there is something wrong with your start script. You are not actually running your release at all. I assume init:get_argument(boot) (note, "boot" not "root" this time) returns an error? That would mean that your release's boot file was not given as an argument when the VM was started. -------------- next part -------------- An HTML attachment was scrubbed... URL: From per.melin@REDACTED Fri Apr 22 15:10:15 2011 From: per.melin@REDACTED (Per Melin) Date: Fri, 22 Apr 2011 15:10:15 +0200 Subject: [erlang-questions] use only parts of a release In-Reply-To: <202628.39280.qm@web112601.mail.gq1.yahoo.com> References: <496034.29700.qm@web112619.mail.gq1.yahoo.com> <202013.91646.qm@web112606.mail.gq1.yahoo.com> <202628.39280.qm@web112601.mail.gq1.yahoo.com> Message-ID: On Fri, Apr 22, 2011 at 2:02 PM, Pablo Platt wrote: > init:get_argument(boot) gives me: > {ok,[["/usr/lib/myserver/releases/1/myserver"]]} Good. Please disregard the part where I said that the start script is broken. I forgot that your release doesn't include the ERTS. From pablo.platt@REDACTED Fri Apr 22 15:15:19 2011 From: pablo.platt@REDACTED (Pablo Platt) Date: Fri, 22 Apr 2011 06:15:19 -0700 (PDT) Subject: [erlang-questions] use only parts of a release In-Reply-To: References: <496034.29700.qm@web112619.mail.gq1.yahoo.com> <202013.91646.qm@web112606.mail.gq1.yahoo.com> <202628.39280.qm@web112601.mail.gq1.yahoo.com> Message-ID: <852604.96454.qm@web112605.mail.gq1.yahoo.com> The release does include ERTS but I'm excluding it when creating the deb package. Is it possible to create a release without the ERTS? ________________________________ From: Per Melin To: Pablo Platt Cc: erlang-questions Sent: Friday, April 22, 2011 4:10 PM Subject: Re: [erlang-questions] use only parts of a release On Fri, Apr 22, 2011 at 2:02 PM, Pablo Platt wrote: > init:get_argument(boot) gives me: > {ok,[["/usr/lib/myserver/releases/1/myserver"]]} Good. Please disregard the part where I said that the start script is broken. I forgot that your release doesn't include the ERTS. -------------- next part -------------- An HTML attachment was scrubbed... URL: From per.melin@REDACTED Fri Apr 22 15:22:33 2011 From: per.melin@REDACTED (Per Melin) Date: Fri, 22 Apr 2011 15:22:33 +0200 Subject: [erlang-questions] some questions about epmd and inet_dist_listen_min/max In-Reply-To: <88D3CBED-F955-450B-9D3A-B3E54850A794@gmail.com> References: <88D3CBED-F955-450B-9D3A-B3E54850A794@gmail.com> Message-ID: On Fri, Apr 22, 2011 at 5:36 AM, zhangbo wrote: > Hi > ? ? ? ?Could someone tell me the function of inet_dist_listen_min/max in distributed env ? > ? ? ? ?Another, I guess there is a ?relation between epmd and ports of inet_dist_listen_min/max, if it's true, could somebody tell me the detail about the relation? When a node is started with -name or -sname it picks a free port between inet_dist_listen_min and inet_dist_listen_max and listens to it for connections from other nodes. epmd keeps track of which node is on which port on the local machine. $ erl -sname foo -kernel inet_dist_listen_min 30000 inet_dist_listen_max 30010 -detached $ erl -sname bar -kernel inet_dist_listen_min 30000 inet_dist_listen_max 30010 -detached $ epmd -names epmd: up and running on port 4369 with data: name bar at port 30001 name foo at port 30000 From comptekki@REDACTED Fri Apr 22 16:25:13 2011 From: comptekki@REDACTED (Wes James) Date: Fri, 22 Apr 2011 08:25:13 -0600 Subject: [erlang-questions] Reinstall wxErlang In-Reply-To: References: Message-ID: Which version/distro of linux? -wes On Fri, Apr 22, 2011 at 2:37 AM, Bambang Purnomosidi D. P. wrote: > > Yes, you're right. Unfortunately, downgrade wxWidgets is not an option for > me, so I reinstall Erlang again. I am still curious as to why doing make > clean; ./configure; make; make install in lib/wx doesn't recover my wxErlang > installation. > > -- > bpdp > > On Fri, Apr 22, 2011 at 11:33 AM, Wes James wrote: >> >> Go back to the previous wxwidgets. ?Your erlang will have been >> compiled against that. ?If you want to use a newer wxwidgets, you will >> probably need to recompile erlang with the new version for it to work. >> >> -wes > > From dan@REDACTED Fri Apr 22 16:32:28 2011 From: dan@REDACTED (Daniel Dormont) Date: Fri, 22 Apr 2011 10:32:28 -0400 Subject: [erlang-questions] Module config data and functional programming In-Reply-To: References: Message-ID: Thanks that helps. I'm not too worried about the code change, because I think given the way Ejabberd works I'd typically need to stop the module before upgrading it anyway. It also occurs to me that switching to gen_server would offer another advantage in that it would be easy to recover from crashes in my own code. If I were not to do that though, is the recommended practice just to put a 'catch' call around code that might break? dan On Apr 22, 2011, at 5:34 AM, Per Melin wrote: > On Thu, Apr 21, 2011 at 8:54 PM, Daniel Dormont > wrote: >> start(Host, Opts) -> ejabberd_hooks:add(some_hook, global, ?MODULE, some_function). >> stop(Host) -> ejabberd_hooks:delete(some_hook, global, ?MODULE, some_function). >> >> some_function(List) -> lists:filter(fun my_filter/1, List). >> >> my_filter(Value) -> %complex logic here% >> >> The idea being that the module can be initialized with some options that were passed from a config file. FYI, ejabberd_hooks is used to register and unregister callbacks for certain events. >> >> What I have above works fine, but now I'm in a situation where my_filter needs access to data that came from Opts. > > I've never used ejabberd but I peeked at the documentation for > ejabberd_hooks:add/3,4,5 and it looks like you can also give it a fun. > So a closure could carry the value of Opts for you: > > start(_Host, Opts) -> ejabberd_hooks:add(some_hook, make_hook_fun(Opts), 1). > > make_hook_fun(Opts) -> > fun(List) -> > lists:filter(fun(Value) -> my_filter(Value, Opts) end, List) > end. > > my_filter(Value, Opts) -> %complex logic here% > > The problem then becomes your stop function since > ejabberd_hooks:delete/3,4,5 needs to be passed the exact same fun it > seems. You would need to either hold on to the return value of > make_hook_fun(Opts) or the Opts themselves and pass that to the stop > function. > > There is also the issue of code updates. If ejabberd stores your fun > in an ETS table and you reload your module with a different version of > make_hook_fun/1 then the fun in ETS will crash the next time it is > invoked. From pablo.platt@REDACTED Fri Apr 22 17:02:16 2011 From: pablo.platt@REDACTED (Pablo Platt) Date: Fri, 22 Apr 2011 08:02:16 -0700 (PDT) Subject: [erlang-questions] use only parts of a release In-Reply-To: <852604.96454.qm@web112605.mail.gq1.yahoo.com> References: <496034.29700.qm@web112619.mail.gq1.yahoo.com> <202013.91646.qm@web112606.mail.gq1.yahoo.com> <202628.39280.qm@web112601.mail.gq1.yahoo.com> <852604.96454.qm@web112605.mail.gq1.yahoo.com> Message-ID: <160188.68300.qm@web112612.mail.gq1.yahoo.com> I made some progress but still have several issues with rebar and I'm not able to unpack the release. Is it possible to unpack the release manually? (the deb package will do it). What's wrong with steps 11 and 12? Thanks 1. ./rebar generate (generate the first release). 2. generated the myserver/rel/myserver/releases/RELEASES file with: release_handler:create_RELEASES(".", "./releases", "./releases/1/myserver.rel", []). Why doesn't rebar create the RELEASES file? 3. created a deb package: myserver-1_amd64.deb and installed it on the target machine. 4. made a change to myserver:ver() so I'll have something to verify that the upgrade works. 5. created myserver.appup in the ebin dir which reflects the myserver module change. 6. renamed myserver release to myserver_first. 7. ./rebar generate 8. created a new RELEASES file (is it required?). 9. ./rebar generate-upgrade previous_release=myserver_first I'm getting error: ERROR: Systools aborted with: {modules, ?????????????????????????????? [{error, ???????????????????????????????? {{module_not_found,erlydtl, ?????????????????????????????????? erlydtl_dateformat_tests}, ????????????????????????????????? {erlydtl_dateformat_tests,'$$ignore$$', ?????????????????????????????????? erlydtl,"0.6.1", ?????????????????????????????????? "./myserver/lib/erlydtl-0.6.1/ebin"}}}, ???? ???? ???? ???? ???? ???? ... Is this a bug in rebar? I copied of erlydtl-0.6.1/ebintest to erlydtl-0.6.1/ebin and it fixed that error. 10 copy myserver_2.tar.gz to the target machine under the folder /usr/lib/myserver/releases 11. /usr/lib/myserver/bin/myserver attach release_handler:unpack_release("myserver_2"). {error,{enoent,"/usr/lib/myserver/releases/myserver_2.rel"}} Why am I getting the enoent error? 12. trying to fix the error - copy manually the myserver_2.rel file to /usr/lib/myserver/releases release_handler:unpack_release("myserver_2"). {error,{{case_clause,{error,eacces}}, ??????? [{release_handler,extract_tar,2}, ???????? {release_handler,do_unpack_release,4}, ???????? {release_handler,handle_call,3}, ???????? {gen_server,handle_msg,5}, ???????? {proc_lib,init_p_do_apply,3}]}} ________________________________ From: Pablo Platt To: Per Melin Cc: erlang-questions Sent: Friday, April 22, 2011 4:15 PM Subject: Re: [erlang-questions] use only parts of a release The release does include ERTS but I'm excluding it when creating the deb package. Is it possible to create a release without the ERTS? ________________________________ From: Per Melin To: Pablo Platt Cc: erlang-questions Sent: Friday, April 22, 2011 4:10 PM Subject: Re: [erlang-questions] use only parts of a release On Fri, Apr 22, 2011 at 2:02 PM, Pablo Platt wrote: > init:get_argument(boot) gives me: > {ok,[["/usr/lib/myserver/releases/1/myserver"]]} Good. Please disregard the part where I said that the start script is broken. I forgot that your release doesn't include the ERTS. _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From richardprideauxevans@REDACTED Fri Apr 22 18:24:09 2011 From: richardprideauxevans@REDACTED (Richard Evans) Date: Fri, 22 Apr 2011 17:24:09 +0100 Subject: [erlang-questions] How to modify the buttons in a panel in wx Message-ID: I have a wxPanel containing various buttons. I want to be able to remove some buttons and add other buttons at run-time. Is this possible in wx? How does one do it? thanks in advance, Richard -------------- next part -------------- An HTML attachment was scrubbed... URL: From per.melin@REDACTED Fri Apr 22 18:58:28 2011 From: per.melin@REDACTED (Per Melin) Date: Fri, 22 Apr 2011 18:58:28 +0200 Subject: [erlang-questions] use only parts of a release In-Reply-To: <160188.68300.qm@web112612.mail.gq1.yahoo.com> References: <496034.29700.qm@web112619.mail.gq1.yahoo.com> <202013.91646.qm@web112606.mail.gq1.yahoo.com> <202628.39280.qm@web112601.mail.gq1.yahoo.com> <852604.96454.qm@web112605.mail.gq1.yahoo.com> <160188.68300.qm@web112612.mail.gq1.yahoo.com> Message-ID: On Fri, Apr 22, 2011 at 5:02 PM, Pablo Platt wrote: > Is it possible to unpack the release manually? (the deb package will do it). release_handler:unpack_release/1 does more than just untar. See next item. > 8. created a new RELEASES file (is it required?). No, RELEASES should only be created for the initial release. Once it exists release_handler will update it when you call unpack_release/1, install_release/1,2, make_permanent/1 etc. > 11. /usr/lib/myserver/bin/myserver attach > release_handler:unpack_release("myserver_2"). > {error,{enoent,"/usr/lib/myserver/releases/myserver_2.rel"}} > Why am I getting the enoent error? I don't use rebar for releases so I can't help you here. I don't know why this file didn't exist. > 12. trying to fix the error - copy manually the myserver_2.rel file to > /usr/lib/myserver/releases > release_handler:unpack_release("myserver_2"). > {error,{{case_clause,{error,eacces}}, > ??????? [{release_handler,extract_tar,2}, > ???????? {release_handler,do_unpack_release,4}, > ???????? {release_handler,handle_call,3}, > ???????? {gen_server,handle_msg,5}, > ???????? {proc_lib,init_p_do_apply,3}]}} The obvious guess here would be that the user running the Erlang VM doesn't have write access to all the paths in the tar. From per.melin@REDACTED Fri Apr 22 19:30:02 2011 From: per.melin@REDACTED (Per Melin) Date: Fri, 22 Apr 2011 19:30:02 +0200 Subject: [erlang-questions] Module config data and functional programming In-Reply-To: References: Message-ID: On Fri, Apr 22, 2011 at 4:32 PM, Daniel Dormont wrote: > It also occurs to me that switching to gen_server would offer another advantage in that it would be easy to recover from crashes in my own code. If I were not to do that though, is the recommended practice just to put a 'catch' call around code that might break? I don't have enough context, but it sounds absolutely unnecessary to create a gen_server for this. I would consider it ejabberd's responsibility to handle any crashes in your code. They have asked you for a callback function and they must consider that it may break. And they are in a better position than you to know how to proceed from a crash here. I did have a look in ejabberd_hooks and they do catch exits from your function. Let it crash. I'm hesitant to touch the question of what is recommended practice since this is the kind of thread where Dr Richard O'Keefe usually comments after a while and turns everyone that posted before him into fools. From comptekki@REDACTED Fri Apr 22 20:57:59 2011 From: comptekki@REDACTED (Wes James) Date: Fri, 22 Apr 2011 12:57:59 -0600 Subject: [erlang-questions] Ubuntu, Erlang, and Laptop Questions In-Reply-To: <1581724946.1474175.1303391873389.JavaMail.root@sz0166a.westchester.pa.mail.comcast.net> References: <1581724946.1474175.1303391873389.JavaMail.root@sz0166a.westchester.pa.mail.comcast.net> Message-ID: On Thu, Apr 21, 2011 at 7:17 AM, wrote: > Hi, > > I am saving up for a new laptop to run Erlang.? Can't?drag my tower around. > Two questions: > > > > 1 - I want to run Ubuntu.? Will Erlang work well with this? (Assuming Ubuntu > v10/11) you will have R13B03, and if you try to compile from scratch to get R14B02, expect to do a bit of work (especially wxwidgets) You may want to try this: http://sivieri.wordpress.com/2011/04/08/erlang-r14b02-in-ppa/ if you want R14B02. I just tried it and it seems to work fine so far. You can also try this procedure (installing packages) to get R14B02 working on Ubuntu 10.10 http://sites.google.com/site/comptekkia/erlang/how-to-install-erlang-on-ubuntu-10-10 > 2 - What's a decent laptop manufacturer/model to run this on?? I've always > bought Dell in the past, but I am not wed to this manufacturer. > > -wes From bpdp.erlang@REDACTED Sat Apr 23 01:25:03 2011 From: bpdp.erlang@REDACTED (Bambang Purnomosidi D. P.) Date: Sat, 23 Apr 2011 06:25:03 +0700 Subject: [erlang-questions] Reinstall wxErlang In-Reply-To: References: Message-ID: On Fri, Apr 22, 2011 at 9:25 PM, Wes James wrote: > Which version/distro of linux? > Arch Linux. Current. wxgtk 2.8.12-1, -- bpdp -------------- next part -------------- An HTML attachment was scrubbed... URL: From comptekki@REDACTED Sat Apr 23 01:36:15 2011 From: comptekki@REDACTED (Wes James) Date: Fri, 22 Apr 2011 17:36:15 -0600 Subject: [erlang-questions] Reinstall wxErlang In-Reply-To: References: Message-ID: I'm not familiar with that distro. Does it have its own version of wx when you install that distro? If you install wx in /usr/local then you can go remove it from /usr/local/bin lib include, etc. and then try and run wx:demo() in erlang and see what happens. I tried make uninstall in wx source but it didn't seem to remove everything from /usr/local so I did manually. (ubuntu 10.10 x64 in this case) -wes On Fri, Apr 22, 2011 at 5:25 PM, Bambang Purnomosidi D. P. wrote: > On Fri, Apr 22, 2011 at 9:25 PM, Wes James wrote: >> >> Which version/distro of linux? > > Arch Linux. Current. wxgtk 2.8.12-1, > > -- > bpdp > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > From bpdp.erlang@REDACTED Sat Apr 23 01:44:30 2011 From: bpdp.erlang@REDACTED (Bambang Purnomosidi D. P.) Date: Sat, 23 Apr 2011 06:44:30 +0700 Subject: [erlang-questions] Reinstall wxErlang In-Reply-To: References: Message-ID: On Sat, Apr 23, 2011 at 6:36 AM, Wes James wrote: > I'm not familiar with that distro. Does it have its own version of wx > when you install that distro? If you install wx in /usr/local then > you can go remove it from /usr/local/bin lib include, etc. and then > try and run wx:demo() in erlang and see what happens. > > Yes, it has its own package and I am a bit reluctant to uninstall wxgtk since many software package depend on wxgtk and uninstall them could bring more costs in maintenance burden. It is now work like a charm since I reinstall full Erlang dist. > I tried make uninstall in wx source but it didn't seem to remove > everything from /usr/local so I did manually. (ubuntu 10.10 x64 in > this case) > hmm ... strange. -- bpdp -------------- next part -------------- An HTML attachment was scrubbed... URL: From rzezeski@REDACTED Sat Apr 23 05:34:23 2011 From: rzezeski@REDACTED (Ryan Zezeski) Date: Fri, 22 Apr 2011 23:34:23 -0400 Subject: [erlang-questions] callback module without behavior definition? In-Reply-To: References: Message-ID: On Wed, Apr 6, 2011 at 12:46 PM, Daniel Goertzen wrote: > One thing that has bothered me about implementing gen_servers is that I > have to create empty stubs for the callbacks that I don't need. Today I > made a gen_server that only needs init/1, so instead of creating all those > stubs I just commented out the behavior definition "-behavior(gen_server)." > > Daniel, The _Erlang Programming_ book actually says **not** to implement callbacks you don't need. (pp274) I think that makes sense and is the advice I have followed. However, most people tend to implement all the callbacks even if they don't use them for anything. In fact, I think that's the recommended way in _OTP in Action_. So it seems not even the veterans can agree on this topic. -Ryan -------------- next part -------------- An HTML attachment was scrubbed... URL: From attila.r.nohl@REDACTED Sat Apr 23 09:48:23 2011 From: attila.r.nohl@REDACTED (Attila Rajmund Nohl) Date: Sat, 23 Apr 2011 09:48:23 +0200 Subject: [erlang-questions] callback module without behavior definition? In-Reply-To: References: Message-ID: 2011/4/23, Ryan Zezeski : > On Wed, Apr 6, 2011 at 12:46 PM, Daniel Goertzen > wrote: > >> One thing that has bothered me about implementing gen_servers is that I >> have to create empty stubs for the callbacks that I don't need. Today I >> made a gen_server that only needs init/1, so instead of creating all those >> stubs I just commented out the behavior definition >> "-behavior(gen_server)." >> >> > Daniel, > > The _Erlang Programming_ book actually says **not** to implement callbacks > you don't need. (pp274) I think that makes sense and is the advice I have > followed. However, most people tend to implement all the callbacks even if > they don't use them for anything. In fact, I think that's the recommended > way in _OTP in Action_. So it seems not even the veterans can agree on this > topic. Implementing all the callbacks gets rid of warnings and can still produce an error log if unexpectedly called. From pablo.platt@REDACTED Sat Apr 23 16:41:35 2011 From: pablo.platt@REDACTED (Pablo Platt) Date: Sat, 23 Apr 2011 07:41:35 -0700 (PDT) Subject: [erlang-questions] use only parts of a release In-Reply-To: References: <496034.29700.qm@web112619.mail.gq1.yahoo.com> <202013.91646.qm@web112606.mail.gq1.yahoo.com> <202628.39280.qm@web112601.mail.gq1.yahoo.com> <852604.96454.qm@web112605.mail.gq1.yahoo.com> <160188.68300.qm@web112612.mail.gq1.yahoo.com> Message-ID: <837468.43162.qm@web112620.mail.gq1.yahoo.com> I have successfully installed the second release on the dev machine with release_handle:unpack_release, install_release and make_permanent but when trying to install myserver_2.tar.gz on the new machine I'm still getting same errors. I'm able? to extract myserver_2.tar.gz with erl_tar:extract("myserver_2.tar.gz", [compressed]) so I don't think it's a permission issue. I also see the myserver_2.rel file so maybe the error is because the path is not correct? The contents after extracting are: lib\ ???? all the application folders... releases\ ???? myserver_2.rel ???? \2 ???? ???? relup ???? ???? myserver.boot (symlink) ???? ???? start.boot ???? ???? start_clean.boot Again, the errors I'm getting are: 1. Error when trying to use release_handler:unpack_release("myserver_2"): {error,{enoent,"/usr/lib/myserver/releases/myserver_2.rel"}} 2. After I copy myserver_2.rel manually to /usr/lib/myserver/releases and trying release_handler:unpack_release("myserver_2") again I'm getting: {error,{{case_clause,{error,eacces}}, ??????? [{release_handler,extract_tar,2}, ???????? {release_handler,do_unpack_release,4}, ???????? {release_handler,handle_call,3}, ???????? {gen_server,handle_msg,5}, ???????? {proc_lib,init_p_do_apply,3}]}} ???? ???? >> 11. /usr/lib/myserver/bin/myserver attach >> release_handler:unpack_release("myserver_2"). >> {error,{enoent,"/usr/lib/myserver/releases/myserver_2.rel"}} >> Why am I getting the enoent error? > >I don't use rebar for releases so I can't help you here. I don't know >why this file didn't exist. > >> 12. trying to fix the error - copy manually the myserver_2.rel file to >> /usr/lib/myserver/releases >> release_handler:unpack_release("myserver_2"). >> {error,{{case_clause,{error,eacces}}, >> ??????? [{release_handler,extract_tar,2}, >> ???????? {release_handler,do_unpack_release,4}, >> ???????? {release_handler,handle_call,3}, >> ???????? {gen_server,handle_msg,5}, >> ???????? {proc_lib,init_p_do_apply,3}]}} > >The obvious guess here would be that the user running the Erlang VM >doesn't have write access to all the paths in the tar. -------------- next part -------------- An HTML attachment was scrubbed... URL: From per.melin@REDACTED Sat Apr 23 19:21:30 2011 From: per.melin@REDACTED (Per Melin) Date: Sat, 23 Apr 2011 19:21:30 +0200 Subject: [erlang-questions] use only parts of a release In-Reply-To: <837468.43162.qm@web112620.mail.gq1.yahoo.com> References: <496034.29700.qm@web112619.mail.gq1.yahoo.com> <202013.91646.qm@web112606.mail.gq1.yahoo.com> <202628.39280.qm@web112601.mail.gq1.yahoo.com> <852604.96454.qm@web112605.mail.gq1.yahoo.com> <160188.68300.qm@web112612.mail.gq1.yahoo.com> <837468.43162.qm@web112620.mail.gq1.yahoo.com> Message-ID: On Sat, Apr 23, 2011 at 4:41 PM, Pablo Platt wrote: > Again, the errors I'm getting are: > 1. Error when trying to use release_handler:unpack_release("myserver_2"): > {error,{enoent,"/usr/lib/myserver/releases/myserver_2.rel"}} > > 2. After I copy myserver_2.rel manually to /usr/lib/myserver/releases and > trying release_handler:unpack_release("myserver_2") again I'm getting: > {error,{{case_clause,{error,eacces}}, > ??????? [{release_handler,extract_tar,2}, > ???????? {release_handler,do_unpack_release,4}, > ???????? {release_handler,handle_call,3}, > ???????? {gen_server,handle_msg,5}, > ???????? {proc_lib,init_p_do_apply,3}]}} Pablo and I went off-list for a while. I'll recap what we discovered. release_handler uses init:get_argument(root) as the base directory for some of its operations. When ERTS is included (which it probably must be) in the release that is not a problem, but since it was not included here and beam was started from the standard installation, the root is /usr/local/lib/erlang. As far as I can tell, release_handler doesn't seem to deal well with a release directory that is outside of $OTP_ROOT. There is a SASL environment variable called releases_dir which release_handler sometimes honors, and sometimes ignores (if I'm reading it right). From ulf.wiger@REDACTED Sat Apr 23 21:27:03 2011 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Sat, 23 Apr 2011 21:27:03 +0200 Subject: [erlang-questions] use only parts of a release In-Reply-To: References: <496034.29700.qm@web112619.mail.gq1.yahoo.com> <202013.91646.qm@web112606.mail.gq1.yahoo.com> <202628.39280.qm@web112601.mail.gq1.yahoo.com> <852604.96454.qm@web112605.mail.gq1.yahoo.com> <160188.68300.qm@web112612.mail.gq1.yahoo.com> <837468.43162.qm@web112620.mail.gq1.yahoo.com> Message-ID: <85729247-0BB1-40A6-B32A-DF98EF69BA25@erlang-solutions.com> I will admit that I haven't been following this thread - apologies. Also, I have yet to update my old knowledge of how to do this to understand how it's done using reltool et al. You can use a releases/ directory outside the OTP root. When you build the boot script, use the {variables, Vars} option, and when starting, define the variables using the -boot_var command-line option. http://www.erlang.org/doc/man/systools.html#make_script-2 E.g. {variables, [{"MYROOT", PathToMyRoot}, {"OTP_ROOT", ERL_TOP}]} init:get_argument(root) should point to the place where you have your .rel and .boot files etc. This can be entirely separate from where you keep your lib/ roots. http://www.erlang.org/doc/embedded/embedded_solaris.html chapter 1.4, can be a good place to read up on how to get Erlang started with full control over the various variables. Perhaps also: http://www.erlang.org/doc/system_principles/create_target.html BR, Ulf W On 23 Apr 2011, at 19:21, Per Melin wrote: > On Sat, Apr 23, 2011 at 4:41 PM, Pablo Platt wrote: >> Again, the errors I'm getting are: >> 1. Error when trying to use release_handler:unpack_release("myserver_2"): >> {error,{enoent,"/usr/lib/myserver/releases/myserver_2.rel"}} >> >> 2. After I copy myserver_2.rel manually to /usr/lib/myserver/releases and >> trying release_handler:unpack_release("myserver_2") again I'm getting: >> {error,{{case_clause,{error,eacces}}, >> [{release_handler,extract_tar,2}, >> {release_handler,do_unpack_release,4}, >> {release_handler,handle_call,3}, >> {gen_server,handle_msg,5}, >> {proc_lib,init_p_do_apply,3}]}} > > Pablo and I went off-list for a while. I'll recap what we discovered. > > release_handler uses init:get_argument(root) as the base directory for > some of its operations. When ERTS is included (which it probably must > be) in the release that is not a problem, but since it was not > included here and beam was started from the standard installation, the > root is /usr/local/lib/erlang. > > As far as I can tell, release_handler doesn't seem to deal well with a > release directory that is outside of $OTP_ROOT. There is a SASL > environment variable called releases_dir which release_handler > sometimes honors, and sometimes ignores (if I'm reading it right). > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions Ulf Wiger, CTO, Erlang Solutions, Ltd. http://erlang-solutions.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From boris.okner@REDACTED Sat Apr 23 23:23:40 2011 From: boris.okner@REDACTED (bokner) Date: Sat, 23 Apr 2011 14:23:40 -0700 (PDT) Subject: [erlang-questions] cross-compiling for vxWorks SH4A Message-ID: <454ee7ca-b4c2-4c25-ba3b-b7343bc7dcb3@v31g2000vbs.googlegroups.com> Hello, Anyone could share experience cross-compiling vxWorks for SH4A processor on Linux box? I am new to vxWorks; I did my best to modify xcomp/erl-xcomp-vxworks_ppc32.conf example, and was able to go through './otp_build configure' part as described in http://www.erlang.org/doc/installation_guide/INSTALL-CROSS.html#Build-and-Install-Procedure_Building-With-the-otpbuild-Script without errors. However, './otp_build boot -a' gives me a lot of errors, particularly "Found no appropriate type to use for 'byte'" ones, and dies with: make[5]: *** [obj/sh-wrs-vxworks/opt/r/ethr_aux.o] Error 1 Any insights would be very much appreciated. Regards, Boris From co7eb@REDACTED Sun Apr 24 01:17:47 2011 From: co7eb@REDACTED (=?iso-8859-1?Q?Gilberio_Carmenates_Garc=EDa?=) Date: Sat, 23 Apr 2011 19:17:47 -0400 Subject: [erlang-questions] Erlang Security and Privacy Message-ID: <000001cc020c$aafca950$00f5fbf0$@co.cu> Hi all, Let?s say that we want to protect some exported function from the outside world but namespace, application or node, like the internal keyword in C#. Some times I presented this problem, for example I use the Jinterface, but in the clients in C# or Java, the client must know the Erlang node cookie to connect to it, so that is the first violation of the security, because we can do wherever we want with the node in the server, like accessing to the database and to finish the server node as we like. So if I have this function that I want it to be public to all the application modules in Erlang To be called from some modules, but I won?t it to can be called from the outside world like clients using Jinterface. For example In node1 in the Erlang server. -module(server_interface). -export([ send_to_all/1 ]). send_to_all(Msg)-> -module(other). -compile(export_all). another_fun()-> Msg = send_to_all(Msg), So what I want is that from the another node we can not do In node2 or JInterface simulated node. rpc:call(node1, server_interface, send_to_all, [?Hello!?]). I mean, to export funs local to node or application. NOTE: to resolve this problem I can create a fun with a long atom parameter as a cookie but that shall be ugly I think. send_to_all(aksjdgaskjgfksdjfbdfdsf_34tiuh78vbif 4h, Msg)-> ======================================================================= Este mensaje ha sido enviado mediante el servicio de correo electr?nico que ofrece la Federaci?n de Radioaficionados de Cuba a sus miembros para respaldar el cumplimiento de los objetivos de la organizaci?n y su pol?tica informativa. La persona que env?a este correo asume el compromiso de usar el servicio a tales fines y cumplir con las regulaciones establecidas. -------------- next part -------------- An HTML attachment was scrubbed... URL: From anishparameswaran@REDACTED Sun Apr 24 09:47:20 2011 From: anishparameswaran@REDACTED (Anish Parameswaran) Date: Sun, 24 Apr 2011 13:17:20 +0530 Subject: [erlang-questions] Erlang HTTP Client always reformats header field names to lowercase Message-ID: Hi , I am new to Erlang . I use the following code to access a web server . The web server doesn't service requests if the HTTP header field names are not in camel-case. That is, the server rejects if 'authorization' is given instead of ' Authorization' in HTTP header field. Code : inets:start(). http:request(get,{"http://10.37.184.222:20080/",[{"Authorization", "Basic dGVqYXM6adcnZSMwNXQ="}]},[],[]). *Erlang http module always sends the HTTP header field names in lower-case*. This is true even if the Headers are supplied as above in camel-case. Is this is a bug ? HTTP/1.1 and HTTP/1.0 complaint servers are supposed to handle header field names in a case-insensitive manner. So sending header field name in lower case is perfectly alright . But changing a as-is supplied header filed name to lower case makes it impossible to work with an non-complaint web server. regards, Anish -------------- next part -------------- An HTML attachment was scrubbed... URL: From edward.yujiang.wang@REDACTED Sun Apr 24 12:17:22 2011 From: edward.yujiang.wang@REDACTED (Edward Wang) Date: Sun, 24 Apr 2011 18:17:22 +0800 Subject: [erlang-questions] Erlang HTTP Client always reformats header field names to lowercase In-Reply-To: References: Message-ID: Anish, Try this: http:request(get,{"http://10.37.184.222:20080/",[{"Authorization", "Basic dGVqYXM6adcnZSMwNXQ="}]},[],[{headers_as_is, true}]). On Sun, Apr 24, 2011 at 3:47 PM, Anish Parameswaran < anishparameswaran@REDACTED> wrote: > Hi , > > I am new to Erlang . > > I use the following code to access a web server . The web server > doesn't service > requests if the HTTP header field names are not in camel-case. > > That is, the server rejects if 'authorization' is given instead of ' > Authorization' in > HTTP header field. > > Code : > inets:start(). > http:request(get,{"http://10.37.184.222:20080/",[{"Authorization", > "Basic dGVqYXM6adcnZSMwNXQ="}]},[],[]). > > *Erlang http module always sends the HTTP header field names in > lower-case*. > This is true even if the Headers are supplied as above in camel-case. > > Is this is a bug ? > HTTP/1.1 and HTTP/1.0 complaint servers are supposed to handle header > field names in a case-insensitive manner. So sending header field name in > lower case is > perfectly alright . But changing a as-is supplied header filed name to > lower case makes it impossible to work with an non-complaint web > server. > > regards, > Anish > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From barcojie@REDACTED Sun Apr 24 13:04:33 2011 From: barcojie@REDACTED (Barco You) Date: Sun, 24 Apr 2011 19:04:33 +0800 Subject: [erlang-questions] [Erlang-Q] Why can not create a Mnesia schema directory indicated by a full path Message-ID: When I tried to indicate Mnesia schema directory with command: erl -mnesia dir "/home/myname/tmp/schemas", I got error while calling "mnesia:create_schema([node()|nodes()])" in erlang shell. But if I start erlang shell with just a string as the schema directory name such as " erl -mnesa dir location", I could correctly create schema in erlang shell. Seemingly Mnesia schema directory can not be indicated as a full path. {erts, "5.8"}, {kernel,"2.14"}, {stdlib,"1.17"}. Best regards, Barco -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf.wiger@REDACTED Sun Apr 24 14:00:30 2011 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Sun, 24 Apr 2011 14:00:30 +0200 Subject: [erlang-questions] [Erlang-Q] Why can not create a Mnesia schema directory indicated by a full path In-Reply-To: References: Message-ID: <7FDDE381-42AE-4958-A9BB-B62DFBCD740A@erlang-solutions.com> The issue is with quoting in the unix shell. Try: erl -mnesia dir \"/home/myname/tmp/schemas\" The reason why it worked with a single directory name was that it parsed as a valid atom, and the file module allows atoms as file names. That is, for any environment variables given as -App Key Value on the command line, Value will be parsed as an Erlang term. Anything with special meaning to the command shell needs to be escaped. BR, Ulf W On 24 Apr 2011, at 13:04, Barco You wrote: > When I tried to indicate Mnesia schema directory with command: erl -mnesia dir "/home/myname/tmp/schemas", I got error while calling "mnesia:create_schema([node()|nodes()])" in erlang shell. > > But if I start erlang shell with just a string as the schema directory name such as " erl -mnesa dir location", I could correctly create schema in erlang shell. > > Seemingly Mnesia schema directory can not be indicated as a full path. > > {erts, "5.8"}, > {kernel,"2.14"}, > {stdlib,"1.17"}. > > > Best regards, > Barco > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions Ulf Wiger, CTO, Erlang Solutions, Ltd. http://erlang-solutions.com From per.melin@REDACTED Sun Apr 24 14:39:52 2011 From: per.melin@REDACTED (Per Melin) Date: Sun, 24 Apr 2011 14:39:52 +0200 Subject: [erlang-questions] use only parts of a release In-Reply-To: <85729247-0BB1-40A6-B32A-DF98EF69BA25@erlang-solutions.com> References: <496034.29700.qm@web112619.mail.gq1.yahoo.com> <202013.91646.qm@web112606.mail.gq1.yahoo.com> <202628.39280.qm@web112601.mail.gq1.yahoo.com> <852604.96454.qm@web112605.mail.gq1.yahoo.com> <160188.68300.qm@web112612.mail.gq1.yahoo.com> <837468.43162.qm@web112620.mail.gq1.yahoo.com> <85729247-0BB1-40A6-B32A-DF98EF69BA25@erlang-solutions.com> Message-ID: On Sat, Apr 23, 2011 at 9:27 PM, Ulf Wiger wrote: > I will admit that I haven't been following this thread - apologies. Also, I > have yet to update my old knowledge of how to do this to understand how it's > done using reltool et al. > You can use a releases/ directory outside the OTP root. Thanks. I was confused about the role of the -root flag. It is used in three places that I can find: - init uses it to locate stuff and to replace the default variable $ROOT in the boot script. - code_server uses it (in interactive mode only) as one of the starting points to search for modules. - release_handler uses it as the top directory of the installed release. > When you build the boot script, use the {variables, Vars} option, and when > starting, define the variables using the -boot_var command-line option. > http://www.erlang.org/doc/man/systools.html#make_script-2 > E.g. {variables, [{"MYROOT", PathToMyRoot}, {"OTP_ROOT", ERL_TOP}]} > init:get_argument(root) should point to the place where you have your .rel > and .boot files etc. This can be entirely separate from where you keep your > lib/ roots. Pablo is using rebar. He would need to drop down a few levels to use systools instead. I can't find any support for boot variables in the doc for reltool. It does look to me like reltool_target:gen_script/4 do support them, but that is an internal function and is always called with a hardcoded empty list of variables. I guess one could let rebar generate the release and then use systools:make_script/2 to rebuild the boot script with variables. From pablo.platt@REDACTED Sun Apr 24 15:06:47 2011 From: pablo.platt@REDACTED (Pablo Platt) Date: Sun, 24 Apr 2011 06:06:47 -0700 (PDT) Subject: [erlang-questions] use only parts of a release In-Reply-To: References: <496034.29700.qm@web112619.mail.gq1.yahoo.com> <202013.91646.qm@web112606.mail.gq1.yahoo.com> <202628.39280.qm@web112601.mail.gq1.yahoo.com> <852604.96454.qm@web112605.mail.gq1.yahoo.com> <160188.68300.qm@web112612.mail.gq1.yahoo.com> <837468.43162.qm@web112620.mail.gq1.yahoo.com> <85729247-0BB1-40A6-B32A-DF98EF69BA25@erlang-solutions.com> Message-ID: <573426.90205.qm@web112608.mail.gq1.yahoo.com> I guess I was complicating things just because something didn't work when I started. At first I tried to copy the whole release to /usr/lib/myserver with the following line in the debian/install script: ../../myserver/rel/myserver/lib/ /usr/lib/myserver/lib but when creating the deb package with debuildI got errors related to crypto and ssl. Is it possible to fix the errors? Please note that the dev and production machine will be identical. The second question (which might deserve a separate thread) is about upgrade vs a new release. When you install a deb package, it is smart enough to handle a fresh install or to upgrade a previous version. Erlang release seem to distinguish between the two scenarios so you can't just have a single deb that handle both cases. Someone suggested that the first release will be an upgrade of a bare runtime which might be an option: http://engineering.yakaz.com/erlang-packaging-on-debian-and-live-upgrade.html The debuild errors: objdump: debian/myserver/usr/lib/myserver/lib/lib/crypto-2.0.2/priv/obj/crypto.o: not a dynamic object objdump: debian/myserver/usr/lib/myserver/lib/lib/crypto-2.0.2/priv/obj/crypto.o: Invalid operation dpkg-shlibdeps: warning: Couldn't parse dynamic symbol definition: no symbols dpkg-shlibdeps: warning: dependency on libdl.so.2 could be avoided if "debian/myserver/usr/lib/myserver/lib/lib/runtime_tools-1.8.4.1/priv/lib/trace_file_drv.so debian/myserver/usr/lib/myserver/lib/lib/runtime_tools-1.8.4.1/priv/lib/trace_ip_drv.so debian/myserver/usr/lib/myserver/lib/lib/ssl-4.1.1/priv/bin/ssl_esock" were not uselessly linked against it (they use none of its symbols). dpkg-shlibdeps: warning: dependency on libm.so.6 could be avoided if "debian/myserver/usr/lib/myserver/lib/lib/runtime_tools-1.8.4.1/priv/lib/trace_file_drv.so debian/myserver/usr/lib/myserver/lib/lib/runtime_tools-1.8.4.1/priv/lib/trace_ip_drv.so debian/myserver/usr/lib/myserver/lib/lib/ssl-4.1.1/priv/bin/ssl_esock" were not uselessly linked against it (they use none of its symbols). dpkg-shlibdeps: warning: dependency on libutil.so.1 could be avoided if "debian/myserver/usr/lib/myserver/lib/lib/runtime_tools-1.8.4.1/priv/lib/trace_file_drv.so debian/myserver/usr/lib/myserver/lib/lib/runtime_tools-1.8.4.1/priv/lib/trace_ip_drv.so debian/myserver/usr/lib/myserver/lib/lib/ssl-4.1.1/priv/bin/ssl_esock" were not uselessly linked against it (they use none of its symbols). ... E: myserver: possible-gpl-code-linked-with-openssl E: myserver: binary-or-shlib-defines-rpath ./usr/lib/myserver/lib/lib/crypto-2.0.2/priv/lib/crypto.so /usr/ssl/lib E: myserver: binary-or-shlib-defines-rpath ./usr/lib/myserver/lib/lib/crypto-2.0.2/priv/lib/crypto.so /usr/local/lib E: myserver: binary-or-shlib-defines-rpath ./usr/lib/myserver/lib/lib/crypto-2.0.2/priv/lib/crypto.so /usr/local/openssl/lib64 E: myserver: binary-or-shlib-defines-rpath ./usr/lib/myserver/lib/lib/crypto-2.0.2/priv/lib/crypto.so /usr/lib/ssl/lib E: myserver: binary-or-shlib-defines-rpath ./usr/lib/myserver/lib/lib/crypto-2.0.2/priv/lib/crypto.so /usr/openssl/lib E: myserver: binary-or-shlib-defines-rpath ./usr/lib/myserver/lib/lib/crypto-2.0.2/priv/lib/crypto.so /usr/pkg/lib64 E: myserver: binary-or-shlib-defines-rpath ./usr/lib/myserver/lib/lib/crypto-2.0.2/priv/lib/crypto.so /usr/local/ssl/lib64 E: myserver: binary-or-shlib-defines-rpath ./usr/lib/myserver/lib/lib/crypto-2.0.2/priv/lib/crypto.so /usr/local/openssl/lib E: myserver: binary-or-shlib-defines-rpath ./usr/lib/myserver/lib/lib/crypto-2.0.2/priv/lib/crypto.so /usr/local/ssl/lib E: myserver: binary-or-shlib-defines-rpath ./usr/lib/myserver/lib/lib/crypto-2.0.2/priv/lib/crypto.so /usr/sfw/lib E: myserver: binary-or-shlib-defines-rpath ./usr/lib/myserver/lib/lib/crypto-2.0.2/priv/lib/crypto.so /usr/lib E: myserver: binary-or-shlib-defines-rpath ./usr/lib/myserver/lib/lib/crypto-2.0.2/priv/lib/crypto.so /opt/local/lib E: myserver: binary-or-shlib-defines-rpath ./usr/lib/myserver/lib/lib/crypto-2.0.2/priv/lib/crypto.so /usr/lib64 E: myserver: binary-or-shlib-defines-rpath ./usr/lib/myserver/lib/lib/crypto-2.0.2/priv/lib/crypto.so /usr/lib/ssl/lib64 E: myserver: binary-or-shlib-defines-rpath ./usr/lib/myserver/lib/lib/crypto-2.0.2/priv/lib/crypto.so /usr/lib/openssl/lib64 E: myserver: binary-or-shlib-defines-rpath ./usr/lib/myserver/lib/lib/crypto-2.0.2/priv/lib/crypto.so /usr/local/lib64 E: myserver: binary-or-shlib-defines-rpath ./usr/lib/myserver/lib/lib/crypto-2.0.2/priv/lib/crypto.so /usr/openssl/lib64 E: myserver: binary-or-shlib-defines-rpath ./usr/lib/myserver/lib/lib/crypto-2.0.2/priv/lib/crypto.so /opt/local/lib64 E: myserver: binary-or-shlib-defines-rpath ./usr/lib/myserver/lib/lib/crypto-2.0.2/priv/lib/crypto.so /usr/pkg/lib E: myserver: binary-or-shlib-defines-rpath ./usr/lib/myserver/lib/lib/crypto-2.0.2/priv/lib/crypto.so /usr/sfw/lib64 E: myserver: binary-or-shlib-defines-rpath ./usr/lib/myserver/lib/lib/crypto-2.0.2/priv/lib/crypto.so /usr/ssl/lib64 E: myserver: binary-or-shlib-defines-rpath ./usr/lib/myserver/lib/lib/crypto-2.0.2/priv/lib/crypto.so /usr/lib/openssl/lib E: myserver: binary-or-shlib-defines-rpath ./usr/lib/myserver/lib/lib/ssl-4.1.1/priv/bin/ssl_esock /usr/ssl/lib E: myserver: binary-or-shlib-defines-rpath ./usr/lib/myserver/lib/lib/ssl-4.1.1/priv/bin/ssl_esock /usr/local/lib E: myserver: binary-or-shlib-defines-rpath ./usr/lib/myserver/lib/lib/ssl-4.1.1/priv/bin/ssl_esock /usr/local/openssl/lib64 E: myserver: binary-or-shlib-defines-rpath ./usr/lib/myserver/lib/lib/ssl-4.1.1/priv/bin/ssl_esock /usr/lib/ssl/lib E: myserver: binary-or-shlib-defines-rpath ./usr/lib/myserver/lib/lib/ssl-4.1.1/priv/bin/ssl_esock /usr/openssl/lib E: myserver: binary-or-shlib-defines-rpath ./usr/lib/myserver/lib/lib/ssl-4.1.1/priv/bin/ssl_esock /usr/pkg/lib64 E: myserver: binary-or-shlib-defines-rpath ./usr/lib/myserver/lib/lib/ssl-4.1.1/priv/bin/ssl_esock /usr/local/ssl/lib64 E: myserver: binary-or-shlib-defines-rpath ./usr/lib/myserver/lib/lib/ssl-4.1.1/priv/bin/ssl_esock /usr/local/openssl/lib E: myserver: binary-or-shlib-defines-rpath ./usr/lib/myserver/lib/lib/ssl-4.1.1/priv/bin/ssl_esock /usr/local/ssl/lib E: myserver: binary-or-shlib-defines-rpath ./usr/lib/myserver/lib/lib/ssl-4.1.1/priv/bin/ssl_esock /usr/sfw/lib E: myserver: binary-or-shlib-defines-rpath ./usr/lib/myserver/lib/lib/ssl-4.1.1/priv/bin/ssl_esock /usr/lib E: myserver: binary-or-shlib-defines-rpath ./usr/lib/myserver/lib/lib/ssl-4.1.1/priv/bin/ssl_esock /opt/local/lib E: myserver: binary-or-shlib-defines-rpath ./usr/lib/myserver/lib/lib/ssl-4.1.1/priv/bin/ssl_esock /usr/lib64 E: myserver: binary-or-shlib-defines-rpath ./usr/lib/myserver/lib/lib/ssl-4.1.1/priv/bin/ssl_esock /usr/lib/ssl/lib64 E: myserver: binary-or-shlib-defines-rpath ./usr/lib/myserver/lib/lib/ssl-4.1.1/priv/bin/ssl_esock /usr/lib/openssl/lib64 E: myserver: binary-or-shlib-defines-rpath ./usr/lib/myserver/lib/lib/ssl-4.1.1/priv/bin/ssl_esock /usr/local/lib64 E: myserver: binary-or-shlib-defines-rpath ./usr/lib/myserver/lib/lib/ssl-4.1.1/priv/bin/ssl_esock /usr/openssl/lib64 E: myserver: binary-or-shlib-defines-rpath ./usr/lib/myserver/lib/lib/ssl-4.1.1/priv/bin/ssl_esock /opt/local/lib64 E: myserver: binary-or-shlib-defines-rpath ./usr/lib/myserver/lib/lib/ssl-4.1.1/priv/bin/ssl_esock /usr/pkg/lib E: myserver: binary-or-shlib-defines-rpath ./usr/lib/myserver/lib/lib/ssl-4.1.1/priv/bin/ssl_esock /usr/sfw/lib64 E: myserver: binary-or-shlib-defines-rpath ./usr/lib/myserver/lib/lib/ssl-4.1.1/priv/bin/ssl_esock /usr/ssl/lib64 E: myserver: binary-or-shlib-defines-rpath ./usr/lib/myserver/lib/lib/ssl-4.1.1/priv/bin/ssl_esock /usr/lib/openssl/lib ________________________________ From: Per Melin To: Ulf Wiger Cc: Pablo Platt ; erlang-questions Sent: Sunday, April 24, 2011 3:39 PM Subject: Re: [erlang-questions] use only parts of a release On Sat, Apr 23, 2011 at 9:27 PM, Ulf Wiger wrote: > I will admit that I haven't been following this thread - apologies. Also, I > have yet to update my old knowledge of how to do this to understand how it's > done using reltool et al. > You can use a releases/ directory outside the OTP root. Thanks. I was confused about the role of the -root flag. It is used in three places that I can find: - init uses it to locate stuff and to replace the default variable $ROOT in the boot script. - code_server uses it (in interactive mode only) as one of the starting points to search for modules. - release_handler uses it as the top directory of the installed release. > When you build the boot script, use the {variables, Vars} option, and when > starting, define the variables using the -boot_var command-line option. > http://www.erlang.org/doc/man/systools.html#make_script-2 > E.g. {variables, [{"MYROOT", PathToMyRoot}, {"OTP_ROOT", ERL_TOP}]} > init:get_argument(root) should point to the place where you have your .rel > and .boot files etc. This can be entirely separate from where you keep your > lib/ roots. Pablo is using rebar. He would need to drop down a few levels to use systools instead. I can't find any support for boot variables in the doc for reltool. It does look to me like reltool_target:gen_script/4 do support them, but that is an internal function and is always called with a hardcoded empty list of variables. I guess one could let rebar generate the release and then use systools:make_script/2 to rebuild the boot script with variables. -------------- next part -------------- An HTML attachment was scrubbed... URL: From dan@REDACTED Sun Apr 24 19:22:10 2011 From: dan@REDACTED (Daniel Dormont) Date: Sun, 24 Apr 2011 13:22:10 -0400 Subject: [erlang-questions] [Erlang-Q] Why can not create a Mnesia schema directory indicated by a full path In-Reply-To: <7FDDE381-42AE-4958-A9BB-B62DFBCD740A@erlang-solutions.com> References: <7FDDE381-42AE-4958-A9BB-B62DFBCD740A@erlang-solutions.com> Message-ID: As a relative newbie to Erlang but experienced Unix user, this was confusing to me at first. I'm very familiar with Unix shell escapes. What was surprising to me when I started working with Erlang was that command line options to Erlang modules require full-fledged Erlang terms: so if you want a string literal, such as in this case, the argument itself needs to include double quotes. Dan On Sun, Apr 24, 2011 at 8:00 AM, Ulf Wiger wrote: > > The issue is with quoting in the unix shell. Try: > > erl -mnesia dir \"/home/myname/tmp/schemas\" > > The reason why it worked with a single directory name was that it parsed as > a valid atom, and the file module allows atoms as file names. > > That is, for any environment variables given as -App Key Value on the > command line, Value will be parsed as an Erlang term. Anything with special > meaning to the command shell needs to be escaped. > > BR, > Ulf W > > On 24 Apr 2011, at 13:04, Barco You wrote: > > > When I tried to indicate Mnesia schema directory with command: erl > -mnesia dir "/home/myname/tmp/schemas", I got error while calling > "mnesia:create_schema([node()|nodes()])" in erlang shell. > > > > But if I start erlang shell with just a string as the schema directory > name such as " erl -mnesa dir location", I could correctly create schema in > erlang shell. > > > > Seemingly Mnesia schema directory can not be indicated as a full path. > > > > {erts, "5.8"}, > > {kernel,"2.14"}, > > {stdlib,"1.17"}. > > > > > > Best regards, > > Barco > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > Ulf Wiger, CTO, Erlang Solutions, Ltd. > http://erlang-solutions.com > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf.wiger@REDACTED Sun Apr 24 19:40:26 2011 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Sun, 24 Apr 2011 19:40:26 +0200 Subject: [erlang-questions] [Erlang-Q] Why can not create a Mnesia schema directory indicated by a full path In-Reply-To: References: <7FDDE381-42AE-4958-A9BB-B62DFBCD740A@erlang-solutions.com> Message-ID: <37D88DAB-833F-4360-B43F-8E378CC57B46@erlang-solutions.com> The application environment variables are a bit special, as they are not primarily intended to be set from the command line. They are normally defined either in the .app file or in the sys.config file. The other command-line options, e.g. -pa and -pz, are more unix-like. :) BR, Ulf W On 24 Apr 2011, at 19:22, Daniel Dormont wrote: > As a relative newbie to Erlang but experienced Unix user, this was confusing to me at first. I'm very familiar with Unix shell escapes. What was surprising to me when I started working with Erlang was that command line options to Erlang modules require full-fledged Erlang terms: so if you want a string literal, such as in this case, the argument itself needs to include double quotes. > > Dan > > On Sun, Apr 24, 2011 at 8:00 AM, Ulf Wiger wrote: > > The issue is with quoting in the unix shell. Try: > > erl -mnesia dir \"/home/myname/tmp/schemas\" > > The reason why it worked with a single directory name was that it parsed as a valid atom, and the file module allows atoms as file names. > > That is, for any environment variables given as -App Key Value on the command line, Value will be parsed as an Erlang term. Anything with special meaning to the command shell needs to be escaped. > > BR, > Ulf W > > On 24 Apr 2011, at 13:04, Barco You wrote: > > > When I tried to indicate Mnesia schema directory with command: erl -mnesia dir "/home/myname/tmp/schemas", I got error while calling "mnesia:create_schema([node()|nodes()])" in erlang shell. > > > > But if I start erlang shell with just a string as the schema directory name such as " erl -mnesa dir location", I could correctly create schema in erlang shell. > > > > Seemingly Mnesia schema directory can not be indicated as a full path. > > > > {erts, "5.8"}, > > {kernel,"2.14"}, > > {stdlib,"1.17"}. > > > > > > Best regards, > > Barco > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > Ulf Wiger, CTO, Erlang Solutions, Ltd. > http://erlang-solutions.com > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions Ulf Wiger, CTO, Erlang Solutions, Ltd. http://erlang-solutions.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From robert.virding@REDACTED Sun Apr 24 20:35:25 2011 From: robert.virding@REDACTED (Robert Virding) Date: Sun, 24 Apr 2011 18:35:25 +0000 (GMT) Subject: [erlang-questions] http:request In-Reply-To: <4DB13D53.3020205@volny.cz> Message-ID: <1472403411.124761303670125353.JavaMail.root@zimbra> If the variables are defined in the head of the fun then they shadow other variables with the same name so you don't get problems with redefining them. So something like: -define(DBG(Str,Args), fun ({Year,Month,Day}, {Hour,Min,Sec}) -> io:format("~2.10.0B/...", [Day,Month,Year,Hour,Min,Sec,?MODULE,?LINE]), io:fornat(Str, Args) end(date(), time())). should work. With the full format string of course. Year, Month, Day, Hour, Min and Sec are now local to the fun so will not clash with other variables and the macro can be used many times. Only problem is that IF they do shadow then the compiler will you warn you about it. I get a lot of those warnings. :-) Robert ----- "Ladislav Lenart" wrote: > Hello, > > see my answer below. > > > On 22.4.2011 09:49, Kostis Sagonas wrote: > > Carlo Bertoldi wrote: > >> Il 21/04/2011 17:10, Carlo Bertoldi ha scritto: > >>> Good afternoon, > >>> I have a problem with http:request. > >>> > >> > >>> > >>> Result = http:request(get, {CompleteUrl, [{"User-Agent", > "Erl-bot"}]}, [], []), > >>> io:format("Result = ~p~n", [Result]). > >>> > >>> Occasionally I don't see Result printed, but a nice error: > >>> ** Reason for termination == > >>> ** {{badmatch,{16,6,18}}, > >> > >> Hello, I discovered the cause of the badmatch: it was due to the > debug macro I've defined. > >> Here it is: > >> > >> -define(DBG(Str, Args), > >> {Year, Month, Day} = date(), > >> {Hour, Min, Sec} = time(), > >> io:format("~2.10.0B/~2.10.0B/~4B ~2.10.0B:~2.10.0B:~2.10.0B [~p:~p] > - ", [Day, Month, > >> Year, Hour, Min, Sec, ?MODULE, ?LINE]), io:format(Str, Args)). > >> > >> Can someone explain me what I did wrong here? Why should I obtain a > badmatch on {Hour, Min, Sec} = time() ? > > > > A typical reason for this is if you used the macro in some context > where variables named Hour, Min, and Sec already existed. This is > called name capture and is a typical problem of macros. You should > > carefully examine all places in the code where this macro is used. > Alternatively, you can try to minimize the risk of name capture by > changing the macro to e.g.: > > > > -define(DBG(Str, Args), > > {Year__, Month__, Day__} = date(), > > {Hour__, Min__, Sec__} = time(), > > io:format("~2.10.0B/~2.10.0B/~4B ~2.10.0B:~2.10.0B:~2.10.0B [~p:~p] > - ", [Day__, Month__, Year__, Hour__, Min__, Sec__, ?MODULE, ?LINE]), > io:format(Str, Args)). > > > If you plan to use ?DBG macro more than once in the same function, > you might want to wrap it in an anonymous fun to prevent its > variables from leaking to the function where the macro is used: > > > -define(DBG(Str, Args), fun () -> > {Year__, Month__, Day__} = date(), > {Hour__, Min__, Sec__} = time(), > io:format("~2.10.0B/~2.10.0B/~4B ~2.10.0B:~2.10.0B:~2.10.0B > [~p:~p] - ", [Day__, Month__, Year__, Hour__, Min__, Sec__, ?MODULE, > ?LINE]), > io:format(Str, Args), > ok > end()). > > With this modification, the following should be possible: > > some_fun() -> > ?DBG("foo", []), > ?DBG("bar", []), > ok. > > However, as Kostis said, the following will still raise a > badmatch error: > > some_other_fun(Year__) -> > ?DBG("foo", []), > ok. > > > HTH, > > Ladislav Lenart > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From watson.timothy@REDACTED Sun Apr 24 20:45:40 2011 From: watson.timothy@REDACTED (Tim Watson) Date: Sun, 24 Apr 2011 19:45:40 +0100 Subject: [erlang-questions] use only parts of a release In-Reply-To: <573426.90205.qm@web112608.mail.gq1.yahoo.com> References: <496034.29700.qm@web112619.mail.gq1.yahoo.com> <202013.91646.qm@web112606.mail.gq1.yahoo.com> <202628.39280.qm@web112601.mail.gq1.yahoo.com> <852604.96454.qm@web112605.mail.gq1.yahoo.com> <160188.68300.qm@web112612.mail.gq1.yahoo.com> <837468.43162.qm@web112620.mail.gq1.yahoo.com> <85729247-0BB1-40A6-B32A-DF98EF69BA25@erlang-solutions.com> <573426.90205.qm@web112608.mail.gq1.yahoo.com> Message-ID: Maybe it might help to poke around in the sources for http://code.google.com/p/erlrc/, which appears to "do appup" via rpm/deb packages. From t.greenwoodgeer@REDACTED Mon Apr 25 06:01:15 2011 From: t.greenwoodgeer@REDACTED (Todd) Date: Sun, 24 Apr 2011 21:01:15 -0700 Subject: [erlang-questions] trouble creating releases with rebar, apps exit with 'bad_return' Message-ID: <4DB4F20B.1080400@gmail.com> Short version: When I create a release with rebar, the app dies with 'bad_return'. Longer version: (rebar version: 2 date: 20110420_043817 vcs: git bd1475d) 1. I've tried following these two rebar tutorials: http://skeptomai.com/?p=56#respond http://alancastro.org/2010/05/01/erlang-application-management-with-rebar.html 2. Following either set of instructions, I can generate a single app and subsequently compile and launch it in the erl shell: rebar create-app rebar compile erl -pa ebin > application:start(myapp). > application:stop(myapp). 3. So far, so good. However, things seem to fall apart in the 'rebar -v generate' command...but then, I'm not sure what I should be seeing here: user@REDACTED:~/projects/testing-rebar-03/mysample$ rebar -v generate DEBUG: Rebar location: "/usr/local/bin/rebar" DEBUG: Entering /home/user/projects/testing-rebar-03/mysample DEBUG: Available deps: [] DEBUG: Missing deps : [] DEBUG: Predirs: ["/home/user/projects/testing-rebar-03/mysample/rel"] DEBUG: Entering /home/user/projects/testing-rebar-03/mysample/rel DEBUG: Available deps: [] DEBUG: Missing deps : [] DEBUG: Predirs: [] ==> rel (generate) DEBUG: Created dir /home/user/projects/testing-rebar-03/mysample/rel/mysample/log/sasl INFO: sh info: cwd: "/home/user/projects/testing-rebar-03/mysample/rel" cmd: cp -R /home/user/projects/testing-rebar-03/mysample/rel/files/erl /home/user/projects/testing-rebar-03/mysample/rel/mysample/erts-5.7.5/bin/erl opts: [{use_stdout,false},return_on_error] INFO: sh info: cwd: "/home/user/projects/testing-rebar-03/mysample/rel" cmd: cp -R /home/user/projects/testing-rebar-03/mysample/rel/files/nodetool /home/user/projects/testing-rebar-03/mysample/rel/mysample/erts-5.7.5/bin/nodetool opts: [{use_stdout,false},return_on_error] INFO: sh info: cwd: "/home/user/projects/testing-rebar-03/mysample/rel" cmd: cp -R /home/user/projects/testing-rebar-03/mysample/rel/files/mysample /home/user/projects/testing-rebar-03/mysample/rel/mysample/bin/mysample opts: [{use_stdout,false},return_on_error] INFO: sh info: cwd: "/home/user/projects/testing-rebar-03/mysample/rel" cmd: cp -R /home/user/projects/testing-rebar-03/mysample/rel/files/app.config /home/user/projects/testing-rebar-03/mysample/rel/mysample/etc/app.config opts: [{use_stdout,false},return_on_error] INFO: sh info: cwd: "/home/user/projects/testing-rebar-03/mysample/rel" cmd: cp -R /home/user/projects/testing-rebar-03/mysample/rel/files/vm.args /home/user/projects/testing-rebar-03/mysample/rel/mysample/etc/vm.args opts: [{use_stdout,false},return_on_error] DEBUG: Postdirs: [] WARN: 'generate' command does not apply to directory /home/user/projects/testing-rebar-03/mysample DEBUG: Postdirs: [] 4. However, the true error shows when I try to start the rebar created app: user@REDACTED:~/projects/testing-rebar-01$ sh rel/mynode/bin/mynode console Exec: /home/user/projects/testing-rebar-01/rel/mynode/erts-5.7.5/bin/erlexec -boot /home/user/projects/testing-rebar-01/rel/mynode/releases/1/mynode -embedded -config /home/user/projects/testing-rebar-01/rel/mynode/etc/app.config -args_file /home/user/projects/testing-rebar-01/rel/mynode/etc/vm.args -- console Root: /home/user/projects/testing-rebar-01/rel/mynode Erlang R13B04 (erts-5.7.5) [source] [rq:1] [async-threads:5] [kernel-poll:true] =INFO REPORT==== 19-Apr-2011::22:51:20 === application: myapp exited: {bad_return, {{myapp_app,start,[normal,[]]}, {'EXIT', {undef, [{myapp_app,start,[normal,[]]}, {application_master,start_it_old,4}]}}}} type: permanent {"Kernel pid terminated",application_controller,"{application_start_failure,myapp,{bad_return,{{myapp_app,start,[normal,[]]},{'EXIT',{undef,[{myapp_app,start,[normal,[]]},{application_master,start_it_old,4}]}}}}}"} Crash dump was written to: erl_crash.dump Kernel pid terminated (application_controller) ({application_start_failure,myapp,{bad_return,{{myapp_app,start,[normal,[]]},{'EXIT',{undef,[{myapp_app,start,[normal,[]]},{application_master,start_it 5. I have tried creating and releasing apps via rebar using both sets of instructions, on both mac os x, and linux, multiple times... and in all cases, I've run into the 'bad_return' when attempting to start the app. 6. I see that this question has been raised before: https://groups.google.com/group/erlang-programming/browse_thread/thread/47961ad971086582 5. And the idea was that the app wasn't being compiled (or the compiled files couldn't be found). Well, I can see the app being compiled here: user@REDACTED:~/projects/testing-rebar-01$ rebar compile ==> myapp (compile) ==> rel (compile) ==> testing-rebar-01 (compile) 6. And when I generate the release, it's all new: user@REDACTED:~/projects/testing-rebar-01$ rm -rf rel/mynode/ && rebar generate && sh rel/mynode/bin/mynode console 7. However, the generated release looks suspicious... for one thing, my app files are not in the release dir: user@REDACTED:~/projects/testing-rebar-01$ find . | grep myapp ./apps/myapp ./apps/myapp/src ./apps/myapp/src/myapp_app.erl ./apps/myapp/src/myapp.app.src ./apps/myapp/src/myapp_sup.erl ./apps/myapp/ebin ./apps/myapp/ebin/myapp_app.beam ./apps/myapp/ebin/myapp_sup.beam ./apps/myapp/ebin/myapp.app 8. For another thing, my app beam files are not in the release dir, either: user@REDACTED:~/projects/testing-rebar-01$ find . | grep beam ./apps/myapp/ebin/myapp_app.beam ./apps/myapp/ebin/myapp_sup.beam ./rel/mynode/erts-5.7.5/bin/beam.smp ./rel/mynode/erts-5.7.5/bin/beam 9. Could someone show me what's supposed to be generated from the rebar generate command? Specifically, what files do I need to look at to verify that my application files have properly compiled into the release? 10. Also, any hints as to how one should approach this sort of problem, debugging hints, etc. are always appreciated. ---------------- files ---------------- user@REDACTED:~/projects/testing-rebar-01$ cat rebar.config {sub_dirs, ["apps/myapp", "rel"]}. user@REDACTED:~/projects/testing-rebar-01$ cat rel/reltool.config {sys, [ {lib_dirs, ["../apps"]}, {rel, "mynode", "1", [ myapp, kernel, stdlib, sasl ]}, {rel, "start_clean", "", [ kernel, stdlib ]}, {boot_rel, "mynode"}, {profile, embedded}, {excl_sys_filters, ["^bin/.*", "^erts.*/bin/(dialyzer|typer)"]}, {app, sasl, [{incl_cond, include}]} ]}. {target_dir, "mynode"}. {overlay, [ {mkdir, "log/sasl"}, {copy, "files/erl", "\{\{erts_vsn\}\}/bin/erl"}, {copy, "files/nodetool", "\{\{erts_vsn\}\}/bin/nodetool"}, {copy, "files/mynode", "bin/mynode"}, {copy, "files/app.config", "etc/app.config"}, {copy, "files/vm.args", "etc/vm.args"} ]}. Thanks, -Todd From yaohui1984@REDACTED Mon Apr 25 08:26:07 2011 From: yaohui1984@REDACTED (=?ISO-8859-1?B?eWFvaHVp?=) Date: Mon, 25 Apr 2011 14:26:07 +0800 Subject: [erlang-questions] About release R14B02 Message-ID: I found that HIPE and halfword emulator cann't be used at the same time in 64-bit linux system, when compiling release R14B02 . Is that a bug? -------------- next part -------------- An HTML attachment was scrubbed... URL: From yaohui1984@REDACTED Mon Apr 25 08:49:15 2011 From: yaohui1984@REDACTED (=?ISO-8859-1?B?eWFvaHVp?=) Date: Mon, 25 Apr 2011 14:49:15 +0800 Subject: [erlang-questions] About release R14B02 Message-ID: Thanks, but would the next release fix this problem? ------------------ Original ------------------ From: "Harsh J"; Date: Mon, Apr 25, 2011 03:13 PM To: "yaohui"; Subject: Re: [erlang-questions] About release R14B02 Not a bug, since halfword can't be used along with HiPE right now. See this erlang-bugs@ thread for more information: http://erlang.org/pipermail/erlang-bugs/2011-March/002245.html On Mon, Apr 25, 2011 at 11:56 AM, yaohui wrote: > I found that HIPE and halfword emulator cann't be used at the same time in > 64-bit linux system, when compiling release R14B02 . Is that a bug? > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -- Harsh J http://harshj.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From qwertymaniac@REDACTED Mon Apr 25 09:25:09 2011 From: qwertymaniac@REDACTED (Harsh J) Date: Mon, 25 Apr 2011 12:55:09 +0530 Subject: [erlang-questions] About release R14B02 In-Reply-To: References: Message-ID: The compile options issue should be fixed in the next release. On Mon, Apr 25, 2011 at 12:19 PM, yaohui wrote: > > Thanks, but would?the next release fix this problem? > ------------------?Original?------------------ > From: ?"Harsh J"; > Date: ?Mon, Apr 25, 2011 03:13 PM > To: ?"yaohui"; > Subject: ?Re: [erlang-questions] About release R14B02 > > Not a bug, since halfword can't be used along with HiPE right now. > See this erlang-bugs@ thread for more information: > http://erlang.org/pipermail/erlang-bugs/2011-March/002245.html > > On Mon, Apr 25, 2011 at 11:56 AM, yaohui wrote: >> I found that HIPE and halfword emulator cann't be used at the same time in >> 64-bit linux system, when compiling release R14B02 . Is that a bug? >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> > > > > -- > Harsh J > http://harshj.com > > -- Harsh J http://harshj.com From moxford@REDACTED Mon Apr 25 10:34:47 2011 From: moxford@REDACTED (Mike Oxford) Date: Mon, 25 Apr 2011 01:34:47 -0700 Subject: [erlang-questions] trouble creating releases with rebar, apps exit with 'bad_return' In-Reply-To: <4DB4F20B.1080400@gmail.com> References: <4DB4F20B.1080400@gmail.com> Message-ID: You will need to create a node before you can generate a release. create 'rel' directory and cd into it rebar -v create-node nodeid= Modify the generated reltool.config file rebar -v generate Subsequent generate calls will need to have "force=1" added to overwrite the previously generated node. After you have a node generated, ex: nodeid=moxnode, then you can launch with boot scripts... rel//bin/ start Look in Alan's link for ... "To create a release we have to create a new directory in the root of our project called *rel* and create a node in it. A node is kind of a standalone Erlang VM for our application to run on." That looks like what you're missing. Another perspective... https://bitbucket.org/basho/rebar/wiki/ReleaseHandling -mox On Sun, Apr 24, 2011 at 9:01 PM, Todd wrote: > Short version: > When I create a release with rebar, the app dies with 'bad_return'. > > Longer version: > (rebar version: 2 date: 20110420_043817 vcs: git bd1475d) > > 1. I've tried following these two rebar tutorials: > > http://skeptomai.com/?p=56#respond > > http://alancastro.org/2010/05/01/erlang-application-management-with-rebar.html > > 2. Following either set of instructions, I can generate a single app and > subsequently compile and launch it in the erl shell: > > rebar create-app > rebar compile > erl -pa ebin > > application:start(myapp). >> application:stop(myapp). >> > > 3. So far, so good. However, things seem to fall apart in the 'rebar -v > generate' command...but then, I'm not sure what I should be seeing here: > > user@REDACTED:~/projects/testing-rebar-03/mysample$ rebar -v generate > DEBUG: Rebar location: "/usr/local/bin/rebar" > DEBUG: Entering /home/user/projects/testing-rebar-03/mysample > DEBUG: Available deps: [] > DEBUG: Missing deps : [] > DEBUG: Predirs: ["/home/user/projects/testing-rebar-03/mysample/rel"] > DEBUG: Entering /home/user/projects/testing-rebar-03/mysample/rel > DEBUG: Available deps: [] > DEBUG: Missing deps : [] > DEBUG: Predirs: [] > ==> rel (generate) > DEBUG: Created dir > /home/user/projects/testing-rebar-03/mysample/rel/mysample/log/sasl > INFO: sh info: > cwd: "/home/user/projects/testing-rebar-03/mysample/rel" > cmd: cp -R > /home/user/projects/testing-rebar-03/mysample/rel/files/erl > /home/user/projects/testing-rebar-03/mysample/rel/mysample/erts-5.7.5/bin/erl > opts: [{use_stdout,false},return_on_error] > INFO: sh info: > cwd: "/home/user/projects/testing-rebar-03/mysample/rel" > cmd: cp -R > /home/user/projects/testing-rebar-03/mysample/rel/files/nodetool > /home/user/projects/testing-rebar-03/mysample/rel/mysample/erts-5.7.5/bin/nodetool > opts: [{use_stdout,false},return_on_error] > INFO: sh info: > cwd: "/home/user/projects/testing-rebar-03/mysample/rel" > cmd: cp -R > /home/user/projects/testing-rebar-03/mysample/rel/files/mysample > /home/user/projects/testing-rebar-03/mysample/rel/mysample/bin/mysample > opts: [{use_stdout,false},return_on_error] > INFO: sh info: > cwd: "/home/user/projects/testing-rebar-03/mysample/rel" > cmd: cp -R > /home/user/projects/testing-rebar-03/mysample/rel/files/app.config > /home/user/projects/testing-rebar-03/mysample/rel/mysample/etc/app.config > opts: [{use_stdout,false},return_on_error] > INFO: sh info: > cwd: "/home/user/projects/testing-rebar-03/mysample/rel" > cmd: cp -R > /home/user/projects/testing-rebar-03/mysample/rel/files/vm.args > /home/user/projects/testing-rebar-03/mysample/rel/mysample/etc/vm.args > opts: [{use_stdout,false},return_on_error] > DEBUG: Postdirs: [] > WARN: 'generate' command does not apply to directory > /home/user/projects/testing-rebar-03/mysample > DEBUG: Postdirs: [] > > 4. However, the true error shows when I try to start the rebar created app: > > user@REDACTED:~/projects/testing-rebar-01$ sh rel/mynode/bin/mynode > console > Exec: > /home/user/projects/testing-rebar-01/rel/mynode/erts-5.7.5/bin/erlexec -boot > /home/user/projects/testing-rebar-01/rel/mynode/releases/1/mynode -embedded > -config /home/user/projects/testing-rebar-01/rel/mynode/etc/app.config > -args_file /home/user/projects/testing-rebar-01/rel/mynode/etc/vm.args -- > console > Root: /home/user/projects/testing-rebar-01/rel/mynode > Erlang R13B04 (erts-5.7.5) [source] [rq:1] [async-threads:5] > [kernel-poll:true] > > > =INFO REPORT==== 19-Apr-2011::22:51:20 === > application: myapp > exited: {bad_return, > {{myapp_app,start,[normal,[]]}, > {'EXIT', > {undef, > [{myapp_app,start,[normal,[]]}, > {application_master,start_it_old,4}]}}}} > type: permanent > {"Kernel pid > terminated",application_controller,"{application_start_failure,myapp,{bad_return,{{myapp_app,start,[normal,[]]},{'EXIT',{undef,[{myapp_app,start,[normal,[]]},{application_master,start_it_old,4}]}}}}}"} > > Crash dump was written to: erl_crash.dump > Kernel pid terminated (application_controller) > ({application_start_failure,myapp,{bad_return,{{myapp_app,start,[normal,[]]},{'EXIT',{undef,[{myapp_app,start,[normal,[]]},{application_master,start_it > > > 5. I have tried creating and releasing apps via rebar using both sets of > instructions, on both mac os x, and linux, multiple times... and in all > cases, I've run into the 'bad_return' when attempting to start the app. > > 6. I see that this question has been raised before: > > > https://groups.google.com/group/erlang-programming/browse_thread/thread/47961ad971086582 > > 5. And the idea was that the app wasn't being compiled (or the compiled > files couldn't be found). Well, I can see the app being compiled here: > > user@REDACTED:~/projects/testing-rebar-01$ rebar compile > ==> myapp (compile) > ==> rel (compile) > ==> testing-rebar-01 (compile) > > 6. And when I generate the release, it's all new: > > user@REDACTED:~/projects/testing-rebar-01$ rm -rf rel/mynode/ && rebar > generate && sh rel/mynode/bin/mynode console > > 7. However, the generated release looks suspicious... for one thing, my app > files are not in the release dir: > > user@REDACTED:~/projects/testing-rebar-01$ find . | grep myapp > ./apps/myapp > ./apps/myapp/src > ./apps/myapp/src/myapp_app.erl > ./apps/myapp/src/myapp.app.src > ./apps/myapp/src/myapp_sup.erl > ./apps/myapp/ebin > ./apps/myapp/ebin/myapp_app.beam > ./apps/myapp/ebin/myapp_sup.beam > ./apps/myapp/ebin/myapp.app > > > 8. For another thing, my app beam files are not in the release dir, either: > > user@REDACTED:~/projects/testing-rebar-01$ find . | grep beam > ./apps/myapp/ebin/myapp_app.beam > ./apps/myapp/ebin/myapp_sup.beam > ./rel/mynode/erts-5.7.5/bin/beam.smp > ./rel/mynode/erts-5.7.5/bin/beam > > 9. Could someone show me what's supposed to be generated from the rebar > generate command? Specifically, what files do I need to look at to verify > that my application files have properly compiled into the release? > > 10. Also, any hints as to how one should approach this sort of problem, > debugging hints, etc. are always appreciated. > > > ---------------- > files > ---------------- > user@REDACTED:~/projects/testing-rebar-01$ cat rebar.config > {sub_dirs, ["apps/myapp", "rel"]}. > user@REDACTED:~/projects/testing-rebar-01$ cat rel/reltool.config > {sys, [ > {lib_dirs, ["../apps"]}, > {rel, "mynode", "1", > [ > myapp, > kernel, > stdlib, > sasl > ]}, > {rel, "start_clean", "", > [ > kernel, > stdlib > ]}, > {boot_rel, "mynode"}, > {profile, embedded}, > {excl_sys_filters, ["^bin/.*", > "^erts.*/bin/(dialyzer|typer)"]}, > {app, sasl, [{incl_cond, include}]} > ]}. > > {target_dir, "mynode"}. > > {overlay, [ > {mkdir, "log/sasl"}, > {copy, "files/erl", "\{\{erts_vsn\}\}/bin/erl"}, > {copy, "files/nodetool", "\{\{erts_vsn\}\}/bin/nodetool"}, > {copy, "files/mynode", "bin/mynode"}, > {copy, "files/app.config", "etc/app.config"}, > {copy, "files/vm.args", "etc/vm.args"} > ]}. > > > Thanks, > > -Todd > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From icarus.alive@REDACTED Mon Apr 25 11:16:21 2011 From: icarus.alive@REDACTED (Icarus Alive) Date: Mon, 25 Apr 2011 14:46:21 +0530 Subject: [erlang-questions] learner's questions -- tuples, CEAN & jungerl Message-ID: Hi, Started learning Erlang using Joe Armstrong's book, and just at about chapter-3. Have few basic / elementary questions. 1. Found the following usage of tuple -- { person, { name, joe }, { age, 42 } } Now when one has millions on such tuples, which are held in-memory, isn't the memory footprint of the application at-least 3 x 8-byte extranuous thanks to the 3 atoms (person, name, age), playing "field names" ? Is this a concern for anyone ? Is there are more efficient storage ? 2. about CEAN How relevant / current is this as a repository of 3rd party / user-contributed libraries / tools / applications ? Few of the libraries / applications seem to point to documentation on www.erlang.org site. Does it mean that such libraries / applications / tools have already been rolled-into the official Erlang distribution ? 3. about Jungerl How relevant / current is this as a repository of 3rd party / user-contributed libraries / tools / applications ? Is this rolled-into CEAN in some way ? Few of the libraries / applications seem to point to documentation on www.erlang.org site. Does it mean that such libraries / applications / tools have already been rolled-into the official Erlang distribution ? thanks, Icarus -------------- next part -------------- An HTML attachment was scrubbed... URL: From ciprian.craciun@REDACTED Mon Apr 25 12:17:57 2011 From: ciprian.craciun@REDACTED (Ciprian Dorin Craciun) Date: Mon, 25 Apr 2011 13:17:57 +0300 Subject: [erlang-questions] Regarding `application:get_env` / `application:set_env` race conditions Message-ID: Hello all! I've started studying some popular Erlang applications in order to use them in a project of mine. Now I've seen that quite a good proportion of these use the application environment as a run-time configuration database -- for example a well known web framework uses it for storing routing information. (I don't name it here as I don't want this to be taken as a criticism. The developers have done a very good overall job and I congratulate them for this.) Thus I see more and more the following pattern: ~~~~ ... case application:get_env (some_app, some_config) of undefined -> application:set_env (some_app, some_config, [SomeValue]); {ok, OlderValues} -> application:set_env (some_app, some_config, [SomeValue|OlderValues]) end, ... ~~~~ Thus certainly in a concurrent environment this leads to a race condition in which two independent calls to the above code would override one each-other. (In some cases this code is hidden behind a `gen_server`, thus the access is sequential, but still using this environment transforms it into a global shared state, which would require other tools.) Thus my two questions are the following: * is it an acceptable pattern in an OTP application to use the application environment as a run-time changing database? * shouldn't there be at least an option in the `application` module that would allow atomic update of an environment value? (For example `update_env(Application, [{Parameter, Fun}])`, which would allow updating multiple parameters atomically; (by the way, shouldn't this option also be available for ETS / DETS?) Thanks, Ciprian. From kostis@REDACTED Mon Apr 25 13:10:03 2011 From: kostis@REDACTED (Kostis Sagonas) Date: Mon, 25 Apr 2011 14:10:03 +0300 Subject: [erlang-questions] Specifying 'erts' as an application In-Reply-To: <4D9868DB.5010602@cs.ntua.gr> References: <4D9868DB.5010602@cs.ntua.gr> Message-ID: <4DB5568B.9030305@cs.ntua.gr> About three weeks ago, I posted the following question but got no answer so far. Let me ask it differently in the hope that I will now get some reaction. Is there any good reason why the erts application does not have a .app file as all other OTP applications (e.g. kernel, stdlib, etc.) have? If there is no good reason, can it please be added? Kostis Kostis Sagonas wrote: > The Erlang/OTP documentation specifies 'erts' as an application: > > http://erlang.org/doc/applications.html > > In a project we are working on, we have an application resource file > that reads: > > {application, APP_NAME, > [{description, ...}, > ... > {applications, [erts, kernel, stdlib, ...] > ... > ]}. > > A user informed us that "erts isn't actually an application that can be > dependent upon and that having it in the applications list breaks > releases". > > I personally consider this a bug, of Erlang/OTP that is, but I will > gladly be enlightened why 'erts' is listed as an OTP application but > cannot be listed in the application resource file and releases break > miserably when one does so. > > Kostis > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From jesper.louis.andersen@REDACTED Mon Apr 25 13:48:05 2011 From: jesper.louis.andersen@REDACTED (Jesper Louis Andersen) Date: Mon, 25 Apr 2011 13:48:05 +0200 Subject: [erlang-questions] learner's questions -- tuples, CEAN & jungerl In-Reply-To: References: Message-ID: On Mon, Apr 25, 2011 at 11:16, Icarus Alive wrote: > 1. Found the following usage of tuple -- > ?? ? ? { person, { name, joe }, { age, 42 } } > ?? ?Now when one has millions on such tuples, which are held in-memory, > isn't the memory footprint of the application at-least 3 ?x 8-byte > extranuous thanks to the 3 atoms (person, name, age), playing "field names" > ? Is this a concern for anyone ? Is there are more efficient storage ? It is actually far worse than 3 * 8 bytes as the representation is boxed everywhere. So each of the tuples are also taking up memory. There are some ways to limit the memory usage though: a) Use records. If we have a record #person { name = joe, age = 42}, the internal representation is {person, joe, 42} which avoids a lot of the tupling overhead. b) Use the halfword emulator. The process-local representation would in that case be much better. c) If you store millions of these tuples, chances are you want to use ETS for it. ETS takes a "compressed" option which trades speed for space. d) If you have rather rare access to the data, you can store them in a binary format which take up less space. Is it a concern? In some cases yes, but note that buying more memory is a relatively cheap thing and that you have the above options to counter it. My main concern is that the internal representation of this, heavily boxed as it is, costs memory lookups - which then cost execution speed compared to an unboxed representation. My concern would be with the cache, not the total memory use. -- J. From ulf.wiger@REDACTED Mon Apr 25 14:55:08 2011 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Mon, 25 Apr 2011 14:55:08 +0200 Subject: [erlang-questions] Regarding `application:get_env` / `application:set_env` race conditions In-Reply-To: References: Message-ID: <03C7C4FE-5B2F-48BD-AFF6-142F8EA5DD47@erlang-solutions.com> Hi Ciprian, The application:set_env/3 function is intended for in-service upgrade, not for the uses you describe. It is of course a slight problem for non-OTP components that there is no other ubiquitous way of maintaining a configuration database; mnesia is quite a good alternative, for example, but not all systems use it. A dets file would work, but where to put it? There is no standard answer. A problem with using application:set_env/3, besides the race condition* that you correctly point out, is that it is not persistent, although the application env vars are perceived as a persistent read-only store. This is a problem in the sense that if another process reads an environment variable, they are likely to assume that the value was set at boot time and unlikely to change after that. I will not present an alternative at this time - although your question gave me an idea. I'll have to think it through a bit first. BR, Ulf W On 25 Apr 2011, at 12:17, Ciprian Dorin Craciun wrote: > Hello all! > > I've started studying some popular Erlang applications in order to > use them in a project of mine. > > Now I've seen that quite a good proportion of these use the > application environment as a run-time configuration database -- for > example a well known web framework uses it for storing routing > information. (I don't name it here as I don't want this to be taken as > a criticism. The developers have done a very good overall job and I > congratulate them for this.) > > Thus I see more and more the following pattern: > ~~~~ > ... > case application:get_env (some_app, some_config) of > undefined -> > application:set_env (some_app, some_config, [SomeValue]); > {ok, OlderValues} -> > application:set_env (some_app, some_config, [SomeValue|OlderValues]) > end, > ... > ~~~~ > > Thus certainly in a concurrent environment this leads to a race > condition in which two independent calls to the above code would > override one each-other. (In some cases this code is hidden behind a > `gen_server`, thus the access is sequential, but still using this > environment transforms it into a global shared state, which would > require other tools.) > > Thus my two questions are the following: > * is it an acceptable pattern in an OTP application to use the > application environment as a run-time changing database? > * shouldn't there be at least an option in the `application` > module that would allow atomic update of an environment value? (For > example `update_env(Application, [{Parameter, Fun}])`, which would > allow updating multiple parameters atomically; (by the way, shouldn't > this option also be available for ETS / DETS?) > > Thanks, > Ciprian. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions Ulf Wiger, CTO, Erlang Solutions, Ltd. http://erlang-solutions.com From ulf.wiger@REDACTED Mon Apr 25 15:23:20 2011 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Mon, 25 Apr 2011 15:23:20 +0200 Subject: [erlang-questions] Specifying 'erts' as an application In-Reply-To: <4DB5568B.9030305@cs.ntua.gr> References: <4D9868DB.5010602@cs.ntua.gr> <4DB5568B.9030305@cs.ntua.gr> Message-ID: I will venture a guess. ERTS was perceived from the beginning as the "master environment" in which applications ran, but has increasingly come to be treated as one of several applications. From that perspective, it's not unreasonable to think that it could be named as one. OTOH, 'erts' is actually a perfectly valid application name, so one may assume that there is some user out there who has defined such an application, and is referring to it in a thousand different places ;-) BR, Ulf W On 25 Apr 2011, at 13:10, Kostis Sagonas wrote: > About three weeks ago, I posted the following question but got no answer so far. Let me ask it differently in the hope that I will now get some reaction. > > Is there any good reason why the erts application does not have a .app file as all other OTP applications (e.g. kernel, stdlib, etc.) have? > > If there is no good reason, can it please be added? > > Kostis > > Kostis Sagonas wrote: >> The Erlang/OTP documentation specifies 'erts' as an application: >> http://erlang.org/doc/applications.html >> In a project we are working on, we have an application resource file that reads: >> {application, APP_NAME, >> [{description, ...}, >> ... >> {applications, [erts, kernel, stdlib, ...] >> ... >> ]}. >> A user informed us that "erts isn't actually an application that can be dependent upon and that having it in the applications list breaks releases". >> I personally consider this a bug, of Erlang/OTP that is, but I will gladly be enlightened why 'erts' is listed as an OTP application but cannot be listed in the application resource file and releases break miserably when one does so. >> Kostis >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions Ulf Wiger, CTO, Erlang Solutions, Ltd. http://erlang-solutions.com From icarus.alive@REDACTED Mon Apr 25 15:27:06 2011 From: icarus.alive@REDACTED (Icarus Alive) Date: Mon, 25 Apr 2011 18:57:06 +0530 Subject: [erlang-questions] learner's questions -- tuples, CEAN & jungerl In-Reply-To: References: Message-ID: Appreciate the explanation. On Mon, Apr 25, 2011 at 5:18 PM, Jesper Louis Andersen < jesper.louis.andersen@REDACTED> wrote: > On Mon, Apr 25, 2011 at 11:16, Icarus Alive > wrote: > > > 1. Found the following usage of tuple -- > > { person, { name, joe }, { age, 42 } } > > Now when one has millions on such tuples, which are held in-memory, > > isn't the memory footprint of the application at-least 3 x 8-byte > > extranuous thanks to the 3 atoms (person, name, age), playing "field > names" > > ? Is this a concern for anyone ? Is there are more efficient storage ? > > It is actually far worse than 3 * 8 bytes as the representation is > boxed everywhere. So each of the tuples are also taking up memory. > There are some ways to limit the memory usage though: > > a) Use records. If we have a record #person { name = joe, age = 42}, > the internal representation is {person, joe, 42} which avoids a lot of > the tupling overhead. > Okay, quickly jumping ahead and reading record, looks like it will give a saving of at least 2 atom's per tuple, still a 8Byte cost to pay to be able to achieve some level of introspection. > b) Use the halfword emulator. The process-local representation would > in that case be much better. > > c) If you store millions of these tuples, chances are you want to use > ETS for it. ETS takes a "compressed" option which trades speed for > space. > When I send "held in-memory" it was for purposes like HTTP session context, or a proprietary TCP based protocol's session context. Each of those contexts is in active use. So the "person" tuple was probably not a good example. In such a case where 1 single Erlang process having million active tuples, or multiple (millions?) of Erlang processes each with such a tuple, would it still be a candidate for ETS ? d) If you have rather rare access to the data, you can store them in a > binary format which take up less space. > As in programmatically turn the Erlang representation into a Blob (of sorts) ? Does Erlang come with some batteries for this purpose, or some recommended best-practices, or it is completely DIY ? > Is it a concern? In some cases yes, but note that buying more memory > is a relatively cheap thing and that you have the above options to > counter it. Okay, that makes sense. > My main concern is that the internal representation of > this, heavily boxed as it is, costs memory lookups - which then cost > execution speed compared to an unboxed representation. In this particular context, do we mean that... { person, { name, joe }, { age, 42 } } -- is boxed representation, and { person, joe, 42 } -- is unboxed repsentation ? or | $j,$o,$e | 42.0000 | (as 32 bytes in memory) -- is unboxed (internal) representation ? I.e. what exactly are we calling the boxed / unboxed representation in this context. My concern > would be with the cache, not the total memory use. > Agreed. This is indeed the biggest concern, but I've seen far too many Java / J2EE applications where system-memory becomes a constraint far before CPU is even @ 25% of saturation, especially where we want to avoid swapping. Does anyone see that a possibility here with Erlang as well ? -------------- next part -------------- An HTML attachment was scrubbed... URL: From james.hague@REDACTED Mon Apr 25 16:00:46 2011 From: james.hague@REDACTED (James Hague) Date: Mon, 25 Apr 2011 09:00:46 -0500 Subject: [erlang-questions] learner's questions -- tuples, CEAN & jungerl In-Reply-To: References: Message-ID: > 1. Found the following usage of tuple -- > ?? ? ? { person, { name, joe }, { age, 42 } } > ?? ?Now when one has millions on such tuples, which are held in-memory, > isn't the memory footprint of the application at-least 3 ?x 8-byte > extranuous thanks to the 3 atoms (person, name, age), playing "field names" A tuple uses 1 + tuple_size cells, where a cell is either 32 or 64 bits, In your example: {age, 42} = 3 cells {name, joe} = 3 cells {person, _, _} = 4 cells the total is 10 cells, or 40 bytes (double that if you're running the full 64-bit version of the Erlang). Personally, I don't think the memory usage is any kind of issue here. I like to use lists of {Key, Value} tuples, which has even more overhead. But if you've got some special case where you need millions of such structures, then you could trade away flexibility in exchange for lower memory usage and just go with {Age, Name}. That's only 3 cells instead of 10. (And if really pressed, there's [Age|Name] which drops the count to 2 cells.) From paul.sullivan@REDACTED Mon Apr 25 17:03:56 2011 From: paul.sullivan@REDACTED (Paul Sullivan) Date: Mon, 25 Apr 2011 11:03:56 -0400 Subject: [erlang-questions] Crypto load failure Message-ID: <4DB58D5C.2060603@teamaol.com> Since upgrading to R14B01, I have been unable to successfully load the crypto drv. I get the following error on use: The on_load function for module crypto returned {error, {load_failed, "Failed to load NIF library: '/opt/bcs/packages/erlang-R14/lib/erlang/lib/crypto-2.0.2/priv/lib/crypto.so: undefined symbol: enif_inspect_iolist_as_binary'"}} Any ideas as to what the culprit may be here? Thanks, ---- Build bits of interest below. ---- /opt/bcs/bin/gcc -c -o ../priv/obj/x86_64-unknown-linux-gnu/crypto.o -Wall -Wstrict-prototypes -Wmissing-prototypes -Wdeclaration-after-statement -DUSE_THREADS -D_THREAD_SAFE -D_REENTRANT -DPOSIX_THREADS -D_POSIX_THREAD_SAFE_FUNCTIONS -g -O -fPIC -fno-strict-aliasing -I/opt/src/RPM/BUILD/otp_src_R14B01/erts/x86_64-unknown-linux-gnu -fno-tree-copyrename -I/opt/bcs/include -D_GNU_SOURCE -fPIC -I/opt/bcs/packages/openssl/include -I/opt/src/RPM/BUILD/otp_src_R14B01/erts/emulator/beam -I/opt/src/RPM/BUILD/otp_src_R14B01/erts/include -I/opt/src/RPM/BUILD/otp_src_R14B01/erts/include/x86_64-unknown-linux-gnu -I/opt/src/RPM/BUILD/otp_src_R14B01/erts/include/internal -I/opt/src/RPM/BUILD/otp_src_R14B01/erts/include/internal/x86_64-unknown-linux-gnu -I/opt/src/RPM/BUILD/otp_src_R14B01/erts/emulator/sys/unix crypto.c /opt/bcs/bin/install -c -d ../priv/lib/x86_64-unknown-linux-gnu /opt/bcs/bin/gcc -Xlinker -rpath -Xlinker /opt/bcs/lib -Xlinker -L/opt/bcs/lib -Xlinker -rpath -Xlinker /opt/bcs/lib64 -Xlinker -L/opt/bcs/lib64 -shared -Wl,-Bsymbolic -o ../priv/lib/x86_64-unknown-linux-gnu/crypto.so ../priv/obj/x86_64-unknown-linux-gnu/crypto.o -Wl,-R/opt/bcs/packages/openssl/lib -Wl,-R/opt/bcs/lib64 -L/opt/bcs/packages/openssl/lib -lcrypto -------------- next part -------------- An HTML attachment was scrubbed... URL: From icarus.alive@REDACTED Mon Apr 25 17:44:25 2011 From: icarus.alive@REDACTED (Icarus Alive) Date: Mon, 25 Apr 2011 21:14:25 +0530 Subject: [erlang-questions] Spawnfest: a 48 hour programming contest featuring Erlang In-Reply-To: References: Message-ID: On Thu, Apr 14, 2011 at 3:21 AM, Bob Ippolito wrote: > > >If you haven't seen it yet, there's a great video about Spawnfest > here: http://vimeo.com/22360540 > > Laughter cramps material. Don't skip until @2:45. Gotta admit that I could relate more to the brown-bear and "delusional enthusiasm". -------------- next part -------------- An HTML attachment was scrubbed... URL: From koenigjm@REDACTED Mon Apr 25 18:01:39 2011 From: koenigjm@REDACTED (John Koenig) Date: Mon, 25 Apr 2011 11:01:39 -0500 Subject: [erlang-questions] C Node Communication Over Localhost Message-ID: <4DB59AE3.70209@acalledshot.org> I have experienced an issue on newer versions of Ubuntu Desktop (10.04 and later) when trying to send messages from an erlang VM to a C node which is using ei. My procedure is as follows (shadow is the hostname of the machine I am currently testing on): 1) Start an erlang VM (thus starting empd in the process): erl -sname test@REDACTED -setcookie dev 2) Start the C node, in this case the C node will bind to localhost:30000 with a published name of "cnode" using "dev" as its secret cookie: ./my_cnode -P 30000 -N cnode -S dev 3) Attempt to send a message from erlang to C Node: {any, cnode@REDACTED} ! {call, self(), {echo}}. Step 3 results in the following error: Error in process <0.43.0> on node 'test@REDACTED' with exit value: {badarg,[{erlang,list_to_existing_atom,["cnode@REDACTED"]},{dist_util,recv_challenge,1},{dist_util,handshake_we_started,1}]} My /etc/hosts file contains: 127.0.0.1 localhost 127.0.1.1 shadow # The following lines are desirable for IPv6 capable hosts ::1 ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters If I change the 127.0.0.1 entry to "127.0.0.1 localhost shadow" and comment out the second line, then communication between the VM and C node succeeds. What is happening here? Is there a way to achieve communication over localhost without having to change /etc/hosts? Thanks in advance, John -------------- next part -------------- An HTML attachment was scrubbed... URL: From bbethke@REDACTED Mon Apr 25 18:09:11 2011 From: bbethke@REDACTED (bbethke) Date: Mon, 25 Apr 2011 09:09:11 -0700 (PDT) Subject: [erlang-questions] Compressing messages sent between Erlang nodes Message-ID: <1303747751685-3473464.post@n4.nabble.com> Hello, I am writing a distributed Erlang application where several nodes are connected via a network with limited bandwidth. Thus, I would like to be able to minimize the size of the packets sent across the network when processes on different nodes send each other messages. >From http://www.erlang.org/doc/apps/erts/erl_ext_dist.html, I understand that the Erlang distribution mechanism uses erlang:term_to_binary/1,2 internally to convert Erlang messages to the external binary format that is sent over the network. Now, term_to_binary/2 supports several options that are useful for reducing the size of the binaries (http://www.erlang.org/doc/man/erlang.html#term_to_binary-1), including a compression option as well as the ability to choose a minor version with more efficient encoding of floats. I would like to be able to tell the distribution mechanism to use both of these options every time it sends a message over the network. In other words, I would like to be able to specify the Options list that the distribution mechanism calls term_to_binary with. However, I have not been able to find any documentation on this subject. Is this possible to do? Thanks for your help! :) -- View this message in context: http://erlang.2086793.n4.nabble.com/Compressing-messages-sent-between-Erlang-nodes-tp3473464p3473464.html Sent from the Erlang Questions mailing list archive at Nabble.com. From pmorreale@REDACTED Mon Apr 25 18:10:57 2011 From: pmorreale@REDACTED (Peter W. Morreale) Date: Mon, 25 Apr 2011 10:10:57 -0600 Subject: [erlang-questions] public_key usage... Message-ID: <1303747857.26286.16.camel@hermosa.morreale.net> Does anyone have some example code showing usage of public_key:sign and public_key:verify()? I'm having a very difficult time getting the following to work: Cert2 = "-----BEGIN CERTIFICATE-----\nMIIB8TCCAVqgAwIBAgIFAIxwZnIwDQYJKoZIhvcNAQEEBQAwLjELMAkGA1UEBhMCREUxEjAQBgNVBAoTCVNTT0NpcmNsZTELMAkGA1UEAxMCQ0EwHhcNMDkwMjIyMTUwNDI0WhcNMTEwNTIyMTUwNDI0WjBLMQswCQYDVQQGEwJERTESMBAGA1UEChMJU1NPQ2lyY2xlMQwwCgYDVQQLEwNpZHAxGjAYBgNVBAMTEWlkcC5zc29jaXJjbGUuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCbzDRkudC/aC2gMqRVVaLdPJJEwpFB4o71fR5bnNd2ocnnNzJ/W9CoCargzKx+EJ4Nm3vWmX/IZRCFvrvy9C78fP1cmt6Sa091K9luaMAyWn7oC8h/YBXH7rB42tdvWLY4Kl9VJy6UCclvasyrfKx+SR4KU6zCsM622Kvp5wW67QIDAQABMA0GCSqGSIb3DQEBBAUAA4GBAGyaydfJHDkm77C39gq9bBb7OqK8OXEUTbIMp8PDJZzIf9QkpkE7gHGcWctRKi7fNdONulc5kn2K2nbvCGrbWsWQvr/DA0bjkBrK8OeWpRhLe7fl+JUgsErMcDIzRTmjNpZzUZp+WESRHV1j3SIcfY4tJM2uMt4Sc/afVnl5P6wL\n-----END CERTIFICATE-----", Text = "some text", Pb = list_to_binary(Cert2), PemEntries = public_key:pem_decode(Pb), RSAPubKey = public_key:pem_entry_decode(hd(PemEntries)), Msg = list_to_binary(Text), C = public_key:sign(Msg, sha, RSAPubKey), io:fwrite("sign: ~p~n", [C]), I'm generating "escript: exception error: function_clause". Thanks, -PWM -------------- next part -------------- An HTML attachment was scrubbed... URL: From banibrata.dutta@REDACTED Mon Apr 25 18:19:37 2011 From: banibrata.dutta@REDACTED (Banibrata Dutta) Date: Mon, 25 Apr 2011 21:49:37 +0530 Subject: [erlang-questions] public_key usage... In-Reply-To: <1303747857.26286.16.camel@hermosa.morreale.net> References: <1303747857.26286.16.camel@hermosa.morreale.net> Message-ID: On Mon, Apr 25, 2011 at 9:40 PM, Peter W. Morreale wrote: > > Does anyone have some example code showing usage of public_key:sign and > public_key:verify()? > > I'm having a very difficult time getting the following to work: > > Cert2 = "-----BEGIN CERTIFICATE-----\nMIIB8TCCAVqgAwIBAgIFAIxwZnIwDQYJKoZIhvcNAQEEBQAwLjELMAkGA1UEBhMCREUxEjAQBgNVBAoTCVNTT0NpcmNsZTELMAkGA1UEAxMCQ0EwHhcNMDkwMjIyMTUwNDI0WhcNMTEwNTIyMTUwNDI0WjBLMQswCQYDVQQGEwJERTESMBAGA1UEChMJU1NPQ2lyY2xlMQwwCgYDVQQLEwNpZHAxGjAYBgNVBAMTEWlkcC5zc29jaXJjbGUuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCbzDRkudC/aC2gMqRVVaLdPJJEwpFB4o71fR5bnNd2ocnnNzJ/W9CoCargzKx+EJ4Nm3vWmX/IZRCFvrvy9C78fP1cmt6Sa091K9luaMAyWn7oC8h/YBXH7rB42tdvWLY4Kl9VJy6UCclvasyrfKx+SR4KU6zCsM622Kvp5wW67QIDAQABMA0GCSqGSIb3DQEBBAUAA4GBAGyaydfJHDkm77C39gq9bBb7OqK8OXEUTbIMp8PDJZzIf9QkpkE7gHGcWctRKi7fNdONulc5kn2K2nbvCGrbWsWQvr/DA0bjkBrK8OeWpRhLe7fl+JUgsErMcDIzRTmjNpZzUZp+WESRHV1j3SIcfY4tJM2uMt4Sc/afVnl5P6wL\n-----END CERTIFICATE-----", > > Text = "some text", > > Pb = list_to_binary(Cert2), > PemEntries = public_key:pem_decode(Pb), > RSAPubKey = public_key:pem_entry_decode(hd(PemEntries)), > > Msg = list_to_binary(Text), > C = public_key:sign(Msg, sha, RSAPubKey), > io:fwrite("sign: ~p~n", [C]), > > > > > I'm generating "escript: exception error: function_clause". > No first hand experience but since I'd like to do something like this shortly, looked around and found this thread: http://erlang.org/pipermail/erlang-questions/2011-January/055880.html Does that help ? -------------- next part -------------- An HTML attachment was scrubbed... URL: From icarus.alive@REDACTED Mon Apr 25 18:43:13 2011 From: icarus.alive@REDACTED (Icarus Alive) Date: Mon, 25 Apr 2011 22:13:13 +0530 Subject: [erlang-questions] C Node Communication Over Localhost In-Reply-To: <4DB59AE3.70209@acalledshot.org> References: <4DB59AE3.70209@acalledshot.org> Message-ID: On Mon, Apr 25, 2011 at 9:31 PM, John Koenig wrote: > I have experienced an issue on newer versions of Ubuntu Desktop (10.04 and > later) when trying to send messages from an erlang VM to a C node which is > using ei. My procedure is as follows (shadow is the hostname of the machine > I am currently testing on): > > 1) Start an erlang VM (thus starting empd in the process): erl -sname > test@REDACTED -setcookie dev > > 2) Start the C node, in this case the C node will bind to localhost:30000 > with a published name of "cnode" using "dev" as its secret cookie: > ./my_cnode -P 30000 -N cnode -S dev > > 3) Attempt to send a message from erlang to C Node: {any, cnode@REDACTED} > ! {call, self(), {echo}}. > > Step 3 results in the following error: > > Error in process <0.43.0> on node 'test@REDACTED' with exit value: > {badarg,[{erlang,list_to_existing_atom,["cnode@REDACTED > "]},{dist_util,recv_challenge,1},{dist_util,handshake_we_started,1}]} > > My /etc/hosts file contains: > > 127.0.0.1 localhost > 127.0.1.1 shadow > > # The following lines are desirable for IPv6 capable hosts > ::1 ip6-localhost ip6-loopback > fe00::0 ip6-localnet > ff00::0 ip6-mcastprefix > ff02::1 ip6-allnodes > ff02::2 ip6-allrouters > > If I change the 127.0.0.1 entry to "127.0.0.1 localhost shadow" and comment > out the second line, then communication between the VM and C node succeeds. > What is happening here? Is there a way to achieve communication over > localhost without having to change /etc/hosts? > Can you ping "shadow" while it is associated to the IP 127.0.1.1 ? If you've blocked ICMP echo in kernel, enable it temporarily and test. If ping works, try to write a small program to do a reverse name-resolution in C and see if it works. -------------- next part -------------- An HTML attachment was scrubbed... URL: From pmorreale@REDACTED Mon Apr 25 19:51:50 2011 From: pmorreale@REDACTED (Peter W. Morreale) Date: Mon, 25 Apr 2011 11:51:50 -0600 Subject: [erlang-questions] public_key usage... In-Reply-To: References: <1303747857.26286.16.camel@hermosa.morreale.net> Message-ID: <1303753910.26286.26.camel@hermosa.morreale.net> On Mon, 2011-04-25 at 21:49 +0530, Banibrata Dutta wrote: > On Mon, Apr 25, 2011 at 9:40 PM, Peter W. Morreale > wrote: > > Does anyone have some example code showing usage of > public_key:sign and public_key:verify()? > > I'm having a very difficult time getting the following to > work: > Cert2 = "-----BEGIN CERTIFICATE-----\nMIIB8TCCAVqgAwIBAgIFAIxwZnIwDQYJKoZIhvcNAQEEBQAwLjELMAkGA1UEBhMCREUxEjAQBgNVBAoTCVNTT0NpcmNsZTELMAkGA1UEAxMCQ0EwHhcNMDkwMjIyMTUwNDI0WhcNMTEwNTIyMTUwNDI0WjBLMQswCQYDVQQGEwJERTESMBAGA1UEChMJU1NPQ2lyY2xlMQwwCgYDVQQLEwNpZHAxGjAYBgNVBAMTEWlkcC5zc29jaXJjbGUuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCbzDRkudC/aC2gMqRVVaLdPJJEwpFB4o71fR5bnNd2ocnnNzJ/W9CoCargzKx+EJ4Nm3vWmX/IZRCFvrvy9C78fP1cmt6Sa091K9luaMAyWn7oC8h/YBXH7rB42tdvWLY4Kl9VJy6UCclvasyrfKx+SR4KU6zCsM622Kvp5wW67QIDAQABMA0GCSqGSIb3DQEBBAUAA4GBAGyaydfJHDkm77C39gq9bBb7OqK8OXEUTbIMp8PDJZzIf9QkpkE7gHGcWctRKi7fNdONulc5kn2K2nbvCGrbWsWQvr/DA0bjkBrK8OeWpRhLe7fl+JUgsErMcDIzRTmjNpZzUZp+WESRHV1j3SIcfY4tJM2uMt4Sc/afVnl5P6wL\n-----END CERTIFICATE-----", > > Text = "some text", > > Pb = list_to_binary(Cert2), > PemEntries = public_key:pem_decode(Pb), > RSAPubKey = public_key:pem_entry_decode(hd(PemEntries)), > > Msg = list_to_binary(Text), > C = public_key:sign(Msg, sha, RSAPubKey), > io:fwrite("sign: ~p~n", [C]), > > > > I'm generating "escript: exception error: function_clause". > > > No first hand experience but since I'd like to do something like this > shortly, looked around and found this thread: > http://erlang.org/pipermail/erlang-questions/2011-January/055880.html > Does that help ? > A little, but only in the sense that I should be using public_key:[d| e]ncrypt_public(). If I replace public_key:sign() with: C = public_key:encrypt_public(Msg, RSAPubKey), I get similar results. Thanks -PWM From torben.lehoff@REDACTED Mon Apr 25 20:58:58 2011 From: torben.lehoff@REDACTED (Torben Hoffmann) Date: Mon, 25 Apr 2011 20:58:58 +0200 Subject: [erlang-questions] The gen server simplified (how it works) In-Reply-To: References: <70CD76DB-0CB6-4934-8AD7-1F04BC71691D@hates.ms> Message-ID: On Thu, Apr 21, 2011 at 12:08, Jeroen Koops wrote: > > > On Wed, Apr 20, 2011 at 11:44 PM, Torben Hoffmann > wrote: > >> >> >> On Wed, Apr 20, 2011 at 15:09, Jeroen Koops wrote: >> >>> >>>> The most common form of gen _server abuse I have seen (and I plead >>>> guilty of it myself) is attempting to turn it into something akin to a state >>>> machine. My rule of thumb is if your state record contains a field called >>>> state or something like it and you take different actions based on it, then >>>> it's time to re-factor into a gen_fsm. It's easy to get into this situation >>>> since things usually start simple and build up once more functionality is >>>> piled on. >>>> >>>> >>> I don't know about this -- I have written numerous gen_servers whose >>> state-record include a state-field (although I usually call it 'current'), >>> and events (calls, casts, infos) are handled differently depending on its >>> value. The reason for not using a gen_fsm is that very often, an event >>> should be handled in one way in one particular state, and in another way in >>> _all_ other states. This is easy to do using pattern-matching when using a >>> gen_server, but when using a gen_fsm you have no choice but to write out >>> every state/event combination, which can become pretty cumbersome. >>> >> >> Then one can use an gen_fsm:send_all_state_event/2 and pattern match on >> both state and state date that in the modules handle_event/3 function. >> I have done that many times and it works rather well. >> >> Of course, but when you do that for the majority of the events it amounts > to the same as using a gen_server with a 'state'-field, doesn't it? > > Well, yes and no. In terms of code evolution I feel that you risk being stuck with gen_server when gen_fsm would be the right choice. Even if most of your events are send_all_state_event's you do gain more information with gen_fsm due to the structure of the callback functions. I have exploited that to create a little program that can produce a CSP description of a gen_fsm, which is good for communication with people who have a hard time reading Erlang code. I think it would have been harder to write that program using the gen_server + state approach, but that is guess work! (The program was very specific to the code style we used, so there is nothing to share.) My experience is probably also tainted by the fact that I have mostly implemented telecom protocols and they fit best with gen_fsm and have only a few all state events. Cheers, Torben -- http://www.linkedin.com/in/torbenhoffmann -------------- next part -------------- An HTML attachment was scrubbed... URL: From koenigjm@REDACTED Mon Apr 25 21:00:34 2011 From: koenigjm@REDACTED (John Koenig) Date: Mon, 25 Apr 2011 14:00:34 -0500 Subject: [erlang-questions] C Node Communication Over Localhost In-Reply-To: References: <4DB59AE3.70209@acalledshot.org> Message-ID: <4DB5C4D2.50105@acalledshot.org> > Can you ping "shadow" while it is associated to the IP 127.0.1.1 ? > If you've blocked ICMP echo in kernel, enable it temporarily and test. > If ping works, try to write a small program to do a reverse > name-resolution in C and see if it works. Yes, I can ping shadow (127.0.1.1), just by entering "ping shadow" at shadow's command line. My concern with doing a hostname lookup within C and then binding to that address was simply that my design was to have 1 erlang VM communicate with 1 C node over a localhost channel. I was lulling myself into a sense of security by not opening up the C node to a potentially external IP address. For example, network manager in Ubuntu 10.10 prepended a line to /etc/hosts of the form " ". Wouldn't the reverse lookup from within C return an address pointing to in this case? John From torben.lehoff@REDACTED Mon Apr 25 21:28:59 2011 From: torben.lehoff@REDACTED (Torben Hoffmann) Date: Mon, 25 Apr 2011 21:28:59 +0200 Subject: [erlang-questions] Runtime checking for types In-Reply-To: <56A7B5DB-C790-4687-A9CF-92C8452E2D8B@cs.otago.ac.nz> References: <945465586.107521303080710089.JavaMail.root@zimbra> <07054f02-aee1-4baf-85b8-6870782e9e18@dr5g2000vbb.googlegroups.com> <25B0968E-BB32-4107-93FA-61D58EC4130E@cs.otago.ac.nz> <56A7B5DB-C790-4687-A9CF-92C8452E2D8B@cs.otago.ac.nz> Message-ID: On Thu, Apr 21, 2011 at 02:08, Richard O'Keefe wrote: > > On 21/04/2011, at 2:21 AM, Tony Finch wrote: > > > > Sounds like Robert Harper. > > > > > http://existentialtype.wordpress.com/2011/03/19/dynamic-languages-are-static-languages/ > > The question Harper tries very hard to evade there is > > "Are there any usable type systems that are sufficiently expressive?" > > The only type systems he blesses are the ones in ML and Haskell. > As a Haskell programmer, I find ML's type system crippling. (No type > classes? > Relying on ad hoc overloading to deal with + and < ? Feh!) > And there are enough people who find the Haskell type system limiting that > Epigram, Cayenne, and Agda exist. > > Make no mistake, a *good* type system *can* do wonders for you. > See the whole "generic programming" stuff, such as Template Haskell, > and contrast the elegance of QuickCheck in Haskell (driven by the types) > with the clunkier version for Erlang. > > At the high end, type systems trail off into things like PVS, where proving > that a specification is type-correct is a non-trivial exercise. (If anyone > reading this knows PVS and would give me a bit of hand-holding, I'd > _really_ > like to be able to use it; the language is clear enough, but driving the > theorem prover is very far from obvious.) > I used PVS years ago - we started out by proving that quick sort actually sorts a list. That is not as easy to prove as one would assume, but it is a good exercise to start with. Before we dived into PVS we did some pre-study on deduction systems - if you have no prior exposure to that I would suggest spending a day reading up on that. I have gazed at the PVS web page and it seems to be just as hard core and terse as I recall it... not many have .ps and .ps.gz versions of their manuals these days! ;-) I can only offer my advice above since my practical experience with PVS is too dated to be of any use to you. You might also consider Isabelle - one of my university friends did his Ph.D. using Isabelle since it was in some way easier to work with than PVS. I just checked up on it and it seems more modern than PVS. It also does code generation, which is the pinnacle of theoretic computer science: just muddle around in some higher order logic for some time and when you are done you have a program that is correct. I might want to try that out one day, but I do not think the market segment where this can be used and make money is all that big. My friend tried to do formal methods in the industry for a couple of years before giving up to become a "regular" software engineer. On the Isabelle site you will also see SPARK Ada mentioned and that is an interesting approach to creation of correct software. Never used it myself, but it might be fun to try out. Cheers, Torben > > When it comes to writing programs, few things are as straitjackety as > a language that isn't finished yet (Epigram) or one where persuading > the compiler your program makes sense requires manual guidance of a > theorem prover. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -- http://www.linkedin.com/in/torbenhoffmann -------------- next part -------------- An HTML attachment was scrubbed... URL: From dmercer@REDACTED Mon Apr 25 22:52:44 2011 From: dmercer@REDACTED (David Mercer) Date: Mon, 25 Apr 2011 15:52:44 -0500 Subject: [erlang-questions] The gen server simplified (how it works) In-Reply-To: References: Message-ID: <012601cc038a$baea7700$30bf6500$@com> On Wednesday, April 20, 2011, Joe Armstrong wrote: > Many users seem to use the gen_server for absolutely everything > and often force their problems to fit the gen_sever even though the > gen_server is not appropriate for their problems. > > . . . > > This is *why* we made the gen_server abstraction. You can write well-typed > sequential code (the handle_call and init functions) to parametrize > a concurrent behavior, ie you need to know nothing about concurrency to > get the job done. We've "abstracted out" the concurrency. > > Things become problematic when you do not entirely understand the abstraction. > Maybe the abstraction is inappropriate for your needs. I have seen many examples > of code where the gen_server *is* inappropriate. The acid test is "does the > gen_sever code look like spaghetti" if the answer is yes then all you have done > is shoe horn the applications into an inappropriate form. In this case > you should ditch the gen_server and roll-your own. I am not sure what you are advocating in gen_server's stead. Some others on this thread seem to be pushing gen_fsm as the alternative, but I don't think that's what you are arguing, since you have generally preferred lightweight non-OTP processes. Are you arguing for more use of gen_fsm, more creation of roll-your-own OTP-compliant processes using proc_lib and sys, or less reliance on the OTP framework and more use of plain old Erlang? From dmercer@REDACTED Mon Apr 25 22:54:23 2011 From: dmercer@REDACTED (David Mercer) Date: Mon, 25 Apr 2011 15:54:23 -0500 Subject: [erlang-questions] The gen server simplified (how it works) In-Reply-To: <012601cc038a$baea7700$30bf6500$@com> References: <012601cc038a$baea7700$30bf6500$@com> Message-ID: <012701cc038a$f5b10110$e1130330$@com> Also, is anyone else having trouble figuring out who wrote what on this thread? I think some people are not adequately distinguishing between their contributions and the existing thread in their replies. Maybe it's just me... Anyone else? From mihai@REDACTED Mon Apr 25 23:50:43 2011 From: mihai@REDACTED (Mihai Balea) Date: Mon, 25 Apr 2011 17:50:43 -0400 Subject: [erlang-questions] The gen server simplified (how it works) In-Reply-To: <012601cc038a$baea7700$30bf6500$@com> References: <012601cc038a$baea7700$30bf6500$@com> Message-ID: <5300E312-D482-4688-BFEA-035D080FCC95@hates.ms> On Apr 25, 2011, at 4:52 PM, David Mercer wrote: > I am not sure what you are advocating in gen_server's stead. Some others on > this thread seem to be pushing gen_fsm as the alternative, but I don't think > that's what you are arguing, since you have generally preferred lightweight > non-OTP processes. Are you arguing for more use of gen_fsm, more creation > of roll-your-own OTP-compliant processes using proc_lib and sys, or less > reliance on the OTP framework and more use of plain old Erlang? I believe I am the one who brought gen_fsm into this discussion. My intention was to exemplify a particular case of gen_server abuse, one where gen_fsm would have made a lot more sense. I did not intend to suggest that gen_fsm be regarded as a generic alternative to gen_server, but rather that each abstraction has its own domain of applicability. Just thought I'd clear any possible misunderstandings. Mihai From pmorreale@REDACTED Tue Apr 26 00:05:27 2011 From: pmorreale@REDACTED (Peter W. Morreale) Date: Mon, 25 Apr 2011 16:05:27 -0600 Subject: [erlang-questions] public_key usage... In-Reply-To: <1303753910.26286.26.camel@hermosa.morreale.net> References: <1303747857.26286.16.camel@hermosa.morreale.net> <1303753910.26286.26.camel@hermosa.morreale.net> Message-ID: <1303769127.26286.33.camel@hermosa.morreale.net> To be clear - the exception is occurring in public_key:encrypt_public() Printing the output of the key decode seems to indicate that the key is valid. I am really lost here, all input greatly appreciated. Thanks, -PWM On Mon, 2011-04-25 at 11:51 -0600, Peter W. Morreale wrote: > On Mon, 2011-04-25 at 21:49 +0530, Banibrata Dutta wrote: > > On Mon, Apr 25, 2011 at 9:40 PM, Peter W. Morreale > > wrote: > > > > Does anyone have some example code showing usage of > > public_key:sign and public_key:verify()? > > > > I'm having a very difficult time getting the following to > > work: > > Cert2 = "-----BEGIN CERTIFICATE-----\nMIIB8TCCAVqgAwIBAgIFAIxwZnIwDQYJKoZIhvcNAQEEBQAwLjELMAkGA1UEBhMCREUxEjAQBgNVBAoTCVNTT0NpcmNsZTELMAkGA1UEAxMCQ0EwHhcNMDkwMjIyMTUwNDI0WhcNMTEwNTIyMTUwNDI0WjBLMQswCQYDVQQGEwJERTESMBAGA1UEChMJU1NPQ2lyY2xlMQwwCgYDVQQLEwNpZHAxGjAYBgNVBAMTEWlkcC5zc29jaXJjbGUuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCbzDRkudC/aC2gMqRVVaLdPJJEwpFB4o71fR5bnNd2ocnnNzJ/W9CoCargzKx+EJ4Nm3vWmX/IZRCFvrvy9C78fP1cmt6Sa091K9luaMAyWn7oC8h/YBXH7rB42tdvWLY4Kl9VJy6UCclvasyrfKx+SR4KU6zCsM622Kvp5wW67QIDAQABMA0GCSqGSIb3DQEBBAUAA4GBAGyaydfJHDkm77C39gq9bBb7OqK8OXEUTbIMp8PDJZzIf9QkpkE7gHGcWctRKi7fNdONulc5kn2K2nbvCGrbWsWQvr/DA0bjkBrK8OeWpRhLe7fl+JUgsErMcDIzRTmjNpZzUZp+WESRHV1j3SIcfY4tJM2uMt4Sc/afVnl5P6wL\n-----END CERTIFICATE-----", > > > > Text = "some text", > > > > Pb = list_to_binary(Cert2), > > PemEntries = public_key:pem_decode(Pb), > > RSAPubKey = public_key:pem_entry_decode(hd(PemEntries)), > > > > Msg = list_to_binary(Text), > > C = public_key:sign(Msg, sha, RSAPubKey), > > io:fwrite("sign: ~p~n", [C]), > > > > > > > > I'm generating "escript: exception error: function_clause". > > > > > > No first hand experience but since I'd like to do something like this > > shortly, looked around and found this thread: > > http://erlang.org/pipermail/erlang-questions/2011-January/055880.html > > Does that help ? > > > > A little, but only in the sense that I should be using public_key:[d| > e]ncrypt_public(). > > If I replace public_key:sign() with: > > C = public_key:encrypt_public(Msg, RSAPubKey), > > I get similar results. > > Thanks > -PWM > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From jesper.louis.andersen@REDACTED Tue Apr 26 00:36:43 2011 From: jesper.louis.andersen@REDACTED (Jesper Louis Andersen) Date: Tue, 26 Apr 2011 00:36:43 +0200 Subject: [erlang-questions] learner's questions -- tuples, CEAN & jungerl In-Reply-To: References: Message-ID: On Mon, Apr 25, 2011 at 15:27, Icarus Alive wrote: > > In this particular context, do we mean that... > ?{ person, { name, joe }, { age, 42 } } ? ? ? ? ? ? ? -- is boxed > representation, and > ?{ person, joe, 42 } ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?-- is unboxed > repsentation ? > or > ??| $j,$o,$e | 42.0000 | ?(as 32 bytes in memory) -- is unboxed (internal) > representation ? > I.e. what exactly are we calling the boxed / unboxed representation in this > context. When I write "boxed" I mean that we have a pointer to a value cell in the heap somewhere. Unboxed values are then those which we have direct access to. For instance, take {3, 7} as an example There are two obvious representations. One is that we have a tuple {P1, P2} where P1 is a pointer to a cell containing 3 and P2 is a pointer to a cell containing 7. But in this case where the values are small, we could store them directly in the tuple where P1 and P2 are. There are some important decisions to make, like we probably need to use tagged arithmetic on them. But this representation would not have 3 and 7 in a boxes. In short: A box is when we have a pointer to a cell containing X rather than having X directly. Personally, I'd not worry too much about memory usage at the beginning and then later look at it if it became a troubling point. There are so many ways to limit the memory usage for such data that you can often work around it later. What I would do though is to make sure my representation is living in a separate module so it is easy to abstract out later if it became a problem. As for the ETS table storing everything: It depends. If you "get" something from an ETS table it is copied into the heap of the requesting process. So you can't obviously use it for large data unless you intend to operate on them a lot. On the other hand, recent Erlangs optimize concurrent reads to such tables if you set the right option on the table, so you can get some decent speeds from it. In other situations, where no sharing of the data are needed, I usually just keep those in the process that will need the data. If everything fails, you can always write a NIF-interface to a C-representation of the data - where you utilize domain-knowledge to minimize memory usage. But in my opinion that is a card you want to play when it becomes a problem in practice, not before. -- J. From t.greenwoodgeer@REDACTED Tue Apr 26 05:56:20 2011 From: t.greenwoodgeer@REDACTED (Todd) Date: Mon, 25 Apr 2011 20:56:20 -0700 Subject: [erlang-questions] trouble creating releases with rebar, apps exit with 'bad_return' In-Reply-To: References: <4DB4F20B.1080400@gmail.com> Message-ID: <4DB64264.4080805@gmail.com> Mike - Thanks for your suggestions. The create-node instructions are definitely part of the skeptomai tutorial. For any other newbies that run into this, I think the culprit was that I was running R13. I just compiled and installed R14B02 from source, and then ran thru the skeptomai tutorial...works like a charm. So, if you, too, are getting the dread, 'bad_return', make sure you aren't running R13*. -Todd On 4/25/11 1:34 AM, Mike Oxford wrote: > You will need to create a node before you can generate a release. > > create 'rel' directory and cd into it > rebar -v create-node nodeid= > Modify the generated reltool.config file > rebar -v generate > > Subsequent generate calls will need to have "force=1" added to overwrite > the previously generated node. > > After you have a node generated, ex: nodeid=moxnode, then you can launch > with boot scripts... > rel//bin/ start > > Look in Alan's link for ... "To create a release we have to create a new > directory in the root of our project called *rel* and create a node in > it. A node is kind of a standalone Erlang VM for our application to run on." > That looks like what you're missing. > > Another perspective... > https://bitbucket.org/basho/rebar/wiki/ReleaseHandling > > > -mox > > > > On Sun, Apr 24, 2011 at 9:01 PM, Todd > wrote: > > Short version: > When I create a release with rebar, the app dies with 'bad_return'. > > Longer version: > (rebar version: 2 date: 20110420_043817 vcs: git bd1475d) > > 1. I've tried following these two rebar tutorials: > > http://skeptomai.com/?p=56#respond > http://alancastro.org/2010/05/01/erlang-application-management-with-rebar.html > > 2. Following either set of instructions, I can generate a single app > and subsequently compile and launch it in the erl shell: > > rebar create-app > rebar compile > erl -pa ebin > > application:start(myapp). > application:stop(myapp). > > > 3. So far, so good. However, things seem to fall apart in the 'rebar > -v generate' command...but then, I'm not sure what I should be > seeing here: > > user@REDACTED:~/projects/testing-rebar-03/mysample$ rebar -v generate > DEBUG: Rebar location: "/usr/local/bin/rebar" > DEBUG: Entering /home/user/projects/testing-rebar-03/mysample > DEBUG: Available deps: [] > DEBUG: Missing deps : [] > DEBUG: Predirs: ["/home/user/projects/testing-rebar-03/mysample/rel"] > DEBUG: Entering /home/user/projects/testing-rebar-03/mysample/rel > DEBUG: Available deps: [] > DEBUG: Missing deps : [] > DEBUG: Predirs: [] > ==> rel (generate) > DEBUG: Created dir > /home/user/projects/testing-rebar-03/mysample/rel/mysample/log/sasl > INFO: sh info: > cwd: "/home/user/projects/testing-rebar-03/mysample/rel" > cmd: cp -R > /home/user/projects/testing-rebar-03/mysample/rel/files/erl > /home/user/projects/testing-rebar-03/mysample/rel/mysample/erts-5.7.5/bin/erl > opts: [{use_stdout,false},return_on_error] > INFO: sh info: > cwd: "/home/user/projects/testing-rebar-03/mysample/rel" > cmd: cp -R > /home/user/projects/testing-rebar-03/mysample/rel/files/nodetool > /home/user/projects/testing-rebar-03/mysample/rel/mysample/erts-5.7.5/bin/nodetool > opts: [{use_stdout,false},return_on_error] > INFO: sh info: > cwd: "/home/user/projects/testing-rebar-03/mysample/rel" > cmd: cp -R > /home/user/projects/testing-rebar-03/mysample/rel/files/mysample > /home/user/projects/testing-rebar-03/mysample/rel/mysample/bin/mysample > opts: [{use_stdout,false},return_on_error] > INFO: sh info: > cwd: "/home/user/projects/testing-rebar-03/mysample/rel" > cmd: cp -R > /home/user/projects/testing-rebar-03/mysample/rel/files/app.config > /home/user/projects/testing-rebar-03/mysample/rel/mysample/etc/app.config > opts: [{use_stdout,false},return_on_error] > INFO: sh info: > cwd: "/home/user/projects/testing-rebar-03/mysample/rel" > cmd: cp -R > /home/user/projects/testing-rebar-03/mysample/rel/files/vm.args > /home/user/projects/testing-rebar-03/mysample/rel/mysample/etc/vm.args > opts: [{use_stdout,false},return_on_error] > DEBUG: Postdirs: [] > WARN: 'generate' command does not apply to directory > /home/user/projects/testing-rebar-03/mysample > DEBUG: Postdirs: [] > > 4. However, the true error shows when I try to start the rebar > created app: > > user@REDACTED:~/projects/testing-rebar-01$ sh rel/mynode/bin/mynode > console > Exec: > /home/user/projects/testing-rebar-01/rel/mynode/erts-5.7.5/bin/erlexec > -boot > /home/user/projects/testing-rebar-01/rel/mynode/releases/1/mynode > -embedded -config > /home/user/projects/testing-rebar-01/rel/mynode/etc/app.config > -args_file > /home/user/projects/testing-rebar-01/rel/mynode/etc/vm.args -- console > Root: /home/user/projects/testing-rebar-01/rel/mynode > Erlang R13B04 (erts-5.7.5) [source] [rq:1] [async-threads:5] > [kernel-poll:true] > > > =INFO REPORT==== 19-Apr-2011::22:51:20 === > application: myapp > exited: {bad_return, > {{myapp_app,start,[normal,[]]}, > {'EXIT', > {undef, > [{myapp_app,start,[normal,[]]}, > {application_master,start_it_old,4}]}}}} > type: permanent > {"Kernel pid > terminated",application_controller,"{application_start_failure,myapp,{bad_return,{{myapp_app,start,[normal,[]]},{'EXIT',{undef,[{myapp_app,start,[normal,[]]},{application_master,start_it_old,4}]}}}}}"} > > Crash dump was written to: erl_crash.dump > Kernel pid terminated (application_controller) > ({application_start_failure,myapp,{bad_return,{{myapp_app,start,[normal,[]]},{'EXIT',{undef,[{myapp_app,start,[normal,[]]},{application_master,start_it > > > 5. I have tried creating and releasing apps via rebar using both > sets of instructions, on both mac os x, and linux, multiple times... > and in all cases, I've run into the 'bad_return' when attempting to > start the app. > > 6. I see that this question has been raised before: > > https://groups.google.com/group/erlang-programming/browse_thread/thread/47961ad971086582 > > 5. And the idea was that the app wasn't being compiled (or the > compiled files couldn't be found). Well, I can see the app being > compiled here: > > user@REDACTED:~/projects/testing-rebar-01$ rebar compile > ==> myapp (compile) > ==> rel (compile) > ==> testing-rebar-01 (compile) > > 6. And when I generate the release, it's all new: > > user@REDACTED:~/projects/testing-rebar-01$ rm -rf rel/mynode/ && > rebar generate && sh rel/mynode/bin/mynode console > > 7. However, the generated release looks suspicious... for one thing, > my app files are not in the release dir: > > user@REDACTED:~/projects/testing-rebar-01$ find . | grep myapp > ./apps/myapp > ./apps/myapp/src > ./apps/myapp/src/myapp_app.erl > ./apps/myapp/src/myapp.app.src > ./apps/myapp/src/myapp_sup.erl > ./apps/myapp/ebin > ./apps/myapp/ebin/myapp_app.beam > ./apps/myapp/ebin/myapp_sup.beam > ./apps/myapp/ebin/myapp.app > > > 8. For another thing, my app beam files are not in the release dir, > either: > > user@REDACTED:~/projects/testing-rebar-01$ find . | grep beam > ./apps/myapp/ebin/myapp_app.beam > ./apps/myapp/ebin/myapp_sup.beam > ./rel/mynode/erts-5.7.5/bin/beam.smp > ./rel/mynode/erts-5.7.5/bin/beam > > 9. Could someone show me what's supposed to be generated from the > rebar generate command? Specifically, what files do I need to look > at to verify that my application files have properly compiled into > the release? > > 10. Also, any hints as to how one should approach this sort of > problem, debugging hints, etc. are always appreciated. > > > ---------------- > files > ---------------- > user@REDACTED:~/projects/testing-rebar-01$ cat rebar.config > {sub_dirs, ["apps/myapp", "rel"]}. > user@REDACTED:~/projects/testing-rebar-01$ cat rel/reltool.config > {sys, [ > {lib_dirs, ["../apps"]}, > {rel, "mynode", "1", > [ > myapp, > kernel, > stdlib, > sasl > ]}, > {rel, "start_clean", "", > [ > kernel, > stdlib > ]}, > {boot_rel, "mynode"}, > {profile, embedded}, > {excl_sys_filters, ["^bin/.*", > "^erts.*/bin/(dialyzer|typer)"]}, > {app, sasl, [{incl_cond, include}]} > ]}. > > {target_dir, "mynode"}. > > {overlay, [ > {mkdir, "log/sasl"}, > {copy, "files/erl", "\{\{erts_vsn\}\}/bin/erl"}, > {copy, "files/nodetool", "\{\{erts_vsn\}\}/bin/nodetool"}, > {copy, "files/mynode", "bin/mynode"}, > {copy, "files/app.config", "etc/app.config"}, > {copy, "files/vm.args", "etc/vm.args"} > ]}. > > > Thanks, > > -Todd > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > From jesper.pettersson@REDACTED Tue Apr 26 08:27:27 2011 From: jesper.pettersson@REDACTED (Jesper Pettersson) Date: Tue, 26 Apr 2011 08:27:27 +0200 Subject: [erlang-questions] public_key usage... In-Reply-To: <1303769127.26286.33.camel@hermosa.morreale.net> References: <1303747857.26286.16.camel@hermosa.morreale.net> <1303753910.26286.26.camel@hermosa.morreale.net> <1303769127.26286.33.camel@hermosa.morreale.net> Message-ID: On Tue, Apr 26, 2011 at 12:05 AM, Peter W. Morreale wrote: > > I'm having a very difficult time getting the following to > > work: > > Cert2 = "-----BEGIN > CERTIFICATE-----\nMIIB8TCCAVqgAwIBAgIFAIxwZnIwDQYJKoZIhvcNAQEEBQAwLjELMAkGA1UEBhMCREUxEjAQBgNVBAoTCVNTT0NpcmNsZTELMAkGA1UEAxMCQ0EwHhcNMDkwMjIyMTUwNDI0WhcNMTEwNTIyMTUwNDI0WjBLMQswCQYDVQQGEwJERTESMBAGA1UEChMJU1NPQ2lyY2xlMQwwCgYDVQQLEwNpZHAxGjAYBgNVBAMTEWlkcC5zc29jaXJjbGUuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCbzDRkudC/aC2gMqRVVaLdPJJEwpFB4o71fR5bnNd2ocnnNzJ/W9CoCargzKx+EJ4Nm3vWmX/IZRCFvrvy9C78fP1cmt6Sa091K9luaMAyWn7oC8h/YBXH7rB42tdvWLY4Kl9VJy6UCclvasyrfKx+SR4KU6zCsM622Kvp5wW67QIDAQABMA0GCSqGSIb3DQEBBAUAA4GBAGyaydfJHDkm77C39gq9bBb7OqK8OXEUTbIMp8PDJZzIf9QkpkE7gHGcWctRKi7fNdONulc5kn2K2nbvCGrbWsWQvr/DA0bjkBrK8OeWpRhLe7fl+JUgsErMcDIzRTmjNpZzUZp+WESRHV1j3SIcfY4tJM2uMt4Sc/afVnl5P6wL\n-----END > CERTIFICATE-----", > > > > Text = "some text", > > > > Pb = list_to_binary(Cert2), > > PemEntries = public_key:pem_decode(Pb), > > RSAPubKey = public_key:pem_entry_decode(hd(PemEntries)), > > > > Msg = list_to_binary(Text), > > C = public_key:sign(Msg, sha, RSAPubKey), > > io:fwrite("sign: ~p~n", [C]), > > > > I'm generating "escript: exception error: function_clause". > First of all, the documentation of public_key:sign/3 found at http://www.erlang.org/doc/man/public_key.html#sign-3 is wrong. You should always sign with a private key so that every holder of your public key can verify the signature. The source code of public_key is correct though. There the type for signing is private_key(). Secondly, your variable RSAPubKey is a 'Certificate' record containing the public key data. The public_key:sign/3 function requires a 'RSAPrivateKey' or a 'DSAPrivateKey' record as its third argument. This is why you get your function_clause error. -- Jesper Pettersson Klarna AB -------------- next part -------------- An HTML attachment was scrubbed... URL: From ingela@REDACTED Tue Apr 26 08:53:42 2011 From: ingela@REDACTED (Ingela Andin) Date: Tue, 26 Apr 2011 08:53:42 +0200 Subject: [erlang-questions] public_key usage... In-Reply-To: References: <1303747857.26286.16.camel@hermosa.morreale.net> <1303753910.26286.26.camel@hermosa.morreale.net> <1303769127.26286.33.camel@hermosa.morreale.net> Message-ID: Hi! 2011/4/26 Jesper Pettersson : > On Tue, Apr 26, 2011 at 12:05 AM, Peter W. Morreale > wrote: > >> >> > ? ? ? ? I'm having a very difficult time getting the following to >> > ? ? ? ? work: >> > ? ? ? ? ? ? ? ? Cert2 = "-----BEGIN >> > CERTIFICATE-----\nMIIB8TCCAVqgAwIBAgIFAIxwZnIwDQYJKoZIhvcNAQEEBQAwLjELMAkGA1UEBhMCREUxEjAQBgNVBAoTCVNTT0NpcmNsZTELMAkGA1UEAxMCQ0EwHhcNMDkwMjIyMTUwNDI0WhcNMTEwNTIyMTUwNDI0WjBLMQswCQYDVQQGEwJERTESMBAGA1UEChMJU1NPQ2lyY2xlMQwwCgYDVQQLEwNpZHAxGjAYBgNVBAMTEWlkcC5zc29jaXJjbGUuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCbzDRkudC/aC2gMqRVVaLdPJJEwpFB4o71fR5bnNd2ocnnNzJ/W9CoCargzKx+EJ4Nm3vWmX/IZRCFvrvy9C78fP1cmt6Sa091K9luaMAyWn7oC8h/YBXH7rB42tdvWLY4Kl9VJy6UCclvasyrfKx+SR4KU6zCsM622Kvp5wW67QIDAQABMA0GCSqGSIb3DQEBBAUAA4GBAGyaydfJHDkm77C39gq9bBb7OqK8OXEUTbIMp8PDJZzIf9QkpkE7gHGcWctRKi7fNdONulc5kn2K2nbvCGrbWsWQvr/DA0bjkBrK8OeWpRhLe7fl+JUgsErMcDIzRTmjNpZzUZp+WESRHV1j3SIcfY4tJM2uMt4Sc/afVnl5P6wL\n-----END >> > CERTIFICATE-----", >> > >> > ? ? ? ? ? ? ? ? Text = "some text", >> > >> > ? ? ? ? ? ? ? ? Pb = list_to_binary(Cert2), >> > ? ? ? ? ? ? ? ? PemEntries = public_key:pem_decode(Pb), >> > ? ? ? ? ? ? ? ? RSAPubKey = public_key:pem_entry_decode(hd(PemEntries)), >> > >> > ? ? ? ? ? ? ? ? Msg = list_to_binary(Text), >> > ? ? ? ? ? ? ? ? C = public_key:sign(Msg, sha, RSAPubKey), >> > ? ? ? ? ? ? ? ? io:fwrite("sign: ~p~n", [C]), >> > >> > ? ? ? ? I'm generating "escript: exception error: function_clause". > > First of all, the documentation of public_key:sign/3 found > at?http://www.erlang.org/doc/man/public_key.html#sign-3 is wrong. You should > always sign with a private key so that every holder of your public key can > verify the signature. The source code of public_key is correct though. There > the type for signing is private_key(). Hoops! Yes the documentation is wrong *Blush*, I will correct it. > Secondly, your variable RSAPubKey is a 'Certificate' record containing the > public key data. The public_key:sign/3 function requires a 'RSAPrivateKey' > or a 'DSAPrivateKey' record as its third argument. This is why you get your > function_clause error. To Peter: We plan to put some example use cases in the users guide. For now perhaps the test suite might help you if you need examples. Regards Ingela Erlang/OTP team - Ericsson AB From littlebobbyerlang@REDACTED Tue Apr 26 10:59:54 2011 From: littlebobbyerlang@REDACTED (littlebobby) Date: Tue, 26 Apr 2011 01:59:54 -0700 (PDT) Subject: [erlang-questions] The gen server simplified (how it works) In-Reply-To: References: Message-ID: <1303808394797-3474996.post@n4.nabble.com> Well, It might just be a consequence of peoples uncertainty. When you want to run erlang in production, there is no doubt that you want to take advantage of it's battle tested code (OTP). So it's going to be some behaviour, right? Well let's see, it's neither gen_event nor gen_fsm, so it has to be gen_server. Why is this question even asked? I think it might be because of a lack of good explanations with lots of reasoning pro / contra per approach. How is a person learning about OTP supposed to know the implications of leaving the tested path? Leaving a tested path is generally a bad thing. To do so you should be aware of the consequences (or whether there even are any). People lack the knowledge to gauge the consequences. That knowledge is only gained from experience - which can include writing spaghetti gen_server code and recognizing it as a mess. You have that knowledge and that might make it hard for you to comprehend the impact of uncertainty here. -- View this message in context: http://erlang.2086793.n4.nabble.com/The-gen-server-simplified-how-it-works-tp3462381p3474996.html Sent from the Erlang Questions mailing list archive at Nabble.com. From sverker@REDACTED Tue Apr 26 11:48:52 2011 From: sverker@REDACTED (Sverker Eriksson) Date: Tue, 26 Apr 2011 11:48:52 +0200 Subject: [erlang-questions] About release R14B02 In-Reply-To: References: Message-ID: <4DB69504.9020502@erix.ericsson.se> You will get a better error message in next release if trying to combine hipe and halfword. The only thing I can say for sure about when hipe and halfword will be supported together is that it will not be in next release. It's quite a big job. /Sverker, Erlang/OTP Harsh J wrote: > The compile options issue should be fixed in the next release. > > On Mon, Apr 25, 2011 at 12:19 PM, yaohui wrote: > >> Thanks, but would the next release fix this problem? >> ------------------ Original ------------------ >> From: "Harsh J"; >> Date: Mon, Apr 25, 2011 03:13 PM >> To: "yaohui"; >> Subject: Re: [erlang-questions] About release R14B02 >> >> Not a bug, since halfword can't be used along with HiPE right now. >> See this erlang-bugs@ thread for more information: >> http://erlang.org/pipermail/erlang-bugs/2011-March/002245.html >> >> On Mon, Apr 25, 2011 at 11:56 AM, yaohui wrote: >> >>> I found that HIPE and halfword emulator cann't be used at the same time in >>> 64-bit linux system, when compiling release R14B02 . Is that a bug? >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://erlang.org/mailman/listinfo/erlang-questions >>> >>> >>> >> >> -- >> Harsh J >> http://harshj.com >> >> >> > > > > From spawn.think@REDACTED Tue Apr 26 12:30:14 2011 From: spawn.think@REDACTED (Ahmed Omar) Date: Tue, 26 Apr 2011 12:30:14 +0200 Subject: [erlang-questions] ssl_esock question Message-ID: Hi All, I noticed a situation when ssl_esock process in the OS still owns an open socket, while erlang node doesn't know about it. (It happened PROBABLY after a node restart, but i'm not able to reproduce it yet). is that behavior expected and/or documented anywhere? R13B03 on Linux Debian 5.0.6, 64-bit -- Best Regards, - Ahmed Omar http://nl.linkedin.com/in/adiaa Follow me on twitter @spawn_think -------------- next part -------------- An HTML attachment was scrubbed... URL: From kenji.rikitake@REDACTED Tue Apr 26 09:06:09 2011 From: kenji.rikitake@REDACTED (Kenji Rikitake) Date: Tue, 26 Apr 2011 16:06:09 +0900 Subject: [erlang-questions] Ubuntu, Erlang, and Laptop Questions In-Reply-To: References: <1581724946.1474175.1303391873389.JavaMail.root@sz0166a.westchester.pa.mail.comcast.net> Message-ID: <20110426070609.GB50485@k2r.org> +1. Asus AspireOne 150 also works just alright on Ubuntu, Windows XP, and FreeBSD. Kenji Rikitake ++> Des Small [2011-04-22 08:13:56 +0200]: > On Thu, 21 Apr 2011, Eric Merritt wrote: > > >Any laptop just about will work. I would suggest you go with something > >that has multiple cores so you get true concurrency off the bat. Just > >about every laptop has that now though. > > At the bottom end, I have had occasion to use Erlang on my Asus eee > netbook with 1 Gb of RAM and a single-core Atom processor. (You can > get these for under EUR 200 these days.) > > It isn't very fast and I'm very glad it isn't my main development > environment, but it does work OK and it fits neatly into my > handluggage for flights. > > Cheers, > > Des > -- > Des Small, > Scientific Programmer, JIVE > Contact details on http://www.jive.nl/~small From kenji.rikitake@REDACTED Tue Apr 26 08:57:58 2011 From: kenji.rikitake@REDACTED (Kenji Rikitake) Date: Tue, 26 Apr 2011 15:57:58 +0900 Subject: [erlang-questions] RNG (Random Number Generator) used in Erlang SSL module In-Reply-To: References: Message-ID: <20110426065758.GA50485@k2r.org> ++> Kaiduan Xie [2011-04-15 23:14:00 -0400]: > I am wondering what is the RNG used in Erlang SSL module. What is the > performance? I am investigating to see if a server can accept 1M TLS > connections in 15 minutes. Someone reminded me that RNG may be the > issue. What do you think? Please share your experience, and idea. For keeping the keys secure crypto:rand_bytes/1 (or even crypto:strong_rand_bytes/1 in a recent "dev" branch of Erlang GitHub repository (I presume it for R14B03)) is the only selection, and it will lead to use /dev/random on UNIX variants. FYI Kenji Rikitake From nick@REDACTED Tue Apr 26 13:10:52 2011 From: nick@REDACTED (Niclas Eklund) Date: Tue, 26 Apr 2011 13:10:52 +0200 Subject: [erlang-questions] RNG (Random Number Generator) used in Erlang SSL module In-Reply-To: <20110426065758.GA50485@k2r.org> References: <20110426065758.GA50485@k2r.org> Message-ID: On Tue, 26 Apr 2011, Kenji Rikitake wrote: > ++> Kaiduan Xie [2011-04-15 23:14:00 -0400]: >> I am wondering what is the RNG used in Erlang SSL module. What is the >> performance? I am investigating to see if a server can accept 1M TLS >> connections in 15 minutes. Someone reminded me that RNG may be the >> issue. What do you think? Please share your experience, and idea. > > For keeping the keys secure crypto:rand_bytes/1 > (or even crypto:strong_rand_bytes/1 in a recent "dev" branch of > Erlang GitHub repository (I presume it for R14B03)) > is the only selection, and it will lead to use /dev/random on > UNIX variants. > > FYI > Kenji Rikitake Yes, the strengthened random number generation will be included in R14B03. The commit Kenji is mentioning can be found here - https://github.com/erlang/otp/commit/f228601de45c5b53241b103af6616453c50885a5 Best Regards, Niclas @ Erlang/OTP From alexey.v.romanov@REDACTED Tue Apr 26 13:12:59 2011 From: alexey.v.romanov@REDACTED (Alexey Romanov) Date: Tue, 26 Apr 2011 15:12:59 +0400 Subject: [erlang-questions] Failing to build valgrind-enabled system Message-ID: I am trying to build a debug-enabled system (more specifically, valgrind-enabled) from the R14B02 source download on Ubuntu 9.10 following http://www.erlang.org/documentation/doc-5.8/doc/installation_guide/INSTALL.html#id2267570. ./configure make make install works fine. However, then I get ~/otp_src/otp_src_R14B02$ pushd erts/emulator/ ~/otp_src/otp_src_R14B02/erts/emulator ~/otp_src/otp_src_R14B02 ~/otp_src/otp_src_R14B02/erts/emulator$ make valgrind flavor=smp Makefile:23: /make/run_make.mk: No such file or directory make: *** No rule to make target `/make/run_make.mk'. Stop. Same if I do `make debug`, `gprof`, etc. or `flavor=plain`. Any ideas? Yours, Alexey Romanov From pmorreale@REDACTED Tue Apr 26 13:54:02 2011 From: pmorreale@REDACTED (Peter W. Morreale) Date: Tue, 26 Apr 2011 05:54:02 -0600 Subject: [erlang-questions] public_key usage... In-Reply-To: References: <1303747857.26286.16.camel@hermosa.morreale.net> <1303753910.26286.26.camel@hermosa.morreale.net> <1303769127.26286.33.camel@hermosa.morreale.net> Message-ID: <1303818842.26286.54.camel@hermosa.morreale.net> On Tue, 2011-04-26 at 08:53 +0200, Ingela Andin wrote: > > To Peter: We plan to put some example use cases in the users guide. > For now perhaps the test suite might help you if you need examples. > > Regards Ingela Erlang/OTP team - Ericsson AB Excellent! I *love* examples. ;-) Where do I get the current set? THanks, -PWM From dsc@REDACTED Tue Apr 26 14:31:05 2011 From: dsc@REDACTED (Dave Challis) Date: Tue, 26 Apr 2011 13:31:05 +0100 Subject: [erlang-questions] Looking for some advice on mnesia with multi-column indexes References: <4DB6BB09.2000802@ecs.soton.ac.uk> Message-ID: I'm wondering what's the best way (or at least what some of the considerations are) when dealing with indexes across multiple fields of a table. Assuming I've got a record to store in mnesia, which looks something like: -record(foo, {id, a, b}). which might contain: #foo{id=1, a="A", b="B"}. I can create an index on the 'a' or 'b' fields when I create an mnesia table, but what about creating an index on the two combined? I could create a new record/table structure which looks like: -record(foo, {id, a, b, a_and_b}). which might contain: #foo{id=1, a="A", b="B", a_and_b={"A", "B"}}. Or, I could create an additional table to hold the indexes: -record(foo_ab_index, {a_and_b, id}). containing: #foo_ab_index{a_and_b={"A", "B"}, id=1}. Or is there some other pattern/practice I should be looking at instead? It feels wrong to store the same value in multiple places (especially if 'a' or 'b' contain large chunks of data), but that could just be my SQL background kicking in. Cheers, -- Dave Challis dsc@REDACTED From ingela@REDACTED Tue Apr 26 14:56:59 2011 From: ingela@REDACTED (Ingela Anderton Andin) Date: Tue, 26 Apr 2011 14:56:59 +0200 Subject: [erlang-questions] public_key usage... In-Reply-To: <1303818842.26286.54.camel@hermosa.morreale.net> References: <1303747857.26286.16.camel@hermosa.morreale.net> <1303753910.26286.26.camel@hermosa.morreale.net> <1303769127.26286.33.camel@hermosa.morreale.net> <1303818842.26286.54.camel@hermosa.morreale.net> Message-ID: <4DB6C11B.6000403@erix.ericsson.se> Hi Peter! At github in the public_key test directory. *otp * / lib / public_key / test Regards Ingela Erlang/OTP team - Ericsson AB Peter W. Morreale wrote: > On Tue, 2011-04-26 at 08:53 +0200, Ingela Andin wrote: > > >> To Peter: We plan to put some example use cases in the users guide. >> For now perhaps the test suite might help you if you need examples. >> >> Regards Ingela Erlang/OTP team - Ericsson AB >> > > Excellent! I *love* examples. ;-) > > Where do I get the current set? > > THanks, > -PWM > > From sverker@REDACTED Tue Apr 26 15:02:16 2011 From: sverker@REDACTED (Sverker Eriksson) Date: Tue, 26 Apr 2011 15:02:16 +0200 Subject: [erlang-questions] Is it possible to compile crypto app with _static_ libcrypto In-Reply-To: References: Message-ID: <4DB6C258.8090807@erix.ericsson.se> Option --disable-dynamic-ssl-lib will link crypto with a static libcrypto.a instead of a dynamic libcrypto.so. But crypto itself (crypto.so) is still a dynamic library loaded by the emulator. I think the problem is with libcrypto.a. It was not built to be part of a dynamic library. I would recommend downloading openssl and rebuild it yourself. /Sverker, Erlang/OTP Ericsson Maxim Treskin wrote: > Seems option --disable-dynamic-ssl-lib has no effect for crypto application > in OTP. Bug? > > On 22 April 2011 14:45, Max Lapshin wrote: > > >> I've downloaded debian source package and decided to rebuild it with >> --disable-dynamic-ssl-lib >> >> As a result, I've finished with: >> >> x86_64-linux-gnu-gcc -c -o ../priv/obj/x86_64-pc-linux-gnu/crypto.o >> -Wall -Wstrict-prototypes -Wmissing-prototypes >> -Wdeclaration-after-statement -DUSE_THREADS -D_THREAD_SAFE >> -D_REENTRANT -DPOSIX_THREADS -D_POSIX_THREAD_SAFE_FUNCTIONS -g -O2 >> -fno-strict-aliasing >> -I/var/tmp/erlang/erlang-14.b.2-dfsg/erts/x86_64-pc-linux-gnu >> -fno-tree-copyrename -D_GNU_SOURCE -fPIC -I/usr/include >> -I/var/tmp/erlang/erlang-14.b.2-dfsg/erts/emulator/beam >> -I/var/tmp/erlang/erlang-14.b.2-dfsg/erts/include >> -I/var/tmp/erlang/erlang-14.b.2-dfsg/erts/include/x86_64-pc-linux-gnu >> -I/var/tmp/erlang/erlang-14.b.2-dfsg/erts/include/internal >> >> -I/var/tmp/erlang/erlang-14.b.2-dfsg/erts/include/internal/x86_64-pc-linux-gnu >> -I/var/tmp/erlang/erlang-14.b.2-dfsg/erts/emulator/sys/unix crypto.c >> /usr/bin/install -c -d ../priv/lib/x86_64-pc-linux-gnu >> x86_64-linux-gnu-gcc -shared -Wl,-Bsymbolic -o >> ../priv/lib/x86_64-pc-linux-gnu/crypto.so >> ../priv/obj/x86_64-pc-linux-gnu/crypto.o /usr/lib64/libcrypto.a >> /usr/bin/ld: /usr/lib64/libcrypto.a(cryptlib.o): relocation >> R_X86_64_32 against `OPENSSL_ia32cap_P' can not be used when making a >> shared object; recompile with -fPIC >> /usr/lib64/libcrypto.a: could not read symbols: Bad value >> >> >> >> I want to do it because I want to make release that has no >> dependencies on system packages and libcrypto seems to be the only >> one. >> Or it would be better to copy libcrypto.so to release folder? >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> > > > > > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > From kaiduanx@REDACTED Tue Apr 26 15:43:38 2011 From: kaiduanx@REDACTED (Kaiduan Xie) Date: Tue, 26 Apr 2011 09:43:38 -0400 Subject: [erlang-questions] ssl_esock question In-Reply-To: References: Message-ID: Ahmed, I strongly recommend switching to latest R14B02 for SSL work in Erlang. You are using old SSL. Best regards, /Kaiduan On Tue, Apr 26, 2011 at 6:30 AM, Ahmed Omar wrote: > Hi All, > I noticed a situation when ssl_esock process in the OS still owns an open > socket, while erlang node doesn't know about it. (It happened PROBABLY after > a node restart, but i'm not able to reproduce it yet). > is that behavior expected and/or documented anywhere? > > R13B03 on Linux Debian 5.0.6, 64-bit > -- > Best Regards, > - Ahmed Omar > http://nl.linkedin.com/in/adiaa > Follow me on twitter > @spawn_think > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > From dmercer@REDACTED Tue Apr 26 16:06:05 2011 From: dmercer@REDACTED (David Mercer) Date: Tue, 26 Apr 2011 09:06:05 -0500 Subject: [erlang-questions] The gen server simplified (how it works) In-Reply-To: <012701cc038a$f5b10110$e1130330$@com> References: <012601cc038a$baea7700$30bf6500$@com> <012701cc038a$f5b10110$e1130330$@com> Message-ID: <001401cc041b$168ab940$43a02bc0$@com> Also, why do some people's postings on this list come with a 255-byte attachment names ATT.txt with the following contents? _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://erlang.org/mailman/listinfo/erlang-questions From ulf.wiger@REDACTED Tue Apr 26 17:23:04 2011 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Tue, 26 Apr 2011 17:23:04 +0200 Subject: [erlang-questions] gproc for environment data (Re: Regarding `application:get_env` / `application:set_env` race conditions) In-Reply-To: <03C7C4FE-5B2F-48BD-AFF6-142F8EA5DD47@erlang-solutions.com> References: <03C7C4FE-5B2F-48BD-AFF6-142F8EA5DD47@erlang-solutions.com> Message-ID: On 25 Apr 2011, at 14:55, Ulf Wiger wrote: > I will not present an alternative at this time - although your question gave me an idea. I'll have to think it through a bit first. Ok, so here goes: I have added some functions in gproc (version 0.2.6) for more uniform handling of environment settings: gproc:get_env(Scope, App, Key, Alternatives) https://github.com/esl/gproc/blob/master/doc/gproc.md#get_env-4 checks for a cached value (a global or local gproc property) corresponding to the requested value; if not found, it tries a list of alternatives, including OTP application env vars, os:getenv/1, init:get_argument/1 or even mnesia. Inheriting a parent's, or other process's cached value is also possible. If gproc:get_set_env/4 is used, the result is also cached. There is also a write-through option, gproc:set_env/5, which modifies the cached value *and* the underlying "original" (e.g. app env, os environment, or mnesia). https://github.com/esl/gproc/blob/master/doc/gproc.md#set_env-5 Apart from offering a reasonably uniform and declarative method of fetching environment data, the values are also presented and indexed in a way that simplifies system inspection and debugging. If used consistently, gproc can help notify users of a configuration value that it has changed, simply by calling gproc:send({p,Scope, {gproc_env, App, Key}}, UpdateMessage). according to the principle that processes that rely on static data in non-stop systems, need to be prepared for that data to change over time. BR, Ulf W Ulf Wiger, CTO, Erlang Solutions, Ltd. http://erlang-solutions.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From moxford@REDACTED Tue Apr 26 19:09:46 2011 From: moxford@REDACTED (Mike Oxford) Date: Tue, 26 Apr 2011 10:09:46 -0700 Subject: [erlang-questions] gproc for environment data (Re: Regarding `application:get_env` / `application:set_env` race conditions) In-Reply-To: References: <03C7C4FE-5B2F-48BD-AFF6-142F8EA5DD47@erlang-solutions.com> Message-ID: Mmm, tasty! May I offer one small enhancement idea; an alternative-scoped get_env/4 as an alternative? You could then say have global scopes fall back to local scopes (eg, local only configuration settings) or local scopes fall back to globals (global configuration fallback unless a local is found.) Also, the documentation states: "The last instance will be the one that determines the return value." Is that the last instance defined in "Strategy" or the last instance tried (eg, first instance that matched) ? Thanks for the cool new enhancements! -mox On Tue, Apr 26, 2011 at 8:23 AM, Ulf Wiger wrote: > > On 25 Apr 2011, at 14:55, Ulf Wiger wrote: > > I will not present an alternative at this time - although your question > gave me an idea. I'll have to think it through a bit first. > > > Ok, so here goes: > > I have added some functions in gproc (version 0.2.6) for more uniform > handling of environment settings: > > gproc:get_env(Scope, App, Key, Alternatives) > > https://github.com/esl/gproc/blob/master/doc/gproc.md#get_env-4 > > checks for a cached value (a global or local gproc property) corresponding > to the requested value; if not found, it tries a list of alternatives, > including OTP application env vars, os:getenv/1, init:get_argument/1 or even > mnesia. Inheriting a parent's, or other process's cached value is also > possible. If gproc:get_set_env/4 is used, the result is also cached. > > There is also a write-through option, gproc:set_env/5, which modifies the > cached value *and* the underlying "original" (e.g. app env, os environment, > or mnesia). > > *https://github.com/esl/gproc/blob/master/doc/gproc.md#set_env-5* > > Apart from offering a reasonably uniform and declarative method of fetching > environment data, the values are also presented and indexed in a way that > simplifies system inspection and debugging. If used consistently, gproc can > help notify users of a configuration value that it has changed, simply by > calling > > gproc:send({p,Scope, {gproc_env, App, Key}}, UpdateMessage). > > according to the principle that processes that rely on static data in > non-stop systems, need to be prepared for that data to change over time. > > BR, > Ulf W > > Ulf Wiger, CTO, Erlang Solutions, Ltd. > http://erlang-solutions.com > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From roberto.majadas@REDACTED Tue Apr 26 19:39:39 2011 From: roberto.majadas@REDACTED (Roberto Majadas Lopez) Date: Tue, 26 Apr 2011 19:39:39 +0200 Subject: [erlang-questions] GPL3 - EPL compatibility Message-ID: Hello erlang hackers : I'm planning to develop a erlang program and i want to release it under gpl3 license. i read, in the gnu web page, epl (mpl 1.0 based license) is not compatible with GPL(2/3). In this page http://www.gnu.org/licenses/license-list.html gnu layers explain this ... ---- Mozilla Public License (MPL) This is a free software license which is not a strong copyleft; unlike the X11 license, it has some complex restrictions that make it incompatible with the GNU GPL. That is, a module covered by the GPL and a module covered by the MPL cannot legally be linked together. We urge you not to use the MPL for this reason. However, MPL 1.1 has a provision (section 13) that allows a program (or parts of it) to offer a choice of another license as well. If part of a program allows the GNU GPL as an alternate choice, or any other GPL-compatible license as an alternate choice, that part of the program has a GPL-compatible license. ----- So , if EPL don't have the MPL1.1 section 13 , EPL is not GPL compatible. But, in the other hand, the ejabberd2 license was released under GPL2. So my questions are : * can i release source code under GPL3 or 2 using Erlang? * if i can't do it , can erlang team to consider add the section 13 to the EPL license and make it GPL compatible ? regards Roberto -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf.wiger@REDACTED Tue Apr 26 19:48:47 2011 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Tue, 26 Apr 2011 19:48:47 +0200 Subject: [erlang-questions] gproc for environment data (Re: Regarding `application:get_env` / `application:set_env` race conditions) In-Reply-To: References: <03C7C4FE-5B2F-48BD-AFF6-142F8EA5DD47@erlang-solutions.com> Message-ID: On 26 Apr 2011, at 19:09, Mike Oxford wrote: > Mmm, tasty! > > May I offer one small enhancement idea; an alternative-scoped get_env/4 as an alternative? You could then say have global scopes fall back to local scopes (eg, local only configuration settings) or local scopes fall back to globals (global configuration fallback unless a local is found.) Interesting. I'd have to think about how that works out conceptually. > Also, the documentation states: > "The last instance will be the one that determines the return value." > Is that the last instance defined in "Strategy" or the last instance tried (eg, first instance that matched) ? That was really meant as "The last instance of {default, Value}", but essentially, the return value will be from the first matching instance, or the last default (initially 'undefined') if nothing matches. The 'error' option is of course special, since it triggers an exception immediately when encountered. BR, Ulf W > > Thanks for the cool new enhancements! > > -mox > > > > > On Tue, Apr 26, 2011 at 8:23 AM, Ulf Wiger wrote: > > On 25 Apr 2011, at 14:55, Ulf Wiger wrote: > >> I will not present an alternative at this time - although your question gave me an idea. I'll have to think it through a bit first. > > > Ok, so here goes: > > I have added some functions in gproc (version 0.2.6) for more uniform handling of environment settings: > > gproc:get_env(Scope, App, Key, Alternatives) > > https://github.com/esl/gproc/blob/master/doc/gproc.md#get_env-4 > > checks for a cached value (a global or local gproc property) corresponding to the requested value; if not found, it tries a list of alternatives, including OTP application env vars, os:getenv/1, init:get_argument/1 or even mnesia. Inheriting a parent's, or other process's cached value is also possible. If gproc:get_set_env/4 is used, the result is also cached. > > There is also a write-through option, gproc:set_env/5, which modifies the cached value *and* the underlying "original" (e.g. app env, os environment, or mnesia). > > https://github.com/esl/gproc/blob/master/doc/gproc.md#set_env-5 > > Apart from offering a reasonably uniform and declarative method of fetching environment data, the values are also presented and indexed in a way that simplifies system inspection and debugging. If used consistently, gproc can help notify users of a configuration value that it has changed, simply by calling > > gproc:send({p,Scope, {gproc_env, App, Key}}, UpdateMessage). > > according to the principle that processes that rely on static data in non-stop systems, need to be prepared for that data to change over time. > > BR, > Ulf W > > Ulf Wiger, CTO, Erlang Solutions, Ltd. > http://erlang-solutions.com > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > Ulf Wiger, CTO, Erlang Solutions, Ltd. http://erlang-solutions.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From ciprian.craciun@REDACTED Tue Apr 26 20:32:41 2011 From: ciprian.craciun@REDACTED (Ciprian Dorin Craciun) Date: Tue, 26 Apr 2011 21:32:41 +0300 Subject: [erlang-questions] gproc for environment data (Re: Regarding `application:get_env` / `application:set_env` race conditions) In-Reply-To: References: <03C7C4FE-5B2F-48BD-AFF6-142F8EA5DD47@erlang-solutions.com> Message-ID: On Tue, Apr 26, 2011 at 18:23, Ulf Wiger wrote: > > On 25 Apr 2011, at 14:55, Ulf Wiger wrote: > > I will not present an alternative at this time - although your question gave > me an idea. I'll have to think it through a bit first. > > Ok, so here goes: > I have added some functions in gproc (version 0.2.6) for more uniform > handling of environment settings: Nice, quite feature-full. > gproc:get_env(Scope, App, Key, Alternatives) > https://github.com/esl/gproc/blob/master/doc/gproc.md#get_env-4 > checks for a cached value (a global or local gproc property) corresponding > to the requested value; if not found, it tries a list of alternatives, > including OTP application env vars, os:getenv/1, init:get_argument/1 or even > mnesia. Inheriting a parent's, or other process's cached value is also > possible. If gproc:get_set_env/4 is used, the result is also cached. > There is also a write-through option, gproc:set_env/5, which modifies the > cached value *and* the underlying "original" (e.g. app env, os environment, > or mnesia). Though: it would be nice to be able to specify a generic function to be used to fetch the value, like: ~~~~ SomeFun = fun (Key) -> case <> of <> -> {ok, some_value}; <> -> undefined end end, gproc:get_env (l, some_app, some_key, [app_env, SomeFun, {transform, {erlang, list_to_atom}, os_env}]). ~~~~ * the ability to specify an arbitrary function in the chain (that behaves just like `application:get_env`); * the ability to specify a "transformer" for the value -- for example os_env would return always strings, but I would expect an atom; > https://github.com/esl/gproc/blob/master/doc/gproc.md#set_env-5 > Apart from offering a reasonably uniform and declarative method of fetching > environment data, the values are also presented and indexed in a way that > simplifies system inspection and debugging. If used consistently, gproc can > help notify users of a configuration value that it has changed, simply by > calling > gproc:send({p,Scope, {gproc_env, App, Key}}, UpdateMessage). > according to the principle that processes that rely on static data in > non-stop systems, need to be prepared for that data to change over time. > BR, > Ulf W > Ulf Wiger, CTO, Erlang Solutions, Ltd. > http://erlang-solutions.com Is this message {p, Scope, {gproc_env, ...}} ... sent automatically by the current gproc version? (I've never used gproc, but I've wanted for some time to see what it can offer.) Thanks, Ciprian. From sigmastar@REDACTED Tue Apr 26 20:36:12 2011 From: sigmastar@REDACTED (Jesse Gumm) Date: Tue, 26 Apr 2011 13:36:12 -0500 Subject: [erlang-questions] GPL3 - EPL compatibility In-Reply-To: References: Message-ID: You're free to release a program under any license you want. The EPL pertains to the Erlang language itself, not necessarily to programs written in Erlang. On Tue, Apr 26, 2011 at 12:39 PM, Roberto Majadas Lopez wrote: > Hello erlang hackers : > I'm planning to develop a erlang program and i want to release it under gpl3 > license. > i read, in the gnu web page, epl (mpl 1.0 based license) is not compatible > with GPL(2/3). > In this page http://www.gnu.org/licenses/license-list.html gnu layers > explain this ... > ---- > Mozilla Public License (MPL) > This is a free software license which is not a strong copyleft; unlike the > X11 license, it has some complex restrictions that make it incompatible with > the GNU GPL. That is, a module covered by the GPL and a module covered by > the MPL cannot legally be linked together. We urge you not to use the MPL > for this reason. > However, MPL 1.1 has a provision (section 13) that allows a program (or > parts of it) to offer a choice of another license as well. If part of a > program allows the GNU GPL as an alternate choice, or any other > GPL-compatible license as an alternate choice, that part of the program has > a GPL-compatible license. > ----- > So , if EPL don't have the MPL1.1 section 13 , EPL is not GPL compatible. > But, in the other hand, the ejabberd2 license was released under GPL2. > So my questions are ?: > * can i release source code under GPL3 or 2 using Erlang? > * if i can't do it , can erlang team to consider add the section 13 to the > EPL license and make it GPL compatible ? > regards > Roberto > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -- Jesse Gumm Sigma Star Systems 414.940.4866 gumm@REDACTED http://www.sigma-star.com From ulf.wiger@REDACTED Tue Apr 26 20:39:45 2011 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Tue, 26 Apr 2011 20:39:45 +0200 Subject: [erlang-questions] gproc for environment data (Re: Regarding `application:get_env` / `application:set_env` race conditions) In-Reply-To: References: <03C7C4FE-5B2F-48BD-AFF6-142F8EA5DD47@erlang-solutions.com> Message-ID: <39C93629-29C2-4684-B1FB-23C52295F508@erlang-solutions.com> I considered it, but decided to hold off on that for now. It's all too tempting to start by creating a big hole that lets you plug in anything, but that can always be done later too. :) BR, Ulf W On 26 Apr 2011, at 20:32, Ciprian Dorin Craciun wrote: > Though: it would be nice to be able to specify a generic function > to be used to fetch the value, like: > ~~~~ > SomeFun = fun (Key) -> > case <> of > <> -> {ok, some_value}; > <> -> undefined > end > end, > gproc:get_env (l, some_app, some_key, [app_env, SomeFun, > {transform, {erlang, list_to_atom}, os_env}]). Ulf Wiger, CTO, Erlang Solutions, Ltd. http://erlang-solutions.com From roberto.majadas@REDACTED Tue Apr 26 20:40:12 2011 From: roberto.majadas@REDACTED (Roberto Majadas Lopez) Date: Tue, 26 Apr 2011 20:40:12 +0200 Subject: [erlang-questions] GPL3 - EPL compatibility In-Reply-To: References: Message-ID: 2011/4/26 Jesse Gumm > You're free to release a program under any license you want. The EPL > pertains to the Erlang language itself, not necessarily to programs > written in Erlang. > But if i use erlang crypto server or another one released under EPL . can this relationship be considered dynamic link ? Roberto > > > > On Tue, Apr 26, 2011 at 12:39 PM, Roberto Majadas Lopez > wrote: > > Hello erlang hackers : > > I'm planning to develop a erlang program and i want to release it under > gpl3 > > license. > > i read, in the gnu web page, epl (mpl 1.0 based license) is not > compatible > > with GPL(2/3). > > In this page http://www.gnu.org/licenses/license-list.html gnu layers > > explain this ... > > ---- > > Mozilla Public License (MPL) > > This is a free software license which is not a strong copyleft; unlike > the > > X11 license, it has some complex restrictions that make it incompatible > with > > the GNU GPL. That is, a module covered by the GPL and a module covered by > > the MPL cannot legally be linked together. We urge you not to use the MPL > > for this reason. > > However, MPL 1.1 has a provision (section 13) that allows a program (or > > parts of it) to offer a choice of another license as well. If part of a > > program allows the GNU GPL as an alternate choice, or any other > > GPL-compatible license as an alternate choice, that part of the program > has > > a GPL-compatible license. > > ----- > > So , if EPL don't have the MPL1.1 section 13 , EPL is not GPL compatible. > > But, in the other hand, the ejabberd2 license was released under GPL2. > > So my questions are : > > * can i release source code under GPL3 or 2 using Erlang? > > * if i can't do it , can erlang team to consider add the section 13 to > the > > EPL license and make it GPL compatible ? > > regards > > Roberto > > > > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > > > > -- > Jesse Gumm > Sigma Star Systems > 414.940.4866 > gumm@REDACTED > http://www.sigma-star.com > -------------- next part -------------- An HTML attachment was scrubbed... URL: From moxford@REDACTED Tue Apr 26 20:55:36 2011 From: moxford@REDACTED (Mike Oxford) Date: Tue, 26 Apr 2011 11:55:36 -0700 Subject: [erlang-questions] When to throw..when to case...when to... Message-ID: I was going through the uds_drv included in the OTP distribution. Here's a snippet of code... --snip command(Port, Command, Parameters) -> SavedTrapExit = process_flag(trap_exit,true), case (catch erlang:port_command(Port,[Command | Parameters])) of true -> receive {Port, {data, [Command, $o, $k]}} -> process_flag(trap_exit,SavedTrapExit), {ok, Port}; {Port, {data, [Command |T]}} -> process_flag(trap_exit,SavedTrapExit), {ok, T}; {Port, Else} -> process_flag(trap_exit,SavedTrapExit), exit({unexpected_driver_response, Else}); {'EXIT', Port, normal} -> process_flag(trap_exit,SavedTrapExit), {error, closed}; {'EXIT', Port, Error} -> process_flag(trap_exit,SavedTrapExit), exit(Error) end; {'EXIT', {badarg, _}} -> process_flag(trap_exit,SavedTrapExit), {error, closed}; Unexpected -> process_flag(trap_exit,SavedTrapExit), exit({unexpected_driver_response, Unexpected}) end. --end snip I understand setting trap_exit in the process. They're also embedding a catch in the Expr for the case. Now, whomever wrote this knows more about Erlang than I do, as I've only been doing this for a couple of weeks. What confuses me is.... 1) Why set trap_exit here instead of in the init()? Is it because a sync-call would be executed in the context of the caller and not be caught by the init()'d trap_exit? 2) Why catch port_command, feed it to case and then handle it? Why not just put it in a try-catch-final block to reset the trap_exit state? Is it because this was written before R10B2 when the try-catch stuff was introduced? In general, when should you throw and exception vs returning a value? When should your protect your code with try/catch vs using a case? Are there any hard and fast rules or is it purely determined by the function being called? TiA! -mox -------------- next part -------------- An HTML attachment was scrubbed... URL: From mihai@REDACTED Tue Apr 26 22:01:28 2011 From: mihai@REDACTED (Mihai Balea) Date: Tue, 26 Apr 2011 16:01:28 -0400 Subject: [erlang-questions] When to throw..when to case...when to... In-Reply-To: References: Message-ID: <203C351A-2C53-4B69-A475-F3D4EBE59863@hates.ms> On Apr 26, 2011, at 2:55 PM, Mike Oxford wrote: > > I understand setting trap_exit in the process. They're also embedding a catch in the Expr for the case. > > Now, whomever wrote this knows more about Erlang than I do, as I've only been doing this for a couple of weeks. > What confuses me is.... > 1) Why set trap_exit here instead of in the init()? Is it because a sync-call would be executed in the context of the caller and not be caught by the init()'d trap_exit? I'd say this code was designed to be called from a user's process. Setting trap_exit would override the user's own trap_exit flag, which is not what you'd normally want. So the author saves the previous trap_exit value, enables it, then restores it before returning. The reason for temporarily enabling trap_exit is to catch port code terminations (crashes) as a response to a specific command. > 2) Why catch port_command, feed it to case and then handle it? Why not just put it in a try-catch-final block to reset the trap_exit state? Is it because this was written before R10B2 when the try-catch stuff was introduced? Most likely. I don't see why anybody would avoid using a try/catch/after nowadays. Especially since restoring trap_exit in an after body would save about 5-6 lines of code. > > In general, when should you throw and exception vs returning a value? When should your protect your code with try/catch vs using a case? Are there any hard and fast rules or is it purely determined by the function being called? It is a matter where personal preferences play a large part. My interpretation is to return an error value when a function fails as part of normal operation and an exception when things might indicate a bug in code. Consider writing to a file: read only access or disk full should be returned as error values; wrong parameters (such as wrong types, etc) would warrant an exception. Mihai From robert.virding@REDACTED Tue Apr 26 22:51:34 2011 From: robert.virding@REDACTED (Robert Virding) Date: Tue, 26 Apr 2011 20:51:34 +0000 (GMT) Subject: [erlang-questions] Specifying 'erts' as an application In-Reply-To: <1381211082.128831303851026309.JavaMail.root@zimbra> Message-ID: <1569163911.128851303851094547.JavaMail.root@zimbra> Looking at what is in ERTS I would actually hesitate to call it an application. ERTS is the actual implementation of the Erlang language containing the emulator and BIFs. Most of the BIFs should also be considered to be part of the language, spawn, link, etc are just as much part of Erlang language as case/receive/! even though they don't have any special syntax. We didn't see the need of giving them special syntax when a function interface worked just as well. (would end up with an enormous number of weird character combinations to no purpose) It also contains some, very few, modules which must be preloaded to get the erlang system running at all. So, I would not call ERTS an application. Having it in an application list is basically saying to run this I need Erlang, which is a bit unnecessary. It would be interesting to see what would happen if someone defined a proper application called erts. Robert ----- "Ulf Wiger" wrote: > I will venture a guess. > > ERTS was perceived from the beginning as the "master environment" in > which applications ran, but has increasingly come to be treated as one > of several applications. From that perspective, it's not unreasonable > to think that it could be named as one. > > OTOH, 'erts' is actually a perfectly valid application name, so one > may assume that there is some user out there who has defined such an > application, and is referring to it in a thousand different places > ;-) > > BR, > Ulf W > > > On 25 Apr 2011, at 13:10, Kostis Sagonas wrote: > > > About three weeks ago, I posted the following question but got no > answer so far. Let me ask it differently in the hope that I will now > get some reaction. > > > > Is there any good reason why the erts application does not have a > .app file as all other OTP applications (e.g. kernel, stdlib, etc.) > have? > > > > If there is no good reason, can it please be added? > > > > Kostis > > > > Kostis Sagonas wrote: > >> The Erlang/OTP documentation specifies 'erts' as an application: > >> http://erlang.org/doc/applications.html > >> In a project we are working on, we have an application resource > file that reads: > >> {application, APP_NAME, > >> [{description, ...}, > >> ... > >> {applications, [erts, kernel, stdlib, ...] > >> ... > >> ]}. > >> A user informed us that "erts isn't actually an application that > can be dependent upon and that having it in the applications list > breaks releases". > >> I personally consider this a bug, of Erlang/OTP that is, but I will > gladly be enlightened why 'erts' is listed as an OTP application but > cannot be listed in the application resource file and releases break > miserably when one does so. > >> Kostis > >> _______________________________________________ > >> erlang-questions mailing list > >> erlang-questions@REDACTED > >> http://erlang.org/mailman/listinfo/erlang-questions > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > Ulf Wiger, CTO, Erlang Solutions, Ltd. > http://erlang-solutions.com > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From mrtndimitrov@REDACTED Wed Apr 27 00:19:12 2011 From: mrtndimitrov@REDACTED (mrtndimitrov) Date: Tue, 26 Apr 2011 15:19:12 -0700 (PDT) Subject: [erlang-questions] supervisor:start_child Message-ID: <1303856352960-3476787.post@n4.nabble.com> Hi, I am trying to develop a supervisor that must have different children specifications. The number of the children are unknown at compile time so be added dynamically through supervisor:start_child. What shell be the supervisor's restart strategy? I try with one_for_all and when calling start_child I receive an error: {error,{ {'EXIT',{undef,[ {child_process,start_link,[]}, {supervisor,do_start_child,2}, {supervisor,handle_start_child,2}, {supervisor,handle_call,3}, {gen_server,handle_msg,5}, {proc_lib,init_p_do_apply,3} ]}}, {child,undefined,child_process_id,{child_process,start_link,[]},permanent,2000,worker,[child_process]} }} Thanks. -- View this message in context: http://erlang.2086793.n4.nabble.com/supervisor-start-child-tp3476787p3476787.html Sent from the Erlang Questions mailing list archive at Nabble.com. From max.lapshin@REDACTED Wed Apr 27 08:08:30 2011 From: max.lapshin@REDACTED (Max Lapshin) Date: Wed, 27 Apr 2011 10:08:30 +0400 Subject: [erlang-questions] Is it possible to compile crypto app with _static_ libcrypto In-Reply-To: <4DB6C258.8090807@erix.ericsson.se> References: <4DB6C258.8090807@erix.ericsson.se> Message-ID: On Tue, Apr 26, 2011 at 5:02 PM, Sverker Eriksson wrote: > Option --disable-dynamic-ssl-lib will link crypto with a static libcrypto.a > instead of a dynamic libcrypto.so. But crypto itself (crypto.so) is still a > dynamic library loaded by the emulator. > > I think the problem is with libcrypto.a. It was not built to be part of a > dynamic library. I would recommend downloading openssl and rebuild it > yourself. At least we've done it so. Debian has broken build of openssl: libssl.a and libcrypto.a aren't suitable for linking into other libraries, so I've took library from other repository and now it works excelent. From mjtruog@REDACTED Wed Apr 27 09:02:34 2011 From: mjtruog@REDACTED (Michael Truog) Date: Wed, 27 Apr 2011 00:02:34 -0700 Subject: [erlang-questions] [ANN] CloudI 0.1.5 Released Message-ID: <4DB7BF8A.8090005@gmail.com> Many changes to CloudI has occurred in the last few months: * Support for Java, Python, and Ruby * service/job communication * service name load balancing * ZeroMQ integration * HTTP integration * new FAQ documentation For more information about CloudI, just refer to the FAQ: http://cloudi.org/faq.html#1_WhatIs CloudI is still being kept as alpha (for now) while more testing and documentation takes place. The current goal is to have 0.2.0 be a rough beta, but that depends on the testing. Anyone with questions, comments, ideas, suggestions, criticisms, or concerns is welcome to send email. Thanks, Michael From kenneth.lundin@REDACTED Wed Apr 27 13:52:50 2011 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Wed, 27 Apr 2011 13:52:50 +0200 Subject: [erlang-questions] asn1ct/asn1rt EXTERNAL 1990/1994 conversion information loss In-Reply-To: <20110417175454.GI9379@prithivi.gnumonks.org> References: <20110417175454.GI9379@prithivi.gnumonks.org> Message-ID: Hi Harald, For good or bad we have once taken the decision to not introduce compiler options for chosing which ASN.1 standard 1990, 1994, 1997 etc. to use. Instead we try to support all reasonable constructs from these standards at the same time. When it comes to the EXTERNAL type we allow input values both as a 5-tuple (1990) and as a 4-tuple (1994) and use the 5 tuple 1990 format for encoding as the standard recommends. When decoding an EXTERNAL type this ends up as a 5-tuple (1990) as you describe and we convert it "back" to a 4-tuple (1994) representation since otherwise a value using the 1994 4-tuple format would not yield the same value back when encoded and then decoded back again. The problem with this approach is as you also explain that some information possible present in the 1990 5 -tuple vesion get lost when converted to the 1994 4 -tuple format. I suggest an easy first step which might be sufficient since the EXTERNAL type in not recommended to be used at all any more is to continue with the same conversion upon decode but only convert to 1994 4-tuple format when this can be done without information loss i.e. only when the "encoding" component is {octet-aligned, Octets}. This will result in that a 4-tuple (1994) or a 5-tuple (1990) value can be returned from decode and that encode will accept both of these formats as well. This will only require a one-liner change in asn1rt_check.erl (plus the documentation of course) You can try it if you want. Just change : in function transform_to_EXTERNAL1994/1 case Encoding of {_,Val} -> to case Encoding of {'octet-aligned',Val} when is_list(Val);is_binary(Val) -> /Regards Kenneth, Erlang/OTP, Ericsson On Sun, Apr 17, 2011 at 7:54 PM, Harald Welte wrote: > Hi! > > I'm working on a variety of (Free Software) projects related to mobile > communications (http://cgit.osmocom.org/). One of them is dealing with the GSM > MAP protocol (TS 09.02, TS 29.002) which is specified in ASN.1 > > I'm using the Erlang asn1ct/asn1rt to parse incoming MAP messages from the > worldwide SS7 backbone, filtering + patching some of the data contained in > it and re-transmit the MAP messages. It's like an application-level-gateway / > proxy that can modify some of the data. > > MAP itself uses TCAP (Q.773). TCAP messages have a dialogue and a component > portion. The dialogue portion is specified as an EXTERNAL type: > > DialoguePortion ::= [APPLICATION 11] EXPLICIT EXTERNAL > > Note: The MAP sender are (normally?) using the 1990 representation of EXTERNAL, > not the 1994 version. > > Erlangs asn1ct-generated dec_EXTERNAL code first internally generates along those > lines: > > #'EXTERNAL'{ > 'direct-reference' = {0,0,17,773,1,1,1}, > 'indirect-reference' = asn1_NOVALUE, > 'data-value-descriptor' = asn1_NOVALUE, > encoding = > {'single-ASN1-type', > [96,15,128,2,7,128,161,9,6,7,4,0,0,1,0,1,3]}} > > However, the asn1ct generated code automatically converts this #'EXTERNAL'{} > record into a tuple of the following structure (using > transform_to_EXTERNAL1994/1): > > {'EXTERNAL', {syntax,{0,0,17,773,1,1,1}}, > asn1_NOVALUE, > [96,15,128,2,7,128,161,9,6,7,4,0,0,1,0,1,3]} > > The problem is, when you pass this tuple into the asn1ct-generated encoder, > the 'single-ASN1-type' information has been lost, and it will be replaced with > 'octet-aligned'. > > The result is that instead of {tag,'CONTEXT',0,'EXPLICIT',32} we now use > {tag,'CONTEXT',1,'IMPLICIT',0} for encoding the data. This is not valid within > the scope of MAP, and both the wireshark MAP dissector as well as all MAP > implementations I've seen reject or ignore the resulting message. > > The problem fundamentally can be summarized as: > * EXTERNAL can contain inner data in either 'Single-ASN1-type' or > 'octet-aligned' > * the OTP asn1ct (at least in ber_bin mode) looses this information and > does not pass it back to the caller when decoding > * if the resulting data is passed through the encoder, the encoded data > semantically differs from the original undecoded BER data. > > I think this is probably not the intended behaviour. It would be weird if > decoding and re-encoding the same unmodified data leads to different BER tags > in the tree. > > What is wrong in passing the 1990 or 1994 EXTERNAL types from the decoder into > the user program? Why should the user not know which of the two formats was > being used? I believe at the very least, this automatic conversion should be > something that can be configured as a compiler option. > > Any comments/ideas/suggestions? > > Regards, > Harald > -- > - Harald Welte http://laforge.gnumonks.org/ > ============================================================================ > "Privacy in residential applications is a desirable marketing option." > (ETSI EN 300 175-7 Ch. A6) > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > From sumasai.shivaprasad@REDACTED Wed Apr 27 16:00:03 2011 From: sumasai.shivaprasad@REDACTED (Suma Shivaprasad) Date: Wed, 27 Apr 2011 19:30:03 +0530 Subject: [erlang-questions] httpc manager crashes Message-ID: We have an app that makes a lot of calls to httpc and we are seeing the following error in sasl logs quite often. CRASH REPORT==== 27-Apr-2011::05:21:24 === crasher: initial call: httpc_manager:init/1 pid: <0.10297.0> registered_name: httpc_manager_profile_8261 exception exit: {{case_clause, [{handler_info,#Ref<0.0.398.166371>,undefined, <0.12971.248>,undefined,operational}]}, [{httpc_manager,handle_connect_and_send,5}, {httpc_manager,handle_info,2}, {gen_server,handle_msg,5}, {proc_lib,init_p_do_apply,3}]} in function gen_server:terminate/6 ancestors: [httpc_profile_sup,httpc_sup,inets_sup,<0.46.0> and =CRASH REPORT==== 27-Apr-2011::05:30:18 === crasher: initial call: httpc_manager:init/1 pid: <0.22933.12> registered_name: httpc_manager_profile_8122 exception exit: {{case_clause, [{handler_info,#Ref<0.0.418.148452>,<0.20608.257>, undefined,<0.15267.257>,initiating}]}, [{httpc_manager,handle_connect_and_send,5}, {httpc_manager,handle_info,2}, {gen_server,handle_msg,5}, {proc_lib,init_p_do_apply,3}]} in function gen_server:terminate/6 ancestors: [httpc_profile_sup,httpc_sup,inets_sup,<0.46.0>] messages: [{'EXIT',<0.20574.257>,normal}] links: [<0.50.0>,<0.20608.257>] dictionary: [] Has anyone else seen these errors or have a fix for this? Thanks Suma -------------- next part -------------- An HTML attachment was scrubbed... URL: From laforge@REDACTED Wed Apr 27 17:52:06 2011 From: laforge@REDACTED (Harald Welte) Date: Wed, 27 Apr 2011 17:52:06 +0200 Subject: [erlang-questions] asn1ct/asn1rt EXTERNAL 1990/1994 conversion information loss In-Reply-To: References: <20110417175454.GI9379@prithivi.gnumonks.org> Message-ID: <20110427155206.GY655@prithivi.gnumonks.org> Hi Kenneth, thansk a lot for looking into the issue and getting back to me. On Wed, Apr 27, 2011 at 01:52:50PM +0200, Kenneth Lundin wrote: > For good or bad we have once taken the decision to not introduce compiler > options for chosing which ASN.1 standard 1990, 1994, 1997 etc. to use. > Instead we try to support all reasonable constructs from these standards at > the same time. I'm not adamant of the compiler option. In fact, a solution that requires no explicit user/developer intervention is always preferred to one that does. > When it comes to the EXTERNAL type we allow input values both as a > 5-tuple (1990) and as a 4-tuple (1994) and use the 5 tuple 1990 format for > encoding as the standard recommends. No complaint here. > When decoding an EXTERNAL type this ends up as a 5-tuple (1990) as > you describe and we convert it "back" to a 4-tuple (1994) representation > since otherwise a value using the 1994 4-tuple format would not yield the > same value back when encoded and then decoded back again. I don't really understand that part, but that's ok for me. > The problem with this approach is as you also explain that some information > possible present in the 1990 5 -tuple vesion get lost when converted to the > 1994 4 -tuple format. Indeed. > I suggest an easy first step which might be sufficient since the > EXTERNAL type in not recommended to be used at all any more The problem is that even in 20111 on the SS7 networks we still see stuff encoded not only using old EXTERNAL types, but even stuff encoded in MAPv1, specified against TCAP from 1988, using ASN.1 MACRO instead of information object classes. And even today, if you write software in 2011, you will want to have it interoperate with those old implementations that at least some GSM operators still use. If you (or someone else on this list) is interested to read about how difficult that really is, I recommend my blog posts at: http://laforge.gnumonks.org/weblog/2011/03/26#20110326-parsing_dos_word_files_for_gsm_map http://laforge.gnumonks.org/weblog/2011/03/27#20110327-parsing_more_word_files_for_gsm_map http://laforge.gnumonks.org/weblog/2011/04/09#20110409-follow_up_on_gsm_map http://laforge.gnumonks.org/weblog/2011/04/12#20110412-mapv1_available So as indicated, the 1990/1994 EXTERNAL type difference is only the smallest of all issues - and it is my belief that for years to come we will still see the need for supporting it in a graceful manner. > is to continue with the same conversion upon decode but only convert to 1994 > 4-tuple format when this can be done without information loss i.e. only when > the "encoding" component is {octet-aligned, Octets}. Makes a lot of sense. > This will result in that a 4-tuple (1994) or a 5-tuple (1990) value can be > returned from decode and that encode will accept both of these formats as > well. I think it is a great solution to the problem. > This will only require a one-liner change in asn1rt_check.erl (plus > the documentation of course) > You can try it if you want. Thanks, I will try it at the next convenient time. Regards, Harald -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From per.melin@REDACTED Wed Apr 27 18:10:33 2011 From: per.melin@REDACTED (Per Melin) Date: Wed, 27 Apr 2011 18:10:33 +0200 Subject: [erlang-questions] EUnit masquerading as Common Test Message-ID: I am not too happy about having half of my tests in EUnit and half in Common Test. And CT does not suit our workflow very well. EUnit is in my opinion quite capable even for system and integration tests. Its biggest drawback for me is that it is a hassle when you have a lot of setup and teardown of fixtures. So I started thinking. What if you could write test modules that look just like CT suites, but execute in EUnit? I started to build a proof-of-concept, but then I think I took it a little farther than that: https://github.com/permelin/common_eunit Obviously there is a lot of functionality from CT that is missing. But at least I wasn't using any of that anyway. I have started to convert my CT suites over and it is so far working beyond expectations. Is this a silly idea? Does anyone else see a value in this? Here is an example that you can run just as usual in EUnit with eunit:test(demo_tests). -module(demo_tests). -include_lib("common_eunit/include/common_eunit.hrl"). suite() -> [{timetrap, {seconds, 5}}, % The entire suite cannot take longer. {node, slave1}]. % A slave node called slave1 is started % on the same host, for the duration of % the suite. all() -> [alpha, {group, beta}, delta, epsilon]. groups() -> [{beta, [parallel, {repeat, 100}], [gamma]}]. %%% Setup and cleanup init_per_suite(Config) -> % Set up fixtures here. Config. end_per_suite(_Config) -> ok. init_per_testcase(Config) -> % Set up fixtures here. Config. end_per_testcase(_Config) -> ok. %%% Tests alpha(_Config) -> % Put test code here. ?assert(1 < 2). gamma(_Config) -> % This test will run 100 times, in parallel. See groups/0. % Put test code here. ok. delta() -> [{timetrap, 200}]. delta(_Config) -> % This test will abort if it takes longer than 200 ms. ok = timer:sleep(100). epsilon() -> [{spawn, slave1}]. epsilon(Config) -> % This test will execute on the node slave1. Node = ?config(slave1, Config), ?assertEqual(node(), Node). From maruthavanan_s@REDACTED Wed Apr 27 18:11:28 2011 From: maruthavanan_s@REDACTED (maruthavanan s) Date: Wed, 27 Apr 2011 12:11:28 -0400 Subject: [erlang-questions] httpc manager crashes In-Reply-To: References: Message-ID: Hi, I have faced the same situtation saw a mail in the same forum suggesting ibrowse and it worked like a charm for me. I suggest the same. Regards, Marutha Date: Wed, 27 Apr 2011 19:30:03 +0530 From: sumasai.shivaprasad@REDACTED To: erlang-questions@REDACTED Subject: [erlang-questions] httpc manager crashes We have an app that makes a lot of calls to httpc and we are seeing the following error in sasl logs quite often. CRASH REPORT==== 27-Apr-2011::05:21:24 === crasher: initial call: httpc_manager:init/1 pid: <0.10297.0> registered_name: httpc_manager_profile_8261 exception exit: {{case_clause, [{handler_info,#Ref<0.0.398.166371>,undefined, <0.12971.248>,undefined,operational}]}, [{httpc_manager,handle_connect_and_send,5}, {httpc_manager,handle_info,2}, {gen_server,handle_msg,5}, {proc_lib,init_p_do_apply,3}]} in function gen_server:terminate/6 ancestors: [httpc_profile_sup,httpc_sup,inets_sup,<0.46.0> and =CRASH REPORT==== 27-Apr-2011::05:30:18 === crasher: initial call: httpc_manager:init/1 pid: <0.22933.12> registered_name: httpc_manager_profile_8122 exception exit: {{case_clause, [{handler_info,#Ref<0.0.418.148452>,<0.20608.257>, undefined,<0.15267.257>,initiating}]}, [{httpc_manager,handle_connect_and_send,5}, {httpc_manager,handle_info,2}, {gen_server,handle_msg,5}, {proc_lib,init_p_do_apply,3}]} in function gen_server:terminate/6 ancestors: [httpc_profile_sup,httpc_sup,inets_sup,<0.46.0>] messages: [{'EXIT',<0.20574.257>,normal}] links: [<0.50.0>,<0.20608.257>] dictionary: [] Has anyone else seen these errors or have a fix for this? Thanks Suma _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf.wiger@REDACTED Wed Apr 27 18:47:16 2011 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Wed, 27 Apr 2011 18:47:16 +0200 Subject: [erlang-questions] EUnit masquerading as Common Test In-Reply-To: References: Message-ID: <8B7803E3-6F15-47E2-9E23-E206361C337A@erlang-solutions.com> On 27 Apr 2011, at 18:10, Per Melin wrote: > Is this a silly idea? Does anyone else see a value in this? I, for one, think it's a brilliant idea. :) BR, Ulf W Ulf Wiger, CTO, Erlang Solutions, Ltd. http://erlang-solutions.com From max.lapshin@REDACTED Wed Apr 27 19:05:06 2011 From: max.lapshin@REDACTED (Max Lapshin) Date: Wed, 27 Apr 2011 21:05:06 +0400 Subject: [erlang-questions] gen_udp port leaking after controlling_process(Port, self()) Message-ID: Open UDP port $ erl Erlang R14B02 (erts-5.8.3) [source] [64-bit] [smp:4:4] [rq:4] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.8.3 (abort with ^G) 1> {ok,Port} = gen_udp:open(9000, [binary]). {ok,#Port<0.576>} $ lsof -nP -i|grep beam|grep UDP beam.smp 10912 max 11u IPv4 0x089073c4 0t0 UDP *:9000 Simulate error: 2> a=b. ** exception error: no match of right hand side value b All ports are closed. $ lsof -nP -i|grep beam|grep UDP $ Now add controlling_process: 4> {ok,Port} = gen_udp:open(9000, [binary]). {ok,#Port<0.587>} 5> gen_udp:controlling_process(Port, self()). ok 6> a=b. ** exception error: no match of right hand side value b Voila: port is not closed lsof -nP -i|grep beam|grep UDP beam.smp 10912 max 11u IPv4 0x089073c4 0t0 UDP *:9000 Where is it? To which process belongs it now and when will it be closed? From jane@REDACTED Wed Apr 27 19:16:00 2011 From: jane@REDACTED (Jane Walerud) Date: Wed, 27 Apr 2011 19:16:00 +0200 Subject: [erlang-questions] Do you want to co-found a startup? Message-ID: Some of you may know of me; I helped get Erlang released as open source, was CEO of Bluetail, and have helped 10 more companies into existence since Bluetail. You may know of some of them: Klarna, Lensway, Tobii Technology, and Midsummer. All of those companies - and Bluetail, of course - are definite successes; three more are still quite likely to succeed (Teclo Networks is looking very good indeed :), and three have not done well. My hit rate is excellent. I am now interested in helping another company into existence. The company will be a web company and will do rather a lot of data mining. I don't want to say much more in this forum. The current founding group of three are young, intelligent, hard working, charming and well educated. They are one sales/marketing communications oriented business person, one math/statistics whiz, and one process oriented, financial business person. They need someone to build the infrastructure. In other words, they need a co-founder. The person we're looking for fits the above description, and is able and eager to do the architecture, build a system that will grow with the company, and participate in discussions about what to do and when. I will not be active in the day to day operations of the company myself; Teclo Networks takes almost all my time, but I will definitely be around. (I've had to quit Venture Cup, Vinnova, and my last board position to make time for this new baby company) Location: Stockholm. If you want this opportunity, contact me at jane at walerud dot com. Cheers, Jane -------------- next part -------------- An HTML attachment was scrubbed... URL: From tony@REDACTED Wed Apr 27 19:36:39 2011 From: tony@REDACTED (Tony Rogvall) Date: Wed, 27 Apr 2011 19:36:39 +0200 Subject: [erlang-questions] gen_udp port leaking after controlling_process(Port, self()) In-Reply-To: References: Message-ID: <9B0B7B9B-AA40-4200-BFF1-FE5136FE600B@rogvall.se> Nice ! ;-) Same problem with gen_tcp ! You can use inet:i() to verify that even Erlang knows about the problem :-) I see the problem. inet:udp/tcp_controlling_process unlinks from the socket without checking that it is already the controlling process, effectively creating a zombie port. Work around: Do not change the controlling process to it self. /Tony On 27 apr 2011, at 19.05, Max Lapshin wrote: > Open UDP port > > $ erl > Erlang R14B02 (erts-5.8.3) [source] [64-bit] [smp:4:4] [rq:4] > [async-threads:0] [hipe] [kernel-poll:false] > > Eshell V5.8.3 (abort with ^G) > 1> {ok,Port} = gen_udp:open(9000, [binary]). > {ok,#Port<0.576>} > > $ lsof -nP -i|grep beam|grep UDP > beam.smp 10912 max 11u IPv4 0x089073c4 0t0 UDP *:9000 > > > > Simulate error: > 2> a=b. > ** exception error: no match of right hand side value b > > All ports are closed. > > $ lsof -nP -i|grep beam|grep UDP > $ > > > Now add controlling_process: > > 4> {ok,Port} = gen_udp:open(9000, [binary]). > {ok,#Port<0.587>} > 5> gen_udp:controlling_process(Port, self()). > ok > 6> a=b. > ** exception error: no match of right hand side value b > > Voila: port is not closed > > lsof -nP -i|grep beam|grep UDP > beam.smp 10912 max 11u IPv4 0x089073c4 0t0 UDP *:9000 > > > Where is it? To which process belongs it now and when will it be closed? > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions "Have run Make so many times I dunno what's installed anymore" -------------- next part -------------- An HTML attachment was scrubbed... URL: From per.melin@REDACTED Wed Apr 27 20:05:14 2011 From: per.melin@REDACTED (Per Melin) Date: Wed, 27 Apr 2011 20:05:14 +0200 Subject: [erlang-questions] EUnit masquerading as Common Test In-Reply-To: <8B7803E3-6F15-47E2-9E23-E206361C337A@erlang-solutions.com> References: <8B7803E3-6F15-47E2-9E23-E206361C337A@erlang-solutions.com> Message-ID: On Wed, Apr 27, 2011 at 6:47 PM, Ulf Wiger wrote: > I, for one, think it's a brilliant idea. :) Awesome. I should stress that my application is very light (less than 300 lines) and EUnit is doing all the work. To illustrate, imagine a module alpha_tests with a single group called beta with a single test case called gamma. For that I would generate a structure similar to this and hand it over to EUnit to execute. {setup, fun() -> alpha_tests:init_per_suite([]) end, fun(Config) -> alpha_tests:end_per_suite(Config) end, fun(Config) -> [{setup, fun() -> alpha_tests:init_per_group(beta, Config) end, fun(Config1) -> alpha_tests:end_per_group(beta, Config1) end, fun(Config1) -> [{setup, fun() -> alpha_tests:init_per_testcase(gamma, Config1) end, fun(Config2) -> alpha_tests:end_per_testcase(gamma, Config2) end, fun(Config2) -> fun() -> alpha_tests:gamma(Config2) end end}] end}] end} From spawn.think@REDACTED Wed Apr 27 20:31:55 2011 From: spawn.think@REDACTED (Ahmed Omar) Date: Wed, 27 Apr 2011 20:31:55 +0200 Subject: [erlang-questions] gen_udp port leaking after controlling_process(Port, self()) In-Reply-To: <9B0B7B9B-AA40-4200-BFF1-FE5136FE600B@rogvall.se> References: <9B0B7B9B-AA40-4200-BFF1-FE5136FE600B@rogvall.se> Message-ID: Nice catch, so something like this shall fix it diff --git a/lib/kernel/src/inet.erl b/lib/kernel/src/inet.erl index 327e0f9..8a9b1ab 100644 --- a/lib/kernel/src/inet.erl +++ b/lib/kernel/src/inet.erl @@ -1262,6 +1262,8 @@ udp_close(S) when is_port(S) -> %% Set controlling process for TCP socket. tcp_controlling_process(S, NewOwner) when is_port(S), is_pid(NewOwner) -> case erlang:port_info(S, connected) of + {connected, NewOwner}-> + ok; {connected, Pid} when Pid =/= self() -> {error, not_owner}; undefined -> @@ -1313,6 +1315,8 @@ tcp_sync_input(S, Owner, Flag) -> %% Set controlling process for UDP or SCTP socket. udp_controlling_process(S, NewOwner) when is_port(S), is_pid(NewOwner) -> case erlang:port_info(S, connected) of + {connected, NewOwner}-> + ok; {connected, Pid} when Pid =/= self() -> {error, not_owner}; _ -> On Wed, Apr 27, 2011 at 7:36 PM, Tony Rogvall wrote: > Nice ! ;-) > > Same problem with gen_tcp ! > You can use inet:i() to verify that even Erlang knows about the problem :-) > > I see the problem. inet:udp/tcp_controlling_process unlinks from the > socket without > checking that it is already the controlling process, effectively creating a > zombie port. > > Work around: Do not change the controlling process to it self. > > /Tony > > > On 27 apr 2011, at 19.05, Max Lapshin wrote: > > Open UDP port > > $ erl > Erlang R14B02 (erts-5.8.3) [source] [64-bit] [smp:4:4] [rq:4] > [async-threads:0] [hipe] [kernel-poll:false] > > Eshell V5.8.3 (abort with ^G) > 1> {ok,Port} = gen_udp:open(9000, [binary]). > {ok,#Port<0.576>} > > $ lsof -nP -i|grep beam|grep UDP > beam.smp 10912 max 11u IPv4 0x089073c4 0t0 UDP *:9000 > > > > Simulate error: > 2> a=b. > ** exception error: no match of right hand side value b > > All ports are closed. > > $ lsof -nP -i|grep beam|grep UDP > $ > > > Now add controlling_process: > > 4> {ok,Port} = gen_udp:open(9000, [binary]). > {ok,#Port<0.587>} > 5> gen_udp:controlling_process(Port, self()). > ok > 6> a=b. > ** exception error: no match of right hand side value b > > Voila: port is not closed > > lsof -nP -i|grep beam|grep UDP > beam.smp 10912 max 11u IPv4 0x089073c4 0t0 UDP *:9000 > > > Where is it? To which process belongs it now and when will it be closed? > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > > *"Have run Make so many times I dunno what's installed anymore"* > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -- Best Regards, - Ahmed Omar http://nl.linkedin.com/in/adiaa Follow me on twitter @spawn_think -------------- next part -------------- An HTML attachment was scrubbed... URL: From watson.timothy@REDACTED Wed Apr 27 20:32:46 2011 From: watson.timothy@REDACTED (Tim Watson) Date: Wed, 27 Apr 2011 19:32:46 +0100 Subject: [erlang-questions] EUnit masquerading as Common Test In-Reply-To: References: Message-ID: > Is this a silly idea? Does anyone else see a value in this? Wicked. I've been writing suites in common_test but using eunit macros for ages but prefer eunit's rebar integration, so this looks ideal. Nice work! From bob@REDACTED Wed Apr 27 21:52:33 2011 From: bob@REDACTED (Bob Cowdery) Date: Wed, 27 Apr 2011 20:52:33 +0100 Subject: [erlang-questions] UDP Broadcast Message-ID: <4DB87401.1080304@bobcowdery.plus.com> I don't think this is an Erlang issue. I'm probably just doing it wrong. Any advice would be gratefully received. My app does a UDP broadcast and expects a reply from a piece of hardware. As I understand broadcast it involves opening a broadcast socket. gen_udp:open(6000, [binary, {broadcast, true}]) doing the broadcast. Then closing the socket and opening a listening socket. gen_udp:open(6000, [binary, {active, false}]) I've had the application working against a simulator, but the hardware is a lot faster. Using wireshark I can see my broadcast go and the reply come back. The problem is I miss the reply because by the time I close the socket and open a new one its too late. I can't help feeling I must be doing something fundamentally wrong here or broadcasts just wouldn't work. Thanks Bob From spawn.think@REDACTED Wed Apr 27 22:22:19 2011 From: spawn.think@REDACTED (Ahmed Omar) Date: Wed, 27 Apr 2011 22:22:19 +0200 Subject: [erlang-questions] UDP Broadcast In-Reply-To: <4DB87401.1080304@bobcowdery.plus.com> References: <4DB87401.1080304@bobcowdery.plus.com> Message-ID: Why do you need to close and open the socket again? Why don't you just do gen_udp:open(6000, [binary, {broadcast, true},{active, false}]). ? On Wed, Apr 27, 2011 at 9:52 PM, Bob Cowdery wrote: > I don't think this is an Erlang issue. I'm probably just doing it wrong. > Any advice would be gratefully received. > > My app does a UDP broadcast and expects a reply from a piece of > hardware. As I understand broadcast it involves opening a broadcast socket. > > gen_udp:open(6000, [binary, {broadcast, true}]) > > doing the broadcast. Then closing the socket and opening a listening > socket. > > gen_udp:open(6000, [binary, {active, false}]) > > I've had the application working against a simulator, but the hardware > is a lot faster. Using wireshark I can see my broadcast go and the reply > come back. The problem is I miss the reply because by the time I close > the socket and open a new one its too late. I can't help feeling I must > be doing something fundamentally wrong here or broadcasts just wouldn't > work. > > Thanks > Bob > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -- Best Regards, - Ahmed Omar http://nl.linkedin.com/in/adiaa Follow me on twitter @spawn_think -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob@REDACTED Wed Apr 27 22:57:41 2011 From: bob@REDACTED (Bob Cowdery) Date: Wed, 27 Apr 2011 21:57:41 +0100 Subject: [erlang-questions] UDP Broadcast In-Reply-To: References: <4DB87401.1080304@bobcowdery.plus.com> Message-ID: <4DB88345.4010509@bobcowdery.plus.com> I must admit I hadn't tried that because I read that a broadcast socket could not be used to listen on. However, if it can that would solve the issue. On 27/04/2011 21:22, Ahmed Omar wrote: > Why do you need to close and open the socket again? Why don't you just do > gen_udp:open(6000, [binary, {broadcast, true},{active, false}]). > ? > > > On Wed, Apr 27, 2011 at 9:52 PM, Bob Cowdery > wrote: > > I don't think this is an Erlang issue. I'm probably just doing it > wrong. > Any advice would be gratefully received. > > My app does a UDP broadcast and expects a reply from a piece of > hardware. As I understand broadcast it involves opening a > broadcast socket. > > gen_udp:open(6000, [binary, {broadcast, true}]) > > doing the broadcast. Then closing the socket and opening a > listening socket. > > gen_udp:open(6000, [binary, {active, false}]) > > I've had the application working against a simulator, but the hardware > is a lot faster. Using wireshark I can see my broadcast go and the > reply > come back. The problem is I miss the reply because by the time I close > the socket and open a new one its too late. I can't help feeling I > must > be doing something fundamentally wrong here or broadcasts just > wouldn't > work. > > Thanks > Bob > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > > > > -- > Best Regards, > - Ahmed Omar > http://nl.linkedin.com/in/adiaa > Follow me on twitter > @spawn_think > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob@REDACTED Wed Apr 27 23:04:21 2011 From: bob@REDACTED (Bob Cowdery) Date: Wed, 27 Apr 2011 22:04:21 +0100 Subject: [erlang-questions] UDP Broadcast In-Reply-To: References: <4DB87401.1080304@bobcowdery.plus.com> Message-ID: <4DB884D5.4010708@bobcowdery.plus.com> I will learn not be believe what I read one day. That works great thanks. Bob On 27/04/2011 21:22, Ahmed Omar wrote: > Why do you need to close and open the socket again? Why don't you just do > gen_udp:open(6000, [binary, {broadcast, true},{active, false}]). > ? > > > On Wed, Apr 27, 2011 at 9:52 PM, Bob Cowdery > wrote: > > I don't think this is an Erlang issue. I'm probably just doing it > wrong. > Any advice would be gratefully received. > > My app does a UDP broadcast and expects a reply from a piece of > hardware. As I understand broadcast it involves opening a > broadcast socket. > > gen_udp:open(6000, [binary, {broadcast, true}]) > > doing the broadcast. Then closing the socket and opening a > listening socket. > > gen_udp:open(6000, [binary, {active, false}]) > > I've had the application working against a simulator, but the hardware > is a lot faster. Using wireshark I can see my broadcast go and the > reply > come back. The problem is I miss the reply because by the time I close > the socket and open a new one its too late. I can't help feeling I > must > be doing something fundamentally wrong here or broadcasts just > wouldn't > work. > > Thanks > Bob > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > > > > -- > Best Regards, > - Ahmed Omar > http://nl.linkedin.com/in/adiaa > Follow me on twitter > @spawn_think > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kenrobinsonster@REDACTED Thu Apr 28 09:44:21 2011 From: kenrobinsonster@REDACTED (Ken Robinson) Date: Thu, 28 Apr 2011 17:44:21 +1000 Subject: [erlang-questions] False warning - function has no local return Message-ID: Hi, As per an earlier post from Kostis I'm reporting what I think is a false warning of a function having no local return (meaning some call will fail/halt/exit within its body). If I'm mistaken please tell me. The warning: ==> jaus_core (dialyze) jaus_core_message_marshaller.erl:31: Function prepare_msgs/1 has no local return Below is the code: prepare_msgs(ListToSend) when is_list(ListToSend) -> log4erl:info("prepare_msgs args ~p~n", [ListToSend]), %% getting Wrapper values [{{Priority, Host, DestId, SourceId}, _MsgPayload} | _Tail] = ListToSend, UnwrappedJausMsgs = [ MsgPayload || {{_Priority, _Host, _DestId, _SrcId}, MsgPayload} <- ListToSend ], %% Broadcast use default ?BCAST_NONE:?BCAST %% AckNak use default ?ACKNAK_MSG_ORIG_RSP_NOTREQ:?ACKNAK %% DataFlag is set in wrapper values. No need to set it here. use a default of %% ?DATA_FLAG_ONLY_PACKET %% JausMsgSize is set in wrapper values. No need to set it here, use a default of 0 Arg1 = <>, log4erl:debug("Arg1 one is ~p~n", [Arg1]), Arg2 = Priority, log4erl:debug("Arg2 one is ~p~n", [Arg2]), Arg3 = <>, log4erl:debug("Arg3 one is ~p~n", [Arg3]), Arg4 = DestId, log4erl:debug("Arg4 one is ~p~n", [Arg4]), Arg5 = SourceId, log4erl:debug("Arg5 one is ~p~n", [Arg5]), log4erl:debug("About to construct Wrappers Vals with args ~p ~p ~p ~p ~p~n", [Arg1, Arg2, Arg3, Arg4, Arg5]), WrapperVals = erlang:list_to_bitstring([Arg1, Arg2, Arg3, Arg4, Arg5]), log4erl:info("prepare return val ~p ~p ~p~n", [Host, UnwrappedJausMsgs, WrapperVals]), {Host, UnwrappedJausMsgs, WrapperVals}. -- regards, Ken Robinson Mob +61438681120 Home +61738523767 From travis.jensen@REDACTED Thu Apr 28 10:15:30 2011 From: travis.jensen@REDACTED (Travis Jensen) Date: Thu, 28 Apr 2011 02:15:30 -0600 Subject: [erlang-questions] NIF Problem Message-ID: I'm getting a bus violation after my NIF code is run. The code is pretty straightforward: I'm extending crypto:aes_ctr_encrypt/3 to allow for real streaming encryption. Unfortunately, something is unhappy because after I return from the BIF, I get the bus violation. I figure I'm either missing something stupid-obvious or there are some side-effects I'm not aware of in some of the enif_* functions. I've included my function (aes_ctr_encrypt_with_state as well as the original aes_ctr_encrypt. State is an arity-4 tuple containing the key (an iolist or binary), the IV (a binary of length 16), ECount (a binary of length 16 initialized to all zeros), and Num (an integer set to 0). There is another function that (correctly) initializes that (it is Erlang code and working fine). (Code also available at http://pastebin.com/fPs7SgiR) Any ideas or thoughts would be much appreciated. 1. static ERL_NIF_TERM aes_ctr_encrypt_with_state(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) 2. {/* ({Key, IVec, ECount, Num}, Data) */ 3. ErlNifBinary key_bin, ivec_bin, text_bin, ecount_bin; 4. AES_KEY aes_key; 5. unsigned int num = 0; 6. ERL_NIF_TERM ret, num2_term, cipher_term, ivec2_term, ecount2_term, new_state_term; 7. int state_arity; 8. const ERL_NIF_TERM *state_term; 9. unsigned char * ivec2_buf; 10. unsigned char * ecount2_buf; 11. 12. if (!enif_get_tuple(env, argv[0], &state_arity, &state_term) 13. || state_arity != 4 14. || !enif_inspect_iolist_as_binary(env, state_term[0], & key_bin) 15. || AES_set_encrypt_key(key_bin.data, key_bin.size*8, & aes_key) != 0 16. || !enif_inspect_binary(env, state_term[1], &ivec_bin) || ivec_bin.size != 16 17. || !enif_inspect_binary(env, state_term[2], &ecount_bin) || ecount_bin.size != AES_BLOCK_SIZE 18. || !enif_get_uint(env, state_term[3], &num) 19. || !enif_inspect_iolist_as_binary(env, argv[1], &text_bin)) { 20. return enif_make_badarg(env); 21. } 22. 23. ivec2_buf = enif_make_new_binary(env, ivec_bin.size, &ivec2_term ); 24. ecount2_buf = enif_make_new_binary(env, ecount_bin.size, & ecount2_term); 25. 26. memcpy(ivec2_buf, ivec_bin.data, 16); 27. memcpy(ecount2_buf, ecount_bin.data, ecount_bin.size); 28. 29. AES_ctr128_encrypt((unsigned char *) text_bin.data, 30. enif_make_new_binary(env, text_bin.size, & cipher_term), 31. text_bin.size, &aes_key, ivec2_buf, ecount2_buf, &num); 32. 33. num2_term = enif_make_uint(env, num); 34. new_state_term = enif_make_tuple4(env, key_bin, ivec2_term, ecount2_term, num2_term); 35. ret = enif_make_tuple2(env, new_state_term, cipher_term); 36. return ret; 37. } 38. 39. 40. static ERL_NIF_TERM aes_ctr_encrypt(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) 41. {/* (Key, IVec, Data) */ 42. ErlNifBinary key, ivec, text; 43. AES_KEY aes_key; 44. unsigned char ivec_clone[16]; /* writable copy */ 45. unsigned char ecount_buf[AES_BLOCK_SIZE]; 46. unsigned int num = 0; 47. ERL_NIF_TERM ret; 48. 49. if (!enif_inspect_iolist_as_binary(env, argv[0], &key) 50. || AES_set_encrypt_key(key.data, key.size*8, &aes_key) != 0 51. || !enif_inspect_binary(env, argv[1], &ivec) || ivec.size != 16 52. || !enif_inspect_iolist_as_binary(env, argv[2], &text)) { 53. return enif_make_badarg(env); 54. } 55. memcpy(ivec_clone, ivec.data, 16); 56. memset(ecount_buf, 0, sizeof(ecount_buf)); 57. AES_ctr128_encrypt((unsigned char *) text.data, 58. enif_make_new_binary(env, text.size, &ret), 59. text.size, &aes_key, ivec_clone, ecount_buf, &num); 60. 61. /* To do an incremental {en|de}cryption, the state to to keep between calls 62. must include ivec_clone, ecount_buf and num. */ 63. return ret; 64. } -- *Travis Jensen* *** *Read the Software Maven @ http://softwaremaven.innerbrane.com/ Read my LinkedIn profile @ http://www.linkedin.com/in/travisjensen Read my Twitter mumblings @ http://twitter.com/SoftwareMaven Send me email @ travis.jensen@REDACTED **What kind of guy calls himself the Software Maven???** -------------- next part -------------- An HTML attachment was scrubbed... URL: From alex.arnon@REDACTED Thu Apr 28 10:46:59 2011 From: alex.arnon@REDACTED (Alex Arnon) Date: Thu, 28 Apr 2011 11:46:59 +0300 Subject: [erlang-questions] Erlang VM: how clean is our memory? Message-ID: Hi All, We've recently been discussing the security of OS and VM stacks here, and several questions came up with regards to the Erlang VM. Specifically, the values of "new" and "old" memory. As an example, take the OpenBSD Unix-like OS. These guys are fanatics for security, and take various steps to ensure that the system is as unbreakable as possible, and in the event of breakage - to make life hard (if not impossible) for the intruder. This includes: - Randomization of integer handles, e.g. accepted socket ports. - Randomization of memory mapping location, e.g. DLLs (SO) will be loaded in random locations in memory. - Newly mapped memory pages are always zeroed before attachment to a process's virtual space. - Swap can be encrypted, or zeroed, on the fly. - The memory allocator also zeroes out freed space. In the context of the Erlang BEAM VM, we're interested in the contents of memory. What happens, for instance, when: - A process is garbage collected. - A process is terminated. Are the memory locations that have been "cleaned", zeroed out? Is it is, is it possible to control it? Regards, Alex. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf.wiger@REDACTED Thu Apr 28 11:07:19 2011 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Thu, 28 Apr 2011 11:07:19 +0200 Subject: [erlang-questions] Erlang VM: how clean is our memory? In-Reply-To: References: Message-ID: <572745F0-0705-4773-837C-6358BAC89780@erlang-solutions.com> I think a good starting point is to meditate over this page: http://www.erlang.org/doc/man/erts_alloc.html It seems to me that it would be _possible_ (with some work) to make use of the +Mym flag, substituting another malloc library for libc. In the old days, with non-SMP Erlang, this was entirely doable, and we played around with different allocators in the AXD 301 project, in order to see which one gave the least fragmentation over time. The whole memory management subsystem in BEAM has become a *lot* more sophisticated since then, but it is designed to be quite configurable. For less hand-wavy answers, I refer to the actual experts on the subject. :) BR, Ulf On 28 Apr 2011, at 10:46, Alex Arnon wrote: > Hi All, > > We've recently been discussing the security of OS and VM stacks here, and several questions came up with regards to the Erlang VM. Specifically, the values of "new" and "old" memory. > As an example, take the OpenBSD Unix-like OS. These guys are fanatics for security, and take various steps to ensure that the system is as unbreakable as possible, and in the event of breakage - to make life hard (if not impossible) for the intruder. > This includes: > - Randomization of integer handles, e.g. accepted socket ports. > - Randomization of memory mapping location, e.g. DLLs (SO) will be loaded in random locations in memory. > - Newly mapped memory pages are always zeroed before attachment to a process's virtual space. > - Swap can be encrypted, or zeroed, on the fly. > - The memory allocator also zeroes out freed space. > > In the context of the Erlang BEAM VM, we're interested in the contents of memory. What happens, for instance, when: > - A process is garbage collected. > - A process is terminated. > Are the memory locations that have been "cleaned", zeroed out? Is it is, is it possible to control it? > > > Regards, > Alex. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions Ulf Wiger, CTO, Erlang Solutions, Ltd. http://erlang-solutions.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From ingela.andin@REDACTED Thu Apr 28 11:23:04 2011 From: ingela.andin@REDACTED (Ingela Andin) Date: Thu, 28 Apr 2011 11:23:04 +0200 Subject: [erlang-questions] httpc manager crashes In-Reply-To: References: Message-ID: Hi! What version of inets and Erlang are you using? What HTTP version HTTP-1.0 ? If there is a bug we will of course fix it. Regards Ingela Erlang/OTP - Ericsson AB 2011/4/27 Suma Shivaprasad : > We have an app that makes a lot of calls to httpc and we are seeing the > following error in sasl logs quite often. > > CRASH REPORT==== 27-Apr-2011::05:21:24 === > ? crasher: > ??? initial call: httpc_manager:init/1 > ??? pid: <0.10297.0> > ??? registered_name: httpc_manager_profile_8261 > ??? exception exit: {{case_clause, > ???????????????????????? [{handler_info,#Ref<0.0.398.166371>,undefined, > ????????????????????????????? <0.12971.248>,undefined,operational}]}, > ???????????????????? [{httpc_manager,handle_connect_and_send,5}, > ????????????????????? {httpc_manager,handle_info,2}, > ????????????????????? {gen_server,handle_msg,5}, > ????????????????????? {proc_lib,init_p_do_apply,3}]} > ????? in function? gen_server:terminate/6 > ??? ancestors: [httpc_profile_sup,httpc_sup,inets_sup,<0.46.0> > > > > and > > > =CRASH REPORT==== 27-Apr-2011::05:30:18 === > ? crasher: > ??? initial call: httpc_manager:init/1 > ??? pid: <0.22933.12> > ??? registered_name: httpc_manager_profile_8122 > ??? exception exit: {{case_clause, > ???????????????????????? [{handler_info,#Ref<0.0.418.148452>,<0.20608.257>, > ????????????????????????????? undefined,<0.15267.257>,initiating}]}, > ???????????????????? [{httpc_manager,handle_connect_and_send,5}, > ????????????????????? {httpc_manager,handle_info,2}, > ????????????????????? {gen_server,handle_msg,5}, > ????????????????????? {proc_lib,init_p_do_apply,3}]} > ????? in function? gen_server:terminate/6 > ??? ancestors: [httpc_profile_sup,httpc_sup,inets_sup,<0.46.0>] > ??? messages: [{'EXIT',<0.20574.257>,normal}] > ??? links: [<0.50.0>,<0.20608.257>] > ??? dictionary: [] > > > Has anyone else seen these errors or have a fix for this? > > Thanks > Suma > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > From clist@REDACTED Thu Apr 28 11:44:53 2011 From: clist@REDACTED (Angel Alvarez) Date: Thu, 28 Apr 2011 11:44:53 +0200 Subject: [erlang-questions] Erlang VM: how clean is our memory? In-Reply-To: References: Message-ID: <201104281144.53435.clist@uah.es> El Jueves, 28 de Abril de 2011 10:46:59 Alex Arnon escribi?: > Hi All, > > We've recently been discussing the security of OS and VM stacks here, and > several questions came up with regards to the Erlang VM. Specifically, the > values of "new" and "old" memory. > As an example, take the OpenBSD Unix-like OS. These guys are fanatics for > security, and take various steps to ensure that the system is as unbreakable > as possible, and in the event of breakage - to make life hard (if not > impossible) for the intruder. > This includes: > - Randomization of integer handles, e.g. accepted socket ports. > - Randomization of memory mapping location, e.g. DLLs (SO) will be loaded in > random locations in memory. I thougth that the famous kdeinit trick make kde apps inherit all kde libs at the same memory mapping to save pages How does this stuff behave on OpenBSD? > - Newly mapped memory pages are always zeroed before attachment to a > process's virtual space. > - Swap can be encrypted, or zeroed, on the fly. > - The memory allocator also zeroes out freed space. > > In the context of the Erlang BEAM VM, we're interested in the contents of > memory. What happens, for instance, when: > - A process is garbage collected. > - A process is terminated. > Are the memory locations that have been "cleaned", zeroed out? Is it is, is > it possible to control it? > > > Regards, > Alex. > -- Este correo no tiene dibujos. Las formas extra?as en la pantalla son letras. __________________________________________ Clist UAH a.k.a Angel AT uah DOT es Angel Alvarez , Servicios Inform?ticos Edificio Torre de Control, Campus Externo UAH Alcal? de Henares 28806, Madrid ** ESPA?A ** __________________________________________ Hoy no has conseguido la iluminaci?n divina. No importa ma??na ser? otro d?a... From freza@REDACTED Thu Apr 28 12:07:11 2011 From: freza@REDACTED (Jachym Holecek) Date: Thu, 28 Apr 2011 11:07:11 +0100 Subject: [erlang-questions] NIF Problem In-Reply-To: References: Message-ID: <20110428100711.GA672@hanele.lan> # Travis Jensen 2011-04-28: > [... This results in SIGBUS after returning to Erlang ...] > > 1. static ERL_NIF_TERM aes_ctr_encrypt_with_state(ErlNifEnv* env, int argc, const ERL_NIF_TERM > argv[]) > 2. {/* ({Key, IVec, ECount, Num}, Data) */ > 3. ErlNifBinary key_bin, ivec_bin, text_bin, ecount_bin; > 4. AES_KEY aes_key; > 5. unsigned int num = 0; > 6. ERL_NIF_TERM ret, num2_term, cipher_term, ivec2_term, ecount2_term, new_state_term; > 7. int state_arity; > 8. const ERL_NIF_TERM *state_term; > 9. unsigned char * ivec2_buf; > 10. unsigned char * ecount2_buf; > 11. > 12. if (!enif_get_tuple(env, argv[0], &state_arity, &state_term) > 13. || state_arity != 4 > 14. || !enif_inspect_iolist_as_binary(env, state_term[0], &key_bin) > 15. || AES_set_encrypt_key(key_bin.data, key_bin.size*8, &aes_key) != 0 > 16. || !enif_inspect_binary(env, state_term[1], &ivec_bin) || ivec_bin.size != 16 > 17. || !enif_inspect_binary(env, state_term[2], &ecount_bin) || ecount_bin.size != > AES_BLOCK_SIZE > 18. || !enif_get_uint(env, state_term[3], &num) > 19. || !enif_inspect_iolist_as_binary(env, argv[1], &text_bin)) { > 20. return enif_make_badarg(env); > 21. } > 22. > 23. ivec2_buf = enif_make_new_binary(env, ivec_bin.size, &ivec2_term); > 24. ecount2_buf = enif_make_new_binary(env, ecount_bin.size, &ecount2_term); > 25. > 26. memcpy(ivec2_buf, ivec_bin.data, 16); > 27. memcpy(ecount2_buf, ecount_bin.data, ecount_bin.size); > 28. > 29. AES_ctr128_encrypt((unsigned char *) text_bin.data, > 30. enif_make_new_binary(env, text_bin.size, &cipher_term), > 31. text_bin.size, &aes_key, ivec2_buf, ecount2_buf, &num); > 32. > 33. num2_term = enif_make_uint(env, num); > 34. new_state_term = enif_make_tuple4(env, key_bin, ivec2_term, ecount2_term, num2_term); > 35. ret = enif_make_tuple2(env, new_state_term, cipher_term); > 36. return ret; > 37. } Just a random guess really, but your key_bin doesn't seem to be a proper term suitable for returning to Erlang, shoudln't you run enif_make_binary() on it? The compiler should warn you about that too, unless ERL_NIF_TERM is something hopelessly vague like "void *"... Regards, -- Jachym From bo.zhang86@REDACTED Thu Apr 28 12:55:29 2011 From: bo.zhang86@REDACTED (zhangbo) Date: Thu, 28 Apr 2011 18:55:29 +0800 Subject: [erlang-questions] about multi process performance and single process performance on mnesia Message-ID: <61703FA9-1312-42B6-B1B6-2D5D0B3A2DF0@gmail.com> Hi all, I caught some problems about mensia, here: 1, how about multi process performance on mnesia vs single process performance on it ? 2, I remember mnesia will deal requests in sequence, is it right ? 3, what's the general solution about concurrent write operation on mnesia ? thanks. email: bo.zhang86@REDACTED From ulf.wiger@REDACTED Thu Apr 28 13:23:46 2011 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Thu, 28 Apr 2011 13:23:46 +0200 Subject: [erlang-questions] about multi process performance and single process performance on mnesia In-Reply-To: <61703FA9-1312-42B6-B1B6-2D5D0B3A2DF0@gmail.com> References: <61703FA9-1312-42B6-B1B6-2D5D0B3A2DF0@gmail.com> Message-ID: On 28 Apr 2011, at 12:55, zhangbo wrote: > Hi all, > I caught some problems about mensia, here: > 1, how about multi process performance on mnesia vs single process performance on it ? Mnesia does have some issues regarding scalability on multi-core. There are a few sequential bottlenecks (activity logging, the lock manager, etc) that limit scalability, but mnesia does run faster on SMP than on non-SMP. > 2, I remember mnesia will deal requests in sequence, is it right ? There are some things that are serialised, but mnesia does as much as it can in parallel. For one thing, the central processes in mnesia are predominately non-blocking, so interleaving is pretty efficient without unnecessary waits. > 3, what's the general solution about concurrent write operation on mnesia ? Each process does as much of the work as it can, before asking the transaction manager to commit changes. For example, when doing a dirty write, the calling process performs the meta-data lookups before letting the transaction manager perform the actual update. For transactions, each process maintains the transaction store and involves the lock manger and transaction manager as needed. BR, Ulf W Ulf Wiger, CTO, Erlang Solutions, Ltd. http://erlang-solutions.com From alex.arnon@REDACTED Thu Apr 28 14:21:33 2011 From: alex.arnon@REDACTED (Alex Arnon) Date: Thu, 28 Apr 2011 15:21:33 +0300 Subject: [erlang-questions] Erlang VM: how clean is our memory? In-Reply-To: <201104281144.53435.clist@uah.es> References: <201104281144.53435.clist@uah.es> Message-ID: Like this, for instance (presentation from 2004, many additions made since then :) ): http://www.openbsd.org/papers/auug04/index.html Zeroed pages (common for all BSDs, I think) are created in the background by the kernel. It always ensures that sbrk() and equivalent will provide the user process with a zeroed-out page. All these "tricks" make OpenBSD somewhat heavier, but very very secure by default. On Thu, Apr 28, 2011 at 12:44 PM, Angel Alvarez wrote: > El Jueves, 28 de Abril de 2011 10:46:59 Alex Arnon escribi?: > > Hi All, > > > > We've recently been discussing the security of OS and VM stacks here, and > > several questions came up with regards to the Erlang VM. Specifically, > the > > values of "new" and "old" memory. > > As an example, take the OpenBSD Unix-like OS. These guys are fanatics for > > security, and take various steps to ensure that the system is as > unbreakable > > as possible, and in the event of breakage - to make life hard (if not > > impossible) for the intruder. > > This includes: > > - Randomization of integer handles, e.g. accepted socket ports. > > - Randomization of memory mapping location, e.g. DLLs (SO) will be loaded > in > > random locations in memory. > > I thougth that the famous kdeinit trick make kde apps inherit all kde libs > at the same memory mapping to save pages > > How does this stuff behave on OpenBSD? > > > - Newly mapped memory pages are always zeroed before attachment to a > > process's virtual space. > > - Swap can be encrypted, or zeroed, on the fly. > > - The memory allocator also zeroes out freed space. > > > > In the context of the Erlang BEAM VM, we're interested in the contents of > > memory. What happens, for instance, when: > > - A process is garbage collected. > > - A process is terminated. > > Are the memory locations that have been "cleaned", zeroed out? Is it is, > is > > it possible to control it? > > > > > > Regards, > > Alex. > > > > > > -- > Este correo no tiene dibujos. Las formas extra?as en la pantalla son > letras. > __________________________________________ > > Clist UAH a.k.a Angel AT uah DOT es > > Angel Alvarez , Servicios Inform?ticos > Edificio Torre de Control, Campus Externo UAH > Alcal? de Henares 28806, Madrid > ** ESPA?A ** > __________________________________________ > Hoy no has conseguido la iluminaci?n divina. No importa ma??na ser? otro > d?a... > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From sverker@REDACTED Thu Apr 28 14:48:31 2011 From: sverker@REDACTED (Sverker Eriksson) Date: Thu, 28 Apr 2011 14:48:31 +0200 Subject: [erlang-questions] NIF Problem In-Reply-To: <20110428100711.GA672@hanele.lan> References: <20110428100711.GA672@hanele.lan> Message-ID: <4DB9621F.1040306@erix.ericsson.se> Jachym Holecek wrote: > # Travis Jensen 2011-04-28: > >> [... This results in SIGBUS after returning to Erlang ...] >> >> 1. static ERL_NIF_TERM aes_ctr_encrypt_with_state(ErlNifEnv* env, int argc, const ERL_NIF_TERM >> argv[]) >> 2. {/* ({Key, IVec, ECount, Num}, Data) */ >> 3. ErlNifBinary key_bin, ivec_bin, text_bin, ecount_bin; >> >> : >> 34. new_state_term = enif_make_tuple4(env, key_bin, ivec2_term, ecount2_term, num2_term); >> 35. ret = enif_make_tuple2(env, new_state_term, cipher_term); >> 36. return ret; >> 37. } >> > > Just a random guess really, but your key_bin doesn't seem to be a proper term > suitable for returning to Erlang, shoudln't you run enif_make_binary() on it? > The compiler should warn you about that too, unless ERL_NIF_TERM is something > hopelessly vague like "void *"... > > Regards, > -- Jachym > > Nicely spotted, Jachym. The reason the compiler did not complain is that enif_make_tuple4 is a macro calling variadic function enif_make_tuple(ErlNifEnv*, ...). A patch turning enif_make_tuple# and enif_make_list# into inline functions (if compiler supports it) would probably be a good idea. Any takers? /Sverker, Erlang/OTP From alex.arnon@REDACTED Thu Apr 28 15:02:30 2011 From: alex.arnon@REDACTED (Alex Arnon) Date: Thu, 28 Apr 2011 16:02:30 +0300 Subject: [erlang-questions] Erlang VM: how clean is our memory? In-Reply-To: <572745F0-0705-4773-837C-6358BAC89780@erlang-solutions.com> References: <572745F0-0705-4773-837C-6358BAC89780@erlang-solutions.com> Message-ID: What interests me, beyond what "the allocator" does, is what happens when a process's heap is garbage collected. To take a more specific example - let's say I have a sensitive small binary, e.g. a credit card number. Though there should be little to no real risk from memory snoopers, I'd like the memory space it would have occupied to have been cleared when I'm done with it - i.e., zero out free space after GC. This would make me feel a bit more secure in the face of third-party modules (though yes, port programs are the preferred way to go). On Thu, Apr 28, 2011 at 12:07 PM, Ulf Wiger wrote: > > I think a good starting point is to meditate over this page: > http://www.erlang.org/doc/man/erts_alloc.html > > It seems to me that it would be _possible_ (with some work) to make use of > the +Mym flag, substituting another malloc library for libc. In the old > days, with non-SMP Erlang, this was entirely doable, and we played around > with different allocators in the AXD 301 project, in order to see which one > gave the least fragmentation over time. > > The whole memory management subsystem in BEAM has become a *lot* more > sophisticated since then, but it is designed to be quite configurable. > > For less hand-wavy answers, I refer to the actual experts on the subject. > :) > > BR, > Ulf > > On 28 Apr 2011, at 10:46, Alex Arnon wrote: > > Hi All, > > We've recently been discussing the security of OS and VM stacks here, and > several questions came up with regards to the Erlang VM. Specifically, the > values of "new" and "old" memory. > As an example, take the OpenBSD Unix-like OS. These guys are fanatics for > security, and take various steps to ensure that the system is as unbreakable > as possible, and in the event of breakage - to make life hard (if not > impossible) for the intruder. > This includes: > - Randomization of integer handles, e.g. accepted socket ports. > - Randomization of memory mapping location, e.g. DLLs (SO) will be loaded > in random locations in memory. > - Newly mapped memory pages are always zeroed before attachment to a > process's virtual space. > - Swap can be encrypted, or zeroed, on the fly. > - The memory allocator also zeroes out freed space. > > In the context of the Erlang BEAM VM, we're interested in the contents of > memory. What happens, for instance, when: > - A process is garbage collected. > - A process is terminated. > Are the memory locations that have been "cleaned", zeroed out? Is it is, is > it possible to control it? > > > Regards, > Alex. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > > Ulf Wiger, CTO, Erlang Solutions, Ltd. > http://erlang-solutions.com > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From attila.r.nohl@REDACTED Thu Apr 28 15:38:23 2011 From: attila.r.nohl@REDACTED (Attila Rajmund Nohl) Date: Thu, 28 Apr 2011 15:38:23 +0200 Subject: [erlang-questions] Erlang VM: how clean is our memory? In-Reply-To: References: <572745F0-0705-4773-837C-6358BAC89780@erlang-solutions.com> Message-ID: 2011/4/28, Alex Arnon : > What interests me, beyond what "the allocator" does, is what happens when a > process's heap is garbage collected. > To take a more specific example - let's say I have a sensitive small binary, > e.g. a credit card number. Though there should be little to no real risk > from memory snoopers, I'd like the memory space it would have occupied to > have been cleared when I'm done with it - i.e., zero out free space after > GC. This would make me feel a bit more secure in the face of third-party > modules (though yes, port programs are the preferred way to go). I think the security threat in C would be that malicious other code allocated some memory and the credit card number would be there. I think in Erlang you can't allocate memory without initializing it - the closest is the unbound variable, but the emulator throws an exception upon accessing unbound variables. On the other hand, the Erlang VM provides great tracing features. If that credit card number is passed to a function (or a list comprehension) and the attacker knows the module name of that function, he can setup trace and see the credit card number... From mihai@REDACTED Thu Apr 28 16:04:32 2011 From: mihai@REDACTED (Mihai Balea) Date: Thu, 28 Apr 2011 10:04:32 -0400 Subject: [erlang-questions] Erlang VM: how clean is our memory? In-Reply-To: References: <572745F0-0705-4773-837C-6358BAC89780@erlang-solutions.com> Message-ID: On Apr 28, 2011, at 9:38 AM, Attila Rajmund Nohl wrote: > > I think the security threat in C would be that malicious other code > allocated some memory and the credit card number would be there. I > think in Erlang you can't allocate memory without initializing it - > the closest is the unbound variable, but the emulator throws an > exception upon accessing unbound variables. > > On the other hand, the Erlang VM provides great tracing features. If > that credit card number is passed to a function (or a list > comprehension) and the attacker knows the module name of that > function, he can setup trace and see the credit card number... I think that if attackers have access to the Erlang VM's memory space, then it's game over, they can get to anything. But I believe the OP was concerned about memory pages released by the VM that, if not properly scrubbed, would allow somebody from outside the VM to glean info Mihai -------------- next part -------------- An HTML attachment was scrubbed... URL: From alex.arnon@REDACTED Thu Apr 28 17:50:56 2011 From: alex.arnon@REDACTED (Alex Arnon) Date: Thu, 28 Apr 2011 18:50:56 +0300 Subject: [erlang-questions] Erlang VM: how clean is our memory? In-Reply-To: References: <572745F0-0705-4773-837C-6358BAC89780@erlang-solutions.com> Message-ID: Thanks guys. Attilla, on further reflection, I completely agree that it's all rather weak - if anyone has access to the VM facilities, it probably is game over anyways. Mihai - that is indeed a worry, in general. However, in case of such applications I'd hope I would have sufficient control over the deployment platform... On Thu, Apr 28, 2011 at 5:04 PM, Mihai Balea wrote: > > On Apr 28, 2011, at 9:38 AM, Attila Rajmund Nohl wrote: > > > I think the security threat in C would be that malicious other code > allocated some memory and the credit card number would be there. I > think in Erlang you can't allocate memory without initializing it - > the closest is the unbound variable, but the emulator throws an > exception upon accessing unbound variables. > > On the other hand, the Erlang VM provides great tracing features. If > that credit card number is passed to a function (or a list > comprehension) and the attacker knows the module name of that > function, he can setup trace and see the credit card number... > > > I think that if attackers have access to the Erlang VM's memory space, then > it's game over, they can get to anything. > But I believe the OP was concerned about memory pages released by the VM > that, if not properly scrubbed, would allow somebody from outside the VM to > glean info > > Mihai > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf.wiger@REDACTED Thu Apr 28 18:09:51 2011 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Thu, 28 Apr 2011 18:09:51 +0200 Subject: [erlang-questions] regexp:sh_to_awk/1 deprecated? Message-ID: <8C9D0F76-85CC-4F9F-BF51-28D9DD24922C@erlang-solutions.com> Given the following compiler warning: Warning: regexp:sh_to_awk/1: the regexp module is deprecated (will be removed in R15A); use the re module instead ?can I expect a re:sh_to_awk/1 to appear in the future, or is this function simply going to disappear? BR, Ulf W Ulf Wiger, CTO, Erlang Solutions, Ltd. http://erlang-solutions.com From spawn.think@REDACTED Thu Apr 28 18:20:09 2011 From: spawn.think@REDACTED (Ahmed Omar) Date: Thu, 28 Apr 2011 18:20:09 +0200 Subject: [erlang-questions] regexp:sh_to_awk/1 deprecated? In-Reply-To: <8C9D0F76-85CC-4F9F-BF51-28D9DD24922C@erlang-solutions.com> References: <8C9D0F76-85CC-4F9F-BF51-28D9DD24922C@erlang-solutions.com> Message-ID: I think the warning is generated by default to ANY function in the module regexp with no exceptions, but we need someone from OTP to tell us about the plan if there will be a replacement in re On Thu, Apr 28, 2011 at 6:09 PM, Ulf Wiger wrote: > > Given the following compiler warning: > > Warning: regexp:sh_to_awk/1: the regexp module is deprecated (will be > removed in R15A); use the re module instead > > ?can I expect a re:sh_to_awk/1 to appear in the future, or is this function > simply going to disappear? > > BR, > Ulf W > > Ulf Wiger, CTO, Erlang Solutions, Ltd. > http://erlang-solutions.com > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -- Best Regards, - Ahmed Omar http://nl.linkedin.com/in/adiaa Follow me on twitter @spawn_think -------------- next part -------------- An HTML attachment was scrubbed... URL: From kostis@REDACTED Thu Apr 28 18:26:02 2011 From: kostis@REDACTED (Kostis Sagonas) Date: Thu, 28 Apr 2011 19:26:02 +0300 Subject: [erlang-questions] byte() vs. char() use in documentation Message-ID: <4DB9951A.4050005@cs.ntua.gr> In the Erlang documentation, the language of types and specs makes a clear distinction between the following two types: byte() :: 0..255 char() :: 0..16#10ffff See http://erlang.org/doc/reference_manual/typespec.html#id72693 I think that nowadays there are very good reasons to have this distinction. In trying to fix a bug today, I happened to notice that some key types of Erlang are inconsistent with this view in the Erlang/OTP documentation (In http://erlang.org/doc/man/erlang.html), most notably: iolist() :: [char() | binary() | iolist()] binary_to_list(Binary) -> [char()] binary_to_list(Binary, Start, Stop) -> [char()] bitstring_to_list(Bitstring) -> [char()|bitstring()] and: BitstringList :: [BitstringList | bitstring() | char()] which actually triggered this mail. I think all the occurrences of char() above should read byte() instead. Right? If yes, could somebody at OTP (or some kind volunteer) please clean up this mess? (I can provide a fix for the documentation of the 'erlang' module if you want me to.) Kostis From travis.jensen@REDACTED Thu Apr 28 20:01:38 2011 From: travis.jensen@REDACTED (Travis Jensen) Date: Thu, 28 Apr 2011 12:01:38 -0600 Subject: [erlang-questions] NIF Problem In-Reply-To: <20110428100711.GA672@hanele.lan> References: <20110428100711.GA672@hanele.lan> Message-ID: On Thu, Apr 28, 2011 at 4:07 AM, Jachym Holecek wrote: > > Just a random guess really, but your key_bin doesn't seem to be a proper > term > suitable for returning to Erlang, shoudln't you run enif_make_binary() on > it? > The compiler should warn you about that too, unless ERL_NIF_TERM is > something > hopelessly vague like "void *"... > > Regards, > -- Jachym > That was a really good random guess. :) Replaced that with the term passed in (since it doesn't change) and it worked perfectly. Thanks for your sharp eyes! tj -- *Travis Jensen* *** *Read the Software Maven @ http://softwaremaven.innerbrane.com/ Read my LinkedIn profile @ http://www.linkedin.com/in/travisjensen Read my Twitter mumblings @ http://twitter.com/SoftwareMaven Send me email @ travis.jensen@REDACTED **What kind of guy calls himself the Software Maven???** -------------- next part -------------- An HTML attachment was scrubbed... URL: From sumasai.shivaprasad@REDACTED Thu Apr 28 20:13:30 2011 From: sumasai.shivaprasad@REDACTED (Suma Shivaprasad) Date: Thu, 28 Apr 2011 23:43:30 +0530 Subject: [erlang-questions] httpc manager crashes In-Reply-To: References: Message-ID: Hi, We are using inets - 5.5.1 and HTTP/1.1. We are creating a new httpc profile for every request that we make and around 300 concurrent requests were running at the same time . Is this fine? How many maximum profiles has httpc been tested with for concurrent use? Thanks Suma On Thu, Apr 28, 2011 at 2:53 PM, Ingela Andin wrote: > Hi! > > What version of inets and Erlang are you using? What HTTP version HTTP-1.0 > ? > If there is a bug we will of course fix it. > > Regards Ingela Erlang/OTP - Ericsson AB > > > 2011/4/27 Suma Shivaprasad : > > We have an app that makes a lot of calls to httpc and we are seeing the > > following error in sasl logs quite often. > > > > CRASH REPORT==== 27-Apr-2011::05:21:24 === > > crasher: > > initial call: httpc_manager:init/1 > > pid: <0.10297.0> > > registered_name: httpc_manager_profile_8261 > > exception exit: {{case_clause, > > [{handler_info,#Ref<0.0.398.166371>,undefined, > > <0.12971.248>,undefined,operational}]}, > > [{httpc_manager,handle_connect_and_send,5}, > > {httpc_manager,handle_info,2}, > > {gen_server,handle_msg,5}, > > {proc_lib,init_p_do_apply,3}]} > > in function gen_server:terminate/6 > > ancestors: [httpc_profile_sup,httpc_sup,inets_sup,<0.46.0> > > > > > > > > and > > > > > > =CRASH REPORT==== 27-Apr-2011::05:30:18 === > > crasher: > > initial call: httpc_manager:init/1 > > pid: <0.22933.12> > > registered_name: httpc_manager_profile_8122 > > exception exit: {{case_clause, > > > [{handler_info,#Ref<0.0.418.148452>,<0.20608.257>, > > undefined,<0.15267.257>,initiating}]}, > > [{httpc_manager,handle_connect_and_send,5}, > > {httpc_manager,handle_info,2}, > > {gen_server,handle_msg,5}, > > {proc_lib,init_p_do_apply,3}]} > > in function gen_server:terminate/6 > > ancestors: [httpc_profile_sup,httpc_sup,inets_sup,<0.46.0>] > > messages: [{'EXIT',<0.20574.257>,normal}] > > links: [<0.50.0>,<0.20608.257>] > > dictionary: [] > > > > > > Has anyone else seen these errors or have a fix for this? > > > > Thanks > > Suma > > > > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From gregory.haskins@REDACTED Thu Apr 28 22:05:23 2011 From: gregory.haskins@REDACTED (Gregory Haskins) Date: Thu, 28 Apr 2011 16:05:23 -0400 Subject: [erlang-questions] Question about gproc and "wildcards" Message-ID: <4DB9C883.4030602@gmail.com> Greetings Ulf, all, Question about gproc. I am using gproc in a variety of ways, one of which is as a pub/sub mechanism as advertised in the readme.md (see: https://github.com/ghaskins/edist/blob/master/lib/src/main/erlang/edist_event_bus.erl as an example). What I am wondering is, is there a way to "subscribe" to something with wildcards? For instance, can I say "subscribe({interesting_event, '_'})" such that I would get notifications for notify({interesting_event, foo}) as well as notify({interesting_event, bar}) I am a bit unclear if or how this could be done. Thanks! -Greg -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 267 bytes Desc: OpenPGP digital signature URL: From travis.jensen@REDACTED Thu Apr 28 23:11:47 2011 From: travis.jensen@REDACTED (Travis Jensen) Date: Thu, 28 Apr 2011 15:11:47 -0600 Subject: [erlang-questions] Can't compile tests Message-ID: I'm getting this error when trying to compile tests: make RELEASE_PATH=/Users/travis/src2/foss/erlang-otp/release/tests release_tests_spec erlc -W +debug_info -o./ et_wx_SUITE.erl ./et_test_lib.hrl:19: can't find include lib "wx/include/wx.hrl" make[2]: *** [et_wx_SUITE.beam] Error 1 make[1]: *** [release_tests] Error 2 make: *** [lib/et/test] Error 2 I've tried both "otp_build tests" and "make release_tests" (from $ERL_TOP). I'm wondering if I'm missing an environment variable or something. Thanks. tj -- *Travis Jensen* *** *Read the Software Maven @ http://softwaremaven.innerbrane.com/ Read my LinkedIn profile @ http://www.linkedin.com/in/travisjensen Read my Twitter mumblings @ http://twitter.com/SoftwareMaven Send me email @ travis.jensen@REDACTED **What kind of guy calls himself the Software Maven???** -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf.wiger@REDACTED Thu Apr 28 23:12:12 2011 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Thu, 28 Apr 2011 23:12:12 +0200 Subject: [erlang-questions] Question about gproc and "wildcards" In-Reply-To: <4DB9C883.4030602@gmail.com> References: <4DB9C883.4030602@gmail.com> Message-ID: <15B444C8-1261-437B-9714-8A6B31A6C377@erlang-solutions.com> Hi Greg, I hadn't really thought of it before, but perhaps something like this: Eshell V5.8.4 (abort with ^G) 1> application:start(gproc). ok 2> Loop = fun(L) -> receive M -> io:fwrite("~p <- ~p~n", [self(),M]) end, L(L) end. #Fun 3> P1 = spawn(fun() -> gproc:reg({p,l,my_event}, [a,b]), Loop(Loop) end). <0.40.0> 4> P2 = spawn(fun() -> gproc:reg({p,l,my_event}, any), Loop(Loop) end). <0.42.0> 5> Notify = fun(X) -> qlc:e(qlc:q([P ! {my_event,X} || {{p,l,my_event},P,V} <- gproc:table(props), V==any orelse (is_list(V) andalso lists:member(X,V))])) end. #Fun 6> Notify(a). <0.40.0> <- {my_event,a} <0.42.0> <- {my_event,a} [{my_event,a},{my_event,a}] 7> Notify(c). [{my_event,c}] <0.42.0> <- {my_event,c} BR, Ulf On 28 Apr 2011, at 22:05, Gregory Haskins wrote: > Greetings Ulf, all, > > Question about gproc. I am using gproc in a variety of ways, one of > which is as a pub/sub mechanism as advertised in the readme.md (see: > https://github.com/ghaskins/edist/blob/master/lib/src/main/erlang/edist_event_bus.erl > as an example). > > What I am wondering is, is there a way to "subscribe" to something with > wildcards? > > For instance, can I say "subscribe({interesting_event, '_'})" such that > I would get notifications for > > notify({interesting_event, foo}) > > as well as > > notify({interesting_event, bar}) > > I am a bit unclear if or how this could be done. > > Thanks! > -Greg > Ulf Wiger, CTO, Erlang Solutions, Ltd. http://erlang-solutions.com From rholmes777@REDACTED Thu Apr 28 23:24:01 2011 From: rholmes777@REDACTED (rholmes) Date: Thu, 28 Apr 2011 14:24:01 -0700 (PDT) Subject: [erlang-questions] Erlang/OTP R14B02 generating documentation from source problem In-Reply-To: References: <4D81E7BB.8090802@gmail.com> <311465162.73841300359543943.JavaMail.root@zimbra> Message-ID: <1304025841404-3482255.post@n4.nabble.com> bsmr wrote: > > Could You please say, which OS You use? > > I reported this "strange behavior" for Ubuntu 10.04 / 10.10 some time ago. > > See http://www.erlang.org/faq.html > Just for the record, I experienced the same problem on Macintosh (OS X 10.6.7 "Snow Leopard") -- the workaround was the same as Kasuhiro Ogura described. Other than Java running out of memory a few times (?!?!) both the executable and the document install went great and I'm having fun with the language! -- View this message in context: http://erlang.2086793.n4.nabble.com/Erlang-OTP-R14B02-has-been-released-tp3381915p3482255.html Sent from the Erlang Questions mailing list archive at Nabble.com. From joaohf@REDACTED Fri Apr 29 01:36:58 2011 From: joaohf@REDACTED (=?UTF-8?Q?Jo=C3=A3o_Henrique_Freitas?=) Date: Thu, 28 Apr 2011 20:36:58 -0300 Subject: [erlang-questions] snmp application Message-ID: Hi, I am writing a litle snmp (manager) application. Is otp_src_R14B02/lib/snmp/example/ex2 a good start point? Thanks. -- ----------------------------------------------------------- Jo?o Henrique Freitas - joaohf_at_gmail.com Campinas-SP-Brasil BSD051283 LPI 1 http://www.joaohfreitas.eti.br From silent_vendetta@REDACTED Fri Apr 29 05:35:36 2011 From: silent_vendetta@REDACTED (Chris Hicks) Date: Thu, 28 Apr 2011 20:35:36 -0700 Subject: [erlang-questions] Can't shut down Mnesia from within application In-Reply-To: References: Message-ID: Hello all, I've got an application which, in it's start function, calls mnesia:start() before starting the top level supervisor. The only thing I'm doing with Mnesia at the moment is working with a single ram-copies table. In the stop function of the same application I call mnesia:stop(). At that point I shouldn't have any transactions or anything going on, but Mnesia simply hangs and I can't do anything but shut the Erlang VM down and restart it again. Any ideas what might be going on or where I should look? Chris Hicks. -------------- next part -------------- An HTML attachment was scrubbed... URL: From seth@REDACTED Fri Apr 29 06:40:55 2011 From: seth@REDACTED (Seth Falcon) Date: Thu, 28 Apr 2011 21:40:55 -0700 Subject: [erlang-questions] Can't compile tests In-Reply-To: References: Message-ID: Hi Travis, You didn't mention what platform you are running on. Based on your RELEASE_PATH and the wx related errors, I think OS X is a good bet :-) On Thu, Apr 28, 2011 at 2:11 PM, Travis Jensen wrote: > I'm getting this error when trying to compile tests: > make ?RELEASE_PATH=/Users/travis/src2/foss/erlang-otp/release/tests > release_tests_spec > erlc -W ?+debug_info -o./ et_wx_SUITE.erl > ./et_test_lib.hrl:19: can't find include lib "wx/include/wx.hrl" > make[2]: *** [et_wx_SUITE.beam] Error 1 > make[1]: *** [release_tests] Error 2 > make: *** [lib/et/test] Error 2 > I've tried both "otp_build tests" and "make release_tests" (from $ERL_TOP). > ?I'm wondering if I'm missing an environment variable or something. There are problems getting Erlang's wx modules to build on Snow Leopard. For example, if you have installed via Homebrew, your build will have omitted wx. A downside of this is that there are a number of tests that depend on wx. If you want to run the tests, you can hunt down the tests wanting wx by temporarily moving them out of the way. I've done this before, there are a handful, but not so many to make it terrible. Perhaps there is a more elegant way to handle this. + seth -- Seth Falcon | @sfalcon | http://userprimary.net/ From silent_vendetta@REDACTED Fri Apr 29 06:50:33 2011 From: silent_vendetta@REDACTED (Chris Hicks) Date: Thu, 28 Apr 2011 21:50:33 -0700 Subject: [erlang-questions] Can't shut down Mnesia from within application In-Reply-To: References: , Message-ID: I forgot to mention that if I comment out mnesia:stop() from the stop function of the app so that it looks like this: stop(_State) -> %% mnesia:stop(), ok. the app shuts down perfectly fine. I can then enter mnesia:stop() into the console and it will immediately shut down as if nothing is wrong. The freezing up only happens when I try to call mnesia:stop() (or application:stop(mnesia)) from within the applications stop function. From: silent_vendetta@REDACTED To: erlang-questions@REDACTED Date: Thu, 28 Apr 2011 20:35:36 -0700 Subject: [erlang-questions] Can't shut down Mnesia from within application Hello all, I've got an application which, in it's start function, calls mnesia:start() before starting the top level supervisor. The only thing I'm doing with Mnesia at the moment is working with a single ram-copies table. In the stop function of the same application I call mnesia:stop(). At that point I shouldn't have any transactions or anything going on, but Mnesia simply hangs and I can't do anything but shut the Erlang VM down and restart it again. Any ideas what might be going on or where I should look? Chris Hicks. _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From garazdawi@REDACTED Fri Apr 29 08:50:48 2011 From: garazdawi@REDACTED (Lukas Larsson) Date: Fri, 29 Apr 2011 08:50:48 +0200 Subject: [erlang-questions] Can't shut down Mnesia from within application In-Reply-To: References: Message-ID: Mnesia:stop sends a call message to the application process to stop. That process is busy shutting down your application and thus a deadlock happens. On Apr 29, 2011 6:50 AM, "Chris Hicks" wrote: > > I forgot to mention that if I comment out mnesia:stop() from the stop function of the app so that it looks like this: > stop(_State) -> %% mnesia:stop(), ok. > the app shuts down perfectly fine. I can then enter mnesia:stop() into the console and it will immediately shut down as if nothing is wrong. The freezing up only happens when I try to call mnesia:stop() (or application:stop(mnesia)) from within the applications stop function. > From: silent_vendetta@REDACTED > To: erlang-questions@REDACTED > Date: Thu, 28 Apr 2011 20:35:36 -0700 > Subject: [erlang-questions] Can't shut down Mnesia from within application > > > > > > > > > Hello all, > I've got an application which, in it's start function, calls mnesia:start() before starting the top level supervisor. The only thing I'm doing with Mnesia at the moment is working with a single ram-copies table. In the stop function of the same application I call mnesia:stop(). At that point I shouldn't have any transactions or anything going on, but Mnesia simply hangs and I can't do anything but shut the Erlang VM down and restart it again. Any ideas what might be going on or where I should look? > Chris Hicks. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From silent_vendetta@REDACTED Fri Apr 29 08:59:37 2011 From: silent_vendetta@REDACTED (Chris Hicks) Date: Thu, 28 Apr 2011 23:59:37 -0700 Subject: [erlang-questions] Can't shut down Mnesia from within application In-Reply-To: References: , , , Message-ID: Always the little things. Didn't even think about the sequential nature of the application process. Thank you to to everyone who responded here and privately. My head and my desk no longer have to fear each other. Chris Hicks. Date: Fri, 29 Apr 2011 08:50:48 +0200 Subject: Re: [erlang-questions] Can't shut down Mnesia from within application From: garazdawi@REDACTED To: silent_vendetta@REDACTED CC: erlang-questions@REDACTED Mnesia:stop sends a call message to the application process to stop. That process is busy shutting down your application and thus a deadlock happens. On Apr 29, 2011 6:50 AM, "Chris Hicks" wrote: > > I forgot to mention that if I comment out mnesia:stop() from the stop function of the app so that it looks like this: > stop(_State) -> %% mnesia:stop(), ok. > the app shuts down perfectly fine. I can then enter mnesia:stop() into the console and it will immediately shut down as if nothing is wrong. The freezing up only happens when I try to call mnesia:stop() (or application:stop(mnesia)) from within the applications stop function. > From: silent_vendetta@REDACTED > To: erlang-questions@REDACTED > Date: Thu, 28 Apr 2011 20:35:36 -0700 > Subject: [erlang-questions] Can't shut down Mnesia from within application > > > > > > > > > Hello all, > I've got an application which, in it's start function, calls mnesia:start() before starting the top level supervisor. The only thing I'm doing with Mnesia at the moment is working with a single ram-copies table. In the stop function of the same application I call mnesia:stop(). At that point I shouldn't have any transactions or anything going on, but Mnesia simply hangs and I can't do anything but shut the Erlang VM down and restart it again. Any ideas what might be going on or where I should look? > Chris Hicks. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From ingela@REDACTED Fri Apr 29 09:19:48 2011 From: ingela@REDACTED (Ingela Andin) Date: Fri, 29 Apr 2011 09:19:48 +0200 Subject: [erlang-questions] httpc manager crashes In-Reply-To: References: Message-ID: Hi! A httpc-profile could be view as a "browser core", it saves options that you want to use for all requests such as proxy-options, it handles cookies, it dispatches requests for pipelining or persistent HTTP-connections queues, it could even do caching but that is not implemented at the moment. There is no hard limit on how many profiles you can use, a profile is mainly a new dispatcher process. 300 erlang-processes is no problem at all, but starting a new profile for every request I think is a bit of an odd strategy. Why do you do that? The manager process will spawn a new request-handler process for each request unless it can be pipelined, or if pipelining is not enabled by setting the pipeline timeout and there is a persistent connection that can be used to queue the request on. Length of pipeline and persistent connection-queues are configurable. After the request has been dispatched to the handler process that process will handle the request and send the answer to the client without any synchronizing with the manager process. The manager process should not be very busy so it should not be a big bottleneck and if it gets too busy we might have to change its implementation. We also think we know what is causing your problem and we will fix it as soon as possible. Regards Ingela Erlang/OTP team - Ericsson AB 2011/4/28 Suma Shivaprasad : > Hi, > > We are using inets - 5.5.1 and HTTP/1.1.? We are creating a new httpc > profile for every request that we make and around 300 concurrent requests > were running at the same time . Is this fine?? How many maximum profiles has > httpc been tested with for concurrent use? > > Thanks > Suma > > On Thu, Apr 28, 2011 at 2:53 PM, Ingela Andin > wrote: >> >> Hi! >> >> What version of inets and Erlang are you using? ?What HTTP version >> HTTP-1.0 ? >> If there is a bug we will of course fix it. >> >> Regards Ingela Erlang/OTP - Ericsson AB >> >> >> 2011/4/27 Suma Shivaprasad : >> > We have an app that makes a lot of calls to httpc and we are seeing the >> > following error in sasl logs quite often. >> > >> > CRASH REPORT==== 27-Apr-2011::05:21:24 === >> > ? crasher: >> > ??? initial call: httpc_manager:init/1 >> > ??? pid: <0.10297.0> >> > ??? registered_name: httpc_manager_profile_8261 >> > ??? exception exit: {{case_clause, >> > ???????????????????????? [{handler_info,#Ref<0.0.398.166371>,undefined, >> > ????????????????????????????? <0.12971.248>,undefined,operational}]}, >> > ???????????????????? [{httpc_manager,handle_connect_and_send,5}, >> > ????????????????????? {httpc_manager,handle_info,2}, >> > ????????????????????? {gen_server,handle_msg,5}, >> > ????????????????????? {proc_lib,init_p_do_apply,3}]} >> > ????? in function? gen_server:terminate/6 >> > ??? ancestors: [httpc_profile_sup,httpc_sup,inets_sup,<0.46.0> >> > >> > >> > >> > and >> > >> > >> > =CRASH REPORT==== 27-Apr-2011::05:30:18 === >> > ? crasher: >> > ??? initial call: httpc_manager:init/1 >> > ??? pid: <0.22933.12> >> > ??? registered_name: httpc_manager_profile_8122 >> > ??? exception exit: {{case_clause, >> > >> > [{handler_info,#Ref<0.0.418.148452>,<0.20608.257>, >> > ????????????????????????????? undefined,<0.15267.257>,initiating}]}, >> > ???????????????????? [{httpc_manager,handle_connect_and_send,5}, >> > ????????????????????? {httpc_manager,handle_info,2}, >> > ????????????????????? {gen_server,handle_msg,5}, >> > ????????????????????? {proc_lib,init_p_do_apply,3}]} >> > ????? in function? gen_server:terminate/6 >> > ??? ancestors: [httpc_profile_sup,httpc_sup,inets_sup,<0.46.0>] >> > ??? messages: [{'EXIT',<0.20574.257>,normal}] >> > ??? links: [<0.50.0>,<0.20608.257>] >> > ??? dictionary: [] >> > >> > >> > Has anyone else seen these errors or have a fix for this? >> > >> > Thanks >> > Suma >> > >> > >> > >> > _______________________________________________ >> > erlang-questions mailing list >> > erlang-questions@REDACTED >> > http://erlang.org/mailman/listinfo/erlang-questions >> > >> > > > From kenneth.lundin@REDACTED Fri Apr 29 11:14:34 2011 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Fri, 29 Apr 2011 11:14:34 +0200 Subject: [erlang-questions] regexp:sh_to_awk/1 deprecated? In-Reply-To: References: <8C9D0F76-85CC-4F9F-BF51-28D9DD24922C@erlang-solutions.com> Message-ID: Hi, Our current intention is that the function sh_to_awk/1 dissapears together with all the other functions in the regexp module. Is it really someone who uses sh_to_awk/1? I don't think it is particularly well known and I think the name is misleading. There are also the wildcard/1 and wildcard/2 functions in filelib that do what you usually want, i.e. matching file names. So, unless you really convince us with really good arguments we intend to remove sh_to_awk/1. /Kenneth, Erlang/OTP, Ericsson On Thu, Apr 28, 2011 at 6:20 PM, Ahmed Omar wrote: > I think the warning is generated by default to ANY function in the module > regexp with no exceptions, but we need someone from OTP to tell us about the > plan if there will be a replacement in re > > On Thu, Apr 28, 2011 at 6:09 PM, Ulf Wiger > wrote: >> >> Given the following compiler warning: >> >> Warning: regexp:sh_to_awk/1: the regexp module is deprecated (will be >> removed in R15A); use the re module instead >> >> ?can I expect a re:sh_to_awk/1 to appear in the future, or is this >> function simply going to disappear? >> >> BR, >> Ulf W >> >> Ulf Wiger, CTO, Erlang Solutions, Ltd. >> http://erlang-solutions.com >> >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions > > > > -- > Best Regards, > - Ahmed Omar > http://nl.linkedin.com/in/adiaa > Follow me on twitter > @spawn_think > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > From max.lapshin@REDACTED Fri Apr 29 13:36:51 2011 From: max.lapshin@REDACTED (Max Lapshin) Date: Fri, 29 Apr 2011 15:36:51 +0400 Subject: [erlang-questions] Proper tool for parsing config Message-ID: I'm thinking about switching erlyvideo config from common proplist to something like nginx config. Which tool is best nowadays to parse such configs: xrl + yrl or something like neotoma? From freza@REDACTED Fri Apr 29 14:03:33 2011 From: freza@REDACTED (Jachym Holecek) Date: Fri, 29 Apr 2011 13:03:33 +0100 Subject: [erlang-questions] Proper tool for parsing config In-Reply-To: References: Message-ID: <20110429120333.GA2877@hanele.lan> # Max Lapshin 2011-04-29: > I'm thinking about switching erlyvideo config from common proplist to > something like nginx config. I know this doesn't answer your real question, but: I think this is an extremely bad idea. Keeping configuration as simple Erlang terms that you can file:consult/1 on (and it's nowhere written it needs to be just a proplist!) is just so convenient that I don't see what could possibly motivate you to abandoning it... Besides, there's already way too many completely random & ad-hoc & lame & ugly configuration formats in the industry that are mutually incompatible and impossible to machine-process correctly and impossible to remember the right syntax for, why would you want to introduce yet another one? Oh well, just my -2p I guess. Regards, -- Jachym From antoine.koener@REDACTED Fri Apr 29 14:26:48 2011 From: antoine.koener@REDACTED (Antoine Koener) Date: Fri, 29 Apr 2011 14:26:48 +0200 Subject: [erlang-questions] Proper tool for parsing config In-Reply-To: <20110429120333.GA2877@hanele.lan> References: <20110429120333.GA2877@hanele.lan> Message-ID: <4AD0823E-4FE9-4238-B187-368A8F3F3131@gmail.com> On Apr 29, 2011, at 14:03 , Jachym Holecek wrote: > # Max Lapshin 2011-04-29: >> I'm thinking about switching erlyvideo config from common proplist to >> something like nginx config. > > I know this doesn't answer your real question, but: I think this is an > extremely bad idea. Keeping configuration as simple Erlang terms that > you can file:consult/1 on (and it's nowhere written it needs to be > just > a proplist!) is just so convenient that I don't see what could > possibly > motivate you to abandoning it... Besides, there's already way too many > completely random & ad-hoc & lame & ugly configuration formats in the > industry that are mutually incompatible and impossible to machine- > process > correctly and impossible to remember the right syntax for, why would > you > want to introduce yet another one? > I totally agree, but if you want, you can also make a converter for 'horrible but widely used' config file format to erlang config. Then I could still use erlyvideo with the erlang syntax but introduce it to my friends whom thinks that 'horrible but widely used' format is really cool. > Oh well, just my -2p I guess. > > Regards, > -- Jachym > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From arun.suresh@REDACTED Fri Apr 29 14:59:03 2011 From: arun.suresh@REDACTED (Arun Suresh) Date: Fri, 29 Apr 2011 18:29:03 +0530 Subject: [erlang-questions] httpc manager crashes In-Reply-To: References: Message-ID: Helo Ingela I am Suma's colleague. Let me try to give more context to the issue we are facing.. * Our app make a LOT (in the range of around 300) of http requests concurrently. * There are two types of requests 1) POST requests : These require us to go thru a proxy. These can themselves hit about 150 - 200concurrent requests. 2) GET requests : Standard http requests. As far as the GET requests are concerned, we start some 300 profiles and randomly pick one for use. Since we have to send our POSTs via a proxy, at app initialialization time, we start 1 httpc profile. We see a lot of httpc_manager crashes pertaining to this particular profile. I understand that the httpc_manager is supposed to be a pretty light weight process.. not requiring any synchronization with the manager.. Is there a chance that the httpc_manager can crash ? Also, I was wondering, is the Data to be posted also copied to the httpc_managers message queue before its again copied to the handlers message queue before actually sending ? Regards -Arun On Fri, Apr 29, 2011 at 12:49 PM, Ingela Andin wrote: > Hi! > > A httpc-profile could be view as a "browser core", it saves options > that you want to use for all requests such as proxy-options, > it handles cookies, it dispatches requests for pipelining or > persistent HTTP-connections queues, it could even do caching but that > is not implemented at the moment. There is no hard limit on how many > profiles you can use, a profile is mainly a new dispatcher process. > 300 erlang-processes is no problem at all, but starting a new profile > for every request I think is a bit of an odd strategy. Why do you do > that? The manager process will spawn a new request-handler process for > each request unless it can be pipelined, or if pipelining is not > enabled by setting the pipeline timeout and there is a persistent > connection that can be used to queue the request on. Length of > pipeline and persistent > connection-queues are configurable. After the request has been > dispatched to the handler process that process will handle the request > and send the answer to the client without any synchronizing with the > manager process. The manager process should not be very busy so it > should not be a big bottleneck and if it gets too busy we might have > to change its implementation. > > We also think we know what is causing your problem and we will fix it > as soon as possible. > > Regards Ingela Erlang/OTP team - Ericsson AB > > > 2011/4/28 Suma Shivaprasad : > > Hi, > > > > We are using inets - 5.5.1 and HTTP/1.1. We are creating a new httpc > > profile for every request that we make and around 300 concurrent requests > > were running at the same time . Is this fine? How many maximum profiles > has > > httpc been tested with for concurrent use? > > > > Thanks > > Suma > > > > On Thu, Apr 28, 2011 at 2:53 PM, Ingela Andin > > wrote: > >> > >> Hi! > >> > >> What version of inets and Erlang are you using? What HTTP version > >> HTTP-1.0 ? > >> If there is a bug we will of course fix it. > >> > >> Regards Ingela Erlang/OTP - Ericsson AB > >> > >> > >> 2011/4/27 Suma Shivaprasad : > >> > We have an app that makes a lot of calls to httpc and we are seeing > the > >> > following error in sasl logs quite often. > >> > > >> > CRASH REPORT==== 27-Apr-2011::05:21:24 === > >> > crasher: > >> > initial call: httpc_manager:init/1 > >> > pid: <0.10297.0> > >> > registered_name: httpc_manager_profile_8261 > >> > exception exit: {{case_clause, > >> > > [{handler_info,#Ref<0.0.398.166371>,undefined, > >> > <0.12971.248>,undefined,operational}]}, > >> > [{httpc_manager,handle_connect_and_send,5}, > >> > {httpc_manager,handle_info,2}, > >> > {gen_server,handle_msg,5}, > >> > {proc_lib,init_p_do_apply,3}]} > >> > in function gen_server:terminate/6 > >> > ancestors: [httpc_profile_sup,httpc_sup,inets_sup,<0.46.0> > >> > > >> > > >> > > >> > and > >> > > >> > > >> > =CRASH REPORT==== 27-Apr-2011::05:30:18 === > >> > crasher: > >> > initial call: httpc_manager:init/1 > >> > pid: <0.22933.12> > >> > registered_name: httpc_manager_profile_8122 > >> > exception exit: {{case_clause, > >> > > >> > [{handler_info,#Ref<0.0.418.148452>,<0.20608.257>, > >> > undefined,<0.15267.257>,initiating}]}, > >> > [{httpc_manager,handle_connect_and_send,5}, > >> > {httpc_manager,handle_info,2}, > >> > {gen_server,handle_msg,5}, > >> > {proc_lib,init_p_do_apply,3}]} > >> > in function gen_server:terminate/6 > >> > ancestors: [httpc_profile_sup,httpc_sup,inets_sup,<0.46.0>] > >> > messages: [{'EXIT',<0.20574.257>,normal}] > >> > links: [<0.50.0>,<0.20608.257>] > >> > dictionary: [] > >> > > >> > > >> > Has anyone else seen these errors or have a fix for this? > >> > > >> > Thanks > >> > Suma > >> > > >> > > >> > > >> > _______________________________________________ > >> > erlang-questions mailing list > >> > erlang-questions@REDACTED > >> > http://erlang.org/mailman/listinfo/erlang-questions > >> > > >> > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From pmorreale@REDACTED Fri Apr 29 23:42:40 2011 From: pmorreale@REDACTED (Peter W. Morreale) Date: Fri, 29 Apr 2011 15:42:40 -0600 Subject: [erlang-questions] canonical XML... Message-ID: <1304113360.11415.11.camel@hermosa.morreale.net> Is anyone working on a canonicalization module for xmerl? Per http://www.w3.org/TR/2002/REC-xml-exc-c14n-20020718/ or does this exist and I missed it? If so, I'd like to collaborate with you. Thanks, -PWM From matthias@REDACTED Sat Apr 30 08:41:37 2011 From: matthias@REDACTED (Matthias Lang) Date: Sat, 30 Apr 2011 08:41:37 +0200 Subject: [erlang-questions] more github than Erlang: how do I quickly get to a patch? Message-ID: <20110430064137.GA3091@corelatus.se> Hi, I noticed a post with an interesting fix to Erlang. The link in the mail is: git fetch git://github.com/falkevik/otp.gitopt_disable_of_flowctrl_for_run_erl_shell How I get from the above to seeing a patch, instantly? Ways which don't work: - cutting and pasting github.com/falkevik/ otp.gitopt_disable_of_flowctrl_for_run_erl_shell to a browser gets me a 404 from github (with a neat parallax effect) - doing the same with the missing space between 'git' and 'opt' reinserted gets me a 500 from github (without any neat picture) - cutting and pasting github.com/falkevik/otp gets me the repo, then I have to use 'switch branches' to get to the right branch, and then I still have no idea which commit is the interesting one. - clicking on 'network' in the hope of seeing where the branch started gets me a spinning "loading graph data". I tire of that after 30s. I then gave up trying to find a github shortcut and just did this: git checkout pu git log --author=falke git show d0775cd6 which is easy and does exactly what I want, but requires me to be logged in to a machine with the repo. (ok, I didn't fetch, so that doesn't show me his later patches, but that's actually what I wanted) Better suggestions? Or is the only easy way to be logged in to a machine that happens to have the repo on it? Matt (thanks for the patch, Jonas, it solves a nasty problem I didn't even realise I had) From kostis@REDACTED Sat Apr 30 09:52:39 2011 From: kostis@REDACTED (Kostis Sagonas) Date: Sat, 30 Apr 2011 10:52:39 +0300 Subject: [erlang-questions] False warning - function has no local return In-Reply-To: References: Message-ID: <4DBBBFC7.4000604@cs.ntua.gr> Ken Robinson wrote: > Hi, > > As per an earlier post from Kostis I'm reporting what I think is a > false warning of a function having no local return ... The hard coded type information about erlang:list_to_bitstring/1 in erl_bif_types was erroneous. The following patch fixes this. Please include in 'pu' and soon to 'dev'. git fetch git://github.com/kostis/otp.git list_to_bitstring Kostis From nox@REDACTED Sat Apr 30 10:45:13 2011 From: nox@REDACTED (Anthony Ramine) Date: Sat, 30 Apr 2011 10:45:13 +0200 Subject: [erlang-questions] more github than Erlang: how do I quickly get to a patch? In-Reply-To: <20110430064137.GA3091@corelatus.se> References: <20110430064137.GA3091@corelatus.se> Message-ID: <7F052365-7B2D-4ECA-9CFB-8F1899CA91C1@dev-extend.eu> https://github.com/falkevik/otp/compare/dev...opt_disable_of_flowctrl_for_run_erl_shell Le 30 avr. 2011 ? 08:41, Matthias Lang a ?crit : > Hi, > > I noticed a post with an interesting fix to Erlang. The link in the mail is: > > git fetch git://github.com/falkevik/otp.gitopt_disable_of_flowctrl_for_run_erl_shell > > How I get from the above to seeing a patch, instantly? > > Ways which don't work: > > - cutting and pasting github.com/falkevik/ > otp.gitopt_disable_of_flowctrl_for_run_erl_shell to a browser > gets me a 404 from github (with a neat parallax effect) > > - doing the same with the missing space between 'git' and 'opt' reinserted > gets me a 500 from github (without any neat picture) > > - cutting and pasting github.com/falkevik/otp gets me the repo, > then I have to use 'switch branches' to get to the right branch, > and then I still have no idea which commit is the interesting one. > > - clicking on 'network' in the hope of seeing where the branch > started gets me a spinning "loading graph data". I tire of that > after 30s. > > I then gave up trying to find a github shortcut and just did this: > > git checkout pu > git log --author=falke > git show d0775cd6 > > which is easy and does exactly what I want, but requires me to be > logged in to a machine with the repo. (ok, I didn't fetch, so that > doesn't show me his later patches, but that's actually what I wanted) > > Better suggestions? Or is the only easy way to be logged in to a > machine that happens to have the repo on it? > > Matt > > (thanks for the patch, Jonas, it solves a nasty problem I didn't even > realise I had) > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -- Anthony Ramine Dev:Extend http://dev-extend.eu From nox@REDACTED Sat Apr 30 10:46:54 2011 From: nox@REDACTED (Anthony Ramine) Date: Sat, 30 Apr 2011 10:46:54 +0200 Subject: [erlang-questions] canonical XML... In-Reply-To: <1304113360.11415.11.camel@hermosa.morreale.net> References: <1304113360.11415.11.camel@hermosa.morreale.net> Message-ID: I've began working on that but it needs several fixes in xmerl (which are planned for R15). Feel free to mail me or to come on #erlang or #erlounge IRC channels on freenode.net Regards, Le 29 avr. 2011 ? 23:42, Peter W. Morreale a ?crit : > > Is anyone working on a canonicalization module for xmerl? Per > > http://www.w3.org/TR/2002/REC-xml-exc-c14n-20020718/ > > or does this exist and I missed it? > > > If so, I'd like to collaborate with you. > > Thanks, > -PWM > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -- Anthony Ramine Dev:Extend http://dev-extend.eu From daniel.goertzen@REDACTED Sat Apr 30 22:21:02 2011 From: daniel.goertzen@REDACTED (Daniel Goertzen) Date: Sat, 30 Apr 2011 15:21:02 -0500 Subject: [erlang-questions] snmp security name problems Message-ID: I am playing with erlang snmp managers, and am having trouble making my first sync_get() command to a v3 agent work. I am getting "unknownSecurityName" (see below), and I am stumped as to what might be wrong. I have What's Up Gold polling my v3 agent device, so I know the agent's SNMP is working well. Any suggestions? Thanks, Dan. PS C:\cygwin\home\goertzen\bulk_config\srpc\ebin> C:\erlang\bin\erl.exe -config C:\erlsnmp\sys.config Eshell V5.8.2 (abort with ^G) 1> crypto:start(). ok 2> snmp:start(). ok 3> snmpm:which_agents(). ["myagent"] 4> snmpm:which_usm_users(). [{"hemi","abc123"}] 5> snmpm:usm_user_info("hemi", "abc123",sec_name). {ok,"abc123"} 6> snmpm:sync_get(defaultuser, "myagent", [[1,3,6,1,2,1,1,1]]). =ERROR REPORT==== 30-Apr-2011::15:15:46 === [ snmp : manager : snmpm_mpd : <0.61.0> ] MPD: CONFIG ERROR: unknownSecurityName (message: {message,'version-3', {v3_hdr,1261510722,484, [7], 3,undefined,undefined}, [48,65,4,32,56,48,58,48,48, 58,54,51,58,57,102,58,48, 51,58,48,48,58,52,48,58,53, 51,58,48,56,58,52,102,58, 55,51,4,0,160,27,2,4,92, 103,199,2,2,1,0,2,1,0,48, 13,48,11,6,7,43,6,1,2,1,1, 1,5,0]}) {error,{send_failed,1550305026,unknownSecurityName}} 7> usm.conf: %% {EngineID, UserName, AuthP, AuthKey, PrivP, PrivKey}. %% {EngineID, UserName, SecName, AuthP, AuthKey, PrivP, PrivKey}. {"hemi", "abc123", "abc123", usmHMACMD5AuthProtocol, [122,254,237,74,242,75,191,73,255,25,189,190,102,250,156,25], % from snmp:passwd2localized_key(md5,"abc123456","hemi") usmDESPrivProtocol, [122,254,237,74,242,75,191,73,255,25,189,190,102,250,156,25] % from snmp:passwd2localized_key(md5,"abc123456","hemi") }. agents.conf: %% {UserId, %% TargetName, Comm, Ip, Port, EngineID, Timeout, %% MaxMessageSize, Version, SecModel, SecName, SecLevel} %% { defaultuser, "myagent", "", [192,168,1,50], 162, "engineid", infinity, 484, v3, usm, "abc123", authPriv }. users.conf: {defaultuser, snmpm_user_default, "dummy"}. manager.conf: {port, 5000}. {address, [192,168,1,104]}. {engine_id, "hemi"}. {max_message_size, 484}. sys.config: [{snmp, [ {manager, [ {priority, normal}, {versions, [v3]}, {config, [{dir, "c:/erlsnmp/"}, {verbosity, silence}, {db_dir, "c:/erlsnmp/data/"}, {repair, true}, {auto_save, 5000}]}, {inform_request_behaviour, auto}, {mibs, ["c:/erlang/lib/snmp-4.18/mibs/SNMPv2-MIB"]}, {server, [{timeout,30000},{verbosity,silence}]}, {note_store, [{timeout,30000},{verbosity,silence}]}, {net_if, [{module,snmpm_net_if},{verbosity,silence},{options,[{bind_to,false},{no_reuse,false}]}]} ] } ] } ]. -------------- next part -------------- An HTML attachment was scrubbed... URL: