From vmitsner@REDACTED Wed Oct 1 01:52:58 2008 From: vmitsner@REDACTED (Vladimir Mitsner) Date: Tue, 30 Sep 2008 18:52:58 -0500 Subject: [erlang-questions] ac_tab Message-ID: <32e4cadb0809301652u2601836aj1527059da04aff53@mail.gmail.com> I heard there is a way to configure a file such that at some point after startup of a node (with appropriate flags), the contents of that file are loaded into "ac_tab" - I have 2 questions : how do I specify the file in such a way that it is loaded into the ac_tab? And at what point would the contents of the file be loaded into ac_tab? Thank you. -------------- next part -------------- An HTML attachment was scrubbed... URL: From dawsdesign@REDACTED Wed Oct 1 02:38:15 2008 From: dawsdesign@REDACTED (Matt Williamson) Date: Tue, 30 Sep 2008 20:38:15 -0400 Subject: [erlang-questions] Erlang SMTP module with support for attachments In-Reply-To: References: <1c3be50f0809300837h89038cfw7a2abbcec8888b9b@mail.gmail.com> Message-ID: I would also like to know. 2008/9/30 Juan Jose Comellas > Does anybody know if there's any open source Erlang module/library > available for sending emails with attachments? > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dawsdesign@REDACTED Wed Oct 1 02:38:41 2008 From: dawsdesign@REDACTED (Matt Williamson) Date: Tue, 30 Sep 2008 20:38:41 -0400 Subject: [erlang-questions] Mnesia multi-table joins In-Reply-To: References: <6a3ae47e0809290545m3191f7b1ka872e4dd5da17cff@mail.gmail.com> <6a3ae47e0809290631h3871cfceie4bd5db04666d35c@mail.gmail.com> <6a3ae47e0809300936p5748e4a7k1934ea8c54c55c8b@mail.gmail.com> Message-ID: As you'll hear from many people, denormalize. Mnesia isn't really made to be a RDMS. On Tue, Sep 30, 2008 at 12:36 PM, Robert Raschke wrote: > On Tue, Sep 30, 2008 at 4:49 PM, wrote: > > Hi all, > > > > Changed subject of my last thread as it wasn't a performance issue! > > > > I have done some more digging and found that Mnesia appears to support > only joins across two tables. > > > > I have tried a cut down version of the below query using the two big > tables only and it is lightning quick. > > > > Does anyone know if there is a way to perform joins across more than two > tables? > > > > I fear I will have tripped on the last hurdle (I am currently prototyping > a proposed system) if I cant perform joins across more than two tables. > > > > Many Thanks, > > Dan > > > > -----Original Message----- > > From: RUBINO, Dana, GBM > > Sent: 30 September 2008 15:59 > > To: erlang-questions@REDACTED > > Subject: Extremely poor Mnesia performance > > > > > > Hey all, > > > > I am doing some benchmarking with Mnesia at the moment and am pretty > disappointed to say the least. > > > > I'm hoping I am doing something wrong. > > > > Running a 5 table join below: (two of the tables have ~50k rows the rest > a couple of hundred) > > > > execute(qlc:q([I#i.user_id || I <- mnesia:table(i), > > C <- mnesia:table(c), > > I#i.user_id =:= > C#c.user_id, > > I#i.group =:= "Group A", > > P <- mnesia:table(p), > > T <- mnesia:table(t), > > S <- mnesia:table(s), > > C#c.platform_id =:= > P#p.platform_id, > > C#c.trans_id =:= > T#t.trans_id, > > C#c.sales_id =:= > S#s.sales_id > > ])). > > > > On a normal RDBMS this query returns in < 1min. I am yet to get a result > from Mnesia and its been running for 10 mins. > > > > Is there anyway I can see what's going wrong with this query under the > hood? > > > > Thanks, > > Dan > > > > Do you really need one result set that makes use of values in all five > tables? Is it possible to have a i.user_id that does not have a > corresponding c.user_id, and can the c.platform_id, ... point to > non-existant p, ... entries? If not, that is, you have (conceptual) > foreign key constraints, then you can probably cut down the query to > just the i and c tables with conditions that the c.platform_id, ... > have values. > > Robby > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From vik@REDACTED Wed Oct 1 03:06:20 2008 From: vik@REDACTED (Vik Olliver) Date: Wed, 01 Oct 2008 14:06:20 +1300 Subject: [erlang-questions] Erlang SMTP module with support for attachments In-Reply-To: References: <1c3be50f0809300837h89038cfw7a2abbcec8888b9b@mail.gmail.com> Message-ID: <1222823180.15251.417.camel@localhost> On Tue, 2008-09-30 at 20:38 -0400, Matt Williamson wrote: > I would also like to know. > > 2008/9/30 Juan Jose Comellas > Does anybody know if there's any open source Erlang > module/library available for sending emails with attachments? You want erlmail. http://code.google.com/p/erlmail/ Vik :v) From colm.dougan@REDACTED Wed Oct 1 03:31:22 2008 From: colm.dougan@REDACTED (Colm Dougan) Date: Wed, 1 Oct 2008 02:31:22 +0100 Subject: [erlang-questions] Multiple ETS lookups Message-ID: <24d4f39c0809301831m6ca40d33id54979b468ad617@mail.gmail.com> Hi list, What do people think of the idea of adding a multiple ETS lookup function, analogous to the SQL 'IN' operator, where you can pass a list of keys and you get a list of matches? Something like : 1> T0 = ets:new(testtable, [set]). 15 2> ets:insert(T0, [{foo, 10}, {bar, 20}, {baz, 30}]). true 3> ets:multi_lookup(T0, [foo, bar, baz]). [{foo, 10},{bar,20},{baz,30}] 4> ets:multi_lookup(T0, [dog, foo, cat]). [{foo,10}] My motivation for this suggestion is mainly performance but I think it is also a common enough idiom that the interface would be generally useful. I realize that this problem has been solved in a more general way with match specs but unless I'm missing something using a match spec (even a compiled one) to do (say) 3 lookups is slower than doing 3 individual ets:lookup calls which defeats the point (in that case). Am I missing something here? I also find the match spec interface a bit unwieldy for such a simple operation (although I realize it is designed for flexibility). In my case the multiple ets lookup would help work around the performance dip I got in critical sections doing intensive lookups when I moved from non-SMP mode to SMP mode. I realize that relatively speaking the SMP locking is not that expensive unless there are lock conflicts but there is still a cost and when doing intensive lookups you definitely notice it. Being able to "unroll" my lookups to do (say) 4 or 8 at once and only incur the locking overheads a quarter of the time would be a big win. Yeah I know people will then potentially be able to do nasty things like try to do too many lookups at once, but then again they could just not do that. Anyway, just throwing the idea out there to be shot at. Thanks, Colm From lloy0076@REDACTED Wed Oct 1 04:58:38 2008 From: lloy0076@REDACTED (David Lloyd) Date: Wed, 01 Oct 2008 12:28:38 +0930 Subject: [erlang-questions] Simple OTP Question... Message-ID: <48E2E75E.4020000@adam.com.au> Hi There, My source is: -module(ping). -behaviour(gen_server). -export([init/1, terminate/2, code_change/3]). -export([handle_call/3, handle_cast/2, handle_info/2]). init(Args) -> {ok, "Started"}. handle_call(Request, From, State) -> true, {reply, "Pong", State}. handle_cast(Request, State) -> {stop, "Not implemented", State}. handle_info(Info, State) -> {stop, "Not implemented", State}. terminate(Reason, State) -> true. code_change(OldVsn, State, Extra) -> State. bash-3.00$ erl Erlang (BEAM) emulator version 5.5.5 [source] [async-threads:0] [kernel-poll:false] Eshell V5.5.5 (abort with ^G) 1> c(ping). ./ping.erl:7: Warning: variable 'Args' is unused ./ping.erl:10: Warning: variable 'From' is unused ./ping.erl:10: Warning: variable 'Request' is unused ./ping.erl:14: Warning: variable 'Request' is unused ./ping.erl:17: Warning: variable 'Info' is unused ./ping.erl:20: Warning: variable 'Reason' is unused ./ping.erl:20: Warning: variable 'State' is unused ./ping.erl:23: Warning: variable 'Extra' is unused ./ping.erl:23: Warning: variable 'OldVsn' is unused {ok,ping} 2> gen_server:start({ok, pserv}, ping, {args}, []). =ERROR REPORT==== 1-Oct-2008::12:23:47 === Error in process <0.30.0> with exit value: {function_clause,[{gen,where,[{ok,pserv}]},{gen,start,6},{erl_eval,do_apply,5},{shell,exprs,6},{shell,eval_loop,3}]} ** exited: {undef,[{shell_default,handle_call,[1,2,3]}, {erl_eval,do_apply,5}, {shell,exprs,6}, {shell,eval_loop,3}]} ** However, if I remove the "true, " in the source, the gen_server starts. I can't figure out what's causing this behaviour and I'm looking at the STDLIB documents and Programming Erlan. DSL From erlang-questions_efine@REDACTED Wed Oct 1 05:27:40 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Tue, 30 Sep 2008 23:27:40 -0400 Subject: [erlang-questions] Simple OTP Question... In-Reply-To: <48E2E75E.4020000@adam.com.au> References: <48E2E75E.4020000@adam.com.au> Message-ID: <6c2563b20809302027l62afbe2et98c5194ad5992c7c@mail.gmail.com> You're calling gen_server:start() with the wrong arguments. This may help: 25> c(ping). ./ping.erl:7: Warning: variable 'Args' is unused ./ping.erl:10: Warning: variable 'From' is unused ./ping.erl:10: Warning: variable 'Request' is unused ./ping.erl:14: Warning: variable 'Request' is unused ./ping.erl:17: Warning: variable 'Info' is unused ./ping.erl:20: Warning: variable 'Reason' is unused ./ping.erl:20: Warning: variable 'State' is unused ./ping.erl:23: Warning: variable 'Extra' is unused ./ping.erl:23: Warning: variable 'OldVsn' is unused {ok,ping} 26> {ok, Pid} = gen_server:start({local, myserver}, ping, [], []). {ok,<0.97.0>} 27> gen_server:call(myserver, some_request). "Pong" 28> gen_server:call(myserver, {arbitrarily_complex,[some_request]}). "Pong" 29> exit(Pid,normal). true 30> erlang:is_process_alive(Pid). true 31> exit(Pid,shutdown). true 32> erlang:is_process_alive(Pid). false 33> f(Pid). ok 34> {ok, Pid} = gen_server:start(ping, [], []). {ok,<0.106.0>} 35> gen_server:call(Pid, some_request). "Pong" 36> exit(Pid,shutdown). true On Tue, Sep 30, 2008 at 10:58 PM, David Lloyd wrote: > > Hi There, > > My source is: > > -module(ping). > -behaviour(gen_server). > > -export([init/1, terminate/2, code_change/3]). > -export([handle_call/3, handle_cast/2, handle_info/2]). > > init(Args) -> > {ok, "Started"}. > > handle_call(Request, From, State) -> > true, > {reply, "Pong", State}. > > handle_cast(Request, State) -> > {stop, "Not implemented", State}. > > handle_info(Info, State) -> > {stop, "Not implemented", State}. > > terminate(Reason, State) -> > true. > > code_change(OldVsn, State, Extra) -> > State. > > > bash-3.00$ erl > Erlang (BEAM) emulator version 5.5.5 [source] [async-threads:0] > [kernel-poll:false] > > Eshell V5.5.5 (abort with ^G) > 1> c(ping). > ./ping.erl:7: Warning: variable 'Args' is unused > ./ping.erl:10: Warning: variable 'From' is unused > ./ping.erl:10: Warning: variable 'Request' is unused > ./ping.erl:14: Warning: variable 'Request' is unused > ./ping.erl:17: Warning: variable 'Info' is unused > ./ping.erl:20: Warning: variable 'Reason' is unused > ./ping.erl:20: Warning: variable 'State' is unused > ./ping.erl:23: Warning: variable 'Extra' is unused > ./ping.erl:23: Warning: variable 'OldVsn' is unused > {ok,ping} > 2> gen_server:start({ok, pserv}, ping, {args}, []). > > =ERROR REPORT==== 1-Oct-2008::12:23:47 === > Error in process <0.30.0> with exit value: > > {function_clause,[{gen,where,[{ok,pserv}]},{gen,start,6},{erl_eval,do_apply,5},{shell,exprs,6},{shell,eval_loop,3}]} > > ** exited: {undef,[{shell_default,handle_call,[1,2,3]}, > {erl_eval,do_apply,5}, > {shell,exprs,6}, > {shell,eval_loop,3}]} ** > > However, if I remove the "true, " in the source, the gen_server starts. > > I can't figure out what's causing this behaviour and I'm looking at the > STDLIB documents and Programming Erlan. > > DSL > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From zerthurd@REDACTED Wed Oct 1 05:27:55 2008 From: zerthurd@REDACTED (Maxim Treskin) Date: Wed, 1 Oct 2008 10:27:55 +0700 Subject: [erlang-questions] Simple OTP Question... In-Reply-To: <48E2E75E.4020000@adam.com.au> References: <48E2E75E.4020000@adam.com.au> Message-ID: Just read `erl -man gen_server`. ====== start(ServerName, Module, Args, Options) -> Result ServerName = {local, Name} | {global, GlobalName} ====== ServerName is NOT {ok, Name} > However, if I remove the "true, " in the source, the gen_server starts. Which of? -- Maxim Treskin From ok@REDACTED Wed Oct 1 05:50:06 2008 From: ok@REDACTED (Richard O'Keefe) Date: Wed, 1 Oct 2008 16:50:06 +1300 Subject: [erlang-questions] The Erlang Rationale In-Reply-To: <3dbc6d1c0809300630q35221794jf0922f370de6dd04@mail.gmail.com> References: <3dbc6d1c0809291502m3ad2147djfdc652a8e5c7a157@mail.gmail.com> <48E1F395.5040501@gmail.com> <3dbc6d1c0809300519kd46dbadsdfb670f71865b5@mail.gmail.com> <48E21D43.1040509@gmail.com> <4ac8254d0809300609m7c72c6b2je9774a70c629acf8@mail.gmail.com> <3dbc6d1c0809300630q35221794jf0922f370de6dd04@mail.gmail.com> Message-ID: On 1 Oct 2008, at 2:30 am, Robert Virding wrote: > OK, OK, OK, enough already! :-) I will fix the next version in PDF. > And I thought this was a bunch of computer savvy people who would > just laugh at Word format. I take software piracy seriously, so I do not laugh when I see people giving financial support to a large company convicted of software piracy, especially when there are free alternatives (AbiWord, OpenOffice) and when an open format (HTML) would have done just as good a job. > "i.e. large switches" should be "i.e., large switches". "handle large number" should be "handle a large number" Immutable data structures: (1) they eliminate the classic OO problem "what happens when you are iterating over a collection and the collection changes" because it can't; (2) just today in Haskell-Caf? someone was complaining about a data structure in C# (hence in F#) not being thread-safe for no apparent reason, immutable data structures means you can't make a thread-unsafe data structure. "all messages sent were complete, no partial messages" -- if you are using two or more node, what exactly stops a message sent from one node to another arriving only in part? Communications networks are unreliable, after all. "The level of security in the message protocol" -- I think you need to explain why asynchrony avoids problems with this, it's certainly not obvious to me. "Typing" "I still think is was" s/is/it/ "distribution were nodes were" s/were nodes/where nodes/ "Generic requests to an i/o server" 1,$s:i/o:I/O:g "while the with" s/the // I never did get my head around the I/O protocol, not least because it didn't seem to be written down anywhere. I am very happy indeed to see this discussion of I/O requests. Being a Bear of Very Little Brain, I *still* don't get how to do the continuation stuff. It might be worth while splitting this out as a separate document and putting in enough idiot-level examples so that I finally get it. [Beg beg.] "Process Groups" The first straightforward explanation of the idea I've ever seen. Are there any plans to extend this feature or its use? 'It would be good to have some example programs' -- you took the words out of my keyboard. "SHAPE \* MERGEFORMAT" I take to be an artefact of the way the PDF was produced. "the '=' operator" What you do not mention, and what would strengthen your position, is that in those languages that have 'let', the '=' sign is usually an essential part of the syntax. ML let val = in end Haskell let = in where = ['let' and 'where' were in ISWIM, if I recall correctly.] So there is nothing in the least unusual in the functional world about = . "take apart you cake" s/you/your/ The thing that *is* rather unusual is allowing '=' inside function calls and having the bindings percolate out. The introduction of 'fun' and list comprehensions has also done bad things to the simple 'the scope of a variable is the entire clause it occurs in' rule. "Macros" Named constants should have been = at top level. I've tried rewriting some modules that way to see what it looks like and it's beautiful. I grant the utility of -include, but that's not macros. If I want M4 I know where to find it. I have CScout to help me cope with C code that's full of macros, but unless I can talk Diomidis Spinellis into it (and he has other maddened grizzly bears to stun) there isn't and won't be an EScout. Macros make maintenance *harder*. "en Erlang point of view" s/en/an/ "Variable scoping and 'let'" This is the perfect opportunity to mention LFE and point out that people who want to try an alternative approach to scoping have something they can play with. I note that 'begin' ... 'end' were originally introduced in the form "begin within end". "Group leader Group leader Process group Process group "user" User driver Job 1 Job 2 " I take these lines at the end to be another artefact of the Weird->PDF conversion process. From devdoer2@REDACTED Wed Oct 1 06:00:28 2008 From: devdoer2@REDACTED (devdoer bird) Date: Wed, 1 Oct 2008 12:00:28 +0800 Subject: [erlang-questions] what does open_port({fd,0,1},...) do? Message-ID: HI: I found erlang's windows version use user.erl module to process terminal IO and user.erl calls function: open_port({fd,0,1},PortSettings) to open a port. I can't find which driver source file in erlang package corresponding to the {fd,0,1} port. I also modify the erlang's linux version to use user.erl instead user_drv.erl to process terminal IO,for I found user.erl can display CJK words correctly. It works except the control input such as cursor move input like "<-" ,"->" will be showed like this "^[[D" . So I want to find the {fd,0,1} port process code to research more. Can some guy give some clues? -------------- next part -------------- An HTML attachment was scrubbed... URL: From zerthurd@REDACTED Wed Oct 1 07:11:19 2008 From: zerthurd@REDACTED (Maxim Treskin) Date: Wed, 1 Oct 2008 12:11:19 +0700 Subject: [erlang-questions] what does open_port({fd,0,1},...) do? In-Reply-To: References: Message-ID: erl -man erlang ===== open_port(PortName, PortSettings) -> port() PortName = {spawn, Command} | {fd, In, Out} Command = string() In = Out = int() ... {fd, In, Out}: Allows an Erlang process to access any currently opened file descriptors used by Erlang. The file descriptor In can be used for standard input, and the file descriptor Out for standard output. It is only used for various servers in the Erlang operating system (shell and user). Hence, its use is very limited. ===== -- Maxim Treskin -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf@REDACTED Wed Oct 1 08:26:49 2008 From: ulf@REDACTED (Ulf Wiger) Date: Wed, 1 Oct 2008 08:26:49 +0200 Subject: [erlang-questions] Multiple ETS lookups In-Reply-To: <24d4f39c0809301831m6ca40d33id54979b468ad617@mail.gmail.com> References: <24d4f39c0809301831m6ca40d33id54979b468ad617@mail.gmail.com> Message-ID: <8209f740809302326l4415b476vd82ed27cbed7b7ea@mail.gmail.com> I posted a slightly more general suggestion a while back: http://www.erlang.org/pipermail/erlang-questions/2007-May/026440.html http://www.erlang.org/pipermail/erlang-questions/2007-June/026998.html http://www.erlang.org/pipermail/erlang-questions/2007-June/027004.html The main reason for doing this, I think, would be atomicity, without having to go either through a serializing process or mnesia. Conceptually, using a process is a lot cleaner. The problem (apart from forcing you to write more code) is that you double the amount of copying needed... BR, Ulf W 2008/10/1 Colm Dougan : > Hi list, > > What do people think of the idea of adding a multiple ETS lookup > function, analogous to the SQL 'IN' operator, where you can pass a > list of keys and you get a list of matches? > > Something like : > > 1> T0 = ets:new(testtable, [set]). > 15 > 2> ets:insert(T0, [{foo, 10}, {bar, 20}, {baz, 30}]). > true > 3> ets:multi_lookup(T0, [foo, bar, baz]). > [{foo, 10},{bar,20},{baz,30}] > 4> ets:multi_lookup(T0, [dog, foo, cat]). > [{foo,10}] > > My motivation for this suggestion is mainly performance but I think it > is also a common enough idiom that the interface would be generally > useful. > > I realize that this problem has been solved in a more general way with > match specs but unless I'm missing something using a match spec (even > a compiled one) to do (say) 3 lookups is slower than doing 3 > individual ets:lookup calls which defeats the point (in that case). > Am I missing something here? I also find the match spec interface a > bit unwieldy for such a simple operation (although I realize it is > designed for flexibility). > > In my case the multiple ets lookup would help work around the > performance dip I got in critical sections doing intensive lookups > when I moved from non-SMP mode to SMP mode. I realize that relatively > speaking the SMP locking is not that expensive unless there are lock > conflicts but there is still a cost and when doing intensive lookups > you definitely notice it. Being able to "unroll" my lookups to do > (say) 4 or 8 at once and only incur the locking overheads a quarter of > the time would be a big win. > > Yeah I know people will then potentially be able to do nasty things > like try to do too many lookups at once, but then again they could > just not do that. > > Anyway, just throwing the idea out there to be shot at. > > Thanks, > Colm > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From pguyot@REDACTED Wed Oct 1 08:43:47 2008 From: pguyot@REDACTED (Paul Guyot) Date: Wed, 1 Oct 2008 08:43:47 +0200 Subject: [erlang-questions] Questions on C/Java nodes Message-ID: Hello, The tutorial for the C nodes (I'm pretty sure I've seen some similar code for Java nodes) goes like this: listen(..., 5) erl_publish(...) fd = erl_accept(...) while (true) { erl_receive_msg(fd, ...) } From what I understand, the C node can only have one peer (the first one that connects). Yet, still in the tutorial sample code [1], listen (2) is called with a backlog of 5. Is there any reason why the tutorial code isn't a regular fork(2) or select(2)-based server code, except for simplicity (and that this probably wouldn't be portable on Windows)? On Unix, can select(2) be used on the file descriptor returned by erl_accept? Still on the C nodes, I am confused by the creation parameter of erl_connect_init. The man page erl_connect(3) says: > creation helps identify a particular instance of a C node. In > particular, it can help prevent us from receiving messages sent > to an earlier process with the same registered name. > > A C node acting as a server will be assigned a creation number > when it calls erl_publish(). and then the sample code below gives 0. In which case should we provide something different from 0? Paul [1] http://erlang.org/doc/tutorial/cnode.html From mats.cronqvist@REDACTED Wed Oct 1 09:37:04 2008 From: mats.cronqvist@REDACTED (Mats Cronqvist) Date: Wed, 01 Oct 2008 09:37:04 +0200 Subject: [erlang-questions] The Erlang Rationale In-Reply-To: References: <3dbc6d1c0809291502m3ad2147djfdc652a8e5c7a157@mail.gmail.com> <48E1F395.5040501@gmail.com> <3dbc6d1c0809300519kd46dbadsdfb670f71865b5@mail.gmail.com> <48E21D43.1040509@gmail.com> <4ac8254d0809300609m7c72c6b2je9774a70c629acf8@mail.gmail.com> <3dbc6d1c0809300630q35221794jf0922f370de6dd04@mail.gmail.com> Message-ID: <48E328A0.6070109@gmail.com> Richard O'Keefe wrote: > On 1 Oct 2008, at 2:30 am, Robert Virding wrote: > > >> OK, OK, OK, enough already! :-) I will fix the next version in PDF. >> And I thought this was a bunch of computer savvy people who would >> just laugh at Word format. >> > > I take software piracy seriously, > so I do not laugh when I see people giving financial > support to a large company convicted of software piracy, > especially when there are free alternatives (AbiWord, > OpenOffice) and when an open format (HTML) would have > done just as good a job. +1 > "Macros" > > [...] Macros make maintenance *harder*. > +10 mats From joelr1@REDACTED Wed Oct 1 12:04:16 2008 From: joelr1@REDACTED (Joel Reymont) Date: Wed, 1 Oct 2008 11:04:16 +0100 Subject: [erlang-questions] best way to implement a "barrier" Message-ID: <23043890-185B-4AF4-BC42-5F2BDB9EF974@gmail.com> I need to make sure that a bunch of processes start doing work all at the same time. I'm looking at 10-50k processes. What is the best way to implement this? To be more precise, I need to make sure my poker games hang around until told to start. What happens otherwise is that I try to start, say, 10k games and by the time games 7-10k start, the first few thousand may have already finished. This complicates counting the number of games running concurrently. Thanks, Joel -- wagerlabs.com From richardc@REDACTED Wed Oct 1 12:38:52 2008 From: richardc@REDACTED (Richard Carlsson) Date: Wed, 01 Oct 2008 12:38:52 +0200 Subject: [erlang-questions] best way to implement a "barrier" In-Reply-To: <23043890-185B-4AF4-BC42-5F2BDB9EF974@gmail.com> References: <23043890-185B-4AF4-BC42-5F2BDB9EF974@gmail.com> Message-ID: <48E3533C.8040606@it.uu.se> Joel Reymont wrote: > I need to make sure that a bunch of processes start doing work all at > the same time. I'm looking at 10-50k processes. What is the best way > to implement this? > > To be more precise, I need to make sure my poker games hang around > until told to start. What happens otherwise is that I try to start, > say, 10k games and by the time games 7-10k start, the first few > thousand may have already finished. This complicates counting the > number of games running concurrently. How exact do you need the synchronization to be? The simplest barrier is a receive that waits for a start message. But if that is not exact enough (some have finished before others have even woken up), you might try a clock synchronization (unless that will overload the Erlang timer wheel): tell each process to go into a state waiting for a specific time (expressed as a datetime). Each process will then individually calculate how many milliseconds that is from now, and go into a simple 'receive after N -> ok end' wait. Possibly, this will wake them all up more simultaneously than the message-based method. The set time must be sufficiently far ahead that all processes have had time to react and enter the wait state. /Richard From joelr1@REDACTED Wed Oct 1 13:45:28 2008 From: joelr1@REDACTED (Joel Reymont) Date: Wed, 1 Oct 2008 12:45:28 +0100 Subject: [erlang-questions] best way to implement a "barrier" In-Reply-To: <48E3533C.8040606@it.uu.se> References: <23043890-185B-4AF4-BC42-5F2BDB9EF974@gmail.com> <48E3533C.8040606@it.uu.se> Message-ID: On Oct 1, 2008, at 11:38 AM, Richard Carlsson wrote: > How exact do you need the synchronization to be? The simplest barrier > is a receive that waits for a start message That's what I was thinking. The question then is how to ensure that all processes get the start message more or less at the same time. I guess this is the question of how long it takes to send 10k-50k start messages. > But if that is not exact > enough (some have finished before others have even woken up), you > might > try a clock synchronization Great suggestion! Thanks, Joel -- wagerlabs.com From nem@REDACTED Wed Oct 1 14:07:00 2008 From: nem@REDACTED (Geoff Cant) Date: Wed, 01 Oct 2008 14:07:00 +0200 Subject: [erlang-questions] Erlang SMTP module with support for attachments In-Reply-To: <1222823180.15251.417.camel@localhost> (Vik Olliver's message of "Wed, 01 Oct 2008 14:06:20 +1300") References: <1c3be50f0809300837h89038cfw7a2abbcec8888b9b@mail.gmail.com> <1222823180.15251.417.camel@localhost> Message-ID: Vik Olliver writes: > On Tue, 2008-09-30 at 20:38 -0400, Matt Williamson wrote: >> I would also like to know. >> >> 2008/9/30 Juan Jose Comellas >> Does anybody know if there's any open source Erlang >> module/library available for sending emails with attachments? > > You want erlmail. > > http://code.google.com/p/erlmail/ > > Vik :v) You may also be interested in my mime module (http://github.com/archaelus/erlmail/tree/mime/src/mail_mime.erl) which provides mime encoding and some functions to make that easier to use. I should really make a cut down distribution of smtpc+mail_mime at some point for the people who just want to be able to generate mail and attachments and fire it off to a smarthost. Cheers, --Geoff From richardc@REDACTED Wed Oct 1 14:58:39 2008 From: richardc@REDACTED (Richard Carlsson) Date: Wed, 01 Oct 2008 14:58:39 +0200 Subject: [erlang-questions] best way to implement a "barrier" In-Reply-To: References: <23043890-185B-4AF4-BC42-5F2BDB9EF974@gmail.com> <48E3533C.8040606@it.uu.se> Message-ID: <48E373FF.40807@it.uu.se> Joel Reymont wrote: > > On Oct 1, 2008, at 11:38 AM, Richard Carlsson wrote: > >> How exact do you need the synchronization to be? The simplest barrier >> is a receive that waits for a start message > > That's what I was thinking. The question then is how to ensure that all > processes get the start message more or less at the same time. I guess > this is the question of how long it takes to send 10k-50k start messages. A quick experiment from the command line: 200 ms for 50000 messages (not including the time to traverse the list), on the local machine. Fast enough? For a bunch of connected nodes, I'd avoid sending 50000 separate messages - if possible, send 1 message to each node, telling it to broadcast to only its local processes. /Richard From psa@REDACTED Wed Oct 1 15:19:52 2008 From: psa@REDACTED (=?ISO-8859-1?Q?Paulo_S=E9rgio_Almeida?=) Date: Wed, 01 Oct 2008 14:19:52 +0100 Subject: [erlang-questions] best way to implement a "barrier" In-Reply-To: References: <23043890-185B-4AF4-BC42-5F2BDB9EF974@gmail.com><48E3533C.804060 6@it.uu.se> Message-ID: <48E378F8.10600@di.uminho.pt> Joel Reymont wrote: > On Oct 1, 2008, at 11:38 AM, Richard Carlsson wrote: > >> How exact do you need the synchronization to be? The simplest barrier >> is a receive that waits for a start message > > That's what I was thinking. The question then is how to ensure that > all processes get the start message more or less at the same time. I > guess this is the question of how long it takes to send 10k-50k start > messages. Here is a version using links and trap_exit, intending to "send" the messages atomically, before being preempted. Does anyone know if the propagation of EXITs upon termination is atomic (at least within the same node) or it can be preempted and resumed later? Regards, Paulo -- -module(barrier). -export([init/0, wait/1, go/1]). init() -> spawn(fun() -> receive go -> ok end end). wait(Barrier) -> TE = process_flag(trap_exit, true), link(Barrier), receive {'EXIT', Barrier, normal} -> ok end, process_flag(trap_exit, TE). go(Barrier) -> Barrier ! go. From erlang-questions_efine@REDACTED Wed Oct 1 15:49:06 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Wed, 1 Oct 2008 09:49:06 -0400 Subject: [erlang-questions] The Erlang Rationale In-Reply-To: References: <3dbc6d1c0809291502m3ad2147djfdc652a8e5c7a157@mail.gmail.com> <48E1F395.5040501@gmail.com> <3dbc6d1c0809300519kd46dbadsdfb670f71865b5@mail.gmail.com> <48E21D43.1040509@gmail.com> <4ac8254d0809300609m7c72c6b2je9774a70c629acf8@mail.gmail.com> <3dbc6d1c0809300630q35221794jf0922f370de6dd04@mail.gmail.com> Message-ID: <6c2563b20810010649xdb362dcyefc9e361608b33f7@mail.gmail.com> This is a dissenting vote regarding macros. Macros *can* make maintenance harder, just like gotos *can* create spaghetti code. Neither of them are intrinsically bad, merely easy to misuse. Used with care and discipline, they both arguably have a place in good programming practice. Now I may get shot down in flames for saying this, but tail recursion in Erlang is effectively a restricted form of goto, and it's used a lot (not by choice over some other construct, though - the language design forces the usage). There are some things that macros can do that I have not found as easy (or possible) to do some other way, for example: -define(LOG_DBG(Msg, ArgList), iutil_log:log_debug(?MODULE, ?LINE, Msg, ArgList)). Example usage: ?LOG_DBG("Received ~p from ~p~n", [Msg, Socket]). The alternative is ugly. iutil_log:log_debug(?MODULE, ?LINE, "Received ~p from ~p~n", [Msg, Socket]). If I find that debug logging is causing too much overhead, I can decide to conditionally compile it: -ifdef(DEBUG). -define(LOG_DBG(Msg, ArgList), iutil_log:log_debug(?MODULE, ?LINE, Msg, ArgList)). -else. -define(LOG_DBG(Msg, ArgList), ok). -endif. A minor inconvenience of the above is that if it uses variables that are not otherwise used, you can get compile warnings when debug logging is disabled. This is easily fixed by using the underscore: _Unused. If I don't like having to recompile the code to enable and disable debug logging, but want to turn it on and off at run-time (and still have negligible overhead when debug logging is disabled), I can do this (and the source code using this does not change in any way, but of course must undergo a once-off recompilation): -define( LOG_DBG(Msg, ArgList), case iutil_log:ok_to_log(debug) of true -> iutil_log:log_debug(?MODULE, ?LINE, Msg, ArgList); false -> ok end ). Checking if the Msg and ArgList should be evaluated before calling saves, at the cost of an efficient function call, potentially enormous amounts of unnecessary list creation and destruction (and garbage collection), not to mention any evaluation of the list elements that might be needed. In this case I would argue that the macro makes the code *more* maintainable and easier to read, while keeping it efficient. Agreed, if the macro changes (and this class of macro seldom changes) I will need to recompile the dependent code, and this is definitely not good, but as Lord Farquhar said, "[Many of you may be killed, but] it is a sacrifice I am willing to make." ;-) On Tue, Sep 30, 2008 at 11:50 PM, Richard O'Keefe wrote: > > On 1 Oct 2008, at 2:30 am, Robert Virding wrote: > > > OK, OK, OK, enough already! :-) I will fix the next version in PDF. > > And I thought this was a bunch of computer savvy people who would > > just laugh at Word format. > > I take software piracy seriously, > so I do not laugh when I see people giving financial > support to a large company convicted of software piracy, > especially when there are free alternatives (AbiWord, > OpenOffice) and when an open format (HTML) would have > done just as good a job. > > > "i.e. large switches" should be "i.e., large switches". > "handle large number" should be "handle a large number" > > Immutable data structures: (1) they eliminate the classic > OO problem "what happens when you are iterating over a > collection and the collection changes" because it can't; > (2) just today in Haskell-Caf? someone was complaining about > a data structure in C# (hence in F#) not being thread-safe > for no apparent reason, immutable data structures means you > can't make a thread-unsafe data structure. > > "all messages sent were complete, no partial messages" > -- if you are using two or more node, what exactly stops > a message sent from one node to another arriving only in > part? Communications networks are unreliable, after all. > > "The level of security in the message protocol" -- I think > you need to explain why asynchrony avoids problems with > this, it's certainly not obvious to me. > > "Typing" > "I still think is was" s/is/it/ > "distribution were nodes were" s/were nodes/where nodes/ > > "Generic requests to an i/o server" > 1,$s:i/o:I/O:g > "while the with" s/the // > > I never did get my head around the I/O protocol, not least > because it didn't seem to be written down anywhere. I am > very happy indeed to see this discussion of I/O requests. > Being a Bear of Very Little Brain, I *still* don't get how > to do the continuation stuff. > > It might be worth while splitting this out as a separate > document and putting in enough idiot-level examples so that > I finally get it. [Beg beg.] > > "Process Groups" > The first straightforward explanation of the idea I've ever > seen. Are there any plans to extend this feature or its use? > 'It would be good to have some example programs' -- you took > the words out of my keyboard. > > "SHAPE \* MERGEFORMAT" I take to be an artefact of the way > the PDF was produced. > > "the '=' operator" > > What you do not mention, and what would strengthen your position, > is that in those languages that have 'let', the '=' sign is usually > an essential part of the syntax. > ML let val = in end > Haskell let = in > where = > ['let' and 'where' were in ISWIM, if I recall correctly.] > So there is nothing in the least unusual in the functional world > about = . > > "take apart you cake" s/you/your/ > > The thing that *is* rather unusual is allowing '=' inside > function calls and having the bindings percolate out. The > introduction of 'fun' and list comprehensions has also done > bad things to the simple 'the scope of a variable is the > entire clause it occurs in' rule. > > "Macros" > > Named constants should have been = > at top level. I've tried rewriting some modules that way to see > what it looks like and it's beautiful. I grant the utility of > -include, but that's not macros. If I want M4 I know where to > find it. I have CScout to help me cope with C code that's full > of macros, but unless I can talk Diomidis Spinellis into it (and > he has other maddened grizzly bears to stun) there isn't and won't > be an EScout. Macros make maintenance *harder*. > > "en Erlang point of view" s/en/an/ > > "Variable scoping and 'let'" > > This is the perfect opportunity to mention LFE and point out > that people who want to try an alternative approach to scoping > have something they can play with. > > I note that 'begin' ... 'end' were originally introduced in the > form "begin within end". > > "Group leader > Group leader > > Process group > Process group > "user" > User driver > Job 1 > Job 2 > " > I take these lines at the end to be another artefact of the > Weird->PDF conversion process. > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From devdoer2@REDACTED Wed Oct 1 17:15:46 2008 From: devdoer2@REDACTED (devdoer bird) Date: Wed, 1 Oct 2008 23:15:46 +0800 Subject: [erlang-questions] what does open_port({fd,0,1},...) do? In-Reply-To: References: Message-ID: Thanks .I read the manual before this mail.But the manul is not very clear. Can you give more details please? Such as why this special {fd,In,Out} port is needed? 2008/10/1 Maxim Treskin > erl -man erlang > > ===== > open_port(PortName, PortSettings) -> port() > PortName = {spawn, Command} | {fd, In, Out} > Command = string() > In = Out = int() > ... > {fd, In, Out}: > Allows an Erlang process to access any currently > opened file descriptors used by Erlang. The file descriptor In can be > used for standard input, and the file descriptor Out > for standard output. It is only used for various servers in the > Erlang operating system (shell and user). Hence, its > use is very limited. > ===== > > -- > Maxim Treskin > -------------- next part -------------- An HTML attachment was scrubbed... URL: From zerthurd@REDACTED Wed Oct 1 17:50:54 2008 From: zerthurd@REDACTED (Maxim Treskin) Date: Wed, 1 Oct 2008 22:50:54 +0700 Subject: [erlang-questions] what does open_port({fd,0,1},...) do? In-Reply-To: References: Message-ID: This option provides access to file descriptors opened by Erlang, i.e. stdin and stdout. So, you can directly write to and read from this descriptors from erlang process. Normally, you must not use this feature. On 01/10/2008, devdoer bird wrote: > Thanks .I read the manual before this mail.But the manul is not very clear. > Can you give more details please? Such as why this special {fd,In,Out} port > is needed? -- Maxim Treskin From joelr1@REDACTED Wed Oct 1 17:57:50 2008 From: joelr1@REDACTED (Joel Reymont) Date: Wed, 1 Oct 2008 16:57:50 +0100 Subject: [erlang-questions] Erlang doesn't suck Message-ID: Not once the pain goes away and only the results stick around. I spent a grueling 1+ week refactoring OpenPoker and wishing for static typing. I started at number of git branches, only to be thrown away a day or two later. Many were the times when I wished to tear my hair out and throw Erlang far and away from my terrace and towards the Atlantic ocean. I do have an extensive test harness and so the best approach proved to be committing reasonably small changes once all tests pass. The end result is that OpenPoker scales MUCH better now, even on a single VM! My workstation is a Mac Pro, 2x2.8Ghz QuadXeon with 14Gb of RAM. A while ago I deliberated between Amazon EC2 and Joyent and decided to host with the latter. For the purposes of testing, Joyent provided me with an 8 Core x86 Solaris Nevada system w/ a 2 GiB memory cap where I can burst to 95% CPU Utilization. A friendly member of this forum gave me access to a Solaris/Niagara system but I haven't had a change to test on it yet so I'll only compare my Mac and Joyent. Here are the test results, statistics collected every 30 seconds. My Mac ------ With SMP... 3000 games started, 15115 players ... 3000 games finished Elapsed: 181.960007s, Average run time: 0.06065333566666666 seconds 5000 games started, 25404 players ... 5000 games finished Elapsed: 329.646545s, Average run time: 0.065929309 seconds 7450 games started, 37890 players ... 7450 games finished Elapsed: 554.956259s, Average run time: 0.07407317925787507 seconds Without SMP (disabled)... (1@REDACTED)3> mb:test(localhost, 3000, 3000). Simulating gameplay with 3000 games... Waiting for games to end... 50 games started, 262 players =INFO REPORT==== 1-Oct-2008::16:00:01 === requests: 26065 bytes: 466134 requests_per_second: 868 bytes_per_second: 15536 1750 games started, 8786 players =INFO REPORT==== 1-Oct-2008::16:00:31 === requests: 26695 bytes: 303955 requests_per_second: 889 bytes_per_second: 10128 1800 games started, 9030 players =INFO REPORT==== 1-Oct-2008::16:01:01 === requests: 38856 bytes: 484091 requests_per_second: 1295 bytes_per_second: 16136 3000 games started, 15115 players 50 games finished =INFO REPORT==== 1-Oct-2008::16:01:31 === requests: 22199 bytes: 249774 requests_per_second: 739 bytes_per_second: 8323 2400 games finished 3000 games finished =INFO REPORT==== 1-Oct-2008::16:02:01 === requests: 14249 bytes: 122289 requests_per_second: 474 bytes_per_second: 4076 Elapsed: 121.541805s, Average run time: 0.040513935 seconds I figured I'll leave SMP disabled since I will likely be running a few VMs anyway. I'm assuming that 8 non-SMP VMs on an 8-core machines are much better than 8 VMs with 8-core SMP. Joyent Labs ----------- (1@REDACTED)3> mb:test(localhost, 3000, 3000). Simulating gameplay with 3000 games... Waiting for games to end... =INFO REPORT==== 1-Oct-2008::14:54:37 === requests: 38588 bytes: 710144 requests_per_second: 1286 bytes_per_second: 23670 2900 games started, 14614 players =INFO REPORT==== 1-Oct-2008::14:55:07 === requests: 40604 bytes: 482419 requests_per_second: 1351 bytes_per_second: 16055 900 games finished 3000 games finished =INFO REPORT==== 1-Oct-2008::14:55:37 === requests: 48872 bytes: 433680 requests_per_second: 1628 bytes_per_second: 14453 Elapsed: 68.21404s, Average run time: 0.02273801333333333 seconds As you can see, the test finished twice as fast at Joyent and the number of request per second stayed high. How did I achieve my scalability increases? I switched to a closure based binary serialization approach [1] based on Andrew Kennedy's Pickler Combinators. I think performance can be better but I'm quite content with describing packets like this: Pickler = record(foo, { byte(), record(bar, { int(), record(baz, { sshort(), list(byte(), byte()) }) }) }), [1] http://www.wagerlabs.com/erlang/pickle.erl I also removed an Erlang-style deadlock from my code. I have players and games. Erlang/OTP gen_server has both cast (fire and forget) and call (wait for reply) mechanisms. My games go in pairs of a gen_fsm driving the poker game logic and a gen_server doing the house keeping. My players called games, games called players and everything may have been fine if I didn't use game timers. With a high server load I would get into a situation where a player was expecting a game reply, a timer fired and the game called the player. A deadlock would ensue and one of the calls would time out. I found out the reason by grabbing the process info of both the player and the game upon a timeout and realizing that there was perhaps a single message in each queue but both processes were waiting on each another. I also poked around in Erlang crash dumps but this didn't prove as useful. Then I made sure that outgoing packets had the numeric game and player ids stuffed in them at the source. My previous approach had game and player process ids in the packet and had the serialization bits call each process to get its id. This really limited scalability and slowed things down. More importantly, this was another source of deadlocks since a game would invoke a serialization function that called back into the very same game. Last but not least, my benchmarking approach is a bit flawed since I can only start 7.5k games on my Mac and 8.6K games at Joyent. This is because my benchmark tool winds down once the number of finished games equals the number of games started, disregarding the total number of games I want to start in the first place. I don't see 15K players online at the same time for the same reason. My next step is to make sure all games run when the start pistol fires and to distribute testing among several VMs. Thanks, Joel -- wagerlabs.com From kostis@REDACTED Wed Oct 1 18:17:42 2008 From: kostis@REDACTED (Kostis Sagonas) Date: Wed, 01 Oct 2008 19:17:42 +0300 Subject: [erlang-questions] Question about gen_event Message-ID: <48E3A2A6.4060007@cs.ntua.gr> I've been staring at the code of 'gen_event' and I cannot make much sense of how the code for swapping handlers works. In fact, I am quite convinced there is a bug in there but it is being silenced by the use of a catch. Can somebody please confirm that this is a bug or enlighten me on what's happening? The code of gen_event:do_swap/7 reads: do_swap(Mod1,Handler1,Args1,State1,Handler2,Args2,SName) -> %% finalise the existing handler State2 = do_terminate(...), {Mod2,Handler} = new_handler(Handler2, Handler1), %% <--- case catch Mod2:init({Args2, State2}) of {ok, State2a} -> {ok, Handler#handler{state = State2a}}; Other -> report_terminate(Handler2, crash, ...), %% <--- no end. Is the use of Handler2 correct in the lines identified as %% <--- ? At least one of them does not seem to be, but I cannot see which one. Kostis PS. This is not found by dialyzer - it requires very different analyses. From joelr1@REDACTED Wed Oct 1 18:27:30 2008 From: joelr1@REDACTED (Joel Reymont) Date: Wed, 1 Oct 2008 17:27:30 +0100 Subject: [erlang-questions] Erlang doesn't suck In-Reply-To: <48E3A1E6.4090307@alertlogic.net> References: <48E3A1E6.4090307@alertlogic.net> Message-ID: <9D9606A2-0064-471E-B214-9E82DC850982@gmail.com> On Oct 1, 2008, at 5:14 PM, Paul Fisher wrote: > Just curious about the config here. Was the solaris using 32 or 64- > bit erlang? Compiled with gcc, right? I believe I used 32 bits both on my Mac and at Joyent. Erlang (BEAM) emulator version 5.6.4 [source] [async-threads:0] [hipe] [kernel-poll:false] gcc -MM -MG -g -O2 ... Do I stand to gain anything from using 64 bits here? Thanks, Joel -- wagerlabs.com From kostis@REDACTED Wed Oct 1 18:58:00 2008 From: kostis@REDACTED (Kostis Sagonas) Date: Wed, 01 Oct 2008 19:58:00 +0300 Subject: [erlang-questions] Erlang doesn't suck In-Reply-To: References: Message-ID: <48E3AC18.2010700@cs.ntua.gr> Joel Reymont wrote: > Not once the pain goes away and only the results stick around. > > I spent a grueling 1+ week refactoring OpenPoker and wishing for > static typing. I started at number of git branches, only to be thrown > away a day or two later. Many were the times when I wished to tear my > hair out and throw Erlang far and away from my terrace ... Before you make yourself bald :-), you should probably read the following: http://user.it.uu.se/~kostis/Papers/wrangler.pdf It describes how you can get most of the benefits from static typing without static typing. Kostis From saleyn@REDACTED Wed Oct 1 19:03:43 2008 From: saleyn@REDACTED (Serge Aleynikov) Date: Wed, 01 Oct 2008 13:03:43 -0400 Subject: [erlang-questions] GTK bindings In-Reply-To: <48E0C70D.5020700@gmail.com> References: <48CF2F1B.3070003@lionet.info> <2ae3549f-f1cb-4e3c-b7e3-d805c6de372a@m36g2000hse.googlegroups.com> <48CFF05B.90401@lionet.info> <15b6a55b-956f-45c8-b412-76751fe630ab@e53g2000hsa.googlegroups.com> <087d239c-07b5-47ef-9372-ae097ca12bcd@m45g2000hsb.googlegroups.com> <3dbc6d1c0809161457v2ed4f29bxe16bcc124dbf06f5@mail.gmail.com> <14f0e3620809161547x32377a37ke4c9abee0a8c41e1@mail.gmail.com> <3dbc6d1c0809161643t33fb3a80l7cb4b330333a1ef7@mail.gmail.com> <4ac8254d0809170244s4ebd31b1y4d0b361cdf3cb76f@mail.gmail.com> <48D1FC87.8030601@it.uu.se> <48E0C70D.5020700@gmail.com> Message-ID: <48E3AD6F.5050909@gmail.com> I compiled the project and have been getting these errors at run-time. As a result the fonts are unreadable. Do you know how to switch font in the examples? =INFO REPORT==== 1-Oct-2008::12:51:27 === in: {gtknode,handle_portdata,2} portdata: "\n(gtknode:17066): Pango-WARNING **: failed to find shape engine, expect ugly output. engine-type='PangoRenderFc', script='latin'\n" =INFO REPORT==== 1-Oct-2008::12:51:27 === in: {gtknode,handle_portdata,2} portdata: "\n(gtknode:17066): Pango-WARNING **: failed to find shape engine, expect ugly output. engine-type='PangoRenderFc', script='common'\n" =INFO REPORT==== 1-Oct-2008::12:51:27 === in: {gtknode,handle_portdata,2} portdata: "\n(gtknode:17066): Pango-WARNING **: _pango_cairo_font_install called with bad font, expect ugly output\n" Mats Cronqvist wrote: > Richard Carlsson wrote: >> YourSurrogateGod wrote: >> >>> Speaking of GTK bindings. Are there any so that one could make Gnome >>> applications (use all of the widgets and such) with Erlang? I haven't >>> heard of any at the moment... >>> >> The most mature (and portable) alternative is probably WxErlang: >> http://www.erlang.org/~dgud/wxerlang/ >> http://sourceforge.net/projects/wxerlang/ >> > will, in all likelihood, eventually be bundled with OTP. > >> There are also a couple of attempts at direct GTK bindings, but >> don't know what their status is: >> >> http://code.google.com/p/gtknode/ >> > gtknode works fine on all versions of GTK from 2.4 to 2.12 (compiled > it last friday). > >> http://erlgtk.sourceforge.net/ > > dead AFAIK. > > mats > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From joelr1@REDACTED Wed Oct 1 18:48:08 2008 From: joelr1@REDACTED (Joel Reymont) Date: Wed, 1 Oct 2008 17:48:08 +0100 Subject: [erlang-questions] Erlang doesn't suck In-Reply-To: <48E3A86A.8010508@alertlogic.net> References: <48E3A1E6.4090307@alertlogic.net> <9D9606A2-0064-471E-B214-9E82DC850982@gmail.com> <48E3A86A.8010508@alertlogic.net> Message-ID: On Oct 1, 2008, at 5:42 PM, Paul Fisher wrote: > I would expect HIPE compiled stuff to have much more chance to go > faster, but otherwise it trades higher memory usage (64-bit > addresses in data structures) for larger addressable memory for a vm. I have yet to test using HiPE. > Which begs the question of whether you compile to native or not for > your benchmarking? Not everything benefits, but we have some > modules that show significant gains from: > > -compile([native, {hipe,[o3]}, inline]). I will test this next. That and further scaling on top of several VMs instead of one. -- wagerlabs.com From pfisher@REDACTED Wed Oct 1 18:42:18 2008 From: pfisher@REDACTED (Paul Fisher) Date: Wed, 01 Oct 2008 11:42:18 -0500 Subject: [erlang-questions] Erlang doesn't suck In-Reply-To: <9D9606A2-0064-471E-B214-9E82DC850982@gmail.com> References: <48E3A1E6.4090307@alertlogic.net> <9D9606A2-0064-471E-B214-9E82DC850982@gmail.com> Message-ID: <48E3A86A.8010508@alertlogic.net> Joel Reymont wrote: > On Oct 1, 2008, at 5:14 PM, Paul Fisher wrote: > >> Just curious about the config here. Was the solaris using 32 or 64- >> bit erlang? Compiled with gcc, right? > > > I believe I used 32 bits both on my Mac and at Joyent. > > Erlang (BEAM) emulator version 5.6.4 [source] [async-threads:0] [hipe] > [kernel-poll:false] > > gcc -MM -MG -g -O2 ... > > Do I stand to gain anything from using 64 bits here? I would expect HIPE compiled stuff to have much more chance to go faster, but otherwise it trades higher memory usage (64-bit addresses in data structures) for larger addressable memory for a vm. You don't seem to need to the memory, so only benefit i could see is gains from better HIPE code execution with the extra registers. Which begs the question of whether you compile to native or not for your benchmarking? Not everything benefits, but we have some modules that show significant gains from: -compile([native, {hipe,[o3]}, inline]). I really asked because we do have the potential to use the larger addressable memory space, so was curious on what your benchmarks were based. Unfortunately, I haven't had a chance to do direct comparisons between 32/64-bit vms yet... Thanks for sharing your experiences! -- paul From colm.dougan@REDACTED Wed Oct 1 19:31:20 2008 From: colm.dougan@REDACTED (Colm Dougan) Date: Wed, 1 Oct 2008 18:31:20 +0100 Subject: [erlang-questions] Multiple ETS lookups In-Reply-To: <8209f740809302326l4415b476vd82ed27cbed7b7ea@mail.gmail.com> References: <24d4f39c0809301831m6ca40d33id54979b468ad617@mail.gmail.com> <8209f740809302326l4415b476vd82ed27cbed7b7ea@mail.gmail.com> Message-ID: <24d4f39c0810011031p703c63apec7c0ec7b9670d86@mail.gmail.com> > 2008/10/1 Colm Dougan : >> Hi list, >> >> What do people think of the idea of adding a multiple ETS lookup >> function, analogous to the SQL 'IN' operator, where you can pass a >> list of keys and you get a list of matches? On Wed, Oct 1, 2008 at 7:26 AM, Ulf Wiger wrote: > I posted a slightly more general suggestion a while back: > > http://www.erlang.org/pipermail/erlang-questions/2007-May/026440.html That looks really useful. IMO there is room for both functions (seq and multi_lookup). In the first instance multi_lookup could be implemented in C but at a later date if your much more powerful seq stuff gets added then that may enable multi_lookup to be implemented in terms of seq. I'm happy to have a stab at putting together a patch for multi_lookup if there is any interest? I'm keen to know if people like the idea, don't like the idea or are indifferent to it :) Colm From saleyn@REDACTED Wed Oct 1 19:37:44 2008 From: saleyn@REDACTED (Serge Aleynikov) Date: Wed, 01 Oct 2008 13:37:44 -0400 Subject: [erlang-questions] GTK bindings In-Reply-To: <48E3AD6F.5050909@gmail.com> References: <48CF2F1B.3070003@lionet.info> <2ae3549f-f1cb-4e3c-b7e3-d805c6de372a@m36g2000hse.googlegroups.com> <48CFF05B.90401@lionet.info> <15b6a55b-956f-45c8-b412-76751fe630ab@e53g2000hsa.googlegroups.com> <087d239c-07b5-47ef-9372-ae097ca12bcd@m45g2000hsb.googlegroups.com> <3dbc6d1c0809161457v2ed4f29bxe16bcc124dbf06f5@mail.gmail.com> <14f0e3620809161547x32377a37ke4c9abee0a8c41e1@mail.gmail.com> <3dbc6d1c0809161643t33fb3a80l7cb4b330333a1ef7@mail.gmail.com> <4ac8254d0809170244s4ebd31b1y4d0b361cdf3cb76f@mail.gmail.com> <48D1FC87.8030601@it.uu.se> <48E0C70D.5020700@gmail.com> <48E3AD6F.5050909@gmail.com> Message-ID: <48E3B568.2010702@gmail.com> Actually I poked around with the makefile settings for gtknode and somehow the problem went away... Serge Aleynikov wrote: > I compiled the project and have been getting these errors at run-time. > As a result the fonts are unreadable. Do you know how to switch font in > the examples? > > =INFO REPORT==== 1-Oct-2008::12:51:27 === > in: {gtknode,handle_portdata,2} > portdata: "\n(gtknode:17066): Pango-WARNING **: failed to find > shape engine, expect ugly output. engine-type='PangoRenderFc', > script='latin'\n" > > =INFO REPORT==== 1-Oct-2008::12:51:27 === > in: {gtknode,handle_portdata,2} > portdata: "\n(gtknode:17066): Pango-WARNING **: failed to find > shape engine, expect ugly output. engine-type='PangoRenderFc', > script='common'\n" > > =INFO REPORT==== 1-Oct-2008::12:51:27 === > in: {gtknode,handle_portdata,2} > portdata: "\n(gtknode:17066): Pango-WARNING **: > _pango_cairo_font_install called with bad font, expect ugly output\n" > > > Mats Cronqvist wrote: >> Richard Carlsson wrote: >>> YourSurrogateGod wrote: >>> >>>> Speaking of GTK bindings. Are there any so that one could make Gnome >>>> applications (use all of the widgets and such) with Erlang? I haven't >>>> heard of any at the moment... >>>> >>> The most mature (and portable) alternative is probably WxErlang: >>> http://www.erlang.org/~dgud/wxerlang/ >>> http://sourceforge.net/projects/wxerlang/ >>> >> will, in all likelihood, eventually be bundled with OTP. >> >>> There are also a couple of attempts at direct GTK bindings, but >>> don't know what their status is: >>> >>> http://code.google.com/p/gtknode/ >>> >> gtknode works fine on all versions of GTK from 2.4 to 2.12 (compiled >> it last friday). >> >>> http://erlgtk.sourceforge.net/ >> dead AFAIK. >> >> mats >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From joelr1@REDACTED Wed Oct 1 20:10:33 2008 From: joelr1@REDACTED (Joel Reymont) Date: Wed, 1 Oct 2008 19:10:33 +0100 Subject: [erlang-questions] Erlang doesn't suck In-Reply-To: <48E3AC18.2010700@cs.ntua.gr> References: <48E3AC18.2010700@cs.ntua.gr> Message-ID: <01F5698E-8E44-4F29-8862-F3F073451E51@gmail.com> On Oct 1, 2008, at 5:58 PM, Kostis Sagonas wrote: > Before you make yourself bald :-), you should probably read the > following: > > http://user.it.uu.se/~kostis/Papers/wrangler.pdf Kostis, I'll give you the benefit of a doubt and ponder how Wrangler would have helped me switch from tuples to records everywhere in OpenPoker. I have a hunch that "typing things up" would have taken almost as long as the refactoring job itself. And then I would have had to retype everything again for records. I'll take static typing and type inference over dynamic typing almost any day of the week. -- wagerlabs.com From als@REDACTED Wed Oct 1 20:11:30 2008 From: als@REDACTED (Anthony Shipman) Date: Thu, 2 Oct 2008 04:11:30 +1000 Subject: [erlang-questions] typer bug? Message-ID: <200810020411.30133.als@iinet.net.au> I've got a recursive type specification. typer didn't seem to cope: > grep xmlNode */*l common/dwcConfig.erl:-spec loadConfig() -> {ok, xmlNode()} | {error, Reason::any()}. common/dwcConfig.erl:-spec toSimpleTree(xmlElement()) -> xmlNode(). common/dwcTypes.hrl:-type xmlNode() :: {Name::atom(), [{atom(), string()}], [xmlNode()]}. > typer --plt ../.erlang_plt -r . typer: analysis failed with error report: Unknown type xmlNode dwcConfig includes the dwcTypes.hrl file. -- Anthony Shipman Mamas don't let your babies als@REDACTED grow up to be outsourced. From ulf.wiger@REDACTED Wed Oct 1 20:17:55 2008 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Wed, 01 Oct 2008 20:17:55 +0200 Subject: [erlang-questions] Erlang doesn't suck In-Reply-To: <01F5698E-8E44-4F29-8862-F3F073451E51@gmail.com> References: <48E3AC18.2010700@cs.ntua.gr> <01F5698E-8E44-4F29-8862-F3F073451E51@gmail.com> Message-ID: <48E3BED3.4020202@ericsson.com> Joel, The paper describes how Kostis applied Dialyzer and Typer to the wrangler source code and found some interesting stuff. It was a great talk at the workshop, Kostis. Thanks. BR, Ulf W Joel Reymont skrev: > On Oct 1, 2008, at 5:58 PM, Kostis Sagonas wrote: > >> Before you make yourself bald :-), you should probably read the >> following: >> >> http://user.it.uu.se/~kostis/Papers/wrangler.pdf > > > Kostis, > > I'll give you the benefit of a doubt and ponder how Wrangler would > have helped me switch from tuples to records everywhere in OpenPoker. > > I have a hunch that "typing things up" would have taken almost as long > as the refactoring job itself. And then I would have had to retype > everything again for records. > > I'll take static typing and type inference over dynamic typing almost > any day of the week. > > -- > wagerlabs.com > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From kostis@REDACTED Wed Oct 1 20:19:13 2008 From: kostis@REDACTED (Kostis Sagonas) Date: Wed, 01 Oct 2008 21:19:13 +0300 Subject: [erlang-questions] Erlang doesn't suck In-Reply-To: <01F5698E-8E44-4F29-8862-F3F073451E51@gmail.com> References: <48E3AC18.2010700@cs.ntua.gr> <01F5698E-8E44-4F29-8862-F3F073451E51@gmail.com> Message-ID: <48E3BF21.9090603@cs.ntua.gr> Joel Reymont wrote: > > On Oct 1, 2008, at 5:58 PM, Kostis Sagonas wrote: > >> Before you make yourself bald :-), you should probably read the >> following: >> >> http://user.it.uu.se/~kostis/Papers/wrangler.pdf > > > Kostis, > > I'll give you the benefit of a doubt and ponder how Wrangler would have > helped me switch from tuples to records everywhere in OpenPoker. The paper is *not* about Wrangler, refactoring or converting to records. Perhaps it's a good idea to read it first --- you might see its point... Kostis From mats.cronqvist@REDACTED Wed Oct 1 20:20:26 2008 From: mats.cronqvist@REDACTED (Mats Cronqvist) Date: Wed, 01 Oct 2008 20:20:26 +0200 Subject: [erlang-questions] GTK bindings In-Reply-To: <48E3B568.2010702@gmail.com> References: <48CF2F1B.3070003@lionet.info> <2ae3549f-f1cb-4e3c-b7e3-d805c6de372a@m36g2000hse.googlegroups.com> <48CFF05B.90401@lionet.info> <15b6a55b-956f-45c8-b412-76751fe630ab@e53g2000hsa.googlegroups.com> <087d239c-07b5-47ef-9372-ae097ca12bcd@m45g2000hsb.googlegroups.com> <3dbc6d1c0809161457v2ed4f29bxe16bcc124dbf06f5@mail.gmail.com> <14f0e3620809161547x32377a37ke4c9abee0a8c41e1@mail.gmail.com> <3dbc6d1c0809161643t33fb3a80l7cb4b330333a1ef7@mail.gmail.com> <4ac8254d0809170244s4ebd31b1y4d0b361cdf3cb76f@mail.gmail.com> <48D1FC87.8030601@it.uu.se> <48E0C70D.5020700@gmail.com> <48E3AD6F.5050909@gmail.com> <48E3B568.2010702@gmail.com> Message-ID: <48E3BF6A.50803@gmail.com> Serge Aleynikov wrote: > Actually I poked around with the makefile settings for gtknode and > somehow the problem went away... good thing, as i've never seen those errors... From als@REDACTED Wed Oct 1 19:10:12 2008 From: als@REDACTED (Anthony Shipman) Date: Thu, 2 Oct 2008 03:10:12 +1000 Subject: [erlang-questions] standard types for dialyzer Message-ID: <200810020310.12947.als@iinet.net.au> There are a lot of types for the stdlib and kernel functions. These should go into a single header file that all applications can include. Otherwise there can easily be clashes. For example I've defined a date() for my code but it clashes with "kernel/include/file.hrl" on the few occasions I include it. -- Anthony Shipman Mamas don't let your babies als@REDACTED grow up to be outsourced. From tty.erlang@REDACTED Wed Oct 1 20:34:07 2008 From: tty.erlang@REDACTED (t ty) Date: Wed, 1 Oct 2008 14:34:07 -0400 Subject: [erlang-questions] Erlang doesn't suck In-Reply-To: <48E3BED3.4020202@ericsson.com> References: <48E3AC18.2010700@cs.ntua.gr> <01F5698E-8E44-4F29-8862-F3F073451E51@gmail.com> <48E3BED3.4020202@ericsson.com> Message-ID: <290b3ba10810011134j1bec4347qbb7309075266a10f@mail.gmail.com> On Wed, Oct 1, 2008 at 2:17 PM, Ulf Wiger (TN/EAB) wrote: > > Joel, > > The paper describes how Kostis applied Dialyzer and > Typer to the wrangler source code and found some > interesting stuff. > > It was a great talk at the workshop, Kostis. Thanks. I agree. I consider this a must read paper from this year's workshop. t From joelr1@REDACTED Wed Oct 1 20:49:24 2008 From: joelr1@REDACTED (Joel Reymont) Date: Wed, 1 Oct 2008 19:49:24 +0100 Subject: [erlang-questions] Erlang doesn't suck In-Reply-To: <48E3BF21.9090603@cs.ntua.gr> References: <48E3AC18.2010700@cs.ntua.gr> <01F5698E-8E44-4F29-8862-F3F073451E51@gmail.com> <48E3BF21.9090603@cs.ntua.gr> Message-ID: On Oct 1, 2008, at 7:19 PM, Kostis Sagonas wrote: > The paper is *not* about Wrangler, refactoring or converting to > records. > Perhaps it's a good idea to read it first --- you might see its > point... I skimmed the paper before replying. The paper is about using Dialyzer on Wrangler. The point that I'm trying to make is that I think Dialyzer would have helped me convert from tuples to records. -- wagerlabs.com From joelr1@REDACTED Wed Oct 1 20:51:39 2008 From: joelr1@REDACTED (Joel Reymont) Date: Wed, 1 Oct 2008 19:51:39 +0100 Subject: [erlang-questions] Building 64-bit Erlang on Solaris 11 Message-ID: <11584396-2118-469C-88DA-B234E10130CA@gmail.com> ./configure --prefix=/opt/local --enable-64bit CFLAGS='-m64' ... gmake ... ld: fatal: file obj/i386-pc-solaris2.11/opt/plain/erl_main.o: wrong ELF class: ELFCLASS64 ld: fatal: File processing errors. No output written to /home/admin/ otp_src_R12B-4/bin/i386-pc-solaris2.11/beam What am I doing wrong? Thanks, Joel P.S. Omitting CFLAGS='-m64' builds a 32-bit Erlang. -- wagerlabs.com From joelr1@REDACTED Wed Oct 1 20:53:29 2008 From: joelr1@REDACTED (Joel Reymont) Date: Wed, 1 Oct 2008 19:53:29 +0100 Subject: [erlang-questions] Erlang doesn't suck In-Reply-To: <48E3A86A.8010508@alertlogic.net> References: <48E3A1E6.4090307@alertlogic.net> <9D9606A2-0064-471E-B214-9E82DC850982@gmail.com> <48E3A86A.8010508@alertlogic.net> Message-ID: <28B99EDD-C840-4E3F-B59C-77A89F371B12@gmail.com> On Oct 1, 2008, at 5:42 PM, Paul Fisher wrote: > Which begs the question of whether you compile to native or not for > your benchmarking? Not everything benefits, but we have some > modules that show significant gains from: > > -compile([native, {hipe,[o3]}, inline]). There's certainly an increase in throughput (request per second) with hipe, even under 32 bits. Is there a way to mass-hipe-compile all of OTP? Simulating gameplay with 3000 games... Waiting for games to end... ... =INFO REPORT==== 1-Oct-2008::18:15:35 === requests: 40041 bytes: 736492 requests_per_second: 1334 bytes_per_second: 24549 50 games finished ... 1250 games finished ... =INFO REPORT==== 1-Oct-2008::18:16:06 === requests: 48419 bytes: 543775 requests_per_second: 1611 bytes_per_second: 18100 ... 3000 games finished =INFO REPORT==== 1-Oct-2008::18:16:35 === requests: 39604 bytes: 345976 requests_per_second: 1319 bytes_per_second: 11529 Elapsed: 62.517129s, Average run time: 0.020839043 seconds Now I have to try to compile R12B4 in 64-bit mode.... -- wagerlabs.com From erlang-questions_efine@REDACTED Wed Oct 1 21:42:00 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Wed, 1 Oct 2008 15:42:00 -0400 Subject: [erlang-questions] Erlang doesn't suck In-Reply-To: <28B99EDD-C840-4E3F-B59C-77A89F371B12@gmail.com> References: <48E3A1E6.4090307@alertlogic.net> <9D9606A2-0064-471E-B214-9E82DC850982@gmail.com> <48E3A86A.8010508@alertlogic.net> <28B99EDD-C840-4E3F-B59C-77A89F371B12@gmail.com> Message-ID: <6c2563b20810011242k12b0375bjfbaba3a02f0f29c6@mail.gmail.com> I have not measured it in this specific instance, so I may be wrong, but I don't think you will get a net increase in performance from 64 bit code (compared to 32 bits on the same processor). In almost every case that I can think of where I have used both, the 32 bit code was on average faster and (unsurprisingly) smaller. Where 64 bits won was when lots of memory was needed and available for use. Maybe if the code had optimizations for the 64 bit processor which included some faster instructions that were specific to the 64-bit mode, and a nice fat register set to avoid passing parameters on the stack, it could be faster. I am very curious: has anyone taken any performance measurements of real-world applications in 32 bit vs 64 bit Erlang on the same processor configuration? As for compilation failures you are seeing, I would try setting the following: export LDFLAGS="-m64 $LDFLAGS" export CFLAGS="-m64 $CFLAGS" The LDFLAGS is needed so that the build doesn't try to link with 32-bit objects. On Wed, Oct 1, 2008 at 2:53 PM, Joel Reymont wrote: > > On Oct 1, 2008, at 5:42 PM, Paul Fisher wrote: > > > Which begs the question of whether you compile to native or not for > > your benchmarking? Not everything benefits, but we have some > > modules that show significant gains from: > > > > -compile([native, {hipe,[o3]}, inline]). > > > There's certainly an increase in throughput (request per second) with > hipe, even under 32 bits. > > Is there a way to mass-hipe-compile all of OTP? > > Simulating gameplay with 3000 games... > Waiting for games to end... > ... > =INFO REPORT==== 1-Oct-2008::18:15:35 === > requests: 40041 > bytes: 736492 > requests_per_second: 1334 > bytes_per_second: 24549 > 50 games finished > ... > 1250 games finished > ... > =INFO REPORT==== 1-Oct-2008::18:16:06 === > requests: 48419 > bytes: 543775 > requests_per_second: 1611 > bytes_per_second: 18100 > ... > 3000 games finished > > =INFO REPORT==== 1-Oct-2008::18:16:35 === > requests: 39604 > bytes: 345976 > requests_per_second: 1319 > bytes_per_second: 11529 > > Elapsed: 62.517129s, Average run time: 0.020839043 seconds > > Now I have to try to compile R12B4 in 64-bit mode.... > > > -- > wagerlabs.com > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From joelr1@REDACTED Wed Oct 1 21:48:02 2008 From: joelr1@REDACTED (Joel Reymont) Date: Wed, 1 Oct 2008 20:48:02 +0100 Subject: [erlang-questions] Erlang doesn't suck In-Reply-To: <6c2563b20810011242k12b0375bjfbaba3a02f0f29c6@mail.gmail.com> References: <48E3A1E6.4090307@alertlogic.net> <9D9606A2-0064-471E-B214-9E82DC850982@gmail.com> <48E3A86A.8010508@alertlogic.net> <28B99EDD-C840-4E3F-B59C-77A89F371B12@gmail.com> <6c2563b20810011242k12b0375bjfbaba3a02f0f29c6@mail.gmail.com> Message-ID: <2EE20B52-57F9-4E66-AE53-EA4544E7FF07@gmail.com> On Oct 1, 2008, at 8:42 PM, Edwin Fine wrote: > As for compilation failures you are seeing, I would try setting the > following: > > export LDFLAGS="-m64 $LDFLAGS" > export CFLAGS="-m64 $CFLAGS" Did the above and then ./configure --prefix=/opt/local --enable-64bit ... gmake clean && gmake ... ld: warning: file /home/admin/otp_src_R12B-4/erts/emulator/zlib/obj/ i386-pc-solaris2.11/opt/libz.a(adler32.o): wrong ELF class: ELFCLASS32 ld: warning: file /home/admin/otp_src_R12B-4/erts/emulator/pcre/obj/ i386-pc-solaris2.11/opt/libepcre.a(pcre_compile.o): wrong ELF class: ELFCLASS32 Undefined first referenced symbol in file inflate obj/i386-pc-solaris2.11/opt/plain/ gzio.o crc32 obj/i386-pc-solaris2.11/opt/plain/ erl_bif_ch -- wagerlabs.com From pfisher@REDACTED Wed Oct 1 21:54:18 2008 From: pfisher@REDACTED (Paul Fisher) Date: Wed, 01 Oct 2008 14:54:18 -0500 Subject: [erlang-questions] Building 64-bit Erlang on Solaris 11 In-Reply-To: <11584396-2118-469C-88DA-B234E10130CA@gmail.com> References: <11584396-2118-469C-88DA-B234E10130CA@gmail.com> Message-ID: <48E3D56A.4060807@alertlogic.net> Joel Reymont wrote: > ./configure --prefix=/opt/local --enable-64bit CFLAGS='-m64' > ... > gmake > ... > ld: fatal: file obj/i386-pc-solaris2.11/opt/plain/erl_main.o: wrong > ELF class: ELFCLASS64 > ld: fatal: File processing errors. No output written to /home/admin/ > otp_src_R12B-4/bin/i386-pc-solaris2.11/beam > > What am I doing wrong? > > Thanks, Joel > > P.S. Omitting CFLAGS='-m64' builds a 32-bit Erlang. Not so straight forward (esp. if you use linked in drivers as we do). Here is what it takes First this patch: This patch allows 64-bit builds when the target system supports both 32-bit and 64-bit in the same system environment. Specifically, this works on Solaris 10/Opensolaris, and adjusts the --enable-darwin-64-bit configure flag to be simply --enable-64bit so that it can be used for the same purpose on both darwin and solaris (building 64-bit target environment) without having to introduce another system specific configure flag. This cleanly builds with the following configure command line: ~/bld/otp_src_R12B-3$ CFLAGS='-m64' LDFLAGS='-m64' ./configure \ --enable-threads \ --enable-smp-support --enable-kernel-poll --enable-hipe \ --disable-megaco-flex-scanner-drvlineno --without-odbc \ --enable-64bit on: ~/bld/otp_src_R12B-3$ uname -a SunOS pfisher-laptop 5.11 snv_94 i86pc i386 i86pc Solaris This does not fix common_test, which seems to be in its own world, and I'll send another patch for that. For now I just set it to SKIP. diff -ru otp_src_R12B-4/configure otp_src_R12B-4.64bit/configure --- otp_src_R12B-4/configure 2008-09-02 13:03:59.000000000 -0500 +++ otp_src_R12B-4.64bit/configure 2008-10-01 14:20:07.448422739 -0500 @@ -814,7 +814,7 @@ --enable-dynamic-ssl-lib force using dynamic openssl libraries --disable-erlang-mandir do not install Erlang man pages in a private directory --enable-darwin-universal build universal binaries on darwin i386 - --enable-darwin-64bit build 64bit binaries on darwin + --enable-64bit build 64bit binaries on 32/64 capable systems Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] @@ -2645,23 +2645,23 @@ fi; -# Check whether --enable-darwin-64bit or --disable-darwin-64bit was given. -if test "${enable_darwin_64bit+set}" = set; then - enableval="$enable_darwin_64bit" +# Check whether --enable-64bit or --disable-64bit was given. +if test "${enable_64bit+set}" = set; then + enableval="$enable_64bit" case "$enableval" in - no) enable_darwin_64bit=no ;; - *) enable_darwin_64bit=yes ;; + no) enable_64bit=no ;; + *) enable_64bit=yes ;; esac else - enable_darwin_64bit=no + enable_64bit=no fi; TMPSYS=`uname -s`-`uname -m` if test X${enable_darwin_universal} = Xyes; then - if test X${enable_darwin_64bit} = Xyes; then + if test X${enable_64bit} = Xyes; then { { echo "$as_me:$LINENO: error: --enable-darwin-universal and --enable-darwin-64bit mutually exclusive" >&5 -echo "$as_me: error: --enable-darwin-universal and --enable-darwin-64bit mutually exclusive" >&2;} +echo "$as_me: error: --enable-darwin-universal and --enable-64bit mutually exclusive" >&2;} { (exit 1); exit 1; }; } fi enable_hipe=no @@ -2670,17 +2670,39 @@ LDFLAGS="-arch i386 -arch ppc $LDFLAGS" export LDFLAGS fi -if test X${enable_darwin_64bit} = Xyes; then - if test X"$TMPSYS" '!=' X"Darwin-i386"; then - { { echo "$as_me:$LINENO: error: --enable-darwin-64bit only supported on x86 host" >&5 -echo "$as_me: error: --enable-darwin-64bit only supported on x86 host" >&2;} - { (exit 1); exit 1; }; } - fi - enable_hipe=no - CFLAGS="-m64 $CFLAGS" - export CFLAGS - LDFLAGS="-m64 $LDFLAGS" - export LDFLAGS +if test X${enable_64bit} = Xyes; then + case $TMPSYS in + Darwin-i386) + enable_hipe=no + CFLAGS="-m64 $CFLAGS" + export CFLAGS + LDFLAGS="-m64 $LDFLAGS" + export LDFLAGS + ;; + SunOS-i86pc) + case $CFLAGS in + *-m64*) + ;; + *) + CFLAGS="-m64 $CFLAGS" + export CLAGS + ;; + esac + case $LDLAGS in + *-m64*) + ;; + *) + LDLAGS="-m64 $LDLAGS" + export LDLAGS + ;; + esac + ;; + + *) + echo "$as_me: error: --enable-64bit only supported on x86 host" + exit 1 + ;; + esac fi export ERL_TOP diff -ru otp_src_R12B-4/configure.in otp_src_R12B-4.64bit/configure.in --- otp_src_R12B-4/configure.in 2008-06-10 07:47:35.000000000 -0500 +++ otp_src_R12B-4.64bit/configure.in 2008-10-01 14:19:13.437109172 -0500 @@ -179,20 +179,20 @@ ],enable_darwin_universal=no) -AC_ARG_ENABLE(darwin-64bit, -[ --enable-darwin-64bit build 64bit binaries on darwin], +AC_ARG_ENABLE(64bit, +[ --enable-64bit build 64bit binaries on 32/64 bit capable system], [ case "$enableval" in - no) enable_darwin_64bit=no ;; - *) enable_darwin_64bit=yes ;; + no) enable_64bit=no ;; + *) enable_64bit=yes ;; esac -],enable_darwin_64bit=no) +],enable_64bit=no) dnl OK, we might have darwin switches off different kinds, lets dnl check it all before continuing. TMPSYS=`uname -s`-`uname -m` if test X${enable_darwin_universal} = Xyes; then if test X${enable_darwin_64bit} = Xyes; then - AC_MSG_ERROR([--enable-darwin-universal and --enable-darwin-64bit mutually exclusive]) + AC_MSG_ERROR([--enable-darwin-universal and --enable-64bit mutually exclusive]) fi enable_hipe=no CFLAGS="-arch i386 -arch ppc $CFLAGS" @@ -200,15 +200,39 @@ LDFLAGS="-arch i386 -arch ppc $LDFLAGS" export LDFLAGS fi -if test X${enable_darwin_64bit} = Xyes; then - if test X"$TMPSYS" '!=' X"Darwin-i386"; then - AC_MSG_ERROR([--enable-darwin-64bit only supported on x86 host]) - fi - enable_hipe=no - CFLAGS="-m64 $CFLAGS" - export CFLAGS - LDFLAGS="-m64 $LDFLAGS" - export LDFLAGS +if test X${enable_64bit} = Xyes; then + case $TMPSYS in + Darwin-i386) + enable_hipe=no + CFLAGS="-m64 $CFLAGS" + export CFLAGS + LDFLAGS="-m64 $LDFLAGS" + export LDFLAGS + ;; + SunOS-i86pc) + case $CFLAGS in + *-m64*) + ;; + *) + CFLAGS="-m64 $CFLAGS" + export CLAGS + ;; + esac + case $LDLAGS in + *-m64*) + ;; + *) + LDLAGS="-m64 $LDLAGS" + export LDLAGS + ;; + esac + ;; + + *) + echo "$as_me: error: --enable-64bit only supported on x86 host" + exit 1 + ;; + esac fi export ERL_TOP diff -ru otp_src_R12B-4/erts/configure otp_src_R12B-4.64bit/erts/configure --- otp_src_R12B-4/erts/configure 2008-09-02 13:03:54.000000000 -0500 +++ otp_src_R12B-4.64bit/erts/configure 2008-10-01 14:17:36.145321678 -0500 @@ -863,7 +863,7 @@ --enable-elib-malloc use elib_malloc instead of normal malloc --enable-fp-exceptions Use hardware floating point exceptions (default if hipe enabled) --enable-darwin-universal build universal binaries on darwin i386 - --enable-darwin-64bit build 64bit binaries on darwin + --enable-64bit build 64bit binaries on 32/64 capable system --disable-fixalloc disable the use of fix_alloc --enable-clock-gettime Use clock-gettime for time correction --enable-native-ethr-impls enable native ethread implementations @@ -2665,16 +2665,16 @@ fi; -# Check whether --enable-darwin-64bit or --disable-darwin-64bit was given. -if test "${enable_darwin_64bit+set}" = set; then - enableval="$enable_darwin_64bit" +# Check whether --enable-64bit or --disable-64bit was given. +if test "${enable_64bit+set}" = set; then + enableval="$enable_64bit" case "$enableval" in - no) enable_darwin_64bit=no ;; - *) enable_darwin_64bit=yes ;; + no) enable_64bit=no ;; + *) enable_64bit=yes ;; esac else - enable_darwin_64bit=no + enable_64bit=no fi; @@ -2755,9 +2755,9 @@ TMPSYS=`uname -s`-`uname -m` if test X${enable_darwin_universal} = Xyes; then - if test X${enable_darwin_64bit} = Xyes; then - { { echo "$as_me:$LINENO: error: --enable-darwin-universal and --enable-darwin-64bit mutually exclusive" >&5 -echo "$as_me: error: --enable-darwin-universal and --enable-darwin-64bit mutually exclusive" >&2;} + if test X${enable_64bit} = Xyes; then + { { echo "$as_me:$LINENO: error: --enable-darwin-universal and --enable-64bit mutually exclusive" >&5 +echo "$as_me: error: --enable-darwin-universal and --enable-64bit mutually exclusive" >&2;} { (exit 1); exit 1; }; } fi enable_hipe=no @@ -2776,20 +2776,35 @@ ;; esac fi -if test X${enable_darwin_64bit} = Xyes; then - if test X"$TMPSYS" '!=' X"Darwin-i386"; then - { { echo "$as_me:$LINENO: error: --enable-darwin-64bit only supported on x86 host" >&5 -echo "$as_me: error: --enable-darwin-64bit only supported on x86 host" >&2;} - { (exit 1); exit 1; }; } - fi - enable_hipe=no - case $CFLAGS in +if test X${enable_64bit} = Xyes; then + case $TMPSYS in + Darwin-i386) + enable_hipe=no + case $CFLAGS in *-m64*) ;; *) CFLAGS="-m64 $CFLAGS" + export CLAGS ;; - esac + esac + ;; + SunOS-i86pc) + case $CFLAGS in + *-m64*) + ;; + *) + CFLAGS="-m64 $CFLAGS" + export CLAGS + ;; + esac + ;; + + *) + echo "$as_me: error: --enable-64bit only supported on x86 host" + exit 1 + ;; + esac fi @@ -4716,6 +4731,17 @@ esac fi ;; + amd64-sol2*) + { echo "$as_me:$LINENO: Adjusting LDFLAGS to cope with 64bit SunOS" >&5 +echo "$as_me: Adjusting LDFLAGS to cope with 64bit SunOS" >&6;} + case $LDFLAGS in + *-m64*) + ;; + *) + LDFLAGS="-m64 $LDFLAGS" + ;; + esac + ;; esac @@ -20430,7 +20456,19 @@ DED_LD_FLAG_RUNTIME_LIBRARY_PATH= ;; solaris2*|sysv4*) + DED_LD=$CC DED_LDFLAGS="-G" + case $CC in + gcc) + DED_LDFLAGS="-shared $DED_LDFLAGS" + ;; + esac + case $ARCH in + amd64) + DED_LDFLAGS="-m64 $DED_LDFLAGS" + DED_CFLAGS="-m64 $DED_CFLAGS" + ;; + esac ;; aix4*) DED_LDFLAGS="-G -bnoentry -bexpall" diff -ru otp_src_R12B-4/erts/configure.in otp_src_R12B-4.64bit/erts/configure.in --- otp_src_R12B-4/erts/configure.in 2008-09-01 07:51:17.000000000 -0500 +++ otp_src_R12B-4.64bit/erts/configure.in 2008-10-01 14:17:39.750396425 -0500 @@ -172,13 +172,13 @@ ],enable_darwin_universal=no) -AC_ARG_ENABLE(darwin-64bit, -[ --enable-darwin-64bit build 64bit binaries on darwin], +AC_ARG_ENABLE(64bit, +[ --enable-64bit build 64bit binaries on 32/64 capable system], [ case "$enableval" in - no) enable_darwin_64bit=no ;; - *) enable_darwin_64bit=yes ;; + no) enable_64bit=no ;; + *) enable_64bit=yes ;; esac -],enable_darwin_64bit=no) +],enable_64bit=no) AC_ARG_ENABLE(fixalloc, @@ -239,8 +239,8 @@ dnl check it all before continuing. TMPSYS=`uname -s`-`uname -m` if test X${enable_darwin_universal} = Xyes; then - if test X${enable_darwin_64bit} = Xyes; then - AC_MSG_ERROR([--enable-darwin-universal and --enable-darwin-64bit mutually exclusive]) + if test X${enable_64bit} = Xyes; then + AC_MSG_ERROR([--enable-darwin-universal and --enable-64bit mutually exclusive]) fi enable_hipe=no case $CFLAGS in @@ -258,18 +258,35 @@ ;; esac fi -if test X${enable_darwin_64bit} = Xyes; then - if test X"$TMPSYS" '!=' X"Darwin-i386"; then - AC_MSG_ERROR([--enable-darwin-64bit only supported on x86 host]) - fi - enable_hipe=no - case $CFLAGS in +if test X${enable_64bit} = Xyes; then + case $TMPSYS in + Darwin-i386) + enable_hipe=no + case $CFLAGS in *-m64*) ;; *) CFLAGS="-m64 $CFLAGS" + export CLAGS ;; - esac + esac + ;; + SunOS-i86pc) + case $CFLAGS in + *-m64*) + ;; + *) + CFLAGS="-m64 $CFLAGS" + export CLAGS + ;; + esac + ;; + + *) + echo "$as_me: error: --enable-64bit only supported on x86 host" + exit 1 + ;; + esac fi @@ -494,10 +511,10 @@ dnl has a build/configure system re rx-lib that is not compatible dnl First remove common_tests skip file. -dnl Adjust LDFLAGS to allow 64bit linkage on DARWIN +dnl Adjust LDFLAGS to allow 64bit linkage on 32/64 system case $ARCH-$OPSYS in - amd64-darwin*) - AC_MSG_NOTICE([Adjusting LDFLAGS to cope with 64bit Darwin]) + amd64-darwin*|amd64-sol2*) + AC_MSG_NOTICE([Adjusting LDFLAGS to cope with 64bit system]) case $LDFLAGS in *-m64*) ;; @@ -526,6 +543,17 @@ esac fi ;; + amd64-sol2*) + { echo "$as_me:$LINENO: Adjusting LDFLAGS to cope with 64bit SunOS" >&5 +echo "$as_me: Adjusting LDFLAGS to cope with 64bit SunOS" >&6;} + case $LDFLAGS in + *-m64*) + ;; + *) + LDFLAGS="-m64 $LDFLAGS" + ;; + esac + ;; esac @@ -2732,7 +2760,19 @@ DED_LD_FLAG_RUNTIME_LIBRARY_PATH= ;; solaris2*|sysv4*) + DED_LD=$CC DED_LDFLAGS="-G" + case $CC in + gcc) + DED_LDFLAGS="-shared $DED_LDFLAGS" + ;; + esac + case $ARCH in + amd64) + DED_LDFLAGS="-m64 $DED_LDFLAGS" + DED_CFLAGS="-m64 $DED_CFLAGS" + ;; + esac ;; aix4*) DED_LDFLAGS="-G -bnoentry -bexpall" Then a script that configures and builds stuff (the skip of common_test is important, others are just to avoid building them): #!/usr/bin/env bash set -e cd otp_src_R12B-4 CFLAGS='-m64' LDFLAGS='-m64' LIBS='-lumem' ./configure --enable-threads --enable-smp-support --enable-kernel-poll --enable-hipe --disable-megaco-flex-scanner-drvlineno --without-unixodbc --enable-64bit touch lib/common_test/SKIP touch lib/cosEvent/SKIP touch lib/cosEventDomain/SKIP touch lib/cosFileTransfer/SKIP touch lib/cosNotification/SKIP touch lib/cosProperty/SKIP touch lib/cosTime/SKIP touch lib/cosTransactions/SKIP touch lib/megaco/SKIP touch lib/odbc/SKIP touch lib/orber/SKIP make pfexec make install -- paul From erlang-questions_efine@REDACTED Wed Oct 1 22:27:11 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Wed, 1 Oct 2008 16:27:11 -0400 Subject: [erlang-questions] Erlang doesn't suck In-Reply-To: <2EE20B52-57F9-4E66-AE53-EA4544E7FF07@gmail.com> References: <48E3A1E6.4090307@alertlogic.net> <9D9606A2-0064-471E-B214-9E82DC850982@gmail.com> <48E3A86A.8010508@alertlogic.net> <28B99EDD-C840-4E3F-B59C-77A89F371B12@gmail.com> <6c2563b20810011242k12b0375bjfbaba3a02f0f29c6@mail.gmail.com> <2EE20B52-57F9-4E66-AE53-EA4544E7FF07@gmail.com> Message-ID: <6c2563b20810011327i120c30f3sc5a5ac82903c88ba@mail.gmail.com> Looks like Paul Fisher has it nailed :) On Wed, Oct 1, 2008 at 3:48 PM, Joel Reymont wrote: > > On Oct 1, 2008, at 8:42 PM, Edwin Fine wrote: > > As for compilation failures you are seeing, I would try setting the >> following: >> >> export LDFLAGS="-m64 $LDFLAGS" >> export CFLAGS="-m64 $CFLAGS" >> > > > Did the above and then > > ./configure --prefix=/opt/local --enable-64bit > ... > gmake clean && gmake > ... > ld: warning: file > /home/admin/otp_src_R12B-4/erts/emulator/zlib/obj/i386-pc-solaris2.11/opt/libz.a(adler32.o): > wrong ELF class: ELFCLASS32 > ld: warning: file > /home/admin/otp_src_R12B-4/erts/emulator/pcre/obj/i386-pc-solaris2.11/opt/libepcre.a(pcre_compile.o): > wrong ELF class: ELFCLASS32 > Undefined first referenced > symbol in file > inflate > obj/i386-pc-solaris2.11/opt/plain/gzio.o > crc32 > obj/i386-pc-solaris2.11/opt/plain/erl_bif_ch > > -- > wagerlabs.com > > > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kostis@REDACTED Wed Oct 1 22:57:45 2008 From: kostis@REDACTED (Kostis Sagonas) Date: Wed, 01 Oct 2008 23:57:45 +0300 Subject: [erlang-questions] Erlang doesn't suck In-Reply-To: <290b3ba10810011134j1bec4347qbb7309075266a10f@mail.gmail.com> References: <48E3AC18.2010700@cs.ntua.gr> <01F5698E-8E44-4F29-8862-F3F073451E51@gmail.com> <48E3BED3.4020202@ericsson.com> <290b3ba10810011134j1bec4347qbb7309075266a10f@mail.gmail.com> Message-ID: <48E3E449.9090509@cs.ntua.gr> t ty wrote: > On Wed, Oct 1, 2008 at 2:17 PM, Ulf Wiger (TN/EAB) > wrote: >> Joel, >> >> The paper describes how Kostis applied Dialyzer and >> Typer to the wrangler source code and found some >> interesting stuff. >> >> It was a great talk at the workshop, Kostis. Thanks. > > I agree. I consider this a must read paper from this year's workshop. Thank you both for your compliments. I admit that I enjoyed very much both writing the paper and giving the talk at the workshop. For the record, I guess, the paper is not just a case study. It aims to describe a *methodology* on how to gradually type a non-trivial existing Erlang application and the benefits of doing so. Comments welcome! Kostis From kostis@REDACTED Wed Oct 1 23:00:47 2008 From: kostis@REDACTED (Kostis Sagonas) Date: Thu, 02 Oct 2008 00:00:47 +0300 Subject: [erlang-questions] Erlang doesn't suck In-Reply-To: <28B99EDD-C840-4E3F-B59C-77A89F371B12@gmail.com> References: <48E3A1E6.4090307@alertlogic.net> <9D9606A2-0064-471E-B214-9E82DC850982@gmail.com> <48E3A86A.8010508@alertlogic.net> <28B99EDD-C840-4E3F-B59C-77A89F371B12@gmail.com> Message-ID: <48E3E4FF.3020403@cs.ntua.gr> Joel Reymont wrote: > On Oct 1, 2008, at 5:42 PM, Paul Fisher wrote: > > There's certainly an increase in throughput (request per second) with > hipe, even under 32 bits. > > Is there a way to mass-hipe-compile all of OTP? Not an easy one that I know of. We have discussed many times with the OTP folks the possibility to add such a configure option, but so far it has not happened. Yet another item for the upcoming meeting with them. Perhaps this option will be available in R12B-5. Kostis From kostis@REDACTED Wed Oct 1 23:03:30 2008 From: kostis@REDACTED (Kostis Sagonas) Date: Thu, 02 Oct 2008 00:03:30 +0300 Subject: [erlang-questions] typer bug? In-Reply-To: <200810020411.30133.als@iinet.net.au> References: <200810020411.30133.als@iinet.net.au> Message-ID: <48E3E5A2.1070906@cs.ntua.gr> Anthony Shipman wrote: > I've got a recursive type specification. typer didn't seem to cope: User-defined recursive types are currently not supported. This is on our TODO list but I doubt it will happen soon. Sorry about that, Kostis From saleyn@REDACTED Thu Oct 2 01:43:08 2008 From: saleyn@REDACTED (Serge Aleynikov) Date: Wed, 01 Oct 2008 19:43:08 -0400 Subject: [erlang-questions] GTK bindings In-Reply-To: <48E3BF6A.50803@gmail.com> References: <48CF2F1B.3070003@lionet.info> <2ae3549f-f1cb-4e3c-b7e3-d805c6de372a@m36g2000hse.googlegroups.com> <48CFF05B.90401@lionet.info> <15b6a55b-956f-45c8-b412-76751fe630ab@e53g2000hsa.googlegroups.com> <087d239c-07b5-47ef-9372-ae097ca12bcd@m45g2000hsb.googlegroups.com> <3dbc6d1c0809161457v2ed4f29bxe16bcc124dbf06f5@mail.gmail.com> <14f0e3620809161547x32377a37ke4c9abee0a8c41e1@mail.gmail.com> <3dbc6d1c0809161643t33fb3a80l7cb4b330333a1ef7@mail.gmail.com> <4ac8254d0809170244s4ebd31b1y4d0b361cdf3cb76f@mail.gmail.com> <48D1FC87.8030601@it.uu.se> <48E0C70D.5020700@gmail.com> <48E3AD6F.5050909@gmail.com> <48E3B568.2010702@gmail.com> <48E3BF6A.50803@gmail.com> Message-ID: <48E40B0C.4050509@gmail.com> BTW, the top example seems pretty sluggish at responding to grid row updates. Is there a way to ensure that updating the grid & repainting doesn't flicker the screen? Mats Cronqvist wrote: > Serge Aleynikov wrote: >> Actually I poked around with the makefile settings for gtknode and >> somehow the problem went away... > good thing, as i've never seen those errors... > From yoursurrogategod@REDACTED Thu Oct 2 04:53:33 2008 From: yoursurrogategod@REDACTED (YourSurrogateGod) Date: Wed, 1 Oct 2008 19:53:33 -0700 (PDT) Subject: [erlang-questions] GTK bindings In-Reply-To: <48E3B568.2010702@gmail.com> References: <48CF2F1B.3070003@lionet.info> <2ae3549f-f1cb-4e3c-b7e3-d805c6de372a@m36g2000hse.googlegroups.com> <48CFF05B.90401@lionet.info> <15b6a55b-956f-45c8-b412-76751fe630ab@e53g2000hsa.googlegroups.com> <087d239c-07b5-47ef-9372-ae097ca12bcd@m45g2000hsb.googlegroups.com> <3dbc6d1c0809161457v2ed4f29bxe16bcc124dbf06f5@mail.gmail.com> <14f0e3620809161547x32377a37ke4c9abee0a8c41e1@mail.gmail.com> <3dbc6d1c0809161643t33fb3a80l7cb4b330333a1ef7@mail.gmail.com> <4ac8254d0809170244s4ebd31b1y4d0b361cdf3cb76f@mail.gmail.com> <48D1FC87.8030601@it.uu.se> <48E0C70D.5020700@gmail.com> <48E3AD6F.5050909@gmail.com> <48E3B568.2010702@gmail.com> Message-ID: <68918cba-a4cd-45bd-a47b-50684819ca16@m45g2000hsb.googlegroups.com> Could you please show your Makefile? On Oct 1, 1:37?pm, Serge Aleynikov wrote: > Actually I poked around with the makefile settings for gtknode and > somehow the problem went away... > > > > > > Serge Aleynikov wrote: > > I compiled the project and have been getting these errors at run-time. > > As a result the fonts are unreadable. ?Do you know how to switch font in > > the examples? > > > =INFO REPORT==== 1-Oct-2008::12:51:27 === > > ? ? ?in: {gtknode,handle_portdata,2} > > ? ? ?portdata: "\n(gtknode:17066): Pango-WARNING **: failed to find > > shape engine, expect ugly output. engine-type='PangoRenderFc', > > script='latin'\n" > > > =INFO REPORT==== 1-Oct-2008::12:51:27 === > > ? ? ?in: {gtknode,handle_portdata,2} > > ? ? ?portdata: "\n(gtknode:17066): Pango-WARNING **: failed to find > > shape engine, expect ugly output. engine-type='PangoRenderFc', > > script='common'\n" > > > =INFO REPORT==== 1-Oct-2008::12:51:27 === > > ? ? ?in: {gtknode,handle_portdata,2} > > ? ? ?portdata: "\n(gtknode:17066): Pango-WARNING **: > > _pango_cairo_font_install called with bad font, expect ugly output\n" > > > Mats Cronqvist wrote: > >> Richard Carlsson wrote: > >>> YourSurrogateGod wrote: > > >>>> Speaking of GTK bindings. Are there any so that one could make Gnome > >>>> applications (use all of the widgets and such) with Erlang? I haven't > >>>> heard of any at the moment... > > >>> The most mature (and portable) alternative is probably WxErlang: > >>>http://www.erlang.org/~dgud/wxerlang/ > >>>http://sourceforge.net/projects/wxerlang/ > > >> ? will, in all likelihood, eventually be bundled with OTP. > > >>> There are also a couple of attempts at direct GTK bindings, but > >>> don't know what their status is: > > >>>http://code.google.com/p/gtknode/ > > >> ? gtknode works fine on all versions of GTK from 2.4 to 2.12 (compiled > >> it last friday). > > >>>http://erlgtk.sourceforge.net/ > >> ? dead AFAIK. > > >> ? mats > >> _______________________________________________ > >> erlang-questions mailing list > >> erlang-questi...@REDACTED > >>http://www.erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questi...@REDACTED > >http://www.erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions From ok@REDACTED Thu Oct 2 07:23:09 2008 From: ok@REDACTED (Richard O'Keefe) Date: Thu, 2 Oct 2008 18:23:09 +1300 Subject: [erlang-questions] The Erlang Rationale In-Reply-To: <6c2563b20810010649xdb362dcyefc9e361608b33f7@mail.gmail.com> References: <3dbc6d1c0809291502m3ad2147djfdc652a8e5c7a157@mail.gmail.com> <48E1F395.5040501@gmail.com> <3dbc6d1c0809300519kd46dbadsdfb670f71865b5@mail.gmail.com> <48E21D43.1040509@gmail.com> <4ac8254d0809300609m7c72c6b2je9774a70c629acf8@mail.gmail.com> <3dbc6d1c0809300630q35221794jf0922f370de6dd04@mail.gmail.com> <6c2563b20810010649xdb362dcyefc9e361608b33f7@mail.gmail.com> Message-ID: On 2 Oct 2008, at 2:49 am, Edwin Fine wrote: > This is a dissenting vote regarding macros. > > Macros *can* make maintenance harder, You've just agreed; this is not dissent. > just like gotos *can* create spaghetti code. Neither of them are > intrinsically bad, merely easy to misuse. Maintenance of large amounts of code has to be done with tools. Macros make it harder to produce accurate tools. The only freely available program I've come across that does a decent job of cross-referencing for *both* macros *and* the underlying symbols for C is CScout. (It isn't an Open Source program, but it is available in executable form for no money.) As far as I know there is no real equivalent for Erlang. > Used with care and discipline, they both arguably have a place in > good programming practice. As a matter of fact, I still use M4 on Java code. (Remember, Java 1.5 generics do *not* accept primitive types as arguments. If you want to do that without the very heavy overhead of Java boxing and unboxing, M4 is the only game in town.) > Now I may get shot down in flames for saying this, but tail > recursion in Erlang is effectively a restricted form of goto, Perfectly true. There's even a famous paper "Lambda, the Ultimate Goto". > and it's used a lot (not by choice over some other construct, though > - the language design forces the usage). > > There are some things that macros can do that I have not found as > easy (or possible) to do some other way, for example: > > -define(LOG_DBG(Msg, ArgList), iutil_log:log_debug(?MODULE, ?LINE, > Msg, ArgList)). > > Example usage: > > ?LOG_DBG("Received ~p from ~p~n", [Msg, Socket]). This is a rather interesting one. What could replace it? -module(flog). -export([flog/2]). flog(Format, Arguments) -> {Module, Line, _} = erlang:call_site(), iutil_log:log_debug(Module, Line, Format, Arguments). Some kind of primitive that extracted a return address and consulted a line number table. That could do it. In fact it could provide more information, such as {Function,Arity}. As a debugging tool, presumably it would not need to be fast. > > iutil_log:log_debug(?MODULE, ?LINE, "Received ~p from ~p~n", [Msg, > Socket]). But what if, instead of or in addition to ?MODULE and ?LINE, the system provided you with ?HERE, expanding to {Module, Line, {Function, Arity}}. Then iutil_log:flog(?HERE, "Received ~p from ~p~n", [Msg,Socket]) doesn't seem _that_ horrible. > > > If I find that debug logging is causing too much overhead, I can > decide to conditionally compile it: > > -ifdef(DEBUG). > -define(LOG_DBG(Msg, ArgList), iutil_log:log_debug(?MODULE, ? > LINE, Msg, ArgList)). > -else. > -define(LOG_DBG(Msg, ArgList), ok). > -endif. Suppose we had top-level variables instead. So Debug = false. -inline([flog/3]). flog({Module,Line,_}, Format, Arguments) when Debug -> iutil:log_debug(Module, Line, Format, Arguments); flog(_, _, _) -> ok. Now we are down to ... flog(?HERE, "Received ~p from ~p~n", [Msg,Socket]) ... with the *same* efficiency as the macro, as easily enabled or disabled, and no preprocessor. The only thing we need that we don't have now (for we do have inlining) is ?HERE, which is no harder to provide than ?LINE. I've been experimentally rewriting some Erlang modules to see what top level variables would look like. Rather nice, in fact. Well, we don't have those now, and we'd need non-trivial compiler changes to get them. So let's do without. -inline([debug/0, flog/3]). debug() -> false. flog(Where, Format, Arguments) -> case debug() of true -> {Module,Line,_} = Where, iutil:log_debug(Module, Line, Format, Arguments) ; false -> ok end. These functions we can write today. > > A minor inconvenience of the above is that if it uses variables that > are not otherwise used, you can get compile warnings when debug > logging is disabled. This is easily fixed by using the underscore: > _Unused. And the version using an inlined function doesn't have the problem in the first place. > If I don't like having to recompile the code to enable and disable > debug logging, but want to turn it on and off at run-time (and still > have negligible overhead when debug logging is disabled), I can do > this (and the source code using this does not change in any way, but > of course must undergo a once-off recompilation): > > -define( > LOG_DBG(Msg, ArgList), > case iutil_log:ok_to_log(debug) of > true -> > iutil_log:log_debug(?MODULE, ?LINE, Msg, ArgList); > false -> > ok > end > ). Ah, the old don't-evaluate-the-arguments trick. I've run into code that only worked when you had assertions enabled, because it relied on the argument of assert() being evaluated... > > Checking if the Msg and ArgList should be evaluated before calling > saves, at the cost of an efficient function call, potentially > enormous amounts of unnecessary list creation and destruction (and > garbage collection), not to mention any evaluation of the list > elements that might be needed. True. It also means that the debugging version and the non-debugging version of your program do not do the same thing. If the expressions involve only constants, variables, control structures, and calls to known pure functions, I would hope that -inline([flog/3]). flog(Where, Format, Arguments) when Debug -> case iutil_log:ok_to_log(debug) of true -> {Module, Line, _} = Where, iutil:log_debug(Module, Line, Format, Arguments) ; false -> ok end; flog(_, _, _) -> ok. ... flog(?HERE, "......", [.....]) ... would push the evaluation of the format and arguments into the one case branch that uses them. If it doesn't, we have far worse performance issues to worry about than this one. If the expressions involve side effects and calls to possibly impure functions, then you had better make sure they are _always_ evaluated, otherwise what you log won't be what happens when you are not logging. In this context, I find BitC's distinction between pure and impure functions _in the type system_ interesting. > > > In this case I would argue that the macro makes the code *more* > maintainable and easier to read, while keeping it efficient. Agreed, > if the macro changes (and this class of macro seldom changes) I will > need to recompile the dependent code, and this is definitely not > good, but as Lord Farquhar said, "[Many of you may be killed, but] > it is a sacrifice I am willing to make." ;-) The problem is that ?LOG_DBG could do *anything*, and it isn't as easy as it should be to find the definition. (I was going to explain what etags does with macros, since etags on my box claims to support Erlang, but what cd stdlib/src; etags -o fred *.erl does is to crash in strncpy(). Since it fails to note the arity of functions, it's dubiously useful anyway.) > The curious thing is that people keep on trotting out the *same* example of why the preprocessor is useful. We *have* inlining. If only we had ?HERE, then LOG_DBG("Received ~p from ~p~n", [Msg,Socket]) would be flog(?HERE, "Received ~p from ~p~n", [Msg,Socket]) which I for one don't regard as unduly burdensome. In fact the visible presence of ?HERE as an argument tells me that the location is being passed on, which is not so obvious in LOG_DBG. Actually, if we had ?HERE, things could get even better. If the compiler handled constant terms specially (using a single static copy instead of building a new copy on the heap), passing ?HERE could be as cheap as passing 42, and we could pass around one possibly detailed location term instead of separate module/line arguments. This would be nice to do for format strings too. From erlang-questions_efine@REDACTED Thu Oct 2 08:55:02 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Thu, 2 Oct 2008 02:55:02 -0400 Subject: [erlang-questions] The Erlang Rationale In-Reply-To: References: <3dbc6d1c0809291502m3ad2147djfdc652a8e5c7a157@mail.gmail.com> <48E1F395.5040501@gmail.com> <3dbc6d1c0809300519kd46dbadsdfb670f71865b5@mail.gmail.com> <48E21D43.1040509@gmail.com> <4ac8254d0809300609m7c72c6b2je9774a70c629acf8@mail.gmail.com> <3dbc6d1c0809300630q35221794jf0922f370de6dd04@mail.gmail.com> <6c2563b20810010649xdb362dcyefc9e361608b33f7@mail.gmail.com> Message-ID: <6c2563b20810012355t5ea248a0q24deddcd415a85fe@mail.gmail.com> On Thu, Oct 2, 2008 at 1:23 AM, Richard O'Keefe wrote: > > On 2 Oct 2008, at 2:49 am, Edwin Fine wrote: > > This is a dissenting vote regarding macros. >> >> Macros *can* make maintenance harder, >> > > You've just agreed; this is not dissent. > Sorry, but I did not agree. You just read it that way. What I perhaps should have written is that you bluntly asserted that macros make maintenance harder. I am bluntly asserting that it is not necessarily so. That's dissent. Or maybe partial dissent, but there's dissent in there somewhere, I'm sure :) > > just like gotos *can* create spaghetti code. Neither of them are >> intrinsically bad, merely easy to misuse. >> > > Maintenance of large amounts of code has to be done with > tools. Macros make it harder to produce accurate tools. > The only freely available program I've come across that > does a decent job of cross-referencing for *both* macros > *and* the underlying symbols for C is CScout. (It isn't > an Open Source program, but it is available in executable > form for no money.) As far as I know there is no real > equivalent for Erlang. > I don't think this is a particularly compelling argument. I've been involved in maintenance of multi-million line systems and had much bigger fish to fry than macro-related difficulties with cross-reference tools. Maybe your experience has been different. > > > Used with care and discipline, they both arguably have a place in good >> programming practice. >> > > As a matter of fact, I still use M4 on Java code. > (Remember, Java 1.5 generics do *not* accept primitive types > as arguments. If you want to do that without the very heavy > overhead of Java boxing and unboxing, M4 is the only game in town.) > So macros are NOT that evil :) > > > Now I may get shot down in flames for saying this, but tail recursion in >> Erlang is effectively a restricted form of goto, >> > > Perfectly true. There's even a famous paper > "Lambda, the Ultimate Goto". > So the evil GOTO is not always evil, only sometimes. So it is for macros, or any dirty trick we have to pull because we never thought of the right way to do it originally and now we have to retrofit a bolt-on solution. > > > and it's used a lot (not by choice over some other construct, though - the >> language design forces the usage). >> >> There are some things that macros can do that I have not found as easy (or >> possible) to do some other way, for example: >> >> -define(LOG_DBG(Msg, ArgList), iutil_log:log_debug(?MODULE, ?LINE, Msg, >> ArgList)). >> >> Example usage: >> >> ?LOG_DBG("Received ~p from ~p~n", [Msg, Socket]). >> > > This is a rather interesting one. > What could replace it? > > -module(flog). > -export([flog/2]). > > flog(Format, Arguments) -> > {Module, Line, _} = erlang:call_site(), > iutil_log:log_debug(Module, Line, Format, Arguments). > > Some kind of primitive that extracted a return address and > consulted a line number table. That could do it. In fact it > could provide more information, such as {Function,Arity}. As > a debugging tool, presumably it would not need to be fast. > But it's not available *today*, and I need something that works *today* to give my customer. > > >> > iutil_log:log_debug(?MODULE, ?LINE, "Received ~p from ~p~n", [Msg, >> Socket]). >> > > But what if, instead of or in addition to ?MODULE and ?LINE, > the system provided you with ?HERE, expanding to > {Module, Line, {Function, Arity}}. Then > > iutil_log:flog(?HERE, "Received ~p from ~p~n", [Msg,Socket]) > > doesn't seem _that_ horrible. > Sorry to belabor the point, but what if it did? It doesn't. What if we all lived in peace and harmony and respected each other's rights? > > >> >> If I find that debug logging is causing too much overhead, I can decide to >> conditionally compile it: >> >> -ifdef(DEBUG). >> -define(LOG_DBG(Msg, ArgList), iutil_log:log_debug(?MODULE, ?LINE, Msg, >> ArgList)). >> -else. >> -define(LOG_DBG(Msg, ArgList), ok). >> -endif. >> > > Suppose we had top-level variables instead. So > But we don't. I wish we did. > > Debug = false. > > -inline([flog/3]). > > flog({Module,Line,_}, Format, Arguments) when Debug -> > iutil:log_debug(Module, Line, Format, Arguments); > flog(_, _, _) -> > ok. > > Now we are down to > > ... flog(?HERE, "Received ~p from ~p~n", [Msg,Socket]) ... > > with the *same* efficiency as the macro, as easily enabled or > disabled, and no preprocessor. The only thing we need that we > don't have now (for we do have inlining) is ?HERE, which is no > harder to provide than ?LINE. > > I've been experimentally rewriting some Erlang modules to see > what top level variables would look like. Rather nice, in fact. > Well, we don't have those now, and we'd need non-trivial compiler > changes to get them. So let's do without. Exactly my point. > > > -inline([debug/0, flog/3]). > > debug() -> false. > > flog(Where, Format, Arguments) -> > case debug() > of true -> > {Module,Line,_} = Where, > iutil:log_debug(Module, Line, Format, Arguments) > ; false -> > ok > end. > > These functions we can write today. > True - but I was working towards my ultimate point that having to recompile is a pain and wanted the ability to change run-time log levels. And, using the above code, won't you get copious compiler or Dialyzer warnings complaining that only one branch of the case will ever be reached? How would you suppress those? Or are you going to invent a suitable -pragma() for Erlang :) ? > > >> > A minor inconvenience of the above is that if it uses variables that are >> not otherwise used, you can get compile warnings when debug logging is >> disabled. This is easily fixed by using the underscore: _Unused. >> > > And the version using an inlined function doesn't have the problem > in the first place. > True. Does the inlined function stay inlined even if you compile with [debug_info]? I truly don't know - in C++ this often disables inlining. > > > If I don't like having to recompile the code to enable and disable debug >> logging, but want to turn it on and off at run-time (and still have >> negligible overhead when debug logging is disabled), I can do this (and the >> source code using this does not change in any way, but of course must >> undergo a once-off recompilation): >> >> -define( >> LOG_DBG(Msg, ArgList), >> case iutil_log:ok_to_log(debug) of >> true -> >> iutil_log:log_debug(?MODULE, ?LINE, Msg, ArgList); >> false -> >> ok >> end >> ). >> > > Ah, the old don't-evaluate-the-arguments trick. > I've run into code that only worked when you had > assertions enabled, because it relied on the > argument of assert() being evaluated... > Ah, the old I've-seen-crap-code trick. Yes, absolutely true, and anyone worth their salt will never put important code into log statements that won't get evaluated. > >> > Checking if the Msg and ArgList should be evaluated before calling saves, >> at the cost of an efficient function call, potentially enormous amounts of >> unnecessary list creation and destruction (and garbage collection), not to >> mention any evaluation of the list elements that might be needed. >> > > True. It also means that the debugging version and the non-debugging > version of your program do not do the same thing. > Only if I'm careless. Anyway, the whole point of having a debugging and non-debugging version is that they DON'T do the same thing - otherwise why have two versions? But I am splitting hairs here - I know you mean that from a functional standpoint, they won't do the same unless you take care. But that's true of anything to do with programming. > If the expressions involve only constants, variables, control > structures, and calls to known pure functions, I would hope that > And they absolutely should! > > -inline([flog/3]). > flog(Where, Format, Arguments) when Debug -> %%% Huh?? > > case iutil_log:ok_to_log(debug) > of true -> > {Module, Line, _} = Where, > iutil:log_debug(Module, Line, Format, Arguments) > ; false -> > ok > end; > flog(_, _, _) -> > ok. > > ... flog(?HERE, "......", [.....]) ... > > would push the evaluation of the format and arguments into the one > case branch that uses them. If it doesn't, we have far worse > performance issues to worry about than this one. > Where does Debug come from? Is it a (non-existent) top-level variable? > If the expressions involve side effects and calls to possibly > impure functions, then you had better make sure they are _always_ > evaluated, otherwise what you log won't be what happens when you > are not logging. Totally agreed. But that's true of any conditional code, not just that to do with logging. You have to be careful. I suppose that with a macro that you don't understand might not always execute, you run a higher risk of screwing up. Ah, if only languages would give us what we need without macros....! > > > In this context, I find BitC's distinction between pure and impure > functions _in the type system_ interesting. > That would be very useful - does that mean the compiler automatically flags functions as pure or impure based on their side-effects? > >> >> In this case I would argue that the macro makes the code *more* >> maintainable and easier to read, while keeping it efficient. Agreed, if the >> macro changes (and this class of macro seldom changes) I will need to >> recompile the dependent code, and this is definitely not good, but as Lord >> Farquhar said, "[Many of you may be killed, but] it is a sacrifice I am >> willing to make." ;-) >> > > The problem is that ?LOG_DBG could do *anything*, > and it isn't as easy as it should be to find the definition. That's also its strength (to be able to do ANYTHING and you don't have to change the code). To find the definition using find and grep isn't *that* hard, is it? I have searched the entire Erlang source code base for things of interest in under a minute with find/grep. Maybe it's slow using that 500MHz UltraSparc you are saddled with :( > (I was going to explain what etags does with macros, since > etags on my box claims to support Erlang, but what > cd stdlib/src; etags -o fred *.erl > does is to crash in strncpy(). Since it fails to note the > arity of functions, it's dubiously useful anyway.) The authors probably weren't careful with the side-effects of their debug log statements :) > > >> The curious thing is that people keep on trotting out the *same* > example of why the preprocessor is useful. We *have* inlining. We keep trotting out the *same* example because there are no *existing* solutions that do what I want without using it!! > > If only we had ?HERE, But we don't. I have to work with the real world. If ?HERE was here I would use it! > then > > LOG_DBG("Received ~p from ~p~n", [Msg,Socket]) > > would be > > flog(?HERE, "Received ~p from ~p~n", [Msg,Socket]) > > which I for one don't regard as unduly burdensome. In > fact the visible presence of ?HERE as an argument tells > me that the location is being passed on, which is not so > obvious in LOG_DBG. > Maybe so, but it gives me the flexibility to remove the location being passed later if I find it is causing a problem, say with performance. > Actually, if we had ?HERE, things could get even better. > If the compiler handled constant terms specially (using a > single static copy instead of building a new copy on the > heap), passing ?HERE could be as cheap as passing 42, and > we could pass around one possibly detailed location term > instead of separate module/line arguments. This would be > nice to do for format strings too. > Well, I for one would vote for a compiler that detected constant terms and kept them statically!! The one important thing that I perhaps didn't understand from your discussion is how you proposed to change the logging level at run time, given the *existing* features of Erlang. Understand that I gave the LOG_DBG macro as an example. As it happens, I have LOG_TRACE, LOG_INFO, LOG_WARN, and LOG_ERROR as well. I know that Erlang has trace facilities, but they are not retrospective. I need to go back in the logs and see what happened historically. I don't like the idea of sending all logging operations to a central manager process that decides to throw away the ones it doesn't want, because I don't want the sending process to be spewing out useless messages and using up CPU and GC time, and the manager process to be throwing things away. I have found historical logs to be an invaluable part of the fault-finding process, so I pepper my code liberally with all kinds of log statements - and I want to do that with the least runtime cost for the most debugging benefit. Let me tell you what I have done, and this will probably give you nightmares because it's a terrible hack, but it works well. I hacked it like this because I didn't want to (a) pass log level variables in the parameter list of every single function I ever write (b) store the log level in the process dictionary where it has to be looked up thousands of times a second (c) even worse, store it in an ETS table. In the absence of top-level variables, I faked a top-level variable as follows. I wrote a module that exports only one function, log_level(). This function is hard-coded to return (say) the atom 'info', e.g. log_level() -> info. If I want to change the logging level to debug at runtime, I simply rewrite the one line of code (plus module and export statements) in a string and recompile the code at runtime, then purge. The logging level then changes and I get debug, warning, error and info logs. (And I do understand that the historical aspect I find so important can be affected by changing the logging level, but I ensure that I log the most critical information at all times). My understanding is that a call to mod:func is very cheap, probably more so than any process dictionary or ETS lookups. So this way, for the price of a bit of skulduggery, I get tremendous flexibility at a low runtime cost. I am sure that the gurus will find some horrible flaw in this scheme, which I'd like to hear about so I can fix it, but for now it is working very well indeed. I do look forward to the implementation an EEP for top-level variables, though, then I can throw this ugliness away. -------------- next part -------------- An HTML attachment was scrubbed... URL: From mikpe@REDACTED Thu Oct 2 09:57:35 2008 From: mikpe@REDACTED (Mikael Pettersson) Date: Thu, 2 Oct 2008 09:57:35 +0200 Subject: [erlang-questions] Building 64-bit Erlang on Solaris 11 In-Reply-To: <48E3D56A.4060807@alertlogic.net> References: <11584396-2118-469C-88DA-B234E10130CA@gmail.com> <48E3D56A.4060807@alertlogic.net> Message-ID: <18660.32495.820483.196948@harpo.it.uu.se> Paul Fisher writes: > Joel Reymont wrote: > > ./configure --prefix=/opt/local --enable-64bit CFLAGS='-m64' > > ... > > gmake > > ... > > ld: fatal: file obj/i386-pc-solaris2.11/opt/plain/erl_main.o: wrong > > ELF class: ELFCLASS64 > > ld: fatal: File processing errors. No output written to /home/admin/ > > otp_src_R12B-4/bin/i386-pc-solaris2.11/beam > > > > What am I doing wrong? > > > > Thanks, Joel > > > > P.S. Omitting CFLAGS='-m64' builds a 32-bit Erlang. > > Not so straight forward (esp. if you use linked in drivers as we do). > Here is what it takes I believe the problem is that the otp build system probably overrides CFLAGS, which would cancel any user setting of CFLAGS. What I and others typically do for 64-bit builds is to set CC='gcc -m64' or to point CC to a script that always adds -m64. The real fix IMO is not to add --enable-64bit because in theory there can be other compilation mode defaults the user may want to override. Instead the build system should be made to respect the user's CFLAGS. From lestat@REDACTED Thu Oct 2 10:22:55 2008 From: lestat@REDACTED (Tamas Nagy) Date: Thu, 2 Oct 2008 09:22:55 +0100 Subject: [erlang-questions] The Erlang Rationale In-Reply-To: <6c2563b20810012355t5ea248a0q24deddcd415a85fe@mail.gmail.com> References: <3dbc6d1c0809291502m3ad2147djfdc652a8e5c7a157@mail.gmail.com> <48E1F395.5040501@gmail.com> <3dbc6d1c0809300519kd46dbadsdfb670f71865b5@mail.gmail.com> <48E21D43.1040509@gmail.com> <4ac8254d0809300609m7c72c6b2je9774a70c629acf8@mail.gmail.com> <3dbc6d1c0809300630q35221794jf0922f370de6dd04@mail.gmail.com> <6c2563b20810010649xdb362dcyefc9e361608b33f7@mail.gmail.com> <6c2563b20810012355t5ea248a0q24deddcd415a85fe@mail.gmail.com> Message-ID: <4498055F-B928-4551-8A25-4281303664D1@elte.hu> Hi! If you have problems with macro support for cross referencing take a look at RefactorErl. Although it is a refactoring tool it provides a quite extensive API to call, macro and record cross referencing. I do not see any obstacle which would make it impossible for somebody - with a bit of spare time - to create a tool on top of the data provided by the system. Best of all it supports macros which cut into the syntactical structure of the code. For example: ... -define(ADD(X,Y), + X + Y). ... foo(X, Y) -> 3 ?ADD(X,Y). ... I'm sure you can come up with uglier but more meaningful examples as well. Regards, Tamas On 2 Oct 2008, at 07:55, Edwin Fine wrote: > > > On Thu, Oct 2, 2008 at 1:23 AM, Richard O'Keefe > wrote: > > On 2 Oct 2008, at 2:49 am, Edwin Fine wrote: > > This is a dissenting vote regarding macros. > > Macros *can* make maintenance harder, > > You've just agreed; this is not dissent. > > Sorry, but I did not agree. You just read it that way. What I > perhaps should have written is that you bluntly asserted that macros > make maintenance harder. I am bluntly asserting that it is not > necessarily so. That's dissent. Or maybe partial dissent, but > there's dissent in there somewhere, I'm sure :) > > > > just like gotos *can* create spaghetti code. Neither of them are > intrinsically bad, merely easy to misuse. > > Maintenance of large amounts of code has to be done with > tools. Macros make it harder to produce accurate tools. > The only freely available program I've come across that > does a decent job of cross-referencing for *both* macros > *and* the underlying symbols for C is CScout. (It isn't > an Open Source program, but it is available in executable > form for no money.) As far as I know there is no real > equivalent for Erlang. > > I don't think this is a particularly compelling argument. I've been > involved in maintenance of multi-million line systems and had much > bigger fish to fry than macro-related difficulties with cross- > reference tools. Maybe your experience has been different. > > > > Used with care and discipline, they both arguably have a place in > good programming practice. > > As a matter of fact, I still use M4 on Java code. > (Remember, Java 1.5 generics do *not* accept primitive types > as arguments. If you want to do that without the very heavy > overhead of Java boxing and unboxing, M4 is the only game in town.) > > So macros are NOT that evil :) > > > > Now I may get shot down in flames for saying this, but tail > recursion in Erlang is effectively a restricted form of goto, > > Perfectly true. There's even a famous paper > "Lambda, the Ultimate Goto". > > So the evil GOTO is not always evil, only sometimes. So it is for > macros, or any dirty trick we have to pull because we never thought > of the right way to do it originally and now we have to retrofit a > bolt-on solution. > > > > and it's used a lot (not by choice over some other construct, though > - the language design forces the usage). > > There are some things that macros can do that I have not found as > easy (or possible) to do some other way, for example: > > -define(LOG_DBG(Msg, ArgList), iutil_log:log_debug(?MODULE, ?LINE, > Msg, ArgList)). > > Example usage: > > ?LOG_DBG("Received ~p from ~p~n", [Msg, Socket]). > > This is a rather interesting one. > What could replace it? > > -module(flog). > -export([flog/2]). > > flog(Format, Arguments) -> > {Module, Line, _} = erlang:call_site(), > iutil_log:log_debug(Module, Line, Format, Arguments). > > Some kind of primitive that extracted a return address and > consulted a line number table. That could do it. In fact it > could provide more information, such as {Function,Arity}. As > a debugging tool, presumably it would not need to be fast. > > But it's not available *today*, and I need something that works > *today* to give my customer. > > > > > iutil_log:log_debug(?MODULE, ?LINE, "Received ~p from ~p~n", [Msg, > Socket]). > > But what if, instead of or in addition to ?MODULE and ?LINE, > the system provided you with ?HERE, expanding to > {Module, Line, {Function, Arity}}. Then > > iutil_log:flog(?HERE, "Received ~p from ~p~n", [Msg,Socket]) > > doesn't seem _that_ horrible. > > Sorry to belabor the point, but what if it did? It doesn't. What if > we all lived in peace and harmony and respected each other's rights? > > > > > If I find that debug logging is causing too much overhead, I can > decide to conditionally compile it: > > -ifdef(DEBUG). > -define(LOG_DBG(Msg, ArgList), iutil_log:log_debug(?MODULE, ? > LINE, Msg, ArgList)). > -else. > -define(LOG_DBG(Msg, ArgList), ok). > -endif. > > Suppose we had top-level variables instead. So > > But we don't. I wish we did. > > > Debug = false. > > -inline([flog/3]). > > flog({Module,Line,_}, Format, Arguments) when Debug -> > iutil:log_debug(Module, Line, Format, Arguments); > flog(_, _, _) -> > ok. > > Now we are down to > > ... flog(?HERE, "Received ~p from ~p~n", [Msg,Socket]) ... > > with the *same* efficiency as the macro, as easily enabled or > disabled, and no preprocessor. The only thing we need that we > don't have now (for we do have inlining) is ?HERE, which is no > harder to provide than ?LINE. > > I've been experimentally rewriting some Erlang modules to see > what top level variables would look like. Rather nice, in fact. > Well, we don't have those now, and we'd need non-trivial compiler > changes to get them. So let's do without. > > Exactly my point. > > > > -inline([debug/0, flog/3]). > > debug() -> false. > > flog(Where, Format, Arguments) -> > case debug() > of true -> > {Module,Line,_} = Where, > iutil:log_debug(Module, Line, Format, Arguments) > ; false -> > ok > end. > > These functions we can write today. > > True - but I was working towards my ultimate point that having to > recompile is a pain and wanted the ability to change run-time log > levels. And, using the above code, won't you get copious compiler or > Dialyzer warnings complaining that only one branch of the case will > ever be reached? How would you suppress those? Or are you going to > invent a suitable -pragma() for Erlang :) ? > > > > > > A minor inconvenience of the above is that if it uses variables that > are not otherwise used, you can get compile warnings when debug > logging is disabled. This is easily fixed by using the underscore: > _Unused. > > And the version using an inlined function doesn't have the problem > in the first place. > > True. Does the inlined function stay inlined even if you compile > with [debug_info]? I truly don't know - in C++ this often disables > inlining. > > > > If I don't like having to recompile the code to enable and disable > debug logging, but want to turn it on and off at run-time (and still > have negligible overhead when debug logging is disabled), I can do > this (and the source code using this does not change in any way, but > of course must undergo a once-off recompilation): > > -define( > LOG_DBG(Msg, ArgList), > case iutil_log:ok_to_log(debug) of > true -> > iutil_log:log_debug(?MODULE, ?LINE, Msg, ArgList); > false -> > ok > end > ). > > Ah, the old don't-evaluate-the-arguments trick. > I've run into code that only worked when you had > assertions enabled, because it relied on the > argument of assert() being evaluated... > > Ah, the old I've-seen-crap-code trick. Yes, absolutely true, and > anyone worth their salt will never put important code into log > statements that won't get evaluated. > > > > > Checking if the Msg and ArgList should be evaluated before calling > saves, at the cost of an efficient function call, potentially > enormous amounts of unnecessary list creation and destruction (and > garbage collection), not to mention any evaluation of the list > elements that might be needed. > > True. It also means that the debugging version and the non-debugging > version of your program do not do the same thing. > > Only if I'm careless. Anyway, the whole point of having a debugging > and non-debugging version is that they DON'T do the same thing - > otherwise why have two versions? But I am splitting hairs here - I > know you mean that from a functional standpoint, they won't do the > same unless you take care. But that's true of anything to do with > programming. > > > If the expressions involve only constants, variables, control > structures, and calls to known pure functions, I would hope that > > And they absolutely should! > > > -inline([flog/3]). > flog(Where, Format, Arguments) when Debug -> %%% Huh?? > > case iutil_log:ok_to_log(debug) > of true -> > {Module, Line, _} = Where, > iutil:log_debug(Module, Line, Format, Arguments) > ; false -> > ok > end; > flog(_, _, _) -> > ok. > > ... flog(?HERE, "......", [.....]) ... > > would push the evaluation of the format and arguments into the one > case branch that uses them. If it doesn't, we have far worse > performance issues to worry about than this one. > > Where does Debug come from? Is it a (non-existent) top-level variable? > > > If the expressions involve side effects and calls to possibly > impure functions, then you had better make sure they are _always_ > evaluated, otherwise what you log won't be what happens when you > are not logging. > > Totally agreed. But that's true of any conditional code, not just > that to do with logging. You have to be careful. I suppose that with > a macro that you don't understand might not always execute, you run > a higher risk of screwing up. Ah, if only languages would give us > what we need without macros....! > > > > In this context, I find BitC's distinction between pure and impure > functions _in the type system_ interesting. > > That would be very useful - does that mean the compiler > automatically flags functions as pure or impure based on their side- > effects? > > > > > In this case I would argue that the macro makes the code *more* > maintainable and easier to read, while keeping it efficient. Agreed, > if the macro changes (and this class of macro seldom changes) I will > need to recompile the dependent code, and this is definitely not > good, but as Lord Farquhar said, "[Many of you may be killed, but] > it is a sacrifice I am willing to make." ;-) > > The problem is that ?LOG_DBG could do *anything*, > and it isn't as easy as it should be to find the definition. > > That's also its strength (to be able to do ANYTHING and you don't > have to change the code). To find the definition using find and grep > isn't *that* hard, is it? I have searched the entire Erlang source > code base for things of interest in under a minute with find/grep. > Maybe it's slow using that 500MHz UltraSparc you are saddled with :( > > > (I was going to explain what etags does with macros, since > etags on my box claims to support Erlang, but what > cd stdlib/src; etags -o fred *.erl > does is to crash in strncpy(). Since it fails to note the > arity of functions, it's dubiously useful anyway.) > > The authors probably weren't careful with the side-effects of their > debug log statements :) > > > > > The curious thing is that people keep on trotting out the *same* > example of why the preprocessor is useful. We *have* inlining. > > We keep trotting out the *same* example because there are no > *existing* solutions that do what I want without using it!! > > > If only we had ?HERE, > > But we don't. I have to work with the real world. If ?HERE was here > I would use it! > > then > > > LOG_DBG("Received ~p from ~p~n", [Msg,Socket]) > > would be > > flog(?HERE, "Received ~p from ~p~n", [Msg,Socket]) > > which I for one don't regard as unduly burdensome. In > fact the visible presence of ?HERE as an argument tells > me that the location is being passed on, which is not so > obvious in LOG_DBG. > > Maybe so, but it gives me the flexibility to remove the location > being passed later if I find it is causing a problem, say with > performance. > > > Actually, if we had ?HERE, things could get even better. > If the compiler handled constant terms specially (using a > single static copy instead of building a new copy on the > heap), passing ?HERE could be as cheap as passing 42, and > we could pass around one possibly detailed location term > instead of separate module/line arguments. This would be > nice to do for format strings too. > > Well, I for one would vote for a compiler that detected constant > terms and kept them statically!! > > The one important thing that I perhaps didn't understand from your > discussion is how you proposed to change the logging level at run > time, given the *existing* features of Erlang. > > Understand that I gave the LOG_DBG macro as an example. As it > happens, I have LOG_TRACE, LOG_INFO, LOG_WARN, and LOG_ERROR as > well. I know that Erlang has trace facilities, but they are not > retrospective. I need to go back in the logs and see what happened > historically. I don't like the idea of sending all logging > operations to a central manager process that decides to throw away > the ones it doesn't want, because I don't want the sending process > to be spewing out useless messages and using up CPU and GC time, and > the manager process to be throwing things away. I have found > historical logs to be an invaluable part of the fault-finding > process, so I pepper my code liberally with all kinds of log > statements - and I want to do that with the least runtime cost for > the most debugging benefit. > > Let me tell you what I have done, and this will probably give you > nightmares because it's a terrible hack, but it works well. I hacked > it like this because I didn't want to (a) pass log level variables > in the parameter list of every single function I ever write (b) > store the log level in the process dictionary where it has to be > looked up thousands of times a second (c) even worse, store it in an > ETS table. In the absence of top-level variables, I faked a top- > level variable as follows. > > I wrote a module that exports only one function, log_level(). This > function is hard-coded to return (say) the atom 'info', e.g. > > log_level() -> info. > > If I want to change the logging level to debug at runtime, I simply > rewrite the one line of code (plus module and export statements) in > a string and recompile the code at runtime, then purge. The logging > level then changes and I get debug, warning, error and info logs. > (And I do understand that the historical aspect I find so important > can be affected by changing the logging level, but I ensure that I > log the most critical information at all times). My understanding is > that a call to mod:func is very cheap, probably more so than any > process dictionary or ETS lookups. So this way, for the price of a > bit of skulduggery, I get tremendous flexibility at a low runtime > cost. I am sure that the gurus will find some horrible flaw in this > scheme, which I'd like to hear about so I can fix it, but for now it > is working very well indeed. > > I do look forward to the implementation an EEP for top-level > variables, though, then I can throw this ugliness away. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From joelr1@REDACTED Thu Oct 2 11:03:40 2008 From: joelr1@REDACTED (Joel Reymont) Date: Thu, 2 Oct 2008 10:03:40 +0100 Subject: [erlang-questions] Building 64-bit Erlang on Solaris 11 In-Reply-To: <18660.32495.820483.196948@harpo.it.uu.se> References: <11584396-2118-469C-88DA-B234E10130CA@gmail.com> <48E3D56A.4060807@alertlogic.net> <18660.32495.820483.196948@harpo.it.uu.se> Message-ID: <80083D46-CA96-4A7F-BE04-CCDCA092D328@gmail.com> On Oct 2, 2008, at 8:57 AM, Mikael Pettersson wrote: > I believe the problem is that the otp build system probably > overrides CFLAGS, which would cancel any user setting of CFLAGS. > What I and others typically do for 64-bit builds is to set > CC='gcc -m64' or to point CC to a script that always adds -m64. That doesn't work too well... checking for a compiler that handles jumptables... /home/admin/ otp_src_R12B-4/erts/configure: line 20569: test: too many arguments /home/admin/otp_src_R12B-4/erts/configure: line 20587: test: too many arguments gcc -m64 /home/admin/otp_src_R12B-4/erts/configure: line 20660: test: too many arguments checking for static ZLib to be used by SSL in standard locations... no -- wagerlabs.com From mikpe@REDACTED Thu Oct 2 12:16:56 2008 From: mikpe@REDACTED (Mikael Pettersson) Date: Thu, 2 Oct 2008 12:16:56 +0200 Subject: [erlang-questions] Building 64-bit Erlang on Solaris 11 In-Reply-To: <80083D46-CA96-4A7F-BE04-CCDCA092D328@gmail.com> References: <11584396-2118-469C-88DA-B234E10130CA@gmail.com> <48E3D56A.4060807@alertlogic.net> <18660.32495.820483.196948@harpo.it.uu.se> <80083D46-CA96-4A7F-BE04-CCDCA092D328@gmail.com> Message-ID: <18660.40856.836062.671229@harpo.it.uu.se> Joel Reymont writes: > > On Oct 2, 2008, at 8:57 AM, Mikael Pettersson wrote: > > > I believe the problem is that the otp build system probably > > overrides CFLAGS, which would cancel any user setting of CFLAGS. > > What I and others typically do for 64-bit builds is to set > > CC='gcc -m64' or to point CC to a script that always adds -m64. > > > That doesn't work too well... > > checking for a compiler that handles jumptables... /home/admin/ > otp_src_R12B-4/erts/configure: line 20569: test: too many arguments > /home/admin/otp_src_R12B-4/erts/configure: line 20587: test: too many > arguments > gcc -m64 > /home/admin/otp_src_R12B-4/erts/configure: line 20660: test: too many > arguments > checking for static ZLib to be used by SSL in standard locations... no Maybe I misremembered the CC='gcc -m64' ./configure approach, it does work in other projects. The auxiliary script approach is known to work in Erlang however: cat > /tmp/gcc64 #!/bin/sh exec gcc -m64 "$@" ^D chmod +x /tmp/gcc64 CC=/tmp/gcc64 ./configure make From bgustavsson@REDACTED Thu Oct 2 12:31:03 2008 From: bgustavsson@REDACTED (Bjorn Gustavsson) Date: Thu, 2 Oct 2008 12:31:03 +0200 Subject: [erlang-questions] The Erlang Rationale In-Reply-To: References: <3dbc6d1c0809291502m3ad2147djfdc652a8e5c7a157@mail.gmail.com> <48E1F395.5040501@gmail.com> <3dbc6d1c0809300519kd46dbadsdfb670f71865b5@mail.gmail.com> <48E21D43.1040509@gmail.com> <4ac8254d0809300609m7c72c6b2je9774a70c629acf8@mail.gmail.com> <3dbc6d1c0809300630q35221794jf0922f370de6dd04@mail.gmail.com> <6c2563b20810010649xdb362dcyefc9e361608b33f7@mail.gmail.com> Message-ID: <6672d0160810020331h1fa3f6b5x95da792849b554fe@mail.gmail.com> On Thu, Oct 2, 2008 at 7:23 AM, Richard O'Keefe wrote: > > Actually, if we had ?HERE, things could get even better. > If the compiler handled constant terms specially (using a > single static copy instead of building a new copy on the > heap), passing ?HERE could be as cheap as passing 42, and > we could pass around one possibly detailed location term > instead of separate module/line arguments. This would be > nice to do for format strings too. > > The compiler (and run-time system) in R12B actually already does that. That was one of the highlights of the R12B release. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB -------------- next part -------------- An HTML attachment was scrubbed... URL: From vychodil.hynek@REDACTED Thu Oct 2 13:05:48 2008 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Thu, 2 Oct 2008 13:05:48 +0200 Subject: [erlang-questions] Erlang doesn't suck In-Reply-To: <48E3E4FF.3020403@cs.ntua.gr> References: <48E3A1E6.4090307@alertlogic.net> <9D9606A2-0064-471E-B214-9E82DC850982@gmail.com> <48E3A86A.8010508@alertlogic.net> <28B99EDD-C840-4E3F-B59C-77A89F371B12@gmail.com> <48E3E4FF.3020403@cs.ntua.gr> Message-ID: <20081002110548.66AFB24064@relay.gooddata.com> I would like notice that hipe can cause performance lost for some special cases. There is not simple equation, switch on hipe and you gain some amount of performance surplus. Especially when you have tight loop over not so much complex data structures you can gain big amount of performance. When you do big amount of inter module calls you gain less and when you do big amount of message passings you can lost some performance when switch it on. On Wed, Oct 1, 2008 at 11:00 PM, Kostis Sagonas wrote: > Joel Reymont wrote: > > On Oct 1, 2008, at 5:42 PM, Paul Fisher wrote: > > > > There's certainly an increase in throughput (request per second) with > > hipe, even under 32 bits. > > > > Is there a way to mass-hipe-compile all of OTP? > > Not an easy one that I know of. We have discussed many times with the > OTP folks the possibility to add such a configure option, but so far it > has not happened. Yet another item for the upcoming meeting with them. > > Perhaps this option will be available in R12B-5. > > Kostis > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- --Hynek (Pichi) Vychodil -------------- next part -------------- An HTML attachment was scrubbed... URL: From saleyn@REDACTED Thu Oct 2 13:32:24 2008 From: saleyn@REDACTED (Serge Aleynikov) Date: Thu, 02 Oct 2008 07:32:24 -0400 Subject: [erlang-questions] GTK bindings In-Reply-To: <68918cba-a4cd-45bd-a47b-50684819ca16@m45g2000hsb.googlegroups.com> References: <48CF2F1B.3070003@lionet.info> <2ae3549f-f1cb-4e3c-b7e3-d805c6de372a@m36g2000hse.googlegroups.com> <48CFF05B.90401@lionet.info> <15b6a55b-956f-45c8-b412-76751fe630ab@e53g2000hsa.googlegroups.com> <087d239c-07b5-47ef-9372-ae097ca12bcd@m45g2000hsb.googlegroups.com> <3dbc6d1c0809161457v2ed4f29bxe16bcc124dbf06f5@mail.gmail.com> <14f0e3620809161547x32377a37ke4c9abee0a8c41e1@mail.gmail.com> <3dbc6d1c0809161643t33fb3a80l7cb4b330333a1ef7@mail.gmail.com> <4ac8254d0809170244s4ebd31b1y4d0b361cdf3cb76f@mail.gmail.com> <48D1FC87.8030601@it.uu.se> <48E0C70D.5020700@gmail.com> <48E3AD6F.5050909@gmail.com> <48E3B568.2010702@gmail.com> <68918cba-a4cd-45bd-a47b-50684819ca16@m45g2000hsb.googlegroups.com> Message-ID: <48E4B148.4060901@gmail.com> Actually it turned out that the server I was running it on had several versions of pango, cairo, gtk+, x11, xml and other dependencies, so I had to play with settings to enforce selection of alternative libraries until I got it to work. YourSurrogateGod wrote: > Could you please show your Makefile? > > On Oct 1, 1:37 pm, Serge Aleynikov wrote: >> Actually I poked around with the makefile settings for gtknode and >> somehow the problem went away... >> >> >> >> >> From devdoer2@REDACTED Thu Oct 2 13:32:58 2008 From: devdoer2@REDACTED (devdoer bird) Date: Thu, 2 Oct 2008 19:32:58 +0800 Subject: [erlang-questions] cean:install can't install iconv Message-ID: HI: I run cean:install(iconv) and got the msg "error: iconv not found in download". Is cean available for R12B now? -------------- next part -------------- An HTML attachment was scrubbed... URL: From psa@REDACTED Thu Oct 2 13:52:05 2008 From: psa@REDACTED (=?ISO-8859-1?Q?Paulo_S=E9rgio_Almeida?=) Date: Thu, 02 Oct 2008 12:52:05 +0100 Subject: [erlang-questions] Documentation: type of filename parameter in ets:tab2file/2 In-Reply-To: <20081002110548.66AFB24064@relay.gooddata.com> References: <48E3A1E6.409030 7@alertlogic.net><9D9606A2-0064-471E-B214-9E82DC850982@gmail.com><48E3A86A. 8010508@alertlogic.net><28B99EDD-C840-4E3F-B59C-77A89F371B12@gmail.com><48E 3E4FF.3020403@cs.ntua.gr> <20081002110548.66AFB24064@relay.gooddata.com> Message-ID: <48E4B5E5.1040204@di.uminho.pt> Hi all, I noticed that the documentation of ets:tab2file/2 says: tab2file(Tab, Filename) -> ok | {error,Reason} Filename = string() | atom() Shouldn't it be a name() instead as in the file module: name() = string() | atom() | DeepList DeepList = [char() | atom() | DeepList] I tried using a deeplist and it works (as it should if it uses the file module). Regards, Paulo From eliliang@REDACTED Thu Oct 2 13:48:32 2008 From: eliliang@REDACTED (Eli Liang) Date: Thu, 2 Oct 2008 04:48:32 -0700 (PDT) Subject: [erlang-questions] Is it possible to build an 64-bit Erlang for Windows? Message-ID: <433485.46774.qm@web30402.mail.mud.yahoo.com> I've looked through the README.win32 file in the source, and it is leading me to believe that it would be difficult to build an x64 flavor of the binaries for Windows Vista x64. Has anyone tried this? -------------- next part -------------- An HTML attachment was scrubbed... URL: From mikpe@REDACTED Thu Oct 2 15:27:47 2008 From: mikpe@REDACTED (Mikael Pettersson) Date: Thu, 2 Oct 2008 15:27:47 +0200 Subject: [erlang-questions] Building 64-bit Erlang on Solaris 11 In-Reply-To: <6E6D4A6C-542D-46BC-85B9-5F52E4C37D3A@alertlogic.com> References: <11584396-2118-469C-88DA-B234E10130CA@gmail.com> <48E3D56A.4060807@alertlogic.net> <18660.32495.820483.196948@harpo.it.uu.se> <80083D46-CA96-4A7F-BE04-CCDCA092D328@gmail.com> <18660.40856.836062.671229@harpo.it.uu.se> <6E6D4A6C-542D-46BC-85B9-5F52E4C37D3A@alertlogic.com> Message-ID: <18660.52307.581140.533@harpo.it.uu.se> Paul Fisher writes: > The problem that I ran into was the fact that LD needs to be > overridden similarly. In addition, DED_xxxx would still still end up > wrong. Finally there a few things that still needed to be fixed up by > hand. > > I did the "enable-64bit" patch because the build already handled Mac > OSX that way. I just cleaned it and generalized the existing approach. > > Can whomever maintains the build cruft on the OTP team comment on > directio? Post a bug report to erlang-bugs, that's what it's there for. From kostis@REDACTED Thu Oct 2 16:21:39 2008 From: kostis@REDACTED (Kostis Sagonas) Date: Thu, 02 Oct 2008 17:21:39 +0300 Subject: [erlang-questions] Documentation: type of filename parameter in ets:tab2file/2 In-Reply-To: <48E4B5E5.1040204@di.uminho.pt> References: <48E3A1E6.409030 7@alertlogic.net><9D9606A2-0064-471E-B214-9E82DC850982@gmail.com><48E3A86A. 8010508@alertlogic.net><28B99EDD-C840-4E3F-B59C-77A89F371B12@gmail.com><48E 3E4FF.3020403@cs.ntua.gr> <20081002110548.66AFB24064@relay.gooddata.com> <48E4B5E5.1040204@di.uminho.pt> Message-ID: <48E4D8F3.1080300@cs.ntua.gr> Paulo S?rgio Almeida wrote: > > I noticed that the documentation of ets:tab2file/2 says: > > tab2file(Tab, Filename) -> ok | {error,Reason} > Filename = string() | atom() > > Shouldn't it be a name() instead as in the file module: > > name() = string() | atom() | DeepList > DeepList = [char() | atom() | DeepList] > > I tried using a deeplist and it works. In my opinion one should be careful not to repeat historical accidents that arguably are signs of bad programming language design. While I could possibly see some convenience arguments why one would want to allow a file name as something constructed out of a list of atoms and strings, so that one can e.g. write: -define(Application, myapp). %% Aren't macros great? -define(Suffix, ".erl"). then later Filename = [?Application, "_", myfile, ?Suffix], and finally use it in a call to: file:open(Filename, [read]) without having to go into the trouble to put a call to lists:concat/1 in between, I see very little reason to allow all possible combinations that the definition of DeepList above permits so that the following is also a valid file name: Filename = [this,['_',"is","_",a,"l",so,['_',["a",[], ['V',[a],[[l]]],id],'F',[i,l,e],"n",a,["me"]]]] In an ideal Erlang world, file names are just strings. Kostis From Rainer.Hansen@REDACTED Thu Oct 2 16:23:13 2008 From: Rainer.Hansen@REDACTED (Rainer Hansen) Date: Thu, 02 Oct 2008 16:23:13 +0200 Subject: [erlang-questions] Aachen-Euskirchen-Bonn Erlounge on Tuesday Message-ID: <20081002142313.126430@gmx.net> Welcome to the second Aachen-Euskirchen-Bonn Erlounge taking place in the Parkhotel in Euskirchen. We meet at 19:00 o'clock on October 7th, 2008. All Erlang developers and users are welcome to meet each other and talk about what you are doing. Homepage of Parkhotel Euskirchen: http://www.parkhotel-euskirchen.com/ You can get driving instructions by just typing Parkhotel Euskirchen into the Google search bar. The Parkhotel is very good to reach by public transport because it is opposite to the bus and train station in Euskirchen. Don't hesitate to contact me if you've got any questions or comments. Rainer Hansen -- Psssst! Schon vom neuen GMX MultiMessenger geh?rt? Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger From michal@REDACTED Thu Oct 2 16:33:49 2008 From: michal@REDACTED (Michal Slaski) Date: Thu, 2 Oct 2008 16:33:49 +0200 Subject: [erlang-questions] =?iso-8859-1?q?ErlLounge_in_Krak=F3w=2C_Poland?= Message-ID: <047C0945-143B-4E8D-B9EB-A2AEE4A239F9@erlang-consulting.com> Hi, Tomorrow evening we are meeting for ErlLounge at 18.30 at Gwarek club which is close to the AGH University campus. Francesco Cesarini will be presenting about the history of Erlang. After the presentation there will be plenty of time to meet others who are interested in Erlang or are working with it every day. You can find more details here: http://www.erlang-consulting.com/erlang/events.html#68 Cheers, Michal -- Michal Slaski http://www.erlang-consulting.com From mbj@REDACTED Thu Oct 2 16:38:11 2008 From: mbj@REDACTED (Martin Bjorklund) Date: Thu, 02 Oct 2008 16:38:11 +0200 (CEST) Subject: [erlang-questions] Question about gen_event In-Reply-To: <48E3A2A6.4060007@cs.ntua.gr> References: <48E3A2A6.4060007@cs.ntua.gr> Message-ID: <20081002.163811.162288526.mbj@tail-f.com> Hi, Kostis Sagonas wrote: > I've been staring at the code of 'gen_event' and I cannot make much > sense of how the code for swapping handlers works. In fact, I am quite > convinced there is a bug in there but it is being silenced by the use of > a catch. Can somebody please confirm that this is a bug or enlighten me > on what's happening? > > The code of gen_event:do_swap/7 reads: > > do_swap(Mod1,Handler1,Args1,State1,Handler2,Args2,SName) -> > %% finalise the existing handler > State2 = do_terminate(...), > {Mod2,Handler} = new_handler(Handler2, Handler1), %% <--- This is correct; the module is extracted from Handler2, and the #handler{} is updated. > case catch Mod2:init({Args2, State2}) of > {ok, State2a} -> > {ok, Handler#handler{state = State2a}}; > Other -> > report_terminate(Handler2, crash, ...), %% <--- But this is wrong; Handler2 should be Handler here. Handler2 is either a module name (atom()) or a tuple {ModuleName, Id} ({atom(), term()}). But report_terminate wants a #handler{}. The variable names are pretty confusing... I suspect that once upon a time, Handler was just a modulename or the 2-tuple, and it has evolved into a record... /martin From jim.mccoy@REDACTED Thu Oct 2 19:28:29 2008 From: jim.mccoy@REDACTED (Jim McCoy) Date: Thu, 2 Oct 2008 10:28:29 -0700 Subject: [erlang-questions] Request to add md4 to crypto module Message-ID: After poking around a bit in the OTP sources it seems that it would be pretty trivial to add md4 to the crypto module. I will be testing a few patches later this week, but before I throw together a real EEP I was hoping that this might be a simple-enough change that the OTP team might consider adding it without the need for the formal process. As for the rationale: some applications (dhts, etc) need a large, fast hash that has a good uniqueness distribution but are not worried about the security implications of selecting an algorithm that is cryptographically weak. The md4 hash is about 50% faster than md5, which is a real win when you are hashing thousands of items. Since there are already "questionable" algorithms included in the crypto module (e.g. md5 and rc2) it seems that a warning in the docs that this algorithm should not be used for security-sensitive tasks would be sufficient notice to developers. Any thoughts or objections? jim From kostis@REDACTED Thu Oct 2 19:51:43 2008 From: kostis@REDACTED (Kostis Sagonas) Date: Thu, 02 Oct 2008 20:51:43 +0300 Subject: [erlang-questions] Erlang doesn't suck In-Reply-To: <20081002110518.8EC0A24064@relay.gooddata.com> References: <48E3A1E6.4090307@alertlogic.net> <9D9606A2-0064-471E-B214-9E82DC850982@gmail.com> <48E3A86A.8010508@alertlogic.net> <28B99EDD-C840-4E3F-B59C-77A89F371B12@gmail.com> <48E3E4FF.3020403@cs.ntua.gr> <20081002110518.8EC0A24064@relay.gooddata.com> Message-ID: <48E50A2F.2000102@cs.ntua.gr> Hynek Vychodil wrote: > I would like notice that hipe can cause performance lost for some > special cases. There is not simple equation, switch on hipe and you gain > some amount of performance surplus. Especially when you have tight loop > over not so much complex data structures you can gain big amount of > performance. It would have been much more helpful for the discussion if you presented some quantitative results (and preferably code) for your claims. For example, what qualifies as "not so much complex data structures" (by the way, have you measured what happens in "complex" ones?), "big amount", "performance loss for some special cases" (what's "special" about these special cases), etc. > When you do big amount of inter module calls you gain less This is slightly misleading: there is no "bad" treatment of inter module calls (other than that dictated by the semantics of hot code loading). What does have a non-negligible cost is so called mode-switching calls: calling interpreted code from native or vice versa. The simplest way to avoid this is to native compile everything. Alas, currently this is not so easy to do for standard libraries. But note that even without compiling everything, the speed up from native code is not something to disregard so quickly. For example, if I read Joel's mails correctly he got: 3000 games finished Elapsed: 181.960007s, Average run time: 0.060653335 seconds (for BEAM) Elapsed: 62.517129s, Average run time: 0.020839043 seconds (for HiPE) without compiling any of the OTP libraries. Joel can correct me if I am wrong here. > and when you do big amount of message passings you can lost some > preformance when switch it on. It would help more if, instead of rather unquantified statements, you or somebody else posted an actual application (*) showing a non-trivial performance loss when native compiled. It would at least give us something to work and improve upon. Kostis (*) not just a synthetic benchmark From joelr1@REDACTED Thu Oct 2 20:22:22 2008 From: joelr1@REDACTED (Joel Reymont) Date: Thu, 2 Oct 2008 19:22:22 +0100 Subject: [erlang-questions] Erlang doesn't suck In-Reply-To: <48E50A2F.2000102@cs.ntua.gr> References: <48E3A1E6.4090307@alertlogic.net> <9D9606A2-0064-471E-B214-9E82DC850982@gmail.com> <48E3A86A.8010508@alertlogic.net> <28B99EDD-C840-4E3F-B59C-77A89F371B12@gmail.com> <48E3E4FF.3020403@cs.ntua.gr> <20081002110518.8EC0A24064@relay.gooddata.com> <48E50A2F.2000102@cs.ntua.gr> Message-ID: <0A69EEEF-0673-4373-8E9A-B8077242302A@gmail.com> Kostis, On Oct 2, 2008, at 6:51 PM, Kostis Sagonas wrote: > For example, if I read Joel's mails correctly he got: > > 3000 games finished > Elapsed: 181.960007s, Average run time: 0.060653335 seconds (for BEAM) > Elapsed: 62.517129s, Average run time: 0.020839043 seconds (for HiPE) The difference between HiPE and BEAM was not pronounced at all, 10-15% if I remember correctly. The difference above is between Solaris/ Nevada and my Mac Pro. Thanks, Joel -- wagerlabs.com From kostis@REDACTED Thu Oct 2 20:27:49 2008 From: kostis@REDACTED (Kostis Sagonas) Date: Thu, 02 Oct 2008 21:27:49 +0300 Subject: [erlang-questions] Erlang doesn't suck In-Reply-To: <48E50C41.6030305@alertlogic.net> References: <48E3A1E6.4090307@alertlogic.net> <9D9606A2-0064-471E-B214-9E82DC850982@gmail.com> <48E3A86A.8010508@alertlogic.net> <28B99EDD-C840-4E3F-B59C-77A89F371B12@gmail.com> <48E3E4FF.3020403@cs.ntua.gr> <20081002110518.8EC0A24064@relay.gooddata.com> <48E50A2F.2000102@cs.ntua.gr> <48E50C41.6030305@alertlogic.net> Message-ID: <48E512A5.6030601@cs.ntua.gr> Paul Fisher wrote: > Kostis Sagonas wrote: >>> When you do big amount of inter module calls you gain less >> >> This is slightly misleading: there is no "bad" treatment of inter module >> calls (other than that dictated by the semantics of hot code loading). >> What does have a non-negligible cost is so called mode-switching calls: >> calling interpreted code from native or vice versa. The simplest way to >> avoid this is to native compile everything. Alas, currently this is not >> so easy to do for standard libraries. > > Wow, this is a wonderful nugget of information. I had not considered > that the transition is the real performance killer... > > Just to clarify, I should expect performance from fastest to slowest to be: > > 1) inter-module HiPE -> HiPE > 2) inter-module BEAM -> BEAM > 3) inter-module HiPE -> BEAM or inter-module BEAM -> HiPE > > right? right Kostis From yoursurrogategod@REDACTED Thu Oct 2 22:34:07 2008 From: yoursurrogategod@REDACTED (YourSurrogateGod) Date: Thu, 2 Oct 2008 13:34:07 -0700 (PDT) Subject: [erlang-questions] GTK bindings In-Reply-To: <48E4B148.4060901@gmail.com> References: <2ae3549f-f1cb-4e3c-b7e3-d805c6de372a@m36g2000hse.googlegroups.com> <48CFF05B.90401@lionet.info> <15b6a55b-956f-45c8-b412-76751fe630ab@e53g2000hsa.googlegroups.com> <087d239c-07b5-47ef-9372-ae097ca12bcd@m45g2000hsb.googlegroups.com> <3dbc6d1c0809161457v2ed4f29bxe16bcc124dbf06f5@mail.gmail.com> <14f0e3620809161547x32377a37ke4c9abee0a8c41e1@mail.gmail.com> <3dbc6d1c0809161643t33fb3a80l7cb4b330333a1ef7@mail.gmail.com> <4ac8254d0809170244s4ebd31b1y4d0b361cdf3cb76f@mail.gmail.com> <48D1FC87.8030601@it.uu.se> <48E0C70D.5020700@gmail.com> <48E3AD6F.5050909@gmail.com> <48E3B568.2010702@gmail.com> <68918cba-a4cd-45bd-a47b-50684819ca16@m45g2000hsb.googlegroups.com> <48E4B148.4060901@gmail.com> Message-ID: Oh, that's fine. I'm just curious how everything looks internally in that file and what commands are used. On Oct 2, 7:32?am, Serge Aleynikov wrote: > Actually it turned out that the server I was running it on had several > versions of pango, cairo, gtk+, x11, xml and other dependencies, so I > had to play with settings to enforce selection of alternative libraries > until I got it to work. > > YourSurrogateGod wrote: > > Could you please show your Makefile? > > > On Oct 1, 1:37 pm, Serge Aleynikov wrote: > >> Actually I poked around with the makefile settings for gtknode and > >> somehow the problem went away... > > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions From vychodil.hynek@REDACTED Thu Oct 2 22:51:10 2008 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Thu, 2 Oct 2008 22:51:10 +0200 Subject: [erlang-questions] Erlang doesn't suck In-Reply-To: <48E50A2F.2000102@cs.ntua.gr> References: <48E3A1E6.4090307@alertlogic.net> <9D9606A2-0064-471E-B214-9E82DC850982@gmail.com> <48E3A86A.8010508@alertlogic.net> <28B99EDD-C840-4E3F-B59C-77A89F371B12@gmail.com> <48E3E4FF.3020403@cs.ntua.gr> <20081002110518.8EC0A24064@relay.gooddata.com> <48E50A2F.2000102@cs.ntua.gr> Message-ID: <20081002205111.9A9E32407D@relay.gooddata.com> On Thu, Oct 2, 2008 at 7:51 PM, Kostis Sagonas wrote: > Hynek Vychodil wrote: > >> I would like notice that hipe can cause performance lost for some special >> cases. There is not simple equation, switch on hipe and you gain some amount >> of performance surplus. Especially when you have tight loop over not so much >> complex data structures you can gain big amount of performance. >> > > It would have been much more helpful for the discussion if you presented > some quantitative results (and preferably code) for your claims. For > example, what qualifies as "not so much complex data structures" (by the > way, have you measured what happens in "complex" ones?), "big amount", > "performance loss for some special cases" (what's "special" about these > special cases), etc. My experience coming from first Wide Finder Project, Cedric Beust's challenge and some other works. I was busy to make some worth synthetic tests which only is valuable in this array, I think. My observation is that HiPE gain strongly depend on how task is solved. The fastest BEAM solution of some nontrivial task is often different from fastest HiPE solution. And from another point of view, same code compiled using HiPE can vary from 30 times faster to 20% slower. It means, that for some modules from OTP switching on HiPE can be worth thing (for nondebug environment only) but only for some modules, not for all. > > > When you do big amount of inter module calls you gain less >> > > This is slightly misleading: there is no "bad" treatment of inter module > calls (other than that dictated by the semantics of hot code loading). What > does have a non-negligible cost is so called mode-switching calls: calling > interpreted code from native or vice versa. The simplest way to avoid this > is to native compile everything. Alas, currently this is not so easy to do > for standard libraries. But note that even without compiling everything, > the speed up from native code is not something to disregard so quickly. > > For example, if I read Joel's mails correctly he got: > > 3000 games finished > Elapsed: 181.960007s, Average run time: 0.060653335 seconds (for BEAM) > Elapsed: 62.517129s, Average run time: 0.020839043 seconds (for HiPE) > > without compiling any of the OTP libraries. Joel can correct me if I am > wrong here. > > and when you do big amount of message passings you can lost some >> preformance when switch it on. >> > > It would help more if, instead of rather unquantified statements, you or > somebody else posted an actual application (*) showing a non-trivial > performance loss when native compiled. It would at least give us something > to work and improve upon. > > Kostis > > (*) not just a synthetic benchmark > Why not synthetic benchmark? My experience is that good synthetic benchmark is far worthy than "real" application because exactly point where is problem and which way is faster. I know, it is worthy only for one which understand. Application benchmarks are usefull just only for marketing and looks good in PR materials. They allege only how thing works for one special task and it solution, they tells nothink how it will works for a little bit different solution or task. Synthetic benchmarks contrary tell how work each component and you can predict how it will work in different tasks and solutions. It is harder, may be not so modern, but good engeneering. -- --Hynek (Pichi) Vychodil -------------- next part -------------- An HTML attachment was scrubbed... URL: From alexander.uvarov@REDACTED Thu Oct 2 23:29:09 2008 From: alexander.uvarov@REDACTED (Alexander) Date: Fri, 3 Oct 2008 03:29:09 +0600 Subject: [erlang-questions] Request to add md4 to crypto module In-Reply-To: References: Message-ID: <200810030329.09362.alexander.uvarov@gmail.com> On Thursday 02 October 2008 23:28:29 Jim McCoy wrote: > After poking around a bit in the OTP sources it seems that it would be > pretty trivial to add md4 to the crypto module. I will be testing a > few patches later this week, but before I throw together a real EEP I > was hoping that this might be a simple-enough change that the OTP team > might consider adding it without the need for the formal process. +1 for enhancement, also it would be useful to have DES in ECB mode too (trivial). If someone interested, there is my implementation based on erlang crypto driver (md4, des in ecb mode - used by mschapv2) http://pastie.org/283903 Also, why not make MD2 and finish dance with MD* crypto in erlang? :) > > As for the rationale: some applications (dhts, etc) need a large, fast > hash that has a good uniqueness distribution but are not worried about > the security implications of selecting an algorithm that is > cryptographically weak. The md4 hash is about 50% faster than md5, > which is a real win when you are hashing thousands of items. Since > there are already "questionable" algorithms included in the crypto > module (e.g. md5 and rc2) it seems that a warning in the docs that > this algorithm should not be used for security-sensitive tasks would > be sufficient notice to developers. > > Any thoughts or objections? > > jim > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From greg.burri@REDACTED Thu Oct 2 23:59:47 2008 From: greg.burri@REDACTED (Greg Burri) Date: Thu, 2 Oct 2008 23:59:47 +0200 Subject: [erlang-questions] Mnesia:write, index and complexity Message-ID: <60ed8a460810021459q28b33bbct15cdd8702a403861@mail.gmail.com> Hi, I use mnesia for a little project and I observed a strange (but maybe right) behavior from the function mnesia:write/1 when an extra index has alway the same value. In this case the complexity of the insertion appears to be in O(n) where n is the number of tuple in the table. My record : -record(minichat, { id, auteur_id, %indexed date, pseudo, contenu, troll_id = undefined, %indexed racine_id = undefined }). So, I made a little benchmark to see what happen in three cases : 1) '#minichat.troll_id' is undefined for all tuple 2) same as 1) but without the index on 'troll_id' 3) 'troll_id' is indexed but some random values are put in it You can see the results here : 1) O(n) : http://www.gburri.org/mnesia_write/results_100_000.png 2) O(1) : http://www.gburri.org/mnesia_write/results_100_000_without_index_on_troll_id.png 3) O(1) : http://www.gburri.org/mnesia_write/results_100_000_with_random_data_into_troll_id.png Is this behavior normal ? Is this the result of the collisions of keys ? Here is some additional informations about my tests : The creation of the table (called at the beginning of all test) : [..] mnesia:create_table(minichat, [ {attributes, record_info(fields, minichat)}, {disc_copies, [node()]} ]), mnesia:add_table_index(minichat, auteur_id), mnesia:add_table_index(minichat, troll_id). % commented for the second case test The benchmark code : [..] bench_write_minichat(Filename) -> Times = bench_write_minichat(1, []), {ok, File} = file:open(Filename, [write]), lists:foreach( fun({Id, Time}) -> io:format(File, "~w ~w~n", [Id, Time]) end, Times ), file:close(File). bench_write_minichat(100000, Temps) -> Temps; bench_write_minichat(Id, Temps) -> {T, _} = timer:tc(mnesia, transaction, [fun() -> mnesia:write(#minichat{ id = Id, auteur_id = random:uniform(1000), date = now(), pseudo = "Test", contenu = "Blabla blabla bla.", racine_id = random:uniform(1000) % ,troll_id = random:uniform(1000) % uncommented for the third case test }) end]), bench_write_minichat(Id + 1, if Id rem 500 =:= 0 -> [{Id, T} | Temps]; true -> Temps end). /Greg Burri -------------- next part -------------- An HTML attachment was scrubbed... URL: From btolputt@REDACTED Thu Oct 2 09:23:58 2008 From: btolputt@REDACTED (Benjamin Tolputt) Date: Thu, 02 Oct 2008 17:23:58 +1000 Subject: [erlang-questions] The Erlang Rationale In-Reply-To: References: <3dbc6d1c0809291502m3ad2147djfdc652a8e5c7a157@mail.gmail.com> <48E1F395.5040501@gmail.com> <3dbc6d1c0809300519kd46dbadsdfb670f71865b5@mail.gmail.com> <48E21D43.1040509@gmail.com> <4ac8254d0809300609m7c72c6b2je9774a70c629acf8@mail.gmail.com> <3dbc6d1c0809300630q35221794jf0922f370de6dd04@mail.gmail.com> <6c2563b20810010649xdb362dcyefc9e361608b33f7@mail.gmail.com> Message-ID: <48E4770E.7040303@bigpond.net.au> Richard O'Keefe wrote: > Nice logging example The problem I see with your solution(s) is that they are only better if the Erlang were different (i.e. top level variables and ?HERE). This, to me, is just a game of "what if" (unless you re actually putting them into Erlang - in which case, I humbly apologise). "What if" scenarios are great and all, but don't actually a valid argument make. -- Regards, Benjamin Tolputt Analyst Programmer Mob: 0417 456 505 Email: btolputt@REDACTED This email and any files transmitted with it are confidential to the intended recipient and may be privileged. If you have received this email inadvertently or you are not the intended recipient, you may not disseminate, distribute, copy or in any way rely on it. Further, you should notify the sender immediately and delete the email from your computer. Whilst we have taken precautions to alert us to the presence of computer viruses, we cannot guarantee that this email and any files transmitted with it are free from such viruses. From pablo.polvorin@REDACTED Fri Oct 3 01:36:46 2008 From: pablo.polvorin@REDACTED (Pablo Polvorin) Date: Thu, 2 Oct 2008 20:36:46 -0300 Subject: [erlang-questions] Mnesia:write, index and complexity In-Reply-To: <60ed8a460810021459q28b33bbct15cdd8702a403861@mail.gmail.com> References: <60ed8a460810021459q28b33bbct15cdd8702a403861@mail.gmail.com> Message-ID: <1ffe809c0810021636t513aaebeq32d413011d48822c@mail.gmail.com> Hi, there has been a discussion of this some months ago, search for "Index Overhead In Mnesia" 2008/10/2 Greg Burri : > Hi, > I use mnesia for a little project and I observed a strange (but maybe right) > behavior from the function mnesia:write/1 when an extra index has alway the > same value. > In this case the complexity of the insertion appears to be in O(n) where n > is the number of tuple in the table. > > My record : > -record(minichat, > { > id, > auteur_id, %indexed > date, > pseudo, > contenu, > troll_id = undefined, %indexed > racine_id = undefined > }). > > So, I made a little benchmark to see what happen in three cases : > 1) '#minichat.troll_id' is undefined for all tuple > 2) same as 1) but without the index on 'troll_id' > 3) 'troll_id' is indexed but some random values are put in it > > You can see the results here : > 1) O(n) : http://www.gburri.org/mnesia_write/results_100_000.png > 2) O(1) : > http://www.gburri.org/mnesia_write/results_100_000_without_index_on_troll_id.png > 3) O(1) : > http://www.gburri.org/mnesia_write/results_100_000_with_random_data_into_troll_id.png > > Is this behavior normal ? Is this the result of the collisions of keys ? > > > Here is some additional informations about my tests : > > The creation of the table (called at the beginning of all test) : > [..] > mnesia:create_table(minichat, [ > {attributes, record_info(fields, minichat)}, > {disc_copies, [node()]} > ]), > mnesia:add_table_index(minichat, auteur_id), > mnesia:add_table_index(minichat, troll_id). % commented for the second > case test > > The benchmark code : > [..] > bench_write_minichat(Filename) -> > Times = bench_write_minichat(1, []), > {ok, File} = file:open(Filename, [write]), > lists:foreach( > fun({Id, Time}) -> > io:format(File, "~w ~w~n", [Id, Time]) > end, > Times > ), > file:close(File). > bench_write_minichat(100000, Temps) -> Temps; > bench_write_minichat(Id, Temps) -> > {T, _} = timer:tc(mnesia, transaction, [fun() -> > mnesia:write(#minichat{ > id = Id, > auteur_id = random:uniform(1000), > date = now(), > pseudo = "Test", > contenu = "Blabla blabla bla.", > racine_id = random:uniform(1000) > % ,troll_id = random:uniform(1000) % uncommented for the third case > test > }) > end]), > bench_write_minichat(Id + 1, if Id rem 500 =:= 0 -> [{Id, T} | Temps]; > true -> Temps end). > > > /Greg Burri > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From pfisher@REDACTED Wed Oct 1 21:09:52 2008 From: pfisher@REDACTED (Paul Fisher) Date: Wed, 01 Oct 2008 14:09:52 -0500 Subject: [erlang-questions] Erlang doesn't suck In-Reply-To: <28B99EDD-C840-4E3F-B59C-77A89F371B12@gmail.com> References: <48E3A1E6.4090307@alertlogic.net> <9D9606A2-0064-471E-B214-9E82DC850982@gmail.com> <48E3A86A.8010508@alertlogic.net> <28B99EDD-C840-4E3F-B59C-77A89F371B12@gmail.com> Message-ID: <48E3CB00.1030104@alertlogic.net> Joel Reymont wrote: > On Oct 1, 2008, at 5:42 PM, Paul Fisher wrote: > >> Which begs the question of whether you compile to native or not for >> your benchmarking? Not everything benefits, but we have some >> modules that show significant gains from: >> >> -compile([native, {hipe,[o3]}, inline]). > > > There's certainly an increase in throughput (request per second) with > hipe, even under 32 bits. > > Is there a way to mass-hipe-compile all of OTP? I'd love to know if there is. > > Elapsed: 62.517129s, Average run time: 0.020839043 seconds > > Now I have to try to compile R12B4 in 64-bit mode.... I'm pulling together patch/instructions to make it all work and will send soon. -- paul From ok@REDACTED Fri Oct 3 03:44:24 2008 From: ok@REDACTED (Richard O'Keefe) Date: Fri, 3 Oct 2008 14:44:24 +1300 Subject: [erlang-questions] The Erlang Rationale In-Reply-To: <6c2563b20810012355t5ea248a0q24deddcd415a85fe@mail.gmail.com> References: <3dbc6d1c0809291502m3ad2147djfdc652a8e5c7a157@mail.gmail.com> <48E1F395.5040501@gmail.com> <3dbc6d1c0809300519kd46dbadsdfb670f71865b5@mail.gmail.com> <48E21D43.1040509@gmail.com> <4ac8254d0809300609m7c72c6b2je9774a70c629acf8@mail.gmail.com> <3dbc6d1c0809300630q35221794jf0922f370de6dd04@mail.gmail.com> <6c2563b20810010649xdb362dcyefc9e361608b33f7@mail.gmail.com> <6c2563b20810012355t5ea248a0q24deddcd415a85fe@mail.gmail.com> Message-ID: On 2 Oct 2008, at 7:55 pm, Edwin Fine wrote: > Sorry, but I did not agree. You agreed that macros *CAN* make maintenance harder. That's enough agreement for me. > You just read it that way. What I perhaps should have written is > that you bluntly asserted that macros make maintenance harder. I am > bluntly asserting that it is not necessarily so. My claim is that macros *always* makes it harder to build intelligent maintenance support tools. > > just like gotos *can* create spaghetti code. Neither of them are > intrinsically bad, merely easy to misuse. The existence of essentially uncontrolled gotos in a language makes optimising compilation harder; the task of building a compiler for such a language is more difficult *whether the feature is used or not*. In the same way, the *possibility* of macros makes it harder to build support tools, whether they are used or not, no matter what degree of discipline might be involved. Of course Erlang still isn't as weird as C, where /??\ * this *??\ /// was a comment As it happens, I straddle the fence on gotos. I have a compiler for a language with no gotos (and in which I never miss them); the compiler generates C with gotos (where they are used in a particular stylised way to avoid code duplication). But I maintain a version of AWK, and one of the things I did in that was to hunt down the gotos one after another. In fact, I'm still doing it. While writing this message I just zapped five more. (They were there for a micro-optimisation that made sense 30 years ago, but is now routinely done by compilers. The code is *definitely* easier to understand without them.) > I don't think this is a particularly compelling argument. I've been > involved in maintenance of multi-million line systems and had much > bigger fish to fry than macro-related difficulties with cross- > reference tools. Maybe your experience has been different. I have repeatedly encountered serious difficulties in navigating other people's macro-heavy code. > Used with care and discipline, they both arguably have a place in > good programming practice. Remember, MY "care and discipline" is YOUR "spaghetti code". [I was going to say it the other way around, but decided that might sound insulting.] I have chunks of C code generated by AWK scripts. (There's a Haskell compiler written in C where large chunks were generated by Perl scripts.) I happen to think this is not only cool, but counts as "care and discipline". Someone whose IDE hasn't the slightest clue and can't really cope with such stuff (XCode certainly isn't much help with colouring C code inside AWK strings (:-)) will not be impressed. > > > As a matter of fact, I still use M4 on Java code. > (Remember, Java 1.5 generics do *not* accept primitive types > as arguments. If you want to do that without the very heavy > overhead of Java boxing and unboxing, M4 is the only game in town.) > > So macros are NOT that evil :) Macros are indeed like gotos: when you aren't given the *right* tools for the job (something rather like Haskell/Clean/ Mercury/BitC typeclasses), macros are better than nothing. But something built into the language (counting the Dialyzer, which can read and check -spec declarations for functions but not for ?macros), is generally better. > > But what if, instead of or in addition to ?MODULE and ?LINE, > the system provided you with ?HERE, expanding to > {Module, Line, {Function, Arity}}. Then > > iutil_log:flog(?HERE, "Received ~p from ~p~n", [Msg,Socket]) > > doesn't seem _that_ horrible. > > Sorry to belabor the point, but what if it did? It doesn't. What if > we all lived in peace and harmony and respected each other's rights? Two answers. First, adding ?HERE to 'epp' is no big deal. Second, we don't actually need it. In your debug.hrl file, have -compile({inline, [{debug,0},{flog,3}]}). debug() -> true. % or false, whatever. flog(L, F, A) -> case debug() of true -> iutil_log:log_debug(?MODULE, L, F, A) ; false -> ok end. And now all you need to get what you had before is flog(?LINE, "Received ~p from ~p~n", [Msg,Socket]) where the ?MODULE part is supplied automatically. > Suppose we had top-level variables instead. So > > But we don't. I wish we did. Agreement again. One of the reasons we *don't* have top level variables is that we were given the preprocessor *instead*. Another strike against it. However, thanks to inlining, we don't actually need them for this problem. > > True - but I was working towards my ultimate point that having to > recompile is a pain and wanted the ability to change run-time log > levels. Which I dealt with later in the message. > And, using the above code, won't you get copious compiler or > Dialyzer warnings complaining that only one branch of the case will > ever be reached? How would you suppress those? Or are you going to > invent a suitable -pragma() for Erlang :) ? You're right that Dialyzer complains here. This is precisely as annoying, and precisely as (un)helpfl, as the way Lint started to warning about "constant conditional" in the do { ... } while (0) construction. If a case or if has *no* matching arms, that's a failure, but if *some* arms don't match, that's not a failure, it's just constant propagation. What's really annoying is that adding the declaration -spec(debug/0 :: () -> bool()). -- which I expected to tell Dialyzer that although *this* version of debug/0 can't return 'false', another version might -- didn't help at all. Shouldn't this *be* the pragma we need here? (Dialyzer v1.8.1) > > Ah, the old I've-seen-crap-code trick. Yes, absolutely true, and > anyone worth their salt will never put important code into log > statements that won't get evaluated. Which means that the argument for using a macro here completely disappears. > > -inline([flog/3]). > flog(Where, Format, Arguments) when Debug -> %%% Huh?? > > case iutil_log:ok_to_log(debug) > of true -> > {Module, Line, _} = Where, > iutil:log_debug(Module, Line, Format, Arguments) > ; false -> > ok > end; > flog(_, _, _) -> > ok. > > ... flog(?HERE, "......", [.....]) ... > > would push the evaluation of the format and arguments into the one > case branch that uses them. If it doesn't, we have far worse > performance issues to worry about than this one. > > Where does Debug come from? Is it a (non-existent) top-level variable? Please. We are picking nits here. So I edited the wrong version. flog(Line, Format, Arguments) -> case debug() of false -> ok ; true-> case iutil_log:ok_to_log(debug) of false -> ok ; true -> iutil_log:log_debug(?MODULE, Line, Format, Arguments) end end. > > In this context, I find BitC's distinction between pure and impure > functions _in the type system_ interesting. > > That would be very useful - does that mean the compiler > automatically flags functions as pure or impure based on their side- > effects? Yes. The draft manual gives the example of inferring that map :: %e fn (%e fn a -> b) list(a) -> list(b) -- I can't quite recall the syntax -- a call to map(f, xs) has side effects if and only if a call to f has. > > > That's also its strength (to be able to do ANYTHING and you don't > have to change the code). To find the definition using find and grep > isn't *that* hard, is it? I have searched the entire Erlang source > code base for things of interest in under a minute with find/grep. > Maybe it's slow using that 500MHz UltraSparc you are saddled with :( It's actually a 2.16 Intel Core 2 Duo intel-Mac that I've been running Erlang on recently. Grep is nice, but it doesn't understand about comments, it doesn't understand the difference between f(X) and f(X, Y), and a whole bunch of other things which explain why we have an Erlang cross-reference program. > If only we had ?HERE, > But we don't. I have to work with the real world. If ?HERE was here > I would use it! A prototype implementation of ?HERE, where it expands to {?MODULE,?LINE,undefined}, is just this much of a change to epp.erl: < Ms30 = dict:store({atom,'HERE'}, {none,[ < {'{',1},{'?',1},{atom,1,'MODULE'}, < {',',1},{'?',1},{atom,1,'LINE'}, < {',',1},{atom,1,undefined},{'}',1}]}, Ms3), < Ms31 = dict:store({atom,'MODULE_STRING'}, undefined, Ms30), --- > Ms31 = dict:store({atom,'MODULE_STRING'}, undefined, Ms3), Making it add ?LINE in as well would be trivial. To get function information requires parser support, so I'd have the preprocessor expand it to a {location, Line_Number, File_Name, Module} token, and then have the parser recognise this and generate the appropriate data structure. I suspect that I would have the parser turn it into a new {location...} AST form, and then another pass would deal with it. The issues are (1) finishing the design. Exactly what information should we put in a location? EEP time, except I don't have time today. (2) writing the code. Given my unfamiliarity with the compiler, this would probably take me two days to code and test. (3) documenting it. Hunting down all the files that need changing would be the tricky bit. (4) fixing all the code that currently thinks it knows exactly what the lexical analyser and parser can produce. This is the really hard bit. > The one important thing that I perhaps didn't understand from your > discussion is how you proposed to change the logging level at run > time, given the *existing* features of Erlang. With plain ordinary run-time code, how else? Didn't you see the "case iutil_log:ok_to_log(debug)" line? > > Understand that I gave the LOG_DBG macro as an example. As it > happens, I have LOG_TRACE, LOG_INFO, LOG_WARN, and LOG_ERROR as well. Which can presumably all be done the same way. To someone writing this code from scratch today, using functions is _less_ effort (because better understood by editing and debugging tools) than using macros. With *no* additions to the language. (Except for getting Dialyzer to shut up.) > Let me tell you what I have done, and this will probably give you > nightmares because it's a terrible hack, but it works well. Actually, no. It was the obvious thing to do. While I too suspect that it's probably faster than using the process dictionary, it might be a good idea to measure it. Ironically, you have actually provided a good example of why functions are *better* than macros for this kind of thing. You *can* hot-load a replacement for an imported function, but you *can't* hot-load a replacement for an included macro. (Nor can you set breakpoints on macros.) What I mean by a "top-level variable" is not something mutable. It's simply an Erlang variable bound at the top level of a module. A named constant, in other words. Although it would be nice to export and import top level variables; your hot-loading trick would still apply (and maybe even be a touch faster). From ok@REDACTED Fri Oct 3 04:15:29 2008 From: ok@REDACTED (Richard O'Keefe) Date: Fri, 3 Oct 2008 15:15:29 +1300 Subject: [erlang-questions] The Erlang Rationale In-Reply-To: <48E4770E.7040303@bigpond.net.au> References: <3dbc6d1c0809291502m3ad2147djfdc652a8e5c7a157@mail.gmail.com> <48E1F395.5040501@gmail.com> <3dbc6d1c0809300519kd46dbadsdfb670f71865b5@mail.gmail.com> <48E21D43.1040509@gmail.com> <4ac8254d0809300609m7c72c6b2je9774a70c629acf8@mail.gmail.com> <3dbc6d1c0809300630q35221794jf0922f370de6dd04@mail.gmail.com> <6c2563b20810010649xdb362dcyefc9e361608b33f7@mail.gmail.com> <48E4770E.7040303@bigpond.net.au> Message-ID: <3A1A577F-46AF-4923-A327-3B36238CB116@cs.otago.ac.nz> On 2 Oct 2008, at 8:23 pm, Benjamin Tolputt wrote: > Richard O'Keefe wrote: >> Nice logging example > > The problem I see with your solution(s) is that they are only better > if > the Erlang were different (i.e. top level variables and ?HERE). Wrong, as I realised after posting it. In fact, >>>>in that very posting<<<< I showed how top level variables are >>>not<<< in fact needed. Let me offer the skeleton again, slightly generalised. -compile({inline, [{compile_time_debug_level,0}, {log_error,3}, {log_warning,3}]}). compile_time_debug_level() -> errors. log_error(L, F, A) -> logger:log(error, ?MODULE, L, F, A). log_warning(L, F, A) -> case compile_time_debug_level() of warnings -> logger:log(warning, ?MODULE, L, F, A) ; errors -> ok end. called as ... log_error(?LINE, "...", [...]) ... ... log_warning(?LINE, "...", [...]) ... where ?LINE is sufficient because after -include processing, the local log functions are in the same module as the caller, so ?MODULE doesn't need to be passed. > This, to > me, is just a game of "what if" (unless you re actually putting them > into Erlang - in which case, I humbly apologise). "What if" scenarios > are great and all, but don't actually a valid argument make. You have completely mistaken the form of my argument at the point. My argument had the implicit form (which I thought to be so very obvious given good will as to not need spelling out) GRANTED for the sake of argument that logging of this form is something not currently well served, WHAT WOULD WE NEED TO DO in order to remove any need to use the preprocessor for this purpose. I first considered a run-time method of discovering the caller's location and dismissed it. I then mentioned top-level variables BUT SHOWED HOW WE DON'T NEED THEM. (Although it would be nice if the Dialyzer were more tolernate of the resulting code.) I then mentioned ?HERE as a possible idea that would leave the source code with a visible mention of "at this point I pass my source location" -- hence would be more tokens to type than using a macro -- but in a much shorter and potentially richer form than ?MODULE, ?LINE. Given my history of writing EEPS, readers were expected to see this as a pre-pre-EEP for ?HERE. Today I've mailed out patches to add a prototype version of ?HERE that gives you {?MODULE,?LINE,undefined} with undefined as a place-holder for a future {function,arity}. However, on the way home last night, it became annoyingly obvious that we don't actually need ?HERE at all. If people are content with ?MODULE and ?LINE, they can get that right now, passing ?LINE in the call and supplying ?MODULE in the (-included) callee. Note that when I complain about what macros do to maintainability -- including the ability of editors to indent properly -- I am *not* arguing against -include or even against ?MODULE and ?LINE or any other compiler-generated context-sensitive named constants, which turn out to be more abundant than I had remembered. This is a textbook case of why "no, we have to deal with the language as it is" is very bad thinking. Erlang is open source. We DON'T have to stick with the language as it is. We can all, any of us, invent alternatives and write EEPS. Having said "I need macros to do X", it is not helpful to just rest there. One should say "Have I really identified a need for macros or is there another way to do it? If I have really identified a need, what changes to the language or system would eliminate that need?" Come to think of it, my first (rejected) idea, of picking up the location at run time, might *long term* be the very best idea of all. (Or, on the other hand, it might still be as stunningly bad as I first thought it. I was inspired by the nargs() function that was available in some versions of C.) One of the issues that keeps coming up each year is someone wanting better location information in errors messages and tracebacks, and digging that out at run time seems to be the only practical way to do it. That being done, we wouldn't need ?MODULE, ?FILE, ?LINE, or any of those things; we could pick them up at run time. (Anyone else out there remember the B6700? 1960s design mainframe and operating system, but run-time errors *routinely* gave you line numbers in tracebacks.) From saleyn@REDACTED Fri Oct 3 04:32:37 2008 From: saleyn@REDACTED (Serge Aleynikov) Date: Thu, 02 Oct 2008 22:32:37 -0400 Subject: [erlang-questions] otp.net Message-ID: <48E58445.6050806@gmail.com> While playing with the otp.net project for the past several days I ran into one problem that I can't quite explain. I am starting a .NET node (saleyn@REDACTED) and connecting to a regular Erlang node (a@REDACTED), then send a Pid from .NET to Erlang and try to set up a monitor. The monitor call fails with badarg: (a@REDACTED)2> register(test, self()). true (a@REDACTED)3> nodes(hidden). [saleyn@REDACTED] (a@REDACTED)4> f(M), M = receive M -> M end. <5852.1.0> (a@REDACTED)5> M ! {hello, self()}. {hello,<0.50.0>} (a@REDACTED)6> erlang:monitor(process, M). ** exception error: bad argument in function erlang:monitor/2 called as erlang:monitor(process,<5852.1.0>) (a@REDACTED)7> I am able to send messages back and forth between two nodes and verify their delivery, but don't understand why the monitor call would fail. Does anyone have a clue? Serge From devdoer2@REDACTED Fri Oct 3 06:08:46 2008 From: devdoer2@REDACTED (devdoer bird) Date: Fri, 3 Oct 2008 12:08:46 +0800 Subject: [erlang-questions] Will mnesia transaction abort when the process who start it exits? Message-ID: HI: When the process start a mnesia transaction exits, will the transaction abort? If the mnesia database operation is NOT in a transaction, will the mnesia operation abort when the start process exit? -------------- next part -------------- An HTML attachment was scrubbed... URL: From lloy0076@REDACTED Wed Oct 1 05:55:45 2008 From: lloy0076@REDACTED (David Lloyd) Date: Wed, 01 Oct 2008 13:25:45 +0930 Subject: [erlang-questions] Simple OTP Question... In-Reply-To: References: <48E2E75E.4020000@adam.com.au> Message-ID: <48E2F4C1.9030202@adam.com.au> Damn, Maxim Treskin wrote: > Just read `erl -man gen_server`. > > ====== > start(ServerName, Module, Args, Options) -> Result > ServerName = {local, Name} | {global, GlobalName} > ====== > ServerName is NOT {ok, Name} > >> However, if I remove the "true, " in the source, the gen_server starts. > Which of? Thanks - I was looking for a more complex error when it should have been staring me in the face :( DSL From greg.burri@REDACTED Fri Oct 3 07:35:28 2008 From: greg.burri@REDACTED (Greg Burri) Date: Fri, 3 Oct 2008 07:35:28 +0200 Subject: [erlang-questions] Mnesia:write, index and complexity In-Reply-To: <1ffe809c0810021636t513aaebeq32d413011d48822c@mail.gmail.com> References: <60ed8a460810021459q28b33bbct15cdd8702a403861@mail.gmail.com> <1ffe809c0810021636t513aaebeq32d413011d48822c@mail.gmail.com> Message-ID: <60ed8a460810022235k3fa0a359tbc850a4d6cb7604c@mail.gmail.com> Thanks a lot, I solved my problem... /Greg On Fri, Oct 3, 2008 at 1:36 AM, Pablo Polvorin wrote: > Hi, > there has been a discussion of this some months ago, > search for "Index Overhead In Mnesia" > > > 2008/10/2 Greg Burri : > > Hi, > > I use mnesia for a little project and I observed a strange (but maybe > right) > > behavior from the function mnesia:write/1 when an extra index has alway > the > > same value. > > In this case the complexity of the insertion appears to be in O(n) where > n > > is the number of tuple in the table. > > > > My record : > > -record(minichat, > > { > > id, > > auteur_id, %indexed > > date, > > pseudo, > > contenu, > > troll_id = undefined, %indexed > > racine_id = undefined > > }). > > > > So, I made a little benchmark to see what happen in three cases : > > 1) '#minichat.troll_id' is undefined for all tuple > > 2) same as 1) but without the index on 'troll_id' > > 3) 'troll_id' is indexed but some random values are put in it > > > > You can see the results here : > > 1) O(n) : http://www.gburri.org/mnesia_write/results_100_000.png > > 2) O(1) : > > > http://www.gburri.org/mnesia_write/results_100_000_without_index_on_troll_id.png > > 3) O(1) : > > > http://www.gburri.org/mnesia_write/results_100_000_with_random_data_into_troll_id.png > > > > Is this behavior normal ? Is this the result of the collisions of keys ? > > > > > > Here is some additional informations about my tests : > > > > The creation of the table (called at the beginning of all test) : > > [..] > > mnesia:create_table(minichat, [ > > {attributes, record_info(fields, minichat)}, > > {disc_copies, [node()]} > > ]), > > mnesia:add_table_index(minichat, auteur_id), > > mnesia:add_table_index(minichat, troll_id). % commented for the second > > case test > > > > The benchmark code : > > [..] > > bench_write_minichat(Filename) -> > > Times = bench_write_minichat(1, []), > > {ok, File} = file:open(Filename, [write]), > > lists:foreach( > > fun({Id, Time}) -> > > io:format(File, "~w ~w~n", [Id, Time]) > > end, > > Times > > ), > > file:close(File). > > bench_write_minichat(100000, Temps) -> Temps; > > bench_write_minichat(Id, Temps) -> > > {T, _} = timer:tc(mnesia, transaction, [fun() -> > > mnesia:write(#minichat{ > > id = Id, > > auteur_id = random:uniform(1000), > > date = now(), > > pseudo = "Test", > > contenu = "Blabla blabla bla.", > > racine_id = random:uniform(1000) > > % ,troll_id = random:uniform(1000) % uncommented for the third > case > > test > > }) > > end]), > > bench_write_minichat(Id + 1, if Id rem 500 =:= 0 -> [{Id, T} | Temps]; > > true -> Temps end). > > > > > > /Greg Burri > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf@REDACTED Fri Oct 3 08:30:26 2008 From: ulf@REDACTED (Ulf Wiger) Date: Fri, 3 Oct 2008 08:30:26 +0200 Subject: [erlang-questions] The Erlang Rationale In-Reply-To: <3A1A577F-46AF-4923-A327-3B36238CB116@cs.otago.ac.nz> References: <3dbc6d1c0809291502m3ad2147djfdc652a8e5c7a157@mail.gmail.com> <3dbc6d1c0809300519kd46dbadsdfb670f71865b5@mail.gmail.com> <48E21D43.1040509@gmail.com> <4ac8254d0809300609m7c72c6b2je9774a70c629acf8@mail.gmail.com> <3dbc6d1c0809300630q35221794jf0922f370de6dd04@mail.gmail.com> <6c2563b20810010649xdb362dcyefc9e361608b33f7@mail.gmail.com> <48E4770E.7040303@bigpond.net.au> <3A1A577F-46AF-4923-A327-3B36238CB116@cs.otago.ac.nz> Message-ID: <8209f740810022330k1f0c8665h952f86ef8dfa533@mail.gmail.com> 2008/10/3 Richard O'Keefe : > > I then mentioned ?HERE as a possible idea that would leave the > source code with a visible mention of "at this point I pass my > source location" -- hence would be more tokens to type than > using a macro -- but in a much shorter and potentially richer > form than ?MODULE, ?LINE. > > Given my history of writing EEPS, readers were expected to see this > as a pre-pre-EEP for ?HERE. Today I've mailed out patches to add a > prototype version of ?HERE that gives you {?MODULE,?LINE,undefined} > with undefined as a place-holder for a future {function,arity}. I've been using ?HERE quite often in my code. It may seem unintuitive, but it works, since macros are simply a syntactic expansion: -module(here). -compile(export_all). -define(HERE, {?MODULE, ?LINE, undefined}). f() -> {?HERE, ?HERE}. $ erl Eshell V5.6.4 (abort with ^G) 1> here:f(). {{here,9,undefined},{here,10,undefined}} 2> So no need to patch epp before one can start using it. It's possible to add to the macro a way to find out the current module and arity as well. In a previous thread: http://groups.google.com/group/erlang-questions/browse_thread/thread/ee2929a3c67375b8 -define(FUNCTION,element(2,process_info(self(),current_function))). Then we could make our HERE definition: -define(HERE, {?MODULE, ?LINE, ?FUNCTION}). BR, Ulf W From ulf@REDACTED Fri Oct 3 08:34:43 2008 From: ulf@REDACTED (Ulf Wiger) Date: Fri, 3 Oct 2008 08:34:43 +0200 Subject: [erlang-questions] Will mnesia transaction abort when the process who start it exits? In-Reply-To: References: Message-ID: <8209f740810022334v254f9efqbbf0f78f79ac74c6@mail.gmail.com> 2008/10/3 devdoer bird : > HI: > > When the process start a mnesia transaction exits, will the transaction > abort? Yes. > If the mnesia database operation is NOT in a transaction, That would be a dirty operation. > will the mnesia operation abort when the start process exit? No. Dirty is dirty. BR, Ulf W From erlang-questions_efine@REDACTED Fri Oct 3 09:30:39 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Fri, 3 Oct 2008 03:30:39 -0400 Subject: [erlang-questions] The Erlang Rationale In-Reply-To: <6c2563b20810030028h35e63af0m78e74d83b2081739@mail.gmail.com> References: <3dbc6d1c0809291502m3ad2147djfdc652a8e5c7a157@mail.gmail.com> <4ac8254d0809300609m7c72c6b2je9774a70c629acf8@mail.gmail.com> <3dbc6d1c0809300630q35221794jf0922f370de6dd04@mail.gmail.com> <6c2563b20810010649xdb362dcyefc9e361608b33f7@mail.gmail.com> <48E4770E.7040303@bigpond.net.au> <3A1A577F-46AF-4923-A327-3B36238CB116@cs.otago.ac.nz> <8209f740810022330k1f0c8665h952f86ef8dfa533@mail.gmail.com> <6c2563b20810030028h35e63af0m78e74d83b2081739@mail.gmail.com> Message-ID: <6c2563b20810030030t23a4e8b3s61191c8ecbf7e0ed@mail.gmail.com> Apropos of all this macro and inline stuff, I tried Richard's suggestion for inlining but immediately hit an annoyance. in.hrl: -compile({inline, [{flog,3}]}). flog(L, F, A) -> case iutil_log:ok_to_log(info) of true -> iutil_log:log_info(?MODULE, L, F, A); false -> ok end. logtest.erl: -module(logtest). -include("in.hrl"). -export([go/0]). go() -> flog(?LINE, "Just logged using ~p's scheme~n", ["Richard O'Keefe"]). $ efine@REDACTED:/tmp$ erlc logtest.erl ./logtest.erl:3: attribute 'export' after function definitions ./in.hrl:3: Warning: function flog/3 is unused ./logtest.erl:5: Warning: function go/0 is unused Now to use this scheme, I have to ensure I put the -include AFTER all export statements. Seems annoying. Is there another way? E. -------------- next part -------------- An HTML attachment was scrubbed... URL: From devdoer2@REDACTED Fri Oct 3 09:45:17 2008 From: devdoer2@REDACTED (devdoer bird) Date: Fri, 3 Oct 2008 15:45:17 +0800 Subject: [erlang-questions] Will mnesia transaction abort when the process who start it exits? In-Reply-To: <8209f740810022334v254f9efqbbf0f78f79ac74c6@mail.gmail.com> References: <8209f740810022334v254f9efqbbf0f78f79ac74c6@mail.gmail.com> Message-ID: Thanks. 2008/10/3 Ulf Wiger > 2008/10/3 devdoer bird : > > HI: > > > > When the process start a mnesia transaction exits, will the transaction > > abort? > > Yes. > > > > If the mnesia database operation is NOT in a transaction, > > That would be a dirty operation. > > > > will the mnesia operation abort when the start process exit? > > No. Dirty is dirty. > > BR, > Ulf W > -------------- next part -------------- An HTML attachment was scrubbed... URL: From koops.j@REDACTED Fri Oct 3 10:45:12 2008 From: koops.j@REDACTED (Jeroen Koops) Date: Fri, 3 Oct 2008 10:45:12 +0200 Subject: [erlang-questions] Can I suppress the error-report when stopping a gen_server? Message-ID: <331a9abb0810030145g167fe3a7gf6e4b792e1ebce30@mail.gmail.com> Hi, When a gen_server stops by returning {stop, Reason, State} from handle_cast or handle_call, an error report is logged to the shell: =ERROR REPORT==== 3-Oct-2008::10:39:45 === ** Generic server test_server terminating ** Last message in was {'$gen_cast',stop} ** When Server state == 37 ** Reason for termination == ** "Stop requested" ** exited: "Stop requested" ** Is there any way to suppress this? Thanks, Jeroen Koops -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf.wiger@REDACTED Fri Oct 3 10:47:43 2008 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Fri, 03 Oct 2008 10:47:43 +0200 Subject: [erlang-questions] The Erlang Rationale In-Reply-To: <6c2563b20810030030t23a4e8b3s61191c8ecbf7e0ed@mail.gmail.com> References: <3dbc6d1c0809291502m3ad2147djfdc652a8e5c7a157@mail.gmail.com> <4ac8254d0809300609m7c72c6b2je9774a70c629acf8@mail.gmail.com> <3dbc6d1c0809300630q35221794jf0922f370de6dd04@mail.gmail.com> <6c2563b20810010649xdb362dcyefc9e361608b33f7@mail.gmail.com> <48E4770E.7040303@bigpond.net.au> <3A1A577F-46AF-4923-A327-3B36238CB116@cs.otago.ac.nz> <8209f740810022330k1f0c8665h952f86ef8dfa533@mail.gmail.com> <6c2563b20810030028h35e63af0m78e74d83b2081739@mail.gmail.com> <6c2563b20810030030t23a4e8b3s61191c8ecbf7e0ed@mail.gmail.com> Message-ID: <48E5DC2F.1010304@ericsson.com> Edwin Fine skrev: > > Now to use this scheme, I have to ensure I put the -include AFTER all > export statements. Seems annoying. Is there another way? I don't know, but I always do it in that order anyway: 1. export declarations 2. import declarations 3. includes 4. records and defines BR, Ulf W From ulf@REDACTED Fri Oct 3 11:00:28 2008 From: ulf@REDACTED (Ulf Wiger) Date: Fri, 3 Oct 2008 11:00:28 +0200 Subject: [erlang-questions] Can I suppress the error-report when stopping a gen_server? In-Reply-To: <331a9abb0810030145g167fe3a7gf6e4b792e1ebce30@mail.gmail.com> References: <331a9abb0810030145g167fe3a7gf6e4b792e1ebce30@mail.gmail.com> Message-ID: <8209f740810030200i76939799oa1261dab1b9c2b3e@mail.gmail.com> Use {stop, normal, State} instead. BR, Ulf W 2008/10/3 Jeroen Koops : > Hi, > > When a gen_server stops by returning {stop, Reason, State} from handle_cast > or handle_call, an error report is logged to the shell: > > =ERROR REPORT==== 3-Oct-2008::10:39:45 === > ** Generic server test_server terminating > ** Last message in was {'$gen_cast',stop} > ** When Server state == 37 > ** Reason for termination == > ** "Stop requested" > ** exited: "Stop requested" ** > > Is there any way to suppress this? > > Thanks, > > Jeroen Koops > > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From koops.j@REDACTED Fri Oct 3 11:07:31 2008 From: koops.j@REDACTED (Jeroen Koops) Date: Fri, 3 Oct 2008 11:07:31 +0200 Subject: [erlang-questions] Can I suppress the error-report when stopping a gen_server? In-Reply-To: <8209f740810030200i76939799oa1261dab1b9c2b3e@mail.gmail.com> References: <331a9abb0810030145g167fe3a7gf6e4b792e1ebce30@mail.gmail.com> <8209f740810030200i76939799oa1261dab1b9c2b3e@mail.gmail.com> Message-ID: <331a9abb0810030207l41fbca21x6d5dc8235af197b@mail.gmail.com> Great, thanks. On Fri, Oct 3, 2008 at 11:00 AM, Ulf Wiger wrote: > Use {stop, normal, State} instead. > > BR, > Ulf W > > 2008/10/3 Jeroen Koops : > > Hi, > > > > When a gen_server stops by returning {stop, Reason, State} from > handle_cast > > or handle_call, an error report is logged to the shell: > > > > =ERROR REPORT==== 3-Oct-2008::10:39:45 === > > ** Generic server test_server terminating > > ** Last message in was {'$gen_cast',stop} > > ** When Server state == 37 > > ** Reason for termination == > > ** "Stop requested" > > ** exited: "Stop requested" ** > > > > Is there any way to suppress this? > > > > Thanks, > > > > Jeroen Koops > > > > > > > > > > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dgud@REDACTED Fri Oct 3 12:08:35 2008 From: dgud@REDACTED (Dan Gudmundsson) Date: Fri, 03 Oct 2008 12:08:35 +0200 Subject: [erlang-questions] Request to add md4 to crypto module In-Reply-To: <200810030329.09362.alexander.uvarov@gmail.com> References: <200810030329.09362.alexander.uvarov@gmail.com> Message-ID: <48E5EF23.3050708@erix.ericsson.se> You don't have to write (in my mind) an EEP for adding things in a library, EEP is for language changes or other major erlang changes. Send a patch to erlang-patches, and if we thinks it's ok and have time we will add it. /Dan "Currently adding things to crypto" Alexander wrote: > On Thursday 02 October 2008 23:28:29 Jim McCoy wrote: >> After poking around a bit in the OTP sources it seems that it would be >> pretty trivial to add md4 to the crypto module. I will be testing a >> few patches later this week, but before I throw together a real EEP I >> was hoping that this might be a simple-enough change that the OTP team >> might consider adding it without the need for the formal process. > > +1 for enhancement, also it would be useful to have DES in ECB mode too > (trivial). If someone interested, there is my implementation based on erlang > crypto driver (md4, des in ecb mode - used by mschapv2) > http://pastie.org/283903 > > Also, why not make MD2 and finish dance with MD* crypto in erlang? :) > >> As for the rationale: some applications (dhts, etc) need a large, fast >> hash that has a good uniqueness distribution but are not worried about >> the security implications of selecting an algorithm that is >> cryptographically weak. The md4 hash is about 50% faster than md5, >> which is a real win when you are hashing thousands of items. Since >> there are already "questionable" algorithms included in the crypto >> module (e.g. md5 and rc2) it seems that a warning in the docs that >> this algorithm should not be used for security-sensitive tasks would >> be sufficient notice to developers. >> >> Any thoughts or objections? >> >> jim >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From joelr1@REDACTED Fri Oct 3 12:17:59 2008 From: joelr1@REDACTED (Joel Reymont) Date: Fri, 3 Oct 2008 11:17:59 +0100 Subject: [erlang-questions] Request to add md4 to crypto module In-Reply-To: <48E5EF23.3050708@erix.ericsson.se> References: <200810030329.09362.alexander.uvarov@gmail.com> <48E5EF23.3050708@erix.ericsson.se> Message-ID: Is there a reason why RC4 is present but not RC5? openssl supports both. Is this a patch issue? Thanks, Joel On Oct 3, 2008, at 11:08 AM, Dan Gudmundsson wrote: > You don't have to write (in my mind) an EEP for adding things in a > library, > EEP is for language changes or other major erlang changes. > > Send a patch to erlang-patches, and if we thinks it's ok and have > time we will add it. -- wagerlabs.com From tuncer.ayaz@REDACTED Fri Oct 3 12:34:12 2008 From: tuncer.ayaz@REDACTED (Tuncer Ayaz) Date: Fri, 3 Oct 2008 12:34:12 +0200 Subject: [erlang-questions] Request to add md4 to crypto module In-Reply-To: References: <200810030329.09362.alexander.uvarov@gmail.com> <48E5EF23.3050708@erix.ericsson.se> Message-ID: <4ac8254d0810030334u26e9ee50y5ffe2953626704eb@mail.gmail.com> On Fri, Oct 3, 2008 at 12:17 PM, Joel Reymont wrote: > Is there a reason why RC4 is present but not RC5? Possibly caused by the patent expiring in 2018? > openssl supports both. > > Is this a patch issue? > > Thanks, Joel > > On Oct 3, 2008, at 11:08 AM, Dan Gudmundsson wrote: > >> You don't have to write (in my mind) an EEP for adding things in a >> library, >> EEP is for language changes or other major erlang changes. >> >> Send a patch to erlang-patches, and if we thinks it's ok and have >> time we will add it. > > -- > wagerlabs.com > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From vladdu55@REDACTED Fri Oct 3 13:13:04 2008 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Fri, 3 Oct 2008 13:13:04 +0200 Subject: [erlang-questions] extending the scanner and parser Message-ID: <95be1d3b0810030413p52bc5b58uf22c6790d64f9f35@mail.gmail.com> Hi, Tools that process Erlang source code need more detailed information about the lexical tokens than those provided by the scanner in the standard distribution. For example, ErlIDE needs the character offset in the file and also the textual representation of the token. It also adds as an optimization the length of the textual token. Wrangler uses column information. These tools also need to be able to reconstruct the source code from the token list. For this to be possible, it must be possible to ask the scanner to return even whitespace and comments. It must also be possible to know the exact textual representation of the token, for example an integer valued 42 may have been written as "42" or as "16#2A" in the source file. In a similar way, the parse tree may need to know for each construct where it starts and where it ends in the source, so it needs to keep track of the underlying tokens. The way these tools get the extra information is by making a copy of erl_scan and erl_parse and modifying them to suit their purposes. This is a big maintenance headache and it limits interoperability between these tools, but currently the only way to solve the problem. Therefore I would like to suggest to extend the standard scanner and parser to support such extra information. If there will be a consensus that this is a Good Thing, I will happily provide a reference implementation in cooperation with any interested parties. If there is not enough general interest, I would still like to call out to all those who develope source handling tools and see if we could create a common library to share. best regards, Vlad From joelr1@REDACTED Fri Oct 3 15:29:03 2008 From: joelr1@REDACTED (Joel Reymont) Date: Fri, 3 Oct 2008 14:29:03 +0100 Subject: [erlang-questions] dialyzer: the pattern ... can never match the type 100 Message-ID: Any suggestions on how to fix this? pot.erl:28: The pattern Pot = {'side_pot', _, _} can never match the type 100 Thanks, Joel --- -record(side_pot, { members, all_in }). new_side_pot(AllInAmt, Members) -> #side_pot{ all_in = AllInAmt, members = Members }. %% vvv This is what it's complaining about new_side_pot(Pot = #side_pot{}) -> new_side_pot(Pot#side_pot.all_in, Pot#side_pot.members); new_side_pot(AllInAmt) when is_number(AllInAmt) -> new_side_pot(AllInAmt, gb_trees:empty()). new_side_pot() -> new_side_pot(0, gb_trees:empty()). -- wagerlabs.com From nick@REDACTED Fri Oct 3 15:52:51 2008 From: nick@REDACTED (Niclas Eklund) Date: Fri, 3 Oct 2008 15:52:51 +0200 (CEST) Subject: [erlang-questions] dialyzer: the pattern ... can never match the type 100 In-Reply-To: References: Message-ID: Hello! Change from: new_side_pot(Pot = #side_pot{}) -> to: new_side_pot(#side_pot{} = Pot) -> /Niclas @ Erlang/OTP On Fri, 3 Oct 2008, Joel Reymont wrote: > Any suggestions on how to fix this? > > pot.erl:28: The pattern Pot = {'side_pot', _, _} can never match the > type 100 > > Thanks, Joel > > --- > > -record(side_pot, { > members, > all_in > }). > > new_side_pot(AllInAmt, Members) -> > #side_pot{ > all_in = AllInAmt, > members = Members > }. > > %% vvv This is what it's complaining about > new_side_pot(Pot = #side_pot{}) -> > new_side_pot(Pot#side_pot.all_in, Pot#side_pot.members); > > new_side_pot(AllInAmt) > when is_number(AllInAmt) -> > new_side_pot(AllInAmt, gb_trees:empty()). > > new_side_pot() -> > new_side_pot(0, gb_trees:empty()). > > > -- > wagerlabs.com > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From joelr1@REDACTED Fri Oct 3 15:53:34 2008 From: joelr1@REDACTED (Joel Reymont) Date: Fri, 3 Oct 2008 14:53:34 +0100 Subject: [erlang-questions] dialyzer: the pattern ... can never match the type 100 In-Reply-To: References: Message-ID: <7FF0B3A7-A9BA-442F-B769-28C17B3415C1@gmail.com> On Oct 3, 2008, at 2:52 PM, Niclas Eklund wrote: > new_side_pot(#side_pot{} = Pot) -> > Thank you Niclas! What is the reason for doing it this way, though? I have ...(X = #foo{}) all over the code but this is the only place where Dialyzer is complaining about it. -- wagerlabs.com From lestat@REDACTED Fri Oct 3 16:04:54 2008 From: lestat@REDACTED (Tamas Nagy) Date: Fri, 3 Oct 2008 15:04:54 +0100 Subject: [erlang-questions] extending the scanner and parser In-Reply-To: <95be1d3b0810030413p52bc5b58uf22c6790d64f9f35@mail.gmail.com> References: <95be1d3b0810030413p52bc5b58uf22c6790d64f9f35@mail.gmail.com> Message-ID: <8DDF50EC-D01D-4DC3-90EF-7E51185C6160@elte.hu> Hi Vlad! Check out RefactorErl and contact the developers if you need something which is not available. I'm pretty sure they can help. It provides all the functionality which is mentioned in your e-mail. (These are all needed for refactoring as well to be able to retain the original layout). Furthermore it has an API to retrieve this information. So you do not have to hack it to get the data needed. :) The website: http://plc.inf.elte.hu/erlang/ Regards, Tamas On 3 Oct 2008, at 12:13, Vlad Dumitrescu wrote: > Hi, > > Tools that process Erlang source code need more detailed information > about the lexical tokens than those provided by the scanner in the > standard distribution. For example, ErlIDE needs the character offset > in the file and also the textual representation of the token. It also > adds as an optimization the length of the textual token. Wrangler > uses column information. > > These tools also need to be able to reconstruct the source code from > the token list. For this to be possible, it must be possible to ask > the scanner to return even whitespace and comments. It must also be > possible to know the exact textual representation of the token, for > example an integer valued 42 may have been written as "42" or as > "16#2A" in the source file. > > In a similar way, the parse tree may need to know for each construct > where it starts and where it ends in the source, so it needs to keep > track of the underlying tokens. > > The way these tools get the extra information is by making a copy of > erl_scan and erl_parse and modifying them to suit their purposes. > This is a big maintenance headache and it limits interoperability > between these tools, but currently the only way to solve the problem. > > Therefore I would like to suggest to extend the standard scanner and > parser to support such extra information. If there will be a consensus > that this is a Good Thing, I will happily provide a reference > implementation in cooperation with any interested parties. > > If there is not enough general interest, I would still like to call > out to all those who develope source handling tools and see if we > could create a common library to share. > > best regards, > Vlad > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From erlang-questions_efine@REDACTED Fri Oct 3 17:01:16 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Fri, 3 Oct 2008 11:01:16 -0400 Subject: [erlang-questions] The Erlang Rationale In-Reply-To: <48E5DC2F.1010304@ericsson.com> References: <3dbc6d1c0809291502m3ad2147djfdc652a8e5c7a157@mail.gmail.com> <6c2563b20810010649xdb362dcyefc9e361608b33f7@mail.gmail.com> <48E4770E.7040303@bigpond.net.au> <3A1A577F-46AF-4923-A327-3B36238CB116@cs.otago.ac.nz> <8209f740810022330k1f0c8665h952f86ef8dfa533@mail.gmail.com> <6c2563b20810030028h35e63af0m78e74d83b2081739@mail.gmail.com> <6c2563b20810030030t23a4e8b3s61191c8ecbf7e0ed@mail.gmail.com> <48E5DC2F.1010304@ericsson.com> Message-ID: <6c2563b20810030801g27c1c45bg8910617c0859783a@mail.gmail.com> Thank you. On Fri, Oct 3, 2008 at 4:47 AM, Ulf Wiger (TN/EAB) wrote: > Edwin Fine skrev: > >> >> Now to use this scheme, I have to ensure I put the -include AFTER all >> export statements. Seems annoying. Is there another way? >> > > I don't know, but I always do it in that order anyway: > > 1. export declarations > 2. import declarations > 3. includes > 4. records and defines > > BR, > Ulf W > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From H.Li@REDACTED Fri Oct 3 17:15:27 2008 From: H.Li@REDACTED (H.Li) Date: Fri, 3 Oct 2008 16:15:27 +0100 Subject: [erlang-questions] extending the scanner and parser In-Reply-To: <95be1d3b0810030413p52bc5b58uf22c6790d64f9f35@mail.gmail.com> References: <95be1d3b0810030413p52bc5b58uf22c6790d64f9f35@mail.gmail.com> Message-ID: <20081003151527.GA28655@myrtle.kent.ac.uk> > > The way these tools get the extra information is by making a copy of > erl_scan and erl_parse and modifying them to suit their purposes. > This is a big maintenance headache and it limits interoperability > between these tools, but currently the only way to solve the problem. That's exactly what Wrangler does. It would be really great if the standard scanner could be extended to support extra information. Regards, Huiqing From kenneth.lundin@REDACTED Fri Oct 3 18:18:04 2008 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Fri, 3 Oct 2008 18:18:04 +0200 Subject: [erlang-questions] extending the scanner and parser In-Reply-To: <20081003151527.GA28655@myrtle.kent.ac.uk> References: <95be1d3b0810030413p52bc5b58uf22c6790d64f9f35@mail.gmail.com> <20081003151527.GA28655@myrtle.kent.ac.uk> Message-ID: It is in our plans to have that support in our standard scanner in some way. Can not promise when but hopefully next year some time. /Kenneth Erlang/OTP tema , Ericsson On Fri, Oct 3, 2008 at 5:15 PM, H.Li wrote: > >> >> The way these tools get the extra information is by making a copy of >> erl_scan and erl_parse and modifying them to suit their purposes. >> This is a big maintenance headache and it limits interoperability >> between these tools, but currently the only way to solve the problem. > > That's exactly what Wrangler does. It would be really great if the standard > scanner could be extended to support extra information. > > Regards, > Huiqing > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From dawsdesign@REDACTED Fri Oct 3 19:05:45 2008 From: dawsdesign@REDACTED (Matt Williamson) Date: Fri, 3 Oct 2008 13:05:45 -0400 Subject: [erlang-questions] OTP.NET Error Message-ID: I'm trying out a simple OTP.NET test and it works great for the first call, but any subsequent calls result in the following exception: System.IO.IOException was unhandled Message="Peer replied with status 'alive' instead of 'ok'" Source="Otp" StackTrace: at Otp.AbstractConnection.recvStatus() in C:\Documents and Settings\Administrator\Desktop\jungerl\lib\otp.net\Otp\AbstractConnection.cs:line 1455 at Otp.AbstractConnection.doConnect(Int32 port) in C:\Documents and Settings\Administrator\Desktop\jungerl\lib\otp.net\Otp\AbstractConnection.cs:line 1018 at Otp.AbstractConnection..ctor(OtpLocalNode self, OtpPeer other) in C:\Documents and Settings\Administrator\Desktop\jungerl\lib\otp.net\Otp\AbstractConnection.cs:line 226 at Otp.OtpConnection..ctor(OtpSelf self, OtpPeer other) in C:\Documents and Settings\Administrator\Desktop\jungerl\lib\otp.net\Otp\OtpConnection.cs:line 84 at Otp.OtpPeer.connect(OtpSelf self) in C:\Documents and Settings\Administrator\Desktop\jungerl\lib\otp.net\Otp\OtpPeer.cs:line 67 at ErlTestClient.Form1.button1_Click(Object sender, EventArgs e) in C:\Documents and Settings\Administrator\My Documents\Projects\ErlTestClient\ErlTestClient\Form1.cs:line 25 at System.Windows.Forms.Control.OnClick(EventArgs e) at System.Windows.Forms.Button.OnClick(EventArgs e) at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ButtonBase.WndProc(Message& m) at System.Windows.Forms.Button.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData) at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.Run(Form mainForm) at ErlTestClient.Program.Main() in C:\Documents and Settings\Administrator\My Documents\Projects\ErlTestClient\ErlTestClient\Program.cs:line 17 at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() You can view my source at http://paste.lisp.org/display/67861 and http://paste.lisp.org/display/67862 Erlang is v5.6.3 on windows and I'm running VS2005. Please help :) -------------- next part -------------- An HTML attachment was scrubbed... URL: From wglozer@REDACTED Fri Oct 3 19:20:00 2008 From: wglozer@REDACTED (Will) Date: Fri, 3 Oct 2008 10:20:00 -0700 Subject: [erlang-questions] [bug] beam_asm failure on invalid binary match Message-ID: Hello, I mistakenly set the size specifier in a binary match to zero and it caused beam_asm to crash. This is Erlang/OTP R12B-4. Test case: test3() -> <> = <<2, 0, $h, $i, 0>>. Result: crash reason: {function_clause,[{beam_dict,old_string,[[],[]]}, {beam_dict,string,2}, {beam_asm,encode_arg,2}, {beam_asm,encode_op_1,3}, {beam_asm,assemble_function,3}, {beam_asm,assemble_1,4}, {beam_asm,assemble,4}, {beam_asm,module,4}]} Thanks, Will -------------- next part -------------- An HTML attachment was scrubbed... URL: From vladdu55@REDACTED Fri Oct 3 20:26:49 2008 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Fri, 3 Oct 2008 20:26:49 +0200 Subject: [erlang-questions] extending the scanner and parser In-Reply-To: References: <95be1d3b0810030413p52bc5b58uf22c6790d64f9f35@mail.gmail.com> <20081003151527.GA28655@myrtle.kent.ac.uk> Message-ID: <95be1d3b0810031126t5fb7b8b9x48bb75c3895a330e@mail.gmail.com> On Fri, Oct 3, 2008 at 18:18, Kenneth Lundin wrote: > It is in our plans to have that support in our standard scanner in some way. > Can not promise when but hopefully next year some time. That's wonderful to know! I suppose that it wouldn't hurt if we (the tool makers) would start right away to tinker with it so that when you're ready you will have something almost ready to work with, would it? best regards, Vlad From sean.d.payne@REDACTED Fri Oct 3 20:52:09 2008 From: sean.d.payne@REDACTED (Sean Payne) Date: Fri, 3 Oct 2008 11:52:09 -0700 Subject: [erlang-questions] Erlang timer program - feedback please Message-ID: <4d775bd70810031152g57c4f217vd181a8b3db3248db@mail.gmail.com> I am hoping someone with more Erlang experience than me could give me some feedback on the timer code below. I am using erlang:start_timer and tail recursion with a paused state and a running state to create a little simulation * world:init(). inits the sim * world:run(). starts the updates (right now updates just print out "updating") * world:pause(). pauses the updates * world:destroy(). shuts it down So my questions are: 1) Is there a better way (timer wise) to do this. I suspect that the way I am using the timer that my update_now will not be called at the right frequency because of the delay between when the event fires and when the next event is scheduled. 2) Is there a better way Erlang wise to do something like this. I am new to Erlang, so I am curious if this is the approach that someone with more experience would take. Is this how you would write this????? 3) Are there any bugs or leaks? ie am I using Tail recursion correctly? (every time I pause or unpause the program, am I going deeper into the stack?) Thanks, Sean ========================================= -module(world). %% External interfaces %% world:init sets up the world (into the paused state) %% world:run starts the timers and updates every UPDATE_INTERVAL %% world:stop pauses the world %% world:destroy destroys the world -export([init/0]). -export([run/0]). -export([stop/0]). -export([destroy/0]). %% internal functions but must be exported to receive events from erlang:start_timer -export([handle_events_while_stopped/0]). -export([handle_events_while_running/0]). -define(UPDATE_INTERVAL,1000). handle_events_while_stopped() -> receive finished-> io:format("world is finished~n", []); run-> io:format("world is running~n", []), erlang:start_timer(?UPDATE_INTERVAL, self(), update_now), handle_events_while_running() end. handle_events_while_running() -> receive finished-> io:format("world is finished~n", []); stop-> io:format("world is stopping~n", []), handle_events_while_stopped(); {timeout, _ , update_now} -> io:format("updating~n", []), erlang:start_timer(?UPDATE_INTERVAL, self(), update_now), handle_events_while_running() end. init() -> register(world, spawn(world, handle_events_while_stopped,[])). run()-> world ! run. stop()-> world ! stop. destroy()-> world ! finished. -------------- next part -------------- An HTML attachment was scrubbed... URL: From erlang-questions_efine@REDACTED Fri Oct 3 21:02:15 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Fri, 3 Oct 2008 15:02:15 -0400 Subject: [erlang-questions] Unused inline functions compiler warning Message-ID: <6c2563b20810031202u6dcf65bdqa88d2c09c193376b@mail.gmail.com> I'm trying to convert my code base from using macros for logging to using inline functions, as advocated by Richard O'Keefe. In an include (.hrl) file, I have inline function definitions like -compile({inline, [{log_info,3}, ...]). log_info(Line, Fmt, Args) -> ok = . %% Some code ... However, if I include this file and don't use all of the inline functions, I get a compiler warning for each unused function: warning:function ilog_error/3 is unused ... and more Does this imply that every inline function in a .hrl file will be inserted into every single .erl file that includes it, even if it is unused? If not, then why have a compiler warning? Is there any way to overcome this without reverting back to using macros? Can I get rid of just those warnings? Is there a way to suppress warnings for individual functions, like a -compile({suppress, [{wunused, [{log_info,3},{log_dbg,3}]}]})? -------------- next part -------------- An HTML attachment was scrubbed... URL: From kostis@REDACTED Fri Oct 3 21:42:31 2008 From: kostis@REDACTED (Kostis Sagonas) Date: Fri, 03 Oct 2008 22:42:31 +0300 Subject: [erlang-questions] dialyzer: the pattern ... can never match the type 100 In-Reply-To: References: Message-ID: <48E675A7.8090900@cs.ntua.gr> Joel Reymont wrote: > Any suggestions on how to fix this? > > pot.erl:28: The pattern Pot = {'side_pot', _, _} can never match the > type 100 How more explicit can the warning be? It says that you have a function (I am willing to bet that it is not exported) and the only call to it is with the integer 100. The first clause below is clearly dead code -- the pattern will never match 100. %% vvv This is what it's complaining about new_side_pot(Pot = #side_pot{}) -> new_side_pot(Pot#side_pot.all_in, Pot#side_pot.members); new_side_pot(AllInAmt) when is_number(AllInAmt) -> new_side_pot(AllInAmt, gb_trees:empty()). The solution to this one is to comment the clause out or simply remove it. It's simply not needed in your module. Kostis PS. What Niclas wrote as a "solution" is very misleading. AFAIK there is no difference between Pot = #side_pot{} and #side_pot{} = Pot in a clause head. From dloutrein.lists@REDACTED Fri Oct 3 23:40:43 2008 From: dloutrein.lists@REDACTED (denis) Date: Fri, 3 Oct 2008 17:40:43 -0400 Subject: [erlang-questions] xmerl_xpath and namespaces Message-ID: <48e6915d.050cc00a.5255.ffffba16@mx.google.com> Hello, I'm having some problem using xmerl_xpath on a document having namespaces. I'm not sure I fully understand how all of this work and the problem should not come from xmerl_xpath, but from my misunderstanding of xml, namespace, xpath. It seems that with xpath, it's mandatory to give the namespace. For instance, in a document like this: If I want to get all "element" attributes, I need to do a query like xmerl_xpath:string("//xs:simpleType", X) Is there a way to not having to give the namespace in the query ?? Another related question is the usage of {namespace, .} option in the query. What is it's usage ? A tried something like this xmerl_xpath:string("//simpleType", X, [{namespace, X#xmlElement.namespace}]). Hoping for a miracle. Of course, no miracle :-) I don't understand what do this option. My problem is that I get different schema "element"s, which are in two different namespaces. I can't see how to retrieve them using xpath. One namespace is declared in the root element, so I can get it's definition and add the namespace manually when building the query, but in the case above, the namespace is defined in the schema node itself, so I can't get it. If anybody can give me some highlight or pointers, this would help me a lot ! :-) Thanks Denis -------------- next part -------------- An HTML attachment was scrubbed... URL: From wglozer@REDACTED Fri Oct 3 23:49:57 2008 From: wglozer@REDACTED (Will) Date: Fri, 3 Oct 2008 14:49:57 -0700 Subject: [erlang-questions] Request to add md4 to crypto module In-Reply-To: <48E5EF23.3050708@erix.ericsson.se> References: <200810030329.09362.alexander.uvarov@gmail.com> <48E5EF23.3050708@erix.ericsson.se> Message-ID: Hi Dan, Glad to hear you're in the midst of work on crypto! I submitted patches a long time ago to add MD5 and SHA1 signing and verification with RSA keys. I'd love to see this included in crypto. http://article.gmane.org/gmane.comp.lang.erlang.patches/151 Thanks, Will On Fri, Oct 3, 2008 at 3:08 AM, Dan Gudmundsson wrote: > You don't have to write (in my mind) an EEP for adding things in a library, > EEP is for language changes or other major erlang changes. > > Send a patch to erlang-patches, and if we thinks it's ok and have time we > will add it. > > /Dan "Currently adding things to crypto" > > Alexander wrote: > > On Thursday 02 October 2008 23:28:29 Jim McCoy wrote: > >> After poking around a bit in the OTP sources it seems that it would be > >> pretty trivial to add md4 to the crypto module. I will be testing a > >> few patches later this week, but before I throw together a real EEP I > >> was hoping that this might be a simple-enough change that the OTP team > >> might consider adding it without the need for the formal process. > > > > +1 for enhancement, also it would be useful to have DES in ECB mode too > > (trivial). If someone interested, there is my implementation based on > erlang > > crypto driver (md4, des in ecb mode - used by mschapv2) > > http://pastie.org/283903 > > > > Also, why not make MD2 and finish dance with MD* crypto in erlang? :) > > > >> As for the rationale: some applications (dhts, etc) need a large, fast > >> hash that has a good uniqueness distribution but are not worried about > >> the security implications of selecting an algorithm that is > >> cryptographically weak. The md4 hash is about 50% faster than md5, > >> which is a real win when you are hashing thousands of items. Since > >> there are already "questionable" algorithms included in the crypto > >> module (e.g. md5 and rc2) it seems that a warning in the docs that > >> this algorithm should not be used for security-sensitive tasks would > >> be sufficient notice to developers. > >> > >> Any thoughts or objections? > >> > >> jim > >> _______________________________________________ > >> erlang-questions mailing list > >> erlang-questions@REDACTED > >> http://www.erlang.org/mailman/listinfo/erlang-questions > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From erlang-questions_efine@REDACTED Sat Oct 4 00:00:46 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Fri, 3 Oct 2008 18:00:46 -0400 Subject: [erlang-questions] Unused inline functions compiler warning - solved Message-ID: <6c2563b20810031500k7681b0a1rce94ff0807b060d0@mail.gmail.com> Please ignore this. I didn't RTFM properly so I missed the {nowarn_unused_function, FAs} in the compile module documentation. For the record, *unused inline functions are inserted into the module if compile([export_all]) is defined*, but not if functions are exported individually. This is hinted at indirectly in the documentation about inline functions: "When a function is inlined, the original function may be kept as a separate function as well, because there might still be calls to it." On Fri, Oct 3, 2008 at 3:02 PM, Edwin Fine wrote: > I'm trying to convert my code base from using macros for logging to using > inline functions, as advocated by Richard O'Keefe. > > In an include (.hrl) file, I have inline function definitions like > > -compile({inline, [{log_info,3}, ...]). > > log_info(Line, Fmt, Args) -> > ok = . %% Some code > ... > > However, if I include this file and don't use all of the inline functions, > I get a compiler warning for each unused function: > > warning:function ilog_error/3 is unused > ... and more > > Does this imply that every inline function in a .hrl file will be inserted > into every single .erl file that includes it, even if it is unused? If not, > then why have a compiler warning? > > Is there any way to overcome this without reverting back to using macros? > > Can I get rid of just those warnings? Is there a way to suppress warnings > for individual functions, like a -compile({suppress, [{wunused, > [{log_info,3},{log_dbg,3}]}]})? > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From saleyn@REDACTED Sat Oct 4 04:38:24 2008 From: saleyn@REDACTED (Serge Aleynikov) Date: Fri, 03 Oct 2008 22:38:24 -0400 Subject: [erlang-questions] OTP.NET Error In-Reply-To: References: Message-ID: <48E6D720.1080404@gmail.com> I took a quick look at your code and see that you are doing this on every button click which is wrong: OtpSelf self = new OtpSelf("client@REDACTED", "abc123"); OtpPeer server = new OtpPeer("server@REDACTED"); OtpConnection connection = server.connect(self); Move that to form initialization function, and try again. I guess what's going on is that OtpAbstractNode doesn't implement proper destruction and freeing resources (the socket connection), and as a result on every button click you are trying to set up more than one connection with the Erlang server node, which is not allowed, so the server drops the second and following connection attempts. Serge Matt Williamson wrote: > I'm trying out a simple OTP.NET test and it works great for the first call, > but any subsequent calls result in the following exception: > System.IO.IOException was unhandled > Message="Peer replied with status 'alive' instead of 'ok'" > Source="Otp" > StackTrace: > at Otp.AbstractConnection.recvStatus() in C:\Documents and > Settings\Administrator\Desktop\jungerl\lib\otp.net\Otp\AbstractConnection.cs:line > 1455 > at Otp.AbstractConnection.doConnect(Int32 port) in C:\Documents and > Settings\Administrator\Desktop\jungerl\lib\otp.net\Otp\AbstractConnection.cs:line > 1018 > at Otp.AbstractConnection..ctor(OtpLocalNode self, OtpPeer other) in > C:\Documents and > Settings\Administrator\Desktop\jungerl\lib\otp.net\Otp\AbstractConnection.cs:line > 226 > at Otp.OtpConnection..ctor(OtpSelf self, OtpPeer other) in > C:\Documents and > Settings\Administrator\Desktop\jungerl\lib\otp.net\Otp\OtpConnection.cs:line > 84 > at Otp.OtpPeer.connect(OtpSelf self) in C:\Documents and > Settings\Administrator\Desktop\jungerl\lib\otp.net\Otp\OtpPeer.cs:line 67 > at ErlTestClient.Form1.button1_Click(Object sender, EventArgs e) in > C:\Documents and Settings\Administrator\My > Documents\Projects\ErlTestClient\ErlTestClient\Form1.cs:line 25 > at System.Windows.Forms.Control.OnClick(EventArgs e) > at System.Windows.Forms.Button.OnClick(EventArgs e) > at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) > at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons > button, Int32 clicks) > at System.Windows.Forms.Control.WndProc(Message& m) > at System.Windows.Forms.ButtonBase.WndProc(Message& m) > at System.Windows.Forms.Button.WndProc(Message& m) > at > System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) > at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& > m) > at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, > Int32 msg, IntPtr wparam, IntPtr lparam) > at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& > msg) > at > System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 > dwComponentID, Int32 reason, Int32 pvLoopData) > at > System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 > reason, ApplicationContext context) > at > System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, > ApplicationContext context) > at System.Windows.Forms.Application.Run(Form mainForm) > at ErlTestClient.Program.Main() in C:\Documents and > Settings\Administrator\My > Documents\Projects\ErlTestClient\ErlTestClient\Program.cs:line 17 > at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] > args) > at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence > assemblySecurity, String[] args) > at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() > at System.Threading.ThreadHelper.ThreadStart_Context(Object state) > at System.Threading.ExecutionContext.Run(ExecutionContext > executionContext, ContextCallback callback, Object state) > at System.Threading.ThreadHelper.ThreadStart() > > > You can view my source at http://paste.lisp.org/display/67861 and > http://paste.lisp.org/display/67862 > > Erlang is v5.6.3 on windows and I'm running VS2005. > > Please help :) > > > > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From saleyn@REDACTED Sat Oct 4 07:32:55 2008 From: saleyn@REDACTED (Serge Aleynikov) Date: Sat, 04 Oct 2008 01:32:55 -0400 Subject: [erlang-questions] jinterface (was: otp.net) In-Reply-To: <48E58445.6050806@gmail.com> References: <48E58445.6050806@gmail.com> Message-ID: <48E70007.1020004@gmail.com> I tried a similar test using jinterface to see if it's possible to monitor processes running on a Java node and ran into the same failure. Can anyone explain what's wrong? (server@REDACTED)10> {test, client@REDACTED} ! {self(), hello}. {<0.45.0>,hello} (server@REDACTED)11> f(), {Pid, _} = receive M -> M end. {<5979.1.0>,hello} (server@REDACTED)12> erlang:monitor(process, Pid). ** exception error: bad argument in function erlang:monitor/2 called as erlang:monitor(process,<5979.1.0>) The corresponding java node was implemented using code below: import com.ericsson.otp.erlang.*; public class test { public static void main (String args[]) { System.out.println ("Hello World!"); try { OtpSelf self = new OtpSelf("client", "abc123"); OtpPeer other = new OtpPeer("server"); OtpConnection connection = self.connect(other); connection.sendRPC("erlang","date",new OtpErlangList()); OtpErlangObject received = connection.receiveRPC(); System.out.println("erlang:date() -> " + received + "\n"); OtpErlangObject o; OtpErlangTuple msg; OtpErlangPid from; while (true) { try { o = connection.receive(); if (o instanceof OtpErlangTuple) { msg = (OtpErlangTuple)o; from = (OtpErlangPid)(msg.elementAt(0)); connection.send(from, new OtpErlangTuple( new OtpErlangObject[] { self.pid(), msg.elementAt(1) } ) ); } } catch (Exception e) { System.out.println("" + e); } } } catch (Exception e) { System.out.println("" + e); } } } Serge Aleynikov wrote: > While playing with the otp.net project for the past several days I ran > into one problem that I can't quite explain. I am starting a .NET node > (saleyn@REDACTED) and connecting to a regular Erlang node > (a@REDACTED), then send a Pid from .NET to Erlang and try to set up a > monitor. The monitor call fails with badarg: > > (a@REDACTED)2> register(test, self()). > true > (a@REDACTED)3> nodes(hidden). > [saleyn@REDACTED] > (a@REDACTED)4> f(M), M = receive M -> M end. > <5852.1.0> > (a@REDACTED)5> M ! {hello, self()}. > {hello,<0.50.0>} > (a@REDACTED)6> erlang:monitor(process, M). > ** exception error: bad argument > in function erlang:monitor/2 > called as erlang:monitor(process,<5852.1.0>) > (a@REDACTED)7> > > I am able to send messages back and forth between two nodes and verify > their delivery, but don't understand why the monitor call would fail. > Does anyone have a clue? > > Serge > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From joelr1@REDACTED Sat Oct 4 11:32:49 2008 From: joelr1@REDACTED (Joel Reymont) Date: Sat, 4 Oct 2008 10:32:49 +0100 Subject: [erlang-questions] dialyzer: the pattern ... can never match the type 100 In-Reply-To: <48E675A7.8090900@cs.ntua.gr> References: <48E675A7.8090900@cs.ntua.gr> Message-ID: On Oct 3, 2008, at 8:42 PM, Kostis Sagonas wrote: > It says that you have a function (I am willing to bet that it is not > exported) and the only call to it is with the integer 100. The > first clause below is clearly dead code -- the pattern will never > match 100. It's not evident that "the type 100" refers to the integer 100. Could the wording be changed perhaps? -- wagerlabs.com From vladdu55@REDACTED Sat Oct 4 13:07:12 2008 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Sat, 4 Oct 2008 13:07:12 +0200 Subject: [erlang-questions] jinterface (was: otp.net) In-Reply-To: <48E70007.1020004@gmail.com> References: <48E58445.6050806@gmail.com> <48E70007.1020004@gmail.com> Message-ID: <95be1d3b0810040407xa4d4011v82eb16afe48cc77c@mail.gmail.com> Hi Serge, On Sat, Oct 4, 2008 at 07:32, Serge Aleynikov wrote: > I tried a similar test using jinterface to see if it's possible to > monitor processes running on a Java node and ran into the same failure. > (server@REDACTED)12> erlang:monitor(process, Pid). > ** exception error: bad argument > in function erlang:monitor/2 > called as erlang:monitor(process,<5979.1.0>) The documentation for erlang:monitor/2 says: "If an attempt is made to monitor a process on an older node (where remote process monitoring is not implemented or one where remote process monitoring by registered name is not implemented), the call fails with badarg. " The Java nodes aren't implementing everything that an Erlang node does, and I process monitoring is one of the things that is missing. In Java it is quite dificult (IMO) to have an Erlang-like setup with many mailboxes in separate threads. It gets hairy pretty fast. I am using only two mailboxes and then it is good enough to do the monitoring with erlang:monitor_node/1. I was considering to implement this kind of features for Java nodes, but never got enough time and motivation (you know, if it doesn't itch, one doesn't have to scratch it :-) regards, Vlad From pguyot@REDACTED Sat Oct 4 15:14:09 2008 From: pguyot@REDACTED (Paul Guyot) Date: Sat, 4 Oct 2008 15:14:09 +0200 Subject: [erlang-questions] jinterface (was: otp.net) In-Reply-To: References: Message-ID: <6C2A5378-5BDE-4FF9-B2AF-790D1F78330B@kallisys.net> > Date: Sat, 04 Oct 2008 01:32:55 -0400 > From: Serge Aleynikov > Subject: Re: [erlang-questions] jinterface (was: otp.net) > > I tried a similar test using jinterface to see if it's possible to > monitor processes running on a Java node and ran into the same > failure. > > Can anyone explain what's wrong? > > (server@REDACTED)10> {test, client@REDACTED} ! {self(), hello}. > {<0.45.0>,hello} > (server@REDACTED)11> f(), {Pid, _} = receive M -> M end. > {<5979.1.0>,hello} > (server@REDACTED)12> erlang:monitor(process, Pid). > ** exception error: bad argument > in function erlang:monitor/2 > called as erlang:monitor(process,<5979.1.0>) I've seen a comment in stdlib/gen.erl, at line 196, that suggests that Java and C nodes are featureweak, and processes in such nodes cannot be monitored. Instead, you have to monitor the whole node with monitor_node/2. This makes sense because the OTP ei (C library) or jinterface do not monitor "processes". Indeed, there is only one pid per node, which is the node's pseudo-pid (even if technically, each connection can receive messages). I guess you can draw from the code in gen.erl if you need to monitor either an erlang process or your java process, or just monitor the node if you only need to monitor java processes. Regards, Paul From saleyn@REDACTED Sat Oct 4 15:43:39 2008 From: saleyn@REDACTED (Serge Aleynikov) Date: Sat, 04 Oct 2008 09:43:39 -0400 Subject: [erlang-questions] jinterface In-Reply-To: <6C2A5378-5BDE-4FF9-B2AF-790D1F78330B@kallisys.net> References: <6C2A5378-5BDE-4FF9-B2AF-790D1F78330B@kallisys.net> Message-ID: <48E7730B.3090506@gmail.com> One other "nasty" feature is that any attempt to make an RPC call of io:format/2 from a Java/.NET node fails with badarg, because io server tries to set up a monitor to the remote pid and fails miserably... Actually I see what's missing in Java/OTP.NET implementation. These features are documented here: http://www.erlang.org/doc/apps/erts/erl_dist_protocol.html#9.7 Serge Paul Guyot wrote: >> Date: Sat, 04 Oct 2008 01:32:55 -0400 >> From: Serge Aleynikov >> Subject: Re: [erlang-questions] jinterface (was: otp.net) >> >> I tried a similar test using jinterface to see if it's possible to >> monitor processes running on a Java node and ran into the same failure. >> >> Can anyone explain what's wrong? >> >> (server@REDACTED)10> {test, client@REDACTED} ! {self(), hello}. >> {<0.45.0>,hello} >> (server@REDACTED)11> f(), {Pid, _} = receive M -> M end. >> {<5979.1.0>,hello} >> (server@REDACTED)12> erlang:monitor(process, Pid). >> ** exception error: bad argument >> in function erlang:monitor/2 >> called as erlang:monitor(process,<5979.1.0>) > > I've seen a comment in stdlib/gen.erl, at line 196, that suggests that > Java and C nodes are featureweak, and processes in such nodes cannot be > monitored. Instead, you have to monitor the whole node with > monitor_node/2. This makes sense because the OTP ei (C library) or > jinterface do not monitor "processes". Indeed, there is only one pid per > node, which is the node's pseudo-pid (even if technically, each > connection can receive messages). I guess you can draw from the code in > gen.erl if you need to monitor either an erlang process or your java > process, or just monitor the node if you only need to monitor java > processes. > > Regards, > > Paul > > From saleyn@REDACTED Sat Oct 4 15:17:35 2008 From: saleyn@REDACTED (Serge Aleynikov) Date: Sat, 04 Oct 2008 09:17:35 -0400 Subject: [erlang-questions] jinterface In-Reply-To: <95be1d3b0810040407xa4d4011v82eb16afe48cc77c@mail.gmail.com> References: <48E58445.6050806@gmail.com> <48E70007.1020004@gmail.com> <95be1d3b0810040407xa4d4011v82eb16afe48cc77c@mail.gmail.com> Message-ID: <48E76CEF.8080106@gmail.com> Vlad Dumitrescu wrote: > On Sat, Oct 4, 2008 at 07:32, Serge Aleynikov wrote: >> I tried a similar test using jinterface to see if it's possible to >> monitor processes running on a Java node and ran into the same failure. > >> (server@REDACTED)12> erlang:monitor(process, Pid). >> ** exception error: bad argument >> in function erlang:monitor/2 >> called as erlang:monitor(process,<5979.1.0>) > > The documentation for erlang:monitor/2 says: > > "If an attempt is made to monitor a process on an older node (where > remote process monitoring is not implemented or one where remote > process monitoring by registered name is not implemented), the call > fails with badarg. " > > The Java nodes aren't implementing everything that an Erlang node > does, and I process monitoring is one of the things that is missing. I guess I had higher hopes for jinterface (and consequently otp.net). :-( > In Java it is quite dificult (IMO) to have an Erlang-like setup with > many mailboxes in separate threads. It gets hairy pretty fast. I am > using only two mailboxes and then it is good enough to do the > monitoring with erlang:monitor_node/1. Actually, my overall goal was to establish the reverse - monitor an Erlang process from a .NET client (or java), where the client implements a UI application that establishes subscription with a process for receiving events of some sort, and tries to reestablish subscription if it detects that the remote process died. Serge From rvirding@REDACTED Sat Oct 4 16:11:56 2008 From: rvirding@REDACTED (Robert Virding) Date: Sat, 4 Oct 2008 16:11:56 +0200 Subject: [erlang-questions] jinterface In-Reply-To: <48E7730B.3090506@gmail.com> References: <6C2A5378-5BDE-4FF9-B2AF-790D1F78330B@kallisys.net> <48E7730B.3090506@gmail.com> Message-ID: <3dbc6d1c0810040711w26eae030pbcbccf7e1f4d5fd0@mail.gmail.com> It's not the io server which tries to setup a monitor, but the io module itself. These are two separate but cooperating entities. The io module monitors the io server to make sure that the call will not block if the process dies. The easiest way around this is to do the send/receive to the io serv yourself without a monitor. Robert 2008/10/4 Serge Aleynikov > One other "nasty" feature is that any attempt to make an RPC call of > io:format/2 from a Java/.NET node fails with badarg, because io server > tries to set up a monitor to the remote pid and fails miserably... > > Actually I see what's missing in Java/OTP.NET implementation. These > features are documented here: > http://www.erlang.org/doc/apps/erts/erl_dist_protocol.html#9.7 > > Serge > > > > Paul Guyot wrote: > >> Date: Sat, 04 Oct 2008 01:32:55 -0400 > >> From: Serge Aleynikov > >> Subject: Re: [erlang-questions] jinterface (was: otp.net) > >> > >> I tried a similar test using jinterface to see if it's possible to > >> monitor processes running on a Java node and ran into the same failure. > >> > >> Can anyone explain what's wrong? > >> > >> (server@REDACTED)10> {test, client@REDACTED} ! {self(), hello}. > >> {<0.45.0>,hello} > >> (server@REDACTED)11> f(), {Pid, _} = receive M -> M end. > >> {<5979.1.0>,hello} > >> (server@REDACTED)12> erlang:monitor(process, Pid). > >> ** exception error: bad argument > >> in function erlang:monitor/2 > >> called as erlang:monitor(process,<5979.1.0>) > > > > I've seen a comment in stdlib/gen.erl, at line 196, that suggests that > > Java and C nodes are featureweak, and processes in such nodes cannot be > > monitored. Instead, you have to monitor the whole node with > > monitor_node/2. This makes sense because the OTP ei (C library) or > > jinterface do not monitor "processes". Indeed, there is only one pid per > > node, which is the node's pseudo-pid (even if technically, each > > connection can receive messages). I guess you can draw from the code in > > gen.erl if you need to monitor either an erlang process or your java > > process, or just monitor the node if you only need to monitor java > > processes. > > > > Regards, > > > > Paul > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From saleyn@REDACTED Sat Oct 4 16:49:27 2008 From: saleyn@REDACTED (Serge Aleynikov) Date: Sat, 04 Oct 2008 10:49:27 -0400 Subject: [erlang-questions] jinterface In-Reply-To: <3dbc6d1c0810040711w26eae030pbcbccf7e1f4d5fd0@mail.gmail.com> References: <6C2A5378-5BDE-4FF9-B2AF-790D1F78330B@kallisys.net> <48E7730B.3090506@gmail.com> <3dbc6d1c0810040711w26eae030pbcbccf7e1f4d5fd0@mail.gmail.com> Message-ID: <48E78277.4000809@gmail.com> Ah, I see, this makes sense. Meanwhile, I looked through the distribution sources, ei, and jinterface and see that it's not that difficult to add some monitoring support for non-Erlang nodes so that they can monitor Erlang pids. I'll patch otp.net and later ei if I find time this or next weekend. Serge Robert Virding wrote: > It's not the io server which tries to setup a monitor, but the io module > itself. These are two separate but cooperating entities. The io module > monitors the io server to make sure that the call will not block if the > process dies. The easiest way around this is to do the send/receive to the > io serv yourself without a monitor. > > Robert > > 2008/10/4 Serge Aleynikov > >> One other "nasty" feature is that any attempt to make an RPC call of >> io:format/2 from a Java/.NET node fails with badarg, because io server >> tries to set up a monitor to the remote pid and fails miserably... >> >> Actually I see what's missing in Java/OTP.NET implementation. These >> features are documented here: >> http://www.erlang.org/doc/apps/erts/erl_dist_protocol.html#9.7 >> >> Serge >> >> >> >> Paul Guyot wrote: >>>> Date: Sat, 04 Oct 2008 01:32:55 -0400 >>>> From: Serge Aleynikov >>>> Subject: Re: [erlang-questions] jinterface (was: otp.net) >>>> >>>> I tried a similar test using jinterface to see if it's possible to >>>> monitor processes running on a Java node and ran into the same failure. >>>> >>>> Can anyone explain what's wrong? >>>> >>>> (server@REDACTED)10> {test, client@REDACTED} ! {self(), hello}. >>>> {<0.45.0>,hello} >>>> (server@REDACTED)11> f(), {Pid, _} = receive M -> M end. >>>> {<5979.1.0>,hello} >>>> (server@REDACTED)12> erlang:monitor(process, Pid). >>>> ** exception error: bad argument >>>> in function erlang:monitor/2 >>>> called as erlang:monitor(process,<5979.1.0>) >>> I've seen a comment in stdlib/gen.erl, at line 196, that suggests that >>> Java and C nodes are featureweak, and processes in such nodes cannot be >>> monitored. Instead, you have to monitor the whole node with >>> monitor_node/2. This makes sense because the OTP ei (C library) or >>> jinterface do not monitor "processes". Indeed, there is only one pid per >>> node, which is the node's pseudo-pid (even if technically, each >>> connection can receive messages). I guess you can draw from the code in >>> gen.erl if you need to monitor either an erlang process or your java >>> process, or just monitor the node if you only need to monitor java >>> processes. >>> >>> Regards, >>> >>> Paul >>> >>> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > From rvirding@REDACTED Sat Oct 4 16:57:42 2008 From: rvirding@REDACTED (Robert Virding) Date: Sat, 4 Oct 2008 16:57:42 +0200 Subject: [erlang-questions] jinterface In-Reply-To: <48E78277.4000809@gmail.com> References: <6C2A5378-5BDE-4FF9-B2AF-790D1F78330B@kallisys.net> <48E7730B.3090506@gmail.com> <3dbc6d1c0810040711w26eae030pbcbccf7e1f4d5fd0@mail.gmail.com> <48E78277.4000809@gmail.com> Message-ID: <3dbc6d1c0810040757u795d521ex4223ad37a4ab3900@mail.gmail.com> That would be a better solution in the long-run, but it is one which, unfortunately, I can't help you with. Robert 2008/10/4 Serge Aleynikov > Ah, I see, this makes sense. Meanwhile, I looked through the distribution > sources, ei, and jinterface and see that it's not that difficult to add some > monitoring support for non-Erlang nodes so that they can monitor Erlang > pids. I'll patch otp.net and later ei if I find time this or next > weekend. > > Serge > > > Robert Virding wrote: > >> It's not the io server which tries to setup a monitor, but the io module >> itself. These are two separate but cooperating entities. The io module >> monitors the io server to make sure that the call will not block if the >> process dies. The easiest way around this is to do the send/receive to the >> io serv yourself without a monitor. >> >> Robert >> >> 2008/10/4 Serge Aleynikov >> >> One other "nasty" feature is that any attempt to make an RPC call of >>> io:format/2 from a Java/.NET node fails with badarg, because io server >>> tries to set up a monitor to the remote pid and fails miserably... >>> >>> Actually I see what's missing in Java/OTP.NET implementation. These >>> features are documented here: >>> http://www.erlang.org/doc/apps/erts/erl_dist_protocol.html#9.7 >>> >>> Serge >>> >>> >>> >>> Paul Guyot wrote: >>> >>>> Date: Sat, 04 Oct 2008 01:32:55 -0400 >>>>> From: Serge Aleynikov >>>>> Subject: Re: [erlang-questions] jinterface (was: otp.net) >>>>> >>>>> I tried a similar test using jinterface to see if it's possible to >>>>> monitor processes running on a Java node and ran into the same failure. >>>>> >>>>> Can anyone explain what's wrong? >>>>> >>>>> (server@REDACTED)10> {test, client@REDACTED} ! {self(), hello}. >>>>> {<0.45.0>,hello} >>>>> (server@REDACTED)11> f(), {Pid, _} = receive M -> M end. >>>>> {<5979.1.0>,hello} >>>>> (server@REDACTED)12> erlang:monitor(process, Pid). >>>>> ** exception error: bad argument >>>>> in function erlang:monitor/2 >>>>> called as erlang:monitor(process,<5979.1.0>) >>>>> >>>> I've seen a comment in stdlib/gen.erl, at line 196, that suggests that >>>> Java and C nodes are featureweak, and processes in such nodes cannot be >>>> monitored. Instead, you have to monitor the whole node with >>>> monitor_node/2. This makes sense because the OTP ei (C library) or >>>> jinterface do not monitor "processes". Indeed, there is only one pid per >>>> node, which is the node's pseudo-pid (even if technically, each >>>> connection can receive messages). I guess you can draw from the code in >>>> gen.erl if you need to monitor either an erlang process or your java >>>> process, or just monitor the node if you only need to monitor java >>>> processes. >>>> >>>> Regards, >>>> >>>> Paul >>>> >>>> >>>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://www.erlang.org/mailman/listinfo/erlang-questions >>> >>> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dawsdesign@REDACTED Sat Oct 4 17:21:36 2008 From: dawsdesign@REDACTED (Matt Williamson) Date: Sat, 4 Oct 2008 11:21:36 -0400 Subject: [erlang-questions] OTP.NET Error In-Reply-To: <48E6D720.1080404@gmail.com> References: <48E6D720.1080404@gmail.com> Message-ID: Yep, that did it. ???????! On Fri, Oct 3, 2008 at 10:38 PM, Serge Aleynikov wrote: > I took a quick look at your code and see that you are doing this on every > button click which is wrong: > > OtpSelf self = new OtpSelf("client@REDACTED", "abc123"); > OtpPeer server = new OtpPeer("server@REDACTED"); > OtpConnection connection = server.connect(self); > > Move that to form initialization function, and try again. I guess what's > going on is that OtpAbstractNode doesn't implement proper destruction and > freeing resources (the socket connection), and as a result on every button > click you are trying to set up more than one connection with the Erlang > server node, which is not allowed, so the server drops the second and > following connection attempts. > > Serge > > > Matt Williamson wrote: > >> I'm trying out a simple OTP.NET test and it works great for the first >> call, >> but any subsequent calls result in the following exception: >> System.IO.IOException was unhandled >> Message="Peer replied with status 'alive' instead of 'ok'" >> Source="Otp" >> StackTrace: >> at Otp.AbstractConnection.recvStatus() in C:\Documents and >> Settings\Administrator\Desktop\jungerl\lib\otp.net >> \Otp\AbstractConnection.cs:line >> 1455 >> at Otp.AbstractConnection.doConnect(Int32 port) in C:\Documents and >> Settings\Administrator\Desktop\jungerl\lib\otp.net >> \Otp\AbstractConnection.cs:line >> 1018 >> at Otp.AbstractConnection..ctor(OtpLocalNode self, OtpPeer other) in >> C:\Documents and >> Settings\Administrator\Desktop\jungerl\lib\otp.net >> \Otp\AbstractConnection.cs:line >> 226 >> at Otp.OtpConnection..ctor(OtpSelf self, OtpPeer other) in >> C:\Documents and >> Settings\Administrator\Desktop\jungerl\lib\otp.net >> \Otp\OtpConnection.cs:line >> 84 >> at Otp.OtpPeer.connect(OtpSelf self) in C:\Documents and >> Settings\Administrator\Desktop\jungerl\lib\otp.net\Otp\OtpPeer.cs:line 67 >> at ErlTestClient.Form1.button1_Click(Object sender, EventArgs e) in >> C:\Documents and Settings\Administrator\My >> Documents\Projects\ErlTestClient\ErlTestClient\Form1.cs:line 25 >> at System.Windows.Forms.Control.OnClick(EventArgs e) >> at System.Windows.Forms.Button.OnClick(EventArgs e) >> at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) >> at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons >> button, Int32 clicks) >> at System.Windows.Forms.Control.WndProc(Message& m) >> at System.Windows.Forms.ButtonBase.WndProc(Message& m) >> at System.Windows.Forms.Button.WndProc(Message& m) >> at >> System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) >> at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& >> m) >> at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, >> Int32 msg, IntPtr wparam, IntPtr lparam) >> at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& >> msg) >> at >> >> System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 >> dwComponentID, Int32 reason, Int32 pvLoopData) >> at >> System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 >> reason, ApplicationContext context) >> at >> System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 >> reason, >> ApplicationContext context) >> at System.Windows.Forms.Application.Run(Form mainForm) >> at ErlTestClient.Program.Main() in C:\Documents and >> Settings\Administrator\My >> Documents\Projects\ErlTestClient\ErlTestClient\Program.cs:line 17 >> at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] >> args) >> at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence >> assemblySecurity, String[] args) >> at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() >> at System.Threading.ThreadHelper.ThreadStart_Context(Object state) >> at System.Threading.ExecutionContext.Run(ExecutionContext >> executionContext, ContextCallback callback, Object state) >> at System.Threading.ThreadHelper.ThreadStart() >> >> >> You can view my source at http://paste.lisp.org/display/67861 and >> http://paste.lisp.org/display/67862 >> >> Erlang is v5.6.3 on windows and I'm running VS2005. >> >> Please help :) >> >> >> >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From greg.burri@REDACTED Sat Oct 4 18:19:53 2008 From: greg.burri@REDACTED (Greg Burri) Date: Sat, 4 Oct 2008 18:19:53 +0200 Subject: [erlang-questions] Get a range of tuples from a Mnesia table Message-ID: <60ed8a460810040919qcf9dd37m994bbf6932f18cc0@mail.gmail.com> Hi, I want to retrieve N tuple with an offset O from the end of a table. N and O are integer(). I consider that the acces is based on an ordered table. Here is an example, I have such tuples in my table t : [{t, 1, _}, {t, 2, _}, {t, 3, _}, {t, 4, _}, {t, 5, _}, {t, 6, _}, {t, 7, _}] For N=2 and O=3 the result will be : [{t, 4, _}, {t, 5, _}] For now I have to use an ordered_set table and the functions mnesia:last/1 and mnesia:prev/2, it works but the complexity is O(O). If I have to get some tuple from the middle of the table it will take long time. Is there an another solution than mine ? Second question : How change the type of a table from set to ordered_set on an existing table ? /Greg Burri -------------- next part -------------- An HTML attachment was scrubbed... URL: From vladdu55@REDACTED Sat Oct 4 20:02:21 2008 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Sat, 4 Oct 2008 20:02:21 +0200 Subject: [erlang-questions] jinterface In-Reply-To: <48E7730B.3090506@gmail.com> References: <6C2A5378-5BDE-4FF9-B2AF-790D1F78330B@kallisys.net> <48E7730B.3090506@gmail.com> Message-ID: <95be1d3b0810041102r5fbfd2f6t5e54c2551926e226@mail.gmail.com> On Sat, Oct 4, 2008 at 15:43, Serge Aleynikov wrote: > Actually I see what's missing in Java/OTP.NET implementation. These > features are documented here: > http://www.erlang.org/doc/apps/erts/erl_dist_protocol.html#9.7 Even if those features were implemented, the Java VM is still not the BEAM VM, so it wouldn't be te same anyway. The impedance mismatch between the two runtime models is too large to integrate them seamlessly. > Actually, my overall goal was to establish the reverse - monitor an Erlang process > from a .NET client (or java), where the client implements a UI application that > establishes subscription with a process for receiving events of some sort, and > tries to reestablish subscription if it detects that the remote process died. Then you are in luck, because it can be done! Start a process that will do the monitoring and let it forward the messages to the Java side. This proxying technique can be applied in many other contexts, too. For example, for the io:format problem, you can start a io server that works as a proxy for the missing one on the Java side. But you may find soon that you will prefer to move more and more functionality on the Erlang side and use Java just as a presentation layer. best regards, Vlad From erlang-questions_efine@REDACTED Sat Oct 4 20:11:06 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Sat, 4 Oct 2008 14:11:06 -0400 Subject: [erlang-questions] Get a range of tuples from a Mnesia table In-Reply-To: <60ed8a460810040919qcf9dd37m994bbf6932f18cc0@mail.gmail.com> References: <60ed8a460810040919qcf9dd37m994bbf6932f18cc0@mail.gmail.com> Message-ID: <6c2563b20810041111t401ebb0fh5482d383438f0b8b@mail.gmail.com> Looking through the docs, I see that if you are using an mnesia table that is ram_copies or disc_copies, you can do certain fast operations on the associated ets table. One such operation (which is recommended only for debugging, but what the heck) is ets:slot(Tab, I), which returns the I'th record in the table. So maybe you could find a way to do that on the ETS table that Mnesia is using, perhaps via the mnesia:ets() function. I have never tried this so it's just a guess. This is also kind of a hack but other than reading through the mnesia code, I can't locate something better. Maybe one of the real Mnesia gurus will have an idea. 2008/10/4 Greg Burri > Hi, > I want to retrieve N tuple with an offset O from the end of a table. N and > O are integer(). I consider that the acces is based on an ordered table. > > Here is an example, I have such tuples in my table t : > [{t, 1, _}, > {t, 2, _}, > {t, 3, _}, > {t, 4, _}, > {t, 5, _}, > {t, 6, _}, > {t, 7, _}] > > For N=2 and O=3 the result will be : > [{t, 4, _}, {t, 5, _}] > > For now I have to use an ordered_set table and the functions mnesia:last/1 > and mnesia:prev/2, it works but the complexity is O(O). If I have to get > some tuple from the middle of the table it will take long time. > Is there an another solution than mine ? > > Second question : How change the type of a table from set to ordered_set on > an existing table ? > > > /Greg Burri > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rvirding@REDACTED Sat Oct 4 20:15:22 2008 From: rvirding@REDACTED (Robert Virding) Date: Sat, 4 Oct 2008 20:15:22 +0200 Subject: [erlang-questions] extending the scanner and parser In-Reply-To: <95be1d3b0810031126t5fb7b8b9x48bb75c3895a330e@mail.gmail.com> References: <95be1d3b0810030413p52bc5b58uf22c6790d64f9f35@mail.gmail.com> <20081003151527.GA28655@myrtle.kent.ac.uk> <95be1d3b0810031126t5fb7b8b9x48bb75c3895a330e@mail.gmail.com> Message-ID: <3dbc6d1c0810041115p571160fft458be1a867ff6cf2@mail.gmail.com> Another solution which may help you is to use leex for generating the scanner. It gives you much more freedom in deciding what to return, so you could return both the value and/or the chars if you wish. However, I don't think it will give all the data you want, you can the line number, characters and length of each token. If you want to use yecc for generating the parser, which really does simplify matters, you have to a little circumspect because it only accepts tokens in the form {Type,Line} or {Type,Line,Value}. It does place any restrictions on the vaule. Robert 2008/10/3 Vlad Dumitrescu > On Fri, Oct 3, 2008 at 18:18, Kenneth Lundin > wrote: > > It is in our plans to have that support in our standard scanner in some > way. > > Can not promise when but hopefully next year some time. > > That's wonderful to know! > > I suppose that it wouldn't hurt if we (the tool makers) would start > right away to tinker with it so that when you're ready you will have > something almost ready to work with, would it? > > best regards, > Vlad > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From vladdu55@REDACTED Sat Oct 4 20:27:56 2008 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Sat, 4 Oct 2008 20:27:56 +0200 Subject: [erlang-questions] extending the scanner and parser In-Reply-To: <3dbc6d1c0810041115p571160fft458be1a867ff6cf2@mail.gmail.com> References: <95be1d3b0810030413p52bc5b58uf22c6790d64f9f35@mail.gmail.com> <20081003151527.GA28655@myrtle.kent.ac.uk> <95be1d3b0810031126t5fb7b8b9x48bb75c3895a330e@mail.gmail.com> <3dbc6d1c0810041115p571160fft458be1a867ff6cf2@mail.gmail.com> Message-ID: <95be1d3b0810041127o3d733f09l5182c0499ee57daa@mail.gmail.com> On Sat, Oct 4, 2008 at 20:15, Robert Virding wrote: > Another solution which may help you is to use leex for generating the > scanner. It gives you much more freedom in deciding what to return, so you > could return both the value and/or the chars if you wish. However, I don't > think it will give all the data you want, you can the line number, > characters and length of each token. > > If you want to use yecc for generating the parser, which really does > simplify matters, you have to a little circumspect because it only accepts > tokens in the form {Type,Line} or {Type,Line,Value}. It does place any > restrictions on the vaule. Thank you for the advice! I considered that, but I'd rather use the standard lexer and parser, to be sure the results are exactly the same as they should (except the presentation). Actually, now that I think of it, I did try it, but got trouble with the more esoteric parts (like multi-line strings) and abandoned that path. Maintenance would still be a headache. best regards, Vlad From cktgatb@REDACTED Sun Oct 5 05:16:23 2008 From: cktgatb@REDACTED (deepblue_other) Date: Sat, 4 Oct 2008 20:16:23 -0700 (PDT) Subject: [erlang-questions] tcp sockets confusion Message-ID: <19803972.post@talk.nabble.com> hello everyone Im building a system with a Flash front-end and an Erlang back-end and have some confusion in a case where there is a single socket on the back-end per user (per single socket on the front-end). I want to have multiple independent objects on the front-end send messages to the back-end, but am not sure how the simultaneous transmission would be handled. This probably stems from my somewhat clowdly understanding of TCP. Say there are 3 objects that initiate a send() method on the front-end (almost at the same time) and send a semi large message each to the back-end. Each message would be ID'd by the front-end so that when received back it can be routed to the appropriate callback. Is this possible? since the packets are being assembled in the {tcp, Socket, Data} pattern match, peace by peace, would the correct peaces of the individual messages be stiched together? (doesnt seem like they would). if that wont work then I would just have the serialize the sending/receiving, which is not too horrible... thanks -- View this message in context: http://www.nabble.com/tcp-sockets-confusion-tp19803972p19803972.html Sent from the Erlang Questions mailing list archive at Nabble.com. From cktgatb@REDACTED Sun Oct 5 05:19:04 2008 From: cktgatb@REDACTED (deepblue_other) Date: Sat, 4 Oct 2008 20:19:04 -0700 (PDT) Subject: [erlang-questions] re cursive fun() Message-ID: <19820386.post@talk.nabble.com> hello I have this going on FunVar = fun() -> ... FunVar() end. so the compiler is complaining that FunVar is unbound at the place where its being used inside fun(); this makes sense, however Im wondering how to make this into a recursive function since there's no name to reference the function with. thanks -- View this message in context: http://www.nabble.com/recursive-fun%28%29-tp19820386p19820386.html Sent from the Erlang Questions mailing list archive at Nabble.com. From bgustavsson@REDACTED Sun Oct 5 08:32:38 2008 From: bgustavsson@REDACTED (Bjorn Gustavsson) Date: Sun, 5 Oct 2008 08:32:38 +0200 Subject: [erlang-questions] Unused inline functions compiler warning In-Reply-To: <6c2563b20810031202u6dcf65bdqa88d2c09c193376b@mail.gmail.com> References: <6c2563b20810031202u6dcf65bdqa88d2c09c193376b@mail.gmail.com> Message-ID: <6672d0160810042332s4d7e8c90kd3cb44d136182ecd@mail.gmail.com> 2008/10/3 Edwin Fine > Does this imply that every inline function in a .hrl file will be inserted > into every single .erl file that includes it, even if it is unused? If not, > then why have a compiler warning? > No, the compiler will always remove unused local functions. The compiler always warns for unused functions, to help you get rid of old functions that are no longer used. I suppose it could be reasonable if the compiler suppressed the warning for functions that are defined in .hrl files (in the same way that it only warns for unused records in .erl files, never in .hrl files). If there are no strong objections either here or in the Erlang/OTP group, we might change that for R12B-5 release. > > Is there any way to overcome this without reverting back to using macros? > > Can I get rid of just those warnings? Is there a way to suppress warnings > for individual functions, like a -compile({suppress, [{wunused, > [{log_info,3},{log_dbg,3}]}]})? > > There is currently no way to suppress individual warnings. We have been thinking about adding such a mechanism. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB -------------- next part -------------- An HTML attachment was scrubbed... URL: From bgustavsson@REDACTED Sun Oct 5 08:45:16 2008 From: bgustavsson@REDACTED (Bjorn Gustavsson) Date: Sun, 5 Oct 2008 08:45:16 +0200 Subject: [erlang-questions] [bug] beam_asm failure on invalid binary match In-Reply-To: References: Message-ID: <6672d0160810042345m6c72a3a2r5087f816492e3121@mail.gmail.com> 2008/10/3 Will > Hello, > > I mistakenly set the size specifier in a binary match to zero and it caused > beam_asm to crash. > This is Erlang/OTP R12B-4. > Thanks! We will fix that bug in R12B-5. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB -------------- next part -------------- An HTML attachment was scrubbed... URL: From bgustavsson@REDACTED Sun Oct 5 08:43:39 2008 From: bgustavsson@REDACTED (Bjorn Gustavsson) Date: Sun, 5 Oct 2008 08:43:39 +0200 Subject: [erlang-questions] Unused inline functions compiler warning In-Reply-To: <6672d0160810042332s4d7e8c90kd3cb44d136182ecd@mail.gmail.com> References: <6c2563b20810031202u6dcf65bdqa88d2c09c193376b@mail.gmail.com> <6672d0160810042332s4d7e8c90kd3cb44d136182ecd@mail.gmail.com> Message-ID: <6672d0160810042343k43a304b5i888a78944c87e008@mail.gmail.com> On Sun, Oct 5, 2008 at 8:32 AM, Bjorn Gustavsson wrote: > 2008/10/3 Edwin Fine >> >> >> Can I get rid of just those warnings? Is there a way to suppress warnings >> for individual functions, like a -compile({suppress, [{wunused, >> [{log_info,3},{log_dbg,3}]}]})? >> >> There is currently no way to suppress individual warnings. We have been > thinking about adding such a mechanism. > Unfortunately, I didn't check the compiler documentation before answering. As you wrote in another email, this particular warning *can* be suppressed. There are still other warnings that cannot be suppressed, unfortunately, and there is an item on my to-do list to fix that. /Bjorn > > -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB -------------- next part -------------- An HTML attachment was scrubbed... URL: From erlang-questions_efine@REDACTED Sun Oct 5 11:13:41 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Sun, 5 Oct 2008 05:13:41 -0400 Subject: [erlang-questions] re cursive fun() In-Reply-To: <19820386.post@talk.nabble.com> References: <19820386.post@talk.nabble.com> Message-ID: <6c2563b20810050213r7ea28fdbp9b2205332b3662a2@mail.gmail.com> I'm assuming that you want to do this in the shell, otherwise it would be easier just to write the function in the usual way, e.g. myfun() -> blah, blah, myfun(). To create a fun that calls itself, you must realize that you are creating an unnamed function. When you write fun(X) -> X * 2 end. this is compiled to a Fun data type, e.g. #Fun. Since the function does not have a name, it cannot refer to itself. When you write FunVar = fun(X) -> X * 2 end, the function is bound to the variable FunVar. Because the binding takes place *after* the fun is created, the fun cannot refer to the variable FunVar within its definition. So how is it done? You have to pass the variable to the function so that it "knows" what to call: FunVar = fun(MySelf) -> ... MySelf(). Then when you call it, you call FunVar(FunVar). Looks strange but it works. Example: Writing a simple generate and fold function using only a fun() variable. 9> GenFold = fun(0, Acc, _) -> Acc; (X, Acc, Fun) -> Fun(X - 1, [X|Acc], Fun) end. #Fun 10> GenFold(10, [], GenFold). [1,2,3,4,5,6,7,8,9,10] 11> Or a for loop: 22> For = fun(Max, Max, ExecFun, _) -> ok; (N, Max, ExecFun, Next) -> ExecFun(N), Next(N + 1, Max, ExecFun, Next) end. #Fun 23> For(0,10,fun(I) -> io:format("~B ", [I]) end, For). 0 1 2 3 4 5 6 7 8 9 ok 24> Stuff like this is described in Joe Armstrong's Erlang book. Hope this helps. On Sat, Oct 4, 2008 at 11:19 PM, deepblue_other wrote: > > hello > I have this going on > > FunVar = > fun() -> > ... > FunVar() > end. > > so the compiler is complaining that FunVar is unbound at the place where > its > being used inside fun(); this makes sense, however Im wondering how to make > this into a recursive function since there's no name to reference the > function with. > > thanks > -- > View this message in context: > http://www.nabble.com/recursive-fun%28%29-tp19820386p19820386.html > Sent from the Erlang Questions mailing list archive at Nabble.com. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From richardc@REDACTED Sun Oct 5 11:30:22 2008 From: richardc@REDACTED (Richard Carlsson) Date: Sun, 05 Oct 2008 11:30:22 +0200 Subject: [erlang-questions] re cursive fun() In-Reply-To: <19820386.post@talk.nabble.com> References: <19820386.post@talk.nabble.com> Message-ID: <48E8892E.5040204@it.uu.se> deepblue_other wrote: > hello > I have this going on > > FunVar = > fun() -> > ... > FunVar() > end. > > so the compiler is complaining that FunVar is unbound at the place where its > being used inside fun(); this makes sense, however Im wondering how to make > this into a recursive function since there's no name to reference the > function with. You have to make it keep "itself" around as an additional parameter, so that you can first create it and then hand it the self-reference: FunVar = fun(Myself) -> ... Myself(Myself) end then call it like this: FunVar(FunVar). If you want the result to be a function of arity 0, as in your example, then replace the last line with FinalFunVar = fun () -> FunVar(FunVar) end /Richard -- "Having users is like optimization: the wise course is to delay it." -- Paul Graham From exta7@REDACTED Sun Oct 5 11:58:34 2008 From: exta7@REDACTED (Zvi) Date: Sun, 5 Oct 2008 02:58:34 -0700 (PDT) Subject: [erlang-questions] Hungarian notation for Erlang / ETL In-Reply-To: <14710892.post@talk.nabble.com> References: <14701912.post@talk.nabble.com> <14710892.post@talk.nabble.com> Message-ID: <19822958.post@talk.nabble.com> Nick Gerakines blogging about need for "Standard Collection behaviour" in Erlang http://blog.socklabs.com/2008/10/erlang_woes/ Zvi Zvi wrote: > > 1. I also hate Hungarian notation and doesn't use it even in C++ (except > m_ prefix), but I still need a solution for current version of Elrang > (does it mean that I need always use Dyalizer?). > > 2. I wasn't talking about implementing object using Erlang processes. I > talking about much simpler and functional solution, like providing > behaviour, like: > > -module(collection). > -export([behaviour_info/1]). > > behaviour_info(callbacks) -> > [{new,0}, > {length,1}, > {to_string,1}, > {from_string,1}, > {map,2}, > {foldl,2}, > {foldr,2}, > {sort,1}, > %% etc... > ]; > behaviour_info(_Other) -> > undefined. > > then each ADT will implement this bahaviour, like: > > -module(queue). > -behaviour(collection). > > %% ... > > -module(set). > -behaviour(collection). > > %% ... > > -module(stack). > -behaviour(collection). > > %% ... > > > etc. > > Zvi > > > David Holz wrote: >> >> >> From: exta7@REDACTED >>> Is there some kind of Hungarian notation for Erlang? i.e. prefix or >>> postfix >>> naming convention. >> >> Hungarian notation is the absolute wrong solution to type confusion (or >> any other problem). The new type annotations will eventually provide >> optional type information available to both the compiler and IDEs for >> keeping things straight. It won't be long before it's an official part >> of the release; the annotation handling is in there already, just not >> documented. >> >> I would, though, also like to see some sort of actual OO-ish interface to >> a block of data that can dispatch to the proper behavior for that >> specific data term. Java's collections and IO streams, while verbose, >> are incredibly usable implementations of that idea at their core. With >> Erlang, however, it might mean that your data item is held by its own >> process, with a well-defined messaging interface, and might want some >> sort of automatic deferring to a parent process/module for unhandled >> calls or messages in the receive loop. >> >> _________________________________________________________________ >> Share life as it happens with the new Windows Live. >> http://www.windowslive.com/share.html?ocid=TXT_TAGHM_Wave2_sharelife_012008 >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> >> > > -- View this message in context: http://www.nabble.com/Hungarian-notation-for-Erlang---ETL-tp14701912p19822958.html Sent from the Erlang Questions mailing list archive at Nabble.com. From jan@REDACTED Sun Oct 5 13:02:20 2008 From: jan@REDACTED (Jan Lehnardt) Date: Sun, 5 Oct 2008 13:02:20 +0200 Subject: [erlang-questions] Introduction to Erlang at Erlang User Group Berlin Message-ID: Dear Erlang Folks in Berlin and thereabouts, This month's Erlang User Group[1] meeting will sport an "Introduction to Erlang" by Florian Ebeling. Florian stepped up to satisfy frequent request by newcomers to give a introductory presentation about Erlang. Thanks Florian! This event is open to everyone, not just members of the Erlang User. Please give us a shout on the Google Group [1] if you are planning to come. We meet at Z-Bar[2], Bergstr.2, Berlin Mitte[3], 20:00 on October 8th, 2008, listen to Florian's presentation and then have a few beers. Please spread the word, thank you! Cheers, Jan -- [1] http://groups.google.com/group/erlang-berlin [2] http://z-bar.de/ [3] http://maps.google.com/maps?f=q&hl=en&geocode=&q=z-bar&sll=52.491349,13.427872&sspn=0.006637,0.013733&ie=UTF8&ll=52.531887,13.401947&spn=0.053048,0.109863&z=13 From bbmaj7@REDACTED Sun Oct 5 12:12:16 2008 From: bbmaj7@REDACTED (Richard Andrews) Date: Sun, 5 Oct 2008 03:12:16 -0700 (PDT) Subject: [erlang-questions] re cursive fun() Message-ID: <58013.1460.qm@web65508.mail.ac4.yahoo.com> > FunVar = > fun() -> > ... > FunVar() > end. > > so the compiler is complaining that FunVar is unbound at the place where its > being used inside fun(); this makes sense, however Im wondering how to make > this into a recursive function since there's no name to reference the > function with. Maybe have the fun call a real (recursive) function. eg. F(A) -> ... F(B). Caller(Data) -> ... FunVar = fun(A) -> F(A) end, ... foo:use_fun(FunVar, Data). -- Rich Make the switch to the world's best email. Get Yahoo!7 Mail! http://au.yahoo.com/y7mail From 0x6e6562@REDACTED Sun Oct 5 13:20:59 2008 From: 0x6e6562@REDACTED (Ben Hood) Date: Sun, 5 Oct 2008 12:20:59 +0100 Subject: [erlang-questions] Some mnesia oddity In-Reply-To: <48B7DB67.7010608@erix.ericsson.se> References: <48B7DB67.7010608@erix.ericsson.se> Message-ID: <269388e30810050420w38e3cc77h23dea901c39d6cc1@mail.gmail.com> Hi, I know this is an old thread but I was wondering where the behaviour I am seeing is in any way related to passing in a pattern to mnesia:delete_object/1. On Fri, Aug 29, 2008 at 12:20 PM, Dan Gudmundsson wrote: >> We found a strange mnesia behavior here... >> >> Some mnesia:write operations after a mnesia:delete_object seem to >> not have the expected result when executed in the same transaction. >> >> See attached example file: >> 1 - We fill a test_table >> 2 - In the same transaction, we read all records, delete them, and >> write them back (do not ask why :)) >> 3 - Surprise! Only a subset of them can be read afterwards >> >> Same result in R11 and R12. >> >> It works if the delete_object and write operations are in separate >> transactions... But who knows what can happen between them... The code I am using (attached below) is similar to the above scenario. Basically what I want to know is if there is a way to delete records from a table and then re-read the table in the same transaction, or whether this must be in separate transactions. My use case is a densely populated table that I want to 1. Selectively delete some records for; 2. Conditionally delete records from a different table if they no longer have any references in the first table. So my approach could be characterized by a delete and sweep action. Of course I could implement this functionality manually by re-reading the table and filtering out any results that I know will get deleted when the transaction commits. But if I could get mnesia to do this, it would be more elegant. Also, I could do this in two transactions and re-arrange the code so to introduce something idempotent to get around the non-atomicity. But if this could be solved using mnesia, that would be cool :-) Thx, Ben ---snip--- -module(sync_test). -compile(export_all). -record(outer,{inner, const = const}). -record(inner,{a,b,c}). init() -> mnesia:start(), mnesia:delete_table(outer), {atomic,ok} = mnesia:create_table(outer, [{type,ordered_set}, {attributes, record_info(fields, outer)}]), ok. insert() -> Record = #outer{inner = #inner{a = 1, b = 2, c = now()}}, mnesia:transaction(fun() -> mnesia:write(Record) end). one_tx() -> Record = #outer{inner = #inner{a = 1, b = 2, c = '_'}}, mnesia:sync_transaction( fun() -> mnesia:delete_object(Record), io:format("~p~n",[mnesia:match_object(Record)]) end). two_tx() -> Record = #outer{inner = #inner{a = 1, b = 2, c = '_'}}, mnesia:sync_transaction( fun() -> mnesia:delete_object(Record) end), mnesia:sync_transaction( fun() -> io:format("~p~n",[mnesia:match_object(Record)]) end). From ciprian.craciun@REDACTED Sun Oct 5 16:11:57 2008 From: ciprian.craciun@REDACTED (Ciprian Dorin Craciun) Date: Sun, 5 Oct 2008 17:11:57 +0300 Subject: [erlang-questions] re cursive fun() In-Reply-To: <48E8892E.5040204@it.uu.se> References: <19820386.post@talk.nabble.com> <48E8892E.5040204@it.uu.se> Message-ID: <8e04b5820810050711s5d4ef554v50131c481fa19e85@mail.gmail.com> On Sun, Oct 5, 2008 at 12:30 PM, Richard Carlsson wrote: > deepblue_other wrote: >> hello >> I have this going on >> >> FunVar = >> fun() -> >> ... >> FunVar() >> end. >> >> so the compiler is complaining that FunVar is unbound at the place where its >> being used inside fun(); this makes sense, however Im wondering how to make >> this into a recursive function since there's no name to reference the >> function with. > > You have to make it keep "itself" around as an additional parameter, > so that you can first create it and then hand it the self-reference: > > FunVar = > fun(Myself) -> > ... > Myself(Myself) > end > > then call it like this: > > FunVar(FunVar). > > If you want the result to be a function of arity 0, > as in your example, then replace the last line with > > FinalFunVar = fun () -> FunVar(FunVar) end > > /Richard > > -- > "Having users is like optimization: the wise course is to delay it." > -- Paul Graham About this subject, I would ask if isn't it better / easier / clearer to add a special function name / keyword that would refer to the function itself. This would also have a few advantages: * first it will solve the recursivity problem described above; * (maybe) it could also improve efficiency (because you know exactly what function you're calling, without any lookup); (this is just an assumption, maybe inside the beam file the lookup does not exist); (certainly it is more efficient than the proposed solution --- sending the function as an argument;) * it will assist in refactoring --- changing a recursive function name will have no impact on it's code; * it could clearly mark the fact that the function calls itself. As for disadvantages I really do not see any. (Except of having a new keyword / special function.) So any comments? Ciprian. P.S.: I think this solution could be equally applied to all languages (mainly Lisp like). From erlang-questions_efine@REDACTED Sun Oct 5 17:03:49 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Sun, 5 Oct 2008 11:03:49 -0400 Subject: [erlang-questions] re cursive fun() In-Reply-To: <6c2563b20810050213r7ea28fdbp9b2205332b3662a2@mail.gmail.com> References: <19820386.post@talk.nabble.com> <6c2563b20810050213r7ea28fdbp9b2205332b3662a2@mail.gmail.com> Message-ID: <6c2563b20810050803w3c25c122yd878f14a6b11cbb3@mail.gmail.com> Just noticed a mistake. FunVar = fun(MySelf) -> ... MySelf(). should have been FunVar = fun(MySelf) -> ... MySelf(MySelf). On Sun, Oct 5, 2008 at 5:13 AM, Edwin Fine wrote: > I'm assuming that you want to do this in the shell, otherwise it would be > easier just to write the function in the usual way, e.g. > > myfun() -> > blah, blah, > myfun(). > > To create a fun that calls itself, you must realize that you are creating > an unnamed function. When you write > > fun(X) -> X * 2 end. > > this is compiled to a Fun data type, e.g. #Fun. > > Since the function does not have a name, it cannot refer to itself. > > When you write FunVar = fun(X) -> X * 2 end, the function is bound to the > variable FunVar. Because the binding takes place *after* the fun is created, > the fun cannot refer to the variable FunVar within its definition. > > So how is it done? You have to pass the variable to the function so that it > "knows" what to call: > > FunVar = > fun(MySelf) -> > ... > MySelf(). > > Then when you call it, you call FunVar(FunVar). Looks strange but it works. > > Example: Writing a simple generate and fold function using only a fun() > variable. > > 9> GenFold = > fun(0, Acc, _) -> > Acc; > (X, Acc, Fun) -> > Fun(X - 1, [X|Acc], Fun) > end. > #Fun > 10> GenFold(10, [], > GenFold). > [1,2,3,4,5,6,7,8,9,10] > 11> > > Or a for loop: > > 22> For = > fun(Max, Max, ExecFun, _) -> > ok; > (N, Max, ExecFun, Next) -> > ExecFun(N), > Next(N + 1, Max, ExecFun, Next) > end. > #Fun > 23> For(0,10,fun(I) -> io:format("~B ", [I]) end, > For). > > 0 1 2 3 4 5 6 7 8 9 ok > 24> > > Stuff like this is described in Joe Armstrong's Erlang book. > > Hope this helps. > > > On Sat, Oct 4, 2008 at 11:19 PM, deepblue_other wrote: > >> >> hello >> I have this going on >> >> FunVar = >> fun() -> >> ... >> FunVar() >> end. >> >> so the compiler is complaining that FunVar is unbound at the place where >> its >> being used inside fun(); this makes sense, however Im wondering how to >> make >> this into a recursive function since there's no name to reference the >> function with. >> >> thanks >> -- >> View this message in context: >> http://www.nabble.com/recursive-fun%28%29-tp19820386p19820386.html >> Sent from the Erlang Questions mailing list archive at Nabble.com. >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From cktgatb@REDACTED Sun Oct 5 17:12:21 2008 From: cktgatb@REDACTED (deepblue_other) Date: Sun, 5 Oct 2008 08:12:21 -0700 (PDT) Subject: [erlang-questions] re cursive fun() In-Reply-To: <6c2563b20810050213r7ea28fdbp9b2205332b3662a2@mail.gmail.com> References: <19820386.post@talk.nabble.com> <6c2563b20810050213r7ea28fdbp9b2205332b3662a2@mail.gmail.com> Message-ID: <19825467.post@talk.nabble.com> Edwin Fine-2 wrote: > > I'm assuming that you want to do this in the shell, otherwise it would be > easier just to write the function in the usual way, e.g. > > myfun() -> > blah, blah, > myfun(). > no shell is not the reason, I need a function that will only be called from within another function and I dont want to "pollute" the "module wide" space with another function, so Im putting in a nested one... I would prefer to declare a regular function, but as far as I know there are no nested functions in Erlang (regular named functions). Edwin Fine-2 wrote: > > To create a fun that calls itself, you must realize that you are creating > an > unnamed function. When you write > > fun(X) -> X * 2 end. > > this is compiled to a Fun data type, e.g. #Fun. > > Since the function does not have a name, it cannot refer to itself. > > When you write FunVar = fun(X) -> X * 2 end, the function is bound to the > variable FunVar. Because the binding takes place *after* the fun is > created, > the fun cannot refer to the variable FunVar within its definition. > > So how is it done? You have to pass the variable to the function so that > it > "knows" what to call: > > FunVar = > fun(MySelf) -> > ... > MySelf(). > > Then when you call it, you call FunVar(FunVar). Looks strange but it > works. > > Example: Writing a simple generate and fold function using only a fun() > variable. > > 9> GenFold = > fun(0, Acc, _) -> > Acc; > (X, Acc, Fun) -> > Fun(X - 1, [X|Acc], Fun) > end. > #Fun > 10> GenFold(10, [], > GenFold). > [1,2,3,4,5,6,7,8,9,10] > 11> > > Or a for loop: > > 22> For = > fun(Max, Max, ExecFun, _) -> > ok; > (N, Max, ExecFun, Next) -> > ExecFun(N), > Next(N + 1, Max, ExecFun, Next) > end. > #Fun > 23> For(0,10,fun(I) -> io:format("~B ", [I]) end, > For). > > 0 1 2 3 4 5 6 7 8 9 ok > 24> > > Stuff like this is described in Joe Armstrong's Erlang book. > > Hope this helps. > > On Sat, Oct 4, 2008 at 11:19 PM, deepblue_other wrote: > >> >> hello >> I have this going on >> >> FunVar = >> fun() -> >> ... >> FunVar() >> end. >> >> so the compiler is complaining that FunVar is unbound at the place where >> its >> being used inside fun(); this makes sense, however Im wondering how to >> make >> this into a recursive function since there's no name to reference the >> function with. >> >> thanks >> -- >> View this message in context: >> http://www.nabble.com/recursive-fun%28%29-tp19820386p19820386.html >> Sent from the Erlang Questions mailing list archive at Nabble.com. >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> >> > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > what you have described makes perfect sense thanks -- View this message in context: http://www.nabble.com/recursive-fun%28%29-tp19820386p19825467.html Sent from the Erlang Questions mailing list archive at Nabble.com. From exta7@REDACTED Sun Oct 5 17:38:31 2008 From: exta7@REDACTED (Zvi) Date: Sun, 5 Oct 2008 08:38:31 -0700 (PDT) Subject: [erlang-questions] re cursive fun() In-Reply-To: <19820386.post@talk.nabble.com> References: <19820386.post@talk.nabble.com> Message-ID: <19825781.post@talk.nabble.com> Otherwise, than passing the Fun as argument to itself, one can implement recursive functions, using code, like this: fact(0) -> 1; fact(N) when N>0 -> {M,F,_A} = element(2,process_info(self(),current_function)), N * {M,F}(N-1). But this doesn't work for funs, if there are was something like: Fact = fun(0) -> 1; (N) when N>0 -> Fun = element(2,process_info(self(),current_fun)), N * Fun(N-1). Zvi deepblue_other wrote: > > hello > I have this going on > > FunVar = > fun() -> > ... > FunVar() > end. > > so the compiler is complaining that FunVar is unbound at the place where > its being used inside fun(); this makes sense, however Im wondering how to > make this into a recursive function since there's no name to reference the > function with. > > thanks > -- View this message in context: http://www.nabble.com/recursive-fun%28%29-tp19820386p19825781.html Sent from the Erlang Questions mailing list archive at Nabble.com. From cktgatb@REDACTED Sun Oct 5 18:07:57 2008 From: cktgatb@REDACTED (deepblue_other) Date: Sun, 5 Oct 2008 09:07:57 -0700 (PDT) Subject: [erlang-questions] re cursive fun() In-Reply-To: <19825781.post@talk.nabble.com> References: <19820386.post@talk.nabble.com> <19825781.post@talk.nabble.com> Message-ID: <19826090.post@talk.nabble.com> so definitely no named nested functions? Zvi wrote: > > Otherwise, than passing the Fun as argument to itself, one can implement > recursive functions, using code, like this: > > fact(0) -> 1; > fact(N) when N>0 -> > {M,F,_A} = element(2,process_info(self(),current_function)), > N * {M,F}(N-1). > > But this doesn't work for funs, if there are was something like: > > Fact = fun(0) -> 1; > (N) when N>0 -> > Fun = element(2,process_info(self(),current_fun)), > N * Fun(N-1). > > Zvi > > > deepblue_other wrote: >> >> hello >> I have this going on >> >> FunVar = >> fun() -> >> ... >> FunVar() >> end. >> >> so the compiler is complaining that FunVar is unbound at the place where >> its being used inside fun(); this makes sense, however Im wondering how >> to make this into a recursive function since there's no name to reference >> the function with. >> >> thanks >> > > -- View this message in context: http://www.nabble.com/recursive-fun%28%29-tp19820386p19826090.html Sent from the Erlang Questions mailing list archive at Nabble.com. From cktgatb@REDACTED Sun Oct 5 18:07:08 2008 From: cktgatb@REDACTED (deepblue_other) Date: Sun, 5 Oct 2008 09:07:08 -0700 (PDT) Subject: [erlang-questions] tcp sockets - not clear Message-ID: <19826070.post@talk.nabble.com> hello everyone Im building a system with a Flash front-end and an Erlang back-end and have some confusion in a case where there is a single socket on the back-end per user (per single socket on the front-end). I want to have multiple independent objects on the front-end send messages to the back-end, but am not sure how the simultaneous transmission would be handled. This probably stems from my somewhat clowdly understanding of TCP. Say there are 3 objects that initiate a send() method on the front-end (almost at the same time) and send a semi large message each to the back-end. Each message would be ID'd by the front-end so that when received back it can be routed to the appropriate callback. Is this possible? since the packets are being assembled in the {tcp, Socket, Data} pattern match, peace by peace, would the correct peaces of the individual messages be stiched together? (doesnt seem like they would). if that wont work then I would just have the serialize the sending/receiving, which is not too horrible... thanks -- View this message in context: http://www.nabble.com/tcp-sockets---not-clear-tp19826070p19826070.html Sent from the Erlang Questions mailing list archive at Nabble.com. From saleyn@REDACTED Sun Oct 5 18:14:52 2008 From: saleyn@REDACTED (Serge Aleynikov) Date: Sun, 05 Oct 2008 12:14:52 -0400 Subject: [erlang-questions] jinterface In-Reply-To: <95be1d3b0810041102r5fbfd2f6t5e54c2551926e226@mail.gmail.com> References: <6C2A5378-5BDE-4FF9-B2AF-790D1F78330B@kallisys.net> <48E7730B.3090506@gmail.com> <95be1d3b0810041102r5fbfd2f6t5e54c2551926e226@mail.gmail.com> Message-ID: <48E8E7FC.9040405@gmail.com> While we are on the subject, I was looking at the hierarchy of classes in jinterface/otp.net and have some design questions. 1. OtpSelf and OtpNode inherit from OtpLocalNode. Only OtpNode implements OtpMbox support. Consequently OtpSelf can't create a mailbox and use its send/receive functions. It looks like it would make more sense if OtpSelf inherited from OtpNode, so that if would have access to all mbox / registerName / whereis goodies. 2. OtpCookedConnection and OtpConnection inherit from AbstractConnection, but only OtpConnection has sendRPC/receiveRPC and only OtpCookedConnection keeps track of established links. It would make more sense if OtpConnection inherited from OtpCookedConnection so that OtpNode can do sendRPC/receiveRPC calls and also be aware of link management offered by OtpCooked Connection. Perhaps I am missing something but it's not clear from this class hierarchy what the intent of the designer was... Serge Vlad Dumitrescu wrote: > On Sat, Oct 4, 2008 at 15:43, Serge Aleynikov wrote: >> Actually I see what's missing in Java/OTP.NET implementation. These >> features are documented here: >> http://www.erlang.org/doc/apps/erts/erl_dist_protocol.html#9.7 > > Even if those features were implemented, the Java VM is still not the > BEAM VM, so it wouldn't be te same anyway. The impedance mismatch > between the two runtime models is too large to integrate them > seamlessly. > >> Actually, my overall goal was to establish the reverse - monitor an Erlang process >> from a .NET client (or java), where the client implements a UI application that >> establishes subscription with a process for receiving events of some sort, and >> tries to reestablish subscription if it detects that the remote process died. > > Then you are in luck, because it can be done! Start a process that > will do the monitoring and let it forward the messages to the Java > side. This proxying technique can be applied in many other contexts, > too. For example, for the io:format problem, you can start a io server > that works as a proxy for the missing one on the Java side. But you > may find soon that you will prefer to move more and more functionality > on the Erlang side and use Java just as a presentation layer. > > best regards, > Vlad > From cktgatb@REDACTED Sun Oct 5 18:39:41 2008 From: cktgatb@REDACTED (deepblue_other) Date: Sun, 5 Oct 2008 09:39:41 -0700 (PDT) Subject: [erlang-questions] wierd "function not used" problem - code included Message-ID: <19826465.post@talk.nabble.com> Hello, its me again... so I've been having this problem for days, with the bellow code. Most of it is straight out of the "Programming Erlang" book from Joe Armstrong... however when Im compiling it its telling me that the function data_process/1 is not being used, gives me a warning, but then still compiles. however when Im sending data from a client side via TCP ofcourse it exits on me because there's nothing to process the message... I HAVE NO IDEA WHAT'S WRONG WITH IT. I've read up on all the spawn_link() definitions and as far as I can tell Im using it correctly... the PiD that spawn_link() returns is being returned so it executes successfully. please help out, its stalling my project progress. thanks -module(tcp_manager). %API-------------------------------------------- -export([start/1]). %----------------------------------------------- start(Port) -> {ok, ListeningSocket} = gen_tcp:listen( Port, [ binary, %receive data in binary form {packet , 0}, {reuseaddr, true}, %hybrid - active for only one message %it auto-receives one message after which it blocks %has to be set to active-once again to receive the next message {active , once} ] ), accept_connection(ListeningSocket). %----------------------------------------------- accept_connection(ListeningSocket) -> io:format("waiting to accept~n"), {ok, Socket} = gen_tcp:accept(ListeningSocket), io:format("Socket is:~p~n", [Socket]), %----------------------------------------------- Listen_for_errors = fun() -> io:format("listening started~n"), receive {'EXIT', Pid, Why} -> io:format("~p exited because:~p", [Pid,Why]); Other -> io:format("Other:~p~n", [Other]) end end, Listen_for_errors(), %----------------------------------------------- Handler_process = spawn_link(?MODULE, data_process, [Socket]), %,[]]), io:format("handlers process ID:~p", [Handler_process]). accept_connection(ListeningSocket). %----------------------------------------------- data_process( Socket, DataSoFar) -> io:format("responder_loop() entered~n"), receive {tcp, Socket, Data} -> %Source_ip = inet:peername(Socket), %io:format("*~p - data coming in:~p~n",[Source_ip,Data]), io:format("works - Data:~p~n", [Data]), %has to be done, since its an active-once socket inet:setopts( Socket, [{active,once}] ), data_process( Socket, %append the new binary fragment to what has been received so far [Data | DataSoFar] ); {tcp_closed, Socket} -> io:format("*client socket closed~n"); %reverse because data has been appended to the head of the list as it was coming in list_to_binary(lists:reverse(SoFar)); Other -> io:format("undefined message came in:~p", [Other]) end. %----------------------------------------------- -- View this message in context: http://www.nabble.com/wierd-%22function-not-used%22-problem---code-included-tp19826465p19826465.html Sent from the Erlang Questions mailing list archive at Nabble.com. From alpar@REDACTED Sun Oct 5 18:52:30 2008 From: alpar@REDACTED (=?ISO-8859-1?Q?Alp=E1r_J=FCttner?=) Date: Sun, 05 Oct 2008 17:52:30 +0100 Subject: [erlang-questions] re cursive fun() In-Reply-To: <19826090.post@talk.nabble.com> References: <19820386.post@talk.nabble.com> <19825781.post@talk.nabble.com> <19826090.post@talk.nabble.com> Message-ID: <1223225550.23038.25.camel@piko.site> You may do a trick like this: 1> Fact = fun(0) -> 1; (N) -> Fun=get(fact), N*Fun(N-1) end. #Fun 2> put(fact,Fact). undefined 3> Fact(5). 120 Regards, Alpar On Sun, 2008-10-05 at 09:07 -0700, deepblue_other wrote: > so definitely no named nested functions? > > Zvi wrote: > > > > Otherwise, than passing the Fun as argument to itself, one can implement > > recursive functions, using code, like this: > > > > fact(0) -> 1; > > fact(N) when N>0 -> > > {M,F,_A} = element(2,process_info(self(),current_function)), > > N * {M,F}(N-1). > > > > But this doesn't work for funs, if there are was something like: > > > > Fact = fun(0) -> 1; > > (N) when N>0 -> > > Fun = element(2,process_info(self(),current_fun)), > > N * Fun(N-1). > > > > Zvi > > > > > > deepblue_other wrote: > >> > >> hello > >> I have this going on > >> > >> FunVar = > >> fun() -> > >> ... > >> FunVar() > >> end. > >> > >> so the compiler is complaining that FunVar is unbound at the place where > >> its being used inside fun(); this makes sense, however Im wondering how > >> to make this into a recursive function since there's no name to reference > >> the function with. > >> > >> thanks > >> > > > > > From cktgatb@REDACTED Sun Oct 5 18:54:32 2008 From: cktgatb@REDACTED (deepblue_other) Date: Sun, 5 Oct 2008 09:54:32 -0700 (PDT) Subject: [erlang-questions] wierd "function not used" problem - code included In-Reply-To: <19826465.post@talk.nabble.com> References: <19826465.post@talk.nabble.com> Message-ID: <19826635.post@talk.nabble.com> this version that I pasted here is data_process/2 and in spawn_link() Im using data_process/1, but thats just an error that i made when pasting the code... Im compiling with: spawn_link(?MODULE, data_process,[Socket,[]]), so the aritiy is correct deepblue_other wrote: > > Hello, its me again... > so I've been having this problem for days, with the bellow code. Most of > it is straight out of the "Programming Erlang" book from Joe Armstrong... > however when Im compiling it its telling me that the function > data_process/1 is not being used, gives me a warning, but then still > compiles. however when Im sending data from a client side via TCP ofcourse > it exits on me because there's nothing to process the message... > > I HAVE NO IDEA WHAT'S WRONG WITH IT. > I've read up on all the spawn_link() definitions and as far as I can tell > Im using it correctly... the PiD that spawn_link() returns is being > returned so it executes successfully. > please help out, its stalling my project progress. > thanks > > > -module(tcp_manager). > %API-------------------------------------------- > -export([start/1]). > %----------------------------------------------- > start(Port) -> > {ok, ListeningSocket} = > gen_tcp:listen( Port, [ binary, %receive data in binary form > {packet , 0}, > {reuseaddr, true}, > %hybrid - active for only one > message > %it auto-receives one message after > which it blocks > %has to be set to active-once again > to receive the next message > {active , once} ] ), > accept_connection(ListeningSocket). > %----------------------------------------------- > accept_connection(ListeningSocket) -> > > io:format("waiting to accept~n"), > {ok, Socket} = gen_tcp:accept(ListeningSocket), > io:format("Socket is:~p~n", [Socket]), > > %----------------------------------------------- > Listen_for_errors = > fun() -> > io:format("listening started~n"), > receive > {'EXIT', Pid, Why} -> > io:format("~p exited because:~p", [Pid,Why]); > Other -> > io:format("Other:~p~n", [Other]) > end > end, > Listen_for_errors(), > %----------------------------------------------- > > Handler_process = spawn_link(?MODULE, data_process, [Socket]), %,[]]), > io:format("handlers process ID:~p", [Handler_process]). > > accept_connection(ListeningSocket). > %----------------------------------------------- > data_process( Socket, DataSoFar) -> > io:format("responder_loop() entered~n"), > > receive > {tcp, Socket, Data} -> > %Source_ip = inet:peername(Socket), > %io:format("*~p - data coming in:~p~n",[Source_ip,Data]), > io:format("works - Data:~p~n", [Data]), > %has to be done, since its an active-once socket > inet:setopts( Socket, [{active,once}] ), > data_process( Socket, > %append the new binary fragment to what > has been received so far > [Data | DataSoFar] ); > > {tcp_closed, Socket} -> > io:format("*client socket closed~n"); > %reverse because data has been appended to the head of the > list as it was coming in > list_to_binary(lists:reverse(SoFar)); > Other -> > io:format("undefined message came in:~p", [Other]) > end. > %----------------------------------------------- > -- View this message in context: http://www.nabble.com/wierd-%22function-not-used%22-problem---code-included-tp19826465p19826635.html Sent from the Erlang Questions mailing list archive at Nabble.com. From michael.regen@REDACTED Sun Oct 5 19:04:12 2008 From: michael.regen@REDACTED (Michael Regen) Date: Sun, 5 Oct 2008 19:04:12 +0200 Subject: [erlang-questions] How to build Erlang with libcmt (/MT) under windows? Message-ID: <9b59d0270810051004u391f464k112d5175573a95f4@mail.gmail.com> Hi, Does anyone a little bit more experienced with the Erlang build mechanism know how to compile and link Erlang with libcmt instead of msvcrt? The default mechanism builds Erlang with the /MD switch which means the C standard libraries are accessed as threaded dll MSVCR??.DLL. This also means you cannot simply copy Erlang to another computer as long as the correct C runtime is not installed there. I am trying to figure out how to statically bind the libcmt library. Normally you do this by using the /MT switch. So far I tried to change the erts\etc\win32\cygwin_tools\vc\cc.sh and ld.sh scripts but with no good effects. I always get the usual error messages like if you mix libraries compiled with different switches. In cc.sh setting MD_FORCED=true MD=-MT and in ld.sh STDLIB=LIBCMT.LIB just leads me to: LIBCMT.LIB(dosmap.obj) : error LNK2005: __dosmaperr already defined in dosmap.o Creating library c:/dev/erlang/ErlangOTP/otp_src_R12B-4/bin/win32/erl_dll.lib and object c:/dev/erlang/ErlangOTP/otp_src_R12B-4/bin/win32/erl_dll.exp c:/dev/erlang/ErlangOTP/otp_src_R12B-4/bin/win32/beam.smp.dll : fatal error LNK1169: one or more multiply defined symbols found Thank you! Regards, Michael -------------- next part -------------- An HTML attachment was scrubbed... URL: From michael.regen@REDACTED Sun Oct 5 19:04:12 2008 From: michael.regen@REDACTED (Michael Regen) Date: Sun, 5 Oct 2008 19:04:12 +0200 Subject: [erlang-questions] How to build Erlang with libcmt (/MT) under windows? Message-ID: <9b59d0270810051004u391f464k112d5175573a95f4@mail.gmail.com> Hi, Does anyone a little bit more experienced with the Erlang build mechanism know how to compile and link Erlang with libcmt instead of msvcrt? The default mechanism builds Erlang with the /MD switch which means the C standard libraries are accessed as threaded dll MSVCR??.DLL. This also means you cannot simply copy Erlang to another computer as long as the correct C runtime is not installed there. I am trying to figure out how to statically bind the libcmt library. Normally you do this by using the /MT switch. So far I tried to change the erts\etc\win32\cygwin_tools\vc\cc.sh and ld.sh scripts but with no good effects. I always get the usual error messages like if you mix libraries compiled with different switches. In cc.sh setting MD_FORCED=true MD=-MT and in ld.sh STDLIB=LIBCMT.LIB just leads me to: LIBCMT.LIB(dosmap.obj) : error LNK2005: __dosmaperr already defined in dosmap.o Creating library c:/dev/erlang/ErlangOTP/otp_src_R12B-4/bin/win32/erl_dll.lib and object c:/dev/erlang/ErlangOTP/otp_src_R12B-4/bin/win32/erl_dll.exp c:/dev/erlang/ErlangOTP/otp_src_R12B-4/bin/win32/beam.smp.dll : fatal error LNK1169: one or more multiply defined symbols found Thank you! Regards, Michael -------------- next part -------------- An HTML attachment was scrubbed... URL: From oscar@REDACTED Sun Oct 5 19:39:42 2008 From: oscar@REDACTED (=?utf-8?Q?Oscar_Hellstr=C3=B6m?=) Date: Sun, 5 Oct 2008 18:39:42 +0100 (BST) Subject: [erlang-questions] wierd "function not used" problem - code included In-Reply-To: <24151217.5861223228208675.JavaMail.root@zimbra> Message-ID: <33112579.5881223228382303.JavaMail.root@zimbra> Hi, Calling spawn_link(Module, Function, Args) will call Module:Function(Args) as a fully qualified call. Therefore this Function has to be exported. Best regards ----- Original Message ----- From: "deepblue_other" To: erlang-questions@REDACTED Sent: Sunday, 5 October, 2008 9:39:41 AM GMT -08:00 US/Canada Pacific Subject: [erlang-questions] wierd "function not used" problem - code included Hello, its me again... so I've been having this problem for days, with the bellow code. Most of it is straight out of the "Programming Erlang" book from Joe Armstrong... however when Im compiling it its telling me that the function data_process/1 is not being used, gives me a warning, but then still compiles. however when Im sending data from a client side via TCP ofcourse it exits on me because there's nothing to process the message... I HAVE NO IDEA WHAT'S WRONG WITH IT. I've read up on all the spawn_link() definitions and as far as I can tell Im using it correctly... the PiD that spawn_link() returns is being returned so it executes successfully. please help out, its stalling my project progress. thanks -module(tcp_manager). %API-------------------------------------------- -export([start/1]). %----------------------------------------------- start(Port) -> {ok, ListeningSocket} = gen_tcp:listen( Port, [ binary, %receive data in binary form {packet , 0}, {reuseaddr, true}, %hybrid - active for only one message %it auto-receives one message after which it blocks %has to be set to active-once again to receive the next message {active , once} ] ), accept_connection(ListeningSocket). %----------------------------------------------- accept_connection(ListeningSocket) -> io:format("waiting to accept~n"), {ok, Socket} = gen_tcp:accept(ListeningSocket), io:format("Socket is:~p~n", [Socket]), %----------------------------------------------- Listen_for_errors = fun() -> io:format("listening started~n"), receive {'EXIT', Pid, Why} -> io:format("~p exited because:~p", [Pid,Why]); Other -> io:format("Other:~p~n", [Other]) end end, Listen_for_errors(), %----------------------------------------------- Handler_process = spawn_link(?MODULE, data_process, [Socket]), %,[]]), io:format("handlers process ID:~p", [Handler_process]). accept_connection(ListeningSocket). %----------------------------------------------- data_process( Socket, DataSoFar) -> io:format("responder_loop() entered~n"), receive {tcp, Socket, Data} -> %Source_ip = inet:peername(Socket), %io:format("*~p - data coming in:~p~n",[Source_ip,Data]), io:format("works - Data:~p~n", [Data]), %has to be done, since its an active-once socket inet:setopts( Socket, [{active,once}] ), data_process( Socket, %append the new binary fragment to what has been received so far [Data | DataSoFar] ); {tcp_closed, Socket} -> io:format("*client socket closed~n"); %reverse because data has been appended to the head of the list as it was coming in list_to_binary(lists:reverse(SoFar)); Other -> io:format("undefined message came in:~p", [Other]) end. %----------------------------------------------- -- View this message in context: http://www.nabble.com/wierd-%22function-not-used%22-problem---code-included-tp19826465p19826465.html Sent from the Erlang Questions mailing list archive at Nabble.com. _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions -- Oscar Hellstr?m, oscar@REDACTED Phone: +44 (0)798 45 44 773 Mobile: +44 (0)207 65 50 337 Web: http://www.erlang-consulting.com From rvirding@REDACTED Sun Oct 5 20:00:56 2008 From: rvirding@REDACTED (Robert Virding) Date: Sun, 5 Oct 2008 20:00:56 +0200 Subject: [erlang-questions] wierd "function not used" problem - code included In-Reply-To: <19826465.post@talk.nabble.com> References: <19826465.post@talk.nabble.com> Message-ID: <3dbc6d1c0810051100h7d746760vd6ff1b3c43937b08@mail.gmail.com> data_process/1 is never directly called so the warning is correct. However, to be spawn in that way it must be explicitly exported, that is why you get a runtime error. Try exporting data_process/1 or changing the spawn to: spawn_link(fun () -> data_process(Socket, []) end), Anyway it should be data_process/2 as there is no data_process/1 defined. Robert 2008/10/5 deepblue_other > > Hello, its me again... > so I've been having this problem for days, with the bellow code. Most of it > is straight out of the "Programming Erlang" book from Joe Armstrong... > however when Im compiling it its telling me that the function > data_process/1 > is not being used, gives me a warning, but then still compiles. however > when > Im sending data from a client side via TCP ofcourse it exits on me because > there's nothing to process the message... > > I HAVE NO IDEA WHAT'S WRONG WITH IT. > I've read up on all the spawn_link() definitions and as far as I can tell > Im > using it correctly... the PiD that spawn_link() returns is being returned > so > it executes successfully. > please help out, its stalling my project progress. > thanks > > > -module(tcp_manager). > %API-------------------------------------------- > -export([start/1]). > %----------------------------------------------- > start(Port) -> > {ok, ListeningSocket} = > gen_tcp:listen( Port, [ binary, %receive data in binary form > {packet , 0}, > {reuseaddr, true}, > %hybrid - active for only one message > %it auto-receives one message after > which it blocks > %has to be set to active-once again to > receive the next message > {active , once} ] ), > accept_connection(ListeningSocket). > %----------------------------------------------- > accept_connection(ListeningSocket) -> > > io:format("waiting to accept~n"), > {ok, Socket} = gen_tcp:accept(ListeningSocket), > io:format("Socket is:~p~n", [Socket]), > > %----------------------------------------------- > Listen_for_errors = > fun() -> > io:format("listening started~n"), > receive > {'EXIT', Pid, Why} -> > io:format("~p exited because:~p", [Pid,Why]); > Other -> > io:format("Other:~p~n", [Other]) > end > end, > Listen_for_errors(), > %----------------------------------------------- > > Handler_process = spawn_link(?MODULE, data_process, [Socket]), %,[]]), > io:format("handlers process ID:~p", [Handler_process]). > > accept_connection(ListeningSocket). > %----------------------------------------------- > data_process( Socket, DataSoFar) -> > io:format("responder_loop() entered~n"), > > receive > {tcp, Socket, Data} -> > %Source_ip = inet:peername(Socket), > %io:format("*~p - data coming in:~p~n",[Source_ip,Data]), > io:format("works - Data:~p~n", [Data]), > %has to be done, since its an active-once socket > inet:setopts( Socket, [{active,once}] ), > data_process( Socket, > %append the new binary fragment to what has > been received so far > [Data | DataSoFar] ); > > {tcp_closed, Socket} -> > io:format("*client socket closed~n"); > %reverse because data has been appended to the head of the list > as it was coming in > list_to_binary(lists:reverse(SoFar)); > Other -> > io:format("undefined message came in:~p", [Other]) > end. > %----------------------------------------------- > -- > View this message in context: > http://www.nabble.com/wierd-%22function-not-used%22-problem---code-included-tp19826465p19826465.html > Sent from the Erlang Questions mailing list archive at Nabble.com. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From cktgatb@REDACTED Sun Oct 5 20:34:30 2008 From: cktgatb@REDACTED (deepblue_other) Date: Sun, 5 Oct 2008 11:34:30 -0700 (PDT) Subject: [erlang-questions] wierd "function not used" problem - code included In-Reply-To: <19826465.post@talk.nabble.com> References: <19826465.post@talk.nabble.com> Message-ID: <19827659.post@talk.nabble.com> hmmm sorry, just a moment deepblue_other wrote: > > Hello, its me again... > so I've been having this problem for days, with the bellow code. Most of > it is straight out of the "Programming Erlang" book from Joe Armstrong... > however when Im compiling it its telling me that the function > data_process/1 is not being used, gives me a warning, but then still > compiles. however when Im sending data from a client side via TCP ofcourse > it exits on me because there's nothing to process the message... > > I HAVE NO IDEA WHAT'S WRONG WITH IT. > I've read up on all the spawn_link() definitions and as far as I can tell > Im using it correctly... the PiD that spawn_link() returns is being > returned so it executes successfully. > please help out, its stalling my project progress. > thanks > > > -module(tcp_manager). > %API-------------------------------------------- > -export([start/1]). > %----------------------------------------------- > start(Port) -> > {ok, ListeningSocket} = > gen_tcp:listen( Port, [ binary, %receive data in binary form > {packet , 0}, > {reuseaddr, true}, > %hybrid - active for only one > message > %it auto-receives one message after > which it blocks > %has to be set to active-once again > to receive the next message > {active , once} ] ), > accept_connection(ListeningSocket). > %----------------------------------------------- > accept_connection(ListeningSocket) -> > > io:format("waiting to accept~n"), > {ok, Socket} = gen_tcp:accept(ListeningSocket), > io:format("Socket is:~p~n", [Socket]), > > %----------------------------------------------- > Listen_for_errors = > fun() -> > io:format("listening started~n"), > receive > {'EXIT', Pid, Why} -> > io:format("~p exited because:~p", [Pid,Why]); > Other -> > io:format("Other:~p~n", [Other]) > end > end, > Listen_for_errors(), > %----------------------------------------------- > > Handler_process = spawn_link(?MODULE, data_process, [Socket]), %,[]]), > io:format("handlers process ID:~p", [Handler_process]). > > accept_connection(ListeningSocket). > %----------------------------------------------- > data_process( Socket, DataSoFar) -> > io:format("responder_loop() entered~n"), > > receive > {tcp, Socket, Data} -> > %Source_ip = inet:peername(Socket), > %io:format("*~p - data coming in:~p~n",[Source_ip,Data]), > io:format("works - Data:~p~n", [Data]), > %has to be done, since its an active-once socket > inet:setopts( Socket, [{active,once}] ), > data_process( Socket, > %append the new binary fragment to what > has been received so far > [Data | DataSoFar] ); > > {tcp_closed, Socket} -> > io:format("*client socket closed~n"); > %reverse because data has been appended to the head of the > list as it was coming in > list_to_binary(lists:reverse(SoFar)); > Other -> > io:format("undefined message came in:~p", [Other]) > end. > %----------------------------------------------- > -- View this message in context: http://www.nabble.com/wierd-%22function-not-used%22-problem---code-included-tp19826465p19827659.html Sent from the Erlang Questions mailing list archive at Nabble.com. From erlang-questions_efine@REDACTED Sun Oct 5 20:25:47 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Sun, 5 Oct 2008 11:25:47 -0700 (PDT) Subject: [erlang-questions] wierd "function not used" problem - code included In-Reply-To: <19826635.post@talk.nabble.com> References: <19826465.post@talk.nabble.com> <19826635.post@talk.nabble.com> Message-ID: <19827568.post@talk.nabble.com> Your code as pasted here does not compile, even after correcting the spawn_link arity. There are syntax errors. Please post a version that compiles. -- View this message in context: http://www.nabble.com/wierd-%22function-not-used%22-problem---code-included-tp19826465p19827568.html Sent from the Erlang Questions mailing list archive at Nabble.com. From cktgatb@REDACTED Sun Oct 5 20:40:18 2008 From: cktgatb@REDACTED (deepblue_other) Date: Sun, 5 Oct 2008 11:40:18 -0700 (PDT) Subject: [erlang-questions] wierd "function not used" problem - code included In-Reply-To: <19827696.post@talk.nabble.com> References: <19826465.post@talk.nabble.com> <19827659.post@talk.nabble.com> <19827696.post@talk.nabble.com> Message-ID: <19827720.post@talk.nabble.com> there was a tiny error in the last one, and I put the correct arity in spawn_link() this should compile thanks -module(tcp_manager). %API-------------------------------------------- -export([start/1]). %----------------------------------------------- start(Port) -> {ok, ListeningSocket} = gen_tcp:listen( Port, [ binary, %receive data in binary form {packet , 0}, {reuseaddr, true}, {active , once} ] ), accept_connection(ListeningSocket). %----------------------------------------------- accept_connection(ListeningSocket) -> io:format("waiting to accept~n"), {ok, Socket} = gen_tcp:accept(ListeningSocket), io:format("Socket is:~p~n", [Socket]), %----------------------------------------------- Listen_for_errors = fun() -> io:format("listening started~n"), receive {'EXIT', Pid, Why} -> io:format("~p exited because:~p", [Pid,Why]); Other -> io:format("Other:~p~n", [Other]) end end, Listen_for_errors(), %----------------------------------------------- Handler_process = spawn_link(?MODULE, data_process, [Socket, []]), io:format("handlers process ID:~p", [Handler_process]). %----------------------------------------------- data_process( Socket, DataSoFar) -> io:format("responder_loop() entered~n"), receive {tcp, Socket, Data} -> io:format("works - Data:~p~n", [Data]), inet:setopts( Socket, [{active,once}] ), data_process( Socket, [Data | DataSoFar] ); {tcp_closed, Socket} -> io:format("*client socket closed~n"); Other -> io:format("undefined message came in:~p", [Other]) end. %----------------------------------------------- deepblue_other wrote: > > here you go, this should compile > sorry about that > thanks > > -module(tcp_manager). > %API-------------------------------------------- > -export([start/1]). > %----------------------------------------------- > start(Port) -> > {ok, ListeningSocket} = > gen_tcp:listen( Port, [ binary, %receive data in binary form > {packet , 0}, > {reuseaddr, true}, > {active , once} ] ), > accept_connection(ListeningSocket). > %----------------------------------------------- > accept_connection(ListeningSocket) -> > > io:format("waiting to accept~n"), > {ok, Socket} = gen_tcp:accept(ListeningSocket), > io:format("Socket is:~p~n", [Socket]), > > %----------------------------------------------- > Listen_for_errors = > fun() -> > io:format("listening started~n"), > receive > {'EXIT', Pid, Why} -> > io:format("~p exited because:~p", [Pid,Why]); > Other -> > io:format("Other:~p~n", [Other]) > end > end, > Listen_for_errors(), > %----------------------------------------------- > > Handler_process = spawn_link(?MODULE, data_process, [Socket]), %,[]]), > io:format("handlers process ID:~p", [Handler_process]). > %----------------------------------------------- > data_process( Socket, DataSoFar) -> > io:format("responder_loop() entered~n"), > > receive > {tcp, Socket, Data} -> > io:format("works - Data:~p~n", [Data]), > inet:setopts( Socket, [{active,once}] ), > data_process( Socket, > [Data | DataSoFar] ); > > {tcp_closed, Socket} -> > io:format("*client socket closed~n"); > Other -> > io:format("undefined message came in:~p", [Other]) > end. > %----------------------------------------------- > > deepblue_other wrote: >> >> hmmm >> sorry, just a moment >> >> deepblue_other wrote: >>> >>> Hello, its me again... >>> so I've been having this problem for days, with the bellow code. Most of >>> it is straight out of the "Programming Erlang" book from Joe >>> Armstrong... however when Im compiling it its telling me that the >>> function data_process/1 is not being used, gives me a warning, but then >>> still compiles. however when Im sending data from a client side via TCP >>> ofcourse it exits on me because there's nothing to process the >>> message... >>> >>> I HAVE NO IDEA WHAT'S WRONG WITH IT. >>> I've read up on all the spawn_link() definitions and as far as I can >>> tell Im using it correctly... the PiD that spawn_link() returns is being >>> returned so it executes successfully. >>> please help out, its stalling my project progress. >>> thanks >>> >>> >>> -module(tcp_manager). >>> %API-------------------------------------------- >>> -export([start/1]). >>> %----------------------------------------------- >>> start(Port) -> >>> {ok, ListeningSocket} = >>> gen_tcp:listen( Port, [ binary, %receive data in binary form >>> {packet , 0}, >>> {reuseaddr, true}, >>> %hybrid - active for only one >>> message >>> %it auto-receives one message >>> after which it blocks >>> %has to be set to active-once >>> again to receive the next message >>> {active , once} ] ), >>> accept_connection(ListeningSocket). >>> %----------------------------------------------- >>> accept_connection(ListeningSocket) -> >>> >>> io:format("waiting to accept~n"), >>> {ok, Socket} = gen_tcp:accept(ListeningSocket), >>> io:format("Socket is:~p~n", [Socket]), >>> >>> %----------------------------------------------- >>> Listen_for_errors = >>> fun() -> >>> io:format("listening started~n"), >>> receive >>> {'EXIT', Pid, Why} -> >>> io:format("~p exited because:~p", [Pid,Why]); >>> Other -> >>> io:format("Other:~p~n", [Other]) >>> end >>> end, >>> Listen_for_errors(), >>> %----------------------------------------------- >>> >>> Handler_process = spawn_link(?MODULE, data_process, [Socket]), >>> %,[]]), >>> io:format("handlers process ID:~p", [Handler_process]). >>> >>> accept_connection(ListeningSocket). >>> %----------------------------------------------- >>> data_process( Socket, DataSoFar) -> >>> io:format("responder_loop() entered~n"), >>> >>> receive >>> {tcp, Socket, Data} -> >>> %Source_ip = inet:peername(Socket), >>> %io:format("*~p - data coming in:~p~n",[Source_ip,Data]), >>> io:format("works - Data:~p~n", [Data]), >>> %has to be done, since its an active-once socket >>> inet:setopts( Socket, [{active,once}] ), >>> data_process( Socket, >>> %append the new binary fragment to what >>> has been received so far >>> [Data | DataSoFar] ); >>> >>> {tcp_closed, Socket} -> >>> io:format("*client socket closed~n"); >>> %reverse because data has been appended to the head of the >>> list as it was coming in >>> list_to_binary(lists:reverse(SoFar)); >>> Other -> >>> io:format("undefined message came in:~p", [Other]) >>> end. >>> %----------------------------------------------- >>> >> >> > > -- View this message in context: http://www.nabble.com/wierd-%22function-not-used%22-problem---code-included-tp19826465p19827720.html Sent from the Erlang Questions mailing list archive at Nabble.com. From cktgatb@REDACTED Sun Oct 5 20:38:14 2008 From: cktgatb@REDACTED (deepblue_other) Date: Sun, 5 Oct 2008 11:38:14 -0700 (PDT) Subject: [erlang-questions] wierd "function not used" problem - code included In-Reply-To: <19827659.post@talk.nabble.com> References: <19826465.post@talk.nabble.com> <19827659.post@talk.nabble.com> Message-ID: <19827696.post@talk.nabble.com> here you go, this should compile sorry about that thanks -module(tcp_manager). %API-------------------------------------------- -export([start/1]). %----------------------------------------------- start(Port) -> {ok, ListeningSocket} = gen_tcp:listen( Port, [ binary, %receive data in binary form {packet , 0}, {reuseaddr, true}, {active , once} ] ), accept_connection(ListeningSocket). %----------------------------------------------- accept_connection(ListeningSocket) -> io:format("waiting to accept~n"), {ok, Socket} = gen_tcp:accept(ListeningSocket), io:format("Socket is:~p~n", [Socket]), %----------------------------------------------- Listen_for_errors = fun() -> io:format("listening started~n"), receive {'EXIT', Pid, Why} -> io:format("~p exited because:~p", [Pid,Why]); Other -> io:format("Other:~p~n", [Other]) end end, Listen_for_errors(), %----------------------------------------------- Handler_process = spawn_link(?MODULE, data_process, [Socket]), %,[]]), io:format("handlers process ID:~p", [Handler_process]). %----------------------------------------------- data_process( Socket, DataSoFar) -> io:format("responder_loop() entered~n"), receive {tcp, Socket, Data} -> io:format("works - Data:~p~n", [Data]), inet:setopts( Socket, [{active,once}] ), data_process( Socket, [Data | DataSoFar] ); {tcp_closed, Socket} -> io:format("*client socket closed~n"); Other -> io:format("undefined message came in:~p", [Other]) end. %----------------------------------------------- deepblue_other wrote: > > hmmm > sorry, just a moment > > deepblue_other wrote: >> >> Hello, its me again... >> so I've been having this problem for days, with the bellow code. Most of >> it is straight out of the "Programming Erlang" book from Joe Armstrong... >> however when Im compiling it its telling me that the function >> data_process/1 is not being used, gives me a warning, but then still >> compiles. however when Im sending data from a client side via TCP >> ofcourse it exits on me because there's nothing to process the message... >> >> I HAVE NO IDEA WHAT'S WRONG WITH IT. >> I've read up on all the spawn_link() definitions and as far as I can tell >> Im using it correctly... the PiD that spawn_link() returns is being >> returned so it executes successfully. >> please help out, its stalling my project progress. >> thanks >> >> >> -module(tcp_manager). >> %API-------------------------------------------- >> -export([start/1]). >> %----------------------------------------------- >> start(Port) -> >> {ok, ListeningSocket} = >> gen_tcp:listen( Port, [ binary, %receive data in binary form >> {packet , 0}, >> {reuseaddr, true}, >> %hybrid - active for only one >> message >> %it auto-receives one message after >> which it blocks >> %has to be set to active-once again >> to receive the next message >> {active , once} ] ), >> accept_connection(ListeningSocket). >> %----------------------------------------------- >> accept_connection(ListeningSocket) -> >> >> io:format("waiting to accept~n"), >> {ok, Socket} = gen_tcp:accept(ListeningSocket), >> io:format("Socket is:~p~n", [Socket]), >> >> %----------------------------------------------- >> Listen_for_errors = >> fun() -> >> io:format("listening started~n"), >> receive >> {'EXIT', Pid, Why} -> >> io:format("~p exited because:~p", [Pid,Why]); >> Other -> >> io:format("Other:~p~n", [Other]) >> end >> end, >> Listen_for_errors(), >> %----------------------------------------------- >> >> Handler_process = spawn_link(?MODULE, data_process, [Socket]), >> %,[]]), >> io:format("handlers process ID:~p", [Handler_process]). >> >> accept_connection(ListeningSocket). >> %----------------------------------------------- >> data_process( Socket, DataSoFar) -> >> io:format("responder_loop() entered~n"), >> >> receive >> {tcp, Socket, Data} -> >> %Source_ip = inet:peername(Socket), >> %io:format("*~p - data coming in:~p~n",[Source_ip,Data]), >> io:format("works - Data:~p~n", [Data]), >> %has to be done, since its an active-once socket >> inet:setopts( Socket, [{active,once}] ), >> data_process( Socket, >> %append the new binary fragment to what >> has been received so far >> [Data | DataSoFar] ); >> >> {tcp_closed, Socket} -> >> io:format("*client socket closed~n"); >> %reverse because data has been appended to the head of the >> list as it was coming in >> list_to_binary(lists:reverse(SoFar)); >> Other -> >> io:format("undefined message came in:~p", [Other]) >> end. >> %----------------------------------------------- >> > > -- View this message in context: http://www.nabble.com/wierd-%22function-not-used%22-problem---code-included-tp19826465p19827696.html Sent from the Erlang Questions mailing list archive at Nabble.com. From fredrik.svahn@REDACTED Sun Oct 5 19:28:51 2008 From: fredrik.svahn@REDACTED (Fredrik Svahn) Date: Sun, 5 Oct 2008 19:28:51 +0200 Subject: [erlang-questions] wierd "function not used" problem - code included In-Reply-To: <19826465.post@talk.nabble.com> References: <19826465.post@talk.nabble.com> Message-ID: Hi, The function given as an argument to spawn/spawn_link must be exported. See e.g. http://erlang.org/doc/getting_started/conc_prog.html#3.1 BR /Fredrik On Sun, Oct 5, 2008 at 6:39 PM, deepblue_other wrote: > > Hello, its me again... > so I've been having this problem for days, with the bellow code. Most of it > is straight out of the "Programming Erlang" book from Joe Armstrong... > however when Im compiling it its telling me that the function > data_process/1 > is not being used, gives me a warning, but then still compiles. however > when > Im sending data from a client side via TCP ofcourse it exits on me because > there's nothing to process the message... > > I HAVE NO IDEA WHAT'S WRONG WITH IT. > I've read up on all the spawn_link() definitions and as far as I can tell > Im > using it correctly... the PiD that spawn_link() returns is being returned > so > it executes successfully. > please help out, its stalling my project progress. > thanks > > > -module(tcp_manager). > %API-------------------------------------------- > -export([start/1]). > %----------------------------------------------- > start(Port) -> > {ok, ListeningSocket} = > gen_tcp:listen( Port, [ binary, %receive data in binary form > {packet , 0}, > {reuseaddr, true}, > %hybrid - active for only one message > %it auto-receives one message after > which it blocks > %has to be set to active-once again to > receive the next message > {active , once} ] ), > accept_connection(ListeningSocket). > %----------------------------------------------- > accept_connection(ListeningSocket) -> > > io:format("waiting to accept~n"), > {ok, Socket} = gen_tcp:accept(ListeningSocket), > io:format("Socket is:~p~n", [Socket]), > > %----------------------------------------------- > Listen_for_errors = > fun() -> > io:format("listening started~n"), > receive > {'EXIT', Pid, Why} -> > io:format("~p exited because:~p", [Pid,Why]); > Other -> > io:format("Other:~p~n", [Other]) > end > end, > Listen_for_errors(), > %----------------------------------------------- > > Handler_process = spawn_link(?MODULE, data_process, [Socket]), %,[]]), > io:format("handlers process ID:~p", [Handler_process]). > > accept_connection(ListeningSocket). > %----------------------------------------------- > data_process( Socket, DataSoFar) -> > io:format("responder_loop() entered~n"), > > receive > {tcp, Socket, Data} -> > %Source_ip = inet:peername(Socket), > %io:format("*~p - data coming in:~p~n",[Source_ip,Data]), > io:format("works - Data:~p~n", [Data]), > %has to be done, since its an active-once socket > inet:setopts( Socket, [{active,once}] ), > data_process( Socket, > %append the new binary fragment to what has > been received so far > [Data | DataSoFar] ); > > {tcp_closed, Socket} -> > io:format("*client socket closed~n"); > %reverse because data has been appended to the head of the list > as it was coming in > list_to_binary(lists:reverse(SoFar)); > Other -> > io:format("undefined message came in:~p", [Other]) > end. > %----------------------------------------------- > -- > View this message in context: > http://www.nabble.com/wierd-%22function-not-used%22-problem---code-included-tp19826465p19826465.html > Sent from the Erlang Questions mailing list archive at Nabble.com. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From erlang-questions_efine@REDACTED Sun Oct 5 19:55:29 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Sun, 5 Oct 2008 13:55:29 -0400 Subject: [erlang-questions] tcp sockets - not clear In-Reply-To: <19826070.post@talk.nabble.com> References: <19826070.post@talk.nabble.com> Message-ID: <6c2563b20810051055r407dda00w3d6b094298bace42@mail.gmail.com> Unless you write it otherwise, I would imagine that each front-end object will get its own independent socket and therefore have its own channel to the back end. On the back end, have a listener that kicks off one Erlang process per new socket to handle the message. Messages in this way will not interfere with each other and you can construct them without fear of them getting mixed up. If you want to see a good example of this, look at the way the listener in the gen_smsc.erl module of the OSERL application ( http://oserl.sourceforge.net) waits for connections, spawns a session process for each connection, and passes off the now-open socket to the spawned process (and makes it the owner of the socket, too - important). -------------- next part -------------- An HTML attachment was scrubbed... URL: From erlang-questions_efine@REDACTED Sun Oct 5 22:02:02 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Sun, 5 Oct 2008 13:02:02 -0700 (PDT) Subject: [erlang-questions] wierd "function not used" problem - code included In-Reply-To: <19827720.post@talk.nabble.com> References: <19826465.post@talk.nabble.com> <19827659.post@talk.nabble.com> <19827696.post@talk.nabble.com> <19827720.post@talk.nabble.com> Message-ID: <19828568.post@talk.nabble.com> Well, there are a couple of problems, but the reason why you get that warning is that you have to export a function that you spawn_link to using Module/Func/Args syntax, otherwise you would have to Handler_process = spawn_link(fun() -> data_process(Socket, []) end), The other problem is that your fun Listen_for_errors may as well be inline, i.e. you could change this code: %----------------------------------------------- Listen_for_errors = fun() -> io:format("listening started~n"), receive {'EXIT', Pid, Why} -> io:format("~p exited because:~p", [Pid,Why]); Other -> io:format("Other:~p~n", [Other]) end end, Listen_for_errors(), %----------------------------------------------- Handler_process = spawn_link(?MODULE, data_process, [Socket, []]), To this: %----------------------------------------------- io:format("listening started~n"), receive {'EXIT', Pid, Why} -> io:format("~p exited because:~p", [Pid,Why]); Other -> io:format("Other:~p~n", [Other]) end, %----------------------------------------------- Handler_process = spawn_link(?MODULE, data_process, [Socket, []]), -- View this message in context: http://www.nabble.com/wierd-%22function-not-used%22-problem---code-included-tp19826465p19828568.html Sent from the Erlang Questions mailing list archive at Nabble.com. From aconbere@REDACTED Mon Oct 6 00:15:26 2008 From: aconbere@REDACTED (anders conbere) Date: Sun, 5 Oct 2008 15:15:26 -0700 Subject: [erlang-questions] a little meta-programing help Message-ID: <8ca3fbe80810051515m6b983822re94985aa0b63248c@mail.gmail.com> Today I sat down to try to make working with mochiweb a little cleaner for myself. I wanted a way to specify a list of mappings between url patterns and methods to be called with the matched variables from them. I quickly ran into issues with not being able to create patterns dynamically, and then tried using funs to wrap that functionality but pretty soon I was back at the same mess I started with. This is kind of my "if the world were perfect" module (that doesn't work at all but I hope might show what I was going for). I was hoping folks might help be think up some ways to handle use cases like this. -module(roto_web_routes). -export([ call/1 ]). -define(VIEWS_MODULE, roto_web_views). routes() -> [ url(["version"], version), url(["register"], register), url(["node", NodeName, "messages"], messages), url(["node", NodeName, "messages", Id], message), url(["node", NodeName, "messages"], subscriptions), url(["node", NodeName, "messages", Id], subscriptions) ]. url(Pattern, View) -> {route, Pattern, View, View}. url(Pattern, View, Name) -> {route, Pattern, View, Name}. % should take a request, find the matching url config and pass % the matched variables into the function specified in the url % config for that entry. call(Req) -> Path = string:tokens(Req:get(path), "/"), match_route(Path). match_route(Path) -> %does something fancy with routes() to get to the function % I want to call and call it with the matched variables ok. Thanks! ~ Anders From cktgatb@REDACTED Mon Oct 6 00:55:10 2008 From: cktgatb@REDACTED (deepblue_other) Date: Sun, 5 Oct 2008 15:55:10 -0700 (PDT) Subject: [erlang-questions] wierd "function not used" problem - code included In-Reply-To: <19828568.post@talk.nabble.com> References: <19826465.post@talk.nabble.com> <19827659.post@talk.nabble.com> <19827696.post@talk.nabble.com> <19827720.post@talk.nabble.com> <19828568.post@talk.nabble.com> Message-ID: <19829936.post@talk.nabble.com> beautiful, it works now. Thank you Edwin. so when I want to use spawn_link() with a named function that function has to be exported? same stands for regular spawn()? just a side question: once a certain "receive" configuration is set for a process it can never be changed to another "receive" configuration? it just popped in my head here when you said that i can inline the error "receive". thanks for your time Edwin Fine wrote: > > Well, there are a couple of problems, but the reason why you get that > warning is that you have to export a function that you spawn_link to using > Module/Func/Args syntax, otherwise you would have to > > Handler_process = spawn_link(fun() -> data_process(Socket, []) end), > > The other problem is that your fun Listen_for_errors may as well be > inline, i.e. you could change this code: > > %----------------------------------------------- > Listen_for_errors = > fun() -> > io:format("listening started~n"), > receive > {'EXIT', Pid, Why} -> > io:format("~p exited because:~p", [Pid,Why]); > Other -> > io:format("Other:~p~n", [Other]) > end > end, > Listen_for_errors(), > %----------------------------------------------- > > Handler_process = spawn_link(?MODULE, data_process, [Socket, []]), > > To this: > > %----------------------------------------------- > io:format("listening started~n"), > receive > {'EXIT', Pid, Why} -> > io:format("~p exited because:~p", [Pid,Why]); > Other -> > io:format("Other:~p~n", [Other]) > end, > %----------------------------------------------- > > Handler_process = spawn_link(?MODULE, data_process, [Socket, []]), > > > -- View this message in context: http://www.nabble.com/wierd-%22function-not-used%22-problem---code-included-tp19826465p19829936.html Sent from the Erlang Questions mailing list archive at Nabble.com. From antoine.koener@REDACTED Mon Oct 6 01:12:31 2008 From: antoine.koener@REDACTED (Antoine Koener) Date: Mon, 6 Oct 2008 01:12:31 +0200 Subject: [erlang-questions] a little meta-programing help In-Reply-To: <8ca3fbe80810051515m6b983822re94985aa0b63248c@mail.gmail.com> References: <8ca3fbe80810051515m6b983822re94985aa0b63248c@mail.gmail.com> Message-ID: <1c89b3a10810051612r6e341282v54d0f94262072dbb@mail.gmail.com> On Mon, Oct 6, 2008 at 12:15 AM, anders conbere wrote: > Today I sat down to try to make working with mochiweb a little cleaner > for myself. I wanted a way to specify a list of mappings between url > patterns and methods to be called with the matched variables from > them. I quickly ran into issues with not being able to create patterns > dynamically, and then tried using funs to wrap that functionality but > pretty soon I was back at the same mess I started with. > I used the list_to_atom fun to build the module name. This is not recommended but it's still really useful: check out: http://easyerl.blogspot.com/2008/07/my-mochiweb-webservice.html -- http://easyerl.blogspot.com/ http://www.open-tools.org/ From aconbere@REDACTED Mon Oct 6 01:31:29 2008 From: aconbere@REDACTED (anders conbere) Date: Sun, 5 Oct 2008 16:31:29 -0700 Subject: [erlang-questions] a little meta-programing help In-Reply-To: <1c89b3a10810051612r6e341282v54d0f94262072dbb@mail.gmail.com> References: <8ca3fbe80810051515m6b983822re94985aa0b63248c@mail.gmail.com> <1c89b3a10810051612r6e341282v54d0f94262072dbb@mail.gmail.com> Message-ID: <8ca3fbe80810051631t2a1650f5x975f927c91e23415@mail.gmail.com> On Sun, Oct 5, 2008 at 4:12 PM, Antoine Koener wrote: > On Mon, Oct 6, 2008 at 12:15 AM, anders conbere wrote: >> Today I sat down to try to make working with mochiweb a little cleaner >> for myself. I wanted a way to specify a list of mappings between url >> patterns and methods to be called with the matched variables from >> them. I quickly ran into issues with not being able to create patterns >> dynamically, and then tried using funs to wrap that functionality but >> pretty soon I was back at the same mess I started with. >> > > I used the list_to_atom fun to build the module name. > This is not recommended but it's still really useful: > check out: http://easyerl.blogspot.com/2008/07/my-mochiweb-webservice.html Yeah, so I'm working more under the presumption that I can specify the route to the module for each mapped url pattern. I'm not supper interested in mapping urls to modules from the actual url text. Thanks, ~ Anders > > -- > > http://easyerl.blogspot.com/ > http://www.open-tools.org/ > From erlang-questions_efine@REDACTED Mon Oct 6 03:06:22 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Sun, 5 Oct 2008 18:06:22 -0700 (PDT) Subject: [erlang-questions] wierd "function not used" problem - code included In-Reply-To: <19829936.post@talk.nabble.com> References: <19826465.post@talk.nabble.com> <19827659.post@talk.nabble.com> <19827696.post@talk.nabble.com> <19827720.post@talk.nabble.com> <19828568.post@talk.nabble.com> <19829936.post@talk.nabble.com> Message-ID: <19830744.post@talk.nabble.com> deepblue_other wrote: > > so when I want to use spawn_link() with a named function that function has > to be exported? > same stands for regular spawn()? > Yes, if you use a spawn that takes Module, Function, Args, like spawn/3, spawn/4, spawn_link/3, spawn_link/4,.... Or apply/3. And so on. In general if you provide a so-called "MFA" (Module, Func, Args) to a function, the Func has to be exported from Module, even if the Func is only for internal use within Module. It's important to know that the shell is your friend. It's critical to try out little pieces of code in the shell to see if they work the way you expect. For example, if you wanted to see if spawn could see your data_process function, you could have tried it in the shell (I'm passing the atom 'junk' instead of a real socket because I know the call will fail because it's not exported, so the socket is not needed): 1> c(tcp_manager). ./tcp_manager.erl:33: Warning: function data_process/2 is unused {ok,tcp_manager} 2> spawn(tcp_manager, data_process, [junk, []]). <0.40.0> 3> =ERROR REPORT==== 5-Oct-2008::20:49:23 === Error in process <0.40.0> with exit value: {undef,[{tcp_manager,data_process,[junk,[]]}]} deepblue_other wrote: > > just a side question: > once a certain "receive" configuration is set for a process it can never > be changed to another "receive" configuration? it just popped in my head > here when you said that i can inline the error "receive". > I perhaps did not make myself clear. What I meant by saying you could inline it is that I didn't see the value of writing Fun = fun() -> do_something(), do_something_else() end, Fun(). That's the same as writing do_something(), do_something_else() It is better in this case to put the code into a separate function. Better, because you can hot-swap the code and change that function. There's an excellent article about hot code swapping http://http://spawnlink.com/articles/rules-of-hot-code-swapping/ here . > %----------------------------------------------- > Listen_for_errors = > fun() -> > io:format("listening started~n"), > receive > {'EXIT', Pid, Why} -> > io:format("~p exited because:~p", [Pid,Why]); > Other -> > io:format("Other:~p~n", [Other]) > end > end, > Listen_for_errors(), > %----------------------------------------------- > Finally, I'm not sure what Listen_for_errors() is supposed to do. It's just going to sit there forever in the receive, waiting for the first message that is sent (or en exit signal), and print it out (thus throwing it away), and return. What did you want it to do? -- View this message in context: http://www.nabble.com/wierd-%22function-not-used%22-problem---code-included-tp19826465p19830744.html Sent from the Erlang Questions mailing list archive at Nabble.com. From cktgatb@REDACTED Mon Oct 6 03:13:59 2008 From: cktgatb@REDACTED (deepblue_other) Date: Sun, 5 Oct 2008 18:13:59 -0700 (PDT) Subject: [erlang-questions] Erlang external binary term format Message-ID: <19830781.post@talk.nabble.com> term_to_binary() outputs a binary. what is the format of that binary? I would like to create a "unpacker/packer" for that format in ActionScript3, and avoid the use of XML (which Im using now for Flash-to-Erlang) communication altogether. it would be faster, less code, and much more efficient from the bandwidth point of view. is there a document someplace that gives the byte layout maybe? thank you -- View this message in context: http://www.nabble.com/Erlang-external-binary-term-format-tp19830781p19830781.html Sent from the Erlang Questions mailing list archive at Nabble.com. From cktgatb@REDACTED Mon Oct 6 03:29:57 2008 From: cktgatb@REDACTED (deepblue_other) Date: Sun, 5 Oct 2008 18:29:57 -0700 (PDT) Subject: [erlang-questions] Erlang external binary term format In-Reply-To: <19830781.post@talk.nabble.com> References: <19830781.post@talk.nabble.com> Message-ID: <19830881.post@talk.nabble.com> for example one day I was looking at the term_to_binary() output of {binaries,"are",useful} and it was: 131,104,3,100,0,8,98,105,110,97,114,105,101,115,107,0,3,97,114,101,100,0,6,117,115,101,102,117,108 so with a little experimentation with other tuples I got these rules so far: 131,104 - this means that its a tuple 3 - this means that it has 3 terms 100 and 107 - type code - in this case 100 stands for atoms, and 107 stands for strings 0 - is the separator between the "type code"(name I gave it just now ;) ) and the actual ASCII sequence 8 and 3(again) and 6 - these indicate the length of the binary sequence (number of ASCII characters in this case so: binaries - 100(type code),0,8(byte length),98,105,110,97,114,105,101,115 "are" - 107(type code),0,3(byte length),97,114,101 useful - 100(type code),0,6(byte length),117,115,101,102,117,108 this just explains a limited set, doesnt go into lists... I could be wrong, but the rules seem to match up other examples as well thanks deepblue_other wrote: > > term_to_binary() outputs a binary. > what is the format of that binary? I would like to create a > "unpacker/packer" for that format in ActionScript3, and avoid the use of > XML (which Im using now for Flash-to-Erlang) communication altogether. it > would be faster, less code, and much more efficient from the bandwidth > point of view. > > is there a document someplace that gives the byte layout maybe? > thank you > -- View this message in context: http://www.nabble.com/Erlang-external-binary-term-format-tp19830781p19830881.html Sent from the Erlang Questions mailing list archive at Nabble.com. From ok@REDACTED Mon Oct 6 04:49:11 2008 From: ok@REDACTED (Richard O'Keefe) Date: Mon, 6 Oct 2008 15:49:11 +1300 Subject: [erlang-questions] [Haskell-cafe] Haskell-cafe-cafe? Was: Re: Health effects In-Reply-To: <22281_1219415383_m7MERn3A020400_24d4f39c0808220634l49188cdet690a703606a4861e@mail.gmail.com> References: <22281_1219415383_m7MERn3A020400_24d4f39c0808220634l49188cdet690a703606a4861e@mail.gmail.com> Message-ID: <9F06040A-24F4-4E55-8D5E-C8678CE36653@cs.otago.ac.nz> On 6 Oct 2008, at 1:54 am, Andrew Coppin wrote: > Hi, > > If I have a list of a fixed size (say 10,000 elements). What is the > most efficient way to add a new item to the list and force out the old > first element. It depends on where you want to add the new item. If you want it at the front, just New_List = [New_Item | tail(Old_List)] is pretty hard to improve on. If you want to add the new item anywhere else, you will have to copy. > I'm currently doing a double reverse trick, e.g. : > > Eshell V5.6.3 (abort with ^G) > 1> L1 = ["A", "B", "C", "D", "E"]. > ["A","B","C","D","E"] > 2> [_ | L2] = L1. > ["A","B","C","D","E"] > 3> lists:reverse(["F" | lists:reverse(L2)]). > ["B","C","D","E","F"] It appears that you are putting the new item at the end, which is the costliest possible place to put it. You are also doing it in two passes, when it can be done in one. snoc(X, [Y|Ys]) -> [Y|snoc(X, Ys)]; snoc(X, []) -> [X]. New_List = snoc(New_Item, tail(Old_List)) The first question you have to ask yourself is "why do I *care* where the new item goes?" The second question you have to ask is "given that I need a *sequence* where the order has to be thus-and-such for such-and-such reasons, is a list the right data structure to represent this sequence?" It may well be that a list is the wrong data structure. Perhaps you need a queue (and it just so happens that there is a 'queue' module in Erlang's stdlib). Perhaps you need some more general sequence type, in which case several of Chris Okasaki's functional data structures have been converted to Erlang and are available. From ok@REDACTED Mon Oct 6 04:30:06 2008 From: ok@REDACTED (Richard O'Keefe) Date: Mon, 6 Oct 2008 15:30:06 +1300 Subject: [erlang-questions] re cursive fun() In-Reply-To: <19820386.post@talk.nabble.com> References: <19820386.post@talk.nabble.com> Message-ID: On 5 Oct 2008, at 4:19 pm, deepblue_other wrote: > I have this going on > > FunVar = > fun() -> > ... > FunVar() > end. > Shouldn't this go in a FAQ somewhere? Maybe it belongs in the reference manual. The quick answer is that if you need a recursive function, why not write a recursive function in the usual way? There's something particularly nasty about this example. One normally proves (or at any rate argues with vigourously waving hands for) the termination of a recursive function by showing that some non-negative measure of its arguments strictly decreases on each recursive call, but this function has no arguments. I think we need to see more of it. The long answer is that you can always do Rec = fun (Self, Args) -> .... Self(Self, Args') end, Foo = fun (Args) -> Rec(Rec, Args) end, It's possible, but you are working against the grain of the language, and there is most likely a better way to achieve your goals. From lloy0076@REDACTED Mon Oct 6 07:31:23 2008 From: lloy0076@REDACTED (David Lloyd) Date: Mon, 06 Oct 2008 16:01:23 +1030 Subject: [erlang-questions] Erlang Course on Web-Site (IP Rights) Message-ID: <48E9A2AB.5090907@adam.com.au> Hi There, The Erlang Course: * http://www.erlang.org/course/course.html ...doesn't have any obvious attribution as to who or what legal entity owns the copyright and other rights to it. Does anyone know who the IP owner actually is and if there are any specific restrictions on its use (eg. not in a commercial setting)? DSL From chsu79@REDACTED Mon Oct 6 08:12:01 2008 From: chsu79@REDACTED (Christian) Date: Mon, 6 Oct 2008 08:12:01 +0200 Subject: [erlang-questions] Erlang external binary term format In-Reply-To: <19830881.post@talk.nabble.com> References: <19830781.post@talk.nabble.com> <19830881.post@talk.nabble.com> Message-ID: You might want to look at ./erts/emulator/internal_doc/erl_ext_dist.txt in the source tree. On Mon, Oct 6, 2008 at 3:29 AM, deepblue_other wrote: > > for example > one day I was looking at the term_to_binary() output of > {binaries,"are",useful} > and it was: > 131,104,3,100,0,8,98,105,110,97,114,105,101,115,107,0,3,97,114,101,100,0,6,117,115,101,102,117,108 From dgud@REDACTED Mon Oct 6 09:32:31 2008 From: dgud@REDACTED (Dan Gudmundsson) Date: Mon, 06 Oct 2008 09:32:31 +0200 Subject: [erlang-questions] Some mnesia oddity In-Reply-To: <269388e30810050420w38e3cc77h23dea901c39d6cc1@mail.gmail.com> References: <48B7DB67.7010608@erix.ericsson.se> <269388e30810050420w38e3cc77h23dea901c39d6cc1@mail.gmail.com> Message-ID: <48E9BF0F.7080303@erix.ericsson.se> You should be able to read the table in the same transaction, but there is a bug in mnesia handling the special atom '_'. delete_object is not match delete do you have records with '_' in them?? /Dan Ben Hood wrote: > Hi, > > I know this is an old thread but I was wondering where the behaviour I > am seeing is in any way related to passing in a pattern to > mnesia:delete_object/1. > > On Fri, Aug 29, 2008 at 12:20 PM, Dan Gudmundsson wrote: >>> We found a strange mnesia behavior here... >>> >>> Some mnesia:write operations after a mnesia:delete_object seem to >>> not have the expected result when executed in the same transaction. >>> >>> See attached example file: >>> 1 - We fill a test_table >>> 2 - In the same transaction, we read all records, delete them, and >>> write them back (do not ask why :)) >>> 3 - Surprise! Only a subset of them can be read afterwards >>> >>> Same result in R11 and R12. >>> >>> It works if the delete_object and write operations are in separate >>> transactions... But who knows what can happen between them... > > The code I am using (attached below) is similar to the above scenario. > > Basically what I want to know is if there is a way to delete records > from a table and then re-read the table in the same transaction, or > whether this must be in separate transactions. > > My use case is a densely populated table that I want to > > 1. Selectively delete some records for; > 2. Conditionally delete records from a different table if they no > longer have any references in the first table. > > So my approach could be characterized by a delete and sweep action. > > Of course I could implement this functionality manually by re-reading > the table and filtering out any results that I know will get deleted > when the transaction commits. But if I could get mnesia to do this, it > would be more elegant. > > Also, I could do this in two transactions and re-arrange the code so > to introduce something idempotent to get around the non-atomicity. > > But if this could be solved using mnesia, that would be cool :-) > > Thx, > > Ben > > ---snip--- > > -module(sync_test). > > -compile(export_all). > > -record(outer,{inner, const = const}). > -record(inner,{a,b,c}). > > init() -> > mnesia:start(), > mnesia:delete_table(outer), > {atomic,ok} = mnesia:create_table(outer, > [{type,ordered_set}, > {attributes, record_info(fields, outer)}]), > ok. > > insert() -> > Record = #outer{inner = #inner{a = 1, b = 2, c = now()}}, > mnesia:transaction(fun() -> mnesia:write(Record) end). > > one_tx() -> > Record = #outer{inner = #inner{a = 1, b = 2, c = '_'}}, > mnesia:sync_transaction( > fun() -> > mnesia:delete_object(Record), > io:format("~p~n",[mnesia:match_object(Record)]) > end). > > two_tx() -> > Record = #outer{inner = #inner{a = 1, b = 2, c = '_'}}, > mnesia:sync_transaction( > fun() -> > mnesia:delete_object(Record) > end), > mnesia:sync_transaction( > fun() -> > io:format("~p~n",[mnesia:match_object(Record)]) > end). > From joelr1@REDACTED Mon Oct 6 09:53:52 2008 From: joelr1@REDACTED (Joel Reymont) Date: Mon, 6 Oct 2008 08:53:52 +0100 Subject: [erlang-questions] Time to client > time to server?! Is my testing flawed? Please help me explain my results! Message-ID: Folks, I run Mac OSX 10.5.5 on a Mac Pro 2x2.8Ghz Xeon, 14Gb of memory. Erlang (BEAM) emulator version 5.6.3 [source] [64-bit] [smp:8] [async- threads:2] [kernel-poll:true] I found that when I run everything on a single VM and launch 500 games everything runs through just fine. I then distributed my OpenPoker test harness over 3 VMs: one hosts Mnesia tables and launches games, one runs games and launches bots, one runs the bots. The last two VMs are added as extra Mnesia nodes, i.e. have RAM copies of tables. Here's is when I started getting player timeouts. Each player (bot actually) is supposed to make a bet within 15 seconds but a lot of bots fail to do so in a distributed configuration. Unlike my previous testing, I now launch all games at the same time. There are about 5 players per game so 500 games would make about 2500 player bots and the same amount of open sockets. Dumping core upon a player timeout reveals that most of queue lengths are 0, a lot of queues have just 1 message in them and two queues have 2 messages. I decided to time packets and measure the time it takes for a packet to travel from the server to the client and from the client to the server. This is where I got results that I can't quite explain... The time a packet travels from a server to the client is consistently greater by a large margin!!! Would someone kindly offer an explanation? Rather than adding timestamps to each individual packet, I send a ping packet right after any packet the server sends out. I do this from my tcpsend macro, i.e. -define(tcpsend(Socket, Data), fun() -> XXX = pp:write(Data), case catch gen_tcp:send(Socket, XXX) of ok -> ok; ... end, YYY = pp:write(#ping{}), case catch gen_tcp:send(Socket, YYY) of ok -> ok; ... end end()). The ping packet looks like this: -record(ping, { send_time = now() }). Once a bot receives the ping packet, it sends a pong back: handle_ping(R, Bot) -> handle_cast(#pong{ orig_send_time = R#ping.send_time }, Bot), {noreply, Bot}. Here I copy the original send time into the pong packet and stamp it with send time on the bot side: -record(pong, { orig_send_time, send_time = now(), recv_time }). Once my server receives the pong packet, it plugs receive time in: process_pong(Client, _Socket, R) -> R1 = R#pong{ recv_time = now() }, gen_server:cast(Client#client.server, {'PONG', R1}), Client. I measure the time to client by subtracting original send time from the bot send time. The bots are dumb, they reply back as quickly as possible and don't contain any logic so there's should be very little overhead on the bot side. The time to server is the difference between time of receipt on the server side and the bot send time. handle_cast({'PONG', R = #pong{}}, Server) -> TC = timer:now_diff(R#pong.send_time, R#pong.orig_send_time), TS = timer:now_diff(R#pong.recv_time, R#pong.send_time), gen_server:cast(?STATS, {'AVG', time_to_client, TC}), gen_server:cast(?STATS, {'AVG', time_to_server, TS}), {noreply, Server}; I have a separate "statistics" server that keeps track of averages: handle_cast({'AVG', Id, New}, Data) -> Old = case gb_trees:lookup(Id, Data#stats.avg) of {value, Val} -> Val; none -> 0 end, Avg1 = gb_trees:enter(Id, (Old + New) / 2, Data#stats.avg), {noreply, Data#stats{ avg = Avg1 }}; When dumping stats, I divide averages by 1000 to get time in milliseconds. So far so good? Here are the results from testing on a single VM. Note that at some point the time to server starts to exceed the time to client. Timings from testing on a cluster of 3 VMs follow at the bottom. --- single VM --- gateway:start('1@REDACTED', 4000, 500000) Waiting for game servers... Starting a port server on 4000... Simulating gameplay with 500 games... 50 games started, 262 players 100 games started, 504 players 150 games started, 743 players 200 games started, 1019 players 250 games started, 1288 players 300 games started, 1529 players 350 games started, 1766 players 400 games started, 2057 players 450 games started, 2304 players 500 games started, 2562 players dmb: 500 games launching simultaneously dmb: waiting for games to end... =INFO REPORT==== 6-Oct-2008::08:14:55 === module: stats elapsed: 5.000022 time_to_client: 0.3116982504004592 time_to_server: 0.26828120427789537 bytes: 110919 packets: 6202 {bytes,per_sec}: 22183 {packets,per_sec}: 1240 =INFO REPORT==== 6-Oct-2008::08:15:00 === module: stats elapsed: 4.999943 time_to_client: 0.335493890834141 time_to_server: 0.2682274480913192 bytes: 35447 packets: 1984 {bytes,per_sec}: 7089 {packets,per_sec}: 396 =INFO REPORT==== 6-Oct-2008::08:15:10 === module: stats elapsed: 4.999295 time_to_client: 0.8764044453192754 time_to_server: 0.5871947161189068 bytes: 600493 packets: 25147 {bytes,per_sec}: 120115 {packets,per_sec}: 5030 =INFO REPORT==== 6-Oct-2008::08:15:15 === module: stats elapsed: 5.000729 time_to_client: 0.416 time_to_server: 198.9885 bytes: 25 packets: 1 {bytes,per_sec}: 4 {packets,per_sec}: 0 =INFO REPORT==== 6-Oct-2008::08:15:25 === module: stats elapsed: 5.131727 time_to_client: 4.039440742060922 time_to_server: 44.38444315504353 bytes: 49034 packets: 1979 {bytes,per_sec}: 9555 {packets,per_sec}: 385 =INFO REPORT==== 6-Oct-2008::08:15:30 === module: stats elapsed: 4.994361 time_to_client: 5.236234569474154 time_to_server: 15.505128105674318 bytes: 8907 packets: 358 {bytes,per_sec}: 1783 {packets,per_sec}: 71 50 games finished =INFO REPORT==== 6-Oct-2008::08:15:35 === module: stats elapsed: 4.923643 time_to_client: 7.458330178363772 time_to_server: 49.56836180504743 bytes: 14380 packets: 581 {bytes,per_sec}: 2920 {packets,per_sec}: 118 100 games finished 150 games finished =INFO REPORT==== 6-Oct-2008::08:15:40 === module: stats elapsed: 5.014354 time_to_client: 10.303327121777983 time_to_server: 64.27703119134696 bytes: 23849 packets: 960 {bytes,per_sec}: 4756 {packets,per_sec}: 191 200 games finished 250 games finished 300 games finished =INFO REPORT==== 6-Oct-2008::08:15:45 === module: stats elapsed: 4.973468 time_to_client: 13.492860654918857 time_to_server: 106.97844814674687 bytes: 28758 packets: 1162 {bytes,per_sec}: 5782 {packets,per_sec}: 233 350 games finished 400 games finished 450 games finished =INFO REPORT==== 6-Oct-2008::08:15:50 === module: stats elapsed: 4.965927 time_to_client: 20.687073726427755 time_to_server: 46.96422948544525 bytes: 76007 packets: 3071 {bytes,per_sec}: 15305 {packets,per_sec}: 618 500 games finished dmb: exited successfully, 58.529502 seconds elapsed ok (1@REDACTED)5> =INFO REPORT==== 6-Oct-2008::08:15:55 === module: stats elapsed: 4.996499 time_to_client: 1.8395921187621034 time_to_server: 3.3051747276788346 bytes: 3845004 packets: 161772 {bytes,per_sec}: 769539 {packets,per_sec}: 32377 Here are the baffling results from testing on a cluster of 3 separate VMs. Note that the time to client is consistently higher and reaches 3.5 seconds at the end, when the game VM is forced to crash upon a player timeout. --- Distributed --- (1@REDACTED)2> dmb:test(500) gateway:start('1@REDACTED', 4000, 500000) Waiting for game servers... Starting a port server on 4000... Simulating gameplay with 500 games... 50 games started, 262 players 100 games started, 504 players 150 games started, 743 players 200 games started, 1019 players 250 games started, 1288 players 300 games started, 1529 players 350 games started, 1766 players 400 games started, 2057 players 450 games started, 2304 players 500 games started, 2562 players dmb: 500 games launching simultaneously dmb: waiting for games to end... =INFO REPORT==== 6-Oct-2008::08:17:12 === module: stats elapsed: 5.000164 time_to_client: 0.7472338659989799 time_to_server: 0.2868026026862225 bytes: 97276 packets: 5438 {bytes,per_sec}: 19454 {packets,per_sec}: 1087 =INFO REPORT==== 6-Oct-2008::08:17:17 === module: stats elapsed: 4.999986 time_to_client: 0.9655462464556185 time_to_server: 0.30163815339577854 bytes: 49090 packets: 2748 {bytes,per_sec}: 9818 {packets,per_sec}: 549 =INFO REPORT==== 6-Oct-2008::08:17:22 === module: stats elapsed: 4.999992 =INFO REPORT==== 6-Oct-2008::08:17:27 === module: stats elapsed: 5.000022 time_to_client: 903.3217931168908 time_to_server: 8.179055363354317 bytes: 346499 packets: 14736 {bytes,per_sec}: 69299 {packets,per_sec}: 2947 =INFO REPORT==== 6-Oct-2008::08:17:32 === module: stats elapsed: 4.999981 time_to_client: 301.7944063249315 time_to_server: 0.13660450764194335 bytes: 254019 packets: 10412 {bytes,per_sec}: 50803 {packets,per_sec}: 2082 =INFO REPORT==== 6-Oct-2008::08:17:37 === module: stats elapsed: 5.000355 time_to_client: 185.66359294523173 time_to_server: 2.651532941434563 bytes: 63537 packets: 2565 {bytes,per_sec}: 12706 {packets,per_sec}: 512 =INFO REPORT==== 6-Oct-2008::08:17:42 === module: stats elapsed: 4.999885 time_to_client: 1501.014993336486 time_to_server: 35.811546393119464 bytes: 405683 packets: 16375 {bytes,per_sec}: 81138 {packets,per_sec}: 3275 vvvvv the game serving VM crash dumps here, as requested ** exception error: no case clause matching noconnection in function dmb:wait_for_games/1 (1@REDACTED)3> =INFO REPORT==== 6-Oct-2008::08:17:47 === module: stats elapsed: 4.999809 time_to_client: 3496.1493304273376 time_to_server: 0.09871293629933679 bytes: 286105 packets: 11573 {bytes,per_sec}: 57223 {packets,per_sec}: 2314 -- wagerlabs.com From joelr1@REDACTED Mon Oct 6 09:53:52 2008 From: joelr1@REDACTED (Joel Reymont) Date: Mon, 6 Oct 2008 08:53:52 +0100 Subject: [erlang-questions] Time to client > time to server?! Is my testing flawed? Please help me explain my results! Message-ID: Folks, I run Mac OSX 10.5.5 on a Mac Pro 2x2.8Ghz Xeon, 14Gb of memory. Erlang (BEAM) emulator version 5.6.3 [source] [64-bit] [smp:8] [async- threads:2] [kernel-poll:true] I found that when I run everything on a single VM and launch 500 games everything runs through just fine. I then distributed my OpenPoker test harness over 3 VMs: one hosts Mnesia tables and launches games, one runs games and launches bots, one runs the bots. The last two VMs are added as extra Mnesia nodes, i.e. have RAM copies of tables. Here's is when I started getting player timeouts. Each player (bot actually) is supposed to make a bet within 15 seconds but a lot of bots fail to do so in a distributed configuration. Unlike my previous testing, I now launch all games at the same time. There are about 5 players per game so 500 games would make about 2500 player bots and the same amount of open sockets. Dumping core upon a player timeout reveals that most of queue lengths are 0, a lot of queues have just 1 message in them and two queues have 2 messages. I decided to time packets and measure the time it takes for a packet to travel from the server to the client and from the client to the server. This is where I got results that I can't quite explain... The time a packet travels from a server to the client is consistently greater by a large margin!!! Would someone kindly offer an explanation? Rather than adding timestamps to each individual packet, I send a ping packet right after any packet the server sends out. I do this from my tcpsend macro, i.e. -define(tcpsend(Socket, Data), fun() -> XXX = pp:write(Data), case catch gen_tcp:send(Socket, XXX) of ok -> ok; ... end, YYY = pp:write(#ping{}), case catch gen_tcp:send(Socket, YYY) of ok -> ok; ... end end()). The ping packet looks like this: -record(ping, { send_time = now() }). Once a bot receives the ping packet, it sends a pong back: handle_ping(R, Bot) -> handle_cast(#pong{ orig_send_time = R#ping.send_time }, Bot), {noreply, Bot}. Here I copy the original send time into the pong packet and stamp it with send time on the bot side: -record(pong, { orig_send_time, send_time = now(), recv_time }). Once my server receives the pong packet, it plugs receive time in: process_pong(Client, _Socket, R) -> R1 = R#pong{ recv_time = now() }, gen_server:cast(Client#client.server, {'PONG', R1}), Client. I measure the time to client by subtracting original send time from the bot send time. The bots are dumb, they reply back as quickly as possible and don't contain any logic so there's should be very little overhead on the bot side. The time to server is the difference between time of receipt on the server side and the bot send time. handle_cast({'PONG', R = #pong{}}, Server) -> TC = timer:now_diff(R#pong.send_time, R#pong.orig_send_time), TS = timer:now_diff(R#pong.recv_time, R#pong.send_time), gen_server:cast(?STATS, {'AVG', time_to_client, TC}), gen_server:cast(?STATS, {'AVG', time_to_server, TS}), {noreply, Server}; I have a separate "statistics" server that keeps track of averages: handle_cast({'AVG', Id, New}, Data) -> Old = case gb_trees:lookup(Id, Data#stats.avg) of {value, Val} -> Val; none -> 0 end, Avg1 = gb_trees:enter(Id, (Old + New) / 2, Data#stats.avg), {noreply, Data#stats{ avg = Avg1 }}; When dumping stats, I divide averages by 1000 to get time in milliseconds. So far so good? Here are the results from testing on a single VM. Note that at some point the time to server starts to exceed the time to client. Timings from testing on a cluster of 3 VMs follow at the bottom. --- single VM --- gateway:start('1@REDACTED', 4000, 500000) Waiting for game servers... Starting a port server on 4000... Simulating gameplay with 500 games... 50 games started, 262 players 100 games started, 504 players 150 games started, 743 players 200 games started, 1019 players 250 games started, 1288 players 300 games started, 1529 players 350 games started, 1766 players 400 games started, 2057 players 450 games started, 2304 players 500 games started, 2562 players dmb: 500 games launching simultaneously dmb: waiting for games to end... =INFO REPORT==== 6-Oct-2008::08:14:55 === module: stats elapsed: 5.000022 time_to_client: 0.3116982504004592 time_to_server: 0.26828120427789537 bytes: 110919 packets: 6202 {bytes,per_sec}: 22183 {packets,per_sec}: 1240 =INFO REPORT==== 6-Oct-2008::08:15:00 === module: stats elapsed: 4.999943 time_to_client: 0.335493890834141 time_to_server: 0.2682274480913192 bytes: 35447 packets: 1984 {bytes,per_sec}: 7089 {packets,per_sec}: 396 =INFO REPORT==== 6-Oct-2008::08:15:10 === module: stats elapsed: 4.999295 time_to_client: 0.8764044453192754 time_to_server: 0.5871947161189068 bytes: 600493 packets: 25147 {bytes,per_sec}: 120115 {packets,per_sec}: 5030 =INFO REPORT==== 6-Oct-2008::08:15:15 === module: stats elapsed: 5.000729 time_to_client: 0.416 time_to_server: 198.9885 bytes: 25 packets: 1 {bytes,per_sec}: 4 {packets,per_sec}: 0 =INFO REPORT==== 6-Oct-2008::08:15:25 === module: stats elapsed: 5.131727 time_to_client: 4.039440742060922 time_to_server: 44.38444315504353 bytes: 49034 packets: 1979 {bytes,per_sec}: 9555 {packets,per_sec}: 385 =INFO REPORT==== 6-Oct-2008::08:15:30 === module: stats elapsed: 4.994361 time_to_client: 5.236234569474154 time_to_server: 15.505128105674318 bytes: 8907 packets: 358 {bytes,per_sec}: 1783 {packets,per_sec}: 71 50 games finished =INFO REPORT==== 6-Oct-2008::08:15:35 === module: stats elapsed: 4.923643 time_to_client: 7.458330178363772 time_to_server: 49.56836180504743 bytes: 14380 packets: 581 {bytes,per_sec}: 2920 {packets,per_sec}: 118 100 games finished 150 games finished =INFO REPORT==== 6-Oct-2008::08:15:40 === module: stats elapsed: 5.014354 time_to_client: 10.303327121777983 time_to_server: 64.27703119134696 bytes: 23849 packets: 960 {bytes,per_sec}: 4756 {packets,per_sec}: 191 200 games finished 250 games finished 300 games finished =INFO REPORT==== 6-Oct-2008::08:15:45 === module: stats elapsed: 4.973468 time_to_client: 13.492860654918857 time_to_server: 106.97844814674687 bytes: 28758 packets: 1162 {bytes,per_sec}: 5782 {packets,per_sec}: 233 350 games finished 400 games finished 450 games finished =INFO REPORT==== 6-Oct-2008::08:15:50 === module: stats elapsed: 4.965927 time_to_client: 20.687073726427755 time_to_server: 46.96422948544525 bytes: 76007 packets: 3071 {bytes,per_sec}: 15305 {packets,per_sec}: 618 500 games finished dmb: exited successfully, 58.529502 seconds elapsed ok (1@REDACTED)5> =INFO REPORT==== 6-Oct-2008::08:15:55 === module: stats elapsed: 4.996499 time_to_client: 1.8395921187621034 time_to_server: 3.3051747276788346 bytes: 3845004 packets: 161772 {bytes,per_sec}: 769539 {packets,per_sec}: 32377 Here are the baffling results from testing on a cluster of 3 separate VMs. Note that the time to client is consistently higher and reaches 3.5 seconds at the end, when the game VM is forced to crash upon a player timeout. --- Distributed --- (1@REDACTED)2> dmb:test(500) gateway:start('1@REDACTED', 4000, 500000) Waiting for game servers... Starting a port server on 4000... Simulating gameplay with 500 games... 50 games started, 262 players 100 games started, 504 players 150 games started, 743 players 200 games started, 1019 players 250 games started, 1288 players 300 games started, 1529 players 350 games started, 1766 players 400 games started, 2057 players 450 games started, 2304 players 500 games started, 2562 players dmb: 500 games launching simultaneously dmb: waiting for games to end... =INFO REPORT==== 6-Oct-2008::08:17:12 === module: stats elapsed: 5.000164 time_to_client: 0.7472338659989799 time_to_server: 0.2868026026862225 bytes: 97276 packets: 5438 {bytes,per_sec}: 19454 {packets,per_sec}: 1087 =INFO REPORT==== 6-Oct-2008::08:17:17 === module: stats elapsed: 4.999986 time_to_client: 0.9655462464556185 time_to_server: 0.30163815339577854 bytes: 49090 packets: 2748 {bytes,per_sec}: 9818 {packets,per_sec}: 549 =INFO REPORT==== 6-Oct-2008::08:17:22 === module: stats elapsed: 4.999992 =INFO REPORT==== 6-Oct-2008::08:17:27 === module: stats elapsed: 5.000022 time_to_client: 903.3217931168908 time_to_server: 8.179055363354317 bytes: 346499 packets: 14736 {bytes,per_sec}: 69299 {packets,per_sec}: 2947 =INFO REPORT==== 6-Oct-2008::08:17:32 === module: stats elapsed: 4.999981 time_to_client: 301.7944063249315 time_to_server: 0.13660450764194335 bytes: 254019 packets: 10412 {bytes,per_sec}: 50803 {packets,per_sec}: 2082 =INFO REPORT==== 6-Oct-2008::08:17:37 === module: stats elapsed: 5.000355 time_to_client: 185.66359294523173 time_to_server: 2.651532941434563 bytes: 63537 packets: 2565 {bytes,per_sec}: 12706 {packets,per_sec}: 512 =INFO REPORT==== 6-Oct-2008::08:17:42 === module: stats elapsed: 4.999885 time_to_client: 1501.014993336486 time_to_server: 35.811546393119464 bytes: 405683 packets: 16375 {bytes,per_sec}: 81138 {packets,per_sec}: 3275 vvvvv the game serving VM crash dumps here, as requested ** exception error: no case clause matching noconnection in function dmb:wait_for_games/1 (1@REDACTED)3> =INFO REPORT==== 6-Oct-2008::08:17:47 === module: stats elapsed: 4.999809 time_to_client: 3496.1493304273376 time_to_server: 0.09871293629933679 bytes: 286105 packets: 11573 {bytes,per_sec}: 57223 {packets,per_sec}: 2314 -- wagerlabs.com From joelr1@REDACTED Mon Oct 6 09:53:52 2008 From: joelr1@REDACTED (Joel Reymont) Date: Mon, 6 Oct 2008 08:53:52 +0100 Subject: [erlang-questions] Time to client > time to server?! Is my testing flawed? Please help me explain my results! Message-ID: Folks, I run Mac OSX 10.5.5 on a Mac Pro 2x2.8Ghz Xeon, 14Gb of memory. Erlang (BEAM) emulator version 5.6.3 [source] [64-bit] [smp:8] [async- threads:2] [kernel-poll:true] I found that when I run everything on a single VM and launch 500 games everything runs through just fine. I then distributed my OpenPoker test harness over 3 VMs: one hosts Mnesia tables and launches games, one runs games and launches bots, one runs the bots. The last two VMs are added as extra Mnesia nodes, i.e. have RAM copies of tables. Here's is when I started getting player timeouts. Each player (bot actually) is supposed to make a bet within 15 seconds but a lot of bots fail to do so in a distributed configuration. Unlike my previous testing, I now launch all games at the same time. There are about 5 players per game so 500 games would make about 2500 player bots and the same amount of open sockets. Dumping core upon a player timeout reveals that most of queue lengths are 0, a lot of queues have just 1 message in them and two queues have 2 messages. I decided to time packets and measure the time it takes for a packet to travel from the server to the client and from the client to the server. This is where I got results that I can't quite explain... The time a packet travels from a server to the client is consistently greater by a large margin!!! Would someone kindly offer an explanation? Rather than adding timestamps to each individual packet, I send a ping packet right after any packet the server sends out. I do this from my tcpsend macro, i.e. -define(tcpsend(Socket, Data), fun() -> XXX = pp:write(Data), case catch gen_tcp:send(Socket, XXX) of ok -> ok; ... end, YYY = pp:write(#ping{}), case catch gen_tcp:send(Socket, YYY) of ok -> ok; ... end end()). The ping packet looks like this: -record(ping, { send_time = now() }). Once a bot receives the ping packet, it sends a pong back: handle_ping(R, Bot) -> handle_cast(#pong{ orig_send_time = R#ping.send_time }, Bot), {noreply, Bot}. Here I copy the original send time into the pong packet and stamp it with send time on the bot side: -record(pong, { orig_send_time, send_time = now(), recv_time }). Once my server receives the pong packet, it plugs receive time in: process_pong(Client, _Socket, R) -> R1 = R#pong{ recv_time = now() }, gen_server:cast(Client#client.server, {'PONG', R1}), Client. I measure the time to client by subtracting original send time from the bot send time. The bots are dumb, they reply back as quickly as possible and don't contain any logic so there's should be very little overhead on the bot side. The time to server is the difference between time of receipt on the server side and the bot send time. handle_cast({'PONG', R = #pong{}}, Server) -> TC = timer:now_diff(R#pong.send_time, R#pong.orig_send_time), TS = timer:now_diff(R#pong.recv_time, R#pong.send_time), gen_server:cast(?STATS, {'AVG', time_to_client, TC}), gen_server:cast(?STATS, {'AVG', time_to_server, TS}), {noreply, Server}; I have a separate "statistics" server that keeps track of averages: handle_cast({'AVG', Id, New}, Data) -> Old = case gb_trees:lookup(Id, Data#stats.avg) of {value, Val} -> Val; none -> 0 end, Avg1 = gb_trees:enter(Id, (Old + New) / 2, Data#stats.avg), {noreply, Data#stats{ avg = Avg1 }}; When dumping stats, I divide averages by 1000 to get time in milliseconds. So far so good? Here are the results from testing on a single VM. Note that at some point the time to server starts to exceed the time to client. Timings from testing on a cluster of 3 VMs follow at the bottom. --- single VM --- gateway:start('1@REDACTED', 4000, 500000) Waiting for game servers... Starting a port server on 4000... Simulating gameplay with 500 games... 50 games started, 262 players 100 games started, 504 players 150 games started, 743 players 200 games started, 1019 players 250 games started, 1288 players 300 games started, 1529 players 350 games started, 1766 players 400 games started, 2057 players 450 games started, 2304 players 500 games started, 2562 players dmb: 500 games launching simultaneously dmb: waiting for games to end... =INFO REPORT==== 6-Oct-2008::08:14:55 === module: stats elapsed: 5.000022 time_to_client: 0.3116982504004592 time_to_server: 0.26828120427789537 bytes: 110919 packets: 6202 {bytes,per_sec}: 22183 {packets,per_sec}: 1240 =INFO REPORT==== 6-Oct-2008::08:15:00 === module: stats elapsed: 4.999943 time_to_client: 0.335493890834141 time_to_server: 0.2682274480913192 bytes: 35447 packets: 1984 {bytes,per_sec}: 7089 {packets,per_sec}: 396 =INFO REPORT==== 6-Oct-2008::08:15:10 === module: stats elapsed: 4.999295 time_to_client: 0.8764044453192754 time_to_server: 0.5871947161189068 bytes: 600493 packets: 25147 {bytes,per_sec}: 120115 {packets,per_sec}: 5030 =INFO REPORT==== 6-Oct-2008::08:15:15 === module: stats elapsed: 5.000729 time_to_client: 0.416 time_to_server: 198.9885 bytes: 25 packets: 1 {bytes,per_sec}: 4 {packets,per_sec}: 0 =INFO REPORT==== 6-Oct-2008::08:15:25 === module: stats elapsed: 5.131727 time_to_client: 4.039440742060922 time_to_server: 44.38444315504353 bytes: 49034 packets: 1979 {bytes,per_sec}: 9555 {packets,per_sec}: 385 =INFO REPORT==== 6-Oct-2008::08:15:30 === module: stats elapsed: 4.994361 time_to_client: 5.236234569474154 time_to_server: 15.505128105674318 bytes: 8907 packets: 358 {bytes,per_sec}: 1783 {packets,per_sec}: 71 50 games finished =INFO REPORT==== 6-Oct-2008::08:15:35 === module: stats elapsed: 4.923643 time_to_client: 7.458330178363772 time_to_server: 49.56836180504743 bytes: 14380 packets: 581 {bytes,per_sec}: 2920 {packets,per_sec}: 118 100 games finished 150 games finished =INFO REPORT==== 6-Oct-2008::08:15:40 === module: stats elapsed: 5.014354 time_to_client: 10.303327121777983 time_to_server: 64.27703119134696 bytes: 23849 packets: 960 {bytes,per_sec}: 4756 {packets,per_sec}: 191 200 games finished 250 games finished 300 games finished =INFO REPORT==== 6-Oct-2008::08:15:45 === module: stats elapsed: 4.973468 time_to_client: 13.492860654918857 time_to_server: 106.97844814674687 bytes: 28758 packets: 1162 {bytes,per_sec}: 5782 {packets,per_sec}: 233 350 games finished 400 games finished 450 games finished =INFO REPORT==== 6-Oct-2008::08:15:50 === module: stats elapsed: 4.965927 time_to_client: 20.687073726427755 time_to_server: 46.96422948544525 bytes: 76007 packets: 3071 {bytes,per_sec}: 15305 {packets,per_sec}: 618 500 games finished dmb: exited successfully, 58.529502 seconds elapsed ok (1@REDACTED)5> =INFO REPORT==== 6-Oct-2008::08:15:55 === module: stats elapsed: 4.996499 time_to_client: 1.8395921187621034 time_to_server: 3.3051747276788346 bytes: 3845004 packets: 161772 {bytes,per_sec}: 769539 {packets,per_sec}: 32377 Here are the baffling results from testing on a cluster of 3 separate VMs. Note that the time to client is consistently higher and reaches 3.5 seconds at the end, when the game VM is forced to crash upon a player timeout. --- Distributed --- (1@REDACTED)2> dmb:test(500) gateway:start('1@REDACTED', 4000, 500000) Waiting for game servers... Starting a port server on 4000... Simulating gameplay with 500 games... 50 games started, 262 players 100 games started, 504 players 150 games started, 743 players 200 games started, 1019 players 250 games started, 1288 players 300 games started, 1529 players 350 games started, 1766 players 400 games started, 2057 players 450 games started, 2304 players 500 games started, 2562 players dmb: 500 games launching simultaneously dmb: waiting for games to end... =INFO REPORT==== 6-Oct-2008::08:17:12 === module: stats elapsed: 5.000164 time_to_client: 0.7472338659989799 time_to_server: 0.2868026026862225 bytes: 97276 packets: 5438 {bytes,per_sec}: 19454 {packets,per_sec}: 1087 =INFO REPORT==== 6-Oct-2008::08:17:17 === module: stats elapsed: 4.999986 time_to_client: 0.9655462464556185 time_to_server: 0.30163815339577854 bytes: 49090 packets: 2748 {bytes,per_sec}: 9818 {packets,per_sec}: 549 =INFO REPORT==== 6-Oct-2008::08:17:22 === module: stats elapsed: 4.999992 =INFO REPORT==== 6-Oct-2008::08:17:27 === module: stats elapsed: 5.000022 time_to_client: 903.3217931168908 time_to_server: 8.179055363354317 bytes: 346499 packets: 14736 {bytes,per_sec}: 69299 {packets,per_sec}: 2947 =INFO REPORT==== 6-Oct-2008::08:17:32 === module: stats elapsed: 4.999981 time_to_client: 301.7944063249315 time_to_server: 0.13660450764194335 bytes: 254019 packets: 10412 {bytes,per_sec}: 50803 {packets,per_sec}: 2082 =INFO REPORT==== 6-Oct-2008::08:17:37 === module: stats elapsed: 5.000355 time_to_client: 185.66359294523173 time_to_server: 2.651532941434563 bytes: 63537 packets: 2565 {bytes,per_sec}: 12706 {packets,per_sec}: 512 =INFO REPORT==== 6-Oct-2008::08:17:42 === module: stats elapsed: 4.999885 time_to_client: 1501.014993336486 time_to_server: 35.811546393119464 bytes: 405683 packets: 16375 {bytes,per_sec}: 81138 {packets,per_sec}: 3275 vvvvv the game serving VM crash dumps here, as requested ** exception error: no case clause matching noconnection in function dmb:wait_for_games/1 (1@REDACTED)3> =INFO REPORT==== 6-Oct-2008::08:17:47 === module: stats elapsed: 4.999809 time_to_client: 3496.1493304273376 time_to_server: 0.09871293629933679 bytes: 286105 packets: 11573 {bytes,per_sec}: 57223 {packets,per_sec}: 2314 -- wagerlabs.com From erlang-questions_efine@REDACTED Mon Oct 6 12:20:53 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Mon, 6 Oct 2008 03:20:53 -0700 (PDT) Subject: [erlang-questions] Erlang external binary term format In-Reply-To: <19830781.post@talk.nabble.com> References: <19830781.post@talk.nabble.com> Message-ID: <19835272.post@talk.nabble.com> deepblue_other wrote: > > term_to_binary() outputs a binary. > what is the format of that binary? > is there a document someplace that gives the byte layout maybe? > This is what you want: http://erlang.org/doc/apps/erts/erl_ext_dist.html Erlang external term format documentation You might want to search the Erlang mailing list before asking questions. A lot of your questions may be answered already. For example, a search using the words "external term format" found the answer to your question in seconds using http://www.erlang.org/faq.html Search the Erlang Mailing Lists -- View this message in context: http://www.nabble.com/Erlang-external-binary-term-format-tp19830781p19835272.html Sent from the Erlang Questions mailing list archive at Nabble.com. From thomas.arts@REDACTED Mon Oct 6 10:41:56 2008 From: thomas.arts@REDACTED (Thomas Arts) Date: Mon, 06 Oct 2008 10:41:56 +0200 Subject: [erlang-questions] QuickCheck @ Erlang User Conference Message-ID: <48E9CF54.8070300@ituniv.se> Quviq provides a QuickCheck course before this years Erlang User Conference. The course will take place in Stockholm, November 10-12, 2008. The course is ment for Erlang developers interested in test driven development. The course consists of two and a half days with a mixture of theory and practical sessions, and includes a one month QuickCheck licence, which can be used to gain further experience with our tool after the course is over. November, 10: 9:00 - 17:00 Properties and generators, Symbolic test cases, Positive and negative testing. November, 11: 9:00 - 17:00 Testing stateful systems, Protocol testing. November 13: 9:00 - 13:00 Minimizing counter-examples. You can get more information and register for the course by email to thomas.arts@REDACTED Registration is on a first come, first served basis and the number of seats is restricted to a maximum of 12. The price is 12 500 sek per participant. This price is excluding hotel costs. Participants are expected to book their hotel themselves. The course is given in collaboration with Sj?land&Thyselius. /Thomas From joelr1@REDACTED Mon Oct 6 10:16:54 2008 From: joelr1@REDACTED (Joel Reymont) Date: Mon, 6 Oct 2008 09:16:54 +0100 Subject: [erlang-questions] Time to client > time to server?! Is my testing flawed? Please help me explain my results! In-Reply-To: References: Message-ID: <0BD13575-3DF8-4AFC-BE33-D45B09D4D7A9@gmail.com> Here's a more revealing set of latency measurements. I'm now tracking the maximum time to client and time to server. Note the peak latency of over 8 seconds in a distributed scenario. --- Single VM --- (1@REDACTED)4> dmb:test(500). gateway:start('1@REDACTED', 4000, 500000) Waiting for game servers... Starting a port server on 4000... Simulating gameplay with 500 games... 50 games started, 262 players 100 games started, 504 players 150 games started, 743 players 200 games started, 1019 players 250 games started, 1288 players 300 games started, 1529 players 350 games started, 1766 players 400 games started, 2057 players 450 games started, 2304 players 500 games started, 2562 players dmb: 500 games launching simultaneously dmb: waiting for games to end... =INFO REPORT==== 6-Oct-2008::09:03:52 === module: stats elapsed: 10.000245 {time_to_client,max}: 4.32 {time_to_server,max}: 2.841 {time_to_client,avg}: 0.2320246180635134 {time_to_server,avg}: 0.22264713927830931 bytes: 146366 packets: 8186 {bytes,per_sec}: 14636 {packets,per_sec}: 818 =INFO REPORT==== 6-Oct-2008::09:04:02 === module: stats elapsed: 10.001825 {time_to_client,max}: 11.05 {time_to_server,max}: 411.33 {time_to_client,avg}: 1.5062184064818505 {time_to_server,avg}: 0.7171950578502572 bytes: 448415 packets: 18778 {bytes,per_sec}: 44833 {packets,per_sec}: 1877 =INFO REPORT==== 6-Oct-2008::09:04:12 === module: stats elapsed: 9.998174 {time_to_client,max}: 12.69 {time_to_server,max}: 418.076 {time_to_client,avg}: 0.4114940672586087 {time_to_server,avg}: 289.4916230003739 bytes: 152103 packets: 6370 {bytes,per_sec}: 15213 {packets,per_sec}: 637 =INFO REPORT==== 6-Oct-2008::09:04:22 === module: stats elapsed: 10.120701 {time_to_client,max}: 13.341 {time_to_server,max}: 49.669 {time_to_client,avg}: 5.355944891472721 {time_to_server,avg}: 5.743951365303288 bytes: 41369 packets: 1670 {bytes,per_sec}: 4087 {packets,per_sec}: 165 50 games finished 100 games finished 150 games finished =INFO REPORT==== 6-Oct-2008::09:04:32 === module: stats elapsed: 9.963557 {time_to_client,max}: 10.079 {time_to_server,max}: 83.54 {time_to_client,avg}: 7.568428330186793 {time_to_server,avg}: 47.86868493253832 bytes: 23612 packets: 951 {bytes,per_sec}: 2369 {packets,per_sec}: 95 200 games finished ... 450 games finished =INFO REPORT==== 6-Oct-2008::09:04:42 === module: stats elapsed: 9.924854 {time_to_client,max}: 25.995 {time_to_server,max}: 228.509 {time_to_client,avg}: 12.582011113358574 {time_to_server,avg}: 63.03305165784938 bytes: 56429 packets: 2277 {bytes,per_sec}: 5685 {packets,per_sec}: 229 500 games finished dmb: exited successfully, 58.173462 seconds elapsed ok (1@REDACTED)5> =INFO REPORT==== 6-Oct-2008::09:04:52 === module: stats elapsed: 9.990864 {time_to_client,max}: 242.641 {time_to_server,max}: 2591.385 {time_to_client,avg}: 1.396611881112888 {time_to_server,avg}: 4.433587847758173 bytes: 3924494 packets: 164982 {bytes,per_sec}: 392808 {packets,per_sec}: 16513 --- Distributed over 3 VMs --- (1@REDACTED)2> dmb:test(500). gateway:start('1@REDACTED', 4000, 500000) Waiting for game servers... Starting a port server on 4000... Simulating gameplay with 500 games... 50 games started, 262 players 100 games started, 504 players 150 games started, 743 players 200 games started, 1019 players 250 games started, 1288 players 300 games started, 1529 players 350 games started, 1766 players 400 games started, 2057 players 450 games started, 2304 players 500 games started, 2562 players dmb: 500 games launching simultaneously dmb: waiting for games to end... =INFO REPORT==== 6-Oct-2008::09:14:51 === module: stats elapsed: 10.000883 {time_to_client,max}: 6.587 {time_to_server,max}: 3.25 {time_to_client,avg}: 0.8858832584049455 {time_to_server,avg}: 0.3519747484853795 bytes: 146366 packets: 8186 {bytes,per_sec}: 14635 {packets,per_sec}: 818 =INFO REPORT==== 6-Oct-2008::09:15:01 === module: stats elapsed: 10.000688 {time_to_client,max}: 904.376 {time_to_server,max}: 180.778 {time_to_client,avg}: 392.1472970779772 {time_to_server,avg}: 11.501733445497706 bytes: 159498 packets: 6790 {bytes,per_sec}: 15948 {packets,per_sec}: 678 =INFO REPORT==== 6-Oct-2008::09:15:11 === module: stats elapsed: 9.998408 {time_to_client,max}: 2736.19 {time_to_server,max}: 453.471 {time_to_client,avg}: 287.5398604052754 {time_to_server,avg}: 0.3376213403517969 bytes: 441020 packets: 18358 {bytes,per_sec}: 44109 {packets,per_sec}: 1836 =INFO REPORT==== 6-Oct-2008::09:15:21 === module: stats elapsed: 10.000147 {time_to_client,max}: 7792.444 {time_to_server,max}: 748.145 {time_to_client,avg}: 6795.083519124172 {time_to_server,avg}: 1.8773269961041452 bytes: 696655 packets: 28135 {bytes,per_sec}: 69664 {packets,per_sec}: 2813 (1@REDACTED)3> =INFO REPORT==== 6-Oct-2008::09:15:31 === module: stats elapsed: 9.999866 {time_to_client,max}: 8154.04 {time_to_server,max}: 728.917 {time_to_client,avg}: 6218.081375635741 {time_to_server,avg}: 58.365337024422914 bytes: 48660 packets: 1972 {bytes,per_sec}: 4866 {packets,per_sec}: 197 From vychodil.hynek@REDACTED Mon Oct 6 12:11:47 2008 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Mon, 6 Oct 2008 12:11:47 +0200 Subject: [erlang-questions] Erlang external binary term format In-Reply-To: <19830881.post@talk.nabble.com> References: <19830781.post@talk.nabble.com> <19830881.post@talk.nabble.com> Message-ID: <20081006101148.335C22407D@relay.gooddata.com> Just RTM http://www.erlang.org/doc/apps/erts/erl_ext_dist.html#8 On Mon, Oct 6, 2008 at 3:29 AM, deepblue_other wrote: > > for example > one day I was looking at the term_to_binary() output of > {binaries,"are",useful} > and it was: > > 131,104,3,100,0,8,98,105,110,97,114,105,101,115,107,0,3,97,114,101,100,0,6,117,115,101,102,117,108 > > so with a little experimentation with other tuples I got these rules so > far: > 131,104 - this means that its a tuple > 3 - this means that it has 3 terms > 100 and 107 - type code - in this case 100 stands for atoms, and 107 stands > for strings > 0 - is the separator between the "type code"(name I gave it > just now ;) ) and the actual ASCII sequence > 8 and 3(again) and 6 - these indicate the length of the binary sequence > (number of ASCII characters in this case > > so: > binaries - 100(type code),0,8(byte length),98,105,110,97,114,105,101,115 > "are" - 107(type code),0,3(byte length),97,114,101 > useful - 100(type code),0,6(byte length),117,115,101,102,117,108 > > this just explains a limited set, doesnt go into lists... > I could be wrong, but the rules seem to match up other examples as well > > thanks > > deepblue_other wrote: > > > > term_to_binary() outputs a binary. > > what is the format of that binary? I would like to create a > > "unpacker/packer" for that format in ActionScript3, and avoid the use of > > XML (which Im using now for Flash-to-Erlang) communication altogether. it > > would be faster, less code, and much more efficient from the bandwidth > > point of view. > > > > is there a document someplace that gives the byte layout maybe? > > thank you > > > > -- > View this message in context: > http://www.nabble.com/Erlang-external-binary-term-format-tp19830781p19830881.html > Sent from the Erlang Questions mailing list archive at Nabble.com. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- --Hynek (Pichi) Vychodil -------------- next part -------------- An HTML attachment was scrubbed... URL: From cktgatb@REDACTED Mon Oct 6 17:21:56 2008 From: cktgatb@REDACTED (deepblue_other) Date: Mon, 6 Oct 2008 08:21:56 -0700 (PDT) Subject: [erlang-questions] wierd "function not used" problem - code included In-Reply-To: <19830744.post@talk.nabble.com> References: <19826465.post@talk.nabble.com> <19827659.post@talk.nabble.com> <19827696.post@talk.nabble.com> <19827720.post@talk.nabble.com> <19828568.post@talk.nabble.com> <19829936.post@talk.nabble.com> <19830744.post@talk.nabble.com> Message-ID: <19840082.post@talk.nabble.com> Edwin Fine wrote: > > > deepblue_other wrote: >> >> so when I want to use spawn_link() with a named function that function >> has to be exported? >> same stands for regular spawn()? >> > Yes, if you use a spawn that takes Module, Function, Args, like spawn/3, > spawn/4, spawn_link/3, spawn_link/4,.... Or apply/3. And so on. > > In general if you provide a so-called "MFA" (Module, Func, Args) to a > function, the Func has to be exported from Module, even if the Func is > only for internal use within Module. > > It's important to know that the shell is your friend. It's critical to try > out little pieces of code in the shell to see if they work the way you > expect. For example, if you wanted to see if spawn could see your > data_process function, you could have tried it in the shell (I'm passing > the atom 'junk' instead of a real socket because I know the call will fail > because it's not exported, so the socket is not needed): > > 1> c(tcp_manager). > ./tcp_manager.erl:33: Warning: function data_process/2 is unused > {ok,tcp_manager} > 2> spawn(tcp_manager, data_process, [junk, []]). > <0.40.0> > 3> > =ERROR REPORT==== 5-Oct-2008::20:49:23 === > Error in process <0.40.0> with exit value: > {undef,[{tcp_manager,data_process,[junk,[]]}]} > > deepblue_other wrote: >> >> just a side question: >> once a certain "receive" configuration is set for a process it can never >> be changed to another "receive" configuration? it just popped in my head >> here when you said that i can inline the error "receive". >> > > I perhaps did not make myself clear. What I meant by saying you could > inline it is that I didn't see the value of writing > > Fun = fun() -> do_something(), do_something_else() end, > Fun(). > > That's the same as writing > > do_something(), > do_something_else() > no I understood what you wanted to say, I just had a case in my mind where for example a "receive configuration" is active for a process, and a message that matches comes in, and the clause starts executing its expressions and one of the expressions calls another function that within it contains another "receive configuration" - the new configuration would now be active, and the old one would stop? also the expressions listed bellow a "receive configuration" are executed even though the "receive" essentially blocks the process in waiting state? as you can tell Im slightly confused as to how the "receive" affects the present/future activity of a process Edwin Fine wrote: > > It is better in this case to put the code into a separate function. > Better, because you can hot-swap the code and change that function. > > There's an excellent article about hot code swapping > http://http://spawnlink.com/articles/rules-of-hot-code-swapping/ here . > I will read this through now Edwin Fine wrote: > > > >> %----------------------------------------------- >> Listen_for_errors = >> fun() -> >> io:format("listening started~n"), >> receive >> {'EXIT', Pid, Why} -> >> io:format("~p exited because:~p", [Pid,Why]); >> Other -> >> io:format("Other:~p~n", [Other]) >> end >> end, >> Listen_for_errors(), >> %----------------------------------------------- >> > Finally, I'm not sure what Listen_for_errors() is supposed to do. It's > just going to sit there forever in the receive, waiting for the first > message that is sent (or en exit signal), and print it out (thus throwing > it away), and return. What did you want it to do? > Listen_for_errors() was meant to catch the errors that were produced because I didnt export the function I used in spawn_link() :) and just to see if the data was coming in from the client. thanks Edwin -- View this message in context: http://www.nabble.com/wierd-%22function-not-used%22-problem---code-included-tp19826465p19840082.html Sent from the Erlang Questions mailing list archive at Nabble.com. From kenneth.lundin@REDACTED Mon Oct 6 12:56:58 2008 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Mon, 6 Oct 2008 12:56:58 +0200 Subject: [erlang-questions] Erlang external binary term format In-Reply-To: <19830881.post@talk.nabble.com> References: <19830781.post@talk.nabble.com> <19830881.post@talk.nabble.com> Message-ID: You find the documentation of the Erlang external term format here: http://www.erlang.org/doc/apps/erts/erl_ext_dist.html#8 (It is chapter 8 of the ERTS Users Guide) /Kenneth Erlang/OTP tema, Ericsson On Mon, Oct 6, 2008 at 3:29 AM, deepblue_other wrote: > > for example > one day I was looking at the term_to_binary() output of > {binaries,"are",useful} > and it was: > 131,104,3,100,0,8,98,105,110,97,114,105,101,115,107,0,3,97,114,101,100,0,6,117,115,101,102,117,108 > > so with a little experimentation with other tuples I got these rules so far: > 131,104 - this means that its a tuple > 3 - this means that it has 3 terms > 100 and 107 - type code - in this case 100 stands for atoms, and 107 stands > for strings > 0 - is the separator between the "type code"(name I gave it > just now ;) ) and the actual ASCII sequence > 8 and 3(again) and 6 - these indicate the length of the binary sequence > (number of ASCII characters in this case > > so: > binaries - 100(type code),0,8(byte length),98,105,110,97,114,105,101,115 > "are" - 107(type code),0,3(byte length),97,114,101 > useful - 100(type code),0,6(byte length),117,115,101,102,117,108 > > this just explains a limited set, doesnt go into lists... > I could be wrong, but the rules seem to match up other examples as well > > thanks > > deepblue_other wrote: >> >> term_to_binary() outputs a binary. >> what is the format of that binary? I would like to create a >> "unpacker/packer" for that format in ActionScript3, and avoid the use of >> XML (which Im using now for Flash-to-Erlang) communication altogether. it >> would be faster, less code, and much more efficient from the bandwidth >> point of view. >> >> is there a document someplace that gives the byte layout maybe? >> thank you >> > > -- > View this message in context: http://www.nabble.com/Erlang-external-binary-term-format-tp19830781p19830881.html > Sent from the Erlang Questions mailing list archive at Nabble.com. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From bengt.kleberg@REDACTED Mon Oct 6 11:20:46 2008 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Mon, 06 Oct 2008 11:20:46 +0200 Subject: [erlang-questions] Erlang timer program - feedback please In-Reply-To: <4d775bd70810031152g57c4f217vd181a8b3db3248db@mail.gmail.com> References: <4d775bd70810031152g57c4f217vd181a8b3db3248db@mail.gmail.com> Message-ID: <1223284849.17611.28.camel@seasc0642.dyn.rnd.as.sw.ericsson.se> Greetings, If you want to call/send at a regular interval you might want to use timer:apply_interval/4 or timer:send_interval/2 in http://erlang.org/doc/man/timer.html bengt On Fri, 2008-10-03 at 11:52 -0700, Sean Payne wrote: > I am hoping someone with more Erlang experience than me could give me > some feedback on the timer code below. > > I am using erlang:start_timer and tail recursion with a paused state > and a running state to create a little simulation > * world:init(). inits the sim > * world:run(). starts the updates (right now updates just print out > "updating") > * world:pause(). pauses the updates > * world:destroy(). shuts it down > > So my questions are: > 1) Is there a better way (timer wise) to do this. I suspect that the > way I am using the timer that my update_now will not be called at the > right frequency because of the delay between when the event fires and > when the next event is scheduled. > > 2) Is there a better way Erlang wise to do something like this. I am > new to Erlang, so I am curious if this is the approach that someone > with more experience would take. Is this how you would write > this????? > > 3) Are there any bugs or leaks? ie am I using Tail recursion > correctly? (every time I pause or unpause the program, am I going > deeper into the stack?) > > Thanks, > > Sean > > ========================================= > -module(world). > > %% External interfaces > %% world:init sets up the world (into the paused state) > %% world:run starts the timers and updates every UPDATE_INTERVAL > %% world:stop pauses the world > %% world:destroy destroys the world > -export([init/0]). > -export([run/0]). > -export([stop/0]). > -export([destroy/0]). > > %% internal functions but must be exported to receive events from > erlang:start_timer > -export([handle_events_while_stopped/0]). > -export([handle_events_while_running/0]). > > -define(UPDATE_INTERVAL,1000). > > handle_events_while_stopped() -> > receive > finished-> > io:format("world is finished~n", []); > run-> > io:format("world is running~n", []), > erlang:start_timer(?UPDATE_INTERVAL, self(), update_now), > handle_events_while_running() > end. > > handle_events_while_running() -> > receive > finished-> > io:format("world is finished~n", []); > stop-> > io:format("world is stopping~n", []), > handle_events_while_stopped(); > {timeout, _ , update_now} -> > io:format("updating~n", []), > erlang:start_timer(?UPDATE_INTERVAL, self(), update_now), > handle_events_while_running() > end. > > > init() -> > register(world, spawn(world, handle_events_while_stopped,[])). > > run()-> > world ! run. > > stop()-> > world ! stop. > > destroy()-> > world ! finished. > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From joelr1@REDACTED Mon Oct 6 14:36:33 2008 From: joelr1@REDACTED (Joel Reymont) Date: Mon, 6 Oct 2008 13:36:33 +0100 Subject: [erlang-questions] latency of smp vs non-smp + optimizing throughput In-Reply-To: <0BD13575-3DF8-4AFC-BE33-D45B09D4D7A9@gmail.com> References: <0BD13575-3DF8-4AFC-BE33-D45B09D4D7A9@gmail.com> Message-ID: I seem to do much better running 3 non-SMP VMs (-smp disable) on my Mac, at least 500 games run to completion without any drastic increases in latency. SMP vs non-SMP stats are at the bottom of this email but briefly looking at the last statistics dump: SMP disabled: {time_to_client,avg}: 224.20649573953042 {time_to_server,avg}: 71.4781241171356 SMP enabled: {time_to_client,avg}: 3586.21374521735 {time_to_server,avg}: 0.345146548308556 I thought that the increase in outgoing latency is due to the sheer amount of data that I'm pumping out. For example, every 10 seconds I get this much data in bytes_in: 793628 {bytes_in,per_sec}: 79362 packets_in: 32108 {packets_in,per_sec}: 3210 which gives decent incoming latency {time_to_server,min}: 23.144 {time_to_server,avg}: 71.4781241171356 {time_to_server,max}: 488.238 I'm pumping out almost as much data, though bytes_out: 778418 {bytes_out,per_sec}: 77841 but in twice as many packets. packets_out: 63074 {packets_out,per_sec}: 6307 This gives me a much higher outgoing latency that I'm still scratching my head over. {time_to_client,min}: 34.8 {time_to_client,avg}: 224.20649573953042 {time_to_client,max}: 2599.91 Any suggestions on how to optimize this? Thanks, Joel --- SMP disabled --- Erlang (BEAM) emulator version 5.6.3 [source] [64-bit] [async-threads: 0] [kernel-poll:true] (1@REDACTED)2> dmb:test(500). gateway:start('1@REDACTED', 4000, 500000) Waiting for game servers... Starting a port server on 4000... Simulating gameplay with 500 games... 50 games started, 262 players 100 games started, 504 players 150 games started, 743 players 200 games started, 1019 players 250 games started, 1288 players 300 games started, 1529 players 350 games started, 1766 players 400 games started, 2057 players 450 games started, 2304 players 500 games started, 2562 players dmb: 500 games launching simultaneously dmb: waiting for games to end... =INFO REPORT==== 6-Oct-2008::13:21:03 === module: stats elapsed: 10.000171 bytes_in: 146366 bytes_out: 46116 packets_in: 8186 packets_out: 5124 {bytes_in,per_sec}: 14636 {bytes_out,per_sec}: 4611 {packets_in,per_sec}: 818 {packets_out,per_sec}: 512 {time_to_client,min}: 0.39 {time_to_server,min}: 0.053 {time_to_client,max}: 4.65 {time_to_server,max}: 3.243 {time_to_client,avg}: 0.7572145936482696 {time_to_server,avg}: 0.2872718335693714 =INFO REPORT==== 6-Oct-2008::13:21:13 === module: stats elapsed: 10.000046 bytes_in: 113721 bytes_out: 446136 packets_in: 4797 packets_out: 30062 {bytes_in,per_sec}: 11372 {bytes_out,per_sec}: 44613 {packets_in,per_sec}: 479 {packets_out,per_sec}: 3006 {time_to_client,min}: 0.29 {time_to_server,min}: 0.085 {time_to_client,max}: 31.137 {time_to_server,max}: 37.724 {time_to_client,avg}: 17.673999912193082 {time_to_server,avg}: 9.69423139935136 =INFO REPORT==== 6-Oct-2008::13:21:23 === module: stats elapsed: 9.999948 bytes_in: 486797 bytes_out: 220674 packets_in: 20351 packets_out: 15110 {bytes_in,per_sec}: 48679 {bytes_out,per_sec}: 22067 {packets_in,per_sec}: 2035 {packets_out,per_sec}: 1511 {time_to_client,min}: 0.466 {time_to_server,min}: 1.573 {time_to_client,max}: 39.079 {time_to_server,max}: 61.043 {time_to_client,avg}: 0.9661870246546748 {time_to_server,avg}: 1.7370862806690366 =INFO REPORT==== 6-Oct-2008::13:21:33 === module: stats elapsed: 10.000047 bytes_in: 42489 bytes_out: 1827059 packets_in: 1713 packets_out: 148182 {bytes_in,per_sec}: 4248 {bytes_out,per_sec}: 182705 {packets_in,per_sec}: 171 {packets_out,per_sec}: 14818 {time_to_client,min}: 0.241 {time_to_server,min}: 0.063 {time_to_client,max}: 216.895 {time_to_server,max}: 35.445 {time_to_client,avg}: 90.84005908047558 {time_to_server,avg}: 9.594852014216947 =INFO REPORT==== 6-Oct-2008::13:21:43 === module: stats elapsed: 9.999926 bytes_in: 186974 bytes_out: 1309921 packets_in: 7550 packets_out: 109166 {bytes_in,per_sec}: 18697 {bytes_out,per_sec}: 130993 {packets_in,per_sec}: 755 {packets_out,per_sec}: 10916 {time_to_client,min}: 13.339 {time_to_server,min}: 4.094 {time_to_client,max}: 548.193 {time_to_server,max}: 168.099 {time_to_client,avg}: 257.6465068927692 {time_to_server,avg}: 40.70231906170637 dmb: exited successfully, 53.110242 seconds elapsed ok (1@REDACTED)3> halt(). =INFO REPORT==== 6-Oct-2008::13:21:53 === module: stats elapsed: 10.000018 bytes_in: 793628 bytes_out: 778418 packets_in: 32108 packets_out: 63074 {bytes_in,per_sec}: 79362 {bytes_out,per_sec}: 77841 {packets_in,per_sec}: 3210 {packets_out,per_sec}: 6307 {time_to_client,min}: 34.8 {time_to_server,min}: 23.144 {time_to_client,max}: 2599.91 {time_to_server,max}: 488.238 {time_to_client,avg}: 224.20649573953042 {time_to_server,avg}: 71.4781241171356 --- SMP enabled --- Doesn't run through and is made to crash on a timeout. Erlang (BEAM) emulator version 5.6.3 [source] [64-bit] [smp:8] [async- threads:0] [kernel-poll:true] (1@REDACTED)2> dmb:test(500). gateway:start('1@REDACTED', 4000, 500000) Waiting for game servers... Starting a port server on 4000... Simulating gameplay with 500 games... 50 games started, 262 players 100 games started, 504 players 150 games started, 743 players 200 games started, 1019 players 250 games started, 1288 players 300 games started, 1529 players 350 games started, 1766 players 400 games started, 2057 players 450 games started, 2304 players 500 games started, 2562 players dmb: 500 games launching simultaneously dmb: waiting for games to end... =INFO REPORT==== 6-Oct-2008::13:26:56 === module: stats elapsed: 10.001047 bytes_in: 129677 bytes_out: 40914 packets_in: 7252 packets_out: 4546 {bytes_in,per_sec}: 12966 {bytes_out,per_sec}: 4090 {packets_in,per_sec}: 725 {packets_out,per_sec}: 454 {time_to_client,min}: 0.479 {time_to_server,min}: 0.064 {time_to_client,max}: 2.798 {time_to_server,max}: 2.383 {time_to_client,avg}: 1.0302147870344318 {time_to_server,avg}: 1.0730058206685198 =INFO REPORT==== 6-Oct-2008::13:27:06 === module: stats elapsed: 9.999979 bytes_in: 73372 bytes_out: 119961 packets_in: 3343 packets_out: 8176 {bytes_in,per_sec}: 7337 {bytes_out,per_sec}: 11996 {packets_in,per_sec}: 334 {packets_out,per_sec}: 817 {time_to_client,min}: 0.556 {time_to_server,min}: 0.067 {time_to_client,max}: 207.146 {time_to_server,max}: 60.546 {time_to_client,avg}: 114.43896301514758 {time_to_server,avg}: 0.8372796687202076 =INFO REPORT==== 6-Oct-2008::13:27:16 === module: stats elapsed: 9.998979 bytes_in: 543835 bytes_out: 552051 packets_in: 22739 packets_out: 37574 {bytes_in,per_sec}: 54389 {bytes_out,per_sec}: 55210 {packets_in,per_sec}: 2274 {packets_out,per_sec}: 3757 {time_to_client,min}: 26.731 {time_to_server,min}: 0.067 {time_to_client,max}: 2600.522 {time_to_server,max}: 430.95 {time_to_client,avg}: 281.00073907216733 {time_to_server,avg}: 0.7417702616026968 =INFO REPORT==== 6-Oct-2008::13:27:26 === module: stats elapsed: 10.00179 bytes_in: 333568 bytes_out: 1035862 packets_in: 13460 packets_out: 81032 {bytes_in,per_sec}: 33350 {bytes_out,per_sec}: 103567 {packets_in,per_sec}: 1345 {packets_out,per_sec}: 8101 {time_to_client,min}: 0.979 {time_to_server,min}: 0.069 {time_to_client,max}: 3687.48 {time_to_server,max}: 596.026 {time_to_client,avg}: 622.5489355064024 {time_to_server,avg}: 1.83386123075884 ** exception error: no case clause matching noconnection in function dmb:wait_for_games/1 (1@REDACTED)3> =INFO REPORT==== 6-Oct-2008::13:27:36 === module: stats elapsed: 9.998224 bytes_in: 153581 bytes_out: 99958 packets_in: 6205 packets_out: 8446 {bytes_in,per_sec}: 15360 {bytes_out,per_sec}: 9997 {packets_in,per_sec}: 620 {packets_out,per_sec}: 844 {time_to_client,min}: 298.654 {time_to_server,min}: 0.078 {time_to_client,max}: 5431.219 {time_to_server,max}: 794.497 {time_to_client,avg}: 3586.21374521735 {time_to_server,avg}: 0.345146548308556 --- http://wagerlabs.com From joelr1@REDACTED Mon Oct 6 15:34:01 2008 From: joelr1@REDACTED (Joel Reymont) Date: Mon, 6 Oct 2008 14:34:01 +0100 Subject: [erlang-questions] latency of smp vs non-smp + optimizing throughput In-Reply-To: References: <0BD13575-3DF8-4AFC-BE33-D45B09D4D7A9@gmail.com> Message-ID: <3598ECD4-8216-43F1-9719-983D33557F78@gmail.com> The good news here is that Solaris/Opteron (Nevada) doesn't seem to break a sweat. Note that SMP is disabled. Erlang (BEAM) emulator version 5.6.4 [source] [async-threads:0] [hipe] [kernel-poll:true] --- 3k games, 15K players, 3 VMs --- (1@REDACTED)2> dmb:test(3000). gateway:start('1@REDACTED', 4000, 500000) Waiting for game servers... Starting a port server on 4000... Simulating gameplay with 3000 games... 50 games started, 262 players ... 3000 games started, 15115 players dmb: 3000 games launching simultaneously dmb: waiting for games to end... =INFO REPORT==== 6-Oct-2008::13:24:59 === module: stats elapsed: 10.000873 bytes_in: 68767 bytes_out: 21636 packets_in: 3842 packets_out: 2404 {bytes_in,per_sec}: 6876 {bytes_out,per_sec}: 2163 {packets_in,per_sec}: 384 {packets_out,per_sec}: 240 {time_to_client,min}: 0.328 {time_to_server,min}: -0.153 {time_to_client,max}: 15.524 {time_to_server,max}: 7.772 {time_to_client,avg}: 0.9502826468283405 {time_to_server,avg}: 0.5327277638966361 =INFO REPORT==== 6-Oct-2008::13:25:09 === module: stats elapsed: 10.001858 bytes_in: 282707 bytes_out: 88956 packets_in: 15795 packets_out: 9884 {bytes_in,per_sec}: 28265 {bytes_out,per_sec}: 8893 {packets_in,per_sec}: 1579 {packets_out,per_sec}: 988 {time_to_client,min}: 0.342 {time_to_server,min}: -0.154 {time_to_client,max}: 32.193 {time_to_server,max}: 9.188 {time_to_client,avg}: 0.5440724004487766 {time_to_server,avg}: 0.16925260605105938 =INFO REPORT==== 6-Oct-2008::13:25:19 === module: stats elapsed: 9.998239 bytes_in: 1017300 bytes_out: 1076952 packets_in: 43558 packets_out: 73806 {bytes_in,per_sec}: 101747 {bytes_out,per_sec}: 107714 {packets_in,per_sec}: 4356 {packets_out,per_sec}: 7381 {time_to_client,min}: 0.273 {time_to_server,min}: -0.166 {time_to_client,max}: 17.486 {time_to_server,max}: 36.317 {time_to_client,avg}: 0.8381414371981343 {time_to_server,avg}: -0.06003086403873219 =INFO REPORT==== 6-Oct-2008::13:25:29 === module: stats elapsed: 9.999059 bytes_in: 941158 bytes_out: 2475950 packets_in: 39362 packets_out: 190330 {bytes_in,per_sec}: 94124 {bytes_out,per_sec}: 247618 {packets_in,per_sec}: 3936 {packets_out,per_sec}: 19034 {time_to_client,min}: 0.27 {time_to_server,min}: -0.167 {time_to_client,max}: 140.496 {time_to_server,max}: 13.837 {time_to_client,avg}: 85.4554748230033 {time_to_server,avg}: 3.818637893852275 =INFO REPORT==== 6-Oct-2008::13:25:39 === module: stats elapsed: 10.001362 bytes_in: 537800 bytes_out: 3835109 packets_in: 22175 packets_out: 309980 {bytes_in,per_sec}: 53772 {bytes_out,per_sec}: 383458 {packets_in,per_sec}: 2217 {packets_out,per_sec}: 30993 {time_to_client,min}: 6.174 {time_to_server,min}: 0.252 {time_to_client,max}: 1159.445 {time_to_server,max}: 54.943 {time_to_client,avg}: 223.2975698054841 {time_to_server,avg}: 22.01449211439593 =INFO REPORT==== 6-Oct-2008::13:25:49 === module: stats elapsed: 9.998972 bytes_in: 791081 bytes_out: 2707910 packets_in: 32433 packets_out: 225746 {bytes_in,per_sec}: 79116 {bytes_out,per_sec}: 270818 {packets_in,per_sec}: 3243 {packets_out,per_sec}: 22576 {time_to_client,min}: 33.944 {time_to_server,min}: 0.533 {time_to_client,max}: 2487.903 {time_to_server,max}: 136.146 {time_to_client,avg}: 600.7879700669516 {time_to_server,avg}: 20.330412830951946 =INFO REPORT==== 6-Oct-2008::13:25:59 === module: stats elapsed: 10.000539 bytes_in: 74843 bytes_out: 2826243 packets_in: 3055 packets_out: 231956 {bytes_in,per_sec}: 7483 {bytes_out,per_sec}: 282609 {packets_in,per_sec}: 305 {packets_out,per_sec}: 23194 {time_to_client,min}: 76.3 {time_to_server,min}: 0.758 {time_to_client,max}: 2539.293 {time_to_server,max}: 114.08 {time_to_client,avg}: 1168.0286129495837 {time_to_server,avg}: 4.338520242410239 =INFO REPORT==== 6-Oct-2008::13:26:09 === module: stats elapsed: 9.999128 bytes_in: 2258335 bytes_out: 887220 packets_in: 92719 packets_out: 71770 {bytes_in,per_sec}: 225853 {bytes_out,per_sec}: 88729 {packets_in,per_sec}: 9272 {packets_out,per_sec}: 7177 {time_to_client,min}: 74.793 {time_to_server,min}: -0.16 {time_to_client,max}: 6072.688 {time_to_server,max}: 403.202 {time_to_client,avg}: 2467.0929211869234 {time_to_server,avg}: 21.581616260229122 =INFO REPORT==== 6-Oct-2008::13:26:19 === module: stats elapsed: 10.00713 bytes_in: 2868537 bytes_out: 168167 packets_in: 118195 packets_out: 13846 {bytes_in,per_sec}: 286649 {bytes_out,per_sec}: 16804 {packets_in,per_sec}: 11811 {packets_out,per_sec}: 1383 {time_to_client,min}: 141.216 {time_to_server,min}: -0.162 {time_to_client,max}: 9914.637 {time_to_server,max}: 527.446 {time_to_client,avg}: 796.8525357953445 {time_to_server,avg}: 22.936007665596 =INFO REPORT==== 6-Oct-2008::13:26:29 === module: stats elapsed: 9.992855 bytes_in: 2117299 bytes_out: 549453 packets_in: 89253 packets_out: 40298 {bytes_in,per_sec}: 211881 {bytes_out,per_sec}: 54984 {packets_in,per_sec}: 8931 {packets_out,per_sec}: 4032 {time_to_client,min}: 11.262 {time_to_server,min}: -0.162 {time_to_client,max}: 10542.49 {time_to_server,max}: 439.312 {time_to_client,avg}: 237.57952461078088 {time_to_server,avg}: 94.565093206288 =INFO REPORT==== 6-Oct-2008::13:26:39 === module: stats elapsed: 10.000009 bytes_in: 1310469 bytes_out: 1931419 packets_in: 56212 packets_out: 152378 {bytes_in,per_sec}: 131046 {bytes_out,per_sec}: 193141 {packets_in,per_sec}: 5621 {packets_out,per_sec}: 15237 {time_to_client,min}: 0.271 {time_to_server,min}: 13.38 {time_to_client,max}: 6630.608 {time_to_server,max}: 505.429 {time_to_client,avg}: 5.189399196632146 {time_to_server,avg}: 43.817916713631014 =INFO REPORT==== 6-Oct-2008::13:26:49 === module: stats elapsed: 9.999995 bytes_in: 690046 bytes_out: 2840243 packets_in: 30002 packets_out: 227816 {bytes_in,per_sec}: 69004 {bytes_out,per_sec}: 284024 {packets_in,per_sec}: 3000 {packets_out,per_sec}: 22781 {time_to_client,min}: 0.281 {time_to_server,min}: 19.745 {time_to_client,max}: 63.059 {time_to_server,max}: 506.526 {time_to_client,avg}: 3.4162563678436983 {time_to_server,avg}: 32.55984930907259 =INFO REPORT==== 6-Oct-2008::13:26:59 === module: stats elapsed: 10.003134 bytes_in: 518215 bytes_out: 2372858 packets_in: 22845 packets_out: 193438 {bytes_in,per_sec}: 51805 {bytes_out,per_sec}: 237211 {packets_in,per_sec}: 2283 {packets_out,per_sec}: 19337 {time_to_client,min}: 0.27 {time_to_server,min}: 13.644 {time_to_client,max}: 72.208 {time_to_server,max}: 289.966 {time_to_client,avg}: 1.0623046789650372 {time_to_server,avg}: 28.797672193416293 =INFO REPORT==== 6-Oct-2008::13:27:09 === module: stats elapsed: 9.997725 bytes_in: 1239798 bytes_out: 1145689 packets_in: 56628 packets_out: 93128 {bytes_in,per_sec}: 124008 {bytes_out,per_sec}: 114594 {packets_in,per_sec}: 5664 {packets_out,per_sec}: 9314 {time_to_client,min}: 0.262 {time_to_server,min}: -0.168 {time_to_client,max}: 81.195 {time_to_server,max}: 253.462 {time_to_client,avg}: 8.403465667253972 {time_to_server,avg}: 2.3821230459554026 =INFO REPORT==== 6-Oct-2008::13:27:19 === module: stats elapsed: 10.000059 bytes_in: 4330839 bytes_out: 804560 packets_in: 183647 packets_out: 63266 {bytes_in,per_sec}: 433081 {bytes_out,per_sec}: 80455 {packets_in,per_sec}: 18364 {packets_out,per_sec}: 6326 {time_to_client,min}: 0.252 {time_to_server,min}: -0.168 {time_to_client,max}: 87.52 {time_to_server,max}: 122.569 {time_to_client,avg}: 4.041418440137954 {time_to_server,avg}: 41.888633391776644 =INFO REPORT==== 6-Oct-2008::13:27:29 === module: stats elapsed: 9.999943 bytes_in: 6079331 bytes_out: 1207405 packets_in: 257496 packets_out: 95114 {bytes_in,per_sec}: 607936 {bytes_out,per_sec}: 120741 {packets_in,per_sec}: 25749 {packets_out,per_sec}: 9511 {time_to_client,min}: 0.248 {time_to_server,min}: -0.168 {time_to_client,max}: 110.687 {time_to_server,max}: 160.911 {time_to_client,avg}: 0.6254370271594177 {time_to_server,avg}: 0.6895430481677953 =INFO REPORT==== 6-Oct-2008::13:27:39 === module: stats elapsed: 9.99912 bytes_in: 2437108 bytes_out: 1673955 packets_in: 102193 packets_out: 137242 {bytes_in,per_sec}: 243732 {bytes_out,per_sec}: 167410 {packets_in,per_sec}: 10220 {packets_out,per_sec}: 13725 {time_to_client,min}: 0.23 {time_to_server,min}: -0.17 {time_to_client,max}: 272.111 {time_to_server,max}: 75.171 {time_to_client,avg}: 1.0046702454518566 {time_to_server,avg}: -0.08508062985883734 dmb: exited successfully, 164.797657 seconds elapsed ok (1@REDACTED)3> =INFO REPORT==== 6-Oct-2008::13:27:49 === module: stats elapsed: 10.007192 bytes_in: 448990 bytes_out: 439782 packets_in: 18794 packets_out: 36034 {bytes_in,per_sec}: 44866 {bytes_out,per_sec}: 43946 {packets_in,per_sec}: 1878 {packets_out,per_sec}: 3600 {time_to_client,min}: 0.273 {time_to_server,min}: -0.169 {time_to_client,max}: 12.465 {time_to_server,max}: 8.763 {time_to_client,avg}: 5.224798551005151 {time_to_server,avg}: 0.09153370462824446 From greg.burri@REDACTED Mon Oct 6 16:08:48 2008 From: greg.burri@REDACTED (Greg Burri) Date: Mon, 6 Oct 2008 16:08:48 +0200 Subject: [erlang-questions] Get a range of tuples from a Mnesia table In-Reply-To: <6c2563b20810041111t401ebb0fh5482d383438f0b8b@mail.gmail.com> References: <60ed8a460810040919qcf9dd37m994bbf6932f18cc0@mail.gmail.com> <6c2563b20810041111t401ebb0fh5482d383438f0b8b@mail.gmail.com> Message-ID: <60ed8a460810060708x61bf8799xf6a399b0f525393a@mail.gmail.com> Thanks for you reply. I haven't try yet but I keep your answer for later use. On Sat, Oct 4, 2008 at 8:11 PM, Edwin Fine wrote: > Looking through the docs, I see that if you are using an mnesia table that > is ram_copies or disc_copies, you can do certain fast operations on the > associated ets table. One such operation (which is recommended only for > debugging, but what the heck) is ets:slot(Tab, I), which returns the I'th > record in the table. So maybe you could find a way to do that on the ETS > table that Mnesia is using, perhaps via the mnesia:ets() function. I have > never tried this so it's just a guess. This is also kind of a hack but other > than reading through the mnesia code, I can't locate something better. Maybe > one of the real Mnesia gurus will have an idea. > > 2008/10/4 Greg Burri > >> Hi, >> I want to retrieve N tuple with an offset O from the end of a table. N and >> O are integer(). I consider that the acces is based on an ordered table. >> >> Here is an example, I have such tuples in my table t : >> [{t, 1, _}, >> {t, 2, _}, >> {t, 3, _}, >> {t, 4, _}, >> {t, 5, _}, >> {t, 6, _}, >> {t, 7, _}] >> >> For N=2 and O=3 the result will be : >> [{t, 4, _}, {t, 5, _}] >> >> For now I have to use an ordered_set table and the functions mnesia:last/1 >> and mnesia:prev/2, it works but the complexity is O(O). If I have to get >> some tuple from the middle of the table it will take long time. >> Is there an another solution than mine ? >> >> Second question : How change the type of a table from set to ordered_set >> on an existing table ? >> >> >> /Greg Burri >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From greg.burri@REDACTED Mon Oct 6 16:17:55 2008 From: greg.burri@REDACTED (Greg Burri) Date: Mon, 6 Oct 2008 16:17:55 +0200 Subject: [erlang-questions] Convert a Mnesia "set" table to an "ordered_set" Message-ID: <60ed8a460810060717i67d6231dxbe28918fc751845@mail.gmail.com> Hi, I already ask this question but it was hided into a mail about something else. Is there a way to convert a mnesia table which has the type "set" to a "ordered_set" one ? For the moment I use "mnesia:backup/1" then I recreate my table with the "ordered_set" type and I call "mnesia:restore/2" to retrieve my data. It's a bit ugly... it isn't ? /Greg Burri -------------- next part -------------- An HTML attachment was scrubbed... URL: From kenneth.lundin@REDACTED Mon Oct 6 16:49:52 2008 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Mon, 6 Oct 2008 16:49:52 +0200 Subject: [erlang-questions] Erlang Course on Web-Site (IP Rights) In-Reply-To: <48E9A2AB.5090907@adam.com.au> References: <48E9A2AB.5090907@adam.com.au> Message-ID: Hi, The IP for the course is owned by Ericsson AB, I will add the Copyright notice which should have been there from the beginning. The rights and restrictions should be defined by the Erlang Public License which I think is a suitable license to be used for both the code and the documentation of Erlang/OTP as well as other publications created by the Erlang/OTP group at Ericssoon. /Kenneth Erlang/OTP team , Ericsson On Mon, Oct 6, 2008 at 7:31 AM, David Lloyd wrote: > > Hi There, > > > The Erlang Course: > > * http://www.erlang.org/course/course.html > > ...doesn't have any obvious attribution as to who or what legal entity > owns the copyright and other rights to it. > > Does anyone know who the IP owner actually is and if there are any > specific restrictions on its use (eg. not in a commercial setting)? > > > DSL > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From cktgatb@REDACTED Mon Oct 6 17:05:58 2008 From: cktgatb@REDACTED (deepblue_other) Date: Mon, 6 Oct 2008 08:05:58 -0700 (PDT) Subject: [erlang-questions] Erlang external binary term format In-Reply-To: <19835272.post@talk.nabble.com> References: <19830781.post@talk.nabble.com> <19835272.post@talk.nabble.com> Message-ID: <19839752.post@talk.nabble.com> ah, sorry about that thanks Edwin Fine wrote: > > > deepblue_other wrote: >> >> term_to_binary() outputs a binary. >> what is the format of that binary? >> is there a document someplace that gives the byte layout maybe? >> > This is what you want: http://erlang.org/doc/apps/erts/erl_ext_dist.html > Erlang external term format documentation > > You might want to search the Erlang mailing list before asking questions. > A lot of your questions may be answered already. For example, a search > using the words "external term format" found the answer to your question > in seconds using http://www.erlang.org/faq.html Search the Erlang Mailing > Lists > -- View this message in context: http://www.nabble.com/Erlang-external-binary-term-format-tp19830781p19839752.html Sent from the Erlang Questions mailing list archive at Nabble.com. From dgud@REDACTED Mon Oct 6 09:50:12 2008 From: dgud@REDACTED (Dan Gudmundsson) Date: Mon, 06 Oct 2008 09:50:12 +0200 Subject: [erlang-questions] Request to add md4 to crypto module In-Reply-To: References: <200810030329.09362.alexander.uvarov@gmail.com> <48E5EF23.3050708@erix.ericsson.se> Message-ID: <48E9C334.70802@erix.ericsson.se> See the thread: http://www.erlang.org/pipermail/erlang-bugs/2008-September/000989.html /Dan Will wrote: > Hi Dan, > > Glad to hear you're in the midst of work on crypto! I submitted patches > a long time ago to add MD5 and SHA1 signing and verification with RSA > keys. I'd love to see this included in crypto. > > http://article.gmane.org/gmane.comp.lang.erlang.patches/151 > > Thanks, > Will > > On Fri, Oct 3, 2008 at 3:08 AM, Dan Gudmundsson > wrote: > > You don't have to write (in my mind) an EEP for adding things in a > library, > EEP is for language changes or other major erlang changes. > > Send a patch to erlang-patches, and if we thinks it's ok and have > time we will add it. > > /Dan "Currently adding things to crypto" > > Alexander wrote: > > On Thursday 02 October 2008 23:28:29 Jim McCoy wrote: > >> After poking around a bit in the OTP sources it seems that it > would be > >> pretty trivial to add md4 to the crypto module. I will be testing a > >> few patches later this week, but before I throw together a real > EEP I > >> was hoping that this might be a simple-enough change that the > OTP team > >> might consider adding it without the need for the formal process. > > > > +1 for enhancement, also it would be useful to have DES in ECB > mode too > > (trivial). If someone interested, there is my implementation > based on erlang > > crypto driver (md4, des in ecb mode - used by mschapv2) > > http://pastie.org/283903 > > > > Also, why not make MD2 and finish dance with MD* crypto in erlang? :) > > > >> As for the rationale: some applications (dhts, etc) need a > large, fast > >> hash that has a good uniqueness distribution but are not worried > about > >> the security implications of selecting an algorithm that is > >> cryptographically weak. The md4 hash is about 50% faster than md5, > >> which is a real win when you are hashing thousands of items. Since > >> there are already "questionable" algorithms included in the crypto > >> module (e.g. md5 and rc2) it seems that a warning in the docs that > >> this algorithm should not be used for security-sensitive tasks would > >> be sufficient notice to developers. > >> > >> Any thoughts or objections? > >> > >> jim > >> _______________________________________________ > >> erlang-questions mailing list > >> erlang-questions@REDACTED > >> http://www.erlang.org/mailman/listinfo/erlang-questions > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > From cktgatb@REDACTED Mon Oct 6 17:34:21 2008 From: cktgatb@REDACTED (deepblue_other) Date: Mon, 6 Oct 2008 08:34:21 -0700 (PDT) Subject: [erlang-questions] re cursive fun() In-Reply-To: References: <19820386.post@talk.nabble.com> Message-ID: <19840331.post@talk.nabble.com> the example I gave was not suppose to be a practical one, I just wanted to ask how to recursively call a anonymous function... Richard O'Keefe wrote: > > On 5 Oct 2008, at 4:19 pm, deepblue_other wrote: >> I have this going on >> >> FunVar = >> fun() -> >> ... >> FunVar() >> end. >> > Shouldn't this go in a FAQ somewhere? > Maybe it belongs in the reference manual. > > The quick answer is that if you need a recursive > function, why not write a recursive function in the > usual way? > > There's something particularly nasty about this > example. One normally proves (or at any rate > argues with vigourously waving hands for) the > termination of a recursive function by showing > that some non-negative measure of its arguments > strictly decreases on each recursive call, but > this function has no arguments. I think we need > to see more of it. > > The long answer is that you can always do > > Rec = fun (Self, Args) -> > .... > Self(Self, Args') > end, > Foo = fun (Args) -> Rec(Rec, Args) end, > > It's possible, but you are working against the > grain of the language, and there is most likely > a better way to achieve your goals. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > -- View this message in context: http://www.nabble.com/recursive-fun%28%29-tp19820386p19840331.html Sent from the Erlang Questions mailing list archive at Nabble.com. From dgud@REDACTED Mon Oct 6 18:01:03 2008 From: dgud@REDACTED (Dan Gudmundsson) Date: Mon, 06 Oct 2008 18:01:03 +0200 Subject: [erlang-questions] Convert a Mnesia "set" table to an "ordered_set" In-Reply-To: <60ed8a460810060717i67d6231dxbe28918fc751845@mail.gmail.com> References: <60ed8a460810060717i67d6231dxbe28918fc751845@mail.gmail.com> Message-ID: <48EA363F.4010305@erix.ericsson.se> It's not possible to change the type on mnesia tables. /Dan Greg Burri wrote: > Hi, > I already ask this question but it was hided into a mail about something > else. > > Is there a way to convert a mnesia table which has the type "set" to a > "ordered_set" one ? > For the moment I use "mnesia:backup/1" then I recreate my table with the > "ordered_set" type and I call "mnesia:restore/2" to retrieve my data. > It's a bit ugly... it isn't ? > > > /Greg Burri > > > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From 0x6e6562@REDACTED Mon Oct 6 19:38:36 2008 From: 0x6e6562@REDACTED (Ben Hood) Date: Mon, 6 Oct 2008 18:38:36 +0100 Subject: [erlang-questions] Some mnesia oddity In-Reply-To: <48E9BF0F.7080303@erix.ericsson.se> References: <48B7DB67.7010608@erix.ericsson.se> <269388e30810050420w38e3cc77h23dea901c39d6cc1@mail.gmail.com> <48E9BF0F.7080303@erix.ericsson.se> Message-ID: <269388e30810061038u66e36bd9w7aeab7eaafa26449@mail.gmail.com> Dan, On Mon, Oct 6, 2008 at 8:32 AM, Dan Gudmundsson wrote: > You should be able to read the table in the same transaction, > but there is a bug in mnesia handling the special atom '_'. > > delete_object is not match delete do you have records with '_' in them?? Yes, but I may be missing the point. The test case I attached in my previous mail leads me to believe that wildcards do actually work with delete_object. As for the visibility of the deleted records, the same test case shows that deleted records are still visible to subsequent reads within the same transaction. Are you saying that this is the expected behavior? Or should I modify the test to iterate over the table with match_object and delete the records via their key? Thx, Ben From bryan.fink@REDACTED Mon Oct 6 20:26:28 2008 From: bryan.fink@REDACTED (Bryan Fink) Date: Mon, 6 Oct 2008 14:26:28 -0400 Subject: [erlang-questions] a little meta-programing help In-Reply-To: <8ca3fbe80810051631t2a1650f5x975f927c91e23415@mail.gmail.com> References: <8ca3fbe80810051515m6b983822re94985aa0b63248c@mail.gmail.com> <1c89b3a10810051612r6e341282v54d0f94262072dbb@mail.gmail.com> <8ca3fbe80810051631t2a1650f5x975f927c91e23415@mail.gmail.com> Message-ID: On Sun, Oct 5, 2008 at 7:31 PM, anders conbere wrote: > On Sun, Oct 5, 2008 at 4:12 PM, Antoine Koener wrote: >> On Mon, Oct 6, 2008 at 12:15 AM, anders conbere wrote: >>> Today I sat down to try to make working with mochiweb a little cleaner >>> for myself. I wanted a way to specify a list of mappings between url >>> patterns and methods to be called with the matched variables from >>> them. I quickly ran into issues with not being able to create patterns >>> dynamically, and then tried using funs to wrap that functionality but >>> pretty soon I was back at the same mess I started with. >>> >> >> I used the list_to_atom fun to build the module name. >> This is not recommended but it's still really useful: >> check out: http://easyerl.blogspot.com/2008/07/my-mochiweb-webservice.html > > Yeah, so I'm working more under the presumption that I can specify the > route to the module for each mapped url pattern. I'm not supper > interested in mapping urls to modules from the actual url text. Hi, Anders. I might suggest that you take a look at the webmachine project. It has a module that does dispatch and binding on URLs, and is built on top of mochiweb. I'm not sure if it's exactly what you're looking for, but it's in the same vein. Take a look at webmachine_dispatcher.erl from http://code.google.com/p/webmachine/ Details about its dispatch configuration syntax are here: http://code.google.com/p/webmachine/wiki/DispatchConfiguration -Bryan From oscar@REDACTED Mon Oct 6 20:35:19 2008 From: oscar@REDACTED (=?utf-8?Q?Oscar_Hellstr=C3=B6m?=) Date: Mon, 6 Oct 2008 19:35:19 +0100 (BST) Subject: [erlang-questions] tcp sockets - not clear In-Reply-To: <859063.6411223317795325.JavaMail.root@zimbra> Message-ID: <21022895.6431223318119607.JavaMail.root@zimbra> Hi, I'm assuming that a object is something running in a separate thread, which means that you will have to have a thread safe implementation of the send() function to be able to get the messages through without problems. AFAIK know at least the POSIX implementations are thread safe. Another important part here is that the whole message must be put on the wire before any part of any other message is, which actually means that the send() function need to support atomicy. If this is not the case for you send() function you probably need to serialise the sending. You can read more about this here: http://www.almaden.ibm.com/cs/people/marksmith/sendmsg.html Keep in mind that TCP packages can be fragmented on the way, and you need to assemble them yourself unless you use use the {packet, 1|2|4} option (and implement that on the flash side), i.e. you need some defined protocol. If you're using a text based protocol this is less of a problem (or more depending on who you are) I guess. >From the erlang side we seem to have the same issue that we need to serialise the data to be absolutely sure that messages are not intervened (since the inet_drv.c essentially calls send() at some point). Someone please correct me if I'm wrong here. Hope this helps. ----- Original Message ----- From: "deepblue_other" To: erlang-questions@REDACTED Sent: Sunday, 5 October, 2008 9:07:08 AM GMT -08:00 US/Canada Pacific Subject: [erlang-questions] tcp sockets - not clear hello everyone Im building a system with a Flash front-end and an Erlang back-end and have some confusion in a case where there is a single socket on the back-end per user (per single socket on the front-end). I want to have multiple independent objects on the front-end send messages to the back-end, but am not sure how the simultaneous transmission would be handled. This probably stems from my somewhat clowdly understanding of TCP. Say there are 3 objects that initiate a send() method on the front-end (almost at the same time) and send a semi large message each to the back-end. Each message would be ID'd by the front-end so that when received back it can be routed to the appropriate callback. Is this possible? since the packets are being assembled in the {tcp, Socket, Data} pattern match, peace by peace, would the correct peaces of the individual messages be stiched together? (doesnt seem like they would). if that wont work then I would just have the serialize the sending/receiving, which is not too horrible... thanks -- View this message in context: http://www.nabble.com/tcp-sockets---not-clear-tp19826070p19826070.html Sent from the Erlang Questions mailing list archive at Nabble.com. Best regards -- Oscar Hellstr?m, oscar@REDACTED Phone: +44 (0)798 45 44 773 Mobile: +44 (0)207 65 50 337 Web: http://www.erlang-consulting.com From aconbere@REDACTED Mon Oct 6 20:42:51 2008 From: aconbere@REDACTED (anders conbere) Date: Mon, 6 Oct 2008 11:42:51 -0700 Subject: [erlang-questions] a little meta-programing help In-Reply-To: References: <8ca3fbe80810051515m6b983822re94985aa0b63248c@mail.gmail.com> <1c89b3a10810051612r6e341282v54d0f94262072dbb@mail.gmail.com> <8ca3fbe80810051631t2a1650f5x975f927c91e23415@mail.gmail.com> Message-ID: <8ca3fbe80810061142y21217e50j60a9846ad15588e6@mail.gmail.com> On Mon, Oct 6, 2008 at 11:26 AM, Bryan Fink wrote: > On Sun, Oct 5, 2008 at 7:31 PM, anders conbere wrote: >> On Sun, Oct 5, 2008 at 4:12 PM, Antoine Koener wrote: >>> On Mon, Oct 6, 2008 at 12:15 AM, anders conbere wrote: >>>> Today I sat down to try to make working with mochiweb a little cleaner >>>> for myself. I wanted a way to specify a list of mappings between url >>>> patterns and methods to be called with the matched variables from >>>> them. I quickly ran into issues with not being able to create patterns >>>> dynamically, and then tried using funs to wrap that functionality but >>>> pretty soon I was back at the same mess I started with. >>>> >>> >>> I used the list_to_atom fun to build the module name. >>> This is not recommended but it's still really useful: >>> check out: http://easyerl.blogspot.com/2008/07/my-mochiweb-webservice.html >> >> Yeah, so I'm working more under the presumption that I can specify the >> route to the module for each mapped url pattern. I'm not supper >> interested in mapping urls to modules from the actual url text. > > Hi, Anders. I might suggest that you take a look at the webmachine > project. It has a module that does dispatch and binding on URLs, and > is built on top of mochiweb. I'm not sure if it's exactly what you're > looking for, but it's in the same vein. > > Take a look at webmachine_dispatcher.erl from > > http://code.google.com/p/webmachine/ > > Details about its dispatch configuration syntax are here: Interesting it looks like it does what I was considering which is writing matching code specifically for this. It seems like there are many good reasons to expose more of erlang's pattern matching tools to developers. I'm not sure historically what the reason behind not exposing the matching primitives is, but it would certainly make metaprogramming in erlang a ton easier. ~ Anders > > http://code.google.com/p/webmachine/wiki/DispatchConfiguration > > -Bryan > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From cktgatb@REDACTED Mon Oct 6 21:07:02 2008 From: cktgatb@REDACTED (deepblue_other) Date: Mon, 6 Oct 2008 12:07:02 -0700 (PDT) Subject: [erlang-questions] tcp sockets - not clear In-Reply-To: <21022895.6431223318119607.JavaMail.root@zimbra> References: <19826070.post@talk.nabble.com> <21022895.6431223318119607.JavaMail.root@zimbra> Message-ID: <19844239.post@talk.nabble.com> thanks for the reply Oscar Hellstr?m-2 wrote: > > Hi, > > I'm assuming that a object is something running in a separate thread, > which means that you will have to have a thread safe implementation of the > send() function to be able to get the messages through without problems. > AFAIK know at least the POSIX implementations are thread safe. Another > important part here is that the whole message must be put on the wire > before any part of any other message is, which actually means that the > send() function need to support atomicy. If this is not the case for you > send() function you probably need to serialise the sending. You can read > more about this here: > http://www.almaden.ibm.com/cs/people/marksmith/sendmsg.html > well the flash VM does not support threading yet, so all the object instances run in the same thread - thus thread safety is not an issue. you did nail it when saying that the whole message must be on the wire, which is my original concern, but Im guessing that you guys might not be able to answer this question since how Flash internally handles this is somewhat undocumented. However I have a feeling that this is not an issue, going back to the fact that Flash is single threaded. the question I guess is if a A is sent after B, TCP will ensure that A is assembled correctly even if some parts of it come in after B. So TCP guarantees that messages arrive in one peace (are assembled correctly) but does not guarantee that they come in the order they were sent? Oscar Hellstr?m-2 wrote: > > Keep in mind that TCP packages can be fragmented on the way, and you need > to assemble them yourself unless you use use the {packet, 1|2|4} option > (and implement that on the flash side), i.e. you need some defined > protocol. > you confused me here a bit. Im using {packet, 4} at the moment, but Im not clear what I would have to do if it were {packet,0}, and what I have to do on the Flash side. The packet assembling would not be handled automatically by the TCP drivers on both Erlang and Flash side? Oscar Hellstr?m-2 wrote: > > If you're using a text based protocol this is less of a problem (or more > depending on who you are) I guess. > > From the erlang side we seem to have the same issue that we need to > serialise the data to be absolutely sure that messages are not intervened > (since the inet_drv.c essentially calls send() at some point). Someone > please correct me if I'm wrong here. > > Hope this helps. > > ----- Original Message ----- > From: "deepblue_other" > To: erlang-questions@REDACTED > Sent: Sunday, 5 October, 2008 9:07:08 AM GMT -08:00 US/Canada Pacific > Subject: [erlang-questions] tcp sockets - not clear > > > hello everyone > Im building a system with a Flash front-end and an Erlang back-end and > have > some confusion in a case where there is a single socket on the back-end > per > user (per single socket on the front-end). > I want to have multiple independent objects on the front-end send messages > to the back-end, but am not sure how the simultaneous transmission would > be > handled. This probably stems from my somewhat clowdly understanding of > TCP. > Say there are 3 objects that initiate a send() method on the front-end > (almost at the same time) and send a semi large message each to the > back-end. Each message would be ID'd by the front-end so that when > received > back it can be routed to the appropriate callback. Is this possible? > since the packets are being assembled in the {tcp, Socket, Data} pattern > match, peace by peace, would the correct peaces of the individual messages > be stiched together? (doesnt seem like they would). > > if that wont work then I would just have the serialize the > sending/receiving, which is not too horrible... > > thanks > -- > View this message in context: > http://www.nabble.com/tcp-sockets---not-clear-tp19826070p19826070.html > Sent from the Erlang Questions mailing list archive at Nabble.com. > > Best regards > -- > Oscar Hellstr?m, oscar@REDACTED > Phone: +44 (0)798 45 44 773 > Mobile: +44 (0)207 65 50 337 > Web: http://www.erlang-consulting.com > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- View this message in context: http://www.nabble.com/tcp-sockets---not-clear-tp19826070p19844239.html Sent from the Erlang Questions mailing list archive at Nabble.com. From kenneth.lundin@REDACTED Mon Oct 6 21:25:47 2008 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Mon, 6 Oct 2008 21:25:47 +0200 Subject: [erlang-questions] extending the scanner and parser In-Reply-To: <95be1d3b0810041127o3d733f09l5182c0499ee57daa@mail.gmail.com> References: <95be1d3b0810030413p52bc5b58uf22c6790d64f9f35@mail.gmail.com> <20081003151527.GA28655@myrtle.kent.ac.uk> <95be1d3b0810031126t5fb7b8b9x48bb75c3895a330e@mail.gmail.com> <3dbc6d1c0810041115p571160fft458be1a867ff6cf2@mail.gmail.com> <95be1d3b0810041127o3d733f09l5182c0499ee57daa@mail.gmail.com> Message-ID: On Sat, Oct 4, 2008 at 8:27 PM, Vlad Dumitrescu wrote: > On Sat, Oct 4, 2008 at 20:15, Robert Virding wrote: >> Another solution which may help you is to use leex for generating the >> scanner. As I said we plan to integrate the required functionality in the official scanner and we can not have dependencies to components which are not part of the distribution in the scanner. We also already have the scanner so there is really no need to implement a new one with Leex. It might whowever be a good thing to have leex as part of the distribution but we can take that dicusssion separately. It gives you much more freedom in deciding what to return, so you >> could return both the value and/or the chars if you wish. However, I don't >> think it will give all the data you want, you can the line number, >> characters and length of each token. >> >> If you want to use yecc for generating the parser, which really does >> simplify matters, you have to a little circumspect because it only accepts >> tokens in the form {Type,Line} or {Type,Line,Value}. It does place any >> restrictions on the vaule. We already use yecc for the parser and it will be no problem to e.g. let the Line info in the tokens be an arbitrarily complex tuple instead. > > Thank you for the advice! I considered that, but I'd rather use the > standard lexer and parser, to be sure the results are exactly the same > as they should (except the presentation). Actually, now that I think > of it, I did try it, but got trouble with the more esoteric parts > (like multi-line strings) and abandoned that path. Maintenance would > still be a headache. > > best regards, > Vlad > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > /Kenneth Erlang/OTP team, Ericsson From michael.regen@REDACTED Mon Oct 6 21:41:46 2008 From: michael.regen@REDACTED (Michael Regen) Date: Mon, 6 Oct 2008 21:41:46 +0200 Subject: [erlang-questions] How to build Erlang with libcmt (/MT) under windows? In-Reply-To: <9b59d0270810051004u391f464k112d5175573a95f4@mail.gmail.com> References: <9b59d0270810051004u391f464k112d5175573a95f4@mail.gmail.com> Message-ID: <9b59d0270810061241g32995b3k5ce8da6221812912@mail.gmail.com> Hi, I think I found a solution. My very limited tests showed no problems so far. Question remains whether I should expect something bad to happen. Is it possible for someone with more insight into the code (shy glance to the Erlang emulator coders :) ) to give a rough estimation whether static binding of the C runtime library might lead to problems? I understand it is difficult by various aspects to publish the test suite used by Ericsson to test the Erlang distributions. And probably difficult to use. But here I ran into a situation where it would be quite usefull... My approach is attached to this mail. The small diffs simply make sure that the /MT switch is used by the compiler/linker. Probably they overshoot the mark. You need to run 'otp_build configure' after applying the patches. And my initial assumption about the error message below was wrong. _dosmaperr is a function which is contained in the static libcmt but not in msvcr??.dll. I have no clue why. However you do not want it when statically linking to libcmt. Regards, Michael On Sun, Oct 5, 2008 at 7:04 PM, Michael Regen wrote: > Hi, > > Does anyone a little bit more experienced with the Erlang build mechanism > know how to compile and link Erlang with libcmt instead of msvcrt? > The default mechanism builds Erlang with the /MD switch which means the C > standard libraries are accessed as threaded dll MSVCR??.DLL. This also means > you cannot simply copy Erlang to another computer as long as the correct C > runtime is not installed there. > > I am trying to figure out how to statically bind the libcmt library. > Normally you do this by using the /MT switch. > > So far I tried to change the erts\etc\win32\cygwin_tools\vc\cc.sh and ld.sh > scripts but with no good effects. I always get the usual error messages like > if you mix libraries compiled with different switches. > > In cc.sh setting > MD_FORCED=true > MD=-MT > and in ld.sh > STDLIB=LIBCMT.LIB > > just leads me to: > > LIBCMT.LIB(dosmap.obj) : error LNK2005: __dosmaperr already defined in > dosmap.o > Creating library > c:/dev/erlang/ErlangOTP/otp_src_R12B-4/bin/win32/erl_dll.lib and object > c:/dev/erlang/ErlangOTP/otp_src_R12B-4/bin/win32/erl_dll.exp > c:/dev/erlang/ErlangOTP/otp_src_R12B-4/bin/win32/beam.smp.dll : fatal error > LNK1169: one or more multiply defined symbols found > > Thank you! > > Regards, > Michael > -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: cc.sh.patch Type: application/octet-stream Size: 1218 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: ld.sh.patch Type: application/octet-stream Size: 375 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: Makefile.in.patch Type: application/octet-stream Size: 309 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: Makefile.patch Type: application/octet-stream Size: 315 bytes Desc: not available URL: From erlang-questions_efine@REDACTED Mon Oct 6 22:34:07 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Mon, 6 Oct 2008 13:34:07 -0700 (PDT) Subject: [erlang-questions] tcp sockets - not clear In-Reply-To: <21022895.6431223318119607.JavaMail.root@zimbra> References: <19826070.post@talk.nabble.com> <21022895.6431223318119607.JavaMail.root@zimbra> Message-ID: <19845876.post@talk.nabble.com> Oscar Hellstr?m-2 wrote: > > I'm assuming that a object is something running in a separate thread, > which means that you will have to have a thread safe implementation of the > send() function to be able to get the messages through without problems. > AFAIK know at least the POSIX implementations are thread safe. Another > important part here is Huh, I didn't think of it in that way. I was assuming that each object (i.e. thread) would open its own socket, not share one socket amongst multiple threads. Sharing the channel would really complicate things, as you rightly say. You'd have to create a protocol to multiplex the data onto the channel, and demultiplex it on the other side, handling fragmentation properly. On the other hand, maybe it will be necessary to have a shared socket if there are many objects (threads) and it's not practical, or too inefficient, for each one to have its own socket. If I am misunderstanding any of this, please correct me. -- View this message in context: http://www.nabble.com/tcp-sockets---not-clear-tp19826070p19845876.html Sent from the Erlang Questions mailing list archive at Nabble.com. From mpharrison@REDACTED Mon Oct 6 23:17:01 2008 From: mpharrison@REDACTED (harry) Date: Mon, 6 Oct 2008 14:17:01 -0700 (PDT) Subject: [erlang-questions] ?DATE and ?TIME MACROs Message-ID: Hi, trawling through the archives I found the answer to how to do a ? FUNCTION macro. How would you do ?DATE and ?TIME (apart from erlc -DDATE=`time` .... or something similar, which is *nix specific) Would there be any mileage in adding these (and ?FUNCTION) to epp? Rgds, Matthew (aka Harry) From tony@REDACTED Tue Oct 7 01:34:07 2008 From: tony@REDACTED (Tony Arcieri) Date: Mon, 6 Oct 2008 17:34:07 -0600 Subject: [erlang-questions] Extracting capture group names from regular expressions Message-ID: I'm trying to write an API which accepts a regexp with arbitrary named capture groups as input. I'm using the re module, and have had success using named subgroups if the names are known ahead of time. However, I'd like to return a mapping of arbitrary named capture groups from the original regular expression to the matched values. Consider the following regular expression with named subpatterns: "(?\\w+) (?\\w+)" If this were applied to the string "baz qux" I'd like to return the following: [{"foo", "baz"}, {"bar", "qux"}] However, it looks as if I must provide the names of the capture groups I want returned in the capture tuple I pass to re:run. Is there any way to extract the names of the subgroups from a compiled regular expression? Or is there some option I can pass to re:run that I'm missing which will return a mapping of subgroup names to what they matched? -- Tony Arcieri medioh.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From yoursurrogategod@REDACTED Tue Oct 7 01:51:46 2008 From: yoursurrogategod@REDACTED (YourSurrogateGod) Date: Mon, 6 Oct 2008 16:51:46 -0700 (PDT) Subject: [erlang-questions] Erlang's security when compared to Ada Message-ID: This is an interesting article that I've found when it comes to security that a programming language can provide. http://www.net-security.org/secworld.php?id=6619 By no means I'm trying to compare Ada to Erlang. There are far too many things to take into account. However, I would like to know just how well Erlang measures up to the features that are part of the Ada language which make it so predictable and secure. I'd love to hear some input from fellow Erlang programmers who have a background in Ada. From ok@REDACTED Tue Oct 7 04:02:45 2008 From: ok@REDACTED (Richard O'Keefe) Date: Tue, 7 Oct 2008 15:02:45 +1300 Subject: [erlang-questions] re cursive fun() In-Reply-To: <19825467.post@talk.nabble.com> References: <19820386.post@talk.nabble.com> <6c2563b20810050213r7ea28fdbp9b2205332b3662a2@mail.gmail.com> <19825467.post@talk.nabble.com> Message-ID: On 6 Oct 2008, at 4:12 am, deepblue_other wrote: > no shell is not the reason, I need a function that will only be > called from > within another function and I dont want to "pollute" the "module > wide" space > with another function, so Im putting in a nested one... This seems an extraordinarily weak reason. Putting local functions into a namespace that is designed for local functions is hardly polluting it! Note that if the 'inner' function is needed in two clauses of the same function, it cannot be inside both, so it would have to be at top level anyway. Somehow, I find myself writing nested functions all the time in Haskell, but never wanting to in Erlang. Of course, many functional language compilers implement nested functions by moving them out to top level anyway... It's a fundamental property of Erlang scope rules that there is no letrec. From sgrady@REDACTED Tue Oct 7 03:06:55 2008 From: sgrady@REDACTED (Steven Grady) Date: Mon, 6 Oct 2008 18:06:55 -0700 Subject: [erlang-questions] re cursive fun() In-Reply-To: <6c2563b20810050213r7ea28fdbp9b2205332b3662a2@mail.gmail.com> References: <19820386.post@talk.nabble.com> <6c2563b20810050213r7ea28fdbp9b2205332b3662a2@mail.gmail.com> Message-ID: BTW, this question has apparently come up before (multiple times). The key google phrase is "Y combinator": http://bc.tech.coop/blog/070611.html Steven On Oct 5, 2008, at 2:13 AM, Edwin Fine wrote: > I'm assuming that you want to do this in the shell, otherwise it > would be easier just to write the function in the usual way, e.g. > > myfun() -> > blah, blah, > myfun(). > > To create a fun that calls itself, you must realize that you are > creating an unnamed function. When you write > > fun(X) -> X * 2 end. > > this is compiled to a Fun data type, e.g. #Fun. > > Since the function does not have a name, it cannot refer to itself. > > When you write FunVar = fun(X) -> X * 2 end, the function is bound > to the variable FunVar. Because the binding takes place *after* the > fun is created, the fun cannot refer to the variable FunVar within > its definition. > > So how is it done? You have to pass the variable to the function so > that it "knows" what to call: > > FunVar = > fun(MySelf) -> > ... > MySelf(). > > Then when you call it, you call FunVar(FunVar). Looks strange but it > works. > > Example: Writing a simple generate and fold function using only a > fun() variable. > > 9> GenFold = > fun(0, Acc, _) -> > Acc; > (X, Acc, Fun) -> > Fun(X - 1, [X|Acc], Fun) > end. > #Fun > 10> GenFold(10, [], GenFold). > [1,2,3,4,5,6,7,8,9,10] > 11> > > Or a for loop: > > 22> For = > fun(Max, Max, ExecFun, _) -> > ok; > (N, Max, ExecFun, Next) -> > ExecFun(N), > Next(N + 1, Max, ExecFun, Next) > end. > #Fun > 23> For(0,10,fun(I) -> io:format("~B ", [I]) end, For). > 0 1 2 3 4 5 6 7 8 9 ok > 24> > > Stuff like this is described in Joe Armstrong's Erlang book. > > Hope this helps. > > On Sat, Oct 4, 2008 at 11:19 PM, deepblue_other > wrote: > > hello > I have this going on > > FunVar = > fun() -> > ... > FunVar() > end. > > so the compiler is complaining that FunVar is unbound at the place > where its > being used inside fun(); this makes sense, however Im wondering how > to make > this into a recursive function since there's no name to reference the > function with. > > thanks > -- > View this message in context: http://www.nabble.com/recursive-fun%28%29-tp19820386p19820386.html > Sent from the Erlang Questions mailing list archive at Nabble.com. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From ok@REDACTED Tue Oct 7 04:43:19 2008 From: ok@REDACTED (Richard O'Keefe) Date: Tue, 7 Oct 2008 15:43:19 +1300 Subject: [erlang-questions] re cursive fun() In-Reply-To: <8e04b5820810050711s5d4ef554v50131c481fa19e85@mail.gmail.com> References: <19820386.post@talk.nabble.com> <48E8892E.5040204@it.uu.se> <8e04b5820810050711s5d4ef554v50131c481fa19e85@mail.gmail.com> Message-ID: <58B11B10-F2AA-4702-A625-A73F9F239A40@cs.otago.ac.nz> On 6 Oct 2008, at 3:11 am, Ciprian Dorin Craciun wrote: > About this subject, I would ask if isn't it better / easier / > clearer to add a special function name / keyword that would refer to > the function itself. This would also have a few advantages: Please write an EEP about this. > > * first it will solve the recursivity problem described above; The particular example here seems to be one that would have been better addressed using existing debugging tools. Recursiveness is not a problem; it's *anonymous* recursive functions. > > * (maybe) it could also improve efficiency (because you know > exactly what function you're calling, without any lookup); (this is > just an assumption, maybe inside the beam file the lookup does not > exist); (certainly it is more efficient than the proposed solution --- > sending the function as an argument;) The best recommendation that has been given is to use a plain ordinary top level function. This is _already_ more efficient than anything based on funs could be (because it is _certain_ not to need to unpack or repack outer variables), and it is certainly easier to get your head around (*some* variables in a function refer to outer variables, *some* do not, despite having the same name as outer variables). > > * it will assist in refactoring --- changing a recursive function > name will have no impact on it's code; Yes it will. Suppose we add something like Factorial = fun:Self (N) when N > 1 -> N*Self(N-1) ; (N) when N >= 0 -> 1 end, [Factorial(X) || X <- [3,1,4,1,5,9,2,6,5,3,5]] Changing "Self" in one place means it had better be changed in other places. For that matter, changing "Factorial" in one place means it has to be changed in other places. > > * it could clearly mark the fact that the function calls itself. It's hard to see how. The mere existence of a mark (such as :Self) is no guarantee that the body of the function *uses* it. And if you are thinking in terms of something like this_fun(), please, we've suffered enough from C already, and don't need any more like that. Consider F = fun:Outer (...) -> ... G = fun:Inner (...) -> ... Inner(X) ... ... Outer(Y) ... end ... Outer ... G ... end With a hook like this, the inner function can not only refer to itself, but also to the function that contains it. With a 'this_fun()' approach, it can't. > As for disadvantages I really do not see any. Try looking just a _little_ harder. > > P.S.: I think this solution could be equally applied to all > languages (mainly Lisp like). Most functional languages don't *need* it because they have 'letrec'. (In Lisp it's called 'labels'.) Even BCPL had letrec, let F(...) = E1 and G(...) = E2 and H(...) = E3 was a letrec in which F G and H could refer to each other. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From zerthurd@REDACTED Tue Oct 7 06:02:54 2008 From: zerthurd@REDACTED (Maxim Treskin) Date: Tue, 7 Oct 2008 11:02:54 +0700 Subject: [erlang-questions] ?DATE and ?TIME MACROs In-Reply-To: References: Message-ID: Hello ?DATE and ?TIME are common and constant for whole application in compilation time. It is not similar to ?FUNCTION, ?MODULE, ?LINE which cannot be specified by -D parameter of erlc. So, better way to definition of ?DATE and ?TIME is commandline options of erlc, specified in Makefile. However it is good idea to add ?FUNCTION to epp. -- Maxim Treskin -------------- next part -------------- An HTML attachment was scrubbed... URL: From kenneth.lundin@REDACTED Tue Oct 7 07:57:27 2008 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Tue, 7 Oct 2008 07:57:27 +0200 Subject: [erlang-questions] Erlang external binary term format In-Reply-To: References: <19830781.post@talk.nabble.com> <19830881.post@talk.nabble.com> Message-ID: Hi Christian, There is absolutely no reason to look at the file you are suggesting now when the contents of that file is moved into the official documentation (since R12B) and is available in both html and pdf. We will actually remove the file erl_ext_dist.txt since it is no longer needed. /Kenneth ERlang/OTP team at Ericsson On Mon, Oct 6, 2008 at 8:12 AM, Christian wrote: > You might want to look at > ./erts/emulator/internal_doc/erl_ext_dist.txt in the source tree. > > > On Mon, Oct 6, 2008 at 3:29 AM, deepblue_other wrote: >> >> for example >> one day I was looking at the term_to_binary() output of >> {binaries,"are",useful} >> and it was: >> 131,104,3,100,0,8,98,105,110,97,114,105,101,115,107,0,3,97,114,101,100,0,6,117,115,101,102,117,108 > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From dgud@REDACTED Tue Oct 7 08:30:44 2008 From: dgud@REDACTED (Dan Gudmundsson) Date: Tue, 07 Oct 2008 08:30:44 +0200 Subject: [erlang-questions] Some mnesia oddity In-Reply-To: <269388e30810061038u66e36bd9w7aeab7eaafa26449@mail.gmail.com> References: <48B7DB67.7010608@erix.ericsson.se> <269388e30810050420w38e3cc77h23dea901c39d6cc1@mail.gmail.com> <48E9BF0F.7080303@erix.ericsson.se> <269388e30810061038u66e36bd9w7aeab7eaafa26449@mail.gmail.com> Message-ID: <48EB0214.5090701@erix.ericsson.se> Ben Hood wrote: > Dan, > > On Mon, Oct 6, 2008 at 8:32 AM, Dan Gudmundsson wrote: >> You should be able to read the table in the same transaction, >> but there is a bug in mnesia handling the special atom '_'. >> >> delete_object is not match delete do you have records with '_' in them?? > Yes, but I may be missing the point. The test case I attached in my > previous mail leads me to believe that wildcards do actually work with > delete_object. No it doesn't, see the first mail in this thread, if it does in some cases it is a bug too, is shouldn't work. > As for the visibility of the deleted records, the same test case shows > that deleted records are still visible to subsequent reads within the > same transaction. Are you saying that this is the expected behavior? That's a part of the bug above, you shouldn't see the deleted records, but then since you are not suppose to be able to delete them with the wildcard '_'. > Or should I modify the test to iterate over the table with > match_object and delete the records via their key? Yes, or clear_table (but that's not allowed inside a transaction). I will probably disallow '_' and '$[1-n]' in mnesia:delete_object. Regards /Dan > Thx, > Ben > From 0x6e6562@REDACTED Tue Oct 7 09:58:16 2008 From: 0x6e6562@REDACTED (Ben Hood) Date: Tue, 7 Oct 2008 08:58:16 +0100 Subject: [erlang-questions] Some mnesia oddity In-Reply-To: <48EB0214.5090701@erix.ericsson.se> References: <48B7DB67.7010608@erix.ericsson.se> <269388e30810050420w38e3cc77h23dea901c39d6cc1@mail.gmail.com> <48E9BF0F.7080303@erix.ericsson.se> <269388e30810061038u66e36bd9w7aeab7eaafa26449@mail.gmail.com> <48EB0214.5090701@erix.ericsson.se> Message-ID: <269388e30810070058m43b79b33sda220791309291ab@mail.gmail.com> Dan, On Tue, Oct 7, 2008 at 7:30 AM, Dan Gudmundsson wrote: > No it doesn't, see the first mail in this thread, if it does in some cases > it is a bug too, is shouldn't work. Good to know that this is not the intended behavior, even if it does seem to work in a variety of cases. This clears up the mystery of what this is not documented in the mnesia guide. > That's a part of the bug above, you shouldn't see the deleted records, > but then since you are not suppose to be able to delete them with the > wildcard > '_'. I converted the test to iterate over the table with mnesia:match_object/1 and then remove each element mnesia:delete/1 and then the results of this were visible within the same transaction. So this is consistent with the fact that you are not supposed to be able to use wildcards with delete_object. > I will probably disallow '_' and '$[1-n]' in mnesia:delete_object. Thanks for the heads up. I will remove all usages of wildcards in mnesia:delete_object/1 calls in our code. Thx, Ben From mats.cronqvist@REDACTED Tue Oct 7 10:28:19 2008 From: mats.cronqvist@REDACTED (Mats Cronqvist) Date: Tue, 07 Oct 2008 10:28:19 +0200 Subject: [erlang-questions] Get a range of tuples from a Mnesia table In-Reply-To: <6c2563b20810041111t401ebb0fh5482d383438f0b8b@mail.gmail.com> References: <60ed8a460810040919qcf9dd37m994bbf6932f18cc0@mail.gmail.com> <6c2563b20810041111t401ebb0fh5482d383438f0b8b@mail.gmail.com> Message-ID: <48EB1DA3.8030304@gmail.com> Edwin Fine wrote: > Looking through the docs, I see that if you are using an mnesia table > that is ram_copies or disc_copies, you can do certain fast operations > on the associated ets table. One such operation (which is recommended > only for debugging, but what the heck) is ets:slot(Tab, I), which > returns the I'th record in the table. slot/2 does not in general return the I:th record. it does return a one-element list of the I:th record, iff the table is of type ordered_set. for other table types, it returns a list of all records in the I:th slot, i.e. all objects whose keys hash to the same value. mats From mats.cronqvist@REDACTED Tue Oct 7 11:35:09 2008 From: mats.cronqvist@REDACTED (Mats Cronqvist) Date: Tue, 07 Oct 2008 11:35:09 +0200 Subject: [erlang-questions] ?DATE and ?TIME MACROs In-Reply-To: References: Message-ID: <48EB2D4D.2060909@gmail.com> harry wrote: > Hi, > > trawling through the archives I found the answer to how to do a ? > FUNCTION macro. > > How would you do ?DATE and ?TIME (apart from erlc -DDATE=`time` .... > or something similar, which is *nix specific) > > -define(DATE,proplists:get_value(time,?MODULE:module_info(compile))). From zerthurd@REDACTED Tue Oct 7 12:22:28 2008 From: zerthurd@REDACTED (Maxim Treskin) Date: Tue, 7 Oct 2008 17:22:28 +0700 Subject: [erlang-questions] ?DATE and ?TIME MACROs In-Reply-To: <48EB2D4D.2060909@gmail.com> References: <48EB2D4D.2060909@gmail.com> Message-ID: On 07/10/2008, Mats Cronqvist wrote: > > -define(DATE,proplists:get_value(time,?MODULE:module_info(compile))). Fine! :D -- Maxim Treskin From mpharrison@REDACTED Tue Oct 7 12:22:35 2008 From: mpharrison@REDACTED (harry) Date: Tue, 7 Oct 2008 03:22:35 -0700 (PDT) Subject: [erlang-questions] ?DATE and ?TIME MACROs In-Reply-To: <48EB2D4D.2060909@gmail.com> References: <48EB2D4D.2060909@gmail.com> Message-ID: <18e4500f-28db-4efd-b399-885fc7ff3e68@l62g2000hse.googlegroups.com> Excellent, thanks! I'm struggling to find docs on module_info. I'm guessing erlc inserts it into each module, and it uses beam_lib? Rgds, Matthew (aka Harry) On Oct 7, 10:35?am, Mats Cronqvist wrote: > harry wrote: > > Hi, > > > trawling through the archives I found the answer to how to do a ? > > FUNCTION macro. > > > How would you do ?DATE and ?TIME (apart from erlc -DDATE=`time` .... > > or something similar, which is *nix specific) > > -define(DATE,proplists:get_value(time,?MODULE:module_info(compile))). > > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions From 0x6e6562@REDACTED Tue Oct 7 13:19:05 2008 From: 0x6e6562@REDACTED (Ben Hood) Date: Tue, 7 Oct 2008 12:19:05 +0100 Subject: [erlang-questions] Some mnesia oddity In-Reply-To: <269388e30810070058m43b79b33sda220791309291ab@mail.gmail.com> References: <48B7DB67.7010608@erix.ericsson.se> <269388e30810050420w38e3cc77h23dea901c39d6cc1@mail.gmail.com> <48E9BF0F.7080303@erix.ericsson.se> <269388e30810061038u66e36bd9w7aeab7eaafa26449@mail.gmail.com> <48EB0214.5090701@erix.ericsson.se> <269388e30810070058m43b79b33sda220791309291ab@mail.gmail.com> Message-ID: <269388e30810070419n1229dc14sce7fd2e51d65391d@mail.gmail.com> Dan, On Tue, Oct 7, 2008 at 8:58 AM, Ben Hood <0x6e6562@REDACTED> wrote: >> I will probably disallow '_' and '$[1-n]' in mnesia:delete_object. > > Thanks for the heads up. I will remove all usages of wildcards in > mnesia:delete_object/1 calls in our code. Just FYI: When I changed the wildcard deletes with exact key matches in a loop, the performance of removing entries in this table dropped by about 40% in my particular application. Is there some way to remove batches of records more efficiently? Would it make a difference to use a dirty_delete? Thx, Ben From vychodil.hynek@REDACTED Tue Oct 7 13:32:37 2008 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Tue, 7 Oct 2008 13:32:37 +0200 Subject: [erlang-questions] re cursive fun() In-Reply-To: <58B11B10-F2AA-4702-A625-A73F9F239A40@cs.otago.ac.nz> References: <19820386.post@talk.nabble.com> <48E8892E.5040204@it.uu.se> <8e04b5820810050711s5d4ef554v50131c481fa19e85@mail.gmail.com> <58B11B10-F2AA-4702-A625-A73F9F239A40@cs.otago.ac.nz> Message-ID: <20081007113238.7D4902407D@relay.gooddata.com> On Tue, Oct 7, 2008 at 4:43 AM, Richard O'Keefe wrote: > > On 6 Oct 2008, at 3:11 am, Ciprian Dorin Craciun wrote: > > About this subject, I would ask if isn't it better / easier / > > clearer to add a special function name / keyword that would refer to > > the function itself. This would also have a few advantages: > > Please write an EEP about this. > > > > > * first it will solve the recursivity problem described above; > > The particular example here seems to be one that would have been > better addressed using existing debugging tools. > > Recursiveness is not a problem; it's *anonymous* recursive > functions. > > > > * (maybe) it could also improve efficiency (because you know > > exactly what function you're calling, without any lookup); (this is > > just an assumption, maybe inside the beam file the lookup does not > > exist); (certainly it is more efficient than the proposed solution --- > > sending the function as an argument;) > > The best recommendation that has been given is to use a plain > ordinary top level function. This is _already_ more efficient > than anything based on funs could be (because it is _certain_ > not to need to unpack or repack outer variables), and it is > certainly easier to get your head around (*some* variables > in a function refer to outer variables, *some* do not, > despite having the same name as outer variables). > > > > > * it will assist in refactoring --- changing a recursive function > > name will have no impact on it's code; > > Yes it will. Suppose we add something like > > Factorial = fun:Self (N) when N > 1 -> N*Self(N-1) > ; (N) when N >= 0 -> 1 > end, > [Factorial(X) || X <- [3,1,4,1,5,9,2,6,5,3,5]] > > Changing "Self" in one place means it had better be changed > in other places. For that matter, changing "Factorial" in > one place means it has to be changed in other places. > > > > > * it could clearly mark the fact that the function calls itself. > > It's hard to see how. The mere existence of a mark (such as :Self) > is no guarantee that the body of the function *uses* it. And if > you are thinking in terms of something like this_fun(), please, > we've suffered enough from C already, and don't need any more like > that. Consider > > F = fun:Outer (...) -> > ... G = fun:Inner (...) -> > ... Inner(X) ... > ... Outer(Y) ... > end > ... Outer ... G ... > end > Is there any problem write this think this way? F = begin Outher = fun(OSelf, ...) -> ... Inner = fun(ISelf, ....) -> ... ISelf(ISelf, X) ... ... OSelf(OSelf, Y) ... end, ... OSelf(OSelf, ...) ... Inner(Inner, ...) ... fun(Args) -> Outher(Outher, Args) end end. For Example factorial: Fact = begin F = fun(_, 0) -> 1; (Self, N) -> Self(Self, N-1)*N end, fun(N) -> F(F, N) end end. Some nontrivial example: 4> UpToGen = begin Outher = fun(_OSelf, M, M) -> []; (OSelf, Step, M) -> Inner = fun(_ISelf, N) when N>M -> []; (ISelf, N) -> [N | ISelf(ISelf, N+Step) ] end, [Inner(Inner, 0) | OSelf(OSelf, Step+1, M)] end, fun(Max) -> Outher(Outher, 1, Max) end end. #Fun 5> UpToGen(10). [[0,1,2,3,4,5,6,7,8,9,10], [0,2,4,6,8,10], [0,3,6,9], [0,4,8], [0,5,10], [0,6], [0,7], [0,8], [0,9]] > > With a hook like this, the inner function can not only refer to > itself, but also to the function that contains it. With a > 'this_fun()' approach, it can't. > > > As for disadvantages I really do not see any. > > Try looking just a _little_ harder. > > > > > P.S.: I think this solution could be equally applied to all > > languages (mainly Lisp like). > > Most functional languages don't *need* it because they > have 'letrec'. (In Lisp it's called 'labels'.) > Even BCPL had letrec, > let F(...) = E1 > and G(...) = E2 > and H(...) = E3 > was a letrec in which F G and H could refer to each other. > > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- --Hynek (Pichi) Vychodil -------------- next part -------------- An HTML attachment was scrubbed... URL: From dgud@REDACTED Tue Oct 7 13:45:47 2008 From: dgud@REDACTED (Dan Gudmundsson) Date: Tue, 07 Oct 2008 13:45:47 +0200 Subject: [erlang-questions] Some mnesia oddity In-Reply-To: <269388e30810070419n1229dc14sce7fd2e51d65391d@mail.gmail.com> References: <48B7DB67.7010608@erix.ericsson.se> <269388e30810050420w38e3cc77h23dea901c39d6cc1@mail.gmail.com> <48E9BF0F.7080303@erix.ericsson.se> <269388e30810061038u66e36bd9w7aeab7eaafa26449@mail.gmail.com> <48EB0214.5090701@erix.ericsson.se> <269388e30810070058m43b79b33sda220791309291ab@mail.gmail.com> <269388e30810070419n1229dc14sce7fd2e51d65391d@mail.gmail.com> Message-ID: <48EB4BEB.6040607@erix.ericsson.se> Ben Hood wrote: > Dan, > > On Tue, Oct 7, 2008 at 8:58 AM, Ben Hood <0x6e6562@REDACTED> wrote: >>> I will probably disallow '_' and '$[1-n]' in mnesia:delete_object. >> Thanks for the heads up. I will remove all usages of wildcards in >> mnesia:delete_object/1 calls in our code. > > Just FYI: When I changed the wildcard deletes with exact key matches > in a loop, the performance of removing entries in this table dropped > by about 40% in my particular application. > > Is there some way to remove batches of records more efficiently? Would > it make a difference to use a dirty_delete? No not today, and I _guess_ that if I implement a match_delete like function it would cost about the same. The cost is in copying the operations to the temporary transaction store and searching it when doing the following operations, I can of course do something special but then that have to be checked (a performance cost) in every write and read operation. /Dan > Thx, > > Ben > From rasmussen.bryan@REDACTED Tue Oct 7 13:53:13 2008 From: rasmussen.bryan@REDACTED (bryan rasmussen) Date: Tue, 7 Oct 2008 13:53:13 +0200 Subject: [erlang-questions] xmerl_xpath and namespaces In-Reply-To: <48e6915d.050cc00a.5255.ffffba16@mx.google.com> References: <48e6915d.050cc00a.5255.ffffba16@mx.google.com> Message-ID: <3bb44c6e0810070453s64aba01dhbb57ffbc4714f065@mail.gmail.com> Hi Denis, 2008/10/3 denis : > Hello, > > > > I'm having some problem using xmerl_xpath on a document having namespaces. > I'm not sure I fully understand how all of this work and the problem should > not come from xmerl_xpath, but from my misunderstanding of xml, namespace, > xpath? > > It seems that with xpath, it's mandatory to give the namespace. > > > For instance, in a document like this: > > > > > > > targetNamespace="http://schemas.microsoft.com/2003/10/Serialization/"> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > If I want to get all "element" attributes, I need to do a query like > > xmerl_xpath:string("//xs:simpleType", X) > > Is there a way to not having to give the namespace in the query ?? This XPath should get it //*[local-name()='simpleType'] but that would also get any element where the local name (xpath term for dom basename) of an element was simpleType so if your instance was this blah blah blah 3 blahs long! then the xpath would return both blah:simpleType and xs:simpleType, but how often is that a real problem. Cheers, Bryan Rasmussen From rasmussen.bryan@REDACTED Tue Oct 7 13:54:37 2008 From: rasmussen.bryan@REDACTED (bryan rasmussen) Date: Tue, 7 Oct 2008 13:54:37 +0200 Subject: [erlang-questions] Erlang with MonetDb Message-ID: <3bb44c6e0810070454s5cd3a829p524ce628808a2323@mail.gmail.com> Hi, Anyone out there made some erlang examples working with MonetDB? using ODBC acceptable. Cheers, Bryan Rasmussen From ulf.wiger@REDACTED Tue Oct 7 15:30:22 2008 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Tue, 07 Oct 2008 15:30:22 +0200 Subject: [erlang-questions] Some mnesia oddity In-Reply-To: <269388e30810070419n1229dc14sce7fd2e51d65391d@mail.gmail.com> References: <48B7DB67.7010608@erix.ericsson.se> <269388e30810050420w38e3cc77h23dea901c39d6cc1@mail.gmail.com> <48E9BF0F.7080303@erix.ericsson.se> <269388e30810061038u66e36bd9w7aeab7eaafa26449@mail.gmail.com> <48EB0214.5090701@erix.ericsson.se> <269388e30810070058m43b79b33sda220791309291ab@mail.gmail.com> <269388e30810070419n1229dc14sce7fd2e51d65391d@mail.gmail.com> Message-ID: <48EB646E.3080104@ericsson.com> Ben Hood skrev: > > Is there some way to remove batches of records more efficiently? > Would it make a difference to use a dirty_delete? On replicated tables, using dirty writes or deletes for batch updates can easily be _less_ efficient (and considerably less safe) than using transactions. The reason is that, if you take a table lock, the overhead for starting the transaction, acquiring the lock and committing (where all operations are included in the commit message), becomes insignificant at some point, compared to the combined overhead of making an rpc call for each single operation. If you _know_ that the table isn't replicated, there are various dirty ways to speed things up, including perhaps even changing the table copy type to ram, making all changes directly on the ets table, and then changing the copy type back to disc_copies (if that's what it was from the beginning). Of course, if confronted, I'll deny that I ever wrote this. ;-) BR, Ulf W From mats.cronqvist@REDACTED Tue Oct 7 15:31:16 2008 From: mats.cronqvist@REDACTED (Mats Cronqvist) Date: Tue, 07 Oct 2008 15:31:16 +0200 Subject: [erlang-questions] ?DATE and ?TIME MACROs In-Reply-To: <18e4500f-28db-4efd-b399-885fc7ff3e68@l62g2000hse.googlegroups.com> References: <48EB2D4D.2060909@gmail.com> <18e4500f-28db-4efd-b399-885fc7ff3e68@l62g2000hse.googlegroups.com> Message-ID: <48EB64A4.90805@gmail.com> harry wrote: > Excellent, thanks! > > I'm struggling to find docs on module_info. > I'm guessing erlc inserts it into each module yes. > and it uses beam_lib? > afaik, no. it's just a regular exported function that would look something like this in Erlang. module_info() -> . module_info(Tag) -> try proplists:get_value(Tag,module_info()) catch _:_ -> exit(badarg) end. where is a constant term. this is just speculation on my part though. mats From dloutrein.lists@REDACTED Tue Oct 7 15:42:58 2008 From: dloutrein.lists@REDACTED (denis) Date: Tue, 7 Oct 2008 09:42:58 -0400 Subject: [erlang-questions] xmerl_xpath and namespaces In-Reply-To: <3bb44c6e0810070453s64aba01dhbb57ffbc4714f065@mail.gmail.com> References: <48e6915d.050cc00a.5255.ffffba16@mx.google.com> <3bb44c6e0810070453s64aba01dhbb57ffbc4714f065@mail.gmail.com> Message-ID: <48eb6764.070fc00a.3f1c.ffff96ce@mx.google.com> Hi bryan, > > > > If I want to get all "element" attributes, I need to do a query like > > > > xmerl_xpath:string("//xs:simpleType", X) > > > > Is there a way to not having to give the namespace in the query ?? > > This XPath should get it //*[local-name()='simpleType'] > I had test this before but where unable to get it working with R12B3. I tried it again yesterday with R12B4 and it works now. It was a bug which has been fixed. Cool ! Thanks for your answer Denis From richardc@REDACTED Tue Oct 7 16:19:04 2008 From: richardc@REDACTED (Richard Carlsson) Date: Tue, 07 Oct 2008 16:19:04 +0200 Subject: [erlang-questions] ?DATE and ?TIME MACROs In-Reply-To: <48EB64A4.90805@gmail.com> References: <48EB2D4D.2060909@gmail.com> <18e4500f-28db-4efd-b399-885fc7ff3e68@l62g2000hse.googlegroups.com> <48EB64A4.90805@gmail.com> Message-ID: <48EB6FD8.1000107@it.uu.se> Mats Cronqvist wrote: > afaik, no. it's just a regular exported function that would look > something like this in Erlang. > > module_info() -> . > module_info(Tag) -> > try proplists:get_value(Tag,module_info()) > catch _:_ -> exit(badarg) > end. > > where is a constant term. > this is just speculation on my part though. That used to be true, but these days they are simply wrappers around a couple of built-in (undocumented?) functions, like this: module_info() -> erlang:get_module_info(?MODULE). module_info(Tag) -> erlang:get_module_info(?MODULE, Tag). (Since the metadata is already loaded from a chunk in the beam file, there is no need to duplicate it in the code.) But the compiler inserts the functions, yes. /Richard From dmercer@REDACTED Tue Oct 7 16:29:18 2008 From: dmercer@REDACTED (David Mercer) Date: Tue, 7 Oct 2008 09:29:18 -0500 Subject: [erlang-questions] re cursive fun() In-Reply-To: <20081007113238.7D4902407D@relay.gooddata.com> References: <19820386.post@talk.nabble.com> <48E8892E.5040204@it.uu.se><8e04b5820810050711s5d4ef554v50131c481fa19e85@mail.gmail.com><58B11B10-F2AA-4702-A625-A73F9F239A40@cs.otago.ac.nz> <20081007113238.7D4902407D@relay.gooddata.com> Message-ID: <0F3BFEC2F16D4D66A6AF13B05F481CF3@SSI.CORP> On Tuesday, October 07, 2008, Hynek Vychodil wrote: > Is there any problem write this think this way? . . . > For Example factorial: > > Fact = begin F = fun(_, 0) -> 1; (Self, N) -> Self(Self, N-1)*N end, fun(N) -> F(F, N) end end. My only objection is that it pollutes the shell variable space with the extra function F. How about: Fact = fun(N) -> F = fun(_, 0) -> 1; (Self, N) -> Self(Self, N-1)*N end, F(F, N) end. Cheers, David -------------- next part -------------- An HTML attachment was scrubbed... URL: From mpharrison@REDACTED Tue Oct 7 16:32:16 2008 From: mpharrison@REDACTED (harry) Date: Tue, 7 Oct 2008 07:32:16 -0700 (PDT) Subject: [erlang-questions] ?DATE and ?TIME MACROs In-Reply-To: <48EB64A4.90805@gmail.com> References: <48EB2D4D.2060909@gmail.com> <18e4500f-28db-4efd-b399-885fc7ff3e68@l62g2000hse.googlegroups.com> <48EB64A4.90805@gmail.com> Message-ID: Cheers, I had a dig around in the source in compile, and found some other possible tags. But, I wonder, if this is not documented, might it change in the future? On Oct 7, 2:31?pm, Mats Cronqvist wrote: > harry wrote: > > Excellent, thanks! > > > I'm struggling to find docs on module_info. > > I'm guessing erlc inserts it into each module > > yes. > > > and it uses beam_lib? > > ?afaik, no. it's just a regular exported function that would look > something like this in Erlang. > > module_info() -> . > module_info(Tag) -> > ?try proplists:get_value(Tag,module_info()) > ?catch _:_ -> exit(badarg) > ?end. > > ?where is a constant term. > ?this is just speculation on my part though. > > ? mats > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions From mpharrison@REDACTED Tue Oct 7 17:09:11 2008 From: mpharrison@REDACTED (harry) Date: Tue, 7 Oct 2008 08:09:11 -0700 (PDT) Subject: [erlang-questions] ?DATE and ?TIME MACROs In-Reply-To: <48EB6FD8.1000107@it.uu.se> References: <48EB2D4D.2060909@gmail.com> <18e4500f-28db-4efd-b399-885fc7ff3e68@l62g2000hse.googlegroups.com> <48EB64A4.90805@gmail.com> <48EB6FD8.1000107@it.uu.se> Message-ID: <42529f32-ebd1-418a-a582-d35459f92a5e@k37g2000hsf.googlegroups.com> Should I post on erlang-bugs to get module_info() and get_module_info() documented? They seem really useful. (I tried it & the info survives beam_lib:strip()) Rgds, Matthew. On Oct 7, 3:19?pm, Richard Carlsson wrote: > That used to be true, but these days they are simply > wrappers around a couple of built-in (undocumented?) > functions, like this: > > module_info() -> erlang:get_module_info(?MODULE). > module_info(Tag) -> erlang:get_module_info(?MODULE, Tag). > > (Since the metadata is already loaded from a chunk in the > beam file, there is no need to duplicate it in the code.) > > But the compiler inserts the functions, yes. > > ? ? /Richard > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions From vychodil.hynek@REDACTED Tue Oct 7 17:47:08 2008 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Tue, 7 Oct 2008 17:47:08 +0200 Subject: [erlang-questions] re cursive fun() In-Reply-To: <0F3BFEC2F16D4D66A6AF13B05F481CF3@SSI.CORP> References: <19820386.post@talk.nabble.com> <48E8892E.5040204@it.uu.se> <8e04b5820810050711s5d4ef554v50131c481fa19e85@mail.gmail.com> <58B11B10-F2AA-4702-A625-A73F9F239A40@cs.otago.ac.nz> <20081007113238.7D4902407D@relay.gooddata.com> <0F3BFEC2F16D4D66A6AF13B05F481CF3@SSI.CORP> Message-ID: <20081007154709.5F69224089@relay.gooddata.com> Yes of course, it can be done. There is little difference when closure is made. this second example can be rewritten (and simplified) in same manner: UpToGen = fun(Max) -> Outer = fun(_OSelf, Max) -> []; (OSelf, Step) -> Inner = fun(_ISelf, N) when N>Max -> []; (ISelf, N) -> [N | ISelf(ISelf, N+Step) ] end, [Inner(Inner, 0) | OSelf(OSelf, Step+1)] end, Outer(Outer, 1) end. On Tue, Oct 7, 2008 at 4:29 PM, David Mercer wrote: > On Tuesday, October 07, 2008, Hynek Vychodil wrote: > > > > > Is there any problem write this think this way? > > . . . > > > For Example factorial: > > > > > > Fact = begin F = fun(_, 0) -> 1; (Self, N) -> Self(Self, N-1)*N end, > fun(N) -> F(F, N) end end. > > > > My only objection is that it pollutes the shell variable space with the > extra function F. How about: > > > > Fact = fun(N) -> F = fun(_, 0) -> 1; (Self, N) -> Self(Self, N-1)*N end, > F(F, N) end. > > > > Cheers, > > > > David > -- --Hynek (Pichi) Vychodil -------------- next part -------------- An HTML attachment was scrubbed... URL: From erlang-questions_efine@REDACTED Tue Oct 7 17:54:40 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Tue, 7 Oct 2008 11:54:40 -0400 Subject: [erlang-questions] Get a range of tuples from a Mnesia table In-Reply-To: <48EB1DA3.8030304@gmail.com> References: <60ed8a460810040919qcf9dd37m994bbf6932f18cc0@mail.gmail.com> <6c2563b20810041111t401ebb0fh5482d383438f0b8b@mail.gmail.com> <48EB1DA3.8030304@gmail.com> Message-ID: <6c2563b20810070854u3eb94b79u5c8d90c7b7a4373c@mail.gmail.com> RIght. He did say he was using an ordered_set, and I was imprecise in saying that it returned the record rather than a one-element list containing the record. Poetic license :) On Tue, Oct 7, 2008 at 4:28 AM, Mats Cronqvist wrote: > Edwin Fine wrote: > >> Looking through the docs, I see that if you are using an mnesia table that >> is ram_copies or disc_copies, you can do certain fast operations on the >> associated ets table. One such operation (which is recommended only for >> debugging, but what the heck) is ets:slot(Tab, I), which returns the I'th >> record in the table. >> > > slot/2 does not in general return the I:th record. > it does return a one-element list of the I:th record, iff the table is of > type ordered_set. for other table types, it returns a list of all records in > the I:th slot, i.e. all objects whose keys hash to the same value. > > mats > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob@REDACTED Tue Oct 7 18:34:28 2008 From: bob@REDACTED (Bob Ippolito) Date: Tue, 7 Oct 2008 09:34:28 -0700 Subject: [erlang-questions] Erlang with MonetDb In-Reply-To: <3bb44c6e0810070454s5cd3a829p524ce628808a2323@mail.gmail.com> References: <3bb44c6e0810070454s5cd3a829p524ce628808a2323@mail.gmail.com> Message-ID: <6a36e7290810070934k1a3fbf43k258c6220b6a56e75@mail.gmail.com> I don't have an answer for you, but we tried using MonetDB early this year and it was an epic failure, the database corrupted itself and at times the server would grow until it ran out of RAM. We unfortunately had to resort to a commercial column store because we couldn't get MonetDB to run for more than a few hours without crashing :( On Tue, Oct 7, 2008 at 4:54 AM, bryan rasmussen wrote: > Hi, > > Anyone out there made some erlang examples working with MonetDB? using > ODBC acceptable. > > > Cheers, > Bryan Rasmussen > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From oscar@REDACTED Tue Oct 7 18:42:17 2008 From: oscar@REDACTED (=?utf-8?Q?Oscar_Hellstr=C3=B6m?=) Date: Tue, 7 Oct 2008 17:42:17 +0100 (BST) Subject: [erlang-questions] tcp sockets - not clear In-Reply-To: <17015960.6921223397512269.JavaMail.root@zimbra> Message-ID: <15350725.6941223397737052.JavaMail.root@zimbra> Hi, See my comments embedded. ----- Original Message ----- From: "deepblue_other" To: erlang-questions@REDACTED Sent: Monday, 6 October, 2008 12:07:02 PM GMT -08:00 US/Canada Pacific Subject: Re: [erlang-questions] tcp sockets - not clear thanks for the reply Oscar Hellstr?m-2 wrote: > > Hi, > > I'm assuming that a object is something running in a separate thread, > which means that you will have to have a thread safe implementation of the > send() function to be able to get the messages through without problems. > AFAIK know at least the POSIX implementations are thread safe. Another > important part here is that the whole message must be put on the wire > before any part of any other message is, which actually means that the > send() function need to support atomicy. If this is not the case for you > send() function you probably need to serialise the sending. You can read > more about this here: > http://www.almaden.ibm.com/cs/people/marksmith/sendmsg.html > well the flash VM does not support threading yet, so all the object instances run in the same thread - thus thread safety is not an issue. you did nail it when saying that the whole message must be on the wire, which is my original concern, but Im guessing that you guys might not be able to answer this question since how Flash internally handles this is somewhat undocumented. However I have a feeling that this is not an issue, going back to the fact that Flash is single threaded. the question I guess is if a A is sent after B, TCP will ensure that A is assembled correctly even if some parts of it come in after B. So TCP guarantees that messages arrive in one peace (are assembled correctly) but does not guarantee that they come in the order they were sent? TCP guarantees that the messages do arrive in order. The only issue you might have is that described in the link posted earlier, but that is only relevant to multi-threaded applications. If you have a single thread then I can't see why all messages wouldn' be sent atomically. Oscar Hellstr?m-2 wrote: > > Keep in mind that TCP packages can be fragmented on the way, and you need > to assemble them yourself unless you use use the {packet, 1|2|4} option > (and implement that on the flash side), i.e. you need some defined > protocol. > you confused me here a bit. Im using {packet, 4} at the moment, but Im not clear what I would have to do if it were {packet,0}, and what I have to do on the Flash side. The packet assembling would not be handled automatically by the TCP drivers on both Erlang and Flash side? The {packet, 4} adds a four byte header which has the number of bytes in the package (big endian). This means that your client needs to read four bytes, interpret them as an unsigned integer and then read that many bytes to get the whole package. I have no idea if this is built in in flash. If you use {packet, 0} you need to define you own protocol to state the payload of the message, or use some text based protocol where you can figure out if you need to read more or not by reading the message received. Oscar Hellstr?m-2 wrote: > > If you're using a text based protocol this is less of a problem (or more > depending on who you are) I guess. > > From the erlang side we seem to have the same issue that we need to > serialise the data to be absolutely sure that messages are not intervened > (since the inet_drv.c essentially calls send() at some point). Someone > please correct me if I'm wrong here. > > Hope this helps. > > ----- Original Message ----- > From: "deepblue_other" > To: erlang-questions@REDACTED > Sent: Sunday, 5 October, 2008 9:07:08 AM GMT -08:00 US/Canada Pacific > Subject: [erlang-questions] tcp sockets - not clear > > > hello everyone > Im building a system with a Flash front-end and an Erlang back-end and > have > some confusion in a case where there is a single socket on the back-end > per > user (per single socket on the front-end). > I want to have multiple independent objects on the front-end send messages > to the back-end, but am not sure how the simultaneous transmission would > be > handled. This probably stems from my somewhat clowdly understanding of > TCP. > Say there are 3 objects that initiate a send() method on the front-end > (almost at the same time) and send a semi large message each to the > back-end. Each message would be ID'd by the front-end so that when > received > back it can be routed to the appropriate callback. Is this possible? > since the packets are being assembled in the {tcp, Socket, Data} pattern > match, peace by peace, would the correct peaces of the individual messages > be stiched together? (doesnt seem like they would). > > if that wont work then I would just have the serialize the > sending/receiving, which is not too horrible... > > thanks > -- > View this message in context: > http://www.nabble.com/tcp-sockets---not-clear-tp19826070p19826070.html > Sent from the Erlang Questions mailing list archive at Nabble.com. > > Best regards > -- > Oscar Hellstr?m, oscar@REDACTED > Phone: +44 (0)798 45 44 773 > Mobile: +44 (0)207 65 50 337 > Web: http://www.erlang-consulting.com > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- View this message in context: http://www.nabble.com/tcp-sockets---not-clear-tp19826070p19844239.html Sent from the Erlang Questions mailing list archive at Nabble.com. _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions -- Oscar Hellstr?m, oscar@REDACTED Phone: +44 (0)798 45 44 773 Mobile: +44 (0)207 65 50 337 Web: http://www.erlang-consulting.com From kenneth.lundin@REDACTED Tue Oct 7 19:30:50 2008 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Tue, 7 Oct 2008 19:30:50 +0200 Subject: [erlang-questions] ?DATE and ?TIME MACROs In-Reply-To: References: <48EB2D4D.2060909@gmail.com> <18e4500f-28db-4efd-b399-885fc7ff3e68@l62g2000hse.googlegroups.com> <48EB64A4.90805@gmail.com> Message-ID: module_info ought to be documented somewhere, I actually thought it was. Our general principle is that what is documented is what we support and keep backwards compatible (as much as possible). When it comes to the information you can get out from module_info there are parts that really can be questioned and we have been thinking of changes although they can be made compatible. If we look at M:module_info it returns a list of key value tuples like this: [ {exports,ListOfExportedFunctions}, {imports,ListOfImportedFunctions}, {attributes,ListOfAttributeValues}, {compile,ListOfCompileInfo} ] where ListOfCompileInfo = [ {options,OptionList}, {version,CompilerVersion},{time,CompileDateAndTime},{source,SourceFilePath}] It is the ListOfCompileInfo that in my experience contains questionable information and that we have plans to change. For example {time,CompileTimeAndDate} which contains the time when the compilation was done, this value makes modules (.beam file) different even if they are compiled from exactly the same sources, with the same version of the compiler and with the same compiler options. This is not always a good thing for example if you want to compare beam files and find out which has changed from one version of an application to another. We have thought of 2 alternative solutions. 1) change the time info from compile time to last modification time of the source file 2) introduce a compiler option which can be used to omit the time info completely. The options info has also been questioned since it has a tendency to create large volumes of data. For example if a big project passes a very long and the same list of include directories to every compilation (even if it is not necessary for that particular file). Sometimes the volume of the data here will then be significant compared to the actual code size and the will be kept in RAM by the Erlang VM. We have thought of 2 alternative solutions here too: 1) remove all include paths not used for this file (i.e only keep the ones where we actually included a file). 2) introduce an option with which the info can be suppressed. So in summary. The CompileDateAndTime is a little unsafe to rely on because it might be changed. I actually don't understand why you are interested in ?DATE and ?TIME macros or similar info and I don't see the problem with passing -DDATE or whatever on the command line to erlc. I am sure it is possible on WIndows as well (You can as one example do it with an escript). Even the {source, SourceFilePath } is sometimes totally worthless info and can also make beam files different even though they ought to be identical. /Kenneth Erlang/OTP team, Ericsson On Tue, Oct 7, 2008 at 4:32 PM, harry wrote: > Cheers, > > I had a dig around in the source in compile, and found some other > possible tags. > > But, I wonder, if this is not documented, might it change in the > future? > > On Oct 7, 2:31 pm, Mats Cronqvist wrote: >> harry wrote: >> > Excellent, thanks! >> >> > I'm struggling to find docs on module_info. >> > I'm guessing erlc inserts it into each module >> >> yes. >> >> > and it uses beam_lib? >> >> afaik, no. it's just a regular exported function that would look >> something like this in Erlang. >> >> module_info() -> . >> module_info(Tag) -> >> try proplists:get_value(Tag,module_info()) >> catch _:_ -> exit(badarg) >> end. >> >> where is a constant term. >> this is just speculation on my part though. >> >> mats >> _______________________________________________ >> erlang-questions mailing list >> erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From 0x6e6562@REDACTED Tue Oct 7 19:31:56 2008 From: 0x6e6562@REDACTED (Ben Hood) Date: Tue, 7 Oct 2008 18:31:56 +0100 Subject: [erlang-questions] Some mnesia oddity In-Reply-To: <48EB646E.3080104@ericsson.com> References: <48B7DB67.7010608@erix.ericsson.se> <269388e30810050420w38e3cc77h23dea901c39d6cc1@mail.gmail.com> <48E9BF0F.7080303@erix.ericsson.se> <269388e30810061038u66e36bd9w7aeab7eaafa26449@mail.gmail.com> <48EB0214.5090701@erix.ericsson.se> <269388e30810070058m43b79b33sda220791309291ab@mail.gmail.com> <269388e30810070419n1229dc14sce7fd2e51d65391d@mail.gmail.com> <48EB646E.3080104@ericsson.com> Message-ID: <269388e30810071031g8f202b0xbd5b306b748071c0@mail.gmail.com> Hey Ulf, On Tue, Oct 7, 2008 at 2:30 PM, Ulf Wiger (TN/EAB) wrote: > On replicated tables, using dirty writes or deletes for batch > updates can easily be _less_ efficient (and considerably less > safe) than using transactions. > > The reason is that, if you take a table lock, the overhead > for starting the transaction, acquiring the lock and > committing (where all operations are included in the > commit message), becomes insignificant at some point, > compared to the combined overhead of making an rpc > call for each single operation. This is a very valueable insight, because the tables are actually replicated. The performance I get from the iterating through the table and deleting based on key is less performant than they wildcard option I've been using until now, but it is not unacceptably slower, and is also not using a bug as a feature, so I will go for this option. > Of course, if confronted, I'll deny that > I ever wrote this. ;-) :-) Ben From mats.cronqvist@REDACTED Tue Oct 7 21:14:15 2008 From: mats.cronqvist@REDACTED (Mats Cronqvist) Date: Tue, 07 Oct 2008 21:14:15 +0200 Subject: [erlang-questions] ?DATE and ?TIME MACROs In-Reply-To: References: <48EB2D4D.2060909@gmail.com> <18e4500f-28db-4efd-b399-885fc7ff3e68@l62g2000hse.googlegroups.com> <48EB64A4.90805@gmail.com> Message-ID: <48EBB507.7070709@gmail.com> Kenneth Lundin wrote: > [...] > So in summary. The CompileDateAndTime is a little unsafe to rely on > because it might be changed. > I actually don't understand why you are interested in ?DATE and ?TIME > macros or similar info [...] here's one use case. distel contains this snippet; %%% reload all modules that are out of date %%% compare the compile time of the loaded beam and the beam on disk reload_modules() -> T = fun(L) -> [X || X <- L, element(1,X)==time] end, Tm = fun(M) -> T(M:module_info(compile)) end, Tf = fun(F) -> {ok,{_,[{_,I}]}}=beam_lib:chunks(F,[compile_info]),T(I) end, Load = fun(M) -> c:l(M),M end, [Load(M) || {M,F} <- code:all_loaded(), is_beamfile(F), Tm(M) ok == element(1,file:read_file_info(F)) andalso ".beam" == filename:extension(F). if one manages to penetrate its general horribleness, it does a pretty useful thing; for every loaded beam, compare the compile time with that of the corresponding beam file on disk, and reload the ones that are out of date. this would of course work equally well if erlc stuck the modification time of the erl file into the beam file. mats From mats.cronqvist@REDACTED Tue Oct 7 21:41:24 2008 From: mats.cronqvist@REDACTED (Mats Cronqvist) Date: Tue, 07 Oct 2008 21:41:24 +0200 Subject: [erlang-questions] Get a range of tuples from a Mnesia table In-Reply-To: <6c2563b20810070854u3eb94b79u5c8d90c7b7a4373c@mail.gmail.com> References: <60ed8a460810040919qcf9dd37m994bbf6932f18cc0@mail.gmail.com> <6c2563b20810041111t401ebb0fh5482d383438f0b8b@mail.gmail.com> <48EB1DA3.8030304@gmail.com> <6c2563b20810070854u3eb94b79u5c8d90c7b7a4373c@mail.gmail.com> Message-ID: <48EBBB64.90404@gmail.com> Edwin Fine wrote: > RIght. He did say he was using an ordered_set, and I was imprecise in > saying that it returned the record rather than a one-element list > containing the record. Poetic license :) > A poetic license? That sounds most inconvenient. Have you considered having it removed? mats From rvirding@REDACTED Tue Oct 7 22:09:47 2008 From: rvirding@REDACTED (Robert Virding) Date: Tue, 7 Oct 2008 22:09:47 +0200 Subject: [erlang-questions] re cursive fun() In-Reply-To: <20081007154709.5F69224089@relay.gooddata.com> References: <19820386.post@talk.nabble.com> <48E8892E.5040204@it.uu.se> <8e04b5820810050711s5d4ef554v50131c481fa19e85@mail.gmail.com> <58B11B10-F2AA-4702-A625-A73F9F239A40@cs.otago.ac.nz> <20081007113238.7D4902407D@relay.gooddata.com> <0F3BFEC2F16D4D66A6AF13B05F481CF3@SSI.CORP> <20081007154709.5F69224089@relay.gooddata.com> Message-ID: <3dbc6d1c0810071309w4ee9fbb9o5eaf9c17573aa6@mail.gmail.com> It seems like there are two separate threads here: one is about defining recursive functions in the shell; and the other is about defining local (recursive) functions in a module. The first case has been reasonably covered in how you create a fun with a reference to itself so it can call itself recursively. In the second case I must agree with Richard, there is no *need* to have local (to a function) functions, you can just use normal top-level functions. They *are * more efficient than funs. I have found, however, that I sometimes use funs as local functions when I want to stress that these are local functions. Especially after a bout of LFE hacking which has them. However, if it was really desired it would be possible to add them, of course you would need both the recursive and non-recursive options. It would be a bit of a contrived expression as it would not, *could not*, return anything sensible. I would not like to add a scoping let type construction as we don't have having scoping anywhere else. Well except in funs and comprehensions where the scoping is a bit off actually. The visibility rules for the defined functions would be a bit hairy, very hairy really, but the best would be to make them the same as for variables, which are very hairy. I have no intention of adding an EEP! I don't like the idea of Self. A rather humourous note is local functions in Core erlang. In Core yo have local functions, but only the mutually recursive type. These were originally added to implement comprehensions so only the recursive kind were needed. A solution would be do what I used to threaten Bjarne with: do an E2 and get it right. What ever right is. Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf@REDACTED Tue Oct 7 22:36:10 2008 From: ulf@REDACTED (Ulf Wiger) Date: Tue, 7 Oct 2008 22:36:10 +0200 Subject: [erlang-questions] Some mnesia oddity In-Reply-To: <269388e30810071031g8f202b0xbd5b306b748071c0@mail.gmail.com> References: <48B7DB67.7010608@erix.ericsson.se> <269388e30810050420w38e3cc77h23dea901c39d6cc1@mail.gmail.com> <48E9BF0F.7080303@erix.ericsson.se> <269388e30810061038u66e36bd9w7aeab7eaafa26449@mail.gmail.com> <48EB0214.5090701@erix.ericsson.se> <269388e30810070058m43b79b33sda220791309291ab@mail.gmail.com> <269388e30810070419n1229dc14sce7fd2e51d65391d@mail.gmail.com> <48EB646E.3080104@ericsson.com> <269388e30810071031g8f202b0xbd5b306b748071c0@mail.gmail.com> Message-ID: <8209f740810071336j7044ce1eyaea6ed19aea8e1fc@mail.gmail.com> Ok, so a good rule of thumb: Don't use dirty updates on replicated tables. http://www.erlang.org/pipermail/erlang-questions/2006-February/019092.html BR, Ulf W 2008/10/7 Ben Hood <0x6e6562@REDACTED>: > Hey Ulf, > > On Tue, Oct 7, 2008 at 2:30 PM, Ulf Wiger (TN/EAB) > wrote: >> On replicated tables, using dirty writes or deletes for batch >> updates can easily be _less_ efficient (and considerably less >> safe) than using transactions. >> >> The reason is that, if you take a table lock, the overhead >> for starting the transaction, acquiring the lock and >> committing (where all operations are included in the >> commit message), becomes insignificant at some point, >> compared to the combined overhead of making an rpc >> call for each single operation. > > This is a very valueable insight, because the tables are actually replicated. > > The performance I get from the iterating through the table and > deleting based on key is less performant than they wildcard option > I've been using until now, but it is not unacceptably slower, and is > also not using a bug as a feature, so I will go for this option. > >> Of course, if confronted, I'll deny that >> I ever wrote this. ;-) > > :-) > > Ben > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From erlang-questions_efine@REDACTED Tue Oct 7 22:46:43 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Tue, 7 Oct 2008 16:46:43 -0400 Subject: [erlang-questions] ?DATE and ?TIME MACROs In-Reply-To: References: <48EB2D4D.2060909@gmail.com> <18e4500f-28db-4efd-b399-885fc7ff3e68@l62g2000hse.googlegroups.com> <48EB64A4.90805@gmail.com> Message-ID: <6c2563b20810071346q1c7aa889r7fa8b24a40275068@mail.gmail.com> Kenneth, I find module_info's {time,CompileTimeAndDate} very useful. At a glance, I can see whether a set of modules that were recently compiled made it to the target platform properly after distribution and installation. Unlike Erlang/OTP itself, the applications I am working with have frequent releases, and sometimes things can go wrong with the distribution mechanism (yes, I know, fix the mechanism, but I still like to have to ability to check). When that happens, I like to be able to look at a beam on the target system and see its compile date and time, and compare it with the known good date and time. A checksum would work just as well for pure comparison purposes but contains less information - a date/time is very human-friendly. The date of the actual beam is, I feel, somewhat more useful (to me, anyway) than the date of the source file, because when I release something I usually rebuild everything from scratch and want to see the *build* date and time in the beam files, not necessarily the *source* date and time. My vote, for what it's worth, is to keep {time,CompileTimeAndDate} and add the compile option to suppress it if it really annoys people. By the way, if module_info is documented somewhere, could some kind person please point me to it because I looked for it in the Erlang docs last night and could not find it. Not saying it's not there, just I couldn't find it. It wasn't in the permuted indexes, either. Regards, Edwin Fine On Tue, Oct 7, 2008 at 1:30 PM, Kenneth Lundin wrote: > module_info ought to be documented somewhere, I actually thought it was. > Our general principle is that what is documented is what we support > and keep backwards compatible (as much as possible). > When it comes to the information you can get out from module_info > there are parts that really can be questioned and we > have been thinking of changes although they can be made compatible. > > If we look at M:module_info it returns a list of key value tuples like > this: > [ > {exports,ListOfExportedFunctions}, > {imports,ListOfImportedFunctions}, > {attributes,ListOfAttributeValues}, > {compile,ListOfCompileInfo} > ] > > where ListOfCompileInfo = [ {options,OptionList}, > > {version,CompilerVersion},{time,CompileDateAndTime},{source,SourceFilePath}] > > It is the ListOfCompileInfo that in my experience contains > questionable information and that we have plans to change. > For example {time,CompileTimeAndDate} which contains the time when the > compilation was done, this value makes modules (.beam file) > different even if they are compiled from exactly the same sources, > with the same version of the compiler and with the same compiler > options. This is not always a good thing for example if you want to > compare beam files and find out which has changed from one > version of an application to another. > We have thought of 2 alternative solutions. 1) change the time info > from compile time to last modification time of the source file > 2) introduce a compiler option which can be used to omit the time info > completely. > > The options info has also been questioned since it has a tendency to > create large volumes of data. For example if a big project passes a > very long and the same list of include directories to every > compilation (even if it is not necessary for that particular file). > Sometimes the volume of the data here will then be significant > compared to the actual code size and the will be kept in RAM by the > Erlang VM. > We have thought of 2 alternative solutions here too: 1) remove all > include paths not used for this file (i.e only keep the ones where > we actually included a file). 2) introduce an option with which the > info can be suppressed. > > > So in summary. The CompileDateAndTime is a little unsafe to rely on > because it might be changed. > > I actually don't understand why you are interested in ?DATE and ?TIME > macros or similar info and I don't see the problem with > passing -DDATE or whatever on the command line to erlc. I am sure it > is possible on WIndows as well (You can as one example > do it with an escript). > > > Even the {source, SourceFilePath } is sometimes totally worthless info > and can also make beam files different even though > they ought to be identical. > > /Kenneth Erlang/OTP team, Ericsson > > > > On Tue, Oct 7, 2008 at 4:32 PM, harry wrote: > > Cheers, > > > > I had a dig around in the source in compile, and found some other > > possible tags. > > > > But, I wonder, if this is not documented, might it change in the > > future? > > > > On Oct 7, 2:31 pm, Mats Cronqvist wrote: > >> harry wrote: > >> > Excellent, thanks! > >> > >> > I'm struggling to find docs on module_info. > >> > I'm guessing erlc inserts it into each module > >> > >> yes. > >> > >> > and it uses beam_lib? > >> > >> afaik, no. it's just a regular exported function that would look > >> something like this in Erlang. > >> > >> module_info() -> . > >> module_info(Tag) -> > >> try proplists:get_value(Tag,module_info()) > >> catch _:_ -> exit(badarg) > >> end. > >> > >> where is a constant term. > >> this is just speculation on my part though. > >> > >> mats > >> _______________________________________________ > >> erlang-questions mailing list > >> erlang-questi...@REDACTED:// > www.erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mpharrison@REDACTED Wed Oct 8 00:39:29 2008 From: mpharrison@REDACTED (harry) Date: Tue, 7 Oct 2008 15:39:29 -0700 (PDT) Subject: [erlang-questions] ?DATE and ?TIME MACROs In-Reply-To: <6c2563b20810071346q1c7aa889r7fa8b24a40275068@mail.gmail.com> References: <48EB2D4D.2060909@gmail.com> <18e4500f-28db-4efd-b399-885fc7ff3e68@l62g2000hse.googlegroups.com> <48EB64A4.90805@gmail.com> <6c2563b20810071346q1c7aa889r7fa8b24a40275068@mail.gmail.com> Message-ID: the only reference I could find was in the page for xref, and it doesn't say a whole lot, apart from saying the compiler inserts the function. On Oct 7, 9:46?pm, "Edwin Fine" wrote: > Kenneth, > > I find module_info's {time,CompileTimeAndDate} very useful. At a glance, I > can see whether a set of modules that were recently compiled made it to the > target platform properly after distribution and installation. Unlike > Erlang/OTP itself, the applications I am working with have frequent > releases, and sometimes things can go wrong with the distribution mechanism > (yes, I know, fix the mechanism, but I still like to have to ability to > check). When that happens, I like to be able to look at a beam on the target > system and see its compile date and time, and compare it with the known good > date and time. A checksum would work just as well for pure comparison > purposes but contains less information - a date/time is very human-friendly. > The date of the actual beam is, I feel, somewhat more useful (to me, anyway) > than the date of the source file, because when I release something I usually > rebuild everything from scratch and want to see the *build* date and time in > the beam files, not necessarily the *source* date and time. > > My vote, for what it's worth, is to keep {time,CompileTimeAndDate} and add > the compile option to suppress it if it really annoys people. > > By the way, if module_info is documented somewhere, could some kind person > please point me to it because I looked for it in the Erlang docs last night > and could not find it. Not saying it's not there, just I couldn't find it. > It wasn't in the permuted indexes, either. > > Regards, > Edwin Fine > > On Tue, Oct 7, 2008 at 1:30 PM, Kenneth Lundin wrote: > > > module_info ought to be documented somewhere, I actually thought it was. > > Our general principle is that what is documented is what we support > > and keep backwards compatible (as much as possible). > > When it comes to the information you can get out from module_info > > there are parts that really can be questioned and we > > have been thinking of changes although they can be made compatible. > > > If we look at M:module_info it returns a list of key value tuples like > > this: > > [ > > ?{exports,ListOfExportedFunctions}, > > ?{imports,ListOfImportedFunctions}, > > ?{attributes,ListOfAttributeValues}, > > ?{compile,ListOfCompileInfo} > > ] > > > where ListOfCompileInfo = [ {options,OptionList}, > > > {version,CompilerVersion},{time,CompileDateAndTime},{source,SourceFilePath}] > > > It is the ListOfCompileInfo that in my experience contains > > questionable information and that we have plans to change. > > For example {time,CompileTimeAndDate} which contains the time when the > > compilation was done, this value makes modules (.beam file) > > different even if they are compiled from exactly the same sources, > > with the same version of the compiler and with the same compiler > > options. This is not always a good thing for example if you want to > > compare beam files and find out which has changed from one > > version of an application to another. > > We have thought of 2 alternative solutions. 1) change the time info > > from compile time to last modification time of the source file > > 2) introduce a compiler option which can be used to omit the time info > > completely. > > > The options info has also been questioned since it has a tendency to > > create large volumes of data. For example if a big project passes a > > very long and the same list of include directories to every > > compilation (even if it is not necessary for that particular file). > > Sometimes the volume of the data here will then be significant > > compared to the actual code size and the will be kept in RAM by the > > Erlang VM. > > We have thought of 2 alternative solutions here too: 1) remove all > > include paths not used for this file (i.e only keep the ones where > > we actually included a file). 2) introduce an option with which the > > info can be suppressed. > > > So in summary. The CompileDateAndTime is a little unsafe to rely on > > because it might be changed. > > > I actually don't understand why you are interested in ?DATE and ?TIME > > macros or similar info and I don't see the problem with > > passing -DDATE or whatever on the command line to erlc. I am sure it > > is possible on WIndows as well (You can as one example > > do it with an escript). > > > Even the {source, SourceFilePath } is sometimes totally worthless info > > and can also make beam files different even though > > they ought to be identical. > > > /Kenneth Erlang/OTP team, Ericsson > > > On Tue, Oct 7, 2008 at 4:32 PM, harry wrote: > > > Cheers, > > > > I had a dig around in the source in compile, and found some other > > > possible tags. > > > > But, I wonder, if this is not documented, might it change in the > > > future? > > > > On Oct 7, 2:31 pm, Mats Cronqvist wrote: > > >> harry wrote: > > >> > Excellent, thanks! > > > >> > I'm struggling to find docs on module_info. > > >> > I'm guessing erlc inserts it into each module > > > >> yes. > > > >> > and it uses beam_lib? > > > >> ?afaik, no. it's just a regular exported function that would look > > >> something like this in Erlang. > > > >> module_info() -> . > > >> module_info(Tag) -> > > >> ?try proplists:get_value(Tag,module_info()) > > >> ?catch _:_ -> exit(badarg) > > >> ?end. > > > >> ?where is a constant term. > > >> ?this is just speculation on my part though. > > > >> ? mats > > >> _______________________________________________ > > >> erlang-questions mailing list > > >> erlang-questi...@REDACTED:// > >www.erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > > > erlang-questions mailing list > > > erlang-questi...@REDACTED > > >http://www.erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questi...@REDACTED > >http://www.erlang.org/mailman/listinfo/erlang-questions > > > > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions From bengt.kleberg@REDACTED Wed Oct 8 07:33:22 2008 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Wed, 08 Oct 2008 07:33:22 +0200 Subject: [erlang-questions] Get a range of tuples from a Mnesia table In-Reply-To: <48EBBB64.90404@gmail.com> References: <60ed8a460810040919qcf9dd37m994bbf6932f18cc0@mail.gmail.com> <6c2563b20810041111t401ebb0fh5482d383438f0b8b@mail.gmail.com> <48EB1DA3.8030304@gmail.com> <6c2563b20810070854u3eb94b79u5c8d90c7b7a4373c@mail.gmail.com> <48EBBB64.90404@gmail.com> Message-ID: <1223444002.3831.3.camel@seasc0642.dyn.rnd.as.sw.ericsson.se> If he then continues without a license, would that make him an underground poet? bengt On Tue, 2008-10-07 at 21:41 +0200, Mats Cronqvist wrote: > Edwin Fine wrote: > > RIght. He did say he was using an ordered_set, and I was imprecise in > > saying that it returned the record rather than a one-element list > > containing the record. Poetic license :) > > > A poetic license? That sounds most inconvenient. Have you considered > having it removed? > > mats > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From richardc@REDACTED Wed Oct 8 08:41:51 2008 From: richardc@REDACTED (Richard Carlsson) Date: Wed, 08 Oct 2008 08:41:51 +0200 Subject: [erlang-questions] ?DATE and ?TIME MACROs In-Reply-To: References: Message-ID: <48EC562F.7060408@it.uu.se> harry wrote: > How would you do ?DATE and ?TIME (apart from erlc -DDATE=`time` .... > or something similar, which is *nix specific) > > Would there be any mileage in adding these (and ?FUNCTION) to epp? DATE and TIME could easily be added to epp, as long as one can still override the definitions from the command line with -D to set a global time and date for the entire build. FUNCTION, however, does not really belong in the preprocessor, because it can never be expanded at preprocessing time to a literal (so that you can e.g. use it in a pattern); it must expand to a runtime call. In that case you might as well use that function call instead of the macro. /Richard From 0x6e6562@REDACTED Wed Oct 8 08:41:45 2008 From: 0x6e6562@REDACTED (Ben Hood) Date: Wed, 8 Oct 2008 07:41:45 +0100 Subject: [erlang-questions] Some mnesia oddity In-Reply-To: <48EC4E3A.6040601@erix.ericsson.se> References: <269388e30810050420w38e3cc77h23dea901c39d6cc1@mail.gmail.com> <48E9BF0F.7080303@erix.ericsson.se> <269388e30810061038u66e36bd9w7aeab7eaafa26449@mail.gmail.com> <48EB0214.5090701@erix.ericsson.se> <269388e30810070058m43b79b33sda220791309291ab@mail.gmail.com> <269388e30810070419n1229dc14sce7fd2e51d65391d@mail.gmail.com> <48EB646E.3080104@ericsson.com> <269388e30810071031g8f202b0xbd5b306b748071c0@mail.gmail.com> <48EC4E3A.6040601@erix.ericsson.se> Message-ID: <269388e30810072341q19bf551bh4b912b053f78611d@mail.gmail.com> Dan, On Wed, Oct 8, 2008 at 7:07 AM, Dan Gudmundsson wrote: > Hey, tought about this when I walked here to work. > > You do take a write table lock before your loop, right. > Because otherwise you loose a lot of roundtrip time, which > wasn't in the delete_object it only gets a lock on the {Tab,Key} > record. Are you suggesting that I get a lock on the whole table before I start iterating through it instead of just getting a record lock for each object on every iteration? If so, I'll give that a go and see what difference it makes. Thx, Ben From vychodil.hynek@REDACTED Wed Oct 8 09:41:31 2008 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Wed, 8 Oct 2008 09:41:31 +0200 Subject: [erlang-questions] re cursive fun() In-Reply-To: <3dbc6d1c0810071309w4ee9fbb9o5eaf9c17573aa6@mail.gmail.com> References: <19820386.post@talk.nabble.com> <48E8892E.5040204@it.uu.se> <8e04b5820810050711s5d4ef554v50131c481fa19e85@mail.gmail.com> <58B11B10-F2AA-4702-A625-A73F9F239A40@cs.otago.ac.nz> <20081007113238.7D4902407D@relay.gooddata.com> <0F3BFEC2F16D4D66A6AF13B05F481CF3@SSI.CORP> <20081007154709.5F69224089@relay.gooddata.com> <3dbc6d1c0810071309w4ee9fbb9o5eaf9c17573aa6@mail.gmail.com> Message-ID: <20081008074132.407B22407D@relay.gooddata.com> On Tue, Oct 7, 2008 at 10:09 PM, Robert Virding wrote: > It seems like there are two separate threads here: one is about defining > recursive functions in the shell; and the other is about defining local > (recursive) functions in a module. > You can use same tricks in module as in shell (if you are pervert a little ;-). > > > The first case has been reasonably covered in how you create a fun with a > reference to itself so it can call itself recursively. > > In the second case I must agree with Richard, there is no *need* to have > local (to a function) functions, you can just use normal top-level > functions. They *are * more efficient than funs. I have found, however, that > I sometimes use funs as local functions when I want to stress that these are > local functions. Especially after a bout of LFE hacking which has them. > I agree, there is always way how to do refactoring to local recursive functions and make up funs from those. (There should not be difference in performance, it is Erlang fault if is. But there is long way to this goal, for example hot spot compiler and such thinks.) I strongly agree with following, especially with EPP and Self thinks. > > > However, if it was really desired it would be possible to add them, of > course you would need both the recursive and non-recursive options. It would > be a bit of a contrived expression as it would not, *could not*, return > anything sensible. I would not like to add a scoping let type construction > as we don't have having scoping anywhere else. Well except in funs and > comprehensions where the scoping is a bit off actually. The visibility rules > for the defined functions would be a bit hairy, very hairy really, but the > best would be to make them the same as for variables, which are very hairy. > > I have no intention of adding an EEP! > > I don't like the idea of Self. > > A rather humourous note is local functions in Core erlang. In Core yo have > local functions, but only the mutually recursive type. These were originally > added to implement comprehensions so only the recursive kind were needed. > > A solution would be do what I used to threaten Bjarne with: do an E2 and > get it right. What ever right is. > > Robert > > -- --Hynek (Pichi) Vychodil -------------- next part -------------- An HTML attachment was scrubbed... URL: From 0x6e6562@REDACTED Wed Oct 8 11:55:52 2008 From: 0x6e6562@REDACTED (Ben Hood) Date: Wed, 8 Oct 2008 10:55:52 +0100 Subject: [erlang-questions] Some mnesia oddity In-Reply-To: <269388e30810072341q19bf551bh4b912b053f78611d@mail.gmail.com> References: <48E9BF0F.7080303@erix.ericsson.se> <269388e30810061038u66e36bd9w7aeab7eaafa26449@mail.gmail.com> <48EB0214.5090701@erix.ericsson.se> <269388e30810070058m43b79b33sda220791309291ab@mail.gmail.com> <269388e30810070419n1229dc14sce7fd2e51d65391d@mail.gmail.com> <48EB646E.3080104@ericsson.com> <269388e30810071031g8f202b0xbd5b306b748071c0@mail.gmail.com> <48EC4E3A.6040601@erix.ericsson.se> <269388e30810072341q19bf551bh4b912b053f78611d@mail.gmail.com> Message-ID: <269388e30810080255n77f78dc4jc1a0b43ba024129c@mail.gmail.com> Dan, On Wed, Oct 8, 2008 at 7:41 AM, Ben Hood <0x6e6562@REDACTED> wrote: >> You do take a write table lock before your loop, right. >> Because otherwise you loose a lot of roundtrip time, which >> wasn't in the delete_object it only gets a lock on the {Tab,Key} >> record. > > Are you suggesting that I get a lock on the whole table before I start > iterating through it instead of just getting a record lock for each > object on every iteration? > > If so, I'll give that a go and see what difference it makes. I've just tried locking the whole table and it effectively doubles the rate of deletion when looping through the table and deleting records based on their keys. Now I need to consider whether a full table lock is acceptable for my particular application, but at least I now know what effect the different ways of deleting records from mnesia have. Thanks for your help, Ben From saleyn@REDACTED Wed Oct 8 14:36:59 2008 From: saleyn@REDACTED (Serge Aleynikov) Date: Wed, 08 Oct 2008 08:36:59 -0400 Subject: [erlang-questions] jinterface In-Reply-To: <3dbc6d1c0810040757u795d521ex4223ad37a4ab3900@mail.gmail.com> References: <6C2A5378-5BDE-4FF9-B2AF-790D1F78330B@kallisys.net> <48E7730B.3090506@gmail.com> <3dbc6d1c0810040711w26eae030pbcbccf7e1f4d5fd0@mail.gmail.com> <48E78277.4000809@gmail.com> <3dbc6d1c0810040757u795d521ex4223ad37a4ab3900@mail.gmail.com> Message-ID: <48ECA96B.2030201@gmail.com> Last weekend I did implement support for monitoring Erlang pids in otp.net. It seems to work ok, though I see Vlad's point in that it's somewhat cumbersome to use Erlang-style message passing in a language that doesn't support native concurrency. I faced another "challenge" being that the IO requests in the form of io:format(Fmt, Args) get directed to a group leader in the otp.net node as an io_request carrying some {put_chars, io_lib, format, Args} content. The inconvenience is that otp.net node doesn't have any clue of how apply that io:format/2 function to format that output. Is there a way to force the evaluation to happen on the Erlang side so that it would come to the non-Erlang node as {put_chars, String} of some sort? Serge Robert Virding wrote: > That would be a better solution in the long-run, but it is one which, > unfortunately, I can't help you with. > > Robert > > 2008/10/4 Serge Aleynikov > >> Ah, I see, this makes sense. Meanwhile, I looked through the distribution >> sources, ei, and jinterface and see that it's not that difficult to add some >> monitoring support for non-Erlang nodes so that they can monitor Erlang >> pids. I'll patch otp.net and later ei if I find time this or next >> weekend. >> >> Serge >> >> >> Robert Virding wrote: >> >>> It's not the io server which tries to setup a monitor, but the io module >>> itself. These are two separate but cooperating entities. The io module >>> monitors the io server to make sure that the call will not block if the >>> process dies. The easiest way around this is to do the send/receive to the >>> io serv yourself without a monitor. >>> >>> Robert >>> >>> 2008/10/4 Serge Aleynikov >>> >>> One other "nasty" feature is that any attempt to make an RPC call of >>>> io:format/2 from a Java/.NET node fails with badarg, because io server >>>> tries to set up a monitor to the remote pid and fails miserably... >>>> >>>> Actually I see what's missing in Java/OTP.NET implementation. These >>>> features are documented here: >>>> http://www.erlang.org/doc/apps/erts/erl_dist_protocol.html#9.7 >>>> >>>> Serge >>>> >>>> >>>> >>>> Paul Guyot wrote: >>>> >>>>> Date: Sat, 04 Oct 2008 01:32:55 -0400 >>>>>> From: Serge Aleynikov >>>>>> Subject: Re: [erlang-questions] jinterface (was: otp.net) >>>>>> >>>>>> I tried a similar test using jinterface to see if it's possible to >>>>>> monitor processes running on a Java node and ran into the same failure. >>>>>> >>>>>> Can anyone explain what's wrong? >>>>>> >>>>>> (server@REDACTED)10> {test, client@REDACTED} ! {self(), hello}. >>>>>> {<0.45.0>,hello} >>>>>> (server@REDACTED)11> f(), {Pid, _} = receive M -> M end. >>>>>> {<5979.1.0>,hello} >>>>>> (server@REDACTED)12> erlang:monitor(process, Pid). >>>>>> ** exception error: bad argument >>>>>> in function erlang:monitor/2 >>>>>> called as erlang:monitor(process,<5979.1.0>) >>>>>> >>>>> I've seen a comment in stdlib/gen.erl, at line 196, that suggests that >>>>> Java and C nodes are featureweak, and processes in such nodes cannot be >>>>> monitored. Instead, you have to monitor the whole node with >>>>> monitor_node/2. This makes sense because the OTP ei (C library) or >>>>> jinterface do not monitor "processes". Indeed, there is only one pid per >>>>> node, which is the node's pseudo-pid (even if technically, each >>>>> connection can receive messages). I guess you can draw from the code in >>>>> gen.erl if you need to monitor either an erlang process or your java >>>>> process, or just monitor the node if you only need to monitor java >>>>> processes. >>>>> >>>>> Regards, >>>>> >>>>> Paul >>>>> >>>>> >>>>> _______________________________________________ >>>> erlang-questions mailing list >>>> erlang-questions@REDACTED >>>> http://www.erlang.org/mailman/listinfo/erlang-questions >>>> >>>> > From rasmussen.bryan@REDACTED Wed Oct 8 15:07:07 2008 From: rasmussen.bryan@REDACTED (bryan rasmussen) Date: Wed, 8 Oct 2008 15:07:07 +0200 Subject: [erlang-questions] Erlang with MonetDb In-Reply-To: <6a36e7290810070934k1a3fbf43k258c6220b6a56e75@mail.gmail.com> References: <3bb44c6e0810070454s5cd3a829p524ce628808a2323@mail.gmail.com> <6a36e7290810070934k1a3fbf43k258c6220b6a56e75@mail.gmail.com> Message-ID: <3bb44c6e0810080607m21ce8ef3o2d8fdfc054a9346d@mail.gmail.com> Damn. I was worried about that myself, I've already had some problems in the initial testing that make me not want to trust important data to it. Well, in case it turns out we don't want to use it does anyone have a good column store that they can recommend to use in conjunction with Erlang? Cheers, Bryan Rasmussen On Tue, Oct 7, 2008 at 6:34 PM, Bob Ippolito wrote: > I don't have an answer for you, but we tried using MonetDB early this > year and it was an epic failure, the database corrupted itself and at > times the server would grow until it ran out of RAM. We unfortunately > had to resort to a commercial column store because we couldn't get > MonetDB to run for more than a few hours without crashing :( > > On Tue, Oct 7, 2008 at 4:54 AM, bryan rasmussen > wrote: >> Hi, >> >> Anyone out there made some erlang examples working with MonetDB? using >> ODBC acceptable. >> >> >> Cheers, >> Bryan Rasmussen >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > From rvirding@REDACTED Wed Oct 8 15:57:14 2008 From: rvirding@REDACTED (Robert Virding) Date: Wed, 8 Oct 2008 15:57:14 +0200 Subject: [erlang-questions] jinterface In-Reply-To: <48ECA96B.2030201@gmail.com> References: <6C2A5378-5BDE-4FF9-B2AF-790D1F78330B@kallisys.net> <48E7730B.3090506@gmail.com> <3dbc6d1c0810040711w26eae030pbcbccf7e1f4d5fd0@mail.gmail.com> <48E78277.4000809@gmail.com> <3dbc6d1c0810040757u795d521ex4223ad37a4ab3900@mail.gmail.com> <48ECA96B.2030201@gmail.com> Message-ID: <3dbc6d1c0810080657u4891111cr2052dc90488290f8@mail.gmail.com> Yes, it is easy to get around this, but no it is not. The io module was designed to send the formatting computations to the io-server to be done there. The group leader is an io-server as well as being group leader (see my Erlang Rationale for a bit better explanation). As I see it you have the following options: - Do not use io:fwrite or other formatting io calls directly but instead do io:put_chars(io_lib:fwrite(Fmt, Args)) instead. This ensures that only an iolist is sent to the group leader. - Modify io.erl to do this for automatically for you and use this private version. This is not difficult and should cause no other problems. - Modify your program so that you start a local group leader/io-server which does the formatting and just send the output iolists to the otp.net process. Do you do any input from otp.net? If so you will have to do the last option and fix the otp.net process a bit. I hope this helps, Robert 2008/10/8 Serge Aleynikov > Last weekend I did implement support for monitoring Erlang pids in otp.net. > It seems to work ok, though I see Vlad's point in that it's somewhat > cumbersome to use Erlang-style message passing in a language that doesn't > support native concurrency. > > I faced another "challenge" being that the IO requests in the form of > io:format(Fmt, Args) get directed to a group leader in the otp.net node as > an io_request carrying some {put_chars, io_lib, format, Args} content. The > inconvenience is that otp.net node doesn't have any clue of how apply that > io:format/2 function to format that output. Is there a way to force the > evaluation to happen on the Erlang side so that it would come to the > non-Erlang node as {put_chars, String} of some sort? > > Serge > > Robert Virding wrote: > >> That would be a better solution in the long-run, but it is one which, >> unfortunately, I can't help you with. >> >> Robert >> >> 2008/10/4 Serge Aleynikov >> >> Ah, I see, this makes sense. Meanwhile, I looked through the >>> distribution >>> sources, ei, and jinterface and see that it's not that difficult to add >>> some >>> monitoring support for non-Erlang nodes so that they can monitor Erlang >>> pids. I'll patch otp.net and later ei if I find time this or next >>> weekend. >>> >>> Serge >>> >>> >>> Robert Virding wrote: >>> >>> It's not the io server which tries to setup a monitor, but the io module >>>> itself. These are two separate but cooperating entities. The io module >>>> monitors the io server to make sure that the call will not block if the >>>> process dies. The easiest way around this is to do the send/receive to >>>> the >>>> io serv yourself without a monitor. >>>> >>>> Robert >>>> >>>> 2008/10/4 Serge Aleynikov >>>> >>>> One other "nasty" feature is that any attempt to make an RPC call of >>>> >>>>> io:format/2 from a Java/.NET node fails with badarg, because io server >>>>> tries to set up a monitor to the remote pid and fails miserably... >>>>> >>>>> Actually I see what's missing in Java/OTP.NET implementation. These >>>>> features are documented here: >>>>> http://www.erlang.org/doc/apps/erts/erl_dist_protocol.html#9.7 >>>>> >>>>> Serge >>>>> >>>>> >>>>> >>>>> Paul Guyot wrote: >>>>> >>>>> Date: Sat, 04 Oct 2008 01:32:55 -0400 >>>>>> >>>>>>> From: Serge Aleynikov >>>>>>> Subject: Re: [erlang-questions] jinterface (was: otp.net) >>>>>>> >>>>>>> I tried a similar test using jinterface to see if it's possible to >>>>>>> monitor processes running on a Java node and ran into the same >>>>>>> failure. >>>>>>> >>>>>>> Can anyone explain what's wrong? >>>>>>> >>>>>>> (server@REDACTED)10> {test, client@REDACTED} ! {self(), hello}. >>>>>>> {<0.45.0>,hello} >>>>>>> (server@REDACTED)11> f(), {Pid, _} = receive M -> M end. >>>>>>> {<5979.1.0>,hello} >>>>>>> (server@REDACTED)12> erlang:monitor(process, Pid). >>>>>>> ** exception error: bad argument >>>>>>> in function erlang:monitor/2 >>>>>>> called as erlang:monitor(process,<5979.1.0>) >>>>>>> >>>>>>> I've seen a comment in stdlib/gen.erl, at line 196, that suggests >>>>>> that >>>>>> Java and C nodes are featureweak, and processes in such nodes cannot >>>>>> be >>>>>> monitored. Instead, you have to monitor the whole node with >>>>>> monitor_node/2. This makes sense because the OTP ei (C library) or >>>>>> jinterface do not monitor "processes". Indeed, there is only one pid >>>>>> per >>>>>> node, which is the node's pseudo-pid (even if technically, each >>>>>> connection can receive messages). I guess you can draw from the code >>>>>> in >>>>>> gen.erl if you need to monitor either an erlang process or your java >>>>>> process, or just monitor the node if you only need to monitor java >>>>>> processes. >>>>>> >>>>>> Regards, >>>>>> >>>>>> Paul >>>>>> >>>>>> >>>>>> _______________________________________________ >>>>>> >>>>> erlang-questions mailing list >>>>> erlang-questions@REDACTED >>>>> http://www.erlang.org/mailman/listinfo/erlang-questions >>>>> >>>>> >>>>> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From joelr1@REDACTED Wed Oct 8 18:01:25 2008 From: joelr1@REDACTED (Joel Reymont) Date: Wed, 8 Oct 2008 17:01:25 +0100 Subject: [erlang-questions] pid to integer and back Message-ID: Is there a safe and efficient way to convert pid to integer and back? I'm assigning each running poker game an integer id. I store this id into every outgoing packet so there's no database lookup. I use the id to lookup the game process for every incoming packet, though. This is proving to be extremely inefficient, even with dirty mnesia reads. I actually repeat the above for every player, so there's twice the overhead. Is there a way to avoid it? This would only apply to running games and connected players so this would be a temporary integer, valid while the process is alive. Thanks, Joel -- wagerlabs.com From pfisher@REDACTED Wed Oct 8 18:08:30 2008 From: pfisher@REDACTED (Paul Fisher) Date: Wed, 08 Oct 2008 11:08:30 -0500 Subject: [erlang-questions] pid to integer and back In-Reply-To: References: Message-ID: <48ECDAFE.5020205@alertlogic.net> Joel Reymont wrote: > Is there a safe and efficient way to convert pid to integer and back? Does it really need to be an integer? Can you do a fixed size binary (e.g. term_to_binary(pid()))? -- paul From joelr1@REDACTED Wed Oct 8 18:13:50 2008 From: joelr1@REDACTED (Joel Reymont) Date: Wed, 8 Oct 2008 17:13:50 +0100 Subject: [erlang-questions] pid to integer and back In-Reply-To: <48ECDAFE.5020205@alertlogic.net> References: <48ECDAFE.5020205@alertlogic.net> Message-ID: Paul, That's quite rich at 27 bytes. I would prefer 12 (4x3). Thanks, Joel On Oct 8, 2008, at 5:08 PM, Paul Fisher wrote: > Does it really need to be an integer? Can you do a fixed size > binary (e.g. term_to_binary(pid()))? -- wagerlabs.com From vychodil.hynek@REDACTED Wed Oct 8 18:14:05 2008 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Wed, 8 Oct 2008 18:14:05 +0200 Subject: [erlang-questions] pid to integer and back In-Reply-To: References: Message-ID: <20081008161406.5E94024022@relay.gooddata.com> And what about term_to_binary? On Wed, Oct 8, 2008 at 6:01 PM, Joel Reymont wrote: > Is there a safe and efficient way to convert pid to integer and back? > > I'm assigning each running poker game an integer id. I store this id > into every outgoing packet so there's no database lookup. > > I use the id to lookup the game process for every incoming packet, > though. This is proving to be extremely inefficient, even with dirty > mnesia reads. > > I actually repeat the above for every player, so there's twice the > overhead. Is there a way to avoid it? > > This would only apply to running games and connected players so this > would be a temporary integer, valid while the process is alive. > > Thanks, Joel > > -- > wagerlabs.com > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- --Hynek (Pichi) Vychodil -------------- next part -------------- An HTML attachment was scrubbed... URL: From joelr1@REDACTED Wed Oct 8 18:16:36 2008 From: joelr1@REDACTED (Joel Reymont) Date: Wed, 8 Oct 2008 17:16:36 +0100 Subject: [erlang-questions] pid to integer and back In-Reply-To: <20081008161406.6F7D12402F@relay.gooddata.com> References: <20081008161406.6F7D12402F@relay.gooddata.com> Message-ID: On Oct 8, 2008, at 5:14 PM, Hynek Vychodil wrote: > And what about term_to_binary? My current encoding uses 4 bytes. term_to_binary uses 27. I would prefer something closer to 4 bytes since term_to_binary would be effectively doubling or tripling the size of every packet. Thanks, Joel -- wagerlabs.com From joelr1@REDACTED Wed Oct 8 18:24:22 2008 From: joelr1@REDACTED (Joel Reymont) Date: Wed, 8 Oct 2008 17:24:22 +0100 Subject: [erlang-questions] pid to integer and back In-Reply-To: <20081008161406.6F7D12402F@relay.gooddata.com> References: <20081008161406.6F7D12402F@relay.gooddata.com> Message-ID: I know you can put pids back together with c:pid(X, Y, Z). How do you take a triple apart, though, without using pid_to_list and parsing the string? Thanks, Joel -- wagerlabs.com From mpharrison@REDACTED Wed Oct 8 18:26:57 2008 From: mpharrison@REDACTED (harry) Date: Wed, 8 Oct 2008 09:26:57 -0700 (PDT) Subject: [erlang-questions] ?DATE and ?TIME MACROs In-Reply-To: <48EC562F.7060408@it.uu.se> References: <48EC562F.7060408@it.uu.se> Message-ID: <04e6df18-568b-44be-8710-b47d4f16623d@t41g2000hsc.googlegroups.com> Thanks all for your replies. ?DATE & ?TIME would be convenient if they were added to epp as you suggest. Then it would match cpp's __DATE__ and __TIME__. Although one can always use erlc -DDATE etc, as suggested above. On Oct 8, 7:41?am, Richard Carlsson wrote: > harry wrote: > DATE and TIME could easily be added to epp, as long as one can still > override the definitions from the command line with -D to set a global > time and date for the entire build. > > FUNCTION, however, does not really belong in the preprocessor, ... I suppose because of inlining? - I saw something like that in my searches. From bob@REDACTED Wed Oct 8 18:45:52 2008 From: bob@REDACTED (Bob Ippolito) Date: Wed, 8 Oct 2008 12:45:52 -0400 Subject: [erlang-questions] pid to integer and back In-Reply-To: References: <48ECDAFE.5020205@alertlogic.net> Message-ID: <6a36e7290810080945o63924981h32e3ac9ffe8cfc2f@mail.gmail.com> It's probably a bad idea (though I guess not much worse than any other serialization of pids) but you could use pid_to_list and list_to_pid. If you want a more compact representation you could parse it. On Wed, Oct 8, 2008 at 12:13 PM, Joel Reymont wrote: > Paul, > > That's quite rich at 27 bytes. I would prefer 12 (4x3). > > Thanks, Joel > > On Oct 8, 2008, at 5:08 PM, Paul Fisher wrote: > >> Does it really need to be an integer? Can you do a fixed size >> binary (e.g. term_to_binary(pid()))? > > -- > wagerlabs.com > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From vychodil.hynek@REDACTED Wed Oct 8 18:54:28 2008 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Wed, 8 Oct 2008 18:54:28 +0200 Subject: [erlang-questions] pid to integer and back In-Reply-To: References: <20081008161406.6F7D12402F@relay.gooddata.com> Message-ID: <20081008165429.4237924012@relay.gooddata.com> Use term_to_binary and just remove starting 131, 130 and following node information, you take 9 bytes and use this. Or you can get only ID part which is only 4bytes. But you must experiment how assemble back and verify. On Wed, Oct 8, 2008 at 6:24 PM, Joel Reymont wrote: > I know you can put pids back together with c:pid(X, Y, Z). > > How do you take a triple apart, though, without using pid_to_list and > parsing the string? > > Thanks, Joel > > -- > wagerlabs.com > > > > > > -- --Hynek (Pichi) Vychodil -------------- next part -------------- An HTML attachment was scrubbed... URL: From hydo@REDACTED Wed Oct 8 17:01:00 2008 From: hydo@REDACTED (Clint Moore) Date: Wed, 08 Oct 2008 08:01:00 -0700 Subject: [erlang-questions] Parallel list proccessing once again Message-ID: <55E8C5F7-41B5-4BD5-8AF0-62BD4E1D5B3C@mac.com> Before I try to write it, I thought I would ask and see if there isn't already something that does this. What I want to do is connect up a bunch of nodes and throw arbitrary functions and data to them and get the responses back in an easily manageable way _without_ overloading the nodes. This module would take care of checking for smp support on the individual nodes to see if it can throw more than one block to it or not, take care of waiting for all of the responses, and resend any blocks that didn't come back. Yea, I know... it's not a small thing but it seems like it would be incredibly useful. The data set I'm working off of is ~28k twitter messages in the form of: [[ { service, "twitter" }, { user, "name" }, { update, "text"}, { updated, date }, ... ]] called Dx. Let's suppose I have a function that takes a list of words and checks for @some_word and, if it finds it, replacing it with @some_word which makes a clickable link to that user for some web-based twitter interface. We'll call this function Fx. Here's what I want to do: (node@REDACTED) 1> ResultSet = awesome_module:distributed_map( Fx, Dx ). ... (node@REDACTED) 2> I could have 100 or no other nodes connected, it wouldn't matter because the module would put as much load on a node as it could handle (A lagom number of processes, I believe?) based off of erlang:system_info(smp_support) or whatever else. Is there anything like this already or is my newbishness with Erlang making the problem sound much more than it actually is? From joelr1@REDACTED Wed Oct 8 20:10:33 2008 From: joelr1@REDACTED (Joel Reymont) Date: Wed, 8 Oct 2008 19:10:33 +0100 Subject: [erlang-questions] pid to integer and back In-Reply-To: <20081008165429.4EDD12402F@relay.gooddata.com> References: <20081008161406.6F7D12402F@relay.gooddata.com> <20081008165429.4EDD12402F@relay.gooddata.com> Message-ID: <09C01AA9-EA01-4CBE-AAC3-BF4054D4958A@gmail.com> On Oct 8, 2008, at 5:54 PM, Hynek Vychodil wrote: > Use term_to_binary and just remove starting 131, 130 and following > node > information, you take 9 bytes and use this. Or you can get only ID > part > which is only 4bytes. That would work. I have a question, though... Under what conditions can the serial portion of the PID change? That would be the Z in . Thanks, Joel -- wagerlabs.com From anders.nygren@REDACTED Wed Oct 8 20:21:39 2008 From: anders.nygren@REDACTED (Anders Nygren) Date: Wed, 8 Oct 2008 13:21:39 -0500 Subject: [erlang-questions] Parallel list proccessing once again In-Reply-To: <55E8C5F7-41B5-4BD5-8AF0-62BD4E1D5B3C@mac.com> References: <55E8C5F7-41B5-4BD5-8AF0-62BD4E1D5B3C@mac.com> Message-ID: On Wed, Oct 8, 2008 at 10:01 AM, Clint Moore wrote: > > Before I try to write it, I thought I would ask and see if there > isn't already something that does this. What I want to do is connect > up a bunch of nodes and throw arbitrary functions and data to them and > get the responses back in an easily manageable way _without_ > overloading the nodes. This module would take care of checking for > smp support on the individual nodes to see if it can throw more than > one block to it or not, take care of waiting for all of the responses, > and resend any blocks that didn't come back. > > Yea, I know... it's not a small thing but it seems like it would be > incredibly useful. The data set I'm working off of is ~28k twitter > messages in the form of: > > [[ { service, "twitter" }, { user, "name" }, { update, "text"}, > { updated, date }, ... ]] called Dx. > > Let's suppose I have a function that takes a list of words and checks > for @some_word and, if it finds it, replacing it with href="http://...">@some_word which makes a clickable link to that > user for some web-based twitter interface. We'll call this function Fx. > > Here's what I want to do: > > (node@REDACTED) 1> ResultSet = awesome_module:distributed_map( Fx, Dx ). > ... > (node@REDACTED) 2> > > I could have 100 or no other nodes connected, it wouldn't matter > because the module would put as much load on a node as it could handle > (A lagom number of processes, I believe?) based off of > erlang:system_info(smp_support) or whatever else. > > Is there anything like this already or is my newbishness with Erlang > making the problem sound much more than it actually is? > To start with take a look at the pool module in the stdlib. Another thing to consider is the cost of sending the data and the results between the nodes compared to the actual amount of work done. From Your description it sounds like the work done on each message is not very much. Sometimes it is better to have the data distributed and then just sending the functions for doing the work to where the data is. /Anders > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From torben.lehoff@REDACTED Wed Oct 8 21:04:50 2008 From: torben.lehoff@REDACTED (Torben Hoffmann) Date: Wed, 8 Oct 2008 21:04:50 +0200 Subject: [erlang-questions] pid to integer and back In-Reply-To: References: Message-ID: On Wed, Oct 8, 2008 at 6:01 PM, Joel Reymont wrote: > Is there a safe and efficient way to convert pid to integer and back? > > I'm assigning each running poker game an integer id. I store this id > into every outgoing packet so there's no database lookup. > > I use the id to lookup the game process for every incoming packet, > though. This is proving to be extremely inefficient, even with dirty > mnesia reads. > > I actually repeat the above for every player, so there's twice the > overhead. Is there a way to avoid it? > > This would only apply to running games and connected players so this > would be a temporary integer, valid while the process is alive. > > Thanks, Joel > > -- > wagerlabs.com > > Hi Joel. I haven't - shame on me - looked at your code for the poker server, so this may be a stupid question... Could you try to step one step back and explain a bit about the scenario and the requirements you have for the routing of messages. I presume that you have local clients that all connect to your server and the trick is to pass actions around to all players at a table, but how that matches up with Erlang entities is beyond me at this stage. Off the top of my head things like AMQP or IP multicast could be a neat way of solving your problem, but it depends on how your architecture is and exactly how your routing requirements are. I have practical experience with IP multicast and I am sure that the RabbitMQ guys could help out with guidance on using AMQP.... if those things match your needs. It might very well be that the pid conversion is a problem you do not need to solve! Cheers, Torben > _____________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From joelr1@REDACTED Wed Oct 8 21:15:37 2008 From: joelr1@REDACTED (Joel Reymont) Date: Wed, 8 Oct 2008 20:15:37 +0100 Subject: [erlang-questions] pid to integer and back In-Reply-To: References: Message-ID: <940411B6-1443-45EC-AF37-BB0ADFEAEBD6@gmail.com> On Oct 8, 2008, at 8:04 PM, Torben Hoffmann wrote: > Could you try to step one step back and explain a bit about the > scenario and the requirements you have for the routing of messages. Players connect to a gateway which tells them the server to connect to. Once connected, they can request the list of games running. This is a list of _all_ games running across the poker cluster. Once players have the game summary, they can request the details, e.g. what seats are occupied, etc. I know the id and thus the pid of each player since everything from the client side goes to a matching player process. The issue is that messages are routed to a game by the player process and so the game id in the packet needs to be converted to a pid. I'll go with term_to_binary for now and trade packet size for speed. -- wagerlabs.com From torben.lehoff@REDACTED Wed Oct 8 21:48:35 2008 From: torben.lehoff@REDACTED (Torben Hoffmann) Date: Wed, 8 Oct 2008 21:48:35 +0200 Subject: [erlang-questions] pid to integer and back In-Reply-To: <940411B6-1443-45EC-AF37-BB0ADFEAEBD6@gmail.com> References: <940411B6-1443-45EC-AF37-BB0ADFEAEBD6@gmail.com> Message-ID: On Wed, Oct 8, 2008 at 9:15 PM, Joel Reymont wrote: > > On Oct 8, 2008, at 8:04 PM, Torben Hoffmann wrote: > > Could you try to step one step back and explain a bit about the scenario >> and the requirements you have for the routing of messages. >> > > Players connect to a gateway which tells them the server to connect to. > > Once connected, they can request the list of games running. This is a list > of _all_ games running across the poker cluster. > > Once players have the game summary, they can request the details, e.g. what > seats are occupied, etc. > > I know the id and thus the pid of each player since everything from the > client side goes to a matching player process. The issue is that messages > are routed to a game by the player process and so the game id in the packet > needs to be converted to a pid. For this I am almost 100% sure that IP multicast routing would work - the question is if IP multicast is allowed across the internet; I cannot read this from the entry about it in Wikipedia. The basic set-up would be to associate a multicast address with each game and then all that joins the multicast group will receive the messages sent on that address. You could let the gateway manage the multicast address pool and when a player wants to get a list of all games running you return the list of active multicast groups. Then the player can query the games for details... hmmm, this could lead to a lot of noise so it might be necessary to create a "control" layer that deals with queries and such and only use the multicast addresses for the in-game related messages which do need to go to every player at the table. AMQP would support this as well, but I am not an expert on that protocol. It is based on TCP so there will be no problems with running it over the internet. Another question: once a player has joined a table in your implementation couldn't he store the pid for the game once and for all and then route all messages to the game using the stored pid? Cheers, Torben -------------- next part -------------- An HTML attachment was scrubbed... URL: From dbudworth@REDACTED Wed Oct 8 22:45:48 2008 From: dbudworth@REDACTED (David Budworth) Date: Wed, 8 Oct 2008 15:45:48 -0500 Subject: [erlang-questions] pid to integer and back In-Reply-To: References: <940411B6-1443-45EC-AF37-BB0ADFEAEBD6@gmail.com> Message-ID: <2e23d1d20810081345o3e1dcef1i35d41de410997152@mail.gmail.com> The whole point of the poker server is to enable web based poker contests / gambling / etc, right? if that's true, i think you can't afford to allow guessable game id's. what stops someone from just sending in packets to all the games? since you are using an int (or even erlang pids as binaries) you basically are using sequential numbers for game identifiers. for something where money is at stake, or even in a contest with prizes of some form. The temptation to hack or even just disrupt will be high. or is this a closed network system where clients are controlled? 2008/10/8 Torben Hoffmann > > > On Wed, Oct 8, 2008 at 9:15 PM, Joel Reymont wrote: > >> >> On Oct 8, 2008, at 8:04 PM, Torben Hoffmann wrote: >> >> Could you try to step one step back and explain a bit about the scenario >>> and the requirements you have for the routing of messages. >>> >> >> Players connect to a gateway which tells them the server to connect to. >> >> Once connected, they can request the list of games running. This is a list >> of _all_ games running across the poker cluster. >> >> Once players have the game summary, they can request the details, e.g. >> what seats are occupied, etc. >> >> I know the id and thus the pid of each player since everything from the >> client side goes to a matching player process. The issue is that messages >> are routed to a game by the player process and so the game id in the packet >> needs to be converted to a pid. > > > For this I am almost 100% sure that IP multicast routing would work - the > question is if IP multicast is allowed across the internet; I cannot read > this from the entry about it in Wikipedia. The basic set-up would be to > associate a multicast address with each game and then all that joins the > multicast group will receive the messages sent on that address. You could > let the gateway manage the multicast address pool and when a player wants to > get a list of all games running you return the list of active multicast > groups. Then the player can query the games for details... hmmm, this could > lead to a lot of noise so it might be necessary to create a "control" layer > that deals with queries and such and only use the multicast addresses for > the in-game related messages which do need to go to every player at the > table. > > AMQP would support this as well, but I am not an expert on that protocol. > It is based on TCP so there will be no problems with running it over the > internet. > > Another question: once a player has joined a table in your implementation > couldn't he store the pid for the game once and for all and then route all > messages to the game using the stored pid? > > Cheers, > Torben > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From joelr1@REDACTED Wed Oct 8 23:34:13 2008 From: joelr1@REDACTED (Joel Reymont) Date: Wed, 8 Oct 2008 22:34:13 +0100 Subject: [erlang-questions] pid to integer and back In-Reply-To: References: <940411B6-1443-45EC-AF37-BB0ADFEAEBD6@gmail.com> Message-ID: On Oct 8, 2008, at 8:48 PM, Torben Hoffmann wrote: > For this I am almost 100% sure that IP multicast routing would work > - the question is if IP multicast is allowed across the internet; I had a lot of trouble with multicast and my Cisco router, I don't think I want to be concerned with multicast, at least not now. > Another question: once a player has joined a table in your > implementation > couldn't he store the pid for the game once and for all and then > route all messages to the game using the stored pid? This is not a problem but it won't work when you need to join a game. I still need to either map integers to process ids or use term_to_binary. -- wagerlabs.com From joelr1@REDACTED Wed Oct 8 23:35:48 2008 From: joelr1@REDACTED (Joel Reymont) Date: Wed, 8 Oct 2008 22:35:48 +0100 Subject: [erlang-questions] pid to integer and back In-Reply-To: <2e23d1d20810081345o3e1dcef1i35d41de410997152@mail.gmail.com> References: <940411B6-1443-45EC-AF37-BB0ADFEAEBD6@gmail.com> <2e23d1d20810081345o3e1dcef1i35d41de410997152@mail.gmail.com> Message-ID: <5307195D-F66D-4883-B1A3-19F101439CE8@gmail.com> On Oct 8, 2008, at 9:45 PM, David Budworth wrote: > The whole point of the poker server is to enable web based poker > contests / > gambling / etc, right? Right. > if that's true, i think you can't afford to allow guessable game id's. > what stops someone from just sending in packets to all the games? You can't do that. You can only send certain packets when you are not playing the game and other packets when you are. A game won't accept packets from you unless you are playing, etc. > for something where money is at stake, or even in a contest with > prizes of some form. The temptation to hack or even just disrupt > will be high. I think I can deal with it. > or is this a closed network system where clients are controlled? This is not the case. You can write a client if you want to. -- wagerlabs.com From b88zhou@REDACTED Wed Oct 8 23:38:56 2008 From: b88zhou@REDACTED (Brian Zhou) Date: Wed, 8 Oct 2008 14:38:56 -0700 Subject: [erlang-questions] Problems cross-compiling OTP on ARM In-Reply-To: References: <48DCC42D.70302@diit.unict.it> <48E0F984.8040206@diit.unict.it> Message-ID: <859e91e70810081438w1fb2f98dw18b5e10bad3c1a2a@mail.gmail.com> Sorry I join this topic late. For anyone interested in cross compiling erlang, please see also http://trac.nslu2-linux.org/optware/browser/trunk/make/erlang.mk http://trac.nslu2-linux.org/optware/browser/trunk/sources/erlang I've been maintaining the cross compilation recipes for NAS devices for a while. Some of the patches can probably go upstream. -Brian Zhou bzhou at nslu2 dash linux dot org From b88zhou@REDACTED Wed Oct 8 23:56:34 2008 From: b88zhou@REDACTED (Brian Zhou) Date: Wed, 8 Oct 2008 14:56:34 -0700 Subject: [erlang-questions] write the ant simulation in Erlang? Message-ID: <859e91e70810081456w244b1c9dh74e108325ae4135c@mail.gmail.com> Recently I watched clojure concurrency video, very impressive talk. http://blip.tv/file/812787 In the talk, lot of time was spent on walking thru the ant simulation code. Like many of you here, I was not convinced by the STM approach. Especially seeing the "Santa Claus" solution in Haskell and Erlang side-by-side. But I'm having some difficulty thinking about how to use Erlang for this ant simulation problem. It was suggested to me in IRC to have a manager process for the world state, with interface like world:is_food(loc). But how to make sure certain calls are in a a transaction? e.g. world:is_food(loc) and world:take_food(loc)? Maybe move what needs to be in a transaction into world:single_function() ? Thanks in advance for any idea, -Brian From b88zhou@REDACTED Thu Oct 9 00:29:07 2008 From: b88zhou@REDACTED (Brian Zhou) Date: Wed, 8 Oct 2008 15:29:07 -0700 Subject: [erlang-questions] write the ant simulation in Erlang? In-Reply-To: <859e91e70810081456w244b1c9dh74e108325ae4135c@mail.gmail.com> References: <859e91e70810081456w244b1c9dh74e108325ae4135c@mail.gmail.com> Message-ID: <859e91e70810081529w4c2245d5rfe0f069772941e7d@mail.gmail.com> The informal condensed description of the problem starts at ~76:00 of the video. You can see the simulation in action at 131:00 - 132:00. -Brian On Wed, Oct 8, 2008 at 2:56 PM, Brian Zhou wrote: > Recently I watched clojure concurrency video, very impressive talk. > > http://blip.tv/file/812787 > > In the talk, lot of time was spent on walking thru the ant simulation code. > > Like many of you here, I was not convinced by the STM approach. > Especially seeing the "Santa Claus" solution in Haskell and Erlang > side-by-side. > > But I'm having some difficulty thinking about how to use Erlang for > this ant simulation problem. > > It was suggested to me in IRC to have a manager process for the world > state, with interface like world:is_food(loc). But how to make sure > certain calls are in a a transaction? e.g. world:is_food(loc) and > world:take_food(loc)? Maybe move what needs to be in a transaction > into world:single_function() ? > > Thanks in advance for any idea, > > -Brian > From matthew@REDACTED Thu Oct 9 00:41:19 2008 From: matthew@REDACTED (Matthew Dempsky) Date: Wed, 8 Oct 2008 15:41:19 -0700 Subject: [erlang-questions] pid to integer and back In-Reply-To: References: <940411B6-1443-45EC-AF37-BB0ADFEAEBD6@gmail.com> Message-ID: 2008/10/8 Torben Hoffmann : > For this I am almost 100% sure that IP multicast routing would work - the > question is if IP multicast is allowed across the internet; You would probably setup a VPN connecting all of your sites and then run multicast over that. From rvirding@REDACTED Thu Oct 9 01:01:57 2008 From: rvirding@REDACTED (Robert Virding) Date: Thu, 9 Oct 2008 01:01:57 +0200 Subject: [erlang-questions] extending the scanner and parser In-Reply-To: References: <95be1d3b0810030413p52bc5b58uf22c6790d64f9f35@mail.gmail.com> <20081003151527.GA28655@myrtle.kent.ac.uk> <95be1d3b0810031126t5fb7b8b9x48bb75c3895a330e@mail.gmail.com> <3dbc6d1c0810041115p571160fft458be1a867ff6cf2@mail.gmail.com> <95be1d3b0810041127o3d733f09l5182c0499ee57daa@mail.gmail.com> Message-ID: <3dbc6d1c0810081601t3832e4e1s47af36a31ef635ad@mail.gmail.com> 2008/10/6 Kenneth Lundin > On Sat, Oct 4, 2008 at 8:27 PM, Vlad Dumitrescu > wrote: > > On Sat, Oct 4, 2008 at 20:15, Robert Virding wrote: > >> Another solution which may help you is to use leex for generating the > >> scanner. > As I said we plan to integrate the required functionality in the > official scanner and we can not > have dependencies to components which are not part of the distribution > in the scanner. > We also already have the scanner so there is really no need to > implement a new one with Leex. Yes, but there is a BIG difference between modifying the output when using leex and going in and hacking the erlang scanner. With leex is is easy to see what you generate. However it is probably more difficult to make leex save more information and make it available to the user, or perhaps not. As far as I know there is only one thing which leex cannot handle today in the erlang syntax and that is that leex needs a newline at the end of the file, the erlang scanner does not. Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: From erlang-questions_efine@REDACTED Thu Oct 9 01:42:25 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Wed, 8 Oct 2008 19:42:25 -0400 Subject: [erlang-questions] [enhancement] string:split/2 Message-ID: <6c2563b20810081642r2fbd1f14w8e3f7a5a2b71bcc4@mail.gmail.com> Splitting a string into multiple parts based on a literal (as opposed to regular expression or set of characters) string delimiter is an extremely common operation in text processing. Its equal and opposite partner, join, is also very common. split and join are complementary functions (that's just what I call them here, so even if there's some more accurate or widely used terminology, please bear with me). At present, string:join exists and behaves like its cousins in other programming languages. There is an *almost*, but not quite complementary function in the string module: string:tokens/2. It *should* be possible to perform an idempotent transformation as follows: Input = "A,,B,C,", Sep = ",", Output = string:join(string:tokens(Input, Sep), Sep), Output =:= Input. The above would return *true* if string:join and string:tokens were truly complementary, but it does not. However, there is nothing *wrong* with string:tokens as it stands today (except maybe that it's a bit underdocumented, for example, by not mentioning that it treats consecutive sequences of delimiters as a single delimiter). It does what its name suggests: tokenizes a string based on a set of token characters. In a tokenization operation, you usually *want* to skip multiple identical token delimiters, and that's precisely what it does. I am not proposing a change to string:tokens; I *am* proposing *the addition of string:split/2*. split(String, Separator) -> List Types: String = string() Separator = string() List = [string()] Returns a list of strings that were separated in String by Separator. Separator can contain any number of characters, including zero. Leading separators will result in empty strings as the first elements of the returned list; the same is true for trailing separators and multiple consecutive separators. If Separator is the empty string, the returned list will be identical to the list returned by [[X] || X <- String]. If Separator cannot be found in String, the returned list will be [String]. In general, if there are N separators embedded in String, the returned list will contain N+1 strings. Examples: > string:split(":", ":This:is::a:contrived:example::"). ["","This","is","","a","contrived","example","",""] > string:split("", "Hello"). ["H","e","l","l","o"] *Existing Alternatives* There are no existing alternatives that I could find that have similar syntactic, semantic, and performance characteristics to split. Anything using regular expressions is more cumbersome and probably slower, and simulating this using Erlang code would also present performance penalties. I searched the list archives using the phrases "string split" and string:split, but found nothing that would cause me not to submit this proposal. EEP 9 does mention a binary_string:split, but I still feel that string:split would be a worthwhile addition to balance string:join. I believe this is too trivial an addition to warrant an EEP, so I am proposing it to the list for comment. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ok@REDACTED Thu Oct 9 03:33:42 2008 From: ok@REDACTED (Richard O'Keefe) Date: Thu, 9 Oct 2008 14:33:42 +1300 Subject: [erlang-questions] ?DATE and ?TIME MACROs In-Reply-To: <48EB2D4D.2060909@gmail.com> References: <48EB2D4D.2060909@gmail.com> Message-ID: <81D9E81B-D137-4377-AB2B-C082B9F3FA30@cs.otago.ac.nz> On 7 Oct 2008, at 10:35 pm, Mats Cronqvist wrote: > > -define(DATE,proplists:get_value(time,?MODULE:module_info(compile))). Just in case it's not obvious, it may be worth pointing out the ?DATE and ?TIME implemented this way, and the ?FUNCTION macro that has previously been posted, - do not give you ground terms, so the new-in-R12 optimisation of storing ground terms once won't happen - are not usable in patterns. The second of these may not matter to many people, but the first is at least potentially a space issue for people wanting to use such macros heavily in logging/debugging code. From ok@REDACTED Thu Oct 9 04:13:23 2008 From: ok@REDACTED (Richard O'Keefe) Date: Thu, 9 Oct 2008 15:13:23 +1300 Subject: [erlang-questions] re cursive fun() In-Reply-To: <20081007113238.85D1624083@relay.gooddata.com> References: <19820386.post@talk.nabble.com> <48E8892E.5040204@it.uu.se> <8e04b5820810050711s5d4ef554v50131c481fa19e85@mail.gmail.com> <58B11B10-F2AA-4702-A625-A73F9F239A40@cs.otago.ac.nz> <20081007113238.85D1624083@relay.gooddata.com> Message-ID: <940285B1-4CCE-4E67-AD87-F369B7082F5B@cs.otago.ac.nz> On 8 Oct 2008, at 12:32 am, Hynek Vychodil wrote: > Is there any problem write this think this way? > > F = begin > Outher = fun(OSelf, ...) -> > ... > Inner = fun(ISelf, ....) -> > ... ISelf(ISelf, X) ... > ... OSelf(OSelf, Y) ... > end, > ... OSelf(OSelf, ...) ... Inner(Inner, ...) ... > fun(Args) -> Outher(Outher, Args) end > end. Given that the topic under discussion was syntactic support to enable the *direct* representation of recursive functions, yes. I agree that we *can* get the effect right now without any extensions at all to the language. The result can most charitably be described as unclear and error-prone. Really, if you want a recursive function, there is no better way to write it than as a plain ordinary Erlang function. As for writing functions in the shell, it is so easy to have an editor in another window letting you write and edit any number of functions and then just using c(...) in the shell that there doesn't seem to be any real point in trying to write non-trivial functions in the shell. By the way, my understanding is that "begin" and "end" in Erlang are, as a pair, precisely equivalent to "(" and ")". > For Example factorial: > > Fact = begin F = fun(_, 0) -> 1; (Self, N) -> Self(Self, N-1)*N end, > fun(N) -> F(F, N) end end. A couple of days ago a 56-year-old member of this university was killed in a tramping accident. She and her teenage daughter were tramping in one of the national parks in the North Island, which has been having some heavy weather recently. Apparently the park people warned her of the the effect the weather had been having on the rivers, and told her of an alternative, safer, route. The route this experienced tramper chose involved a river crossing. The river was swollen with the rain, and swept her away. Her daughter immediately called for help on a mobile phone, but it was already too late. What has this to do with programming in Erlang? This: PEOPLE MAKE MISTAKES ALL THE TIME. When you've made a mistake, you need TIME to notice and recover. If you've typed something in an editor window, you have *time* to look at it, to check it, to think "maybe this could do a bit more checking". And if you get it wrong, you have it there to fix. But if you type something in the shell, you are under subtle pressure to do it quickly and briefly. Note, for example, the difference in how Hynek Vychodil's two examples were laid out. I'm sure that in an edit window he would write something _at least_ as good as factorial(N) when N > 0 -> N * factorial(N-1); factorial(0) -> 1. > Some nontrivial example: > > 4> UpToGen = begin > Outher = fun(_OSelf, M, M) -> []; > (OSelf, Step, M) -> > Inner = fun(_ISelf, N) when N>M > -> []; > (ISelf, N) -> [N > | ISelf(ISelf, N+Step) ] > end, > [Inner(Inner, 0) | OSelf(OSelf, Step > +1, M)] > end, > fun(Max) -> Outher(Outher, 1, Max) end > end. This must have been done with tabs set to something other than the standard 8. The problem is that I cannot tell what it is supposed to do without far more work than I have time for right now. What I *can* say is that it looks like a textbook example of something that should not have been written that way. > > #Fun > 5> UpToGen(10). > [[0,1,2,3,4,5,6,7,8,9,10], > [0,2,4,6,8,10], > [0,3,6,9], > [0,4,8], > [0,5,10], > [0,6], > [0,7], > [0,8], > [0,9]] To get this particular result, one does [lists:seq(0, 10, Step) || Step <- lists:seq(1, 9)] at to get the general version, U = fun (N) -> [lists:seq(0, N, Step) || Step <- lists:seq(1, N-1)] end will do fine. Even factorial can be done as F = fun (N) -> lists:foldl(fun (X, Y) -> X * Y end, 1, lists:seq(1, N)) end. Or rather, this *WOULD* work if it weren't for the lists:seq(1, 0) bug that I have complained about before. Similarly, U(1) *ought* to be the empty list, but thanks to the lists:seq(1, 0) but it crashes. People, it really is time to fix that bug. From ok@REDACTED Thu Oct 9 04:28:07 2008 From: ok@REDACTED (Richard O'Keefe) Date: Thu, 9 Oct 2008 15:28:07 +1300 Subject: [erlang-questions] ?DATE and ?TIME MACROs In-Reply-To: <48EC562F.7060408@it.uu.se> References: <48EC562F.7060408@it.uu.se> Message-ID: <7DF2C733-5DF0-451C-860F-382876E3C6F5@cs.otago.ac.nz> On 8 Oct 2008, at 7:41 pm, Richard Carlsson wrote: > FUNCTION, however, does not really belong in the preprocessor, because > it can never be expanded at preprocessing time to a literal (so that > you > can e.g. use it in a pattern); it must expand to a runtime call It can't be expanded at preprocessing time to a literal, true. But it CAN be expanded at preprocessing time to a {location,Line_Number,function} token which the *parser* can expand to a literal (so that you can for example use it in a pattern). (Actually, with a bit more work, the preprocessor *could* do that part as well, but this would mean repeating work already done by the parser, so I wouldn't do it that way.) From ok@REDACTED Thu Oct 9 05:51:52 2008 From: ok@REDACTED (Richard O'Keefe) Date: Thu, 9 Oct 2008 16:51:52 +1300 Subject: [erlang-questions] [enhancement] string:split/2 In-Reply-To: <6c2563b20810081642r2fbd1f14w8e3f7a5a2b71bcc4@mail.gmail.com> References: <6c2563b20810081642r2fbd1f14w8e3f7a5a2b71bcc4@mail.gmail.com> Message-ID: I agree that there should be an operation that is the converse of string:join/2. I'd like to see the spelling mistake (s/Seperators/Separators/) fixed in the comment for string:tokens/2. Can anyone explain to me why -spec(tokens/2 :: (string(), string()) -> [[char(),...]]). doesn't mention "string()" on the right hand side of the arrow? There are three minor quibbles about the proposed string:split/2. (1) We already have lists:split/2 and lists:splitwith/2. A module system exists so that names can safely be reused, but this is a little too close for comfort. While 'unjoin' is uglier than 'split', maybe it would mean less confusion? (2) What should string:split(Input, "") do? One plausible answer would be to split the input into a list of single-character strings. I know this is what Edwin Fine asked for, but is it the _right_ thing to do? Why is "abc" "" -> ["a","b","c"] the right answer rather than ["abc"], for example? Why is the separator deemed to occur only between characters and not at the beginning or end, yielding ["","a","b","c",""]? Perhaps the best answer for now is to require the separator to be a non-empty list. (3) unjoin:unjoin(";;;abc;;de;f;g;;", ";;"). [[],";abc","de;f;g",[]] Is that the right answer, or should it be [";","abc","de;f;g",[]]? > It should be possible to perform an idempotent transformation as > follows: An idempotent transformation F is one such that F(F(X)) = F(X) I see no idempotent transformation here. A useful operation, yes, but an idempotent one, no. > Examples: > > > string:split(":", ":This:is::a:contrived:example::"). > ["","This","is","","a","contrived","example","",""] > > string:split("", "Hello"). > ["H","e","l","l","o"] > Since the separator is the SECOND argument of string:join/2, I suggest that it should be the SECOND argument of string:unjoin/2 as well. The following code (1) has the name I suggested (unjoin/2) rather than the name Edwin Fine suggested (split/2); (2) has the argument order I suggested (consistent with join/2) rather than the argument order Edwin Fine suggested; (3) has the "split into single character strings" behaviour when presented with an empty separator that Edwin Fine suggested, rather than any of the alternatives I did; (4) has been tested. unjoin(String, []) -> unjoin0(String); unjoin(String, [Sep]) when is_integer(Sep) -> unjoin1(String, Sep); unjoin(String, [C1,C2|L]) when is_integer(C1), is_integer(C2) -> unjoin2(String, C1, C2, L). %% Split a string at "", which is deemed to occur _between_ %% adjacent characters, but queerly, not at the beginning %% or the end. unjoin0([C|Cs]) -> [[C] | unjoin0(Cs)]; unjoin0([]) -> []. %% Split a string at a single character separator. unjoin1(String, Sep) -> unjoin1_loop(String, Sep, ""). unjoin1_loop([Sep|String], Sep, Rev) -> [lists:reverse(Rev) | unjoin1(String, Sep)]; unjoin1_loop([Chr|String], Sep, Rev) -> unjoin1_loop(String, Sep, [Chr|Rev]); unjoin1_loop([], _, Rev) -> [lists:reverse(Rev)]. %% Split a string at a multi-character separator %% [C1,C2|L]. These components are split out for %% a fast match. unjoin2(String, C1, C2, L) -> unjoin2_loop(String, C1, C2, L, ""). unjoin2_loop([C1|S = [C2|String]], C1, C2, L, Rev) -> case unjoin_prefix(L, String) of no -> unjoin2_loop(S, C1, C2, L, [C1|Rev]) ; Rest -> [lists:reverse(Rev) | unjoin2(Rest, C1, C2, L)] end; unjoin2_loop([Chr|String], C1, C2, L, Rev) -> unjoin2_loop(String, C1, C2, L, [Chr|Rev]); unjoin2_loop([], _, _, _, Rev) -> [lists:reverse(Rev)]. unjoin_prefix([C|L], [C|S]) -> unjoin_prefix(L, S); unjoin_prefix([], S) -> S; unjoin_prefix(_, _) -> no. From saleyn@REDACTED Thu Oct 9 05:58:26 2008 From: saleyn@REDACTED (Serge Aleynikov) Date: Wed, 08 Oct 2008 23:58:26 -0400 Subject: [erlang-questions] jinterface In-Reply-To: <3dbc6d1c0810080657u4891111cr2052dc90488290f8@mail.gmail.com> References: <6C2A5378-5BDE-4FF9-B2AF-790D1F78330B@kallisys.net> <48E7730B.3090506@gmail.com> <3dbc6d1c0810040711w26eae030pbcbccf7e1f4d5fd0@mail.gmail.com> <48E78277.4000809@gmail.com> <3dbc6d1c0810040757u795d521ex4223ad37a4ab3900@mail.gmail.com> <48ECA96B.2030201@gmail.com> <3dbc6d1c0810080657u4891111cr2052dc90488290f8@mail.gmail.com> Message-ID: <48ED8162.4050405@gmail.com> Robert Virding wrote: > Yes, it is easy to get around this, but no it is not. The io module was > designed to send the formatting computations to the io-server to be done > there. The group leader is an io-server as well as being group leader (see > my Erlang Rationale for a bit better explanation). As I see it you have the > following options: > > - Do not use io:fwrite or other formatting io calls directly but instead do > io:put_chars(io_lib:fwrite(Fmt, Args)) instead. This ensures that only an > iolist is sent to the group leader. This would be quite limiting as I cannot control nested functions (that may have io calls) that are being called by functions executed via RPC. > - Modify io.erl to do this for automatically for you and use this private > version. This is not difficult and should cause no other problems. I think this is the most convenient option out of the three. What was the rationale of having the io server do the formatting as opposed to the node generating the io output request? Was it to decrease the possible load on the evaluating node? > - Modify your program so that you start a local group leader/io-server which > does the formatting and just send the output iolists to the otp.net process. The otp.net node already has a mailbox for getting messages destined to the io_server, and rpc requests carry the pid of that mailbox. Ideally I wouldn't need to have another "proxy" io_server on the Erlang side that would format and send requests to the connected otp.net hidden node. > Do you do any input from otp.net? What I did as far as the input was concerned - I wrote a parser of Erlang terms that took a string (such as "M:F(Arg1, Arg2, ...)" from the otp.net's stdin or a UI text box, converted it to an AST corresponding to a valid Erlang term in external term format, and did an RPC call to a connected Erlang node. Though, the purpose of this exercise was not to compete with werl, but rather offer RPC (and optional shell-like capabilities) to a rich UI client interface. Serge From ok@REDACTED Thu Oct 9 06:37:11 2008 From: ok@REDACTED (Richard O'Keefe) Date: Thu, 9 Oct 2008 17:37:11 +1300 Subject: [erlang-questions] [enhancement] string:split/2 In-Reply-To: References: <6c2563b20810081642r2fbd1f14w8e3f7a5a2b71bcc4@mail.gmail.com> Message-ID: <34A27838-5CBA-425D-97A1-C2D2CF6F5456@cs.otago.ac.nz> Colour me stupid. I just realised, 40+ minute late, what Fine meant about "idempotent" and why it matters. The requirement is that for all strings String and Separator for all Substring <- unjoin(String, Separator) unjoin(Substring, Separator) =:= [Substring] This _isn't_ idempotence, but it's some sort of cousin to it. And this is why unjoin("abc", "") doesn't include empty matches at the beginning and end, so that unjoin("a", "") =:= ["a"]. From b88zhou@REDACTED Thu Oct 9 06:46:29 2008 From: b88zhou@REDACTED (Brian Zhou) Date: Wed, 8 Oct 2008 21:46:29 -0700 Subject: [erlang-questions] write the ant simulation in Erlang? In-Reply-To: <859e91e70810082144v52c0998bi140a6116c67cf12a@mail.gmail.com> References: <859e91e70810081456w244b1c9dh74e108325ae4135c@mail.gmail.com> <7D2420AE-BA6D-4EE4-85DD-CCB6C1723DBE@cs.otago.ac.nz> <859e91e70810082144v52c0998bi140a6116c67cf12a@mail.gmail.com> Message-ID: <859e91e70810082146k3457bd2evc813a51beda59989@mail.gmail.com> Let me try to reverse engineer some kind of spec: * On a world of 80x80 cells, there are 49 ants, and 35 scattered cells with food. * Initially the ants are in their home, a square from (20, 20) to (26, 26), facing random directions. * An ant can move ahead, turn 45 degree left, or 45 degree right, every 40ms. * Ant should not move ahead if there is another ant in the ahead cell. * Whenever ant make a move, it leaves a pheromone trail by increment pheromone amount by 1.0 in the previous cell. * For an ant without food, ** If ahead is not home, and there is food ahead, move ahead, take food and turn around; ** Among cells that are ahead, ahead-left (45 degree), ahead-right (45 degree), turn/move to the one with the most (if (contain-food?) 1 0) + pheromone score, if all equal, turn/move randomly; * For an ant with food, ** If ahead is home, move ahead, drop food and turn around; ** Among cells that are ahead, ahead-left (45 degree), ahead-right (45 degree), turn/move to the one with the most (if (at-home?) 1 0) + pheromone score, if all equal, turn/move randomly; * Every 1 second, the pheromone in all cells evaporate to 99% of the previous amount; * If a graphical animation is provided, the animation is refreshed every 100ms. * Hard-coded numbers are used above to make description easier. They are actually adjustable. ;dimensions of square world (def dim 80) ;number of ants = nants-sqrt^2 (def nants-sqrt 7) ;number of places with food (def food-places 35) ;range of amount of food at a place (def food-range 100) ;evaporation rate (def evap-rate 0.99) (def animation-sleep-ms 100) (def ant-sleep-ms 40) (def evap-sleep-ms 1000) Anyone feel free to correct me if my understanding is not right. -Brian On Wed, Oct 8, 2008 at 7:46 PM, Richard O'Keefe wrote: > Bearing in mind that it really isn't practical > for someone in NZ to watch videos over the international net, > can you tell me what the ant simulation problem is? > > From romain.lenglet@REDACTED Thu Oct 9 07:18:50 2008 From: romain.lenglet@REDACTED (Romain Lenglet) Date: Thu, 09 Oct 2008 14:18:50 +0900 Subject: [erlang-questions] Article on Erlang in ACM Queue Message-ID: <48ED943A.80801@berabera.info> Jim Larson has written an article entitled "Erlang for Concurrent Programming", published in the latest ACM Queue: http://mags.acm.org/queue/200809/ This article is a very good, practical introduction to Erlang and OTP. -- Romain Lenglet From jim@REDACTED Thu Oct 9 08:00:20 2008 From: jim@REDACTED (Jim Larson) Date: Wed, 08 Oct 2008 23:00:20 -0700 Subject: [erlang-questions] Article on Erlang in ACM Queue In-Reply-To: Your message of "Thu, 09 Oct 2008 14:18:50 +0900." <48ED943A.80801@berabera.info> Message-ID: <200810090600.m9960KTF054979@krumkake.jetcafe.org> In message <48ED943A.80801@REDACTED> you write: >Jim Larson has written an article entitled "Erlang for Concurrent >Programming", published in the latest ACM Queue: >http://mags.acm.org/queue/200809/ Thanks to Romain for some great feedback on an early draft! Jim From erlang-questions_efine@REDACTED Thu Oct 9 08:43:36 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Thu, 9 Oct 2008 02:43:36 -0400 Subject: [erlang-questions] [enhancement] string:split/2 In-Reply-To: References: <6c2563b20810081642r2fbd1f14w8e3f7a5a2b71bcc4@mail.gmail.com> Message-ID: <6c2563b20810082343j255330ccp396cf4f8da0d2fe4@mail.gmail.com> On Wed, Oct 8, 2008 at 11:51 PM, Richard O'Keefe wrote: > I agree that there should be an operation that is > the converse of string:join/2. *That's* the word I wanted, thanks. > I'd like to see the spelling mistake (s/Seperators/Separators/) > fixed in the comment for string:tokens/2. > Can anyone explain to me why > > -spec(tokens/2 :: (string(), string()) -> [[char(),...]]). > > doesn't mention "string()" on the right hand side of the arrow? > > There are three minor quibbles about the proposed > string:split/2. > > (1) We already have lists:split/2 and lists:splitwith/2. > A module system exists so that names can safely be reused, > but this is a little too close for comfort. > Well, split is used in some very widespread languages like Perl, Ruby, and JavaScript. The version I proposed works much like Ruby's but doesn't have all the "kitchen sink" options that are available in Ruby. This being a multi-lingual software world, I decided to go with the Principle of Least Astonishment and do as the Romans do, as it were. I regret the much earlier naming of lists:split, which is a totally different beast, but I maintain that string:split is the right name. As long as people don't overuse import (which I never use, ever) it should be ok. If you *really* wanted to be perverse, you could call it nioj (only joking, I never understood the attraction of that Algol-68 esac/fi/od stuff). > > While 'unjoin' is uglier than 'split', maybe it would mean > less confusion? > Maybe. Yuk. > > (2) What should string:split(Input, "") do? > > One plausible answer would be to split the input into a > list of single-character strings. I know this is what > Edwin Fine asked for, but is it the _right_ thing to do? It's what Ruby and JavaScript do, and for all I know, others. That doesn't mean it's *right* but it does mean it's unsurprising for people who have to work across multiple languages that include these and similar ones. > Why is "abc" "" -> ["a","b","c"] the right answer rather > than ["abc"], for example? Why is the separator deemed > to occur only between characters and not at the beginning > or end, yielding ["","a","b","c",""]? > Good point. I suppose by convention, really; we are talking about an invisible zero-length string, after all, and there could be an infinite number of them in any string. I think. I am sure you can tell from my "idempotent" gaffe that I'm not a computer scientist by training; I are an enjineer. Perhaps the best answer for now is to require the separator > to be a non-empty list. > That would work... but could cause exceptions in places where it's not really an obvious error. I know you hate those. Me too. > (3) unjoin:unjoin(";;;abc;;de;f;g;;", ";;"). > [[],";abc","de;f;g",[]] > > Is that the right answer, or should it be > [";","abc","de;f;g",[]]? > Out of interest, what does Ruby do? irb(main):001:0> ";;;abc;;de;f;g;;".split ";;" => ["", ";abc", "de;f;g"] Neither of the above. Hmmm.. why? Ah. "If the *limit* parameter is omitted, trailing null fields are suppressed." (http://www.ruby-doc.org/core/classes/String.html#M000818) Well. Things *can* get really confusing. > It should be possible to perform an idempotent transformation as follows: >> > > An idempotent transformation F is one such that > > F(F(X)) = F(X) > > I see no idempotent transformation here. A useful operation, > yes, but an idempotent one, no. > I know, I know. I was trying to find the right word to signify a "round-trip" operation that leaves the operand unchanged, and was in too much of a hurry to make sure that idempotent meant that. Sorry. This is more of a sort of mutual identity operation, like f(g(x)) = x. > Examples: > > > string:split(":", ":This:is::a:contrived:example::"). > ["","This","is","","a","contrived","example","",""] > > string:split("", "Hello"). > ["H","e","l","l","o"] > > Since the separator is the SECOND argument of > string:join/2, I suggest that it should be the SECOND > argument of string:unjoin/2 as well. > That was very careless of me. I specially wrote the specification of string:split to be patterned after string:join, and then screwed up the example. Eheu, mea culpa (no, really, I could kick myself). > The following code > (1) has the name I suggested (unjoin/2) rather than the name > Edwin Fine suggested (split/2); > (2) has the argument order I suggested (consistent with join/2) > rather than the argument order Edwin Fine suggested; > (3) has the "split into single character strings" behaviour > when presented with an empty separator that Edwin Fine > suggested, rather than any of the alternatives I did; > (4) has been tested. > I'm assuming you are providing this code as an "executable requirements document." I was rather hoping that it could be implemented as a BIF. I'll have to study your code below so I can learn some "fast and fancy" Erlang! > unjoin(String, []) -> > unjoin0(String); > unjoin(String, [Sep]) when is_integer(Sep) -> > unjoin1(String, Sep); > unjoin(String, [C1,C2|L]) when is_integer(C1), is_integer(C2) -> > unjoin2(String, C1, C2, L). > > %% Split a string at "", which is deemed to occur _between_ > %% adjacent characters, but queerly, not at the beginning > %% or the end. > > unjoin0([C|Cs]) -> > [[C] | unjoin0(Cs)]; > unjoin0([]) -> > []. > > %% Split a string at a single character separator. > > unjoin1(String, Sep) -> > unjoin1_loop(String, Sep, ""). > > unjoin1_loop([Sep|String], Sep, Rev) -> > [lists:reverse(Rev) | unjoin1(String, Sep)]; > unjoin1_loop([Chr|String], Sep, Rev) -> > unjoin1_loop(String, Sep, [Chr|Rev]); > unjoin1_loop([], _, Rev) -> > [lists:reverse(Rev)]. > > %% Split a string at a multi-character separator > %% [C1,C2|L]. These components are split out for > %% a fast match. > > unjoin2(String, C1, C2, L) -> > unjoin2_loop(String, C1, C2, L, ""). > > unjoin2_loop([C1|S = [C2|String]], C1, C2, L, Rev) -> > case unjoin_prefix(L, String) > of no -> unjoin2_loop(S, C1, C2, L, [C1|Rev]) > ; Rest -> [lists:reverse(Rev) | unjoin2(Rest, C1, C2, L)] > end; > unjoin2_loop([Chr|String], C1, C2, L, Rev) -> > unjoin2_loop(String, C1, C2, L, [Chr|Rev]); > unjoin2_loop([], _, _, _, Rev) -> > [lists:reverse(Rev)]. > > unjoin_prefix([C|L], [C|S]) -> unjoin_prefix(L, S); > unjoin_prefix([], S) -> S; > unjoin_prefix(_, _) -> no. > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From raimo+erlang-questions@REDACTED Thu Oct 9 08:50:59 2008 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Thu, 9 Oct 2008 08:50:59 +0200 Subject: [erlang-questions] : pid to integer and back In-Reply-To: <09C01AA9-EA01-4CBE-AAC3-BF4054D4958A@gmail.com> References: <20081008161406.6F7D12402F@relay.gooddata.com> <20081008165429.4EDD12402F@relay.gooddata.com> <09C01AA9-EA01-4CBE-AAC3-BF4054D4958A@gmail.com> Message-ID: <20081009065059.GA27055@erix.ericsson.se> On Wed, Oct 08, 2008 at 07:10:33PM +0100, Joel Reymont wrote: > > On Oct 8, 2008, at 5:54 PM, Hynek Vychodil wrote: > > > Use term_to_binary and just remove starting 131, 130 and following > > node > > information, you take 9 bytes and use this. Or you can get only ID > > part > > which is only 4bytes. > > That would work. I have a question, though... Under what conditions > can the serial portion of the PID change? That would be the Z in > . For many enough processes. Due to backwards comp... you have heard it before, Y is the 15 least significant bits of the process index, and Z the more significant. And X is the external node index, so on the home node of a process, X is 0. > > Thanks, Joel > > -- > wagerlabs.com > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From erlang-questions_efine@REDACTED Thu Oct 9 08:54:21 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Thu, 9 Oct 2008 02:54:21 -0400 Subject: [erlang-questions] [enhancement] string:split/2 In-Reply-To: <34A27838-5CBA-425D-97A1-C2D2CF6F5456@cs.otago.ac.nz> References: <6c2563b20810081642r2fbd1f14w8e3f7a5a2b71bcc4@mail.gmail.com> <34A27838-5CBA-425D-97A1-C2D2CF6F5456@cs.otago.ac.nz> Message-ID: <6c2563b20810082354u34372510n1fb4e1d23d777c23@mail.gmail.com> On Thu, Oct 9, 2008 at 12:37 AM, Richard O'Keefe wrote: > Colour me stupid. > I just realised, 40+ minute late, > what Fine meant about "idempotent" and why it matters. That'll learn me not to use big words I don't understand. > The requirement is that > for all strings String and Separator > for all Substring <- unjoin(String, Separator) > unjoin(Substring, Separator) =:= [Substring] > > This _isn't_ idempotence, but it's some sort of cousin > to it. And this is why unjoin("abc", "") doesn't > include empty matches at the beginning and end, so that > unjoin("a", "") =:= ["a"]. > Yeah, that's what I meant right there. Is there a big word for that? Impotent? Um, no, I don't think so. Let's see, "idem" is Latin for "the same".. I believe Greek for "the same" is "homo" (homogeneous?)... how about "homopotent"? Doesn't sound right ... -------------- next part -------------- An HTML attachment was scrubbed... URL: From bengt.kleberg@REDACTED Thu Oct 9 09:03:27 2008 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Thu, 09 Oct 2008 09:03:27 +0200 Subject: [erlang-questions] Adding simple process to supervisor? Message-ID: <1223535807.3831.36.camel@seasc0642.dyn.rnd.as.sw.ericsson.se> Greetings, I have a gen_server which is supervised according to OTP rules. Now I want to add a simple process that will read from a TCP port and send the incoming data to the gen_server. I could spawn_link this process from the gen_server and restart it if it dies. However, since I have a supervisor it seems more logical to just add the process there, as a rest_for_one. There is the alternative of using a supervisor_bridge, but that seems more complex than using the gen_server. It seems as if I just design my process according to the OTP rules I will not need to use a supervisor_bridge. What are those rules? The only suggestions I have found are: 1 Module:start_link/1 => {ok, Pid} 2 Module:terminate/2 => ok The child specification returned by the init/1 call-back in a supervisor mentions the value for Modules if we have a gen_server, gen_fsm or gen_event. What could be used for a simple process? But how do I add a simple process to the supervisor? It seems overkill to masquerade it as a get_fsm or similar. Since it is not called from erlang it is not a gen_server. Since it does not have state it is not a gen_fsm. No events are handled. bengt From bgustavsson@REDACTED Thu Oct 9 09:59:12 2008 From: bgustavsson@REDACTED (Bjorn Gustavsson) Date: Thu, 9 Oct 2008 09:59:12 +0200 Subject: [erlang-questions] Extracting capture group names from regular expressions In-Reply-To: References: Message-ID: <6672d0160810090059v56e82766h8af0f8ae46831c42@mail.gmail.com> 2008/10/7 Tony Arcieri > I'm trying to write an API which accepts a regexp with arbitrary named > capture groups as input. > > I'm using the re module, and have had success using named subgroups if the > names are known ahead of time. However, I'd like to return a mapping of > arbitrary named capture groups from the original regular expression to the > matched values. > > Consider the following regular expression with named subpatterns: > > "(?\\w+) (?\\w+)" > > If this were applied to the string "baz qux" I'd like to return the > following: > > [{"foo", "baz"}, {"bar", "qux"}] > > However, it looks as if I must provide the names of the capture groups I > want returned in the capture tuple I pass to re:run. > > Is there any way to extract the names of the subgroups from a compiled > regular expression? Or is there some option I can pass to re:run that I'm > missing which will return a mapping of subgroup names to what they matched? > > There is currently no such option or functionality. It could be added in a future release if it's a general need. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB -------------- next part -------------- An HTML attachment was scrubbed... URL: From joelr1@REDACTED Thu Oct 9 10:56:31 2008 From: joelr1@REDACTED (Joel Reymont) Date: Thu, 9 Oct 2008 09:56:31 +0100 Subject: [erlang-questions] pid to integer and back In-Reply-To: References: <940411B6-1443-45EC-AF37-BB0ADFEAEBD6@gmail.com> <489F4BB7-4F92-456A-822A-555E05289C5C@gmail.com> Message-ID: On Oct 9, 2008, at 9:37 AM, Torben Hoffmann wrote: > did you ever get around to documenting Open Poker in > greater detail? Or are you busy making mone?!?! ;-) I'm busy coding so that I can finally make _real_ money and no, I don't want to impose AMPQ on the OpenPoker client implementors. Thanks for the suggestions, though. -- wagerlabs.com From twoggle@REDACTED Thu Oct 9 11:04:44 2008 From: twoggle@REDACTED (Tim Fletcher) Date: Thu, 9 Oct 2008 02:04:44 -0700 (PDT) Subject: [erlang-questions] [enhancement] string:split/2 In-Reply-To: <6c2563b20810082354u34372510n1fb4e1d23d777c23@mail.gmail.com> References: <6c2563b20810081642r2fbd1f14w8e3f7a5a2b71bcc4@mail.gmail.com> <34A27838-5CBA-425D-97A1-C2D2CF6F5456@cs.otago.ac.nz> <6c2563b20810082354u34372510n1fb4e1d23d777c23@mail.gmail.com> Message-ID: <781bce43-97e9-48fb-bba2-0ce230f2011a@t39g2000prh.googlegroups.com> > Yeah, that's what I meant right there. Is there a big word for that? > Impotent? Um, no, I don't think so. Let's see, "idem" is Latin for "the > same".. I believe Greek for "the same" is "homo" (homogeneous?)... how about > "homopotent"? Doesn't sound right ... Do you mean that string:split should be the _inverse_ of string:join? http://en.wikipedia.org/wiki/Inverse_function From rvirding@REDACTED Thu Oct 9 11:54:13 2008 From: rvirding@REDACTED (Robert Virding) Date: Thu, 9 Oct 2008 11:54:13 +0200 Subject: [erlang-questions] [enhancement] string:split/2 In-Reply-To: References: <6c2563b20810081642r2fbd1f14w8e3f7a5a2b71bcc4@mail.gmail.com> Message-ID: <3dbc6d1c0810090254q6a75d971o5752178126d21e34@mail.gmail.com> 2008/10/9 Richard O'Keefe > > (3) unjoin:unjoin(";;;abc;;de;f;g;;", ";;"). > [[],";abc","de;f;g",[]] > > Is that the right answer, or should it be > [";","abc","de;f;g",[]]? Either, depending on how you define your string. It could either start/end with a separator, or start/end with data. The important thing is to define it and should be the same at either end. For example regular expression libraries often have start/end with data. Your first example is start/end with data, while your second is start/end with separator. I would personally prefer the name split even though unjoin might more correct. Looking at the documentation for string:join it is start/end data so I definitely feel that split/unjoin should do the same so that they are inverses. Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: From erlangy@REDACTED Thu Oct 9 12:59:51 2008 From: erlangy@REDACTED (ERLANG) Date: Thu, 9 Oct 2008 12:59:51 +0200 Subject: [erlang-questions] External file sorting Message-ID: Hi List, Is there some free Erlang code for external (i.e on disk) file sorting? cheers Y. From joelr1@REDACTED Thu Oct 9 13:08:01 2008 From: joelr1@REDACTED (Joel Reymont) Date: Thu, 9 Oct 2008 12:08:01 +0100 Subject: [erlang-questions] Benchmarking Erlang: Deathmatch of gb_trees, dict, ets, mnesia ... and registered names Message-ID: <35FA1D83-B63F-4691-AA81-7129BC3BC5F9@gmail.com> I'm still trying to figure out how to optimize pid <-> integer mapping and I thought I'd try several approaches. My goal is to lookup a process id as quickly as possible given an integer. My system is a Mac Pro 2x2.8Ghz Quad Xeon, 14Gb of memory Erlang (BEAM) emulator version 5.6.3 [source] [smp:8] [async-threads: 0] [kernel-poll:false] Here's my set of timings, code at the end of this message. %% gb_trees 1> map1:test(10000). Populate: 0.0972 Lookup: 0.0912 ok 2> map1:test(100000). Populate: 0.8737 Lookup: 5.0007 ok 3> map1:test(1000000). Populate: 9.9215 Lookup: 5.0010 ok %% dict 1> map2:test(10000). Populate: 0.1035 Lookup: 0.0730 ok 2> map2:test(100000). Populate: 1.0407 Lookup: 1.2715 ok 3> map2:test(1000000). Populate: 10.5010 Lookup: 5.0010 ok %% ets 4> map3:test(10000). Populate: 0.1140 Lookup: 0.0448 ok 5> map3:test(100000). Populate: 1.3435 Lookup: 0.4669 ok 6> map3:test(1000000). Populate: 11.6472 Lookup: 5.0860 ok Dict seems to be the winner for 100K values. What's particularly interesting to me is that gb_trees, dict and ets give take about the same time to look up 1 mil. values. Is there an explanation? map4, map5 and map6 that test mnesia ram_copies, disc_only_copies and ram_copies in a 2-node setup. There seems to be no overhead compared to ets, though. Can't explain this either. The absolutely bizarre and surprising discovery are the timings for registered names. On a hunch, I thought I'd try to register a process under its id. This way I could just send messages to that id from any node in the cluster, without having to go through a separate translation process. %% registered names (2@REDACTED)2> map7:test(10000). Populate: 0.8526 Lookup: 0.0040 ok (2@REDACTED)1> map7:test(100000). Populate: 8.8507 Lookup: 0.0605 ok (2@REDACTED)3> map7:test(1000000). Populate: 94.6030 Lookup: 0.8558 It seems that registering processes under their integer id is the way to go. Am I right in my conclusion? Are there any pitfalls with going this route? Between players and games, I would most likely have <100K ids registered at any given time. Code in follow-up messages, registered names first, then gb_trees, dict, ets and mnesia. Thanks, Joel -- wagerlabs.com From joelr1@REDACTED Thu Oct 9 13:08:54 2008 From: joelr1@REDACTED (Joel Reymont) Date: Thu, 9 Oct 2008 12:08:54 +0100 Subject: [erlang-questions] Benchmarking Erlang: Deathmatch of gb_trees, dict, ets, mnesia ... and registered names In-Reply-To: <35FA1D83-B63F-4691-AA81-7129BC3BC5F9@gmail.com> References: <35FA1D83-B63F-4691-AA81-7129BC3BC5F9@gmail.com> Message-ID: %%% gb_trees -module(map1). -behaviour(gen_server). -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]). -export([start/0, test/1, populate/2, lookup/2]). -record(data, { xref }). start() -> gen_server:start(map1, [], []). init([]) -> {ok, #data{ xref = gb_trees:empty() }}. terminate(_, _) -> ok. handle_cast({'ADD', Key, Val}, Data) -> Xref = Data#data.xref, {noreply, Data#data{ xref = gb_trees:enter(Key, Val, Xref) }}; handle_cast(stop, Data) -> {stop, normal, Data}. handle_call({'LOOKUP', Key}, _From, Data) -> {reply, gb_trees:get(Key, Data#data.xref), Data}. handle_info(Info, Data) -> error_logger:info_report([{module, ?MODULE}, {line, ?LINE}, {self, self()}, {message, Info}]), {noreply, Data}. code_change(_, Data, _) -> {ok, Data}. test(N) -> {ok, Pid} = start(), {T1, _} = timer:tc(map1, populate, [Pid, N]), {T2, _} = timer:tc(map1, lookup, [Pid, N]), io:format("Populate: ~.4. f~n", [T1 / 1000000]), io:format("Lookup: ~.4. f~n", [T2 / 1000000]), gen_server:cast(Pid, stop). populate(_, 0) -> ok; populate(Pid, N) -> gen_server:cast(Pid, {'ADD', N, N}), populate(Pid, N - 1). lookup(_, 0) -> ok; lookup(Pid, N) -> gen_server:call(Pid, {'LOOKUP', N}), lookup(Pid, N - 1). From joelr1@REDACTED Thu Oct 9 13:09:26 2008 From: joelr1@REDACTED (Joel Reymont) Date: Thu, 9 Oct 2008 12:09:26 +0100 Subject: [erlang-questions] Benchmarking Erlang: Deathmatch of gb_trees, dict, ets, mnesia ... and registered names In-Reply-To: <35FA1D83-B63F-4691-AA81-7129BC3BC5F9@gmail.com> References: <35FA1D83-B63F-4691-AA81-7129BC3BC5F9@gmail.com> Message-ID: %%% dict -module(map2). -behaviour(gen_server). -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]). -export([start/0, test/1, populate/2, lookup/2]). -record(data, { xref }). start() -> gen_server:start(map2, [], []). init([]) -> {ok, #data{ xref = dict:new() }}. terminate(_, _) -> ok. handle_cast({'ADD', Key, Val}, Data) -> Xref = Data#data.xref, {noreply, Data#data{ xref = dict:store(Key, Val, Xref) }}; handle_cast(stop, Data) -> {stop, normal, Data}. handle_call({'LOOKUP', Key}, _From, Data) -> {reply, dict:fetch(Key, Data#data.xref), Data}. handle_info(Info, Data) -> error_logger:info_report([{module, ?MODULE}, {line, ?LINE}, {self, self()}, {message, Info}]), {noreply, Data}. code_change(_, Data, _) -> {ok, Data}. test(N) -> {ok, Pid} = start(), {T1, _} = timer:tc(map2, populate, [Pid, N]), {T2, _} = timer:tc(map2, lookup, [Pid, N]), io:format("Populate: ~.4. f~n", [T1 / 1000000]), io:format("Lookup: ~.4. f~n", [T2 / 1000000]), gen_server:cast(Pid, stop). populate(_, 0) -> ok; populate(Pid, N) -> gen_server:cast(Pid, {'ADD', N, N}), populate(Pid, N - 1). lookup(_, 0) -> ok; lookup(Pid, N) -> gen_server:call(Pid, {'LOOKUP', N}), lookup(Pid, N - 1). From joelr1@REDACTED Thu Oct 9 13:10:05 2008 From: joelr1@REDACTED (Joel Reymont) Date: Thu, 9 Oct 2008 12:10:05 +0100 Subject: [erlang-questions] Benchmarking Erlang: Deathmatch of gb_trees, dict, ets, mnesia ... and registered names In-Reply-To: <35FA1D83-B63F-4691-AA81-7129BC3BC5F9@gmail.com> References: <35FA1D83-B63F-4691-AA81-7129BC3BC5F9@gmail.com> Message-ID: <5E3032AF-1710-4173-BBA6-6435D5A2DB1A@gmail.com> %%% ets -module(map3). -behaviour(gen_server). -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]). -export([start/0, test/1, populate/2, lookup/2]). -record(data, { xref }). start() -> gen_server:start(map3, [], []). init([]) -> {ok, #data{ xref = ets:new(xref, []) }}. terminate(_, _) -> ok. handle_cast({'ADD', Key, Val}, Data) -> ets:insert(Data#data.xref, [{Key, Val}]), {noreply, Data}; handle_cast(stop, Data) -> {stop, normal, Data}. handle_call({'LOOKUP', Key}, _From, Data) -> [Value] = ets:lookup(Data#data.xref, Key), {reply, Value, Data}. handle_info(Info, Data) -> error_logger:info_report([{module, ?MODULE}, {line, ?LINE}, {self, self()}, {message, Info}]), {noreply, Data}. code_change(_, Data, _) -> {ok, Data}. test(N) -> {ok, Pid} = start(), {T1, _} = timer:tc(map3, populate, [Pid, N]), {T2, _} = timer:tc(map3, lookup, [Pid, N]), io:format("Populate: ~.4. f~n", [T1 / 1000000]), io:format("Lookup: ~.4. f~n", [T2 / 1000000]), gen_server:cast(Pid, stop). populate(_, 0) -> ok; populate(Pid, N) -> gen_server:cast(Pid, {'ADD', N, N}), populate(Pid, N - 1). lookup(_, 0) -> ok; lookup(Pid, N) -> gen_server:call(Pid, {'LOOKUP', N}), lookup(Pid, N - 1). From joelr1@REDACTED Thu Oct 9 13:10:52 2008 From: joelr1@REDACTED (Joel Reymont) Date: Thu, 9 Oct 2008 12:10:52 +0100 Subject: [erlang-questions] Benchmarking Erlang: Deathmatch of gb_trees, dict, ets, mnesia ... and registered names In-Reply-To: <35FA1D83-B63F-4691-AA81-7129BC3BC5F9@gmail.com> References: <35FA1D83-B63F-4691-AA81-7129BC3BC5F9@gmail.com> Message-ID: %%% mnesia ram_copies -module(map4). -behaviour(gen_server). -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]). -export([start/0, test/1, populate/2, lookup/2]). -record(xref, { key, val }). start() -> gen_server:start(map4, [], []). init([]) -> {ok, none}. terminate(_, _) -> ok. handle_cast({'ADD', Key, Val}, Data) -> F = fun() -> mnesia:write(#xref{ key = Key, val = Val}) end, mnesia:transaction(F), {noreply, Data}; handle_cast(stop, Data) -> {stop, normal, Data}. handle_call({'LOOKUP', Key}, _From, Data) -> F = fun() -> mnesia:read({xref, Key}) end, {atomic, [Value]} = mnesia:transaction(F), {reply, Value, Data}. handle_info(Info, Data) -> error_logger:info_report([{module, ?MODULE}, {line, ?LINE}, {self, self()}, {message, Info}]), {noreply, Data}. code_change(_, Data, _) -> {ok, Data}. test(N) -> mnesia:stop(), mnesia:delete_schema([node()]), mnesia:create_schema([node()]), mnesia:start(), {atomic, ok} = mnesia:create_table(xref, [ {ram_copies, [node()]}, {type, set}, {attributes, record_info(fields, xref)} ]), {ok, Pid} = start(), {T1, _} = timer:tc(map4, populate, [Pid, N]), {T2, _} = timer:tc(map4, lookup, [Pid, N]), io:format("Populate: ~.4. f~n", [T1 / 1000000]), io:format("Lookup: ~.4. f~n", [T2 / 1000000]), gen_server:cast(Pid, stop). populate(_, 0) -> ok; populate(Pid, N) -> gen_server:cast(Pid, {'ADD', N, N}), populate(Pid, N - 1). lookup(_, 0) -> ok; lookup(Pid, N) -> gen_server:call(Pid, {'LOOKUP', N}), lookup(Pid, N - 1). From joelr1@REDACTED Thu Oct 9 13:12:22 2008 From: joelr1@REDACTED (Joel Reymont) Date: Thu, 9 Oct 2008 12:12:22 +0100 Subject: [erlang-questions] Benchmarking Erlang: Deathmatch of gb_trees, dict, ets, mnesia ... and registered names In-Reply-To: <35FA1D83-B63F-4691-AA81-7129BC3BC5F9@gmail.com> References: <35FA1D83-B63F-4691-AA81-7129BC3BC5F9@gmail.com> Message-ID: <310AE5D4-2D20-4763-87B2-92BD228B30D0@gmail.com> %%% mnesia disc_only_copies -module(map5). -behaviour(gen_server). -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]). -export([start/0, test/1, populate/2, lookup/2]). -record(xref, { key, val }). start() -> gen_server:start(map5, [], []). init([]) -> {ok, none}. terminate(_, _) -> ok. handle_cast({'ADD', Key, Val}, Data) -> F = fun() -> mnesia:write(#xref{ key = Key, val = Val}) end, mnesia:transaction(F), {noreply, Data}; handle_cast(stop, Data) -> {stop, normal, Data}. handle_call({'LOOKUP', Key}, _From, Data) -> F = fun() -> mnesia:read({xref, Key}) end, {atomic, [Value]} = mnesia:transaction(F), {reply, Value, Data}. handle_info(Info, Data) -> error_logger:info_report([{module, ?MODULE}, {line, ?LINE}, {self, self()}, {message, Info}]), {noreply, Data}. code_change(_, Data, _) -> {ok, Data}. test(N) -> mnesia:stop(), mnesia:delete_schema([node()]), mnesia:create_schema([node()]), mnesia:start(), {atomic, ok} = mnesia:create_table(xref, [ {disc_only_copies, [node()]}, {type, set}, {attributes, record_info(fields, xref)} ]), {ok, Pid} = start(), {T1, _} = timer:tc(map5, populate, [Pid, N]), {T2, _} = timer:tc(map5, lookup, [Pid, N]), io:format("Populate: ~.4. f~n", [T1 / 1000000]), io:format("Lookup: ~.4. f~n", [T2 / 1000000]), gen_server:cast(Pid, stop). populate(_, 0) -> ok; populate(Pid, N) -> gen_server:cast(Pid, {'ADD', N, N}), populate(Pid, N - 1). lookup(_, 0) -> ok; lookup(Pid, N) -> gen_server:call(Pid, {'LOOKUP', N}), lookup(Pid, N - 1). From joelr1@REDACTED Thu Oct 9 13:13:26 2008 From: joelr1@REDACTED (Joel Reymont) Date: Thu, 9 Oct 2008 12:13:26 +0100 Subject: [erlang-questions] Benchmarking Erlang: Deathmatch of gb_trees, dict, ets, mnesia ... and registered names In-Reply-To: <35FA1D83-B63F-4691-AA81-7129BC3BC5F9@gmail.com> References: <35FA1D83-B63F-4691-AA81-7129BC3BC5F9@gmail.com> Message-ID: <1F60C446-258F-4F99-A901-84045DE8DEE5@gmail.com> %%% mnesia ram_copies that can be used in a distributed scenario -module(map6). -behaviour(gen_server). -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]). -export([start/0, test/1, populate/2, lookup/2, setup1/1]). -record(xref, { key, val }). start() -> gen_server:start(map6, [], []). init([]) -> {ok, none}. terminate(_, _) -> ok. handle_cast({'ADD', Key, Val}, Data) -> F = fun() -> mnesia:write(#xref{ key = Key, val = Val}) end, mnesia:transaction(F), {noreply, Data}; handle_cast(stop, Data) -> {stop, normal, Data}. handle_call({'LOOKUP', Key}, _From, Data) -> F = fun() -> mnesia:read({xref, Key}) end, {atomic, [Value]} = mnesia:transaction(F), {reply, Value, Data}. handle_info(Info, Data) -> error_logger:info_report([{module, ?MODULE}, {line, ?LINE}, {self, self()}, {message, Info}]), {noreply, Data}. code_change(_, Data, _) -> {ok, Data}. setup1(Nodes) -> mnesia:stop(), mnesia:delete_schema(Nodes), mnesia:create_schema(Nodes), mnesia:start(), {atomic, ok} = mnesia:create_table(xref, [ {ram_copies, Nodes}, {type, set}, {attributes, record_info(fields, xref)} ]). test(N) -> {ok, Pid} = start(), {T1, _} = timer:tc(map6, populate, [Pid, N]), {T2, _} = timer:tc(map6, lookup, [Pid, N]), io:format("Populate: ~.4. f~n", [T1 / 1000000]), io:format("Lookup: ~.4. f~n", [T2 / 1000000]), gen_server:cast(Pid, stop). populate(_, 0) -> ok; populate(Pid, N) -> gen_server:cast(Pid, {'ADD', N, N}), populate(Pid, N - 1). lookup(_, 0) -> ok; lookup(Pid, N) -> gen_server:call(Pid, {'LOOKUP', N}), lookup(Pid, N - 1). From joelr1@REDACTED Thu Oct 9 13:14:12 2008 From: joelr1@REDACTED (Joel Reymont) Date: Thu, 9 Oct 2008 12:14:12 +0100 Subject: [erlang-questions] Benchmarking Erlang: Deathmatch of gb_trees, dict, ets, mnesia ... and registered names In-Reply-To: <35FA1D83-B63F-4691-AA81-7129BC3BC5F9@gmail.com> References: <35FA1D83-B63F-4691-AA81-7129BC3BC5F9@gmail.com> Message-ID: %%% and finally, the moment you have all been waiting for! %%% ... %%% registered names -module(map7). -behaviour(gen_server). -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]). -export([start/1, test/1, populate/1, lookup/1]). start(N) -> gen_server:start({global, N}, map7, [], []). init([]) -> {ok, none}. terminate(_, _) -> ok. handle_cast(stop, Data) -> {stop, normal, Data}. handle_call(Event, From, Data) -> error_logger:info_report([{module, ?MODULE}, {line, ?LINE}, {self, self()}, {event, Event}, {from, From} ]), {noreply, Data}. handle_info(Info, Data) -> error_logger:info_report([{module, ?MODULE}, {line, ?LINE}, {self, self()}, {message, Info}]), {noreply, Data}. code_change(_, Data, _) -> {ok, Data}. test(N) -> {T1, _} = timer:tc(map7, populate, [N]), {T2, _} = timer:tc(map7, lookup, [N]), io:format("Populate: ~.4. f~n", [T1 / 1000000]), io:format("Lookup: ~.4. f~n", [T2 / 1000000]), stop(N). populate(0) -> ok; populate(N) -> {ok, _} = start(N), populate(N - 1). lookup(0) -> ok; lookup(N) -> P = global:whereis_name(N), lookup(N - 1). stop(0) -> ok; stop(N) -> gen_server:cast({global, N}, stop), stop(N - 1). From joelr1@REDACTED Thu Oct 9 13:18:38 2008 From: joelr1@REDACTED (Joel Reymont) Date: Thu, 9 Oct 2008 12:18:38 +0100 Subject: [erlang-questions] Benchmarking Erlang: Deathmatch of gb_trees, dict, ets, mnesia ... and registered names In-Reply-To: <35FA1D83-B63F-4691-AA81-7129BC3BC5F9@gmail.com> References: <35FA1D83-B63F-4691-AA81-7129BC3BC5F9@gmail.com> Message-ID: <1D12F980-BEA2-4356-84BA-A2B373BBE7B4@gmail.com> %% mnesia disc_only_copies (1@REDACTED)5> map5:test(10000). Populate: 0.1501 Lookup: 5.0008 ok (1@REDACTED)6> map5:test(100000). Populate: 1.2503 Lookup: 5.0002 ok (1@REDACTED)7> map5:test(1000000). Populate: 10.1628 Lookup: 5.0006 ok Is there a bug in my code? I thought disk access was supposed to be much slower! From ulf.wiger@REDACTED Thu Oct 9 13:24:16 2008 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Thu, 09 Oct 2008 13:24:16 +0200 Subject: [erlang-questions] Benchmarking Erlang: Deathmatch of gb_trees, dict, ets, mnesia ... and registered names In-Reply-To: <35FA1D83-B63F-4691-AA81-7129BC3BC5F9@gmail.com> References: <35FA1D83-B63F-4691-AA81-7129BC3BC5F9@gmail.com> Message-ID: <48EDE9E0.1080606@ericsson.com> Joel Reymont skrev: > > The absolutely bizarre and surprising discovery are the timings for > registered names. On a hunch, I thought I'd try to register a process > under its id. This way I could just send messages to that id from any > node in the cluster, without having to go through a separate > translation process. The only thing to think about, perhaps, is that global doesn't scale well when you add more nodes. If you have only one node, it's very fast indeed. See e.g. the benchmark figures given in my Gproc paper, pg 9: http://svn.ulf.wiger.net/gproc/doc/erlang07-wiger.pdf BR, Ulf W From joelr1@REDACTED Thu Oct 9 13:16:18 2008 From: joelr1@REDACTED (Joel Reymont) Date: Thu, 9 Oct 2008 12:16:18 +0100 Subject: [erlang-questions] Benchmarking Erlang: Deathmatch of gb_trees, dict, ets, mnesia ... and registered names In-Reply-To: <35FA1D83-B63F-4691-AA81-7129BC3BC5F9@gmail.com> References: <35FA1D83-B63F-4691-AA81-7129BC3BC5F9@gmail.com> Message-ID: %%% mnesia ram_copies (1@REDACTED)2> map4:test(10000). Populate: 0.1463 Lookup: 4.7873 ok (1@REDACTED)3> map4:test(100000). Populate: 1.5338 Lookup: 5.0010 ok (1@REDACTED)4> map4:test(1000000). Populate: 12.3123 Lookup: 5.0009 ok About the same as map3/ets. Not surprising, since ram_copies _is_ ets. From joelr1@REDACTED Thu Oct 9 13:26:33 2008 From: joelr1@REDACTED (Joel Reymont) Date: Thu, 9 Oct 2008 12:26:33 +0100 Subject: [erlang-questions] Benchmarking Erlang: Deathmatch of gb_trees, dict, ets, mnesia ... and registered names In-Reply-To: <35FA1D83-B63F-4691-AA81-7129BC3BC5F9@gmail.com> References: <35FA1D83-B63F-4691-AA81-7129BC3BC5F9@gmail.com> Message-ID: %% mnesia ram_copies on two nodes %% node #1 mothership:opti joelr$ erl -sname 1 (1@REDACTED)1> map6:setup1(['1@REDACTED', '2@REDACTED']). {atomic,ok} (1@REDACTED)2> mnesia:info(). ... ---> Active tables <--- schema : with 2 records occupying 553 words of mem xref : with 0 records occupying 312 words of mem ... running db nodes = ['2@REDACTED','1@REDACTED'] ... [{'1@REDACTED',ram_copies},{'2@REDACTED',ram_copies}] = [xref,schema] 5 transactions committed, 0 aborted, 0 restarted, 0 logged to disc 0 held locks, 0 in queue; 0 local transactions, 0 remote 0 transactions waits for other nodes: [] ok %% node #2 mothership:opti joelr$ erl -sname 2 (2@REDACTED)2> mnesia:start(). ok (2@REDACTED)3> mnesia:change_config(extra_db_nodes, ['1@REDACTED']). {ok,['1@REDACTED']} (2@REDACTED)4> mnesia:info(). ... ---> Active tables <--- schema : with 2 records occupying 553 words of mem xref : with 0 records occupying 312 words of mem ... running db nodes = ['1@REDACTED','2@REDACTED'] ... [{'1@REDACTED',ram_copies},{'2@REDACTED',ram_copies}] = [xref,schema] 5 transactions committed, 0 aborted, 0 restarted, 0 logged to disc 0 held locks, 0 in queue; 0 local transactions, 0 remote 0 transactions waits for other nodes: [] ok %% node #1 (1@REDACTED)3> map6:test(10000). Populate: 0.1193 Lookup: 5.0006 ok (1@REDACTED)4> map6:test(100000). Populate: 1.4206 Lookup: 5.0003 ok (1@REDACTED)5> map6:test(1000000). Populate: 1.8590 Lookup: 5.0009 ok No difference from ets and mnesia ram_copies on a single node! Here's proof that we did commit to the other node: %% node #2 (2@REDACTED)5> mnesia:info(). ---> Processes holding locks <--- Lock: {{xref,93850},write,{tid,16678,<5738.84.0>}} Lock: {{xref,999482},write,{tid,16671,<5738.86.0>}} ---> Participant transactions <--- Tid: 16671 (owned by <5738.86.0>) with participant objects {commit,'2@REDACTED',presume_commit, [{{xref,999482},{xref, 999482,999482},write}], [],[],[],[],[]} ---> Active tables <--- schema : with 2 records occupying 553 words of mem xref : with 16668 records occupying 186219 words of mem ... 5 transactions committed, 0 aborted, 0 restarted, 0 logged to disc 2 held locks, 0 in queue; 0 local transactions, 1 remote 0 transactions waits for other nodes: [] ok From vychodil.hynek@REDACTED Thu Oct 9 13:34:12 2008 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Thu, 9 Oct 2008 13:34:12 +0200 Subject: [erlang-questions] Benchmarking Erlang: Deathmatch of gb_trees, dict, ets, mnesia ... and registered names In-Reply-To: References: <35FA1D83-B63F-4691-AA81-7129BC3BC5F9@gmail.com> Message-ID: <20081009113413.775B92402F@relay.gooddata.com> Did you test if returned values from global:whereis_name is correct? You should do it especially when you don't believe benchmark result. You should check return value from each function call if you want trust your code. It can catch big amount of weird errors. On Thu, Oct 9, 2008 at 1:14 PM, Joel Reymont wrote: > %%% and finally, the moment you have all been waiting for! > %%% ... > %%% registered names > > -module(map7). > -behaviour(gen_server). > > -export([init/1, handle_call/3, handle_cast/2, > handle_info/2, terminate/2, code_change/3]). > > -export([start/1, test/1, populate/1, lookup/1]). > > start(N) -> > gen_server:start({global, N}, map7, [], []). > > init([]) -> > {ok, none}. > > terminate(_, _) -> > ok. > > handle_cast(stop, Data) -> > {stop, normal, Data}. > > handle_call(Event, From, Data) -> > error_logger:info_report([{module, ?MODULE}, > {line, ?LINE}, > {self, self()}, > {event, Event}, > {from, From} > ]), > {noreply, Data}. > > handle_info(Info, Data) -> > error_logger:info_report([{module, ?MODULE}, > {line, ?LINE}, > {self, self()}, > {message, Info}]), > {noreply, Data}. > > code_change(_, Data, _) -> > {ok, Data}. > > test(N) -> > {T1, _} = timer:tc(map7, populate, [N]), > {T2, _} = timer:tc(map7, lookup, [N]), > io:format("Populate: ~.4. f~n", [T1 / 1000000]), > io:format("Lookup: ~.4. f~n", [T2 / 1000000]), > stop(N). > > populate(0) -> > ok; > > populate(N) -> > {ok, _} = start(N), > populate(N - 1). > > lookup(0) -> > ok; > > lookup(N) -> > P = global:whereis_name(N), > lookup(N - 1). > > stop(0) -> > ok; > > stop(N) -> > gen_server:cast({global, N}, stop), > stop(N - 1). > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- --Hynek (Pichi) Vychodil -------------- next part -------------- An HTML attachment was scrubbed... URL: From joelr1@REDACTED Thu Oct 9 13:44:09 2008 From: joelr1@REDACTED (Joel Reymont) Date: Thu, 9 Oct 2008 12:44:09 +0100 Subject: [erlang-questions] Benchmarking Erlang: Deathmatch of gb_trees, dict, ets, mnesia ... and registered names In-Reply-To: <48EDE9E0.1080606@ericsson.com> References: <35FA1D83-B63F-4691-AA81-7129BC3BC5F9@gmail.com> <48EDE9E0.1080606@ericsson.com> Message-ID: <1A33E093-7C86-4E8E-BDB3-52E5971D5912@gmail.com> On Oct 9, 2008, at 12:24 PM, Ulf Wiger (TN/EAB) wrote: > The only thing to think about, perhaps, is that global doesn't > scale well when you add more nodes. If you have only one node, > it's very fast indeed. I thought I'd test with 4 nodes... (1@REDACTED)2> nodes(). ['2@REDACTED','3@REDACTED','4@REDACTED'] (1@REDACTED)3> map7:test(100000). Populate: 165.2079 Lookup: 0.0641 ok Not much of a difference, still super-efficient! -- wagerlabs.com From joelr1@REDACTED Thu Oct 9 13:45:14 2008 From: joelr1@REDACTED (Joel Reymont) Date: Thu, 9 Oct 2008 12:45:14 +0100 Subject: [erlang-questions] Benchmarking Erlang: Deathmatch of gb_trees, dict, ets, mnesia ... and registered names In-Reply-To: <20081009113413.7492324022@relay.gooddata.com> References: <35FA1D83-B63F-4691-AA81-7129BC3BC5F9@gmail.com> <20081009113413.7492324022@relay.gooddata.com> Message-ID: <999BCDBE-DCA5-46F7-9AC0-BEE7BA1F735F@gmail.com> lookup(N) -> P = global:whereis_name(N), true = is_process_alive(P), lookup(N - 1). This should be enough for error checking, right? (1@REDACTED)4> c(map7). {ok,map7} (1@REDACTED)5> map7:test(100000). Populate: 265.2531 Lookup: 0.0831 ok The timings are not much off! -- wagerlabs.com From saleyn@REDACTED Thu Oct 9 13:48:02 2008 From: saleyn@REDACTED (Serge Aleynikov) Date: Thu, 09 Oct 2008 07:48:02 -0400 Subject: [erlang-questions] Adding simple process to supervisor? In-Reply-To: <1223535807.3831.36.camel@seasc0642.dyn.rnd.as.sw.ericsson.se> References: <1223535807.3831.36.camel@seasc0642.dyn.rnd.as.sw.ericsson.se> Message-ID: <48EDEF72.60907@gmail.com> You need to look into the proc_lib module, which serves the need you described. Search this list for "proc_lib and sys" http://www.erlang.org/pipermail/erlang-questions/2006-July/021526.html In addition to implementing a synchronous startup function (using proc_lib:init_ack({ok, self()}) in your Module:start_link/1), you'll need to support these three functions so that your process is an obedient citizen in the OTP system: system_continue/3, system_terminate/4, system_code_change/4 E.g.: http://www.erlang.org/pipermail/erlang-questions/2005-April/015224.html Serge Bengt Kleberg wrote: > Greetings, > > I have a gen_server which is supervised according to OTP rules. Now I > want to add a simple process that will read from a TCP port and send > the incoming data to the gen_server. I could spawn_link this process > from the gen_server and restart it if it dies. However, since I have a > supervisor it seems more logical to just add the process there, as a > rest_for_one. > > > There is the alternative of using a supervisor_bridge, but that seems > more complex than using the gen_server. It seems as if I just design > my process according to the OTP rules I will not need to use a > supervisor_bridge. What are those rules? The only suggestions I have > found are: > 1 Module:start_link/1 => {ok, Pid} > 2 Module:terminate/2 => ok > > > The child specification returned by the init/1 call-back in a > supervisor mentions the value for Modules if we have a gen_server, > gen_fsm or gen_event. What could be used for a simple process? > > > But how do I add a simple process to the supervisor? It seems overkill > to masquerade it as a get_fsm or similar. Since it is not called from > erlang it is not a gen_server. Since it does not have state it is not a > gen_fsm. No events are handled. > > > bengt > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From saleyn@REDACTED Thu Oct 9 14:03:28 2008 From: saleyn@REDACTED (Serge Aleynikov) Date: Thu, 09 Oct 2008 08:03:28 -0400 Subject: [erlang-questions] Benchmarking Erlang: Deathmatch of gb_trees, dict, ets, mnesia ... and registered names In-Reply-To: <999BCDBE-DCA5-46F7-9AC0-BEE7BA1F735F@gmail.com> References: <35FA1D83-B63F-4691-AA81-7129BC3BC5F9@gmail.com> <20081009113413.7492324022@relay.gooddata.com> <999BCDBE-DCA5-46F7-9AC0-BEE7BA1F735F@gmail.com> Message-ID: <48EDF310.20502@gmail.com> This doesn't make sense as calling is_process_alive/1 on a non-local Pid would throw an exception (meaning that all your pids are on the local node since you are not getting one). Joel Reymont wrote: > lookup(N) -> > P = global:whereis_name(N), > true = is_process_alive(P), > lookup(N - 1). > > This should be enough for error checking, right? > > (1@REDACTED)4> c(map7). > {ok,map7} > (1@REDACTED)5> map7:test(100000). > Populate: 265.2531 > Lookup: 0.0831 > ok > > The timings are not much off! > > -- > wagerlabs.com > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From ulf.wiger@REDACTED Thu Oct 9 14:05:54 2008 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Thu, 09 Oct 2008 14:05:54 +0200 Subject: [erlang-questions] Benchmarking Erlang: Deathmatch of gb_trees, dict, ets, mnesia ... and registered names In-Reply-To: <999BCDBE-DCA5-46F7-9AC0-BEE7BA1F735F@gmail.com> References: <35FA1D83-B63F-4691-AA81-7129BC3BC5F9@gmail.com> <20081009113413.7492324022@relay.gooddata.com> <999BCDBE-DCA5-46F7-9AC0-BEE7BA1F735F@gmail.com> Message-ID: <48EDF3A2.4000006@ericsson.com> Joel Reymont skrev: > lookup(N) -> > P = global:whereis_name(N), > true = is_process_alive(P), > lookup(N - 1). > > This should be enough for error checking, right? > > (1@REDACTED)4> c(map7). > {ok,map7} > (1@REDACTED)5> map7:test(100000). > Populate: 265.2531 > Lookup: 0.0831 > ok > > The timings are not much off! How many nodes did you have there? > I thought I'd test with 4 nodes... > > (1@REDACTED)2> nodes(). > ['2@REDACTED','3@REDACTED','4@REDACTED'] > (1@REDACTED)3> map7:test(100000). > Populate: 165.2079 > Lookup: 0.0641 > ok > > Not much of a difference, still super-efficient! It seems as if you have quite a large variation on the populate benchmark - esp if the first test above is with only one node. Anyway, the worst part of global's algorithm is the random backoff at lock conflicts, but that shouldn't affect you in this particular case. BR, Ulf W From joelr1@REDACTED Thu Oct 9 14:06:57 2008 From: joelr1@REDACTED (Joel Reymont) Date: Thu, 9 Oct 2008 13:06:57 +0100 Subject: [erlang-questions] Benchmarking Erlang: Deathmatch of gb_trees, dict, ets, mnesia ... and registered names In-Reply-To: <1A33E093-7C86-4E8E-BDB3-52E5971D5912@gmail.com> References: <35FA1D83-B63F-4691-AA81-7129BC3BC5F9@gmail.com> <48EDE9E0.1080606@ericsson.com> <1A33E093-7C86-4E8E-BDB3-52E5971D5912@gmail.com> Message-ID: <17F15E0F-F779-4C91-833C-4261949E4210@gmail.com> The difference is that it took 165 seconds to globally register 100k processes on 4 nodes. The lookup time is still excellent, though! On Oct 9, 2008, at 12:44 PM, Joel Reymont wrote: > I thought I'd test with 4 nodes... > > (1@REDACTED)2> nodes(). > ['2@REDACTED','3@REDACTED','4@REDACTED'] > (1@REDACTED)3> map7:test(100000). > Populate: 165.2079 > Lookup: 0.0641 > ok -- wagerlabs.com From joelr1@REDACTED Thu Oct 9 14:07:55 2008 From: joelr1@REDACTED (Joel Reymont) Date: Thu, 9 Oct 2008 13:07:55 +0100 Subject: [erlang-questions] Benchmarking Erlang: Deathmatch of gb_trees, dict, ets, mnesia ... and registered names In-Reply-To: <48EDF310.20502@gmail.com> References: <35FA1D83-B63F-4691-AA81-7129BC3BC5F9@gmail.com> <20081009113413.7492324022@relay.gooddata.com> <999BCDBE-DCA5-46F7-9AC0-BEE7BA1F735F@gmail.com> <48EDF310.20502@gmail.com> Message-ID: <0F30EFA1-F6B5-48F6-AF6F-7206A4D3F311@gmail.com> On Oct 9, 2008, at 1:03 PM, Serge Aleynikov wrote: > This doesn't make sense as calling is_process_alive/1 on a non-local > Pid would throw an exception (meaning that all your pids are on the > local node since you are not getting one). For the purposes of testing, all my pids _are_ on the local node. -- wagerlabs.com From joelr1@REDACTED Thu Oct 9 14:15:54 2008 From: joelr1@REDACTED (Joel Reymont) Date: Thu, 9 Oct 2008 13:15:54 +0100 Subject: [erlang-questions] Benchmarking Erlang: Deathmatch of gb_trees, dict, ets, mnesia ... and registered names In-Reply-To: <48EDF3A2.4000006@ericsson.com> References: <35FA1D83-B63F-4691-AA81-7129BC3BC5F9@gmail.com> <20081009113413.7492324022@relay.gooddata.com> <999BCDBE-DCA5-46F7-9AC0-BEE7BA1F735F@gmail.com> <48EDF3A2.4000006@ericsson.com> Message-ID: On Oct 9, 2008, at 1:05 PM, Ulf Wiger (TN/EAB) wrote: > How many nodes did you have there? Same 4 nodes. > It seems as if you have quite a large variation on > the populate benchmark - esp if the first test above > is with only one node. No, there's no variation, it's the same 4 nodes. > Anyway, the worst part of global's algorithm is the > random backoff at lock conflicts, but that shouldn't > affect you in this particular case. Here's the version of the code I'm testing with 50 nodes now. Use start_slaves/1 with your desired number of nodes and try test/1 right after. I think it will be tomorrow before my 50 nodes and 100k processes test is done. --- -module(map8). -behaviour(gen_server). -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]). -export([start/1, test/1, populate/1, lookup/1, start_slaves/1]). start(N) -> gen_server:start({global, N}, map8, [], []). init([]) -> {ok, none}. terminate(_, _) -> ok. handle_cast(stop, Data) -> {stop, normal, Data}. handle_call(Event, From, Data) -> error_logger:info_report([{module, ?MODULE}, {line, ?LINE}, {self, self()}, {event, Event}, {from, From} ]), {noreply, Data}. handle_info(Info, Data) -> error_logger:info_report([{module, ?MODULE}, {line, ?LINE}, {self, self()}, {message, Info}]), {noreply, Data}. code_change(_, Data, _) -> {ok, Data}. test(N) -> {T1, _} = timer:tc(map8, populate, [N]), {T2, _} = timer:tc(map8, lookup, [N]), io:format("Populate: ~.4. f~n", [T1 / 1000000]), io:format("Lookup: ~.4. f~n", [T2 / 1000000]), stop(N). populate(0) -> ok; populate(N) -> {ok, _} = start(N), populate(N - 1). lookup(0) -> ok; lookup(N) -> P = global:whereis_name(N), true = is_process_alive(P), lookup(N - 1). stop(0) -> ok; stop(N) -> gen_server:cast({global, N}, stop), stop(N - 1). start_slaves(0) -> ok; start_slaves(N) -> Name = list_to_atom(integer_to_list(N)), Args = "", Node = start_slave_node(Name, Args), io:format("~p up running~n", [Node]), timer:sleep(100), start_slaves(N - 1). start_slave_node(Name, Args) -> {ok, Node} = slave:start_link(net_adm:localhost(), Name, Args), Node. -- wagerlabs.com From richardc@REDACTED Thu Oct 9 14:17:49 2008 From: richardc@REDACTED (Richard Carlsson) Date: Thu, 09 Oct 2008 14:17:49 +0200 Subject: [erlang-questions] Benchmarking Erlang: Deathmatch of gb_trees, dict, ets, mnesia ... and registered names In-Reply-To: <35FA1D83-B63F-4691-AA81-7129BC3BC5F9@gmail.com> References: <35FA1D83-B63F-4691-AA81-7129BC3BC5F9@gmail.com> Message-ID: <48EDF66D.9010101@it.uu.se> Joel Reymont wrote: > Dict seems to be the winner for 100K values. What's particularly > interesting to me is that gb_trees, dict and ets give take about the > same time to look up 1 mil. values. Is there an explanation? Joel, one of the problems with benchmarking is to be sure what it is that you measure. Your code for "populate" uses gen_server:cast, which basically means that what you measure is message passing time. Furthermore, for large numbers of messages, you start running the lookup test before the server has had time to process its huge in-queue, hence the strangely similar numbers 5.0xxx for most tests. The hint is that your numbers _should_ scale at least linearly with the number of elements, and that the lookup time should be the same for both 100k and 1000k elements is completely unreasonable. (The confirmation for me was that even though the test had completed, my cpu was still working like crazy until I shut down the VM again; the server was still processing a million backed up ADD-requests.) Changing cast to call in your code, I get this for dict and gb_trees: ---- map1:test(10000). Populate: 0.1408 Lookup: 0.0497 map1:test(100000). Populate: 1.9648 Lookup: 0.5244 map1:test(1000000). Populate: 34.2963 Lookup: 5.2909 ---- map2:test(10000). Populate: 0.1187 Lookup: 0.0519 map2:test(100000). Populate: 0.9676 Lookup: 0.5331 map2:test(1000000). Populate: 40.2369 Lookup: 5.8442 ---- These numbers make more sense: they scale with the number of elements, and gb_trees wins over dict. /Richard From joelr1@REDACTED Thu Oct 9 14:27:30 2008 From: joelr1@REDACTED (Joel Reymont) Date: Thu, 9 Oct 2008 13:27:30 +0100 Subject: [erlang-questions] Benchmarking Erlang: Deathmatch of gb_trees, dict, ets, mnesia ... and registered names In-Reply-To: <48EDF66D.9010101@it.uu.se> References: <35FA1D83-B63F-4691-AA81-7129BC3BC5F9@gmail.com> <48EDF66D.9010101@it.uu.se> Message-ID: On Oct 9, 2008, at 1:17 PM, Richard Carlsson wrote: > Changing cast to call in your code, I get this for dict and gb_trees: Richard, thank you for pointing out the flaw in my code. Still, note that the lookup time is still very very low. I'm not really concerned with the time to populate as my goal is to grab a number from every incoming packet and map that to a process id so that I can route the packet. I really like globally registered names since they take care of distributing the pids across the cluster. It doesn't seem they scale, though. -- wagerlabs.com From Dana.RUBINO@REDACTED Thu Oct 9 15:05:48 2008 From: Dana.RUBINO@REDACTED (Dana.RUBINO@REDACTED) Date: Thu, 9 Oct 2008 14:05:48 +0100 Subject: [erlang-questions] Erlang ODBC best practices Message-ID: Hi All, I am currently using an in-memory database which offers ODBC connectivity (Oracle Times Ten). Of course given I am using ODBC I need to generate and pass SQL commands to the DB. I was wondering what is the best way to organise SQL statements (canned) and build up dynamic SQL statements within Erlang? Currently I just have my static SQL commands in a .hrl file and as a crude example access them as such: odbc:start(), {ok, Ref} = odbc:connect("DSN=TT_HWHU;UID=aUID;PWD=aPWD", [{scrollable_cursors, off}]), {selected, ColNames, Data} = odbc:sql_query(Ref, ?TESTSQL), Does anyone know of a better way of doing this? In particular building up an SQL statement dynamically - for example in an insert statement? Many Thanks, Dan *********************************************************************************** The Royal Bank of Scotland plc. Registered in Scotland No 90312. Registered Office: 36 St Andrew Square, Edinburgh EH2 2YB. Authorised and regulated by the Financial Services Authority This e-mail message is confidential and for use by the addressee only. If the message is received by anyone other than the addressee, please return the message to the sender by replying to it and then delete the message from your computer. Internet e-mails are not necessarily secure. The Royal Bank of Scotland plc does not accept responsibility for changes made to this message after it was sent. Whilst all reasonable care has been taken to avoid the transmission of viruses, it is the responsibility of the recipient to ensure that the onward transmission, opening or use of this message and any attachments will not adversely affect its systems or data. No responsibility is accepted by The Royal Bank of Scotland plc in this regard and the recipient should carry out such virus and other checks as it considers appropriate. Visit our websites at: www.rbs.com www.rbs.com/gbm www.rbsgc.com *********************************************************************************** -------------- next part -------------- An HTML attachment was scrubbed... URL: From dot@REDACTED Thu Oct 9 14:35:23 2008 From: dot@REDACTED (Tony Finch) Date: Thu, 9 Oct 2008 13:35:23 +0100 Subject: [erlang-questions] Benchmarking Erlang: Deathmatch of gb_trees, dict, ets, mnesia ... and registered names In-Reply-To: <48EDF66D.9010101@it.uu.se> References: <35FA1D83-B63F-4691-AA81-7129BC3BC5F9@gmail.com> <48EDF66D.9010101@it.uu.se> Message-ID: On Thu, 9 Oct 2008, Richard Carlsson wrote: > > The hint is that your numbers _should_ scale at least linearly with > the number of elements, Shouldn't lookup be O(log n)? Tony. -- f.anthony.n.finch http://dotat.at/ SOLE: SOUTHERLY 5 TO 7, OCCASIONALLY GALE 8. MODERATE OR ROUGH, OCCASIONALLY VERY ROUGH IN WEST LATER. OCCASIONAL RAIN. MODERATE OR GOOD, OCCASIONALLY POOR. From erlang@REDACTED Thu Oct 9 15:18:07 2008 From: erlang@REDACTED (Joe Armstrong) Date: Thu, 9 Oct 2008 15:18:07 +0200 Subject: [erlang-questions] disk tests Message-ID: <9b08084c0810090618l5226d8b0m74bcfb92026e621d@mail.gmail.com> Hello, I've written a little program to test writing to disk - I need to create a number of large random access files and was running some tests when I ran into problems. As I write files to disk the erlang process grows and eventually I hit some kind of memory limits and the system slows to a crawl. It also has this behavior for sequential writes to disk. Also the data rate to disk is not as fast as I would have expected. Is this a bug or a feature? Here's a program that reproduces this. When I run disk_test:test() my system slows to a crawl. Can anybody explain what is happening here? Best /Joe -module(disk_test). %% Time-stamp: <2008-10-09 15:16:16 joe> -import(lists, [min/1, duplicate/2]). -compile(export_all). %% This program was supposed to test how fast I could write to disk %% but when I run it, it virtually stops the system. %% I create a 2 Meg file filled with zeros, then a 4 Meg file %% then a 6 Meg file and so on. %% By the time I get to creating a 40 MByte file the system has slowed to %% a crawl. The total data written at this point is around 500 Meg. %% If I watch the Memory usage my Erlang process has run up to 2GB of %% memory and the entire system crawls along. I then have to kill Erlang. %% The first few lines of output when I run this are as follows: %% > disk_test:test(). %% Creating a 2 Megabyte file %% {created,2,megs,in,0.225377,secs,8.874019975418966, %% megaBytesPerSec}. %% Creating a 4 Megabyte file %% {created,6,megs,in,0.49773,secs,12.054728467241276, %% megaBytesPerSec}. %% Creating a 6 Megabyte file %% {created,12,megs,in,0.930026,secs,12.902865081191278, %% megaBytesPerSec}. %% Creating a 8 Megabyte file %% {created,20,megs,in,1.461848,secs,13.681312968242937, %% megaBytesPerSec}. %% Creating a 10 Megabyte file %% {created,30,megs,in,2.213844,secs,13.551090320727207, %% megaBytesPerSec}. %% Creating a 12 Megabyte file %% {created,42,megs,in,2.926186,secs,14.353154584158355, %% megaBytesPerSec}. %% I'm managing to write about 12 MBytes/sec %% I suspect the disk is capable of about 70 MB/sec %% (just a guess) %% What's happening here? - why does the process size grow so large? test() -> make_file_seq(2,2,now_micros()). make_file_seq(N,_,_) when N > 60 -> true; make_file_seq(N,Tot,Tstart) -> make_file_seq0(N), Secs = duration(Tstart), Rate = Tot/Secs, io:format("~p.~n",[{created, Tot, megs,in, Secs,secs, Rate,megaBytesPerSec}]), make_file_seq(N+2, Tot+N+2, Tstart). duration(Tstart) -> (now_micros() - Tstart)/1000000. now_micros() -> {Mega,Sec,Micro} = erlang:now(), (Mega*1000000 + Sec)*1000000 + Micro. make_file_seq0(N) -> io:format("Creating a ~p Megabyte file~n",[N]), File = "tmp", file:delete(File), {ok, S} = file:open(File, [write]), Size = N * 1000000, zero_file_seqwrite(S, Size), file:close(S), Size = filelib:file_size(File). %% just checking :-) %% zero_file_seqwrite_seqwrite(FileHandle, Len) %% writes Len zeros to a file zero_file_seqwrite(S, Len) -> N = min([Len, 4096]), B = list_to_binary(duplicate(N, 0)), zero_file_seqwrite(S, Len, B, N). zero_file_seqwrite(S, Len, B, Size) when Size > Len -> file:write(S, [B]), zero_file_seqwrite(S, Len-Size, B, Size); zero_file_seqwrite(S, Len, _, _) -> B = list_to_binary(duplicate(Len, 0)), file:write(S, [B]). From richardc@REDACTED Thu Oct 9 15:32:09 2008 From: richardc@REDACTED (Richard Carlsson) Date: Thu, 09 Oct 2008 15:32:09 +0200 Subject: [erlang-questions] Benchmarking Erlang: Deathmatch of gb_trees, dict, ets, mnesia ... and registered names In-Reply-To: References: <35FA1D83-B63F-4691-AA81-7129BC3BC5F9@gmail.com> <48EDF66D.9010101@it.uu.se> Message-ID: <48EE07D9.5010508@it.uu.se> Tony Finch wrote: > On Thu, 9 Oct 2008, Richard Carlsson wrote: >> The hint is that your numbers _should_ scale at least linearly with >> the number of elements, > > Shouldn't lookup be O(log n)? Yes, if you do it once. But these runtimes were measured over n calls. (For populate, it gets a bit more complicated since the first operations work on a small dictionary and the last operations work on a huge one, but for lookup the total time should be a straightforward O(n*log n) for gb_trees.) /Richard From richardc@REDACTED Thu Oct 9 15:38:55 2008 From: richardc@REDACTED (Richard Carlsson) Date: Thu, 09 Oct 2008 15:38:55 +0200 Subject: [erlang-questions] Benchmarking Erlang: Deathmatch of gb_trees, dict, ets, mnesia ... and registered names In-Reply-To: References: <35FA1D83-B63F-4691-AA81-7129BC3BC5F9@gmail.com> <48EDF66D.9010101@it.uu.se> Message-ID: <48EE096F.6090307@it.uu.se> Joel Reymont wrote: > Richard, thank you for pointing out the flaw in my code. Still, note > that the lookup time is still very very low. > > I'm not really concerned with the time to populate as my goal is to > grab a number from every incoming packet and map that to a process id > so that I can route the packet. The main thing was just that you will not get any sensible numbers from the lookup measurement unless you have made sure that the population of the table has finished first. Otherwise you'll be measuring the time to look up nonexisting stuff, and for that most storage methods will do equally well. /Richard From vladdu55@REDACTED Thu Oct 9 15:44:53 2008 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Thu, 9 Oct 2008 15:44:53 +0200 Subject: [erlang-questions] Fwd: disk tests In-Reply-To: <9b08084c0810090618l5226d8b0m74bcfb92026e621d@mail.gmail.com> References: <9b08084c0810090618l5226d8b0m74bcfb92026e621d@mail.gmail.com> Message-ID: <95be1d3b0810090644j7dc7fc8es88ed4a5d17e495db@mail.gmail.com> Hi Joe, Shouldn't this > zero_file_seqwrite(S, Len, B, Size) when Size > Len -> be zero_file_seqwrite(S, Len, B, Size) when Size =< Len -> instead? The second version works completely fine. regards, Vlad From anders.nygren@REDACTED Thu Oct 9 15:55:57 2008 From: anders.nygren@REDACTED (Anders Nygren) Date: Thu, 9 Oct 2008 08:55:57 -0500 Subject: [erlang-questions] Benchmarking Erlang: Deathmatch of gb_trees, dict, ets, mnesia ... and registered names In-Reply-To: <48EE096F.6090307@it.uu.se> References: <35FA1D83-B63F-4691-AA81-7129BC3BC5F9@gmail.com> <48EDF66D.9010101@it.uu.se> <48EE096F.6090307@it.uu.se> Message-ID: On Thu, Oct 9, 2008 at 8:38 AM, Richard Carlsson wrote: > Joel Reymont wrote: >> Richard, thank you for pointing out the flaw in my code. Still, note >> that the lookup time is still very very low. >> >> I'm not really concerned with the time to populate as my goal is to >> grab a number from every incoming packet and map that to a process id >> so that I can route the packet. > > The main thing was just that you will not get any sensible numbers from > the lookup measurement unless you have made sure that the population of > the table has finished first. Otherwise you'll be measuring the time to > look up nonexisting stuff, and for that most storage methods will do > equally well. > But since gen_server handles messages in a FIFO manner, all inserts will be processed before the lookups. The only problem is that the first lookup will have to wait for all inserts to finish. So the time for lookups will include the time for the inserts to finish, but there will not be a lot of lookups before the inserts have finished. /Anders > /Richard > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From joelr1@REDACTED Thu Oct 9 16:09:21 2008 From: joelr1@REDACTED (Joel Reymont) Date: Thu, 9 Oct 2008 15:09:21 +0100 Subject: [erlang-questions] Benchmarking Erlang: Deathmatch of gb_trees, dict, ets, mnesia ... and registered names In-Reply-To: <48EDE9E0.1080606@ericsson.com> References: <35FA1D83-B63F-4691-AA81-7129BC3BC5F9@gmail.com> <48EDE9E0.1080606@ericsson.com> Message-ID: On Oct 9, 2008, at 12:24 PM, Ulf Wiger (TN/EAB) wrote: > The only thing to think about, perhaps, is that global doesn't > scale well when you add more nodes. If you have only one node, > it's very fast indeed. Here are results for 4, 25 and 50 nodes, averages calculated thusly: populate(N) -> populate(N, 0). populate(0, Avg) -> Avg; populate(N, Avg) -> if (N rem 10000) == 0 -> io:format("Avg: ~.4. f~n", [Avg / 1000000]); true -> ok end, {T, {ok, _}} = timer:tc(map8, start, [N]), populate(N - 1, (Avg + T) / 2). It looks like process registration time doubles with the # of nodes. (master@REDACTED)3> map8:start_slaves(4). ... ok (master@REDACTED)4> map8:test(100000). ... Avg: 0.0000 Avg: 0.0017 Avg: 0.0017 Avg: 0.0016 Avg: 0.0019 Avg: 0.0016 Avg: 0.0018 Avg: 0.0016 Avg: 0.0017 Avg: 0.0016 Populate: 170.1915 Avg start: 0.0017 Lookup: 0.0857 ok (master@REDACTED)1> map8:start_slaves(25). ... ok (master@REDACTED)2> map8:test(100000). Avg: 0.0000 Avg: 0.0113 Avg: 0.0105 Avg: 0.0108 Avg: 0.0111 Avg: 0.0105 Avg: 0.0096 Avg: 0.0114 Avg: 0.0110 Avg: 0.0111 Populate: 1031.4716 Avg start: 0.0111 Lookup: 0.0875 (master@REDACTED)1> map8:start_slaves(50). ... ok (master@REDACTED)2> map8:test(100000). Avg: 0.0000 Avg: 0.0240 Avg: 0.0220 Avg: 0.0248 Avg: 0.0207 Avg: 0.0234 Avg: 0.0262 Avg: 0.0242 Avg: 0.0237 Avg: 0.0241 Populate: 2393.1143 Avg start: 0.0247 Lookup: 0.0877 ok -- wagerlabs.com From erlang@REDACTED Thu Oct 9 16:19:20 2008 From: erlang@REDACTED (Joe Armstrong) Date: Thu, 9 Oct 2008 16:19:20 +0200 Subject: [erlang-questions] Fwd: disk tests In-Reply-To: <95be1d3b0810090644j7dc7fc8es88ed4a5d17e495db@mail.gmail.com> References: <9b08084c0810090618l5226d8b0m74bcfb92026e621d@mail.gmail.com> <95be1d3b0810090644j7dc7fc8es88ed4a5d17e495db@mail.gmail.com> Message-ID: <9b08084c0810090719o40e3db3en84ab57e729a15f45@mail.gmail.com> yes yes - fool that I am - the funny thing is that it worked at all - the second clause would trigger and create a collosal list in memory .... it's been a bad day ... thanks -- /Joe On Thu, Oct 9, 2008 at 3:44 PM, Vlad Dumitrescu wrote: > Hi Joe, > > Shouldn't this > >> zero_file_seqwrite(S, Len, B, Size) when Size > Len -> > > be > > zero_file_seqwrite(S, Len, B, Size) when Size =< Len -> > > instead? > > The second version works completely fine. > > regards, > Vlad > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From vychodil.hynek@REDACTED Thu Oct 9 16:30:31 2008 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Thu, 9 Oct 2008 16:30:31 +0200 Subject: [erlang-questions] Fwd: disk tests In-Reply-To: <4d08db370810090724g61770b13kfb5ab08a0cc349ec@mail.gmail.com> References: <9b08084c0810090618l5226d8b0m74bcfb92026e621d@mail.gmail.com> <95be1d3b0810090644j7dc7fc8es88ed4a5d17e495db@mail.gmail.com> <4d08db370810090724g61770b13kfb5ab08a0cc349ec@mail.gmail.com> Message-ID: <20081009143032.3327624022@relay.gooddata.com> On Thu, Oct 9, 2008 at 4:24 PM, Hynek Vychodil wrote: > It will work also with > > zero_file_seqwrite(S, Len, B, Size) when Size < Len -> > > but I think better will be > > zero_file_seqwrite(Handler, Size, Block, BlockSize) when BlockSize < Size > -> > > and all comes clear. > > zero_file_seqwrite(_, 0, _, _) -> ok; > zero_file_seqwrite(Handler, Size, Block, BlockSize) when BlockSize < Size > -> > oh mistake, there should be BlockSize= > file:write(Handler, [Block]), > zero_file_seqwrite(Handler, Size-BlockSize, Block, BlockSize); > zero_file_seqwrite(Handler, Size, _, _) -> > Block = list_to_binary(duplicate(Size, 0)), > file:write(Handler, [Block]). > > On Thu, Oct 9, 2008 at 3:44 PM, Vlad Dumitrescu wrote: > >> Hi Joe, >> >> Shouldn't this >> >> > zero_file_seqwrite(S, Len, B, Size) when Size > Len -> >> >> be >> >> zero_file_seqwrite(S, Len, B, Size) when Size =< Len -> >> >> instead? >> >> The second version works completely fine. >> >> regards, >> Vlad >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > > > -- > --Hynek (Pichi) Vychodil > -- --Hynek (Pichi) Vychodil -------------- next part -------------- An HTML attachment was scrubbed... URL: From richardc@REDACTED Thu Oct 9 17:58:37 2008 From: richardc@REDACTED (Richard Carlsson) Date: Thu, 09 Oct 2008 17:58:37 +0200 Subject: [erlang-questions] The trouble with measurements (was: Benchmarking Erlang: ...) In-Reply-To: References: <35FA1D83-B63F-4691-AA81-7129BC3BC5F9@gmail.com> <48EDF66D.9010101@it.uu.se> <48EE096F.6090307@it.uu.se> Message-ID: <48EE2A2D.7000800@it.uu.se> Anders Nygren wrote: > But since gen_server handles messages in a FIFO manner, all inserts > will be processed before the lookups. The only problem is that the > first lookup will have to wait for all inserts to finish. So the time > for lookups will include the time for the inserts to finish, but > there will not be a lot of lookups before the inserts have finished. The major problem with benchmarks, I have to say again, is to know what is actually being measured. I thought I knew what was going on, but Anders' comment here made me sit up and think "of course he's right!" followed by "but how could that possibly fit in with what I'm seeing??" because what I was seeing was that for large N, the results from test(N) came in long before all the messages were processed by the gen_server. The explanation turned out to be complicated. It was a dark and stormy night... First, this doesn't happen as easily without SMP (and since smp is on by default these days, that was what I was using - and Joel too, I assume). Without SMP, there is a single scheduler which time-slices all the ready Erlang processes. A sender process, which does a large number (30000+) of gen_server:cast() (asynchronous messages to the server), will not be able to dispatch all of these before the gen_server process is swapped in instead and starts handling the messages. But with SMP, a sender can happily fill upp the server mailbox with tens of thousands of messages and then proceed to doing gen_server:call() instead. Second, Joel had not specified a timeout for his gen_server:call(). This means that it uses the default, which happens to be five seconds. Now, you may remember from Joel's numbers what the lookup times for large N were all very close to... So, with SMP, and sufficiently large N, the test process very quickly dispatched all its casts to ADD elements to the table, and the poor gen_server had barely started to process them, when the test process entered the first gen_server:call() to do a LOOKUP. Five seconds passed, and the call timed out (still long before the server was anywhere near getting through all the ADDs). This threw an exception, which immediately quit the lookup(Pid, N) loop after the first call. So why didn't anyone notice the timeout? Well, because of timer:tc(), of course, which runs the call within a catch! So, what the timer really measured for the lookup loop, was the time for the first gen_server:call to time out, namely, five seconds. /Richard From erlang-questions_efine@REDACTED Thu Oct 9 18:53:52 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Thu, 9 Oct 2008 12:53:52 -0400 Subject: [erlang-questions] [enhancement] string:split/2 In-Reply-To: <781bce43-97e9-48fb-bba2-0ce230f2011a@t39g2000prh.googlegroups.com> References: <6c2563b20810081642r2fbd1f14w8e3f7a5a2b71bcc4@mail.gmail.com> <34A27838-5CBA-425D-97A1-C2D2CF6F5456@cs.otago.ac.nz> <6c2563b20810082354u34372510n1fb4e1d23d777c23@mail.gmail.com> <781bce43-97e9-48fb-bba2-0ce230f2011a@t39g2000prh.googlegroups.com> Message-ID: <6c2563b20810090953n1b0c7672v17ceb84cbb59a1fd@mail.gmail.com> > > > Do you mean that string:split should be the _inverse_ of string:join? > > http://en.wikipedia.org/wiki/Inverse_function Yes, that's it. Thanks. I just wish there was a more impressive-sounding word like idempotent :) > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From joelr1@REDACTED Thu Oct 9 19:18:39 2008 From: joelr1@REDACTED (Joel Reymont) Date: Thu, 9 Oct 2008 18:18:39 +0100 Subject: [erlang-questions] The trouble with measurements (was: Benchmarking Erlang: ...) In-Reply-To: <48EE2A2D.7000800@it.uu.se> References: <35FA1D83-B63F-4691-AA81-7129BC3BC5F9@gmail.com> <48EDF66D.9010101@it.uu.se> <48EE096F.6090307@it.uu.se> <48EE2A2D.7000800@it.uu.se> Message-ID: On Oct 9, 2008, at 4:58 PM, Richard Carlsson wrote: > So why didn't anyone notice the timeout? Well, because of timer:tc(), > of course, which runs the call within a catch! So, what the timer > really > measured for the lookup loop, was the time for the first > gen_server:call > to time out, namely, five seconds. Ouch! It works properly with call instead of cast, though, do I understand you correctly? -- wagerlabs.com From stonecypher@REDACTED Thu Oct 9 20:32:17 2008 From: stonecypher@REDACTED (John Haugeland) Date: Thu, 9 Oct 2008 12:32:17 -0600 Subject: [erlang-questions] erlang-questions Digest, Vol 17, Issue 41 In-Reply-To: <8f24f4b10810091131n7590f33aw20ae6da138a7e642@mail.gmail.com> References: <8f24f4b10810091131n7590f33aw20ae6da138a7e642@mail.gmail.com> Message-ID: <8f24f4b10810091132s74eb779cuc21ad7c93fae72f2@mail.gmail.com> > function get_card_id( { ThisBack, ThisFace, ThisSuit } ) -> > Er, obviously no function. Sorry, I've been working in PHP all morning. -------------- next part -------------- An HTML attachment was scrubbed... URL: From stonecypher@REDACTED Thu Oct 9 20:31:07 2008 From: stonecypher@REDACTED (John Haugeland) Date: Thu, 9 Oct 2008 12:31:07 -0600 Subject: [erlang-questions] erlang-questions Digest, Vol 17, Issue 41 In-Reply-To: References: Message-ID: <8f24f4b10810091131n7590f33aw20ae6da138a7e642@mail.gmail.com> > > Date: Wed, 8 Oct 2008 17:01:25 +0100 > From: Joel Reymont > Subject: [erlang-questions] pid to integer and back > To: Erlang Questions > Message-ID: > Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes > > Is there a safe and efficient way to convert pid to integer and back? > > I'm assigning each running poker game an integer id. I store this id > into every outgoing packet so there's no database lookup. > > I use the id to lookup the game process for every incoming packet, > though. This is proving to be extremely inefficient, even with dirty > mnesia reads. > > I actually repeat the above for every player, so there's twice the > overhead. Is there a way to avoid it? > > This would only apply to running games and connected players so this > would be a temporary integer, valid while the process is alive. There are three general approaches to this. 1) You can pack any known integer ranges into another integer through radix multiplication. You know, for example, that you can store four decks of cards { redback, 6, hearts } in an octet by skipping ranges up to fill: -define(Suits, [hearts,clubs,spades,diamonds]). -define(Faces, [ace,2,3,4,5,6,7,8,9,10,jack,queen,king]). -define(Backs, [red,blue,green,black]). function get_card_id( { ThisBack, ThisFace, ThisSuit } ) -> SuitRadix = length(?Suits), FaceRadix = length(?Faces), ThisSuit + (ThisFace * SuitRadix) + (ThisBack * (SuitRadix*FaceRadix)). So, if you can find documentation of the maximum range of the three integers in a PID, you can just compose them this way. 2) You can keep a lookup process somewhere, and just dole out integer handles. 3) You can notice that local PIDs already only eat one word, and quit playing translation games, because they're unnecessary. (reference: http://www.erlang.org/doc/efficiency_guide/advanced.html ) The real question you should be asking yourself, in my opinion, is why you're that worried about a few bytes, and why you're trying to represent it as an integer in the first place. In most cases where people say "I need to reduce their size because there are so many they're getting out of control", it's quite common to be able to reduce the count of IDs, rather than the size of their representation. For example, if each of your player processes has a handle to each other player process, spin up a process for a given match instead, and give the player processes a hook to that and nothing else. Bang: 7/8 or so savings on PID space, and probably a significant speed increase despite the extra messaging, since you're going to get so many more correct branch predictions and cache wins. Granted, you probably aren't making a mistake that basic, and I haven't actually looked at your code, but it's an example that's clear enough to get me out of extra explanation. Micro-optimization is almost never the right way to push back machine limits. Consider working on your approach instead. -------------- next part -------------- An HTML attachment was scrubbed... URL: From stonecypher@REDACTED Thu Oct 9 21:08:42 2008 From: stonecypher@REDACTED (John Haugeland) Date: Thu, 9 Oct 2008 13:08:42 -0600 Subject: [erlang-questions] erlang-questions Digest, Vol 17, Issue 49 In-Reply-To: References: Message-ID: <8f24f4b10810091208n56d81cf5ibdb618d44f69c2bc@mail.gmail.com> > > The hint is that your numbers _should_ scale at least linearly with > > the number of elements, > > Shouldn't lookup be O(log n)? For trees, yes. For hashes, no, amortized O(1). Which is, incidentally, why he probably shouldn't use trees. -------------- next part -------------- An HTML attachment was scrubbed... URL: From stonecypher@REDACTED Thu Oct 9 21:03:15 2008 From: stonecypher@REDACTED (John Haugeland) Date: Thu, 9 Oct 2008 13:03:15 -0600 Subject: [erlang-questions] erlang-questions Digest, Vol 17, Issue 45 In-Reply-To: References: Message-ID: <8f24f4b10810091203i6eeb60f5q1b6bdaa483abea79@mail.gmail.com> > I agree that there should be an operation that is > the converse of string:join/2. It's scutil:explode(). See http://scutil.com/ . -------------- next part -------------- An HTML attachment was scrubbed... URL: From erlang-questions_efine@REDACTED Thu Oct 9 21:52:09 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Thu, 9 Oct 2008 15:52:09 -0400 Subject: [erlang-questions] erlang-questions Digest, Vol 17, Issue 45 In-Reply-To: <8f24f4b10810091203i6eeb60f5q1b6bdaa483abea79@mail.gmail.com> References: <8f24f4b10810091203i6eeb60f5q1b6bdaa483abea79@mail.gmail.com> Message-ID: <6c2563b20810091252l199969a3v2d82a5d9f87e0e91@mail.gmail.com> 2008/10/9 John Haugeland > > I agree that there should be an operation that is > > the converse of string:join/2. > > It's scutil:explode(). See http://scutil.com/ . > Maybe I'm just being a bit of an idealist here, but if there is an operation, string:join, I'd really, really, like its inverse operation also to be in the string module, namely, string:split. It's the symmetry. Especially since there's no earthly reason I can see that string:split should be (or have been) omitted. I suppose they could rid of string:join and we could all use scutil:explode (and I presume its inverse, scutil:implode?). But then that's another module/application I need which is not part of the standard release. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From richardc@REDACTED Thu Oct 9 22:08:24 2008 From: richardc@REDACTED (Richard Carlsson) Date: Thu, 09 Oct 2008 22:08:24 +0200 Subject: [erlang-questions] The trouble with measurements In-Reply-To: References: <35FA1D83-B63F-4691-AA81-7129BC3BC5F9@gmail.com> <48EDF66D.9010101@it.uu.se> <48EE096F.6090307@it.uu.se> <48EE2A2D.7000800@it.uu.se> Message-ID: <48EE64B8.8020603@it.uu.se> Joel Reymont wrote: > > On Oct 9, 2008, at 4:58 PM, Richard Carlsson wrote: > >> So why didn't anyone notice the timeout? Well, because of timer:tc(), >> of course, which runs the call within a catch! So, what the timer really >> measured for the lookup loop, was the time for the first gen_server:call >> to time out, namely, five seconds. > > Ouch! It works properly with call instead of cast, though, do I > understand you correctly? Yes, if all the ADD requests are also done with gen_server:call(), the test process cannot run ahead of the server like it does now. /Richard From fig@REDACTED Thu Oct 9 22:13:02 2008 From: fig@REDACTED (Michael FIG) Date: Thu, 9 Oct 2008 14:13:02 -0600 (CST) Subject: [erlang-questions] ODBC truncates DATETIME results In-Reply-To: <20073882.23731223583086148.JavaMail.root@julie.marketel> Message-ID: <29952892.23751223583182465.JavaMail.root@julie.marketel> Hi, I've been using unixodbc in conjunction with tdsodbc and a Microsoft SQL Server 2000 database. With at least Erlang R11B1, I found that datetimes and smalldatetimes were being truncated, so I'd get results that looked like: > odbc:sql_query(O, "SELECT CAST('2008-09-03 14:35:12.234' AS DATETIME)"). {selected,[[]],[{"2008-09-"}]} > odbc:sql_query(O, "SELECT CAST('2008-09-03 14:35:12.234' AS SMALLDATETIME)"). {selected,[[]],[{"2008"}]} Upon further investigation, I found out that the culprit appears to be in odbcserver.c, where the size of the result columns is calculated. The driver combination I am using returns a length of 4 for SMALLDATETIME and 8 for DATETIME, which is inadequate to hold the results that are actually 23 characters in length. The attached patch corrects this issue: > odbc:sql_query(O, "SELECT CAST('2008-09-03 14:35:12.234' AS DATETIME)"). {selected,[[]],[{"2008-09-03 14:35:12.233"}]} > odbc:sql_query(O, "SELECT CAST('2008-09-03 14:35:12.234' AS SMALLDATETIME)"). {selected,[[]],[{"2008-09-03 14:35:00.000"}]} I'm not sure if it this bug still exists in Erlang R12, but I thought I should post this anyway. Hope this helps somebody out there, -- Michael FIG MarkeTel Multi-Line Dialing Systems, Ltd. Phone: (306) 359-6893 ext. 528 -------------- next part -------------- A non-text attachment was scrubbed... Name: erl-11.b.1-odbc.patch Type: application/octet-stream Size: 521 bytes Desc: not available URL: From stonecypher@REDACTED Thu Oct 9 22:14:41 2008 From: stonecypher@REDACTED (John Haugeland) Date: Thu, 9 Oct 2008 14:14:41 -0600 Subject: [erlang-questions] erlang-questions Digest, Vol 17, Issue 45 In-Reply-To: <6c2563b20810091252l199969a3v2d82a5d9f87e0e91@mail.gmail.com> References: <8f24f4b10810091203i6eeb60f5q1b6bdaa483abea79@mail.gmail.com> <6c2563b20810091252l199969a3v2d82a5d9f87e0e91@mail.gmail.com> Message-ID: <8f24f4b10810091314r1586e999n999ffd972068e072@mail.gmail.com> Oh, I just wanted to point out that someone else agreed with you that a round trip matched functional converse was important, and that it was available to you. Besides, there's a ton of fun stuff in that library. If you install it, you'll use it. On Thu, Oct 9, 2008 at 1:52 PM, Edwin Fine wrote: > 2008/10/9 John Haugeland > >> > I agree that there should be an operation that is >> > the converse of string:join/2. >> >> It's scutil:explode(). See http://scutil.com/ . >> > Maybe I'm just being a bit of an idealist here, but if there is an > operation, string:join, I'd really, really, like its inverse operation also > to be in the string module, namely, string:split. It's the symmetry. > Especially since there's no earthly reason I can see that string:split > should be (or have been) omitted. > > I suppose they could rid of string:join and we could all use scutil:explode > (and I presume its inverse, scutil:implode?). But then that's another > module/application I need which is not part of the standard release. > GuaranteedVPS.com - bandwidth commitments and root starting from $12.98/mo -------------- next part -------------- An HTML attachment was scrubbed... URL: From joelr1@REDACTED Thu Oct 9 22:38:14 2008 From: joelr1@REDACTED (Joel Reymont) Date: Thu, 9 Oct 2008 21:38:14 +0100 Subject: [erlang-questions] erlang-questions Digest, Vol 17, Issue 41 In-Reply-To: <8f24f4b10810091131n7590f33aw20ae6da138a7e642@mail.gmail.com> References: <8f24f4b10810091131n7590f33aw20ae6da138a7e642@mail.gmail.com> Message-ID: On Oct 9, 2008, at 7:31 PM, John Haugeland wrote: >> For example, if each of your player processes has a handle to each >> other > player process, spin up a process for a given match instead, and > give the > player processes a hook to that and nothing else. How does this work? Can you elaborate a bit? > Bang: 7/8 or so savings > on PID space, and probably a significant speed increase despite the > extra > messaging, since you're going to get so many more correct branch > predictions > and cache wins. And how do you measure cache wins and branch predictions with Erlang? Thanks, Joel -- wagerlabs.com From oscar@REDACTED Thu Oct 9 22:43:43 2008 From: oscar@REDACTED (=?utf-8?Q?Oscar_Hellstr=C3=B6m?=) Date: Thu, 9 Oct 2008 21:43:43 +0100 (BST) Subject: [erlang-questions] Adding simple process to supervisor? In-Reply-To: <24398926.11601223584825347.JavaMail.root@zimbra> Message-ID: <28655359.11621223585023526.JavaMail.root@zimbra> Hi Bengt, What I usually do is just to spawn a reader process from the gen_server and link to it. Then depending on if the gen_server should die with errors in the reader process or not I sometimes traps exits in the gen_server. Most of the time you want to restart the gen_server to open a new socket if the reader dies anyway. IMHO, there are too many issues with trying to get a process that does blocking calls to exist under a supervisor and this kind of process is typically very simple (read small room for errors) as well. Another approach is to use proc_lib to create a "special process" which uses {active, once} for the socket, to get away from doing blocking calls. ----- Original Message ----- From: "Bengt Kleberg" To: "erlang-questions" Sent: Thursday, 9 October, 2008 12:03:27 AM GMT -08:00 US/Canada Pacific Subject: [erlang-questions] Adding simple process to supervisor? Greetings, I have a gen_server which is supervised according to OTP rules. Now I want to add a simple process that will read from a TCP port and send the incoming data to the gen_server. I could spawn_link this process from the gen_server and restart it if it dies. However, since I have a supervisor it seems more logical to just add the process there, as a rest_for_one. There is the alternative of using a supervisor_bridge, but that seems more complex than using the gen_server. It seems as if I just design my process according to the OTP rules I will not need to use a supervisor_bridge. What are those rules? The only suggestions I have found are: 1 Module:start_link/1 => {ok, Pid} 2 Module:terminate/2 => ok The child specification returned by the init/1 call-back in a supervisor mentions the value for Modules if we have a gen_server, gen_fsm or gen_event. What could be used for a simple process? But how do I add a simple process to the supervisor? It seems overkill to masquerade it as a get_fsm or similar. Since it is not called from erlang it is not a gen_server. Since it does not have state it is not a gen_fsm. No events are handled. bengt _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions -- Oscar Hellstr?m, oscar@REDACTED Phone: +44 (0)798 45 44 773 Mobile: +44 (0)207 65 50 337 Web: http://www.erlang-consulting.com From rvirding@REDACTED Thu Oct 9 23:47:50 2008 From: rvirding@REDACTED (Robert Virding) Date: Thu, 9 Oct 2008 23:47:50 +0200 Subject: [erlang-questions] write the ant simulation in Erlang? In-Reply-To: <859e91e70810082146k3457bd2evc813a51beda59989@mail.gmail.com> References: <859e91e70810081456w244b1c9dh74e108325ae4135c@mail.gmail.com> <7D2420AE-BA6D-4EE4-85DD-CCB6C1723DBE@cs.otago.ac.nz> <859e91e70810082144v52c0998bi140a6116c67cf12a@mail.gmail.com> <859e91e70810082146k3457bd2evc813a51beda59989@mail.gmail.com> Message-ID: <3dbc6d1c0810091447ye7fbc56j9d7ee5f322dd1854@mail.gmail.com> I haven't really checked the Clojure code that closely but it seems like a reasonable problem. Do you know if it "turn based" or do the all the ants just move after their own clocks in a parallel way? A first approximation would be to have one process per ant and one for the world. The only problem would be handling atomic look-at-the-immediate-world-around-me-and-make-a-move. The really difficult bit is displaying it. :-) Robert 2008/10/9 Brian Zhou > Let me try to reverse engineer some kind of spec: > > * On a world of 80x80 cells, there are 49 ants, and 35 scattered cells > with food. > * Initially the ants are in their home, a square from (20, 20) to (26, > 26), facing random directions. > > * An ant can move ahead, turn 45 degree left, or 45 degree right, every > 40ms. > * Ant should not move ahead if there is another ant in the ahead cell. > * Whenever ant make a move, it leaves a pheromone trail by increment > pheromone amount by 1.0 in the previous cell. > > * For an ant without food, > ** If ahead is not home, and there is food ahead, move ahead, take > food and turn around; > ** Among cells that are ahead, ahead-left (45 degree), ahead-right (45 > degree), turn/move to the one with the most (if (contain-food?) 1 0) + > pheromone score, if all equal, turn/move randomly; > > * For an ant with food, > ** If ahead is home, move ahead, drop food and turn around; > ** Among cells that are ahead, ahead-left (45 degree), ahead-right (45 > degree), turn/move to the one with the most (if (at-home?) 1 0) + > pheromone score, if all equal, turn/move randomly; > > * Every 1 second, the pheromone in all cells evaporate to 99% of the > previous amount; > > * If a graphical animation is provided, the animation is refreshed every > 100ms. > > * Hard-coded numbers are used above to make description easier. They > are actually adjustable. > > ;dimensions of square world > (def dim 80) > ;number of ants = nants-sqrt^2 > (def nants-sqrt 7) > ;number of places with food > (def food-places 35) > ;range of amount of food at a place > (def food-range 100) > ;evaporation rate > (def evap-rate 0.99) > > (def animation-sleep-ms 100) > (def ant-sleep-ms 40) > (def evap-sleep-ms 1000) > > Anyone feel free to correct me if my understanding is not right. > > -Brian > > On Wed, Oct 8, 2008 at 7:46 PM, Richard O'Keefe wrote: > > Bearing in mind that it really isn't practical > > for someone in NZ to watch videos over the international net, > > can you tell me what the ant simulation problem is? > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rvirding@REDACTED Thu Oct 9 23:48:42 2008 From: rvirding@REDACTED (Robert Virding) Date: Thu, 9 Oct 2008 23:48:42 +0200 Subject: [erlang-questions] Article on Erlang in ACM Queue In-Reply-To: <200810090600.m9960KTF054979@krumkake.jetcafe.org> References: <48ED943A.80801@berabera.info> <200810090600.m9960KTF054979@krumkake.jetcafe.org> Message-ID: <3dbc6d1c0810091448v60bdd5c1of474f708fc1638be@mail.gmail.com> I agree with Romain, good article. Robert 2008/10/9 Jim Larson > In message <48ED943A.80801@REDACTED> you write: > >Jim Larson has written an article entitled "Erlang for Concurrent > >Programming", published in the latest ACM Queue: > >http://mags.acm.org/queue/200809/ > > Thanks to Romain for some great feedback on an early draft! > > Jim > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From stonecypher@REDACTED Thu Oct 9 23:53:31 2008 From: stonecypher@REDACTED (John Haugeland) Date: Thu, 9 Oct 2008 15:53:31 -0600 Subject: [erlang-questions] erlang-questions Digest, Vol 17, Issue 41 In-Reply-To: References: <8f24f4b10810091131n7590f33aw20ae6da138a7e642@mail.gmail.com> Message-ID: <8f24f4b10810091453l610b3528w6145a42948aad9b@mail.gmail.com> > > For example, if each of your player processes has a handle to each other >>> >> player process, spin up a process for a given match instead, and give the >> player processes a hook to that and nothing else. >> > > How does this work? Can you elaborate a bit? Every mailing list needs ascii art! If it used to be A---B /|\ /|\ C-+-*-+-D (plus connections I can't draw \|/ \|/ from A-D, B-C, D-E, C-F) E---F Then change it to Z /|\ // \\ / | | \ /\ | | /\ A B C D E F Instead of (6*5)=30 pids, you're now tracking (6*1)+6=12 pids. The savings goes up the larger the games get, because in the old fully connected network you need N*(N-1) connections per game, whereas in the new network you need 2N connections per game, and exponential vs linear growth, and rada rada rada. > > Bang: 7/8 or so savings >> on PID space, and probably a significant speed increase despite the extra >> messaging, since you're going to get so many more correct branch >> predictions >> and cache wins. >> > > And how do you measure cache wins and branch predictions with Erlang? Ancient wisdom. When you've been programming 20+ years, you can smell what's going to work and what isn't. And, I know, for someone who says "intuition is worthless, profile it" as much as I do, that's kind of hypocritical in the way that the ocean is kind of wet, but I haven't really taken the time to learn Erlang's profiling situation yet, so it's the best I've got. But, I mean, when you drop the size of a block of data by 80-85%, you're just going to keep a lot more of it in cache, and when the data has stronger locality, it's more likely to get a good branch prediction. That's just the nature of modern branch prediction algorithms. There's a fascinating (if somewhat poorly written) discussion of these issues in the original Judy Tree papers by that guy from Hewlett Packard. - John -------------- next part -------------- An HTML attachment was scrubbed... URL: From stonecypher@REDACTED Fri Oct 10 00:29:35 2008 From: stonecypher@REDACTED (John Haugeland) Date: Thu, 9 Oct 2008 16:29:35 -0600 Subject: [erlang-questions] erlang-questions Digest, Vol 17, Issue 41 In-Reply-To: <20081009222447.GA19797@contorpis.lisalinda.com> References: <8f24f4b10810091131n7590f33aw20ae6da138a7e642@mail.gmail.com> <8f24f4b10810091453l610b3528w6145a42948aad9b@mail.gmail.com> <20081009222447.GA19797@contorpis.lisalinda.com> Message-ID: <8f24f4b10810091529w376de405xb66c2cf16642364e@mail.gmail.com> > > > ... in the old fully connected network > > you need N*(N-1) connections per game, whereas in the new network you > need > > 2N connections per game, and exponential vs linear growth, and ... > > N*(N-1) isn't exponential. > > Matt I'd check that math, if I were you. Try actually plotting some values, then ask yourself what the difference is between n**2, n*n, and n*(n-1). You might as well suggest that O(a*b) is linear. If its dominating term governing growth rate is a non-1 exponent, as it is in this case, it's exponential growth. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gbulmer@REDACTED Fri Oct 10 01:03:44 2008 From: gbulmer@REDACTED (G Bulmer) Date: Fri, 10 Oct 2008 00:03:44 +0100 Subject: [erlang-questions] Interesting: "Squeak VM adapted to run on Tilera" Message-ID: Folks, I thought some might be interested in this ... Sam S. Adams and David Ungar (Self) have adapted the Squeak VM to run on 56 of the 64 cores on the Tilera64 processor family. "Exploring Massively Multicore Programming Models: Introducing the Renaissance ER Project" http://domino.watson.ibm.com/comm/research.nsf/pages/r.plansoft.seminars.html Mentioned by Sam Adams here: http://wiki.squeak.org/squeak/1107 G Bulmer From matthias@REDACTED Fri Oct 10 00:24:47 2008 From: matthias@REDACTED (Matthias Lang) Date: Fri, 10 Oct 2008 00:24:47 +0200 Subject: [erlang-questions] erlang-questions Digest, Vol 17, Issue 41 In-Reply-To: <8f24f4b10810091453l610b3528w6145a42948aad9b@mail.gmail.com> References: <8f24f4b10810091131n7590f33aw20ae6da138a7e642@mail.gmail.com> <8f24f4b10810091453l610b3528w6145a42948aad9b@mail.gmail.com> Message-ID: <20081009222447.GA19797@contorpis.lisalinda.com> On Thursday, October 09, John Haugeland wrote: > ... in the old fully connected network > you need N*(N-1) connections per game, whereas in the new network you need > 2N connections per game, and exponential vs linear growth, and ... N*(N-1) isn't exponential. Matt > Ancient wisdom. When you've been programming 20+ years, you smell From ok@REDACTED Fri Oct 10 01:21:44 2008 From: ok@REDACTED (Richard O'Keefe) Date: Fri, 10 Oct 2008 12:21:44 +1300 Subject: [erlang-questions] [enhancement] string:split/2 In-Reply-To: <6c2563b20810082343j255330ccp396cf4f8da0d2fe4@mail.gmail.com> References: <6c2563b20810081642r2fbd1f14w8e3f7a5a2b71bcc4@mail.gmail.com> <6c2563b20810082343j255330ccp396cf4f8da0d2fe4@mail.gmail.com> Message-ID: <330AAA17-394B-44D0-9E09-7CEE4B6BF9C9@cs.otago.ac.nz> On 9 Oct 2008, at 7:43 pm, Edwin Fine wrote: > I'm assuming you are providing this code as an "executable > requirements document." I was rather hoping that it could be > implemented as a BIF. > I'll have to study your code below so I can learn some "fast and > fancy" Erlang! Well, no. I was providing the code as a first draft of what could be dropped into string.erl. I see no reason why it should be a BIF, if by that you mean something implemented in C. If the performance of unjoining should be a bottleneck in some program, after getting over my astonishment I would recommend unrolling. For example, > unjoin0([C|Cs]) -> > [[C] | unjoin0(Cs)]; > unjoin0([]) -> > []. would become unjoin0([A,B,C,D|S]) -> [[A],[B],[C],[D] | unjoin0(S); unjoin0([A,B,C]) -> [[A],[B],[C]]; unjoin0([A,B]) -> [[A],[B]]; unjoin0([A]) -> [[A]]; unjoin0([]) -> []. That plus HiPE can often do surprisingly well. But this is something to do AFTER measurement! From ok@REDACTED Fri Oct 10 01:51:07 2008 From: ok@REDACTED (Richard O'Keefe) Date: Fri, 10 Oct 2008 12:51:07 +1300 Subject: [erlang-questions] erlang-questions Digest, Vol 17, Issue 45 In-Reply-To: <8f24f4b10810091314r1586e999n999ffd972068e072@mail.gmail.com> References: <8f24f4b10810091203i6eeb60f5q1b6bdaa483abea79@mail.gmail.com> <6c2563b20810091252l199969a3v2d82a5d9f87e0e91@mail.gmail.com> <8f24f4b10810091314r1586e999n999ffd972068e072@mail.gmail.com> Message-ID: <61EC12E1-6393-4427-846D-8B5DDC12B4D3@cs.otago.ac.nz> I note that "explode" has historically meant "to break a string (or equivalent) into a list of its single-character elements", which is not all that split/unjoin does. Some of the names in the 'lists' module were copied from Haskell. It's a pity that Haskell's "splitAt" was copied as "split". I dare say Ruby and PHP (?) got the name 'split' from Perl, which got it from 'AWK', where a *regular expression* controls the splitting. This is the other reason for preferring to call the operation 'unjoin': anyone familiar with "split" in AWK, Perl, &c will expect string:split/2 to take a regular expression parameter, and this one DOESN'T. There is, or should be, a regular pattern words <-> unwords lines <-> unlines unjoin <-> join Oh well, sort of regular... When I clicked on the Documentation link on the scutil page, I got to some sort of Wiki thingie, with no documentation that I could see. From ok@REDACTED Fri Oct 10 01:54:23 2008 From: ok@REDACTED (Richard O'Keefe) Date: Fri, 10 Oct 2008 12:54:23 +1300 Subject: [erlang-questions] write the ant simulation in Erlang? In-Reply-To: <3dbc6d1c0810091447ye7fbc56j9d7ee5f322dd1854@mail.gmail.com> References: <859e91e70810081456w244b1c9dh74e108325ae4135c@mail.gmail.com> <7D2420AE-BA6D-4EE4-85DD-CCB6C1723DBE@cs.otago.ac.nz> <859e91e70810082144v52c0998bi140a6116c67cf12a@mail.gmail.com> <859e91e70810082146k3457bd2evc813a51beda59989@mail.gmail.com> <3dbc6d1c0810091447ye7fbc56j9d7ee5f322dd1854@mail.gmail.com> Message-ID: On 10 Oct 2008, at 10:47 am, Robert Virding wrote: > A first approximation would be to have one process per ant and one > for the world. The only problem would be handling atomic look-at-the- > immediate-world-around-me-and-make-a-move. Thinking idly about this last night, I wondered whether the look at the world bit *should* be atomic. Real ants don't lock the real world, and while an ant is looking at one square, something _could_ move into a square it can't see. I was wondering about dividing the world into patches. From jeffm@REDACTED Fri Oct 10 02:51:38 2008 From: jeffm@REDACTED (jm) Date: Fri, 10 Oct 2008 11:51:38 +1100 Subject: [erlang-questions] write the ant simulation in Erlang? In-Reply-To: References: <859e91e70810081456w244b1c9dh74e108325ae4135c@mail.gmail.com> <7D2420AE-BA6D-4EE4-85DD-CCB6C1723DBE@cs.otago.ac.nz> <859e91e70810082144v52c0998bi140a6116c67cf12a@mail.gmail.com> <859e91e70810082146k3457bd2evc813a51beda59989@mail.gmail.com> <3dbc6d1c0810091447ye7fbc56j9d7ee5f322dd1854@mail.gmail.com> Message-ID: <48EEA71A.8010104@ghostgun.com> Richard O'Keefe wrote: > I was wondering about dividing the world into patches. > > This was my first reaction when seeing a description of the problem. To create a process for each square and then use a naming convention for the processes, eg world_x_y where x, y are the co-ordinates of the square. For an 80 x 80 world this would be 6400 processes just for the world plus 49 ant processes which I thought might be a bit of an over kill. I was also concerned that the process name look up may be a bottle neck. The API for the square processes might be something along the lines of * look return the status of the square. Presents of ant, food, etc. * take move to this tile. Returns success or failure. The ant would look at the square to see if it was empty and if there was any food. If the square was chosen as the next location the ant would attempt to move there by attempting to take the square which could fail if another ant had taken the square in the interim. In which case it would look for a new square, otherwise it would up date its own status to reflect the new location. Jeff. From rvirding@REDACTED Fri Oct 10 02:57:07 2008 From: rvirding@REDACTED (Robert Virding) Date: Fri, 10 Oct 2008 02:57:07 +0200 Subject: [erlang-questions] write the ant simulation in Erlang? In-Reply-To: References: <859e91e70810081456w244b1c9dh74e108325ae4135c@mail.gmail.com> <7D2420AE-BA6D-4EE4-85DD-CCB6C1723DBE@cs.otago.ac.nz> <859e91e70810082144v52c0998bi140a6116c67cf12a@mail.gmail.com> <859e91e70810082146k3457bd2evc813a51beda59989@mail.gmail.com> <3dbc6d1c0810091447ye7fbc56j9d7ee5f322dd1854@mail.gmail.com> Message-ID: <3dbc6d1c0810091757y7acee41r63464976c1eee0ba@mail.gmail.com> 2008/10/10 Richard O'Keefe > > On 10 Oct 2008, at 10:47 am, Robert Virding wrote: > >> A first approximation would be to have one process per ant and one for the >> world. The only problem would be handling atomic >> look-at-the-immediate-world-around-me-and-make-a-move. >> > > Thinking idly about this last night, I wondered whether > the look at the world bit *should* be atomic. Real ants > don't lock the real world, and while an ant is looking at > one square, something _could_ move into a square it can't > see. This was to get around the problem of checking if a cell was free before moving into and then finding the cell has been taken. The immediate world is one cell left, center, right, so it is very immediate. The "spec" stated only one ant per cell. Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: From ok@REDACTED Fri Oct 10 03:08:29 2008 From: ok@REDACTED (Richard O'Keefe) Date: Fri, 10 Oct 2008 14:08:29 +1300 Subject: [erlang-questions] write the ant simulation in Erlang? In-Reply-To: <3dbc6d1c0810091757y7acee41r63464976c1eee0ba@mail.gmail.com> References: <859e91e70810081456w244b1c9dh74e108325ae4135c@mail.gmail.com> <7D2420AE-BA6D-4EE4-85DD-CCB6C1723DBE@cs.otago.ac.nz> <859e91e70810082144v52c0998bi140a6116c67cf12a@mail.gmail.com> <859e91e70810082146k3457bd2evc813a51beda59989@mail.gmail.com> <3dbc6d1c0810091447ye7fbc56j9d7ee5f322dd1854@mail.gmail.com> <3dbc6d1c0810091757y7acee41r63464976c1eee0ba@mail.gmail.com> Message-ID: <07630C85-CE8E-475B-8E01-B44EF3FFFC09@cs.otago.ac.nz> On 10 Oct 2008, at 1:57 pm, Robert Virding wrote: > This was to get around the problem of checking if a cell was free > before moving into and then finding the cell has been taken. That was understood. > The immediate world is one cell left, center, right, so it is very > immediate. The "spec" stated only one ant per cell. It *happened* to be very immediate. What about a protocol like this: check each relevant square choose where to go ask the world to move you if it refuses, try again with locking. The old "locks are usually not contended" idea. I think one process per cell of the world may make sense. From corticalcomputer@REDACTED Fri Oct 10 03:08:36 2008 From: corticalcomputer@REDACTED (G.S.) Date: Thu, 9 Oct 2008 18:08:36 -0700 Subject: [erlang-questions] Are there any companies that hire Erlangers? Message-ID: <2a67d3ff0810091808x2c4be63dpbe1ef8f79654593c@mail.gmail.com> Hello All, I have yet to find a company that programs using Erlang, and I'd really like to work for one. Am I looking in the wrong place, do any of you know a company that uses Erlang as the main language? -Gene -------------- next part -------------- An HTML attachment was scrubbed... URL: From dbarker@REDACTED Fri Oct 10 02:18:49 2008 From: dbarker@REDACTED (Deryk Barker) Date: Thu, 09 Oct 2008 17:18:49 -0700 Subject: [erlang-questions] erlang-questions Digest, Vol 17, Issue 41 In-Reply-To: <8f24f4b10810091529w376de405xb66c2cf16642364e@mail.gmail.com> References: <8f24f4b10810091131n7590f33aw20ae6da138a7e642@mail.gmail.com> <8f24f4b10810091453l610b3528w6145a42948aad9b@mail.gmail.com> <20081009222447.GA19797@contorpis.lisalinda.com> <8f24f4b10810091529w376de405xb66c2cf16642364e@mail.gmail.com> Message-ID: <48EE9F69.6020004@camosun.bc.ca> John Haugeland wrote: > > > ... in the old fully connected network > > you need N*(N-1) connections per game, whereas in the new > network you need > > 2N connections per game, and exponential vs linear growth, and ... > > N*(N-1) isn't exponential. > > Matt > > > I'd check that math, if I were you. Try actually plotting some > values, then ask yourself what the difference is between n**2, n*n, > and n*(n-1). You might as well suggest that O(a*b) is linear. > > If its dominating term governing growth rate is a non-1 exponent, as > it is in this case, it's exponential growth. Surely it's polynomial? 2**N would be exponential. -- |Deryk Barker, Computer Science Dept. | Music does not have to be understood| |Camosun College, Victoria, BC, Canada| It has to be listened to. | |email: dbarker@REDACTED | | |phone: +1 250 370 4452 | Hermann Scherchen. | From ok@REDACTED Fri Oct 10 03:26:42 2008 From: ok@REDACTED (Richard O'Keefe) Date: Fri, 10 Oct 2008 14:26:42 +1300 Subject: [erlang-questions] write the ant simulation in Erlang? In-Reply-To: <48EEA71A.8010104@ghostgun.com> References: <859e91e70810081456w244b1c9dh74e108325ae4135c@mail.gmail.com> <7D2420AE-BA6D-4EE4-85DD-CCB6C1723DBE@cs.otago.ac.nz> <859e91e70810082144v52c0998bi140a6116c67cf12a@mail.gmail.com> <859e91e70810082146k3457bd2evc813a51beda59989@mail.gmail.com> <3dbc6d1c0810091447ye7fbc56j9d7ee5f322dd1854@mail.gmail.com> <48EEA71A.8010104@ghostgun.com> Message-ID: On 10 Oct 2008, at 1:51 pm, jm wrote: > This was my first reaction when seeing a description of the problem. > To > create a process for each square and then use a naming convention for > the processes, eg world_x_y where x, y are the co-ordinates of the > square. For an 80 x 80 world this would be 6400 processes just for the > world plus 49 ant processes which I thought might be a bit of an over > kill. I was also concerned that the process name look up may be a > bottle > neck. First, I was originally talking about dividing the world up into *patches*, not *cells*. In an 80x80 world, patches might be 10x10, which is only 64 patches. Second, why on earth would you *name* the patch processes? Let's now switch to cell processes, not patch processes. A cell needs to know its neighbours. element_number(nw) -> 1; element_number(n) -> 2; element_number(ne) -> 3; element_number(e) -> 4; element_number(se) -> 5; element_number(s) -> 6; element_number(sw) -> 7; element_number(w) -> 8. cell() -> cell_start({0,0,0,0,0,0,0,0}). cell_start(Neighbours) -> receive go -> cell_loop(Neighbours, 0, 0, no_ant) ; {D,N} -> cell_start(setelement( element_number(D), Neighbours, N)) end. cell_loop(Neighbours, Pheromone, Food, Ant) -> .... startup() -> create an 80 x 80 array of processes all running cell/0 using spawn_link set up all the neighbour links send each cell a !go message Something along those lines. Processes normally shouldn't *have* names, and in this problem there certainly doesn't seem to be any reason for any process to have a name, so process name lookup can't be a bottleneck. Moving is a little tricky because we need to change the state of two cells (if doing cells) or possibly two patches (if doing patches). From erlang-questions_efine@REDACTED Fri Oct 10 04:11:04 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Thu, 9 Oct 2008 22:11:04 -0400 Subject: [erlang-questions] erlang-questions Digest, Vol 17, Issue 45 In-Reply-To: <61EC12E1-6393-4427-846D-8B5DDC12B4D3@cs.otago.ac.nz> References: <8f24f4b10810091203i6eeb60f5q1b6bdaa483abea79@mail.gmail.com> <6c2563b20810091252l199969a3v2d82a5d9f87e0e91@mail.gmail.com> <8f24f4b10810091314r1586e999n999ffd972068e072@mail.gmail.com> <61EC12E1-6393-4427-846D-8B5DDC12B4D3@cs.otago.ac.nz> Message-ID: <6c2563b20810091911j581553d9s1f7bcc766620c48c@mail.gmail.com> On Thu, Oct 9, 2008 at 7:51 PM, Richard O'Keefe wrote: > I note that "explode" has historically meant > "to break a string (or equivalent) into a list of its > single-character elements", > which is not all that split/unjoin does. > > Some of the names in the 'lists' module were copied > from Haskell. It's a pity that Haskell's "splitAt" > was copied as "split". > > I dare say Ruby and PHP (?) got the name 'split' > from Perl, which got it from 'AWK', where a > *regular expression* controls the splitting. I am sure they did. > > This is the other reason for preferring to call the > operation 'unjoin': anyone familiar with "split" in > AWK, Perl, &c will expect string:split/2 to take a > regular expression parameter, and this one DOESN'T. Ok, then to preserve the Principle Of Least Astonishment, let string:split accept a regular expression, which is just a string with special RE operators. If the string contains no RE operators, use an optimized special case of split (like the one you wrote) that does not use an RE engine. Get the best of both worlds. > There is, or should be, a regular pattern > words <-> unwords > lines <-> unlines > unjoin <-> join > Oh well, sort of regular... > Sorry, and no offense meant, but that's really horribly ugly. Reminds me of that sentence, "A not unblack dog chased a not unbrown rabbit across a not ungreen field." Should the opposite of down then be "undown"? Languages (well, I can vouch for two, anyway) contain many complementary words that are not syntactically constructable by adding or removing "un-". Like split and join, for example. Hard and soft. Big and small. Break and mend. Wake and sleep. > When I clicked on the Documentation link on the scutil page, > I got to some sort of Wiki thingie, with no documentation > that I could see. > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From erlang-questions_efine@REDACTED Fri Oct 10 04:32:33 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Thu, 9 Oct 2008 22:32:33 -0400 Subject: [erlang-questions] [enhancement] string:split/2 In-Reply-To: <330AAA17-394B-44D0-9E09-7CEE4B6BF9C9@cs.otago.ac.nz> References: <6c2563b20810081642r2fbd1f14w8e3f7a5a2b71bcc4@mail.gmail.com> <6c2563b20810082343j255330ccp396cf4f8da0d2fe4@mail.gmail.com> <330AAA17-394B-44D0-9E09-7CEE4B6BF9C9@cs.otago.ac.nz> Message-ID: <6c2563b20810091932x245481ew538675b5526e8db3@mail.gmail.com> On Thu, Oct 9, 2008 at 7:21 PM, Richard O'Keefe wrote: > > On 9 Oct 2008, at 7:43 pm, Edwin Fine wrote: > >> I'm assuming you are providing this code as an "executable requirements >> document." I was rather hoping that it could be implemented as a BIF. >> I'll have to study your code below so I can learn some "fast and fancy" >> Erlang! >> > > Well, no. I was providing the code as a first draft of what > could be dropped into string.erl. I see no reason why it should > be a BIF, if by that you mean something implemented in C. Yes, that is what I meant. > > If the performance of unjoining should be a bottleneck in some My background and experience has led me to believe that primitive operations, or functions that are likely to be heavily used, should be implemented in a low-level language like C, and not in the higher-level language. I consider string:split to be something that will be heavily used in text-processing applications (which will also become heavily used, I predict). Since string operations really need to be efficient, I wrongly assumed that the string operations were written in C and that the equivalent Erlang code would not be nearly as efficient. > program, after getting over my astonishment I would recommend > unrolling. For example, > > unjoin0([C|Cs]) -> >> [[C] | unjoin0(Cs)]; >> unjoin0([]) -> >> []. >> > > would become > > unjoin0([A,B,C,D|S]) -> [[A],[B],[C],[D] | unjoin0(S); > unjoin0([A,B,C]) -> [[A],[B],[C]]; > unjoin0([A,B]) -> [[A],[B]]; > unjoin0([A]) -> [[A]]; > unjoin0([]) -> []. > > That plus HiPE can often do surprisingly well. I'd rather ensure that the function is implemented efficiently to start off with, and not *require* HiPE to be used to get performance. One of these nights when I have some spare time, I am going to try your code out (with and without HiPE) against a 'C' or C++ version of split and join so that I can have some hard data to tell for sure one way or the other. This is how I see it: even given the increasingly fast computer architectures of today, one should do one's best not to waste processor time when performance is desired. I have seen users of interpreted, byte-code interpreted, and threaded-interpreted languages implement computationally expensive, heavily used functions in the language instead of in a low-level C library. In almost all cases where the code was not I/O bound, there was a significant penalty for writing such functions. Rewriting those functions in C/C++ often gave one or two orders of magnitude improvement. I know that the overall algorithm can make a huge difference, and that we should not waste our time with premature optimization, but at the same time we should not waste CPU time with belated pessimization. If we can predict based on experience that something (a) is likely to be heavily used and (b) will be more efficient in a lower-level language then we should implement it in said language. All the little inefficiencies can add up into a steaming great system-wide inefficiency. The death of a thousand cuts. Now, that having been said, I have not devoted time (yet) to studying the relative efficiency of Erlang-implemented operations compared to C code. Obviously in a large-scale sense, Erlang is generally efficient enough given the uses to which it has been put. On the gripping hand, the uses to which Erlang has been put are going to push its envelope as it gains more traction. It's going to be used in many more Web-related applications, which means *inter alia* much more text processing involving fiddling around with strings (excuse the unintended pun). Fiddling with strings can and does kill systems that are not designed to do that. Here's the old war story ploy. I once ported a C++ application to an IBM mainframe - which had (gasp!) a C++ compiler - and saw the mainframe get absolutely *caned* by my laptop performance-wise in many cases. Investigation at that time revealed that although the mainframe wiped out my laptop in terms of I/O speed and bandwidth, my laptop just smoked the IBM when it came to what goes on in the Web: dynamic string processing and lots of memory allocations and deallocations. IBM, seeing the writing on the wall, modified its hardware architecture, IIRC by adding special string opcodes, and improved its runtime libraries, to support more efficient string-processing and better dynamic memory handling. Now Erlang has been known to present challenges when it comes to string processing (and pattern matching and file I/O - see the WideFinder project) if the unwary don't take special steps like using binaries for efficiency, and keeping as much as possible in iolists instead of having everything flattened. We all know that Erlang was originally intended for soft real-time type applications. The way things go is that as a language proves its merits, and becomes more and more in demand because (in Erlang's case) it has a reputation for creating highly reliable and available systems, people will start pushing the envelope of its original design parameters. Reading the history of Awk is interesting in this regard; it was put to uses which the authors never dreamed of (like implementing a database - horror). Demands came in for more and better library functions. I predict the same will happen with Erlang, if it is not already happening. It is well to say that one shouldn't use one single language to do everything (and I agree with that caution), but in my experience, software managers don't like having too many languages floating about because of the recruitment, maintenance and training burden. Many developers are not as gifted as the readers of this list and find it difficult to hop between different languages. This all creates a tendency to use the primary language for as many things as possible (the old hammer and nails analogy), even if it wasn't designed for that. It is therefore probably a good idea that we don't pessimize Erlang by writing fundamental code in Erlang that arguably should be implemented as 'C' BIFs. And I am sure there will be argument :) But this is something to do AFTER measurement! > Ideally, yes, and then again, maybe not, if we strongly suspect that it's going to bite us later NOT to do it now. Here's the problem: like I wrote earlier about the death of a thousand cuts, what if there isn't a few big bottlenecks? What if the system is slow simply because it is bloated from too many unnecessary opcodes being executed in a fairly distributed pattern? Like John Haugeland (sp?) wrote earlier, sometimes 20+ years of programming experience gives one an intuitive idea regarding performance. Every little bit counts (excuse the pun). I am just generally saying that if one doesn't watch out, the system gradually bloats with new high-level code and then it's not so performant anymore. Now I will duck into the flame-proof bomb shelter. -------------- next part -------------- An HTML attachment was scrubbed... URL: From erlang-questions_efine@REDACTED Fri Oct 10 04:37:27 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Thu, 9 Oct 2008 22:37:27 -0400 Subject: [erlang-questions] Are there any companies that hire Erlangers? In-Reply-To: <2a67d3ff0810091808x2c4be63dpbe1ef8f79654593c@mail.gmail.com> References: <2a67d3ff0810091808x2c4be63dpbe1ef8f79654593c@mail.gmail.com> Message-ID: <6c2563b20810091937u2b411cean65d972caa4d60bd9@mail.gmail.com> Not to be funny, but in which country? I mean, where are you looking? In the U.K for example, I think I know of a company or two that uses primarily Erlang (Erlang Training and Consulting is one, and I think LShift is another - http://www.lshift.net/recruitment). 2008/10/9 G.S. > Hello All, > > I have yet to find a company that programs using Erlang, and I'd really > like to work for one. Am I looking in the wrong place, do any of you know a > company that uses Erlang as the main language? > > -Gene > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jeffm@REDACTED Fri Oct 10 04:54:46 2008 From: jeffm@REDACTED (jm) Date: Fri, 10 Oct 2008 13:54:46 +1100 Subject: [erlang-questions] write the ant simulation in Erlang? In-Reply-To: References: <859e91e70810081456w244b1c9dh74e108325ae4135c@mail.gmail.com> <7D2420AE-BA6D-4EE4-85DD-CCB6C1723DBE@cs.otago.ac.nz> <859e91e70810082144v52c0998bi140a6116c67cf12a@mail.gmail.com> <859e91e70810082146k3457bd2evc813a51beda59989@mail.gmail.com> <3dbc6d1c0810091447ye7fbc56j9d7ee5f322dd1854@mail.gmail.com> <48EEA71A.8010104@ghostgun.com> Message-ID: <48EEC3F6.8060101@ghostgun.com> Richard O'Keefe wrote: > > On 10 Oct 2008, at 1:51 pm, jm wrote: >> This was my first reaction when seeing a description of the problem. Read the first sentence. I was not stating it was a good idea merely sketching out an idea between doing some work. There are obviously some problems with the approach taken, but I think using a process per square (cell) or a subset of squares (patch) is a more natural approach for erlang. As this approach mantains the atomic nature of the squares and scales more easily as the cores/processes grow. > First, I was originally talking about dividing the world > up into *patches*, not *cells*. In an 80x80 world, > patches might be 10x10, which is only 64 patches. > > Second, why on earth would you *name* the patch processes? Just a simple way to find the correct process in a first cut and easier to see what is going on. You could also prime each ant with knowledge of which processes represent each square(s) or each patch/cell could contain this knowledge which is what I think your thinking. > > startup() -> > create an 80 x 80 array of processes > all running cell/0 using spawn_link > set up all the neighbour links > send each cell a !go message > > Moving is a little tricky because we need to change the > state of two cells (if doing cells) or possibly two > patches (if doing patches). Can you live with an ant occupying two squares at once? Then enter the new location first before leaving the old location. Jeff. From rec@REDACTED Fri Oct 10 05:17:16 2008 From: rec@REDACTED (Roger Critchlow) Date: Thu, 9 Oct 2008 21:17:16 -0600 Subject: [erlang-questions] write the ant simulation in Erlang? In-Reply-To: <48EEC3F6.8060101@ghostgun.com> References: <859e91e70810081456w244b1c9dh74e108325ae4135c@mail.gmail.com> <7D2420AE-BA6D-4EE4-85DD-CCB6C1723DBE@cs.otago.ac.nz> <859e91e70810082144v52c0998bi140a6116c67cf12a@mail.gmail.com> <859e91e70810082146k3457bd2evc813a51beda59989@mail.gmail.com> <3dbc6d1c0810091447ye7fbc56j9d7ee5f322dd1854@mail.gmail.com> <48EEA71A.8010104@ghostgun.com> <48EEC3F6.8060101@ghostgun.com> Message-ID: <66d1c98f0810092017n5610b482h9517935400aab383@mail.gmail.com> On Thu, Oct 9, 2008 at 8:54 PM, jm wrote: > > > > Moving is a little tricky because we need to change the > > state of two cells (if doing cells) or possibly two > > patches (if doing patches). > Can you live with an ant occupying two squares at once? Then enter the > new location first before leaving the old location. > That would break the transactional consistency that the example has in Clojure: You have a thing you want to move from one place to another, you don't want it to be in both places, and you don't want it to be no place. It would also break the graphical display of the simulation if the number of ants fluctuated from frame to frame. -- rec -- -------------- next part -------------- An HTML attachment was scrubbed... URL: From jeffm@REDACTED Fri Oct 10 05:30:52 2008 From: jeffm@REDACTED (jm) Date: Fri, 10 Oct 2008 14:30:52 +1100 Subject: [erlang-questions] write the ant simulation in Erlang? In-Reply-To: <66d1c98f0810092017n5610b482h9517935400aab383@mail.gmail.com> References: <859e91e70810081456w244b1c9dh74e108325ae4135c@mail.gmail.com> <7D2420AE-BA6D-4EE4-85DD-CCB6C1723DBE@cs.otago.ac.nz> <859e91e70810082144v52c0998bi140a6116c67cf12a@mail.gmail.com> <859e91e70810082146k3457bd2evc813a51beda59989@mail.gmail.com> <3dbc6d1c0810091447ye7fbc56j9d7ee5f322dd1854@mail.gmail.com> <48EEA71A.8010104@ghostgun.com> <48EEC3F6.8060101@ghostgun.com> <66d1c98f0810092017n5610b482h9517935400aab383@mail.gmail.com> Message-ID: <48EECC6C.1080808@ghostgun.com> Roger Critchlow wrote: > > That would break the transactional consistency that the example has in > Clojure: You have a thing you want to move from one place to another, > you don't want it to be in both places, and you don't want it to be no > place. > > It would also break the graphical display of the simulation if the > number of ants fluctuated from frame to frame. > What about having more states that just occupied and empty (with respect to ants)? Just thinking aloud, how about one of empty, moving, and occupied? No, that doesn't work either. How about asking the current square to move the ant to the next square? I don't think this works either though. There must be something wrong with the way I'm looking at this. Oh well, back to the day job. Jeff. From ok@REDACTED Fri Oct 10 05:53:41 2008 From: ok@REDACTED (Richard O'Keefe) Date: Fri, 10 Oct 2008 16:53:41 +1300 Subject: [erlang-questions] erlang-questions Digest, Vol 17, Issue 45 In-Reply-To: <6c2563b20810091911j581553d9s1f7bcc766620c48c@mail.gmail.com> References: <8f24f4b10810091203i6eeb60f5q1b6bdaa483abea79@mail.gmail.com> <6c2563b20810091252l199969a3v2d82a5d9f87e0e91@mail.gmail.com> <8f24f4b10810091314r1586e999n999ffd972068e072@mail.gmail.com> <61EC12E1-6393-4427-846D-8B5DDC12B4D3@cs.otago.ac.nz> <6c2563b20810091911j581553d9s1f7bcc766620c48c@mail.gmail.com> Message-ID: On 10 Oct 2008, at 3:11 pm, Edwin Fine wrote: > Ok, then to preserve the Principle Of Least Astonishment, let > string:split accept a regular expression, which is just a string > with special RE operators. If the string contains no RE operators, > use an optimized special case of split (like the one you wrote) that > does not use an RE engine. Get the best of both worlds. No, that *violates* the principle of least astonishment, Big Time! First, absolutely nothing else whatever in the 'string' module has anything to do with regular expressions. This would be highly exceptional and very confusing. Second, something that splits strings using regular expressions would be expected in the 'regexp' module, not the 'string' module. In fact, regexp:split/2 already exists. It would be rather astonishing to replicate this in the wrong module. Third, if there were a string:split/2 that used regular expressions, that would make it very incompatible with string:join/2, which doesn't. I thought we were wanting string:join(string:split(String, Sep), Sep) to give back Sep. In short, if you want something called 'split' that preserves the principle of least astonishment, use regexp:split/2. If you want an opposite of string:join/2, DON'T make it use regular expressions, and DON'T call i split/2. By the way, I have a use for string:join(reverse([Stuff|tail(reverse( string:unjoin(Thing, ".")))]), ".") so I would be very unhappy to have to write one of those string literals as "\\." and the other NOT. > > > > There is, or should be, a regular pattern > words <-> unwords > lines <-> unlines > unjoin <-> join > Oh well, sort of regular... > > Sorry, and no offense meant, but that's really horribly ugly. So you really hate it that English has "tie" and "untie", "do" and "undo", "wary" and "unwary", amongst many pairs? > Reminds me of that sentence, "A not unblack dog chased a not unbrown > rabbit across a not ungreen field." Straw man. The nasty thing about that sentence is the double negations. There is no double negation in unjoin. "unwords" and "unlines" are not my inventions, they are from the Haskell standard Prelude. > Should the opposite of down then be "undown"? Languages (well, I can > vouch for two, anyway) contain many complementary words that are not > syntactically constructable by adding or removing "un-". What of it? The words/unwords lines/unline pattern DOES exist in the language Erlang copied many of its list processing function names from. It's not my invention. Indeed, the Haskell community is as familiar with "unfold" as with "fold". In this specific context, UNdoing the effect of a list operation, "un-" is an excellent cultural fit. The fact that for example "add" and "subtract" are not related in that way really doesn't signify anything, just as the fact that there are many colours doesn't mean that black is a bad choice. > Like split and join, for example. Hard and soft. Big and small. > Break and mend. Wake and sleep. Join is also related to sever, disunite, unfasten, disconnect, unyoke, separate, put asunder, unlink, disassociate, disaffiliate, resign, detach, disengage, leave, part, divide, quit, ... Split is also related to unite, unify, connect, fragm?nt (stress shown), and another whole lot of words. It's not as if "split" and "join" were each other's _only_ relative. From ok@REDACTED Fri Oct 10 06:16:20 2008 From: ok@REDACTED (Richard O'Keefe) Date: Fri, 10 Oct 2008 17:16:20 +1300 Subject: [erlang-questions] Bug in string:to_{lower,upper}/1? Message-ID: <5EBB3A16-726D-41C7-B295-280E83161232@cs.otago.ac.nz> In string.erl we find to_lower_char(C) when is_integer(C), C >= $A, C =< $Z -> C + 32; to_lower_char(C) when is_integer(C), C >= 16#C1, C =< 16#D6 -> C + 32; to_lower_char(C) when is_integer(C), C >= 16#D8, C =< 16#DE -> C + 32; to_lower_char(C) -> C. to_upper_char(C) when is_integer(C), C >= $a, C =< $z -> C - 32; to_upper_char(C) when is_integer(C), C >= 16#E1, C =< 16#F6 -> C - 32; to_upper_char(C) when is_integer(C), C >= 16#F8, C =< 16#FE -> C - 32; to_upper_char(C) -> C. But 16#C0 is capital A with grave, which is an upper case letter that should be converted, and to_lower_char/1 does not recognise it. I think 16#C1 should be 16#C0. And 16#E0 is lower case A with grave, which is a lower case letter that should be converted, but to_upper_char/1 does not recognise it. I think 16#E1 should be 16#E0. While these functions are not export, they are the guts of to_lower/1 and to_upper/1. From ok@REDACTED Fri Oct 10 07:00:58 2008 From: ok@REDACTED (Richard O'Keefe) Date: Fri, 10 Oct 2008 18:00:58 +1300 Subject: [erlang-questions] [enhancement] string:split/2 In-Reply-To: <6c2563b20810091932x245481ew538675b5526e8db3@mail.gmail.com> References: <6c2563b20810081642r2fbd1f14w8e3f7a5a2b71bcc4@mail.gmail.com> <6c2563b20810082343j255330ccp396cf4f8da0d2fe4@mail.gmail.com> <330AAA17-394B-44D0-9E09-7CEE4B6BF9C9@cs.otago.ac.nz> <6c2563b20810091932x245481ew538675b5526e8db3@mail.gmail.com> Message-ID: <8689C36E-B021-4300-88E1-AB66164891F6@cs.otago.ac.nz> On 10 Oct 2008, at 3:32 pm, Edwin Fine wrote: > My background and experience has led me to believe that primitive > operations, or functions that are likely to be heavily used, should > be implemented in a low-level language like C, and not in the higher- > level language. This is why, until Intergraph took it over, Quintus was the peer of Prologs. We didn't believe that. We ate our own dog food. If some aspect of our Prolog system was so slow that we were tempted to rewrite it in C, we said "oh no, our customers will find it too slow too" and improved our system. Some other companies said "we must have a fast compiler, so we'll write our compiler in C." That meant their customers found performance problems in generated code before they did. OOPS. Whether you call it split/2 or unjoin/2, it ISN'T a primitive operation. It's very easy to define in terms of other operations. And it HASN'T been heavily used, or it would already be there. > I consider string:split to be something that will be heavily used in > text-processing applications (which will also become heavily used, I > predict). I've done a lot of splitting in my time, and I must say that I have never found it to be the performance bottleneck. There's one thing I've learned over the years, and that is never to think I know where the time will go. Always measure. I've been progamming since the early 70s, and I am *still* surprised every time. > Since string operations really need to be efficient, Do they? Remind me never to use Java or Perl then. They need to be efficient *enough* not to be the bottleneck. For some applications, they might be. For some, not. Strings are almost always the wrong tool for the job. > I wrongly assumed that the string operations were written in C and > that the equivalent Erlang code would not be nearly as efficient. The 'string' library deals with strings represented as lists of integer character codes. C code _could_ be faster, but it would be hell to write. First you get your code working, then you measure it on real applications, then you improve your compiler, then you measure again, and only afterwards do you even think about putting things in C. And when you do, you think in terms of better building blocks, not in terms of doing the top level operation directly. Now this is what has already been happening slowly in Erlang. List length, reverse, and member have all migrated to C. They turn out to be very common building blocks. In 'string', instead of hacking unjoin/2, it would be best to hack the version of 'prefix' that I sent (which either returns the list after the prefix or the atom 'no'). That version can do the job of the existing 'prefix' code in 'string', but not conversely. > I'd rather ensure that the function is implemented efficiently to > start off with, and not require HiPE to be used to get performance. What is the point of worrying about the efficiency of a function when we don't even have agreement on its name? Get it right *first*. Talking about "not requir[ing] HiPE" is like saying "I demand that your C compiler produce efficient code without optimisation." Setting compiler options routinely produces more than a factor of 2 in C speed these days. (Even with the Intel C compiler, I found changing from its default options gave me a factor of 2.) Until you have *measured* the actual performance of my implementation of unjoin/2 in a real program working on real data, you have no reason to complain of its efficiency. > One of these nights when I have some spare time, I am going to try > your code out (with and without HiPE) against a 'C' or C++ version > of split and join so that I can have some hard data to tell for sure > one way or the other. What counts is the performance of the *whole* program. What might be more important in a complete program would be using binaries instead of strings. That could usefully go in C. Let's take a look at a use of the 'string' module. extract_sequences(Fmt, Need0) -> case string:chr(Fmt, $~) of 0 -> {ok,lists:reverse(Need0)}; %That's it Pos -> Fmt1 = string:substr(Fmt, Pos+1), %Skip ~ case extract_sequence(1, Fmt1, Need0) of {ok,Need1,Rest} -> extract_sequences(Rest, Need1); Error -> Error end end. The problem here is that whoever did this was thinking in a very C-like way. Suppose we had a different version of member/2, one which like its Lisp original returned a list: [] means not found, [X|_] means "found here". memq(X, [H|T]) when H =/= X -> memq(X, T); memq(_, L) -> L. Then the extract_sequences/2 function could be extract_sequences(Fmt, Need0) -> case memq($~, Fmt) of [] -> {ok, lists:reverse(Need0)} ; [_|Fmt1] -> case extract_sequence(1, Fmt1, Need0) of {ok,Need1,Rest} -> extract_sequences(Rest, Need1) ; Error -> Error end end. The original version traverses a list twice. The revised version traverses it once. In this case, coding string:substr/2 would have been the wrong way to get performance; the best way is to eliminate it entirely. Recently, I have been saying to myself "Suppose we had a rigid separation between guards and expressions, suppose we tried to completely do without 'false' and 'true' in expressions. What then?" The answer so far is "my code is the better for it. Every time." As far as I am concerned, the effort spent coding member/2 in C was effort spent on the *wrong* version of that concept. > > This is how I see it: even given the increasingly fast computer > architectures of today, one should do one's best not to waste > processor time when performance is desired. Indeed. But a programmer's primary job is to deliver working code on time and within budget. Time spent optimising functions that don't actually matter very much to the overall performance of the complete system is time wasted. Writing things in a low level language like C takes much more effort than writing them in a high level language. So you code as much as you can in your high level language and play around with it until the design settles, then you benchmark on real data, and when you know where the bottlenecks are, do you then recode in C? No, you try first to redesign the slow stuff out. (Like the extract_sequences/2 example above.) > I have seen users of interpreted, byte-code interpreted, and > threaded-interpreted languages implement computationally expensive, > heavily used functions in the language instead of in a low-level C > library. In almost all cases where the code was not I/O bound, there > was a significant penalty for writing such functions. Rewriting > those functions in C/C++ often gave one or two orders of magnitude > improvement. Fine. But you have to know which ones. Which means you have to have a sufficiently complete sufficiently working system to run real benchmarks to find out. I've implemented enough computationally intensive heavily used functions in my time to have learned that writing them first in the highest level language available can be a huge time saver in getting them right. Up until a year ago I had a PhD student working on data mining who decided to do all her coding in Python. That was the right decision for her. The code ran fast *enough*, and there wasn't any point optimising an algorithm when the point of her research was to find out what the algorithm should be. I've just finished co-supervising a 4th-year project where the student implemented an information retrieval engine in Common Lisp so that he could use Genetic Programming to learn a stemming algorithm. Common Lisp was fast *enough*, and it took a long time to figure out what his algorithm (not the learned algorithm) should be. Any time spent writing that in C would have slowed the project down, possibly preventing its completion. (The year before another student, trying to do the same thing in Java, came to grief. Mind you, he was a worse student, but the difficulty of coding anything in Java, compared with Lisp, certainly didn't help him.) > I know that the overall algorithm can make a huge difference, and > that we should not waste our time with premature optimization, but > at the same time we should not waste CPU time with belated > pessimization. If we can predict based on experience that something > (a) is likely to be heavily used and (b) will be more efficient in a > lower-level language then we should implement it in said language. I don't believe your prediction. unjoin/2 is useful, true, but it's not *that* useful. Writing an algorithm in Erlang isn't pessimisation and it hardly counts as "belated". If you think that badly of Erlang, why use it? > All the little inefficiencies can add up into a steaming great > system-wide inefficiency. The death of a thousand cuts. > > Now, that having been said, I have not devoted time (yet) to > studying the relative efficiency of Erlang-implemented operations > compared to C code. It is an amazingly tricky thing to do. Erlang is very bad at some things, like floating-point intensive computations, that C is very good at. It is very good at other things, like pattern matching and concurrency, that C is very bad at. Inter-language comparisons that use both languages effectively are as scarce as hen's teeth. (That is, a few have been constructed by wizards in the lab, but none are known in the wild.) > > Here's the old war story ploy. > > I once ported a C++ application to an IBM mainframe - which had > (gasp!) a C++ compiler - and saw the mainframe get absolutely > *caned* by my laptop performance-wise in many cases. Investigation > at that time revealed that although the mainframe wiped out my > laptop in terms of I/O speed and bandwidth, my laptop just smoked > the IBM when it came to what goes on in the Web: dynamic string > processing and lots of memory allocations and deallocations. IBM, > seeing the writing on the wall, modified its hardware architecture, > IIRC by adding special string opcodes, and improved its runtime > libraries, to support more efficient string-processing and better > dynamic memory handling. The z/Series ISA is readily available on the Web. The /360 always *had* special string opcodes. Some of the new opcodes add Unicode support. Dynamic memory handling is a library issue, and there are good, so-so, and spectacularly bad C and C++ libraries for that job. In this case, it had nothing to do with the hardware, but with the system library. I suspect that it was (ab)using GETMAIN instead of running suballocators. I don't know why the "gasp!"; IBM mainframes had C compilers, quite good ones for the time, before C++ was commonly available on most UNIX systems. The really funny thing here is that C++ strings are notorious. I'm sure it would have been easy to beat C++ on the laptop. From mats.westin@REDACTED Fri Oct 10 07:21:33 2008 From: mats.westin@REDACTED (Mats Westin) Date: Fri, 10 Oct 2008 07:21:33 +0200 Subject: [erlang-questions] Are there any companies that hire Erlangers? In-Reply-To: <2a67d3ff0810091808x2c4be63dpbe1ef8f79654593c@mail.gmail.com> References: <2a67d3ff0810091808x2c4be63dpbe1ef8f79654593c@mail.gmail.com> Message-ID: 2008/10/10 G.S. : > Hello All, > > I have yet to find a company that programs using Erlang, and I'd really like > to work for one. Am I looking in the wrong place, do any of you know a > company that uses Erlang as the main language? > > -Gene +1 -- http://www.linkedin.com/in/matswestin From erlang-questions_efine@REDACTED Fri Oct 10 07:24:03 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Fri, 10 Oct 2008 01:24:03 -0400 Subject: [erlang-questions] erlang-questions Digest, Vol 17, Issue 45 In-Reply-To: References: <8f24f4b10810091203i6eeb60f5q1b6bdaa483abea79@mail.gmail.com> <6c2563b20810091252l199969a3v2d82a5d9f87e0e91@mail.gmail.com> <8f24f4b10810091314r1586e999n999ffd972068e072@mail.gmail.com> <61EC12E1-6393-4427-846D-8B5DDC12B4D3@cs.otago.ac.nz> <6c2563b20810091911j581553d9s1f7bcc766620c48c@mail.gmail.com> Message-ID: <6c2563b20810092224s1329d172s7ef39932018cdb51@mail.gmail.com> On Thu, Oct 9, 2008 at 11:53 PM, Richard O'Keefe wrote: > On 10 Oct 2008, at 3:11 pm, Edwin Fine wrote: > >> Ok, then to preserve the Principle Of Least Astonishment, let string:split >> accept a regular expression, which is just a string with special RE >> operators. If the string contains no RE operators, use an optimized special >> case of split (like the one you wrote) that does not use an RE engine. Get >> the best of both worlds. >> > > No, that *violates* the principle of least astonishment, Big Time! > > First, absolutely nothing else whatever in the 'string' module > has anything to do with regular expressions. This would be > highly exceptional and very confusing. > I disagree. Take for example the String classes of Ruby ( http://www.ruby-doc.org/core/classes/String.html#M000818), JavaScript ( http://www.w3schools.com/jsref/jsref_split.asp) and Java ( http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html#split(java.lang.String)), all of which use split with an RE. It's very intuitive to use and doesn't seem odd or out of place in a string class or module at all. One could argue that strings and regular expressions are inextricably intertwined (Python, on the other hand, uses split in its re class as far as I can see, so it's not universally true). > Second, something that splits strings using regular expressions > would be expected in the 'regexp' module, not the 'string' module. > In fact, regexp:split/2 already exists. It would be rather > astonishing to replicate this in the wrong module. > I think it's a matter of taste or opinion. I don't think split belongs in the regexp module. The new re module correctly does not include it. I think regexp:split should be deprecated, in fact, the entire regexp module should be deprecated because enough people have used it and been burned by its lack of performance (because it is written in Erlang when it should have been written in C) that it warrants an entire Caveat section in the Erlang Efficiency Guide. > Third, if there were a string:split/2 that used regular > expressions, that would make it very incompatible with > string:join/2, which doesn't. I thought we were wanting > string:join(string:split(String, Sep), Sep) > to give back Sep. > Did you mean to write "to give back String?" Yes, that is what we want, and it is what will happen, because it is meaningless to join using an RE, isn't it. You can't join things together with a regular expression. So Sep would *have* to be a literal string. As it happens, split and join work exactly like this in other languages and don't seem to overly confuse people. > In short, if you want something called 'split' that preserves > the principle of least astonishment, use regexp:split/2. > If you want an opposite of string:join/2, DON'T make it use > regular expressions, and DON'T call i split/2. > So we are stuck with contriving some name because of history (lists:split should have been lists:split_as from Haskell, regexp already has split). This, in spite of there being more than enough precedents amongst other languages that use split as a method of their String classes. By the way, I have a use for > string:join(reverse([Stuff|tail(reverse( > string:unjoin(Thing, ".")))]), ".") > so I would be very unhappy to have to write one of > those string literals as "\\." and the other NOT. > That's a VERY good point. It's a glaring inconsistency. Other languages deal with that by having a regular expression type and special syntax (e.g. /abc/ or %r{abc}) to avoid confusion, and (IIRC) if a string type is passed in stead of an RE type, the receiving method treats it as a non-RE. One would then be able to use the same literal in both join and unjoin. Maybe Erlang should have a new regular expression type and syntax, seeing as it is going to be used in more and more applications that do heavy text processing. > There is, or should be, a regular pattern > words <-> unwords > lines <-> unlines > unjoin <-> join > Oh well, sort of regular... > > Sorry, and no offense meant, but that's really horribly ugly. > So you really hate it that English has "tie" and "untie", > "do" and "undo", "wary" and "unwary", amongst many pairs? > Maybe it's because I'm accustomed to the words "tie" and "untie" and the others you mentioned, and unlines, unwords and so on just sound ghastly to me due to lack of familiarity. I honestly can't intuit what unwords and unlines do. Well, that's not true. If I think about it, I suppose lines would split a string into lines (similarly "words" would split a string into words), and unlines would "undo" the lines operation and join them back together. But I did have to think about it for a while. Maybe I'm not that smart. > > Reminds me of that sentence, "A not unblack dog chased a not unbrown >> rabbit across a not ungreen field." >> > > Straw man. The nasty thing about that sentence is the double > negations. There is no double negation in unjoin. Yes, that is true, but in my eyes it's not only the double negation that's ugly. I was citing that sentence to show the ugliness of using "un" in places that are unusual. Note: "un" is not unusual in "unusual." > "unwords" and "unlines" are not my inventions, they are > from the Haskell standard Prelude. There is no intended irony or sarcasm in this: seeing as the inventors of Haskell are undoubtedly smarter than I am, I defer to their superior intelligence, but those words are still ugly to me. Sorry. > > Should the opposite of down then be "undown"? Languages (well, I can vouch >> for two, anyway) contain many complementary words that are not syntactically >> constructable by adding or removing "un-". >> > > What of it? The words/unwords lines/unline pattern DOES exist > in the language Erlang copied many of its list processing > function names from. It's not my invention. Indeed, the > Haskell community is as familiar with "unfold" as with "fold". > In this specific context, UNdoing the effect of a list > operation, "un-" is an excellent cultural fit. Fold and unfold are words in the English dictionary, and I can't swear to it because I am too lazy to look it up, but I would suspect that "unwords" and "unlines" are not. Still, I take your point. One can get used to almost anything given time. Not being a Haskell initiate, the usage looks strange to me. > The fact that for example "add" and "subtract" are not related > in that way really doesn't signify anything, just as the fact > that there are many colours doesn't mean that black is a bad > choice. But you wouldn't create a function named "unadd" when "subtract " is a more acceptable usage - would you? > Like split and join, for example. Hard and soft. Big and small. Break and >> mend. Wake and sleep. >> > > Join is also related to sever, disunite, unfasten, disconnect, unyoke, > separate, put asunder, unlink, disassociate, disaffiliate, resign, > detach, disengage, leave, part, divide, quit, ... > Interesting. One of the words you wrote above gave me an idea. How about meeting halfway? How about two new functions, string:separate(String, Separator) and string:unseparate(List, Separator)? No clash and it makes even more sense (to me) than split and join. Split is also related to unite, unify, connect, fragm?nt (stress shown), > and another whole lot of words. > > It's not as if "split" and "join" were each other's _only_ relative. > Point(s) well taken. How do you feel about "separate" and "unseparate", then? -------------- next part -------------- An HTML attachment was scrubbed... URL: From bengt.kleberg@REDACTED Fri Oct 10 08:03:58 2008 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Fri, 10 Oct 2008 08:03:58 +0200 Subject: [erlang-questions] Adding simple process to supervisor? In-Reply-To: <28655359.11621223585023526.JavaMail.root@zimbra> References: <28655359.11621223585023526.JavaMail.root@zimbra> Message-ID: <1223618638.3831.78.camel@seasc0642.dyn.rnd.as.sw.ericsson.se> Greetings, After suggestions from the list I have have tried the "proc_lib creates special process" method. It meant using proc_lib:start_link/3, calling proc_lib:init_ack/2, adding receive of system messages (2 lines) and 2 exported call-back functions (1 line each). That was acceptable complications too me since I keep all the restarting in the supervisor. Note that I think using your method would have been fewer lines. However, the process blocks in gen_tcp:accept/1, thus missing any system messages during this time. Is there a way around that? bengt On Thu, 2008-10-09 at 21:43 +0100, Oscar Hellstr?m wrote: > Hi Bengt, > > What I usually do is just to spawn a reader process from the gen_server and link to it. Then depending on if the gen_server should die with errors in the reader process or not I sometimes traps exits in the gen_server. Most of the time you want to restart the gen_server to open a new socket if the reader dies anyway. IMHO, there are too many issues with trying to get a process that does blocking calls to exist under a supervisor and this kind of process is typically very simple (read small room for errors) as well. Another approach is to use proc_lib to create a "special process" which uses {active, once} for the socket, to get away from doing blocking calls. > > ----- Original Message ----- > From: "Bengt Kleberg" > To: "erlang-questions" > Sent: Thursday, 9 October, 2008 12:03:27 AM GMT -08:00 US/Canada Pacific > Subject: [erlang-questions] Adding simple process to supervisor? > > Greetings, > > I have a gen_server which is supervised according to OTP rules. Now I > want to add a simple process that will read from a TCP port and send > the incoming data to the gen_server. I could spawn_link this process > from the gen_server and restart it if it dies. However, since I have a > supervisor it seems more logical to just add the process there, as a > rest_for_one. > > > There is the alternative of using a supervisor_bridge, but that seems > more complex than using the gen_server. It seems as if I just design > my process according to the OTP rules I will not need to use a > supervisor_bridge. What are those rules? The only suggestions I have > found are: > 1 Module:start_link/1 => {ok, Pid} > 2 Module:terminate/2 => ok > > > The child specification returned by the init/1 call-back in a > supervisor mentions the value for Modules if we have a gen_server, > gen_fsm or gen_event. What could be used for a simple process? > > > But how do I add a simple process to the supervisor? It seems overkill > to masquerade it as a get_fsm or similar. Since it is not called from > erlang it is not a gen_server. Since it does not have state it is not a > gen_fsm. No events are handled. > > > bengt > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From raimo+erlang-questions@REDACTED Fri Oct 10 08:35:17 2008 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Fri, 10 Oct 2008 08:35:17 +0200 Subject: [erlang-questions] External file sorting In-Reply-To: References: Message-ID: <20081010063517.GA16638@erix.ericsson.se> On Thu, Oct 09, 2008 at 12:59:51PM +0200, ERLANG wrote: > Hi List, > > Is there some free Erlang code for external (i.e on disk) file sorting? > This module in stdlib might be what you are looking for: http://www.erlang.org/doc/man/file_sorter.html > cheers > Y. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From kenneth.lundin@REDACTED Fri Oct 10 08:40:13 2008 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Fri, 10 Oct 2008 08:40:13 +0200 Subject: [erlang-questions] Interesting: "Squeak VM adapted to run on Tilera" In-Reply-To: References: Message-ID: For your info we can also say that we have the Erlang SMP VM running on a 64 core Tilera. How many cores from 1 to 64 we use is configurable. It is actually not a very big deal to port the Erlang VM to Tilera since it is run on top of Linux there as well. Getting good performance and scalability is another thing. The Tilera is a good test bench for testing scalability over many cores and we expect to get much better scalability when we have finished the implementation of multiple run-queues. /Kenneth Erlang/OTP team, Ericsson On Fri, Oct 10, 2008 at 1:03 AM, G Bulmer wrote: > > Folks, I thought some might be interested in this ... > > Sam S. Adams and David Ungar (Self) have adapted the Squeak VM to run > on 56 of the 64 cores on the Tilera64 processor family. > "Exploring Massively Multicore Programming Models: Introducing the > Renaissance ER Project" > http://domino.watson.ibm.com/comm/research.nsf/pages/r.plansoft.seminars.html > > Mentioned by Sam Adams here: > http://wiki.squeak.org/squeak/1107 > > G Bulmer > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From b88zhou@REDACTED Fri Oct 10 08:47:04 2008 From: b88zhou@REDACTED (Brian Zhou) Date: Thu, 9 Oct 2008 23:47:04 -0700 Subject: [erlang-questions] write the ant simulation in Erlang? In-Reply-To: <3dbc6d1c0810091447ye7fbc56j9d7ee5f322dd1854@mail.gmail.com> References: <859e91e70810081456w244b1c9dh74e108325ae4135c@mail.gmail.com> <7D2420AE-BA6D-4EE4-85DD-CCB6C1723DBE@cs.otago.ac.nz> <859e91e70810082144v52c0998bi140a6116c67cf12a@mail.gmail.com> <859e91e70810082146k3457bd2evc813a51beda59989@mail.gmail.com> <3dbc6d1c0810091447ye7fbc56j9d7ee5f322dd1854@mail.gmail.com> Message-ID: <859e91e70810092347x5903f7fdva3f44f6db99f916c@mail.gmail.com> On Thu, Oct 9, 2008 at 2:47 PM, Robert Virding wrote: > I haven't really checked the Clojure code that closely but it seems like a > reasonable problem. > > Do you know if it "turn based" or do the all the ants just move after their > own clocks in a parallel way? The clojure implementation uses one thread for each ant. Each ant has their own clock. > > A first approximation would be to have one process per ant and one for the > world. The only problem would be handling atomic > look-at-the-immediate-world-around-me-and-make-a-move. > Strictly speaking, the world state should be version'ed, the world process should reject the move if the world has changed since the ant looked, the ant process then should retry look-decide-and-request-move. As an optimization, I guess the world process can just check whether the FPA (food, pheromone, ant) value of the target cell has changed. I wrote a rough first cut based on the above idea: http://pastebin.ca/1224362 - It's not completed yet, TODO: 1. pheromone evaporation 2. initialization of the world, spawn world process, spawn ant processes 3. scoring candidate cells Am I on the right track? > The really difficult bit is displaying it. :-) > I'm not there yet. Thanks, -Brian From vladdu55@REDACTED Fri Oct 10 08:57:17 2008 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Fri, 10 Oct 2008 08:57:17 +0200 Subject: [erlang-questions] Fwd: [enhancement] string:split/2 In-Reply-To: <95be1d3b0810092356lc2f1d93m5e86a0ecc97358cd@mail.gmail.com> References: <6c2563b20810081642r2fbd1f14w8e3f7a5a2b71bcc4@mail.gmail.com> <6c2563b20810082343j255330ccp396cf4f8da0d2fe4@mail.gmail.com> <330AAA17-394B-44D0-9E09-7CEE4B6BF9C9@cs.otago.ac.nz> <6c2563b20810091932x245481ew538675b5526e8db3@mail.gmail.com> <8689C36E-B021-4300-88E1-AB66164891F6@cs.otago.ac.nz> <95be1d3b0810092356lc2f1d93m5e86a0ecc97358cd@mail.gmail.com> Message-ID: <95be1d3b0810092357l560fc443s717064b14cfb5677@mail.gmail.com> Hi, On Fri, Oct 10, 2008 at 07:00, Richard O'Keefe wrote: > On 10 Oct 2008, at 3:32 pm, Edwin Fine wrote: >> I'd rather ensure that the function is implemented efficiently to >> start off with, and not require HiPE to be used to get performance. > > Talking about "not requir[ing] HiPE" is like saying > "I demand that your C compiler produce efficient code > without optimisation." A side issue: the above comparison is not really correct. Until HiPE is available on all platforms and architectures supported by Erlang, it is perfectly valid to not want to have it as a requirement for an application. best regards, Vlad From btolputt@REDACTED Fri Oct 10 07:25:29 2008 From: btolputt@REDACTED (Benjamin Tolputt) Date: Fri, 10 Oct 2008 16:25:29 +1100 Subject: [erlang-questions] [enhancement] string:split/2 In-Reply-To: <8689C36E-B021-4300-88E1-AB66164891F6@cs.otago.ac.nz> References: <6c2563b20810081642r2fbd1f14w8e3f7a5a2b71bcc4@mail.gmail.com> <6c2563b20810082343j255330ccp396cf4f8da0d2fe4@mail.gmail.com> <330AAA17-394B-44D0-9E09-7CEE4B6BF9C9@cs.otago.ac.nz> <6c2563b20810091932x245481ew538675b5526e8db3@mail.gmail.com> <8689C36E-B021-4300-88E1-AB66164891F6@cs.otago.ac.nz> Message-ID: <48EEE749.7000100@bigpond.net.au> Richard O'Keefe wrote: > Talking about "not requir[ing] HiPE" is like saying > "I demand that your C compiler produce efficient code > without optimisation." Setting compiler options routinely > produces more than a factor of 2 in C speed these days. > (Even with the Intel C compiler, I found changing from > its default options gave me a factor of 2.) While I agree with nigh on all the rest of your post, I take issue with the above statement for one simple reason... HiPE does not run on Windows. Depending on the system being put together this ranges between non-applicable to "deal breaker". In cases involving string processing - Windows is a very likely candidate for the platform on which the application will be run. As someone who sees Erlang as being applicable beyond the clustered server paradigm, performance on the operating system used in 90+% desktop installations is incredibly important. -- Regards, Benjamin Tolputt Analyst Programmer Email: btolputt@REDACTED This email and any files transmitted with it are confidential to the intended recipient and may be privileged. If you have received this email inadvertently or you are not the intended recipient, you may not disseminate, distribute, copy or in any way rely on it. Further, you should notify the sender immediately and delete the email from your computer. Whilst we have taken precautions to alert us to the presence of computer viruses, we cannot guarantee that this email and any files transmitted with it are free from such viruses. From ulf.wiger@REDACTED Fri Oct 10 09:47:06 2008 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Fri, 10 Oct 2008 09:47:06 +0200 Subject: [erlang-questions] Adding simple process to supervisor? In-Reply-To: <1223618638.3831.78.camel@seasc0642.dyn.rnd.as.sw.ericsson.se> References: <28655359.11621223585023526.JavaMail.root@zimbra> <1223618638.3831.78.camel@seasc0642.dyn.rnd.as.sw.ericsson.se> Message-ID: <48EF087A.6060600@ericsson.com> Bengt Kleberg skrev: > > However, the process blocks in gen_tcp:accept/1, thus missing any > system messages during this time. Is there a way around that? You can spawn an acceptor process and then transfer control using controlling_process(). The acceptor process has but one job: to block while waiting for the accept() to return. It is linked to the parent process and doesn't trap exits. BR, Ulf W From bgustavsson@REDACTED Fri Oct 10 10:26:08 2008 From: bgustavsson@REDACTED (Bjorn Gustavsson) Date: Fri, 10 Oct 2008 10:26:08 +0200 Subject: [erlang-questions] Bug in string:to_{lower,upper}/1? In-Reply-To: <5EBB3A16-726D-41C7-B295-280E83161232@cs.otago.ac.nz> References: <5EBB3A16-726D-41C7-B295-280E83161232@cs.otago.ac.nz> Message-ID: <6672d0160810100126j1b6555d1u532b1c113bdb2380@mail.gmail.com> On Fri, Oct 10, 2008 at 6:16 AM, Richard O'Keefe wrote: > In string.erl we find > > to_lower_char(C) when is_integer(C), C >= $A, C =< $Z -> > C + 32; > to_lower_char(C) when is_integer(C), C >= 16#C1, C =< 16#D6 -> > C + 32; > to_lower_char(C) when is_integer(C), C >= 16#D8, C =< 16#DE -> > C + 32; > to_lower_char(C) -> > C. > > to_upper_char(C) when is_integer(C), C >= $a, C =< $z -> > C - 32; > to_upper_char(C) when is_integer(C), C >= 16#E1, C =< 16#F6 -> > C - 32; > to_upper_char(C) when is_integer(C), C >= 16#F8, C =< 16#FE -> > C - 32; > to_upper_char(C) -> > C. > > But 16#C0 is capital A with grave, > which is an upper case letter that should be converted, > and to_lower_char/1 does not recognise it. > I think 16#C1 should be 16#C0. > > And 16#E0 is lower case A with grave, > which is a lower case letter that should be converted, > but to_upper_char/1 does not recognise it. > I think 16#E1 should be 16#E0. > Thanks for pointing this out. We will correct this problem in R12B-5. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB -------------- next part -------------- An HTML attachment was scrubbed... URL: From tty.erlang@REDACTED Fri Oct 10 13:10:45 2008 From: tty.erlang@REDACTED (t ty) Date: Fri, 10 Oct 2008 07:10:45 -0400 Subject: [erlang-questions] Are there any companies that hire Erlangers? In-Reply-To: <6c2563b20810091937u2b411cean65d972caa4d60bd9@mail.gmail.com> References: <2a67d3ff0810091808x2c4be63dpbe1ef8f79654593c@mail.gmail.com> <6c2563b20810091937u2b411cean65d972caa4d60bd9@mail.gmail.com> Message-ID: <290b3ba10810100410k205642demb8ec48b7f361a3e4@mail.gmail.com> Erlang Training and Consulting has a jobs page which you might want to subscribe to http://www.erlang-consulting.com/jobs.html For the record I don't work for ETC :) t 2008/10/9 Edwin Fine : > Not to be funny, but in which country? I mean, where are you looking? In the > U.K for example, I think I know of a company or two that uses primarily > Erlang (Erlang Training and Consulting is one, and I think LShift is another > - http://www.lshift.net/recruitment). > > 2008/10/9 G.S. >> >> Hello All, >> >> I have yet to find a company that programs using Erlang, and I'd really >> like to work for one. Am I looking in the wrong place, do any of you know a >> company that uses Erlang as the main language? >> >> -Gene >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From tty.erlang@REDACTED Fri Oct 10 13:23:01 2008 From: tty.erlang@REDACTED (t ty) Date: Fri, 10 Oct 2008 07:23:01 -0400 Subject: [erlang-questions] 2008 Workshop Presentation Slides Available Message-ID: <290b3ba10810100423v4eba5713va4e55ee248ce7c8b@mail.gmail.com> ===================================================================== Workshop Presentation Slides Available The 7th ACM SIGPLAN Erlang Workshop 2008 http://www.erlang.org/workshop/2008/ Victoria, BC, Canada, 27 September 2008 ===================================================================== The presentation slides for the 7th ACM SIGPLAN Erlang Workshop in Victoria, British Columbia, Canada, held on September 27 are now available at http://www.erlang.org/workshop/2008/ Workshop papers can be obtained from the ACM Digital Library. Please feel free to distribute this announcement to any other interested mailing-list. From kostis@REDACTED Fri Oct 10 13:33:12 2008 From: kostis@REDACTED (Kostis Sagonas) Date: Fri, 10 Oct 2008 14:33:12 +0300 Subject: [erlang-questions] Types and specs [WAS: [enhancement] string:split/2] In-Reply-To: References: <6c2563b20810081642r2fbd1f14w8e3f7a5a2b71bcc4@mail.gmail.com> Message-ID: <48EF3D78.2060306@cs.ntua.gr> Richard O'Keefe wrote: > > Can anyone explain to me why > > -spec(tokens/2 :: (string(), string()) -> [[char(),...]]). > > doesn't mention "string()" on the right hand side of the arrow? There is no native string() type in Erlang, as we all well know. So, in the language ot types, string() is just an alias for the type list(char()), which, for convenience, is typically written as [char()]. This can include both the empty string "" == [] and a non-empty list of characters, which is denoted [char(),...]. That's what the above spec signifies: the resulting list consists of non-empty strings, which is consistent with what string:tokens/2 actually returns. Hope this explains things. On the other hand, I can see how this may look a bit strange to some and have for a long time now pondered whether a non_empty_string() type alias might be added to the list of built-in types. Kostis From ash@REDACTED Fri Oct 10 14:04:01 2008 From: ash@REDACTED (Alex Chateau) Date: Fri, 10 Oct 2008 15:04:01 +0300 Subject: [erlang-questions] [enhancement] string:split/2 In-Reply-To: <6c2563b20810090953n1b0c7672v17ceb84cbb59a1fd@mail.gmail.com> References: <6c2563b20810081642r2fbd1f14w8e3f7a5a2b71bcc4@mail.gmail.com> <34A27838-5CBA-425D-97A1-C2D2CF6F5456@cs.otago.ac.nz> <6c2563b20810082354u34372510n1fb4e1d23d777c23@mail.gmail.com> <781bce43-97e9-48fb-bba2-0ce230f2011a@t39g2000prh.googlegroups.com> <6c2563b20810090953n1b0c7672v17ceb84cbb59a1fd@mail.gmail.com> Message-ID: <20081010120401.GA3909@tsi.lv> On Thu, Oct 09, 2008 at 12:53:52PM -0400, Edwin Fine wrote: > > > > > > Do you mean that string:split should be the _inverse_ of string:join? > > > > http://en.wikipedia.org/wiki/Inverse_function > > > Yes, that's it. Thanks. I just wish there was a more impressive-sounding > word like idempotent :) string:join/2 is not a surjective function, not a bijective one: 1> string:join(["a.", "b"], "."). "a..b" 2> string:join(["a", ".b"], "."). "a..b" So, there is no inverse function for string:join/2 http://en.wikipedia.org/wiki/Bijection http://en.wikipedia.org/wiki/Surjection -- Alex Chateau From saleyn@REDACTED Fri Oct 10 14:19:51 2008 From: saleyn@REDACTED (Serge Aleynikov) Date: Fri, 10 Oct 2008 08:19:51 -0400 Subject: [erlang-questions] Adding simple process to supervisor? In-Reply-To: <1223618638.3831.78.camel@seasc0642.dyn.rnd.as.sw.ericsson.se> References: <28655359.11621223585023526.JavaMail.root@zimbra> <1223618638.3831.78.camel@seasc0642.dyn.rnd.as.sw.ericsson.se> Message-ID: <48EF4867.6080703@gmail.com> If you need a completely non-blocking solution, you can read this article: http://www.trapexit.org/Building_a_Non-blocking_TCP_server_using_OTP_principles Serge Bengt Kleberg wrote: > Greetings, > > After suggestions from the list I have have tried the "proc_lib creates > special process" method. It meant using proc_lib:start_link/3, calling > proc_lib:init_ack/2, adding receive of system messages (2 lines) and 2 > exported call-back functions (1 line each). That was acceptable > complications too me since I keep all the restarting in the supervisor. > Note that I think using your method would have been fewer lines. > > However, the process blocks in gen_tcp:accept/1, thus missing any system > messages during this time. Is there a way around that? > > > bengt > > On Thu, 2008-10-09 at 21:43 +0100, Oscar Hellstr?m wrote: >> Hi Bengt, >> >> What I usually do is just to spawn a reader process from the gen_server and link to it. Then depending on if the gen_server should die with errors in the reader process or not I sometimes traps exits in the gen_server. Most of the time you want to restart the gen_server to open a new socket if the reader dies anyway. IMHO, there are too many issues with trying to get a process that does blocking calls to exist under a supervisor and this kind of process is typically very simple (read small room for errors) as well. Another approach is to use proc_lib to create a "special process" which uses {active, once} for the socket, to get away from doing blocking calls. >> >> ----- Original Message ----- >> From: "Bengt Kleberg" >> To: "erlang-questions" >> Sent: Thursday, 9 October, 2008 12:03:27 AM GMT -08:00 US/Canada Pacific >> Subject: [erlang-questions] Adding simple process to supervisor? >> >> Greetings, >> >> I have a gen_server which is supervised according to OTP rules. Now I >> want to add a simple process that will read from a TCP port and send >> the incoming data to the gen_server. I could spawn_link this process >> from the gen_server and restart it if it dies. However, since I have a >> supervisor it seems more logical to just add the process there, as a >> rest_for_one. >> >> >> There is the alternative of using a supervisor_bridge, but that seems >> more complex than using the gen_server. It seems as if I just design >> my process according to the OTP rules I will not need to use a >> supervisor_bridge. What are those rules? The only suggestions I have >> found are: >> 1 Module:start_link/1 => {ok, Pid} >> 2 Module:terminate/2 => ok >> >> >> The child specification returned by the init/1 call-back in a >> supervisor mentions the value for Modules if we have a gen_server, >> gen_fsm or gen_event. What could be used for a simple process? >> >> >> But how do I add a simple process to the supervisor? It seems overkill >> to masquerade it as a get_fsm or similar. Since it is not called from >> erlang it is not a gen_server. Since it does not have state it is not a >> gen_fsm. No events are handled. >> >> >> bengt >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From r.b.lists@REDACTED Fri Oct 10 15:00:23 2008 From: r.b.lists@REDACTED (Roland Braito) Date: Fri, 10 Oct 2008 15:00:23 +0200 Subject: [erlang-questions] Are there any companies that hire Erlangers? In-Reply-To: <290b3ba10810100410k205642demb8ec48b7f361a3e4@mail.gmail.com> References: <2a67d3ff0810091808x2c4be63dpbe1ef8f79654593c@mail.gmail.com> <6c2563b20810091937u2b411cean65d972caa4d60bd9@mail.gmail.com> <290b3ba10810100410k205642demb8ec48b7f361a3e4@mail.gmail.com> Message-ID: <20081010130023.30940@gmx.net> I have got some offers since i have put up my interest in erlang in my profile on Xing.com -------- Original-Nachricht -------- > Datum: Fri, 10 Oct 2008 07:10:45 -0400 > Von: "t ty" > An: "Edwin Fine" > CC: erlang-questions@REDACTED > Betreff: Re: [erlang-questions] Are there any companies that hire Erlangers? > Erlang Training and Consulting has a jobs page which you might want to > subscribe to > > http://www.erlang-consulting.com/jobs.html > > For the record I don't work for ETC :) > > t > > 2008/10/9 Edwin Fine : > > Not to be funny, but in which country? I mean, where are you looking? In > the > > U.K for example, I think I know of a company or two that uses primarily > > Erlang (Erlang Training and Consulting is one, and I think LShift is > another > > - http://www.lshift.net/recruitment). > > > > 2008/10/9 G.S. > >> > >> Hello All, > >> > >> I have yet to find a company that programs using Erlang, and I'd really > >> like to work for one. Am I looking in the wrong place, do any of you > know a > >> company that uses Erlang as the main language? > >> > >> -Gene > >> > >> _______________________________________________ > >> erlang-questions mailing list > >> erlang-questions@REDACTED > >> http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- GMX Kostenlose Spiele: Einfach online spielen und Spa? haben mit Pastry Passion! http://games.entertainment.gmx.net/de/entertainment/games/free/puzzle/6169196 From armstrong.whit@REDACTED Fri Oct 10 15:21:37 2008 From: armstrong.whit@REDACTED (Whit Armstrong) Date: Fri, 10 Oct 2008 09:21:37 -0400 Subject: [erlang-questions] Article on Erlang in ACM Queue In-Reply-To: <48ED943A.80801@berabera.info> References: <48ED943A.80801@berabera.info> Message-ID: <8ec76080810100621r48b0a482j1e02ad8bf5788a58@mail.gmail.com> I'm new to Erlang. I've been considering it for a few simulation projects in finance. However, I was discouraged because the ACM article suggests that Erlang has poor floating point performance. Are any list members using Erlang for numerical simulations? If so, do you have any advice on how to how to improve efficiency? What about using binaries to store vectors of doubles? Are there any extensions of Erlang that allow one to do that? Any feedback is appreciated. Thanks, Whit On Thu, Oct 9, 2008 at 1:18 AM, Romain Lenglet wrote: > Jim Larson has written an article entitled "Erlang for Concurrent > Programming", published in the latest ACM Queue: > http://mags.acm.org/queue/200809/ > > This article is a very good, practical introduction to Erlang and OTP. > > -- > Romain Lenglet > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From saleyn@REDACTED Fri Oct 10 15:42:19 2008 From: saleyn@REDACTED (Serge Aleynikov) Date: Fri, 10 Oct 2008 09:42:19 -0400 Subject: [erlang-questions] jinterface bug Message-ID: <48EF5BBB.5080207@gmail.com> While working with otp.net I encountered a fairly serious bug that has its origin in jinterface. The later doesn't detect remote node disconnects. Attached patch addresses the issue. Serge -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: AbstractConnection.java.patch URL: From Bill.McKeeman@REDACTED Fri Oct 10 15:46:43 2008 From: Bill.McKeeman@REDACTED (Bill McKeeman) Date: Fri, 10 Oct 2008 09:46:43 -0400 Subject: [erlang-questions] Article on Erlang in ACM Queue In-Reply-To: <8ec76080810100621r48b0a482j1e02ad8bf5788a58@mail.gmail.com> References: <48ED943A.80801@berabera.info> <8ec76080810100621r48b0a482j1e02ad8bf5788a58@mail.gmail.com> Message-ID: I think it depends on how much you can do in parallel and how much is really floating point as contrasted to function calls and the like. I wrote a numerical integration routine with a parameter N for the number of cores I expected to use. Even with N = 2 it was better than some competing sequential versions. I'll attach the code. /s/Bill -----Original Message----- From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Whit Armstrong Sent: Friday, October 10, 2008 9:22 AM To: Erlang mailing list Subject: Re: [erlang-questions] Article on Erlang in ACM Queue I'm new to Erlang. I've been considering it for a few simulation projects in finance. However, I was discouraged because the ACM article suggests that Erlang has poor floating point performance. Are any list members using Erlang for numerical simulations? If so, do you have any advice on how to how to improve efficiency? What about using binaries to store vectors of doubles? Are there any extensions of Erlang that allow one to do that? Any feedback is appreciated. Thanks, Whit On Thu, Oct 9, 2008 at 1:18 AM, Romain Lenglet wrote: > Jim Larson has written an article entitled "Erlang for Concurrent > Programming", published in the latest ACM Queue: > http://mags.acm.org/queue/200809/ > > This article is a very good, practical introduction to Erlang and OTP. > > -- > Romain Lenglet > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- A non-text attachment was scrubbed... Name: pquadn.erl Type: application/octet-stream Size: 1711 bytes Desc: pquadn.erl URL: From nicolas@REDACTED Fri Oct 10 16:01:22 2008 From: nicolas@REDACTED (Nicolas Niclausse) Date: Fri, 10 Oct 2008 16:01:22 +0200 Subject: [erlang-questions] Article on Erlang in ACM Queue In-Reply-To: <8ec76080810100621r48b0a482j1e02ad8bf5788a58@mail.gmail.com> References: <48ED943A.80801@berabera.info> <8ec76080810100621r48b0a482j1e02ad8bf5788a58@mail.gmail.com> Message-ID: <48EF6032.8080400@niclux.org> Whit Armstrong ecrivait le 10.10.2008 15:21: > I'm new to Erlang. I've been considering it for a few simulation > projects in finance. However, I was discouraged because the ACM > article suggests that Erlang has poor floating point performance. > > Are any list members using Erlang for numerical simulations? If so, > do you have any advice on how to how to improve efficiency? What > about using binaries to store vectors of doubles? Are there any > extensions of Erlang that allow one to do that? Take a look at the slides "High-performance Technical Computing with Erlang " recently published in http://www.erlang.org/workshop/2008/ It seems very promising. I'm waiting for a code release ! -- Nicolas From ulf.wiger@REDACTED Fri Oct 10 16:03:18 2008 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Fri, 10 Oct 2008 16:03:18 +0200 Subject: [erlang-questions] Article on Erlang in ACM Queue In-Reply-To: <8ec76080810100621r48b0a482j1e02ad8bf5788a58@mail.gmail.com> References: <48ED943A.80801@berabera.info> <8ec76080810100621r48b0a482j1e02ad8bf5788a58@mail.gmail.com> Message-ID: <48EF60A6.10400@ericsson.com> Whit Armstrong skrev: > I'm new to Erlang. I've been considering it for a few simulation > projects in finance. However, I was discouraged because the ACM > article suggests that Erlang has poor floating point performance. > > Are any list members using Erlang for numerical simulations? If so, > do you have any advice on how to how to improve efficiency? What > about using binaries to store vectors of doubles? Are there any > extensions of Erlang that allow one to do that? Perhaps this might at least give you some initial intuition: High-performance Technical Computing with Erlang Alceste Scalas Giovanni Casu Piero Pili Center for Advanced Studies, Research and Development in Sardinia ACM ICFP 2008 / Erlang Workshop September 27th, 2008 Victoria, BC, Canada http://www.erlang.org/workshop/2008/Sess23.pdf BR, Ulf W From saleyn@REDACTED Fri Oct 10 16:04:01 2008 From: saleyn@REDACTED (Serge Aleynikov) Date: Fri, 10 Oct 2008 10:04:01 -0400 Subject: [erlang-questions] code_server & ERL_LIBS bug Message-ID: <48EF60D1.1030704@gmail.com> There's an error in code server that causes erl & erlc to hang at startup if ERL_LIBS environment variable is set to an empty string or a string containing non-existing directories. Here's how to reproduce it: $ export ERL_LIBS= $ erl or $ export ERL_LIBS="/a/b/c" $ erl Attached patch corrects the problem. Regards, Serge -------------- next part -------------- A non-text attachment was scrubbed... Name: code_server.erl.patch Type: application/octet-stream Size: 1157 bytes Desc: not available URL: From juanjo@REDACTED Fri Oct 10 16:07:52 2008 From: juanjo@REDACTED (Juan Jose Comellas) Date: Fri, 10 Oct 2008 11:07:52 -0300 Subject: [erlang-questions] Are there any companies that hire Erlangers? In-Reply-To: <2a67d3ff0810091808x2c4be63dpbe1ef8f79654593c@mail.gmail.com> References: <2a67d3ff0810091808x2c4be63dpbe1ef8f79654593c@mail.gmail.com> Message-ID: <1c3be50f0810100707x1dafca95pf173a22fc20c752e@mail.gmail.com> We use Erlang for some of our projects and we are always looking for people with good skills and knowledge of the language. So far we've never found anybody who already knew Erlang in Argentina so we've been training our employees ourselves. We have offices in Buenos Aires and San Luis, a bit far from the countries where most Erlang developers reside, but we already have 12 people working in Erlang at our company (http://www.novamens.com). 2008/10/9 G.S. > Hello All, > > I have yet to find a company that programs using Erlang, and I'd really > like to work for one. Am I looking in the wrong place, do any of you know a > company that uses Erlang as the main language? > > -Gene > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ash@REDACTED Fri Oct 10 16:09:50 2008 From: ash@REDACTED (Alex Chateau) Date: Fri, 10 Oct 2008 17:09:50 +0300 Subject: [erlang-questions] [enhancement] string:split/2 In-Reply-To: <20081010120401.GA3909@tsi.lv> References: <6c2563b20810081642r2fbd1f14w8e3f7a5a2b71bcc4@mail.gmail.com> <34A27838-5CBA-425D-97A1-C2D2CF6F5456@cs.otago.ac.nz> <6c2563b20810082354u34372510n1fb4e1d23d777c23@mail.gmail.com> <781bce43-97e9-48fb-bba2-0ce230f2011a@t39g2000prh.googlegroups.com> <6c2563b20810090953n1b0c7672v17ceb84cbb59a1fd@mail.gmail.com> <20081010120401.GA3909@tsi.lv> Message-ID: <20081010140950.GB3909@tsi.lv> > string:join/2 is not a surjective function, not a bijective one: Sorry, string:join/2 _is_ a surjective function -- Alex Chateau From erik.stenman@REDACTED Fri Oct 10 16:22:46 2008 From: erik.stenman@REDACTED (Erik Stenman) Date: Fri, 10 Oct 2008 16:22:46 +0200 Subject: [erlang-questions] Are there any companies that hire Erlangers? In-Reply-To: <2a67d3ff0810091808x2c4be63dpbe1ef8f79654593c@mail.gmail.com> References: <2a67d3ff0810091808x2c4be63dpbe1ef8f79654593c@mail.gmail.com> Message-ID: Kreditor is using Erlang for almost all of our development. We are currently hiring two to three erlang developers, a head of development, a technical project manager, one operations engineer and one support engineer. If you want to know more about any of these positions, just drop me a line. On 10 okt 2008, at 03.08, G.S. wrote: > Hello All, > > I have yet to find a company that programs using Erlang, and I'd > really like to work for one. Am I looking in the wrong place, do any > of you know a company that uses Erlang as the main language? > > -Gene > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions Erik Stenman ? CTO KREDITOR EUROPE AB Sankt Eriksgatan 117 113 43, Stockholm Vxl: +46 8 120 120 00 Fax: +46 8 120 120 99 Webb: www.kreditor.se E-mail: erik.stenman@REDACTED -------------- next part -------------- An HTML attachment was scrubbed... URL: From n39052@REDACTED Fri Oct 10 17:09:14 2008 From: n39052@REDACTED (Sergey A.) Date: Fri, 10 Oct 2008 08:09:14 -0700 Subject: [erlang-questions] Lots of questions about error_logger Message-ID: <3bff71aa0810100809w1b5282dfhd7bd06876f255605@mail.gmail.com> Hello. In the first place, sorry for several different questions placed in one letter. I know it's something wearily to answer a list of questions. I tried using error_logger as a tool for handling error reports and I've came across some oddities: #1. Is there a way to set SASL options (I'm about sasl_error_logger, errlog_type etc) from the Erlang code at runtime without using a .config file + the "-config" argument? I just want to give an end user only one config file to edit and use values from that to setup SASL. #2. The following is from the "Programming Erlang": --[Beginning of quote]------------------------------------------------- The next configuration file lists error reports in the shell, and a copy of everything reported in the shell is also made to a file: %% single text file - minimal tty [{sasl, [ %% All reports go to this file {sasl_error_logger, {file, "/home/joe/error_logs/THELOG" }} ]}]." --[End of quote]------------------------------------------------- I replaced the path to just "THELOG" and then run the shell: --[Beginning of erl session]------------------------------------------------- erl -boot start_sasl -config elog2.config Erlang (BEAM) emulator version 5.6.3 [source] [smp:2] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.6.3 (abort with ^G) 1> error_logger:error_msg("foobar~n"). ok =ERROR REPORT==== 10-Oct-2008::03:19:38 === foobar 2> error_logger:error_report("foobar\n"). =ERROR REPORT==== 10-Oct-2008::03:21:05 === foobar ok 3> User switch command --> q --[End of erl session]------------------------------------------------- But after all, THELOG doesn't contain any string related to my foobar-errors! Just only progress reports! Why does this happen? #3. If I decide to use rotating of logs, those logs will be written in binary format. What are the benefits of using binary format for storing logs? Is there possibility to force Erlang to use plain text files instead of binary ones? #4. What is the "index" file for? #5. Quote from Programming Erlang: --[Beginning of quote]------------------------------------------------- In a production environment, we are really interested only in errors and not progress or information reports, so we tell the error logger to report only errors. Without this setting, the system might get swamped with information and progress reports. Download elog4.config %% rotating log and errors [{sasl, [ %% minimise shell error logging {sasl_error_logger, false}, %% only report errors {errlog_type, error}, %% define the parameters of the rotating log %% the log file directory {error_logger_mf_dir,"/home/joe/error_logs" }, %% # bytes per logfile {error_logger_mf_maxbytes,10485760}, % 10 MB %% maximum number of {error_logger_mf_maxfiles, 10} ]}]. --[End of quote]------------------------------------------------- But using this config I see some progress reports: 3> rb:list(). No Type Process Date Time == ==== ======= ==== ==== 6 progress <0.30.0> 2008-10-10 03:39:59 5 progress <0.30.0> 2008-10-10 03:39:59 4 progress <0.30.0> 2008-10-10 03:39:59 3 progress <0.30.0> 2008-10-10 03:39:59 2 progress <0.23.0> 2008-10-10 03:39:59 1 error <0.24.0> 2008-10-10 03:40:20 ok What is wrong? -- Sergey. P.S. Sorry for the possible English mistakes in my letter =) From rec@REDACTED Fri Oct 10 17:56:30 2008 From: rec@REDACTED (Roger Critchlow) Date: Fri, 10 Oct 2008 09:56:30 -0600 Subject: [erlang-questions] write the ant simulation in Erlang? In-Reply-To: <859e91e70810092347x5903f7fdva3f44f6db99f916c@mail.gmail.com> References: <859e91e70810081456w244b1c9dh74e108325ae4135c@mail.gmail.com> <7D2420AE-BA6D-4EE4-85DD-CCB6C1723DBE@cs.otago.ac.nz> <859e91e70810082144v52c0998bi140a6116c67cf12a@mail.gmail.com> <859e91e70810082146k3457bd2evc813a51beda59989@mail.gmail.com> <3dbc6d1c0810091447ye7fbc56j9d7ee5f322dd1854@mail.gmail.com> <859e91e70810092347x5903f7fdva3f44f6db99f916c@mail.gmail.com> Message-ID: <66d1c98f0810100856r4d91c602lacb81c0b1fa9639e@mail.gmail.com> I think the world process is the right idea. It is supplying the semantics of the language runtime in Clojure which sorts out which speculative transactions are allowed to commit. Versioning of world state would need to restrict itself to the part of the world that the ant looked at, forcing a retry any time any part of the world had changed would be excessive. And I think that only moves resulting in ant-ant collisions need to be rejected -- that the rewards of moving might change between the time we make the decision and the time we enact the decision is unfortunate, but all too real. The clojure ants are making decisions based on a snapshot, too, and only retrying on collisions. Capturing the snapshot for display should be simple, just return the world_loop State. -- rec -- On Fri, Oct 10, 2008 at 12:47 AM, Brian Zhou wrote: > On Thu, Oct 9, 2008 at 2:47 PM, Robert Virding wrote: > > I haven't really checked the Clojure code that closely but it seems like > a > > reasonable problem. > > > > Do you know if it "turn based" or do the all the ants just move after > their > > own clocks in a parallel way? > The clojure implementation uses one thread for each ant. Each ant has > their own clock. > > > > > A first approximation would be to have one process per ant and one for > the > > world. The only problem would be handling atomic > > look-at-the-immediate-world-around-me-and-make-a-move. > > > Strictly speaking, the world state should be version'ed, the world > process should reject the move if the world has changed since the ant > looked, the ant process then should retry > look-decide-and-request-move. As an optimization, I guess the world > process can just check whether the FPA (food, pheromone, ant) value of > the target cell has changed. > > I wrote a rough first cut based on the above idea: > http://pastebin.ca/1224362 - It's not completed yet, TODO: > 1. pheromone evaporation > 2. initialization of the world, spawn world process, spawn ant processes > 3. scoring candidate cells > > Am I on the right track? > > > The really difficult bit is displaying it. :-) > > > I'm not there yet. > > Thanks, > > -Brian > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From sten.gruener@REDACTED Fri Oct 10 18:30:41 2008 From: sten.gruener@REDACTED (Stasik) Date: Fri, 10 Oct 2008 09:30:41 -0700 (PDT) Subject: [erlang-questions] FFI Interface - Limitation of the size of parameters Message-ID: Hello, I am quite new to Erland, and try to get some Erlang-C Communication. I found a tutorial at http://www.wagerlabs.com/blog/2008/02/erlang-ffi---in.html (which is a commented version of another tutorial, but it does not matter). Well, I was successful to compile the example and its pretty fine, BUT: I noticed that all exchanged parameters in port_driver.c are chars i.e.: - static void example_drv_output(ErlDrvData handle, char *buff, int bufflen) //here the input array consists of chars - driver_output(d->port, &res, 1); //here &res should point to a char, driver_output is a predefined function in erl_driver.h These limitations do not allow to send and receive any values which are bigger then 255 (and I do not want to split bigger numbers in bytes if there is a possibility to do it elegantly). Well, is there a known solution for that problem? I would like to have an int range. Cheers, Sten Gruener From erlang-questions_efine@REDACTED Fri Oct 10 18:47:08 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Fri, 10 Oct 2008 12:47:08 -0400 Subject: [erlang-questions] Types and specs [WAS: [enhancement] string:split/2] In-Reply-To: <48EF3D78.2060306@cs.ntua.gr> References: <6c2563b20810081642r2fbd1f14w8e3f7a5a2b71bcc4@mail.gmail.com> <48EF3D78.2060306@cs.ntua.gr> Message-ID: <6c2563b20810100947p4d6a638eh67d46c866fc9108a@mail.gmail.com> Question - trying to understand the spec, if I did the following: Eshell V5.6.4 (abort with ^G) 1> string:tokens([], "abc"). [] Does that violate the type specification, or does it allow for the return of an empty list? On Fri, Oct 10, 2008 at 7:33 AM, Kostis Sagonas wrote: > Richard O'Keefe wrote: > > > > Can anyone explain to me why > > > > -spec(tokens/2 :: (string(), string()) -> [[char(),...]]). > > > > doesn't mention "string()" on the right hand side of the arrow? > > There is no native string() type in Erlang, as we all well know. > > So, in the language ot types, string() is just an alias for the type > list(char()), which, for convenience, is typically written as [char()]. > This can include both the empty string "" == [] and a non-empty list > of characters, which is denoted [char(),...]. That's what the above > spec signifies: the resulting list consists of non-empty strings, which > is consistent with what string:tokens/2 actually returns. Hope this > explains things. > > On the other hand, I can see how this may look a bit strange to some and > have for a long time now pondered whether a non_empty_string() type > alias might be added to the list of built-in types. > > Kostis > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kostis@REDACTED Fri Oct 10 18:57:28 2008 From: kostis@REDACTED (Kostis Sagonas) Date: Fri, 10 Oct 2008 19:57:28 +0300 Subject: [erlang-questions] Types and specs [WAS: [enhancement] string:split/2] In-Reply-To: <6c2563b20810100947p4d6a638eh67d46c866fc9108a@mail.gmail.com> References: <6c2563b20810081642r2fbd1f14w8e3f7a5a2b71bcc4@mail.gmail.com> <48EF3D78.2060306@cs.ntua.gr> <6c2563b20810100947p4d6a638eh67d46c866fc9108a@mail.gmail.com> Message-ID: <48EF8978.1070304@cs.ntua.gr> Edwin Fine wrote: > Question - trying to understand the spec, if I did the following: > > Eshell V5.6.4 (abort with ^G) > 1> string:tokens([], "abc"). > [] > > Does that violate the type specification, or does it allow for the > return of an empty list? Note that the return type is specified as: [[char(),...]] i.e., a list of non-empty strings. The outer list can be empty or not. It's the strings inside it that cannot be empty. If the function returned a list of at least one non-empty string, it would have the following type instead: [[char(),...],...] If empty strings were allowed but there needed to be at least one of them, the return type would have been: [[char()],...] Hope this clears up the issue. Kostis > On Fri, Oct 10, 2008 at 7:33 AM, Kostis Sagonas > wrote: > > Richard O'Keefe wrote: > > > > Can anyone explain to me why > > > > -spec(tokens/2 :: (string(), string()) -> [[char(),...]]). > > > > doesn't mention "string()" on the right hand side of the arrow? > > There is no native string() type in Erlang, as we all well know. > > So, in the language ot types, string() is just an alias for the type > list(char()), which, for convenience, is typically written as [char()]. > This can include both the empty string "" == [] and a non-empty list > of characters, which is denoted [char(),...]. That's what the above > spec signifies: the resulting list consists of non-empty strings, which > is consistent with what string:tokens/2 actually returns. Hope this > explains things. > > On the other hand, I can see how this may look a bit strange to some and > have for a long time now pondered whether a non_empty_string() type > alias might be added to the list of built-in types. > > Kostis > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > From erlang-questions_efine@REDACTED Fri Oct 10 19:00:30 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Fri, 10 Oct 2008 13:00:30 -0400 Subject: [erlang-questions] Types and specs [WAS: [enhancement] string:split/2] In-Reply-To: <48EF8978.1070304@cs.ntua.gr> References: <6c2563b20810081642r2fbd1f14w8e3f7a5a2b71bcc4@mail.gmail.com> <48EF3D78.2060306@cs.ntua.gr> <6c2563b20810100947p4d6a638eh67d46c866fc9108a@mail.gmail.com> <48EF8978.1070304@cs.ntua.gr> Message-ID: <6c2563b20810101000m15925507u64b100365d914052@mail.gmail.com> > > If the function returned a list of at least one non-empty string, it would > have the following type instead: > > [[char(),...],...] > > If empty strings were allowed but there needed to be at least one of them, > the return type would have been: > > [[char()],...] > > Hope this clears up the issue. > Yes, it does. Thanks for clarifying that. -------------- next part -------------- An HTML attachment was scrubbed... URL: From hasan.veldstra@REDACTED Fri Oct 10 21:14:38 2008 From: hasan.veldstra@REDACTED (Hasan Veldstra) Date: Fri, 10 Oct 2008 20:14:38 +0100 Subject: [erlang-questions] FFI Interface - Limitation of the size of parameters In-Reply-To: References: Message-ID: Check out the ei library: http://www.erlang.org/doc/man/ei.html You can use the term_to_binary function on the Erlang side on any term and then decode that in C using functions in ei. It works the other way round too. On 10 Oct 2008, at 17:30PM, Stasik wrote: > Hello, > > I am quite new to Erland, and try to get some Erlang-C Communication. > I found a tutorial at http://www.wagerlabs.com/blog/2008/02/erlang- > ffi---in.html > (which is a commented version of another tutorial, but it does not > matter). Well, I was successful to compile the example and its pretty > fine, BUT: I noticed that all exchanged parameters in port_driver.c > are chars i.e.: > - static void example_drv_output(ErlDrvData handle, char *buff, int > bufflen) //here the input array consists of chars > - driver_output(d->port, &res, 1); //here &res should point to a char, > driver_output is a predefined function in erl_driver.h > These limitations do not allow to send and receive any values which > are bigger then 255 (and I do not want to split bigger numbers in > bytes if there is a possibility to do it elegantly). > > Well, is there a known solution for that problem? I would like to have > an int range. > > Cheers, > Sten Gruener From greg.burri@REDACTED Fri Oct 10 21:54:17 2008 From: greg.burri@REDACTED (Greg Burri) Date: Fri, 10 Oct 2008 21:54:17 +0200 Subject: [erlang-questions] Chameneos.rednux micro benchmark Message-ID: <60ed8a460810101254s5e1f3a34rb79b644a0c6e4ea@mail.gmail.com> Hi, I'm very surprise to see the differences between these two same benchmarks on shootout.alioth.debian.org : 1) Quad core : http://shootout.alioth.debian.org/u64q/benchmark.php?test=chameneosredux&lang=hipe 2) Mono core : http://shootout.alioth.debian.org/u64/benchmark.php?test=chameneosredux&lang=hipe Here are the CPU times : 1) 2095.18 s 2) 37.03 s I try on my machine[1] with a) "-smp enable" and b) "-smp disable" : a) 47.863 s b) 18.285 Maybe It's not strange to see a such difference because of inter-cpu message passing. But the difference on shootout.alioth.debian.org is too large What should we do ? /Greg [1] : (Dual-Core AMD Opteron(tm) Processor 2212 HE, 2GHz) -------------- next part -------------- An HTML attachment was scrubbed... URL: From daniel.goertzen@REDACTED Fri Oct 10 21:59:03 2008 From: daniel.goertzen@REDACTED (Daniel Goertzen) Date: Fri, 10 Oct 2008 14:59:03 -0500 Subject: [erlang-questions] write the ant simulation in Erlang? In-Reply-To: <66d1c98f0810100856r4d91c602lacb81c0b1fa9639e@mail.gmail.com> References: <859e91e70810081456w244b1c9dh74e108325ae4135c@mail.gmail.com> <7D2420AE-BA6D-4EE4-85DD-CCB6C1723DBE@cs.otago.ac.nz> <859e91e70810082144v52c0998bi140a6116c67cf12a@mail.gmail.com> <859e91e70810082146k3457bd2evc813a51beda59989@mail.gmail.com> <3dbc6d1c0810091447ye7fbc56j9d7ee5f322dd1854@mail.gmail.com> <859e91e70810092347x5903f7fdva3f44f6db99f916c@mail.gmail.com> <66d1c98f0810100856r4d91c602lacb81c0b1fa9639e@mail.gmail.com> Message-ID: How about 1 process for each cell, but no processes for the ants. The ants exist as state inside each cell and as messages interrogating neighboring cells. I think you'll get nice fine-grained localized transactions this way. Dan. 2008/10/10 Roger Critchlow > I think the world process is the right idea. It is supplying the semantics > of the language runtime in Clojure which sorts out which speculative > transactions are allowed to commit. > > Versioning of world state would need to restrict itself to the part of the > world that the ant looked at, forcing a retry any time any part of the world > had changed would be excessive. > > And I think that only moves resulting in ant-ant collisions need to be > rejected -- that the rewards of moving might change between the time we make > the decision and the time we enact the decision is unfortunate, but all too > real. The clojure ants are making decisions based on a snapshot, too, and > only retrying on collisions. > > Capturing the snapshot for display should be simple, just return the > world_loop State. > > -- rec -- > > > > On Fri, Oct 10, 2008 at 12:47 AM, Brian Zhou wrote: > >> On Thu, Oct 9, 2008 at 2:47 PM, Robert Virding >> wrote: >> > I haven't really checked the Clojure code that closely but it seems like >> a >> > reasonable problem. >> > >> > Do you know if it "turn based" or do the all the ants just move after >> their >> > own clocks in a parallel way? >> The clojure implementation uses one thread for each ant. Each ant has >> their own clock. >> >> > >> > A first approximation would be to have one process per ant and one for >> the >> > world. The only problem would be handling atomic >> > look-at-the-immediate-world-around-me-and-make-a-move. >> > >> Strictly speaking, the world state should be version'ed, the world >> process should reject the move if the world has changed since the ant >> looked, the ant process then should retry >> look-decide-and-request-move. As an optimization, I guess the world >> process can just check whether the FPA (food, pheromone, ant) value of >> the target cell has changed. >> >> I wrote a rough first cut based on the above idea: >> http://pastebin.ca/1224362 - It's not completed yet, TODO: >> 1. pheromone evaporation >> 2. initialization of the world, spawn world process, spawn ant processes >> 3. scoring candidate cells >> >> Am I on the right track? >> >> > The really difficult bit is displaying it. :-) >> > >> I'm not there yet. >> >> Thanks, >> >> -Brian >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rick.richardson@REDACTED Fri Oct 10 22:38:46 2008 From: rick.richardson@REDACTED (Rick R) Date: Fri, 10 Oct 2008 16:38:46 -0400 Subject: [erlang-questions] write the ant simulation in Erlang? In-Reply-To: References: <859e91e70810081456w244b1c9dh74e108325ae4135c@mail.gmail.com> <7D2420AE-BA6D-4EE4-85DD-CCB6C1723DBE@cs.otago.ac.nz> <859e91e70810082144v52c0998bi140a6116c67cf12a@mail.gmail.com> <859e91e70810082146k3457bd2evc813a51beda59989@mail.gmail.com> <3dbc6d1c0810091447ye7fbc56j9d7ee5f322dd1854@mail.gmail.com> <859e91e70810092347x5903f7fdva3f44f6db99f916c@mail.gmail.com> <66d1c98f0810100856r4d91c602lacb81c0b1fa9639e@mail.gmail.com> Message-ID: <9810b81b0810101338i1b5018e2p5e36bff85acbfe3c@mail.gmail.com> 2008/10/10 Daniel Goertzen > How about 1 process for each cell, but no processes for the ants. The ants > exist as state inside each cell and as messages interrogating neighboring > cells. I think you'll get nice fine-grained localized transactions this > way. > > Dan. > > Using that method, I think you'll still have the same issue with transactions. For instance: if two cells decide to move their ant to the same adjacent cell, you will have the same conflict and one ant will have to be rolled back. It may not even be more efficient message-wise because instead of the ant sending a message to an adjacent cell, the cell simply sends the same message to the adjacent cell on behalf of the ant. Of course we could go existentialist and say that there is no board except what the ants perceive, and since they can only see one square in any direction, that would imply that there is 1 process for each ant and no process for a board (or any data for that matter). This would mean that if there are no ants on a section of board it would cease to exist. The only way to reconstitute it would be to mathematically prove that it exists. e.g. The ant was at 5,5 and moved 3 east, 8 < 64, therefore, the board exists. One could extend this method with a Paxos algorithm so that the ants could achieve consensus as to the existence of Board. -------------- next part -------------- An HTML attachment was scrubbed... URL: From kevin@REDACTED Fri Oct 10 22:47:20 2008 From: kevin@REDACTED (Kevin Scaldeferri) Date: Fri, 10 Oct 2008 13:47:20 -0700 Subject: [erlang-questions] Chameneos.rednux micro benchmark In-Reply-To: <60ed8a460810101254s5e1f3a34rb79b644a0c6e4ea@mail.gmail.com> References: <60ed8a460810101254s5e1f3a34rb79b644a0c6e4ea@mail.gmail.com> Message-ID: On Oct 10, 2008, at 12:54 PM, Greg Burri wrote: > Hi, > I'm very surprise to see the differences between these two same > benchmarks on shootout.alioth.debian.org : > 1) Quad core : http://shootout.alioth.debian.org/u64q/benchmark.php?test=chameneosredux&lang=hipe > 2) Mono core : http://shootout.alioth.debian.org/u64/benchmark.php?test=chameneosredux&lang=hipe > > Here are the CPU times : > 1) 2095.18 s > 2) 37.03 s > > I try on my machine[1] with a) "-smp enable" and b) "-smp disable" : > a) 47.863 s > b) 18.285 > > Maybe It's not strange to see a such difference because of inter-cpu > message passing. But the difference on shootout.alioth.debian.org is > too large > What should we do ? Are you using HiPE? There's some chance that could explain some of the relative difference. I don't think message passing is the issue. I suspect it's lack of process affinity. The chameneos processes are likely getting bounced around between schedulers constantly. In the short term, I'm not sure what can be done other than requesting the benchmark be run with '-S 1', which really kinda defeats the purpose. It would be nice to have a different solution, as I agree that this situation is pretty embarrassing. This task is such a natural for the actor-model and Erlang; it's a shame the performance ends up being so poor. -k -------------- next part -------------- An HTML attachment was scrubbed... URL: From dmercer@REDACTED Fri Oct 10 23:43:00 2008 From: dmercer@REDACTED (David Mercer) Date: Fri, 10 Oct 2008 16:43:00 -0500 Subject: [erlang-questions] write the ant simulation in Erlang? In-Reply-To: <9810b81b0810101338i1b5018e2p5e36bff85acbfe3c@mail.gmail.com> References: <859e91e70810081456w244b1c9dh74e108325ae4135c@mail.gmail.com><7D2420AE-BA6D-4EE4-85DD-CCB6C1723DBE@cs.otago.ac.nz><859e91e70810082144v52c0998bi140a6116c67cf12a@mail.gmail.com><859e91e70810082146k3457bd2evc813a51beda59989@mail.gmail.com><3dbc6d1c0810091447ye7fbc56j9d7ee5f322dd1854@mail.gmail.com><859e91e70810092347x5903f7fdva3f44f6db99f916c@mail.gmail.com><66d1c98f0810100856r4d91c602lacb81c0b1fa9639e@mail.gmail.com> <9810b81b0810101338i1b5018e2p5e36bff85acbfe3c@mail.gmail.com> Message-ID: Actually Danny G's approach has merit. Ant on square A wants to move to square B. The messages passed are quite simple: 1. A: B ! {A, 'I have an ant who wants to move to you'} 2. B: Either: a. A ! 'Your ant moved here successfully' b. A ! 'No can do, mate; I'm already occupied' In the case of 2a, square A marks itself vacant and can now respond with its own 'Your ant moved here successfully' message when another square requests passage for its ant. In case of 2b, square A tries another square. DBM _____ From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Rick R Sent: Friday, October 10, 2008 15:39 To: Erlang-Questions (E-mail) Subject: Re: [erlang-questions] write the ant simulation in Erlang? 2008/10/10 Daniel Goertzen How about 1 process for each cell, but no processes for the ants. The ants exist as state inside each cell and as messages interrogating neighboring cells. I think you'll get nice fine-grained localized transactions this way. Dan. Using that method, I think you'll still have the same issue with transactions. For instance: if two cells decide to move their ant to the same adjacent cell, you will have the same conflict and one ant will have to be rolled back. It may not even be more efficient message-wise because instead of the ant sending a message to an adjacent cell, the cell simply sends the same message to the adjacent cell on behalf of the ant. Of course we could go existentialist and say that there is no board except what the ants perceive, and since they can only see one square in any direction, that would imply that there is 1 process for each ant and no process for a board (or any data for that matter). This would mean that if there are no ants on a section of board it would cease to exist. The only way to reconstitute it would be to mathematically prove that it exists. e.g. The ant was at 5,5 and moved 3 east, 8 < 64, therefore, the board exists. One could extend this method with a Paxos algorithm so that the ants could achieve consensus as to the existence of Board. -------------- next part -------------- An HTML attachment was scrubbed... URL: From rick.richardson@REDACTED Sat Oct 11 00:37:47 2008 From: rick.richardson@REDACTED (Rick R) Date: Fri, 10 Oct 2008 18:37:47 -0400 Subject: [erlang-questions] write the ant simulation in Erlang? In-Reply-To: References: <859e91e70810081456w244b1c9dh74e108325ae4135c@mail.gmail.com> <7D2420AE-BA6D-4EE4-85DD-CCB6C1723DBE@cs.otago.ac.nz> <859e91e70810082144v52c0998bi140a6116c67cf12a@mail.gmail.com> <859e91e70810082146k3457bd2evc813a51beda59989@mail.gmail.com> <3dbc6d1c0810091447ye7fbc56j9d7ee5f322dd1854@mail.gmail.com> <859e91e70810092347x5903f7fdva3f44f6db99f916c@mail.gmail.com> <66d1c98f0810100856r4d91c602lacb81c0b1fa9639e@mail.gmail.com> <9810b81b0810101338i1b5018e2p5e36bff85acbfe3c@mail.gmail.com> Message-ID: <9810b81b0810101537w5c0e422fn81c4111dc585339b@mail.gmail.com> You're right. I didn't think it through at all. Better than decreasing the amount of messages, it avoids having to transact (or resolve conflicts) at all. The cell can have three states, empty, full, or pending. Pending would be that it is waiting for a response from an adjacent cell on whether it's ant can move there. It would simply delay any of its own responses until receiving a response from it's suitor. One could argue for a fourth state which is empty-but-expecting. But if an ant is guaranteed to travel to your location once you've agreed to let it, then this state is as good as full. Not treating the ant as its own actor does take the fun (and the expense) out it. On Fri, Oct 10, 2008 at 5:43 PM, David Mercer wrote: > Actually Danny G's approach has merit. Ant on square A wants to move to > square B. The messages passed are quite simple: > > > > 1. A: B ! {A, 'I have an ant who wants to move to you'} > 2. B: Either: > 1. A ! 'Your ant moved here successfully' > 2. A ! 'No can do, mate; I'm already occupied' > > > > In the case of 2a, square A marks itself vacant and can now respond with > its own 'Your ant moved here successfully' message when another square > requests passage for its ant. In case of 2b, square A tries another square. > > > > DBM > > > > > > > ------------------------------ > > *From:* erlang-questions-bounces@REDACTED [mailto: > erlang-questions-bounces@REDACTED] *On Behalf Of *Rick R > *Sent:* Friday, October 10, 2008 15:39 > *To:* Erlang-Questions (E-mail) > *Subject:* Re: [erlang-questions] write the ant simulation in Erlang? > > > > > > 2008/10/10 Daniel Goertzen > > How about 1 process for each cell, but no processes for the ants. The ants > exist as state inside each cell and as messages interrogating neighboring > cells. I think you'll get nice fine-grained localized transactions this > way. > > Dan. > > > Using that method, I think you'll still have the same issue with > transactions. For instance: if two cells decide to move their ant to the > same adjacent cell, you will have the same conflict and one ant will have to > be rolled back. > It may not even be more efficient message-wise because instead of the ant > sending a message to an adjacent cell, the cell simply sends the same > message to the adjacent cell on behalf of the ant. > > Of course we could go existentialist and say that there is no board except > what the ants perceive, and since they can only see one square in any > direction, that would imply that there is 1 process for each ant and no > process for a board (or any data for that matter). This would mean that if > there are no ants on a section of board it would cease to exist. The only > way to reconstitute it would be to mathematically prove that it exists. e.g. > The ant was at 5,5 and moved 3 east, 8 < 64, therefore, the board exists. > > One could extend this method with a Paxos algorithm so that the ants could > achieve consensus as to the existence of Board. > > -- "Have more than thou showest, Speak less than thou knowest, Lend less than thou owest, Ride more than thou goest." -- The Fool to King Lear -------------- next part -------------- An HTML attachment was scrubbed... URL: From erlang-questions_efine@REDACTED Sat Oct 11 01:19:14 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Fri, 10 Oct 2008 19:19:14 -0400 Subject: [erlang-questions] Chameneos.rednux micro benchmark In-Reply-To: References: <60ed8a460810101254s5e1f3a34rb79b644a0c6e4ea@mail.gmail.com> Message-ID: <6c2563b20810101619m5c373e1bhe9d0aad36fc2a06d@mail.gmail.com> It was run with HiPE. It's mentioned on the page that has the Erlang code. I was curious so I ran it on my configuration (Ubuntu 8.04 x86_64, 2.4GHz Q6600, 8GB RAM, Erlang R12B-4). Here's the bottom line. *When I ran it with -smp disable there was a* *monumentally huge* *(91.8x) * *performance boost* *over when I ran it with smp enabled*. That was without HiPE. Adding HiPE speeded the SMP version up by about 20% or so. The performance difference between the non-SMP HiPE and non-HiPE versions was about 80x. # *SMP without HiPE *$ time /usr/local/bin/erl +K true -noshell -run chameneosredux main 6000000 *real 11m24.231s *user 20m25.933s sys 1m49.315s # *SMP with HiPE * $ time /usr/local/bin/erl +K true -noshell -run chameneosredux main 6000000 *real 9m19.138s* user 16m28.374s sys 1m49.899s # *SMP disabled, without HiPE *$ time /usr/local/bin/erl -smp disable +K true -noshell -run chameneosredux main 6000000 *real 0m7.451s *user 0m7.404s sys 0m0.048s # *SMP disabled, with HiPE *$ time /usr/local/bin/erl -smp disable +K true -noshell -run chameneosredux main 6000000 *real 0m6.970s *user 0m6.864s sys 0m0.104s So if it's not CPU-bound (60% idle), and it's not memory capacity bound (virtual memory usage only 78MB), and it's not disk or network I/O bound, what is it? A run of vmstat showed a minimum of about *15,000 context switches per second* and often more. Without the program running, there were *only about 500 or so per second*. procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu---- r b swpd free buff cache si so bi bo in cs us sy id wa 6 0 371656 651900 646988 967940 0 0 0 0 67 15781 44 1 55 0 3 0 371656 651900 646992 967936 0 0 0 4 179 18291 44 2 54 0 1 0 371656 651900 646992 967940 0 0 0 0 61 28605 44 2 54 0 2 0 371656 651892 646992 967940 0 0 0 0 156 15751 42 1 57 0 3 0 371656 651900 646992 967940 0 0 0 0 61 78329 47 6 48 0 3 0 371656 651776 646992 967940 0 0 0 0 156 15081 43 1 56 0 3 0 371656 651776 646992 967940 0 0 0 0 61 15800 44 1 55 0 2 0 371656 651776 646996 967936 0 0 0 4 157 15393 44 1 55 0 2 0 371656 651760 646996 967940 0 0 0 0 62 16251 46 1 53 0 2 0 371656 651776 646996 967940 0 0 0 0 156 35213 43 4 53 0 I ran again with vmstat and -*smp disabled*. vmstat showed *no noticable difference* in the cs column *when the program was running compared to when it was not*: 0 0 371656 707156 624840 947328 0 0 0 28 110 453 0 0 100 0 0 0 371656 707148 624840 947328 0 0 0 0 285 775 0 0 99 0 0 0 371656 707140 624840 947328 0 0 0 0 102 537 0 0 100 0 0 0 371656 707148 624840 947328 0 0 0 0 172 597 0 0 100 0 0 0 371656 707148 624840 947328 0 0 0 0 113 532 0 0 100 0 1 0 371656 700460 624840 947328 32 0 32 0 204 1290 24 1 75 0 1 0 371656 700436 624840 947328 0 0 0 0 71 655 28 0 72 0 1 0 371656 700412 624844 947324 0 0 0 44 302 994 26 0 74 0 1 0 371656 700436 624844 947328 0 0 0 0 98 520 26 0 74 0 1 0 371656 700436 624844 947328 0 0 0 0 156 558 25 0 75 0 1 0 371656 700428 624844 947328 0 0 0 0 76 431 25 0 74 0 Tentative conclusion: this benchmark makes SMP Erlang do an excessive number of context switches. Is that because it is jumping between cores, or because of inter-process communication between cores? I can't answer that fully, but I can see what happens if we retrict it to one core using one VM. And the answer is: *vmstat shows that using taskset and +S 1, the context switches go down to about the same level as if you were not running with SMP *. It's still about 3x slower than -smp disable, though, but orders of magnitude faster than using all processors with SMP. * # SMP, Without HiPE, one scheduler, affinitied to CPU 2* $ time taskset -c 2 /usr/local/bin/erl +S 1 -noshell -noinput -run chameneosredux main 6000000 *real 0m24.296s* user 0m24.270s sys 0m0.004s Last one. What about using +K true to user kernel poll? No significant difference. *real 0m24.006s* user 0m23.998s sys 0m0.012s I tried capturing the output of various runs using strace but it's going to take me a while to interpret the results (if I can even do that) and rerun it until it makes sense. I don't know if it makes sense to try to use strace with Erlang. I'll have to do some Googling. Regards, Edwin Fine 2008/10/10 Kevin Scaldeferri > > On Oct 10, 2008, at 12:54 PM, Greg Burri wrote: > > Hi, > I'm very surprise to see the differences between these two same benchmarks > on shootout.alioth.debian.org : > 1) Quad core : > http://shootout.alioth.debian.org/u64q/benchmark.php?test=chameneosredux&lang=hipe > 2) Mono core : > http://shootout.alioth.debian.org/u64/benchmark.php?test=chameneosredux&lang=hipe > > Here are the CPU times : > 1) 2095.18 s > 2) 37.03 s > > I try on my machine[1] with a) "-smp enable" and b) "-smp disable" : > a) 47.863 s > b) 18.285 > > Maybe It's not strange to see a such difference because of inter-cpu > message passing. But the difference on shootout.alioth.debian.org is too > large > What should we do ? > > > Are you using HiPE? There's some chance that could explain some of the > relative difference. > > I don't think message passing is the issue. I suspect it's lack of process > affinity. The chameneos processes are likely getting bounced around between > schedulers constantly. > > In the short term, I'm not sure what can be done other than requesting the > benchmark be run with '-S 1', which really kinda defeats the purpose. It > would be nice to have a different solution, as I agree that this situation > is pretty embarrassing. This task is such a natural for the actor-model and > Erlang; it's a shame the performance ends up being so poor. > > -k > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dmercer@REDACTED Sat Oct 11 06:12:05 2008 From: dmercer@REDACTED (David Mercer) Date: Fri, 10 Oct 2008 23:12:05 -0500 Subject: [erlang-questions] write the ant simulation in Erlang? In-Reply-To: <9810b81b0810101537w5c0e422fn81c4111dc585339b@mail.gmail.com> References: <859e91e70810081456w244b1c9dh74e108325ae4135c@mail.gmail.com> <859e91e70810082144v52c0998bi140a6116c67cf12a@mail.gmail.com> <859e91e70810082146k3457bd2evc813a51beda59989@mail.gmail.com> <3dbc6d1c0810091447ye7fbc56j9d7ee5f322dd1854@mail.gmail.com> <859e91e70810092347x5903f7fdva3f44f6db99f916c@mail.gmail.com> <66d1c98f0810100856r4d91c602lacb81c0b1fa9639e@mail.gmail.com> <9810b81b0810101338i1b5018e2p5e36bff85acbfe3c@mail.gmail.com> <9810b81b0810101537w5c0e422fn81c4111dc585339b@mail.gmail.com> Message-ID: Actually, I'd just have two states: ant and antless. Your pending state could result in deadlocks. David On Fri, Oct 10, 2008 at 5:37 PM, Rick R wrote: > You're right. I didn't think it through at all. > Better than decreasing the amount of messages, it avoids having to transact > (or resolve conflicts) at all. > The cell can have three states, empty, full, or pending. Pending would be > that it is waiting for a response from an adjacent cell on whether it's ant > can move there. It would simply delay any of its own responses until > receiving a response from it's suitor. > > One could argue for a fourth state which is empty-but-expecting. But if an > ant is guaranteed to travel to your location once you've agreed to let it, > then this state is as good as full. > > Not treating the ant as its own actor does take the fun (and the expense) > out it. > > On Fri, Oct 10, 2008 at 5:43 PM, David Mercer wrote: > >> Actually Danny G's approach has merit. Ant on square A wants to move to >> square B. The messages passed are quite simple: >> >> >> >> 1. A: B ! {A, 'I have an ant who wants to move to you'} >> 2. B: Either: >> 1. A ! 'Your ant moved here successfully' >> 2. A ! 'No can do, mate; I'm already occupied' >> >> >> >> In the case of 2a, square A marks itself vacant and can now respond with >> its own 'Your ant moved here successfully' message when another square >> requests passage for its ant. In case of 2b, square A tries another square. >> >> >> >> DBM >> >> >> >> >> >> >> ------------------------------ >> >> *From:* erlang-questions-bounces@REDACTED [mailto: >> erlang-questions-bounces@REDACTED] *On Behalf Of *Rick R >> *Sent:* Friday, October 10, 2008 15:39 >> *To:* Erlang-Questions (E-mail) >> *Subject:* Re: [erlang-questions] write the ant simulation in Erlang? >> >> >> >> >> >> 2008/10/10 Daniel Goertzen >> >> How about 1 process for each cell, but no processes for the ants. The >> ants exist as state inside each cell and as messages interrogating >> neighboring cells. I think you'll get nice fine-grained localized >> transactions this way. >> >> Dan. >> >> >> Using that method, I think you'll still have the same issue with >> transactions. For instance: if two cells decide to move their ant to the >> same adjacent cell, you will have the same conflict and one ant will have to >> be rolled back. >> It may not even be more efficient message-wise because instead of the ant >> sending a message to an adjacent cell, the cell simply sends the same >> message to the adjacent cell on behalf of the ant. >> >> Of course we could go existentialist and say that there is no board except >> what the ants perceive, and since they can only see one square in any >> direction, that would imply that there is 1 process for each ant and no >> process for a board (or any data for that matter). This would mean that if >> there are no ants on a section of board it would cease to exist. The only >> way to reconstitute it would be to mathematically prove that it exists. e.g. >> The ant was at 5,5 and moved 3 east, 8 < 64, therefore, the board exists. >> >> One could extend this method with a Paxos algorithm so that the ants could >> achieve consensus as to the existence of Board. >> >> > > > -- > "Have more than thou showest, > Speak less than thou knowest, > Lend less than thou owest, > Ride more than thou goest." > -- The Fool to King Lear > -------------- next part -------------- An HTML attachment was scrubbed... URL: From steven.charles.davis@REDACTED Sat Oct 11 11:36:24 2008 From: steven.charles.davis@REDACTED (Steve Davis) Date: Sat, 11 Oct 2008 02:36:24 -0700 (PDT) Subject: [erlang-questions] Why is query a reserved word Message-ID: I notice that query is a reserved word in erlang - anyone know why? It's the first/most obvious function name you'd choose when dealing with a data store, so i'm interested in why it's reserved... From steven.charles.davis@REDACTED Sat Oct 11 11:46:55 2008 From: steven.charles.davis@REDACTED (Steve Davis) Date: Sat, 11 Oct 2008 04:46:55 -0500 Subject: [erlang-questions] Just curious - why is "query" a reserved word? Message-ID: <48F0760F.5010101@gmail.com> It's one of the most obvious choices of function name when dealing with persistent storage - and I notice that e.g. erlyweb has used q(), q1(), etc instead probably *because* query is a reserved word. So I'm curious as to why it is reserved? /s From Lennart.Ohman@REDACTED Sat Oct 11 12:35:54 2008 From: Lennart.Ohman@REDACTED (=?iso-8859-1?Q?Lennart_=D6hman?=) Date: Sat, 11 Oct 2008 12:35:54 +0200 Subject: [erlang-questions] Why is query a reserved word In-Reply-To: References: Message-ID: Hi, it was used in defining a Mnemosyne query - a now obsoleted Mnesia query language. Check R11B documentation if you are interested in learning more about Mnemosyne. Best Regards Lennart ________________________________________ From: erlang-questions-bounces@REDACTED [erlang-questions-bounces@REDACTED] On Behalf Of Steve Davis [steven.charles.davis@REDACTED] Sent: Saturday, October 11, 2008 11:36 AM To: erlang-questions@REDACTED Subject: [erlang-questions] Why is query a reserved word I notice that query is a reserved word in erlang - anyone know why? It's the first/most obvious function name you'd choose when dealing with a data store, so i'm interested in why it's reserved... _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions From steven.charles.davis@REDACTED Sat Oct 11 12:53:02 2008 From: steven.charles.davis@REDACTED (Steve Davis) Date: Sat, 11 Oct 2008 05:53:02 -0500 Subject: [erlang-questions] Why is query a reserved word In-Reply-To: References: Message-ID: <48F0858E.8050501@gmail.com> Thanks, Lennart - I figured there must be some historical reason. Umm... anyone know if there's a chance that it will be "unreserved" in the future? /s Lennart ?hman wrote: > Hi, > it was used in defining a Mnemosyne query - a now obsoleted Mnesia query language. > Check R11B documentation if you are interested in learning more about Mnemosyne. > > Best Regards > Lennart > > ________________________________________ > From: erlang-questions-bounces@REDACTED [erlang-questions-bounces@REDACTED] On Behalf Of Steve Davis [steven.charles.davis@REDACTED] > Sent: Saturday, October 11, 2008 11:36 AM > To: erlang-questions@REDACTED > Subject: [erlang-questions] Why is query a reserved word > > I notice that query is a reserved word in erlang - anyone know why? > It's the first/most obvious function name you'd choose when dealing > with a data store, so i'm interested in why it's reserved... > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From erlang-questions_efine@REDACTED Sat Oct 11 18:21:03 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Sat, 11 Oct 2008 12:21:03 -0400 Subject: [erlang-questions] What erlc flags are needed to compile native (HiPE) to run on smp-disabled runtime? Message-ID: <6c2563b20810110921n28ff218p7707902cf0b29b5d@mail.gmail.com> To generate native code for smp-enabled runtime using erlc is easy. I can't seem to make it happen for smp disabled runtime. If I start up Erlang with -smp disable and compile from within Erlang, then it does what I want (creates a natively-compiled beam for non-smp use). $ erl -smp disable 1> c(mymodule, [native, {hipe, o3}]) {ok,mymodule} 8> But this is very inconvenient if a build system is created that relies on erlc. Is there a better way? -------------- next part -------------- An HTML attachment was scrubbed... URL: From kevin@REDACTED Sat Oct 11 18:59:27 2008 From: kevin@REDACTED (Kevin Scaldeferri) Date: Sat, 11 Oct 2008 09:59:27 -0700 Subject: [erlang-questions] Fwd: Chameneos.rednux micro benchmark References: Message-ID: [sigh... hit Reply instead of Reply All] Begin forwarded message: > From: Kevin Scaldeferri > Date: October 10, 2008 6:31:27 PM PDT > To: "Edwin Fine" > Subject: Re: [erlang-questions] Chameneos.rednux micro benchmark > > > On Oct 10, 2008, at 4:19 PM, Edwin Fine wrote: > >> It was run with HiPE. It's mentioned on the page that has the >> Erlang code. > > I was actually asking about when you ran it. I did know that the > benchmark site uses HiPE. > >> >> A run of vmstat showed a minimum of about 15,000 context switches >> per second and often more. Without the program running, there were >> only about 500 or so per second. >> ... >> >> I ran again with vmstat and -smp disabled. vmstat showed no >> noticable difference in the cs column when the program was running >> compared to when it was not: >> >> ... >> >> Tentative conclusion: this benchmark makes SMP Erlang do an >> excessive number of context switches. Is that because it is jumping >> between cores, or because of inter-process communication between >> cores? I can't answer that fully, but I can see what happens if we >> retrict it to one core using one VM. > > This is not all that surprising. Consider the part of the benchmark > where there are 3 chameneos participating. Each of them, and the > parent, will likely end up on their own scheduler (on quad-core). > They all send a message then go to sleep. The parent receives the > messages, processes some, goes to sleep. Children wake up, get > messages, send message, go to sleep. Repeat. You can see that for > much of the time, many of the schedules have nothing to do, and > their threads may be switched out. > > Without SMP, all the Erlang processes run in the same scheduler > thread, and there is always work to be done, so no or few context > switches. > > Of course, for the portion with 10 chameneos, there is more often > work that can be done, but maybe still not enough to saturate all > the cores all the time. > >> >> >> So if it's not CPU-bound (60% idle), and it's not memory capacity >> bound (virtual memory usage only 78MB), and it's not disk or >> network I/O bound, what is it? > > a) as explained above, there are synchronization requirements as > part of the game that may make it difficult to saturate all the CPUs > > b) I also speculated that migrating processes from one thread (core) > to another may be significant. I'm not really sure where to look in > the OS stats to find evidence to support this. (I guess you'd want > to see if the memory bus is saturated.) > > > > I should also point out that it seems like there is either a > significant different between Erlang running on 2 and 4 cores, or > between the chip architectures themselves. Running parallel > versions of other benchmarks on my 2-core hardware, I usually find > that the total CPU time used is only slightly higher than a single- > process version. However, on the Alioth 4-core hardware, the total > CPU usage is about double. (Look at the two Erlang version for > binary-trees and mandelbrot). I am inclined to think Erlang is to > blame, if only because the Haskell entries don't show the same > behavior. > > > > -kevin > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf@REDACTED Sat Oct 11 19:08:40 2008 From: ulf@REDACTED (Ulf Wiger) Date: Sat, 11 Oct 2008 19:08:40 +0200 Subject: [erlang-questions] Just curious - why is "query" a reserved word? In-Reply-To: <48F0760F.5010101@gmail.com> References: <48F0760F.5010101@gmail.com> Message-ID: <8209f740810111008u20725ff5p84e999856210073b@mail.gmail.com> It was used by mnemosyne list comprehensions. BR, Ulf W 2008/10/11, Steve Davis : > It's one of the most obvious choices of function name when dealing with > persistent storage - and I notice that e.g. erlyweb has used q(), q1(), > etc instead probably *because* query is a reserved word. So I'm curious > as to why it is reserved? > > /s > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From erlang-questions_efine@REDACTED Sat Oct 11 21:13:06 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Sat, 11 Oct 2008 15:13:06 -0400 Subject: [erlang-questions] Lots of questions about error_logger In-Reply-To: <3bff71aa0810100809w1b5282dfhd7bd06876f255605@mail.gmail.com> References: <3bff71aa0810100809w1b5282dfhd7bd06876f255605@mail.gmail.com> Message-ID: <6c2563b20810111213h13ceae5fy11e588323b10e3d0@mail.gmail.com> On Fri, Oct 10, 2008 at 11:09 AM, Sergey A. wrote: > Hello. > > In the first place, sorry for several different questions placed in > one letter. I know it's something wearily to answer a list of > questions. > > I tried using error_logger as a tool for handling error reports and > I've came across some oddities: > > #1. Is there a way to set SASL options (I'm about sasl_error_logger, > errlog_type etc) from the Erlang code at runtime without using a > .config file + the "-config" argument? Possibly, but I don't know how. I just want to give an end user > only one config file to edit and use values from that to setup SASL. You can put the sasl config along with other application configs. You can pass application environment variables in this way to your own apps. This usually goes into a file named sys.config, which is expected (or at least standard) if you use Erlang release management (see http://www.erlang.org/doc/man/systools.html). [ {sasl, [ {sasl_error_logger, {file, "/data/shg/log_base/shg.sasl_log"}} ]}, {myapp1, [ {myappvar1, "value1"}, {myappvar2, value2} ] } ]. %% <-- dot and whitespace Remember to have a dot and whitespace at end of file as shown above. > #2. The following is from the "Programming Erlang": > > --[Beginning of quote]------------------------------------------------- > The next configuration file lists error reports in the shell, and a copy of > everything reported in the shell is also made to a file: > > %% single text file - minimal tty > [{sasl, [ > %% All reports go to this file > {sasl_error_logger, {file, "/home/joe/error_logs/THELOG" }} > ]}]." > --[End of quote]------------------------------------------------- > > I replaced the path to just "THELOG" and then run the shell: > > --[Beginning of erl > session]------------------------------------------------- > erl -boot start_sasl -config elog2.config > > Erlang (BEAM) emulator version 5.6.3 [source] [smp:2] > [async-threads:0] [hipe] [kernel-poll:false] > > Eshell V5.6.3 (abort with ^G) > 1> error_logger:error_msg("foobar~n"). > ok > > =ERROR REPORT==== 10-Oct-2008::03:19:38 === > foobar > 2> error_logger:error_report("foobar\n"). > > =ERROR REPORT==== 10-Oct-2008::03:21:05 === > foobar > > ok > 3> > User switch command > --> q > --[End of erl session]------------------------------------------------- > > But after all, THELOG doesn't contain any string related to my > foobar-errors! Just only progress reports! Why does this happen? > The standard error log handler in SASL only logs supervisor reports, crashes and progress reports. Take a look at http://www.erlang.org/doc/apps/sasl/index.html, from which the following was extracted: Error Logger Event Handlers The following error logger event handlers are defined in the SASL application. sasl_report_tty_h Formats and writes *supervisor reports*, *crash reports*and *progress reports* to stdio. sasl_report_file_h Formats and writes *supervisor reports*, *crash report*and *progress report* to a single file. error_logger_mf_h This error logger writes *all* events sent to the error logger to disk. It installs the log_mf_h event handler in the error_loggerprocess.You need to configure the error_logger_mf_h to get what you have logged, for example: [ { sasl, [ % All supervisor, crash, and progress reports go to this file {sasl_error_logger, {file, "/tmp/error_logs/sasl_log" }}, % And to these files, too {error_logger_mf_dir, "/tmp/error_logs"}, {error_logger_mf_maxbytes, 10000000}, {error_logger_mf_maxfiles, 10} ] } ]. > #3. If I decide to use rotating of logs, those logs will be written in > binary format. What are the benefits of using binary format for > storing logs? The binary format files are very fast to write and more compact than ASCII logs. However, they are much less convenient to browse. I think many people use ASCII logs, but you have to be careful and not flood your system with logs. > Is there possibility to force Erlang to use plain text > files instead of binary ones? > Yes, but you have to provide your own error logger callback module. Fortunately, there is at least one I know of that is publicly available, in Jungerl. You'll need to get these: http://jungerl.cvs.sourceforge.net/viewvc/jungerl/jungerl/lib/msc/src/disk_log_h.erl?revision=1.2&view=markup http://jungerl.cvs.sourceforge.net/viewvc/jungerl/jungerl/lib/msc/src/logger.erl?revision=1.2&view=markup The files contain documentation on how to install and use these. I've used them for quite a while with no problems. > > #4. What is the "index" file for? > I dunno. I think it's for the wrap logs, to ell the logger which number to use next. So if you are running 10 logs, they start off at 1. Once they get to 10, they start at 1 again. I think the index file contains the next index. Let's find out. 1> file:read_file("index"). {ok,<<2>>} 2> Yes, looks like it's just a binary integer that has the next wrap index. > > #5. Quote from Programming Erlang: > --[Beginning of quote]------------------------------------------------- > In a production environment, we are really interested only in errors and > not progress or information reports, so we tell the error logger to report > only errors. Without this setting, the system might get swamped with > information and progress reports. > Download elog4.config > %% rotating log and errors > [{sasl, [ > %% minimise shell error logging > {sasl_error_logger, false}, > %% only report errors > {errlog_type, error}, > %% define the parameters of the rotating log > %% the log file directory > {error_logger_mf_dir,"/home/joe/error_logs" }, > %% # bytes per logfile > {error_logger_mf_maxbytes,10485760}, % 10 MB > %% maximum number of > {error_logger_mf_maxfiles, 10} > ]}]. > --[End of quote]------------------------------------------------- > > But using this config I see some progress reports: > > 3> rb:list(). > No Type Process Date Time > == ==== ======= ==== ==== > 6 progress <0.30.0> 2008-10-10 03:39:59 > 5 progress <0.30.0> 2008-10-10 03:39:59 > 4 progress <0.30.0> 2008-10-10 03:39:59 > 3 progress <0.30.0> 2008-10-10 03:39:59 > 2 progress <0.23.0> 2008-10-10 03:39:59 > 1 error <0.24.0> 2008-10-10 03:40:20 > ok > > What is wrong? When you put in {sasl_error_logger, false}, the {errlog_type, error} is ignored because it pertains only to the sasl_error_logger file. If {sasl_error_logger, {file, "foo.bar"}} was specified, then {errlog_type, error} would mean, "Put only errors into foo.bar". It has no control over what goes into the error_logger_mf binary files. It appears (AFAIK) that SASL will always log progress reports and crash reports to the binary file(s) controlled by error_logger_mf, if they are configured, but because you specified {sasl_error_logger, false} they are not being duplicated into a separate SASL ASCII log file, e.g. "foo.bar". Hope this makes sense. P.S. Sorry for the possible English mistakes in my letter =) Your English is pretty good, actually. Hope this helps. Edwin -------------- next part -------------- An HTML attachment was scrubbed... URL: From igouy2@REDACTED Sat Oct 11 23:00:09 2008 From: igouy2@REDACTED (Isaac Gouy) Date: Sat, 11 Oct 2008 14:00:09 -0700 (PDT) Subject: [erlang-questions] Chameneos.rednux micro benchmark Message-ID: <1688.88913.qm@web65409.mail.ac4.yahoo.com> On Oct 11, 2008, Edwin Fine wrote: -snip- > I was curious so I ran it on my configuration (Ubuntu 8.04 x86_64, > 2.4GHz Q6600, 8GB RAM, Erlang R12B-4). That configuration seems fairly similar - Ubuntu 8.04 x86_64, 2.4GHz Q6600, 4GB RAM, Erlang R12B-2 - but # *SMP without HiPE $ time /usr/local/src/otp_src_R12B-2/bin/erl -noshell -run chameneosredux main 6000000 real 18m31.693s user 35m41.518s sys 0m58.836s # *SMP disabled, without HiPE $ time /usr/local/src/otp_src_R12B-2/bin/erl -smp disable -noshell -run chameneosredux main 6000000 real 0m7.692s user 0m7.516s sys 0m0.100s From igouy2@REDACTED Sat Oct 11 23:29:44 2008 From: igouy2@REDACTED (Isaac Gouy) Date: Sat, 11 Oct 2008 14:29:44 -0700 (PDT) Subject: [erlang-questions] Chameneos.rednux micro benchmark Message-ID: <305780.85834.qm@web65410.mail.ac4.yahoo.com> If I compile for HiPE like this: /usr/local/bin/erlc +native +"{hipe, [o3]}" binarytrees.erl then trying to use -smp disable gives warnings like this: < =INFO REPORT==== 10-Oct-2008::17:33:14 === < Warning: not loading native code for module binarytrees: it was compiled for an incompatible runtime system; please regenerate native code for this runtime system Are there erlc command line options that would allow programs to be compiled for HiPE and run with -smp disable ? From tty.erlang@REDACTED Sun Oct 12 04:41:59 2008 From: tty.erlang@REDACTED (t ty) Date: Sat, 11 Oct 2008 22:41:59 -0400 Subject: [erlang-questions] Why is query a reserved word In-Reply-To: References: Message-ID: <290b3ba10810111941x234d54c0v1eda3fce665fb2e2@mail.gmail.com> It was a keyword for mnemosyne which has been superseded by QLC. If you are curious: http://web.mit.edu/erlang_vR11B-5/arch/sun4x_510/lib/erlang/lib/mnemosyne-1.2.7.1/doc/html/mnemosyne.html t On Sat, Oct 11, 2008 at 5:36 AM, Steve Davis wrote: > I notice that query is a reserved word in erlang - anyone know why? > It's the first/most obvious function name you'd choose when dealing > with a data store, so i'm interested in why it's reserved... > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From kenji.rikitake@REDACTED Sun Oct 12 07:44:44 2008 From: kenji.rikitake@REDACTED (Kenji Rikitake) Date: Sun, 12 Oct 2008 14:44:44 +0900 Subject: [erlang-questions] Chameneos.rednux micro benchmark In-Reply-To: <1688.88913.qm@web65409.mail.ac4.yahoo.com> References: <1688.88913.qm@web65409.mail.ac4.yahoo.com> Message-ID: <20081012054444.GA1517@k2r.org> Using the source code available at: http://shootout.alioth.debian.org/gp4/benchmark.php?test=chameneosredux&lang=hipe&id=1 FreeBSD 7.0-RELEASE i386 1.6GHz L2400 1.5GB RAM Erlang E12B-4 without HiPE compiled with stock gcc-4.2.1 % SMP enabled, without HiPE % time erl -smp enable -noshell -run chameneosredux main 6000000 199.488u 3.733s 1:42.93 197.4% 1833+689k 0+0io 0pf+0w % SMP disabled, without HiPE % time erl -smp disable -noshell -run chameneosredux main 6000000 36.405u 0.517s 0:37.02 99.7% 1690+826k 0+0io 0pf+0w FYI Kenji Rikitake From kenneth.lundin@REDACTED Sun Oct 12 09:27:26 2008 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Sun, 12 Oct 2008 09:27:26 +0200 Subject: [erlang-questions] Fwd: Chameneos.rednux micro benchmark In-Reply-To: References: Message-ID: Hi, It is not at all surprising that the SMP version run much slower than the non SMP version. I looked at the program source and what I find there is an implementation that does not allow very much of parallell execution. The broker process is clearly a bottleneck since it is involved in everything. Every other process must wait for the broker process before it can continue it's execution. The other processes are also doing so little useful work so the task-switching and locking around the run-queue will become the dominating thing. When you have benchmarks with parallell processes that hardly perform any work and all processes are highly dependent on other processes, you can expect results like this, there is nothing wrong or bad with the ERlang SMP implementation because of that. It is the same with a SW project, do you think a 100 line program will be finished faster if you have 100 programmers instead of one? /Kenneth Erlang/OTP team, Ericsson 2008/10/11 Kevin Scaldeferri : > [sigh... hit Reply instead of Reply All] > > Begin forwarded message: > > From: Kevin Scaldeferri > Date: October 10, 2008 6:31:27 PM PDT > To: "Edwin Fine" > Subject: Re: [erlang-questions] Chameneos.rednux micro benchmark > > On Oct 10, 2008, at 4:19 PM, Edwin Fine wrote: > > It was run with HiPE. It's mentioned on the page that has the Erlang code. > > I was actually asking about when you ran it. I did know that the benchmark > site uses HiPE. > > A run of vmstat showed a minimum of about 15,000 context switches per second > and often more. Without the program running, there were only about 500 or so > per second. > ... > > I ran again with vmstat and -smp disabled. vmstat showed no noticable > difference in the cs column when the program was running compared to when it > was not: > > ... > > Tentative conclusion: this benchmark makes SMP Erlang do an excessive number > of context switches. Is that because it is jumping between cores, or because > of inter-process communication between cores? I can't answer that fully, but > I can see what happens if we retrict it to one core using one VM. > > This is not all that surprising. Consider the part of the benchmark where > there are 3 chameneos participating. Each of them, and the parent, will > likely end up on their own scheduler (on quad-core). They all send a > message then go to sleep. The parent receives the messages, processes some, > goes to sleep. Children wake up, get messages, send message, go to sleep. > Repeat. You can see that for much of the time, many of the schedules have > nothing to do, and their threads may be switched out. > Without SMP, all the Erlang processes run in the same scheduler thread, and > there is always work to be done, so no or few context switches. > Of course, for the portion with 10 chameneos, there is more often work that > can be done, but maybe still not enough to saturate all the cores all the > time. > > > So if it's not CPU-bound (60% idle), and it's not memory capacity bound > (virtual memory usage only 78MB), and it's not disk or network I/O bound, > what is it? > > a) as explained above, there are synchronization requirements as part of the > game that may make it difficult to saturate all the CPUs > b) I also speculated that migrating processes from one thread (core) to > another may be significant. I'm not really sure where to look in the OS > stats to find evidence to support this. (I guess you'd want to see if the > memory bus is saturated.) > > > I should also point out that it seems like there is either a significant > different between Erlang running on 2 and 4 cores, or between the chip > architectures themselves. Running parallel versions of other benchmarks on > my 2-core hardware, I usually find that the total CPU time used is only > slightly higher than a single-process version. However, on the Alioth > 4-core hardware, the total CPU usage is about double. (Look at the two > Erlang version for binary-trees and mandelbrot). I am inclined to think > Erlang is to blame, if only because the Haskell entries don't show the same > behavior. > > > -kevin > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From qiulang@REDACTED Sun Oct 12 18:20:05 2008 From: qiulang@REDACTED (lang qiu) Date: Mon, 13 Oct 2008 00:20:05 +0800 Subject: [erlang-questions] confused by the grammar of split_binary/2 in the example of mp3_sync Message-ID: Hi, I am confused by the grammar of split_binary/2 in the example of mp3_sync in the book "Programming Erlang", get_word(N, Bin) -> * {_,<>} = split_binary(Bin, N), C.* I understand that *@spec split_binary(Bin, Pos)* -> {Bin1, Bin2} but how does the above clause work ? How does it make C get the first 4 bytes of Bin starting from N ? Thanks! -------------- next part -------------- An HTML attachment was scrubbed... URL: From kevin@REDACTED Sun Oct 12 18:25:46 2008 From: kevin@REDACTED (Kevin Scaldeferri) Date: Sun, 12 Oct 2008 09:25:46 -0700 Subject: [erlang-questions] Fwd: Chameneos.rednux micro benchmark In-Reply-To: References: Message-ID: <502F3A34-13DE-4DB7-AD5B-A8434416A97B@scaldeferri.com> On Oct 12, 2008, at 12:27 AM, Kenneth Lundin wrote: > Hi, > > It is not at all surprising that the SMP version run much slower than > the non SMP version. > I looked at the program source and what I find there is an > implementation that does not allow very much of > parallell execution. I agree with your analysis, but not with your conclusion. We can expect that the SMP version will not run much faster. However, we might also hope that it does not run orders of magnitude slower. At the moment, pthread based solutions are slaughtering Erlang, and also achieving up to 350% CPU utilization. -kevin From vychodil.hynek@REDACTED Sun Oct 12 18:55:20 2008 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Sun, 12 Oct 2008 18:55:20 +0200 Subject: [erlang-questions] confused by the grammar of split_binary/2 in the example of mp3_sync In-Reply-To: References: Message-ID: <20081012165521.1DC7124012@relay.gooddata.com> 2008/10/12 lang qiu > Hi, > > I am confused by the grammar of split_binary/2 in the example of mp3_sync > in the book "Programming Erlang", > > get_word(N, Bin) -> > * {_,<>} = split_binary(Bin, N), C.* > > I understand that *@spec split_binary(Bin, Pos)* -> {Bin1, Bin2} but how > does the above clause work ? How does it make C get the first 4 bytes of Bin > starting from N ? > get_word(N, Bin) -> * {_,<>} = split_binary(Bin, N), C. *is shorthand for:* *get_word(N, Bin) -> * {Bin1, Bin2} = split_binary(Bin, N), **<> = Bin2,* * C.* Another way how to write it: get_word(N, Bin) -> *<<_:N/binary, C:4/binary,_/binary>> = Bin,* * C.* > > Thanks! > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- --Hynek (Pichi) Vychodil -------------- next part -------------- An HTML attachment was scrubbed... URL: From kevin@REDACTED Sun Oct 12 19:45:48 2008 From: kevin@REDACTED (Kevin Scaldeferri) Date: Sun, 12 Oct 2008 10:45:48 -0700 Subject: [erlang-questions] What erlc flags are needed to compile native (HiPE) to run on smp-disabled runtime? In-Reply-To: <6c2563b20810110921n28ff218p7707902cf0b29b5d@mail.gmail.com> References: <6c2563b20810110921n28ff218p7707902cf0b29b5d@mail.gmail.com> Message-ID: <9E2B06AB-1BBC-479A-B60F-ADF08FCAF94B@scaldeferri.com> On Oct 11, 2008, at 9:21 AM, Edwin Fine wrote: > To generate native code for smp-enabled runtime using erlc is easy. > I can't seem to make it happen for smp disabled runtime. > > If I start up Erlang with -smp disable and compile from within > Erlang, then it does what I want (creates a natively-compiled beam > for non-smp use). > > $ erl -smp disable > 1> c(mymodule, [native, {hipe, o3}]) > {ok,mymodule} > 8> > > But this is very inconvenient if a build system is created that > relies on erlc. Is there a better way? > I'm not on a HiPE enabled system, but supposedly hipe:help_options() will list the compile flags you can use. Maybe you'll find something there. -kevin PS: is there some secret HiPE documentation I've never managed to find? The "All you wanted to know" document is the best I've found, but I am sad to say it does not tell me everything I want to know :- (. (Also, producing HTML versions of the docs would be nice.) From mikpe@REDACTED Sun Oct 12 20:44:29 2008 From: mikpe@REDACTED (Mikael Pettersson) Date: Sun, 12 Oct 2008 20:44:29 +0200 Subject: [erlang-questions] What erlc flags are needed to compile native (HiPE) to run on smp-disabled runtime? In-Reply-To: <6c2563b20810110921n28ff218p7707902cf0b29b5d@mail.gmail.com> References: <6c2563b20810110921n28ff218p7707902cf0b29b5d@mail.gmail.com> Message-ID: <18674.17805.783465.813357@harpo.it.uu.se> Edwin Fine writes: > To generate native code for smp-enabled runtime using erlc is easy. I can't > seem to make it happen for smp disabled runtime. > > If I start up Erlang with -smp disable and compile from within Erlang, then > it does what I want (creates a natively-compiled beam for non-smp use). > > $ erl -smp disable > 1> c(mymodule, [native, {hipe, o3}]) > {ok,mymodule} > 8> > > But this is very inconvenient if a build system is created that relies on > erlc. Is there a better way? For various reasons the HiPE compiler can only generate code for the runtime system it's running on, so to generate non-SMP code you must run the compiler from within a non-SMP system. Unfortunately there doesn't seem to be any flag to erlc to make it choose a non-default runtime system, or a way to pass on raw options to erl instead of the compiler. erl (erlexec.c), however, can take command-line options from the environment, and the following seems to work: ERL_AFLAGS='-smp disable' erlc +native Module.erl But extending erts/etc/common/erlc.c to accept erlc -smp disable MoreOptions with the same meaning as for erl, or to accept erlc -erl ErlOption ... and pass ErlOption verbatim to erl would be a nicer solution. /Mikael From igouy2@REDACTED Sun Oct 12 19:49:53 2008 From: igouy2@REDACTED (Isaac Gouy) Date: Sun, 12 Oct 2008 10:49:53 -0700 (PDT) Subject: [erlang-questions] Fwd: Chameneos.rednux micro benchmark In-Reply-To: <502F3A34-13DE-4DB7-AD5B-A8434416A97B@scaldeferri.com> Message-ID: <543222.86452.qm@web65407.mail.ac4.yahoo.com> --- Kevin Scaldeferri wrote: > > On Oct 12, 2008, at 12:27 AM, Kenneth Lundin wrote: > > > Hi, > > > > It is not at all surprising that the SMP version run much slower > than > > the non SMP version. > > I looked at the program source and what I find there is an > > implementation that does not allow very much of > > parallell execution. > > I agree with your analysis, but not with your conclusion. > > We can expect that the SMP version will not run much faster. > However, we might also hope that it does not run orders of magnitude > slower. > > At the moment, pthread based solutions are slaughtering Erlang, and > also achieving up to 350% CPU utilization. Is there some well known understanding of how CPU utilization should be reported for multi-core and many-core? 350% utilization sounds quite wrong - but that's probably just me. From erlang-questions_efine@REDACTED Sun Oct 12 21:03:11 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Sun, 12 Oct 2008 15:03:11 -0400 Subject: [erlang-questions] Fwd: Chameneos.rednux micro benchmark In-Reply-To: <543222.86452.qm@web65407.mail.ac4.yahoo.com> References: <502F3A34-13DE-4DB7-AD5B-A8434416A97B@scaldeferri.com> <543222.86452.qm@web65407.mail.ac4.yahoo.com> Message-ID: <6c2563b20810121203h5d6decd2sb80307a6f451b9bf@mail.gmail.com> 350% utilization means that 350/400 of the 4 cores are busy (i.e. 87.5% average CPU utilization). It's quite common to report CPU like that, at least in my experience. On Sun, Oct 12, 2008 at 1:49 PM, Isaac Gouy wrote: > > --- Kevin Scaldeferri wrote: > > > > > On Oct 12, 2008, at 12:27 AM, Kenneth Lundin wrote: > > > > > Hi, > > > > > > It is not at all surprising that the SMP version run much slower > > than > > > the non SMP version. > > > I looked at the program source and what I find there is an > > > implementation that does not allow very much of > > > parallell execution. > > > > I agree with your analysis, but not with your conclusion. > > > > We can expect that the SMP version will not run much faster. > > However, we might also hope that it does not run orders of magnitude > > slower. > > > > At the moment, pthread based solutions are slaughtering Erlang, and > > also achieving up to 350% CPU utilization. > > Is there some well known understanding of how CPU utilization should be > reported for multi-core and many-core? > > 350% utilization sounds quite wrong - but that's probably just me. > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From erlang-questions_efine@REDACTED Sun Oct 12 21:20:47 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Sun, 12 Oct 2008 15:20:47 -0400 Subject: [erlang-questions] Further SMP and distributed performance comments Message-ID: <6c2563b20810121220v33244ee9we87d770555f42cf8@mail.gmail.com> Sorry, this email got sent before it was complete, so if you get it twice, my apologies. I never knew that, in Gmail, if you reply to an email while busy with another, it seems to send the one you were busy with first. I would have expected it to save to draft, but you live and learn. > > It is not at all surprising that the SMP version run much slower than > the non SMP version. > I looked at the program source and what I find there is an > implementation that does not allow very much of > parallell execution. > The broker process is clearly a bottleneck since it is involved in > everything. Every other process must wait for the broker process > before it can continue it's execution. Agreed. > > The other processes are also doing so little useful work so the > task-switching and locking around the run-queue will become the > dominating thing. I also thought so - but more about that later. When you have benchmarks with parallell processes that hardly perform > any work and all processes are highly dependent on > other processes, you can expect results like this, there is nothing > wrong or bad with the ERlang SMP implementation because of that. You are absolutely right that the benchmark is not representative of most real-world situations. It does, however, show up some weakness in the current Erlang SMP implementation. Other languages managed to run the same benchmark in a reasonable amount of time, therefore the benchmark itself cannot be totally invalid. Two orders of magnitude difference between running non-SMP and SMP is excessive under any circumstances. I tried some further experiments and got surprising results. I'd like to hear your opinion on this. I first hypothesized the following: 1. If the locking of the shared run queue is the problem, then if you run multiple VMs (nodes) each with a non-shared run queue (i.e. non-SMP) the program will run faster. 2. If the broker is the bottleneck, have multiple brokers and there should be a large improvement in performance. Initially, I modified the chameneos benchmark to allow more flexibility. - I changed it into a distributed system that allows you to choose how many separate Erlang nodes on which to run. The nodes have to be pre-started manually, unfortunately, but I haven't gotten around to trying to start them from within the program. - I increased the number of brokers to one broker per node. - I changed the benchmark code to spawn processes evenly across the number of nodes chosen. I also set it up that there will be an even number of "chameneos" processes per node, because one of the scenarios I wanted to test is if there is no cross-node communication - the broker on a given node only communicates with chameneos on the same node. This is to test how inter-node communications compares to intra-node communications. - The benchmark now has an extra step that gathered the intermediate results from all the brokers to present the final result. - I put lots of print statements in the code to show progress. - Finally, I removed the initial test that runs with only 3 chameneos because I only wanted to test the worst-case scenario (10 chameneos). The benchmark figures are therefore no longer directly comparable to the results on the alioth web site, but may be compared to each other only. The code I modified is now a bit of a mess because (a) I am not a highly experienced Erlang programmer and (b) I was rushing to try a whole lot of different things, so I was hacking it, but it does the intended job. I started four Erlang shells (nodes), all on the same 4-core Q6600 system. Initially I started the nodes with SMP enabled then I re-ran the tests with SMP disabled. I decided to test the following scenarios (parameters are [number of iterations, number of nodes]): 1. One Erlang SMP node, 1 broker, 10 chameneos - timer:tc(broker, start, [*6000000*, 1]) [353.18 secs]. 2. Four Erlang SMP nodes, 4 brokers, 10 chameneos - timer:tc(broker, start, [*6000000*, 4]). [12.42 secs] 3. One Erlang non-SMP node, 1 broker, 10 chameneos - timer:tc(broker, start, [*6000000*, 1]) [6.08 secs]. 4. Four Erlang non-SMP nodes, 4 brokers, 10 chameneos - timer:tc(broker, start, [*6000000*, 4]). [1.55 secs] Please note that the above results are for brokers that are constrained to be on the *same* node as the chameneos with which they are communicating. When this constraint is removed, that is, when brokers communicate with chameneos on different nodes, it is much slower, even in smp-disabled mode. To quantify that: Four Erlang non-SMP nodes, 4 brokers, 10 chameneos, *intra-node*communications - timer:tc(broker, start, [ *6000000*, 4]). *[1.55 secs]* Four Erlang non-SMP nodes, 4 brokers, 10 chameneos, *inter-node*communications - timer:tc(broker, start, [ *6000000*, 4]). *[192.6 secs]* Maybe this is to be expected, but if so, why? Should it be 124 times faster to communicate between Erlang nodes *on the same physical system* than it is to communicate within the nodes only? *Sample output of intra-node communication* Started broker <6364.44.0> on cwork_4@REDACTED expecting 1500000 messages; collector pid = <0.39.0> Started broker <6363.44.0> on cwork_3@REDACTED expecting 1500000 messages; collector pid = <0.39.0> Started broker <6362.44.0> on cwork_2@REDACTED expecting 1500000 messages; collector pid = <0.39.0> Started broker <0.64.0> on cwork_1@REDACTED expecting 1500000 messages; collector pid = <0.39.0> Started chameneos <0.65.0> for color blue on cwork_1@REDACTED for broker <0.64.0> Started chameneos <0.66.0> for color red on cwork_1@REDACTED for broker <0.64.0> Started chameneos <6362.45.0> for color yellow on cwork_2@REDACTED for broker <6362.44.0> Started chameneos <6362.46.0> for color red on cwork_2@REDACTED for broker <6362.44.0> Started chameneos <6363.45.0> for color yellow on cwork_3@REDACTED for broker <6363.44.0> Started chameneos <6363.46.0> for color blue on cwork_3@REDACTED for broker <6363.44.0> Started chameneos <6364.45.0> for color red on cwork_4@REDACTED for broker <6364.44.0> Started chameneos <6364.46.0> for color yellow on cwork_4@REDACTED for broker <6364.44.0> Started chameneos <0.67.0> for color red on cwork_1@REDACTED for broker <0.64.0> Started chameneos <0.68.0> for color blue on cwork_1@REDACTED for broker <0.64.0> *Sample output showing inter-node communication* Started broker <0.41.0> on cwork_1@REDACTED expecting 1500000 messages; collector pid = <0.39.0> Started broker <6346.44.0> on cwork_2@REDACTED expecting 1500000 messages; collector pid = <0.39.0> Started broker <6347.44.0> on cwork_3@REDACTED expecting 1500000 messages; collector pid = <0.39.0> Started broker <6348.44.0> on cwork_4@REDACTED expecting 1500000 messages; collector pid = <0.39.0> Started chameneos <0.53.0> for color blue on cwork_1@REDACTED for broker <6348.44.0> Started chameneos <0.54.0> for color red on cwork_1@REDACTED for broker <6348.44.0> Started chameneos <6346.45.0> for color yellow on cwork_2@REDACTED for broker <6347.44.0> Started chameneos <6346.49.0> for color red on cwork_2@REDACTED for broker <6347.44.0> Started chameneos <6347.45.0> for color yellow on cwork_3@REDACTED for broker <6346.44.0> Started chameneos <6347.49.0> for color blue on cwork_3@REDACTED for broker <6346.44.0> Started chameneos <6348.45.0> for color red on cwork_4@REDACTED for broker <0.41.0> Started chameneos <6348.46.0> for color yellow on cwork_4@REDACTED for broker <0.41.0> Started chameneos <0.55.0> for color red on cwork_1@REDACTED for broker <6348.44.0> Started chameneos <0.56.0> for color blue on cwork_1@REDACTED for broker <6348.44.0> Again, please excuse the ugly code. To compile, just erlc broker.erl and chameneos.erl. No HiPE used in these measurements. To run, start nodes with the sname cwork_1, cwork_2, ... e.g. $ erl +K true -sname cwork_1 -smp disable - OR - $ erl +K true -sname cwork_1 # to enable SMP Then in cwork_1, enter: > timer:tc(broker, start, [6000000,4]). The 4 is the number of nodes expected (cwork_1 .. cwork_4). Regards, Edwin Fine -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: broker.erl Type: text/x-erlang Size: 6084 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: chameneos.erl Type: text/x-erlang Size: 2004 bytes Desc: not available URL: From erlang-questions_efine@REDACTED Sun Oct 12 21:24:40 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Sun, 12 Oct 2008 15:24:40 -0400 Subject: [erlang-questions] What erlc flags are needed to compile native (HiPE) to run on smp-disabled runtime? In-Reply-To: <9E2B06AB-1BBC-479A-B60F-ADF08FCAF94B@scaldeferri.com> References: <6c2563b20810110921n28ff218p7707902cf0b29b5d@mail.gmail.com> <9E2B06AB-1BBC-479A-B60F-ADF08FCAF94B@scaldeferri.com> Message-ID: <6c2563b20810121224h164d03f9pf382bb85f4e2d671@mail.gmail.com> I find myself in the same position as you do. Although it does a great job of compiling Erlang code, when it comes to acceptable levels of documentation, HiPE *is* unfortunately hype. I tried the hipe:help_options() but they don't give any clue about compiling in non-SMP mode. Apparently it cannot currently be using command-line flags (see Mikael Petterson's email). On Sun, Oct 12, 2008 at 1:45 PM, Kevin Scaldeferri wrote: > > On Oct 11, 2008, at 9:21 AM, Edwin Fine wrote: > > To generate native code for smp-enabled runtime using erlc is easy. I >> can't seem to make it happen for smp disabled runtime. >> >> If I start up Erlang with -smp disable and compile from within Erlang, >> then it does what I want (creates a natively-compiled beam for non-smp use). >> >> $ erl -smp disable >> 1> c(mymodule, [native, {hipe, o3}]) >> {ok,mymodule} >> 8> >> >> But this is very inconvenient if a build system is created that relies on >> erlc. Is there a better way? >> >> > I'm not on a HiPE enabled system, but supposedly hipe:help_options() will > list the compile flags you can use. Maybe you'll find something there. > > -kevin > > PS: is there some secret HiPE documentation I've never managed to find? > The "All you wanted to know" document is the best I've found, but I am sad > to say it does not tell me everything I want to know :-(. (Also, producing > HTML versions of the docs would be nice.) > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rvirding@REDACTED Sun Oct 12 22:15:59 2008 From: rvirding@REDACTED (Robert Virding) Date: Sun, 12 Oct 2008 22:15:59 +0200 Subject: [erlang-questions] jinterface In-Reply-To: <48ED8162.4050405@gmail.com> References: <6C2A5378-5BDE-4FF9-B2AF-790D1F78330B@kallisys.net> <48E7730B.3090506@gmail.com> <3dbc6d1c0810040711w26eae030pbcbccf7e1f4d5fd0@mail.gmail.com> <48E78277.4000809@gmail.com> <3dbc6d1c0810040757u795d521ex4223ad37a4ab3900@mail.gmail.com> <48ECA96B.2030201@gmail.com> <3dbc6d1c0810080657u4891111cr2052dc90488290f8@mail.gmail.com> <48ED8162.4050405@gmail.com> Message-ID: <3dbc6d1c0810121315rb049283mc3a5bf90296e2803@mail.gmail.com> 2008/10/9 Serge Aleynikov > Robert Virding wrote: > > - Modify your program so that you start a local group leader/io-server >> which >> does the formatting and just send the output iolists to the otp.netprocess. >> > > The otp.net node already has a mailbox for getting messages destined to > the io_server, and rpc requests carry the pid of that mailbox. Ideally I > wouldn't need to have another "proxy" io_server on the Erlang side that > would format and send requests to the connected otp.net hidden node. One reason I suggested this was for doing input. While for output you can modify io so that calling io_lib is done locally in the application process this does not work for input. For input the io-server has to be able to evaluate erlang functions, which I reckon can't be done in the otp.net node. Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: From rvirding@REDACTED Sun Oct 12 22:22:17 2008 From: rvirding@REDACTED (Robert Virding) Date: Sun, 12 Oct 2008 22:22:17 +0200 Subject: [erlang-questions] [enhancement] string:split/2 In-Reply-To: <20081010140950.GB3909@tsi.lv> References: <6c2563b20810081642r2fbd1f14w8e3f7a5a2b71bcc4@mail.gmail.com> <34A27838-5CBA-425D-97A1-C2D2CF6F5456@cs.otago.ac.nz> <6c2563b20810082354u34372510n1fb4e1d23d777c23@mail.gmail.com> <781bce43-97e9-48fb-bba2-0ce230f2011a@t39g2000prh.googlegroups.com> <6c2563b20810090953n1b0c7672v17ceb84cbb59a1fd@mail.gmail.com> <20081010120401.GA3909@tsi.lv> <20081010140950.GB3909@tsi.lv> Message-ID: <3dbc6d1c0810121322s52919d8dl2feef72f61379c5b@mail.gmail.com> Can we end the language discussion? :-) I suggest a function string:split/2 which splits the input string with the separator and assumes that there is no separator and either end of the string. So: string:split("ab:de:fg", ":") ==> ["ab","de","fg"] string:split(":ab:de:fg:", ":") ==> [[],"ab","de","fg",[]] We call it split because it sounds better inspite of it being an unjoin. This also matches what will be in the re module (if they get it right) and what is in the old regexp module. And I don't really care what its relationship to join is called. :-) Robert 2008/10/10 Alex Chateau > > string:join/2 is not a surjective function, not a bijective one: > > Sorry, string:join/2 _is_ a surjective function > > -- > Alex Chateau > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From erlang-questions_efine@REDACTED Sun Oct 12 22:24:52 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Sun, 12 Oct 2008 16:24:52 -0400 Subject: [erlang-questions] What erlc flags are needed to compile native (HiPE) to run on smp-disabled runtime? In-Reply-To: <18674.17805.783465.813357@harpo.it.uu.se> References: <6c2563b20810110921n28ff218p7707902cf0b29b5d@mail.gmail.com> <18674.17805.783465.813357@harpo.it.uu.se> Message-ID: <6c2563b20810121324g5659d3bbj742b30e448c7fa3b@mail.gmail.com> Thanks, Mikael. On Sun, Oct 12, 2008 at 2:44 PM, Mikael Pettersson wrote: > Edwin Fine writes: > > To generate native code for smp-enabled runtime using erlc is easy. I > can't > > seem to make it happen for smp disabled runtime. > > > > If I start up Erlang with -smp disable and compile from within Erlang, > then > > it does what I want (creates a natively-compiled beam for non-smp use). > > > > $ erl -smp disable > > 1> c(mymodule, [native, {hipe, o3}]) > > {ok,mymodule} > > 8> > > > > But this is very inconvenient if a build system is created that relies > on > > erlc. Is there a better way? > > For various reasons the HiPE compiler can only generate code > for the runtime system it's running on, so to generate non-SMP > code you must run the compiler from within a non-SMP system. > > Unfortunately there doesn't seem to be any flag to erlc to make > it choose a non-default runtime system, or a way to pass on raw > options to erl instead of the compiler. erl (erlexec.c), however, > can take command-line options from the environment, and the > following seems to work: > > ERL_AFLAGS='-smp disable' erlc +native Module.erl > > But extending erts/etc/common/erlc.c to accept > > erlc -smp disable MoreOptions > > with the same meaning as for erl, or to accept > > erlc -erl ErlOption ... > > and pass ErlOption verbatim to erl would be a nicer solution. > > /Mikael > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From erlang-questions_efine@REDACTED Sun Oct 12 23:01:51 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Sun, 12 Oct 2008 17:01:51 -0400 Subject: [erlang-questions] Notes about the modified chameneos/broker benchmark code I posted Message-ID: <6c2563b20810121401v45af985bkeaaf7d7e3854715f@mail.gmail.com> I forgot to add this in the original email. The code I sent to this list is based on the code posted to alioth for the benchmark game. I modified it heavily. The code as I modified it has a bug (or two): it expects there to be at least 2 chameneos (requester process) per broker. The reason for this is that (a) the code forces a broker to communicate only with chameneos running on the same node as the broker (unless you change the foldr to foldl as commented in the code) and (b) as in the original benchmark, the broker waits for pairs of messages, and will time out if there are fewer than 2 chameneos running on that node. The number of chameneos is currently hard-coded to 10 (by the colors list having 10 colors), so you can't have more than 5 nodes, otherwise there will be nodes that only have 1 chameneos per broker and the broker will time out. I am sure there are other bugs, given the hasty hacking, but I do believe that the code performs the algorithm from the benchmark correctly. If not, sorry, please let me know where I went wrong. Obviously if you parameterize it so that the chameneos to broker ratio is correct (>=2:1) then you can have as many nodes as you like. The way I wrote it to start up and distribute brokers and chameneos is probably very naive, and buggy, but I don't feel too bad about it because I was in a hurry and just trying to get something working to do some measurements, not write production-quality code. Nevertheless, I do apologize if this disgusts or annoys someone. If someone is kind enough to fix the bugs and "expertise" the code, I'd really like to see it the way it should be written. Regards Edwin Fine -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay@REDACTED Mon Oct 13 01:16:53 2008 From: jay@REDACTED (Jay Nelson) Date: Sun, 12 Oct 2008 16:16:53 -0700 Subject: [erlang-questions] Erlounge in Los Angeles, Wed Oct 15 Message-ID: <0ABE7E1D-9C63-49D0-9BB3-8F0291631A9D@duomark.com> Planning to meet Wednesday, Oct. 15 at 6:30pm. Chilbomyunok 3680 West 6th Street Los Angeles, CA 90020 (213) 387-9292 This is a Korean restaurant one block north of Wilshire, 2 blocks west of Normandie. Red line metro stop is at Wilshire and Normandie. I am expecting 6-8 people, more are welcome. jay From ok@REDACTED Mon Oct 13 04:28:47 2008 From: ok@REDACTED (Richard O'Keefe) Date: Mon, 13 Oct 2008 15:28:47 +1300 Subject: [erlang-questions] erlang-questions Digest, Vol 17, Issue 45 In-Reply-To: <6c2563b20810092224s1329d172s7ef39932018cdb51@mail.gmail.com> References: <8f24f4b10810091203i6eeb60f5q1b6bdaa483abea79@mail.gmail.com> <6c2563b20810091252l199969a3v2d82a5d9f87e0e91@mail.gmail.com> <8f24f4b10810091314r1586e999n999ffd972068e072@mail.gmail.com> <61EC12E1-6393-4427-846D-8B5DDC12B4D3@cs.otago.ac.nz> <6c2563b20810091911j581553d9s1f7bcc766620c48c@mail.gmail.com> <6c2563b20810092224s1329d172s7ef39932018cdb51@mail.gmail.com> Message-ID: <965113C8-AFE4-404A-9E07-4D703750108E@cs.otago.ac.nz> On 10 Oct 2008, at 6:24 pm, Edwin Fine wrote: > On Thu, Oct 9, 2008 at 11:53 PM, Richard O'Keefe > wrote: > On 10 Oct 2008, at 3:11 pm, Edwin Fine wrote: > Ok, then to preserve the Principle Of Least Astonishment, let > string:split accept a regular expression, which is just a string > with special RE operators. If the string contains no RE operators, > use an optimized special case of split (like the one you wrote) that > does not use an RE engine. Get the best of both worlds. > > No, that *violates* the principle of least astonishment, Big Time! > > First, absolutely nothing else whatever in the 'string' module > has anything to do with regular expressions. This would be > highly exceptional and very confusing. > > I disagree. Take for example the String classes of Ruby (http://www.ruby-doc.org/core/classes/String.html#M000818 > ), JavaScript (http://www.w3schools.com/jsref/jsref_split.asp) and > Java (http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html#split(java.lang.String) > ), all of which use split with an RE. We *agree* that languages that have a 'split' function take a regular expression as an argument. If you will recall, that was my point. However, it is simply a fact that the 'string' module in >>>Erlang<<< has nothing connected with regular expressions in it. It used to, but they were removed. FOR ERLANG, it would now be astonishing to find just one function relating to regular expressions in 'string'. We *have* a split that uses a regular expression argument. It's in the regular expression module, where it is NOT surprising to find a regular expression used. You wanted a function that was a converse of the 'join' function. Since split-with-an-RE is *not* a converse of 'join', it cannot be the function you were asking for. A function of the kind you asked for *can* be written (and can be more efficient that regexp:split/2), and to be consistent with the Principle of Least Astonishment, it must not be given the name 'split', because a converse of the 'join' function does not do what the 'split' function does. > I think it's a matter of taste or opinion. I don't think split > belongs in the regexp module. It's about regular expressions. There is therefore no better place for it. Bear in mind that there is more than one syntax for regular expressions around. A posix_regexp:split/2 function and a pcre:split/2 function would behave differently, and it would be confusing to put them both in 'string'. > The new re module correctly does not include it. I think > regexp:split should be deprecated, in fact, the entire regexp module > should be deprecated because enough people have used it and been > burned by its lack of performance (because it is written in Erlang > when it should have been written in C) that it warrants an entire > Caveat section in the Erlang Efficiency Guide. Rewriting in C a regular expression module that works on *LINKED LISTS* of character codes would be like painting the Titanic. If you are that worried about bulk string handling, you are using binaries. We *AGREE* that regular expressions implemented at the level of C or better working on space-efficient strings would be a good thing. The lack of performance of the regexp module has very little to do with the language it is written in, by the way. On the contrary, it has to do with the *design*. There are two problems with regexp:split/2. (1) Presumably for the sake of 'convenience', the functions in the 'regexp' module that accept a regular expression accept EITHER a translated regular expression OR a string, which they first translate. It is fatally easy to write regexp:split(Line, "[ \t]*,[ \t]*") instead of {ok,Separator} = regexp:parse("[ \t]*,[ \t]*"), ... regexp:split(Line, Separator). I haven't measured how large the cost is, but it is certainly a trap for the unwary. (In AWK, the argument is usually translated at compile time.) (2) The internal representation is suboptimal. The regexp module translates regular expressions to trees, indeed, to ASTs. At match time, it interprets these trees. Grep and Mawk translate to a kind of automaton, which amongst other things admits a number of special case hacks. One thing that could be done fairly straightforwardly in a system like Erlang would be to have a HiPRE -- a run-time compiler from regexp ASTs to native code, which could be faster than a C implementation. By the way, the manual page for the 're' module starts out "This is an experimental module and the interface is subject to change" so to praise it for omitting 'split' is to go beyond what the evidence will bear. This is all the more so since the existing interface WILL do 90% of what split/2 needs: - compile a regular expression - find all the matches of that expression in a binary - report matches as location pairs To build split/2 on top of that, the hardest thing would be slogging your way through the 're.3' manual page figuring out the options. > Third, if there were a string:split/2 that used regular > expressions, that would make it very incompatible with > string:join/2, which doesn't. I thought we were wanting > string:join(string:split(String, Sep), Sep) > to give back Sep. > > Did you mean to write "to give back String?" Yes I did. > > > Yes, that is what we want, and it is what will happen, because it is > meaningless to join using an RE, isn't it. You can't join things > together with a regular expression. Exactly. Which is why 'split' is *NOT* a converse of 'join'. > So Sep would *have* to be a literal string. A literal string Sep passed to join/2 is treated as a string. A literal string Sep passed to split/2 is treated as a regular expression, which is NOT consistent with its use in join/2. > As it happens, split and join work exactly like this in other > languages and don't seem to overly confuse people. Well, in AWK it doesn't confuse people because AWK doesn't *have* a join/2 function. In Perl, the first argument of join/2 is normally written with quotation marks and the first argument of split/2 is normally written with slashes, acting as a visible reminder that it is not a string. But Erlang does not have the /.../ syntax for regular expressions. If you can find a language where strings and regular expressions have identical literal syntax and where people are not confused by split taking an RE and join taking a string, then you have a case. Only then. > So we are stuck with contriving some name because of history > (lists:split should have been lists:split_as from Haskell, regexp > already has split). > This, in spite of there being more than enough precedents amongst > other languages that use split as a method of their String classes. Since Erlang doesn't have classes, so what? It is you who I understand to be saying that "split" should have a regular expression argument because that's what other languages do. Fine. THAT'S WHAT WE HAVE IN ERLANG. We have a 'split' function that acts just like the split function in Perl (except for the argument order). If you want - a function called 'split' for splitting strings We agree about this! - that takes a regular expression argument We agree about this! - a function called 'join' that takes a string argument We agree about this! - a function X that is a converse of 'join' We agree about this! THEN the function X should not be called 'split'. It appears that we don't agree about this conclusion, and I honestly cannot see why not. Also, IF there were a unique best regular expression syntax we would agree that 'split' should be in the 'string' module. But there are several candidates on the table. Perl-compatible regular expressions are very expressive, but the expressiveness comes at a heavy price: efficiency. POSIX-compatible regular expressions are less expressive, but in return you get guaranteed linear time matching. I believe that the regular expression language in HyTime is comparable to POSIX ones. While I hold no brief for Perl-style "regular expressions", they are in wide use, so support is warranted. Support for efficiently implementable regular expressions is ALSO warranted, especially considering that there is a free C implementation that *is* efficient. So there is good reason to have at least two regular expression modules. (We agree that neither of them is the existing 'regexp'.) And that means there is good reason for each to have its own 'split' function. Let's drop the argument about whether the 'split' function > > By the way, I have a use for > string:join(reverse([Stuff|tail(reverse( > string:unjoin(Thing, ".")))]), ".") > so I would be very unhappy to have to write one of > those string literals as "\\." and the other NOT. > > That's a VERY good point. It's a glaring inconsistency. Other > languages deal with that by having a regular expression type and > special syntax (e.g. /abc/ or %r{abc}) to avoid confusion, and > (IIRC) if a string type is passed in stead of an RE type, the > receiving method treats it as a non-RE. Sadly, no. Take this example. my $data = 'a,b,c'; my @values = split(',', $data); print "$#values\n"; foreach my $item (@values) { print "$item\n"; } The output is 2 a b c Now change the commas to dots: my $data = 'a.b.c'; my @values = split('.', $data); # the rest as before The output is -1 The string has to be changed to '\\.' to work as expected. (Tested with Perl 5.8.8, tested on UltraSPARC II Solaris 2.10 and Intel Core 2 Duo MacOS 10.5.4.) I have no idea what other languages do, except for Squeak Smalltalk, whose analogue of 'split' takes only a fun as an argument. > One would then be able to use the same literal in both join and > unjoin. Maybe Erlang should have a new regular expression type and > syntax, seeing as it is going to be used in more and more > applications that do heavy text processing. We've had that debate before. The position I took then was that text patterns in a language like Erlang should be expressed as trees, rather like Bigloo. See http://www-sop.inria.fr/mimosa/fp/Bigloo/doc/bigloo-12.html#Regular-parsing This is vastly more convenient for programs that *construct* regular expressions than the traditional AWK-style // stuff, and for tricky regular expressions, it has been my experience that it is easier to get right than the linear form. > The fact that for example "add" and "subtract" are not related > in that way really doesn't signify anything, just as the fact > that there are many colours doesn't mean that black is a bad > choice. > > But you wouldn't create a function named "unadd" when "subtract " is > a more acceptable usage - would you? If there was *already* an *incompatible* function called 'subtract', I might be driven to it. Come to think of it, in Smalltalk the opposite of 'add' is 'remove', not 'subtract'. > Interesting. One of the words you wrote above gave me an idea. How > about meeting halfway? How about two new functions, > string:separate(String, Separator) and string:unseparate(List, > Separator)? No clash and it makes even more sense (to me) than split > and join. Suits me. 'join' already has other meanings in computing, like |><|. From ok@REDACTED Mon Oct 13 04:48:15 2008 From: ok@REDACTED (Richard O'Keefe) Date: Mon, 13 Oct 2008 15:48:15 +1300 Subject: [erlang-questions] Types and specs [WAS: [enhancement] string:split/2] In-Reply-To: <48EF3D78.2060306@cs.ntua.gr> References: <6c2563b20810081642r2fbd1f14w8e3f7a5a2b71bcc4@mail.gmail.com> <48EF3D78.2060306@cs.ntua.gr> Message-ID: <795E68D8-738A-4EE5-88E4-0F607132026C@cs.otago.ac.nz> On 11 Oct 2008, at 12:33 am, Kostis Sagonas wrote that [[char(),...]] means list of non-empty strings, which is more precise than [string()]. Would [char()|string()] also work? > > On the other hand, I can see how this may look a bit strange to some > and have for a long time now pondered whether a non_empty_string() > type alias might be added to the list of built-in types. It would certainly make some types easier to read. From ok@REDACTED Mon Oct 13 06:00:38 2008 From: ok@REDACTED (Richard O'Keefe) Date: Mon, 13 Oct 2008 17:00:38 +1300 Subject: [erlang-questions] [enhancement] string:split/2 In-Reply-To: <3dbc6d1c0810121322s52919d8dl2feef72f61379c5b@mail.gmail.com> References: <6c2563b20810081642r2fbd1f14w8e3f7a5a2b71bcc4@mail.gmail.com> <34A27838-5CBA-425D-97A1-C2D2CF6F5456@cs.otago.ac.nz> <6c2563b20810082354u34372510n1fb4e1d23d777c23@mail.gmail.com> <781bce43-97e9-48fb-bba2-0ce230f2011a@t39g2000prh.googlegroups.com> <6c2563b20810090953n1b0c7672v17ceb84cbb59a1fd@mail.gmail.com> <20081010120401.GA3909@tsi.lv> <20081010140950.GB3909@tsi.lv> <3dbc6d1c0810121322s52919d8dl2feef72f61379c5b@mail.gmail.com> Message-ID: <3053526A-C808-4A9D-93CD-E9C2B3511B43@cs.otago.ac.nz> On 13 Oct 2008, at 9:22 am, Robert Virding wrote: > Can we end the language discussion? :-) > > I suggest a function string:split/2 which splits the input string > with the separator and assumes that there is no separator and either > end of the string. So: > > string:split("ab:de:fg", ":") ==> ["ab","de","fg"] > string:split(":ab:de:fg:", ":") ==> [[],"ab","de","fg",[]] This violates the assumption "that there is no separator [at] either end of the string". To make that assumption is to assume that something that _looks_ like a separator at either end _isn't_ one, so string:split(":ab:de:fg:", ":") ==> [":ab","de","fg:"] under that assumption. I _think_ you are talking about the issue that came up last week with *multicharacter* separators: string:split("a:::b", "::") ==> ["a:","b"] or ["a",":b"] -- the code I posted does this As I recall it, we don't have a resolution for that. The posted 'unjoin' takes the _leftmost_ occurrence of a multicharacter separator as a separator, but it could just as well take the _rightmost_. (Existence proof: reverse . map reverse . (\ s -> unjoin s sep) . reverse) > We call it split because it sounds better inspite of it being an > unjoin. s/inspite of/in spite of/ or more idiomatically, s/inspite of/despite/ > This also matches what will be in the re module (if they get it > right) and what is in the old regexp module. No, it DOESN'T match it. It CONFLICTS with regexp splitting. In fact, that's why it is useful! Call it disjoin/2 if you will (that being an existing English word). But please do not give it the same name as an existing function with significantly incompatible behaviour. > From igouy2@REDACTED Mon Oct 13 07:18:26 2008 From: igouy2@REDACTED (Isaac Gouy) Date: Sun, 12 Oct 2008 22:18:26 -0700 (PDT) Subject: [erlang-questions] What erlc flags are needed to compile native (HiPE) to run on smp-disabled runtime? In-Reply-To: <6c2563b20810121324g5659d3bbj742b30e448c7fa3b@mail.gmail.com> Message-ID: <750844.82679.qm@web65408.mail.ac4.yahoo.com> > On Sun, Oct 12, 2008 at 2:44 PM, Mikael Pettersson > > For various reasons the HiPE compiler can only generate code > > for the runtime system it's running on, so to generate non-SMP > > code you must run the compiler from within a non-SMP system. I've now made a separate build using --disable-smp-support so both HiPE and -smp disable can be used: http://shootout.alioth.debian.org/u32/erlang.php http://shootout.alioth.debian.org/u64/erlang.php From kostis@REDACTED Mon Oct 13 08:49:11 2008 From: kostis@REDACTED (Kostis Sagonas) Date: Mon, 13 Oct 2008 09:49:11 +0300 Subject: [erlang-questions] Types and specs [WAS: [enhancement] string:split/2] In-Reply-To: <795E68D8-738A-4EE5-88E4-0F607132026C@cs.otago.ac.nz> References: <6c2563b20810081642r2fbd1f14w8e3f7a5a2b71bcc4@mail.gmail.com> <48EF3D78.2060306@cs.ntua.gr> <795E68D8-738A-4EE5-88E4-0F607132026C@cs.otago.ac.nz> Message-ID: <48F2EF67.7010005@cs.ntua.gr> Richard O'Keefe wrote: > > On 11 Oct 2008, at 12:33 am, Kostis Sagonas wrote that > [[char(),...]] means list of non-empty strings, which > is more precise than [string()]. > > Would [char()|string()] also work? No. This is a different type, which does not express what you want here. Note that in the language of types | does not mean list tail, but instead means type union. The above type denotes a (possibly empty) list consisting of characters or strings. Quite different from [[char(),...]]. Kostis From ulf.wiger@REDACTED Mon Oct 13 09:20:19 2008 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Mon, 13 Oct 2008 09:20:19 +0200 Subject: [erlang-questions] Lots of questions about error_logger In-Reply-To: <3bff71aa0810100809w1b5282dfhd7bd06876f255605@mail.gmail.com> References: <3bff71aa0810100809w1b5282dfhd7bd06876f255605@mail.gmail.com> Message-ID: <48F2F6B3.70203@ericsson.com> Sergey A. skrev: > Hello. > > In the first place, sorry for several different questions placed in > one letter. I know it's something wearily to answer a list of > questions. > > I tried using error_logger as a tool for handling error reports and > I've came across some oddities: > > #1. Is there a way to set SASL options (I'm about sasl_error_logger, > errlog_type etc) from the Erlang code at runtime without using a > .config file + the "-config" argument? I just want to give an end user > only one config file to edit and use values from that to setup SASL. I guess application:set_env(App, Par, Val) is what you're after? However, the function comes with a big fat warning: "Use this function only if you know what you are doing, that is, on your own applications. It is very application and configuration parameter dependent when and how often the value is read by the application, and careless use of this function may put the application in a weird, inconsistent, and malfunctioning state." (http://www.erlang.org/doc/apps/kernel/application.html) Especially with things like the error logger, the value is expected to be present from the beginning, and the warning is particularly relevant. If you don't want to mess with a config file, you can add the parameters to the command line, using -App Par Val constructs. Remember to escape special characters and omit spaces if you want to declare complex terms this way. It's easy with simple values, like erl -sasl error_logger_mf_maxbytes 100000 BR, Ulf W From vladdu55@REDACTED Mon Oct 13 09:22:50 2008 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Mon, 13 Oct 2008 09:22:50 +0200 Subject: [erlang-questions] Fwd: [enhancement] string:split/2 In-Reply-To: References: <6c2563b20810081642r2fbd1f14w8e3f7a5a2b71bcc4@mail.gmail.com> <6c2563b20810082343j255330ccp396cf4f8da0d2fe4@mail.gmail.com> <330AAA17-394B-44D0-9E09-7CEE4B6BF9C9@cs.otago.ac.nz> <6c2563b20810091932x245481ew538675b5526e8db3@mail.gmail.com> <8689C36E-B021-4300-88E1-AB66164891F6@cs.otago.ac.nz> <95be1d3b0810092356lc2f1d93m5e86a0ecc97358cd@mail.gmail.com> Message-ID: <95be1d3b0810130022h6de0a4ffne24e606310086053@mail.gmail.com> I believe Richard's question wasn't aimed at just me, so I'm forwarding it here. /Vlad ---------- Forwarded message ---------- From: Richard O'Keefe Date: Mon, Oct 13, 2008 at 04:41 Subject: Re: [erlang-questions] [enhancement] string:split/2 On 10 Oct 2008, at 7:56 pm, Vlad Dumitrescu wrote: > > On Fri, Oct 10, 2008 at 07:00, Richard O'Keefe wrote: >> >> Talking about "not requir[ing] HiPE" is like saying >> "I demand that your C compiler produce efficient code >> without optimisation." > > A side issue: the above comparison is not really correct. Until HiPE > is available on all platforms and architectures supported by Erlang, > it is perfectly valid to not want to have it as a requirement for an > application. The thing we are all agreed on is that it is desirable to have HiPE "on all platforms and architectures supported by Erlang". I was willing to pay USD 160 for a licence to the Intel C compiler on my Mac. All things considered, I'd be happy to donate a similar amount towards getting HiPE going. Could there be a HiPE foundation? From rvirding@REDACTED Mon Oct 13 12:14:04 2008 From: rvirding@REDACTED (Robert Virding) Date: Mon, 13 Oct 2008 12:14:04 +0200 Subject: [erlang-questions] [enhancement] string:split/2 In-Reply-To: <3053526A-C808-4A9D-93CD-E9C2B3511B43@cs.otago.ac.nz> References: <6c2563b20810081642r2fbd1f14w8e3f7a5a2b71bcc4@mail.gmail.com> <34A27838-5CBA-425D-97A1-C2D2CF6F5456@cs.otago.ac.nz> <6c2563b20810082354u34372510n1fb4e1d23d777c23@mail.gmail.com> <781bce43-97e9-48fb-bba2-0ce230f2011a@t39g2000prh.googlegroups.com> <6c2563b20810090953n1b0c7672v17ceb84cbb59a1fd@mail.gmail.com> <20081010120401.GA3909@tsi.lv> <20081010140950.GB3909@tsi.lv> <3dbc6d1c0810121322s52919d8dl2feef72f61379c5b@mail.gmail.com> <3053526A-C808-4A9D-93CD-E9C2B3511B43@cs.otago.ac.nz> Message-ID: <3dbc6d1c0810130314x630f4736q90162ed739321ac0@mail.gmail.com> 2008/10/13 Richard O'Keefe > > On 13 Oct 2008, at 9:22 am, Robert Virding wrote: > > I suggest a function string:split/2 which splits the input string with the >> separator and assumes that there is no separator and either end of the >> string. So: >> >> string:split("ab:de:fg", ":") ==> ["ab","de","fg"] >> string:split(":ab:de:fg:", ":") ==> [[],"ab","de","fg",[]] >> > > This violates the assumption "that there is no separator [at] > either end of the string". To make that assumption is to > assume that something that _looks_ like a separator at either > end _isn't_ one, so > string:split(":ab:de:fg:", ":") ==> [":ab","de","fg:"] > under that assumption. > > I _think_ you are talking about the issue that came up > last week with *multicharacter* separators: > string:split("a:::b", "::") > ==> ["a:","b"] > or ["a",":b"] -- the code I posted does this That was me being extremely unclear. The examples I showed describe what I mean, and not what I wrote. I think the function should search for the separator from left-to-right as your second example. The question is how do you describe in text what it returns when it finds the separator at the beginning and at the end. This also matches what will be in the re module (if they get it right) and >> what is in the old regexp module. >> > > No, it DOESN'T match it. It CONFLICTS with regexp splitting. > In fact, that's why it is useful! regexp:split("ab:cd:ef", ":"). ==> {ok,["ab","cd","ef"]} regexp:split(":ab:cd:ef:", ":"). ==> {ok,[[],"ab","cd","ef",[]]} regexp:split(":::ab:::cd::ef", "::"). ==> {ok,[[],":ab",":cd","ef"]} Or have I misunderstood you. What the new re:split will do I don't know, hopefully the same thing. Not to be different I have also included some code for a split/2. It is a bit simpler than yours, at least I think so, but no guarantees for speed. Although it would be easy to modify so that strip_sep/2 never returns but directly calls strip/4. %% strip(String, Separator) -> [String]. strip(S, Sep) -> strip(S, Sep, [], []). strip([H|T]=S0, Sep, R, Rs) -> case strip_sep(S0, Sep) of {yes,S1} -> strip(S1, Sep, [], [R|Rs]); no -> strip(T, Sep, [H|R], Rs) end; strip([], _, R, Rs) -> strip_rev([R|Rs], []). strip_rev([R|Rs], Acc) -> strip_rev(Rs, [reverse(R)|Acc]); strip_rev([], Acc) -> Acc. strip_sep([C|S], [C|Sep]) -> strip_sep(S, Sep); strip_sep(S, []) -> {yes,S}; strip_sep(_, _) -> no. Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: From bgustavsson@REDACTED Mon Oct 13 12:25:17 2008 From: bgustavsson@REDACTED (Bjorn Gustavsson) Date: Mon, 13 Oct 2008 12:25:17 +0200 Subject: [erlang-questions] [erlang-patches] code_server & ERL_LIBS bug In-Reply-To: <48EF60D1.1030704@gmail.com> References: <48EF60D1.1030704@gmail.com> Message-ID: <6672d0160810130325h2cf5a74cr7e9536a1453d86ec@mail.gmail.com> 2008/10/10 Serge Aleynikov > There's an error in code server that causes erl & erlc to hang at startup > if ERL_LIBS environment variable is set to an empty string or a string > containing non-existing directories. > > Thanks! It will be corrected in R12B-5. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB -------------- next part -------------- An HTML attachment was scrubbed... URL: From rvg@REDACTED Mon Oct 13 14:14:41 2008 From: rvg@REDACTED (Rudolph van Graan) Date: Mon, 13 Oct 2008 14:14:41 +0200 Subject: [erlang-questions] Are there any companies that hire Erlangers? In-Reply-To: <290b3ba10810100410k205642demb8ec48b7f361a3e4@mail.gmail.com> References: <2a67d3ff0810091808x2c4be63dpbe1ef8f79654593c@mail.gmail.com> <6c2563b20810091937u2b411cean65d972caa4d60bd9@mail.gmail.com> <290b3ba10810100410k205642demb8ec48b7f361a3e4@mail.gmail.com> Message-ID: <8BC540AA-B6B7-4EBC-A3DB-D41AF6E259C5@patternmatched.com> Hi All, Pattern Matched Technologies (www.patternmatched.com) is looking for programmers right now. We work closely with Francesco and ETC (Erlang Training and Consulting). We are based in South Africa and have a number of positions available. All our products are Erlang-based - we have been working with the language for about 8 years now. Please do not hesitate to contact me if you are interested. Rudolph Pattern Matched Technologies E-Mail: rvg@REDACTED Tel: 086 1000 700 (SA Only) Mobile: +27 83 390 7767 Fax: +27 12 665 9566 Web: www.patternmatched.com On Oct 10, 2008, at 1:10 PM, t ty wrote: > Hello All, > > I have yet to find a company that programs using Erlang, and I'd > really > like to work for one. Am I looking in the wrong place, do any of you > know a > company that uses Erlang as the main language? > > -Gene From klsr.2008@REDACTED Mon Oct 13 14:11:41 2008 From: klsr.2008@REDACTED (Klsr K) Date: Mon, 13 Oct 2008 12:41:41 +0030 Subject: [erlang-questions] Erlang linked in driver question Message-ID: <4ae243650810130511y17ed29e7pdf8534af05157574@mail.gmail.com> Hi to all i was going through the linked in driver program . . . In gen_tcp for gen_tcp:connect for each connection they opening new port and my question is there is any diff when we open the port for each connect and opening the port when loading the driver and using that port for communication for all connection and send.... From chandrashekhar.mullaparthi@REDACTED Mon Oct 13 16:41:59 2008 From: chandrashekhar.mullaparthi@REDACTED (Chandru) Date: Mon, 13 Oct 2008 15:41:59 +0100 Subject: [erlang-questions] Are there any companies that hire Erlangers? In-Reply-To: <6c2563b20810091937u2b411cean65d972caa4d60bd9@mail.gmail.com> References: <2a67d3ff0810091808x2c4be63dpbe1ef8f79654593c@mail.gmail.com> <6c2563b20810091937u2b411cean65d972caa4d60bd9@mail.gmail.com> Message-ID: T-Mobile UK uses Erlang/OTP a lot. There is currently a vacant contracting position if anyone is interested. cheers Chandru 2008/10/10 Edwin Fine > Not to be funny, but in which country? I mean, where are you looking? In > the U.K for example, I think I know of a company or two that uses primarily > Erlang (Erlang Training and Consulting is one, and I think LShift is another > - http://www.lshift.net/recruitment). > > 2008/10/9 G.S. > >> Hello All, >> >> I have yet to find a company that programs using Erlang, and I'd really >> like to work for one. Am I looking in the wrong place, do any of you know a >> company that uses Erlang as the main language? >> >> -Gene >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kevin@REDACTED Mon Oct 13 18:13:43 2008 From: kevin@REDACTED (Kevin Scaldeferri) Date: Mon, 13 Oct 2008 09:13:43 -0700 Subject: [erlang-questions] What erlc flags are needed to compile native (HiPE) to run on smp-disabled runtime? In-Reply-To: <750844.82679.qm@web65408.mail.ac4.yahoo.com> References: <750844.82679.qm@web65408.mail.ac4.yahoo.com> Message-ID: <44F7E98A-6B45-4983-9E06-76AFF0C05CFC@scaldeferri.com> On Oct 12, 2008, at 10:18 PM, Isaac Gouy wrote: >> On Sun, Oct 12, 2008 at 2:44 PM, Mikael Pettersson > >>> For various reasons the HiPE compiler can only generate code >>> for the runtime system it's running on, so to generate non-SMP >>> code you must run the compiler from within a non-SMP system. > > I've now made a separate build using --disable-smp-support so both > HiPE > and -smp disable can be used: > > http://shootout.alioth.debian.org/u32/erlang.php > > http://shootout.alioth.debian.org/u64/erlang.php > This is all well and good for chameneos, but it looks like all erlang entries are being run this way now, including ones like the binary- trees entries that was written to take advantage of multiple cores and which does go faster with SMP: http://shootout.alioth.debian.org/u64/benchmark.php?test=binarytrees&lang=hipe&id=2 -kevin From igouy2@REDACTED Mon Oct 13 19:00:08 2008 From: igouy2@REDACTED (Isaac Gouy) Date: Mon, 13 Oct 2008 10:00:08 -0700 (PDT) Subject: [erlang-questions] What erlc flags are needed to compile native (HiPE) to run on smp-disabled runtime? In-Reply-To: <44F7E98A-6B45-4983-9E06-76AFF0C05CFC@scaldeferri.com> Message-ID: <529648.50104.qm@web65404.mail.ac4.yahoo.com> --- Kevin Scaldeferri wrote: > > On Oct 12, 2008, at 10:18 PM, Isaac Gouy wrote: > > >> On Sun, Oct 12, 2008 at 2:44 PM, Mikael Pettersson > > > > >>> For various reasons the HiPE compiler can only generate code > >>> for the runtime system it's running on, so to generate non-SMP > >>> code you must run the compiler from within a non-SMP system. > > > > I've now made a separate build using --disable-smp-support so both > > > HiPE > > and -smp disable can be used: > > > > http://shootout.alioth.debian.org/u32/erlang.php > > > > http://shootout.alioth.debian.org/u64/erlang.php > > > > > This is all well and good for chameneos, but it looks like all erlang > entries are being run this way now, including ones like the binary- > trees entries that was written to take advantage of multiple cores > and which does go faster with SMP There are 4 sets of measurements. Those 2 sets of measurements show programs forced to use a single core. These 2 sets of measurements show programs allowed to use multiple cores, and use -smp enable http://shootout.alioth.debian.org/u32q/erlang.php http://shootout.alioth.debian.org/u64q/erlang.php From kenneth.lundin@REDACTED Mon Oct 13 20:00:50 2008 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Mon, 13 Oct 2008 20:00:50 +0200 Subject: [erlang-questions] Fwd: Chameneos.rednux micro benchmark In-Reply-To: <502F3A34-13DE-4DB7-AD5B-A8434416A97B@scaldeferri.com> References: <502F3A34-13DE-4DB7-AD5B-A8434416A97B@scaldeferri.com> Message-ID: Hi, We have now looked a bit closer on why this benchmark does perform so bad with Erlang SMP. There are 2 major things that stand out: 1) The locking of the single run-queue between the pthread based schedulers is the main thing. There is an enormous amount of locking and lock-conflicts here. 2) One single process (the broker) to which all others are sending messages does also cause a lot of locking (the message-queue and heap on the receiving process requires a lock before the sending process can complete it's send operation) Fortunately we have ongoing work with optimizations in these areas which will have major impact on this benchmark. On Sun, Oct 12, 2008 at 6:25 PM, Kevin Scaldeferri wrote: > > On Oct 12, 2008, at 12:27 AM, Kenneth Lundin wrote: > >> Hi, >> >> It is not at all surprising that the SMP version run much slower than >> the non SMP version. >> I looked at the program source and what I find there is an >> implementation that does not allow very much of >> parallel execution. > > I agree with your analysis, but not with your conclusion. > > We can expect that the SMP version will not run much faster. However, we > might also hope that it does not run orders of magnitude slower. > > At the moment, pthread based solutions are slaughtering Erlang, and also > achieving up to 350% CPU utilization. A pthread based solution written in C for this particular problem is not a fair comparison since the Erlang VM is designed to support general execution of thousands of processes on top of a number of pthreads based schedulers. The VM has to handle all Erlang programs whatever execution pattern they have. There is an overhead for being able to execute Erlang processes and IO in a soft real time way. Normally this overhead is around 20% compared with the non SMP VM. With this particular benchmark each process perform so little execution each time it is run and the number of simultaneously runnable processes goes like a Jojo between first 1 to 4 and later 1-12. The effect of this is that it costs more to schedule in a process than it costs to run it's code. Most probably the benchmark can be written in a more efficient way for the Erlang VM as well. Maybe I will take the time to do that later. /Kenneth Erlang/OTP team, Ericsson > > -kevin > From mickael.remond@REDACTED Mon Oct 13 19:35:57 2008 From: mickael.remond@REDACTED (=?UTF-8?Q?Micka=C3=ABl_R=C3=A9mond?=) Date: Mon, 13 Oct 2008 19:35:57 +0200 Subject: [erlang-questions] Erlounge in Los Angeles, Wed Oct 15 In-Reply-To: <0ABE7E1D-9C63-49D0-9BB3-8F0291631A9D@duomark.com> References: <0ABE7E1D-9C63-49D0-9BB3-8F0291631A9D@duomark.com> Message-ID: Hello Jay, Too bad, I will miss it from a few days. I would love to meet Erlanger and XMPP fan in Los Angeles on sunday 19th Oct or on the 22th Oct. I am arriving on Saturday (18th Oct) and living an thursday (23rd Oct). Le 13 oct. 08 ? 01:16, Jay Nelson a ?crit : > Planning to meet Wednesday, Oct. 15 at 6:30pm. > > Chilbomyunok > 3680 West 6th Street > Los Angeles, CA 90020 > (213) 387-9292 > > This is a Korean restaurant one block north of Wilshire, > 2 blocks west of Normandie. Red line metro stop is > at Wilshire and Normandie. > > I am expecting 6-8 people, more are welcome. > > jay > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- Micka?l R?mond http://www.process-one.net/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From josh@REDACTED Mon Oct 13 20:02:01 2008 From: josh@REDACTED (Josh Goldberg) Date: Mon, 13 Oct 2008 11:02:01 -0700 Subject: [erlang-questions] [spam?] Are there any companies that hire Erlangers? In-Reply-To: <2a67d3ff0810091808x2c4be63dpbe1ef8f79654593c@mail.gmail.com> References: <2a67d3ff0810091808x2c4be63dpbe1ef8f79654593c@mail.gmail.com> Message-ID: <4c7f9e8d0810131102q83cfeb4tfaefb285e0a751d6@mail.gmail.com> I've gotten a couple job inquiries from linkedin.com with erlang in my profile. 2008/10/9 G.S. > Hello All, > > I have yet to find a company that programs using Erlang, and I'd really > like to work for one. Am I looking in the wrong place, do any of you know a > company that uses Erlang as the main language? > > -Gene > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From david.koch@REDACTED Mon Oct 13 15:04:07 2008 From: david.koch@REDACTED (=?iso-8859-1?Q?david.koch@libertysurf.fr?=) Date: Mon, 13 Oct 2008 15:04:07 +0200 Subject: [erlang-questions] =?iso-8859-1?q?REF=3A_ErlIDE_0=2E3=2E94_on_Ecl?= =?iso-8859-1?q?ipse_3=2E4=2E1_M20080911-1700?= Message-ID: The Erlang perspective just doesn't show anymore... Am I mistaken with my upgrade ? Any solution ? Sorry to be a pain in the a.. ! Kochise ---------------------- ALICE N?1 de la RELATION CLIENT 2008*-------------------- D?couvrez vite l'offre exclusive ALICE BOX! En cliquant ici http://abonnement.aliceadsl.fr Offre soumise ? conditions.*Source : TNS SOFRES / BEARING POINT. Secteur Fournisseur d.Acc?s Internet From vladdu55@REDACTED Mon Oct 13 20:20:37 2008 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Mon, 13 Oct 2008 20:20:37 +0200 Subject: [erlang-questions] REF: ErlIDE 0.3.94 on Eclipse 3.4.1 M20080911-1700 In-Reply-To: References: Message-ID: <95be1d3b0810131120x1de27bfewfe6c275d4daf0b13@mail.gmail.com> On Mon, Oct 13, 2008 at 15:04, david.koch@REDACTED wrote: > The Erlang perspective just doesn't show anymore... Am I mistaken > with my upgrade ? Any solution ? Sorry to be a pain in the a.. ! Hi, Please send me some more details about your settings and I will help you. >From which version did you update? regards, Vlad From kevin@REDACTED Mon Oct 13 20:33:30 2008 From: kevin@REDACTED (Kevin Scaldeferri) Date: Mon, 13 Oct 2008 11:33:30 -0700 Subject: [erlang-questions] What erlc flags are needed to compile native (HiPE) to run on smp-disabled runtime? In-Reply-To: <529648.50104.qm@web65404.mail.ac4.yahoo.com> References: <529648.50104.qm@web65404.mail.ac4.yahoo.com> Message-ID: <367ACD9E-0875-4A2F-989A-9331AF4F39CC@scaldeferri.com> On Oct 13, 2008, at 10:00 AM, Isaac Gouy wrote: > > --- Kevin Scaldeferri wrote: > >> >> On Oct 12, 2008, at 10:18 PM, Isaac Gouy wrote: >> >>>> On Sun, Oct 12, 2008 at 2:44 PM, Mikael Pettersson >> >>> >>>>> For various reasons the HiPE compiler can only generate code >>>>> for the runtime system it's running on, so to generate non-SMP >>>>> code you must run the compiler from within a non-SMP system. >>> >>> I've now made a separate build using --disable-smp-support so both >> >>> HiPE >>> and -smp disable can be used: >>> >>> http://shootout.alioth.debian.org/u32/erlang.php >>> >>> http://shootout.alioth.debian.org/u64/erlang.php >>> >> >> >> This is all well and good for chameneos, but it looks like all erlang >> entries are being run this way now, including ones like the binary- >> trees entries that was written to take advantage of multiple cores >> and which does go faster with SMP > > There are 4 sets of measurements. > > Those 2 sets of measurements show programs forced to use a single > core. > > These 2 sets of measurements show programs allowed to use multiple > cores, and use -smp enable > > http://shootout.alioth.debian.org/u32q/erlang.php > > http://shootout.alioth.debian.org/u64q/erlang.php > Ahh, my mistake. I didn't look closely enough at the headers. -kevin From dloutrein.lists@REDACTED Mon Oct 13 23:47:40 2008 From: dloutrein.lists@REDACTED (denis) Date: Mon, 13 Oct 2008 17:47:40 -0400 Subject: [erlang-questions] core erlang, scope, primop Message-ID: <349ebab60810131447x2391571ei4c01e5d4e6f5c091@mail.gmail.com> Hi all, I've two questions on core erlang: Concerning the scope of variables: when using let, the scope of the variables is the body of the let. But when a variable is defined by a pattern matching or by an alias, what is the scope ? I suppose that it's the function, but I've not been able to find references of that in the core erlang 1.0.3 specifications. Concerning primop: is there a way to call these functions in erlang ? If not, is it possible to know all primops that are used by erlang compiler when generating core erlang ? As you may understand, I'm toying with writing a core erlang evaluator. Thanks Denis From ok@REDACTED Tue Oct 14 03:42:57 2008 From: ok@REDACTED (Richard O'Keefe) Date: Tue, 14 Oct 2008 14:42:57 +1300 Subject: [erlang-questions] Types and specs [WAS: [enhancement] string:split/2] In-Reply-To: <48F2EF67.7010005@cs.ntua.gr> References: <6c2563b20810081642r2fbd1f14w8e3f7a5a2b71bcc4@mail.gmail.com> <48EF3D78.2060306@cs.ntua.gr> <795E68D8-738A-4EE5-88E4-0F607132026C@cs.otago.ac.nz> <48F2EF67.7010005@cs.ntua.gr> Message-ID: <4335FA0F-BE26-4000-B883-111F35F85058@cs.otago.ac.nz> On 13 Oct 2008, at 7:49 pm, Kostis Sagonas wrote: > Richard O'Keefe wrote: >> On 11 Oct 2008, at 12:33 am, Kostis Sagonas wrote that >> [[char(),...]] means list of non-empty strings, which >> is more precise than [string()]. >> Would [char()|string()] also work? > > No. This is a different type, which does not express what you want > here. > > Note that in the language of types | does not mean list tail, but > instead means type union. The above type denotes a (possibly empty) > list consisting of characters or strings. Then we have a rather nasty syntax problem here. If I had written [(char() | string()] where the bar is NOT part of the list syntax, I would certainly expect that to mean a list of things each of which is a char or a string. But with the vertical bar being part of the list syntax, I would expect [H | T] as a type to mean the type of cons cells whose heads are of type H and whose tails are of type T. If it *doesn't* mean that, it should be a syntax error. From kostis@REDACTED Tue Oct 14 08:41:47 2008 From: kostis@REDACTED (Kostis Sagonas) Date: Tue, 14 Oct 2008 09:41:47 +0300 Subject: [erlang-questions] Types and specs [WAS: [enhancement] string:split/2] In-Reply-To: <4335FA0F-BE26-4000-B883-111F35F85058@cs.otago.ac.nz> References: <6c2563b20810081642r2fbd1f14w8e3f7a5a2b71bcc4@mail.gmail.com> <48EF3D78.2060306@cs.ntua.gr> <795E68D8-738A-4EE5-88E4-0F607132026C@cs.otago.ac.nz> <48F2EF67.7010005@cs.ntua.gr> <4335FA0F-BE26-4000-B883-111F35F85058@cs.otago.ac.nz> Message-ID: <48F43F2B.2030308@cs.ntua.gr> Richard O'Keefe wrote: > > On 13 Oct 2008, at 7:49 pm, Kostis Sagonas wrote: > >> Richard O'Keefe wrote: >>> On 11 Oct 2008, at 12:33 am, Kostis Sagonas wrote that >>> [[char(),...]] means list of non-empty strings, which >>> is more precise than [string()]. >>> Would [char()|string()] also work? >> >> No. This is a different type, which does not express what you want here. >> >> Note that in the language of types | does not mean list tail, but >> instead means type union. The above type denotes a (possibly empty) >> list consisting of characters or strings. > > Then we have a rather nasty syntax problem here. > > If I had written [(char() | string()] where the bar is NOT > part of the list syntax, I would certainly expect that to > mean a list of things each of which is a char or a string. > But with the vertical bar being part of the list syntax, > I would expect [H | T] as a type to mean the type of cons > cells whose heads are of type H and whose tails are of type T. The language of types does not have any convenient notation for lists with a tail other than []. The [...] notation is a shorthand for list() and *always* refers to proper lists, so there's no ambiguity there. (If you want to specify an improper list the closer you can get is to employ the long and yucky type maybe_improper_list() that does not have any convenient shorthand. As its name suggests, you cannot even be specify with certainty that the list is improper.) > If it *doesn't* mean that, it should be a syntax error. I agree with you that the version with parentheses looks and feels better. You are welcome to submit a patch for this. Kostis From monch1962@REDACTED Tue Oct 14 08:43:56 2008 From: monch1962@REDACTED (David Mitchell) Date: Tue, 14 Oct 2008 17:43:56 +1100 Subject: [erlang-questions] What's the status of erl_com, the Erlang-to-COM bridge? Message-ID: Hello everyone, I've come across what used to be called the COMET project, or erl_com, which is a bridge between Erlang and COM on Windows. Unfortunately, all the info I can find on it is several years old, but it would be very useful to me if it was still usable, supportable, etc. Does anyone know the status of this project? Is it still active (and I haven't been able to find any recent docs)? Has it been replaced by something else? Does it still work in R11 or R12? Thanks in advance Dave M. From kostis@REDACTED Tue Oct 14 09:26:52 2008 From: kostis@REDACTED (Kostis Sagonas) Date: Tue, 14 Oct 2008 10:26:52 +0300 Subject: [erlang-questions] Why is query a reserved word In-Reply-To: References: Message-ID: <48F449BC.1020902@cs.ntua.gr> Lennart ?hman wrote: > Hi, > it was used in defining a Mnemosyne query - a now obsoleted Mnesia query language. I would have assumed that since Mnemosyne is now obsolete, 'query' would have stopped being a reserved word.... Kostis From richardc@REDACTED Tue Oct 14 09:33:12 2008 From: richardc@REDACTED (Richard Carlsson) Date: Tue, 14 Oct 2008 09:33:12 +0200 Subject: [erlang-questions] core erlang, scope, primop In-Reply-To: <349ebab60810131447x2391571ei4c01e5d4e6f5c091@mail.gmail.com> References: <349ebab60810131447x2391571ei4c01e5d4e6f5c091@mail.gmail.com> Message-ID: <48F44B38.6040300@it.uu.se> denis wrote: > I've two questions on core erlang: > > Concerning the scope of variables: when using let, the scope of the > variables is the body of the let. But when a variable is defined by a > pattern matching or by an alias, what is the scope ? I suppose that > it's the function, but I've not been able to find references of that > in the core erlang 1.0.3 specifications. This is described at the top of page 15, under "Case:". The scope is the body of the clause, and also the guard (follow the reference to section 6.6). (Core Erlang isolates all pattern matching to the case expressions, so things are a lot easier than in the full Erlang.) > Concerning primop: is there a way to call these functions in erlang ? > If not, is it possible to know all primops that are used by erlang > compiler when generating core erlang ? Not as such. As explained in section 7, the primops are only there to help on the implementation level, to represent internal operations that do not generally have a corresponding Erlang function somewhere. They are thus completely dependent on the compiler and VM implementation. However, the number of primops used by the OTP compiler is pretty small, and can be found rather quickly by inspecting some core code generated from typical Erlang source files and grepping under lib/compiler/src. > As you may understand, I'm toying with writing a core erlang evaluator. There should really have been an official interpreter, but I never got time to finish it. Have fun! /Richard From imre@REDACTED Tue Oct 14 10:46:03 2008 From: imre@REDACTED (Imre Palik) Date: Tue, 14 Oct 2008 11:46:03 +0300 Subject: [erlang-questions] generating primes Message-ID: <3BE6DBA1F3BE9D4798255806113D56540F78C912D5@utx-exchange.utx.local> Hi, I am playing with Project Euler nowdays, and in the last few problems I solved I had problems generating primes fast enough. Currently I am using the following implementation of the Sieve of Eratosthenes: sieve([]) -> []; sieve([H|T]) -> [H|sieve([X||X<-T,X rem H =/= 0])]. I tried to change it to use addition instead of doing the remainder: sieve_filter(_, _, []) -> []; sieve_filter(F, I, [F|T]) -> sieve_filter(F + I, I, T); sieve_filter(F, I, [H|T]) when H > F-> [H|sieve_filter(F + I, I, T)]; sieve_filter(F, I, [H|T]) -> [H|sieve_filter(F, I, T)]. sieve2([]) -> []; sieve2([H|T]) -> [H|sieve2(sieve_filter(3 * H, 2 * H, T))]. But this one runs slower than the original. Could anybody explain why? Are there any optimisations I can do here, or do I have to find a better algorithm (any pointers?)? Thanks Imre From roberto@REDACTED Tue Oct 14 11:42:04 2008 From: roberto@REDACTED (Roberto Aloi) Date: Tue, 14 Oct 2008 10:42:04 +0100 Subject: [erlang-questions] PDG Generation in Erlang Message-ID: <48F4696C.20406@erlang-consulting.com> Hello everyone, I'm trying to dynamically create a PDF file within an erlang server, sending it to a requesting client, but I couldn't find any library that support that. Any hint? Regards, Roberto Aloi From ulf@REDACTED Tue Oct 14 11:50:31 2008 From: ulf@REDACTED (Ulf Wiger) Date: Tue, 14 Oct 2008 11:50:31 +0200 Subject: [erlang-questions] PDG Generation in Erlang In-Reply-To: <48F4696C.20406@erlang-consulting.com> References: <48F4696C.20406@erlang-consulting.com> Message-ID: <8209f740810140250uec7b296w6eac0b0ea956080@mail.gmail.com> You could take a look at erlguten: http://code.google.com/p/erlguten/ BR, Ulf W 2008/10/14 Roberto Aloi : > Hello everyone, > I'm trying to dynamically create a PDF file within an erlang server, > sending it to a requesting client, but I couldn't find any library that > support that. > Any hint? > Regards, > > Roberto Aloi > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From roberto@REDACTED Tue Oct 14 12:10:09 2008 From: roberto@REDACTED (Roberto Aloi) Date: Tue, 14 Oct 2008 11:10:09 +0100 Subject: [erlang-questions] PDG Generation in Erlang In-Reply-To: <48F4696C.20406@erlang-consulting.com> References: <48F4696C.20406@erlang-consulting.com> Message-ID: <48F47001.2010402@erlang-consulting.com> It seems to be exactly what I was looking for. Cheers, Roberto Aloi From armstrong.whit@REDACTED Tue Oct 14 13:28:13 2008 From: armstrong.whit@REDACTED (Whit Armstrong) Date: Tue, 14 Oct 2008 07:28:13 -0400 Subject: [erlang-questions] Article on Erlang in ACM Queue In-Reply-To: <48EF60A6.10400@ericsson.com> References: <48ED943A.80801@berabera.info> <8ec76080810100621r48b0a482j1e02ad8bf5788a58@mail.gmail.com> <48EF60A6.10400@ericsson.com> Message-ID: <8ec76080810140428v3cf77612ofa0b4c488e51b21d@mail.gmail.com> Thanks for the feedback everyone. FFI looks very interesting. does Erlang make guarantees about storing data in contiguous memory? My guess is that the binary data type was designed with that in mind. However, do I understand correctly that floats cannot be stored in a binary data type? for instance: Eshell V5.6.3 (abort with ^G) 1> X = <<1,3,9>>. <<1,3,9>> 2> Y = <<1.0,3.0,9.0>>. ** exception error: bad argument 3> or am I missing something obvious? Can anyone refer me to the source file that defines binary data types? Thanks, Whit On Fri, Oct 10, 2008 at 10:03 AM, Ulf Wiger (TN/EAB) wrote: > Whit Armstrong skrev: >> >> I'm new to Erlang. I've been considering it for a few simulation >> projects in finance. However, I was discouraged because the ACM >> article suggests that Erlang has poor floating point performance. >> >> Are any list members using Erlang for numerical simulations? If so, >> do you have any advice on how to how to improve efficiency? What >> about using binaries to store vectors of doubles? Are there any >> extensions of Erlang that allow one to do that? > > Perhaps this might at least give you some initial intuition: > > High-performance Technical Computing with Erlang > Alceste Scalas Giovanni Casu Piero Pili > Center for Advanced Studies, Research and Development in Sardinia > ACM ICFP 2008 / Erlang Workshop > September 27th, 2008 > Victoria, BC, Canada > > http://www.erlang.org/workshop/2008/Sess23.pdf > > BR, > Ulf W > From armstrong.whit@REDACTED Tue Oct 14 13:31:05 2008 From: armstrong.whit@REDACTED (Whit Armstrong) Date: Tue, 14 Oct 2008 07:31:05 -0400 Subject: [erlang-questions] Article on Erlang in ACM Queue In-Reply-To: References: <48ED943A.80801@berabera.info> <8ec76080810100621r48b0a482j1e02ad8bf5788a58@mail.gmail.com> Message-ID: <8ec76080810140431i4264e06ala8c42a41b5f30e56@mail.gmail.com> Bill, Thanks for the code. Any chance that you have a quadratic optimization method defined in Erlang code? I'd be very curious to see how that problem is tackled in Erlang. Cheers, Whit On Fri, Oct 10, 2008 at 9:46 AM, Bill McKeeman wrote: > I think it depends on how much you can do in parallel and how much is really floating point as contrasted to function calls and the like. I wrote a numerical integration routine with a parameter N for the number of cores I expected to use. Even with N = 2 it was better than some competing sequential versions. I'll attach the code. > /s/Bill > > -----Original Message----- > From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Whit Armstrong > Sent: Friday, October 10, 2008 9:22 AM > To: Erlang mailing list > Subject: Re: [erlang-questions] Article on Erlang in ACM Queue > > I'm new to Erlang. I've been considering it for a few simulation > projects in finance. However, I was discouraged because the ACM > article suggests that Erlang has poor floating point performance. > > Are any list members using Erlang for numerical simulations? If so, > do you have any advice on how to how to improve efficiency? What > about using binaries to store vectors of doubles? Are there any > extensions of Erlang that allow one to do that? > > Any feedback is appreciated. > > Thanks, > Whit > > > On Thu, Oct 9, 2008 at 1:18 AM, Romain Lenglet > wrote: >> Jim Larson has written an article entitled "Erlang for Concurrent >> Programming", published in the latest ACM Queue: >> http://mags.acm.org/queue/200809/ >> >> This article is a very good, practical introduction to Erlang and OTP. >> >> -- >> Romain Lenglet >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From freza@REDACTED Tue Oct 14 14:10:06 2008 From: freza@REDACTED (Jachym Holecek) Date: Tue, 14 Oct 2008 14:10:06 +0200 Subject: [erlang-questions] Article on Erlang in ACM Queue In-Reply-To: <8ec76080810140428v3cf77612ofa0b4c488e51b21d@mail.gmail.com> References: <48ED943A.80801@berabera.info> <8ec76080810100621r48b0a482j1e02ad8bf5788a58@mail.gmail.com> <48EF60A6.10400@ericsson.com> <8ec76080810140428v3cf77612ofa0b4c488e51b21d@mail.gmail.com> Message-ID: <20081014121006.GA1897@hanele.fractal2003.cz> # Whit Armstrong 2008-10-14: > Thanks for the feedback everyone. FFI looks very interesting. > [...] > Can anyone refer me to the source file that defines binary data types? erts/emulator/beam/erl_binary.h erts/emulator/beam/erl_term.h erts/emulator/beam/binary.c -- Jachym From florian.ebeling@REDACTED Tue Oct 14 15:01:36 2008 From: florian.ebeling@REDACTED (C. Florian Ebeling) Date: Tue, 14 Oct 2008 15:01:36 +0200 Subject: [erlang-questions] Specify version in release using woldcards? Message-ID: <5cbbe4ae0810140601r1c8da84ah72f52739f1c6cead@mail.gmail.com> Hi, we have an application on which two people are working using defferent kinds of unix/linux distributions (Mac and Suse). So they have deferent releases of erlang installed. When I use this release spec, I get warnings from make_script/2. {release, {"adrecord_rel","1.0"}, {erts, "5.6.3"}, [{kernel,"2.12.3"}, {stdlib,"1.15.3"}, {sasl, "2.1.5.3"}, {crypto, "1.5.2"}, {adrecord, "0.1"}]} which look like this: erl -noshell -pa ebin -eval 'systools:make_script("adrecord", [local])' -s init stop crypto: No valid version ("1.5.2") of .app file found. Found file "/opt/local/lib/erlang/lib/crypto-1.5.2.1/ebin/crypto.app" with version "1.5.2.1" Is there some elegant way to deal with this? Can I maybe specify some wildcards or only the more major part of versions? Florian -- Florian Ebeling Twitter: febeling florian.ebeling@REDACTED From anders.nygren@REDACTED Tue Oct 14 15:14:08 2008 From: anders.nygren@REDACTED (Anders Nygren) Date: Tue, 14 Oct 2008 08:14:08 -0500 Subject: [erlang-questions] Article on Erlang in ACM Queue In-Reply-To: <8ec76080810140428v3cf77612ofa0b4c488e51b21d@mail.gmail.com> References: <48ED943A.80801@berabera.info> <8ec76080810100621r48b0a482j1e02ad8bf5788a58@mail.gmail.com> <48EF60A6.10400@ericsson.com> <8ec76080810140428v3cf77612ofa0b4c488e51b21d@mail.gmail.com> Message-ID: On Tue, Oct 14, 2008 at 6:28 AM, Whit Armstrong wrote: > Thanks for the feedback everyone. FFI looks very interesting. > > does Erlang make guarantees about storing data in contiguous memory? > My guess is that the binary data type was designed with that in mind. > However, do I understand correctly that floats cannot be stored in a > binary data type? > > for instance: > > Eshell V5.6.3 (abort with ^G) > 1> X = <<1,3,9>>. > <<1,3,9>> > 2> Y = <<1.0,3.0,9.0>>. > ** exception error: bad argument > 3> > > or am I missing something obvious? > You need to tell the compiler that it is supposed to be floats. Like Y = <<1.0/float,3.0/float,9.0/float>>. <<63,240,0,0,0,0,0,0,64,8,0,0,0,0,0,0,64,34,0,0,0,0,0,0>> see the documentation, especially http://erlang.org/doc/programming_examples/bit_syntax.html#4 for more details /Anders > Can anyone refer me to the source file that defines binary data types? > > Thanks, > Whit > > > > > On Fri, Oct 10, 2008 at 10:03 AM, Ulf Wiger (TN/EAB) > wrote: >> Whit Armstrong skrev: >>> >>> I'm new to Erlang. I've been considering it for a few simulation >>> projects in finance. However, I was discouraged because the ACM >>> article suggests that Erlang has poor floating point performance. >>> >>> Are any list members using Erlang for numerical simulations? If so, >>> do you have any advice on how to how to improve efficiency? What >>> about using binaries to store vectors of doubles? Are there any >>> extensions of Erlang that allow one to do that? >> >> Perhaps this might at least give you some initial intuition: >> >> High-performance Technical Computing with Erlang >> Alceste Scalas Giovanni Casu Piero Pili >> Center for Advanced Studies, Research and Development in Sardinia >> ACM ICFP 2008 / Erlang Workshop >> September 27th, 2008 >> Victoria, BC, Canada >> >> http://www.erlang.org/workshop/2008/Sess23.pdf >> >> BR, >> Ulf W >> > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From alceste@REDACTED Tue Oct 14 14:15:38 2008 From: alceste@REDACTED (Alceste Scalas) Date: Tue, 14 Oct 2008 14:15:38 +0200 Subject: [erlang-questions] Article on Erlang in ACM Queue In-Reply-To: <8ec76080810140428v3cf77612ofa0b4c488e51b21d@mail.gmail.com> References: <48ED943A.80801@berabera.info> <8ec76080810100621r48b0a482j1e02ad8bf5788a58@mail.gmail.com> <48EF60A6.10400@ericsson.com> <8ec76080810140428v3cf77612ofa0b4c488e51b21d@mail.gmail.com> Message-ID: <1223986538.8191.71.camel@gnatziu> Il giorno mar, 14/10/2008 alle 07.28 -0400, Whit Armstrong ha scritto: > does Erlang make guarantees about storing data in contiguous memory? > My guess is that the binary data type was designed with that in mind. Yes, binary data is guaranteed to be stored in contiguous memory. See: http://erlang.org/doc/reference_manual/data_types.html#2.4 > However, do I understand correctly that floats cannot be stored in a > binary data type? Sure they can, just try with: %% Single precision Y1 = <<1.0:32/native-float, 2.0:32/native-float, 3.0:32/native-float>>. %% Double precision Y2 = <<1.0:64/native-float, 2.0:64/native-float, 3.0:64/native-float>>. More details on: http://erlang.org/doc/reference_manual/expressions.html#bit_syntax Regards, -- Alceste Scalas CRS4 - http://www.crs4.it/ From harveyd@REDACTED Tue Oct 14 15:36:05 2008 From: harveyd@REDACTED (Dale Harvey) Date: Tue, 14 Oct 2008 14:36:05 +0100 Subject: [erlang-questions] Specify version in release using woldcards? In-Reply-To: <5cbbe4ae0810140601r1c8da84ah72f52739f1c6cead@mail.gmail.com> References: <5cbbe4ae0810140601r1c8da84ah72f52739f1c6cead@mail.gmail.com> Message-ID: might not be the best solution, but I just build the spec file dynamically before building the boot script get_vsn(Module) -> AppFile = code:lib_dir(Module)++"/ebin/"++atom_to_list(Module)++".app", {ok,[{application,_App,Attrs}]} = file:consult(AppFile), {value,{vsn,Vsn}} = lists:keysearch(vsn,1,Attrs), Vsn get_vsn(crypto) will then get you the installed version of crypto use get_vsn and erlang:system_info(version) to build the spec file, write it, and then call make_script 2008/10/14 C. Florian Ebeling > Hi, > > we have an application on which two people are working > using defferent kinds of unix/linux distributions (Mac and Suse). > > So they have deferent releases of erlang installed. When > I use this release spec, I get warnings from make_script/2. > > {release, {"adrecord_rel","1.0"}, {erts, "5.6.3"}, > [{kernel,"2.12.3"}, > {stdlib,"1.15.3"}, > {sasl, "2.1.5.3"}, > {crypto, "1.5.2"}, > {adrecord, "0.1"}]} > > which look like this: > > erl -noshell -pa ebin -eval 'systools:make_script("adrecord", > [local])' -s init stop > crypto: No valid version ("1.5.2") of .app file found. Found file > "/opt/local/lib/erlang/lib/crypto-1.5.2.1/ebin/crypto.app" with > version "1.5.2.1" > > Is there some elegant way to deal with this? Can I maybe > specify some wildcards or only the more major part of versions? > > Florian > > > -- > Florian Ebeling > Twitter: febeling > florian.ebeling@REDACTED > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From florian.ebeling@REDACTED Tue Oct 14 15:42:05 2008 From: florian.ebeling@REDACTED (C. Florian Ebeling) Date: Tue, 14 Oct 2008 15:42:05 +0200 Subject: [erlang-questions] Specify version in release using woldcards? In-Reply-To: References: <5cbbe4ae0810140601r1c8da84ah72f52739f1c6cead@mail.gmail.com> Message-ID: <5cbbe4ae0810140642j20a13ee2n353f9660cdd69b67@mail.gmail.com> On Tue, Oct 14, 2008 at 3:36 PM, Dale Harvey wrote: > might not be the best solution, but I just build the spec file dynamically > before building the boot script > > get_vsn(Module) -> > AppFile = code:lib_dir(Module)++"/ebin/"++atom_to_list(Module)++".app", > {ok,[{application,_App,Attrs}]} = file:consult(AppFile), > {value,{vsn,Vsn}} = lists:keysearch(vsn,1,Attrs), > Vsn > > get_vsn(crypto) will then get you the installed version of crypto > > use get_vsn and erlang:system_info(version) to build the spec file, > write it, and then call make_script yes, I was kind of hoping to avoid that route :) Anyway, thanks for posting the details how to do that. Florian -- Florian Ebeling Twitter: febeling florian.ebeling@REDACTED From devdoer2@REDACTED Tue Oct 14 15:56:13 2008 From: devdoer2@REDACTED (devdoer bird) Date: Tue, 14 Oct 2008 21:56:13 +0800 Subject: [erlang-questions] Failed to fetch .app file when using "-loader inet" and erl_boot_server Message-ID: HI: I decide to run a diskless node and let it fetch code from a remote machine. I accomplish this by using erl_boot_server and starting the remote node with "-loader inet -hosts" parameters. It is ok to fetch code from the code server node on which erl_boot_server is started, but the .app file is failed to fetch. It report the error "{error,{"no such file or directory","some_application.app"}}" . So how can I configure the boot server to let it run a application on the remote diskless node If the application's app file can't be passed to the remote node? -------------- next part -------------- An HTML attachment was scrubbed... URL: From erlang@REDACTED Tue Oct 14 17:31:02 2008 From: erlang@REDACTED (Joe Armstrong) Date: Tue, 14 Oct 2008 17:31:02 +0200 Subject: [erlang-questions] Finding inconsistencies in record definitions and pretty printing records Message-ID: <9b08084c0810140831s5d8e1828x1e9a836b17951fc5@mail.gmail.com> Hi, This is a method for ensuring the consistency of records and for providing record field information at run-time. Long-time readers of this list will recognize this as a long-standing problem. (what's the problem? if you change a record definition and forget to recompile everything you will get fried - and record definitions get forgotten at run time) (Short summary of how it works) - compile record definitions into the modules (uses a simple parse transform) - hack the error_handler so that every time a new module is loaded the record definitions in the module are sent to a global server that remembers all record definitions - make a global sever to check the consistency of the record definitions - start things off the right way ... (The long version) Here's what I do: 1) make a parse transform that compiles all local and included record definitions into a file. If you include the line: -compile({parse_transform, jalib_records}). In your code then an extra function called module_records() -> ... will be included into the compiled code for your module. 2) Change error_handler.erl The old code: ensure_loaded(Module) -> Self = self(), case whereis(code_server) of %% Perhaps double fault should be detected in code:ensure_loaded/1 %% instead, since this error handler cannot know whether the %% code server can resolve the problem or not. %% An {error, Reason} return from there would crash the code server and %% bring down the node. Self -> Error = "The code server called the unloaded module `" ++ atom_to_list(Module) ++ "'", halt(Error); Pid when is_pid(Pid) -> code:ensure_loaded(Module); _ -> init:ensure_loaded(Module) end. Is changed to: ensure_loaded(Module) -> Self = self(), case whereis(code_server) of %% Perhaps double fault should be detected in code:ensure_loaded/1 %% instead, since this error handler cannot know whether the %% code server can resolve the problem or not. %% An {error, Reason} return from there would crash the code server and %% bring down the node. Self -> Error = "The code server called the unloaded module `" ++ atom_to_list(Module) ++ "'", halt(Error); Pid when is_pid(Pid) -> Val = code:ensure_loaded(Module), run_on_load(Module), %% **** NEW STUFF Val; _ -> init:ensure_loaded(Module) end. Where run_on_load(Mod) -> case erlang:function_exported(Mod, module_records, 0) of true -> Records = Mod:module_records(), %% assume a registered process %% jalib_records that keeps track of all records (catch jalib_records ! {loaded, Mod, Records}); false -> void end. 3) jalib_records.erl also has a server that keeps track of the records. So I have to start this somehow. I added these lines to my ${HOME}/.erlang (catch jalib_records:start()). code:unstick_mod(error_handler). code:load_abs("/home/joe/code/jalib/error_handler"). io:format("new error handler loaded~n"). Now we're ready to test 0) compile error_handler.erl and jalib_records.erl and put in your path. a) Here's a module with some records -module(rec_test1). -compile(export_all). -compile({parse_transform, jalib_records}). -record(foo, {a=1,b=2,c=[]}). -record(bar, {x=2,y=23}). foo() -> {#foo{}, #bar{}}. test() -> jalib_records:print_record(#foo{a=hello}). b) and rec_test2.erl -module(rec_test2). -compile(export_all). -compile({parse_transform, jalib_records}). -record(foo, {a=1,b=2,c=[]}). -record(bar, {x=2,y=23,z=6}). foo() -> {#foo{}, #bar{}}. test() -> jalib_records:print_record(#foo{a=hello}). c) Compile both: erlc rec_test1.erl rec_test2.erl d) run in the shell 1> rec_test1:test(). "#foo{a = hello,b = 2,c = []}" It works 2> rec_test2:test(). *** Record definition error: Record:bar Old Mod:rec_test1 definition:[{x,2},{y,23}] New Mod:rec_test2 definition:[{x,2},{y,23},{z,6}] "#foo{a = hello,b = 2,c = []}" Yes - we detect that the module definition of bar is inconsistent. This is a quick and dirty prototype - which shows that the method works. For a production version some improvements are necessary: - make it work for incremental code loading (it only works the first time you load a module) - improve error messages (ie make uniform with OTP standards) - improve pretty printer Have fun /Joe Armstrong -------------- next part -------------- A non-text attachment was scrubbed... Name: jalib_records.erl Type: application/octet-stream Size: 3613 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: error_handler.erl Type: application/octet-stream Size: 4462 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: rec_test1.erl Type: application/octet-stream Size: 235 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: rec_test2.erl Type: application/octet-stream Size: 239 bytes Desc: not available URL: From ulf.wiger@REDACTED Tue Oct 14 17:51:07 2008 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Tue, 14 Oct 2008 17:51:07 +0200 Subject: [erlang-questions] Finding inconsistencies in record definitions and pretty printing records In-Reply-To: <9b08084c0810140831s5d8e1828x1e9a836b17951fc5@mail.gmail.com> References: <9b08084c0810140831s5d8e1828x1e9a836b17951fc5@mail.gmail.com> Message-ID: <48F4BFEB.4050803@ericsson.com> Joe Armstrong skrev: > > For a production version some improvements are necessary: > > - ... > - improve pretty printer Therer is already a good pretty printer of records in OTP: io_lib_pretty:print(Term, Column, LineLength, Depth, RecDefFun) where Column is typically 1, LineLength = 30 in the shell, and RecDefFun = fun(Tag, N_fields) -> [Field_name] | no See shell.erl for how it's used. I played around with it here: http://ulf.wiger.net/weblog/2007/11/20/extending-the-erlang-shell-part-1/ BR, Ulf W From erlang@REDACTED Tue Oct 14 21:57:49 2008 From: erlang@REDACTED (Joe Armstrong) Date: Tue, 14 Oct 2008 21:57:49 +0200 Subject: [erlang-questions] Finding inconsistencies in record definitions and pretty printing records In-Reply-To: <87vdvv6tkb.fsf@sterlett.hq.kred> References: <9b08084c0810140831s5d8e1828x1e9a836b17951fc5@mail.gmail.com> <87vdvv6tkb.fsf@sterlett.hq.kred> Message-ID: <9b08084c0810141257o651f363fx82dddfe0749cbe97@mail.gmail.com> On Tue, Oct 14, 2008 at 6:16 PM, mats cronqvist wrote: > "Joe Armstrong" writes: > >> Hi, >> >> This is a method for ensuring the consistency of records and for >> providing record field information at run-time. >> >> Long-time readers of this list will recognize this as a long-standing >> problem. >> >> (what's the problem? if you change a record definition and >> forget to recompile everything you will get fried - and >> record definitions get forgotten at run time) >> >> (Short summary of how it works) >> >> - compile record definitions into the modules >> (uses a simple parse transform) > > this is the problematic bit. as has been hashed several times on > this list, were record info exported (perhaps as a field in > module_info), all kinds of cool things could be accomplished. It's not problematic - the parse transform in the enclosed code does exactly that. The enclosed code compiles record defs into the modules concerned - sets up the servers, detects module inconsitencies at run time and retrieves record definitions at run time *from any module* (not just the definition module). As far as I can see it is ready to include in a production version - except for a slight improvement to the pretty printer and to make sure the definitions are reloaded when we recompile a module. A slight (and obvious) change makes all kind of dynamic (and generic) record operations possible. ie things like doing X#rec{a=A} at run time *in any module* when the module concerned did not have knowledge of #rec at compile time. (hint change the parse transform to make an efficient form of module_record so that calling module_record(rec, a) -> 1 (or whatever) the "trick" is in finding which module #rec came from - and this is solved in the enclosed code. (With a simple optimization in the beam (hint - cache the module, once it it is known) this would be pretty efficient). /Joe > > mats > From erlang@REDACTED Tue Oct 14 21:59:44 2008 From: erlang@REDACTED (Joe Armstrong) Date: Tue, 14 Oct 2008 21:59:44 +0200 Subject: [erlang-questions] Finding inconsistencies in record definitions and pretty printing records In-Reply-To: <48F4BFEB.4050803@ericsson.com> References: <9b08084c0810140831s5d8e1828x1e9a836b17951fc5@mail.gmail.com> <48F4BFEB.4050803@ericsson.com> Message-ID: <9b08084c0810141259h68cbf74ch76d1bc36ef794fd1@mail.gmail.com> Thanks - so now I can hack this to fetch RecDefFun at run-time :-) /Joe On Tue, Oct 14, 2008 at 5:51 PM, Ulf Wiger (TN/EAB) wrote: > Joe Armstrong skrev: >> >> For a production version some improvements are necessary: >> >> - ... >> - improve pretty printer > > Therer is already a good pretty printer of records in OTP: > io_lib_pretty:print(Term, Column, LineLength, Depth, RecDefFun) > > where Column is typically 1, LineLength = 30 in the shell, > and RecDefFun = fun(Tag, N_fields) -> [Field_name] | no > > See shell.erl for how it's used. > > I played around with it here: > http://ulf.wiger.net/weblog/2007/11/20/extending-the-erlang-shell-part-1/ > > BR, > Ulf W > From kenneth.lundin@REDACTED Tue Oct 14 23:52:27 2008 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Tue, 14 Oct 2008 23:52:27 +0200 Subject: [erlang-questions] What's the status of erl_com, the Erlang-to-COM bridge? In-Reply-To: References: Message-ID: Hi, The Comet application did never reach more than alfa or maybe beta status before we stopped the development due to no customers for it. We had to prioritize other things instead. It has not been maintained or even used for maybe 7 years or more now. It will for sure not even build toegther with the latest release (R12B). I have no idea how much work it will be to get it in a useful state. We have no plans to work with it. /Kenneth Erlang/OTP team , Ericsson On Tue, Oct 14, 2008 at 8:43 AM, David Mitchell wrote: > Hello everyone, > > I've come across what used to be called the COMET project, or erl_com, > which is a bridge between Erlang and COM on Windows. Unfortunately, > all the info I can find on it is several years old, but it would be > very useful to me if it was still usable, supportable, etc. > > Does anyone know the status of this project? Is it still active (and > I haven't been able to find any recent docs)? Has it been replaced by > something else? Does it still work in R11 or R12? > > Thanks in advance > > Dave M. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From monch1962@REDACTED Wed Oct 15 06:52:24 2008 From: monch1962@REDACTED (David Mitchell) Date: Wed, 15 Oct 2008 15:52:24 +1100 Subject: [erlang-questions] What's the status of erl_com, the Erlang-to-COM bridge? In-Reply-To: References: Message-ID: Thanks Jakob and Kenneth for your responses. I need to hook Erlang to a variety of external applications (MQ, Tibco Rendezvous, Oracle), none of which have "native" Erlang interfaces but all have COM interfaces available. Comet looked like a good fit (assuming I ran Erlang on a Windows box), but based on your comments I'll look elsewhere. That probably means building a C port for MQ and Tibco, and I may be able to get away with using ODBC for Oracle. If you need any votes of support to revive COMET within Ericsson, please let me know ;-> Thanks again Dave M. 2008/10/15 Kenneth Lundin : > Hi, > > The Comet application did never reach more than alfa or maybe beta > status before we stopped the development due to > no customers for it. We had to prioritize other things instead. > It has not been maintained or even used for maybe 7 years or more now. > It will for sure not even build toegther with the latest release (R12B). > I have no idea how much work it will be to get it in a useful state. > > We have no plans to work with it. > > /Kenneth Erlang/OTP team , Ericsson > > On Tue, Oct 14, 2008 at 8:43 AM, David Mitchell wrote: >> Hello everyone, >> >> I've come across what used to be called the COMET project, or erl_com, >> which is a bridge between Erlang and COM on Windows. Unfortunately, >> all the info I can find on it is several years old, but it would be >> very useful to me if it was still usable, supportable, etc. >> >> Does anyone know the status of this project? Is it still active (and >> I haven't been able to find any recent docs)? Has it been replaced by >> something else? Does it still work in R11 or R12? >> >> Thanks in advance >> >> Dave M. >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > From jeffm@REDACTED Wed Oct 15 07:46:00 2008 From: jeffm@REDACTED (jm) Date: Wed, 15 Oct 2008 16:46:00 +1100 Subject: [erlang-questions] Q: Differenciating between List and List of Lists Message-ID: <48F58398.6040801@ghostgun.com> What is the best way to tell the difference between a list and a list of lists (possible in a guard)? What I'm trying to differentiate between is a string, eg, "astring" and a list of strings, eg ["a", "list", "of", "strings"]. Jeff. From jerome@REDACTED Wed Oct 15 08:05:47 2008 From: jerome@REDACTED (=?ISO-8859-1?Q?J=E9r=F4me_Desquilbet?=) Date: Wed, 15 Oct 2008 08:05:47 +0200 Subject: [erlang-questions] generating primes In-Reply-To: <3BE6DBA1F3BE9D4798255806113D56540F78C912D5@utx-exchange.utx.local> References: <3BE6DBA1F3BE9D4798255806113D56540F78C912D5@utx-exchange.utx.local> Message-ID: <48F5883B.8080607@desquilbet.org> Imre Palik a ?crit : > Hi, > > I am playing with Project Euler nowdays, and in the last few problems > I solved I had problems generating primes fast enough. Currently I > am using the following implementation of the Sieve of Eratosthenes: > > sieve([]) -> []; sieve([H|T]) -> [H|sieve([X||X<-T,X rem H =/= 0])]. > > ... Would you like a suboptimal algorithm? Here it is: N primes --> N sieves --> N erlang processes. It's all about playing after all... :-) J?r?me. PS: it's translated from an Ada example from Alan Burns and Andy Wellings. -----8<-------------------------- -module(eratosthenes). -export([message_logger/0, run/0, prime_collector/0, process_next_numbers/2, start_sieve/2, wait_for_next_prime/1]). message_logger() -> receive {prime_msg, P} -> io:format("~p is prime!~n", [P]), message_logger() end. prime_collector() -> receive Prime -> logger ! {prime_msg, Prime}, prime_collector() end. run() -> register(logger, spawn(?MODULE, message_logger, [])), Collector = spawn(?MODULE, prime_collector, []), Collector ! 1, Collector ! 2, First_Sieve = spawn(?MODULE, start_sieve, [3, Collector]), give_odd(5, First_Sieve). give_odd(Odd, First_Sieve) -> First_Sieve ! Odd, give_odd(Odd+2, First_Sieve). start_sieve(Prime, Collector) -> Collector ! Prime, Next_Prime = wait_for_next_prime(Prime), Next_Sieve = spawn(?MODULE, start_sieve, [Next_Prime, Collector]), process_next_numbers(Prime, Next_Sieve). wait_for_next_prime(Current_Prime) -> receive Odd -> if Odd rem Current_Prime == 0 -> wait_for_next_prime(Current_Prime); true -> Odd end end. process_next_numbers(Current_Prime, Next_Sieve) -> receive Odd -> if Odd rem Current_Prime /= 0 -> Next_Sieve ! Odd; true -> false end, process_next_numbers(Current_Prime, Next_Sieve) end. -----8<-------------------------- From vladdu55@REDACTED Wed Oct 15 08:22:08 2008 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Wed, 15 Oct 2008 08:22:08 +0200 Subject: [erlang-questions] Finding inconsistencies in record definitions and pretty printing records In-Reply-To: <9b08084c0810141257o651f363fx82dddfe0749cbe97@mail.gmail.com> References: <9b08084c0810140831s5d8e1828x1e9a836b17951fc5@mail.gmail.com> <87vdvv6tkb.fsf@sterlett.hq.kred> <9b08084c0810141257o651f363fx82dddfe0749cbe97@mail.gmail.com> Message-ID: <95be1d3b0810142322o684e4ac2xa148dfc8f1b1b99f@mail.gmail.com> Hi, On Tue, Oct 14, 2008 at 21:57, Joe Armstrong wrote: > On Tue, Oct 14, 2008 at 6:16 PM, mats cronqvist >> "Joe Armstrong" writes: >>> - compile record definitions into the modules >>> (uses a simple parse transform) >> >> this is the problematic bit. as has been hashed several times on >> this list, were record info exported (perhaps as a field in >> module_info), all kinds of cool things could be accomplished. > > It's not problematic - the parse transform in the enclosed code does > exactly that. > > The enclosed code compiles record defs into the modules > concerned - sets up the servers, detects module inconsitencies at run > time and retrieves record definitions at run time *from any module* > (not just the definition module). This is cool! Am I right that the "any module" above should be "any module compiled with this parse_transform"? If yes, it restricts a little working with legacy code, but it's still cool :-) regards, Vlad From vlm@REDACTED Wed Oct 15 08:23:14 2008 From: vlm@REDACTED (Lev Walkin) Date: Wed, 15 Oct 2008 10:23:14 +0400 Subject: [erlang-questions] Q: Differenciating between List and List of Lists In-Reply-To: <48F58398.6040801@ghostgun.com> References: <48F58398.6040801@ghostgun.com> Message-ID: <48F58C52.5070609@lionet.info> jm wrote: > What is the best way to tell the difference between a list and a list of > lists (possible in a guard)? What I'm trying to differentiate between is > a string, eg, "astring" and a list of strings, eg ["a", "list", "of", > "strings"]. Differentiating between just these two is easy, provided that the lists are non-empty: classify([I|_]) when is_integer(I) -> string; classify([L|_]) when is_list(L) -> list. in guard: just try the is_list/is_integer on the first element. However, look out for lists which aren't strings or lists of lists, such as [123,[def],$g,$h]. Hopefully you don't use them in your particular application. -- Lev Walkin vlm@REDACTED From erlang@REDACTED Wed Oct 15 08:45:57 2008 From: erlang@REDACTED (Joe Armstrong) Date: Wed, 15 Oct 2008 08:45:57 +0200 Subject: [erlang-questions] Finding inconsistencies in record definitions and pretty printing records In-Reply-To: <95be1d3b0810142322o684e4ac2xa148dfc8f1b1b99f@mail.gmail.com> References: <9b08084c0810140831s5d8e1828x1e9a836b17951fc5@mail.gmail.com> <87vdvv6tkb.fsf@sterlett.hq.kred> <9b08084c0810141257o651f363fx82dddfe0749cbe97@mail.gmail.com> <95be1d3b0810142322o684e4ac2xa148dfc8f1b1b99f@mail.gmail.com> Message-ID: <9b08084c0810142345j64bc24e6m2fe5b184ee6ffc91@mail.gmail.com> On Wed, Oct 15, 2008 at 8:22 AM, Vlad Dumitrescu wrote: > Hi, > > On Tue, Oct 14, 2008 at 21:57, Joe Armstrong wrote: >> On Tue, Oct 14, 2008 at 6:16 PM, mats cronqvist >>> "Joe Armstrong" writes: >>>> - compile record definitions into the modules >>>> (uses a simple parse transform) >>> >>> this is the problematic bit. as has been hashed several times on >>> this list, were record info exported (perhaps as a field in >>> module_info), all kinds of cool things could be accomplished. >> >> It's not problematic - the parse transform in the enclosed code does >> exactly that. >> >> The enclosed code compiles record defs into the modules >> concerned - sets up the servers, detects module inconsitencies at run >> time and retrieves record definitions at run time *from any module* >> (not just the definition module). > > This is cool! > > Am I right that the "any module" above should be "any module compiled > with this parse_transform"? If yes, it restricts a little working with > legacy code, but it's still cool :-) Yes - you have to recompile the modules erlc +'{parse_transform, jalib_records}' *.erl The point to recognise is that you have to add an "on_load" trigger - that puts the record definition into a *global* store of some kind. In fact It might be better to do this ensure_loaded(Module) -> Self = self(), case whereis(code_server) of Self -> Error = "The code server called the unloaded module `" ++ atom_to_list(Module) ++ "'", halt(Error); Pid when is_pid(Pid) -> Val = code:ensure_loaded(Module), (catch load_daemon ! {loaded, Module}), %% <---- the nifty bit Val; _ -> init:ensure_loaded(Module) end. Then if there is a registered load_daemon process it can do whatever it likes, for example receive {loaded, Mod} -> case erlang:function_exported(Mod, auto_exec_bat, 0) of true -> spawn(fun() -> Mod:auto_exec_bat() end); false -> void end , ... Loading a module is so important that perhaps it deserves a standard trigger ! /Joe > > regards, > Vlad > From tom@REDACTED Wed Oct 15 08:40:59 2008 From: tom@REDACTED (Tom Samplonius) Date: Tue, 14 Oct 2008 23:40:59 -0700 (PDT) Subject: [erlang-questions] Erlang with MonetDb In-Reply-To: <3bb44c6e0810080607m21ce8ef3o2d8fdfc054a9346d@mail.gmail.com> Message-ID: <12493306.9051224052859119.JavaMail.root@ly.sdf.com> ... > Well, in case it turns out we don't want to use it does anyone have a > good column store that they can recommend to use in conjunction with > Erlang? > > Cheers, > Bryan Rasmussen Maybe Scalaris? http://code.google.com/p/scalaris/ Tom From ulf.wiger@REDACTED Wed Oct 15 08:56:58 2008 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Wed, 15 Oct 2008 08:56:58 +0200 Subject: [erlang-questions] Finding inconsistencies in record definitions and pretty printing records In-Reply-To: <9b08084c0810141259h68cbf74ch76d1bc36ef794fd1@mail.gmail.com> References: <9b08084c0810140831s5d8e1828x1e9a836b17951fc5@mail.gmail.com> <48F4BFEB.4050803@ericsson.com> <9b08084c0810141259h68cbf74ch76d1bc36ef794fd1@mail.gmail.com> Message-ID: <48F5943A.6000004@ericsson.com> Joe Armstrong skrev: > Thanks - so now I can hack this to fetch RecDefFun at run-time :-) > > /Joe The shell already fetches the record definitions at run-time, so no need to hack io_lib_pretty... ...although I did, of course, but that was just to support custom formatting of complex data structures, such as: 3> dict:from_list([{N,a} || N <- lists:seq(1,5)]). <|dict:[{3,a},{2,a},{5,a},{1,a},{4,a}]|> BR, Ulf W > > > On Tue, Oct 14, 2008 at 5:51 PM, Ulf Wiger (TN/EAB) > wrote: >> Joe Armstrong skrev: >>> For a production version some improvements are necessary: >>> >>> - ... >>> - improve pretty printer >> Therer is already a good pretty printer of records in OTP: >> io_lib_pretty:print(Term, Column, LineLength, Depth, RecDefFun) >> >> where Column is typically 1, LineLength = 30 in the shell, >> and RecDefFun = fun(Tag, N_fields) -> [Field_name] | no >> >> See shell.erl for how it's used. >> >> I played around with it here: >> http://ulf.wiger.net/weblog/2007/11/20/extending-the-erlang-shell-part-1/ >> >> BR, >> Ulf W >> From chn.dao77@REDACTED Wed Oct 15 10:46:31 2008 From: chn.dao77@REDACTED (WS Dao) Date: Wed, 15 Oct 2008 16:46:31 +0800 Subject: [erlang-questions] OTP float error on ARM. Message-ID: I cross-compiled OTP R12B4 for my ARM9 platform (S3C2410, kernel 2.4.18) When I run erl on arm, float error occurs: # ./erl Eshell V5.6.4 (abort with ^G) 1> 3+5. 8 2> 3.0. 0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005307579804 3> 3.0+4.0. 0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000531405562 4> My toolchain is gcc 3.4.5. I'd wrote a c test program and cross-compile it, no float problems found. Any suggestion? -dao -------------- next part -------------- An HTML attachment was scrubbed... URL: From roberto@REDACTED Wed Oct 15 10:57:29 2008 From: roberto@REDACTED (Roberto Aloi) Date: Wed, 15 Oct 2008 09:57:29 +0100 Subject: [erlang-questions] Q: Differenciating between List and List of Lists In-Reply-To: <48F58398.6040801@ghostgun.com> References: <48F58398.6040801@ghostgun.com> Message-ID: <48F5B079.6060808@erlang-consulting.com> > What is the best way to tell the difference between a list and a list of > lists (possible in a guard)? What I'm trying to differentiate between is > a string, eg, "astring" and a list of strings, eg ["a", "list", "of", > "strings"]. > I think the best way should be to organize your application so that you have a list containing one element only in the first case. I mean: ["astring"] instead of simply "astring". The main problem is that strings are not a data type in Erlang, but they are just lists of integers. If the above solution is not applicable for you, just check for the type of the contained elements. Something like: 1> List = "aList". "aList" 2> ListOfLists = ["first", "second"]. ["first","second"] 3> is_list(lists:nth(1,List)). false 4> is_list(lists:nth(1,ListOfLists)). true 5> is_integer(lists:nth(1,ListOfLists)). false 6> is_integer(lists:nth(1,List)). true Just remember to check for empty lists!!! Roberto Aloi From rasmussen.bryan@REDACTED Wed Oct 15 11:08:45 2008 From: rasmussen.bryan@REDACTED (bryan rasmussen) Date: Wed, 15 Oct 2008 11:08:45 +0200 Subject: [erlang-questions] php on yaws performance? Message-ID: <3bb44c6e0810150208x1ab86470v24c3828cb8759897@mail.gmail.com> Hi, I was just wondering about PHP on Yaws performance. Does php derive any performance benefits, scaling benefits? Does anyone out there have any success or horror stories of using PHP on Yaws? From what I understand PHP on Yaws is implemented via a CGI interface - any FastCGI like functionality? Best Regards, Bryan Rasmussen From bob@REDACTED Wed Oct 15 11:11:26 2008 From: bob@REDACTED (Bob Ippolito) Date: Wed, 15 Oct 2008 02:11:26 -0700 Subject: [erlang-questions] Erlang with MonetDb In-Reply-To: <12493306.9051224052859119.JavaMail.root@ly.sdf.com> References: <3bb44c6e0810080607m21ce8ef3o2d8fdfc054a9346d@mail.gmail.com> <12493306.9051224052859119.JavaMail.root@ly.sdf.com> Message-ID: <6a36e7290810150211k34a999aam4b2c679167e39074@mail.gmail.com> On Tue, Oct 14, 2008 at 11:40 PM, Tom Samplonius wrote: > > ... >> Well, in case it turns out we don't want to use it does anyone have a >> good column store that they can recommend to use in conjunction with >> Erlang? >> >> Cheers, >> Bryan Rasmussen > > Maybe Scalaris? > > http://code.google.com/p/scalaris/ Scalaris is not a column store, different use case. http://en.wikipedia.org/wiki/Column-oriented_DBMS -bob From rtrlists@REDACTED Wed Oct 15 11:31:28 2008 From: rtrlists@REDACTED (Robert Raschke) Date: Wed, 15 Oct 2008 10:31:28 +0100 Subject: [erlang-questions] What's the status of erl_com, the Erlang-to-COM bridge? In-Reply-To: References: Message-ID: <6a3ae47e0810150231j38381c94jf1be1874bf88b83d@mail.gmail.com> On Wed, Oct 15, 2008 at 5:52 AM, David Mitchell wrote: > Thanks Jakob and Kenneth for your responses. > > I need to hook Erlang to a variety of external applications (MQ, Tibco > Rendezvous, Oracle), none of which have "native" Erlang interfaces but > all have COM interfaces available. Comet looked like a good fit > (assuming I ran Erlang on a Windows box), but based on your comments > I'll look elsewhere. That probably means building a C port for MQ and > Tibco, and I may be able to get away with using ODBC for Oracle. > > If you need any votes of support to revive COMET within Ericsson, > please let me know ;-> If you don't want to use something like C#, then I can recommend Lua together with LuaCOM for interfacing to COM. I would guess that it's not very hard to wrap a COM interface with this and expose it to Erlang through a port. Still, a little bit of work would be required. Robby From chn.dao77@REDACTED Wed Oct 15 11:34:08 2008 From: chn.dao77@REDACTED (WS Dao) Date: Wed, 15 Oct 2008 17:34:08 +0800 Subject: [erlang-questions] OTP float error on ARM Message-ID: I cross-compiled OTP R12B4 for my ARM9 platform (S3C2410, kernel 2.4.18) When I run erl on arm, float error occurs: # ./erl Eshell V5.6.4 (abort with ^G) 1> 3+5. 8 2> 3.0. 0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005307579804 3> 3.0+4.0. 0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000531405562 4> My toolchain is gcc 3.4.5. I'd wrote a c test program and cross-compile it, no float problems found. Any suggestion? -dao -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob@REDACTED Wed Oct 15 12:23:59 2008 From: bob@REDACTED (Bob Ippolito) Date: Wed, 15 Oct 2008 03:23:59 -0700 Subject: [erlang-questions] OTP float error on ARM In-Reply-To: References: Message-ID: <6a36e7290810150323u18351ec9rf579192477ef256f@mail.gmail.com> There's code in io_lib_format.erl that does the default format floats, which assumes IEEE 754 floats. Perhaps the float<->binary code is broken on your platform, or your platform doesn't do IEEE 754? This is the code in io_lib_format (in R12B3 anyway, I don't have R12B4 installed on this machine): mantissa_exponent(F) -> case <> of <<_S:1, 0:11, M:52>> -> % denormalized E = log2floor(M), {M bsl (53 - E), E - 52 - 1075}; <<_S:1, BE:11, M:52>> when BE < 2047 -> {M + ?BIG_POW, BE - 1075} end. Does the output for this differ in your shell? If so, then your Erlang VM isn't doing the right thing when converting floats to binary... 1> <<1.0:64/float>>. <<63,240,0,0,0,0,0,0>> 2008/10/15 WS Dao : > I cross-compiled OTP R12B4 for my ARM9 platform (S3C2410, kernel 2.4.18) > When I run erl on arm, float error occurs: > # ./erl > Eshell V5.6.4 (abort with ^G) > 1> 3+5. > 8 > 2> 3.0. > 0. > 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005307579804 > 3> 3.0+4.0. > 0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000531405562 > 4> > > My toolchain is gcc 3.4.5. I'd wrote a c test program and cross-compile it, > no float problems found. > > Any suggestion? > > > -dao > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From rapsey@REDACTED Wed Oct 15 13:42:14 2008 From: rapsey@REDACTED (Rapsey) Date: Wed, 15 Oct 2008 13:42:14 +0200 Subject: [erlang-questions] What's the status of erl_com, the Erlang-to-COM bridge? In-Reply-To: <6a3ae47e0810150231j38381c94jf1be1874bf88b83d@mail.gmail.com> References: <6a3ae47e0810150231j38381c94jf1be1874bf88b83d@mail.gmail.com> Message-ID: <97619b170810150442l2733df15m50990889ddc9b393@mail.gmail.com> I'm sure Java has what you need, so why not go through jinterface? Sergej On Wed, Oct 15, 2008 at 11:31 AM, Robert Raschke wrote: > On Wed, Oct 15, 2008 at 5:52 AM, David Mitchell > wrote: > > Thanks Jakob and Kenneth for your responses. > > > > I need to hook Erlang to a variety of external applications (MQ, Tibco > > Rendezvous, Oracle), none of which have "native" Erlang interfaces but > > all have COM interfaces available. Comet looked like a good fit > > (assuming I ran Erlang on a Windows box), but based on your comments > > I'll look elsewhere. That probably means building a C port for MQ and > > Tibco, and I may be able to get away with using ODBC for Oracle. > > > > If you need any votes of support to revive COMET within Ericsson, > > please let me know ;-> > > If you don't want to use something like C#, then I can recommend Lua > together with LuaCOM for interfacing to COM. I would guess that it's > not very hard to wrap a COM interface with this and expose it to > Erlang through a port. Still, a little bit of work would be required. > > Robby > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From thomasl_erlang@REDACTED Wed Oct 15 13:15:07 2008 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Wed, 15 Oct 2008 04:15:07 -0700 (PDT) Subject: [erlang-questions] Finding inconsistencies in record definitions and pretty printing records In-Reply-To: <9b08084c0810140831s5d8e1828x1e9a836b17951fc5@mail.gmail.com> Message-ID: <914854.2451.qm@web38808.mail.mud.yahoo.com> --- On Tue, 10/14/08, Joe Armstrong wrote: > From: Joe Armstrong > Subject: [erlang-questions] Finding inconsistencies in record definitions and pretty printing records > To: "erlang-questions" > Date: Tuesday, October 14, 2008, 5:31 PM > Hi, > > This is a method for ensuring the consistency of records > and for > providing record field information at run-time. > > Long-time readers of this list will recognize this as a > long-standing > problem. > > (what's the problem? if you change a record definition > and > forget to recompile everything you will get fried - and > record definitions get forgotten at run time) Does it handle multiple definitions of the same record name? (#state, to take the canonical example) Best, Thomas From ulf@REDACTED Wed Oct 15 14:38:32 2008 From: ulf@REDACTED (Ulf Wiger) Date: Wed, 15 Oct 2008 14:38:32 +0200 Subject: [erlang-questions] Finding inconsistencies in record definitions and pretty printing records In-Reply-To: <914854.2451.qm@web38808.mail.mud.yahoo.com> References: <9b08084c0810140831s5d8e1828x1e9a836b17951fc5@mail.gmail.com> <914854.2451.qm@web38808.mail.mud.yahoo.com> Message-ID: <8209f740810150538l51d2dbe4vb64e34676864264@mail.gmail.com> 2008/10/15 Thomas Lindgren : > > Does it handle multiple definitions of the same record name? > (#state, to take the canonical example) This is what prompted me to introduce an -export_records() directive in my exprecs contrib. If I have records that I only use inside one module, I don't really care if similar, but different, records are used elsewhere. BR, Ulf W From mikpe@REDACTED Wed Oct 15 14:39:33 2008 From: mikpe@REDACTED (Mikael Pettersson) Date: Wed, 15 Oct 2008 14:39:33 +0200 Subject: [erlang-questions] OTP float error on ARM In-Reply-To: <6a36e7290810150323u18351ec9rf579192477ef256f@mail.gmail.com> References: <6a36e7290810150323u18351ec9rf579192477ef256f@mail.gmail.com> Message-ID: <18677.58501.987530.621132@harpo.it.uu.se> Bob Ippolito writes: > There's code in io_lib_format.erl that does the default format floats, > which assumes IEEE 754 floats. Perhaps the float<->binary code is > broken on your platform, or your platform doesn't do IEEE 754? > > This is the code in io_lib_format (in R12B3 anyway, I don't have R12B4 > installed on this machine): > > mantissa_exponent(F) -> > case <> of > <<_S:1, 0:11, M:52>> -> % denormalized > E = log2floor(M), > {M bsl (53 - E), E - 52 - 1075}; > <<_S:1, BE:11, M:52>> when BE < 2047 -> > {M + ?BIG_POW, BE - 1075} > end. > > Does the output for this differ in your shell? If so, then your Erlang > VM isn't doing the right thing when converting floats to binary... > > 1> <<1.0:64/float>>. > <<63,240,0,0,0,0,0,0>> Off-hand I can't say if that code above is compatible with ARM's more "exotic" FP formats, like the insane FPA format. (Big-endian even on little-endian machines, or something like that.) What I can say is that R12 built natively with a softfloat VFP toolchain works for me on both big- and little-endian machines. Q1. Is the target machine big or little endian? Q2. What's the FP format? hard or soft? FPA or VFP? Or something else like Maverick? From erlang@REDACTED Wed Oct 15 15:13:10 2008 From: erlang@REDACTED (Joe Armstrong) Date: Wed, 15 Oct 2008 15:13:10 +0200 Subject: [erlang-questions] Finding inconsistencies in record definitions and pretty printing records In-Reply-To: <8209f740810150538l51d2dbe4vb64e34676864264@mail.gmail.com> References: <9b08084c0810140831s5d8e1828x1e9a836b17951fc5@mail.gmail.com> <914854.2451.qm@web38808.mail.mud.yahoo.com> <8209f740810150538l51d2dbe4vb64e34676864264@mail.gmail.com> Message-ID: <9b08084c0810150613g36ac02beq409476f3190b05be@mail.gmail.com> On Wed, Oct 15, 2008 at 2:38 PM, Ulf Wiger wrote: > 2008/10/15 Thomas Lindgren : >> >> Does it handle multiple definitions of the same record name? >> (#state, to take the canonical example) Yes - it reports an error if two record declarations are not identical > > This is what prompted me to introduce an -export_records() > directive in my exprecs contrib. > > If I have records that I only use inside one module, I don't > really care if similar, but different, records are used elsewhere. And you promise not to send a message containing a private record, anywhere - and you promise that some other process will not send you a message with this record and you promise not to store a record in a data base - .... Yes guv - scouts honour ... /Joe > > BR, > Ulf W > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From icfp.publicity@REDACTED Wed Oct 15 16:17:49 2008 From: icfp.publicity@REDACTED (Matthew Fluet (ICFP Publicity Chair)) Date: Wed, 15 Oct 2008 09:17:49 -0500 Subject: [erlang-questions] ICFP09: Call for Workshop Proposals Message-ID: <53ff55480810150717p3ba7953cr90d0148d1a98d6f4@mail.gmail.com> CALL FOR WORKSHOP PROPOSALS ICFP 2009 14th ACM SIGPLAN International Conference on Functional Programming 31st August - 2nd September, 2009 Edinburgh, Scotland http://www.icfpconference.org/icfp2009 The 14th ACM SIGPLAN International Conference on Functional Programming will be held in Edinburgh, Scotland from 31st August to 2nd September 2009. ICFP provides a forum for researchers and developers to hear about the latest work on the design, implementations, principles, and uses of functional programming. Proposals are invited for workshops to be affiliated with ICFP 2009 and sponsored by SIGPLAN. These workshops should be more informal and focused than ICFP itself, include sessions that enable interaction among the workshop attendees, and be fairly low cost. The preference is for one-day workshops, but other schedules can also be considered. The workshops themselves will be held between August 30th and September 5th, as capacity allows. ---------------------------------------------------------------------- Submission details Deadline for submission: 19th November 2008 Notification of acceptance: 17th December 2008 Prospective workshop organisers are invited to submit a completed workshop proposal form in plain text format to the ICFP 2009 workshop co-chairs (Chris Stone and Mike Sperber), via email to icfp09-workshops at cs.hmc.edu by 19th November 2008. Please note that this is a firm deadline. Organisers will be notified if their proposal is accepted by 17th December 2008, and if successful are required to produce a final report after the workshop has taken place that is suitable for publication in SIGPLAN Notices. The proposal form is available at: http://www.icfpconference.org/icfp2009/workshops/icfp09-workshops-form.txt Further information about SIGPLAN sponsorship is available at: http://acm.org/sigplan/sigplan_workshop_proposal.htm ---------------------------------------------------------------------- Selection committee The workshop proposals will be evaluated by a committee comprising the following members of the ICFP 2009 organising committee, together with the members of the SIGPLAN executive committee. Chris Stone Harvey Mudd College Workshops co-chair Mike Sperber DeinProgramm Workshops co-chair Graham Hutton University of Nottingham General Chair Andrew Tolmach Portland State University Program Chair ---------------------------------------------------------------------- Further information Any queries regarding ICFP 2009 workshop proposals should be addressed to the workshops co-chairs (Chris Stone and Mike Sperber), via email to icfp09-workshops at cs.hmc.edu From ulf.wiger@REDACTED Wed Oct 15 16:24:43 2008 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Wed, 15 Oct 2008 16:24:43 +0200 Subject: [erlang-questions] Finding inconsistencies in record definitions and pretty printing records In-Reply-To: <9b08084c0810150613g36ac02beq409476f3190b05be@mail.gmail.com> References: <9b08084c0810140831s5d8e1828x1e9a836b17951fc5@mail.gmail.com> <914854.2451.qm@web38808.mail.mud.yahoo.com> <8209f740810150538l51d2dbe4vb64e34676864264@mail.gmail.com> <9b08084c0810150613g36ac02beq409476f3190b05be@mail.gmail.com> Message-ID: <48F5FD2B.30107@ericsson.com> Joe Armstrong skrev: > On Wed, Oct 15, 2008 at 2:38 PM, Ulf Wiger wrote: >> 2008/10/15 Thomas Lindgren : >>> Does it handle multiple definitions of the same record name? >>> (#state, to take the canonical example) > > Yes - it reports an error if two record declarations are not > identical > >> This is what prompted me to introduce an -export_records() >> directive in my exprecs contrib. >> >> If I have records that I only use inside one module, I don't really >> care if similar, but different, records are used elsewhere. > > And you promise not to send a message containing a private record, > anywhere - and you promise that some other process will not send you > a message with this record and you promise not to store a record in a > data base - .... Yes, just like I promise not to mess with data structures documented as "opaque", or mess with contents of ets tables, just because they're created as 'public', or send bogus messages to other processes just because I can, or mess with other programs' mnesia data, for that matter. I also restrain myself from calling rpc:multicall(nodes(), erlang,halt,[]), even though it's perfectly possible. I guess the question is whether your cure is worse than the disease. ;-) I don't think it's very common that programs inadvertedly pass around their internal data structures. If you offer a way for people to specify some of their records as internal, they may be more inclined to use your solution. BR, Ulf W From vychodil.hynek@REDACTED Wed Oct 15 16:39:18 2008 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Wed, 15 Oct 2008 16:39:18 +0200 Subject: [erlang-questions] Finding inconsistencies in record definitions and pretty printing records In-Reply-To: <48F5FD2B.30107@ericsson.com> References: <9b08084c0810140831s5d8e1828x1e9a836b17951fc5@mail.gmail.com> <914854.2451.qm@web38808.mail.mud.yahoo.com> <8209f740810150538l51d2dbe4vb64e34676864264@mail.gmail.com> <9b08084c0810150613g36ac02beq409476f3190b05be@mail.gmail.com> <48F5FD2B.30107@ericsson.com> Message-ID: <20081015143919.4F5AA24065@relay.gooddata.com> Agree. All this thing sounds to me like some kind of type check but neither in compile time neither runtime, but in load time. It's like fairy tale, neither naked, neither dressed. With global name space it easy become to horror. On Wed, Oct 15, 2008 at 4:24 PM, Ulf Wiger (TN/EAB) wrote: > Joe Armstrong skrev: > > On Wed, Oct 15, 2008 at 2:38 PM, Ulf Wiger wrote: > >> 2008/10/15 Thomas Lindgren : > >>> Does it handle multiple definitions of the same record name? > >>> (#state, to take the canonical example) > > > > Yes - it reports an error if two record declarations are not > > identical > > > >> This is what prompted me to introduce an -export_records() > >> directive in my exprecs contrib. > >> > >> If I have records that I only use inside one module, I don't really > >> care if similar, but different, records are used elsewhere. > > > > And you promise not to send a message containing a private record, > > anywhere - and you promise that some other process will not send you > > a message with this record and you promise not to store a record in a > > data base - .... > > Yes, just like I promise not to mess with data structures documented > as "opaque", or mess with contents of ets tables, just because > they're created as 'public', or send bogus messages to other > processes just because I can, or mess with other programs' mnesia > data, for that matter. > > I also restrain myself from calling > rpc:multicall(nodes(), erlang,halt,[]), > even though it's perfectly possible. > > I guess the question is whether your cure is worse than the > disease. ;-) I don't think it's very common that programs inadvertedly > pass around their internal data structures. If you offer a way for > people to specify some of their records as internal, they may be > more inclined to use your solution. > > BR, > Ulf W > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- --Hynek (Pichi) Vychodil -------------- next part -------------- An HTML attachment was scrubbed... URL: From greg.burri@REDACTED Wed Oct 15 17:01:56 2008 From: greg.burri@REDACTED (Greg Burri) Date: Wed, 15 Oct 2008 17:01:56 +0200 Subject: [erlang-questions] php on yaws performance? In-Reply-To: <3bb44c6e0810150208x1ab86470v24c3828cb8759897@mail.gmail.com> References: <3bb44c6e0810150208x1ab86470v24c3828cb8759897@mail.gmail.com> Message-ID: <60ed8a460810150801j48b8cad7t43a92343b8c30cb@mail.gmail.com> Hi, I think there is no scale benefits to use Yaws with PHP because it supports only the CGI interface (maybe I'm wrong). I'm using Yaws with WordPress and other PHP stuff without problem but whitout high load... /Greg On Wed, Oct 15, 2008 at 11:08 AM, bryan rasmussen wrote: > Hi, > I was just wondering about PHP on Yaws performance. Does php derive > any performance benefits, scaling benefits? Does anyone out there have > any success or horror stories of using PHP on Yaws? From what I > understand PHP on Yaws is implemented via a CGI interface - any > FastCGI like functionality? > > > > Best Regards, > Bryan Rasmussen > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From fess-erlang@REDACTED Wed Oct 15 20:05:35 2008 From: fess-erlang@REDACTED (fess) Date: Wed, 15 Oct 2008 11:05:35 -0700 Subject: [erlang-questions] Q: Differenciating between List and List of Lists In-Reply-To: <48F5B079.6060808@erlang-consulting.com> References: <48F58398.6040801@ghostgun.com> <48F5B079.6060808@erlang-consulting.com> Message-ID: On Oct 15, 2008, at 1:57 AM, Roberto Aloi wrote: > 1> List = "aList". > "aList" > 2> ListOfLists = ["first", "second"]. > ["first","second"] > 3> is_list(lists:nth(1,List)). > false > 4> is_list(lists:nth(1,ListOfLists)). > true > 5> is_integer(lists:nth(1,ListOfLists)). > false > 6> is_integer(lists:nth(1,List)). > true > > Just remember to check for empty lists!!! I like hd() for brevity in place of lists:nth(1,...) 1> List = "aList". "aList" 2> ListOfLists = ["first", "second"]. ["first","second"] 3> is_list(hd(List)). false 4> is_list(hd(ListOfLists)). true 5> is_integer(hd(ListOfLists)). false 6> is_integer(hd(List)). true --fess From tomas.abrahamsson@REDACTED Wed Oct 15 20:45:10 2008 From: tomas.abrahamsson@REDACTED (Tomas Abrahamsson) Date: Wed, 15 Oct 2008 20:45:10 +0200 Subject: [erlang-questions] OTP float error on ARM In-Reply-To: References: Message-ID: 2008/10/15 WS Dao : > I cross-compiled OTP R12B4 for my ARM9 platform (S3C2410, kernel 2.4.18) > When I run erl on arm, float error occurs: Not exactly the same set up, but floating points seem to work fine with the erlang R12B-3 of debian on an arm9 (s3c2442b, ARM920T rev 0 on an openmoko freerunner phone). I just did an apt-get install erlang and was up and running. Unfortunately, I don't know neither how it was compiled, nor what FP format this would be. BRs Tomas From klacke@REDACTED Wed Oct 15 21:14:01 2008 From: klacke@REDACTED (=?ISO-8859-1?Q?Claes_Wikstr=F6m?=) Date: Wed, 15 Oct 2008 21:14:01 +0200 Subject: [erlang-questions] php on yaws performance? In-Reply-To: <60ed8a460810150801j48b8cad7t43a92343b8c30cb@mail.gmail.com> References: <3bb44c6e0810150208x1ab86470v24c3828cb8759897@mail.gmail.com> <60ed8a460810150801j48b8cad7t43a92343b8c30cb@mail.gmail.com> Message-ID: <48F640F9.9090209@hyber.org> Greg Burri wrote: > Hi, > I think there is no scale benefits to use Yaws with PHP because it > supports only the CGI interface (maybe I'm wrong). I'm using Yaws with > WordPress and other PHP stuff without problem but whitout high load... Agree completely, /klacke From dmorton@REDACTED Wed Oct 15 21:29:40 2008 From: dmorton@REDACTED (damien morton) Date: Thu, 16 Oct 2008 07:29:40 +1200 Subject: [erlang-questions] Erlang with MonetDb In-Reply-To: <6a36e7290810070934k1a3fbf43k258c6220b6a56e75@mail.gmail.com> References: <3bb44c6e0810070454s5cd3a829p524ce628808a2323@mail.gmail.com> <6a36e7290810070934k1a3fbf43k258c6220b6a56e75@mail.gmail.com> Message-ID: <8092dc770810151229m32e2601dv429247a37b72bae2@mail.gmail.com> Which commercial column store did you end up using? On Wed, Oct 8, 2008 at 4:34 AM, Bob Ippolito wrote: > I don't have an answer for you, but we tried using MonetDB early this > year and it was an epic failure, the database corrupted itself and at > times the server would grow until it ran out of RAM. We unfortunately > had to resort to a commercial column store because we couldn't get > MonetDB to run for more than a few hours without crashing :( > > On Tue, Oct 7, 2008 at 4:54 AM, bryan rasmussen > wrote: > > Hi, > > > > Anyone out there made some erlang examples working with MonetDB? using > > ODBC acceptable. > > > > > > Cheers, > > Bryan Rasmussen > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob@REDACTED Wed Oct 15 21:42:17 2008 From: bob@REDACTED (Bob Ippolito) Date: Wed, 15 Oct 2008 12:42:17 -0700 Subject: [erlang-questions] Erlang with MonetDb In-Reply-To: <8092dc770810151229m32e2601dv429247a37b72bae2@mail.gmail.com> References: <3bb44c6e0810070454s5cd3a829p524ce628808a2323@mail.gmail.com> <6a36e7290810070934k1a3fbf43k258c6220b6a56e75@mail.gmail.com> <8092dc770810151229m32e2601dv429247a37b72bae2@mail.gmail.com> Message-ID: <6a36e7290810151242r313c8ae4pe3b2db944f745a62@mail.gmail.com> We ended up using Vertica. I'd much prefer an open source solution, but it does what we need it to do. On Wed, Oct 15, 2008 at 12:29 PM, damien morton wrote: > Which commercial column store did you end up using? > > On Wed, Oct 8, 2008 at 4:34 AM, Bob Ippolito wrote: >> >> I don't have an answer for you, but we tried using MonetDB early this >> year and it was an epic failure, the database corrupted itself and at >> times the server would grow until it ran out of RAM. We unfortunately >> had to resort to a commercial column store because we couldn't get >> MonetDB to run for more than a few hours without crashing :( >> >> On Tue, Oct 7, 2008 at 4:54 AM, bryan rasmussen >> wrote: >> > Hi, >> > >> > Anyone out there made some erlang examples working with MonetDB? using >> > ODBC acceptable. >> > >> > >> > Cheers, >> > Bryan Rasmussen >> > _______________________________________________ >> > erlang-questions mailing list >> > erlang-questions@REDACTED >> > http://www.erlang.org/mailman/listinfo/erlang-questions >> > >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions > > From exta7@REDACTED Wed Oct 15 22:16:12 2008 From: exta7@REDACTED (Zvi) Date: Wed, 15 Oct 2008 13:16:12 -0700 (PDT) Subject: [erlang-questions] php on yaws performance? In-Reply-To: <3bb44c6e0810150208x1ab86470v24c3828cb8759897@mail.gmail.com> References: <3bb44c6e0810150208x1ab86470v24c3828cb8759897@mail.gmail.com> Message-ID: <20001442.post@talk.nabble.com> You, might be interested in this one (implementation of Erlang node as a PHP extension): http://www.math-hat.com/~zukerman/projects/php-erlang/ I didn't checked it yet Zvi bryan rasmussen wrote: > > Hi, > I was just wondering about PHP on Yaws performance. Does php derive > any performance benefits, scaling benefits? Does anyone out there have > any success or horror stories of using PHP on Yaws? From what I > understand PHP on Yaws is implemented via a CGI interface - any > FastCGI like functionality? > > > > Best Regards, > Bryan Rasmussen > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > -- View this message in context: http://www.nabble.com/php-on-yaws-performance--tp19989718p20001442.html Sent from the Erlang Questions mailing list archive at Nabble.com. From monch1962@REDACTED Wed Oct 15 22:33:43 2008 From: monch1962@REDACTED (David Mitchell) Date: Thu, 16 Oct 2008 07:33:43 +1100 Subject: [erlang-questions] What's the status of erl_com, the Erlang-to-COM bridge? In-Reply-To: <97619b170810150442l2733df15m50990889ddc9b393@mail.gmail.com> References: <6a3ae47e0810150231j38381c94jf1be1874bf88b83d@mail.gmail.com> <97619b170810150442l2733df15m50990889ddc9b393@mail.gmail.com> Message-ID: My reason for choosing Erlang in the first place was for scalability - I need to be able to read/write/monitor upwards of 1000 MQ and Tibco queues simultaneously, and drive them all and present status plus drill-down info from a central point via a Web interface. I've got access to lots of Intel servers (if necessary) to build this. With Erlang, the ease of scaling horizontally makes it relatively straightforward to handle that quantity of interfaces (ignoring the fact that they're MQ and Tibco specifically), and using Yaws would mean that I won't have issues with scalability in data presentation. Finally, and I haven't thought this next part through thoroughly yet, I would also lean towards using COMET (not the COM interface project; the Web push interface project) to push updates out to my Web clients. Finally the app is such that it needs to be 100% reliable during extended periods of high load, and OTP gives me the capability to build that in fairly easily. Bottom line is that I know Erlang would be a good fit (again, ignoring the fact that the interfaces are MQ and Tibco), whereas I think it would take me longer to produce a less-reliable solution in Java. Regards Dave M. 2008/10/15 Rapsey : > I'm sure Java has what you need, so why not go through jinterface? > > > Sergej > > On Wed, Oct 15, 2008 at 11:31 AM, Robert Raschke > wrote: >> >> On Wed, Oct 15, 2008 at 5:52 AM, David Mitchell >> wrote: >> > Thanks Jakob and Kenneth for your responses. >> > >> > I need to hook Erlang to a variety of external applications (MQ, Tibco >> > Rendezvous, Oracle), none of which have "native" Erlang interfaces but >> > all have COM interfaces available. Comet looked like a good fit >> > (assuming I ran Erlang on a Windows box), but based on your comments >> > I'll look elsewhere. That probably means building a C port for MQ and >> > Tibco, and I may be able to get away with using ODBC for Oracle. >> > >> > If you need any votes of support to revive COMET within Ericsson, >> > please let me know ;-> >> >> If you don't want to use something like C#, then I can recommend Lua >> together with LuaCOM for interfacing to COM. I would guess that it's >> not very hard to wrap a COM interface with this and expose it to >> Erlang through a port. Still, a little bit of work would be required. >> >> Robby >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From monch1962@REDACTED Wed Oct 15 22:35:13 2008 From: monch1962@REDACTED (David Mitchell) Date: Thu, 16 Oct 2008 07:35:13 +1100 Subject: [erlang-questions] What's the status of erl_com, the Erlang-to-COM bridge? In-Reply-To: <6a3ae47e0810150231j38381c94jf1be1874bf88b83d@mail.gmail.com> References: <6a3ae47e0810150231j38381c94jf1be1874bf88b83d@mail.gmail.com> Message-ID: Thanks Robert. I'm aware of Lua, but haven't used it and hadn't considered it for this purpose. I know it's fairly simple, so I might build a prototype with it to see how it'll scale. Regards Dave M. 2008/10/15 Robert Raschke : > On Wed, Oct 15, 2008 at 5:52 AM, David Mitchell wrote: >> Thanks Jakob and Kenneth for your responses. >> >> I need to hook Erlang to a variety of external applications (MQ, Tibco >> Rendezvous, Oracle), none of which have "native" Erlang interfaces but >> all have COM interfaces available. Comet looked like a good fit >> (assuming I ran Erlang on a Windows box), but based on your comments >> I'll look elsewhere. That probably means building a C port for MQ and >> Tibco, and I may be able to get away with using ODBC for Oracle. >> >> If you need any votes of support to revive COMET within Ericsson, >> please let me know ;-> > > If you don't want to use something like C#, then I can recommend Lua > together with LuaCOM for interfacing to COM. I would guess that it's > not very hard to wrap a COM interface with this and expose it to > Erlang through a port. Still, a little bit of work would be required. > > Robby > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From ok@REDACTED Thu Oct 16 00:34:04 2008 From: ok@REDACTED (Richard O'Keefe) Date: Thu, 16 Oct 2008 11:34:04 +1300 Subject: [erlang-questions] Q: Differenciating between List and List of Lists In-Reply-To: <48F58398.6040801@ghostgun.com> References: <48F58398.6040801@ghostgun.com> Message-ID: On 15 Oct 2008, at 6:46 pm, jm wrote: > What is the best way to tell the difference between a list and a > list of > lists (possible in a guard)? It's impossible: an empty list and an empty list of lists are the same thing. You can tell the difference between a non-empty list of non-empty lists and any other list thus: case Thingy of [[_|_]|_] -> non-empty list of lists ; X when is_list(X) -> any other list ; _ -> not a list at all end If you are specifically interested in distinguishing between strings and lists of strings, if is_integer(hd(Thingy)) -> non-empty string ; is_list( hd(Thingy)) -> non-empty list of strings ; Thingy =:= [] -> empty so could be either ; true -> not a list at all end There are more variations on both of these than I have time to write or you to read. From ok@REDACTED Thu Oct 16 00:37:27 2008 From: ok@REDACTED (Richard O'Keefe) Date: Thu, 16 Oct 2008 11:37:27 +1300 Subject: [erlang-questions] Finding inconsistencies in record definitions and pretty printing records In-Reply-To: <95be1d3b0810142322o684e4ac2xa148dfc8f1b1b99f@mail.gmail.com> References: <9b08084c0810140831s5d8e1828x1e9a836b17951fc5@mail.gmail.com> <87vdvv6tkb.fsf@sterlett.hq.kred> <9b08084c0810141257o651f363fx82dddfe0749cbe97@mail.gmail.com> <95be1d3b0810142322o684e4ac2xa148dfc8f1b1b99f@mail.gmail.com> Message-ID: I imagine that I must have misunderstood, but this scheme seems designed to prevent hot loading. If I need to add a field to a -record declaration and reload the module in question, it looks as though the "conflict" will be detected and prevented. I've also failed to understand how the system copes with two independently developed and unrelated modules having a record with the same name and different structure. From jeffm@REDACTED Thu Oct 16 01:29:49 2008 From: jeffm@REDACTED (jm) Date: Thu, 16 Oct 2008 10:29:49 +1100 Subject: [erlang-questions] Q: Differenciating between List and List of Lists In-Reply-To: References: <48F58398.6040801@ghostgun.com> <48F5B079.6060808@erlang-consulting.com> Message-ID: <48F67CED.9090806@ghostgun.com> Thanks folks. Jeff. fess wrote: > On Oct 15, 2008, at 1:57 AM, Roberto Aloi wrote: > > >> 1> List = "aList". >> "aList" >> 2> ListOfLists = ["first", "second"]. >> ["first","second"] >> 3> is_list(lists:nth(1,List)). >> false >> 4> is_list(lists:nth(1,ListOfLists)). >> true >> 5> is_integer(lists:nth(1,ListOfLists)). >> false >> 6> is_integer(lists:nth(1,List)). >> true >> >> Just remember to check for empty lists!!! >> > > I like hd() for brevity in place of lists:nth(1,...) > > 1> List = "aList". > "aList" > 2> ListOfLists = ["first", "second"]. > ["first","second"] > 3> is_list(hd(List)). > false > 4> is_list(hd(ListOfLists)). > true > 5> is_integer(hd(ListOfLists)). > false > 6> is_integer(hd(List)). > true > > --fess > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From pfisher@REDACTED Thu Oct 16 01:08:31 2008 From: pfisher@REDACTED (Paul Fisher) Date: Wed, 15 Oct 2008 18:08:31 -0500 Subject: [erlang-questions] ready_async() before outputv() calling driver_async() completes? Message-ID: <48F677EF.7060709@alertlogic.net> Should it be possible for a ready_async() callback to happen before the outputv() callback which called driver_async() has returned? I am seeing this happen on R12B-2 smp runtime (2 schedulers), w/four (4) async threads. -- paul From chn.dao77@REDACTED Thu Oct 16 05:59:13 2008 From: chn.dao77@REDACTED (WS Dao) Date: Thu, 16 Oct 2008 11:59:13 +0800 Subject: [erlang-questions] OTP float error on ARM In-Reply-To: <6a36e7290810150323u18351ec9rf579192477ef256f@mail.gmail.com> References: <6a36e7290810150323u18351ec9rf579192477ef256f@mail.gmail.com> Message-ID: my shell output is: 4> <<1.0:64/float>>. <<0,0,0,0,63,240,0,0>> as Tony said, S3C2410/ARM920T CPU , double float is "Middle Endian" IEEE float: 12 34 AB CD Middle Endian: AB CD 12 34 my toolchain doesn't support "-msoft-float" option. [root@REDACTED ~]# arm-unknown-linux-gnu-readelf -h /tmp/cross-compile/lib/erlang/erts-5.6.4/bin/beam ELF Header: Magic: 7f 45 4c 46 01 01 01 61 00 00 00 00 00 00 00 00 Class: ELF32 Data: 2's complement, little endian Version: 1 (current) OS/ABI: ARM ABI Version: 0 Type: EXEC (Executable file) Machine: ARM Version: 0x1 Entry point address: 0x21f84 Start of program headers: 52 (bytes into file) Start of section headers: 1346104 (bytes into file) Flags: 0x2, has entry point, GNU EABI Size of this header: 52 (bytes) Size of program headers: 32 (bytes) Number of program headers: 6 Size of section headers: 40 (bytes) Number of section headers: 31 Section header string table index: 28 My platform doesn't support clock_gettime(CLOCK_MONOTONIC,&ts) , /erts/emulator/sys/unix/sys.c, so I can't use debian binary. 2008/10/15 Bob Ippolito > There's code in io_lib_format.erl that does the default format floats, > which assumes IEEE 754 floats. Perhaps the float<->binary code is > broken on your platform, or your platform doesn't do IEEE 754? > > This is the code in io_lib_format (in R12B3 anyway, I don't have R12B4 > installed on this machine): > > mantissa_exponent(F) -> > case <> of > <<_S:1, 0:11, M:52>> -> % denormalized > E = log2floor(M), > {M bsl (53 - E), E - 52 - 1075}; > <<_S:1, BE:11, M:52>> when BE < 2047 -> > {M + ?BIG_POW, BE - 1075} > end. > > Does the output for this differ in your shell? If so, then your Erlang > VM isn't doing the right thing when converting floats to binary... > > 1> <<1.0:64/float>>. > <<63,240,0,0,0,0,0,0>> > > > 2008/10/15 WS Dao : > > I cross-compiled OTP R12B4 for my ARM9 platform (S3C2410, kernel 2.4.18) > > When I run erl on arm, float error occurs: > > # ./erl > > Eshell V5.6.4 (abort with ^G) > > 1> 3+5. > > 8 > > 2> 3.0. > > 0. > > > 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005307579804 > > 3> 3.0+4.0. > > > 0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000531405562 > > 4> > > > > My toolchain is gcc 3.4.5. I'd wrote a c test program and cross-compile > it, > > no float problems found. > > > > Any suggestion? > > > > > > -dao > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From litaocheng@REDACTED Thu Oct 16 06:02:01 2008 From: litaocheng@REDACTED (litao cheng) Date: Thu, 16 Oct 2008 12:02:01 +0800 Subject: [erlang-questions] timer:send_interval/3 how to return {error, Reason} value? Message-ID: Hi, everyone. When I use timer:send_interval/3, I have some puzzle with the return values: {ok, TRef}, {error, Reason}. I see the timer.erl, I know that the timer module is implented by gen_server behaviour, the exported functions such as send_after, apply_after and so on, are just call the gen_server:call/2. the gen_server:call/2 may invoke erlang:exit/1 with some reasons, but in the timer.erl the timer:req/2 don't catch the exit signal. So I wonder how the timer:send_interval/3 return {error, Reason}. Is it a bug? BS! litaocheng -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob@REDACTED Thu Oct 16 07:40:11 2008 From: bob@REDACTED (Bob Ippolito) Date: Wed, 15 Oct 2008 22:40:11 -0700 Subject: [erlang-questions] OTP float error on ARM In-Reply-To: References: <6a36e7290810150323u18351ec9rf579192477ef256f@mail.gmail.com> Message-ID: <6a36e7290810152240h7d620a3l54cdd807bd83b7b0@mail.gmail.com> Well, the float type in Erlang binaries by itself is big endian, not native endian. This is a bug in Erlang. On Wed, Oct 15, 2008 at 8:59 PM, WS Dao wrote: > my shell output is: > > 4> <<1.0:64/float>>. > <<0,0,0,0,63,240,0,0>> > > > as Tony said, S3C2410/ARM920T CPU , double float is "Middle Endian" > > IEEE float: 12 34 AB CD > Middle Endian: AB CD 12 34 > > > my toolchain doesn't support "-msoft-float" option. > [root@REDACTED ~]# arm-unknown-linux-gnu-readelf -h > /tmp/cross-compile/lib/erlang/erts-5.6.4/bin/beam > ELF Header: > Magic: 7f 45 4c 46 01 01 01 61 00 00 00 00 00 00 00 00 > Class: ELF32 > Data: 2's complement, little endian > Version: 1 (current) > OS/ABI: ARM > ABI Version: 0 > Type: EXEC (Executable file) > Machine: ARM > Version: 0x1 > Entry point address: 0x21f84 > Start of program headers: 52 (bytes into file) > Start of section headers: 1346104 (bytes into file) > Flags: 0x2, has entry point, GNU EABI > Size of this header: 52 (bytes) > Size of program headers: 32 (bytes) > Number of program headers: 6 > Size of section headers: 40 (bytes) > Number of section headers: 31 > Section header string table index: 28 > > > My platform doesn't support clock_gettime(CLOCK_MONOTONIC,&ts) , > /erts/emulator/sys/unix/sys.c, so I can't use debian binary. > > > > 2008/10/15 Bob Ippolito >> >> There's code in io_lib_format.erl that does the default format floats, >> which assumes IEEE 754 floats. Perhaps the float<->binary code is >> broken on your platform, or your platform doesn't do IEEE 754? >> >> This is the code in io_lib_format (in R12B3 anyway, I don't have R12B4 >> installed on this machine): >> >> mantissa_exponent(F) -> >> case <> of >> <<_S:1, 0:11, M:52>> -> % denormalized >> E = log2floor(M), >> {M bsl (53 - E), E - 52 - 1075}; >> <<_S:1, BE:11, M:52>> when BE < 2047 -> >> {M + ?BIG_POW, BE - 1075} >> end. >> >> Does the output for this differ in your shell? If so, then your Erlang >> VM isn't doing the right thing when converting floats to binary... >> >> 1> <<1.0:64/float>>. >> <<63,240,0,0,0,0,0,0>> >> >> >> 2008/10/15 WS Dao : >> > I cross-compiled OTP R12B4 for my ARM9 platform (S3C2410, kernel 2.4.18) >> > When I run erl on arm, float error occurs: >> > # ./erl >> > Eshell V5.6.4 (abort with ^G) >> > 1> 3+5. >> > 8 >> > 2> 3.0. >> > 0. >> > >> > 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005307579804 >> > 3> 3.0+4.0. >> > >> > 0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000531405562 >> > 4> >> > >> > My toolchain is gcc 3.4.5. I'd wrote a c test program and cross-compile >> > it, >> > no float problems found. >> > >> > Any suggestion? >> > >> > >> > -dao >> > _______________________________________________ >> > erlang-questions mailing list >> > erlang-questions@REDACTED >> > http://www.erlang.org/mailman/listinfo/erlang-questions >> > > > From chn.dao77@REDACTED Thu Oct 16 08:09:47 2008 From: chn.dao77@REDACTED (WS Dao) Date: Thu, 16 Oct 2008 14:09:47 +0800 Subject: [erlang-questions] OTP float error on ARM In-Reply-To: <6a36e7290810152240h7d620a3l54cdd807bd83b7b0@mail.gmail.com> References: <6a36e7290810150323u18351ec9rf579192477ef256f@mail.gmail.com> <6a36e7290810152240h7d620a3l54cdd807bd83b7b0@mail.gmail.com> Message-ID: Oh. so, which file should i patch, please? 2008/10/16 Bob Ippolito > Well, the float type in Erlang binaries by itself is big endian, not > native endian. This is a bug in Erlang. > > On Wed, Oct 15, 2008 at 8:59 PM, WS Dao wrote: > > my shell output is: > > > > 4> <<1.0:64/float>>. > > <<0,0,0,0,63,240,0,0>> > > > > > > as Tony said, S3C2410/ARM920T CPU , double float is "Middle Endian" > > > > IEEE float: 12 34 AB CD > > Middle Endian: AB CD 12 34 > > > > > > my toolchain doesn't support "-msoft-float" option. > > [root@REDACTED ~]# arm-unknown-linux-gnu-readelf -h > > /tmp/cross-compile/lib/erlang/erts-5.6.4/bin/beam > > ELF Header: > > Magic: 7f 45 4c 46 01 01 01 61 00 00 00 00 00 00 00 00 > > Class: ELF32 > > Data: 2's complement, little endian > > Version: 1 (current) > > OS/ABI: ARM > > ABI Version: 0 > > Type: EXEC (Executable file) > > Machine: ARM > > Version: 0x1 > > Entry point address: 0x21f84 > > Start of program headers: 52 (bytes into file) > > Start of section headers: 1346104 (bytes into file) > > Flags: 0x2, has entry point, GNU EABI > > Size of this header: 52 (bytes) > > Size of program headers: 32 (bytes) > > Number of program headers: 6 > > Size of section headers: 40 (bytes) > > Number of section headers: 31 > > Section header string table index: 28 > > > > > > My platform doesn't support clock_gettime(CLOCK_MONOTONIC,&ts) , > > /erts/emulator/sys/unix/sys.c, so I can't use debian binary. > > > > > > > > 2008/10/15 Bob Ippolito > >> > >> There's code in io_lib_format.erl that does the default format floats, > >> which assumes IEEE 754 floats. Perhaps the float<->binary code is > >> broken on your platform, or your platform doesn't do IEEE 754? > >> > >> This is the code in io_lib_format (in R12B3 anyway, I don't have R12B4 > >> installed on this machine): > >> > >> mantissa_exponent(F) -> > >> case <> of > >> <<_S:1, 0:11, M:52>> -> % denormalized > >> E = log2floor(M), > >> {M bsl (53 - E), E - 52 - 1075}; > >> <<_S:1, BE:11, M:52>> when BE < 2047 -> > >> {M + ?BIG_POW, BE - 1075} > >> end. > >> > >> Does the output for this differ in your shell? If so, then your Erlang > >> VM isn't doing the right thing when converting floats to binary... > >> > >> 1> <<1.0:64/float>>. > >> <<63,240,0,0,0,0,0,0>> > >> > >> > >> 2008/10/15 WS Dao : > >> > I cross-compiled OTP R12B4 for my ARM9 platform (S3C2410, kernel > 2.4.18) > >> > When I run erl on arm, float error occurs: > >> > # ./erl > >> > Eshell V5.6.4 (abort with ^G) > >> > 1> 3+5. > >> > 8 > >> > 2> 3.0. > >> > 0. > >> > > >> > > 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005307579804 > >> > 3> 3.0+4.0. > >> > > >> > > 0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000531405562 > >> > 4> > >> > > >> > My toolchain is gcc 3.4.5. I'd wrote a c test program and > cross-compile > >> > it, > >> > no float problems found. > >> > > >> > Any suggestion? > >> > > >> > > >> > -dao > >> > _______________________________________________ > >> > erlang-questions mailing list > >> > erlang-questions@REDACTED > >> > http://www.erlang.org/mailman/listinfo/erlang-questions > >> > > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bgustavsson@REDACTED Thu Oct 16 08:28:52 2008 From: bgustavsson@REDACTED (Bjorn Gustavsson) Date: Thu, 16 Oct 2008 08:28:52 +0200 Subject: [erlang-questions] OTP float error on ARM In-Reply-To: <6a36e7290810152240h7d620a3l54cdd807bd83b7b0@mail.gmail.com> References: <6a36e7290810150323u18351ec9rf579192477ef256f@mail.gmail.com> <6a36e7290810152240h7d620a3l54cdd807bd83b7b0@mail.gmail.com> Message-ID: <6672d0160810152328g14efa4e6v3789dbbab7ecb9e1@mail.gmail.com> Thu, Oct 16, 2008 at 7:40 AM, Bob Ippolito wrote: > Well, the float type in Erlang binaries by itself is big endian, not > native endian. This is a bug in Erlang. > This is not a bug. The default for numeric types is big endian. If you want native endian, you must say so: <> /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob@REDACTED Thu Oct 16 08:51:15 2008 From: bob@REDACTED (Bob Ippolito) Date: Wed, 15 Oct 2008 23:51:15 -0700 Subject: [erlang-questions] OTP float error on ARM In-Reply-To: <6672d0160810152328g14efa4e6v3789dbbab7ecb9e1@mail.gmail.com> References: <6a36e7290810150323u18351ec9rf579192477ef256f@mail.gmail.com> <6a36e7290810152240h7d620a3l54cdd807bd83b7b0@mail.gmail.com> <6672d0160810152328g14efa4e6v3789dbbab7ecb9e1@mail.gmail.com> Message-ID: <6a36e7290810152351x658be316va9625f2d43b616cc@mail.gmail.com> On Wed, Oct 15, 2008 at 11:28 PM, Bjorn Gustavsson wrote: > Thu, Oct 16, 2008 at 7:40 AM, Bob Ippolito wrote: >> >> Well, the float type in Erlang binaries by itself is big endian, not >> native endian. This is a bug in Erlang. > > This is not a bug. The default for numeric types is big endian. If you want > native endian, you must say so: > > <> No, this is a bug. <> on his platform is not returning big endian. -bob From chn.dao77@REDACTED Thu Oct 16 09:04:48 2008 From: chn.dao77@REDACTED (WS Dao) Date: Thu, 16 Oct 2008 15:04:48 +0800 Subject: [erlang-questions] OTP float error on ARM In-Reply-To: <6a36e7290810152351x658be316va9625f2d43b616cc@mail.gmail.com> References: <6a36e7290810150323u18351ec9rf579192477ef256f@mail.gmail.com> <6a36e7290810152240h7d620a3l54cdd807bd83b7b0@mail.gmail.com> <6672d0160810152328g14efa4e6v3789dbbab7ecb9e1@mail.gmail.com> <6a36e7290810152351x658be316va9625f2d43b616cc@mail.gmail.com> Message-ID: # ./erl Eshell V5.6.4 (abort with ^G) 1> <<1.0:64/float>>. <<0,0,0,0,63,240,0,0>> 2> <<1.0:64/native-float>>. <<0,0,240,63,0,0,0,0>> 2008/10/16 Bob Ippolito > On Wed, Oct 15, 2008 at 11:28 PM, Bjorn Gustavsson > wrote: > > Thu, Oct 16, 2008 at 7:40 AM, Bob Ippolito wrote: > >> > >> Well, the float type in Erlang binaries by itself is big endian, not > >> native endian. This is a bug in Erlang. > > > > This is not a bug. The default for numeric types is big endian. If you > want > > native endian, you must say so: > > > > <> > > No, this is a bug. <> on his platform is not returning big endian. > > -bob > -------------- next part -------------- An HTML attachment was scrubbed... URL: From imre@REDACTED Thu Oct 16 09:21:45 2008 From: imre@REDACTED (Imre Palik) Date: Thu, 16 Oct 2008 10:21:45 +0300 Subject: [erlang-questions] generating primes Message-ID: <3BE6DBA1F3BE9D4798255806113D56540F78C912D9@utx-exchange.utx.local> > From: J?r?me Desquilbet > > Imre Palik a ?crit : > > Hi, > > > > I am playing with Project Euler nowdays, and in the last few problems > > I solved I had problems generating primes fast enough. Currently I > > am using the following implementation of the Sieve of Eratosthenes: > > > > sieve([]) -> []; sieve([H|T]) -> [H|sieve([X||X<-T,X rem H =/= 0])]. > > > > ... > > Would you like a suboptimal algorithm? > Here it is: N primes --> N sieves --> N erlang processes. > It's all about playing after all... :-) > J?r?me. Thanks for the idea. Using 2 processes to partition the sieve I managed to get a 30% speedup in my dualcore machine on the first try. I guess there must be an additional 10% somewhere that I can get wit fine tuning and/or with an additional process. Imre From raimo+erlang-questions@REDACTED Thu Oct 16 09:29:32 2008 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Thu, 16 Oct 2008 09:29:32 +0200 Subject: [erlang-questions] ready_async() before outputv() calling driver_async() completes? In-Reply-To: <48F677EF.7060709@alertlogic.net> References: <48F677EF.7060709@alertlogic.net> Message-ID: <20081016072932.GA27066@erix.ericsson.se> On Wed, Oct 15, 2008 at 06:08:31PM -0500, Paul Fisher wrote: > Should it be possible for a ready_async() callback to happen before the > outputv() callback which called driver_async() has returned? I am > seeing this happen on R12B-2 smp runtime (2 schedulers), w/four (4) > async threads. For a non-SMP emulator ready_async() is called by driver_async(), so then the call to ready_async() certainly happens before the return of outputv(), so the SMP emulator should could take the liberty to do the same. And even if the SMP emulator does not do it explicitly, it is always possible for the thread calling outputv() to get scheduled out between the return from driver_async() and the return from outputv(), and the asynchronous thread to get scheduled in, do its thing and call ready_async() right then. > > > -- > paul > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From lfredlund@REDACTED Thu Oct 16 09:51:26 2008 From: lfredlund@REDACTED (=?ISO-8859-1?Q?Lars-=C5ke_Fredlund?=) Date: Thu, 16 Oct 2008 09:51:26 +0200 Subject: [erlang-questions] Core Erlang questions Message-ID: <48F6F27E.9000100@fi.upm.es> Hello, I am considering using Core Erlang to do some transformations on Erlang code, that is doing transformations on the result of after compiling "to_core", and so would like to have a very small and regular source language as a starting point. From reading the Core Erlang 1.0.3 language specification it seems that it is impossible to have expressions with "complex subexpressions" (a very nice syntactic property!) For example, the tuple {2, receive when 'true' -> X after 'infinity' -> 'true'} would not be legal Core Erlang since the receive (like any other expression) returns a sequence, not a value. And because it is not a value, such a sequence cannot be "spliced" into a tuple (except via an outer let expression): let <_cor1> = receive when 'true' -> X after 'infinity' -> 'true' in {2,_cor1} Is this a correct understanding of the dynamic semantics? (or is a singleton sequence also a value?) How should one then understand the "2" in the tuple, doesn't this expression also return a sequence? (just nitpicking) /Lars-Ake Fredlund From kenneth.lundin@REDACTED Thu Oct 16 09:59:51 2008 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Thu, 16 Oct 2008 09:59:51 +0200 Subject: [erlang-questions] timer:send_interval/3 how to return {error, Reason} value? In-Reply-To: References: Message-ID: The timer server does never call exit/1. The timer server is never supposed to crash, it will be a shutdown of the whole E-node if it does. The function timer:send_interval(Time,ReceiverPid,Message) will return {ok,Ref} if everything is ok and {error,badarg} if Time is not an integer, if ReceiverPid is not a pid. /Kenneth Erlang/OTP team, Ericsson 2008/10/16 litao cheng : > Hi, everyone. > When I use timer:send_interval/3, I have some puzzle with the return values: > {ok, TRef}, {error, Reason}. > I see the timer.erl, I know that the timer module is implented by gen_server > behaviour, the exported functions such as send_after, apply_after and so on, > are just call the gen_server:call/2. the gen_server:call/2 may invoke > erlang:exit/1 with some reasons, > but in the timer.erl the timer:req/2 don't catch the exit signal. So I > wonder how the timer:send_interval/3 return {error, Reason}. Is it a bug? > > BS! > litaocheng > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From bgustavsson@REDACTED Thu Oct 16 10:02:28 2008 From: bgustavsson@REDACTED (Bjorn Gustavsson) Date: Thu, 16 Oct 2008 10:02:28 +0200 Subject: [erlang-questions] OTP float error on ARM In-Reply-To: <6a36e7290810152351x658be316va9625f2d43b616cc@mail.gmail.com> References: <6a36e7290810150323u18351ec9rf579192477ef256f@mail.gmail.com> <6a36e7290810152240h7d620a3l54cdd807bd83b7b0@mail.gmail.com> <6672d0160810152328g14efa4e6v3789dbbab7ecb9e1@mail.gmail.com> <6a36e7290810152351x658be316va9625f2d43b616cc@mail.gmail.com> Message-ID: <6672d0160810160102r708d3942o8cb8b879af297f3f@mail.gmail.com> On Thu, Oct 16, 2008 at 8:51 AM, Bob Ippolito wrote: > On Wed, Oct 15, 2008 at 11:28 PM, Bjorn Gustavsson > wrote: > > Thu, Oct 16, 2008 at 7:40 AM, Bob Ippolito wrote: > >> > >> Well, the float type in Erlang binaries by itself is big endian, not > >> native endian. This is a bug in Erlang. > > > > This is not a bug. The default for numeric types is big endian. If you > want > > native endian, you must say so: > > > > <> > > No, this is a bug. <> on his platform is not returning big endian. > Sorry, I misunderstood you. In that case, WORDS_BIGENDIAN in config.h seems to be wrong. It should be defined if the processor is big endian (like Sparc), and undefined otherwise. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB -------------- next part -------------- An HTML attachment was scrubbed... URL: From litaocheng@REDACTED Thu Oct 16 10:34:01 2008 From: litaocheng@REDACTED (litao cheng) Date: Thu, 16 Oct 2008 16:34:01 +0800 Subject: [erlang-questions] timer:send_interval/3 how to return {error, Reason} value? In-Reply-To: References: Message-ID: Kenneth , thank you very much! I just read the timer.erl again, I see in one handle_call cluase, if the Time and Pid format error, the {error, badarg} reply will send to the caller. please pardon my careless. :) 2008/10/16 Kenneth Lundin > The timer server does never call exit/1. > The timer server is never supposed to crash, it will be a shutdown of > the whole E-node if it does. > The function timer:send_interval(Time,ReceiverPid,Message) will return > {ok,Ref} if everything is ok and > {error,badarg} if Time is not an integer, if ReceiverPid is not a pid. > > > /Kenneth Erlang/OTP team, Ericsson > > 2008/10/16 litao cheng : > > Hi, everyone. > > When I use timer:send_interval/3, I have some puzzle with the return > values: > > {ok, TRef}, {error, Reason}. > > I see the timer.erl, I know that the timer module is implented by > gen_server > > behaviour, the exported functions such as send_after, apply_after and so > on, > > are just call the gen_server:call/2. the gen_server:call/2 may invoke > > erlang:exit/1 with some reasons, > > but in the timer.erl the timer:req/2 don't catch the exit signal. So I > > wonder how the timer:send_interval/3 return {error, Reason}. Is it a bug? > > > > BS! > > litaocheng > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mikpe@REDACTED Thu Oct 16 10:55:31 2008 From: mikpe@REDACTED (Mikael Pettersson) Date: Thu, 16 Oct 2008 10:55:31 +0200 Subject: [erlang-questions] OTP float error on ARM In-Reply-To: <6672d0160810160102r708d3942o8cb8b879af297f3f@mail.gmail.com> References: <6a36e7290810150323u18351ec9rf579192477ef256f@mail.gmail.com> <6a36e7290810152240h7d620a3l54cdd807bd83b7b0@mail.gmail.com> <6672d0160810152328g14efa4e6v3789dbbab7ecb9e1@mail.gmail.com> <6a36e7290810152351x658be316va9625f2d43b616cc@mail.gmail.com> <6672d0160810160102r708d3942o8cb8b879af297f3f@mail.gmail.com> Message-ID: <18679.387.354457.384265@harpo.it.uu.se> Bjorn Gustavsson writes: > On Thu, Oct 16, 2008 at 8:51 AM, Bob Ippolito wrote: > > > On Wed, Oct 15, 2008 at 11:28 PM, Bjorn Gustavsson > > wrote: > > > Thu, Oct 16, 2008 at 7:40 AM, Bob Ippolito wrote: > > >> > > >> Well, the float type in Erlang binaries by itself is big endian, not > > >> native endian. This is a bug in Erlang. > > > > > > This is not a bug. The default for numeric types is big endian. If you > > want > > > native endian, you must say so: > > > > > > <> > > > > No, this is a bug. <> on his platform is not returning big endian. In a way it is. It takes the byte sequence representation of a float or double and converts that byte sequence to big endian order. The problem is that the FPA format isn't consistent with the processor's normal integer byte ordering rules. So things like the exponent don't necessarily end up where you'd expect. > > > > Sorry, I misunderstood you. > > In that case, WORDS_BIGENDIAN in config.h seems to be wrong. It should be > defined if the > processor is big endian (like Sparc), and undefined otherwise. No, see above. I've seen many application source codes ported to ARM, and there is no simple generic "it's little endian" or "it's big endian" description for the C "double" representation. The only way to handle it is to use various ARM-specific preprocessor symbols to enumerate combinations of native endianess and FP format and handle each combination individually. That's why the long obsolete FPA format is so insane, and why every ARM out there should migrate over to soft or hard VFP ASAP. (Unless it has hard-FPA or hard-Maverick, but few do.) But there is a bug in Erlang in that it contains code which assumes standard IEEE FP representation. You can fix that, or you can declare machines using other formats unsupported. From richardc@REDACTED Thu Oct 16 11:19:38 2008 From: richardc@REDACTED (Richard Carlsson) Date: Thu, 16 Oct 2008 11:19:38 +0200 Subject: [erlang-questions] Core Erlang questions In-Reply-To: <48F6F27E.9000100@fi.upm.es> References: <48F6F27E.9000100@fi.upm.es> Message-ID: <48F7072A.9090004@it.uu.se> Lars-?ke Fredlund wrote: > From reading the Core Erlang 1.0.3 language specification it seems that > it is impossible to have expressions with "complex subexpressions" (a > very nice syntactic property!) > > For example, > the tuple > {2, receive when 'true' -> X after 'infinity' -> 'true'} > would not be legal Core Erlang since the receive (like any other > expression) > returns a sequence, not a value. And because it is not a value, > such a sequence cannot be "spliced" into a tuple (except via an outer > let expression): > > let <_cor1> = > receive > when 'true' -> > X > after 'infinity' -> > 'true' > in > {2,_cor1} > > > Is this a correct understanding of the dynamic semantics? (or is a > singleton sequence also a value?) > > How should one then understand the "2" in the tuple, doesn't this > expression also return a sequence? No no, don't worry, you can nest expressions as much as you like. Grammatically, page 7 shows how an Expression 'e' can be either a SingleExpression 's' or a ValueList '< s1, ..., sN >' of zero or more SingleExpressions. A SingleExpression is an "ordinary, plain expression" like an atom, a tuple, a fun, a case switch, etc. The arguments to these (such as the elements of a tuple) are in their turn also Expressions. Page 11 explains (or tries to) that in Core Erlang, every expression evaluates to a sequence of zero or more values, whereas in plain Erlang, an expression always evaluates to exactly one value. Sequences have no runtime representation in themselves, so you cannot pass them around or nest them. A sequence '' is usually written 'x' where there is no risk of confusion. For the dynamic semantics ("what does it _mean_"), first, Page 13 states that expressions used as arguments to other expressions (e.g., an element of a tuple) is expected to always evaluate to a sequence of exactly one element, i.e., you cannot return multiple values if you are going to use the result as a direct argument - for that, you do need a let-binding or similar to access the different values. But the main thing (which is not very obvious), is that you need to read the evaluation rules for expressions (section 6.3) carefully if you want to see how the transition between "values" and "sequences" is specified. For example, evaluation of a tuple is described like this: "{e_1, ..., e_n} This evaluates to the Erlang n-tuple {x_1, ...,x_n}, where for i in [1,n], e_i evaluates to x_i. ..." Here, "e_i evaluates to x_i" really means "e_i evaluates to " (that's the "no risk of confusion" part above), so e.g. in your example, the '2' evaluates to '<2>', from which the rule takes the naked value 2 and uses it to construct <{2,...}>. (In my original specification drafts, I used a downcast operator everywhere to move explicitly from seqences to naked values, but it turned out messy and unreadable. Switching to a more implicit specification, I got something that is much more readable but perhaps harder for a semanticist to follow to the point, at least without a guide.) /Richard PS. It was hard to write, so by Zeus, it should be hard to read! From lfredlund@REDACTED Thu Oct 16 13:31:58 2008 From: lfredlund@REDACTED (=?ISO-8859-1?Q?Lars-=C5ke_Fredlund?=) Date: Thu, 16 Oct 2008 13:31:58 +0200 Subject: [erlang-questions] Core Erlang questions In-Reply-To: <48F7072A.9090004@it.uu.se> References: <48F6F27E.9000100@fi.upm.es> <48F7072A.9090004@it.uu.se> Message-ID: <48F7262E.4010903@fi.upm.es> Richard Carlsson wrote: > Lars-?ke Fredlund wrote: > >> From reading the Core Erlang 1.0.3 language specification it seems that >> it is impossible to have expressions with "complex subexpressions" (a >> very nice syntactic property!) >> >> For example, >> the tuple >> {2, receive when 'true' -> X after 'infinity' -> 'true'} >> would not be legal Core Erlang since the receive (like any other >> expression) >> returns a sequence, not a value. And because it is not a value, >> such a sequence cannot be "spliced" into a tuple (except via an outer >> let expression): >> >> let <_cor1> = >> receive >> when 'true' -> >> X >> after 'infinity' -> >> 'true' >> in >> {2,_cor1} >> >> >> Is this a correct understanding of the dynamic semantics? (or is a >> singleton sequence also a value?) >> >> How should one then understand the "2" in the tuple, doesn't this >> expression also return a sequence? >> > > No no, don't worry, you can nest expressions as much as you like. > > Grammatically, page 7 shows how an Expression 'e' can be either a > SingleExpression 's' or a ValueList '< s1, ..., sN >' of zero or more > SingleExpressions. A SingleExpression is an "ordinary, plain expression" > like an atom, a tuple, a fun, a case switch, etc. The arguments to > these (such as the elements of a tuple) are in their turn also > Expressions. > > Page 11 explains (or tries to) that in Core Erlang, every expression > evaluates to a sequence of zero or more values, whereas in plain Erlang, > an expression always evaluates to exactly one value. Sequences have no > runtime representation in themselves, so you cannot pass them around > or nest them. A sequence '' is usually written 'x' where there is > no risk of confusion. > > For the dynamic semantics ("what does it _mean_"), first, Page 13 states > that expressions used as arguments to other expressions (e.g., an > element of a tuple) is expected to always evaluate to a sequence of > exactly one element, i.e., you cannot return multiple values if you are > going to use the result as a direct argument - for that, you do need a > let-binding or similar to access the different values. But the main > thing (which is not very obvious), is that you need to read the > evaluation rules for expressions (section 6.3) carefully if you want to > see how the transition between "values" and "sequences" is specified. > For example, evaluation of a tuple is described like this: > > "{e_1, ..., e_n} > This evaluates to the Erlang n-tuple {x_1, ...,x_n}, where for i in > [1,n], e_i evaluates to x_i. ..." > > Here, "e_i evaluates to x_i" really means "e_i evaluates to " > (that's the "no risk of confusion" part above), so e.g. in your > example, the '2' evaluates to '<2>', from which the rule takes the > naked value 2 and uses it to construct <{2,...}>. > > (In my original specification drafts, I used a downcast operator > everywhere to move explicitly from seqences to naked values, but > it turned out messy and unreadable. Switching to a more implicit > specification, I got something that is much more readable but > perhaps harder for a semanticist to follow to the point, at least > without a guide.) > > /Richard > > PS. It was hard to write, so by Zeus, it should be hard to read! > Thank you for the explanation, which made the definition much more clearer. Anyway I wasn't worrying, I was rather hoping :-) that it was impossible to have very "complicated" expressions. In a sense having a very simple input format where "computation" (calling functions, receive, case, etc) of expressions only takes place in let arguments, and the let body only composes basic values and variables using simple data constructors. The Core Erlang output from compile:file (with option 'to_core') seems (in my limited testing experience) to respect this. Essentially I want to implement a transformation lifting a subexpression with a receive out from its expression context, and if that receive expression can occur at an arbitrary depth the task will be a bit harder (not much, but a bit). Anyway, the separation between returning a value and variable binding enforced in Core Erlang (through the requirement to a sequence of one element) will help. Greetings, Lars-Ake From saleyn@REDACTED Thu Oct 16 13:47:38 2008 From: saleyn@REDACTED (Serge Aleynikov) Date: Thu, 16 Oct 2008 07:47:38 -0400 Subject: [erlang-questions] binary syntax bug? Message-ID: <48F729DA.2030708@gmail.com> Expected: 1> <<(16#01020304):32/integer>>. <<1,2,3,4>> 2> <<16909060/integer>>. * 3: syntax error before: '<<' Unexpected: 1> <<16#01020304/integer>>. <<4>> 2> <<(16#01020304)/integer>>. <<4>> Serge From rvirding@REDACTED Thu Oct 16 13:59:36 2008 From: rvirding@REDACTED (Robert Virding) Date: Thu, 16 Oct 2008 13:59:36 +0200 Subject: [erlang-questions] Core Erlang questions In-Reply-To: <48F7262E.4010903@fi.upm.es> References: <48F6F27E.9000100@fi.upm.es> <48F7072A.9090004@it.uu.se> <48F7262E.4010903@fi.upm.es> Message-ID: <3dbc6d1c0810160459u510ee29h7030ed8774568d80@mail.gmail.com> 2008/10/16 Lars-?ke Fredlund > > Thank you for the explanation, which made the definition much more clearer. > > Anyway I wasn't worrying, I was rather hoping :-) that it was > impossible to have very > "complicated" expressions. In a sense having a very simple input format > where "computation" (calling functions, receive, case, etc) of > expressions only takes place in let arguments, and the let body only > composes basic values and variables using simple data constructors. The > Core Erlang output from compile:file (with option 'to_core') seems (in > my limited testing experience) to respect this. As Richard said you can basically have full expressions everywhere. One thing to note about returning multiple values is that the compiler makes very few checks of their consistency, it does some internally within a module but none between modules. It is assumed you only return one value. Multiple values were added as a way of handling the export of variables from if/case/receive in Erlang. There is a specific reason for the Erlang compiler to return code like that. In Erlang the order of evaluation is defined to be left-to-right while in Core Erlang no order of evaluation is defined. So to be certain the Erlang compiler explictily sequentialises the evaluation of code by using nested lets. The only problem with this is that some of the Core optimisation modules "assume" that the Core code has been generated like this. I discovered this doing LFE, which generates Core, and while I have only discovered two bugs (fixed in subsequent releases) I do miss out on some optimisations. :-( The way around this is to do the same sequentialisation as the Erlang compiler, which would be right anyway, bit it seems so negative. :-) Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: From richardc@REDACTED Thu Oct 16 14:21:58 2008 From: richardc@REDACTED (Richard Carlsson) Date: Thu, 16 Oct 2008 14:21:58 +0200 Subject: [erlang-questions] Core Erlang questions In-Reply-To: <48F7262E.4010903@fi.upm.es> References: <48F6F27E.9000100@fi.upm.es> <48F7072A.9090004@it.uu.se> <48F7262E.4010903@fi.upm.es> Message-ID: <48F731E6.9080200@it.uu.se> Lars-?ke Fredlund wrote: > Thank you for the explanation, which made the definition much > clearer. > > Anyway I wasn't worrying, I was rather hoping :-) that it was > impossible to have very "complicated" expressions. In a sense having > a very simple input format where "computation" (calling functions, > receive, case, etc) of expressions only takes place in let arguments, > and the let body only composes basic values and variables using > simple data constructors. The Core Erlang output from compile:file > (with option 'to_core') seems (in my limited testing experience) to > respect this. That was another design decision: whether or not to enforce A-normal form. In the end we decided that it was more flexible to allow free form code, and let anyone who wanted a restricted form do their own transformation prepass. The compiler generated code does not so much "respect" a normal form as it "happens to end up something like that". If you add 'inline' to the options, you will see more compact Core code. > Essentially I want to implement a transformation lifting a > subexpression with a receive out from its expression context, and if > that receive expression can occur at an arbitrary depth the task will > be a bit harder (not much, but a bit). Anyway, the separation > between returning a value and variable binding enforced in Core > Erlang (through the requirement to a sequence of one element) will > help. Perhaps surprisingly, I've never had to implement such a normal-form prepass, even though I though I'd need to sooner or later. Maybe I just never attacked a kind of transformation problem where it would have been useful. /Richard From bgustavsson@REDACTED Thu Oct 16 15:01:24 2008 From: bgustavsson@REDACTED (Bjorn Gustavsson) Date: Thu, 16 Oct 2008 15:01:24 +0200 Subject: [erlang-questions] OTP float error on ARM In-Reply-To: <18679.387.354457.384265@harpo.it.uu.se> References: <6a36e7290810150323u18351ec9rf579192477ef256f@mail.gmail.com> <6a36e7290810152240h7d620a3l54cdd807bd83b7b0@mail.gmail.com> <6672d0160810152328g14efa4e6v3789dbbab7ecb9e1@mail.gmail.com> <6a36e7290810152351x658be316va9625f2d43b616cc@mail.gmail.com> <6672d0160810160102r708d3942o8cb8b879af297f3f@mail.gmail.com> <18679.387.354457.384265@harpo.it.uu.se> Message-ID: <6672d0160810160601x38ba3a6bn927ad33612aec76a@mail.gmail.com> On Thu, Oct 16, 2008 at 10:55 AM, Mikael Pettersson wrote: > > > But there is a bug in Erlang in that it contains code which > assumes standard IEEE FP representation. You can fix that, > or you can declare machines using other formats unsupported. > We only support machines that use the standard IEEE FP representation. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB -------------- next part -------------- An HTML attachment was scrubbed... URL: From rklophaus@REDACTED Thu Oct 16 15:06:34 2008 From: rklophaus@REDACTED (Rusty Klophaus) Date: Thu, 16 Oct 2008 09:06:34 -0400 Subject: [erlang-questions] Feedback Request: Nitrogen - A New Web Framework for Erlang Message-ID: <58B8C11B-38D6-42A0-9E95-C1CD7CBF8F83@gmail.com> Hello all, I am working on a new event-driven, Ajax enabled web framework for Erlang (hope to release the code under an open source license in the next three weeks), and would love some early feedback. You can see a Nitrogen remake of the famous 5 minute "Flickr on Rails" screencast here. - Nitrogen Blog - http://nitrogen-erlang.tumblr.com (Sadly, it took me 6 minutes with Nitrogen.) Or, check out these two sites that run Nitrogen: - Stitcho.com - http://www.stitcho.com - Real desktop notifications for your website. - EM5K.com - http://www.em5k.com - Get a real-time desktop alert (via Stitcho) when someone visits your website or blog. Here are some things that make it exciting: - Event-driven model (similar to ASP.NET, not like the Ruby on Rails' MVC model) - Simple and elegant: ~2.5k lines of code - Comprehensive Ajax support - Prototype/Scriptaculous Integration - Form validation on both client-side (through LiveValidation) and server-side validation - Continuations and Long Polling - Common Ajax controls are included: Lightbox, Inplace editing, etc. Best, Rusty From joelr1@REDACTED Thu Oct 16 15:52:31 2008 From: joelr1@REDACTED (Joel Reymont) Date: Thu, 16 Oct 2008 14:52:31 +0100 Subject: [erlang-questions] Feedback Request: Nitrogen - A New Web Framework for Erlang In-Reply-To: <58B8C11B-38D6-42A0-9E95-C1CD7CBF8F83@gmail.com> References: <58B8C11B-38D6-42A0-9E95-C1CD7CBF8F83@gmail.com> Message-ID: Rusty, What is the web server that you are using? It looks like a very elegant framework and I can't wait to kick the tires! Thanks, Joel On Oct 16, 2008, at 2:06 PM, Rusty Klophaus wrote: > You can see a Nitrogen remake of the famous 5 minute "Flickr on > Rails" screencast here. > - Nitrogen Blog - http://nitrogen-erlang.tumblr.com > (Sadly, it took me 6 minutes with Nitrogen.) -- wagerlabs.com From rklophaus@REDACTED Thu Oct 16 16:04:07 2008 From: rklophaus@REDACTED (Rusty Klophaus) Date: Thu, 16 Oct 2008 10:04:07 -0400 Subject: [erlang-questions] Feedback Request: Nitrogen - A New Web Framework for Erlang In-Reply-To: References: <58B8C11B-38D6-42A0-9E95-C1CD7CBF8F83@gmail.com> Message-ID: Hi Joel, I'm using Yaws as the HTTP server, though as you can see from the demo, it doesn't actually hit any .yaws files, instead it goes straight to a module. Thanks for your interest, I'm happy to answer any other questions you have, and I look forward to your feedback after kicking the tires. Also, I recently organized an Erlang Users Group in the Washington, DC area. You might be interested to know that we ended up talking about you and your blog for about 30 minutes at our first meeting, your open poker server, and your passion for different languages. :) Best, Rusty On Oct 16, 2008, at 9:52 AM, Joel Reymont wrote: Rusty, What is the web server that you are using? It looks like a very elegant framework and I can't wait to kick the tires! Thanks, Joel On Oct 16, 2008, at 2:06 PM, Rusty Klophaus wrote: > You can see a Nitrogen remake of the famous 5 minute "Flickr on > Rails" screencast here. > - Nitrogen Blog - http://nitrogen-erlang.tumblr.com > (Sadly, it took me 6 minutes with Nitrogen.) -- wagerlabs.com From erlang-questions_efine@REDACTED Thu Oct 16 16:06:19 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Thu, 16 Oct 2008 10:06:19 -0400 Subject: [erlang-questions] binary syntax bug? In-Reply-To: <48F729DA.2030708@gmail.com> References: <48F729DA.2030708@gmail.com> Message-ID: <6c2563b20810160706i27a8226eo9851413cffb43fef@mail.gmail.com> According to my understanding of the documentation (Programming Examples), this is correct behavior. 1. Default integer size is 8 bits if unspecified. 2. If more data than the size specified is provided, it will be truncated to the least significant bits. So 01020304 becomes 04 (8 bits). I had originally reported this as a bug, but was told it is a feature. There is an EEP to provide a compile-tme option to throw an exception if the truncation is going to happen. Sorry you were bitten by this one, too. On Thu, Oct 16, 2008 at 7:47 AM, Serge Aleynikov wrote: > Expected: > > 1> <<(16#01020304):32/integer>>. > <<1,2,3,4>> > 2> <<16909060/integer>>. > * 3: syntax error before: '<<' > > Unexpected: > > 1> <<16#01020304/integer>>. > <<4>> > 2> <<(16#01020304)/integer>>. > <<4>> > > Serge > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From joelr1@REDACTED Thu Oct 16 16:12:58 2008 From: joelr1@REDACTED (Joel Reymont) Date: Thu, 16 Oct 2008 15:12:58 +0100 Subject: [erlang-questions] Feedback Request: Nitrogen - A New Web Framework for Erlang In-Reply-To: References: <58B8C11B-38D6-42A0-9E95-C1CD7CBF8F83@gmail.com> Message-ID: > I'm using Yaws as the HTTP server, though as you can see from the > demo, it doesn't actually hit any .yaws files, instead it goes > straight to a module. Well, yaws is not bad once you configure it, I suppose. > You might be interested to know that we ended up talking about you > and your blog for about 30 minutes at our first meeting, your open > poker server, I'm flattered! I didn't know there's 30 minutes worth of discussion in the subject :D. > and your passion for different languages. :) Speaking of which, I was nursing my Erlang wounds and sulking just when your message came along. My spirits are much lifted after watching the screencast! The reason for the sulking is that I just rewrote OpenPoker for the third time and have no idea whether it will truly scale now. I'll very soon find out. The lifting of spirits is because I plan to offer a hosted poker solution and that needs a web front-end. I want that to be Nitrogen! -- wagerlabs.com From rklophaus@REDACTED Thu Oct 16 16:15:51 2008 From: rklophaus@REDACTED (Rusty Klophaus) Date: Thu, 16 Oct 2008 10:15:51 -0400 Subject: [erlang-questions] Feedback Request: Nitrogen - A New Web Framework for Erlang In-Reply-To: References: <58B8C11B-38D6-42A0-9E95-C1CD7CBF8F83@gmail.com> Message-ID: <58DB08EE-C850-446E-8ADD-C06F30A3E608@gmail.com> "I want that to be Nitrogen!" Nice! So do I! Let's make it happen! "Well, yaws is not bad once you configure it, I suppose." I've heard from a few people that Yaws might not be the best choice. Nitrogen is relatively loosely coupled to the underlying server, so I would certainly be open to swapping it for something else. What do you recommend? Best, Rusty On Oct 16, 2008, at 10:12 AM, Joel Reymont wrote: > I'm using Yaws as the HTTP server, though as you can see from the > demo, it doesn't actually hit any .yaws files, instead it goes > straight to a module. Well, yaws is not bad once you configure it, I suppose. > You might be interested to know that we ended up talking about you > and your blog for about 30 minutes at our first meeting, your open > poker server, I'm flattered! I didn't know there's 30 minutes worth of discussion in the subject :D. > and your passion for different languages. :) Speaking of which, I was nursing my Erlang wounds and sulking just when your message came along. My spirits are much lifted after watching the screencast! The reason for the sulking is that I just rewrote OpenPoker for the third time and have no idea whether it will truly scale now. I'll very soon find out. The lifting of spirits is because I plan to offer a hosted poker solution and that needs a web front-end. I want that to be Nitrogen! -- wagerlabs.com From C.Grasl@REDACTED Thu Oct 16 17:00:11 2008 From: C.Grasl@REDACTED (Grasl Christoph) Date: Thu, 16 Oct 2008 17:00:11 +0200 Subject: [erlang-questions] webFrameWorkForOTP References: <94C5430AA547F24AA801BA5706F29D2E25CDD4@srvkeyx01.KEYTRONIX.local> <5F3AB0B2-7EAB-4690-9215-74FAB205062B@gmail.com> Message-ID: <94C5430AA547F24AA801BA5706F29D2E25CDD7@srvkeyx01.KEYTRONIX.local> Sweet! I'll be looking forward to exchange some good ideas & strategies in the furure! Cheers, Christoph Grasl Embedded Software Entwickler KEYTRONIX Gesellschaft f?r industrielle Elektronik und Informationstechnologie mbH Ungargasse 64-66/1/109 A-1030 WIEN E-Mail: c.grasl@REDACTED Tel.: +43 (1) 718 06 60 - 323 Mobil: +43 (664) 8556456 WWW: http://www.keytronix.com HG Wien FN 261131t Confidentiality Notice: This message may contain privileged and confidential information. If you think, for any reason, that this message may have been addressed to you in error, you must not disseminate, copy or take any action in reliance on it, and we would ask you to notify us immediately by return email. > -----Urspr?ngliche Nachricht----- > Von: Rusty Klophaus [mailto:rklophaus@REDACTED] > Gesendet: Do 16.10.2008 16:26 > An: Grasl Christoph > Betreff: Re: webFrameWorkForOTP > > Hi Grasl, > > Thanks for your feedback! > > I'm hoping to have the code up and online with some basic > documentation over the next few weeks. Once that happens, I like the > idea of comparing strategies and borrowing eachothers good ideas. :) > > Best, > Rusty >> On Oct 16, 2008, at 9:58 AM, Grasl Christoph wrote: >> >> Hi, Rusty! >> >> I've watched the vid and i must say it all looks >> very neat and dandy! >> >> i'm working myself on a tweaked version of the >> http1.1 ws needed for a web-OPI of an embedded device, >> including such things as PHP & Ajax processors >> in order to extend the functionality of the ESI-scheme, >> HTML & JS processors and client- as well as server-side >> validation routines etc. Right now i'm looking at >> multi homing and link load balancing in order to >> eleminate some apparent connectivity issues. >> I'd be very much interested in your framework and >> if you are willing to give some implementational >> details about the project we could exchange our >> (maybe) different approaches and methodology in >> order to make things more work/fast/beautiful. >> >> Cheers, >> >> Christoph Grasl >> Embedded Software Entwickler >> >> KEYTRONIX >> Gesellschaft f?r industrielle Elektronik und Informationstechnologie mbH >> >> Ungargasse 64-66/1/109 >> A-1030 WIEN >> >> E-Mail: c.grasl@REDACTED >> Tel.: +43 (1) 718 06 60 - 323 >> Mobil: +43 (664) 8556456 >> WWW: http://www.keytronix.com >> >> HG Wien FN 261131t >> >> Confidentiality Notice: >> This message may contain privileged and confidential information. If >> you think, for any reason, that this message may have been addressed >> to you in error, you must not disseminate, copy or take any action in >> reliance on it, and we would ask you to notify us immediately by >> return email. -------------- next part -------------- An HTML attachment was scrubbed... URL: From pfisher@REDACTED Thu Oct 16 17:34:33 2008 From: pfisher@REDACTED (Paul Fisher) Date: Thu, 16 Oct 2008 10:34:33 -0500 Subject: [erlang-questions] driver_entry stop() and driver_async() interaction Message-ID: <48F75F09.7020108@alertlogic.net> Question about work scheduled on async threads via driver_async() and still pending (i.e. they are still on the queue to be executed,) when the stop() callback is invoked. Specifically, assuming smp w/async thread pool and the driver marked ERL_DRV_FLAG_USE_PORT_LOCKING. Is it the responsibility of the code in the stop() callback to call driver_async_cancel() on each outstanding async work item, or will this be done automatically by the emulator before the call to stop()? If this is the responsibility of the code in stop(), is it guaranteed that no async work item will be executing or scheduled during the call to the stop() callback? If no guarantee is made, is holding the PDL necessary and sufficient to guarantee this? -- paul From n39052@REDACTED Thu Oct 16 18:36:44 2008 From: n39052@REDACTED (Sergey A.) Date: Thu, 16 Oct 2008 09:36:44 -0700 Subject: [erlang-questions] Lots of questions about error_logger In-Reply-To: <3bff71aa0810100809w1b5282dfhd7bd06876f255605@mail.gmail.com> References: <3bff71aa0810100809w1b5282dfhd7bd06876f255605@mail.gmail.com> Message-ID: <3bff71aa0810160936k4db2bb0bj1dd3930426721c3@mail.gmail.com> Hello. Edwin Fine, Ulf Wiger, thanks for your detailed answers! They were very-very helpful to me! Trying all your suggestions in practice took some time, but now I know what to do with logging and what to read in the following. -- Sergey From rick.richardson@REDACTED Thu Oct 16 18:46:42 2008 From: rick.richardson@REDACTED (Rick R) Date: Thu, 16 Oct 2008 12:46:42 -0400 Subject: [erlang-questions] Feedback Request: Nitrogen - A New Web Framework for Erlang In-Reply-To: <58DB08EE-C850-446E-8ADD-C06F30A3E608@gmail.com> References: <58B8C11B-38D6-42A0-9E95-C1CD7CBF8F83@gmail.com> <58DB08EE-C850-446E-8ADD-C06F30A3E608@gmail.com> Message-ID: <9810b81b0810160946w3f38f8dfv86b13f0cdb3becd9@mail.gmail.com> I'm currently impressed with MochiWeb, it is small, unobtrusive and event driven, it might fit into your model very nicely. It has quite a few apps built on it, though I'm sure there are others that claim that they are better/faster. On Thu, Oct 16, 2008 at 10:15 AM, Rusty Klophaus wrote: > "I want that to be Nitrogen!" > > Nice! So do I! Let's make it happen! > > > "Well, yaws is not bad once you configure it, I suppose." > > I've heard from a few people that Yaws might not be the best choice. > Nitrogen is relatively loosely coupled to the underlying server, so I > would certainly be open to swapping it for something else. What do > you recommend? > > Best, > Rusty > > > On Oct 16, 2008, at 10:12 AM, Joel Reymont wrote: > > > I'm using Yaws as the HTTP server, though as you can see from the > > demo, it doesn't actually hit any .yaws files, instead it goes > > straight to a module. > > Well, yaws is not bad once you configure it, I suppose. > > > You might be interested to know that we ended up talking about you > > and your blog for about 30 minutes at our first meeting, your open > > poker server, > > I'm flattered! I didn't know there's 30 minutes worth of discussion > in the subject :D. > > > and your passion for different languages. :) > > > Speaking of which, I was nursing my Erlang wounds and sulking just > when your message came along. My spirits are much lifted after > watching the screencast! > > The reason for the sulking is that I just rewrote OpenPoker for the > third time and have no idea whether it will truly scale now. I'll > very soon find out. > > The lifting of spirits is because I plan to offer a hosted poker > solution and that needs a web front-end. I want that to be Nitrogen! > > -- > wagerlabs.com > > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- "Have more than thou showest, Speak less than thou knowest, Lend less than thou owest, Ride more than thou goest." -- The Fool to King Lear -------------- next part -------------- An HTML attachment was scrubbed... URL: From vychodil.hynek@REDACTED Thu Oct 16 19:19:20 2008 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Thu, 16 Oct 2008 19:19:20 +0200 Subject: [erlang-questions] Feedback Request: Nitrogen - A New Web Framework for Erlang In-Reply-To: <9810b81b0810160946w3f38f8dfv86b13f0cdb3becd9@mail.gmail.com> References: <58B8C11B-38D6-42A0-9E95-C1CD7CBF8F83@gmail.com> <58DB08EE-C850-446E-8ADD-C06F30A3E608@gmail.com> <9810b81b0810160946w3f38f8dfv86b13f0cdb3becd9@mail.gmail.com> Message-ID: <20081016171921.84E3E24065@relay.gooddata.com> http://www.erlang.org/pipermail/erlang-questions/2008-July/036838.html 2008/10/16 Rick R > I'm currently impressed with MochiWeb, it is small, unobtrusive and event > driven, it might fit into your model very nicely. It has quite a few apps > built on it, though I'm sure there are others that claim that they are > better/faster. > > On Thu, Oct 16, 2008 at 10:15 AM, Rusty Klophaus wrote: > >> "I want that to be Nitrogen!" >> >> Nice! So do I! Let's make it happen! >> >> >> "Well, yaws is not bad once you configure it, I suppose." >> >> I've heard from a few people that Yaws might not be the best choice. >> Nitrogen is relatively loosely coupled to the underlying server, so I >> would certainly be open to swapping it for something else. What do >> you recommend? >> >> Best, >> Rusty >> >> >> On Oct 16, 2008, at 10:12 AM, Joel Reymont wrote: >> >> > I'm using Yaws as the HTTP server, though as you can see from the >> > demo, it doesn't actually hit any .yaws files, instead it goes >> > straight to a module. >> >> Well, yaws is not bad once you configure it, I suppose. >> >> > You might be interested to know that we ended up talking about you >> > and your blog for about 30 minutes at our first meeting, your open >> > poker server, >> >> I'm flattered! I didn't know there's 30 minutes worth of discussion >> in the subject :D. >> >> > and your passion for different languages. :) >> >> >> Speaking of which, I was nursing my Erlang wounds and sulking just >> when your message came along. My spirits are much lifted after >> watching the screencast! >> >> The reason for the sulking is that I just rewrote OpenPoker for the >> third time and have no idea whether it will truly scale now. I'll >> very soon find out. >> >> The lifting of spirits is because I plan to offer a hosted poker >> solution and that needs a web front-end. I want that to be Nitrogen! >> >> -- >> wagerlabs.com >> >> >> >> >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > > > -- > "Have more than thou showest, > Speak less than thou knowest, > Lend less than thou owest, > Ride more than thou goest." > -- The Fool to King Lear > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- --Hynek (Pichi) Vychodil -------------- next part -------------- An HTML attachment was scrubbed... URL: From fritchie@REDACTED Thu Oct 16 20:16:53 2008 From: fritchie@REDACTED (Scott Lystig Fritchie) Date: Thu, 16 Oct 2008 13:16:53 -0500 Subject: [erlang-questions] Redirect -remsh output In-Reply-To: Message of "Fri, 26 Sep 2008 19:33:58 EDT." <48DD7166.4060809@gmail.com> Message-ID: <20190.1224181013@snookles.snookles.com> I'm catching up on mailing list reading, sorry about replying to an old thread. Serge Aleynikov wrote: sa> At least your "send and play" cured my "tab and cry". ;-) If you're using an OTP system that hasn't been patched(*), then there's a hack work-around already available in OTP: use the nl() function(**). After "nl(mumble)." on the remote node, the local node's expansion of "mumble:" will work as hoped for. -Scott (*) I, too, have been bitten by the tab-in-remote-shell-doesn't-do- what-I-expect-and-hope. The patch (or another patch that does the same thing) is well worth adding to the next releases of OTP. (**) That assumes that you know the module name and you're using tab to find a function. If you don't know the module name, this cheap hack won't help. From babo.online@REDACTED Thu Oct 16 21:54:10 2008 From: babo.online@REDACTED (Attila Babo) Date: Thu, 16 Oct 2008 21:54:10 +0200 Subject: [erlang-questions] generating primes In-Reply-To: <3BE6DBA1F3BE9D4798255806113D56540F78C912D9@utx-exchange.utx.local> References: <3BE6DBA1F3BE9D4798255806113D56540F78C912D9@utx-exchange.utx.local> Message-ID: <597c69660810161254t2e7a44cbpc959ca41fd35d8a1@mail.gmail.com> Using an accumulator for your sieve_filter functions pays back, it's around 30 percent faster than the original version. Erlang optimized the other functions quite nicely, but here the tail recursive version is better by a clean margin. sf(_, _, [], R) -> R; sf(F, I, [F|T], R) -> sf(F + I, I, T, R); sf(F, I, [H|T], R) when H > F-> sf(F + I, I, T, [H|R]); sf(F, I, [H|T], R) -> sf(F, I, T, [H|R]). /Attila From klacke@REDACTED Thu Oct 16 22:33:03 2008 From: klacke@REDACTED (=?ISO-8859-1?Q?Claes_Wikstr=F6m?=) Date: Thu, 16 Oct 2008 22:33:03 +0200 Subject: [erlang-questions] Feedback Request: Nitrogen - A New Web Framework for Erlang In-Reply-To: <9810b81b0810160946w3f38f8dfv86b13f0cdb3becd9@mail.gmail.com> References: <58B8C11B-38D6-42A0-9E95-C1CD7CBF8F83@gmail.com> <58DB08EE-C850-446E-8ADD-C06F30A3E608@gmail.com> <9810b81b0810160946w3f38f8dfv86b13f0cdb3becd9@mail.gmail.com> Message-ID: <48F7A4FF.5060205@hyber.org> Rick R wrote: > I'm currently impressed with MochiWeb, I am too, > it is small, unobtrusive and > event driven, it might fit into your model very nicely. It has quite a > few apps built on it, though I'm sure there are others that claim that > they are better/faster. Mochiweb and yaws are different beast, I'd love to see this sort of framework work on (at least both) The heart of the code would be the ajax code which is where the action is. Integration code to the webserver would typically be on the fringe ?? right. In the case of yaws, a single appmod at / (I suppose) - thus not using yaws for anything else than pure http(s). Many apps typically use a combo of stuff though - not all is ajaxy. Typically there is other cruft on the sides. My 2c /klacke From webaccounts@REDACTED Thu Oct 16 22:38:39 2008 From: webaccounts@REDACTED (Dan Rubino) Date: Thu, 16 Oct 2008 21:38:39 +0100 Subject: [erlang-questions] Erlang and XML. Message-ID: <1224189519.6175.14.camel@linux-box> Hi all, Been having a dabble with XMErl today. I am using Erlang on the server side to query an in-memory database via ODBC. As I am sure most of you know when you query a DB via ODBC in Erlang you get a structure something like this back: {selected, ColumnNames, Rows} = ... Where ColumnNames and Rows are of course lists. What I would like to do is convert these list into a very simple XML structure which I can return to a Java based client for easier processing. So something simple like the following for example (don't worry about col ordering): Having looked at XMErl there doesn't appear at first glance to be an easy and generic way in which I can do this. I am sure its something commonly done - any ideas? Many Thanks, Dan From ulf@REDACTED Thu Oct 16 23:07:20 2008 From: ulf@REDACTED (Ulf Wiger) Date: Thu, 16 Oct 2008 23:07:20 +0200 Subject: [erlang-questions] Erlang and XML. In-Reply-To: <1224189519.6175.14.camel@linux-box> References: <1224189519.6175.14.camel@linux-box> Message-ID: <8209f740810161407k387b9016x5a332ce512185f43@mail.gmail.com> Something like this? 1> X = [{result,[], [{cols,[],[{col,[],[C]} || C <- ColumnNames]}, {rows,[],[{row,[],[{value,[],[V]} || V <- tuple_to_list(R)]} || R <- Rows]}]}]. 2> xmerl:export_simple(X, xmerl_xml). If some column value is something other than a string, you'll need to convert it first (e.g. integer_to_list(Int)). BR, Ulf W 2008/10/16 Dan Rubino : > Hi all, > > Been having a dabble with XMErl today. I am using Erlang on the server > side to query an in-memory database via ODBC. > > As I am sure most of you know when you query a DB via ODBC in Erlang you > get a structure something like this back: > > {selected, ColumnNames, Rows} = ... > > Where ColumnNames and Rows are of course lists. What I would like to do > is convert these list into a very simple XML structure which I can > return to a Java based client for easier processing. > > So something simple like the following for example (don't worry about > col ordering): > > > > > > > > > > > > Having looked at XMErl there doesn't appear at first glance to be an > easy and generic way in which I can do this. > > I am sure its something commonly done - any ideas? > > Many Thanks, > Dan > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From monch1962@REDACTED Thu Oct 16 23:09:03 2008 From: monch1962@REDACTED (David Mitchell) Date: Fri, 17 Oct 2008 08:09:03 +1100 Subject: [erlang-questions] What's the status of erl_com, the Erlang-t o-COM bridge? In-Reply-To: References: Message-ID: I'd LOVE to replace MQ and Tibco - about they only things they have in their favor is "vendor support", and being already entrenched in the environment. I quite like the functionality of both, but trying to do something with them that the vendors didn't consider (i.e. hook Erlang to them) is painful. For an open-source app, there would either be a generic API (e.g. REST) that would be language independent, or I could pull apart the source and extend it. Actually, MQ has a "sort of like REST" API, but it's an optional extra i.e. costs money. It's not enough like REST to make it a no-brainer though, and then there's the question of how it's gonna impact the existing infrastructure since it has to run on the MQ server. As far as the data distribution goes, I need to build a "dashboard"-type Web page that I can use to see the state of all the various interfaces. COMET gives me the ability to have the server update each interface's status as new info becomes available without having the user refresh the Web page (at least, that's the theory - whether it's gonna scale is another matter...). Do you know of a way I could duplicate that with XMPP and ejabberd? I don't really want an AJAX interface except as a last resort, as that's going to be a "pull" interface; I'd really like a "push" interface if it's practical, so I can get something approaching real-time updates. Thanks for your response Dave M. 2008/10/16 French, Mike : > > How about using XMPP and ejabberd for the data distribution ? > COMET over HTTP is always an unnatural contortion, > but Jabber is pub/sub push by nature. > > Then you could always replace MQ and Tibco with XMPP later on :) > > Mike > >> -----Original Message----- >> From: erlang-questions-bounces@REDACTED >> [mailto:erlang-questions-bounces@REDACTED]On Behalf Of >> David Mitchell >> Sent: 15 October 2008 21:34 >> To: erlang-questions@REDACTED >> Subject: Re: [erlang-questions] What's the status of erl_com, the >> Erlang-to-COM bridge? >> >> >> My reason for choosing Erlang in the first place was for scalability - >> I need to be able to read/write/monitor upwards of 1000 MQ and Tibco >> queues simultaneously, and drive them all and present status plus >> drill-down info from a central point via a Web interface. I've got >> access to lots of Intel servers (if necessary) to build this. With >> Erlang, the ease of scaling horizontally makes it relatively >> straightforward to handle that quantity of interfaces (ignoring the >> fact that they're MQ and Tibco specifically), and using Yaws would >> mean that I won't have issues with scalability in data presentation. >> Finally, and I haven't thought this next part through thoroughly yet, >> I would also lean towards using COMET (not the COM interface project; >> the Web push interface project) to push updates out to my Web clients. >> >> Finally the app is such that it needs to be 100% reliable during >> extended periods of high load, and OTP gives me the capability to >> build that in fairly easily. >> >> Bottom line is that I know Erlang would be a good fit (again, ignoring >> the fact that the interfaces are MQ and Tibco), whereas I think it >> would take me longer to produce a less-reliable solution in Java. >> >> Regards >> >> Dave M. >> >> 2008/10/15 Rapsey : >> > I'm sure Java has what you need, so why not go through jinterface? >> > >> > >> > Sergej >> > >> > On Wed, Oct 15, 2008 at 11:31 AM, Robert Raschke >> >> > wrote: >> >> >> >> On Wed, Oct 15, 2008 at 5:52 AM, David Mitchell >> >> >> wrote: >> >> > Thanks Jakob and Kenneth for your responses. >> >> > >> >> > I need to hook Erlang to a variety of external >> applications (MQ, Tibco >> >> > Rendezvous, Oracle), none of which have "native" Erlang >> interfaces but >> >> > all have COM interfaces available. Comet looked like a good fit >> >> > (assuming I ran Erlang on a Windows box), but based on >> your comments >> >> > I'll look elsewhere. That probably means building a C >> port for MQ and >> >> > Tibco, and I may be able to get away with using ODBC for Oracle. >> >> > >> >> > If you need any votes of support to revive COMET within Ericsson, >> >> > please let me know ;-> >> >> >> >> If you don't want to use something like C#, then I can >> recommend Lua >> >> together with LuaCOM for interfacing to COM. I would guess >> that it's >> >> not very hard to wrap a COM interface with this and expose it to >> >> Erlang through a port. Still, a little bit of work would >> be required. >> >> >> >> Robby >> >> _______________________________________________ >> >> erlang-questions mailing list >> >> erlang-questions@REDACTED >> >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > >> > >> > _______________________________________________ >> > erlang-questions mailing list >> > erlang-questions@REDACTED >> > http://www.erlang.org/mailman/listinfo/erlang-questions >> > >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > Thales UK Ltd (Wells) DISCLAIMER: The information contained in this e-mail > is confidential. It may also be legally privileged. It is intended only for > the stated addressee(s) and access to it by any other person is > unauthorised. If you are not an addressee, you must not disclose, copy, > circulate or in any other way use or rely on the information contained in > this e-mail. Such unauthorised use may be unlawful. We may monitor all > e-mail communications through our networks. If you have received this e-mail > in error, please inform us immediately on sender's telephone number above > and delete it and all copies from your system. We accept no responsibility > for changes to any e-mail which occur after it has been sent. Attachments > to this e-mail may contain software viruses which could damage your system. > We therefore recommend you virus-check all attachments before opening. > Thales UK Ltd. Registered Office: 2 Dashwood Lang Road, The Bourne Business > Park, Addlestone, Weybridge, Surrey KT15 2NX Registered in England No. > 868273 > From webaccounts@REDACTED Thu Oct 16 23:10:51 2008 From: webaccounts@REDACTED (Dan Rubino) Date: Thu, 16 Oct 2008 22:10:51 +0100 Subject: [erlang-questions] Erlang and XML. In-Reply-To: <8209f740810161407k387b9016x5a332ce512185f43@mail.gmail.com> References: <1224189519.6175.14.camel@linux-box> <8209f740810161407k387b9016x5a332ce512185f43@mail.gmail.com> Message-ID: <1224191451.6175.15.camel@linux-box> Excellent - thanks Ulf I will give that a go! Dan On Thu, 2008-10-16 at 23:07 +0200, Ulf Wiger wrote: > Something like this? > > 1> X = [{result,[], > [{cols,[],[{col,[],[C]} > || C <- ColumnNames]}, > {rows,[],[{row,[],[{value,[],[V]} > || V <- tuple_to_list(R)]} > || R <- Rows]}]}]. > > 2> xmerl:export_simple(X, xmerl_xml). > > If some column value is something other than a string, you'll > need to convert it first (e.g. integer_to_list(Int)). > > BR, > Ulf W > > > 2008/10/16 Dan Rubino : > > Hi all, > > > > Been having a dabble with XMErl today. I am using Erlang on the server > > side to query an in-memory database via ODBC. > > > > As I am sure most of you know when you query a DB via ODBC in Erlang you > > get a structure something like this back: > > > > {selected, ColumnNames, Rows} = ... > > > > Where ColumnNames and Rows are of course lists. What I would like to do > > is convert these list into a very simple XML structure which I can > > return to a Java based client for easier processing. > > > > So something simple like the following for example (don't worry about > > col ordering): > > > > > > > > > > > > > > > > > > > > > > > > Having looked at XMErl there doesn't appear at first glance to be an > > easy and generic way in which I can do this. > > > > I am sure its something commonly done - any ideas? > > > > Many Thanks, > > Dan > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > From harveyd@REDACTED Thu Oct 16 23:36:58 2008 From: harveyd@REDACTED (Dale Harvey) Date: Thu, 16 Oct 2008 22:36:58 +0100 Subject: [erlang-questions] What's the status of erl_com, the Erlang-t o-COM bridge? In-Reply-To: References: Message-ID: the xiff library can connect to ejabberd using flash sockets, writing a custom client with flash sockets is also possible, and writing a proxy / gateway that connects to xmpp on the server and can serve comet or flash would be straightforward. websockets are also coming natively to browsers but not yet supported. (they would need a proxy / gateway to xmpp, incompatible protocol) as for comet 'scaling' its used for facebook and meebo chat, both serve a fair amount of people with realtime information. flash sockets havent gained the same popularity as far as ive seen, although I dont see an obvious reason why, apart from the flash plugin dependancy 2008/10/16 David Mitchell > I'd LOVE to replace MQ and Tibco - about they only things they have in > their favor is "vendor support", and being already entrenched in the > environment. I quite like the functionality of both, but trying to do > something with them that the vendors didn't consider (i.e. hook Erlang > to them) is painful. For an open-source app, there would either be a > generic API (e.g. REST) that would be language independent, or I could > pull apart the source and extend it. > > Actually, MQ has a "sort of like REST" API, but it's an optional extra > i.e. costs money. It's not enough like REST to make it a no-brainer > though, and then there's the question of how it's gonna impact the > existing infrastructure since it has to run on the MQ server. > > As far as the data distribution goes, I need to build a > "dashboard"-type Web page that I can use to see the state of all the > various interfaces. COMET gives me the ability to have the server > update each interface's status as new info becomes available without > having the user refresh the Web page (at least, that's the theory - > whether it's gonna scale is another matter...). Do you know of a way > I could duplicate that with XMPP and ejabberd? I don't really want an > AJAX interface except as a last resort, as that's going to be a "pull" > interface; I'd really like a "push" interface if it's practical, so I > can get something approaching real-time updates. > > Thanks for your response > > Dave M. > > 2008/10/16 French, Mike : > > > > How about using XMPP and ejabberd for the data distribution ? > > COMET over HTTP is always an unnatural contortion, > > but Jabber is pub/sub push by nature. > > > > Then you could always replace MQ and Tibco with XMPP later on :) > > > > Mike > > > >> -----Original Message----- > >> From: erlang-questions-bounces@REDACTED > >> [mailto:erlang-questions-bounces@REDACTED]On Behalf Of > >> David Mitchell > >> Sent: 15 October 2008 21:34 > >> To: erlang-questions@REDACTED > >> Subject: Re: [erlang-questions] What's the status of erl_com, the > >> Erlang-to-COM bridge? > >> > >> > >> My reason for choosing Erlang in the first place was for scalability - > >> I need to be able to read/write/monitor upwards of 1000 MQ and Tibco > >> queues simultaneously, and drive them all and present status plus > >> drill-down info from a central point via a Web interface. I've got > >> access to lots of Intel servers (if necessary) to build this. With > >> Erlang, the ease of scaling horizontally makes it relatively > >> straightforward to handle that quantity of interfaces (ignoring the > >> fact that they're MQ and Tibco specifically), and using Yaws would > >> mean that I won't have issues with scalability in data presentation. > >> Finally, and I haven't thought this next part through thoroughly yet, > >> I would also lean towards using COMET (not the COM interface project; > >> the Web push interface project) to push updates out to my Web clients. > >> > >> Finally the app is such that it needs to be 100% reliable during > >> extended periods of high load, and OTP gives me the capability to > >> build that in fairly easily. > >> > >> Bottom line is that I know Erlang would be a good fit (again, ignoring > >> the fact that the interfaces are MQ and Tibco), whereas I think it > >> would take me longer to produce a less-reliable solution in Java. > >> > >> Regards > >> > >> Dave M. > >> > >> 2008/10/15 Rapsey : > >> > I'm sure Java has what you need, so why not go through jinterface? > >> > > >> > > >> > Sergej > >> > > >> > On Wed, Oct 15, 2008 at 11:31 AM, Robert Raschke > >> > >> > wrote: > >> >> > >> >> On Wed, Oct 15, 2008 at 5:52 AM, David Mitchell > >> > >> >> wrote: > >> >> > Thanks Jakob and Kenneth for your responses. > >> >> > > >> >> > I need to hook Erlang to a variety of external > >> applications (MQ, Tibco > >> >> > Rendezvous, Oracle), none of which have "native" Erlang > >> interfaces but > >> >> > all have COM interfaces available. Comet looked like a good fit > >> >> > (assuming I ran Erlang on a Windows box), but based on > >> your comments > >> >> > I'll look elsewhere. That probably means building a C > >> port for MQ and > >> >> > Tibco, and I may be able to get away with using ODBC for Oracle. > >> >> > > >> >> > If you need any votes of support to revive COMET within Ericsson, > >> >> > please let me know ;-> > >> >> > >> >> If you don't want to use something like C#, then I can > >> recommend Lua > >> >> together with LuaCOM for interfacing to COM. I would guess > >> that it's > >> >> not very hard to wrap a COM interface with this and expose it to > >> >> Erlang through a port. Still, a little bit of work would > >> be required. > >> >> > >> >> Robby > >> >> _______________________________________________ > >> >> erlang-questions mailing list > >> >> erlang-questions@REDACTED > >> >> http://www.erlang.org/mailman/listinfo/erlang-questions > >> > > >> > > >> > _______________________________________________ > >> > erlang-questions mailing list > >> > erlang-questions@REDACTED > >> > http://www.erlang.org/mailman/listinfo/erlang-questions > >> > > >> _______________________________________________ > >> erlang-questions mailing list > >> erlang-questions@REDACTED > >> http://www.erlang.org/mailman/listinfo/erlang-questions > >> > > > > Thales UK Ltd (Wells) DISCLAIMER: The information contained in this > e-mail > > is confidential. It may also be legally privileged. It is intended only > for > > the stated addressee(s) and access to it by any other person is > > unauthorised. If you are not an addressee, you must not disclose, copy, > > circulate or in any other way use or rely on the information contained in > > this e-mail. Such unauthorised use may be unlawful. We may monitor all > > e-mail communications through our networks. If you have received this > e-mail > > in error, please inform us immediately on sender's telephone number above > > and delete it and all copies from your system. We accept no > responsibility > > for changes to any e-mail which occur after it has been sent. > Attachments > > to this e-mail may contain software viruses which could damage your > system. > > We therefore recommend you virus-check all attachments before opening. > > Thales UK Ltd. Registered Office: 2 Dashwood Lang Road, The Bourne > Business > > Park, Addlestone, Weybridge, Surrey KT15 2NX Registered in England No. > > 868273 > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf@REDACTED Fri Oct 17 00:36:27 2008 From: ulf@REDACTED (Ulf Wiger) Date: Fri, 17 Oct 2008 00:36:27 +0200 Subject: [erlang-questions] Core Erlang questions In-Reply-To: <3dbc6d1c0810160459u510ee29h7030ed8774568d80@mail.gmail.com> References: <48F6F27E.9000100@fi.upm.es> <48F7072A.9090004@it.uu.se> <48F7262E.4010903@fi.upm.es> <3dbc6d1c0810160459u510ee29h7030ed8774568d80@mail.gmail.com> Message-ID: <8209f740810161536m2bda0e83wd2d8733fab447b28@mail.gmail.com> 2008/10/16 Robert Virding : > > There is a specific reason for the Erlang compiler to return code like that. > In Erlang the order of evaluation is defined to be left-to-right Where is this defined? I believe (too tired to check) that the Barklund spec left the evaluation order undefined, with the proviso that no possible evaluation order should leave variables unbound when used. In the Erlang Reference Manual, the only reference I found (during a very sloppy search) said that sub-expressions are evaluated in any order. Not that I rely on this property - just curious. BR, Ulf W From monch1962@REDACTED Fri Oct 17 03:53:44 2008 From: monch1962@REDACTED (David Mitchell) Date: Fri, 17 Oct 2008 12:53:44 +1100 Subject: [erlang-questions] What's the status of erl_com, the Erlang-t o-COM bridge? In-Reply-To: References: Message-ID: Hmm, thanks Dale - you've definitely given me another approach worth thinking about. Time to make a list of the pros and cons of Flash vs. COMET. To be honest, I've never even considered using Flash for something like this, but I can see it's got a lot going for it. Hmm... Thanks and regards Dave M. 2008/10/17 Dale Harvey : > the xiff library can connect to ejabberd using flash sockets, writing a > custom client > with flash sockets is also possible, and writing a proxy / gateway that > connects to > xmpp on the server and can serve comet or flash would be straightforward. > > websockets are also coming natively to browsers but not yet supported. > (they would need a proxy / gateway to xmpp, incompatible protocol) > > as for comet 'scaling' its used for facebook and meebo chat, both serve a > fair > amount of people with realtime information. flash sockets havent gained > the same popularity as far as ive seen, although I dont see an obvious > reason > why, apart from the flash plugin dependancy > > 2008/10/16 David Mitchell >> >> I'd LOVE to replace MQ and Tibco - about they only things they have in >> their favor is "vendor support", and being already entrenched in the >> environment. I quite like the functionality of both, but trying to do >> something with them that the vendors didn't consider (i.e. hook Erlang >> to them) is painful. For an open-source app, there would either be a >> generic API (e.g. REST) that would be language independent, or I could >> pull apart the source and extend it. >> >> Actually, MQ has a "sort of like REST" API, but it's an optional extra >> i.e. costs money. It's not enough like REST to make it a no-brainer >> though, and then there's the question of how it's gonna impact the >> existing infrastructure since it has to run on the MQ server. >> >> As far as the data distribution goes, I need to build a >> "dashboard"-type Web page that I can use to see the state of all the >> various interfaces. COMET gives me the ability to have the server >> update each interface's status as new info becomes available without >> having the user refresh the Web page (at least, that's the theory - >> whether it's gonna scale is another matter...). Do you know of a way >> I could duplicate that with XMPP and ejabberd? I don't really want an >> AJAX interface except as a last resort, as that's going to be a "pull" >> interface; I'd really like a "push" interface if it's practical, so I >> can get something approaching real-time updates. >> >> Thanks for your response >> >> Dave M. >> >> 2008/10/16 French, Mike : >> > >> > How about using XMPP and ejabberd for the data distribution ? >> > COMET over HTTP is always an unnatural contortion, >> > but Jabber is pub/sub push by nature. >> > >> > Then you could always replace MQ and Tibco with XMPP later on :) >> > >> > Mike >> > >> >> -----Original Message----- >> >> From: erlang-questions-bounces@REDACTED >> >> [mailto:erlang-questions-bounces@REDACTED]On Behalf Of >> >> David Mitchell >> >> Sent: 15 October 2008 21:34 >> >> To: erlang-questions@REDACTED >> >> Subject: Re: [erlang-questions] What's the status of erl_com, the >> >> Erlang-to-COM bridge? >> >> >> >> >> >> My reason for choosing Erlang in the first place was for scalability - >> >> I need to be able to read/write/monitor upwards of 1000 MQ and Tibco >> >> queues simultaneously, and drive them all and present status plus >> >> drill-down info from a central point via a Web interface. I've got >> >> access to lots of Intel servers (if necessary) to build this. With >> >> Erlang, the ease of scaling horizontally makes it relatively >> >> straightforward to handle that quantity of interfaces (ignoring the >> >> fact that they're MQ and Tibco specifically), and using Yaws would >> >> mean that I won't have issues with scalability in data presentation. >> >> Finally, and I haven't thought this next part through thoroughly yet, >> >> I would also lean towards using COMET (not the COM interface project; >> >> the Web push interface project) to push updates out to my Web clients. >> >> >> >> Finally the app is such that it needs to be 100% reliable during >> >> extended periods of high load, and OTP gives me the capability to >> >> build that in fairly easily. >> >> >> >> Bottom line is that I know Erlang would be a good fit (again, ignoring >> >> the fact that the interfaces are MQ and Tibco), whereas I think it >> >> would take me longer to produce a less-reliable solution in Java. >> >> >> >> Regards >> >> >> >> Dave M. >> >> >> >> 2008/10/15 Rapsey : >> >> > I'm sure Java has what you need, so why not go through jinterface? >> >> > >> >> > >> >> > Sergej >> >> > >> >> > On Wed, Oct 15, 2008 at 11:31 AM, Robert Raschke >> >> >> >> > wrote: >> >> >> >> >> >> On Wed, Oct 15, 2008 at 5:52 AM, David Mitchell >> >> >> >> >> wrote: >> >> >> > Thanks Jakob and Kenneth for your responses. >> >> >> > >> >> >> > I need to hook Erlang to a variety of external >> >> applications (MQ, Tibco >> >> >> > Rendezvous, Oracle), none of which have "native" Erlang >> >> interfaces but >> >> >> > all have COM interfaces available. Comet looked like a good fit >> >> >> > (assuming I ran Erlang on a Windows box), but based on >> >> your comments >> >> >> > I'll look elsewhere. That probably means building a C >> >> port for MQ and >> >> >> > Tibco, and I may be able to get away with using ODBC for Oracle. >> >> >> > >> >> >> > If you need any votes of support to revive COMET within Ericsson, >> >> >> > please let me know ;-> >> >> >> >> >> >> If you don't want to use something like C#, then I can >> >> recommend Lua >> >> >> together with LuaCOM for interfacing to COM. I would guess >> >> that it's >> >> >> not very hard to wrap a COM interface with this and expose it to >> >> >> Erlang through a port. Still, a little bit of work would >> >> be required. >> >> >> >> >> >> Robby >> >> >> _______________________________________________ >> >> >> erlang-questions mailing list >> >> >> erlang-questions@REDACTED >> >> >> http://www.erlang.org/mailman/listinfo/erlang-questions >> >> > >> >> > >> >> > _______________________________________________ >> >> > erlang-questions mailing list >> >> > erlang-questions@REDACTED >> >> > http://www.erlang.org/mailman/listinfo/erlang-questions >> >> > >> >> _______________________________________________ >> >> erlang-questions mailing list >> >> erlang-questions@REDACTED >> >> http://www.erlang.org/mailman/listinfo/erlang-questions >> >> >> > >> > Thales UK Ltd (Wells) DISCLAIMER: The information contained in this >> > e-mail >> > is confidential. It may also be legally privileged. It is intended only >> > for >> > the stated addressee(s) and access to it by any other person is >> > unauthorised. If you are not an addressee, you must not disclose, copy, >> > circulate or in any other way use or rely on the information contained >> > in >> > this e-mail. Such unauthorised use may be unlawful. We may monitor all >> > e-mail communications through our networks. If you have received this >> > e-mail >> > in error, please inform us immediately on sender's telephone number >> > above >> > and delete it and all copies from your system. We accept no >> > responsibility >> > for changes to any e-mail which occur after it has been sent. >> > Attachments >> > to this e-mail may contain software viruses which could damage your >> > system. >> > We therefore recommend you virus-check all attachments before opening. >> > Thales UK Ltd. Registered Office: 2 Dashwood Lang Road, The Bourne >> > Business >> > Park, Addlestone, Weybridge, Surrey KT15 2NX Registered in England No. >> > 868273 >> > >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions > > From richardc@REDACTED Fri Oct 17 09:59:56 2008 From: richardc@REDACTED (Richard Carlsson) Date: Fri, 17 Oct 2008 09:59:56 +0200 Subject: [erlang-questions] Core Erlang questions In-Reply-To: <8209f740810161536m2bda0e83wd2d8733fab447b28@mail.gmail.com> References: <48F6F27E.9000100@fi.upm.es> <48F7072A.9090004@it.uu.se> <48F7262E.4010903@fi.upm.es> <3dbc6d1c0810160459u510ee29h7030ed8774568d80@mail.gmail.com> <8209f740810161536m2bda0e83wd2d8733fab447b28@mail.gmail.com> Message-ID: <48F845FC.6010808@it.uu.se> Ulf Wiger wrote: > 2008/10/16 Robert Virding : >> There is a specific reason for the Erlang compiler to return code like that. >> In Erlang the order of evaluation is defined to be left-to-right > > Where is this defined? > > I believe (too tired to check) that the Barklund spec left the > evaluation order undefined, with the proviso that no possible > evaluation order should leave variables unbound when used. As far as I can remember, around the time when Barklund wrote that spec it was decided that Erlang should have a fixed evaluation order, so that there would never be a situation where a program would behave slightly different (e.g., a process sending messages in a different order, or a different exception being thrown) on an alternative implementation. I think some minor things in the compiler were changed at that time, to conform to the left-to-right principle. It does restrict a bit what the compiler can do, though: only safe expressions (free from side effects and exceptions) can be reordered at all. I can't tell if this ever made it into any text, though. In the core language, the evaluation order is made completely explicit, as Robert explained, which forces the translated code to almost-normal form. > In the Erlang Reference Manual, the only reference I found > (during a very sloppy search) said that sub-expressions > are evaluated in any order. On one hand, that is not correct, given what I just described above. On the other hand, it's probably best if programmers never get into the habit of treating the evaluation order as known. So if you read the above, please forget it again for your everyday work. /Richard From bgustavsson@REDACTED Fri Oct 17 10:41:40 2008 From: bgustavsson@REDACTED (Bjorn Gustavsson) Date: Fri, 17 Oct 2008 10:41:40 +0200 Subject: [erlang-questions] blunt error reporting by escript In-Reply-To: <8209f740809090758k47b5b0eeh5da2aa5e90173f4f@mail.gmail.com> References: <8209f740809090758k47b5b0eeh5da2aa5e90173f4f@mail.gmail.com> Message-ID: <6672d0160810170141q658ac624vf9e6b3008c6dc0e5@mail.gmail.com> On Tue, Sep 9, 2008 at 4:58 PM, Ulf Wiger wrote: > I'm writing a non-trivial escript script, and am getting pretty > frustrated with the error reporting. > > escript: exception error: no match of right hand side value {ok, ["..."]} > > My script is only 75 lines so far but has 10 different functions, and it > would > certainly help to at least know in which function the error occured, > if not the line. > > If the script is interpreted, couldn't it give me the line number? > I'd even forego the pretty-printing of the message in favor of some hard > facts about where in the program the exception happened. > We'll try to fix this in a future release. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB -------------- next part -------------- An HTML attachment was scrubbed... URL: From pguyot@REDACTED Fri Oct 17 10:41:59 2008 From: pguyot@REDACTED (Paul Guyot) Date: Fri, 17 Oct 2008 10:41:59 +0200 Subject: [erlang-questions] ei_reg_send is destructive to the erlang node's pid Message-ID: <7BD2E391-F28C-495A-BCCA-D652CA8F68D9@kallisys.net> Hello, I noticed that ei_reg_send and ei_reg_send_tmo are destructive of the node's pid: erlang_pid *self = ei_self(ec); self->num = fd; (and so is ei_rpc_to) The same problem can be found in the code snipet in ei_send_reg_encoded's documentation: > A suitable erlang_pid can be constructed from the ei_cnode > structure by the following example code: > > ei_cnode ec; > erlang_pid *self; > int fd; /* the connection fd */ > ... > self = ei_self(&ec); > self->num = fd; This means that two calls to ei_self won't return the same value, and this might be a problem for pids sent to a node and then received back and compared, especially if several fds are passed to ei_reg_send to send messages to several distant nodes (and therefore several connection fds). I am actually confused by the comment. Why such a pid is suitable and the original node's pid () unsuitable? Paul From bgustavsson@REDACTED Fri Oct 17 11:12:23 2008 From: bgustavsson@REDACTED (Bjorn Gustavsson) Date: Fri, 17 Oct 2008 11:12:23 +0200 Subject: [erlang-questions] How to build Erlang with libcmt (/MT) under windows? In-Reply-To: <9b59d0270810051004u391f464k112d5175573a95f4@mail.gmail.com> References: <9b59d0270810051004u391f464k112d5175573a95f4@mail.gmail.com> Message-ID: <6672d0160810170212n5eefd0a6o3e2e7a41fc0c6483@mail.gmail.com> 2008/10/5 Michael Regen > Hi, > > Does anyone a little bit more experienced with the Erlang build mechanism > know how to compile and link Erlang with libcmt instead of msvcrt? > The default mechanism builds Erlang with the /MD switch which means the C > standard libraries are accessed as threaded dll MSVCR??.DLL. This also means > you cannot simply copy Erlang to another computer as long as the correct C > runtime is not installed there. > > I am trying to figure out how to statically bind the libcmt library. > Normally you do this by using the /MT switch. > Sorry, but we have no intention of supporting that. The reason is that Microsoft strongly discourages using the statically linked run-time library in programs that loads DLLs. Having a MT-linked emulator will lead to memory leaks. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB -------------- next part -------------- An HTML attachment was scrubbed... URL: From bgustavsson@REDACTED Fri Oct 17 11:50:57 2008 From: bgustavsson@REDACTED (Bjorn Gustavsson) Date: Fri, 17 Oct 2008 11:50:57 +0200 Subject: [erlang-questions] maybe a BUG in the build system of erlang? In-Reply-To: References: Message-ID: <6672d0160810170250t201bf203v48fc7c0a04e022f@mail.gmail.com> On Mon, Sep 8, 2008 at 4:52 AM, luoyi wrote: > I'm making slackware pkgs for erlang R12B4, and find the "make > INSTALL_PREFIX=xxx install" command do some wrong work. > We plan to solve this problem in a future release (not R12B-5). /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB -------------- next part -------------- An HTML attachment was scrubbed... URL: From bgustavsson@REDACTED Fri Oct 17 12:13:23 2008 From: bgustavsson@REDACTED (Bjorn Gustavsson) Date: Fri, 17 Oct 2008 12:13:23 +0200 Subject: [erlang-questions] m4 not checked in configure. In-Reply-To: <48C50ABA.6080502@erlang-consulting.com> References: <48C50ABA.6080502@erlang-consulting.com> Message-ID: <6672d0160810170313g3cbbb511kf02c8bf49c9d5d70@mail.gmail.com> On Mon, Sep 8, 2008 at 1:21 PM, Mazen Harake wrote: > I'm sure this has been brought up before but configure doesn't check for > m4... > annoying but true... we've known this for a long time but I always do > the same mistake when setting up a new systems on various machines :) > > can it be fixed? :) > We will fix this problem in a future release (possibly in R12B-5). /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB -------------- next part -------------- An HTML attachment was scrubbed... URL: From bjourne@REDACTED Fri Oct 17 13:24:11 2008 From: bjourne@REDACTED (=?ISO-8859-1?Q?BJ=F6rn_Lindqvist?=) Date: Fri, 17 Oct 2008 13:24:11 +0200 Subject: [erlang-questions] os:cmd/1 with return code Message-ID: <740c3aec0810170424r4c60458cpb750fa7d8f7470aa@mail.gmail.com> Hello good people, I've been trying to implement and os:cmd/1 variant that also returns the status code of the executed command. But it proved to be exceedingly difficult. First I tried something like os:cmd(Cmd ++ "; echo \n$?") and parsing out the exit code. But that doesn't work if the command string is broken in for example "ls ); echo \n$?" or "exit 99; echo \n$?". Then I tried opening a port to "sh -c" like this: port_open({spawn, "sh -c '" ++ Cmd ++ "'"}, [exit_status]), and then reading from the port and receiving the exit_status message. That works, but has escaping problems so it will fail if e.g. Cmd is "ls 'foo bar'". Then I tried opening a port to "sh", sending the command to it and read the response from the port. Using this code: mycmd(Cmd)-> Opts = [stream, exit_status, stderr_to_stdout, eof], Port = open_port({spawn, "sh"}, Opts), port_command(Port, Cmd ++ "\nexit\n"), get_data(Port, []). get_data(Port, Data) -> receive {Port, {data, Data1}} -> get_data(Port, Data ++ Data1); {Port, {exit_status, N}} -> port_close(Port), {N, Data} end. This mostly works, except when it doesn't. Sometimes I don't get the {exit_status, N} message so the receive waits forever other times I get other messages that I don't want. What should I do? It shouldn't be that complicated to get this right. And why isn't this function already in the OTP library? -- mvh Bj?rn From saleyn@REDACTED Fri Oct 17 13:35:41 2008 From: saleyn@REDACTED (Serge Aleynikov) Date: Fri, 17 Oct 2008 07:35:41 -0400 Subject: [erlang-questions] os:cmd/1 with return code In-Reply-To: <740c3aec0810170424r4c60458cpb750fa7d8f7470aa@mail.gmail.com> References: <740c3aec0810170424r4c60458cpb750fa7d8f7470aa@mail.gmail.com> Message-ID: <48F8788D.9050401@gmail.com> You can take a look at this project: http://code.google.com/p/erlexec/ It aims at solving this along with a handful of other problems. It also allows to link Erlang Pids to spawned OS Pids, send POSIX signals. Regards, Serge BJ?rn Lindqvist wrote: > Hello good people, > > I've been trying to implement and os:cmd/1 variant that also returns > the status code of the executed command. But it proved to be > exceedingly difficult. > > First I tried something like os:cmd(Cmd ++ "; echo \n$?") and parsing > out the exit code. But that doesn't work if the command string is > broken in for example "ls ); echo \n$?" or "exit 99; echo \n$?". > > Then I tried opening a port to "sh -c" like this: > > port_open({spawn, "sh -c '" ++ Cmd ++ "'"}, [exit_status]), > > and then reading from the port and receiving the exit_status > message. That works, but has escaping problems so it will fail if > e.g. Cmd is "ls 'foo bar'". > > Then I tried opening a port to "sh", sending the command to it and > read the response from the port. Using this code: > > mycmd(Cmd)-> > Opts = [stream, exit_status, stderr_to_stdout, eof], > Port = open_port({spawn, "sh"}, Opts), > port_command(Port, Cmd ++ "\nexit\n"), > get_data(Port, []). > > get_data(Port, Data) -> > receive > {Port, {data, Data1}} -> > get_data(Port, Data ++ Data1); > {Port, {exit_status, N}} -> > port_close(Port), > {N, Data} > end. > > This mostly works, except when it doesn't. Sometimes I don't get the > {exit_status, N} message so the receive waits forever other times I > get other messages that I don't want. What should I do? It shouldn't > be that complicated to get this right. And why isn't this function > already in the OTP library? > > From apnmbx-public@REDACTED Fri Oct 17 15:05:46 2008 From: apnmbx-public@REDACTED (Ashok P. Nadkarni) Date: Fri, 17 Oct 2008 18:35:46 +0530 Subject: [erlang-questions] Case-insensitive matching in mnesia and erlang Message-ID: <48F88DAA.1030001@yahoo.com> I'm working my way through erlang and mnesia and writing my first toy application. I had the following question - I'm storing string data in an mnesia database as either a list of integers or as binaries. I want to find records using case-insensitive matching against this field. How would I use mnesia:select to do this? Do I have to explicitly retrieve each record and convert the field and seach key to lower case myself and compare? Is there a faster way? /Ashok From Dana.RUBINO@REDACTED Fri Oct 17 16:11:09 2008 From: Dana.RUBINO@REDACTED (Dana.RUBINO@REDACTED) Date: Fri, 17 Oct 2008 15:11:09 +0100 Subject: [erlang-questions] Erlang unit testing and continuous integration Message-ID: Hi all, Now that I am more familiar with Erlang - going forward I would like to start unit testing my code. I have seen eunit which seems pretty straight forward. http://svn.process-one.net/contribs/trunk/eunit/doc/overview-summary.html Does anyone have any tips for unit testing Erlang and/or know of any other frameworks? Also, are there any options for continuous integration with Erlang? Many Thanks, Dan *********************************************************************************** The Royal Bank of Scotland plc. Registered in Scotland No 90312. Registered Office: 36 St Andrew Square, Edinburgh EH2 2YB. Authorised and regulated by the Financial Services Authority This e-mail message is confidential and for use by the addressee only. If the message is received by anyone other than the addressee, please return the message to the sender by replying to it and then delete the message from your computer. Internet e-mails are not necessarily secure. The Royal Bank of Scotland plc does not accept responsibility for changes made to this message after it was sent. Whilst all reasonable care has been taken to avoid the transmission of viruses, it is the responsibility of the recipient to ensure that the onward transmission, opening or use of this message and any attachments will not adversely affect its systems or data. No responsibility is accepted by The Royal Bank of Scotland plc in this regard and the recipient should carry out such virus and other checks as it considers appropriate. Visit our websites at: www.rbs.com www.rbs.com/gbm www.rbsgc.com *********************************************************************************** -------------- next part -------------- An HTML attachment was scrubbed... URL: From drcabana@REDACTED Fri Oct 17 16:26:49 2008 From: drcabana@REDACTED (David Cabana) Date: Fri, 17 Oct 2008 10:26:49 -0400 Subject: [erlang-questions] Question re io:format and string handling Message-ID: <44ed5e0f0810170726o56b0a92asd49ca4e7550db83a@mail.gmail.com> Consider the result of evaluating the following in an erl console: io:format("The ~p in the ~p", ["cat", "hat"]). The strings "cat" and "hat" are substituted for the occurrences of ~p, and a string is printed to the console. Is there a way to bind that string to a variable instead of printing it to the console? What I am after is a facility somewhat like the one used in the Python example below: phrase = "The %s in the %s" % ("cat", "hat") Evaluating the example above results in the variable 'phrase' taking the value "The cat in the hat". The similarity to the io:format behavior is clear. The Python idiom is useful, and I have been looking for something similar in Erlang, without luck. Before I try to concoct such a thing, I thought I'd ask whether it already exists. Thanks, David -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf@REDACTED Fri Oct 17 16:38:34 2008 From: ulf@REDACTED (Ulf Wiger) Date: Fri, 17 Oct 2008 16:38:34 +0200 Subject: [erlang-questions] Question re io:format and string handling In-Reply-To: <44ed5e0f0810170726o56b0a92asd49ca4e7550db83a@mail.gmail.com> References: <44ed5e0f0810170726o56b0a92asd49ca4e7550db83a@mail.gmail.com> Message-ID: <8209f740810170738y387173dco9f119a4c89e68a67@mail.gmail.com> io_lib:format(Format, Args) is the formatting function used by io:format/2, and returns a (non-flat) string. BR, Ulf W 2008/10/17 David Cabana : > Consider the result of evaluating the following in an erl console: > io:format("The ~p in the ~p", ["cat", "hat"]). > > The strings "cat" and "hat" are substituted for the occurrences of ~p, and a > string is printed to the console. > Is there a way to bind that string to a variable instead of printing it to > the console? > > What I am after is a facility somewhat like the one used in the Python > example below: > phrase = "The %s in the %s" % ("cat", "hat") > > Evaluating the example above results in the variable 'phrase' taking the > value "The cat in the hat". > > The similarity to the io:format behavior is clear. The Python idiom is > useful, and I have been looking for something > similar in Erlang, without luck. Before I try to concoct such a thing, I > thought I'd ask whether it already exists. > > Thanks, > David > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From dmitriid@REDACTED Fri Oct 17 16:39:33 2008 From: dmitriid@REDACTED (Dmitrii Dimandt) Date: Fri, 17 Oct 2008 17:39:33 +0300 Subject: [erlang-questions] Feedback Request: Nitrogen - A New Web Framework for Erlang In-Reply-To: <58B8C11B-38D6-42A0-9E95-C1CD7CBF8F83@gmail.com> References: <58B8C11B-38D6-42A0-9E95-C1CD7CBF8F83@gmail.com> Message-ID: > > - Prototype/Scriptaculous Integration why oh why? :) jQuery is so much better... Where can I dowload it? :) From freza@REDACTED Fri Oct 17 16:41:02 2008 From: freza@REDACTED (Jachym Holecek) Date: Fri, 17 Oct 2008 16:41:02 +0200 Subject: [erlang-questions] Question re io:format and string handling In-Reply-To: <44ed5e0f0810170726o56b0a92asd49ca4e7550db83a@mail.gmail.com> References: <44ed5e0f0810170726o56b0a92asd49ca4e7550db83a@mail.gmail.com> Message-ID: <20081017144102.GA4688@hanele.fractal2003.cz> # David Cabana 2008-10-17: > Consider the result of evaluating the following in an erl console: > io:format("The ~p in the ~p", ["cat", "hat"]). > > The strings "cat" and "hat" are substituted for the occurrences of ~p, and a > string is printed to the console. > Is there a way to bind that string to a variable instead of printing it to > the console? See io_lib:format/2. -- Jachym From kostis@REDACTED Fri Oct 17 16:43:18 2008 From: kostis@REDACTED (Kostis Sagonas) Date: Fri, 17 Oct 2008 17:43:18 +0300 Subject: [erlang-questions] Question re io:format and string handling In-Reply-To: <44ed5e0f0810170726o56b0a92asd49ca4e7550db83a@mail.gmail.com> References: <44ed5e0f0810170726o56b0a92asd49ca4e7550db83a@mail.gmail.com> Message-ID: <48F8A486.7020700@cs.ntua.gr> David Cabana wrote: > Consider the result of evaluating the following in an erl console: > io:format("The ~p in the ~p", ["cat", "hat"]). > > The strings "cat" and "hat" are substituted for the occurrences of ~p, > and a string is printed to the console. > Is there a way to bind that string to a variable instead of printing it > to the console? > > What I am after is a facility somewhat like the one used in the Python > example below: > phrase = "The %s in the %s" % ("cat", "hat") > > Evaluating the example above results in the variable 'phrase' taking the > value "The cat in the hat". > > The similarity to the io:format behavior is clear. The Python idiom is > useful, and I have been looking for something similar in Erlang, without luck. This is your lucky day ;-) Use io_lib:format instead of io:format Kostis PS. For better-looking results in the shell, you probably want to substitute the ~p with ~s and wrap the io_lib:format call with a call to lists:flatten/1 as in: lists:flatten(io_lib:format("The ~s in the ~s", ["cat", "hat"])). From rvirding@REDACTED Fri Oct 17 16:45:03 2008 From: rvirding@REDACTED (Robert Virding) Date: Fri, 17 Oct 2008 16:45:03 +0200 Subject: [erlang-questions] Question re io:format and string handling In-Reply-To: <44ed5e0f0810170726o56b0a92asd49ca4e7550db83a@mail.gmail.com> References: <44ed5e0f0810170726o56b0a92asd49ca4e7550db83a@mail.gmail.com> Message-ID: <3dbc6d1c0810170745p6bc83915r6fa3146ff0ae1b19@mail.gmail.com> There is nothing exactly like what Python does. There are options though: - You can use io_lib:format which returns a, possibly deep, list of characters which is the the representation of format string and the arguments. So: Phrase = io_lib:format("The ~p in the ~p", ["cat", "hat"]) Depending on what you are going to do, you may have to apply lists:flatten to the string to get a flat list. io_lib:format has the same format options as io:format, and is in fact called by io:format to generate the output string. - A more direct but less general way is to concatenate the string directly: Cat = "cat", Hat = "hat", Phrase = "The " ++ Cat ++ " in the " ++ Hat >From your question I would guess it is the 1st version you want, Robert 2008/10/17 David Cabana > Consider the result of evaluating the following in an erl console: > io:format("The ~p in the ~p", ["cat", "hat"]). > > The strings "cat" and "hat" are substituted for the occurrences of ~p, and > a string is printed to the console. > Is there a way to bind that string to a variable instead of printing it to > the console? > > What I am after is a facility somewhat like the one used in the Python > example below: > phrase = "The %s in the %s" % ("cat", "hat") > > Evaluating the example above results in the variable 'phrase' taking the > value "The cat in the hat". > > The similarity to the io:format behavior is clear. The Python idiom is > useful, and I have been looking for something > similar in Erlang, without luck. Before I try to concoct such a thing, I > thought I'd ask whether it already exists. > > Thanks, > David > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From richardc@REDACTED Fri Oct 17 16:53:06 2008 From: richardc@REDACTED (Richard Carlsson) Date: Fri, 17 Oct 2008 16:53:06 +0200 Subject: [erlang-questions] Question re io:format and string handling In-Reply-To: <44ed5e0f0810170726o56b0a92asd49ca4e7550db83a@mail.gmail.com> References: <44ed5e0f0810170726o56b0a92asd49ca4e7550db83a@mail.gmail.com> Message-ID: <48F8A6D2.30605@it.uu.se> David Cabana wrote: > Consider the result of evaluating the following in an erl console: > io:format("The ~p in the ~p", ["cat", "hat"]). > > The Python idiom is useful, and I have been looking for something > similar in Erlang, without luck. Before I try to concoct such a thing, > I thought I'd ask whether it already exists. Use the io_lib module instead: Text = io_lib:format("The ~p in the ~p", ["cat", "hat"]). /Richard From ulf.wiger@REDACTED Fri Oct 17 16:57:56 2008 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Fri, 17 Oct 2008 16:57:56 +0200 Subject: [erlang-questions] Question re io:format and string handling In-Reply-To: <3dbc6d1c0810170745p6bc83915r6fa3146ff0ae1b19@mail.gmail.com> References: <44ed5e0f0810170726o56b0a92asd49ca4e7550db83a@mail.gmail.com> <3dbc6d1c0810170745p6bc83915r6fa3146ff0ae1b19@mail.gmail.com> Message-ID: <48F8A7F4.6060206@ericsson.com> Robert Virding skrev: > > - A more direct but less general way is to concatenate the string directly: > > Cat = "cat", > Hat = "hat", > Phrase = "The " ++ Cat ++ " in the " ++ Hat Or, if the string is going to be sent out through a port right away, and you don't care if it isn't flat: Phrase = ["The ", Cat, " in the ", Hat] (The deep string gets flattened when passed through a port. This is quite useful when constructing e.g. a web page or large XML structure.) BR, Ulf W From pguyot@REDACTED Fri Oct 17 17:10:40 2008 From: pguyot@REDACTED (Paul Guyot) Date: Fri, 17 Oct 2008 17:10:40 +0200 Subject: [erlang-questions] Erlang unit testing and continuous integration In-Reply-To: References: Message-ID: > Date: Fri, 17 Oct 2008 15:11:09 +0100 > From: > Subject: [erlang-questions] Erlang unit testing and continuous > integration > Also, are there any options for continuous integration with Erlang? We use continuum with maven-erlang plug-in: http://maven-erlang.sourceforge.net/erlang-plugin/index.html Combined with this patch for eunit: http://support.process-one.net/browse/EUNIT-13 Paul From drcabana@REDACTED Fri Oct 17 17:13:56 2008 From: drcabana@REDACTED (David Cabana) Date: Fri, 17 Oct 2008 11:13:56 -0400 Subject: [erlang-questions] Question re io:format and string handling In-Reply-To: <48F8A7F4.6060206@ericsson.com> References: <44ed5e0f0810170726o56b0a92asd49ca4e7550db83a@mail.gmail.com> <3dbc6d1c0810170745p6bc83915r6fa3146ff0ae1b19@mail.gmail.com> <48F8A7F4.6060206@ericsson.com> Message-ID: <44ed5e0f0810170813p74dadcb8h4618096ad6f87320@mail.gmail.com> Thank you all. That was exactly what this newb want to know. -------------- next part -------------- An HTML attachment was scrubbed... URL: From rick.richardson@REDACTED Fri Oct 17 17:47:30 2008 From: rick.richardson@REDACTED (Rick R) Date: Fri, 17 Oct 2008 11:47:30 -0400 Subject: [erlang-questions] Feedback Request: Nitrogen - A New Web Framework for Erlang In-Reply-To: References: <58B8C11B-38D6-42A0-9E95-C1CD7CBF8F83@gmail.com> Message-ID: <9810b81b0810170847u5f00bb81q943b2bfb742a129c@mail.gmail.com> I agree, jQuery is fantastic and is quickly becoming the de-facto standard js library. Although, if you're going to be switching to Mochiweb, you might look at mochikit too :P On Fri, Oct 17, 2008 at 10:39 AM, Dmitrii Dimandt wrote: > > > > - Prototype/Scriptaculous Integration > > why oh why? :) jQuery is so much better... > > > Where can I dowload it? :) > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- "Have more than thou showest, Speak less than thou knowest, Lend less than thou owest, Ride more than thou goest." -- The Fool to King Lear -------------- next part -------------- An HTML attachment was scrubbed... URL: From pfisher@REDACTED Thu Oct 16 13:45:17 2008 From: pfisher@REDACTED (Paul Fisher) Date: Thu, 16 Oct 2008 06:45:17 -0500 Subject: [erlang-questions] ready_async() before outputv() calling driver_async() completes? In-Reply-To: <20081016072932.GA27066@erix.ericsson.se> References: <48F677EF.7060709@alertlogic.net> <20081016072932.GA27066@erix.ericsson.se> Message-ID: <48F7294D.2080500@alertlogic.net> Raimo Niskanen wrote: > On Wed, Oct 15, 2008 at 06:08:31PM -0500, Paul Fisher wrote: >> Should it be possible for a ready_async() callback to happen before the >> outputv() callback which called driver_async() has returned? I am >> seeing this happen on R12B-2 smp runtime (2 schedulers), w/four (4) >> async threads. > > And even if the SMP emulator does not do it explicitly, > it is always possible for the thread calling outputv() > to get scheduled out between the return from driver_async() > and the return from outputv(), and the asynchronous > thread to get scheduled in, do its thing and call ready_async() > right then. I am talking about SMP with async threads only. The documentation says that the ready_async() callback happens from the emulator thread. "This function is called from the erlang emulator thread, as opposed to the asynchronous function, which is called in some thread (if multithreading is enabled)." All other indications in the documentation make me believe that only one callback from an emulator thread is active in a callback at a time (for each port instance that is). "There will only be one thread at a time calling driver call-backs corresponding to the same port, though." So you are saying that ready_async() is an exception to this? -- paul From n39052@REDACTED Fri Oct 17 18:13:03 2008 From: n39052@REDACTED (Sergey A.) Date: Fri, 17 Oct 2008 09:13:03 -0700 Subject: [erlang-questions] appmon doesn't start Message-ID: <3bff71aa0810170913s21ced169jd535f2f2531f122@mail.gmail.com> Hello. I tried to use appmon (which looks very helpful to overview the structure of running application), but my efforts weren't successful. appmon doesn't start. After the following command: appmon:start() nothing happens. The function just doesn't return control and new windows aren't created. Are there any additional steps needed to get appmon to work? Maybe, it is an Archlinux specific bug. Please tell me, if appmon works fine on your Linux (in this case, what distribution do you use?). I use Erlang R12B.3 from Archlinux repository. Thanks. -- Sergey From dmitriy.kargapolov@REDACTED Fri Oct 17 18:41:23 2008 From: dmitriy.kargapolov@REDACTED (Dmitriy Kargapolov) Date: Fri, 17 Oct 2008 12:41:23 -0400 Subject: [erlang-questions] appmon doesn't start In-Reply-To: <3bff71aa0810170913s21ced169jd535f2f2531f122@mail.gmail.com> References: <3bff71aa0810170913s21ced169jd535f2f2531f122@mail.gmail.com> Message-ID: <63caf42f0810170941n77f6bd2fs48796fdd0ea74738@mail.gmail.com> 1) Does X11 work at all? Try xclock in system shell for example. 2) Does gs work? Try gs:config(gs:create(window,gs:start()),{map,true}). in Erlang shell. On Fri, Oct 17, 2008 at 12:13 PM, Sergey A. wrote: > Hello. > > I tried to use appmon (which looks very helpful to overview the > structure of running application), but my efforts weren't successful. > appmon doesn't start. > > After the following command: > > appmon:start() > > nothing happens. The function just doesn't return control and new > windows aren't created. > > Are there any additional steps needed to get appmon to work? > > Maybe, it is an Archlinux specific bug. Please tell me, if appmon > works fine on your Linux (in this case, what distribution do you > use?). > > I use Erlang R12B.3 from Archlinux repository. > > Thanks. > > -- > Sergey > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From erlang-questions_efine@REDACTED Fri Oct 17 18:41:27 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Fri, 17 Oct 2008 12:41:27 -0400 Subject: [erlang-questions] appmon doesn't start In-Reply-To: <3bff71aa0810170913s21ced169jd535f2f2531f122@mail.gmail.com> References: <3bff71aa0810170913s21ced169jd535f2f2531f122@mail.gmail.com> Message-ID: <6c2563b20810170941g570fdc02ke04a76b9fa8ca27d@mail.gmail.com> Try looking in the erlang-questions archive. I found this link which may be helpful. http://www.erlang.org/pipermail/erlang-questions/2008-September/038512.html On Fri, Oct 17, 2008 at 12:13 PM, Sergey A. wrote: > Hello. > > I tried to use appmon (which looks very helpful to overview the > structure of running application), but my efforts weren't successful. > appmon doesn't start. > > After the following command: > > appmon:start() > > nothing happens. The function just doesn't return control and new > windows aren't created. > > Are there any additional steps needed to get appmon to work? > > Maybe, it is an Archlinux specific bug. Please tell me, if appmon > works fine on your Linux (in this case, what distribution do you > use?). > > I use Erlang R12B.3 from Archlinux repository. > > Thanks. > > -- > Sergey > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From Martin.Logan@REDACTED Fri Oct 17 21:45:40 2008 From: Martin.Logan@REDACTED (Logan, Martin) Date: Fri, 17 Oct 2008 14:45:40 -0500 Subject: [erlang-questions] Inets concurrent limit Message-ID: <1B67010539493A48B777F49CE49F574B30DDAA@chiresexc04.resource.corp.lcl> Does inets have a limit on the number of concurrent requests it can handle both inbound and outbound. On the inbound side when I really ramp up load I see 503 responses quite a bit, I am also seeing sporadic 500's. On the outbound side (this thing I am testing is an http proxy) I am seeing issues with addrinuse, which looks to be an OS issue so I am investigating that as a separate issue. Anyhow, any inets info you can provide would be helpful. Basically I am looking to be able to drive as much traffic though this thing as I can. Cheers, Martin If you are not the intended recipient of this e-mail message, please notify the sender and delete all copies immediately. The sender believes this message and any attachments were sent free of any virus, worm, Trojan horse, and other forms of malicious code. This message and its attachments could have been infected during transmission. The recipient opens any attachments at the recipient's own risk, and in so doing, the recipient accepts full responsibility for such actions and agrees to take protective and remedial action relating to any malicious code. Travelport is not liable for any loss or damage arising from this message or its attachments. -------------- next part -------------- An HTML attachment was scrubbed... URL: From rvirding@REDACTED Fri Oct 17 23:42:05 2008 From: rvirding@REDACTED (Robert Virding) Date: Fri, 17 Oct 2008 23:42:05 +0200 Subject: [erlang-questions] Core Erlang questions In-Reply-To: <48F845FC.6010808@it.uu.se> References: <48F6F27E.9000100@fi.upm.es> <48F7072A.9090004@it.uu.se> <48F7262E.4010903@fi.upm.es> <3dbc6d1c0810160459u510ee29h7030ed8774568d80@mail.gmail.com> <8209f740810161536m2bda0e83wd2d8733fab447b28@mail.gmail.com> <48F845FC.6010808@it.uu.se> Message-ID: <3dbc6d1c0810171442t4c189dd3wbe96e82470e4075@mail.gmail.com> 2008/10/17 Richard Carlsson > Ulf Wiger wrote: > > 2008/10/16 Robert Virding : > >> There is a specific reason for the Erlang compiler to return code like > that. > >> In Erlang the order of evaluation is defined to be left-to-right > > > > Where is this defined? > > > > I believe (too tired to check) that the Barklund spec left the > > evaluation order undefined, with the proviso that no possible > > evaluation order should leave variables unbound when used. > > As far as I can remember, around the time when Barklund wrote that > spec it was decided that Erlang should have a fixed evaluation order, > so that there would never be a situation where a program would behave > slightly different (e.g., a process sending messages in a different > order, or a different exception being thrown) on an alternative > implementation. I think some minor things in the compiler were changed > at that time, to conform to the left-to-right principle. It does > restrict a bit what the compiler can do, though: only safe expressions > (free from side effects and exceptions) can be reordered at all. > Another reason to explicitly define evaluation order is that you also define where variables are visible and who binds them and who tests them. This can get *very* tricky in the general case. Fortunately people usually don't write that tricky and convoluted code. :-) Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: From hokan.stenholm@REDACTED Fri Oct 17 23:55:32 2008 From: hokan.stenholm@REDACTED (=?ISO-8859-1?Q?H=E5kan_Stenholm?=) Date: Fri, 17 Oct 2008 23:55:32 +0200 Subject: [erlang-questions] Question re io:format and string handling In-Reply-To: <3dbc6d1c0810170745p6bc83915r6fa3146ff0ae1b19@mail.gmail.com> References: <44ed5e0f0810170726o56b0a92asd49ca4e7550db83a@mail.gmail.com> <3dbc6d1c0810170745p6bc83915r6fa3146ff0ae1b19@mail.gmail.com> Message-ID: <48F909D4.2040402@bredband.net> Robert Virding wrote: > There is nothing exactly like what Python does. There are options though: > > - You can use io_lib:format which returns a, possibly deep, list of > characters which is the the representation of format string and the > arguments. So: > > Phrase = io_lib:format("The ~p in the ~p", ["cat", "hat"]) > > Depending on what you are going to do, you may have to apply lists:flatten > to the string to get a flat list. io_lib:format has the same format options > as io:format, and is in fact called by io:format to generate the output > string. > > - A more direct but less general way is to concatenate the string directly: > > Cat = "cat", > Hat = "hat", > Phrase = "The " ++ Cat ++ " in the " ++ Hat > > Another minor variation that avoids repeated appends (++) which may be useful if the initial texts are large to avoid a costly O(N^2) append (lists:flatten/1 is O(N log N)): Cat = "cat", Hat = "hat", Phrase = lists:flatten(["The ", Cat, " in the ", Hat]) > >From your question I would guess it is the 1st version you want, > > Robert > > 2008/10/17 David Cabana > > >> Consider the result of evaluating the following in an erl console: >> io:format("The ~p in the ~p", ["cat", "hat"]). >> >> The strings "cat" and "hat" are substituted for the occurrences of ~p, and >> a string is printed to the console. >> Is there a way to bind that string to a variable instead of printing it to >> the console? >> >> What I am after is a facility somewhat like the one used in the Python >> example below: >> phrase = "The %s in the %s" % ("cat", "hat") >> >> Evaluating the example above results in the variable 'phrase' taking the >> value "The cat in the hat". >> >> The similarity to the io:format behavior is clear. The Python idiom is >> useful, and I have been looking for something >> similar in Erlang, without luck. Before I try to concoct such a thing, I >> thought I'd ask whether it already exists. >> >> Thanks, >> David >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> >> > > > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From greg.burri@REDACTED Sat Oct 18 00:06:07 2008 From: greg.burri@REDACTED (Greg Burri) Date: Sat, 18 Oct 2008 00:06:07 +0200 Subject: [erlang-questions] Feedback Request: Nitrogen - A New Web Framework for Erlang In-Reply-To: References: <58B8C11B-38D6-42A0-9E95-C1CD7CBF8F83@gmail.com> Message-ID: <60ed8a460810171506u3c26a83ci315e21627de94704@mail.gmail.com> +1 for JQuery !! /Greg On Fri, Oct 17, 2008 at 4:39 PM, Dmitrii Dimandt wrote: >> >> - Prototype/Scriptaculous Integration > > why oh why? :) jQuery is so much better... > > > Where can I dowload it? :) > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From marcsugiyama@REDACTED Sat Oct 18 00:34:33 2008 From: marcsugiyama@REDACTED (Marc Sugiyama) Date: Fri, 17 Oct 2008 15:34:33 -0700 Subject: [erlang-questions] tcp active mode connection with http packet sometimes gives tcp packets? Message-ID: We are using a locally modified mochiweb that uses active mode (active, true). Mochiweb uses the http packet mode. Occasionally, the server is getting a "tcp" packet instead of an "http" packet. The tcp packet contains the request line and headers. One problem, which we already fixed, is that we were setting active mode true and http packet mode in two different places of the code. Moving the two together (either in the socket options for the listener socket, or after the socket is accepted) reduced the frequency of the problem, but we're still seeing "tcp" packets on occasion. This occurs in both R12B3 and R12B4 on MacOSX and Linux. Has anyone else seen a problem like this? Marc -------------- next part -------------- An HTML attachment was scrubbed... URL: From chsu79@REDACTED Sat Oct 18 00:50:03 2008 From: chsu79@REDACTED (Christian) Date: Sat, 18 Oct 2008 00:50:03 +0200 Subject: [erlang-questions] Case-insensitive matching in mnesia and erlang In-Reply-To: <48F88DAA.1030001@yahoo.com> References: <48F88DAA.1030001@yahoo.com> Message-ID: You convert your key to either all uppercase (or lowercase) on inserting the record, then you do the same conversion on the key used on lookup. This is the faster way. Not the fastest. > I had the following question - I'm storing string data in an mnesia > database as either a list of integers or as binaries. I want to find > records using case-insensitive matching against this field. How would I > use mnesia:select to do this? Do I have to explicitly retrieve each > record and convert the field and seach key to lower case myself and > compare? Is there a faster way? > > /Ashok > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From goofyheadedpunk@REDACTED Sat Oct 18 00:50:01 2008 From: goofyheadedpunk@REDACTED (Brian Troutwine) Date: Fri, 17 Oct 2008 15:50:01 -0700 Subject: [erlang-questions] Restrict logging to stdio. Message-ID: <971980cc0810171550t566d4f0ga2677d58142a43ff@mail.gmail.com> Hello all, I'd like to not allow any sort of logging output to the erlang shell, which is to say I would like no reports of any sort (error or otherwise) sent to stdio. Here's the config I thought would do the trick: [{sasl, [{sasl_error_logger, false}, {error_logger_mf_dir,"/home/olorin/logs"}, {error_logger_mf_maxbytes,10485760}, % 10 MB {error_logger_mf_maxfiles, 2}] }]. On further inspection, it only restricts supervisor, crash and progress reports. How can I configure sasl to log only to files for all report types? -- Brian From erlang-questions_efine@REDACTED Sat Oct 18 00:53:26 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Fri, 17 Oct 2008 18:53:26 -0400 Subject: [erlang-questions] Inets concurrent limit In-Reply-To: <1B67010539493A48B777F49CE49F574B30DDAA@chiresexc04.resource.corp.lcl> References: <1B67010539493A48B777F49CE49F574B30DDAA@chiresexc04.resource.corp.lcl> Message-ID: <6c2563b20810171553g54553d64mb0da6172f35099a9@mail.gmail.com> Martin, I wonder if you are running into the TCP/IP ephemeral port starvation problem? There's more information about this (and how to reduce problems due to it) in a post I wrote a little while ago: http://www.erlang.org/pipermail/erlang-questions/2008-September/038154.html Hope this helps. Regards, Edwin 2008/10/17 Logan, Martin > Does inets have a limit on the number of concurrent requests it can > handle both inbound and outbound. On the inbound side when I really ramp up > load I see 503 responses quite a bit, I am also seeing sporadic 500's. On > the outbound side (this thing I am testing is an http proxy) I am seeing > issues with addrinuse, which looks to be an OS issue so I am investigating > that as a separate issue. Anyhow, any inets info you can provide would be > helpful. Basically I am looking to be able to drive as much traffic though > this thing as I can. > > > > Cheers, > > Martin > > If you are not the intended recipient of this e-mail message, please notify the sender > and delete all copies immediately. The sender believes this message and any attachments > were sent free of any virus, worm, Trojan horse, and other forms of malicious code. > This message and its attachments could have been infected during transmission. The > recipient opens any attachments at the recipient's own risk, and in so doing, the > recipient accepts full responsibility for such actions and agrees to take protective > and remedial action relating to any malicious code. Travelport is not liable for any > loss or damage arising from this message or its attachments. > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From marcsugiyama@REDACTED Sat Oct 18 04:03:29 2008 From: marcsugiyama@REDACTED (Marc Sugiyama) Date: Fri, 17 Oct 2008 19:03:29 -0700 Subject: [erlang-questions] tcp active mode connection with http packet sometimes gives tcp packets? Message-ID: > We are using a locally modified mochiweb that uses active mode > (active, true). Mochiweb uses the http packet mode. [...] I'm going to answer my own question. I think I've tracked down the problem. What's happening is that after reading the header mochiweb puts the socket in raw mode (for the web application to read data). While the socket is in raw mode, we're getting another http request, which ends up being fed into mochiweb's http receive loop as tcp rather than http packets. This likely isn't a problem with passive mode, since Erlang won't interpret the tcp data until we explicitly read data. Marc From bob@REDACTED Sat Oct 18 04:51:02 2008 From: bob@REDACTED (Bob Ippolito) Date: Fri, 17 Oct 2008 19:51:02 -0700 Subject: [erlang-questions] tcp active mode connection with http packet sometimes gives tcp packets? In-Reply-To: References: Message-ID: <6a36e7290810171951q23ea4e63o9e047dbe3d82cfe@mail.gmail.com> On Fri, Oct 17, 2008 at 7:03 PM, Marc Sugiyama wrote: >> We are using a locally modified mochiweb that uses active mode >> (active, true). Mochiweb uses the http packet mode. > [...] > > I'm going to answer my own question. > > I think I've tracked down the problem. What's happening is that after > reading the header > mochiweb puts the socket in raw mode (for the web application to read > data). While the > socket is in raw mode, we're getting another http request, which ends > up being fed into > mochiweb's http receive loop as tcp rather than http packets. > > This likely isn't a problem with passive mode, since Erlang won't > interpret the tcp data until > we explicitly read data. Out of curiosity, why have you decided to use active mode? -bob From cktgatb@REDACTED Sat Oct 18 10:19:20 2008 From: cktgatb@REDACTED (deepblue_other) Date: Sat, 18 Oct 2008 01:19:20 -0700 (PDT) Subject: [erlang-questions] small ETS wierdness... Message-ID: <20045004.post@talk.nabble.com> hello... so this is pretty minor yet is slightly pissing me off... ets:new(tableName,[]) creates the table with name tableName... why in all examples people use the ID returned by this func, instead of using the tableName as a reference in other ops. Its their choice, but when I try to use tableName in for example ets:info(tableName) it tells me its undefined, and all the other ets: functions also fail with badArg when I use the tableName atom instead of the table ID returned from ets:new(). same thing is not an issue with dets: strange... thanks -- View this message in context: http://www.nabble.com/small-ETS-wierdness...-tp20045004p20045004.html Sent from the Erlang Questions mailing list archive at Nabble.com. From dmitriid@REDACTED Sat Oct 18 10:22:33 2008 From: dmitriid@REDACTED (Dmitrii Dimandt) Date: Sat, 18 Oct 2008 11:22:33 +0300 Subject: [erlang-questions] Feedback Request: Nitrogen - A New Web Framework for Erlang In-Reply-To: <60ed8a460810171506u3c26a83ci315e21627de94704@mail.gmail.com> References: <58B8C11B-38D6-42A0-9E95-C1CD7CBF8F83@gmail.com> <60ed8a460810171506u3c26a83ci315e21627de94704@mail.gmail.com> Message-ID: <4D51B4A0-8D4F-46A8-AF7B-89808070F852@gmail.com> It appears that I've started a holy war of frameworks over frameworks :) Actually, I don't really think that tight integration of a particular js-framework into a server-side framework is an obstacle to using anything you want. My own (albeit rather short) encounter with RoR left me with an impression that I still wouldn't use the built-in calls to js-code (:hide etc), because there are suited for simple cases. Once you start building something with monsters like qooxdoo, ext or backbase, you quickly forget all the integration and either start coding everything by hand or come up with a DSL of your own :) I woould still vote for jQuery however :))) On Oct 18, 2008, at 1:06 AM, Greg Burri wrote: > +1 for JQuery !! > > /Greg > > On Fri, Oct 17, 2008 at 4:39 PM, Dmitrii Dimandt > wrote: >>> >>> - Prototype/Scriptaculous Integration >> >> why oh why? :) jQuery is so much better... >> >> >> Where can I dowload it? :) >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> From bob@REDACTED Sat Oct 18 11:29:00 2008 From: bob@REDACTED (Bob Ippolito) Date: Sat, 18 Oct 2008 02:29:00 -0700 Subject: [erlang-questions] small ETS wierdness... In-Reply-To: <20045004.post@talk.nabble.com> References: <20045004.post@talk.nabble.com> Message-ID: <6a36e7290810180229g2b570d6bgece34dbc7cd936c1@mail.gmail.com> Take a closer look at the documentation for ets:new/2 Particularly these lines (my emphasis): The parameter Options is a list of atoms which specifies table type, access rights, key position and if the table is named or not. If one or more options are left out, the default values are used. This means that not specifying any options ([]) is the same as specifying ***[set,protected,{keypos,1}]***. named_table ***If*** this option is present, the name Name is associated with the table identifier. The name can then be used instead of the table identifier in subsequent operations. On Sat, Oct 18, 2008 at 1:19 AM, deepblue_other wrote: > > hello... > so this is pretty minor yet is slightly pissing me off... > ets:new(tableName,[]) creates the table with name tableName... why in all > examples people use the ID returned by this func, instead of using the > tableName as a reference in other ops. Its their choice, but when I try to > use tableName in for example ets:info(tableName) it tells me its undefined, > and all the other ets: functions also fail with badArg when I use the > tableName atom instead of the table ID returned from ets:new(). > > same thing is not an issue with dets: > strange... > thanks > -- > View this message in context: http://www.nabble.com/small-ETS-wierdness...-tp20045004p20045004.html > Sent from the Erlang Questions mailing list archive at Nabble.com. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From jesper.louis.andersen@REDACTED Sat Oct 18 11:57:17 2008 From: jesper.louis.andersen@REDACTED (jesper.louis.andersen@REDACTED) Date: Sat, 18 Oct 2008 02:57:17 -0700 Subject: [erlang-questions] small ETS wierdness... Message-ID: <000e0cd1e0ba6a7f560459841b7a@google.com> On Oct 18, 2008 11:29am, Bob Ippolito wrote: > Take a closer look at the documentation for ets:new/2 I'll just add a hint for reference: erl(1) takes a -man parameter, so you can just write 'erl -man ets' to get yourself into $PAGER with the documentation. This is mighty effective when having to look up documentation. Beware, that Erlang has a number of inconsistencies in the libraries. This is probably due to the way Erlang was developed over time. Hence, one must be extremely careful and read the documentation before jumping to conclusions. -------------- next part -------------- An HTML attachment was scrubbed... URL: From twoggle@REDACTED Sat Oct 18 11:57:59 2008 From: twoggle@REDACTED (Tim Fletcher) Date: Sat, 18 Oct 2008 02:57:59 -0700 (PDT) Subject: [erlang-questions] os:cmd/1 with return code In-Reply-To: <740c3aec0810170424r4c60458cpb750fa7d8f7470aa@mail.gmail.com> References: <740c3aec0810170424r4c60458cpb750fa7d8f7470aa@mail.gmail.com> Message-ID: > I've been trying to implement and os:cmd/1 variant that also returns > the status code of the executed command. But it proved to be > exceedingly difficult. There's an example of that in eunit: http://svn.process-one.net/contribs/trunk/eunit/src/eunit_lib.erl From cktgatb@REDACTED Sat Oct 18 12:06:32 2008 From: cktgatb@REDACTED (deepblue_other) Date: Sat, 18 Oct 2008 03:06:32 -0700 (PDT) Subject: [erlang-questions] small ETS wierdness... In-Reply-To: <6a36e7290810180229g2b570d6bgece34dbc7cd936c1@mail.gmail.com> References: <20045004.post@talk.nabble.com> <6a36e7290810180229g2b570d6bgece34dbc7cd936c1@mail.gmail.com> Message-ID: <20045656.post@talk.nabble.com> ah, I see thank you. I've read this line, and have it in my notes, but have not thought about it (what is the point of having it in my notes then ;) ). best Bob Ippolito wrote: > > Take a closer look at the documentation for ets:new/2 > > Particularly these lines (my emphasis): > The parameter Options is a list of atoms which specifies table type, > access rights, key position and if the table is named or not. If one > or more options are left out, the default values are used. This means > that not specifying any options ([]) is the same as specifying > ***[set,protected,{keypos,1}]***. > > named_table ***If*** this option is present, the name Name is > associated with the table identifier. The name can then be used > instead of the table identifier in subsequent operations. > > On Sat, Oct 18, 2008 at 1:19 AM, deepblue_other wrote: >> >> hello... >> so this is pretty minor yet is slightly pissing me off... >> ets:new(tableName,[]) creates the table with name tableName... why in all >> examples people use the ID returned by this func, instead of using the >> tableName as a reference in other ops. Its their choice, but when I try >> to >> use tableName in for example ets:info(tableName) it tells me its >> undefined, >> and all the other ets: functions also fail with badArg when I use the >> tableName atom instead of the table ID returned from ets:new(). >> >> same thing is not an issue with dets: >> strange... >> thanks >> -- >> View this message in context: >> http://www.nabble.com/small-ETS-wierdness...-tp20045004p20045004.html >> Sent from the Erlang Questions mailing list archive at Nabble.com. >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > -- View this message in context: http://www.nabble.com/small-ETS-wierdness...-tp20045004p20045656.html Sent from the Erlang Questions mailing list archive at Nabble.com. From bjourne@REDACTED Sat Oct 18 16:48:19 2008 From: bjourne@REDACTED (=?ISO-8859-1?Q?BJ=F6rn_Lindqvist?=) Date: Sat, 18 Oct 2008 14:48:19 +0000 Subject: [erlang-questions] os:cmd/1 with return code In-Reply-To: References: <740c3aec0810170424r4c60458cpb750fa7d8f7470aa@mail.gmail.com> Message-ID: <740c3aec0810180748r194564afk6f7dbf51673f223e@mail.gmail.com> 2008/10/18 Tim Fletcher : >> I've been trying to implement and os:cmd/1 variant that also returns >> the status code of the executed command. But it proved to be >> exceedingly difficult. > > There's an example of that in eunit: > > http://svn.process-one.net/contribs/trunk/eunit/src/eunit_lib.erl That function does not run the command in a shell. So, for example, eunit_lib:command("exit 123") will not work. -- mvh Bj?rn From richardc@REDACTED Sat Oct 18 17:38:57 2008 From: richardc@REDACTED (Richard Carlsson) Date: Sat, 18 Oct 2008 17:38:57 +0200 Subject: [erlang-questions] os:cmd/1 with return code In-Reply-To: <740c3aec0810180748r194564afk6f7dbf51673f223e@mail.gmail.com> References: <740c3aec0810170424r4c60458cpb750fa7d8f7470aa@mail.gmail.com> <740c3aec0810180748r194564afk6f7dbf51673f223e@mail.gmail.com> Message-ID: <48FA0311.5040300@it.uu.se> BJ?rn Lindqvist wrote: > 2008/10/18 Tim Fletcher : >>> I've been trying to implement and os:cmd/1 variant that also returns >>> the status code of the executed command. But it proved to be >>> exceedingly difficult. >> There's an example of that in eunit: >> >> http://svn.process-one.net/contribs/trunk/eunit/src/eunit_lib.erl > > That function does not run the command in a shell. So, for example, > eunit_lib:command("exit 123") will not work. _Should_ it run in a shell? I didn't find it obvious what a command that "runs an operating system command" ought to do. If someone can lay down the law here, I'd be grateful. I mean, it can obviously be handy to be able to execute any shell command directly, but I guessed that it might also be _not_ what one always wants. And of course, the code must check then which platform it is on, so it can run the right shell (for some definition of right). /Richard -- "Having users is like optimization: the wise course is to delay it." -- Paul Graham From bjourne@REDACTED Sat Oct 18 23:38:14 2008 From: bjourne@REDACTED (=?ISO-8859-1?Q?BJ=F6rn_Lindqvist?=) Date: Sat, 18 Oct 2008 21:38:14 +0000 Subject: [erlang-questions] os:cmd/1 with return code In-Reply-To: <48FA0311.5040300@it.uu.se> References: <740c3aec0810170424r4c60458cpb750fa7d8f7470aa@mail.gmail.com> <740c3aec0810180748r194564afk6f7dbf51673f223e@mail.gmail.com> <48FA0311.5040300@it.uu.se> Message-ID: <740c3aec0810181438g69b8f2a9pcb054e33b4b9ee64@mail.gmail.com> 2008/10/18 Richard Carlsson : > BJ?rn Lindqvist wrote: >> 2008/10/18 Tim Fletcher : >>>> I've been trying to implement and os:cmd/1 variant that also returns >>>> the status code of the executed command. But it proved to be >>>> exceedingly difficult. >>> There's an example of that in eunit: >>> >>> http://svn.process-one.net/contribs/trunk/eunit/src/eunit_lib.erl >> >> That function does not run the command in a shell. So, for example, >> eunit_lib:command("exit 123") will not work. > > _Should_ it run in a shell? I didn't find it obvious what a command > that "runs an operating system command" ought to do. If someone can > lay down the law here, I'd be grateful. I mean, it can obviously be > handy to be able to execute any shell command directly, but I guessed > that it might also be _not_ what one always wants. And of course, the > code must check then which platform it is on, so it can run the right > shell (for some definition of right). Yes it should. os:cmd/1 mimics the system() C library function and the man page says that it "Executes Command in a command shell." Unfortunately since os:cmd/1 doesn't actually use the system() call, its semantics are off in corner cases. -- mvh Bj?rn From msciab@REDACTED Sat Oct 18 23:48:23 2008 From: msciab@REDACTED (Michele Sciabarra) Date: Sat, 18 Oct 2008 22:48:23 +0100 Subject: [erlang-questions] Configuring an erlang cluster In-Reply-To: References: <9b08084c0810140831s5d8e1828x1e9a836b17951fc5@mail.gmail.com> <87vdvv6tkb.fsf@sterlett.hq.kred> <9b08084c0810141257o651f363fx82dddfe0749cbe97@mail.gmail.com> <95be1d3b0810142322o684e4ac2xa148dfc8f1b1b99f@mail.gmail.com> Message-ID: <48FA59A7.5060509@eprometeus.com> I am trying to set up an erlang cluster. I am trying to put in a cluster mochiweb. What I want to do is to have a master boot server, and slave nodes pick their code from the master. I have followed Joel Reymond tutorial in his blog (http://www.wagerlabs.com/blog/2007/10/setting-up-erla.html) It works when I start a second node in the same machine. It does not work when I start a second node in a remote machine. I have done a .rel and generated a boot script with the local option, and I am also using cean. On the master I run (boot_server is a simple module that calls erl_boot_server:start(...)) /cean/start.sh -name e1 -setcookie xxx -s boot_server On the slaves I run /cean/start.sh \ -name e2 -id e2 -setcookie xxx \ -loader inet -hosts 10.0.1.1 -boot /cean/erlang/boot/demoweb -mode embedded I get: ** Bad path can't read /cean/erlang/boot ** Bad path can't read /cean/erlang/lib/mochiweb-0.01/ebin ** Bad path can't read /cean/erlang/lib/demoweb-0.01/ebin Note that running those commands in the same node works, even using a different erlang installation, not having mochiweb and demoweb installed. I was expectiing that the inets loader is able to fetch beam code from the boot server, but this seems not to be the case. I am afraid I am missing something of basic and fundamental, but reading the OTP documentation I was unable to figure out how this should work. Have I to copy all the files in the slave machine? What is the purpose of the systools:make_tar ? Should instead generate a tar to allow the boot server to distribuite the application? A normal j2ee based cluster is usually able to copy a war file from the master to the slave nodes automatically. I was expecting something similar. Any help will be appreciated. From webaccounts@REDACTED Sat Oct 18 12:32:32 2008 From: webaccounts@REDACTED (Dan Rubino) Date: Sat, 18 Oct 2008 11:32:32 +0100 Subject: [erlang-questions] Erlang unit testing and continuous integration In-Reply-To: References: Message-ID: <1224325952.6216.10.camel@linux-box> Hi Paul, That's exactly what I was hoping for! Thanks. Just installed it all and converted my project to the maven format. Everything builds, tests run and docs generated (great)....but when I run 'mvn package' it creates the project xyz.zip except I don't see the boot files generated with it? (only /ebin /src /doc /include) Am I missing a step here? Normally I would run something like: systools:make_script("release-1.0"). Followed by: erl -boot release-1.0 To start the application and all its dependencies. If I could get Maven to take care of this step that would be fantastic. I cant see any other goals listed which may take care of this. Any thoughts? Many Thanks, Dan On Fri, 2008-10-17 at 17:10 +0200, Paul Guyot wrote: > > Date: Fri, 17 Oct 2008 15:11:09 +0100 > > From: > > Subject: [erlang-questions] Erlang unit testing and continuous > > integration > > > > Also, are there any options for continuous integration with Erlang? > > We use continuum with maven-erlang plug-in: > http://maven-erlang.sourceforge.net/erlang-plugin/index.html > > Combined with this patch for eunit: > http://support.process-one.net/browse/EUNIT-13 > > Paul > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From tty.erlang@REDACTED Sun Oct 19 06:07:57 2008 From: tty.erlang@REDACTED (t ty) Date: Sun, 19 Oct 2008 00:07:57 -0400 Subject: [erlang-questions] sqlite Erlang binding Message-ID: <290b3ba10810182107w2d504ab3waadfb1a801de8967@mail.gmail.com> Put it on github. git://github.com/ttyerl/sqlite-erlang.git Have fun, t From gleber.p@REDACTED Sun Oct 19 10:06:59 2008 From: gleber.p@REDACTED (Gleb Peregud) Date: Sun, 19 Oct 2008 08:36:59 +0030 Subject: [erlang-questions] Case-insensitive matching in mnesia and erlang In-Reply-To: References: <48F88DAA.1030001@yahoo.com> Message-ID: <14f0e3620810190106j3b0411e3n1370ad166db8a90@mail.gmail.com> May you share with us the fastest way? :) On 10/17/08, Christian wrote: > You convert your key to either all uppercase (or lowercase) on > inserting the record, then you do the same conversion on the key used > on lookup. This is the faster way. Not the fastest. > >> I had the following question - I'm storing string data in an mnesia >> database as either a list of integers or as binaries. I want to find >> records using case-insensitive matching against this field. How would I >> use mnesia:select to do this? Do I have to explicitly retrieve each >> record and convert the field and seach key to lower case myself and >> compare? Is there a faster way? >> >> /Ashok >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- Sent from Gmail for mobile | mobile.google.com Gleb Peregud http://gleber.pl/ Every minute is to be grasped. Time waits for nobody. -- Inscription on a Zen Gong From michael.regen@REDACTED Sun Oct 19 13:30:54 2008 From: michael.regen@REDACTED (Michael Regen) Date: Sun, 19 Oct 2008 13:30:54 +0200 Subject: [erlang-questions] How to build Erlang with libcmt (/MT) under windows? In-Reply-To: <6672d0160810170212n5eefd0a6o3e2e7a41fc0c6483@mail.gmail.com> References: <9b59d0270810051004u391f464k112d5175573a95f4@mail.gmail.com> <6672d0160810170212n5eefd0a6o3e2e7a41fc0c6483@mail.gmail.com> Message-ID: <9b59d0270810190430h6bf221ai4264b2dd93dd2484@mail.gmail.com> Hi Bj?rn, I can understand that you do not have intentions supporting it in the main distribution. It simply does not make sense there. An installer is needed in any case which can take care of the CRT dependencies. But may I ask you - can you give me a hint where Microsoft discourages the use of a statically bound CRT? Or give me a hint why that would lead to memory leaks? I would really like to understand the problem, investigated since I read your statements and so far was unsuccessful finding any hints. The reason why I am asking is because I was thinking about some kind of SAE revival. I wrote some tests and I am already able to run Erlang together with many kinds of Erlang applications in one single .exe without patching the emulator. But of course this does not make sense if there are dependencies to one of the bazillion msvcr??.dlls out there. Furthermore more recent CRTs cannot be loaded with LoadLibrary or similar mechanisms and my solution needs that. In case someone is curious: I kind of rewrote erl.c, erlexec.c and win_erlexec.c. It hooks some of its own API calls (e.g. file I/O) and serves files (e.g. .beam, .dll, etc.) out of a zip file attached to the .exe. In some aspects it is similar to py2exe. I am pretty sure such a solution would be nice to have. Not for your super stable high-performance server applications but for lots of smaller tools. I will publish the code as soon as it is out of pre-alpha - if the concept makes sense. Thank you! Regards, Michael On Fri, Oct 17, 2008 at 11:12 AM, Bjorn Gustavsson wrote: > 2008/10/5 Michael Regen > >> Hi, >> >> Does anyone a little bit more experienced with the Erlang build mechanism >> know how to compile and link Erlang with libcmt instead of msvcrt? >> The default mechanism builds Erlang with the /MD switch which means the C >> standard libraries are accessed as threaded dll MSVCR??.DLL. This also means >> you cannot simply copy Erlang to another computer as long as the correct C >> runtime is not installed there. >> >> I am trying to figure out how to statically bind the libcmt library. >> Normally you do this by using the /MT switch. >> > > Sorry, but we have no intention of supporting that. The reason is that > Microsoft strongly discourages using the statically linked run-time library > in programs > that loads DLLs. Having a MT-linked emulator will lead to memory leaks. > > /Bjorn > -- > Bj?rn Gustavsson, Erlang/OTP, Ericsson AB > -------------- next part -------------- An HTML attachment was scrubbed... URL: From pguyot@REDACTED Sun Oct 19 18:09:31 2008 From: pguyot@REDACTED (Paul Guyot) Date: Sun, 19 Oct 2008 18:09:31 +0200 Subject: [erlang-questions] Erlang unit testing and continuous integration In-Reply-To: <1224325952.6216.10.camel@linux-box> References: <1224325952.6216.10.camel@linux-box> Message-ID: Le 18 oct. 08 ? 12:32, Dan Rubino a ?crit : > Hi Paul, > > That's exactly what I was hoping for! Thanks. > > Just installed it all and converted my project to the maven format. > > Everything builds, tests run and docs generated (great)....but when I > run 'mvn package' it creates the project xyz.zip except I don't see > the > boot files generated with it? (only /ebin /src /doc /include) > > Am I missing a step here? Normally I would run something like: > systools:make_script("release-1.0"). > > Followed by: > > erl -boot release-1.0 > > To start the application and all its dependencies. > > If I could get Maven to take care of this step that would be > fantastic. > I cant see any other goals listed which may take care of this. Actually, the maven plugin only handled Erlang OTP applications (packaging: erlang-otp). Each application must have its own pom.xml, and dependencies between applications are declared with lines like: com.semiocast.lib aspell 0.1 erlang-otp com.semiocast.lib sqlite 0.1 erlang-otp ... Our OTP release was generated by a custom pom.xml with a Makefile, but I cleaned that up and implemented everything in the maven plug- in. You just need to update the plug-in to get these new features. Each release must have its own pom.xml as well and are packaged as "erlang-rel". You must declare the applications composing the release with the dependencies XML element and the applications must be installed in your repository (with mvn install). The release pom.xml typically goes like this: erlang-rel ... ... net.sf.maven-erlang erlang-plugin true true true true semiocast {variables, [{"TARGET", "$ {project.build.directory}/lib"}]} releaseName is the name of your .rel file (without the .rel). It should be in src/main/erlang/ subdirectory. The makeScriptOptions can be used to pass options such as where the applications are. '{variables, [{"TARGET", "${project.build.directory}/lib"}]}' is a convenient default value, since the maven plug-in will unzip your dependencies (your applications) in ${project.build.directory}/lib. The dialyzer stuff here allows you to run dialyzer on the whole release (and therefore check inter-application calls). To run the application, you only need to do: erl -boot_var TARGET lib -boot releaseName Paul From dot@REDACTED Wed Oct 15 13:16:18 2008 From: dot@REDACTED (Tony Finch) Date: Wed, 15 Oct 2008 12:16:18 +0100 Subject: [erlang-questions] OTP float error on ARM In-Reply-To: References: Message-ID: On Wed, 15 Oct 2008, WS Dao wrote: > I cross-compiled OTP R12B4 for my ARM9 platform (S3C2410, kernel 2.4.18) > When I run erl on arm, float error occurs: > # ./erl > Eshell V5.6.4 (abort with ^G) > 1> 3+5. > 8 > 2> 3.0. > 0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005307579804 > 3> 3.0+4.0. > 0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000531405562 > 4> > > My toolchain is gcc 3.4.5. I'd wrote a c test program and cross-compile it, > no float problems found. > > Any suggestion? I wonder if this is to do with the ARM FPA middle endian double precision floating point memory layout? Tony. -- f.anthony.n.finch http://dotat.at/ FISHER: CYCLONIC BECOMING WEST 5 OR 6, OCCASIONALLY 7. MODERATE OR ROUGH. RAIN THEN SHOWERS. MODERATE OR GOOD. From erlang-questions_efine@REDACTED Mon Oct 20 06:56:03 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Mon, 20 Oct 2008 00:56:03 -0400 Subject: [erlang-questions] List to proplist? Message-ID: <6c2563b20810192156i7516e69aqb4d0eda2e1ee98d9@mail.gmail.com> Hi all, I was wondering what the most elegant and efficient way would be to take a list containing an even number of elements and convert it into a proplist, using only Erlang library functions? This is really a learning thing for me (how to think in Erlang) rather than an urgent question, but it is based on a real need (having a flat list of key/value pairs and wanting it in proplist form). For example, the function would do this: f([1,2,3,4,5,6,7,8]) -> [{1,2},{3,4},{5,6},{7,8}]. I know it would be easy to write a pattern-matching-style function, but I wanted to do it without having to define a new function, in as compact a way as possible while still keeping it reasonably efficient. I thought there might be a proplists:from_list/1 function, but I couldn't find one. The best I could come up with is this (it's ok to assume that there will be an even number of elements in L): element(1, lists:mapfoldl(fun(_,[X,Y|T]) -> {{X,Y}, T} end, L, lists:seq(1, length(L) div 2))). It seems like a bit of a perversion of the idea of foldl, being used to "unaccumulate". I'm also not really happy with having to generate another list using lists:seq, especially if L is long, but I can't think of a better way to drive the foldl part with the right number of elements. I thought of splitting L in half for this, but what if L has large elements? Wouldn't I be using much more memory than a simple list of integers, or would it internally be a list of pointers to half of the elements of L? Actually, that would almost always be bigger than a list of integers on a 64-bit system... Is there a better way to do this given the stated constraints? If so, I'd appreciate it if you'd share it with me. Regards, Edwin Fine -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf@REDACTED Mon Oct 20 08:27:30 2008 From: ulf@REDACTED (Ulf Wiger) Date: Mon, 20 Oct 2008 08:27:30 +0200 Subject: [erlang-questions] List to proplist? In-Reply-To: <6c2563b20810192156i7516e69aqb4d0eda2e1ee98d9@mail.gmail.com> References: <6c2563b20810192156i7516e69aqb4d0eda2e1ee98d9@mail.gmail.com> Message-ID: <8209f740810192327ue8af7a0y5ca21b254ff8b7c4@mail.gmail.com> Well, the obvious way to do it ought to be: to_proplist([K,V | T]) -> [{K,V} | to_proplist(T)]; to_proplist([]) -> []. BR, Ulf W 2008/10/20 Edwin Fine : > Hi all, > > I was wondering what the most elegant and efficient way would be to take a > list containing an even number of elements and convert it into a proplist, > using only Erlang library functions? This is really a learning thing for me > (how to think in Erlang) rather than an urgent question, but it is based on > a real need (having a flat list of key/value pairs and wanting it in > proplist form). > > For example, the function would do this: f([1,2,3,4,5,6,7,8]) -> > [{1,2},{3,4},{5,6},{7,8}]. > > I know it would be easy to write a pattern-matching-style function, but I > wanted to do it without having to define a new function, in as compact a way > as possible while still keeping it reasonably efficient. I thought there > might be a proplists:from_list/1 function, but I couldn't find one. > > The best I could come up with is this (it's ok to assume that there will be > an even number of elements in L): > > element(1, lists:mapfoldl(fun(_,[X,Y|T]) -> {{X,Y}, T} end, L, > lists:seq(1, length(L) div 2))). > > It seems like a bit of a perversion of the idea of foldl, being used to > "unaccumulate". I'm also not really happy with having to generate another > list using lists:seq, especially if L is long, but I can't think of a better > way to drive the foldl part with the right number of elements. I thought of > splitting L in half for this, but what if L has large elements? Wouldn't I > be using much more memory than a simple list of integers, or would it > internally be a list of pointers to half of the elements of L? Actually, > that would almost always be bigger than a list of integers on a 64-bit > system... > > Is there a better way to do this given the stated constraints? If so, I'd > appreciate it if you'd share it with me. > > Regards, > Edwin Fine > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From ulf@REDACTED Mon Oct 20 08:51:51 2008 From: ulf@REDACTED (Ulf Wiger) Date: Mon, 20 Oct 2008 08:51:51 +0200 Subject: [erlang-questions] List to proplist? In-Reply-To: <8209f740810192327ue8af7a0y5ca21b254ff8b7c4@mail.gmail.com> References: <6c2563b20810192156i7516e69aqb4d0eda2e1ee98d9@mail.gmail.com> <8209f740810192327ue8af7a0y5ca21b254ff8b7c4@mail.gmail.com> Message-ID: <8209f740810192351m574b0cdcg2836c18e450a8833@mail.gmail.com> Ok, so you said you already knew that. (: - I didn't read too carefully there). So, make it a recursive fun then, if the main problem is that you don't want to create a new function: F = fun([K,V|T], Recurse) -> [{K,V} | Recurse(T)]; ([], _) -> [] end, F(L, F). I think most other solutions will be contrived and inefficient. BR, Ulf W 2008/10/20 Ulf Wiger : > Well, the obvious way to do it ought to be: > > to_proplist([K,V | T]) -> [{K,V} | to_proplist(T)]; > to_proplist([]) -> []. > > BR, > Ulf W > > 2008/10/20 Edwin Fine : >> Hi all, >> >> I was wondering what the most elegant and efficient way would be to take a >> list containing an even number of elements and convert it into a proplist, >> using only Erlang library functions? This is really a learning thing for me >> (how to think in Erlang) rather than an urgent question, but it is based on >> a real need (having a flat list of key/value pairs and wanting it in >> proplist form). >> >> For example, the function would do this: f([1,2,3,4,5,6,7,8]) -> >> [{1,2},{3,4},{5,6},{7,8}]. >> >> I know it would be easy to write a pattern-matching-style function, but I >> wanted to do it without having to define a new function, in as compact a way >> as possible while still keeping it reasonably efficient. I thought there >> might be a proplists:from_list/1 function, but I couldn't find one. >> >> The best I could come up with is this (it's ok to assume that there will be >> an even number of elements in L): >> >> element(1, lists:mapfoldl(fun(_,[X,Y|T]) -> {{X,Y}, T} end, L, >> lists:seq(1, length(L) div 2))). >> >> It seems like a bit of a perversion of the idea of foldl, being used to >> "unaccumulate". I'm also not really happy with having to generate another >> list using lists:seq, especially if L is long, but I can't think of a better >> way to drive the foldl part with the right number of elements. I thought of >> splitting L in half for this, but what if L has large elements? Wouldn't I >> be using much more memory than a simple list of integers, or would it >> internally be a list of pointers to half of the elements of L? Actually, >> that would almost always be bigger than a list of integers on a 64-bit >> system... >> >> Is there a better way to do this given the stated constraints? If so, I'd >> appreciate it if you'd share it with me. >> >> Regards, >> Edwin Fine >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > From richardc@REDACTED Mon Oct 20 09:06:22 2008 From: richardc@REDACTED (Richard Carlsson) Date: Mon, 20 Oct 2008 09:06:22 +0200 Subject: [erlang-questions] List to proplist? In-Reply-To: <6c2563b20810192156i7516e69aqb4d0eda2e1ee98d9@mail.gmail.com> References: <6c2563b20810192156i7516e69aqb4d0eda2e1ee98d9@mail.gmail.com> Message-ID: <48FC2DEE.5050900@it.uu.se> Edwin Fine wrote: > For example, the function would do this: f([1,2,3,4,5,6,7,8]) -> > [{1,2},{3,4},{5,6},{7,8}]. > > I know it would be easy to write a pattern-matching-style function, but > I wanted to do it without having to define a new function, in as compact > a way as possible while still keeping it reasonably efficient. element(1, lists:foldr(fun (X,{As,[]}) -> {As,[X]}; (X,{As,[Y]}) -> {[{X,Y}|As],[]} end, {[],[]}, List)). /Richard From kenneth.lundin@REDACTED Mon Oct 20 09:58:08 2008 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Mon, 20 Oct 2008 09:58:08 +0200 Subject: [erlang-questions] Request for comments on EEP-24 Message-ID: We would like you to submit comments on EEP-24 on the eeps@REDACTED mailing list. Deadline for comments is 2008-10-28 and after that we will make a decision about the EEP. Here is a link to the EEP: http://www.erlang.org/eeps/eep-0024.html The reason for taking this EEP before other EEPs that was submitted earlier is that we we think it is an improvement that is compatible and it is very easy to implement. NOTE AGAIN! WE WANT THE COMMENTS on the eeps@REDACTED mailing list only (NOT on erlang-questions). This will be the common procedure for EEPS that we announce request for comments on erlang-questions with a deadline and then receive and discuss the comments on the eeps mailing lists before we make a decision which we will announce on both mailing lists. /Regards Kenneth Erlang/OTP team, Ericsson From bgustavsson@REDACTED Mon Oct 20 15:09:54 2008 From: bgustavsson@REDACTED (Bjorn Gustavsson) Date: Mon, 20 Oct 2008 15:09:54 +0200 Subject: [erlang-questions] How to build Erlang with libcmt (/MT) under windows? In-Reply-To: <9b59d0270810190430h6bf221ai4264b2dd93dd2484@mail.gmail.com> References: <9b59d0270810051004u391f464k112d5175573a95f4@mail.gmail.com> <6672d0160810170212n5eefd0a6o3e2e7a41fc0c6483@mail.gmail.com> <9b59d0270810190430h6bf221ai4264b2dd93dd2484@mail.gmail.com> Message-ID: <6672d0160810200609ve5de1ddj770680927dcae7aa@mail.gmail.com> On Sun, Oct 19, 2008 at 1:30 PM, Michael Regen wrote: > Hi Bj?rn, > > I can understand that you do not have intentions supporting it in the main > distribution. It simply does not make sense there. An installer is needed in > any case which can take care of the CRT dependencies. > > But may I ask you - can you give me a hint where Microsoft discourages the > use of a statically bound CRT? Or give me a hint why that would lead to > memory leaks? I would really like to understand the problem, investigated > since I read your statements and so far was unsuccessful finding any hints. > Here is an article about the potential problems about passing CRT objects across DLL boundaries: http://msdn.microsoft.com/en-us/library/ms235460(VS.80).aspx In the context of the Erlang emulator, you could run into those problems if you load drivers into a statically linked emulator, as they would use a different copy of the run-time library. > > The reason why I am asking is because I was thinking about some kind of SAE > revival. I wrote some tests and I am already able to run Erlang together > with many kinds of Erlang applications in one single .exe without patching > the emulator. > As long as you don't load dynamic drivers, statically linking the run-time library would be OK since there would still only be one copy of the run-time library. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB -------------- next part -------------- An HTML attachment was scrubbed... URL: From ruzin82@REDACTED Mon Oct 20 15:33:48 2008 From: ruzin82@REDACTED (Yongbeom Pak) Date: Mon, 20 Oct 2008 16:33:48 +0300 Subject: [erlang-questions] eheap_alloc crash when using mnesia Message-ID: <72e228670810200633q1e17bf7alaab35cfb8c53e3b2@mail.gmail.com> I am trying to use mnesia heavily. It seems there are memory problem on the mnesia or my soruce code. Message i got is "Crash dump was written to: erl_crash.dump eheap_alloc: Cannot allocate 373662860 bytes of memory (of type "heap"). Abnormal termination ". I have erlang 5.6.4 on windows xp sp2 and 2G of physical memory. I installed erlang from binary from the erlang.org Can anybody please tell me what is the problem on my source code and how to solve? I am guessing that erlang has its own limit on the heap memory size and garbage collector is not working fast because of some reason that i don't know. Thanks in advance. Here is my source code. -compile(export_all). -record(test, {user, data, timestamp, timestamp1}). -define(PROCNAME_UPDATER, data_updater). start_amount(N) -> mnesia:start(), create_table(), delete(), write(200000), mnesia:table_info(test,size), data_handler_start(). data_handler_start() -> case whereis(?PROCNAME_UPDATER) of undefined -> register(?PROCNAME_UPDATER, spawn(?MODULE, data_updater, [5000])); _ -> ?PROCNAME_UPDATER end. stop() -> ?PROCNAME_UPDATER ! stop. data_updater(Interval) -> data_updater(Interval, true). data_updater(Interval, true) -> timer:send_after(Interval, update), receive update -> supdate(), data_updater(Interval, true); stop -> ok; {'EXIT', DiedPid, Reason} -> io:format("~p died becausere of '~p '",[DiedPid, Reason]), data_updater(Interval, true); _ -> data_updater(Interval, true) end. create_table() -> mnesia:create_table(test, [{ram_copies, [node()]}, {index, [timestamp1]}, {local_content, true}, {attributes, record_info(fields, test)}]), ok. write(N) -> statistics(runtime), write_data(N), {_, Time} = statistics(runtime), io:format("~nTotal writing time : ~p millisecond~n",[Time]). write_data(0) -> ok; write_data(N) -> {Mega, Sec, _Micro} = now(), mnesia:dirty_write(test, #test{user={"aaaaaaaaaaaaaaaaaaaaaaaaa",random:uniform()}, data = {"aaaaaaaaaaaaaaaaaaaa","bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"}, timestamp = now(), timestamp1 = ((Mega*1000000) + (Sec+random:uniform(10000))) }), write_data(N-1). select_data() -> mnesia:dirty_select(test, [{'$1',[],['$1']}]). delete() -> mnesia:delete_table(test), create_table(). supdate() -> {Mega, Sec, _Micro} = now(), Timesearch = ((Mega*1000000) + (Sec+random:uniform(10000))), io:format("before crash point~n"), mnesia:dirty_select(test, [{#test{user='$0',timestamp1='$1',_='_',data='$2'}, [{'<', '$1', Timesearch }], [['$0','$2']]}]), io:format("after crash point~n"), io:format("---------------------------------------~n"). -------------- next part -------------- An HTML attachment was scrubbed... URL: From gleber.p@REDACTED Mon Oct 20 18:36:49 2008 From: gleber.p@REDACTED (Gleb Peregud) Date: Mon, 20 Oct 2008 18:36:49 +0200 Subject: [erlang-questions] eheap_alloc crash when using mnesia In-Reply-To: <72e228670810200633q1e17bf7alaab35cfb8c53e3b2@mail.gmail.com> References: <72e228670810200633q1e17bf7alaab35cfb8c53e3b2@mail.gmail.com> Message-ID: <14f0e3620810200936j3f59bed3ybc4080b977dad0ff@mail.gmail.com> As far as i know, this error appears when system runs out of memory. Unfortunately Erlang VM crashes when it's alloc() fails. imvho proper solution would be to kill offending erlang process :) On 10/20/08, Yongbeom Pak wrote: > I am trying to use mnesia heavily. It seems there are memory problem on the > mnesia or my soruce code. > Message i got is > "Crash dump was written to: erl_crash.dump > eheap_alloc: Cannot allocate 373662860 bytes of memory (of type "heap"). > > Abnormal termination > ". > I have erlang 5.6.4 on windows xp sp2 and 2G of physical memory. I installed > erlang from binary from the erlang.org > > Can anybody please tell me what is the problem on my source code and how to > solve? > I am guessing that erlang has its own limit on the heap memory size and > garbage collector is not working fast because of some reason that i don't > know. > > Thanks in advance. > > > Here is my source code. > > -compile(export_all). > > -record(test, {user, data, timestamp, timestamp1}). > > -define(PROCNAME_UPDATER, data_updater). > > start_amount(N) -> > mnesia:start(), > create_table(), > delete(), > write(200000), > mnesia:table_info(test,size), > data_handler_start(). > > > > data_handler_start() -> > case whereis(?PROCNAME_UPDATER) of > undefined -> > register(?PROCNAME_UPDATER, spawn(?MODULE, data_updater, [5000])); > _ -> > ?PROCNAME_UPDATER > end. > > stop() -> > ?PROCNAME_UPDATER ! stop. > > data_updater(Interval) -> > data_updater(Interval, true). > > data_updater(Interval, true) -> > timer:send_after(Interval, update), > receive > update -> > supdate(), > data_updater(Interval, true); > stop -> > ok; > {'EXIT', DiedPid, Reason} -> > io:format("~p died becausere of '~p '",[DiedPid, Reason]), > data_updater(Interval, true); > _ -> > data_updater(Interval, true) > end. > > > > create_table() -> > mnesia:create_table(test, > [{ram_copies, [node()]}, > {index, [timestamp1]}, > {local_content, true}, > {attributes, record_info(fields, test)}]), > ok. > > > write(N) -> > statistics(runtime), > write_data(N), > {_, Time} = statistics(runtime), > io:format("~nTotal writing time : ~p millisecond~n",[Time]). > > write_data(0) -> > ok; > > write_data(N) -> > {Mega, Sec, _Micro} = now(), > mnesia:dirty_write(test, > #test{user={"aaaaaaaaaaaaaaaaaaaaaaaaa",random:uniform()}, > data = > {"aaaaaaaaaaaaaaaaaaaa","bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"}, > timestamp = now(), > timestamp1 = ((Mega*1000000) + (Sec+random:uniform(10000))) > }), > write_data(N-1). > > select_data() -> > mnesia:dirty_select(test, [{'$1',[],['$1']}]). > > delete() -> > mnesia:delete_table(test), > create_table(). > > supdate() -> > {Mega, Sec, _Micro} = now(), > Timesearch = ((Mega*1000000) + (Sec+random:uniform(10000))), > io:format("before crash point~n"), > mnesia:dirty_select(test, > [{#test{user='$0',timestamp1='$1',_='_',data='$2'}, > [{'<', '$1', Timesearch }], > [['$0','$2']]}]), > io:format("after crash point~n"), > io:format("---------------------------------------~n"). > -- Gleb Peregud http://gleber.pl/ Every minute is to be grasped. Time waits for nobody. -- Inscription on a Zen Gong From erlang-questions_efine@REDACTED Mon Oct 20 18:46:06 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Mon, 20 Oct 2008 12:46:06 -0400 Subject: [erlang-questions] List to proplist? In-Reply-To: <48FC2DEE.5050900@it.uu.se> References: <6c2563b20810192156i7516e69aqb4d0eda2e1ee98d9@mail.gmail.com> <48FC2DEE.5050900@it.uu.se> Message-ID: <6c2563b20810200946p34c400dfobeaca5d8b9a0a345@mail.gmail.com> On Mon, Oct 20, 2008 at 3:06 AM, Richard Carlsson wrote: > Edwin Fine wrote: > > For example, the function would do this: f([1,2,3,4,5,6,7,8]) -> > > [{1,2},{3,4},{5,6},{7,8}]. > > > > I know it would be easy to write a pattern-matching-style function, but > > I wanted to do it without having to define a new function, in as compact > > a way as possible while still keeping it reasonably efficient. > > element(1, lists:foldr(fun (X,{As,[]}) -> {As,[X]}; (X,{As,[Y]}) -> > {[{X,Y}|As],[]} end, {[],[]}, List)). > That's beautiful - thanks! That's exactly what I was looking for - an idiom. I never thought of having two accumulators. I see that the principle you used could be extended to making triples instead of pairs, and so on: element(1, lists:foldr(fun(Z,{As,[]}) -> {As,[Z]}; (Y,{As,[Z]}) -> {As,[Y,Z]}; (X,{As,[Y,Z]}) -> {[{X,Y,Z}|As],[]} end, {[],[]}, List)) Ulf, thanks for your response, too! Regards, Edwin -------------- next part -------------- An HTML attachment was scrubbed... URL: From q2h46uw02@REDACTED Mon Oct 20 22:05:01 2008 From: q2h46uw02@REDACTED (Kevin) Date: 20 Oct 2008 20:05:01 -0000 Subject: [erlang-questions] Good reason for not using "releases"? Message-ID: <15068-87089@sneakemail.com> Hello, I'm building my first erlang server program, and I've worked my way up from modules, to gen_server and gen_fsm, to supervisor, to application behavior. If this application is going to run on a linux host, and boot using a linux init script, does it make sense to take it to the next level of "release", or is that just more complication I don't need to deal with. I don't ever anticipate the need for hotswapping of code. The users will have no issues with just restarting the entire thing just like all the other stuff running from init scripts, and they might find hotswapping, or whatever fancy stuff releases offers, more work than appreciated. I also don't anticipate this application sharing an running erlang system with any other erlang applications. Thanks, especially if this is such an ignorant question. From matthew@REDACTED Mon Oct 20 22:56:03 2008 From: matthew@REDACTED (Matthew Dempsky) Date: Mon, 20 Oct 2008 13:56:03 -0700 Subject: [erlang-questions] eheap_alloc crash when using mnesia In-Reply-To: <14f0e3620810200936j3f59bed3ybc4080b977dad0ff@mail.gmail.com> References: <72e228670810200633q1e17bf7alaab35cfb8c53e3b2@mail.gmail.com> <14f0e3620810200936j3f59bed3ybc4080b977dad0ff@mail.gmail.com> Message-ID: On Mon, Oct 20, 2008 at 9:36 AM, Gleb Peregud wrote: > As far as i know, this error appears when system runs out of memory. > Unfortunately Erlang VM crashes when it's alloc() fails. imvho proper > solution would be to kill offending erlang process :) I'd love to see a more elegant solution for out-of-memory conditions, but it seems difficult to recover from without explicit memory allocation. E.g., in C, you can check whether malloc(3) failed and then fail gracefully, making sure your error handling code doesn't need to allocate additional memory. (Stack space is still implicitly allocated, but I've never heard this to be a problem, except with runaway recursive programs and kernel programming where the stack space is more limited.) Do any other programming languages with implicit dynamic memory allocation have a better solution than simply terminating? From monch1962@REDACTED Mon Oct 20 23:50:12 2008 From: monch1962@REDACTED (David Mitchell) Date: Tue, 21 Oct 2008 08:50:12 +1100 Subject: [erlang-questions] Good reason for not using "releases"? In-Reply-To: <15068-87089@sneakemail.com> References: <15068-87089@sneakemail.com> Message-ID: My take would be that if you don't need a facility, don't bother implementing it. You might find you need releases at some point in the future, but assuming you don't exclude the possibility of building them in later (e.g. by writing your code in such a way that prevents it from happening), then it seems you could add it in if/when the requirement becomes apparent. As an analogy, I like to think of myself as someone who tries to improve their coding skills as far as I'm able, and I think I'm doing that month by month. That said, I've got no problem building quick and dirty one-off Perl scripts to e.g. read in some data and reformat it for me - trying to create elegant code isn't a priority in this instance, but getting it done as quickly as possible often is a priority in this case. I'll be interested to hear what others think Regards Dave M. 2008/10/21 Kevin : > > > Hello, I'm building my first erlang server program, and I've worked my way up from modules, to gen_server and gen_fsm, to supervisor, to application behavior. > > If this application is going to run on a linux host, and boot using a linux init script, does it make sense to take it to the next level of "release", or is that just more complication I don't need to deal with. > > I don't ever anticipate the need for hotswapping of code. The users will have no issues with just restarting the entire thing just like all the other stuff running from init scripts, and they might find hotswapping, or whatever fancy stuff releases offers, more work than appreciated. > > I also don't anticipate this application sharing an running erlang system with any other erlang applications. > > Thanks, especially if this is such an ignorant question. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From erlang-questions_efine@REDACTED Tue Oct 21 00:00:22 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Mon, 20 Oct 2008 18:00:22 -0400 Subject: [erlang-questions] Good reason for not using "releases"? In-Reply-To: <15068-87089@sneakemail.com> References: <15068-87089@sneakemail.com> Message-ID: <6c2563b20810201500l3c02c0eaw54ca43130b544d8a@mail.gmail.com> On Mon, Oct 20, 2008 at 4:05 PM, Kevin wrote: > > > Hello, I'm building my first erlang server program, and I've worked my way > up from modules, to gen_server and gen_fsm, to supervisor, to application > behavior. > > If this application is going to run on a linux host, and boot using a linux > init script, does it make sense to take it to the next level of "release", > or is that just more complication I don't need to deal with. Yes, because you will surely upgrade the code at some point (new features, bug fixes) and it's a pain to do this by hand or even using scripts. I suggest taking a look at some open source Erlang-specific software that allows you to build and distribute (install) your Erlang applications relatively painlessly. The builder component is called Sinan ( http://code.google.com/p/sinan/); the distribution/installation component is called Faxien (http://code.google.com/p/faxien/). I use these for the job and although there are some minor imperfections, I would never go back to the "old way". Also take a look at the Faxien/Sinan cookbook at http://myfcci.com/yab/2008/09/11/my-faxiensinan-cookbook/ to get started (disclosure: I wrote the cookbook, but I have no vested interest in Sinan or Faxien other than using it for my work). I don't ever anticipate the need for hotswapping of code. The users will > have no issues with just restarting the entire thing just like all the other > stuff running from init scripts, and they might find hotswapping, or > whatever fancy stuff releases offers, more work than appreciated. > How would they like to upgrade to the latest release just by typing in "$ faxien upgrade-release kevins_stuff" and then restart the app? > > I also don't anticipate this application sharing an running erlang system > with any other erlang applications. > > Thanks, especially if this is such an ignorant question. No question is ignorant. Hope this helps. -------------- next part -------------- An HTML attachment was scrubbed... URL: From japerk@REDACTED Tue Oct 21 00:24:49 2008 From: japerk@REDACTED (Jacob Perkins) Date: Mon, 20 Oct 2008 15:24:49 -0700 Subject: [erlang-questions] eheap_alloc crash when using mnesia Message-ID: I used to get those eheap out-of-memory crashes a lot. The way to fix it is to ruthlessly minimize the records you store in mnesia. I've found that mnesia works best with very small records, and if you're doing iteration on the table, then do it in small chunks at a time without accumulating a large structure (use select instead of match_object if you expect to get a large number of records). I had been storing dicts in mnesia, and running into memory issues, until members of this list pointed me to the idea of using ordered_set tables with tuples keys. That allowed me to separate the dict into small records while still maintaining iteration & matching performance requirements. The number of records in a table has gone up dramatically, but that doesn't seem to cause any problems. Hope that helps, Jacob -------------- next part -------------- An HTML attachment was scrubbed... URL: From michael.regen@REDACTED Tue Oct 21 00:44:37 2008 From: michael.regen@REDACTED (Michael Regen) Date: Tue, 21 Oct 2008 00:44:37 +0200 Subject: [erlang-questions] How to build Erlang with libcmt (/MT) under windows? In-Reply-To: <6672d0160810200609ve5de1ddj770680927dcae7aa@mail.gmail.com> References: <9b59d0270810051004u391f464k112d5175573a95f4@mail.gmail.com> <6672d0160810170212n5eefd0a6o3e2e7a41fc0c6483@mail.gmail.com> <9b59d0270810190430h6bf221ai4264b2dd93dd2484@mail.gmail.com> <6672d0160810200609ve5de1ddj770680927dcae7aa@mail.gmail.com> Message-ID: <9b59d0270810201544y2cbbbaddoc3e070c30acf4811@mail.gmail.com> Hi, I am beginning to understand. And to be honest this article horrifies me. OK, before I say something bad about Microsoft (again) I should meditate about this for some time. Thank you for taking the time! Regards, Michael On Mon, Oct 20, 2008 at 3:09 PM, Bjorn Gustavsson wrote: > On Sun, Oct 19, 2008 at 1:30 PM, Michael Regen wrote: > >> Hi Bj?rn, >> >> I can understand that you do not have intentions supporting it in the main >> distribution. It simply does not make sense there. An installer is needed in >> any case which can take care of the CRT dependencies. >> >> But may I ask you - can you give me a hint where Microsoft discourages the >> use of a statically bound CRT? Or give me a hint why that would lead to >> memory leaks? I would really like to understand the problem, investigated >> since I read your statements and so far was unsuccessful finding any hints. >> > > Here is an article about the potential problems about passing CRT objects > across DLL boundaries: > > http://msdn.microsoft.com/en-us/library/ms235460(VS.80).aspx > > In the context of the Erlang emulator, you could run into those problems if > you load drivers into a statically linked > emulator, as they would use a different copy of the run-time library. > > >> >> The reason why I am asking is because I was thinking about some kind of >> SAE revival. I wrote some tests and I am already able to run Erlang together >> with many kinds of Erlang applications in one single .exe without patching >> the emulator. >> > > As long as you don't load dynamic drivers, statically linking the run-time > library would be OK since there would > still only be one copy of the run-time library. > > /Bjorn > > -- > Bj?rn Gustavsson, Erlang/OTP, Ericsson AB > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ok@REDACTED Tue Oct 21 01:37:15 2008 From: ok@REDACTED (Richard O'Keefe) Date: Tue, 21 Oct 2008 12:37:15 +1300 Subject: [erlang-questions] List to proplist? In-Reply-To: <6c2563b20810192156i7516e69aqb4d0eda2e1ee98d9@mail.gmail.com> References: <6c2563b20810192156i7516e69aqb4d0eda2e1ee98d9@mail.gmail.com> Message-ID: On 20 Oct 2008, at 5:56 pm, Edwin Fine wrote: > I know it would be easy to write a pattern-matching-style function, > but I wanted to do it without having to define a new function, > > element(1, lists:mapfoldl(fun(_,[X,Y|T]) -> {{X,Y}, T} end, L, > lists:seq(1, length(L) div 2))). But you just defined a new function and a pattern-matching one at that. The obvious function is to_proplist([Key,Val|Rest]) -> [{Key,Val} | to_proplist(Rest)]; to_proplist([]) -> []. Now let's pretend that you've heard of "unfold", maybe even read http://debasishg.blogspot.com/2007/11/fun-with-unfold-in-erlang.html Let's copy the unfold function from there. unfold(Seed, Predicate, Transformer, Incrementor) -> unfold(Seed, Predicate, Transformer, Incrementor, []). unfold(Seed, Predicate, Transformer, Incrementor, Acc) -> case Predicate(Seed) of false -> lists:reverse(Acc) ; true -> unfold(Incrementor(Seed), Predicate, Transformer, Incrementor, [Transformer(Seed)|Acc]) end. Now it's fairly straightforward: to_proplist(Even_List) -> unfold(Even_List, fun (L) -> L =/= [] end, fun ([Key,Val|_]) -> {Key,Val} end, fun ([_,_|Rest]) -> Rest end). When you want to generate a list, an unfold is often what you want rather than a fold. I don't suppose we could have unfold/4 in the lists module, could we? From erlang-questions_efine@REDACTED Tue Oct 21 02:13:45 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Mon, 20 Oct 2008 20:13:45 -0400 Subject: [erlang-questions] List to proplist? In-Reply-To: References: <6c2563b20810192156i7516e69aqb4d0eda2e1ee98d9@mail.gmail.com> Message-ID: <6c2563b20810201713x2c970a91t12e4c755f7d5f345@mail.gmail.com> Thanks for your very informative answer. On Mon, Oct 20, 2008 at 7:37 PM, Richard O'Keefe wrote: > > On 20 Oct 2008, at 5:56 pm, Edwin Fine wrote: > >> I know it would be easy to write a pattern-matching-style function, but I >> wanted to do it without having to define a new function, >> >> element(1, lists:mapfoldl(fun(_,[X,Y|T]) -> {{X,Y}, T} end, L, >> lists:seq(1, length(L) div 2))). >> > > But you just defined a new function and a pattern-matching one > at that. > > The obvious function is > > to_proplist([Key,Val|Rest]) -> > [{Key,Val} | to_proplist(Rest)]; > to_proplist([]) -> > []. > > Now let's pretend that you've heard of "unfold", > maybe even read > http://debasishg.blogspot.com/2007/11/fun-with-unfold-in-erlang.html > > Let's copy the unfold function from there. > > unfold(Seed, Predicate, Transformer, Incrementor) -> > unfold(Seed, Predicate, Transformer, Incrementor, []). > > unfold(Seed, Predicate, Transformer, Incrementor, Acc) -> > case Predicate(Seed) > of false -> lists:reverse(Acc) > ; true -> unfold(Incrementor(Seed), > Predicate, > Transformer, > Incrementor, > [Transformer(Seed)|Acc]) > end. > > Now it's fairly straightforward: > > to_proplist(Even_List) -> > unfold(Even_List, > fun (L) -> L =/= [] end, > fun ([Key,Val|_]) -> {Key,Val} end, > fun ([_,_|Rest]) -> Rest end). > > When you want to generate a list, an unfold is often what > you want rather than a fold. > I'll pretend that you actually answered, and maybe even read, the question I was asking. Somehow, Richard Carlsson managed to do that, without inventing new library functions, so it couldn't have been too obscure and badly-worded. However, I see now that I asked the wrong question, or phrased it incorrectly, so thank you for setting me straight. I apologize for not having heard of unfold, and for not having read every blog in existence that contained something relevant to my question prior to wasting people's valuable time on this list by asking it in the first place. > I don't suppose we could have unfold/4 in the lists module, > could we? > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ok@REDACTED Tue Oct 21 02:44:59 2008 From: ok@REDACTED (Richard O'Keefe) Date: Tue, 21 Oct 2008 13:44:59 +1300 Subject: [erlang-questions] eheap_alloc crash when using mnesia In-Reply-To: References: <72e228670810200633q1e17bf7alaab35cfb8c53e3b2@mail.gmail.com> <14f0e3620810200936j3f59bed3ybc4080b977dad0ff@mail.gmail.com> Message-ID: <839F95C1-1FFE-43D0-982F-1EAE7670D36E@cs.otago.ac.nz> On 21 Oct 2008, at 9:56 am, Matthew Dempsky wrote: > Do any other programming languages with implicit dynamic memory > allocation have a better solution than simply terminating? Funnily enough I've been arguing about this in the mailing list for revising the Smalltalk standard. VisualWorks Smalltalk raises an exception. (I suspect that it preallocates the exception object.) Squeak Smalltalk reserves enough memory to run a "Low Space Warning" dialogue that offers to let you blast away the current activity + a few other options. SWI Prolog reserves enough memory to build an exception and raise it. In a language with multiple processes (like Smalltalk and SWI Prolog), it can be difficult to decide which process to blame. From ok@REDACTED Tue Oct 21 03:08:32 2008 From: ok@REDACTED (Richard O'Keefe) Date: Tue, 21 Oct 2008 14:08:32 +1300 Subject: [erlang-questions] List to proplist? In-Reply-To: References: <6c2563b20810192156i7516e69aqb4d0eda2e1ee98d9@mail.gmail.com> Message-ID: <620F5FF0-93F8-4E0E-BBDA-5404E82BB054@cs.otago.ac.nz> A version of unfold that I prefer is unfold(State, Splitter) -> unfold(State, Splitter, []). unfold(State, Splitter, Acc) -> case Splitter(State) of [] -> lists:reverse(Acc) ; [Item|State1] -> unfold(State1, Splitter, [Item|Acc]) end. With that, generating a proplist is to_proplist(Even_List) -> unfold(Even_List, fun ([Key,Val|Rest]) -> [{Key,Val}|Rest] ; ([]) -> [] end). From martin.logan@REDACTED Tue Oct 21 04:25:15 2008 From: martin.logan@REDACTED (Martin Logan) Date: Mon, 20 Oct 2008 21:25:15 -0500 Subject: [erlang-questions] Inets concurrent limit In-Reply-To: <6c2563b20810171553g54553d64mb0da6172f35099a9@mail.gmail.com> Message-ID: That is one of the problems I did run into. Was hitting ulimits as well. Both problems are fixed now and the proxy flies :) Thanks for the response. Cheers, Martin On 10/17/08 5:53 PM, "Edwin Fine" wrote: > Martin, > > I wonder if you are running into the TCP/IP ephemeral port starvation problem? > > There's more information about this (and how to reduce problems due to it) in > a post I wrote a little while ago: > > http://www.erlang.org/pipermail/erlang-questions/2008-September/038154.html > > Hope this helps. > > Regards, > Edwin > > 2008/10/17 Logan, Martin >> Does inets have a limit on the number of concurrent requests it can handle >> both inbound and outbound. On the inbound side when I really ramp up load I >> see 503 responses quite a bit, I am also seeing sporadic 500's. On the >> outbound side (this thing I am testing is an http proxy) I am seeing issues >> with addrinuse, which looks to be an OS issue so I am investigating that as a >> separate issue. Anyhow, any inets info you can provide would be helpful. >> Basically I am looking to be able to drive as much traffic though this thing >> as I can. >> >> >> >> Cheers, >> >> Martin >> If you are not the intended recipient of this e-mail message, please notify >> the sender >> and delete all copies immediately. The sender believes this message and any >> attachments >> were sent free of any virus, worm, Trojan horse, and other forms of malicious >> code. >> This message and its attachments could have been infected during >> transmission. The >> recipient opens any attachments at the recipient's own risk, and in so doing, >> the >> recipient accepts full responsibility for such actions and agrees to take >> protective >> and remedial action relating to any malicious code. Travelport is not liable >> for any >> loss or damage arising from this message or its attachments. >> >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rtrlists@REDACTED Tue Oct 21 10:07:13 2008 From: rtrlists@REDACTED (Robert Raschke) Date: Tue, 21 Oct 2008 09:07:13 +0100 Subject: [erlang-questions] eheap_alloc crash when using mnesia In-Reply-To: References: <72e228670810200633q1e17bf7alaab35cfb8c53e3b2@mail.gmail.com> <14f0e3620810200936j3f59bed3ybc4080b977dad0ff@mail.gmail.com> Message-ID: <6a3ae47e0810210107u16f4c75fx27bc95ac2528e33a@mail.gmail.com> On Mon, Oct 20, 2008 at 9:56 PM, Matthew Dempsky wrote: > I'd love to see a more elegant solution for out-of-memory conditions, > but it seems difficult to recover from without explicit memory > allocation. E.g., in C, you can check whether malloc(3) failed and > then fail gracefully, making sure your error handling code doesn't > need to allocate additional memory. (Stack space is still implicitly > allocated, but I've never heard this to be a problem, except with > runaway recursive programs and kernel programming where the stack > space is more limited.) Beware! With modern kernels it is no longer true that malloc always fails if you run out of memory. Often you'll find it crashes upon access of the allocated memory rather than on the call to malloc(). I'll need to dig out the references. Robby From rtrlists@REDACTED Tue Oct 21 10:30:59 2008 From: rtrlists@REDACTED (Robert Raschke) Date: Tue, 21 Oct 2008 09:30:59 +0100 Subject: [erlang-questions] eheap_alloc crash when using mnesia In-Reply-To: <6a3ae47e0810210107u16f4c75fx27bc95ac2528e33a@mail.gmail.com> References: <72e228670810200633q1e17bf7alaab35cfb8c53e3b2@mail.gmail.com> <14f0e3620810200936j3f59bed3ybc4080b977dad0ff@mail.gmail.com> <6a3ae47e0810210107u16f4c75fx27bc95ac2528e33a@mail.gmail.com> Message-ID: <6a3ae47e0810210130o4bfaadg4e56c83f70e883fb@mail.gmail.com> On Tue, Oct 21, 2008 at 9:07 AM, Robert Raschke wrote: > On Mon, Oct 20, 2008 at 9:56 PM, Matthew Dempsky wrote: >> I'd love to see a more elegant solution for out-of-memory conditions, >> but it seems difficult to recover from without explicit memory >> allocation. E.g., in C, you can check whether malloc(3) failed and >> then fail gracefully, making sure your error handling code doesn't >> need to allocate additional memory. (Stack space is still implicitly >> allocated, but I've never heard this to be a problem, except with >> runaway recursive programs and kernel programming where the stack >> space is more limited.) > > Beware! With modern kernels it is no longer true that malloc always > fails if you run out of memory. Often you'll find it crashes upon > access of the allocated memory rather than on the call to malloc(). > I'll need to dig out the references. > > Robby > See http://www.linuxdevcenter.com/pub/a/linux/2006/11/30/linux-out-of-memory.html for a good explanation. Robby From thomasl_erlang@REDACTED Tue Oct 21 11:34:17 2008 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Tue, 21 Oct 2008 02:34:17 -0700 (PDT) Subject: [erlang-questions] eheap_alloc crash when using mnesia In-Reply-To: <6a3ae47e0810210107u16f4c75fx27bc95ac2528e33a@mail.gmail.com> Message-ID: <588204.36771.qm@web38805.mail.mud.yahoo.com> --- On Tue, 10/21/08, Robert Raschke wrote: > From: Robert Raschke > Subject: Re: [erlang-questions] eheap_alloc crash when using mnesia > To: erlang-questions@REDACTED > Date: Tuesday, October 21, 2008, 10:07 AM > On Mon, Oct 20, 2008 at 9:56 PM, Matthew Dempsky > wrote: > > I'd love to see a more elegant solution for > out-of-memory conditions, > > but it seems difficult to recover from without > explicit memory > > allocation. E.g., in C, you can check whether > malloc(3) failed and > > then fail gracefully, making sure your error handling > code doesn't > > need to allocate additional memory. (Stack space is > still implicitly > > allocated, but I've never heard this to be a > problem, except with > > runaway recursive programs and kernel programming > where the stack > > space is more limited.) > > Beware! With modern kernels it is no longer true that > malloc always > fails if you run out of memory. Often you'll find it > crashes upon > access of the allocated memory rather than on the call to > malloc(). > I'll need to dig out the references. Sounds pretty painful; I've mostly heard complaints about the Linux OOM killer so far. For Erlang, we could use some of the following (perhaps configurable per process): 1. Kill processes that use more than a predefined amount of memory. 2. Kill processes that spawn more than some limit. 3. Kill unimportant processes. 4. Kill greedy supervisors 5. Let the emulator die, have heart restart it and exercise our smooth failover code. (What we do today.) Of course, just killing processes still leaves the various tables around, which can eat a considerable share by themselves (and are natural sources of space leaks to boot; doubly so if you start killing processes that would eventually have removed some entries). Anyone with a good solution to killing tables and/or table entries? :-) Best, Thomas __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From taavi@REDACTED Tue Oct 21 12:16:38 2008 From: taavi@REDACTED (Taavi Talvik) Date: Tue, 21 Oct 2008 13:16:38 +0300 Subject: [erlang-questions] Question about edoc and type specifications Message-ID: <4CA69F2F-2AA9-4FB0-BEC2-E7B23E1BBE36@uninet.ee> Hello! Has anyone done work on edoc to use type specifications (EEP-008). If not - any hints where to start. Any pointer to -spec abstract syntax? Compiler /spec them and they are nicely inserted into syntax tree. And it would be nice to see real type specifications in doc. best regards, taavi From raimo+erlang-questions@REDACTED Tue Oct 21 13:24:20 2008 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Tue, 21 Oct 2008 13:24:20 +0200 Subject: [erlang-questions] : ready_async() before outputv() calling driver_async() completes? In-Reply-To: <48F7294D.2080500@alertlogic.net> References: <48F677EF.7060709@alertlogic.net> <20081016072932.GA27066@erix.ericsson.se> <48F7294D.2080500@alertlogic.net> Message-ID: <20081021112420.GA13445@erix.ericsson.se> In-line answers below. In which driver do you see that ready_async() happens before outputv() returned? And how do you see it? The file driver (efile_drv) has a strange optimization where it short circuits driver_async() for simple file operations, so it itself calls ready_async() from within the outputv() call. If it happens in some other driver that does not do the same kind of dirty tricks; it is a bug. On Thu, Oct 16, 2008 at 06:45:17AM -0500, Paul Fisher wrote: > Raimo Niskanen wrote: > > On Wed, Oct 15, 2008 at 06:08:31PM -0500, Paul Fisher wrote: > >> Should it be possible for a ready_async() callback to happen before the > >> outputv() callback which called driver_async() has returned? I am > >> seeing this happen on R12B-2 smp runtime (2 schedulers), w/four (4) > >> async threads. > > > > And even if the SMP emulator does not do it explicitly, > > it is always possible for the thread calling outputv() > > to get scheduled out between the return from driver_async() > > and the return from outputv(), and the asynchronous > > thread to get scheduled in, do its thing and call ready_async() > > right then. Forget I said that, I was writing before thinking. Of course we have locks preventing this to happen so drivers can happily behave as before the SMP era. > > I am talking about SMP with async threads only. > OK, SMP 2 schedulers 4 async threads. I am with you now... > The documentation says that the ready_async() callback happens from the > emulator thread. > > "This function is called from the erlang emulator thread, as opposed to > the asynchronous function, which is called in some thread (if > multithreading is enabled)." > > > All other indications in the documentation make me believe that only one > callback from an emulator thread is active in a callback at a time (for > each port instance that is). Correct. The default for a driver is that it gets one lock and any callback except for the driver_async callbacks all use the same lock. Hence only one callback at a time in the whole driver is executed. This is a fallback to make old non-SMP aware drivers work as before. > > "There will only be one thread at a time calling driver call-backs > corresponding to the same port, though." Drivers that so desire can by setting a flag in their driver structure during driver init request port locking. Then they get one lock per port and can only execute in one callback per port, but several ports can execute callbacks in parallel. The most important drivers within OTP has been rewritten to use this feature, but many less used ones use driver locking. > > > So you are saying that ready_async() is an exception to this? No, sorry about the noise. > > > -- > paul > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From steven.charles.davis@REDACTED Tue Oct 21 16:18:52 2008 From: steven.charles.davis@REDACTED (Steve Davis) Date: Tue, 21 Oct 2008 07:18:52 -0700 (PDT) Subject: [erlang-questions] Why isn't erlang strongly typed? Message-ID: <58fb3ab8-9ec2-43a1-9b69-51803bdb4dbc@r66g2000hsg.googlegroups.com> I'm sure that there's a simple and convincing answer to this. I'm finding myself having to dig into the source code of libraries or plough through often erratic documentation all the time which really slows down productivity. Am I thinking about this all wrong? Is there a guiding principle that will help me as I learn? TIA /Steve From chsu79@REDACTED Tue Oct 21 16:30:02 2008 From: chsu79@REDACTED (Christian) Date: Tue, 21 Oct 2008 16:30:02 +0200 Subject: [erlang-questions] Why isn't erlang strongly typed? In-Reply-To: <58fb3ab8-9ec2-43a1-9b69-51803bdb4dbc@r66g2000hsg.googlegroups.com> References: <58fb3ab8-9ec2-43a1-9b69-51803bdb4dbc@r66g2000hsg.googlegroups.com> Message-ID: > I'm finding myself having to dig into the source code of libraries or > plough through often erratic documentation all the time which really > slows down productivity. Am I thinking about this all wrong? Is there > a guiding principle that will help me as I learn? Yeah, I know, I have this problem with programming too, whatever the language is. From richardc@REDACTED Tue Oct 21 16:30:57 2008 From: richardc@REDACTED (Richard Carlsson) Date: Tue, 21 Oct 2008 16:30:57 +0200 Subject: [erlang-questions] Question about edoc and type specifications In-Reply-To: <4CA69F2F-2AA9-4FB0-BEC2-E7B23E1BBE36@uninet.ee> References: <4CA69F2F-2AA9-4FB0-BEC2-E7B23E1BBE36@uninet.ee> Message-ID: <48FDE7A1.4080605@it.uu.se> Taavi Talvik wrote: > Hello! > > Has anyone done work on edoc to use type specifications (EEP-008). > > If not - any hints where to start. Any pointer to -spec abstract syntax? > > Compiler /spec them and they are nicely inserted into syntax tree. And > it would be nice to see real type specifications in doc. It would be nice, yes. I have planned to make edoc parse the -spec declarations, but have not had time to work on it yet. It should be fixed for R13 next year, though. /Richard From dave.smith.to@REDACTED Tue Oct 21 16:41:06 2008 From: dave.smith.to@REDACTED (Dave Smith) Date: Tue, 21 Oct 2008 10:41:06 -0400 Subject: [erlang-questions] List to proplist? In-Reply-To: <620F5FF0-93F8-4E0E-BBDA-5404E82BB054@cs.otago.ac.nz> References: <6c2563b20810192156i7516e69aqb4d0eda2e1ee98d9@mail.gmail.com> <620F5FF0-93F8-4E0E-BBDA-5404E82BB054@cs.otago.ac.nz> Message-ID: <5ea453f90810210741j2f3805b6m48de8e80dbebaac1@mail.gmail.com> Nice! Your second version is much better. It's also clearer than Richards foldr version. This also my first introduction to unfold. I will definitely be looking for application of this pattern in the future. 2008/10/20 Richard O'Keefe > A version of unfold that I prefer is > > unfold(State, Splitter) -> > unfold(State, Splitter, []). > > ... > to_proplist(Even_List) -> > unfold(Even_List, fun ([Key,Val|Rest]) -> [{Key,Val}|Rest] > ; ([]) -> [] > end). > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rapsey@REDACTED Tue Oct 21 16:45:22 2008 From: rapsey@REDACTED (Rapsey) Date: Tue, 21 Oct 2008 16:45:22 +0200 Subject: [erlang-questions] Why isn't erlang strongly typed? In-Reply-To: <58fb3ab8-9ec2-43a1-9b69-51803bdb4dbc@r66g2000hsg.googlegroups.com> References: <58fb3ab8-9ec2-43a1-9b69-51803bdb4dbc@r66g2000hsg.googlegroups.com> Message-ID: <97619b170810210745k921b46h427f0523d7c96082@mail.gmail.com> I don't understand. What does this have to do with the language being strongly typed? Sergej On Tue, Oct 21, 2008 at 4:18 PM, Steve Davis wrote: > I'm sure that there's a simple and convincing answer to this. > > I'm finding myself having to dig into the source code of libraries or > plough through often erratic documentation all the time which really > slows down productivity. Am I thinking about this all wrong? Is there > a guiding principle that will help me as I learn? > > TIA > /Steve > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From gleber.p@REDACTED Tue Oct 21 16:46:14 2008 From: gleber.p@REDACTED (Gleb Peregud) Date: Tue, 21 Oct 2008 16:46:14 +0200 Subject: [erlang-questions] Why isn't erlang strongly typed? In-Reply-To: <58fb3ab8-9ec2-43a1-9b69-51803bdb4dbc@r66g2000hsg.googlegroups.com> References: <58fb3ab8-9ec2-43a1-9b69-51803bdb4dbc@r66g2000hsg.googlegroups.com> Message-ID: <14f0e3620810210746p564c1a08jfaa7d4ed680976cb@mail.gmail.com> On 10/21/08, Steve Davis wrote: > I'm sure that there's a simple and convincing answer to this. IMHO the reason is two-fold. First - historical, i.e. it was largely based on Prolog. Second - strong typing would complicated hot code swapping a lot. Having two versions of single function with different types accepted would be quite cumbersome to handle. What if there are multiple nodes in a cluster having different versions of some module? It wouldn't be easy to handle it in strong typed language, imvho. Though I'm not saying it is impossible ;) > > I'm finding myself having to dig into the source code of libraries or > plough through often erratic documentation all the time which really > slows down productivity. Am I thinking about this all wrong? Is there > a guiding principle that will help me as I learn? > > TIA > /Steve > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- Gleb Peregud http://gleber.pl/ Every minute is to be grasped. Time waits for nobody. -- Inscription on a Zen Gong From steven.charles.davis@REDACTED Tue Oct 21 17:14:00 2008 From: steven.charles.davis@REDACTED (Steve Davis) Date: Tue, 21 Oct 2008 08:14:00 -0700 (PDT) Subject: [erlang-questions] Why isn't erlang strongly typed? In-Reply-To: <97619b170810210745k921b46h427f0523d7c96082@mail.gmail.com> References: <58fb3ab8-9ec2-43a1-9b69-51803bdb4dbc@r66g2000hsg.googlegroups.com> <97619b170810210745k921b46h427f0523d7c96082@mail.gmail.com> Message-ID: <356d0fb3-c13d-43f2-ab2f-5f1aa9fd27df@l62g2000hse.googlegroups.com> On Oct 21, 9:45 am, Rapsey wrote: > I don't understand. What does this have to do with the language being > strongly typed? Well, the way I think about it is that types let you define what the function expects, and what you can expect in return. So it would provide a contract or agreed protocol in a far more cohesive way that is possible right now in erlang (cf. "spec" and "record"). Types would speed up coding as it would avoid you having to dig around in every function's source to see what you should expect in return. There's probably some fatal flaw in this thinking -- which is why I asked the question :) /s From holger@REDACTED Tue Oct 21 17:12:27 2008 From: holger@REDACTED (Holger Hoffstaette) Date: Tue, 21 Oct 2008 17:12:27 +0200 Subject: [erlang-questions] Why isn't erlang strongly typed? References: <58fb3ab8-9ec2-43a1-9b69-51803bdb4dbc@r66g2000hsg.googlegroups.com> Message-ID: On Tue, 21 Oct 2008 07:18:52 -0700, Steve Davis wrote: > I'm sure that there's a simple and convincing answer to this. No, but that's mostly because you are confusing two things. ;) > I'm finding myself having to dig into the source code of libraries or > plough through often erratic documentation all the time which really slows > down productivity. Am I thinking about this all wrong? Is there a guiding > principle that will help me as I learn? This is a consequence of Erlangs incredibly unergonomic function/parameter naming conventions and has little to do with strong typing (or its absence). Dynamic/weak typing per se does not preclude ergonomic/intuitive class/module/function naming conventions; I've written pages of Smalltalk and Objective-C without looking into the docs even when using mostly unknown classes (most of the time you can literally guess the method names and parameters). Likewise, strong typing is no guarantee for readable method signatures and consistent code conventions - just look at Java or C. Unfortunately this and the rather antiquated build/deploy processes are really big (and unnecessary) inhibitors to more widespread adoption - which is a shame, because the platform itself is solid and has a lot to offer. -h From rvirding@REDACTED Tue Oct 21 17:19:46 2008 From: rvirding@REDACTED (Robert Virding) Date: Tue, 21 Oct 2008 17:19:46 +0200 Subject: [erlang-questions] List to proplist? In-Reply-To: <5ea453f90810210741j2f3805b6m48de8e80dbebaac1@mail.gmail.com> References: <6c2563b20810192156i7516e69aqb4d0eda2e1ee98d9@mail.gmail.com> <620F5FF0-93F8-4E0E-BBDA-5404E82BB054@cs.otago.ac.nz> <5ea453f90810210741j2f3805b6m48de8e80dbebaac1@mail.gmail.com> Message-ID: <3dbc6d1c0810210819s4ca37756q498a1df6beb6ff35@mail.gmail.com> Same Richard! 2008/10/21 Dave Smith > Nice! Your second version is much better. It's also clearer than Richards > foldr version. > > This also my first introduction to unfold. I will definitely be looking for > application of this pattern in the future. > > > 2008/10/20 Richard O'Keefe > >> A version of unfold that I prefer is >> >> unfold(State, Splitter) -> >> unfold(State, Splitter, []). >> >> ... >> to_proplist(Even_List) -> >> unfold(Even_List, fun ([Key,Val|Rest]) -> [{Key,Val}|Rest] >> ; ([]) -> [] >> end). >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kenneth.lundin@REDACTED Tue Oct 21 17:34:29 2008 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Tue, 21 Oct 2008 17:34:29 +0200 Subject: [erlang-questions] Why isn't erlang strongly typed? In-Reply-To: <58fb3ab8-9ec2-43a1-9b69-51803bdb4dbc@r66g2000hsg.googlegroups.com> References: <58fb3ab8-9ec2-43a1-9b69-51803bdb4dbc@r66g2000hsg.googlegroups.com> Message-ID: Hi, In the documentation regarding the API's the type information should be and is present and your statement regarding "OFTEN ERRATIC" surprises me at least for the Erlang/OTP distribution. If you find errors in the Erlang/OTP documentation please report them to the erlang-bugs mailing list. Note, that the documentation covers the supported API's which we intend to keep backwards compatible. It is usually not an error in the documentation that you may find modules and exported functions that are not documented. /Regards Kenneth Erlang/OTP team , Ericsson On Tue, Oct 21, 2008 at 4:18 PM, Steve Davis wrote: > I'm sure that there's a simple and convincing answer to this. > > I'm finding myself having to dig into the source code of libraries or > plough through often erratic documentation all the time which really > slows down productivity. Am I thinking about this all wrong? Is there > a guiding principle that will help me as I learn? > > TIA > /Steve > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From attila.rajmund.nohl@REDACTED Tue Oct 21 17:47:31 2008 From: attila.rajmund.nohl@REDACTED (attila.rajmund.nohl@REDACTED) Date: Tue, 21 Oct 2008 17:47:31 +0200 (CEST) Subject: [erlang-questions] Why isn't erlang strongly typed? In-Reply-To: References: <58fb3ab8-9ec2-43a1-9b69-51803bdb4dbc@r66g2000hsg.googlegroups.com> Message-ID: On Tue, 21 Oct 2008, Kenneth Lundin wrote: > Hi, > > In the documentation regarding the API's the type information should > be and is present and your statement regarding "OFTEN ERRATIC" > surprises me at least for the Erlang/OTP distribution. It's not only about the documentation - it's about the documented functions itself too. My favourite example from mnesia - there's a two parameters dirty_read function: dirty_read(Tab, Key) -> ValueList | exit({aborted, Reason} but there's no two parameters read function. Annoys the heck out of me when I replace a dirty_read with a read and get a runtime error. Bye,NAR P.s.: notice the typo in the documentation. -- "Beware of bugs in the above code; I have only proved it correct, not tried it." From steven.charles.davis@REDACTED Tue Oct 21 18:06:17 2008 From: steven.charles.davis@REDACTED (Steve Davis) Date: Tue, 21 Oct 2008 09:06:17 -0700 (PDT) Subject: [erlang-questions] Why isn't erlang strongly typed? In-Reply-To: References: <58fb3ab8-9ec2-43a1-9b69-51803bdb4dbc@r66g2000hsg.googlegroups.com> Message-ID: <095140fb-2ea1-4643-ab6f-5e0f8afd4d25@17g2000hsk.googlegroups.com> On Oct 21, 10:34?am, "Kenneth Lundin" wrote: > Hi, > > In the documentation regarding the API's the type information should > be and is present and your statement regarding ?"OFTEN ERRATIC" > surprises me at least for the Erlang/OTP distribution. > That "erratic" comment was not directed at the OTP libraries! They are very well documented (and exceptionally so compared to 3rd party libraries). From ulf@REDACTED Tue Oct 21 18:52:11 2008 From: ulf@REDACTED (Ulf Wiger) Date: Tue, 21 Oct 2008 18:52:11 +0200 Subject: [erlang-questions] Why isn't erlang strongly typed? In-Reply-To: <58fb3ab8-9ec2-43a1-9b69-51803bdb4dbc@r66g2000hsg.googlegroups.com> References: <58fb3ab8-9ec2-43a1-9b69-51803bdb4dbc@r66g2000hsg.googlegroups.com> Message-ID: <8209f740810210952v4cc25c0euff4cffa0e6bd77dc@mail.gmail.com> Erlang *is* strongly typed. It's not statically typed, but that's a different issue. Strongly typed = the type system cannot be subverted. BR, Ulf W 2008/10/21 Steve Davis : > I'm sure that there's a simple and convincing answer to this. > > I'm finding myself having to dig into the source code of libraries or > plough through often erratic documentation all the time which really > slows down productivity. Am I thinking about this all wrong? Is there > a guiding principle that will help me as I learn? > > TIA > /Steve > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From taavi@REDACTED Tue Oct 21 19:10:38 2008 From: taavi@REDACTED (Taavi Talvik) Date: Tue, 21 Oct 2008 20:10:38 +0300 Subject: [erlang-questions] Rather not - aintiquated build/deploy processes (Re: Why isn't erlang strongly typed?) In-Reply-To: References: <58fb3ab8-9ec2-43a1-9b69-51803bdb4dbc@r66g2000hsg.googlegroups.com> Message-ID: <8A7B5014-488C-42AF-9042-236A650B1A22@uninet.ee> On Oct 21, 2008, at 6:12 PM, Holger Hoffstaette wrote: > Unfortunately this and the rather antiquated build/deploy processes > are > really big (and unnecessary) inhibitors to more widespread adoption - > which is a shame, because the platform itself is solid and has a lot > to > offer. Erlang has enourmously strong foundation for build&deploy processes. - hot code loading - code replacement at runtime - erl_boot_server(3) - remote code loading - platform independent .beam format (almost, native depends on architecture) - release_handler(3) Remeber, this is only foundation and geared towards application domain of building reliable servers. For other domains, different build&deploy strategies fit better: - http://cean.process-one.net/ - http://www.trapexit.org/Maven_and_Erlang best regards, taavi From rvirding@REDACTED Tue Oct 21 20:41:37 2008 From: rvirding@REDACTED (Robert Virding) Date: Tue, 21 Oct 2008 20:41:37 +0200 Subject: [erlang-questions] Why isn't erlang strongly typed? In-Reply-To: <356d0fb3-c13d-43f2-ab2f-5f1aa9fd27df@l62g2000hse.googlegroups.com> References: <58fb3ab8-9ec2-43a1-9b69-51803bdb4dbc@r66g2000hsg.googlegroups.com> <97619b170810210745k921b46h427f0523d7c96082@mail.gmail.com> <356d0fb3-c13d-43f2-ab2f-5f1aa9fd27df@l62g2000hse.googlegroups.com> Message-ID: <3dbc6d1c0810211141m31b3412ai58d0812cdd0e2354@mail.gmail.com> I think a lot of confusion here among different issues: - Erlang is strongly typed, you cannot get around the type system and functions complain (generate exceptions) when they don't get the right types - It is, however, dynamically typed and not statically typed in that the types are checked at run time and not at compile time - If you deem the documentation and function arguments/returns to be confusing this has absolutely nothing to do with typing, whether strong, weak, static or dynamic. That it is dynamically typed really does help with hot code loading. Otherwise you either have static and unchangeable module interfaces or you could get a system which is *really* unsafe, a function is called with one data type and thinks it is getting another and doesn't check as it knows the compiler has checked. Distribution makes this problem worse. I will freely admit that some of the functions don't always have intuitive arguments, are inconsistent or otherwise don't uphold the principle of least surprise. One reason for this is that the system evolved rather freely over time and many things (useful) things were just added to the system without much consideration for consistency and such. And, as everyone who has tried, knows changing things afterwards is *not trivial*. Robert 2008/10/21 Steve Davis > On Oct 21, 9:45 am, Rapsey wrote: > > I don't understand. What does this have to do with the language being > > strongly typed? > > Well, the way I think about it is that types let you define what the > function expects, and what you can expect in return. So it would > provide a contract or agreed protocol in a far more cohesive way that > is possible right now in erlang (cf. "spec" and "record"). Types would > speed up coding as it would avoid you having to dig around in every > function's source to see what you should expect in return. There's > probably some fatal flaw in this thinking -- which is why I asked the > question :) > > /s > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From holger@REDACTED Tue Oct 21 20:24:57 2008 From: holger@REDACTED (Holger Hoffstaette) Date: Tue, 21 Oct 2008 20:24:57 +0200 Subject: [erlang-questions] Rather not - aintiquated build/deploy processes (Re: Why isn't erlang strongly typed?) References: <58fb3ab8-9ec2-43a1-9b69-51803bdb4dbc@r66g2000hsg.googlegroups.com> <8A7B5014-488C-42AF-9042-236A650B1A22@uninet.ee> Message-ID: On Tue, 21 Oct 2008 20:10:38 +0300, Taavi Talvik wrote: > Erlang has enourmously strong foundation for build&deploy processes. Yes, I understand all that. I was thinking about development, not operational concerns. The runtime properties are all very nice and well thought-out, no argument there. However, it is not clear to me why the domain necessitates user-hostile, platform-specific development tools like (e)make. I know that these things tend to "accidentally" happen, but regardless of the established history, one has to wonder exactly how often the good Erlang team was allowed to go into the big blue room known as "outside". :) Holger PS: please don't take this too seriously. I'm just miffed that so many Erlang modules are built with platform-specific Makefiles and Unixy paths. Good cross-platform toolchain support is rarely a technical problem. From jason.ganetsky@REDACTED Tue Oct 21 21:37:27 2008 From: jason.ganetsky@REDACTED (Jason Ganetsky) Date: Tue, 21 Oct 2008 15:37:27 -0400 Subject: [erlang-questions] Why isn't erlang strongly typed? In-Reply-To: <3dbc6d1c0810211141m31b3412ai58d0812cdd0e2354@mail.gmail.com> References: <58fb3ab8-9ec2-43a1-9b69-51803bdb4dbc@r66g2000hsg.googlegroups.com> <97619b170810210745k921b46h427f0523d7c96082@mail.gmail.com> <356d0fb3-c13d-43f2-ab2f-5f1aa9fd27df@l62g2000hse.googlegroups.com> <3dbc6d1c0810211141m31b3412ai58d0812cdd0e2354@mail.gmail.com> Message-ID: Dynamic typing also helps a lot with Erlang style message passing. If you want to see a statically typed language with almost-Erlang-like message passing, check out Phillip Wadler's Links. Erlang-style selective receive can't be done in Links (because its receive statement must exhaustively cover all patterns in order to type-check). In order to get similar functionality in a static typing environment, message passing must be replaced with a more complicated concurrency paradigm like join-calculus. Also, message passing complicates the typing system. Functions have a more complicated type (instead of A -> B... A ~ C -> B... which means the function can receive a message of type C while executing). All other statements have an implicit message type which depends on the context of the statements around it. It gets harder for the programmer to mentally type-check the program. Another issue with static typing arises when handling process death. Monitoring a process would require the type of the reason to match up with the code receiving the {'EXIT',...} message. So, every process is of type process (m, d)... where m is the type of message it can receive, and d is the type of the death reason. You would link() would only be able to called from process (a, _) onto process (_, a). It's restrictive. Anyway, I like static typing, but these issues would have to get solved. They are necessarily simple. 2008/10/21 Robert Virding > I think a lot of confusion here among different issues: > > - Erlang is strongly typed, you cannot get around the type system and > functions complain (generate exceptions) when they don't get the right types > - It is, however, dynamically typed and not statically typed in that the > types are checked at run time and not at compile time > - If you deem the documentation and function arguments/returns to be > confusing this has absolutely nothing to do with typing, whether strong, > weak, static or dynamic. > > That it is dynamically typed really does help with hot code loading. > Otherwise you either have static and unchangeable module interfaces or you > could get a system which is *really* unsafe, a function is called with one > data type and thinks it is getting another and doesn't check as it knows the > compiler has checked. Distribution makes this problem worse. > > I will freely admit that some of the functions don't always have intuitive > arguments, are inconsistent or otherwise don't uphold the principle of least > surprise. One reason for this is that the system evolved rather freely over > time and many things (useful) things were just added to the system without > much consideration for consistency and such. And, as everyone who has tried, > knows changing things afterwards is *not trivial*. > > Robert > > 2008/10/21 Steve Davis > > On Oct 21, 9:45 am, Rapsey wrote: >> > I don't understand. What does this have to do with the language being >> > strongly typed? >> >> Well, the way I think about it is that types let you define what the >> function expects, and what you can expect in return. So it would >> provide a contract or agreed protocol in a far more cohesive way that >> is possible right now in erlang (cf. "spec" and "record"). Types would >> speed up coding as it would avoid you having to dig around in every >> function's source to see what you should expect in return. There's >> probably some fatal flaw in this thinking -- which is why I asked the >> question :) >> >> /s >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From matthew@REDACTED Tue Oct 21 23:05:19 2008 From: matthew@REDACTED (Matthew Dempsky) Date: Tue, 21 Oct 2008 14:05:19 -0700 Subject: [erlang-questions] eheap_alloc crash when using mnesia In-Reply-To: <6a3ae47e0810210107u16f4c75fx27bc95ac2528e33a@mail.gmail.com> References: <72e228670810200633q1e17bf7alaab35cfb8c53e3b2@mail.gmail.com> <14f0e3620810200936j3f59bed3ybc4080b977dad0ff@mail.gmail.com> <6a3ae47e0810210107u16f4c75fx27bc95ac2528e33a@mail.gmail.com> Message-ID: On Tue, Oct 21, 2008 at 1:07 AM, Robert Raschke wrote: > Beware! With modern kernels it is no longer true that malloc always > fails if you run out of memory. Often you'll find it crashes upon > access of the allocated memory rather than on the call to malloc(). To my knowledge, Linux does this but allows you to disable it with a run-time kernel setting, and BSD does not. This understanding seems supported at least by PostgreSQL's documentation, which specifically calls out Linux's behavior and how to disable it without mentioning any other kernels: http://www.postgresql.org/docs/8.3/static/kernel-resources.html I'll admit to not having thoroughly researched the issue though. If someone can speak more authoritatively, I'm all ears. :-) From rtrlists@REDACTED Tue Oct 21 23:31:06 2008 From: rtrlists@REDACTED (Robert Raschke) Date: Tue, 21 Oct 2008 22:31:06 +0100 Subject: [erlang-questions] eheap_alloc crash when using mnesia In-Reply-To: References: <72e228670810200633q1e17bf7alaab35cfb8c53e3b2@mail.gmail.com> <14f0e3620810200936j3f59bed3ybc4080b977dad0ff@mail.gmail.com> <6a3ae47e0810210107u16f4c75fx27bc95ac2528e33a@mail.gmail.com> Message-ID: <6a3ae47e0810211431mb1749bfkde677c2aa69cd2bc@mail.gmail.com> On Tue, Oct 21, 2008 at 10:05 PM, Matthew Dempsky wrote: > On Tue, Oct 21, 2008 at 1:07 AM, Robert Raschke wrote: >> Beware! With modern kernels it is no longer true that malloc always >> fails if you run out of memory. Often you'll find it crashes upon >> access of the allocated memory rather than on the call to malloc(). > > To my knowledge, Linux does this but allows you to disable it with a > run-time kernel setting, and BSD does not. This understanding seems > supported at least by PostgreSQL's documentation, which specifically > calls out Linux's behavior and how to disable it without mentioning > any other kernels: > http://www.postgresql.org/docs/8.3/static/kernel-resources.html > > I'll admit to not having thoroughly researched the issue though. If > someone can speak more authoritatively, I'm all ears. :-) > Even though you should still check your return value from malloc() and react accordingly, this does not automatically mean that your program will be able to do anything usefull in an out of memory situation. Apart from aborting your program, what would be a sensible thing to do when you run out of memory? Its not like you would actually be able to give some mem back to the system and continue. At least not in any system that I've come across. In terms of Erlang, we're running in a VM, which I guess would appear to give the impression of allowing something more "sensible" to happen. But apart from telling the VM explicitly which processes it is allowed to abort and which not, in order to reclaim space, what is possible or desirable? And what kind of behaviour would be understandable? I'd have thought with the Erlang philosophy of "let it crash" we already have one answer. Turns out it's identical to what most (all?) OS'es do in this cirumstance. I'm not sure I would like a popup appearing telling me I'm low on memory and that I now have to choose whom to get killed. That just sounds like a "neat" marketing feature to me, rather than something actually useful in a production setting. Robby From matthew@REDACTED Tue Oct 21 23:46:59 2008 From: matthew@REDACTED (Matthew Dempsky) Date: Tue, 21 Oct 2008 14:46:59 -0700 Subject: [erlang-questions] eheap_alloc crash when using mnesia In-Reply-To: <6a3ae47e0810211431mb1749bfkde677c2aa69cd2bc@mail.gmail.com> References: <72e228670810200633q1e17bf7alaab35cfb8c53e3b2@mail.gmail.com> <14f0e3620810200936j3f59bed3ybc4080b977dad0ff@mail.gmail.com> <6a3ae47e0810210107u16f4c75fx27bc95ac2528e33a@mail.gmail.com> <6a3ae47e0810211431mb1749bfkde677c2aa69cd2bc@mail.gmail.com> Message-ID: On Tue, Oct 21, 2008 at 2:31 PM, Robert Raschke wrote: > Apart from aborting your program, what would be a sensible thing to do > when you run out of memory? Its not like you would actually be able to > give some mem back to the system and continue. At least not in any > system that I've come across. Simple example: dnscache from djbdns. Handling each new DNS query requires allocating some temporary space for domain names that it needs to resolve in the process. If it fails to allocate memory for a request at some point in the resolution process, it gives up on that query, frees any memory it used, and continues handling other queries. This is a far better solution than crashing and dropping *every* query *and* flushing the entire cache. The same principle applies to any process handling multiple requests simultaneously. From ahmed.nawras@REDACTED Tue Oct 21 23:56:15 2008 From: ahmed.nawras@REDACTED (Ahmed Ali) Date: Wed, 22 Oct 2008 01:56:15 +0400 Subject: [erlang-questions] Issue: erl/yaws init Message-ID: Hi all, I don't know if this is a erlang or yaws's issue. The first command below doesn't work while the second works. > yaws --conf yaws.conf --id my_app --daemon --pa ebin/ --erlarg -s\ application\ start\ my_app > yaws --conf yaws.conf --id my_app --daemon --pa ebin/ --erlarg -s\ web_utils\ init Although funciton web_utils:init/0 looks like below init() -> application:start(my_app). Did anyone face a similar issue before? Best regards, Ahmed From joelr1@REDACTED Tue Oct 21 23:56:43 2008 From: joelr1@REDACTED (Joel Reymont) Date: Tue, 21 Oct 2008 22:56:43 +0100 Subject: [erlang-questions] eunit and test timeouts Message-ID: I'm using eunit from the erlang prompt by invoking a module's test function. My issue is that tests run fine when invoked one by one but some randomly timeout when ran as a batch. Is there a way to increase the default timeout used by eunit when concurrently running all tests in a module (mod:test())? Thanks, Joel -- wagerlabs.com From jwecker@REDACTED Wed Oct 22 00:40:41 2008 From: jwecker@REDACTED (Joseph Wecker) Date: Tue, 21 Oct 2008 16:40:41 -0600 Subject: [erlang-questions] eunit and test timeouts In-Reply-To: References: Message-ID: <48FE5A69.3060209@entride.com> Joel Reymont wrote: > I'm using eunit from the erlang prompt by invoking a module's test > function. My issue is that tests run fine when invoked one by one but > some randomly timeout when ran as a batch. > > Is there a way to increase the default timeout used by eunit when > concurrently running all tests in a module (mod:test())? > > Thanks, Joel > > -- > wagerlabs.com > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > I had the same problem at one point- did something like this (obviously ignore the app specifics): load_test_() -> {inparallel, fetch_tests()}. fetch_tests() -> [ {"Plain fetch", {timeout, 100, ?_assertMatch(?FS_DATA, fetch_server:bfetch(?PLAIN_URL))}}, {"Plain fetch with Priority", {timeout, 100, ?_assertMatch(?FS_DATA, fetch_server:bfetch(?PLAIN_URL,"a00"))}}, ... etc... ]. - Joseph From cliff@REDACTED Wed Oct 22 00:51:03 2008 From: cliff@REDACTED (Cliff Moon) Date: Tue, 21 Oct 2008 15:51:03 -0700 Subject: [erlang-questions] eunit and test timeouts In-Reply-To: References: Message-ID: <48FE5CD7.2030101@moonpolysoft.com> You can return a structure describing a test from an underscore test method. Like so: my_built_test_() -> {timeout, 1200, [{?LINE, fun() -> test_something() end}]}. Joel Reymont wrote: > I'm using eunit from the erlang prompt by invoking a module's test > function. My issue is that tests run fine when invoked one by one but > some randomly timeout when ran as a batch. > > Is there a way to increase the default timeout used by eunit when > concurrently running all tests in a module (mod:test())? > > Thanks, Joel > > -- > wagerlabs.com > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > From ok@REDACTED Wed Oct 22 04:21:18 2008 From: ok@REDACTED (Richard O'Keefe) Date: Wed, 22 Oct 2008 15:21:18 +1300 Subject: [erlang-questions] Why isn't erlang strongly typed? In-Reply-To: <58fb3ab8-9ec2-43a1-9b69-51803bdb4dbc@r66g2000hsg.googlegroups.com> References: <58fb3ab8-9ec2-43a1-9b69-51803bdb4dbc@r66g2000hsg.googlegroups.com> Message-ID: <1929ACE1-C4D7-4972-B6D3-B58623B60C8A@cs.otago.ac.nz> On 22 Oct 2008, at 3:18 am, Steve Davis wrote: > I'm sure that there's a simple and convincing answer to this. Because Erlang was designed for systems that are supposed to be running all the time, even when you want to install upgraded software with *different* types. There have been several attempts to provide type systems for Erlang. It took a long time to get one that was found to be satisfactory in practice, but it's there now in documentation and in the Dialyzer and Typerl. However, even that system is not as expressive as one might wish. > > I'm finding myself having to dig into the source code of libraries or > plough through often erratic documentation all the time which really > slows down productivity. Am I thinking about this all wrong? Probably. Can you give an example of a problem you had recently where you found yourself digging into the source code? From ok@REDACTED Wed Oct 22 04:38:08 2008 From: ok@REDACTED (Richard O'Keefe) Date: Wed, 22 Oct 2008 15:38:08 +1300 Subject: [erlang-questions] List to proplist? In-Reply-To: <5ea453f90810210741j2f3805b6m48de8e80dbebaac1@mail.gmail.com> References: <6c2563b20810192156i7516e69aqb4d0eda2e1ee98d9@mail.gmail.com> <620F5FF0-93F8-4E0E-BBDA-5404E82BB054@cs.otago.ac.nz> <5ea453f90810210741j2f3805b6m48de8e80dbebaac1@mail.gmail.com> Message-ID: On 22 Oct 2008, at 3:41 am, Dave Smith wrote: > > This also my first introduction to unfold. I will definitely be > looking for application of this pattern in the future. It comes from the Haskell world, a strange place where people talk about "coinduction" and the like. The idea is actually quite simple. Given some kind of data structure, you ask "Could I view this as a list?" and the answer is yes if you can 1. classify it as empty (map it to []) 2. or non-empty, with an identified 2a. first element X and 2b. residue R, the same kind of data structure you started with. Step 2 gives you [X|R]. What's really interesting here is that an implementation strategy for list comprehensions somewhat different from the one we now have could fit unfolds in beautifully. Let's just consider a simple comprehension [E(X) || X <- L, F(X)] where E(X) is some expression whose value we want to collect and F(X) is some filter. This could be implemented as (quasi-Erlang pseudocode): ( %R := [], %L := L, loop case %L of [] -> break lists:reverse(%R) ; [H|T] -> %L := T, case H of X -> case F(X) of true -> %R := [E(X)|%R], continue ; false -> continue end ; _ -> continue end end end ) Now consider [E(X) || X <- unfold(State, Splitter), F(X)] This could be implemented as (quasi-Erlang pseudocode): ( %R := [], * %L := State, loop * case Splitter(%L) of [] -> break lists:reverse(%R) ; [H|T] -> %L := T, case H of X -> case F(X) of true -> %R := [E(X)|%R], continue ; false -> continue end ; _ -> continue end end end ) where the two lines I've starred are the only changes. It's even clearer once you realise that if L is a list, L = unfold(L, fun (X) -> X end). If the compiler were aware that lists:seq(From, To) = if is_integer(From), is_integer(To) -> unfold(From, fun (X) when X > To -> [] ; (X) -> [X|X+1] end) end then list comprehensions with numeric ranges would not actually require the generation of a real list. > From ok@REDACTED Wed Oct 22 04:47:02 2008 From: ok@REDACTED (Richard O'Keefe) Date: Wed, 22 Oct 2008 15:47:02 +1300 Subject: [erlang-questions] Why isn't erlang strongly typed? In-Reply-To: References: <58fb3ab8-9ec2-43a1-9b69-51803bdb4dbc@r66g2000hsg.googlegroups.com> Message-ID: <77E781FC-7723-4C51-986A-3F165D264AFA@cs.otago.ac.nz> > > This is a consequence of Erlangs incredibly unergonomic function/ > parameter > naming conventions and has little to do with strong typing (or its > absence). I have proposed in the past that Erlang should adopt Paul Lyons' "split procedure names" idea. Instead of call = [module:]name([expr{,expr}]) we take call = [module:]{name([expr{,expr}])}+ For example, instead of in_degree(G, V) you would have in_degree_of(V) in(G) My experience of Smalltalk is the same as Holger Hoffstaette's; the names tell you what the argument r?les are so that it is very unusual to get arguments confused. From ok@REDACTED Wed Oct 22 05:06:55 2008 From: ok@REDACTED (Richard O'Keefe) Date: Wed, 22 Oct 2008 16:06:55 +1300 Subject: [erlang-questions] Why isn't erlang strongly typed? In-Reply-To: References: <58fb3ab8-9ec2-43a1-9b69-51803bdb4dbc@r66g2000hsg.googlegroups.com> Message-ID: On 22 Oct 2008, at 4:47 am, > It's not only about the documentation - it's about the documented > functions itself too. My favourite example from mnesia - there's a two > parameters dirty_read function: > > dirty_read(Tab, Key) -> ValueList | exit({aborted, Reason} > > but there's no two parameters read function. Annoys the heck out of me > when I replace a dirty_read with a read and get a runtime error. As I understand it, we have dirty_read({Tab,Key}) -> dirty_read(Tab, Key) and read({Tab,Key}) -> ... so it should be possible to add read(Tab, Key) -> read({Tab,Key}) I've just sent off an EEP for this. Maybe that was the wrong thing to do. I'm sure someone @ericsson.com could have asked somebody to add this. From ok@REDACTED Wed Oct 22 05:19:11 2008 From: ok@REDACTED (Richard O'Keefe) Date: Wed, 22 Oct 2008 16:19:11 +1300 Subject: [erlang-questions] eheap_alloc crash when using mnesia In-Reply-To: References: <72e228670810200633q1e17bf7alaab35cfb8c53e3b2@mail.gmail.com> <14f0e3620810200936j3f59bed3ybc4080b977dad0ff@mail.gmail.com> <6a3ae47e0810210107u16f4c75fx27bc95ac2528e33a@mail.gmail.com> Message-ID: <1C55A148-9A40-458C-A167-0AE92C2B2321@cs.otago.ac.nz> I first heard of overcommitment in connection with AIX. That was about 15 years ago, I think. Running a little test program on my Solaris 2.10 box gave me the same amount of VM (modulo noise from other processes) whether I touched it or not. Sadly, in Mac OS X 10.5.5, the version that looped, allocating memory and initialising it, creashed with this message instead of simply returning NULL: yyy(2227) malloc: *** mmap(size=1048576) failed (error code=12) *** error: can't allocate region *** set a breakpoint in malloc_error_break to debug That does pretty horrible things to an argument I was making in another mailing list. Sigh. From mrad-direct-erlang@REDACTED Wed Oct 22 06:18:51 2008 From: mrad-direct-erlang@REDACTED (Michael Radford) Date: Tue, 21 Oct 2008 21:18:51 -0700 Subject: [erlang-questions] Why isn't erlang strongly typed? In-Reply-To: <1929ACE1-C4D7-4972-B6D3-B58623B60C8A@cs.otago.ac.nz> References: <58fb3ab8-9ec2-43a1-9b69-51803bdb4dbc@r66g2000hsg.googlegroups.com> <1929ACE1-C4D7-4972-B6D3-B58623B60C8A@cs.otago.ac.nz> Message-ID: <20081022041851.GA22961@herbie> Richard O'Keefe writes: > > I'm sure that there's a simple and convincing answer to this. > > Because Erlang was designed for systems that are > supposed to be running all the time, even when you > want to install upgraded software with *different* > types. > > There have been several attempts to provide type systems > for Erlang. It took a long time to get one that was > found to be satisfactory in practice, but it's there now > in documentation and in the Dialyzer and Typerl. I'm not familiar with Typerl, but Dialyzer only does static analysis for a single version of each module, right? (It provides no way to check the correctness of a code_change handler between two versions?) It seems to me that static typing in Erlang could work if there were a way to load multiple modules atomically. All exported functions would be annotated with the types of their arguments and return values, and all inter-module calls would be annotated with the types of the arguments passed and uses of return values. It could be illegal to perform a module load that resulted in badly typed inter-module calls. And when a load failed due to a type error, the previous version could continue running -- whereas today there will be a transient failure when an exception is raised. Other than the expense of all that type analysis (which could be done in advance for the versions involved, and just recorded in the compiled code), is there a flaw in this scheme? Sometimes the type inference would be intractable I guess. In those cases, a manual annotation could override the checking, and we'd be back to the possibility of a runtime exception. Still, this seems like an improvement over the current situation. Mike From bengt.kleberg@REDACTED Wed Oct 22 07:01:29 2008 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Wed, 22 Oct 2008 07:01:29 +0200 Subject: [erlang-questions] Issue: erl/yaws init In-Reply-To: References: Message-ID: <1224651689.1694.69.camel@seasc0642.dyn.rnd.as.sw.ericsson.se> Greetings, The flag -s can take ... That is a variable amount of arguments. To handle that, the arguments are assembled into a list before the call. In your case : application:start( [my_app] ) This is not the same as init() -> application:start(my_app). bengt On Wed, 2008-10-22 at 01:56 +0400, Ahmed Ali wrote: > Hi all, > > I don't know if this is a erlang or yaws's issue. The first command > below doesn't work while the second works. > > > yaws --conf yaws.conf --id my_app --daemon --pa ebin/ --erlarg -s\ application\ start\ my_app > > yaws --conf yaws.conf --id my_app --daemon --pa ebin/ --erlarg -s\ web_utils\ init > > Although funciton web_utils:init/0 looks like below > > init() -> > application:start(my_app). > > Did anyone face a similar issue before? > > Best regards, > > Ahmed > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From bengt.kleberg@REDACTED Wed Oct 22 07:14:56 2008 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Wed, 22 Oct 2008 07:14:56 +0200 Subject: [erlang-questions] Rather not - aintiquated build/deploy processes (Re: Why isn't erlang strongly typed?) In-Reply-To: References: <58fb3ab8-9ec2-43a1-9b69-51803bdb4dbc@r66g2000hsg.googlegroups.com> <8A7B5014-488C-42AF-9042-236A650B1A22@uninet.ee> Message-ID: <1224652496.1694.74.camel@seasc0642.dyn.rnd.as.sw.ericsson.se> Greetings, There is an erlang make tool that is platform agnostic. http://www.erlang.org/doc/man/make.html bengt On Tue, 2008-10-21 at 20:24 +0200, Holger Hoffstaette wrote: > On Tue, 21 Oct 2008 20:10:38 +0300, Taavi Talvik wrote: > > > Erlang has enourmously strong foundation for build&deploy processes. > > Yes, I understand all that. I was thinking about development, not > operational concerns. The runtime properties are all very nice and well > thought-out, no argument there. > > However, it is not clear to me why the domain necessitates user-hostile, > platform-specific development tools like (e)make. I know that these things > tend to "accidentally" happen, but regardless of the established history, > one has to wonder exactly how often the good Erlang team was allowed to go > into the big blue room known as "outside". :) > > Holger > > PS: please don't take this too seriously. I'm just miffed that so many > Erlang modules are built with platform-specific Makefiles and Unixy paths. > Good cross-platform toolchain support is rarely a technical problem. > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From dave.smith.to@REDACTED Wed Oct 22 07:48:44 2008 From: dave.smith.to@REDACTED (Dave Smith) Date: Wed, 22 Oct 2008 01:48:44 -0400 Subject: [erlang-questions] Rather not - aintiquated build/deploy processes (Re: Why isn't erlang strongly typed?) In-Reply-To: <1224652496.1694.74.camel@seasc0642.dyn.rnd.as.sw.ericsson.se> References: <58fb3ab8-9ec2-43a1-9b69-51803bdb4dbc@r66g2000hsg.googlegroups.com> <8A7B5014-488C-42AF-9042-236A650B1A22@uninet.ee> <1224652496.1694.74.camel@seasc0642.dyn.rnd.as.sw.ericsson.se> Message-ID: <5ea453f90810212248t77c50f88n3c72567958348d8f@mail.gmail.com> There are other build systems. Notably... http://maven-erlang.sourceforge.net/erlang-plugin/ http://www.erlware.org/tools/sinan/index.html 2008/10/22 Bengt Kleberg > Greetings, > > There is an erlang make tool that is platform agnostic. > http://www.erlang.org/doc/man/make.html > > > bengt > > On Tue, 2008-10-21 at 20:24 +0200, Holger Hoffstaette wrote: > > On Tue, 21 Oct 2008 20:10:38 +0300, Taavi Talvik wrote: > > > > > Erlang has enourmously strong foundation for build&deploy processes. > > > > Yes, I understand all that. I was thinking about development, not > > operational concerns. The runtime properties are all very nice and well > > thought-out, no argument there. > > > > However, it is not clear to me why the domain necessitates user-hostile, > > platform-specific development tools like (e)make. I know that these > things > > tend to "accidentally" happen, but regardless of the established history, > > one has to wonder exactly how often the good Erlang team was allowed to > go > > into the big blue room known as "outside". :) > > > > Holger > > > > PS: please don't take this too seriously. I'm just miffed that so many > > Erlang modules are built with platform-specific Makefiles and Unixy > paths. > > Good cross-platform toolchain support is rarely a technical problem. > > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dgud@REDACTED Wed Oct 22 09:09:37 2008 From: dgud@REDACTED (Dan Gudmundsson) Date: Wed, 22 Oct 2008 09:09:37 +0200 Subject: [erlang-questions] Why isn't erlang strongly typed? In-Reply-To: References: <58fb3ab8-9ec2-43a1-9b69-51803bdb4dbc@r66g2000hsg.googlegroups.com> Message-ID: <48FED1B1.6080902@erix.ericsson.se> There is a reason there is no mnesia:read/2 and it is that the third argument is the lock type which forces you to think what kind of lock you want on that object, there is no need for that on the dirty_* functions. It's no big deal to add it, but how many will use that instead of mnesia:read(Tab,Key,write) without thinking. /Dan PS: I still think that EEP's should be used for language or major library re-writes and not minor backward compatible changes. I don't want people to spend time on meaningless meatings discussing if mnesia api should have a read/2 or read/3 or both. Richard O'Keefe wrote: > On 22 Oct 2008, at 4:47 am, >> It's not only about the documentation - it's about the documented >> functions itself too. My favourite example from mnesia - there's a two >> parameters dirty_read function: >> >> dirty_read(Tab, Key) -> ValueList | exit({aborted, Reason} >> >> but there's no two parameters read function. Annoys the heck out of me >> when I replace a dirty_read with a read and get a runtime error. > > As I understand it, we have > > dirty_read({Tab,Key}) -> dirty_read(Tab, Key) > and > read({Tab,Key}) -> ... > > so it should be possible to add > > read(Tab, Key) -> read({Tab,Key}) > > I've just sent off an EEP for this. Maybe that was the wrong > thing to do. I'm sure someone @ericsson.com could have asked > somebody to add this. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From erlang@REDACTED Wed Oct 22 09:51:08 2008 From: erlang@REDACTED (Joe Armstrong) Date: Wed, 22 Oct 2008 09:51:08 +0200 Subject: [erlang-questions] Why isn't erlang strongly typed? In-Reply-To: <77E781FC-7723-4C51-986A-3F165D264AFA@cs.otago.ac.nz> References: <58fb3ab8-9ec2-43a1-9b69-51803bdb4dbc@r66g2000hsg.googlegroups.com> <77E781FC-7723-4C51-986A-3F165D264AFA@cs.otago.ac.nz> Message-ID: <9b08084c0810220051n6f9889adm95af0584d494a853@mail.gmail.com> That's really nice, sometime, almost as a joke I've written code like this in_degree_of(G, in, V) -> ... But I think your syntax is nicer - it's also reallly easy to implement - worth experimenting with I think /Joe On Wed, Oct 22, 2008 at 4:47 AM, Richard O'Keefe wrote: > >> >> This is a consequence of Erlangs incredibly unergonomic function/ >> parameter >> naming conventions and has little to do with strong typing (or its >> absence). > > I have proposed in the past that Erlang should adopt > Paul Lyons' "split procedure names" idea. > > Instead of > > call = [module:]name([expr{,expr}]) > > we take > > call = [module:]{name([expr{,expr}])}+ > > For example, instead of > > in_degree(G, V) > > you would have > > in_degree_of(V) in(G) > > My experience of Smalltalk is the same as Holger Hoffstaette's; > the names tell you what the argument r?les are so that it is > very unusual to get arguments confused. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From rtrlists@REDACTED Wed Oct 22 10:33:39 2008 From: rtrlists@REDACTED (Robert Raschke) Date: Wed, 22 Oct 2008 09:33:39 +0100 Subject: [erlang-questions] eheap_alloc crash when using mnesia In-Reply-To: References: <72e228670810200633q1e17bf7alaab35cfb8c53e3b2@mail.gmail.com> <14f0e3620810200936j3f59bed3ybc4080b977dad0ff@mail.gmail.com> <6a3ae47e0810210107u16f4c75fx27bc95ac2528e33a@mail.gmail.com> <6a3ae47e0810211431mb1749bfkde677c2aa69cd2bc@mail.gmail.com> Message-ID: <6a3ae47e0810220133j68680eaetac147102b9f4737f@mail.gmail.com> On Tue, Oct 21, 2008 at 10:46 PM, Matthew Dempsky wrote: > Simple example: dnscache from djbdns. Handling each new DNS query > requires allocating some temporary space for domain names that it > needs to resolve in the process. If it fails to allocate memory for a > request at some point in the resolution process, it gives up on that > query, frees any memory it used, and continues handling other queries. > This is a far better solution than crashing and dropping *every* > query *and* flushing the entire cache. Are you sure that uses plain old memory allocation for its cache entries (I haven't looked, I must admit)? The kind of cache handling you describe would most likely use it's own cache size management, otherwise it would be quite easy to mount a denial of service attack on this DNS server (i.e., crash it) by flooding it with lots of new domain names (assuming it doesn't have some other mechanism to detect this). > The same principle applies to any process handling multiple requests > simultaneously. I would guess that most programs that allow for this have limits set (if they don't have them explicitly, they'll be using the OS limits). If you're in control of those limits, then they are probably linked to things like available memory, bandwidth and other resources. I've never looked into the mechanisms that Erlang may provide for handling constrained memory. If I would want to write an Erlang server and make sure its memory consumption never grows beyond some limit, where would I start reading? Robby From zoltan.peter.toth@REDACTED Wed Oct 22 11:36:38 2008 From: zoltan.peter.toth@REDACTED (Zoltan Peter Toth) Date: Wed, 22 Oct 2008 11:36:38 +0200 Subject: [erlang-questions] clarify: Sending big messages Message-ID: <48FEF426.2070606@ericsson.com> Hi, We have a function like this: deliver(Port, Data) -> Port ! {data, Data}. This function returns Data. Let's assume we want to send a big binary. If we call deliver(Port, BigBinary), is there any performance penalty that results from handling the return value (that equals BigBinary) ? Can it cause extra CPU/memory consumption later on e.g. during garbage collection ? I.e. is it worth changing deliver() to return just ok ? (This would be probably a good idea if this function is invoked via rpc.) Best regs, /Zoltan From gleber.p@REDACTED Wed Oct 22 13:25:50 2008 From: gleber.p@REDACTED (Gleb Peregud) Date: Wed, 22 Oct 2008 13:25:50 +0200 Subject: [erlang-questions] clarify: Sending big messages In-Reply-To: <48FEF426.2070606@ericsson.com> References: <48FEF426.2070606@ericsson.com> Message-ID: <14f0e3620810220425v1d9f6604vcb7ad436c4ac3e29@mail.gmail.com> Hi, afaik, returning big terms will not degrade performance, since they are not copied - it is just "returning by reference". It also applies to big binaries. Correct me if I'm wrong. Sending terms in a message involves copying, except for binaries larger than 64bytes, which are referenced (and reference counted). Hence you are absolutely right about rpc invoking. BR, Gleb On 10/22/08, Zoltan Peter Toth wrote: > Hi, > > We have a function like this: > > deliver(Port, Data) -> > Port ! {data, Data}. > > This function returns Data. > Let's assume we want to send a big binary. If we call deliver(Port, > BigBinary), is there any performance > penalty that results from handling the return value (that equals > BigBinary) ? > > Can it cause extra CPU/memory consumption later on e.g. during garbage > collection ? > > I.e. is it worth changing deliver() to return just ok ? > (This would be probably a good idea if this function is invoked via rpc.) > > Best regs, > /Zoltan > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- Gleb Peregud http://gleber.pl/ Every minute is to be grasped. Time waits for nobody. -- Inscription on a Zen Gong From steven.charles.davis@REDACTED Wed Oct 22 14:01:19 2008 From: steven.charles.davis@REDACTED (Steve Davis) Date: Wed, 22 Oct 2008 05:01:19 -0700 (PDT) Subject: [erlang-questions] Why isn't erlang strongly typed? In-Reply-To: <20081022041851.GA22961@herbie> References: <58fb3ab8-9ec2-43a1-9b69-51803bdb4dbc@r66g2000hsg.googlegroups.com> <1929ACE1-C4D7-4972-B6D3-B58623B60C8A@cs.otago.ac.nz> <20081022041851.GA22961@herbie> Message-ID: <682a2670-e082-4652-aaca-180d27eb62b6@h2g2000hsg.googlegroups.com> Thanks for all the comments -- I really appreciate the quality of these responses! I am now receiving the following message: There isn't a simple answer. I guess if I accept Ulf's definition of strongly typed, then it's true that Erlang is "strongly typed", and mea culpa for using terminology that's known to be ambiguous, but I wasn't sure that confining the question to "statically typed" was the accurate way to phrase my query or to elicit a useful answer/discussion. I can see from reading Gleb and Robert's answers there would be issues with hot code loading, and also with selective receive as Jason pointed out. However, it seems that perhaps even these language design issues were not insurmountable (see Michael's post and also Richard/ Joe's comments). However, the fact remains that Erlang does essentially leave a library user in the dark at code level, since functions may return any data type at all depending on their arguments. When you are designing your pattern matches to extract/unpack/*use* return values it becomes onerous whenever the data type is non-trivial. Of course feeding in the "right" arguments bring similar issues of how to package them correctly. I tend to get lost quite quickly in the ream of balanced separators required (maybe that's just me). Yes, records do help here... perhaps they are the "right" answer, and should be more widely encouraged. With well documented libraries you have "spec" of course, but spec is essentially pseudocode that shores up the (inevitable?) lack of static typing in the code. As a result it's harder to read and breaks the flow as it takes you away from your code for too long. Perhaps more problematically, it takes a good deal of work to write a spec, so you can guarantee that 99.9% of library developers will avoid doing it if they can. Case in point - for some the the most popular and useful third party libraries, a familiar example would be "mochiweb", there's almost zero documentation. I suspect another reason is that it's almost as easy to read the code as it is to read the spec - in simpler cases it is actually *easier* to read the code than read a spec. All in all, pushing structured data around in Erlang takes a lot more care and thinking time than it could otherwise if there were better support for data structures in Erlang. Of course the issue here is what the word "better" would mean... blindly including constraints could easily mean throwing out the baby with the bathwater. I think I'm now resigned to the fact that this issue is not one that Erlang does solve or will solve. Perhaps whatever language that evolves from Erlang in the future will do so. Meantime... guess I will just have to accept the world for what it is. It's one of the sacrifices that must be made to get access to the enormous and fundamental benefits of the Erlang/OTP platform. /s From kostis@REDACTED Wed Oct 22 15:35:35 2008 From: kostis@REDACTED (Kostis Sagonas) Date: Wed, 22 Oct 2008 16:35:35 +0300 Subject: [erlang-questions] clarify: Sending big messages In-Reply-To: <48FEF426.2070606@ericsson.com> References: <48FEF426.2070606@ericsson.com> Message-ID: <48FF2C27.5090406@cs.ntua.gr> Zoltan Peter Toth wrote: > Hi, > > We have a function like this: > > deliver(Port, Data) -> > Port ! {data, Data}. > > This function returns Data. Nope. This function returns {data, Data}. I personally think that !/2 returning a value instead of being void as it should, is a design flow in the definition of the language. (*) > Let's assume we want to send a big binary. If we call deliver(Port, > BigBinary), is there any performance > penalty that results from handling the return value (that equals > BigBinary) ? > > Can it cause extra CPU/memory consumption later on e.g. during garbage > collection ? The time overhead is minimal, if any. > I.e. is it worth changing deliver() to return just ok ? > (This would be probably a good idea if this function is invoked via rpc.) It's not only worth, but it is actually a very good idea. It's not kosher having functions that you essentially treat as void returning things. The dialyzer option -Wunmatched_returns warns about this. Kostis (*) The only reason I could possibly see for this happening is that one can implement broadcast using P1 ! P2 ! ... ! Pn ! Msg, but I've yet to come across a program that uses the above idiom... Has anybody seen one? From nem@REDACTED Wed Oct 22 15:54:16 2008 From: nem@REDACTED (Geoff Cant) Date: Wed, 22 Oct 2008 15:54:16 +0200 Subject: [erlang-questions] API Design/Documentation [Was: Why isn't erlang strongly typed?] In-Reply-To: <682a2670-e082-4652-aaca-180d27eb62b6@h2g2000hsg.googlegroups.com> (Steve Davis's message of "Wed, 22 Oct 2008 05:01:19 -0700 (PDT)") References: <58fb3ab8-9ec2-43a1-9b69-51803bdb4dbc@r66g2000hsg.googlegroups.com> <1929ACE1-C4D7-4972-B6D3-B58623B60C8A@cs.otago.ac.nz> <20081022041851.GA22961@herbie> <682a2670-e082-4652-aaca-180d27eb62b6@h2g2000hsg.googlegroups.com> Message-ID: Steve Davis writes: > > However, the fact remains that Erlang does essentially leave a library > user in the dark at code level, since functions may return any data > type at all depending on their arguments. When you are designing your > pattern matches to extract/unpack/*use* return values it becomes > onerous whenever the data type is non-trivial. Of course feeding in > the "right" arguments bring similar issues of how to package them > correctly. I tend to get lost quite quickly in the ream of balanced > separators required (maybe that's just me). Yes, records do help > here... perhaps they are the "right" answer, and should be more widely > encouraged. Ack - yes, inconsistent return values from (3rd party?) library functions are annoying. This is just bad library API design and the author would probably be happy with a comment indicating this point of weakness (or a patch to fix it :). It's only in the last year or so that I've come to realise how small changes in ad-hoc datastructures (such as return values) can affect how easy it is to program with a library. A common case of this is returning tuples of varying arities - most often this requires the caller to have one case or function clause per possible arity, and this is frequently annoying. Returning records is somewhat frustrating too - this means that I as an API client need to include your code as a build dependency so I can -include the definition. This will recursively frustrate people that build on top of my code as to compile theirs they now have to compile yours and mine as well. The obvious alternative of retuning proplists for less-commonly used information is frustrating too as when I do need it, I have to call functions instead of patternmatching. e.g. Say you're writing a dns library - what whould dns:lookup(Name, Type) return? [#dns_rr{name,class,type,ttl,data},...] - now you need to -include() to use the code [{name,type,data,[{class,C},{ttl,TTL}]},...] - somewhat better until you want to examine the ttl of something and you need proplists:get_value(ttl,Info) instead of the pattern #dns_rr{ttl=TTL}. Regarding library documentation, I applaud the Erlware call for higher standards in 3rd party libraries and am working towards making more of my libraries comply. (http://www.erlware.org/development/standards.html) My own particular library rating scheme gives points for: * Low number of non-OTP library dependencies * Platform standard build infrastructure (make/erl -make in my case) * Ease of scm checkout -> working library (bonus point for a distributed scm - if I have to tweak the code then a dvcs make my life easier. bonus points for hosting on github) * OTP application packaging * Good API * Documented API * Example code * Compiler-warning free * Xref-warning free * Dialyzer warning free (well minimal) As a convenience matter it'd be nice if the shell would spit out function documentation if you try to tab complete on arguments. i.e. 1> erlang:setelement( setelement(Index, Tuple1, Value) -> Tuple2 Types: Index = 1..tuple_size(Tuple1) Tuple1 = Tuple2 = tuple() Value = term() 1> erlang:setelement( Cheers, -- Geoff Cant From raimo+erlang-questions@REDACTED Wed Oct 22 15:56:49 2008 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Wed, 22 Oct 2008 15:56:49 +0200 Subject: [erlang-questions] : Why isn't erlang strongly typed? In-Reply-To: <682a2670-e082-4652-aaca-180d27eb62b6@h2g2000hsg.googlegroups.com> References: <58fb3ab8-9ec2-43a1-9b69-51803bdb4dbc@r66g2000hsg.googlegroups.com> <1929ACE1-C4D7-4972-B6D3-B58623B60C8A@cs.otago.ac.nz> <20081022041851.GA22961@herbie> <682a2670-e082-4652-aaca-180d27eb62b6@h2g2000hsg.googlegroups.com> Message-ID: <20081022135649.GB31458@erix.ericsson.se> On Wed, Oct 22, 2008 at 05:01:19AM -0700, Steve Davis wrote: > Thanks for all the comments -- I really appreciate the quality of > these responses! > > I am now receiving the following message: There isn't a simple answer. > > I guess if I accept Ulf's definition of strongly typed, then it's true > that Erlang is "strongly typed", and mea culpa for using terminology > that's known to be ambiguous, but I wasn't sure that confining the > question to "statically typed" was the accurate way to phrase my query > or to elicit a useful answer/discussion. > > I can see from reading Gleb and Robert's answers there would be issues > with hot code loading, and also with selective receive as Jason > pointed out. However, it seems that perhaps even these language design > issues were not insurmountable (see Michael's post and also Richard/ > Joe's comments). > > However, the fact remains that Erlang does essentially leave a library > user in the dark at code level, since functions may return any data > type at all depending on their arguments. When you are designing your > pattern matches to extract/unpack/*use* return values it becomes > onerous whenever the data type is non-trivial. Of course feeding in I am maybe missing a point here, but "the Erlang way" here is often to assume you get what you expected, run along and process the data, and when you get something unexpected, thanks to the strong typing, you will get a crashed process. And this you take care of by using OTP supervision trees that handle the error and restart the task. The code you see is the code for the correct data flow. > the "right" arguments bring similar issues of how to package them > correctly. I tend to get lost quite quickly in the ream of balanced > separators required (maybe that's just me). Yes, records do help > here... perhaps they are the "right" answer, and should be more widely > encouraged. > > With well documented libraries you have "spec" of course, but spec is > essentially pseudocode that shores up the (inevitable?) lack of static > typing in the code. As a result it's harder to read and breaks the > flow as it takes you away from your code for too long. Perhaps more > problematically, it takes a good deal of work to write a spec, so you > can guarantee that 99.9% of library developers will avoid doing it if > they can. Case in point - for some the the most popular and useful > third party libraries, a familiar example would be "mochiweb", there's > almost zero documentation. I suspect another reason is that it's > almost as easy to read the code as it is to read the spec - in simpler > cases it is actually *easier* to read the code than read a spec. > > All in all, pushing structured data around in Erlang takes a lot more > care and thinking time than it could otherwise if there were better > support for data structures in Erlang. Of course the issue here is > what the word "better" would mean... blindly including constraints > could easily mean throwing out the baby with the bathwater. > > I think I'm now resigned to the fact that this issue is not one that > Erlang does solve or will solve. Perhaps whatever language that > evolves from Erlang in the future will do so. Meantime... guess I will > just have to accept the world for what it is. It's one of the > sacrifices that must be made to get access to the enormous and > fundamental benefits of the Erlang/OTP platform. > > /s > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From ulf@REDACTED Wed Oct 22 16:00:11 2008 From: ulf@REDACTED (Ulf Wiger) Date: Wed, 22 Oct 2008 16:00:11 +0200 Subject: [erlang-questions] clarify: Sending big messages In-Reply-To: <48FF2C27.5090406@cs.ntua.gr> References: <48FEF426.2070606@ericsson.com> <48FF2C27.5090406@cs.ntua.gr> Message-ID: <8209f740810220700x250f7ce5r718bdd5d9f981994@mail.gmail.com> 2008/10/22 Kostis Sagonas : > > (*) The only reason I could possibly see for this happening is that one > can implement broadcast using P1 ! P2 ! ... ! Pn ! Msg, but I've yet to > come across a program that uses the above idiom... Has anybody seen one? Yes, Joe has sported this sort of programming on occasion. Whether he's done anything really useful with it is a matter of interpretation. ;-) I don't recall where he's used it, but I know he has. BR, Ulf W From bqt@REDACTED Wed Oct 22 16:22:00 2008 From: bqt@REDACTED (Johnny Billquist) Date: Wed, 22 Oct 2008 16:22:00 +0200 Subject: [erlang-questions] clarify: Sending big messages In-Reply-To: <48FF2C27.5090406@cs.ntua.gr> References: <48FEF426.2070606@ericsson.com> <48FF2C27.5090406@cs.ntua.gr> Message-ID: <48FF3708.2060802@softjar.se> Kostis Sagonas wrote: > Zoltan Peter Toth wrote: >> Hi, >> >> We have a function like this: >> >> deliver(Port, Data) -> >> Port ! {data, Data}. >> >> This function returns Data. > > Nope. This function returns {data, Data}. > > I personally think that !/2 returning a value instead of being void as > it should, is a design flow in the definition of the language. (*) ??? Erlang is a functional language. Everything returns something. There is no "void". Maybe it should always return "ok" instead, but I think it's better it returns the expression sent, in case you do want to play around with it somehow. Johnny From rvirding@REDACTED Wed Oct 22 16:25:37 2008 From: rvirding@REDACTED (Robert Virding) Date: Wed, 22 Oct 2008 16:25:37 +0200 Subject: [erlang-questions] clarify: Sending big messages In-Reply-To: <48FF2C27.5090406@cs.ntua.gr> References: <48FEF426.2070606@ericsson.com> <48FF2C27.5090406@cs.ntua.gr> Message-ID: <3dbc6d1c0810220725p6c2e89f8kaaee84e383e53b5@mail.gmail.com> 2008/10/22 Kostis Sagonas > Zoltan Peter Toth wrote: > > Hi, > > > > We have a function like this: > > > > deliver(Port, Data) -> > > Port ! {data, Data}. > > > > This function returns Data. > > Nope. This function returns {data, Data}. > > I personally think that !/2 returning a value instead of being void as > it should, is a design flow in the definition of the language. (*) Trouble is there is no void data type and every expression must return a value. So we decided that as it must return something it might as well return something useful, so why not the message? Personally I think this is better than returning 'ok' or 'void'. How would you handle a void return anyway? Can you put in a tuple and send it? Or just return it and never use it, except to return it again as in the deliver example. Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: From kostis@REDACTED Wed Oct 22 16:31:42 2008 From: kostis@REDACTED (Kostis Sagonas) Date: Wed, 22 Oct 2008 17:31:42 +0300 Subject: [erlang-questions] clarify: Sending big messages In-Reply-To: <48FF3708.2060802@softjar.se> References: <48FEF426.2070606@ericsson.com> <48FF2C27.5090406@cs.ntua.gr> <48FF3708.2060802@softjar.se> Message-ID: <48FF394E.2030306@cs.ntua.gr> Johnny Billquist wrote: > Kostis Sagonas wrote: >> Zoltan Peter Toth wrote: >>> Hi, >>> >>> We have a function like this: >>> >>> deliver(Port, Data) -> >>> Port ! {data, Data}. >>> >>> This function returns Data. >> >> Nope. This function returns {data, Data}. >> >> I personally think that !/2 returning a value instead of being void as >> it should, is a design flow in the definition of the language. (*) > > ??? > Erlang is a functional language. Everything returns something. Well, not quite. For example the following function does not return anything at all: foo() -> exit("hello world"). Here is another one: bar() -> throw(42). One more: loop(State) -> NewState = do_something_with(State), loop(NewState). > There is no "void". > Maybe it should always return "ok" instead, Of course that's what pretty much what I meant. In today's state of Erlang, it should return 'ok' (the atom, not the string). In an ideal world, it should return an opaque value (unit?) which, in some sense, is the equivalent of the function being void. > but I think it's better it > returns the expression sent, in case you do want to play around with it > somehow. You are of course entitled to this opinion. Kostis From Bill.McKeeman@REDACTED Wed Oct 22 16:42:09 2008 From: Bill.McKeeman@REDACTED (Bill McKeeman) Date: Wed, 22 Oct 2008 10:42:09 -0400 Subject: [erlang-questions] clarify: Sending big messages In-Reply-To: <3dbc6d1c0810220725p6c2e89f8kaaee84e383e53b5@mail.gmail.com> References: <48FEF426.2070606@ericsson.com> <48FF2C27.5090406@cs.ntua.gr> <3dbc6d1c0810220725p6c2e89f8kaaee84e383e53b5@mail.gmail.com> Message-ID: The Armstrong book says A ! B ! C ! msg is convenient when one message must go several places. It seems simple enough to add a line with void or ok to your function if that is what you want. /s/ Bill ________________________________ From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Robert Virding Sent: Wednesday, October 22, 2008 10:26 AM To: Kostis Sagonas Cc: erlang-questions@REDACTED Subject: Re: [erlang-questions] clarify: Sending big messages 2008/10/22 Kostis Sagonas > Zoltan Peter Toth wrote: > Hi, > > We have a function like this: > > deliver(Port, Data) -> > Port ! {data, Data}. > > This function returns Data. Nope. This function returns {data, Data}. I personally think that !/2 returning a value instead of being void as it should, is a design flow in the definition of the language. (*) Trouble is there is no void data type and every expression must return a value. So we decided that as it must return something it might as well return something useful, so why not the message? Personally I think this is better than returning 'ok' or 'void'. How would you handle a void return anyway? Can you put in a tuple and send it? Or just return it and never use it, except to return it again as in the deliver example. Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: From zoltan.peter.toth@REDACTED Wed Oct 22 16:44:53 2008 From: zoltan.peter.toth@REDACTED (Zoltan Peter Toth) Date: Wed, 22 Oct 2008 16:44:53 +0200 Subject: [erlang-questions] clarify: Sending big messages In-Reply-To: <3dbc6d1c0810220725p6c2e89f8kaaee84e383e53b5@mail.gmail.com> References: <48FEF426.2070606@ericsson.com> <48FF2C27.5090406@cs.ntua.gr> <3dbc6d1c0810220725p6c2e89f8kaaee84e383e53b5@mail.gmail.com> Message-ID: <48FF3C65.1040705@ericsson.com> > > deliver(Port, Data) -> > > Port ! {data, Data}. > > > > This function returns Data. > > Nope. This function returns {data, Data}. > Oops, sorry. Such things will not bypass the attention of the creator of dialyzer, though :))) > > I personally think that !/2 returning a value instead of being void as > it should, is a design flow in the definition of the language. (*) > > > Trouble is there is no void data type and every expression must return > a value. So we decided that as it must return something it might as > well return something useful, so why not the message? Personally I > think this is better than returning 'ok' or 'void'. It's probably a matter of taste... however, imho: - the message to be sent is obviously available in the function invoking !/2. I see no gain from returning it. If one needs it, it can be bound to a variable before sending. - it would be safer to return ok: otherwise it's easy to cause trouble with an unconsidered rpc. It's easy to run into that if one calls a function via rpc that calls others locally, and the call stack may somehow end with a !/2 in certain cases. /Zoltan From vychodil.hynek@REDACTED Wed Oct 22 16:47:38 2008 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Wed, 22 Oct 2008 16:47:38 +0200 Subject: [erlang-questions] clarify: Sending big messages In-Reply-To: <48FF394E.2030306@cs.ntua.gr> References: <48FEF426.2070606@ericsson.com> <48FF2C27.5090406@cs.ntua.gr> <48FF3708.2060802@softjar.se> <48FF394E.2030306@cs.ntua.gr> Message-ID: <20081022144739.6D26F24063@relay.gooddata.com> On Wed, Oct 22, 2008 at 4:31 PM, Kostis Sagonas wrote: > Johnny Billquist wrote: > > Kostis Sagonas wrote: > >> Zoltan Peter Toth wrote: > >>> Hi, > >>> > >>> We have a function like this: > >>> > >>> deliver(Port, Data) -> > >>> Port ! {data, Data}. > >>> > >>> This function returns Data. > >> > >> Nope. This function returns {data, Data}. > >> > >> I personally think that !/2 returning a value instead of being void as > >> it should, is a design flow in the definition of the language. (*) > > > > ??? > > Erlang is a functional language. Everything returns something. > > Well, not quite. > For example the following function does not return anything at all: > > foo() -> exit("hello world"). > > Here is another one: > > bar() -> throw(42). > > One more: > > loop(State) -> > NewState = do_something_with(State), > loop(NewState). Yes, those function doesn't return at all, it is not same as return nothing. Well to clarify it, each function return some value or crash (raise exception). There is not any function returning nothing so claim "Everything returns something" is true with little add-on, "if returns". > > > > There is no "void". > > Maybe it should always return "ok" instead, > > Of course that's what pretty much what I meant. In today's state of > Erlang, it should return 'ok' (the atom, not the string). In an ideal > world, it should return an opaque value (unit?) which, in some sense, is > the equivalent of the function being void. Why? Why there should be this extra unit? > > > > but I think it's better it > > returns the expression sent, in case you do want to play around with it > > somehow. > > You are of course entitled to this opinion. > > Kostis > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- --Hynek (Pichi) Vychodil -------------- next part -------------- An HTML attachment was scrubbed... URL: From kevin@REDACTED Wed Oct 22 16:51:45 2008 From: kevin@REDACTED (Kevin Scaldeferri) Date: Wed, 22 Oct 2008 07:51:45 -0700 Subject: [erlang-questions] Why isn't erlang strongly typed? In-Reply-To: <682a2670-e082-4652-aaca-180d27eb62b6@h2g2000hsg.googlegroups.com> References: <58fb3ab8-9ec2-43a1-9b69-51803bdb4dbc@r66g2000hsg.googlegroups.com> <1929ACE1-C4D7-4972-B6D3-B58623B60C8A@cs.otago.ac.nz> <20081022041851.GA22961@herbie> <682a2670-e082-4652-aaca-180d27eb62b6@h2g2000hsg.googlegroups.com> Message-ID: On Oct 22, 2008, at 5:01 AM, Steve Davis wrote: > I am now receiving the following message: There isn't a simple answer. > > I guess if I accept Ulf's definition of strongly typed, then it's true > that Erlang is "strongly typed", and mea culpa for using terminology > that's known to be ambiguous, but I wasn't sure that confining the > question to "statically typed" was the accurate way to phrase my query > or to elicit a useful answer/discussion. You don't have to "accept Ulf's definition". Strong typing and static typing mean entirely different things. Many people misunderstand this (which is odd because the most popular statically typed languages are rather weakly typed), but that doesn't mean that they don't have definitions which are being abused. -kevin From adrian.balij@REDACTED Tue Oct 21 22:24:39 2008 From: adrian.balij@REDACTED (adrian.balij@REDACTED) Date: Tue, 21 Oct 2008 16:24:39 -0400 (Eastern Daylight Time) Subject: [erlang-questions] global:registered_names() returns [] Message-ID: <156a5cebc785889bd6284b2a1f09997a.squirrel@pop.musket.ca> Hello everyone, I am fairly new to Erlang and I have been trying to setup a gen_server so that other nodes can communicate with it. However, on the client nodes, every time I call global:registered_names(), it returns []. The odd thing is on the server node, calling global:registered_names() returns [account_monitor]. I am running two consoles on the same computer using the following commands: erl -sname a@REDACTED -setcookie Test erl -sname b@REDACTED -setcookie Test Both consoles can ping each other. My start function is: % Initialize routine start_link() -> gen_server:start_link({global, ?MODULE}, ?MODULE, [], []). where ?MODULE = account_monitor. I tried calling net_adm:world() and global:sync() and no luck at all! The gen_server works fine (and by fine, I mean calling gen_server:call(...)) when I start it locally (start_link({local, ?MODULE} ....). Any help or suggestions would be extremely helpful at this point! Additional info: - OS: Leopard 10.5 - Erang bin: Sep 3, 2008 Thank you for your time, Adrian Balij From pfisher@REDACTED Wed Oct 22 19:00:59 2008 From: pfisher@REDACTED (Paul Fisher) Date: Wed, 22 Oct 2008 12:00:59 -0500 Subject: [erlang-questions] global:registered_names() returns [] In-Reply-To: <156a5cebc785889bd6284b2a1f09997a.squirrel@pop.musket.ca> References: <156a5cebc785889bd6284b2a1f09997a.squirrel@pop.musket.ca> Message-ID: <48FF5C4B.2060907@alertlogic.net> adrian.balij@REDACTED wrote: > Hello everyone, > > I am fairly new to Erlang and I have been trying to setup a gen_server so > that other nodes can communicate with it. However, on the client nodes, > every time I call global:registered_names(), it returns []. The odd thing > is on the server node, calling global:registered_names() returns > [account_monitor]. > > I am running two consoles on the same computer using the following commands: > > erl -sname a@REDACTED -setcookie Test > > erl -sname b@REDACTED -setcookie Test > > Both consoles can ping each other. > > My start function is: > > % Initialize routine > start_link() -> gen_server:start_link({global, ?MODULE}, ?MODULE, [], []). > > where ?MODULE = account_monitor. > > I tried calling net_adm:world() and global:sync() and no luck at all! Do you have a $HOME/.hosts.erlang file with the following: 'localhost'. (end file with empty line) -- paul From als@REDACTED Wed Oct 22 19:45:44 2008 From: als@REDACTED (Anthony Shipman) Date: Thu, 23 Oct 2008 04:45:44 +1100 Subject: [erlang-questions] a surprising atom Message-ID: <200810230445.44576.als@iinet.net.au> Eshell V5.6.4 (abort with ^G) 1> X = ''. '' 2> is_atom(X). true -- Anthony Shipman Mamas don't let your babies als@REDACTED grow up to be outsourced. From ulf@REDACTED Wed Oct 22 20:08:12 2008 From: ulf@REDACTED (Ulf Wiger) Date: Wed, 22 Oct 2008 20:08:12 +0200 Subject: [erlang-questions] a surprising atom In-Reply-To: <200810230445.44576.als@iinet.net.au> References: <200810230445.44576.als@iinet.net.au> Message-ID: <8209f740810221108j1001edcsd0bef432c520321@mail.gmail.com> Well, since [] (or "") is a valid string, and list_to_atom/1 will convert a valid string to a valid atom*, it's perfectly logical that there should be an "empty atom" as well. * There is a system limit on how many characters can be used in an atom, so list_to_atom/1 in fact *wont* work on strings of length > 255. But "" is even a pretty common string, so it would be more frustrating if list_to_atom([]) didn't work. BR, Ulf W 2008/10/22 Anthony Shipman : > Eshell V5.6.4 (abort with ^G) > 1> X = ''. > '' > 2> is_atom(X). > true > > -- > Anthony Shipman Mamas don't let your babies > als@REDACTED grow up to be outsourced. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From bob@REDACTED Wed Oct 22 20:08:13 2008 From: bob@REDACTED (Bob Ippolito) Date: Wed, 22 Oct 2008 11:08:13 -0700 Subject: [erlang-questions] a surprising atom In-Reply-To: <200810230445.44576.als@iinet.net.au> References: <200810230445.44576.als@iinet.net.au> Message-ID: <6a36e7290810221108pade346eg9b082e2e335fa30b@mail.gmail.com> Why is that surprising? Is it any more surprising than this? 1> list_to_atom([0]). '\000' 2> list_to_atom([255]). ? On Wed, Oct 22, 2008 at 10:45 AM, Anthony Shipman wrote: > Eshell V5.6.4 (abort with ^G) > 1> X = ''. > '' > 2> is_atom(X). > true > > -- > Anthony Shipman Mamas don't let your babies > als@REDACTED grow up to be outsourced. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From matthew@REDACTED Wed Oct 22 20:28:22 2008 From: matthew@REDACTED (Matthew Dempsky) Date: Wed, 22 Oct 2008 11:28:22 -0700 Subject: [erlang-questions] eheap_alloc crash when using mnesia In-Reply-To: <6a3ae47e0810220133j68680eaetac147102b9f4737f@mail.gmail.com> References: <72e228670810200633q1e17bf7alaab35cfb8c53e3b2@mail.gmail.com> <14f0e3620810200936j3f59bed3ybc4080b977dad0ff@mail.gmail.com> <6a3ae47e0810210107u16f4c75fx27bc95ac2528e33a@mail.gmail.com> <6a3ae47e0810211431mb1749bfkde677c2aa69cd2bc@mail.gmail.com> <6a3ae47e0810220133j68680eaetac147102b9f4737f@mail.gmail.com> Message-ID: On Wed, Oct 22, 2008 at 1:33 AM, Robert Raschke wrote: > Are you sure that uses plain old memory allocation for its cache > entries (I haven't looked, I must admit)? Yes, I chose dnscache as a concrete example because it's a server whose internals I'm thoroughly familiar with. :-) dnscache allocates a big chunk of memory (1000000 bytes by default) up front for cache storage, but while processing requests, it allocates additional memory for temporary storage for names relevant to the resolution process. E.g., if a cache receives a query for "www.erlang.org", it allocate 16 bytes to store that name. While resolving this query, it also allocates temporary space for "a.root-servers.net", "d0.org.afilias-nst.org", "ns.erlang.org", and so on. Names are promptly freed as soon as they are no longer needed, but if allocating space for one of these names fails, then dnscache gives up on resolving "www.erlang.org" and the user tries again later. From ulf@REDACTED Wed Oct 22 20:36:37 2008 From: ulf@REDACTED (Ulf Wiger) Date: Wed, 22 Oct 2008 20:36:37 +0200 Subject: [erlang-questions] a surprising atom In-Reply-To: <6a36e7290810221108pade346eg9b082e2e335fa30b@mail.gmail.com> References: <200810230445.44576.als@iinet.net.au> <6a36e7290810221108pade346eg9b082e2e335fa30b@mail.gmail.com> Message-ID: <8209f740810221136k3f654b7h251635c9e0ebe2b@mail.gmail.com> 2008/10/22 Bob Ippolito : > Why is that surprising? Is it any more surprising than this? > > 1> list_to_atom([0]). > '\000' > 2> list_to_atom([255]). > ? I think that has to do with your tty settings. For me it's: 11> list_to_atom([255]). ? (However that displays on your end, but to me it looks like a small y with diaeresis.) BR, Ulf W > > On Wed, Oct 22, 2008 at 10:45 AM, Anthony Shipman wrote: >> Eshell V5.6.4 (abort with ^G) >> 1> X = ''. >> '' >> 2> is_atom(X). >> true >> >> -- >> Anthony Shipman Mamas don't let your babies >> als@REDACTED grow up to be outsourced. >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From matthew@REDACTED Wed Oct 22 20:48:56 2008 From: matthew@REDACTED (Matthew Dempsky) Date: Wed, 22 Oct 2008 11:48:56 -0700 Subject: [erlang-questions] a surprising atom In-Reply-To: <8209f740810221136k3f654b7h251635c9e0ebe2b@mail.gmail.com> References: <200810230445.44576.als@iinet.net.au> <6a36e7290810221108pade346eg9b082e2e335fa30b@mail.gmail.com> <8209f740810221136k3f654b7h251635c9e0ebe2b@mail.gmail.com> Message-ID: On Wed, Oct 22, 2008 at 11:36 AM, Ulf Wiger wrote: > I think that has to do with your tty settings. For me it's: I think the emphasis was on atoms being arbitrary strings. > 11> list_to_atom([255]). > ? Your terminal is broken. It's using ISO 8859-1 when it should be using UTF-8. ;-) From ulf@REDACTED Wed Oct 22 21:08:29 2008 From: ulf@REDACTED (Ulf Wiger) Date: Wed, 22 Oct 2008 21:08:29 +0200 Subject: [erlang-questions] a surprising atom In-Reply-To: References: <200810230445.44576.als@iinet.net.au> <6a36e7290810221108pade346eg9b082e2e335fa30b@mail.gmail.com> <8209f740810221136k3f654b7h251635c9e0ebe2b@mail.gmail.com> Message-ID: <8209f740810221208u75096af0le030c186b5f0ab6c@mail.gmail.com> 2008/10/22 Matthew Dempsky : > On Wed, Oct 22, 2008 at 11:36 AM, Ulf Wiger wrote: >> I think that has to do with your tty settings. For me it's: > > I think the emphasis was on atoms being arbitrary strings. They can be. If they contain non-alphanumeric characters, they should be quoted, and the first one ('\000') was. The other one wasn't, since, apparently, Erlang considers it a character. > >> 11> list_to_atom([255]). >> ? > > Your terminal is broken. It's using ISO 8859-1 when it should be > using UTF-8. ;-) Yeah, well it's coLinux with Finnish language settings (since the Swedish one didn't work at all), so it's broken alright. (: Still, ÿ is part of the Latin-1 character set, which is what Erlang uses. BR, Ulf W From sgrady@REDACTED Wed Oct 22 21:20:32 2008 From: sgrady@REDACTED (Steven Grady) Date: Wed, 22 Oct 2008 12:20:32 -0700 Subject: [erlang-questions] confusing message behavior Message-ID: <7EB15192-5EC3-4A8E-8E0E-F2DE42181304@hi5.com> Can someone explain why some messages are thrown away when doing a "receive" from the command line? $ cat test.erl -module(test). -export([m/0, g/0]). m() -> self() ! a, self() ! b. g() -> receive X -> X after 100 -> timeout end. Bad behavior ("a" is received, but not "b"): $ erl Erlang (BEAM) emulator version 5.6.2 [source] [async-threads:0] [kernel-poll:false] Eshell V5.6.2 (abort with ^G) 1> test:m(). b 2> receive X -> X after 100 -> timeout end. a 3> receive X -> X after 100 -> timeout end. timeout 4> Good behavior (both messages are received): $ erl Erlang (BEAM) emulator version 5.6.2 [source] [async-threads:0] [kernel-poll:false] Eshell V5.6.2 (abort with ^G) 1> test:m(). b 2> test:g(). a 3> test:g(). b 4> test:g(). timeout 5> Steven From sgrady@REDACTED Wed Oct 22 21:14:20 2008 From: sgrady@REDACTED (Steven Grady) Date: Wed, 22 Oct 2008 12:14:20 -0700 Subject: [erlang-questions] confusing message behavior Message-ID: <34846908-B933-4D12-AD41-A2ACB9284089@hi5.com> Can someone explain why some messages are thrown away when doing a "receive" from the command line? $ cat test.erl -module(test). -export([m/0, g/0]). m() -> self() ! a, self() ! b. g() -> receive X -> X after 100 -> timeout end. Bad behavior ("a" is received, but not "b"): $ erl Erlang (BEAM) emulator version 5.6.2 [source] [async-threads:0] [kernel-poll:false] Eshell V5.6.2 (abort with ^G) 1> test:m(). b 2> receive X -> X after 100 -> timeout end. a 3> receive X -> X after 100 -> timeout end. timeout 4> Good behavior (both messages are received): $ erl Erlang (BEAM) emulator version 5.6.2 [source] [async-threads:0] [kernel-poll:false] Eshell V5.6.2 (abort with ^G) 1> test:m(). b 2> test:g(). a 3> test:g(). b 4> test:g(). timeout 5> Steven From adrian.balij@REDACTED Wed Oct 22 21:48:01 2008 From: adrian.balij@REDACTED (Adrian Balij) Date: Wed, 22 Oct 2008 15:48:01 -0400 Subject: [erlang-questions] global:registered_names() returns [] In-Reply-To: References: Message-ID: <048301c9347f$1b29b960$517d2c20$@balij@musket.ca> Thank you Andrew, that did work and I was able to see the registered names on both nodes. It is odd how in books such as Programming Erlang by Joe and the videos by Kevin Smith never mention the need to use net_kernel:connect and somehow their examples seem to work. Maybe I missed something or my lack of experience cannot answer this odd scenario. Although your solution worked, I ran into another problem. Both nodes can see the registered names: [account_monitor] However, when I call gen_server:start_link for the first time, the name does not get registered! However any subsequent calls (without terminating the node) causes the process to register!! On top of that, when I call gen_server:call(account_monitor, getOnlineUsers) , I get the error: *exception exit: {noproc, {gen_server, call,[account_monitor, getOnlineUsers]}} Any have any ideas why? Sincerely, Adrian Balij Software Engineer Musket/Melburn Group -----Original Message----- From: Andrew Stone [mailto:stondage123@REDACTED] Sent: October 22, 2008 1:05 PM To: adrian.balij@REDACTED Subject: Re: [erlang-questions] global:registered_names() returns [] Adrian, I think you want to call net_kernel:connect right before you call global:sync. That will actually connect the two nodes. Then global:sync will synch the names on each node. -Andrew ----- Original Message ---- From: "adrian.balij@REDACTED" To: erlang-questions@REDACTED Sent: Tuesday, October 21, 2008 4:24:39 PM Subject: [erlang-questions] global:registered_names() returns [] Hello everyone, I am fairly new to Erlang and I have been trying to setup a gen_server so that other nodes can communicate with it. However, on the client nodes, every time I call global:registered_names(), it returns []. The odd thing is on the server node, calling global:registered_names() returns [account_monitor]. I am running two consoles on the same computer using the following commands: erl -sname a@REDACTED -setcookie Test erl -sname b@REDACTED -setcookie Test Both consoles can ping each other. My start function is: % Initialize routine start_link() -> gen_server:start_link({global, ?MODULE}, ?MODULE, [], []). where ?MODULE = account_monitor. I tried calling net_adm:world() and global:sync() and no luck at all! The gen_server works fine (and by fine, I mean calling gen_server:call(...)) when I start it locally (start_link({local, ?MODULE} ....). Any help or suggestions would be extremely helpful at this point! Additional info: - OS: Leopard 10.5 - Erang bin: Sep 3, 2008 Thank you for your time, Adrian Balij _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions From tty.erlang@REDACTED Wed Oct 22 21:51:02 2008 From: tty.erlang@REDACTED (t ty) Date: Wed, 22 Oct 2008 15:51:02 -0400 Subject: [erlang-questions] confusing message behavior In-Reply-To: <7EB15192-5EC3-4A8E-8E0E-F2DE42181304@hi5.com> References: <7EB15192-5EC3-4A8E-8E0E-F2DE42181304@hi5.com> Message-ID: <290b3ba10810221251s150f370bj7f78dc27a3841bff@mail.gmail.com> After the first 'receive' X is bound to 'a', meaning the second receive could be viewed as: receive 'a' -> 'a' after 100 -> timeout end. Do the following: 1> test:m(). 2> receive X -> X after 100 -> timeout end. 3> f(X) 4> receive X -> X after 100 -> timeout end. t On Wed, Oct 22, 2008 at 3:20 PM, Steven Grady wrote: > Can someone explain why some messages are thrown away when doing a > "receive" from the command line? > > $ cat test.erl > -module(test). > -export([m/0, g/0]). > > m() -> self() ! a, self() ! b. > g() -> receive X -> X after 100 -> timeout end. > > Bad behavior ("a" is received, but not "b"): > > $ erl > Erlang (BEAM) emulator version 5.6.2 [source] [async-threads:0] > [kernel-poll:false] > > Eshell V5.6.2 (abort with ^G) > 1> test:m(). > b > 2> receive X -> X after 100 -> timeout end. > a > 3> receive X -> X after 100 -> timeout end. > timeout > 4> > > Good behavior (both messages are received): > > $ erl > Erlang (BEAM) emulator version 5.6.2 [source] [async-threads:0] > [kernel-poll:false] > > Eshell V5.6.2 (abort with ^G) > 1> test:m(). > b > 2> test:g(). > a > 3> test:g(). > b > 4> test:g(). > timeout > 5> > > Steven > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From sgrady@REDACTED Wed Oct 22 21:55:13 2008 From: sgrady@REDACTED (Steven Grady) Date: Wed, 22 Oct 2008 12:55:13 -0700 Subject: [erlang-questions] confusing message behavior In-Reply-To: <290b3ba10810221251s150f370bj7f78dc27a3841bff@mail.gmail.com> References: <7EB15192-5EC3-4A8E-8E0E-F2DE42181304@hi5.com> <290b3ba10810221251s150f370bj7f78dc27a3841bff@mail.gmail.com> Message-ID: <9D529E12-E63F-4B7A-A800-21E7E9381DE3@hi5.com> D'oh! Of course. I keep on expecting the scope of a variable binding in a receive to be restricted to the receive block. Sigh. Thanks, Steven On Oct 22, 2008, at 12:51 PM, t ty wrote: > After the first 'receive' X is bound to 'a', meaning the second > receive could be viewed as: > > receive 'a' -> 'a' after 100 -> timeout end. > > Do the following: > > 1> test:m(). > 2> receive X -> X after 100 -> timeout end. > 3> f(X) > 4> receive X -> X after 100 -> timeout end. > > t > > On Wed, Oct 22, 2008 at 3:20 PM, Steven Grady wrote: >> Can someone explain why some messages are thrown away when doing a >> "receive" from the command line? >> >> $ cat test.erl >> -module(test). >> -export([m/0, g/0]). >> >> m() -> self() ! a, self() ! b. >> g() -> receive X -> X after 100 -> timeout end. >> >> Bad behavior ("a" is received, but not "b"): >> >> $ erl >> Erlang (BEAM) emulator version 5.6.2 [source] [async-threads:0] >> [kernel-poll:false] >> >> Eshell V5.6.2 (abort with ^G) >> 1> test:m(). >> b >> 2> receive X -> X after 100 -> timeout end. >> a >> 3> receive X -> X after 100 -> timeout end. >> timeout >> 4> >> >> Good behavior (both messages are received): >> >> $ erl >> Erlang (BEAM) emulator version 5.6.2 [source] [async-threads:0] >> [kernel-poll:false] >> >> Eshell V5.6.2 (abort with ^G) >> 1> test:m(). >> b >> 2> test:g(). >> a >> 3> test:g(). >> b >> 4> test:g(). >> timeout >> 5> >> >> Steven >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> From ulf@REDACTED Wed Oct 22 22:12:26 2008 From: ulf@REDACTED (Ulf Wiger) Date: Wed, 22 Oct 2008 22:12:26 +0200 Subject: [erlang-questions] global:registered_names() returns [] In-Reply-To: <-5479651605450171689@unknownmsgid> References: <-5479651605450171689@unknownmsgid> Message-ID: <8209f740810221312o41c08bcg9a565e9413606130@mail.gmail.com> You must tell gen_server:call() that it's a global name. BR, Ulf W 2008/10/22, Adrian Balij : > Thank you Andrew, that did work and I was able to see the registered names > on both nodes. > > It is odd how in books such as Programming Erlang by Joe and the videos by > Kevin Smith never mention the need to use net_kernel:connect and somehow > their examples seem to work. Maybe I missed something or my lack of > experience cannot answer this odd scenario. > > Although your solution worked, I ran into another problem. Both nodes can > see the registered names: [account_monitor] > > However, when I call gen_server:start_link for the first time, the name does > not get registered! However any subsequent calls (without terminating the > node) causes the process to register!! > > On top of that, when I call gen_server:call(account_monitor, getOnlineUsers) > , I get the error: > > *exception exit: {noproc, {gen_server, call,[account_monitor, > getOnlineUsers]}} > > Any have any ideas why? > > Sincerely, > > Adrian Balij > Software Engineer > Musket/Melburn Group > > > -----Original Message----- > From: Andrew Stone [mailto:stondage123@REDACTED] > Sent: October 22, 2008 1:05 PM > To: adrian.balij@REDACTED > Subject: Re: [erlang-questions] global:registered_names() returns [] > > Adrian, > > I think you want to call net_kernel:connect right before you call > global:sync. That will actually connect the two nodes. Then global:sync will > synch the names on each node. > > -Andrew > > > > ----- Original Message ---- > From: "adrian.balij@REDACTED" > To: erlang-questions@REDACTED > Sent: Tuesday, October 21, 2008 4:24:39 PM > Subject: [erlang-questions] global:registered_names() returns [] > > Hello everyone, > > I am fairly new to Erlang and I have been trying to setup a gen_server so > that other nodes can communicate with it. However, on the client nodes, > every time I call global:registered_names(), it returns []. The odd thing > is on the server node, calling global:registered_names() returns > [account_monitor]. > > I am running two consoles on the same computer using the following commands: > > erl -sname a@REDACTED -setcookie Test > > erl -sname b@REDACTED -setcookie Test > > Both consoles can ping each other. > > My start function is: > > % Initialize routine > start_link() -> gen_server:start_link({global, ?MODULE}, ?MODULE, [], []). > > where ?MODULE = account_monitor. > > I tried calling net_adm:world() and global:sync() and no luck at all! > > The gen_server works fine (and by fine, I mean calling > gen_server:call(...)) when I start it locally (start_link({local, ?MODULE} > ....). > > Any help or suggestions would be extremely helpful at this point! > > Additional info: > - OS: Leopard 10.5 > - Erang bin: Sep 3, 2008 > > Thank you for your time, > > Adrian Balij > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From dave.smith.to@REDACTED Wed Oct 22 22:25:24 2008 From: dave.smith.to@REDACTED (Dave Smith) Date: Wed, 22 Oct 2008 16:25:24 -0400 Subject: [erlang-questions] a surprising atom In-Reply-To: References: <200810230445.44576.als@iinet.net.au> <6a36e7290810221108pade346eg9b082e2e335fa30b@mail.gmail.com> <8209f740810221136k3f654b7h251635c9e0ebe2b@mail.gmail.com> Message-ID: <5ea453f90810221325y1124721fwc5041326d59620cf@mail.gmail.com> I took a quick look at EEP-10 and there seems to be no mention of how Unicode atoms would be represented, or if they would be at all. Currently I have my terminal settings to Latin-1 so I get what Ulf gets. EEP-10 has unicode lists stored as UTF-32, but does not mention how lists will be output to the terminal from the interactive shell. I would favour a UTF-8 output. For consistancy though, I think that the shell should also convert atoms to UTF-8, even if they are stored as Latin-1. If this was the case, list_to_atom([255]) would show ? properly with my terminal set to UTF-8. The shell would be responsible for converting Latin-1(FF) to UTF-8(C3 BF). Having the interactive shell output all terms consistantly as UTF-8 would allow me to set my terminal to UTF-8 and everything would display correctly. Any thoughts? 2008/10/22 Matthew Dempsky > On Wed, Oct 22, 2008 at 11:36 AM, Ulf Wiger wrote: > > I think that has to do with your tty settings. For me it's: > > I think the emphasis was on atoms being arbitrary strings. > > > 11> list_to_atom([255]). > > ? > > Your terminal is broken. It's using ISO 8859-1 when it should be > using UTF-8. ;-) > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From steven.charles.davis@REDACTED Wed Oct 22 23:12:45 2008 From: steven.charles.davis@REDACTED (Steve Davis) Date: Wed, 22 Oct 2008 14:12:45 -0700 (PDT) Subject: [erlang-questions] Why isn't erlang strongly typed? In-Reply-To: References: <58fb3ab8-9ec2-43a1-9b69-51803bdb4dbc@r66g2000hsg.googlegroups.com> <1929ACE1-C4D7-4972-B6D3-B58623B60C8A@cs.otago.ac.nz> <20081022041851.GA22961@herbie> <682a2670-e082-4652-aaca-180d27eb62b6@h2g2000hsg.googlegroups.com> Message-ID: On Oct 22, 9:51?am, Kevin Scaldeferri wrote: > You don't have to "accept Ulf's definition". ? Well, that's true. There are many other definitions that I could choose to accept. ...but I'm not at all sure that this would mean I am in the least confused about/between strong typing and static typing (or their relevance to my question). /s From stondage123@REDACTED Wed Oct 22 22:19:40 2008 From: stondage123@REDACTED (Andrew Stone) Date: Wed, 22 Oct 2008 13:19:40 -0700 (PDT) Subject: [erlang-questions] global:registered_names() returns [] Message-ID: <942683.56042.qm@web35907.mail.mud.yahoo.com> > It is odd how in books such as Programming Erlang by Joe and the videos by > Kevin Smith never mention the need to use net_kernel:connect and somehow > their examples seem to work. Maybe I missed something or my lack of > experience cannot answer this odd scenario. I just reviewed Joe's book and the reason his examples work are two-fold. His first examples with distributed erlang across nodes use the rpc:call mechanism which uses the well known REX process, so naming is unecessary. rpc:call handles node connections by itself. This took me a while to figure out a few months ago. His gen_server examples all use local naming so can only run within one node. He never states they should run across nodes. I haven't actually seen Kevin Smith's videos so can't comment there. I will say that you are on the right track and are off to a good start by using gen_server instead of hand rolled process loop servers. Learning OTP and how to use distributed Erlang takes time and sometimes it is hard to find the exact answer you are looking for. I've been on many newsgroups over the last few years and I must say that this one continues to impress me with the vast knowledge presented by list members and their willingness to help. So stick around here and keep experimenting and your knowledge base will surely grow. > However, when I call gen_server:start_link for the first time, the name does > not get registered! However any subsequent calls (without terminating the > node) causes the process to register!! I don't really understand this, maybe someone else can help. > On top of that, when I call gen_server:call(account_monitor, getOnlineUsers) > , I get the error: > *exception exit: {noproc, {gen_server, call,[account_monitor, > getOnlineUsers]}} Since you are using global naming, you need to access your server's differently with gen_server:call You need to do something like gen_server:call({global,account_monitor}, getOnlineUsers). Note that with this scenario you cannot register account_monitor globally on both nodes. If you would like to use the same process name register it locally and call like this gen_server:call({account,Node}, getOnlineUsers) See http://erlang.org/doc/man/gen_server.html for details. Good Luck, Andrew ----- Original Message ---- From: Adrian Balij To: Andrew Stone Cc: erlang-questions@REDACTED Sent: Wednesday, October 22, 2008 3:48:01 PM Subject: RE: [erlang-questions] global:registered_names() returns [] Thank you Andrew, that did work and I was able to see the registered names on both nodes. It is odd how in books such as Programming Erlang by Joe and the videos by Kevin Smith never mention the need to use net_kernel:connect and somehow their examples seem to work. Maybe I missed something or my lack of experience cannot answer this odd scenario. Although your solution worked, I ran into another problem. Both nodes can see the registered names: [account_monitor] However, when I call gen_server:start_link for the first time, the name does not get registered! However any subsequent calls (without terminating the node) causes the process to register!! On top of that, when I call gen_server:call(account_monitor, getOnlineUsers) , I get the error: *exception exit: {noproc, {gen_server, call,[account_monitor, getOnlineUsers]}} Any have any ideas why? Sincerely, Adrian Balij Software Engineer Musket/Melburn Group -----Original Message----- From: Andrew Stone [mailto:stondage123@REDACTED] Sent: October 22, 2008 1:05 PM To: adrian.balij@REDACTED Subject: Re: [erlang-questions] global:registered_names() returns [] Adrian, I think you want to call net_kernel:connect right before you call global:sync. That will actually connect the two nodes. Then global:sync will synch the names on each node. -Andrew ----- Original Message ---- From: "adrian.balij@REDACTED" To: erlang-questions@REDACTED Sent: Tuesday, October 21, 2008 4:24:39 PM Subject: [erlang-questions] global:registered_names() returns [] Hello everyone, I am fairly new to Erlang and I have been trying to setup a gen_server so that other nodes can communicate with it. However, on the client nodes, every time I call global:registered_names(), it returns []. The odd thing is on the server node, calling global:registered_names() returns [account_monitor]. I am running two consoles on the same computer using the following commands: erl -sname a@REDACTED -setcookie Test erl -sname b@REDACTED -setcookie Test Both consoles can ping each other. My start function is: % Initialize routine start_link() -> gen_server:start_link({global, ?MODULE}, ?MODULE, [], []). where ?MODULE = account_monitor. I tried calling net_adm:world() and global:sync() and no luck at all! The gen_server works fine (and by fine, I mean calling gen_server:call(...)) when I start it locally (start_link({local, ?MODULE} ....). Any help or suggestions would be extremely helpful at this point! Additional info: - OS: Leopard 10.5 - Erang bin: Sep 3, 2008 Thank you for your time, Adrian Balij _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions From bqt@REDACTED Wed Oct 22 23:21:21 2008 From: bqt@REDACTED (Johnny Billquist) Date: Wed, 22 Oct 2008 23:21:21 +0200 Subject: [erlang-questions] a surprising atom In-Reply-To: References: <200810230445.44576.als@iinet.net.au> <6a36e7290810221108pade346eg9b082e2e335fa30b@mail.gmail.com> <8209f740810221136k3f654b7h251635c9e0ebe2b@mail.gmail.com> Message-ID: <48FF9951.9030408@softjar.se> Matthew Dempsky wrote: > On Wed, Oct 22, 2008 at 11:36 AM, Ulf Wiger wrote: >> I think that has to do with your tty settings. For me it's: > > I think the emphasis was on atoms being arbitrary strings. > >> 11> list_to_atom([255]). >> ? > > Your terminal is broken. It's using ISO 8859-1 when it should be > using UTF-8. ;-) I think that defines his terminal as behaving right. :D (Don't get me started on UTF-x, or Unicode, and all the devils spawns...) Johnny From kostis@REDACTED Thu Oct 23 00:54:45 2008 From: kostis@REDACTED (Kostis Sagonas) Date: Thu, 23 Oct 2008 01:54:45 +0300 Subject: [erlang-questions] Why isn't erlang strongly typed? In-Reply-To: <20081022041851.GA22961@herbie> References: <58fb3ab8-9ec2-43a1-9b69-51803bdb4dbc@r66g2000hsg.googlegroups.com> <1929ACE1-C4D7-4972-B6D3-B58623B60C8A@cs.otago.ac.nz> <20081022041851.GA22961@herbie> Message-ID: <48FFAF35.10708@cs.ntua.gr> Michael Radford wrote: > Richard O'Keefe writes: >>> I'm sure that there's a simple and convincing answer to this. >> Because Erlang was designed for systems that are >> supposed to be running all the time, even when you >> want to install upgraded software with *different* >> types. >> >> There have been several attempts to provide type systems >> for Erlang. It took a long time to get one that was >> found to be satisfactory in practice, but it's there now >> in documentation and in the Dialyzer and Typerl. > > I'm not familiar with Typerl, but Dialyzer only does static analysis > for a single version of each module, right? (It provides no way > to check the correctness of a code_change handler between two versions?) I think you are mixing two things: Dialyzer does not provide any way whatsoever to check the type correctness of a set of modules. PERIOD. What Dialyzer does provide is analysis that finds *definite type errors* in a set of modules. There is a big difference between finding definite type errors and proving the absence of (a class of) type errors. However, under that prism, Dialyzer can indeed find type clashes between the original version of an application (modules M1,...,Mi, O1,...,Oj) and the new ones (N1,..., Nk) that will replace the Ojs. You just analyze off-line the set M1,...,Mi, N1,..., Nk and Dialyzer will report any discrepancies and incompatibilities it finds. Note that this does not guarantee that there will be no runtime type errors. Kostis From kostis@REDACTED Thu Oct 23 01:11:53 2008 From: kostis@REDACTED (Kostis Sagonas) Date: Thu, 23 Oct 2008 02:11:53 +0300 Subject: [erlang-questions] Why isn't erlang strongly typed? In-Reply-To: <1929ACE1-C4D7-4972-B6D3-B58623B60C8A@cs.otago.ac.nz> References: <58fb3ab8-9ec2-43a1-9b69-51803bdb4dbc@r66g2000hsg.googlegroups.com> <1929ACE1-C4D7-4972-B6D3-B58623B60C8A@cs.otago.ac.nz> Message-ID: <48FFB339.3000009@cs.ntua.gr> Richard O'Keefe wrote: > On 22 Oct 2008, at 3:18 am, Steve Davis wrote: > > There have been several attempts to provide type systems > for Erlang. It took a long time to get one that was > found to be satisfactory in practice, but it's there now > in documentation and in the Dialyzer and Typerl. > > However, even that system is not as expressive as one > might wish. Indeed it isn't. However, one of the nice properties of types is that they can always become stronger and more expressive. One of the problems in doing it though is agreeing in which ways to make them stronger. After all, with sufficiently strong types one can describe pretty much any property one wishes. Kostis From ok@REDACTED Thu Oct 23 02:04:47 2008 From: ok@REDACTED (Richard O'Keefe) Date: Thu, 23 Oct 2008 13:04:47 +1300 Subject: [erlang-questions] Why isn't erlang strongly typed? In-Reply-To: <20081022041851.GA22961@herbie> References: <58fb3ab8-9ec2-43a1-9b69-51803bdb4dbc@r66g2000hsg.googlegroups.com> <1929ACE1-C4D7-4972-B6D3-B58623B60C8A@cs.otago.ac.nz> <20081022041851.GA22961@herbie> Message-ID: <6ED68394-5DDF-4BCA-8224-BC6E5573430E@cs.otago.ac.nz> There is continuing debate in the programming languages world about the merits of types. Consider four kinds of languages. Dynamic type systems. Here we find Lisp, Smalltalk, Erlang, Python, JavaScript, Prolog, &c. Systems where variables are not annotated with types at compile time, but where the run time type system is not breakable by any means in the language. "Type errors" do exist as a run-time concept, just like division by zero, index out of range, and file won't open. Feeble type systems. Here we find C, Pascal, traditional Fortran, &c. Systems where there _is_ a static type system but it is laughably easy to bypass it whenever you want to. Such a type system has two chief merits: - to catch some errors at compile time - to let the compiler automatically resolve overloaded operator, field, and perhaps function names. Vanilla type systems. Here we find Java and Eiffel and some others. Systems where there is a static type system that cannot be broken by any means in the language, but some of the checking is deferred to run time. Type errors remain as a run-time concept, but they are at least caught, unlike feeble type systems. These type systems provide useful guarantees about types, and also allow (some) compile-time resolution of overloaded operators (at least in Eiffel), fields, and so on. The classical single inheritance model doesn't really work very well. (I've been building a Smalltalk compiler in my spare time for a couple of times. It ran its first method yesterday! Over and over and over I've found single inheritance limiting.) This means either providing multiple inheritance, as in Eiffel, or in the limited way offered by the proposed ISO Object-Oriented Extensions to Pascal, or in the still more limited interfaces of Java, or by divorcing the type hierarchy from the implementation hierarchy as in (was it Sather? was it Cecil?). It also leads, early or late, to some sort of parameterised types. Types as a tool of design. Here we find Haskell, Clean, Mercury, arguably SML and CAML, and more experimental languages like Agda. In these systems the type system is the heart and soul of the language. It's not just a statically unbreakable system with no run time type errors, it's not just parameterised types, it's types *enhancing* the expressiveness of the language rather than limiting it. C++ is a weird mixture of feeble (C heritage) + types as a tool of design (template metaprogramming). It doesn't just let you shoot yourself in the foot, it gives you an A-bomb factory to really do yourself in with. When "functional" people argue for "typed" languages, they are generally thinking about types-as-a-tool-of-design. You can't just add that to Erlang. (You can add concurrency to Haskell, though, which has been done.) You'd have to overhaul the whole thing from top to bottom. That might be a good idea. So what are the merits of other type systems for Erlang? Do we want overloaded functions and operators? Nobody seems to be crying out for them. Do we have a serious problem with run-time type errors? Is a type system the only, or the best, way to deal with them? One aspect of unit testing frameworks is that if you test each function in a module even a few times, you are going to smoke out most type errors fairly quickly. You will also find many mistakes that a type system will not catch. A suitable notation, such as Smalltalk/Objective-C split method names, can prevent most type errors in the first place. Last year I kept a log of the mistakes I was finding in my Smalltalk system. I haven't kept it up this year, because I'd learned the main thing I wanted to learn: errors that would have been caught by a type checker and not by other means were quite rare. As yet, I don't think any of the languages I know has a type system that works in a *distributed* system except by taking a single program built at one time and chopping it up into distributed pieces (which is how Ada does it). Clean seems to be aimed in that direction, but the pieces of the manual that ought to describe the key ideas are still missing. Let me give you a recent example of what can go wrong. Some of my 4th year students wrote a compiler for a parallel programming language (a stripped down Java + 'in parallel' + 'wait until'). I couldn't run it. It was type checked and everything, but for the Java 1.6 libraries, and I had the 1.5 libraries. Now think of exchanging objects between their machine and mine... From ok@REDACTED Thu Oct 23 02:06:43 2008 From: ok@REDACTED (Richard O'Keefe) Date: Thu, 23 Oct 2008 13:06:43 +1300 Subject: [erlang-questions] Why isn't erlang strongly typed? In-Reply-To: <48FED1B1.6080902@erix.ericsson.se> References: <58fb3ab8-9ec2-43a1-9b69-51803bdb4dbc@r66g2000hsg.googlegroups.com> <48FED1B1.6080902@erix.ericsson.se> Message-ID: On 22 Oct 2008, at 8:09 pm, Dan Gudmundsson wrote: > PS: I still think that EEP's should be used for language or major > library re-writes and > not minor backward compatible changes. What _is_ the preferred method for that? From ok@REDACTED Thu Oct 23 02:08:48 2008 From: ok@REDACTED (Richard O'Keefe) Date: Thu, 23 Oct 2008 13:08:48 +1300 Subject: [erlang-questions] Why isn't erlang strongly typed? In-Reply-To: <48FED1B1.6080902@erix.ericsson.se> References: <58fb3ab8-9ec2-43a1-9b69-51803bdb4dbc@r66g2000hsg.googlegroups.com> <48FED1B1.6080902@erix.ericsson.se> Message-ID: <7C818186-A73A-4E2A-BB2B-595AC658AC3A@cs.otago.ac.nz> On 22 Oct 2008, at 8:09 pm, Dan Gudmundsson wrote: > There is a reason there is no mnesia:read/2 and it is that the third > argument > is the lock type which forces you to think what kind of lock you > want on that object, > there is no need for that on the dirty_* functions. This argument would have force *IF* mnesia:read/1 didn't exist. But it does. It is idle to claim that people are forced to think about what kind of lock they want when they can already write mnesia:read({Tab,Key}). From travis@REDACTED Thu Oct 23 02:12:41 2008 From: travis@REDACTED (Travis Brady) Date: Wed, 22 Oct 2008 17:12:41 -0700 Subject: [erlang-questions] Erlang with MonetDb In-Reply-To: <3bb44c6e0810080607m21ce8ef3o2d8fdfc054a9346d@mail.gmail.com> References: <3bb44c6e0810070454s5cd3a829p524ce628808a2323@mail.gmail.com> <6a36e7290810070934k1a3fbf43k258c6220b6a56e75@mail.gmail.com> <3bb44c6e0810080607m21ce8ef3o2d8fdfc054a9346d@mail.gmail.com> Message-ID: <3b82df80810221712w48420861l8e49abb4eb4114a4@mail.gmail.com> On Wed, Oct 8, 2008 at 6:07 AM, bryan rasmussen wrote: > Damn. I was worried about that myself, I've already had some problems > in the initial testing that make me not want to trust important data > to it. > > Well, in case it turns out we don't want to use it does anyone have a > good column store that they can recommend to use in conjunction with > Erlang? I haven't used it at all, but Infobright recently open sourced their column store built on top of MySQL: http://www.infobright.org/Open-Source/Home good luck, Travis > > > Cheers, > Bryan Rasmussen > > > On Tue, Oct 7, 2008 at 6:34 PM, Bob Ippolito wrote: > > I don't have an answer for you, but we tried using MonetDB early this > > year and it was an epic failure, the database corrupted itself and at > > times the server would grow until it ran out of RAM. We unfortunately > > had to resort to a commercial column store because we couldn't get > > MonetDB to run for more than a few hours without crashing :( > > > > On Tue, Oct 7, 2008 at 4:54 AM, bryan rasmussen > > wrote: > >> Hi, > >> > >> Anyone out there made some erlang examples working with MonetDB? using > >> ODBC acceptable. > >> > >> > >> Cheers, > >> Bryan Rasmussen > >> _______________________________________________ > >> erlang-questions mailing list > >> erlang-questions@REDACTED > >> http://www.erlang.org/mailman/listinfo/erlang-questions > >> > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ok@REDACTED Thu Oct 23 02:18:58 2008 From: ok@REDACTED (Richard O'Keefe) Date: Thu, 23 Oct 2008 13:18:58 +1300 Subject: [erlang-questions] clarify: Sending big messages In-Reply-To: <48FF3C65.1040705@ericsson.com> References: <48FEF426.2070606@ericsson.com> <48FF2C27.5090406@cs.ntua.gr> <3dbc6d1c0810220725p6c2e89f8kaaee84e383e53b5@mail.gmail.com> <48FF3C65.1040705@ericsson.com> Message-ID: I seem to have missed the start of this thread. However, if someone is unhappy that deliver(Port, Data) -> Port ! {data,Data}. returns {data,Data}, why don't they just write deliver(Port, Data) -> Port ! {data,Data}, ok. One thing we should definitely have for Erlang some day is some sort of style checker where people can plug in their own rules, so you could do something like Pattern Action (A ! B , C) ok (A ! B) warn("! returns a value") > From ok@REDACTED Thu Oct 23 02:36:51 2008 From: ok@REDACTED (Richard O'Keefe) Date: Thu, 23 Oct 2008 13:36:51 +1300 Subject: [erlang-questions] Why isn't erlang strongly typed? In-Reply-To: <48FFB339.3000009@cs.ntua.gr> References: <58fb3ab8-9ec2-43a1-9b69-51803bdb4dbc@r66g2000hsg.googlegroups.com> <1929ACE1-C4D7-4972-B6D3-B58623B60C8A@cs.otago.ac.nz> <48FFB339.3000009@cs.ntua.gr> Message-ID: <02C3B597-108B-4555-BD27-94814B9A06B5@cs.otago.ac.nz> On 23 Oct 2008, at 12:11 pm, Kostis Sagonas wrote: > Richard O'Keefe wrote: >> On 22 Oct 2008, at 3:18 am, Steve Davis wrote: >> >> There have been several attempts to provide type systems >> for Erlang. It took a long time to get one that was >> found to be satisfactory in practice, but it's there now >> in documentation and in the Dialyzer and Typerl. >> >> However, even that system is not as expressive as one >> might wish. > > Indeed it isn't. I should have written more clearly. That wasn't intended as a criticism. ANY type system has to strike a balance between expressiveness and practicality. To me, the type system in Haskell98 is just about perfect. Almost any step you take beyond it loses you something. Rank-2 polymorphism (which GHC supports) loses you type inference. Fortunately, you can still infer rank-1 types even in the presence of a few know rank-2 types. Dependent types can lose you decidability. (Indeed, the C++ type system is not decidable. C++ compilers are not in fact required to get it right.) From ok@REDACTED Thu Oct 23 02:39:50 2008 From: ok@REDACTED (Richard O'Keefe) Date: Thu, 23 Oct 2008 13:39:50 +1300 Subject: [erlang-questions] a surprising atom In-Reply-To: <200810230445.44576.als@iinet.net.au> References: <200810230445.44576.als@iinet.net.au> Message-ID: <3D857C7D-3CB1-43FF-9AB3-2CF4DF3F7304@cs.otago.ac.nz> On 23 Oct 2008, at 6:45 am, Anthony Shipman wrote: > Eshell V5.6.4 (abort with ^G) > 1> X = ''. > '' > 2> is_atom(X). > true What is surprising about this? '' is an atom with an empty name in Prolog. '|| is an atom with an empty name in Lisp. #'' is a Symbol with an empty name in Smalltalk. It would be dumbfounding if empty-name atoms _didn't_ work. From ahmed.nawras@REDACTED Thu Oct 23 06:43:23 2008 From: ahmed.nawras@REDACTED (Ahmed Ali) Date: Thu, 23 Oct 2008 08:43:23 +0400 Subject: [erlang-questions] Issue: erl/yaws init In-Reply-To: <1224651689.1694.69.camel@seasc0642.dyn.rnd.as.sw.ericsson.se> References: <1224651689.1694.69.camel@seasc0642.dyn.rnd.as.sw.ericsson.se> Message-ID: Thanks all. The issue is clear to me now. Best regards, Ahmed On Wed, Oct 22, 2008 at 9:01 AM, Bengt Kleberg wrote: > Greetings, > > The flag -s can take ... > That is a variable amount of arguments. > To handle that, the arguments are assembled into a list before the call. > > In your case : > application:start( [my_app] ) > > This is not the same as > init() -> > application:start(my_app). > > > bengt > > On Wed, 2008-10-22 at 01:56 +0400, Ahmed Ali wrote: >> Hi all, >> >> I don't know if this is a erlang or yaws's issue. The first command >> below doesn't work while the second works. >> >> > yaws --conf yaws.conf --id my_app --daemon --pa ebin/ --erlarg -s\ application\ start\ my_app >> > yaws --conf yaws.conf --id my_app --daemon --pa ebin/ --erlarg -s\ web_utils\ init >> >> Although funciton web_utils:init/0 looks like below >> >> init() -> >> application:start(my_app). >> >> Did anyone face a similar issue before? >> >> Best regards, >> >> Ahmed >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From dgud@REDACTED Thu Oct 23 08:34:50 2008 From: dgud@REDACTED (Dan Gudmundsson) Date: Thu, 23 Oct 2008 08:34:50 +0200 Subject: [erlang-questions] Why isn't erlang strongly typed? In-Reply-To: References: <58fb3ab8-9ec2-43a1-9b69-51803bdb4dbc@r66g2000hsg.googlegroups.com> <48FED1B1.6080902@erix.ericsson.se> Message-ID: <49001B0A.7010203@erix.ericsson.se> Most of us developers read this list, maybe not all the messages in the long threads you participate in :-) And we read erlang-patches, erlang-bugs. /Dan Richard O'Keefe wrote: > > On 22 Oct 2008, at 8:09 pm, Dan Gudmundsson wrote: >> PS: I still think that EEP's should be used for language or major >> library re-writes and >> not minor backward compatible changes. > > What _is_ the preferred method for that? > From dgud@REDACTED Thu Oct 23 08:45:55 2008 From: dgud@REDACTED (Dan Gudmundsson) Date: Thu, 23 Oct 2008 08:45:55 +0200 Subject: [erlang-questions] Why isn't erlang strongly typed? In-Reply-To: <7C818186-A73A-4E2A-BB2B-595AC658AC3A@cs.otago.ac.nz> References: <58fb3ab8-9ec2-43a1-9b69-51803bdb4dbc@r66g2000hsg.googlegroups.com> <48FED1B1.6080902@erix.ericsson.se> <7C818186-A73A-4E2A-BB2B-595AC658AC3A@cs.otago.ac.nz> Message-ID: <49001DA3.40801@erix.ericsson.se> Richard O'Keefe wrote: > > On 22 Oct 2008, at 8:09 pm, Dan Gudmundsson wrote: > >> There is a reason there is no mnesia:read/2 and it is that the third >> argument >> is the lock type which forces you to think what kind of lock you want >> on that object, >> there is no need for that on the dirty_* functions. > > This argument would have force *IF* mnesia:read/1 didn't exist. > But it does. It is idle to claim that people are forced to > think about what kind of lock they want when they can already > write mnesia:read({Tab,Key}). > Agree, but I think that was the motivation. mnesia:read/1 was the original api function which was kept when the 'new'* dirty_read/2 and read/3 was introduced. So what do you want? mnesia:read({Tab,key}, Lock) -> mnesia:read(Tab,Key,Lock); or mnesia:read(Tab,Key) -> mnesia:read(Tab,Key,read). or both? /Dan * new means before 1997 :-) From als@REDACTED Thu Oct 23 08:50:17 2008 From: als@REDACTED (Anthony Shipman) Date: Thu, 23 Oct 2008 17:50:17 +1100 Subject: [erlang-questions] Clarification on supervisor restart limits Message-ID: <200810231750.17740.als@iinet.net.au> The doco says: "To prevent a supervisor from getting into an infinite loop of child process terminations and restarts, a maximum restart frequency is defined using two integer values MaxR and MaxT. If more than MaxR restarts occur within MaxT seconds, the supervisor terminates all child processes and then itself." I've always interpreted that to mean that the limits are applied to each child individually. But it appears that in reality restarts are counted over all children. Perhaps it would be clearer to add to the doco something like "Restarts are not counted per child. A restart is counted if any child restarts." -- Anthony Shipman Mamas don't let your babies als@REDACTED grow up to be outsourced. From ruzin82@REDACTED Thu Oct 23 08:58:13 2008 From: ruzin82@REDACTED (Yongbeom Pak) Date: Thu, 23 Oct 2008 09:58:13 +0300 Subject: [erlang-questions] eheap_alloc crash when using mnesia In-Reply-To: References: <72e228670810200633q1e17bf7alaab35cfb8c53e3b2@mail.gmail.com> <14f0e3620810200936j3f59bed3ybc4080b977dad0ff@mail.gmail.com> <6a3ae47e0810210107u16f4c75fx27bc95ac2528e33a@mail.gmail.com> <6a3ae47e0810211431mb1749bfkde677c2aa69cd2bc@mail.gmail.com> <6a3ae47e0810220133j68680eaetac147102b9f4737f@mail.gmail.com> Message-ID: <72e228670810222358q5b49affes4815f722b704e28e@mail.gmail.com> Thanks for all comments, i did not have proper solution than reducing the amount of the data that is processing on the selecting queries. Thanks again. 2008/10/22 Matthew Dempsky > On Wed, Oct 22, 2008 at 1:33 AM, Robert Raschke > wrote: > > Are you sure that uses plain old memory allocation for its cache > > entries (I haven't looked, I must admit)? > > Yes, I chose dnscache as a concrete example because it's a server > whose internals I'm thoroughly familiar with. :-) > > dnscache allocates a big chunk of memory (1000000 bytes by default) up > front for cache storage, but while processing requests, it allocates > additional memory for temporary storage for names relevant to the > resolution process. > > E.g., if a cache receives a query for "www.erlang.org", it allocate 16 > bytes to store that name. While resolving this query, it also > allocates temporary space for "a.root-servers.net", > "d0.org.afilias-nst.org", "ns.erlang.org", and so on. Names are > promptly freed as soon as they are no longer needed, but if allocating > space for one of these names fails, then dnscache gives up on > resolving "www.erlang.org" and the user tries again later. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From attila.rajmund.nohl@REDACTED Thu Oct 23 09:44:13 2008 From: attila.rajmund.nohl@REDACTED (attila.rajmund.nohl@REDACTED) Date: Thu, 23 Oct 2008 09:44:13 +0200 (CEST) Subject: [erlang-questions] eheap_alloc crash when using mnesia In-Reply-To: References: <72e228670810200633q1e17bf7alaab35cfb8c53e3b2@mail.gmail.com> <14f0e3620810200936j3f59bed3ybc4080b977dad0ff@mail.gmail.com> <6a3ae47e0810210107u16f4c75fx27bc95ac2528e33a@mail.gmail.com> <6a3ae47e0810211431mb1749bfkde677c2aa69cd2bc@mail.gmail.com> <6a3ae47e0810220133j68680eaetac147102b9f4737f@mail.gmail.com> Message-ID: On Wed, 22 Oct 2008, Matthew Dempsky wrote: > On Wed, Oct 22, 2008 at 1:33 AM, Robert Raschke wrote: >> Are you sure that uses plain old memory allocation for its cache >> entries (I haven't looked, I must admit)? > > Yes, I chose dnscache as a concrete example because it's a server > whose internals I'm thoroughly familiar with. :-) > > dnscache allocates a big chunk of memory (1000000 bytes by default) up > front for cache storage, but while processing requests, it allocates > additional memory for temporary storage for names relevant to the > resolution process. > > E.g., if a cache receives a query for "www.erlang.org", it allocate 16 > bytes to store that name. While resolving this query, it also > allocates temporary space for "a.root-servers.net", > "d0.org.afilias-nst.org", "ns.erlang.org", and so on. Names are > promptly freed as soon as they are no longer needed, but if allocating > space for one of these names fails, then dnscache gives up on > resolving "www.erlang.org" and the user tries again later. This works for a stateless protocol like DNS - but what would you do for e.g. HTTP? The correct answer would probably to send an "503 Service Unavailable" answer, but that would need more memory and we've just run out of memory. Even abruptly closing the TCP session might need more memory to construct the FIN packet. It's probably easier to setup a limit for maximum number of connections that could be handled safe. Bye,NAR -- "Beware of bugs in the above code; I have only proved it correct, not tried it." From chsu79@REDACTED Thu Oct 23 10:07:45 2008 From: chsu79@REDACTED (Christian) Date: Thu, 23 Oct 2008 10:07:45 +0200 Subject: [erlang-questions] eheap_alloc crash when using mnesia In-Reply-To: References: <72e228670810200633q1e17bf7alaab35cfb8c53e3b2@mail.gmail.com> <14f0e3620810200936j3f59bed3ybc4080b977dad0ff@mail.gmail.com> <6a3ae47e0810210107u16f4c75fx27bc95ac2528e33a@mail.gmail.com> <6a3ae47e0810211431mb1749bfkde677c2aa69cd2bc@mail.gmail.com> <6a3ae47e0810220133j68680eaetac147102b9f4737f@mail.gmail.com> Message-ID: > This works for a stateless protocol like DNS - but what would you do for > e.g. HTTP? The correct answer would probably to send an "503 Service > Unavailable" answer, but that would need more memory and we've just run > out of memory. Even abruptly closing the TCP session might need more > memory to construct the FIN packet. There is "memsup" in OTP, allowing one to monitor ram usage and adjust limits dynamically. Not that I have ever used it, but it seems sensible. From hakan@REDACTED Thu Oct 23 11:18:50 2008 From: hakan@REDACTED (Hakan Mattsson) Date: Thu, 23 Oct 2008 11:18:50 +0200 (CEST) Subject: [erlang-questions] Why isn't erlang strongly typed? In-Reply-To: <49001DA3.40801@erix.ericsson.se> References: <58fb3ab8-9ec2-43a1-9b69-51803bdb4dbc@r66g2000hsg.googlegroups.com> <48FED1B1.6080902@erix.ericsson.se> <7C818186-A73A-4E2A-BB2B-595AC658AC3A@cs.otago.ac.nz> <49001DA3.40801@erix.ericsson.se> Message-ID: On Thu, 23 Oct 2008, Dan Gudmundsson wrote: dgud> So what do you want? dgud> dgud> mnesia:read({Tab,key}, Lock) -> I like this one with key as an atom. ;-) /H?kan From attila.rajmund.nohl@REDACTED Thu Oct 23 12:54:34 2008 From: attila.rajmund.nohl@REDACTED (attila.rajmund.nohl@REDACTED) Date: Thu, 23 Oct 2008 12:54:34 +0200 (CEST) Subject: [erlang-questions] Why isn't erlang strongly typed? In-Reply-To: <49001DA3.40801@erix.ericsson.se> References: <58fb3ab8-9ec2-43a1-9b69-51803bdb4dbc@r66g2000hsg.googlegroups.com> <48FED1B1.6080902@erix.ericsson.se> <7C818186-A73A-4E2A-BB2B-595AC658AC3A@cs.otago.ac.nz> <49001DA3.40801@erix.ericsson.se> Message-ID: On Thu, 23 Oct 2008, Dan Gudmundsson wrote: [...] > Agree, but I think that was the motivation. > mnesia:read/1 was the original api function which was kept > when the 'new'* dirty_read/2 and read/3 was introduced. > > So what do you want? > > mnesia:read({Tab,key}, Lock) -> > mnesia:read(Tab,Key,Lock); > or > mnesia:read(Tab,Key) -> > mnesia:read(Tab,Key,read). > or both? This second would be consistent with the dirty_read, so I'd like this one. Bye,NAR -- "Beware of bugs in the above code; I have only proved it correct, not tried it." From sbailey@REDACTED Thu Oct 23 18:20:00 2008 From: sbailey@REDACTED (Stuart Bailey) Date: Thu, 23 Oct 2008 09:20:00 -0700 Subject: [erlang-questions] Why isn't erlang strongly typed? References: <58fb3ab8-9ec2-43a1-9b69-51803bdb4dbc@r66g2000hsg.googlegroups.com><48FED1B1.6080902@erix.ericsson.se><7C818186-A73A-4E2A-BB2B-595AC658AC3A@cs.otago.ac.nz><49001DA3.40801@erix.ericsson.se> Message-ID: <083AD28775D80048925EE4273AFD41030164166B@thor.infoblox.com> There is a very enjoyable and rigorous treatment of many of the issues raised on this thread in the book: Types and Programming Languages by Benjamin C. Pierce. http://www.amazon.com/Types-Programming-Languages-Benjamin-Pierce/dp/0262162091 It spends quite some time on typing concerns of the Lambda-Calculus which is especially relevant for Erlang. I agree with Milner's statement below: "Types are the leaven of computer programming; they make it digestible. This excellent book uses types to navigate the rich variety of programming languages, bringing a new kind of unity to their usage, theory, and implementation. Its author writes with the authority of experience in all three of these aspects." ?Robin Milner, Computer Laboratory, University of Cambridge -------------- next part -------------- An HTML attachment was scrubbed... URL: From matthew@REDACTED Thu Oct 23 19:40:19 2008 From: matthew@REDACTED (Matthew Dempsky) Date: Thu, 23 Oct 2008 10:40:19 -0700 Subject: [erlang-questions] eheap_alloc crash when using mnesia In-Reply-To: References: <72e228670810200633q1e17bf7alaab35cfb8c53e3b2@mail.gmail.com> <14f0e3620810200936j3f59bed3ybc4080b977dad0ff@mail.gmail.com> <6a3ae47e0810210107u16f4c75fx27bc95ac2528e33a@mail.gmail.com> <6a3ae47e0810211431mb1749bfkde677c2aa69cd2bc@mail.gmail.com> <6a3ae47e0810220133j68680eaetac147102b9f4737f@mail.gmail.com> Message-ID: On Thu, Oct 23, 2008 at 12:44 AM, wrote: > This works for a stateless protocol like DNS - but what would you do for > e.g. HTTP? The correct answer would probably to send an "503 Service > Unavailable" answer, but that would need more memory and we've just run > out of memory. Before accepting a new TCP connection, you allocate enough space to ensure you can fail correctly. E.g., the qmail-smtpd program from qmail handles inbound SMTP connections. If it runs out of memory while processing a request, it gives a "420 out of memory" response using memory allocated when the new connection was first accepted. > Even abruptly closing the TCP session might need more > memory to construct the FIN packet. That's a problem that the kernel needs to handle. From q2h46uw02@REDACTED Thu Oct 23 21:35:01 2008 From: q2h46uw02@REDACTED (Kevin) Date: 23 Oct 2008 19:35:01 -0000 Subject: [erlang-questions] Priviliged ports and effective UID Message-ID: <9893-51893@sneakemail.com> Hello, I can't find an answer to this anywhere. In erlang how does one deal with the problem of starting erlang as root, binding to a privileged port, and then change the effective user id to something other than root. In a daemon process written in c or even perl, a process is started by an init script, which is run as root, it then binds to port, 25, 80, etc, and then it sets its effective UID and effective GID to something more harmless, like httpd/httpd. I know you can start the whole thing like su httpd -c erl, but this doesnt allow for binding to prilileged port first. And please don't tell me to use open_port() or write a linked in driver :-) Thanks From toby@REDACTED Thu Oct 23 22:01:14 2008 From: toby@REDACTED (Toby Thain) Date: Thu, 23 Oct 2008 16:01:14 -0400 Subject: [erlang-questions] Why isn't erlang strongly typed? In-Reply-To: <9b08084c0810220051n6f9889adm95af0584d494a853@mail.gmail.com> References: <58fb3ab8-9ec2-43a1-9b69-51803bdb4dbc@r66g2000hsg.googlegroups.com> <77E781FC-7723-4C51-986A-3F165D264AFA@cs.otago.ac.nz> <9b08084c0810220051n6f9889adm95af0584d494a853@mail.gmail.com> Message-ID: <871FF320-735A-40EB-B28A-6ED87BEF809A@telegraphics.com.au> On 22-Oct-08, at 3:51 AM, Joe Armstrong wrote: > That's really nice, sometime, almost as a joke I've written code > like this > > in_degree_of(G, in, V) -> > ... > Ohhh! That's no joke! I think it's wonderful. Pattern matched glue as internal documentation! I'm more in love with Erlang than ever. --Toby > But I think your syntax is nicer - it's also reallly easy to implement > - worth experimenting with I think > > /Joe > > > On Wed, Oct 22, 2008 at 4:47 AM, Richard O'Keefe > wrote: >> >>> >>> This is a consequence of Erlangs incredibly unergonomic function/ >>> parameter >>> naming conventions and has little to do with strong typing (or its >>> absence). >> >> I have proposed in the past that Erlang should adopt >> Paul Lyons' "split procedure names" idea. >> >> Instead of >> >> call = [module:]name([expr{,expr}]) >> >> we take >> >> call = [module:]{name([expr{,expr}])}+ >> >> For example, instead of >> >> in_degree(G, V) >> >> you would have >> >> in_degree_of(V) in(G) >> >> My experience of Smalltalk is the same as Holger Hoffstaette's; >> the names tell you what the argument r?les are so that it is >> very unusual to get arguments confused. >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From ok@REDACTED Thu Oct 23 23:38:08 2008 From: ok@REDACTED (Richard O'Keefe) Date: Fri, 24 Oct 2008 10:38:08 +1300 Subject: [erlang-questions] Why isn't erlang strongly typed? In-Reply-To: <49001DA3.40801@erix.ericsson.se> References: <58fb3ab8-9ec2-43a1-9b69-51803bdb4dbc@r66g2000hsg.googlegroups.com> <48FED1B1.6080902@erix.ericsson.se> <7C818186-A73A-4E2A-BB2B-595AC658AC3A@cs.otago.ac.nz> <49001DA3.40801@erix.ericsson.se> Message-ID: <2B56735E-6052-48B5-86E9-F8B0F7FD4027@cs.otago.ac.nz> On 23 Oct 2008, at 7:45 pm, Dan Gudmundsson wrote: > Agree, but I think that was the motivation. > mnesia:read/1 was the original api function which was kept > when the 'new'* dirty_read/2 and read/3 was introduced. > > So what do you want? > > mnesia:read({Tab,key}, Lock) -> > mnesia:read(Tab,Key,Lock); > or > mnesia:read(Tab,Key) -> > mnesia:read(Tab,Key,read). The second of them is the definition I actually posted. The point, after all, was to satisfy the OP's desire for an interface that was compatible with dirty_read/2. From ulf@REDACTED Thu Oct 23 23:57:41 2008 From: ulf@REDACTED (Ulf Wiger) Date: Thu, 23 Oct 2008 23:57:41 +0200 Subject: [erlang-questions] Why isn't erlang strongly typed? In-Reply-To: <2B56735E-6052-48B5-86E9-F8B0F7FD4027@cs.otago.ac.nz> References: <58fb3ab8-9ec2-43a1-9b69-51803bdb4dbc@r66g2000hsg.googlegroups.com> <48FED1B1.6080902@erix.ericsson.se> <7C818186-A73A-4E2A-BB2B-595AC658AC3A@cs.otago.ac.nz> <49001DA3.40801@erix.ericsson.se> <2B56735E-6052-48B5-86E9-F8B0F7FD4027@cs.otago.ac.nz> Message-ID: <8209f740810231457m5446ecbaj96b755928a711df7@mail.gmail.com> What the OP could do is to make use of the mnesia:activity(Type, Fun) function, and use the functions mnesia:read/1 and mnesia:write/1 etc. throughout. If Type is set to e.g. async_dirty, all operations will be remapped to their dirty counterparts. I strongly recommend going with transactions until it's abundantly clear that dirty ops are required. In my experience, they very seldom are, but YMMV, of course. BR, Ulf W 2008/10/23 Richard O'Keefe : > > On 23 Oct 2008, at 7:45 pm, Dan Gudmundsson wrote: >> Agree, but I think that was the motivation. >> mnesia:read/1 was the original api function which was kept >> when the 'new'* dirty_read/2 and read/3 was introduced. >> >> So what do you want? >> >> mnesia:read({Tab,key}, Lock) -> >> mnesia:read(Tab,Key,Lock); >> or >> mnesia:read(Tab,Key) -> >> mnesia:read(Tab,Key,read). > > The second of them is the definition I actually posted. > The point, after all, was to satisfy the OP's desire > for an interface that was compatible with dirty_read/2. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From masse@REDACTED Fri Oct 24 00:42:04 2008 From: masse@REDACTED (mats cronqvist) Date: Fri, 24 Oct 2008 00:42:04 +0200 Subject: [erlang-questions] Priviliged ports and effective UID In-Reply-To: <9893-51893@sneakemail.com> (Kevin's message of "23 Oct 2008 19\:35\:01 -0000") References: <9893-51893@sneakemail.com> Message-ID: <87bpxbrl1f.fsf@sterlett.hq.kred> "Kevin" writes: > Hello, I can't find an answer to this anywhere. In erlang how does > one deal with the problem of starting erlang as root, binding to a > privileged port, and then change the effective user id to something > other than root. afaik, the same way you deal with it in all other contexts; port forwarding in iptables. mats From masse@REDACTED Fri Oct 24 01:11:27 2008 From: masse@REDACTED (mats cronqvist) Date: Fri, 24 Oct 2008 01:11:27 +0200 Subject: [erlang-questions] API Design/Documentation In-Reply-To: (Geoff Cant's message of "Wed\, 22 Oct 2008 15\:54\:16 +0200") References: <58fb3ab8-9ec2-43a1-9b69-51803bdb4dbc@r66g2000hsg.googlegroups.com> <1929ACE1-C4D7-4972-B6D3-B58623B60C8A@cs.otago.ac.nz> <20081022041851.GA22961@herbie> <682a2670-e082-4652-aaca-180d27eb62b6@h2g2000hsg.googlegroups.com> Message-ID: <87prlqrjog.fsf@sterlett.hq.kred> Geoff Cant writes: > As a convenience matter it'd be nice if the shell would spit out > function documentation if you try to tab complete on arguments. i.e. distel has something along those lines; 1> otp_doc:sig(erla, sete). ["erlang:setelement(Index, Tuple1, Value) -> Tuple2"] works by parsing the html docs on the fly. note that you don't have to type the whole thing to get a match. the module is used to do tab completion in emacs, but it doesn't depend on anything else in distel. available free of charge at http://code.google.com/p/distel. adding tab completion of args in the shell would be pretty easy, although i personally don't feel enough pain to make it happen. mats From matthew@REDACTED Fri Oct 24 01:15:55 2008 From: matthew@REDACTED (Matthew Dempsky) Date: Thu, 23 Oct 2008 16:15:55 -0700 Subject: [erlang-questions] Why isn't erlang strongly typed? In-Reply-To: <49001DA3.40801@erix.ericsson.se> References: <58fb3ab8-9ec2-43a1-9b69-51803bdb4dbc@r66g2000hsg.googlegroups.com> <48FED1B1.6080902@erix.ericsson.se> <7C818186-A73A-4E2A-BB2B-595AC658AC3A@cs.otago.ac.nz> <49001DA3.40801@erix.ericsson.se> Message-ID: On Wed, Oct 22, 2008 at 11:45 PM, Dan Gudmundsson wrote: > * new means before 1997 :-) What's 'old' mean then? :-) From eliliang@REDACTED Fri Oct 24 00:34:49 2008 From: eliliang@REDACTED (Eli Liang) Date: Thu, 23 Oct 2008 15:34:49 -0700 (PDT) Subject: [erlang-questions] Erlang certification exam? In-Reply-To: <871FF320-735A-40EB-B28A-6ED87BEF809A@telegraphics.com.au> Message-ID: <904006.70245.qm@web30404.mail.mud.yahoo.com> What is the "Erlang certification exam"?? I've seen material from ETC talking about this. ? ? -------------- next part -------------- An HTML attachment was scrubbed... URL: From monch1962@REDACTED Fri Oct 24 01:34:55 2008 From: monch1962@REDACTED (David Mitchell) Date: Fri, 24 Oct 2008 10:34:55 +1100 Subject: [erlang-questions] Updates at CEAN? Message-ID: G'day everyone, Any news on when the CEAN download versions will be updated? The Erlang downloadable is still at R11. No idea what's involved in making it happen - if I can assist, please let me know. Thanks and regards Dave M. From oscar@REDACTED Fri Oct 24 09:49:46 2008 From: oscar@REDACTED (=?ISO-8859-1?Q?Oscar_Hellstr=F6m?=) Date: Fri, 24 Oct 2008 00:49:46 -0700 Subject: [erlang-questions] Feedback Request: Nitrogen - A New Web Framework for Erlang In-Reply-To: <58DB08EE-C850-446E-8ADD-C06F30A3E608@gmail.com> References: <58B8C11B-38D6-42A0-9E95-C1CD7CBF8F83@gmail.com> <58DB08EE-C850-446E-8ADD-C06F30A3E608@gmail.com> Message-ID: <49017E1A.20308@erlang-consulting.com> Hi, Rusty Klophaus wrote: > "I want that to be Nitrogen!" > > Nice! So do I! Let's make it happen! > > > "Well, yaws is not bad once you configure it, I suppose." > > I've heard from a few people that Yaws might not be the best choice. > Nitrogen is relatively loosely coupled to the underlying server, so I > would certainly be open to swapping it for something else. What do > you recommend? I can't say I recommend it right now, but I (and Martin) have started develop something we call gen_httpd where the goal is to provide a very simple HTTP server interface rather than a web server. The motivation behind this is that things such as frameworks, backends with HTTP interfaces etc. usually don't need a web server per say, but only a HTTP interface. Anyway, you can find some code at http://code.hellstrom.st/hg.cgi/ I hope to add some documentation soonish :) > Best, > Rusty > > > On Oct 16, 2008, at 10:12 AM, Joel Reymont wrote: > >> I'm using Yaws as the HTTP server, though as you can see from the >> demo, it doesn't actually hit any .yaws files, instead it goes >> straight to a module. > > Well, yaws is not bad once you configure it, I suppose. > >> You might be interested to know that we ended up talking about you >> and your blog for about 30 minutes at our first meeting, your open >> poker server, > > I'm flattered! I didn't know there's 30 minutes worth of discussion > in the subject :D. > >> and your passion for different languages. :) > > > Speaking of which, I was nursing my Erlang wounds and sulking just > when your message came along. My spirits are much lifted after > watching the screencast! > > The reason for the sulking is that I just rewrote OpenPoker for the > third time and have no idea whether it will truly scale now. I'll > very soon find out. > > The lifting of spirits is because I plan to offer a hosted poker > solution and that needs a web front-end. I want that to be Nitrogen! > > -- > wagerlabs.com > > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- Oscar Hellstr?m, oscar@REDACTED Phone: +44 (0)798 45 44 773 Mobile: +44 (0)207 65 50 337 Web: http://www.erlang-consulting.com From chsu79@REDACTED Fri Oct 24 10:50:40 2008 From: chsu79@REDACTED (Christian) Date: Fri, 24 Oct 2008 10:50:40 +0200 Subject: [erlang-questions] Feedback Request: Nitrogen - A New Web Framework for Erlang In-Reply-To: <49017E1A.20308@erlang-consulting.com> References: <58B8C11B-38D6-42A0-9E95-C1CD7CBF8F83@gmail.com> <58DB08EE-C850-446E-8ADD-C06F30A3E608@gmail.com> <49017E1A.20308@erlang-consulting.com> Message-ID: > I can't say I recommend it right now, but I (and Martin) have started > develop something we call gen_httpd where the goal is to provide a very > simple HTTP server interface rather than a web server. The motivation > behind this is that things such as frameworks, backends with HTTP > interfaces etc. usually don't need a web server per say, but only a HTTP > interface. Anyway, you can find some code at > http://code.hellstrom.st/hg.cgi/ I hope to add some documentation soonish :) A weekend a few weeks ago I started a little fastcgi project: http://frihjul.net/ifastcgi I have tested, and developed, it with nginx and it relays http requests fine. Thanks to {packet, fcgi} mode it was very simple to get it working. What remains is a good well defined failure behavior. The idea is that the ifastcgi application monitors servers that receive fastcgi connections and relays them to the module registed. Allowing you to have multiple running fastcgi servers at different ports and so on, all in the same node. There is no documentation in ifastcgi either :), cant say i have any plans for it either, but ifastcgi_test:run() is a pointer. Also, iserve seem to be a tiny web server that does what you describe gen_httpd as. What I now see a need for is a _standalone library_ for parsing various http headers: dates, cookies, content negotiation,... From pacini@REDACTED Fri Oct 24 10:52:40 2008 From: pacini@REDACTED (Filippo Pacini) Date: Fri, 24 Oct 2008 10:52:40 +0200 Subject: [erlang-questions] Feedback Request: Nitrogen - A New Web Framework for Erlang In-Reply-To: <49017E1A.20308@erlang-consulting.com> References: <58B8C11B-38D6-42A0-9E95-C1CD7CBF8F83@gmail.com> <58DB08EE-C850-446E-8ADD-C06F30A3E608@gmail.com> <49017E1A.20308@erlang-consulting.com> Message-ID: <49018CD8.70304@sgconsulting.it> Oscar Hellstr?m wrote: > Hi, > > Rusty Klophaus wrote: >> >> I've heard from a few people that Yaws might not be the best choice. >> Nitrogen is relatively loosely coupled to the underlying server, so I >> would certainly be open to swapping it for something else. What do >> you recommend? > > I can't say I recommend it right now, but I (and Martin) have started > develop something we call gen_httpd where the goal is to provide a very > simple HTTP server interface rather than a web server. The motivation > behind this is that things such as frameworks, backends with HTTP > interfaces etc. usually don't need a web server per say, but only a HTTP > interface. Anyway, you can find some code at > http://code.hellstrom.st/hg.cgi/ I hope to add some documentation soonish :) > You might also be interested in ewgi (Erlang Web Gateway Interface). Seems similar to gen_httpd. It defines a standard interface for Erlang web applications and frameworks to interact with underlying web servers. http://code.google.com/p/ewgi/ Here the specs: http://code.google.com/p/ewgi/wiki/EWGISpecification I wouldn't recommend it right now either. If you are interested join the google group. cheers, filippo From jesper.louis.andersen@REDACTED Fri Oct 24 11:17:02 2008 From: jesper.louis.andersen@REDACTED (Jesper Louis Andersen) Date: Fri, 24 Oct 2008 11:17:02 +0200 Subject: [erlang-questions] Why isn't erlang strongly typed? In-Reply-To: <083AD28775D80048925EE4273AFD41030164166B@thor.infoblox.com> References: <58fb3ab8-9ec2-43a1-9b69-51803bdb4dbc@r66g2000hsg.googlegroups.com> <48FED1B1.6080902@erix.ericsson.se> <7C818186-A73A-4E2A-BB2B-595AC658AC3A@cs.otago.ac.nz> <49001DA3.40801@erix.ericsson.se> <083AD28775D80048925EE4273AFD41030164166B@thor.infoblox.com> Message-ID: <56a0a2840810240217m6f345b10p81dc4727961bb301@mail.gmail.com> 2008/10/23 Stuart Bailey : > There is a very enjoyable and rigorous treatment of many of the issues > raised on this thread in the book: > > Types and Programming Languages by Benjamin C. Pierce. TAPL is a wonderful book indeed. However, I feel it is a bit misplaced in this discussion. The problem is not the fact that you can (simply type) the lambda calculus, but you need some more heavyweight machinery to incorporate the message passing. The hard thing in type theory is when you begin to combine the different ideas from TAPL into one language. It is exactly this strain which makes Haskell and ML impressive. The hardest thing to get a good type system for will be the message passing semantics. Just building a big sum-type of all messages that can be received is probably not enough: the type system will catch far too few errors to be interesting. On the other hand, I've toyed with the idea of using substructural types to prove that a message can be passed by pointer rather than copied between 2 processes. That is, the type of the sender proves that once the message is sent, it is the last use. Food for thought: You can augment any language with a type system. There is one type, TET (The Erlang Type), and all expressions have type TET. It works, but the system is trivial. You can't *use* it for anything. If you want the type system to provide you any help, it must be designed cleverly. The design must be such that whenever you do something wrong, there is a high chance of tripping the type system. From sbailey@REDACTED Fri Oct 24 18:32:32 2008 From: sbailey@REDACTED (Stuart Bailey) Date: Fri, 24 Oct 2008 09:32:32 -0700 Subject: [erlang-questions] Why isn't erlang strongly typed? References: <58fb3ab8-9ec2-43a1-9b69-51803bdb4dbc@r66g2000hsg.googlegroups.com><48FED1B1.6080902@erix.ericsson.se><7C818186-A73A-4E2A-BB2B-595AC658AC3A@cs.otago.ac.nz><49001DA3.40801@erix.ericsson.se><083AD28775D80048925EE4273AFD41030164166B@thor.infoblox.com> <56a0a2840810240217m6f345b10p81dc4727961bb301@mail.gmail.com> Message-ID: <083AD28775D80048925EE4273AFD41030164166C@thor.infoblox.com> Jesper, I am glad you enjoyed the book as well. Unfortunately, I cannot respond to your other points as I did not understand them. Were you discussing the relationship between computer programing language typing systems and message passing vocabularies? Stu -----Original Message----- From: Jesper Louis Andersen [mailto:jesper.louis.andersen@REDACTED] Sent: Fri 10/24/2008 2:17 AM To: Stuart Bailey Cc: Erlang (E-mail) Subject: Re: [erlang-questions] Why isn't erlang strongly typed? 2008/10/23 Stuart Bailey : > There is a very enjoyable and rigorous treatment of many of the issues > raised on this thread in the book: > > Types and Programming Languages by Benjamin C. Pierce. TAPL is a wonderful book indeed. However, I feel it is a bit misplaced in this discussion. The problem is not the fact that you can (simply type) the lambda calculus, but you need some more heavyweight machinery to incorporate the message passing. The hard thing in type theory is when you begin to combine the different ideas from TAPL into one language. It is exactly this strain which makes Haskell and ML impressive. The hardest thing to get a good type system for will be the message passing semantics. Just building a big sum-type of all messages that can be received is probably not enough: the type system will catch far too few errors to be interesting. On the other hand, I've toyed with the idea of using substructural types to prove that a message can be passed by pointer rather than copied between 2 processes. That is, the type of the sender proves that once the message is sent, it is the last use. Food for thought: You can augment any language with a type system. There is one type, TET (The Erlang Type), and all expressions have type TET. It works, but the system is trivial. You can't *use* it for anything. If you want the type system to provide you any help, it must be designed cleverly. The design must be such that whenever you do something wrong, there is a high chance of tripping the type system. -------------- next part -------------- An HTML attachment was scrubbed... URL: From drcabana@REDACTED Fri Oct 24 19:18:18 2008 From: drcabana@REDACTED (David Cabana) Date: Fri, 24 Oct 2008 13:18:18 -0400 Subject: [erlang-questions] Question re console io in a distributed computation Message-ID: <44ed5e0f0810241018y202b3dcdt4809b0d24c335c0f@mail.gmail.com> I'm writing a simple distributed quiz game intended to work as follows. A referee process waits for two player processes to join the game. Once the players have joined, the referee sends the players questions, and the players respond with answers. The first player to correctly answer N questions is the winner. My initial approach was to get dummy messages flowing on a single erlang node. To see that this is working, I write to the console upon receipt of messages, as seen below, in the main loop of a player process. loop(Nickname)-> receive {_From, stop} -> io:format("~p:: ~p received stop msg ~n", [?MODULE, Nickname]), player_stopped; {From, {question, N} } -> io:format("~p:: ~p received question ~p~n", [?MODULE, Nickname, N]), From ! {self(), {answer,N} }, loop(Nickname); Other -> io:format("~p ~p received unknown msg ~p~n", [?MODULE, Nickname, Other]), loop(Nickname) end. Everything worked as expected on a single node, so my next step was to get things working across multiple nodes. I created a referee node and two player nodes, each running its respective process. The messages flow correctly, but all the terminal io happens in a single console, the one associated with the referee node. My question is how to get player output written to the console of the corresponding player node? Eventually I want the nodes to run on separate computers, and the console output (questions) to be read by actual players, so I need the output to go to the right place. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf.wiger@REDACTED Fri Oct 24 20:44:59 2008 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Fri, 24 Oct 2008 20:44:59 +0200 Subject: [erlang-questions] Question re console io in a distributed computation In-Reply-To: <44ed5e0f0810241018y202b3dcdt4809b0d24c335c0f@mail.gmail.com> References: <44ed5e0f0810241018y202b3dcdt4809b0d24c335c0f@mail.gmail.com> Message-ID: <490217AB.3050505@ericsson.com> David Cabana skrev: > > The messages flow correctly, but all the terminal > io happens in > a single console, the one associated with the referee node. > > My question is how to get player output written to the console of the > corresponding > player node? Use io:format(user, Fmt, Args) Alternatively, set the group leader of the process to some local process - e.g. the group leader of net_kernel (found by calling process_info(whereis(net_kernel),group_leader)). The group leader is the process that's handed all io messages. The rpc server deliberately sets the group leader of an rpc handler process to that of the caller on the originating node, since the remote node may not always have a tty to print to. When spawning, the group leader of the spawned process will be inherited from the parent. If you spawn a process on another node, it will still have the same group leader as the parent. The BIF group_leader(Pid,New_group_leader_pid) sets a new leader. BR, Ulf W From drcabana@REDACTED Fri Oct 24 22:09:19 2008 From: drcabana@REDACTED (David Cabana) Date: Fri, 24 Oct 2008 16:09:19 -0400 Subject: [erlang-questions] Question re console io in a distributed computation In-Reply-To: <490217AB.3050505@ericsson.com> References: <44ed5e0f0810241018y202b3dcdt4809b0d24c335c0f@mail.gmail.com> <490217AB.3050505@ericsson.com> Message-ID: <44ed5e0f0810241309h33d2f514q701c8b5fd84ae72d@mail.gmail.com> Ulf, Thank you for your help. I found very useful your observation that "When spawning, the group leader of the spawned process will be inherited from the parent. If you spawn a process on another node, it will still have the same group leader as the parent." As a convenience during testing, I was letting the referee process spawn the player processes, and evreyone wound up having the same group leader. It was a simple matter to start the player processes independently of the referee, and then have them register with the referee. After that, console io went to the right place automatically. regards, David On Fri, Oct 24, 2008 at 2:44 PM, Ulf Wiger (TN/EAB) wrote: > David Cabana skrev: > > > >> The messages flow correctly, but all the terminal io happens in >> a single console, the one associated with the referee node. >> >> My question is how to get player output written to the console of the >> corresponding >> player node? >> > > Use io:format(user, Fmt, Args) > > Alternatively, set the group leader of the process to some > local process - e.g. the group leader of net_kernel > (found by calling process_info(whereis(net_kernel),group_leader)). > > The group leader is the process that's handed all io messages. > The rpc server deliberately sets the group leader of an rpc > handler process to that of the caller on the originating node, > since the remote node may not always have a tty to print to. > When spawning, the group leader of the spawned process will > be inherited from the parent. If you spawn a process on > another node, it will still have the same group leader as > the parent. > > The BIF group_leader(Pid,New_group_leader_pid) sets a new > leader. > > BR, > Ulf W > -------------- next part -------------- An HTML attachment was scrubbed... URL: From eliliang@REDACTED Sat Oct 25 03:30:06 2008 From: eliliang@REDACTED (Eli Liang) Date: Fri, 24 Oct 2008 18:30:06 -0700 (PDT) Subject: [erlang-questions] Is it possible to build an 64-bit Erlang for Windows? Message-ID: <55014.57360.qm@web30404.mail.mud.yahoo.com> I've looked through the README.win32 file in the source, and it is leading me to believe that it would be difficult to build an x64 flavor of the binaries for Windows Vista x64. Has anyone tried this? -------------- next part -------------- An HTML attachment was scrubbed... URL: From rapsey@REDACTED Sat Oct 25 12:05:58 2008 From: rapsey@REDACTED (Rapsey) Date: Sat, 25 Oct 2008 12:05:58 +0200 Subject: [erlang-questions] open_port vs. unix pipes Message-ID: <97619b170810250305u4b1a41ceqa3f39f062083c8e7@mail.gmail.com> What is the difference for the program that communicates using stdin and stdout, if it is opened using open_port from within erlang or with unix pipes? I'm trying to use open_port with ffmpeg, this works just fine for instance: cat blabla.mp3 | /opt/local/bin/ffmpeg -f mp3 -i - -acodec libfaac -f flv - > dan.flv But if I use open_port: {ok, Bin} = file:read_file("blabla.mp3"), Port = open_port({spawn, "/opt/local/bin/ffmpeg -f mp3 -i - -acodec libfaac -f flv -"}, [binary, use_stdio, stream]), <> = Bin, Port ! {Port {command, Data}} ffmpeg call will fail with: pipe:: Error while opening file /Sergej -------------- next part -------------- An HTML attachment was scrubbed... URL: From litaocheng@REDACTED Sat Oct 25 14:25:05 2008 From: litaocheng@REDACTED (litao cheng) Date: Sat, 25 Oct 2008 20:25:05 +0800 Subject: [erlang-questions] how to get the factual ip address? Message-ID: hi, everyone. I want to get the factual ip address of my host. when I use the inet:gethostname earn my host name. and then use the inet:gethostbyname/1 or inet:getaddrs/2 to get the ip address. the results is : 127.0.1.1. I can use the ifconfig to see the ip address of eth0 is 192.168.1.101, I want to get this value. how can I do it? btw, If it relate to the inetrc config of kernel app? (my computer os is ubuntu 8.04, OTP R12B4) BS! litaocheng -------------- next part -------------- An HTML attachment was scrubbed... URL: From matthew@REDACTED Sun Oct 26 00:10:54 2008 From: matthew@REDACTED (Matthew Dempsky) Date: Sat, 25 Oct 2008 15:10:54 -0700 Subject: [erlang-questions] how to get the factual ip address? In-Reply-To: References: Message-ID: 2008/10/25 litao cheng : > I can use the ifconfig to see the ip address of eth0 is 192.168.1.101, I > want to get this value. how can I do it? Computers have more than one IP address. E.g., yours has both 127.0.0.1 and 192.168.1.101. Other computers have even more. The inet module has undocumented functions getif/0 and getiflist/0 that might do what you want. Another possibility is to call inet:sockname/1 on an open socket to find what address the operating system used. From vinoski@REDACTED Sun Oct 26 02:09:15 2008 From: vinoski@REDACTED (Steve Vinoski) Date: Sat, 25 Oct 2008 20:09:15 -0400 Subject: [erlang-questions] how to get the factual ip address? In-Reply-To: References: Message-ID: <65b2728e0810251709k6765957dgbb9036cb7e15b339@mail.gmail.com> On 10/25/08, litao cheng wrote: > > hi, everyone. > I want to get the factual ip address of my host. when I use the > inet:gethostname earn my host name. and then use the inet:gethostbyname/1 or > inet:getaddrs/2 to get the ip address. the results is : 127.0.1.1. > I can use the ifconfig to see the ip address of eth0 is 192.168.1.101, I > want to get this value. how can I do it? > btw, If it relate to the inetrc config of kernel app? > (my computer os is ubuntu 8.04, OTP R12B4) There's the following undocumented function: 1> inet:ifget("eth0", [addr]). {ok,[{addr,{192,168,1,101}}]} On Ubuntu "eth0" should work for you, but if you want to know what interfaces you have: 2> inet:getiflist(). {ok,["lo","eth0"]} Also note you can change the IP address tuple to a string like this: 3> inet_parse:ntoa({192,168,1,101}). "192.168.1.101" and back again: 4> inet_parse:address("192.168.1.101"). {ok,{192,168,1,101}} --steve From rapsey@REDACTED Sun Oct 26 10:50:24 2008 From: rapsey@REDACTED (Rapsey) Date: Sun, 26 Oct 2008 10:50:24 +0100 Subject: [erlang-questions] open_port vs. unix pipes In-Reply-To: <97619b170810250305u4b1a41ceqa3f39f062083c8e7@mail.gmail.com> References: <97619b170810250305u4b1a41ceqa3f39f062083c8e7@mail.gmail.com> Message-ID: <97619b170810260250v2eda008ex8921147a18c77ce9@mail.gmail.com> I tried a simple echo.c program: #include #include #include int main() { char readBuff[1024]; int numRead = 0; while ((numRead = read(0, readBuff, 1024)) > 0) { write(1, readBuff, numRead); } return 1; } It seems that read returns with 0 immediately and the program exits. Is this suppose to happen? Sergej On Sat, Oct 25, 2008 at 11:05 AM, Rapsey wrote: > What is the difference for the program that communicates using stdin and > stdout, if it is opened using open_port from within erlang or with unix > pipes? > I'm trying to use open_port with ffmpeg, this works just fine for instance: > > cat blabla.mp3 | /opt/local/bin/ffmpeg -f mp3 -i - -acodec libfaac -f flv > - > dan.flv > > But if I use open_port: > {ok, Bin} = file:read_file("blabla.mp3"), > Port = open_port({spawn, "/opt/local/bin/ffmpeg -f mp3 -i - -acodec libfaac > -f flv -"}, [binary, use_stdio, stream]), > <> = Bin, > Port ! {Port {command, Data}} > > ffmpeg call will fail with: > pipe:: Error while opening file > > > > /Sergej > -------------- next part -------------- An HTML attachment was scrubbed... URL: From litaocheng@REDACTED Sun Oct 26 15:45:56 2008 From: litaocheng@REDACTED (litao cheng) Date: Sun, 26 Oct 2008 22:45:56 +0800 Subject: [erlang-questions] how to get the factual ip address? In-Reply-To: References: Message-ID: thank you very much! that's ok! :) 2008/10/26 Matthew Dempsky > 2008/10/25 litao cheng : > > I can use the ifconfig to see the ip address of eth0 is 192.168.1.101, I > > want to get this value. how can I do it? > > Computers have more than one IP address. E.g., yours has both > 127.0.0.1 and 192.168.1.101. Other computers have even more. The > inet module has undocumented functions getif/0 and getiflist/0 that > might do what you want. > > Another possibility is to call inet:sockname/1 on an open socket to > find what address the operating system used. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From litaocheng@REDACTED Sun Oct 26 15:46:28 2008 From: litaocheng@REDACTED (litao cheng) Date: Sun, 26 Oct 2008 22:46:28 +0800 Subject: [erlang-questions] how to get the factual ip address? In-Reply-To: <65b2728e0810251709k6765957dgbb9036cb7e15b339@mail.gmail.com> References: <65b2728e0810251709k6765957dgbb9036cb7e15b339@mail.gmail.com> Message-ID: thanks you! steve! :) 2008/10/26 Steve Vinoski > On 10/25/08, litao cheng wrote: > > > > hi, everyone. > > I want to get the factual ip address of my host. when I use the > > inet:gethostname earn my host name. and then use the inet:gethostbyname/1 > or > > inet:getaddrs/2 to get the ip address. the results is : 127.0.1.1. > > I can use the ifconfig to see the ip address of eth0 is 192.168.1.101, > I > > want to get this value. how can I do it? > > btw, If it relate to the inetrc config of kernel app? > > (my computer os is ubuntu 8.04, OTP R12B4) > > There's the following undocumented function: > > 1> inet:ifget("eth0", [addr]). > {ok,[{addr,{192,168,1,101}}]} > > On Ubuntu "eth0" should work for you, but if you want to know what > interfaces you have: > > 2> inet:getiflist(). > {ok,["lo","eth0"]} > > Also note you can change the IP address tuple to a string like this: > > 3> inet_parse:ntoa({192,168,1,101}). > "192.168.1.101" > > and back again: > > 4> inet_parse:address("192.168.1.101"). > {ok,{192,168,1,101}} > > --steve > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rapsey@REDACTED Sun Oct 26 16:32:19 2008 From: rapsey@REDACTED (Rapsey) Date: Sun, 26 Oct 2008 16:32:19 +0100 Subject: [erlang-questions] open_port vs. unix pipes In-Reply-To: <6c2563b20810260748j45e832feu20765224138da6fe@mail.gmail.com> References: <97619b170810250305u4b1a41ceqa3f39f062083c8e7@mail.gmail.com> <6c2563b20810260748j45e832feu20765224138da6fe@mail.gmail.com> Message-ID: <97619b170810260832w4e52e504l81d45d2ed0a41ae7@mail.gmail.com> Awesome! Thank you. The stupid bug in my code was: Port ! {Port, {command, Data}} instead of: Port ! {self(), {command, Data}} It works perfectly. Sergej On Sun, Oct 26, 2008 at 3:48 PM, Edwin Fine wrote: > Sergey, > > I tried to write an email about this, but found it easier just to write a > program. It's only 70 lines, so here it is. It's maybe not the best code, > but I did crank it out as fast as I could, and it does seem to work. I > haven't actually tested the binary output to see if it's complete and > correct, but if you specify a file name it does write to the file with no > complaints. > > I hope it helps. > > Example usage: > > {ok,Bin} = file:read_file("/backups/mp3/Allan Holdsworth/Allan Holdsworth - > Devil take the hindmost.mp3"), > Opts = > [{fmt_in,"mp3"},{fmt_out,"flv"},{file_out,"-"},{stderr_redirect,{file,"/tmp/dtth.out"}], > {ok, Results} = ffmpeg:convert(Bin,Opts). > ----------------------- > -module(ffmpeg). > -author("Edwin Fine"). > -export([convert/2, print_responses/1]). > > %% Params are in proplists format: > %% [Opt] - All opts are mandatory except for overwrite, which defaults to > false > %% Opt = {fmt_in, string()} > %% {fmt_out, string()} - must be provided > %% {file_out, string()} - may be "-", in which case the list of > binaries returned will contain the data > %% {overwrite, true|false} - default true > %% {stderr_redirect, {file, string()} | stdin | bit_bucket} - Either > redirects stderr to a given file, to stdin, or /dev/nul > %% {extra, string()} - free format parameters > %% > %% If file_out is set to "-", stderr_redirect should really be to file or > bit_bucket or the returned data will be corrupt > %% > %% Example: > %% > %% Opts = [{fmt_in, "mp3"}, {fmt_out, "flv"}, {file_out, "/tmp/test.flv"}] > %% > %% -> [binary()] > %% > %% Returns a list of binaries output by ffmpeg. > %% > convert(InputBinary, Opts) when is_binary(InputBinary), is_list(Opts) -> > Prog = "/usr/local/bin/ffmpeg", > FmtIn = proplists:get_value(fmt_in, Opts), > FmtOut = proplists:get_value(fmt_out, Opts), > FileOut = proplists:get_value(file_out, Opts), > Extra = proplists:get_value(extra, Opts, ""), > OverWrite = overwrite(proplists:get_value(overwrite, Opts, false)), > Redirect = format_redirect(proplists:get_value(stderr_redirect, Opts, > {file, "/tmp/ffmpeg.out"})), > > PortCmd = build_port_cmd(Prog, FmtIn, FmtOut, OverWrite, FileOut, > Redirect, Extra), > > Port = open_port({spawn, PortCmd}, [binary, use_stdio, stream]), > port_command(Port, InputBinary), > Responses = response_reader(Port), > port_close(Port), > Responses. > > print_responses(Msgs) -> > io:format("~s~n", [binary_to_list(list_to_binary(Msgs))]). > > response_reader(Port) -> > response_reader_loop(Port, []). > > response_reader_loop(Port, L) -> > receive > {Port, {data, Bin}} -> > response_reader_loop(Port, [Bin|L]); > Other -> > io:format("Unexpected: ~p~n", [Other]), > response_reader_loop(Port, L) > after > 1000 -> > {ok, lists:reverse(L)} > end. > > build_port_cmd(Prog, FmtIn, FmtOut, OverWrite, FileOut, Redirect, Extra) -> > lists:concat([ > Prog, " -f ", FmtIn, " -i - ", OverWrite, " -f ", > FmtOut, " ", FileOut, " ", Extra, Redirect] > ). > > overwrite(true) -> "-y"; > overwrite(false) -> "". > > format_redirect({file, File}) -> " 2>" ++ File; > format_redirect(stdin) -> " 2>&1"; > format_redirect(bit_bucket) -> " 2>/dev/null". > --------------- > > 2008/10/25 Rapsey > >> What is the difference for the program that communicates using stdin and >> stdout, if it is opened using open_port from within erlang or with unix >> pipes? >> I'm trying to use open_port with ffmpeg, this works just fine for >> instance: >> >> cat blabla.mp3 | /opt/local/bin/ffmpeg -f mp3 -i - -acodec libfaac -f flv >> - > dan.flv >> >> But if I use open_port: >> {ok, Bin} = file:read_file("blabla.mp3"), >> Port = open_port({spawn, "/opt/local/bin/ffmpeg -f mp3 -i - -acodec >> libfaac -f flv -"}, [binary, use_stdio, stream]), >> <> = Bin, >> Port ! {Port {command, Data}} >> >> ffmpeg call will fail with: >> pipe:: Error while opening file >> >> >> >> /Sergej >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bengt.kleberg@REDACTED Mon Oct 27 07:43:57 2008 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Mon, 27 Oct 2008 07:43:57 +0100 Subject: [erlang-questions] Regular expressions in Plan9 Message-ID: <1225089837.6597.4.camel@seasc0642.dyn.rnd.as.sw.ericsson.se> Greetings, Those that implement/use-a-lot-of regular expressions have previously expressed an interest in the work done on Plan9 on these. Perhaps you would be interested in a thread on comp.os.plan9 ("non greedy regular expressions") that is currently ongoing. bengt From john.hughes@REDACTED Mon Oct 27 12:48:07 2008 From: john.hughes@REDACTED (John Hughes) Date: Mon, 27 Oct 2008 12:48:07 +0100 Subject: [erlang-questions] File creation times under Windows In-Reply-To: References: Message-ID: <0D17E79F6D2B4573B72FD1419DD9846F@HallDesktop> I would have expected that, once a file has been created, then its creation time should remain constant (unless explicitly modified)--wouldn't you? Not so! At least, not under Windows. Under both XP and Vista, the file creation time reported by file:read_file_info changes by an hour when daylight saving time ends (and presumably also when it begins)! File system design according to the Principle of Greatest Astonishment, evidently. John From dawsdesign@REDACTED Mon Oct 27 13:13:42 2008 From: dawsdesign@REDACTED (Matt Williamson) Date: Mon, 27 Oct 2008 08:13:42 -0400 Subject: [erlang-questions] Good reason for not using "releases"? In-Reply-To: <6c2563b20810201500l3c02c0eaw54ca43130b544d8a@mail.gmail.com> References: <15068-87089@sneakemail.com> <6c2563b20810201500l3c02c0eaw54ca43130b544d8a@mail.gmail.com> Message-ID: I've been using erlware as well and it is _quite_ convenient. There are some problems, but the project is still growing rapidly and the conveniences it provides are excellent. 2008/10/20 Edwin Fine > On Mon, Oct 20, 2008 at 4:05 PM, Kevin wrote: > >> >> >> Hello, I'm building my first erlang server program, and I've worked my way >> up from modules, to gen_server and gen_fsm, to supervisor, to application >> behavior. >> >> If this application is going to run on a linux host, and boot using a >> linux init script, does it make sense to take it to the next level of >> "release", or is that just more complication I don't need to deal with. > > > Yes, because you will surely upgrade the code at some point (new features, > bug fixes) and it's a pain to do this by hand or even using scripts. I > suggest taking a look at some open source Erlang-specific software that > allows you to build and distribute (install) your Erlang applications > relatively painlessly. The builder component is called Sinan ( > http://code.google.com/p/sinan/); the distribution/installation component > is called Faxien (http://code.google.com/p/faxien/). I use these for the > job and although there are some minor imperfections, I would never go back > to the "old way". > > Also take a look at the Faxien/Sinan cookbook at > http://myfcci.com/yab/2008/09/11/my-faxiensinan-cookbook/ to get started > (disclosure: I wrote the cookbook, but I have no vested interest in Sinan or > Faxien other than using it for my work). > > I don't ever anticipate the need for hotswapping of code. The users will >> have no issues with just restarting the entire thing just like all the other >> stuff running from init scripts, and they might find hotswapping, or >> whatever fancy stuff releases offers, more work than appreciated. >> > > How would they like to upgrade to the latest release just by typing in "$ > faxien upgrade-release kevins_stuff" and then restart the app? > > >> >> I also don't anticipate this application sharing an running erlang system >> with any other erlang applications. >> >> Thanks, especially if this is such an ignorant question. > > > No question is ignorant. > > Hope this helps. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bqt@REDACTED Mon Oct 27 13:34:32 2008 From: bqt@REDACTED (Johnny Billquist) Date: Mon, 27 Oct 2008 13:34:32 +0100 Subject: [erlang-questions] File creation times under Windows In-Reply-To: <0D17E79F6D2B4573B72FD1419DD9846F@HallDesktop> References: <0D17E79F6D2B4573B72FD1419DD9846F@HallDesktop> Message-ID: <4905B558.6060401@softjar.se> John Hughes wrote: > I would have expected that, once a file has been created, then its creation > time should remain constant (unless explicitly modified)--wouldn't you? Not > so! At least, not under Windows. Under both XP and Vista, the file creation > time reported by file:read_file_info changes by an hour when daylight saving > time ends (and presumably also when it begins)! > > File system design according to the Principle of Greatest Astonishment, > evidently. I believe that's a basic problem with windows, since it don't actually keep time in UTC, but local time, internally. In short: if you use Windows, that's the way it is. Don't have anything to do with Erlang. Johnny From dave.smith.to@REDACTED Mon Oct 27 21:56:40 2008 From: dave.smith.to@REDACTED (Dave Smith) Date: Mon, 27 Oct 2008 16:56:40 -0400 Subject: [erlang-questions] File creation times under Windows In-Reply-To: <4905B558.6060401@softjar.se> References: <0D17E79F6D2B4573B72FD1419DD9846F@HallDesktop> <4905B558.6060401@softjar.se> Message-ID: <5ea453f90810271356l5e47670bu6dfea4ecfe1cb782@mail.gmail.com> NTFS stores time properly in UTC. FAT/FAT32 stores in local time. Either way, time should be displayed in local time when file:read_file_info/1 is called. I did a little digging into the driver code an to appears the the FileTimeToLocalTime Win32API to convert the time. I suspect it is this API call that is the root of the problem. I don't have a Windows platform to test on, so I can't dig any further, but there is a discussion herethat might explain the problem more. 2008/10/27 Johnny Billquist > John Hughes wrote: > > I would have expected that, once a file has been created, then its > creation > > time should remain constant (unless explicitly modified)--wouldn't you? > Not > > so! At least, not under Windows. Under both XP and Vista, the file > creation > > time reported by file:read_file_info changes by an hour when daylight > saving > > time ends (and presumably also when it begins)! > > > > File system design according to the Principle of Greatest Astonishment, > > evidently. > > I believe that's a basic problem with windows, since it don't actually > keep time in UTC, but local time, internally. > > In short: if you use Windows, that's the way it is. Don't have anything > to do with Erlang. > > Johnny > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From camuig@REDACTED Tue Oct 28 08:53:12 2008 From: camuig@REDACTED (Andrey Shnayder) Date: Tue, 28 Oct 2008 10:53:12 +0300 Subject: [erlang-questions] Documentation creation in Russian Message-ID: <3df44f150810280053l49befc88g5fad0ecad3a23ec9@mail.gmail.com> Hi, I need to generate the documentation on my erlang modules in russian. I try to use edoc and docbuilder (they use the same functions however), but I get the error: ------------------------------------------------------------------------- ** exception exit: {badarg,[{io,put_chars, [<0.74.0>, ["\n", "\n", ........ in function io:o_request/2 in call from edoc_lib:write_file/4 ------------------------------------------------------------------------- If I write comments in English there are no errors, but I need documentation in russian. Can you help me? Files encoding is utf-8. Thank you. -------------- next part -------------- An HTML attachment was scrubbed... URL: From john.hughes@REDACTED Tue Oct 28 09:47:16 2008 From: john.hughes@REDACTED (John Hughes) Date: Tue, 28 Oct 2008 09:47:16 +0100 Subject: [erlang-questions] QuickCheck course in Stockholm--registration deadline Message-ID: The QuickCheck course to be held in Stockholm before the Users Conference is filling up, and the registration deadline is now just a few days away--so if you plan to take part, then don't delay in registering. Dates: Nov 10-12th Location: Stockholm Contact: sales@REDACTED Price: 12.500 SEK per participant More information: http://quviq.com John -------------- next part -------------- An HTML attachment was scrubbed... URL: From richardc@REDACTED Tue Oct 28 10:15:33 2008 From: richardc@REDACTED (Richard Carlsson) Date: Tue, 28 Oct 2008 10:15:33 +0100 Subject: [erlang-questions] Documentation creation in Russian In-Reply-To: <3df44f150810280053l49befc88g5fad0ecad3a23ec9@mail.gmail.com> References: <3df44f150810280053l49befc88g5fad0ecad3a23ec9@mail.gmail.com> Message-ID: <4906D835.9020306@it.uu.se> Andrey Shnayder wrote: > Hi, > > I need to generate the documentation on my erlang modules in russian. I > try to use edoc and docbuilder (they use the same functions however), > but I get the error: > > ------------------------------------------------------------------------- > ** exception exit: {badarg,[{io,put_chars, > [<0.74.0>, > ["\n", > "\n", > ........ > in function io:o_request/2 > in call from edoc_lib:write_file/4 > ------------------------------------------------------------------------- > > If I write comments in English there are no errors, but I need > documentation in russian. Can you help me? Files encoding is utf-8. Hi! There is no real support for UTF-8 in Erlang right now (people are working on it), so most things assume Latin-1 encoding in input and output. If you can send me a minimal test case (a small .erl file in UTF-8 that causes the crash) I can try and find a workaround for edoc. /Richard From goofyheadedpunk@REDACTED Tue Oct 28 10:18:09 2008 From: goofyheadedpunk@REDACTED (Brian Troutwine) Date: Tue, 28 Oct 2008 02:18:09 -0700 Subject: [erlang-questions] Target system installation difficulties. Message-ID: <971980cc0810280218k4a9e1069uea135ae7504ff6d3@mail.gmail.com> Hello all, I've grown enough as an Erlang developer that having proper release handling is now appealing to me. For this I need a properly installed target system, which I gave up on previously out of frustration. Starting with the OTP Design Principles I am able to get all the way through section 10.4, up until the point where the documentation states "Refer to System Principles for how to install the first target system..." After heading on over to the System Principles I was quite perturbed to see that it's using a custom script to handle installation. I dutifully started over from the top of the System Principles document, getting to section 3.3 before being greeted with this: 3> target_system:install("aule", "/usr/local/erl-target"). Extracting aule.tar.gz ... Substituting in erl.src, start.src and start_erl.src to form erl, start and start_erl ... ** exception error: no match of right hand side value {error,enoent} in function target_system:read_txt_file/1 in call from target_system:subst_file/4 in call from lists:foreach/2 in call from target_system:install/2 The file it's choking on is /usr/local/erl-target/erts-5.6.3/bin/erl.src, which does not exist. Yikes. Have I done something wrong? Can someone explain, in a manner more clear than the documentation provided, how to complete my task? Thanks, Brian From camuig@REDACTED Tue Oct 28 10:51:00 2008 From: camuig@REDACTED (Andrey Shnayder) Date: Tue, 28 Oct 2008 12:51:00 +0300 Subject: [erlang-questions] Documentation creation in Russian In-Reply-To: <4906D835.9020306@it.uu.se> References: <3df44f150810280053l49befc88g5fad0ecad3a23ec9@mail.gmail.com> <4906D835.9020306@it.uu.se> Message-ID: <3df44f150810280251s7f50d4aej3a54bd7b87ff27d6@mail.gmail.com> Thank you for your reply, Richard! I have created small test module with edoc comments in russian. I have attached it to the message. 2008/10/28, Richard Carlsson : > > Andrey Shnayder wrote: > > Hi, > > > > I need to generate the documentation on my erlang modules in russian. I > > try to use edoc and docbuilder (they use the same functions however), > > but I get the error: > > > > ------------------------------------------------------------------------- > > ** exception exit: {badarg,[{io,put_chars, > > [<0.74.0>, > > ["\n", > > "\n", > > ........ > > in function io:o_request/2 > > in call from edoc_lib:write_file/4 > > ------------------------------------------------------------------------- > > > > If I write comments in English there are no errors, but I need > > documentation in russian. Can you help me? Files encoding is utf-8. > > > Hi! > There is no real support for UTF-8 in Erlang right now (people > are working on it), so most things assume Latin-1 encoding in > input and output. If you can send me a minimal test case (a small > .erl file in UTF-8 that causes the crash) I can try and find a > workaround for edoc. > > > /Richard -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: test.erl Type: application/octet-stream Size: 1182 bytes Desc: not available URL: From bqt@REDACTED Tue Oct 28 10:55:04 2008 From: bqt@REDACTED (Johnny Billquist) Date: Tue, 28 Oct 2008 10:55:04 +0100 Subject: [erlang-questions] File creation times under Windows In-Reply-To: <5ea453f90810271356l5e47670bu6dfea4ecfe1cb782@mail.gmail.com> References: <0D17E79F6D2B4573B72FD1419DD9846F@HallDesktop> <4905B558.6060401@softjar.se> <5ea453f90810271356l5e47670bu6dfea4ecfe1cb782@mail.gmail.com> Message-ID: <4906E178.4070708@softjar.se> Dave Smith wrote: > NTFS stores time properly in UTC. FAT/FAT32 stores in local time. > Either way, time should be displayed in local time when > file:read_file_info/1 is called. > > I did a little digging into the driver code an to appears the the > FileTimeToLocalTime Win32API to convert the time. I suspect it is this > API call that is the root of the problem. I don't have a Windows > platform to test on, so I can't dig any further, but there is a > discussion here > that might explain the problem more. Looks like you're right. It's storing the timestamp in UTC, but then destroys it when retrieving it, trying to make a local time of it. Well, still a general bug in Windows, which don't have anything to do with Erlang. In fact, from the way Windows seems to behave, you get a better result (in this aspect) from FAT than NTFS file systems... Johnny > > > > 2008/10/27 Johnny Billquist > > > John Hughes wrote: > > I would have expected that, once a file has been created, then > its creation > > time should remain constant (unless explicitly > modified)--wouldn't you? Not > > so! At least, not under Windows. Under both XP and Vista, the > file creation > > time reported by file:read_file_info changes by an hour when > daylight saving > > time ends (and presumably also when it begins)! > > > > File system design according to the Principle of Greatest > Astonishment, > > evidently. > > I believe that's a basic problem with windows, since it don't actually > keep time in UTC, but local time, internally. > > In short: if you use Windows, that's the way it is. Don't have anything > to do with Erlang. > > Johnny > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > From Bill.McKeeman@REDACTED Tue Oct 28 14:14:39 2008 From: Bill.McKeeman@REDACTED (Bill McKeeman) Date: Tue, 28 Oct 2008 09:14:39 -0400 Subject: [erlang-questions] Documentation creation in Russian In-Reply-To: <3df44f150810280251s7f50d4aej3a54bd7b87ff27d6@mail.gmail.com> References: <3df44f150810280053l49befc88g5fad0ecad3a23ec9@mail.gmail.com> <4906D835.9020306@it.uu.se> <3df44f150810280251s7f50d4aej3a54bd7b87ff27d6@mail.gmail.com> Message-ID: A word about utf8 support. Python supports utf8 and ascii as separate types. I think this was a good decision. If Erlang replaces ascii with utf8, it will slow down a lot of things that are currently fast. /w/ From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Andrey Shnayder Sent: Tuesday, October 28, 2008 5:51 AM To: Richard Carlsson Cc: erlang-questions@REDACTED Subject: Re: [erlang-questions] Documentation creation in Russian Thank you for your reply, Richard! I have created small test module with edoc comments in russian. I have attached it to the message. 2008/10/28, Richard Carlsson >: Andrey Shnayder wrote: > Hi, > > I need to generate the documentation on my erlang modules in russian. I > try to use edoc and docbuilder (they use the same functions however), > but I get the error: > > ------------------------------------------------------------------------- > ** exception exit: {badarg,[{io,put_chars, > [<0.74.0>, > ["\n", > "\n", > ........ > in function io:o_request/2 > in call from edoc_lib:write_file/4 > ------------------------------------------------------------------------- > > If I write comments in English there are no errors, but I need > documentation in russian. Can you help me? Files encoding is utf-8. Hi! There is no real support for UTF-8 in Erlang right now (people are working on it), so most things assume Latin-1 encoding in input and output. If you can send me a minimal test case (a small .erl file in UTF-8 that causes the crash) I can try and find a workaround for edoc. /Richard -------------- next part -------------- An HTML attachment was scrubbed... URL: From akos.kutvolgyi@REDACTED Tue Oct 28 14:28:45 2008 From: akos.kutvolgyi@REDACTED (Akos kutvolgyi) Date: Tue, 28 Oct 2008 14:28:45 +0100 Subject: [erlang-questions] Is it a Bug? odbc:param_query when using in_or_out() in Params list Message-ID: <4907138D.7090308@sei.hu> Hello All The documentation says the following about Params in the param_query section Params = [{odbc_data_type(), [value()]}] |[{odbc_data_type(), in_or_out(), [value()]}] So the Params List's element could be a tuple with three elements. in odbc.erl param_query(ConnectionReference, SQLQuery, Params, infinity) when pid(ConnectionReference), list(SQLQuery), list(Params) -> [{_, Values} | _] = Params, This line may cause badmatch :( NoRows = length(Values), NewParams = lists:map(fun fix_params/1, Params), ODBCCmd = [?PARAM_QUERY, term_to_binary({SQLQuery ++ [?STR_TERMINATOR], NoRows, NewParams})], call(ConnectionReference, {param_query, ODBCCmd}, infinity); Instead of that line we should use ... [H|_T] = Params, Values = case H of {_,_,Vals} -> Vals; {_,Vals} -> Vals; end, ... Or I mistaking something :S Regards, ?kos K?tv?lgyi -------------- next part -------------- An HTML attachment was scrubbed... URL: From vlm@REDACTED Tue Oct 28 14:44:09 2008 From: vlm@REDACTED (Lev Walkin) Date: Tue, 28 Oct 2008 06:44:09 -0700 Subject: [erlang-questions] Documentation creation in Russian In-Reply-To: References: <3df44f150810280053l49befc88g5fad0ecad3a23ec9@mail.gmail.com> <4906D835.9020306@it.uu.se> <3df44f150810280251s7f50d4aej3a54bd7b87ff27d6@mail.gmail.com> Message-ID: <49071729.4030601@lionet.info> Bill McKeeman wrote: > > > A word about utf8 support. Python supports utf8 and ascii as separate > types. I think this was a good decision. If Erlang replaces ascii with > utf8, it will slow down a lot of things that are currently fast. /w/ On the contrary, it is going to make faster many things that are acurrently slow. Since our contradictory propositions are equally unsubstantiated, the mathematical expectation is that the utf-8 solution is going to be just as fast as the present state of things. > *From:* erlang-questions-bounces@REDACTED > [mailto:erlang-questions-bounces@REDACTED] *On Behalf Of *Andrey Shnayder > *Sent:* Tuesday, October 28, 2008 5:51 AM > *To:* Richard Carlsson > *Cc:* erlang-questions@REDACTED > *Subject:* Re: [erlang-questions] Documentation creation in Russian > > > > Thank you for your reply, Richard! > I have created small test module with edoc comments in russian. I have > attached it to the message. > > 2008/10/28, Richard Carlsson >: > > Andrey Shnayder wrote: > > Hi, > > > > I need to generate the documentation on my erlang modules in russian. I > > try to use edoc and docbuilder (they use the same functions however), > > but I get the error: > > > > ------------------------------------------------------------------------- > > ** exception exit: {badarg,[{io,put_chars, > > [<0.74.0>, > > ["\n", > > "\n", > > ........ > > in function io:o_request/2 > > in call from edoc_lib:write_file/4 > > ------------------------------------------------------------------------- > > > > If I write comments in English there are no errors, but I need > > documentation in russian. Can you help me? Files encoding is utf-8. > > > Hi! > There is no real support for UTF-8 in Erlang right now (people > are working on it), so most things assume Latin-1 encoding in > input and output. If you can send me a minimal test case (a small > .erl file in UTF-8 that causes the crash) I can try and find a > workaround for edoc. > > > /Richard > > > > > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From erlang-questions_efine@REDACTED Tue Oct 28 15:34:36 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Tue, 28 Oct 2008 10:34:36 -0400 Subject: [erlang-questions] Target system installation difficulties. In-Reply-To: <971980cc0810280218k4a9e1069uea135ae7504ff6d3@mail.gmail.com> References: <971980cc0810280218k4a9e1069uea135ae7504ff6d3@mail.gmail.com> Message-ID: <6c2563b20810280734h3b186acdnb04230349cc24c61@mail.gmail.com> Brian, I struggled with releases and eventually started using Sinan and Faxien. Although still maturing, and needing attention for more complex applications, these tools have saved me enormous time and trouble. It may be worth your while, if you haven't already, to take a look at them. http://erlware.org/erlware/index.html Note: I have no interest in, or connection with these tools or their authors, other than as a tools user. Regards, Edwin Fine On Tue, Oct 28, 2008 at 5:18 AM, Brian Troutwine wrote: > Hello all, > > I've grown enough as an Erlang developer that having proper release > handling is now appealing to me. For this I need a properly installed > target system, which I gave up on previously out of frustration. > Starting with the OTP Design Principles I am able to get all the way > through section 10.4, up until the point where the documentation > states "Refer to System Principles for how to install the first target > system..." > > After heading on over to the System Principles I was quite perturbed > to see that it's using a custom script to handle installation. I > dutifully started over from the top of the System Principles document, > getting to section 3.3 before being greeted with this: > > 3> target_system:install("aule", "/usr/local/erl-target"). > Extracting aule.tar.gz ... > Substituting in erl.src, start.src and start_erl.src to > form erl, start and start_erl ... > ** exception error: no match of right hand side value {error,enoent} > in function target_system:read_txt_file/1 > in call from target_system:subst_file/4 > in call from lists:foreach/2 > in call from target_system:install/2 > > The file it's choking on is > /usr/local/erl-target/erts-5.6.3/bin/erl.src, which does not exist. > > Yikes. Have I done something wrong? Can someone explain, in a manner > more clear than the documentation provided, how to complete my task? > > Thanks, > Brian > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dave.smith.to@REDACTED Tue Oct 28 18:24:11 2008 From: dave.smith.to@REDACTED (Dave Smith) Date: Tue, 28 Oct 2008 13:24:11 -0400 Subject: [erlang-questions] Documentation creation in Russian In-Reply-To: <4906D835.9020306@it.uu.se> References: <3df44f150810280053l49befc88g5fad0ecad3a23ec9@mail.gmail.com> <4906D835.9020306@it.uu.se> Message-ID: <5ea453f90810281024sf46648flb317b4bfdc8592ca@mail.gmail.com> Hi Richard, When you say people are working on it, are you referring to EEP 10? This deals with a lot of good stuff, including Lists, Binaries, IO and conversion modules. It doesn't, however, deal with source file encodings. It also doesn't mention atoms and shell support. Has any thought been given to these? If so, would they be include in EEP 10? or other EEP? Thanks 2008/10/28 Richard Carlsson > > Hi! > There is no real support for UTF-8 in Erlang right now (people > are working on it), so most things assume Latin-1 encoding in > input and output. If you can send me a minimal test case (a small > .erl file in UTF-8 that causes the crash) I can try and find a > workaround for edoc. > > /Richard > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From klacke@REDACTED Tue Oct 28 19:10:40 2008 From: klacke@REDACTED (Claes Wikstrom) Date: Tue, 28 Oct 2008 19:10:40 +0100 Subject: [erlang-questions] Priviliged ports and effective UID In-Reply-To: <9893-51893@sneakemail.com> References: <9893-51893@sneakemail.com> Message-ID: <490755A0.5040002@hyber.org> Kevin wrote: > > Hello, I can't find an answer to this anywhere. In erlang how does one deal with the problem of starting erlang as root, binding to a privileged port, and then change the effective user id to something other than root. > > In a daemon process written in c or even perl, a process is started by an init script, which is run as root, it then binds to port, 25, 80, etc, and then it sets its effective UID and effective GID to something more harmless, like httpd/httpd. > > I know you can start the whole thing like su httpd -c erl, but this doesnt allow for binding to prilileged port first. > > And please don't tell me to use open_port() or write a linked in driver :-) open_port will not work, this code has to execute in the same UNIX process. I used to have support for this in Yaws, whereby Yaws started as root, bound its ports and then changed uid. This was good, however it led to major havocs with some other stuff, e.g. ownership of logfiles etc, so I actually removed the feature. The code is still there in yaws though - as a linked in driver. You can find the driver (setuid_drv.c ) in the yaws src. It has to be a linked in driver, either that or change the emulator source. There is no other way. There are some tips at http://yaws.hyber.org/wiki/showPage.yaws?node=fdserver /klacke From vik@REDACTED Wed Oct 29 00:47:41 2008 From: vik@REDACTED (Vik Olliver) Date: Wed, 29 Oct 2008 12:47:41 +1300 Subject: [erlang-questions] Recreating a PID from a log file. Message-ID: <1225237661.1107.55.camel@localhost> I have the value of a PID in a log file. It's given as: <0.24454.8> How can I stuff it back into a variable? :1> Pid=<0.24454.8>. ** 1: syntax error before: 8 ** :1> Vik :v) From fess-erlang@REDACTED Wed Oct 29 00:57:35 2008 From: fess-erlang@REDACTED (fess) Date: Tue, 28 Oct 2008 16:57:35 -0700 Subject: [erlang-questions] Recreating a PID from a log file. In-Reply-To: <1225237661.1107.55.camel@localhost> References: <1225237661.1107.55.camel@localhost> Message-ID: <5AF53C95-6D10-4D52-87B7-E4D23C23F0F7@fess.org> On Oct 28, 2008, at 4:47 PM, Vik Olliver wrote: > I have the value of a PID in a log file. It's given as: > > <0.24454.8> > > How can I stuff it back into a variable? > > > :1> Pid=<0.24454.8>. > ** 1: syntax error before: 8 ** > :1> I'm sure this answer will be one of many but, I actually know this one. :D Pid=list_to_pid("<0.24454.8>"). --fess From mark.geib@REDACTED Wed Oct 29 01:04:49 2008 From: mark.geib@REDACTED (Mark Geib) Date: Tue, 28 Oct 2008 18:04:49 -0600 Subject: [erlang-questions] Problems with sending UDP datagrams without buffering Message-ID: <4907A8A1.2090701@echostar.com> I have a case where I MUST send datagrams that are smaller than a network frame. The device I am sending to will not except larger datagrams. I am sending message that are less than 700 bytes in length, but on the network using a sniffer I periodically see datagrams from the application that are 7000 bytes or so in size. The data is correct, the end device will not accept. I am sending these datagrams about every 20 miliseconds. Is there an option I am missing to force every gen_dup:send() to cause the datagram to be sent.?? I am running on linux 2.6.27 kernel. -- Principal Engineer Cheyenne Software Engineering mark.geib@REDACTED / 35-215 From florian.ebeling@REDACTED Wed Oct 29 01:12:35 2008 From: florian.ebeling@REDACTED (C. Florian Ebeling) Date: Wed, 29 Oct 2008 01:12:35 +0100 Subject: [erlang-questions] Good reason for not using "releases"? In-Reply-To: References: <15068-87089@sneakemail.com> <6c2563b20810201500l3c02c0eaw54ca43130b544d8a@mail.gmail.com> Message-ID: <5cbbe4ae0810281712k5a3780cdh88252681df3de2ea@mail.gmail.com> >>> Hello, I'm building my first erlang server program, and I've worked my >>> way up from modules, to gen_server and gen_fsm, to supervisor, to >>> application behavior. >>> >>> If this application is going to run on a linux host, and boot using a >>> linux init script, does it make sense to take it to the next level of >>> "release", or is that just more complication I don't need to deal with. To me it seems like the erlang "application" concept is not quite what you ususally would call an application. It encompasses code, plus process(es) to be started an stopped in an orderly fashion. But since processes are ubiquitous in erlang, you have to start something in most cases. So an application feels to be analogous to a module in other environments, and what is an application elsewhere is an erlang release, because it integrates several applications, including init order and such. So it is not as much over-engeneering as it might appear in the beginning. Since you get upgrade facilities on top you should really consider creating a system as an release. Florian -- Florian Ebeling Twitter: febeling florian.ebeling@REDACTED From Bill.McKeeman@REDACTED Wed Oct 29 01:12:43 2008 From: Bill.McKeeman@REDACTED (Bill McKeeman) Date: Tue, 28 Oct 2008 20:12:43 -0400 Subject: [erlang-questions] Documentation creation in Russian In-Reply-To: <49071729.4030601@lionet.info> References: <3df44f150810280053l49befc88g5fad0ecad3a23ec9@mail.gmail.com> <4906D835.9020306@it.uu.se> <3df44f150810280251s7f50d4aej3a54bd7b87ff27d6@mail.gmail.com> <49071729.4030601@lionet.info> Message-ID: Lev, When one of our propositions is substantiated, the truth will be known. Since I do not have to invest in the experiment, I am content to wait. /s/ Bill -----Original Message----- From: Lev Walkin [mailto:vlm@REDACTED] Sent: Tuesday, October 28, 2008 9:44 AM To: Bill McKeeman Cc: Andrey Shnayder; Richard Carlsson; erlang-questions@REDACTED Subject: Re: [erlang-questions] Documentation creation in Russian Bill McKeeman wrote: > > > A word about utf8 support. Python supports utf8 and ascii as separate > types. I think this was a good decision. If Erlang replaces ascii with > utf8, it will slow down a lot of things that are currently fast. /w/ On the contrary, it is going to make faster many things that are acurrently slow. Since our contradictory propositions are equally unsubstantiated, the mathematical expectation is that the utf-8 solution is going to be just as fast as the present state of things. > *From:* erlang-questions-bounces@REDACTED > [mailto:erlang-questions-bounces@REDACTED] *On Behalf Of *Andrey Shnayder > *Sent:* Tuesday, October 28, 2008 5:51 AM > *To:* Richard Carlsson > *Cc:* erlang-questions@REDACTED > *Subject:* Re: [erlang-questions] Documentation creation in Russian > > > > Thank you for your reply, Richard! > I have created small test module with edoc comments in russian. I have > attached it to the message. > > 2008/10/28, Richard Carlsson >: > > Andrey Shnayder wrote: > > Hi, > > > > I need to generate the documentation on my erlang modules in russian. I > > try to use edoc and docbuilder (they use the same functions however), > > but I get the error: > > > > ------------------------------------------------------------------------- > > ** exception exit: {badarg,[{io,put_chars, > > [<0.74.0>, > > ["\n", > > "\n", > > ........ > > in function io:o_request/2 > > in call from edoc_lib:write_file/4 > > ------------------------------------------------------------------------- > > > > If I write comments in English there are no errors, but I need > > documentation in russian. Can you help me? Files encoding is utf-8. > > > Hi! > There is no real support for UTF-8 in Erlang right now (people > are working on it), so most things assume Latin-1 encoding in > input and output. If you can send me a minimal test case (a small > .erl file in UTF-8 that causes the crash) I can try and find a > workaround for edoc. > > > /Richard > > > > > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From ok@REDACTED Wed Oct 29 01:30:08 2008 From: ok@REDACTED (Richard O'Keefe) Date: Wed, 29 Oct 2008 13:30:08 +1300 Subject: [erlang-questions] Recreating a PID from a log file. In-Reply-To: <5AF53C95-6D10-4D52-87B7-E4D23C23F0F7@fess.org> References: <1225237661.1107.55.camel@localhost> <5AF53C95-6D10-4D52-87B7-E4D23C23F0F7@fess.org> Message-ID: The Erlang documentation for the 'erlang' module has a big scary red box warning: This BIF is intended for debugging and for use in the Erlang operating system. It should not be used in application programs. The big problem is that just because you have <0.24454.8> in a log and Pid = list_to_pid("<0.24454.8>") succeeds and gives you a "process id", - it need not be the id of ANY process (now) - if it is the id of some process, it need not be the one you think it is. If you are using this for debugging, fine, but trust it about as much as you would trust a cardboard ladder. From cjsvance@REDACTED Wed Oct 29 01:39:07 2008 From: cjsvance@REDACTED (Christopher Vance) Date: Wed, 29 Oct 2008 11:39:07 +1100 Subject: [erlang-questions] Priviliged ports and effective UID In-Reply-To: <490755A0.5040002@hyber.org> References: <9893-51893@sneakemail.com> <490755A0.5040002@hyber.org> Message-ID: An alternate approach, if you have the appropriate permissions, is to use port forwarding. On one of my systems, I had port 443 forwarded to 1029, and in the yaws configuration had port set to 1029 and rhost set to :443. (This was embedded, so I used yaws_api:setconf, not a file.) Setting up the port forwarding requires both the presence of appropriate software, and of somebody authorized to configure it, but it does mean that an unprivileged user can from then on start and stop the server without requiring further privileged actions. -- Christopher Vance From vik@REDACTED Wed Oct 29 01:48:21 2008 From: vik@REDACTED (Vik Olliver) Date: Wed, 29 Oct 2008 13:48:21 +1300 Subject: [erlang-questions] Recreating a PID from a log file. In-Reply-To: References: <1225237661.1107.55.camel@localhost> <5AF53C95-6D10-4D52-87B7-E4D23C23F0F7@fess.org> Message-ID: <1225241301.1107.70.camel@localhost> Yes, is for debugging. I needed the PID field to retrieve a message to find out what the heck was going on. Vik :v) On Wed, 2008-10-29 at 13:30 +1300, Richard O'Keefe wrote: > The Erlang documentation for the 'erlang' module has > a big scary red box warning: > > This BIF is intended for debugging > and for use in the Erlang operating system. > It should not be used in application programs. > > The big problem is that just because you have > <0.24454.8> > in a log and > Pid = list_to_pid("<0.24454.8>") > succeeds and gives you a "process id", > - it need not be the id of ANY process (now) > - if it is the id of some process, it need not be > the one you think it is. > > If you are using this for debugging, fine, > but trust it about as much as you would trust a > cardboard ladder. > __________________ From matthew@REDACTED Wed Oct 29 06:41:00 2008 From: matthew@REDACTED (Matthew Dempsky) Date: Tue, 28 Oct 2008 22:41:00 -0700 Subject: [erlang-questions] Recreating a PID from a log file. In-Reply-To: <1225237661.1107.55.camel@localhost> References: <1225237661.1107.55.camel@localhost> Message-ID: On Tue, Oct 28, 2008 at 4:47 PM, Vik Olliver wrote: > I have the value of a PID in a log file. It's given as: > > <0.24454.8> > > How can I stuff it back into a variable? 1> pid(0,24454,8). <0.24454.8> From trevorw@REDACTED Wed Oct 29 08:42:30 2008 From: trevorw@REDACTED (Trevor Woollacott) Date: Wed, 29 Oct 2008 09:42:30 +0200 Subject: [erlang-questions] Problems with sending UDP datagrams withoutbuffering References: <4907A8A1.2090701@echostar.com> Message-ID: <003801c93999$ed40db80$626bd90a@mtn.co.za> Have you tried using the sndbuf option: gen_udp:open( Port, [binary, {sndbuf, Buffer}] ). Regards, Trevor ----- Original Message ----- From: "Mark Geib" To: "Erlang Questions" Sent: Wednesday, October 29, 2008 2:04 AM Subject: [erlang-questions] Problems with sending UDP datagrams withoutbuffering >I have a case where I MUST send datagrams that are smaller than a > network frame. The device I am sending to will not except larger > datagrams. > > I am sending message that are less than 700 bytes in length, but on the > network using a sniffer I periodically see datagrams from the > application that are 7000 bytes or so in size. The data is correct, the > end device will not accept. > > I am sending these datagrams about every 20 miliseconds. > > Is there an option I am missing to force every gen_dup:send() to cause > the datagram to be sent.?? I am running on linux 2.6.27 kernel. > > -- > Principal Engineer > Cheyenne Software Engineering > mark.geib@REDACTED / 35-215 > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From raimo+erlang-questions@REDACTED Wed Oct 29 09:17:28 2008 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Wed, 29 Oct 2008 09:17:28 +0100 Subject: [erlang-questions] Priviliged ports and effective UID In-Reply-To: <9893-51893@sneakemail.com> References: <9893-51893@sneakemail.com> Message-ID: <20081029081727.GA31386@erix.ericsson.se> On Thu, Oct 23, 2008 at 07:35:01PM -0000, Kevin wrote: > > > Hello, I can't find an answer to this anywhere. In erlang how does one deal with the problem of starting erlang as root, binding to a privileged port, and then change the effective user id to something other than root. > > In a daemon process written in c or even perl, a process is started by an init script, which is run as root, it then binds to port, 25, 80, etc, and then it sets its effective UID and effective GID to something more harmless, like httpd/httpd. > > I know you can start the whole thing like su httpd -c erl, but this doesnt allow for binding to prilileged port first. > > And please don't tell me to use open_port() or write a linked in driver :-) > > Thanks There is an old example program in the erlang release: erts/etc/unix/setuid_socket_wrap.c I do not know how well it is working, but it can(could) be used to open priviliged ports and give them to a program, e.g erl, as open file descriptors. These open file descriptors can then be given to e.g gen_tcp. Might be worth to have a look at. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From eeajam@REDACTED Wed Oct 29 09:22:02 2008 From: eeajam@REDACTED (Alex Alvarez) Date: Wed, 29 Oct 2008 04:22:02 -0400 Subject: [erlang-questions] how to get the factual ip address? Message-ID: getif/0 and getiflist/0 seem very useful, but shouldn't their output be in sync order-wise with each other? getif/0 in my machine outputs... {ok,[{{192,168,1,3},{192,168,1,255},{255,255,255,0}}, {{127,0,0,1},{0,0,0,0},{255,0,0,0}}]} , while getiflist/0 outputs... {ok,["lo","eth0"]} This might be a problem if you had several more interfaces available. Knowing the output of both are always in sync might simplify things out. Cheers, Alex >Computers have more than one IP address. E.g., yours has both >127.0.0.1 and 192.168.1.101. Other computers have even more. The >inet module has undocumented functions getif/0 and getiflist/0 that >might do what you want. > >Another possibility is to call inet:sockname/1 on an open socket to >find what address the operating system used. -------------- next part -------------- An HTML attachment was scrubbed... URL: From hans.bolinder@REDACTED Wed Oct 29 13:15:54 2008 From: hans.bolinder@REDACTED (Hans Bolinder) Date: Wed, 29 Oct 2008 13:15:54 +0100 Subject: [erlang-questions] List to proplist? In-Reply-To: <620F5FF0-93F8-4E0E-BBDA-5404E82BB054@cs.otago.ac.nz> References: <6c2563b20810192156i7516e69aqb4d0eda2e1ee98d9@mail.gmail.com> <620F5FF0-93F8-4E0E-BBDA-5404E82BB054@cs.otago.ac.nz> Message-ID: <18696.21498.534675.651372@ornendil.du.uab.ericsson.se> [Richard O'Keefe:] > A version of unfold that I prefer is > > unfold(State, Splitter) -> > unfold(State, Splitter, []). > > unfold(State, Splitter, Acc) -> > case Splitter(State) > of [] -> lists:reverse(Acc) > ; [Item|State1] -> unfold(State1, Splitter, [Item|Acc]) > end. Thanks! lists:unfold/2 has been added to the upcoming R12B-5 release. Best regards, Hans Bolinder, Erlang/OTP team, Ericsson From exta7@REDACTED Wed Oct 29 13:27:53 2008 From: exta7@REDACTED (Zvi) Date: Wed, 29 Oct 2008 05:27:53 -0700 (PDT) Subject: [erlang-questions] how to get the factual ip address? In-Reply-To: References: Message-ID: <20226001.post@talk.nabble.com> Below is what they return on Windows. I guess there is a reason, these functions are undocumented :-) Zvi Erlang (BEAM) emulator version 5.6.4 [smp:2] [async-threads:0] Eshell V5.6.4 (abort with ^G) 1> inet:getif(). {ok,[{{127,0,0,1},undefined,{255,0,0,0}}, {{20,207,16,76},undefined,{255,255,255,0}}]} 2> inet:getiflist(). {ok,["20.207.16.76","127.0.0.1"]} -- View this message in context: http://www.nabble.com/how-to-get-the-factual-ip-address--tp20170429p20226001.html Sent from the Erlang Questions mailing list archive at Nabble.com. From n.decker@REDACTED Wed Oct 29 13:30:54 2008 From: n.decker@REDACTED (Decker, Nils) Date: Wed, 29 Oct 2008 13:30:54 +0100 Subject: [erlang-questions] Priviliged ports and effective UID In-Reply-To: <20081029081727.GA31386@erix.ericsson.se> References: <9893-51893@sneakemail.com> <20081029081727.GA31386@erix.ericsson.se> Message-ID: Hello, I am using a small tool named authbind [1] in my project without any problems. It is a LD_PRELOAD wrapper and a setuid root binary. The right to open specific ports can be controlled in /etc/. Nils [1] http://en.wikipedia.org/wiki/Authbind Nils Decker Software-Ingenieur Projektierung Studio Hamburg Media Consult International (MCI) GmbH Jenfelder Allee 80 | A8 2. OG / Raum 238 22039 Hamburg Telefon: +49 (0)40 6688-3437 n.decker@REDACTED www.mci-broadcast.com www.mci-systems.de www.mci-products.de www.mci-werkstaetten.de ................................................................................. Gesch?ftsf?hrung: Ralf Schimmel Goetz Hoefer Prokuristen: J?rn Denneborg J?rg Pankow Amtsgericht Hamburg: HRB 70454 From vik@REDACTED Wed Oct 29 13:30:58 2008 From: vik@REDACTED (Vik Olliver) Date: Thu, 30 Oct 2008 01:30:58 +1300 Subject: [erlang-questions] Recreating a PID from a log file. In-Reply-To: References: <1225237661.1107.55.camel@localhost> Message-ID: <1225283458.1107.138.camel@localhost> On Tue, 2008-10-28 at 22:41 -0700, Matthew Dempsky wrote: > On Tue, Oct 28, 2008 at 4:47 PM, Vik Olliver wrote: > > I have the value of a PID in a log file. It's given as: > > > > <0.24454.8> > > > > How can I stuff it back into a variable? > > 1> pid(0,24454,8). > <0.24454.8> Easy when you know how. Thanks. Vik :v) From bengt.kleberg@REDACTED Wed Oct 29 13:41:46 2008 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Wed, 29 Oct 2008 13:41:46 +0100 Subject: [erlang-questions] List to proplist? In-Reply-To: <18696.21498.534675.651372@ornendil.du.uab.ericsson.se> References: <6c2563b20810192156i7516e69aqb4d0eda2e1ee98d9@mail.gmail.com> <620F5FF0-93F8-4E0E-BBDA-5404E82BB054@cs.otago.ac.nz> <18696.21498.534675.651372@ornendil.du.uab.ericsson.se> Message-ID: <1225284106.31992.26.camel@seasc0642.dyn.rnd.as.sw.ericsson.se> Greetings, The unfold/2 below seems to take a fun. Many functions in the lists module take their fun as the first argument. For consistency it would perhaps be a good idea to let unfold/2 also takes the fun as its first argument? This is all provided that Splitter is a fun, of course. bengt On Wed, 2008-10-29 at 13:15 +0100, Hans Bolinder wrote: > [Richard O'Keefe:] > > A version of unfold that I prefer is > > > > unfold(State, Splitter) -> > > unfold(State, Splitter, []). > > > > unfold(State, Splitter, Acc) -> > > case Splitter(State) > > of [] -> lists:reverse(Acc) > > ; [Item|State1] -> unfold(State1, Splitter, [Item|Acc]) > > end. > > Thanks! > > lists:unfold/2 has been added to the upcoming R12B-5 release. > > Best regards, > > Hans Bolinder, Erlang/OTP team, Ericsson > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From richardc@REDACTED Wed Oct 29 13:58:11 2008 From: richardc@REDACTED (Richard Carlsson) Date: Wed, 29 Oct 2008 13:58:11 +0100 Subject: [erlang-questions] List to proplist? In-Reply-To: <18696.21498.534675.651372@ornendil.du.uab.ericsson.se> References: <6c2563b20810192156i7516e69aqb4d0eda2e1ee98d9@mail.gmail.com> <620F5FF0-93F8-4E0E-BBDA-5404E82BB054@cs.otago.ac.nz> <18696.21498.534675.651372@ornendil.du.uab.ericsson.se> Message-ID: <49085DE3.502@it.uu.se> Hans Bolinder wrote: > [Richard O'Keefe:] >> A version of unfold that I prefer is >> >> unfold(State, Splitter) -> >> unfold(State, Splitter, []). >> >> unfold(State, Splitter, Acc) -> >> case Splitter(State) >> of [] -> lists:reverse(Acc) >> ; [Item|State1] -> unfold(State1, Splitter, [Item|Acc]) >> end. > > Thanks! > > lists:unfold/2 has been added to the upcoming R12B-5 release. I was going to comment on this before, but didn't get around to it. Please don't use the return convention above; it is not normal Erlang programming style, and introduces an improper list for no really good reason. A more traditional return convention would use e.g., {Item,State1} | 'none'. This kind of decision might have far-reaching effects on how other code that uses an "iterator" approach is coded in the future. I think it would be a good thing if there was some kind of inofficial standard convention for iterator-style programming in Erlang. For example, there is some iterator functionality in gb_trees, that uses the convention {NextKey,NextValue,NextState} | 'none'. In retrospect, it should have been {{NextKey,NextValue},NextState}, to fit the {Item,State1} pattern. But I think it is a bad idea to use cons cells with arbitrary terms as "tail". (For one thing, Dialyzer will hate it.) /Richard From hans.bolinder@REDACTED Wed Oct 29 14:00:31 2008 From: hans.bolinder@REDACTED (Hans Bolinder) Date: Wed, 29 Oct 2008 14:00:31 +0100 Subject: [erlang-questions] List to proplist? In-Reply-To: <1225284106.31992.26.camel@seasc0642.dyn.rnd.as.sw.ericsson.se> References: <6c2563b20810192156i7516e69aqb4d0eda2e1ee98d9@mail.gmail.com> <620F5FF0-93F8-4E0E-BBDA-5404E82BB054@cs.otago.ac.nz> <18696.21498.534675.651372@ornendil.du.uab.ericsson.se> <1225284106.31992.26.camel@seasc0642.dyn.rnd.as.sw.ericsson.se> Message-ID: <18696.24175.300110.826916@ornendil.du.uab.ericsson.se> [Bengt Kleberg:] > The unfold/2 below seems to take a fun. Many functions in the lists > module take their fun as the first argument. For consistency it would > perhaps be a good idea to let unfold/2 also takes the fun as its first > argument? Yes. The following code was added to lists.erl: -spec(unfold/2 :: (fun((_) -> maybe_improper_list()), any()) -> [any()]). unfold(Splitter, State) when is_function(Splitter, 1) -> unfold(Splitter, State, []). unfold(Splitter, State, Acc) -> case Splitter(State) of [] -> lists:reverse(Acc); [Item|State1] -> unfold(Splitter, State1, [Item|Acc]) end. Best regards, Hans Bolinder, Erlang/OTP team, Ericsson From bqt@REDACTED Wed Oct 29 14:06:34 2008 From: bqt@REDACTED (Johnny Billquist) Date: Wed, 29 Oct 2008 14:06:34 +0100 Subject: [erlang-questions] Problems with sending UDP datagrams without buffering In-Reply-To: <4907A8A1.2090701@echostar.com> References: <4907A8A1.2090701@echostar.com> Message-ID: <49085FDA.7000306@softjar.se> Mark Geib wrote: > I have a case where I MUST send datagrams that are smaller than a > network frame. The device I am sending to will not except larger datagrams. > > I am sending message that are less than 700 bytes in length, but on the > network using a sniffer I periodically see datagrams from the > application that are 7000 bytes or so in size. The data is correct, the > end device will not accept. > > I am sending these datagrams about every 20 miliseconds. > > Is there an option I am missing to force every gen_dup:send() to cause > the datagram to be sent.?? I am running on linux 2.6.27 kernel. If you are using TCP, there are no such concept as a datagram. TCP is a stream oriented connection. There is a lot more to this if you want to dig into it, but the basic assumption is wrong if you try to use this as a datagram service. Johnny From mbj@REDACTED Wed Oct 29 14:29:24 2008 From: mbj@REDACTED (Martin Bjorklund) Date: Wed, 29 Oct 2008 14:29:24 +0100 (CET) Subject: [erlang-questions] List to proplist? In-Reply-To: <49085DE3.502@it.uu.se> References: <620F5FF0-93F8-4E0E-BBDA-5404E82BB054@cs.otago.ac.nz> <18696.21498.534675.651372@ornendil.du.uab.ericsson.se> <49085DE3.502@it.uu.se> Message-ID: <20081029.142924.71849153.mbj@tail-f.com> Richard Carlsson wrote: > Hans Bolinder wrote: > > [Richard O'Keefe:] > >> A version of unfold that I prefer is > >> > >> unfold(State, Splitter) -> > >> unfold(State, Splitter, []). > >> > >> unfold(State, Splitter, Acc) -> > >> case Splitter(State) > >> of [] -> lists:reverse(Acc) > >> ; [Item|State1] -> unfold(State1, Splitter, [Item|Acc]) > >> end. > > > > Thanks! > > > > lists:unfold/2 has been added to the upcoming R12B-5 release. > > I was going to comment on this before, but didn't get around to it. > Please don't use the return convention above; it is not normal > Erlang programming style, and introduces an improper list for no > really good reason. +1. I was just going to make the same comment. /martin From vychodil.hynek@REDACTED Wed Oct 29 14:42:03 2008 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Wed, 29 Oct 2008 14:42:03 +0100 Subject: [erlang-questions] List to proplist? In-Reply-To: <20081029.142924.71849153.mbj@tail-f.com> References: <620F5FF0-93F8-4E0E-BBDA-5404E82BB054@cs.otago.ac.nz> <18696.21498.534675.651372@ornendil.du.uab.ericsson.se> <49085DE3.502@it.uu.se> <20081029.142924.71849153.mbj@tail-f.com> Message-ID: <20081029134204.44C8F24063@relay.gooddata.com> On Wed, Oct 29, 2008 at 2:29 PM, Martin Bjorklund wrote: > Richard Carlsson wrote: > > Hans Bolinder wrote: > > > [Richard O'Keefe:] > > >> A version of unfold that I prefer is > > >> > > >> unfold(State, Splitter) -> > > >> unfold(State, Splitter, []). > > >> > > >> unfold(State, Splitter, Acc) -> > > >> case Splitter(State) > > >> of [] -> lists:reverse(Acc) > > >> ; [Item|State1] -> unfold(State1, Splitter, [Item|Acc]) > > >> end. > > > > > > Thanks! > > > > > > lists:unfold/2 has been added to the upcoming R12B-5 release. > > > > I was going to comment on this before, but didn't get around to it. > > Please don't use the return convention above; it is not normal > > Erlang programming style, and introduces an improper list for no > > really good reason. > > +1. I was just going to make the same comment. > +1. me too > > > /martin > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- --Hynek (Pichi) Vychodil -------------- next part -------------- An HTML attachment was scrubbed... URL: From matthias@REDACTED Wed Oct 29 14:44:11 2008 From: matthias@REDACTED (Matthias Lang) Date: Wed, 29 Oct 2008 14:44:11 +0100 Subject: [erlang-questions] Problems with sending UDP datagrams without buffering In-Reply-To: <49085FDA.7000306@softjar.se> References: <4907A8A1.2090701@echostar.com> <49085FDA.7000306@softjar.se> Message-ID: <20081029134411.GB4461@contorpis.lisalinda.com> > Mark Geib wrote: > > I have a case where I MUST send datagrams that are smaller than a > > network frame. The device I am sending to will not except larger datagrams. > > I am sending message that are less than 700 bytes in length, but on the > > network using a sniffer I periodically see datagrams from the > > application that are 7000 bytes or so in size. The data is correct, the > > end device will not accept. > > I am sending these datagrams about every 20 miliseconds. > > Is there an option I am missing to force every gen_dup:send() to cause > > the datagram to be sent.?? I am running on linux 2.6.27 kernel. On Wednesday, October 29, Johnny Billquist wrote: > If you are using TCP, there are no such concept as a datagram. TCP is a > stream oriented connection. I don't understand the original poster's question. For starters, he says he's using "gen_dup:send()". There is no gen_dup. I'm guessing it's a typo for gen_udp:send(). So it can't be TCP. Or can it? But if I assume that, then the only way to get a "datagram" (does he mean "UDP payload" or does he mean "IP packet" or something else? I don't know) 7000 octets long is to pass a 7000 octet argument to gen_udp:send. Original poster, please explain more precisely. A minimal (three or four lines should be enough) program which actually works and also shows what you're doing and a description of how to see it failing (e.g. "I run the program on my linux box on Erlang R12B-4 and see this output from 'tcpdump' but I expected...") would be nice. Matt From bqt@REDACTED Wed Oct 29 14:56:24 2008 From: bqt@REDACTED (Johnny Billquist) Date: Wed, 29 Oct 2008 14:56:24 +0100 Subject: [erlang-questions] Problems with sending UDP datagrams without buffering In-Reply-To: <20081029134411.GB4461@contorpis.lisalinda.com> References: <4907A8A1.2090701@echostar.com> <49085FDA.7000306@softjar.se> <20081029134411.GB4461@contorpis.lisalinda.com> Message-ID: <49086B88.8040303@softjar.se> Matthias Lang wrote: >> Mark Geib wrote: >>> I have a case where I MUST send datagrams that are smaller than a >>> network frame. The device I am sending to will not except larger datagrams. > >>> I am sending message that are less than 700 bytes in length, but on the >>> network using a sniffer I periodically see datagrams from the >>> application that are 7000 bytes or so in size. The data is correct, the >>> end device will not accept. > >>> I am sending these datagrams about every 20 miliseconds. > >>> Is there an option I am missing to force every gen_dup:send() to cause >>> the datagram to be sent.?? I am running on linux 2.6.27 kernel. > > On Wednesday, October 29, Johnny Billquist wrote: >> If you are using TCP, there are no such concept as a datagram. TCP is a >> stream oriented connection. > > I don't understand the original poster's question. > > For starters, he says he's using "gen_dup:send()". There is no > gen_dup. I'm guessing it's a typo for gen_udp:send(). So it can't be TCP. > Or can it? I was making the (probably wrong) assumption that he was actually meaning gen_dup. :-) > But if I assume that, then the only way to get a "datagram" (does he mean > "UDP payload" or does he mean "IP packet" or something else? I don't know) > 7000 octets long is to pass a 7000 octet argument to gen_udp:send. If he is sending 700 bytes packets with UDP, I can't see how the total packet length could become 7000. Can Erlang also buffer sends internally? I wouldn't have thought so, but it's not entirely clear from the documentation. Johnny From fdeserres@REDACTED Wed Oct 29 15:00:08 2008 From: fdeserres@REDACTED (Francois De Serres) Date: Wed, 29 Oct 2008 15:00:08 +0100 Subject: [erlang-questions] Pattern-matching function? Message-ID: <20081029140008.219340@gmx.net> Hi there. I need a function that actually does pattern matching: pm(Tuple, Pattern)->MatchedPattern|error > pm({a,b,c}, {a,X,Y}). {a,b,c} >X. b > pm({a,b,c}, {b,X,Y}). {error, badmatch} > pm({a,b,c}, {a,X}). {error, badmatch} etc. This trivial code works only with the empty tuple/pattern : pm(T,P) -> P = T, P. because pattern variables (X, Y) are unbound at function call. I tried to find a hint in the libs with no avail. If anyone has a lead, can you please put me on track? Thanks, -- Francois -- "Feel free" - 10 GB Mailbox, 100 FreeSMS/Monat ... Jetzt GMX TopMail testen: http://www.gmx.net/de/go/topmail From richardc@REDACTED Wed Oct 29 15:24:56 2008 From: richardc@REDACTED (Richard Carlsson) Date: Wed, 29 Oct 2008 15:24:56 +0100 Subject: [erlang-questions] Pattern-matching function? In-Reply-To: <20081029140008.219340@gmx.net> References: <20081029140008.219340@gmx.net> Message-ID: <49087238.3030904@it.uu.se> Francois De Serres wrote: > Hi there. > > I need a function that actually does pattern matching: pm(Tuple, Pattern)->MatchedPattern|error You cannot pass a pattern with uninstantiated variables to a function. Erlang is a strict functional language, it is not Prolog. Patterns are not run-time values. /Richard From steven.charles.davis@REDACTED Wed Oct 29 15:27:45 2008 From: steven.charles.davis@REDACTED (Steve Davis) Date: Wed, 29 Oct 2008 07:27:45 -0700 (PDT) Subject: [erlang-questions] Add XXTEA (Corrected Block TEA) to crypto? Message-ID: <169d6478-b9f6-4b85-886c-eed551df85eb@m44g2000hsc.googlegroups.com> Would XXTEA be a good candidate for inclusion in the crypto module? It's very useful for working with limited devices. There's a number of varieties of TEA but specifically the one I'm talking about is: David J. Wheeler and Roger M. Needham (October 1998). "Correction to xtea" http://www.movable-type.co.uk/scripts/xxtea.pdf I found an (alpha) implementation of XXTEA here -> http://code.google.com/p/initiale/source/browse/trunk/initiale/src/xxtea.erl /s From mark.geib@REDACTED Wed Oct 29 15:31:22 2008 From: mark.geib@REDACTED (Mark Geib) Date: Wed, 29 Oct 2008 08:31:22 -0600 Subject: [erlang-questions] Problems with sending UDP datagrams without buffering In-Reply-To: <49086B88.8040303@softjar.se> References: <4907A8A1.2090701@echostar.com> <49085FDA.7000306@softjar.se> <20081029134411.GB4461@contorpis.lisalinda.com> <49086B88.8040303@softjar.se> Message-ID: <490873BA.6030506@echostar.com> Sorry for lack of details, it was the end of a long day. Yes, I am using UDP, not TCP. And to confirm, I am sending 700 bytes, never any more. I see the 7000 byte datagram in WireShark on another system monitoring the network. The 7000 bytes are reported as fragmented packets that have been re-assembled. I am an sending the 700 bytes every 20 miliseconds. I am assuming that erlang is buffering in a lower layer, but could be the linux network stack as well. Mark. Johnny Billquist wrote: > Matthias Lang wrote: >>> Mark Geib wrote: >>>> I have a case where I MUST send datagrams that are smaller than a >>>> network frame. The device I am sending to will not except larger >>>> datagrams. >> >>>> I am sending message that are less than 700 bytes in length, but on the >>>> network using a sniffer I periodically see datagrams from the >>>> application that are 7000 bytes or so in size. The data is correct, the >>>> end device will not accept. >> >>>> I am sending these datagrams about every 20 miliseconds. >> >>>> Is there an option I am missing to force every gen_dup:send() to cause >>>> the datagram to be sent.?? I am running on linux 2.6.27 kernel. >> >> On Wednesday, October 29, Johnny Billquist wrote: >>> If you are using TCP, there are no such concept as a datagram. TCP is >>> a stream oriented connection. >> >> I don't understand the original poster's question. >> >> For starters, he says he's using "gen_dup:send()". There is no >> gen_dup. I'm guessing it's a typo for gen_udp:send(). So it can't be TCP. >> Or can it? > > I was making the (probably wrong) assumption that he was actually > meaning gen_dup. :-) > >> But if I assume that, then the only way to get a "datagram" (does he mean >> "UDP payload" or does he mean "IP packet" or something else? I don't >> know) >> 7000 octets long is to pass a 7000 octet argument to gen_udp:send. > > If he is sending 700 bytes packets with UDP, I can't see how the total > packet length could become 7000. > Can Erlang also buffer sends internally? I wouldn't have thought so, but > it's not entirely clear from the documentation. > > Johnny > > -- Principal Engineer Cheyenne Software Engineering mark.geib@REDACTED / 35-215 From oscar@REDACTED Wed Oct 29 16:12:52 2008 From: oscar@REDACTED (=?utf-8?Q?Oscar_Hellstr=C3=B6m?=) Date: Wed, 29 Oct 2008 15:12:52 +0000 (GMT) Subject: [erlang-questions] Problems with sending UDP datagrams without buffering In-Reply-To: <490873BA.6030506@echostar.com> Message-ID: <938861.26261225293172753.JavaMail.root@zimbra> Hi Mark, I don't have very much experience with UDP but I'm quite sure that Erlang itself doesn't do any buffering. If you look in erts/emulator/drivers/common/inet_drv.c You will find exactly what is going on though :) ----- "Mark Geib" wrote: > Sorry for lack of details, it was the end of a long day. > > Yes, I am using UDP, not TCP. And to confirm, I am sending 700 bytes, > never any more. I see the 7000 byte datagram in WireShark on another > system monitoring the network. The 7000 bytes are reported as > fragmented > packets that have been re-assembled. I am an sending the 700 bytes > every > 20 miliseconds. > > I am assuming that erlang is buffering in a lower layer, but could be > the linux network stack as well. > > Mark. > > > > Johnny Billquist wrote: > > Matthias Lang wrote: > >>> Mark Geib wrote: > >>>> I have a case where I MUST send datagrams that are smaller than > a > >>>> network frame. The device I am sending to will not except larger > >>>> datagrams. > >> > >>>> I am sending message that are less than 700 bytes in length, but > on the > >>>> network using a sniffer I periodically see datagrams from the > >>>> application that are 7000 bytes or so in size. The data is > correct, the > >>>> end device will not accept. > >> > >>>> I am sending these datagrams about every 20 miliseconds. > >> > >>>> Is there an option I am missing to force every gen_dup:send() to > cause > >>>> the datagram to be sent.?? I am running on linux 2.6.27 kernel. > >> > >> On Wednesday, October 29, Johnny Billquist wrote: > >>> If you are using TCP, there are no such concept as a datagram. TCP > is > >>> a stream oriented connection. > >> > >> I don't understand the original poster's question. > >> > >> For starters, he says he's using "gen_dup:send()". There is no > >> gen_dup. I'm guessing it's a typo for gen_udp:send(). So it can't > be TCP. > >> Or can it? > > > > I was making the (probably wrong) assumption that he was actually > > meaning gen_dup. :-) > > > >> But if I assume that, then the only way to get a "datagram" (does > he mean > >> "UDP payload" or does he mean "IP packet" or something else? I > don't > >> know) > >> 7000 octets long is to pass a 7000 octet argument to gen_udp:send. > > > > If he is sending 700 bytes packets with UDP, I can't see how the > total > > packet length could become 7000. > > Can Erlang also buffer sends internally? I wouldn't have thought so, > but > > it's not entirely clear from the documentation. > > > > Johnny > > > > > > -- > Principal Engineer > Cheyenne Software Engineering > mark.geib@REDACTED / 35-215 > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions Best regards -- Oscar Hellstr?m, oscar@REDACTED Phone: +44 (0)798 45 44 773 Mobile: +44 (0)207 65 50 337 Web: http://www.erlang-consulting.com From aconbere@REDACTED Wed Oct 29 16:18:11 2008 From: aconbere@REDACTED (anders conbere) Date: Wed, 29 Oct 2008 08:18:11 -0700 Subject: [erlang-questions] Pattern-matching function? In-Reply-To: <49087238.3030904@it.uu.se> References: <20081029140008.219340@gmx.net> <49087238.3030904@it.uu.se> Message-ID: <8ca3fbe80810290818o5447de7ct8a13305fffe6583a@mail.gmail.com> On Wed, Oct 29, 2008 at 7:24 AM, Richard Carlsson wrote: > Francois De Serres wrote: >> Hi there. >> >> I need a function that actually does pattern matching: pm(Tuple, Pattern)->MatchedPattern|error > > You cannot pass a pattern with uninstantiated variables to a function. > Erlang is a strict functional language, it is not Prolog. Patterns are > not run-time values. That being said, the lack of first class access to Patterns makes programmatic access to a few of the most common tools in erlang exceptionally difficult. Constructing case statements at runtime is impossible with out accessing the preproccessor, building functions at runtime that have many different possible patterns, also impossible. It seems like there should be some way to gain access to this. I could for instance imagine delaying access to with a function that accepted something like pattern(x, supplies("X"), y, z) which would return a function that when applied to a tuple {x, anything, y, z} would return {ok, {match, [{"X", anything}]}} and in that way you could construct semantics for applying those to case statements or function parameters, etc. Maybe that's crazy, but I sympathize with Francois, I've been trying to fumble my way through erlang metaprogramming and just running into huge walls like this. ~ Anders > > /Richard > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From mrad-direct-erlang@REDACTED Wed Oct 29 17:22:31 2008 From: mrad-direct-erlang@REDACTED (Michael Radford) Date: Wed, 29 Oct 2008 09:22:31 -0700 Subject: [erlang-questions] Pattern-matching function? In-Reply-To: <49087238.3030904@it.uu.se> References: <20081029140008.219340@gmx.net> <49087238.3030904@it.uu.se> Message-ID: <20081029162231.GA29526@herbie> Richard Carlsson writes: > Francois De Serres wrote: > > I need a function that actually does pattern matching: pm(Tuple, Pattern)->MatchedPattern|error > > You cannot pass a pattern with uninstantiated variables to a function. > Erlang is a strict functional language, it is not Prolog. Patterns are > not run-time values. But maybe he can do what he wants with match specs? They're much more cumbersome than pattern matching, but they are more or less a run-time representation of a pattern. See ets:match_spec_run/2 and other mentions of match specs in the ets manpage. Also this page: http://www.erlang.org/doc/apps/erts/match_spec.html Mike From zoltan.peter.toth@REDACTED Wed Oct 29 18:15:18 2008 From: zoltan.peter.toth@REDACTED (Zoltan Peter Toth) Date: Wed, 29 Oct 2008 18:15:18 +0100 Subject: [erlang-questions] clarify: mnesia:dirty_update_counter Message-ID: <49089A26.70409@ericsson.com> Hi, mnesia:dirty_update_counter works only for set tables, not for ordered sets. Why ? Would it be possible to remove this limitation ? Cheers, /Zoltan From bjourne@REDACTED Wed Oct 29 19:18:54 2008 From: bjourne@REDACTED (=?ISO-8859-1?Q?BJ=F6rn_Lindqvist?=) Date: Wed, 29 Oct 2008 19:18:54 +0100 Subject: [erlang-questions] Extracting capture group names from regular expressions In-Reply-To: <6672d0160810090059v56e82766h8af0f8ae46831c42@mail.gmail.com> References: <6672d0160810090059v56e82766h8af0f8ae46831c42@mail.gmail.com> Message-ID: <740c3aec0810291118ncae988i315c1eb16ae48962@mail.gmail.com> 2008/10/9 Bjorn Gustavsson : > 2008/10/7 Tony Arcieri >> >> I'm trying to write an API which accepts a regexp with arbitrary named >> capture groups as input. >> >> I'm using the re module, and have had success using named subgroups if the >> names are known ahead of time. However, I'd like to return a mapping of >> arbitrary named capture groups from the original regular expression to the >> matched values. >> >> Consider the following regular expression with named subpatterns: >> >> "(?\\w+) (?\\w+)" >> >> If this were applied to the string "baz qux" I'd like to return the >> following: >> >> [{"foo", "baz"}, {"bar", "qux"}] >> >> However, it looks as if I must provide the names of the capture groups I >> want returned in the capture tuple I pass to re:run. >> >> Is there any way to extract the names of the subgroups from a compiled >> regular expression? Or is there some option I can pass to re:run that I'm >> missing which will return a mapping of subgroup names to what they matched? > > There is currently no such option or functionality. It could be added in a > future release if it's a general need. Yes please! There is no support for anonymous groups either which is an even bigger omission. -- mvh Bj?rn From fdeserres@REDACTED Wed Oct 29 19:26:45 2008 From: fdeserres@REDACTED (Francois De Serres) Date: Wed, 29 Oct 2008 19:26:45 +0100 Subject: [erlang-questions] Pattern-matching function? In-Reply-To: <49087238.3030904@it.uu.se> References: <20081029140008.219340@gmx.net> <49087238.3030904@it.uu.se> Message-ID: <20081029182645.219350@gmx.net> Thank you Richard. Any way to overcome this with parsing/binding/eval magic, even cumbersome ? > Francois De Serres wrote: > > Hi there. > > > > I need a function that actually does pattern matching: pm(Tuple, > Pattern)->MatchedPattern|error > > You cannot pass a pattern with uninstantiated variables to a function. > Erlang is a strict functional language, it is not Prolog. Patterns are > not run-time values. > > /Richard -- "Feel free" - 5 GB Mailbox, 50 FreeSMS/Monat ... Jetzt GMX ProMail testen: http://www.gmx.net/de/go/promail From fdeserres@REDACTED Wed Oct 29 19:45:43 2008 From: fdeserres@REDACTED (Francois De Serres) Date: Wed, 29 Oct 2008 19:45:43 +0100 Subject: [erlang-questions] Pattern-matching function? In-Reply-To: <20081029162231.GA29526@herbie> References: <20081029140008.219340@gmx.net> <49087238.3030904@it.uu.se> <20081029162231.GA29526@herbie> Message-ID: <20081029184543.21340@gmx.net> > Richard Carlsson writes: > > Francois De Serres wrote: > > > I need a function that actually does pattern matching: pm(Tuple, > Pattern)->MatchedPattern|error > > > > You cannot pass a pattern with uninstantiated variables to a function. > > Erlang is a strict functional language, it is not Prolog. Patterns are > > not run-time values. > > But maybe he can do what he wants with match specs? They're much more > cumbersome than pattern matching, but they are more or less a run-time > representation of a pattern. > > See ets:match_spec_run/2 and other mentions of match specs in the ets > manpage. Also this page: > http://www.erlang.org/doc/apps/erts/match_spec.html > > Mike Thanks Mike, Nice, but ets:select/2 means the tuple to match against would have to be in a table, or...? -- Francois -- GMX Download-Spiele: Preizsturz! Alle Puzzle-Spiele Deluxe ?ber 60% billiger. http://games.entertainment.gmx.net/de/entertainment/games/download/puzzle/index.html From drcabana@REDACTED Wed Oct 29 19:44:24 2008 From: drcabana@REDACTED (David Cabana) Date: Wed, 29 Oct 2008 14:44:24 -0400 Subject: [erlang-questions] Question re console io in a distributed computation In-Reply-To: <44ed5e0f0810241309h33d2f514q701c8b5fd84ae72d@mail.gmail.com> References: <44ed5e0f0810241018y202b3dcdt4809b0d24c335c0f@mail.gmail.com> <490217AB.3050505@ericsson.com> <44ed5e0f0810241309h33d2f514q701c8b5fd84ae72d@mail.gmail.com> Message-ID: <44ed5e0f0810291144m5370c23euf827335a5eb7da2a@mail.gmail.com> I've now played with both of Ulf's suggested approaches (using io:format(user, Fmt, Args), or alternatively, resetting processes group leaders) and have gotten output to go the correct consoles with both approaches. Which of course led to the next hurdle, reading input from the player console. The referee sent a question to the player, which was written to the player node's console. What I want to do is type a response in the player console, have it read, parsed, and sent to the referee, but so far no luck. My responses vanish into the ether, and the referee hangs waiting for players to respond. Here is how I am trying to respond. When the player process receives a question, it writes to the console and tries to read a line: io:fwrite("~n~s", [Question]), Reply = io:get_line(["= "]), I have also tried: io:fwrite(user, "~n~s", [Question]), Reply = io:get_line(user, ["= "]), It occurs to me that maybe I am going about this the wrong way? Perhaps my approch is misconceived. I have to believe that console IO in a client-server setting is pretty common. Can anyone point me in the right direction? Thank you, David > > On Fri, Oct 24, 2008 at 2:44 PM, Ulf Wiger (TN/EAB) < > ulf.wiger@REDACTED> wrote: > >> David Cabana skrev: >> > >> >>> The messages flow correctly, but all the terminal io happens in >>> a single console, the one associated with the referee node. >>> >>> My question is how to get player output written to the console of the >>> corresponding >>> player node? >>> >> >> Use io:format(user, Fmt, Args) >> >> Alternatively, set the group leader of the process to some >> local process - e.g. the group leader of net_kernel >> (found by calling process_info(whereis(net_kernel),group_leader)). >> >> The group leader is the process that's handed all io messages. >> The rpc server deliberately sets the group leader of an rpc >> handler process to that of the caller on the originating node, >> since the remote node may not always have a tty to print to. >> When spawning, the group leader of the spawned process will >> be inherited from the parent. If you spawn a process on >> another node, it will still have the same group leader as >> the parent. >> >> The BIF group_leader(Pid,New_group_leader_pid) sets a new >> leader. >> >> BR, >> Ulf W >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From fdeserres@REDACTED Wed Oct 29 20:20:21 2008 From: fdeserres@REDACTED (Francois De Serres) Date: Wed, 29 Oct 2008 20:20:21 +0100 Subject: [erlang-questions] Pattern-matching function? In-Reply-To: <20081029185002.GA11480@herbie> References: <20081029140008.219340@gmx.net> <49087238.3030904@it.uu.se> <20081029162231.GA29526@herbie> <20081029184543.21340@gmx.net> <20081029185002.GA11480@herbie> Message-ID: <20081029192021.179320@gmx.net> Seems like the one, will try it. Thanks Much. -- Fran?ois > ets:match_spec_run/2 allows you to run the match spec against a list of > tuples. > > Mike > > Francois De Serres writes: > > > Richard Carlsson writes: > > > > Francois De Serres wrote: > > > > > I need a function that actually does pattern matching: pm(Tuple, > > > Pattern)->MatchedPattern|error > > > > > > > > You cannot pass a pattern with uninstantiated variables to a > function. > > > > Erlang is a strict functional language, it is not Prolog. Patterns > are > > > > not run-time values. > > > > > > But maybe he can do what he wants with match specs? They're much more > > > cumbersome than pattern matching, but they are more or less a run-time > > > representation of a pattern. > > > > > > See ets:match_spec_run/2 and other mentions of match specs in the ets > > > manpage. Also this page: > > > http://www.erlang.org/doc/apps/erts/match_spec.html > > > > > > Mike > > > > Thanks Mike, > > Nice, but ets:select/2 means the tuple to match against would have to be > in a table, or...? > > -- > > Francois -- "Feel free" - 5 GB Mailbox, 50 FreeSMS/Monat ... Jetzt GMX ProMail testen: http://www.gmx.net/de/go/promail From freza@REDACTED Wed Oct 29 20:40:10 2008 From: freza@REDACTED (Jachym Holecek) Date: Wed, 29 Oct 2008 20:40:10 +0100 Subject: [erlang-questions] Pattern-matching function? In-Reply-To: <8ca3fbe80810290818o5447de7ct8a13305fffe6583a@mail.gmail.com> References: <20081029140008.219340@gmx.net> <49087238.3030904@it.uu.se> <8ca3fbe80810290818o5447de7ct8a13305fffe6583a@mail.gmail.com> Message-ID: <20081029194010.GA11732@hanele> # anders conbere 2008-10-29: > On Wed, Oct 29, 2008 at 7:24 AM, Richard Carlsson wrote: > > You cannot pass a pattern with uninstantiated variables to a function. > > Erlang is a strict functional language, it is not Prolog. Patterns are > > not run-time values. > > That being said, the lack of first class access to Patterns makes > programmatic access to a few of the most common tools in erlang > exceptionally difficult. Constructing case statements at runtime is > impossible with out accessing the preproccessor, building functions at > runtime that have many different possible patterns, also impossible. It's not impossible, it's just not as easy as you seem to be expecting: compile:forms/[1, 2]. Also, it works with module granularity, not individual functions/expressions. > Maybe that's crazy, but I > sympathize with Francois, I've been trying to fumble my way through > erlang metaprogramming and just running into huge walls like this. When running into huge walls, consider changing direction. ;-) What actual problems are you trying to solve? -- Jachym From ulf@REDACTED Wed Oct 29 21:01:50 2008 From: ulf@REDACTED (Ulf Wiger) Date: Wed, 29 Oct 2008 21:01:50 +0100 Subject: [erlang-questions] Question re console io in a distributed computation In-Reply-To: <44ed5e0f0810291144m5370c23euf827335a5eb7da2a@mail.gmail.com> References: <44ed5e0f0810241018y202b3dcdt4809b0d24c335c0f@mail.gmail.com> <490217AB.3050505@ericsson.com> <44ed5e0f0810241309h33d2f514q701c8b5fd84ae72d@mail.gmail.com> <44ed5e0f0810291144m5370c23euf827335a5eb7da2a@mail.gmail.com> Message-ID: <8209f740810291301h42c78cc2xf43749af389e624d@mail.gmail.com> Well, I'm not quite sure why it didn't work with the group leader (I'd have to dig into that), but the 'user' trick ought to work with the question as well. Compare: rpc:call(OtherNode, io, get_line, ["Hello? "]) with rpc:call(OtherNode, io, get_line, [user, "Hello? "]). The first version should give a prompt on the originating node, and the second version should give it on the target node (assuming, of course, that the target node has a shell.) BR, Ulf W 2008/10/29 David Cabana : > I've now played with both of Ulf's suggested approaches (using > io:format(user, Fmt, Args), or alternatively, resetting processes group > leaders) and have gotten output to go the correct consoles with both > approaches. Which of course led to the next hurdle, reading input from the > player console. > > The referee sent a question to the player, which was written to the player > node's console. What I want to do is type a response in the player console, > have it read, parsed, and sent to the referee, but so far no luck. My > responses vanish into the ether, and the referee hangs waiting for players > to respond. > > Here is how I am trying to respond. When the player process receives a > question, it writes to the console and tries to read a line: > > > io:fwrite("~n~s", [Question]), > Reply = io:get_line(["= "]), > > io> > I have also tried: > io:fwrite(user, "~n~s", [Question]), > Reply = io:get_line(user, ["= "]), > > > It occurs to me that maybe I am going about this the wrong way? Perhaps my > approch is misconceived. I have to believe that console IO in a > client-server setting is pretty common. Can anyone point me in the right > direction? > > Thank you, > David >> >> On Fri, Oct 24, 2008 at 2:44 PM, Ulf Wiger (TN/EAB) >> wrote: >>> >>> David Cabana skrev: >>> > >>>> >>>> The messages flow correctly, but all the terminal io happens in >>>> a single console, the one associated with the referee node. >>>> >>>> My question is how to get player output written to the console of the >>>> corresponding >>>> player node? >>> >>> Use io:format(user, Fmt, Args) >>> >>> Alternatively, set the group leader of the process to some >>> local process - e.g. the group leader of net_kernel >>> (found by calling process_info(whereis(net_kernel),group_leader)). >>> >>> The group leader is the process that's handed all io messages. >>> The rpc server deliberately sets the group leader of an rpc >>> handler process to that of the caller on the originating node, >>> since the remote node may not always have a tty to print to. >>> When spawning, the group leader of the spawned process will >>> be inherited from the parent. If you spawn a process on >>> another node, it will still have the same group leader as >>> the parent. >>> >>> The BIF group_leader(Pid,New_group_leader_pid) sets a new >>> leader. >>> >>> BR, >>> Ulf W >> > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From launoja@REDACTED Wed Oct 29 18:05:49 2008 From: launoja@REDACTED (Jani Launonen) Date: Wed, 29 Oct 2008 19:05:49 +0200 Subject: [erlang-questions] Shoein viriili... In-Reply-To: <208519030810280824n1e5998eaw4efbf680f1dbb0d@mail.gmail.com> References: <208519030810280824n1e5998eaw4efbf680f1dbb0d@mail.gmail.com> Message-ID: - > Siell? on semmonen vipu kiinnityskohdan alalaidassa molemmilla > puolilla.Katseleppa liikkuvia osia siit?. Kun vivusta vet??, > niin se irrottaa > visiirin alaosan ja loppu pit?isi olla heleppoa. Kas! Olipas aivan vituimmaksi paras systeemi! Ei tarvinnut edes junttanostoa ja t?ysnelsonia, kuten joskus tuon Arain kanssa, jos viriili ei menek??n heti oikein... From ulf@REDACTED Wed Oct 29 21:13:48 2008 From: ulf@REDACTED (Ulf Wiger) Date: Wed, 29 Oct 2008 21:13:48 +0100 Subject: [erlang-questions] Question re console io in a distributed computation In-Reply-To: <8209f740810291301h42c78cc2xf43749af389e624d@mail.gmail.com> References: <44ed5e0f0810241018y202b3dcdt4809b0d24c335c0f@mail.gmail.com> <490217AB.3050505@ericsson.com> <44ed5e0f0810241309h33d2f514q701c8b5fd84ae72d@mail.gmail.com> <44ed5e0f0810291144m5370c23euf827335a5eb7da2a@mail.gmail.com> <8209f740810291301h42c78cc2xf43749af389e624d@mail.gmail.com> Message-ID: <8209f740810291313k2277bb1y6a80a507ec1ea56@mail.gmail.com> Hmm, sorry, I was too fast there. The prompt appeared all right, but the call never returned. Very interesting... BR, Ulf W 2008/10/29 Ulf Wiger : > Well, I'm not quite sure why it didn't work with the group leader > (I'd have to dig into that), but the 'user' trick ought to work with > the question as well. Compare: > > rpc:call(OtherNode, io, get_line, ["Hello? "]) > > with > > rpc:call(OtherNode, io, get_line, [user, "Hello? "]). > > The first version should give a prompt on the originating node, > and the second version should give it on the target node > (assuming, of course, that the target node has a shell.) > > BR, > Ulf W > > 2008/10/29 David Cabana : >> I've now played with both of Ulf's suggested approaches (using >> io:format(user, Fmt, Args), or alternatively, resetting processes group >> leaders) and have gotten output to go the correct consoles with both >> approaches. Which of course led to the next hurdle, reading input from the >> player console. >> >> The referee sent a question to the player, which was written to the player >> node's console. What I want to do is type a response in the player console, >> have it read, parsed, and sent to the referee, but so far no luck. My >> responses vanish into the ether, and the referee hangs waiting for players >> to respond. >> >> Here is how I am trying to respond. When the player process receives a >> question, it writes to the console and tries to read a line: >> >> >> io:fwrite("~n~s", [Question]), >> Reply = io:get_line(["= "]), >> >> > io> >> I have also tried: >> io:fwrite(user, "~n~s", [Question]), >> Reply = io:get_line(user, ["= "]), >> >> >> It occurs to me that maybe I am going about this the wrong way? Perhaps my >> approch is misconceived. I have to believe that console IO in a >> client-server setting is pretty common. Can anyone point me in the right >> direction? >> >> Thank you, >> David >>> >>> On Fri, Oct 24, 2008 at 2:44 PM, Ulf Wiger (TN/EAB) >>> wrote: >>>> >>>> David Cabana skrev: >>>> > >>>>> >>>>> The messages flow correctly, but all the terminal io happens in >>>>> a single console, the one associated with the referee node. >>>>> >>>>> My question is how to get player output written to the console of the >>>>> corresponding >>>>> player node? >>>> >>>> Use io:format(user, Fmt, Args) >>>> >>>> Alternatively, set the group leader of the process to some >>>> local process - e.g. the group leader of net_kernel >>>> (found by calling process_info(whereis(net_kernel),group_leader)). >>>> >>>> The group leader is the process that's handed all io messages. >>>> The rpc server deliberately sets the group leader of an rpc >>>> handler process to that of the caller on the originating node, >>>> since the remote node may not always have a tty to print to. >>>> When spawning, the group leader of the spawned process will >>>> be inherited from the parent. If you spawn a process on >>>> another node, it will still have the same group leader as >>>> the parent. >>>> >>>> The BIF group_leader(Pid,New_group_leader_pid) sets a new >>>> leader. >>>> >>>> BR, >>>> Ulf W >>> >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > From rvirding@REDACTED Wed Oct 29 21:19:40 2008 From: rvirding@REDACTED (Robert Virding) Date: Wed, 29 Oct 2008 21:19:40 +0100 Subject: [erlang-questions] Pattern-matching function? In-Reply-To: <8ca3fbe80810290818o5447de7ct8a13305fffe6583a@mail.gmail.com> References: <20081029140008.219340@gmx.net> <49087238.3030904@it.uu.se> <8ca3fbe80810290818o5447de7ct8a13305fffe6583a@mail.gmail.com> Message-ID: <3dbc6d1c0810291319u2a84bc8bjbc212b4efee0a863@mail.gmail.com> One solution is to use macros as a wrapper around a fun. So for example you could define: -define(pattern(Pat, Ret) , fun (Pat) -> {yes,Ret}; (_) -> no end). and then use it like: Match = ?pattern({x,X,y,z}, X), Match({x,anything,yz}) ==> {yes,anything}. and use it like: case Match(Value) of {yes,X} -> ... ; no -> ... end As for Francois request you could probably use macros there as well, but your question was very general so I can not really give you a suggestion. What are you after? As Richard said variables in Erlang don't exist as in Prolog so you can only "create" them by binding them to a value. They also have to be always bound so you cannot "return" a variable, only a value which can then be bound to a variable, as in the macro example above. The X in the macro call never escapes from the fun it is only used to show which values from the pattern are returned. Robert 2008/10/29 anders conbere > On Wed, Oct 29, 2008 at 7:24 AM, Richard Carlsson > wrote: > > Francois De Serres wrote: > >> Hi there. > >> > >> I need a function that actually does pattern matching: pm(Tuple, > Pattern)->MatchedPattern|error > > > > You cannot pass a pattern with uninstantiated variables to a function. > > Erlang is a strict functional language, it is not Prolog. Patterns are > > not run-time values. > > That being said, the lack of first class access to Patterns makes > programmatic access to a few of the most common tools in erlang > exceptionally difficult. Constructing case statements at runtime is > impossible with out accessing the preproccessor, building functions at > runtime that have many different possible patterns, also impossible. > It seems like there should be some way to gain access to this. > > I could for instance imagine delaying access to with a function that > accepted something like > > pattern(x, supplies("X"), y, z) > > which would return a function that when applied to a tuple > > {x, anything, y, z} > > would return > > {ok, {match, [{"X", anything}]}} > > and in that way you could construct semantics for applying those to > case statements or function parameters, etc. Maybe that's crazy, but I > sympathize with Francois, I've been trying to fumble my way through > erlang metaprogramming and just running into huge walls like this. > > ~ Anders > > > > > > > > /Richard > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kenneth.lundin@REDACTED Wed Oct 29 21:44:25 2008 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Wed, 29 Oct 2008 21:44:25 +0100 Subject: [erlang-questions] Extracting capture group names from regular expressions In-Reply-To: <740c3aec0810291118ncae988i315c1eb16ae48962@mail.gmail.com> References: <6672d0160810090059v56e82766h8af0f8ae46831c42@mail.gmail.com> <740c3aec0810291118ncae988i315c1eb16ae48962@mail.gmail.com> Message-ID: Hi, > Yes please! There is no support for anonymous groups either which is > an even bigger omission. There is certainly support for anonymous groups in the 're' module which we are talking about here. In the old regexp module there is no support for groups. /Kenneth Erlang/OTP, Ericsson From matthias@REDACTED Wed Oct 29 21:52:31 2008 From: matthias@REDACTED (Matthias Lang) Date: Wed, 29 Oct 2008 21:52:31 +0100 Subject: [erlang-questions] Problems with sending UDP datagrams without buffering In-Reply-To: <490873BA.6030506@echostar.com> References: <4907A8A1.2090701@echostar.com> <49085FDA.7000306@softjar.se> <20081029134411.GB4461@contorpis.lisalinda.com> <49086B88.8040303@softjar.se> <490873BA.6030506@echostar.com> Message-ID: <20081029205231.GA9074@contorpis.lisalinda.com> On Wednesday, October 29, Mark Geib wrote: > Yes, I am using UDP, not TCP. And to confirm, I am sending 700 bytes, > never any more. I see the 7000 byte datagram in WireShark on another > system monitoring the network. The 7000 bytes are reported as fragmented > packets that have been re-assembled. I am an sending the 700 bytes every > 20 miliseconds. > I am assuming that erlang is buffering in a lower layer, but could be > the linux network stack as well. If either of those two assumptions were true, then erlang (or linux) would break pretty much every UDP protocol there was. Everyone with a SIP stack would be screaming blue murder. They're not, so those assumptions look unlikely. Here's a minimal program which does what you say you're doing: -module(udpsender). -export([go/1]). go(Length) when is_integer(Length), Length > 0, Length < 16#ffff -> {ok, S} = gen_udp:open(0), {ok, Portno} = inet:port(S), io:fwrite("using outgoing port #~p\n", [Portno]), Bin = list_to_binary(lists:duplicate(Length, 36)), loop(S, Bin). loop(S, Bin) -> gen_udp:send(S, {172,16,2,7}, 9999, Bin), timer:sleep(20), loop(S, Bin). If I watch the network interface with 'tcpdump port 9999', here's what udpsender:go(700) looks like: 21:36:10.081265 IP contorpis.53829 > gth21.9999: UDP, length 700 21:36:10.102115 IP contorpis.53829 > gth21.9999: UDP, length 700 21:36:10.125267 IP contorpis.53829 > gth21.9999: UDP, length 700 21:36:10.146114 IP contorpis.53829 > gth21.9999: UDP, length 700 21:36:10.169257 IP contorpis.53829 > gth21.9999: UDP, length 700 21:36:10.190114 IP contorpis.53829 > gth21.9999: UDP, length 700 21:36:10.213255 IP contorpis.53829 > gth21.9999: UDP, length 700 i.e. as expected. One IP packet per UDP payload, length is always 700. I let it run for a minute while writing this. All lengths 700. Repeating for udpsender:go(7000), I get 21:39:40.726132 IP contorpis.43227 > gth21.9999: UDP, length 7000 21:39:40.749771 IP contorpis.43227 > gth21.9999: UDP, length 7000 21:39:40.770129 IP contorpis.43227 > gth21.9999: UDP, length 7000 21:39:40.793768 IP contorpis.43227 > gth21.9999: UDP, length 7000 21:39:40.814133 IP contorpis.43227 > gth21.9999: UDP, length 7000 i.e. again as expected. You can see the fragments by removing the port filter: 21:41:36.329803 IP contorpis.43227 > gth21.9999: UDP, length 7000 21:41:36.329818 IP contorpis > gth21: udp 21:41:36.329826 IP contorpis > gth21: udp 21:41:36.329831 IP contorpis > gth21: udp 21:41:36.329836 IP contorpis > gth21: udp So: the behaviour you're reporting is unexpected and I can't reproduce it. One way to make some progress is to post a minimal program which demonstrates what you're seeing so that others can try and repeat it. Matt p.s. all of the above is on R12B-4, Linux 2.6.24-1-amd64 and erlang says "version 5.6.4 [source] [64-bit] [smp:2] [async-threads:0] [hipe] [kernel-poll:false]" at startup From kenneth.lundin@REDACTED Wed Oct 29 21:54:05 2008 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Wed, 29 Oct 2008 21:54:05 +0100 Subject: [erlang-questions] Request for comments on EEP-24 In-Reply-To: References: Message-ID: The deadline for comments on EEP-24 is reached and the conclusion is that there are mostly positive comments and no engraving objections. Therefore we will set this EEP in approved status. And for your information the implementation will be included in the R12B-5 release which will be available soon. /Regards Kenneth Erlang/OTP, Ericsson On Mon, Oct 20, 2008 at 8:58 AM, Kenneth Lundin wrote: > We would like you to submit comments on EEP-24 on the eeps@REDACTED > mailing list. > Deadline for comments is 2008-10-28 and after that we will make a > decision about the EEP. > Here is a link to the EEP: http://www.erlang.org/eeps/eep-0024.html > > The reason for taking this EEP before other EEPs that was submitted > earlier is that we we think it is > an improvement that is compatible and it is very easy to implement. > > NOTE AGAIN! WE WANT THE COMMENTS on the eeps@REDACTED mailing list > only (NOT on erlang-questions). > > This will be the common procedure for EEPS that we announce request > for comments on erlang-questions with a deadline and > then receive and discuss the comments on the eeps mailing lists before > we make a decision which we will announce on both mailing lists. > > /Regards Kenneth Erlang/OTP team, Ericsson > From rvirding@REDACTED Wed Oct 29 23:48:40 2008 From: rvirding@REDACTED (Robert Virding) Date: Wed, 29 Oct 2008 23:48:40 +0100 Subject: [erlang-questions] Use of regular expressions Message-ID: <3dbc6d1c0810291548v52cbcc4ai2b791a6e1570c3bf@mail.gmail.com> As the new regular expression module is coming soon and after all the discussions on the net of how slow the old module was/is I was just wondering how they are used in "real life"? What type of searches are typically done on what type of data? Is there a typical usage? For example do people use regexps to pull apart a small string into components, like an URL? Or search for a match in a 100Mb data file? Or what? Or all of the above? I am just curious as to how they are used. Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: From per@REDACTED Thu Oct 30 00:01:59 2008 From: per@REDACTED (Per Hedeland) Date: Thu, 30 Oct 2008 00:01:59 +0100 (CET) Subject: [erlang-questions] how to get the factual ip address? In-Reply-To: Message-ID: <200810292301.m9TN1xYx069530@pluto.hedeland.org> "Alex Alvarez" wrote: > >getif/0 and getiflist/0 seem very useful, but shouldn't their output be in >sync order-wise with each other? > >getif/0 in my machine outputs... > >{ok,[{{192,168,1,3},{192,168,1,255},{255,255,255,0}}, > {{127,0,0,1},{0,0,0,0},{255,0,0,0}}]} > >, while getiflist/0 outputs... > >{ok,["lo","eth0"]} Yes, that would make sense - seems it's a foldl that should be a foldr in inet:getif/1. But anyway if you want to know the address for a specific interface, you can use ifget/2 instead - e.g.: 3> inet:ifget("bge0", [addr]). {ok,[{addr,{192,168,1,70}}]} And unfortunately is seems none of the above support the fact that an interface can have multiple addresses. --Per Hedeland From matthew@REDACTED Thu Oct 30 01:06:13 2008 From: matthew@REDACTED (Matthew Dempsky) Date: Wed, 29 Oct 2008 17:06:13 -0700 Subject: [erlang-questions] how to get the factual ip address? In-Reply-To: References: Message-ID: 2008/10/29 Alex Alvarez : > getif/0 and getiflist/0 seem very useful, Actually, I realized they're rather less useful than I was hoping. getif/0 only returns the primary IP address on each interface, it excludes aliases (at least on the systems I tested with). From monch1962@REDACTED Thu Oct 30 01:34:33 2008 From: monch1962@REDACTED (David Mitchell) Date: Thu, 30 Oct 2008 11:34:33 +1100 Subject: [erlang-questions] Use of regular expressions In-Reply-To: <3dbc6d1c0810291548v52cbcc4ai2b791a6e1570c3bf@mail.gmail.com> References: <3dbc6d1c0810291548v52cbcc4ai2b791a6e1570c3bf@mail.gmail.com> Message-ID: Do you have a pointer to info about the new Erlang regular expression module? I've heard bits and pieces about it, but haven't found any solid information other than "it's coming, and it'll be better than the current one". A large part of what I do is message handling, which involves tearing apart incoming messages (which might be XML, or binary data, or MQ data, or Oracle SQL*Net client requests, or ...), examining the content, then either routing the message to somewhere else, or extracting content from the incoming message and using it to build a suitable response. Regex is the way to go for tearing apart this type of data (well, if the incoming data is XML, then I'll parse out the individual field/s I'm interested in first using an XML parser, then often use regex to extract the info from within individual fields); I've tried using Erlang's pattern matching to achieve the same result, but the code required to do so was just too clunky and difficult to maintain. At the moment, Perl 5.10 is what I'm using; as of 5.10, the thread handling is much improved, and Perl's regex handling is basically as good as it gets. The limitation is that Perl has no easy way to scale load across multiple machines, which is an ongoing problem for us. There's also the broader problem of it being a challenge to write Perl code that is maintainable, long-term. I'd really like to be doing this in Erlang, for any number of reasons. A more powerful regex module would be a huge help in making this happen. Regards Dave M. 2008/10/30 Robert Virding : > As the new regular expression module is coming soon and after all the > discussions on the net of how slow the old module was/is I was just > wondering how they are used in "real life"? What type of searches are > typically done on what type of data? Is there a typical usage? > > For example do people use regexps to pull apart a small string into > components, like an URL? Or search for a match in a 100Mb data file? Or > what? Or all of the above? > > I am just curious as to how they are used. > > Robert > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From erlang-questions_efine@REDACTED Thu Oct 30 02:04:31 2008 From: erlang-questions_efine@REDACTED (Edwin Fine) Date: Wed, 29 Oct 2008 21:04:31 -0400 Subject: [erlang-questions] Use of regular expressions In-Reply-To: References: <3dbc6d1c0810291548v52cbcc4ai2b791a6e1570c3bf@mail.gmail.com> Message-ID: <6c2563b20810291804j647501c4u66df5f1295a5c5f1@mail.gmail.com> I thought the re module was supposed to be the new one ( http://www.erlang.org/doc/man/re.html), in experimental status but definitely in the current Erlang release, and regexp is the old one that's being replaced. Is there another new one coming that's different from re? Regards Edwin Fine On Wed, Oct 29, 2008 at 8:34 PM, David Mitchell wrote: > Do you have a pointer to info about the new Erlang regular expression > module? I've heard bits and pieces about it, but haven't found any > solid information other than "it's coming, and it'll be better than > the current one". > > A large part of what I do is message handling, which involves tearing > apart incoming messages (which might be XML, or binary data, or MQ > data, or Oracle SQL*Net client requests, or ...), examining the > content, then either routing the message to somewhere else, or > extracting content from the incoming message and using it to build a > suitable response. Regex is the way to go for tearing apart this type > of data (well, if the incoming data is XML, then I'll parse out the > individual field/s I'm interested in first using an XML parser, then > often use regex to extract the info from within individual fields); > I've tried using Erlang's pattern matching to achieve the same result, > but the code required to do so was just too clunky and difficult to > maintain. > > At the moment, Perl 5.10 is what I'm using; as of 5.10, the thread > handling is much improved, and Perl's regex handling is basically as > good as it gets. The limitation is that Perl has no easy way to scale > load across multiple machines, which is an ongoing problem for us. > There's also the broader problem of it being a challenge to write Perl > code that is maintainable, long-term. > > I'd really like to be doing this in Erlang, for any number of reasons. > A more powerful regex module would be a huge help in making this > happen. > > Regards > > Dave M. > > 2008/10/30 Robert Virding : > > As the new regular expression module is coming soon and after all the > > discussions on the net of how slow the old module was/is I was just > > wondering how they are used in "real life"? What type of searches are > > typically done on what type of data? Is there a typical usage? > > > > For example do people use regexps to pull apart a small string into > > components, like an URL? Or search for a match in a 100Mb data file? Or > > what? Or all of the above? > > > > I am just curious as to how they are used. > > > > Robert > > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jason.huang@REDACTED Thu Oct 30 03:09:40 2008 From: jason.huang@REDACTED (Jason Huang) Date: Wed, 29 Oct 2008 19:09:40 -0700 Subject: [erlang-questions] UNSUBSCRIBE Message-ID: <09ae01c93a34$91ec1b50$b5c451f0$@huang@wescongroup.com> -------------- next part -------------- An HTML attachment was scrubbed... URL: From rvirding@REDACTED Thu Oct 30 03:13:25 2008 From: rvirding@REDACTED (Robert Virding) Date: Thu, 30 Oct 2008 03:13:25 +0100 Subject: [erlang-questions] Use of regular expressions In-Reply-To: <6c2563b20810291804j647501c4u66df5f1295a5c5f1@mail.gmail.com> References: <3dbc6d1c0810291548v52cbcc4ai2b791a6e1570c3bf@mail.gmail.com> <6c2563b20810291804j647501c4u66df5f1295a5c5f1@mail.gmail.com> Message-ID: <3dbc6d1c0810291913o19049460n3b2dbe2a4501dbd4@mail.gmail.com> Yes, that is/will be the new one. It is still experimental and you can get a better idea of what is coming by looking at the EEP for it: http://www.erlang.org/eeps/eep-0011.html Robert 2008/10/30 Edwin Fine > I thought the re module was supposed to be the new one ( > http://www.erlang.org/doc/man/re.html), in experimental status but > definitely in the current Erlang release, and regexp is the old one that's > being replaced. Is there another new one coming that's different from re? > > Regards > Edwin Fine > > > On Wed, Oct 29, 2008 at 8:34 PM, David Mitchell wrote: > >> Do you have a pointer to info about the new Erlang regular expression >> module? I've heard bits and pieces about it, but haven't found any >> solid information other than "it's coming, and it'll be better than >> the current one". >> >> A large part of what I do is message handling, which involves tearing >> apart incoming messages (which might be XML, or binary data, or MQ >> data, or Oracle SQL*Net client requests, or ...), examining the >> content, then either routing the message to somewhere else, or >> extracting content from the incoming message and using it to build a >> suitable response. Regex is the way to go for tearing apart this type >> of data (well, if the incoming data is XML, then I'll parse out the >> individual field/s I'm interested in first using an XML parser, then >> often use regex to extract the info from within individual fields); >> I've tried using Erlang's pattern matching to achieve the same result, >> but the code required to do so was just too clunky and difficult to >> maintain. >> >> At the moment, Perl 5.10 is what I'm using; as of 5.10, the thread >> handling is much improved, and Perl's regex handling is basically as >> good as it gets. The limitation is that Perl has no easy way to scale >> load across multiple machines, which is an ongoing problem for us. >> There's also the broader problem of it being a challenge to write Perl >> code that is maintainable, long-term. >> >> I'd really like to be doing this in Erlang, for any number of reasons. >> A more powerful regex module would be a huge help in making this >> happen. >> >> Regards >> >> Dave M. >> >> 2008/10/30 Robert Virding : >> > As the new regular expression module is coming soon and after all the >> > discussions on the net of how slow the old module was/is I was just >> > wondering how they are used in "real life"? What type of searches are >> > typically done on what type of data? Is there a typical usage? >> > >> > For example do people use regexps to pull apart a small string into >> > components, like an URL? Or search for a match in a 100Mb data file? Or >> > what? Or all of the above? >> > >> > I am just curious as to how they are used. >> > >> > Robert >> > >> > >> > _______________________________________________ >> > erlang-questions mailing list >> > erlang-questions@REDACTED >> > http://www.erlang.org/mailman/listinfo/erlang-questions >> > >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From joelr1@REDACTED Thu Oct 30 04:15:46 2008 From: joelr1@REDACTED (Joel Reymont) Date: Thu, 30 Oct 2008 03:15:46 +0000 Subject: [erlang-questions] OpenPoker v2: The bestest and most scalable poker server ever Message-ID: http://tinyurl.com/5exq4c This is the final architecture as I'm sick of rewriting the thing and I don't think I can simplify it further! The first version I wrote back in 2005 used processes for everything. Seats, games, players, bots, games, pots, hands, all were processes. Moreover, they were all gen_servers. My cardgame "uber gen_fsm" was of particular interest and gave me the ability to put a stack of gen_fsm modules together. The cardgame driver would pop modules off the stack as they finished and modules could also tell the driver to re-run them, restart from the top of the full stack or go to the last module. The implementation was fugly but gave me the ability to put card game logic together from a set of betting, card dealing, etc. modules. Texas Hold'em, for example, uses a stack that looks like this: wait_for_players, blinds, deal_cards, betting, deal_cards, etc. Another feature was mapping process ids to integers by using gen_server:call on the pid at serialization time and looking up the integer in Mnesia when interpreting the packets. Last but not least, games freely gen_server:called players and vise versa, a recipe for disaster as I discovered under very high load. Yes, Virginia you can deadlock in Erlang! A great example of deadlock waiting to happen is firing off a timer from a game process and asking the player process for its id while the player is waiting for something from the game after a gen_server:call of its own. There are only two process types left in this latest version of OpenPoker: games and players. State machine logic is integrated into the game gen_server and I'm happy to say that the implementation is beautiful and still uses a stack of modules, albeit much smaller and simpler. Game gen_servers never ever call players and all processes are globally registered as {game, N} and {player, N} respectively. All packets go out with the integer ids in them since they are known at the source. Incoming messages are simply addressed to {player, References: <6c2563b20810192156i7516e69aqb4d0eda2e1ee98d9@mail.gmail.com> <620F5FF0-93F8-4E0E-BBDA-5404E82BB054@cs.otago.ac.nz> <18696.21498.534675.651372@ornendil.du.uab.ericsson.se> <49085DE3.502@it.uu.se> Message-ID: On 30 Oct 2008, at 1:58 am, Richard Carlsson wrote: > I was going to comment on this before, but didn't get around to it. > Please don't use the return convention above; namely, [] to represent an empty list and [Head|Tail] to represent a non-empty list. > it is not normal > Erlang programming style, and introduces an improper list for no > really good reason. You don't think that representing a list cell is a good reason to use a list cell? If the Dialyzer cannot represent the type [] + [T | seq(T)], so much the worse for the Dialyzer. As it happens, I tried a more usual Erlang style at first, and decided it was pointlessly un-mnemonic (as well as pointlessly inefficient). unfold(State, Splitter) -> Splitter(State, [], fun (X, State1) -> [X|unfold(State1, Splitter) end]). where we have unfold :: state -> % initial state (state -> % current state result -> % what to do if empty (item -> state -> result) % what to do if not empty -> result) % result of splitter -> result % result of unfold For counting, splitter might be fun (N, Nil, Cons) -> if N > Limit -> Nil ; N =< Limit -> Cons(N, N+1) end. [Note Return of Cons] Cons here is a function, but it's basically playing the role that [_|_] did in the previous version. The problem with the type given for 'unfold' above is 'item'. Dealing with it seems to require advanced type system machinery like existential types (or possibly dependent types) so unfold is _really_ unfold :: state -> (E item . state -> result -> (item -> state -> result) -> result) -> result Somehow, returning a pair to represent a pair just doesn't seem so evil. > A more traditional return convention would > use e.g., {Item,State1} | 'none'. Where the use of 'none' rather than 'empty' or 'end' or 'finished' or 'false' is rather arbitrary. The use of [] to represent an empty list is not arbitrary. Frankly, when the idea of using [] to represent [] and [_|_] to represent [_|_] struck me, I was pleasantly surprised at the naturalness of the result. But then I am a Bear of Very Little Brain. What _really_ matters is that _some_ form of unfold/2 be adopted, and if it uses a lengthier, less readable, and less efficient (but Dialyzer-friendlier) style, sobeit. I shall think of a Hum to comfort myself. From ok@REDACTED Thu Oct 30 05:13:20 2008 From: ok@REDACTED (Richard O'Keefe) Date: Thu, 30 Oct 2008 17:13:20 +1300 Subject: [erlang-questions] List to proplist? In-Reply-To: <1225284106.31992.26.camel@seasc0642.dyn.rnd.as.sw.ericsson.se> References: <6c2563b20810192156i7516e69aqb4d0eda2e1ee98d9@mail.gmail.com> <620F5FF0-93F8-4E0E-BBDA-5404E82BB054@cs.otago.ac.nz> <18696.21498.534675.651372@ornendil.du.uab.ericsson.se> <1225284106.31992.26.camel@seasc0642.dyn.rnd.as.sw.ericsson.se> Message-ID: <8FEABB6E-34FB-4B72-8F73-9989A48C767D@cs.otago.ac.nz> On 30 Oct 2008, at 1:41 am, Bengt Kleberg wrote: > Greetings, > > The unfold/2 below seems to take a fun. Yes, it does. > Many functions in the lists > module take their fun as the first argument. They do. The Lisp world has a reason for this. I'll use the (simpler) Scheme version: (map F Xs) (map F Xs Ys) (map F Xs Ys Zs) ... In practice this impairs readability: (map (lambda (X) .... .... ...) (...)) ; this is the list whereas (map (...) (lambda (X) .... .... ....)) would have been easier to follow in the very common case that the expression that yields the list is short. In Smalltalk one writes aCollection collect: [:each | ....] with the fun at the _end_, and the improvement in readability is noteworthy. The SML/Haskell world also has a reason for it, but a different one: increase_all = map (+1) is a function in its own right, thanks to Currying. (It's still waiting for its list argument.) Since Erlang doesn't have multi-arity mapping functions and doesn't do Currying, the best place for fun arguments would have been at the far end. Sigh. > For consistency it would > perhaps be a good idea to let unfold/2 also takes the fun as its first > argument? So that it can be as awkward as the others? You have a point. Let it be so, then. From ok@REDACTED Thu Oct 30 05:18:43 2008 From: ok@REDACTED (Richard O'Keefe) Date: Thu, 30 Oct 2008 17:18:43 +1300 Subject: [erlang-questions] Pattern-matching function? In-Reply-To: <20081029140008.219340@gmx.net> References: <20081029140008.219340@gmx.net> Message-ID: <3CE2E712-8196-43AA-91B7-C935C894D3A8@cs.otago.ac.nz> On 30 Oct 2008, at 3:00 am, Francois De Serres wrote: > Hi there. > > I need a function that actually does pattern matching: pm(Tuple, > Pattern)->MatchedPattern|error Patterns are not expressions, you cannot pass them as parameters. What you CAN do is pass functions. >> >> pm({a,b,c}, {a,X,Y}). > {a,b,c} >> X. > b You are trying to pass a variable into another function and have it bound there. That cannot happen. Variables are not values either, and cannot be passed as arguments. There are also 'match specifications' which are data structures that get processed sort of as if they were kind of not entirely unlike patterns. Could you explain what problem you are trying to solve by doing this? There is probably a simpler way. From als@REDACTED Thu Oct 30 07:04:22 2008 From: als@REDACTED (Anthony Shipman) Date: Thu, 30 Oct 2008 17:04:22 +1100 Subject: [erlang-questions] small dialyzer bug Message-ID: <200810301704.22977.als@iinet.net.au> Message considered unreadable: Analysis failed with error: Could not scan the following file(s): [{"/home/als/wk/dev/s4_als/step/estep/web/.bin/webUtil.beam", [85,110,107,110,111,119,110,32,116, 121,112,101,32,"integer",10]}, -- Anthony Shipman Mamas don't let your babies als@REDACTED grow up to be outsourced. From eeajam@REDACTED Thu Oct 30 08:33:59 2008 From: eeajam@REDACTED (Alex Alvarez) Date: Thu, 30 Oct 2008 03:33:59 -0400 Subject: [erlang-questions] how to get the factual ip address? Message-ID: >Actually, I realized they're rather less useful than I was hoping. >getif/0 only returns the primary IP address on each interface, it >excludes aliases (at least on the systems I tested with). Well, I said useful, not perfect! ;) I suppose all the current functionality was originally added for Ericsson equipment's use only, which might not require the use of additional IPs per interface. Having said that, the ability to show all the given IPs for each active interface would be must welcomed! Cheers, Alex -------------- next part -------------- An HTML attachment was scrubbed... URL: From adam@REDACTED Thu Oct 30 08:34:49 2008 From: adam@REDACTED (Adam Lindberg) Date: Thu, 30 Oct 2008 08:34:49 +0100 Subject: [erlang-questions] Extracting capture group names from regular expressions In-Reply-To: <6672d0160810090059v56e82766h8af0f8ae46831c42@mail.gmail.com> References: <6672d0160810090059v56e82766h8af0f8ae46831c42@mail.gmail.com> Message-ID: <6344005f0810300034t5cae6ddawf506233f0bb6716f@mail.gmail.com> When using regular expressions as a part of an API returning named groups is very desirable. As it is now one has to parse the regular expression (with another regular expression?) to find the group names and the match them together with the result. Not a very efficient way of doing things, and rather error prone. If the re module knows about the groups, as you can retrieve them by name, why not just return their names too? I'd like this feature to be included since it is very powerful together with groups. Thanks! Cheers, Adam 2008/10/9 Bjorn Gustavsson > 2008/10/7 Tony Arcieri > >> I'm trying to write an API which accepts a regexp with arbitrary named >> capture groups as input. >> >> I'm using the re module, and have had success using named subgroups if the >> names are known ahead of time. However, I'd like to return a mapping of >> arbitrary named capture groups from the original regular expression to the >> matched values. >> >> Consider the following regular expression with named subpatterns: >> >> "(?\\w+) (?\\w+)" >> >> If this were applied to the string "baz qux" I'd like to return the >> following: >> >> [{"foo", "baz"}, {"bar", "qux"}] >> >> However, it looks as if I must provide the names of the capture groups I >> want returned in the capture tuple I pass to re:run. >> >> Is there any way to extract the names of the subgroups from a compiled >> regular expression? Or is there some option I can pass to re:run that I'm >> missing which will return a mapping of subgroup names to what they matched? >> >> > > There is currently no such option or functionality. It could be added in a > future release if it's a general need. > > /Bjorn > -- > Bj?rn Gustavsson, Erlang/OTP, Ericsson AB > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From als@REDACTED Thu Oct 30 08:41:09 2008 From: als@REDACTED (Anthony Shipman) Date: Thu, 30 Oct 2008 18:41:09 +1100 Subject: [erlang-questions] type syntax question Message-ID: <200810301841.09209.als@iinet.net.au> I want to write something like -type (deviceOpHandler() :: fun( (integer(), cstate()) -> cstate() )). -spec (okHandler/2 :: deviceOpHandler()). okHandler(_DeviceID, CState) -> sendResponse(200, "OK", CState). but I can't find the right combination of parentheses to please the compiler. Is this kind of specification possible? Will there be documentation on the type and spec syntax coming soon? -- Anthony Shipman Mamas don't let your babies als@REDACTED grow up to be outsourced. From kostis@REDACTED Thu Oct 30 09:05:44 2008 From: kostis@REDACTED (Kostis Sagonas) Date: Thu, 30 Oct 2008 10:05:44 +0200 Subject: [erlang-questions] type syntax question In-Reply-To: <200810301841.09209.als@iinet.net.au> References: <200810301841.09209.als@iinet.net.au> Message-ID: <49096AD8.9060502@cs.ntua.gr> Anthony Shipman wrote: > I want to write something like > > -type (deviceOpHandler() :: fun( (integer(), cstate()) -> cstate() )). > > -spec (okHandler/2 :: deviceOpHandler()). > > okHandler(_DeviceID, CState) -> > sendResponse(200, "OK", CState). > > but I can't find the right combination of parentheses to please the compiler. > Is this kind of specification possible? The deviceOpHandler() does not need a "type" declaration. In fact, it shouldn't have one for just the above. In the old spec syntax, the above example can simply be written as: -spec(okHandler/2 :: (integer(), cstate()) -> cstate()). or, from R12B-4 onwards, more simply as: -spec okHandler(integer(), cstate()) -> cstate(). which is now the recommended way -- the EEP needs to be updated. If at some other function you need to specify that the function takes a deviceOpHandler as an argument, then you can define that type as: -type deviceOpHandler() :: fun((integer(), cstate()) -> cstate()). and use it as: -spec my_foo(deviceOpHandler()) -> 42. > Will there be documentation on the type and spec syntax coming soon? Well, the answer depends on your definition of "soon"... ;-) The current plan is that types & specs will be properly documented in R13. Kostis From rapsey@REDACTED Thu Oct 30 09:27:16 2008 From: rapsey@REDACTED (Rapsey) Date: Thu, 30 Oct 2008 09:27:16 +0100 Subject: [erlang-questions] OpenPoker v2: The bestest and most scalable poker server ever In-Reply-To: References: Message-ID: <97619b170810300127r5aef97bfwf5456bf1f0114272@mail.gmail.com> Why R11B3? Sergej On Thu, Oct 30, 2008 at 4:15 AM, Joel Reymont wrote: > http://tinyurl.com/5exq4c > > This is the final architecture as I'm sick of rewriting the thing and > I don't think I can simplify it further! > > The first version I wrote back in 2005 used processes for everything. > Seats, games, players, bots, games, pots, hands, all were processes. > Moreover, they were all gen_servers. > > My cardgame "uber gen_fsm" was of particular interest and gave me the > ability to put a stack of gen_fsm modules together. The cardgame > driver would pop modules off the stack as they finished and modules > could also tell the driver to re-run them, restart from the top of the > full stack or go to the last module. > > The implementation was fugly but gave me the ability to put card game > logic together from a set of betting, card dealing, etc. modules. > Texas Hold'em, for example, uses a stack that looks like this: > wait_for_players, blinds, deal_cards, betting, deal_cards, etc. > > Another feature was mapping process ids to integers by using > gen_server:call on the pid at serialization time and looking up the > integer in Mnesia when interpreting the packets. > > Last but not least, games freely gen_server:called players and vise > versa, a recipe for disaster as I discovered under very high load. > Yes, Virginia you can deadlock in Erlang! > > A great example of deadlock waiting to happen is firing off a timer > from a game process and asking the player process for its id while the > player is waiting for something from the game after a gen_server:call > of its own. > > There are only two process types left in this latest version of > OpenPoker: games and players. State machine logic is integrated into > the game gen_server and I'm happy to say that the implementation is > beautiful and still uses a stack of modules, albeit much smaller and > simpler. > > Game gen_servers never ever call players and all processes are > globally registered as {game, N} and {player, N} respectively. All > packets go out with the integer ids in them since they are known at > the source. Incoming messages are simply addressed to {player, > "global" infrastructure but it hasn't let me down yet. > > Everything else is just record "mutation", no message passing > whatsoever. > > I'm throwing down the gauntlet here. I'll bloody switch to Lisp and > libevent-based single-threaded servers if this OpenPoker cannot handle > mover than 10k games and 50K players on a single server! > > -- > wagerlabs.com > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From richardc@REDACTED Thu Oct 30 09:30:29 2008 From: richardc@REDACTED (Richard Carlsson) Date: Thu, 30 Oct 2008 09:30:29 +0100 Subject: [erlang-questions] Pattern-matching function? In-Reply-To: <20081029182645.219350@gmx.net> References: <20081029140008.219340@gmx.net> <49087238.3030904@it.uu.se> <20081029182645.219350@gmx.net> Message-ID: <490970A5.9020207@it.uu.se> Francois De Serres wrote: > Thank you Richard. > Any way to overcome this with parsing/binding/eval magic, even cumbersome ? Depending on what you need, in terms of efficiency (is the code going to be a bottleneck, or just executed occasionally?), and if you really need to do metaprogramming (often a big *if*), there are several options: - Output the code as plain text to a .erl-file and call the compiler. (Dead simple, and quite flexible - can use macros and includes for "template" stuff so you don't need to generate that as well.) - Generate the code as text in memory, call the scanner and parser, and pass the result to compile:forms/2. You can't use the preprocessor this way (it only works on files), but you don't have to go to disk, and you don't need to learn about the syntax tree representation. - Generate the syntax trees directly and pass to the compiler. Fiddly, unreadable and hard to maintain, but low-overhead and full control. But doing compilation on the fly might not be suitable if you are going to do it a million times (unless you can reuse the same module name, you will have to generate unique module names for each new compilation, and who will then be responsible for deleting unused modules?). If the code you are going to run is short and not a bottleneck, it could be better to use erl_eval, for example like this: make_match_fun(Pstr) -> element(2, erl_eval:expr(hd(element(2, erl_parse:parse_exprs(element(2, erl_scan:string(lists:flatten(io_lib:format("fun (~s=__P) -> {matched,__P}; (_) -> fail end.", [Pstr]))))))), erl_eval:new_bindings())). This will, via erl_eval, produce a fun that can be used like you wanted: F = make_match_fun("{X,Y}") F({1,2}) ==> {matched, {1,2}} F({}) ==> fail /Richard From tobias.lindahl@REDACTED Thu Oct 30 09:35:51 2008 From: tobias.lindahl@REDACTED (Tobias Lindahl) Date: Thu, 30 Oct 2008 09:35:51 +0100 Subject: [erlang-questions] type syntax question In-Reply-To: <200810301841.09209.als@iinet.net.au> References: <200810301841.09209.als@iinet.net.au> Message-ID: <490971E7.2010807@kreditor.se> Anthony Shipman wrote: > I want to write something like > > -type (deviceOpHandler() :: fun( (integer(), cstate()) -> cstate() )). > > -spec (okHandler/2 :: deviceOpHandler()). > > okHandler(_DeviceID, CState) -> > sendResponse(200, "OK", CState). > > but I can't find the right combination of parentheses to please the compiler. > Is this kind of specification possible? No it isn't. You can use your own declared types in specs (of course), but for the top level in the spec you have to be explicit. There is nowadays also an alternative notation to the specs that do away with some of the parentheses. -spec okHandler(integer(), cstate()) -> cstate(). I find this one easier to read. As before you can also put your variables in the arguments if you like. -spec okHandler(DeviceID :: integer(), CState :: cstate()) -> cstate(). > > Will there be documentation on the type and spec syntax coming soon? > Please define soon... ;-) Well, I guess when the EEP gets accepted and the types become an official feature someone should make a proper documentation. For now, you can look in the EEP http://www.erlang.org/eeps/eep-0008.html which is in need of an update, but gets the main things correct. Tobias From joelr1@REDACTED Thu Oct 30 09:40:54 2008 From: joelr1@REDACTED (Joel Reymont) Date: Thu, 30 Oct 2008 08:40:54 +0000 Subject: [erlang-questions] OpenPoker v2: The bestest and most scalable poker server ever In-Reply-To: <97619b170810300127r5aef97bfwf5456bf1f0114272@mail.gmail.com> References: <97619b170810300127r5aef97bfwf5456bf1f0114272@mail.gmail.com> Message-ID: <0B9D2A61-8BBB-4C1E-87C9-442006F6D6BA@gmail.com> It's R12B3, my bad. I suppose you can use R12B4 as well. On Oct 30, 2008, at 8:27 AM, Rapsey wrote: > Why R11B3? -- wagerlabs.com From joelr1@REDACTED Thu Oct 30 11:03:45 2008 From: joelr1@REDACTED (Joel Reymont) Date: Thu, 30 Oct 2008 10:03:45 +0000 Subject: [erlang-questions] unlimited # of fds on solaris, including for slave nodes Message-ID: <0B08CB0D-F973-4002-BB38-1ED451E1A8E7@gmail.com> Folks, How do I make sure that an unlimited # of file descriptors is available to me on Solaris 5.11, including the shell and Erlang slave nodes? I do it like this now: cat poker #!/bin/bash ulimit -Sn 65536 erl +K true +P 134217727 -sname 1 -s mnesia start $* But launched slaves nodes don't seem to inherit the ulimit setting. I have root access, just don't know what to change. Thanks, Joel -- wagerlabs.com From ulf@REDACTED Thu Oct 30 11:53:45 2008 From: ulf@REDACTED (Ulf Wiger) Date: Thu, 30 Oct 2008 11:53:45 +0100 Subject: [erlang-questions] unlimited # of fds on solaris, including for slave nodes In-Reply-To: <0B08CB0D-F973-4002-BB38-1ED451E1A8E7@gmail.com> References: <0B08CB0D-F973-4002-BB38-1ED451E1A8E7@gmail.com> Message-ID: <8209f740810300353t4d325395v8ee5fe0864cd656f@mail.gmail.com> Joel, If you use slave.erl, you can write a small wrapper around rsh and use erl -rsh rsh_wrapper to tell slave to use it. BR, Ulf W 2008/10/30 Joel Reymont : > Folks, > > How do I make sure that an unlimited # of file descriptors is > available to me on Solaris 5.11, including the shell and Erlang slave > nodes? > > I do it like this now: > > cat poker > #!/bin/bash > > ulimit -Sn 65536 > erl +K true +P 134217727 -sname 1 -s mnesia start $* > > But launched slaves nodes don't seem to inherit the ulimit setting. > > I have root access, just don't know what to change. > > Thanks, Joel > > -- > wagerlabs.com > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From joelr1@REDACTED Thu Oct 30 12:09:05 2008 From: joelr1@REDACTED (Joel Reymont) Date: Thu, 30 Oct 2008 11:09:05 +0000 Subject: [erlang-questions] unlimited # of fds on solaris, including for slave nodes In-Reply-To: <78892139.20081030130005@mail.ru> References: <0B08CB0D-F973-4002-BB38-1ED451E1A8E7@gmail.com> <78892139.20081030130005@mail.ru> Message-ID: <029C8FAA-EDFD-43F3-BFFB-0E49C63D51EC@gmail.com> On Oct 30, 2008, at 11:00 AM, Dennis wrote: > Default soft limit for # of open FDs is set by rlim_fd_cur in > /etc/sysem. You should also take a look at rlim_fd_max to > make sure it is not set lower than rlim_fd_cur. cat /etc/system set rlim_fd_max=65536 Should I add rlim_fd_cur and set it to the same number? Thanks, Joel -- wagerlabs.com From bekesa@REDACTED Thu Oct 30 12:14:05 2008 From: bekesa@REDACTED (Andras Georgy Bekes) Date: Thu, 30 Oct 2008 12:14:05 +0100 Subject: [erlang-questions] [eeps] Request for comments on EEP-24 In-Reply-To: References: Message-ID: <200810301214.05613.bekesa@sch.bme.hu> > The deadline for comments on EEP-24 is reached and the conclusion is > that there are mostly positive comments and no engraving objections. Hi, I've sent a mail to eeps@REDACTED with my comments, but it seems that it did not reach the list (I cannot find it in the archives). I suggested the followings: Currently no operators are allowed in module attributes, except for F/A in -export(). Example: -myattribute(1+2) is not allowed. I proposed to allow every standard operator in attributes, and each X op Y subexpression in an attribute to be converted to {'op',X,Y}. This means that F/A will be converted to {'/',F,A}, which is against EEP-24, but F/A's are treated specially in -export() attributes anyways, and regarding F/A's in other attributes, I can't see the advantage of {F,A} over {'/',F,A}. On the other hand, this really removes the special treating of the F/A construct. Waiting for your reactions. My original mail to eeps@REDACTED is: ------------------------------------------------------- Subject: Re: [eeps] EEP 24 -- F/N converts to {F,N} in *all* directives Date: Tuesday 21 October 2008 From: Andras Georgy Bekes To: eeps@REDACTED Hi all, I fully support this eep. We use a parse transformation that should use a user-defined module attribute with a list of F/N's, but we can not use this notation (until this eep gets accepted). On the other hand, we should have another custom module attribute, which resembles to record definitions, but we can not use such a notation and this eep won't help us. The -record/2 attribute has two properties that can not be done with custom attributes: - it has arity 2 - it can contain "fieldname=DefaultValue" like stuff. These should be allowed in custom attributes as well, in order to remove one more inconsistency. I know allowing the latter in custom attributes is nonsensical, but at least the parser should accept it (in order some parse transformations could use it), and it should be rejected by the compiler. A different solution would be not to reject it by the compiler but to convert X = Y to {'=',X,Y}, and generalizing the idea, every X op Y could be converted to {'op',X,Y}. This implies that F/N should be converted to {'/',F,N}, which sounds bad, but the compiler could still convert it to {F,N} when building the exports list for the module_info/0,1 functions. (The F/N notation had special treatment anyways.) Parse transformations are so powerful, but on the other hand are so limited because of the parser accepts only a very limited set of operators and only in some places... Something should be done to improve the consistency of the language! Georgy ------------------------------------------------------- From launoja@REDACTED Thu Oct 30 12:38:39 2008 From: launoja@REDACTED (Jani Launonen) Date: Thu, 30 Oct 2008 13:38:39 +0200 Subject: [erlang-questions] Sorry, mailing mistake (WAS: Re: Shoein viriili...) In-Reply-To: References: <208519030810280824n1e5998eaw4efbf680f1dbb0d@mail.gmail.com> Message-ID: Sorry everyone, I did send a private mail to the whole list by mistake. I'm not quite sure how it did happen, perhaps long latency in webmail over 3G did result in stale information in composing new message or I did some cut'n'paste acrobatics without noticing it. Sorry for the noise. I try to be more careful next time and apologies for Finnish speakers for the bad language ;) Jani L. From joelr1@REDACTED Thu Oct 30 12:38:46 2008 From: joelr1@REDACTED (Joel Reymont) Date: Thu, 30 Oct 2008 11:38:46 +0000 Subject: [erlang-questions] openpoker crashes erlang on solaris Message-ID: Solaris x86 5.11. Erlang (BEAM) emulator version 5.6.4 [source] [async-threads:0] [hipe] [kernel-poll:false] How do I troubleshoot this? Thanks, Joel === (1@REDACTED)1> dmb:run(1000, 5, 5). game5@REDACTED: game server on port 3001 game5@REDACTED: port server on 3001... game4@REDACTED: game server on port 3002 game4@REDACTED: port server on 3002... game3@REDACTED: game server on port 3003 game3@REDACTED: port server on 3003... game2@REDACTED: game server on port 3004 game2@REDACTED: port server on 3004... game1@REDACTED: game server on port 3005 game1@REDACTED: port server on 3005... cluster: [bot5@REDACTED,bot4@REDACTED,bot3@REDACTED,bot2@REDACTED, bot1@REDACTED,game5@REDACTED,game4@REDACTED,game3@REDACTED, game2@REDACTED,game1@REDACTED] bot launchers : [<8625.83.0>,<8623.78.0>,<8621.73.0>,<8619.68.0>,<8579.62.0>] game launchers : [<8677.485.0>,<8675.431.0>,<8673.582.0>,<8671.416.0>, <8627.252.0>] game servers : [<8677.322.0>,<8675.268.0>,<8673.419.0>,<8671.253.0>, <8627.89.0>] gateway:start('1@REDACTED', 4000, 500000) Waiting for game servers... '1@REDACTED': port server on 4000... Simulating gameplay with 1000 games... 50 games started, 262 players 100 games started, 504 players 150 games started, 743 players 200 games started, 1019 players 250 games started, 1288 players 300 games started, 1529 players 350 games started, 1766 players 400 games started, 2057 players 450 games started, 2304 players 500 games started, 2562 players 550 games started, 2800 players 600 games started, 3021 players 650 games started, 3242 players 700 games started, 3523 players 750 games started, 3765 players 800 games started, 4032 players 850 games started, 4297 players 900 games started, 4540 players 950 games started, 4777 players 1000 games started, 5066 players dmb: 1000 games will be launching simultaneously dmb: waiting for games to end... =INFO REPORT==== 30-Oct-2008::11:32:43 === module: stats elapsed: 5.000047 {total_bots_connected,2}: 1032 =INFO REPORT==== 30-Oct-2008::11:33:08 === module: stats elapsed: 4.999943 {total_bots_connected,7}: 1578 {bots_connected,7}: 488 {games_launched,7}: 135 {read_count,7}: 694 {update_balance_count,7}: 697 {write_count,7}: 1760 {"bots_connected/sec",7}: 97 {"games_launched/sec",7}: 27 {"read_count/sec",7}: 138 {"update_balance_count/sec",7}: 139 {"write_count/sec",7}: 352 {max_game_launch_time,7}: 32755.475 {max_read_time,7}: 6.246 {max_time_to_client,7}: 4.834 {max_time_to_server,7}: 3.619 {max_update_balance_time,7}: 15.028 {max_write_time,7}: 17.56 {player_connect_time,7}: 8.373 {game_launch_time,7}: 1783.6615121877164 {game_start_time,7}: 1763.5292236823987 {player_connect_time,7}: 0.4632935153522024 {read_time,7}: 0.16648887271605387 {time_to_client,7}: 0.011833071131099462 {time_to_server,7}: 0.1577965194965255 {update_balance_time,7}: 0.1634220775668928 {write_time,7}: 0.07750144444110416 ./poker: line 4: 22720 Segmentation Fault (core dumped) erl +K true +P 134217727 -sname 1 -s mnesia start $* -- wagerlabs.com From bekesa@REDACTED Thu Oct 30 12:48:28 2008 From: bekesa@REDACTED (Andras Georgy Bekes) Date: Thu, 30 Oct 2008 12:48:28 +0100 Subject: [erlang-questions] Pattern-matching function? In-Reply-To: <490970A5.9020207@it.uu.se> References: <20081029140008.219340@gmx.net> <20081029182645.219350@gmx.net> <490970A5.9020207@it.uu.se> Message-ID: <200810301248.28632.bekesa@sch.bme.hu> > But doing compilation on the fly might not be suitable if you are > going to do it a million times (unless you can reuse the same module > name, you will have to generate unique module names for each new > compilation, and who will then be responsible for deleting unused > modules?). Even if you delete the unused module (does the Erlang VM really "delete" a module if it is made old by calling code:delete(Module) and are no processes executing it?), you can not delete the atom you created and you're filling the (limited) atom table. Georgy From saleyn@REDACTED Thu Oct 30 12:58:50 2008 From: saleyn@REDACTED (Serge Aleynikov) Date: Thu, 30 Oct 2008 07:58:50 -0400 Subject: [erlang-questions] inets http client Message-ID: <4909A17A.1070206@gmail.com> Is there a way in http:request/4 call to limit the number of bytes returned without waiting for the full content? I have a URL to query frequently where the most relevant information is in the beginning of the page and the tail of the document is useless but large. There is {full_result, boolean()} option (that doesn't seem to be documented well, so I am unclear what it does) but I don't see how to limit the number of bytes to be received. Serge From jeansagi@REDACTED Thu Oct 30 13:24:47 2008 From: jeansagi@REDACTED (Jean Sagi) Date: Thu, 30 Oct 2008 07:24:47 -0500 Subject: [erlang-questions] OpenPoker v2: The bestest and most scalable poker server ever In-Reply-To: References: Message-ID: <5bd82490810300524j44411df1v7eb75a480587cbcd@mail.gmail.com> Isn't it said that perfection is achieved when there is nothing left to take away ;) J. 2008/10/29 Joel Reymont > http://tinyurl.com/5exq4c > > This is the final architecture as I'm sick of rewriting the thing and > I don't think I can simplify it further! > > The first version I wrote back in 2005 used processes for everything. > Seats, games, players, bots, games, pots, hands, all were processes. > Moreover, they were all gen_servers. > > My cardgame "uber gen_fsm" was of particular interest and gave me the > ability to put a stack of gen_fsm modules together. The cardgame > driver would pop modules off the stack as they finished and modules > could also tell the driver to re-run them, restart from the top of the > full stack or go to the last module. > > The implementation was fugly but gave me the ability to put card game > logic together from a set of betting, card dealing, etc. modules. > Texas Hold'em, for example, uses a stack that looks like this: > wait_for_players, blinds, deal_cards, betting, deal_cards, etc. > > Another feature was mapping process ids to integers by using > gen_server:call on the pid at serialization time and looking up the > integer in Mnesia when interpreting the packets. > > Last but not least, games freely gen_server:called players and vise > versa, a recipe for disaster as I discovered under very high load. > Yes, Virginia you can deadlock in Erlang! > > A great example of deadlock waiting to happen is firing off a timer > from a game process and asking the player process for its id while the > player is waiting for something from the game after a gen_server:call > of its own. > > There are only two process types left in this latest version of > OpenPoker: games and players. State machine logic is integrated into > the game gen_server and I'm happy to say that the implementation is > beautiful and still uses a stack of modules, albeit much smaller and > simpler. > > Game gen_servers never ever call players and all processes are > globally registered as {game, N} and {player, N} respectively. All > packets go out with the integer ids in them since they are known at > the source. Incoming messages are simply addressed to {player, > "global" infrastructure but it hasn't let me down yet. > > Everything else is just record "mutation", no message passing > whatsoever. > > I'm throwing down the gauntlet here. I'll bloody switch to Lisp and > libevent-based single-threaded servers if this OpenPoker cannot handle > mover than 10k games and 50K players on a single server! > > -- > wagerlabs.com > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- J.! jeansagi@REDACTED jeansagi@REDACTED -------------- next part -------------- An HTML attachment was scrubbed... URL: From bekesa@REDACTED Thu Oct 30 13:26:23 2008 From: bekesa@REDACTED (Andras Georgy Bekes) Date: Thu, 30 Oct 2008 13:26:23 +0100 Subject: [erlang-questions] List to proplist? In-Reply-To: <8FEABB6E-34FB-4B72-8F73-9989A48C767D@cs.otago.ac.nz> References: <6c2563b20810192156i7516e69aqb4d0eda2e1ee98d9@mail.gmail.com> <1225284106.31992.26.camel@seasc0642.dyn.rnd.as.sw.ericsson.se> <8FEABB6E-34FB-4B72-8F73-9989A48C767D@cs.otago.ac.nz> Message-ID: <200810301326.23513.bekesa@sch.bme.hu> > lists:unfold/2 has been added to the upcoming R12B-5 release. Please note that I proposed an extension for list comprehensions that does the job of unfold/2 and more. See http://www.erlang.org/pipermail/erlang-questions/2008-August/037150.html I'm not saying that unfold/2 is not needed. We do have (and sometimes use) map/2 and filter/2 even if using list comprehension is usually more readable. I'm saying that the power of unfold should be incorporated in list comprehensions, as it can be done with a nice syntax and semantics. Georgy From bog09@REDACTED Thu Oct 30 13:21:23 2008 From: bog09@REDACTED (BOG BOG) Date: Thu, 30 Oct 2008 05:21:23 -0700 (PDT) Subject: [erlang-questions] sending multiple packets on the same socket Message-ID: <458458.99871.qm@web54301.mail.re2.yahoo.com> Hello everybody, I have a little problem and I do not know how to resolve it. I am writing a little client that must communicate with a server based on sessions: Basically this is the scenario: 1. client sends the login request to the server; 2. server responds with an welcome message 3. after that, client send other messages to the server, in this newly created session 4. the session is closed normally by the client issuing a closing message to the server. The client is written in erlang, and the server in perl. The problem: I'm not able to keep the socket open in order to send successive packets to the server, because the socket is automatically closed when the client receives the welcome message from the server. I want to be able to make succesive calls to the pair gen_tcp:send(Socket, Packet), gen_tcp:recv(Socket, 0) on the same socket (the socket is opened with the option {active, false}). I've tried a statement like this upon socket creation: {ok, Socket} = gen_tcp:connect("epp.rotld.ro", 5544, [binary, {packet, 0}, {active, false}, {exit_on_close,false}, {keepalive,true},{reuseaddr,true}]), and to subsequent calls to inet:setopts(), but the socket behaves in the same way - it is closing after the first reply of the server. Thank you very much, bogdan From bengt.kleberg@REDACTED Thu Oct 30 14:46:02 2008 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Thu, 30 Oct 2008 14:46:02 +0100 Subject: [erlang-questions] sending multiple packets on the same socket In-Reply-To: <458458.99871.qm@web54301.mail.re2.yahoo.com> References: <458458.99871.qm@web54301.mail.re2.yahoo.com> Message-ID: <1225374362.554.11.camel@seasc0642.dyn.rnd.as.sw.ericsson.se> Greetings, Have you checked (with tcpdump or similar) who it is that closes the socket? Is it the server or the client? bengt On Thu, 2008-10-30 at 05:21 -0700, BOG BOG wrote: > Hello everybody, > > I have a little problem and I do not know how to resolve it. > > I am writing a little client that must communicate with a server based on sessions: > > Basically this is the scenario: > > 1. client sends the login request to the server; > 2. server responds with an welcome message > 3. after that, client send other messages to the server, in this newly created session > 4. the session is closed normally by the client issuing a closing message to the server. > > The client is written in erlang, and the server in perl. > > The problem: > > I'm not able to keep the socket open in order to send successive packets to > the server, because the socket is automatically closed when the client receives the welcome message from the server. > > I want to be able to make succesive calls to the pair > gen_tcp:send(Socket, Packet), > gen_tcp:recv(Socket, 0) > > on the same socket (the socket is opened with the option {active, false}). > > I've tried a statement like this upon socket creation: > {ok, Socket} = gen_tcp:connect("epp.rotld.ro", 5544, [binary, {packet, 0}, > {active, false}, {exit_on_close,false}, > {keepalive,true},{reuseaddr,true}]), > > and to subsequent calls to inet:setopts(), but the socket behaves in the same way - it is closing after the first reply of the server. > > Thank you very much, > > bogdan > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From als@REDACTED Thu Oct 30 15:01:38 2008 From: als@REDACTED (Anthony Shipman) Date: Fri, 31 Oct 2008 01:01:38 +1100 Subject: [erlang-questions] type syntax question In-Reply-To: <49096AD8.9060502@cs.ntua.gr> References: <200810301841.09209.als@iinet.net.au> <49096AD8.9060502@cs.ntua.gr> Message-ID: <200810310101.38106.als@iinet.net.au> On Thu, 30 Oct 2008 07:05:44 pm Kostis Sagonas wrote: > Anthony Shipman wrote: > > I want to write something like > > > > -type (deviceOpHandler() :: fun( (integer(), cstate()) -> cstate() )). > > > > -spec (okHandler/2 :: deviceOpHandler()). > > > > okHandler(_DeviceID, CState) -> > > sendResponse(200, "OK", CState). > > > > but I can't find the right combination of parentheses to please the > > compiler. Is this kind of specification possible? > > The deviceOpHandler() does not need a "type" declaration. In fact, it > shouldn't have one for just the above. In the old spec syntax, the > above example can simply be written as: > > -spec(okHandler/2 :: (integer(), cstate()) -> cstate()). > > or, from R12B-4 onwards, more simply as: > > -spec okHandler(integer(), cstate()) -> cstate(). > > which is now the recommended way -- the EEP needs to be updated. > > If at some other function you need to specify that the function takes a > deviceOpHandler as an argument, then you can define that type as: > > -type deviceOpHandler() :: fun((integer(), cstate()) -> cstate()). > Sure I can write the type out in full for okHandler. But I actually have a number of these and it seems wrong to write out the type in full for each of them. -- Anthony Shipman Mamas don't let your babies als@REDACTED grow up to be outsourced. From bjourne@REDACTED Thu Oct 30 15:14:42 2008 From: bjourne@REDACTED (=?ISO-8859-1?Q?BJ=F6rn_Lindqvist?=) Date: Thu, 30 Oct 2008 15:14:42 +0100 Subject: [erlang-questions] Extracting capture group names from regular expressions In-Reply-To: References: <6672d0160810090059v56e82766h8af0f8ae46831c42@mail.gmail.com> <740c3aec0810291118ncae988i315c1eb16ae48962@mail.gmail.com> Message-ID: <740c3aec0810300714o73aba478t4474feb1a6d7ebe5@mail.gmail.com> 2008/10/29 Kenneth Lundin : > Hi, > >> Yes please! There is no support for anonymous groups either which is >> an even bigger omission. > > There is certainly support for anonymous groups in the 're' module > which we are talking about here. > In the old regexp module there is no support for groups. Sure, but this is what the module doc says: "This is an experimental module and the interface is subject to change. The purpose is to be a reference implementation of what's described in the EEP "Built in regular expressions in Erlang", available at www.erlang.org for review. No production code should be based on this module until the draft is accepted and the module corrected accordingly." I.e. fire and brimstone on anyone trying to use it. -- mvh Bj?rn From masse@REDACTED Thu Oct 30 15:29:23 2008 From: masse@REDACTED (mats cronqvist) Date: Thu, 30 Oct 2008 15:29:23 +0100 Subject: [erlang-questions] Pattern-matching function? In-Reply-To: <3dbc6d1c0810291319u2a84bc8bjbc212b4efee0a863@mail.gmail.com> (Robert Virding's message of "Wed\, 29 Oct 2008 21\:19\:40 +0100") References: <20081029140008.219340@gmx.net> <49087238.3030904@it.uu.se> <8ca3fbe80810290818o5447de7ct8a13305fffe6583a@mail.gmail.com> <3dbc6d1c0810291319u2a84bc8bjbc212b4efee0a863@mail.gmail.com> Message-ID: <87wsfq6trw.fsf@dixie.cronqvi.st> "Robert Virding" writes: > One solution is to use macros as a wrapper around a fun. Some people, when confronted with a problem, think "I know, I'll use a macro." Now they have two problems. with apologies to jwz. mats p.s. unless you're coding in lisp, of course. From kenneth.lundin@REDACTED Thu Oct 30 15:38:13 2008 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Thu, 30 Oct 2008 15:38:13 +0100 Subject: [erlang-questions] Extracting capture group names from regular expressions In-Reply-To: <740c3aec0810300714o73aba478t4474feb1a6d7ebe5@mail.gmail.com> References: <6672d0160810090059v56e82766h8af0f8ae46831c42@mail.gmail.com> <740c3aec0810291118ncae988i315c1eb16ae48962@mail.gmail.com> <740c3aec0810300714o73aba478t4474feb1a6d7ebe5@mail.gmail.com> Message-ID: >> >> There is certainly support for anonymous groups in the 're' module >> which we are talking about here. >> In the old regexp module there is no support for groups. > > Sure, but this is what the module doc says: > > "This is an experimental module and the interface is subject to > change. The purpose is to be a reference implementation of what's > described in the EEP "Built in regular expressions in Erlang", > available at www.erlang.org for review. No production code should be > based on this module until the draft is accepted and the module > corrected accordingly." The experimental notice in the documentation is there because we have not frozen the API yet. But I know for sure that this is the implementation it will be and the type of regular expressions it supports will be the same as it is today. I see no problem with using the re module even in production code as long as you are prepared to change your code if we change the API. I can also say for sure that you will not get any more functionality in the old regexp module at least not from us. /Kenneth Erlang/OTP, Ericsson From rvirding@REDACTED Thu Oct 30 16:17:58 2008 From: rvirding@REDACTED (Robert Virding) Date: Thu, 30 Oct 2008 16:17:58 +0100 Subject: [erlang-questions] Pattern-matching function? In-Reply-To: <87wsfq6trw.fsf@dixie.cronqvi.st> References: <20081029140008.219340@gmx.net> <49087238.3030904@it.uu.se> <8ca3fbe80810290818o5447de7ct8a13305fffe6583a@mail.gmail.com> <3dbc6d1c0810291319u2a84bc8bjbc212b4efee0a863@mail.gmail.com> <87wsfq6trw.fsf@dixie.cronqvi.st> Message-ID: <3dbc6d1c0810300817u429f4865kbe099131d8fd4ed7@mail.gmail.com> Well of course I would use LFE, but otherwise I agree. :-) And define a macro defining macro. Seriously though, using macros or parse_transforms is the only way to get around the problem of not having patterns or variables as real "things". Robert 2008/10/30 mats cronqvist > "Robert Virding" writes: > > > One solution is to use macros as a wrapper around a fun. > > Some people, when confronted with a problem, think > "I know, I'll use a macro." > Now they have two problems. > > with apologies to jwz. > > mats > > p.s. unless you're coding in lisp, of course. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rvirding@REDACTED Thu Oct 30 16:20:08 2008 From: rvirding@REDACTED (Robert Virding) Date: Thu, 30 Oct 2008 16:20:08 +0100 Subject: [erlang-questions] Pattern-matching function? In-Reply-To: <490970A5.9020207@it.uu.se> References: <20081029140008.219340@gmx.net> <49087238.3030904@it.uu.se> <20081029182645.219350@gmx.net> <490970A5.9020207@it.uu.se> Message-ID: <3dbc6d1c0810300820t182540c4w46b9ad6cf07ccf1a@mail.gmail.com> 2008/10/30 Richard Carlsson > Francois De Serres wrote: > > Thank you Richard. > > Any way to overcome this with parsing/binding/eval magic, even cumbersome > ? > > But doing compilation on the fly might not be suitable if you are going > to do it a million times (unless you can reuse the same module name, you > will have to generate unique module names for each new compilation, and > who will then be responsible for deleting unused modules?). If the code > you are going to run is short and not a bottleneck, it could be better > to use erl_eval, for example like this: > > make_match_fun(Pstr) -> element(2, erl_eval:expr(hd(element(2, > erl_parse:parse_exprs(element(2, > erl_scan:string(lists:flatten(io_lib:format("fun (~s=__P) -> > {matched,__P}; (_) -> fail end.", [Pstr]))))))), erl_eval:new_bindings())). > > This will, via erl_eval, produce a fun that can be used like you wanted: > > F = make_match_fun("{X,Y}") > > F({1,2}) ==> {matched, {1,2}} > > F({}) ==> fail My macro basically does this is easier, at least I think so. Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: From bjourne@REDACTED Thu Oct 30 16:24:47 2008 From: bjourne@REDACTED (=?ISO-8859-1?Q?BJ=F6rn_Lindqvist?=) Date: Thu, 30 Oct 2008 16:24:47 +0100 Subject: [erlang-questions] Killing a genserver Message-ID: <740c3aec0810300824v4dbb0f09p660ef47c4f9acb2d@mail.gmail.com> Hello good people! Here is my code for killing a genserver: -module(kill). -behaviour(gen_server). -compile(export_all). -export([code_change/3, handle_call/3, handle_cast/2, handle_info/2, init/1, terminate/2]). code_change(_, _, _) -> {ok, []}. init([]) -> {ok, []}. handle_call(_, _, _) -> {reply, [], []}. handle_cast(_, _) -> {noreply, []}. handle_info(_, _) -> {noreply, []}. terminate(_, _) -> ok. start_stop(_) -> {ok, Pid} = gen_server:start({local, kill}, kill, [], []), MRef = erlang:monitor(process, Pid), true = exit(Pid, kill), receive {'DOWN', MRef, process, Pid, killed} -> ok end, erlang:demonitor(MRef). test_start_and_stop() -> lists:foreach(fun start_stop/1, lists:seq(1, 10000)). I wonder if this is a good way of doing it? What I want is to send the exit signal to the process and then wait until the process has actually died. And this is the best way I've found. But it seem complicated, is there no shorter way? -- mvh Bj?rn From masse@REDACTED Thu Oct 30 16:42:56 2008 From: masse@REDACTED (mats cronqvist) Date: Thu, 30 Oct 2008 16:42:56 +0100 Subject: [erlang-questions] openpoker crashes erlang on solaris In-Reply-To: (Joel Reymont's message of "Thu\, 30 Oct 2008 11\:38\:46 +0000") References: Message-ID: <878ws66qdb.fsf@dixie.cronqvi.st> Joel Reymont writes: > Solaris x86 5.11. > > Erlang (BEAM) emulator version 5.6.4 [source] [async-threads:0] [hipe] > [kernel-poll:false] > > How do I troubleshoot this? ... > ./poker: line 4: 22720 Segmentation Fault (core dumped) erl +K > true +P 134217727 -sname 1 -s mnesia start $* iirc; gdb /beam /core or use ddd as a front end to gdb. it was a long time since i did tht kind of stuff though. mats From colm.dougan@REDACTED Thu Oct 30 16:44:39 2008 From: colm.dougan@REDACTED (Colm Dougan) Date: Thu, 30 Oct 2008 15:44:39 +0000 Subject: [erlang-questions] Setting socket buffers on SSL sockets Message-ID: <24d4f39c0810300844x1b155307wd216e5ff613f3286@mail.gmail.com> Hi, Is there any technical reason that socket buffers can't be set on SSL sockets or is it just that it hasn't been implemented yet? Thanks, Colm From lemenkov@REDACTED Thu Oct 30 16:56:45 2008 From: lemenkov@REDACTED (Peter Lemenkov) Date: Thu, 30 Oct 2008 18:56:45 +0300 Subject: [erlang-questions] Killing a genserver In-Reply-To: <740c3aec0810300824v4dbb0f09p660ef47c4f9acb2d@mail.gmail.com> References: <740c3aec0810300824v4dbb0f09p660ef47c4f9acb2d@mail.gmail.com> Message-ID: 2008/10/30 BJ?rn Lindqvist : > Hello good people! > > Here is my code for killing a genserver: > > -module(kill). > -behaviour(gen_server). > -compile(export_all). > > -export([code_change/3, > handle_call/3, > handle_cast/2, > handle_info/2, > init/1, > terminate/2]). > > code_change(_, _, _) -> > {ok, []}. > > init([]) -> > {ok, []}. > > handle_call(_, _, _) -> > {reply, [], []}. > > handle_cast(_, _) -> > {noreply, []}. > > handle_info(_, _) -> > {noreply, []}. > > terminate(_, _) -> > ok. > > start_stop(_) -> > {ok, Pid} = gen_server:start({local, kill}, kill, [], []), > MRef = erlang:monitor(process, Pid), > true = exit(Pid, kill), > receive > {'DOWN', MRef, process, Pid, killed} -> > ok > end, > erlang:demonitor(MRef). > > test_start_and_stop() -> > lists:foreach(fun start_stop/1, lists:seq(1, 10000)). > > I wonder if this is a good way of doing it? What I want is to send the > exit signal to the process and then wait until the process has > actually died. And this is the best way I've found. But it seem > complicated, is there no shorter way? Better way is to define function: handle_cast(stop, State) -> {stop, {reason, "Just received stop message"}, State}. and send a proper message to server: gen_server:cast({local,kil}, stop). -- With best regards! From masse@REDACTED Thu Oct 30 16:56:55 2008 From: masse@REDACTED (mats cronqvist) Date: Thu, 30 Oct 2008 16:56:55 +0100 Subject: [erlang-questions] Problems with sending UDP datagrams without buffering In-Reply-To: <20081029205231.GA9074@contorpis.lisalinda.com> (Matthias Lang's message of "Wed\, 29 Oct 2008 21\:52\:31 +0100") References: <4907A8A1.2090701@echostar.com> <49085FDA.7000306@softjar.se> <20081029134411.GB4461@contorpis.lisalinda.com> <49086B88.8040303@softjar.se> <490873BA.6030506@echostar.com> <20081029205231.GA9074@contorpis.lisalinda.com> Message-ID: <873aie6pq0.fsf@dixie.cronqvi.st> Matthias Lang writes: > On Wednesday, October 29, Mark Geib wrote: > >> Yes, I am using UDP, not TCP. And to confirm, I am sending 700 bytes, >> never any more. I see the 7000 byte datagram in WireShark on another >> system monitoring the network. The 7000 bytes are reported as fragmented >> packets that have been re-assembled. I am an sending the 700 bytes every >> 20 miliseconds. > >> I am assuming that erlang is buffering in a lower layer, but could be >> the linux network stack as well. > > If either of those two assumptions were true, then erlang (or linux) > would break pretty much every UDP protocol there was. Everyone with > a SIP stack would be screaming blue murder. They're not, so those > assumptions look unlikely. possibly relevant? from the inet:setopts doc; {delay_send, Boolean} Normally, when an Erlang process sends to a socket, the driver will try to immediately send the data. If that fails, the driver will use any means available to queue up the message to be sent whenever the operating system says it can handle it. Setting {delay_send, true} will make all messages queue up. This makes the messages actually sent onto the network be larger but fewer. The option actually affects the scheduling of send requests versus Erlang processes instead of changing any real property of the socket. Needless to say it is an implementation specific option. Default is false. mats From richardc@REDACTED Thu Oct 30 17:05:15 2008 From: richardc@REDACTED (Richard Carlsson) Date: Thu, 30 Oct 2008 17:05:15 +0100 Subject: [erlang-questions] Pattern-matching function? In-Reply-To: <3dbc6d1c0810300820t182540c4w46b9ad6cf07ccf1a@mail.gmail.com> References: <20081029140008.219340@gmx.net> <49087238.3030904@it.uu.se> <20081029182645.219350@gmx.net> <490970A5.9020207@it.uu.se> <3dbc6d1c0810300820t182540c4w46b9ad6cf07ccf1a@mail.gmail.com> Message-ID: <4909DB3B.3010107@it.uu.se> Robert Virding wrote: > 2008/10/30 Richard Carlsson > > > make_match_fun(Pstr) -> element(2, erl_eval:expr(hd(element(2, > erl_parse:parse_exprs(element(2, > erl_scan:string(lists:flatten(io_lib:format("fun (~s=__P) -> > {matched,__P}; (_) -> fail end.", [Pstr]))))))), > erl_eval:new_bindings())). > > This will, via erl_eval, produce a fun that can be used like you wanted: > > F = make_match_fun("{X,Y}") > > F({1,2}) ==> {matched, {1,2}} > > F({}) ==> fail > > > My macro basically does this is easier, at least I think so. Not quite. With your suggestion, he could still only use a fixed number of patterns, known at compile time. But it sounded like he wanted to generate patterns somehow on the fly, in which case he'd need to do either dynamic compilation or interpretation. /Richard From bjourne@REDACTED Thu Oct 30 17:05:46 2008 From: bjourne@REDACTED (=?ISO-8859-1?Q?BJ=F6rn_Lindqvist?=) Date: Thu, 30 Oct 2008 17:05:46 +0100 Subject: [erlang-questions] Killing a genserver In-Reply-To: References: <740c3aec0810300824v4dbb0f09p660ef47c4f9acb2d@mail.gmail.com> Message-ID: <740c3aec0810300905s432ead62o6976247fc1e7e7cb@mail.gmail.com> 2008/10/30 Peter Lemenkov : > Better way is to define function: > > handle_cast(stop, State) -> > {stop, {reason, "Just received stop message"}, State}. > > and send a proper message to server: > > gen_server:cast({local,kil}, stop). That requires a cooperative genserver which I can't guarantee. -- mvh Bj?rn From joelr1@REDACTED Thu Oct 30 17:14:11 2008 From: joelr1@REDACTED (Joel Reymont) Date: Thu, 30 Oct 2008 16:14:11 +0000 Subject: [erlang-questions] openpoker crashes erlang on solaris In-Reply-To: <878ws66qdb.fsf@dixie.cronqvi.st> References: <878ws66qdb.fsf@dixie.cronqvi.st> Message-ID: <11DCC2C3-7553-4EEA-895B-BA4AC342DE45@gmail.com> On Oct 30, 2008, at 3:42 PM, mats cronqvist wrote: > gdb /beam /core It looks like an out of memory error. #0 0x080f5270 in loaded (to=3, to_arg=0x0) at beam/break.c:467 #1 0x080f5768 in erl_crash_dump_v (file=0x0, line=135827668, fmt=0x3
, args=0x8092777 "\203?\020?\227???x???\220\213\035\224?\034\b?\001? \r") at beam/break.c:712 #2 0x08092777 in erl_exit (n=1, fmt=0x81890d4 "%s: Cannot %s %lu bytes of memory (of type \"%s\"). \n") at beam/erl_init.c:1191 #3 0x08083286 in erts_alc_fatal_error (error=1, func=185480, n=99) at beam/erl_alloc.c:1439 #4 0x080894e6 in mbc_alloc (allctr=0x81c7c80, size=185472) at beam/erl_alloc_util.c:635 #5 0x0002d480 in ?? () #6 0x00000001 in ?? () #7 0x00000011 in ?? () #8 0x00000022 in ?? () #9 0x080f9b19 in erts_garbage_collect (p=0x849ddc2, need=696597372, objv=0x80477b8, nobj=135241230) at erl_alloc.h:183 #10 0x29853b7c in ?? () #11 0x0849ddc2 in ?? () #12 0x29853b7c in ?? () #13 0x080477b8 in ?? () #14 0x080f9e0e in erts_gc_after_bif_call (p=0xfebde922, result=4269990720, regs=0x8110034, arity=135349901) at beam/erl_gc.c:324 #15 0x08110034 in process_main () at beam/beam_emu.c:3375 Previous frame inner to this frame (corrupt stack?) -- wagerlabs.com From fdeserres@REDACTED Thu Oct 30 17:25:55 2008 From: fdeserres@REDACTED (Francois De Serres) Date: Thu, 30 Oct 2008 17:25:55 +0100 Subject: [erlang-questions] solved: Pattern-matching function? In-Reply-To: <20081029140008.219340@gmx.net> References: <20081029140008.219340@gmx.net> Message-ID: <20081030162555.18000@gmx.net> I'll investigate further both of these options: A) Match Specifications with ets:match_spec_run/2 (thanks to Michael Radford): slightly awkward to use (match spec syntax), but straightforward to implement. B) ad-hoc matching functions generated with erl_eval (thanks to Richard Carlsson): metaprogramming magic, but the resulting API is lean. 8<-------- make_match_fun(Pstr) -> element(2, erl_eval:expr(hd(element(2, erl_parse:parse_exprs(element(2, erl_scan:string(lists:flatten(io_lib:format("fun (~s=__P) -> {matched,__P}; (_) -> fail end.", [Pstr]))))))), erl_eval:new_bindings())). F = make_match_fun("{X,Y}") F({1,2}) ==> {matched, {1,2}} F({}) ==> fail 8<-------- Thanks to all for your precious help, -- Fran?ois > Hi there. > > I need a function that actually does pattern matching: pm(Tuple, > Pattern)->MatchedPattern|error > > pm({a,b,c}, {a,X,Y}). > {a,b,c} > >X. > b > > pm({a,b,c}, {b,X,Y}). > {error, badmatch} > > pm({a,b,c}, {a,X}). > {error, badmatch} > etc. > > This trivial code works only with the empty tuple/pattern : > pm(T,P) -> > P = T, P. > because pattern variables (X, Y) are unbound at function call. > > I tried to find a hint in the libs with no avail. > If anyone has a lead, can you please put me on track? > > Thanks, > -- > Francois > > -- > "Feel free" - 10 GB Mailbox, 100 FreeSMS/Monat ... > Jetzt GMX TopMail testen: http://www.gmx.net/de/go/topmail > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- "Feel free" - 10 GB Mailbox, 100 FreeSMS/Monat ... Jetzt GMX TopMail testen: http://www.gmx.net/de/go/topmail -- GMX Download-Spiele: Preizsturz! Alle Puzzle-Spiele Deluxe ?ber 60% billiger. http://games.entertainment.gmx.net/de/entertainment/games/download/puzzle/index.html From aconbere@REDACTED Thu Oct 30 17:27:30 2008 From: aconbere@REDACTED (anders conbere) Date: Thu, 30 Oct 2008 09:27:30 -0700 Subject: [erlang-questions] Pattern-matching function? In-Reply-To: <3dbc6d1c0810300817u429f4865kbe099131d8fd4ed7@mail.gmail.com> References: <20081029140008.219340@gmx.net> <49087238.3030904@it.uu.se> <8ca3fbe80810290818o5447de7ct8a13305fffe6583a@mail.gmail.com> <3dbc6d1c0810291319u2a84bc8bjbc212b4efee0a863@mail.gmail.com> <87wsfq6trw.fsf@dixie.cronqvi.st> <3dbc6d1c0810300817u429f4865kbe099131d8fd4ed7@mail.gmail.com> Message-ID: <8ca3fbe80810300927o51c52aav18bcc0c91e78eda3@mail.gmail.com> On Thu, Oct 30, 2008 at 8:17 AM, Robert Virding wrote: > Well of course I would use LFE, but otherwise I agree. :-) And define a > macro defining macro. > > Seriously though, using macros or parse_transforms is the only way to get > around the problem of not having patterns or variables as real "things". To illuminate a bit, I'm writing a mochiweb app and hating life because I haven't found a good way to reduce the amount of noise created by the gargantuan case statement created by splitting up the url. When writing web applications like this in python, there are often some nice tools provided to at least make the matching list of routes more readable (see, routes, django urls, werkzeug etc.). Many of these actually use regexes or a matching techniques that I could also use in erlang, it just feels like a shame that matches aren't more readily available as first class citizens. That being said, parse_transforms are what I've been looking at, but finding very little in the way of helpful examples :( ~ Anders > > Robert > > 2008/10/30 mats cronqvist >> >> "Robert Virding" writes: >> >> > One solution is to use macros as a wrapper around a fun. >> >> Some people, when confronted with a problem, think >> "I know, I'll use a macro." >> Now they have two problems. >> >> with apologies to jwz. >> >> mats >> >> p.s. unless you're coding in lisp, of course. > > From chandrashekhar.mullaparthi@REDACTED Thu Oct 30 17:57:46 2008 From: chandrashekhar.mullaparthi@REDACTED (Chandru) Date: Thu, 30 Oct 2008 16:57:46 +0000 Subject: [erlang-questions] inets http client In-Reply-To: <4909A17A.1070206@gmail.com> References: <4909A17A.1070206@gmail.com> Message-ID: 2008/10/30 Serge Aleynikov > Is there a way in http:request/4 call to limit the number of bytes > returned without waiting for the full content? I have a URL to query > frequently where the most relevant information is in the beginning of > the page and the tail of the document is useless but large. > > There is {full_result, boolean()} option (that doesn't seem to be > documented well, so I am unclear what it does) but I don't see how to > limit the number of bytes to be received. > > I don't have an answer to your question, but if your server supports it, you could probably use the Range header in the request to specify which bytes of the response you want. See section 14.35 in http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html cheers Chandru -------------- next part -------------- An HTML attachment was scrubbed... URL: From vychodil.hynek@REDACTED Thu Oct 30 18:41:34 2008 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Thu, 30 Oct 2008 18:41:34 +0100 Subject: [erlang-questions] solved: Pattern-matching function? In-Reply-To: <20081030162555.18000@gmx.net> References: <20081029140008.219340@gmx.net> <20081030162555.18000@gmx.net> Message-ID: <20081030174135.5BE1824063@relay.gooddata.com> On Thu, Oct 30, 2008 at 5:25 PM, Francois De Serres wrote: > I'll investigate further both of these options: > > A) Match Specifications with ets:match_spec_run/2 (thanks to Michael > Radford): > slightly awkward to use (match spec syntax), but straightforward to > implement. > > > B) ad-hoc matching functions generated with erl_eval (thanks to Richard > Carlsson): > metaprogramming magic, but the resulting API is lean. > 8<-------- > make_match_fun(Pstr) -> element(2, erl_eval:expr(hd(element(2, > erl_parse:parse_exprs(element(2, > erl_scan:string(lists:flatten(io_lib:format("fun (~s=__P) -> > {matched,__P}; (_) -> fail end.", [Pstr]))))))), erl_eval:new_bindings())). > F = make_match_fun("{X,Y}") > F({1,2}) ==> {matched, {1,2}} > F({}) ==> fail > 8<-------- > > Thanks to all for your precious help, > -- > Fran?ois > > One of most important thing in Erlang is reliability and readability which goes in Erlang together. Compare this code and yours: make_match_fun(Pstr) -> FStr = lists:flatten(io_lib:format( "fun (~s=__P) -> {matched,__P}; (_) -> fail end.", [Pstr] )), {ok, Tokens, _Line} = erl_scan:string(FStr), {ok, [Expr]} = erl_parse:parse_exprs(Tokens), {value, Fun, _} = erl_eval:expr(Expr, erl_eval:new_bindings()), Fun. Difference is not only you can see what is going on, but if any fail, you get valuable error message. It fails fast and as result code is more reliable. > > Hi there. > > > > I need a function that actually does pattern matching: pm(Tuple, > > Pattern)->MatchedPattern|error > > > pm({a,b,c}, {a,X,Y}). > > {a,b,c} > > >X. > > b > > > pm({a,b,c}, {b,X,Y}). > > {error, badmatch} > > > pm({a,b,c}, {a,X}). > > {error, badmatch} > > etc. > > > > This trivial code works only with the empty tuple/pattern : > > pm(T,P) -> > > P = T, P. > > because pattern variables (X, Y) are unbound at function call. > > > > I tried to find a hint in the libs with no avail. > > If anyone has a lead, can you please put me on track? > > > > Thanks, > > -- > > Francois > > > > -- > > "Feel free" - 10 GB Mailbox, 100 FreeSMS/Monat ... > > Jetzt GMX TopMail testen: http://www.gmx.net/de/go/topmail > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > -- > "Feel free" - 10 GB Mailbox, 100 FreeSMS/Monat ... > Jetzt GMX TopMail testen: http://www.gmx.net/de/go/topmail > > -- > GMX Download-Spiele: Preizsturz! Alle Puzzle-Spiele Deluxe ?ber 60% > billiger. > > http://games.entertainment.gmx.net/de/entertainment/games/download/puzzle/index.html > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- --Hynek (Pichi) Vychodil -------------- next part -------------- An HTML attachment was scrubbed... URL: From matthias@REDACTED Thu Oct 30 19:51:10 2008 From: matthias@REDACTED (Matthias Lang) Date: Thu, 30 Oct 2008 19:51:10 +0100 Subject: [erlang-questions] Problems with sending UDP datagrams without buffering In-Reply-To: <873aie6pq0.fsf@dixie.cronqvi.st> References: <4907A8A1.2090701@echostar.com> <49085FDA.7000306@softjar.se> <20081029134411.GB4461@contorpis.lisalinda.com> <49086B88.8040303@softjar.se> <490873BA.6030506@echostar.com> <20081029205231.GA9074@contorpis.lisalinda.com> <873aie6pq0.fsf@dixie.cronqvi.st> Message-ID: <20081030185110.GA15771@contorpis.lisalinda.com> On Thursday, October 30, mats cronqvist wrote: > possibly relevant? from the inet:setopts doc; > > {delay_send, Boolean} No, for several reasons. Firstly, the original poster didn't say anything about using nondefault options, and nobody would ever be so careless as to post a bug report without fully disclosing what they're doing. Secondly, if this option does anything at all for UDP, it still shouldn't merge successive UDP datagrams. But, let's look at the source: inet:setopts(S, [{delay_send, true}]) calls prim_inet:setopts(S, [{delay_send, true}] calls ctl_cmd(S, ?INET_REQ_SETOPTS, encode_opt_val([{delay_send, true})) encode_opt_value() takes a bit of unravelling, but it eventually encodes delay_send as ?INET_LOPT_TCP_DELAY_SEND. Note the "TCP" in there. Finally ctl_cmd calls erlang:port_control(S, ?INET_REQ_SETOPTS, [?INET_LOPT_TCP_DELAY_SEND, ...]) At that point, we need to go and look at the TCP driver, inet_drv.c. And there we find this code: case INET_LOPT_TCP_DELAY_SEND: if (desc->stype == SOCK_STREAM) { tcp_descriptor* tdesc = (tcp_descriptor*) desc; if (ival) tdesc->tcp_add_flags |= TCP_ADDF_DELAY_SEND; else tdesc->tcp_add_flags &= ~TCP_ADDF_DELAY_SEND; } continue; For a UDP socket, the desc->stype is SOCK_DGRAM, so this does nothing. Conclusion: {delay_send, true} is a no-op for UDP sockets and thus not relevant to the original poster's question. Since both you and Johnny had doubts about this, I'd like to second Johnny's suggestion of making the man page dispel that possibility. I've appended a suggested new version below. Matthias ---------------------------------------------------------------------- {delay_send, Boolean} Default is false. Does not apply to UDP sockets. Corresponds to the tcp(7) TCP_NODELAY option. Normally, when an Erlang process sends to a socket, the driver will try to immediately send the data. If that fails, the driver will use any means available to queue up the message to be sent whenever the operating system says it can handle it. Setting {delay_send, true} will make all messages queue up. This makes the messages actually sent onto the network be larger but fewer. The option actually affects the scheduling of send requests versus Erlang processes instead of changing any real property of the socket. This is an implementation specific option. From matthias@REDACTED Thu Oct 30 20:11:58 2008 From: matthias@REDACTED (Matthias Lang) Date: Thu, 30 Oct 2008 20:11:58 +0100 Subject: [erlang-questions] Problems with sending UDP datagrams without buffering In-Reply-To: <20081030185110.GA15771@contorpis.lisalinda.com> References: <4907A8A1.2090701@echostar.com> <49085FDA.7000306@softjar.se> <20081029134411.GB4461@contorpis.lisalinda.com> <49086B88.8040303@softjar.se> <490873BA.6030506@echostar.com> <20081029205231.GA9074@contorpis.lisalinda.com> <873aie6pq0.fsf@dixie.cronqvi.st> <20081030185110.GA15771@contorpis.lisalinda.com> Message-ID: <20081030191158.GA15996@contorpis.lisalinda.com> Correction. > {delay_send, Boolean} > > Default is false. > > Does not apply to UDP sockets. Corresponds to the tcp(7) TCP_NODELAY > option. Forget the last sentence above. Sorry about the noise. Matthias From joelr1@REDACTED Thu Oct 30 20:19:48 2008 From: joelr1@REDACTED (Joel Reymont) Date: Thu, 30 Oct 2008 19:19:48 +0000 Subject: [erlang-questions] minimizing the footprint of a running node Message-ID: <4B7174DA-7A12-472D-A39E-0E006F58E601@gmail.com> I only have 3Gb of memory in my accelerator at Joyent and I'm trying to launch 10 nodes. beam starts with RSS of about 135Mb and quickly goes to 500Mb+. How can I minimize the footprint of my running nodes? I'm starting slaves like this: common_args() -> "+K true +P 134217727 -smp disable". start_slave_node(Name, Args) -> case slave:start_link(net_adm:localhost(), Name, Args) of {ok, Node} -> timer:sleep(1000), %%mnesia:add_table_copy(schema, Node, ram_copies), rpc:call(Node, mnesia, start, []), rpc:call(Node, mnesia, change_config, [extra_db_nodes, [node()]]), timer:sleep(1000), Node; Reason -> io:format("Failed to start slave node: ~p. Retrying in 1 second.~n", [Reason]), timer:sleep(1000), start_slave_node(Name, Args) end. And here's the output from top: load averages: 1.37, 2.75, 2.53; up 0+08:07:22 19:16:41 64 processes: 63 sleeping, 1 on cpu CPU states: 95.9% idle, 0.3% user, 3.8% kernel, 0.0% iowait, 0.0% swap Memory: 32G phys mem, 3899M free mem, 76G total swap, 75G free swap PID USERNAME LWP PRI NICE SIZE RES STATE TIME CPU COMMAND 7710 admin 3 1 0 551M 536M sleep 0:01 0.04% beam 7746 admin 1 59 0 5004K 2052K cpu/5 0:00 0.01% top 7578 postfix 1 59 0 6728K 4624K sleep 0:00 0.00% smtpd 7695 admin 3 1 0 547M 534M sleep 0:01 0.00% beam 7665 admin 3 14 0 547M 2572K sleep 0:02 0.00% beam 7638 admin 3 1 0 547M 329M sleep 0:01 0.00% beam 7740 admin 3 1 0 551M 537M sleep 0:01 0.00% beam 7607 admin 3 1 0 549M 536M sleep 0:07 0.00% beam 19718 root 13 59 0 4100K 1532K sleep 0:02 0.00% syslogd 7651 admin 3 19 0 547M 534M sleep 0:01 0.00% beam 7680 admin 3 1 0 547M 534M sleep 0:01 0.00% beam 19633 root 29 59 0 8748K 2552K sleep 0:00 0.00% nscd 7724 admin 3 1 0 551M 537M sleep 0:01 0.00% beam 19737 root 1 59 0 10M 2016K sleep 0:03 0.00% miniserv.pl 19762 root 1 57 0 2760K 1176K sleep 0:00 0.00% authdaemond Thanks, Joel -- wagerlabs.com From vinoski@REDACTED Thu Oct 30 20:28:31 2008 From: vinoski@REDACTED (Steve Vinoski) Date: Thu, 30 Oct 2008 15:28:31 -0400 Subject: [erlang-questions] Pattern-matching function? In-Reply-To: <8ca3fbe80810300927o51c52aav18bcc0c91e78eda3@mail.gmail.com> References: <20081029140008.219340@gmx.net> <49087238.3030904@it.uu.se> <8ca3fbe80810290818o5447de7ct8a13305fffe6583a@mail.gmail.com> <3dbc6d1c0810291319u2a84bc8bjbc212b4efee0a863@mail.gmail.com> <87wsfq6trw.fsf@dixie.cronqvi.st> <3dbc6d1c0810300817u429f4865kbe099131d8fd4ed7@mail.gmail.com> <8ca3fbe80810300927o51c52aav18bcc0c91e78eda3@mail.gmail.com> Message-ID: <65b2728e0810301228j17a25647h78c4f9121a1ee0ed@mail.gmail.com> On 10/30/08, anders conbere wrote: > To illuminate a bit, I'm writing a mochiweb app and hating life > because I haven't found a good way to reduce the amount of noise > created by the gargantuan case statement created by splitting up the > url. I don't use mochiweb so I can't comment on that, but with yaws I use separate functions to handle each URI as described here: In my experience breaking the handlers into different functions makes them more convenient to deal with. I'd be very surprised if you couldn't do something similar with mochiweb. (An aside: Joe Armstrong and I were wondering back at Erlang eXchange in July: maybe this is a dumb question but how do you actually pronounce "mochiweb" -- is it "mo-chee-web" or "mo-key-web" or "mock-key-web" or ...?) > When writing web applications like this in python, there are > often some nice tools provided to at least make the matching list of > routes more readable (see, routes, django urls, werkzeug etc.). Many > of these actually use regexes or a matching techniques that I could > also use in erlang, it just feels like a shame that matches aren't > more readily available as first class citizens. If you own the URIs, then you can make them as friendly as you want for the function arg matching approach described above. Some people downplay the design of URIs as being relatively unimportant, and from a client POV they're correct because a RESTful server is responsible for supplying the client with URIs embedded within hypermedia responses to drive the client through its application state, which means the client doesn't really need to care about the "shape" of the URIs. But from a server perspective, I disagree that URI design is unimportant -- if you design your URIs well, it definitely eases the difficulties of tying them to their underlying resource implementations. If you don't own the URIs, then matching can be a lot more problematic if the URIs are poorly designed. For example if they all use the same path and rely on query strings with lots of parameters for differentiation, then you're best off isolating their parsing into a function that effectively rewrites the URIs into something more friendly, and then dispatching them on that basis. I personally haven't seen any cases where I needed regexp URI matching for my RESTful web service implementations, but I acknowledge your mileage may vary. --steve From masse@REDACTED Thu Oct 30 21:11:33 2008 From: masse@REDACTED (mats cronqvist) Date: Thu, 30 Oct 2008 21:11:33 +0100 Subject: [erlang-questions] Problems with sending UDP datagrams without buffering In-Reply-To: <20081030185110.GA15771@contorpis.lisalinda.com> (Matthias Lang's message of "Thu\, 30 Oct 2008 19\:51\:10 +0100") References: <4907A8A1.2090701@echostar.com> <49085FDA.7000306@softjar.se> <20081029134411.GB4461@contorpis.lisalinda.com> <49086B88.8040303@softjar.se> <490873BA.6030506@echostar.com> <20081029205231.GA9074@contorpis.lisalinda.com> <873aie6pq0.fsf@dixie.cronqvi.st> <20081030185110.GA15771@contorpis.lisalinda.com> Message-ID: <87skqdc07e.fsf@dixie.cronqvi.st> Matthias Lang writes: > On Thursday, October 30, mats cronqvist wrote: > >> possibly relevant? from the inet:setopts doc; >> >> {delay_send, Boolean} > > No, for several reasons. Firstly, the original poster didn't say > anything about using nondefault options, and nobody would ever be so > careless as to post a bug report without fully disclosing what they're > doing. yes, my bad. never again shall i try to read between the lines of a bug report. > Secondly, if this option does anything at all for UDP, it still > shouldn't merge successive UDP datagrams. No. I guess it was this bit that meda me a bit suspicious; "This makes the messages actually sent onto the network be larger but fewer." > But, let's look at the source: i am of course way to lazy for that. i'll just take your word for it. mats From aconbere@REDACTED Thu Oct 30 21:16:40 2008 From: aconbere@REDACTED (anders conbere) Date: Thu, 30 Oct 2008 13:16:40 -0700 Subject: [erlang-questions] Pattern-matching function? In-Reply-To: <65b2728e0810301228j17a25647h78c4f9121a1ee0ed@mail.gmail.com> References: <20081029140008.219340@gmx.net> <49087238.3030904@it.uu.se> <8ca3fbe80810290818o5447de7ct8a13305fffe6583a@mail.gmail.com> <3dbc6d1c0810291319u2a84bc8bjbc212b4efee0a863@mail.gmail.com> <87wsfq6trw.fsf@dixie.cronqvi.st> <3dbc6d1c0810300817u429f4865kbe099131d8fd4ed7@mail.gmail.com> <8ca3fbe80810300927o51c52aav18bcc0c91e78eda3@mail.gmail.com> <65b2728e0810301228j17a25647h78c4f9121a1ee0ed@mail.gmail.com> Message-ID: <8ca3fbe80810301316k4e5d1009xf854a66c53c27008@mail.gmail.com> On Thu, Oct 30, 2008 at 12:28 PM, Steve Vinoski wrote: > On 10/30/08, anders conbere wrote: >> To illuminate a bit, I'm writing a mochiweb app and hating life >> because I haven't found a good way to reduce the amount of noise >> created by the gargantuan case statement created by splitting up the >> url. > > I don't use mochiweb so I can't comment on that, but with yaws I use > separate functions to handle each URI as described here: > > > > In my experience breaking the handlers into different functions makes > them more convenient to deal with. I'd be very surprised if you > couldn't do something similar with mochiweb. > > (An aside: Joe Armstrong and I were wondering back at Erlang eXchange > in July: maybe this is a dumb question but how do you actually > pronounce "mochiweb" -- is it "mo-chee-web" or "mo-key-web" or > "mock-key-web" or ...?) > >> When writing web applications like this in python, there are >> often some nice tools provided to at least make the matching list of >> routes more readable (see, routes, django urls, werkzeug etc.). Many >> of these actually use regexes or a matching techniques that I could >> also use in erlang, it just feels like a shame that matches aren't >> more readily available as first class citizens. > > If you own the URIs, then you can make them as friendly as you want > for the function arg matching approach described above. Some people > downplay the design of URIs as being relatively unimportant, and from > a client POV they're correct because a RESTful server is responsible > for supplying the client with URIs embedded within hypermedia > responses to drive the client through its application state, which > means the client doesn't really need to care about the "shape" of the > URIs. But from a server perspective, I disagree that URI design is > unimportant -- if you design your URIs well, it definitely eases the > difficulties of tying them to their underlying resource > implementations. > > If you don't own the URIs, then matching can be a lot more problematic > if the URIs are poorly designed. For example if they all use the same > path and rely on query strings with lots of parameters for > differentiation, then you're best off isolating their parsing into a > function that effectively rewrites the URIs into something more > friendly, and then dispatching them on that basis. > > I personally haven't seen any cases where I needed regexp URI matching > for my RESTful web service implementations, but I acknowledge your > mileage may vary. Oh absolutely. The pattern isn't bad at all I do something very similar in mochiweb (MOE-CHEE-WEB) loop(Req) -> Resp = case string:tokens(Req:get(path), "/") of [] -> % GET roto_web_views:version(Req); ["version"] -> % GET roto_web_views:version(Req); ["register"] -> % POST roto_web_views:register(Req); ["nodes"] -> % GET roto_web_views:get_nodes(Req); ["nodes", NodeName] -> % GET DELETE roto_web_views:nodes(Req, NodeName); ["nodes", NodeName, "queues"] -> % GET POST roto_web_views:queues(Req, NodeName); ["nodes", NodeName, "messages"] -> % GET POST roto_web_views:messages(Req, NodeName); _ -> {404, [], "{'error': 404, 'msg': \"Path not found\""} end, Req:respond(Resp), ok. That being said I would love to be able to do URLS = [{module, roto_web_view} {[], version}, {["version"], version}, {["register"], register}, {["nodes"], get_nodes}, {["nodes", NodeName], nodes}; {["nodes", NodeName, "queues"], queues}; {["nodes", NodeName, "messages"], messages}; ], where each function get's passed the Request and any matches in the order they were specified. ~ Anders > > --steve > From fredrikelinder@REDACTED Thu Oct 30 21:19:36 2008 From: fredrikelinder@REDACTED (Fredrik Linder) Date: Thu, 30 Oct 2008 21:19:36 +0100 Subject: [erlang-questions] Pattern-matching function? In-Reply-To: <490970A5.9020207@it.uu.se> References: <20081029140008.219340@gmx.net> <49087238.3030904@it.uu.se> <20081029182645.219350@gmx.net> <490970A5.9020207@it.uu.se> Message-ID: <3b513c8d0810301319y7fcb9928u658a60efffc265fb@mail.gmail.com> Hi Richard Could you give a code example of the second alternativ please? This question is not related to first class pattern matching, I use alternative 1 to generate mocks but would rather use alternative 2 as my mocks does not need the preprocessor. Thank you /Fredrik On Thu, Oct 30, 2008 at 9:30 AM, Richard Carlsson wrote: > Francois De Serres wrote: > > Thank you Richard. > > Any way to overcome this with parsing/binding/eval magic, even cumbersome > ? > > Depending on what you need, in terms of efficiency (is the code going to > be a bottleneck, or just executed occasionally?), and if you really need > to do metaprogramming (often a big *if*), there are several options: > > - Output the code as plain text to a .erl-file and call the compiler. > (Dead simple, and quite flexible - can use macros and includes for > "template" stuff so you don't need to generate that as well.) > > - Generate the code as text in memory, call the scanner and parser, and > pass the result to compile:forms/2. You can't use the preprocessor > this way (it only works on files), but you don't have to go to disk, > and you don't need to learn about the syntax tree representation. > > - Generate the syntax trees directly and pass to the compiler. Fiddly, > unreadable and hard to maintain, but low-overhead and full control. > > But doing compilation on the fly might not be suitable if you are going > to do it a million times (unless you can reuse the same module name, you > will have to generate unique module names for each new compilation, and > who will then be responsible for deleting unused modules?). If the code > you are going to run is short and not a bottleneck, it could be better > to use erl_eval, for example like this: > > make_match_fun(Pstr) -> element(2, erl_eval:expr(hd(element(2, > erl_parse:parse_exprs(element(2, > erl_scan:string(lists:flatten(io_lib:format("fun (~s=__P) -> > {matched,__P}; (_) -> fail end.", [Pstr]))))))), erl_eval:new_bindings())). > > This will, via erl_eval, produce a fun that can be used like you wanted: > > F = make_match_fun("{X,Y}") > > F({1,2}) ==> {matched, {1,2}} > > F({}) ==> fail > > /Richard > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kenneth.lundin@REDACTED Thu Oct 30 21:20:52 2008 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Thu, 30 Oct 2008 21:20:52 +0100 Subject: [erlang-questions] minimizing the footprint of a running node In-Reply-To: <4B7174DA-7A12-472D-A39E-0E006F58E601@gmail.com> References: <4B7174DA-7A12-472D-A39E-0E006F58E601@gmail.com> Message-ID: On Thu, Oct 30, 2008 at 8:19 PM, Joel Reymont wrote: > I only have 3Gb of memory in my accelerator at Joyent and I'm trying > to launch 10 nodes. beam starts with RSS of about 135Mb and quickly > goes to 500Mb+. > > How can I minimize the footprint of my running nodes? > > I'm starting slaves like this: > > common_args() -> > "+K true +P 134217727 -smp disable". > You will lower the memory footprint significantly by removing +P option or using a much lower value for it (the number of simultaneously existing processes that the system can handle). I am pretty sure you don't need the maximum value there, you will run out of memory in one node before you reach 134 millions of processes and I am pretty sure that your system will not handle millions of simultaneous poker players (in one Erlang-node) The value +P 134217727 will result in a memory requirement of 4 times 134217727 bytes = 536870908 bytes = 536 Mbytes for the Erlang node just to hold the process-table. /Kenneth Erlang/OTP, Ericsson > start_slave_node(Name, Args) -> > case slave:start_link(net_adm:localhost(), Name, Args) of > {ok, Node} -> > timer:sleep(1000), > %%mnesia:add_table_copy(schema, Node, ram_copies), > rpc:call(Node, mnesia, start, []), > rpc:call(Node, mnesia, change_config, [extra_db_nodes, > [node()]]), > timer:sleep(1000), > Node; > Reason -> > io:format("Failed to start slave node: ~p. Retrying in 1 > second.~n", > [Reason]), > timer:sleep(1000), > start_slave_node(Name, Args) > end. > > And here's the output from top: > > load averages: 1.37, 2.75, 2.53; up 0+08:07:22 > 19:16:41 > 64 processes: 63 sleeping, 1 on cpu > CPU states: 95.9% idle, 0.3% user, 3.8% kernel, 0.0% iowait, 0.0% > swap > Memory: 32G phys mem, 3899M free mem, 76G total swap, 75G free swap > > PID USERNAME LWP PRI NICE SIZE RES STATE TIME CPU COMMAND > 7710 admin 3 1 0 551M 536M sleep 0:01 0.04% beam > 7746 admin 1 59 0 5004K 2052K cpu/5 0:00 0.01% top > 7578 postfix 1 59 0 6728K 4624K sleep 0:00 0.00% smtpd > 7695 admin 3 1 0 547M 534M sleep 0:01 0.00% beam > 7665 admin 3 14 0 547M 2572K sleep 0:02 0.00% beam > 7638 admin 3 1 0 547M 329M sleep 0:01 0.00% beam > 7740 admin 3 1 0 551M 537M sleep 0:01 0.00% beam > 7607 admin 3 1 0 549M 536M sleep 0:07 0.00% beam > 19718 root 13 59 0 4100K 1532K sleep 0:02 0.00% syslogd > 7651 admin 3 19 0 547M 534M sleep 0:01 0.00% beam > 7680 admin 3 1 0 547M 534M sleep 0:01 0.00% beam > 19633 root 29 59 0 8748K 2552K sleep 0:00 0.00% nscd > 7724 admin 3 1 0 551M 537M sleep 0:01 0.00% beam > 19737 root 1 59 0 10M 2016K sleep 0:03 0.00% > miniserv.pl > 19762 root 1 57 0 2760K 1176K sleep 0:00 0.00% > authdaemond > > Thanks, Joel > > -- > wagerlabs.com > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From joelr1@REDACTED Thu Oct 30 21:35:31 2008 From: joelr1@REDACTED (Joel Reymont) Date: Thu, 30 Oct 2008 20:35:31 +0000 Subject: [erlang-questions] minimizing the footprint of a running node In-Reply-To: References: <4B7174DA-7A12-472D-A39E-0E006F58E601@gmail.com> Message-ID: <6D3ABBF4-68D5-495A-93E5-768B942C820D@gmail.com> On Oct 30, 2008, at 8:20 PM, Kenneth Lundin wrote: > The value +P 134217727 will result in a memory requirement of 4 times > 134217727 bytes = 536870908 bytes = 536 Mbytes for the Erlang node > just to hold the process-table. That does it, thanks! I was running out of processes at some point but I use far fewer processes now. -- wagerlabs.com From ok@REDACTED Thu Oct 30 22:06:11 2008 From: ok@REDACTED (Richard O'Keefe) Date: Fri, 31 Oct 2008 10:06:11 +1300 Subject: [erlang-questions] [eeps] Request for comments on EEP-24 In-Reply-To: <200810301214.05613.bekesa@sch.bme.hu> References: <200810301214.05613.bekesa@sch.bme.hu> Message-ID: <290C1A92-FAA9-4A56-91E5-3284CD9B024C@cs.otago.ac.nz> On 31 Oct 2008, at 12:14 am, Andras Georgy Bekes wrote: > I suggested the followings: Currently no operators are allowed in > module > attributes, This isn't _quite_ true: unary + and unary - are allowed in front of numbers. > > I proposed to allow every standard operator in attributes, > and each X op Y subexpression in an attribute to be converted to > {'op',X,Y}. The question is WHY? Why do you want to be able to write now+then as well as {'+',now,then} What is the advantage of allowing expression syntax for things that are not, and certainly will not be evaluated as, expressions? The thing about F/A in (some) existing attributes is it does not mean division and never has. On the contrary, it has always been converted to {F,A} for processing by downstream tools. Changing F/A to {'/',F,A} will certainly break downstream tools. The advantage of {F,A} over {'/',F,A} is that the former is what the downstream tools are already expecting. > The -record/2 attribute has two properties that can not be done with > custom attributes: > - it has arity 2 > - it can contain "fieldname=DefaultValue" like stuff. It would have been nice if system attributes and user attributes were always distinguishable. For one thing, the last time I checked what attributes were used in an Erlang/OTP release, one of them was 'behavoiur'. Perhaps another EEP could be considered, with some kind of extended user-defined attributes beginning with a + sign, and a promise that there will never be any system-defined + attributes. We'd still have the problem of distinguishing between - this is a +attribute containing e/1 and it is supposed to refer to the local e/1 function - this is a +attribute containing e/1 but it was meant to be the expression 4/1 (4 and e being neighbours on the keyboard). > > A different solution would be not to reject it by the compiler but to > convert X = Y to {'=',X,Y}, and generalizing the idea, every X op Y > could be converted to {'op',X,Y}. This implies that F/N should be > converted to {'/',F,N}, which sounds bad, but the compiler could still > convert it to {F,N} when building the exports list for the > module_info/0,1 functions. The point is that it needs to {F,N} for things *other than* export lists. > Parse transformations are so powerful, but on the other hand are so > limited because of the parser accepts only a very limited set of > operators and only in some places... Something should be done to > improve the consistency of the language! Something along the lines of ::= '+' . might do the job. What is the problem for which you wanted custom attributes with arity higher than 1 and containing operators? From ok@REDACTED Thu Oct 30 22:21:09 2008 From: ok@REDACTED (Richard O'Keefe) Date: Fri, 31 Oct 2008 10:21:09 +1300 Subject: [erlang-questions] List to proplist? In-Reply-To: <200810301326.23513.bekesa@sch.bme.hu> References: <6c2563b20810192156i7516e69aqb4d0eda2e1ee98d9@mail.gmail.com> <1225284106.31992.26.camel@seasc0642.dyn.rnd.as.sw.ericsson.se> <8FEABB6E-34FB-4B72-8F73-9989A48C767D@cs.otago.ac.nz> <200810301326.23513.bekesa@sch.bme.hu> Message-ID: On 31 Oct 2008, at 1:26 am, Andras Georgy Bekes wrote: > Please note that I proposed an extension for list comprehensions that > does the job of unfold/2 and more. Between [E(X) || X (<-) F] and [E(X) || X <- unfold(S, F')] there is very little difference, *provided* the compiler knows about unfold and treats it specially. I've been thinking that we wouldn't really need syntax for iterating over the elements of a tuple if the compiler knew how to handle [E(X) || X <- tuple_to_list(T)]. It's a little more long-winded than [E(X) || X <-: T] but a lot more obvious. From exta7@REDACTED Thu Oct 30 22:21:43 2008 From: exta7@REDACTED (Zvi) Date: Thu, 30 Oct 2008 14:21:43 -0700 (PDT) Subject: [erlang-questions] inets http client In-Reply-To: <4909A17A.1070206@gmail.com> References: <4909A17A.1070206@gmail.com> Message-ID: <20255737.post@talk.nabble.com> Maybe, HTTP HEAD request will help you: "Asks for the response identical to the one that would correspond to a GET request, but without the response body. This is useful for retrieving meta-information written in response headers, without having to transport the entire content." zvi Serge Aleynikov-2 wrote: > > Is there a way in http:request/4 call to limit the number of bytes > returned without waiting for the full content? I have a URL to query > frequently where the most relevant information is in the beginning of > the page and the tail of the document is useless but large. > > There is {full_result, boolean()} option (that doesn't seem to be > documented well, so I am unclear what it does) but I don't see how to > limit the number of bytes to be received. > > Serge > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > -- View this message in context: http://www.nabble.com/inets-http-client-tp20245563p20255737.html Sent from the Erlang Questions mailing list archive at Nabble.com. From chris.newcombe@REDACTED Thu Oct 30 22:23:09 2008 From: chris.newcombe@REDACTED (Chris Newcombe) Date: Thu, 30 Oct 2008 14:23:09 -0700 Subject: [erlang-questions] Pattern-matching function? In-Reply-To: <490970A5.9020207@it.uu.se> References: <20081029140008.219340@gmx.net> <49087238.3030904@it.uu.se> <20081029182645.219350@gmx.net> <490970A5.9020207@it.uu.se> Message-ID: <781dd98c0810301423id43ccbu9d3fce980494a20a@mail.gmail.com> > make_match_fun(Pstr) -> element(2, erl_eval:expr(hd(element(2, > erl_parse:parse_exprs(element(2, > erl_scan:string(lists:flatten(io_lib:format("fun (~s=__P) -> > {matched,__P}; (_) -> fail end.", [Pstr]))))))), erl_eval:new_bindings())). Thanks -- that's very useful :) > - Generate the code as text in memory, call the scanner and parser, and > pass the result to compile:forms/2. You can't use the preprocessor > this way (it only works on files), but you don't have to go to disk, > and you don't need to learn about the syntax tree representation. I know that isn't a good technique for the particular problem being discussed here, but I wanted to point out that there is a useful module to do this here: http://www.erlang.org/pipermail/erlang-questions/2007-July/028023.html Mats Cronqvist wrote it, and I extended a little bit (slightly more macro support, and support for -include). Sometimes you do want to compile a new version of an existing module on the fly. e.g. I use it to generate a pattern-matching function to efficiently control dynamic debug/logging levels. (This is an enhancement of an idea from Edwin Fine -- see the end of his post http://www.erlang.org/pipermail/erlang-questions/2008-October/038674.html -- thanks Edwin :) Example code is below. (This also uses Matthias Lang's excellent and indispensable trunc_io.erl module: see http://www.erlang.org/pipermail/erlang-questions/2003-February/007571.html . That post from Matthias also discusses use of tracing to control debug/logging levels, but I prefer the following approach.) %%% File : is_debug_enabled.erl %%% %%% See also debug.hrl (for the code controlled by the function in this module) %%% %%% This module contains a single exported function which efficiently %%% controls the level of debug logging (and debug code execution) in %%% the rest of the application. %%% %%% To change the logging level we generate, compile and load a new version of this module. %%% %%% By default the only debug that is enabled is everything at level %%% ?DBG_ALWAYS. %%% %%% By 'efficient' we mean %%% %%% - each invocation of the ?DBG macro makes a single %%% fully-qualified function call to a tiny constant-time function %%% -- for/3 in this module. %%% %%% - the other arguments (logging) to ?DBG or ?DBG_CODE are %%% only evaluated if for/3 returns true (although any constants %%% in those arguments will already be compiled into the constant-table %%% for the module containing the ?DBG instance, that seems unavoidable). %%% %%% Runtime control over a global cross-module system is actually a %%% fairly difficult problem for Erlang as there are no global or %%% module-level variables. Other potential solutions include %%% %%% - 'tracing a do-nothing function' (see http://www.erlang.org/pipermail/erlang-questions/2003-February/007571.html) %%% - parameterized modules (passing the logger funs as parameters; but requires code changes) %%% - opening a port to a linked-in driver which returns the value %%% %%% We use a function call to decide if a ?DBG instance is active. %%% This allows us to change the level of debug logging/activity by %%% compiling and hot-loading a new version of the module that %%% contains the decision-function. Users simply change the %%% definition of the 'for' function, to returns true for the subset %%% of debug statements that you want to enable (and continue to %%% return false for everything else). %%% %%% It is very easy to dynamically change the code, by using %%% compile_module_from_string.erl %%% %%% Currently we can control execution of debug code by any %%% combination if level and source-code location. (Ideally we would %%% also pattern match on CurrentFunction here, but it's a bit too %%% expensive for every debug statement to call process_info(self(), %%% current_function) when deciding if it is active.) %%% %%% See debug.hrl for macros that use this. -module(is_debug_enabled). -export([for/3]). -include("debug.hrl"). % for DBG_WARN, etc %% Important: this function must ALWAYS have a final catch-all clause %% that returns false. The caller does NOT wrap the call in an %% exception handler. for(?DBG_ALWAYS, _Module, _Line) -> true; for(_, _, _) -> false. %%% File : debug.hrl %%% %%% See also module is_debug_enabled.erl %% Debug levels; numeric so that is_debug_enabled:for() can efficiently %% tell if a given level is included or excluded by a cut-off threshold. %% (we want cut-off thresholds to transitive). %% %% e.g. %% %% '(Importance, OptionalModule, _) when Importance >= ?DBG_ERROR' => 'true' %% %% will enable ?DBG() statements with levels ERROR, CRITICAL, or ALWAYS %% -define(DBG_NEVER, 00). -define(DBG_VERBOSE, 50). -define(DBG_INFO, 60). -define(DBG_WARN, 70). -define(DBG_ERROR, 80). -define(DBG_CRITICAL, 90). -define(DBG_ALWAYS, 100). -define(DBG(Importance, Term), ?DBG_MAXLEN(Importance, Term, 5000)). %% This does not bind any variables, so we don't but the body in an %% anonymous fun. -define(DBG_MAXLEN(Importance, Term, MaxLength), case is_debug_enabled:for(Importance, ?MODULE, ?LINE) of false -> ok; true -> debug:logger( "~w:~w: ~s~n", [%% This gets the {module,Name,Arity} of the current function %% (?MODULE would be faster and less verbose) element(2, process_info(self(), current_function)), ?LINE, trunc_io:safe_print(Term, MaxLength)]) end). %% In order to avoid polluting the calling function (leaving bound variables behind) %% or being polluted by the calling function (unwanted variable bindings), %% we execute the code in an anonymous fun, which is the recommended way to %% get a clean scope in Erlang. %% %% This *will* allow exceptions to escape from Code into the caller function %% that's a feature. %% -define(DBG_CODE(Importance, Code), case is_debug_enabled:for(Importance, ?MODULE, ?LINE) of false -> ok; true -> (fun() -> Code end)() end). %%% File : debug.erl %% See comments in %% %% debug.hrl %% is_debug_enabled.erl %%% -module(debug). -export([logger/2, validate_is_debug_enabled_clauses/1, set_is_debug_enabled/1, trunc_process_info_str/2, ordered_process_info/1]). -include("debug.hrl"). %% For EUnit's debugFmt macro (otherwise logging does not appear during EUnit tests) -include_lib("eunit/include/eunit.hrl"). logger(FormatStr, Args) -> case process_info(self(), registered_name) of {registered_name, ProcessName} -> ?debugFmt("~w: ~w: " ++ FormatStr, [ProcessName | [now() | Args]]); [] -> case get('$ancestors') of % proc_lib:spawn sets this undefined -> ?debugFmt("~w: ~w: " ++ FormatStr, [self() | [now() | Args]]); Ancestors -> ?debugFmt("~w (child of ~p): ~w: " ++ FormatStr, [self() | [hd(Ancestors) | [now() | Args]]]) end end. validate_is_debug_enabled_clauses(Clauses) -> %% There's not much value in being pedantic in the pattern regex, %% as it's not a proper grammar and compile_module_to_string is %% the proper test. The main purpose here is to stop arbitrary %% code being injected when we compile the new version of the %% module. (e.g. below we absolutely restrict the body of the %% clauses to returning true or false). {ok, PatternRe} = regexp:parse("^\([^,]+, *[^,]+, *[^,]+\).*$"), lists:foreach(fun({PatternStr, <<"true">>}) -> validate_clause_pattern(PatternStr, PatternRe); ({PatternStr, <<"false">>}) -> validate_clause_pattern(PatternStr, PatternRe) end, Clauses). validate_clause_pattern(PatternStr, PatternRe) -> case regexp:first_match(PatternStr, PatternRe) of {match, _, _} -> ok; Error -> throw({bad_pattern, {Error, PatternStr}}) end. set_is_debug_enabled(Clauses) -> %% This involves generating new code for is_debug_enabled.erl %% See comments in that module for details. CodeStr = lists:flatten( ["-module(is_debug_enabled).\n", "-export([for/3]).\n", "-include(\"debug.hrl\").\n", %% We don't include the ALWAYS clause as in an emergency %% we might want to remove it. %%%% "for(?DBG_ALWAYS, _Module, _Line) -> true;\n", lists:map(fun({PatternStr, ValueBin}) -> ValueStr = binary_to_list(ValueBin), io_lib:format("for~s -> ~s;\n", [PatternStr, ValueStr]) end, Clauses), %% The 'for' function must ALWAYS have a catch-all clause that returns false. "for(_, _, _) -> false.\n" ]), %% The generated module needs to include debug.hrl %% We assume it is in the same utilties' library as compile_module_from_string, %% and construct the include path from that %% First we have to ensure that the module is loaded, otherwise %% is_loaded won't be able to report it's path. (This should only %% necessary in development, as the boot script should proactively %% load all code at startup) code:ensure_loaded(compile_module_from_string), {file, AbsBeamPath} = code:is_loaded(compile_module_from_string), {LibDir, _BeamFileName} = ?GU:split_string_on_delimiter("/ebin/", AbsBeamPath), IncludePathOptions = [{i, LibDir ++ "/include"}], {is_debug_enabled, CompiledCodeBin} = compile_module_from_string:compile( CodeStr, [return_errors, return_warnings, verbose] ++ IncludePathOptions), ?DBG(?DBG_INFO, ["Successfully compiled new version of is_debug_enabled"]), %% We have to purge the 'old' version of the module, so that code:load_binary can %% move the current version to the 'old' version before it installs the new version. %% The first time through this fails with {error, not_purged} as there isn't an %% old version. So we don't check the result. code:purge(is_debug_enabled), {module, is_debug_enabled} = code:load_binary(is_debug_enabled, compiled_by__set_is_debug_enabled, % tag to identify the 'source' of the module (normal its .erl filename) CompiledCodeBin), ?DBG(?DBG_INFO, ["Successfully loaded new version of is_debug_enabled: ", CodeStr]), ok. trunc_process_info_str(Pid, MaxLen) -> trunc_io:safe_print(ordered_process_info(Pid), MaxLen). %% Note: process_info/1 is documented as 'use only for debugging'. %% A bigger issue is that the result is not ordered, but we really %% want the potentially large items (message_queue, dictionary) at the end. %% %% So we use the approved process_info(Pid, Tag) for the %% interesting tags, and put the potentially large items at the end. %% %% This also returns the gproc info for the process. %% ordered_process_info(Pid) -> %% The list of tags is from R12B-2 documentation. InfoSpec = [registered_name, % Atom is the registered name of the process. If the process has no registered name, this tuple is not present in the list. initial_call, % Module, Function, Arity is the initial function call with which the process was spawned. current_function, % Module, Function, Args is the current function call of the process. trap_exit, % status, % Status is the status of the process. Status is waiting (waiting for a message), running, runnable (ready to run, but another process is running), or suspended (suspended on a "busy" port or by the erlang:suspend_process/[1,2] BIF). memory, % Size is the size in bytes of the process. This includes call stack, heap and internal structures. stack_size, % Size is the stack size of the process in words. heap_size, % Size is the size in words of youngest heap generation of the process. This generation currently include the stack of the process. This information is highly implementation dependent, and may change if the implementation change. total_heap_size, % Size is the total size in words of all heap fragments of the process. This currently include the stack of the process. message_queue_len, % MessageQueueLen is the number of messages currently in the message queue of the process. This is the length of the list MessageQueue returned as the info item messages (see below). garbage_collection, % GCInfo is a list which contains miscellaneous information about garbage collection for this process. The content of GCInfo may be changed without prior notice. binary, % BinInfo is a list containing miscellaneous information about binaries currently being referred to by this process. This InfoTuple may be changed or removed without prior notice. %%message_binary, % BinInfo is a list containing miscellaneous information about binaries currently being referred to by the message area. This InfoTuple is only valid on an emulator using the hybrid heap type. This InfoTuple may be changed or removed without prior notice. links, % Pids is a list of pids, with processes to which the process has a link. monitored_by, % A list of pids that are monitoring the process (with erlang:monitor/2). monitors, % A list of monitors (started by erlang:monitor/2) that are active for the process. For a local process monitor or a remote process monitor by pid, the list item is {process, Pid}, and for a remote process monitor by name, the list item is {process, {RegName, Node}}. priority, % Level is the current priority level for the process. For more information on priorities see process_flag(priority, Level). reductions, % Number is the number of reductions executed by the process. group_leader, % GroupLeader is group leader for the IO of the process. %%error_handler, % Module is the error handler module used by the process (for undefined function calls, for example). %%sequential_trace_token, % SequentialTraceToken the sequential trace token for the process. This InfoTuple may be changed or removed without prior notice. suspending, % SuspendeeList is a list of {Suspendee, ActiveSuspendCount, OutstandingSuspendCount} tuples. Suspendee is the pid of a process that have been or is to be suspended by the process identified by Pid via the erlang:suspend_process/2 BIF, or the erlang:suspend_process/1 BIF. ActiveSuspendCount is the number of times the Suspendee has been suspended by Pid. OutstandingSuspendCount is the number of not yet completed suspend requests sent by Pid. That is, if ActiveSuspendCount /= 0, Suspendee is currently in the suspended state, and if OutstandingSuspendCount /= 0 the asynchronous option of erlang:suspend_process/2 has been used and the suspendee has not yet been suspended by Pid. Note that the ActiveSuspendCount and OutstandingSuspendCount are not the total suspend count on Suspendee, only the parts contributed by Pid. trace, % InternalTraceFlags is an integer representing internal trace flag for this process. This InfoTuple may be changed or removed without prior notice. %%catchlevel, % CatchLevel is the number of currently active catches in this process. This InfoTuple may be changed or removed without prior notice. %% Potentially large backtrace, % The binary Bin contains the same information as the output from erlang:process_display(Pid, backtrace). Use binary_to_list/1 to obtain the string of characters from the binary. dictionary, % Dictionary is the dictionary of the process. messages, % MessageQueue is a list of the messages to the process, which have not yet been processed. last_calls % The value is false if call saving is not active for the process (see process_flag/3). If call saving is active, a list is returned, in which the last element is the most recent called. ], ProcInfoData = process_info(Pid, InfoSpec), GProcData = case (catch gproc:info(Pid, gproc)) of {gproc, _KeysValues} = Data -> Data; _ -> failed_to_get_gproc_data end, {GProcData, ProcInfoData}. From joelr1@REDACTED Thu Oct 30 22:41:09 2008 From: joelr1@REDACTED (Joel Reymont) Date: Thu, 30 Oct 2008 21:41:09 +0000 Subject: [erlang-questions] openpoker: 25k players on a physical machine Message-ID: <071EF7A6-A22E-4A42-98EF-51084F94C651@gmail.com> I'm happy to report great results after following Kenneth's advice to reduce the size of the process table. I'm testing on a 3Gb Joyent Accelerator running Solaris 5.11. I'm launching 5000 games with 25000 players on 5 game servers and 5 bot nodes, all running on the same physical machine. I'm hitting the 65000 socket maximum so the way to scale out is by adding more physical servers to the cluster. A starter gun fires when all the players join their respective tables. All games start at the same time and players act in rapid fire, with no delay between bet request and response. Think of it as a 25000 player tournament, running full-speed! The interesting part is that poker does not consume any significant amount of CPU time so the way to scale is to run OpenPoker on a bunch of cheap machines with a decent (1-2Gb) amount of memory. (1@REDACTED)1> schema:install(). =INFO REPORT==== 30-Oct-2008::20:49:19 === application: mnesia exited: stopped type: temporary ok (1@REDACTED)2> dmb:run(5000, 5, 5, 60000). game5@REDACTED: game server on port 3001 game5@REDACTED: port server on 3001... game4@REDACTED: game server on port 3002 game4@REDACTED: port server on 3002... game3@REDACTED: game server on port 3003 game3@REDACTED: port server on 3003... game2@REDACTED: game server on port 3004 game2@REDACTED: port server on 3004... game1@REDACTED: game server on port 3005 game1@REDACTED: port server on 3005... cluster: [bot5@REDACTED,bot4@REDACTED,bot3@REDACTED,bot2@REDACTED, bot1@REDACTED,game5@REDACTED,game4@REDACTED,game3@REDACTED, game2@REDACTED,game1@REDACTED] bot launchers : [<7615.83.0>,<7614.78.0>,<7613.73.0>,<7612.68.0>,<7611.62.0>] game launchers : [<8822.485.0>,<8820.498.0>,<7610.582.0>,<7609.416.0>, <7608.252.0>] game servers : [<8822.322.0>,<8820.335.0>,<7610.419.0>,<7609.253.0>, <7608.89.0>] gateway:start('1@REDACTED', 4000, 500000) Waiting for game servers... '1@REDACTED': port server on 4000... Simulating gameplay with 5000 games... 50 games started, 262 players ... 5000 games started, 25404 players dmb: 5000 games will be launching simultaneously dmb: waiting for games to end... =INFO REPORT==== 30-Oct-2008::20:50:59 === module: stats elapsed: 60.003419 {total_bots_connected,0}: 8904 {bots_connected,0}: 8904 {games_launched,0}: 1820 =INFO REPORT==== 30-Oct-2008::20:51:59 === module: stats elapsed: 59.99997 {total_bots_connected,1}: 17961 {bots_connected,1}: 9057 {games_launched,1}: 1811 =INFO REPORT==== 30-Oct-2008::20:52:59 === module: stats elapsed: 60.000001 {total_bots_connected,2}: 24494 {bots_connected,2}: 6533 {games_launched,2}: 1198 barrier: reached target of 5000 50 games finished 50 games finished =INFO REPORT==== 30-Oct-2008::20:53:59 === module: stats elapsed: 59.996606 {total_bots_connected,3}: 25404 {total_bots_disconnected,3}: 742 {total_games_ended,3}: 188 {total_games_started,3}: 5000 50 games finished ... 1000 games finished dmb: exited successfully, 269.970918 seconds elapsed dmb: exited successfully, 269.971041 seconds elapsed dmb: exited successfully, 269.97109 seconds elapsed dmb: exited successfully, 269.971134 seconds elapsed dmb: exited successfully, 269.971178 seconds elapsed ok (1@REDACTED)3> =INFO REPORT==== 30-Oct-2008::20:54:59 === module: stats elapsed: 60.000917 {total_bots_connected,4}: 25404 {total_bots_disconnected,4}: 30404 {total_games_ended,4}: 5000 {total_games_started,4}: 5000 -- wagerlabs.com From ulf@REDACTED Fri Oct 31 00:13:39 2008 From: ulf@REDACTED (Ulf Wiger) Date: Fri, 31 Oct 2008 00:13:39 +0100 Subject: [erlang-questions] Question re console io in a distributed computation In-Reply-To: <44ed5e0f0810301113x7ca4344cje1f75a35054f9840@mail.gmail.com> References: <44ed5e0f0810241018y202b3dcdt4809b0d24c335c0f@mail.gmail.com> <490217AB.3050505@ericsson.com> <44ed5e0f0810241309h33d2f514q701c8b5fd84ae72d@mail.gmail.com> <44ed5e0f0810291144m5370c23euf827335a5eb7da2a@mail.gmail.com> <8209f740810291301h42c78cc2xf43749af389e624d@mail.gmail.com> <8209f740810291313k2277bb1y6a80a507ec1ea56@mail.gmail.com> <44ed5e0f0810301113x7ca4344cje1f75a35054f9840@mail.gmail.com> Message-ID: <8209f740810301613lf053041r3dc76006a1cfbfb9@mail.gmail.com> Whether there's a bug hidden in this, I'm not sure... but certainly some interesting interaction, and if it's documented anywhere, I have yet to find it. (: If you start erlang on the remote nodes using -noshell, it works as expected. Otherwise, it seems as if the shell steals all the input and starves the call to io:get_line() (or whichever input function you use). This starvation is certainly unexpected, since the output (the prompt) appears on the console, but the input request is never served. Calling io:get_line(Prompt) locally from the shell works, presumably because the shell is not consuming input while waiting for the shell evaluator to return. BR, Ulf W 2008/10/30 David Cabana : > "Very interesting...", you say. Does that mean you were you able to > reproduce what I encountered? > > I'm a relative newcomer to Erlang, so I am far more inclined to believe I'm > doing something wrong than to believe I've run into a bug. But if you're > running into the same problem, I begin to suspect I'm out of my league. Any > thoughts on what's going on? > > BTW, I'm running R12B-3 on Ubuntu Hardy. > > On Wed, Oct 29, 2008 at 4:13 PM, Ulf Wiger wrote: >> >> Hmm, sorry, I was too fast there. The prompt appeared all right, >> but the call never returned. Very interesting... >> >> BR, >> Ulf W >> >> 2008/10/29 Ulf Wiger : >> > Well, I'm not quite sure why it didn't work with the group leader >> > (I'd have to dig into that), but the 'user' trick ought to work with >> > the question as well. Compare: >> > >> > rpc:call(OtherNode, io, get_line, ["Hello? "]) >> > >> > with >> > >> > rpc:call(OtherNode, io, get_line, [user, "Hello? "]). >> > >> > The first version should give a prompt on the originating node, >> > and the second version should give it on the target node >> > (assuming, of course, that the target node has a shell.) >> > >> > BR, >> > Ulf W >> > >> > 2008/10/29 David Cabana : >> >> I've now played with both of Ulf's suggested approaches (using >> >> io:format(user, Fmt, Args), or alternatively, resetting processes group >> >> leaders) and have gotten output to go the correct consoles with both >> >> approaches. Which of course led to the next hurdle, reading input >> >> from the >> >> player console. >> >> >> >> The referee sent a question to the player, which was written to the >> >> player >> >> node's console. What I want to do is type a response in the player >> >> console, >> >> have it read, parsed, and sent to the referee, but so far no luck. My >> >> responses vanish into the ether, and the referee hangs waiting for >> >> players >> >> to respond. >> >> >> >> Here is how I am trying to respond. When the player process receives a >> >> question, it writes to the console and tries to read a line: >> >> >> >> >> >> io:fwrite("~n~s", [Question]), >> >> Reply = io:get_line(["= "]), >> >> >> >> > >> during >> >> io> >> >> I have also tried: >> >> io:fwrite(user, "~n~s", [Question]), >> >> Reply = io:get_line(user, ["= "]), >> >> >> >> >> >> It occurs to me that maybe I am going about this the wrong way? Perhaps >> >> my >> >> approch is misconceived. I have to believe that console IO in a >> >> client-server setting is pretty common. Can anyone point me in the >> >> right >> >> direction? >> >> >> >> Thank you, >> >> David >> >>> >> >>> On Fri, Oct 24, 2008 at 2:44 PM, Ulf Wiger (TN/EAB) >> >>> wrote: >> >>>> >> >>>> David Cabana skrev: >> >>>> > >> >>>>> >> >>>>> The messages flow correctly, but all the terminal io happens in >> >>>>> a single console, the one associated with the referee node. >> >>>>> >> >>>>> My question is how to get player output written to the console of >> >>>>> the >> >>>>> corresponding >> >>>>> player node? >> >>>> >> >>>> Use io:format(user, Fmt, Args) >> >>>> >> >>>> Alternatively, set the group leader of the process to some >> >>>> local process - e.g. the group leader of net_kernel >> >>>> (found by calling process_info(whereis(net_kernel),group_leader)). >> >>>> >> >>>> The group leader is the process that's handed all io messages. >> >>>> The rpc server deliberately sets the group leader of an rpc >> >>>> handler process to that of the caller on the originating node, >> >>>> since the remote node may not always have a tty to print to. >> >>>> When spawning, the group leader of the spawned process will >> >>>> be inherited from the parent. If you spawn a process on >> >>>> another node, it will still have the same group leader as >> >>>> the parent. >> >>>> >> >>>> The BIF group_leader(Pid,New_group_leader_pid) sets a new >> >>>> leader. >> >>>> >> >>>> BR, >> >>>> Ulf W >> >>> >> >> >> >> >> >> _______________________________________________ >> >> erlang-questions mailing list >> >> erlang-questions@REDACTED >> >> http://www.erlang.org/mailman/listinfo/erlang-questions >> >> >> > > > From q2h46uw02@REDACTED Fri Oct 31 07:33:46 2008 From: q2h46uw02@REDACTED (Kevin) Date: 31 Oct 2008 06:33:46 -0000 Subject: [erlang-questions] Badmatch doesn't propage up in an application? Message-ID: <21115-84049@sneakemail.com> Hello, I'm going to hope I don't have to include much code because its spread out quite a bit, but I have a feeling you guys can school me quickly on this problem. I have an erlang "application" behavior, that starts up a supervisor, thats starts up a gen_server, which calls a my library file. In this lib file there's badmatch error certain to happen. Listen = hydralib:get_first_arg(listen), get_first_arg actually returns {ok, Listen}. This was a very recent rewrite. Now when I run the app, i get only this in the error_log (actually the terminal) =INFO REPORT==== 31-Oct-2008::02:20:25 === application: hydra exited: {shutdown,{hydra,start,[normal,[]]}} type: temporary Well I had to go digging for this for a while, figure out what I had changed. If this was in production, and that badmatch was a hard to produce error, I NEVER would find it, and that worries me quite a lot. Am I doing it wrong? From adam@REDACTED Fri Oct 31 08:13:11 2008 From: adam@REDACTED (Adam Lindberg) Date: Fri, 31 Oct 2008 08:13:11 +0100 Subject: [erlang-questions] Badmatch doesn't propage up in an application? In-Reply-To: <21115-84049@sneakemail.com> References: <21115-84049@sneakemail.com> Message-ID: <6344005f0810310013v263903f1pf9fc9d79ec1b37e1@mail.gmail.com> On Fri, Oct 31, 2008 at 07:33, Kevin wrote: > In this lib file there's badmatch error certain to happen. > > Listen = hydralib:get_first_arg(listen), > > get_first_arg actually returns {ok, Listen}. This was a very recent > rewrite. > Is Listen bound at the time? If it's not, then there will be no bad match there. Cheers, Adam -------------- next part -------------- An HTML attachment was scrubbed... URL: From imre@REDACTED Fri Oct 31 08:55:36 2008 From: imre@REDACTED (Imre Palik) Date: Fri, 31 Oct 2008 09:55:36 +0200 Subject: [erlang-questions] Constraint satisfaction problems Message-ID: <3BE6DBA1F3BE9D4798255806113D56540F7FB8AA87@utx-exchange.utx.local> During playing with project Euler I solved a few constraint satisfaction problems with erlang. But whenever I code a solution, I have a really awkward feeling, that it should be possible to do better, but I don't know how. I tend to code a backtracking search with constraint propagation before every step. I model the constraint graph with digraph, but then the non-functional nature of the digraph package makes backtracking really awkward. Is there any better way to solve constraint satisfaction problems? What is the rationale behind those pesky side effects in digraph? Thx Imre From chsu79@REDACTED Fri Oct 31 09:40:56 2008 From: chsu79@REDACTED (Christian) Date: Fri, 31 Oct 2008 09:40:56 +0100 Subject: [erlang-questions] List to proplist? In-Reply-To: References: <6c2563b20810192156i7516e69aqb4d0eda2e1ee98d9@mail.gmail.com> <1225284106.31992.26.camel@seasc0642.dyn.rnd.as.sw.ericsson.se> <8FEABB6E-34FB-4B72-8F73-9989A48C767D@cs.otago.ac.nz> <200810301326.23513.bekesa@sch.bme.hu> Message-ID: > Between [E(X) || X (<-) F] > and [E(X) || X <- unfold(S, F')] > there is very little difference, > *provided* the compiler knows about unfold and treats it specially. Using QLC it is already possible to implement generators and use them with the LC syntax. From matthias@REDACTED Fri Oct 31 10:39:01 2008 From: matthias@REDACTED (Matthias Lang) Date: Fri, 31 Oct 2008 10:39:01 +0100 Subject: [erlang-questions] Types and specs [WAS: [enhancement] string:split/2] In-Reply-To: <48F43F2B.2030308@cs.ntua.gr> References: <6c2563b20810081642r2fbd1f14w8e3f7a5a2b71bcc4@mail.gmail.com> <48EF3D78.2060306@cs.ntua.gr> <795E68D8-738A-4EE5-88E4-0F607132026C@cs.otago.ac.nz> <48F2EF67.7010005@cs.ntua.gr> <4335FA0F-BE26-4000-B883-111F35F85058@cs.otago.ac.nz> <48F43F2B.2030308@cs.ntua.gr> Message-ID: <20081031093901.GA4191@contorpis.lisalinda.com> On Tuesday, October 14, Kostis Sagonas wrote: > (If you want to specify an improper list the closer you can get is to > employ the long and yucky type maybe_improper_list() cons_cell() would have been a more appetising name. Matthias From ingela@REDACTED Fri Oct 31 11:18:10 2008 From: ingela@REDACTED (Ingela Anderton Andin) Date: Fri, 31 Oct 2008 11:18:10 +0100 Subject: [erlang-questions] Setting socket buffers on SSL sockets In-Reply-To: References: Message-ID: <490ADB62.6070806@erix.ericsson.se> Hi! The old ssl implementation has many limitations when it comes to socket options, as it is a framework around the openssl implementation and the actual ssl-socket is buried deep down in openssl. The new ssl implementation on the other hand is an erlang solution that only uses openssl for payload encryption/decryption and sining/verification through the crypto-driver, but handles the communication part in erlang and the latest ssl-3.10 supports all inet-socket-options. (Will be released in R12B-5 on 5 of November) The new implementation still will have a few limitations and hence can not yet fully replace the old ssl but for the most common case scenarios it will probably do fine. Regards Ingela Erlang/OTP - Ericsson > Hi, > Is there any technical reason that socket buffers can't be set on SSL > sockets or is it just that it hasn't been implemented yet? > Thanks, > Colm From ingela@REDACTED Fri Oct 31 11:38:38 2008 From: ingela@REDACTED (Ingela Anderton Andin) Date: Fri, 31 Oct 2008 11:38:38 +0100 Subject: [erlang-questions] inets http client (Serge Aleynikov) In-Reply-To: References: Message-ID: <490AE02E.6040807@erix.ericsson.se> Hi! erlang-questions-request@REDACTED wrote: > Is there a way in http:request/4 call to limit the number of bytes > returned without waiting for the full content? I have a URL to query > frequently where the most relevant information is in the beginning of > the page and the tail of the document is useless but large. > > There is {full_result, boolean()} option (that doesn't seem to be > documented well, so I am unclear what it does) but I don't see how to > limit the number of bytes to be received. > > Serge > The option {full_result, false} will acctuly just strip-away the http-headers and return {ok, {Status, Body}} and it is something that exists for backward compatibility reasons. We ought to document it better or perhaps deprecate it. But we have not had time to focus on these types of issues when we have been swamped with more pressing things. What you could do is to use the option {sync, false} and when you received enough info in your process you can cancel the request. This way you would not have to receive the whole body but you may get a few more bytes than you are interested in. There is no way to receive just a specified number of bytes. Or perhaps you can utilize the ranged property in the HTTP-protocol as suggested by others. Regards Ingela Erlang/OTP - Ericsson From rvirding@REDACTED Fri Oct 31 11:41:20 2008 From: rvirding@REDACTED (Robert Virding) Date: Fri, 31 Oct 2008 11:41:20 +0100 Subject: [erlang-questions] Badmatch doesn't propage up in an application? In-Reply-To: <6344005f0810310013v263903f1pf9fc9d79ec1b37e1@mail.gmail.com> References: <21115-84049@sneakemail.com> <6344005f0810310013v263903f1pf9fc9d79ec1b37e1@mail.gmail.com> Message-ID: <3dbc6d1c0810310341q3e3cb805w6210475898d00307@mail.gmail.com> A corollary to Adam's reply is that to get the Listen value you seem to want, and which I assume you got before, you should change the code to: {ok,Listen} = hydralib:get_first_arg(listen), Robert 2008/10/31 Adam Lindberg > On Fri, Oct 31, 2008 at 07:33, Kevin wrote: > >> In this lib file there's badmatch error certain to happen. >> >> Listen = hydralib:get_first_arg(listen), >> >> get_first_arg actually returns {ok, Listen}. This was a very recent >> rewrite. >> > > Is Listen bound at the time? If it's not, then there will be no bad match > there. > > Cheers, > Adam > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From exta7@REDACTED Fri Oct 31 12:05:43 2008 From: exta7@REDACTED (Zvi) Date: Fri, 31 Oct 2008 04:05:43 -0700 (PDT) Subject: [erlang-questions] List to proplist? In-Reply-To: References: <6c2563b20810192156i7516e69aqb4d0eda2e1ee98d9@mail.gmail.com> <620F5FF0-93F8-4E0E-BBDA-5404E82BB054@cs.otago.ac.nz> <18696.21498.534675.651372@ornendil.du.uab.ericsson.se> <1225284106.31992.26.camel@seasc0642.dyn.rnd.as.sw.ericsson.se> <8FEABB6E-34FB-4B72-8F73-9989A48C767D@cs.otago.ac.nz> <200810301326.23513.bekesa@sch.bme.hu> Message-ID: <20263801.post@talk.nabble.com> Richard O'Keefe wrote: > > > On 31 Oct 2008, at 1:26 am, Andras Georgy Bekes wrote: >> Please note that I proposed an extension for list comprehensions that >> does the job of unfold/2 and more. > > Between [E(X) || X (<-) F] > and [E(X) || X <- unfold(S, F')] > there is very little difference, > *provided* the compiler knows about unfold and treats it specially. > > I've been thinking that we wouldn't really need > syntax for iterating over the elements of a tuple > if the compiler knew how to handle > [E(X) || X <- tuple_to_list(T)]. > I think compiler shouldn't be dependent on standard library, it should be vice versa. I for example don't like special treatment of lists:reverse. If there is some optimized feature in the compiler it should be made first-class citizen in the language via special syntax or new keyword or reusing already existing syntax/keywords if it's possible and make sense. For example instead of of writing lists:reverse(L) - you write ~L or something like this. When you see how frequently is lists:reverse used in the tail-recursive functions it really make sense. Richard O'Keefe wrote: > > It's a little more long-winded than > [E(X) || X <-: T] > but a lot more obvious. > Why there should be multiple variants for '<-' ? After all Erlang has dynamic typing, recognizing which collection type is T at run-time should cost just one compare. And if type guards or type spec is present, then it may be recognized at compile-time. Zvi -- View this message in context: http://www.nabble.com/List-to-proplist--tp20063268p20263801.html Sent from the Erlang Questions mailing list archive at Nabble.com. From bekesa@REDACTED Fri Oct 31 12:10:19 2008 From: bekesa@REDACTED (Andras Georgy Bekes) Date: Fri, 31 Oct 2008 12:10:19 +0100 Subject: [erlang-questions] [eeps] Request for comments on EEP-24 In-Reply-To: <290C1A92-FAA9-4A56-91E5-3284CD9B024C@cs.otago.ac.nz> References: <200810301214.05613.bekesa@sch.bme.hu> <290C1A92-FAA9-4A56-91E5-3284CD9B024C@cs.otago.ac.nz> Message-ID: <200810311210.20004.bekesa@sch.bme.hu> > What is the advantage of allowing expression syntax > for things that are not, and certainly will not be > evaluated as, expressions? As I stated, I primarily asked for being able to use = in custom attributes, as we need to have a custom attribute that is syntactically the same as -record/2 except for its name. I requested that if the F/A syntax will be allowed in attributes, also allow X=Y syntax. At least accept it by the parser (and maybe reject it at a later phase of compilation). I suggested allowing every standard operator JUST in order to remove the special treatment of F/A (and X=Y). If you think that converting every X op Y to {'op',X,Y} is a bad idea, I'm quite happy if the parser accepts X op Y and they're rejected at a later phase of compilation. But I already told this. I just want to write X=Y in a module attribute and use it by a parse transformation. But maybe other operators will be useful (for someone else), who knows? If the parser accepts every operator in module attributes, and later the compiler transforms F/A to {F,A} and rejects everything else, I'm happy with that. But don't settle with the current proposal, which states in the first paragraph: "The parser will convert this [i.e. F/N] to the existing {F,N}..." > What is the problem for which you wanted custom attributes > with arity higher than 1 and containing operators? For defining something that is not a record, but the syntax for defining a record is perfectly good for it (except for the 'record' name). The attribute will be used by a parse transform. Again, I'd be quite happy if the parser accepts module attributes with arity >1, even if they are rejected later. Georgy From bekesa@REDACTED Fri Oct 31 12:29:23 2008 From: bekesa@REDACTED (Andras Georgy Bekes) Date: Fri, 31 Oct 2008 12:29:23 +0100 Subject: [erlang-questions] List to proplist? In-Reply-To: References: <6c2563b20810192156i7516e69aqb4d0eda2e1ee98d9@mail.gmail.com> <200810301326.23513.bekesa@sch.bme.hu> Message-ID: <200810311229.23420.bekesa@sch.bme.hu> > Between [E(X) || X (<-) F] > and [E(X) || X <- unfold(S, F')] > there is very little difference, > *provided* the compiler knows about unfold and treats it specially. What do you mean by "treats it specially"? Do you mean that the result list of unfold(S,F') is not generated by calling unfold as a function call, but is generated element-by-element as the list-comprehension progresses? In that case, the difference is only syntactic I think, and I'm perfectly satisfied by both solutions. > I've been thinking that we wouldn't really need > syntax for iterating over the elements of a tuple > if the compiler knew how to handle > [E(X) || X <- tuple_to_list(T)]. The compiler handles this just right. What do you mean? Do you want the compiler to generate code that does not build the result list of tuple_to_list(T), but traverses the tuple element-by-element as the list-comprehension progresses? I don't think it makes a big difference, as tuples are usually small. On the other hand, the list generated by an unfold can be really big (even infinite, and a list comprehension should handle it without problems, if the resulting list is not used and therefore, not generated). > Using QLC it is already possible to implement generators and use them > with the LC syntax. But QLC is too bloated. You must write way more boilerplate code for QLC than for the above specially-treated unfold. Georgy From tobias.lindahl@REDACTED Fri Oct 31 12:32:27 2008 From: tobias.lindahl@REDACTED (Tobias Lindahl) Date: Fri, 31 Oct 2008 12:32:27 +0100 Subject: [erlang-questions] Types and specs [WAS: [enhancement] string:split/2] In-Reply-To: <20081031093901.GA4191@contorpis.lisalinda.com> References: <6c2563b20810081642r2fbd1f14w8e3f7a5a2b71bcc4@mail.gmail.com> <48EF3D78.2060306@cs.ntua.gr> <795E68D8-738A-4EE5-88E4-0F607132026C@cs.otago.ac.nz> <48F2EF67.7010005@cs.ntua.gr> <4335FA0F-BE26-4000-B883-111F35F85058@cs.otago.ac.nz> <48F43F2B.2030308@cs.ntua.gr> <20081031093901.GA4191@contorpis.lisalinda.com> Message-ID: <490AECCB.9010107@kreditor.se> Matthias Lang wrote: > On Tuesday, October 14, Kostis Sagonas wrote: > >> (If you want to specify an improper list the closer you can get is to >> employ the long and yucky type maybe_improper_list() > > cons_cell() would have been a more appetising name. It used to be called cons_or_nil() once upon a time, then it became possibly_improper_list() and ended up in maybe_improper_list(). The corresponding type to cons_cell() is the even nicer nonempty_maybe_improper_list(). I agree that the names are too verbose, I'm not even sure anymore how it happened. Tobias > > Matthias > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From bekesa@REDACTED Fri Oct 31 12:36:14 2008 From: bekesa@REDACTED (Andras Georgy Bekes) Date: Fri, 31 Oct 2008 12:36:14 +0100 Subject: [erlang-questions] List to proplist? In-Reply-To: <20263801.post@talk.nabble.com> References: <6c2563b20810192156i7516e69aqb4d0eda2e1ee98d9@mail.gmail.com> <20263801.post@talk.nabble.com> Message-ID: <200810311236.14809.bekesa@sch.bme.hu> On Friday 31 October 2008, Zvi wrote: > Why there should be multiple variants for '<-' ? After all Erlang has > dynamic typing, recognizing which collection type is T at run-time > should cost just one compare. This has been aswered long ago: http://www.erlang.org/pipermail/erlang-questions/2008-July/037072.html Georgy From saleyn@REDACTED Fri Oct 31 12:50:40 2008 From: saleyn@REDACTED (Serge Aleynikov) Date: Fri, 31 Oct 2008 07:50:40 -0400 Subject: [erlang-questions] inets http client (Serge Aleynikov) In-Reply-To: <490AE02E.6040807@erix.ericsson.se> References: <490AE02E.6040807@erix.ericsson.se> Message-ID: <490AF110.8000405@gmail.com> Thanks all who answered! Unfortunately the embedded http server I am pulling this data from doesn't support range headers. Or maybe I am using it incorrectly? Here's what request looked like: http:request(get, {Url, [{"Range", "bytes=0-100"}]}, [{body_format, binary},{full_result, false}]). Tried the same with Url="www.google.com" and a couple of other sites without success. I was hoping there was a way to do this in synchronous mode, so that I wouldn't need to assemble binary response chunks... Actually the full_result option is seems to be useful if you don't care about headers. Here's one correction to documentation: body_format() = string() | binary() should be: body_format() = string | binary Serge Ingela Anderton Andin wrote: > Hi! > > erlang-questions-request@REDACTED wrote: >> Is there a way in http:request/4 call to limit the number of bytes >> returned without waiting for the full content? I have a URL to query >> frequently where the most relevant information is in the beginning of >> the page and the tail of the document is useless but large. >> >> There is {full_result, boolean()} option (that doesn't seem to be >> documented well, so I am unclear what it does) but I don't see how to >> limit the number of bytes to be received. >> >> Serge >> > The option {full_result, false} will acctuly just strip-away the > http-headers and return > {ok, {Status, Body}} and it is something that exists for backward > compatibility reasons. > We ought to document it better or perhaps deprecate it. But we have not > had time to focus on > these types of issues when we have been swamped with more pressing > things. > > What you could do is to use the option {sync, false} and when you > received enough info in your > process you can cancel the request. This way you would not have to > receive the whole body but you > may get a few more bytes than you are interested in. There is no way to > receive just a specified number of bytes. > Or perhaps you can utilize the ranged property in the HTTP-protocol as > suggested by others. > > Regards Ingela Erlang/OTP - Ericsson From exta7@REDACTED Fri Oct 31 13:24:40 2008 From: exta7@REDACTED (Zvi) Date: Fri, 31 Oct 2008 05:24:40 -0700 (PDT) Subject: [erlang-questions] List to proplist? In-Reply-To: <200810311236.14809.bekesa@sch.bme.hu> References: <6c2563b20810192156i7516e69aqb4d0eda2e1ee98d9@mail.gmail.com> <620F5FF0-93F8-4E0E-BBDA-5404E82BB054@cs.otago.ac.nz> <18696.21498.534675.651372@ornendil.du.uab.ericsson.se> <1225284106.31992.26.camel@seasc0642.dyn.rnd.as.sw.ericsson.se> <8FEABB6E-34FB-4B72-8F73-9989A48C767D@cs.otago.ac.nz> <200810301326.23513.bekesa@sch.bme.hu> <20263801.post@talk.nabble.com> <200810311236.14809.bekesa@sch.bme.hu> Message-ID: <20264874.post@talk.nabble.com> While Richard is right about the tradeoff, I do not agree with his conclusions, that it's either/either. You can dance on both weddings. You can have both highly-readable, succint, expressive code (without memorizing uncomprehensive assembler/perl-like character sequences) and still leave the option to optimize for performance / code size for those wishing to do it. For example: when prototyping or working from shell, you will write: C = {1,2,3}. [X+1 || X<-C]. C = [1,2,3]. [X+1 || X<-C]. but when writing production code, you may write: f(C) when is_tuple(C) -> [X+1 || X<-C]. or f(C) when is_list(C) -> [X+1 || X<-C]. (another possibility is using type specs). Without a cheatshit, nobody will remeber all the spicies of <- , <=, {<-}, (<-). etc. Zvi Andras Georgy Bekes wrote: > > On Friday 31 October 2008, Zvi wrote: >> Why there should be multiple variants for '<-' ? After all Erlang has >> dynamic typing, recognizing which collection type is T at run-time >> should cost just one compare. > This has been aswered long ago: > http://www.erlang.org/pipermail/erlang-questions/2008-July/037072.html > > Georgy > -- View this message in context: http://www.nabble.com/List-to-proplist--tp20063268p20264874.html Sent from the Erlang Questions mailing list archive at Nabble.com. From exta7@REDACTED Fri Oct 31 13:37:40 2008 From: exta7@REDACTED (Zvi) Date: Fri, 31 Oct 2008 05:37:40 -0700 (PDT) Subject: [erlang-questions] List to proplist? In-Reply-To: <20264874.post@talk.nabble.com> References: <6c2563b20810192156i7516e69aqb4d0eda2e1ee98d9@mail.gmail.com> <620F5FF0-93F8-4E0E-BBDA-5404E82BB054@cs.otago.ac.nz> <18696.21498.534675.651372@ornendil.du.uab.ericsson.se> <1225284106.31992.26.camel@seasc0642.dyn.rnd.as.sw.ericsson.se> <8FEABB6E-34FB-4B72-8F73-9989A48C767D@cs.otago.ac.nz> <200810301326.23513.bekesa@sch.bme.hu> <20263801.post@talk.nabble.com> <200810311236.14809.bekesa@sch.bme.hu> <20264874.post@talk.nabble.com> Message-ID: <20265061.post@talk.nabble.com> Zvi wrote: > > ... cheatshit ... > Oops, this is a neologism I invented. I mean cheatsheet :-) Anyway, I think language design can't be done incrementally. Look at Erlang stdlib: http://blog.socklabs.com/2008/10/erlang_woes/ http://www.nabble.com/Hungarian-notation-for-Erlang---ETL-td14701912.html#a19822958 It follows the pattern of "maximum surprise" :-) All the issues of: * list/tuple/binary/etc. comprehensions * parallel comprehensions (i.e. something like [X+Y || X<-Xs ; Y<- Ys] ) * iterators/generators * real sequences (unlike lists:seq) * new collection types * built-in string type * built-in dictionary type (like in Javascript and Python) * built-in matrix/vector of floats type * implicit data-parallel constructs All these and other issues should be considered together, incremental changes to the language, only leading to Balkanization of the language (same as with libraries in Nick's blog post). Zvi -- View this message in context: http://www.nabble.com/List-to-proplist--tp20063268p20265061.html Sent from the Erlang Questions mailing list archive at Nabble.com. From bbmaj7@REDACTED Fri Oct 31 12:44:57 2008 From: bbmaj7@REDACTED (Richard Andrews) Date: Fri, 31 Oct 2008 04:44:57 -0700 (PDT) Subject: [erlang-questions] openpoker: 25k players on a physical machine Message-ID: <794169.97794.qm@web65502.mail.ac4.yahoo.com> > I'm launching 5000 games with 25000 players on 5 game servers and 5 > bot nodes, all running on the same physical machine. I'm hitting the > 65000 socket maximum so the way to scale out is by adding more > physical servers to the cluster. Can't you add another IP address to each host to get 64k connections per address? Surely the file descriptor table can be bigger than 64k. I thought UNIX systems put the maximum representable FD number at 1024x1024 and 64k was only a per-process limit FD limit. -- Rich Search 1000's of available singles in your area at the new Yahoo!7 Dating. Get Started http://au.dating.yahoo.com/?cid=53151&pid=1011 From bengt.kleberg@REDACTED Fri Oct 31 13:57:56 2008 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Fri, 31 Oct 2008 13:57:56 +0100 Subject: [erlang-questions] openpoker: 25k players on a physical machine In-Reply-To: <794169.97794.qm@web65502.mail.ac4.yahoo.com> References: <794169.97794.qm@web65502.mail.ac4.yahoo.com> Message-ID: <1225457876.12435.10.camel@seasc0642.dyn.rnd.as.sw.ericsson.se> Greetings, I think that the original poster meant 65000 sockets, not file descriptors. Your suggestion of adding IP addresses solves the socket problem. bengt On Fri, 2008-10-31 at 04:44 -0700, Richard Andrews wrote: > > I'm launching 5000 games with 25000 players on 5 game servers and 5 > > bot nodes, all running on the same physical machine. I'm hitting the > > 65000 socket maximum so the way to scale out is by adding more > > physical servers to the cluster. > > Can't you add another IP address to each host to get 64k connections per address? > Surely the file descriptor table can be bigger than 64k. > > I thought UNIX systems put the maximum representable FD number at 1024x1024 and 64k was only a per-process limit FD limit. > > -- > Rich > > > Search 1000's of available singles in your area at the new Yahoo!7 Dating. Get Started http://au.dating.yahoo.com/?cid=53151&pid=1011 > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From joelr1@REDACTED Fri Oct 31 14:03:52 2008 From: joelr1@REDACTED (Joel Reymont) Date: Fri, 31 Oct 2008 13:03:52 +0000 Subject: [erlang-questions] openpoker: 25k players on a physical machine In-Reply-To: <794169.97794.qm@web65502.mail.ac4.yahoo.com> References: <794169.97794.qm@web65502.mail.ac4.yahoo.com> Message-ID: <9E1353B9-FF5C-4850-9315-E9802C8FBA7E@gmail.com> On Oct 31, 2008, at 11:44 AM, Richard Andrews wrote: >> I thought UNIX systems put the maximum representable FD number at >> 1024x1024 and 64k was only a per-process limit FD limit. Aye! Big thanks to everyone for suggestions. I'll experiment with this shortly and report the results. -- wagerlabs.com From joelr1@REDACTED Fri Oct 31 14:05:26 2008 From: joelr1@REDACTED (Joel Reymont) Date: Fri, 31 Oct 2008 13:05:26 +0000 Subject: [erlang-questions] openpoker: 25k players on a physical machine In-Reply-To: References: <071EF7A6-A22E-4A42-98EF-51084F94C651@gmail.com> Message-ID: On Oct 31, 2008, at 12:17 PM, Tony Finch wrote: > bind different nodes to different IP > addresses. How is this done? -- wagerlabs.com From matthew@REDACTED Fri Oct 31 14:52:58 2008 From: matthew@REDACTED (Matthew Dempsky) Date: Fri, 31 Oct 2008 06:52:58 -0700 Subject: [erlang-questions] openpoker: 25k players on a physical machine In-Reply-To: References: <071EF7A6-A22E-4A42-98EF-51084F94C651@gmail.com> Message-ID: On Fri, Oct 31, 2008 at 6:05 AM, Joel Reymont wrote: > On Oct 31, 2008, at 12:17 PM, Tony Finch wrote: >> bind different nodes to different IP >> addresses. > > How is this done? Specify different IP addresses using the {ip, ip_address()} option to gen_tcp:listen/2. From rvirding@REDACTED Fri Oct 31 16:35:13 2008 From: rvirding@REDACTED (Robert Virding) Date: Fri, 31 Oct 2008 16:35:13 +0100 Subject: [erlang-questions] Types and specs [WAS: [enhancement] string:split/2] In-Reply-To: <490AECCB.9010107@kreditor.se> References: <6c2563b20810081642r2fbd1f14w8e3f7a5a2b71bcc4@mail.gmail.com> <48EF3D78.2060306@cs.ntua.gr> <795E68D8-738A-4EE5-88E4-0F607132026C@cs.otago.ac.nz> <48F2EF67.7010005@cs.ntua.gr> <4335FA0F-BE26-4000-B883-111F35F85058@cs.otago.ac.nz> <48F43F2B.2030308@cs.ntua.gr> <20081031093901.GA4191@contorpis.lisalinda.com> <490AECCB.9010107@kreditor.se> Message-ID: <3dbc6d1c0810310835l5fba3ba5ke382599c019cdb6b@mail.gmail.com> 2008/10/31 Tobias Lindahl > Matthias Lang wrote: > > On Tuesday, October 14, Kostis Sagonas wrote: > > > >> (If you want to specify an improper list the closer you can get is to > >> employ the long and yucky type maybe_improper_list() > > > > cons_cell() would have been a more appetising name. > > It used to be called cons_or_nil() once upon a time, then it became > possibly_improper_list() and ended up in maybe_improper_list(). > > The corresponding type to cons_cell() is the even nicer > nonempty_maybe_improper_list(). > > I agree that the names are too verbose, I'm not even sure anymore how it > happened. Perhaps it reflects the opinions of those who set the names that this is a very bad thing and shouldn't be done, hence the verbose support. Lists are nil terminated lists and cons cells are really list cells and should only be used as such. :-) Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: From colm.dougan@REDACTED Fri Oct 31 16:38:44 2008 From: colm.dougan@REDACTED (Colm Dougan) Date: Fri, 31 Oct 2008 15:38:44 +0000 Subject: [erlang-questions] HiPE code from i386 linux portable to amd64 linux? Message-ID: <24d4f39c0810310838h5bfc68e5yeedf855d6017b6a0@mail.gmail.com> Hi, If I compile using the +native option on a i386 Linux then should that be portable to an AMD64 linux? I assumed that it wouldn't but I don't see to get a warning when the module is loaded to indicate that it is incompatible so I wasn't sure if that meant that the native code was compatible with both or that it was silently falling back to non-native code. Is there any way to tell if a given beam contains native code that is incompatible.on a given erlang? Thanks, Colm From bekesa@REDACTED Fri Oct 31 16:54:15 2008 From: bekesa@REDACTED (Andras Georgy Bekes) Date: Fri, 31 Oct 2008 16:54:15 +0100 Subject: [erlang-questions] erlang:monitor(node, NodeName) could obsolate monitor_node/2 Message-ID: <200810311654.15586.bekesa@sch.bme.hu> Hi, >From the documentation: "erlang:monitor(Type, Item) -> MonitorRef: ... Currently only processes can be monitored, i.e. the only allowed Type is 'process', but other types may be allowed in the future." It seems to me that a new type 'node' could be allowed easily, using the node name as the reference to the monitored object. The delivered message obvoisly should be {'DOWN', MonitorRef, node, NodeName, Info}. This could completely take over the role of the current monitor_node/2, which could be obsolated. Questions: Are there any uses of the current monitor_node/2 that can not be done (easily) with the above extension of monitor/2 ? Are there any reasons for having two different monitoring methods for nodes and processes, besides history? If no, I think we should take this step. Georgy From ulf@REDACTED Fri Oct 31 17:22:42 2008 From: ulf@REDACTED (Ulf Wiger) Date: Fri, 31 Oct 2008 17:22:42 +0100 Subject: [erlang-questions] erlang:monitor(node, NodeName) could obsolate monitor_node/2 In-Reply-To: <200810311654.15586.bekesa@sch.bme.hu> References: <200810311654.15586.bekesa@sch.bme.hu> Message-ID: <8209f740810310922p6d67647l89e3bc918a901daf@mail.gmail.com> This seems reasonable. The function that's harder to replace is net_kernel:monitor_nodes(Bool), which also delivers {nodeup,N} messages. One could also argue that given the existence of net_kernel:monitor_nodes/[1,2], no other node monitoring function is really needed. ;-) BR, Ulf W 2008/10/31 Andras Georgy Bekes : > Hi, > > >From the documentation: > "erlang:monitor(Type, Item) -> MonitorRef: > ... > Currently only processes can be monitored, i.e. the only allowed Type > is 'process', but other types may be allowed in the future." > > It seems to me that a new type 'node' could be allowed easily, using the > node name as the reference to the monitored object. The delivered > message obvoisly should be {'DOWN', MonitorRef, node, NodeName, Info}. > > This could completely take over the role of the current monitor_node/2, > which could be obsolated. > > Questions: Are there any uses of the current monitor_node/2 that can not > be done (easily) with the above extension of monitor/2 ? > Are there any reasons for having two different monitoring methods for > nodes and processes, besides history? > > If no, I think we should take this step. > > Georgy > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From pguyot@REDACTED Fri Oct 31 17:45:38 2008 From: pguyot@REDACTED (Paul Guyot) Date: Fri, 31 Oct 2008 17:45:38 +0100 Subject: [erlang-questions] parse_transform and error messages Message-ID: <81459DF7-80C7-49D1-80E1-2A8E9E5D1EEA@kallisys.net> Hello, Is there a way to generate nice error messages (and warnings) with parse_transform? I currently raise a custom error to make compilation fail, but the error message could be nicer. For example, I wish I could raise an undefined_module error, so it would print a message just like erl_lint does when -module attribute isn't defined. Paul From q2h46uw02@REDACTED Fri Oct 31 18:47:06 2008 From: q2h46uw02@REDACTED (Kevin) Date: Fri, 31 Oct 2008 13:47:06 -0400 Subject: [erlang-questions] Badmatch doesn't propage up in an application? In-Reply-To: <3dbc6d1c0810310341q3e3cb805w6210475898d00307@mail.gmail.com> References: <21115-84049@sneakemail.com> <6344005f0810310013v263903f1pf9fc9d79ec1b37e1@mail.gmail.com> <3dbc6d1c0810310341q3e3cb805w6210475898d00307@mail.gmail.com> Message-ID: <26287-13175@sneakemail.com> Sorry, I meant "propagate" of course. Thats what happens when you cant sleep because of a problem, get back out of bed and post to a list. I'm very sure the problem is because of a bad match, because I can run that code without the application and it gives me a badmatch error. I also changed the function to return {ok, string} rather than just string, and, I actually fixed the problem by changing the code to {ok, Listen} Should I just assume that exceptions way down the "application stack" don't rise up to the level where they can be seen? Thats a scary thought. -ks Robert Virding rvirding-at-gmail.com |erlang| wrote: > A corollary to Adam's reply is that to get the Listen value you seem > to want, and which I assume you got before, you should change the code to: > > {ok,Listen} = hydralib:get_first_arg(listen), > > Robert > > 2008/10/31 Adam Lindberg > > > On Fri, Oct 31, 2008 at 07:33, Kevin > wrote: > > In this lib file there's badmatch error certain to happen. > > Listen = hydralib:get_first_arg(listen), > > get_first_arg actually returns {ok, Listen}. This was a very > recent rewrite. > > > Is Listen bound at the time? If it's not, then there will be no > bad match there. > > Cheers, > Adam > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > From dloutrein.lists@REDACTED Fri Oct 31 18:49:40 2008 From: dloutrein.lists@REDACTED (denis) Date: Fri, 31 Oct 2008 13:49:40 -0400 Subject: [erlang-questions] parse_transform and error messages In-Reply-To: <81459DF7-80C7-49D1-80E1-2A8E9E5D1EEA@kallisys.net> References: <81459DF7-80C7-49D1-80E1-2A8E9E5D1EEA@kallisys.net> Message-ID: <349ebab60810311049w736c9b5dha967e559db026a9c@mail.gmail.com> You can do it by adding the term {error, {Line, Module, Msg::io_list()}} into the AST. You can generate an error in a module, and look at the generated AST to have an example. Hope this helps Denis 2008/10/31 Paul Guyot : > Hello, > > Is there a way to generate nice error messages (and warnings) with > parse_transform? I currently raise a custom error to make compilation > fail, but the error message could be nicer. > > For example, I wish I could raise an undefined_module error, so it > would print a message just like erl_lint does when -module attribute > isn't defined. > > Paul > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From stondage123@REDACTED Fri Oct 31 17:52:41 2008 From: stondage123@REDACTED (Andrew Stone) Date: Fri, 31 Oct 2008 09:52:41 -0700 (PDT) Subject: [erlang-questions] erlang:monitor(node, NodeName) could obsolate monitor_node/2 References: <200810311654.15586.bekesa@sch.bme.hu> <8209f740810310922p6d67647l89e3bc918a901daf@mail.gmail.com> Message-ID: <523597.82645.qm@web35903.mail.mud.yahoo.com> I use net_kernel:monitor_nodes and it works just like expected. I think erlang:monitor_node should be deprecated. It isn't even as full featured as net_kernel:monitor_node, since it can't receive nodeup messages. However, I also like the idea to make monitor work on nodes also just for consistency sake. -Andrew ----- Original Message ---- From: Ulf Wiger To: Andras Georgy Bekes Cc: erlang-questions@REDACTED Sent: Friday, October 31, 2008 12:22:42 PM Subject: Re: [erlang-questions] erlang:monitor(node, NodeName) could obsolate monitor_node/2 This seems reasonable. The function that's harder to replace is net_kernel:monitor_nodes(Bool), which also delivers {nodeup,N} messages. One could also argue that given the existence of net_kernel:monitor_nodes/[1,2], no other node monitoring function is really needed. ;-) BR, Ulf W 2008/10/31 Andras Georgy Bekes : > Hi, > > >From the documentation: > "erlang:monitor(Type, Item) -> MonitorRef: > ... > Currently only processes can be monitored, i.e. the only allowed Type > is 'process', but other types may be allowed in the future." > > It seems to me that a new type 'node' could be allowed easily, using the > node name as the reference to the monitored object. The delivered > message obvoisly should be {'DOWN', MonitorRef, node, NodeName, Info}. > > This could completely take over the role of the current monitor_node/2, > which could be obsolated. > > Questions: Are there any uses of the current monitor_node/2 that can not > be done (easily) with the above extension of monitor/2 ? > Are there any reasons for having two different monitoring methods for > nodes and processes, besides history? > > If no, I think we should take this step. > > Georgy > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions From mikpe@REDACTED Fri Oct 31 19:29:20 2008 From: mikpe@REDACTED (Mikael Pettersson) Date: Fri, 31 Oct 2008 19:29:20 +0100 Subject: [erlang-questions] HiPE code from i386 linux portable to amd64 linux? In-Reply-To: <24d4f39c0810310838h5bfc68e5yeedf855d6017b6a0@mail.gmail.com> References: <24d4f39c0810310838h5bfc68e5yeedf855d6017b6a0@mail.gmail.com> Message-ID: <18699.20096.786338.864783@harpo.it.uu.se> Colm Dougan writes: > Hi, > > If I compile using the +native option on a i386 Linux then should that > be portable to an AMD64 linux? Not if the Erlang system runs in 64-bit mode. If it runs in 32-bit mode then the native code should be compatible. > I assumed that it wouldn't but I don't > see to get a warning when the module is loaded to indicate that it is > incompatible so I wasn't sure if that meant that the native code was > compatible with both or that it was silently falling back to > non-native code. You don't get a load-time warning if the BEAM file lacks native code for the current CPU type -- from the loader's perspective that's equivalent to a BEAM file with no native code at all. You do get a warning (and a fallback to interpreted code) if the BEAM file contains native code for the current CPU type, but the code is deemed incompatible (there's a checksum on a set of runtime system properties embedded in the object file). > Is there any way to tell if a given beam contains > native code that is incompatible.on a given erlang? Not in any easy-to-use way no. You currently have to load the module and observe any warnings, and observe if it executes in native or interpreted mode. The latter you can do by calling hipe_bifs:in_native/0 and checking its boolean return value. /Mikael From rec@REDACTED Fri Oct 31 20:10:50 2008 From: rec@REDACTED (Roger Critchlow) Date: Fri, 31 Oct 2008 13:10:50 -0600 Subject: [erlang-questions] Badmatch doesn't propage up in an application? In-Reply-To: <26287-13175@sneakemail.com> References: <21115-84049@sneakemail.com> <6344005f0810310013v263903f1pf9fc9d79ec1b37e1@mail.gmail.com> <3dbc6d1c0810310341q3e3cb805w6210475898d00307@mail.gmail.com> <26287-13175@sneakemail.com> Message-ID: <66d1c98f0810311210r445c9212oecddb7a9e31b2e08@mail.gmail.com> You want to start erlang with sasl to get the complete blow-by-blow commentary on your program's life and death. erl -boot start_sasl ... The mismatch report will be in there. -- rec -- On Fri, Oct 31, 2008 at 11:47 AM, Kevin wrote: > > Sorry, I meant "propagate" of course. Thats what happens when you cant > sleep because of a problem, get back out of bed and post to a list. > > I'm very sure the problem is because of a bad match, because I can run > that code without the application and it gives me a badmatch error. > I also changed the function to return {ok, string} rather than just > string, and, I actually fixed the problem by changing the code to {ok, > Listen} > > > Should I just assume that exceptions way down the "application stack" > don't rise up to the level where they can be seen? Thats a scary thought. > > -ks > > > > > Robert Virding rvirding-at-gmail.com |erlang| wrote: > > A corollary to Adam's reply is that to get the Listen value you seem > > to want, and which I assume you got before, you should change the code > to: > > > > {ok,Listen} = hydralib:get_first_arg(listen), > > > > Robert > > > > 2008/10/31 Adam Lindberg > > > > > > On Fri, Oct 31, 2008 at 07:33, Kevin > > wrote: > > > > In this lib file there's badmatch error certain to happen. > > > > Listen = hydralib:get_first_arg(listen), > > > > get_first_arg actually returns {ok, Listen}. This was a very > > recent rewrite. > > > > > > Is Listen bound at the time? If it's not, then there will be no > > bad match there. > > > > Cheers, > > Adam > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rvirding@REDACTED Fri Oct 31 22:51:38 2008 From: rvirding@REDACTED (Robert Virding) Date: Fri, 31 Oct 2008 22:51:38 +0100 Subject: [erlang-questions] New version of Leex - a lexical analyser generator Message-ID: <3dbc6d1c0810311451u325ca9b7w5c6a4880ac968636@mail.gmail.com> I have just released version 0.2 of Leex. New features and changes from the previous version are: - The structure of the release is such that you can now drop straight into your ERL_LIBS directory. - Added includefile option. Search for include file in current directory or leex/include lib dir. - Restored text file version of documentation until edoc and I are in agreement. - Upgraded erlang_scan.xrl to full erlang tokeniser. - Now use line number of token start. - Fixed a bug where if the file ended in an incomplete token this was ignored and no error returned. You can get from either trapexit.org or github. The links are: http://forum.trapexit.org/viewtopic.php?p=44233#44233 http://github.com/rvirding/leex/tree Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: From dot@REDACTED Fri Oct 31 13:17:30 2008 From: dot@REDACTED (Tony Finch) Date: Fri, 31 Oct 2008 12:17:30 +0000 Subject: [erlang-questions] openpoker: 25k players on a physical machine In-Reply-To: <071EF7A6-A22E-4A42-98EF-51084F94C651@gmail.com> References: <071EF7A6-A22E-4A42-98EF-51084F94C651@gmail.com> Message-ID: On Thu, 30 Oct 2008, Joel Reymont wrote: > > I'm launching 5000 games with 25000 players on 5 game servers and 5 > bot nodes, all running on the same physical machine. I'm hitting the > 65000 socket maximum so the way to scale out is by adding more > physical servers to the cluster. If you are running out of port numbers you could try configuring more IP addresses on the machine, and bind different nodes to different IP addresses. Tony. -- f.anthony.n.finch http://dotat.at/ FAEROES: NORTHERLY BACKING SOUTHWESTERLY 5 TO 7, PERHAPS GALE 8 LATER. MODERATE OR ROUGH, OCCASIONALLY VERY ROUGH LATER. SHOWERS THEN RAIN. MODERATE OR GOOD. From vances@REDACTED Fri Oct 31 18:34:26 2008 From: vances@REDACTED (Vance Shipley) Date: Fri, 31 Oct 2008 13:34:26 -0400 Subject: [erlang-questions] Badmatch doesn't propage up in an application? In-Reply-To: <21115-84049@sneakemail.com> References: <21115-84049@sneakemail.com> Message-ID: <20081031173425.GB2638@h216-235-12-168.host.egate.net> Kevin, You shouldn't worry too much. The supervisor traps exits during initialization itself and therefore masks things a bit. Outside of that you will get a badmatch which will be much more explicit. -Vance On Fri, Oct 31, 2008 at 06:33:46AM -0000, Kevin wrote: } Now when I run the app, i get only this in the error_log (actually the terminal) } } =INFO REPORT==== 31-Oct-2008::02:20:25 === } application: hydra } exited: {shutdown,{hydra,start,[normal,[]]}} } type: temporary } } } Well I had to go digging for this for a while, figure out what I had changed. If this was in production, and that badmatch was a hard to produce error, I NEVER would find it, and that worries me quite a lot. } } Am I doing it wrong?